diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..4c076f9 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/gnome-calculator-3.28.2.tar.xz diff --git a/0001-Implemented-exchange-rate-refresh-interval-setting.patch b/0001-Implemented-exchange-rate-refresh-interval-setting.patch new file mode 100644 index 0000000..7e456ca --- /dev/null +++ b/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/0002-currency-provider-Don-t-ever-download-rates-if-refre.patch b/0002-currency-provider-Don-t-ever-download-rates-if-refre.patch new file mode 100644 index 0000000..a350f1c --- /dev/null +++ b/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/0003-gnome-calculator-Update-refresh-interval-when-change.patch b/0003-gnome-calculator-Update-refresh-interval-when-change.patch new file mode 100644 index 0000000..6a4a9e5 --- /dev/null +++ b/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/0004-Conversion-ui-improvements-72.patch b/0004-Conversion-ui-improvements-72.patch new file mode 100644 index 0000000..8452d6b --- /dev/null +++ b/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/0005-math-converter-Hide-currency-conversion-UI-if-there-.patch b/0005-math-converter-Hide-currency-conversion-UI-if-there-.patch new file mode 100644 index 0000000..05c46f4 --- /dev/null +++ b/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/EMPTY b/EMPTY deleted file mode 100644 index 0519ecb..0000000 --- a/EMPTY +++ /dev/null @@ -1 +0,0 @@ - \ No newline at end of file diff --git a/gnome-calculator.spec b/gnome-calculator.spec new file mode 100644 index 0000000..2ab1e50 --- /dev/null +++ b/gnome-calculator.spec @@ -0,0 +1,335 @@ +Name: gnome-calculator +Version: 3.28.2 +Release: 2%{?dist} +Summary: A desktop calculator + +License: GPLv3+ +URL: https://wiki.gnome.org/Apps/Calculator +Source0: https://download.gnome.org/sources/%{name}/3.28/%{name}-%{version}.tar.xz + +BuildRequires: desktop-file-utils +BuildRequires: gettext +BuildRequires: itstool +BuildRequires: libmpc-devel +BuildRequires: libsoup-devel +BuildRequires: meson +BuildRequires: mpfr-devel +BuildRequires: pkgconfig(glib-2.0) +BuildRequires: pkgconfig(gtk+-3.0) +BuildRequires: pkgconfig(gtksourceview-3.0) +BuildRequires: pkgconfig(libxml-2.0) +BuildRequires: vala +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, +logical and scientific modes. It uses a multiple precision package +to do its arithmetic to give a high degree of accuracy. + + +%prep +%autosetup -p1 + + +%build +%meson +%meson_build + + +%install +%meson_install +%find_lang %{name} --with-gnome --all-name + + +%check +appstream-util validate-relax --nonet %{buildroot}/%{_datadir}/metainfo/org.gnome.Calculator.appdata.xml +desktop-file-validate %{buildroot}/%{_datadir}/applications/org.gnome.Calculator.desktop + + +%files -f %{name}.lang +%doc NEWS +%license COPYING +%{_bindir}/gcalccmd +%{_bindir}/gnome-calculator +%{_libexecdir}/gnome-calculator-search-provider +%{_datadir}/applications/org.gnome.Calculator.desktop +%{_datadir}/dbus-1/services/org.gnome.Calculator.SearchProvider.service +%{_datadir}/glib-2.0/schemas/org.gnome.calculator.gschema.xml +%{_datadir}/gnome-shell/ +%{_datadir}/icons/hicolor/*/apps/gnome-calculator.png +%{_datadir}/icons/hicolor/scalable/apps/gnome-calculator-symbolic.svg +%{_datadir}/metainfo/org.gnome.Calculator.appdata.xml +%{_mandir}/man1/gnome-calculator.1* +%{_mandir}/man1/gcalccmd.1* + + +%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 + +* Mon Apr 09 2018 Kalev Lember - 3.28.1-1 +- Update to 3.28.1 +- Switch to the meson build system + +* Mon Mar 12 2018 Kalev Lember - 3.28.0-1 +- Update to 3.28.0 + +* Mon Mar 05 2018 Kalev Lember - 3.27.92-1 +- Update to 3.27.92 + +* Wed Feb 07 2018 Fedora Release Engineering - 3.26.0-4 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_28_Mass_Rebuild + +* Mon Jan 22 2018 Bastien Nocera - 3.26.0-3 ++ gnome-calculator-3.26.0-3 +- Fix reusing result in fr locales (#1536368) + +* Sat Jan 06 2018 Igor Gnatenko - 3.26.0-2 +- Remove obsolete scriptlets + +* Thu Nov 02 2017 Kalev Lember - 3.26.0-1 +- Update to 3.26.0 + +* Thu Sep 07 2017 Kalev Lember - 3.25.92-1 +- Update to 3.25.92 + +* Fri Aug 25 2017 Kalev Lember - 3.25.91-1 +- Update to 3.25.91 + +* Tue Aug 15 2017 Kalev Lember - 3.25.90-1 +- Update to 3.25.90 + +* Wed Aug 02 2017 Fedora Release Engineering - 3.25.2-3 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Binutils_Mass_Rebuild + +* Wed Jul 26 2017 Fedora Release Engineering - 3.25.2-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_27_Mass_Rebuild + +* Mon Jun 12 2017 Kalev Lember - 3.25.2-1 +- Update to 3.25.2 + +* Tue Mar 21 2017 Kalev Lember - 3.24.0-1 +- Update to 3.24.0 + +* Thu Mar 16 2017 Kalev Lember - 3.23.92-1 +- Update to 3.23.92 + +* Tue Feb 28 2017 Richard Hughes - 3.23.91-1 +- Update to 3.23.91 + +* Tue Feb 14 2017 Richard Hughes - 3.23.90-1 +- Update to 3.23.90 + +* Mon Feb 13 2017 Richard Hughes - 3.23.4-1 +- Update to 3.23.4 + +* Fri Feb 10 2017 Fedora Release Engineering - 3.23.2-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_26_Mass_Rebuild + +* Thu Dec 01 2016 Kalev Lember - 3.23.2-1 +- Update to 3.23.2 + +* Sun Oct 30 2016 Kalev Lember - 3.23.1-1 +- Update to 3.23.1 + +* Wed Oct 12 2016 Kalev Lember - 3.22.1-1 +- Update to 3.22.1 +- Don't set group tags + +* Tue Sep 20 2016 Kalev Lember - 3.22.0-1 +- Update to 3.22.0 + +* Tue Sep 13 2016 Kalev Lember - 3.21.92-1 +- Update to 3.21.92 + +* Thu Aug 18 2016 Kalev Lember - 3.21.90-1 +- Update to 3.21.90 + +* Wed Jun 22 2016 Richard Hughes - 3.21.2-1 +- Update to 3.21.2 + +* Sun May 08 2016 Kalev Lember - 3.20.1-1 +- Update to 3.20.1 + +* Tue Mar 22 2016 Kalev Lember - 3.20.0-1 +- Update to 3.20.0 + +* Tue Mar 01 2016 Richard Hughes - 3.19.91-1 +- Update to 3.19.91 + +* Tue Feb 16 2016 Richard Hughes - 3.19.90-1 +- Update to 3.19.90 + +* Wed Feb 03 2016 Fedora Release Engineering - 3.19.4-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_24_Mass_Rebuild + +* Wed Jan 20 2016 Kalev Lember - 3.19.4-1 +- Update to 3.19.4 + +* Wed Nov 25 2015 Kalev Lember - 3.19.2-1 +- Update to 3.19.2 + +* Wed Oct 28 2015 Kalev Lember - 3.19.1-1 +- Update to 3.19.1 + +* Mon Oct 12 2015 Kalev Lember - 3.18.1-1 +- Update to 3.18.1 + +* Sun Sep 20 2015 Kalev Lember - 3.18.0-1 +- Update to 3.18.0 +- Use make_install macro + +* Mon Sep 14 2015 Kalev Lember - 3.17.92-1 +- Update to 3.17.92 + +* Sun Jun 21 2015 David King - 3.17.3-1 +- Update to 3.17.3 +- Use license macro for COPYING + +* Wed Jun 17 2015 Fedora Release Engineering - 3.17.2-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_23_Mass_Rebuild + +* Sun May 31 2015 Kalev Lember - 3.17.2-1 +- Update to 3.17.2 + +* Mon Mar 23 2015 Kalev Lember - 3.16.0-1 +- Update to 3.16.0 + +* Tue Mar 03 2015 Kalev Lember - 3.15.91-1 +- Update to 3.15.91 + +* Mon Feb 16 2015 Michael Catanzaro - 3.15.4-1 +- Update license tag to GPLv3+ + +* Fri Jan 23 2015 David King - 3.15.4-1 +- Update to 3.15.4 +- Update URL +- Update man page globs in files section +- Use pkgconfig for BuildRequires +- Remove obsolete glib2 dependencies for GSettings schema +- Validate AppData in check +- Preserve timestamps during install + +* Fri Dec 19 2014 Richard Hughes - 3.15.1-1 +- Update to 3.15.1 + +* Sun Oct 26 2014 Kalev Lember - 3.14.1-1 +- Update to 3.14.1 + +* Mon Sep 22 2014 Kalev Lember - 3.14.0-1 +- Update to 3.14.0 + +* Tue Sep 16 2014 Kalev Lember - 3.13.92-1 +- Update to 3.13.92 + +* Tue Aug 19 2014 Kalev Lember - 3.13.90-1 +- Update to 3.13.90 + +* Sat Aug 16 2014 Fedora Release Engineering - 3.13.3-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_21_22_Mass_Rebuild + +* Thu Jul 17 2014 Kalev Lember - 3.13.3-1 +- Update to 3.13.3 +- Drop an upstreamed patch +- Include new gnome-shell search provider + +* Sat Jun 07 2014 Fedora Release Engineering - 3.13.2-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_21_Mass_Rebuild + +* Wed May 28 2014 Kalev Lember - 3.13.2-1 +- Update to 3.13.2 + +* Thu Apr 10 2014 Kalev Lember - 3.12.1-1 +- Update to 3.12.1 + +* Mon Mar 24 2014 Richard Hughes - 3.12.0-1 +- Update to 3.12.0 + +* Tue Mar 18 2014 Richard Hughes - 3.11.92-1 +- Update to 3.11.92 + +* Sat Mar 08 2014 Richard Hughes - 3.11.91-1 +- Update to 3.11.91 + +* Tue Feb 18 2014 Richard Hughes - 3.11.90-1 +- Update to 3.11.90 + +* Tue Feb 04 2014 Richard Hughes - 3.11.5-1 +- Update to 3.11.5 + +* Wed Jan 15 2014 Richard Hughes - 3.11.4-1 +- Update to 3.11.4 + +* Tue Dec 17 2013 Richard Hughes - 3.11.3-1 +- Update to 3.11.3 + +* Thu Nov 14 2013 Richard Hughes - 3.10.2-1 +- Update to 3.10.2 + +* Mon Oct 28 2013 Richard Hughes - 3.10.1-1 +- Update to 3.10.1 + +* Wed Sep 25 2013 Kalev Lember - 3.10.0-1 +- Update to 3.10.0 + +* Wed Sep 18 2013 Kalev Lember - 3.9.92-1 +- Update to 3.9.92 +- Include the appdata file + +* Wed Aug 28 2013 Kalev Lember - 3.9.90-1 +- Update to 3.9.90 + +* Sat Aug 03 2013 Fedora Release Engineering - 3.9.4-2 +- Rebuilt for https://fedoraproject.org/wiki/Fedora_20_Mass_Rebuild + +* Tue Jul 16 2013 Richard Hughes - 3.9.4-1 +- Update to 3.9.4 + +* Fri Jun 21 2013 Kalev Lember - 3.9.3-1 +- Update to 3.9.3 + +* Sun Jun 02 2013 Kalev Lember - 3.9.2-1 +- Update to 3.9.2 + +* Tue May 14 2013 Richard Hughes - 3.8.2-1 +- Update to 3.8.2 + +* Mon Apr 15 2013 Richard Hughes - 3.8.1-1 +- Update to 3.8.1 + +* Tue Mar 26 2013 Kalev Lember - 3.8.0-1 +- Update to 3.8.0 + +* Wed Mar 20 2013 Kalev Lember - 3.7.92-1 +- Update to 3.7.92 + +* Thu Mar 7 2013 Matthias Clasen - 3.7.91-1 +- Update to 3.7.91 + +* Fri Feb 22 2013 Adel Gadllah - 3.7.90-2 +- Bump obsolete (mass rebuild bumped the gcalcool nevr) + +* Thu Feb 21 2013 Kalev Lember - 3.7.90-1 +- Update to 3.7.90 + +* Wed Feb 06 2013 Kalev Lember - 3.7.5-1 +- Update to 3.7.5 + +* Wed Jan 16 2013 Matthias Clasen - 3.7.4-2 +- Fix keyword translations in desktop file + +* Wed Jan 16 2013 Matthias Clasen - 3.7.4-1 +- Renamed package from gcalctool to gnome-calculator diff --git a/sources b/sources new file mode 100644 index 0000000..782e9f2 --- /dev/null +++ b/sources @@ -0,0 +1 @@ +SHA512 (gnome-calculator-3.28.2.tar.xz) = 63b750a24c12feb4db20cdff6bbeb2ce595c7ba165b264c03a507ff9b7c10b70f874230a0f80741ccae775c30a5a39acc9c1fe39270b435eb6d4caef1d92dce5