[evolution-data-server/gnome-3-0] Bug 647873 [2/2] - e_cal_new_system_foo() should create source in GConf (cherry picked from commit 3
- From: David Woodhouse <dwmw2 src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [evolution-data-server/gnome-3-0] Bug 647873 [2/2] - e_cal_new_system_foo() should create source in GConf (cherry picked from commit 3
- Date: Fri, 15 Apr 2011 20:57:34 +0000 (UTC)
commit 2458c24ef3d0ae2559f57318441ab50ad0c8a1fe
Author: David Woodhouse <David Woodhouse intel com>
Date: Fri Apr 15 12:19:00 2011 +0100
Bug 647873 [2/2] - e_cal_new_system_foo() should create source in GConf
(cherry picked from commit 3bb75464a6774b25cacb070959f4eb0465fd665c)
calendar/libecal/e-cal.c | 56 +++++++++++++++++++++++++++++++++++++++++++--
1 files changed, 53 insertions(+), 3 deletions(-)
---
diff --git a/calendar/libecal/e-cal.c b/calendar/libecal/e-cal.c
index d9a813d..b38d639 100644
--- a/calendar/libecal/e-cal.c
+++ b/calendar/libecal/e-cal.c
@@ -1031,6 +1031,56 @@ e_cal_new_from_uri (const gchar *uri, ECalSourceType type)
return cal;
}
+static ECal *
+get_local_source (ECalSourceType type)
+{
+ ESourceList *sources;
+ ESourceGroup *on_this_computer;
+ GSList *local_sources, *iter;
+ gchar *source_uri = NULL;
+ ECal *ecal;
+
+ if (!e_cal_get_sources (&sources, type, NULL)) {
+ g_warning ("Could not get task sources from GConf!");
+ goto out;
+ }
+
+ on_this_computer = e_source_list_ensure_group (sources,
+ _("On This Computer"),
+ "local:", TRUE);
+ if (!on_this_computer) {
+ g_object_unref (sources);
+ goto out;
+ }
+
+ local_sources = e_source_group_peek_sources (on_this_computer);
+ for (iter = local_sources; !source_uri && iter != NULL; iter = iter->next) {
+ ESource *source = iter->data;
+ gchar *uri;
+
+ uri = e_source_get_uri (source);
+ if (g_strcmp0 (uri, "local:system") == 0)
+ source_uri = uri;
+ else
+ g_free (uri);
+ }
+ if (!source_uri) {
+ ESource *source;
+ source = e_source_new (_("Personal"), "system");
+ e_source_set_color_spec (source, "#BECEDD");
+ e_source_group_add_source (on_this_computer, source, -1);
+ g_object_unref (source);
+
+ if (!e_source_list_sync (sources, NULL))
+ g_warning ("Cannot add system source to GConf!");
+ }
+ g_object_unref (on_this_computer);
+ g_object_unref (sources);
+ out:
+ ecal = e_cal_new_from_uri (source_uri?:"local:system", type);
+ g_free (source_uri);
+ return ecal;
+}
/**
* e_cal_new_system_calendar:
*
@@ -1044,7 +1094,7 @@ e_cal_new_from_uri (const gchar *uri, ECalSourceType type)
ECal *
e_cal_new_system_calendar (void)
{
- return e_cal_new_from_uri ("local:system", E_CAL_SOURCE_TYPE_EVENT);
+ return get_local_source (E_CAL_SOURCE_TYPE_EVENT);
}
/**
@@ -1060,7 +1110,7 @@ e_cal_new_system_calendar (void)
ECal *
e_cal_new_system_tasks (void)
{
- return e_cal_new_from_uri ("local:system", E_CAL_SOURCE_TYPE_TODO);
+ return get_local_source (E_CAL_SOURCE_TYPE_TODO);
}
/**
@@ -1076,7 +1126,7 @@ e_cal_new_system_tasks (void)
ECal *
e_cal_new_system_memos (void)
{
- return e_cal_new_from_uri ("local:system", E_CAL_SOURCE_TYPE_JOURNAL);
+ return get_local_source (E_CAL_SOURCE_TYPE_JOURNAL);
}
/**
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]