[gnome-calculator/currency-display-format] Removed requirement for restart when currency format is changed



commit 7baa0d3652a3a355ca13c3a8a10bf94042a65247
Author: A.M. Rowsell <amrowsell frozenelectronics ca>
Date:   Wed Nov 4 17:56:28 2020 -0500

    Removed requirement for restart when currency format is changed
    
    The MathConverter class now connects to the settings changed
    signal, looking for changes to the currency-display-format setting.
    If this occurs, it updates the from model and also provokes a
    callback to from_combobox_changed_cb() to update the displayed
    units. However, because of the if (category != to_category) statement
    in that function, the to combobox is not being updated.

 src/math-converter.vala | 7 +++++++
 1 file changed, 7 insertions(+)
---
diff --git a/src/math-converter.vala b/src/math-converter.vala
index 87cf9f90..11d0b59f 100644
--- a/src/math-converter.vala
+++ b/src/math-converter.vala
@@ -38,6 +38,7 @@ public class MathConverter : Gtk.Grid
     construct
     {
         settings = new Settings ("org.gnome.calculator");
+        settings.changed["currency-display-format"].connect (() => { update_financial_labels (); });
         from_combo.set_cell_data_func (from_renderer, from_cell_data_func);
         CurrencyManager.get_default ().updated.connect (() => { update_result_label (); });
 
@@ -120,6 +121,12 @@ public class MathConverter : Gtk.Grid
         }
     }
 
+    private void update_financial_labels ()
+    {
+        update_from_model ();
+        from_combobox_changed_cb ();
+    }
+
     private string get_unit_display_name (UnitCategory category, Unit unit) {
         if (category.name != "currency") return unit.display_name;
         var currencyFormat = settings.get_int ("currency-display-format");


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