From d893466560f87581cb14322a39446d14d9c405f3 Mon Sep 17 00:00:00 2001 From: Jeffrey Stedfast Date: Mon, 6 Nov 2000 20:05:25 +0000 Subject: Updated to have the same menu items as the new right-click menu - 2000-11-06 Jeffrey Stedfast * folder-browser-factory.c: Updated to have the same menu items as the new right-click menu - eventually these 2 menus should be the same. * folder-browser.c (on_right_click): Now correctly handles the case of multiple selection. * mail-callbacks.c (enumerate_msg): Make public so it can be used in other source files (it's a useful function!) svn path=/trunk/; revision=6419 --- mail/folder-browser.c | 56 +++++++++++++++++++++++++++++++++++++++------------ 1 file changed, 43 insertions(+), 13 deletions(-) (limited to 'mail/folder-browser.c') diff --git a/mail/folder-browser.c b/mail/folder-browser.c index 7009c32f45..8727591cb6 100644 --- a/mail/folder-browser.c +++ b/mail/folder-browser.c @@ -474,8 +474,9 @@ on_right_click (ETableScrolled *table, gint row, gint col, GdkEvent *event, Fold { extern CamelFolder *drafts_folder; const CamelMessageInfo *info; + GPtrArray *uids; int enable_mask = 0; - int last_item; + int last_item, i; char *mailing_list_name; EPopupMenu menu[] = { { _("Open"), NULL, GTK_SIGNAL_FUNC (view_msg), 0 }, @@ -525,18 +526,42 @@ on_right_click (ETableScrolled *table, gint row, gint col, GdkEvent *event, Fold NULL, NULL); } - /* FIXME: the following 2 should really account for when multiple messages are selected. */ - info = camel_folder_get_message_info (fb->folder, fb->message_list->cursor_uid); - if (info->flags & CAMEL_MESSAGE_SEEN) - enable_mask |= 4; - else - enable_mask |= 8; - - if (info->flags & CAMEL_MESSAGE_DELETED) - enable_mask |= 16; - else - enable_mask |= 32; - + /* get a list of uids */ + uids = g_ptr_array_new (); + message_list_foreach (fb->message_list, enumerate_msg, uids); + if (uids->len >= 1) { + /* gray-out any items we don't need */ + gboolean have_deleted = FALSE; + gboolean have_undeleted = FALSE; + gboolean have_seen = FALSE; + gboolean have_unseen = FALSE; + + for (i = 0; i < uids->len; i++) { + info = camel_folder_get_message_info (fb->folder, uids->pdata[i]); + if (info->flags & CAMEL_MESSAGE_SEEN) + have_seen = TRUE; + else + have_unseen = TRUE; + + if (info->flags & CAMEL_MESSAGE_DELETED) + have_deleted = TRUE; + else + have_undeleted = TRUE; + + if (have_seen && have_unseen && have_deleted && have_undeleted) + break; + } + + if (!have_unseen) + enable_mask |= 4; + if (!have_seen) + enable_mask |= 8; + + if (!have_undeleted) + enable_mask |= 16; + if (!have_deleted) + enable_mask |= 32; + } if (mailing_list_name == NULL) { enable_mask |= 64; @@ -546,6 +571,11 @@ on_right_click (ETableScrolled *table, gint row, gint col, GdkEvent *event, Fold mailing_list_name); } + /* free uids */ + for (i = 0; i < uids->len; i++) + g_free (uids->pdata[i]); + g_ptr_array_free (uids, TRUE); + e_popup_menu_run (menu, (GdkEventButton *)event, enable_mask, 0, fb); g_free (menu[last_item].name); -- cgit