gpointing-device-settings r196 - trunk/src



Author: hiikezoe
Date: Tue Mar 10 03:37:01 2009
New Revision: 196
URL: http://svn.gnome.org/viewvc/gpointing-device-settings?rev=196&view=rev

Log:
set error.

Modified:
   trunk/src/gpds-xinput.c
   trunk/src/gpds-xinput.h

Modified: trunk/src/gpds-xinput.c
==============================================================================
--- trunk/src/gpds-xinput.c	(original)
+++ trunk/src/gpds-xinput.c	Tue Mar 10 03:37:01 2009
@@ -159,6 +159,12 @@
     }
 }
 
+GQuark
+gpds_xinput_error_quark (void)
+{
+    return g_quark_from_static_string("gpds-xinput-error-quark");
+}
+
 GpdsXInput *
 gpds_xinput_new (const gchar *device_name)
 {
@@ -252,7 +258,7 @@
 }
 
 static const gchar *
-get_property_name_from_property_enum (GpdsXInput *xinput, gint property_enum)
+get_property_name_from_property_enum (GpdsXInput *xinput, gint property_enum, GError **error)
 {
     gint i;
     GpdsXInputPriv *priv = GPDS_XINPUT_GET_PRIVATE(xinput);
@@ -262,11 +268,15 @@
             return priv->property_entries[i].name;
     }
 
+    g_set_error(error,
+                GPDS_XINPUT_ERROR,
+                GPDS_XINPUT_ERROR_NO_REGISTERED_PROPERTY,
+                _("There is no registered property for %d."), property_enum);
     return NULL;
 }
 
 static gint
-get_format_type_from_property_enum (GpdsXInput *xinput, gint property_enum)
+get_format_type_from_property_enum (GpdsXInput *xinput, gint property_enum, GError **error)
 {
     gint i;
     GpdsXInputPriv *priv = GPDS_XINPUT_GET_PRIVATE(xinput);
@@ -276,11 +286,15 @@
             return priv->property_entries[i].format_type;
     }
 
+    g_set_error(error,
+                GPDS_XINPUT_ERROR,
+                GPDS_XINPUT_ERROR_NO_REGISTERED_PROPERTY,
+                _("There is no registered property for %d."), property_enum);
     return -1;
 }
 
 static gint
-get_max_value_count_type_from_property_enum (GpdsXInput *xinput, gint property_enum)
+get_max_value_count_type_from_property_enum (GpdsXInput *xinput, gint property_enum, GError **error)
 {
     gint i;
     GpdsXInputPriv *priv = GPDS_XINPUT_GET_PRIVATE(xinput);
@@ -290,6 +304,10 @@
             return priv->property_entries[i].max_value_count;
     }
 
+    g_set_error(error,
+                GPDS_XINPUT_ERROR,
+                GPDS_XINPUT_ERROR_NO_REGISTERED_PROPERTY,
+                _("There is no registered property for %d."), property_enum);
     return -1;
 }
 
@@ -305,15 +323,13 @@
 
     g_return_val_if_fail(GPDS_IS_XINPUT(xinput), FALSE);
 
-    property_name = get_property_name_from_property_enum(xinput, property_enum);
-    if (!property_name) {
+    property_name = get_property_name_from_property_enum(xinput, property_enum, error);
+    if (!property_name)
         return FALSE;
-    }
 
-    format_type = get_format_type_from_property_enum(xinput, property_enum);
-    if (format_type < 0) {
+    format_type = get_format_type_from_property_enum(xinput, property_enum, error);
+    if (format_type < 0)
         return FALSE;
-    }
 
     return gpds_xinput_set_int_properties_by_name_with_format_type(xinput,
                                                                    property_name,
@@ -350,11 +366,12 @@
     return found_atom;
 }
 
-static gboolean
-get_int_properties (GpdsXInput *xinput,
-                    const gchar *property_name,
-                    GError **error,
-                    gint **values, gulong *n_values)
+gboolean
+gpds_xinput_get_int_properties_by_name (GpdsXInput *xinput,
+                                        const gchar *property_name,
+                                        GError **error,
+                                        gint **values,
+                                        gulong *n_values)
 {
     XDevice *device;
     Atom atom;
@@ -415,24 +432,6 @@
 }
 
 gboolean
-gpds_xinput_get_int_properties_by_name (GpdsXInput *xinput,
-                                        const gchar *property_name,
-                                        GError **error,
-                                        gint **values,
-                                        gulong *n_values)
-{
-    XDevice *device;
-
-    g_return_val_if_fail(GPDS_IS_XINPUT(xinput), FALSE);
-
-    device = get_device(xinput, error);
-    if (!device)
-        return FALSE;
-
-    return get_int_properties(xinput, property_name, error, values, n_values);
-}
-
-gboolean
 gpds_xinput_get_int_properties (GpdsXInput *xinput,
                                 gint property_enum,
                                 GError **error,
@@ -443,21 +442,23 @@
 
     g_return_val_if_fail(GPDS_IS_XINPUT(xinput), FALSE);
 
-    property_name = get_property_name_from_property_enum(xinput, property_enum);
-    if (!property_name) {
+    property_name = get_property_name_from_property_enum(xinput, property_enum, error);
+    if (!property_name)
         return FALSE;
-    }
 
-    return get_int_properties(xinput, 
-                              property_name, error, values, n_values);
+    return gpds_xinput_get_int_properties_by_name(xinput, 
+                                                 property_name,
+                                                 error,
+                                                 values,
+                                                 n_values);
 }
 
 gboolean
-gpds_xinput_set_float_properties (GpdsXInput *xinput,
-                                  const gchar *property_name,
-                                  GError **error,
-                                  gdouble *properties,
-                                  guint n_properties)
+gpds_xinput_set_float_properties_by_name (GpdsXInput *xinput,
+                                          const gchar *property_name,
+                                          GError **error,
+                                          gdouble *properties,
+                                          guint n_properties)
 {
     XDevice *device;
     Atom float_atom, property_atom;
@@ -493,11 +494,33 @@
 }
 
 gboolean
-gpds_xinput_get_float_properties (GpdsXInput *xinput,
-                                  const gchar *property_name,
+gpds_xinput_set_float_properties (GpdsXInput *xinput,
+                                  gint property_enum,
                                   GError **error,
-                                  gdouble **properties,
-                                  gulong *n_properties)
+                                  gdouble *properties,
+                                  guint n_properties)
+{
+    const gchar *property_name;
+
+    g_return_val_if_fail(GPDS_IS_XINPUT(xinput), FALSE);
+
+    property_name = get_property_name_from_property_enum(xinput, property_enum, error);
+    if (!property_name)
+        return FALSE;
+
+    return gpds_xinput_set_float_properties_by_name(xinput,
+                                                    property_name,
+                                                    error,
+                                                    properties,
+                                                    n_properties);
+}
+
+gboolean
+gpds_xinput_get_float_properties_by_name (GpdsXInput *xinput,
+                                          const gchar *property_name,
+                                          GError **error,
+                                          gdouble **properties,
+                                          gulong *n_properties)
 {
     XDevice *device;
     Atom property_atom, float_atom;
@@ -551,6 +574,28 @@
     return TRUE;
 }
 
+gboolean
+gpds_xinput_get_float_properties (GpdsXInput *xinput,
+                                  gint property_enum,
+                                  GError **error,
+                                  gdouble **values,
+                                  gulong *n_values)
+{
+    const gchar *property_name;
+
+    g_return_val_if_fail(GPDS_IS_XINPUT(xinput), FALSE);
+
+    property_name = get_property_name_from_property_enum(xinput, property_enum, error);
+    if (!property_name)
+        return FALSE;
+
+    return gpds_xinput_get_float_properties_by_name(xinput, 
+                                                    property_name,
+                                                    error,
+                                                    values,
+                                                    n_values);
+}
+
 void
 gpds_xinput_register_property_entries (GpdsXInput *xinput,
                                        const GpdsXInputPropertyEntry *entries,

Modified: trunk/src/gpds-xinput.h
==============================================================================
--- trunk/src/gpds-xinput.h	(original)
+++ trunk/src/gpds-xinput.h	Tue Mar 10 03:37:01 2009
@@ -31,6 +31,13 @@
 #define GPDS_IS_XINPUT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GPDS_TYPE_XINPUT))
 #define GPDS_XINPUT_GET_CLASS(obj)  (G_TYPE_INSTANCE_GET_CLASS((obj), GPDS_TYPE_XINPUT, GpdsXInputClass))
 
+#define GPDS_XINPUT_ERROR           (gpds_xinput_error_quark())
+
+typedef enum
+{
+    GPDS_XINPUT_ERROR_NO_REGISTERED_PROPERTY
+} GpdsXInputError;
+
 typedef struct _GpdsXInputPropertyEntry GpdsXInputPropertyEntry;
 struct _GpdsXInputPropertyEntry
 {
@@ -54,7 +61,8 @@
     GObjectClass parent_class;
 };
 
-GType         gpds_xinput_get_type            (void) G_GNUC_CONST;
+GQuark       gpds_xinput_error_quark          (void);
+GType        gpds_xinput_get_type             (void) G_GNUC_CONST;
 
 GpdsXInput  *gpds_xinput_new                  (const gchar *device_name);
 const gchar *gpds_xinput_get_device_name      (GpdsXInput *xinput);
@@ -87,11 +95,23 @@
                                                gint **values,
                                                gulong *n_values);
 gboolean     gpds_xinput_set_float_properties (GpdsXInput *xinput,
+                                               gint property_enum,
+                                               GError **error,
+                                               gdouble *properties,
+                                               guint n_properties);
+gboolean     gpds_xinput_set_float_properties_by_name
+                                              (GpdsXInput *xinput,
                                                const gchar *property_name,
                                                GError **error,
                                                gdouble *properties,
                                                guint n_properties);
 gboolean     gpds_xinput_get_float_properties (GpdsXInput *xinput,
+                                               gint property_enum,
+                                               GError **error,
+                                               gdouble **properties,
+                                               gulong *n_properties);
+gboolean     gpds_xinput_get_float_properties_by_name
+                                              (GpdsXInput *xinput,
                                                const gchar *property_name,
                                                GError **error,
                                                gdouble **properties,



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