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

John Ralls jralls at code.gnucash.org
Sun Jan 30 23:29:49 EST 2011


Author: jralls
Date: 2011-01-30 23:29:48 -0500 (Sun, 30 Jan 2011)
New Revision: 20209
Trac: http://svn.gnucash.org/trac/changeset/20209

Modified:
   gnucash/trunk/src/app-utils/app-utils.i
   gnucash/trunk/src/app-utils/gnc-exp-parser.c
   gnucash/trunk/src/app-utils/gnc-ui-util.c
   gnucash/trunk/src/app-utils/gnc-ui-util.h
   gnucash/trunk/src/backend/dbi/gnc-backend-dbi.c
   gnucash/trunk/src/backend/dbi/test/Makefile.am
   gnucash/trunk/src/core-utils/Makefile.am
   gnucash/trunk/src/core-utils/core-utils.i
   gnucash/trunk/src/html/gnc-html-graph-gog-gtkhtml.c
   gnucash/trunk/src/html/gnc-html-graph-gog-webkit.c
Log:
Move gnc_locale functions from src/app-utils/gnc-ui-util to src/core-utils/gnc-locale-utils (new files) and adjust accordingly.

Modified: gnucash/trunk/src/app-utils/app-utils.i
===================================================================
--- gnucash/trunk/src/app-utils/app-utils.i	2011-01-30 22:40:22 UTC (rev 20208)
+++ gnucash/trunk/src/app-utils/app-utils.i	2011-01-31 04:29:48 UTC (rev 20209)
@@ -68,8 +68,6 @@
 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);

Modified: gnucash/trunk/src/app-utils/gnc-exp-parser.c
===================================================================
--- gnucash/trunk/src/app-utils/gnc-exp-parser.c	2011-01-30 22:40:22 UTC (rev 20208)
+++ gnucash/trunk/src/app-utils/gnc-exp-parser.c	2011-01-31 04:29:48 UTC (rev 20209)
@@ -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"

Modified: gnucash/trunk/src/app-utils/gnc-ui-util.c
===================================================================
--- gnucash/trunk/src/app-utils/gnc-ui-util.c	2011-01-30 22:40:22 UTC (rev 20208)
+++ gnucash/trunk/src/app-utils/gnc-ui-util.c	2011-01-31 04:29:48 UTC (rev 20209)
@@ -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,64 +967,7 @@
         *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 @@
 }
 
 
-/* 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)
 {

Modified: gnucash/trunk/src/app-utils/gnc-ui-util.h
===================================================================
--- gnucash/trunk/src/app-utils/gnc-ui-util.h	2011-01-30 22:40:22 UTC (rev 20208)
+++ gnucash/trunk/src/app-utils/gnc-ui-util.h	2011-01-31 04:29:48 UTC (rev 20209)
@@ -204,10 +204,6 @@
 
 /* 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_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 **************************************/
 
 /*

Modified: gnucash/trunk/src/backend/dbi/gnc-backend-dbi.c
===================================================================
--- gnucash/trunk/src/backend/dbi/gnc-backend-dbi.c	2011-01-30 22:40:22 UTC (rev 20208)
+++ gnucash/trunk/src/backend/dbi/gnc-backend-dbi.c	2011-01-31 04:29:48 UTC (rev 20209)
@@ -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"
 

Modified: gnucash/trunk/src/backend/dbi/test/Makefile.am
===================================================================
--- gnucash/trunk/src/backend/dbi/test/Makefile.am	2011-01-30 22:40:22 UTC (rev 20208)
+++ gnucash/trunk/src/backend/dbi/test/Makefile.am	2011-01-31 04:29:48 UTC (rev 20209)
@@ -54,7 +54,6 @@
         ${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 \

Modified: gnucash/trunk/src/core-utils/Makefile.am
===================================================================
--- gnucash/trunk/src/core-utils/Makefile.am	2011-01-30 22:40:22 UTC (rev 20208)
+++ gnucash/trunk/src/core-utils/Makefile.am	2011-01-31 04:29:48 UTC (rev 20209)
@@ -10,6 +10,7 @@
   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 @@
   gnc-gkeyfile-utils.h \
   gnc-glib-utils.h \
   gnc-jalali.h \
+  gnc-locale-utils.h \
   gnc-path.h \
   gnc-uri-utils.h
 

Modified: gnucash/trunk/src/core-utils/core-utils.i
===================================================================
--- gnucash/trunk/src/core-utils/core-utils.i	2011-01-30 22:40:22 UTC (rev 20208)
+++ gnucash/trunk/src/core-utils/core-utils.i	2011-01-31 04:29:48 UTC (rev 20209)
@@ -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 @@
 %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. */

Modified: gnucash/trunk/src/html/gnc-html-graph-gog-gtkhtml.c
===================================================================
--- gnucash/trunk/src/html/gnc-html-graph-gog-gtkhtml.c	2011-01-30 22:40:22 UTC (rev 20208)
+++ gnucash/trunk/src/html/gnc-html-graph-gog-gtkhtml.c	2011-01-31 04:29:48 UTC (rev 20209)
@@ -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"

Modified: gnucash/trunk/src/html/gnc-html-graph-gog-webkit.c
===================================================================
--- gnucash/trunk/src/html/gnc-html-graph-gog-webkit.c	2011-01-30 22:40:22 UTC (rev 20208)
+++ gnucash/trunk/src/html/gnc-html-graph-gog-webkit.c	2011-01-31 04:29:48 UTC (rev 20209)
@@ -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"



More information about the gnucash-changes mailing list