diff options
author | Matthew Barnes <mbarnes@redhat.com> | 2013-06-02 23:03:34 +0800 |
---|---|---|
committer | Matthew Barnes <mbarnes@redhat.com> | 2013-06-03 01:22:41 +0800 |
commit | f5e47561f995ca50f2bbd45b940e0a10100281a5 (patch) | |
tree | 16386f25f49632fce70256294451993f65315480 /mail | |
parent | 1570f53d1eab0a750680df72be3363659f11db46 (diff) | |
download | gsoc2013-evolution-f5e47561f995ca50f2bbd45b940e0a10100281a5.tar gsoc2013-evolution-f5e47561f995ca50f2bbd45b940e0a10100281a5.tar.gz gsoc2013-evolution-f5e47561f995ca50f2bbd45b940e0a10100281a5.tar.bz2 gsoc2013-evolution-f5e47561f995ca50f2bbd45b940e0a10100281a5.tar.lz gsoc2013-evolution-f5e47561f995ca50f2bbd45b940e0a10100281a5.tar.xz gsoc2013-evolution-f5e47561f995ca50f2bbd45b940e0a10100281a5.tar.zst gsoc2013-evolution-f5e47561f995ca50f2bbd45b940e0a10100281a5.zip |
EMailReader: Add a "composer-created" signal.
Emitted to indicate a composer window was created in response to a user
action on the EMailReader. Examples of such actions include replying,
forwarding, and starting a new message.
If applicable, the source message (i.e. the message being replied to or
forwarded) is included in the signal emission.
New functions:
e_mail_reader_composer_created()
Diffstat (limited to 'mail')
-rw-r--r-- | mail/e-mail-reader-utils.c | 13 | ||||
-rw-r--r-- | mail/e-mail-reader.c | 49 | ||||
-rw-r--r-- | mail/e-mail-reader.h | 7 | ||||
-rw-r--r-- | mail/em-composer-utils.c | 35 |
4 files changed, 96 insertions, 8 deletions
diff --git a/mail/e-mail-reader-utils.c b/mail/e-mail-reader-utils.c index ed6d14548a..0a7dc8d421 100644 --- a/mail/e-mail-reader-utils.c +++ b/mail/e-mail-reader-utils.c @@ -1322,6 +1322,7 @@ mail_reader_reply_message_parsed (GObject *object, EMailBackend *backend; EMailReader *reader = E_MAIL_READER (object); EMailPartList *part_list; + EMsgComposer *composer; CamelMimeMessage *message; AsyncContext *async_context; @@ -1333,7 +1334,7 @@ mail_reader_reply_message_parsed (GObject *object, backend = e_mail_reader_get_backend (async_context->reader); shell = e_shell_backend_get_shell (E_SHELL_BACKEND (backend)); - em_utils_reply_to_message ( + composer = em_utils_reply_to_message ( shell, message, async_context->folder, async_context->message_uid, @@ -1342,6 +1343,8 @@ mail_reader_reply_message_parsed (GObject *object, part_list, async_context->address); + e_mail_reader_composer_created (reader, composer, message); + g_object_unref (part_list); async_context_free (async_context); @@ -1558,7 +1561,7 @@ e_mail_reader_reply_to_message (EMailReader *reader, composer = em_utils_reply_to_message ( shell, new_message, folder, uid, reply_type, reply_style, NULL, address); - if (composer && (validity_pgp_sum != 0 || validity_smime_sum != 0)) { + if (validity_pgp_sum != 0 || validity_smime_sum != 0) { GtkToggleAction *action; if ((validity_pgp_sum & E_MAIL_PART_VALIDITY_PGP) != 0) { @@ -1586,6 +1589,8 @@ e_mail_reader_reply_to_message (EMailReader *reader, } } + e_mail_reader_composer_created (reader, composer, new_message); + if (address) g_object_unref (address); @@ -1626,9 +1631,11 @@ whole_message: g_object_unref (activity); } else { - em_utils_reply_to_message ( + composer = em_utils_reply_to_message ( shell, src_message, folder, uid, reply_type, reply_style, part_list, address); + + e_mail_reader_composer_created (reader, composer, src_message); } g_clear_object (&address); diff --git a/mail/e-mail-reader.c b/mail/e-mail-reader.c index 2a468704c9..fd9fefc2b9 100644 --- a/mail/e-mail-reader.c +++ b/mail/e-mail-reader.c @@ -97,6 +97,7 @@ struct _EMailReaderPrivate { enum { CHANGED, + COMPOSER_CREATED, FOLDER_LOADED, MESSAGE_LOADED, MESSAGE_SEEN, @@ -969,6 +970,7 @@ action_mail_message_new_cb (GtkAction *action, EMailBackend *backend; EShellBackend *shell_backend; CamelFolder *folder; + EMsgComposer *composer; folder = e_mail_reader_get_folder (reader); backend = e_mail_reader_get_backend (reader); @@ -976,7 +978,9 @@ action_mail_message_new_cb (GtkAction *action, shell_backend = E_SHELL_BACKEND (backend); shell = e_shell_backend_get_shell (shell_backend); - em_utils_compose_new_message (shell, folder); + composer = em_utils_compose_new_message (shell, folder); + + e_mail_reader_composer_created (reader, composer, NULL); } static void @@ -1237,6 +1241,7 @@ mail_reader_redirect_cb (CamelFolder *folder, EMailBackend *backend; EAlertSink *alert_sink; CamelMimeMessage *message; + EMsgComposer *composer; GError *error = NULL; alert_sink = e_activity_get_alert_sink (closure->activity); @@ -1264,9 +1269,11 @@ mail_reader_redirect_cb (CamelFolder *folder, backend = e_mail_reader_get_backend (closure->reader); shell = e_shell_backend_get_shell (E_SHELL_BACKEND (backend)); - em_utils_redirect_message (shell, message); + composer = em_utils_redirect_message (shell, message); check_close_browser_reader (closure->reader); + e_mail_reader_composer_created (closure->reader, composer, message); + g_object_unref (message); mail_reader_closure_free (closure); @@ -3842,6 +3849,16 @@ e_mail_reader_default_init (EMailReaderInterface *interface) g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0); + signals[COMPOSER_CREATED] = g_signal_new ( + "composer-created", + G_OBJECT_CLASS_TYPE (interface), + G_SIGNAL_RUN_FIRST, + G_STRUCT_OFFSET (EMailReaderInterface, composer_created), + NULL, NULL, NULL, + G_TYPE_NONE, 2, + E_TYPE_MSG_COMPOSER, + CAMEL_TYPE_MIME_MESSAGE); + signals[FOLDER_LOADED] = g_signal_new ( "folder-loaded", G_OBJECT_CLASS_TYPE (interface), @@ -4861,3 +4878,31 @@ e_mail_reader_avoid_next_mark_as_seen (EMailReader *reader) priv->avoid_next_mark_as_seen = TRUE; } + +/** + * e_mail_reader_composer_created: + * @reader: an #EMailReader + * @composer: an #EMsgComposer + * @message: the source #CamelMimeMessage, or %NULL + * + * Emits a #EMailReader::composer-created signal to indicate the @composer + * window was created in response to a user action on @reader. Examples of + * such actions include replying, forwarding, and composing a new message. + * If applicable, the source @message (i.e. the message being replied to or + * forwarded) should be included. + **/ +void +e_mail_reader_composer_created (EMailReader *reader, + EMsgComposer *composer, + CamelMimeMessage *message) +{ + g_return_if_fail (E_IS_MAIL_READER (reader)); + g_return_if_fail (E_IS_MSG_COMPOSER (composer)); + + if (message != NULL) + g_return_if_fail (CAMEL_IS_MIME_MESSAGE (message)); + + g_signal_emit ( + reader, signals[COMPOSER_CREATED], 0, composer, message); +} + diff --git a/mail/e-mail-reader.h b/mail/e-mail-reader.h index 213ba63a41..6303ce99b0 100644 --- a/mail/e-mail-reader.h +++ b/mail/e-mail-reader.h @@ -30,6 +30,7 @@ #include <gtk/gtk.h> #include <camel/camel.h> #include <e-util/e-util.h> +#include <composer/e-msg-composer.h> #include <mail/e-mail-backend.h> #include <mail/e-mail-display.h> @@ -113,6 +114,9 @@ struct _EMailReaderInterface { gboolean (*enable_show_folder) (EMailReader *reader); /* Signals */ + void (*composer_created) (EMailReader *reader, + EMsgComposer *composer, + CamelMimeMessage *source); void (*folder_loaded) (EMailReader *reader); void (*message_loaded) (EMailReader *reader, const gchar *message_uid, @@ -178,6 +182,9 @@ void e_mail_reader_enable_show_folder (EMailReader *reader); void e_mail_reader_avoid_next_mark_as_seen (EMailReader *reader); +void e_mail_reader_composer_created (EMailReader *reader, + EMsgComposer *composer, + CamelMimeMessage *message); G_END_DECLS diff --git a/mail/em-composer-utils.c b/mail/em-composer-utils.c index 6c60925c3f..a849f2830f 100644 --- a/mail/em-composer-utils.c +++ b/mail/em-composer-utils.c @@ -1545,6 +1545,7 @@ edit_messages_cb (GObject *source_object, g_hash_table_iter_init (&iter, hash_table); while (g_hash_table_iter_next (&iter, &key, &value)) { + EMsgComposer *composer; CamelMimeMessage *message; const gchar *message_uid; @@ -1556,9 +1557,12 @@ edit_messages_cb (GObject *source_object, camel_medium_remove_header (CAMEL_MEDIUM (value), "X-Mailer"); - em_utils_edit_message ( + composer = em_utils_edit_message ( shell, folder, message, message_uid, async_context->keep_signature); + + e_mail_reader_composer_created ( + async_context->reader, composer, message); } g_hash_table_unref (hash_table); @@ -1775,6 +1779,8 @@ forward_attached_cb (GObject *source_object, EActivity *activity; EAlertSink *alert_sink; CamelMimePart *part; + CamelDataWrapper *content; + EMsgComposer *composer; gchar *subject = NULL; AsyncContext *async_context; GError *local_error = NULL; @@ -1810,9 +1816,28 @@ forward_attached_cb (GObject *source_object, backend = e_mail_reader_get_backend (async_context->reader); - forward_attached ( + composer = forward_attached ( backend, folder, async_context->ptr_array, part, subject); + content = camel_medium_get_content (CAMEL_MEDIUM (part)); + if (CAMEL_IS_MIME_MESSAGE (content)) { + e_mail_reader_composer_created ( + async_context->reader, composer, + CAMEL_MIME_MESSAGE (content)); + } else { + /* XXX What to do for the multipart/digest case? + * Extract the first message from the digest, or + * change the argument type to CamelMimePart and + * just pass the whole digest through? + * + * This signal is primarily serving EMailBrowser, + * which can only forward one message at a time. + * So for the moment it doesn't matter, but still + * something to consider. */ + e_mail_reader_composer_created ( + async_context->reader, composer, NULL); + } + e_activity_set_state (activity, E_ACTIVITY_COMPLETED); g_object_unref (part); @@ -1991,15 +2016,19 @@ forward_got_messages_cb (GObject *source_object, g_hash_table_iter_init (&iter, hash_table); while (g_hash_table_iter_next (&iter, &key, &value)) { + EMsgComposer *composer; CamelMimeMessage *message; const gchar *message_uid; message_uid = (const gchar *) key; message = CAMEL_MIME_MESSAGE (value); - em_utils_forward_message ( + composer = em_utils_forward_message ( backend, message, async_context->style, folder, message_uid); + + e_mail_reader_composer_created ( + async_context->reader, composer, message); } g_hash_table_unref (hash_table); |