GnuCash  5.6-150-g038405b370+
gnc-html.h
1 /********************************************************************
2  * gnc-html.h -- display html with gnc special tags *
3  * Copyright (C) 2000 Bill Gribble <grib@billgribble.com> *
4  * *
5  * This program is free software; you can redistribute it and/or *
6  * modify it under the terms of the GNU General Public License as *
7  * published by the Free Software Foundation; either version 2 of *
8  * the License, or (at your option) any later version. *
9  * *
10  * This program is distributed in the hope that it will be useful, *
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13  * GNU General Public License for more details. *
14  * *
15  * You should have received a copy of the GNU General Public License*
16  * along with this program; if not, contact: *
17  * *
18  * Free Software Foundation Voice: +1-617-542-5942 *
19  * 51 Franklin Street, Fifth Floor Fax: +1-617-542-2652 *
20  * Boston, MA 02110-1301, USA gnu@gnu.org *
21 \********************************************************************/
22 
23 #ifndef GNC_HTML_H
24 #define GNC_HTML_H
25 
32 #include <glib-object.h>
33 
34 G_BEGIN_DECLS
35 
36 #define GNC_TYPE_HTML (gnc_html_get_type())
37 #define GNC_HTML(o) (G_TYPE_CHECK_INSTANCE_CAST ((o), GNC_TYPE_HTML, GncHtml))
38 #define GNC_HTML_CLASS(k) (G_TYPE_CHECK_CLASS_CAST((k), GNC_TYPE_HTML, GncHtmlClass))
39 #define GNC_IS_HTML(o) (G_TYPE_CHECK_INSTANCE_TYPE((o), GNC_TYPE_HTML))
40 #define GNC_IS_HTML_CLASS(k) (G_TYPE_CHECK_CLASS_TYPE((o), GNC_TYPE_HTML))
41 #define GNC_HTML_GET_CLASS(o) (G_TYPE_INSTANCE_GET_CLASS((o), GNC_TYPE_HTML, GncHtmlClass))
42 
43 GType gnc_html_get_type(void);
44 
45 typedef struct _GncHtml GncHtml;
46 typedef struct _GncHtmlClass GncHtmlClass;
47 typedef struct _GncHtmlPrivate GncHtmlPrivate;
48 
49 #include "gnc-html-extras.h"
50 
51 /* The result structure of url handlers. Strings should be g_malloc'd
52  * by the handler and will be freed by gnc_html. */
53 typedef struct
54 {
55  /* The following members are used if the handler succeeds (returns TRUE). */
56 
57  gboolean load_to_stream; /* If TRUE, the url should be loaded from
58  * a stream using the rest of the data in
59  * the struct into the original gnc_html
60  * object. If FALSE, the handler will
61  * perform all needed actions itself. */
62 
63  URLType url_type; /* Defaults to original */
64  gchar* location; /* If NULL, use original (NULL is default) */
65  gchar* label; /* If NULL, use original (NULL is default) */
66 
67  URLType base_type;
68  gchar* base_location;
69 
70  /* The window that triggered this URL request */
71  GtkWindow *parent;
72 
73  /* The following members are used if the handler fails (returns FALSE). */
74  gchar* error_message;
75 } GNCURLResult;
76 
77 typedef gboolean (* GncHTMLObjectCB)(GncHtml* html, gpointer eb,
78  gpointer data);
79 typedef gboolean (* GncHTMLStreamCB)(const gchar* location, gchar** data, int* datalen);
80 typedef gboolean (* GncHTMLUrlCB)(const gchar* location, const gchar* label,
81  gboolean new_window, GNCURLResult* result);
82 
91 gboolean gnc_html_register_urltype( URLType type, const gchar* protocol );
92 
96 void gnc_html_initialize( void );
97 
98 gchar* gnc_html_encode_string( const gchar* in );
99 gchar* gnc_html_decode_string( const gchar* in );
100 gchar* gnc_html_escape_newlines( const gchar* in );
101 gchar* gnc_html_unescape_newlines( const gchar* in );
102 
103 /* object handlers deal with <object classid="foo"> objects in HTML.
104  * the handlers are looked up at object load time. */
105 void gnc_html_register_object_handler( const gchar* classid, GncHTMLObjectCB hand );
106 void gnc_html_unregister_object_handler( const gchar* classid );
107 
108 /* stream handlers load data for particular URLTypes. */
109 void gnc_html_register_stream_handler( URLType url_type, GncHTMLStreamCB hand );
110 void gnc_html_unregister_stream_handler( URLType url_type );
111 
112 /* handlers for particular URLTypes. */
113 void gnc_html_register_url_handler( URLType url_type, GncHTMLUrlCB hand );
114 void gnc_html_unregister_url_handler( URLType url_type );
115 
116 #include "gnc-html-history.h"
117 
118 typedef int (* GncHTMLUrltypeCB)(URLType ut);
119 typedef void (* GncHTMLFlyoverCB)(GncHtml* html, const gchar* url,
120  gpointer data);
121 typedef void (* GncHTMLLoadCB)(GncHtml* html, URLType type,
122  const gchar* location, const gchar* label,
123  gpointer data);
124 typedef int (* GncHTMLButtonCB)(GncHtml* html, GdkEventButton* event,
125  gpointer data);
126 
128 {
129  GtkBinClass parent_class;
130 
131  /* Methods */
132  void (*show_url)( GncHtml* html,
133  URLType type,
134  const gchar* location,
135  const gchar* label,
136  gboolean new_window_hint );
137  void (*show_data)( GncHtml* html, const gchar* data, int datalen );
138  void (*reload)( GncHtml* html, gboolean force_rebuild );
139  void (*copy_to_clipboard)( GncHtml* html );
140  gboolean (*export_to_file)( GncHtml* html, const gchar* file );
141 #ifdef WEBKIT1
142  void (*print) (GncHtml* html, const gchar* jobname, gboolean export_pdf);
143 #else
144  void (*print) (GncHtml* html, const gchar* jobname);
145 #endif
146  void (*cancel)( GncHtml* html );
147  URLType (*parse_url)( GncHtml* html, const gchar* url,
148  gchar** url_location, gchar** url_label );
149  void (*set_parent)( GncHtml* html, GtkWindow* parent );
150 };
151 
152 struct _GncHtml
153 {
154  GtkBin parent_instance;
155 
156  /*< private >*/
157  GncHtmlPrivate* priv;
158 };
159 
165 void gnc_html_destroy( GncHtml* html );
166 
172 void gnc_html_show_url( GncHtml* html, URLType type, const gchar* location,
173  const gchar* label, gboolean new_window_hint );
174 
180 void gnc_html_show_data( GncHtml* html, const gchar* data, int datalen );
181 
188 void gnc_html_reload( GncHtml* html, gboolean view );
189 
195 void gnc_html_copy_to_clipboard( GncHtml* html );
196 
204 gboolean gnc_html_export_to_file( GncHtml* html, const gchar* filename );
205 
206 #ifdef WEBKIT1
207 
216 void gnc_html_print (GncHtml* html, const char* jobname, gboolean export_pdf);
217 #else
218 
223 void gnc_html_print (GncHtml* html, const char* jobname);
224 #endif
225 
230 void gnc_html_cancel( GncHtml* html );
231 
240 URLType gnc_html_parse_url( GncHtml* html, const gchar* url,
241  gchar** url_location, gchar** url_label );
242 
249 gnc_html_history* gnc_html_get_history( GncHtml* html );
250 
257 GtkWidget* gnc_html_get_widget( GncHtml* html );
258 
265 GtkWidget* gnc_html_get_webview( GncHtml* html );
266 
267 
274 void gnc_html_set_parent( GncHtml* html, GtkWindow* parent );
275 
276 /* setting callbacks */
277 void gnc_html_set_urltype_cb( GncHtml* html, GncHTMLUrltypeCB urltype_cb );
278 void gnc_html_set_load_cb( GncHtml* html, GncHTMLLoadCB load_cb, gpointer data );
279 void gnc_html_set_flyover_cb( GncHtml* html, GncHTMLFlyoverCB newwin_cb, gpointer data );
280 void gnc_html_set_button_cb( GncHtml* html, GncHTMLButtonCB button_cb, gpointer data );
281 
282 /* object handlers deal with <object classid="foo"> objects in HTML.
283  * the handlers are looked up at object load time. */
284 void gnc_html_register_object_handler( const gchar* classid, GncHTMLObjectCB hand );
285 void gnc_html_unregister_object_handler( const gchar* classid );
286 
287 /* stream handlers load data for particular URLTypes. */
288 void gnc_html_register_stream_handler( URLType url_type, GncHTMLStreamCB hand );
289 void gnc_html_unregister_stream_handler( URLType url_type );
290 
291 /* handlers for particular URLTypes. */
292 void gnc_html_register_url_handler( URLType url_type, GncHTMLUrlCB hand );
293 void gnc_html_unregister_url_handler( URLType url_type );
294 
295 const gchar* gnc_html_get_embedded_param( gpointer eb, const gchar* param_name );
296 
297 G_END_DECLS
298 #endif