[gnome-control-center] mouse: Offer a separate option for edge scrolling



commit f01277fb485ea84c16ab59e44f947a9b4936f21c
Author: Bastien Nocera <hadess hadess net>
Date:   Thu Jun 30 13:33:09 2016 +0200

    mouse: Offer a separate option for edge scrolling
    
    When a touchpad supports it. When the option is set, it will
    automatically disable two-finger scrolling.
    
    The scrolling method used by each individual touchpad is implemented in
    mutter, not here.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=761461

 configure.ac                           |    2 +-
 panels/mouse/gnome-mouse-properties.c  |   34 +++++++++++++++++++-
 panels/mouse/gnome-mouse-properties.ui |   53 ++++++++++++++++++++++++++++++++
 3 files changed, 86 insertions(+), 3 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index e2e8680..4abb5de 100644
--- a/configure.ac
+++ b/configure.ac
@@ -97,7 +97,7 @@ NETWORK_MANAGER_APPLET_REQUIRED_VERSION=1.2.0
 MODEM_MANAGER_REQUIRED_VERSION=0.7
 LIBNOTIFY_REQUIRED_VERSION=0.7.3
 GNOME_DESKTOP_REQUIRED_VERSION=3.21.2
-SCHEMAS_REQUIRED_VERSION=3.19.3
+SCHEMAS_REQUIRED_VERSION=3.21.4
 LIBWACOM_REQUIRED_VERSION=0.7
 CLUTTER_REQUIRED_VERSION=1.11.3
 GOA_REQUIRED_VERSION=3.15.1
diff --git a/panels/mouse/gnome-mouse-properties.c b/panels/mouse/gnome-mouse-properties.c
index 049db0e..a64bb68 100644
--- a/panels/mouse/gnome-mouse-properties.c
+++ b/panels/mouse/gnome-mouse-properties.c
@@ -76,6 +76,7 @@ static void
 setup_touchpad_options (CcMousePropertiesPrivate *d)
 {
        gboolean edge_scroll_enabled;
+       gboolean two_finger_scroll_enabled;
        gboolean have_two_finger_scrolling;
        gboolean have_edge_scrolling;
        gboolean have_tap_to_click;
@@ -92,16 +93,38 @@ setup_touchpad_options (CcMousePropertiesPrivate *d)
 
        gtk_widget_show_all (WID ("touchpad-frame"));
 
-       gtk_widget_set_visible (WID ("edge-scrolling-row"), have_edge_scrolling && 
!have_two_finger_scrolling);
+       gtk_widget_set_visible (WID ("two-finger-scrolling-row"), have_two_finger_scrolling);
+       gtk_widget_set_visible (WID ("edge-scrolling-row"), have_edge_scrolling);
        gtk_widget_set_visible (WID ("tap-to-click-row"), have_tap_to_click);
 
        edge_scroll_enabled = g_settings_get_boolean (d->touchpad_settings, "edge-scrolling-enabled");
+       two_finger_scroll_enabled = g_settings_get_boolean (d->touchpad_settings, 
"two-finger-scrolling-enabled");
        d->changing_scroll = TRUE;
        gtk_switch_set_active (GTK_SWITCH (WID ("edge-scrolling-switch")), edge_scroll_enabled);
+       gtk_switch_set_active (GTK_SWITCH (WID ("two-finger-scrolling-switch")), two_finger_scroll_enabled);
        d->changing_scroll = FALSE;
 }
 
 static void
+two_finger_scrolling_changed_event (GtkSwitch *button,
+                                   gboolean   state,
+                                   gpointer user_data)
+{
+       CcMousePropertiesPrivate *d = user_data;
+
+       if (d->changing_scroll)
+               return;
+
+       g_settings_set_boolean (d->touchpad_settings, "two-finger-scrolling-enabled", state);
+       gtk_switch_set_state (button, state);
+
+       if (state && gtk_widget_get_visible (WID ("edge-scrolling-row"))) {
+               /* Disable edge scrolling if two-finger scrolling is enabled */
+               gtk_switch_set_state (GTK_SWITCH (WID ("edge-scrolling-switch")), FALSE);
+       }
+}
+
+static void
 edge_scrolling_changed_event (GtkSwitch *button,
                              gboolean   state,
                              gpointer user_data)
@@ -111,8 +134,13 @@ edge_scrolling_changed_event (GtkSwitch *button,
        if (d->changing_scroll)
                return;
 
-       g_settings_set_boolean (d->touchpad_settings, "edge-scrolling-switch", state);
+       g_settings_set_boolean (d->touchpad_settings, "edge-scrolling-enabled", state);
        gtk_switch_set_state (button, state);
+
+       if (state && gtk_widget_get_visible (WID ("two-finger-scrolling-row"))) {
+               /* Disable two-finger scrolling if edge scrolling is enabled */
+               gtk_switch_set_state (GTK_SWITCH (WID ("two-finger-scrolling-switch")), FALSE);
+       }
 }
 
 static gboolean
@@ -254,6 +282,8 @@ setup_dialog (CcMousePropertiesPrivate *d)
 
        g_signal_connect (WID ("edge-scrolling-switch"), "state-set",
                          G_CALLBACK (edge_scrolling_changed_event), d);
+       g_signal_connect (WID ("two-finger-scrolling-switch"), "state-set",
+                         G_CALLBACK (two_finger_scrolling_changed_event), d);
 
        gtk_list_box_set_header_func (GTK_LIST_BOX (WID ("touchpad-options-listbox")), 
cc_list_box_update_header_func, NULL, NULL);
 }
diff --git a/panels/mouse/gnome-mouse-properties.ui b/panels/mouse/gnome-mouse-properties.ui
index db058ec..a5c93d7 100644
--- a/panels/mouse/gnome-mouse-properties.ui
+++ b/panels/mouse/gnome-mouse-properties.ui
@@ -616,6 +616,59 @@
                           </object>
                         </child>
                         <child>
+                          <object class="GtkListBoxRow" id="two-finger-scrolling-row">
+                            <property name="visible">False</property>
+                            <property name="can_focus">True</property>
+                            <property name="no_show_all">True</property>
+                            <property name="activatable">false</property>
+                            <child>
+                              <object class="GtkGrid" id="two-finger-scrolling-grid">
+                                <property name="visible">True</property>
+                                <property name="can_focus">False</property>
+                                <property name="row_spacing">0</property>
+                                <property name="column_spacing">32</property>
+                                <property name="margin_start">12</property>
+                                <property name="margin_end">6</property>
+                                <property name="margin_top">6</property>
+                                <property name="margin_bottom">6</property>
+                                <property name="valign">center</property>
+                                <child>
+                                  <object class="GtkLabel" id="two-finger-scrolling-label">
+                                    <property name="visible">True</property>
+                                    <property name="can_focus">False</property>
+                                    <property name="hexpand">True</property>
+                                    <property name="xalign">0</property>
+                                    <property name="valign">end</property>
+                                    <property name="label" translatable="yes">Two-finger Scrolling</property>
+                                    <property name="use_underline">True</property>
+                                    <property name="mnemonic_widget">two-finger-scrolling-switch</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>
+                                <child>
+                                  <object class="GtkSwitch" id="two-finger-scrolling-switch">
+                                    <property name="visible">True</property>
+                                    <property name="can_focus">True</property>
+                                    <property name="halign">end</property>
+                                    <property name="valign">center</property>
+                                  </object>
+                                  <packing>
+                                    <property name="left_attach">1</property>
+                                    <property name="top_attach">0</property>
+                                    <property name="width">1</property>
+                                    <property name="height">2</property>
+                                  </packing>
+                                </child>
+                              </object>
+                            </child>
+                          </object>
+                        </child>
+                        <child>
                           <object class="GtkListBoxRow" id="edge-scrolling-row">
                             <property name="visible">False</property>
                             <property name="can_focus">True</property>


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