diff options
Diffstat (limited to 'calendar/gui/alarm-notify/config-data.c')
-rw-r--r-- | calendar/gui/alarm-notify/config-data.c | 78 |
1 files changed, 65 insertions, 13 deletions
diff --git a/calendar/gui/alarm-notify/config-data.c b/calendar/gui/alarm-notify/config-data.c index 8737d0549f..23ec04826a 100644 --- a/calendar/gui/alarm-notify/config-data.c +++ b/calendar/gui/alarm-notify/config-data.c @@ -22,6 +22,7 @@ #include <config.h> #endif +#include <libedataserver/e-source-list.h> #include "config-data.h" #include "save.h" @@ -29,7 +30,8 @@ /* Whether we have initied ourselves by reading the data from the configuration engine */ static gboolean inited = FALSE; -static EConfigListener *config; +static GConfClient *conf_client = NULL; +static ESourceList *calendar_source_list = NULL, *tasks_source_list = NULL; @@ -49,8 +51,19 @@ locale_supports_12_hour_format (void) static void do_cleanup (void) { - g_object_unref (config); - config = NULL; + if (calendar_source_list) { + g_object_unref (calendar_source_list); + calendar_source_list = NULL; + } + + if (tasks_source_list) { + g_object_unref (tasks_source_list); + tasks_source_list = NULL; + } + + g_object_unref (conf_client); + conf_client = NULL; + inited = FALSE; } @@ -63,20 +76,27 @@ ensure_inited (void) inited = TRUE; - config = e_config_listener_new (); - if (!E_IS_CONFIG_LISTENER (config)) { + conf_client = gconf_client_get_default (); + if (!GCONF_IS_CLIENT (conf_client)) { inited = FALSE; return; } g_atexit ((GVoidFunc) do_cleanup); + + /* load the sources for calendars and tasks */ + calendar_source_list = e_source_list_new_for_gconf (conf_client, + "/apps/evolution/calendar/sources"); + tasks_source_list = e_source_list_new_for_gconf (conf_client, + "/apps/evolution/tasks/sources"); + } -EConfigListener * +GConfClient * config_data_get_listener (void) { ensure_inited (); - return config; + return conf_client; } icaltimezone * @@ -87,9 +107,9 @@ config_data_get_timezone (void) ensure_inited (); - location = e_config_listener_get_string_with_default (config, - "/apps/evolution/calendar/display/timezone", - "UTC", NULL); + location = gconf_client_get_string (conf_client, + "/apps/evolution/calendar/display/timezone", + NULL); if (location && location[0]) { local_timezone = icaltimezone_get_builtin_timezone (location); } else { @@ -107,10 +127,42 @@ config_data_get_24_hour_format (void) ensure_inited (); if (locale_supports_12_hour_format ()) { - return e_config_listener_get_boolean_with_default ( - config, - "/apps/evolution/calendar/display/use_24hour_format", FALSE, NULL); + return gconf_client_get_bool (conf_client, + "/apps/evolution/calendar/display/use_24hour_format", + NULL); } return TRUE; } + +GPtrArray * +config_data_get_calendars_to_load (void) +{ + GPtrArray *cals; + GSList *groups, *gl, *sources, *sl; + + ensure_inited (); + + /* create the array to be returned */ + cals = g_ptr_array_new (); + + /* process calendar sources */ + groups = e_source_list_peek_groups (calendar_source_list); + for (gl = groups; gl != NULL; gl = gl->next) { + sources = e_source_group_peek_sources (E_SOURCE_GROUP (gl->data)); + for (sl = sources; sl != NULL; sl = sl->next) { + g_ptr_array_add (cals, sl->data); + } + } + + /* process tasks sources */ + groups = e_source_list_peek_groups (tasks_source_list); + for (gl = groups; gl != NULL; gl = gl->next) { + sources = e_source_group_peek_sources (E_SOURCE_GROUP (gl->data)); + for (sl = sources; sl != NULL; sl = sl->next) { + g_ptr_array_add (cals, sl->data); + } + } + + return cals; +} |