GnuCash  2.6.99
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
gnc-html.h
1 /********************************************************************
2  * gnc-html.h -- display html with gnc special tags *
3  * Copyright (C) 2000 Bill Gribble <[email protected]> *
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 [email protected] *
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 following members are used if the handler fails (returns FALSE). */
71  gchar* error_message;
72 } GNCURLResult;
73 
74 typedef gboolean (* GncHTMLObjectCB)(GncHtml* html, gpointer eb,
75  gpointer data);
76 typedef gboolean (* GncHTMLStreamCB)(const gchar* location, gchar** data, int* datalen);
77 typedef gboolean (* GncHTMLUrlCB)(const gchar* location, const gchar* label,
78  gboolean new_window, GNCURLResult* result);
79 
88 gboolean gnc_html_register_urltype( URLType type, const gchar* protocol );
89 
93 void gnc_html_initialize( void );
94 
95 gchar* gnc_html_encode_string( const gchar* in );
96 gchar* gnc_html_decode_string( const gchar* in );
97 gchar* gnc_html_escape_newlines( const gchar* in );
98 gchar* gnc_html_unescape_newlines( const gchar* in );
99 
100 /* object handlers deal with <object classid="foo"> objects in HTML.
101  * the handlers are looked up at object load time. */
102 void gnc_html_register_object_handler( const gchar* classid, GncHTMLObjectCB hand );
103 void gnc_html_unregister_object_handler( const gchar* classid );
104 
105 /* stream handlers load data for particular URLTypes. */
106 void gnc_html_register_stream_handler( URLType url_type, GncHTMLStreamCB hand );
107 void gnc_html_unregister_stream_handler( URLType url_type );
108 
109 /* handlers for particular URLTypes. */
110 void gnc_html_register_url_handler( URLType url_type, GncHTMLUrlCB hand );
111 void gnc_html_unregister_url_handler( URLType url_type );
112 
113 #include "gnc-html-history.h"
114 
115 typedef int (* GncHTMLUrltypeCB)(URLType ut);
116 typedef void (* GncHTMLFlyoverCB)(GncHtml* html, const gchar* url,
117  gpointer data);
118 typedef void (* GncHTMLLoadCB)(GncHtml* html, URLType type,
119  const gchar* location, const gchar* label,
120  gpointer data);
121 typedef int (* GncHTMLButtonCB)(GncHtml* html, GdkEventButton* event,
122  gpointer data);
123 
125 {
126  GtkBinClass parent_class;
127 
128  /* Methods */
129  void (*show_url)( GncHtml* html,
130  URLType type,
131  const gchar* location,
132  const gchar* label,
133  gboolean new_window_hint );
134  void (*show_data)( GncHtml* html, const gchar* data, int datalen );
135  void (*reload)( GncHtml* html );
136  void (*copy_to_clipboard)( GncHtml* html );
137  gboolean (*export_to_file)( GncHtml* html, const gchar* file );
138  void (*print)( GncHtml* html, const gchar* jobname, gboolean export_pdf );
139  void (*cancel)( GncHtml* html );
140  URLType (*parse_url)( GncHtml* html, const gchar* url,
141  gchar** url_location, gchar** url_label );
142  void (*set_parent)( GncHtml* html, GtkWindow* parent );
143 };
144 
145 struct _GncHtml
146 {
147  GtkBin parent_instance;
148 
149  /*< private >*/
150  GncHtmlPrivate* priv;
151 };
152 
158 void gnc_html_destroy( GncHtml* html );
159 
165 void gnc_html_show_url( GncHtml* html, URLType type, const gchar* location,
166  const gchar* label, gboolean new_window_hint );
167 
173 void gnc_html_show_data( GncHtml* html, const gchar* data, int datalen );
174 
180 void gnc_html_reload( GncHtml* html );
181 
187 void gnc_html_copy_to_clipboard( GncHtml* html );
188 
196 gboolean gnc_html_export_to_file( GncHtml* html, const gchar* filename );
197 
206 void gnc_html_print( GncHtml* html, const gchar* jobname, gboolean export_pdf );
207 
213 void gnc_html_cancel( GncHtml* html );
214 
223 URLType gnc_html_parse_url( GncHtml* html, const gchar* url,
224  gchar** url_location, gchar** url_label );
225 
232 gnc_html_history* gnc_html_get_history( GncHtml* html );
233 
240 GtkWidget* gnc_html_get_widget( GncHtml* html );
241 
248 void gnc_html_set_parent( GncHtml* html, GtkWindow* parent );
249 
250 /* setting callbacks */
251 void gnc_html_set_urltype_cb( GncHtml* html, GncHTMLUrltypeCB urltype_cb );
252 void gnc_html_set_load_cb( GncHtml* html, GncHTMLLoadCB load_cb, gpointer data );
253 void gnc_html_set_flyover_cb( GncHtml* html, GncHTMLFlyoverCB newwin_cb, gpointer data );
254 void gnc_html_set_button_cb( GncHtml* html, GncHTMLButtonCB button_cb, gpointer data );
255 
256 /* object handlers deal with <object classid="foo"> objects in HTML.
257  * the handlers are looked up at object load time. */
258 void gnc_html_register_object_handler( const gchar* classid, GncHTMLObjectCB hand );
259 void gnc_html_unregister_object_handler( const gchar* classid );
260 
261 /* stream handlers load data for particular URLTypes. */
262 void gnc_html_register_stream_handler( URLType url_type, GncHTMLStreamCB hand );
263 void gnc_html_unregister_stream_handler( URLType url_type );
264 
265 /* handlers for particular URLTypes. */
266 void gnc_html_register_url_handler( URLType url_type, GncHTMLUrlCB hand );
267 void gnc_html_unregister_url_handler( URLType url_type );
268 
269 const gchar* gnc_html_get_embedded_param( gpointer eb, const gchar* param_name );
270 
271 #endif