pidgin/gtkimhtml.h

changeset 32710
e07993a28f20
parent 32656
d26e0b6b9d2c
child 32790
b95c7c504118
equal deleted inserted replaced
32056:5ecbc7cf4ee1 32710:e07993a28f20
48 #define GTK_IMHTML_SCALABLE(obj) ((GtkIMHtmlScalable *)obj) 48 #define GTK_IMHTML_SCALABLE(obj) ((GtkIMHtmlScalable *)obj)
49 #define GTK_IMHTML_ANIMATION(obj) ((GtkIMHtmlAnimation *)obj) 49 #define GTK_IMHTML_ANIMATION(obj) ((GtkIMHtmlAnimation *)obj)
50 50
51 typedef struct _GtkIMHtml GtkIMHtml; 51 typedef struct _GtkIMHtml GtkIMHtml;
52 typedef struct _GtkIMHtmlClass GtkIMHtmlClass; 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 */
55 #endif
56 typedef struct _GtkSmileyTree GtkSmileyTree; 53 typedef struct _GtkSmileyTree GtkSmileyTree;
57 typedef struct _GtkIMHtmlSmiley GtkIMHtmlSmiley; 54 typedef struct _GtkIMHtmlSmiley GtkIMHtmlSmiley;
58 typedef struct _GtkIMHtmlScalable GtkIMHtmlScalable; 55 typedef struct _GtkIMHtmlScalable GtkIMHtmlScalable;
59 typedef struct _GtkIMHtmlImage GtkIMHtmlImage; 56 typedef struct _GtkIMHtmlImage GtkIMHtmlImage;
60 typedef struct _GtkIMHtmlAnimation GtkIMHtmlAnimation; 57 typedef struct _GtkIMHtmlAnimation GtkIMHtmlAnimation;
61 typedef struct _GtkIMHtmlHr GtkIMHtmlHr; 58 typedef struct _GtkIMHtmlHr GtkIMHtmlHr;
62 typedef struct _GtkIMHtmlFuncs GtkIMHtmlFuncs; 59 typedef struct _GtkIMHtmlFuncs GtkIMHtmlFuncs;
63 60
64 /**
65 * @since 2.6.0
66 */
67 typedef struct _GtkIMHtmlLink GtkIMHtmlLink; 61 typedef struct _GtkIMHtmlLink GtkIMHtmlLink;
68 62
69 typedef enum { 63 typedef enum {
70 GTK_IMHTML_BOLD = 1 << 0, 64 GTK_IMHTML_BOLD = 1 << 0,
71 GTK_IMHTML_ITALIC = 1 << 1, 65 GTK_IMHTML_ITALIC = 1 << 1,
79 GTK_IMHTML_LINK = 1 << 9, 73 GTK_IMHTML_LINK = 1 << 9,
80 GTK_IMHTML_IMAGE = 1 << 10, 74 GTK_IMHTML_IMAGE = 1 << 10,
81 GTK_IMHTML_SMILEY = 1 << 11, 75 GTK_IMHTML_SMILEY = 1 << 11,
82 GTK_IMHTML_LINKDESC = 1 << 12, 76 GTK_IMHTML_LINKDESC = 1 << 12,
83 GTK_IMHTML_STRIKE = 1 << 13, 77 GTK_IMHTML_STRIKE = 1 << 13,
84 /** Show custom smileys when appropriate. @since 2.5.0 */ 78 /** Show custom smileys when appropriate. */
85 GTK_IMHTML_CUSTOM_SMILEY = 1 << 14, 79 GTK_IMHTML_CUSTOM_SMILEY = 1 << 14,
86 GTK_IMHTML_ALL = -1 80 GTK_IMHTML_ALL = -1
87 } GtkIMHtmlButtons; 81 } GtkIMHtmlButtons;
88 82
89 typedef enum { 83 typedef enum {
133 gchar *fontface; 127 gchar *fontface;
134 int fontsize; 128 int fontsize;
135 GtkTextTag *link; 129 GtkTextTag *link;
136 } edit; 130 } edit;
137 131
138 #if !(defined PIDGIN_DISABLE_DEPRECATED) || (defined _PIDGIN_GTKIMHTML_C_)
139 /** @deprecated */
140 char *clipboard_text_string;
141 /** @deprecated */
142 char *clipboard_html_string;
143 #else
144 char *depr1;
145 char *depr2;
146 #endif
147
148 GSList *im_images; 132 GSList *im_images;
149 GtkIMHtmlFuncs *funcs; 133 GtkIMHtmlFuncs *funcs;
150 GtkSourceUndoManager *undo_manager; 134 GtkSourceUndoManager *undo_manager;
151 }; 135 };
152 136
162 void (*undo)(GtkIMHtml *); 146 void (*undo)(GtkIMHtml *);
163 void (*redo)(GtkIMHtml *); 147 void (*redo)(GtkIMHtml *);
164 GList *protocols; /* List of GtkIMHtmlProtocol's */ 148 GList *protocols; /* List of GtkIMHtmlProtocol's */
165 }; 149 };
166 150
167 #if !(defined PIDGIN_DISABLE_DEPRECATED) && !(defined _PIDGIN_GTKIMHTML_C_)
168 /** @deprecated as of 2.7.10 */
169 struct _GtkIMHtmlFontDetail {
170 gushort size;
171 gchar *face;
172 gchar *fore;
173 gchar *back;
174 gchar *bg;
175 gchar *sml;
176 gboolean underline;
177 gshort bold;
178 };
179 #endif
180
181 struct _GtkSmileyTree {
182 GString *values;
183 GtkSmileyTree **children;
184 GtkIMHtmlSmiley *image;
185 };
186
187 struct _GtkIMHtmlSmiley { 151 struct _GtkIMHtmlSmiley {
188 gchar *smile; 152 gchar *smile;
189 gchar *file; 153 gchar *file;
190 GdkPixbufAnimation *icon; 154 GdkPixbufAnimation *icon;
191 gboolean hidden; 155 gboolean hidden;
192 GdkPixbufLoader *loader; 156 GdkPixbufLoader *loader;
193 GSList *anchors; 157 GSList *anchors;
194 GtkIMHtmlSmileyFlags flags; 158 GtkIMHtmlSmileyFlags flags;
195 GtkIMHtml *imhtml; 159 GtkIMHtml *imhtml;
196 gpointer data; /** @since 2.6.0 */ 160 gpointer data;
197 gsize datasize; /** @since 2.6.0 */ 161 gsize datasize;
198 };
199
200 struct _GtkIMHtmlScalable {
201 void (*scale)(struct _GtkIMHtmlScalable *, int, int);
202 void (*add_to)(struct _GtkIMHtmlScalable *, GtkIMHtml *, GtkTextIter *);
203 void (*free)(struct _GtkIMHtmlScalable *);
204 };
205
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. */
210 GtkTextMark *mark;
211 gchar *filename;
212 int width;
213 int height;
214 int id;
215 GtkWidget *filesel;
216 };
217
218 struct _GtkIMHtmlAnimation {
219 GtkIMHtmlImage imhtmlimage;
220 GdkPixbufAnimation *anim; /**< The original animation, before any scaling. */
221 GdkPixbufAnimationIter *iter;
222 guint timer;
223 };
224
225 struct _GtkIMHtmlHr {
226 GtkIMHtmlScalable scalable;
227 GtkWidget *sep;
228 }; 162 };
229 163
230 typedef enum { 164 typedef enum {
231 GTK_IMHTML_NO_COLOURS = 1 << 0, 165 GTK_IMHTML_NO_COLOURS = 1 << 0,
232 GTK_IMHTML_NO_FONTS = 1 << 1, 166 GTK_IMHTML_NO_FONTS = 1 << 1,
441 * @return A new IM/HTML Scalable object. 375 * @return A new IM/HTML Scalable object.
442 */ 376 */
443 GtkIMHtmlScalable *gtk_imhtml_scalable_new(void); 377 GtkIMHtmlScalable *gtk_imhtml_scalable_new(void);
444 378
445 /** 379 /**
446 * Creates and returns a new GTK+ IM/HTML scalable object with an image.
447 *
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.
451 *
452 * @return A new IM/HTML Scalable object with an image.
453 */
454 GtkIMHtmlScalable *gtk_imhtml_image_new(GdkPixbuf *img, const gchar *filename, int id);
455
456 /**
457 * Creates and returns a new GTK+ IM/HTML scalable object with an
458 * animated image.
459 *
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.
463 *
464 * @return A new IM/HTML Scalable object with an image.
465 *
466 * @since 2.1.0
467 */
468 /*
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.
473 */
474 GtkIMHtmlScalable *gtk_imhtml_animation_new(GdkPixbufAnimation *img, const gchar *filename, int id);
475
476 /**
477 * Destroys and frees a GTK+ IM/HTML scalable image.
478 *
479 * @param scale The GTK+ IM/HTML scalable.
480 */
481 /* TODO: Is there any reason this isn't private? */
482 void gtk_imhtml_image_free(GtkIMHtmlScalable *scale);
483
484 /**
485 * Destroys and frees a GTK+ IM/HTML scalable animation.
486 *
487 * @param scale The GTK+ IM/HTML scalable.
488 */
489 /* TODO: Is there any reason this isn't private? */
490 void gtk_imhtml_animation_free(GtkIMHtmlScalable *scale);
491
492 /**
493 * Rescales a GTK+ IM/HTML scalable image to a given size.
494 *
495 * @param scale The GTK+ IM/HTML scalable.
496 * @param width The new width.
497 * @param height The new height.
498 */
499 /* TODO: Is there any reason this isn't private? */
500 void gtk_imhtml_image_scale(GtkIMHtmlScalable *scale, int width, int height);
501
502 /**
503 * Adds a GTK+ IM/HTML scalable image to a given GTK+ IM/HTML at a given iter.
504 *
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.
508 */
509 /* TODO: Is there any reason this isn't private? */
510 void gtk_imhtml_image_add_to(GtkIMHtmlScalable *scale, GtkIMHtml *imhtml, GtkTextIter *iter);
511
512 /**
513 * Creates and returns an new GTK+ IM/HTML scalable with a horizontal rule. 380 * Creates and returns an new GTK+ IM/HTML scalable with a horizontal rule.
514 * 381 *
515 * @return A new IM/HTML Scalable object with an image. 382 * @return A new IM/HTML Scalable object with an image.
516 */ 383 */
517 GtkIMHtmlScalable *gtk_imhtml_hr_new(void); 384 GtkIMHtmlScalable *gtk_imhtml_hr_new(void);
858 /** 725 /**
859 * Setup formatting for an imhtml depending on the flags specified. 726 * Setup formatting for an imhtml depending on the flags specified.
860 * 727 *
861 * @param imhtml The GTK+ IM/HTML. 728 * @param imhtml The GTK+ IM/HTML.
862 * @param flags The connection flag which describes the allowed types of formatting. 729 * @param flags The connection flag which describes the allowed types of formatting.
863 *
864 * @since 2.1.0
865 */ 730 */
866 void gtk_imhtml_setup_entry(GtkIMHtml *imhtml, PurpleConnectionFlags flags); 731 void gtk_imhtml_setup_entry(GtkIMHtml *imhtml, PurpleConnectionFlags flags);
867 732
868 /** 733 /**
869 * Create a new GtkIMHtmlSmiley. 734 * Create a new GtkIMHtmlSmiley.
872 * @param shortcut The key shortcut for the smiley 737 * @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 738 * @param hide @c TRUE if the smiley should be hidden in the smiley dialog, @c FALSE otherwise
874 * @param flags The smiley flags 739 * @param flags The smiley flags
875 * 740 *
876 * @return The newly created smiley 741 * @return The newly created smiley
877 * @since 2.5.0
878 */ 742 */
879 GtkIMHtmlSmiley *gtk_imhtml_smiley_create(const char *file, const char *shortcut, gboolean hide, 743 GtkIMHtmlSmiley *gtk_imhtml_smiley_create(const char *file, const char *shortcut, gboolean hide,
880 GtkIMHtmlSmileyFlags flags); 744 GtkIMHtmlSmileyFlags flags);
881 745
882 /** 746 /**
883 * Reload the image data for the smiley. 747 * Reload the image data for the smiley.
884 * 748 *
885 * @param smiley The smiley to reload 749 * @param smiley The smiley to reload
886 *
887 * @since 2.5.0
888 */ 750 */
889 void gtk_imhtml_smiley_reload(GtkIMHtmlSmiley *smiley); 751 void gtk_imhtml_smiley_reload(GtkIMHtmlSmiley *smiley);
890 752
891 /** 753 /**
892 * Destroy a GtkIMHtmlSmiley. 754 * Destroy a GtkIMHtmlSmiley.
893 * 755 *
894 * @param smiley The smiley to destroy 756 * @param smiley The smiley to destroy
895 *
896 * @since 2.5.0
897 */ 757 */
898 void gtk_imhtml_smiley_destroy(GtkIMHtmlSmiley *smiley); 758 void gtk_imhtml_smiley_destroy(GtkIMHtmlSmiley *smiley);
899 759
900 /** 760 /**
901 * Register a protocol with the GtkIMHtml widget. Registering a protocol would 761 * Register a protocol with the GtkIMHtml widget. Registering a protocol would
910 * up on the protocol text. The callback should return 770 * up on the protocol text. The callback should return
911 * @c TRUE if the request for context menu was processed 771 * @c TRUE if the request for context menu was processed
912 * successfully, @c FALSE otherwise. 772 * successfully, @c FALSE otherwise.
913 * 773 *
914 * @return @c TRUE if the protocol was successfully registered (or unregistered, when \a activate is @c NULL) 774 * @return @c TRUE if the protocol was successfully registered (or unregistered, when \a activate is @c NULL)
915 *
916 * @since 2.6.0
917 */ 775 */
918 gboolean gtk_imhtml_class_register_protocol(const char *name, 776 gboolean gtk_imhtml_class_register_protocol(const char *name,
919 gboolean (*activate)(GtkIMHtml *imhtml, GtkIMHtmlLink *link), 777 gboolean (*activate)(GtkIMHtml *imhtml, GtkIMHtmlLink *link),
920 gboolean (*context_menu)(GtkIMHtml *imhtml, GtkIMHtmlLink *link, GtkWidget *menu)); 778 gboolean (*context_menu)(GtkIMHtml *imhtml, GtkIMHtmlLink *link, GtkWidget *menu));
921 779
923 * Get the URL associated with a link. This should be used by the IMHtml protocol-callbacks. 781 * Get the URL associated with a link. This should be used by the IMHtml protocol-callbacks.
924 * 782 *
925 * @param link The GtkIMHtmlLink object sent to the callback functions 783 * @param link The GtkIMHtmlLink object sent to the callback functions
926 * 784 *
927 * @return The URL 785 * @return The URL
928 *
929 * @since 2.6.0
930 */ 786 */
931 const char *gtk_imhtml_link_get_url(GtkIMHtmlLink *link); 787 const char *gtk_imhtml_link_get_url(GtkIMHtmlLink *link);
932 788
933 /** 789 /**
934 * Get the GtkTextTag object (if any) associated with a particular link. 790 * Get the GtkTextTag object (if any) associated with a particular link.
935 * 791 *
936 * @param link The GtkIMHtmlLink object sent to the callback functions 792 * @param link The GtkIMHtmlLink object sent to the callback functions
937 * 793 *
938 * @return The GtkTextTag object, or @c NULL 794 * @return The GtkTextTag object, or @c NULL
939 *
940 * @since 2.6.0
941 */ 795 */
942 const GtkTextTag *gtk_imhtml_link_get_text_tag(GtkIMHtmlLink *link); 796 const GtkTextTag *gtk_imhtml_link_get_text_tag(GtkIMHtmlLink *link);
943 797
944 /** 798 /**
945 * Activates a GtkIMHtmlLink object. This triggers the 'url-clicked' signal, marks the 799 * Activates a GtkIMHtmlLink object. This triggers the 'url-clicked' signal, marks the
946 * link as visited (when possible). 800 * link as visited (when possible).
947 * 801 *
948 * @param link The GtkIMHtmlLink object sent to the callback functions 802 * @param link The GtkIMHtmlLink object sent to the callback functions
949 * 803 *
950 * @return @c TRUE if 'url-clicked' signal was emitted, @c FALSE otherwise. 804 * @return @c TRUE if 'url-clicked' signal was emitted, @c FALSE otherwise.
951 *
952 * @since 2.6.0
953 */ 805 */
954 gboolean gtk_imhtml_link_activate(GtkIMHtmlLink *link); 806 gboolean gtk_imhtml_link_activate(GtkIMHtmlLink *link);
955 807
956 /** 808 /**
957 * By default this widget intercepts presses of the "return" key and 809 * By default this widget intercepts presses of the "return" key and

mercurial