Author: nick
Date: 2008-07-08 17:05:59 +0000 (Tue, 08 Jul 2008)
New Revision: 27239

Modified:
   xfce4-settings/branches/multiple_pointers/daemon.c
   xfce4-settings/branches/multiple_pointers/main.c
   xfce4-settings/branches/multiple_pointers/mouse_dialog.glade
Log:
* Add a button to reset the acceleration and threshold
  to the default values of X.
* Change the Motion frame name to Feedback.


Modified: xfce4-settings/branches/multiple_pointers/daemon.c
===================================================================
--- xfce4-settings/branches/multiple_pointers/daemon.c  2008-07-08 15:31:30 UTC 
(rev 27238)
+++ xfce4-settings/branches/multiple_pointers/daemon.c  2008-07-08 17:05:59 UTC 
(rev 27239)
@@ -136,9 +136,8 @@
     XPtrFeedbackControl  feedback;
     gint                 n;
     gulong               mask = 0;
-    gint                 num, denom, gcd;
+    gint                 num = -1, denom = -1, gcd;
 
-
     /* get the feedback states for this device */
     states = XGetFeedbackControl (xdisplay, device, &num_feedbacks);
 
@@ -150,26 +149,24 @@
             /* find the pointer feedback class */
             if (states->class == PtrFeedbackClass)
             {
-                if (acceleration > 0)
+                if (acceleration > 0 || acceleration == -1)
                 {
-                    /* calculate the faction of the acceleration */
-                    num = acceleration * MAX_DENOMINATOR;
-                    denom = MAX_DENOMINATOR;
-                    gcd = mouse_daemon_gcd (num, denom);
-                    num /= gcd;
-                    denom /= gcd;
+                    if (acceleration > 0)
+                    {
+                        /* calculate the faction of the acceleration */
+                        num = acceleration * MAX_DENOMINATOR;
+                        denom = MAX_DENOMINATOR;
+                        gcd = mouse_daemon_gcd (num, denom);
+                        num /= gcd;
+                        denom /= gcd;
+                    }
 
                     /* set the mask */
                     mask |= DvAccelNum | DvAccelDenom;
                 }
-                else
-                {
-                    /* nothing special */
-                    num = denom = 1;
-                }
 
                 /* setup the mask for the threshold */
-                if (threshold != -1)
+                if (threshold > 0 || threshold == -1)
                     mask |= DvThreshold;
 
                 /* create a new feedback */
@@ -351,9 +348,9 @@
                         if (strcmp (names[1], "RightHanded") == 0)
                             mouse_daemon_change_button_mapping (device_info, 
device, xdisplay, g_value_get_boolean (value));
                         else if (strcmp (names[1], "Threshold") == 0)
-                            mouse_daemon_change_feedback (device, xdisplay, 
g_value_get_int (value), -1);
+                            mouse_daemon_change_feedback (device, xdisplay, 
g_value_get_int (value), -2.00);
                         else if (strcmp (names[1], "Acceleration") == 0)
-                            mouse_daemon_change_feedback (device, xdisplay, 
-1, g_value_get_double (value));
+                            mouse_daemon_change_feedback (device, xdisplay, 
-2, g_value_get_double (value));
 
                         /* close the device */
                         XCloseDevice (xdisplay, device);

Modified: xfce4-settings/branches/multiple_pointers/main.c
===================================================================
--- xfce4-settings/branches/multiple_pointers/main.c    2008-07-08 15:31:30 UTC 
(rev 27238)
+++ xfce4-settings/branches/multiple_pointers/main.c    2008-07-08 17:05:59 UTC 
(rev 27239)
@@ -60,7 +60,7 @@
 static GdkDisplay *display;
 
 /* device update id */
-static guint device_changed_timeout_id = 0;
+static guint timeout_id = 0;
 
 /* option entries */
 static gboolean opt_version = FALSE;
@@ -880,6 +880,32 @@
 
 
 static gboolean
+mouse_settings_device_update_sliders (gpointer user_data)
+{
+    GladeXML  *gxml = GLADE_XML (user_data);
+    GtkWidget *treeview;
+    GtkWidget *button;
+    
+    GDK_THREADS_ENTER ();
+    
+    /* get the treeview */
+    treeview = glade_xml_get_widget (gxml, "mouse-devices-treeview");
+    
+    /* update */
+    mouse_settings_device_selection_changed (gtk_tree_view_get_selection 
(GTK_TREE_VIEW (treeview)), gxml);
+    
+    /* make the button sensitive again */
+    button = glade_xml_get_widget (gxml, "mouse-reset");
+    gtk_widget_set_sensitive (button, TRUE);
+    
+    GDK_THREADS_LEAVE ();
+
+    return FALSE;
+}
+
+
+
+static gboolean
 mouse_settings_device_list_changed_timeout (gpointer user_data)
 {
     GladeXML *gxml = GLADE_XML (user_data);
@@ -900,7 +926,7 @@
 mouse_settings_device_list_changed_timeout_destroyed (gpointer user_data)
 {
     /* reset the timeout id */
-    device_changed_timeout_id = 0;
+    timeout_id = 0;
 }
 
 
@@ -912,19 +938,75 @@
     GladeXML *gxml;
 
     /* queue a new timeout if none is set */
-    if (device_changed_timeout_id == 0)
+    if (timeout_id == 0)
     {
         /* get the user data */
         gxml = libhal_ctx_get_user_data (context);
 
         /* update the dialog in 1 second */
-        device_changed_timeout_id = g_timeout_add_full (G_PRIORITY_LOW, 1000, 
mouse_settings_device_list_changed_timeout,
-                                                        gxml, 
mouse_settings_device_list_changed_timeout_destroyed);
+        timeout_id = g_timeout_add_full (G_PRIORITY_LOW, 1000, 
mouse_settings_device_list_changed_timeout,
+                                         gxml, 
mouse_settings_device_list_changed_timeout_destroyed);
     }
 }
 
 
 
+static void
+mouse_settings_device_reset (GtkWidget *button,
+                             GladeXML  *gxml)
+{
+    GtkWidget        *treeview;
+    GtkTreeSelection *selection;
+    gchar            *name, *property_name;
+    gboolean          has_selection;
+    GtkTreeModel     *model;
+    GtkTreeIter       iter;
+    
+    /* leave when locked */
+    if (locked > 0)
+        return;
+
+    /* get the treeview */
+    treeview = glade_xml_get_widget (gxml, "mouse-devices-treeview");
+
+    /* get the selection */
+    selection = gtk_tree_view_get_selection (GTK_TREE_VIEW (treeview));
+
+    has_selection = gtk_tree_selection_get_selected (selection, &model, &iter);
+    if (G_LIKELY (has_selection))
+    {
+        /* get device id and number of buttons */
+        gtk_tree_model_get (model, &iter, COLUMN_DEVICE_NAME, &name, -1);
+
+        if (G_LIKELY (name && timeout_id == 0))
+        {
+            /* make the button insensitive */
+            gtk_widget_set_sensitive (button, FALSE);
+            
+            /* set the threshold to -1 */
+            property_name = g_strdup_printf ("/Pointers/%s/Threshold", name);
+            xfconf_channel_set_int (channel, property_name, -1);
+            g_free (property_name);
+
+            /* set the acceleration to -1 */
+            property_name = g_strdup_printf ("/Pointers/%s/Acceleration", 
name);
+            xfconf_channel_set_double (channel, property_name, -1.00);
+            g_free (property_name);
+            
+            /* update the sliders in 500ms */
+            timeout_id = g_timeout_add_full (G_PRIORITY_LOW, 500, 
mouse_settings_device_update_sliders,
+                                             gxml, 
mouse_settings_device_list_changed_timeout_destroyed);
+
+            
+        }
+        
+        /* cleanup */
+        g_free (name);
+    }
+}
+
+
+
 gint
 main(gint argc, gchar **argv)
 {
@@ -1004,6 +1086,9 @@
 
             widget = glade_xml_get_widget (gxml, "mouse-right-handed");
             g_signal_connect_swapped (G_OBJECT (widget), "toggled", G_CALLBACK 
(mouse_settings_device_save), gxml);
+            
+            widget = glade_xml_get_widget (gxml, "mouse-reset");
+            g_signal_connect (G_OBJECT (widget), "clicked", G_CALLBACK 
(mouse_settings_device_reset), gxml);
 
             /* populate the themes treeview */
             mouse_settings_themes_populate_store (gxml);
@@ -1090,8 +1175,8 @@
                 dbus_connection_unref (connection);
 
             /* stop any running sources */
-            if (G_UNLIKELY (device_changed_timeout_id != 0))
-                g_source_remove (device_changed_timeout_id);
+            if (G_UNLIKELY (timeout_id != 0))
+                g_source_remove (timeout_id);
 
             /* destroy the dialog */
             gtk_widget_destroy (GTK_WIDGET (dialog));

Modified: xfce4-settings/branches/multiple_pointers/mouse_dialog.glade
===================================================================
--- xfce4-settings/branches/multiple_pointers/mouse_dialog.glade        
2008-07-08 15:31:30 UTC (rev 27238)
+++ xfce4-settings/branches/multiple_pointers/mouse_dialog.glade        
2008-07-08 17:05:59 UTC (rev 27239)
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8" standalone="no"?>
 <!DOCTYPE glade-interface SYSTEM "glade-2.0.dtd">
-<!--Generated with glade3 3.4.5 on Mon Jul  7 22:16:43 2008 -->
+<!--Generated with glade3 3.4.5 on Tue Jul  8 19:04:35 2008 -->
 <glade-interface>
   <requires lib="xfce4"/>
   <widget class="XfceTitledDialog" id="mouse-dialog">
@@ -177,6 +177,27 @@
                                     <property name="position">1</property>
                                   </packing>
                                 </child>
+                                <child>
+                                  <widget class="GtkAlignment" id="alignment7">
+                                    <property name="visible">True</property>
+                                    <property name="xalign">0</property>
+                                    <property name="xscale">0</property>
+                                    <child>
+                                      <widget class="GtkButton" 
id="mouse-reset">
+                                        <property 
name="visible">True</property>
+                                        <property 
name="can_focus">True</property>
+                                        <property 
name="receives_default">True</property>
+                                        <property name="tooltip" 
translatable="yes">Set the acceleration and threshold for the selected device 
to the default values</property>
+                                        <property name="label" 
translatable="yes">Re_set to default</property>
+                                        <property 
name="use_underline">True</property>
+                                        <property 
name="response_id">0</property>
+                                      </widget>
+                                    </child>
+                                  </widget>
+                                  <packing>
+                                    <property name="position">2</property>
+                                  </packing>
+                                </child>
                               </widget>
                             </child>
                           </widget>
@@ -184,7 +205,7 @@
                         <child>
                           <widget class="GtkLabel" id="label5">
                             <property name="visible">True</property>
-                            <property name="label" 
translatable="yes">&lt;b&gt;Motion&lt;/b&gt;</property>
+                            <property name="label" 
translatable="yes">&lt;b&gt;Feedback&lt;/b&gt;</property>
                             <property name="use_markup">True</property>
                           </widget>
                           <packing>

_______________________________________________
Xfce4-commits mailing list
[email protected]
http://foo-projects.org/mailman/listinfo/xfce4-commits

Reply via email to