| |
1 /** |
| |
2 * @file gtkimhtml.h GTK+ IM/HTML rendering component |
| |
3 * @ingroup gtkui |
| |
4 * |
| |
5 * Pidgin is the legal property of its developers, whose names are too numerous |
| |
6 * to list here. Please refer to the COPYRIGHT file distributed with this |
| |
7 * source distribution. |
| |
8 * |
| |
9 * This program is free software; you can redistribute it and/or modify |
| |
10 * under the terms of the GNU General Public License as published by |
| |
11 * the Free Software Foundation; either version 2 of the License, or |
| |
12 * (at your option) any later version. |
| |
13 * |
| |
14 * This program is distributed in the hope that it will be useful, |
| |
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| |
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| |
17 * GNU General Public License for more details. |
| |
18 * |
| |
19 * You should have received a copy of the GNU General Public License |
| |
20 * along with this program; if not, write to the Free Software |
| |
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| |
22 */ |
| |
23 #ifndef _PIDGINIMHTML_H_ |
| |
24 #define _PIDGINIMHTML_H_ |
| |
25 |
| |
26 #include <gdk/gdk.h> |
| |
27 #include <gtk/gtktextview.h> |
| |
28 #include <gtk/gtktooltips.h> |
| |
29 #include <gtk/gtkimage.h> |
| |
30 |
| |
31 #ifdef __cplusplus |
| |
32 extern "C" { |
| |
33 #endif |
| |
34 |
| |
35 /************************************************************************** |
| |
36 * @name Structures |
| |
37 **************************************************************************/ |
| |
38 /*@{*/ |
| |
39 |
| |
40 #define GTK_TYPE_IMHTML (gtk_imhtml_get_type ()) |
| |
41 #define GTK_IMHTML(obj) (GTK_CHECK_CAST ((obj), GTK_TYPE_IMHTML, GtkIMHtml)) |
| |
42 #define GTK_IMHTML_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GTK_TYPE_IMHTML, GtkIMHtmlClass)) |
| |
43 #define GTK_IS_IMHTML(obj) (GTK_CHECK_TYPE ((obj), GTK_TYPE_IMHTML)) |
| |
44 #define GTK_IS_IMHTML_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GTK_TYPE_IMHTML)) |
| |
45 #define GTK_IMHTML_SCALABLE(obj) ((GtkIMHtmlScalable *)obj) |
| |
46 |
| |
47 typedef struct _GtkIMHtml GtkIMHtml; |
| |
48 typedef struct _GtkIMHtmlClass GtkIMHtmlClass; |
| |
49 typedef struct _GtkIMHtmlFontDetail GtkIMHtmlFontDetail; /* The five elements contained in a FONT tag */ |
| |
50 typedef struct _GtkSmileyTree GtkSmileyTree; |
| |
51 typedef struct _GtkIMHtmlSmiley GtkIMHtmlSmiley; |
| |
52 typedef struct _GtkIMHtmlScalable GtkIMHtmlScalable; |
| |
53 typedef struct _GtkIMHtmlImage GtkIMHtmlImage; |
| |
54 typedef struct _GtkIMHtmlHr GtkIMHtmlHr; |
| |
55 typedef struct _GtkIMHtmlFuncs GtkIMHtmlFuncs; |
| |
56 |
| |
57 typedef enum { |
| |
58 GTK_IMHTML_BOLD = 1 << 0, |
| |
59 GTK_IMHTML_ITALIC = 1 << 1, |
| |
60 GTK_IMHTML_UNDERLINE = 1 << 2, |
| |
61 GTK_IMHTML_GROW = 1 << 3, |
| |
62 GTK_IMHTML_SHRINK = 1 << 4, |
| |
63 GTK_IMHTML_FACE = 1 << 5, |
| |
64 GTK_IMHTML_FORECOLOR = 1 << 6, |
| |
65 GTK_IMHTML_BACKCOLOR = 1 << 7, |
| |
66 GTK_IMHTML_BACKGROUND = 1 << 8, |
| |
67 GTK_IMHTML_LINK = 1 << 9, |
| |
68 GTK_IMHTML_IMAGE = 1 << 10, |
| |
69 GTK_IMHTML_SMILEY = 1 << 11, |
| |
70 GTK_IMHTML_LINKDESC = 1 << 12, |
| |
71 GTK_IMHTML_STRIKE = 1 << 13, |
| |
72 GTK_IMHTML_ALL = -1 |
| |
73 } GtkIMHtmlButtons; |
| |
74 |
| |
75 typedef enum { |
| |
76 GTK_IMHTML_SMILEY_CUSTOM = 1 << 0 |
| |
77 } GtkIMHtmlSmileyFlags; |
| |
78 |
| |
79 struct _GtkIMHtml { |
| |
80 GtkTextView text_view; |
| |
81 GtkTextBuffer *text_buffer; |
| |
82 GdkCursor *hand_cursor; |
| |
83 GdkCursor *arrow_cursor; |
| |
84 GdkCursor *text_cursor; |
| |
85 GHashTable *smiley_data; |
| |
86 GtkSmileyTree *default_smilies; |
| |
87 char *protocol_name; |
| |
88 guint scroll_src; |
| |
89 GTimer *scroll_time; |
| |
90 |
| |
91 gboolean show_comments; |
| |
92 |
| |
93 GtkWidget *tip_window; |
| |
94 char *tip; |
| |
95 guint tip_timer; |
| |
96 GtkTextTag *prelit_tag; |
| |
97 |
| |
98 GList *scalables; |
| |
99 GdkRectangle old_rect; |
| |
100 |
| |
101 gchar *search_string; |
| |
102 |
| |
103 gboolean editable; |
| |
104 GtkIMHtmlButtons format_functions; |
| |
105 gboolean wbfo; /* Whole buffer formatting only. */ |
| |
106 |
| |
107 gint insert_offset; |
| |
108 |
| |
109 struct { |
| |
110 gboolean bold:1; |
| |
111 gboolean italic:1; |
| |
112 gboolean underline:1; |
| |
113 gboolean strike:1; |
| |
114 gchar *forecolor; |
| |
115 gchar *backcolor; |
| |
116 gchar *background; |
| |
117 gchar *fontface; |
| |
118 int fontsize; |
| |
119 GtkTextTag *link; |
| |
120 } edit; |
| |
121 |
| |
122 char *clipboard_text_string; |
| |
123 char *clipboard_html_string; |
| |
124 |
| |
125 GSList *im_images; |
| |
126 GtkIMHtmlFuncs *funcs; |
| |
127 }; |
| |
128 |
| |
129 struct _GtkIMHtmlClass { |
| |
130 GtkTextViewClass parent_class; |
| |
131 |
| |
132 void (*url_clicked)(GtkIMHtml *, const gchar *); |
| |
133 void (*buttons_update)(GtkIMHtml *, GtkIMHtmlButtons); |
| |
134 void (*toggle_format)(GtkIMHtml *, GtkIMHtmlButtons); |
| |
135 void (*clear_format)(GtkIMHtml *); |
| |
136 void (*update_format)(GtkIMHtml *); |
| |
137 gboolean (*message_send)(GtkIMHtml *); |
| |
138 }; |
| |
139 |
| |
140 struct _GtkIMHtmlFontDetail { |
| |
141 gushort size; |
| |
142 gchar *face; |
| |
143 gchar *fore; |
| |
144 gchar *back; |
| |
145 gchar *bg; |
| |
146 gchar *sml; |
| |
147 gboolean underline; |
| |
148 gshort bold; |
| |
149 }; |
| |
150 |
| |
151 struct _GtkSmileyTree { |
| |
152 GString *values; |
| |
153 GtkSmileyTree **children; |
| |
154 GtkIMHtmlSmiley *image; |
| |
155 }; |
| |
156 |
| |
157 struct _GtkIMHtmlSmiley { |
| |
158 gchar *smile; |
| |
159 gchar *file; |
| |
160 GdkPixbufAnimation *icon; |
| |
161 gboolean hidden; |
| |
162 GdkPixbufLoader *loader; |
| |
163 GSList *anchors; |
| |
164 GtkIMHtmlSmileyFlags flags; |
| |
165 GtkIMHtml *imhtml; |
| |
166 }; |
| |
167 |
| |
168 struct _GtkIMHtmlScalable { |
| |
169 void (*scale)(struct _GtkIMHtmlScalable *, int, int); |
| |
170 void (*add_to)(struct _GtkIMHtmlScalable *, GtkIMHtml *, GtkTextIter *); |
| |
171 void (*free)(struct _GtkIMHtmlScalable *); |
| |
172 }; |
| |
173 |
| |
174 struct _GtkIMHtmlImage { |
| |
175 GtkIMHtmlScalable scalable; |
| |
176 GtkImage *image; |
| |
177 GdkPixbuf *pixbuf; |
| |
178 GtkTextMark *mark; |
| |
179 gchar *filename; |
| |
180 int width; |
| |
181 int height; |
| |
182 int id; |
| |
183 GtkWidget *filesel; |
| |
184 }; |
| |
185 |
| |
186 struct _GtkIMHtmlHr { |
| |
187 GtkIMHtmlScalable scalable; |
| |
188 GtkWidget *sep; |
| |
189 }; |
| |
190 |
| |
191 typedef enum { |
| |
192 GTK_IMHTML_NO_COLOURS = 1 << 0, |
| |
193 GTK_IMHTML_NO_FONTS = 1 << 1, |
| |
194 GTK_IMHTML_NO_COMMENTS = 1 << 2, /* Remove */ |
| |
195 GTK_IMHTML_NO_TITLE = 1 << 3, |
| |
196 GTK_IMHTML_NO_NEWLINE = 1 << 4, |
| |
197 GTK_IMHTML_NO_SIZES = 1 << 5, |
| |
198 GTK_IMHTML_NO_SCROLL = 1 << 6, |
| |
199 GTK_IMHTML_RETURN_LOG = 1 << 7, |
| |
200 GTK_IMHTML_USE_POINTSIZE = 1 << 8, |
| |
201 GTK_IMHTML_NO_FORMATTING = 1 << 9, |
| |
202 GTK_IMHTML_USE_SMOOTHSCROLLING = 1 << 10 |
| |
203 } GtkIMHtmlOptions; |
| |
204 |
| |
205 enum { |
| |
206 GTK_IMHTML_DRAG_URL = 0, |
| |
207 GTK_IMHTML_DRAG_HTML, |
| |
208 GTK_IMHTML_DRAG_UTF8_STRING, |
| |
209 GTK_IMHTML_DRAG_COMPOUND_TEXT, |
| |
210 GTK_IMHTML_DRAG_STRING, |
| |
211 GTK_IMHTML_DRAG_TEXT, |
| |
212 GTK_IMHTML_DRAG_NUM |
| |
213 }; |
| |
214 |
| |
215 #define GTK_IMHTML_DND_TARGETS \ |
| |
216 { "text/uri-list", 0, GTK_IMHTML_DRAG_URL }, \ |
| |
217 { "_NETSCAPE_URL", 0, GTK_IMHTML_DRAG_URL }, \ |
| |
218 { "text/html", 0, GTK_IMHTML_DRAG_HTML }, \ |
| |
219 { "x-url/ftp", 0, GTK_IMHTML_DRAG_URL }, \ |
| |
220 { "x-url/http", 0, GTK_IMHTML_DRAG_URL }, \ |
| |
221 { "UTF8_STRING", 0, GTK_IMHTML_DRAG_UTF8_STRING }, \ |
| |
222 { "COMPOUND_TEXT", 0, GTK_IMHTML_DRAG_COMPOUND_TEXT }, \ |
| |
223 { "STRING", 0, GTK_IMHTML_DRAG_STRING }, \ |
| |
224 { "text/plain", 0, GTK_IMHTML_DRAG_TEXT }, \ |
| |
225 { "TEXT", 0, GTK_IMHTML_DRAG_TEXT } |
| |
226 |
| |
227 typedef gpointer (*GtkIMHtmlGetImageFunc) (int id); |
| |
228 typedef gpointer (*GtkIMHtmlGetImageDataFunc) (gpointer i); |
| |
229 typedef size_t (*GtkIMHtmlGetImageSizeFunc) (gpointer i); |
| |
230 typedef const char *(*GtkIMHtmlGetImageFilenameFunc)(gpointer i); |
| |
231 typedef void (*GtkIMHtmlImageRefFunc) (int id); |
| |
232 typedef void (*GtkIMHtmlImageUnrefFunc) (int id); |
| |
233 |
| |
234 struct _GtkIMHtmlFuncs { |
| |
235 GtkIMHtmlGetImageFunc image_get; |
| |
236 GtkIMHtmlGetImageDataFunc image_get_data; |
| |
237 GtkIMHtmlGetImageSizeFunc image_get_size; |
| |
238 GtkIMHtmlGetImageFilenameFunc image_get_filename; |
| |
239 GtkIMHtmlImageRefFunc image_ref; |
| |
240 GtkIMHtmlImageUnrefFunc image_unref; |
| |
241 }; |
| |
242 |
| |
243 /*@}*/ |
| |
244 |
| |
245 /************************************************************************** |
| |
246 * @name GTK+ IM/HTML rendering component API |
| |
247 **************************************************************************/ |
| |
248 /*@{*/ |
| |
249 |
| |
250 /** |
| |
251 * Returns the GType object for an IM/HTML widget. |
| |
252 * |
| |
253 * @return The GType for an IM/HTML widget. |
| |
254 */ |
| |
255 GType gtk_imhtml_get_type(void); |
| |
256 |
| |
257 /** |
| |
258 * Creates and returns a new GTK+ IM/HTML widget. |
| |
259 * |
| |
260 * @return The GTK+ IM/HTML widget created. |
| |
261 */ |
| |
262 GtkWidget *gtk_imhtml_new(void *, void *); |
| |
263 |
| |
264 /** |
| |
265 * Returns the smiley object associated with the text. |
| |
266 * |
| |
267 * @param imhtml The GTK+ IM/HTML. |
| |
268 * @param sml The name of the smiley category. |
| |
269 * @param text The text associated with the smiley. |
| |
270 */ |
| |
271 |
| |
272 GtkIMHtmlSmiley *gtk_imhtml_smiley_get(GtkIMHtml * imhtml, |
| |
273 const gchar * sml, const gchar * text); |
| |
274 |
| |
275 |
| |
276 /** |
| |
277 * Associates a smiley with a GTK+ IM/HTML. |
| |
278 * |
| |
279 * @param imhtml The GTK+ IM/HTML. |
| |
280 * @param sml The name of the smiley category. |
| |
281 * @param smiley The GtkIMSmiley to associate. |
| |
282 */ |
| |
283 void gtk_imhtml_associate_smiley(GtkIMHtml *imhtml, const gchar *sml, GtkIMHtmlSmiley *smiley); |
| |
284 |
| |
285 /** |
| |
286 * Removes all smileys associated with a GTK+ IM/HTML. |
| |
287 * |
| |
288 * @param imhtml The GTK+ IM/HTML. |
| |
289 */ |
| |
290 void gtk_imhtml_remove_smileys(GtkIMHtml *imhtml); |
| |
291 |
| |
292 /** |
| |
293 * Sets the function callbacks to use with a GTK+ IM/HTML instance. |
| |
294 * |
| |
295 * @param imhtml The GTK+ IM/HTML. |
| |
296 * @param f The GtkIMHTMLFuncs struct containing the functions to use. |
| |
297 */ |
| |
298 void gtk_imhtml_set_funcs(GtkIMHtml *imhtml, GtkIMHtmlFuncs *f); |
| |
299 |
| |
300 /** |
| |
301 * Enables or disables showing the contents of HTML comments in a GTK+ IM/HTML. |
| |
302 * |
| |
303 * @param imhtml The GTK+ IM/HTML. |
| |
304 * @param show @c TRUE if comments should be shown, or @c FALSE otherwise. |
| |
305 */ |
| |
306 void gtk_imhtml_show_comments(GtkIMHtml *imhtml, gboolean show); |
| |
307 |
| |
308 /** |
| |
309 * Gets the protocol name associated with this GTK+ IM/HTML. |
| |
310 * |
| |
311 * @param imhtml The GTK+ IM/HTML |
| |
312 */ |
| |
313 const char *gtk_imhtml_get_protocol_name(GtkIMHtml *imhtml); |
| |
314 |
| |
315 /** |
| |
316 * Associates a protocol name with a GTK+ IM/HTML. |
| |
317 * |
| |
318 * @param imhtml The GTK+ IM/HTML. |
| |
319 * @param protocol_name The protocol name to associate with the IM/HTML. |
| |
320 */ |
| |
321 void gtk_imhtml_set_protocol_name(GtkIMHtml *imhtml, const gchar *protocol_name); |
| |
322 |
| |
323 /** |
| |
324 * Appends HTML formatted text to a GTK+ IM/HTML. |
| |
325 * |
| |
326 * @param imhtml The GTK+ IM/HTML. |
| |
327 * @param text The formatted text to append. |
| |
328 * @param options A GtkIMHtmlOptions object indicating insert behavior. |
| |
329 */ |
| |
330 #define gtk_imhtml_append_text(imhtml, text, options) \ |
| |
331 gtk_imhtml_append_text_with_images(imhtml, text, options, NULL) |
| |
332 |
| |
333 /** |
| |
334 * Appends HTML formatted text to a GTK+ IM/HTML. |
| |
335 * |
| |
336 * @param imhtml The GTK+ IM/HTML. |
| |
337 * @param text The formatted text to append. |
| |
338 * @param options A GtkIMHtmlOptions object indicating insert behavior. |
| |
339 * @param unused Use @c NULL value. |
| |
340 */ |
| |
341 void gtk_imhtml_append_text_with_images(GtkIMHtml *imhtml, |
| |
342 const gchar *text, |
| |
343 GtkIMHtmlOptions options, |
| |
344 GSList *unused); |
| |
345 |
| |
346 /** |
| |
347 * Inserts HTML formatted text to a GTK+ IM/HTML at a given iter. |
| |
348 * |
| |
349 * @param imhtml The GTK+ IM/HTML. |
| |
350 * @param text The formatted text to append. |
| |
351 * @param options A GtkIMHtmlOptions object indicating insert behavior. |
| |
352 * @param iter A GtkTextIter in the GTK+ IM/HTML at which to insert text. |
| |
353 */ |
| |
354 void gtk_imhtml_insert_html_at_iter(GtkIMHtml *imhtml, |
| |
355 const gchar *text, |
| |
356 GtkIMHtmlOptions options, |
| |
357 GtkTextIter *iter); |
| |
358 |
| |
359 /** |
| |
360 * Scrolls a GTK+ IM/HTML to the end of its contents. |
| |
361 * |
| |
362 * @param imhtml The GTK+ IM/HTML. |
| |
363 * @param smooth A boolean indicating if smooth scrolling should be used. |
| |
364 */ |
| |
365 void gtk_imhtml_scroll_to_end(GtkIMHtml *imhtml, gboolean smooth); |
| |
366 |
| |
367 /** |
| |
368 * Delete the contents of a GTK+ IM/HTML between start and end. |
| |
369 * |
| |
370 * @param imhtml The GTK+ IM/HTML. |
| |
371 * @param start a postition in the imhtml's buffer |
| |
372 * @param end another postition in the imhtml's buffer |
| |
373 */ |
| |
374 void gtk_imhtml_delete(GtkIMHtml *imhtml, GtkTextIter *start, GtkTextIter *end); |
| |
375 |
| |
376 /** |
| |
377 * Purges the contents from a GTK+ IM/HTML and resets formatting. |
| |
378 * |
| |
379 * @param imhtml The GTK+ IM/HTML. |
| |
380 */ |
| |
381 #define gtk_imhtml_clear(imhtml) \ |
| |
382 gtk_imhtml_delete(imhtml, NULL, NULL) |
| |
383 |
| |
384 /** |
| |
385 * Scrolls a GTK+ IM/HTML up by one page. |
| |
386 * |
| |
387 * @param imhtml The GTK+ IM/HTML. |
| |
388 */ |
| |
389 void gtk_imhtml_page_up(GtkIMHtml *imhtml); |
| |
390 |
| |
391 /** |
| |
392 * Scrolls a GTK+ IM/HTML down by one page. |
| |
393 * |
| |
394 * @param imhtml The GTK+ IM/HTML. |
| |
395 */ |
| |
396 void gtk_imhtml_page_down(GtkIMHtml *imhtml); |
| |
397 |
| |
398 /** |
| |
399 * Creates and returns an new GTK+ IM/HTML scalable object. |
| |
400 * |
| |
401 * @return A new IM/HTML Scalable object. |
| |
402 */ |
| |
403 GtkIMHtmlScalable *gtk_imhtml_scalable_new(void); |
| |
404 |
| |
405 /** |
| |
406 * Creates and returns an new GTK+ IM/HTML scalable object with an image. |
| |
407 * |
| |
408 * @param img A GdkPixbuf of the image to add. |
| |
409 * @param filename The filename to associate with the image. |
| |
410 * @param id The id to associate with the image. |
| |
411 * |
| |
412 * @return A new IM/HTML Scalable object with an image. |
| |
413 */ |
| |
414 GtkIMHtmlScalable *gtk_imhtml_image_new(GdkPixbuf *img, const gchar *filename, int id); |
| |
415 |
| |
416 /** |
| |
417 * Destroys and frees a GTK+ IM/HTML scalable image. |
| |
418 * |
| |
419 * @param scale The GTK+ IM/HTML scalable. |
| |
420 */ |
| |
421 void gtk_imhtml_image_free(GtkIMHtmlScalable *scale); |
| |
422 |
| |
423 /** |
| |
424 * Rescales a GTK+ IM/HTML scalable image to a given size. |
| |
425 * |
| |
426 * @param scale The GTK+ IM/HTML scalable. |
| |
427 * @param width The new width. |
| |
428 * @param height The new height. |
| |
429 */ |
| |
430 void gtk_imhtml_image_scale(GtkIMHtmlScalable *scale, int width, int height); |
| |
431 |
| |
432 /** |
| |
433 * Adds a GTK+ IM/HTML scalable image to a given GTK+ IM/HTML at a given iter. |
| |
434 * |
| |
435 * @param scale The GTK+ IM/HTML scalable. |
| |
436 * @param imhtml The GTK+ IM/HTML. |
| |
437 * @param iter The GtkTextIter at which to add the scalable. |
| |
438 */ |
| |
439 void gtk_imhtml_image_add_to(GtkIMHtmlScalable *scale, GtkIMHtml *imhtml, GtkTextIter *iter); |
| |
440 |
| |
441 /** |
| |
442 * Creates and returns an new GTK+ IM/HTML scalable with a horizontal rule. |
| |
443 * |
| |
444 * @return A new IM/HTML Scalable object with an image. |
| |
445 */ |
| |
446 GtkIMHtmlScalable *gtk_imhtml_hr_new(void); |
| |
447 |
| |
448 /** |
| |
449 * Destroys and frees a GTK+ IM/HTML scalable horizontal rule. |
| |
450 * |
| |
451 * @param scale The GTK+ IM/HTML scalable. |
| |
452 */ |
| |
453 void gtk_imhtml_hr_free(GtkIMHtmlScalable *scale); |
| |
454 |
| |
455 /** |
| |
456 * Rescales a GTK+ IM/HTML scalable horizontal rule to a given size. |
| |
457 * |
| |
458 * @param scale The GTK+ IM/HTML scalable. |
| |
459 * @param width The new width. |
| |
460 * @param height The new height. |
| |
461 */ |
| |
462 void gtk_imhtml_hr_scale(GtkIMHtmlScalable *scale, int width, int height); |
| |
463 |
| |
464 /** |
| |
465 * Adds a GTK+ IM/HTML scalable horizontal rule to a given GTK+ IM/HTML at |
| |
466 * a given iter. |
| |
467 * |
| |
468 * @param scale The GTK+ IM/HTML scalable. |
| |
469 * @param imhtml The GTK+ IM/HTML. |
| |
470 * @param iter The GtkTextIter at which to add the scalable. |
| |
471 */ |
| |
472 void gtk_imhtml_hr_add_to(GtkIMHtmlScalable *scale, GtkIMHtml *imhtml, GtkTextIter *iter); |
| |
473 |
| |
474 /** |
| |
475 * Finds and highlights a given string in a GTK+ IM/HTML. |
| |
476 * |
| |
477 * @param imhtml The GTK+ IM/HTML. |
| |
478 * @param text The string to search for. |
| |
479 * |
| |
480 * @return @c TRUE if a search was performed, or @c FALSE if not. |
| |
481 */ |
| |
482 gboolean gtk_imhtml_search_find(GtkIMHtml *imhtml, const gchar *text); |
| |
483 |
| |
484 /** |
| |
485 * Clears the highlighting from a prior search in a GTK+ IM/HTML. |
| |
486 * |
| |
487 * @param imhtml The GTK+ IM/HTML. |
| |
488 */ |
| |
489 void gtk_imhtml_search_clear(GtkIMHtml *imhtml); |
| |
490 |
| |
491 /** |
| |
492 * Enables or disables editing in a GTK+ IM/HTML. |
| |
493 * |
| |
494 * @param imhtml The GTK+ IM/HTML. |
| |
495 * @param editable @c TRUE to make the widget editable, or @c FALSE otherwise. |
| |
496 */ |
| |
497 void gtk_imhtml_set_editable(GtkIMHtml *imhtml, gboolean editable); |
| |
498 |
| |
499 /** |
| |
500 * Enables or disables whole buffer formatting only (wbfo) in a GTK+ IM/HTML. |
| |
501 * In this mode formatting options to the buffer take effect for the entire |
| |
502 * buffer instead of specific text. |
| |
503 * |
| |
504 * @param imhtml The GTK+ IM/HTML. |
| |
505 * @param wbfo @c TRUE to enable the mode, or @c FALSE otherwise. |
| |
506 */ |
| |
507 void gtk_imhtml_set_whole_buffer_formatting_only(GtkIMHtml *imhtml, gboolean wbfo); |
| |
508 |
| |
509 /** |
| |
510 * Indicates which formatting functions to enable and disable in a GTK+ IM/HTML. |
| |
511 * |
| |
512 * @param imhtml The GTK+ IM/HTML. |
| |
513 * @param buttons A GtkIMHtmlButtons bitmask indicating which functions to use. |
| |
514 */ |
| |
515 void gtk_imhtml_set_format_functions(GtkIMHtml *imhtml, GtkIMHtmlButtons buttons); |
| |
516 |
| |
517 /** |
| |
518 * Returns which formatting functions are enabled in a GTK+ IM/HTML. |
| |
519 * |
| |
520 * @param imhtml The GTK+ IM/HTML. |
| |
521 * |
| |
522 * @return A GtkIMHtmlButtons bitmask indicating which functions to are enabled. |
| |
523 */ |
| |
524 GtkIMHtmlButtons gtk_imhtml_get_format_functions(GtkIMHtml *imhtml); |
| |
525 |
| |
526 /** |
| |
527 * Sets each boolean to @c TRUE or @c FALSE to indicate if that formatting option |
| |
528 * is enabled at the current position in a GTK+ IM/HTML. |
| |
529 * |
| |
530 * @param imhtml The GTK+ IM/HTML. |
| |
531 * @param bold The boolean to set for bold or @c NULL. |
| |
532 * @param italic The boolean to set for italic or @c NULL. |
| |
533 * @param underline The boolean to set for underline or @c NULL. |
| |
534 */ |
| |
535 void gtk_imhtml_get_current_format(GtkIMHtml *imhtml, gboolean *bold, gboolean *italic, gboolean *underline); |
| |
536 |
| |
537 /** |
| |
538 * Returns a string containing the selected font face at the current position |
| |
539 * in a GTK+ IM/HTML. |
| |
540 * |
| |
541 * @param imhtml The GTK+ IM/HTML. |
| |
542 * |
| |
543 * @return A string containg the font face or @c NULL if none is set. |
| |
544 */ |
| |
545 char *gtk_imhtml_get_current_fontface(GtkIMHtml *imhtml); |
| |
546 |
| |
547 /** |
| |
548 * Returns a string containing the selected foreground color at the current |
| |
549 * position in a GTK+ IM/HTML. |
| |
550 * |
| |
551 * @param imhtml The GTK+ IM/HTML. |
| |
552 * |
| |
553 * @return A string containg the foreground color or @c NULL if none is set. |
| |
554 */ |
| |
555 char *gtk_imhtml_get_current_forecolor(GtkIMHtml *imhtml); |
| |
556 |
| |
557 /** |
| |
558 * Returns a string containing the selected font background color at the current |
| |
559 * position in a GTK+ IM/HTML. |
| |
560 * |
| |
561 * @param imhtml The GTK+ IM/HTML. |
| |
562 * |
| |
563 * @return A string containg the font background color or @c NULL if none is set. |
| |
564 */ |
| |
565 char *gtk_imhtml_get_current_backcolor(GtkIMHtml *imhtml); |
| |
566 |
| |
567 /** |
| |
568 * Returns a string containing the selected background color at the current |
| |
569 * position in a GTK+ IM/HTML. |
| |
570 * |
| |
571 * @param imhtml The GTK+ IM/HTML. |
| |
572 * |
| |
573 * @return A string containg the background color or @c NULL if none is set. |
| |
574 */ |
| |
575 char *gtk_imhtml_get_current_background(GtkIMHtml *imhtml); |
| |
576 |
| |
577 /** |
| |
578 * Returns a integer containing the selected HTML font size at the current |
| |
579 * position in a GTK+ IM/HTML. |
| |
580 * |
| |
581 * @param imhtml The GTK+ IM/HTML. |
| |
582 * |
| |
583 * @return The HTML font size. |
| |
584 */ |
| |
585 gint gtk_imhtml_get_current_fontsize(GtkIMHtml *imhtml); |
| |
586 |
| |
587 /** |
| |
588 * Checks whether a GTK+ IM/HTML is marked as editable. |
| |
589 * |
| |
590 * @param imhtml The GTK+ IM/HTML. |
| |
591 * |
| |
592 * @return @c TRUE if the IM/HTML is editable, or @c FALSE otherwise. |
| |
593 */ |
| |
594 gboolean gtk_imhtml_get_editable(GtkIMHtml *imhtml); |
| |
595 |
| |
596 /** |
| |
597 * Clear all the formatting on a GTK+ IM/HTML. |
| |
598 * |
| |
599 * @param imhtml The GTK+ IM/HTML. |
| |
600 */ |
| |
601 void gtk_imhtml_clear_formatting(GtkIMHtml *imhtml); |
| |
602 |
| |
603 /** |
| |
604 * Toggles bold at the cursor location or selection in a GTK+ IM/HTML. |
| |
605 * |
| |
606 * @param imhtml The GTK+ IM/HTML. |
| |
607 */ |
| |
608 void gtk_imhtml_toggle_bold(GtkIMHtml *imhtml); |
| |
609 |
| |
610 /** |
| |
611 * Toggles italic at the cursor location or selection in a GTK+ IM/HTML. |
| |
612 * |
| |
613 * @param imhtml The GTK+ IM/HTML. |
| |
614 */ |
| |
615 void gtk_imhtml_toggle_italic(GtkIMHtml *imhtml); |
| |
616 |
| |
617 /** |
| |
618 * Toggles underline at the cursor location or selection in a GTK+ IM/HTML. |
| |
619 * |
| |
620 * @param imhtml The GTK+ IM/HTML. |
| |
621 */ |
| |
622 void gtk_imhtml_toggle_underline(GtkIMHtml *imhtml); |
| |
623 |
| |
624 /** |
| |
625 * Toggles strikethrough at the cursor location or selection in a GTK+ IM/HTML. |
| |
626 * |
| |
627 * @param imhtml The GTK+ IM/HTML. |
| |
628 */ |
| |
629 void gtk_imhtml_toggle_strike(GtkIMHtml *imhtml); |
| |
630 |
| |
631 /** |
| |
632 * Toggles a foreground color at the current location or selection in a GTK |
| |
633 * IM/HTML. |
| |
634 * |
| |
635 * @param imhtml The GTK+ IM/HTML. |
| |
636 * @param color The HTML-style color, or @c NULL or "" to clear the color. |
| |
637 * |
| |
638 * @return @c TRUE if a color was set, or @c FALSE if it was cleared. |
| |
639 */ |
| |
640 gboolean gtk_imhtml_toggle_forecolor(GtkIMHtml *imhtml, const char *color); |
| |
641 |
| |
642 /** |
| |
643 * Toggles a background color at the current location or selection in a GTK |
| |
644 * IM/HTML. |
| |
645 * |
| |
646 * @param imhtml The GTK+ IM/HTML. |
| |
647 * @param color The HTML-style color, or @c NULL or "" to clear the color. |
| |
648 * |
| |
649 * @return @c TRUE if a color was set, or @c FALSE if it was cleared. |
| |
650 */ |
| |
651 gboolean gtk_imhtml_toggle_backcolor(GtkIMHtml *imhtml, const char *color); |
| |
652 |
| |
653 /** |
| |
654 * Toggles a background color at the current location or selection in a GTK |
| |
655 * IM/HTML. |
| |
656 * |
| |
657 * @param imhtml The GTK+ IM/HTML. |
| |
658 * @param color The HTML-style color, or @c NULL or "" to clear the color. |
| |
659 * |
| |
660 * @return @c TRUE if a color was set, or @c FALSE if it was cleared. |
| |
661 */ |
| |
662 gboolean gtk_imhtml_toggle_background(GtkIMHtml *imhtml, const char *color); |
| |
663 |
| |
664 /** |
| |
665 * Toggles a font face at the current location or selection in a GTK+ IM/HTML. |
| |
666 * |
| |
667 * @param imhtml The GTK+ IM/HTML. |
| |
668 * @param face The font face name, or @c NULL or "" to clear the font. |
| |
669 * |
| |
670 * @return @c TRUE if a font name was set, or @c FALSE if it was cleared. |
| |
671 */ |
| |
672 gboolean gtk_imhtml_toggle_fontface(GtkIMHtml *imhtml, const char *face); |
| |
673 |
| |
674 /** |
| |
675 * Toggles a link tag with the given URL at the current location or selection |
| |
676 * in a GTK+ IM/HTML. |
| |
677 * |
| |
678 * @param imhtml The GTK+ IM/HTML. |
| |
679 * @param url The URL for the link or @c NULL to terminate the link. |
| |
680 */ |
| |
681 void gtk_imhtml_toggle_link(GtkIMHtml *imhtml, const char *url); |
| |
682 |
| |
683 /** |
| |
684 * Inserts a link to the given url at the given GtkTextMark in a GTK+ IM/HTML. |
| |
685 * |
| |
686 * @param imhtml The GTK+ IM/HTML. |
| |
687 * @param mark The GtkTextMark to insert the link at. |
| |
688 * @param url The URL for the link. |
| |
689 * @param text The string to use for the link description. |
| |
690 */ |
| |
691 void gtk_imhtml_insert_link(GtkIMHtml *imhtml, GtkTextMark *mark, const char *url, const char *text); |
| |
692 |
| |
693 /** |
| |
694 * Inserts a smiley at the current location or selection in a GTK+ IM/HTML. |
| |
695 * |
| |
696 * @param imhtml The GTK+ IM/HTML. |
| |
697 * @param sml The category of the smiley. |
| |
698 * @param smiley The text of the smiley to insert. |
| |
699 */ |
| |
700 void gtk_imhtml_insert_smiley(GtkIMHtml *imhtml, const char *sml, char *smiley); |
| |
701 /** |
| |
702 * Inserts a smiley at the given iter in a GTK+ IM/HTML. |
| |
703 * |
| |
704 * @param imhtml The GTK+ IM/HTML. |
| |
705 * @param sml The category of the smiley. |
| |
706 * @param smiley The text of the smiley to insert. |
| |
707 * @param iter The GtkTextIter in the IM/HTML to insert the smiley at. |
| |
708 */ |
| |
709 void gtk_imhtml_insert_smiley_at_iter(GtkIMHtml *imhtml, const char *sml, char *smiley, GtkTextIter *iter); |
| |
710 |
| |
711 /** |
| |
712 * Inserts the IM/HTML scalable image with the given id at the given iter in a |
| |
713 * GTK+ IM/HTML. |
| |
714 * |
| |
715 * @param imhtml The GTK+ IM/HTML. |
| |
716 * @param id The id of the IM/HTML scalable. |
| |
717 * @param iter The GtkTextIter in the IM/HTML to insert the image at. |
| |
718 */ |
| |
719 void gtk_imhtml_insert_image_at_iter(GtkIMHtml *imhtml, int id, GtkTextIter *iter); |
| |
720 |
| |
721 /** |
| |
722 * Sets the font size at the current location or selection in a GTK+ IM/HTML. |
| |
723 * |
| |
724 * @param imhtml The GTK+ IM/HTML. |
| |
725 * @param size The HTML font size to use. |
| |
726 */ |
| |
727 void gtk_imhtml_font_set_size(GtkIMHtml *imhtml, gint size); |
| |
728 |
| |
729 /** |
| |
730 * Decreases the font size by 1 at the current location or selection in a GTK |
| |
731 * IM/HTML. |
| |
732 * |
| |
733 * @param imhtml The GTK+ IM/HTML. |
| |
734 */ |
| |
735 void gtk_imhtml_font_shrink(GtkIMHtml *imhtml); |
| |
736 |
| |
737 /** |
| |
738 * Increases the font size by 1 at the current location or selection in a GTK |
| |
739 * IM/HTML. |
| |
740 * |
| |
741 * @param imhtml The GTK+ IM/HTML. |
| |
742 */ |
| |
743 void gtk_imhtml_font_grow(GtkIMHtml *imhtml); |
| |
744 |
| |
745 /** |
| |
746 * Returns the HTML formatted contents between two iters in a GTK+ IM/HTML. |
| |
747 * |
| |
748 * @param imhtml The GTK+ IM/HTML. |
| |
749 * @param start The GtkTextIter indicating the start point in the IM/HTML. |
| |
750 * @param end The GtkTextIter indicating the end point in the IM/HTML. |
| |
751 * |
| |
752 * @return A string containing the HTML formatted text. |
| |
753 */ |
| |
754 char *gtk_imhtml_get_markup_range(GtkIMHtml *imhtml, GtkTextIter *start, GtkTextIter *end); |
| |
755 |
| |
756 /** |
| |
757 * Returns the entire HTML formatted contents of a GTK+ IM/HTML. |
| |
758 * |
| |
759 * @param imhtml The GTK+ IM/HTML. |
| |
760 * |
| |
761 * @return A string containing the HTML formatted text. |
| |
762 */ |
| |
763 char *gtk_imhtml_get_markup(GtkIMHtml *imhtml); |
| |
764 |
| |
765 /** |
| |
766 * Returns a null terminated array of pointers to null terminated strings, each |
| |
767 * string for each line. g_strfreev() should be called to free it when done. |
| |
768 * |
| |
769 * @param imhtml The GTK+ IM/HTML. |
| |
770 * |
| |
771 * @return A null terminated array of null terminated HTML formatted strings. |
| |
772 */ |
| |
773 char **gtk_imhtml_get_markup_lines(GtkIMHtml *imhtml); |
| |
774 |
| |
775 /** |
| |
776 * Returns the entire unformatted (plain text) contents of a GTK+ IM/HTML |
| |
777 * between two iters in a GTK+ IM/HTML. |
| |
778 * |
| |
779 * @param imhtml The GTK+ IM/HTML. |
| |
780 * @param start The GtkTextIter indicating the start point in the IM/HTML. |
| |
781 * @param stop The GtkTextIter indicating the end point in the IM/HTML. |
| |
782 * |
| |
783 * @return A string containing the unformatted text. |
| |
784 */ |
| |
785 char *gtk_imhtml_get_text(GtkIMHtml *imhtml, GtkTextIter *start, GtkTextIter *stop); |
| |
786 |
| |
787 /*@}*/ |
| |
788 |
| |
789 #ifdef __cplusplus |
| |
790 } |
| |
791 #endif |
| |
792 |
| |
793 #endif /* _PIDGINIMHTML_H_ */ |