From f6fc25f48f4aa92ca110834d94c4eef4d68f2fc0 Mon Sep 17 00:00:00 2001 From: Colin Clark Date: Wed, 28 Apr 2021 11:17:05 +0100 Subject: [PATCH] Circular selection lists option An option in Preferences/Behavior to permit image selections to be traversed in a circular or non-circular manner. The default is "on" (circular) which is the method used until now. --- doc/docbook/GuideOptionsBehavior.xml | 8 ++++++++ src/layout_image.c | 14 ++++++++++++-- src/options.c | 1 + src/options.h | 2 ++ src/preferences.c | 6 ++++++ src/rcfile.c | 2 ++ 6 files changed, 31 insertions(+), 2 deletions(-) diff --git a/doc/docbook/GuideOptionsBehavior.xml b/doc/docbook/GuideOptionsBehavior.xml index 67e18506..1d3ae3b3 100644 --- a/doc/docbook/GuideOptionsBehavior.xml +++ b/doc/docbook/GuideOptionsBehavior.xml @@ -140,6 +140,14 @@ If selected, a single click will enter a directory, rather than the GTK+ default of a double click. + + + Circular selection lists + + + If selected, when traversing a list of selected images using Next or Previous Image, when the last or first image is encountered the focus moves to the beginning or end of the list. When deselected, focus will go no further than the start or end of the list. + + Save marks on exit diff --git a/src/layout_image.c b/src/layout_image.c index 4f1e7697..b26f956b 100644 --- a/src/layout_image.c +++ b/src/layout_image.c @@ -1618,7 +1618,12 @@ void layout_image_next(LayoutWindow *lw) if (y->next) layout_image_set_index(lw, GPOINTER_TO_INT(y->next->data)); else - layout_image_set_index(lw, GPOINTER_TO_INT(x->data)); + { + if (options->circular_selection_lists) + { + layout_image_set_index(lw, GPOINTER_TO_INT(x->data)); + } + } } while (x) x = g_list_remove(x, x->data); @@ -1691,7 +1696,12 @@ void layout_image_prev(LayoutWindow *lw) if (y->prev) layout_image_set_index(lw, GPOINTER_TO_INT(y->prev->data)); else - layout_image_set_index(lw, GPOINTER_TO_INT(last->data)); + { + if (options->circular_selection_lists) + { + layout_image_set_index(lw, GPOINTER_TO_INT(last->data)); + } + } } while (x) x = g_list_remove(x, x->data); diff --git a/src/options.c b/src/options.c index 371ab1df..0cf60928 100644 --- a/src/options.c +++ b/src/options.c @@ -187,6 +187,7 @@ ConfOptions *init_options(ConfOptions *options) options->tree_descend_subdirs = FALSE; options->view_dir_list_single_click_enter = TRUE; + options->circular_selection_lists = TRUE; options->update_on_time_change = TRUE; options->clipboard_selection = CLIPBOARD_BOTH; diff --git a/src/options.h b/src/options.h index c59161cc..c303f45d 100644 --- a/src/options.h +++ b/src/options.h @@ -45,6 +45,8 @@ struct _ConfOptions gboolean tree_descend_subdirs; gboolean view_dir_list_single_click_enter; + gboolean circular_selection_lists; + gboolean lazy_image_sync; gboolean update_on_time_change; diff --git a/src/preferences.c b/src/preferences.c index dbee9b5d..fa17431f 100644 --- a/src/preferences.c +++ b/src/preferences.c @@ -378,6 +378,7 @@ static void config_window_apply(void) options->tree_descend_subdirs = c_options->tree_descend_subdirs; options->view_dir_list_single_click_enter = c_options->view_dir_list_single_click_enter; + options->circular_selection_lists = c_options->circular_selection_lists; options->open_recent_list_maxsize = c_options->open_recent_list_maxsize; options->dnd_icon_size = c_options->dnd_icon_size; @@ -3287,6 +3288,7 @@ static void config_tab_behavior(GtkWidget *notebook) GtkWidget *collections_on_top; GtkWidget *hide_window_in_fullscreen; GtkWidget *checkbox; + GtkWidget *tmp; vbox = scrolled_notebook_page(notebook, _("Behavior")); @@ -3350,6 +3352,10 @@ static void config_tab_behavior(GtkWidget *notebook) pref_checkbox_new_int(group, _("List directory view uses single click to enter"), options->view_dir_list_single_click_enter, &c_options->view_dir_list_single_click_enter); + tmp = pref_checkbox_new_int(group, _("Circular selection lists"), + options->circular_selection_lists, &c_options->circular_selection_lists); + gtk_widget_set_tooltip_text(tmp, _("Traverse selection lists in a circular manner")); + marks = pref_checkbox_new_int(group, _("Save marks on exit"), options->marks_save, &c_options->marks_save); gtk_widget_set_tooltip_text(marks,"Note that marks linked to a keyword will be saved irrespective of this setting"); diff --git a/src/rcfile.c b/src/rcfile.c index accc7b3d..cac00af1 100644 --- a/src/rcfile.c +++ b/src/rcfile.c @@ -313,6 +313,7 @@ static void write_global_attributes(GString *outstr, gint indent) WRITE_NL(); WRITE_BOOL(*options, tree_descend_subdirs); WRITE_NL(); WRITE_BOOL(*options, view_dir_list_single_click_enter); + WRITE_NL(); WRITE_BOOL(*options, circular_selection_lists); WRITE_NL(); WRITE_BOOL(*options, lazy_image_sync); WRITE_NL(); WRITE_BOOL(*options, update_on_time_change); WRITE_SEPARATOR(); @@ -746,6 +747,7 @@ static gboolean load_global_params(const gchar **attribute_names, const gchar ** if (READ_BOOL(*options, tree_descend_subdirs)) continue; if (READ_BOOL(*options, view_dir_list_single_click_enter)) continue; + if (READ_BOOL(*options, circular_selection_lists)) continue; if (READ_BOOL(*options, lazy_image_sync)) continue; if (READ_BOOL(*options, update_on_time_change)) continue; -- 2.20.1