1 | /* -*- Mode: C; tab-width: 8; indent-tabs-mode: t; c-basic-offset: 8 -*- */ |
---|
2 | /* This file is part of the GtkHTML library. |
---|
3 | |
---|
4 | Copyright 1999, 2000 Helix Code, Inc. |
---|
5 | |
---|
6 | This library is free software; you can redistribute it and/or |
---|
7 | modify it under the terms of the GNU Library General Public |
---|
8 | License as published by the Free Software Foundation; either |
---|
9 | version 2 of the License, or (at your option) any later version. |
---|
10 | |
---|
11 | This library is distributed in the hope that it will be useful, |
---|
12 | but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
13 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
---|
14 | Library General Public License for more details. |
---|
15 | |
---|
16 | You should have received a copy of the GNU Library General Public License |
---|
17 | along with this library; see the file COPYING.LIB. If not, write to |
---|
18 | the Free Software Foundation, Inc., 59 Temple Place - Suite 330, |
---|
19 | Boston, MA 02111-1307, USA. |
---|
20 | */ |
---|
21 | |
---|
22 | #ifndef _GTKHTML_H_ |
---|
23 | #define _GTKHTML_H_ |
---|
24 | |
---|
25 | #include <sys/types.h> |
---|
26 | #include <gtk/gtklayout.h> |
---|
27 | #include <gtk/gtkbindings.h> |
---|
28 | #include <libgnomeprint/gnome-print.h> |
---|
29 | #include <libgnomeprint/gnome-print-job.h> |
---|
30 | |
---|
31 | #include "gtkhtml-types.h" |
---|
32 | #include "gtkhtml-enums.h" |
---|
33 | |
---|
34 | /* FIXME we should remove html dep */ |
---|
35 | #include "htmltypes.h" |
---|
36 | |
---|
37 | #define GTK_TYPE_HTML (gtk_html_get_type ()) |
---|
38 | #define GTK_HTML(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GTK_TYPE_HTML, GtkHTML)) |
---|
39 | #define GTK_HTML_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GTK_TYPE_HTML, GtkHTMLClass)) |
---|
40 | #define GTK_IS_HTML(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GTK_TYPE_HTML)) |
---|
41 | #define GTK_IS_HTML_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GTK_TYPE_HTML)) |
---|
42 | |
---|
43 | struct _GtkHTML { |
---|
44 | GtkLayout layout; |
---|
45 | |
---|
46 | GtkWidget *iframe_parent; |
---|
47 | HTMLObject *frame; |
---|
48 | GtkHTMLEditorAPI *editor_api; |
---|
49 | gpointer editor_data; |
---|
50 | HTMLEngine *engine; |
---|
51 | |
---|
52 | /* The URL of the link over which the pointer currently is. NULL if |
---|
53 | the pointer is not over a link. */ |
---|
54 | gchar *pointer_url; |
---|
55 | |
---|
56 | /* The cursors we use within the widget. */ |
---|
57 | GdkCursor *hand_cursor; |
---|
58 | GdkCursor *ibeam_cursor; |
---|
59 | |
---|
60 | gint selection_x1, selection_y1; |
---|
61 | |
---|
62 | guint in_selection : 1; |
---|
63 | guint in_selection_drag : 1; |
---|
64 | |
---|
65 | guint debug : 1; |
---|
66 | guint allow_selection : 1; |
---|
67 | |
---|
68 | guint hadj_connection; |
---|
69 | guint vadj_connection; |
---|
70 | |
---|
71 | gboolean binding_handled; |
---|
72 | GtkHTMLPrivate *priv; |
---|
73 | }; |
---|
74 | |
---|
75 | struct _GtkHTMLClass { |
---|
76 | GtkLayoutClass parent_class; |
---|
77 | |
---|
78 | void (* title_changed) (GtkHTML *html, const gchar *new_title); |
---|
79 | void (* url_requested) (GtkHTML *html, const gchar *url, GtkHTMLStream *handle); |
---|
80 | void (* load_done) (GtkHTML *html); |
---|
81 | void (* link_clicked) (GtkHTML *html, const gchar *url); |
---|
82 | void (* set_base) (GtkHTML *html, const gchar *base_url); |
---|
83 | void (* set_base_target) (GtkHTML *html, const gchar *base_url); |
---|
84 | |
---|
85 | void (* on_url) (GtkHTML *html, const gchar *url); |
---|
86 | void (* redirect) (GtkHTML *html, const gchar *url, int delay); |
---|
87 | void (* submit) (GtkHTML *html, const gchar *method, const gchar *url, const gchar *encoding); |
---|
88 | gboolean (* object_requested)(GtkHTML *html, GtkHTMLEmbedded *); |
---|
89 | |
---|
90 | void (* current_paragraph_style_changed) (GtkHTML *html, GtkHTMLParagraphStyle new_style); |
---|
91 | void (* current_paragraph_alignment_changed) (GtkHTML *html, GtkHTMLParagraphAlignment new_alignment); |
---|
92 | void (* current_paragraph_indentation_changed) (GtkHTML *html, guint new_indentation); |
---|
93 | void (* insertion_font_style_changed) (GtkHTML *html, GtkHTMLFontStyle style); |
---|
94 | void (* insertion_color_changed) (GtkHTML *html, GdkColor *color); |
---|
95 | |
---|
96 | void (* size_changed) (GtkHTML *html); |
---|
97 | void (* iframe_created) (GtkHTML *html, GtkHTML *iframe); |
---|
98 | |
---|
99 | /* keybindings signals */ |
---|
100 | void (* scroll) (GtkHTML *html, GtkOrientation orientation, GtkScrollType scroll_type, |
---|
101 | gfloat position); |
---|
102 | void (* cursor_move) (GtkHTML *html, GtkDirectionType dir_type, GtkHTMLCursorSkipType skip); |
---|
103 | gboolean (* command) (GtkHTML *html, GtkHTMLCommandType com_type); |
---|
104 | |
---|
105 | /* properties */ |
---|
106 | GtkHTMLClassProperties *properties; |
---|
107 | GtkBindingSet *emacs_bindings; |
---|
108 | gboolean use_emacs_bindings; |
---|
109 | }; |
---|
110 | |
---|
111 | struct _GtkHTMLEditorAPI |
---|
112 | { |
---|
113 | /* spell checking methods */ |
---|
114 | gboolean (* check_word) (GtkHTML *html, const gchar *word, gpointer data); |
---|
115 | void (* suggestion_request) (GtkHTML *html, gpointer data); |
---|
116 | void (* add_to_session) (GtkHTML *html, const gchar *word, gpointer data); |
---|
117 | void (* add_to_personal) (GtkHTML *html, const gchar *word, const gchar *language, gpointer data); |
---|
118 | |
---|
119 | /* unhandled commands */ |
---|
120 | gboolean (* command) (GtkHTML *html, GtkHTMLCommandType com_type, gpointer data); |
---|
121 | |
---|
122 | GValue * (* event) (GtkHTML *html, GtkHTMLEditorEventType event_type, GValue *args, gpointer data); |
---|
123 | |
---|
124 | /* input line */ |
---|
125 | GtkWidget * (* create_input_line) (GtkHTML *html, gpointer data); |
---|
126 | |
---|
127 | /* spell checking methods */ |
---|
128 | void (* set_language) (GtkHTML *html, const gchar *language, gpointer data); |
---|
129 | }; |
---|
130 | |
---|
131 | /* Creation. */ |
---|
132 | GtkType gtk_html_get_type (void); |
---|
133 | void gtk_html_construct (GtkHTML *html); |
---|
134 | GtkWidget *gtk_html_new (void); |
---|
135 | void gtk_html_set_editor_api (GtkHTML *html, |
---|
136 | GtkHTMLEditorAPI *api, |
---|
137 | gpointer data); |
---|
138 | |
---|
139 | /* parent iframe setting */ |
---|
140 | gint gtk_html_set_iframe_parent (GtkHTML *html, |
---|
141 | GtkWidget *parent, |
---|
142 | HTMLObject *frame); |
---|
143 | GtkHTML *gtk_html_get_top_html (GtkHTML *html); |
---|
144 | |
---|
145 | /* Debugging. */ |
---|
146 | void gtk_html_enable_debug (GtkHTML *html, |
---|
147 | gboolean debug); |
---|
148 | |
---|
149 | /* Behavior. */ |
---|
150 | void gtk_html_allow_selection (GtkHTML *html, |
---|
151 | gboolean allow); |
---|
152 | void gtk_html_select_word (GtkHTML *html); |
---|
153 | void gtk_html_select_line (GtkHTML *html); |
---|
154 | void gtk_html_select_paragraph (GtkHTML *html); |
---|
155 | void gtk_html_select_paragraph_extended (GtkHTML *html); |
---|
156 | void gtk_html_select_all (GtkHTML *html); |
---|
157 | int gtk_html_request_paste (GtkHTML *html, |
---|
158 | GdkAtom selection, |
---|
159 | gint type, |
---|
160 | gint32 time, |
---|
161 | gboolean as_cite); |
---|
162 | /* Loading. */ |
---|
163 | GtkHTMLStream *gtk_html_begin (GtkHTML *html); |
---|
164 | GtkHTMLStream *gtk_html_begin_full (GtkHTML *html, |
---|
165 | char *target_frame, |
---|
166 | char *content_type, |
---|
167 | GtkHTMLBeginFlags flags); |
---|
168 | |
---|
169 | void gtk_html_write (GtkHTML *html, |
---|
170 | GtkHTMLStream *handle, |
---|
171 | const gchar *buffer, |
---|
172 | size_t size); |
---|
173 | void gtk_html_end (GtkHTML *html, |
---|
174 | GtkHTMLStream *handle, |
---|
175 | GtkHTMLStreamStatus status); |
---|
176 | void gtk_html_flush (GtkHTML *html); |
---|
177 | void gtk_html_stop (GtkHTML *html); |
---|
178 | void gtk_html_load_from_string (GtkHTML *html, |
---|
179 | const gchar *str, |
---|
180 | gint len); |
---|
181 | |
---|
182 | /* Saving. */ |
---|
183 | gboolean gtk_html_export (GtkHTML *html, |
---|
184 | const char *type, |
---|
185 | GtkHTMLSaveReceiverFn receiver, |
---|
186 | gpointer data); |
---|
187 | |
---|
188 | /* Editable support. */ |
---|
189 | void gtk_html_set_editable (GtkHTML *html, |
---|
190 | gboolean editable); |
---|
191 | gboolean gtk_html_get_editable (const GtkHTML *html); |
---|
192 | void gtk_html_set_inline_spelling (GtkHTML *html, |
---|
193 | gboolean inline_spell); |
---|
194 | gboolean gtk_html_get_inline_spelling (const GtkHTML *html); |
---|
195 | void gtk_html_set_magic_links (GtkHTML *html, |
---|
196 | gboolean magic_links); |
---|
197 | gboolean gtk_html_get_magic_links (const GtkHTML *html); |
---|
198 | void gtk_html_set_magic_smileys (GtkHTML *html, |
---|
199 | gboolean magic_smileys); |
---|
200 | gboolean gtk_html_get_magic_smileys (const GtkHTML *html); |
---|
201 | |
---|
202 | /* Caret Mode */ |
---|
203 | void gtk_html_set_caret_mode (GtkHTML *html, |
---|
204 | gboolean caret_mode); |
---|
205 | gboolean gtk_html_get_caret_mode (const GtkHTML *html); |
---|
206 | |
---|
207 | /* Animated Images */ |
---|
208 | void gtk_html_set_animate (GtkHTML *html, |
---|
209 | gboolean animate); |
---|
210 | gboolean gtk_html_get_animate (const GtkHTML *html); |
---|
211 | |
---|
212 | /* Printing support. */ |
---|
213 | void gtk_html_print_with_header_footer (GtkHTML *html, |
---|
214 | GnomePrintContext *print_context, |
---|
215 | gdouble header_height, |
---|
216 | gdouble footer_height, |
---|
217 | GtkHTMLPrintCallback header_print, |
---|
218 | GtkHTMLPrintCallback footer_print, |
---|
219 | gpointer user_data); |
---|
220 | void gtk_html_print (GtkHTML *html, |
---|
221 | GnomePrintContext *print_context); |
---|
222 | gint gtk_html_print_get_pages_num (GtkHTML *html, |
---|
223 | GnomePrintContext *print_context, |
---|
224 | gdouble header_height, |
---|
225 | gdouble footer_height); |
---|
226 | void gtk_html_print_set_master (GtkHTML *html, |
---|
227 | GnomePrintJob *print_master); |
---|
228 | |
---|
229 | /* Title. */ |
---|
230 | const gchar *gtk_html_get_title (GtkHTML *html); |
---|
231 | void gtk_html_set_title (GtkHTML *html, const char *title); |
---|
232 | |
---|
233 | /* Anchors. */ |
---|
234 | gboolean gtk_html_jump_to_anchor (GtkHTML *html, |
---|
235 | const gchar *anchor); |
---|
236 | |
---|
237 | |
---|
238 | /* Editing functions. */ |
---|
239 | GtkHTMLParagraphStyle gtk_html_get_paragraph_style (GtkHTML *html); |
---|
240 | void gtk_html_set_paragraph_style (GtkHTML *html, |
---|
241 | GtkHTMLParagraphStyle style); |
---|
242 | void gtk_html_set_indent (GtkHTML *html, |
---|
243 | GByteArray *levels); |
---|
244 | void gtk_html_indent_push_level (GtkHTML *html, |
---|
245 | HTMLListType level_type); |
---|
246 | void gtk_html_indent_pop_level (GtkHTML *html); |
---|
247 | guint gtk_html_get_paragraph_indentation (GtkHTML *html); |
---|
248 | void gtk_html_set_font_style (GtkHTML *html, |
---|
249 | GtkHTMLFontStyle and_mask, |
---|
250 | GtkHTMLFontStyle or_mask); |
---|
251 | void gtk_html_set_color (GtkHTML *html, |
---|
252 | HTMLColor *color); |
---|
253 | void gtk_html_toggle_font_style (GtkHTML *html, |
---|
254 | GtkHTMLFontStyle style); |
---|
255 | GtkHTMLParagraphAlignment gtk_html_get_paragraph_alignment (GtkHTML *html); |
---|
256 | void gtk_html_set_paragraph_alignment (GtkHTML *html, |
---|
257 | GtkHTMLParagraphAlignment alignment); |
---|
258 | void gtk_html_cut (GtkHTML *html); |
---|
259 | void gtk_html_copy (GtkHTML *html); |
---|
260 | void gtk_html_paste (GtkHTML *html, |
---|
261 | gboolean as_cite); |
---|
262 | void gtk_html_undo (GtkHTML *html); |
---|
263 | void gtk_html_redo (GtkHTML *html); |
---|
264 | void gtk_html_insert_html (GtkHTML *html, |
---|
265 | const gchar *html_src); |
---|
266 | void gtk_html_insert_gtk_html (GtkHTML *html, |
---|
267 | GtkHTML *to_be_destroyed); |
---|
268 | void gtk_html_append_html (GtkHTML *html, |
---|
269 | const gchar *html_src); |
---|
270 | |
---|
271 | /* misc utils */ |
---|
272 | gpointer gtk_html_get_object_by_id (GtkHTML *html, |
---|
273 | const gchar *id); |
---|
274 | gboolean gtk_html_command (GtkHTML *html, |
---|
275 | const gchar *command_name); |
---|
276 | gboolean gtk_html_edit_make_cursor_visible (GtkHTML *html); |
---|
277 | |
---|
278 | void gtk_html_set_magnification (GtkHTML *html, |
---|
279 | gdouble magnification); |
---|
280 | void gtk_html_zoom_in (GtkHTML *html); |
---|
281 | void gtk_html_zoom_out (GtkHTML *html); |
---|
282 | void gtk_html_zoom_reset (GtkHTML *html); |
---|
283 | void gtk_html_update_styles (GtkHTML *html); |
---|
284 | void gtk_html_set_allow_frameset (GtkHTML *html, |
---|
285 | gboolean allow); |
---|
286 | gboolean gtk_html_get_allow_frameset (GtkHTML *html); |
---|
287 | void gtk_html_set_base (GtkHTML *html, |
---|
288 | const char *url); |
---|
289 | const char *gtk_html_get_base (GtkHTML *html); |
---|
290 | char *gtk_html_get_url_base_relative (GtkHTML *html, |
---|
291 | const char *url); |
---|
292 | char *gtk_html_get_url_object_relative (GtkHTML *html, |
---|
293 | HTMLObject *o, |
---|
294 | const char *url); |
---|
295 | void gtk_html_images_ref (GtkHTML *html); |
---|
296 | void gtk_html_images_unref (GtkHTML *html); |
---|
297 | void gtk_html_image_ref (GtkHTML *html, |
---|
298 | const gchar *url); |
---|
299 | void gtk_html_image_unref (GtkHTML *html, |
---|
300 | const gchar *url); |
---|
301 | void gtk_html_image_preload (GtkHTML *html, |
---|
302 | const gchar *url); |
---|
303 | void gtk_html_set_blocking (GtkHTML *html, |
---|
304 | gboolean block); |
---|
305 | void gtk_html_set_images_blocking (GtkHTML *html, |
---|
306 | gboolean block); |
---|
307 | gboolean gtk_html_has_undo (GtkHTML *html); |
---|
308 | void gtk_html_drop_undo (GtkHTML *html); |
---|
309 | |
---|
310 | /* DEPRECATED */ |
---|
311 | #if 1 |
---|
312 | gboolean gtk_html_build_with_gconf (void); |
---|
313 | void gtk_html_set_default_content_type (GtkHTML *html, |
---|
314 | gchar *content_type); |
---|
315 | GtkWidget *gtk_html_new_from_string (const gchar *Astr, |
---|
316 | gint len); |
---|
317 | void gtk_html_load_empty (GtkHTML *html); |
---|
318 | gboolean gtk_html_save (GtkHTML *html, |
---|
319 | GtkHTMLSaveReceiverFn receiver, |
---|
320 | gpointer data); |
---|
321 | GtkHTMLStream *gtk_html_begin_content (GtkHTML *html, |
---|
322 | gchar *content_type); |
---|
323 | void gtk_html_drag_dest_set (GtkHTML *html); |
---|
324 | #endif |
---|
325 | |
---|
326 | #endif /* _GTKHTML_H_ */ |
---|