diff options
author | Milan Crha <mcrha@redhat.com> | 2009-04-30 22:56:58 +0800 |
---|---|---|
committer | Milan Crha <mcrha@redhat.com> | 2009-04-30 22:56:58 +0800 |
commit | 8f2b4f9c6554698af19a39223acc33f965e2dfca (patch) | |
tree | 4a66ec23024087aa1b7dc54a63ccb115f0e91509 /calendar/conduits/common | |
parent | a4bc46297551d65f2fbffb853b773f857e14edf2 (diff) | |
download | gsoc2013-evolution-8f2b4f9c6554698af19a39223acc33f965e2dfca.tar.gz gsoc2013-evolution-8f2b4f9c6554698af19a39223acc33f965e2dfca.tar.zst gsoc2013-evolution-8f2b4f9c6554698af19a39223acc33f965e2dfca.zip |
Bug #570730 - Get rid of gnome-config in Evolution
Diffstat (limited to 'calendar/conduits/common')
-rw-r--r-- | calendar/conduits/common/libecalendar-common-conduit.c | 166 | ||||
-rw-r--r-- | calendar/conduits/common/libecalendar-common-conduit.h | 6 |
2 files changed, 172 insertions, 0 deletions
diff --git a/calendar/conduits/common/libecalendar-common-conduit.c b/calendar/conduits/common/libecalendar-common-conduit.c index 1b7013bb0a..fbbe0278b1 100644 --- a/calendar/conduits/common/libecalendar-common-conduit.c +++ b/calendar/conduits/common/libecalendar-common-conduit.c @@ -29,6 +29,7 @@ #include <e-pilot-util.h> #include <pi-appinfo.h> #include <glib.h> +#include <gconf/gconf-client.h> #include "libecalendar-common-conduit.h" @@ -204,3 +205,168 @@ void e_pilot_remote_category_to_local(int pilotCategory, ECalComponent *comp, st e_cal_component_free_categories_list(c_list); } } + +static char * +build_setup_path (const char *path, const char *key) +{ + return g_strconcat ("/apps/evolution/conduit", "/", path, "/", key, NULL); +} + +gboolean +e_pilot_setup_get_bool (const char *path, const char *key, gboolean def) +{ + gboolean res = def; + char *full_path; + GConfValue *value; + GConfClient *gconf; + + g_return_val_if_fail (path != NULL, res); + g_return_val_if_fail (key != NULL, res); + + gconf = gconf_client_get_default (); + full_path = build_setup_path (path, key); + + value = gconf_client_get (gconf, full_path, NULL); + if (value) { + if (value->type == GCONF_VALUE_BOOL) + res = gconf_value_get_bool (value); + + gconf_value_free (value); + } + + g_free (full_path); + g_object_unref (gconf); + + return res; +} + +void +e_pilot_setup_set_bool (const char *path, const char *key, gboolean value) +{ + GError *error = NULL; + char *full_path; + GConfClient *gconf; + + g_return_if_fail (path != NULL); + g_return_if_fail (key != NULL); + + gconf = gconf_client_get_default (); + full_path = build_setup_path (path, key); + + gconf_client_set_bool (gconf, full_path, value, &error); + + g_free (full_path); + g_object_unref (gconf); + + if (error) { + g_message ("%s: Failed to write: %s", G_STRFUNC, error->message); + g_error_free (error); + } +} + +int +e_pilot_setup_get_int (const char *path, const char *key, int def) +{ + int res = def; + char *full_path; + GConfValue *value; + GConfClient *gconf; + + g_return_val_if_fail (path != NULL, res); + g_return_val_if_fail (key != NULL, res); + + gconf = gconf_client_get_default (); + full_path = build_setup_path (path, key); + + value = gconf_client_get (gconf, full_path, NULL); + if (value) { + if (value->type == GCONF_VALUE_INT) + res = gconf_value_get_int (value); + + gconf_value_free (value); + } + + g_free (full_path); + g_object_unref (gconf); + + return res; +} + +void +e_pilot_setup_set_int (const char *path, const char *key, int value) +{ + GError *error = NULL; + char *full_path; + GConfClient *gconf; + + g_return_if_fail (path != NULL); + g_return_if_fail (key != NULL); + + gconf = gconf_client_get_default (); + full_path = build_setup_path (path, key); + + gconf_client_set_int (gconf, full_path, value, &error); + + g_free (full_path); + g_object_unref (gconf); + + if (error) { + g_message ("%s: Failed to write: %s", G_STRFUNC, error->message); + g_error_free (error); + } +} + +char * +e_pilot_setup_get_string (const char *path, const char *key, const char *def) +{ + char *res = g_strdup (def); + char *full_path; + GConfValue *value; + GConfClient *gconf; + + g_return_val_if_fail (path != NULL, res); + g_return_val_if_fail (key != NULL, res); + + gconf = gconf_client_get_default (); + full_path = build_setup_path (path, key); + + value = gconf_client_get (gconf, full_path, NULL); + if (value) { + if (value->type == GCONF_VALUE_STRING) { + g_free (res); + res = g_strdup (gconf_value_get_string (value)); + } + + gconf_value_free (value); + } + + g_free (full_path); + g_object_unref (gconf); + + return res; +} + +void +e_pilot_setup_set_string (const char *path, const char *key, const char *value) +{ + GError *error = NULL; + char *full_path; + GConfClient *gconf; + + g_return_if_fail (path != NULL); + g_return_if_fail (key != NULL); + g_return_if_fail (value != NULL); + + gconf = gconf_client_get_default (); + full_path = build_setup_path (path, key); + + gconf_client_set_string (gconf, full_path, value, &error); + + g_free (full_path); + g_object_unref (gconf); + + if (error) { + g_message ("%s: Failed to write: %s", G_STRFUNC, error->message); + g_error_free (error); + } +} diff --git a/calendar/conduits/common/libecalendar-common-conduit.h b/calendar/conduits/common/libecalendar-common-conduit.h index e168e001eb..0641ec3e88 100644 --- a/calendar/conduits/common/libecalendar-common-conduit.h +++ b/calendar/conduits/common/libecalendar-common-conduit.h @@ -29,3 +29,9 @@ int e_pilot_add_category_if_possible(char *cat_to_add, struct CategoryAppInfo *c void e_pilot_local_category_to_remote(int * pilotCategory, ECalComponent *comp, struct CategoryAppInfo *category); void e_pilot_remote_category_to_local(int pilotCategory, ECalComponent *comp, struct CategoryAppInfo *category); +gboolean e_pilot_setup_get_bool (const char *path, const char *key, gboolean def); +void e_pilot_setup_set_bool (const char *path, const char *key, gboolean value); +int e_pilot_setup_get_int (const char *path, const char *key, int def); +void e_pilot_setup_set_int (const char *path, const char *key, int value); +char *e_pilot_setup_get_string (const char *path, const char *key, const char *def); +void e_pilot_setup_set_string (const char *path, const char *key, const char *value); |