diff options
author | Milan Crha <mcrha@redhat.com> | 2008-06-02 12:42:19 +0800 |
---|---|---|
committer | Bharath Acharya <abharath@src.gnome.org> | 2008-06-02 12:42:19 +0800 |
commit | 4c2a34cddd0261e589a402f0d66248119702e593 (patch) | |
tree | 31f7851492595f6ebeb4d35e4e599097f2c3f4ec | |
parent | 851c7fac433e4c5a5ac04398c89480f4500c30a9 (diff) | |
download | gsoc2013-evolution-4c2a34cddd0261e589a402f0d66248119702e593.tar gsoc2013-evolution-4c2a34cddd0261e589a402f0d66248119702e593.tar.gz gsoc2013-evolution-4c2a34cddd0261e589a402f0d66248119702e593.tar.bz2 gsoc2013-evolution-4c2a34cddd0261e589a402f0d66248119702e593.tar.lz gsoc2013-evolution-4c2a34cddd0261e589a402f0d66248119702e593.tar.xz gsoc2013-evolution-4c2a34cddd0261e589a402f0d66248119702e593.tar.zst gsoc2013-evolution-4c2a34cddd0261e589a402f0d66248119702e593.zip |
Committing on behalf of Milan Crha <mcrha@redhat.com>
2008-05-29 Milan Crha <mcrha@redhat.com>
** Fix for bug #534312
* em-composer-utils.c: (create_new_composer),
(em_utils_compose_new_message), (struct forward_attached_data),
(real_update_forwarded_flag), (update_forwarded_flags_cb),
(composer_destroy_fad_cb), (setup_forward_attached_callbacks),
(forward_attached), (forward_attached_cb), (em_utils_forward_attached),
(forward_non_attached), (forward_quoted), (em_utils_forward_message):
Set new CAMEL_MESSAGE_FORWARDED flag on forwarded messages.
* message-list.c: (ml_value_to_string), (message_list_create_extras),
(ml_tree_value_at), (create_composite_cell), (struct states_pixmaps):
Draw mail-forward icon on forwarded messages.
svn path=/trunk/; revision=35567
-rw-r--r-- | mail/ChangeLog | 15 | ||||
-rw-r--r-- | mail/em-composer-utils.c | 103 | ||||
-rw-r--r-- | mail/message-list.c | 30 |
3 files changed, 120 insertions, 28 deletions
diff --git a/mail/ChangeLog b/mail/ChangeLog index 29a8ab27c4..8bf754f62d 100644 --- a/mail/ChangeLog +++ b/mail/ChangeLog @@ -1,3 +1,18 @@ +2008-06-02 Milan Crha <mcrha@redhat.com> + + ** Fix for bug #534312 + + * em-composer-utils.c: (create_new_composer), + (em_utils_compose_new_message), (struct forward_attached_data), + (real_update_forwarded_flag), (update_forwarded_flags_cb), + (composer_destroy_fad_cb), (setup_forward_attached_callbacks), + (forward_attached), (forward_attached_cb), (em_utils_forward_attached), + (forward_non_attached), (forward_quoted), (em_utils_forward_message): + Set new CAMEL_MESSAGE_FORWARDED flag on forwarded messages. + * message-list.c: (ml_value_to_string), (message_list_create_extras), + (ml_tree_value_at), (create_composite_cell), (struct states_pixmaps): + Draw mail-forward icon on forwarded messages. + 2008-05-30 Lucian Langa <lucilanga@gnome.org> ** Fix for bug #535670 diff --git a/mail/em-composer-utils.c b/mail/em-composer-utils.c index f5a3a2ced0..6934e3f33d 100644 --- a/mail/em-composer-utils.c +++ b/mail/em-composer-utils.c @@ -631,7 +631,7 @@ em_composer_utils_setup_callbacks (EMsgComposer *composer, /* Composing messages... */ static EMsgComposer * -create_new_composer (const char *subject, const char *fromuri) +create_new_composer (const char *subject, const char *fromuri, gboolean use_default_callbacks) { EMsgComposer *composer; EComposerHeaderTable *table; @@ -648,7 +648,8 @@ create_new_composer (const char *subject, const char *fromuri) e_composer_header_table_set_account (table, account); e_composer_header_table_set_subject (table, subject); - em_composer_utils_setup_default_callbacks (composer); + if (use_default_callbacks) + em_composer_utils_setup_default_callbacks (composer); return composer; } @@ -665,7 +666,7 @@ em_utils_compose_new_message (const char *fromuri) GtkWidget *composer; GtkhtmlEditor *editor; - composer = (GtkWidget *) create_new_composer ("", fromuri); + composer = (GtkWidget *) create_new_composer ("", fromuri, TRUE); if (composer == NULL) return; @@ -864,18 +865,77 @@ em_utils_edit_messages (CamelFolder *folder, GPtrArray *uids, gboolean replace) } /* Forwarding messages... */ +struct forward_attached_data +{ + CamelFolder *folder; + GPtrArray *uids; + char *fromuri; +}; + static void -forward_attached (CamelFolder *folder, GPtrArray *messages, CamelMimePart *part, char *subject, const char *fromuri) +real_update_forwarded_flag (gpointer uid, gpointer folder) +{ + if (uid && folder) + camel_folder_set_message_flags (folder, uid, CAMEL_MESSAGE_FORWARDED, CAMEL_MESSAGE_FORWARDED); +} + +static void +update_forwarded_flags_cb (EMsgComposer *composer, gpointer user_data) +{ + struct forward_attached_data *fad = (struct forward_attached_data *) user_data; + + if (fad && fad->uids && fad->folder) + g_ptr_array_foreach (fad->uids, real_update_forwarded_flag, fad->folder); +} + +static void +composer_destroy_fad_cb (gpointer user_data, GObject *deadbeef) +{ + struct forward_attached_data *fad = (struct forward_attached_data*) user_data; + + if (fad) { + camel_object_unref (fad->folder); + em_utils_uids_free (fad->uids); + g_free (fad); + } +} + +static void +setup_forward_attached_callbacks (EMsgComposer *composer, CamelFolder *folder, GPtrArray *uids) +{ + struct forward_attached_data *fad; + + if (!composer || !folder || !uids || !uids->len) + return; + + camel_object_ref (folder); + + fad = g_new0 (struct forward_attached_data, 1); + fad->folder = folder; + fad->uids = em_utils_uids_copy (uids); + + g_signal_connect (composer, "send", G_CALLBACK (update_forwarded_flags_cb), fad); + g_signal_connect (composer, "save-draft", G_CALLBACK (update_forwarded_flags_cb), fad); + + g_object_weak_ref ((GObject *) composer, (GWeakNotify) composer_destroy_fad_cb, fad); +} + +static void +forward_attached (CamelFolder *folder, GPtrArray *uids, GPtrArray *messages, CamelMimePart *part, char *subject, const char *fromuri) { EMsgComposer *composer; GtkhtmlEditor *editor; - composer = create_new_composer (subject, fromuri); + composer = create_new_composer (subject, fromuri, TRUE); if (composer == NULL) return; e_msg_composer_attach (composer, part); + + if (uids) + setup_forward_attached_callbacks (composer, folder, uids); + editor = GTKHTML_EDITOR (composer); gtkhtml_editor_set_changed (editor, FALSE); gtkhtml_editor_drop_undo (editor); @@ -886,9 +946,13 @@ forward_attached (CamelFolder *folder, GPtrArray *messages, CamelMimePart *part, static void forward_attached_cb (CamelFolder *folder, GPtrArray *messages, CamelMimePart *part, char *subject, void *user_data) { + struct forward_attached_data *fad = (struct forward_attached_data *) user_data; + if (part) - forward_attached(folder, messages, part, subject, (char *)user_data); - g_free(user_data); + forward_attached (folder, fad->uids, messages, part, subject, fad->fromuri); + + g_free (fad->fromuri); + g_free (fad); } /** @@ -906,14 +970,20 @@ forward_attached_cb (CamelFolder *folder, GPtrArray *messages, CamelMimePart *pa void em_utils_forward_attached (CamelFolder *folder, GPtrArray *uids, const char *fromuri) { + struct forward_attached_data *fad; + g_return_if_fail (CAMEL_IS_FOLDER (folder)); g_return_if_fail (uids != NULL); - mail_build_attachment (folder, uids, forward_attached_cb, g_strdup(fromuri)); + fad = g_new0 (struct forward_attached_data, 1); + fad->uids = uids; + fad->fromuri = g_strdup (fromuri); + + mail_build_attachment (folder, uids, forward_attached_cb, fad); } static void -forward_non_attached (GPtrArray *messages, int style, const char *fromuri) +forward_non_attached (CamelFolder *folder, GPtrArray *uids, GPtrArray *messages, int style, const char *fromuri) { CamelMimeMessage *message; EMsgComposer *composer; @@ -938,7 +1008,7 @@ forward_non_attached (GPtrArray *messages, int style, const char *fromuri) text = em_utils_message_to_html (message, _("-------- Forwarded Message --------"), flags, &len, NULL); if (text) { - composer = create_new_composer (subject, fromuri); + composer = create_new_composer (subject, fromuri, !uids || !uids->pdata [i]); if (composer) { if (CAMEL_IS_MULTIPART(camel_medium_get_content_object((CamelMedium *)message))) @@ -946,6 +1016,9 @@ forward_non_attached (GPtrArray *messages, int style, const char *fromuri) e_msg_composer_set_body_text (composer, text, len); + if (uids && uids->pdata[i]) + em_composer_utils_setup_callbacks (composer, folder, uids->pdata[i], CAMEL_MESSAGE_FORWARDED, CAMEL_MESSAGE_FORWARDED, NULL, NULL); + editor = GTKHTML_EDITOR (composer); gtkhtml_editor_set_changed (editor, FALSE); gtkhtml_editor_drop_undo (editor); @@ -962,7 +1035,7 @@ forward_non_attached (GPtrArray *messages, int style, const char *fromuri) static void forward_inline (CamelFolder *folder, GPtrArray *uids, GPtrArray *messages, void *user_data) { - forward_non_attached (messages, MAIL_CONFIG_FORWARD_INLINE, (char *)user_data); + forward_non_attached (folder, uids, messages, MAIL_CONFIG_FORWARD_INLINE, (char *)user_data); g_free(user_data); } @@ -986,7 +1059,7 @@ em_utils_forward_inline (CamelFolder *folder, GPtrArray *uids, const char *fromu static void forward_quoted (CamelFolder *folder, GPtrArray *uids, GPtrArray *messages, void *user_data) { - forward_non_attached (messages, MAIL_CONFIG_FORWARD_QUOTED, (char *)user_data); + forward_non_attached (folder, uids, messages, MAIL_CONFIG_FORWARD_QUOTED, (char *)user_data); g_free(user_data); } @@ -1038,15 +1111,15 @@ em_utils_forward_message (CamelMimeMessage *message, const char *fromuri) subject = mail_tool_generate_forward_subject (message); - forward_attached (NULL, messages, part, subject, fromuri); + forward_attached (NULL, NULL, messages, part, subject, fromuri); camel_object_unref (part); g_free (subject); break; case MAIL_CONFIG_FORWARD_INLINE: - forward_non_attached (messages, MAIL_CONFIG_FORWARD_INLINE, fromuri); + forward_non_attached (NULL, NULL, messages, MAIL_CONFIG_FORWARD_INLINE, fromuri); break; case MAIL_CONFIG_FORWARD_QUOTED: - forward_non_attached (messages, MAIL_CONFIG_FORWARD_QUOTED, fromuri); + forward_non_attached (NULL, NULL, messages, MAIL_CONFIG_FORWARD_QUOTED, fromuri); break; } diff --git a/mail/message-list.c b/mail/message-list.c index b23cc1c160..d2cb8000b2 100644 --- a/mail/message-list.c +++ b/mail/message-list.c @@ -223,6 +223,7 @@ static struct { { "mail-unread", NULL }, { "mail-read", NULL }, { "mail-replied", NULL }, + { "mail-forward", NULL }, { "stock_mail-unread-multiple", NULL }, { "stock_mail-open-multiple", NULL }, { NULL, NULL }, @@ -1053,6 +1054,7 @@ static const char *status_map[] = { N_("Unseen"), N_("Seen"), N_("Answered"), + N_("Forwarded"), N_("Multiple Unseen Messages"), N_("Multiple Messages"), }; @@ -1076,7 +1078,7 @@ ml_value_to_string (ETreeModel *etm, int col, const void *value, void *data) switch (col){ case COL_MESSAGE_STATUS: i = GPOINTER_TO_UINT(value); - if (i > 4) + if (i > 5) return g_strdup (""); return g_strdup (_(status_map[i])); @@ -1292,6 +1294,8 @@ ml_tree_value_at (ETreeModel *etm, ETreePath path, int col, void *model_data) flags = camel_message_info_flags(msg_info); if (flags & CAMEL_MESSAGE_ANSWERED) return GINT_TO_POINTER (2); + else if (flags & CAMEL_MESSAGE_FORWARDED) + return GINT_TO_POINTER (3); else if (flags & CAMEL_MESSAGE_SEEN) return GINT_TO_POINTER (1); else @@ -1665,7 +1669,7 @@ static ECell * create_composite_cell (int col) cell_hbox = e_cell_hbox_new (); for (i = 0; i < 2; i++) - images [i] = states_pixmaps [i + 5].pixbuf; + images [i] = states_pixmaps [i + 6].pixbuf; cell_attach = e_cell_toggle_new (0, 2, images); cell_date = e_cell_date_new(NULL, GTK_JUSTIFY_RIGHT); @@ -1719,32 +1723,32 @@ message_list_create_extras (void) extras = e_table_extras_new (); e_table_extras_add_pixbuf (extras, "status", states_pixmaps [0].pixbuf); - e_table_extras_add_pixbuf (extras, "score", states_pixmaps [13].pixbuf); - e_table_extras_add_pixbuf (extras, "attachment", states_pixmaps [6].pixbuf); - e_table_extras_add_pixbuf (extras, "flagged", states_pixmaps [7].pixbuf); - e_table_extras_add_pixbuf (extras, "followup", states_pixmaps [15].pixbuf); + e_table_extras_add_pixbuf (extras, "score", states_pixmaps [14].pixbuf); + e_table_extras_add_pixbuf (extras, "attachment", states_pixmaps [7].pixbuf); + e_table_extras_add_pixbuf (extras, "flagged", states_pixmaps [8].pixbuf); + e_table_extras_add_pixbuf (extras, "followup", states_pixmaps [16].pixbuf); e_table_extras_add_compare (extras, "address_compare", address_compare); - for (i = 0; i < 5; i++) + for (i = 0; i < 6; i++) images [i] = states_pixmaps [i].pixbuf; - e_table_extras_add_cell (extras, "render_message_status", e_cell_toggle_new (0, 5, images)); + e_table_extras_add_cell (extras, "render_message_status", e_cell_toggle_new (0, 6, images)); for (i = 0; i < 2; i++) - images [i] = states_pixmaps [i + 5].pixbuf; + images [i] = states_pixmaps [i + 6].pixbuf; e_table_extras_add_cell (extras, "render_attachment", e_cell_toggle_new (0, 2, images)); - images [1] = states_pixmaps [7].pixbuf; + images [1] = states_pixmaps [8].pixbuf; e_table_extras_add_cell (extras, "render_flagged", e_cell_toggle_new (0, 2, images)); - images[1] = states_pixmaps [15].pixbuf; - images[2] = states_pixmaps [16].pixbuf; + images[1] = states_pixmaps [16].pixbuf; + images[2] = states_pixmaps [17].pixbuf; e_table_extras_add_cell (extras, "render_flag_status", e_cell_toggle_new (0, 3, images)); for (i = 0; i < 7; i++) - images[i] = states_pixmaps [i + 7].pixbuf; + images[i] = states_pixmaps [i + 8].pixbuf; e_table_extras_add_cell (extras, "render_score", e_cell_toggle_new (0, 7, images)); |