diff options
| author | Xavier Del Campo Romero <xavi.dcr@tutanota.com> | 2023-10-04 01:23:11 +0200 |
|---|---|---|
| committer | Xavier Del Campo Romero <xavi.dcr@tutanota.com> | 2023-10-09 16:38:02 +0200 |
| commit | 6d3aef271875eba7a3867259f2089e3801141b19 (patch) | |
| tree | fb8d639dd84c3c0242cd8bf5ea8f73b83a4c0bc8 /main/src/ui/conversation_content_view/file_default_widget.vala | |
| parent | f3c50f07395f0e3331c4389015fe26ef53213c83 (diff) | |
| download | dino-6d3aef271875eba7a3867259f2089e3801141b19.tar.gz | |
Show file upload/download progress
Fixes upstream issue #1350.
Notes:
Image uploads were incorrectly handled by Dino, as they were always
reported as completed even if they were not, maybe so as to show the
image preview from the start. Now, Dino shows the upload progress for
all file types, and the image is only shown when completed.
Diffstat (limited to 'main/src/ui/conversation_content_view/file_default_widget.vala')
| -rw-r--r-- | main/src/ui/conversation_content_view/file_default_widget.vala | 15 |
1 files changed, 13 insertions, 2 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 638dab15..79d22fe4 100644 --- a/main/src/ui/conversation_content_view/file_default_widget.vala +++ b/main/src/ui/conversation_content_view/file_default_widget.vala @@ -31,7 +31,8 @@ public class FileDefaultWidget : EventBox { cancel_button = new ModelButton() { text=_("Cancel"), visible=true }; } - public void update_file_info(string? mime_type, FileTransfer.State state, long size) { + public void update_file_info(string? mime_type, uint64 transferred_bytes, + bool direction, FileTransfer.State state, long size) { this.state = state; spinner.active = false; // A hidden spinning spinner still uses CPU. Deactivate asap @@ -58,7 +59,17 @@ public class FileDefaultWidget : EventBox { popover_menu.closed.connect(on_pointer_left); break; case FileTransfer.State.IN_PROGRESS: - mime_label.label = _("Downloading %s…").printf(get_size_string(size)); + uint progress = 0; + + if (size > 0) + progress = (uint)((transferred_bytes * (uint64)100) / (uint64)size); + + if (direction == FileTransfer.DIRECTION_SENT) { + mime_label.label = _("Uploading %s (%u%%)…").printf(get_size_string(size), progress); + } + else { + mime_label.label = _("Downloading %s (%u%%)…").printf(get_size_string(size), progress); + } spinner.active = true; image_stack.set_visible_child_name("spinner"); |
