Mercurial > hg > forks > geeqie
changeset 2426:28546abc2b90
Fix #435: Remember duplicates settings
https://github.com/BestImageViewer/geeqie/issues/435
Preserve duplicates window settings - Compare By, Thumbnails and Group
Selected - between sessions
author | Colin Clark <cclark@mcb.net> |
---|---|
date | Sat, 07 Jan 2017 11:47:30 +0000 |
parents | 0af6b94854c2 |
children | 95afc4dda19f |
files | src/collect-table.c src/dupe.c src/dupe.h src/layout_util.c src/options.h src/rcfile.c src/view_dir.c src/view_file.c |
diffstat | 8 files changed, 63 insertions(+), 13 deletions(-) [+] |
line wrap: on
line diff
--- a/src/collect-table.c Fri Jan 06 13:20:26 2017 +0000 +++ b/src/collect-table.c Sat Jan 07 11:47:30 2017 +0000 @@ -861,7 +861,7 @@ CollectTable *ct = data; DupeWindow *dw; - dw = dupe_window_new(DUPE_MATCH_NAME); + dw = dupe_window_new(); dupe_window_add_collection(dw, ct->cd); }
--- a/src/dupe.c Fri Jan 06 13:20:26 2017 +0000 +++ b/src/dupe.c Sat Jan 07 11:47:30 2017 +0000 @@ -574,6 +574,8 @@ g_free(text[DUPE_COLUMN_DIMENSIONS]); } +static void dupe_listview_select_dupes(DupeWindow *dw, DupeSelectType parents); + static void dupe_listview_populate(DupeWindow *dw) { GtkListStore *store; @@ -607,6 +609,16 @@ } gtk_tree_view_columns_autosize(GTK_TREE_VIEW(dw->listview)); + + if (options->duplicates_select_type == DUPE_SELECT_GROUP1) + { + dupe_listview_select_dupes(dw, DUPE_SELECT_GROUP1); + } + else if (options->duplicates_select_type == DUPE_SELECT_GROUP2) + { + dupe_listview_select_dupes(dw, DUPE_SELECT_GROUP2); + } + } static void dupe_listview_remove(DupeWindow *dw, DupeItem *di) @@ -712,7 +724,7 @@ return found; } -static void dupe_listview_select_dupes(DupeWindow *dw, gint parents) +static void dupe_listview_select_dupes(DupeWindow *dw, DupeSelectType parents) { GtkTreeModel *store; GtkTreeSelection *selection; @@ -729,7 +741,7 @@ DupeItem *di; gtk_tree_model_get(store, &iter, DUPE_COLUMN_POINTER, &di, -1); - if ( (dupe_match_find_parent(dw, di) == di) == (parents) ) + if ((dupe_match_find_parent(dw, di) == di) == (parents == DUPE_SELECT_GROUP1)) { gtk_tree_selection_select_iter(selection, &iter); } @@ -2129,6 +2141,7 @@ DupeWindow *dw = data; GtkTreeSelection *selection; + options->duplicates_select_type = DUPE_SELECT_NONE; selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(dw->listview)); gtk_tree_selection_select_all(selection); } @@ -2138,6 +2151,7 @@ DupeWindow *dw = data; GtkTreeSelection *selection; + options->duplicates_select_type = DUPE_SELECT_NONE; selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(dw->listview)); gtk_tree_selection_unselect_all(selection); } @@ -2146,14 +2160,16 @@ { DupeWindow *dw = data; - dupe_listview_select_dupes(dw, TRUE); + options->duplicates_select_type = DUPE_SELECT_GROUP1; + dupe_listview_select_dupes(dw, DUPE_SELECT_GROUP1); } static void dupe_menu_select_dupes_set2_cb(GtkWidget *widget, gpointer data) { DupeWindow *dw = data; - dupe_listview_select_dupes(dw, FALSE); + options->duplicates_select_type = DUPE_SELECT_GROUP2; + dupe_listview_select_dupes(dw, DUPE_SELECT_GROUP2); } static void dupe_menu_edit_cb(GtkWidget *widget, gpointer data) @@ -2653,6 +2669,8 @@ if (!gtk_combo_box_get_active_iter(GTK_COMBO_BOX(combo), &iter)) return; gtk_tree_model_get(store, &iter, DUPE_MENU_COLUMN_MASK, &dw->match_mask, -1); + options->duplicates_match = dw->match_mask; + dupe_window_recompare(dw); } @@ -2827,6 +2845,7 @@ DupeWindow *dw = data; dw->show_thumbs = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(widget)); + options->duplicates_thumbnails = dw->show_thumbs; if (dw->show_thumbs) { @@ -3023,10 +3042,12 @@ } break; case '1': - dupe_listview_select_dupes(dw, TRUE); + options->duplicates_select_type == DUPE_SELECT_GROUP1; + dupe_listview_select_dupes(dw, DUPE_SELECT_GROUP1); break; case '2': - dupe_listview_select_dupes(dw, FALSE); + options->duplicates_select_type == DUPE_SELECT_GROUP2; + dupe_listview_select_dupes(dw, DUPE_SELECT_GROUP2); break; case GDK_KEY_Menu: case GDK_KEY_F10: @@ -3108,7 +3129,7 @@ } /* collection and files can be NULL */ -DupeWindow *dupe_window_new(DupeMatchType match_mask) +DupeWindow *dupe_window_new() { DupeWindow *dw; GtkWidget *vbox; @@ -3123,7 +3144,18 @@ dw = g_new0(DupeWindow, 1); - dw->match_mask = match_mask; + dw->match_mask = DUPE_MATCH_NAME; + if (options->duplicates_match == DUPE_MATCH_NAME) dw->match_mask = DUPE_MATCH_NAME; + if (options->duplicates_match == DUPE_MATCH_SIZE) dw->match_mask = DUPE_MATCH_SIZE; + if (options->duplicates_match == DUPE_MATCH_DATE) dw->match_mask = DUPE_MATCH_DATE; + if (options->duplicates_match == DUPE_MATCH_DIM) dw->match_mask = DUPE_MATCH_DIM; + if (options->duplicates_match == DUPE_MATCH_SUM) dw->match_mask = DUPE_MATCH_SUM; + if (options->duplicates_match == DUPE_MATCH_PATH) dw->match_mask = DUPE_MATCH_PATH; + if (options->duplicates_match == DUPE_MATCH_SIM_HIGH) dw->match_mask = DUPE_MATCH_SIM_HIGH; + if (options->duplicates_match == DUPE_MATCH_SIM_MED) dw->match_mask = DUPE_MATCH_SIM_MED; + if (options->duplicates_match == DUPE_MATCH_SIM_LOW) dw->match_mask = DUPE_MATCH_SIM_LOW; + if (options->duplicates_match == DUPE_MATCH_SIM_CUSTOM) dw->match_mask = DUPE_MATCH_SIM_CUSTOM; + if (options->duplicates_match == DUPE_MATCH_NAME_CI) dw->match_mask = DUPE_MATCH_NAME_CI; dw->window = window_new(GTK_WINDOW_TOPLEVEL, "dupe", NULL, NULL, _("Find duplicates")); @@ -3229,6 +3261,7 @@ gtk_widget_show(dw->combo); dw->button_thumbs = gtk_check_button_new_with_label(_("Thumbnails")); + dw->show_thumbs = options->duplicates_thumbnails; gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(dw->button_thumbs), dw->show_thumbs); g_signal_connect(G_OBJECT(dw->button_thumbs), "toggled", G_CALLBACK(dupe_window_show_thumb_cb), dw);
--- a/src/dupe.h Fri Jan 06 13:20:26 2017 +0000 +++ b/src/dupe.h Sat Jan 07 11:47:30 2017 +0000 @@ -41,6 +41,13 @@ DUPE_MATCH_NAME_CI = 1 << 10 /* same as name, but case insensitive */ } DupeMatchType; +typedef enum +{ + DUPE_SELECT_NONE, + DUPE_SELECT_GROUP1, + DUPE_SELECT_GROUP2 +} DupeSelectType; + typedef struct _DupeItem DupeItem; struct _DupeItem { @@ -119,7 +126,7 @@ }; -DupeWindow *dupe_window_new(DupeMatchType match_mask); +DupeWindow *dupe_window_new(void); void dupe_window_clear(DupeWindow *dw); void dupe_window_close(DupeWindow *dw);
--- a/src/layout_util.c Fri Jan 06 13:20:26 2017 +0000 +++ b/src/layout_util.c Sat Jan 07 11:47:30 2017 +0000 @@ -248,7 +248,7 @@ LayoutWindow *lw = data; layout_exit_fullscreen(lw); - dupe_window_new(DUPE_MATCH_NAME); + dupe_window_new(); } static void layout_menu_pan_cb(GtkAction *action, gpointer data)
--- a/src/options.h Fri Jan 06 13:20:26 2017 +0000 +++ b/src/options.h Sat Jan 07 11:47:30 2017 +0000 @@ -41,6 +41,9 @@ gboolean update_on_time_change; guint duplicates_similarity_threshold; + guint duplicates_match; + gboolean duplicates_thumbnails; + guint duplicates_select_type; gboolean rot_invariant_sim; gint open_recent_list_maxsize;
--- a/src/rcfile.c Fri Jan 06 13:20:26 2017 +0000 +++ b/src/rcfile.c Sat Jan 07 11:47:30 2017 +0000 @@ -43,6 +43,7 @@ #include "bar.h" #include "metadata.h" #include "bar_gps.h" +#include "dupe.h" /* @@ -317,6 +318,9 @@ WRITE_NL(); WRITE_UINT(*options, keyboard_scroll_step); WRITE_NL(); WRITE_UINT(*options, duplicates_similarity_threshold); + WRITE_NL(); WRITE_UINT(*options, duplicates_match); + WRITE_NL(); WRITE_UINT(*options, duplicates_select_type); + WRITE_NL(); WRITE_BOOL(*options, duplicates_thumbnails); WRITE_NL(); WRITE_BOOL(*options, rot_invariant_sim); WRITE_SEPARATOR(); @@ -594,6 +598,9 @@ if (READ_BOOL(*options, update_on_time_change)) continue; if (READ_UINT_CLAMP(*options, duplicates_similarity_threshold, 0, 100)) continue; + if (READ_UINT_CLAMP(*options, duplicates_match, 0, DUPE_MATCH_NAME_CI)) continue; + if (READ_UINT_CLAMP(*options, duplicates_select_type, 0, DUPE_SELECT_GROUP2)) continue; + if (READ_BOOL(*options, duplicates_thumbnails)) continue; if (READ_BOOL(*options, rot_invariant_sim)) continue; if (READ_BOOL(*options, progressive_key_scrolling)) continue;