r21874 - gnucash/trunk/src/import-export/aqbanking - Bug #668454: Make it easier to paste account/bank in online transaction dialog
Christian Stimming
cstim at code.gnucash.org
Sun Jan 22 16:09:35 EST 2012
Author: cstim
Date: 2012-01-22 16:09:34 -0500 (Sun, 22 Jan 2012)
New Revision: 21874
Trac: http://svn.gnucash.org/trac/changeset/21874
Modified:
gnucash/trunk/src/import-export/aqbanking/dialog-ab-trans.c
Log:
Bug #668454: Make it easier to paste account/bank in online transaction dialog
Patch by Johannes Schmid (with indentation fixed by our usual astyle call):
The patch actually fixes two issues:
* Only allow digits in account/bank code field
* Filter spaces when pasting content.
This has annoyed me for a while because quite often I paste account
informations from the browser or some email into gnucash and people tend to
group the numbers like this:
BLZ: 763 510 40
The result of the paste is that the number looks like 763 510<end> because the
number of characters in the entry is limited. With the patch the spaces will be
removed and you will see
763 510 40 -> 76351040
Modified: gnucash/trunk/src/import-export/aqbanking/dialog-ab-trans.c
===================================================================
--- gnucash/trunk/src/import-export/aqbanking/dialog-ab-trans.c 2012-01-22 20:33:49 UTC (rev 21873)
+++ gnucash/trunk/src/import-export/aqbanking/dialog-ab-trans.c 2012-01-22 21:09:34 UTC (rev 21874)
@@ -72,6 +72,12 @@
void dat_sort_templ_cb(GtkButton *button, gpointer user_data);
void dat_del_templ_cb(GtkButton *button, gpointer user_data);
+static void entry_insert_cb (GtkEditable *editable,
+ const gchar *text,
+ gint length,
+ gint *position,
+ gpointer data);
+
enum
{
TEMPLATE_NAME,
@@ -276,6 +282,12 @@
td->template_gtktreeview =
GTK_TREE_VIEW(gtk_builder_get_object (builder, "template_list"));
+ /* Connect signals */
+ g_signal_connect (td->recp_account_entry, "insert-text",
+ G_CALLBACK (entry_insert_cb), td);
+ g_signal_connect (td->recp_bankcode_entry, "insert-text",
+ G_CALLBACK (entry_insert_cb), td);
+
/* Amount edit */
td->amount_edit = gnc_amount_edit_new();
gtk_box_pack_start_defaults(GTK_BOX(amount_hbox), td->amount_edit);
@@ -324,7 +336,7 @@
default:
g_critical("gnc_ab_trans_dialog_new: Oops, unknown GncABTransType %d",
trans_type);
- break;
+ break;
}
gtk_label_set_text(GTK_LABEL(orig_name_label), ab_ownername);
@@ -1063,3 +1075,35 @@
g_free(name);
LEAVE(" ");
}
+
+static void
+entry_insert_cb (GtkEditable *editable,
+ const gchar *text,
+ gint length,
+ gint *position,
+ gpointer data)
+{
+ GString* result = g_string_new(NULL);
+ gint i;
+
+ if (length == -1)
+ length = strlen(text);
+
+ /* Filter non digits */
+ for (i = 0; i < length; i++)
+ {
+ gchar c = text[i];
+ if (g_ascii_isdigit(c))
+ {
+ g_string_append_c(result, c);
+ }
+ }
+
+ g_signal_handlers_block_by_func (editable,
+ (gpointer) entry_insert_cb, data);
+ gtk_editable_insert_text (editable, result->str, result->len, position);
+ g_signal_handlers_unblock_by_func (editable,
+ (gpointer) entry_insert_cb, data);
+ g_signal_stop_emission_by_name (editable, "insert_text");
+ g_string_free (result, TRUE);
+}
More information about the gnucash-changes
mailing list