[gnome-calculator] Fixed broken currency conversion (fixes #199)



commit 5399029fd8a82ee331ebed0bb632d27d21800889
Author: Robert Roth <robert roth off gmail com>
Date:   Mon Jan 4 15:59:01 2021 +0200

    Fixed broken currency conversion (fixes #199)

 lib/currency.vala         | 23 +++++++++++------------
 src/gnome-calculator.vala |  1 -
 2 files changed, 11 insertions(+), 13 deletions(-)
---
diff --git a/lib/currency.vala b/lib/currency.vala
index e366522c..a0b3e7d9 100644
--- a/lib/currency.vala
+++ b/lib/currency.vala
@@ -27,7 +27,7 @@ public class CurrencyManager : Object
             return default_currency_manager;
 
         default_currency_manager = new CurrencyManager ();
-
+        default_currency_manager.refresh_interval = new Settings ("org.gnome.calculator").get_int 
("refresh-interval");
         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 ("BDT", _("Bangladeshi Taka"), "৳"));
@@ -122,7 +122,7 @@ public class CurrencyManager : Object
 
     private string get_imf_rate_filepath ()
     {
-        return Path.build_filename (Environment.get_user_cache_dir (), "gnome-calculator", "rms_five.xls");
+        return Path.build_filename (Environment.get_user_cache_dir (), "gnome-calculator", "rms_rep.xls");
     }
 
     private string get_ecb_rate_filepath ()
@@ -245,16 +245,15 @@ public class CurrencyManager : Object
         {
             line = line.chug ();
 
-            /* Start after first blank line, stop on next */
-            if (line == "")
+            /* Start after Last Updated, end on Notes:*/
+            if (line.has_prefix ("Last Updated:"))
             {
-                if (!in_data)
-                {
-                   in_data = true;
-                   continue;
-                }
-                else
-                   break;
+                in_data = true;
+                continue;
+            } else if (line.has_prefix ("Notes:"))
+            {
+                in_data = false;
+                continue;
             }
             if (!in_data)
                 continue;
@@ -392,7 +391,7 @@ public class CurrencyManager : Object
         {
             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");
+            download_file.begin ("https://www.imf.org/external/np/fin/data/rms_rep.aspx?tsvflag=Y";, path, 
"IMF");
         }
         path = get_ecb_rate_filepath ();
         if (!downloading_ecb_rates && file_needs_update (path, refresh_interval))
diff --git a/src/gnome-calculator.vala b/src/gnome-calculator.vala
index 6edf4c8b..b2b52d58 100644
--- a/src/gnome-calculator.vala
+++ b/src/gnome-calculator.vala
@@ -121,7 +121,6 @@ public class Calculator : Gtk.Application
         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 ()


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