[geary/wip/765516-gtk-widget-conversation-viewer: 142/142] Minor code tidy.



commit 878f0c42cb22e3af9247c12ad60cb57e14e0f824
Author: Michael James Gratton <mike vee net>
Date:   Thu Aug 25 22:27:27 2016 +1000

    Minor code tidy.

 .../conversation-viewer/conversation-message.vala  |   36 ++++++++-----------
 1 files changed, 15 insertions(+), 21 deletions(-)
---
diff --git a/src/client/conversation-viewer/conversation-message.vala 
b/src/client/conversation-viewer/conversation-message.vala
index d3417a3..c9f5ffe 100644
--- a/src/client/conversation-viewer/conversation-message.vala
+++ b/src/client/conversation-viewer/conversation-message.vala
@@ -334,26 +334,9 @@ public class ConversationMessage : Gtk.Grid {
      * Shows the complete message and hides the preview headers.
      */
     public void show_message_body(bool include_transitions=true) {
-        Gtk.RevealerTransitionType revealer = preview_revealer.get_transition_type();
-        if (!include_transitions) {
-            preview_revealer.set_transition_type(Gtk.RevealerTransitionType.NONE);
-        }
-        preview_revealer.set_reveal_child(false);
-        preview_revealer.set_transition_type(revealer);
-
-        revealer = header_revealer.get_transition_type();
-        if (!include_transitions) {
-            header_revealer.set_transition_type(Gtk.RevealerTransitionType.NONE);
-        }
-        header_revealer.set_reveal_child(true);
-        header_revealer.set_transition_type(revealer);
-
-        revealer = body_revealer.get_transition_type();
-        if (!include_transitions) {
-            body_revealer.set_transition_type(Gtk.RevealerTransitionType.NONE);
-        }
-        body_revealer.set_reveal_child(true);
-        body_revealer.set_transition_type(revealer);
+        set_revealer(this.preview_revealer, false, include_transitions);
+        set_revealer(this.header_revealer, true, include_transitions);
+        set_revealer(this.body_revealer, true, include_transitions);
     }
 
     /**
@@ -1151,7 +1134,7 @@ public class ConversationMessage : Gtk.Grid {
         }
         return false;
     }
-    
+
     private void assemble_uris(string[] parts, out string full, out string short_) {
         full = parts[1] + parts[2];
         short_ = parts[2];
@@ -1176,6 +1159,17 @@ public class ConversationMessage : Gtk.Grid {
         return image;
     }
 
+    private inline void set_revealer(Gtk.Revealer revealer,
+                                     bool expand,
+                                     bool use_transition) {
+        Gtk.RevealerTransitionType transition = revealer.get_transition_type();
+        if (!use_transition) {
+            revealer.set_transition_type(Gtk.RevealerTransitionType.NONE);
+        }
+        revealer.set_reveal_child(expand);
+        revealer.set_transition_type(transition);
+    }
+
     private static void on_show_quote_clicked(WebKit.DOM.Element element,
                                               WebKit.DOM.Event event) {
         try {


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