Skip to content

Commit

Permalink
Fix #280: Set defaults for Auto Rename
Browse files Browse the repository at this point in the history
#280

Remember last used settings
  • Loading branch information
caclark committed Jun 17, 2017
1 parent 68c4796 commit 0dd6923
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 4 deletions.
8 changes: 8 additions & 0 deletions src/options.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
12 changes: 12 additions & 0 deletions src/rcfile.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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;

Expand Down
14 changes: 10 additions & 4 deletions src/utilops.c
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down Expand Up @@ -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);
Expand All @@ -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 */
Expand Down

0 comments on commit 0dd6923

Please sign in to comment.