diff options
Diffstat (limited to 'calendar/gui')
-rw-r--r-- | calendar/gui/alarm-notify/alarm-notify.c | 9 | ||||
-rw-r--r-- | calendar/gui/alarm-notify/config-data.c | 112 | ||||
-rw-r--r-- | calendar/gui/calendar-config.c | 62 | ||||
-rw-r--r-- | calendar/gui/dialogs/comp-editor.c | 34 |
4 files changed, 95 insertions, 122 deletions
diff --git a/calendar/gui/alarm-notify/alarm-notify.c b/calendar/gui/alarm-notify/alarm-notify.c index e612b0c56c..3b5402b4a6 100644 --- a/calendar/gui/alarm-notify/alarm-notify.c +++ b/calendar/gui/alarm-notify/alarm-notify.c @@ -37,9 +37,7 @@ #include "alarm-queue.h" #include "config-data.h" -#define ALARM_NOTIFY_GET_PRIVATE(obj) \ - (G_TYPE_INSTANCE_GET_PRIVATE \ - ((obj), TYPE_ALARM_NOTIFY, AlarmNotifyPrivate)) +#define APPLICATION_ID "org.gnome.EvolutionAlarmNotify" #define APPLICATION_ID "org.gnome.EvolutionAlarmNotify" @@ -222,7 +220,7 @@ alarm_notify_finalize (GObject *object) AlarmNotifyPrivate *priv; gint ii; - priv = ALARM_NOTIFY_GET_PRIVATE (object); + priv = ALARM_NOTIFY (object)->priv; for (ii = 0; ii < E_CAL_CLIENT_SOURCE_TYPE_LAST; ii++) { g_hash_table_foreach ( @@ -311,7 +309,8 @@ alarm_notify_init (AlarmNotify *an) { gint ii; - an->priv = ALARM_NOTIFY_GET_PRIVATE (an); + an->priv = G_TYPE_INSTANCE_GET_PRIVATE ( + an, TYPE_ALARM_NOTIFY, AlarmNotifyPrivate); an->priv->mutex = g_mutex_new (); an->priv->selected_calendars = config_data_get_calendars ( "/apps/evolution/calendar/sources"); diff --git a/calendar/gui/alarm-notify/config-data.c b/calendar/gui/alarm-notify/config-data.c index 567ca69c09..4f30a4e4f3 100644 --- a/calendar/gui/alarm-notify/config-data.c +++ b/calendar/gui/alarm-notify/config-data.c @@ -30,14 +30,11 @@ #include <libedataserver/e-source-list.h> #include "config-data.h" -#define KEY_LAST_NOTIFICATION_TIME \ - "/apps/evolution/calendar/notify/last_notification_time" -#define KEY_PROGRAMS "/apps/evolution/calendar/notify/programs" - /* Whether we have initied ourselves by reading * the data from the configuration engine. */ static gboolean inited = FALSE; static GConfClient *conf_client = NULL; +static GSetting *calendar_settings = NULL; static ESourceList *calendar_source_list = NULL, *tasks_source_list = NULL; /* Copied from ../calendar-config.c; returns whether the locale has 'am' and @@ -69,6 +66,9 @@ do_cleanup (void) g_object_unref (conf_client); conf_client = NULL; + g_object_unref (calendar_settings); + calendar_settings = FALSE; + inited = FALSE; } @@ -87,6 +87,8 @@ ensure_inited (void) return; } + calendar_settings = g_settings_new ("org.gnome.evolution.calendar"); + g_atexit ((GVoidFunc) do_cleanup); /* load the sources for calendars and tasks */ @@ -104,8 +106,10 @@ config_data_get_calendars (const gchar *key) gboolean state; GSList *gconf_list; - if (!inited) + if (!inited) { conf_client = gconf_client_get_default (); + calendar_settings = g_settings_new ("org.gnome.evolution.calendar"); + } gconf_list = gconf_client_get_list (conf_client, key, @@ -119,15 +123,11 @@ config_data_get_calendars (const gchar *key) return cal_sources; } - state = gconf_client_get_bool (conf_client, - "/apps/evolution/calendar/notify/notify_with_tray", - NULL); + state = g_settings_get_boolean (calendar_settings, "notify-with-tray", NULL); if (!state) /* Should be old client */ { GSList *source; - gconf_client_set_bool (conf_client, - "/apps/evolution/calendar/notify/notify_with_tray", - TRUE, - NULL); + + g_settings_set_boolean (calendar_settings, "notify-with-tray", TRUE, NULL); source = gconf_client_get_list (conf_client, "/apps/evolution/calendar/sources", GCONF_VALUE_STRING, @@ -200,17 +200,14 @@ icaltimezone * config_data_get_timezone (void) { gchar *location; - const gchar *key; icaltimezone *local_timezone; ensure_inited (); - key = "/apps/evolution/calendar/display/use_system_timezone"; - if (gconf_client_get_bool (conf_client, key, NULL)) + if (g_settings_get_boolean (calendar_settings, "use-system-timezone")) location = e_cal_util_get_system_timezone_location (); else { - key = "/apps/evolution/calendar/display/timezone"; - location = gconf_client_get_string (conf_client, key, NULL); + location = g_settings_get_string (calendar_settings, "timezone"); } if (location && location[0]) @@ -229,10 +226,7 @@ config_data_get_24_hour_format (void) ensure_inited (); if (locale_supports_12_hour_format ()) { - const gchar *key; - - key = "/apps/evolution/calendar/display/use_24hour_format"; - return gconf_client_get_bool (conf_client, key, NULL); + return g_settings_get_boolean (calendar_client, "use-24hour-format"); } return TRUE; @@ -243,9 +237,7 @@ config_data_get_notify_with_tray (void) { ensure_inited (); - return gconf_client_get_bool (conf_client, - "/apps/evolution/calendar/notify/notify_with_tray", - NULL); + return g_settings_get_boolean (calendar_client, "notify-with-tray"); } /** @@ -260,7 +252,6 @@ void config_data_set_last_notification_time (ECalClient *cal, time_t t) { - GConfClient *client; time_t current_t, now = time (NULL); g_return_if_fail (t != -1); @@ -291,14 +282,11 @@ config_data_set_last_notification_time (ECalClient *cal, } } - if (!(client = config_data_get_conf_client ())) - return; - /* we only store the new notification time if it is bigger * than the already stored one */ - current_t = gconf_client_get_int (client, KEY_LAST_NOTIFICATION_TIME, NULL); + current_t = g_settings_get_int (calendar_settings, "last-notification-time"); if (t > current_t || current_t > now) - gconf_client_set_int (client, KEY_LAST_NOTIFICATION_TIME, t, NULL); + g_settings_set_int (calendar_settings "last-notification-time", t); } /** @@ -311,8 +299,7 @@ config_data_set_last_notification_time (ECalClient *cal, time_t config_data_get_last_notification_time (ECalClient *cal) { - GConfValue *value; - GConfClient *client; + time_t value, now; if (cal) { ESource *source = e_client_get_source (E_CLIENT (cal)); @@ -335,24 +322,12 @@ config_data_get_last_notification_time (ECalClient *cal) } } - if (!(client = config_data_get_conf_client ())) - return -1; + value = g_settings_get_int (calendar_settings, "last-notification-time"); + now = time (NULL); + if (val > now) + val = now; - value = gconf_client_get_without_default ( - client, KEY_LAST_NOTIFICATION_TIME, NULL); - if (value) { - time_t val, now; - - val = (time_t) gconf_value_get_int (value); - now = time (NULL); - - if (val > now) - val = now; - - return val; - } - - return -1; + return val; } /** @@ -364,17 +339,19 @@ config_data_get_last_notification_time (ECalClient *cal) void config_data_save_blessed_program (const gchar *program) { - GConfClient *client; - GSList *l; + gchar **list; + gint i; + GArray *array = g_array_new (TRUE, FALSE, sizeof (gchar *)); - if (!(client = config_data_get_conf_client ())) - return; + list = g_settings_get_strv (calendar_settings, "notify-programs"); + for (i = 0; i < g_strv_length (list); i++) + g_array_append_val (array, list[i]); - l = gconf_client_get_list (client, KEY_PROGRAMS, GCONF_VALUE_STRING, NULL); - l = g_slist_append (l, g_strdup (program)); - gconf_client_set_list (client, KEY_PROGRAMS, GCONF_VALUE_STRING, l, NULL); - g_slist_foreach (l, (GFunc) g_free, NULL); - g_slist_free (l); + g_array_append_val (array, program); + g_settings_set_strv (calendar_settings, "notify-programs", (const gchar *const *) array->data); + + g_strfreev (list); + g_array_free (array, TRUE); } /** @@ -388,23 +365,22 @@ config_data_save_blessed_program (const gchar *program) gboolean config_data_is_blessed_program (const gchar *program) { - GConfClient *client; - GSList *l, *n; + gchar **list; + gint i = 0; gboolean found = FALSE; - if (!(client = config_data_get_conf_client ())) + list = g_settings_get_strv (calendar_settings, "notify-programs"); + if (!list) return FALSE; - l = gconf_client_get_list (client, KEY_PROGRAMS, GCONF_VALUE_STRING, NULL); - while (l) { - n = l->next; + while (list[i] != NULL) { if (!found) - found = strcmp ((gchar *) l->data, program) == 0; - g_free (l->data); - g_slist_free_1 (l); - l = n; + found = strcmp ((gchar *) list[i], program) == 0; + i++; } + g_strfreev (list); + return found; } diff --git a/calendar/gui/calendar-config.c b/calendar/gui/calendar-config.c index 6d97cdf8cf..9623dcf058 100644 --- a/calendar/gui/calendar-config.c +++ b/calendar/gui/calendar-config.c @@ -31,6 +31,7 @@ #include <time.h> #include <string.h> +#include <gio/gio.h> #include <e-util/e-util.h> #include <libecal/e-cal-time-util.h> #include <libedataserver/e-data-server-util.h> @@ -40,7 +41,7 @@ #include "calendar-config-keys.h" #include "calendar-config.h" -static GConfClient *config = NULL; +static GSettings *config = NULL; static void do_cleanup (void) @@ -55,10 +56,8 @@ calendar_config_init (void) if (config) return; - config = gconf_client_get_default (); + config = g_settings_new ("org.gnome.evolution.calendar"); g_atexit ((GVoidFunc) do_cleanup); - - gconf_client_add_dir (config, CALENDAR_CONFIG_PREFIX, GCONF_CLIENT_PRELOAD_RECURSIVE, NULL); } void @@ -92,7 +91,7 @@ calendar_config_get_timezone_stored (void) { calendar_config_init (); - return gconf_client_get_string (config, CALENDAR_CONFIG_TIMEZONE, NULL); + return g_settings_get_string (config, "timezone"); } static gchar * @@ -142,7 +141,7 @@ calendar_config_get_24_hour_format (void) * default. If the locale doesn't have 'am' and 'pm' strings we have * to use 24-hour format, or strftime ()/strptime () won't work. */ if (calendar_config_locale_supports_12_hour_format ()) - return gconf_client_get_bool (config, CALENDAR_CONFIG_24HOUR, NULL); + return g_settings_get_boolean (config, "use-24hour-format"); return TRUE; } @@ -153,7 +152,7 @@ calendar_config_get_month_scroll_by_week (void) { calendar_config_init (); - return gconf_client_get_bool (config, CALENDAR_CONFIG_MONTH_SCROLL_BY_WEEK, NULL); + return g_settings_get_boolean (config, "month-scroll-by-week"); } guint @@ -177,7 +176,7 @@ calendar_config_get_working_days (void) { calendar_config_init (); - return gconf_client_get_int (config, CALENDAR_CONFIG_WORKING_DAYS, NULL); + return g_settings_get_int (config, "working-days"); } /* Settings to hide completed tasks. */ @@ -186,7 +185,7 @@ calendar_config_get_hide_completed_tasks (void) { calendar_config_init (); - return gconf_client_get_bool (config, CALENDAR_CONFIG_TASKS_HIDE_COMPLETED, NULL); + return g_settings_get_boolean (config, "hide-completed-tasks"); } static EDurationType @@ -197,7 +196,7 @@ calendar_config_get_hide_completed_tasks_units (void) calendar_config_init (); - units = gconf_client_get_string (config, CALENDAR_CONFIG_TASKS_HIDE_COMPLETED_UNITS, NULL); + units = g_settings_get_string (config, "hide-completed-tasks-units"); if (units && !strcmp (units, "minutes")) cu = E_DURATION_MINUTES; @@ -229,7 +228,7 @@ calendar_config_get_hide_completed_tasks_sexp (gboolean get_completed) gint value; units = calendar_config_get_hide_completed_tasks_units (); - value = gconf_client_get_int (config, CALENDAR_CONFIG_TASKS_HIDE_COMPLETED_VALUE, NULL); + value = g_settings_get_int (config, "hide-completed-tasks-value"); if (value == 0) { /* If the value is 0, we want to hide completed tasks @@ -284,7 +283,7 @@ calendar_config_set_dir_path (const gchar *path) { calendar_config_init (); - gconf_client_set_string (config, CALENDAR_CONFIG_SAVE_DIR, path, NULL); + g_settings_set_string (config, "audio-dir", path); } gchar * @@ -294,7 +293,7 @@ calendar_config_get_dir_path (void) calendar_config_init (); - path = gconf_client_get_string (config, CALENDAR_CONFIG_SAVE_DIR, NULL); + path = g_settings_get_string (config, "audio-dir"); return path; } @@ -304,11 +303,19 @@ calendar_config_get_dir_path (void) GSList * calendar_config_get_day_second_zones (void) { - GSList *res; + GSList *res = NULL; + gchar **strv; + gint i; calendar_config_init (); - res = gconf_client_get_list (config, CALENDAR_CONFIG_DAY_SECOND_ZONES_LIST, GCONF_VALUE_STRING, NULL); + strv = g_settings_get_strv (config, "day-second-zones"); + for (i = 0; i < g_strv_length (strv); i++) { + if (strv[i] != NULL) + res = g_slist_append (res, g_strdup (strv[i])); + } + + g_strfreev (strv); return res; } @@ -331,16 +338,12 @@ calendar_config_set_day_second_zone (const gchar *location) if (location && *location) { GSList *lst, *l; - GError *error = NULL; gint max_zones; + GPtrArray *array; + gint i; /* configurable max number of timezones to remember */ - max_zones = gconf_client_get_int (config, CALENDAR_CONFIG_DAY_SECOND_ZONES_MAX, &error); - - if (error) { - g_error_free (error); - max_zones = -1; - } + max_zones = g_settings_get_int (config, "day-second-zones-max"); if (max_zones <= 0) max_zones = 5; @@ -364,18 +367,17 @@ calendar_config_set_day_second_zone (const gchar *location) lst = g_slist_prepend (lst, g_strdup (location)); } - while (g_slist_length (lst) > max_zones) { - l = g_slist_last (lst); - g_free (l->data); - lst = g_slist_delete_link (lst, l); - } + array = g_ptr_array_new (); + for (i = 0, l = lst; i < max_zones && l != NULL; i++, l = l->next) + g_ptr_array_add (array, l->data); - gconf_client_set_list (config, CALENDAR_CONFIG_DAY_SECOND_ZONES_LIST, GCONF_VALUE_STRING, lst, NULL); + g_settings_set_strv (config, "day-second-zones", array->pdata); calendar_config_free_day_second_zones (lst); + g_ptr_array_free (array, FALSE); } - gconf_client_set_string (config, CALENDAR_CONFIG_DAY_SECOND_ZONE, location ? location : "", NULL); + g_settings_set_string (config, "day-second-zone", location ? location : ""); } /* location of the second time zone user has selected. Free with g_free. */ @@ -384,7 +386,7 @@ calendar_config_get_day_second_zone (void) { calendar_config_init (); - return gconf_client_get_string (config, CALENDAR_CONFIG_DAY_SECOND_ZONE, NULL); + return g_settings_get_string (config, "day-second-zone"); } void diff --git a/calendar/gui/dialogs/comp-editor.c b/calendar/gui/dialogs/comp-editor.c index 9c463c66dc..033b1323f9 100644 --- a/calendar/gui/dialogs/comp-editor.c +++ b/calendar/gui/dialogs/comp-editor.c @@ -34,13 +34,14 @@ #include <unistd.h> #include <glib/gi18n-lib.h> #include <glib/gstdio.h> +#include <gio/gio.h> #include <gdk/gdkkeysyms.h> #include <libebackend/e-extensible.h> #include <e-util/e-util.h> #include <e-util/e-alert-sink.h> #include <e-util/e-dialog-utils.h> +#include <e-util/e-extensible.h> #include <e-util/e-util-private.h> -#include <e-util/gconf-bridge.h> #include <shell/e-shell.h> #include <libedataserver/e-data-server-util.h> @@ -71,6 +72,8 @@ struct _CompEditorPrivate { gpointer shell; /* weak pointer */ + GSettings *calendar_settings; + /* EFocusTracker keeps selection actions up-to-date. */ EFocusTracker *focus_tracker; @@ -1637,6 +1640,7 @@ comp_editor_finalize (GObject *object) priv = COMP_EDITOR (object)->priv; + g_object_unref (priv->calendar_settings); g_free (priv->summary); /* Chain up to parent's finalize() method. */ @@ -1653,39 +1657,29 @@ comp_editor_constructed (GObject *object) } static void -comp_editor_bind_gconf (CompEditor *editor) +comp_editor_bind_settings (CompEditor *editor) { - GConfBridge *bridge; GtkAction *action; - const gchar *key; g_return_if_fail (editor != NULL); - bridge = gconf_bridge_get (); - - key = "/apps/evolution/calendar/display/show_categories"; action = comp_editor_get_action (editor, "view-categories"); - gconf_bridge_bind_property (bridge, key, G_OBJECT (action), "active"); + g_settings_bind (priv->calendar_settings, "editor-show-categories", G_OBJECT (action), "active", G_SETTINGS_BIND_DEFAULT); - key = "/apps/evolution/calendar/display/show_role"; action = comp_editor_get_action (editor, "view-role"); - gconf_bridge_bind_property (bridge, key, G_OBJECT (action), "active"); + g_settings_bind (priv->calendar_settings, "editor-show-role", G_OBJECT (action), "active", G_SETTINGS_BIND_DEFAULT); - key = "/apps/evolution/calendar/display/show_rsvp"; action = comp_editor_get_action (editor, "view-rsvp"); - gconf_bridge_bind_property (bridge, key, G_OBJECT (action), "active"); + g_settings_bind (priv->calendar_settings, "editor-show-rsvp", G_OBJECT (action), "active", G_SETTINGS_BIND_DEFAULT); - key = "/apps/evolution/calendar/display/show_status"; action = comp_editor_get_action (editor, "view-status"); - gconf_bridge_bind_property (bridge, key, G_OBJECT (action), "active"); + g_settings_bind (priv->calendar_settings, "editor-show-status", G_OBJECT (action), "active", G_SETTINGS_BIND_DEFAULT); - key = "/apps/evolution/calendar/display/show_timezone"; action = comp_editor_get_action (editor, "view-time-zone"); - gconf_bridge_bind_property (bridge, key, G_OBJECT (action), "active"); + g_settings_bind (priv->calendar_settings, "editor-show-timezone", G_OBJECT (action), "active", G_SETTINGS_BIND_DEFAULT); - key = "/apps/evolution/calendar/display/show_type"; action = comp_editor_get_action (editor, "view-type"); - gconf_bridge_bind_property (bridge, key, G_OBJECT (action), "active"); + g_settings_bind (priv->calendar_settings, "editor-show-type", G_OBJECT (action), "active", G_SETTINGS_BIND_DEFAULT); } static gboolean @@ -1981,6 +1975,8 @@ comp_editor_init (CompEditor *editor) active_editors = g_list_prepend (active_editors, editor); + priv->calendar_settings = g_settings_new ("org.gnome.evolution.calendar"); + /* Each editor window gets its own window group. */ window = GTK_WINDOW (editor); priv->window_group = gtk_window_group_new (); @@ -2193,7 +2189,7 @@ comp_editor_init (CompEditor *editor) store, "row-inserted", G_CALLBACK (attachment_store_changed_cb), editor); - comp_editor_bind_gconf (editor); + comp_editor_bind_settings (editor); e_shell_watch_window (shell, GTK_WINDOW (editor)); e_shell_adapt_window_size (shell, GTK_WINDOW (editor)); |