From 35186367db316d2d5c55e9eff43fdfe5544ae357 Mon Sep 17 00:00:00 2001 From: CentOS Sources Date: Oct 06 2021 03:01:12 +0000 Subject: import gnome-calculator-3.28.2-2.el8 --- diff --git a/SOURCES/0001-Implemented-exchange-rate-refresh-interval-setting.patch b/SOURCES/0001-Implemented-exchange-rate-refresh-interval-setting.patch new file mode 100644 index 0000000..7e456ca --- /dev/null +++ b/SOURCES/0001-Implemented-exchange-rate-refresh-interval-setting.patch @@ -0,0 +1,552 @@ +From fc5cb8d7cff03a48cf88e9df1007a497293b56bb Mon Sep 17 00:00:00 2001 +From: Robert Roth +Date: Sun, 3 Feb 2019 16:31:28 +0200 +Subject: [PATCH 1/5] Implemented exchange rate refresh interval setting + +--- + data/org.gnome.calculator.gschema.xml | 5 ++++ + lib/currency.vala | 10 +++++-- + src/gnome-calculator.vala | 1 + + src/math-preferences.vala | 40 +++++++++++++++++++++++++++ + 4 files changed, 54 insertions(+), 2 deletions(-) + +diff --git a/data/org.gnome.calculator.gschema.xml b/data/org.gnome.calculator.gschema.xml +index 8cb1fc83..a3af435f 100644 +--- a/data/org.gnome.calculator.gschema.xml ++++ b/data/org.gnome.calculator.gschema.xml +@@ -30,60 +30,65 @@ + + Word size + The size of the words used in bitwise operations + + + 10 + + Numeric Base + The numeric base + + + false + Show Thousands Separators + Indicates whether thousands separators are shown in large numbers. + + + false + Show Trailing Zeroes + Indicates whether any trailing zeroes after the numeric point should be shown in the display value. + + + 'automatic' + Number format + The format to display numbers in + + + 'degrees' + Angle units + The angle units to use + ++ ++ 604800 ++ Currency update interval ++ How often the currency exchange rates should be updated ++ + + 'basic' + Button mode + The button mode + + + '' + Source currency + Currency of the current calculation + + + '' + Target currency + Currency to convert the current calculation into + + + 'degree' + Source units + Units of the current calculation + + + 'radian' + Target units + Units to convert the current calculation into + + + 2000 + Internal precision + The internal precision used with the MPFR library + +diff --git a/lib/currency.vala b/lib/currency.vala +index f9b913aa..c098cc52 100644 +--- a/lib/currency.vala ++++ b/lib/currency.vala +@@ -1,48 +1,51 @@ + /* + * Copyright (C) 2008-2012 Robert Ancell. + * + * This program is free software: you can redistribute it and/or modify it under + * the terms of the GNU General Public License as published by the Free Software + * Foundation, either version 3 of the License, or (at your option) any later + * version. See http://www.gnu.org/copyleft/gpl.html the full text of the + * license. + */ + + static bool downloading_imf_rates = false; + static bool downloading_ecb_rates = false; + static bool loaded_rates = false; + private static CurrencyManager? default_currency_manager = null; + + public class CurrencyManager : Object + { + private List currencies; ++ ++ public int refresh_interval { get; set; } ++ + public signal void updated (); + + public static CurrencyManager get_default () + { + if (default_currency_manager != null) + return default_currency_manager; + + default_currency_manager = new CurrencyManager (); + + default_currency_manager.currencies.append (new Currency ("AED", _("UAE Dirham"), "إ.د")); + default_currency_manager.currencies.append (new Currency ("AUD", _("Australian Dollar"), "$")); + default_currency_manager.currencies.append (new Currency ("BGN", _("Bulgarian Lev"), "лв")); + default_currency_manager.currencies.append (new Currency ("BHD", _("Bahraini Dinar"), ".ب.د")); + default_currency_manager.currencies.append (new Currency ("BND", _("Brunei Dollar"), "$")); + default_currency_manager.currencies.append (new Currency ("BRL", _("Brazilian Real"), "R$")); + default_currency_manager.currencies.append (new Currency ("BWP", _("Botswana Pula"), "P")); + default_currency_manager.currencies.append (new Currency ("CAD", _("Canadian Dollar"), "$")); + default_currency_manager.currencies.append (new Currency ("CFA", _("CFA Franc"), "Fr")); + default_currency_manager.currencies.append (new Currency ("CHF", _("Swiss Franc"), "Fr")); + default_currency_manager.currencies.append (new Currency ("CLP", _("Chilean Peso"), "$")); + default_currency_manager.currencies.append (new Currency ("CNY", _("Chinese Yuan"), "¥")); + default_currency_manager.currencies.append (new Currency ("COP", _("Colombian Peso"), "$")); + default_currency_manager.currencies.append (new Currency ("CZK", _("Czech Koruna"), "Kč")); + default_currency_manager.currencies.append (new Currency ("DKK", _("Danish Krone"), "kr")); + default_currency_manager.currencies.append (new Currency ("DZD", _("Algerian Dinar"), "ج.د")); + default_currency_manager.currencies.append (new Currency ("EEK", _("Estonian Kroon"), "KR")); + default_currency_manager.currencies.append (new Currency ("EUR", _("Euro"), "€")); + default_currency_manager.currencies.append (new Currency ("GBP", _("British Pound Sterling"), "£")); + default_currency_manager.currencies.append (new Currency ("HKD", _("Hong Kong Dollar"), "$")); + default_currency_manager.currencies.append (new Currency ("HRK", _("Croatian Kuna"), "kn")); +@@ -120,60 +123,63 @@ public class CurrencyManager : Object + return Path.build_filename (Environment.get_user_cache_dir (), "gnome-calculator", "rms_five.xls"); + } + + private string get_ecb_rate_filepath () + { + return Path.build_filename (Environment.get_user_cache_dir (), "gnome-calculator", "eurofxref-daily.xml"); + } + + private Currency add_currency (string short_name, string source) + { + foreach (var c in currencies) + if (c.name == short_name) + { + c.source = source; + return c; + } + + warning ("Currency %s is not in the currency table", short_name); + var c = new Currency (short_name, short_name, short_name); + c.source = source; + currencies.append (c); + + return c; + } + + /* A file needs to be redownloaded if it doesn't exist, or is too old. + * When an error occur, it probably won't hurt to try to download again. + */ + private bool file_needs_update (string filename, double max_age) + { ++ if (max_age == 0) ++ return false; ++ + if (!FileUtils.test (filename, FileTest.IS_REGULAR)) + return true; + + var buf = Posix.Stat (); + if (Posix.stat (filename, out buf) == -1) + return true; + + var modify_time = buf.st_mtime; + var now = time_t (); + if (now - modify_time > max_age) + return true; + + return false; + } + + private void load_imf_rates () + { + var name_map = new HashTable (str_hash, str_equal); + name_map.insert ("Euro", "EUR"); + name_map.insert ("Japanese yen", "JPY"); + name_map.insert ("U.K. pound", "GBP"); + name_map.insert ("U.S. dollar", "USD"); + name_map.insert ("Algerian dinar", "DZD"); + name_map.insert ("Australian dollar", "AUD"); + name_map.insert ("Bahrain dinar", "BHD"); + name_map.insert ("Botswana pula", "BWP"); + name_map.insert ("Brazilian real", "BRL"); + name_map.insert ("Brunei dollar", "BND"); + name_map.insert ("Canadian dollar", "CAD"); + name_map.insert ("Chilean peso", "CLP"); +@@ -350,68 +356,68 @@ public class CurrencyManager : Object + return; + } + + xpath_ctx.register_ns ("xref", "http://www.ecb.int/vocabulary/2002-08-01/eurofxref"); + var xpath_obj = xpath_ctx.eval_expression ("//xref:Cube[@currency][@rate]"); + if (xpath_obj == null) + { + warning ("Couldn't create XPath object"); + return; + } + var len = (xpath_obj->nodesetval != null) ? xpath_obj->nodesetval->length () : 0; + for (var i = 0; i < len; i++) + { + var node = xpath_obj->nodesetval->item (i); + + if (node->type == Xml.ElementType.ELEMENT_NODE) + set_ecb_rate (node, eur_rate); + + /* Avoid accessing removed elements */ + if (node->type != Xml.ElementType.NAMESPACE_DECL) + node = null; + } + + Xml.Parser.cleanup (); + } + + private void download_rates () + { + /* Update rates if necessary */ + var path = get_imf_rate_filepath (); +- if (!downloading_imf_rates && file_needs_update (path, 60 * 60 * 24 * 7)) ++ if (!downloading_imf_rates && file_needs_update (path, refresh_interval)) + { + downloading_imf_rates = true; + debug ("Downloading rates from the IMF..."); + download_file.begin ("https://www.imf.org/external/np/fin/data/rms_five.aspx?tsvflag=Y", path, "IMF"); + } + path = get_ecb_rate_filepath (); +- if (!downloading_ecb_rates && file_needs_update (path, 60 * 60 * 24 * 7)) ++ if (!downloading_ecb_rates && file_needs_update (path, refresh_interval)) + { + downloading_ecb_rates = true; + debug ("Downloading rates from the ECB..."); + download_file.begin ("https://www.ecb.europa.eu/stats/eurofxref/eurofxref-daily.xml", path, "ECB"); + } + } + + private bool load_rates () + { + /* Already loaded */ + if (loaded_rates) + return true; + + /* In process */ + if (downloading_imf_rates || downloading_ecb_rates) + return false; + + /* Use the IMF provided values and top up with currencies tracked by the ECB and not the IMF */ + load_imf_rates (); + load_ecb_rates (); + + /* Check if we couldn't find out a currency */ + foreach (var c in currencies) + if (c.get_value () == null || c.get_value ().is_zero ()) + warning ("Currency %s is not provided by IMF or ECB", c.name); + + debug ("Rates loaded"); + loaded_rates = true; + + updated (); +diff --git a/src/gnome-calculator.vala b/src/gnome-calculator.vala +index 9f2549e7..5b3f9b8d 100644 +--- a/src/gnome-calculator.vala ++++ b/src/gnome-calculator.vala +@@ -100,60 +100,61 @@ public class Calculator : Gtk.Application + } + catch (Error e) + { + error ("Error loading menu UI: %s", e.message); + } + + var menu = builder.get_object ("appmenu") as MenuModel; + set_app_menu (menu); + + set_accels_for_action ("win.mode::basic", {"B"}); + set_accels_for_action ("win.mode::advanced", {"A"}); + set_accels_for_action ("win.mode::financial", {"F"}); + set_accels_for_action ("win.mode::programming", {"P"}); + set_accels_for_action ("win.mode::keyboard", {"K"}); + set_accels_for_action ("win.copy", {"C"}); + set_accels_for_action ("win.paste", {"V"}); + set_accels_for_action ("win.undo", {"Z"}); + set_accels_for_action ("win.close", {"W"}); + set_accels_for_action ("win.redo", {"Z"}); + return current_window; + } + + protected override void startup () + { + base.startup (); + + settings = new Settings ("org.gnome.calculator"); + last_opened_window = create_new_window (settings); + // restore the first window position from the settings + load_window_position (last_opened_window); ++ CurrencyManager.get_default ().refresh_interval = settings.get_int ("refresh-interval"); + } + + private MathWindow get_active_math_window () + { + return (MathWindow) get_active_window (); + } + + protected override void activate () + { + base.activate (); + + last_opened_window.present (); + if (equation_string != "" && equation_string != null) + { + var equations = (equation_string.compress ()).split ("\n",0); + for (var i = 0; i < equations.length; i++) + { + if ((equations [i].strip ()).length > 0) + last_opened_window.equation.set (equations [i]); + else + last_opened_window.equation.solve (); + } + } + if (mode_string != "" && mode_string != null) + { + var mode = ButtonMode.BASIC; + + switch (mode_string) + { + case "basic": +diff --git a/src/math-preferences.vala b/src/math-preferences.vala +index d1ab7657..335b97c6 100644 +--- a/src/math-preferences.vala ++++ b/src/math-preferences.vala +@@ -1,58 +1,61 @@ + /* + * Copyright (C) 2008-2012 Robert Ancell + * + * This program is free software: you can redistribute it and/or modify it under + * the terms of the GNU General Public License as published by the Free Software + * Foundation, either version 3 of the License, or (at your option) any later + * version. See http://www.gnu.org/copyleft/gpl.html the full text of the + * license. + */ + + public class MathPreferencesDialog : Gtk.Dialog + { + public MathEquation equation { private get; construct; } + + private Gtk.ComboBox angle_unit_combo; ++ private Gtk.ComboBox refresh_interval_combo; + private Gtk.ComboBox number_format_combo; + private Gtk.ComboBox word_size_combo; + private Gtk.SpinButton decimal_places_spin; + private Gtk.Switch thousands_separator_switch; + private Gtk.Switch trailing_zeroes_switch; ++ private Settings settings; + + public MathPreferencesDialog (MathEquation eq) + { + Object(use_header_bar: 1, equation: eq, resizable: false); + } + + construct + { ++ settings = new Settings ("org.gnome.calculator"); + set_title (/* Title of preferences dialog */ + _("Preferences")); + border_width = 8; + + ((Gtk.HeaderBar) get_header_bar ()).show_close_button = true; + + var grid = new Gtk.Grid (); + grid.show (); + grid.border_width = 5; + grid.column_spacing = 6; + grid.row_spacing = 12; + get_content_area ().pack_start (grid, true, true, 0); + + var label = new Gtk.Label.with_mnemonic (/* Preferences dialog: Label for number format combo box */ + _("Number _Format:")); + label.show (); + label.xalign = 0; + grid.attach (label, 0, 0, 1, 1); + + number_format_combo = new Gtk.ComboBox (); + label.mnemonic_widget = number_format_combo; + number_format_combo.show (); + number_format_combo.changed.connect (number_format_combo_changed_cb); + grid.attach (number_format_combo, 1, 0, 1, 1); + + var model = new Gtk.ListStore (2, typeof (string), typeof (int)); + number_format_combo.model = model; + Gtk.TreeIter iter; + model.append (out iter); + model.set (iter, 0, +@@ -153,106 +156,143 @@ public class MathPreferencesDialog : Gtk.Dialog + renderer = new Gtk.CellRendererText (); + angle_unit_combo.pack_start (renderer, true); + angle_unit_combo.add_attribute (renderer, "text", 0); + + label = new Gtk.Label.with_mnemonic (/* Preferences dialog: Label for word size combo box */ + _("Word _size:")); + label.show (); + label.xalign = 0; + grid.attach (label, 0, 6, 1, 1); + + word_size_combo = new Gtk.ComboBox (); + label.mnemonic_widget = word_size_combo; + word_size_combo.show (); + word_size_combo.changed.connect (word_size_combo_changed_cb); + grid.attach (word_size_combo, 1, 6, 1, 1); + + model = new Gtk.ListStore (2, typeof (string), typeof (int)); + word_size_combo.model = model; + model.append (out iter); + model.set (iter, 0, /* Word size combo: 8 bits */ _("8 bits"), 1, 8); + model.append (out iter); + model.set (iter, 0, /* Word size combo: 16 bits */ _("16 bits"), 1, 16); + model.append (out iter); + model.set (iter, 0, /* Word size combo: 32 bits */ _("32 bits"), 1, 32); + model.append (out iter); + model.set (iter, 0, /* Word size combo: 64 bits */ _("64 bits"), 1, 64); + renderer = new Gtk.CellRendererText (); + word_size_combo.pack_start (renderer, true); + word_size_combo.add_attribute (renderer, "text", 0); + ++ label = new Gtk.Label.with_mnemonic (/* Preferences dialog: Label for word size combo box */ ++ _("Exchange rate refresh interval")); ++ label.show (); ++ label.xalign = 0; ++ grid.attach (label, 0, 7, 1, 1); ++ ++ refresh_interval_combo = new Gtk.ComboBox (); ++ label.mnemonic_widget = refresh_interval_combo; ++ refresh_interval_combo.show (); ++ refresh_interval_combo.changed.connect (refresh_interval_combo_changed_cb); ++ grid.attach (refresh_interval_combo, 1, 7, 1, 1); ++ ++ model = new Gtk.ListStore (2, typeof (string), typeof (int)); ++ refresh_interval_combo.model = model; ++ model.append (out iter); ++ model.set (iter, 0, /* Refresh interval combo: never */ _("never"), 1, 0); ++ model.append (out iter); ++ model.set (iter, 0, /* Refresh interval combo: daily */ _("daily"), 1, 60 * 60 * 24); ++ model.append (out iter); ++ model.set (iter, 0, /* Refresh interval combo: weekly */ _("weekly"), 1, 60 * 60 * 24 * 7); ++ renderer = new Gtk.CellRendererText (); ++ refresh_interval_combo.pack_start (renderer, true); ++ refresh_interval_combo.add_attribute (renderer, "text", 0); ++ + decimal_places_spin.set_value (equation.accuracy); + equation.notify["accuracy"].connect ((pspec) => { decimal_places_spin.set_value (equation.accuracy); }); + + thousands_separator_switch.set_active (equation.show_thousands_separators); + equation.notify["show-thousands-separators"].connect (() => { thousands_separator_switch.set_active (equation.show_thousands_separators); }); + + trailing_zeroes_switch.set_active (equation.show_trailing_zeroes); + equation.notify["show-trailing_zeroes"].connect (() => { trailing_zeroes_switch.set_active (equation.show_trailing_zeroes); }); + + set_combo_box_from_int (number_format_combo, equation.number_format); + equation.notify["number-format"].connect ((pspec) => { set_combo_box_from_int (number_format_combo, equation.number_format); }); + + set_combo_box_from_int (word_size_combo, equation.word_size); + equation.notify["word-size"].connect ((pspec) => { set_combo_box_from_int (word_size_combo, equation.word_size); }); + + set_combo_box_from_int (angle_unit_combo, equation.angle_units); + equation.notify["angle-units"].connect ((pspec) => { set_combo_box_from_int (angle_unit_combo, equation.angle_units); }); ++ ++ set_combo_box_from_int (refresh_interval_combo, settings.get_int ("refresh-interval")); + } + + protected override void response (int id) + { + hide (); + } + + protected override bool delete_event (Gdk.EventAny event) + { + hide (); + return true; + } + + private void number_format_combo_changed_cb (Gtk.ComboBox combo) + { + Gtk.TreeIter iter; + combo.get_active_iter (out iter); + DisplayFormat value; + combo.model.get (iter, 1, out value, -1); + equation.number_format = value; + } + + private void angle_unit_combo_changed_cb (Gtk.ComboBox combo) + { + Gtk.TreeIter iter; + combo.get_active_iter (out iter); + AngleUnit value; + combo.model.get (iter, 1, out value, -1); + equation.angle_units = value; + } + + private void word_size_combo_changed_cb (Gtk.ComboBox combo) + { + Gtk.TreeIter iter; + combo.get_active_iter (out iter); + int value; + combo.model.get (iter, 1, out value, -1); + equation.word_size = value; + } + ++ private void refresh_interval_combo_changed_cb (Gtk.ComboBox combo) ++ { ++ Gtk.TreeIter iter; ++ combo.get_active_iter (out iter); ++ int value; ++ combo.model.get (iter, 1, out value, -1); ++ settings.set_int ("refresh-interval", value); ++ CurrencyManager.get_default ().refresh_interval = value; ++ ++ } ++ + private void set_combo_box_from_int (Gtk.ComboBox combo, int value) + { + Gtk.TreeIter iter; + var valid = combo.model.get_iter_first (out iter); + while (valid) + { + int v; + + combo.model.get (iter, 1, out v, -1); + if (v == value) + break; + valid = combo.model.iter_next (ref iter); + } + if (!valid) + valid = combo.model.get_iter_first (out iter); + + combo.set_active_iter (iter); + } + } +-- +2.31.1 + diff --git a/SOURCES/0002-currency-provider-Don-t-ever-download-rates-if-refre.patch b/SOURCES/0002-currency-provider-Don-t-ever-download-rates-if-refre.patch new file mode 100644 index 0000000..a350f1c --- /dev/null +++ b/SOURCES/0002-currency-provider-Don-t-ever-download-rates-if-refre.patch @@ -0,0 +1,180 @@ +From bddcd343ec6a4aad86a7add9cd5abf77338ffb76 Mon Sep 17 00:00:00 2001 +From: Ray Strode +Date: Thu, 13 May 2021 10:44:33 -0400 +Subject: [PATCH 2/5] currency-provider: Don't ever download rates if refresh + interval is 0 + +If an admin has set the currency refresh interval to 0 they probably +don't ever want the data refreshed from the network. + +This commit treats a refresh interval of 0 specially to mean +"don't go on the network at all" +--- + data/org.gnome.calculator.gschema.xml | 2 +- + lib/currency.vala | 6 ++++++ + 2 files changed, 7 insertions(+), 1 deletion(-) + +diff --git a/data/org.gnome.calculator.gschema.xml b/data/org.gnome.calculator.gschema.xml +index a3af435f..fbde9b53 100644 +--- a/data/org.gnome.calculator.gschema.xml ++++ b/data/org.gnome.calculator.gschema.xml +@@ -33,61 +33,61 @@ + + + 10 + + Numeric Base + The numeric base + + + false + Show Thousands Separators + Indicates whether thousands separators are shown in large numbers. + + + false + Show Trailing Zeroes + Indicates whether any trailing zeroes after the numeric point should be shown in the display value. + + + 'automatic' + Number format + The format to display numbers in + + + 'degrees' + Angle units + The angle units to use + + + 604800 + Currency update interval +- How often the currency exchange rates should be updated ++ How often the currency exchange rates should be updated. A value of 0 means the currency exchange rates won't be fetched from the network at all. + + + 'basic' + Button mode + The button mode + + + '' + Source currency + Currency of the current calculation + + + '' + Target currency + Currency to convert the current calculation into + + + 'degree' + Source units + Units of the current calculation + + + 'radian' + Target units + Units to convert the current calculation into + + + 2000 + Internal precision + The internal precision used with the MPFR library +diff --git a/lib/currency.vala b/lib/currency.vala +index c098cc52..2adb11e4 100644 +--- a/lib/currency.vala ++++ b/lib/currency.vala +@@ -354,83 +354,89 @@ public class CurrencyManager : Object + { + warning ("Couldn't create XPath context"); + return; + } + + xpath_ctx.register_ns ("xref", "http://www.ecb.int/vocabulary/2002-08-01/eurofxref"); + var xpath_obj = xpath_ctx.eval_expression ("//xref:Cube[@currency][@rate]"); + if (xpath_obj == null) + { + warning ("Couldn't create XPath object"); + return; + } + var len = (xpath_obj->nodesetval != null) ? xpath_obj->nodesetval->length () : 0; + for (var i = 0; i < len; i++) + { + var node = xpath_obj->nodesetval->item (i); + + if (node->type == Xml.ElementType.ELEMENT_NODE) + set_ecb_rate (node, eur_rate); + + /* Avoid accessing removed elements */ + if (node->type != Xml.ElementType.NAMESPACE_DECL) + node = null; + } + + Xml.Parser.cleanup (); + } + + private void download_rates () + { ++ if (refresh_interval == 0) ++ return; ++ + /* Update rates if necessary */ + var path = get_imf_rate_filepath (); + if (!downloading_imf_rates && file_needs_update (path, refresh_interval)) + { + downloading_imf_rates = true; + debug ("Downloading rates from the IMF..."); + download_file.begin ("https://www.imf.org/external/np/fin/data/rms_five.aspx?tsvflag=Y", path, "IMF"); + } + path = get_ecb_rate_filepath (); + if (!downloading_ecb_rates && file_needs_update (path, refresh_interval)) + { + downloading_ecb_rates = true; + debug ("Downloading rates from the ECB..."); + download_file.begin ("https://www.ecb.europa.eu/stats/eurofxref/eurofxref-daily.xml", path, "ECB"); + } + } + + private bool load_rates () + { + /* Already loaded */ + if (loaded_rates) + return true; + ++ if (refresh_interval == 0) ++ return false; ++ + /* In process */ + if (downloading_imf_rates || downloading_ecb_rates) + return false; + + /* Use the IMF provided values and top up with currencies tracked by the ECB and not the IMF */ + load_imf_rates (); + load_ecb_rates (); + + /* Check if we couldn't find out a currency */ + foreach (var c in currencies) + if (c.get_value () == null || c.get_value ().is_zero ()) + warning ("Currency %s is not provided by IMF or ECB", c.name); + + debug ("Rates loaded"); + loaded_rates = true; + + updated (); + + return true; + } + + public Number? get_value (string currency) + { + /* Make sure that the rates we're returning are up to date. (Just in case the application is running from a long long time) */ + download_rates (); + + if (!load_rates ()) + return null; + + var c = get_currency (currency); +-- +2.31.1 + diff --git a/SOURCES/0003-gnome-calculator-Update-refresh-interval-when-change.patch b/SOURCES/0003-gnome-calculator-Update-refresh-interval-when-change.patch new file mode 100644 index 0000000..6a4a9e5 --- /dev/null +++ b/SOURCES/0003-gnome-calculator-Update-refresh-interval-when-change.patch @@ -0,0 +1,85 @@ +From 21b2235fc53e72eea0aab035de5b19a74fd165c3 Mon Sep 17 00:00:00 2001 +From: Ray Strode +Date: Thu, 13 May 2021 14:08:27 -0400 +Subject: [PATCH 3/5] gnome-calculator: Update refresh interval when changed in + gsettings + +Right now the refresh interval is read at start up. + +This commit makes sure it gets reread any time it's changed too. +--- + src/gnome-calculator.vala | 4 ++++ + 1 file changed, 4 insertions(+) + +diff --git a/src/gnome-calculator.vala b/src/gnome-calculator.vala +index 5b3f9b8d..89a83450 100644 +--- a/src/gnome-calculator.vala ++++ b/src/gnome-calculator.vala +@@ -101,60 +101,64 @@ public class Calculator : Gtk.Application + catch (Error e) + { + error ("Error loading menu UI: %s", e.message); + } + + var menu = builder.get_object ("appmenu") as MenuModel; + set_app_menu (menu); + + set_accels_for_action ("win.mode::basic", {"B"}); + set_accels_for_action ("win.mode::advanced", {"A"}); + set_accels_for_action ("win.mode::financial", {"F"}); + set_accels_for_action ("win.mode::programming", {"P"}); + set_accels_for_action ("win.mode::keyboard", {"K"}); + set_accels_for_action ("win.copy", {"C"}); + set_accels_for_action ("win.paste", {"V"}); + set_accels_for_action ("win.undo", {"Z"}); + set_accels_for_action ("win.close", {"W"}); + set_accels_for_action ("win.redo", {"Z"}); + return current_window; + } + + protected override void startup () + { + base.startup (); + + settings = new Settings ("org.gnome.calculator"); + last_opened_window = create_new_window (settings); + // restore the first window position from the settings + load_window_position (last_opened_window); + CurrencyManager.get_default ().refresh_interval = settings.get_int ("refresh-interval"); ++ ++ settings.changed["refresh-interval"].connect(() => { ++ CurrencyManager.get_default ().refresh_interval = settings.get_int ("refresh-interval"); ++ }); + } + + private MathWindow get_active_math_window () + { + return (MathWindow) get_active_window (); + } + + protected override void activate () + { + base.activate (); + + last_opened_window.present (); + if (equation_string != "" && equation_string != null) + { + var equations = (equation_string.compress ()).split ("\n",0); + for (var i = 0; i < equations.length; i++) + { + if ((equations [i].strip ()).length > 0) + last_opened_window.equation.set (equations [i]); + else + last_opened_window.equation.solve (); + } + } + if (mode_string != "" && mode_string != null) + { + var mode = ButtonMode.BASIC; + + switch (mode_string) + { + case "basic": +-- +2.31.1 + diff --git a/SOURCES/0004-Conversion-ui-improvements-72.patch b/SOURCES/0004-Conversion-ui-improvements-72.patch new file mode 100644 index 0000000..8452d6b --- /dev/null +++ b/SOURCES/0004-Conversion-ui-improvements-72.patch @@ -0,0 +1,425 @@ +From 3edf6664432fd65ad68b7e5b91de65eef7fcdb09 Mon Sep 17 00:00:00 2001 +From: Robert Roth +Date: Thu, 4 Oct 2018 23:41:03 +0300 +Subject: [PATCH 4/5] Conversion ui improvements (#72) + +--- + src/math-converter.ui | 9 +++++++-- + src/math-converter.vala | 45 +++++++++++++++++++++++++++-------------- + src/math-display.vala | 12 ++++------- + 3 files changed, 41 insertions(+), 25 deletions(-) + +diff --git a/src/math-converter.ui b/src/math-converter.ui +index 8172ede3..9ec03820 100644 +--- a/src/math-converter.ui ++++ b/src/math-converter.ui +@@ -1,59 +1,63 @@ + + + + + + ++ +diff --git a/src/math-converter.vala b/src/math-converter.vala +index 0cf90ac5..a83dea24 100644 +--- a/src/math-converter.vala ++++ b/src/math-converter.vala +@@ -75,66 +75,64 @@ public class MathConverter : Gtk.Grid + { + Gtk.TreeIter child_iter; + while (model.iter_children (out child_iter, iter)) + iter = child_iter; + from_combo.set_active_iter (iter); + } + return; + } + + set_active_unit (from_combo, null, ua); + set_active_unit (to_combo, null, ub); + } + + public void get_conversion (out Unit from_unit, out Unit to_unit) + { + Gtk.TreeIter from_iter, to_iter; + + from_combo.get_active_iter (out from_iter); + to_combo.get_active_iter (out to_iter); + + from_combo.get_model ().get (from_iter, 2, out from_unit, -1); + to_combo.get_model ().get (to_iter, 2, out to_unit, -1); + } + + private void update_result_label () + { + var x = equation.number; + if (x == null) + return; + +- var z = convert_equation (x); ++ Unit source_unit, target_unit; ++ var z = convert_equation (x, out source_unit, out target_unit); + if (z != null) + { +- Unit source_unit, target_unit; +- get_conversion (out source_unit, out target_unit); +- + var source_text = source_unit.format (x); + var target_text = target_unit.format (z); + from_label.set_text (source_text); + to_label.set_text (target_text); + } + } + + private void update_from_model () + { + var from_model = new Gtk.TreeStore (3, typeof (string), typeof (UnitCategory), typeof (Unit)); + + if (category == null) + { + var categories = UnitManager.get_default ().get_categories (); + foreach (var category in categories) + { + Gtk.TreeIter parent; + from_model.append (out parent, null); + from_model.set (parent, 0, category.display_name, 1, category, -1); + + foreach (var unit in category.get_units ()) + { + Gtk.TreeIter iter; + from_model.append (out iter, parent); + from_model.set (iter, 0, unit.display_name, 1, category, 2, unit, -1); + } + } + } + else + { +@@ -201,62 +199,79 @@ public class MathConverter : Gtk.Grid + /* Set the to combobox to be the list of units can be converted to */ + to_model = new Gtk.ListStore (3, typeof (string), typeof (UnitCategory), typeof (Unit)); + foreach (var u in category.get_units ()) + { + to_model.append (out iter); + to_model.set (iter, 0, u.display_name, 1, category, 2, u, -1); + } + to_combo.model = to_model; + + /* Select the first possible unit */ + to_combo.set_active (0); + } + } + + [GtkCallback] + private void to_combobox_changed_cb () + { + /* Conversion must have changed */ + update_result_label (); + changed (); + } + + private void from_cell_data_func (Gtk.CellLayout cell_layout, Gtk.CellRenderer cell, Gtk.TreeModel tree_model, Gtk.TreeIter iter) + { + cell.set ("sensitive", !tree_model.iter_has_child (iter)); + } + + [GtkCallback] + private void swap_button_clicked_cb () + { ++ Unit? from_unit, to_unit; ++ get_conversion (out from_unit, out to_unit); ++ ++ set_active_unit (from_combo, null, to_unit); ++ set_active_unit (to_combo, null, from_unit); ++ ++ do_convert(out from_unit, out to_unit); ++ ++ update_result_label (); ++ } ++ ++ private void do_convert (out Unit? from_unit, out Unit? to_unit) { + var x = equation.number; + if (x != null) + { +- var z = convert_equation (x); +- if (z != null) +- equation.set_number (z); ++ var z = convert_equation (x, out from_unit, out to_unit); ++ if (z != null && from_unit != null && to_unit != null) ++ { ++ equation.set ("%s %s %s %s".printf(equation.serializer.to_string (x), from_unit.display_name, _("in"), to_unit.display_name)); ++ equation.solve (); ++ } + } ++ } + +- Unit from_unit, to_unit; +- get_conversion (out from_unit, out to_unit); +- set_active_unit (from_combo, null, to_unit); +- set_active_unit (to_combo, null, from_unit); ++ [GtkCallback] ++ private void convert_button_clicked_cb () ++ { ++ Unit? from_unit, to_unit; ++ do_convert (out from_unit, out to_unit); + + update_result_label (); + } + +- private Number? convert_equation (Number x) ++ private Number? convert_equation (Number x, ++ out Unit? source_unit, ++ out Unit? target_unit) + { + Gtk.TreeIter from_iter, to_iter; + if (!from_combo.get_active_iter (out from_iter)) + return null; + if (!to_combo.get_active_iter (out to_iter)) + return null; +- + UnitCategory category; +- Unit source_unit, target_unit; + from_combo.model.get (from_iter, 1, out category, 2, out source_unit, -1); + to_combo.model.get (to_iter, 2, out target_unit, -1); + + return category.convert (x, source_unit, target_unit); +- } ++ } + } +diff --git a/src/math-display.vala b/src/math-display.vala +index 4b1a17c8..01156b0c 100644 +--- a/src/math-display.vala ++++ b/src/math-display.vala +@@ -1,60 +1,60 @@ + /* + * Copyright (C) 2008-2012 Robert Ancell + * + * This program is free software: you can redistribute it and/or modify it under + * the terms of the GNU General Public License as published by the Free Software + * Foundation, either version 3 of the License, or (at your option) any later + * version. See http://www.gnu.org/copyleft/gpl.html the full text of the + * license. + */ + + public class MathDisplay : Gtk.Viewport + { + /* Equation being displayed */ + private MathEquation _equation; + public MathEquation equation { get { return _equation; } } + private HistoryView history; + + /* Display widget */ + Gtk.SourceView source_view; + + /* Buffer that shows errors etc */ + Gtk.TextBuffer info_buffer; + + /* Spinner widget that shows if we're calculating a response */ + Gtk.Spinner spinner; + + public MathDisplay (MathEquation equation) + { + _equation = equation; +- _equation.history_signal.connect (this.handler); ++ _equation.history_signal.connect (this.update_history); + var main_box = new Gtk.Box (Gtk.Orientation.VERTICAL, 0); + add (main_box); + + history = new HistoryView (); + history.answer_clicked.connect ((ans) => { insert_text (ans); }); + history.equation_clicked.connect ((eq) => { display_text (eq); }); + main_box.add (history); + main_box.show_all (); + + var scrolled_window = new Gtk.ScrolledWindow (null, null); + var style_context = scrolled_window.get_style_context (); + style_context.add_class ("display-scrolled"); + + scrolled_window.set_policy (Gtk.PolicyType.AUTOMATIC, Gtk.PolicyType.NEVER); + source_view = new Gtk.SourceView.with_buffer (equation); + source_view.set_accepts_tab (false); + source_view.set_left_margin (14); + source_view.set_pixels_above_lines (8); + source_view.set_pixels_below_lines (2); + source_view.set_justification (Gtk.Justification.LEFT); + + source_view.set_name ("displayitem"); + source_view.set_size_request (20, 20); + source_view.get_accessible ().set_role (Atk.Role.EDITBAR); + //FIXME:Result Region + source_view.key_press_event.connect (key_press_cb); + create_autocompletion (); + + main_box.pack_start (scrolled_window, false, false, 0); + scrolled_window.add (source_view); /* Adds ScrolledWindow to source_view for displaying long equations */ +@@ -67,75 +67,71 @@ public class MathDisplay : Gtk.Viewport + info_view.set_wrap_mode (Gtk.WrapMode.WORD); + info_view.set_can_focus (false); + info_view.set_editable (false); + info_view.set_left_margin (12); + info_view.set_right_margin (12); + info_box.pack_start (info_view, true, true, 0); + info_buffer = info_view.get_buffer (); + + style_context = info_view.get_style_context (); + style_context.add_class ("info-view"); + + spinner = new Gtk.Spinner (); + info_box.pack_end (spinner, false, false, 0); + + info_box.show (); + info_view.show (); + source_view.show (); + main_box.show (); + + equation.notify["status"].connect ((pspec) => { status_changed_cb (); }); + status_changed_cb (); + + equation.notify["error-token-end"].connect ((pspec) => { error_status_changed_cb (); }); + } + + public void grabfocus () /* Editbar grabs focus when an instance of gnome-calculator is created */ + { + source_view.grab_focus (); + } + +- public void handler (string answer, Number number, int number_base, uint representation_base) ++ public void update_history (string answer, Number number, int number_base, uint representation_base) + { +- this.update_history (answer, number, number_base, representation_base); /* Recieves signal emitted by a MathEquation object for updating history-view */ ++ /* Recieves signal emitted by a MathEquation object for updating history-view */ ++ history.insert_entry (answer, number, number_base, representation_base); /* Sends current equation and answer for updating History-View */ + } + + public void display_text (string prev_eq) + { + _equation.display_selected (prev_eq); + } + +- public void update_history (string answer, Number number, int number_base, uint representation_base) +- { +- history.insert_entry (answer, number, number_base, representation_base); /* Sends current equation and answer for updating History-View */ +- } +- + public void clear_history () + { + history.clear (); + } + + public void insert_text (string answer) + { + _equation.insert_selected (answer); + } + + private void create_autocompletion () + { + Gtk.SourceCompletion completion = source_view.get_completion (); + try + { + completion.add_provider (new FunctionCompletionProvider ()); + completion.add_provider (new VariableCompletionProvider (equation)); + } + catch (Error e) + { + warning ("Could not add CompletionProvider to source-view"); + } + } + + private bool function_completion_window_visible () + { + unowned List providers_list = source_view.get_completion ().get_providers (); + if (providers_list.length () > 0) + { + MathFunction[] functions = FunctionCompletionProvider.get_matches_for_completion_at_cursor (equation); +-- +2.31.1 + diff --git a/SOURCES/0005-math-converter-Hide-currency-conversion-UI-if-there-.patch b/SOURCES/0005-math-converter-Hide-currency-conversion-UI-if-there-.patch new file mode 100644 index 0000000..05c46f4 --- /dev/null +++ b/SOURCES/0005-math-converter-Hide-currency-conversion-UI-if-there-.patch @@ -0,0 +1,697 @@ +From 213feffa73f09303914f0032ba9976ecb17629cd Mon Sep 17 00:00:00 2001 +From: Ray Strode +Date: Thu, 13 May 2021 11:29:33 -0400 +Subject: [PATCH 5/5] math-converter: Hide currency conversion UI if there + isn't a loaded currency provider + +If the admin sets a currency refresh-interval of 0, then the currency +conversion data will be missing or woefully out of date. + +This commit changes the code to hide the conversion UI in this case. +--- + lib/currency.vala | 15 ++- + src/gnome-calculator.vala | 1 + + src/math-converter.ui | 264 ++++++++++++++++++++++++-------------- + src/math-converter.vala | 18 ++- + 4 files changed, 197 insertions(+), 101 deletions(-) + +diff --git a/lib/currency.vala b/lib/currency.vala +index 2adb11e4..4270b701 100644 +--- a/lib/currency.vala ++++ b/lib/currency.vala +@@ -1,53 +1,62 @@ + /* + * Copyright (C) 2008-2012 Robert Ancell. + * + * This program is free software: you can redistribute it and/or modify it under + * the terms of the GNU General Public License as published by the Free Software + * Foundation, either version 3 of the License, or (at your option) any later + * version. See http://www.gnu.org/copyleft/gpl.html the full text of the + * license. + */ + + static bool downloading_imf_rates = false; + static bool downloading_ecb_rates = false; +-static bool loaded_rates = false; + private static CurrencyManager? default_currency_manager = null; + + public class CurrencyManager : Object + { + private List currencies; + + public int refresh_interval { get; set; } + + public signal void updated (); + ++ public bool loaded { get; private set; } ++ ++ public void refresh_sync () { ++ loaded = false; ++ load_rates (); ++ ++ if (!loaded) ++ updated (); ++ } ++ + public static CurrencyManager get_default () + { + if (default_currency_manager != null) + return default_currency_manager; + + default_currency_manager = new CurrencyManager (); + + default_currency_manager.currencies.append (new Currency ("AED", _("UAE Dirham"), "إ.د")); + default_currency_manager.currencies.append (new Currency ("AUD", _("Australian Dollar"), "$")); + default_currency_manager.currencies.append (new Currency ("BGN", _("Bulgarian Lev"), "лв")); + default_currency_manager.currencies.append (new Currency ("BHD", _("Bahraini Dinar"), ".ب.د")); + default_currency_manager.currencies.append (new Currency ("BND", _("Brunei Dollar"), "$")); + default_currency_manager.currencies.append (new Currency ("BRL", _("Brazilian Real"), "R$")); + default_currency_manager.currencies.append (new Currency ("BWP", _("Botswana Pula"), "P")); + default_currency_manager.currencies.append (new Currency ("CAD", _("Canadian Dollar"), "$")); + default_currency_manager.currencies.append (new Currency ("CFA", _("CFA Franc"), "Fr")); + default_currency_manager.currencies.append (new Currency ("CHF", _("Swiss Franc"), "Fr")); + default_currency_manager.currencies.append (new Currency ("CLP", _("Chilean Peso"), "$")); + default_currency_manager.currencies.append (new Currency ("CNY", _("Chinese Yuan"), "¥")); + default_currency_manager.currencies.append (new Currency ("COP", _("Colombian Peso"), "$")); + default_currency_manager.currencies.append (new Currency ("CZK", _("Czech Koruna"), "Kč")); + default_currency_manager.currencies.append (new Currency ("DKK", _("Danish Krone"), "kr")); + default_currency_manager.currencies.append (new Currency ("DZD", _("Algerian Dinar"), "ج.د")); + default_currency_manager.currencies.append (new Currency ("EEK", _("Estonian Kroon"), "KR")); + default_currency_manager.currencies.append (new Currency ("EUR", _("Euro"), "€")); + default_currency_manager.currencies.append (new Currency ("GBP", _("British Pound Sterling"), "£")); + default_currency_manager.currencies.append (new Currency ("HKD", _("Hong Kong Dollar"), "$")); + default_currency_manager.currencies.append (new Currency ("HRK", _("Croatian Kuna"), "kn")); + default_currency_manager.currencies.append (new Currency ("HUF", _("Hungarian Forint"), "Ft")); + default_currency_manager.currencies.append (new Currency ("IDR", _("Indonesian Rupiah"), "Rp")); +@@ -377,81 +386,81 @@ public class CurrencyManager : Object + } + + Xml.Parser.cleanup (); + } + + private void download_rates () + { + if (refresh_interval == 0) + return; + + /* Update rates if necessary */ + var path = get_imf_rate_filepath (); + if (!downloading_imf_rates && file_needs_update (path, refresh_interval)) + { + downloading_imf_rates = true; + debug ("Downloading rates from the IMF..."); + download_file.begin ("https://www.imf.org/external/np/fin/data/rms_five.aspx?tsvflag=Y", path, "IMF"); + } + path = get_ecb_rate_filepath (); + if (!downloading_ecb_rates && file_needs_update (path, refresh_interval)) + { + downloading_ecb_rates = true; + debug ("Downloading rates from the ECB..."); + download_file.begin ("https://www.ecb.europa.eu/stats/eurofxref/eurofxref-daily.xml", path, "ECB"); + } + } + + private bool load_rates () + { + /* Already loaded */ +- if (loaded_rates) ++ if (loaded) + return true; + + if (refresh_interval == 0) + return false; + + /* In process */ + if (downloading_imf_rates || downloading_ecb_rates) + return false; + + /* Use the IMF provided values and top up with currencies tracked by the ECB and not the IMF */ + load_imf_rates (); + load_ecb_rates (); + + /* Check if we couldn't find out a currency */ + foreach (var c in currencies) + if (c.get_value () == null || c.get_value ().is_zero ()) + warning ("Currency %s is not provided by IMF or ECB", c.name); + + debug ("Rates loaded"); +- loaded_rates = true; ++ loaded = true; + + updated (); + + return true; + } + + public Number? get_value (string currency) + { + /* Make sure that the rates we're returning are up to date. (Just in case the application is running from a long long time) */ + download_rates (); + + if (!load_rates ()) + return null; + + var c = get_currency (currency); + if (c != null) + return c.get_value (); + else + return null; + } + + private async void download_file (string uri, string filename, string source) + { + + var directory = Path.get_dirname (filename); + DirUtils.create_with_parents (directory, 0755); + + var dest = File.new_for_path (filename); + var session = new Soup.Session (); + var message = new Soup.Message ("GET", uri); +diff --git a/src/gnome-calculator.vala b/src/gnome-calculator.vala +index 89a83450..0aa0054e 100644 +--- a/src/gnome-calculator.vala ++++ b/src/gnome-calculator.vala +@@ -104,60 +104,61 @@ public class Calculator : Gtk.Application + } + + var menu = builder.get_object ("appmenu") as MenuModel; + set_app_menu (menu); + + set_accels_for_action ("win.mode::basic", {"B"}); + set_accels_for_action ("win.mode::advanced", {"A"}); + set_accels_for_action ("win.mode::financial", {"F"}); + set_accels_for_action ("win.mode::programming", {"P"}); + set_accels_for_action ("win.mode::keyboard", {"K"}); + set_accels_for_action ("win.copy", {"C"}); + set_accels_for_action ("win.paste", {"V"}); + set_accels_for_action ("win.undo", {"Z"}); + set_accels_for_action ("win.close", {"W"}); + set_accels_for_action ("win.redo", {"Z"}); + return current_window; + } + + protected override void startup () + { + base.startup (); + + settings = new Settings ("org.gnome.calculator"); + last_opened_window = create_new_window (settings); + // restore the first window position from the settings + load_window_position (last_opened_window); + CurrencyManager.get_default ().refresh_interval = settings.get_int ("refresh-interval"); + + settings.changed["refresh-interval"].connect(() => { + CurrencyManager.get_default ().refresh_interval = settings.get_int ("refresh-interval"); ++ CurrencyManager.get_default ().refresh_sync (); + }); + } + + private MathWindow get_active_math_window () + { + return (MathWindow) get_active_window (); + } + + protected override void activate () + { + base.activate (); + + last_opened_window.present (); + if (equation_string != "" && equation_string != null) + { + var equations = (equation_string.compress ()).split ("\n",0); + for (var i = 0; i < equations.length; i++) + { + if ((equations [i].strip ()).length > 0) + last_opened_window.equation.set (equations [i]); + else + last_opened_window.equation.solve (); + } + } + if (mode_string != "" && mode_string != null) + { + var mode = ButtonMode.BASIC; + + switch (mode_string) + { +diff --git a/src/math-converter.ui b/src/math-converter.ui +index 9ec03820..fb633f10 100644 +--- a/src/math-converter.ui ++++ b/src/math-converter.ui +@@ -1,137 +1,207 @@ + + + + + + + +diff --git a/src/math-converter.vala b/src/math-converter.vala +index a83dea24..c470b91f 100644 +--- a/src/math-converter.vala ++++ b/src/math-converter.vala +@@ -1,128 +1,144 @@ + /* + * Copyright (C) 2008-2012 Robert Ancell + * + * This program is free software: you can redistribute it and/or modify it under + * the terms of the GNU General Public License as published by the Free Software + * Foundation, either version 3 of the License, or (at your option) any later + * version. See http://www.gnu.org/copyleft/gpl.html the full text of the + * license. + */ + + [GtkTemplate (ui = "/org/gnome/calculator/math-converter.ui")] + public class MathConverter : Gtk.Grid + { + private MathEquation equation = null; + + private string category; + + [GtkChild] + private Gtk.CellRendererText from_renderer; + + [GtkChild] + private Gtk.ComboBox from_combo; + [GtkChild] + private Gtk.ComboBox to_combo; + [GtkChild] + private Gtk.Label from_label; + [GtkChild] + private Gtk.Label to_label; ++ public bool outer_box_visible { set; get; default = false; } + + public signal void changed (); + + construct + { + from_combo.set_cell_data_func (from_renderer, from_cell_data_func); +- CurrencyManager.get_default ().updated.connect (() => { update_result_label (); }); ++ CurrencyManager.get_default ().updated.connect (() => { ++ update_visibility (); ++ update_result_label (); ++ }); + ++ update_visibility (); + update_from_model (); + } + + public MathConverter (MathEquation equation) + { + set_equation (equation); + } + + public void set_equation (MathEquation equation) + { + this.equation = equation; + equation.notify["display"].connect ((pspec) => { update_result_label (); }); + } + + public void set_category (string? category) + { + if (this.category == category) + return; + this.category = category; + ++ update_visibility (); + update_from_model (); + } + + public string get_category () + { + return category; + } + + public void set_conversion (/*string category,*/ string unit_a, string unit_b) + { + var ua = UnitManager.get_default ().get_unit_by_name (unit_a); + var ub = UnitManager.get_default ().get_unit_by_name (unit_b); + if (ua == null || ub == null) + { + /* Select the first unit */ + var model = from_combo.get_model (); + Gtk.TreeIter iter; + if (model.get_iter_first (out iter)) + { + Gtk.TreeIter child_iter; + while (model.iter_children (out child_iter, iter)) + iter = child_iter; + from_combo.set_active_iter (iter); + } + return; + } + + set_active_unit (from_combo, null, ua); + set_active_unit (to_combo, null, ub); + } + + public void get_conversion (out Unit from_unit, out Unit to_unit) + { + Gtk.TreeIter from_iter, to_iter; + + from_combo.get_active_iter (out from_iter); + to_combo.get_active_iter (out to_iter); + + from_combo.get_model ().get (from_iter, 2, out from_unit, -1); + to_combo.get_model ().get (to_iter, 2, out to_unit, -1); + } + ++ private void update_visibility () ++ { ++ if (category != "currency") { ++ this.outer_box_visible = true; ++ return; ++ } ++ ++ this.outer_box_visible = CurrencyManager.get_default ().loaded; ++ } ++ + private void update_result_label () + { + var x = equation.number; + if (x == null) + return; + + Unit source_unit, target_unit; + var z = convert_equation (x, out source_unit, out target_unit); + if (z != null) + { + var source_text = source_unit.format (x); + var target_text = target_unit.format (z); + from_label.set_text (source_text); + to_label.set_text (target_text); + } + } + + private void update_from_model () + { + var from_model = new Gtk.TreeStore (3, typeof (string), typeof (UnitCategory), typeof (Unit)); + + if (category == null) + { + var categories = UnitManager.get_default ().get_categories (); + foreach (var category in categories) + { + Gtk.TreeIter parent; + from_model.append (out parent, null); + from_model.set (parent, 0, category.display_name, 1, category, -1); + +-- +2.31.1 + diff --git a/SPECS/gnome-calculator.spec b/SPECS/gnome-calculator.spec index 841e102..2ab1e50 100644 --- a/SPECS/gnome-calculator.spec +++ b/SPECS/gnome-calculator.spec @@ -1,6 +1,6 @@ Name: gnome-calculator Version: 3.28.2 -Release: 1%{?dist} +Release: 2%{?dist} Summary: A desktop calculator License: GPLv3+ @@ -24,6 +24,11 @@ BuildRequires: /usr/bin/appstream-util Provides: gcalctool = 6.6.2-3 Obsoletes: gcalctool < 6.6.2-3 +Patch10001: 0001-Implemented-exchange-rate-refresh-interval-setting.patch +Patch10002: 0002-currency-provider-Don-t-ever-download-rates-if-refre.patch +Patch10003: 0003-gnome-calculator-Update-refresh-interval-when-change.patch +Patch10004: 0004-Conversion-ui-improvements-72.patch +Patch10005: 0005-math-converter-Hide-currency-conversion-UI-if-there-.patch %description gnome-calculator is a powerful graphical calculator with financial, @@ -68,6 +73,10 @@ desktop-file-validate %{buildroot}/%{_datadir}/applications/org.gnome.Calculator %changelog +* Thu Jul 15 2021 Ray Strode - 3.28.2-2 +- Allow disabling downloading by setting refresh interval to 0 + Resolves: #1957705 + * Tue Jun 26 2018 Kalev Lember - 3.28.2-1 - Update to 3.28.2