2001-08-08 Dave Peticolas <dave@krondo.com>

* src/register/register-gnome/pricecell-gnome.c: better 'return'
	handling.


git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@5091 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Dave Peticolas 2001-08-08 22:47:07 +00:00
parent bf6e8fc947
commit 36c1a668e2
2 changed files with 32 additions and 10 deletions

View File

@ -1,3 +1,8 @@
2001-08-08 Dave Peticolas <dave@krondo.com>
* src/register/register-gnome/pricecell-gnome.c: better 'return'
handling.
2001-08-08 Bill Gribble <grib@billgribble.com> 2001-08-08 Bill Gribble <grib@billgribble.com>
* fix Makefile.am in various places to clean up libtool * fix Makefile.am in various places to clean up libtool

View File

@ -22,9 +22,8 @@
* *
* Implements gnome dependent price cell functions : * Implements gnome dependent price cell functions :
* *
* often the decimal key in the keypad is not maped to the correct locale * Often the decimal key in the keypad is not mapped to the correct locale
* decimal point, the function PriceDirect handle this case. * decimal point, the function PriceDirect handle this case.
*
*/ */
#include "config.h" #include "config.h"
@ -49,6 +48,7 @@ PriceDirect (BasicCell *bcell,
char decimal_point; char decimal_point;
struct lconv *lc; struct lconv *lc;
GdkWChar *newval; GdkWChar *newval;
gboolean is_return;
int i; int i;
if (event->type != GDK_KEY_PRESS) if (event->type != GDK_KEY_PRESS)
@ -56,31 +56,48 @@ PriceDirect (BasicCell *bcell,
lc = gnc_localeconv (); lc = gnc_localeconv ();
is_return = FALSE;
switch (event->keyval) switch (event->keyval)
{ {
case GDK_Return: case GDK_Return:
if (!cell->need_to_parse)
return FALSE;
if (!(event->state & if (!(event->state &
(GDK_CONTROL_MASK | GDK_MOD1_MASK | GDK_SHIFT_MASK))) (GDK_CONTROL_MASK | GDK_MOD1_MASK | GDK_SHIFT_MASK)))
return FALSE; is_return = TRUE;
case GDK_KP_Enter: case GDK_KP_Enter:
{ {
char *error_loc; char *error_loc;
gnc_numeric amount; gnc_numeric amount;
gboolean parse_ok;
gboolean changed = FALSE;
if (!cell->need_to_parse) if (!cell->need_to_parse)
return FALSE; return FALSE;
if (gnc_exp_parser_parse(cell->cell.value, parse_ok = gnc_exp_parser_parse (cell->cell.value,
&amount, &error_loc)) &amount, &error_loc);
return xaccSetPriceCellValue (cell, amount);
if (parse_ok)
changed = xaccSetPriceCellValue (cell, amount);
else else
*cursor_position = error_loc - cell->cell.value; *cursor_position = error_loc - cell->cell.value;
return TRUE; /* If there is a problem with the parse, swallow
* the key so we stay put. */
if (!parse_ok)
return TRUE;
/* If nothing has changed, let the key cause a
* cursor activation no matter what. */
if (!changed)
return FALSE;
/* If it's not a plain return, stay put. This
* allows a 'calculator' style operation using
* keypad enter where you can keep entering more
* items to add, say. */
return !is_return;
} }
case GDK_KP_Decimal: case GDK_KP_Decimal: