gpointing-device-settings r186 - trunk/src



Author: hiikezoe
Date: Mon Mar  9 03:23:37 2009
New Revision: 186
URL: http://svn.gnome.org/viewvc/gpointing-device-settings?rev=186&view=rev

Log:
added gpds_gconf_get_(bool|int|string) functions with GConfValueType check.

Modified:
   trunk/src/Makefile.am
   trunk/src/gpds-gconf.c
   trunk/src/gpds-gconf.h
   trunk/src/gpds-ui.c

Modified: trunk/src/Makefile.am
==============================================================================
--- trunk/src/Makefile.am	(original)
+++ trunk/src/Makefile.am	Mon Mar  9 03:23:37 2009
@@ -25,7 +25,6 @@
 
 libgpds_la_CFLAGS =			\
 	$(GPDS_CFLAGS)			\
-	$(GCONF2_CFLAGS)	        \
 	$(COVERAGE_CFLAGS)
 
 libgpds_la_LDFLAGS =				\

Modified: trunk/src/gpds-gconf.c
==============================================================================
--- trunk/src/gpds-gconf.c	(original)
+++ trunk/src/gpds-gconf.c	Mon Mar  9 03:23:37 2009
@@ -34,6 +34,60 @@
     return segment ? segment + 1 : NULL;
 }
 
+gboolean
+gpds_gconf_get_bool (GConfClient *gconf, const gchar *key, gboolean *value)
+{
+    GConfValue *gconf_value;
+    gboolean exist_value = FALSE;
+
+    gconf_value = gconf_client_get(gconf, key, NULL);
+    if (gconf_value) {
+        if (gconf_value->type == GCONF_VALUE_BOOL) {
+            *value = gconf_value_get_bool(gconf_value);
+            exist_value = TRUE;
+        }
+        gconf_value_free(gconf_value);
+    }
+
+    return exist_value;
+}
+
+gboolean
+gpds_gconf_get_int (GConfClient *gconf, const gchar *key, gint *value)
+{
+    GConfValue *gconf_value;
+    gboolean exist_value = FALSE;
+
+    gconf_value = gconf_client_get(gconf, key, NULL);
+    if (gconf_value) {
+        if (gconf_value->type == GCONF_VALUE_INT) {
+            *value = gconf_value_get_int(gconf_value);
+            exist_value = TRUE;
+        }
+        gconf_value_free(gconf_value);
+    }
+
+    return exist_value;
+}
+
+gboolean
+gpds_gconf_get_string (GConfClient *gconf, const gchar *key, const gchar **value)
+{
+    GConfValue *gconf_value;
+    gboolean exist_value = FALSE;
+
+    gconf_value = gconf_client_get(gconf, key, NULL);
+    if (gconf_value) {
+        if (gconf_value->type == GCONF_VALUE_STRING) {
+            *value = gconf_value_get_string(gconf_value);
+            exist_value = TRUE;
+        }
+        gconf_value_free(gconf_value);
+    }
+
+    return exist_value;
+}
+
 /*
 vi:ts=4:nowrap:ai:expandtab:sw=4
 */

Modified: trunk/src/gpds-gconf.h
==============================================================================
--- trunk/src/gpds-gconf.h	(original)
+++ trunk/src/gpds-gconf.h	Mon Mar  9 03:23:37 2009
@@ -21,6 +21,7 @@
 #define __GPDS_GCONF_H__
 
 #include <glib.h>
+#include <gconf/gconf-client.h>
 
 G_BEGIN_DECLS
 
@@ -29,6 +30,16 @@
 
 const gchar *gpds_gconf_get_key_from_path (const gchar *path);
 
+gboolean     gpds_gconf_get_bool          (GConfClient *gconf,
+                                           const gchar *key,
+                                           gboolean *value);
+gboolean     gpds_gconf_get_int           (GConfClient *gconf,
+                                           const gchar *key,
+                                           gboolean *value);
+gboolean     gpds_gconf_get_string        (GConfClient *gconf,
+                                           const gchar *key,
+                                           const gchar **value);
+
 G_END_DECLS
 
 #endif /* __GPDS_GCONF_H__ */

Modified: trunk/src/gpds-ui.c
==============================================================================
--- trunk/src/gpds-ui.c	(original)
+++ trunk/src/gpds-ui.c	Mon Mar  9 03:23:37 2009
@@ -293,7 +293,6 @@
 gboolean
 gpds_ui_get_gconf_bool (GpdsUI *ui, const gchar *key, gboolean *value)
 {
-    GConfValue *gconf_value;
     gchar *gconf_key;
     gboolean exist_value = FALSE;
     GpdsUIPriv *priv;
@@ -302,12 +301,7 @@
 
     priv = GPDS_UI_GET_PRIVATE(ui);
     gconf_key = build_gconf_key(ui, key);
-    gconf_value = gconf_client_get(priv->gconf, gconf_key, NULL);
-    if (gconf_value) {
-        *value = gconf_value_get_bool(gconf_value);
-        gconf_value_free(gconf_value);
-        exist_value = TRUE;
-    }
+    exist_value =gpds_gconf_get_bool(priv->gconf, gconf_key, value);
     g_free(gconf_key);
 
     return exist_value;
@@ -330,7 +324,6 @@
 gboolean
 gpds_ui_get_gconf_int (GpdsUI *ui, const gchar *key, gint *value)
 {
-    GConfValue *gconf_value;
     gchar *gconf_key;
     gboolean exist_value = FALSE;
     GpdsUIPriv *priv;
@@ -339,12 +332,7 @@
 
     priv = GPDS_UI_GET_PRIVATE(ui);
     gconf_key = build_gconf_key(ui, key);
-    gconf_value = gconf_client_get(priv->gconf, gconf_key, NULL);
-    if (gconf_value) {
-        *value = gconf_value_get_int(gconf_value);
-        gconf_value_free(gconf_value);
-        exist_value = TRUE;
-    }
+    exist_value =gpds_gconf_get_int(priv->gconf, gconf_key, value);
     g_free(gconf_key);
 
     return exist_value;
@@ -367,7 +355,6 @@
 gboolean
 gpds_ui_get_gconf_string (GpdsUI *ui, const gchar *key, const gchar **value)
 {
-    GConfValue *gconf_value;
     gchar *gconf_key;
     gboolean exist_value = FALSE;
     GpdsUIPriv *priv;
@@ -376,12 +363,7 @@
 
     priv = GPDS_UI_GET_PRIVATE(ui);
     gconf_key = build_gconf_key(ui, key);
-    gconf_value = gconf_client_get(priv->gconf, gconf_key, NULL);
-    if (gconf_value) {
-        *value = gconf_value_get_string(gconf_value);
-        gconf_value_free(gconf_value);
-        exist_value = TRUE;
-    }
+    exist_value =gpds_gconf_get_string(priv->gconf, gconf_key, value);
     g_free(gconf_key);
 
     return exist_value;



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