[dconf-editor] Use set_window_size for old adaptative stuff.



commit 2512e2fac7b8c20eaf62d6115c156a859e721167
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date:   Sun Nov 25 17:57:55 2018 +0100

    Use set_window_size for old adaptative stuff.

 editor/modifications-revealer.ui   |  1 -
 editor/modifications-revealer.vala | 57 +++++++++++++++++---------------------
 2 files changed, 25 insertions(+), 33 deletions(-)
---
diff --git a/editor/modifications-revealer.ui b/editor/modifications-revealer.ui
index a473505..72ee5e6 100644
--- a/editor/modifications-revealer.ui
+++ b/editor/modifications-revealer.ui
@@ -3,7 +3,6 @@
   <!-- interface-requires gtk+ 3.0 -->
   <template class="ModificationsRevealer" parent="GtkRevealer">
     <property name="reveal-child">False</property>
-    <signal name="size-allocate" handler="on_size_allocate"/>
     <child>
       <object class="GtkActionBar">
         <property name="visible">True</property>
diff --git a/editor/modifications-revealer.vala b/editor/modifications-revealer.vala
index 67d18a7..3eceac9 100644
--- a/editor/modifications-revealer.vala
+++ b/editor/modifications-revealer.vala
@@ -31,16 +31,36 @@ private class ModificationsRevealer : Revealer, AdaptativeWidget
         }
     }
 
+    StyleContext apply_button_context;
     private bool disable_action_bar = false;
+    private bool short_size_button = false;
     private void set_window_size (AdaptativeWidget.WindowSize new_size)
     {
         bool _disable_action_bar = AdaptativeWidget.WindowSize.is_extra_thin (new_size)
                                 || AdaptativeWidget.WindowSize.is_extra_flat (new_size);
-        if (disable_action_bar == _disable_action_bar)
-            return;
-        disable_action_bar = _disable_action_bar;
+        if (disable_action_bar != _disable_action_bar)
+        {
+            disable_action_bar = _disable_action_bar;
+            update ();
+        }
 
-        update ();
+        bool _short_size_button = AdaptativeWidget.WindowSize.is_quite_thin (new_size);
+        if (short_size_button != _short_size_button)
+        {
+            short_size_button = _short_size_button;
+            if (_short_size_button)
+            {
+                apply_button_context.remove_class ("text-button");
+                apply_button.icon = apply_button_icon;
+                apply_button_context.add_class ("image-button");
+            }
+            else
+            {
+                apply_button_context.remove_class ("image-button");
+                apply_button.icon = null;
+                apply_button_context.add_class ("text-button");
+            }
+        }
     }
 
     [GtkChild] private Label label;
@@ -53,38 +73,11 @@ private class ModificationsRevealer : Revealer, AdaptativeWidget
 
     construct
     {
+        apply_button_context = apply_button.get_style_context ();
         apply_button.icon = null;
         apply_button.get_style_context ().add_class ("text-button");
     }
 
-    /*\
-    * * Window management callbacks
-    \*/
-
-    [GtkCallback]
-    private void on_size_allocate (Allocation allocation)   // TODO remaining warnings printed on redim when 
allocation width passes 900
-    {
-        StyleContext context = apply_button.get_style_context ();
-        if (allocation.width < 900)
-        {
-            if (apply_button.icon == null)
-            {
-                context.remove_class ("text-button");
-                apply_button.icon = apply_button_icon;
-                context.add_class ("image-button");
-            }
-        }
-        else
-        {
-            if (apply_button.icon != null)
-            {
-                context.remove_class ("image-button");
-                apply_button.icon = null;
-                context.add_class ("text-button");
-            }
-        }
-    }
-
     /*\
     * * Reseting objects
     \*/


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