2 * @file gtkimhtml.h GTK+ IM/HTML rendering component
4 * @see @ref gtkimhtml-signals
7 /* Pidgin is the legal property of its developers, whose names are too numerous
8 * to list here. Please refer to the COPYRIGHT file distributed with this
11 * This program is free software; you can redistribute it and/or modify
12 * under the terms of the GNU General Public License as published by
13 * the Free Software Foundation; either version 2 of the License, or
14 * (at your option) any later version.
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
21 * You should have received a copy of the GNU General Public License
22 * along with this program; if not, write to the Free Software
23 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA
25 #ifndef _PIDGINIMHTML_H_
26 #define _PIDGINIMHTML_H_
30 #include "gtksourceundomanager.h"
32 #include "connection.h"
38 /**************************************************************************
40 **************************************************************************/
43 #define GTK_TYPE_IMHTML (gtk_imhtml_get_type())
44 #define GTK_IMHTML(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj), GTK_TYPE_IMHTML, GtkIMHtml))
45 #define GTK_IMHTML_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass), GTK_TYPE_IMHTML, GtkIMHtmlClass))
46 #define GTK_IS_IMHTML(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj), GTK_TYPE_IMHTML))
47 #define GTK_IS_IMHTML_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass), GTK_TYPE_IMHTML))
48 #define GTK_IMHTML_SCALABLE(obj) ((GtkIMHtmlScalable *)obj)
49 #define GTK_IMHTML_ANIMATION(obj) ((GtkIMHtmlAnimation *)obj)
51 typedef struct _GtkIMHtml GtkIMHtml
;
52 typedef struct _GtkIMHtmlClass GtkIMHtmlClass
;
53 #if !(defined PIDGIN_DISABLE_DEPRECATED) && !(defined _PIDGIN_GTKIMHTML_C_)
54 typedef struct _GtkIMHtmlFontDetail GtkIMHtmlFontDetail
; /* The five elements contained in a FONT tag */
56 typedef struct _GtkSmileyTree GtkSmileyTree
;
57 typedef struct _GtkIMHtmlSmiley GtkIMHtmlSmiley
;
58 typedef struct _GtkIMHtmlScalable GtkIMHtmlScalable
;
59 typedef struct _GtkIMHtmlImage GtkIMHtmlImage
;
60 typedef struct _GtkIMHtmlAnimation GtkIMHtmlAnimation
;
61 typedef struct _GtkIMHtmlHr GtkIMHtmlHr
;
62 typedef struct _GtkIMHtmlFuncs GtkIMHtmlFuncs
;
67 typedef struct _GtkIMHtmlLink GtkIMHtmlLink
;
70 GTK_IMHTML_BOLD
= 1 << 0,
71 GTK_IMHTML_ITALIC
= 1 << 1,
72 GTK_IMHTML_UNDERLINE
= 1 << 2,
73 GTK_IMHTML_GROW
= 1 << 3,
74 GTK_IMHTML_SHRINK
= 1 << 4,
75 GTK_IMHTML_FACE
= 1 << 5,
76 GTK_IMHTML_FORECOLOR
= 1 << 6,
77 GTK_IMHTML_BACKCOLOR
= 1 << 7,
78 GTK_IMHTML_BACKGROUND
= 1 << 8,
79 GTK_IMHTML_LINK
= 1 << 9,
80 GTK_IMHTML_IMAGE
= 1 << 10,
81 GTK_IMHTML_SMILEY
= 1 << 11,
82 GTK_IMHTML_LINKDESC
= 1 << 12,
83 GTK_IMHTML_STRIKE
= 1 << 13,
84 /** Show custom smileys when appropriate. @since 2.5.0 */
85 GTK_IMHTML_CUSTOM_SMILEY
= 1 << 14,
90 GTK_IMHTML_SMILEY_CUSTOM
= 1 << 0
91 } GtkIMHtmlSmileyFlags
;
94 GtkTextView text_view
;
95 GtkTextBuffer
*text_buffer
;
96 GdkCursor
*hand_cursor
;
97 GdkCursor
*arrow_cursor
;
98 GdkCursor
*text_cursor
;
99 GHashTable
*smiley_data
;
100 GtkSmileyTree
*default_smilies
;
107 gboolean show_comments
;
109 GtkWidget
*tip_window
;
112 GtkTextTag
*prelit_tag
;
115 GdkRectangle old_rect
;
117 gchar
*search_string
;
120 GtkIMHtmlButtons format_functions
;
121 gboolean wbfo
; /* Whole buffer formatting only. */
128 gboolean underline
:1;
138 #if !(defined PIDGIN_DISABLE_DEPRECATED) || (defined _PIDGIN_GTKIMHTML_C_)
140 char *clipboard_text_string
;
142 char *clipboard_html_string
;
149 GtkIMHtmlFuncs
*funcs
;
150 GtkSourceUndoManager
*undo_manager
;
153 struct _GtkIMHtmlClass
{
154 GtkTextViewClass parent_class
;
156 void (*url_clicked
)(GtkIMHtml
*, const gchar
*);
157 void (*buttons_update
)(GtkIMHtml
*, GtkIMHtmlButtons
);
158 void (*toggle_format
)(GtkIMHtml
*, GtkIMHtmlButtons
);
159 void (*clear_format
)(GtkIMHtml
*);
160 void (*update_format
)(GtkIMHtml
*);
161 gboolean (*message_send
)(GtkIMHtml
*);
162 void (*undo
)(GtkIMHtml
*);
163 void (*redo
)(GtkIMHtml
*);
164 GList
*protocols
; /* List of GtkIMHtmlProtocol's */
167 #if !(defined PIDGIN_DISABLE_DEPRECATED) && !(defined _PIDGIN_GTKIMHTML_C_)
168 /** @deprecated as of 2.7.10 */
169 struct _GtkIMHtmlFontDetail
{
181 struct _GtkSmileyTree
{
183 GtkSmileyTree
**children
;
184 GtkIMHtmlSmiley
*image
;
187 struct _GtkIMHtmlSmiley
{
190 GdkPixbufAnimation
*icon
;
192 GdkPixbufLoader
*loader
;
194 GtkIMHtmlSmileyFlags flags
;
196 gpointer data
; /** @since 2.6.0 */
197 gsize datasize
; /** @since 2.6.0 */
200 struct _GtkIMHtmlScalable
{
201 void (*scale
)(struct _GtkIMHtmlScalable
*, int, int);
202 void (*add_to
)(struct _GtkIMHtmlScalable
*, GtkIMHtml
*, GtkTextIter
*);
203 void (*free
)(struct _GtkIMHtmlScalable
*);
206 struct _GtkIMHtmlImage
{
207 GtkIMHtmlScalable scalable
;
208 GtkImage
*image
; /**< Contains the scaled version of this pixbuf. */
209 GdkPixbuf
*pixbuf
; /**< The original pixbuf, before any scaling. */
218 struct _GtkIMHtmlAnimation
{
219 GtkIMHtmlImage imhtmlimage
;
220 GdkPixbufAnimation
*anim
; /**< The original animation, before any scaling. */
221 GdkPixbufAnimationIter
*iter
;
225 struct _GtkIMHtmlHr
{
226 GtkIMHtmlScalable scalable
;
231 GTK_IMHTML_NO_COLOURS
= 1 << 0,
232 GTK_IMHTML_NO_FONTS
= 1 << 1,
233 GTK_IMHTML_NO_COMMENTS
= 1 << 2, /* Remove */
234 GTK_IMHTML_NO_TITLE
= 1 << 3,
235 GTK_IMHTML_NO_NEWLINE
= 1 << 4,
236 GTK_IMHTML_NO_SIZES
= 1 << 5,
237 GTK_IMHTML_NO_SCROLL
= 1 << 6,
238 GTK_IMHTML_RETURN_LOG
= 1 << 7,
239 GTK_IMHTML_USE_POINTSIZE
= 1 << 8,
240 GTK_IMHTML_NO_FORMATTING
= 1 << 9,
241 GTK_IMHTML_USE_SMOOTHSCROLLING
= 1 << 10,
242 GTK_IMHTML_NO_SMILEY
= 1 << 11
246 GTK_IMHTML_DRAG_URL
= 0,
247 GTK_IMHTML_DRAG_HTML
,
248 GTK_IMHTML_DRAG_UTF8_STRING
,
249 GTK_IMHTML_DRAG_COMPOUND_TEXT
,
250 GTK_IMHTML_DRAG_STRING
,
251 GTK_IMHTML_DRAG_TEXT
,
255 #define GTK_IMHTML_DND_TARGETS \
256 { "text/uri-list", 0, GTK_IMHTML_DRAG_URL }, \
257 { "_NETSCAPE_URL", 0, GTK_IMHTML_DRAG_URL }, \
258 { "text/html", 0, GTK_IMHTML_DRAG_HTML }, \
259 { "x-url/ftp", 0, GTK_IMHTML_DRAG_URL }, \
260 { "x-url/http", 0, GTK_IMHTML_DRAG_URL }, \
261 { "UTF8_STRING", 0, GTK_IMHTML_DRAG_UTF8_STRING }, \
262 { "COMPOUND_TEXT", 0, GTK_IMHTML_DRAG_COMPOUND_TEXT }, \
263 { "STRING", 0, GTK_IMHTML_DRAG_STRING }, \
264 { "text/plain", 0, GTK_IMHTML_DRAG_TEXT }, \
265 { "TEXT", 0, GTK_IMHTML_DRAG_TEXT }
267 typedef gpointer (*GtkIMHtmlGetImageFunc
) (int id
);
268 typedef gpointer (*GtkIMHtmlGetImageDataFunc
) (gpointer i
);
269 typedef size_t (*GtkIMHtmlGetImageSizeFunc
) (gpointer i
);
270 typedef const char *(*GtkIMHtmlGetImageFilenameFunc
)(gpointer i
);
271 typedef void (*GtkIMHtmlImageRefFunc
) (int id
);
272 typedef void (*GtkIMHtmlImageUnrefFunc
) (int id
);
274 struct _GtkIMHtmlFuncs
{
275 GtkIMHtmlGetImageFunc image_get
;
276 GtkIMHtmlGetImageDataFunc image_get_data
;
277 GtkIMHtmlGetImageSizeFunc image_get_size
;
278 GtkIMHtmlGetImageFilenameFunc image_get_filename
;
279 GtkIMHtmlImageRefFunc image_ref
;
280 GtkIMHtmlImageUnrefFunc image_unref
;
285 /**************************************************************************
286 * @name GTK+ IM/HTML rendering component API
287 **************************************************************************/
291 * Returns the GType object for an IM/HTML widget.
293 * @return The GType for an IM/HTML widget.
295 GType
gtk_imhtml_get_type(void);
298 * Creates and returns a new GTK+ IM/HTML widget.
300 * @return The GTK+ IM/HTML widget created.
302 GtkWidget
*gtk_imhtml_new(void *, void *);
305 * Returns the smiley object associated with the text.
307 * @param imhtml The GTK+ IM/HTML.
308 * @param sml The name of the smiley category.
309 * @param text The text associated with the smiley.
312 GtkIMHtmlSmiley
*gtk_imhtml_smiley_get(GtkIMHtml
* imhtml
,
313 const gchar
* sml
, const gchar
* text
);
317 * Associates a smiley with a GTK+ IM/HTML.
319 * @param imhtml The GTK+ IM/HTML.
320 * @param sml The name of the smiley category.
321 * @param smiley The GtkIMSmiley to associate.
323 void gtk_imhtml_associate_smiley(GtkIMHtml
*imhtml
, const gchar
*sml
, GtkIMHtmlSmiley
*smiley
);
326 * Removes all smileys associated with a GTK+ IM/HTML.
328 * @param imhtml The GTK+ IM/HTML.
330 void gtk_imhtml_remove_smileys(GtkIMHtml
*imhtml
);
333 * Sets the function callbacks to use with a GTK+ IM/HTML instance.
335 * @param imhtml The GTK+ IM/HTML.
336 * @param f The GtkIMHTMLFuncs struct containing the functions to use.
338 void gtk_imhtml_set_funcs(GtkIMHtml
*imhtml
, GtkIMHtmlFuncs
*f
);
341 * Enables or disables showing the contents of HTML comments in a GTK+ IM/HTML.
343 * @param imhtml The GTK+ IM/HTML.
344 * @param show @c TRUE if comments should be shown, or @c FALSE otherwise.
346 void gtk_imhtml_show_comments(GtkIMHtml
*imhtml
, gboolean show
);
349 * Gets the protocol name associated with this GTK+ IM/HTML.
351 * @param imhtml The GTK+ IM/HTML
353 const char *gtk_imhtml_get_protocol_name(GtkIMHtml
*imhtml
);
356 * Associates a protocol name with a GTK+ IM/HTML.
358 * @param imhtml The GTK+ IM/HTML.
359 * @param protocol_name The protocol name to associate with the IM/HTML.
361 void gtk_imhtml_set_protocol_name(GtkIMHtml
*imhtml
, const gchar
*protocol_name
);
364 * Appends HTML formatted text to a GTK+ IM/HTML.
366 * @param imhtml The GTK+ IM/HTML.
367 * @param text The formatted text to append.
368 * @param options A GtkIMHtmlOptions object indicating insert behavior.
370 #define gtk_imhtml_append_text(imhtml, text, options) \
371 gtk_imhtml_append_text_with_images(imhtml, text, options, NULL)
374 * Appends HTML formatted text to a GTK+ IM/HTML.
376 * @param imhtml The GTK+ IM/HTML.
377 * @param text The formatted text to append.
378 * @param options A GtkIMHtmlOptions object indicating insert behavior.
379 * @param unused Use @c NULL value.
381 void gtk_imhtml_append_text_with_images(GtkIMHtml
*imhtml
,
383 GtkIMHtmlOptions options
,
387 * Inserts HTML formatted text to a GTK+ IM/HTML at a given iter.
389 * @param imhtml The GTK+ IM/HTML.
390 * @param text The formatted text to append.
391 * @param options A GtkIMHtmlOptions object indicating insert behavior.
392 * @param iter A GtkTextIter in the GTK+ IM/HTML at which to insert text.
394 void gtk_imhtml_insert_html_at_iter(GtkIMHtml
*imhtml
,
396 GtkIMHtmlOptions options
,
400 * Scrolls a GTK+ IM/HTML to the end of its contents.
402 * @param imhtml The GTK+ IM/HTML.
403 * @param smooth A boolean indicating if smooth scrolling should be used.
405 void gtk_imhtml_scroll_to_end(GtkIMHtml
*imhtml
, gboolean smooth
);
408 * Delete the contents of a GTK+ IM/HTML between start and end.
410 * @param imhtml The GTK+ IM/HTML.
411 * @param start a postition in the imhtml's buffer
412 * @param end another postition in the imhtml's buffer
414 void gtk_imhtml_delete(GtkIMHtml
*imhtml
, GtkTextIter
*start
, GtkTextIter
*end
);
417 * Purges the contents from a GTK+ IM/HTML and resets formatting.
419 * @param imhtml The GTK+ IM/HTML.
421 #define gtk_imhtml_clear(imhtml) \
422 gtk_imhtml_delete(imhtml, NULL, NULL)
425 * Scrolls a GTK+ IM/HTML up by one page.
427 * @param imhtml The GTK+ IM/HTML.
429 void gtk_imhtml_page_up(GtkIMHtml
*imhtml
);
432 * Scrolls a GTK+ IM/HTML down by one page.
434 * @param imhtml The GTK+ IM/HTML.
436 void gtk_imhtml_page_down(GtkIMHtml
*imhtml
);
439 * Creates and returns an new GTK+ IM/HTML scalable object.
441 * @return A new IM/HTML Scalable object.
443 GtkIMHtmlScalable
*gtk_imhtml_scalable_new(void);
446 * Creates and returns a new GTK+ IM/HTML scalable object with an image.
448 * @param img A GdkPixbuf of the image to add.
449 * @param filename The filename to associate with the image.
450 * @param id The id to associate with the image.
452 * @return A new IM/HTML Scalable object with an image.
454 GtkIMHtmlScalable
*gtk_imhtml_image_new(GdkPixbuf
*img
, const gchar
*filename
, int id
);
457 * Creates and returns a new GTK+ IM/HTML scalable object with an
460 * @param img A GdkPixbufAnimation of the image to add.
461 * @param filename The filename to associate with the image.
462 * @param id The id to associate with the image.
464 * @return A new IM/HTML Scalable object with an image.
469 * TODO: All this animation code could be combined much better with
470 * the image code. It couldn't be done when it was written
471 * because it requires breaking backward compatibility. It
472 * would be good to do it for 3.0.0.
474 GtkIMHtmlScalable
*gtk_imhtml_animation_new(GdkPixbufAnimation
*img
, const gchar
*filename
, int id
);
477 * Destroys and frees a GTK+ IM/HTML scalable image.
479 * @param scale The GTK+ IM/HTML scalable.
481 /* TODO: Is there any reason this isn't private? */
482 void gtk_imhtml_image_free(GtkIMHtmlScalable
*scale
);
485 * Destroys and frees a GTK+ IM/HTML scalable animation.
487 * @param scale The GTK+ IM/HTML scalable.
489 /* TODO: Is there any reason this isn't private? */
490 void gtk_imhtml_animation_free(GtkIMHtmlScalable
*scale
);
493 * Rescales a GTK+ IM/HTML scalable image to a given size.
495 * @param scale The GTK+ IM/HTML scalable.
496 * @param width The new width.
497 * @param height The new height.
499 /* TODO: Is there any reason this isn't private? */
500 void gtk_imhtml_image_scale(GtkIMHtmlScalable
*scale
, int width
, int height
);
503 * Adds a GTK+ IM/HTML scalable image to a given GTK+ IM/HTML at a given iter.
505 * @param scale The GTK+ IM/HTML scalable.
506 * @param imhtml The GTK+ IM/HTML.
507 * @param iter The GtkTextIter at which to add the scalable.
509 /* TODO: Is there any reason this isn't private? */
510 void gtk_imhtml_image_add_to(GtkIMHtmlScalable
*scale
, GtkIMHtml
*imhtml
, GtkTextIter
*iter
);
513 * Creates and returns an new GTK+ IM/HTML scalable with a horizontal rule.
515 * @return A new IM/HTML Scalable object with an image.
517 GtkIMHtmlScalable
*gtk_imhtml_hr_new(void);
520 * Destroys and frees a GTK+ IM/HTML scalable horizontal rule.
522 * @param scale The GTK+ IM/HTML scalable.
524 void gtk_imhtml_hr_free(GtkIMHtmlScalable
*scale
);
527 * Rescales a GTK+ IM/HTML scalable horizontal rule to a given size.
529 * @param scale The GTK+ IM/HTML scalable.
530 * @param width The new width.
531 * @param height The new height.
533 void gtk_imhtml_hr_scale(GtkIMHtmlScalable
*scale
, int width
, int height
);
536 * Adds a GTK+ IM/HTML scalable horizontal rule to a given GTK+ IM/HTML at
539 * @param scale The GTK+ IM/HTML scalable.
540 * @param imhtml The GTK+ IM/HTML.
541 * @param iter The GtkTextIter at which to add the scalable.
543 void gtk_imhtml_hr_add_to(GtkIMHtmlScalable
*scale
, GtkIMHtml
*imhtml
, GtkTextIter
*iter
);
546 * Finds and highlights a given string in a GTK+ IM/HTML.
548 * @param imhtml The GTK+ IM/HTML.
549 * @param text The string to search for.
551 * @return @c TRUE if a search was performed, or @c FALSE if not.
553 gboolean
gtk_imhtml_search_find(GtkIMHtml
*imhtml
, const gchar
*text
);
556 * Clears the highlighting from a prior search in a GTK+ IM/HTML.
558 * @param imhtml The GTK+ IM/HTML.
560 void gtk_imhtml_search_clear(GtkIMHtml
*imhtml
);
563 * Enables or disables editing in a GTK+ IM/HTML.
565 * @param imhtml The GTK+ IM/HTML.
566 * @param editable @c TRUE to make the widget editable, or @c FALSE otherwise.
568 void gtk_imhtml_set_editable(GtkIMHtml
*imhtml
, gboolean editable
);
571 * Enables or disables whole buffer formatting only (wbfo) in a GTK+ IM/HTML.
572 * In this mode formatting options to the buffer take effect for the entire
573 * buffer instead of specific text.
575 * @param imhtml The GTK+ IM/HTML.
576 * @param wbfo @c TRUE to enable the mode, or @c FALSE otherwise.
578 void gtk_imhtml_set_whole_buffer_formatting_only(GtkIMHtml
*imhtml
, gboolean wbfo
);
581 * Indicates which formatting functions to enable and disable in a GTK+ IM/HTML.
583 * @param imhtml The GTK+ IM/HTML.
584 * @param buttons A GtkIMHtmlButtons bitmask indicating which functions to use.
586 void gtk_imhtml_set_format_functions(GtkIMHtml
*imhtml
, GtkIMHtmlButtons buttons
);
589 * Returns which formatting functions are enabled in a GTK+ IM/HTML.
591 * @param imhtml The GTK+ IM/HTML.
593 * @return A GtkIMHtmlButtons bitmask indicating which functions to are enabled.
595 GtkIMHtmlButtons
gtk_imhtml_get_format_functions(GtkIMHtml
*imhtml
);
598 * Sets each boolean to @c TRUE or @c FALSE to indicate if that formatting option
599 * is enabled at the current position in a GTK+ IM/HTML.
601 * @param imhtml The GTK+ IM/HTML.
602 * @param bold The boolean to set for bold or @c NULL.
603 * @param italic The boolean to set for italic or @c NULL.
604 * @param underline The boolean to set for underline or @c NULL.
606 void gtk_imhtml_get_current_format(GtkIMHtml
*imhtml
, gboolean
*bold
, gboolean
*italic
, gboolean
*underline
);
609 * Returns a string containing the selected font face at the current position
612 * @param imhtml The GTK+ IM/HTML.
614 * @return A string containg the font face or @c NULL if none is set.
616 char *gtk_imhtml_get_current_fontface(GtkIMHtml
*imhtml
);
619 * Returns a string containing the selected foreground color at the current
620 * position in a GTK+ IM/HTML.
622 * @param imhtml The GTK+ IM/HTML.
624 * @return A string containg the foreground color or @c NULL if none is set.
626 char *gtk_imhtml_get_current_forecolor(GtkIMHtml
*imhtml
);
629 * Returns a string containing the selected font background color at the current
630 * position in a GTK+ IM/HTML.
632 * @param imhtml The GTK+ IM/HTML.
634 * @return A string containg the font background color or @c NULL if none is set.
636 char *gtk_imhtml_get_current_backcolor(GtkIMHtml
*imhtml
);
639 * Returns a string containing the selected background color at the current
640 * position in a GTK+ IM/HTML.
642 * @param imhtml The GTK+ IM/HTML.
644 * @return A string containg the background color or @c NULL if none is set.
646 char *gtk_imhtml_get_current_background(GtkIMHtml
*imhtml
);
649 * Returns a integer containing the selected HTML font size at the current
650 * position in a GTK+ IM/HTML.
652 * @param imhtml The GTK+ IM/HTML.
654 * @return The HTML font size.
656 gint
gtk_imhtml_get_current_fontsize(GtkIMHtml
*imhtml
);
659 * Checks whether a GTK+ IM/HTML is marked as editable.
661 * @param imhtml The GTK+ IM/HTML.
663 * @return @c TRUE if the IM/HTML is editable, or @c FALSE otherwise.
665 gboolean
gtk_imhtml_get_editable(GtkIMHtml
*imhtml
);
668 * Clear all the formatting on a GTK+ IM/HTML.
670 * @param imhtml The GTK+ IM/HTML.
672 void gtk_imhtml_clear_formatting(GtkIMHtml
*imhtml
);
675 * Toggles bold at the cursor location or selection in a GTK+ IM/HTML.
677 * @param imhtml The GTK+ IM/HTML.
679 void gtk_imhtml_toggle_bold(GtkIMHtml
*imhtml
);
682 * Toggles italic at the cursor location or selection in a GTK+ IM/HTML.
684 * @param imhtml The GTK+ IM/HTML.
686 void gtk_imhtml_toggle_italic(GtkIMHtml
*imhtml
);
689 * Toggles underline at the cursor location or selection in a GTK+ IM/HTML.
691 * @param imhtml The GTK+ IM/HTML.
693 void gtk_imhtml_toggle_underline(GtkIMHtml
*imhtml
);
696 * Toggles strikethrough at the cursor location or selection in a GTK+ IM/HTML.
698 * @param imhtml The GTK+ IM/HTML.
700 void gtk_imhtml_toggle_strike(GtkIMHtml
*imhtml
);
703 * Toggles a foreground color at the current location or selection in a GTK
706 * @param imhtml The GTK+ IM/HTML.
707 * @param color The HTML-style color, or @c NULL or "" to clear the color.
709 * @return @c TRUE if a color was set, or @c FALSE if it was cleared.
711 gboolean
gtk_imhtml_toggle_forecolor(GtkIMHtml
*imhtml
, const char *color
);
714 * Toggles a background color at the current location or selection in a GTK
717 * @param imhtml The GTK+ IM/HTML.
718 * @param color The HTML-style color, or @c NULL or "" to clear the color.
720 * @return @c TRUE if a color was set, or @c FALSE if it was cleared.
722 gboolean
gtk_imhtml_toggle_backcolor(GtkIMHtml
*imhtml
, const char *color
);
725 * Toggles a background color at the current location or selection in a GTK
728 * @param imhtml The GTK+ IM/HTML.
729 * @param color The HTML-style color, or @c NULL or "" to clear the color.
731 * @return @c TRUE if a color was set, or @c FALSE if it was cleared.
733 gboolean
gtk_imhtml_toggle_background(GtkIMHtml
*imhtml
, const char *color
);
736 * Toggles a font face at the current location or selection in a GTK+ IM/HTML.
738 * @param imhtml The GTK+ IM/HTML.
739 * @param face The font face name, or @c NULL or "" to clear the font.
741 * @return @c TRUE if a font name was set, or @c FALSE if it was cleared.
743 gboolean
gtk_imhtml_toggle_fontface(GtkIMHtml
*imhtml
, const char *face
);
746 * Toggles a link tag with the given URL at the current location or selection
749 * @param imhtml The GTK+ IM/HTML.
750 * @param url The URL for the link or @c NULL to terminate the link.
752 void gtk_imhtml_toggle_link(GtkIMHtml
*imhtml
, const char *url
);
755 * Inserts a link to the given url at the given GtkTextMark in a GTK+ IM/HTML.
757 * @param imhtml The GTK+ IM/HTML.
758 * @param mark The GtkTextMark to insert the link at.
759 * @param url The URL for the link.
760 * @param text The string to use for the link description.
762 void gtk_imhtml_insert_link(GtkIMHtml
*imhtml
, GtkTextMark
*mark
, const char *url
, const char *text
);
765 * Inserts a smiley at the current location or selection in a GTK+ IM/HTML.
767 * @param imhtml The GTK+ IM/HTML.
768 * @param sml The category of the smiley.
769 * @param smiley The text of the smiley to insert.
771 void gtk_imhtml_insert_smiley(GtkIMHtml
*imhtml
, const char *sml
, char *smiley
);
773 * Inserts a smiley at the given iter in a GTK+ IM/HTML.
775 * @param imhtml The GTK+ IM/HTML.
776 * @param sml The category of the smiley.
777 * @param smiley The text of the smiley to insert.
778 * @param iter The GtkTextIter in the IM/HTML to insert the smiley at.
780 void gtk_imhtml_insert_smiley_at_iter(GtkIMHtml
*imhtml
, const char *sml
, char *smiley
, GtkTextIter
*iter
);
783 * Inserts the IM/HTML scalable image with the given id at the given iter in a
786 * @param imhtml The GTK+ IM/HTML.
787 * @param id The id of the IM/HTML scalable.
788 * @param iter The GtkTextIter in the IM/HTML to insert the image at.
790 void gtk_imhtml_insert_image_at_iter(GtkIMHtml
*imhtml
, int id
, GtkTextIter
*iter
);
793 * Sets the font size at the current location or selection in a GTK+ IM/HTML.
795 * @param imhtml The GTK+ IM/HTML.
796 * @param size The HTML font size to use.
798 void gtk_imhtml_font_set_size(GtkIMHtml
*imhtml
, gint size
);
801 * Decreases the font size by 1 at the current location or selection in a GTK
804 * @param imhtml The GTK+ IM/HTML.
806 void gtk_imhtml_font_shrink(GtkIMHtml
*imhtml
);
809 * Increases the font size by 1 at the current location or selection in a GTK
812 * @param imhtml The GTK+ IM/HTML.
814 void gtk_imhtml_font_grow(GtkIMHtml
*imhtml
);
817 * Returns the HTML formatted contents between two iters in a GTK+ IM/HTML.
819 * @param imhtml The GTK+ IM/HTML.
820 * @param start The GtkTextIter indicating the start point in the IM/HTML.
821 * @param end The GtkTextIter indicating the end point in the IM/HTML.
823 * @return A string containing the HTML formatted text.
825 char *gtk_imhtml_get_markup_range(GtkIMHtml
*imhtml
, GtkTextIter
*start
, GtkTextIter
*end
);
828 * Returns the entire HTML formatted contents of a GTK+ IM/HTML.
830 * @param imhtml The GTK+ IM/HTML.
832 * @return A string containing the HTML formatted text.
834 char *gtk_imhtml_get_markup(GtkIMHtml
*imhtml
);
837 * Returns a null terminated array of pointers to null terminated strings, each
838 * string for each line. g_strfreev() should be called to free it when done.
840 * @param imhtml The GTK+ IM/HTML.
842 * @return A null terminated array of null terminated HTML formatted strings.
844 char **gtk_imhtml_get_markup_lines(GtkIMHtml
*imhtml
);
847 * Returns the entire unformatted (plain text) contents of a GTK+ IM/HTML
848 * between two iters in a GTK+ IM/HTML.
850 * @param imhtml The GTK+ IM/HTML.
851 * @param start The GtkTextIter indicating the start point in the IM/HTML.
852 * @param stop The GtkTextIter indicating the end point in the IM/HTML.
854 * @return A string containing the unformatted text.
856 char *gtk_imhtml_get_text(GtkIMHtml
*imhtml
, GtkTextIter
*start
, GtkTextIter
*stop
);
859 * Setup formatting for an imhtml depending on the flags specified.
861 * @param imhtml The GTK+ IM/HTML.
862 * @param flags The connection flag which describes the allowed types of formatting.
866 void gtk_imhtml_setup_entry(GtkIMHtml
*imhtml
, PurpleConnectionFlags flags
);
869 * Create a new GtkIMHtmlSmiley.
871 * @param file The image file for the smiley
872 * @param shortcut The key shortcut for the smiley
873 * @param hide @c TRUE if the smiley should be hidden in the smiley dialog, @c FALSE otherwise
874 * @param flags The smiley flags
876 * @return The newly created smiley
879 GtkIMHtmlSmiley
*gtk_imhtml_smiley_create(const char *file
, const char *shortcut
, gboolean hide
,
880 GtkIMHtmlSmileyFlags flags
);
883 * Reload the image data for the smiley.
885 * @param smiley The smiley to reload
889 void gtk_imhtml_smiley_reload(GtkIMHtmlSmiley
*smiley
);
892 * Destroy a GtkIMHtmlSmiley.
894 * @param smiley The smiley to destroy
898 void gtk_imhtml_smiley_destroy(GtkIMHtmlSmiley
*smiley
);
901 * Register a protocol with the GtkIMHtml widget. Registering a protocol would
902 * allow certain text to be clickable.
904 * @param name The name of the protocol (e.g. http://)
905 * @param activate The callback to trigger when the protocol text is clicked.
906 * Removes any current protocol definition if @c NULL. The
907 * callback should return @c TRUE if the link was activated
908 * properly, @c FALSE otherwise.
909 * @param context_menu The callback to trigger when the context menu is popped
910 * up on the protocol text. The callback should return
911 * @c TRUE if the request for context menu was processed
912 * successfully, @c FALSE otherwise.
914 * @return @c TRUE if the protocol was successfully registered (or unregistered, when \a activate is @c NULL)
918 gboolean
gtk_imhtml_class_register_protocol(const char *name
,
919 gboolean (*activate
)(GtkIMHtml
*imhtml
, GtkIMHtmlLink
*link
),
920 gboolean (*context_menu
)(GtkIMHtml
*imhtml
, GtkIMHtmlLink
*link
, GtkWidget
*menu
));
923 * Get the URL associated with a link. This should be used by the IMHtml protocol-callbacks.
925 * @param link The GtkIMHtmlLink object sent to the callback functions
931 const char *gtk_imhtml_link_get_url(GtkIMHtmlLink
*link
);
934 * Get the GtkTextTag object (if any) associated with a particular link.
936 * @param link The GtkIMHtmlLink object sent to the callback functions
938 * @return The GtkTextTag object, or @c NULL
942 const GtkTextTag
*gtk_imhtml_link_get_text_tag(GtkIMHtmlLink
*link
);
945 * Activates a GtkIMHtmlLink object. This triggers the 'url-clicked' signal, marks the
946 * link as visited (when possible).
948 * @param link The GtkIMHtmlLink object sent to the callback functions
950 * @return @c TRUE if 'url-clicked' signal was emitted, @c FALSE otherwise.
954 gboolean
gtk_imhtml_link_activate(GtkIMHtmlLink
*link
);
957 * By default this widget intercepts presses of the "return" key and
958 * emits the "message_send" signal instead. If you don't want this
959 * behavior, and you want the standard GtkTextView behavior of
960 * inserting a newline into the buffer, then call this function.
962 * @param imhtml The GtkIMHtml where you want the "return" key to add
963 * newline and not emit the "message_send" signal.
965 void gtk_imhtml_set_return_inserts_newline(GtkIMHtml
*imhtml
);
968 * By default this widget populates the PRIMARY clipboard with any selected
969 * text (as you would expect). For scenarios (e.g. select-on-focus) where this
970 * would be problematic, this function can disable the PRIMARY population.
972 * @param imhtml The GtkIMHtml to enable/disable populating PRIMARY
973 * @param populate enable/disable PRIMARY population
975 void gtk_imhtml_set_populate_primary_clipboard(GtkIMHtml
*imhtml
, gboolean populate
);
983 #endif /* _PIDGINIMHTML_H_ */