diff src/pan-view.c @ 1397:a0bd58a6535f

In various Edit context menus, only display editors that match the file types in the selection.
author zas_
date Sun, 08 Mar 2009 13:23:25 +0000
parents fe4da037be21
children b106af9689db
line wrap: on
line diff
--- a/src/pan-view.c	Sun Mar 08 12:42:23 2009 +0000
+++ b/src/pan-view.c	Sun Mar 08 13:23:25 2009 +0000
@@ -2773,6 +2773,24 @@
 	pan_window_close(pw);
 }
 
+static void pan_popup_menu_destroy_cb(GtkWidget *widget, gpointer data)
+{
+	PanWindow *pw = data;
+
+	filelist_free(pw->editmenu_fd_list);
+	pw->editmenu_fd_list = NULL;
+}
+
+static GList *pan_view_get_fd_list(PanWindow *pw)
+{
+	GList *list = NULL;
+	FileData *fd = pan_menu_click_fd(pw);
+	
+	if (fd) list = g_list_append(NULL, file_data_ref(fd));
+	
+	return list;
+}
+
 static GtkWidget *pan_popup_menu(PanWindow *pw)
 {
 	GtkWidget *menu;
@@ -2783,6 +2801,8 @@
 	active = (pw->click_pi != NULL);
 
 	menu = popup_menu_short_lived();
+	g_signal_connect(G_OBJECT(menu), "destroy",
+			 G_CALLBACK(pan_popup_menu_destroy_cb), pw);
 
 	menu_item_add_stock(menu, _("Zoom _in"), GTK_STOCK_ZOOM_IN,
 			    G_CALLBACK(pan_zoom_in_cb), pw);
@@ -2792,9 +2812,10 @@
 			    G_CALLBACK(pan_zoom_1_1_cb), pw);
 	menu_item_add_divider(menu);
 
-	submenu_add_edit(menu, &item, G_CALLBACK(pan_edit_cb), pw);
+	pw->editmenu_fd_list = pan_view_get_fd_list(pw);
+	submenu_add_edit(menu, &item, G_CALLBACK(pan_edit_cb), pw, pw->editmenu_fd_list);
 	gtk_widget_set_sensitive(item, active);
-
+	
 	menu_item_add_stock_sensitive(menu, _("View in _new window"), GTK_STOCK_NEW, active,
 				      G_CALLBACK(pan_new_window_cb), pw);