[Xfce4-commits] <xfce4-settings:peter/circularscrolling> Changed scrolling mode for touchpads to a combobox.

Peter de Ridder noreply at xfce.org
Thu May 3 23:52:03 CEST 2012


Updating branch refs/heads/peter/circularscrolling
         to a14ce7113757844aecb5dc29ca656aaf7017ef8b (commit)
       from 267b4df56f48449d2e9c478554053d26ea3eeb0a (commit)

commit a14ce7113757844aecb5dc29ca656aaf7017ef8b
Author: Peter de Ridder <peter at xfce.org>
Date:   Thu May 3 23:50:01 2012 +0200

    Changed scrolling mode for touchpads to a combobox.

 dialogs/mouse-settings/main.c             |  132 ++++++++++++++++++-----------
 dialogs/mouse-settings/mouse-dialog.glade |   92 +++++++++-----------
 2 files changed, 124 insertions(+), 100 deletions(-)

diff --git a/dialogs/mouse-settings/main.c b/dialogs/mouse-settings/main.c
index 5f0707b..f4b475b 100644
--- a/dialogs/mouse-settings/main.c
+++ b/dialogs/mouse-settings/main.c
@@ -790,22 +790,21 @@ mouse_settings_synaptics_set_tap_to_click (GtkBuilder *builder)
 static void
 mouse_settings_synaptics_hscroll_sensitive (GtkBuilder *builder)
 {
+    gint      active;
     gboolean  sensitive = FALSE;
     GObject  *object;
 
-    object = gtk_builder_get_object (builder, "synaptics-scroll-edge");
+    /* Values for active:
+     * -1 no selection
+     *  0 disabled
+     *  1 edge scrolling
+     *  2 two-finger scrolling
+     *  3 circular scrolling
+     */
+    object = gtk_builder_get_object (builder, "synaptics-scroll");
+    active = gtk_combo_box_get_active (GTK_COMBO_BOX (object));
     if (gtk_widget_get_sensitive (GTK_WIDGET (object))
-        && gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (object)))
-        sensitive = TRUE;
-
-    object = gtk_builder_get_object (builder, "synaptics-scroll-two");
-    if (gtk_widget_get_sensitive (GTK_WIDGET (object))
-        && gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (object)))
-        sensitive = TRUE;
-
-    object = gtk_builder_get_object (builder, "synaptics-scroll-circ");
-    if (gtk_widget_get_sensitive (GTK_WIDGET (object))
-        && gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (object)))
+        && active > 0)
         sensitive = TRUE;
 
     object = gtk_builder_get_object (builder, "synaptics-scroll-horiz");
@@ -817,8 +816,8 @@ mouse_settings_synaptics_hscroll_sensitive (GtkBuilder *builder)
 
 #ifdef DEVICE_PROPERTIES
 static void
-mouse_settings_synaptics_set_scrolling (GtkWidget  *widget,
-                                        GtkBuilder *builder)
+mouse_settings_synaptics_set_scrolling (GtkComboBox *combobox,
+                                        GtkBuilder  *builder)
 {
     gint      edge_scroll[3] = { 0, 0, 0 };
     gint      two_scroll[2] = { 0, 0 };
@@ -826,41 +825,44 @@ mouse_settings_synaptics_set_scrolling (GtkWidget  *widget,
     gint      circ_trigger = 0;
     GObject  *object;
     gboolean  horizontal = FALSE;
+    gint      active;
     gchar    *name = NULL, *prop;
 
     if (locked > 0)
         return;
 
-    /*  skip double event if a radio button is toggled */
-    if (GTK_IS_RADIO_BUTTON (widget)
-        && !gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (widget)))
-        return;
-
     mouse_settings_synaptics_hscroll_sensitive (builder);
 
     object = gtk_builder_get_object (builder, "synaptics-scroll-horiz");
     if (gtk_widget_get_sensitive (GTK_WIDGET (object)))
         horizontal = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (object));
 
-    object = gtk_builder_get_object (builder, "synaptics-scroll-edge");
-    if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (object))
-        && gtk_widget_get_sensitive (GTK_WIDGET (object)))
+    /* Values for active:
+     * -1 no selection
+     *  0 disabled
+     *  1 edge scrolling
+     *  2 two-finger scrolling
+     *  3 circular scrolling
+     */
+    object = gtk_builder_get_object (builder, "synaptics-scroll");
+    active = gtk_combo_box_get_active (GTK_COMBO_BOX (object));
+    if (!gtk_widget_get_sensitive (GTK_WIDGET (object)))
+        active = -1;
+
+
+    if (active == 1)
     {
         edge_scroll[0] = TRUE;
         edge_scroll[1] = horizontal;
     }
 
-    object = gtk_builder_get_object (builder, "synaptics-scroll-two");
-    if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (object))
-        && gtk_widget_get_sensitive (GTK_WIDGET (object)))
+    if (active == 2)
     {
         two_scroll[0] = TRUE;
         two_scroll[1] = horizontal;
     }
 
-    object = gtk_builder_get_object (builder, "synaptics-scroll-circ");
-    if (gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (object))
-        && gtk_widget_get_sensitive (GTK_WIDGET (object)))
+    if (active == 3)
     {
         circ_scroll = TRUE;
         if (horizontal)
@@ -908,6 +910,24 @@ mouse_settings_synaptics_set_scrolling (GtkWidget  *widget,
 
 #ifdef DEVICE_PROPERTIES
 static void
+mouse_settings_synaptics_set_scroll_horiz (GtkWidget  *widget,
+                                           GtkBuilder *builder)
+{
+    GObject  *object;
+
+    if (locked > 0)
+        return;
+
+    object = gtk_builder_get_object (builder, "synaptics-scroll");
+
+    mouse_settings_synaptics_set_scrolling (GTK_COMBO_BOX (object), builder);
+}
+#endif
+
+
+
+#ifdef DEVICE_PROPERTIES
+static void
 mouse_settings_device_set_enabled (GtkToggleButton *button,
                                    GtkBuilder      *builder)
 {
@@ -973,6 +993,8 @@ mouse_settings_device_selection_changed (GtkBuilder *builder)
     gint               synaptics_two_scroll = -1;
     gint               synaptics_two_hscroll = -1;
     gint               synaptics_circ_scroll = -1;
+    gint               synaptics_scroll_mode = 0;
+    GtkTreeIter        iter;
     gint               wacom_rotation = -1;
     Atom              *props;
     gint               nprops;
@@ -1154,21 +1176,34 @@ mouse_settings_device_selection_changed (GtkBuilder *builder)
         gtk_widget_set_sensitive (GTK_WIDGET (object), synaptics_tap_to_click != -1);
         gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (object), synaptics_tap_to_click > 0);
 
-        object = gtk_builder_get_object (builder, "synaptics-scroll-no");
-        gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (object),
-                                      synaptics_edge_scroll == -1 && synaptics_two_scroll == -1 && synaptics_circ_scroll == -1);
+        /* Values for synaptics_scroll_mode:
+         * -1 no selection
+         *  0 disabled
+         *  1 edge scrolling
+         *  2 two-finger scrolling
+         *  3 circular scrolling
+         */
+        if (synaptics_edge_scroll > 0)
+            synaptics_scroll_mode = 1;
 
-        object = gtk_builder_get_object (builder, "synaptics-scroll-edge");
-        gtk_widget_set_sensitive (GTK_WIDGET (object), synaptics_edge_scroll != -1);
-        gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (object), synaptics_edge_scroll > 0);
+        if (synaptics_two_scroll > 0)
+            synaptics_scroll_mode = 2;
 
-        object = gtk_builder_get_object (builder, "synaptics-scroll-two");
-        gtk_widget_set_sensitive (GTK_WIDGET (object), synaptics_two_scroll != -1);
-        gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (object), synaptics_two_scroll > 0);
+        if (synaptics_circ_scroll > 0)
+            synaptics_scroll_mode = 3;
 
-        object = gtk_builder_get_object (builder, "synaptics-scroll-circ");
-        gtk_widget_set_sensitive (GTK_WIDGET (object), synaptics_circ_scroll != -1);
-        gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (object), synaptics_circ_scroll > 0);
+        object = gtk_builder_get_object (builder, "synaptics-scroll-store");
+        if (gtk_tree_model_iter_nth_child (GTK_TREE_MODEL (object), &iter, NULL, 1))
+            gtk_list_store_set (GTK_LIST_STORE (object), &iter, 1, synaptics_edge_scroll != -1, -1);
+
+        if (gtk_tree_model_iter_nth_child (GTK_TREE_MODEL (object), &iter, NULL, 2))
+            gtk_list_store_set (GTK_LIST_STORE (object), &iter, 1, synaptics_two_scroll != -1, -1);
+
+        if (gtk_tree_model_iter_nth_child (GTK_TREE_MODEL (object), &iter, NULL, 3))
+            gtk_list_store_set (GTK_LIST_STORE (object), &iter, 1, synaptics_circ_scroll != -1, -1);
+
+        object = gtk_builder_get_object (builder, "synaptics-scroll");
+        gtk_combo_box_set_active (GTK_COMBO_BOX (object), synaptics_scroll_mode);
 
         object = gtk_builder_get_object (builder, "synaptics-scroll-horiz");
         mouse_settings_synaptics_hscroll_sensitive (builder);
@@ -1547,10 +1582,6 @@ main (gint argc, gchar **argv)
     XExtensionVersion *version = NULL;
 #ifdef DEVICE_PROPERTIES
     gchar             *syndaemon;
-    guint              i;
-    const gchar       *synaptics_scroll[] = { "synaptics-scroll-no", "synaptics-scroll-edge",
-                                              "synaptics-scroll-two", "synaptics-scroll-circ",
-                                              "synaptics-scroll-horiz" };
 #endif
 
     /* setup translation domain */
@@ -1683,12 +1714,13 @@ main (gint argc, gchar **argv)
             g_signal_connect_swapped (G_OBJECT (object), "toggled",
                                       G_CALLBACK (mouse_settings_synaptics_set_tap_to_click), builder);
 
-            for (i = 0; i < G_N_ELEMENTS (synaptics_scroll); i++)
-            {
-                object = gtk_builder_get_object (builder, synaptics_scroll[i]);
-                g_signal_connect (G_OBJECT (object), "toggled",
-                                  G_CALLBACK (mouse_settings_synaptics_set_scrolling), builder);
-            }
+            object = gtk_builder_get_object (builder, "synaptics-scroll");
+            g_signal_connect (G_OBJECT (object), "changed",
+                              G_CALLBACK (mouse_settings_synaptics_set_scrolling), builder);
+
+            object = gtk_builder_get_object (builder, "synaptics-scroll-horiz");
+            g_signal_connect (G_OBJECT (object), "toggled",
+                              G_CALLBACK (mouse_settings_synaptics_set_scroll_horiz), builder);
 
             object = gtk_builder_get_object (builder, "wacom-mode");
             g_signal_connect (G_OBJECT (object), "changed",
diff --git a/dialogs/mouse-settings/mouse-dialog.glade b/dialogs/mouse-settings/mouse-dialog.glade
index f63a93f..c92f3ca 100644
--- a/dialogs/mouse-settings/mouse-dialog.glade
+++ b/dialogs/mouse-settings/mouse-dialog.glade
@@ -517,15 +517,13 @@
                                         <property name="can_focus">False</property>
                                         <property name="spacing">12</property>
                                         <child>
-                                          <object class="GtkRadioButton" id="synaptics-scroll-no">
-                                            <property name="label" translatable="yes">Di_sabled</property>
+                                          <object class="GtkLabel" id="label23">
                                             <property name="visible">True</property>
-                                            <property name="can_focus">True</property>
-                                            <property name="receives_default">False</property>
-                                            <property name="use_action_appearance">False</property>
+                                            <property name="can_focus">False</property>
+                                            <property name="xalign">0</property>
+                                            <property name="label" translatable="yes">Scro_lling mode:</property>
                                             <property name="use_underline">True</property>
-                                            <property name="active">True</property>
-                                            <property name="draw_indicator">True</property>
+                                            <property name="mnemonic_widget">synaptics-scroll</property>
                                           </object>
                                           <packing>
                                             <property name="expand">False</property>
@@ -534,54 +532,22 @@
                                           </packing>
                                         </child>
                                         <child>
-                                          <object class="GtkRadioButton" id="synaptics-scroll-edge">
-                                            <property name="label" translatable="yes">Edge scro_lling</property>
+                                          <object class="GtkComboBox" id="synaptics-scroll">
                                             <property name="visible">True</property>
-                                            <property name="can_focus">True</property>
-                                            <property name="receives_default">False</property>
-                                            <property name="use_action_appearance">False</property>
-                                            <property name="use_underline">True</property>
-                                            <property name="draw_indicator">True</property>
-                                            <property name="group">synaptics-scroll-no</property>
-                                          </object>
-                                          <packing>
-                                            <property name="expand">False</property>
-                                            <property name="fill">True</property>
-                                            <property name="position">1</property>
-                                          </packing>
-                                        </child>
-                                        <child>
-                                          <object class="GtkRadioButton" id="synaptics-scroll-two">
-                                            <property name="label" translatable="yes">Two-_finger scrolling</property>
-                                            <property name="visible">True</property>
-                                            <property name="can_focus">True</property>
-                                            <property name="receives_default">False</property>
-                                            <property name="use_action_appearance">False</property>
-                                            <property name="use_underline">True</property>
-                                            <property name="draw_indicator">True</property>
-                                            <property name="group">synaptics-scroll-no</property>
+                                            <property name="can_focus">False</property>
+                                            <property name="model">synaptics-scroll-store</property>
+                                            <child>
+                                              <object class="GtkCellRendererText" id="cellrenderertext3"/>
+                                              <attributes>
+                                                <attribute name="text">0</attribute>
+                                                <attribute name="sensitive">1</attribute>
+                                              </attributes>
+                                            </child>
                                           </object>
                                           <packing>
                                             <property name="expand">True</property>
                                             <property name="fill">True</property>
-                                            <property name="position">2</property>
-                                          </packing>
-                                        </child>
-                                        <child>
-                                          <object class="GtkRadioButton" id="synaptics-scroll-circ">
-                                            <property name="label" translatable="yes">C_ircular scrolling</property>
-                                            <property name="visible">True</property>
-                                            <property name="can_focus">True</property>
-                                            <property name="receives_default">False</property>
-                                            <property name="use_action_appearance">False</property>
-                                            <property name="use_underline">True</property>
-                                            <property name="draw_indicator">True</property>
-                                            <property name="group">synaptics-scroll-no</property>
-                                          </object>
-                                          <packing>
-                                            <property name="expand">True</property>
-                                            <property name="fill">True</property>
-                                            <property name="position">3</property>
+                                            <property name="position">1</property>
                                           </packing>
                                         </child>
                                       </object>
@@ -1180,6 +1146,32 @@
     <property name="step_increment">1</property>
     <property name="page_increment">11</property>
   </object>
+  <object class="GtkListStore" id="synaptics-scroll-store">
+    <columns>
+      <!-- column-name title -->
+      <column type="gchararray"/>
+      <!-- column-name sensitive -->
+      <column type="gboolean"/>
+    </columns>
+    <data>
+      <row>
+        <col id="0" translatable="yes">Disabled</col>
+        <col id="1">True</col>
+      </row>
+      <row>
+        <col id="0" translatable="yes">Edge scrolling</col>
+        <col id="1">True</col>
+      </row>
+      <row>
+        <col id="0" translatable="yes">Two-finger scrolling</col>
+        <col id="1">True</col>
+      </row>
+      <row>
+        <col id="0" translatable="yes">Circular scrolling</col>
+        <col id="1">True</col>
+      </row>
+    </data>
+  </object>
   <object class="GtkListStore" id="wacom-mode-store">
     <columns>
       <!-- column-name mode -->


More information about the Xfce4-commits mailing list