mirror of
https://github.com/Gnucash/gnucash.git
synced 2025-02-25 18:55:30 -06:00
Make the gnc-currency-editor use gnc_commodities.
git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@3113 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
parent
6f41f77088
commit
e337d684cb
@ -89,9 +89,6 @@ static gint last_height = 0;
|
||||
|
||||
static int last_used_account_type = BANK;
|
||||
|
||||
static gchar * default_currency = "USD";
|
||||
static gboolean default_currency_dynamically_allocated = FALSE;
|
||||
|
||||
static GList *new_account_windows = NULL;
|
||||
static AccountWindow ** editAccountList = NULL;
|
||||
|
||||
@ -1226,9 +1223,9 @@ gnc_ui_new_account_window (AccountGroup *this_is_not_used)
|
||||
gnc_account_window_create(aw);
|
||||
new_account_windows = g_list_prepend(new_account_windows, aw->dialog);
|
||||
|
||||
commodity = gnc_commodity_table_lookup(gnc_engine_commodities(),
|
||||
GNC_COMMODITY_NS_ISO,
|
||||
default_currency);
|
||||
commodity = gnc_lookup_currency_option ("International",
|
||||
"Default Currency",
|
||||
gnc_locale_default_currency ());
|
||||
|
||||
gnc_commodity_edit_set_commodity (GNC_COMMODITY_EDIT (aw->currency_edit),
|
||||
commodity);
|
||||
@ -1301,26 +1298,6 @@ gnc_ui_edit_account_window(Account *account)
|
||||
}
|
||||
|
||||
|
||||
/*********************************************************************\
|
||||
* gnc_ui_set_default_new_account_currency *
|
||||
* Set the default currency for new accounts *
|
||||
* intended to be called by option handling code *
|
||||
* *
|
||||
* Args: currency *
|
||||
* Globals: default_currency, default_currency_dynamically_allocated *
|
||||
* Return value: none *
|
||||
\*********************************************************************/
|
||||
void
|
||||
gnc_ui_set_default_new_account_currency(const char *currency)
|
||||
{
|
||||
if (default_currency_dynamically_allocated)
|
||||
g_free(default_currency);
|
||||
|
||||
default_currency = g_strdup(currency);
|
||||
default_currency_dynamically_allocated = TRUE;
|
||||
}
|
||||
|
||||
|
||||
/********************************************************************\
|
||||
* Function: gnc_ui_destroy_account_add_windows - destroy all open *
|
||||
* account add windows. *
|
||||
|
@ -181,13 +181,12 @@ gnc_option_set_ui_value(GNCOption *option, gboolean use_default)
|
||||
}
|
||||
else if (safe_strcmp(type, "currency") == 0)
|
||||
{
|
||||
if (gh_string_p(value))
|
||||
{
|
||||
char *string = gh_scm2newstr(value, NULL);
|
||||
const gnc_commodity *commodity;
|
||||
|
||||
commodity = gnc_scm_to_commodity (value);
|
||||
if (commodity)
|
||||
gnc_currency_edit_set_currency(GNC_CURRENCY_EDIT(option->widget),
|
||||
string);
|
||||
free(string);
|
||||
}
|
||||
commodity);
|
||||
else
|
||||
bad_value = TRUE;
|
||||
}
|
||||
@ -448,10 +447,12 @@ gnc_option_get_ui_value(GNCOption *option)
|
||||
}
|
||||
else if (safe_strcmp(type, "currency") == 0)
|
||||
{
|
||||
const char * string;
|
||||
const gnc_commodity *commodity;
|
||||
|
||||
string = gnc_currency_edit_get_currency(GNC_CURRENCY_EDIT(option->widget));
|
||||
result = gh_str02scm(string);
|
||||
commodity =
|
||||
gnc_currency_edit_get_currency(GNC_CURRENCY_EDIT(option->widget));
|
||||
|
||||
result = gnc_commodity_to_scm (commodity);
|
||||
}
|
||||
else if (safe_strcmp(type, "commodity") == 0)
|
||||
{
|
||||
|
@ -184,13 +184,14 @@ gnc_currency_edit_new (void)
|
||||
*/
|
||||
void
|
||||
gnc_currency_edit_set_currency (GNCCurrencyEdit *gce,
|
||||
const char *currency_code)
|
||||
const gnc_commodity *currency)
|
||||
{
|
||||
g_return_if_fail(gce != NULL);
|
||||
g_return_if_fail(GNC_IS_CURRENCY_EDIT(gce));
|
||||
g_return_if_fail(currency_code != NULL);
|
||||
g_return_if_fail(currency != NULL);
|
||||
|
||||
gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(gce)->entry), currency_code);
|
||||
gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(gce)->entry),
|
||||
gnc_commodity_get_mnemonic (currency));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -199,13 +200,19 @@ gnc_currency_edit_set_currency (GNCCurrencyEdit *gce,
|
||||
*
|
||||
* Returns the selected currency.
|
||||
*/
|
||||
const char *
|
||||
const gnc_commodity *
|
||||
gnc_currency_edit_get_currency (GNCCurrencyEdit *gce)
|
||||
{
|
||||
const char *mnemonic;
|
||||
|
||||
g_return_val_if_fail(gce != NULL, NULL);
|
||||
g_return_val_if_fail(GNC_IS_CURRENCY_EDIT(gce), NULL);
|
||||
|
||||
return gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(gce)->entry));
|
||||
mnemonic = gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(gce)->entry));
|
||||
|
||||
return gnc_commodity_table_lookup (gnc_engine_commodities (),
|
||||
GNC_COMMODITY_NS_ISO,
|
||||
mnemonic);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -53,9 +53,9 @@ guint gnc_currency_edit_get_type (void);
|
||||
GtkWidget *gnc_currency_edit_new (void);
|
||||
|
||||
void gnc_currency_edit_set_currency (GNCCurrencyEdit *gce,
|
||||
const char *currency_code);
|
||||
const gnc_commodity *currency);
|
||||
|
||||
const char * gnc_currency_edit_get_currency (GNCCurrencyEdit *gce);
|
||||
const gnc_commodity * gnc_currency_edit_get_currency (GNCCurrencyEdit *gce);
|
||||
|
||||
END_GNOME_DECLS
|
||||
|
||||
|
@ -65,8 +65,6 @@
|
||||
/** PROTOTYPES ******************************************************/
|
||||
static void gnc_configure_date_format_cb(void *);
|
||||
static void gnc_configure_date_format(void);
|
||||
static void gnc_configure_newacc_currency_cb(void *);
|
||||
static void gnc_configure_newacc_currency(void);
|
||||
static void gnc_configure_account_separator_cb(void *);
|
||||
static void gnc_configure_account_separator(void);
|
||||
static void gnc_configure_register_colors_cb(void *);
|
||||
@ -100,7 +98,6 @@ static int gnome_is_initialized = FALSE;
|
||||
static int gnome_is_terminating = FALSE;
|
||||
|
||||
static SCM date_callback_id = SCM_UNDEFINED;
|
||||
static SCM currency_callback_id = SCM_UNDEFINED;
|
||||
static SCM account_separator_callback_id = SCM_UNDEFINED;
|
||||
static SCM register_colors_callback_id = SCM_UNDEFINED;
|
||||
static SCM register_borders_callback_id = SCM_UNDEFINED;
|
||||
@ -170,12 +167,6 @@ gnucash_ui_init(void)
|
||||
gnc_register_option_change_callback(gnc_configure_date_format_cb, NULL,
|
||||
"International", "Date Format");
|
||||
|
||||
gnc_configure_newacc_currency();
|
||||
currency_callback_id =
|
||||
gnc_register_option_change_callback(gnc_configure_newacc_currency_cb,
|
||||
NULL, "International",
|
||||
"Default Currency");
|
||||
|
||||
gnc_configure_account_separator();
|
||||
account_separator_callback_id =
|
||||
gnc_register_option_change_callback(gnc_configure_account_separator_cb,
|
||||
@ -284,7 +275,6 @@ gnc_ui_destroy (void)
|
||||
return;
|
||||
|
||||
gnc_unregister_option_change_callback_id(date_callback_id);
|
||||
gnc_unregister_option_change_callback_id(currency_callback_id);
|
||||
gnc_unregister_option_change_callback_id(account_separator_callback_id);
|
||||
gnc_unregister_option_change_callback_id(register_colors_callback_id);
|
||||
gnc_unregister_option_change_callback_id(register_borders_callback_id);
|
||||
@ -495,40 +485,6 @@ gnc_configure_date_format (void)
|
||||
free(format_code);
|
||||
}
|
||||
|
||||
/* gnc_configure_date_format_cb
|
||||
* Callback called when options change - sets default currency to
|
||||
* the current value on the scheme side
|
||||
*
|
||||
* Args: Nothing
|
||||
* Returns: Nothing
|
||||
*/
|
||||
static void
|
||||
gnc_configure_newacc_currency_cb(void *data)
|
||||
{
|
||||
gnc_configure_newacc_currency();
|
||||
}
|
||||
|
||||
/* gnc_configure_newacc_currency
|
||||
* sets the default currency for new accounts to the
|
||||
* current value on the scheme side
|
||||
*
|
||||
* Args: Nothing
|
||||
* Returns: Nothing
|
||||
*/
|
||||
static void
|
||||
gnc_configure_newacc_currency(void)
|
||||
{
|
||||
char *newacc_def_currency =
|
||||
gnc_lookup_string_option("International",
|
||||
"Default Currency",
|
||||
"USD");
|
||||
|
||||
gnc_ui_set_default_new_account_currency (newacc_def_currency);
|
||||
|
||||
if (newacc_def_currency != NULL)
|
||||
free(newacc_def_currency);
|
||||
}
|
||||
|
||||
/* gnc_configure_account_separator_cb
|
||||
* Callback called when options change - sets account separator
|
||||
* to the current value on the scheme side
|
||||
|
@ -261,24 +261,20 @@ gnc_ui_accounts_recurse (AccountGroup *group, GList **currency_list,
|
||||
const gnc_commodity * account_currency;
|
||||
const gnc_commodity * default_currency;
|
||||
const gnc_commodity * euro_commodity;
|
||||
const char * default_mnemonic;
|
||||
GNCCurrencyAcc *currency_accum;
|
||||
GNCCurrencyAcc *euro_accum = NULL;
|
||||
int i;
|
||||
|
||||
default_mnemonic = gnc_lookup_string_option("International",
|
||||
"Default Currency",
|
||||
"USD");
|
||||
default_currency = gnc_commodity_table_lookup(gnc_engine_commodities(),
|
||||
GNC_COMMODITY_NS_ISO,
|
||||
default_mnemonic);
|
||||
default_currency =
|
||||
gnc_lookup_currency_option("International",
|
||||
"Default Currency",
|
||||
gnc_locale_default_currency ());
|
||||
|
||||
if (euro) {
|
||||
euro_commodity = gnc_commodity_table_lookup(gnc_engine_commodities(),
|
||||
GNC_COMMODITY_NS_ISO,
|
||||
"EUR");
|
||||
if (euro)
|
||||
{
|
||||
euro_commodity = gnc_get_euro ();
|
||||
euro_accum = gnc_ui_get_currency_accumulator(currency_list,
|
||||
euro_commodity);
|
||||
euro_commodity);
|
||||
}
|
||||
|
||||
num_accounts = xaccGroupGetNumAccounts(group);
|
||||
@ -352,7 +348,6 @@ gnc_ui_refresh_statusbar (void)
|
||||
AccountGroup *group;
|
||||
char asset_string[256];
|
||||
char profit_string[256];
|
||||
const char * default_mnemonic;
|
||||
const gnc_commodity * default_currency;
|
||||
GNCCurrencyAcc *currency_accum;
|
||||
GNCCurrencyItem *currency_item;
|
||||
@ -360,16 +355,14 @@ gnc_ui_refresh_statusbar (void)
|
||||
GList *current;
|
||||
gboolean euro;
|
||||
|
||||
default_mnemonic = gnc_lookup_string_option("International",
|
||||
"Default Currency",
|
||||
"USD");
|
||||
default_currency = gnc_commodity_table_lookup(gnc_engine_commodities(),
|
||||
GNC_COMMODITY_NS_ISO,
|
||||
default_mnemonic);
|
||||
default_currency =
|
||||
gnc_lookup_currency_option("International",
|
||||
"Default Currency",
|
||||
gnc_locale_default_currency ());
|
||||
|
||||
euro = gnc_lookup_boolean_option("International",
|
||||
"Enable EURO support",
|
||||
FALSE);
|
||||
"Enable EURO support",
|
||||
FALSE);
|
||||
|
||||
main_info = gnc_get_main_info();
|
||||
if (main_info == NULL)
|
||||
@ -1425,16 +1418,14 @@ mainWindow()
|
||||
/* create the label containing the account balances */
|
||||
{
|
||||
GtkWidget *combo_box;
|
||||
const char *default_currency_mnemonic;
|
||||
const gnc_commodity * default_currency;
|
||||
GNCCurrencyItem *def_item;
|
||||
|
||||
default_currency_mnemonic = gnc_lookup_string_option("International",
|
||||
"Default Currency",
|
||||
"USD");
|
||||
default_currency = gnc_commodity_table_lookup(gnc_engine_commodities(),
|
||||
GNC_COMMODITY_NS_ISO,
|
||||
default_currency_mnemonic);
|
||||
default_currency =
|
||||
gnc_lookup_currency_option("International",
|
||||
"Default Currency",
|
||||
gnc_locale_default_currency ());
|
||||
|
||||
combo_box = gtk_select_new();
|
||||
main_info->totals_combo = combo_box;
|
||||
main_info->totals_list = NULL;
|
||||
|
@ -7,7 +7,6 @@ gnc_autogen_scm_files = \
|
||||
bootstrap.scm
|
||||
|
||||
gnc_regular_scm_files = \
|
||||
bs-interp.scm \
|
||||
c-interface.scm \
|
||||
command-line.scm \
|
||||
config-var.scm \
|
||||
|
@ -1,25 +0,0 @@
|
||||
;; startup-interpreter.scm -*-scheme-*-
|
||||
;;
|
||||
;; 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
|
||||
|
||||
;; Load the necessary files for use in interpreter mode.
|
||||
|
||||
(primitive-load (getenv "GNC_BOOTSTRAP_SCM"))
|
||||
(gnc:load "startup.scm")
|
||||
(gnc:load "main.scm")
|
||||
(gnc:startup)
|
@ -223,17 +223,27 @@
|
||||
sort-tag
|
||||
documentation-string
|
||||
default-value)
|
||||
(let* ((value default-value)
|
||||
|
||||
(define (currency->scm currency)
|
||||
(if (string? currency)
|
||||
currency
|
||||
(gnc:commodity-get-mnemonic currency)))
|
||||
|
||||
(define (scm->currency currency)
|
||||
(if (string? currency)
|
||||
(gnc:commodity-table-lookup
|
||||
(gnc:engine-commodities) GNC_COMMODITY_NS_ISO currency)
|
||||
currency))
|
||||
|
||||
(let* ((value (currency->scm default-value))
|
||||
(value->string (lambda () (gnc:value->string value))))
|
||||
(gnc:make-option
|
||||
section name sort-tag 'currency documentation-string
|
||||
(lambda () value)
|
||||
(lambda (x) (set! value x))
|
||||
(lambda () default-value)
|
||||
(lambda () (scm->currency value))
|
||||
(lambda (x) (set! value (currency->scm x)))
|
||||
(lambda () (scm->currency default-value))
|
||||
(gnc:restore-form-generator value->string)
|
||||
(lambda (x)
|
||||
(cond ((string? x)(list #t x))
|
||||
(else (list #f "currency-option: not a currency code"))))
|
||||
(lambda (x) (list #t x))
|
||||
#f #f #f #f)))
|
||||
|
||||
;; commodity options use a specialized widget for entering commodities
|
||||
|
@ -183,7 +183,7 @@ the account instead of opening a register." #f))
|
||||
(gnc:make-currency-option
|
||||
"International" "Default Currency"
|
||||
"b" "Default currency for new accounts"
|
||||
(gnc:commodity-get-mnemonic (gnc:locale-default-currency))))
|
||||
(gnc:locale-default-currency)))
|
||||
|
||||
(gnc:register-configuration-option
|
||||
(gnc:make-simple-boolean-option
|
||||
|
Loading…
Reference in New Issue
Block a user