Mercurial > geeqie.yaz
changeset 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 | 58f0b4586c8c |
children | 9e7aed6ba6bd |
files | src/collect-table.c src/dupe.c src/dupe.h src/editors.c src/editors.h src/img-view.c src/layout_image.c src/menu.c src/menu.h src/pan-types.h src/pan-view.c src/search.c src/typedefs.h src/view_file.c |
diffstat | 14 files changed, 194 insertions(+), 38 deletions(-) [+] |
line wrap: on
line diff
--- a/src/collect-table.c Sun Mar 08 12:42:23 2009 +0000 +++ b/src/collect-table.c Sun Mar 08 13:23:25 2009 +0000 @@ -839,6 +839,9 @@ filelist_free(ct->drop_list); ct->drop_list = NULL; ct->drop_info = NULL; + + filelist_free(ct->editmenu_fd_list); + ct->editmenu_fd_list = NULL; } static GtkWidget *collection_table_popup_menu(CollectTable *ct, gint over_icon) @@ -877,8 +880,10 @@ gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), submenu); menu_item_add_divider(menu); + + ct->editmenu_fd_list = collection_table_selection_get_list(ct); submenu_add_edit(menu, &item, - G_CALLBACK(collection_table_popup_edit_cb), ct); + G_CALLBACK(collection_table_popup_edit_cb), ct, ct->editmenu_fd_list); gtk_widget_set_sensitive(item, over_icon); menu_item_add_divider(menu);
--- a/src/dupe.c Sun Mar 08 12:42:23 2009 +0000 +++ b/src/dupe.c Sun Mar 08 13:23:25 2009 +0000 @@ -2211,6 +2211,30 @@ dupe_window_close(dw); } +static void dupe_menu_popup_destroy_cb(GtkWidget *widget, gpointer data) +{ + DupeWindow *dw = data; + + filelist_free(dw->editmenu_fd_list); + dw->editmenu_fd_list = NULL; +} + +static GList *dupe_window_get_fd_list(DupeWindow *dw) +{ + GList *list; + + if (GTK_WIDGET_HAS_FOCUS(dw->second_listview)) + { + list = dupe_listview_get_selection(dw, dw->second_listview); + } + else + { + list = dupe_listview_get_selection(dw, dw->listview); + } + + return list; +} + static GtkWidget *dupe_menu_popup_main(DupeWindow *dw, DupeItem *di) { GtkWidget *menu; @@ -2220,6 +2244,9 @@ on_row = (di != NULL); menu = popup_menu_short_lived(); + g_signal_connect(G_OBJECT(menu), "destroy", + G_CALLBACK(dupe_menu_popup_destroy_cb), dw); + menu_item_add_sensitive(menu, _("_View"), on_row, G_CALLBACK(dupe_menu_view_cb), dw); menu_item_add_stock_sensitive(menu, _("View in _new window"), GTK_STOCK_NEW, on_row, @@ -2234,7 +2261,9 @@ menu_item_add_sensitive(menu, _("Select group _2 duplicates"), (dw->dupes != NULL), G_CALLBACK(dupe_menu_select_dupes_set2_cb), dw); menu_item_add_divider(menu); - submenu_add_edit(menu, &item, G_CALLBACK(dupe_menu_edit_cb), dw); + + dw->editmenu_fd_list = dupe_window_get_fd_list(dw); + submenu_add_edit(menu, &item, G_CALLBACK(dupe_menu_edit_cb), dw, dw->editmenu_fd_list); if (!on_row) gtk_widget_set_sensitive(item, FALSE); menu_item_add_stock_sensitive(menu, _("Add to new collection"), GTK_STOCK_INDEX, on_row, G_CALLBACK(dupe_menu_collection_cb), dw);
--- a/src/dupe.h Sun Mar 08 12:42:23 2009 +0000 +++ b/src/dupe.h Sun Mar 08 13:23:25 2009 +0000 @@ -109,6 +109,10 @@ GtkWidget *second_status_label; gint color_frozen; + + /* file list for edit menu */ + GList *editmenu_fd_list; + };
--- a/src/editors.c Sun Mar 08 12:42:23 2009 +0000 +++ b/src/editors.c Sun Mar 08 13:23:25 2009 +0000 @@ -59,7 +59,6 @@ static gint editor_command_next_start(EditorData *ed); static gint editor_command_next_finish(EditorData *ed, gint status); static gint editor_command_done(EditorData *ed); -static gint editor_command_parse(const EditorDescription *editor, GList *list, gchar **output); /* *----------------------------------------------------------------------------- @@ -646,7 +645,7 @@ } -static gint editor_command_parse(const EditorDescription *editor, GList *list, gchar **output) +gint editor_command_parse(const EditorDescription *editor, GList *list, gchar **output) { gint flags = 0; const gchar *p; @@ -689,27 +688,28 @@ flags |= EDITOR_ERROR_INCOMPATIBLE; goto err; } + /* use the first file from the list */ + if (!list || !list->data) + { + flags |= EDITOR_ERROR_NO_FILE; + goto err; + } + pathl = editor_command_path_parse((FileData *)list->data, + (*p == 'f') ? PATH_FILE : PATH_FILE_URL, + editor); + if (!pathl) + { + flags |= EDITOR_ERROR_NO_FILE; + goto err; + } if (output) { - /* use the first file from the list */ - if (!list || !list->data) - { - flags |= EDITOR_ERROR_NO_FILE; - goto err; - } - pathl = editor_command_path_parse((FileData *)list->data, - (*p == 'f') ? PATH_FILE : PATH_FILE_URL, - editor); - if (!pathl) - { - flags |= EDITOR_ERROR_NO_FILE; - goto err; - } result = g_string_append_c(result, '"'); result = g_string_append(result, pathl); - g_free(pathl); result = g_string_append_c(result, '"'); } + g_free(pathl); + break; case 'F': @@ -721,7 +721,6 @@ goto err; } - if (output) { /* use whole list */ GList *work = list; @@ -731,15 +730,19 @@ { FileData *fd = work->data; pathl = editor_command_path_parse(fd, (*p == 'F') ? PATH_FILE : PATH_FILE_URL, editor); - if (pathl) { ok = TRUE; - if (work != list) g_string_append_c(result, ' '); - result = g_string_append_c(result, '"'); - result = g_string_append(result, pathl); + + if (output) + { + ok = TRUE; + if (work != list) g_string_append_c(result, ' '); + result = g_string_append_c(result, '"'); + result = g_string_append(result, pathl); + result = g_string_append_c(result, '"'); + } g_free(pathl); - result = g_string_append_c(result, '"'); } work = work->next; } @@ -802,7 +805,7 @@ } -static void editor_child_exit_cb (GPid pid, gint status, gpointer data) +static void editor_child_exit_cb(GPid pid, gint status, gpointer data) { EditorData *ed = data; g_spawn_close_pid(pid);
--- a/src/editors.h Sun Mar 08 12:42:23 2009 +0000 +++ b/src/editors.h Sun Mar 08 13:23:25 2009 +0000 @@ -77,6 +77,7 @@ const gchar *editor_get_name(const gchar *key); gboolean is_valid_editor_command(const gchar *key); +gint editor_command_parse(const EditorDescription *editor, GList *list, gchar **output); #endif /* vim: set shiftwidth=8 softtabstop=0 cindent cinoptions={1s: */
--- a/src/img-view.c Sun Mar 08 12:42:23 2009 +0000 +++ b/src/img-view.c Sun Mar 08 13:23:25 2009 +0000 @@ -49,6 +49,9 @@ GList *list; GList *list_pointer; + + /* file list for edit menu */ + GList *editmenu_fd_list; }; @@ -1240,6 +1243,28 @@ view_window_close(vw); } +static void view_popup_menu_destroy_cb(GtkWidget *widget, gpointer data) +{ + ViewWindow *vw = data; + + filelist_free(vw->editmenu_fd_list); + vw->editmenu_fd_list = NULL; +} + +static GList *view_window_get_fd_list(ViewWindow *vw) +{ + GList *list = NULL; + ImageWindow *imd = view_window_active_image(vw); + + if (imd) + { + FileData *fd = image_get_fd(imd); + if (fd) list = g_list_append(NULL, file_data_ref(fd)); + } + + return list; +} + static GtkWidget *view_popup_menu(ViewWindow *vw) { GtkWidget *menu; @@ -1247,13 +1272,17 @@ menu = popup_menu_short_lived(); + g_signal_connect(G_OBJECT(menu), "destroy", + G_CALLBACK(view_popup_menu_destroy_cb), vw); + menu_item_add_stock(menu, _("Zoom _in"), GTK_STOCK_ZOOM_IN, G_CALLBACK(view_zoom_in_cb), vw); menu_item_add_stock(menu, _("Zoom _out"), GTK_STOCK_ZOOM_OUT, G_CALLBACK(view_zoom_out_cb), vw); menu_item_add_stock(menu, _("Zoom _1:1"), GTK_STOCK_ZOOM_100, G_CALLBACK(view_zoom_1_1_cb), vw); menu_item_add_stock(menu, _("Fit image to _window"), GTK_STOCK_ZOOM_FIT, G_CALLBACK(view_zoom_fit_cb), vw); menu_item_add_divider(menu); - item = submenu_add_edit(menu, NULL, G_CALLBACK(view_edit_cb), vw); + vw->editmenu_fd_list = view_window_get_fd_list(vw); + item = submenu_add_edit(menu, NULL, G_CALLBACK(view_edit_cb), vw, vw->editmenu_fd_list); menu_item_add_divider(item); menu_item_add(item, _("Set as _wallpaper"), G_CALLBACK(view_wallpaper_cb), vw);
--- 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);
--- a/src/menu.c Sun Mar 08 12:42:23 2009 +0000 +++ b/src/menu.c Sun Mar 08 13:23:25 2009 +0000 @@ -64,7 +64,7 @@ *----------------------------------------------------------------------------- */ -static void add_edit_items(GtkWidget *menu, GCallback func) +static void add_edit_items(GtkWidget *menu, GCallback func, GList *fd_list) { GList *editors_list = editor_list_get(); GList *work = editors_list; @@ -73,15 +73,24 @@ { const EditorDescription *editor = work->data; work = work->next; - - menu_item_add(menu, editor->name, func, editor->key); + gboolean active = TRUE; + + if (fd_list) + { + gint flags = editor_command_parse(editor, fd_list, NULL); + if ((flags & EDITOR_ERROR_MASK) != 0) + active = FALSE; + } + + if (active) + menu_item_add(menu, editor->name, func, editor->key); } g_list_free(editors_list); } -GtkWidget *submenu_add_edit(GtkWidget *menu, GtkWidget **menu_item, GCallback func, gpointer data) +GtkWidget *submenu_add_edit(GtkWidget *menu, GtkWidget **menu_item, GCallback func, gpointer data, GList *fd_list) { GtkWidget *item; GtkWidget *submenu; @@ -90,7 +99,7 @@ submenu = gtk_menu_new(); g_object_set_data(G_OBJECT(submenu), "submenu_data", data); - add_edit_items(submenu, func); + add_edit_items(submenu, func, fd_list); gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), submenu);
--- a/src/menu.h Sun Mar 08 12:42:23 2009 +0000 +++ b/src/menu.h Sun Mar 08 13:23:25 2009 +0000 @@ -17,7 +17,7 @@ gpointer submenu_item_get_data(GtkWidget *menu); -GtkWidget *submenu_add_edit(GtkWidget *menu, GtkWidget **menu_item, GCallback func, gpointer data); +GtkWidget *submenu_add_edit(GtkWidget *menu, GtkWidget **menu_item, GCallback func, gpointer data, GList *fd_list); gchar *sort_type_get_text(SortType method); GtkWidget *submenu_add_sort(GtkWidget *menu, GCallback func, gpointer data,
--- a/src/pan-types.h Sun Mar 08 12:42:23 2009 +0000 +++ b/src/pan-types.h Sun Mar 08 13:23:25 2009 +0000 @@ -227,6 +227,9 @@ PanItem *search_pi; gint idle_id; + + /* file list for edit menu */ + GList *editmenu_fd_list; }; typedef struct _PanGrid PanGrid;
--- 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);
--- a/src/search.c Sun Mar 08 12:42:23 2009 +0000 +++ b/src/search.c Sun Mar 08 13:23:25 2009 +0000 @@ -190,6 +190,10 @@ ThumbLoader *thumb_loader; gint thumb_enable; FileData *thumb_fd; + + /* file list for edit menu */ + GList *editmenu_fd_list; + }; typedef struct _MatchFileData MatchFileData; @@ -979,12 +983,23 @@ search_result_clear(sd); } +static void search_result_menu_destroy_cb(GtkWidget *widget, gpointer data) +{ + SearchData *sd = data; + + filelist_free(sd->editmenu_fd_list); + sd->editmenu_fd_list = NULL; +} + static GtkWidget *search_result_menu(SearchData *sd, gint on_row, gint empty) { GtkWidget *menu; GtkWidget *item; menu = popup_menu_short_lived(); + g_signal_connect(G_OBJECT(menu), "destroy", + G_CALLBACK(search_result_menu_destroy_cb), sd); + menu_item_add_sensitive(menu, _("_View"), on_row, G_CALLBACK(sr_menu_view_cb), sd); menu_item_add_stock_sensitive(menu, _("View in _new window"), GTK_STOCK_NEW, on_row, @@ -995,7 +1010,9 @@ menu_item_add_sensitive(menu, _("Select none"), !empty, G_CALLBACK(sr_menu_select_none_cb), sd); menu_item_add_divider(menu); - submenu_add_edit(menu, &item, G_CALLBACK(sr_menu_edit_cb), sd); + + sd->editmenu_fd_list = search_result_selection_list(sd); + submenu_add_edit(menu, &item, G_CALLBACK(sr_menu_edit_cb), sd, sd->editmenu_fd_list); if (!on_row) gtk_widget_set_sensitive(item, FALSE); menu_item_add_stock_sensitive(menu, _("Add to new collection"), GTK_STOCK_INDEX, on_row, G_CALLBACK(sr_menu_collection_cb), sd);
--- a/src/typedefs.h Sun Mar 08 12:42:23 2009 +0000 +++ b/src/typedefs.h Sun Mar 08 13:23:25 2009 +0000 @@ -340,6 +340,9 @@ gint drop_idle_id; gint show_text; + + /* file list for edit menu */ + GList *editmenu_fd_list; }; struct _CollectWindow @@ -655,6 +658,9 @@ // gint bar_width; GtkWidget *exif_window; + + /* file list for edit menu */ + GList *editmenu_fd_list; }; struct _ViewDir @@ -739,6 +745,9 @@ /* refresh */ gint refresh_idle_id; + + /* file list for edit menu */ + GList *editmenu_fd_list; }; struct _ViewFileInfoList
--- a/src/view_file.c Sun Mar 08 12:42:23 2009 +0000 +++ b/src/view_file.c Sun Mar 08 13:23:25 2009 +0000 @@ -475,6 +475,9 @@ case FILEVIEW_LIST: vflist_popup_destroy_cb(widget, data); break; case FILEVIEW_ICON: vficon_popup_destroy_cb(widget, data); break; } + + filelist_free(vf->editmenu_fd_list); + vf->editmenu_fd_list = NULL; } GtkWidget *vf_pop_menu(ViewFile *vf) @@ -547,7 +550,8 @@ g_free(str_sel_mark_minus); } - submenu_add_edit(menu, &item, G_CALLBACK(vf_pop_menu_edit_cb), vf); + vf->editmenu_fd_list = vf_selection_get_list(vf); + submenu_add_edit(menu, &item, G_CALLBACK(vf_pop_menu_edit_cb), vf, vf->editmenu_fd_list); gtk_widget_set_sensitive(item, active); menu_item_add_stock_sensitive(menu, _("View in _new window"), GTK_STOCK_NEW, active,