aboutsummaryrefslogtreecommitdiffstats
path: root/calendar/gui
diff options
context:
space:
mode:
authorRodrigo Moya <rodrigo@gnome-db.org>2011-09-15 17:24:25 +0800
committerRodrigo Moya <rodrigo@gnome-db.org>2011-09-15 17:26:58 +0800
commit035eda3f14857100bbf53b70173442ed5b929b19 (patch)
tree909f35c43f9d94edd9881764404f2e9dd43fc96b /calendar/gui
parent0886cc544f0616f90383d4d51709a45da42dea37 (diff)
downloadgsoc2013-evolution-035eda3f14857100bbf53b70173442ed5b929b19.tar
gsoc2013-evolution-035eda3f14857100bbf53b70173442ed5b929b19.tar.gz
gsoc2013-evolution-035eda3f14857100bbf53b70173442ed5b929b19.tar.bz2
gsoc2013-evolution-035eda3f14857100bbf53b70173442ed5b929b19.tar.lz
gsoc2013-evolution-035eda3f14857100bbf53b70173442ed5b929b19.tar.xz
gsoc2013-evolution-035eda3f14857100bbf53b70173442ed5b929b19.tar.zst
gsoc2013-evolution-035eda3f14857100bbf53b70173442ed5b929b19.zip
Port alarm-notify configuration to GSettings
Diffstat (limited to 'calendar/gui')
-rw-r--r--calendar/gui/alarm-notify/config-data.c111
1 files changed, 44 insertions, 67 deletions
diff --git a/calendar/gui/alarm-notify/config-data.c b/calendar/gui/alarm-notify/config-data.c
index d056131280..aa8755973a 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;
@@ -71,6 +68,9 @@ do_cleanup (void)
g_object_unref (conf_client);
conf_client = NULL;
+ g_object_unref (calendar_settings);
+ calendar_settings = FALSE;
+
inited = FALSE;
}
@@ -89,6 +89,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 */
@@ -106,8 +108,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,
@@ -121,15 +125,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,
@@ -202,17 +202,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])
@@ -231,10 +228,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;
@@ -245,9 +239,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");
}
/**
@@ -262,7 +254,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);
@@ -284,14 +275,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);
}
/**
@@ -304,8 +292,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));
@@ -328,24 +315,13 @@ config_data_get_last_notification_time (ECalClient *cal)
}
}
- if (!(client = config_data_get_conf_client ()))
- return -1;
-
- 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;
+ value = g_settings_get_int (calendar_settings, "last-notification-time");
+ now = time (NULL);
- return val;
- }
+ if (val > now)
+ val = now;
- return -1;
+ return val;
}
/**
@@ -357,17 +333,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);
}
/**
@@ -381,23 +359,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;
}