From 18420e77507819dcee97dcc6cf5f5811915df82a Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Sat, 23 Jun 2012 19:02:01 -0400 Subject: Bug 678634 - Criticals warnings when creating new book/cal This required some reworking of assumptions I made early on when I first wrote ESourceConfig, before I thought up the whole "collection" concept. Not all ESourceConfigBackends will use a fixed parent UID, specifically collection backends. In fact we may use multiple instances of the same ESourceConfigBackend subclass if, for example, a user has two different Exchange Web Services accounts configured. We would need to show both EWS account (or "collection") names in the "Type" combo box. For the moment collection-based ESourceConfigBackends are not listed when creating a new calendar or address book since we lack support for creating new resources on a remote server. A D-Bus interface for that is in the works. --- widgets/misc/e-cal-source-config.c | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) (limited to 'widgets/misc/e-cal-source-config.c') diff --git a/widgets/misc/e-cal-source-config.c b/widgets/misc/e-cal-source-config.c index 1d3243c77b..e57d0c6745 100644 --- a/widgets/misc/e-cal-source-config.c +++ b/widgets/misc/e-cal-source-config.c @@ -229,6 +229,37 @@ cal_source_config_get_backend_extension_name (ESourceConfig *config) return extension_name; } +static GList * +cal_source_config_list_eligible_collections (ESourceConfig *config) +{ + GQueue trash = G_QUEUE_INIT; + GList *list, *link; + + /* Chain up to parent's list_eligible_collections() method. */ + list = E_SOURCE_CONFIG_CLASS (e_cal_source_config_parent_class)-> + list_eligible_collections (config); + + for (link = list; link != NULL; link = g_list_next (link)) { + ESource *source = E_SOURCE (link->data); + ESourceCollection *extension; + const gchar *extension_name; + + extension_name = E_SOURCE_EXTENSION_COLLECTION; + extension = e_source_get_extension (source, extension_name); + + if (!e_source_collection_get_calendar_enabled (extension)) + g_queue_push_tail (&trash, link); + } + + /* Remove ineligible collections from the list. */ + while ((link = g_queue_pop_head (&trash)) != NULL) { + g_object_unref (link->data); + list = g_list_delete_link (list, link); + } + + return list; +} + static void cal_source_config_init_candidate (ESourceConfig *config, ESource *scratch_source) @@ -306,6 +337,8 @@ e_cal_source_config_class_init (ECalSourceConfigClass *class) source_config_class = E_SOURCE_CONFIG_CLASS (class); source_config_class->get_backend_extension_name = cal_source_config_get_backend_extension_name; + source_config_class->list_eligible_collections = + cal_source_config_list_eligible_collections; source_config_class->init_candidate = cal_source_config_init_candidate; source_config_class->commit_changes = cal_source_config_commit_changes; -- cgit v1.2.3