[Xfce4-commits] <xfce4-settings:master> Add function to enable and disable a device.

Nick Schermer noreply at xfce.org
Wed May 25 19:00:11 CEST 2011


Updating branch refs/heads/master
         to 9b46d93374bc6af5095be54c36053946584da1f7 (commit)
       from 0745b21da4211d0b3fc784f4fce2dc1049ba0777 (commit)

commit 9b46d93374bc6af5095be54c36053946584da1f7
Author: Nick Schermer <nick at xfce.org>
Date:   Tue May 24 23:34:03 2011 +0200

    Add function to enable and disable a device.

 dialogs/mouse-settings/main.c |  103 ++++++++++++++++++++++++++---------------
 1 files changed, 65 insertions(+), 38 deletions(-)

diff --git a/dialogs/mouse-settings/main.c b/dialogs/mouse-settings/main.c
index 17c0ab1..3f89fc6 100644
--- a/dialogs/mouse-settings/main.c
+++ b/dialogs/mouse-settings/main.c
@@ -665,7 +665,6 @@ mouse_settings_wacom_set_rotation (GtkComboBox *combobox,
                                    GtkBuilder  *builder)
 {
     XDevice      *device;
-    Display      *xdisplay = GDK_DISPLAY ();
     GtkTreeIter   iter;
     GtkTreeModel *model;
     gint          rotation = 0;
@@ -687,6 +686,43 @@ mouse_settings_wacom_set_rotation (GtkComboBox *combobox,
             g_free (prop);
         }
 
+        XCloseDevice (GDK_DISPLAY (), device);
+    }
+
+    g_free (name);
+}
+
+
+
+static void
+mouse_settings_wacom_set_mode (GtkComboBox *combobox,
+                               GtkBuilder  *builder)
+{
+    XDevice      *device;
+    Display      *xdisplay = GDK_DISPLAY ();
+    GtkTreeIter   iter;
+    GtkTreeModel *model;
+    gchar        *mode = NULL;
+    gchar        *name = NULL;
+    gchar        *prop;
+
+    if (locked > 0)
+        return;
+
+    if (mouse_settings_device_get_selected (builder, &device, &name))
+    {
+        if (gtk_combo_box_get_active_iter (combobox, &iter))
+        {
+            model = gtk_combo_box_get_model (combobox);
+            gtk_tree_model_get (model, &iter, 0, &mode, -1);
+
+            prop = g_strconcat ("/", name, "/Mode", NULL);
+            xfconf_channel_set_string (pointers_channel, prop, mode);
+            g_free (prop);
+
+            g_free (mode);
+        }
+
         XCloseDevice (xdisplay, device);
     }
 
@@ -851,6 +887,30 @@ mouse_settings_synaptics_set_scrolling (GtkWidget  *widget,
 
 
 
+
+static void
+mouse_settings_device_set_enabled (GtkToggleButton *button,
+                                   GtkBuilder      *builder)
+{
+    gchar *name = NULL;
+    gchar *prop;
+
+    if (locked > 0)
+        return;
+
+    if (mouse_settings_device_get_selected (builder, NULL, &name))
+    {
+        prop = g_strconcat ("/", name, "/Properties/Device_Enabled", NULL);
+        xfconf_channel_set_int (pointers_channel, prop,
+                                gtk_toggle_button_get_active (button));
+        g_free (prop);
+    }
+
+    g_free (name);
+}
+
+
+
 static void
 mouse_settings_device_selection_changed (GtkBuilder *builder)
 {
@@ -1099,43 +1159,6 @@ mouse_settings_device_selection_changed (GtkBuilder *builder)
 
 
 static void
-mouse_settings_wacom_set_mode (GtkComboBox *combobox,
-                               GtkBuilder  *builder)
-{
-    XDevice      *device;
-    Display      *xdisplay = GDK_DISPLAY ();
-    GtkTreeIter   iter;
-    GtkTreeModel *model;
-    gchar        *mode = NULL;
-    gchar        *name = NULL;
-    gchar        *prop;
-
-    if (locked > 0)
-        return;
-
-    if (mouse_settings_device_get_selected (builder, &device, &name))
-    {
-        if (gtk_combo_box_get_active_iter (combobox, &iter))
-        {
-            model = gtk_combo_box_get_model (combobox);
-            gtk_tree_model_get (model, &iter, 0, &mode, -1);
-
-            prop = g_strconcat ("/", name, "/Mode", NULL);
-            xfconf_channel_set_string (pointers_channel, prop, mode);
-            g_free (prop);
-
-            g_free (mode);
-        }
-
-        XCloseDevice (xdisplay, device);
-    }
-
-    g_free (name);
-}
-
-
-
-static void
 mouse_settings_device_save (GtkBuilder *builder)
 {
     GObject          *combobox;
@@ -1552,6 +1575,10 @@ main (gint argc, gchar **argv)
             mouse_settings_device_populate_store (builder, TRUE);
 
             /* connect signals */
+            object = gtk_builder_get_object (builder, "device-enabled");
+            g_signal_connect (G_OBJECT (object), "toggled",
+                              G_CALLBACK (mouse_settings_device_set_enabled), builder);
+
             object = gtk_builder_get_object (builder, "device-acceleration-scale");
             g_signal_connect_swapped (G_OBJECT (object), "value-changed",
                                       G_CALLBACK (mouse_settings_device_save), builder);



More information about the Xfce4-commits mailing list