mirror of
https://github.com/Gnucash/gnucash.git
synced 2024-11-22 08:57:17 -06:00
Raphael Dechenaux's patch to fix keypad input of decimal points.
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@2789 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
35154bc874
commit
5c10547c1b
1
AUTHORS
1
AUTHORS
@ -53,6 +53,7 @@ Albert Chin-A-Young <china@thewrittenword.com> configure.in patch
|
||||
Jeremey Collins <jcollins@gnucash.org> for GnoMoney & GTK port
|
||||
Matthew Condell <mcondell@bbn.com> FreeBSD patch
|
||||
Patrick Condron <pcondon@rackspace.com> for webserver and T1 connection.
|
||||
Raphael Dechenaux <raphael.dechenaux@worldonline.fr> register patch
|
||||
Ciaran Deignan <Ciaran.Deignan@bull.net> for AIX binary version
|
||||
Glen Ditchfield <gjditchfield@acm.org> updated documentation
|
||||
Tyson Dowd <tyson@tyse.net> for config/make patches & debian maint
|
||||
|
@ -369,6 +369,7 @@ Motif as a school project, taking it to version 0.9 by October
|
||||
<PARA>FreeBSD patch</PARA>
|
||||
</GLOSSDEF>
|
||||
</GLOSSENTRY>
|
||||
|
||||
<GLOSSENTRY>
|
||||
<GLOSSTERM><email> pcondon@rackspace.com</email> Patrick
|
||||
Condron</GLOSSTERM>
|
||||
@ -377,6 +378,14 @@ Motif as a school project, taking it to version 0.9 by October
|
||||
</GLOSSDEF>
|
||||
</GLOSSENTRY>
|
||||
|
||||
<GLOSSENTRY>
|
||||
<GLOSSTERM><email> raphael.dechenaux@worldonline.fr</email> Raphael
|
||||
Dechenaux</GLOSSTERM>
|
||||
<GLOSSDEF>
|
||||
<PARA>register patch</PARA>
|
||||
</GLOSSDEF>
|
||||
</GLOSSENTRY>
|
||||
|
||||
<GLOSSENTRY>
|
||||
<GLOSSTERM><email> Ciaran.Deignan@bull.net</email> Ciaran
|
||||
Deignan</GLOSSTERM>
|
||||
|
@ -11,7 +11,8 @@ libgncregistergnome_a_SOURCES = \
|
||||
gnucash-item-list.c \
|
||||
gnucash-sheet.c \
|
||||
gnucash-style.c \
|
||||
quickfillcell-gnome.c
|
||||
quickfillcell-gnome.c \
|
||||
pricecell-gnome.c
|
||||
|
||||
noinst_HEADERS = \
|
||||
gnucash-color.h \
|
||||
|
@ -117,7 +117,7 @@ l = @l@
|
||||
|
||||
noinst_LIBRARIES = libgncregistergnome.a
|
||||
|
||||
libgncregistergnome_a_SOURCES = combocell-gnome.c gnucash-color.c gnucash-cursor.c gnucash-grid.c gnucash-header.c gnucash-item-edit.c gnucash-item-list.c gnucash-sheet.c gnucash-style.c quickfillcell-gnome.c
|
||||
libgncregistergnome_a_SOURCES = combocell-gnome.c gnucash-color.c gnucash-cursor.c gnucash-grid.c gnucash-header.c gnucash-item-edit.c gnucash-item-list.c gnucash-sheet.c gnucash-style.c quickfillcell-gnome.c pricecell-gnome.c
|
||||
|
||||
|
||||
noinst_HEADERS = gnucash-color.h gnucash-cursor.h gnucash-grid.h gnucash-header.h gnucash-item-edit.h gnucash-item-list.h gnucash-sheet.h gnucash-style.h
|
||||
@ -148,7 +148,7 @@ libgncregistergnome_a_LIBADD =
|
||||
libgncregistergnome_a_OBJECTS = combocell-gnome.o gnucash-color.o \
|
||||
gnucash-cursor.o gnucash-grid.o gnucash-header.o gnucash-item-edit.o \
|
||||
gnucash-item-list.o gnucash-sheet.o gnucash-style.o \
|
||||
quickfillcell-gnome.o
|
||||
quickfillcell-gnome.o pricecell-gnome.o
|
||||
AR = ar
|
||||
COMPILE = $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
|
||||
LTCOMPILE = $(LIBTOOL) --mode=compile $(CC) $(DEFS) $(INCLUDES) $(AM_CPPFLAGS) $(CPPFLAGS) $(AM_CFLAGS) $(CFLAGS)
|
||||
@ -166,7 +166,8 @@ GZIP_ENV = --best
|
||||
DEP_FILES = .deps/combocell-gnome.P .deps/gnucash-color.P \
|
||||
.deps/gnucash-cursor.P .deps/gnucash-grid.P .deps/gnucash-header.P \
|
||||
.deps/gnucash-item-edit.P .deps/gnucash-item-list.P \
|
||||
.deps/gnucash-sheet.P .deps/gnucash-style.P .deps/quickfillcell-gnome.P
|
||||
.deps/gnucash-sheet.P .deps/gnucash-style.P .deps/pricecell-gnome.P \
|
||||
.deps/quickfillcell-gnome.P
|
||||
SOURCES = $(libgncregistergnome_a_SOURCES)
|
||||
OBJECTS = $(libgncregistergnome_a_OBJECTS)
|
||||
|
||||
|
104
src/register/gnome/pricecell-gnome.c
Normal file
104
src/register/gnome/pricecell-gnome.c
Normal file
@ -0,0 +1,104 @@
|
||||
/********************************************************************\
|
||||
* This program is free software; you can redistribute it and/or *
|
||||
* modify it under the terms of the GNU General Public License as *
|
||||
* published by the Free Software Foundation; either version 2 of *
|
||||
* the License, or (at your option) any later version. *
|
||||
* *
|
||||
* This program is distributed in the hope that it will be useful, *
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of *
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
|
||||
* GNU General Public License for more details. *
|
||||
* *
|
||||
* You should have received a copy of the GNU General Public License*
|
||||
* along with this program; if not, contact: *
|
||||
* *
|
||||
* Free Software Foundation Voice: +1-617-542-5942 *
|
||||
* 59 Temple Place - Suite 330 Fax: +1-617-542-2652 *
|
||||
* Boston, MA 02111-1307, USA gnu@gnu.org *
|
||||
* *
|
||||
\********************************************************************/
|
||||
|
||||
/* pricecell-gnome.c
|
||||
*
|
||||
* Implements gnome dependent price cell functions :
|
||||
*
|
||||
* often the decimal key in the keypad is not maped to the correct locale
|
||||
* decimal point, the function PriceDirect handle this case.
|
||||
*
|
||||
*/
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <gnome.h>
|
||||
#include <locale.h>
|
||||
|
||||
#include "pricecell.h"
|
||||
#include "util.h"
|
||||
|
||||
|
||||
static gboolean
|
||||
PriceDirect (BasicCell *bcell,
|
||||
const char *oldval,
|
||||
char **newval_ptr,
|
||||
int *cursor_position,
|
||||
int *start_selection,
|
||||
int *end_selection,
|
||||
void *gui_data)
|
||||
{
|
||||
PriceCell *cell = (PriceCell *) bcell;
|
||||
GdkEventKey *event = gui_data;
|
||||
char decimal_point;
|
||||
struct lconv *lc = gnc_localeconv();
|
||||
|
||||
if (event->type != GDK_KEY_PRESS)
|
||||
return FALSE;
|
||||
|
||||
if (event->keyval != GDK_KP_Decimal)
|
||||
return FALSE;
|
||||
|
||||
if (cell->monetary)
|
||||
decimal_point = lc->mon_decimal_point[0];
|
||||
else
|
||||
decimal_point = lc->decimal_point[0];
|
||||
|
||||
/* Only one decimal point allowed in price : */
|
||||
if (strchr( oldval, decimal_point) != NULL)
|
||||
return FALSE;
|
||||
|
||||
/* allocate space for newval_ptr : oldval + one letter ( the
|
||||
decimal_point ) */
|
||||
(*newval_ptr) = g_new(char, strlen(oldval) + 2);
|
||||
|
||||
/* copy oldval up to the cursor position */
|
||||
strncpy( *newval_ptr, oldval, *cursor_position);
|
||||
|
||||
/* insert the decimal_point at cursor position */
|
||||
(*newval_ptr)[*cursor_position] = decimal_point;
|
||||
|
||||
/* copy the end of oldval : */
|
||||
strcpy( *newval_ptr + (*cursor_position) + 1, oldval + (*cursor_position));
|
||||
|
||||
/* update the cursor position */
|
||||
(*cursor_position)++;
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
void
|
||||
xaccPriceGUIInit (PriceCell *cell)
|
||||
{
|
||||
if (cell == NULL)
|
||||
return;
|
||||
|
||||
cell->cell.direct_update = PriceDirect;
|
||||
}
|
||||
|
||||
/* =============== end of file =================== */
|
||||
|
||||
/*
|
||||
Local Variables:
|
||||
c-basic-offset: 4
|
||||
tab-width: 8
|
||||
End:
|
||||
*/
|
@ -40,6 +40,8 @@
|
||||
#include "basiccell.h"
|
||||
#include "pricecell.h"
|
||||
|
||||
/* GUI-dependent */
|
||||
extern void xaccPriceGUIInit (PriceCell *);
|
||||
|
||||
static void PriceSetValue (BasicCell *, const char *);
|
||||
static char * xaccPriceCellPrintValue (PriceCell *cell);
|
||||
@ -228,6 +230,8 @@ xaccInitPriceCell (PriceCell *cell)
|
||||
cell->cell.leave_cell = PriceLeave;
|
||||
cell->cell.set_value = PriceSetValue;
|
||||
cell->cell.get_help_value = PriceHelp;
|
||||
|
||||
xaccPriceGUIInit( cell);
|
||||
}
|
||||
|
||||
/* ================================================ */
|
||||
|
Loading…
Reference in New Issue
Block a user