[Evolution-hackers] Re: Evolution Context Menus (status report)



I've been looking at simplifying the Evolution context menus in the mail
component.  My proposals are here:
http://primates.ximian.com/~glesage/wiki/doku.php?id=evolution:menus

I have created a patch which implements most of these proposals (I have
yet to change the context menu when over an email address.)  

I'm looking at the other menus in Evolution -- you can see my proposal
for the Evolution mailer menus at: 
http://primates.ximian.com/~glesage/wiki/doku.php?id=evolution:menus:mailer

Patch for the context menus is attached.
Index: mail/em-folder-view.c
===================================================================
RCS file: /cvs/gnome/evolution/mail/em-folder-view.c,v
retrieving revision 1.97
diff -u -b -r1.97 em-folder-view.c
--- mail/em-folder-view.c	3 Nov 2004 09:47:23 -0000	1.97
+++ mail/em-folder-view.c	17 Dec 2004 19:02:34 -0000
@@ -635,6 +635,25 @@
 }
 
 static void
+emfv_popup_source(EPopup *ep, EPopupItem *pitem, void *data)
+{
+	EMFolderView *emfv = data;
+	EMMessageBrowser *emmb;
+	GPtrArray *uids;
+	
+	uids = message_list_get_selected(emfv->list);
+
+	emmb = (EMMessageBrowser *)em_message_browser_window_new();
+	em_format_set_session((EMFormat *)((EMFolderView *)emmb)->preview, ((EMFormat *)emfv->preview)->session);
+	em_folder_view_set_folder((EMFolderView *)emmb, emfv->folder, emfv->folder_uri);
+	em_format_set_mode((EMFormat *)((EMFolderView *)emmb)->preview, EM_FORMAT_SOURCE);
+	em_folder_view_set_message((EMFolderView *)emmb, uids->pdata[0], FALSE);
+	gtk_widget_show(emmb->window);
+
+	message_list_free_uids(emfv->list, uids);
+}
+
+static void
 emfv_popup_reply_sender(EPopup *ep, EPopupItem *pitem, void *data)
 {
 	EMFolderView *emfv = data;
@@ -923,50 +942,43 @@
 
 /* TODO: Move some of these to be 'standard' menu's */
 
-static EPopupItem emfv_popup_items[] = {
-	{ E_POPUP_ITEM, "00.emfv.00", N_("_Open"), emfv_popup_open, NULL, NULL, 0 },
-	{ E_POPUP_ITEM, "00.emfv.01", N_("_Edit as New Message..."), emfv_popup_edit, NULL, NULL, EM_POPUP_SELECT_EDIT },
-	{ E_POPUP_ITEM, "00.emfv.02", N_("_Save As..."), emfv_popup_saveas, NULL, "stock_save-as", 0 },
-	{ E_POPUP_ITEM, "00.emfv.03", N_("_Print"), emfv_popup_print, NULL, "stock_print", 0 },
+static EPopupItem emfv_popup_message_items[] = {
+	{ E_POPUP_ITEM, "00.emfv.00", N_("Reply"), emfv_popup_reply_all, NULL, "stock_mail-reply-to-all", EM_POPUP_SELECT_ONE },
+	{ E_POPUP_ITEM, "00.emfv.01", N_("_Reply to Sender"), emfv_popup_reply_sender, NULL, "stock_mail-reply", EM_POPUP_SELECT_ONE },
+	{ E_POPUP_ITEM, "00.emfv.02", N_("_Forward"), emfv_popup_forward, NULL, "stock_mail-forward", EM_POPUP_SELECT_MANY },
 
 	{ E_POPUP_BAR, "10.emfv" },
-	{ E_POPUP_ITEM, "10.emfv.00", N_("_Reply to Sender"), emfv_popup_reply_sender, NULL, "stock_mail-reply", EM_POPUP_SELECT_ONE },
-	{ E_POPUP_ITEM, "10.emfv.01", N_("Reply to _List"), emfv_popup_reply_list, NULL, NULL, EM_POPUP_SELECT_ONE|EM_POPUP_SELECT_MAILING_LIST },
-	{ E_POPUP_ITEM, "10.emfv.02", N_("Reply to _All"), emfv_popup_reply_all, NULL, "stock_mail-reply-to-all", EM_POPUP_SELECT_ONE },
-	{ E_POPUP_ITEM, "10.emfv.03", N_("_Forward"), emfv_popup_forward, NULL, "stock_mail-forward", EM_POPUP_SELECT_MANY },
-
-	{ E_POPUP_BAR, "20.emfv", NULL, NULL, NULL, NULL, EM_POPUP_SELECT_FLAG_FOLLOWUP|EM_POPUP_SELECT_FLAG_COMPLETED|EM_POPUP_SELECT_FLAG_CLEAR },
-	{ E_POPUP_ITEM, "20.emfv.00", N_("Follo_w Up..."), emfv_popup_flag_followup, NULL, "stock_mail-flag-for-followup",  EM_POPUP_SELECT_FLAG_FOLLOWUP },
-	{ E_POPUP_ITEM, "20.emfv.01", N_("Fla_g Completed"), emfv_popup_flag_completed, NULL, NULL, EM_POPUP_SELECT_FLAG_COMPLETED },
-	{ E_POPUP_ITEM, "20.emfv.02", N_("Cl_ear Flag"), emfv_popup_flag_clear, NULL, NULL, EM_POPUP_SELECT_FLAG_CLEAR },
-	
-	{ E_POPUP_BAR, "30.emfv" },
-	{ E_POPUP_ITEM, "30.emfv.00", N_("Mar_k as Read"), emfv_popup_mark_read, NULL, "stock_mail-open", EM_POPUP_SELECT_MARK_READ },
-	{ E_POPUP_ITEM,  "30.emfv.01", N_("Mark as _Unread"), emfv_popup_mark_unread, NULL, "stock_mail-unread", EM_POPUP_SELECT_MARK_UNREAD },
-	{ E_POPUP_ITEM, "30.emfv.02", N_("Mark as _Important"), emfv_popup_mark_important, NULL, "stock_mail-priority-high", EM_POPUP_SELECT_MARK_IMPORTANT },
-	{ E_POPUP_ITEM, "30.emfv.03", N_("_Mark as Unimportant"), emfv_popup_mark_unimportant, NULL, NULL, EM_POPUP_SELECT_MARK_UNIMPORTANT },
-	{ E_POPUP_ITEM, "30.emfv.04", N_("Mark as _Junk"), emfv_popup_mark_junk, NULL, "stock_spam", EM_POPUP_SELECT_MARK_JUNK },
-	{ E_POPUP_ITEM, "30.emfv.05", N_("Mark as _Not Junk"), emfv_popup_mark_nojunk, NULL, "stock_not-spam", EM_POPUP_SELECT_MARK_NOJUNK },
+	{ E_POPUP_ITEM, "10.emfv.00", N_("_Save As..."), emfv_popup_saveas, NULL, "stock_save-as", 0 },
+	{ E_POPUP_ITEM, "10.emfv.01", N_("_Print"), emfv_popup_print, NULL, "stock_print", 0 },
+
+	{ E_POPUP_BAR, "20.emfv" },
+	{ E_POPUP_ITEM, "20.emfv.00", N_("_Show Email Source"), emfv_popup_source, NULL, NULL, 0 },
+};
+
+static EPopupItem emfv_popup_items[] = {
+	{ E_POPUP_ITEM, "10.emfv.00", N_("Reply"), emfv_popup_reply_all, NULL, "stock_mail-reply-to-all", EM_POPUP_SELECT_ONE },
+	{ E_POPUP_ITEM, "10.emfv.01", N_("_Reply to Sender"), emfv_popup_reply_sender, NULL, "stock_mail-reply", EM_POPUP_SELECT_ONE },
+	{ E_POPUP_ITEM, "10.emfv.02", N_("_Forward"), emfv_popup_forward, NULL, "stock_mail-forward", EM_POPUP_SELECT_MANY },
+
+	{ E_POPUP_BAR, "20.emfv" },
+	{ E_POPUP_ITEM, "20.emfv.00", N_("_Edit as New Message..."), emfv_popup_edit, NULL, NULL, EM_POPUP_SELECT_EDIT },
+	{ E_POPUP_ITEM, "20.emfv.01", N_("_Save As..."), emfv_popup_saveas, NULL, "stock_save-as", 0 },
+	{ E_POPUP_ITEM, "20.emfv.02", N_("_Print"), emfv_popup_print, NULL, "stock_print", 0 },
 	
 	{ E_POPUP_BAR, "40.emfv" },
 	{ E_POPUP_ITEM, "40.emfv.00", N_("_Delete"), emfv_popup_delete, NULL, "stock_delete", EM_POPUP_SELECT_DELETE },
-	{ E_POPUP_ITEM, "40.emfv.01", N_("U_ndelete"), emfv_popup_undelete, NULL, "stock_undelete", EM_POPUP_SELECT_UNDELETE },
+	{ E_POPUP_ITEM, "40.emfv.01", N_("Mo_ve to Folder..."), emfv_popup_move },
+	{ E_POPUP_ITEM, "40.emfv.02", N_("_Copy to Folder..."), emfv_popup_copy },
 
 	{ E_POPUP_BAR, "50.emfv" },
-	{ E_POPUP_ITEM, "50.emfv.00", N_("Mo_ve to Folder..."), emfv_popup_move },
-	{ E_POPUP_ITEM, "50.emfv.01", N_("_Copy to Folder..."), emfv_popup_copy },
-
-	{ E_POPUP_BAR, "60.label" },
-	{ E_POPUP_SUBMENU, "60.label.00", N_("Label") },
-	{ E_POPUP_IMAGE, "60.label.00/00.label", N_("None"), emfv_popup_label_clear },
-	{ E_POPUP_BAR, "60.label.00/00.label.00" },
-
-	{ E_POPUP_BAR, "70.emfv", NULL, NULL, NULL, NULL, EM_POPUP_SELECT_ADD_SENDER },
-	{ E_POPUP_ITEM, "70.emfv.00", N_("Add Sender to Address_book"), emfv_popup_add_sender, NULL, NULL, EM_POPUP_SELECT_ADD_SENDER },
-
-	{ E_POPUP_BAR, "80.emfv" },	
-	{ E_POPUP_ITEM, "80.emfv.00", N_("Appl_y Filters"), emfv_popup_apply_filters, NULL, "stock_mail-filters-apply" },
-	{ E_POPUP_ITEM, "80.emfv.01", N_("F_ilter Junk"), emfv_popup_filter_junk, NULL, "stock_spam" },
+	{ E_POPUP_ITEM, "50.emfv.02", N_("Mark as _Important"), emfv_popup_mark_important, NULL, "stock_mail-priority-high", EM_POPUP_SELECT_MARK_IMPORTANT },
+	{ E_POPUP_ITEM, "50.emfv.03", N_("_Mark as Unimportant"), emfv_popup_mark_unimportant, NULL, NULL, EM_POPUP_SELECT_MARK_UNIMPORTANT },
+	{ E_POPUP_ITEM, "50.emfv.01", N_("Mark as _Junk"), emfv_popup_mark_junk, NULL, "stock_spam", EM_POPUP_SELECT_MARK_JUNK },
+	{ E_POPUP_ITEM, "50.emfv.02", N_("Mark as _Not Junk"), emfv_popup_mark_nojunk, NULL, "stock_not-spam", EM_POPUP_SELECT_MARK_NOJUNK },
+
+	{ E_POPUP_SUBMENU, "60.label.03", N_("Label") },
+	{ E_POPUP_IMAGE, "60.label.03/00.label", N_("None"), emfv_popup_label_clear },
+	{ E_POPUP_BAR, "60.label.03/00.label.00" },
 
 	{ E_POPUP_BAR, "90.filter", NULL, NULL, NULL, NULL, EM_POPUP_SELECT_ONE },
 	{ E_POPUP_SUBMENU, "90.filter.00", N_("Crea_te Rule From Message"), NULL, NULL, NULL, EM_POPUP_SELECT_ONE },
@@ -982,6 +994,7 @@
 	{ E_POPUP_ITEM, "90.filter.00/10.02", N_("Filter on Re_cipients"), emfv_popup_filter_recipients,  NULL, NULL, EM_POPUP_SELECT_ONE },
 	{ E_POPUP_ITEM, "90.filter.00/10.03", N_("Filter on _Mailing List"),
 	  emfv_popup_filter_mlist, NULL, NULL, EM_POPUP_SELECT_ONE|EM_POPUP_SELECT_MAILING_LIST },
+
 };
 
 static void
@@ -1006,6 +1019,40 @@
 }
        
 static void
+emfv_popup_message(EMFolderView *emfv, GdkEvent *event)
+{
+	GSList *menus = NULL, *l, *label_list = NULL;
+	GtkMenu *menu;
+	EMPopup *emp;
+	EMPopupTargetSelect *target;
+	int i;
+
+	/** @HookPoint-EMPopup: Message List Context Menu
+	 * @Id: org.gnome.evolution.mail.folderview.popup.select
+	 * @Type: EMPopup
+	 * @Target: EMPopupTargetSelect
+	 *
+	 * This is the context menu shown on the message list or over a message.
+	 */
+	emp = em_popup_new("org.gnome.evolution.mail.folderview.popup");
+	target = em_folder_view_get_popup_target(emfv, emp);
+
+	for (i=0;i<sizeof(emfv_popup_message_items)/sizeof(emfv_popup_message_items[0]);i++)
+		menus = g_slist_prepend(menus, &emfv_popup_message_items[i]);
+
+	e_popup_add_items((EPopup *)emp, menus, emfv_popup_items_free, emfv);
+
+	menu = e_popup_create_menu_once((EPopup *)emp, (EPopupTarget *)target, 0);
+
+	if (event == NULL || event->type == GDK_KEY_PRESS) {
+		/* FIXME: menu pos function */
+		gtk_menu_popup(menu, NULL, NULL, NULL, NULL, 0, event ? event->key.time : gtk_get_current_event_time());
+	} else {
+		gtk_menu_popup(menu, NULL, NULL, NULL, NULL, event->button.button, event->button.time);
+	}
+}
+       
+static void
 emfv_popup(EMFolderView *emfv, GdkEvent *event)
 {
 	GSList *menus = NULL, *l, *label_list = NULL;
@@ -1039,7 +1086,7 @@
 		
 		item = g_malloc0(sizeof(*item));
 		item->type = E_POPUP_IMAGE;
-		item->path = g_strdup_printf("60.label.00/00.label.%02d", i++);
+		item->path = g_strdup_printf("60.label.03/00.label.%02d", i++);
 		item->label = label->name;
 		item->activate = emfv_popup_label_set;
 		item->user_data = label->tag;
@@ -2205,9 +2252,13 @@
 		/* So we don't try and popup with nothing selected - rather odd result! */
 		GPtrArray *uids = message_list_get_selected(emfv->list);
 		int doit = uids->len > 0;
+		int message_menu = uids->len == 1;
 
 		message_list_free_uids(emfv->list, uids);
 		if (doit)
+			if (message_menu)
+				emfv_popup_message(emfv, (GdkEvent *)event);
+		        else
 			emfv_popup(emfv, (GdkEvent *)event);
 		return doit;
 	}


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]