Mercurial > geeqie.yaz
changeset 635:eaca3e910ecd
Move a part of pop up menu common code to view_file.[ch].
author | zas_ |
---|---|
date | Sun, 11 May 2008 23:47:59 +0000 |
parents | 92208e71673b |
children | 2ea7af1fbfe0 |
files | src/view_file.c src/view_file.h src/view_file_icon.c src/view_file_list.c |
diffstat | 4 files changed, 182 insertions(+), 256 deletions(-) [+] |
line wrap: on
line diff
--- a/src/view_file.c Sun May 11 23:09:39 2008 +0000 +++ b/src/view_file.c Sun May 11 23:47:59 2008 +0000 @@ -13,6 +13,11 @@ #include "view_file.h" #include "debug.h" +#include "editors.h" +#include "info.h" +#include "layout.h" +#include "menu.h" +#include "utilops.h" #include "view_file_list.h" #include "view_file_icon.h" @@ -290,6 +295,142 @@ return ret; } +void vf_pop_menu_edit_cb(GtkWidget *widget, gpointer data) +{ + ViewFile *vf; + gint n; + GList *list; + + vf = submenu_item_get_data(widget); + n = GPOINTER_TO_INT(data); + + if (!vf) return; + + list = vf_pop_menu_file_list(vf); + start_editor_from_filelist(n, list); + filelist_free(list); +} + +void vf_pop_menu_info_cb(GtkWidget *widget, gpointer data) +{ + ViewFile *vf = data; + + info_window_new(NULL, vf_pop_menu_file_list(vf), NULL); +} + +void vf_pop_menu_copy_cb(GtkWidget *widget, gpointer data) +{ + ViewFile *vf = data; + + file_util_copy(NULL, vf_pop_menu_file_list(vf), NULL, vf->listview); +} + +void vf_pop_menu_move_cb(GtkWidget *widget, gpointer data) +{ + ViewFile *vf = data; + + file_util_move(NULL, vf_pop_menu_file_list(vf), NULL, vf->listview); +} + +void vf_pop_menu_delete_cb(GtkWidget *widget, gpointer data) +{ + ViewFile *vf = data; + + file_util_delete(NULL, vf_pop_menu_file_list(vf), vf->listview); +} + +void vf_pop_menu_copy_path_cb(GtkWidget *widget, gpointer data) +{ + ViewFile *vf = data; + + file_util_copy_path_list_to_clipboard(vf_pop_menu_file_list(vf)); +} + +void vf_pop_menu_sort_cb(GtkWidget *widget, gpointer data) +{ + ViewFile *vf; + SortType type; + + if (!gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(widget))) return; + + vf = submenu_item_get_data(widget); + if (!vf) return; + + type = (SortType)GPOINTER_TO_INT(data); + + if (vf->layout) + { + layout_sort_set(vf->layout, type, vf->sort_ascend); + } + else + { + vf_sort_set(vf, type, vf->sort_ascend); + } +} + +void vf_pop_menu_sort_ascend_cb(GtkWidget *widget, gpointer data) +{ + ViewFile *vf = data; + + if (vf->layout) + { + layout_sort_set(vf->layout, vf->sort_method, !vf->sort_ascend); + } + else + { + vf_sort_set(vf, vf->sort_method, !vf->sort_ascend); + } +} + +void vf_pop_menu_sel_mark_cb(GtkWidget *widget, gpointer data) +{ + ViewFile *vf = data; + vf_mark_to_selection(vf, vf->active_mark, MTS_MODE_SET); +} + +void vf_pop_menu_sel_mark_and_cb(GtkWidget *widget, gpointer data) +{ + ViewFile *vf = data; + vf_mark_to_selection(vf, vf->active_mark, MTS_MODE_AND); +} + +void vf_pop_menu_sel_mark_or_cb(GtkWidget *widget, gpointer data) +{ + ViewFile *vf = data; + vf_mark_to_selection(vf, vf->active_mark, MTS_MODE_OR); +} + +void vf_pop_menu_sel_mark_minus_cb(GtkWidget *widget, gpointer data) +{ + ViewFile *vf = data; + vf_mark_to_selection(vf, vf->active_mark, MTS_MODE_MINUS); +} + +void vf_pop_menu_set_mark_sel_cb(GtkWidget *widget, gpointer data) +{ + ViewFile *vf = data; + vf_selection_to_mark(vf, vf->active_mark, STM_MODE_SET); +} + +void vf_pop_menu_res_mark_sel_cb(GtkWidget *widget, gpointer data) +{ + ViewFile *vf = data; + vf_selection_to_mark(vf, vf->active_mark, STM_MODE_RESET); +} + +void vf_pop_menu_toggle_mark_sel_cb(GtkWidget *widget, gpointer data) +{ + ViewFile *vf = data; + vf_selection_to_mark(vf, vf->active_mark, STM_MODE_TOGGLE); +} + +void vf_pop_menu_toggle_view_type_cb(GtkWidget *widget, gpointer data) +{ + ViewFile *vf = data; + + if (vf->layout) layout_views_set(vf->layout, vf->layout->dir_view_type, !vf->layout->file_view_type); +} +
--- a/src/view_file.h Sun May 11 23:09:39 2008 +0000 +++ b/src/view_file.h Sun May 11 23:47:59 2008 +0000 @@ -31,6 +31,22 @@ void vf_sort_set(ViewFile *vf, SortType type, gint ascend); GList *vf_pop_menu_file_list(ViewFile *vf); +void vf_pop_menu_edit_cb(GtkWidget *widget, gpointer data); +void vf_pop_menu_info_cb(GtkWidget *widget, gpointer data); +void vf_pop_menu_copy_cb(GtkWidget *widget, gpointer data); +void vf_pop_menu_move_cb(GtkWidget *widget, gpointer data); +void vf_pop_menu_delete_cb(GtkWidget *widget, gpointer data); +void vf_pop_menu_copy_path_cb(GtkWidget *widget, gpointer data); +void vf_pop_menu_sort_cb(GtkWidget *widget, gpointer data); +void vf_pop_menu_sort_ascend_cb(GtkWidget *widget, gpointer data); +void vf_pop_menu_sel_mark_cb(GtkWidget *widget, gpointer data); +void vf_pop_menu_sel_mark_and_cb(GtkWidget *widget, gpointer data); +void vf_pop_menu_sel_mark_or_cb(GtkWidget *widget, gpointer data); +void vf_pop_menu_sel_mark_minus_cb(GtkWidget *widget, gpointer data); +void vf_pop_menu_set_mark_sel_cb(GtkWidget *widget, gpointer data); +void vf_pop_menu_res_mark_sel_cb(GtkWidget *widget, gpointer data); +void vf_pop_menu_toggle_mark_sel_cb(GtkWidget *widget, gpointer data); +void vf_pop_menu_toggle_view_type_cb(GtkWidget *widget, gpointer data); FileData *vf_index_get_data(ViewFile *vf, gint row); gint vf_index_by_path(ViewFile *vf, const gchar *path);
--- a/src/view_file_icon.c Sun May 11 23:09:39 2008 +0000 +++ b/src/view_file_icon.c Sun May 11 23:47:59 2008 +0000 @@ -176,29 +176,6 @@ return g_list_append(NULL, file_data_ref(VFICON_INFO(vf, click_id)->fd)); } -static void vficon_pop_menu_edit_cb(GtkWidget *widget, gpointer data) -{ - ViewFile *vf; - gint n; - GList *list; - - vf = submenu_item_get_data(widget); - n = GPOINTER_TO_INT(data); - - if (!vf) return; - - list = vf_pop_menu_file_list(vf); - start_editor_from_filelist(n, list); - filelist_free(list); -} - -static void vficon_pop_menu_info_cb(GtkWidget *widget, gpointer data) -{ - ViewFile *vf = data; - - info_window_new(NULL, vf_pop_menu_file_list(vf), NULL); -} - static void vficon_pop_menu_view_cb(GtkWidget *widget, gpointer data) { ViewFile *vf = data; @@ -219,20 +196,6 @@ } } -static void vficon_pop_menu_copy_cb(GtkWidget *widget, gpointer data) -{ - ViewFile *vf = data; - - file_util_copy(NULL, vf_pop_menu_file_list(vf), NULL, vf->listview); -} - -static void vficon_pop_menu_move_cb(GtkWidget *widget, gpointer data) -{ - ViewFile *vf = data; - - file_util_move(NULL, vf_pop_menu_file_list(vf), NULL, vf->listview); -} - static void vficon_pop_menu_rename_cb(GtkWidget *widget, gpointer data) { ViewFile *vf = data; @@ -240,63 +203,6 @@ file_util_rename(NULL, vf_pop_menu_file_list(vf), vf->listview); } -static void vficon_pop_menu_delete_cb(GtkWidget *widget, gpointer data) -{ - ViewFile *vf = data; - - file_util_delete(NULL, vf_pop_menu_file_list(vf), vf->listview); -} - -static void vficon_pop_menu_copy_path_cb(GtkWidget *widget, gpointer data) -{ - ViewFile *vf = data; - - file_util_copy_path_list_to_clipboard(vf_pop_menu_file_list(vf)); -} - -static void vficon_pop_menu_sort_cb(GtkWidget *widget, gpointer data) -{ - ViewFile *vf; - SortType type; - - if (!gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(widget))) return; - - vf = submenu_item_get_data(widget); - if (!vf) return; - - type = (SortType)GPOINTER_TO_INT(data); - - if (vf->layout) - { - layout_sort_set(vf->layout, type, vf->sort_ascend); - } - else - { - vf_sort_set(vf, type, vf->sort_ascend); - } -} - -static void vficon_pop_menu_sort_ascend_cb(GtkWidget *widget, gpointer data) -{ - ViewFile *vf = data; - - if (vf->layout) - { - layout_sort_set(vf->layout, vf->sort_method, !vf->sort_ascend); - } - else - { - vf_sort_set(vf, vf->sort_method, !vf->sort_ascend); - } -} - -static void vficon_pop_menu_list_cb(GtkWidget *widget, gpointer data) -{ - ViewFile *vf = data; - - if (vf->layout) layout_views_set(vf->layout, vf->layout->dir_view_type, FALSE); -} - static void vficon_pop_menu_show_names_cb(GtkWidget *widget, gpointer data) { ViewFile *vf = data; @@ -330,40 +236,40 @@ g_signal_connect(G_OBJECT(menu), "destroy", G_CALLBACK(vficon_popup_destroy_cb), vf); - submenu_add_edit(menu, &item, G_CALLBACK(vficon_pop_menu_edit_cb), vf); + submenu_add_edit(menu, &item, G_CALLBACK(vf_pop_menu_edit_cb), vf); gtk_widget_set_sensitive(item, active); menu_item_add_stock_sensitive(menu, _("_Properties"), GTK_STOCK_PROPERTIES, active, - G_CALLBACK(vficon_pop_menu_info_cb), vf); + G_CALLBACK(vf_pop_menu_info_cb), vf); menu_item_add_stock_sensitive(menu, _("View in _new window"), GTK_STOCK_NEW, active, G_CALLBACK(vficon_pop_menu_view_cb), vf); menu_item_add_divider(menu); menu_item_add_stock_sensitive(menu, _("_Copy..."), GTK_STOCK_COPY, active, - G_CALLBACK(vficon_pop_menu_copy_cb), vf); + G_CALLBACK(vf_pop_menu_copy_cb), vf); menu_item_add_sensitive(menu, _("_Move..."), active, - G_CALLBACK(vficon_pop_menu_move_cb), vf); + G_CALLBACK(vf_pop_menu_move_cb), vf); menu_item_add_sensitive(menu, _("_Rename..."), active, G_CALLBACK(vficon_pop_menu_rename_cb), vf); menu_item_add_stock_sensitive(menu, _("_Delete..."), GTK_STOCK_DELETE, active, - G_CALLBACK(vficon_pop_menu_delete_cb), vf); + G_CALLBACK(vf_pop_menu_delete_cb), vf); if (options->show_copy_path) menu_item_add_sensitive(menu, _("_Copy path"), active, - G_CALLBACK(vficon_pop_menu_copy_path_cb), vf); + G_CALLBACK(vf_pop_menu_copy_path_cb), vf); menu_item_add_divider(menu); - submenu = submenu_add_sort(NULL, G_CALLBACK(vficon_pop_menu_sort_cb), vf, + submenu = submenu_add_sort(NULL, G_CALLBACK(vf_pop_menu_sort_cb), vf, FALSE, FALSE, TRUE, vf->sort_method); menu_item_add_divider(submenu); menu_item_add_check(submenu, _("Ascending"), vf->sort_ascend, - G_CALLBACK(vficon_pop_menu_sort_ascend_cb), vf); + G_CALLBACK(vf_pop_menu_sort_ascend_cb), vf); item = menu_item_add(menu, _("_Sort"), NULL, NULL); gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), submenu); menu_item_add_check(menu, _("View as _icons"), TRUE, - G_CALLBACK(vficon_pop_menu_list_cb), vf); + G_CALLBACK(vf_pop_menu_toggle_view_type_cb), vf); menu_item_add_check(menu, _("Show filename _text"), VFICON_INFO(vf, show_text), G_CALLBACK(vficon_pop_menu_show_names_cb), vf); menu_item_add_stock(menu, _("Re_fresh"), GTK_STOCK_REFRESH, G_CALLBACK(vficon_pop_menu_refresh_cb), vf);
--- a/src/view_file_list.c Sun May 11 23:09:39 2008 +0000 +++ b/src/view_file_list.c Sun May 11 23:47:59 2008 +0000 @@ -289,29 +289,6 @@ return g_list_append(NULL, file_data_ref(VFLIST_INFO(vf, click_fd))); } -static void vflist_pop_menu_edit_cb(GtkWidget *widget, gpointer data) -{ - ViewFile *vf; - gint n; - GList *list; - - vf = submenu_item_get_data(widget); - n = GPOINTER_TO_INT(data); - - if (!vf) return; - - list = vf_pop_menu_file_list(vf); - start_editor_from_filelist(n, list); - filelist_free(list); -} - -static void vflist_pop_menu_info_cb(GtkWidget *widget, gpointer data) -{ - ViewFile *vf = data; - - info_window_new(NULL, vf_pop_menu_file_list(vf), NULL); -} - static void vflist_pop_menu_view_cb(GtkWidget *widget, gpointer data) { ViewFile *vf = data; @@ -330,27 +307,6 @@ } } -static void vflist_pop_menu_copy_cb(GtkWidget *widget, gpointer data) -{ - ViewFile *vf = data; - - file_util_copy(NULL, vf_pop_menu_file_list(vf), NULL, vf->listview); -} - -static void vflist_pop_menu_copy_path_cb(GtkWidget *widget, gpointer data) -{ - ViewFile *vf = data; - - file_util_copy_path_list_to_clipboard(vf_pop_menu_file_list(vf)); -} - -static void vflist_pop_menu_move_cb(GtkWidget *widget, gpointer data) -{ - ViewFile *vf = data; - - file_util_move(NULL, vf_pop_menu_file_list(vf), NULL, vf->listview); -} - static void vflist_pop_menu_rename_cb(GtkWidget *widget, gpointer data) { ViewFile *vf = data; @@ -382,56 +338,6 @@ file_util_rename(NULL, list, vf->listview); } -static void vflist_pop_menu_delete_cb(GtkWidget *widget, gpointer data) -{ - ViewFile *vf = data; - - file_util_delete(NULL, vf_pop_menu_file_list(vf), vf->listview); -} - -static void vflist_pop_menu_sort_cb(GtkWidget *widget, gpointer data) -{ - ViewFile *vf; - SortType type; - - if (!gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(widget))) return; - - vf = submenu_item_get_data(widget); - if (!vf) return; - - type = (SortType)GPOINTER_TO_INT(data); - - if (vf->layout) - { - layout_sort_set(vf->layout, type, vf->sort_ascend); - } - else - { - vf_sort_set(vf, type, vf->sort_ascend); - } -} - -static void vflist_pop_menu_sort_ascend_cb(GtkWidget *widget, gpointer data) -{ - ViewFile *vf = data; - - if (vf->layout) - { - layout_sort_set(vf->layout, vf->sort_method, !vf->sort_ascend); - } - else - { - vf_sort_set(vf, vf->sort_method, !vf->sort_ascend); - } -} - -static void vflist_pop_menu_icons_cb(GtkWidget *widget, gpointer data) -{ - ViewFile *vf = data; - - if (vf->layout) layout_views_set(vf->layout, vf->layout->dir_view_type, TRUE); -} - static void vflist_pop_menu_thumbs_cb(GtkWidget *widget, gpointer data) { ViewFile *vf = data; @@ -455,49 +361,6 @@ vf_refresh(vf); } -static void vflist_pop_menu_sel_mark_cb(GtkWidget *widget, gpointer data) -{ - ViewFile *vf = data; - vf_mark_to_selection(vf, vf->active_mark, MTS_MODE_SET); -} - -static void vflist_pop_menu_sel_mark_and_cb(GtkWidget *widget, gpointer data) -{ - ViewFile *vf = data; - vf_mark_to_selection(vf, vf->active_mark, MTS_MODE_AND); -} - -static void vflist_pop_menu_sel_mark_or_cb(GtkWidget *widget, gpointer data) -{ - ViewFile *vf = data; - vf_mark_to_selection(vf, vf->active_mark, MTS_MODE_OR); -} - -static void vflist_pop_menu_sel_mark_minus_cb(GtkWidget *widget, gpointer data) -{ - ViewFile *vf = data; - vf_mark_to_selection(vf, vf->active_mark, MTS_MODE_MINUS); -} - -static void vflist_pop_menu_set_mark_sel_cb(GtkWidget *widget, gpointer data) -{ - ViewFile *vf = data; - vf_selection_to_mark(vf, vf->active_mark, STM_MODE_SET); -} - -static void vflist_pop_menu_res_mark_sel_cb(GtkWidget *widget, gpointer data) -{ - ViewFile *vf = data; - vf_selection_to_mark(vf, vf->active_mark, STM_MODE_RESET); -} - -static void vflist_pop_menu_toggle_mark_sel_cb(GtkWidget *widget, gpointer data) -{ - ViewFile *vf = data; - vf_selection_to_mark(vf, vf->active_mark, STM_MODE_TOGGLE); -} - - static void vflist_popup_destroy_cb(GtkWidget *widget, gpointer data) { ViewFile *vf = data; @@ -535,24 +398,24 @@ vf->active_mark = mark; menu_item_add_sensitive(menu, str_set_mark, active, - G_CALLBACK(vflist_pop_menu_set_mark_sel_cb), vf); + G_CALLBACK(vf_pop_menu_set_mark_sel_cb), vf); menu_item_add_sensitive(menu, str_res_mark, active, - G_CALLBACK(vflist_pop_menu_res_mark_sel_cb), vf); + G_CALLBACK(vf_pop_menu_res_mark_sel_cb), vf); menu_item_add_sensitive(menu, str_toggle_mark, active, - G_CALLBACK(vflist_pop_menu_toggle_mark_sel_cb), vf); + G_CALLBACK(vf_pop_menu_toggle_mark_sel_cb), vf); menu_item_add_divider(menu); menu_item_add_sensitive(menu, str_sel_mark, active, - G_CALLBACK(vflist_pop_menu_sel_mark_cb), vf); + G_CALLBACK(vf_pop_menu_sel_mark_cb), vf); menu_item_add_sensitive(menu, str_sel_mark_or, active, - G_CALLBACK(vflist_pop_menu_sel_mark_or_cb), vf); + G_CALLBACK(vf_pop_menu_sel_mark_or_cb), vf); menu_item_add_sensitive(menu, str_sel_mark_and, active, - G_CALLBACK(vflist_pop_menu_sel_mark_and_cb), vf); + G_CALLBACK(vf_pop_menu_sel_mark_and_cb), vf); menu_item_add_sensitive(menu, str_sel_mark_minus, active, - G_CALLBACK(vflist_pop_menu_sel_mark_minus_cb), vf); + G_CALLBACK(vf_pop_menu_sel_mark_minus_cb), vf); menu_item_add_divider(menu); @@ -565,40 +428,40 @@ g_free(str_sel_mark_minus); } - submenu_add_edit(menu, &item, G_CALLBACK(vflist_pop_menu_edit_cb), vf); + submenu_add_edit(menu, &item, G_CALLBACK(vf_pop_menu_edit_cb), vf); gtk_widget_set_sensitive(item, active); menu_item_add_stock_sensitive(menu, _("_Properties"), GTK_STOCK_PROPERTIES, active, - G_CALLBACK(vflist_pop_menu_info_cb), vf); + G_CALLBACK(vf_pop_menu_info_cb), vf); menu_item_add_stock_sensitive(menu, _("View in _new window"), GTK_STOCK_NEW, active, G_CALLBACK(vflist_pop_menu_view_cb), vf); menu_item_add_divider(menu); menu_item_add_stock_sensitive(menu, _("_Copy..."), GTK_STOCK_COPY, active, - G_CALLBACK(vflist_pop_menu_copy_cb), vf); + G_CALLBACK(vf_pop_menu_copy_cb), vf); menu_item_add_sensitive(menu, _("_Move..."), active, - G_CALLBACK(vflist_pop_menu_move_cb), vf); + G_CALLBACK(vf_pop_menu_move_cb), vf); menu_item_add_sensitive(menu, _("_Rename..."), active, G_CALLBACK(vflist_pop_menu_rename_cb), vf); menu_item_add_stock_sensitive(menu, _("_Delete..."), GTK_STOCK_DELETE, active, - G_CALLBACK(vflist_pop_menu_delete_cb), vf); + G_CALLBACK(vf_pop_menu_delete_cb), vf); if (options->show_copy_path) menu_item_add_sensitive(menu, _("_Copy path"), active, - G_CALLBACK(vflist_pop_menu_copy_path_cb), vf); + G_CALLBACK(vf_pop_menu_copy_path_cb), vf); menu_item_add_divider(menu); - submenu = submenu_add_sort(NULL, G_CALLBACK(vflist_pop_menu_sort_cb), vf, + submenu = submenu_add_sort(NULL, G_CALLBACK(vf_pop_menu_sort_cb), vf, FALSE, FALSE, TRUE, vf->sort_method); menu_item_add_divider(submenu); menu_item_add_check(submenu, _("Ascending"), vf->sort_ascend, - G_CALLBACK(vflist_pop_menu_sort_ascend_cb), vf); + G_CALLBACK(vf_pop_menu_sort_ascend_cb), vf); item = menu_item_add(menu, _("_Sort"), NULL, NULL); gtk_menu_item_set_submenu(GTK_MENU_ITEM(item), submenu); menu_item_add_check(menu, _("View as _icons"), FALSE, - G_CALLBACK(vflist_pop_menu_icons_cb), vf); + G_CALLBACK(vf_pop_menu_toggle_view_type_cb), vf); menu_item_add_check(menu, _("Show _thumbnails"), VFLIST_INFO(vf, thumbs_enabled), G_CALLBACK(vflist_pop_menu_thumbs_cb), vf); menu_item_add_stock(menu, _("Re_fresh"), GTK_STOCK_REFRESH, G_CALLBACK(vflist_pop_menu_refresh_cb), vf);