diff options
Diffstat (limited to 'main/src/ui/conversation_content_view')
-rw-r--r-- | main/src/ui/conversation_content_view/file_default_widget.vala | 14 | ||||
-rw-r--r-- | main/src/ui/conversation_content_view/file_widget.vala | 5 |
2 files changed, 16 insertions, 3 deletions
diff --git a/main/src/ui/conversation_content_view/file_default_widget.vala b/main/src/ui/conversation_content_view/file_default_widget.vala index 02249b3f..aaf36b57 100644 --- a/main/src/ui/conversation_content_view/file_default_widget.vala +++ b/main/src/ui/conversation_content_view/file_default_widget.vala @@ -39,7 +39,7 @@ public class FileDefaultWidget : Box { }); } - public void update_file_info(string? mime_type, FileTransfer.State state, int64 size) { + public void update_file_info(string? mime_type, FileTransfer.State state, bool direction, int64 size, int64 transferred_bytes) { this.state = state; spinner.stop(); // A hidden spinning spinner still uses CPU. Deactivate asap @@ -61,7 +61,17 @@ public class FileDefaultWidget : Box { popover_menu.closed.connect(on_pointer_left); break; case FileTransfer.State.IN_PROGRESS: - mime_label.label = _("Downloading %s…").printf(get_size_string(size)); + if (direction == FileTransfer.DIRECTION_RECEIVED) { + if (size > 0) { + int64 progress = transferred_bytes * 100 / size; + mime_label.label = _("Downloading %s… (%u%%)").printf(get_size_string(size), progress); + } else { + mime_label.label = _("Downloading %s…").printf(get_size_string(size)); + } + } else { + int64 progress = transferred_bytes * 100 / size; + mime_label.label = _("Uploading %s… (%u%%)").printf(get_size_string(size), progress); + } spinner.start(); image_stack.set_visible_child_name("spinner"); diff --git a/main/src/ui/conversation_content_view/file_widget.vala b/main/src/ui/conversation_content_view/file_widget.vala index 583609d2..1cf84eb4 100644 --- a/main/src/ui/conversation_content_view/file_widget.vala +++ b/main/src/ui/conversation_content_view/file_widget.vala @@ -196,6 +196,7 @@ public class FileDefaultWidgetController : Object { private FileTransfer? file_transfer; public string file_transfer_state { get; set; } public string file_transfer_mime_type { get; set; } + public int64 file_transfer_transferred_bytes { get; set; } private FileTransfer.State state; @@ -206,6 +207,7 @@ public class FileDefaultWidgetController : Object { this.notify["file-transfer-state"].connect(update_file_info); this.notify["file-transfer-mime-type"].connect(update_file_info); + this.notify["file-transfer-transferred-bytes"].connect(update_file_info); } public void set_file_transfer(FileTransfer file_transfer) { @@ -215,13 +217,14 @@ public class FileDefaultWidgetController : Object { file_transfer.bind_property("state", this, "file-transfer-state"); file_transfer.bind_property("mime-type", this, "file-transfer-mime-type"); + file_transfer.bind_property("transferred-bytes", this, "file-transfer-transferred-bytes"); update_file_info(); } private void update_file_info() { state = file_transfer.state; - widget.update_file_info(file_transfer.mime_type, file_transfer.state, file_transfer.size); + widget.update_file_info(file_transfer.mime_type, file_transfer.state, file_transfer.direction, file_transfer.size, file_transfer.transferred_bytes); } private void on_clicked() { |