From 0dd6923f3b5f44fdaed2a1d1060f7b8df5e7014c Mon Sep 17 00:00:00 2001 From: Colin Clark Date: Sat, 17 Jun 2017 09:14:58 +0100 Subject: [PATCH] Fix #280: Set defaults for Auto Rename https://github.com/BestImageViewer/geeqie/issues/280 Remember last used settings --- src/options.h | 8 ++++++++ src/rcfile.c | 12 ++++++++++++ src/utilops.c | 14 ++++++++++---- 3 files changed, 30 insertions(+), 4 deletions(-) diff --git a/src/options.h b/src/options.h index 4a6c7762..11acdcbb 100644 --- a/src/options.h +++ b/src/options.h @@ -257,6 +257,14 @@ struct _ConfOptions gboolean fs_temp_disable; } tmp; } stereo; + + /* copy move rename */ + struct { + gint auto_start; + gchar *auto_end; + gint auto_padding; + gint formatted_start; + } cp_mv_rn; }; ConfOptions *options; diff --git a/src/rcfile.c b/src/rcfile.c index cf2f4746..ec853789 100644 --- a/src/rcfile.c +++ b/src/rcfile.c @@ -463,6 +463,12 @@ static void write_global_attributes(GString *outstr, gint indent) WRITE_NL(); WRITE_INT(*options, stereo.fixed_y1); WRITE_NL(); WRITE_INT(*options, stereo.fixed_x2); WRITE_NL(); WRITE_INT(*options, stereo.fixed_y2); + + /* copy move rename */ + WRITE_NL(); WRITE_INT(*options, cp_mv_rn.auto_start); + WRITE_NL(); WRITE_INT(*options, cp_mv_rn.auto_padding); + WRITE_NL(); WRITE_CHAR(*options, cp_mv_rn.auto_end); + WRITE_NL(); WRITE_INT(*options, cp_mv_rn.formatted_start); } static void write_color_profile(GString *outstr, gint indent) @@ -747,6 +753,12 @@ static gboolean load_global_params(const gchar **attribute_names, const gchar ** if (READ_INT(*options, stereo.fixed_x2)) continue; if (READ_INT(*options, stereo.fixed_y2)) continue; + /* copy move rename */ + if (READ_INT(*options, cp_mv_rn.auto_start)) continue; + if (READ_INT(*options, cp_mv_rn.auto_padding)) continue; + if (READ_CHAR(*options, cp_mv_rn.auto_end)) continue; + if (READ_INT(*options, cp_mv_rn.formatted_start)) continue; + /* Dummy options */ if (READ_DUMMY(*options, image.dither_quality, "deprecated since 2012-08-13")) continue; diff --git a/src/utilops.c b/src/utilops.c index 4b042b6e..1cb26327 100644 --- a/src/utilops.c +++ b/src/utilops.c @@ -1291,13 +1291,19 @@ static void file_util_rename_preview_update(UtilityData *ud) format = gtk_entry_get_text(GTK_ENTRY(ud->format_entry)); + g_free(options->cp_mv_rn.auto_end); + options->cp_mv_rn.auto_end = g_strdup(end); + options->cp_mv_rn.auto_padding = padding; + if (mode == UTILITY_RENAME_FORMATTED) { start_n = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(ud->format_spin)); + options->cp_mv_rn.formatted_start = start_n; } else { start_n = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(ud->auto_spin_start)); + options->cp_mv_rn.auto_start = start_n; } store = gtk_tree_view_get_model(GTK_TREE_VIEW(ud->listview)); @@ -1687,19 +1693,19 @@ static void file_util_dialog_init_source_dest(UtilityData *ud, gboolean second_i box2 = furm_simple_vlabel(hbox, _("Start #"), FALSE); ud->auto_spin_start = pref_spin_new(box2, NULL, NULL, - 0.0, 1000000.0, 1.0, 0, 1.0, + 0.0, 1000000.0, 1.0, 0, options->cp_mv_rn.auto_start, G_CALLBACK(file_util_rename_preview_adj_cb), ud); box2 = furm_simple_vlabel(hbox, _("End text"), TRUE); - combo = history_combo_new(&ud->auto_entry_end, "", "numerical_rename_suffix", -1); + combo = history_combo_new(&ud->auto_entry_end, options->cp_mv_rn.auto_end, "numerical_rename_suffix", -1); g_signal_connect(G_OBJECT(ud->auto_entry_end), "changed", G_CALLBACK(file_util_rename_preview_entry_cb), ud); gtk_box_pack_start(GTK_BOX(box2), combo, TRUE, TRUE, 0); gtk_widget_show(combo); ud->auto_spin_pad = pref_spin_new(page, _("Padding:"), NULL, - 1.0, 8.0, 1.0, 0, 1.0, + 1.0, 8.0, 1.0, 0, options->cp_mv_rn.auto_padding, G_CALLBACK(file_util_rename_preview_adj_cb), ud); page = gtk_vbox_new(FALSE, PREF_PAD_GAP); @@ -1719,7 +1725,7 @@ static void file_util_dialog_init_source_dest(UtilityData *ud, gboolean second_i box2 = furm_simple_vlabel(hbox, _("Start #"), FALSE); ud->format_spin = pref_spin_new(box2, NULL, NULL, - 0.0, 1000000.0, 1.0, 0, 1.0, + 0.0, 1000000.0, 1.0, 0, options->cp_mv_rn.formatted_start, G_CALLBACK(file_util_rename_preview_adj_cb), ud); // gtk_combo_box_set_active(GTK_COMBO_BOX(ud->combo_type), 0); /* callback will take care of the rest */ -- 2.20.1