Move gnc_locale functions from src/app-utils/gnc-ui-util to src/core-utils/gnc-locale-utils (new files) and adjust accordingly.

git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@20209 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
John Ralls 2011-01-31 04:29:48 +00:00
parent 9872a070e3
commit 8ff535a1af
10 changed files with 10 additions and 153 deletions

View File

@ -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);

View File

@ -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"

View File

@ -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)
{

View File

@ -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 **************************************/
/*

View File

@ -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"

View File

@ -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 \

View File

@ -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

View File

@ -5,6 +5,7 @@
#include <gnc-main.h>
#include <gnc-path.h>
#include <gnc-filepath-utils.h>
#include <gnc-locale-utils.h>
#include <glib.h>
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. */

View File

@ -28,7 +28,7 @@
#include <gtkhtml/gtkhtml-embedded.h>
#include <string.h>
#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"

View File

@ -29,7 +29,7 @@
#include <string.h>
#include <stdlib.h>
#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"