Create amount editing widget.

Incorporate it into the transfer dialog for testing.


git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@2825 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Dave Peticolas 2000-09-11 11:09:49 +00:00
parent 2104ee86ac
commit b073146555
10 changed files with 531 additions and 31 deletions

2
TODO
View File

@ -1,7 +1,7 @@
For the latest plans regarding future GnuCash features, please consult
the file:
doc/html/C/projects.html
doc/projects.html
or the webpage:

View File

@ -362,7 +362,7 @@ void xaccSplitSetDocref (Split *, const char *);
* are "N", "C" and "R"
*/
void xaccSplitSetReconcile (Split *split, char reconciled_flag);
void xaccSplitSetDateReconciledSecs (Split *split, time_t);
void xaccSplitSetDateReconciledSecs (Split *split, time_t time);
void xaccSplitSetDateReconciledTS (Split *split, Timespec *ts);
void xaccSplitGetDateReconciledTS (Split *split, Timespec *ts);
@ -391,9 +391,9 @@ void xaccSplitGetDateReconciledTS (Split *split, Timespec *ts);
void xaccSplitSetSharePriceAndAmount (Split *split, double price,
double amount);
void xaccSplitSetShareAmount (Split *split, double);
void xaccSplitSetSharePrice (Split *split, double);
void xaccSplitSetValue (Split *split, double);
void xaccSplitSetShareAmount (Split *split, double amount);
void xaccSplitSetSharePrice (Split *split, double price);
void xaccSplitSetValue (Split *split, double value);
void xaccSplitSetBaseValue (Split *split, double value,
const char * base_currency);

View File

@ -182,12 +182,17 @@ static void
make_predefined_vars_helper (gpointer key, gpointer value, gpointer data)
{
var_store_ptr *vars_p = data;
ParserNum *pnum_old = value;
var_store_ptr var;
ParserNum *pnum;
var = g_new0 (var_store, 1);
var->variable_name = key;
var->value = value;
pnum = g_new (ParserNum, 1);
*pnum = *pnum_old;
var->variable_name = g_strdup(key);
var->value = pnum;
var->next_var = *vars_p;
*vars_p = var;
@ -212,6 +217,9 @@ free_predefined_variables (var_store_ptr vars)
{
next = vars->next_var;
g_free(vars->variable_name);
vars->variable_name = NULL;
g_free(vars->value);
vars->value = NULL;

View File

@ -19,6 +19,7 @@ libgncgnome_a_SOURCES = \
extensions.c \
file-history.c \
glade-gnc-dialogs.c \
gnc-amount-edit.c \
gnc-currency-edit.c \
gnc-datedelta.c \
gnc-dateedit.c \
@ -57,6 +58,7 @@ noinst_HEADERS = \
glade-cb-gnc-dialogs.h \
glade-gnc-dialogs.h \
glade-support-gnc-dialogs.h \
gnc-amount-edit.h \
gnc-currency-edit.h \
gnc-datedelta.h \
gnc-dateedit.h \

View File

@ -118,14 +118,14 @@ l = @l@
noinst_LIBRARIES = libgncgnome.a
libgncgnome_a_SOURCES = account-tree.c cursors.c dialog-account.c dialog-account-picker.c dialog-budget.c dialog-filebox.c dialog-fincalc.c dialog-find-transactions.c dialog-options.c dialog-print-check.c dialog-qif-import.c dialog-totd.c dialog-transfer.c dialog-utils.c extensions.c file-history.c glade-gnc-dialogs.c gnc-currency-edit.c gnc-datedelta.c gnc-dateedit.c gtkselect.c print-session.c query-user.c reconcile-list.c top-level.c window-adjust.c window-help.c window-html.c window-main.c window-reconcile.c window-register.c window-report.c
libgncgnome_a_SOURCES = account-tree.c cursors.c dialog-account.c dialog-account-picker.c dialog-budget.c dialog-filebox.c dialog-fincalc.c dialog-find-transactions.c dialog-options.c dialog-print-check.c dialog-qif-import.c dialog-totd.c dialog-transfer.c dialog-utils.c extensions.c file-history.c glade-gnc-dialogs.c gnc-amount-edit.c gnc-currency-edit.c gnc-datedelta.c gnc-dateedit.c gtkselect.c print-session.c query-user.c reconcile-list.c top-level.c window-adjust.c window-help.c window-html.c window-main.c window-reconcile.c window-register.c window-report.c
gnomeappdir = ${datadir}/gnome/apps/Applications
gnomeapp_DATA = gnucash.desktop
noinst_HEADERS = account-tree.h cursors.h dialog-account.h dialog-account-picker.h dialog-budget.h dialog-fincalc.h dialog-find-transactions.h dialog-options.h dialog-print-check.h dialog-qif-import.h dialog-totd.h dialog-transfer.h dialog-utils.h extensions.h glade-cb-gnc-dialogs.h glade-gnc-dialogs.h glade-support-gnc-dialogs.h gnc-currency-edit.h gnc-datedelta.h gnc-dateedit.h gnome-top-level.h gtkselect.h print-session.h query-user.h reconcile-list.h window-help.h window-html.h window-main.h window-reconcile.h window-register.h window-report.h
noinst_HEADERS = account-tree.h cursors.h dialog-account.h dialog-account-picker.h dialog-budget.h dialog-fincalc.h dialog-find-transactions.h dialog-options.h dialog-print-check.h dialog-qif-import.h dialog-totd.h dialog-transfer.h dialog-utils.h extensions.h glade-cb-gnc-dialogs.h glade-gnc-dialogs.h glade-support-gnc-dialogs.h gnc-amount-edit.h gnc-currency-edit.h gnc-datedelta.h gnc-dateedit.h gnome-top-level.h gtkselect.h print-session.h query-user.h reconcile-list.h window-help.h window-html.h window-main.h window-reconcile.h window-register.h window-report.h
EXTRA_DIST = .cvsignore gnc-dialogs.glade gnucash.desktop
@ -155,10 +155,11 @@ dialog-account-picker.o dialog-budget.o dialog-filebox.o \
dialog-fincalc.o dialog-find-transactions.o dialog-options.o \
dialog-print-check.o dialog-qif-import.o dialog-totd.o \
dialog-transfer.o dialog-utils.o extensions.o file-history.o \
glade-gnc-dialogs.o gnc-currency-edit.o gnc-datedelta.o gnc-dateedit.o \
gtkselect.o print-session.o query-user.o reconcile-list.o top-level.o \
window-adjust.o window-help.o window-html.o window-main.o \
window-reconcile.o window-register.o window-report.o
glade-gnc-dialogs.o gnc-amount-edit.o gnc-currency-edit.o \
gnc-datedelta.o gnc-dateedit.o gtkselect.o print-session.o query-user.o \
reconcile-list.o top-level.o window-adjust.o window-help.o \
window-html.o window-main.o window-reconcile.o window-register.o \
window-report.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)
@ -182,11 +183,12 @@ DEP_FILES = .deps/account-tree.P .deps/cursors.P \
.deps/dialog-print-check.P .deps/dialog-qif-import.P \
.deps/dialog-totd.P .deps/dialog-transfer.P .deps/dialog-utils.P \
.deps/extensions.P .deps/file-history.P .deps/glade-gnc-dialogs.P \
.deps/gnc-currency-edit.P .deps/gnc-datedelta.P .deps/gnc-dateedit.P \
.deps/gtkselect.P .deps/print-session.P .deps/query-user.P \
.deps/reconcile-list.P .deps/top-level.P .deps/window-adjust.P \
.deps/window-help.P .deps/window-html.P .deps/window-main.P \
.deps/window-reconcile.P .deps/window-register.P .deps/window-report.P
.deps/gnc-amount-edit.P .deps/gnc-currency-edit.P .deps/gnc-datedelta.P \
.deps/gnc-dateedit.P .deps/gtkselect.P .deps/print-session.P \
.deps/query-user.P .deps/reconcile-list.P .deps/top-level.P \
.deps/window-adjust.P .deps/window-help.P .deps/window-html.P \
.deps/window-main.P .deps/window-reconcile.P .deps/window-register.P \
.deps/window-report.P
SOURCES = $(libgncgnome_a_SOURCES)
OBJECTS = $(libgncgnome_a_OBJECTS)

View File

@ -33,7 +33,9 @@
#include "window-reconcile.h"
#include "query-user.h"
#include "account-tree.h"
#include "gnc-amount-edit.h"
#include "gnc-dateedit.h"
#include "gnc-exp-parser.h"
#include "enriched-messages.h"
#include "ui-callbacks.h"
#include "util.h"
@ -55,7 +57,7 @@ struct _xferDialog
{
GtkWidget * dialog;
GtkWidget * amount_entry;
GtkWidget * amount_edit;
GtkWidget * date_entry;
GtkWidget * num_entry;
GtkWidget * description_entry;
@ -255,7 +257,6 @@ gnc_xfer_dialog_set_amount(XferDialog *xferData, double amount)
{
Account *account;
const char *currency;
const char *string;
if (xferData == NULL)
return;
@ -266,9 +267,10 @@ gnc_xfer_dialog_set_amount(XferDialog *xferData, double amount)
currency = xaccAccountGetCurrency(account);
string = xaccPrintAmount(amount, PRTSEP, currency);
gnc_amount_edit_set_currency (GNC_AMOUNT_EDIT (xferData->amount_edit),
currency);
gtk_entry_set_text(GTK_ENTRY(xferData->amount_entry), string);
gnc_amount_edit_set_amount (GNC_AMOUNT_EDIT (xferData->amount_edit), amount);
}
@ -325,9 +327,23 @@ gnc_xfer_dialog_ok_cb(GtkWidget * widget, gpointer data)
return;
}
string = gtk_entry_get_text(GTK_ENTRY(xferData->amount_entry));
amount = 0.0;
xaccParseAmount(string, TRUE, &amount, NULL);
if (!gnc_amount_edit_evaluate (GNC_AMOUNT_EDIT (xferData->amount_edit)))
{
const char *error_string;
char * error_phrase;
error_string = gnc_exp_parser_error_string ();
if (error_string == NULL)
error_string = "";
error_phrase = g_strdup_printf(ERROR_IN_AMOUNT, error_string);
gnc_error_dialog_parented(GTK_WINDOW(xferData->dialog), error_phrase);
g_free(error_phrase);
}
amount = gnc_amount_edit_get_amount(GNC_AMOUNT_EDIT(xferData->amount_edit));
time = gnc_date_edit_get_date(GNC_DATE_EDIT(xferData->date_entry));
@ -461,19 +477,23 @@ gnc_xfer_dialog_create(GtkWidget * parent, XferDialog *xferData)
{
GtkWidget *amount;
GtkWidget *entry;
label = gtk_label_new(AMOUNT_C_STR);
gtk_misc_set_alignment(GTK_MISC(label), 1.0, 0.5);
gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0);
amount = gtk_entry_new();
amount = gnc_amount_edit_new();
gnc_amount_edit_set_print_flags (GNC_AMOUNT_EDIT(amount), PRTSEP);
gtk_box_pack_start(GTK_BOX(hbox), amount, TRUE, TRUE, 0);
xferData->amount_entry = amount;
xferData->amount_edit = amount;
gtk_signal_connect(GTK_OBJECT(amount), "focus-out-event",
entry = gnc_amount_edit_gtk_entry (GNC_AMOUNT_EDIT (amount));
gtk_signal_connect(GTK_OBJECT(entry), "focus-out-event",
GTK_SIGNAL_FUNC(gnc_xfer_update_cb), xferData);
gnome_dialog_editable_enters(GNOME_DIALOG(dialog), GTK_EDITABLE(amount));
gnome_dialog_editable_enters(GNOME_DIALOG(dialog), GTK_EDITABLE(entry));
}
{
@ -579,6 +599,8 @@ XferDialog *
gnc_xfer_dialog(GtkWidget * parent, Account * initial)
{
XferDialog *xferData;
GNCAmountEdit *gae;
GtkWidget *amount_entry;
xferData = g_new0(XferDialog, 1);
@ -586,7 +608,10 @@ gnc_xfer_dialog(GtkWidget * parent, Account * initial)
xfer_dialogs = g_list_prepend(xfer_dialogs, xferData->dialog);
gtk_widget_grab_focus(xferData->amount_entry);
gae = GNC_AMOUNT_EDIT(xferData->amount_edit);
amount_entry = gnc_amount_edit_gtk_entry (gae);
gtk_widget_grab_focus(amount_entry);
gnc_xfer_dialog_select_from_account(xferData, initial);
gnc_xfer_dialog_select_to_account(xferData, initial);

374
src/gnome/gnc-amount-edit.c Normal file
View File

@ -0,0 +1,374 @@
/*
* Copyright (C) 2000 Dave Peticolas <dave@krondo.com>
* All rights reserved.
*
* Gnucash is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public License
* as published by the Free Software Foundation; either version 2 of the
* License, or (at your option) any later version.
*
* Gnucash 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
* Library 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
*
*/
/*
@NOTATION@
*/
/*
* Amount editor widget
*
* Authors: Dave Peticolas <dave@krondo.com>
*/
#include "config.h"
#include "gnc-amount-edit.h"
#include "gnc-exp-parser.h"
#include "messages.h"
#include "query-user.h"
#include "ui-callbacks.h"
/* Signal codes */
enum
{
AMOUNT_CHANGED,
LAST_SIGNAL
};
static gint amount_edit_signals [LAST_SIGNAL] = { 0 };
static void gnc_amount_edit_init (GNCAmountEdit *gae);
static void gnc_amount_edit_class_init (GNCAmountEditClass *class);
static void gnc_amount_edit_destroy (GtkObject *object);
static void gnc_amount_edit_forall (GtkContainer *container,
gboolean include_internals,
GtkCallback callback,
gpointer callbabck_data);
static GtkHBoxClass *parent_class;
/**
* gnc_amount_edit_get_type:
*
* Returns the GtkType for the GNCAmountEdit widget
*/
guint
gnc_amount_edit_get_type (void)
{
static guint amount_edit_type = 0;
if (!amount_edit_type){
GtkTypeInfo amount_edit_info = {
"GNCAmountEdit",
sizeof (GNCAmountEdit),
sizeof (GNCAmountEditClass),
(GtkClassInitFunc) gnc_amount_edit_class_init,
(GtkObjectInitFunc) gnc_amount_edit_init,
NULL,
NULL,
};
amount_edit_type = gtk_type_unique (gtk_hbox_get_type (),
&amount_edit_info);
}
return amount_edit_type;
}
static void
gnc_amount_edit_class_init (GNCAmountEditClass *class)
{
GtkObjectClass *object_class = (GtkObjectClass *) class;
GtkContainerClass *container_class = (GtkContainerClass *) class;
object_class = (GtkObjectClass*) class;
parent_class = gtk_type_class (gtk_hbox_get_type ());
amount_edit_signals [AMOUNT_CHANGED] =
gtk_signal_new ("amount_changed",
GTK_RUN_FIRST, object_class->type,
GTK_SIGNAL_OFFSET (GNCAmountEditClass,
amount_changed),
gtk_signal_default_marshaller,
GTK_TYPE_NONE, 0);
gtk_object_class_add_signals (object_class, amount_edit_signals,
LAST_SIGNAL);
container_class->forall = gnc_amount_edit_forall;
object_class->destroy = gnc_amount_edit_destroy;
class->amount_changed = NULL;
}
static void
gnc_amount_edit_init (GNCAmountEdit *gae)
{
gae->need_to_parse = FALSE;
gae->amount = 0.0;
gae->print_flags = 0;
gae->currency = NULL;
}
static void
gnc_amount_edit_destroy (GtkObject *object)
{
GNCAmountEdit *gae;
g_return_if_fail (object != NULL);
g_return_if_fail (GNC_IS_AMOUNT_EDIT (object));
gae = GNC_AMOUNT_EDIT (object);
g_free(gae->currency);
gae->currency = NULL;
if (GTK_OBJECT_CLASS (parent_class)->destroy)
(* GTK_OBJECT_CLASS (parent_class)->destroy) (object);
}
static void
gnc_amount_edit_forall (GtkContainer *container, gboolean include_internals,
GtkCallback callback, gpointer callback_data)
{
g_return_if_fail (container != NULL);
g_return_if_fail (GNC_IS_AMOUNT_EDIT (container));
g_return_if_fail (callback != NULL);
/* Let GtkBox handle things only if the internal widgets need
* to be poked. */
if (include_internals)
if (GTK_CONTAINER_CLASS (parent_class)->forall)
(* GTK_CONTAINER_CLASS (parent_class)->forall)
(container,
include_internals,
callback,
callback_data);
}
static void
amount_entry_changed (GtkEditable *editable, gpointer data)
{
GNCAmountEdit *gae = data;
gae->need_to_parse = TRUE;
}
static int
amount_entry_key_press(GtkWidget *widget, GdkEventKey *event, gpointer data)
{
GNCAmountEdit *gae = data;
switch (event->keyval)
{
case GDK_Return:
if (event->state & (GDK_CONTROL_MASK | GDK_MOD1_MASK | GDK_SHIFT_MASK))
break;
return FALSE;
case GDK_KP_Enter:
break;
default:
return FALSE;
}
gtk_signal_emit_stop_by_name (GTK_OBJECT (widget), "key_press_event");
gnc_amount_edit_evaluate (gae);
return TRUE;
}
static void
create_children (GNCAmountEdit *gae)
{
gae->amount_entry = gtk_entry_new ();
gtk_box_pack_start (GTK_BOX (gae), gae->amount_entry, TRUE, TRUE, 0);
gtk_widget_show (gae->amount_entry);
gtk_signal_connect (GTK_OBJECT (gae->amount_entry), "changed",
GTK_SIGNAL_FUNC(amount_entry_changed), gae);
gtk_signal_connect (GTK_OBJECT (gae->amount_entry), "key_press_event",
GTK_SIGNAL_FUNC(amount_entry_key_press), gae);
}
/**
* gnc_amount_edit_new:
*
* Creates a new GNCAmountEdit widget which can be used to provide
* an easy to use way for entering amounts, allowing the user to
* enter and evaluate expressions.
*
* Returns a GNCAmountEdit widget.
*/
GtkWidget *
gnc_amount_edit_new (void)
{
GNCAmountEdit *gae;
gae = gtk_type_new (gnc_amount_edit_get_type ());
create_children (gae);
return GTK_WIDGET (gae);
}
/**
* gnc_amount_edit_evaluate
* @gae: The GNCAmountEdit widget
*
* If needed, parse the expression in the amount entry
* and replace the expression with the result of evaluation.
* If there is a parsing error, don't change the expression entry,
* but do put the cursor at the point of the error.
*
* Return TRUE if parsing was successful or there was no need to parse.
*/
gboolean
gnc_amount_edit_evaluate (GNCAmountEdit *gae)
{
const char *string;
char *error_loc;
double amount;
gboolean ok;
g_return_val_if_fail(gae != NULL, FALSE);
g_return_val_if_fail(GNC_IS_AMOUNT_EDIT(gae), FALSE);
if (!gae->need_to_parse)
return TRUE;
string = gtk_entry_get_text(GTK_ENTRY(gae->amount_entry));
error_loc = NULL;
ok = gnc_exp_parser_parse (string, &amount, &error_loc);
if (ok)
{
if (!DEQ(amount, gae->amount))
gtk_signal_emit (GTK_OBJECT (gae), amount_edit_signals [AMOUNT_CHANGED]);
gnc_amount_edit_set_amount (gae, amount);
return TRUE;
}
/* Not ok */
if (error_loc != NULL)
gtk_editable_set_position (GTK_EDITABLE(gae->amount_entry),
error_loc - string);
return FALSE;
}
/**
* gnc_amount_edit_get_amount:
* @gae: The GNCAmountEdit widget
*
* Returns the amount entered in the GNCAmountEdit widget,
* parsing the epxression if necessary. The result of parsing
* replaces the expression.
*/
double
gnc_amount_edit_get_amount (GNCAmountEdit *gae)
{
g_return_val_if_fail(gae != NULL, 0.0);
g_return_val_if_fail(GNC_IS_AMOUNT_EDIT(gae), 0.0);
gnc_amount_edit_evaluate (gae);
return gae->amount;
}
/**
* gnc_amount_edit_set_amount:
* @gae: The GNCAmountEdit widget
* @amount: The amount to set
*
* Returns nothing.
*/
void
gnc_amount_edit_set_amount (GNCAmountEdit *gae, double amount)
{
const char * amount_string;
g_return_if_fail(gae != NULL);
g_return_if_fail(GNC_IS_AMOUNT_EDIT(gae));
gae->amount = amount;
gae->need_to_parse = FALSE;
amount_string = xaccPrintAmount (amount, gae->print_flags, gae->currency);
gtk_entry_set_text (GTK_ENTRY (gae->amount_entry), amount_string);
}
/**
* gnc_amount_edit_set_print_flags:
* @gae: The GNCAmountEdit widget
* @print_flags: The print flags to set
*
* Returns nothing.
*/
void
gnc_amount_edit_set_print_flags (GNCAmountEdit *gae,
GNCPrintAmountFlags print_flags)
{
g_return_if_fail(gae != NULL);
g_return_if_fail(GNC_IS_AMOUNT_EDIT(gae));
gae->print_flags = print_flags;
}
/**
* gnc_amount_edit_set_currency:
* @gae: The GNCAmountEdit widget
* @currency: The currency to set
*
* Returns nothing.
*/
void
gnc_amount_edit_set_currency (GNCAmountEdit *gae, const char * currency)
{
g_return_if_fail(gae != NULL);
g_return_if_fail(GNC_IS_AMOUNT_EDIT(gae));
g_free (gae->currency);
currency = g_strdup (currency);
}
/**
* gnc_amount_edit_gtk_entry:
* @gae: The GNCAmountEdit widget
*
* Returns the gtk entry of the widget..
*/
GtkWidget *
gnc_amount_edit_gtk_entry (GNCAmountEdit *gae)
{
g_return_val_if_fail(gae != NULL, NULL);
g_return_val_if_fail(GNC_IS_AMOUNT_EDIT(gae), NULL);
return gae->amount_entry;
}

View File

@ -0,0 +1,82 @@
/*
* Copyright (C) 2000 Dave Peticolas <dave@krondo.com>
* All rights reserved.
*
* GnuCash is free software; you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License as
* published by the Free Software Foundation; either version 2 of
* the License, or (at your option) any later version.
*
* Gnucash 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
* Library 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
*
*/
/*
@NOTATION@
*/
#ifndef __GNC_AMOUNT_EDIT_H_
#define __GNC_AMOUNT_EDIT_H_
#include <gnome.h>
#include "util.h"
BEGIN_GNOME_DECLS
#define GNC_AMOUNT_EDIT(obj) GTK_CHECK_CAST (obj, gnc_amount_edit_get_type(), GNCAmountEdit)
#define GNC_AMOUNT_EDIT_CLASS(klass) GTK_CHECK_CLASS_CAST (klass, gnc_amount_edit_get_type(), GNCAmountEditClass)
#define GNC_IS_AMOUNT_EDIT(obj) GTK_CHECK_TYPE (obj, gnc_amount_edit_get_type ())
typedef struct
{
GtkHBox hbox;
GtkWidget *amount_entry;
gboolean need_to_parse;
GNCPrintAmountFlags print_flags;
char *currency;
double amount;
} GNCAmountEdit;
typedef struct
{
GtkHBoxClass parent_class;
void (*amount_changed) (GNCAmountEdit *gae);
} GNCAmountEditClass;
guint gnc_amount_edit_get_type (void);
GtkWidget *gnc_amount_edit_new (void);
GtkWidget *gnc_amount_edit_gtk_entry (GNCAmountEdit *gae);
void gnc_amount_edit_set_amount (GNCAmountEdit *gae, double amount);
double gnc_amount_edit_get_amount (GNCAmountEdit *gae);
gboolean gnc_amount_edit_evaluate (GNCAmountEdit *gae);
void gnc_amount_edit_set_print_flags (GNCAmountEdit *gae,
GNCPrintAmountFlags print_flags);
void gnc_amount_edit_set_currency (GNCAmountEdit *gae,
const char * currency);
END_GNOME_DECLS
#endif

View File

@ -437,6 +437,8 @@
/* Error messages */
#define ERROR_IN_AMOUNT _("You must enter a valid amount.\n\n" \
"Error: %s.")
#define PARSER_UNBALANCED_PARENS _("Unbalanced parenthesis")
#define PARSER_STACK_OVERFLOW _("Stack overflow")
#define PARSER_STACK_UNDERFLOW _("Stack underflow")

View File

@ -53,6 +53,8 @@
(gnc:hook-run-danglers gnc:*startup-hook*)
(gnc:exp-parser-init)
(if (gnc:config-var-value-get gnc:*arg-show-version*)
(begin
(gnc:prefs-show-version)
@ -95,7 +97,10 @@
(if (not (= (gnc:lowlev-app-init) 0))
(gnc:shutdown 0))
;; add a hook to shut down the expression parser
(gnc:hook-add-dangler gnc:*shutdown-hook* gnc:exp-parser-shutdown)
;; add a hook to save the user configs on shutdown
(gnc:hook-add-dangler gnc:*shutdown-hook* gnc:save-global-options)