Commit 6b46f0e0 authored by Milan Crha's avatar Milan Crha

Bug 241477 - Message color cannot be removed once applied to a message

Closes https://bugzilla.gnome.org/show_bug.cgi?id=241477
parent 2427b2b5
...@@ -76,18 +76,21 @@ ...@@ -76,18 +76,21 @@
<menuitem action='mail-archive'/> <menuitem action='mail-archive'/>
<separator/> <separator/>
<menu action='mail-mark-as-menu'> <menu action='mail-mark-as-menu'>
<menuitem action="mail-mark-read"/> <menuitem action='mail-mark-read'/>
<menuitem action="mail-mark-unread"/> <menuitem action='mail-mark-unread'/>
<separator/> <separator/>
<menuitem action="mail-mark-important"/> <menuitem action='mail-mark-important'/>
<menuitem action="mail-mark-unimportant"/> <menuitem action='mail-mark-unimportant'/>
<separator/> <separator/>
<menuitem action="mail-mark-junk"/> <menuitem action='mail-mark-junk'/>
<menuitem action="mail-mark-notjunk"/> <menuitem action='mail-mark-notjunk'/>
<separator/> <separator/>
<menuitem action="mail-flag-for-followup"/> <menuitem action='mail-flag-for-followup'/>
<menuitem action="mail-flag-clear"/> <menuitem action='mail-flag-clear'/>
<menuitem action="mail-flag-completed"/> <menuitem action='mail-flag-completed'/>
<separator/>
<menuitem action='mail-color-assign'/>
<menuitem action='mail-color-unset'/>
<separator/> <separator/>
<menu action='mail-label-menu'> <menu action='mail-label-menu'>
<menuitem action='mail-label-none'/> <menuitem action='mail-label-none'/>
...@@ -97,10 +100,10 @@ ...@@ -97,10 +100,10 @@
<menuitem action='mail-label-new'/> <menuitem action='mail-label-new'/>
</menu> </menu>
<separator/> <separator/>
<menuitem action="mail-mark-ignore-thread-whole"/> <menuitem action='mail-mark-ignore-thread-whole'/>
<menuitem action="mail-mark-ignore-thread-sub"/> <menuitem action='mail-mark-ignore-thread-sub'/>
<menuitem action="mail-mark-unignore-thread-whole"/> <menuitem action='mail-mark-unignore-thread-whole'/>
<menuitem action="mail-mark-unignore-thread-sub"/> <menuitem action='mail-mark-unignore-thread-sub'/>
</menu> </menu>
<menuitem action='mail-filters-apply'/> <menuitem action='mail-filters-apply'/>
<menuitem action='mail-check-for-junk'/> <menuitem action='mail-check-for-junk'/>
......
...@@ -121,8 +121,11 @@ ...@@ -121,8 +121,11 @@
<menuitem action='mail-popup-mark-junk'/> <menuitem action='mail-popup-mark-junk'/>
<menuitem action='mail-popup-mark-notjunk'/> <menuitem action='mail-popup-mark-notjunk'/>
<menuitem action='mail-popup-flag-for-followup'/> <menuitem action='mail-popup-flag-for-followup'/>
<menuitem action="mail-popup-flag-clear"/> <menuitem action='mail-popup-flag-clear'/>
<menuitem action="mail-popup-flag-completed"/> <menuitem action='mail-popup-flag-completed'/>
<separator/>
<menuitem action='mail-popup-color-assign'/>
<menuitem action='mail-popup-color-unset'/>
<separator/> <separator/>
<menuitem action='mail-popup-add-note'/> <menuitem action='mail-popup-add-note'/>
<menuitem action='mail-popup-edit-note'/> <menuitem action='mail-popup-edit-note'/>
......
...@@ -397,6 +397,78 @@ exit: ...@@ -397,6 +397,78 @@ exit:
g_ptr_array_unref (uids); g_ptr_array_unref (uids);
} }
static void
mail_reader_manage_color_flag_on_selection (EMailReader *reader,
const gchar *color)
{
CamelFolder *folder;
g_return_if_fail (E_IS_MAIL_READER (reader));
folder = e_mail_reader_ref_folder (reader);
if (folder != NULL) {
GPtrArray *uids;
guint ii;
camel_folder_freeze (folder);
uids = e_mail_reader_get_selected_uids_with_collapsed_threads (reader);
for (ii = 0; ii < uids->len; ii++) {
CamelMessageInfo *info;
info = camel_folder_get_message_info (folder, uids->pdata[ii]);
if (info) {
camel_message_info_set_user_tag (info, "color", color);
g_object_unref (info);
}
}
g_ptr_array_unref (uids);
camel_folder_thaw (folder);
g_object_unref (folder);
}
}
static void
action_mail_color_assign_cb (GtkAction *action,
EMailReader *reader)
{
GtkWidget *dialog;
dialog = gtk_color_chooser_dialog_new (NULL, e_mail_reader_get_window (reader));
if (gtk_dialog_run (GTK_DIALOG (dialog)) == GTK_RESPONSE_OK) {
GdkRGBA rgba;
gchar *color;
gtk_color_chooser_get_rgba (GTK_COLOR_CHOOSER (dialog), &rgba);
color = g_strdup_printf ("#%02X%02X%02X",
0xFF & ((gint) (255 * rgba.red)),
0xFF & ((gint) (255 * rgba.green)),
0xFF & ((gint) (255 * rgba.blue)));
if (color) {
mail_reader_manage_color_flag_on_selection (reader, color);
g_free (color);
}
}
gtk_widget_destroy (dialog);
}
static void
action_mail_color_unset_cb (GtkAction *action,
EMailReader *reader)
{
mail_reader_manage_color_flag_on_selection (reader, NULL);
}
static void static void
action_mail_copy_cb (GtkAction *action, action_mail_copy_cb (GtkAction *action,
EMailReader *reader) EMailReader *reader)
...@@ -2182,6 +2254,20 @@ static GtkActionEntry mail_reader_entries[] = { ...@@ -2182,6 +2254,20 @@ static GtkActionEntry mail_reader_entries[] = {
N_("Filter the selected messages for junk status"), N_("Filter the selected messages for junk status"),
G_CALLBACK (action_mail_check_for_junk_cb) }, G_CALLBACK (action_mail_check_for_junk_cb) },
{ "mail-color-assign",
NULL,
N_("Assign C_olor…"),
NULL,
N_("Assign color for the selected messages"),
G_CALLBACK (action_mail_color_assign_cb) },
{ "mail-color-unset",
NULL,
N_("Unse_t Color"),
NULL,
N_("Unset color for the selected messages"),
G_CALLBACK (action_mail_color_unset_cb) },
{ "mail-copy", { "mail-copy",
"mail-copy", "mail-copy",
N_("_Copy to Folder..."), N_("_Copy to Folder..."),
...@@ -2691,6 +2777,14 @@ static EPopupActionEntry mail_reader_popup_entries[] = { ...@@ -2691,6 +2777,14 @@ static EPopupActionEntry mail_reader_popup_entries[] = {
NULL, NULL,
"mail-archive" }, "mail-archive" },
{ "mail-popup-color-assign",
NULL,
"mail-color-assign" },
{ "mail-popup-color-unset",
NULL,
"mail-color-unset" },
{ "mail-popup-copy", { "mail-popup-copy",
NULL, NULL,
"mail-copy" }, "mail-copy" },
...@@ -3802,6 +3896,7 @@ mail_reader_update_actions (EMailReader *reader, ...@@ -3802,6 +3896,7 @@ mail_reader_update_actions (EMailReader *reader,
gboolean selection_has_unimportant_messages; gboolean selection_has_unimportant_messages;
gboolean selection_has_unread_messages; gboolean selection_has_unread_messages;
gboolean selection_has_mail_note; gboolean selection_has_mail_note;
gboolean selection_has_color;
gboolean selection_is_mailing_list; gboolean selection_is_mailing_list;
gboolean single_message_selected; gboolean single_message_selected;
gboolean first_message_selected = FALSE; gboolean first_message_selected = FALSE;
...@@ -3844,6 +3939,8 @@ mail_reader_update_actions (EMailReader *reader, ...@@ -3844,6 +3939,8 @@ mail_reader_update_actions (EMailReader *reader,
(state & E_MAIL_READER_SELECTION_HAS_UNREAD); (state & E_MAIL_READER_SELECTION_HAS_UNREAD);
selection_has_mail_note = selection_has_mail_note =
(state & E_MAIL_READER_SELECTION_HAS_MAIL_NOTE); (state & E_MAIL_READER_SELECTION_HAS_MAIL_NOTE);
selection_has_color =
(state & E_MAIL_READER_SELECTION_HAS_COLOR);
selection_is_mailing_list = selection_is_mailing_list =
(state & E_MAIL_READER_SELECTION_IS_MAILING_LIST); (state & E_MAIL_READER_SELECTION_IS_MAILING_LIST);
...@@ -3889,6 +3986,16 @@ mail_reader_update_actions (EMailReader *reader, ...@@ -3889,6 +3986,16 @@ mail_reader_update_actions (EMailReader *reader,
action = e_mail_reader_get_action (reader, action_name); action = e_mail_reader_get_action (reader, action_name);
gtk_action_set_sensitive (action, sensitive); gtk_action_set_sensitive (action, sensitive);
action_name = "mail-color-assign";
sensitive = any_messages_selected;
action = e_mail_reader_get_action (reader, action_name);
gtk_action_set_sensitive (action, sensitive);
action_name = "mail-color-unset";
sensitive = any_messages_selected && selection_has_color;
action = e_mail_reader_get_action (reader, action_name);
gtk_action_set_sensitive (action, sensitive);
action_name = "mail-copy"; action_name = "mail-copy";
sensitive = any_messages_selected; sensitive = any_messages_selected;
action = e_mail_reader_get_action (reader, action_name); action = e_mail_reader_get_action (reader, action_name);
...@@ -4762,6 +4869,7 @@ e_mail_reader_check_state (EMailReader *reader) ...@@ -4762,6 +4869,7 @@ e_mail_reader_check_state (EMailReader *reader)
gboolean has_unimportant = FALSE; gboolean has_unimportant = FALSE;
gboolean has_unread = FALSE; gboolean has_unread = FALSE;
gboolean has_mail_note = FALSE; gboolean has_mail_note = FALSE;
gboolean has_color = FALSE;
gboolean have_enabled_account = FALSE; gboolean have_enabled_account = FALSE;
gboolean drafts_or_outbox = FALSE; gboolean drafts_or_outbox = FALSE;
gboolean is_mailing_list; gboolean is_mailing_list;
...@@ -4816,9 +4924,6 @@ e_mail_reader_check_state (EMailReader *reader) ...@@ -4816,9 +4924,6 @@ e_mail_reader_check_state (EMailReader *reader)
if (info == NULL) if (info == NULL)
continue; continue;
if (camel_message_info_get_user_flag (info, E_MAIL_NOTES_USER_FLAG))
has_mail_note = TRUE;
flags = camel_message_info_get_flags (info); flags = camel_message_info_get_flags (info);
if (flags & CAMEL_MESSAGE_SEEN) if (flags & CAMEL_MESSAGE_SEEN)
...@@ -4880,10 +4985,10 @@ e_mail_reader_check_state (EMailReader *reader) ...@@ -4880,10 +4985,10 @@ e_mail_reader_check_state (EMailReader *reader)
string = camel_message_info_get_mlist (info); string = camel_message_info_get_mlist (info);
is_mailing_list &= (string != NULL && *string != '\0'); is_mailing_list &= (string != NULL && *string != '\0');
has_ignore_thread = has_ignore_thread || has_ignore_thread = has_ignore_thread || camel_message_info_get_user_flag (info, "ignore-thread");
camel_message_info_get_user_flag (info, "ignore-thread"); has_notignore_thread = has_notignore_thread || !camel_message_info_get_user_flag (info, "ignore-thread");
has_notignore_thread = has_notignore_thread || has_mail_note = has_mail_note || camel_message_info_get_user_flag (info, E_MAIL_NOTES_USER_FLAG);
!camel_message_info_get_user_flag (info, "ignore-thread"); has_color = has_color || camel_message_info_get_user_tag (info, "color") != NULL;
g_clear_object (&info); g_clear_object (&info);
} }
...@@ -4938,6 +5043,8 @@ e_mail_reader_check_state (EMailReader *reader) ...@@ -4938,6 +5043,8 @@ e_mail_reader_check_state (EMailReader *reader)
state |= E_MAIL_READER_FOLDER_ARCHIVE_FOLDER_SET; state |= E_MAIL_READER_FOLDER_ARCHIVE_FOLDER_SET;
if (has_mail_note) if (has_mail_note)
state |= E_MAIL_READER_SELECTION_HAS_MAIL_NOTE; state |= E_MAIL_READER_SELECTION_HAS_MAIL_NOTE;
if (has_color)
state |= E_MAIL_READER_SELECTION_HAS_COLOR;
g_clear_object (&folder); g_clear_object (&folder);
g_ptr_array_unref (uids); g_ptr_array_unref (uids);
......
...@@ -91,7 +91,8 @@ enum { ...@@ -91,7 +91,8 @@ enum {
E_MAIL_READER_FOLDER_ARCHIVE_FOLDER_SET = 1 << 19, E_MAIL_READER_FOLDER_ARCHIVE_FOLDER_SET = 1 << 19,
E_MAIL_READER_SELECTION_HAS_IGNORE_THREAD = 1 << 20, E_MAIL_READER_SELECTION_HAS_IGNORE_THREAD = 1 << 20,
E_MAIL_READER_SELECTION_HAS_NOTIGNORE_THREAD = 1 << 21, E_MAIL_READER_SELECTION_HAS_NOTIGNORE_THREAD = 1 << 21,
E_MAIL_READER_SELECTION_HAS_MAIL_NOTE = 1 << 22 E_MAIL_READER_SELECTION_HAS_MAIL_NOTE = 1 << 22,
E_MAIL_READER_SELECTION_HAS_COLOR = 1 << 23
}; };
struct _EMailReaderInterface { struct _EMailReaderInterface {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment