diff src/layout_image.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 3c9abbc05792
children 7e180091e0b7
line wrap: on
line diff
--- a/src/layout_image.c	Sun Mar 08 12:42:23 2009 +0000
+++ b/src/layout_image.c	Sun Mar 08 13:23:25 2009 +0000
@@ -456,6 +456,25 @@
 	return ret;
 }
 
+static void layout_image_popup_menu_destroy_cb(GtkWidget *widget, gpointer data)
+{
+	LayoutWindow *lw = data;
+
+	filelist_free(lw->editmenu_fd_list);
+	lw->editmenu_fd_list = NULL;
+}	
+
+static GList *layout_image_get_fd_list(LayoutWindow *lw)
+{
+	GList *list = NULL;
+	FileData *fd = layout_image_get_fd(lw);
+
+	if (fd)
+		list = g_list_append(NULL, file_data_ref(fd));
+	
+	return list;
+}
+
 static GtkWidget *layout_image_pop_menu(LayoutWindow *lw)
 {
 	GtkWidget *menu;
@@ -468,6 +487,8 @@
 	fullscreen = layout_image_full_screen_active(lw);
 
 	menu = popup_menu_short_lived();
+	g_signal_connect(G_OBJECT(menu), "destroy",
+			 G_CALLBACK(layout_image_popup_menu_destroy_cb), lw);
 
 	menu_item_add_stock(menu, _("Zoom _in"), GTK_STOCK_ZOOM_IN, G_CALLBACK(li_pop_menu_zoom_in_cb), lw);
 	menu_item_add_stock(menu, _("Zoom _out"), GTK_STOCK_ZOOM_OUT, G_CALLBACK(li_pop_menu_zoom_out_cb), lw);
@@ -475,7 +496,8 @@
 	menu_item_add_stock(menu, _("Fit image to _window"), GTK_STOCK_ZOOM_FIT, G_CALLBACK(li_pop_menu_zoom_fit_cb), lw);
 	menu_item_add_divider(menu);
 
-	submenu = submenu_add_edit(menu, &item, G_CALLBACK(li_pop_menu_edit_cb), lw);
+	lw->editmenu_fd_list = layout_image_get_fd_list(lw);
+	submenu = submenu_add_edit(menu, &item, G_CALLBACK(li_pop_menu_edit_cb), lw, lw->editmenu_fd_list);
 	if (!path) gtk_widget_set_sensitive(item, FALSE);
 	menu_item_add_divider(submenu);
 	menu_item_add(submenu, _("Set as _wallpaper"), G_CALLBACK(li_pop_menu_wallpaper_cb), lw);