mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Bug #525821 new or edited account names should be checked for reserved chars like ":"
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@18883 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
cec36eea50
commit
18ecb2c28c
@ -1161,6 +1161,36 @@ gnc_account_type_view_create (AccountWindow *aw)
|
||||
gnc_tree_model_account_types_set_selection(selection, 1 << aw->type);
|
||||
}
|
||||
|
||||
static void
|
||||
gnc_account_name_insert_text_cb (GtkWidget *entry,
|
||||
const gchar *text,
|
||||
gint length,
|
||||
gint *position,
|
||||
gpointer data)
|
||||
{
|
||||
GtkEditable *editable = GTK_EDITABLE( entry );
|
||||
const gchar *separator = NULL;
|
||||
gchar **strsplit;
|
||||
|
||||
separator = gnc_get_account_separator_string();
|
||||
strsplit = g_strsplit ( text, separator, 0 );
|
||||
if ( strsplit[1] != NULL )
|
||||
{
|
||||
gchar *result = g_strjoinv ( NULL, strsplit );
|
||||
g_signal_handlers_block_by_func ( G_OBJECT ( editable ),
|
||||
G_CALLBACK ( gnc_account_name_insert_text_cb ),
|
||||
data );
|
||||
gtk_editable_insert_text ( editable, result, g_utf8_strlen ( result, -1 ), position );
|
||||
g_signal_handlers_unblock_by_func ( G_OBJECT ( editable ),
|
||||
G_CALLBACK ( gnc_account_name_insert_text_cb ),
|
||||
data );
|
||||
g_signal_stop_emission_by_name (G_OBJECT ( editable ), "insert_text");
|
||||
g_free (result);
|
||||
}
|
||||
|
||||
g_strfreev ( strsplit );
|
||||
}
|
||||
|
||||
static void
|
||||
gnc_account_name_changed_cb(GtkWidget *widget, gpointer data)
|
||||
{
|
||||
@ -1281,6 +1311,8 @@ gnc_account_window_create(AccountWindow *aw)
|
||||
aw->notebook = glade_xml_get_widget (xml, "account_notebook");
|
||||
|
||||
aw->name_entry = glade_xml_get_widget (xml, "name_entry");
|
||||
g_signal_connect (G_OBJECT (aw->name_entry), "insert-text",
|
||||
G_CALLBACK (gnc_account_name_insert_text_cb), aw);
|
||||
g_signal_connect (G_OBJECT (aw->name_entry), "changed",
|
||||
G_CALLBACK (gnc_account_name_changed_cb), aw);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user