gnucash maint: Display detected Finance::Quote version in about dialog

Geert Janssens gjanssens at code.gnucash.org
Thu Jan 25 04:35:35 EST 2018


Updated	 via  https://github.com/Gnucash/gnucash/commit/adba439b (commit)
	from  https://github.com/Gnucash/gnucash/commit/cb2b0396 (commit)



commit adba439b1cc44cea1a806c3d9b020973a21a5f53
Author: Geert Janssens <geert at kobaltwit.be>
Date:   Thu Jan 25 10:09:50 2018 +0100

    Display detected Finance::Quote version in about dialog

diff --git a/src/engine/engine.i b/src/engine/engine.i
index 9001eb6..7c8a1a0 100644
--- a/src/engine/engine.i
+++ b/src/engine/engine.i
@@ -237,7 +237,8 @@ Timespec timespecCanonicalDayTime(Timespec t);
   $1 = g_list_reverse (path);
 }
 
-void gnc_quote_source_set_fq_installed (GList *sources_list);
+void gnc_quote_source_set_fq_installed (const char* version_string,
+                                        GList *sources_list);
 %clear GList *;
 %ignore gnc_quote_source_set_fq_installed;
 %ignore gnc_commodity_table_get_quotable_commodities;
diff --git a/src/engine/gnc-commodity.c b/src/engine/gnc-commodity.c
index a48cb79..7993d14 100644
--- a/src/engine/gnc-commodity.c
+++ b/src/engine/gnc-commodity.c
@@ -142,7 +142,7 @@ struct gnc_new_iso_code
 #define GNC_NEW_ISO_CODES \
         (sizeof(gnc_new_iso_codes) / sizeof(struct gnc_new_iso_code))
 
-static gboolean fq_is_installed = FALSE;
+static char *fq_version = NULL;
 
 struct gnc_quote_source_s
 {
@@ -259,7 +259,20 @@ static GList *new_quote_sources = NULL;
 gboolean
 gnc_quote_source_fq_installed (void)
 {
-    return fq_is_installed;
+    return (fq_version != NULL);
+}
+
+
+/********************************************************************
+ * gnc_quote_source_fq_version
+ *
+ * This function the version of the Finance::Quote module installed
+ * on a user's computer or NULL if no installation is found.
+ ********************************************************************/
+const char*
+gnc_quote_source_fq_version (void)
+{
+    return fq_version;
 }
 
 /********************************************************************
@@ -510,6 +523,7 @@ gnc_quote_source_get_internal_name (const gnc_quote_source *source)
     return source->internal_name;
 }
 
+
 /********************************************************************
  * gnc_quote_source_set_fq_installed
  *
@@ -517,18 +531,27 @@ gnc_quote_source_get_internal_name (const gnc_quote_source *source)
  * installed.
  ********************************************************************/
 void
-gnc_quote_source_set_fq_installed (const GList *sources_list)
+gnc_quote_source_set_fq_installed (const char* version_string,
+                                   const GList *sources_list)
 {
     gnc_quote_source *source;
     char *source_name;
     const GList *node;
 
     ENTER(" ");
-    fq_is_installed = TRUE;
 
     if (!sources_list)
         return;
 
+    if (fq_version)
+    {
+        g_free (fq_version);
+        fq_version = NULL;
+    }
+
+    if (version_string)
+        fq_version = g_strdup (version_string);
+
     for (node = sources_list; node; node = node->next)
     {
         source_name = node->data;
diff --git a/src/engine/gnc-commodity.h b/src/engine/gnc-commodity.h
index 161996e..479366c 100644
--- a/src/engine/gnc-commodity.h
+++ b/src/engine/gnc-commodity.h
@@ -139,13 +139,21 @@ typedef enum
 } QuoteSourceType;
 
 /** This function indicates whether or not the Finance::Quote module
- *  is installed on a users computer.  This includes any other related
+ *  is installed on a user's computer.  This includes any other related
  *  modules that gnucash need to process F::Q information.
  *
  *  @return TRUE is F::Q is installed properly.
  */
 gboolean gnc_quote_source_fq_installed (void);
 
+/** This function returns the version of the Finance::Quote module
+ *  installed on a user's computer. If no proper installation is found
+ *  it will return NULL.
+ *
+ *  @return a version string or NULL
+ */
+const char* gnc_quote_source_fq_version (void);
+
 /** Update gnucash internal tables based on what Finance::Quote
  *  sources are installed.  Sources that have been explicitly coded
  *  into gnucash are marked sensitive/insensitive based upon whether
@@ -155,7 +163,8 @@ gboolean gnc_quote_source_fq_installed (void);
  *  @param sources_list A list of strings containing the source names
  *  as they are known to F::Q.
  */
-void gnc_quote_source_set_fq_installed (const GList *sources_list);
+void gnc_quote_source_set_fq_installed (const char* version_string,
+                                        const GList *sources_list);
 
 /** Return the number of entries for a given type of quote source.
  *
diff --git a/src/gnome-utils/gnc-main-window.c b/src/gnome-utils/gnc-main-window.c
index 347805a..95a3890 100644
--- a/src/gnome-utils/gnc-main-window.c
+++ b/src/gnome-utils/gnc-main-window.c
@@ -4374,7 +4374,7 @@ gnc_main_window_cmd_help_about (GtkAction *action, GncMainWindow *window)
 	gchar **authors = get_file_strsplit("AUTHORS");
 	gchar **documenters = get_file_strsplit("DOCUMENTERS");
 	gchar *license = get_file("LICENSE");
-	gchar *message;
+	gchar *message, *tmp_msg;
 	GdkPixbuf *logo = gnc_gnome_get_gdkpixbuf ("gnucash-icon-48x48.png");
 
 #ifdef GNUCASH_SCM
@@ -4383,17 +4383,20 @@ gnc_main_window_cmd_help_about (GtkAction *action, GncMainWindow *window)
                     2nd %s is the scm type (svn/svk/git/bzr);
                     3rd %s is the scm revision number;
                     4th %s is the build date */
-	message = g_strdup_printf(_("%s\nThis copy was built from %s rev %s on %s."),
+	tmp_msg = g_strdup_printf(_("%s\nThis copy was built from %s rev %s on %s."),
 				  fixed_message, GNUCASH_SCM, GNUCASH_SCM_REV,
 				  GNUCASH_BUILD_DATE);
 #else
     /* Translators: 1st %s is a fixed message, which is translated independently;
                     2nd %s is the scm (svn/svk/git/bzr) revision number;
                     3rd %s is the build date */
-	message = g_strdup_printf(_("%s\nThis copy was built from rev %s on %s."),
+	tmp_msg = g_strdup_printf(_("%s\nThis copy was built from rev %s on %s."),
 				  fixed_message, GNUCASH_SCM_REV,
 				  GNUCASH_BUILD_DATE);
 #endif
+        message = g_strdup_printf ("%s\n\nFinance::Quote: %s", tmp_msg,
+                                   gnc_quote_source_fq_version () ? gnc_quote_source_fq_version () : "-");
+        g_free (tmp_msg);
 	priv->about_dialog = gtk_about_dialog_new ();
 	g_object_set (priv->about_dialog,
 		      "authors", authors,
diff --git a/src/scm/price-quotes.scm b/src/scm/price-quotes.scm
index 8161e83..0008dd8 100644
--- a/src/scm/price-quotes.scm
+++ b/src/scm/price-quotes.scm
@@ -611,4 +611,4 @@ Run 'gnc-fq-update' as root to install them.") "\n")))
       (format #t "Found Finance::Quote version ~A" (car sources))
       (newline)
 	  (gnc:msg "Found Finance::Quote version " (car sources))
-	  (gnc-quote-source-set-fq-installed (cdr sources))))))
+	  (gnc-quote-source-set-fq-installed (car sources) (cdr sources))))))



Summary of changes:
 src/engine/engine.i               |  3 ++-
 src/engine/gnc-commodity.c        | 31 +++++++++++++++++++++++++++----
 src/engine/gnc-commodity.h        | 13 +++++++++++--
 src/gnome-utils/gnc-main-window.c |  9 ++++++---
 src/scm/price-quotes.scm          |  2 +-
 5 files changed, 47 insertions(+), 11 deletions(-)



More information about the gnucash-changes mailing list