Mercurial > pidgin.yaz
annotate src/gtkimhtml.h @ 8317:6f549c1d0829
[gaim-migrate @ 9041]
Because I won't be able to work on this until late this week at the earliest,
here's GtkIMHtmlToolbar. It's a composite widget that attaches to an editable
gtkimhtml and controls all the formatting with ease. All one has to do to get
a formattable, editable, gtkimhtml now is to replace a gtktextview with a
gtkimhtml (you can even leave all the other calls that control it as gtkimhtml
descends from gtktextview) throw one of these toolbars in there and
gtk_imhtml_toolbar_attach it to the gtkimhtml. That's what I did in the New
Away Message dialog. This would also be nice in gtkrequest.c and gtkpounce.c.
Of course, this isn't done and there's a ton of hacky commented out old code in
there. Things like keyboard shortcut preferences don't currently work and
there's a lot of things I want to move around yet. However, if anyone feels
inspired to work on it before I get back to it feel free. Maybe you can IM me
beforehand or something.
committer: Tailor Script <tailor@pidgin.im>
author | Sean Egan <seanegan@gmail.com> |
---|---|
date | Mon, 23 Feb 2004 21:18:27 +0000 |
parents | 42c7227d6e4d |
children | c25c697525b7 |
rev | line source |
---|---|
5034
4691c5936c01
[gaim-migrate @ 5377]
Christian Hammond <chipx86@chipx86.com>
parents:
5012
diff
changeset
|
1 /** |
5967 | 2 * @file gtkimhtml.h GTK+ IM/HTML rendering component |
5034
4691c5936c01
[gaim-migrate @ 5377]
Christian Hammond <chipx86@chipx86.com>
parents:
5012
diff
changeset
|
3 * @ingroup gtkui |
1428 | 4 * |
8046 | 5 * Gaim 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. | |
1428 | 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 | |
24 #ifndef __GTK_IMHTML_H | |
25 #define __GTK_IMHTML_H | |
26 | |
27 #include <gdk/gdk.h> | |
3922 | 28 #include <gtk/gtktextview.h> |
4735 | 29 #include <gtk/gtktooltips.h> |
5012 | 30 #include <gtk/gtkimage.h> |
1428 | 31 |
32 #ifdef __cplusplus | |
33 extern "C" { | |
34 #endif | |
35 | |
36 #define GTK_TYPE_IMHTML (gtk_imhtml_get_type ()) | |
37 #define GTK_IMHTML(obj) (GTK_CHECK_CAST ((obj), GTK_TYPE_IMHTML, GtkIMHtml)) | |
38 #define GTK_IMHTML_CLASS(klass) (GTK_CHECK_CLASS_CAST ((klass), GTK_TYPE_IMHTML, GtkIMHtmlClass)) | |
39 #define GTK_IS_IMHTML(obj) (GTK_CHECK_TYPE ((obj), GTK_TYPE_IMHTML)) | |
40 #define GTK_IS_IMHTML_CLASS(klass) (GTK_CHECK_CLASS_TYPE ((klass), GTK_TYPE_IMHTML)) | |
5967 | 41 #define GTK_IMHTML_SCALABLE(obj) ((GtkIMHtmlScalable *)obj) |
1428 | 42 |
5967 | 43 typedef struct _GtkIMHtml GtkIMHtml; |
44 typedef struct _GtkIMHtmlClass GtkIMHtmlClass; | |
45 typedef struct _GtkIMHtmlFontDetail GtkIMHtmlFontDetail; /* The five elements contained in a FONT tag */ | |
46 typedef struct _GtkSmileyTree GtkSmileyTree; | |
47 typedef struct _GtkIMHtmlSmiley GtkIMHtmlSmiley; | |
48 typedef struct _GtkIMHtmlScalable GtkIMHtmlScalable; | |
49 typedef struct _GtkIMHtmlImage GtkIMHtmlImage; | |
50 typedef struct _GtkIMHtmlHr GtkIMHtmlHr; | |
8061 | 51 |
52 | |
53 typedef struct { | |
54 GtkTextMark *start; | |
55 GtkTextMark *end; | |
56 char *start_tag; | |
57 char *end_tag; | |
58 GtkTextBuffer *buffer; | |
59 GtkTextTag *tag; | |
60 } GtkIMHtmlFormatSpan; | |
7694 | 61 |
1428 | 62 struct _GtkIMHtml { |
3922 | 63 GtkTextView text_view; |
64 GtkTextBuffer *text_buffer; | |
65 GtkTextMark *end; | |
66 gboolean comments, smileys; | |
1428 | 67 GdkCursor *hand_cursor; |
68 GdkCursor *arrow_cursor; | |
8061 | 69 GdkCursor *text_cursor; |
4032 | 70 GHashTable *smiley_data; |
71 GtkSmileyTree *default_smilies; | |
4254 | 72 |
73 gboolean show_smileys; | |
6124 | 74 gboolean show_comments; |
4735 | 75 |
76 GtkWidget *tip_window; | |
77 char *tip; | |
78 guint tip_timer; | |
4895 | 79 |
80 GList *scalables; | |
4947 | 81 GdkRectangle old_rect; |
7295 | 82 |
8061 | 83 gchar *search_string; |
7694 | 84 |
8061 | 85 gboolean editable; |
86 struct { | |
87 GtkIMHtmlFormatSpan *bold; | |
88 GtkIMHtmlFormatSpan *italic; | |
89 GtkIMHtmlFormatSpan *underline; | |
90 GtkIMHtmlFormatSpan *forecolor; | |
91 GtkIMHtmlFormatSpan *backcolor; | |
92 GtkIMHtmlFormatSpan *fontface; | |
93 GtkIMHtmlFormatSpan *sizespan; | |
94 int fontsize; | |
95 } edit; | |
96 char *clipboard_string; | |
97 GList *format_spans; | |
1428 | 98 }; |
99 | |
100 struct _GtkIMHtmlClass { | |
3922 | 101 GtkTextViewClass parent_class; |
1428 | 102 |
5967 | 103 void (*url_clicked)(GtkIMHtml *, const gchar *); |
104 }; | |
105 | |
106 struct _GtkIMHtmlFontDetail { | |
107 gushort size; | |
108 gchar *face; | |
109 gchar *fore; | |
110 gchar *back; | |
111 gchar *sml; | |
112 }; | |
113 | |
114 struct _GtkSmileyTree { | |
115 GString *values; | |
116 GtkSmileyTree **children; | |
117 GtkIMHtmlSmiley *image; | |
1428 | 118 }; |
119 | |
4263 | 120 struct _GtkIMHtmlSmiley { |
121 gchar *smile; | |
122 gchar *file; | |
6814
782907a6ae65
[gaim-migrate @ 7354]
Christian Hammond <chipx86@chipx86.com>
parents:
6282
diff
changeset
|
123 GdkPixbufAnimation *icon; |
4263 | 124 gboolean hidden; |
125 }; | |
126 | |
5967 | 127 struct _GtkIMHtmlScalable { |
4895 | 128 void (*scale)(struct _GtkIMHtmlScalable *, int, int); |
129 void (*add_to)(struct _GtkIMHtmlScalable *, GtkIMHtml *, GtkTextIter *); | |
130 void (*free)(struct _GtkIMHtmlScalable *); | |
131 }; | |
132 | |
5967 | 133 struct _GtkIMHtmlImage { |
4895 | 134 GtkIMHtmlScalable scalable; |
5012 | 135 GtkImage *image; |
5046 | 136 GdkPixbuf *pixbuf; |
4895 | 137 GtkTextMark *mark; |
5012 | 138 gchar *filename; |
4895 | 139 int width; |
140 int height; | |
5967 | 141 }; |
4895 | 142 |
5967 | 143 struct _GtkIMHtmlHr { |
4895 | 144 GtkIMHtmlScalable scalable; |
145 GtkWidget *sep; | |
5967 | 146 }; |
147 | |
148 typedef enum { | |
149 GTK_IMHTML_NO_COLOURS = 1 << 0, | |
150 GTK_IMHTML_NO_FONTS = 1 << 1, | |
8105 | 151 GTK_IMHTML_NO_COMMENTS = 1 << 2, /* Remove */ |
5967 | 152 GTK_IMHTML_NO_TITLE = 1 << 3, |
153 GTK_IMHTML_NO_NEWLINE = 1 << 4, | |
154 GTK_IMHTML_NO_SIZES = 1 << 5, | |
155 GTK_IMHTML_NO_SCROLL = 1 << 6, | |
156 GTK_IMHTML_RETURN_LOG = 1 << 7, | |
157 GTK_IMHTML_USE_POINTSIZE = 1 << 8 | |
158 } GtkIMHtmlOptions; | |
159 | |
160 GtkType gtk_imhtml_get_type (void); | |
161 GtkWidget* gtk_imhtml_new (void *, void *); | |
162 | |
163 void gtk_imhtml_set_adjustments (GtkIMHtml *imhtml, | |
164 GtkAdjustment *hadj, | |
165 GtkAdjustment *vadj); | |
166 | |
167 void gtk_imhtml_associate_smiley (GtkIMHtml *imhtml, | |
168 gchar *sml, GtkIMHtmlSmiley *smiley); | |
169 | |
170 void gtk_imhtml_remove_smileys (GtkIMHtml *imhtml); | |
171 | |
172 void gtk_imhtml_show_smileys (GtkIMHtml *imhtml, gboolean show); | |
173 | |
174 void gtk_imhtml_show_comments (GtkIMHtml *imhtml, gboolean show); | |
175 | |
6982 | 176 #define gtk_imhtml_append_text(x, y, z) \ |
177 gtk_imhtml_append_text_with_images(x, y, z, NULL) | |
178 | |
179 GString* gtk_imhtml_append_text_with_images (GtkIMHtml *imhtml, | |
180 const gchar *text, | |
181 GtkIMHtmlOptions options, | |
182 GSList *images); | |
5967 | 183 |
184 void gtk_imhtml_clear (GtkIMHtml *imhtml); | |
185 void gtk_imhtml_page_up (GtkIMHtml *imhtml); | |
186 void gtk_imhtml_page_down (GtkIMHtml *imhtml); | |
4895 | 187 |
188 GtkIMHtmlScalable *gtk_imhtml_scalable_new(); | |
6982 | 189 GtkIMHtmlScalable *gtk_imhtml_image_new(GdkPixbuf *img, const gchar *filename); |
5967 | 190 void gtk_imhtml_image_free(GtkIMHtmlScalable *); |
191 void gtk_imhtml_image_scale(GtkIMHtmlScalable *, int, int); | |
192 void gtk_imhtml_image_add_to(GtkIMHtmlScalable *, GtkIMHtml *, GtkTextIter *); | |
4895 | 193 |
5967 | 194 GtkIMHtmlScalable *gtk_imhtml_hr_new(); |
195 void gtk_imhtml_hr_free(GtkIMHtmlScalable *); | |
196 void gtk_imhtml_hr_scale(GtkIMHtmlScalable *, int, int); | |
197 void gtk_imhtml_hr_add_to(GtkIMHtmlScalable *, GtkIMHtml *, GtkTextIter *); | |
4895 | 198 |
7295 | 199 /* Search functions */ |
200 gboolean gtk_imhtml_search_find(GtkIMHtml *imhtml, const gchar *text); | |
201 void gtk_imhtml_search_clear(GtkIMHtml *imhtml); | |
4895 | 202 |
8061 | 203 /* Editable stuff */ |
204 void gtk_imhtml_set_editable(GtkIMHtml *imhtml, gboolean editable); | |
205 gboolean gtk_imhtml_get_editable(GtkIMHtml *imhtml); | |
206 gboolean gtk_imhtml_toggle_bold(GtkIMHtml *imhtml); | |
207 gboolean gtk_imhtml_toggle_italic(GtkIMHtml *imhtml); | |
208 gboolean gtk_imhtml_toggle_underline(GtkIMHtml *imhtml); | |
209 gboolean gtk_imhtml_toggle_forecolor(GtkIMHtml *imhtml, const char *color); | |
210 gboolean gtk_imhtml_toggle_backcolor(GtkIMHtml *imhtml, const char *color); | |
211 gboolean gtk_imhtml_toggle_fontface(GtkIMHtml *imhtml, const char *face); | |
212 void gtk_imhtml_insert_link(GtkIMHtml *imhtml, const char *url, const char *text); | |
213 void gtk_imhtml_insert_smiley(GtkIMHtml *imhtml, const char *sml, char *smiley); | |
214 void gtk_imhtml_font_set_size(GtkIMHtml *imhtml, gint size); | |
215 void gtk_imhtml_font_shrink(GtkIMHtml *imhtml); | |
216 void gtk_imhtml_font_grow(GtkIMHtml *imhtml); | |
217 char *gtk_imhtml_get_markup_range(GtkIMHtml *imhtml, GtkTextIter *start, GtkTextIter *end); | |
218 char *gtk_imhtml_get_markup(GtkIMHtml *imhtml); | |
219 char *gtk_imhtml_get_text(GtkIMHtml *imhtml); | |
220 | |
1428 | 221 #ifdef __cplusplus |
222 } | |
223 #endif | |
224 | |
225 #endif |