From 2d440318088bca90273099d6acafb33bff8fb480 Mon Sep 17 00:00:00 2001 From: Phil Longstaff Date: Sat, 11 Apr 2009 02:52:43 +0000 Subject: [PATCH] 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 --- src/html/gnc-html-graph-gog-extras.h | 33 +++++++++++++++++++++ src/html/gnc-html-graph-gog-gtkhtml.c | 11 +++---- src/html/gnc-html-graph-gog-webkit.c | 16 ++++------ src/html/gnc-html.i | 6 ++++ src/report/report-system/html-barchart.scm | 4 +-- src/report/report-system/html-linechart.scm | 8 ++--- src/report/report-system/html-piechart.scm | 4 +-- src/report/report-system/html-scatter.scm | 4 +-- 8 files changed, 61 insertions(+), 25 deletions(-) create mode 100644 src/html/gnc-html-graph-gog-extras.h diff --git a/src/html/gnc-html-graph-gog-extras.h b/src/html/gnc-html-graph-gog-extras.h new file mode 100644 index 0000000000..02280a99d0 --- /dev/null +++ b/src/html/gnc-html-graph-gog-extras.h @@ -0,0 +1,33 @@ +/******************************************************************** + * gnc-html-graph-gog-extras.h -- display html with gnc special * + * tags * + * Copyright (C) 2000 Bill Gribble * + * Copyright (C) 2009 Phil Longstaff * + * * + * 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 */ diff --git a/src/html/gnc-html-graph-gog-gtkhtml.c b/src/html/gnc-html-graph-gog-gtkhtml.c index 3b934d54c8..8315140693 100644 --- a/src/html/gnc-html-graph-gog-gtkhtml.c +++ b/src/html/gnc-html-graph-gog-gtkhtml.c @@ -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 @@ -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 * diff --git a/src/html/gnc-html-graph-gog-webkit.c b/src/html/gnc-html-graph-gog-webkit.c index 77eeb78d99..b0dbb3c55d 100644 --- a/src/html/gnc-html-graph-gog-webkit.c +++ b/src/html/gnc-html-graph-gog-webkit.c @@ -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 @@ -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 * diff --git a/src/html/gnc-html.i b/src/html/gnc-html.i index e94a2b1880..b0a484e8ce 100644 --- a/src/html/gnc-html.i +++ b/src/html/gnc-html.i @@ -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 } diff --git a/src/report/report-system/html-barchart.scm b/src/report/report-system/html-barchart.scm index caa2ecafe4..5f3ecfaa4e 100644 --- a/src/report/report-system/html-barchart.scm +++ b/src/report/report-system/html-barchart.scm @@ -48,7 +48,7 @@ ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;; class -;; generate the form for a guppi barchart. +;; generate the form for a barchart. ;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; (define gnc:make-html-barchart-internal @@ -331,7 +331,7 @@ (not (null? data)) (gnc:not-all-zeros data)) (begin - (push "