From 7c87f8f202a7743a18b8d7fdab5c66a3d54badd5 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Andreas=20M=C3=BCller?= <schnitzeltony@googlemail.com>
Date: Thu, 1 Nov 2012 21:01:59 +0100
Subject: [PATCH 2/5] mouse settings dialog: add touchscreen-pointer option
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit


Signed-off-by: Andreas Müller <schnitzeltony@googlemail.com>
Upstream-Status: Submitted [1]
[1] https://bugzilla.xfce.org/show_bug.cgi?id=9474
---
 dialogs/mouse-settings/main.c             |   56 +++++++++++++++++++++++++++++
 dialogs/mouse-settings/mouse-dialog.glade |   28 ++++++++++++++-
 3 files changed, 422 insertions(+), 329 deletions(-)

diff --git a/dialogs/mouse-settings/main.c b/dialogs/mouse-settings/main.c
index f4b475b..ff08219 100644
--- a/dialogs/mouse-settings/main.c
+++ b/dialogs/mouse-settings/main.c
@@ -956,6 +956,50 @@ mouse_settings_device_set_enabled (GtkToggleButton *button,
 
 
 
+#ifdef HAVE_XCURSOR
+static void
+mouse_settings_on_touchscreen_pointer (GtkToggleButton *button,
+                                       GtkBuilder      *builder)
+{
+    gchar    *name = NULL;
+    gchar    *prop;
+    gboolean  enabled;
+
+    if (locked > 0)
+        return;
+
+    if (mouse_settings_device_get_selected (builder, NULL, &name))
+    {
+        enabled = gtk_toggle_button_get_active (button);
+        prop = g_strconcat ("/", name, "/TouchscreenPointer", NULL);
+        xfconf_channel_set_bool (pointers_channel, prop, enabled);
+        g_free (prop);
+    }
+    g_free (name);
+}
+
+static void
+mouse_settings_set_touchscreen_pointer (GtkBuilder *builder)
+{
+    gchar           *name = NULL;
+    gchar           *prop;
+    gboolean         enabled;
+    GtkToggleButton *button;
+
+    if (mouse_settings_device_get_selected (builder, NULL, &name))
+    {
+        button = GTK_TOGGLE_BUTTON (gtk_builder_get_object (builder, "touchscreen-pointer"));
+        prop = g_strconcat ("/", name, "/TouchscreenPointer", NULL);
+        enabled = xfconf_channel_get_bool (pointers_channel, prop, FALSE);
+        gtk_toggle_button_set_active (button, enabled);
+        g_free (prop);
+    }
+    g_free (name);
+}
+#endif
+
+
+
 static void
 mouse_settings_device_selection_changed (GtkBuilder *builder)
 {
@@ -1007,6 +1051,9 @@ mouse_settings_device_selection_changed (GtkBuilder *builder)
     /* get the selected item */
     if (mouse_settings_device_get_selected (builder, &device, NULL))
     {
+#ifdef HAVE_XCURSOR
+        mouse_settings_set_touchscreen_pointer (builder);
+#endif
         gdk_error_trap_push ();
         device_info = XListInputDevices (xdisplay, &ndevices);
         if (gdk_error_trap_pop () == 0 && device_info != NULL)
@@ -1735,11 +1782,20 @@ main (gint argc, gchar **argv)
             /* populate the themes treeview */
             mouse_settings_themes_populate_store (builder);
 
+            /* connect & fill touchscreen-pointer */
+            object = gtk_builder_get_object (builder, "touchscreen-pointer");
+            g_signal_connect (G_OBJECT (object), "toggled",
+                              G_CALLBACK (mouse_settings_on_touchscreen_pointer), builder);
+            mouse_settings_set_touchscreen_pointer (builder);
+
             /* connect the cursor size in the cursor tab */
             object = gtk_builder_get_object (builder, "theme-cursor-size");
             xfconf_g_property_bind (xsettings_channel, "/Gtk/CursorThemeSize",
                                     G_TYPE_INT, G_OBJECT (object), "value");
 #else
+            /* hide touchscreen-pointer */
+            object = gtk_builder_get_object (builder, "touchscreen-pointer");
+            gtk_widget_hide (GTK_WIDGET (object));
             /* hide the themes tab */
             object = gtk_builder_get_object (builder, "themes-hbox");
             gtk_widget_hide (GTK_WIDGET (object));
diff --git a/dialogs/mouse-settings/mouse-dialog.glade b/dialogs/mouse-settings/mouse-dialog.glade
index d3aab0d..573c551 100644
--- a/dialogs/mouse-settings/mouse-dialog.glade
+++ b/dialogs/mouse-settings/mouse-dialog.glade
@@ -323,7 +323,7 @@
                                     <property name="visible">True</property>
                                     <property name="can_focus">False</property>
                                     <property name="border_width">6</property>
-                                    <property name="n_rows">3</property>
+                                    <property name="n_rows">4</property>
                                     <property name="n_columns">2</property>
                                     <property name="column_spacing">12</property>
                                     <property name="row_spacing">6</property>
@@ -415,6 +415,32 @@
                                         <property name="bottom_attach">3</property>
                                       </packing>
                                     </child>
+                                    <child>
+                                      <object class="GtkAlignment" id="alignment9">
+                                        <property name="visible">True</property>
+                                        <property name="can_focus">False</property>
+                                        <property name="xalign">0</property>
+                                        <property name="xscale">0</property>
+                                        <property name="yscale">0</property>
+                                        <child>
+                                          <object class="GtkCheckButton" id="touchscreen-pointer">
+                                            <property name="label" translatable="yes">_Touchscreen pointer</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="tooltip_text" translatable="yes">When selected, no mouse pointer is displayed for this device and gtk TouchscreenMode is activated</property>
+                                            <property name="use_underline">True</property>
+                                            <property name="draw_indicator">True</property>
+                                          </object>
+                                        </child>
+                                      </object>
+                                      <packing>
+                                        <property name="right_attach">2</property>
+                                        <property name="top_attach">3</property>
+                                        <property name="bottom_attach">4</property>
+                                      </packing>
+                                    </child>
                                   </object>
                                 </child>
                               </object>
-- 
1.7.6.5

