From df6a8262a141e0bec824149e7f65568d2187c5c2 Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Fri, 12 Sep 2008 01:54:07 +0000 Subject: Arrange for an ESourceList to be shared amongst all instances of a type of shell view. For example, all EBookShellView instances will now share the same ESourceList instance for address books. svn path=/branches/kill-bonobo/; revision=36311 --- calendar/gui/memos-component.c | 123 ----------------------------------------- 1 file changed, 123 deletions(-) (limited to 'calendar/gui/memos-component.c') diff --git a/calendar/gui/memos-component.c b/calendar/gui/memos-component.c index e292e8a7da..93af51f061 100644 --- a/calendar/gui/memos-component.c +++ b/calendar/gui/memos-component.c @@ -119,128 +119,6 @@ struct _MemosComponentPrivate { /* #define d(x) x */ #define d(x) -static void -ensure_sources (MemosComponent *component) -{ - GSList *groups; - ESourceList *source_list; - ESourceGroup *group; - ESourceGroup *on_this_computer; - ESourceGroup *on_the_web; - ESource *personal_source; - char *base_uri, *base_uri_proto; - const gchar *base_dir; - - on_this_computer = NULL; - on_the_web = NULL; - personal_source = NULL; - - if (!e_cal_get_sources (&source_list, E_CAL_SOURCE_TYPE_JOURNAL, NULL)) { - g_warning ("Could not get memo source list from GConf!"); - return; - } - - base_dir = memos_component_peek_base_directory (component); - base_uri = g_build_filename (base_dir, "local", NULL); - - base_uri_proto = g_filename_to_uri (base_uri, NULL, NULL); - - groups = e_source_list_peek_groups (source_list); - if (groups) { - /* groups are already there, we need to search for things... */ - GSList *g; - - for (g = groups; g; g = g->next) { - - group = E_SOURCE_GROUP (g->data); - - /* compare only file:// part. If user home dir name changes we do not want to create - one more group */ - - if (!on_this_computer && !strncmp (base_uri_proto, e_source_group_peek_base_uri (group), 7)) - on_this_computer = group; - else if (!on_the_web && !strcmp (WEB_BASE_URI, e_source_group_peek_base_uri (group))) - on_the_web = group; - } - } - - if (on_this_computer) { - /* make sure "Personal" shows up as a source under - this group */ - GSList *sources = e_source_group_peek_sources (on_this_computer); - GSList *s; - for (s = sources; s; s = s->next) { - ESource *source = E_SOURCE (s->data); - const gchar *relative_uri; - - relative_uri = e_source_peek_relative_uri (source); - if (relative_uri == NULL) - continue; - if (!strcmp (PERSONAL_RELATIVE_URI, relative_uri)) { - personal_source = source; - break; - } - } - /* Make sure we have the correct base uri. This can change when user's - homedir name changes */ - if (strcmp (base_uri_proto, e_source_group_peek_base_uri (on_this_computer))) { - e_source_group_set_base_uri (on_this_computer, base_uri_proto); - - /* *sigh* . We shouldn't need this sync call here as set_base_uri - call results in synching to gconf, but that happens in idle loop - and too late to prevent user seeing "Can not Open ... because of invalid uri" error.*/ - e_source_list_sync (source_list,NULL); - } - } - else { - /* create the local source group */ - group = e_source_group_new (_("On This Computer"), base_uri_proto); - e_source_list_add_group (source_list, group, -1); - - on_this_computer = group; - } - - if (!personal_source) { - GSList *memos_selected; - /* Create the default Person addressbook */ - ESource *source = e_source_new (_("Personal"), PERSONAL_RELATIVE_URI); - e_source_group_add_source (on_this_computer, source, -1); - g_object_unref (source); - - memos_selected = calendar_config_get_memos_selected (); - - if (!calendar_config_get_primary_memos () && !memos_selected) { - GSList selected; - - calendar_config_set_primary_memos (e_source_peek_uid (source)); - - selected.data = (gpointer)e_source_peek_uid (source); - selected.next = NULL; - calendar_config_set_memos_selected (&selected); - } - - if (memos_selected) { - g_slist_foreach (memos_selected, (GFunc) g_free, NULL); - g_slist_free (memos_selected); - } - - e_source_set_color_spec (source, "#BECEDD"); - personal_source = source; - } - - if (!on_the_web) { - /* Create the LDAP source group */ - group = e_source_group_new (_("On The Web"), WEB_BASE_URI); - e_source_list_add_group (source_list, group, -1); - - on_the_web = group; - } - - component->priv->source_list = source_list; - g_free (base_uri_proto); - g_free (base_uri); -} - /* Utility functions. */ /* FIXME Some of these are duplicated from calendar-component.c */ static gboolean @@ -1346,7 +1224,6 @@ memos_component_init (MemosComponent *component, MemosComponentClass *klass) priv = g_new0 (MemosComponentPrivate, 1); component->priv = priv; - ensure_sources (component); } /* Public API */ -- cgit v1.2.3