r23322 - gnucash/trunk/src - Use the new user_symbol property where relevant

Geert Janssens gjanssens at code.gnucash.org
Thu Oct 24 08:27:49 EDT 2013


Author: gjanssens
Date: 2013-10-24 08:27:49 -0400 (Thu, 24 Oct 2013)
New Revision: 23322
Trac: http://svn.gnucash.org/trac/changeset/23322

Modified:
   gnucash/trunk/src/app-utils/gnc-ui-util.c
   gnucash/trunk/src/app-utils/gnc-ui-util.h
   gnucash/trunk/src/gnome-utils/window-main-summarybar.c
Log:
Use the new user_symbol property where relevant

Author:    Frédéric Perrin <frederic.perrin at resel.fr>

Modified: gnucash/trunk/src/app-utils/gnc-ui-util.c
===================================================================
--- gnucash/trunk/src/app-utils/gnc-ui-util.c	2013-10-24 12:27:37 UTC (rev 23321)
+++ gnucash/trunk/src/app-utils/gnc-ui-util.c	2013-10-24 12:27:49 UTC (rev 23322)
@@ -1454,48 +1454,36 @@
         return 0;
 
     lc = gnc_localeconv();
-
-    if (info.use_symbol)
-    {
-        /* There was a bug here: don't use gnc_locale_default_currency */
-        if (gnc_commodity_equiv (info.commodity,
-                                 gnc_locale_default_currency_nodefault ()))
+    if (info.use_locale)
+        if (gnc_numeric_negative_p (val))
         {
-            currency_symbol = lc->currency_symbol;
+            cs_precedes  = lc->n_cs_precedes;
+            sep_by_space = lc->n_sep_by_space;
         }
         else
         {
-            if (info.commodity && !gnc_commodity_is_iso (info.commodity))
-                is_shares = TRUE;
-
-            currency_symbol = gnc_commodity_get_mnemonic (info.commodity);
-            info.use_locale = 0;
+            cs_precedes  = lc->p_cs_precedes;
+            sep_by_space = lc->p_sep_by_space;
         }
-
-        if (currency_symbol == NULL)
-            currency_symbol = "";
-    }
     else
-        currency_symbol = NULL;
-
-    if (!info.use_locale)
     {
-        cs_precedes = is_shares ? 0 : 1;
-        sep_by_space = 1;
+        cs_precedes = TRUE;
+        sep_by_space = TRUE;
     }
-    else
+
+    if (info.commodity && info.use_symbol)
     {
-        if (gnc_numeric_negative_p (val))
-        {
-            cs_precedes  = lc->n_cs_precedes;
-            sep_by_space = lc->n_sep_by_space;
-        }
+        if (gnc_commodity_is_iso (info.commodity))
+	    currency_symbol = gnc_commodity_get_nice_symbol (info.commodity);
         else
         {
-            cs_precedes  = lc->p_cs_precedes;
-            sep_by_space = lc->p_sep_by_space;
+            currency_symbol = gnc_commodity_get_mnemonic (info.commodity);
+            cs_precedes  = FALSE;
+            sep_by_space = TRUE;
         }
     }
+    else /* !info.use_symbol || !info.commodity */
+        currency_symbol = "";
 
     if (gnc_numeric_negative_p (val))
     {
@@ -1759,7 +1747,23 @@
     return xaccPrintAmount (num, info);
 }
 
+const char*
+gnc_commodity_get_nice_symbol(const gnc_commodity *cm)
+{
+    const char *nice_symbol;
+    if (!cm) return NULL;
 
+    nice_symbol = gnc_commodity_get_user_symbol(cm);
+    if (nice_symbol)
+	return nice_symbol;
+    else if (gnc_commodity_equiv (cm, gnc_locale_default_currency_nodefault ()))
+	return gnc_localeconv()->currency_symbol;
+    else if ((nice_symbol = gnc_commodity_get_mnemonic(cm)))
+	return nice_symbol;
+    else
+	return "";
+}
+
 /********************************************************************\
  * xaccParseAmount                                                  *
  *   parses amount strings using locale data                        *

Modified: gnucash/trunk/src/app-utils/gnc-ui-util.h
===================================================================
--- gnucash/trunk/src/app-utils/gnc-ui-util.h	2013-10-24 12:27:37 UTC (rev 23321)
+++ gnucash/trunk/src/app-utils/gnc-ui-util.h	2013-10-24 12:27:49 UTC (rev 23322)
@@ -259,6 +259,7 @@
 int xaccSPrintAmount (char *buf, gnc_numeric val, GNCPrintAmountInfo info);
 
 const gchar *printable_value(gdouble val, gint denom);
+const char*gnc_commodity_get_nice_symbol(const gnc_commodity *cm);
 gchar *number_to_words(gdouble val, gint64 denom);
 gchar *numeric_to_words(gnc_numeric val);
 

Modified: gnucash/trunk/src/gnome-utils/window-main-summarybar.c
===================================================================
--- gnucash/trunk/src/gnome-utils/window-main-summarybar.c	2013-10-24 12:27:37 UTC (rev 23321)
+++ gnucash/trunk/src/gnome-utils/window-main-summarybar.c	2013-10-24 12:27:49 UTC (rev 23322)
@@ -395,11 +395,7 @@
 
             currency_accum = current->data;
 
-            if (gnc_commodity_equiv (currency_accum->currency, gnc_locale_default_currency ()))
-                mnemonic = lc->currency_symbol;
-            else
-                mnemonic = gnc_commodity_get_mnemonic (currency_accum->currency);
-
+	    mnemonic = gnc_commodity_get_nice_symbol (currency_accum->currency);
             if (mnemonic == NULL)
                 mnemonic = "";
 



More information about the gnucash-changes mailing list