--- 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_preference_engine_null.h \
gf_preference_engine_xml.h \
@@ -88,6 +89,7 @@
gf_preference_engine_null.c \
gf_preference_engine_xml.c \
@@ -122,7 +124,7 @@
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/>. +#endif /* HAVE_CONFIG_H */ +#include <gflib/gf_intl.h> +#include <gflib/gf_preference.h> +/****************************************************************************** + *****************************************************************************/ +gf_preference_get_g_type(void) { + g_boxed_type_register_static("GfPreference", + (GBoxedCopyFunc)gf_preference_copy, + (GBoxedFreeFunc)gf_preference_free); + * @pref : The #GfPreference instance. + * Creates a copy of @pref. + * Return Value: A copy of @pref. +gf_preference_copy(const GfPreference *pref) { + 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); + * @pref : The #GfPreference instance. +gf_preference_free(GfPreference *pref) { + g_return_if_fail(pref); + if(pref->value && G_IS_VALUE(pref->value)) { + g_value_unset(pref->value); + * @prefs : An array of #GfPreference's. + * Frees an array of #GfPreferences's. +gf_preference_freev(GfPreference **prefs) { + g_return_if_fail(prefs); + for(i = 0; prefs[i]; i++) + gf_preference_free(prefs[i]); + * @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. +gf_preference_new(const gchar *name, const gchar *path, GfPreferenceType type, + pref = g_new(GfPreference, 1); + pref->name = (name) ? g_strdup(name) : NULL; + pref->path = (path) ? g_strdup(path) : NULL; + pref->value = g_new0(GValue, 1); + case GF_PREFERENCE_TYPE_STRING: + g_value_init(pref->value, G_TYPE_STRING); + g_value_copy(value, pref->value); + case GF_PREFERENCE_TYPE_INT: + g_value_init(pref->value, G_TYPE_INT); + g_value_copy(value, pref->value); + case GF_PREFERENCE_TYPE_BOOL: + g_value_init(pref->value, G_TYPE_BOOLEAN); + g_value_copy(value, pref->value); + case GF_PREFERENCE_TYPE_UNKNOWN: + case GF_PREFERENCE_TYPE_SECTION: + case GF_PREFERENCE_TYPES: + g_value_init(pref->value, G_TYPE_CHAR); + g_value_set_char(pref->value, '\0'); + * 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) { + 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); + * gf_preference_set_name: + * @pref : The #GfPreference instance. + * @name : The new name. + * Sets the name for @pref. +gf_preference_set_name(GfPreference *pref, const gchar *name) { + g_return_if_fail(pref); + 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. +gf_preference_get_name(const GfPreference *pref) { + g_return_val_if_fail(pref, NULL); + * gf_preference_set_path: + * @pref : The #GfPreference instance. + * @path : The new path. + * Sets the path for @pref. +gf_preference_set_path(GfPreference *pref, const gchar *path) { + g_return_if_fail(pref); + 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. +gf_preference_get_path(const GfPreference *pref) { + g_return_val_if_fail(pref, NULL); + * gf_preference_set_type: + * @pref : The #GfPreference instance. + * @type : The new type. + * Sets the type of @pref. +gf_preference_set_type(GfPreference *pref, GfPreferenceType type) { + g_return_if_fail(pref); + * gf_preference_get_type: + * @pref : The #GfPreference instance. + * Gets the type of @pref. + * Return Value: The type of @pref. +gf_preference_get_type(const GfPreference *pref) { + g_return_val_if_fail(pref, GF_PREFERENCE_TYPE_UNKNOWN); + * gf_preference_set_string: + * @pref : The #GfPreference instance. + * @value : The new string value. + * Sets the string value for @pref. +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. +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. +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. +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. +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. +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/>. +#define GF_TYPE_PREFERENCE (gf_preference_get_g_type()) +typedef struct _GfPreference GfPreference; +#include <gflib/gf_enum.h> + * @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. + 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 >*/ +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)) +#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;
-/******************************************************************************
- *****************************************************************************/
-gf_preference_get_g_type(void) {
- g_boxed_type_register_static("GfPreference",
- (GBoxedCopyFunc)gf_preference_copy,
- (GBoxedFreeFunc)gf_preference_free);
- * @pref : The #GfPreference instance.
- * Creates a copy of @pref.
- * Return Value: A copy of @pref.
-gf_preference_copy(const GfPreference *pref) {
- 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);
- * @pref : The #GfPreference instance.
-gf_preference_free(GfPreference *pref) {
- g_return_if_fail(pref);
- if(pref->value && G_IS_VALUE(pref->value)) {
- g_value_unset(pref->value);
- * @prefs : An array of #GfPreference's.
- * Frees an array of #GfPreferences's.
-gf_preference_freev(GfPreference **prefs) {
- g_return_if_fail(prefs);
- for(i = 0; prefs[i]; i++)
- gf_preference_free(prefs[i]);
- * @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.
-gf_preference_new(const gchar *name, const gchar *path, GfPreferenceType type,
- pref = g_new(GfPreference, 1);
- pref->name = (name) ? g_strdup(name) : NULL;
- pref->path = (path) ? g_strdup(path) : NULL;
- pref->value = g_new0(GValue, 1);
- case GF_PREFERENCE_TYPE_STRING:
- g_value_init(pref->value, G_TYPE_STRING);
- g_value_copy(value, pref->value);
- case GF_PREFERENCE_TYPE_INT:
- g_value_init(pref->value, G_TYPE_INT);
- g_value_copy(value, pref->value);
- case GF_PREFERENCE_TYPE_BOOL:
- g_value_init(pref->value, G_TYPE_BOOLEAN);
- g_value_copy(value, pref->value);
- case GF_PREFERENCE_TYPE_UNKNOWN:
- case GF_PREFERENCE_TYPE_SECTION:
- case GF_PREFERENCE_TYPES:
- g_value_init(pref->value, G_TYPE_CHAR);
- g_value_set_char(pref->value, '\0');
- * 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) {
- 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);
- * gf_preference_set_name:
- * @pref : The #GfPreference instance.
- * @name : The new name.
- * Sets the name for @pref.
-gf_preference_set_name(GfPreference *pref, const gchar *name) {
- g_return_if_fail(pref);
- 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.
-gf_preference_get_name(const GfPreference *pref) {
- g_return_val_if_fail(pref, NULL);
- * gf_preference_set_path:
- * @pref : The #GfPreference instance.
- * @path : The new path.
- * Sets the path for @pref.
-gf_preference_set_path(GfPreference *pref, const gchar *path) {
- g_return_if_fail(pref);
- 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.
-gf_preference_get_path(const GfPreference *pref) {
- g_return_val_if_fail(pref, NULL);
- * gf_preference_set_type:
- * @pref : The #GfPreference instance.
- * @type : The new type.
- * Sets the type of @pref.
-gf_preference_set_type(GfPreference *pref, GfPreferenceType type) {
- g_return_if_fail(pref);
- * gf_preference_get_type:
- * @pref : The #GfPreference instance.
- * Gets the type of @pref.
- * Return Value: The type of @pref.
-gf_preference_get_type(const GfPreference *pref) {
- g_return_val_if_fail(pref, GF_PREFERENCE_TYPE_UNKNOWN);
- * gf_preference_set_string:
- * @pref : The #GfPreference instance.
- * @value : The new string value.
- * Sets the string value for @pref.
-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.
-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.
-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.
-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.
-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.
-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>
- * @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.
- 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 >*/
+#include <gflib/gf_preference.h> struct _GfPreferenceEngine {
@@ -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);
#endif /* GF_PREFERENCE_ENGINE_H */