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.



git-svn-id: svn+ssh://svn.gnucash.org/repo/gnucash/trunk@18042 57a11ea4-9604-0410-9ed3-97b8803252fd
This commit is contained in:
Phil Longstaff 2009-04-11 02:52:43 +00:00
parent ea934ae4d0
commit 2d44031808
8 changed files with 61 additions and 25 deletions

View File

@ -0,0 +1,33 @@
/********************************************************************
* gnc-html-graph-gog-extras.h -- display html with gnc special *
* tags *
* Copyright (C) 2000 Bill Gribble <grib@billgribble.com> *
* Copyright (C) 2009 Phil Longstaff <plongstaff@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@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 */

View File

@ -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 @@ static void set_chart_axis_labels(GogObject *chart, const char *x_axis_label, co
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 *

View File

@ -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 @@ static double * read_doubles(const char * string, int nvalues);
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 *

View File

@ -21,6 +21,7 @@ SCM scm_init_sw_gnc_html_module(void);
/* Parse the header file to generate wrappers */
%include "gnc-html-extras.h"
%include "gnc-html-graph-gog-extras.h"
%init {
@ -45,6 +46,11 @@ SCM scm_init_sw_gnc_html_module(void);
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
}

View File

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

View File

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

View File

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

View File

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