From 63420660a443d3a98d556ef90da3d079d058c4cb Mon Sep 17 00:00:00 2001 From: Vladimir Nadvornik Date: Mon, 28 Sep 2009 09:57:06 +0000 Subject: [PATCH] consider sidecars in layout_image popup menu --- src/layout_image.c | 9 ++++++++- src/view_file.c | 13 +++++++++++++ src/view_file.h | 1 + src/view_file_icon.c | 8 ++++++-- src/view_file_icon.h | 1 + src/view_file_list.c | 30 +++++++++++++++++------------- src/view_file_list.h | 1 + 7 files changed, 47 insertions(+), 16 deletions(-) diff --git a/src/layout_image.c b/src/layout_image.c index c9752cad..4156ef3c 100644 --- a/src/layout_image.c +++ b/src/layout_image.c @@ -33,6 +33,7 @@ #include "ui_menu.h" #include "uri_utils.h" #include "utilops.h" +#include "view_file.h" #include /* for keyboard values */ @@ -460,7 +461,13 @@ static GList *layout_image_get_fd_list(LayoutWindow *lw) FileData *fd = layout_image_get_fd(lw); if (fd) - list = g_list_append(NULL, file_data_ref(fd)); + { + if (lw->vf) + /* optionally include sidecars if the filelist entry is not expanded */ + list = vf_selection_get_one(lw->vf, fd); + else + list = g_list_append(NULL, file_data_ref(fd)); + } return list; } diff --git a/src/view_file.c b/src/view_file.c index 18624582..b44b3381 100644 --- a/src/view_file.c +++ b/src/view_file.c @@ -310,6 +310,19 @@ GList *vf_pop_menu_file_list(ViewFile *vf) return ret; } +GList *vf_selection_get_one(ViewFile *vf, FileData *fd) +{ + GList *ret = NULL; + + switch (vf->type) + { + case FILEVIEW_LIST: ret = vflist_selection_get_one(vf, fd); break; + case FILEVIEW_ICON: ret = vficon_selection_get_one(vf, fd); break; + } + + return ret; +} + static void vf_pop_menu_edit_cb(GtkWidget *widget, gpointer data) { ViewFile *vf; diff --git a/src/view_file.h b/src/view_file.h index 2cb2d72b..d410c969 100644 --- a/src/view_file.h +++ b/src/view_file.h @@ -37,6 +37,7 @@ void vf_sort_set(ViewFile *vf, SortType type, gboolean ascend); guint vf_marks_get_filter(ViewFile *vf); void vf_mark_filter_toggle(ViewFile *vf, gint mark); +GList *vf_selection_get_one(ViewFile *vf, FileData *fd); GList *vf_pop_menu_file_list(ViewFile *vf); GtkWidget *vf_pop_menu(ViewFile *vf); diff --git a/src/view_file_icon.c b/src/view_file_icon.c index eca8b073..00a83ad6 100644 --- a/src/view_file_icon.c +++ b/src/view_file_icon.c @@ -161,6 +161,11 @@ static void vficon_populate_at_new_size(ViewFile *vf, gint w, gint h, gboolean f *----------------------------------------------------------------------------- */ +GList *vficon_selection_get_one(ViewFile *vf, FileData *fd) +{ + return g_list_prepend(filelist_copy(fd->sidecar_files), file_data_ref(fd)); +} + GList *vficon_pop_menu_file_list(ViewFile *vf) { if (!VFICON(vf)->click_id) return NULL; @@ -170,8 +175,7 @@ GList *vficon_pop_menu_file_list(ViewFile *vf) return vf_selection_get_list(vf); } - - return g_list_prepend(filelist_copy(VFICON(vf)->click_id->fd->sidecar_files), file_data_ref(VFICON(vf)->click_id->fd)); + return vficon_selection_get_one(vf, VFICON(vf)->click_id->fd); } void vficon_pop_menu_view_cb(GtkWidget *widget, gpointer data) diff --git a/src/view_file_icon.h b/src/view_file_icon.h index b4dcbf47..3c6084d3 100644 --- a/src/view_file_icon.h +++ b/src/view_file_icon.h @@ -29,6 +29,7 @@ void vficon_sort_set(ViewFile *vf, SortType type, gboolean ascend); void vficon_marks_set(ViewFile *vf, gboolean enable); +GList *vficon_selection_get_one(ViewFile *vf, FileData *fd); GList *vficon_pop_menu_file_list(ViewFile *vf); void vficon_pop_menu_view_cb(GtkWidget *widget, gpointer data); void vficon_pop_menu_rename_cb(GtkWidget *widget, gpointer data); diff --git a/src/view_file_list.c b/src/view_file_list.c index 4bd4506f..8825244f 100644 --- a/src/view_file_list.c +++ b/src/view_file_list.c @@ -363,26 +363,18 @@ void vflist_dnd_init(ViewFile *vf) *----------------------------------------------------------------------------- */ -GList *vflist_pop_menu_file_list(ViewFile *vf) +GList *vflist_selection_get_one(ViewFile *vf, FileData *fd) { - GList *list; - if (!VFLIST(vf)->click_fd) return NULL; + GList *list = g_list_append(NULL, file_data_ref(fd)); - if (vflist_row_is_selected(vf, VFLIST(vf)->click_fd)) - { - return vf_selection_get_list(vf); - } - - list = g_list_append(NULL, file_data_ref(VFLIST(vf)->click_fd)); - - if (VFLIST(vf)->click_fd->sidecar_files) + if (fd->sidecar_files) { /* check if the row is expanded */ GtkTreeModel *store; GtkTreeIter iter; store = gtk_tree_view_get_model(GTK_TREE_VIEW(vf->listview)); - if (vflist_find_row(vf, VFLIST(vf)->click_fd, &iter) >= 0) + if (vflist_find_row(vf, fd, &iter) >= 0) { GtkTreePath *tpath; @@ -390,7 +382,7 @@ GList *vflist_pop_menu_file_list(ViewFile *vf) if (!gtk_tree_view_row_expanded(GTK_TREE_VIEW(vf->listview), tpath)) { /* unexpanded - add whole group */ - GList *work = VFLIST(vf)->click_fd->sidecar_files; + GList *work = fd->sidecar_files; while (work) { FileData *sfd = work->data; @@ -406,6 +398,18 @@ GList *vflist_pop_menu_file_list(ViewFile *vf) return list; } +GList *vflist_pop_menu_file_list(ViewFile *vf) +{ + if (!VFLIST(vf)->click_fd) return NULL; + + if (vflist_row_is_selected(vf, VFLIST(vf)->click_fd)) + { + return vf_selection_get_list(vf); + } + return vflist_selection_get_one(vf, VFLIST(vf)->click_fd); +} + + void vflist_pop_menu_view_cb(GtkWidget *widget, gpointer data) { ViewFile *vf = data; diff --git a/src/view_file_list.h b/src/view_file_list.h index edc825c2..e1ea32a2 100644 --- a/src/view_file_list.h +++ b/src/view_file_list.h @@ -32,6 +32,7 @@ void vflist_thumb_set(ViewFile *vf, gboolean enable); void vflist_marks_set(ViewFile *vf, gboolean enable); void vflist_sort_set(ViewFile *vf, SortType type, gboolean ascend); +GList *vflist_selection_get_one(ViewFile *vf, FileData *fd); GList *vflist_pop_menu_file_list(ViewFile *vf); void vflist_pop_menu_view_cb(GtkWidget *widget, gpointer data); void vflist_pop_menu_rename_cb(GtkWidget *widget, gpointer data); -- 2.20.1