diff --git a/src/app-utils/app-utils.i b/src/app-utils/app-utils.i index 71bb1ac4d7..e1fc6e8860 100644 --- a/src/app-utils/app-utils.i +++ b/src/app-utils/app-utils.i @@ -68,8 +68,6 @@ void gncp_option_invoke_callback(GNCOptionChangeCallback callback, void *data); void gnc_option_db_register_option(GNCOptionDBHandle handle, SCM guile_option); -const char * gnc_locale_default_iso_currency_code (void); - GNCPrintAmountInfo gnc_default_print_info (gboolean use_symbol); GNCPrintAmountInfo gnc_account_print_info (const Account *account, gboolean use_symbol); diff --git a/src/app-utils/gnc-exp-parser.c b/src/app-utils/gnc-exp-parser.c index 991dcb10c8..9be73fd237 100644 --- a/src/app-utils/gnc-exp-parser.c +++ b/src/app-utils/gnc-exp-parser.c @@ -34,6 +34,7 @@ #include "gnc-gkeyfile-utils.h" #include "gnc-exp-parser.h" #include "gnc-ui-util.h" +#include "gnc-locale-utils.h" #include "guile-mappings.h" #define GROUP_NAME "Variables" diff --git a/src/app-utils/gnc-ui-util.c b/src/app-utils/gnc-ui-util.c index b4b4a3160e..680f8ec98a 100644 --- a/src/app-utils/gnc-ui-util.c +++ b/src/app-utils/gnc-ui-util.c @@ -51,6 +51,7 @@ #include "app-utils/gnc-euro.h" #include "engine/gnc-hooks.h" #include "engine/gnc-session.h" +#include "gnc-locale-utils.h" #define KEY_CURRENCY_CHOICE "currency_choice" #define KEY_CURRENCY_OTHER "currency_other" @@ -966,63 +967,6 @@ gnc_lconv_set_char (char *p_value, char default_value) *p_value = default_value; } -struct lconv * -gnc_localeconv (void) -{ - static struct lconv lc; - static gboolean lc_set = FALSE; - - if (lc_set) - return &lc; - - lc = *localeconv(); - - gnc_lconv_set_utf8(&lc.decimal_point, "."); - gnc_lconv_set_utf8(&lc.thousands_sep, ","); - gnc_lconv_set_utf8(&lc.grouping, "\003"); - gnc_lconv_set_utf8(&lc.int_curr_symbol, "USD "); - gnc_lconv_set_utf8(&lc.currency_symbol, "$"); - gnc_lconv_set_utf8(&lc.mon_decimal_point, "."); - gnc_lconv_set_utf8(&lc.mon_thousands_sep, ","); - gnc_lconv_set_utf8(&lc.mon_grouping, "\003"); - gnc_lconv_set_utf8(&lc.negative_sign, "-"); - gnc_lconv_set_utf8(&lc.positive_sign, ""); - - gnc_lconv_set_char(&lc.frac_digits, 2); - gnc_lconv_set_char(&lc.int_frac_digits, 2); - gnc_lconv_set_char(&lc.p_cs_precedes, 1); - gnc_lconv_set_char(&lc.p_sep_by_space, 0); - gnc_lconv_set_char(&lc.n_cs_precedes, 1); - gnc_lconv_set_char(&lc.n_sep_by_space, 0); - gnc_lconv_set_char(&lc.p_sign_posn, 1); - gnc_lconv_set_char(&lc.n_sign_posn, 1); - - lc_set = TRUE; - - return &lc; -} - -const char * -gnc_locale_default_iso_currency_code (void) -{ - static char *code = NULL; - struct lconv *lc; - - if (code) - return code; - - lc = gnc_localeconv (); - - code = g_strdup (lc->int_curr_symbol); - - /* The int_curr_symbol includes a space at the end! Note: you - * can't just change "USD " to "USD" in gnc_localeconv, because - * that is only used if int_curr_symbol was not defined in the - * current locale. If it was, it will have the space! */ - g_strstrip (code); - - return code; -} gnc_commodity * gnc_locale_default_currency_nodefault (void) @@ -1113,67 +1057,6 @@ gnc_currency_changed_cb (GConfEntry *entry, gpointer user_data) } -/* Return the number of decimal places for this locale. */ -int -gnc_locale_decimal_places (void) -{ - static gboolean got_it = FALSE; - static int places; - struct lconv *lc; - - if (got_it) - return places; - - lc = gnc_localeconv(); - places = lc->frac_digits; - - /* frac_digits is already initialized by gnc_localeconv, hopefully - * to a reasonable default. */ - got_it = TRUE; - - return places; -} - - -static GList *locale_stack = NULL; - -void -gnc_push_locale (int category, const char *locale) -{ - char *saved_locale; - - g_return_if_fail (locale != NULL); - -# ifdef G_OS_WIN32 - /* On win32, setlocale() doesn't say anything useful. Use - glib's function instead. */ - saved_locale = g_win32_getlocale(); -# else - saved_locale = g_strdup(setlocale(category, NULL) ? - setlocale(category, NULL) : "C"); -#endif - locale_stack = g_list_prepend (locale_stack, saved_locale); - setlocale (category, locale); -} - -void -gnc_pop_locale (int category) -{ - char *saved_locale; - GList *node; - - g_return_if_fail (locale_stack != NULL); - - node = locale_stack; - saved_locale = node->data; - - setlocale (category, saved_locale); - - locale_stack = g_list_remove_link (locale_stack, node); - g_list_free_1 (node); - g_free (saved_locale); -} - GNCPrintAmountInfo gnc_default_print_info (gboolean use_symbol) { diff --git a/src/app-utils/gnc-ui-util.h b/src/app-utils/gnc-ui-util.h index af480b3c44..d1f228a3e7 100644 --- a/src/app-utils/gnc-ui-util.h +++ b/src/app-utils/gnc-ui-util.h @@ -204,10 +204,6 @@ gboolean gnc_account_create_opening_balance (Account *account, /* Locale functions *************************************************/ -/* The gnc_localeconv() subroutine returns an lconv structure - * containing locale information. If no locale is set, the structure - * is given default (en_US) values. */ -struct lconv * gnc_localeconv (void); /* Returns the default currency of the current locale, or NULL if no * sensible currency could be identified from the locale. */ @@ -239,31 +235,6 @@ gnc_commodity * gnc_default_currency (void); */ gnc_commodity * gnc_default_report_currency (void); - -/* Returns the number of decimal place to print in the current locale */ -int gnc_locale_decimal_places (void); - -/** Temporarily change locale, pushing the old one onto a stack - * Currently, this has no effect on gnc_localeconv. i.e., after the - * first call to gnc_localeconv, subsequent calls will return the same - * information. - * - * WARNING: Be careful to maintain the correct nesting order of pushes - * or pops; otherwise, the localization results might be - * interesting. Note that the stack does not keep track of which - * category a locale was pushed from, so careless use will alse - * produce interesting results. - * - * @param category: The locale category (e.g. LC_ALL, LC_NUMERIC) to push onto - * @param locale: The new locale to set - */ -void gnc_push_locale (int category, const char *locale); - -/** Restore the last-pushed locale. - * @param category: The locale category to restore the locale to. - */ -void gnc_pop_locale (int category); - /* Amount printing and parsing **************************************/ /* diff --git a/src/backend/dbi/gnc-backend-dbi.c b/src/backend/dbi/gnc-backend-dbi.c index f65c0e49ba..63b2b70385 100644 --- a/src/backend/dbi/gnc-backend-dbi.c +++ b/src/backend/dbi/gnc-backend-dbi.c @@ -47,7 +47,7 @@ #include "gnc-gconf-utils.h" #include "gnc-uri-utils.h" -#include "gnc-ui-util.h" +#include "gnc-locale-utils.h" #include "gnc-backend-dbi.h" diff --git a/src/backend/dbi/test/Makefile.am b/src/backend/dbi/test/Makefile.am index aa85e26253..a4adeaccb9 100644 --- a/src/backend/dbi/test/Makefile.am +++ b/src/backend/dbi/test/Makefile.am @@ -54,7 +54,6 @@ LDADD = ${top_builddir}/src/test-core/libtest-core.la \ ${top_builddir}/src/gnc-module/libgnc-module.la \ ${top_builddir}/src/engine/libgncmod-engine.la \ ${top_builddir}/src/engine/test-core/libgncmod-test-engine.la \ - ${top_builddir}/src/app-utils/libgncmod-app-utils.la \ ${top_builddir}/src/core-utils/libgnc-core-utils.la \ ${top_builddir}/src/libqof/qof/libgnc-qof.la \ ${top_builddir}/src/backend/dbi/test/libgncmod-test-dbi.la \ diff --git a/src/core-utils/Makefile.am b/src/core-utils/Makefile.am index f2c5387d77..b1b3082546 100644 --- a/src/core-utils/Makefile.am +++ b/src/core-utils/Makefile.am @@ -10,6 +10,7 @@ libgnc_core_utils_la_SOURCES = \ gnc-gkeyfile-utils.c \ gnc-glib-utils.c \ gnc-jalali.c \ + gnc-locale-utils.c \ gnc-main.c \ gnc-path.c \ gnc-uri-utils.c \ @@ -32,6 +33,7 @@ noinst_HEADERS = \ gnc-gkeyfile-utils.h \ gnc-glib-utils.h \ gnc-jalali.h \ + gnc-locale-utils.h \ gnc-path.h \ gnc-uri-utils.h diff --git a/src/core-utils/core-utils.i b/src/core-utils/core-utils.i index 673fbc6d02..b3ca533618 100644 --- a/src/core-utils/core-utils.i +++ b/src/core-utils/core-utils.i @@ -5,6 +5,7 @@ #include #include #include +#include #include SCM scm_init_sw_core_utils_module (void); @@ -38,6 +39,8 @@ gchar * gnc_locale_from_utf8(const gchar *); %newobject gnc_locale_to_utf8; gchar * gnc_locale_to_utf8(const gchar *); +const char * gnc_locale_default_iso_currency_code (void); + %rename ("gnc-utf8?") wrap_gnc_utf8_validate; %inline %{ /* This helper function wraps gnc_utf8_validate() into a predicate. */ diff --git a/src/html/gnc-html-graph-gog-gtkhtml.c b/src/html/gnc-html-graph-gog-gtkhtml.c index a8f4741f89..dd6c932bfe 100644 --- a/src/html/gnc-html-graph-gog-gtkhtml.c +++ b/src/html/gnc-html-graph-gog-gtkhtml.c @@ -28,7 +28,7 @@ #include #include -#include "gnc-ui-util.h" +#include "gnc-locale-utils.h" #include "gnc-html-graph-gog.h" #include "gnc-html-graph-gog-gtkhtml.h" #include "gnc-html-graph-gog-extras.h" diff --git a/src/html/gnc-html-graph-gog-webkit.c b/src/html/gnc-html-graph-gog-webkit.c index 06a60f92a0..91a5f4bf17 100644 --- a/src/html/gnc-html-graph-gog-webkit.c +++ b/src/html/gnc-html-graph-gog-webkit.c @@ -29,7 +29,7 @@ #include #include -#include "gnc-ui-util.h" +#include "gnc-locale-utils.h" #include "gnc-html-graph-gog.h" #include "gnc-html-graph-gog-webkit.h" #include "gnc-html-graph-gog-extras.h"