|
GnuCash 2.4.99
|
00001 /******************************************************************** 00002 * gnc-html.h -- display html with gnc special tags * 00003 * Copyright (C) 2000 Bill Gribble <grib@billgribble.com> * 00004 * * 00005 * This program is free software; you can redistribute it and/or * 00006 * modify it under the terms of the GNU General Public License as * 00007 * published by the Free Software Foundation; either version 2 of * 00008 * the License, or (at your option) any later version. * 00009 * * 00010 * This program is distributed in the hope that it will be useful, * 00011 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00012 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 00013 * GNU General Public License for more details. * 00014 * * 00015 * You should have received a copy of the GNU General Public License* 00016 * along with this program; if not, contact: * 00017 * * 00018 * Free Software Foundation Voice: +1-617-542-5942 * 00019 * 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652 * 00020 * Boston, MA 02110-1301, USA gnu@gnu.org * 00021 \********************************************************************/ 00022 00023 #ifndef GNC_HTML_H 00024 #define GNC_HTML_H 00025 00032 #include <glib-object.h> 00033 00034 G_BEGIN_DECLS 00035 00036 #define GNC_TYPE_HTML (gnc_html_get_type()) 00037 #define GNC_HTML(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GNC_TYPE_HTML, GncHtml)) 00038 #define GNC_HTML_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), GNC_TYPE_HTML, GncHtmlClass)) 00039 #define GNC_IS_HTML(o) (G_TYPE_CHECK_INSTANCE_TYPE((o), GNC_TYPE_HTML)) 00040 #define GNC_IS_HTML_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE((o), GNC_TYPE_HTML)) 00041 #define GNC_HTML_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS((o), GNC_TYPE_HTML, GncHtmlClass)) 00042 00043 GType gnc_html_get_type(void); 00044 00045 typedef struct _GncHtml GncHtml; 00046 typedef struct _GncHtmlClass GncHtmlClass; 00047 typedef struct _GncHtmlPrivate GncHtmlPrivate; 00048 00049 #include "gnc-html-extras.h" 00050 00051 /* The result structure of url handlers. Strings should be g_malloc'd 00052 * by the handler and will be freed by gnc_html. */ 00053 typedef struct 00054 { 00055 /* The following members are used if the handler succeeds (returns TRUE). */ 00056 00057 gboolean load_to_stream; /* If TRUE, the url should be loaded from 00058 * a stream using the rest of the data in 00059 * the struct into the original gnc_html 00060 * object. If FALSE, the handler will 00061 * perform all needed actions itself. */ 00062 00063 URLType url_type; /* Defaults to original */ 00064 gchar* location; /* If NULL, use original (NULL is default) */ 00065 gchar* label; /* If NULL, use original (NULL is default) */ 00066 00067 URLType base_type; 00068 gchar* base_location; 00069 00070 /* The following members are used if the handler fails (returns FALSE). */ 00071 gchar* error_message; 00072 } GNCURLResult; 00073 00074 typedef gboolean (* GncHTMLObjectCB)(GncHtml* html, gpointer eb, 00075 gpointer data); 00076 typedef gboolean (* GncHTMLStreamCB)(const gchar* location, gchar** data, int* datalen); 00077 typedef gboolean (* GncHTMLUrlCB)(const gchar* location, const gchar* label, 00078 gboolean new_window, GNCURLResult* result); 00079 00088 gboolean gnc_html_register_urltype( URLType type, const gchar* protocol ); 00089 00093 void gnc_html_initialize( void ); 00094 00095 gchar* gnc_html_encode_string( const gchar* in ); 00096 gchar* gnc_html_decode_string( const gchar* in ); 00097 gchar* gnc_html_escape_newlines( const gchar* in ); 00098 gchar* gnc_html_unescape_newlines( const gchar* in ); 00099 00100 /* object handlers deal with <object classid="foo"> objects in HTML. 00101 * the handlers are looked up at object load time. */ 00102 void gnc_html_register_object_handler( const gchar* classid, GncHTMLObjectCB hand ); 00103 void gnc_html_unregister_object_handler( const gchar* classid ); 00104 00105 /* stream handlers load data for particular URLTypes. */ 00106 void gnc_html_register_stream_handler( URLType url_type, GncHTMLStreamCB hand ); 00107 void gnc_html_unregister_stream_handler( URLType url_type ); 00108 00109 /* handlers for particular URLTypes. */ 00110 void gnc_html_register_url_handler( URLType url_type, GncHTMLUrlCB hand ); 00111 void gnc_html_unregister_url_handler( URLType url_type ); 00112 00113 #include "gnc-html-history.h" 00114 00115 typedef int (* GncHTMLUrltypeCB)(URLType ut); 00116 typedef void (* GncHTMLFlyoverCB)(GncHtml* html, const gchar* url, 00117 gpointer data); 00118 typedef void (* GncHTMLLoadCB)(GncHtml* html, URLType type, 00119 const gchar* location, const gchar* label, 00120 gpointer data); 00121 typedef int (* GncHTMLButtonCB)(GncHtml* html, GdkEventButton* event, 00122 gpointer data); 00123 00124 struct _GncHtmlClass 00125 { 00126 GtkBinClass parent_class; 00127 00128 /* Methods */ 00129 void (*show_url)( GncHtml* html, 00130 URLType type, 00131 const gchar* location, 00132 const gchar* label, 00133 gboolean new_window_hint ); 00134 void (*show_data)( GncHtml* html, const gchar* data, int datalen ); 00135 void (*reload)( GncHtml* html ); 00136 void (*copy_to_clipboard)( GncHtml* html ); 00137 gboolean (*export_to_file)( GncHtml* html, const gchar* file ); 00138 void (*print)( GncHtml* html, const gchar* jobname, gboolean export_pdf ); 00139 void (*cancel)( GncHtml* html ); 00140 URLType (*parse_url)( GncHtml* html, const gchar* url, 00141 gchar** url_location, gchar** url_label ); 00142 void (*set_parent)( GncHtml* html, GtkWindow* parent ); 00143 }; 00144 00145 struct _GncHtml 00146 { 00147 GtkBin parent_instance; 00148 00149 /*< private >*/ 00150 GncHtmlPrivate* priv; 00151 }; 00152 00158 void gnc_html_destroy( GncHtml* html ); 00159 00165 void gnc_html_show_url( GncHtml* html, URLType type, const gchar* location, 00166 const gchar* label, gboolean new_window_hint ); 00167 00173 void gnc_html_show_data( GncHtml* html, const gchar* data, int datalen ); 00174 00180 void gnc_html_reload( GncHtml* html ); 00181 00187 void gnc_html_copy_to_clipboard( GncHtml* html ); 00188 00196 gboolean gnc_html_export_to_file( GncHtml* html, const gchar* filename ); 00197 00206 void gnc_html_print( GncHtml* html, const gchar* jobname, gboolean export_pdf ); 00207 00213 void gnc_html_cancel( GncHtml* html ); 00214 00223 URLType gnc_html_parse_url( GncHtml* html, const gchar* url, 00224 gchar** url_location, gchar** url_label ); 00225 00232 gnc_html_history* gnc_html_get_history( GncHtml* html ); 00233 00240 GtkWidget* gnc_html_get_widget( GncHtml* html ); 00241 00248 void gnc_html_set_parent( GncHtml* html, GtkWindow* parent ); 00249 00250 /* setting callbacks */ 00251 void gnc_html_set_urltype_cb( GncHtml* html, GncHTMLUrltypeCB urltype_cb ); 00252 void gnc_html_set_load_cb( GncHtml* html, GncHTMLLoadCB load_cb, gpointer data ); 00253 void gnc_html_set_flyover_cb( GncHtml* html, GncHTMLFlyoverCB newwin_cb, gpointer data ); 00254 void gnc_html_set_button_cb( GncHtml* html, GncHTMLButtonCB button_cb, gpointer data ); 00255 00256 /* object handlers deal with <object classid="foo"> objects in HTML. 00257 * the handlers are looked up at object load time. */ 00258 void gnc_html_register_object_handler( const gchar* classid, GncHTMLObjectCB hand ); 00259 void gnc_html_unregister_object_handler( const gchar* classid ); 00260 00261 /* stream handlers load data for particular URLTypes. */ 00262 void gnc_html_register_stream_handler( URLType url_type, GncHTMLStreamCB hand ); 00263 void gnc_html_unregister_stream_handler( URLType url_type ); 00264 00265 /* handlers for particular URLTypes. */ 00266 void gnc_html_register_url_handler( URLType url_type, GncHTMLUrlCB hand ); 00267 void gnc_html_unregister_url_handler( URLType url_type ); 00268 00269 const gchar* gnc_html_get_embedded_param( gpointer eb, const gchar* param_name ); 00270 00271 #endif
1.7.4