[geary: 1/3] conversation-email-row: use is-expanded to add/remove css class




commit b978f69341ac1f984756b90864558fe690dc03ef
Author: Julian Sparber <julian sparber net>
Date:   Thu Oct 22 15:47:09 2020 +0200

    conversation-email-row: use is-expanded to add/remove css class

 src/client/conversation-viewer/conversation-list-box.vala | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)
---
diff --git a/src/client/conversation-viewer/conversation-list-box.vala 
b/src/client/conversation-viewer/conversation-list-box.vala
index 7d0c94aff..5bad2d103 100644
--- a/src/client/conversation-viewer/conversation-list-box.vala
+++ b/src/client/conversation-viewer/conversation-list-box.vala
@@ -284,6 +284,7 @@ public class ConversationListBox : Gtk.ListBox, Geary.BaseInterface {
             }
             protected set {
                 this._is_expanded = value;
+                notify_property("is-expanded");
             }
         }
         private bool _is_expanded = false;
@@ -301,6 +302,7 @@ public class ConversationListBox : Gtk.ListBox, Geary.BaseInterface {
         protected ConversationRow(Geary.Email? email) {
             base_ref();
             this.email = email;
+            notify["is-expanded"].connect(update_css_class);
             show();
         }
 
@@ -325,6 +327,13 @@ public class ConversationListBox : Gtk.ListBox, Geary.BaseInterface {
             this.size_allocate.connect(on_size_allocate);
         }
 
+        private void update_css_class() {
+            if (this.is_expanded)
+                get_style_context().add_class(EXPANDED_CLASS);
+            else
+                get_style_context().remove_class(EXPANDED_CLASS);
+        }
+
         protected inline void set_style_context_class(string class_name, bool value) {
             if (value) {
                 get_style_context().add_class(class_name);
@@ -392,10 +401,8 @@ public class ConversationListBox : Gtk.ListBox, Geary.BaseInterface {
 
         private inline void update_row_expansion() {
             if (this.is_expanded || this.is_pinned) {
-                get_style_context().add_class(EXPANDED_CLASS);
                 this.view.expand_email();
             } else {
-                get_style_context().remove_class(EXPANDED_CLASS);
                 this.view.collapse_email();
             }
         }
@@ -436,7 +443,6 @@ public class ConversationListBox : Gtk.ListBox, Geary.BaseInterface {
             base(view.referred);
             this.view = view;
             this.is_expanded = true;
-            get_style_context().add_class(EXPANDED_CLASS);
             add(this.view);
         }
 


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]