r18042 - gnucash/trunk/src - Remove magic strings - "gnc-guppi-pie" and other chart object types were separately defined

Phil Longstaff plongstaff at code.gnucash.org
Fri Apr 10 22:52:44 EDT 2009


Author: plongstaff
Date: 2009-04-10 22:52:43 -0400 (Fri, 10 Apr 2009)
New Revision: 18042
Trac: http://svn.gnucash.org/trac/changeset/18042

Added:
   gnucash/trunk/src/html/gnc-html-graph-gog-extras.h
Modified:
   gnucash/trunk/src/html/gnc-html-graph-gog-gtkhtml.c
   gnucash/trunk/src/html/gnc-html-graph-gog-webkit.c
   gnucash/trunk/src/html/gnc-html.i
   gnucash/trunk/src/report/report-system/html-barchart.scm
   gnucash/trunk/src/report/report-system/html-linechart.scm
   gnucash/trunk/src/report/report-system/html-piechart.scm
   gnucash/trunk/src/report/report-system/html-scatter.scm
Log:
Remove magic strings - "gnc-guppi-pie" and other chart object types were separately defined
in both the .c file and the .scm files where the chart html was created.  This change defines
the values once, in gnc-html-graph-gog-extras.h, and these #defines are used and passed into
guile for use in the scm files.



Added: gnucash/trunk/src/html/gnc-html-graph-gog-extras.h
===================================================================
--- gnucash/trunk/src/html/gnc-html-graph-gog-extras.h	                        (rev 0)
+++ gnucash/trunk/src/html/gnc-html-graph-gog-extras.h	2009-04-11 02:52:43 UTC (rev 18042)
@@ -0,0 +1,33 @@
+/********************************************************************
+ * gnc-html-graph-gog-extras.h -- display html with gnc special     *
+ *									tags			                *
+ * Copyright (C) 2000 Bill Gribble <grib at billgribble.com>           *
+ * Copyright (C) 2009 Phil Longstaff <plongstaff at rogers.com>        *
+ *                                                                  *
+ * 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 2 of   *
+ * the License, or (at your option) any later version.              *
+ *                                                                  *
+ * This program is distributed in the hope that it will be useful,  *
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of   *
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the    *
+ * GNU General Public License for more details.                     *
+ *                                                                  *
+ * You should have received a copy of the GNU General Public License*
+ * along with this program; if not, contact:                        *
+ *                                                                  *
+ * Free Software Foundation           Voice:  +1-617-542-5942       *
+ * 51 Franklin Street, Fifth Floor    Fax:    +1-617-542-2652       *
+ * Boston, MA  02110-1301,  USA       gnu at gnu.org                   *
+\********************************************************************/
+
+#ifndef GNC_HTML_GRAPH_GOG_EXTRAS_H
+#define GNC_HTML_GRAPH_GOG_EXTRAS_H 1
+
+#define GNC_CHART_PIE "gnc-guppi-pie"
+#define GNC_CHART_BAR "gnc-guppi-bar"
+#define GNC_CHART_LINE "gnc-guppi-line"
+#define GNC_CHART_SCATTER "gnc-guppi-scatter"
+
+#endif /* GNC_HTML_GRAPH_GOG_EXTRAS_H */

Modified: gnucash/trunk/src/html/gnc-html-graph-gog-gtkhtml.c
===================================================================
--- gnucash/trunk/src/html/gnc-html-graph-gog-gtkhtml.c	2009-04-11 01:44:14 UTC (rev 18041)
+++ gnucash/trunk/src/html/gnc-html-graph-gog-gtkhtml.c	2009-04-11 02:52:43 UTC (rev 18042)
@@ -31,6 +31,7 @@
 #include "gnc-ui-util.h"
 #include "gnc-html-graph-gog.h"
 #include "gnc-html-graph-gog-gtkhtml.h"
+#include "gnc-html-graph-gog-extras.h"
 #include "gnc-html.h"
 #include "gnc-engine.h"
 #include <goffice/goffice.h>
@@ -93,12 +94,12 @@
 void
 gnc_html_graph_gog_gtkhtml_init( void )
 {
-  gnc_html_graph_gog_init();
+	gnc_html_graph_gog_init();
 
-  gnc_html_register_object_handler( "gnc-guppi-pie", handle_piechart );
-  gnc_html_register_object_handler( "gnc-guppi-bar", handle_barchart );
-  gnc_html_register_object_handler( "gnc-guppi-scatter", handle_scatter );
-  gnc_html_register_object_handler( "gnc-guppi-line", handle_linechart );
+	gnc_html_register_object_handler( GNC_CHART_PIE, handle_piechart );
+	gnc_html_register_object_handler( GNC_CHART_BAR, handle_barchart );
+	gnc_html_register_object_handler( GNC_CHART_SCATTER, handle_scatter );
+	gnc_html_register_object_handler( GNC_CHART_LINE, handle_linechart );
 }
 
 static double * 

Modified: gnucash/trunk/src/html/gnc-html-graph-gog-webkit.c
===================================================================
--- gnucash/trunk/src/html/gnc-html-graph-gog-webkit.c	2009-04-11 01:44:14 UTC (rev 18041)
+++ gnucash/trunk/src/html/gnc-html-graph-gog-webkit.c	2009-04-11 02:52:43 UTC (rev 18042)
@@ -31,6 +31,7 @@
 #include "gnc-ui-util.h"
 #include "gnc-html-graph-gog.h"
 #include "gnc-html-graph-gog-webkit.h"
+#include "gnc-html-graph-gog-extras.h"
 #include "gnc-html.h"
 #include "gnc-engine.h"
 #include <goffice/goffice.h>
@@ -82,17 +83,12 @@
 void
 gnc_html_graph_gog_webkit_init( void )
 {
-  g_debug( "init gog graphing" );
-  
-  libgoffice_init();
-  
-  /* Initialize plugins manager */
-  go_plugins_init( NULL, NULL, NULL, NULL, TRUE, GO_PLUGIN_LOADER_MODULE_TYPE );
+	gnc_html_graph_gog_init();
 
-  gnc_html_register_object_handler( "gnc-guppi-pie", handle_piechart );
-  gnc_html_register_object_handler( "gnc-guppi-bar", handle_barchart );
-  gnc_html_register_object_handler( "gnc-guppi-scatter", handle_scatter );
-  gnc_html_register_object_handler( "gnc-guppi-line", handle_linechart );
+	gnc_html_register_object_handler( GNC_CHART_PIE, handle_piechart );
+	gnc_html_register_object_handler( GNC_CHART_BAR, handle_barchart );
+	gnc_html_register_object_handler( GNC_CHART_SCATTER, handle_scatter );
+	gnc_html_register_object_handler( GNC_CHART_LINE, handle_linechart );
 }
 
 static double * 

Modified: gnucash/trunk/src/html/gnc-html.i
===================================================================
--- gnucash/trunk/src/html/gnc-html.i	2009-04-11 01:44:14 UTC (rev 18041)
+++ gnucash/trunk/src/html/gnc-html.i	2009-04-11 02:52:43 UTC (rev 18042)
@@ -21,6 +21,7 @@
 
 /* Parse the header file to generate wrappers */
 %include "gnc-html-extras.h"
+%include "gnc-html-graph-gog-extras.h"
 
 
 %init {
@@ -45,6 +46,11 @@
     SET_ENUM("URL-TYPE-PRICE");
     SET_ENUM("URL-TYPE-OTHER");
 
+    SET_ENUM("GNC-CHART-PIE");
+    SET_ENUM("GNC-CHART-BAR");
+    SET_ENUM("GNC-CHART-LINE");
+    SET_ENUM("GNC-CHART-SCATTER");
+
 #undefine SET_ENUM
   }
 

Modified: gnucash/trunk/src/report/report-system/html-barchart.scm
===================================================================
--- gnucash/trunk/src/report/report-system/html-barchart.scm	2009-04-11 01:44:14 UTC (rev 18041)
+++ gnucash/trunk/src/report/report-system/html-barchart.scm	2009-04-11 02:52:43 UTC (rev 18042)
@@ -48,7 +48,7 @@
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;;  <html-barchart> class
-;;  generate the <object> form for a guppi barchart. 
+;;  generate the <object> form for a barchart. 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
 (define gnc:make-html-barchart-internal
@@ -331,7 +331,7 @@
              (not (null? data))
 	     (gnc:not-all-zeros data))
         (begin 
-          (push "<object classid=\"gnc-guppi-bar\" width=")
+          (push "<object classid=\"")(push GNC-CHART-BAR)(push "\" width=")
           (push (gnc:html-barchart-width barchart))
           (push " height=") 
           (push (gnc:html-barchart-height barchart))

Modified: gnucash/trunk/src/report/report-system/html-linechart.scm
===================================================================
--- gnucash/trunk/src/report/report-system/html-linechart.scm	2009-04-11 01:44:14 UTC (rev 18041)
+++ gnucash/trunk/src/report/report-system/html-linechart.scm	2009-04-11 02:52:43 UTC (rev 18042)
@@ -54,7 +54,7 @@
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;;  <html-linechart> class
-;;  generate the <object> form for a guppi linechart. 
+;;  generate the <object> form for a linechart. 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
 (define gnc:make-html-linechart-internal
@@ -356,7 +356,7 @@
              (not (null? data))
 	     (gnc:not-all-zeros data))
         (begin 
-          (push "<object classid=\"gnc-guppi-line\" width=")
+          (push "<object classid=\"")(push GNC-CHART-LINE)(push "\" width=")
           (push (gnc:html-linechart-width linechart))
           (push " height=") 
           (push (gnc:html-linechart-height linechart))
@@ -531,7 +531,7 @@
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;;  <html-linechart> class
-;;  generate the <object> form for a guppi linechart.
+;;  generate the <object> form for a linechart.
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
 (define gnc:make-html-linechart-internal
@@ -833,7 +833,7 @@
              (not (null? data))
             (gnc:not-all-zeros data))
         (begin
-          (push "<object classid=\"gnc-guppi-line\" width=")
+          (push "<object classid=\"")(push GNC-CHART-LINE)(push "\" width=")
           (push (gnc:html-linechart-width linechart))
           (push " height=")
           (push (gnc:html-linechart-height linechart))

Modified: gnucash/trunk/src/report/report-system/html-piechart.scm
===================================================================
--- gnucash/trunk/src/report/report-system/html-piechart.scm	2009-04-11 01:44:14 UTC (rev 18041)
+++ gnucash/trunk/src/report/report-system/html-piechart.scm	2009-04-11 02:52:43 UTC (rev 18042)
@@ -44,7 +44,7 @@
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;;  <html-piechart> class
-;;  generate the <object> form for a guppi piechart. 
+;;  generate the <object> form for a piechart. 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
 (define gnc:make-html-piechart-internal
@@ -197,7 +197,7 @@
     (if (and (list? data) 
              (not (null? data)))
         (begin 
-          (push "<object classid=\"gnc-guppi-pie\" width=")
+          (push "<object classid=\"")(push GNC-CHART-PIE)(push "\" width=")
           (push (gnc:html-piechart-width piechart))
           (push " height=") 
           (push (gnc:html-piechart-height piechart))

Modified: gnucash/trunk/src/report/report-system/html-scatter.scm
===================================================================
--- gnucash/trunk/src/report/report-system/html-scatter.scm	2009-04-11 01:44:14 UTC (rev 18041)
+++ gnucash/trunk/src/report/report-system/html-scatter.scm	2009-04-11 02:52:43 UTC (rev 18042)
@@ -53,7 +53,7 @@
 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 ;;  <html-scatter> class
-;;  generate the <object> form for a guppi scatter plot. 
+;;  generate the <object> form for a scatter plot. 
 ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
 
 (define gnc:make-html-scatter-internal
@@ -168,7 +168,7 @@
     (if (and (list? data)
              (not (null? data)))
         (begin 
-          (push "<object classid=\"gnc-guppi-scatter\" width=")
+          (push "<object classid=\"")(push GNC-CHART-SCATTER)(push "\" width=")
           (push (gnc:html-scatter-width scatter))
           (push " height=") 
           (push (gnc:html-scatter-height scatter))



More information about the gnucash-changes mailing list