[dconf-editor] Change ModificationsRevealer look.



commit 556be6cd73dace0399a6666b867b10bdd8939585
Author: Arnaud Bonatti <arnaud bonatti gmail com>
Date:   Tue Jun 28 15:43:37 2016 +0200

    Change ModificationsRevealer look.

 editor/modifications-revealer.ui   |   43 +++++++++++++++++++++++++-----------
 editor/modifications-revealer.vala |   25 +++++++++++++++++++++
 2 files changed, 55 insertions(+), 13 deletions(-)
---
diff --git a/editor/modifications-revealer.ui b/editor/modifications-revealer.ui
index d64debf..d4cfef4 100644
--- a/editor/modifications-revealer.ui
+++ b/editor/modifications-revealer.ui
@@ -3,27 +3,51 @@
   <!-- 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>
         <child>
+          <object class="GtkLabel" id="label">
+            <property name="visible">True</property>
+            <property name="margin-left">6</property><!-- GtkActionBar creates a GtkBox which "spacing" 
property is not editable -->
+            <property name="margin-right">6</property>
+          </object>
+        </child>
+        <child>
           <object class="GtkButton" id="dismiss-button">
             <property name="visible">True</property>
-            <property name="label" translatable="yes">Dismiss</property>
             <signal name="clicked" handler="dismiss_delayed_settings"/>
+            <style>
+              <class name="image-button"/>
+            </style>
+            <child>
+              <object class="GtkImage">
+                <property name="visible">True</property>
+                <property name="icon-name">window-close-symbolic</property>
+                <property name="icon-size">1</property>
+              </object>
+            </child>
           </object>
+          <packing>
+            <property name="pack-type">end</property>
+          </packing>
         </child>
         <child>
-          <object class="GtkLabel" id="label">
+          <object class="GtkSeparator">
             <property name="visible">True</property>
-            <property name="margin-left">6</property><!-- GtkActionBar creates a GtkBox which "spacing" 
property is not editable -->
-            <property name="margin-right">6</property>
+            <property name="orientation">horizontal</property>
           </object>
+          <packing>
+            <property name="pack-type">end</property>
+          </packing>
         </child>
         <child>
-          <object class="GtkButton" id="apply-button">
+          <object class="GtkModelButton" id="apply_button">
             <property name="visible">True</property>
-            <property name="label" translatable="yes">Apply</property>
+            <property name="text" translatable="yes">Apply</property>
+            <property name="centered">True</property>
+            <property name="iconic">True</property>
             <signal name="clicked" handler="apply_delayed_settings"/>
             <style>
               <class name="suggested-action"/>
@@ -36,11 +60,4 @@
       </object>
     </child>
   </template>
-  <object class="GtkSizeGroup">
-    <property name="mode">both</property>
-    <widgets>
-      <widget name="dismiss-button"/>
-      <widget name="apply-button"/>
-    </widgets>
-  </object>
 </interface>
diff --git a/editor/modifications-revealer.vala b/editor/modifications-revealer.vala
index 1c0d93f..75727d1 100644
--- a/editor/modifications-revealer.vala
+++ b/editor/modifications-revealer.vala
@@ -21,6 +21,9 @@ using Gtk;
 class ModificationsRevealer : Revealer
 {
     [GtkChild] private Label label;
+    [GtkChild] private ModelButton apply_button;
+
+    private ThemedIcon apply_button_icon = new ThemedIcon.from_names ({"object-select-symbolic"});
 
     private DConf.Client dconf_client = new DConf.Client ();
 
@@ -30,6 +33,28 @@ class ModificationsRevealer : Revealer
     public signal void reload ();
 
     /*\
+    * * Window management callbacks
+    \*/
+
+    [GtkCallback]
+    private void on_size_allocate (Allocation allocation)
+    {
+        StyleContext context = apply_button.get_style_context ();
+        if (allocation.width < 900)
+        {
+            context.remove_class ("text-button");
+            apply_button.icon = apply_button_icon;
+            context.add_class ("image-button");
+        }
+        else
+        {
+            context.remove_class ("image-button");
+            apply_button.icon = null;
+            context.add_class ("text-button");
+        }
+    }
+
+    /*\
     * * Public calls
     \*/
 


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