Re: [evolution-patches] Mailer Context Menus Patch



Here is a new patch that moves everything to a single menu and uses
flags. I had to patch e-popup.c to get this to work properly, since
it was wanting to always create separators in the submenus for some
reason.

-- dobey


On Fri, 2005-01-28 at 11:10 +0800, Not Zed wrote:
> 
> Instead of using separate arguments for boolean variables to the popup
> function, you should add new flags to em-popup, and control it that
> way.  You shouldn't need to create three separate popup lists at all,
> it can all be controlled via the flags on the one list, and that gives
> the same capabilities to all plugins, otherwise they will not have
> access to these differentiators - particularly since the menu is given
> the same id in all cases.
> 

? mail/evolution-mail-2.0.schemas
? mail/default/zh_CN/Makefile
? mail/default/zh_CN/Makefile.in
Index: e-util/e-popup.c
===================================================================
RCS file: /cvs/gnome/evolution/e-util/e-popup.c,v
retrieving revision 1.7
diff -u -p -r1.7 e-popup.c
--- e-util/e-popup.c	22 Dec 2004 07:36:46 -0000	1.7
+++ e-util/e-popup.c	28 Jan 2005 20:19:34 -0000
@@ -362,13 +362,8 @@ e_popup_create_menu(EPopup *emp, EPopupT
 		char *tmp;
 
 		/* for bar's, the mask is exclusive or */
-		if (item->visible) {
-			if ((item->type & E_POPUP_TYPE_MASK) == E_POPUP_BAR) {
-				if ((item->visible & mask) == item->visible)
-					continue;
-			} else if (item->visible & mask)
-				continue;
-		}
+		if (item->visible & mask)
+			continue;
 
 		g_string_truncate(ppath, 0);
 		tmp = strrchr(item->path, '/');
Index: mail/em-folder-view.c
===================================================================
RCS file: /cvs/gnome/evolution/mail/em-folder-view.c,v
retrieving revision 1.102
diff -u -p -r1.102 em-folder-view.c
--- mail/em-folder-view.c	24 Jan 2005 14:46:24 -0000	1.102
+++ mail/em-folder-view.c	28 Jan 2005 20:19:35 -0000
@@ -86,6 +86,7 @@
 #include <gtkhtml/htmlengine.h>
 #include <gtkhtml/htmlengine-save.h>
 #include <gtkhtml/htmlengine-edit-cut-and-paste.h>
+#include <gtkhtml/htmlselection.h>
 
 #include "mail-mt.h"
 #include "mail-ops.h"
@@ -647,6 +648,13 @@ emfv_popup_print(EPopup *ep, EPopupItem 
 }
 
 static void
+emfv_popup_copy_text(EPopup *ep, EPopupItem *pitem, void *data)
+{
+	EMFolderView *emfv = data;
+	html_engine_copy (((EMFormatHTML *)emfv->preview)->html->engine);
+}
+
+static void
 emfv_popup_reply_sender(EPopup *ep, EPopupItem *pitem, void *data)
 {
 	EMFolderView *emfv = data;
@@ -927,65 +935,59 @@ EMFV_POPUP_AUTO_TYPE(filter_type_current
 
 /* 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 },
-
-	{ 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_MANY },
-	{ E_POPUP_ITEM, "30.emfv.05", N_("Mark as _Not Junk"), emfv_popup_mark_nojunk, NULL, "stock_not-spam", EM_POPUP_SELECT_MANY },
-	
-	{ 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_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_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 },
-	{ E_POPUP_ITEM, "90.filter.00/00.00", N_("VFolder on _Subject"), emfv_popup_vfolder_subject, NULL, NULL, EM_POPUP_SELECT_ONE },
-	{ E_POPUP_ITEM, "90.filter.00/00.01", N_("VFolder on Se_nder"), emfv_popup_vfolder_sender, NULL, NULL, EM_POPUP_SELECT_ONE },
-	{ E_POPUP_ITEM, "90.filter.00/00.02", N_("VFolder on _Recipients"), emfv_popup_vfolder_recipients, NULL, NULL, EM_POPUP_SELECT_ONE },
-	{ E_POPUP_ITEM, "90.filter.00/00.03", N_("VFolder on Mailing _List"),
-	  emfv_popup_vfolder_mlist, NULL, NULL, EM_POPUP_SELECT_ONE|EM_POPUP_SELECT_MAILING_LIST },
-	
-	{ E_POPUP_BAR, "90.filter.00/10", NULL, NULL, NULL, NULL, EM_POPUP_SELECT_ONE },
-	{ E_POPUP_ITEM, "90.filter.00/10.00", N_("Filter on Sub_ject"), emfv_popup_filter_subject, NULL, NULL, EM_POPUP_SELECT_ONE },
-	{ E_POPUP_ITEM, "90.filter.00/10.01", N_("Filter on Sen_der"), emfv_popup_filter_sender, NULL, NULL, EM_POPUP_SELECT_ONE },
-	{ E_POPUP_ITEM, "90.filter.00/10.02", N_("Filter on Re_cipients"), emfv_popup_filter_recipients,  NULL, NULL, EM_POPUP_SELECT_ONE },
+static EPopupItem emfv_popup_list_items[] = {
+	{ E_POPUP_ITEM, "00.emfv.00", N_("_Copy"), emfv_popup_copy_text, NULL, "stock_copy", EM_FOLDER_VIEW_SELECT_SELECTION },
+
+	{ E_POPUP_BAR, "10.emfv", NULL, NULL, NULL, NULL, EM_FOLDER_VIEW_SELECT_SELECTION },
+	{ E_POPUP_ITEM, "10.emfv.00", N_("Quoted Reply to _All"), emfv_popup_reply_all, NULL, "stock_mail-reply-to-all", EM_POPUP_SELECT_ONE|EM_FOLDER_VIEW_SELECT_SELECTION },
+	{ E_POPUP_ITEM, "10.emfv.01", N_("Quoted _Reply to Sender"), emfv_popup_reply_sender, NULL, "stock_mail-reply", EM_POPUP_SELECT_ONE|EM_FOLDER_VIEW_SELECT_SELECTION },
+	{ E_POPUP_ITEM, "10.emfv.02", N_("Quoted _Forward"), emfv_popup_forward, NULL, "stock_mail-forward", EM_POPUP_SELECT_ONE|EM_FOLDER_VIEW_SELECT_SELECTION },
+
+	{E_POPUP_ITEM, "10.emfv.00", N_("Reply to _All"), emfv_popup_reply_all, NULL, "stock_mail-reply-to-all", EM_POPUP_SELECT_ONE|EM_FOLDER_VIEW_SELECT_NOSELECTION },
+	{ E_POPUP_ITEM, "10.emfv.01", N_("_Reply to Sender"), emfv_popup_reply_sender, NULL, "stock_mail-reply", EM_POPUP_SELECT_ONE|EM_FOLDER_VIEW_SELECT_NOSELECTION },
+	{ E_POPUP_ITEM, "10.emfv.02", N_("_Forward"), emfv_popup_forward, NULL, "stock_mail-forward", EM_POPUP_SELECT_MANY|EM_FOLDER_VIEW_SELECT_NOSELECTION },
+
+	{ E_POPUP_BAR, "20.emfv", NULL, NULL, NULL, NULL, EM_POPUP_SELECT_ONE },
+	{ 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", EM_POPUP_SELECT_MANY },
+	{ E_POPUP_ITEM, "20.emfv.02", N_("_Print"), emfv_popup_print, NULL, "stock_print", EM_POPUP_SELECT_ONE },
+
+	{ E_POPUP_BAR, "40.emfv", NULL, NULL, NULL, NULL, EM_FOLDER_VIEW_SELECT_LISTONLY },
+	{ E_POPUP_ITEM, "40.emfv.00", N_("_Delete"), emfv_popup_delete, NULL, "stock_delete", EM_POPUP_SELECT_DELETE|EM_FOLDER_VIEW_SELECT_LISTONLY },
+	{ E_POPUP_ITEM, "40.emfv.01", N_("U_ndelete"), emfv_popup_undelete, NULL, "stock_undelete", EM_POPUP_SELECT_UNDELETE|EM_FOLDER_VIEW_SELECT_LISTONLY },
+	{ E_POPUP_ITEM, "40.emfv.02", N_("Mo_ve to Folder..."), emfv_popup_move, NULL, "stock_mail-move", EM_POPUP_SELECT_MANY|EM_FOLDER_VIEW_SELECT_LISTONLY },
+	{ E_POPUP_ITEM, "40.emfv.03", N_("_Copy to Folder..."), emfv_popup_copy, NULL, "stock_mail-copy", EM_POPUP_SELECT_MANY|EM_FOLDER_VIEW_SELECT_LISTONLY },
+
+	{ E_POPUP_BAR, "50.emfv", NULL, NULL, NULL, NULL, EM_FOLDER_VIEW_SELECT_LISTONLY },
+	{ E_POPUP_ITEM, "50.emfv.02", N_("Mark as _Important"), emfv_popup_mark_important, NULL, "stock_mail-priority-high", EM_POPUP_SELECT_MARK_IMPORTANT|EM_FOLDER_VIEW_SELECT_LISTONLY },
+	{ E_POPUP_ITEM, "50.emfv.03", N_("_Mark as Unimportant"), emfv_popup_mark_unimportant, NULL, NULL, EM_POPUP_SELECT_MARK_UNIMPORTANT|EM_FOLDER_VIEW_SELECT_LISTONLY },
+	{ E_POPUP_ITEM, "50.emfv.01", N_("Mark as _Junk"), emfv_popup_mark_junk, NULL, "stock_spam", EM_POPUP_SELECT_MANY|EM_FOLDER_VIEW_SELECT_LISTONLY },
+	{ E_POPUP_ITEM, "50.emfv.02", N_("Mark as _Not Junk"), emfv_popup_mark_nojunk, NULL, "stock_not-spam", EM_POPUP_SELECT_MANY|EM_FOLDER_VIEW_SELECT_LISTONLY },
+	{ E_POPUP_ITEM, "50.emfv.05", N_("Mark for Follo_w Up..."), emfv_popup_flag_followup, NULL, "stock_mail-flag-for-followup",  EM_POPUP_SELECT_FLAG_FOLLOWUP|EM_FOLDER_VIEW_SELECT_LISTONLY },
+
+	{ E_POPUP_SUBMENU, "60.label.00", N_("Label"), NULL, NULL, NULL, EM_POPUP_SELECT_MANY|EM_FOLDER_VIEW_SELECT_LISTONLY },
+	{ E_POPUP_ITEM, "60.label.00/00.label", N_("None"), emfv_popup_label_clear, NULL, NULL, EM_POPUP_SELECT_MANY|EM_FOLDER_VIEW_SELECT_LISTONLY },
+	{ E_POPUP_BAR, "60.label.00/00.label.00", NULL, NULL, NULL, NULL, EM_POPUP_SELECT_MANY|EM_FOLDER_VIEW_SELECT_LISTONLY },
+
+	{ E_POPUP_BAR, "70.emfv.06", NULL, NULL, NULL, NULL, EM_POPUP_SELECT_FLAG_COMPLETED|EM_POPUP_SELECT_FLAG_CLEAR|EM_FOLDER_VIEW_SELECT_LISTONLY },
+
+	{ E_POPUP_ITEM, "70.emfv.07", N_("Fla_g Completed"), emfv_popup_flag_completed, NULL, "stock_mail-flag-for-followup-done", EM_POPUP_SELECT_FLAG_COMPLETED|EM_FOLDER_VIEW_SELECT_LISTONLY },
+	{ E_POPUP_ITEM, "70.emfv.08", N_("Cl_ear Flag"), emfv_popup_flag_clear, NULL, NULL, EM_POPUP_SELECT_FLAG_CLEAR|EM_FOLDER_VIEW_SELECT_LISTONLY },
+ 
+	{ E_POPUP_BAR, "90.filter", NULL, NULL, NULL, NULL, EM_POPUP_SELECT_ONE|EM_FOLDER_VIEW_SELECT_LISTONLY },
+	{ E_POPUP_SUBMENU, "90.filter.00", N_("Crea_te Rule From Message"), NULL, NULL, NULL, EM_POPUP_SELECT_ONE|EM_FOLDER_VIEW_SELECT_LISTONLY },
+	{ E_POPUP_ITEM, "90.filter.00/00.00", N_("vFolder on _Subject"), emfv_popup_vfolder_subject, NULL, NULL, EM_POPUP_SELECT_ONE|EM_FOLDER_VIEW_SELECT_LISTONLY },
+	{ E_POPUP_ITEM, "90.filter.00/00.01", N_("vFolder on Se_nder"), emfv_popup_vfolder_sender, NULL, NULL, EM_POPUP_SELECT_ONE|EM_FOLDER_VIEW_SELECT_LISTONLY },
+	{ E_POPUP_ITEM, "90.filter.00/00.02", N_("vFolder on _Recipients"), emfv_popup_vfolder_recipients, NULL, NULL, EM_POPUP_SELECT_ONE|EM_FOLDER_VIEW_SELECT_LISTONLY },
+	{ E_POPUP_ITEM, "90.filter.00/00.03", N_("vFolder on Mailing _List"),
+	  emfv_popup_vfolder_mlist, NULL, NULL, EM_POPUP_SELECT_ONE|EM_POPUP_SELECT_MAILING_LIST|EM_FOLDER_VIEW_SELECT_LISTONLY },
+	
+	{ E_POPUP_BAR, "90.filter.00/10", NULL, NULL, NULL, NULL, EM_POPUP_SELECT_ONE|EM_FOLDER_VIEW_SELECT_LISTONLY },
+	{ E_POPUP_ITEM, "90.filter.00/10.00", N_("Filter on Sub_ject"), emfv_popup_filter_subject, NULL, NULL, EM_POPUP_SELECT_ONE|EM_FOLDER_VIEW_SELECT_LISTONLY },
+	{ E_POPUP_ITEM, "90.filter.00/10.01", N_("Filter on Sen_der"), emfv_popup_filter_sender, NULL, NULL, EM_POPUP_SELECT_ONE|EM_FOLDER_VIEW_SELECT_LISTONLY },
+	{ E_POPUP_ITEM, "90.filter.00/10.02", N_("Filter on Re_cipients"), emfv_popup_filter_recipients,  NULL, NULL, EM_POPUP_SELECT_ONE|EM_FOLDER_VIEW_SELECT_LISTONLY },
 	{ 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 },
+	  emfv_popup_filter_mlist, NULL, NULL, EM_POPUP_SELECT_ONE|EM_POPUP_SELECT_MAILING_LIST|EM_FOLDER_VIEW_SELECT_LISTONLY },
 };
 
 static void
@@ -1010,7 +1012,7 @@ emfv_popup_items_free(EPopup *ep, GSList
 }
        
 static void
-emfv_popup(EMFolderView *emfv, GdkEvent *event)
+emfv_popup(EMFolderView *emfv, GdkEvent *event, int on_display)
 {
 	GSList *menus = NULL, *l, *label_list = NULL;
 	GtkMenu *menu;
@@ -1026,44 +1028,46 @@ emfv_popup(EMFolderView *emfv, GdkEvent 
 	 * 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);
+	target = em_folder_view_get_popup_target(emfv, emp, on_display);
 
-	for (i=0;i<sizeof(emfv_popup_items)/sizeof(emfv_popup_items[0]);i++)
-		menus = g_slist_prepend(menus, &emfv_popup_items[i]);
+	for (i=0;i<sizeof(emfv_popup_list_items)/sizeof(emfv_popup_list_items[0]);i++)
+		menus = g_slist_prepend(menus, &emfv_popup_list_items[i]);
 
 	e_popup_add_items((EPopup *)emp, menus, NULL, emfv_popup_items_free, emfv);
 
-	i = 1;
-	for (l = mail_config_get_labels(); l; l = l->next) {
-		EPopupItem *item;
-		MailConfigLabel *label = l->data;
-		GdkPixmap *pixmap;
-		GdkColor colour;
-		GdkGC *gc;
+	if (!on_display) {
+		i = 1;
+		for (l = mail_config_get_labels(); l; l = l->next) {
+			EPopupItem *item;
+			MailConfigLabel *label = l->data;
+			GdkPixmap *pixmap;
+			GdkColor colour;
+			GdkGC *gc;
 		
-		item = g_malloc0(sizeof(*item));
-		item->type = E_POPUP_IMAGE;
-		item->path = g_strdup_printf("60.label.00/00.label.%02d", i++);
-		item->label = label->name;
-		item->activate = emfv_popup_label_set;
-		item->user_data = label->tag;
+			item = g_malloc0(sizeof(*item));
+			item->type = E_POPUP_IMAGE;
+			item->path = g_strdup_printf("60.label.00/00.label.%02d", i++);
+			item->label = label->name;
+			item->activate = emfv_popup_label_set;
+			item->user_data = label->tag;
 
-		gdk_color_parse(label->colour, &colour);
-		gdk_color_alloc(gdk_colormap_get_system(), &colour);
+			gdk_color_parse(label->colour, &colour);
+			gdk_color_alloc(gdk_colormap_get_system(), &colour);
 		
-		pixmap = gdk_pixmap_new(((GtkWidget *)emfv)->window, 16, 16, -1);
-		gc = gdk_gc_new(((GtkWidget *)emfv)->window);
-		gdk_gc_set_foreground(gc, &colour);
-		gdk_draw_rectangle(pixmap, gc, TRUE, 0, 0, 16, 16);
-		gdk_gc_unref(gc);
+			pixmap = gdk_pixmap_new(((GtkWidget *)emfv)->window, 16, 16, -1);
+			gc = gdk_gc_new(((GtkWidget *)emfv)->window);
+			gdk_gc_set_foreground(gc, &colour);
+			gdk_draw_rectangle(pixmap, gc, TRUE, 0, 0, 16, 16);
+			gdk_gc_unref(gc);
 
-		item->image = gtk_image_new_from_pixmap(pixmap, NULL);
-		gtk_widget_show(item->image);
+			item->image = gtk_image_new_from_pixmap(pixmap, NULL);
+			gtk_widget_show(item->image);
 
-		label_list = g_slist_prepend(label_list, item);
-	}
+			label_list = g_slist_prepend(label_list, item);
+		}
 
-	e_popup_add_items((EPopup *)emp, label_list, NULL, emfv_popup_labels_free, emfv);
+		e_popup_add_items((EPopup *)emp, label_list, NULL, emfv_popup_labels_free, emfv);
+	}
 
 	menu = e_popup_create_menu_once((EPopup *)emp, (EPopupTarget *)target, 0);
 
@@ -1433,6 +1437,56 @@ vfolder_type_got_message (CamelFolder *f
 }
 
 static void
+emp_uri_popup_vfolder_sender(EPopup *ep, EPopupItem *pitem, void *data)
+{
+	EMFolderView *emfv = data;
+	EMPopupTargetURI *t = (EMPopupTargetURI *)ep->target;
+	CamelURL *url;	
+	CamelInternetAddress *addr;
+	
+	url = camel_url_new(t->uri, NULL);
+	if (url == NULL) {
+		g_warning("cannot parse url '%s'", t->uri);
+		return;
+	}
+
+	if (url->path && url->path[0]) {
+		addr = camel_internet_address_new ();
+		camel_address_decode (CAMEL_ADDRESS (addr), url->path);
+		vfolder_gui_add_from_address (addr, AUTO_FROM, emfv->folder_uri);
+		camel_object_unref (addr);
+	}
+	
+	camel_url_free(url);	
+	
+}
+
+
+static void
+emp_uri_popup_vfolder_recipient(EPopup *ep, EPopupItem *pitem, void *data)
+{
+	EMFolderView *emfv = data;
+	EMPopupTargetURI *t = (EMPopupTargetURI *)ep->target;
+	CamelURL *url;	
+	CamelInternetAddress *addr;
+	
+	url = camel_url_new(t->uri, NULL);
+	if (url == NULL) {
+		g_warning("cannot parse url '%s'", t->uri);
+		return;
+	}
+
+	if (url->path && url->path[0]) {
+		addr = camel_internet_address_new ();
+		camel_address_decode (CAMEL_ADDRESS (addr), url->path);
+		vfolder_gui_add_from_address (addr, AUTO_TO, emfv->folder_uri);
+		camel_object_unref (addr);
+	}
+
+	camel_url_free(url);	
+}
+
+static void
 vfolder_type_uid (CamelFolder *folder, const char *uid, const char *uri, int type)
 {
 	struct _filter_data *data;
@@ -1677,7 +1731,7 @@ emfv_enable_menus(EMFolderView *emfv)
 		EMPopup *emp = em_popup_new("dummy");
 		EMPopupTargetSelect *t;
 
-		t = em_folder_view_get_popup_target(emfv, emp);
+		t = em_folder_view_get_popup_target(emfv, emp, FALSE);
 		disable_mask = t->target.mask;
 		e_popup_target_free((EPopup *)emp, t);
 		g_object_unref(emp);
@@ -1912,7 +1966,7 @@ int em_folder_view_print(EMFolderView *e
 }
 
 EMPopupTargetSelect *
-em_folder_view_get_popup_target(EMFolderView *emfv, EMPopup *emp)
+em_folder_view_get_popup_target(EMFolderView *emfv, EMPopup *emp, int on_display)
 {
 	EMPopupTargetSelect *t;
 
@@ -1931,6 +1985,14 @@ em_folder_view_get_popup_target(EMFolder
 	if (message_list_can_select(emfv->list, MESSAGE_LIST_SELECT_PREVIOUS, 0, 0))
 		t->target.mask &= ~EM_FOLDER_VIEW_SELECT_PREV_MSG;
 
+	if (!on_display)
+		t->target.mask &= ~EM_FOLDER_VIEW_SELECT_LISTONLY;
+
+	if (html_engine_is_selection_active(((EMFormatHTML *)emfv->preview)->html->engine))
+		t->target.mask &= ~EM_FOLDER_VIEW_SELECT_SELECTION;
+	else
+		t->target.mask &= ~EM_FOLDER_VIEW_SELECT_NOSELECTION;
+
 	/* See bug #54770 */
 	if (!emfv->hide_deleted)
 		t->target.mask &= ~EM_POPUP_SELECT_DELETE;
@@ -2081,7 +2143,7 @@ emfv_list_double_click(ETree *tree, gint
 static int
 emfv_list_right_click(ETree *tree, gint row, ETreePath path, gint col, GdkEvent *event, EMFolderView *emfv)
 {
-	emfv_popup(emfv, event);
+	emfv_popup(emfv, event, FALSE);
 
 	return TRUE;
 }
@@ -2129,7 +2191,7 @@ emfv_popup_menu (GtkWidget *widget)
 {
 	EMFolderView *emfv = (EMFolderView *)widget;
 
-	emfv_popup (emfv, NULL);
+	emfv_popup (emfv, NULL, FALSE);
 
 	return TRUE;
 }
@@ -2179,7 +2241,11 @@ emp_uri_popup_link_copy(EPopup *ep, EPop
 }
 
 static EPopupItem emfv_uri_popups[] = {
-	{ E_POPUP_ITEM, "00.uri.01", N_("_Copy Link Location"), emp_uri_popup_link_copy, NULL, NULL, EM_POPUP_URI_NOT_MAILTO },
+	{ E_POPUP_ITEM, "00.uri.15", N_("_Copy Link Location"), emp_uri_popup_link_copy, NULL, NULL, EM_POPUP_URI_NOT_MAILTO },
+
+	{ E_POPUP_SUBMENU, "99.uri.00", N_("Create _VFolder"), NULL, NULL, NULL, EM_POPUP_URI_MAILTO },
+	{ E_POPUP_ITEM, "99.uri.00/00.10", N_("_From this Address"), emp_uri_popup_vfolder_sender, NULL, NULL, EM_POPUP_URI_MAILTO },
+	{ E_POPUP_ITEM, "99.uri.00/00.00", N_("_To this Address"), emp_uri_popup_vfolder_recipient, NULL, NULL, EM_POPUP_URI_MAILTO },
 };
 
 static void
@@ -2208,10 +2274,11 @@ emfv_format_popup_event(EMFormatHTMLDisp
 		/* 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)
-			emfv_popup(emfv, (GdkEvent *)event);
+			emfv_popup(emfv, (GdkEvent *)event, TRUE);
 		return doit;
 	}
 
Index: mail/em-folder-view.h
===================================================================
RCS file: /cvs/gnome/evolution/mail/em-folder-view.h,v
retrieving revision 1.14
diff -u -p -r1.14 em-folder-view.h
--- mail/em-folder-view.h	20 Sep 2004 05:59:54 -0000	1.14
+++ mail/em-folder-view.h	28 Jan 2005 20:19:35 -0000
@@ -49,7 +49,10 @@ enum {
 	EM_FOLDER_VIEW_SELECT_HIDDEN = EM_POPUP_SELECT_LAST<<1,
 	EM_FOLDER_VIEW_SELECT_NEXT_MSG = EM_POPUP_SELECT_LAST<<2,
 	EM_FOLDER_VIEW_SELECT_PREV_MSG = EM_POPUP_SELECT_LAST<<3,
-	EM_FOLDER_VIEW_SELECT_LAST = EM_POPUP_SELECT_LAST<<4,
+	EM_FOLDER_VIEW_SELECT_LISTONLY = EM_POPUP_SELECT_LAST<<4,
+	EM_FOLDER_VIEW_SELECT_SELECTION = EM_POPUP_SELECT_LAST<<5,
+	EM_FOLDER_VIEW_SELECT_NOSELECTION = EM_POPUP_SELECT_LAST<<6,
+	EM_FOLDER_VIEW_SELECT_LAST = EM_POPUP_SELECT_LAST<<7,
 };
 
 struct _EMFolderViewEnable {
@@ -122,7 +125,7 @@ GtkWidget *em_folder_view_new(void);
 #define em_folder_view_set_folder_uri(emfv, uri) EM_FOLDER_VIEW_GET_CLASS (emfv)->set_folder_uri((emfv), (uri))
 #define em_folder_view_set_message(emfv, uid, nomarkseen) EM_FOLDER_VIEW_GET_CLASS (emfv)->set_message((emfv), (uid), (nomarkseen))
 
-EMPopupTargetSelect *em_folder_view_get_popup_target(EMFolderView *emfv, EMPopup *emp);
+EMPopupTargetSelect *em_folder_view_get_popup_target(EMFolderView *emfv, EMPopup *emp, int on_display);
 
 int em_folder_view_mark_selected(EMFolderView *emfv, guint32 mask, guint32 set);
 int em_folder_view_open_selected(EMFolderView *emfv);
Index: mail/em-popup.c
===================================================================
RCS file: /cvs/gnome/evolution/mail/em-popup.c,v
retrieving revision 1.33
diff -u -p -r1.33 em-popup.c
--- mail/em-popup.c	24 Jan 2005 14:46:24 -0000	1.33
+++ mail/em-popup.c	28 Jan 2005 20:19:35 -0000
@@ -546,7 +546,7 @@ emp_uri_popup_address_add(EPopup *ep, EP
 
 static EPopupItem emp_standard_uri_popups[] = {
 	{ E_POPUP_ITEM, "00.uri.00", N_("_Open Link in Browser"), emp_uri_popup_link_open, NULL, NULL, EM_POPUP_URI_NOT_MAILTO },
-	{ E_POPUP_ITEM, "00.uri.10", N_("Se_nd message to..."), emp_uri_popup_address_send, NULL, NULL, EM_POPUP_URI_MAILTO },
+	{ E_POPUP_ITEM, "00.uri.10", N_("_Send New Message To..."), emp_uri_popup_address_send, NULL, NULL, EM_POPUP_URI_MAILTO },
 	{ E_POPUP_ITEM, "00.uri.20", N_("_Add to Addressbook"), emp_uri_popup_address_add, NULL, NULL, EM_POPUP_URI_MAILTO },
 };
 
Index: mail/mail-autofilter.c
===================================================================
RCS file: /cvs/gnome/evolution/mail/mail-autofilter.c,v
retrieving revision 1.51
diff -u -p -r1.51 mail-autofilter.c
--- mail/mail-autofilter.c	17 Jun 2004 07:34:49 -0000	1.51
+++ mail/mail-autofilter.c	28 Jan 2005 20:19:35 -0000
@@ -223,6 +223,29 @@ rule_match_mlist(RuleContext *context, F
 }
 
 static void
+rule_from_address (FilterRule *rule, RuleContext *context, CamelInternetAddress* addr, int flags)
+{
+	rule->grouping = FILTER_GROUP_ANY;
+
+	if (flags & AUTO_FROM) {
+		const char *name, *address;
+		char *namestr;
+		
+		camel_internet_address_get (addr, 0, &name, &address);
+		rule_add_sender (context, rule, address);
+		if (name == NULL || name[0] == '\0')
+			name = address;
+		namestr = g_strdup_printf(_("Mail from %s"), name);
+		filter_rule_set_name (rule, namestr);
+		g_free (namestr);
+	}
+	if (flags & AUTO_TO) {
+		rule_match_recipients (context, rule, addr);
+	}
+
+}
+
+static void
 rule_from_message (FilterRule *rule, RuleContext *context, CamelMimeMessage *msg, int flags)
 {
 	CamelInternetAddress *addr;
@@ -285,6 +308,20 @@ em_vfolder_rule_from_message (EMVFolderC
 	rule = em_vfolder_rule_new ();
 	em_vfolder_rule_add_source (rule, euri);
 	rule_from_message ((FilterRule *)rule, (RuleContext *)context, msg, flags);
+	g_free(euri);
+
+	return (FilterRule *)rule;
+}
+
+FilterRule *
+em_vfolder_rule_from_address (EMVFolderContext *context, CamelInternetAddress *addr, int flags, const char *source)
+{
+	EMVFolderRule *rule;
+	char *euri = em_uri_from_camel(source);
+
+	rule = em_vfolder_rule_new ();
+	em_vfolder_rule_add_source (rule, euri);
+	rule_from_address ((FilterRule *)rule, (RuleContext *)context, addr, flags);
 	g_free(euri);
 
 	return (FilterRule *)rule;
Index: mail/mail-vfolder.c
===================================================================
RCS file: /cvs/gnome/evolution/mail/mail-vfolder.c,v
retrieving revision 1.129
diff -u -p -r1.129 mail-vfolder.c
--- mail/mail-vfolder.c	28 Jan 2005 09:04:28 -0000	1.129
+++ mail/mail-vfolder.c	28 Jan 2005 20:19:35 -0000
@@ -1120,6 +1120,17 @@ vfolder_gui_add_from_message(CamelMimeMe
 	vfolder_gui_add_rule(rule);
 }
 
+void
+vfolder_gui_add_from_address(CamelInternetAddress *addr, int flags, const char *source)
+{
+	EMVFolderRule *rule;
+
+	g_return_if_fail (addr != NULL);
+	
+	rule = (EMVFolderRule*)em_vfolder_rule_from_address(context, addr, flags, source);
+	vfolder_gui_add_rule(rule);
+}
+
 static void
 vfolder_foreach_cb (gpointer key, gpointer data, gpointer user_data)
 {
Index: mail/mail-vfolder.h
===================================================================
RCS file: /cvs/gnome/evolution/mail/mail-vfolder.h,v
retrieving revision 1.21
diff -u -p -r1.21 mail-vfolder.h
--- mail/mail-vfolder.h	17 Jun 2004 07:34:50 -0000	1.21
+++ mail/mail-vfolder.h	28 Jan 2005 20:19:35 -0000
@@ -18,6 +18,7 @@ FilterPart *vfolder_create_part (const c
 FilterRule *vfolder_clone_rule (FilterRule *in);
 void vfolder_gui_add_rule (EMVFolderRule *rule);
 void vfolder_gui_add_from_message (CamelMimeMessage *msg, int flags, const char *source);
+void vfolder_gui_add_from_address (CamelInternetAddress *addr, int flags, const char *source);
 
 /* add a uri that is now (un)available to vfolders in a transient manner */
 void mail_vfolder_add_uri(CamelStore *store, const char *uri, int remove);


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