[gnome-calculator/currency-display-format: 2/3] Fixed display in preferences




commit d91b17173ee2394819c66452cff619d280f3916d
Author: A.M. Rowsell <amrowsell frozenelectronics ca>
Date:   Tue Nov 3 18:16:43 2020 -0500

    Fixed display in preferences
    
    The option was not displaying in preferences because I had
    forgotten to add the set_combo_box_from_int for the new combo
    box. Also, added (requires restart) because the only sane way
    to change the displayed labels for currencies is when the list
    is created at startup. Shouldn't be a big deal.
    
    Working on getting it to display for financial mode -- the
    conversion dropdown in advanced mode does display correctly. I
    think this commit fixes it but I'm having issues with Builder.

 src/math-converter.vala    | 22 +++++++++++++++++++++-
 src/math-preferences.vala  |  1 +
 src/ui/math-preferences.ui |  2 +-
 3 files changed, 23 insertions(+), 2 deletions(-)
---
diff --git a/src/math-converter.vala b/src/math-converter.vala
index 09e69415..b52c13d2 100644
--- a/src/math-converter.vala
+++ b/src/math-converter.vala
@@ -167,7 +167,27 @@ public class MathConverter : Gtk.Grid
             {
                 Gtk.TreeIter iter;
                 from_model.append (out iter, null);
-                from_model.set (iter, 0, unit.display_name, 1, c, 2, unit, -1);
+                if (category == "currency")
+                {
+                    var CurrencyFormat = settings.get_int ("currency-display-format");
+                    if (CurrencyFormat == 0) /* Currency names */
+                    {
+                        from_model.set (iter, 0, unit.display_name, 1, category, 2, unit, -1);
+                    }
+                    else if (CurrencyFormat == 1) /* Currency code */
+                    {
+                        from_model.set (iter, 0, unit.name, 1, category, 2, unit, -1);
+                    }
+                    else if (CurrencyFormat == 2) /* Both */
+                    {
+                        string DisplayName = unit.display_name + unit.name;
+                        from_model.set (iter, 0, DisplayName, 1, category, 2, unit, -1);
+                    }
+                }
+                else
+                {
+                    from_model.set (iter, 0, unit.display_name, 1, category, 2, unit, -1);
+                }
             }
         }
 
diff --git a/src/math-preferences.vala b/src/math-preferences.vala
index 285207af..87b34f92 100644
--- a/src/math-preferences.vala
+++ b/src/math-preferences.vala
@@ -62,6 +62,7 @@ public class MathPreferencesDialog : Gtk.Dialog
         equation.notify["angle-units"].connect ((pspec) => { set_combo_box_from_int (combo_angle_units, 
equation.angle_units); });
 
         set_combo_box_from_int (combo_refresh_interval, settings.get_int ("refresh-interval"));
+        set_combo_box_from_int (combo_currency_display_format, settings.get_int ("currency-display-format"));
     }
 
 
diff --git a/src/ui/math-preferences.ui b/src/ui/math-preferences.ui
index 4910e380..6985fb0f 100644
--- a/src/ui/math-preferences.ui
+++ b/src/ui/math-preferences.ui
@@ -224,7 +224,7 @@
                 <property name="visible">True</property>
                 <property name="can-focus">False</property>
                 <property name="halign">start</property>
-                <property name="label" translatable="yes">Currenc_y format</property>
+                <property name="label" translatable="yes">Currenc_y format (requires restart)</property>
                 <property name="use-underline">True</property>
               </object>
               <packing>


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]