[rygel] ui: Use Switch instead of checkbox



commit 4f0c4ce7e972db3683bdb6fa18e25f7c8760c867
Author: Jens Georg <jensg openismus com>
Date:   Tue Apr 30 04:57:38 2013 +0200

    ui: Use Switch instead of checkbox

 configure.ac                         |    2 +-
 data/rygel-preferences.ui            |   81 +++++++++++++++++++---------------
 src/ui/rygel-preferences-dialog.vala |   14 +++---
 3 files changed, 55 insertions(+), 42 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index fa2d52e..eb9af22 100644
--- a/configure.ac
+++ b/configure.ac
@@ -43,7 +43,7 @@ GIO_REQUIRED=2.26
 GEE_REQUIRED=0.8.0
 UUID_REQUIRED=1.41.3
 LIBSOUP_REQUIRED=2.34.0
-GTK_REQUIRED=2.90.3
+GTK_REQUIRED=3.0
 
 dnl Additional requirements for media-export plugin
 GSTREAMER_TAG_REQUIRED=1.0
diff --git a/data/rygel-preferences.ui b/data/rygel-preferences.ui
index 244f3b9..fada139 100644
--- a/data/rygel-preferences.ui
+++ b/data/rygel-preferences.ui
@@ -6,9 +6,6 @@
     <property name="step_increment">1</property>
     <property name="page_increment">10</property>
   </object>
-  <object class="GtkSizeGroup" id="general-labels-sizegroup">
-    <property name="mode">both</property>
-  </object>
   <object class="GtkListStore" id="iface-liststore">
     <columns>
       <!-- column-name interface -->
@@ -38,28 +35,6 @@
             <property name="row_spacing">12</property>
             <property name="column_spacing">12</property>
             <child>
-              <object class="GtkCheckButton" id="upnp-checkbutton">
-                <property name="label" translatable="yes">_Share media through DLNA</property>
-                <property name="use_action_appearance">False</property>
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="receives_default">False</property>
-                <property name="has_tooltip">True</property>
-                <property name="tooltip_markup" translatable="yes">Enable sharing of media, such as photos, 
videos and music, with DLNA</property>
-                <property name="tooltip_text" translatable="yes">Enable sharing of media, such as photos, 
videos and music, with DLNA</property>
-                <property name="use_action_appearance">False</property>
-                <property name="use_underline">True</property>
-                <property name="xalign">0</property>
-                <property name="draw_indicator">True</property>
-              </object>
-              <packing>
-                <property name="left_attach">0</property>
-                <property name="top_attach">0</property>
-                <property name="width">2</property>
-                <property name="height">1</property>
-              </packing>
-            </child>
-            <child>
               <object class="GtkGrid" id="grid2">
                 <property name="visible">True</property>
                 <property name="can_focus">False</property>
@@ -102,11 +77,9 @@
                     <property name="icon_size">1</property>
                     <child>
                       <object class="GtkToolButton" id="add-button">
-                        <property name="use_action_appearance">False</property>
                         <property name="visible">True</property>
                         <property name="can_focus">False</property>
                         <property name="tooltip_text" translatable="yes">Add a directory to the list of 
shared directories</property>
-                        <property name="use_action_appearance">False</property>
                         <property name="label" translatable="yes">Add shared directory</property>
                         <property name="icon_name">list-add-symbolic</property>
                       </object>
@@ -120,7 +93,6 @@
                         <property name="visible">True</property>
                         <property name="can_focus">False</property>
                         <property name="tooltip_text" translatable="yes">Remove a directory from the list of 
shared directories</property>
-                        <property name="use_action_appearance">False</property>
                         <property name="label" translatable="yes">Remove shared directory</property>
                         <property name="icon_name">list-remove-symbolic</property>
                       </object>
@@ -183,6 +155,48 @@
                 <property name="height">1</property>
               </packing>
             </child>
+            <child>
+              <object class="GtkGrid" id="grid3">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <child>
+                  <object class="GtkSwitch" id="upnp-checkbutton">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                  </object>
+                  <packing>
+                    <property name="left_attach">1</property>
+                    <property name="top_attach">0</property>
+                    <property name="width">1</property>
+                    <property name="height">1</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkLabel" id="label1">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="margin_left">12</property>
+                    <property name="hexpand">True</property>
+                    <property name="xalign">0</property>
+                    <property name="label" translatable="yes">_Share media through DLNA</property>
+                    <property name="use_underline">True</property>
+                    <property name="mnemonic_widget">upnp-checkbutton</property>
+                  </object>
+                  <packing>
+                    <property name="left_attach">0</property>
+                    <property name="top_attach">0</property>
+                    <property name="width">1</property>
+                    <property name="height">1</property>
+                  </packing>
+                </child>
+              </object>
+              <packing>
+                <property name="left_attach">0</property>
+                <property name="top_attach">0</property>
+                <property name="width">2</property>
+                <property name="height">1</property>
+              </packing>
+            </child>
           </object>
           <packing>
             <property name="expand">False</property>
@@ -198,14 +212,12 @@
             <child>
               <object class="GtkButton" id="button3">
                 <property name="label">gtk-close</property>
-                <property name="use_action_appearance">False</property>
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
                 <property name="has_focus">True</property>
                 <property name="can_default">True</property>
                 <property name="has_default">True</property>
                 <property name="receives_default">True</property>
-                <property name="use_action_appearance">False</property>
                 <property name="use_stock">True</property>
               </object>
               <packing>
@@ -228,7 +240,6 @@
       <action-widget response="-7">button3</action-widget>
     </action-widgets>
   </object>
-  <object class="GtkSizeGroup" id="plugin-labels-sizegroup"/>
   <object class="GtkFileChooserDialog" id="uris-dialog">
     <property name="can_focus">False</property>
     <property name="can_default">True</property>
@@ -256,12 +267,10 @@
             <child>
               <object class="GtkButton" id="button4">
                 <property name="label">gtk-cancel</property>
-                <property name="use_action_appearance">False</property>
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
                 <property name="can_default">True</property>
                 <property name="receives_default">True</property>
-                <property name="use_action_appearance">False</property>
                 <property name="use_stock">True</property>
               </object>
               <packing>
@@ -273,13 +282,11 @@
             <child>
               <object class="GtkButton" id="button5">
                 <property name="label">gtk-open</property>
-                <property name="use_action_appearance">False</property>
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
                 <property name="can_default">True</property>
                 <property name="has_default">True</property>
                 <property name="receives_default">True</property>
-                <property name="use_action_appearance">False</property>
                 <property name="use_stock">True</property>
               </object>
               <packing>
@@ -306,6 +313,10 @@
       <action-widget response="-5">button5</action-widget>
     </action-widgets>
   </object>
+  <object class="GtkSizeGroup" id="general-labels-sizegroup">
+    <property name="mode">both</property>
+  </object>
+  <object class="GtkSizeGroup" id="plugin-labels-sizegroup"/>
   <object class="GtkListStore" id="uris-liststore">
     <columns>
       <!-- column-name path -->
diff --git a/src/ui/rygel-preferences-dialog.vala b/src/ui/rygel-preferences-dialog.vala
index 7cdd0fc..970deef 100644
--- a/src/ui/rygel-preferences-dialog.vala
+++ b/src/ui/rygel-preferences-dialog.vala
@@ -34,7 +34,7 @@ public class Rygel.PreferencesDialog : GLib.Object {
     private WritableUserConfig config;
     private Builder builder;
     private Dialog dialog;
-    private CheckButton upnp_check;
+    private Switch upnp_check;
     private ArrayList<PreferencesSection> sections;
 
     public PreferencesDialog () throws Error {
@@ -49,7 +49,7 @@ public class Rygel.PreferencesDialog : GLib.Object {
 
         this.dialog = (Dialog) this.builder.get_object (DIALOG);
         assert (this.dialog != null);
-        this.upnp_check = (CheckButton) builder.get_object (UPNP_CHECKBUTTON);
+        this.upnp_check = (Switch) builder.get_object (UPNP_CHECKBUTTON);
         assert (this.upnp_check != null);
 
         this.dialog.set_icon_from_file (ICON);
@@ -61,8 +61,10 @@ public class Rygel.PreferencesDialog : GLib.Object {
         this.sections.add (new MediaPrefSection (this.builder, this.config));
 
         // All sections must be disabled if sharing is disabled
-        this.on_upnp_check_button_toggled (this.upnp_check);
-        this.upnp_check.toggled.connect (this.on_upnp_check_button_toggled);
+        this.on_upnp_switch_toggled ();
+        this.upnp_check.notify["active"].connect ( () => {
+            this.on_upnp_switch_toggled ();
+        });
     }
 
     public void run () {
@@ -97,9 +99,9 @@ public class Rygel.PreferencesDialog : GLib.Object {
         return 0;
     }
 
-    private void on_upnp_check_button_toggled (ToggleButton upnp_check) {
+    private void on_upnp_switch_toggled () {
         foreach (var section in this.sections) {
-            section.set_sensitivity (upnp_check.active);
+            section.set_sensitivity (this.upnp_check.active);
         }
     }
 }


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