Fri, 27 Jul 2007 08:34:40 +0000
- tls_peers certmgr now responds to certificate-stored,
certificate-deleted signals
| 1428 | 1 | /* |
|
10297
b36800725b7a
[gaim-migrate @ 11480]
Evan Schoenberg <evands@pidgin.im>
parents:
10243
diff
changeset
|
2 | * @file gtkimhtml.c GTK+ IMHtml |
|
16254
eeb2bba4dc94
Rename the Doxygen group from gtkui to pidgin.
Richard Laager <rlaager@pidgin.im>
parents:
16144
diff
changeset
|
3 | * @ingroup pidgin |
|
10297
b36800725b7a
[gaim-migrate @ 11480]
Evan Schoenberg <evands@pidgin.im>
parents:
10243
diff
changeset
|
4 | * |
|
15931
716b5fac1895
Re-sed the copyright notices so they don't all talk about Purple.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
5 | * pidgin |
| 1428 | 6 | * |
|
15931
716b5fac1895
Re-sed the copyright notices so they don't all talk about Purple.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
7 | * Pidgin is the legal property of its developers, whose names are too numerous |
| 8046 | 8 | * to list here. Please refer to the COPYRIGHT file distributed with this |
| 9 | * source distribution. | |
| 1428 | 10 | * |
| 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. | |
| 15 | * | |
| 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. | |
| 20 | * | |
| 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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
| 24 | * | |
| 25 | */ | |
| 26 | ||
|
2541
0afd3aaba327
[gaim-migrate @ 2554]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2365
diff
changeset
|
27 | #ifdef HAVE_CONFIG_H |
|
0afd3aaba327
[gaim-migrate @ 2554]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2365
diff
changeset
|
28 | #include <config.h> |
|
0afd3aaba327
[gaim-migrate @ 2554]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2365
diff
changeset
|
29 | #endif |
|
18119
699d876e3db0
Include pidgin.h to make this compile.
Richard Laager <rlaager@pidgin.im>
parents:
18108
diff
changeset
|
30 | |
|
18633
34ba43198355
Fix the win32 build. Thanks to Etan and Lee Roach. Fixes #1929.
Daniel Atallah <datallah@pidgin.im>
parents:
18552
diff
changeset
|
31 | #include "internal.h" |
|
18119
699d876e3db0
Include pidgin.h to make this compile.
Richard Laager <rlaager@pidgin.im>
parents:
18108
diff
changeset
|
32 | #include "pidgin.h" |
|
699d876e3db0
Include pidgin.h to make this compile.
Richard Laager <rlaager@pidgin.im>
parents:
18108
diff
changeset
|
33 | |
| 8526 | 34 | #include "debug.h" |
| 8091 | 35 | #include "util.h" |
| 1428 | 36 | #include "gtkimhtml.h" |
| 7358 | 37 | #include "gtksourceiter.h" |
|
17880
5e73968467e0
Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@pidgin.im>
parents:
17288
diff
changeset
|
38 | #include "gtksourceundomanager.h" |
|
5e73968467e0
Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@pidgin.im>
parents:
17288
diff
changeset
|
39 | #include "gtksourceview-marshal.h" |
| 1428 | 40 | #include <gtk/gtk.h> |
| 4895 | 41 | #include <glib/gerror.h> |
| 4046 | 42 | #include <gdk/gdkkeysyms.h> |
| 1428 | 43 | #include <string.h> |
| 44 | #include <ctype.h> | |
| 45 | #include <stdio.h> | |
|
4629
7ac4830de853
[gaim-migrate @ 4920]
Mark Doliner <markdoliner@pidgin.im>
parents:
4612
diff
changeset
|
46 | #include <stdlib.h> |
| 1428 | 47 | #include <math.h> |
|
2541
0afd3aaba327
[gaim-migrate @ 2554]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2365
diff
changeset
|
48 | #ifdef HAVE_LANGINFO_CODESET |
|
0afd3aaba327
[gaim-migrate @ 2554]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2365
diff
changeset
|
49 | #include <langinfo.h> |
|
0afd3aaba327
[gaim-migrate @ 2554]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2365
diff
changeset
|
50 | #include <locale.h> |
|
0afd3aaba327
[gaim-migrate @ 2554]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2365
diff
changeset
|
51 | #endif |
| 8692 | 52 | #ifdef _WIN32 |
|
10901
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
53 | #include <gdk/gdkwin32.h> |
| 8692 | 54 | #include <windows.h> |
| 55 | #endif | |
| 1428 | 56 | |
| 4735 | 57 | #include <pango/pango-font.h> |
| 58 | ||
| 15577 | 59 | /* GTK+ < 2.4.x hack, see pidgin.h for details. */ |
|
10062
144767f0643a
[gaim-migrate @ 11037]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10016
diff
changeset
|
60 | #if (!GTK_CHECK_VERSION(2,4,0)) |
|
5105
3565a4c4de6a
[gaim-migrate @ 5468]
David J. Brigada <brigada@prism.net>
parents:
5104
diff
changeset
|
61 | #define GTK_WRAP_WORD_CHAR GTK_WRAP_WORD |
|
3565a4c4de6a
[gaim-migrate @ 5468]
David J. Brigada <brigada@prism.net>
parents:
5104
diff
changeset
|
62 | #endif |
|
3565a4c4de6a
[gaim-migrate @ 5468]
David J. Brigada <brigada@prism.net>
parents:
5104
diff
changeset
|
63 | |
| 4735 | 64 | #define TOOLTIP_TIMEOUT 500 |
| 65 | ||
| 8786 | 66 | /* GTK+ 2.0 hack */ |
| 67 | #if (!GTK_CHECK_VERSION(2,2,0)) | |
| 68 | #define gtk_widget_get_clipboard(x, y) gtk_clipboard_get(y) | |
| 69 | #endif | |
| 70 | ||
| 10100 | 71 | static GtkTextViewClass *parent_class = NULL; |
| 72 | ||
|
11224
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
73 | struct scalable_data { |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
74 | GtkIMHtmlScalable *scalable; |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
75 | GtkTextMark *mark; |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
76 | }; |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
77 | |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
78 | |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
79 | struct im_image_data { |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
80 | int id; |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
81 | GtkTextMark *mark; |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
82 | }; |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
83 | |
| 9300 | 84 | static gboolean |
| 85 | gtk_text_view_drag_motion (GtkWidget *widget, | |
| 86 | GdkDragContext *context, | |
| 87 | gint x, | |
| 88 | gint y, | |
| 89 | guint time); | |
| 90 | ||
| 8677 | 91 | static void preinsert_cb(GtkTextBuffer *buffer, GtkTextIter *iter, gchar *text, gint len, GtkIMHtml *imhtml); |
| 8061 | 92 | static void insert_cb(GtkTextBuffer *buffer, GtkTextIter *iter, gchar *text, gint len, GtkIMHtml *imhtml); |
|
12673
4c8a20955e0b
[gaim-migrate @ 15016]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12672
diff
changeset
|
93 | static void delete_cb(GtkTextBuffer *buffer, GtkTextIter *iter, GtkTextIter *end, GtkIMHtml *imhtml); |
| 10169 | 94 | static void insert_ca_cb(GtkTextBuffer *buffer, GtkTextIter *arg1, GtkTextChildAnchor *arg2, gpointer user_data); |
| 95 | static void gtk_imhtml_apply_tags_on_insert(GtkIMHtml *imhtml, GtkTextIter *start, GtkTextIter *end); | |
| 8698 | 96 | void gtk_imhtml_close_tags(GtkIMHtml *imhtml, GtkTextIter *iter); |
| 9300 | 97 | static void gtk_imhtml_link_drop_cb(GtkWidget *widget, GdkDragContext *context, gint x, gint y, guint time, gpointer user_data); |
| 8091 | 98 | static void gtk_imhtml_link_drag_rcv_cb(GtkWidget *widget, GdkDragContext *dc, guint x, guint y, GtkSelectionData *sd, guint info, guint t, GtkIMHtml *imhtml); |
| 8677 | 99 | static void mark_set_cb(GtkTextBuffer *buffer, GtkTextIter *arg1, GtkTextMark *mark, GtkIMHtml *imhtml); |
| 8931 | 100 | static void hijack_menu_cb(GtkIMHtml *imhtml, GtkMenu *menu, gpointer data); |
| 101 | static void paste_received_cb (GtkClipboard *clipboard, GtkSelectionData *selection_data, gpointer data); | |
| 102 | static void paste_plaintext_received_cb (GtkClipboard *clipboard, const gchar *text, gpointer data); | |
|
10901
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
103 | static void imhtml_paste_insert(GtkIMHtml *imhtml, const char *text, gboolean plaintext); |
|
11267
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
104 | static void imhtml_toggle_bold(GtkIMHtml *imhtml); |
|
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
105 | static void imhtml_toggle_italic(GtkIMHtml *imhtml); |
|
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
106 | static void imhtml_toggle_strike(GtkIMHtml *imhtml); |
|
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
107 | static void imhtml_toggle_underline(GtkIMHtml *imhtml); |
|
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
108 | static void imhtml_font_grow(GtkIMHtml *imhtml); |
|
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
109 | static void imhtml_font_shrink(GtkIMHtml *imhtml); |
|
12672
673e2a1d2954
[gaim-migrate @ 15015]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12635
diff
changeset
|
110 | static void imhtml_clear_formatting(GtkIMHtml *imhtml); |
| 8061 | 111 | |
|
10899
87d9aec5b72d
[gaim-migrate @ 12619]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10871
diff
changeset
|
112 | /* POINT_SIZE converts from AIM font sizes to a point size scale factor. */ |
| 3922 | 113 | #define MAX_FONT_SIZE 7 |
|
10900
cc19dfd83910
[gaim-migrate @ 12621]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10899
diff
changeset
|
114 | #define POINT_SIZE(x) (_point_sizes [MIN ((x > 0 ? x : 1), MAX_FONT_SIZE) - 1]) |
| 14741 | 115 | static gdouble _point_sizes [] = { .85, .95, 1, 1.2, 1.44, 1.728, 2.0736}; |
|
2349
9832b57ded64
[gaim-migrate @ 2362]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2348
diff
changeset
|
116 | |
|
10184
543c9a84ce16
[gaim-migrate @ 11299]
Mark Doliner <markdoliner@pidgin.im>
parents:
10169
diff
changeset
|
117 | enum { |
| 8677 | 118 | TARGET_HTML, |
| 8061 | 119 | TARGET_UTF8_STRING, |
| 120 | TARGET_COMPOUND_TEXT, | |
| 121 | TARGET_STRING, | |
| 122 | TARGET_TEXT | |
| 123 | }; | |
| 124 | ||
| 8091 | 125 | enum { |
| 8420 | 126 | URL_CLICKED, |
| 127 | BUTTONS_UPDATE, | |
| 128 | TOGGLE_FORMAT, | |
| 8427 | 129 | CLEAR_FORMAT, |
| 8506 | 130 | UPDATE_FORMAT, |
| 10108 | 131 | MESSAGE_SEND, |
|
17880
5e73968467e0
Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@pidgin.im>
parents:
17288
diff
changeset
|
132 | UNDO, |
|
5e73968467e0
Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@pidgin.im>
parents:
17288
diff
changeset
|
133 | REDO, |
| 8420 | 134 | LAST_SIGNAL |
| 135 | }; | |
| 136 | static guint signals [LAST_SIGNAL] = { 0 }; | |
| 137 | ||
|
17546
51b1c1e2c3fe
Maintain global poitners to the clipboard selection text, with the aim of
Sean Egan <seanegan@pidgin.im>
parents:
17406
diff
changeset
|
138 | static char *html_clipboard = NULL; |
|
51b1c1e2c3fe
Maintain global poitners to the clipboard selection text, with the aim of
Sean Egan <seanegan@pidgin.im>
parents:
17406
diff
changeset
|
139 | static char *text_clipboard = NULL; |
|
51b1c1e2c3fe
Maintain global poitners to the clipboard selection text, with the aim of
Sean Egan <seanegan@pidgin.im>
parents:
17406
diff
changeset
|
140 | GtkClipboard *clipboard_selection = NULL; |
|
51b1c1e2c3fe
Maintain global poitners to the clipboard selection text, with the aim of
Sean Egan <seanegan@pidgin.im>
parents:
17406
diff
changeset
|
141 | |
|
10871
c0282a4f2250
[gaim-migrate @ 12558]
Mark Doliner <markdoliner@pidgin.im>
parents:
10865
diff
changeset
|
142 | static GtkTargetEntry selection_targets[] = { |
|
15111
e427dd6f3b7e
[gaim-migrate @ 17833]
Daniel Atallah <datallah@pidgin.im>
parents:
15093
diff
changeset
|
143 | #ifndef _WIN32 |
| 8566 | 144 | { "text/html", 0, TARGET_HTML }, |
|
15111
e427dd6f3b7e
[gaim-migrate @ 17833]
Daniel Atallah <datallah@pidgin.im>
parents:
15093
diff
changeset
|
145 | #else |
|
e427dd6f3b7e
[gaim-migrate @ 17833]
Daniel Atallah <datallah@pidgin.im>
parents:
15093
diff
changeset
|
146 | { "HTML Format", 0, TARGET_HTML }, |
|
e427dd6f3b7e
[gaim-migrate @ 17833]
Daniel Atallah <datallah@pidgin.im>
parents:
15093
diff
changeset
|
147 | #endif |
| 8061 | 148 | { "UTF8_STRING", 0, TARGET_UTF8_STRING }, |
| 149 | { "COMPOUND_TEXT", 0, TARGET_COMPOUND_TEXT }, | |
| 150 | { "STRING", 0, TARGET_STRING }, | |
| 151 | { "TEXT", 0, TARGET_TEXT}}; | |
| 152 | ||
|
10871
c0282a4f2250
[gaim-migrate @ 12558]
Mark Doliner <markdoliner@pidgin.im>
parents:
10865
diff
changeset
|
153 | static GtkTargetEntry link_drag_drop_targets[] = { |
|
10145
f1405f65ff41
[gaim-migrate @ 11218]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10110
diff
changeset
|
154 | GTK_IMHTML_DND_TARGETS |
|
f1405f65ff41
[gaim-migrate @ 11218]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10110
diff
changeset
|
155 | }; |
| 8091 | 156 | |
| 8692 | 157 | #ifdef _WIN32 |
| 158 | static gchar * | |
| 159 | clipboard_win32_to_html(char *clipboard) { | |
| 9465 | 160 | const char *header; |
| 8693 | 161 | const char *begin, *end; |
|
10016
18418b9fa749
[gaim-migrate @ 10935]
Daniel Atallah <datallah@pidgin.im>
parents:
10013
diff
changeset
|
162 | gint start = 0; |
|
18418b9fa749
[gaim-migrate @ 10935]
Daniel Atallah <datallah@pidgin.im>
parents:
10013
diff
changeset
|
163 | gint finish = 0; |
| 8692 | 164 | gchar *html; |
|
10016
18418b9fa749
[gaim-migrate @ 10935]
Daniel Atallah <datallah@pidgin.im>
parents:
10013
diff
changeset
|
165 | gchar **split; |
|
18418b9fa749
[gaim-migrate @ 10935]
Daniel Atallah <datallah@pidgin.im>
parents:
10013
diff
changeset
|
166 | int clipboard_length = 0; |
| 9465 | 167 | |
| 168 | #if 0 /* Debugging for Windows clipboard */ | |
| 9467 | 169 | FILE *fd; |
| 170 | ||
| 15884 | 171 | purple_debug_info("imhtml clipboard", "from clipboard: %s\n", clipboard); |
| 172 | ||
| 173 | fd = g_fopen("e:\\purplecb.txt", "wb"); | |
| 9465 | 174 | fprintf(fd, "%s", clipboard); |
| 175 | fclose(fd); | |
| 176 | #endif | |
| 177 | ||
|
10016
18418b9fa749
[gaim-migrate @ 10935]
Daniel Atallah <datallah@pidgin.im>
parents:
10013
diff
changeset
|
178 | clipboard_length = strlen(clipboard); |
|
18418b9fa749
[gaim-migrate @ 10935]
Daniel Atallah <datallah@pidgin.im>
parents:
10013
diff
changeset
|
179 | |
|
18418b9fa749
[gaim-migrate @ 10935]
Daniel Atallah <datallah@pidgin.im>
parents:
10013
diff
changeset
|
180 | if (!(header = strstr(clipboard, "StartFragment:")) || (header - clipboard) >= clipboard_length) |
| 9465 | 181 | return NULL; |
| 182 | sscanf(header, "StartFragment:%d", &start); | |
| 183 | ||
|
10016
18418b9fa749
[gaim-migrate @ 10935]
Daniel Atallah <datallah@pidgin.im>
parents:
10013
diff
changeset
|
184 | if (!(header = strstr(clipboard, "EndFragment:")) || (header - clipboard) >= clipboard_length) |
|
18418b9fa749
[gaim-migrate @ 10935]
Daniel Atallah <datallah@pidgin.im>
parents:
10013
diff
changeset
|
185 | return NULL; |
| 9465 | 186 | sscanf(header, "EndFragment:%d", &finish); |
| 187 | ||
|
10016
18418b9fa749
[gaim-migrate @ 10935]
Daniel Atallah <datallah@pidgin.im>
parents:
10013
diff
changeset
|
188 | if (finish > clipboard_length) |
|
18418b9fa749
[gaim-migrate @ 10935]
Daniel Atallah <datallah@pidgin.im>
parents:
10013
diff
changeset
|
189 | finish = clipboard_length; |
|
18418b9fa749
[gaim-migrate @ 10935]
Daniel Atallah <datallah@pidgin.im>
parents:
10013
diff
changeset
|
190 | |
|
18418b9fa749
[gaim-migrate @ 10935]
Daniel Atallah <datallah@pidgin.im>
parents:
10013
diff
changeset
|
191 | if (start > finish) |
|
18418b9fa749
[gaim-migrate @ 10935]
Daniel Atallah <datallah@pidgin.im>
parents:
10013
diff
changeset
|
192 | start = finish; |
|
18418b9fa749
[gaim-migrate @ 10935]
Daniel Atallah <datallah@pidgin.im>
parents:
10013
diff
changeset
|
193 | |
| 9465 | 194 | begin = clipboard + start; |
| 195 | ||
|
10016
18418b9fa749
[gaim-migrate @ 10935]
Daniel Atallah <datallah@pidgin.im>
parents:
10013
diff
changeset
|
196 | end = clipboard + finish; |
|
18418b9fa749
[gaim-migrate @ 10935]
Daniel Atallah <datallah@pidgin.im>
parents:
10013
diff
changeset
|
197 | |
|
18418b9fa749
[gaim-migrate @ 10935]
Daniel Atallah <datallah@pidgin.im>
parents:
10013
diff
changeset
|
198 | html = g_strndup(begin, end - begin); |
|
18418b9fa749
[gaim-migrate @ 10935]
Daniel Atallah <datallah@pidgin.im>
parents:
10013
diff
changeset
|
199 | |
|
18418b9fa749
[gaim-migrate @ 10935]
Daniel Atallah <datallah@pidgin.im>
parents:
10013
diff
changeset
|
200 | /* any newlines in the string will now be \r\n, so we need to strip out the \r */ |
|
18418b9fa749
[gaim-migrate @ 10935]
Daniel Atallah <datallah@pidgin.im>
parents:
10013
diff
changeset
|
201 | split = g_strsplit(html, "\r\n", 0); |
|
18418b9fa749
[gaim-migrate @ 10935]
Daniel Atallah <datallah@pidgin.im>
parents:
10013
diff
changeset
|
202 | g_free(html); |
|
18418b9fa749
[gaim-migrate @ 10935]
Daniel Atallah <datallah@pidgin.im>
parents:
10013
diff
changeset
|
203 | html = g_strjoinv("\n", split); |
|
18418b9fa749
[gaim-migrate @ 10935]
Daniel Atallah <datallah@pidgin.im>
parents:
10013
diff
changeset
|
204 | g_strfreev(split); |
|
18418b9fa749
[gaim-migrate @ 10935]
Daniel Atallah <datallah@pidgin.im>
parents:
10013
diff
changeset
|
205 | |
|
18418b9fa749
[gaim-migrate @ 10935]
Daniel Atallah <datallah@pidgin.im>
parents:
10013
diff
changeset
|
206 | html = g_strstrip(html); |
| 9465 | 207 | |
| 208 | #if 0 /* Debugging for Windows clipboard */ | |
| 15884 | 209 | purple_debug_info("imhtml clipboard", "HTML fragment: '%s'\n", html); |
| 9465 | 210 | #endif |
| 211 | ||
| 8707 | 212 | return html; |
| 8692 | 213 | } |
| 214 | ||
| 215 | static gchar * | |
| 216 | clipboard_html_to_win32(char *html) { | |
| 8693 | 217 | int length; |
|
11240
cd4ca16ff57c
[gaim-migrate @ 13399]
Richard Laager <rlaager@pidgin.im>
parents:
11234
diff
changeset
|
218 | GString *clipboard; |
| 8692 | 219 | |
| 8693 | 220 | if (html == NULL) |
| 221 | return NULL; | |
| 8692 | 222 | |
| 223 | length = strlen(html); | |
| 9465 | 224 | clipboard = g_string_new ("Version:1.0\r\n"); |
| 8692 | 225 | g_string_append(clipboard, "StartHTML:0000000105\r\n"); |
|
18665
157820042a6f
Fix #1727 and also plug a possible leak and make a little efficiency improvement to the win32 clipboard handling.
Daniel Atallah <datallah@pidgin.im>
parents:
18633
diff
changeset
|
226 | g_string_append_printf(clipboard, "EndHTML:%010d\r\n", 147 + length); |
| 9465 | 227 | g_string_append(clipboard, "StartFragment:0000000127\r\n"); |
|
18665
157820042a6f
Fix #1727 and also plug a possible leak and make a little efficiency improvement to the win32 clipboard handling.
Daniel Atallah <datallah@pidgin.im>
parents:
18633
diff
changeset
|
228 | g_string_append_printf(clipboard, "EndFragment:%010d\r\n", 127 + length); |
| 9465 | 229 | g_string_append(clipboard, "<!--StartFragment-->\r\n"); |
| 8692 | 230 | g_string_append(clipboard, html); |
| 9465 | 231 | g_string_append(clipboard, "\r\n<!--EndFragment-->"); |
|
14101
89a79c2a971e
[gaim-migrate @ 16643]
Mark Doliner <markdoliner@pidgin.im>
parents:
14097
diff
changeset
|
232 | |
|
89a79c2a971e
[gaim-migrate @ 16643]
Mark Doliner <markdoliner@pidgin.im>
parents:
14097
diff
changeset
|
233 | return g_string_free(clipboard, FALSE); |
| 8692 | 234 | } |
|
10901
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
235 | |
|
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
236 | static gboolean clipboard_paste_html_win32(GtkIMHtml *imhtml) { |
|
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
237 | gboolean pasted = FALSE; |
|
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
238 | |
|
15111
e427dd6f3b7e
[gaim-migrate @ 17833]
Daniel Atallah <datallah@pidgin.im>
parents:
15093
diff
changeset
|
239 | /* Win32 clipboard format value, and functions to convert back and |
|
e427dd6f3b7e
[gaim-migrate @ 17833]
Daniel Atallah <datallah@pidgin.im>
parents:
15093
diff
changeset
|
240 | * forth between HTML and the clipboard format. |
|
e427dd6f3b7e
[gaim-migrate @ 17833]
Daniel Atallah <datallah@pidgin.im>
parents:
15093
diff
changeset
|
241 | */ |
|
e427dd6f3b7e
[gaim-migrate @ 17833]
Daniel Atallah <datallah@pidgin.im>
parents:
15093
diff
changeset
|
242 | static UINT win_html_fmt = 0; |
|
e427dd6f3b7e
[gaim-migrate @ 17833]
Daniel Atallah <datallah@pidgin.im>
parents:
15093
diff
changeset
|
243 | |
|
e427dd6f3b7e
[gaim-migrate @ 17833]
Daniel Atallah <datallah@pidgin.im>
parents:
15093
diff
changeset
|
244 | /* Register HTML Format as desired clipboard format */ |
|
e427dd6f3b7e
[gaim-migrate @ 17833]
Daniel Atallah <datallah@pidgin.im>
parents:
15093
diff
changeset
|
245 | if (!win_html_fmt) |
|
e427dd6f3b7e
[gaim-migrate @ 17833]
Daniel Atallah <datallah@pidgin.im>
parents:
15093
diff
changeset
|
246 | win_html_fmt = RegisterClipboardFormat("HTML Format"); |
|
e427dd6f3b7e
[gaim-migrate @ 17833]
Daniel Atallah <datallah@pidgin.im>
parents:
15093
diff
changeset
|
247 | |
|
10901
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
248 | if (gtk_text_view_get_editable(GTK_TEXT_VIEW(imhtml)) |
|
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
249 | && IsClipboardFormatAvailable(win_html_fmt)) { |
|
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
250 | gboolean error_reading_clipboard = FALSE; |
|
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
251 | HWND hwnd = GDK_WINDOW_HWND(GTK_WIDGET(imhtml)->window); |
|
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
252 | |
|
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
253 | if (OpenClipboard(hwnd)) { |
|
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
254 | HGLOBAL hdata = GetClipboardData(win_html_fmt); |
|
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
255 | if (hdata == NULL) { |
|
15111
e427dd6f3b7e
[gaim-migrate @ 17833]
Daniel Atallah <datallah@pidgin.im>
parents:
15093
diff
changeset
|
256 | if (GetLastError() != ERROR_SUCCESS) |
|
e427dd6f3b7e
[gaim-migrate @ 17833]
Daniel Atallah <datallah@pidgin.im>
parents:
15093
diff
changeset
|
257 | error_reading_clipboard = TRUE; |
|
10901
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
258 | } else { |
|
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
259 | char *buffer = GlobalLock(hdata); |
|
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
260 | if (buffer == NULL) { |
|
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
261 | error_reading_clipboard = TRUE; |
|
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
262 | } else { |
|
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
263 | char *text = clipboard_win32_to_html( |
|
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
264 | buffer); |
|
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
265 | imhtml_paste_insert(imhtml, text, |
|
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
266 | FALSE); |
|
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
267 | g_free(text); |
|
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
268 | pasted = TRUE; |
|
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
269 | } |
|
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
270 | GlobalUnlock(hdata); |
|
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
271 | } |
|
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
272 | |
|
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
273 | CloseClipboard(); |
|
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
274 | } else { |
|
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
275 | error_reading_clipboard = TRUE; |
|
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
276 | } |
|
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
277 | |
|
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
278 | if (error_reading_clipboard) { |
|
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
279 | gchar *err_msg = g_win32_error_message(GetLastError()); |
| 15884 | 280 | purple_debug_info("html clipboard", |
|
10901
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
281 | "Unable to read clipboard data: %s\n", |
|
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
282 | err_msg ? err_msg : "Unknown Error"); |
|
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
283 | g_free(err_msg); |
|
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
284 | } |
|
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
285 | } |
|
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
286 | |
|
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
287 | return pasted; |
|
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
288 | } |
| 8692 | 289 | #endif |
| 290 | ||
| 4032 | 291 | static GtkSmileyTree* |
| 292 | gtk_smiley_tree_new () | |
| 293 | { | |
| 294 | return g_new0 (GtkSmileyTree, 1); | |
| 295 | } | |
| 296 | ||
| 297 | static void | |
| 298 | gtk_smiley_tree_insert (GtkSmileyTree *tree, | |
| 4263 | 299 | GtkIMHtmlSmiley *smiley) |
| 4032 | 300 | { |
| 301 | GtkSmileyTree *t = tree; | |
| 4263 | 302 | const gchar *x = smiley->smile; |
| 4032 | 303 | |
|
12229
ad8d3ae8fc1b
[gaim-migrate @ 14531]
Michael Carlson <corfe83@users.sourceforge.net>
parents:
12072
diff
changeset
|
304 | if (!(*x)) |
| 4032 | 305 | return; |
| 306 | ||
|
12229
ad8d3ae8fc1b
[gaim-migrate @ 14531]
Michael Carlson <corfe83@users.sourceforge.net>
parents:
12072
diff
changeset
|
307 | do { |
| 4032 | 308 | gchar *pos; |
| 309 | gint index; | |
| 310 | ||
| 311 | if (!t->values) | |
| 312 | t->values = g_string_new (""); | |
| 313 | ||
| 314 | pos = strchr (t->values->str, *x); | |
| 315 | if (!pos) { | |
| 316 | t->values = g_string_append_c (t->values, *x); | |
| 317 | index = t->values->len - 1; | |
| 318 | t->children = g_realloc (t->children, t->values->len * sizeof (GtkSmileyTree *)); | |
| 319 | t->children [index] = g_new0 (GtkSmileyTree, 1); | |
| 320 | } else | |
| 7386 | 321 | index = GPOINTER_TO_INT(pos) - GPOINTER_TO_INT(t->values->str); |
| 8061 | 322 | |
| 4032 | 323 | t = t->children [index]; |
| 8061 | 324 | |
| 4032 | 325 | x++; |
|
12229
ad8d3ae8fc1b
[gaim-migrate @ 14531]
Michael Carlson <corfe83@users.sourceforge.net>
parents:
12072
diff
changeset
|
326 | } while (*x); |
| 8061 | 327 | |
| 4263 | 328 | t->image = smiley; |
| 4032 | 329 | } |
| 4041 | 330 | |
| 4263 | 331 | |
|
11677
89c2ab8d2ebf
[gaim-migrate @ 13963]
Mark Doliner <markdoliner@pidgin.im>
parents:
11586
diff
changeset
|
332 | static void |
|
89c2ab8d2ebf
[gaim-migrate @ 13963]
Mark Doliner <markdoliner@pidgin.im>
parents:
11586
diff
changeset
|
333 | gtk_smiley_tree_destroy (GtkSmileyTree *tree) |
| 4032 | 334 | { |
|
11701
8cf812de5e92
[gaim-migrate @ 13992]
Michael Carlson <corfe83@users.sourceforge.net>
parents:
11677
diff
changeset
|
335 | GSList *list = g_slist_prepend (NULL, tree); |
| 4032 | 336 | |
| 337 | while (list) { | |
| 338 | GtkSmileyTree *t = list->data; | |
|
12229
ad8d3ae8fc1b
[gaim-migrate @ 14531]
Michael Carlson <corfe83@users.sourceforge.net>
parents:
12072
diff
changeset
|
339 | gsize i; |
| 4032 | 340 | list = g_slist_remove(list, t); |
| 7384 | 341 | if (t && t->values) { |
| 4032 | 342 | for (i = 0; i < t->values->len; i++) |
|
11701
8cf812de5e92
[gaim-migrate @ 13992]
Michael Carlson <corfe83@users.sourceforge.net>
parents:
11677
diff
changeset
|
343 | list = g_slist_prepend (list, t->children [i]); |
| 4032 | 344 | g_string_free (t->values, TRUE); |
| 345 | g_free (t->children); | |
| 346 | } | |
| 347 | g_free (t); | |
| 348 | } | |
| 349 | } | |
| 350 | ||
|
11840
c9ec5a42d420
[gaim-migrate @ 14131]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11820
diff
changeset
|
351 | static void gtk_size_allocate_cb(GtkIMHtml *widget, GtkAllocation *alloc, gpointer user_data) |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
352 | { |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
353 | GdkRectangle rect; |
| 8726 | 354 | int xminus; |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
355 | |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
356 | gtk_text_view_get_visible_rect(GTK_TEXT_VIEW(widget), &rect); |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
357 | if(widget->old_rect.width != rect.width || widget->old_rect.height != rect.height){ |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
358 | GList *iter = GTK_IMHTML(widget)->scalables; |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
359 | |
| 8726 | 360 | xminus = gtk_text_view_get_left_margin(GTK_TEXT_VIEW(widget)) + |
| 361 | gtk_text_view_get_right_margin(GTK_TEXT_VIEW(widget)); | |
| 362 | ||
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
363 | while(iter){ |
|
11224
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
364 | struct scalable_data *sd = iter->data; |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
365 | GtkIMHtmlScalable *scale = GTK_IMHTML_SCALABLE(sd->scalable); |
| 8726 | 366 | scale->scale(scale, rect.width - xminus, rect.height); |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
367 | |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
368 | iter = iter->next; |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
369 | } |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
370 | } |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
371 | |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
372 | widget->old_rect = rect; |
|
11840
c9ec5a42d420
[gaim-migrate @ 14131]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11820
diff
changeset
|
373 | return; |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
374 | } |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
375 | |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
376 | static gint |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
377 | gtk_imhtml_tip_paint (GtkIMHtml *imhtml) |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
378 | { |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
379 | PangoLayout *layout; |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
380 | |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
381 | g_return_val_if_fail(GTK_IS_IMHTML(imhtml), FALSE); |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
382 | |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
383 | layout = gtk_widget_create_pango_layout(imhtml->tip_window, imhtml->tip); |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
384 | |
| 8061 | 385 | gtk_paint_flat_box (imhtml->tip_window->style, imhtml->tip_window->window, |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
386 | GTK_STATE_NORMAL, GTK_SHADOW_OUT, NULL, imhtml->tip_window, |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
387 | "tooltip", 0, 0, -1, -1); |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
388 | |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
389 | gtk_paint_layout (imhtml->tip_window->style, imhtml->tip_window->window, GTK_STATE_NORMAL, |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
390 | FALSE, NULL, imhtml->tip_window, NULL, 4, 4, layout); |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
391 | |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
392 | g_object_unref(layout); |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
393 | return FALSE; |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
394 | } |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
395 | |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
396 | static gint |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
397 | gtk_imhtml_tip (gpointer data) |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
398 | { |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
399 | GtkIMHtml *imhtml = data; |
| 8526 | 400 | PangoFontMetrics *font_metrics; |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
401 | PangoLayout *layout; |
| 8526 | 402 | PangoFont *font; |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
403 | |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
404 | gint gap, x, y, h, w, scr_w, baseline_skip; |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
405 | |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
406 | g_return_val_if_fail(GTK_IS_IMHTML(imhtml), FALSE); |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
407 | |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
408 | if (!imhtml->tip || !GTK_WIDGET_DRAWABLE (GTK_WIDGET(imhtml))) { |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
409 | imhtml->tip_timer = 0; |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
410 | return FALSE; |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
411 | } |
| 8061 | 412 | |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
413 | if (imhtml->tip_window){ |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
414 | gtk_widget_destroy (imhtml->tip_window); |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
415 | imhtml->tip_window = NULL; |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
416 | } |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
417 | |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
418 | imhtml->tip_timer = 0; |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
419 | imhtml->tip_window = gtk_window_new (GTK_WINDOW_POPUP); |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
420 | gtk_widget_set_app_paintable (imhtml->tip_window, TRUE); |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
421 | gtk_window_set_resizable (GTK_WINDOW (imhtml->tip_window), FALSE); |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
422 | gtk_widget_set_name (imhtml->tip_window, "gtk-tooltips"); |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
423 | g_signal_connect_swapped (G_OBJECT (imhtml->tip_window), "expose_event", |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
424 | G_CALLBACK (gtk_imhtml_tip_paint), imhtml); |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
425 | |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
426 | gtk_widget_ensure_style (imhtml->tip_window); |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
427 | layout = gtk_widget_create_pango_layout(imhtml->tip_window, imhtml->tip); |
| 8526 | 428 | font = pango_context_load_font(pango_layout_get_context(layout), |
| 429 | imhtml->tip_window->style->font_desc); | |
| 430 | ||
| 431 | if (font == NULL) { | |
| 432 | char *tmp = pango_font_description_to_string( | |
| 433 | imhtml->tip_window->style->font_desc); | |
| 434 | ||
| 15884 | 435 | purple_debug(PURPLE_DEBUG_ERROR, "gtk_imhtml_tip", |
| 8526 | 436 | "pango_context_load_font() couldn't load font: '%s'\n", |
| 437 | tmp); | |
| 438 | g_free(tmp); | |
| 439 | ||
| 440 | return FALSE; | |
| 441 | } | |
| 442 | ||
| 443 | font_metrics = pango_font_get_metrics(font, NULL); | |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
444 | |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
445 | pango_layout_get_pixel_size(layout, &scr_w, NULL); |
| 8526 | 446 | gap = PANGO_PIXELS((pango_font_metrics_get_ascent(font_metrics) + |
| 447 | pango_font_metrics_get_descent(font_metrics))/ 4); | |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
448 | |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
449 | if (gap < 2) |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
450 | gap = 2; |
| 8526 | 451 | baseline_skip = PANGO_PIXELS(pango_font_metrics_get_ascent(font_metrics) + |
| 452 | pango_font_metrics_get_descent(font_metrics)); | |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
453 | w = 8 + scr_w; |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
454 | h = 8 + baseline_skip; |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
455 | |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
456 | gdk_window_get_pointer (NULL, &x, &y, NULL); |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
457 | if (GTK_WIDGET_NO_WINDOW (GTK_WIDGET(imhtml))) |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
458 | y += GTK_WIDGET(imhtml)->allocation.y; |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
459 | |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
460 | scr_w = gdk_screen_width(); |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
461 | |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
462 | x -= ((w >> 1) + 4); |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
463 | |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
464 | if ((x + w) > scr_w) |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
465 | x -= (x + w) - scr_w; |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
466 | else if (x < 0) |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
467 | x = 0; |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
468 | |
| 8526 | 469 | y = y + PANGO_PIXELS(pango_font_metrics_get_ascent(font_metrics) + |
| 470 | pango_font_metrics_get_descent(font_metrics)); | |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
471 | |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
472 | gtk_widget_set_size_request (imhtml->tip_window, w, h); |
|
15865
e046bdae3964
Move the tooltip window before showing the tooltip to avoid a transient
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15577
diff
changeset
|
473 | gtk_window_move (GTK_WINDOW(imhtml->tip_window), x, y); |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
474 | gtk_widget_show (imhtml->tip_window); |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
475 | |
| 8526 | 476 | pango_font_metrics_unref(font_metrics); |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
477 | g_object_unref(layout); |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
478 | |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
479 | return FALSE; |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
480 | } |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
481 | |
|
11844
57ad7c52cc9c
[gaim-migrate @ 14135]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11840
diff
changeset
|
482 | static gboolean |
|
57ad7c52cc9c
[gaim-migrate @ 14135]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11840
diff
changeset
|
483 | gtk_motion_event_notify(GtkWidget *imhtml, GdkEventMotion *event, gpointer data) |
| 8061 | 484 | { |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
485 | GtkTextIter iter; |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
486 | GdkWindow *win = event->window; |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
487 | int x, y; |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
488 | char *tip = NULL; |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
489 | GSList *tags = NULL, *templist = NULL; |
| 10799 | 490 | GdkColor *norm, *pre; |
| 491 | GtkTextTag *tag = NULL, *oldprelit_tag; | |
|
18543
c590aed61aa4
Show tooltip for smileys. Fixes #1981.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18371
diff
changeset
|
492 | GtkTextChildAnchor* anchor; |
|
c590aed61aa4
Show tooltip for smileys. Fixes #1981.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18371
diff
changeset
|
493 | gboolean hand = TRUE; |
| 10799 | 494 | |
| 495 | oldprelit_tag = GTK_IMHTML(imhtml)->prelit_tag; | |
| 496 | ||
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
497 | gdk_window_get_pointer(GTK_WIDGET(imhtml)->window, NULL, NULL, NULL); |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
498 | gtk_text_view_window_to_buffer_coords(GTK_TEXT_VIEW(imhtml), GTK_TEXT_WINDOW_WIDGET, |
| 10799 | 499 | event->x, event->y, &x, &y); |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
500 | gtk_text_view_get_iter_at_location(GTK_TEXT_VIEW(imhtml), &iter, x, y); |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
501 | tags = gtk_text_iter_get_tags(&iter); |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
502 | |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
503 | templist = tags; |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
504 | while (templist) { |
| 10799 | 505 | tag = templist->data; |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
506 | tip = g_object_get_data(G_OBJECT(tag), "link_url"); |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
507 | if (tip) |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
508 | break; |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
509 | templist = templist->next; |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
510 | } |
| 8061 | 511 | |
| 10799 | 512 | if (tip) { |
| 513 | gtk_widget_style_get(GTK_WIDGET(imhtml), "hyperlink-prelight-color", &pre, NULL); | |
| 514 | GTK_IMHTML(imhtml)->prelit_tag = tag; | |
| 515 | if (tag != oldprelit_tag) { | |
| 516 | if (pre) | |
| 517 | g_object_set(G_OBJECT(tag), "foreground-gdk", pre, NULL); | |
| 518 | else | |
|
12253
5025434b18f8
[gaim-migrate @ 14555]
Mark Doliner <markdoliner@pidgin.im>
parents:
12230
diff
changeset
|
519 | g_object_set(G_OBJECT(tag), "foreground", "#70a0ff", NULL); |
| 10799 | 520 | } |
| 521 | } else { | |
| 522 | GTK_IMHTML(imhtml)->prelit_tag = NULL; | |
| 523 | } | |
|
11572
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
524 | |
|
10834
5fd1dfd395e8
[gaim-migrate @ 12505]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10826
diff
changeset
|
525 | if ((oldprelit_tag != NULL) && (GTK_IMHTML(imhtml)->prelit_tag != oldprelit_tag)) { |
| 10799 | 526 | gtk_widget_style_get(GTK_WIDGET(imhtml), "hyperlink-color", &norm, NULL); |
| 527 | if (norm) | |
| 528 | g_object_set(G_OBJECT(oldprelit_tag), "foreground-gdk", norm, NULL); | |
| 529 | else | |
| 530 | g_object_set(G_OBJECT(oldprelit_tag), "foreground", "blue", NULL); | |
| 531 | } | |
| 532 | ||
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
533 | if (GTK_IMHTML(imhtml)->tip) { |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
534 | if ((tip == GTK_IMHTML(imhtml)->tip)) { |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
535 | return FALSE; |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
536 | } |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
537 | /* We've left the cell. Remove the timeout and create a new one below */ |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
538 | if (GTK_IMHTML(imhtml)->tip_window) { |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
539 | gtk_widget_destroy(GTK_IMHTML(imhtml)->tip_window); |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
540 | GTK_IMHTML(imhtml)->tip_window = NULL; |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
541 | } |
| 8061 | 542 | if (GTK_IMHTML(imhtml)->editable) |
| 543 | gdk_window_set_cursor(win, GTK_IMHTML(imhtml)->text_cursor); | |
| 544 | else | |
| 545 | gdk_window_set_cursor(win, GTK_IMHTML(imhtml)->arrow_cursor); | |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
546 | if (GTK_IMHTML(imhtml)->tip_timer) |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
547 | g_source_remove(GTK_IMHTML(imhtml)->tip_timer); |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
548 | GTK_IMHTML(imhtml)->tip_timer = 0; |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
549 | } |
| 8061 | 550 | |
|
18543
c590aed61aa4
Show tooltip for smileys. Fixes #1981.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18371
diff
changeset
|
551 | /* If we don't have a tip from a URL, let's see if we have a tip from a smiley */ |
|
c590aed61aa4
Show tooltip for smileys. Fixes #1981.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18371
diff
changeset
|
552 | anchor = gtk_text_iter_get_child_anchor(&iter); |
|
c590aed61aa4
Show tooltip for smileys. Fixes #1981.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18371
diff
changeset
|
553 | if (anchor) { |
|
c590aed61aa4
Show tooltip for smileys. Fixes #1981.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18371
diff
changeset
|
554 | tip = g_object_get_data(G_OBJECT(anchor), "gtkimhtml_plaintext"); |
|
c590aed61aa4
Show tooltip for smileys. Fixes #1981.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18371
diff
changeset
|
555 | hand = FALSE; |
|
c590aed61aa4
Show tooltip for smileys. Fixes #1981.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18371
diff
changeset
|
556 | } |
|
c590aed61aa4
Show tooltip for smileys. Fixes #1981.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18371
diff
changeset
|
557 | |
| 10799 | 558 | if (tip){ |
|
18543
c590aed61aa4
Show tooltip for smileys. Fixes #1981.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18371
diff
changeset
|
559 | if (!GTK_IMHTML(imhtml)->editable && hand) |
| 8061 | 560 | gdk_window_set_cursor(win, GTK_IMHTML(imhtml)->hand_cursor); |
| 561 | GTK_IMHTML(imhtml)->tip_timer = g_timeout_add (TOOLTIP_TIMEOUT, | |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
562 | gtk_imhtml_tip, imhtml); |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
563 | } |
| 8061 | 564 | |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
565 | GTK_IMHTML(imhtml)->tip = tip; |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
566 | g_slist_free(tags); |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
567 | return FALSE; |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
568 | } |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
569 | |
|
11677
89c2ab8d2ebf
[gaim-migrate @ 13963]
Mark Doliner <markdoliner@pidgin.im>
parents:
11586
diff
changeset
|
570 | static gboolean |
|
89c2ab8d2ebf
[gaim-migrate @ 13963]
Mark Doliner <markdoliner@pidgin.im>
parents:
11586
diff
changeset
|
571 | gtk_enter_event_notify(GtkWidget *imhtml, GdkEventCrossing *event, gpointer data) |
|
10946
63a41710fc94
[gaim-migrate @ 12742]
Daniel Atallah <datallah@pidgin.im>
parents:
10936
diff
changeset
|
572 | { |
|
63a41710fc94
[gaim-migrate @ 12742]
Daniel Atallah <datallah@pidgin.im>
parents:
10936
diff
changeset
|
573 | if (GTK_IMHTML(imhtml)->editable) |
|
63a41710fc94
[gaim-migrate @ 12742]
Daniel Atallah <datallah@pidgin.im>
parents:
10936
diff
changeset
|
574 | gdk_window_set_cursor( |
|
63a41710fc94
[gaim-migrate @ 12742]
Daniel Atallah <datallah@pidgin.im>
parents:
10936
diff
changeset
|
575 | gtk_text_view_get_window(GTK_TEXT_VIEW(imhtml), |
|
63a41710fc94
[gaim-migrate @ 12742]
Daniel Atallah <datallah@pidgin.im>
parents:
10936
diff
changeset
|
576 | GTK_TEXT_WINDOW_TEXT), |
|
63a41710fc94
[gaim-migrate @ 12742]
Daniel Atallah <datallah@pidgin.im>
parents:
10936
diff
changeset
|
577 | GTK_IMHTML(imhtml)->text_cursor); |
|
63a41710fc94
[gaim-migrate @ 12742]
Daniel Atallah <datallah@pidgin.im>
parents:
10936
diff
changeset
|
578 | else |
|
63a41710fc94
[gaim-migrate @ 12742]
Daniel Atallah <datallah@pidgin.im>
parents:
10936
diff
changeset
|
579 | gdk_window_set_cursor( |
|
63a41710fc94
[gaim-migrate @ 12742]
Daniel Atallah <datallah@pidgin.im>
parents:
10936
diff
changeset
|
580 | gtk_text_view_get_window(GTK_TEXT_VIEW(imhtml), |
|
63a41710fc94
[gaim-migrate @ 12742]
Daniel Atallah <datallah@pidgin.im>
parents:
10936
diff
changeset
|
581 | GTK_TEXT_WINDOW_TEXT), |
|
63a41710fc94
[gaim-migrate @ 12742]
Daniel Atallah <datallah@pidgin.im>
parents:
10936
diff
changeset
|
582 | GTK_IMHTML(imhtml)->arrow_cursor); |
|
63a41710fc94
[gaim-migrate @ 12742]
Daniel Atallah <datallah@pidgin.im>
parents:
10936
diff
changeset
|
583 | |
|
63a41710fc94
[gaim-migrate @ 12742]
Daniel Atallah <datallah@pidgin.im>
parents:
10936
diff
changeset
|
584 | /* propagate the event normally */ |
|
63a41710fc94
[gaim-migrate @ 12742]
Daniel Atallah <datallah@pidgin.im>
parents:
10936
diff
changeset
|
585 | return FALSE; |
|
63a41710fc94
[gaim-migrate @ 12742]
Daniel Atallah <datallah@pidgin.im>
parents:
10936
diff
changeset
|
586 | } |
|
63a41710fc94
[gaim-migrate @ 12742]
Daniel Atallah <datallah@pidgin.im>
parents:
10936
diff
changeset
|
587 | |
|
11677
89c2ab8d2ebf
[gaim-migrate @ 13963]
Mark Doliner <markdoliner@pidgin.im>
parents:
11586
diff
changeset
|
588 | static gboolean |
|
89c2ab8d2ebf
[gaim-migrate @ 13963]
Mark Doliner <markdoliner@pidgin.im>
parents:
11586
diff
changeset
|
589 | gtk_leave_event_notify(GtkWidget *imhtml, GdkEventCrossing *event, gpointer data) |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
590 | { |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
591 | /* when leaving the widget, clear any current & pending tooltips and restore the cursor */ |
| 10799 | 592 | if (GTK_IMHTML(imhtml)->prelit_tag) { |
| 593 | GdkColor *norm; | |
| 594 | gtk_widget_style_get(GTK_WIDGET(imhtml), "hyperlink-color", &norm, NULL); | |
| 595 | if (norm) | |
| 596 | g_object_set(G_OBJECT(GTK_IMHTML(imhtml)->prelit_tag), "foreground-gdk", norm, NULL); | |
| 597 | else | |
| 598 | g_object_set(G_OBJECT(GTK_IMHTML(imhtml)->prelit_tag), "foreground", "blue", NULL); | |
| 599 | GTK_IMHTML(imhtml)->prelit_tag = NULL; | |
| 600 | } | |
| 601 | ||
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
602 | if (GTK_IMHTML(imhtml)->tip_window) { |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
603 | gtk_widget_destroy(GTK_IMHTML(imhtml)->tip_window); |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
604 | GTK_IMHTML(imhtml)->tip_window = NULL; |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
605 | } |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
606 | if (GTK_IMHTML(imhtml)->tip_timer) { |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
607 | g_source_remove(GTK_IMHTML(imhtml)->tip_timer); |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
608 | GTK_IMHTML(imhtml)->tip_timer = 0; |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
609 | } |
|
10946
63a41710fc94
[gaim-migrate @ 12742]
Daniel Atallah <datallah@pidgin.im>
parents:
10936
diff
changeset
|
610 | gdk_window_set_cursor( |
|
63a41710fc94
[gaim-migrate @ 12742]
Daniel Atallah <datallah@pidgin.im>
parents:
10936
diff
changeset
|
611 | gtk_text_view_get_window(GTK_TEXT_VIEW(imhtml), |
|
63a41710fc94
[gaim-migrate @ 12742]
Daniel Atallah <datallah@pidgin.im>
parents:
10936
diff
changeset
|
612 | GTK_TEXT_WINDOW_TEXT), NULL); |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
613 | |
|
8568
66907b37ce85
[gaim-migrate @ 9316]
Mark Doliner <markdoliner@pidgin.im>
parents:
8566
diff
changeset
|
614 | /* propagate the event normally */ |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
615 | return FALSE; |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
616 | } |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
617 | |
|
10844
fb5b88957742
[gaim-migrate @ 12516]
Richard Laager <rlaager@pidgin.im>
parents:
10834
diff
changeset
|
618 | #if (!GTK_CHECK_VERSION(2,2,0)) |
| 6066 | 619 | /* |
| 620 | * XXX - This should be removed eventually. | |
| 621 | * | |
| 8061 | 622 | * This function exists to work around a gross bug in GtkTextView. |
| 623 | * Basically, we short circuit ctrl+a and ctrl+end because they make | |
| 6066 | 624 | * el program go boom. |
| 625 | * | |
| 8061 | 626 | * It's supposed to be fixed in gtk2.2. You can view the bug report at |
| 6066 | 627 | * http://bugzilla.gnome.org/show_bug.cgi?id=107939 |
| 628 | */ | |
|
10849
476d68d7a435
[gaim-migrate @ 12521]
Richard Laager <rlaager@pidgin.im>
parents:
10844
diff
changeset
|
629 | static gboolean |
|
476d68d7a435
[gaim-migrate @ 12521]
Richard Laager <rlaager@pidgin.im>
parents:
10844
diff
changeset
|
630 | gtk_key_pressed_cb(GtkIMHtml *imhtml, GdkEventKey *event, gpointer data) |
| 8677 | 631 | { |
|
10844
fb5b88957742
[gaim-migrate @ 12516]
Richard Laager <rlaager@pidgin.im>
parents:
10834
diff
changeset
|
632 | if (event->state & GDK_CONTROL_MASK) { |
| 6066 | 633 | switch (event->keyval) { |
|
10844
fb5b88957742
[gaim-migrate @ 12516]
Richard Laager <rlaager@pidgin.im>
parents:
10834
diff
changeset
|
634 | case 'a': |
|
fb5b88957742
[gaim-migrate @ 12516]
Richard Laager <rlaager@pidgin.im>
parents:
10834
diff
changeset
|
635 | case GDK_Home: |
|
fb5b88957742
[gaim-migrate @ 12516]
Richard Laager <rlaager@pidgin.im>
parents:
10834
diff
changeset
|
636 | case GDK_End: |
|
fb5b88957742
[gaim-migrate @ 12516]
Richard Laager <rlaager@pidgin.im>
parents:
10834
diff
changeset
|
637 | return TRUE; |
| 6066 | 638 | } |
|
10844
fb5b88957742
[gaim-migrate @ 12516]
Richard Laager <rlaager@pidgin.im>
parents:
10834
diff
changeset
|
639 | } |
| 6066 | 640 | return FALSE; |
| 641 | } | |
|
10844
fb5b88957742
[gaim-migrate @ 12516]
Richard Laager <rlaager@pidgin.im>
parents:
10834
diff
changeset
|
642 | #endif /* !(GTK+ >= 2.2.0) */ |
| 10692 | 643 | |
| 644 | static gint | |
| 645 | gtk_imhtml_expose_event (GtkWidget *widget, | |
| 646 | GdkEventExpose *event) | |
| 647 | { | |
| 10776 | 648 | GtkTextIter start, end, cur; |
| 649 | int buf_x, buf_y; | |
| 650 | GdkRectangle visible_rect; | |
| 10777 | 651 | GdkGC *gc = gdk_gc_new(GDK_DRAWABLE(event->window)); |
| 652 | GdkColor gcolor; | |
|
10844
fb5b88957742
[gaim-migrate @ 12516]
Richard Laager <rlaager@pidgin.im>
parents:
10834
diff
changeset
|
653 | |
| 10776 | 654 | gtk_text_view_get_visible_rect(GTK_TEXT_VIEW(widget), &visible_rect); |
| 655 | gtk_text_view_buffer_to_window_coords(GTK_TEXT_VIEW(widget), | |
| 656 | GTK_TEXT_WINDOW_TEXT, | |
| 657 | visible_rect.x, | |
| 658 | visible_rect.y, | |
| 659 | &visible_rect.x, | |
| 660 | &visible_rect.y); | |
| 661 | ||
| 662 | gtk_text_view_window_to_buffer_coords(GTK_TEXT_VIEW(widget), GTK_TEXT_WINDOW_TEXT, | |
| 663 | event->area.x, event->area.y, &buf_x, &buf_y); | |
| 664 | ||
| 10777 | 665 | if (GTK_IMHTML(widget)->editable || GTK_IMHTML(widget)->wbfo) { |
|
11572
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
666 | |
| 10777 | 667 | if (GTK_IMHTML(widget)->edit.background) { |
| 668 | gdk_color_parse(GTK_IMHTML(widget)->edit.background, &gcolor); | |
| 669 | gdk_gc_set_rgb_fg_color(gc, &gcolor); | |
| 670 | } else { | |
| 671 | gdk_gc_set_rgb_fg_color(gc, &(widget->style->base[GTK_WIDGET_STATE(widget)])); | |
| 672 | } | |
|
11572
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
673 | |
| 10777 | 674 | gdk_draw_rectangle(event->window, |
| 675 | gc, | |
| 676 | TRUE, | |
| 677 | visible_rect.x, visible_rect.y, visible_rect.width, visible_rect.height); | |
| 678 | gdk_gc_unref(gc); | |
|
11572
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
679 | |
| 10777 | 680 | if (GTK_WIDGET_CLASS (parent_class)->expose_event) |
| 681 | return (* GTK_WIDGET_CLASS (parent_class)->expose_event) | |
| 682 | (widget, event); | |
| 683 | return FALSE; | |
| 684 | ||
| 685 | } | |
|
11572
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
686 | |
| 10776 | 687 | gtk_text_view_get_iter_at_location(GTK_TEXT_VIEW(widget), &start, buf_x, buf_y); |
| 688 | gtk_text_view_get_iter_at_location(GTK_TEXT_VIEW(widget), &end, | |
| 689 | buf_x + event->area.width, buf_y + event->area.height); | |
| 690 | ||
| 691 | ||
| 692 | ||
| 693 | cur = start; | |
| 694 | ||
| 695 | while (gtk_text_iter_in_range(&cur, &start, &end)) { | |
| 10795 | 696 | GSList *tags = gtk_text_iter_get_tags(&cur); |
| 697 | GSList *l; | |
| 10776 | 698 | |
| 699 | for (l = tags; l; l = l->next) { | |
| 700 | GtkTextTag *tag = l->data; | |
| 701 | GdkRectangle rect; | |
| 702 | GdkRectangle tag_area; | |
| 703 | const char *color; | |
|
11572
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
704 | |
| 10776 | 705 | if (strncmp(tag->name, "BACKGROUND ", 11)) |
| 706 | continue; | |
| 707 | ||
| 708 | if (gtk_text_iter_ends_tag(&cur, tag)) | |
| 709 | continue; | |
| 710 | ||
| 711 | gtk_text_view_get_iter_location(GTK_TEXT_VIEW(widget), &cur, &tag_area); | |
| 712 | gtk_text_view_buffer_to_window_coords(GTK_TEXT_VIEW(widget), | |
| 713 | GTK_TEXT_WINDOW_TEXT, | |
| 714 | tag_area.x, | |
| 715 | tag_area.y, | |
| 716 | &tag_area.x, | |
| 717 | &tag_area.y); | |
| 718 | rect.x = visible_rect.x; | |
| 719 | rect.y = tag_area.y; | |
|
11768
b45e26d7a4c9
[gaim-migrate @ 14059]
Gary Kramlich <grim@reaperworld.com>
parents:
11760
diff
changeset
|
720 | rect.width = visible_rect.width; |
| 10776 | 721 | |
| 10795 | 722 | do |
| 10776 | 723 | gtk_text_iter_forward_to_tag_toggle(&cur, tag); |
| 10795 | 724 | while (!gtk_text_iter_is_end(&cur) && gtk_text_iter_begins_tag(&cur, tag)); |
| 725 | ||
| 10776 | 726 | gtk_text_view_get_iter_location(GTK_TEXT_VIEW(widget), &cur, &tag_area); |
| 727 | gtk_text_view_buffer_to_window_coords(GTK_TEXT_VIEW(widget), | |
| 728 | GTK_TEXT_WINDOW_TEXT, | |
| 729 | tag_area.x, | |
| 730 | tag_area.y, | |
| 731 | &tag_area.x, | |
| 732 | &tag_area.y); | |
| 733 | ||
| 11760 | 734 | |
| 735 | rect.height = tag_area.y + tag_area.height - rect.y | |
| 736 | + gtk_text_view_get_pixels_below_lines(GTK_TEXT_VIEW(widget)); | |
|
11572
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
737 | |
| 10776 | 738 | color = tag->name + 11; |
| 739 | ||
| 10857 | 740 | if (!gdk_color_parse(color, &gcolor)) { |
| 10858 | 741 | gchar tmp[8]; |
| 742 | tmp[0] = '#'; | |
| 743 | strncpy(&tmp[1], color, 7); | |
| 744 | tmp[7] = '\0'; | |
| 10857 | 745 | if (!gdk_color_parse(tmp, &gcolor)) |
| 746 | gdk_color_parse("white", &gcolor); | |
| 747 | } | |
| 10776 | 748 | gdk_gc_set_rgb_fg_color(gc, &gcolor); |
| 749 | ||
| 750 | gdk_draw_rectangle(event->window, | |
| 751 | gc, | |
| 752 | TRUE, | |
| 753 | rect.x, rect.y, rect.width, rect.height); | |
| 10795 | 754 | gtk_text_iter_backward_char(&cur); /* go back one, in case the end is the begining is the end |
| 755 | * note that above, we always moved cur ahead by at least | |
| 756 | * one character */ | |
| 10776 | 757 | break; |
| 758 | } | |
| 759 | ||
| 760 | g_slist_free(tags); | |
| 10795 | 761 | |
| 762 | /* loop until another tag begins, or no tag begins */ | |
| 763 | while (gtk_text_iter_forward_to_tag_toggle(&cur, NULL) && | |
| 764 | !gtk_text_iter_is_end(&cur) && | |
| 765 | !gtk_text_iter_begins_tag(&cur, NULL)); | |
|
11572
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
766 | } |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
767 | |
| 10777 | 768 | gdk_gc_unref(gc); |
| 769 | ||
| 10692 | 770 | if (GTK_WIDGET_CLASS (parent_class)->expose_event) |
| 771 | return (* GTK_WIDGET_CLASS (parent_class)->expose_event) | |
| 772 | (widget, event); | |
| 10776 | 773 | |
| 10692 | 774 | return FALSE; |
| 775 | } | |
| 776 | ||
| 777 | ||
| 8931 | 778 | static void paste_unformatted_cb(GtkMenuItem *menu, GtkIMHtml *imhtml) |
| 779 | { | |
| 780 | GtkClipboard *clipboard = gtk_widget_get_clipboard(GTK_WIDGET(imhtml), GDK_SELECTION_CLIPBOARD); | |
| 781 | ||
| 782 | gtk_clipboard_request_text(clipboard, paste_plaintext_received_cb, imhtml); | |
| 783 | ||
| 784 | } | |
| 785 | ||
| 13336 | 786 | static void clear_formatting_cb(GtkMenuItem *menu, GtkIMHtml *imhtml) |
| 787 | { | |
| 788 | gtk_imhtml_clear_formatting(imhtml); | |
| 789 | } | |
| 10692 | 790 | |
| 8931 | 791 | static void hijack_menu_cb(GtkIMHtml *imhtml, GtkMenu *menu, gpointer data) |
| 792 | { | |
| 793 | GtkWidget *menuitem; | |
| 794 | ||
|
12635
5b2fbc3da55b
[gaim-migrate @ 14971]
Richard Laager <rlaager@pidgin.im>
parents:
12605
diff
changeset
|
795 | menuitem = gtk_menu_item_new_with_mnemonic(_("Paste as Plain _Text")); |
| 8931 | 796 | gtk_widget_show(menuitem); |
|
14970
fd8984ce4fda
[gaim-migrate @ 17680]
Mark Doliner <markdoliner@pidgin.im>
parents:
14863
diff
changeset
|
797 | /* |
|
fd8984ce4fda
[gaim-migrate @ 17680]
Mark Doliner <markdoliner@pidgin.im>
parents:
14863
diff
changeset
|
798 | * TODO: gtk_clipboard_wait_is_text_available() iterates the glib |
|
fd8984ce4fda
[gaim-migrate @ 17680]
Mark Doliner <markdoliner@pidgin.im>
parents:
14863
diff
changeset
|
799 | * mainloop, which tends to be a source of bugs. It would |
|
fd8984ce4fda
[gaim-migrate @ 17680]
Mark Doliner <markdoliner@pidgin.im>
parents:
14863
diff
changeset
|
800 | * be good to audit this or change it to not wait. |
|
fd8984ce4fda
[gaim-migrate @ 17680]
Mark Doliner <markdoliner@pidgin.im>
parents:
14863
diff
changeset
|
801 | */ |
| 8931 | 802 | gtk_widget_set_sensitive(menuitem, |
|
12836
837fe5d43dac
[gaim-migrate @ 15184]
Richard Laager <rlaager@pidgin.im>
parents:
12833
diff
changeset
|
803 | (imhtml->editable && |
|
837fe5d43dac
[gaim-migrate @ 15184]
Richard Laager <rlaager@pidgin.im>
parents:
12833
diff
changeset
|
804 | gtk_clipboard_wait_is_text_available( |
|
837fe5d43dac
[gaim-migrate @ 15184]
Richard Laager <rlaager@pidgin.im>
parents:
12833
diff
changeset
|
805 | gtk_widget_get_clipboard(GTK_WIDGET(imhtml), GDK_SELECTION_CLIPBOARD)))); |
| 8931 | 806 | /* put it after "Paste" */ |
| 807 | gtk_menu_shell_insert(GTK_MENU_SHELL(menu), menuitem, 3); | |
| 808 | ||
| 809 | g_signal_connect(G_OBJECT(menuitem), "activate", | |
| 810 | G_CALLBACK(paste_unformatted_cb), imhtml); | |
| 13336 | 811 | |
|
13539
8036a635a316
[gaim-migrate @ 15915]
Richard Laager <rlaager@pidgin.im>
parents:
13340
diff
changeset
|
812 | menuitem = gtk_menu_item_new_with_mnemonic(_("_Reset formatting")); |
| 13336 | 813 | gtk_widget_show(menuitem); |
|
13340
e18166659513
[gaim-migrate @ 15709]
Richard Laager <rlaager@pidgin.im>
parents:
13336
diff
changeset
|
814 | gtk_widget_set_sensitive(menuitem, imhtml->editable); |
| 13336 | 815 | /* put it after Delete */ |
| 816 | gtk_menu_shell_insert(GTK_MENU_SHELL(menu), menuitem, 5); | |
| 817 | ||
| 818 | g_signal_connect(G_OBJECT(menuitem), "activate", G_CALLBACK(clear_formatting_cb), imhtml); | |
| 8931 | 819 | } |
| 820 | ||
|
11572
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
821 | static char * |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
822 | ucs2_order(gboolean swap) |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
823 | { |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
824 | gboolean be; |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
825 | |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
826 | be = G_BYTE_ORDER == G_BIG_ENDIAN; |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
827 | be = swap ? be : !be; |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
828 | |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
829 | if (be) |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
830 | return "UCS-2BE"; |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
831 | else |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
832 | return "UCS-2LE"; |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
833 | |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
834 | } |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
835 | |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
836 | /* Convert from UCS-2 to UTF-8, stripping the BOM if one is present.*/ |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
837 | static gchar * |
| 11586 | 838 | ucs2_to_utf8_with_bom_check(gchar *data, guint len) { |
|
11572
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
839 | char *fromcode = NULL; |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
840 | GError *error = NULL; |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
841 | guint16 c; |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
842 | gchar *utf8_ret; |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
843 | |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
844 | /* |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
845 | * Unicode Techinical Report 20 |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
846 | * ( http://www.unicode.org/unicode/reports/tr20/ ) says to treat an |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
847 | * initial 0xfeff (ZWNBSP) as a byte order indicator so that is |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
848 | * what we do. If there is no indicator assume it is in the default |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
849 | * order |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
850 | */ |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
851 | |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
852 | memcpy(&c, data, 2); |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
853 | switch (c) { |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
854 | case 0xfeff: |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
855 | case 0xfffe: |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
856 | fromcode = ucs2_order(c == 0xfeff); |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
857 | data += 2; |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
858 | len -= 2; |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
859 | break; |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
860 | default: |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
861 | fromcode = "UCS-2"; |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
862 | break; |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
863 | } |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
864 | |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
865 | utf8_ret = g_convert(data, len, "UTF-8", fromcode, NULL, NULL, &error); |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
866 | |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
867 | if (error) { |
| 15884 | 868 | purple_debug_warning("gtkimhtml", "g_convert error: %s\n", error->message); |
|
11572
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
869 | g_error_free(error); |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
870 | } |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
871 | return utf8_ret; |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
872 | } |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
873 | |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
874 | |
| 8061 | 875 | static void gtk_imhtml_clipboard_get(GtkClipboard *clipboard, GtkSelectionData *selection_data, guint info, GtkIMHtml *imhtml) { |
|
15111
e427dd6f3b7e
[gaim-migrate @ 17833]
Daniel Atallah <datallah@pidgin.im>
parents:
15093
diff
changeset
|
876 | char *text = NULL; |
|
17546
51b1c1e2c3fe
Maintain global poitners to the clipboard selection text, with the aim of
Sean Egan <seanegan@pidgin.im>
parents:
17406
diff
changeset
|
877 | gboolean primary = (clipboard != clipboard_selection); |
| 8061 | 878 | GtkTextIter start, end; |
|
17546
51b1c1e2c3fe
Maintain global poitners to the clipboard selection text, with the aim of
Sean Egan <seanegan@pidgin.im>
parents:
17406
diff
changeset
|
879 | GtkTextMark *sel = NULL; |
|
51b1c1e2c3fe
Maintain global poitners to the clipboard selection text, with the aim of
Sean Egan <seanegan@pidgin.im>
parents:
17406
diff
changeset
|
880 | GtkTextMark *ins = NULL; |
|
51b1c1e2c3fe
Maintain global poitners to the clipboard selection text, with the aim of
Sean Egan <seanegan@pidgin.im>
parents:
17406
diff
changeset
|
881 | |
|
51b1c1e2c3fe
Maintain global poitners to the clipboard selection text, with the aim of
Sean Egan <seanegan@pidgin.im>
parents:
17406
diff
changeset
|
882 | if (primary) { |
|
51b1c1e2c3fe
Maintain global poitners to the clipboard selection text, with the aim of
Sean Egan <seanegan@pidgin.im>
parents:
17406
diff
changeset
|
883 | ins = gtk_text_buffer_get_insert(imhtml->text_buffer); |
|
51b1c1e2c3fe
Maintain global poitners to the clipboard selection text, with the aim of
Sean Egan <seanegan@pidgin.im>
parents:
17406
diff
changeset
|
884 | sel = gtk_text_buffer_get_selection_bound(imhtml->text_buffer); |
|
51b1c1e2c3fe
Maintain global poitners to the clipboard selection text, with the aim of
Sean Egan <seanegan@pidgin.im>
parents:
17406
diff
changeset
|
885 | gtk_text_buffer_get_iter_at_mark(imhtml->text_buffer, &start, sel); |
|
51b1c1e2c3fe
Maintain global poitners to the clipboard selection text, with the aim of
Sean Egan <seanegan@pidgin.im>
parents:
17406
diff
changeset
|
886 | gtk_text_buffer_get_iter_at_mark(imhtml->text_buffer, &end, ins); |
|
51b1c1e2c3fe
Maintain global poitners to the clipboard selection text, with the aim of
Sean Egan <seanegan@pidgin.im>
parents:
17406
diff
changeset
|
887 | } |
| 8061 | 888 | |
| 889 | if (info == TARGET_HTML) { | |
|
15111
e427dd6f3b7e
[gaim-migrate @ 17833]
Daniel Atallah <datallah@pidgin.im>
parents:
15093
diff
changeset
|
890 | char *selection; |
|
e427dd6f3b7e
[gaim-migrate @ 17833]
Daniel Atallah <datallah@pidgin.im>
parents:
15093
diff
changeset
|
891 | #ifndef _WIN32 |
| 8907 | 892 | gsize len; |
| 8061 | 893 | GString *str = g_string_new(NULL); |
| 8681 | 894 | if (primary) { |
| 895 | text = gtk_imhtml_get_markup_range(imhtml, &start, &end); | |
| 10013 | 896 | } else |
|
17546
51b1c1e2c3fe
Maintain global poitners to the clipboard selection text, with the aim of
Sean Egan <seanegan@pidgin.im>
parents:
17406
diff
changeset
|
897 | text = html_clipboard; |
| 8061 | 898 | |
| 899 | /* Mozilla asks that we start our text/html with the Unicode byte order mark */ | |
| 900 | str = g_string_append_unichar(str, 0xfeff); | |
| 901 | str = g_string_append(str, text); | |
| 902 | str = g_string_append_unichar(str, 0x0000); | |
|
8148
dc970ca129c5
[gaim-migrate @ 8859]
Mohammed Sameer <msameer@users.sourceforge.net>
parents:
8128
diff
changeset
|
903 | selection = g_convert(str->str, str->len, "UCS-2", "UTF-8", NULL, &len, NULL); |
|
11143
f606fb334190
[gaim-migrate @ 13207]
Mark Doliner <markdoliner@pidgin.im>
parents:
11069
diff
changeset
|
904 | gtk_selection_data_set(selection_data, gdk_atom_intern("text/html", FALSE), 16, (const guchar *)selection, len); |
| 8061 | 905 | g_string_free(str, TRUE); |
|
15111
e427dd6f3b7e
[gaim-migrate @ 17833]
Daniel Atallah <datallah@pidgin.im>
parents:
15093
diff
changeset
|
906 | #else |
|
18665
157820042a6f
Fix #1727 and also plug a possible leak and make a little efficiency improvement to the win32 clipboard handling.
Daniel Atallah <datallah@pidgin.im>
parents:
18633
diff
changeset
|
907 | selection = clipboard_html_to_win32(html_clipboard); |
|
15111
e427dd6f3b7e
[gaim-migrate @ 17833]
Daniel Atallah <datallah@pidgin.im>
parents:
15093
diff
changeset
|
908 | gtk_selection_data_set(selection_data, gdk_atom_intern("HTML Format", FALSE), 8, (const guchar *)selection, strlen(selection)); |
|
e427dd6f3b7e
[gaim-migrate @ 17833]
Daniel Atallah <datallah@pidgin.im>
parents:
15093
diff
changeset
|
909 | #endif |
| 8061 | 910 | g_free(selection); |
| 911 | } else { | |
| 8681 | 912 | if (primary) { |
| 913 | text = gtk_imhtml_get_text(imhtml, &start, &end); | |
| 914 | } else | |
|
17546
51b1c1e2c3fe
Maintain global poitners to the clipboard selection text, with the aim of
Sean Egan <seanegan@pidgin.im>
parents:
17406
diff
changeset
|
915 | text = text_clipboard; |
| 8061 | 916 | gtk_selection_data_set_text(selection_data, text, strlen(text)); |
| 917 | } | |
| 8681 | 918 | if (primary) /* This was allocated here */ |
| 919 | g_free(text); | |
| 920 | } | |
| 8061 | 921 | |
| 922 | static void gtk_imhtml_primary_clipboard_clear(GtkClipboard *clipboard, GtkIMHtml *imhtml) | |
| 7749 | 923 | { |
| 8061 | 924 | GtkTextIter insert; |
| 925 | GtkTextIter selection_bound; | |
| 926 | ||
| 927 | gtk_text_buffer_get_iter_at_mark (imhtml->text_buffer, &insert, | |
| 928 | gtk_text_buffer_get_mark (imhtml->text_buffer, "insert")); | |
| 929 | gtk_text_buffer_get_iter_at_mark (imhtml->text_buffer, &selection_bound, | |
| 930 | gtk_text_buffer_get_mark (imhtml->text_buffer, "selection_bound")); | |
| 931 | ||
| 932 | if (!gtk_text_iter_equal (&insert, &selection_bound)) | |
| 933 | gtk_text_buffer_move_mark (imhtml->text_buffer, | |
| 934 | gtk_text_buffer_get_mark (imhtml->text_buffer, "selection_bound"), | |
| 935 | &insert); | |
| 7749 | 936 | } |
| 7742 | 937 | |
|
17546
51b1c1e2c3fe
Maintain global poitners to the clipboard selection text, with the aim of
Sean Egan <seanegan@pidgin.im>
parents:
17406
diff
changeset
|
938 | static void gtk_imhtml_clipboard_clear (GtkClipboard *clipboard, GtkSelectionData *sel_data, |
|
51b1c1e2c3fe
Maintain global poitners to the clipboard selection text, with the aim of
Sean Egan <seanegan@pidgin.im>
parents:
17406
diff
changeset
|
939 | guint info, gpointer user_data_or_owner) |
|
51b1c1e2c3fe
Maintain global poitners to the clipboard selection text, with the aim of
Sean Egan <seanegan@pidgin.im>
parents:
17406
diff
changeset
|
940 | { |
|
51b1c1e2c3fe
Maintain global poitners to the clipboard selection text, with the aim of
Sean Egan <seanegan@pidgin.im>
parents:
17406
diff
changeset
|
941 | clipboard_selection = NULL; |
|
51b1c1e2c3fe
Maintain global poitners to the clipboard selection text, with the aim of
Sean Egan <seanegan@pidgin.im>
parents:
17406
diff
changeset
|
942 | } |
|
51b1c1e2c3fe
Maintain global poitners to the clipboard selection text, with the aim of
Sean Egan <seanegan@pidgin.im>
parents:
17406
diff
changeset
|
943 | |
| 8677 | 944 | static void copy_clipboard_cb(GtkIMHtml *imhtml, gpointer unused) |
| 7749 | 945 | { |
| 8681 | 946 | GtkTextIter start, end; |
|
17288
ffda972c2fb4
Ignore copy/cut requests when there is no selection instead of clearing the clipboard. This is consistent with the rest of how GTK+ works. Fixes #1030
Daniel Atallah <datallah@pidgin.im>
parents:
17189
diff
changeset
|
947 | if (gtk_text_buffer_get_selection_bounds(imhtml->text_buffer, &start, &end)) { |
|
17546
51b1c1e2c3fe
Maintain global poitners to the clipboard selection text, with the aim of
Sean Egan <seanegan@pidgin.im>
parents:
17406
diff
changeset
|
948 | if (!clipboard_selection) |
|
51b1c1e2c3fe
Maintain global poitners to the clipboard selection text, with the aim of
Sean Egan <seanegan@pidgin.im>
parents:
17406
diff
changeset
|
949 | clipboard_selection = gtk_widget_get_clipboard(GTK_WIDGET(imhtml), GDK_SELECTION_CLIPBOARD); |
|
51b1c1e2c3fe
Maintain global poitners to the clipboard selection text, with the aim of
Sean Egan <seanegan@pidgin.im>
parents:
17406
diff
changeset
|
950 | gtk_clipboard_set_with_owner(clipboard_selection, |
|
17288
ffda972c2fb4
Ignore copy/cut requests when there is no selection instead of clearing the clipboard. This is consistent with the rest of how GTK+ works. Fixes #1030
Daniel Atallah <datallah@pidgin.im>
parents:
17189
diff
changeset
|
951 | selection_targets, sizeof(selection_targets) / sizeof(GtkTargetEntry), |
|
ffda972c2fb4
Ignore copy/cut requests when there is no selection instead of clearing the clipboard. This is consistent with the rest of how GTK+ works. Fixes #1030
Daniel Atallah <datallah@pidgin.im>
parents:
17189
diff
changeset
|
952 | (GtkClipboardGetFunc)gtk_imhtml_clipboard_get, |
|
17546
51b1c1e2c3fe
Maintain global poitners to the clipboard selection text, with the aim of
Sean Egan <seanegan@pidgin.im>
parents:
17406
diff
changeset
|
953 | (GtkClipboardClearFunc)gtk_imhtml_clipboard_clear, G_OBJECT(imhtml)); |
|
17288
ffda972c2fb4
Ignore copy/cut requests when there is no selection instead of clearing the clipboard. This is consistent with the rest of how GTK+ works. Fixes #1030
Daniel Atallah <datallah@pidgin.im>
parents:
17189
diff
changeset
|
954 | |
|
18665
157820042a6f
Fix #1727 and also plug a possible leak and make a little efficiency improvement to the win32 clipboard handling.
Daniel Atallah <datallah@pidgin.im>
parents:
18633
diff
changeset
|
955 | g_free(html_clipboard); |
|
157820042a6f
Fix #1727 and also plug a possible leak and make a little efficiency improvement to the win32 clipboard handling.
Daniel Atallah <datallah@pidgin.im>
parents:
18633
diff
changeset
|
956 | g_free(text_clipboard); |
|
17288
ffda972c2fb4
Ignore copy/cut requests when there is no selection instead of clearing the clipboard. This is consistent with the rest of how GTK+ works. Fixes #1030
Daniel Atallah <datallah@pidgin.im>
parents:
17189
diff
changeset
|
957 | |
|
ffda972c2fb4
Ignore copy/cut requests when there is no selection instead of clearing the clipboard. This is consistent with the rest of how GTK+ works. Fixes #1030
Daniel Atallah <datallah@pidgin.im>
parents:
17189
diff
changeset
|
958 | imhtml->clipboard_html_string = gtk_imhtml_get_markup_range(imhtml, &start, &end); |
|
ffda972c2fb4
Ignore copy/cut requests when there is no selection instead of clearing the clipboard. This is consistent with the rest of how GTK+ works. Fixes #1030
Daniel Atallah <datallah@pidgin.im>
parents:
17189
diff
changeset
|
959 | imhtml->clipboard_text_string = gtk_imhtml_get_text(imhtml, &start, &end); |
|
17546
51b1c1e2c3fe
Maintain global poitners to the clipboard selection text, with the aim of
Sean Egan <seanegan@pidgin.im>
parents:
17406
diff
changeset
|
960 | |
|
51b1c1e2c3fe
Maintain global poitners to the clipboard selection text, with the aim of
Sean Egan <seanegan@pidgin.im>
parents:
17406
diff
changeset
|
961 | text_clipboard = imhtml->clipboard_text_string; |
|
51b1c1e2c3fe
Maintain global poitners to the clipboard selection text, with the aim of
Sean Egan <seanegan@pidgin.im>
parents:
17406
diff
changeset
|
962 | html_clipboard = imhtml->clipboard_html_string; |
|
51b1c1e2c3fe
Maintain global poitners to the clipboard selection text, with the aim of
Sean Egan <seanegan@pidgin.im>
parents:
17406
diff
changeset
|
963 | |
| 8681 | 964 | } |
| 965 | ||
| 8061 | 966 | g_signal_stop_emission_by_name(imhtml, "copy-clipboard"); |
| 967 | } | |
| 968 | ||
| 8698 | 969 | static void cut_clipboard_cb(GtkIMHtml *imhtml, gpointer unused) |
| 970 | { | |
| 971 | GtkTextIter start, end; | |
|
17288
ffda972c2fb4
Ignore copy/cut requests when there is no selection instead of clearing the clipboard. This is consistent with the rest of how GTK+ works. Fixes #1030
Daniel Atallah <datallah@pidgin.im>
parents:
17189
diff
changeset
|
972 | if (gtk_text_buffer_get_selection_bounds(imhtml->text_buffer, &start, &end)) { |
|
17546
51b1c1e2c3fe
Maintain global poitners to the clipboard selection text, with the aim of
Sean Egan <seanegan@pidgin.im>
parents:
17406
diff
changeset
|
973 | if (!clipboard_selection) |
|
51b1c1e2c3fe
Maintain global poitners to the clipboard selection text, with the aim of
Sean Egan <seanegan@pidgin.im>
parents:
17406
diff
changeset
|
974 | clipboard_selection = gtk_widget_get_clipboard(GTK_WIDGET(imhtml), GDK_SELECTION_CLIPBOARD); |
|
51b1c1e2c3fe
Maintain global poitners to the clipboard selection text, with the aim of
Sean Egan <seanegan@pidgin.im>
parents:
17406
diff
changeset
|
975 | gtk_clipboard_set_with_owner(clipboard_selection, |
|
17288
ffda972c2fb4
Ignore copy/cut requests when there is no selection instead of clearing the clipboard. This is consistent with the rest of how GTK+ works. Fixes #1030
Daniel Atallah <datallah@pidgin.im>
parents:
17189
diff
changeset
|
976 | selection_targets, sizeof(selection_targets) / sizeof(GtkTargetEntry), |
|
ffda972c2fb4
Ignore copy/cut requests when there is no selection instead of clearing the clipboard. This is consistent with the rest of how GTK+ works. Fixes #1030
Daniel Atallah <datallah@pidgin.im>
parents:
17189
diff
changeset
|
977 | (GtkClipboardGetFunc)gtk_imhtml_clipboard_get, |
|
17546
51b1c1e2c3fe
Maintain global poitners to the clipboard selection text, with the aim of
Sean Egan <seanegan@pidgin.im>
parents:
17406
diff
changeset
|
978 | (GtkClipboardClearFunc)gtk_imhtml_clipboard_clear, G_OBJECT(imhtml)); |
|
17288
ffda972c2fb4
Ignore copy/cut requests when there is no selection instead of clearing the clipboard. This is consistent with the rest of how GTK+ works. Fixes #1030
Daniel Atallah <datallah@pidgin.im>
parents:
17189
diff
changeset
|
979 | |
|
18665
157820042a6f
Fix #1727 and also plug a possible leak and make a little efficiency improvement to the win32 clipboard handling.
Daniel Atallah <datallah@pidgin.im>
parents:
18633
diff
changeset
|
980 | g_free(html_clipboard); |
|
157820042a6f
Fix #1727 and also plug a possible leak and make a little efficiency improvement to the win32 clipboard handling.
Daniel Atallah <datallah@pidgin.im>
parents:
18633
diff
changeset
|
981 | g_free(text_clipboard); |
|
17288
ffda972c2fb4
Ignore copy/cut requests when there is no selection instead of clearing the clipboard. This is consistent with the rest of how GTK+ works. Fixes #1030
Daniel Atallah <datallah@pidgin.im>
parents:
17189
diff
changeset
|
982 | |
|
ffda972c2fb4
Ignore copy/cut requests when there is no selection instead of clearing the clipboard. This is consistent with the rest of how GTK+ works. Fixes #1030
Daniel Atallah <datallah@pidgin.im>
parents:
17189
diff
changeset
|
983 | imhtml->clipboard_html_string = gtk_imhtml_get_markup_range(imhtml, &start, &end); |
|
ffda972c2fb4
Ignore copy/cut requests when there is no selection instead of clearing the clipboard. This is consistent with the rest of how GTK+ works. Fixes #1030
Daniel Atallah <datallah@pidgin.im>
parents:
17189
diff
changeset
|
984 | imhtml->clipboard_text_string = gtk_imhtml_get_text(imhtml, &start, &end); |
|
ffda972c2fb4
Ignore copy/cut requests when there is no selection instead of clearing the clipboard. This is consistent with the rest of how GTK+ works. Fixes #1030
Daniel Atallah <datallah@pidgin.im>
parents:
17189
diff
changeset
|
985 | |
|
17546
51b1c1e2c3fe
Maintain global poitners to the clipboard selection text, with the aim of
Sean Egan <seanegan@pidgin.im>
parents:
17406
diff
changeset
|
986 | text_clipboard = imhtml->clipboard_text_string; |
|
51b1c1e2c3fe
Maintain global poitners to the clipboard selection text, with the aim of
Sean Egan <seanegan@pidgin.im>
parents:
17406
diff
changeset
|
987 | html_clipboard = imhtml->clipboard_html_string; |
|
51b1c1e2c3fe
Maintain global poitners to the clipboard selection text, with the aim of
Sean Egan <seanegan@pidgin.im>
parents:
17406
diff
changeset
|
988 | |
|
17288
ffda972c2fb4
Ignore copy/cut requests when there is no selection instead of clearing the clipboard. This is consistent with the rest of how GTK+ works. Fixes #1030
Daniel Atallah <datallah@pidgin.im>
parents:
17189
diff
changeset
|
989 | if (imhtml->editable) |
|
ffda972c2fb4
Ignore copy/cut requests when there is no selection instead of clearing the clipboard. This is consistent with the rest of how GTK+ works. Fixes #1030
Daniel Atallah <datallah@pidgin.im>
parents:
17189
diff
changeset
|
990 | gtk_text_buffer_delete_selection(imhtml->text_buffer, FALSE, FALSE); |
| 8698 | 991 | } |
| 992 | ||
| 993 | g_signal_stop_emission_by_name(imhtml, "cut-clipboard"); | |
| 994 | } | |
| 995 | ||
| 8931 | 996 | static void imhtml_paste_insert(GtkIMHtml *imhtml, const char *text, gboolean plaintext) |
| 997 | { | |
| 998 | GtkTextIter iter; | |
| 9465 | 999 | GtkIMHtmlOptions flags = plaintext ? 0 : (GTK_IMHTML_NO_NEWLINE | GTK_IMHTML_NO_COMMENTS); |
| 8931 | 1000 | |
| 9028 | 1001 | if (gtk_text_buffer_get_selection_bounds(imhtml->text_buffer, NULL, NULL)) |
| 1002 | gtk_text_buffer_delete_selection(imhtml->text_buffer, TRUE, TRUE); | |
| 1003 | ||
| 8931 | 1004 | gtk_text_buffer_get_iter_at_mark(imhtml->text_buffer, &iter, gtk_text_buffer_get_insert(imhtml->text_buffer)); |
| 1005 | if (!imhtml->wbfo && !plaintext) | |
| 1006 | gtk_imhtml_close_tags(imhtml, &iter); | |
| 1007 | ||
| 1008 | gtk_imhtml_insert_html_at_iter(imhtml, text, flags, &iter); | |
|
11267
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
1009 | gtk_text_buffer_move_mark_by_name(imhtml->text_buffer, "insert", &iter); |
| 8931 | 1010 | gtk_text_view_scroll_to_mark(GTK_TEXT_VIEW(imhtml), gtk_text_buffer_get_insert(imhtml->text_buffer), |
| 1011 | 0, FALSE, 0.0, 0.0); | |
|
18363
3e2a0ab4d6f8
Re-arrange a few lines in gtkimhtml's paste function so that we reset formatting after moving the cursor to the new location. Fixes #1198
Sean Egan <seanegan@pidgin.im>
parents:
18283
diff
changeset
|
1012 | if (!imhtml->wbfo && !plaintext) |
|
3e2a0ab4d6f8
Re-arrange a few lines in gtkimhtml's paste function so that we reset formatting after moving the cursor to the new location. Fixes #1198
Sean Egan <seanegan@pidgin.im>
parents:
18283
diff
changeset
|
1013 | gtk_imhtml_close_tags(imhtml, &iter); |
|
3e2a0ab4d6f8
Re-arrange a few lines in gtkimhtml's paste function so that we reset formatting after moving the cursor to the new location. Fixes #1198
Sean Egan <seanegan@pidgin.im>
parents:
18283
diff
changeset
|
1014 | |
| 8931 | 1015 | } |
| 1016 | ||
| 1017 | static void paste_plaintext_received_cb (GtkClipboard *clipboard, const gchar *text, gpointer data) | |
| 1018 | { | |
| 1019 | char *tmp; | |
| 1020 | ||
| 1021 | if (text == NULL) | |
| 1022 | return; | |
| 1023 | ||
|
10732
5e314ab498bf
[gaim-migrate @ 12334]
Richard Laager <rlaager@pidgin.im>
parents:
10699
diff
changeset
|
1024 | tmp = g_markup_escape_text(text, -1); |
| 8931 | 1025 | imhtml_paste_insert(data, tmp, TRUE); |
| 1026 | g_free(tmp); | |
| 1027 | } | |
| 1028 | ||
| 8061 | 1029 | static void paste_received_cb (GtkClipboard *clipboard, GtkSelectionData *selection_data, gpointer data) |
| 1030 | { | |
| 1031 | char *text; | |
| 1032 | GtkIMHtml *imhtml = data; | |
| 7809 | 1033 | |
|
8123
e09c75f511c2
[gaim-migrate @ 8827]
Mark Doliner <markdoliner@pidgin.im>
parents:
8120
diff
changeset
|
1034 | if (!gtk_text_view_get_editable(GTK_TEXT_VIEW(imhtml))) |
|
8105
54ea897b764e
[gaim-migrate @ 8805]
Nathan Fredrickson <nathan@silverorange.com>
parents:
8091
diff
changeset
|
1035 | return; |
|
54ea897b764e
[gaim-migrate @ 8805]
Nathan Fredrickson <nathan@silverorange.com>
parents:
8091
diff
changeset
|
1036 | |
| 8061 | 1037 | if (selection_data->length < 0) { |
| 8931 | 1038 | gtk_clipboard_request_text(clipboard, paste_plaintext_received_cb, imhtml); |
| 1039 | return; | |
| 8061 | 1040 | } else { |
| 8719 | 1041 | #if 0 |
| 1042 | /* Here's some debug code, for figuring out what sent to us over the clipboard. */ | |
| 1043 | { | |
| 1044 | int i; | |
| 1045 | ||
| 15884 | 1046 | purple_debug_misc("gtkimhtml", "In paste_received_cb():\n\tformat = %d, length = %d\n\t", |
| 8719 | 1047 | selection_data->format, selection_data->length); |
| 1048 | ||
| 1049 | for (i = 0; i < (/*(selection_data->format / 8) **/ selection_data->length); i++) { | |
| 1050 | if ((i % 70) == 0) | |
| 1051 | printf("\n\t"); | |
| 1052 | if (selection_data->data[i] == '\0') | |
| 1053 | printf("."); | |
| 1054 | else | |
| 1055 | printf("%c", selection_data->data[i]); | |
| 1056 | } | |
| 1057 | printf("\n"); | |
| 1058 | } | |
| 1059 | #endif | |
| 1060 | text = g_malloc(selection_data->length); | |
| 1061 | memcpy(text, selection_data->data, selection_data->length); | |
| 7766 | 1062 | } |
| 8061 | 1063 | |
| 8869 | 1064 | if (selection_data->length >= 2 && |
| 1065 | (*(guint16 *)text == 0xfeff || *(guint16 *)text == 0xfffe)) { | |
| 1066 | /* This is UCS-2 */ | |
|
11572
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
1067 | char *utf8 = ucs2_to_utf8_with_bom_check(text, selection_data->length); |
| 8061 | 1068 | g_free(text); |
| 1069 | text = utf8; | |
| 8698 | 1070 | if (!text) { |
| 15884 | 1071 | purple_debug_warning("gtkimhtml", "g_convert from UCS-2 failed in paste_received_cb\n"); |
| 8698 | 1072 | return; |
| 1073 | } | |
| 8061 | 1074 | } |
|
11572
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
1075 | |
| 8698 | 1076 | if (!(*text) || !g_utf8_validate(text, -1, NULL)) { |
| 15884 | 1077 | purple_debug_warning("gtkimhtml", "empty string or invalid UTF-8 in paste_received_cb\n"); |
| 8698 | 1078 | g_free(text); |
| 1079 | return; | |
| 1080 | } | |
| 1081 | ||
| 8931 | 1082 | imhtml_paste_insert(imhtml, text, FALSE); |
| 8681 | 1083 | g_free(text); |
| 8061 | 1084 | } |
| 1085 | ||
| 1086 | static void paste_clipboard_cb(GtkIMHtml *imhtml, gpointer blah) | |
| 1087 | { | |
| 8931 | 1088 | #ifdef _WIN32 |
| 1089 | /* If we're on windows, let's see if we can get data from the HTML Format | |
|
10901
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
1090 | clipboard before we try to paste from the GTK buffer */ |
|
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
1091 | if (!clipboard_paste_html_win32(imhtml)) { |
| 8931 | 1092 | #endif |
| 8061 | 1093 | GtkClipboard *clipboard = gtk_widget_get_clipboard(GTK_WIDGET(imhtml), GDK_SELECTION_CLIPBOARD); |
| 1094 | gtk_clipboard_request_contents(clipboard, gdk_atom_intern("text/html", FALSE), | |
| 1095 | paste_received_cb, imhtml); | |
| 8931 | 1096 | #ifdef _WIN32 |
| 1097 | } | |
| 1098 | #endif | |
| 8061 | 1099 | g_signal_stop_emission_by_name(imhtml, "paste-clipboard"); |
| 7766 | 1100 | } |
| 1101 | ||
| 8677 | 1102 | static void imhtml_realized_remove_primary(GtkIMHtml *imhtml, gpointer unused) |
| 1103 | { | |
| 1104 | gtk_text_buffer_remove_selection_clipboard(GTK_IMHTML(imhtml)->text_buffer, | |
| 1105 | gtk_widget_get_clipboard(GTK_WIDGET(imhtml), GDK_SELECTION_PRIMARY)); | |
| 1106 | ||
| 1107 | } | |
| 1108 | ||
|
8740
098a43943bba
[gaim-migrate @ 9495]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
1109 | static void imhtml_destroy_add_primary(GtkIMHtml *imhtml, gpointer unused) |
|
098a43943bba
[gaim-migrate @ 9495]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
1110 | { |
|
098a43943bba
[gaim-migrate @ 9495]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
1111 | gtk_text_buffer_add_selection_clipboard(GTK_IMHTML(imhtml)->text_buffer, |
|
098a43943bba
[gaim-migrate @ 9495]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
1112 | gtk_widget_get_clipboard(GTK_WIDGET(imhtml), GDK_SELECTION_PRIMARY)); |
|
098a43943bba
[gaim-migrate @ 9495]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
1113 | } |
| 8677 | 1114 | |
| 1115 | static void mark_set_so_update_selection_cb(GtkTextBuffer *buffer, GtkTextIter *arg1, GtkTextMark *mark, GtkIMHtml *imhtml) | |
| 1116 | { | |
| 1117 | if (gtk_text_buffer_get_selection_bounds(buffer, NULL, NULL)) { | |
| 1118 | gtk_clipboard_set_with_owner(gtk_widget_get_clipboard(GTK_WIDGET(imhtml), GDK_SELECTION_PRIMARY), | |
| 1119 | selection_targets, sizeof(selection_targets) / sizeof(GtkTargetEntry), | |
| 1120 | (GtkClipboardGetFunc)gtk_imhtml_clipboard_get, | |
| 1121 | (GtkClipboardClearFunc)gtk_imhtml_primary_clipboard_clear, G_OBJECT(imhtml)); | |
| 1122 | } | |
| 1123 | } | |
| 1124 | ||
| 1125 | static gboolean gtk_imhtml_button_press_event(GtkIMHtml *imhtml, GdkEventButton *event, gpointer unused) | |
| 7346 | 1126 | { |
| 8677 | 1127 | if (event->button == 2) { |
| 1128 | int x, y; | |
| 1129 | GtkTextIter iter; | |
| 1130 | GtkClipboard *clipboard = gtk_widget_get_clipboard(GTK_WIDGET(imhtml), GDK_SELECTION_PRIMARY); | |
| 1131 | ||
| 1132 | if (!imhtml->editable) | |
| 1133 | return FALSE; | |
| 1134 | ||
| 1135 | gtk_text_view_window_to_buffer_coords(GTK_TEXT_VIEW(imhtml), | |
| 1136 | GTK_TEXT_WINDOW_TEXT, | |
| 1137 | event->x, | |
| 1138 | event->y, | |
| 1139 | &x, | |
| 1140 | &y); | |
| 1141 | gtk_text_view_get_iter_at_location(GTK_TEXT_VIEW(imhtml), &iter, x, y); | |
| 1142 | gtk_text_buffer_place_cursor(imhtml->text_buffer, &iter); | |
| 1143 | ||
| 1144 | gtk_clipboard_request_contents(clipboard, gdk_atom_intern("text/html", FALSE), | |
| 1145 | paste_received_cb, imhtml); | |
| 1146 | ||
| 1147 | return TRUE; | |
| 1148 | } | |
| 1149 | ||
| 7346 | 1150 | return FALSE; |
| 1151 | } | |
| 4263 | 1152 | |
|
17880
5e73968467e0
Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@pidgin.im>
parents:
17288
diff
changeset
|
1153 | static void |
|
5e73968467e0
Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@pidgin.im>
parents:
17288
diff
changeset
|
1154 | gtk_imhtml_undo(GtkIMHtml *imhtml) { |
|
5e73968467e0
Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@pidgin.im>
parents:
17288
diff
changeset
|
1155 | g_return_if_fail(GTK_IS_IMHTML(imhtml)); |
|
5e73968467e0
Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@pidgin.im>
parents:
17288
diff
changeset
|
1156 | g_return_if_fail(imhtml->editable); |
|
5e73968467e0
Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@pidgin.im>
parents:
17288
diff
changeset
|
1157 | |
|
5e73968467e0
Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@pidgin.im>
parents:
17288
diff
changeset
|
1158 | gtk_source_undo_manager_undo(imhtml->undo_manager); |
|
5e73968467e0
Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@pidgin.im>
parents:
17288
diff
changeset
|
1159 | } |
|
5e73968467e0
Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@pidgin.im>
parents:
17288
diff
changeset
|
1160 | |
|
5e73968467e0
Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@pidgin.im>
parents:
17288
diff
changeset
|
1161 | static void |
|
5e73968467e0
Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@pidgin.im>
parents:
17288
diff
changeset
|
1162 | gtk_imhtml_redo(GtkIMHtml *imhtml) { |
|
5e73968467e0
Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@pidgin.im>
parents:
17288
diff
changeset
|
1163 | g_return_if_fail(GTK_IS_IMHTML(imhtml)); |
|
5e73968467e0
Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@pidgin.im>
parents:
17288
diff
changeset
|
1164 | g_return_if_fail(imhtml->editable); |
|
5e73968467e0
Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@pidgin.im>
parents:
17288
diff
changeset
|
1165 | |
|
5e73968467e0
Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@pidgin.im>
parents:
17288
diff
changeset
|
1166 | gtk_source_undo_manager_redo(imhtml->undo_manager); |
|
5e73968467e0
Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@pidgin.im>
parents:
17288
diff
changeset
|
1167 | |
|
5e73968467e0
Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@pidgin.im>
parents:
17288
diff
changeset
|
1168 | } |
|
5e73968467e0
Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@pidgin.im>
parents:
17288
diff
changeset
|
1169 | |
| 10108 | 1170 | static gboolean imhtml_message_send(GtkIMHtml *imhtml) |
| 1171 | { | |
| 1172 | return FALSE; | |
| 1173 | } | |
| 1174 | ||
| 10100 | 1175 | static void imhtml_toggle_format(GtkIMHtml *imhtml, GtkIMHtmlButtons buttons) |
| 1176 | { | |
|
10699
7f9fa4f13758
[gaim-migrate @ 12256]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10695
diff
changeset
|
1177 | /* since this function is the handler for the formatting keystrokes, |
|
7f9fa4f13758
[gaim-migrate @ 12256]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10695
diff
changeset
|
1178 | we need to check here that the formatting attempted is permitted */ |
|
11275
cdcc651d7ecd
[gaim-migrate @ 13461]
Richard Laager <rlaager@pidgin.im>
parents:
11269
diff
changeset
|
1179 | buttons &= imhtml->format_functions; |
|
10699
7f9fa4f13758
[gaim-migrate @ 12256]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10695
diff
changeset
|
1180 | |
| 10100 | 1181 | switch (buttons) { |
| 1182 | case GTK_IMHTML_BOLD: | |
|
11267
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
1183 | imhtml_toggle_bold(imhtml); |
| 10100 | 1184 | break; |
| 1185 | case GTK_IMHTML_ITALIC: | |
|
11267
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
1186 | imhtml_toggle_italic(imhtml); |
| 10100 | 1187 | break; |
| 1188 | case GTK_IMHTML_UNDERLINE: | |
|
11267
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
1189 | imhtml_toggle_underline(imhtml); |
|
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
1190 | break; |
|
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
1191 | case GTK_IMHTML_STRIKE: |
|
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
1192 | imhtml_toggle_strike(imhtml); |
| 10100 | 1193 | break; |
| 1194 | case GTK_IMHTML_SHRINK: | |
|
11267
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
1195 | imhtml_font_shrink(imhtml); |
| 10100 | 1196 | break; |
| 1197 | case GTK_IMHTML_GROW: | |
|
11267
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
1198 | imhtml_font_grow(imhtml); |
| 10100 | 1199 | break; |
| 1200 | default: | |
| 1201 | break; | |
| 1202 | } | |
| 1203 | } | |
| 4032 | 1204 | |
| 1205 | static void | |
| 1206 | gtk_imhtml_finalize (GObject *object) | |
| 1207 | { | |
| 1208 | GtkIMHtml *imhtml = GTK_IMHTML(object); | |
| 4895 | 1209 | GList *scalables; |
| 8962 | 1210 | GSList *l; |
| 8061 | 1211 | |
| 10798 | 1212 | if (imhtml->scroll_src) |
| 1213 | g_source_remove(imhtml->scroll_src); | |
| 1214 | if (imhtml->scroll_time) | |
| 1215 | g_timer_destroy(imhtml->scroll_time); | |
| 1216 | ||
| 4138 | 1217 | g_hash_table_destroy(imhtml->smiley_data); |
| 4032 | 1218 | gtk_smiley_tree_destroy(imhtml->default_smilies); |
| 4138 | 1219 | gdk_cursor_unref(imhtml->hand_cursor); |
| 1220 | gdk_cursor_unref(imhtml->arrow_cursor); | |
| 8061 | 1221 | gdk_cursor_unref(imhtml->text_cursor); |
| 8677 | 1222 | |
| 4735 | 1223 | if(imhtml->tip_window){ |
| 1224 | gtk_widget_destroy(imhtml->tip_window); | |
| 1225 | } | |
| 1226 | if(imhtml->tip_timer) | |
| 1227 | gtk_timeout_remove(imhtml->tip_timer); | |
| 1228 | ||
| 4895 | 1229 | for(scalables = imhtml->scalables; scalables; scalables = scalables->next) { |
|
11224
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
1230 | struct scalable_data *sd = scalables->data; |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
1231 | GtkIMHtmlScalable *scale = GTK_IMHTML_SCALABLE(sd->scalable); |
| 4895 | 1232 | scale->free(scale); |
|
11224
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
1233 | g_free(sd); |
| 4895 | 1234 | } |
| 7991 | 1235 | |
| 8962 | 1236 | for (l = imhtml->im_images; l; l = l->next) { |
|
11224
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
1237 | struct im_image_data *img_data = l->data; |
| 8962 | 1238 | if (imhtml->funcs->image_unref) |
|
11224
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
1239 | imhtml->funcs->image_unref(img_data->id); |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
1240 | g_free(img_data); |
| 8962 | 1241 | } |
| 1242 | ||
| 4895 | 1243 | g_list_free(imhtml->scalables); |
| 8962 | 1244 | g_slist_free(imhtml->im_images); |
|
16385
aa5b9456e258
Fixes #213 This allows only 20 animated smileys to be animnating at a time
Sean Egan <seanegan@pidgin.im>
parents:
16291
diff
changeset
|
1245 | g_queue_free(imhtml->animations); |
|
14097
0c340861ab79
[gaim-migrate @ 16638]
Mark Doliner <markdoliner@pidgin.im>
parents:
14010
diff
changeset
|
1246 | g_free(imhtml->protocol_name); |
|
0c340861ab79
[gaim-migrate @ 16638]
Mark Doliner <markdoliner@pidgin.im>
parents:
14010
diff
changeset
|
1247 | g_free(imhtml->search_string); |
|
17880
5e73968467e0
Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@pidgin.im>
parents:
17288
diff
changeset
|
1248 | g_object_unref(imhtml->undo_manager); |
| 4032 | 1249 | G_OBJECT_CLASS(parent_class)->finalize (object); |
|
17546
51b1c1e2c3fe
Maintain global poitners to the clipboard selection text, with the aim of
Sean Egan <seanegan@pidgin.im>
parents:
17406
diff
changeset
|
1250 | if (clipboard_selection) |
|
51b1c1e2c3fe
Maintain global poitners to the clipboard selection text, with the aim of
Sean Egan <seanegan@pidgin.im>
parents:
17406
diff
changeset
|
1251 | gtk_clipboard_set_with_owner(clipboard_selection, |
|
51b1c1e2c3fe
Maintain global poitners to the clipboard selection text, with the aim of
Sean Egan <seanegan@pidgin.im>
parents:
17406
diff
changeset
|
1252 | selection_targets, sizeof(selection_targets) / sizeof(GtkTargetEntry), |
|
51b1c1e2c3fe
Maintain global poitners to the clipboard selection text, with the aim of
Sean Egan <seanegan@pidgin.im>
parents:
17406
diff
changeset
|
1253 | (GtkClipboardGetFunc)gtk_imhtml_clipboard_get, |
|
51b1c1e2c3fe
Maintain global poitners to the clipboard selection text, with the aim of
Sean Egan <seanegan@pidgin.im>
parents:
17406
diff
changeset
|
1254 | (GtkClipboardClearFunc)NULL, G_OBJECT(imhtml)); |
|
51b1c1e2c3fe
Maintain global poitners to the clipboard selection text, with the aim of
Sean Egan <seanegan@pidgin.im>
parents:
17406
diff
changeset
|
1255 | |
| 4032 | 1256 | } |
| 1428 | 1257 | |
|
10814
7e17cb56b019
[gaim-migrate @ 12468]
Luke Schierer <lschiere@pidgin.im>
parents:
10799
diff
changeset
|
1258 | /* Boring GTK+ stuff */ |
| 8519 | 1259 | static void gtk_imhtml_class_init (GtkIMHtmlClass *klass) |
| 1428 | 1260 | { |
| 9007 | 1261 | GtkWidgetClass *widget_class = (GtkWidgetClass *) klass; |
| 3922 | 1262 | GtkObjectClass *object_class; |
| 10100 | 1263 | GtkBindingSet *binding_set; |
| 4032 | 1264 | GObjectClass *gobject_class; |
| 8519 | 1265 | object_class = (GtkObjectClass*) klass; |
| 1266 | gobject_class = (GObjectClass*) klass; | |
| 4032 | 1267 | parent_class = gtk_type_class(GTK_TYPE_TEXT_VIEW); |
| 4417 | 1268 | signals[URL_CLICKED] = g_signal_new("url_clicked", |
| 1269 | G_TYPE_FROM_CLASS(gobject_class), | |
| 1270 | G_SIGNAL_RUN_FIRST, | |
| 1271 | G_STRUCT_OFFSET(GtkIMHtmlClass, url_clicked), | |
| 1272 | NULL, | |
| 1273 | 0, | |
| 1274 | g_cclosure_marshal_VOID__POINTER, | |
| 1275 | G_TYPE_NONE, 1, | |
| 1276 | G_TYPE_POINTER); | |
| 8506 | 1277 | signals[BUTTONS_UPDATE] = g_signal_new("format_buttons_update", |
| 8420 | 1278 | G_TYPE_FROM_CLASS(gobject_class), |
| 1279 | G_SIGNAL_RUN_FIRST, | |
| 1280 | G_STRUCT_OFFSET(GtkIMHtmlClass, buttons_update), | |
| 1281 | NULL, | |
| 1282 | 0, | |
|
10076
1ccc0286a4ae
[gaim-migrate @ 11057]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10062
diff
changeset
|
1283 | g_cclosure_marshal_VOID__INT, |
| 8420 | 1284 | G_TYPE_NONE, 1, |
| 1285 | G_TYPE_INT); | |
| 1286 | signals[TOGGLE_FORMAT] = g_signal_new("format_function_toggle", | |
| 1287 | G_TYPE_FROM_CLASS(gobject_class), | |
| 10100 | 1288 | G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION, |
| 8420 | 1289 | G_STRUCT_OFFSET(GtkIMHtmlClass, toggle_format), |
| 1290 | NULL, | |
| 1291 | 0, | |
|
10076
1ccc0286a4ae
[gaim-migrate @ 11057]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10062
diff
changeset
|
1292 | g_cclosure_marshal_VOID__INT, |
|
1ccc0286a4ae
[gaim-migrate @ 11057]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10062
diff
changeset
|
1293 | G_TYPE_NONE, 1, |
| 8420 | 1294 | G_TYPE_INT); |
| 8427 | 1295 | signals[CLEAR_FORMAT] = g_signal_new("format_function_clear", |
| 1296 | G_TYPE_FROM_CLASS(gobject_class), | |
|
11385
38ca1438e055
[gaim-migrate @ 13612]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11315
diff
changeset
|
1297 | G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION, |
| 8427 | 1298 | G_STRUCT_OFFSET(GtkIMHtmlClass, clear_format), |
| 1299 | NULL, | |
| 1300 | 0, | |
| 10100 | 1301 | g_cclosure_marshal_VOID__VOID, |
| 1302 | G_TYPE_NONE, 0); | |
| 8506 | 1303 | signals[UPDATE_FORMAT] = g_signal_new("format_function_update", |
| 10100 | 1304 | G_TYPE_FROM_CLASS(gobject_class), |
| 1305 | G_SIGNAL_RUN_FIRST, | |
| 1306 | G_STRUCT_OFFSET(GtkIMHtmlClass, update_format), | |
| 1307 | NULL, | |
| 1308 | 0, | |
| 1309 | g_cclosure_marshal_VOID__VOID, | |
| 1310 | G_TYPE_NONE, 0); | |
| 10108 | 1311 | signals[MESSAGE_SEND] = g_signal_new("message_send", |
| 1312 | G_TYPE_FROM_CLASS(gobject_class), | |
| 1313 | G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION, | |
| 1314 | G_STRUCT_OFFSET(GtkIMHtmlClass, message_send), | |
| 1315 | NULL, | |
| 1316 | 0, g_cclosure_marshal_VOID__VOID, | |
| 1317 | G_TYPE_NONE, 0); | |
|
17880
5e73968467e0
Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@pidgin.im>
parents:
17288
diff
changeset
|
1318 | signals [UNDO] = g_signal_new ("undo", |
|
5e73968467e0
Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@pidgin.im>
parents:
17288
diff
changeset
|
1319 | G_TYPE_FROM_CLASS (klass), |
|
5e73968467e0
Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@pidgin.im>
parents:
17288
diff
changeset
|
1320 | G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION, |
|
5e73968467e0
Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@pidgin.im>
parents:
17288
diff
changeset
|
1321 | G_STRUCT_OFFSET (GtkIMHtmlClass, undo), |
|
5e73968467e0
Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@pidgin.im>
parents:
17288
diff
changeset
|
1322 | NULL, |
|
5e73968467e0
Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@pidgin.im>
parents:
17288
diff
changeset
|
1323 | NULL, |
|
5e73968467e0
Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@pidgin.im>
parents:
17288
diff
changeset
|
1324 | gtksourceview_marshal_VOID__VOID, |
|
5e73968467e0
Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@pidgin.im>
parents:
17288
diff
changeset
|
1325 | G_TYPE_NONE, |
|
5e73968467e0
Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@pidgin.im>
parents:
17288
diff
changeset
|
1326 | 0); |
|
5e73968467e0
Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@pidgin.im>
parents:
17288
diff
changeset
|
1327 | signals [REDO] = g_signal_new ("redo", |
|
5e73968467e0
Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@pidgin.im>
parents:
17288
diff
changeset
|
1328 | G_TYPE_FROM_CLASS (klass), |
|
5e73968467e0
Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@pidgin.im>
parents:
17288
diff
changeset
|
1329 | G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION, |
|
5e73968467e0
Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@pidgin.im>
parents:
17288
diff
changeset
|
1330 | G_STRUCT_OFFSET (GtkIMHtmlClass, redo), |
|
5e73968467e0
Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@pidgin.im>
parents:
17288
diff
changeset
|
1331 | NULL, |
|
5e73968467e0
Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@pidgin.im>
parents:
17288
diff
changeset
|
1332 | NULL, |
|
5e73968467e0
Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@pidgin.im>
parents:
17288
diff
changeset
|
1333 | gtksourceview_marshal_VOID__VOID, |
|
5e73968467e0
Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@pidgin.im>
parents:
17288
diff
changeset
|
1334 | G_TYPE_NONE, |
|
5e73968467e0
Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@pidgin.im>
parents:
17288
diff
changeset
|
1335 | 0); |
|
5e73968467e0
Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@pidgin.im>
parents:
17288
diff
changeset
|
1336 | |
|
5e73968467e0
Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@pidgin.im>
parents:
17288
diff
changeset
|
1337 | |
| 10100 | 1338 | |
| 1339 | klass->toggle_format = imhtml_toggle_format; | |
| 10108 | 1340 | klass->message_send = imhtml_message_send; |
|
12672
673e2a1d2954
[gaim-migrate @ 15015]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12635
diff
changeset
|
1341 | klass->clear_format = imhtml_clear_formatting; |
|
17880
5e73968467e0
Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@pidgin.im>
parents:
17288
diff
changeset
|
1342 | klass->undo = gtk_imhtml_undo; |
|
5e73968467e0
Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@pidgin.im>
parents:
17288
diff
changeset
|
1343 | klass->redo = gtk_imhtml_redo; |
|
10184
543c9a84ce16
[gaim-migrate @ 11299]
Mark Doliner <markdoliner@pidgin.im>
parents:
10169
diff
changeset
|
1344 | |
| 4032 | 1345 | gobject_class->finalize = gtk_imhtml_finalize; |
|
10184
543c9a84ce16
[gaim-migrate @ 11299]
Mark Doliner <markdoliner@pidgin.im>
parents:
10169
diff
changeset
|
1346 | widget_class->drag_motion = gtk_text_view_drag_motion; |
| 10692 | 1347 | widget_class->expose_event = gtk_imhtml_expose_event; |
| 9007 | 1348 | gtk_widget_class_install_style_property(widget_class, g_param_spec_boxed("hyperlink-color", |
| 1349 | _("Hyperlink color"), | |
| 1350 | _("Color to draw hyperlinks."), | |
| 1351 | GDK_TYPE_COLOR, G_PARAM_READABLE)); | |
| 10799 | 1352 | gtk_widget_class_install_style_property(widget_class, g_param_spec_boxed("hyperlink-prelight-color", |
| 1353 | _("Hyperlink prelight color"), | |
| 1354 | _("Color to draw hyperlinks when mouse is over them."), | |
| 1355 | GDK_TYPE_COLOR, G_PARAM_READABLE)); | |
| 10100 | 1356 | |
| 1357 | binding_set = gtk_binding_set_by_class (parent_class); | |
| 10110 | 1358 | gtk_binding_entry_add_signal (binding_set, GDK_b, GDK_CONTROL_MASK, "format_function_toggle", 1, G_TYPE_INT, GTK_IMHTML_BOLD); |
| 10100 | 1359 | gtk_binding_entry_add_signal (binding_set, GDK_i, GDK_CONTROL_MASK, "format_function_toggle", 1, G_TYPE_INT, GTK_IMHTML_ITALIC); |
| 1360 | gtk_binding_entry_add_signal (binding_set, GDK_u, GDK_CONTROL_MASK, "format_function_toggle", 1, G_TYPE_INT, GTK_IMHTML_UNDERLINE); | |
| 1361 | gtk_binding_entry_add_signal (binding_set, GDK_plus, GDK_CONTROL_MASK, "format_function_toggle", 1, G_TYPE_INT, GTK_IMHTML_GROW); | |
| 1362 | gtk_binding_entry_add_signal (binding_set, GDK_equal, GDK_CONTROL_MASK, "format_function_toggle", 1, G_TYPE_INT, GTK_IMHTML_GROW); | |
| 1363 | gtk_binding_entry_add_signal (binding_set, GDK_minus, GDK_CONTROL_MASK, "format_function_toggle", 1, G_TYPE_INT, GTK_IMHTML_SHRINK); | |
| 10108 | 1364 | binding_set = gtk_binding_set_by_class(klass); |
|
11385
38ca1438e055
[gaim-migrate @ 13612]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11315
diff
changeset
|
1365 | gtk_binding_entry_add_signal (binding_set, GDK_r, GDK_CONTROL_MASK, "format_function_clear", 0); |
| 10108 | 1366 | gtk_binding_entry_add_signal (binding_set, GDK_KP_Enter, 0, "message_send", 0); |
| 1367 | gtk_binding_entry_add_signal (binding_set, GDK_Return, 0, "message_send", 0); | |
|
17880
5e73968467e0
Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@pidgin.im>
parents:
17288
diff
changeset
|
1368 | gtk_binding_entry_add_signal (binding_set, GDK_z, GDK_CONTROL_MASK, "undo", 0); |
|
5e73968467e0
Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@pidgin.im>
parents:
17288
diff
changeset
|
1369 | gtk_binding_entry_add_signal (binding_set, GDK_z, GDK_CONTROL_MASK | GDK_SHIFT_MASK, "redo", 0); |
|
5e73968467e0
Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@pidgin.im>
parents:
17288
diff
changeset
|
1370 | gtk_binding_entry_add_signal (binding_set, GDK_F14, 0, "undo", 0); |
|
5e73968467e0
Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@pidgin.im>
parents:
17288
diff
changeset
|
1371 | |
| 1428 | 1372 | } |
| 1373 | ||
| 3922 | 1374 | static void gtk_imhtml_init (GtkIMHtml *imhtml) |
| 1428 | 1375 | { |
| 3922 | 1376 | GtkTextIter iter; |
| 1377 | imhtml->text_buffer = gtk_text_buffer_new(NULL); | |
|
17880
5e73968467e0
Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@pidgin.im>
parents:
17288
diff
changeset
|
1378 | imhtml->undo_manager = gtk_source_undo_manager_new(imhtml->text_buffer); |
| 3922 | 1379 | gtk_text_buffer_get_end_iter (imhtml->text_buffer, &iter); |
| 1380 | gtk_text_view_set_buffer(GTK_TEXT_VIEW(imhtml), imhtml->text_buffer); | |
|
5105
3565a4c4de6a
[gaim-migrate @ 5468]
David J. Brigada <brigada@prism.net>
parents:
5104
diff
changeset
|
1381 | gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(imhtml), GTK_WRAP_WORD_CHAR); |
| 3922 | 1382 | gtk_text_view_set_pixels_below_lines(GTK_TEXT_VIEW(imhtml), 5); |
| 8677 | 1383 | gtk_text_view_set_left_margin(GTK_TEXT_VIEW(imhtml), 2); |
| 1384 | gtk_text_view_set_right_margin(GTK_TEXT_VIEW(imhtml), 2); | |
| 8061 | 1385 | /*gtk_text_view_set_indent(GTK_TEXT_VIEW(imhtml), -15);*/ |
| 3922 | 1386 | /*gtk_text_view_set_justification(GTK_TEXT_VIEW(imhtml), GTK_JUSTIFY_FILL);*/ |
| 8061 | 1387 | |
| 3922 | 1388 | /* These tags will be used often and can be reused--we create them on init and then apply them by name |
| 8932 | 1389 | * other tags (color, size, face, etc.) will have to be created and applied dynamically |
| 9924 | 1390 | * Note that even though we created SUB, SUP, and PRE tags here, we don't really |
| 8932 | 1391 | * apply them anywhere yet. */ |
| 3922 | 1392 | gtk_text_buffer_create_tag(imhtml->text_buffer, "BOLD", "weight", PANGO_WEIGHT_BOLD, NULL); |
| 1393 | gtk_text_buffer_create_tag(imhtml->text_buffer, "ITALICS", "style", PANGO_STYLE_ITALIC, NULL); | |
| 1394 | gtk_text_buffer_create_tag(imhtml->text_buffer, "UNDERLINE", "underline", PANGO_UNDERLINE_SINGLE, NULL); | |
| 1395 | gtk_text_buffer_create_tag(imhtml->text_buffer, "STRIKE", "strikethrough", TRUE, NULL); | |
| 1396 | gtk_text_buffer_create_tag(imhtml->text_buffer, "SUB", "rise", -5000, NULL); | |
| 1397 | gtk_text_buffer_create_tag(imhtml->text_buffer, "SUP", "rise", 5000, NULL); | |
| 1398 | gtk_text_buffer_create_tag(imhtml->text_buffer, "PRE", "family", "Monospace", NULL); | |
| 7295 | 1399 | gtk_text_buffer_create_tag(imhtml->text_buffer, "search", "background", "#22ff00", "weight", "bold", NULL); |
| 8677 | 1400 | |
| 3922 | 1401 | /* When hovering over a link, we show the hand cursor--elsewhere we show the plain ol' pointer cursor */ |
| 1402 | imhtml->hand_cursor = gdk_cursor_new (GDK_HAND2); | |
| 1403 | imhtml->arrow_cursor = gdk_cursor_new (GDK_LEFT_PTR); | |
| 8061 | 1404 | imhtml->text_cursor = gdk_cursor_new (GDK_XTERM); |
| 2993 | 1405 | |
|
6124
322206d79652
[gaim-migrate @ 6598]
Mark Doliner <markdoliner@pidgin.im>
parents:
6066
diff
changeset
|
1406 | imhtml->show_comments = TRUE; |
| 4253 | 1407 | |
| 4892 | 1408 | imhtml->smiley_data = g_hash_table_new_full(g_str_hash, g_str_equal, |
| 4902 | 1409 | g_free, (GDestroyNotify)gtk_smiley_tree_destroy); |
| 4032 | 1410 | imhtml->default_smilies = gtk_smiley_tree_new(); |
| 4735 | 1411 | |
|
4944
032dac83798e
[gaim-migrate @ 5278]
Robert McQueen <robot101@debian.org>
parents:
4926
diff
changeset
|
1412 | g_signal_connect(G_OBJECT(imhtml), "size-allocate", G_CALLBACK(gtk_size_allocate_cb), NULL); |
| 4735 | 1413 | g_signal_connect(G_OBJECT(imhtml), "motion-notify-event", G_CALLBACK(gtk_motion_event_notify), NULL); |
|
4944
032dac83798e
[gaim-migrate @ 5278]
Robert McQueen <robot101@debian.org>
parents:
4926
diff
changeset
|
1414 | g_signal_connect(G_OBJECT(imhtml), "leave-notify-event", G_CALLBACK(gtk_leave_event_notify), NULL); |
|
10946
63a41710fc94
[gaim-migrate @ 12742]
Daniel Atallah <datallah@pidgin.im>
parents:
10936
diff
changeset
|
1415 | g_signal_connect(G_OBJECT(imhtml), "enter-notify-event", G_CALLBACK(gtk_enter_event_notify), NULL); |
|
10844
fb5b88957742
[gaim-migrate @ 12516]
Richard Laager <rlaager@pidgin.im>
parents:
10834
diff
changeset
|
1416 | #if (!GTK_CHECK_VERSION(2,2,0)) |
|
fb5b88957742
[gaim-migrate @ 12516]
Richard Laager <rlaager@pidgin.im>
parents:
10834
diff
changeset
|
1417 | /* See the comment for gtk_key_pressed_cb */ |
| 6066 | 1418 | g_signal_connect(G_OBJECT(imhtml), "key_press_event", G_CALLBACK(gtk_key_pressed_cb), NULL); |
|
10844
fb5b88957742
[gaim-migrate @ 12516]
Richard Laager <rlaager@pidgin.im>
parents:
10834
diff
changeset
|
1419 | #endif |
| 8677 | 1420 | g_signal_connect(G_OBJECT(imhtml), "button_press_event", G_CALLBACK(gtk_imhtml_button_press_event), NULL); |
| 1421 | g_signal_connect(G_OBJECT(imhtml->text_buffer), "insert-text", G_CALLBACK(preinsert_cb), imhtml); | |
|
12673
4c8a20955e0b
[gaim-migrate @ 15016]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12672
diff
changeset
|
1422 | g_signal_connect(G_OBJECT(imhtml->text_buffer), "delete_range", G_CALLBACK(delete_cb), imhtml); |
| 8061 | 1423 | g_signal_connect_after(G_OBJECT(imhtml->text_buffer), "insert-text", G_CALLBACK(insert_cb), imhtml); |
| 10169 | 1424 | g_signal_connect_after(G_OBJECT(imhtml->text_buffer), "insert-child-anchor", G_CALLBACK(insert_ca_cb), imhtml); |
| 8091 | 1425 | gtk_drag_dest_set(GTK_WIDGET(imhtml), 0, |
| 1426 | link_drag_drop_targets, sizeof(link_drag_drop_targets) / sizeof(GtkTargetEntry), | |
| 1427 | GDK_ACTION_COPY); | |
| 1428 | g_signal_connect(G_OBJECT(imhtml), "drag_data_received", G_CALLBACK(gtk_imhtml_link_drag_rcv_cb), imhtml); | |
| 9300 | 1429 | g_signal_connect(G_OBJECT(imhtml), "drag_drop", G_CALLBACK(gtk_imhtml_link_drop_cb), imhtml); |
| 8091 | 1430 | |
| 7353 | 1431 | g_signal_connect(G_OBJECT(imhtml), "copy-clipboard", G_CALLBACK(copy_clipboard_cb), NULL); |
| 8698 | 1432 | g_signal_connect(G_OBJECT(imhtml), "cut-clipboard", G_CALLBACK(cut_clipboard_cb), NULL); |
| 8061 | 1433 | g_signal_connect(G_OBJECT(imhtml), "paste-clipboard", G_CALLBACK(paste_clipboard_cb), NULL); |
| 8677 | 1434 | g_signal_connect_after(G_OBJECT(imhtml), "realize", G_CALLBACK(imhtml_realized_remove_primary), NULL); |
|
8740
098a43943bba
[gaim-migrate @ 9495]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
1435 | g_signal_connect(G_OBJECT(imhtml), "unrealize", G_CALLBACK(imhtml_destroy_add_primary), NULL); |
| 8677 | 1436 | |
| 1437 | g_signal_connect_after(G_OBJECT(GTK_IMHTML(imhtml)->text_buffer), "mark-set", | |
| 1438 | G_CALLBACK(mark_set_so_update_selection_cb), imhtml); | |
| 1439 | ||
|
10946
63a41710fc94
[gaim-migrate @ 12742]
Daniel Atallah <datallah@pidgin.im>
parents:
10936
diff
changeset
|
1440 | gtk_widget_add_events(GTK_WIDGET(imhtml), |
|
63a41710fc94
[gaim-migrate @ 12742]
Daniel Atallah <datallah@pidgin.im>
parents:
10936
diff
changeset
|
1441 | GDK_LEAVE_NOTIFY_MASK | GDK_ENTER_NOTIFY_MASK); |
| 4735 | 1442 | |
| 8681 | 1443 | imhtml->clipboard_text_string = NULL; |
| 1444 | imhtml->clipboard_html_string = NULL; | |
| 1445 | ||
| 4735 | 1446 | imhtml->tip = NULL; |
| 1447 | imhtml->tip_timer = 0; | |
| 1448 | imhtml->tip_window = NULL; | |
| 4895 | 1449 | |
| 8677 | 1450 | imhtml->edit.bold = FALSE; |
| 1451 | imhtml->edit.italic = FALSE; | |
| 1452 | imhtml->edit.underline = FALSE; | |
| 8061 | 1453 | imhtml->edit.forecolor = NULL; |
| 1454 | imhtml->edit.backcolor = NULL; | |
| 1455 | imhtml->edit.fontface = NULL; | |
| 8677 | 1456 | imhtml->edit.fontsize = 0; |
| 1457 | imhtml->edit.link = NULL; | |
| 1458 | ||
|
11572
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
1459 | |
| 4895 | 1460 | imhtml->scalables = NULL; |
|
16385
aa5b9456e258
Fixes #213 This allows only 20 animated smileys to be animnating at a time
Sean Egan <seanegan@pidgin.im>
parents:
16291
diff
changeset
|
1461 | imhtml->animations = g_queue_new(); |
| 8061 | 1462 | gtk_imhtml_set_editable(imhtml, FALSE); |
|
11572
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
1463 | g_signal_connect(G_OBJECT(imhtml), "populate-popup", |
| 8931 | 1464 | G_CALLBACK(hijack_menu_cb), NULL); |
| 2993 | 1465 | } |
| 1466 | ||
| 3922 | 1467 | GtkWidget *gtk_imhtml_new(void *a, void *b) |
| 1428 | 1468 | { |
| 4635 | 1469 | return GTK_WIDGET(g_object_new(gtk_imhtml_get_type(), NULL)); |
| 1428 | 1470 | } |
| 1471 | ||
| 9037 | 1472 | GType gtk_imhtml_get_type() |
| 1428 | 1473 | { |
| 9037 | 1474 | static GType imhtml_type = 0; |
| 1428 | 1475 | |
| 1476 | if (!imhtml_type) { | |
| 9037 | 1477 | static const GTypeInfo imhtml_info = { |
| 4635 | 1478 | sizeof(GtkIMHtmlClass), |
| 1479 | NULL, | |
| 1480 | NULL, | |
| 1481 | (GClassInitFunc) gtk_imhtml_class_init, | |
| 1482 | NULL, | |
| 1483 | NULL, | |
| 1428 | 1484 | sizeof (GtkIMHtml), |
| 4635 | 1485 | 0, |
|
12600
7ecd4441fdc7
[gaim-migrate @ 14934]
Richard Laager <rlaager@pidgin.im>
parents:
12553
diff
changeset
|
1486 | (GInstanceInitFunc) gtk_imhtml_init, |
|
7ecd4441fdc7
[gaim-migrate @ 14934]
Richard Laager <rlaager@pidgin.im>
parents:
12553
diff
changeset
|
1487 | NULL |
| 1428 | 1488 | }; |
| 4635 | 1489 | |
| 1490 | imhtml_type = g_type_register_static(gtk_text_view_get_type(), | |
| 1491 | "GtkIMHtml", &imhtml_info, 0); | |
| 1428 | 1492 | } |
| 1493 | ||
| 1494 | return imhtml_type; | |
| 1495 | } | |
| 1496 | ||
| 4417 | 1497 | struct url_data { |
| 1498 | GObject *object; | |
| 1499 | gchar *url; | |
| 1500 | }; | |
| 1501 | ||
| 8677 | 1502 | static void url_data_destroy(gpointer mydata) |
| 1503 | { | |
| 1504 | struct url_data *data = mydata; | |
| 1505 | g_object_unref(data->object); | |
| 1506 | g_free(data->url); | |
| 1507 | g_free(data); | |
| 1508 | } | |
| 1509 | ||
| 4417 | 1510 | static void url_open(GtkWidget *w, struct url_data *data) { |
| 1511 | if(!data) return; | |
| 8061 | 1512 | g_signal_emit(data->object, signals[URL_CLICKED], 0, data->url); |
| 7988 | 1513 | |
| 4417 | 1514 | } |
|
5582
2e5da5db947b
[gaim-migrate @ 5986]
Robert McQueen <robot101@debian.org>
parents:
5367
diff
changeset
|
1515 | |
| 4417 | 1516 | static void url_copy(GtkWidget *w, gchar *url) { |
| 1517 | GtkClipboard *clipboard; | |
| 1518 | ||
| 8931 | 1519 | clipboard = gtk_widget_get_clipboard(w, GDK_SELECTION_PRIMARY); |
| 4417 | 1520 | gtk_clipboard_set_text(clipboard, url, -1); |
|
5582
2e5da5db947b
[gaim-migrate @ 5986]
Robert McQueen <robot101@debian.org>
parents:
5367
diff
changeset
|
1521 | |
| 8931 | 1522 | clipboard = gtk_widget_get_clipboard(w, GDK_SELECTION_CLIPBOARD); |
|
5582
2e5da5db947b
[gaim-migrate @ 5986]
Robert McQueen <robot101@debian.org>
parents:
5367
diff
changeset
|
1523 | gtk_clipboard_set_text(clipboard, url, -1); |
| 4417 | 1524 | } |
| 1525 | ||
| 1526 | /* The callback for an event on a link tag. */ | |
|
10871
c0282a4f2250
[gaim-migrate @ 12558]
Mark Doliner <markdoliner@pidgin.im>
parents:
10865
diff
changeset
|
1527 | static gboolean tag_event(GtkTextTag *tag, GObject *imhtml, GdkEvent *event, GtkTextIter *arg2, gpointer unused) { |
| 4417 | 1528 | GdkEventButton *event_button = (GdkEventButton *) event; |
| 8061 | 1529 | if (GTK_IMHTML(imhtml)->editable) |
| 1530 | return FALSE; | |
| 3922 | 1531 | if (event->type == GDK_BUTTON_RELEASE) { |
| 8957 | 1532 | if ((event_button->button == 1) || (event_button->button == 2)) { |
| 4417 | 1533 | GtkTextIter start, end; |
| 1534 | /* we shouldn't open a URL if the user has selected something: */ | |
| 8677 | 1535 | if (gtk_text_buffer_get_selection_bounds( |
| 1536 | gtk_text_iter_get_buffer(arg2), &start, &end)) | |
| 4417 | 1537 | return FALSE; |
| 1538 | ||
| 1539 | /* A link was clicked--we emit the "url_clicked" signal | |
| 1540 | * with the URL as the argument */ | |
| 8677 | 1541 | g_object_ref(G_OBJECT(tag)); |
| 1542 | g_signal_emit(imhtml, signals[URL_CLICKED], 0, g_object_get_data(G_OBJECT(tag), "link_url")); | |
| 1543 | g_object_unref(G_OBJECT(tag)); | |
| 4417 | 1544 | return FALSE; |
| 1545 | } else if(event_button->button == 3) { | |
| 4745 | 1546 | GtkWidget *img, *item, *menu; |
| 4417 | 1547 | struct url_data *tempdata = g_new(struct url_data, 1); |
| 5091 | 1548 | tempdata->object = g_object_ref(imhtml); |
| 8677 | 1549 | tempdata->url = g_strdup(g_object_get_data(G_OBJECT(tag), "link_url")); |
| 4745 | 1550 | |
| 5091 | 1551 | /* Don't want the tooltip around if user right-clicked on link */ |
| 1552 | if (GTK_IMHTML(imhtml)->tip_window) { | |
| 1553 | gtk_widget_destroy(GTK_IMHTML(imhtml)->tip_window); | |
| 1554 | GTK_IMHTML(imhtml)->tip_window = NULL; | |
| 1555 | } | |
| 1556 | if (GTK_IMHTML(imhtml)->tip_timer) { | |
| 1557 | g_source_remove(GTK_IMHTML(imhtml)->tip_timer); | |
| 1558 | GTK_IMHTML(imhtml)->tip_timer = 0; | |
| 1559 | } | |
| 8061 | 1560 | if (GTK_IMHTML(imhtml)->editable) |
| 1561 | gdk_window_set_cursor(event_button->window, GTK_IMHTML(imhtml)->text_cursor); | |
| 1562 | else | |
| 1563 | gdk_window_set_cursor(event_button->window, GTK_IMHTML(imhtml)->arrow_cursor); | |
| 4417 | 1564 | menu = gtk_menu_new(); |
| 8677 | 1565 | g_object_set_data_full(G_OBJECT(menu), "x-imhtml-url-data", tempdata, url_data_destroy); |
| 4745 | 1566 | |
| 4417 | 1567 | /* buttons and such */ |
| 1568 | ||
| 8677 | 1569 | if (!strncmp(tempdata->url, "mailto:", 7)) |
|
7140
2670fa7da352
[gaim-migrate @ 7707]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
1570 | { |
|
2670fa7da352
[gaim-migrate @ 7707]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
1571 | /* Copy E-Mail Address */ |
|
2670fa7da352
[gaim-migrate @ 7707]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
1572 | img = gtk_image_new_from_stock(GTK_STOCK_COPY, |
|
2670fa7da352
[gaim-migrate @ 7707]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
1573 | GTK_ICON_SIZE_MENU); |
|
2670fa7da352
[gaim-migrate @ 7707]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
1574 | item = gtk_image_menu_item_new_with_mnemonic( |
|
2670fa7da352
[gaim-migrate @ 7707]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
1575 | _("_Copy E-Mail Address")); |
|
2670fa7da352
[gaim-migrate @ 7707]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
1576 | gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(item), img); |
|
2670fa7da352
[gaim-migrate @ 7707]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
1577 | g_signal_connect(G_OBJECT(item), "activate", |
| 8677 | 1578 | G_CALLBACK(url_copy), tempdata->url + 7); |
|
7140
2670fa7da352
[gaim-migrate @ 7707]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
1579 | gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); |
|
2670fa7da352
[gaim-migrate @ 7707]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
1580 | } |
|
2670fa7da352
[gaim-migrate @ 7707]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
1581 | else |
|
2670fa7da352
[gaim-migrate @ 7707]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
1582 | { |
| 10936 | 1583 | /* Open Link in Browser */ |
| 1584 | img = gtk_image_new_from_stock(GTK_STOCK_JUMP_TO, | |
| 1585 | GTK_ICON_SIZE_MENU); | |
| 1586 | item = gtk_image_menu_item_new_with_mnemonic( | |
| 1587 | _("_Open Link in Browser")); | |
| 1588 | gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(item), img); | |
| 1589 | g_signal_connect(G_OBJECT(item), "activate", | |
| 1590 | G_CALLBACK(url_open), tempdata); | |
| 1591 | gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); | |
| 1592 | ||
|
7140
2670fa7da352
[gaim-migrate @ 7707]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
1593 | /* Copy Link Location */ |
|
2670fa7da352
[gaim-migrate @ 7707]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
1594 | img = gtk_image_new_from_stock(GTK_STOCK_COPY, |
|
2670fa7da352
[gaim-migrate @ 7707]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
1595 | GTK_ICON_SIZE_MENU); |
|
2670fa7da352
[gaim-migrate @ 7707]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
1596 | item = gtk_image_menu_item_new_with_mnemonic( |
|
2670fa7da352
[gaim-migrate @ 7707]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
1597 | _("_Copy Link Location")); |
|
2670fa7da352
[gaim-migrate @ 7707]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
1598 | gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(item), img); |
|
2670fa7da352
[gaim-migrate @ 7707]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
1599 | g_signal_connect(G_OBJECT(item), "activate", |
| 8677 | 1600 | G_CALLBACK(url_copy), tempdata->url); |
|
7140
2670fa7da352
[gaim-migrate @ 7707]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
1601 | gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); |
|
2670fa7da352
[gaim-migrate @ 7707]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
1602 | } |
|
2670fa7da352
[gaim-migrate @ 7707]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
1603 | |
|
4756
ee19a87a495f
[gaim-migrate @ 5073]
Mark Doliner <markdoliner@pidgin.im>
parents:
4745
diff
changeset
|
1604 | |
| 4417 | 1605 | gtk_widget_show_all(menu); |
|
4756
ee19a87a495f
[gaim-migrate @ 5073]
Mark Doliner <markdoliner@pidgin.im>
parents:
4745
diff
changeset
|
1606 | gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL, |
|
ee19a87a495f
[gaim-migrate @ 5073]
Mark Doliner <markdoliner@pidgin.im>
parents:
4745
diff
changeset
|
1607 | event_button->button, event_button->time); |
| 4745 | 1608 | |
| 4417 | 1609 | return TRUE; |
| 1610 | } | |
| 1428 | 1611 | } |
| 4417 | 1612 | if(event->type == GDK_BUTTON_PRESS && event_button->button == 3) |
| 1613 | return TRUE; /* Clicking the right mouse button on a link shouldn't | |
| 1614 | be caught by the regular GtkTextView menu */ | |
| 1615 | else | |
| 1616 | return FALSE; /* Let clicks go through if we didn't catch anything */ | |
| 1428 | 1617 | } |
| 1618 | ||
| 9300 | 1619 | static gboolean |
| 1620 | gtk_text_view_drag_motion (GtkWidget *widget, | |
| 1621 | GdkDragContext *context, | |
| 1622 | gint x, | |
| 1623 | gint y, | |
| 1624 | guint time) | |
| 1625 | { | |
|
11572
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
1626 | GdkDragAction suggested_action = 0; |
| 9300 | 1627 | |
|
10145
f1405f65ff41
[gaim-migrate @ 11218]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10110
diff
changeset
|
1628 | if (gtk_drag_dest_find_target (widget, context, NULL) == GDK_NONE) { |
|
11572
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
1629 | /* can't accept any of the offered targets */ |
| 9300 | 1630 | } else { |
| 1631 | GtkWidget *source_widget; | |
| 1632 | suggested_action = context->suggested_action; | |
| 1633 | source_widget = gtk_drag_get_source_widget (context); | |
| 1634 | if (source_widget == widget) { | |
| 1635 | /* Default to MOVE, unless the user has | |
| 1636 | * pressed ctrl or alt to affect available actions | |
| 1637 | */ | |
| 1638 | if ((context->actions & GDK_ACTION_MOVE) != 0) | |
| 1639 | suggested_action = GDK_ACTION_MOVE; | |
| 1640 | } | |
|
11572
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
1641 | } |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
1642 | |
|
10145
f1405f65ff41
[gaim-migrate @ 11218]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10110
diff
changeset
|
1643 | gdk_drag_status (context, suggested_action, time); |
|
11572
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
1644 | |
| 9300 | 1645 | /* TRUE return means don't propagate the drag motion to parent |
| 1646 | * widgets that may also be drop sites. | |
| 1647 | */ | |
| 1648 | return TRUE; | |
| 1649 | } | |
| 1650 | ||
| 1651 | static void | |
| 1652 | gtk_imhtml_link_drop_cb(GtkWidget *widget, GdkDragContext *context, gint x, gint y, guint time, gpointer user_data) | |
| 1653 | { | |
| 1654 | GdkAtom target = gtk_drag_dest_find_target (widget, context, NULL); | |
|
11572
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
1655 | |
| 9300 | 1656 | if (target != GDK_NONE) |
| 1657 | gtk_drag_get_data (widget, context, target, time); | |
| 1658 | else | |
| 1659 | gtk_drag_finish (context, FALSE, FALSE, time); | |
| 1660 | ||
| 1661 | return; | |
| 1662 | } | |
| 1663 | ||
| 8091 | 1664 | static void |
| 1665 | gtk_imhtml_link_drag_rcv_cb(GtkWidget *widget, GdkDragContext *dc, guint x, guint y, | |
|
11143
f606fb334190
[gaim-migrate @ 13207]
Mark Doliner <markdoliner@pidgin.im>
parents:
11069
diff
changeset
|
1666 | GtkSelectionData *sd, guint info, guint t, GtkIMHtml *imhtml) |
| 8091 | 1667 | { |
| 9300 | 1668 | gchar **links; |
| 1669 | gchar *link; | |
|
11143
f606fb334190
[gaim-migrate @ 13207]
Mark Doliner <markdoliner@pidgin.im>
parents:
11069
diff
changeset
|
1670 | char *text = (char *)sd->data; |
| 9300 | 1671 | GtkTextMark *mark = gtk_text_buffer_get_insert(imhtml->text_buffer); |
| 1672 | GtkTextIter iter; | |
|
10782
18cc41076f4e
[gaim-migrate @ 12410]
Luke Schierer <lschiere@pidgin.im>
parents:
10777
diff
changeset
|
1673 | gint i = 0; |
| 9300 | 1674 | |
| 1675 | gtk_text_buffer_get_iter_at_mark(imhtml->text_buffer, &iter, mark); | |
| 1676 | ||
| 8091 | 1677 | if(gtk_imhtml_get_editable(imhtml) && sd->data){ |
| 9300 | 1678 | switch (info) { |
|
10145
f1405f65ff41
[gaim-migrate @ 11218]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10110
diff
changeset
|
1679 | case GTK_IMHTML_DRAG_URL: |
|
11143
f606fb334190
[gaim-migrate @ 13207]
Mark Doliner <markdoliner@pidgin.im>
parents:
11069
diff
changeset
|
1680 | /* TODO: Is it really ok to change sd->data...? */ |
| 15884 | 1681 | purple_str_strip_char((char *)sd->data, '\r'); |
|
11143
f606fb334190
[gaim-migrate @ 13207]
Mark Doliner <markdoliner@pidgin.im>
parents:
11069
diff
changeset
|
1682 | |
|
f606fb334190
[gaim-migrate @ 13207]
Mark Doliner <markdoliner@pidgin.im>
parents:
11069
diff
changeset
|
1683 | links = g_strsplit((char *)sd->data, "\n", 0); |
|
10782
18cc41076f4e
[gaim-migrate @ 12410]
Luke Schierer <lschiere@pidgin.im>
parents:
10777
diff
changeset
|
1684 | while((link = links[i]) != NULL){ |
| 15884 | 1685 | if(purple_str_has_prefix(link, "http://") || |
| 1686 | purple_str_has_prefix(link, "https://") || | |
| 1687 | purple_str_has_prefix(link, "ftp://")) | |
|
10782
18cc41076f4e
[gaim-migrate @ 12410]
Luke Schierer <lschiere@pidgin.im>
parents:
10777
diff
changeset
|
1688 | { |
|
18cc41076f4e
[gaim-migrate @ 12410]
Luke Schierer <lschiere@pidgin.im>
parents:
10777
diff
changeset
|
1689 | gchar *label; |
|
18cc41076f4e
[gaim-migrate @ 12410]
Luke Schierer <lschiere@pidgin.im>
parents:
10777
diff
changeset
|
1690 | |
|
18cc41076f4e
[gaim-migrate @ 12410]
Luke Schierer <lschiere@pidgin.im>
parents:
10777
diff
changeset
|
1691 | if(links[i + 1]) |
|
18cc41076f4e
[gaim-migrate @ 12410]
Luke Schierer <lschiere@pidgin.im>
parents:
10777
diff
changeset
|
1692 | i++; |
|
18cc41076f4e
[gaim-migrate @ 12410]
Luke Schierer <lschiere@pidgin.im>
parents:
10777
diff
changeset
|
1693 | |
|
18cc41076f4e
[gaim-migrate @ 12410]
Luke Schierer <lschiere@pidgin.im>
parents:
10777
diff
changeset
|
1694 | label = links[i]; |
|
18cc41076f4e
[gaim-migrate @ 12410]
Luke Schierer <lschiere@pidgin.im>
parents:
10777
diff
changeset
|
1695 | |
|
18cc41076f4e
[gaim-migrate @ 12410]
Luke Schierer <lschiere@pidgin.im>
parents:
10777
diff
changeset
|
1696 | gtk_imhtml_insert_link(imhtml, mark, link, label); |
| 9300 | 1697 | } else if (link=='\0') { |
| 1698 | /* Ignore blank lines */ | |
| 1699 | } else { | |
| 1700 | /* Special reasons, aka images being put in via other tag, etc. */ | |
|
10345
7d7f8cfa2b4f
[gaim-migrate @ 11556]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
10297
diff
changeset
|
1701 | /* ... don't pretend we handled it if we didn't */ |
|
7d7f8cfa2b4f
[gaim-migrate @ 11556]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
10297
diff
changeset
|
1702 | gtk_drag_finish(dc, FALSE, FALSE, t); |
|
10782
18cc41076f4e
[gaim-migrate @ 12410]
Luke Schierer <lschiere@pidgin.im>
parents:
10777
diff
changeset
|
1703 | g_strfreev(links); |
|
10345
7d7f8cfa2b4f
[gaim-migrate @ 11556]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
10297
diff
changeset
|
1704 | return; |
| 9300 | 1705 | } |
|
10782
18cc41076f4e
[gaim-migrate @ 12410]
Luke Schierer <lschiere@pidgin.im>
parents:
10777
diff
changeset
|
1706 | |
|
18cc41076f4e
[gaim-migrate @ 12410]
Luke Schierer <lschiere@pidgin.im>
parents:
10777
diff
changeset
|
1707 | i++; |
| 8091 | 1708 | } |
|
10782
18cc41076f4e
[gaim-migrate @ 12410]
Luke Schierer <lschiere@pidgin.im>
parents:
10777
diff
changeset
|
1709 | g_strfreev(links); |
| 9300 | 1710 | break; |
|
10145
f1405f65ff41
[gaim-migrate @ 11218]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10110
diff
changeset
|
1711 | case GTK_IMHTML_DRAG_HTML: |
|
10243
6d75b29afc71
[gaim-migrate @ 11383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10217
diff
changeset
|
1712 | { |
|
6d75b29afc71
[gaim-migrate @ 11383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10217
diff
changeset
|
1713 | char *utf8 = NULL; |
|
6d75b29afc71
[gaim-migrate @ 11383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10217
diff
changeset
|
1714 | /* Ewww. This is all because mozilla thinks that text/html is 'for internal use only.' |
|
6d75b29afc71
[gaim-migrate @ 11383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10217
diff
changeset
|
1715 | * as explained by this comment in gtkhtml: |
|
6d75b29afc71
[gaim-migrate @ 11383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10217
diff
changeset
|
1716 | * |
|
6d75b29afc71
[gaim-migrate @ 11383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10217
diff
changeset
|
1717 | * FIXME This hack decides the charset of the selection. It seems that |
|
6d75b29afc71
[gaim-migrate @ 11383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10217
diff
changeset
|
1718 | * mozilla/netscape alway use ucs2 for text/html |
|
6d75b29afc71
[gaim-migrate @ 11383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10217
diff
changeset
|
1719 | * and openoffice.org seems to always use utf8 so we try to validate |
|
6d75b29afc71
[gaim-migrate @ 11383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10217
diff
changeset
|
1720 | * the string as utf8 and if that fails we assume it is ucs2 |
|
6d75b29afc71
[gaim-migrate @ 11383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10217
diff
changeset
|
1721 | * |
|
6d75b29afc71
[gaim-migrate @ 11383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10217
diff
changeset
|
1722 | * See also the comment on text/html here: |
|
6d75b29afc71
[gaim-migrate @ 11383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10217
diff
changeset
|
1723 | * http://mail.gnome.org/archives/gtk-devel-list/2001-September/msg00114.html |
|
6d75b29afc71
[gaim-migrate @ 11383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10217
diff
changeset
|
1724 | */ |
|
6d75b29afc71
[gaim-migrate @ 11383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10217
diff
changeset
|
1725 | if (sd->length >= 2 && !g_utf8_validate(text, sd->length - 1, NULL)) { |
|
11572
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
1726 | utf8 = ucs2_to_utf8_with_bom_check(text, sd->length); |
|
10243
6d75b29afc71
[gaim-migrate @ 11383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10217
diff
changeset
|
1727 | |
|
6d75b29afc71
[gaim-migrate @ 11383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10217
diff
changeset
|
1728 | if (!utf8) { |
| 15884 | 1729 | purple_debug_warning("gtkimhtml", "g_convert from UCS-2 failed in drag_rcv_cb\n"); |
| 9300 | 1730 | return; |
| 1731 | } | |
|
10243
6d75b29afc71
[gaim-migrate @ 11383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10217
diff
changeset
|
1732 | } else if (!(*text) || !g_utf8_validate(text, -1, NULL)) { |
| 15884 | 1733 | purple_debug_warning("gtkimhtml", "empty string or invalid UTF-8 in drag_rcv_cb\n"); |
| 9300 | 1734 | return; |
| 1735 | } | |
|
10243
6d75b29afc71
[gaim-migrate @ 11383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10217
diff
changeset
|
1736 | |
|
6d75b29afc71
[gaim-migrate @ 11383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10217
diff
changeset
|
1737 | gtk_imhtml_insert_html_at_iter(imhtml, utf8 ? utf8 : text, 0, &iter); |
|
6d75b29afc71
[gaim-migrate @ 11383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10217
diff
changeset
|
1738 | g_free(utf8); |
| 9300 | 1739 | break; |
|
10243
6d75b29afc71
[gaim-migrate @ 11383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10217
diff
changeset
|
1740 | } |
|
10145
f1405f65ff41
[gaim-migrate @ 11218]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10110
diff
changeset
|
1741 | case GTK_IMHTML_DRAG_TEXT: |
|
f1405f65ff41
[gaim-migrate @ 11218]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10110
diff
changeset
|
1742 | if (!(*text) || !g_utf8_validate(text, -1, NULL)) { |
| 15884 | 1743 | purple_debug_warning("gtkimhtml", "empty string or invalid UTF-8 in drag_rcv_cb\n"); |
|
10145
f1405f65ff41
[gaim-migrate @ 11218]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10110
diff
changeset
|
1744 | return; |
|
f1405f65ff41
[gaim-migrate @ 11218]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10110
diff
changeset
|
1745 | } else { |
|
10732
5e314ab498bf
[gaim-migrate @ 12334]
Richard Laager <rlaager@pidgin.im>
parents:
10699
diff
changeset
|
1746 | char *tmp = g_markup_escape_text(text, -1); |
|
10145
f1405f65ff41
[gaim-migrate @ 11218]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10110
diff
changeset
|
1747 | gtk_imhtml_insert_html_at_iter(imhtml, tmp, 0, &iter); |
|
f1405f65ff41
[gaim-migrate @ 11218]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10110
diff
changeset
|
1748 | g_free(tmp); |
|
f1405f65ff41
[gaim-migrate @ 11218]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10110
diff
changeset
|
1749 | } |
|
f1405f65ff41
[gaim-migrate @ 11218]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10110
diff
changeset
|
1750 | break; |
| 9300 | 1751 | default: |
|
10145
f1405f65ff41
[gaim-migrate @ 11218]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10110
diff
changeset
|
1752 | gtk_drag_finish(dc, FALSE, FALSE, t); |
|
f1405f65ff41
[gaim-migrate @ 11218]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10110
diff
changeset
|
1753 | return; |
| 8091 | 1754 | } |
| 1755 | gtk_drag_finish(dc, TRUE, (dc->action == GDK_ACTION_MOVE), t); | |
| 1756 | } else { | |
| 1757 | gtk_drag_finish(dc, FALSE, FALSE, t); | |
| 1758 | } | |
| 1759 | } | |
| 1760 | ||
| 4298 | 1761 | /* this isn't used yet |
| 9300 | 1762 | static void gtk_smiley_tree_remove (GtkSmileyTree *tree, |
| 4263 | 1763 | GtkIMHtmlSmiley *smiley) |
| 4032 | 1764 | { |
| 1765 | GtkSmileyTree *t = tree; | |
| 4263 | 1766 | const gchar *x = smiley->smile; |
| 4032 | 1767 | gint len = 0; |
| 1768 | ||
| 1769 | while (*x) { | |
| 1770 | gchar *pos; | |
| 1771 | ||
| 1772 | if (!t->values) | |
| 1773 | return; | |
| 1774 | ||
| 1775 | pos = strchr (t->values->str, *x); | |
| 1776 | if (pos) | |
| 1777 | t = t->children [(int) pos - (int) t->values->str]; | |
| 1778 | else | |
| 1779 | return; | |
| 1780 | ||
| 1781 | x++; len++; | |
| 1782 | } | |
| 1783 | ||
| 4141 | 1784 | if (t->image) { |
| 4032 | 1785 | t->image = NULL; |
| 4141 | 1786 | } |
| 4032 | 1787 | } |
| 4298 | 1788 | */ |
| 1789 | ||
| 4032 | 1790 | |
| 1791 | static gint | |
| 1792 | gtk_smiley_tree_lookup (GtkSmileyTree *tree, | |
| 1793 | const gchar *text) | |
| 1794 | { | |
| 1795 | GtkSmileyTree *t = tree; | |
| 1796 | const gchar *x = text; | |
| 1797 | gint len = 0; | |
|
16143
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
1798 | const gchar *amp; |
| 8505 | 1799 | gint alen; |
| 4032 | 1800 | |
| 1801 | while (*x) { | |
| 1802 | gchar *pos; | |
| 1803 | ||
| 1804 | if (!t->values) | |
| 1805 | break; | |
| 1806 | ||
| 16144 | 1807 | if(*x == '&' && (amp = purple_markup_unescape_entity(x, &alen))) { |
|
10865
f5bb66be81a0
[gaim-migrate @ 12549]
Daniel Atallah <datallah@pidgin.im>
parents:
10858
diff
changeset
|
1808 | gboolean matched = TRUE; |
|
f5bb66be81a0
[gaim-migrate @ 12549]
Daniel Atallah <datallah@pidgin.im>
parents:
10858
diff
changeset
|
1809 | /* Make sure all chars of the unescaped value match */ |
|
f5bb66be81a0
[gaim-migrate @ 12549]
Daniel Atallah <datallah@pidgin.im>
parents:
10858
diff
changeset
|
1810 | while (*(amp + 1)) { |
|
f5bb66be81a0
[gaim-migrate @ 12549]
Daniel Atallah <datallah@pidgin.im>
parents:
10858
diff
changeset
|
1811 | pos = strchr (t->values->str, *amp); |
|
f5bb66be81a0
[gaim-migrate @ 12549]
Daniel Atallah <datallah@pidgin.im>
parents:
10858
diff
changeset
|
1812 | if (pos) |
|
f5bb66be81a0
[gaim-migrate @ 12549]
Daniel Atallah <datallah@pidgin.im>
parents:
10858
diff
changeset
|
1813 | t = t->children [GPOINTER_TO_INT(pos) - GPOINTER_TO_INT(t->values->str)]; |
|
f5bb66be81a0
[gaim-migrate @ 12549]
Daniel Atallah <datallah@pidgin.im>
parents:
10858
diff
changeset
|
1814 | else { |
|
f5bb66be81a0
[gaim-migrate @ 12549]
Daniel Atallah <datallah@pidgin.im>
parents:
10858
diff
changeset
|
1815 | matched = FALSE; |
|
f5bb66be81a0
[gaim-migrate @ 12549]
Daniel Atallah <datallah@pidgin.im>
parents:
10858
diff
changeset
|
1816 | break; |
|
f5bb66be81a0
[gaim-migrate @ 12549]
Daniel Atallah <datallah@pidgin.im>
parents:
10858
diff
changeset
|
1817 | } |
|
f5bb66be81a0
[gaim-migrate @ 12549]
Daniel Atallah <datallah@pidgin.im>
parents:
10858
diff
changeset
|
1818 | amp++; |
|
f5bb66be81a0
[gaim-migrate @ 12549]
Daniel Atallah <datallah@pidgin.im>
parents:
10858
diff
changeset
|
1819 | } |
|
f5bb66be81a0
[gaim-migrate @ 12549]
Daniel Atallah <datallah@pidgin.im>
parents:
10858
diff
changeset
|
1820 | if (!matched) |
|
f5bb66be81a0
[gaim-migrate @ 12549]
Daniel Atallah <datallah@pidgin.im>
parents:
10858
diff
changeset
|
1821 | break; |
|
f5bb66be81a0
[gaim-migrate @ 12549]
Daniel Atallah <datallah@pidgin.im>
parents:
10858
diff
changeset
|
1822 | |
|
f5bb66be81a0
[gaim-migrate @ 12549]
Daniel Atallah <datallah@pidgin.im>
parents:
10858
diff
changeset
|
1823 | pos = strchr (t->values->str, *amp); |
| 8505 | 1824 | } |
|
11572
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
1825 | else if (*x == '<') /* Because we're all WYSIWYG now, a '<' |
| 9636 | 1826 | * char should only appear as the start of a tag. Perhaps a safer (but costlier) |
| 1827 | * check would be to call gtk_imhtml_is_tag on it */ | |
| 10600 | 1828 | break; |
|
10865
f5bb66be81a0
[gaim-migrate @ 12549]
Daniel Atallah <datallah@pidgin.im>
parents:
10858
diff
changeset
|
1829 | else { |
|
f5bb66be81a0
[gaim-migrate @ 12549]
Daniel Atallah <datallah@pidgin.im>
parents:
10858
diff
changeset
|
1830 | alen = 1; |
|
f5bb66be81a0
[gaim-migrate @ 12549]
Daniel Atallah <datallah@pidgin.im>
parents:
10858
diff
changeset
|
1831 | pos = strchr (t->values->str, *x); |
|
f5bb66be81a0
[gaim-migrate @ 12549]
Daniel Atallah <datallah@pidgin.im>
parents:
10858
diff
changeset
|
1832 | } |
| 8505 | 1833 | |
| 4032 | 1834 | if (pos) |
| 7371 | 1835 | t = t->children [GPOINTER_TO_INT(pos) - GPOINTER_TO_INT(t->values->str)]; |
| 4032 | 1836 | else |
| 1837 | break; | |
| 1838 | ||
|
10865
f5bb66be81a0
[gaim-migrate @ 12549]
Daniel Atallah <datallah@pidgin.im>
parents:
10858
diff
changeset
|
1839 | x += alen; |
|
f5bb66be81a0
[gaim-migrate @ 12549]
Daniel Atallah <datallah@pidgin.im>
parents:
10858
diff
changeset
|
1840 | len += alen; |
| 4032 | 1841 | } |
| 1842 | ||
| 1843 | if (t->image) | |
| 1844 | return len; | |
| 1845 | ||
| 1846 | return 0; | |
| 1847 | } | |
| 1848 | ||
| 1849 | void | |
| 4263 | 1850 | gtk_imhtml_associate_smiley (GtkIMHtml *imhtml, |
|
10537
9ece7671fa62
[gaim-migrate @ 11890]
Mark Doliner <markdoliner@pidgin.im>
parents:
10526
diff
changeset
|
1851 | const gchar *sml, |
| 4263 | 1852 | GtkIMHtmlSmiley *smiley) |
| 4032 | 1853 | { |
| 1854 | GtkSmileyTree *tree; | |
| 1855 | g_return_if_fail (imhtml != NULL); | |
| 1856 | g_return_if_fail (GTK_IS_IMHTML (imhtml)); | |
| 7371 | 1857 | |
| 4032 | 1858 | if (sml == NULL) |
| 1859 | tree = imhtml->default_smilies; | |
|
12833
1f461f275b90
[gaim-migrate @ 15181]
Richard Laager <rlaager@pidgin.im>
parents:
12796
diff
changeset
|
1860 | else if (!(tree = g_hash_table_lookup(imhtml->smiley_data, sml))) { |
| 4032 | 1861 | tree = gtk_smiley_tree_new(); |
| 4892 | 1862 | g_hash_table_insert(imhtml->smiley_data, g_strdup(sml), tree); |
| 4032 | 1863 | } |
| 1864 | ||
| 12335 | 1865 | smiley->imhtml = imhtml; |
| 1866 | ||
| 4263 | 1867 | gtk_smiley_tree_insert (tree, smiley); |
| 4032 | 1868 | } |
| 1869 | ||
| 1870 | static gboolean | |
| 1871 | gtk_imhtml_is_smiley (GtkIMHtml *imhtml, | |
| 1872 | GSList *fonts, | |
| 1873 | const gchar *text, | |
| 1874 | gint *len) | |
| 1875 | { | |
| 1876 | GtkSmileyTree *tree; | |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
1877 | GtkIMHtmlFontDetail *font; |
| 4032 | 1878 | char *sml = NULL; |
| 1879 | ||
| 1880 | if (fonts) { | |
| 1881 | font = fonts->data; | |
| 1882 | sml = font->sml; | |
| 1883 | } | |
| 1884 | ||
| 9029 | 1885 | if (!sml) |
| 1886 | sml = imhtml->protocol_name; | |
| 1887 | ||
| 1888 | if (!sml || !(tree = g_hash_table_lookup(imhtml->smiley_data, sml))) | |
| 4032 | 1889 | tree = imhtml->default_smilies; |
| 9029 | 1890 | |
| 4032 | 1891 | if (tree == NULL) |
| 1892 | return FALSE; | |
| 7371 | 1893 | |
| 8505 | 1894 | *len = gtk_smiley_tree_lookup (tree, text); |
| 4032 | 1895 | return (*len > 0); |
| 1896 | } | |
| 1897 | ||
| 10526 | 1898 | GtkIMHtmlSmiley * |
| 1899 | gtk_imhtml_smiley_get(GtkIMHtml *imhtml, | |
| 1900 | const gchar *sml, | |
| 1901 | const gchar *text) | |
| 4032 | 1902 | { |
| 1903 | GtkSmileyTree *t; | |
| 1904 | const gchar *x = text; | |
| 1905 | if (sml == NULL) | |
| 1906 | t = imhtml->default_smilies; | |
| 7371 | 1907 | else |
| 4032 | 1908 | t = g_hash_table_lookup(imhtml->smiley_data, sml); |
| 7371 | 1909 | |
| 4032 | 1910 | |
| 1911 | if (t == NULL) | |
| 10526 | 1912 | return sml ? gtk_imhtml_smiley_get(imhtml, NULL, text) : NULL; |
| 4032 | 1913 | |
| 1914 | while (*x) { | |
| 1915 | gchar *pos; | |
| 1916 | ||
| 1917 | if (!t->values) { | |
| 10526 | 1918 | return sml ? gtk_imhtml_smiley_get(imhtml, NULL, text) : NULL; |
| 4032 | 1919 | } |
| 7371 | 1920 | |
| 4032 | 1921 | pos = strchr (t->values->str, *x); |
| 1922 | if (pos) { | |
| 7371 | 1923 | t = t->children [GPOINTER_TO_INT(pos) - GPOINTER_TO_INT(t->values->str)]; |
| 4032 | 1924 | } else { |
| 10526 | 1925 | return sml ? gtk_imhtml_smiley_get(imhtml, NULL, text) : NULL; |
| 4032 | 1926 | } |
| 1927 | x++; | |
| 1928 | } | |
| 1929 | ||
| 10526 | 1930 | return t->image; |
| 1931 | } | |
| 1932 | ||
|
11677
89c2ab8d2ebf
[gaim-migrate @ 13963]
Mark Doliner <markdoliner@pidgin.im>
parents:
11586
diff
changeset
|
1933 | static GdkPixbufAnimation * |
|
17009
2cc9edf33feb
Allow saving custom smileys by right-clicking on them. And use the custom smileys only on the received messages, not for the system/etc. messages.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16385
diff
changeset
|
1934 | gtk_smiley_get_image(GtkIMHtmlSmiley *smiley) |
| 10526 | 1935 | { |
| 1936 | if (!smiley->icon && smiley->file) { | |
| 1937 | smiley->icon = gdk_pixbuf_animation_new_from_file(smiley->file, NULL); | |
| 1938 | } else if (!smiley->icon && smiley->loader) { | |
| 1939 | smiley->icon = gdk_pixbuf_loader_get_animation(smiley->loader); | |
| 1940 | if (smiley->icon) | |
| 1941 | g_object_ref(G_OBJECT(smiley->icon)); | |
| 1942 | } | |
|
11572
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
1943 | |
| 10526 | 1944 | return smiley->icon; |
| 4032 | 1945 | } |
| 8890 | 1946 | |
|
17009
2cc9edf33feb
Allow saving custom smileys by right-clicking on them. And use the custom smileys only on the received messages, not for the system/etc. messages.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16385
diff
changeset
|
1947 | static GdkPixbufAnimation * |
|
2cc9edf33feb
Allow saving custom smileys by right-clicking on them. And use the custom smileys only on the received messages, not for the system/etc. messages.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16385
diff
changeset
|
1948 | gtk_smiley_tree_image (GtkIMHtml *imhtml, |
|
2cc9edf33feb
Allow saving custom smileys by right-clicking on them. And use the custom smileys only on the received messages, not for the system/etc. messages.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16385
diff
changeset
|
1949 | const gchar *sml, |
|
2cc9edf33feb
Allow saving custom smileys by right-clicking on them. And use the custom smileys only on the received messages, not for the system/etc. messages.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16385
diff
changeset
|
1950 | const gchar *text) |
|
2cc9edf33feb
Allow saving custom smileys by right-clicking on them. And use the custom smileys only on the received messages, not for the system/etc. messages.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16385
diff
changeset
|
1951 | { |
|
2cc9edf33feb
Allow saving custom smileys by right-clicking on them. And use the custom smileys only on the received messages, not for the system/etc. messages.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16385
diff
changeset
|
1952 | GtkIMHtmlSmiley *smiley; |
|
2cc9edf33feb
Allow saving custom smileys by right-clicking on them. And use the custom smileys only on the received messages, not for the system/etc. messages.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16385
diff
changeset
|
1953 | |
|
2cc9edf33feb
Allow saving custom smileys by right-clicking on them. And use the custom smileys only on the received messages, not for the system/etc. messages.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16385
diff
changeset
|
1954 | smiley = gtk_imhtml_smiley_get(imhtml,sml,text); |
|
2cc9edf33feb
Allow saving custom smileys by right-clicking on them. And use the custom smileys only on the received messages, not for the system/etc. messages.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16385
diff
changeset
|
1955 | |
|
2cc9edf33feb
Allow saving custom smileys by right-clicking on them. And use the custom smileys only on the received messages, not for the system/etc. messages.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16385
diff
changeset
|
1956 | if (!smiley) |
|
2cc9edf33feb
Allow saving custom smileys by right-clicking on them. And use the custom smileys only on the received messages, not for the system/etc. messages.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16385
diff
changeset
|
1957 | return NULL; |
|
2cc9edf33feb
Allow saving custom smileys by right-clicking on them. And use the custom smileys only on the received messages, not for the system/etc. messages.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16385
diff
changeset
|
1958 | |
|
2cc9edf33feb
Allow saving custom smileys by right-clicking on them. And use the custom smileys only on the received messages, not for the system/etc. messages.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16385
diff
changeset
|
1959 | return gtk_smiley_get_image(smiley); |
|
2cc9edf33feb
Allow saving custom smileys by right-clicking on them. And use the custom smileys only on the received messages, not for the system/etc. messages.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16385
diff
changeset
|
1960 | } |
|
2cc9edf33feb
Allow saving custom smileys by right-clicking on them. And use the custom smileys only on the received messages, not for the system/etc. messages.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16385
diff
changeset
|
1961 | |
| 4793 | 1962 | #define VALID_TAG(x) if (!g_ascii_strncasecmp (string, x ">", strlen (x ">"))) { \ |
| 3922 | 1963 | *tag = g_strndup (string, strlen (x)); \ |
| 1964 | *len = strlen (x) + 1; \ | |
| 1965 | return TRUE; \ | |
| 1966 | } \ | |
| 1967 | (*type)++ | |
| 1428 | 1968 | |
| 4793 | 1969 | #define VALID_OPT_TAG(x) if (!g_ascii_strncasecmp (string, x " ", strlen (x " "))) { \ |
| 3922 | 1970 | const gchar *c = string + strlen (x " "); \ |
| 1971 | gchar e = '"'; \ | |
| 1972 | gboolean quote = FALSE; \ | |
| 1973 | while (*c) { \ | |
| 1974 | if (*c == '"' || *c == '\'') { \ | |
| 1975 | if (quote && (*c == e)) \ | |
| 1976 | quote = !quote; \ | |
| 1977 | else if (!quote) { \ | |
| 1978 | quote = !quote; \ | |
| 1979 | e = *c; \ | |
| 1980 | } \ | |
| 1981 | } else if (!quote && (*c == '>')) \ | |
| 1982 | break; \ | |
| 1983 | c++; \ | |
| 1984 | } \ | |
| 1985 | if (*c) { \ | |
| 1986 | *tag = g_strndup (string, c - string); \ | |
| 1987 | *len = c - string + 1; \ | |
| 1988 | return TRUE; \ | |
| 1989 | } \ | |
| 1990 | } \ | |
| 1991 | (*type)++ | |
| 1428 | 1992 | |
| 1993 | ||
|
1472
ce83d12b7df9
[gaim-migrate @ 1482]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
1463
diff
changeset
|
1994 | static gboolean |
|
2856
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
1995 | gtk_imhtml_is_tag (const gchar *string, |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
1996 | gchar **tag, |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
1997 | gint *len, |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
1998 | gint *type) |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
1999 | { |
| 8061 | 2000 | char *close; |
|
2856
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2001 | *type = 1; |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2002 | |
|
8118
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
2003 | |
| 8061 | 2004 | if (!(close = strchr (string, '>'))) |
|
2856
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2005 | return FALSE; |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2006 | |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2007 | VALID_TAG ("B"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2008 | VALID_TAG ("BOLD"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2009 | VALID_TAG ("/B"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2010 | VALID_TAG ("/BOLD"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2011 | VALID_TAG ("I"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2012 | VALID_TAG ("ITALIC"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2013 | VALID_TAG ("/I"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2014 | VALID_TAG ("/ITALIC"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2015 | VALID_TAG ("U"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2016 | VALID_TAG ("UNDERLINE"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2017 | VALID_TAG ("/U"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2018 | VALID_TAG ("/UNDERLINE"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2019 | VALID_TAG ("S"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2020 | VALID_TAG ("STRIKE"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2021 | VALID_TAG ("/S"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2022 | VALID_TAG ("/STRIKE"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2023 | VALID_TAG ("SUB"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2024 | VALID_TAG ("/SUB"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2025 | VALID_TAG ("SUP"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2026 | VALID_TAG ("/SUP"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2027 | VALID_TAG ("PRE"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2028 | VALID_TAG ("/PRE"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2029 | VALID_TAG ("TITLE"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2030 | VALID_TAG ("/TITLE"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2031 | VALID_TAG ("BR"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2032 | VALID_TAG ("HR"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2033 | VALID_TAG ("/FONT"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2034 | VALID_TAG ("/A"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2035 | VALID_TAG ("P"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2036 | VALID_TAG ("/P"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2037 | VALID_TAG ("H3"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2038 | VALID_TAG ("/H3"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2039 | VALID_TAG ("HTML"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2040 | VALID_TAG ("/HTML"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2041 | VALID_TAG ("BODY"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2042 | VALID_TAG ("/BODY"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2043 | VALID_TAG ("FONT"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2044 | VALID_TAG ("HEAD"); |
| 2993 | 2045 | VALID_TAG ("/HEAD"); |
| 2046 | VALID_TAG ("BINARY"); | |
| 2047 | VALID_TAG ("/BINARY"); | |
| 5093 | 2048 | |
|
2856
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2049 | VALID_OPT_TAG ("HR"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2050 | VALID_OPT_TAG ("FONT"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2051 | VALID_OPT_TAG ("BODY"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2052 | VALID_OPT_TAG ("A"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2053 | VALID_OPT_TAG ("IMG"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2054 | VALID_OPT_TAG ("P"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2055 | VALID_OPT_TAG ("H3"); |
| 5093 | 2056 | VALID_OPT_TAG ("HTML"); |
|
2856
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2057 | |
| 5101 | 2058 | VALID_TAG ("CITE"); |
| 2059 | VALID_TAG ("/CITE"); | |
| 2060 | VALID_TAG ("EM"); | |
| 2061 | VALID_TAG ("/EM"); | |
| 2062 | VALID_TAG ("STRONG"); | |
| 2063 | VALID_TAG ("/STRONG"); | |
| 2064 | ||
| 5104 | 2065 | VALID_OPT_TAG ("SPAN"); |
| 2066 | VALID_TAG ("/SPAN"); | |
| 5174 | 2067 | VALID_TAG ("BR/"); /* hack until gtkimhtml handles things better */ |
|
6982
12f08de92674
[gaim-migrate @ 7538]
Mark Doliner <markdoliner@pidgin.im>
parents:
6882
diff
changeset
|
2068 | VALID_TAG ("IMG"); |
| 8026 | 2069 | VALID_TAG("SPAN"); |
| 8061 | 2070 | VALID_OPT_TAG("BR"); |
| 7988 | 2071 | |
| 4793 | 2072 | if (!g_ascii_strncasecmp(string, "!--", strlen ("!--"))) { |
|
2954
fc07d855731d
[gaim-migrate @ 2967]
Christian Hammond <chipx86@chipx86.com>
parents:
2898
diff
changeset
|
2073 | gchar *e = strstr (string + strlen("!--"), "-->"); |
|
2856
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2074 | if (e) { |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2075 | *len = e - string + strlen ("-->"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2076 | *tag = g_strndup (string + strlen ("!--"), *len - strlen ("!---->")); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2077 | return TRUE; |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2078 | } |
|
8118
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
2079 | } |
|
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
2080 | |
| 8061 | 2081 | *type = -1; |
| 2082 | *len = close - string + 1; | |
| 2083 | *tag = g_strndup(string, *len - 1); | |
| 2084 | return TRUE; | |
|
2856
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2085 | } |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2086 | |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2087 | static gchar* |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2088 | gtk_imhtml_get_html_opt (gchar *tag, |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2089 | const gchar *opt) |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2090 | { |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2091 | gchar *t = tag; |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2092 | gchar *e, *a; |
| 5177 | 2093 | gchar *val; |
| 2094 | gint len; | |
|
16143
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
2095 | const gchar *c; |
| 5177 | 2096 | GString *ret; |
|
2856
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2097 | |
| 4793 | 2098 | while (g_ascii_strncasecmp (t, opt, strlen (opt))) { |
|
2856
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2099 | gboolean quote = FALSE; |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2100 | if (*t == '\0') break; |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2101 | while (*t && !((*t == ' ') && !quote)) { |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2102 | if (*t == '\"') |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2103 | quote = ! quote; |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2104 | t++; |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2105 | } |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2106 | while (*t && (*t == ' ')) t++; |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2107 | } |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2108 | |
| 4793 | 2109 | if (!g_ascii_strncasecmp (t, opt, strlen (opt))) { |
|
2856
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2110 | t += strlen (opt); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2111 | } else { |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2112 | return NULL; |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2113 | } |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2114 | |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2115 | if ((*t == '\"') || (*t == '\'')) { |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2116 | e = a = ++t; |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2117 | while (*e && (*e != *(t - 1))) e++; |
| 2993 | 2118 | if (*e == '\0') { |
|
2856
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2119 | return NULL; |
| 5177 | 2120 | } else |
| 2121 | val = g_strndup(a, e - a); | |
|
2856
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2122 | } else { |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2123 | e = a = t; |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2124 | while (*e && !isspace ((gint) *e)) e++; |
| 5177 | 2125 | val = g_strndup(a, e - a); |
|
2856
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2126 | } |
| 5177 | 2127 | |
| 2128 | ret = g_string_new(""); | |
| 2129 | e = val; | |
| 2130 | while(*e) { | |
| 16144 | 2131 | if((c = purple_markup_unescape_entity(e, &len))) { |
| 7280 | 2132 | ret = g_string_append(ret, c); |
| 5177 | 2133 | e += len; |
| 2134 | } else { | |
| 2135 | ret = g_string_append_c(ret, *e); | |
| 2136 | e++; | |
| 2137 | } | |
| 2138 | } | |
| 2139 | ||
| 2140 | g_free(val); | |
|
8568
66907b37ce85
[gaim-migrate @ 9316]
Mark Doliner <markdoliner@pidgin.im>
parents:
8566
diff
changeset
|
2141 | |
|
66907b37ce85
[gaim-migrate @ 9316]
Mark Doliner <markdoliner@pidgin.im>
parents:
8566
diff
changeset
|
2142 | return g_string_free(ret, FALSE); |
|
2856
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2143 | } |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2144 | |
| 8334 | 2145 | static const char *accepted_protocols[] = { |
| 2146 | "http://", | |
| 2147 | "https://", | |
| 2148 | "ftp://" | |
| 2149 | }; | |
|
11572
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
2150 | |
| 8334 | 2151 | static const int accepted_protocols_size = 3; |
| 2152 | ||
| 2153 | /* returns if the beginning of the text is a protocol. If it is the protocol, returns the length so | |
| 2154 | the caller knows how long the protocol string is. */ | |
|
12412
8abe3226695e
[gaim-migrate @ 14719]
Richard Laager <rlaager@pidgin.im>
parents:
12335
diff
changeset
|
2155 | static int gtk_imhtml_is_protocol(const char *text) |
| 8334 | 2156 | { |
| 2157 | gint i; | |
| 2158 | ||
| 2159 | for(i=0; i<accepted_protocols_size; i++){ | |
|
18552
810a338ef085
Use the glib strcasecmp functions everywhere, as we've had reports of
Richard Laager <rlaager@pidgin.im>
parents:
18543
diff
changeset
|
2160 | if( g_ascii_strncasecmp(text, accepted_protocols[i], strlen(accepted_protocols[i])) == 0 ){ |
| 8334 | 2161 | return strlen(accepted_protocols[i]); |
| 2162 | } | |
| 2163 | } | |
| 2164 | return 0; | |
| 2165 | } | |
| 2166 | ||
| 8677 | 2167 | /* |
| 15884 | 2168 | <KingAnt> marv: The two IM image functions in oscar are purple_odc_send_im and purple_odc_incoming |
| 8677 | 2169 | |
| 2170 | ||
| 2171 | [19:58] <Robot101> marv: images go into the imgstore, a refcounted... well.. hash. :) | |
| 2172 | [19:59] <KingAnt> marv: I think the image tag used by the core is something like <img id="#"/> | |
|
11572
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
2173 | [19:59] Ro0tSiEgE robert42 RobFlynn Robot101 ross22 roz |
| 15884 | 2174 | [20:00] <KingAnt> marv: Where the ID is the what is returned when you add the image to the imgstore using purple_imgstore_add |
| 8677 | 2175 | [20:00] <marv> Robot101: so how does the image get passed to serv_got_im() and serv_send_im()? just as the <img id="#" and then the prpl looks it up from the store? |
| 2176 | [20:00] <KingAnt> marv: Right | |
| 2177 | [20:00] <marv> alright | |
| 2178 | ||
| 2179 | Here's my plan with IMImages. make gtk_imhtml_[append|insert]_text_with_images instead just | |
| 2180 | gtkimhtml_[append|insert]_text (hrm maybe it should be called html instead of text), add a | |
| 15884 | 2181 | function for purple to register for look up images, i.e. gtk_imhtml_set_get_img_fnc, so that |
| 8677 | 2182 | images can be looked up like that, instead of passing a GSList of them. |
| 2183 | */ | |
| 2184 | ||
| 2185 | void gtk_imhtml_append_text_with_images (GtkIMHtml *imhtml, | |
| 2186 | const gchar *text, | |
| 2187 | GtkIMHtmlOptions options, | |
| 2188 | GSList *unused) | |
| 1428 | 2189 | { |
| 8677 | 2190 | GtkTextIter iter, ins, sel; |
| 2191 | GdkRectangle rect; | |
| 2192 | int y, height, ins_offset = 0, sel_offset = 0; | |
| 2193 | gboolean fixins = FALSE, fixsel = FALSE; | |
| 2194 | ||
| 2195 | g_return_if_fail (imhtml != NULL); | |
| 2196 | g_return_if_fail (GTK_IS_IMHTML (imhtml)); | |
| 2197 | g_return_if_fail (text != NULL); | |
| 2198 | ||
| 2199 | ||
| 2200 | gtk_text_buffer_get_end_iter(imhtml->text_buffer, &iter); | |
| 2201 | gtk_text_buffer_get_iter_at_mark(imhtml->text_buffer, &ins, gtk_text_buffer_get_insert(imhtml->text_buffer)); | |
| 2202 | if (gtk_text_iter_equal(&iter, &ins) && gtk_text_buffer_get_selection_bounds(imhtml->text_buffer, NULL, NULL)) { | |
| 2203 | fixins = TRUE; | |
| 2204 | ins_offset = gtk_text_iter_get_offset(&ins); | |
| 2205 | } | |
| 2206 | ||
| 2207 | gtk_text_buffer_get_iter_at_mark(imhtml->text_buffer, &sel, gtk_text_buffer_get_selection_bound(imhtml->text_buffer)); | |
| 2208 | if (gtk_text_iter_equal(&iter, &sel) && gtk_text_buffer_get_selection_bounds(imhtml->text_buffer, NULL, NULL)) { | |
| 2209 | fixsel = TRUE; | |
| 2210 | sel_offset = gtk_text_iter_get_offset(&sel); | |
| 2211 | } | |
| 2212 | ||
| 2213 | gtk_text_view_get_visible_rect(GTK_TEXT_VIEW(imhtml), &rect); | |
| 2214 | gtk_text_view_get_line_yrange(GTK_TEXT_VIEW(imhtml), &iter, &y, &height); | |
| 2215 | ||
| 2216 | ||
| 2217 | if(((y + height) - (rect.y + rect.height)) > height | |
| 2218 | && gtk_text_buffer_get_char_count(imhtml->text_buffer)){ | |
| 2219 | options |= GTK_IMHTML_NO_SCROLL; | |
| 2220 | } | |
| 2221 | ||
| 2222 | gtk_imhtml_insert_html_at_iter(imhtml, text, options, &iter); | |
| 2223 | ||
| 2224 | if (fixins) { | |
| 2225 | gtk_text_buffer_get_iter_at_offset(imhtml->text_buffer, &ins, ins_offset); | |
| 2226 | gtk_text_buffer_move_mark(imhtml->text_buffer, gtk_text_buffer_get_insert(imhtml->text_buffer), &ins); | |
| 2227 | } | |
| 2228 | ||
| 2229 | if (fixsel) { | |
| 2230 | gtk_text_buffer_get_iter_at_offset(imhtml->text_buffer, &sel, sel_offset); | |
| 2231 | gtk_text_buffer_move_mark(imhtml->text_buffer, gtk_text_buffer_get_selection_bound(imhtml->text_buffer), &sel); | |
| 2232 | } | |
| 2233 | ||
| 2234 | if (!(options & GTK_IMHTML_NO_SCROLL)) { | |
| 12553 | 2235 | gtk_imhtml_scroll_to_end(imhtml, (options & GTK_IMHTML_USE_SMOOTHSCROLLING)); |
| 8677 | 2236 | } |
| 2237 | } | |
| 2238 | ||
| 11006 | 2239 | #define MAX_SCROLL_TIME 0.4 /* seconds */ |
| 2240 | #define SCROLL_DELAY 33 /* milliseconds */ | |
| 2241 | ||
| 2242 | /* | |
| 2243 | * Smoothly scroll a GtkIMHtml. | |
| 2244 | * | |
| 2245 | * @return TRUE if the window needs to be scrolled further, FALSE if we're at the bottom. | |
| 2246 | */ | |
|
10871
c0282a4f2250
[gaim-migrate @ 12558]
Mark Doliner <markdoliner@pidgin.im>
parents:
10865
diff
changeset
|
2247 | static gboolean scroll_cb(gpointer data) |
| 10798 | 2248 | { |
| 2249 | GtkIMHtml *imhtml = data; | |
| 2250 | GtkAdjustment *adj = GTK_TEXT_VIEW(imhtml)->vadjustment; | |
| 11006 | 2251 | gdouble max_val = adj->upper - adj->page_size; |
| 2252 | ||
| 2253 | g_return_val_if_fail(imhtml->scroll_time != NULL, FALSE); | |
| 2254 | ||
| 2255 | if (g_timer_elapsed(imhtml->scroll_time, NULL) > MAX_SCROLL_TIME) { | |
| 2256 | /* time's up. jump to the end and kill the timer */ | |
| 2257 | gtk_adjustment_set_value(adj, max_val); | |
| 10798 | 2258 | g_timer_destroy(imhtml->scroll_time); |
| 2259 | imhtml->scroll_time = NULL; | |
| 2260 | return FALSE; | |
| 11006 | 2261 | } |
| 2262 | ||
| 2263 | /* scroll by 1/3rd the remaining distance */ | |
| 2264 | gtk_adjustment_set_value(adj, gtk_adjustment_get_value(adj) + ((max_val - gtk_adjustment_get_value(adj)) / 3)); | |
| 2265 | return TRUE; | |
| 10798 | 2266 | } |
| 2267 | ||
| 12553 | 2268 | static gboolean smooth_scroll_idle_cb(gpointer data) |
| 10797 | 2269 | { |
| 10798 | 2270 | GtkIMHtml *imhtml = data; |
| 11006 | 2271 | imhtml->scroll_src = g_timeout_add(SCROLL_DELAY, scroll_cb, imhtml); |
| 10797 | 2272 | return FALSE; |
| 2273 | } | |
| 2274 | ||
| 12553 | 2275 | static gboolean scroll_idle_cb(gpointer data) |
| 2276 | { | |
| 2277 | GtkIMHtml *imhtml = data; | |
| 2278 | GtkAdjustment *adj = GTK_TEXT_VIEW(imhtml)->vadjustment; | |
| 2279 | if(adj) { | |
| 2280 | gtk_adjustment_set_value(adj, adj->upper - adj->page_size); | |
| 2281 | } | |
| 2282 | imhtml->scroll_src = 0; | |
| 2283 | return FALSE; | |
| 2284 | } | |
| 2285 | ||
| 2286 | void gtk_imhtml_scroll_to_end(GtkIMHtml *imhtml, gboolean smooth) | |
| 8729 | 2287 | { |
| 10798 | 2288 | if (imhtml->scroll_time) |
| 2289 | g_timer_destroy(imhtml->scroll_time); | |
| 2290 | if (imhtml->scroll_src) | |
| 2291 | g_source_remove(imhtml->scroll_src); | |
| 12553 | 2292 | if(smooth) { |
| 2293 | imhtml->scroll_time = g_timer_new(); | |
| 2294 | imhtml->scroll_src = g_idle_add_full(G_PRIORITY_LOW, smooth_scroll_idle_cb, imhtml, NULL); | |
| 2295 | } else { | |
| 2296 | imhtml->scroll_time = NULL; | |
| 2297 | imhtml->scroll_src = g_idle_add_full(G_PRIORITY_LOW, scroll_idle_cb, imhtml, NULL); | |
| 2298 | } | |
| 8729 | 2299 | } |
| 2300 | ||
| 8677 | 2301 | void gtk_imhtml_insert_html_at_iter(GtkIMHtml *imhtml, |
| 2302 | const gchar *text, | |
| 2303 | GtkIMHtmlOptions options, | |
| 2304 | GtkTextIter *iter) | |
| 2305 | { | |
| 8061 | 2306 | GdkRectangle rect; |
|
2856
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2307 | gint pos = 0; |
| 3922 | 2308 | gchar *ws; |
|
2856
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2309 | gchar *tag; |
| 3922 | 2310 | gchar *bg = NULL; |
|
6982
12f08de92674
[gaim-migrate @ 7538]
Mark Doliner <markdoliner@pidgin.im>
parents:
6882
diff
changeset
|
2311 | gint len; |
| 4032 | 2312 | gint tlen, smilelen, wpos=0; |
|
2856
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2313 | gint type; |
| 3922 | 2314 | const gchar *c; |
|
16143
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
2315 | const gchar *amp; |
| 8334 | 2316 | gint len_protocol; |
| 15379 | 2317 | |
| 1428 | 2318 | guint bold = 0, |
| 2319 | italics = 0, | |
| 2320 | underline = 0, | |
| 2321 | strike = 0, | |
| 2322 | sub = 0, | |
| 2323 | sup = 0, | |
|
1691
c8bd41036372
[gaim-migrate @ 1701]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
1647
diff
changeset
|
2324 | title = 0, |
| 8061 | 2325 | pre = 0; |
| 1428 | 2326 | |
| 10217 | 2327 | gboolean br = FALSE; |
|
16143
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
2328 | gboolean align_right = FALSE; |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
2329 | gboolean rtl_direction = FALSE; |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
2330 | gint align_line = 0; |
| 15420 | 2331 | |
| 3922 | 2332 | GSList *fonts = NULL; |
| 8506 | 2333 | GObject *object; |
| 8061 | 2334 | GtkIMHtmlScalable *scalable = NULL; |
| 8677 | 2335 | |
| 2336 | g_return_if_fail (imhtml != NULL); | |
| 2337 | g_return_if_fail (GTK_IS_IMHTML (imhtml)); | |
| 2338 | g_return_if_fail (text != NULL); | |
| 3922 | 2339 | c = text; |
|
6982
12f08de92674
[gaim-migrate @ 7538]
Mark Doliner <markdoliner@pidgin.im>
parents:
6882
diff
changeset
|
2340 | len = strlen(text); |
| 3922 | 2341 | ws = g_malloc(len + 1); |
| 2342 | ws[0] = 0; | |
| 1428 | 2343 | |
|
2856
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2344 | while (pos < len) { |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2345 | if (*c == '<' && gtk_imhtml_is_tag (c + 1, &tag, &tlen, &type)) { |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2346 | c++; |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2347 | pos++; |
| 8061 | 2348 | ws[wpos] = '\0'; |
| 10217 | 2349 | br = FALSE; |
| 8061 | 2350 | switch (type) |
| 3922 | 2351 | { |
| 2352 | case 1: /* B */ | |
| 2353 | case 2: /* BOLD */ | |
| 5101 | 2354 | case 54: /* STRONG */ |
|
11485
fe334b13d1d0
[gaim-migrate @ 13727]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11385
diff
changeset
|
2355 | if (!(options & GTK_IMHTML_NO_FORMATTING)) { |
|
fe334b13d1d0
[gaim-migrate @ 13727]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11385
diff
changeset
|
2356 | gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos); |
|
fe334b13d1d0
[gaim-migrate @ 13727]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11385
diff
changeset
|
2357 | |
|
fe334b13d1d0
[gaim-migrate @ 13727]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11385
diff
changeset
|
2358 | if ((bold == 0) && (imhtml->format_functions & GTK_IMHTML_BOLD)) |
|
fe334b13d1d0
[gaim-migrate @ 13727]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11385
diff
changeset
|
2359 | gtk_imhtml_toggle_bold(imhtml); |
|
fe334b13d1d0
[gaim-migrate @ 13727]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11385
diff
changeset
|
2360 | bold++; |
|
fe334b13d1d0
[gaim-migrate @ 13727]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11385
diff
changeset
|
2361 | ws[0] = '\0'; wpos = 0; |
|
fe334b13d1d0
[gaim-migrate @ 13727]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11385
diff
changeset
|
2362 | } |
| 3922 | 2363 | break; |
| 2364 | case 3: /* /B */ | |
| 2365 | case 4: /* /BOLD */ | |
| 5101 | 2366 | case 55: /* /STRONG */ |
|
11485
fe334b13d1d0
[gaim-migrate @ 13727]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11385
diff
changeset
|
2367 | if (!(options & GTK_IMHTML_NO_FORMATTING)) { |
|
fe334b13d1d0
[gaim-migrate @ 13727]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11385
diff
changeset
|
2368 | gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos); |
|
fe334b13d1d0
[gaim-migrate @ 13727]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11385
diff
changeset
|
2369 | ws[0] = '\0'; wpos = 0; |
|
fe334b13d1d0
[gaim-migrate @ 13727]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11385
diff
changeset
|
2370 | |
|
14010
a47143a57c82
[gaim-migrate @ 16489]
Gary Kramlich <grim@reaperworld.com>
parents:
13552
diff
changeset
|
2371 | if (bold) { |
|
11485
fe334b13d1d0
[gaim-migrate @ 13727]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11385
diff
changeset
|
2372 | bold--; |
|
14010
a47143a57c82
[gaim-migrate @ 16489]
Gary Kramlich <grim@reaperworld.com>
parents:
13552
diff
changeset
|
2373 | if ((bold == 0) && (imhtml->format_functions & GTK_IMHTML_BOLD) && !imhtml->wbfo) |
|
a47143a57c82
[gaim-migrate @ 16489]
Gary Kramlich <grim@reaperworld.com>
parents:
13552
diff
changeset
|
2374 | gtk_imhtml_toggle_bold(imhtml); |
|
a47143a57c82
[gaim-migrate @ 16489]
Gary Kramlich <grim@reaperworld.com>
parents:
13552
diff
changeset
|
2375 | } |
|
11485
fe334b13d1d0
[gaim-migrate @ 13727]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11385
diff
changeset
|
2376 | } |
| 3922 | 2377 | break; |
| 2378 | case 5: /* I */ | |
| 2379 | case 6: /* ITALIC */ | |
| 5101 | 2380 | case 52: /* EM */ |
|
11485
fe334b13d1d0
[gaim-migrate @ 13727]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11385
diff
changeset
|
2381 | if (!(options & GTK_IMHTML_NO_FORMATTING)) { |
|
fe334b13d1d0
[gaim-migrate @ 13727]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11385
diff
changeset
|
2382 | gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos); |
|
fe334b13d1d0
[gaim-migrate @ 13727]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11385
diff
changeset
|
2383 | ws[0] = '\0'; wpos = 0; |
|
fe334b13d1d0
[gaim-migrate @ 13727]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11385
diff
changeset
|
2384 | if ((italics == 0) && (imhtml->format_functions & GTK_IMHTML_ITALIC)) |
|
fe334b13d1d0
[gaim-migrate @ 13727]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11385
diff
changeset
|
2385 | gtk_imhtml_toggle_italic(imhtml); |
|
fe334b13d1d0
[gaim-migrate @ 13727]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11385
diff
changeset
|
2386 | italics++; |
|
fe334b13d1d0
[gaim-migrate @ 13727]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11385
diff
changeset
|
2387 | } |
| 3922 | 2388 | break; |
| 2389 | case 7: /* /I */ | |
| 2390 | case 8: /* /ITALIC */ | |
| 5101 | 2391 | case 53: /* /EM */ |
|
11485
fe334b13d1d0
[gaim-migrate @ 13727]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11385
diff
changeset
|
2392 | if (!(options & GTK_IMHTML_NO_FORMATTING)) { |
|
fe334b13d1d0
[gaim-migrate @ 13727]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11385
diff
changeset
|
2393 | gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos); |
|
fe334b13d1d0
[gaim-migrate @ 13727]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11385
diff
changeset
|
2394 | ws[0] = '\0'; wpos = 0; |
|
14010
a47143a57c82
[gaim-migrate @ 16489]
Gary Kramlich <grim@reaperworld.com>
parents:
13552
diff
changeset
|
2395 | if (italics) { |
|
11485
fe334b13d1d0
[gaim-migrate @ 13727]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11385
diff
changeset
|
2396 | italics--; |
|
14010
a47143a57c82
[gaim-migrate @ 16489]
Gary Kramlich <grim@reaperworld.com>
parents:
13552
diff
changeset
|
2397 | if ((italics == 0) && (imhtml->format_functions & GTK_IMHTML_ITALIC) && !imhtml->wbfo) |
|
a47143a57c82
[gaim-migrate @ 16489]
Gary Kramlich <grim@reaperworld.com>
parents:
13552
diff
changeset
|
2398 | gtk_imhtml_toggle_italic(imhtml); |
|
a47143a57c82
[gaim-migrate @ 16489]
Gary Kramlich <grim@reaperworld.com>
parents:
13552
diff
changeset
|
2399 | } |
|
11485
fe334b13d1d0
[gaim-migrate @ 13727]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11385
diff
changeset
|
2400 | } |
| 3922 | 2401 | break; |
| 2402 | case 9: /* U */ | |
| 2403 | case 10: /* UNDERLINE */ | |
|
11485
fe334b13d1d0
[gaim-migrate @ 13727]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11385
diff
changeset
|
2404 | if (!(options & GTK_IMHTML_NO_FORMATTING)) { |
|
fe334b13d1d0
[gaim-migrate @ 13727]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11385
diff
changeset
|
2405 | gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos); |
|
fe334b13d1d0
[gaim-migrate @ 13727]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11385
diff
changeset
|
2406 | ws[0] = '\0'; wpos = 0; |
|
fe334b13d1d0
[gaim-migrate @ 13727]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11385
diff
changeset
|
2407 | if ((underline == 0) && (imhtml->format_functions & GTK_IMHTML_UNDERLINE)) |
|
fe334b13d1d0
[gaim-migrate @ 13727]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11385
diff
changeset
|
2408 | gtk_imhtml_toggle_underline(imhtml); |
|
fe334b13d1d0
[gaim-migrate @ 13727]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11385
diff
changeset
|
2409 | underline++; |
|
fe334b13d1d0
[gaim-migrate @ 13727]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11385
diff
changeset
|
2410 | } |
| 3922 | 2411 | break; |
| 2412 | case 11: /* /U */ | |
| 2413 | case 12: /* /UNDERLINE */ | |
|
11485
fe334b13d1d0
[gaim-migrate @ 13727]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11385
diff
changeset
|
2414 | if (!(options & GTK_IMHTML_NO_FORMATTING)) { |
|
fe334b13d1d0
[gaim-migrate @ 13727]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11385
diff
changeset
|
2415 | gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos); |
|
fe334b13d1d0
[gaim-migrate @ 13727]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11385
diff
changeset
|
2416 | ws[0] = '\0'; wpos = 0; |
|
14010
a47143a57c82
[gaim-migrate @ 16489]
Gary Kramlich <grim@reaperworld.com>
parents:
13552
diff
changeset
|
2417 | if (underline) { |
|
11485
fe334b13d1d0
[gaim-migrate @ 13727]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11385
diff
changeset
|
2418 | underline--; |
|
14010
a47143a57c82
[gaim-migrate @ 16489]
Gary Kramlich <grim@reaperworld.com>
parents:
13552
diff
changeset
|
2419 | if ((underline == 0) && (imhtml->format_functions & GTK_IMHTML_UNDERLINE) && !imhtml->wbfo) |
|
a47143a57c82
[gaim-migrate @ 16489]
Gary Kramlich <grim@reaperworld.com>
parents:
13552
diff
changeset
|
2420 | gtk_imhtml_toggle_underline(imhtml); |
|
a47143a57c82
[gaim-migrate @ 16489]
Gary Kramlich <grim@reaperworld.com>
parents:
13552
diff
changeset
|
2421 | } |
|
11485
fe334b13d1d0
[gaim-migrate @ 13727]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11385
diff
changeset
|
2422 | } |
| 3922 | 2423 | break; |
| 2424 | case 13: /* S */ | |
| 2425 | case 14: /* STRIKE */ | |
| 9924 | 2426 | gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos); |
| 2427 | ws[0] = '\0'; wpos = 0; | |
| 2428 | if ((strike == 0) && (imhtml->format_functions & GTK_IMHTML_STRIKE)) | |
| 2429 | gtk_imhtml_toggle_strike(imhtml); | |
| 3922 | 2430 | strike++; |
| 2431 | break; | |
| 2432 | case 15: /* /S */ | |
| 2433 | case 16: /* /STRIKE */ | |
| 9924 | 2434 | gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos); |
| 2435 | ws[0] = '\0'; wpos = 0; | |
| 3922 | 2436 | if (strike) |
| 2437 | strike--; | |
| 9924 | 2438 | if ((strike == 0) && (imhtml->format_functions & GTK_IMHTML_STRIKE) && !imhtml->wbfo) |
| 2439 | gtk_imhtml_toggle_strike(imhtml); | |
| 3922 | 2440 | break; |
| 2441 | case 17: /* SUB */ | |
| 8677 | 2442 | /* FIXME: reimpliment this */ |
| 3922 | 2443 | sub++; |
| 2444 | break; | |
| 2445 | case 18: /* /SUB */ | |
| 8677 | 2446 | /* FIXME: reimpliment this */ |
| 3922 | 2447 | if (sub) |
| 2448 | sub--; | |
| 2449 | break; | |
| 2450 | case 19: /* SUP */ | |
| 8677 | 2451 | /* FIXME: reimplement this */ |
| 3922 | 2452 | sup++; |
|
2856
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2453 | break; |
| 3922 | 2454 | case 20: /* /SUP */ |
| 8677 | 2455 | /* FIXME: reimplement this */ |
| 3922 | 2456 | if (sup) |
| 2457 | sup--; | |
| 2458 | break; | |
| 2459 | case 21: /* PRE */ | |
| 8677 | 2460 | /* FIXME: reimplement this */ |
| 3922 | 2461 | pre++; |
| 2462 | break; | |
| 2463 | case 22: /* /PRE */ | |
| 8677 | 2464 | /* FIXME: reimplement this */ |
| 3922 | 2465 | if (pre) |
| 2466 | pre--; | |
| 2467 | break; | |
| 2468 | case 23: /* TITLE */ | |
| 8677 | 2469 | /* FIXME: what was this supposed to do anyway? */ |
| 3922 | 2470 | title++; |
| 2471 | break; | |
| 2472 | case 24: /* /TITLE */ | |
| 8677 | 2473 | /* FIXME: make this undo whatever 23 was supposed to do */ |
| 3922 | 2474 | if (title) { |
| 2475 | if (options & GTK_IMHTML_NO_TITLE) { | |
| 2476 | wpos = 0; | |
| 2477 | ws [wpos] = '\0'; | |
| 2478 | } | |
| 2479 | title--; | |
|
2856
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2480 | } |
| 3922 | 2481 | break; |
| 2482 | case 25: /* BR */ | |
| 5174 | 2483 | case 58: /* BR/ */ |
| 8061 | 2484 | case 61: /* BR (opt) */ |
| 3922 | 2485 | ws[wpos] = '\n'; |
| 2486 | wpos++; | |
| 10217 | 2487 | br = TRUE; |
|
6982
12f08de92674
[gaim-migrate @ 7538]
Mark Doliner <markdoliner@pidgin.im>
parents:
6882
diff
changeset
|
2488 | break; |
| 3922 | 2489 | case 26: /* HR */ |
| 2490 | case 42: /* HR (opt) */ | |
| 8726 | 2491 | { |
| 2492 | int minus; | |
|
11224
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
2493 | struct scalable_data *sd = g_new(struct scalable_data, 1); |
| 8726 | 2494 | |
| 3922 | 2495 | ws[wpos++] = '\n'; |
| 8677 | 2496 | gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos); |
| 2497 | ||
|
11224
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
2498 | sd->scalable = scalable = gtk_imhtml_hr_new(); |
|
11233
28c0f184a2d4
[gaim-migrate @ 13373]
Daniel Atallah <datallah@pidgin.im>
parents:
11224
diff
changeset
|
2499 | sd->mark = gtk_text_buffer_create_mark(imhtml->text_buffer, NULL, iter, TRUE); |
| 8061 | 2500 | gtk_text_view_get_visible_rect(GTK_TEXT_VIEW(imhtml), &rect); |
| 8677 | 2501 | scalable->add_to(scalable, imhtml, iter); |
| 8726 | 2502 | minus = gtk_text_view_get_left_margin(GTK_TEXT_VIEW(imhtml)) + |
| 2503 | gtk_text_view_get_right_margin(GTK_TEXT_VIEW(imhtml)); | |
| 2504 | scalable->scale(scalable, rect.width - minus, rect.height); | |
|
11224
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
2505 | imhtml->scalables = g_list_append(imhtml->scalables, sd); |
| 8061 | 2506 | ws[0] = '\0'; wpos = 0; |
| 7942 | 2507 | ws[wpos++] = '\n'; |
| 8061 | 2508 | |
| 3922 | 2509 | break; |
| 8726 | 2510 | } |
| 3922 | 2511 | case 27: /* /FONT */ |
| 8677 | 2512 | if (fonts && !imhtml->wbfo) { |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
2513 | GtkIMHtmlFontDetail *font = fonts->data; |
| 8677 | 2514 | gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos); |
| 8061 | 2515 | ws[0] = '\0'; wpos = 0; |
|
8177
33b3a01c6318
[gaim-migrate @ 8891]
Mark Doliner <markdoliner@pidgin.im>
parents:
8149
diff
changeset
|
2516 | /* NEW_BIT (NEW_TEXT_BIT); */ |
| 8677 | 2517 | |
| 8698 | 2518 | if (font->face && (imhtml->format_functions & GTK_IMHTML_FACE)) { |
| 8061 | 2519 | gtk_imhtml_toggle_fontface(imhtml, NULL); |
| 2520 | } | |
|
14821
c91127e2b784
[gaim-migrate @ 17516]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14741
diff
changeset
|
2521 | g_free (font->face); |
| 8698 | 2522 | if (font->fore && (imhtml->format_functions & GTK_IMHTML_FORECOLOR)) { |
| 8061 | 2523 | gtk_imhtml_toggle_forecolor(imhtml, NULL); |
| 2524 | } | |
|
14821
c91127e2b784
[gaim-migrate @ 17516]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14741
diff
changeset
|
2525 | g_free (font->fore); |
| 8698 | 2526 | if (font->back && (imhtml->format_functions & GTK_IMHTML_BACKCOLOR)) { |
| 8061 | 2527 | gtk_imhtml_toggle_backcolor(imhtml, NULL); |
| 2528 | } | |
|
14821
c91127e2b784
[gaim-migrate @ 17516]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14741
diff
changeset
|
2529 | g_free (font->back); |
|
c91127e2b784
[gaim-migrate @ 17516]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14741
diff
changeset
|
2530 | g_free (font->sml); |
| 8309 | 2531 | |
| 8698 | 2532 | if ((font->size != 3) && (imhtml->format_functions & (GTK_IMHTML_GROW|GTK_IMHTML_SHRINK))) |
| 8309 | 2533 | gtk_imhtml_font_set_size(imhtml, 3); |
| 2534 | ||
| 10761 | 2535 | fonts = g_slist_remove (fonts, font); |
| 9245 | 2536 | g_free(font); |
| 2537 | ||
| 8309 | 2538 | if (fonts) { |
| 2539 | GtkIMHtmlFontDetail *font = fonts->data; | |
| 8677 | 2540 | |
| 8698 | 2541 | if (font->face && (imhtml->format_functions & GTK_IMHTML_FACE)) |
| 8309 | 2542 | gtk_imhtml_toggle_fontface(imhtml, font->face); |
| 8698 | 2543 | if (font->fore && (imhtml->format_functions & GTK_IMHTML_FORECOLOR)) |
| 8309 | 2544 | gtk_imhtml_toggle_forecolor(imhtml, font->fore); |
| 8698 | 2545 | if (font->back && (imhtml->format_functions & GTK_IMHTML_BACKCOLOR)) |
| 8309 | 2546 | gtk_imhtml_toggle_backcolor(imhtml, font->back); |
| 8698 | 2547 | if ((font->size != 3) && (imhtml->format_functions & (GTK_IMHTML_GROW|GTK_IMHTML_SHRINK))) |
| 8309 | 2548 | gtk_imhtml_font_set_size(imhtml, font->size); |
| 2549 | } | |
| 3922 | 2550 | } |
| 8309 | 2551 | break; |
| 3922 | 2552 | case 28: /* /A */ |
| 8677 | 2553 | gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos); |
| 2554 | gtk_imhtml_toggle_link(imhtml, NULL); | |
| 2555 | ws[0] = '\0'; wpos = 0; | |
| 8061 | 2556 | break; |
|
8118
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
2557 | |
| 3922 | 2558 | case 29: /* P */ |
| 2559 | case 30: /* /P */ | |
| 2560 | case 31: /* H3 */ | |
| 2561 | case 32: /* /H3 */ | |
| 2562 | case 33: /* HTML */ | |
| 2563 | case 34: /* /HTML */ | |
| 2564 | case 35: /* BODY */ | |
| 10776 | 2565 | break; |
| 3922 | 2566 | case 36: /* /BODY */ |
| 10786 | 2567 | gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos); |
| 2568 | ws[0] = '\0'; wpos = 0; | |
| 10776 | 2569 | gtk_imhtml_toggle_background(imhtml, NULL); |
| 2570 | break; | |
| 3922 | 2571 | case 37: /* FONT */ |
| 2572 | case 38: /* HEAD */ | |
| 2573 | case 39: /* /HEAD */ | |
|
6982
12f08de92674
[gaim-migrate @ 7538]
Mark Doliner <markdoliner@pidgin.im>
parents:
6882
diff
changeset
|
2574 | case 40: /* BINARY */ |
|
12f08de92674
[gaim-migrate @ 7538]
Mark Doliner <markdoliner@pidgin.im>
parents:
6882
diff
changeset
|
2575 | case 41: /* /BINARY */ |
| 3922 | 2576 | break; |
| 2577 | case 43: /* FONT (opt) */ | |
| 2578 | { | |
| 4032 | 2579 | gchar *color, *back, *face, *size, *sml; |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
2580 | GtkIMHtmlFontDetail *font, *oldfont = NULL; |
| 3922 | 2581 | color = gtk_imhtml_get_html_opt (tag, "COLOR="); |
| 2582 | back = gtk_imhtml_get_html_opt (tag, "BACK="); | |
| 2583 | face = gtk_imhtml_get_html_opt (tag, "FACE="); | |
| 2584 | size = gtk_imhtml_get_html_opt (tag, "SIZE="); | |
| 4032 | 2585 | sml = gtk_imhtml_get_html_opt (tag, "SML="); |
| 2586 | if (!(color || back || face || size || sml)) | |
| 3922 | 2587 | break; |
| 8061 | 2588 | |
| 8677 | 2589 | gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos); |
| 8061 | 2590 | ws[0] = '\0'; wpos = 0; |
| 2591 | ||
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
2592 | font = g_new0 (GtkIMHtmlFontDetail, 1); |
| 3922 | 2593 | if (fonts) |
| 2594 | oldfont = fonts->data; | |
|
2856
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2595 | |
| 8677 | 2596 | if (color && !(options & GTK_IMHTML_NO_COLOURS) && (imhtml->format_functions & GTK_IMHTML_FORECOLOR)) { |
| 3922 | 2597 | font->fore = color; |
| 8061 | 2598 | gtk_imhtml_toggle_forecolor(imhtml, font->fore); |
|
14821
c91127e2b784
[gaim-migrate @ 17516]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14741
diff
changeset
|
2599 | } else |
|
c91127e2b784
[gaim-migrate @ 17516]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14741
diff
changeset
|
2600 | g_free(color); |
| 8677 | 2601 | |
| 2602 | if (back && !(options & GTK_IMHTML_NO_COLOURS) && (imhtml->format_functions & GTK_IMHTML_BACKCOLOR)) { | |
| 3922 | 2603 | font->back = back; |
| 8061 | 2604 | gtk_imhtml_toggle_backcolor(imhtml, font->back); |
|
14821
c91127e2b784
[gaim-migrate @ 17516]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14741
diff
changeset
|
2605 | } else |
|
c91127e2b784
[gaim-migrate @ 17516]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14741
diff
changeset
|
2606 | g_free(back); |
| 8677 | 2607 | |
| 2608 | if (face && !(options & GTK_IMHTML_NO_FONTS) && (imhtml->format_functions & GTK_IMHTML_FACE)) { | |
| 3922 | 2609 | font->face = face; |
| 8061 | 2610 | gtk_imhtml_toggle_fontface(imhtml, font->face); |
|
14821
c91127e2b784
[gaim-migrate @ 17516]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14741
diff
changeset
|
2611 | } else |
|
c91127e2b784
[gaim-migrate @ 17516]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14741
diff
changeset
|
2612 | g_free(face); |
| 4032 | 2613 | |
| 2614 | if (sml) | |
| 2615 | font->sml = sml; | |
| 2616 | else if (oldfont && oldfont->sml) | |
| 2617 | font->sml = g_strdup(oldfont->sml); | |
| 2618 | ||
| 8677 | 2619 | if (size && !(options & GTK_IMHTML_NO_SIZES) && (imhtml->format_functions & (GTK_IMHTML_GROW|GTK_IMHTML_SHRINK))) { |
| 3922 | 2620 | if (*size == '+') { |
| 2621 | sscanf (size + 1, "%hd", &font->size); | |
| 2622 | font->size += 3; | |
| 2623 | } else if (*size == '-') { | |
| 2624 | sscanf (size + 1, "%hd", &font->size); | |
| 2625 | font->size = MAX (0, 3 - font->size); | |
| 2626 | } else if (isdigit (*size)) { | |
| 2627 | sscanf (size, "%hd", &font->size); | |
|
14821
c91127e2b784
[gaim-migrate @ 17516]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14741
diff
changeset
|
2628 | } |
|
6042
e329fe962c9a
[gaim-migrate @ 6492]
Mark Doliner <markdoliner@pidgin.im>
parents:
5967
diff
changeset
|
2629 | if (font->size > 100) |
|
e329fe962c9a
[gaim-migrate @ 6492]
Mark Doliner <markdoliner@pidgin.im>
parents:
5967
diff
changeset
|
2630 | font->size = 100; |
| 3922 | 2631 | } else if (oldfont) |
| 2632 | font->size = oldfont->size; | |
| 8309 | 2633 | else |
| 2634 | font->size = 3; | |
| 8698 | 2635 | if ((imhtml->format_functions & (GTK_IMHTML_GROW|GTK_IMHTML_SHRINK))) |
| 2636 | gtk_imhtml_font_set_size(imhtml, font->size); | |
| 3922 | 2637 | g_free(size); |
| 2638 | fonts = g_slist_prepend (fonts, font); | |
| 2639 | } | |
| 2640 | break; | |
| 2641 | case 44: /* BODY (opt) */ | |
| 2642 | if (!(options & GTK_IMHTML_NO_COLOURS)) { | |
| 2643 | char *bgcolor = gtk_imhtml_get_html_opt (tag, "BGCOLOR="); | |
| 8677 | 2644 | if (bgcolor && (imhtml->format_functions & GTK_IMHTML_BACKCOLOR)) { |
| 2645 | gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos); | |
| 8061 | 2646 | ws[0] = '\0'; wpos = 0; |
|
8177
33b3a01c6318
[gaim-migrate @ 8891]
Mark Doliner <markdoliner@pidgin.im>
parents:
8149
diff
changeset
|
2647 | /* NEW_BIT(NEW_TEXT_BIT); */ |
|
14097
0c340861ab79
[gaim-migrate @ 16638]
Mark Doliner <markdoliner@pidgin.im>
parents:
14010
diff
changeset
|
2648 | g_free(bg); |
| 3922 | 2649 | bg = bgcolor; |
| 10776 | 2650 | gtk_imhtml_toggle_background(imhtml, bg); |
|
14821
c91127e2b784
[gaim-migrate @ 17516]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14741
diff
changeset
|
2651 | } else |
|
c91127e2b784
[gaim-migrate @ 17516]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14741
diff
changeset
|
2652 | g_free(bgcolor); |
| 1428 | 2653 | } |
|
2856
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2654 | break; |
| 3922 | 2655 | case 45: /* A (opt) */ |
| 2656 | { | |
| 2657 | gchar *href = gtk_imhtml_get_html_opt (tag, "HREF="); | |
| 8677 | 2658 | if (href && (imhtml->format_functions & GTK_IMHTML_LINK)) { |
| 2659 | gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos); | |
| 8061 | 2660 | ws[0] = '\0'; wpos = 0; |
| 8677 | 2661 | gtk_imhtml_toggle_link(imhtml, href); |
| 3922 | 2662 | } |
|
14097
0c340861ab79
[gaim-migrate @ 16638]
Mark Doliner <markdoliner@pidgin.im>
parents:
14010
diff
changeset
|
2663 | g_free(href); |
| 2993 | 2664 | } |
| 3922 | 2665 | break; |
| 4895 | 2666 | case 46: /* IMG (opt) */ |
|
6982
12f08de92674
[gaim-migrate @ 7538]
Mark Doliner <markdoliner@pidgin.im>
parents:
6882
diff
changeset
|
2667 | case 59: /* IMG */ |
| 4895 | 2668 | { |
| 8962 | 2669 | const char *id; |
| 2670 | ||
| 2671 | gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos); | |
| 2672 | ws[0] = '\0'; wpos = 0; | |
| 4895 | 2673 | |
| 8677 | 2674 | if (!(imhtml->format_functions & GTK_IMHTML_IMAGE)) |
| 2675 | break; | |
| 2676 | ||
| 8962 | 2677 | id = gtk_imhtml_get_html_opt(tag, "ID="); |
| 9186 | 2678 | if (!id) |
| 2679 | break; | |
| 8962 | 2680 | gtk_imhtml_insert_image_at_iter(imhtml, atoi(id), iter); |
| 2681 | break; | |
| 4895 | 2682 | } |
| 3922 | 2683 | case 47: /* P (opt) */ |
| 2684 | case 48: /* H3 (opt) */ | |
| 5093 | 2685 | case 49: /* HTML (opt) */ |
| 5101 | 2686 | case 50: /* CITE */ |
| 2687 | case 51: /* /CITE */ | |
| 8026 | 2688 | case 56: /* SPAN (opt) */ |
|
8118
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
2689 | /* Inline CSS Support - Douglas Thrift |
|
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
2690 | * |
|
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
2691 | * color |
| 8686 | 2692 | * background |
|
8118
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
2693 | * font-family |
|
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
2694 | * font-size |
| 8686 | 2695 | * text-decoration: underline |
| 14395 | 2696 | * font-weight: bold |
|
16143
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
2697 | * direction: rtl |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
2698 | * text-align: right |
| 10483 | 2699 | * |
| 2700 | * TODO: | |
| 2701 | * background-color | |
| 2702 | * font-style | |
|
8118
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
2703 | */ |
|
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
2704 | { |
|
16143
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
2705 | gchar *style, *color, *background, *family, *size, *direction, *alignment; |
| 14395 | 2706 | gchar *textdec, *weight; |
|
8118
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
2707 | GtkIMHtmlFontDetail *font, *oldfont = NULL; |
|
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
2708 | style = gtk_imhtml_get_html_opt (tag, "style="); |
|
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
2709 | |
|
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
2710 | if (!style) break; |
|
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
2711 | |
|
16143
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
2712 | color = purple_markup_get_css_property (style, "color"); |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
2713 | background = purple_markup_get_css_property (style, "background"); |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
2714 | family = purple_markup_get_css_property (style, "font-family"); |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
2715 | size = purple_markup_get_css_property (style, "font-size"); |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
2716 | textdec = purple_markup_get_css_property (style, "text-decoration"); |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
2717 | weight = purple_markup_get_css_property (style, "font-weight"); |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
2718 | direction = purple_markup_get_css_property (style, "direction"); |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
2719 | alignment = purple_markup_get_css_property (style, "text-align"); |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
2720 | |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
2721 | |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
2722 | if (!(color || family || size || background || textdec || weight || direction || alignment)) { |
| 8120 | 2723 | g_free(style); |
| 2724 | break; | |
| 2725 | } | |
|
8118
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
2726 | |
| 8677 | 2727 | |
| 2728 | gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos); | |
|
8118
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
2729 | ws[0] = '\0'; wpos = 0; |
|
8177
33b3a01c6318
[gaim-migrate @ 8891]
Mark Doliner <markdoliner@pidgin.im>
parents:
8149
diff
changeset
|
2730 | /* NEW_BIT (NEW_TEXT_BIT); */ |
|
8118
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
2731 | |
|
16143
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
2732 | /* Bi-Directional text support */ |
|
18552
810a338ef085
Use the glib strcasecmp functions everywhere, as we've had reports of
Richard Laager <rlaager@pidgin.im>
parents:
18543
diff
changeset
|
2733 | if (direction && (!g_ascii_strncasecmp(direction, "RTL", 3))) { |
|
16143
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
2734 | rtl_direction = TRUE; |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
2735 | /* insert RLE character to set direction */ |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
2736 | ws[wpos++] = 0xE2; |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
2737 | ws[wpos++] = 0x80; |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
2738 | ws[wpos++] = 0xAB; |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
2739 | ws[wpos] = '\0'; |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
2740 | gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos); |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
2741 | ws[0] = '\0'; wpos = 0; |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
2742 | } |
| 16144 | 2743 | g_free(direction); |
| 2744 | ||
|
18552
810a338ef085
Use the glib strcasecmp functions everywhere, as we've had reports of
Richard Laager <rlaager@pidgin.im>
parents:
18543
diff
changeset
|
2745 | if (alignment && (!g_ascii_strncasecmp(alignment, "RIGHT", 5))) { |
|
16143
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
2746 | align_right = TRUE; |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
2747 | align_line = gtk_text_iter_get_line(iter); |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
2748 | } |
| 16144 | 2749 | g_free(alignment); |
|
16143
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
2750 | |
|
8118
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
2751 | font = g_new0 (GtkIMHtmlFontDetail, 1); |
|
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
2752 | if (fonts) |
|
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
2753 | oldfont = fonts->data; |
|
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
2754 | |
|
14821
c91127e2b784
[gaim-migrate @ 17516]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14741
diff
changeset
|
2755 | if (color && !(options & GTK_IMHTML_NO_COLOURS) && (imhtml->format_functions & GTK_IMHTML_FORECOLOR)) { |
|
8118
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
2756 | font->fore = color; |
| 8686 | 2757 | gtk_imhtml_toggle_forecolor(imhtml, font->fore); |
|
14821
c91127e2b784
[gaim-migrate @ 17516]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14741
diff
changeset
|
2758 | } else { |
|
c91127e2b784
[gaim-migrate @ 17516]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14741
diff
changeset
|
2759 | if (oldfont && oldfont->fore) |
|
c91127e2b784
[gaim-migrate @ 17516]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14741
diff
changeset
|
2760 | font->fore = g_strdup(oldfont->fore); |
|
c91127e2b784
[gaim-migrate @ 17516]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14741
diff
changeset
|
2761 | g_free(color); |
| 8686 | 2762 | } |
|
14821
c91127e2b784
[gaim-migrate @ 17516]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14741
diff
changeset
|
2763 | |
|
c91127e2b784
[gaim-migrate @ 17516]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14741
diff
changeset
|
2764 | if (background && !(options & GTK_IMHTML_NO_COLOURS) && (imhtml->format_functions & GTK_IMHTML_BACKCOLOR)) { |
| 8686 | 2765 | font->back = background; |
| 2766 | gtk_imhtml_toggle_backcolor(imhtml, font->back); | |
|
14821
c91127e2b784
[gaim-migrate @ 17516]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14741
diff
changeset
|
2767 | } else { |
|
c91127e2b784
[gaim-migrate @ 17516]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14741
diff
changeset
|
2768 | if (oldfont && oldfont->back) |
|
c91127e2b784
[gaim-migrate @ 17516]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14741
diff
changeset
|
2769 | font->back = g_strdup(oldfont->back); |
|
c91127e2b784
[gaim-migrate @ 17516]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14741
diff
changeset
|
2770 | g_free(background); |
| 8686 | 2771 | } |
|
14821
c91127e2b784
[gaim-migrate @ 17516]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14741
diff
changeset
|
2772 | |
|
c91127e2b784
[gaim-migrate @ 17516]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14741
diff
changeset
|
2773 | if (family && !(options & GTK_IMHTML_NO_FONTS) && (imhtml->format_functions & GTK_IMHTML_FACE)) { |
|
8118
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
2774 | font->face = family; |
| 8686 | 2775 | gtk_imhtml_toggle_fontface(imhtml, font->face); |
|
14821
c91127e2b784
[gaim-migrate @ 17516]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14741
diff
changeset
|
2776 | } else { |
|
c91127e2b784
[gaim-migrate @ 17516]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14741
diff
changeset
|
2777 | if (oldfont && oldfont->face) |
|
c91127e2b784
[gaim-migrate @ 17516]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14741
diff
changeset
|
2778 | font->face = g_strdup(oldfont->face); |
|
c91127e2b784
[gaim-migrate @ 17516]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14741
diff
changeset
|
2779 | g_free(family); |
| 8686 | 2780 | } |
|
8118
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
2781 | if (font->face && (atoi(font->face) > 100)) { |
| 8677 | 2782 | /* WTF is this? */ |
|
11572
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
2783 | /* Maybe it sets a max size on the font face? I seem to |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
2784 | * remember bad things happening if the font size was |
|
9696
9d62e1ec5977
[gaim-migrate @ 10555]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9636
diff
changeset
|
2785 | * 2 billion */ |
|
8118
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
2786 | g_free(font->face); |
|
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
2787 | font->face = g_strdup("100"); |
|
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
2788 | } |
|
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
2789 | |
|
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
2790 | if (oldfont && oldfont->sml) |
|
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
2791 | font->sml = g_strdup(oldfont->sml); |
|
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
2792 | |
| 8677 | 2793 | if (size && !(options & GTK_IMHTML_NO_SIZES) && (imhtml->format_functions & (GTK_IMHTML_SHRINK|GTK_IMHTML_GROW))) { |
| 8686 | 2794 | if (g_ascii_strcasecmp(size, "xx-small") == 0) |
| 2795 | font->size = 1; | |
| 2796 | else if (g_ascii_strcasecmp(size, "smaller") == 0 | |
| 2797 | || g_ascii_strcasecmp(size, "x-small") == 0) | |
|
8118
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
2798 | font->size = 2; |
| 8686 | 2799 | else if (g_ascii_strcasecmp(size, "larger") == 0 |
| 2800 | || g_ascii_strcasecmp(size, "medium") == 0) | |
|
8118
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
2801 | font->size = 4; |
| 8686 | 2802 | else if (g_ascii_strcasecmp(size, "large") == 0) |
| 2803 | font->size = 5; | |
| 2804 | else if (g_ascii_strcasecmp(size, "x-large") == 0) | |
| 2805 | font->size = 6; | |
| 2806 | else if (g_ascii_strcasecmp(size, "xx-large") == 0) | |
| 2807 | font->size = 7; | |
|
8118
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
2808 | else |
|
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
2809 | font->size = 3; |
| 8686 | 2810 | gtk_imhtml_font_set_size(imhtml, font->size); |
| 2811 | } | |
| 2812 | else if (oldfont) | |
| 2813 | { | |
| 2814 | font->size = oldfont->size; | |
| 2815 | } | |
| 2816 | ||
| 2817 | if (oldfont) | |
| 2818 | { | |
| 2819 | font->underline = oldfont->underline; | |
| 2820 | } | |
| 2821 | if (textdec && font->underline != 1 | |
| 9025 | 2822 | && g_ascii_strcasecmp(textdec, "underline") == 0 |
|
17088
1ecea6e2fd97
Ignore bold, underline and other formatting type things in SPAN tags if
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17009
diff
changeset
|
2823 | && (imhtml->format_functions & GTK_IMHTML_UNDERLINE) |
|
1ecea6e2fd97
Ignore bold, underline and other formatting type things in SPAN tags if
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17009
diff
changeset
|
2824 | && !(options & GTK_IMHTML_NO_FORMATTING)) |
| 8686 | 2825 | { |
| 2826 | gtk_imhtml_toggle_underline(imhtml); | |
| 2827 | font->underline = 1; | |
|
14821
c91127e2b784
[gaim-migrate @ 17516]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14741
diff
changeset
|
2828 | } else |
|
c91127e2b784
[gaim-migrate @ 17516]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14741
diff
changeset
|
2829 | g_free(textdec); |
|
8118
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
2830 | |
| 14395 | 2831 | if (oldfont) |
| 2832 | { | |
| 2833 | font->bold = oldfont->bold; | |
| 2834 | } | |
| 2835 | if (weight) | |
| 2836 | { | |
| 2837 | if(!g_ascii_strcasecmp(weight, "normal")) { | |
| 2838 | font->bold = 0; | |
| 2839 | } else if(!g_ascii_strcasecmp(weight, "bold")) { | |
| 2840 | font->bold = 1; | |
| 2841 | } else if(!g_ascii_strcasecmp(weight, "bolder")) { | |
| 2842 | font->bold++; | |
| 2843 | } else if(!g_ascii_strcasecmp(weight, "lighter")) { | |
| 2844 | if(font->bold > 0) | |
| 2845 | font->bold--; | |
| 2846 | } else { | |
| 2847 | int num = atoi(weight); | |
| 2848 | if(num >= 700) | |
| 2849 | font->bold = 1; | |
| 2850 | else | |
| 2851 | font->bold = 0; | |
| 2852 | } | |
|
17088
1ecea6e2fd97
Ignore bold, underline and other formatting type things in SPAN tags if
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17009
diff
changeset
|
2853 | if (((font->bold && oldfont && !oldfont->bold) || (oldfont && oldfont->bold && !font->bold) || (font->bold && !oldfont)) && !(options & GTK_IMHTML_NO_FORMATTING)) |
| 14395 | 2854 | { |
| 2855 | gtk_imhtml_toggle_bold(imhtml); | |
| 2856 | } | |
|
14821
c91127e2b784
[gaim-migrate @ 17516]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14741
diff
changeset
|
2857 | g_free(weight); |
| 14395 | 2858 | } |
| 2859 | ||
|
8118
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
2860 | g_free(style); |
|
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
2861 | g_free(size); |
|
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
2862 | fonts = g_slist_prepend (fonts, font); |
|
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
2863 | } |
|
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
2864 | break; |
| 5104 | 2865 | case 57: /* /SPAN */ |
|
8118
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
2866 | /* Inline CSS Support - Douglas Thrift */ |
| 8677 | 2867 | if (fonts && !imhtml->wbfo) { |
| 8686 | 2868 | GtkIMHtmlFontDetail *oldfont = NULL; |
|
8118
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
2869 | GtkIMHtmlFontDetail *font = fonts->data; |
| 8677 | 2870 | gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos); |
|
8118
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
2871 | ws[0] = '\0'; wpos = 0; |
|
8177
33b3a01c6318
[gaim-migrate @ 8891]
Mark Doliner <markdoliner@pidgin.im>
parents:
8149
diff
changeset
|
2872 | /* NEW_BIT (NEW_TEXT_BIT); */ |
|
8118
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
2873 | fonts = g_slist_remove (fonts, font); |
| 8692 | 2874 | if (fonts) |
| 2875 | oldfont = fonts->data; | |
| 2876 | ||
| 2877 | if (!oldfont) { | |
| 2878 | gtk_imhtml_font_set_size(imhtml, 3); | |
|
17088
1ecea6e2fd97
Ignore bold, underline and other formatting type things in SPAN tags if
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17009
diff
changeset
|
2879 | if (font->underline && !(options & GTK_IMHTML_NO_FORMATTING)) |
| 8692 | 2880 | gtk_imhtml_toggle_underline(imhtml); |
|
17088
1ecea6e2fd97
Ignore bold, underline and other formatting type things in SPAN tags if
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17009
diff
changeset
|
2881 | if (font->bold && !(options & GTK_IMHTML_NO_FORMATTING)) |
| 14395 | 2882 | gtk_imhtml_toggle_bold(imhtml); |
|
17088
1ecea6e2fd97
Ignore bold, underline and other formatting type things in SPAN tags if
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17009
diff
changeset
|
2883 | if (!(options & GTK_IMHTML_NO_FONTS)) |
|
1ecea6e2fd97
Ignore bold, underline and other formatting type things in SPAN tags if
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17009
diff
changeset
|
2884 | gtk_imhtml_toggle_fontface(imhtml, NULL); |
|
1ecea6e2fd97
Ignore bold, underline and other formatting type things in SPAN tags if
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17009
diff
changeset
|
2885 | if (!(options & GTK_IMHTML_NO_COLOURS)) |
|
1ecea6e2fd97
Ignore bold, underline and other formatting type things in SPAN tags if
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17009
diff
changeset
|
2886 | gtk_imhtml_toggle_forecolor(imhtml, NULL); |
|
1ecea6e2fd97
Ignore bold, underline and other formatting type things in SPAN tags if
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17009
diff
changeset
|
2887 | if (!(options & GTK_IMHTML_NO_COLOURS)) |
|
1ecea6e2fd97
Ignore bold, underline and other formatting type things in SPAN tags if
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17009
diff
changeset
|
2888 | gtk_imhtml_toggle_backcolor(imhtml, NULL); |
| 8686 | 2889 | } |
| 8692 | 2890 | else |
| 8686 | 2891 | { |
| 8692 | 2892 | |
|
17088
1ecea6e2fd97
Ignore bold, underline and other formatting type things in SPAN tags if
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17009
diff
changeset
|
2893 | if ((font->size != oldfont->size) && !(options & GTK_IMHTML_NO_SIZES)) |
| 8692 | 2894 | gtk_imhtml_font_set_size(imhtml, oldfont->size); |
| 2895 | ||
|
17088
1ecea6e2fd97
Ignore bold, underline and other formatting type things in SPAN tags if
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17009
diff
changeset
|
2896 | if ((font->underline != oldfont->underline) && !(options & GTK_IMHTML_NO_FORMATTING)) |
| 8692 | 2897 | gtk_imhtml_toggle_underline(imhtml); |
| 2898 | ||
|
17088
1ecea6e2fd97
Ignore bold, underline and other formatting type things in SPAN tags if
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17009
diff
changeset
|
2899 | if (((font->bold && !oldfont->bold) || (oldfont->bold && !font->bold)) && !(options & GTK_IMHTML_NO_FORMATTING)) |
| 14395 | 2900 | gtk_imhtml_toggle_bold(imhtml); |
| 2901 | ||
|
17088
1ecea6e2fd97
Ignore bold, underline and other formatting type things in SPAN tags if
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17009
diff
changeset
|
2902 | if (font->face && (!oldfont->face || strcmp(font->face, oldfont->face) != 0) && !(options & GTK_IMHTML_NO_FONTS)) |
| 8692 | 2903 | gtk_imhtml_toggle_fontface(imhtml, oldfont->face); |
| 2904 | ||
|
17088
1ecea6e2fd97
Ignore bold, underline and other formatting type things in SPAN tags if
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17009
diff
changeset
|
2905 | if (font->fore && (!oldfont->fore || strcmp(font->fore, oldfont->fore) != 0) && !(options & GTK_IMHTML_NO_COLOURS)) |
| 8692 | 2906 | gtk_imhtml_toggle_forecolor(imhtml, oldfont->fore); |
| 2907 | ||
|
17088
1ecea6e2fd97
Ignore bold, underline and other formatting type things in SPAN tags if
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17009
diff
changeset
|
2908 | if (font->back && (!oldfont->back || strcmp(font->back, oldfont->back) != 0) && !(options & GTK_IMHTML_NO_COLOURS)) |
| 8692 | 2909 | gtk_imhtml_toggle_backcolor(imhtml, oldfont->back); |
| 8686 | 2910 | } |
| 8692 | 2911 | |
| 2912 | g_free (font->face); | |
| 2913 | g_free (font->fore); | |
| 2914 | g_free (font->back); | |
| 2915 | g_free (font->sml); | |
| 2916 | ||
|
8118
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
2917 | g_free (font); |
|
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
2918 | } |
|
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
2919 | break; |
| 8026 | 2920 | case 60: /* SPAN */ |
| 2993 | 2921 | break; |
| 8061 | 2922 | case 62: /* comment */ |
|
8177
33b3a01c6318
[gaim-migrate @ 8891]
Mark Doliner <markdoliner@pidgin.im>
parents:
8149
diff
changeset
|
2923 | /* NEW_BIT (NEW_TEXT_BIT); */ |
| 8317 | 2924 | ws[wpos] = '\0'; |
| 9465 | 2925 | |
| 8677 | 2926 | gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos); |
| 2927 | ||
|
10815
b1ca28de65d3
[gaim-migrate @ 12470]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10814
diff
changeset
|
2928 | if (imhtml->show_comments && !(options & GTK_IMHTML_NO_COMMENTS)) { |
|
6124
322206d79652
[gaim-migrate @ 6598]
Mark Doliner <markdoliner@pidgin.im>
parents:
6066
diff
changeset
|
2929 | wpos = g_snprintf (ws, len, "%s", tag); |
|
10815
b1ca28de65d3
[gaim-migrate @ 12470]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10814
diff
changeset
|
2930 | gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos); |
|
b1ca28de65d3
[gaim-migrate @ 12470]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10814
diff
changeset
|
2931 | } |
|
b1ca28de65d3
[gaim-migrate @ 12470]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10814
diff
changeset
|
2932 | ws[0] = '\0'; wpos = 0; |
|
b1ca28de65d3
[gaim-migrate @ 12470]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10814
diff
changeset
|
2933 | |
|
8177
33b3a01c6318
[gaim-migrate @ 8891]
Mark Doliner <markdoliner@pidgin.im>
parents:
8149
diff
changeset
|
2934 | /* NEW_BIT (NEW_COMMENT_BIT); */ |
| 3922 | 2935 | break; |
| 2936 | default: | |
| 6882 | 2937 | break; |
| 2993 | 2938 | } |
|
2856
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2939 | c += tlen; |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2940 | pos += tlen; |
|
13138
4d3bd039da3e
[gaim-migrate @ 15499]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13137
diff
changeset
|
2941 | g_free(tag); /* This was allocated back in VALID_TAG() */ |
|
15331
a8ef18791524
[gaim-migrate @ 18059]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15111
diff
changeset
|
2942 | } else if (imhtml->edit.link == NULL && |
|
a8ef18791524
[gaim-migrate @ 18059]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15111
diff
changeset
|
2943 | gtk_imhtml_is_smiley(imhtml, fonts, c, &smilelen)) { |
| 8473 | 2944 | GtkIMHtmlFontDetail *fd; |
| 2945 | ||
| 2946 | gchar *sml = NULL; | |
| 2947 | if (fonts) { | |
| 2948 | fd = fonts->data; | |
| 2949 | sml = fd->sml; | |
| 2950 | } | |
| 9029 | 2951 | if (!sml) |
| 2952 | sml = imhtml->protocol_name; | |
| 2953 | ||
| 8677 | 2954 | gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos); |
| 8505 | 2955 | wpos = g_snprintf (ws, smilelen + 1, "%s", c); |
| 8473 | 2956 | |
| 8677 | 2957 | gtk_imhtml_insert_smiley_at_iter(imhtml, sml, ws, iter); |
| 8473 | 2958 | |
| 8505 | 2959 | c += smilelen; |
| 2960 | pos += smilelen; | |
| 8473 | 2961 | wpos = 0; |
| 2962 | ws[0] = 0; | |
| 16144 | 2963 | } else if (*c == '&' && (amp = purple_markup_unescape_entity(c, &tlen))) { |
| 7280 | 2964 | while(*amp) { |
| 2965 | ws [wpos++] = *amp++; | |
| 2966 | } | |
|
2856
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2967 | c += tlen; |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2968 | pos += tlen; |
| 1428 | 2969 | } else if (*c == '\n') { |
| 2970 | if (!(options & GTK_IMHTML_NO_NEWLINE)) { | |
| 3922 | 2971 | ws[wpos] = '\n'; |
| 2972 | wpos++; | |
| 8677 | 2973 | gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos); |
| 8061 | 2974 | ws[0] = '\0'; |
| 2975 | wpos = 0; | |
|
8177
33b3a01c6318
[gaim-migrate @ 8891]
Mark Doliner <markdoliner@pidgin.im>
parents:
8149
diff
changeset
|
2976 | /* NEW_BIT (NEW_TEXT_BIT); */ |
| 10217 | 2977 | } else if (!br) { /* Don't insert a space immediately after an HTML break */ |
| 9621 | 2978 | /* A newline is defined by HTML as whitespace, which means we have to replace it with a word boundary. |
| 2979 | * word breaks vary depending on the language used, so the correct thing to do is to use Pango to determine | |
| 2980 | * what language this is, determine the proper word boundary to use, and insert that. I'm just going to insert | |
| 2981 | * a space instead. What are the non-English speakers going to do? Complain in a language I'll understand? | |
| 2982 | * Bu-wahaha! */ | |
| 2983 | ws[wpos] = ' '; | |
| 2984 | wpos++; | |
| 2985 | gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos); | |
| 2986 | ws[0] = '\0'; | |
| 2987 | wpos = 0; | |
| 1428 | 2988 | } |
| 2989 | c++; | |
|
2856
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2990 | pos++; |
| 8334 | 2991 | } else if ((len_protocol = gtk_imhtml_is_protocol(c)) > 0){ |
| 2992 | while(len_protocol--){ | |
| 8677 | 2993 | /* Skip the next len_protocol characters, but make sure they're |
| 8334 | 2994 | copied into the ws array. |
| 2995 | */ | |
| 2996 | ws [wpos++] = *c++; | |
| 2997 | pos++; | |
| 2998 | } | |
| 8061 | 2999 | } else if (*c) { |
| 1428 | 3000 | ws [wpos++] = *c++; |
|
2856
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
3001 | pos++; |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
3002 | } else { |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
3003 | break; |
| 1428 | 3004 | } |
| 3005 | } | |
| 8677 | 3006 | gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos); |
| 8061 | 3007 | ws[0] = '\0'; wpos = 0; |
| 3008 | ||
|
8177
33b3a01c6318
[gaim-migrate @ 8891]
Mark Doliner <markdoliner@pidgin.im>
parents:
8149
diff
changeset
|
3009 | /* NEW_BIT(NEW_TEXT_BIT); */ |
| 8061 | 3010 | |
|
16143
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
3011 | if(align_right) { |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
3012 | /* insert RLM+LRM at beginning of the line to set alignment */ |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
3013 | GtkTextIter line_iter; |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
3014 | line_iter = *iter; |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
3015 | gtk_text_iter_set_line(&line_iter, align_line); |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
3016 | /* insert RLM character to set alignment */ |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
3017 | ws[wpos++] = 0xE2; |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
3018 | ws[wpos++] = 0x80; |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
3019 | ws[wpos++] = 0x8F; |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
3020 | |
| 16144 | 3021 | if (!rtl_direction) |
|
16143
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
3022 | { |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
3023 | /* insert LRM character to set direction */ |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
3024 | /* (alignment=right and direction=LTR) */ |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
3025 | ws[wpos++] = 0xE2; |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
3026 | ws[wpos++] = 0x80; |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
3027 | ws[wpos++] = 0x8E; |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
3028 | } |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
3029 | |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
3030 | ws[wpos] = '\0'; |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
3031 | gtk_text_buffer_insert(imhtml->text_buffer, &line_iter, ws, wpos); |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
3032 | gtk_text_buffer_get_end_iter(gtk_text_iter_get_buffer(&line_iter), iter); |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
3033 | ws[0] = '\0'; |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
3034 | wpos = 0; |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
3035 | } |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
3036 | |
| 4032 | 3037 | while (fonts) { |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
3038 | GtkIMHtmlFontDetail *font = fonts->data; |
| 4032 | 3039 | fonts = g_slist_remove (fonts, font); |
|
14097
0c340861ab79
[gaim-migrate @ 16638]
Mark Doliner <markdoliner@pidgin.im>
parents:
14010
diff
changeset
|
3040 | g_free (font->face); |
|
0c340861ab79
[gaim-migrate @ 16638]
Mark Doliner <markdoliner@pidgin.im>
parents:
14010
diff
changeset
|
3041 | g_free (font->fore); |
|
0c340861ab79
[gaim-migrate @ 16638]
Mark Doliner <markdoliner@pidgin.im>
parents:
14010
diff
changeset
|
3042 | g_free (font->back); |
|
0c340861ab79
[gaim-migrate @ 16638]
Mark Doliner <markdoliner@pidgin.im>
parents:
14010
diff
changeset
|
3043 | g_free (font->sml); |
| 4032 | 3044 | g_free (font); |
| 3045 | } | |
| 8932 | 3046 | |
| 3047 | g_free(ws); | |
|
13138
4d3bd039da3e
[gaim-migrate @ 15499]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13137
diff
changeset
|
3048 | g_free(bg); |
| 8677 | 3049 | |
| 3050 | if (!imhtml->wbfo) | |
| 8698 | 3051 | gtk_imhtml_close_tags(imhtml, iter); |
| 8506 | 3052 | |
| 15403 | 3053 | object = g_object_ref(G_OBJECT(imhtml)); |
| 8506 | 3054 | g_signal_emit(object, signals[UPDATE_FORMAT], 0); |
| 3055 | g_object_unref(object); | |
| 15420 | 3056 | |
| 3922 | 3057 | } |
| 3058 | ||
| 4892 | 3059 | void gtk_imhtml_remove_smileys(GtkIMHtml *imhtml) |
| 3060 | { | |
| 4288 | 3061 | g_hash_table_destroy(imhtml->smiley_data); |
| 3062 | gtk_smiley_tree_destroy(imhtml->default_smilies); | |
| 4892 | 3063 | imhtml->smiley_data = g_hash_table_new_full(g_str_hash, g_str_equal, |
| 4902 | 3064 | g_free, (GDestroyNotify)gtk_smiley_tree_destroy); |
| 4288 | 3065 | imhtml->default_smilies = gtk_smiley_tree_new(); |
| 3066 | } | |
| 8481 | 3067 | |
| 3922 | 3068 | void gtk_imhtml_show_comments (GtkIMHtml *imhtml, |
| 4253 | 3069 | gboolean show) |
| 3070 | { | |
|
6124
322206d79652
[gaim-migrate @ 6598]
Mark Doliner <markdoliner@pidgin.im>
parents:
6066
diff
changeset
|
3071 | imhtml->show_comments = show; |
| 4253 | 3072 | } |
|
1780
431333222954
[gaim-migrate @ 1790]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
1738
diff
changeset
|
3073 | |
|
11814
5003711283c0
[gaim-migrate @ 14105]
Richard Laager <rlaager@pidgin.im>
parents:
11768
diff
changeset
|
3074 | const char * |
|
5003711283c0
[gaim-migrate @ 14105]
Richard Laager <rlaager@pidgin.im>
parents:
11768
diff
changeset
|
3075 | gtk_imhtml_get_protocol_name(GtkIMHtml *imhtml) { |
|
5003711283c0
[gaim-migrate @ 14105]
Richard Laager <rlaager@pidgin.im>
parents:
11768
diff
changeset
|
3076 | return imhtml->protocol_name; |
|
5003711283c0
[gaim-migrate @ 14105]
Richard Laager <rlaager@pidgin.im>
parents:
11768
diff
changeset
|
3077 | } |
|
5003711283c0
[gaim-migrate @ 14105]
Richard Laager <rlaager@pidgin.im>
parents:
11768
diff
changeset
|
3078 | |
| 8962 | 3079 | void |
| 9029 | 3080 | gtk_imhtml_set_protocol_name(GtkIMHtml *imhtml, const gchar *protocol_name) { |
|
14097
0c340861ab79
[gaim-migrate @ 16638]
Mark Doliner <markdoliner@pidgin.im>
parents:
14010
diff
changeset
|
3081 | g_free(imhtml->protocol_name); |
|
0c340861ab79
[gaim-migrate @ 16638]
Mark Doliner <markdoliner@pidgin.im>
parents:
14010
diff
changeset
|
3082 | imhtml->protocol_name = g_strdup(protocol_name); |
| 8456 | 3083 | } |
| 3084 | ||
|
1780
431333222954
[gaim-migrate @ 1790]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
1738
diff
changeset
|
3085 | void |
|
11224
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3086 | gtk_imhtml_delete(GtkIMHtml *imhtml, GtkTextIter *start, GtkTextIter *end) { |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3087 | GList *l; |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3088 | GSList *sl; |
|
11234
e23fd86e7581
[gaim-migrate @ 13377]
Daniel Atallah <datallah@pidgin.im>
parents:
11233
diff
changeset
|
3089 | GtkTextIter i, i_s, i_e; |
| 8427 | 3090 | GObject *object = g_object_ref(G_OBJECT(imhtml)); |
|
11224
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3091 | |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3092 | if (start == NULL) { |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3093 | gtk_text_buffer_get_start_iter(imhtml->text_buffer, &i_s); |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3094 | start = &i_s; |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3095 | } |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3096 | |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3097 | if (end == NULL) { |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3098 | gtk_text_buffer_get_end_iter(imhtml->text_buffer, &i_e); |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3099 | end = &i_e; |
| 7991 | 3100 | } |
|
11224
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3101 | |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3102 | l = imhtml->scalables; |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3103 | while (l) { |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3104 | GList *next = l->next; |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3105 | struct scalable_data *sd = l->data; |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3106 | gtk_text_buffer_get_iter_at_mark(imhtml->text_buffer, |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3107 | &i, sd->mark); |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3108 | if (gtk_text_iter_in_range(&i, start, end)) { |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3109 | GtkIMHtmlScalable *scale = sd->scalable; |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3110 | scale->free(scale); |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3111 | imhtml->scalables = g_list_remove_link(imhtml->scalables, l); |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3112 | } |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3113 | l = next; |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3114 | } |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3115 | |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3116 | sl = imhtml->im_images; |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3117 | while (sl) { |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3118 | GSList *next = sl->next; |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3119 | struct im_image_data *img_data = sl->data; |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3120 | gtk_text_buffer_get_iter_at_mark(imhtml->text_buffer, |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3121 | &i, img_data->mark); |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3122 | if (gtk_text_iter_in_range(&i, start, end)) { |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3123 | if (imhtml->funcs->image_unref) |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3124 | imhtml->funcs->image_unref(img_data->id); |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3125 | imhtml->im_images = g_slist_delete_link(imhtml->im_images, sl); |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3126 | g_free(img_data); |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3127 | } |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3128 | sl = next; |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3129 | } |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3130 | gtk_text_buffer_delete(imhtml->text_buffer, start, end); |
| 8061 | 3131 | |
| 8427 | 3132 | g_object_unref(object); |
|
1780
431333222954
[gaim-migrate @ 1790]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
1738
diff
changeset
|
3133 | } |
|
2363
0767c14d7879
[gaim-migrate @ 2376]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2349
diff
changeset
|
3134 | |
| 4046 | 3135 | void gtk_imhtml_page_up (GtkIMHtml *imhtml) |
| 3136 | { | |
| 5282 | 3137 | GdkRectangle rect; |
| 3138 | GtkTextIter iter; | |
| 4046 | 3139 | |
| 5282 | 3140 | gtk_text_view_get_visible_rect(GTK_TEXT_VIEW(imhtml), &rect); |
| 3141 | gtk_text_view_get_iter_at_location(GTK_TEXT_VIEW(imhtml), &iter, rect.x, | |
| 3142 | rect.y - rect.height); | |
| 3143 | gtk_text_view_scroll_to_iter(GTK_TEXT_VIEW(imhtml), &iter, 0, TRUE, 0, 0); | |
| 8061 | 3144 | |
| 4046 | 3145 | } |
| 5282 | 3146 | void gtk_imhtml_page_down (GtkIMHtml *imhtml) |
| 3147 | { | |
| 3148 | GdkRectangle rect; | |
| 3149 | GtkTextIter iter; | |
| 3150 | ||
| 3151 | gtk_text_view_get_visible_rect(GTK_TEXT_VIEW(imhtml), &rect); | |
| 3152 | gtk_text_view_get_iter_at_location(GTK_TEXT_VIEW(imhtml), &iter, rect.x, | |
| 3153 | rect.y + rect.height); | |
| 3154 | gtk_text_view_scroll_to_iter(GTK_TEXT_VIEW(imhtml), &iter, 0, TRUE, 0, 0); | |
| 3155 | } | |
| 4735 | 3156 | |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
3157 | /* GtkIMHtmlScalable, gtk_imhtml_image, gtk_imhtml_hr */ |
| 8962 | 3158 | GtkIMHtmlScalable *gtk_imhtml_image_new(GdkPixbuf *img, const gchar *filename, int id) |
| 4735 | 3159 | { |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
3160 | GtkIMHtmlImage *im_image = g_malloc(sizeof(GtkIMHtmlImage)); |
| 4895 | 3161 | |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
3162 | GTK_IMHTML_SCALABLE(im_image)->scale = gtk_imhtml_image_scale; |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
3163 | GTK_IMHTML_SCALABLE(im_image)->add_to = gtk_imhtml_image_add_to; |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
3164 | GTK_IMHTML_SCALABLE(im_image)->free = gtk_imhtml_image_free; |
| 5046 | 3165 | |
| 3166 | im_image->pixbuf = img; | |
|
18151
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
3167 | im_image->image = GTK_IMAGE(gtk_image_new_from_pixbuf(im_image->pixbuf)); |
| 4895 | 3168 | im_image->width = gdk_pixbuf_get_width(img); |
| 3169 | im_image->height = gdk_pixbuf_get_height(img); | |
| 3170 | im_image->mark = NULL; | |
|
14097
0c340861ab79
[gaim-migrate @ 16638]
Mark Doliner <markdoliner@pidgin.im>
parents:
14010
diff
changeset
|
3171 | im_image->filename = g_strdup(filename); |
| 8962 | 3172 | im_image->id = id; |
|
9573
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3173 | im_image->filesel = NULL; |
| 4895 | 3174 | |
| 5046 | 3175 | g_object_ref(img); |
| 4895 | 3176 | return GTK_IMHTML_SCALABLE(im_image); |
| 3177 | } | |
| 3178 | ||
|
18151
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
3179 | static gboolean |
|
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
3180 | animate_image_cb(gpointer data) |
|
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
3181 | { |
|
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
3182 | GtkIMHtmlImage *im_image; |
|
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
3183 | int width, height; |
|
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
3184 | int delay; |
|
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
3185 | |
|
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
3186 | im_image = data; |
|
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
3187 | |
|
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
3188 | /* Update the pointer to this GdkPixbuf frame of the animation */ |
|
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
3189 | g_object_unref(G_OBJECT(im_image->pixbuf)); |
|
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
3190 | gdk_pixbuf_animation_iter_advance(GTK_IMHTML_ANIMATION(im_image)->iter, NULL); |
|
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
3191 | im_image->pixbuf = gdk_pixbuf_animation_iter_get_pixbuf(GTK_IMHTML_ANIMATION(im_image)->iter); |
|
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
3192 | g_object_ref(G_OBJECT(im_image->pixbuf)); |
|
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
3193 | |
|
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
3194 | /* Update the displayed GtkImage */ |
|
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
3195 | width = gdk_pixbuf_get_width(gtk_image_get_pixbuf(im_image->image)); |
|
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
3196 | height = gdk_pixbuf_get_height(gtk_image_get_pixbuf(im_image->image)); |
|
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
3197 | if (width > 0 && height > 0) |
|
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
3198 | { |
|
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
3199 | /* Need to scale the new frame to the same size as the old frame */ |
|
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
3200 | GdkPixbuf *tmp; |
|
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
3201 | tmp = gdk_pixbuf_scale_simple(im_image->pixbuf, width, height, GDK_INTERP_BILINEAR); |
|
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
3202 | gtk_image_set_from_pixbuf(im_image->image, tmp); |
|
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
3203 | g_object_unref(G_OBJECT(tmp)); |
|
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
3204 | } else { |
|
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
3205 | /* Display at full-size */ |
|
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
3206 | gtk_image_set_from_pixbuf(im_image->image, im_image->pixbuf); |
|
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
3207 | } |
|
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
3208 | |
|
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
3209 | delay = MIN(gdk_pixbuf_animation_iter_get_delay_time(GTK_IMHTML_ANIMATION(im_image)->iter), 100); |
|
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
3210 | GTK_IMHTML_ANIMATION(im_image)->timer = g_timeout_add(delay, animate_image_cb, im_image); |
|
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
3211 | |
|
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
3212 | return FALSE; |
|
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
3213 | } |
|
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
3214 | |
|
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
3215 | GtkIMHtmlScalable *gtk_imhtml_animation_new(GdkPixbufAnimation *anim, const gchar *filename, int id) |
|
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
3216 | { |
|
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
3217 | GtkIMHtmlImage *im_image = g_malloc(sizeof(GtkIMHtmlAnimation)); |
|
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
3218 | |
|
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
3219 | GTK_IMHTML_SCALABLE(im_image)->scale = gtk_imhtml_image_scale; |
|
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
3220 | GTK_IMHTML_SCALABLE(im_image)->add_to = gtk_imhtml_image_add_to; |
|
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
3221 | GTK_IMHTML_SCALABLE(im_image)->free = gtk_imhtml_animation_free; |
|
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
3222 | |
|
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
3223 | GTK_IMHTML_ANIMATION(im_image)->anim = anim; |
|
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
3224 | if (gdk_pixbuf_animation_is_static_image(anim)) { |
|
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
3225 | GTK_IMHTML_ANIMATION(im_image)->iter = NULL; |
|
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
3226 | im_image->pixbuf = gdk_pixbuf_animation_get_static_image(anim); |
|
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
3227 | GTK_IMHTML_ANIMATION(im_image)->timer = 0; |
|
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
3228 | } else { |
|
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
3229 | int delay; |
|
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
3230 | GTK_IMHTML_ANIMATION(im_image)->iter = gdk_pixbuf_animation_get_iter(anim, NULL); |
|
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
3231 | im_image->pixbuf = gdk_pixbuf_animation_iter_get_pixbuf(GTK_IMHTML_ANIMATION(im_image)->iter); |
|
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
3232 | delay = MIN(gdk_pixbuf_animation_iter_get_delay_time(GTK_IMHTML_ANIMATION(im_image)->iter), 100); |
|
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
3233 | GTK_IMHTML_ANIMATION(im_image)->timer = g_timeout_add(delay, animate_image_cb, im_image); |
|
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
3234 | } |
|
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
3235 | im_image->image = GTK_IMAGE(gtk_image_new_from_pixbuf(im_image->pixbuf)); |
|
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
3236 | im_image->width = gdk_pixbuf_animation_get_width(anim); |
|
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
3237 | im_image->height = gdk_pixbuf_animation_get_height(anim); |
|
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
3238 | im_image->mark = NULL; |
|
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
3239 | im_image->filename = g_strdup(filename); |
|
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
3240 | im_image->id = id; |
|
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
3241 | im_image->filesel = NULL; |
|
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
3242 | |
|
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
3243 | g_object_ref(anim); |
|
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
3244 | g_object_ref(im_image->pixbuf); |
|
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
3245 | |
|
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
3246 | return GTK_IMHTML_SCALABLE(im_image); |
|
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
3247 | } |
|
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
3248 | |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
3249 | void gtk_imhtml_image_scale(GtkIMHtmlScalable *scale, int width, int height) |
| 4895 | 3250 | { |
|
11867
de448bc5da1a
[gaim-migrate @ 14158]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11844
diff
changeset
|
3251 | GtkIMHtmlImage *im_image = (GtkIMHtmlImage *)scale; |
|
de448bc5da1a
[gaim-migrate @ 14158]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11844
diff
changeset
|
3252 | |
|
de448bc5da1a
[gaim-migrate @ 14158]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11844
diff
changeset
|
3253 | if (im_image->width > width || im_image->height > height) { |
|
11840
c9ec5a42d420
[gaim-migrate @ 14131]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11820
diff
changeset
|
3254 | double ratio_w, ratio_h, ratio; |
|
c9ec5a42d420
[gaim-migrate @ 14131]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11820
diff
changeset
|
3255 | int new_h, new_w; |
| 4895 | 3256 | GdkPixbuf *new_image = NULL; |
|
11840
c9ec5a42d420
[gaim-migrate @ 14131]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11820
diff
changeset
|
3257 | |
|
11867
de448bc5da1a
[gaim-migrate @ 14158]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11844
diff
changeset
|
3258 | ratio_w = ((double)width - 2) / im_image->width; |
|
de448bc5da1a
[gaim-migrate @ 14158]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11844
diff
changeset
|
3259 | ratio_h = ((double)height - 2) / im_image->height; |
|
11840
c9ec5a42d420
[gaim-migrate @ 14131]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11820
diff
changeset
|
3260 | |
|
c9ec5a42d420
[gaim-migrate @ 14131]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11820
diff
changeset
|
3261 | ratio = (ratio_w < ratio_h) ? ratio_w : ratio_h; |
|
c9ec5a42d420
[gaim-migrate @ 14131]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11820
diff
changeset
|
3262 | |
|
11867
de448bc5da1a
[gaim-migrate @ 14158]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11844
diff
changeset
|
3263 | new_w = (int)(im_image->width * ratio); |
|
de448bc5da1a
[gaim-migrate @ 14158]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11844
diff
changeset
|
3264 | new_h = (int)(im_image->height * ratio); |
|
de448bc5da1a
[gaim-migrate @ 14158]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11844
diff
changeset
|
3265 | |
|
de448bc5da1a
[gaim-migrate @ 14158]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11844
diff
changeset
|
3266 | new_image = gdk_pixbuf_scale_simple(im_image->pixbuf, new_w, new_h, GDK_INTERP_BILINEAR); |
|
de448bc5da1a
[gaim-migrate @ 14158]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11844
diff
changeset
|
3267 | gtk_image_set_from_pixbuf(im_image->image, new_image); |
|
de448bc5da1a
[gaim-migrate @ 14158]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11844
diff
changeset
|
3268 | g_object_unref(G_OBJECT(new_image)); |
|
de448bc5da1a
[gaim-migrate @ 14158]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11844
diff
changeset
|
3269 | } else if (gdk_pixbuf_get_width(gtk_image_get_pixbuf(im_image->image)) != im_image->width) { |
|
de448bc5da1a
[gaim-migrate @ 14158]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11844
diff
changeset
|
3270 | /* Enough space to show the full-size of the image. */ |
|
de448bc5da1a
[gaim-migrate @ 14158]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11844
diff
changeset
|
3271 | GdkPixbuf *new_image; |
|
de448bc5da1a
[gaim-migrate @ 14158]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11844
diff
changeset
|
3272 | |
|
de448bc5da1a
[gaim-migrate @ 14158]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11844
diff
changeset
|
3273 | new_image = gdk_pixbuf_scale_simple(im_image->pixbuf, im_image->width, im_image->height, GDK_INTERP_BILINEAR); |
|
de448bc5da1a
[gaim-migrate @ 14158]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11844
diff
changeset
|
3274 | gtk_image_set_from_pixbuf(im_image->image, new_image); |
| 4895 | 3275 | g_object_unref(G_OBJECT(new_image)); |
| 3276 | } | |
| 3277 | } | |
| 3278 | ||
|
9573
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3279 | static void |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3280 | image_save_yes_cb(GtkIMHtmlImage *image, const char *filename) |
| 5012 | 3281 | { |
| 3282 | gchar *type = NULL; | |
| 5019 | 3283 | GError *error = NULL; |
| 5015 | 3284 | #if GTK_CHECK_VERSION(2,2,0) |
| 5012 | 3285 | GSList *formats = gdk_pixbuf_get_formats(); |
|
6162
aed29c41bdfa
[gaim-migrate @ 6642]
Mark Doliner <markdoliner@pidgin.im>
parents:
6124
diff
changeset
|
3286 | #else |
|
aed29c41bdfa
[gaim-migrate @ 6642]
Mark Doliner <markdoliner@pidgin.im>
parents:
6124
diff
changeset
|
3287 | char *basename = g_path_get_basename(filename); |
|
aed29c41bdfa
[gaim-migrate @ 6642]
Mark Doliner <markdoliner@pidgin.im>
parents:
6124
diff
changeset
|
3288 | char *ext = strrchr(basename, '.'); |
|
5959
827dbe4b5bb2
[gaim-migrate @ 6405]
Mark Doliner <markdoliner@pidgin.im>
parents:
5582
diff
changeset
|
3289 | #endif |
|
17694
d7b54168059b
When right-clicking on an image in a GtkIMHtml to save it, if the file
Mark Doliner <markdoliner@pidgin.im>
parents:
17546
diff
changeset
|
3290 | char *newfilename; |
| 5012 | 3291 | |
|
9573
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3292 | gtk_widget_destroy(image->filesel); |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3293 | image->filesel = NULL; |
|
5959
827dbe4b5bb2
[gaim-migrate @ 6405]
Mark Doliner <markdoliner@pidgin.im>
parents:
5582
diff
changeset
|
3294 | |
|
827dbe4b5bb2
[gaim-migrate @ 6405]
Mark Doliner <markdoliner@pidgin.im>
parents:
5582
diff
changeset
|
3295 | #if GTK_CHECK_VERSION(2,2,0) |
|
9573
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3296 | while (formats) { |
| 5012 | 3297 | GdkPixbufFormat *format = formats->data; |
| 3298 | gchar **extensions = gdk_pixbuf_format_get_extensions(format); | |
| 3299 | gpointer p = extensions; | |
| 3300 | ||
| 3301 | while(gdk_pixbuf_format_is_writable(format) && extensions && extensions[0]){ | |
| 3302 | gchar *fmt_ext = extensions[0]; | |
| 3303 | const gchar* file_ext = filename + strlen(filename) - strlen(fmt_ext); | |
| 3304 | ||
|
17695
5e7fcc2f23cc
Compare the user-entered file extension to the GDK file extension
Mark Doliner <markdoliner@pidgin.im>
parents:
17694
diff
changeset
|
3305 | if(!g_ascii_strcasecmp(fmt_ext, file_ext)){ |
| 5012 | 3306 | type = gdk_pixbuf_format_get_name(format); |
| 3307 | break; | |
| 3308 | } | |
| 3309 | ||
| 3310 | extensions++; | |
| 3311 | } | |
| 3312 | ||
| 3313 | g_strfreev(p); | |
| 3314 | ||
|
9573
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3315 | if (type) |
| 5012 | 3316 | break; |
| 3317 | ||
| 3318 | formats = formats->next; | |
| 3319 | } | |
| 3320 | ||
| 5020 | 3321 | g_slist_free(formats); |
| 3322 | #else | |
| 3323 | /* this is really ugly code, but I think it will work */ | |
|
9573
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3324 | if (ext) { |
| 5020 | 3325 | ext++; |
|
9573
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3326 | if (!g_ascii_strcasecmp(ext, "jpeg") || !g_ascii_strcasecmp(ext, "jpg")) |
| 5020 | 3327 | type = g_strdup("jpeg"); |
|
9573
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3328 | else if (!g_ascii_strcasecmp(ext, "png")) |
| 5020 | 3329 | type = g_strdup("png"); |
| 3330 | } | |
| 3331 | ||
| 3332 | g_free(basename); | |
| 3333 | #endif | |
| 3334 | ||
| 5012 | 3335 | /* If I can't find a valid type, I will just tell the user about it and then assume |
| 3336 | it's a png */ | |
|
9573
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3337 | if (!type){ |
|
17694
d7b54168059b
When right-clicking on an image in a GtkIMHtml to save it, if the file
Mark Doliner <markdoliner@pidgin.im>
parents:
17546
diff
changeset
|
3338 | char *basename, *tmp; |
|
11069
3cc1cdd931e9
[gaim-migrate @ 13065]
Richard Laager <rlaager@pidgin.im>
parents:
11019
diff
changeset
|
3339 | #if GTK_CHECK_VERSION(2,4,0) |
|
11019
6786068b00ab
[gaim-migrate @ 12890]
Richard Laager <rlaager@pidgin.im>
parents:
11006
diff
changeset
|
3340 | GtkWidget *dialog = gtk_message_dialog_new_with_markup(NULL, 0, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, |
|
6786068b00ab
[gaim-migrate @ 12890]
Richard Laager <rlaager@pidgin.im>
parents:
11006
diff
changeset
|
3341 | _("<span size='larger' weight='bold'>Unrecognized file type</span>\n\nDefaulting to PNG.")); |
|
11069
3cc1cdd931e9
[gaim-migrate @ 13065]
Richard Laager <rlaager@pidgin.im>
parents:
11019
diff
changeset
|
3342 | #else |
|
3cc1cdd931e9
[gaim-migrate @ 13065]
Richard Laager <rlaager@pidgin.im>
parents:
11019
diff
changeset
|
3343 | GtkWidget *dialog = gtk_message_dialog_new(NULL, 0, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, |
|
3cc1cdd931e9
[gaim-migrate @ 13065]
Richard Laager <rlaager@pidgin.im>
parents:
11019
diff
changeset
|
3344 | _("Unrecognized file type\n\nDefaulting to PNG.")); |
|
3cc1cdd931e9
[gaim-migrate @ 13065]
Richard Laager <rlaager@pidgin.im>
parents:
11019
diff
changeset
|
3345 | #endif |
|
3cc1cdd931e9
[gaim-migrate @ 13065]
Richard Laager <rlaager@pidgin.im>
parents:
11019
diff
changeset
|
3346 | |
|
11019
6786068b00ab
[gaim-migrate @ 12890]
Richard Laager <rlaager@pidgin.im>
parents:
11006
diff
changeset
|
3347 | g_signal_connect_swapped(dialog, "response", G_CALLBACK (gtk_widget_destroy), dialog); |
|
6786068b00ab
[gaim-migrate @ 12890]
Richard Laager <rlaager@pidgin.im>
parents:
11006
diff
changeset
|
3348 | gtk_widget_show(dialog); |
|
17694
d7b54168059b
When right-clicking on an image in a GtkIMHtml to save it, if the file
Mark Doliner <markdoliner@pidgin.im>
parents:
17546
diff
changeset
|
3349 | |
|
9717
3c8f42ca313e
[gaim-migrate @ 10578]
Mark Doliner <markdoliner@pidgin.im>
parents:
9709
diff
changeset
|
3350 | type = g_strdup("png"); |
|
17694
d7b54168059b
When right-clicking on an image in a GtkIMHtml to save it, if the file
Mark Doliner <markdoliner@pidgin.im>
parents:
17546
diff
changeset
|
3351 | basename = g_path_get_basename(filename); |
|
d7b54168059b
When right-clicking on an image in a GtkIMHtml to save it, if the file
Mark Doliner <markdoliner@pidgin.im>
parents:
17546
diff
changeset
|
3352 | tmp = strrchr(basename, '.'); |
|
d7b54168059b
When right-clicking on an image in a GtkIMHtml to save it, if the file
Mark Doliner <markdoliner@pidgin.im>
parents:
17546
diff
changeset
|
3353 | if (tmp != NULL) |
|
d7b54168059b
When right-clicking on an image in a GtkIMHtml to save it, if the file
Mark Doliner <markdoliner@pidgin.im>
parents:
17546
diff
changeset
|
3354 | tmp[0] = '\0'; |
|
d7b54168059b
When right-clicking on an image in a GtkIMHtml to save it, if the file
Mark Doliner <markdoliner@pidgin.im>
parents:
17546
diff
changeset
|
3355 | newfilename = g_strdup_printf("%s.png", basename); |
|
d7b54168059b
When right-clicking on an image in a GtkIMHtml to save it, if the file
Mark Doliner <markdoliner@pidgin.im>
parents:
17546
diff
changeset
|
3356 | g_free(basename); |
|
d7b54168059b
When right-clicking on an image in a GtkIMHtml to save it, if the file
Mark Doliner <markdoliner@pidgin.im>
parents:
17546
diff
changeset
|
3357 | } else { |
|
d7b54168059b
When right-clicking on an image in a GtkIMHtml to save it, if the file
Mark Doliner <markdoliner@pidgin.im>
parents:
17546
diff
changeset
|
3358 | /* |
|
d7b54168059b
When right-clicking on an image in a GtkIMHtml to save it, if the file
Mark Doliner <markdoliner@pidgin.im>
parents:
17546
diff
changeset
|
3359 | * We're able to save the file in it's original format, so we |
|
d7b54168059b
When right-clicking on an image in a GtkIMHtml to save it, if the file
Mark Doliner <markdoliner@pidgin.im>
parents:
17546
diff
changeset
|
3360 | * can use the original file name. |
|
d7b54168059b
When right-clicking on an image in a GtkIMHtml to save it, if the file
Mark Doliner <markdoliner@pidgin.im>
parents:
17546
diff
changeset
|
3361 | */ |
|
d7b54168059b
When right-clicking on an image in a GtkIMHtml to save it, if the file
Mark Doliner <markdoliner@pidgin.im>
parents:
17546
diff
changeset
|
3362 | newfilename = g_strdup(filename); |
| 5012 | 3363 | } |
| 3364 | ||
|
17694
d7b54168059b
When right-clicking on an image in a GtkIMHtml to save it, if the file
Mark Doliner <markdoliner@pidgin.im>
parents:
17546
diff
changeset
|
3365 | gdk_pixbuf_save(image->pixbuf, newfilename, type, &error, NULL); |
|
d7b54168059b
When right-clicking on an image in a GtkIMHtml to save it, if the file
Mark Doliner <markdoliner@pidgin.im>
parents:
17546
diff
changeset
|
3366 | |
|
d7b54168059b
When right-clicking on an image in a GtkIMHtml to save it, if the file
Mark Doliner <markdoliner@pidgin.im>
parents:
17546
diff
changeset
|
3367 | g_free(newfilename); |
|
d7b54168059b
When right-clicking on an image in a GtkIMHtml to save it, if the file
Mark Doliner <markdoliner@pidgin.im>
parents:
17546
diff
changeset
|
3368 | g_free(type); |
| 5012 | 3369 | |
|
9573
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3370 | if (error){ |
|
11069
3cc1cdd931e9
[gaim-migrate @ 13065]
Richard Laager <rlaager@pidgin.im>
parents:
11019
diff
changeset
|
3371 | #if GTK_CHECK_VERSION(2,4,0) |
|
11019
6786068b00ab
[gaim-migrate @ 12890]
Richard Laager <rlaager@pidgin.im>
parents:
11006
diff
changeset
|
3372 | GtkWidget *dialog = gtk_message_dialog_new_with_markup(NULL, 0, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, |
|
6786068b00ab
[gaim-migrate @ 12890]
Richard Laager <rlaager@pidgin.im>
parents:
11006
diff
changeset
|
3373 | _("<span size='larger' weight='bold'>Error saving image</span>\n\n%s"), error->message); |
|
11069
3cc1cdd931e9
[gaim-migrate @ 13065]
Richard Laager <rlaager@pidgin.im>
parents:
11019
diff
changeset
|
3374 | #else |
|
3cc1cdd931e9
[gaim-migrate @ 13065]
Richard Laager <rlaager@pidgin.im>
parents:
11019
diff
changeset
|
3375 | GtkWidget *dialog = gtk_message_dialog_new(NULL, 0, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, |
|
3cc1cdd931e9
[gaim-migrate @ 13065]
Richard Laager <rlaager@pidgin.im>
parents:
11019
diff
changeset
|
3376 | _("Error saving image\n\n%s"), error->message); |
|
3cc1cdd931e9
[gaim-migrate @ 13065]
Richard Laager <rlaager@pidgin.im>
parents:
11019
diff
changeset
|
3377 | #endif |
|
11019
6786068b00ab
[gaim-migrate @ 12890]
Richard Laager <rlaager@pidgin.im>
parents:
11006
diff
changeset
|
3378 | g_signal_connect_swapped(dialog, "response", G_CALLBACK (gtk_widget_destroy), dialog); |
|
6786068b00ab
[gaim-migrate @ 12890]
Richard Laager <rlaager@pidgin.im>
parents:
11006
diff
changeset
|
3379 | gtk_widget_show(dialog); |
| 5012 | 3380 | g_error_free(error); |
| 3381 | } | |
| 3382 | } | |
| 3383 | ||
|
9573
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3384 | #if GTK_CHECK_VERSION(2,4,0) /* FILECHOOSER */ |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3385 | static void |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3386 | image_save_check_if_exists_cb(GtkWidget *widget, gint response, GtkIMHtmlImage *image) |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3387 | { |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3388 | gchar *filename; |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3389 | |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3390 | if (response != GTK_RESPONSE_ACCEPT) { |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3391 | gtk_widget_destroy(widget); |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3392 | image->filesel = NULL; |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3393 | return; |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3394 | } |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3395 | |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3396 | filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(widget)); |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3397 | #else /* FILECHOOSER */ |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3398 | static void |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3399 | image_save_check_if_exists_cb(GtkWidget *button, GtkIMHtmlImage *image) |
| 5012 | 3400 | { |
|
9573
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3401 | gchar *filename; |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3402 | |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3403 | filename = g_strdup(gtk_file_selection_get_filename(GTK_FILE_SELECTION(image->filesel))); |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3404 | |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3405 | if (g_file_test(filename, G_FILE_TEST_IS_DIR)) { |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3406 | gchar *dirname; |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3407 | /* append a / is needed */ |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3408 | if (filename[strlen(filename) - 1] != G_DIR_SEPARATOR) { |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3409 | dirname = g_strconcat(filename, G_DIR_SEPARATOR_S, NULL); |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3410 | } else { |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3411 | dirname = g_strdup(filename); |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3412 | } |
|
9574
d5a2c770adcd
[gaim-migrate @ 10417]
Mark Doliner <markdoliner@pidgin.im>
parents:
9573
diff
changeset
|
3413 | gtk_file_selection_set_filename(GTK_FILE_SELECTION(image->filesel), dirname); |
|
9573
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3414 | g_free(dirname); |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3415 | g_free(filename); |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3416 | return; |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3417 | } |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3418 | #endif /* FILECHOOSER */ |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3419 | |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3420 | /* |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3421 | * XXX - We should probably prompt the user to determine if they really |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3422 | * want to overwrite the file or not. However, I don't feel like doing |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3423 | * that, so we're just always going to overwrite if the file exists. |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3424 | */ |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3425 | /* |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3426 | if (g_file_test(filename, G_FILE_TEST_EXISTS)) { |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3427 | } else |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3428 | image_save_yes_cb(image, filename); |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3429 | */ |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3430 | |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3431 | image_save_yes_cb(image, filename); |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3432 | |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3433 | g_free(filename); |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3434 | } |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3435 | |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3436 | #if !GTK_CHECK_VERSION(2,4,0) /* FILECHOOSER */ |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3437 | static void |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3438 | image_save_cancel_cb(GtkIMHtmlImage *image) |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3439 | { |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3440 | gtk_widget_destroy(image->filesel); |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3441 | image->filesel = NULL; |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3442 | } |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3443 | #endif /* FILECHOOSER */ |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3444 | |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3445 | static void |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3446 | gtk_imhtml_image_save(GtkWidget *w, GtkIMHtmlImage *image) |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3447 | { |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3448 | if (image->filesel != NULL) { |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3449 | gtk_window_present(GTK_WINDOW(image->filesel)); |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3450 | return; |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3451 | } |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3452 | |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3453 | #if GTK_CHECK_VERSION(2,4,0) /* FILECHOOSER */ |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3454 | image->filesel = gtk_file_chooser_dialog_new(_("Save Image"), |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3455 | NULL, |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3456 | GTK_FILE_CHOOSER_ACTION_SAVE, |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3457 | GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3458 | GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT, |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3459 | NULL); |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3460 | gtk_dialog_set_default_response(GTK_DIALOG(image->filesel), GTK_RESPONSE_ACCEPT); |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3461 | if (image->filename != NULL) |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3462 | gtk_file_chooser_set_current_name(GTK_FILE_CHOOSER(image->filesel), image->filename); |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3463 | g_signal_connect(G_OBJECT(GTK_FILE_CHOOSER(image->filesel)), "response", |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3464 | G_CALLBACK(image_save_check_if_exists_cb), image); |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3465 | #else /* FILECHOOSER */ |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3466 | image->filesel = gtk_file_selection_new(_("Save Image")); |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3467 | if (image->filename != NULL) |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3468 | gtk_file_selection_set_filename(GTK_FILE_SELECTION(image->filesel), image->filename); |
|
9574
d5a2c770adcd
[gaim-migrate @ 10417]
Mark Doliner <markdoliner@pidgin.im>
parents:
9573
diff
changeset
|
3469 | g_signal_connect_swapped(G_OBJECT(GTK_FILE_SELECTION(image->filesel)), "delete_event", |
|
d5a2c770adcd
[gaim-migrate @ 10417]
Mark Doliner <markdoliner@pidgin.im>
parents:
9573
diff
changeset
|
3470 | G_CALLBACK(image_save_cancel_cb), image); |
|
d5a2c770adcd
[gaim-migrate @ 10417]
Mark Doliner <markdoliner@pidgin.im>
parents:
9573
diff
changeset
|
3471 | g_signal_connect_swapped(G_OBJECT(GTK_FILE_SELECTION(image->filesel)->cancel_button), |
|
d5a2c770adcd
[gaim-migrate @ 10417]
Mark Doliner <markdoliner@pidgin.im>
parents:
9573
diff
changeset
|
3472 | "clicked", G_CALLBACK(image_save_cancel_cb), image); |
|
9573
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3473 | g_signal_connect(G_OBJECT(GTK_FILE_SELECTION(image->filesel)->ok_button), "clicked", |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3474 | G_CALLBACK(image_save_check_if_exists_cb), image); |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3475 | #endif /* FILECHOOSER */ |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3476 | |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3477 | gtk_widget_show(image->filesel); |
| 5012 | 3478 | } |
| 3479 | ||
|
9815
fcbbbce0e1ff
[gaim-migrate @ 10686]
Mark Doliner <markdoliner@pidgin.im>
parents:
9726
diff
changeset
|
3480 | /* |
|
fcbbbce0e1ff
[gaim-migrate @ 10686]
Mark Doliner <markdoliner@pidgin.im>
parents:
9726
diff
changeset
|
3481 | * So, um, AIM Direct IM lets you send any file, not just images. You can |
|
fcbbbce0e1ff
[gaim-migrate @ 10686]
Mark Doliner <markdoliner@pidgin.im>
parents:
9726
diff
changeset
|
3482 | * just insert a sound or a file or whatever in a conversation. It's |
|
fcbbbce0e1ff
[gaim-migrate @ 10686]
Mark Doliner <markdoliner@pidgin.im>
parents:
9726
diff
changeset
|
3483 | * basically like file transfer, except there is an icon to open the file |
| 15884 | 3484 | * embedded in the conversation. Someone should make the Purple core handle |
|
9815
fcbbbce0e1ff
[gaim-migrate @ 10686]
Mark Doliner <markdoliner@pidgin.im>
parents:
9726
diff
changeset
|
3485 | * all of that. |
|
fcbbbce0e1ff
[gaim-migrate @ 10686]
Mark Doliner <markdoliner@pidgin.im>
parents:
9726
diff
changeset
|
3486 | */ |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
3487 | static gboolean gtk_imhtml_image_clicked(GtkWidget *w, GdkEvent *event, GtkIMHtmlImage *image) |
| 5012 | 3488 | { |
| 3489 | GdkEventButton *event_button = (GdkEventButton *) event; | |
| 3490 | ||
| 3491 | if (event->type == GDK_BUTTON_RELEASE) { | |
| 3492 | if(event_button->button == 3) { | |
| 3493 | GtkWidget *img, *item, *menu; | |
| 3494 | gchar *text = g_strdup_printf(_("_Save Image...")); | |
| 3495 | menu = gtk_menu_new(); | |
| 3496 | ||
| 3497 | /* buttons and such */ | |
| 3498 | img = gtk_image_new_from_stock(GTK_STOCK_SAVE, GTK_ICON_SIZE_MENU); | |
| 3499 | item = gtk_image_menu_item_new_with_mnemonic(text); | |
| 3500 | gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(item), img); | |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
3501 | g_signal_connect(G_OBJECT(item), "activate", G_CALLBACK(gtk_imhtml_image_save), image); |
| 5012 | 3502 | gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); |
| 3503 | ||
| 3504 | gtk_widget_show_all(menu); | |
| 3505 | gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL, | |
| 3506 | event_button->button, event_button->time); | |
| 3507 | ||
| 3508 | g_free(text); | |
| 3509 | return TRUE; | |
| 3510 | } | |
| 3511 | } | |
| 3512 | if(event->type == GDK_BUTTON_PRESS && event_button->button == 3) | |
| 3513 | return TRUE; /* Clicking the right mouse button on a link shouldn't | |
| 3514 | be caught by the regular GtkTextView menu */ | |
| 3515 | else | |
| 3516 | return FALSE; /* Let clicks go through if we didn't catch anything */ | |
| 3517 | ||
| 3518 | } | |
|
17009
2cc9edf33feb
Allow saving custom smileys by right-clicking on them. And use the custom smileys only on the received messages, not for the system/etc. messages.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16385
diff
changeset
|
3519 | |
|
2cc9edf33feb
Allow saving custom smileys by right-clicking on them. And use the custom smileys only on the received messages, not for the system/etc. messages.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16385
diff
changeset
|
3520 | static gboolean gtk_imhtml_smiley_clicked(GtkWidget *w, GdkEvent *event, GtkIMHtmlSmiley *smiley) |
|
2cc9edf33feb
Allow saving custom smileys by right-clicking on them. And use the custom smileys only on the received messages, not for the system/etc. messages.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16385
diff
changeset
|
3521 | { |
|
2cc9edf33feb
Allow saving custom smileys by right-clicking on them. And use the custom smileys only on the received messages, not for the system/etc. messages.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16385
diff
changeset
|
3522 | GdkPixbufAnimation *anim = NULL; |
|
2cc9edf33feb
Allow saving custom smileys by right-clicking on them. And use the custom smileys only on the received messages, not for the system/etc. messages.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16385
diff
changeset
|
3523 | GtkIMHtmlScalable *image = NULL; |
|
2cc9edf33feb
Allow saving custom smileys by right-clicking on them. And use the custom smileys only on the received messages, not for the system/etc. messages.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16385
diff
changeset
|
3524 | gboolean ret; |
|
2cc9edf33feb
Allow saving custom smileys by right-clicking on them. And use the custom smileys only on the received messages, not for the system/etc. messages.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16385
diff
changeset
|
3525 | |
|
2cc9edf33feb
Allow saving custom smileys by right-clicking on them. And use the custom smileys only on the received messages, not for the system/etc. messages.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16385
diff
changeset
|
3526 | if (event->type != GDK_BUTTON_RELEASE || ((GdkEventButton*)event)->button != 3) |
|
2cc9edf33feb
Allow saving custom smileys by right-clicking on them. And use the custom smileys only on the received messages, not for the system/etc. messages.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16385
diff
changeset
|
3527 | return FALSE; |
|
2cc9edf33feb
Allow saving custom smileys by right-clicking on them. And use the custom smileys only on the received messages, not for the system/etc. messages.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16385
diff
changeset
|
3528 | |
|
2cc9edf33feb
Allow saving custom smileys by right-clicking on them. And use the custom smileys only on the received messages, not for the system/etc. messages.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16385
diff
changeset
|
3529 | anim = gtk_smiley_get_image(smiley); |
|
2cc9edf33feb
Allow saving custom smileys by right-clicking on them. And use the custom smileys only on the received messages, not for the system/etc. messages.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16385
diff
changeset
|
3530 | if (!anim) |
|
2cc9edf33feb
Allow saving custom smileys by right-clicking on them. And use the custom smileys only on the received messages, not for the system/etc. messages.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16385
diff
changeset
|
3531 | return FALSE; |
|
2cc9edf33feb
Allow saving custom smileys by right-clicking on them. And use the custom smileys only on the received messages, not for the system/etc. messages.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16385
diff
changeset
|
3532 | |
|
18151
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
3533 | image = gtk_imhtml_animation_new(anim, smiley->smile, 0); |
|
17009
2cc9edf33feb
Allow saving custom smileys by right-clicking on them. And use the custom smileys only on the received messages, not for the system/etc. messages.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16385
diff
changeset
|
3534 | ret = gtk_imhtml_image_clicked(w, event, (GtkIMHtmlImage*)image); |
|
2cc9edf33feb
Allow saving custom smileys by right-clicking on them. And use the custom smileys only on the received messages, not for the system/etc. messages.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16385
diff
changeset
|
3535 | g_object_set_data_full(G_OBJECT(w), "image-data", image, (GDestroyNotify)gtk_imhtml_image_free); |
|
2cc9edf33feb
Allow saving custom smileys by right-clicking on them. And use the custom smileys only on the received messages, not for the system/etc. messages.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16385
diff
changeset
|
3536 | return ret; |
|
2cc9edf33feb
Allow saving custom smileys by right-clicking on them. And use the custom smileys only on the received messages, not for the system/etc. messages.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16385
diff
changeset
|
3537 | } |
|
2cc9edf33feb
Allow saving custom smileys by right-clicking on them. And use the custom smileys only on the received messages, not for the system/etc. messages.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16385
diff
changeset
|
3538 | |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
3539 | void gtk_imhtml_image_free(GtkIMHtmlScalable *scale) |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
3540 | { |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
3541 | GtkIMHtmlImage *image = (GtkIMHtmlImage *)scale; |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
3542 | |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
3543 | g_object_unref(image->pixbuf); |
|
14097
0c340861ab79
[gaim-migrate @ 16638]
Mark Doliner <markdoliner@pidgin.im>
parents:
14010
diff
changeset
|
3544 | g_free(image->filename); |
|
9573
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3545 | if (image->filesel) |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3546 | gtk_widget_destroy(image->filesel); |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
3547 | g_free(scale); |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
3548 | } |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
3549 | |
|
18151
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
3550 | void gtk_imhtml_animation_free(GtkIMHtmlScalable *scale) |
|
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
3551 | { |
|
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
3552 | GtkIMHtmlAnimation *animation = (GtkIMHtmlAnimation *)scale; |
|
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
3553 | |
|
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
3554 | if (animation->timer > 0) |
|
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
3555 | g_source_remove(animation->timer); |
|
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
3556 | if (animation->iter != NULL) |
|
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
3557 | g_object_unref(animation->iter); |
|
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
3558 | g_object_unref(animation->anim); |
|
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
3559 | |
|
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
3560 | gtk_imhtml_image_free(scale); |
|
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
3561 | } |
|
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
3562 | |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
3563 | void gtk_imhtml_image_add_to(GtkIMHtmlScalable *scale, GtkIMHtml *imhtml, GtkTextIter *iter) |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
3564 | { |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
3565 | GtkIMHtmlImage *image = (GtkIMHtmlImage *)scale; |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
3566 | GtkWidget *box = gtk_event_box_new(); |
| 8962 | 3567 | char *tag; |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
3568 | GtkTextChildAnchor *anchor = gtk_text_buffer_create_child_anchor(imhtml->text_buffer, iter); |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
3569 | |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
3570 | gtk_container_add(GTK_CONTAINER(box), GTK_WIDGET(image->image)); |
| 9229 | 3571 | |
| 3572 | if(!gtk_check_version(2, 4, 0)) | |
| 3573 | g_object_set(G_OBJECT(box), "visible-window", FALSE, NULL); | |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
3574 | |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
3575 | gtk_widget_show(GTK_WIDGET(image->image)); |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
3576 | gtk_widget_show(box); |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
3577 | |
| 8962 | 3578 | tag = g_strdup_printf("<IMG ID=\"%d\">", image->id); |
| 3579 | g_object_set_data_full(G_OBJECT(anchor), "gtkimhtml_htmltext", tag, g_free); | |
| 3580 | g_object_set_data(G_OBJECT(anchor), "gtkimhtml_plaintext", "[Image]"); | |
| 3581 | ||
| 15420 | 3582 | gtk_text_view_add_child_at_anchor(GTK_TEXT_VIEW(imhtml), box, anchor); |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
3583 | g_signal_connect(G_OBJECT(box), "event", G_CALLBACK(gtk_imhtml_image_clicked), image); |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
3584 | } |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
3585 | |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
3586 | GtkIMHtmlScalable *gtk_imhtml_hr_new() |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
3587 | { |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
3588 | GtkIMHtmlHr *hr = g_malloc(sizeof(GtkIMHtmlHr)); |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
3589 | |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
3590 | GTK_IMHTML_SCALABLE(hr)->scale = gtk_imhtml_hr_scale; |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
3591 | GTK_IMHTML_SCALABLE(hr)->add_to = gtk_imhtml_hr_add_to; |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
3592 | GTK_IMHTML_SCALABLE(hr)->free = gtk_imhtml_hr_free; |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
3593 | |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
3594 | hr->sep = gtk_hseparator_new(); |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
3595 | gtk_widget_set_size_request(hr->sep, 5000, 2); |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
3596 | gtk_widget_show(hr->sep); |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
3597 | |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
3598 | return GTK_IMHTML_SCALABLE(hr); |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
3599 | } |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
3600 | |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
3601 | void gtk_imhtml_hr_scale(GtkIMHtmlScalable *scale, int width, int height) |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
3602 | { |
|
8588
6bcf7ed80ed8
[gaim-migrate @ 9339]
Mark Doliner <markdoliner@pidgin.im>
parents:
8568
diff
changeset
|
3603 | gtk_widget_set_size_request(((GtkIMHtmlHr *)scale)->sep, width - 2, 2); |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
3604 | } |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
3605 | |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
3606 | void gtk_imhtml_hr_add_to(GtkIMHtmlScalable *scale, GtkIMHtml *imhtml, GtkTextIter *iter) |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
3607 | { |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
3608 | GtkIMHtmlHr *hr = (GtkIMHtmlHr *)scale; |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
3609 | GtkTextChildAnchor *anchor = gtk_text_buffer_create_child_anchor(imhtml->text_buffer, iter); |
| 8698 | 3610 | g_object_set_data(G_OBJECT(anchor), "gtkimhtml_htmltext", "<hr>"); |
| 3611 | g_object_set_data(G_OBJECT(anchor), "gtkimhtml_plaintext", "\n---\n"); | |
| 15420 | 3612 | gtk_text_view_add_child_at_anchor(GTK_TEXT_VIEW(imhtml), hr->sep, anchor); |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
3613 | } |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
3614 | |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
3615 | void gtk_imhtml_hr_free(GtkIMHtmlScalable *scale) |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
3616 | { |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
3617 | g_free(scale); |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
3618 | } |
| 7295 | 3619 | |
| 3620 | gboolean gtk_imhtml_search_find(GtkIMHtml *imhtml, const gchar *text) | |
| 3621 | { | |
| 3622 | GtkTextIter iter, start, end; | |
| 3623 | gboolean new_search = TRUE; | |
|
14863
82888d51234c
[gaim-migrate @ 17566]
Daniel Atallah <datallah@pidgin.im>
parents:
14821
diff
changeset
|
3624 | GtkTextMark *start_mark; |
| 7295 | 3625 | |
| 3626 | g_return_val_if_fail(imhtml != NULL, FALSE); | |
| 3627 | g_return_val_if_fail(text != NULL, FALSE); | |
| 8061 | 3628 | |
|
14863
82888d51234c
[gaim-migrate @ 17566]
Daniel Atallah <datallah@pidgin.im>
parents:
14821
diff
changeset
|
3629 | start_mark = gtk_text_buffer_get_mark(imhtml->text_buffer, "search"); |
|
82888d51234c
[gaim-migrate @ 17566]
Daniel Atallah <datallah@pidgin.im>
parents:
14821
diff
changeset
|
3630 | |
|
82888d51234c
[gaim-migrate @ 17566]
Daniel Atallah <datallah@pidgin.im>
parents:
14821
diff
changeset
|
3631 | if (start_mark && imhtml->search_string && !strcmp(text, imhtml->search_string)) |
| 7295 | 3632 | new_search = FALSE; |
| 8061 | 3633 | |
| 7295 | 3634 | if (new_search) { |
| 3635 | gtk_imhtml_search_clear(imhtml); | |
|
14863
82888d51234c
[gaim-migrate @ 17566]
Daniel Atallah <datallah@pidgin.im>
parents:
14821
diff
changeset
|
3636 | g_free(imhtml->search_string); |
|
82888d51234c
[gaim-migrate @ 17566]
Daniel Atallah <datallah@pidgin.im>
parents:
14821
diff
changeset
|
3637 | imhtml->search_string = g_strdup(text); |
| 15093 | 3638 | gtk_text_buffer_get_end_iter(imhtml->text_buffer, &iter); |
| 7295 | 3639 | } else { |
| 3640 | gtk_text_buffer_get_iter_at_mark(imhtml->text_buffer, &iter, | |
|
14863
82888d51234c
[gaim-migrate @ 17566]
Daniel Atallah <datallah@pidgin.im>
parents:
14821
diff
changeset
|
3641 | start_mark); |
| 7295 | 3642 | } |
| 3643 | ||
| 15093 | 3644 | if (gtk_source_iter_backward_search(&iter, imhtml->search_string, |
|
14400
953baf2eba1a
[gaim-migrate @ 17035]
Richard Laager <rlaager@pidgin.im>
parents:
14395
diff
changeset
|
3645 | GTK_SOURCE_SEARCH_VISIBLE_ONLY | GTK_SOURCE_SEARCH_CASE_INSENSITIVE, |
|
953baf2eba1a
[gaim-migrate @ 17035]
Richard Laager <rlaager@pidgin.im>
parents:
14395
diff
changeset
|
3646 | &start, &end, NULL)) |
|
953baf2eba1a
[gaim-migrate @ 17035]
Richard Laager <rlaager@pidgin.im>
parents:
14395
diff
changeset
|
3647 | { |
| 7295 | 3648 | gtk_text_view_scroll_to_iter(GTK_TEXT_VIEW(imhtml), &start, 0, TRUE, 0, 0); |
| 15093 | 3649 | gtk_text_buffer_create_mark(imhtml->text_buffer, "search", &start, FALSE); |
|
14400
953baf2eba1a
[gaim-migrate @ 17035]
Richard Laager <rlaager@pidgin.im>
parents:
14395
diff
changeset
|
3650 | if (new_search) |
|
953baf2eba1a
[gaim-migrate @ 17035]
Richard Laager <rlaager@pidgin.im>
parents:
14395
diff
changeset
|
3651 | { |
| 7295 | 3652 | gtk_text_buffer_remove_tag_by_name(imhtml->text_buffer, "search", &iter, &end); |
| 8061 | 3653 | do |
| 7295 | 3654 | gtk_text_buffer_apply_tag_by_name(imhtml->text_buffer, "search", &start, &end); |
| 15093 | 3655 | while (gtk_source_iter_backward_search(&start, imhtml->search_string, |
| 8061 | 3656 | GTK_SOURCE_SEARCH_VISIBLE_ONLY | |
| 7358 | 3657 | GTK_SOURCE_SEARCH_CASE_INSENSITIVE, |
| 7295 | 3658 | &start, &end, NULL)); |
| 3659 | } | |
| 3660 | return TRUE; | |
| 3661 | } | |
|
14400
953baf2eba1a
[gaim-migrate @ 17035]
Richard Laager <rlaager@pidgin.im>
parents:
14395
diff
changeset
|
3662 | else if (!new_search) |
|
953baf2eba1a
[gaim-migrate @ 17035]
Richard Laager <rlaager@pidgin.im>
parents:
14395
diff
changeset
|
3663 | { |
|
953baf2eba1a
[gaim-migrate @ 17035]
Richard Laager <rlaager@pidgin.im>
parents:
14395
diff
changeset
|
3664 | /* We hit the end, so start at the beginning again. */ |
| 15093 | 3665 | gtk_text_buffer_get_end_iter(imhtml->text_buffer, &iter); |
| 3666 | ||
| 3667 | if (gtk_source_iter_backward_search(&iter, imhtml->search_string, | |
|
14400
953baf2eba1a
[gaim-migrate @ 17035]
Richard Laager <rlaager@pidgin.im>
parents:
14395
diff
changeset
|
3668 | GTK_SOURCE_SEARCH_VISIBLE_ONLY | GTK_SOURCE_SEARCH_CASE_INSENSITIVE, |
|
953baf2eba1a
[gaim-migrate @ 17035]
Richard Laager <rlaager@pidgin.im>
parents:
14395
diff
changeset
|
3669 | &start, &end, NULL)) |
|
953baf2eba1a
[gaim-migrate @ 17035]
Richard Laager <rlaager@pidgin.im>
parents:
14395
diff
changeset
|
3670 | { |
|
953baf2eba1a
[gaim-migrate @ 17035]
Richard Laager <rlaager@pidgin.im>
parents:
14395
diff
changeset
|
3671 | gtk_text_view_scroll_to_iter(GTK_TEXT_VIEW(imhtml), &start, 0, TRUE, 0, 0); |
| 15093 | 3672 | gtk_text_buffer_create_mark(imhtml->text_buffer, "search", &start, FALSE); |
|
14400
953baf2eba1a
[gaim-migrate @ 17035]
Richard Laager <rlaager@pidgin.im>
parents:
14395
diff
changeset
|
3673 | |
|
953baf2eba1a
[gaim-migrate @ 17035]
Richard Laager <rlaager@pidgin.im>
parents:
14395
diff
changeset
|
3674 | return TRUE; |
|
953baf2eba1a
[gaim-migrate @ 17035]
Richard Laager <rlaager@pidgin.im>
parents:
14395
diff
changeset
|
3675 | } |
|
953baf2eba1a
[gaim-migrate @ 17035]
Richard Laager <rlaager@pidgin.im>
parents:
14395
diff
changeset
|
3676 | |
|
953baf2eba1a
[gaim-migrate @ 17035]
Richard Laager <rlaager@pidgin.im>
parents:
14395
diff
changeset
|
3677 | } |
| 8061 | 3678 | |
| 7295 | 3679 | return FALSE; |
| 3680 | } | |
| 3681 | ||
| 3682 | void gtk_imhtml_search_clear(GtkIMHtml *imhtml) | |
| 3683 | { | |
| 3684 | GtkTextIter start, end; | |
| 8061 | 3685 | |
| 7295 | 3686 | g_return_if_fail(imhtml != NULL); |
| 8061 | 3687 | |
| 7295 | 3688 | gtk_text_buffer_get_start_iter(imhtml->text_buffer, &start); |
| 3689 | gtk_text_buffer_get_end_iter(imhtml->text_buffer, &end); | |
| 3690 | ||
| 3691 | gtk_text_buffer_remove_tag_by_name(imhtml->text_buffer, "search", &start, &end); | |
|
14097
0c340861ab79
[gaim-migrate @ 16638]
Mark Doliner <markdoliner@pidgin.im>
parents:
14010
diff
changeset
|
3692 | g_free(imhtml->search_string); |
| 7295 | 3693 | imhtml->search_string = NULL; |
| 3694 | } | |
| 8061 | 3695 | |
| 8677 | 3696 | static GtkTextTag *find_font_forecolor_tag(GtkIMHtml *imhtml, gchar *color) |
| 3697 | { | |
| 3698 | gchar str[18]; | |
| 3699 | GtkTextTag *tag; | |
| 3700 | ||
| 3701 | g_snprintf(str, sizeof(str), "FORECOLOR %s", color); | |
| 3702 | ||
| 3703 | tag = gtk_text_tag_table_lookup(gtk_text_buffer_get_tag_table(imhtml->text_buffer), str); | |
| 10858 | 3704 | if (!tag) { |
| 3705 | GdkColor gcolor; | |
| 3706 | if (!gdk_color_parse(color, &gcolor)) { | |
| 3707 | gchar tmp[8]; | |
| 3708 | tmp[0] = '#'; | |
| 3709 | strncpy(&tmp[1], color, 7); | |
| 3710 | tmp[7] = '\0'; | |
| 3711 | if (!gdk_color_parse(tmp, &gcolor)) | |
| 3712 | gdk_color_parse("black", &gcolor); | |
| 3713 | } | |
| 3714 | tag = gtk_text_buffer_create_tag(imhtml->text_buffer, str, "foreground-gdk", &gcolor, NULL); | |
| 3715 | } | |
| 8677 | 3716 | |
| 3717 | return tag; | |
| 3718 | } | |
| 3719 | ||
| 3720 | static GtkTextTag *find_font_backcolor_tag(GtkIMHtml *imhtml, gchar *color) | |
| 3721 | { | |
| 3722 | gchar str[18]; | |
| 3723 | GtkTextTag *tag; | |
| 3724 | ||
| 3725 | g_snprintf(str, sizeof(str), "BACKCOLOR %s", color); | |
| 3726 | ||
| 3727 | tag = gtk_text_tag_table_lookup(gtk_text_buffer_get_tag_table(imhtml->text_buffer), str); | |
| 10858 | 3728 | if (!tag) { |
| 3729 | GdkColor gcolor; | |
| 3730 | if (!gdk_color_parse(color, &gcolor)) { | |
| 3731 | gchar tmp[8]; | |
| 3732 | tmp[0] = '#'; | |
| 3733 | strncpy(&tmp[1], color, 7); | |
| 3734 | tmp[7] = '\0'; | |
| 3735 | if (!gdk_color_parse(tmp, &gcolor)) | |
| 3736 | gdk_color_parse("white", &gcolor); | |
| 3737 | } | |
| 3738 | tag = gtk_text_buffer_create_tag(imhtml->text_buffer, str, "background-gdk", &gcolor, NULL); | |
| 3739 | } | |
| 8677 | 3740 | |
| 3741 | return tag; | |
| 3742 | } | |
| 3743 | ||
| 10776 | 3744 | static GtkTextTag *find_font_background_tag(GtkIMHtml *imhtml, gchar *color) |
| 3745 | { | |
| 3746 | gchar str[19]; | |
| 3747 | GtkTextTag *tag; | |
| 3748 | ||
| 3749 | g_snprintf(str, sizeof(str), "BACKGROUND %s", color); | |
| 3750 | ||
| 3751 | tag = gtk_text_tag_table_lookup(gtk_text_buffer_get_tag_table(imhtml->text_buffer), str); | |
| 3752 | if (!tag) | |
| 3753 | tag = gtk_text_buffer_create_tag(imhtml->text_buffer, str, NULL); | |
| 3754 | ||
| 3755 | return tag; | |
| 3756 | } | |
| 3757 | ||
| 8677 | 3758 | static GtkTextTag *find_font_face_tag(GtkIMHtml *imhtml, gchar *face) |
| 8061 | 3759 | { |
| 8677 | 3760 | gchar str[256]; |
| 3761 | GtkTextTag *tag; | |
| 3762 | ||
| 3763 | g_snprintf(str, sizeof(str), "FONT FACE %s", face); | |
| 3764 | str[255] = '\0'; | |
| 3765 | ||
| 3766 | tag = gtk_text_tag_table_lookup(gtk_text_buffer_get_tag_table(imhtml->text_buffer), str); | |
| 3767 | if (!tag) | |
| 3768 | tag = gtk_text_buffer_create_tag(imhtml->text_buffer, str, "family", face, NULL); | |
| 3769 | ||
| 3770 | return tag; | |
| 3771 | } | |
| 3772 | ||
| 3773 | static GtkTextTag *find_font_size_tag(GtkIMHtml *imhtml, int size) | |
| 3774 | { | |
| 3775 | gchar str[24]; | |
| 3776 | GtkTextTag *tag; | |
| 3777 | ||
| 3778 | g_snprintf(str, sizeof(str), "FONT SIZE %d", size); | |
| 3779 | str[23] = '\0'; | |
| 3780 | ||
| 3781 | tag = gtk_text_tag_table_lookup(gtk_text_buffer_get_tag_table(imhtml->text_buffer), str); | |
| 3782 | if (!tag) { | |
| 10525 | 3783 | /* For reasons I don't understand, setting "scale" here scaled |
| 3784 | * based on some default size other than my theme's default | |
| 3785 | * size. Our size 4 was actually smaller than our size 3 for | |
| 3786 | * me. So this works around that oddity. | |
| 8677 | 3787 | */ |
| 10525 | 3788 | GtkTextAttributes *attr = gtk_text_view_get_default_attributes(GTK_TEXT_VIEW(imhtml)); |
| 8677 | 3789 | tag = gtk_text_buffer_create_tag(imhtml->text_buffer, str, "size", |
| 10525 | 3790 | (gint) (pango_font_description_get_size(attr->font) * |
|
10899
87d9aec5b72d
[gaim-migrate @ 12619]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10871
diff
changeset
|
3791 | (double) POINT_SIZE(size)), NULL); |
| 10525 | 3792 | gtk_text_attributes_unref(attr); |
| 8061 | 3793 | } |
| 3794 | ||
| 8677 | 3795 | return tag; |
| 3796 | } | |
| 3797 | ||
| 3798 | static void remove_tag_by_prefix(GtkIMHtml *imhtml, const GtkTextIter *i, const GtkTextIter *e, | |
| 3799 | const char *prefix, guint len, gboolean homo) | |
| 3800 | { | |
| 3801 | GSList *tags, *l; | |
| 3802 | GtkTextIter iter; | |
| 3803 | ||
| 3804 | tags = gtk_text_iter_get_tags(i); | |
| 3805 | ||
| 3806 | for (l = tags; l; l = l->next) { | |
| 3807 | GtkTextTag *tag = l->data; | |
| 3808 | ||
| 3809 | if (tag->name && !strncmp(tag->name, prefix, len)) | |
| 3810 | gtk_text_buffer_remove_tag(imhtml->text_buffer, tag, i, e); | |
| 8061 | 3811 | } |
| 3812 | ||
| 8677 | 3813 | g_slist_free(tags); |
| 3814 | ||
| 3815 | if (homo) | |
| 3816 | return; | |
| 3817 | ||
| 3818 | iter = *i; | |
| 3819 | ||
| 3820 | while (gtk_text_iter_forward_char(&iter) && !gtk_text_iter_equal(&iter, e)) { | |
| 3821 | if (gtk_text_iter_begins_tag(&iter, NULL)) { | |
| 3822 | tags = gtk_text_iter_get_toggled_tags(&iter, TRUE); | |
| 3823 | ||
| 3824 | for (l = tags; l; l = l->next) { | |
| 3825 | GtkTextTag *tag = l->data; | |
| 3826 | ||
| 3827 | if (tag->name && !strncmp(tag->name, prefix, len)) | |
| 3828 | gtk_text_buffer_remove_tag(imhtml->text_buffer, tag, &iter, e); | |
| 3829 | } | |
| 3830 | ||
| 3831 | g_slist_free(tags); | |
| 3832 | } | |
| 8061 | 3833 | } |
| 8677 | 3834 | } |
| 3835 | ||
| 3836 | static void remove_font_size(GtkIMHtml *imhtml, GtkTextIter *i, GtkTextIter *e, gboolean homo) | |
| 3837 | { | |
| 3838 | remove_tag_by_prefix(imhtml, i, e, "FONT SIZE ", 10, homo); | |
| 3839 | } | |
| 3840 | ||
| 3841 | static void remove_font_face(GtkIMHtml *imhtml, GtkTextIter *i, GtkTextIter *e, gboolean homo) | |
| 3842 | { | |
| 3843 | remove_tag_by_prefix(imhtml, i, e, "FONT FACE ", 10, homo); | |
| 3844 | } | |
| 3845 | ||
| 3846 | static void remove_font_forecolor(GtkIMHtml *imhtml, GtkTextIter *i, GtkTextIter *e, gboolean homo) | |
| 3847 | { | |
| 3848 | remove_tag_by_prefix(imhtml, i, e, "FORECOLOR ", 10, homo); | |
| 3849 | } | |
| 3850 | ||
| 3851 | static void remove_font_backcolor(GtkIMHtml *imhtml, GtkTextIter *i, GtkTextIter *e, gboolean homo) | |
| 3852 | { | |
| 3853 | remove_tag_by_prefix(imhtml, i, e, "BACKCOLOR ", 10, homo); | |
| 3854 | } | |
| 3855 | ||
| 10776 | 3856 | static void remove_font_background(GtkIMHtml *imhtml, GtkTextIter *i, GtkTextIter *e, gboolean homo) |
| 3857 | { | |
| 3858 | remove_tag_by_prefix(imhtml, i, e, "BACKGROUND ", 10, homo); | |
| 3859 | } | |
| 3860 | ||
| 8677 | 3861 | static void remove_font_link(GtkIMHtml *imhtml, GtkTextIter *i, GtkTextIter *e, gboolean homo) |
| 3862 | { | |
| 3863 | remove_tag_by_prefix(imhtml, i, e, "LINK ", 5, homo); | |
| 3864 | } | |
| 3865 | ||
|
12672
673e2a1d2954
[gaim-migrate @ 15015]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12635
diff
changeset
|
3866 | static void |
|
673e2a1d2954
[gaim-migrate @ 15015]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12635
diff
changeset
|
3867 | imhtml_clear_formatting(GtkIMHtml *imhtml) |
|
673e2a1d2954
[gaim-migrate @ 15015]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12635
diff
changeset
|
3868 | { |
|
673e2a1d2954
[gaim-migrate @ 15015]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12635
diff
changeset
|
3869 | GtkTextIter start, end; |
|
673e2a1d2954
[gaim-migrate @ 15015]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12635
diff
changeset
|
3870 | |
|
12796
8fb3611a91e1
[gaim-migrate @ 15143]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12673
diff
changeset
|
3871 | if (!imhtml->editable) |
|
8fb3611a91e1
[gaim-migrate @ 15143]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12673
diff
changeset
|
3872 | return; |
|
8fb3611a91e1
[gaim-migrate @ 15143]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12673
diff
changeset
|
3873 | |
|
8fb3611a91e1
[gaim-migrate @ 15143]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12673
diff
changeset
|
3874 | if (imhtml->wbfo) |
|
8fb3611a91e1
[gaim-migrate @ 15143]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12673
diff
changeset
|
3875 | gtk_text_buffer_get_bounds(imhtml->text_buffer, &start, &end); |
|
8fb3611a91e1
[gaim-migrate @ 15143]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12673
diff
changeset
|
3876 | else |
|
8fb3611a91e1
[gaim-migrate @ 15143]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12673
diff
changeset
|
3877 | if (!gtk_text_buffer_get_selection_bounds(imhtml->text_buffer, &start, &end)) |
|
8fb3611a91e1
[gaim-migrate @ 15143]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12673
diff
changeset
|
3878 | gtk_text_buffer_get_bounds(imhtml->text_buffer, &start, &end); |
|
12672
673e2a1d2954
[gaim-migrate @ 15015]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12635
diff
changeset
|
3879 | |
|
673e2a1d2954
[gaim-migrate @ 15015]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12635
diff
changeset
|
3880 | gtk_text_buffer_remove_tag_by_name(imhtml->text_buffer, "BOLD", &start, &end); |
|
673e2a1d2954
[gaim-migrate @ 15015]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12635
diff
changeset
|
3881 | gtk_text_buffer_remove_tag_by_name(imhtml->text_buffer, "ITALICS", &start, &end); |
|
673e2a1d2954
[gaim-migrate @ 15015]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12635
diff
changeset
|
3882 | gtk_text_buffer_remove_tag_by_name(imhtml->text_buffer, "UNDERLINE", &start, &end); |
|
673e2a1d2954
[gaim-migrate @ 15015]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12635
diff
changeset
|
3883 | gtk_text_buffer_remove_tag_by_name(imhtml->text_buffer, "STRIKE", &start, &end); |
|
13224
485977c61b47
[gaim-migrate @ 15587]
Richard Laager <rlaager@pidgin.im>
parents:
13138
diff
changeset
|
3884 | remove_font_size(imhtml, &start, &end, FALSE); |
|
485977c61b47
[gaim-migrate @ 15587]
Richard Laager <rlaager@pidgin.im>
parents:
13138
diff
changeset
|
3885 | remove_font_face(imhtml, &start, &end, FALSE); |
|
485977c61b47
[gaim-migrate @ 15587]
Richard Laager <rlaager@pidgin.im>
parents:
13138
diff
changeset
|
3886 | remove_font_forecolor(imhtml, &start, &end, FALSE); |
|
485977c61b47
[gaim-migrate @ 15587]
Richard Laager <rlaager@pidgin.im>
parents:
13138
diff
changeset
|
3887 | remove_font_backcolor(imhtml, &start, &end, FALSE); |
|
485977c61b47
[gaim-migrate @ 15587]
Richard Laager <rlaager@pidgin.im>
parents:
13138
diff
changeset
|
3888 | remove_font_background(imhtml, &start, &end, FALSE); |
|
485977c61b47
[gaim-migrate @ 15587]
Richard Laager <rlaager@pidgin.im>
parents:
13138
diff
changeset
|
3889 | remove_font_link(imhtml, &start, &end, FALSE); |
|
12672
673e2a1d2954
[gaim-migrate @ 15015]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12635
diff
changeset
|
3890 | |
|
673e2a1d2954
[gaim-migrate @ 15015]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12635
diff
changeset
|
3891 | imhtml->edit.bold = 0; |
|
673e2a1d2954
[gaim-migrate @ 15015]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12635
diff
changeset
|
3892 | imhtml->edit.italic = 0; |
|
673e2a1d2954
[gaim-migrate @ 15015]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12635
diff
changeset
|
3893 | imhtml->edit.underline = 0; |
|
673e2a1d2954
[gaim-migrate @ 15015]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12635
diff
changeset
|
3894 | imhtml->edit.strike = 0; |
|
673e2a1d2954
[gaim-migrate @ 15015]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12635
diff
changeset
|
3895 | imhtml->edit.fontsize = 0; |
|
13224
485977c61b47
[gaim-migrate @ 15587]
Richard Laager <rlaager@pidgin.im>
parents:
13138
diff
changeset
|
3896 | |
|
485977c61b47
[gaim-migrate @ 15587]
Richard Laager <rlaager@pidgin.im>
parents:
13138
diff
changeset
|
3897 | g_free(imhtml->edit.fontface); |
|
485977c61b47
[gaim-migrate @ 15587]
Richard Laager <rlaager@pidgin.im>
parents:
13138
diff
changeset
|
3898 | imhtml->edit.fontface = NULL; |
|
485977c61b47
[gaim-migrate @ 15587]
Richard Laager <rlaager@pidgin.im>
parents:
13138
diff
changeset
|
3899 | |
|
485977c61b47
[gaim-migrate @ 15587]
Richard Laager <rlaager@pidgin.im>
parents:
13138
diff
changeset
|
3900 | g_free(imhtml->edit.forecolor); |
|
12672
673e2a1d2954
[gaim-migrate @ 15015]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12635
diff
changeset
|
3901 | imhtml->edit.forecolor = NULL; |
|
13224
485977c61b47
[gaim-migrate @ 15587]
Richard Laager <rlaager@pidgin.im>
parents:
13138
diff
changeset
|
3902 | |
|
485977c61b47
[gaim-migrate @ 15587]
Richard Laager <rlaager@pidgin.im>
parents:
13138
diff
changeset
|
3903 | g_free(imhtml->edit.backcolor); |
|
12672
673e2a1d2954
[gaim-migrate @ 15015]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12635
diff
changeset
|
3904 | imhtml->edit.backcolor = NULL; |
|
13224
485977c61b47
[gaim-migrate @ 15587]
Richard Laager <rlaager@pidgin.im>
parents:
13138
diff
changeset
|
3905 | |
|
485977c61b47
[gaim-migrate @ 15587]
Richard Laager <rlaager@pidgin.im>
parents:
13138
diff
changeset
|
3906 | g_free(imhtml->edit.background); |
|
12672
673e2a1d2954
[gaim-migrate @ 15015]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12635
diff
changeset
|
3907 | imhtml->edit.background = NULL; |
|
673e2a1d2954
[gaim-migrate @ 15015]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12635
diff
changeset
|
3908 | } |
|
673e2a1d2954
[gaim-migrate @ 15015]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12635
diff
changeset
|
3909 | |
| 8677 | 3910 | /* Editable stuff */ |
| 3911 | static void preinsert_cb(GtkTextBuffer *buffer, GtkTextIter *iter, gchar *text, gint len, GtkIMHtml *imhtml) | |
| 3912 | { | |
| 3913 | imhtml->insert_offset = gtk_text_iter_get_offset(iter); | |
| 3914 | } | |
| 3915 | ||
| 10169 | 3916 | static void insert_ca_cb(GtkTextBuffer *buffer, GtkTextIter *arg1, GtkTextChildAnchor *arg2, gpointer user_data) |
| 3917 | { | |
| 3918 | GtkTextIter start; | |
| 3919 | ||
| 3920 | start = *arg1; | |
| 3921 | gtk_text_iter_backward_char(&start); | |
| 3922 | ||
| 3923 | gtk_imhtml_apply_tags_on_insert(user_data, &start, arg1); | |
| 3924 | } | |
| 3925 | ||
| 8677 | 3926 | static void insert_cb(GtkTextBuffer *buffer, GtkTextIter *end, gchar *text, gint len, GtkIMHtml *imhtml) |
| 3927 | { | |
| 3928 | GtkTextIter start; | |
| 3929 | ||
| 3930 | if (!len) | |
| 3931 | return; | |
| 3932 | ||
| 3933 | start = *end; | |
| 3934 | gtk_text_iter_set_offset(&start, imhtml->insert_offset); | |
| 3935 | ||
| 10169 | 3936 | gtk_imhtml_apply_tags_on_insert(imhtml, &start, end); |
| 3937 | } | |
| 3938 | ||
|
12673
4c8a20955e0b
[gaim-migrate @ 15016]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12672
diff
changeset
|
3939 | static void delete_cb(GtkTextBuffer *buffer, GtkTextIter *start, GtkTextIter *end, GtkIMHtml *imhtml) |
|
4c8a20955e0b
[gaim-migrate @ 15016]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12672
diff
changeset
|
3940 | { |
|
4c8a20955e0b
[gaim-migrate @ 15016]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12672
diff
changeset
|
3941 | GSList *tags, *l; |
|
4c8a20955e0b
[gaim-migrate @ 15016]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12672
diff
changeset
|
3942 | |
|
4c8a20955e0b
[gaim-migrate @ 15016]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12672
diff
changeset
|
3943 | tags = gtk_text_iter_get_tags(start); |
|
4c8a20955e0b
[gaim-migrate @ 15016]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12672
diff
changeset
|
3944 | for (l = tags; l != NULL; l = l->next) { |
|
4c8a20955e0b
[gaim-migrate @ 15016]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12672
diff
changeset
|
3945 | GtkTextTag *tag = GTK_TEXT_TAG(l->data); |
|
4c8a20955e0b
[gaim-migrate @ 15016]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12672
diff
changeset
|
3946 | |
|
4c8a20955e0b
[gaim-migrate @ 15016]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12672
diff
changeset
|
3947 | if (tag && /* Remove the formatting only if */ |
|
4c8a20955e0b
[gaim-migrate @ 15016]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12672
diff
changeset
|
3948 | gtk_text_iter_starts_word(start) && /* beginning of a word */ |
|
4c8a20955e0b
[gaim-migrate @ 15016]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12672
diff
changeset
|
3949 | gtk_text_iter_begins_tag(start, tag) && /* the tag starts with the selection */ |
|
4c8a20955e0b
[gaim-migrate @ 15016]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12672
diff
changeset
|
3950 | (!gtk_text_iter_has_tag(end, tag) || /* the tag ends within the selection */ |
|
4c8a20955e0b
[gaim-migrate @ 15016]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12672
diff
changeset
|
3951 | gtk_text_iter_ends_tag(end, tag))) { |
|
4c8a20955e0b
[gaim-migrate @ 15016]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12672
diff
changeset
|
3952 | gtk_text_buffer_remove_tag(imhtml->text_buffer, tag, start, end); |
|
4c8a20955e0b
[gaim-migrate @ 15016]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12672
diff
changeset
|
3953 | if (tag->name && |
|
4c8a20955e0b
[gaim-migrate @ 15016]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12672
diff
changeset
|
3954 | strncmp(tag->name, "LINK ", 5) == 0 && imhtml->edit.link) { |
|
4c8a20955e0b
[gaim-migrate @ 15016]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12672
diff
changeset
|
3955 | gtk_imhtml_toggle_link(imhtml, NULL); |
|
4c8a20955e0b
[gaim-migrate @ 15016]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12672
diff
changeset
|
3956 | } |
|
14097
0c340861ab79
[gaim-migrate @ 16638]
Mark Doliner <markdoliner@pidgin.im>
parents:
14010
diff
changeset
|
3957 | } |
|
12673
4c8a20955e0b
[gaim-migrate @ 15016]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12672
diff
changeset
|
3958 | } |
|
4c8a20955e0b
[gaim-migrate @ 15016]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12672
diff
changeset
|
3959 | g_slist_free(tags); |
|
4c8a20955e0b
[gaim-migrate @ 15016]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12672
diff
changeset
|
3960 | } |
|
4c8a20955e0b
[gaim-migrate @ 15016]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12672
diff
changeset
|
3961 | |
| 10169 | 3962 | static void gtk_imhtml_apply_tags_on_insert(GtkIMHtml *imhtml, GtkTextIter *start, GtkTextIter *end) |
| 3963 | { | |
| 8677 | 3964 | if (imhtml->edit.bold) |
| 10169 | 3965 | gtk_text_buffer_apply_tag_by_name(imhtml->text_buffer, "BOLD", start, end); |
| 8677 | 3966 | else |
| 10169 | 3967 | gtk_text_buffer_remove_tag_by_name(imhtml->text_buffer, "BOLD", start, end); |
| 8677 | 3968 | |
| 3969 | if (imhtml->edit.italic) | |
| 10169 | 3970 | gtk_text_buffer_apply_tag_by_name(imhtml->text_buffer, "ITALICS", start, end); |
| 8677 | 3971 | else |
| 10169 | 3972 | gtk_text_buffer_remove_tag_by_name(imhtml->text_buffer, "ITALICS", start, end); |
| 8677 | 3973 | |
| 3974 | if (imhtml->edit.underline) | |
| 10169 | 3975 | gtk_text_buffer_apply_tag_by_name(imhtml->text_buffer, "UNDERLINE", start, end); |
| 8677 | 3976 | else |
| 10169 | 3977 | gtk_text_buffer_remove_tag_by_name(imhtml->text_buffer, "UNDERLINE", start, end); |
| 8677 | 3978 | |
| 9924 | 3979 | if (imhtml->edit.strike) |
| 10169 | 3980 | gtk_text_buffer_apply_tag_by_name(imhtml->text_buffer, "STRIKE", start, end); |
| 9924 | 3981 | else |
| 10169 | 3982 | gtk_text_buffer_remove_tag_by_name(imhtml->text_buffer, "STRIKE", start, end); |
| 9924 | 3983 | |
| 8677 | 3984 | if (imhtml->edit.forecolor) { |
| 10169 | 3985 | remove_font_forecolor(imhtml, start, end, TRUE); |
| 8677 | 3986 | gtk_text_buffer_apply_tag(imhtml->text_buffer, |
| 3987 | find_font_forecolor_tag(imhtml, imhtml->edit.forecolor), | |
| 10169 | 3988 | start, end); |
| 8061 | 3989 | } |
| 3990 | ||
| 8677 | 3991 | if (imhtml->edit.backcolor) { |
| 10169 | 3992 | remove_font_backcolor(imhtml, start, end, TRUE); |
| 8677 | 3993 | gtk_text_buffer_apply_tag(imhtml->text_buffer, |
| 3994 | find_font_backcolor_tag(imhtml, imhtml->edit.backcolor), | |
| 10169 | 3995 | start, end); |
| 8677 | 3996 | } |
| 3997 | ||
| 10776 | 3998 | if (imhtml->edit.background) { |
| 3999 | remove_font_background(imhtml, start, end, TRUE); | |
| 4000 | gtk_text_buffer_apply_tag(imhtml->text_buffer, | |
| 4001 | find_font_background_tag(imhtml, imhtml->edit.background), | |
| 4002 | start, end); | |
| 4003 | } | |
| 8677 | 4004 | if (imhtml->edit.fontface) { |
| 10169 | 4005 | remove_font_face(imhtml, start, end, TRUE); |
| 8677 | 4006 | gtk_text_buffer_apply_tag(imhtml->text_buffer, |
| 4007 | find_font_face_tag(imhtml, imhtml->edit.fontface), | |
| 10169 | 4008 | start, end); |
| 8061 | 4009 | } |
| 8677 | 4010 | |
| 4011 | if (imhtml->edit.fontsize) { | |
| 10169 | 4012 | remove_font_size(imhtml, start, end, TRUE); |
| 8677 | 4013 | gtk_text_buffer_apply_tag(imhtml->text_buffer, |
| 4014 | find_font_size_tag(imhtml, imhtml->edit.fontsize), | |
| 10169 | 4015 | start, end); |
| 8677 | 4016 | } |
| 4017 | ||
| 4018 | if (imhtml->edit.link) { | |
| 10169 | 4019 | remove_font_link(imhtml, start, end, TRUE); |
| 8677 | 4020 | gtk_text_buffer_apply_tag(imhtml->text_buffer, |
| 4021 | imhtml->edit.link, | |
| 10169 | 4022 | start, end); |
| 8677 | 4023 | } |
| 8061 | 4024 | } |
| 4025 | ||
| 4026 | void gtk_imhtml_set_editable(GtkIMHtml *imhtml, gboolean editable) | |
| 4027 | { | |
| 4028 | gtk_text_view_set_editable(GTK_TEXT_VIEW(imhtml), editable); | |
|
8177
33b3a01c6318
[gaim-migrate @ 8891]
Mark Doliner <markdoliner@pidgin.im>
parents:
8149
diff
changeset
|
4029 | /* |
|
33b3a01c6318
[gaim-migrate @ 8891]
Mark Doliner <markdoliner@pidgin.im>
parents:
8149
diff
changeset
|
4030 | * We need a visible caret for accessibility, so mouseless |
|
33b3a01c6318
[gaim-migrate @ 8891]
Mark Doliner <markdoliner@pidgin.im>
parents:
8149
diff
changeset
|
4031 | * people can highlight stuff. |
|
33b3a01c6318
[gaim-migrate @ 8891]
Mark Doliner <markdoliner@pidgin.im>
parents:
8149
diff
changeset
|
4032 | */ |
|
33b3a01c6318
[gaim-migrate @ 8891]
Mark Doliner <markdoliner@pidgin.im>
parents:
8149
diff
changeset
|
4033 | /* gtk_text_view_set_cursor_visible(GTK_TEXT_VIEW(imhtml), editable); */ |
| 8061 | 4034 | imhtml->editable = editable; |
| 8677 | 4035 | imhtml->format_functions = GTK_IMHTML_ALL; |
| 4036 | ||
| 4037 | if (editable) | |
| 4038 | g_signal_connect_after(G_OBJECT(GTK_IMHTML(imhtml)->text_buffer), "mark-set", | |
| 4039 | G_CALLBACK(mark_set_cb), imhtml); | |
| 4040 | } | |
| 4041 | ||
| 4042 | void gtk_imhtml_set_whole_buffer_formatting_only(GtkIMHtml *imhtml, gboolean wbfo) | |
| 4043 | { | |
| 4044 | g_return_if_fail(imhtml != NULL); | |
| 4045 | ||
| 4046 | imhtml->wbfo = wbfo; | |
| 8420 | 4047 | } |
| 4048 | ||
| 4049 | void gtk_imhtml_set_format_functions(GtkIMHtml *imhtml, GtkIMHtmlButtons buttons) | |
| 4050 | { | |
| 4051 | GObject *object = g_object_ref(G_OBJECT(imhtml)); | |
| 8677 | 4052 | imhtml->format_functions = buttons; |
| 8420 | 4053 | g_signal_emit(object, signals[BUTTONS_UPDATE], 0, buttons); |
| 4054 | g_object_unref(object); | |
| 8061 | 4055 | } |
| 4056 | ||
|
8788
a13634443a38
[gaim-migrate @ 9550]
Mark Doliner <markdoliner@pidgin.im>
parents:
8786
diff
changeset
|
4057 | GtkIMHtmlButtons gtk_imhtml_get_format_functions(GtkIMHtml *imhtml) |
|
a13634443a38
[gaim-migrate @ 9550]
Mark Doliner <markdoliner@pidgin.im>
parents:
8786
diff
changeset
|
4058 | { |
|
a13634443a38
[gaim-migrate @ 9550]
Mark Doliner <markdoliner@pidgin.im>
parents:
8786
diff
changeset
|
4059 | return imhtml->format_functions; |
|
a13634443a38
[gaim-migrate @ 9550]
Mark Doliner <markdoliner@pidgin.im>
parents:
8786
diff
changeset
|
4060 | } |
| 8516 | 4061 | |
| 4062 | void gtk_imhtml_get_current_format(GtkIMHtml *imhtml, gboolean *bold, | |
| 4063 | gboolean *italic, gboolean *underline) | |
| 8481 | 4064 | { |
|
12900
7fe519669e07
[gaim-migrate @ 15253]
Richard Laager <rlaager@pidgin.im>
parents:
12836
diff
changeset
|
4065 | if (bold != NULL) |
|
7fe519669e07
[gaim-migrate @ 15253]
Richard Laager <rlaager@pidgin.im>
parents:
12836
diff
changeset
|
4066 | (*bold) = imhtml->edit.bold; |
|
7fe519669e07
[gaim-migrate @ 15253]
Richard Laager <rlaager@pidgin.im>
parents:
12836
diff
changeset
|
4067 | if (italic != NULL) |
|
7fe519669e07
[gaim-migrate @ 15253]
Richard Laager <rlaager@pidgin.im>
parents:
12836
diff
changeset
|
4068 | (*italic) = imhtml->edit.italic; |
|
7fe519669e07
[gaim-migrate @ 15253]
Richard Laager <rlaager@pidgin.im>
parents:
12836
diff
changeset
|
4069 | if (underline != NULL) |
|
7fe519669e07
[gaim-migrate @ 15253]
Richard Laager <rlaager@pidgin.im>
parents:
12836
diff
changeset
|
4070 | (*underline) = imhtml->edit.underline; |
| 8481 | 4071 | } |
| 4072 | ||
| 9025 | 4073 | char * |
| 4074 | gtk_imhtml_get_current_fontface(GtkIMHtml *imhtml) | |
| 4075 | { | |
|
14097
0c340861ab79
[gaim-migrate @ 16638]
Mark Doliner <markdoliner@pidgin.im>
parents:
14010
diff
changeset
|
4076 | return g_strdup(imhtml->edit.fontface); |
| 9025 | 4077 | } |
| 4078 | ||
| 4079 | char * | |
| 4080 | gtk_imhtml_get_current_forecolor(GtkIMHtml *imhtml) | |
| 4081 | { | |
|
14097
0c340861ab79
[gaim-migrate @ 16638]
Mark Doliner <markdoliner@pidgin.im>
parents:
14010
diff
changeset
|
4082 | return g_strdup(imhtml->edit.forecolor); |
| 9025 | 4083 | } |
| 4084 | ||
| 4085 | char * | |
| 4086 | gtk_imhtml_get_current_backcolor(GtkIMHtml *imhtml) | |
| 4087 | { | |
|
14097
0c340861ab79
[gaim-migrate @ 16638]
Mark Doliner <markdoliner@pidgin.im>
parents:
14010
diff
changeset
|
4088 | return g_strdup(imhtml->edit.backcolor); |
| 9025 | 4089 | } |
| 4090 | ||
|
11267
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
4091 | char * |
|
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
4092 | gtk_imhtml_get_current_background(GtkIMHtml *imhtml) |
|
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
4093 | { |
|
14097
0c340861ab79
[gaim-migrate @ 16638]
Mark Doliner <markdoliner@pidgin.im>
parents:
14010
diff
changeset
|
4094 | return g_strdup(imhtml->edit.background); |
|
11267
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
4095 | } |
|
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
4096 | |
| 9025 | 4097 | gint |
| 4098 | gtk_imhtml_get_current_fontsize(GtkIMHtml *imhtml) | |
| 4099 | { | |
| 4100 | return imhtml->edit.fontsize; | |
| 4101 | } | |
| 4102 | ||
| 8061 | 4103 | gboolean gtk_imhtml_get_editable(GtkIMHtml *imhtml) |
| 4104 | { | |
| 4105 | return imhtml->editable; | |
| 4106 | } | |
| 4107 | ||
|
11269
ca63789d57b9
[gaim-migrate @ 13451]
Richard Laager <rlaager@pidgin.im>
parents:
11267
diff
changeset
|
4108 | void |
|
ca63789d57b9
[gaim-migrate @ 13451]
Richard Laager <rlaager@pidgin.im>
parents:
11267
diff
changeset
|
4109 | gtk_imhtml_clear_formatting(GtkIMHtml *imhtml) |
|
ca63789d57b9
[gaim-migrate @ 13451]
Richard Laager <rlaager@pidgin.im>
parents:
11267
diff
changeset
|
4110 | { |
|
11275
cdcc651d7ecd
[gaim-migrate @ 13461]
Richard Laager <rlaager@pidgin.im>
parents:
11269
diff
changeset
|
4111 | GObject *object; |
|
cdcc651d7ecd
[gaim-migrate @ 13461]
Richard Laager <rlaager@pidgin.im>
parents:
11269
diff
changeset
|
4112 | |
|
cdcc651d7ecd
[gaim-migrate @ 13461]
Richard Laager <rlaager@pidgin.im>
parents:
11269
diff
changeset
|
4113 | object = g_object_ref(G_OBJECT(imhtml)); |
|
cdcc651d7ecd
[gaim-migrate @ 13461]
Richard Laager <rlaager@pidgin.im>
parents:
11269
diff
changeset
|
4114 | g_signal_emit(object, signals[CLEAR_FORMAT], 0); |
|
11276
aec923529d31
[gaim-migrate @ 13463]
Richard Laager <rlaager@pidgin.im>
parents:
11275
diff
changeset
|
4115 | |
|
11269
ca63789d57b9
[gaim-migrate @ 13451]
Richard Laager <rlaager@pidgin.im>
parents:
11267
diff
changeset
|
4116 | gtk_widget_grab_focus(GTK_WIDGET(imhtml)); |
|
11276
aec923529d31
[gaim-migrate @ 13463]
Richard Laager <rlaager@pidgin.im>
parents:
11275
diff
changeset
|
4117 | |
|
aec923529d31
[gaim-migrate @ 13463]
Richard Laager <rlaager@pidgin.im>
parents:
11275
diff
changeset
|
4118 | g_object_unref(object); |
|
11269
ca63789d57b9
[gaim-migrate @ 13451]
Richard Laager <rlaager@pidgin.im>
parents:
11267
diff
changeset
|
4119 | } |
|
ca63789d57b9
[gaim-migrate @ 13451]
Richard Laager <rlaager@pidgin.im>
parents:
11267
diff
changeset
|
4120 | |
| 8677 | 4121 | /* |
| 4122 | * I had this crazy idea about changing the text cursor color to reflex the foreground color | |
| 4123 | * of the text about to be entered. This is the place you'd do it, along with the place where | |
| 4124 | * we actually set a new foreground color. | |
| 15884 | 4125 | * I may not do this, because people will bitch about Purple overriding their gtk theme's cursor |
| 8677 | 4126 | * colors. |
| 4127 | * | |
| 4128 | * Just in case I do do this, I asked about what to set the secondary text cursor to. | |
| 4129 | * | |
| 8719 | 4130 | * (12:45:27) ?? ???: secondary_cursor_color = (rgb(background) + rgb(primary_cursor_color) ) / 2 |
| 4131 | * (12:45:55) ?? ???: understand? | |
| 8677 | 4132 | * (12:46:14) Tim: yeah. i didn't know there was an exact formula |
|
8735
01248ea222d3
[gaim-migrate @ 9490]
Jonathan Champ <royanee@users.sourceforge.net>
parents:
8729
diff
changeset
|
4133 | * (12:46:56) ?? ???: u might need to extract separate each color from RGB |
| 8677 | 4134 | */ |
| 4135 | ||
| 4136 | static void mark_set_cb(GtkTextBuffer *buffer, GtkTextIter *arg1, GtkTextMark *mark, | |
| 4137 | GtkIMHtml *imhtml) | |
| 4138 | { | |
| 4139 | GSList *tags, *l; | |
| 4140 | GtkTextIter iter; | |
| 4141 | ||
| 4142 | if (mark != gtk_text_buffer_get_insert(buffer)) | |
| 4143 | return; | |
| 4144 | ||
| 4145 | if (!gtk_text_buffer_get_char_count(buffer)) | |
| 4146 | return; | |
| 4147 | ||
| 9924 | 4148 | imhtml->edit.bold = imhtml->edit.italic = imhtml->edit.underline = imhtml->edit.strike = FALSE; |
|
14097
0c340861ab79
[gaim-migrate @ 16638]
Mark Doliner <markdoliner@pidgin.im>
parents:
14010
diff
changeset
|
4149 | g_free(imhtml->edit.forecolor); |
| 8677 | 4150 | imhtml->edit.forecolor = NULL; |
|
14097
0c340861ab79
[gaim-migrate @ 16638]
Mark Doliner <markdoliner@pidgin.im>
parents:
14010
diff
changeset
|
4151 | |
|
0c340861ab79
[gaim-migrate @ 16638]
Mark Doliner <markdoliner@pidgin.im>
parents:
14010
diff
changeset
|
4152 | g_free(imhtml->edit.backcolor); |
| 8677 | 4153 | imhtml->edit.backcolor = NULL; |
|
14097
0c340861ab79
[gaim-migrate @ 16638]
Mark Doliner <markdoliner@pidgin.im>
parents:
14010
diff
changeset
|
4154 | |
|
0c340861ab79
[gaim-migrate @ 16638]
Mark Doliner <markdoliner@pidgin.im>
parents:
14010
diff
changeset
|
4155 | g_free(imhtml->edit.fontface); |
| 8677 | 4156 | imhtml->edit.fontface = NULL; |
|
14097
0c340861ab79
[gaim-migrate @ 16638]
Mark Doliner <markdoliner@pidgin.im>
parents:
14010
diff
changeset
|
4157 | |
| 8677 | 4158 | imhtml->edit.fontsize = 0; |
| 4159 | imhtml->edit.link = NULL; | |
| 4160 | ||
| 4161 | gtk_text_buffer_get_iter_at_mark(imhtml->text_buffer, &iter, mark); | |
| 4162 | ||
| 4163 | ||
| 4164 | if (gtk_text_iter_is_end(&iter)) | |
| 4165 | tags = gtk_text_iter_get_toggled_tags(&iter, FALSE); | |
| 4166 | else | |
| 4167 | tags = gtk_text_iter_get_tags(&iter); | |
| 4168 | ||
| 4169 | for (l = tags; l != NULL; l = l->next) { | |
| 4170 | GtkTextTag *tag = GTK_TEXT_TAG(l->data); | |
| 4171 | ||
| 4172 | if (tag->name) { | |
| 4173 | if (strcmp(tag->name, "BOLD") == 0) | |
| 4174 | imhtml->edit.bold = TRUE; | |
|
13138
4d3bd039da3e
[gaim-migrate @ 15499]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13137
diff
changeset
|
4175 | else if (strcmp(tag->name, "ITALICS") == 0) |
| 8677 | 4176 | imhtml->edit.italic = TRUE; |
|
13138
4d3bd039da3e
[gaim-migrate @ 15499]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13137
diff
changeset
|
4177 | else if (strcmp(tag->name, "UNDERLINE") == 0) |
| 8677 | 4178 | imhtml->edit.underline = TRUE; |
|
13138
4d3bd039da3e
[gaim-migrate @ 15499]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13137
diff
changeset
|
4179 | else if (strcmp(tag->name, "STRIKE") == 0) |
| 9924 | 4180 | imhtml->edit.strike = TRUE; |
|
13138
4d3bd039da3e
[gaim-migrate @ 15499]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13137
diff
changeset
|
4181 | else if (strncmp(tag->name, "FORECOLOR ", 10) == 0) |
| 8677 | 4182 | imhtml->edit.forecolor = g_strdup(&(tag->name)[10]); |
|
13138
4d3bd039da3e
[gaim-migrate @ 15499]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13137
diff
changeset
|
4183 | else if (strncmp(tag->name, "BACKCOLOR ", 10) == 0) |
| 8677 | 4184 | imhtml->edit.backcolor = g_strdup(&(tag->name)[10]); |
|
13138
4d3bd039da3e
[gaim-migrate @ 15499]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13137
diff
changeset
|
4185 | else if (strncmp(tag->name, "FONT FACE ", 10) == 0) |
| 8677 | 4186 | imhtml->edit.fontface = g_strdup(&(tag->name)[10]); |
|
13138
4d3bd039da3e
[gaim-migrate @ 15499]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13137
diff
changeset
|
4187 | else if (strncmp(tag->name, "FONT SIZE ", 10) == 0) |
| 8677 | 4188 | imhtml->edit.fontsize = strtol(&(tag->name)[10], NULL, 10); |
|
13138
4d3bd039da3e
[gaim-migrate @ 15499]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13137
diff
changeset
|
4189 | else if ((strncmp(tag->name, "LINK ", 5) == 0) && !gtk_text_iter_is_end(&iter)) |
| 8677 | 4190 | imhtml->edit.link = tag; |
| 4191 | } | |
| 4192 | } | |
| 4193 | ||
| 4194 | g_slist_free(tags); | |
| 4195 | } | |
| 4196 | ||
|
12605
7390627a6aaf
[gaim-migrate @ 14940]
Richard Laager <rlaager@pidgin.im>
parents:
12600
diff
changeset
|
4197 | static void imhtml_emit_signal_for_format(GtkIMHtml *imhtml, GtkIMHtmlButtons button) |
|
7390627a6aaf
[gaim-migrate @ 14940]
Richard Laager <rlaager@pidgin.im>
parents:
12600
diff
changeset
|
4198 | { |
|
7390627a6aaf
[gaim-migrate @ 14940]
Richard Laager <rlaager@pidgin.im>
parents:
12600
diff
changeset
|
4199 | GObject *object; |
|
7390627a6aaf
[gaim-migrate @ 14940]
Richard Laager <rlaager@pidgin.im>
parents:
12600
diff
changeset
|
4200 | |
|
7390627a6aaf
[gaim-migrate @ 14940]
Richard Laager <rlaager@pidgin.im>
parents:
12600
diff
changeset
|
4201 | g_return_if_fail(imhtml != NULL); |
|
7390627a6aaf
[gaim-migrate @ 14940]
Richard Laager <rlaager@pidgin.im>
parents:
12600
diff
changeset
|
4202 | |
|
7390627a6aaf
[gaim-migrate @ 14940]
Richard Laager <rlaager@pidgin.im>
parents:
12600
diff
changeset
|
4203 | object = g_object_ref(G_OBJECT(imhtml)); |
|
7390627a6aaf
[gaim-migrate @ 14940]
Richard Laager <rlaager@pidgin.im>
parents:
12600
diff
changeset
|
4204 | g_signal_emit(object, signals[TOGGLE_FORMAT], 0, button); |
|
7390627a6aaf
[gaim-migrate @ 14940]
Richard Laager <rlaager@pidgin.im>
parents:
12600
diff
changeset
|
4205 | g_object_unref(object); |
|
7390627a6aaf
[gaim-migrate @ 14940]
Richard Laager <rlaager@pidgin.im>
parents:
12600
diff
changeset
|
4206 | } |
|
7390627a6aaf
[gaim-migrate @ 14940]
Richard Laager <rlaager@pidgin.im>
parents:
12600
diff
changeset
|
4207 | |
|
11267
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
4208 | static void imhtml_toggle_bold(GtkIMHtml *imhtml) |
| 8061 | 4209 | { |
| 8677 | 4210 | GtkTextIter start, end; |
| 4211 | ||
| 4212 | imhtml->edit.bold = !imhtml->edit.bold; | |
| 4213 | ||
| 4214 | if (imhtml->wbfo) { | |
| 4215 | gtk_text_buffer_get_bounds(imhtml->text_buffer, &start, &end); | |
| 4216 | if (imhtml->edit.bold) | |
| 4217 | gtk_text_buffer_apply_tag_by_name(imhtml->text_buffer, "BOLD", &start, &end); | |
| 4218 | else | |
| 4219 | gtk_text_buffer_remove_tag_by_name(imhtml->text_buffer, "BOLD", &start, &end); | |
|
11276
aec923529d31
[gaim-migrate @ 13463]
Richard Laager <rlaager@pidgin.im>
parents:
11275
diff
changeset
|
4220 | } else if (imhtml->editable && gtk_text_buffer_get_selection_bounds(imhtml->text_buffer, &start, &end)) { |
| 8677 | 4221 | if (imhtml->edit.bold) |
| 4222 | gtk_text_buffer_apply_tag_by_name(imhtml->text_buffer, "BOLD", &start, &end); | |
| 4223 | else | |
| 4224 | gtk_text_buffer_remove_tag_by_name(imhtml->text_buffer, "BOLD", &start, &end); | |
|
11276
aec923529d31
[gaim-migrate @ 13463]
Richard Laager <rlaager@pidgin.im>
parents:
11275
diff
changeset
|
4225 | |
| 8061 | 4226 | } |
| 4227 | } | |
| 4228 | ||
|
11267
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
4229 | void gtk_imhtml_toggle_bold(GtkIMHtml *imhtml) |
| 8061 | 4230 | { |
|
12605
7390627a6aaf
[gaim-migrate @ 14940]
Richard Laager <rlaager@pidgin.im>
parents:
12600
diff
changeset
|
4231 | imhtml_emit_signal_for_format(imhtml, GTK_IMHTML_BOLD); |
|
11267
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
4232 | } |
|
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
4233 | |
|
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
4234 | static void imhtml_toggle_italic(GtkIMHtml *imhtml) |
|
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
4235 | { |
| 8677 | 4236 | GtkTextIter start, end; |
| 4237 | ||
| 4238 | imhtml->edit.italic = !imhtml->edit.italic; | |
| 4239 | ||
| 4240 | if (imhtml->wbfo) { | |
| 4241 | gtk_text_buffer_get_bounds(imhtml->text_buffer, &start, &end); | |
| 4242 | if (imhtml->edit.italic) | |
| 4243 | gtk_text_buffer_apply_tag_by_name(imhtml->text_buffer, "ITALICS", &start, &end); | |
| 4244 | else | |
| 4245 | gtk_text_buffer_remove_tag_by_name(imhtml->text_buffer, "ITALICS", &start, &end); | |
|
11276
aec923529d31
[gaim-migrate @ 13463]
Richard Laager <rlaager@pidgin.im>
parents:
11275
diff
changeset
|
4246 | } else if (imhtml->editable && gtk_text_buffer_get_selection_bounds(imhtml->text_buffer, &start, &end)) { |
|
aec923529d31
[gaim-migrate @ 13463]
Richard Laager <rlaager@pidgin.im>
parents:
11275
diff
changeset
|
4247 | if (imhtml->edit.italic) |
| 8677 | 4248 | gtk_text_buffer_apply_tag_by_name(imhtml->text_buffer, "ITALICS", &start, &end); |
| 4249 | else | |
| 4250 | gtk_text_buffer_remove_tag_by_name(imhtml->text_buffer, "ITALICS", &start, &end); | |
| 8061 | 4251 | } |
| 4252 | } | |
| 4253 | ||
|
11267
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
4254 | void gtk_imhtml_toggle_italic(GtkIMHtml *imhtml) |
| 8061 | 4255 | { |
|
12605
7390627a6aaf
[gaim-migrate @ 14940]
Richard Laager <rlaager@pidgin.im>
parents:
12600
diff
changeset
|
4256 | imhtml_emit_signal_for_format(imhtml, GTK_IMHTML_ITALIC); |
|
7390627a6aaf
[gaim-migrate @ 14940]
Richard Laager <rlaager@pidgin.im>
parents:
12600
diff
changeset
|
4257 | } |
|
11267
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
4258 | |
|
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
4259 | static void imhtml_toggle_underline(GtkIMHtml *imhtml) |
|
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
4260 | { |
| 8677 | 4261 | GtkTextIter start, end; |
| 4262 | ||
| 4263 | imhtml->edit.underline = !imhtml->edit.underline; | |
| 4264 | ||
| 4265 | if (imhtml->wbfo) { | |
| 4266 | gtk_text_buffer_get_bounds(imhtml->text_buffer, &start, &end); | |
| 4267 | if (imhtml->edit.underline) | |
| 4268 | gtk_text_buffer_apply_tag_by_name(imhtml->text_buffer, "UNDERLINE", &start, &end); | |
| 4269 | else | |
| 4270 | gtk_text_buffer_remove_tag_by_name(imhtml->text_buffer, "UNDERLINE", &start, &end); | |
|
11276
aec923529d31
[gaim-migrate @ 13463]
Richard Laager <rlaager@pidgin.im>
parents:
11275
diff
changeset
|
4271 | } else if (imhtml->editable && gtk_text_buffer_get_selection_bounds(imhtml->text_buffer, &start, &end)) { |
|
aec923529d31
[gaim-migrate @ 13463]
Richard Laager <rlaager@pidgin.im>
parents:
11275
diff
changeset
|
4272 | if (imhtml->edit.underline) |
| 8677 | 4273 | gtk_text_buffer_apply_tag_by_name(imhtml->text_buffer, "UNDERLINE", &start, &end); |
| 4274 | else | |
| 4275 | gtk_text_buffer_remove_tag_by_name(imhtml->text_buffer, "UNDERLINE", &start, &end); | |
| 8061 | 4276 | } |
| 4277 | } | |
| 4278 | ||
|
11267
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
4279 | void gtk_imhtml_toggle_underline(GtkIMHtml *imhtml) |
| 9924 | 4280 | { |
|
12605
7390627a6aaf
[gaim-migrate @ 14940]
Richard Laager <rlaager@pidgin.im>
parents:
12600
diff
changeset
|
4281 | imhtml_emit_signal_for_format(imhtml, GTK_IMHTML_UNDERLINE); |
|
11267
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
4282 | } |
|
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
4283 | |
|
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
4284 | static void imhtml_toggle_strike(GtkIMHtml *imhtml) |
|
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
4285 | { |
| 9924 | 4286 | GtkTextIter start, end; |
| 4287 | ||
| 4288 | imhtml->edit.strike = !imhtml->edit.strike; | |
| 4289 | ||
| 4290 | if (imhtml->wbfo) { | |
| 4291 | gtk_text_buffer_get_bounds(imhtml->text_buffer, &start, &end); | |
| 4292 | if (imhtml->edit.strike) | |
| 4293 | gtk_text_buffer_apply_tag_by_name(imhtml->text_buffer, "STRIKE", &start, &end); | |
| 4294 | else | |
| 4295 | gtk_text_buffer_remove_tag_by_name(imhtml->text_buffer, "STRIKE", &start, &end); | |
|
11276
aec923529d31
[gaim-migrate @ 13463]
Richard Laager <rlaager@pidgin.im>
parents:
11275
diff
changeset
|
4296 | } else if (imhtml->editable && gtk_text_buffer_get_selection_bounds(imhtml->text_buffer, &start, &end)) { |
|
aec923529d31
[gaim-migrate @ 13463]
Richard Laager <rlaager@pidgin.im>
parents:
11275
diff
changeset
|
4297 | if (imhtml->edit.strike) |
| 9924 | 4298 | gtk_text_buffer_apply_tag_by_name(imhtml->text_buffer, "STRIKE", &start, &end); |
| 4299 | else | |
| 4300 | gtk_text_buffer_remove_tag_by_name(imhtml->text_buffer, "STRIKE", &start, &end); | |
| 4301 | } | |
|
11267
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
4302 | } |
|
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
4303 | |
|
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
4304 | void gtk_imhtml_toggle_strike(GtkIMHtml *imhtml) |
|
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
4305 | { |
|
12605
7390627a6aaf
[gaim-migrate @ 14940]
Richard Laager <rlaager@pidgin.im>
parents:
12600
diff
changeset
|
4306 | imhtml_emit_signal_for_format(imhtml, GTK_IMHTML_STRIKE); |
| 9924 | 4307 | } |
| 4308 | ||
| 8061 | 4309 | void gtk_imhtml_font_set_size(GtkIMHtml *imhtml, gint size) |
| 4310 | { | |
| 9025 | 4311 | GObject *object; |
| 8677 | 4312 | GtkTextIter start, end; |
| 8061 | 4313 | |
| 4314 | imhtml->edit.fontsize = size; | |
| 4315 | ||
| 8677 | 4316 | if (imhtml->wbfo) { |
| 4317 | gtk_text_buffer_get_bounds(imhtml->text_buffer, &start, &end); | |
| 4318 | remove_font_size(imhtml, &start, &end, TRUE); | |
| 4319 | gtk_text_buffer_apply_tag(imhtml->text_buffer, | |
| 4320 | find_font_size_tag(imhtml, imhtml->edit.fontsize), &start, &end); | |
|
11276
aec923529d31
[gaim-migrate @ 13463]
Richard Laager <rlaager@pidgin.im>
parents:
11275
diff
changeset
|
4321 | } else if (imhtml->editable && gtk_text_buffer_get_selection_bounds(imhtml->text_buffer, &start, &end)) { |
| 8677 | 4322 | remove_font_size(imhtml, &start, &end, FALSE); |
| 4323 | gtk_text_buffer_apply_tag(imhtml->text_buffer, | |
| 4324 | find_font_size_tag(imhtml, imhtml->edit.fontsize), &start, &end); | |
| 8061 | 4325 | } |
| 8677 | 4326 | |
| 9025 | 4327 | object = g_object_ref(G_OBJECT(imhtml)); |
|
11267
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
4328 | g_signal_emit(object, signals[TOGGLE_FORMAT], 0, GTK_IMHTML_SHRINK | GTK_IMHTML_GROW); |
| 9025 | 4329 | g_object_unref(object); |
| 8061 | 4330 | } |
| 4331 | ||
|
11267
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
4332 | static void imhtml_font_shrink(GtkIMHtml *imhtml) |
| 8061 | 4333 | { |
| 8677 | 4334 | GtkTextIter start, end; |
| 4335 | ||
| 8061 | 4336 | if (imhtml->edit.fontsize == 1) |
| 4337 | return; | |
| 4338 | ||
| 8677 | 4339 | if (!imhtml->edit.fontsize) |
| 4340 | imhtml->edit.fontsize = 2; | |
| 4341 | else | |
| 4342 | imhtml->edit.fontsize--; | |
| 4343 | ||
| 4344 | if (imhtml->wbfo) { | |
| 4345 | gtk_text_buffer_get_bounds(imhtml->text_buffer, &start, &end); | |
| 4346 | remove_font_size(imhtml, &start, &end, TRUE); | |
| 4347 | gtk_text_buffer_apply_tag(imhtml->text_buffer, | |
| 4348 | find_font_size_tag(imhtml, imhtml->edit.fontsize), &start, &end); | |
|
11276
aec923529d31
[gaim-migrate @ 13463]
Richard Laager <rlaager@pidgin.im>
parents:
11275
diff
changeset
|
4349 | } else if (imhtml->editable && gtk_text_buffer_get_selection_bounds(imhtml->text_buffer, &start, &end)) { |
| 8677 | 4350 | remove_font_size(imhtml, &start, &end, FALSE); |
| 4351 | gtk_text_buffer_apply_tag(imhtml->text_buffer, | |
| 4352 | find_font_size_tag(imhtml, imhtml->edit.fontsize), &start, &end); | |
| 8061 | 4353 | } |
|
11267
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
4354 | } |
|
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
4355 | |
|
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
4356 | void gtk_imhtml_font_shrink(GtkIMHtml *imhtml) |
|
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
4357 | { |
|
12605
7390627a6aaf
[gaim-migrate @ 14940]
Richard Laager <rlaager@pidgin.im>
parents:
12600
diff
changeset
|
4358 | imhtml_emit_signal_for_format(imhtml, GTK_IMHTML_SHRINK); |
| 8061 | 4359 | } |
| 4360 | ||
|
11267
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
4361 | static void imhtml_font_grow(GtkIMHtml *imhtml) |
| 8061 | 4362 | { |
| 8677 | 4363 | GtkTextIter start, end; |
| 4364 | ||
| 8061 | 4365 | if (imhtml->edit.fontsize == MAX_FONT_SIZE) |
| 4366 | return; | |
| 4367 | ||
| 8677 | 4368 | if (!imhtml->edit.fontsize) |
| 4369 | imhtml->edit.fontsize = 4; | |
| 4370 | else | |
| 4371 | imhtml->edit.fontsize++; | |
| 4372 | ||
| 4373 | if (imhtml->wbfo) { | |
| 4374 | gtk_text_buffer_get_bounds(imhtml->text_buffer, &start, &end); | |
| 4375 | remove_font_size(imhtml, &start, &end, TRUE); | |
| 4376 | gtk_text_buffer_apply_tag(imhtml->text_buffer, | |
| 4377 | find_font_size_tag(imhtml, imhtml->edit.fontsize), &start, &end); | |
|
11276
aec923529d31
[gaim-migrate @ 13463]
Richard Laager <rlaager@pidgin.im>
parents:
11275
diff
changeset
|
4378 | } else if (imhtml->editable && gtk_text_buffer_get_selection_bounds(imhtml->text_buffer, &start, &end)) { |
| 8677 | 4379 | remove_font_size(imhtml, &start, &end, FALSE); |
| 4380 | gtk_text_buffer_apply_tag(imhtml->text_buffer, | |
| 4381 | find_font_size_tag(imhtml, imhtml->edit.fontsize), &start, &end); | |
| 8061 | 4382 | } |
|
11267
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
4383 | } |
|
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
4384 | |
|
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
4385 | void gtk_imhtml_font_grow(GtkIMHtml *imhtml) |
|
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
4386 | { |
|
12605
7390627a6aaf
[gaim-migrate @ 14940]
Richard Laager <rlaager@pidgin.im>
parents:
12600
diff
changeset
|
4387 | imhtml_emit_signal_for_format(imhtml, GTK_IMHTML_GROW); |
| 8061 | 4388 | } |
| 4389 | ||
|
13225
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4390 | static gboolean gtk_imhtml_toggle_str_tag(GtkIMHtml *imhtml, const char *value, char **edit_field, |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4391 | void (*remove_func)(GtkIMHtml *imhtml, GtkTextIter *i, GtkTextIter *e, gboolean homo), |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4392 | GtkTextTag *(find_func)(GtkIMHtml *imhtml, gchar *color), GtkIMHtmlButtons button) |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4393 | { |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4394 | GObject *object; |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4395 | GtkTextIter start; |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4396 | GtkTextIter end; |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4397 | |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4398 | g_free(*edit_field); |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4399 | *edit_field = NULL; |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4400 | |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4401 | if (value && strcmp(value, "") != 0) |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4402 | { |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4403 | *edit_field = g_strdup(value); |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4404 | |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4405 | if (imhtml->wbfo) |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4406 | { |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4407 | gtk_text_buffer_get_bounds(imhtml->text_buffer, &start, &end); |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4408 | remove_func(imhtml, &start, &end, TRUE); |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4409 | gtk_text_buffer_apply_tag(imhtml->text_buffer, |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4410 | find_func(imhtml, *edit_field), &start, &end); |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4411 | } |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4412 | else |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4413 | { |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4414 | gtk_text_buffer_get_iter_at_mark(imhtml->text_buffer, &start, |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4415 | gtk_text_buffer_get_mark(imhtml->text_buffer, "insert")); |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4416 | if (imhtml->editable && gtk_text_buffer_get_selection_bounds(imhtml->text_buffer, &start, &end)) |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4417 | { |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4418 | remove_func(imhtml, &start, &end, FALSE); |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4419 | gtk_text_buffer_apply_tag(imhtml->text_buffer, |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4420 | find_func(imhtml, |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4421 | *edit_field), |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4422 | &start, &end); |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4423 | } |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4424 | } |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4425 | } |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4426 | else |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4427 | { |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4428 | if (imhtml->wbfo) |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4429 | { |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4430 | gtk_text_buffer_get_bounds(imhtml->text_buffer, &start, &end); |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4431 | remove_func(imhtml, &start, &end, TRUE); |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4432 | } |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4433 | else |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4434 | { |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4435 | if (imhtml->editable && gtk_text_buffer_get_selection_bounds(imhtml->text_buffer, &start, &end)) |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4436 | remove_func(imhtml, &start, &end, TRUE); |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4437 | } |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4438 | } |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4439 | |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4440 | object = g_object_ref(G_OBJECT(imhtml)); |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4441 | g_signal_emit(object, signals[TOGGLE_FORMAT], 0, button); |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4442 | g_object_unref(object); |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4443 | |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4444 | return *edit_field != NULL; |
| 10776 | 4445 | } |
| 4446 | ||
| 8061 | 4447 | gboolean gtk_imhtml_toggle_forecolor(GtkIMHtml *imhtml, const char *color) |
| 4448 | { | |
|
13225
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4449 | return gtk_imhtml_toggle_str_tag(imhtml, color, &imhtml->edit.forecolor, |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4450 | remove_font_forecolor, find_font_forecolor_tag, |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4451 | GTK_IMHTML_FORECOLOR); |
| 8061 | 4452 | } |
| 4453 | ||
| 4454 | gboolean gtk_imhtml_toggle_backcolor(GtkIMHtml *imhtml, const char *color) | |
| 4455 | { | |
|
13225
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4456 | return gtk_imhtml_toggle_str_tag(imhtml, color, &imhtml->edit.backcolor, |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4457 | remove_font_backcolor, find_font_backcolor_tag, |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4458 | GTK_IMHTML_BACKCOLOR); |
| 10776 | 4459 | } |
| 4460 | ||
| 4461 | gboolean gtk_imhtml_toggle_background(GtkIMHtml *imhtml, const char *color) | |
| 4462 | { | |
|
13225
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4463 | return gtk_imhtml_toggle_str_tag(imhtml, color, &imhtml->edit.background, |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4464 | remove_font_background, find_font_background_tag, |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4465 | GTK_IMHTML_BACKGROUND); |
| 8061 | 4466 | } |
| 4467 | ||
| 4468 | gboolean gtk_imhtml_toggle_fontface(GtkIMHtml *imhtml, const char *face) | |
| 4469 | { | |
|
13225
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4470 | return gtk_imhtml_toggle_str_tag(imhtml, face, &imhtml->edit.fontface, |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4471 | remove_font_face, find_font_face_tag, |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4472 | GTK_IMHTML_FACE); |
| 8061 | 4473 | } |
| 4474 | ||
| 8677 | 4475 | void gtk_imhtml_toggle_link(GtkIMHtml *imhtml, const char *url) |
| 8061 | 4476 | { |
| 9025 | 4477 | GObject *object; |
| 8677 | 4478 | GtkTextIter start, end; |
| 4479 | GtkTextTag *linktag; | |
| 4480 | static guint linkno = 0; | |
| 4481 | gchar str[48]; | |
| 9007 | 4482 | GdkColor *color = NULL; |
| 8677 | 4483 | |
| 4484 | imhtml->edit.link = NULL; | |
| 4485 | ||
| 4486 | if (url) { | |
| 4487 | g_snprintf(str, sizeof(str), "LINK %d", linkno++); | |
| 4488 | str[47] = '\0'; | |
| 4489 | ||
| 9007 | 4490 | gtk_widget_style_get(GTK_WIDGET(imhtml), "hyperlink-color", &color, NULL); |
| 9008 | 4491 | if (color) { |
| 9007 | 4492 | imhtml->edit.link = linktag = gtk_text_buffer_create_tag(imhtml->text_buffer, str, "foreground-gdk", color, "underline", PANGO_UNDERLINE_SINGLE, NULL); |
| 9008 | 4493 | gdk_color_free(color); |
| 4494 | } else { | |
| 9007 | 4495 | imhtml->edit.link = linktag = gtk_text_buffer_create_tag(imhtml->text_buffer, str, "foreground", "blue", "underline", PANGO_UNDERLINE_SINGLE, NULL); |
| 9008 | 4496 | } |
| 8677 | 4497 | g_object_set_data_full(G_OBJECT(linktag), "link_url", g_strdup(url), g_free); |
| 4498 | g_signal_connect(G_OBJECT(linktag), "event", G_CALLBACK(tag_event), NULL); | |
| 4499 | ||
|
11276
aec923529d31
[gaim-migrate @ 13463]
Richard Laager <rlaager@pidgin.im>
parents:
11275
diff
changeset
|
4500 | if (imhtml->editable && gtk_text_buffer_get_selection_bounds(imhtml->text_buffer, &start, &end)) { |
| 8677 | 4501 | remove_font_link(imhtml, &start, &end, FALSE); |
| 4502 | gtk_text_buffer_apply_tag(imhtml->text_buffer, linktag, &start, &end); | |
| 4503 | } | |
| 4504 | } | |
| 9025 | 4505 | |
| 4506 | object = g_object_ref(G_OBJECT(imhtml)); | |
| 4507 | g_signal_emit(object, signals[TOGGLE_FORMAT], 0, GTK_IMHTML_LINK); | |
| 4508 | g_object_unref(object); | |
| 8677 | 4509 | } |
| 4510 | ||
| 4511 | void gtk_imhtml_insert_link(GtkIMHtml *imhtml, GtkTextMark *mark, const char *url, const char *text) | |
| 4512 | { | |
| 8061 | 4513 | GtkTextIter iter; |
| 8677 | 4514 | |
| 9599 | 4515 | if (gtk_text_buffer_get_selection_bounds(imhtml->text_buffer, NULL, NULL)) |
| 4516 | gtk_text_buffer_delete_selection(imhtml->text_buffer, TRUE, TRUE); | |
| 4517 | ||
| 8677 | 4518 | gtk_imhtml_toggle_link(imhtml, url); |
| 8061 | 4519 | gtk_text_buffer_get_iter_at_mark(imhtml->text_buffer, &iter, mark); |
| 8677 | 4520 | gtk_text_buffer_insert(imhtml->text_buffer, &iter, text, -1); |
| 4521 | gtk_imhtml_toggle_link(imhtml, NULL); | |
| 8061 | 4522 | } |
| 4523 | ||
| 4524 | void gtk_imhtml_insert_smiley(GtkIMHtml *imhtml, const char *sml, char *smiley) | |
| 4525 | { | |
| 8677 | 4526 | GtkTextMark *mark; |
| 8061 | 4527 | GtkTextIter iter; |
| 8677 | 4528 | |
|
11750
63f951281392
[gaim-migrate @ 14041]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11701
diff
changeset
|
4529 | if (gtk_text_buffer_get_selection_bounds(imhtml->text_buffer, NULL, NULL)) |
|
63f951281392
[gaim-migrate @ 14041]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11701
diff
changeset
|
4530 | gtk_text_buffer_delete_selection(imhtml->text_buffer, TRUE, TRUE); |
|
63f951281392
[gaim-migrate @ 14041]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11701
diff
changeset
|
4531 | |
| 8677 | 4532 | mark = gtk_text_buffer_get_insert(imhtml->text_buffer); |
| 4533 | ||
| 4534 | gtk_text_buffer_get_iter_at_mark(imhtml->text_buffer, &iter, mark); | |
| 4535 | gtk_imhtml_insert_smiley_at_iter(imhtml, sml, smiley, &iter); | |
| 4536 | } | |
| 4537 | ||
| 13552 | 4538 | static gboolean |
| 4539 | image_expose(GtkWidget *widget, GdkEventExpose *event, gpointer user_data) | |
| 4540 | { | |
| 4541 | GTK_WIDGET_CLASS(GTK_WIDGET_GET_CLASS(widget))->expose_event(widget, event); | |
| 4542 | ||
| 4543 | return TRUE; | |
| 4544 | } | |
| 4545 | ||
|
16385
aa5b9456e258
Fixes #213 This allows only 20 animated smileys to be animnating at a time
Sean Egan <seanegan@pidgin.im>
parents:
16291
diff
changeset
|
4546 | /* In case the smiley gets removed from the imhtml before it gets removed from the queue */ |
|
aa5b9456e258
Fixes #213 This allows only 20 animated smileys to be animnating at a time
Sean Egan <seanegan@pidgin.im>
parents:
16291
diff
changeset
|
4547 | static void animated_smiley_destroy_cb(GtkObject *widget, GtkIMHtml *imhtml) |
|
aa5b9456e258
Fixes #213 This allows only 20 animated smileys to be animnating at a time
Sean Egan <seanegan@pidgin.im>
parents:
16291
diff
changeset
|
4548 | { |
|
aa5b9456e258
Fixes #213 This allows only 20 animated smileys to be animnating at a time
Sean Egan <seanegan@pidgin.im>
parents:
16291
diff
changeset
|
4549 | GList *l = imhtml->animations->head; |
|
aa5b9456e258
Fixes #213 This allows only 20 animated smileys to be animnating at a time
Sean Egan <seanegan@pidgin.im>
parents:
16291
diff
changeset
|
4550 | while (l) { |
|
aa5b9456e258
Fixes #213 This allows only 20 animated smileys to be animnating at a time
Sean Egan <seanegan@pidgin.im>
parents:
16291
diff
changeset
|
4551 | GList *next = l->next; |
|
aa5b9456e258
Fixes #213 This allows only 20 animated smileys to be animnating at a time
Sean Egan <seanegan@pidgin.im>
parents:
16291
diff
changeset
|
4552 | if (l->data == widget) { |
|
aa5b9456e258
Fixes #213 This allows only 20 animated smileys to be animnating at a time
Sean Egan <seanegan@pidgin.im>
parents:
16291
diff
changeset
|
4553 | if (l == imhtml->animations->tail) |
|
aa5b9456e258
Fixes #213 This allows only 20 animated smileys to be animnating at a time
Sean Egan <seanegan@pidgin.im>
parents:
16291
diff
changeset
|
4554 | imhtml->animations->tail = imhtml->animations->tail->prev; |
|
aa5b9456e258
Fixes #213 This allows only 20 animated smileys to be animnating at a time
Sean Egan <seanegan@pidgin.im>
parents:
16291
diff
changeset
|
4555 | imhtml->animations->head = g_list_delete_link(imhtml->animations->head, l); |
|
aa5b9456e258
Fixes #213 This allows only 20 animated smileys to be animnating at a time
Sean Egan <seanegan@pidgin.im>
parents:
16291
diff
changeset
|
4556 | imhtml->num_animations--; |
|
aa5b9456e258
Fixes #213 This allows only 20 animated smileys to be animnating at a time
Sean Egan <seanegan@pidgin.im>
parents:
16291
diff
changeset
|
4557 | } |
|
aa5b9456e258
Fixes #213 This allows only 20 animated smileys to be animnating at a time
Sean Egan <seanegan@pidgin.im>
parents:
16291
diff
changeset
|
4558 | l = next; |
|
aa5b9456e258
Fixes #213 This allows only 20 animated smileys to be animnating at a time
Sean Egan <seanegan@pidgin.im>
parents:
16291
diff
changeset
|
4559 | } |
|
aa5b9456e258
Fixes #213 This allows only 20 animated smileys to be animnating at a time
Sean Egan <seanegan@pidgin.im>
parents:
16291
diff
changeset
|
4560 | } |
|
aa5b9456e258
Fixes #213 This allows only 20 animated smileys to be animnating at a time
Sean Egan <seanegan@pidgin.im>
parents:
16291
diff
changeset
|
4561 | |
| 8677 | 4562 | void gtk_imhtml_insert_smiley_at_iter(GtkIMHtml *imhtml, const char *sml, char *smiley, GtkTextIter *iter) |
| 4563 | { | |
| 8061 | 4564 | GdkPixbuf *pixbuf = NULL; |
| 4565 | GdkPixbufAnimation *annipixbuf = NULL; | |
| 4566 | GtkWidget *icon = NULL; | |
|
17009
2cc9edf33feb
Allow saving custom smileys by right-clicking on them. And use the custom smileys only on the received messages, not for the system/etc. messages.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16385
diff
changeset
|
4567 | GtkTextChildAnchor *anchor = NULL; |
| 15884 | 4568 | char *unescaped = purple_unescape_html(smiley); |
|
11525
1d06283bdcc9
[gaim-migrate @ 13773]
Francesco Fracassi <ffracassi@users.sourceforge.net>
parents:
11485
diff
changeset
|
4569 | GtkIMHtmlSmiley *imhtml_smiley = gtk_imhtml_smiley_get(imhtml, sml, unescaped); |
|
17009
2cc9edf33feb
Allow saving custom smileys by right-clicking on them. And use the custom smileys only on the received messages, not for the system/etc. messages.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16385
diff
changeset
|
4570 | GtkWidget *ebox = NULL; |
| 8061 | 4571 | |
| 10526 | 4572 | if (imhtml->format_functions & GTK_IMHTML_SMILEY) { |
|
10522
d505522bcc93
[gaim-migrate @ 11838]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10504
diff
changeset
|
4573 | annipixbuf = gtk_smiley_tree_image(imhtml, sml, unescaped); |
| 10526 | 4574 | if (annipixbuf) { |
| 4575 | if (gdk_pixbuf_animation_is_static_image(annipixbuf)) { | |
|
10522
d505522bcc93
[gaim-migrate @ 11838]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10504
diff
changeset
|
4576 | pixbuf = gdk_pixbuf_animation_get_static_image(annipixbuf); |
| 10526 | 4577 | if (pixbuf) |
|
10522
d505522bcc93
[gaim-migrate @ 11838]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10504
diff
changeset
|
4578 | icon = gtk_image_new_from_pixbuf(pixbuf); |
|
d505522bcc93
[gaim-migrate @ 11838]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10504
diff
changeset
|
4579 | } else { |
|
d505522bcc93
[gaim-migrate @ 11838]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10504
diff
changeset
|
4580 | icon = gtk_image_new_from_animation(annipixbuf); |
|
16385
aa5b9456e258
Fixes #213 This allows only 20 animated smileys to be animnating at a time
Sean Egan <seanegan@pidgin.im>
parents:
16291
diff
changeset
|
4581 | if (imhtml->num_animations == 20) { |
|
aa5b9456e258
Fixes #213 This allows only 20 animated smileys to be animnating at a time
Sean Egan <seanegan@pidgin.im>
parents:
16291
diff
changeset
|
4582 | GtkImage *image = GTK_IMAGE(g_queue_pop_head(imhtml->animations)); |
|
aa5b9456e258
Fixes #213 This allows only 20 animated smileys to be animnating at a time
Sean Egan <seanegan@pidgin.im>
parents:
16291
diff
changeset
|
4583 | GdkPixbufAnimation *anim = gtk_image_get_animation(image); |
|
aa5b9456e258
Fixes #213 This allows only 20 animated smileys to be animnating at a time
Sean Egan <seanegan@pidgin.im>
parents:
16291
diff
changeset
|
4584 | if (anim) { |
|
aa5b9456e258
Fixes #213 This allows only 20 animated smileys to be animnating at a time
Sean Egan <seanegan@pidgin.im>
parents:
16291
diff
changeset
|
4585 | GdkPixbuf *pb = gdk_pixbuf_animation_get_static_image(anim); |
|
aa5b9456e258
Fixes #213 This allows only 20 animated smileys to be animnating at a time
Sean Egan <seanegan@pidgin.im>
parents:
16291
diff
changeset
|
4586 | gtk_image_set_from_pixbuf(image, pb); |
|
17009
2cc9edf33feb
Allow saving custom smileys by right-clicking on them. And use the custom smileys only on the received messages, not for the system/etc. messages.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16385
diff
changeset
|
4587 | g_object_unref(G_OBJECT(pb)); |
|
16385
aa5b9456e258
Fixes #213 This allows only 20 animated smileys to be animnating at a time
Sean Egan <seanegan@pidgin.im>
parents:
16291
diff
changeset
|
4588 | } |
|
aa5b9456e258
Fixes #213 This allows only 20 animated smileys to be animnating at a time
Sean Egan <seanegan@pidgin.im>
parents:
16291
diff
changeset
|
4589 | } else { |
|
aa5b9456e258
Fixes #213 This allows only 20 animated smileys to be animnating at a time
Sean Egan <seanegan@pidgin.im>
parents:
16291
diff
changeset
|
4590 | imhtml->num_animations++; |
|
aa5b9456e258
Fixes #213 This allows only 20 animated smileys to be animnating at a time
Sean Egan <seanegan@pidgin.im>
parents:
16291
diff
changeset
|
4591 | } |
|
aa5b9456e258
Fixes #213 This allows only 20 animated smileys to be animnating at a time
Sean Egan <seanegan@pidgin.im>
parents:
16291
diff
changeset
|
4592 | g_signal_connect(G_OBJECT(icon), "destroy", G_CALLBACK(animated_smiley_destroy_cb), imhtml); |
|
aa5b9456e258
Fixes #213 This allows only 20 animated smileys to be animnating at a time
Sean Egan <seanegan@pidgin.im>
parents:
16291
diff
changeset
|
4593 | g_queue_push_tail(imhtml->animations, icon); |
|
10522
d505522bcc93
[gaim-migrate @ 11838]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10504
diff
changeset
|
4594 | } |
| 8061 | 4595 | } |
| 4596 | } | |
| 4597 | ||
|
17189
7d0cf54d0f32
Do not crash when trying to insert a smiley for a protocol not mentioned
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17136
diff
changeset
|
4598 | if (imhtml_smiley && imhtml_smiley->flags & GTK_IMHTML_SMILEY_CUSTOM) { |
|
17009
2cc9edf33feb
Allow saving custom smileys by right-clicking on them. And use the custom smileys only on the received messages, not for the system/etc. messages.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16385
diff
changeset
|
4599 | ebox = gtk_event_box_new(); |
| 17406 | 4600 | #if GTK_CHECK_VERSION(2,4,0) |
|
17009
2cc9edf33feb
Allow saving custom smileys by right-clicking on them. And use the custom smileys only on the received messages, not for the system/etc. messages.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16385
diff
changeset
|
4601 | gtk_event_box_set_visible_window(GTK_EVENT_BOX(ebox), FALSE); |
| 17406 | 4602 | #endif |
|
17009
2cc9edf33feb
Allow saving custom smileys by right-clicking on them. And use the custom smileys only on the received messages, not for the system/etc. messages.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16385
diff
changeset
|
4603 | gtk_widget_show(ebox); |
|
2cc9edf33feb
Allow saving custom smileys by right-clicking on them. And use the custom smileys only on the received messages, not for the system/etc. messages.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16385
diff
changeset
|
4604 | } |
|
2cc9edf33feb
Allow saving custom smileys by right-clicking on them. And use the custom smileys only on the received messages, not for the system/etc. messages.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16385
diff
changeset
|
4605 | |
| 8061 | 4606 | if (icon) { |
| 8890 | 4607 | anchor = gtk_text_buffer_create_child_anchor(imhtml->text_buffer, iter); |
| 4608 | g_object_set_data_full(G_OBJECT(anchor), "gtkimhtml_plaintext", g_strdup(unescaped), g_free); | |
| 4609 | g_object_set_data_full(G_OBJECT(anchor), "gtkimhtml_htmltext", g_strdup(smiley), g_free); | |
| 4610 | ||
| 13552 | 4611 | /* This catches the expose events generated by animated |
| 4612 | * images, and ensures that they are handled by the image | |
| 4613 | * itself, without propagating to the textview and causing | |
| 4614 | * a complete refresh */ | |
| 4615 | g_signal_connect(G_OBJECT(icon), "expose-event", G_CALLBACK(image_expose), NULL); | |
| 4616 | ||
| 8061 | 4617 | gtk_widget_show(icon); |
|
17009
2cc9edf33feb
Allow saving custom smileys by right-clicking on them. And use the custom smileys only on the received messages, not for the system/etc. messages.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16385
diff
changeset
|
4618 | if (ebox) |
|
2cc9edf33feb
Allow saving custom smileys by right-clicking on them. And use the custom smileys only on the received messages, not for the system/etc. messages.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16385
diff
changeset
|
4619 | gtk_container_add(GTK_CONTAINER(ebox), icon); |
|
2cc9edf33feb
Allow saving custom smileys by right-clicking on them. And use the custom smileys only on the received messages, not for the system/etc. messages.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16385
diff
changeset
|
4620 | gtk_text_view_add_child_at_anchor(GTK_TEXT_VIEW(imhtml), ebox ? ebox : icon, anchor); |
|
11525
1d06283bdcc9
[gaim-migrate @ 13773]
Francesco Fracassi <ffracassi@users.sourceforge.net>
parents:
11485
diff
changeset
|
4621 | } else if (imhtml_smiley != NULL && (imhtml->format_functions & GTK_IMHTML_SMILEY)) { |
|
1d06283bdcc9
[gaim-migrate @ 13773]
Francesco Fracassi <ffracassi@users.sourceforge.net>
parents:
11485
diff
changeset
|
4622 | anchor = gtk_text_buffer_create_child_anchor(imhtml->text_buffer, iter); |
|
1d06283bdcc9
[gaim-migrate @ 13773]
Francesco Fracassi <ffracassi@users.sourceforge.net>
parents:
11485
diff
changeset
|
4623 | imhtml_smiley->anchors = g_slist_append(imhtml_smiley->anchors, anchor); |
|
17009
2cc9edf33feb
Allow saving custom smileys by right-clicking on them. And use the custom smileys only on the received messages, not for the system/etc. messages.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16385
diff
changeset
|
4624 | if (ebox) { |
|
2cc9edf33feb
Allow saving custom smileys by right-clicking on them. And use the custom smileys only on the received messages, not for the system/etc. messages.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16385
diff
changeset
|
4625 | GtkWidget *img = gtk_image_new_from_stock(GTK_STOCK_MISSING_IMAGE, GTK_ICON_SIZE_MENU); |
|
2cc9edf33feb
Allow saving custom smileys by right-clicking on them. And use the custom smileys only on the received messages, not for the system/etc. messages.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16385
diff
changeset
|
4626 | gtk_container_add(GTK_CONTAINER(ebox), img); |
|
2cc9edf33feb
Allow saving custom smileys by right-clicking on them. And use the custom smileys only on the received messages, not for the system/etc. messages.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16385
diff
changeset
|
4627 | gtk_widget_show(img); |
|
18543
c590aed61aa4
Show tooltip for smileys. Fixes #1981.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18371
diff
changeset
|
4628 | g_object_set_data_full(G_OBJECT(anchor), "gtkimhtml_plaintext", g_strdup(unescaped), g_free); |
|
17009
2cc9edf33feb
Allow saving custom smileys by right-clicking on them. And use the custom smileys only on the received messages, not for the system/etc. messages.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16385
diff
changeset
|
4629 | gtk_text_view_add_child_at_anchor(GTK_TEXT_VIEW(imhtml), ebox, anchor); |
|
2cc9edf33feb
Allow saving custom smileys by right-clicking on them. And use the custom smileys only on the received messages, not for the system/etc. messages.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16385
diff
changeset
|
4630 | } |
| 8890 | 4631 | } else { |
| 4632 | gtk_text_buffer_insert(imhtml->text_buffer, iter, smiley, -1); | |
| 8061 | 4633 | } |
| 8890 | 4634 | |
|
17009
2cc9edf33feb
Allow saving custom smileys by right-clicking on them. And use the custom smileys only on the received messages, not for the system/etc. messages.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16385
diff
changeset
|
4635 | if (ebox) { |
|
2cc9edf33feb
Allow saving custom smileys by right-clicking on them. And use the custom smileys only on the received messages, not for the system/etc. messages.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16385
diff
changeset
|
4636 | g_signal_connect(G_OBJECT(ebox), "event", G_CALLBACK(gtk_imhtml_smiley_clicked), imhtml_smiley); |
|
2cc9edf33feb
Allow saving custom smileys by right-clicking on them. And use the custom smileys only on the received messages, not for the system/etc. messages.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16385
diff
changeset
|
4637 | } |
|
2cc9edf33feb
Allow saving custom smileys by right-clicking on them. And use the custom smileys only on the received messages, not for the system/etc. messages.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16385
diff
changeset
|
4638 | |
| 8890 | 4639 | g_free(unescaped); |
| 8061 | 4640 | } |
| 4641 | ||
| 8962 | 4642 | void gtk_imhtml_insert_image_at_iter(GtkIMHtml *imhtml, int id, GtkTextIter *iter) |
| 4643 | { | |
|
18151
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
4644 | GdkPixbufAnimation *anim = NULL; |
| 8962 | 4645 | const char *filename = NULL; |
| 4646 | gpointer image; | |
| 4647 | GdkRectangle rect; | |
| 4648 | GtkIMHtmlScalable *scalable = NULL; | |
|
11224
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
4649 | struct scalable_data *sd; |
| 8962 | 4650 | int minus; |
| 4651 | ||
| 4652 | if (!imhtml->funcs || !imhtml->funcs->image_get || | |
| 4653 | !imhtml->funcs->image_get_size || !imhtml->funcs->image_get_data || | |
| 4654 | !imhtml->funcs->image_get_filename || !imhtml->funcs->image_ref || | |
| 4655 | !imhtml->funcs->image_unref) | |
| 4656 | return; | |
| 4657 | ||
| 4658 | image = imhtml->funcs->image_get(id); | |
| 4659 | ||
| 4660 | if (image) { | |
| 4661 | gpointer data; | |
| 4662 | size_t len; | |
| 4663 | ||
| 4664 | data = imhtml->funcs->image_get_data(image); | |
| 4665 | len = imhtml->funcs->image_get_size(image); | |
| 4666 | ||
| 4667 | if (data && len) { | |
| 4668 | GdkPixbufLoader *loader = gdk_pixbuf_loader_new(); | |
| 4669 | gdk_pixbuf_loader_write(loader, data, len, NULL); | |
|
12230
2f327bccf63b
[gaim-migrate @ 14532]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12229
diff
changeset
|
4670 | gdk_pixbuf_loader_close(loader, NULL); |
|
18151
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
4671 | anim = gdk_pixbuf_loader_get_animation(loader); |
|
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
4672 | if (anim) |
|
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
4673 | g_object_ref(G_OBJECT(anim)); |
| 9337 | 4674 | g_object_unref(G_OBJECT(loader)); |
| 8962 | 4675 | } |
| 4676 | ||
| 4677 | } | |
| 4678 | ||
|
18151
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
4679 | if (anim) { |
|
11299
06bb44ed0cf3
[gaim-migrate @ 13499]
Richard Laager <rlaager@pidgin.im>
parents:
11276
diff
changeset
|
4680 | struct im_image_data *t = g_new(struct im_image_data, 1); |
| 8962 | 4681 | filename = imhtml->funcs->image_get_filename(image); |
| 4682 | imhtml->funcs->image_ref(id); | |
|
11224
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
4683 | t->id = id; |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
4684 | t->mark = gtk_text_buffer_create_mark(imhtml->text_buffer, NULL, iter, TRUE); |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
4685 | imhtml->im_images = g_slist_prepend(imhtml->im_images, t); |
|
18151
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
4686 | scalable = gtk_imhtml_animation_new(anim, filename, id); |
|
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
4687 | g_object_unref(G_OBJECT(anim)); |
| 8962 | 4688 | } else { |
|
18151
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
4689 | GdkPixbuf *pixbuf; |
| 8962 | 4690 | pixbuf = gtk_widget_render_icon(GTK_WIDGET(imhtml), GTK_STOCK_MISSING_IMAGE, |
| 4691 | GTK_ICON_SIZE_BUTTON, "gtkimhtml-missing-image"); | |
|
18151
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
4692 | scalable = gtk_imhtml_image_new(pixbuf, filename, id); |
|
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
4693 | g_object_unref(G_OBJECT(pixbuf)); |
| 8962 | 4694 | } |
| 4695 | ||
|
11224
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
4696 | sd = g_new(struct scalable_data, 1); |
|
18151
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
4697 | sd->scalable = scalable; |
|
11233
28c0f184a2d4
[gaim-migrate @ 13373]
Daniel Atallah <datallah@pidgin.im>
parents:
11224
diff
changeset
|
4698 | sd->mark = gtk_text_buffer_create_mark(imhtml->text_buffer, NULL, iter, TRUE); |
| 8962 | 4699 | gtk_text_view_get_visible_rect(GTK_TEXT_VIEW(imhtml), &rect); |
| 4700 | scalable->add_to(scalable, imhtml, iter); | |
| 4701 | minus = gtk_text_view_get_left_margin(GTK_TEXT_VIEW(imhtml)) + | |
| 4702 | gtk_text_view_get_right_margin(GTK_TEXT_VIEW(imhtml)); | |
| 4703 | scalable->scale(scalable, rect.width - minus, rect.height); | |
|
11224
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
4704 | imhtml->scalables = g_list_append(imhtml->scalables, sd); |
| 8962 | 4705 | } |
| 4706 | ||
| 8677 | 4707 | static const gchar *tag_to_html_start(GtkTextTag *tag) |
| 8061 | 4708 | { |
| 8677 | 4709 | const gchar *name; |
| 4710 | static gchar buf[1024]; | |
| 4711 | ||
| 4712 | name = tag->name; | |
| 4713 | g_return_val_if_fail(name != NULL, ""); | |
| 4714 | ||
| 4715 | if (strcmp(name, "BOLD") == 0) { | |
| 4716 | return "<b>"; | |
| 4717 | } else if (strcmp(name, "ITALICS") == 0) { | |
| 4718 | return "<i>"; | |
| 4719 | } else if (strcmp(name, "UNDERLINE") == 0) { | |
| 4720 | return "<u>"; | |
| 9924 | 4721 | } else if (strcmp(name, "STRIKE") == 0) { |
| 4722 | return "<s>"; | |
| 8677 | 4723 | } else if (strncmp(name, "LINK ", 5) == 0) { |
| 4724 | char *tmp = g_object_get_data(G_OBJECT(tag), "link_url"); | |
| 4725 | if (tmp) { | |
| 4726 | g_snprintf(buf, sizeof(buf), "<a href=\"%s\">", tmp); | |
| 4727 | buf[sizeof(buf)-1] = '\0'; | |
| 4728 | return buf; | |
| 4729 | } else { | |
| 4730 | return ""; | |
| 4731 | } | |
| 4732 | } else if (strncmp(name, "FORECOLOR ", 10) == 0) { | |
| 4733 | g_snprintf(buf, sizeof(buf), "<font color=\"%s\">", &name[10]); | |
| 4734 | return buf; | |
| 4735 | } else if (strncmp(name, "BACKCOLOR ", 10) == 0) { | |
| 4736 | g_snprintf(buf, sizeof(buf), "<font back=\"%s\">", &name[10]); | |
| 4737 | return buf; | |
| 10776 | 4738 | } else if (strncmp(name, "BACKGROUND ", 10) == 0) { |
| 4739 | g_snprintf(buf, sizeof(buf), "<body bgcolor=\"%s\">", &name[11]); | |
| 4740 | return buf; | |
| 8677 | 4741 | } else if (strncmp(name, "FONT FACE ", 10) == 0) { |
| 4742 | g_snprintf(buf, sizeof(buf), "<font face=\"%s\">", &name[10]); | |
| 4743 | return buf; | |
| 4744 | } else if (strncmp(name, "FONT SIZE ", 10) == 0) { | |
| 4745 | g_snprintf(buf, sizeof(buf), "<font size=\"%s\">", &name[10]); | |
| 4746 | return buf; | |
| 4747 | } else { | |
| 4748 | return ""; | |
| 4749 | } | |
| 8061 | 4750 | } |
| 4751 | ||
| 8677 | 4752 | static const gchar *tag_to_html_end(GtkTextTag *tag) |
| 8061 | 4753 | { |
| 8677 | 4754 | const gchar *name; |
| 4755 | ||
| 4756 | name = tag->name; | |
| 4757 | g_return_val_if_fail(name != NULL, ""); | |
| 4758 | ||
| 4759 | if (strcmp(name, "BOLD") == 0) { | |
| 4760 | return "</b>"; | |
| 4761 | } else if (strcmp(name, "ITALICS") == 0) { | |
| 4762 | return "</i>"; | |
| 4763 | } else if (strcmp(name, "UNDERLINE") == 0) { | |
| 4764 | return "</u>"; | |
| 9924 | 4765 | } else if (strcmp(name, "STRIKE") == 0) { |
| 4766 | return "</s>"; | |
| 8677 | 4767 | } else if (strncmp(name, "LINK ", 5) == 0) { |
| 4768 | return "</a>"; | |
| 4769 | } else if (strncmp(name, "FORECOLOR ", 10) == 0) { | |
| 4770 | return "</font>"; | |
| 4771 | } else if (strncmp(name, "BACKCOLOR ", 10) == 0) { | |
| 4772 | return "</font>"; | |
| 10776 | 4773 | } else if (strncmp(name, "BACKGROUND ", 10) == 0) { |
| 4774 | return "</body>"; | |
| 8677 | 4775 | } else if (strncmp(name, "FONT FACE ", 10) == 0) { |
| 4776 | return "</font>"; | |
| 4777 | } else if (strncmp(name, "FONT SIZE ", 10) == 0) { | |
| 4778 | return "</font>"; | |
| 4779 | } else { | |
| 4780 | return ""; | |
| 4781 | } | |
| 4782 | } | |
| 4783 | ||
| 4784 | static gboolean tag_ends_here(GtkTextTag *tag, GtkTextIter *iter, GtkTextIter *niter) | |
| 4785 | { | |
| 4786 | return ((gtk_text_iter_has_tag(iter, GTK_TEXT_TAG(tag)) && | |
| 4787 | !gtk_text_iter_has_tag(niter, GTK_TEXT_TAG(tag))) || | |
| 4788 | gtk_text_iter_is_end(niter)); | |
| 8061 | 4789 | } |
| 4790 | ||
| 4791 | /* Basic notion here: traverse through the text buffer one-by-one, non-character elements, such | |
| 4792 | * as smileys and IM images are represented by the Unicode "unknown" character. Handle them. Else | |
| 8677 | 4793 | * check for tags that are toggled on, insert their html form, and push them on the queue. Then insert |
| 4794 | * the actual text. Then check for tags that are toggled off and insert them, after checking the queue. | |
|
8735
01248ea222d3
[gaim-migrate @ 9490]
Jonathan Champ <royanee@users.sourceforge.net>
parents:
8729
diff
changeset
|
4795 | * Finally, replace <, >, &, and " with their HTML equivalent. |
| 8677 | 4796 | */ |
| 8061 | 4797 | char *gtk_imhtml_get_markup_range(GtkIMHtml *imhtml, GtkTextIter *start, GtkTextIter *end) |
| 4798 | { | |
| 4799 | gunichar c; | |
|
16143
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
4800 | GtkTextIter iter, next_iter, non_neutral_iter; |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
4801 | gboolean is_rtl_message = FALSE; |
| 8061 | 4802 | GString *str = g_string_new(""); |
| 8677 | 4803 | GSList *tags, *sl; |
| 4804 | GQueue *q, *r; | |
| 4805 | GtkTextTag *tag; | |
| 4806 | ||
| 4807 | q = g_queue_new(); | |
| 4808 | r = g_queue_new(); | |
| 4809 | ||
| 8061 | 4810 | |
| 4811 | gtk_text_iter_order(start, end); | |
|
16143
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
4812 | non_neutral_iter = next_iter = iter = *start; |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
4813 | gtk_text_iter_forward_char(&next_iter); |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
4814 | |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
4815 | /* Bi-directional text support */ |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
4816 | /* Get to the first non-neutral character */ |
|
16291
acbfc9276da1
Fix for using Pango < 1.4, will not have complete RTL support with older
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16254
diff
changeset
|
4817 | #ifdef HAVE_PANGO14 |
| 16144 | 4818 | while ((PANGO_DIRECTION_NEUTRAL == pango_unichar_direction(gtk_text_iter_get_char(&non_neutral_iter))) |
|
16143
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
4819 | && gtk_text_iter_forward_char(&non_neutral_iter)); |
| 16144 | 4820 | if (PANGO_DIRECTION_RTL == pango_unichar_direction(gtk_text_iter_get_char(&non_neutral_iter))) { |
|
16143
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
4821 | is_rtl_message = TRUE; |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
4822 | g_string_append(str, "<SPAN style=\"direction:rtl;text-align:right;\">"); |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
4823 | } |
|
16291
acbfc9276da1
Fix for using Pango < 1.4, will not have complete RTL support with older
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16254
diff
changeset
|
4824 | #endif |
| 8677 | 4825 | |
| 9071 | 4826 | /* First add the tags that are already in progress (we don't care about non-printing tags)*/ |
| 8677 | 4827 | tags = gtk_text_iter_get_tags(start); |
| 4828 | ||
| 4829 | for (sl = tags; sl; sl = sl->next) { | |
| 4830 | tag = sl->data; | |
| 4831 | if (!gtk_text_iter_toggles_tag(start, GTK_TEXT_TAG(tag))) { | |
| 9071 | 4832 | if (strlen(tag_to_html_end(tag)) > 0) |
|
11572
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
4833 | g_string_append(str, tag_to_html_start(tag)); |
| 8677 | 4834 | g_queue_push_tail(q, tag); |
| 8061 | 4835 | } |
| 4836 | } | |
| 8677 | 4837 | g_slist_free(tags); |
| 8061 | 4838 | |
| 4839 | while ((c = gtk_text_iter_get_char(&iter)) != 0 && !gtk_text_iter_equal(&iter, end)) { | |
| 8677 | 4840 | |
| 4841 | tags = gtk_text_iter_get_tags(&iter); | |
| 4842 | ||
| 4843 | for (sl = tags; sl; sl = sl->next) { | |
| 4844 | tag = sl->data; | |
| 4845 | if (gtk_text_iter_begins_tag(&iter, GTK_TEXT_TAG(tag))) { | |
| 9071 | 4846 | if (strlen(tag_to_html_end(tag)) > 0) |
|
11572
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
4847 | g_string_append(str, tag_to_html_start(tag)); |
| 8677 | 4848 | g_queue_push_tail(q, tag); |
| 4849 | } | |
| 4850 | } | |
| 4851 | ||
| 4852 | ||
| 8061 | 4853 | if (c == 0xFFFC) { |
| 4854 | GtkTextChildAnchor* anchor = gtk_text_iter_get_child_anchor(&iter); | |
| 9071 | 4855 | if (anchor) { |
| 4856 | char *text = g_object_get_data(G_OBJECT(anchor), "gtkimhtml_htmltext"); | |
| 4857 | if (text) | |
| 4858 | str = g_string_append(str, text); | |
| 4859 | } | |
|
11572
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
4860 | } else if (c == '<') { |
| 8677 | 4861 | str = g_string_append(str, "<"); |
| 4862 | } else if (c == '>') { | |
| 4863 | str = g_string_append(str, ">"); | |
| 4864 | } else if (c == '&') { | |
| 4865 | str = g_string_append(str, "&"); | |
| 4866 | } else if (c == '"') { | |
| 4867 | str = g_string_append(str, """); | |
| 4868 | } else if (c == '\n') { | |
| 4869 | str = g_string_append(str, "<br>"); | |
| 8061 | 4870 | } else { |
| 8677 | 4871 | str = g_string_append_unichar(str, c); |
| 4872 | } | |
| 4873 | ||
| 4874 | tags = g_slist_reverse(tags); | |
| 4875 | for (sl = tags; sl; sl = sl->next) { | |
| 4876 | tag = sl->data; | |
| 9071 | 4877 | /** don't worry about non-printing tags ending */ |
|
16143
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
4878 | if (tag_ends_here(tag, &iter, &next_iter) && strlen(tag_to_html_end(tag)) > 0) { |
| 8677 | 4879 | |
| 4880 | GtkTextTag *tmp; | |
| 4881 | ||
| 4882 | while ((tmp = g_queue_pop_tail(q)) != tag) { | |
| 4883 | if (tmp == NULL) | |
| 4884 | break; | |
| 4885 | ||
|
16143
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
4886 | if (!tag_ends_here(tmp, &iter, &next_iter) && strlen(tag_to_html_end(tmp)) > 0) |
| 8677 | 4887 | g_queue_push_tail(r, tmp); |
|
11572
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
4888 | g_string_append(str, tag_to_html_end(GTK_TEXT_TAG(tmp))); |
| 8677 | 4889 | } |
| 4890 | ||
| 4891 | if (tmp == NULL) | |
| 15884 | 4892 | purple_debug_warning("gtkimhtml", "empty queue, more closing tags than open tags!\n"); |
|
11572
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
4893 | else |
| 8677 | 4894 | g_string_append(str, tag_to_html_end(GTK_TEXT_TAG(tag))); |
| 4895 | ||
| 4896 | while ((tmp = g_queue_pop_head(r))) { | |
| 4897 | g_string_append(str, tag_to_html_start(GTK_TEXT_TAG(tmp))); | |
| 4898 | g_queue_push_tail(q, tmp); | |
| 8061 | 4899 | } |
| 4900 | } | |
| 4901 | } | |
| 8677 | 4902 | |
| 4903 | g_slist_free(tags); | |
| 8061 | 4904 | gtk_text_iter_forward_char(&iter); |
|
16143
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
4905 | gtk_text_iter_forward_char(&next_iter); |
| 8061 | 4906 | } |
| 8677 | 4907 | |
| 4908 | while ((tag = g_queue_pop_tail(q))) | |
| 4909 | g_string_append(str, tag_to_html_end(GTK_TEXT_TAG(tag))); | |
| 4910 | ||
|
16143
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
4911 | /* Bi-directional text support - close tags */ |
| 16144 | 4912 | if (is_rtl_message) |
|
16143
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
4913 | g_string_append(str, "</SPAN>"); |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
4914 | |
| 8677 | 4915 | g_queue_free(q); |
| 4916 | g_queue_free(r); | |
| 8061 | 4917 | return g_string_free(str, FALSE); |
| 4918 | } | |
| 4919 | ||
| 8698 | 4920 | void gtk_imhtml_close_tags(GtkIMHtml *imhtml, GtkTextIter *iter) |
| 8061 | 4921 | { |
| 4922 | if (imhtml->edit.bold) | |
| 4923 | gtk_imhtml_toggle_bold(imhtml); | |
| 4924 | ||
| 4925 | if (imhtml->edit.italic) | |
| 4926 | gtk_imhtml_toggle_italic(imhtml); | |
| 4927 | ||
| 4928 | if (imhtml->edit.underline) | |
| 4929 | gtk_imhtml_toggle_underline(imhtml); | |
| 4930 | ||
| 9924 | 4931 | if (imhtml->edit.strike) |
| 4932 | gtk_imhtml_toggle_strike(imhtml); | |
| 4933 | ||
| 8061 | 4934 | if (imhtml->edit.forecolor) |
| 4935 | gtk_imhtml_toggle_forecolor(imhtml, NULL); | |
| 4936 | ||
| 4937 | if (imhtml->edit.backcolor) | |
| 4938 | gtk_imhtml_toggle_backcolor(imhtml, NULL); | |
| 4939 | ||
| 4940 | if (imhtml->edit.fontface) | |
| 4941 | gtk_imhtml_toggle_fontface(imhtml, NULL); | |
| 4942 | ||
| 8677 | 4943 | imhtml->edit.fontsize = 0; |
| 4944 | ||
| 8719 | 4945 | if (imhtml->edit.link) |
| 4946 | gtk_imhtml_toggle_link(imhtml, NULL); | |
| 8061 | 4947 | } |
| 4948 | ||
| 4949 | char *gtk_imhtml_get_markup(GtkIMHtml *imhtml) | |
| 4950 | { | |
| 4951 | GtkTextIter start, end; | |
| 4952 | ||
| 4953 | gtk_text_buffer_get_start_iter(imhtml->text_buffer, &start); | |
| 4954 | gtk_text_buffer_get_end_iter(imhtml->text_buffer, &end); | |
| 4955 | return gtk_imhtml_get_markup_range(imhtml, &start, &end); | |
| 4956 | } | |
| 4957 | ||
| 8677 | 4958 | char **gtk_imhtml_get_markup_lines(GtkIMHtml *imhtml) |
| 4959 | { | |
| 4960 | int i, j, lines; | |
| 4961 | GtkTextIter start, end; | |
| 4962 | char **ret; | |
| 4963 | ||
| 4964 | lines = gtk_text_buffer_get_line_count(imhtml->text_buffer); | |
| 4965 | ret = g_new0(char *, lines + 1); | |
| 4966 | gtk_text_buffer_get_start_iter(imhtml->text_buffer, &start); | |
| 4967 | end = start; | |
| 4968 | gtk_text_iter_forward_to_line_end(&end); | |
| 4969 | ||
| 4970 | for (i = 0, j = 0; i < lines; i++) { | |
| 9612 | 4971 | if (gtk_text_iter_get_char(&start) != '\n') { |
| 4972 | ret[j] = gtk_imhtml_get_markup_range(imhtml, &start, &end); | |
| 4973 | if (ret[j] != NULL) | |
| 4974 | j++; | |
| 4975 | } | |
| 4976 | ||
| 8677 | 4977 | gtk_text_iter_forward_line(&start); |
| 4978 | end = start; | |
| 4979 | gtk_text_iter_forward_to_line_end(&end); | |
| 4980 | } | |
| 4981 | ||
| 4982 | return ret; | |
| 4983 | } | |
| 4984 | ||
| 4985 | char *gtk_imhtml_get_text(GtkIMHtml *imhtml, GtkTextIter *start, GtkTextIter *stop) | |
| 8061 | 4986 | { |
| 8519 | 4987 | GString *str = g_string_new(""); |
| 4988 | GtkTextIter iter, end; | |
| 4989 | gunichar c; | |
| 4990 | ||
| 8677 | 4991 | if (start == NULL) |
| 4992 | gtk_text_buffer_get_start_iter(imhtml->text_buffer, &iter); | |
| 4993 | else | |
| 4994 | iter = *start; | |
| 4995 | ||
| 4996 | if (stop == NULL) | |
| 4997 | gtk_text_buffer_get_end_iter(imhtml->text_buffer, &end); | |
| 4998 | else | |
| 4999 | end = *stop; | |
| 5000 | ||
| 5001 | gtk_text_iter_order(&iter, &end); | |
| 8519 | 5002 | |
| 5003 | while ((c = gtk_text_iter_get_char(&iter)) != 0 && !gtk_text_iter_equal(&iter, &end)) { | |
| 5004 | if (c == 0xFFFC) { | |
| 8677 | 5005 | GtkTextChildAnchor* anchor; |
| 5006 | char *text = NULL; | |
| 5007 | ||
| 5008 | anchor = gtk_text_iter_get_child_anchor(&iter); | |
| 5009 | if (anchor) | |
| 8698 | 5010 | text = g_object_get_data(G_OBJECT(anchor), "gtkimhtml_plaintext"); |
| 8677 | 5011 | if (text) |
| 5012 | str = g_string_append(str, text); | |
| 8519 | 5013 | } else { |
| 5014 | g_string_append_unichar(str, c); | |
| 5015 | } | |
| 5016 | gtk_text_iter_forward_char(&iter); | |
| 5017 | } | |
| 5018 | ||
| 5019 | return g_string_free(str, FALSE); | |
| 8061 | 5020 | } |
| 8962 | 5021 | |
| 5022 | void gtk_imhtml_set_funcs(GtkIMHtml *imhtml, GtkIMHtmlFuncs *f) | |
| 5023 | { | |
| 5024 | g_return_if_fail(imhtml != NULL); | |
| 5025 | imhtml->funcs = f; | |
| 5026 | } | |
|
17388
8be39f0de528
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17288
diff
changeset
|
5027 | |
|
8be39f0de528
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17288
diff
changeset
|
5028 | void gtk_imhtml_setup_entry(GtkIMHtml *imhtml, PurpleConnectionFlags flags) |
|
8be39f0de528
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17288
diff
changeset
|
5029 | { |
|
18240
0a7d2fde749b
Fix setting the sensitivity of the toolbar items in a number of places
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
18185
diff
changeset
|
5030 | GtkIMHtmlButtons buttons; |
|
0a7d2fde749b
Fix setting the sensitivity of the toolbar items in a number of places
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
18185
diff
changeset
|
5031 | |
|
17388
8be39f0de528
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17288
diff
changeset
|
5032 | if (flags & PURPLE_CONNECTION_HTML) { |
|
8be39f0de528
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17288
diff
changeset
|
5033 | char color[8]; |
|
8be39f0de528
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17288
diff
changeset
|
5034 | GdkColor fg_color, bg_color; |
|
8be39f0de528
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17288
diff
changeset
|
5035 | |
|
18240
0a7d2fde749b
Fix setting the sensitivity of the toolbar items in a number of places
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
18185
diff
changeset
|
5036 | buttons = GTK_IMHTML_ALL; |
|
0a7d2fde749b
Fix setting the sensitivity of the toolbar items in a number of places
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
18185
diff
changeset
|
5037 | |
|
0a7d2fde749b
Fix setting the sensitivity of the toolbar items in a number of places
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
18185
diff
changeset
|
5038 | if (flags & PURPLE_CONNECTION_NO_BGCOLOR) |
|
0a7d2fde749b
Fix setting the sensitivity of the toolbar items in a number of places
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
18185
diff
changeset
|
5039 | buttons &= ~GTK_IMHTML_BACKCOLOR; |
|
0a7d2fde749b
Fix setting the sensitivity of the toolbar items in a number of places
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
18185
diff
changeset
|
5040 | if (flags & PURPLE_CONNECTION_NO_FONTSIZE) |
|
0a7d2fde749b
Fix setting the sensitivity of the toolbar items in a number of places
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
18185
diff
changeset
|
5041 | { |
|
0a7d2fde749b
Fix setting the sensitivity of the toolbar items in a number of places
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
18185
diff
changeset
|
5042 | buttons &= ~GTK_IMHTML_GROW; |
|
0a7d2fde749b
Fix setting the sensitivity of the toolbar items in a number of places
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
18185
diff
changeset
|
5043 | buttons &= ~GTK_IMHTML_SHRINK; |
|
0a7d2fde749b
Fix setting the sensitivity of the toolbar items in a number of places
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
18185
diff
changeset
|
5044 | } |
|
0a7d2fde749b
Fix setting the sensitivity of the toolbar items in a number of places
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
18185
diff
changeset
|
5045 | if (flags & PURPLE_CONNECTION_NO_URLDESC) |
|
0a7d2fde749b
Fix setting the sensitivity of the toolbar items in a number of places
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
18185
diff
changeset
|
5046 | buttons &= ~GTK_IMHTML_LINKDESC; |
|
0a7d2fde749b
Fix setting the sensitivity of the toolbar items in a number of places
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
18185
diff
changeset
|
5047 | |
|
17388
8be39f0de528
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17288
diff
changeset
|
5048 | gtk_imhtml_set_format_functions(imhtml, GTK_IMHTML_ALL); |
|
8be39f0de528
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17288
diff
changeset
|
5049 | if (purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/conversations/send_bold") != imhtml->edit.bold) |
|
8be39f0de528
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17288
diff
changeset
|
5050 | gtk_imhtml_toggle_bold(imhtml); |
|
8be39f0de528
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17288
diff
changeset
|
5051 | |
|
8be39f0de528
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17288
diff
changeset
|
5052 | if (purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/conversations/send_italic") != imhtml->edit.italic) |
|
8be39f0de528
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17288
diff
changeset
|
5053 | gtk_imhtml_toggle_italic(imhtml); |
|
8be39f0de528
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17288
diff
changeset
|
5054 | |
|
8be39f0de528
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17288
diff
changeset
|
5055 | if (purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/conversations/send_underline") != imhtml->edit.underline) |
|
8be39f0de528
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17288
diff
changeset
|
5056 | gtk_imhtml_toggle_underline(imhtml); |
|
8be39f0de528
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17288
diff
changeset
|
5057 | |
|
8be39f0de528
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17288
diff
changeset
|
5058 | gtk_imhtml_toggle_fontface(imhtml, |
|
8be39f0de528
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17288
diff
changeset
|
5059 | purple_prefs_get_string(PIDGIN_PREFS_ROOT "/conversations/font_face")); |
|
8be39f0de528
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17288
diff
changeset
|
5060 | |
|
8be39f0de528
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17288
diff
changeset
|
5061 | if (!(flags & PURPLE_CONNECTION_NO_FONTSIZE)) |
|
8be39f0de528
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17288
diff
changeset
|
5062 | { |
|
8be39f0de528
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17288
diff
changeset
|
5063 | int size = purple_prefs_get_int(PIDGIN_PREFS_ROOT "/conversations/font_size"); |
|
8be39f0de528
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17288
diff
changeset
|
5064 | |
|
8be39f0de528
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17288
diff
changeset
|
5065 | /* 3 is the default. */ |
|
8be39f0de528
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17288
diff
changeset
|
5066 | if (size != 3) |
|
8be39f0de528
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17288
diff
changeset
|
5067 | gtk_imhtml_font_set_size(imhtml, size); |
|
8be39f0de528
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17288
diff
changeset
|
5068 | } |
|
8be39f0de528
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17288
diff
changeset
|
5069 | |
|
8be39f0de528
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17288
diff
changeset
|
5070 | if(strcmp(purple_prefs_get_string(PIDGIN_PREFS_ROOT "/conversations/fgcolor"), "") != 0) |
|
8be39f0de528
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17288
diff
changeset
|
5071 | { |
|
8be39f0de528
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17288
diff
changeset
|
5072 | gdk_color_parse(purple_prefs_get_string(PIDGIN_PREFS_ROOT "/conversations/fgcolor"), |
|
8be39f0de528
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17288
diff
changeset
|
5073 | &fg_color); |
|
8be39f0de528
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17288
diff
changeset
|
5074 | g_snprintf(color, sizeof(color), "#%02x%02x%02x", |
|
8be39f0de528
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17288
diff
changeset
|
5075 | fg_color.red / 256, |
|
8be39f0de528
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17288
diff
changeset
|
5076 | fg_color.green / 256, |
|
8be39f0de528
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17288
diff
changeset
|
5077 | fg_color.blue / 256); |
|
8be39f0de528
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17288
diff
changeset
|
5078 | } else |
|
8be39f0de528
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17288
diff
changeset
|
5079 | strcpy(color, ""); |
|
8be39f0de528
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17288
diff
changeset
|
5080 | |
|
8be39f0de528
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17288
diff
changeset
|
5081 | gtk_imhtml_toggle_forecolor(imhtml, color); |
|
8be39f0de528
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17288
diff
changeset
|
5082 | |
|
8be39f0de528
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17288
diff
changeset
|
5083 | if(!(flags & PURPLE_CONNECTION_NO_BGCOLOR) && |
|
8be39f0de528
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17288
diff
changeset
|
5084 | strcmp(purple_prefs_get_string(PIDGIN_PREFS_ROOT "/conversations/bgcolor"), "") != 0) |
|
8be39f0de528
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17288
diff
changeset
|
5085 | { |
|
8be39f0de528
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17288
diff
changeset
|
5086 | gdk_color_parse(purple_prefs_get_string(PIDGIN_PREFS_ROOT "/conversations/bgcolor"), |
|
8be39f0de528
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17288
diff
changeset
|
5087 | &bg_color); |
|
8be39f0de528
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17288
diff
changeset
|
5088 | g_snprintf(color, sizeof(color), "#%02x%02x%02x", |
|
8be39f0de528
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17288
diff
changeset
|
5089 | bg_color.red / 256, |
|
8be39f0de528
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17288
diff
changeset
|
5090 | bg_color.green / 256, |
|
8be39f0de528
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17288
diff
changeset
|
5091 | bg_color.blue / 256); |
|
8be39f0de528
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17288
diff
changeset
|
5092 | } else |
|
8be39f0de528
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17288
diff
changeset
|
5093 | strcpy(color, ""); |
|
8be39f0de528
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17288
diff
changeset
|
5094 | |
|
8be39f0de528
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17288
diff
changeset
|
5095 | gtk_imhtml_toggle_background(imhtml, color); |
|
8be39f0de528
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17288
diff
changeset
|
5096 | |
|
8be39f0de528
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17288
diff
changeset
|
5097 | if (flags & PURPLE_CONNECTION_FORMATTING_WBFO) |
|
8be39f0de528
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17288
diff
changeset
|
5098 | gtk_imhtml_set_whole_buffer_formatting_only(imhtml, TRUE); |
|
8be39f0de528
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17288
diff
changeset
|
5099 | else |
|
8be39f0de528
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17288
diff
changeset
|
5100 | gtk_imhtml_set_whole_buffer_formatting_only(imhtml, FALSE); |
|
8be39f0de528
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17288
diff
changeset
|
5101 | } else { |
|
18240
0a7d2fde749b
Fix setting the sensitivity of the toolbar items in a number of places
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
18185
diff
changeset
|
5102 | buttons = GTK_IMHTML_SMILEY | GTK_IMHTML_IMAGE; |
|
17388
8be39f0de528
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17288
diff
changeset
|
5103 | imhtml_clear_formatting(imhtml); |
|
8be39f0de528
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17288
diff
changeset
|
5104 | } |
|
18240
0a7d2fde749b
Fix setting the sensitivity of the toolbar items in a number of places
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
18185
diff
changeset
|
5105 | |
|
0a7d2fde749b
Fix setting the sensitivity of the toolbar items in a number of places
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
18185
diff
changeset
|
5106 | if (flags & PURPLE_CONNECTION_NO_IMAGES) |
|
0a7d2fde749b
Fix setting the sensitivity of the toolbar items in a number of places
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
18185
diff
changeset
|
5107 | buttons &= ~GTK_IMHTML_IMAGE; |
|
0a7d2fde749b
Fix setting the sensitivity of the toolbar items in a number of places
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
18185
diff
changeset
|
5108 | |
|
0a7d2fde749b
Fix setting the sensitivity of the toolbar items in a number of places
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
18185
diff
changeset
|
5109 | gtk_imhtml_set_format_functions(imhtml, buttons); |
|
17388
8be39f0de528
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17288
diff
changeset
|
5110 | } |
|
8be39f0de528
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17288
diff
changeset
|
5111 | |
|
18105
bab0b0bcb664
propagate from branch 'im.pidgin.pidgin' (head 1b4384bff09a39fca58692fb6c929d4fe1276022)
Sadrul Habib Chowdhury <sadrul@pidgin.im>
diff
changeset
|
5112 |