[gpointing-device-settings] Add gpds_xinput_ui_set_xinput_property_from_range_value.



commit 31690499a4964d1bb80de3042a9e9b659a5a88e7
Author: Hiroyuki Ikezoe <poincare ikezoe net>
Date:   Wed Mar 10 20:53:27 2010 +0900

    Add gpds_xinput_ui_set_xinput_property_from_range_value.
    
    GPDS_XINPUT_UI_DEFINE_SCALE_VALUE_CHANGED_CALLBACK macro used this function.

 src/gpds-xinput-ui.c |   32 ++++++++++++++++++++++++++++++++
 src/gpds-xinput-ui.h |   24 +++++++-----------------
 2 files changed, 39 insertions(+), 17 deletions(-)
---
diff --git a/src/gpds-xinput-ui.c b/src/gpds-xinput-ui.c
index 86709e4..00d19b3 100644
--- a/src/gpds-xinput-ui.c
+++ b/src/gpds-xinput-ui.c
@@ -246,6 +246,38 @@ gpds_xinput_ui_set_xinput_property_from_toggle_button_state (GpdsXInputUI *ui,
 }
 
 void
+gpds_xinput_ui_set_xinput_property_from_range_value (GpdsXInputUI *ui,
+                                                     gint property,
+                                                     GtkRange *range)
+{
+    GError *error = NULL;
+    gdouble value;
+    gint properties[1];
+    GpdsXInputUIPriv *priv;
+
+    g_return_if_fail(GPDS_IS_XINPUT_UI(ui));
+    g_return_if_fail(GTK_IS_RANGE(range));
+
+    priv = GPDS_XINPUT_UI_GET_PRIVATE(ui);
+    if (!priv->xinput)
+        return;
+
+    value = gtk_range_get_value(range);
+    properties[0] = (gint)value;
+
+    if (!gpds_xinput_set_int_properties(priv->xinput,
+                                        property,
+                                        &error,
+                                        properties,
+                                        1)) {
+        if (error) {
+            show_error(error);
+            g_error_free(error);
+        }
+    }
+}
+
+void
 gpds_xinput_ui_set_toggle_button_state_from_preference (GpdsXInputUI *ui,
                                                         gint property,
                                                         const gchar *gconf_key_name,
diff --git a/src/gpds-xinput-ui.h b/src/gpds-xinput-ui.h
index 61f6edc..0b8c9bf 100644
--- a/src/gpds-xinput-ui.h
+++ b/src/gpds-xinput-ui.h
@@ -65,6 +65,10 @@ void        gpds_xinput_ui_set_xinput_property_from_toggle_button_state
                                             (GpdsXInputUI *ui,
                                              gint property,
                                              GtkToggleButton *button);
+void        gpds_xinput_ui_set_xinput_property_from_range_value
+                                            (GpdsXInputUI *ui,
+                                             gint property,
+                                             GtkRange *range);
 void        gpds_xinput_ui_set_toggle_button_state_from_preference
                                             (GpdsXInputUI *ui,
                                              gint property,
@@ -103,24 +107,10 @@ static void
 cb_ ## function_name ## _value_changed (GtkRange *range, gpointer user_data)                \
 {                                                                                           \
     gdouble value;                                                                          \
-    GpdsXInput *xinput;                                                                     \
-    GError *error = NULL;                                                                   \
-    gint properties[1];                                                                     \
-    xinput = gpds_xinput_ui_get_xinput(GPDS_XINPUT_UI(user_data));                          \
-    if (!xinput)                                                                            \
-        return;                                                                             \
+    gpds_xinput_ui_set_xinput_property_from_range_value(GPDS_XINPUT_UI(user_data),          \
+                                                        PROPERTY_NAME,                      \
+                                                        range);                             \
     value = gtk_range_get_value(range);                                                     \
-    properties[0] = (gint)value;                                                            \
-    if (!gpds_xinput_set_int_properties(xinput,                                             \
-                                        PROPERTY_NAME,                                      \
-                                        &error,                                             \
-                                        properties,                                         \
-                                        1)) {                                               \
-        if (error) {                                                                        \
-            show_error(error);                                                              \
-            g_error_free(error);                                                            \
-        }                                                                                   \
-    }                                                                                       \
     gpds_ui_set_gconf_int(GPDS_UI(user_data), PROPERTY_NAME ## _KEY, (gint)value);          \
 }
 



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