Index: src/gnome-utils/dialog-account.c
===================================================================
--- src/gnome-utils/dialog-account.c (revision 17190)
+++ src/gnome-utils/dialog-account.c (working copy)
@@ -119,9 +119,11 @@
{
GtkWidget *dialog;
GtkWidget *prefix;
+ GtkWidget *beginat;
GtkWidget *interval;
GtkWidget *example1;
GtkWidget *example2;
+ GtkWidget *example3;
Account *parent;
gint num_children;
@@ -138,6 +140,7 @@
static void gnc_account_window_set_name (AccountWindow *aw);
void gnc_account_renumber_prefix_changed_cb (GtkEditable *editable, RenumberDialog *data);
+void gnc_account_renumber_beginat_changed_cb (GtkEditable *editable, RenumberDialog *data);
void gnc_account_renumber_interval_changed_cb (GtkSpinButton *spinbutton, RenumberDialog *data);
void gnc_account_renumber_response_cb (GtkDialog *dialog, gint response, RenumberDialog *data);
@@ -1744,23 +1747,32 @@
gnc_account_renumber_update_examples (RenumberDialog *data)
{
gchar *str;
- gchar *prefix;
- gint interval, num_digits;
+ gchar *prefix, *beginat;
+ gint interval, beginint, num_digits;
prefix = gtk_editable_get_chars(GTK_EDITABLE(data->prefix), 0, -1);
+ beginat = gtk_editable_get_chars(GTK_EDITABLE(data->beginat), 0, -1);
+ beginint = strtol(beginat, NULL, 10);
interval = gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(data->interval));
- num_digits = log10(data->num_children * interval) + 1;
+ num_digits = MAX(strlen(beginat), log10(data->num_children * interval) + 1);
+ if (num_digits > 12)
+ num_digits = 12; /* Prevent insanity */
- str = g_strdup_printf("%s-%0*d", prefix, num_digits, interval);
+ str = g_strdup_printf("%s%0*d", prefix, num_digits, beginint);
gtk_label_set_text(GTK_LABEL(data->example1), str);
g_free(str);
- str = g_strdup_printf("%s-%0*d", prefix, num_digits,
- interval * data->num_children);
+ str = g_strdup_printf("%s%0*d", prefix, num_digits, beginint + interval);
gtk_label_set_text(GTK_LABEL(data->example2), str);
g_free(str);
+ str = g_strdup_printf("%s%0*d", prefix, num_digits,
+ beginint + interval * data->num_children);
+ gtk_label_set_text(GTK_LABEL(data->example3), str);
+ g_free(str);
+
g_free(prefix);
+ g_free(beginat);
}
void
@@ -1771,6 +1783,13 @@
}
void
+gnc_account_renumber_beginat_changed_cb (GtkEditable *editable,
+ RenumberDialog *data)
+{
+ gnc_account_renumber_update_examples(data);
+}
+
+void
gnc_account_renumber_interval_changed_cb (GtkSpinButton *spinbutton,
RenumberDialog *data)
{
@@ -1784,25 +1803,31 @@
{
GList *children, *tmp;
gchar *str;
- gchar *prefix;
- gint interval, num_digits, i;
+ gchar *prefix, *beginat;
+ gint beginint, interval, num_digits, i;
if (response == GTK_RESPONSE_OK) {
gtk_widget_hide(data->dialog);
children = gnc_account_get_children(data->parent);
prefix = gtk_editable_get_chars(GTK_EDITABLE(data->prefix), 0, -1);
+ beginat = gtk_editable_get_chars(GTK_EDITABLE(data->beginat), 0, -1);
+ beginint = strtol(beginat, NULL, 10);
interval =
gtk_spin_button_get_value_as_int(GTK_SPIN_BUTTON(data->interval));
- num_digits = log10(data->num_children * interval) + 1;
+ num_digits = MAX(strlen(beginat), log10(data->num_children * interval) + 1);
+ if (num_digits > 12)
+ num_digits = 12; /* Prevent insanity */
gnc_set_busy_cursor (NULL, TRUE);
- for (tmp = children, i = 1; tmp; tmp = g_list_next(tmp), i += 1) {
- str = g_strdup_printf("%s-%0*d", prefix, num_digits, interval * i);
+ for (tmp = children, i = 0; tmp; tmp = g_list_next(tmp), i += 1) {
+ str = g_strdup_printf("%s%0*d", prefix, num_digits, beginint + interval * i);
xaccAccountSetCode(tmp->data, str);
g_free(str);
}
gnc_unset_busy_cursor (NULL);
g_list_free(children);
+ g_free(prefix);
+ g_free(beginat);
}
gtk_widget_destroy(data->dialog);
@@ -1827,19 +1852,23 @@
g_object_set_data_full(G_OBJECT(data->dialog), "xml", xml, g_object_unref);
widget = glade_xml_get_widget (xml, "header_label");
- string = g_strdup_printf(_( "Renumber the immediate sub-accounts of %s? "
- "This will replace the account code field of "
+ string = g_strdup_printf(_( "Renumber the immediate sub-accounts of %s. "
+ "ie. replace the account code field of "
"each child account with a newly generated code."),
xaccAccountGetFullName(account));
gtk_label_set_text(GTK_LABEL(widget), string);
g_free(string);
data->prefix = glade_xml_get_widget (xml, "prefix_entry");
+ data->beginat = glade_xml_get_widget (xml, "beginat_entry");
data->interval = glade_xml_get_widget (xml, "interval_spin");
data->example1 = glade_xml_get_widget (xml, "example1_label");
data->example2 = glade_xml_get_widget (xml, "example2_label");
+ data->example3 = glade_xml_get_widget (xml, "example3_label");
- gtk_entry_set_text(GTK_ENTRY(data->prefix), xaccAccountGetCode(account));
+ string = g_strdup_printf("%s-", xaccAccountGetCode(account));
+ gtk_entry_set_text(GTK_ENTRY(data->prefix), string);
+ g_free(string);
gnc_account_renumber_update_examples(data);
glade_xml_signal_autoconnect_full(xml, gnc_glade_autoconnect_full_func,
Index: src/gnome/glade/account.glade
===================================================================
--- src/gnome/glade/account.glade (revision 17190)
+++ src/gnome/glade/account.glade (working copy)
@@ -3530,7 +3530,7 @@
True
- 5
+ 8
2
False
6
@@ -3635,8 +3635,8 @@
0
1
- 3
- 4
+ 4
+ 5
fill
@@ -3663,14 +3663,98 @@
1
2
- 3
- 4
+ 4
+ 5
fill
+
+ True
+ ...
+ False
+ False
+ GTK_JUSTIFY_LEFT
+ False
+ False
+ 0
+ 0.5
+ 0
+ 0
+ PANGO_ELLIPSIZE_NONE
+ -1
+ False
+ 0
+
+
+ 1
+ 2
+ 6
+ 7
+ fill
+
+
+
+
+
+
+ True
+
+ False
+ False
+ GTK_JUSTIFY_LEFT
+ False
+ False
+ 0
+ 0.5
+ 0
+ 0
+ PANGO_ELLIPSIZE_NONE
+ -1
+ False
+ 0
+
+
+ 1
+ 2
+ 5
+ 6
+ fill
+
+
+
+
+
+
+ True
+
+ False
+ False
+ GTK_JUSTIFY_LEFT
+ False
+ False
+ 0
+ 0.5
+ 0
+ 0
+ PANGO_ELLIPSIZE_NONE
+ -1
+ False
+ 0
+
+
+ 1
+ 2
+ 7
+ 8
+ fill
+
+
+
+
+
True
Interval:
@@ -3691,8 +3775,8 @@
0
1
- 2
- 3
+ 3
+ 4
fill
@@ -3714,16 +3798,16 @@
1
2
- 2
- 3
+ 3
+ 4
-
+
True
-
+ Begin at:
False
False
GTK_JUSTIFY_LEFT
@@ -3739,11 +3823,33 @@
0
+ 0
+ 1
+ 2
+ 3
+ fill
+
+
+
+
+
+
+ True
+ True
+ True
+ True
+ 12
+ 00
+ True
+ *
+ False
+
+
+
1
2
- 4
- 5
- fill
+ 2
+ 3