* src/register/ledger-core/dialog-dup-trans.c: If the "number" is

set to 0, then empty out the entry.  Considering the SpinButton
	  wants to force a digit, this lets you set an empty number if you
	  accidentally tab into and out of the number field.  This also
	  means you cannot have a check numbered '0', but that is probably
	  a reasonable limitation.  Fixes #109610.


git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@8411 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Derek Atkins 2003-05-27 02:11:34 +00:00
parent ff366530f6
commit ef61c14495
2 changed files with 72 additions and 2 deletions

View File

@ -1,11 +1,24 @@
2003-05-26 Derek Atkins <derek@ihtfp.com>
* src/register/ledger-core/dialog-dup-trans.c: If the "number" is
set to 0, then empty out the entry. Considering the SpinButton
wants to force a digit, this lets you set an empty number if you
accidentally tab into and out of the number field. This also
means you cannot have a check numbered '0', but that is probably
a reasonable limitation. Fixes #109610.
2003-05-26 Chris Lyttle <chris@wilddev.net> 2003-05-26 Chris Lyttle <chris@wilddev.net>
* src/scm/main.scm: Change stable version to 1.8.4 * src/scm/main.scm: Change stable version to 1.8.4
2003-05-26 Benoit Grégoire <bock@step.polymtl.ca> 2003-05-26 Benoit Grégoire <bock@step.polymtl.ca>
* src/import-export/import-settings.c: Fix pref page define to the proper page, should fix the problem of all prefs being ignored. Also make strings in the lookup code translatable so that the matching won't be lost when changing language. * src/import-export/import-settings.c: Fix pref page define to the
* src/import-export/generic-import.scm: Add note not to forget to change the c file as well when changing preference page. proper page, should fix the problem of all prefs being ignored.
Also make strings in the lookup code translatable so that the
matching won't be lost when changing language.
* src/import-export/generic-import.scm: Add note not to forget to
change the c file as well when changing preference page.
2003-05-25 Derek Atkins <derek@ihtfp.com> 2003-05-25 Derek Atkins <derek@ihtfp.com>

View File

@ -40,6 +40,8 @@ typedef struct
{ {
GtkWidget * dialog; GtkWidget * dialog;
gboolean focus_out;
GtkWidget * date_edit; GtkWidget * date_edit;
GtkWidget * num_edit; GtkWidget * num_edit;
} DupTransDialog; } DupTransDialog;
@ -70,6 +72,56 @@ parse_num (const char *string, long int *num)
return TRUE; return TRUE;
} }
/*
* This code works around an annoying bug in the SpinButton -- as soon
* as you focus into the spin button it wants to force a digit to
* appear and there is nothing the user can do. Once you focus in,
* the user cannot make the spin button entry be empty.
*
* To make matters worse, the spin button draws this number AFTER a
* focus-out event, so we can't just use that event to clear it out.
*
* To work around this problem we hook into two signals, focus-out and
* draw. The focus-out event lets us know when we leave the
* spinbutton entry, and we set a flag to remember this fact, and also
* queue a redraw (just to be sure). The draw event happens more
* frequently, but also happens after the spin button digitizes
* itself. So when we hit a draw event we can check the flag and if
* it's set we can potentially empty out the entry.
*
* This also means you cannot have a check numbered "0", but that is
* probably a reasonable limitation.
*/
static void
gnc_dup_trans_focus_out_cb (GtkSpinButton *button, GdkEventFocus *event,
gpointer user_data)
{
DupTransDialog *dt_dialog = user_data;
g_return_if_fail(GTK_IS_SPIN_BUTTON(button));
if (!dt_dialog) return;
dt_dialog->focus_out = TRUE;
gtk_widget_queue_draw(GTK_WIDGET(button));
}
static void
gnc_dup_trans_draw_cb (GtkSpinButton *button, GdkRectangle *unused, gpointer data)
{
DupTransDialog *dt_dialog = data;
g_return_if_fail(GTK_IS_SPIN_BUTTON(button));
if (!dt_dialog) return;
if (!dt_dialog->focus_out)
return;
dt_dialog->focus_out = FALSE;
if (!gtk_spin_button_get_value_as_int(button))
gtk_entry_set_text(GTK_ENTRY(button), "");
}
static void static void
gnc_dup_trans_dialog_create (GtkWidget * parent, DupTransDialog *dt_dialog, gnc_dup_trans_dialog_create (GtkWidget * parent, DupTransDialog *dt_dialog,
time_t date, const char *num_str) time_t date, const char *num_str)
@ -112,6 +164,11 @@ gnc_dup_trans_dialog_create (GtkWidget * parent, DupTransDialog *dt_dialog,
gnome_dialog_editable_enters (GNOME_DIALOG (dialog), gnome_dialog_editable_enters (GNOME_DIALOG (dialog),
GTK_EDITABLE (num_spin)); GTK_EDITABLE (num_spin));
gtk_signal_connect (GTK_OBJECT(num_spin), "focus-out-event",
GTK_SIGNAL_FUNC(gnc_dup_trans_focus_out_cb), dt_dialog);
gtk_signal_connect (GTK_OBJECT(num_spin), "draw",
GTK_SIGNAL_FUNC(gnc_dup_trans_draw_cb), dt_dialog);
if (num_str && parse_num (num_str, &num)) if (num_str && parse_num (num_str, &num))
gtk_spin_button_set_value (GTK_SPIN_BUTTON (num_spin), num + 1); gtk_spin_button_set_value (GTK_SPIN_BUTTON (num_spin), num + 1);
else else