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

This commit is contained in:
Geert Janssens 2018-02-02 18:46:58 +01:00
parent 8812aae5d5
commit d983ad9e46
8 changed files with 108 additions and 14 deletions

View File

@ -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

View File

@ -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

View File

@ -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))

View File

@ -3102,6 +3102,18 @@ many months before the current month:</property>
<child>
<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>
@ -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>

View File

@ -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})
SET_DIST_LIST(gnome_gschema_DIST CMakeLists.txt Makefile.am ${gnome_gschema_DIST_local})

View File

@ -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

View File

@ -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>

View File

@ -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.