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/gtkbindings.h> |
---|
27 | #include <gtk/gtklayout.h> |
---|
28 | #include <libgnome/gnome-paper.h> |
---|
29 | #include <libgnomeprint/gnome-print.h> |
---|
30 | #include <libgnomeprint/gnome-print-master.h> |
---|
31 | |
---|
32 | #include "gtkhtml-types.h" |
---|
33 | #include "gtkhtml-enums.h" |
---|
34 | |
---|
35 | /* FIXME we should remove html dep */ |
---|
36 | #include "htmltypes.h" |
---|
37 | |
---|
38 | #define GTK_TYPE_HTML (gtk_html_get_type ()) |
---|
39 | #define GTK_HTML(obj) (GTK_CHECK_CAST ((obj), GTK_TYPE_HTML, GtkHTML)) |
---|
40 | #define GTK_HTML_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GTK_TYPE_HTML, GtkHTMLClass)) |
---|
41 | #define GTK_IS_HTML(obj) (GTK_CHECK_TYPE ((obj), GTK_TYPE_HTML)) |
---|
42 | #define GTK_IS_HTML_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GTK_TYPE_HTML)) |
---|
43 | |
---|
44 | struct _GtkHTML { |
---|
45 | GtkLayout layout; |
---|
46 | |
---|
47 | GtkBindingSet *editor_bindings; |
---|
48 | GtkWidget *iframe_parent; |
---|
49 | HTMLObject *frame; |
---|
50 | GtkHTMLEditorAPI *editor_api; |
---|
51 | gpointer editor_data; |
---|
52 | HTMLEngine *engine; |
---|
53 | |
---|
54 | /* The URL of the link over which the pointer currently is. NULL if |
---|
55 | the pointer is not over a link. */ |
---|
56 | gchar *pointer_url; |
---|
57 | |
---|
58 | /* The cursors we use within the widget. */ |
---|
59 | GdkCursor *hand_cursor; |
---|
60 | GdkCursor *arrow_cursor; |
---|
61 | GdkCursor *ibeam_cursor; |
---|
62 | |
---|
63 | gint selection_x1, selection_y1; |
---|
64 | |
---|
65 | guint in_selection : 1; |
---|
66 | guint in_selection_drag : 1; |
---|
67 | |
---|
68 | guint debug : 1; |
---|
69 | guint allow_selection : 1; |
---|
70 | |
---|
71 | guint hadj_connection; |
---|
72 | guint vadj_connection; |
---|
73 | |
---|
74 | gboolean binding_handled; |
---|
75 | GtkHTMLPrivate *priv; |
---|
76 | }; |
---|
77 | |
---|
78 | struct _GtkHTMLClass { |
---|
79 | GtkLayoutClass parent_class; |
---|
80 | |
---|
81 | void (* title_changed) (GtkHTML *html, const gchar *new_title); |
---|
82 | void (* url_requested) (GtkHTML *html, const gchar *url, GtkHTMLStream *handle); |
---|
83 | void (* load_done) (GtkHTML *html); |
---|
84 | void (* link_clicked) (GtkHTML *html, const gchar *url); |
---|
85 | void (* set_base) (GtkHTML *html, const gchar *base_url); |
---|
86 | void (* set_base_target) (GtkHTML *html, const gchar *base_url); |
---|
87 | |
---|
88 | void (* on_url) (GtkHTML *html, const gchar *url); |
---|
89 | void (* redirect) (GtkHTML *html, const gchar *url, int delay); |
---|
90 | void (* submit) (GtkHTML *html, const gchar *method, const gchar *url, const gchar *encoding); |
---|
91 | gboolean (* object_requested)(GtkHTML *html, GtkHTMLEmbedded *); |
---|
92 | |
---|
93 | void (* current_paragraph_style_changed) (GtkHTML *html, GtkHTMLParagraphStyle new_style); |
---|
94 | void (* current_paragraph_alignment_changed) (GtkHTML *html, GtkHTMLParagraphAlignment new_alignment); |
---|
95 | void (* current_paragraph_indentation_changed) (GtkHTML *html, guint new_indentation); |
---|
96 | void (* insertion_font_style_changed) (GtkHTML *html, GtkHTMLFontStyle style); |
---|
97 | void (* insertion_color_changed) (GtkHTML *html, GdkColor *color); |
---|
98 | |
---|
99 | void (* size_changed) (GtkHTML *html); |
---|
100 | void (* iframe_created) (GtkHTML *html, GtkHTML *iframe); |
---|
101 | |
---|
102 | /* keybindings signals */ |
---|
103 | void (* scroll) (GtkHTML *html, GtkOrientation orientation, GtkScrollType scroll_type, |
---|
104 | gfloat position); |
---|
105 | void (* cursor_move) (GtkHTML *html, GtkDirectionType dir_type, GtkHTMLCursorSkipType skip); |
---|
106 | gboolean (* command) (GtkHTML *html, GtkHTMLCommandType com_type); |
---|
107 | |
---|
108 | /* properties */ |
---|
109 | GtkHTMLClassProperties *properties; |
---|
110 | }; |
---|
111 | |
---|
112 | struct _GtkHTMLEditorAPI |
---|
113 | { |
---|
114 | /* spell checking methods */ |
---|
115 | gboolean (* check_word) (GtkHTML *html, const gchar *word, gpointer data); |
---|
116 | void (* suggestion_request) (GtkHTML *html, const gchar *word, gpointer data); |
---|
117 | void (* add_to_session) (GtkHTML *html, const gchar *word, gpointer data); |
---|
118 | void (* add_to_personal) (GtkHTML *html, const gchar *word, gpointer data); |
---|
119 | |
---|
120 | /* unhandled commands */ |
---|
121 | gboolean (* command) (GtkHTML *html, GtkHTMLCommandType com_type, gpointer data); |
---|
122 | |
---|
123 | GtkArg * (* event) (GtkHTML *html, GtkHTMLEditorEventType event_type, GtkArg **args, gpointer data); |
---|
124 | |
---|
125 | /* input line */ |
---|
126 | GtkWidget * (* create_input_line) (GtkHTML *html, gpointer data); |
---|
127 | |
---|
128 | /* spell checking methods */ |
---|
129 | void (* set_language) (GtkHTML *html, const gchar *language, gpointer data); |
---|
130 | }; |
---|
131 | |
---|
132 | /* Creation. */ |
---|
133 | GtkType gtk_html_get_type (void); |
---|
134 | void gtk_html_construct (GtkWidget *html); |
---|
135 | GtkWidget *gtk_html_new (void); |
---|
136 | GtkWidget *gtk_html_new_from_string (const gchar *str, |
---|
137 | gint len); |
---|
138 | void gtk_html_set_editor_api (GtkHTML *html, |
---|
139 | GtkHTMLEditorAPI *api, |
---|
140 | gpointer data); |
---|
141 | |
---|
142 | /* parent iframe setting */ |
---|
143 | gint gtk_html_set_iframe_parent (GtkHTML *html, |
---|
144 | GtkWidget *parent, |
---|
145 | HTMLObject *frame); |
---|
146 | |
---|
147 | /* Debugging. */ |
---|
148 | void gtk_html_enable_debug (GtkHTML *html, |
---|
149 | gboolean debug); |
---|
150 | |
---|
151 | /* Behavior. */ |
---|
152 | void gtk_html_allow_selection (GtkHTML *html, |
---|
153 | gboolean allow); |
---|
154 | void gtk_html_select_word (GtkHTML *html); |
---|
155 | void gtk_html_select_line (GtkHTML *html); |
---|
156 | void gtk_html_select_paragraph (GtkHTML *html); |
---|
157 | void gtk_html_select_paragraph_extended (GtkHTML *html); |
---|
158 | void gtk_html_select_all (GtkHTML *html); |
---|
159 | int gtk_html_request_paste (GtkHTML *html, |
---|
160 | GdkAtom selection, |
---|
161 | gint type, |
---|
162 | gint32 time, |
---|
163 | gboolean as_cite); |
---|
164 | /* Loading. */ |
---|
165 | GtkHTMLStream *gtk_html_begin (GtkHTML *html); |
---|
166 | GtkHTMLStream *gtk_html_begin_content (GtkHTML *html, |
---|
167 | gchar *content_type); |
---|
168 | void gtk_html_write (GtkHTML *html, |
---|
169 | GtkHTMLStream *handle, |
---|
170 | const gchar *buffer, |
---|
171 | size_t size); |
---|
172 | void gtk_html_end (GtkHTML *html, |
---|
173 | GtkHTMLStream *handle, |
---|
174 | GtkHTMLStreamStatus status); |
---|
175 | void gtk_html_load_empty (GtkHTML *html); |
---|
176 | void gtk_html_load_from_string (GtkHTML *html, |
---|
177 | const gchar *str, |
---|
178 | gint len); |
---|
179 | |
---|
180 | /* Saving. */ |
---|
181 | gboolean gtk_html_save (GtkHTML *html, |
---|
182 | GtkHTMLSaveReceiverFn receiver, |
---|
183 | gpointer data); |
---|
184 | gboolean gtk_html_export (GtkHTML *html, |
---|
185 | const char *type, |
---|
186 | GtkHTMLSaveReceiverFn receiver, |
---|
187 | gpointer data); |
---|
188 | |
---|
189 | /* Editable support. */ |
---|
190 | void gtk_html_set_editable (GtkHTML *html, |
---|
191 | gboolean editable); |
---|
192 | gboolean gtk_html_get_editable (const GtkHTML *html); |
---|
193 | |
---|
194 | /* Printing support. */ |
---|
195 | void gtk_html_print_with_header_footer (GtkHTML *html, |
---|
196 | GnomePrintContext *print_context, |
---|
197 | gdouble header_height, |
---|
198 | gdouble footer_height, |
---|
199 | GtkHTMLPrintCallback header_print, |
---|
200 | GtkHTMLPrintCallback footer_print, |
---|
201 | gpointer user_data); |
---|
202 | void gtk_html_print (GtkHTML *html, |
---|
203 | GnomePrintContext *print_context); |
---|
204 | gint gtk_html_print_get_pages_num (GtkHTML *html, |
---|
205 | GnomePrintContext *print_context, |
---|
206 | gdouble header_height, |
---|
207 | gdouble footer_height); |
---|
208 | void gtk_html_print_set_master (GtkHTML *html, |
---|
209 | GnomePrintMaster *print_master); |
---|
210 | |
---|
211 | /* Title. */ |
---|
212 | const gchar *gtk_html_get_title (GtkHTML *html); |
---|
213 | void gtk_html_set_title (GtkHTML *html, const char *title); |
---|
214 | |
---|
215 | /* Anchors. */ |
---|
216 | gboolean gtk_html_jump_to_anchor (GtkHTML *html, |
---|
217 | const gchar *anchor); |
---|
218 | |
---|
219 | |
---|
220 | /* Editing functions. */ |
---|
221 | GtkHTMLParagraphStyle gtk_html_get_paragraph_style (GtkHTML *html); |
---|
222 | void gtk_html_set_paragraph_style (GtkHTML *html, |
---|
223 | GtkHTMLParagraphStyle style); |
---|
224 | void gtk_html_set_indent (GtkHTML *html, |
---|
225 | GByteArray *levels); |
---|
226 | void gtk_html_indent_push_level (GtkHTML *html, |
---|
227 | HTMLListType level_type); |
---|
228 | void gtk_html_indent_pop_level (GtkHTML *html); |
---|
229 | guint gtk_html_get_paragraph_indentation (GtkHTML *html); |
---|
230 | void gtk_html_set_font_style (GtkHTML *html, |
---|
231 | GtkHTMLFontStyle and_mask, |
---|
232 | GtkHTMLFontStyle or_mask); |
---|
233 | void gtk_html_set_color (GtkHTML *html, |
---|
234 | HTMLColor *color); |
---|
235 | void gtk_html_toggle_font_style (GtkHTML *html, |
---|
236 | GtkHTMLFontStyle style); |
---|
237 | GtkHTMLParagraphAlignment gtk_html_get_paragraph_alignment (GtkHTML *html); |
---|
238 | void gtk_html_set_paragraph_alignment (GtkHTML *html, |
---|
239 | GtkHTMLParagraphAlignment alignment); |
---|
240 | void gtk_html_cut (GtkHTML *html); |
---|
241 | void gtk_html_copy (GtkHTML *html); |
---|
242 | void gtk_html_paste (GtkHTML *html, |
---|
243 | gboolean as_cite); |
---|
244 | void gtk_html_undo (GtkHTML *html); |
---|
245 | void gtk_html_redo (GtkHTML *html); |
---|
246 | void gtk_html_insert_html (GtkHTML *html, |
---|
247 | const gchar *html_src); |
---|
248 | void gtk_html_insert_gtk_html (GtkHTML *html, |
---|
249 | GtkHTML *to_be_destroyed); |
---|
250 | void gtk_html_append_html (GtkHTML *html, |
---|
251 | const gchar *html_src); |
---|
252 | |
---|
253 | /* misc utils */ |
---|
254 | void gtk_html_set_default_background_color (GtkHTML *html, |
---|
255 | GdkColor *c); |
---|
256 | void gtk_html_set_default_content_type (GtkHTML *html, |
---|
257 | gchar *content_type); |
---|
258 | gpointer gtk_html_get_object_by_id (GtkHTML *html, |
---|
259 | const gchar *id); |
---|
260 | gboolean gtk_html_command (GtkHTML *html, |
---|
261 | const gchar *command_name); |
---|
262 | gboolean gtk_html_edit_make_cursor_visible (GtkHTML *html); |
---|
263 | gboolean gtk_html_build_with_gconf (void); |
---|
264 | void gtk_html_set_magnification (GtkHTML *html, |
---|
265 | gdouble magnification); |
---|
266 | void gtk_html_zoom_in (GtkHTML *html); |
---|
267 | void gtk_html_zoom_out (GtkHTML *html); |
---|
268 | void gtk_html_zoom_reset (GtkHTML *html); |
---|
269 | void gtk_html_update_styles (GtkHTML *html); |
---|
270 | void gtk_html_set_allow_frameset (GtkHTML *html, |
---|
271 | gboolean allow); |
---|
272 | gboolean gtk_html_get_allow_frameset (GtkHTML *html); |
---|
273 | void gtk_html_set_base (GtkHTML *html, |
---|
274 | const char *url); |
---|
275 | const char *gtk_html_get_base (GtkHTML *html); |
---|
276 | char *gtk_html_get_url_base_relative (GtkHTML *html, |
---|
277 | const char *url); |
---|
278 | char *gtk_html_get_url_object_relative (GtkHTML *html, |
---|
279 | HTMLObject *o, |
---|
280 | const char *url); |
---|
281 | void gtk_html_images_ref (GtkHTML *html); |
---|
282 | void gtk_html_images_unref (GtkHTML *html); |
---|
283 | void gtk_html_image_ref (GtkHTML *html, |
---|
284 | const gchar *url); |
---|
285 | void gtk_html_image_unref (GtkHTML *html, |
---|
286 | const gchar *url); |
---|
287 | void gtk_html_image_preload (GtkHTML *html, |
---|
288 | const gchar *url); |
---|
289 | void gtk_html_set_blocking (GtkHTML *html, |
---|
290 | gboolean block); |
---|
291 | gboolean gtk_html_has_undo (GtkHTML *html); |
---|
292 | void gtk_html_drop_undo (GtkHTML *html); |
---|
293 | #endif /* _GTKHTML_H_ */ |
---|