From 0dc9aae35b1032c04f1de5a8eb2aff77550d7897 Mon Sep 17 00:00:00 2001 From: Matthew Barnes Date: Sat, 1 Jun 2013 14:25:11 -0400 Subject: EComposeHeaderTable: Replace "registry" property with "client-cache". The ESourceRegistry can still be obtained from the EClientCache: client_cache = e_composer_header_table_ref_client_cache (table); registry = e_client_cache_ref_registry (client_cache); ... g_object_unref (client_cache); g_object_unref (registry); Added functions: e_composer_header_table_ref_client_cache() Removed functions: e_composer_header_table_get_registry() --- composer/e-composer-header-table.c | 114 +++++++++++++++++++++---------------- composer/e-composer-header-table.h | 5 +- composer/e-composer-private.c | 6 +- composer/e-msg-composer.c | 49 ++++++++++++++-- 4 files changed, 114 insertions(+), 60 deletions(-) (limited to 'composer') diff --git a/composer/e-composer-header-table.c b/composer/e-composer-header-table.c index 35ac6c9903..77106609c4 100644 --- a/composer/e-composer-header-table.c +++ b/composer/e-composer-header-table.c @@ -52,18 +52,18 @@ struct _EComposerHeaderTablePrivate { GtkWidget *signature_label; GtkWidget *signature_combo_box; ENameSelector *name_selector; - ESourceRegistry *registry; + EClientCache *client_cache; EShell *shell; }; enum { PROP_0, + PROP_CLIENT_CACHE, PROP_DESTINATIONS_BCC, PROP_DESTINATIONS_CC, PROP_DESTINATIONS_TO, PROP_IDENTITY_UID, PROP_POST_TO, - PROP_REGISTRY, PROP_REPLY_TO, PROP_SHELL, PROP_SIGNATURE_COMBO_BOX, @@ -399,13 +399,16 @@ composer_header_table_setup_post_headers (EComposerHeaderTable *table) static gboolean composer_header_table_show_post_headers (EComposerHeaderTable *table) { + EClientCache *client_cache; ESourceRegistry *registry; GList *list, *link; const gchar *extension_name; const gchar *target_uid; gboolean show_post_headers = FALSE; - registry = e_composer_header_table_get_registry (table); + client_cache = e_composer_header_table_ref_client_cache (table); + registry = e_client_cache_ref_registry (client_cache); + target_uid = e_composer_header_table_get_identity_uid (table); extension_name = E_SOURCE_EXTENSION_MAIL_ACCOUNT; @@ -444,6 +447,9 @@ composer_header_table_show_post_headers (EComposerHeaderTable *table) g_list_free_full (list, (GDestroyNotify) g_object_unref); + g_object_unref (client_cache); + g_object_unref (registry); + return show_post_headers; } @@ -452,6 +458,7 @@ composer_header_table_from_changed_cb (EComposerHeaderTable *table) { ESource *source = NULL; ESource *mail_account = NULL; + EClientCache *client_cache; ESourceRegistry *registry; EComposerHeader *header; EComposerHeaderType type; @@ -466,9 +473,10 @@ composer_header_table_from_changed_cb (EComposerHeaderTable *table) /* Keep "Post-To" and "Reply-To" synchronized with "From" */ - registry = e_composer_header_table_get_registry (table); - uid = e_composer_header_table_get_identity_uid (table); + client_cache = e_composer_header_table_ref_client_cache (table); + registry = e_client_cache_ref_registry (client_cache); + uid = e_composer_header_table_get_identity_uid (table); if (uid != NULL) source = e_source_registry_ref_source (registry, uid); @@ -535,16 +543,19 @@ composer_header_table_from_changed_cb (EComposerHeaderTable *table) composer_header_table_setup_post_headers (table); else composer_header_table_setup_mail_headers (table); + + g_object_unref (client_cache); + g_object_unref (registry); } static void -composer_header_table_set_registry (EComposerHeaderTable *table, - ESourceRegistry *registry) +composer_header_table_set_client_cache (EComposerHeaderTable *table, + EClientCache *client_cache) { - g_return_if_fail (E_IS_SOURCE_REGISTRY (registry)); - g_return_if_fail (table->priv->registry == NULL); + g_return_if_fail (E_IS_CLIENT_CACHE (client_cache)); + g_return_if_fail (table->priv->client_cache == NULL); - table->priv->registry = g_object_ref (registry); + table->priv->client_cache = g_object_ref (client_cache); } static void @@ -567,6 +578,12 @@ composer_header_table_set_property (GObject *object, GList *list; switch (property_id) { + case PROP_CLIENT_CACHE: + composer_header_table_set_client_cache ( + E_COMPOSER_HEADER_TABLE (object), + g_value_get_object (value)); + return; + case PROP_DESTINATIONS_BCC: destinations = g_value_dup_destinations (value); e_composer_header_table_set_destinations_bcc ( @@ -605,12 +622,6 @@ composer_header_table_set_property (GObject *object, g_list_free (list); return; - case PROP_REGISTRY: - composer_header_table_set_registry ( - E_COMPOSER_HEADER_TABLE (object), - g_value_get_object (value)); - return; - case PROP_REPLY_TO: e_composer_header_table_set_reply_to ( E_COMPOSER_HEADER_TABLE (object), @@ -649,6 +660,13 @@ composer_header_table_get_property (GObject *object, GList *list; switch (property_id) { + case PROP_CLIENT_CACHE: + g_value_take_object ( + value, + e_composer_header_table_ref_client_cache ( + E_COMPOSER_HEADER_TABLE (object))); + return; + case PROP_DESTINATIONS_BCC: destinations = e_composer_header_table_get_destinations_bcc ( @@ -688,13 +706,6 @@ composer_header_table_get_property (GObject *object, g_list_free (list); return; - case PROP_REGISTRY: - g_value_set_object ( - value, - e_composer_header_table_get_registry ( - E_COMPOSER_HEADER_TABLE (object))); - return; - case PROP_REPLY_TO: g_value_set_string ( value, @@ -760,9 +771,9 @@ composer_header_table_dispose (GObject *object) priv->name_selector = NULL; } - if (priv->registry != NULL) { - g_object_unref (priv->registry); - priv->registry = NULL; + if (priv->client_cache != NULL) { + g_object_unref (priv->client_cache); + priv->client_cache = NULL; } if (priv->shell != NULL) { @@ -783,7 +794,6 @@ composer_header_table_constructed (GObject *object) ESourceRegistry *registry; EComposerHeader *header; GtkWidget *widget; - EShell *shell; guint ii; gint row_padding; @@ -792,9 +802,9 @@ composer_header_table_constructed (GObject *object) constructed (object); table = E_COMPOSER_HEADER_TABLE (object); - shell = e_composer_header_table_get_shell (table); - client_cache = e_shell_get_client_cache (shell); - registry = e_composer_header_table_get_registry (table); + + client_cache = e_composer_header_table_ref_client_cache (table); + registry = e_client_cache_ref_registry (client_cache); name_selector = e_name_selector_new (client_cache); table->priv->name_selector = name_selector; @@ -891,6 +901,9 @@ composer_header_table_constructed (GObject *object) /* Initialize the headers. */ composer_header_table_from_changed_cb (table); + + g_object_unref (client_cache); + g_object_unref (registry); } static void @@ -906,6 +919,23 @@ e_composer_header_table_class_init (EComposerHeaderTableClass *class) object_class->dispose = composer_header_table_dispose; object_class->constructed = composer_header_table_constructed; + /** + * EComposerHeaderTable:client-cache: + * + * Cache of shared #EClient instances. + **/ + g_object_class_install_property ( + object_class, + PROP_CLIENT_CACHE, + g_param_spec_object ( + "client-cache", + "Client Cache", + "Cache of shared EClient instances", + E_TYPE_CLIENT_CACHE, + G_PARAM_READWRITE | + G_PARAM_CONSTRUCT_ONLY | + G_PARAM_STATIC_STRINGS)); + g_object_class_install_property ( object_class, PROP_DESTINATIONS_BCC, @@ -961,18 +991,6 @@ e_composer_header_table_class_init (EComposerHeaderTableClass *class) G_PARAM_READWRITE | G_PARAM_STATIC_STRINGS)); - g_object_class_install_property ( - object_class, - PROP_REGISTRY, - g_param_spec_object ( - "registry", - NULL, - NULL, - E_TYPE_SOURCE_REGISTRY, - G_PARAM_READWRITE | - G_PARAM_CONSTRUCT_ONLY | - G_PARAM_STATIC_STRINGS)); - g_object_class_install_property ( object_class, PROP_REPLY_TO, @@ -1062,14 +1080,14 @@ e_composer_header_table_init (EComposerHeaderTable *table) GtkWidget * e_composer_header_table_new (EShell *shell, - ESourceRegistry *registry) + EClientCache *client_cache) { g_return_val_if_fail (E_IS_SHELL (shell), NULL); - g_return_val_if_fail (E_IS_SOURCE_REGISTRY (registry), NULL); + g_return_val_if_fail (E_IS_CLIENT_CACHE (client_cache), NULL); return g_object_new ( E_TYPE_COMPOSER_HEADER_TABLE, - "shell", shell, "registry", registry, NULL); + "shell", shell, "client-cache", client_cache, NULL); } EShell * @@ -1080,12 +1098,12 @@ e_composer_header_table_get_shell (EComposerHeaderTable *table) return table->priv->shell; } -ESourceRegistry * -e_composer_header_table_get_registry (EComposerHeaderTable *table) +EClientCache * +e_composer_header_table_ref_client_cache (EComposerHeaderTable *table) { g_return_val_if_fail (E_IS_COMPOSER_HEADER_TABLE (table), NULL); - return table->priv->registry; + return g_object_ref (table->priv->client_cache); } EComposerHeader * diff --git a/composer/e-composer-header-table.h b/composer/e-composer-header-table.h index f459aaeae8..5ccc77e6a1 100644 --- a/composer/e-composer-header-table.h +++ b/composer/e-composer-header-table.h @@ -71,11 +71,10 @@ struct _EComposerHeaderTableClass { GType e_composer_header_table_get_type (void); GtkWidget * e_composer_header_table_new (EShell *shell, - ESourceRegistry *registry); + EClientCache *client_cache); EShell * e_composer_header_table_get_shell (EComposerHeaderTable *table); -ESourceRegistry * - e_composer_header_table_get_registry +EClientCache * e_composer_header_table_ref_client_cache (EComposerHeaderTable *table); EComposerHeader * e_composer_header_table_get_header diff --git a/composer/e-composer-private.c b/composer/e-composer-private.c index 2e44aa1aa9..90ff2037c8 100644 --- a/composer/e-composer-private.c +++ b/composer/e-composer-private.c @@ -141,7 +141,7 @@ e_composer_private_constructed (EMsgComposer *composer) EFocusTracker *focus_tracker; EShell *shell; EWebViewGtkHTML *web_view; - ESourceRegistry *registry; + EClientCache *client_cache; GtkhtmlEditor *editor; GtkUIManager *ui_manager; GtkAction *action; @@ -161,7 +161,7 @@ e_composer_private_constructed (EMsgComposer *composer) settings = g_settings_new ("org.gnome.evolution.mail"); shell = e_msg_composer_get_shell (composer); - registry = e_shell_get_registry (shell); + client_cache = e_shell_get_client_cache (shell); web_view = e_msg_composer_get_web_view (composer); /* Each composer window gets its own window group. */ @@ -245,7 +245,7 @@ e_composer_private_constructed (EMsgComposer *composer) /* Construct the header table. */ - widget = e_composer_header_table_new (shell, registry); + widget = e_composer_header_table_new (shell, client_cache); gtk_container_set_border_width (GTK_CONTAINER (widget), 6); gtk_box_pack_start (GTK_BOX (container), widget, FALSE, FALSE, 0); gtk_box_reorder_child (GTK_BOX (container), widget, 2); diff --git a/composer/e-msg-composer.c b/composer/e-msg-composer.c index 0a3a3223f7..efb29e0b2e 100644 --- a/composer/e-msg-composer.c +++ b/composer/e-msg-composer.c @@ -532,6 +532,7 @@ build_message_headers (EMsgComposer *composer, { EComposerHeaderTable *table; EComposerHeader *header; + EClientCache *client_cache; ESourceRegistry *registry; ESource *source; const gchar *subject; @@ -543,7 +544,9 @@ build_message_headers (EMsgComposer *composer, table = e_msg_composer_get_header_table (composer); - registry = e_composer_header_table_get_registry (table); + client_cache = e_composer_header_table_ref_client_cache (table); + registry = e_client_cache_ref_registry (client_cache); + uid = e_composer_header_table_get_identity_uid (table); source = e_source_registry_ref_source (registry, uid); @@ -657,6 +660,9 @@ build_message_headers (EMsgComposer *composer, } g_list_free (list); } + + g_object_unref (client_cache); + g_object_unref (registry); } static CamelCipherHash @@ -1080,6 +1086,7 @@ composer_build_message (EMsgComposer *composer, EComposerHeaderTable *table; CamelDataWrapper *html; ESourceMailIdentity *mi; + EClientCache *client_cache; ESourceRegistry *registry; const gchar *extension_name; const gchar *iconv_charset = NULL; @@ -1101,9 +1108,15 @@ composer_build_message (EMsgComposer *composer, view = e_msg_composer_get_attachment_view (composer); store = e_attachment_view_get_store (view); - registry = e_composer_header_table_get_registry (table); + client_cache = e_composer_header_table_ref_client_cache (table); + registry = e_client_cache_ref_registry (client_cache); + identity_uid = e_composer_header_table_get_identity_uid (table); source = e_source_registry_ref_source (registry, identity_uid); + + g_clear_object (&client_cache); + g_clear_object (®istry); + g_return_if_fail (source != NULL); /* Do all the non-blocking work here, and defer @@ -1568,6 +1581,7 @@ msg_composer_mail_identity_changed_cb (EMsgComposer *composer) { EMsgComposerPrivate *p = composer->priv; EMailSignatureComboBox *combo_box; + EClientCache *client_cache; ESourceRegistry *registry; ESourceMailComposition *mc; ESourceOpenPGP *pgp; @@ -1583,14 +1597,18 @@ msg_composer_mail_identity_changed_cb (EMsgComposer *composer) const gchar *uid; table = e_msg_composer_get_header_table (composer); - registry = e_composer_header_table_get_registry (table); uid = e_composer_header_table_get_identity_uid (table); /* Silently return if no identity is selected. */ if (uid == NULL) return; + client_cache = e_composer_header_table_ref_client_cache (table); + registry = e_client_cache_ref_registry (client_cache); source = e_source_registry_ref_source (registry, uid); + g_clear_object (&client_cache); + g_clear_object (®istry); + g_return_if_fail (source != NULL); extension_name = E_SOURCE_EXTENSION_MAIL_COMPOSITION; @@ -3080,6 +3098,7 @@ e_msg_composer_new_with_message (EShell *shell, EMsgComposer *composer; EMsgComposerPrivate *priv; EComposerHeaderTable *table; + EClientCache *client_cache; ESourceRegistry *registry; ESource *source = NULL; GtkToggleAction *action; @@ -3104,7 +3123,6 @@ e_msg_composer_new_with_message (EShell *shell, composer = e_msg_composer_new (shell); priv = E_MSG_COMPOSER_GET_PRIVATE (composer); table = e_msg_composer_get_header_table (composer); - registry = e_composer_header_table_get_registry (table); if (postto) { e_composer_header_table_set_post_to_list (table, postto); @@ -3113,6 +3131,9 @@ e_msg_composer_new_with_message (EShell *shell, postto = NULL; } + client_cache = e_composer_header_table_ref_client_cache (table); + registry = e_client_cache_ref_registry (client_cache); + /* Restore the mail identity preference. */ identity_uid = (gchar *) camel_medium_get_header ( CAMEL_MEDIUM (message), "X-Evolution-Identity"); @@ -3126,6 +3147,9 @@ e_msg_composer_new_with_message (EShell *shell, source = e_source_registry_ref_source (registry, identity_uid); } + g_clear_object (&client_cache); + g_clear_object (®istry); + if (postto == NULL) { auto_cc = g_hash_table_new_full ( (GHashFunc) camel_strcase_hash, @@ -4204,6 +4228,7 @@ e_msg_composer_set_body (EMsgComposer *composer, EMsgComposerPrivate *priv = composer->priv; EComposerHeaderTable *table; EWebViewGtkHTML *web_view; + EClientCache *client_cache; ESourceRegistry *registry; ESource *source; const gchar *identity_uid; @@ -4212,11 +4237,16 @@ e_msg_composer_set_body (EMsgComposer *composer, g_return_if_fail (E_IS_MSG_COMPOSER (composer)); table = e_msg_composer_get_header_table (composer); - registry = e_composer_header_table_get_registry (table); + + client_cache = e_composer_header_table_ref_client_cache (table); + registry = e_client_cache_ref_registry (client_cache); identity_uid = e_composer_header_table_get_identity_uid (table); source = e_source_registry_ref_source (registry, identity_uid); + g_clear_object (&client_cache); + g_clear_object (®istry); + buff = g_markup_printf_escaped ( "%s", _("The composer contains a non-text " @@ -4759,6 +4789,7 @@ e_msg_composer_get_from (EMsgComposer *composer) CamelInternetAddress *inet_address = NULL; ESourceMailIdentity *mail_identity; EComposerHeaderTable *table; + EClientCache *client_cache; ESourceRegistry *registry; ESource *source; const gchar *extension_name; @@ -4770,9 +4801,15 @@ e_msg_composer_get_from (EMsgComposer *composer) table = e_msg_composer_get_header_table (composer); - registry = e_composer_header_table_get_registry (table); + client_cache = e_composer_header_table_ref_client_cache (table); + registry = e_client_cache_ref_registry (client_cache); + uid = e_composer_header_table_get_identity_uid (table); source = e_source_registry_ref_source (registry, uid); + + g_clear_object (&client_cache); + g_clear_object (®istry); + g_return_val_if_fail (source != NULL, NULL); extension_name = E_SOURCE_EXTENSION_MAIL_IDENTITY; -- cgit v1.2.3