From 0f0e838a1f76f605051936ad6c7d47e149a9b05e Mon Sep 17 00:00:00 2001 From: fiaxh Date: Fri, 13 Sep 2019 12:28:44 +0200 Subject: Deactivate spinner in file widget as soon as its not displayed anymore (CPU usage) --- main/src/ui/conversation_selector/conversation_selector_row.vala | 2 +- main/src/ui/conversation_summary/file_widget.vala | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/main/src/ui/conversation_selector/conversation_selector_row.vala b/main/src/ui/conversation_selector/conversation_selector_row.vala index c7331b31..8d601309 100644 --- a/main/src/ui/conversation_selector/conversation_selector_row.vala +++ b/main/src/ui/conversation_selector/conversation_selector_row.vala @@ -136,7 +136,7 @@ public class ConversationSelectorRow : ListBoxRow { nick_label.label = last_message.direction == Message.DIRECTION_SENT ? _("Me") + ": " : ""; } - name_label.attributes.filter((attr) => attr.equal(attr_style_new(Pango.Style.ITALIC))); + message_label.attributes.filter((attr) => attr.equal(attr_style_new(Pango.Style.ITALIC))); message_label.label = Util.summarize_whitespaces_to_space(last_message.body); break; case FileItem.TYPE: diff --git a/main/src/ui/conversation_summary/file_widget.vala b/main/src/ui/conversation_summary/file_widget.vala index 178eb31d..7e662917 100644 --- a/main/src/ui/conversation_summary/file_widget.vala +++ b/main/src/ui/conversation_summary/file_widget.vala @@ -151,7 +151,7 @@ public class FileWidget : Box { main_box = new Box(Orientation.HORIZONTAL, 10) { halign=Align.FILL, hexpand=true, visible=true }; content_type_image = new Image.from_icon_name(icon_name, IconSize.DND) { opacity=0.5, visible=true }; download_image = new Image.from_icon_name("dino-file-download-symbolic", IconSize.DND) { opacity=0.7, visible=true }; - spinner = new Spinner() { active=true, visible=true }; + spinner = new Spinner() { visible=true }; EventBox stack_event_box = new EventBox() { visible=true }; image_stack = new Stack() { transition_type = StackTransitionType.CROSSFADE, transition_duration=50, valign=Align.CENTER, visible=true }; @@ -259,6 +259,8 @@ public class FileWidget : Box { state = State.IMAGE; } + spinner.active = false; // A hidden spinning spinner still uses CPU. Deactivate asap + string? mime_description = file_transfer.mime_type != null ? ContentType.get_description(file_transfer.mime_type) : null; switch (file_transfer.state) { @@ -268,6 +270,7 @@ public class FileWidget : Box { break; case FileTransfer.State.IN_PROGRESS: mime_label.label = "" + _("Downloading %s…").printf(get_size_string(file_transfer.size)) + ""; + spinner.active = true; image_stack.set_visible_child_name("spinner"); break; case FileTransfer.State.NOT_STARTED: -- cgit v1.2.3-70-g09d2