Conditionally build for Webkit1 on Win32 and Webkit2 everywhere else.

This commit is contained in:
John Ralls 2017-07-11 08:53:20 -07:00
parent 8655dbc55c
commit f28ea50aaf
9 changed files with 1489 additions and 43 deletions

View File

@ -4,9 +4,9 @@ SET (html_HEADERS
gnc-html.h gnc-html.h
gnc-html-p.h gnc-html-p.h
gnc-html-factory.h gnc-html-factory.h
gnc-html-webkit.h
gnc-html-extras.h gnc-html-extras.h
gnc-html-webkit-p.h gnc-html-webkit-p.h
gnc-html-webkit.h
) )
IF (BUILDING_FROM_VCS) IF (BUILDING_FROM_VCS)
@ -21,9 +21,16 @@ SET (html_SOURCES
gnc-html.c gnc-html.c
gnc-html-history.c gnc-html-history.c
gnc-html-factory.c gnc-html-factory.c
gnc-html-webkit.c
) )
IF (WEBKIT1)
LIST(APPEND html_HEADERS gnc-html-webkit1.h)
LIST(APPEND html_SOURCES gnc-html-webkit1.c)
ELSE ()
LIST(APPEND html_HEADERS gnc-html-webkit2.h)
LIST(APPEND html_SOURCES gnc-html-webkit2.c)
ENDIF ()
SET_DIST_LIST(html_DIST CMakeLists.txt Makefile.am ${html_HEADERS} ${html_SOURCES} gnc-html.i) SET_DIST_LIST(html_DIST CMakeLists.txt Makefile.am ${html_HEADERS} ${html_SOURCES} gnc-html.i)
ADD_LIBRARY (gncmod-html ADD_LIBRARY (gncmod-html

View File

@ -1,6 +1,6 @@
/******************************************************************** /********************************************************************
* gnc-html-webkit.h -- display html with gnc special tags * * gnc-html-webkit.h -- display html with gnc special tags *
* Copyright (C) 2009 Phil Longstaff <plongstaff@rogers.com> * * Copyright (C) 2017 John Ralls <jralls@ceridwen.us> *
* * * *
* This program is free software; you can redistribute it and/or * * This program is free software; you can redistribute it and/or *
* modify it under the terms of the GNU General Public License as * * modify it under the terms of the GNU General Public License as *
@ -20,42 +20,9 @@
* Boston, MA 02110-1301, USA gnu@gnu.org * * Boston, MA 02110-1301, USA gnu@gnu.org *
\********************************************************************/ \********************************************************************/
#ifndef GNC_HTML_WEBKIT_H #include <config.h>
#define GNC_HTML_WEBKIT_H #ifdef WEBKIT1
#include "gnc-html-webkit1.h"
#include <glib-object.h> #else
#include "gnc-html.h" #include "gnc-html-webkit2.h"
G_BEGIN_DECLS
#define GNC_TYPE_HTML_WEBKIT (gnc_html_webkit_get_type())
#define GNC_HTML_WEBKIT(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GNC_TYPE_HTML_WEBKIT, GncHtmlWebkit))
#define GNC_HTML_WEBKIT_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), GNC_TYPE_HTML_WEBKIT, GncHtmlWebkitClass))
#define GNC_IS_HTML_WEBKIT(o) (G_TYPE_CHECK_INSTANCE_TYPE((o), GNC_TYPE_HTML_WEBKIT))
#define GNC_IS_HTML_WEBKIT_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE((k), GNC_TYPE_HTML_WEBKIT))
#define GNC_HTML_WEBKIT_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS((o), GNC_TYPE_HTML_WEBKIT, GncHtmlWebkitClass))
typedef struct _GncHtmlWebkit GncHtmlWebkit;
typedef struct _GncHtmlWebkitClass GncHtmlWebkitClass;
typedef struct _GncHtmlWebkitPrivate GncHtmlWebkitPrivate;
struct _GncHtmlWebkit
{
GncHtml parent_instance;
/*< private >*/
GncHtmlWebkitPrivate* priv;
};
struct _GncHtmlWebkitClass
{
GncHtmlClass parent_class;
};
GType gnc_html_webkit_get_type( void );
GncHtml* gnc_html_webkit_new( void );
G_END_DECLS
#endif #endif

1318
src/html/gnc-html-webkit1.c Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,61 @@
/********************************************************************
* gnc-html-webkit.h -- display html with gnc special tags *
* 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_WEBKIT_H
#define GNC_HTML_WEBKIT_H
#include <glib-object.h>
#include "gnc-html.h"
G_BEGIN_DECLS
#define GNC_TYPE_HTML_WEBKIT (gnc_html_webkit_get_type())
#define GNC_HTML_WEBKIT(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GNC_TYPE_HTML_WEBKIT, GncHtmlWebkit))
#define GNC_HTML_WEBKIT_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), GNC_TYPE_HTML_WEBKIT, GncHtmlWebkitClass))
#define GNC_IS_HTML_WEBKIT(o) (G_TYPE_CHECK_INSTANCE_TYPE((o), GNC_TYPE_HTML_WEBKIT))
#define GNC_IS_HTML_WEBKIT_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE((k), GNC_TYPE_HTML_WEBKIT))
#define GNC_HTML_WEBKIT_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS((o), GNC_TYPE_HTML_WEBKIT, GncHtmlWebkitClass))
typedef struct _GncHtmlWebkit GncHtmlWebkit;
typedef struct _GncHtmlWebkitClass GncHtmlWebkitClass;
typedef struct _GncHtmlWebkitPrivate GncHtmlWebkitPrivate;
struct _GncHtmlWebkit
{
GncHtml parent_instance;
/*< private >*/
GncHtmlWebkitPrivate* priv;
};
struct _GncHtmlWebkitClass
{
GncHtmlClass parent_class;
};
GType gnc_html_webkit_get_type( void );
GncHtml* gnc_html_webkit_new( void );
G_END_DECLS
#endif

View File

@ -0,0 +1,61 @@
/********************************************************************
* gnc-html-webkit.h -- display html with gnc special tags *
* 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_WEBKIT_H
#define GNC_HTML_WEBKIT_H
#include <glib-object.h>
#include "gnc-html.h"
G_BEGIN_DECLS
#define GNC_TYPE_HTML_WEBKIT (gnc_html_webkit_get_type())
#define GNC_HTML_WEBKIT(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GNC_TYPE_HTML_WEBKIT, GncHtmlWebkit))
#define GNC_HTML_WEBKIT_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), GNC_TYPE_HTML_WEBKIT, GncHtmlWebkitClass))
#define GNC_IS_HTML_WEBKIT(o) (G_TYPE_CHECK_INSTANCE_TYPE((o), GNC_TYPE_HTML_WEBKIT))
#define GNC_IS_HTML_WEBKIT_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE((k), GNC_TYPE_HTML_WEBKIT))
#define GNC_HTML_WEBKIT_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS((o), GNC_TYPE_HTML_WEBKIT, GncHtmlWebkitClass))
typedef struct _GncHtmlWebkit GncHtmlWebkit;
typedef struct _GncHtmlWebkitClass GncHtmlWebkitClass;
typedef struct _GncHtmlWebkitPrivate GncHtmlWebkitPrivate;
struct _GncHtmlWebkit
{
GncHtml parent_instance;
/*< private >*/
GncHtmlWebkitPrivate* priv;
};
struct _GncHtmlWebkitClass
{
GncHtmlClass parent_class;
};
GType gnc_html_webkit_get_type( void );
GncHtml* gnc_html_webkit_new( void );
G_END_DECLS
#endif

View File

@ -530,16 +530,24 @@ gnc_html_export_to_file( GncHtml* self, const gchar* filepath )
return FALSE; return FALSE;
} }
} }
#ifdef WEBKIT1
void
gnc_html_print (GncHtml* self, const char *jobname, gboolean export_pdf)
#else
void void
gnc_html_print (GncHtml* self) gnc_html_print (GncHtml* self)
#endif
{ {
g_return_if_fail( self != NULL ); g_return_if_fail( self != NULL );
g_return_if_fail( GNC_IS_HTML(self) ); g_return_if_fail( GNC_IS_HTML(self) );
if ( GNC_HTML_GET_CLASS(self)->print != NULL ) if ( GNC_HTML_GET_CLASS(self)->print != NULL )
{ {
#ifdef WEBKIT1
GNC_HTML_GET_CLASS(self)->print (self, jobname, export_pdf);
#else
GNC_HTML_GET_CLASS(self)->print (self); GNC_HTML_GET_CLASS(self)->print (self);
#endif
} }
else else
{ {

View File

@ -135,7 +135,11 @@ struct _GncHtmlClass
void (*reload)( GncHtml* html, gboolean force_rebuild ); void (*reload)( GncHtml* html, gboolean force_rebuild );
void (*copy_to_clipboard)( GncHtml* html ); void (*copy_to_clipboard)( GncHtml* html );
gboolean (*export_to_file)( GncHtml* html, const gchar* file ); gboolean (*export_to_file)( GncHtml* html, const gchar* file );
#ifdef WEBKIT1
void (*print) (GncHtml* html, const gchar* jobname, gboolean export_pdf);
#else
void (*print) (GncHtml* html); void (*print) (GncHtml* html);
#endif
void (*cancel)( GncHtml* html ); void (*cancel)( GncHtml* html );
URLType (*parse_url)( GncHtml* html, const gchar* url, URLType (*parse_url)( GncHtml* html, const gchar* url,
gchar** url_location, gchar** url_label ); gchar** url_location, gchar** url_label );
@ -196,13 +200,25 @@ void gnc_html_copy_to_clipboard( GncHtml* html );
*/ */
gboolean gnc_html_export_to_file( GncHtml* html, const gchar* filename ); gboolean gnc_html_export_to_file( GncHtml* html, const gchar* filename );
#ifdef WEBKIT1
/**
* Prints the report.
*
* @param html GncHtml object
* @param jobname A jobname fo identifying the print job or to provide
* an output filename.
* @param export_pdf If TRUE write a PDF file using the jobname for a
* filename; otherwise put up a print dialog.
*/
void gnc_html_print (GncHtml* html, const char* jobname, gboolean export_pdf);
#else
/** /**
* Prints the report. * Prints the report.
* *
* @param html GncHtml object * @param html GncHtml object
*/ */
void gnc_html_print (GncHtml* html); void gnc_html_print (GncHtml* html);
#endif
/** /**
* Cancels the current operation * Cancels the current operation
* *

View File

@ -1838,7 +1838,11 @@ gnc_plugin_page_report_print_cb( GtkAction *action, GncPluginPageReport *report
//g_warning("Setting job name=%s", job_name); //g_warning("Setting job name=%s", job_name);
#ifdef WEBKIT1
gnc_html_print (priv->html, job_name, TRUE);
#else
gnc_html_print (priv->html); gnc_html_print (priv->html);
#endif
g_free (job_name); g_free (job_name);
} }
@ -1877,7 +1881,11 @@ gnc_plugin_page_report_exportpdf_cb( GtkAction *action, GncPluginPageReport *rep
//g_warning("Setting job name=%s", job_name); //g_warning("Setting job name=%s", job_name);
#ifdef WEBKIT1
gnc_html_print (priv->html, job_name, TRUE);
#else
gnc_html_print (priv->html); gnc_html_print (priv->html);
#endif
if (owner) if (owner)
{ {