ECollectionBackend: Synchronize display-names on mail sources.
authorMatthew Barnes <mbarnes@redhat.com>
Thu, 28 Feb 2013 15:29:18 +0000 (10:29 -0500)
committerMatthew Barnes <mbarnes@redhat.com>
Thu, 28 Feb 2013 16:15:18 +0000 (11:15 -0500)
Keep display names of mail-related child sources synchronized with the
collection source's display name.  This is needed to support GOA's new
"imap_smtp" provider, but all known collection backend implementations
are already doing it on their own anyway.

Seems like a reasonable default behavior given our current use cases.

libebackend/e-collection-backend.c

index 51a3356..4b73e55 100644 (file)
@@ -711,12 +711,30 @@ collection_backend_child_added (ECollectionBackend *backend,
                                 ESource *child_source)
 {
        ESource *collection_source;
+       const gchar *extension_name;
+       gboolean is_mail = FALSE;
 
        collection_backend_children_insert (backend, child_source);
        collection_backend_bind_child_enabled (backend, child_source);
 
        collection_source = e_backend_get_source (E_BACKEND (backend));
 
+       extension_name = E_SOURCE_EXTENSION_MAIL_ACCOUNT;
+       is_mail |= e_source_has_extension (child_source, extension_name);
+
+       extension_name = E_SOURCE_EXTENSION_MAIL_IDENTITY;
+       is_mail |= e_source_has_extension (child_source, extension_name);
+
+       extension_name = E_SOURCE_EXTENSION_MAIL_TRANSPORT;
+       is_mail |= e_source_has_extension (child_source, extension_name);
+
+       /* Synchronize mail-related display names with the collection. */
+       if (is_mail)
+               g_object_bind_property (
+                       collection_source, "display-name",
+                       child_source, "display-name",
+                       G_BINDING_SYNC_CREATE);
+
        /* Collection children are not removable. */
        e_server_side_source_set_removable (
                E_SERVER_SIDE_SOURCE (child_source), FALSE);