gnucash maint: Provide preference panel to set the Alpha Vantage API key needed for fincance::quote

Geert Janssens gjanssens at code.gnucash.org
Fri Feb 2 12:48:55 EST 2018


Updated	 via  https://github.com/Gnucash/gnucash/commit/d983ad9e (commit)
	from  https://github.com/Gnucash/gnucash/commit/8812aae5 (commit)



commit d983ad9e468434420d42f198aeddffdb70881017
Author: Geert Janssens <geert at kobaltwit.be>
Date:   Fri Feb 2 18:46:58 2018 +0100

    Provide preference panel to set the Alpha Vantage API key needed for fincance::quote

diff --git a/configure.ac b/configure.ac
index 4c7b38a..e8bec1f 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1585,6 +1585,7 @@ AC_CONFIG_FILES(
   src/gnome/gschemas/org.gnucash.dialogs.sxs.gschema.xml.in
   src/gnome/gschemas/org.gnucash.dialogs.totd.gschema.xml.in
   src/gnome/gschemas/org.gnucash.gschema.xml.in
+  src/gnome/gschemas/org.gnucash.general.finance-quote.gschema.xml.in
   src/gnome/gschemas/org.gnucash.window.pages.account.tree.gschema.xml.in
   src/gnome/gschemas/org.gnucash.window.pages.gschema.xml.in
   src/gnome-utils/gschemas/org.gnucash.history.gschema.xml.in
diff --git a/po/POTFILES.in b/po/POTFILES.in
index decb229..990b3ba 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -238,6 +238,7 @@ src/gnome/gnc-split-reg.c
 [type: gettext/gsettings]src/gnome/gschemas/org.gnucash.dialogs.reconcile.gschema.xml.in.in
 [type: gettext/gsettings]src/gnome/gschemas/org.gnucash.dialogs.sxs.gschema.xml.in.in
 [type: gettext/gsettings]src/gnome/gschemas/org.gnucash.dialogs.totd.gschema.xml.in.in
+[type: gettext/gsettings]src/gnome/gschemas/org.gnucash.general.finance-quote.gschema.xml.in.in
 [type: gettext/gsettings]src/gnome/gschemas/org.gnucash.gschema.xml.in.in
 [type: gettext/gsettings]src/gnome/gschemas/org.gnucash.window.pages.account.tree.gschema.xml.in.in
 [type: gettext/gsettings]src/gnome/gschemas/org.gnucash.window.pages.gschema.xml.in.in
@@ -494,7 +495,6 @@ src/plugins/customer_import/gnc-plugin-customer_import.c
 src/plugins/customer_import/gtkbuilder/dialog-customer-import-gui.glade
 src/plugins/customer_import/libgncmod-customer_import.c
 src/plugins/example/gncmod-example.c
-src/plugins/example/gnc-plugin.example.c
 src/python/gncmod-python.c
 src/register/ledger-core/gnc-ledger-display2.c
 src/register/ledger-core/gnc-ledger-display.c
diff --git a/src/core-utils/core-utils.scm b/src/core-utils/core-utils.scm
index 8fd2869..8d88f62 100644
--- a/src/core-utils/core-utils.scm
+++ b/src/core-utils/core-utils.scm
@@ -60,5 +60,6 @@
 (re-export gnc-prefs-set-float)
 (re-export gnc-prefs-set-string)
 (re-export gnc-prefs-set-coords)
+(re-export gnc-prefs-get-string)
 
 (define-public gnc:version (gnc-version))
diff --git a/src/gnome-utils/gtkbuilder/dialog-preferences.glade b/src/gnome-utils/gtkbuilder/dialog-preferences.glade
index 50cd79a..821778c 100644
--- a/src/gnome-utils/gtkbuilder/dialog-preferences.glade
+++ b/src/gnome-utils/gtkbuilder/dialog-preferences.glade
@@ -3103,6 +3103,18 @@ many months before the current month:</property>
                   <placeholder/>
                 </child>
                 <child>
+                  <placeholder/>
+                </child>
+                <child>
+                  <placeholder/>
+                </child>
+                <child>
+                  <placeholder/>
+                </child>
+                <child>
+                  <placeholder/>
+                </child>
+                <child>
                   <object class="GtkLabel" id="locale_currency2">
                     <property name="visible">True</property>
                     <property name="can_focus">False</property>
@@ -3320,18 +3332,6 @@ many months before the current month:</property>
                     <property name="y_options"/>
                   </packing>
                 </child>
-                <child>
-                  <placeholder/>
-                </child>
-                <child>
-                  <placeholder/>
-                </child>
-                <child>
-                  <placeholder/>
-                </child>
-                <child>
-                  <placeholder/>
-                </child>
               </object>
               <packing>
                 <property name="position">7</property>
@@ -3777,6 +3777,80 @@ many months before the current month:</property>
                 <property name="tab_fill">False</property>
               </packing>
             </child>
+            <child>
+              <object class="GtkTable" id="table6">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="border_width">6</property>
+                <property name="n_rows">3</property>
+                <property name="n_columns">3</property>
+                <property name="column_spacing">12</property>
+                <child>
+                  <placeholder/>
+                </child>
+                <child>
+                  <placeholder/>
+                </child>
+                <child>
+                  <placeholder/>
+                </child>
+                <child>
+                  <placeholder/>
+                </child>
+                <child>
+                  <placeholder/>
+                </child>
+                <child>
+                  <placeholder/>
+                </child>
+                <child>
+                  <placeholder/>
+                </child>
+                <child>
+                  <object class="GtkLabel" id="label23">
+                    <property name="visible">True</property>
+                    <property name="can_focus">False</property>
+                    <property name="label" translatable="yes">Alpha Vantage API key</property>
+                  </object>
+                  <packing>
+                    <property name="x_options">GTK_FILL</property>
+                    <property name="y_options">GTK_FILL</property>
+                  </packing>
+                </child>
+                <child>
+                  <object class="GtkEntry" id="pref/general.finance-quote/alphavantage-api-key">
+                    <property name="visible">True</property>
+                    <property name="can_focus">True</property>
+                    <property name="invisible_char">●</property>
+                    <property name="primary_icon_activatable">False</property>
+                    <property name="secondary_icon_activatable">False</property>
+                    <property name="primary_icon_sensitive">True</property>
+                    <property name="secondary_icon_sensitive">True</property>
+                  </object>
+                  <packing>
+                    <property name="left_attach">1</property>
+                    <property name="right_attach">2</property>
+                    <property name="x_options">GTK_FILL</property>
+                    <property name="y_options">GTK_FILL</property>
+                  </packing>
+                </child>
+              </object>
+              <packing>
+                <property name="position">9</property>
+              </packing>
+            </child>
+            <child type="tab">
+              <object class="GtkLabel" id="label22">
+                <property name="visible">True</property>
+                <property name="can_focus">False</property>
+                <property name="xalign">0</property>
+                <property name="label" translatable="yes">Online Quotes</property>
+              </object>
+              <packing>
+                <property name="position">9</property>
+                <property name="tab_fill">False</property>
+              </packing>
+            </child>
           </object>
           <packing>
             <property name="expand">True</property>
diff --git a/src/gnome/gschemas/CMakeLists.txt b/src/gnome/gschemas/CMakeLists.txt
index 05e8c82..21697b4 100644
--- a/src/gnome/gschemas/CMakeLists.txt
+++ b/src/gnome/gschemas/CMakeLists.txt
@@ -7,6 +7,7 @@ SET(gnome_GSCHEMA
   org.gnucash.dialogs.sxs.gschema.xml
   org.gnucash.dialogs.totd.gschema.xml
   org.gnucash.gschema.xml
+  org.gnucash.general.finance-quote.gschema.xml
   org.gnucash.window.pages.account.tree.gschema.xml
   org.gnucash.window.pages.gschema.xml
 )
@@ -22,4 +23,4 @@ SET(gnome_gschema_DIST_local "")
 FOREACH(file ${gnome_GSCHEMA})
     LIST(APPEND gnome_gschema_DIST_local ${file}.in.in)
 ENDFOREACH()
-SET_DIST_LIST(gnome_gschema_DIST CMakeLists.txt Makefile.am ${gnome_gschema_DIST_local})
\ No newline at end of file
+SET_DIST_LIST(gnome_gschema_DIST CMakeLists.txt Makefile.am ${gnome_gschema_DIST_local})
diff --git a/src/gnome/gschemas/Makefile.am b/src/gnome/gschemas/Makefile.am
index 6e5070a..3b353bf 100644
--- a/src/gnome/gschemas/Makefile.am
+++ b/src/gnome/gschemas/Makefile.am
@@ -8,6 +8,7 @@ gschema_in_files = \
   org.gnucash.dialogs.sxs.gschema.xml.in \
   org.gnucash.dialogs.totd.gschema.xml.in \
   org.gnucash.gschema.xml.in \
+  org.gnucash.general.finance-quote.gschema.xml.in \
   org.gnucash.window.pages.account.tree.gschema.xml.in \
   org.gnucash.window.pages.gschema.xml.in
 
diff --git a/src/gnome/gschemas/org.gnucash.general.finance-quote.gschema.xml.in.in b/src/gnome/gschemas/org.gnucash.general.finance-quote.gschema.xml.in.in
new file mode 100644
index 0000000..1a69fae
--- /dev/null
+++ b/src/gnome/gschemas/org.gnucash.general.finance-quote.gschema.xml.in.in
@@ -0,0 +1,9 @@
+<schemalist gettext-domain="@GETTEXT_PACKAGE@">
+  <schema id="org.gnucash.general.finance-quote" path="/org/gnucash/general/finance-quote/">
+    <key name="alphavantage-api-key" type="s">
+      <default>''</default>
+      <summary>Alpha Vantage API key</summary>
+      <description>To retrieve online quotes from Alphavantage, this key needs to be set. A key can be retrieved from the Alpha Vantage website.</description>
+    </key>
+  </schema>
+</schemalist>
diff --git a/src/scm/price-quotes.scm b/src/scm/price-quotes.scm
index 0008dd8..2f01ca1 100644
--- a/src/scm/price-quotes.scm
+++ b/src/scm/price-quotes.scm
@@ -453,6 +453,13 @@
                #f)))
        prices)))
 
+  ;; Add the alphavantage api key to the environment. This value is taken from
+  ;; the Online Quotes preference tab
+  (let* ((alphavantage-api-key (gnc-prefs-get-string "general.finance-quote" "alphavantage-api-key")))
+        (gnc:debug (string-concatenate (list "ALPHAVANTAGE_API_KEY=" alphavantage-api-key)))
+        (if (not (string-null? alphavantage-api-key))
+            (setenv "ALPHAVANTAGE_API_KEY" alphavantage-api-key)))
+
   ;; FIXME: uses of gnc:warn in here need to be cleaned up.  Right
   ;; now, they'll result in funny formatting.
 



Summary of changes:
 configure.ac                                       |  1 +
 po/POTFILES.in                                     |  2 +-
 src/core-utils/core-utils.scm                      |  1 +
 .../gtkbuilder/dialog-preferences.glade            | 98 +++++++++++++++++++---
 src/gnome/gschemas/CMakeLists.txt                  |  3 +-
 src/gnome/gschemas/Makefile.am                     |  1 +
 ...gnucash.general.finance-quote.gschema.xml.in.in |  9 ++
 src/scm/price-quotes.scm                           |  7 ++
 8 files changed, 108 insertions(+), 14 deletions(-)
 create mode 100644 src/gnome/gschemas/org.gnucash.general.finance-quote.gschema.xml.in.in



More information about the gnucash-changes mailing list