[evolution/wip/gsettings] Port most settings in calendar-config.c to GSettings



commit f304d1898d61e431738154c7f09cab901936e647
Author: Rodrigo Moya <rodrigo gnome-db org>
Date:   Thu Sep 15 13:47:06 2011 +0200

    Port most settings in calendar-config.c to GSettings

 calendar/gui/calendar-config.c                   |   49 +++++++++++-----------
 data/evolution.convert                           |    9 ++++
 data/org.gnome.evolution.calendar.gschema.xml.in |   45 ++++++++++++++++++++
 3 files changed, 79 insertions(+), 24 deletions(-)
---
diff --git a/calendar/gui/calendar-config.c b/calendar/gui/calendar-config.c
index 6d97cdf..1ae04af 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,10 @@ calendar_config_set_day_second_zone (const gchar *location)
 
 	if (location && *location) {
 		GSList *lst, *l;
-		GError *error = NULL;
 		gint max_zones;
 
 		/* 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;
@@ -375,7 +376,7 @@ calendar_config_set_day_second_zone (const gchar *location)
 		calendar_config_free_day_second_zones (lst);
 	}
 
-	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 +385,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/data/evolution.convert b/data/evolution.convert
index 45954be..874453a 100644
--- a/data/evolution.convert
+++ b/data/evolution.convert
@@ -32,18 +32,27 @@ vpane-position = /apps/evolution/addressbook/display/vpane_position
 show-preview = /apps/evolution/addressbook/display/show_preview
 
 [org.gnome.evolution.calendar]
+audi-dir = /apps/evolution/calendar/audio_dir
+day-second-zone = /apps/evolution/calendar/display/day_second_zone
+day-second-zones = /apps/evolution/calendar/display/day_second_zones
+day-second-zones-max = /apps/evolution/calendar/display/day_second_zones_max
 editor-show-categories = /apps/evolution/calendar/display/show_categories
 editor-show-role = /apps/evolution/calendar/display/show_role
 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
+hide-completed-tasks = /apps/evolution/calendar/tasks/hide_completed
+hide-completed-tasks-units = /apps/evolution/calendar/tasks/hide_completed_units
+hide-completed-tasks-value = /apps/evolution/calendar/tasks/hide_completed_value
 last-notification-time = /apps/evolution/calendar/notify/last_notification_time
+month-scroll-by-week = /apps/evolution/calendar/display/month_scroll_by_week
 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
+working-days = /apps/evolution/calendar/display/working_days
 
 [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 9c0050f..70a13b9 100644
--- a/data/org.gnome.evolution.calendar.gschema.xml.in
+++ b/data/org.gnome.evolution.calendar.gschema.xml.in
@@ -1,6 +1,26 @@
 <schemalist>
   <schema gettext-domain="evolution" id="org.gnome.evolution.calendar" path="/apps/evolution/calendar/">
   </schema>
+  <key name="audio-dir" type="s">
+    <default>''</default>
+    <_summary>Save directory for reminder audio</_summary>
+    <_description>Directory for saving reminder audio files</_description>
+  </key>
+  <key name="day-second-zone" type="s">
+    <default>''</default>
+    <_summary>The second timezone for a Day View</_summary>
+    <_description>Shows the second time zone in a Day View, if set. Value is similar to one used in a 'timezone' key</_description>
+  </key>
+  <key name="day-second-zones" type="as">
+    <default>[]</default>
+    <_summary>Recently used second time zones in a Day View</_summary>
+    <_description>List of recently used second time zones in a Day View</_description>
+  </key>
+  <key name="day-second-zones-max" type="i">
+    <default>5</default>
+    <_summary>Maximum number of recently used timezones to remember</_summary>
+    <_description>Maximum number of recently used timezones to remember in a 'day-second-zones' list</_description>
+  </key>
   <key name="editor-show-categories" type="b">
     <default>false</default>
     <_summary>Show categories field in the event/meeting/task editor</_summary>
@@ -31,11 +51,31 @@
     <_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="hide-completed-tasks" type="b">
+    <default>false</default>
+    <_summary>Hide completed tasks</_summary>
+    <_description>Whether to hide completed tasks in the tasks view</_description>
+  </key>
+  <key name="hide-completed-tasks-units" type="s">
+    <default>'days'</default>
+    <_summary>Hide task units</_summary>
+    <_description>Units for determining when to hide tasks, "minutes", "hours" or "days"</_description>
+  </key>
+  <key name="hide-completed-tasks-value" type="i">
+    <default>1</default>
+    <_summary>Hide task value</_summary>
+    <_description>Number of units for determining when to hide tasks</_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="month-scroll-by-week" type="b">
+    <default>true</default>
+    <_summary>Scroll Month View by a week</_summary>
+    <_description>Whether to scroll a Month View by a week, not by a month</_description>
+  </key>
   <key name="notify-programs" type="as">
     <default>[]</default>
     <_summary>Reminder programs</_summary>
@@ -61,4 +101,9 @@
     <_summary>Use system timezone</_summary>
     <_description>Use the system timezone instead of the timezone selected in Evolution</_description>
   </key>
+  <key name="working-days" type="i">
+    <default>62</default>
+    <_summary>Work days</_summary>
+    <_description>Days on which the start and end of work hours should be indicated</_description>
+  </key>
 </schemalist>



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]