aboutsummaryrefslogtreecommitdiffstats
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
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
-rw-r--r--calendar/gui/alarm-notify/config-data.c111
-rw-r--r--data/evolution.convert6
-rw-r--r--data/org.gnome.evolution.calendar.gschema.xml.in30
3 files changed, 80 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;
}
diff --git a/data/evolution.convert b/data/evolution.convert
index ad6c946579..45954be817 100644
--- a/data/evolution.convert
+++ b/data/evolution.convert
@@ -38,6 +38,12 @@ editor-show-rsvp = /apps/evolution/calendar/display/show_rsvp
editor-show-status = /apps/evolution/calendar/display/show_status
editor-show-timezone = /apps/evolution/calendar/display/show_timezone
editor-show-type = /apps/evolution/calendar/display/show_type
+last-notification-time = /apps/evolution/calendar/notify/last_notification_time
+notify-programs = /apps/evolution/calendar/notify/programs
+notify-with-tray = /apps/evolution/calendar/notify/notify_with_tray
+timezone = /apps/evolution/calendar/display/timezone
+use-24hour-format = /apps/evolution/calendar/display/use_24hour_format
+use-system-timezone = /apps/evolution/calendar/display/use_system_timezone
[org.gnome.evolution.mail]
check-if-default-mailer = /apps/evolution/mail/prompts/checkdefault
diff --git a/data/org.gnome.evolution.calendar.gschema.xml.in b/data/org.gnome.evolution.calendar.gschema.xml.in
index c10a1000cf..9c0050f8f2 100644
--- a/data/org.gnome.evolution.calendar.gschema.xml.in
+++ b/data/org.gnome.evolution.calendar.gschema.xml.in
@@ -31,4 +31,34 @@
<_summary>Show type field in the event/task/meeting editor</_summary>
<_description>Whether to show type field in the event/task/meeting editor</_description>
</key>
+ <key name="last-notification-time" type="i">
+ <default>1</default>
+ <_summary>Last reminder time</_summary>
+ <_description>Time the last reminder ran, in time_t</_description>
+ </key>
+ <key name="notify-programs" type="as">
+ <default>[]</default>
+ <_summary>Reminder programs</_summary>
+ <_description>Programs that are allowed to be run by reminders</_description>
+ </key>
+ <key name="notify-with-tray" type="b">
+ <default>false</default>
+ <_summary>Show display reminders in notification tray</_summary>
+ <_description>Whether or not to use the notification tray for display reminders</_description>
+ </key>
+ <key name="timezone" type="s">
+ <default>'UTC'</default>
+ <_summary>Timezone</_summary>
+ <_description>The default timezone to use for dates and times in the calendar, as an untranslated Olsen timezone database location like "America/New York"</_description>
+ </key>
+ <key name="use-24hour-format" type="b">
+ <default>false</default>
+ <_summary>Twenty four hour time format</_summary>
+ <_description>Whether to show times in twenty four hour format instead of using am/pm</_description>
+ </key>
+ <key name="use-system-timezone" type="b">
+ <default>true</default>
+ <_summary>Use system timezone</_summary>
+ <_description>Use the system timezone instead of the timezone selected in Evolution</_description>
+ </key>
</schemalist>