grim/guifications3

Parents fcd5cd57a801
Children 6ba4348f432b
moved GfPreference and GfPreferenceType from gf_preference_engine.[ch] to gf_preference.[ch]
--- a/gflib/gflib/Makefile.am Sat Oct 10 18:38:10 2009 -0500
+++ b/gflib/gflib/Makefile.am Sat Oct 10 18:47:52 2009 -0500
@@ -50,6 +50,7 @@
gf_plugin_info.h \
gf_plugin_loader.h \
gf_plugin_manager.h \
+ gf_preference.h \
gf_preference_engine.h \
gf_preference_engine_null.h \
gf_preference_engine_xml.h \
@@ -88,6 +89,7 @@
gf_plugin_info.c \
gf_plugin_loader.c \
gf_plugin_manager.c \
+ gf_preference.c \
gf_preference_engine.c \
gf_preference_engine_null.c \
gf_preference_engine_xml.c \
@@ -122,7 +124,7 @@
gf_log.h \
gf_object.h \
gf_plugin.h \
- gf_preference_engine.h
+ gf_preference.h
gf_enum.c: $(enum_headers) gf_enum.c.template
@echo "Generating $@ ... "
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/gflib/gflib/gf_preference.c Sat Oct 10 18:47:52 2009 -0500
@@ -0,0 +1,360 @@
+/*
+ * Guifications - The end-all, be-all notification framework
+ * Copyright (C) 2003-2009 Gary Kramlich <grim@reaperworld.com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+#if HAVE_CONFIG_H
+# include <config.h>
+#endif /* HAVE_CONFIG_H */
+
+#include <gflib/gf_intl.h>
+#include <gflib/gf_preference.h>
+
+/******************************************************************************
+ * GfPrefernce API
+ *****************************************************************************/
+GType
+gf_preference_get_g_type(void) {
+ static GType type = 0;
+
+ if(type == 0) {
+ type =
+ g_boxed_type_register_static("GfPreference",
+ (GBoxedCopyFunc)gf_preference_copy,
+ (GBoxedFreeFunc)gf_preference_free);
+ }
+
+ return type;
+}
+
+/**
+ * gf_preference_copy:
+ * @pref : The #GfPreference instance.
+ *
+ * Creates a copy of @pref.
+ *
+ * Return Value: A copy of @pref.
+ */
+GfPreference *
+gf_preference_copy(const GfPreference *pref) {
+ GfPreference *copy;
+
+ g_return_val_if_fail(pref, NULL);
+
+ copy = gf_preference_new(pref->name, pref->path, pref->type, pref->value);
+
+ g_return_val_if_fail(copy, NULL);
+
+ return copy;
+}
+
+/**
+ * gf_preference_free:
+ * @pref : The #GfPreference instance.
+ *
+ * Frees @pref.
+ */
+void
+gf_preference_free(GfPreference *pref) {
+ g_return_if_fail(pref);
+
+ g_free(pref->name);
+ g_free(pref->path);
+
+ if(pref->value && G_IS_VALUE(pref->value)) {
+ g_value_unset(pref->value);
+ g_free(pref->value);
+ }
+
+ g_free(pref);
+}
+
+/**
+ * gf_preference_freev:
+ * @prefs : An array of #GfPreference's.
+ *
+ * Frees an array of #GfPreferences's.
+ */
+void
+gf_preference_freev(GfPreference **prefs) {
+ gint i = 0;
+
+ g_return_if_fail(prefs);
+
+ for(i = 0; prefs[i]; i++)
+ gf_preference_free(prefs[i]);
+
+ g_free(prefs);
+}
+
+/**
+ * gf_preference_new:
+ * @name : The name of the preference.
+ * @path : The path of the preference.
+ * @type : The #GfPreferenceType of the preference.
+ * @value : The value of the preference.
+ *
+ * Creates a new #GfPreference.
+ *
+ * Return Value: The new #GfPreference.
+ */
+GfPreference *
+gf_preference_new(const gchar *name, const gchar *path, GfPreferenceType type,
+ const GValue *value)
+{
+ GfPreference *pref;
+
+ pref = g_new(GfPreference, 1);
+
+ pref->name = (name) ? g_strdup(name) : NULL;
+ pref->path = (path) ? g_strdup(path) : NULL;
+ pref->type = type;
+
+ pref->value = g_new0(GValue, 1);
+
+ switch(pref->type) {
+ case GF_PREFERENCE_TYPE_STRING:
+ g_value_init(pref->value, G_TYPE_STRING);
+ if(value)
+ g_value_copy(value, pref->value);
+ break;
+ case GF_PREFERENCE_TYPE_INT:
+ g_value_init(pref->value, G_TYPE_INT);
+ if(value)
+ g_value_copy(value, pref->value);
+ break;
+ case GF_PREFERENCE_TYPE_BOOL:
+ g_value_init(pref->value, G_TYPE_BOOLEAN);
+ if(value)
+ g_value_copy(value, pref->value);
+ break;
+ case GF_PREFERENCE_TYPE_UNKNOWN:
+ case GF_PREFERENCE_TYPE_SECTION:
+ case GF_PREFERENCE_TYPES:
+ default:
+ g_value_init(pref->value, G_TYPE_CHAR);
+ g_value_set_char(pref->value, '\0');
+ break;
+ }
+
+ return pref;
+}
+
+/**
+ * gf_preference_get_full_name:
+ * @pref : The #GfPreference instance.
+ *
+ * Gets the full name for a preference.
+ *
+ * Return Value: The full absolute name of @pref.
+ */
+gchar *gf_preference_get_full_name(const GfPreference *pref) {
+ gchar *ret;
+
+ g_return_val_if_fail(pref, NULL);
+
+ if(!pref->path) /* root pref */
+ ret = g_strdup(pref->name);
+ else if(!g_utf8_collate(pref->path, "/")) /* first level pref */
+ ret = g_strdup_printf("/%s", pref->name);
+ else /* everything else... */
+ ret = g_strdup_printf("%s/%s", pref->path, pref->name);
+
+ return ret;
+}
+
+/**
+ * gf_preference_set_name:
+ * @pref : The #GfPreference instance.
+ * @name : The new name.
+ *
+ * Sets the name for @pref.
+ */
+void
+gf_preference_set_name(GfPreference *pref, const gchar *name) {
+ g_return_if_fail(pref);
+
+ g_free(pref->name);
+
+ pref->name = (name) ? g_strdup(name) : NULL;
+}
+
+/**
+ * gf_preference_get_name:
+ * @pref : The #GfPreference instance.
+ *
+ * Gets the name of @pref.
+ *
+ * Return Value: The name of @pref.
+ */
+const gchar *
+gf_preference_get_name(const GfPreference *pref) {
+ g_return_val_if_fail(pref, NULL);
+
+ return pref->name;
+}
+
+/**
+ * gf_preference_set_path:
+ * @pref : The #GfPreference instance.
+ * @path : The new path.
+ *
+ * Sets the path for @pref.
+ */
+void
+gf_preference_set_path(GfPreference *pref, const gchar *path) {
+ g_return_if_fail(pref);
+
+ g_free(pref->path);
+
+ pref->path = (path) ? g_strdup(path) : NULL;
+}
+
+/**
+ * gf_preference_get_path:
+ * @pref : The #GfPreference instance.
+ *
+ * Gets the path of @pref.
+ *
+ * Return Value: The path of @pref.
+ */
+const gchar *
+gf_preference_get_path(const GfPreference *pref) {
+ g_return_val_if_fail(pref, NULL);
+
+ return pref->path;
+}
+
+/**
+ * gf_preference_set_type:
+ * @pref : The #GfPreference instance.
+ * @type : The new type.
+ *
+ * Sets the type of @pref.
+ */
+void
+gf_preference_set_type(GfPreference *pref, GfPreferenceType type) {
+ g_return_if_fail(pref);
+
+ pref->type = type;
+}
+
+/**
+ * gf_preference_get_type:
+ * @pref : The #GfPreference instance.
+ *
+ * Gets the type of @pref.
+ *
+ * Return Value: The type of @pref.
+ */
+GfPreferenceType
+gf_preference_get_type(const GfPreference *pref) {
+ g_return_val_if_fail(pref, GF_PREFERENCE_TYPE_UNKNOWN);
+
+ return pref->type;
+}
+
+/**
+ * gf_preference_set_string:
+ * @pref : The #GfPreference instance.
+ * @value : The new string value.
+ *
+ * Sets the string value for @pref.
+ */
+void
+gf_preference_set_string(GfPreference *pref, const gchar *value) {
+ g_return_if_fail(pref);
+ g_return_if_fail(G_VALUE_TYPE(pref->value) == G_TYPE_STRING);
+
+ g_value_set_string(pref->value, value);
+}
+
+/**
+ * gf_preference_get_string:
+ * @pref : The #GfPreference instance.
+ *
+ * Gets the string value for @pref.
+ *
+ * Return Value: The string value for @pref.
+ */
+const gchar *
+gf_preference_get_string(const GfPreference *pref) {
+ g_return_val_if_fail(pref, NULL);
+ g_return_val_if_fail(G_VALUE_TYPE(pref->value) == G_TYPE_STRING, NULL);
+
+ return g_value_get_string(pref->value);
+}
+
+/**
+ * gf_preference_set_int:
+ * @pref : The #GfPreference instance.
+ * @value : The new integer value.
+ *
+ * Sets the integer value of @pref.
+ */
+void
+gf_preference_set_int(GfPreference *pref, gint value) {
+ g_return_if_fail(pref);
+ g_return_if_fail(G_VALUE_TYPE(pref->value) == G_TYPE_INT);
+
+ g_value_set_int(pref->value, value);
+}
+
+/**
+ * gf_preference_get_int:
+ * @pref : The #GfPreference instance.
+ *
+ * Gets the integer value of @pref.
+ *
+ * Return Value: The integer value of @pref.
+ */
+gint
+gf_preference_get_int(const GfPreference *pref) {
+ g_return_val_if_fail(pref, 0);
+ g_return_val_if_fail(G_VALUE_TYPE(pref->value) == G_TYPE_INT, 0);
+
+ return g_value_get_int(pref->value);
+}
+
+/**
+ * gf_preference_set_bool:
+ * @pref : The #GfPreference instance.
+ * @value : The new boolean value.
+ *
+ * Sets the boolean value of @pref.
+ */
+void
+gf_preference_set_bool(GfPreference *pref, gboolean value) {
+ g_return_if_fail(pref);
+ g_return_if_fail(G_VALUE_TYPE(pref->value) == G_TYPE_BOOLEAN);
+
+ g_value_set_boolean(pref->value, value);
+}
+
+/**
+ * gf_preference_get_bool:
+ * @pref : The #GfPreference instance.
+ *
+ * Gets the boolean value of @pref.
+ *
+ * Return Value: The boolean value of @pref.
+ */
+gboolean
+gf_preference_get_bool(const GfPreference *pref) {
+ g_return_val_if_fail(pref, FALSE);
+ g_return_val_if_fail(G_VALUE_TYPE(pref->value) == G_TYPE_BOOLEAN, FALSE);
+
+ return g_value_get_boolean(pref->value);
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/gflib/gflib/gf_preference.h Sat Oct 10 18:47:52 2009 -0500
@@ -0,0 +1,90 @@
+/*
+ * Guifications - The end-all, be-all notification framework
+ * Copyright (C) 2003-2009 Gary Kramlich <grim@reaperworld.com>
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program. If not, see <http://www.gnu.org/licenses/>.
+ */
+#ifndef GF_PREFERENCE_H
+#define GF_PREFERENCE_H
+
+#define GF_TYPE_PREFERENCE (gf_preference_get_g_type())
+
+typedef struct _GfPreference GfPreference;
+
+#include <gflib/gf_enum.h>
+
+/**
+ * GfPreferenceType:
+ * @GF_PREFERENCE_TYPE_UNKNOWN: The preference has an unknown type.
+ * @GF_PREFERENCE_TYPE_SECTION: The prefernce is a section.
+ * @GF_PREFERENCE_TYPE_STRING: The preference is a string.
+ * @GF_PREFERENCE_TYPE_INT: The preference is an integer.
+ * @GF_PREFERENCE_TYPE_BOOL: The preference is a boolean.
+ * @GF_PREFERENCE_TYPES: The number of preferences.
+ *
+ * The different types that a #GfPreference can be.
+ */
+typedef enum {
+ GF_PREFERENCE_TYPE_UNKNOWN = -1, /*< skip >*/
+ GF_PREFERENCE_TYPE_SECTION = 0, /*< nick=Section >*/
+ GF_PREFERENCE_TYPE_STRING, /*< nick=String >*/
+ GF_PREFERENCE_TYPE_INT, /*< nick=Integer >*/
+ GF_PREFERENCE_TYPE_BOOL, /*< nick=Boolean >*/
+ GF_PREFERENCE_TYPES /*< skip >*/
+} GfPreferenceType;
+
+struct _GfPreference {
+ gchar *name;
+ gchar *path;
+ GfPreferenceType type;
+ GValue *value;
+};
+
+G_BEGIN_DECLS
+
+GType gf_preference_get_g_type(void);
+
+GfPreference *gf_preference_copy(const GfPreference *pref);
+void gf_preference_free(GfPreference *pref);
+void gf_preference_freev(GfPreference **prefs);
+GfPreference *gf_preference_new(const gchar *name, const gchar *path, GfPreferenceType type, const GValue *value);
+
+gchar *gf_preference_get_full_name(const GfPreference *pref);
+
+void gf_preference_set_name(GfPreference *pref, const gchar *name);
+const gchar *gf_preference_get_name(const GfPreference *pref);
+
+void gf_preference_set_path(GfPreference *pref, const gchar *path);
+const gchar *gf_preference_get_path(const GfPreference *pref);
+
+void gf_preference_set_type(GfPreference *pref, GfPreferenceType type);
+GfPreferenceType gf_preference_get_type(const GfPreference *pref);
+
+void gf_preference_set_string(GfPreference *pref, const gchar *value);
+const gchar *gf_preference_get_string(const GfPreference *pref);
+
+void gf_preference_set_int(GfPreference *pref, gint value);
+gint gf_preference_get_int(const GfPreference *pref);
+
+void gf_preference_set_bool(GfPreference *pref, gboolean value);
+gboolean gf_preference_get_bool(const GfPreference *pref);
+
+#define gf_preference_type_from_string(str) \
+ gf_enum_from_string(GF_TYPE_PREFERENCE_TYPE, (str))
+#define gf_preference_type_to_string(type, i18n) \
+ gf_enum_to_string(GF_TYPE_PREFERENCE_TYPE, (type), (i18n))
+
+G_END_DECLS
+
+#endif /* GF_PREFERENCE_H */
--- a/gflib/gflib/gf_preference_engine.c Sat Oct 10 18:38:10 2009 -0500
+++ b/gflib/gflib/gf_preference_engine.c Sat Oct 10 18:47:52 2009 -0500
@@ -570,339 +570,3 @@
return GF_PREFERENCE_TYPE_UNKNOWN;
}
-/******************************************************************************
- * GfPrefernce API
- *****************************************************************************/
-GType
-gf_preference_get_g_type(void) {
- static GType type = 0;
-
- if(type == 0) {
- type =
- g_boxed_type_register_static("GfPreference",
- (GBoxedCopyFunc)gf_preference_copy,
- (GBoxedFreeFunc)gf_preference_free);
- }
-
- return type;
-}
-
-/**
- * gf_preference_copy:
- * @pref : The #GfPreference instance.
- *
- * Creates a copy of @pref.
- *
- * Return Value: A copy of @pref.
- */
-GfPreference *
-gf_preference_copy(const GfPreference *pref) {
- GfPreference *copy;
-
- g_return_val_if_fail(pref, NULL);
-
- copy = gf_preference_new(pref->name, pref->path, pref->type, pref->value);
-
- g_return_val_if_fail(copy, NULL);
-
- return copy;
-}
-
-/**
- * gf_preference_free:
- * @pref : The #GfPreference instance.
- *
- * Frees @pref.
- */
-void
-gf_preference_free(GfPreference *pref) {
- g_return_if_fail(pref);
-
- g_free(pref->name);
- g_free(pref->path);
-
- if(pref->value && G_IS_VALUE(pref->value)) {
- g_value_unset(pref->value);
- g_free(pref->value);
- }
-
- g_free(pref);
-}
-
-/**
- * gf_preference_freev:
- * @prefs : An array of #GfPreference's.
- *
- * Frees an array of #GfPreferences's.
- */
-void
-gf_preference_freev(GfPreference **prefs) {
- gint i = 0;
-
- g_return_if_fail(prefs);
-
- for(i = 0; prefs[i]; i++)
- gf_preference_free(prefs[i]);
-
- g_free(prefs);
-}
-
-/**
- * gf_preference_new:
- * @name : The name of the preference.
- * @path : The path of the preference.
- * @type : The #GfPreferenceType of the preference.
- * @value : The value of the preference.
- *
- * Creates a new #GfPreference.
- *
- * Return Value: The new #GfPreference.
- */
-GfPreference *
-gf_preference_new(const gchar *name, const gchar *path, GfPreferenceType type,
- const GValue *value)
-{
- GfPreference *pref;
-
- pref = g_new(GfPreference, 1);
-
- pref->name = (name) ? g_strdup(name) : NULL;
- pref->path = (path) ? g_strdup(path) : NULL;
- pref->type = type;
-
- pref->value = g_new0(GValue, 1);
-
- switch(pref->type) {
- case GF_PREFERENCE_TYPE_STRING:
- g_value_init(pref->value, G_TYPE_STRING);
- if(value)
- g_value_copy(value, pref->value);
- break;
- case GF_PREFERENCE_TYPE_INT:
- g_value_init(pref->value, G_TYPE_INT);
- if(value)
- g_value_copy(value, pref->value);
- break;
- case GF_PREFERENCE_TYPE_BOOL:
- g_value_init(pref->value, G_TYPE_BOOLEAN);
- if(value)
- g_value_copy(value, pref->value);
- break;
- case GF_PREFERENCE_TYPE_UNKNOWN:
- case GF_PREFERENCE_TYPE_SECTION:
- case GF_PREFERENCE_TYPES:
- default:
- g_value_init(pref->value, G_TYPE_CHAR);
- g_value_set_char(pref->value, '\0');
- break;
- }
-
- return pref;
-}
-
-/**
- * gf_preference_get_full_name:
- * @pref : The #GfPreference instance.
- *
- * Gets the full name for a preference.
- *
- * Return Value: The full absolute name of @pref.
- */
-gchar *gf_preference_get_full_name(const GfPreference *pref) {
- gchar *ret;
-
- g_return_val_if_fail(pref, NULL);
-
- if(!pref->path) /* root pref */
- ret = g_strdup(pref->name);
- else if(!g_utf8_collate(pref->path, "/")) /* first level pref */
- ret = g_strdup_printf("/%s", pref->name);
- else /* everything else... */
- ret = g_strdup_printf("%s/%s", pref->path, pref->name);
-
- return ret;
-}
-
-/**
- * gf_preference_set_name:
- * @pref : The #GfPreference instance.
- * @name : The new name.
- *
- * Sets the name for @pref.
- */
-void
-gf_preference_set_name(GfPreference *pref, const gchar *name) {
- g_return_if_fail(pref);
-
- g_free(pref->name);
-
- pref->name = (name) ? g_strdup(name) : NULL;
-}
-
-/**
- * gf_preference_get_name:
- * @pref : The #GfPreference instance.
- *
- * Gets the name of @pref.
- *
- * Return Value: The name of @pref.
- */
-const gchar *
-gf_preference_get_name(const GfPreference *pref) {
- g_return_val_if_fail(pref, NULL);
-
- return pref->name;
-}
-
-/**
- * gf_preference_set_path:
- * @pref : The #GfPreference instance.
- * @path : The new path.
- *
- * Sets the path for @pref.
- */
-void
-gf_preference_set_path(GfPreference *pref, const gchar *path) {
- g_return_if_fail(pref);
-
- g_free(pref->path);
-
- pref->path = (path) ? g_strdup(path) : NULL;
-}
-
-/**
- * gf_preference_get_path:
- * @pref : The #GfPreference instance.
- *
- * Gets the path of @pref.
- *
- * Return Value: The path of @pref.
- */
-const gchar *
-gf_preference_get_path(const GfPreference *pref) {
- g_return_val_if_fail(pref, NULL);
-
- return pref->path;
-}
-
-/**
- * gf_preference_set_type:
- * @pref : The #GfPreference instance.
- * @type : The new type.
- *
- * Sets the type of @pref.
- */
-void
-gf_preference_set_type(GfPreference *pref, GfPreferenceType type) {
- g_return_if_fail(pref);
-
- pref->type = type;
-}
-
-/**
- * gf_preference_get_type:
- * @pref : The #GfPreference instance.
- *
- * Gets the type of @pref.
- *
- * Return Value: The type of @pref.
- */
-GfPreferenceType
-gf_preference_get_type(const GfPreference *pref) {
- g_return_val_if_fail(pref, GF_PREFERENCE_TYPE_UNKNOWN);
-
- return pref->type;
-}
-
-/**
- * gf_preference_set_string:
- * @pref : The #GfPreference instance.
- * @value : The new string value.
- *
- * Sets the string value for @pref.
- */
-void
-gf_preference_set_string(GfPreference *pref, const gchar *value) {
- g_return_if_fail(pref);
- g_return_if_fail(G_VALUE_TYPE(pref->value) == G_TYPE_STRING);
-
- g_value_set_string(pref->value, value);
-}
-
-/**
- * gf_preference_get_string:
- * @pref : The #GfPreference instance.
- *
- * Gets the string value for @pref.
- *
- * Return Value: The string value for @pref.
- */
-const gchar *
-gf_preference_get_string(const GfPreference *pref) {
- g_return_val_if_fail(pref, NULL);
- g_return_val_if_fail(G_VALUE_TYPE(pref->value) == G_TYPE_STRING, NULL);
-
- return g_value_get_string(pref->value);
-}
-
-/**
- * gf_preference_set_int:
- * @pref : The #GfPreference instance.
- * @value : The new integer value.
- *
- * Sets the integer value of @pref.
- */
-void
-gf_preference_set_int(GfPreference *pref, gint value) {
- g_return_if_fail(pref);
- g_return_if_fail(G_VALUE_TYPE(pref->value) == G_TYPE_INT);
-
- g_value_set_int(pref->value, value);
-}
-
-/**
- * gf_preference_get_int:
- * @pref : The #GfPreference instance.
- *
- * Gets the integer value of @pref.
- *
- * Return Value: The integer value of @pref.
- */
-gint
-gf_preference_get_int(const GfPreference *pref) {
- g_return_val_if_fail(pref, 0);
- g_return_val_if_fail(G_VALUE_TYPE(pref->value) == G_TYPE_INT, 0);
-
- return g_value_get_int(pref->value);
-}
-
-/**
- * gf_preference_set_bool:
- * @pref : The #GfPreference instance.
- * @value : The new boolean value.
- *
- * Sets the boolean value of @pref.
- */
-void
-gf_preference_set_bool(GfPreference *pref, gboolean value) {
- g_return_if_fail(pref);
- g_return_if_fail(G_VALUE_TYPE(pref->value) == G_TYPE_BOOLEAN);
-
- g_value_set_boolean(pref->value, value);
-}
-
-/**
- * gf_preference_get_bool:
- * @pref : The #GfPreference instance.
- *
- * Gets the boolean value of @pref.
- *
- * Return Value: The boolean value of @pref.
- */
-gboolean
-gf_preference_get_bool(const GfPreference *pref) {
- g_return_val_if_fail(pref, FALSE);
- g_return_val_if_fail(G_VALUE_TYPE(pref->value) == G_TYPE_BOOLEAN, FALSE);
-
- return g_value_get_boolean(pref->value);
-}
--- a/gflib/gflib/gf_preference_engine.h Sat Oct 10 18:38:10 2009 -0500
+++ b/gflib/gflib/gf_preference_engine.h Sat Oct 10 18:47:52 2009 -0500
@@ -28,41 +28,9 @@
typedef struct _GfPreferenceEngine GfPreferenceEngine;
typedef struct _GfPreferenceEngineClass GfPreferenceEngineClass;
-#define GF_TYPE_PREFERENCE_TYPE (gf_preference_type_get_type())
-
-#define GF_TYPE_PREFERENCE (gf_preference_get_g_type())
-
-typedef struct _GfPreference GfPreference;
-
#include <gflib/gf_enum.h>
#include <gflib/gf_named_object.h>
-
-/**
- * GfPreference:
- * @GF_PREFERENCE_TYPE_UNKNOWN: The preference has an unknown type.
- * @GF_PREFERENCE_TYPE_SECTION: The prefernce is a section.
- * @GF_PREFERENCE_TYPE_STRING: The preference is a string.
- * @GF_PREFERENCE_TYPE_INT: The preference is an integer.
- * @GF_PREFERENCE_TYPE_BOOL: The preference is a boolean.
- * @GF_PREFERENCE_TYPES: The number of preferences.
- *
- * The different types that a #GfPreference can be.
- */
-typedef enum {
- GF_PREFERENCE_TYPE_UNKNOWN = -1, /*< skip >*/
- GF_PREFERENCE_TYPE_SECTION = 0, /*< nick=Section >*/
- GF_PREFERENCE_TYPE_STRING, /*< nick=String >*/
- GF_PREFERENCE_TYPE_INT, /*< nick=Integer >*/
- GF_PREFERENCE_TYPE_BOOL, /*< nick=Boolean >*/
- GF_PREFERENCE_TYPES /*< skip >*/
-} GfPreferenceType;
-
-struct _GfPreference {
- gchar *name;
- gchar *path;
- GfPreferenceType type;
- GValue *value;
-};
+#include <gflib/gf_preference.h>
struct _GfPreferenceEngine {
GfNamedObject gparent;
@@ -140,37 +108,6 @@
GfPreferenceType gf_preference_engine_get_type(GfPreferenceEngine *engine, const gchar *path);
-#define gf_preference_type_from_string(str) \
- gf_enum_from_string(GF_TYPE_PREFERENCE_TYPE, (str))
-#define gf_preference_type_to_string(type, i18n) \
- gf_enum_to_string(GF_TYPE_PREFERENCE_TYPE, (type), (i18n))
-
-GType gf_preference_get_g_type(void);
-GfPreference *gf_preference_copy(const GfPreference *pref);
-void gf_preference_free(GfPreference *pref);
-void gf_preference_freev(GfPreference **prefs);
-GfPreference *gf_preference_new(const gchar *name, const gchar *path, GfPreferenceType type, const GValue *value);
-
-gchar *gf_preference_get_full_name(const GfPreference *pref);
-
-void gf_preference_set_name(GfPreference *pref, const gchar *name);
-const gchar *gf_preference_get_name(const GfPreference *pref);
-
-void gf_preference_set_path(GfPreference *pref, const gchar *path);
-const gchar *gf_preference_get_path(const GfPreference *pref);
-
-void gf_preference_set_type(GfPreference *pref, GfPreferenceType type);
-GfPreferenceType gf_preference_get_type(const GfPreference *pref);
-
-void gf_preference_set_string(GfPreference *pref, const gchar *value);
-const gchar *gf_preference_get_string(const GfPreference *pref);
-
-void gf_preference_set_int(GfPreference *pref, gint value);
-gint gf_preference_get_int(const GfPreference *pref);
-
-void gf_preference_set_bool(GfPreference *pref, gboolean value);
-gboolean gf_preference_get_bool(const GfPreference *pref);
-
G_END_DECLS
#endif /* GF_PREFERENCE_ENGINE_H */