r18012 - gnucash/branches/webkit/src - 1) Move final bits of scheme binding for html stuff from gnome-utils to html
Phil Longstaff
plongstaff at code.gnucash.org
Wed Apr 1 20:34:11 EDT 2009
Author: plongstaff
Date: 2009-04-01 20:34:11 -0400 (Wed, 01 Apr 2009)
New Revision: 18012
Trac: http://svn.gnucash.org/trac/changeset/18012
Modified:
gnucash/branches/webkit/src/gnome-utils/gnome-utils.i
gnucash/branches/webkit/src/html/Makefile.am
gnucash/branches/webkit/src/html/gnc-html-gtkhtml.c
gnucash/branches/webkit/src/html/gnc-html-gtkmozembed.c
gnucash/branches/webkit/src/html/gnc-html-webkit-p.h
gnucash/branches/webkit/src/html/gnc-html-webkit.c
gnucash/branches/webkit/src/html/gnc-html.c
gnucash/branches/webkit/src/html/gnc-html.h
gnucash/branches/webkit/src/report/report-gnome/gnc-plugin-page-report.c
gnucash/branches/webkit/src/report/report-system/report-system.scm
Log:
1) Move final bits of scheme binding for html stuff from gnome-utils to html
2) Rename gnc_html_copy() to gnc_html_copy_to_clipboard() and gnc_html_export() to
gnc_html_export_to_file().
3) In webkit html engine, save the html string so that it can be exported to a file and
implement export_to_file.
4) In webkit html engine, implement copy_to_clipboard for the currently selected section.
5) Remove the form handling stuff. There was a trace line in the code saying that it
hadn't really been working for years, and it wasn't called from anywhere.
Modified: gnucash/branches/webkit/src/gnome-utils/gnome-utils.i
===================================================================
--- gnucash/branches/webkit/src/gnome-utils/gnome-utils.i 2009-03-31 14:22:53 UTC (rev 18011)
+++ gnucash/branches/webkit/src/gnome-utils/gnome-utils.i 2009-04-02 00:34:11 UTC (rev 18012)
@@ -12,7 +12,6 @@
#include <gnc-file.h>
#include <gnc-gnome-utils.h>
#include <gnc-gui-query.h>
-#include <gnc-html.h>
#include <gnc-main-window.h>
#include <gnc-window.h>
#include <gnc-menu-extensions.h>
@@ -25,10 +24,6 @@
%import "base-typemaps.i"
-/* Parse the header file to generate wrappers */
-%include "gnc-html-extras.h"
-
-
GNCOptionWin * gnc_options_dialog_new(gchar *title);
void gnc_options_dialog_destroy(GNCOptionWin * win);
void gnc_options_dialog_build_contents(GNCOptionWin *propertybox,
@@ -57,30 +52,3 @@
void gnc_window_show_progress (const char *message, double percentage);
gboolean gnucash_ui_is_running(void);
-
-%init {
- {
- char tmp[100];
-
-#define SET_ENUM(e) snprintf(tmp, 100, "(set! %s (%s))", (e), (e)); \
- scm_c_eval_string(tmp);
-
- SET_ENUM("URL-TYPE-FILE");
- SET_ENUM("URL-TYPE-JUMP");
- SET_ENUM("URL-TYPE-HTTP");
- SET_ENUM("URL-TYPE-FTP");
- SET_ENUM("URL-TYPE-SECURE");
- SET_ENUM("URL-TYPE-REGISTER");
- SET_ENUM("URL-TYPE-ACCTTREE");
- SET_ENUM("URL-TYPE-REPORT");
- SET_ENUM("URL-TYPE-OPTIONS");
- SET_ENUM("URL-TYPE-SCHEME");
- SET_ENUM("URL-TYPE-HELP");
- SET_ENUM("URL-TYPE-XMLDATA");
- SET_ENUM("URL-TYPE-PRICE");
- SET_ENUM("URL-TYPE-OTHER");
-
-#undefine SET_ENUM
- }
-
-}
Modified: gnucash/branches/webkit/src/html/Makefile.am
===================================================================
--- gnucash/branches/webkit/src/html/Makefile.am 2009-03-31 14:22:53 UTC (rev 18011)
+++ gnucash/branches/webkit/src/html/Makefile.am 2009-04-02 00:34:11 UTC (rev 18012)
@@ -3,8 +3,6 @@
pkglib_LTLIBRARIES = libgncmod-html.la
-# Note that src/gnome-utils CANNOT depend on src/gnome!
-
if HTML_USING_WEBKIT
AM_CPPFLAGS = \
-I${top_srcdir}/src/core-utils \
@@ -43,6 +41,7 @@
if HTML_USING_WEBKIT
libgncmod_html_la_SOURCES = \
+ gncmod-html.c \
gnc-html.c \
gnc-html-history.c \
gnc-html-graph-gog.c \
@@ -52,6 +51,7 @@
swig-gnc-html.c
else
libgncmod_html_la_SOURCES = \
+ gncmod-html.c \
gnc-html.c \
gnc-html-history.c \
gnc-html-gtkhtml.c \
@@ -148,7 +148,7 @@
noinst_DATA = .scm-links
CLEANFILES = $(BUILT_SOURCES) gnucash .scm-links ${SCM_FILE_LINKS}
-MAINTAINERCLEANFILES = swig-gnome-utils.c
+MAINTAINERCLEANFILES = swig-html.c
# FIXME: Symlinking directories only works on non-win32.
if !PLATFORM_WIN32
Modified: gnucash/branches/webkit/src/html/gnc-html-gtkhtml.c
===================================================================
--- gnucash/branches/webkit/src/html/gnc-html-gtkhtml.c 2009-03-31 14:22:53 UTC (rev 18011)
+++ gnucash/branches/webkit/src/html/gnc-html-gtkhtml.c 2009-04-02 00:34:11 UTC (rev 18012)
@@ -77,11 +77,6 @@
/* hashes an HTML <object classid="ID"> classid to a handler function */
extern GHashTable* gnc_html_object_handlers;
-/* hashes an action name from a FORM definition to a handler function.
- * <form method=METHOD action=gnc-action:ACTION-NAME?ACTION-ARGS>
- * action-args is what gets passed to the handler. */
-extern GHashTable* gnc_html_action_handlers;
-
/* hashes handlers for loading different URLType data */
extern GHashTable* gnc_html_stream_handlers;
@@ -102,16 +97,13 @@
gpointer data );
static int gnc_html_button_press_cb( GtkWidget* widg, GdkEventButton* event,
gpointer user_data );
-static int gnc_html_submit_cb( GtkHTML* html, const gchar* method,
- const gchar* action, const gchar* encoded_form_data,
- gpointer user_data );
static void impl_gtkhtml_show_url( GncHtml* self, URLType type,
const gchar* location, const gchar* label,
gboolean new_window_hint );
static void impl_gtkhtml_show_data( GncHtml* self, const gchar* data, int datalen );
static void impl_gtkhtml_reload( GncHtml* self );
-static void impl_gtkhtml_copy( GncHtml* self );
-static gboolean impl_gtkhtml_export( GncHtml* self, const gchar* filepath );
+static void impl_gtkhtml_copy_to_clipboard( GncHtml* self );
+static gboolean impl_gtkhtml_export_to_file( GncHtml* self, const gchar* filepath );
static void impl_gtkhtml_print( GncHtml* self );
static void impl_gtkhtml_cancel( GncHtml* self );
static void impl_gtkhtml_set_parent( GncHtml* self, GtkWindow* parent );
@@ -161,10 +153,6 @@
G_CALLBACK (gnc_html_button_press_cb),
self);
- g_signal_connect (priv->html, "submit",
- G_CALLBACK(gnc_html_submit_cb),
- self);
-
gtk_html_load_empty(GTK_HTML(priv->html));
LEAVE("retval %p", self);
@@ -182,8 +170,8 @@
html_class->show_url = impl_gtkhtml_show_url;
html_class->show_data = impl_gtkhtml_show_data;
html_class->reload = impl_gtkhtml_reload;
- html_class->copy = impl_gtkhtml_copy;
- html_class->export = impl_gtkhtml_export;
+ html_class->copy_to_clipboard = impl_gtkhtml_copy_to_clipboard;
+ html_class->export_to_file = impl_gtkhtml_export_to_file;
html_class->print = impl_gtkhtml_print;
html_class->cancel = impl_gtkhtml_cancel;
html_class->set_parent = impl_gtkhtml_set_parent;
@@ -561,37 +549,6 @@
}
/********************************************************************
- * gnc_html_button_submit_cb
- * form submission callback
- ********************************************************************/
-
-static int
-gnc_html_submit_cb( GtkHTML* html, const gchar* method,
- const gchar* action, const gchar* encoded_form_data,
- gpointer user_data )
-{
- GncHtmlGtkhtml* self = GNC_HTML_GTKHTML(user_data);
- gchar* location = NULL;
- gchar* new_loc = NULL;
- gchar* label = NULL;
- GHashTable * form_data;
- URLType type;
-
- DEBUG(" ");
- form_data = gnc_html_unpack_form_data( encoded_form_data );
- type = gnc_html_parse_url( GNC_HTML(self), action, &location, &label );
-
- g_critical( "form submission hasn't been supported in years." );
-
- g_free( location );
- g_free( label );
- g_free( new_loc );
- gnc_html_free_form_data( form_data );
- return TRUE;
-}
-
-
-/********************************************************************
* gnc_html_open_scm
* insert some scheme-generated HTML
********************************************************************/
@@ -839,7 +796,7 @@
}
static void
-impl_gtkhtml_copy( GncHtml* self )
+impl_gtkhtml_copy_to_clipboard( GncHtml* self )
{
GncHtmlGtkhtmlPrivate* priv;
@@ -850,7 +807,7 @@
}
/**************************************************************
- * gnc_html_export : wrapper around the builtin function in gtkhtml
+ * gnc_html_export_to_file : wrapper around the builtin function in gtkhtml
**************************************************************/
static gboolean
@@ -870,7 +827,7 @@
}
static gboolean
-impl_gtkhtml_export( GncHtml* self, const char *filepath )
+impl_gtkhtml_export_to_file( GncHtml* self, const char *filepath )
{
FILE *fh;
GncHtmlGtkhtmlPrivate* priv;
Modified: gnucash/branches/webkit/src/html/gnc-html-gtkmozembed.c
===================================================================
--- gnucash/branches/webkit/src/html/gnc-html-gtkmozembed.c 2009-03-31 14:22:53 UTC (rev 18011)
+++ gnucash/branches/webkit/src/html/gnc-html-gtkmozembed.c 2009-04-02 00:34:11 UTC (rev 18012)
@@ -74,11 +74,6 @@
/* hashes an HTML <object classid="ID"> classid to a handler function */
extern GHashTable* gnc_html_object_handlers;
-/* hashes an action name from a FORM definition to a handler function.
- * <form method=METHOD action=gnc-action:ACTION-NAME?ACTION-ARGS>
- * action-args is what gets passed to the handler. */
-extern GHashTable* gnc_html_action_handlers;
-
/* hashes handlers for loading different URLType data */
extern GHashTable* gnc_html_stream_handlers;
@@ -103,18 +98,13 @@
#endif
static int gnc_html_button_press_cb( GtkWidget* widg, GdkEventButton* event,
gpointer user_data );
-#if 0
-static int gnc_html_submit_cb( GtkHTML* html, const gchar* method,
- const gchar* action, const gchar* encoded_form_data,
- gpointer user_data );
-#endif
static void impl_gtkmozembed_show_url( GncHtml* self, URLType type,
const gchar* location, const gchar* label,
gboolean new_window_hint );
static void impl_gtkmozembed_show_data( GncHtml* self, const gchar* data, int datalen );
static void impl_gtkmozembed_reload( GncHtml* self );
-static void impl_gtkmozembed_copy( GncHtml* self );
-static gboolean impl_gtkmozembed_export( GncHtml* self, const gchar* filepath );
+static void impl_gtkmozembed_copy_to_clipboard( GncHtml* self );
+static gboolean impl_gtkmozembed_export_to_file( GncHtml* self, const gchar* filepath );
static void impl_gtkmozembed_print( GncHtml* self );
static void impl_gtkmozembed_cancel( GncHtml* self );
static void impl_gtkmozembed_set_parent( GncHtml* self, GtkWindow* parent );
@@ -191,8 +181,8 @@
html_class->show_url = impl_gtkmozembed_show_url;
html_class->show_data = impl_gtkmozembed_show_data;
html_class->reload = impl_gtkmozembed_reload;
- html_class->copy = impl_gtkmozembed_copy;
- html_class->export = impl_gtkmozembed_export;
+ html_class->copy_to_clipboard = impl_gtkmozembed_copy_to_clipboard;
+ html_class->export_to_file = impl_gtkmozembed_export_to_file;
// html_class->print = impl_gtkmozembed_print;
html_class->cancel = impl_gtkmozembed_cancel;
html_class->set_parent = impl_gtkmozembed_set_parent;
@@ -542,38 +532,6 @@
}
/********************************************************************
- * gnc_html_button_submit_cb
- * form submission callback
- ********************************************************************/
-
-#if 0
-static int
-gnc_html_submit_cb( GtkHTML* html, const gchar* method,
- const gchar* action, const gchar* encoded_form_data,
- gpointer user_data )
-{
- GncHtmlWebkit* self = GNC_HTML_WEBKIT(user_data);
- gchar* location = NULL;
- gchar* new_loc = NULL;
- gchar* label = NULL;
- GHashTable * form_data;
- URLType type;
-
- DEBUG(" ");
- form_data = gnc_html_unpack_form_data( encoded_form_data );
- type = gnc_html_parse_url( GNC_HTML(self), action, &location, &label );
-
- g_critical( "form submission hasn't been supported in years." );
-
- g_free( location );
- g_free( label );
- g_free( new_loc );
- gnc_html_free_form_data( form_data );
- return TRUE;
-}
-#endif
-
-/********************************************************************
* gnc_html_open_scm
* insert some scheme-generated HTML
********************************************************************/
@@ -816,7 +774,7 @@
}
static void
-impl_webkit_copy( GncHtml* self )
+impl_webkit_copy_to_clipboard( GncHtml* self )
{
GncHtmlWebkitPrivate* priv;
@@ -828,7 +786,7 @@
}
/**************************************************************
- * gnc_html_export : wrapper around the builtin function in webkit
+ * gnc_html_export_to_file : wrapper around the builtin function in webkit
**************************************************************/
static gboolean
@@ -848,7 +806,7 @@
}
static gboolean
-impl_webkit_export( GncHtml* self, const char *filepath )
+impl_webkit_export_to_file( GncHtml* self, const char *filepath )
{
FILE *fh;
GncHtmlWebkitPrivate* priv;
Modified: gnucash/branches/webkit/src/html/gnc-html-webkit-p.h
===================================================================
--- gnucash/branches/webkit/src/html/gnc-html-webkit-p.h 2009-03-31 14:22:53 UTC (rev 18011)
+++ gnucash/branches/webkit/src/html/gnc-html-webkit-p.h 2009-04-02 00:34:11 UTC (rev 18012)
@@ -29,6 +29,7 @@
struct _GncHtmlPrivate base;
WebKitWebView* web_view; /* webkit widget itself */
+ gchar* html_string; /* html string being displayed */
};
#endif
Modified: gnucash/branches/webkit/src/html/gnc-html-webkit.c
===================================================================
--- gnucash/branches/webkit/src/html/gnc-html-webkit.c 2009-03-31 14:22:53 UTC (rev 18011)
+++ gnucash/branches/webkit/src/html/gnc-html-webkit.c 2009-04-02 00:34:11 UTC (rev 18012)
@@ -72,11 +72,6 @@
/* hashes an HTML <object classid="ID"> classid to a handler function */
extern GHashTable* gnc_html_object_handlers;
-/* hashes an action name from a FORM definition to a handler function.
- * <form method=METHOD action=gnc-action:ACTION-NAME?ACTION-ARGS>
- * action-args is what gets passed to the handler. */
-extern GHashTable* gnc_html_action_handlers;
-
/* hashes handlers for loading different URLType data */
extern GHashTable* gnc_html_stream_handlers;
@@ -100,18 +95,13 @@
#endif
static int gnc_html_button_press_cb( GtkWidget* widg, GdkEventButton* event,
gpointer user_data );
-#if 0
-static int gnc_html_submit_cb( GtkHTML* html, const gchar* method,
- const gchar* action, const gchar* encoded_form_data,
- gpointer user_data );
-#endif
static void impl_webkit_show_url( GncHtml* self, URLType type,
const gchar* location, const gchar* label,
gboolean new_window_hint );
static void impl_webkit_show_data( GncHtml* self, const gchar* data, int datalen );
static void impl_webkit_reload( GncHtml* self );
-static void impl_webkit_copy( GncHtml* self );
-static gboolean impl_webkit_export( GncHtml* self, const gchar* filepath );
+static void impl_webkit_copy_to_clipboard( GncHtml* self );
+static gboolean impl_webkit_export_to_file( GncHtml* self, const gchar* filepath );
static void impl_webkit_print( GncHtml* self );
static void impl_webkit_cancel( GncHtml* self );
static void impl_webkit_set_parent( GncHtml* self, GtkWindow* parent );
@@ -124,7 +114,9 @@
new_priv = g_realloc( GNC_HTML(self)->priv, sizeof(GncHtmlWebkitPrivate) );
priv = self->priv = new_priv;
+ GNC_HTML(self)->priv = (GncHtmlPrivate*)priv;
+ priv->html_string = NULL;
priv->web_view = WEBKIT_WEB_VIEW(webkit_web_view_new());
gtk_container_add( GTK_CONTAINER(priv->base.container),
@@ -183,8 +175,8 @@
html_class->show_url = impl_webkit_show_url;
html_class->show_data = impl_webkit_show_data;
html_class->reload = impl_webkit_reload;
-// html_class->copy = impl_webkit_copy;
-// html_class->export = impl_webkit_export;
+ html_class->copy_to_clipboard = impl_webkit_copy_to_clipboard;
+ html_class->export_to_file = impl_webkit_export_to_file;
html_class->print = impl_webkit_print;
html_class->cancel = impl_webkit_cancel;
html_class->set_parent = impl_webkit_set_parent;
@@ -393,6 +385,11 @@
fdata = new_fdata;
}
+ // Save a copy for export purposes
+ if( priv->html_string != NULL ) {
+ g_free( priv->html_string );
+ }
+ priv->html_string = g_strdup( fdata );
webkit_web_view_load_html_string( priv->web_view, fdata, "base-uri" );
} else {
fdata = fdata ? fdata :
@@ -591,38 +588,6 @@
}
/********************************************************************
- * gnc_html_button_submit_cb
- * form submission callback
- ********************************************************************/
-
-#if 0
-static int
-gnc_html_submit_cb( GtkHTML* html, const gchar* method,
- const gchar* action, const gchar* encoded_form_data,
- gpointer user_data )
-{
- GncHtmlWebkit* self = GNC_HTML_WEBKIT(user_data);
- gchar* location = NULL;
- gchar* new_loc = NULL;
- gchar* label = NULL;
- GHashTable * form_data;
- URLType type;
-
- DEBUG(" ");
- form_data = gnc_html_unpack_form_data( encoded_form_data );
- type = gnc_html_parse_url( GNC_HTML(self), action, &location, &label );
-
- g_critical( "form submission hasn't been supported in years." );
-
- g_free( location );
- g_free( label );
- g_free( new_loc );
- gnc_html_free_form_data( form_data );
- return TRUE;
-}
-#endif
-
-/********************************************************************
* gnc_html_open_scm
* insert some scheme-generated HTML
********************************************************************/
@@ -879,7 +844,7 @@
}
static void
-impl_webkit_copy( GncHtml* self )
+impl_webkit_copy_to_clipboard( GncHtml* self )
{
GncHtmlWebkitPrivate* priv;
@@ -887,32 +852,17 @@
g_return_if_fail( GNC_IS_HTML_WEBKIT(self) );
priv = GNC_HTML_WEBKIT_GET_PRIVATE(self);
- g_assert( FALSE );
+ if( webkit_web_view_can_copy_clipboard( priv->web_view ) ) {
+ webkit_web_view_copy_clipboard( priv->web_view );
+ }
}
/**************************************************************
- * gnc_html_export : wrapper around the builtin function in webkit
+ * gnc_html_export_to_file : wrapper around the builtin function in webkit
**************************************************************/
-
static gboolean
-raw_html_receiver( gpointer engine,
- const gchar* data,
- size_t len,
- gpointer user_data )
+impl_webkit_export_to_file( GncHtml* self, const char *filepath )
{
- FILE *fh = (FILE *) user_data;
- size_t written;
-
- do {
- written = fwrite (data, 1, len, fh);
- len -= written;
- } while (len > 0);
- return TRUE;
-}
-
-static gboolean
-impl_webkit_export( GncHtml* self, const char *filepath )
-{
FILE *fh;
GncHtmlWebkitPrivate* priv;
@@ -921,33 +871,46 @@
g_return_val_if_fail( filepath != NULL, FALSE );
priv = GNC_HTML_WEBKIT_GET_PRIVATE(self);
- fh = g_fopen( filepath, "w" );
- if( fh == 0 )
+ if( priv->html_string == NULL ) {
return FALSE;
+ }
+ fh = g_fopen( filepath, "w" );
+ if( fh != NULL ) {
+ gint written;
+ gint len = strlen( priv->html_string );
-// gtk_html_save( GTK_HTML(priv->html), GINT_TO_POINTER(raw_html_receiver), fh );
- g_assert( FALSE );
- fclose (fh);
+ written = fwrite( priv->html_string, 1, len, fh );
+ fclose (fh);
- return TRUE;
+ if( written != len ) {
+ return FALSE;
+ }
+
+ return TRUE;
+ } else {
+ return FALSE;
+ }
}
static void
impl_webkit_print( GncHtml* self )
{
GncHtmlWebkitPrivate* priv;
- static void (*webkit_web_frame_print)( WebKitWebFrame* frame ) = NULL;
+// static void (*webkit_web_frame_print)( WebKitWebFrame* frame ) = NULL;
WebKitWebFrame* frame;
+ extern void webkit_web_frame_print( WebKitWebFrame* frame );
/* HACK ALERT
*
* The api to print isn't exported, but exists and works, so let's dig for it.
*/
+#if 0
if( webkit_web_frame_print == NULL ) {
void* handle = dlopen( "/usr/lib/libwebkit-1.0.so", RTLD_LAZY );
webkit_web_frame_print = dlsym( handle, "webkit_web_frame_print" );
dlclose( handle );
}
+#endif
priv = GNC_HTML_WEBKIT_GET_PRIVATE(self);
frame = webkit_web_view_get_main_frame( priv->web_view );
Modified: gnucash/branches/webkit/src/html/gnc-html.c
===================================================================
--- gnucash/branches/webkit/src/html/gnc-html.c 2009-03-31 14:22:53 UTC (rev 18011)
+++ gnucash/branches/webkit/src/html/gnc-html.c 2009-04-02 00:34:11 UTC (rev 18012)
@@ -59,11 +59,6 @@
/* hashes an HTML <object classid="ID"> classid to a handler function */
GHashTable* gnc_html_object_handlers = NULL;
-/* hashes an action name from a FORM definition to a handler function.
- * <form method=METHOD action=gnc-action:ACTION-NAME?ACTION-ARGS>
- * action-args is what gets passed to the handler. */
-GHashTable* gnc_html_action_handlers = NULL;
-
/* hashes handlers for loading different URLType data */
GHashTable* gnc_html_stream_handlers = NULL;
@@ -101,8 +96,8 @@
klass->show_url = NULL;
klass->show_data = NULL;
klass->reload = NULL;
- klass->copy = NULL;
- klass->export = NULL;
+ klass->copy_to_clipboard = NULL;
+ klass->export_to_file = NULL;
klass->print = NULL;
klass->cancel = NULL;
klass->parse_url = NULL;
@@ -442,32 +437,32 @@
}
void
-gnc_html_copy( GncHtml* self )
+gnc_html_copy_to_clipboard( GncHtml* self )
{
g_return_if_fail( self != NULL );
g_return_if_fail( GNC_IS_HTML(self) );
- if( GNC_HTML_GET_CLASS(self)->copy != NULL ) {
- GNC_HTML_GET_CLASS(self)->copy( self );
+ if( GNC_HTML_GET_CLASS(self)->copy_to_clipboard != NULL ) {
+ GNC_HTML_GET_CLASS(self)->copy_to_clipboard( self );
} else {
- DEBUG( "'copy' not implemented" );
+ DEBUG( "'copy_to_clipboard' not implemented" );
}
}
/**************************************************************
- * gnc_html_export : wrapper around the builtin function in gtkhtml
+ * gnc_html_export_to_file : wrapper around the builtin function in gtkhtml
**************************************************************/
gboolean
-gnc_html_export( GncHtml* self, const gchar* filepath )
+gnc_html_export_to_file( GncHtml* self, const gchar* filepath )
{
g_return_val_if_fail( self != NULL, FALSE );
g_return_val_if_fail( GNC_IS_HTML(self), FALSE );
- if( GNC_HTML_GET_CLASS(self)->export != NULL ) {
- return GNC_HTML_GET_CLASS(self)->export( self, filepath );
+ if( GNC_HTML_GET_CLASS(self)->export_to_file != NULL ) {
+ return GNC_HTML_GET_CLASS(self)->export_to_file( self, filepath );
} else {
- DEBUG( "'export' not implemented" );
+ DEBUG( "'export_to_file' not implemented" );
return FALSE;
}
}
@@ -589,108 +584,6 @@
}
/********************************************************************
- * gnc_html_pack/unpack_form_data
- * convert an encoded arg string to/from a name-value hash table
- ********************************************************************/
-
-GHashTable *
-gnc_html_unpack_form_data(const char * encoding)
-{
- GHashTable * rv;
-
- DEBUG(" ");
- rv = g_hash_table_new(g_str_hash, g_str_equal);
- gnc_html_merge_form_data(rv, encoding);
- return rv;
-}
-
-void
-gnc_html_merge_form_data(GHashTable * rv, const char * encoding)
-{
- char * next_pair = NULL;
- char * name = NULL;
- char * value = NULL;
- char * extr_name = NULL;
- char * extr_value = NULL;
-
- DEBUG(" ");
- if(!encoding) {
- return;
- }
- next_pair = g_strdup(encoding);
-
- while(next_pair) {
- name = next_pair;
- if((value = strchr(name, '=')) != NULL) {
- extr_name = g_strndup(name, value-name);
- next_pair = strchr(value, '&');
- if(next_pair) {
- extr_value = g_strndup(value+1, next_pair-value-1);
- next_pair++;
- }
- else {
- extr_value = g_strdup(value+1);
- }
-
- g_hash_table_insert(rv,
- gnc_html_decode_string(extr_name),
- gnc_html_decode_string(extr_value));
- g_free(extr_name);
- g_free(extr_value);
- }
- else {
- next_pair = NULL;
- }
- }
-}
-
-static gboolean
-free_form_data_helper(gpointer k, gpointer v, gpointer user)
-{
- DEBUG(" ");
- g_free(k);
- g_free(v);
- return TRUE;
-}
-
-void
-gnc_html_free_form_data(GHashTable * d)
-{
- DEBUG(" ");
- g_hash_table_foreach_remove(d, free_form_data_helper, NULL);
- g_hash_table_destroy(d);
-}
-
-static void
-pack_form_data_helper(gpointer key, gpointer val,
- gpointer user_data)
-{
- char * old_str = *(char **)user_data;
- char * enc_key = gnc_html_encode_string((char *)key);
- char * enc_val = gnc_html_encode_string((char *)val);
- char * new_str = NULL;
-
- DEBUG(" ");
- if(old_str) {
- new_str = g_strconcat(old_str, "&", enc_key, "=", enc_val, NULL);
- }
- else {
- new_str = g_strconcat(enc_key, "=", enc_val, NULL);
- }
- *(char **)user_data = new_str;
- g_free(old_str);
-}
-
-char *
-gnc_html_pack_form_data(GHashTable * form_data)
-{
- char * encoded = NULL;
- DEBUG(" ");
- g_hash_table_foreach(form_data, pack_form_data_helper, &encoded);
- return encoded;
-}
-
-/********************************************************************
* gnc_html_encode_string
* RFC 1738 encoding of string for submission with an HTML form.
* GPL code lifted from gtkhtml. copyright notice:
@@ -867,41 +760,6 @@
}
void
-gnc_html_register_action_handler( const gchar* actionid,
- GncHTMLActionCB hand )
-{
- g_return_if_fail( actionid != NULL );
-
- if( gnc_html_action_handlers == NULL ) {
- gnc_html_action_handlers = g_hash_table_new( g_str_hash, g_str_equal );
- }
-
- gnc_html_unregister_action_handler( actionid );
- if( hand != NULL ) {
- g_hash_table_insert( gnc_html_action_handlers, g_strdup( actionid ), hand );
- }
-}
-
-void
-gnc_html_unregister_action_handler( const gchar* actionid )
-{
- gchar* keyptr = NULL;
- gchar* valptr = NULL;
- gchar** p_keyptr = &keyptr;
- gchar** p_valptr = &valptr;
-
- g_return_if_fail( actionid != NULL );
-
- if( g_hash_table_lookup_extended( gnc_html_action_handlers,
- actionid,
- (gpointer *)p_keyptr,
- (gpointer *)p_valptr) ) {
- g_hash_table_remove( gnc_html_action_handlers, actionid );
- g_free( keyptr );
- }
-}
-
-void
gnc_html_register_stream_handler( URLType url_type, GncHTMLStreamCB hand )
{
g_return_if_fail( url_type != NULL && *url_type != '\0' );
Modified: gnucash/branches/webkit/src/html/gnc-html.h
===================================================================
--- gnucash/branches/webkit/src/html/gnc-html.h 2009-03-31 14:22:53 UTC (rev 18011)
+++ gnucash/branches/webkit/src/html/gnc-html.h 2009-04-02 00:34:11 UTC (rev 18012)
@@ -73,8 +73,6 @@
typedef gboolean (* GncHTMLObjectCB)(GncHtml* html, gpointer eb,
gpointer data);
-typedef int (* GncHTMLActionCB)(GncHtml* html, const gchar* method,
- const gchar* action, GHashTable* form_data);
typedef gboolean (* GncHTMLStreamCB)(const gchar* location, gchar** data, int* datalen);
typedef gboolean (* GncHTMLUrlCB)(const gchar* location, const gchar* label,
gboolean new_window, GNCURLResult* result);
@@ -99,23 +97,11 @@
gchar* gnc_html_escape_newlines( const gchar* in );
gchar* gnc_html_unescape_newlines( const gchar* in );
-/* utilities for dealing with encoded argument strings for forms */
-gchar* gnc_html_pack_form_data( GHashTable* form_data );
-GHashTable* gnc_html_unpack_form_data( const gchar* encoding );
-void gnc_html_merge_form_data( GHashTable* fdata, const gchar* enc );
-void gnc_html_free_form_data( GHashTable* fdata );
-
/* object handlers deal with <object classid="foo"> objects in HTML.
* the handlers are looked up at object load time. */
void gnc_html_register_object_handler( const gchar* classid, GncHTMLObjectCB hand );
void gnc_html_unregister_object_handler( const gchar* classid );
-/* action handlers deal with submitting forms of the type
- * <FORM action="gnc-action:action?args">. Normal get/post http:
- * forms are handled as would be expected, with no callback. */
-void gnc_html_register_action_handler( const gchar* action, GncHTMLActionCB hand );
-void gnc_html_unregister_action_handler( const gchar* action );
-
/* stream handlers load data for particular URLTypes. */
void gnc_html_register_stream_handler( URLType url_type, GncHTMLStreamCB hand );
void gnc_html_unregister_stream_handler( URLType url_type );
@@ -147,8 +133,8 @@
gboolean new_window_hint );
void (*show_data)( GncHtml* html, const gchar* data, int datalen );
void (*reload)( GncHtml* html );
- void (*copy)( GncHtml* html );
- gboolean (*export)( GncHtml* html, const gchar* file );
+ void (*copy_to_clipboard)( GncHtml* html );
+ gboolean (*export_to_file)( GncHtml* html, const gchar* file );
void (*print)( GncHtml* html );
void (*cancel)( GncHtml* html );
URLType (*parse_url)( GncHtml* html, const gchar* url,
@@ -194,10 +180,11 @@
void gnc_html_reload( GncHtml* html );
/**
- *
+ * Copies the html to the clipboard
+ *
* @param html GncHtml object
*/
-void gnc_html_copy( GncHtml* html );
+void gnc_html_copy_to_clipboard( GncHtml* html );
/**
* Exports the html to an external file.
@@ -206,7 +193,7 @@
* @param filename External file name
* @param TRUE if successful, FALSE if unsuccessful
*/
-gboolean gnc_html_export( GncHtml* html, const gchar* filename );
+gboolean gnc_html_export_to_file( GncHtml* html, const gchar* filename );
/**
* Prints the report.
@@ -268,12 +255,6 @@
void gnc_html_register_object_handler( const gchar* classid, GncHTMLObjectCB hand );
void gnc_html_unregister_object_handler( const gchar* classid );
-/* action handlers deal with submitting forms of the type
- * <FORM action="gnc-action:action?args">. Normal get/post http:
- * forms are handled as would be expected, with no callback. */
-void gnc_html_register_action_handler( const gchar* action, GncHTMLActionCB hand );
-void gnc_html_unregister_action_handler( const gchar* action );
-
/* stream handlers load data for particular URLTypes. */
void gnc_html_register_stream_handler( URLType url_type, GncHTMLStreamCB hand );
void gnc_html_unregister_stream_handler( URLType url_type );
Modified: gnucash/branches/webkit/src/report/report-gnome/gnc-plugin-page-report.c
===================================================================
--- gnucash/branches/webkit/src/report/report-gnome/gnc-plugin-page-report.c 2009-03-31 14:22:53 UTC (rev 18011)
+++ gnucash/branches/webkit/src/report/report-gnome/gnc-plugin-page-report.c 2009-04-02 00:34:11 UTC (rev 18012)
@@ -1434,7 +1434,7 @@
result = (res != SCM_BOOL_F);
}
else
- result = gnc_html_export (priv->html, filepath);
+ result = gnc_html_export_to_file (priv->html, filepath);
if (!result)
{
@@ -1491,7 +1491,7 @@
GncPluginPageReportPrivate *priv;
priv = GNC_PLUGIN_PAGE_REPORT_GET_PRIVATE(report);
- gnc_html_copy(priv->html);
+ gnc_html_copy_to_clipboard(priv->html);
}
/********************************************************************
Modified: gnucash/branches/webkit/src/report/report-system/report-system.scm
===================================================================
--- gnucash/branches/webkit/src/report/report-system/report-system.scm 2009-03-31 14:22:53 UTC (rev 18011)
+++ gnucash/branches/webkit/src/report/report-system/report-system.scm 2009-04-02 00:34:11 UTC (rev 18012)
@@ -17,7 +17,8 @@
(gnc:module-load "gnucash/engine" 0)
(gnc:module-load "gnucash/app-utils" 0)
-(gnc:module-load "gnucash/gnome-utils" 0) ; for the html routines
+(gnc:module-load "gnucash/html" 0)
+(gnc:module-load "gnucash/gnome-utils" 0)
;; commodity-utilities.scm
(export gnc:get-match-commodity-splits)
More information about the gnucash-changes
mailing list