Tue, 27 Jan 2009 03:32:11 +0000
Prevent a crash that can occur while copying the contents of the Debug Window. This ends up masking mismatched tags in the imhtml output, but that is
better than a crash.
Thanks to Danilo Piazzalunga for figuring out what was happening.
Fixes #6089
| 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 |
|
20330
650a7af9c238
remove gpl boilerplate from doxygen docs
Sean Egan <seanegan@pidgin.im>
parents:
19859
diff
changeset
|
4 | */ |
|
650a7af9c238
remove gpl boilerplate from doxygen docs
Sean Egan <seanegan@pidgin.im>
parents:
19859
diff
changeset
|
5 | |
|
650a7af9c238
remove gpl boilerplate from doxygen docs
Sean Egan <seanegan@pidgin.im>
parents:
19859
diff
changeset
|
6 | /* pidgin |
| 1428 | 7 | * |
|
15931
716b5fac1895
Re-sed the copyright notices so they don't all talk about Purple.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
8 | * Pidgin is the legal property of its developers, whose names are too numerous |
| 8046 | 9 | * to list here. Please refer to the COPYRIGHT file distributed with this |
| 10 | * source distribution. | |
| 1428 | 11 | * |
| 12 | * This program is free software; you can redistribute it and/or modify | |
| 13 | * under the terms of the GNU General Public License as published by | |
| 14 | * the Free Software Foundation; either version 2 of the License, or | |
| 15 | * (at your option) any later version. | |
| 16 | * | |
| 17 | * This program is distributed in the hope that it will be useful, | |
| 18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 20 | * GNU General Public License for more details. | |
| 21 | * | |
| 22 | * You should have received a copy of the GNU General Public License | |
| 23 | * along with this program; if not, write to the Free Software | |
|
19859
71d37b57eff2
The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19746
diff
changeset
|
24 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
| 1428 | 25 | * |
| 26 | */ | |
|
24569
5dbd0617a27d
Build everything with the *_DISABLE_DEPRECATED flags set. This allows us
Richard Laager <rlaager@pidgin.im>
parents:
24544
diff
changeset
|
27 | #define _PIDGIN_GTKIMHTML_C_ |
| 1428 | 28 | |
|
2541
0afd3aaba327
[gaim-migrate @ 2554]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2365
diff
changeset
|
29 | #ifdef HAVE_CONFIG_H |
|
0afd3aaba327
[gaim-migrate @ 2554]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2365
diff
changeset
|
30 | #include <config.h> |
|
0afd3aaba327
[gaim-migrate @ 2554]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2365
diff
changeset
|
31 | #endif |
|
18119
699d876e3db0
Include pidgin.h to make this compile.
Richard Laager <rlaager@pidgin.im>
parents:
18108
diff
changeset
|
32 | |
|
18633
34ba43198355
Fix the win32 build. Thanks to Etan and Lee Roach. Fixes #1929.
Daniel Atallah <datallah@pidgin.im>
parents:
18552
diff
changeset
|
33 | #include "internal.h" |
|
18119
699d876e3db0
Include pidgin.h to make this compile.
Richard Laager <rlaager@pidgin.im>
parents:
18108
diff
changeset
|
34 | #include "pidgin.h" |
|
21777
0662651f6902
Kevin says we're ok defaulting persistent IMs on
Sean Egan <seanegan@pidgin.im>
parents:
21765
diff
changeset
|
35 | #include "pidginstock.h" |
|
23304
3aba02105818
Modified patch from malu to "Add context menu alternative to add received
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23302
diff
changeset
|
36 | #include "gtkutils.h" |
|
3aba02105818
Modified patch from malu to "Add context menu alternative to add received
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23302
diff
changeset
|
37 | #include "smiley.h" |
|
3aba02105818
Modified patch from malu to "Add context menu alternative to add received
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23302
diff
changeset
|
38 | #include "imgstore.h" |
|
18119
699d876e3db0
Include pidgin.h to make this compile.
Richard Laager <rlaager@pidgin.im>
parents:
18108
diff
changeset
|
39 | |
| 8526 | 40 | #include "debug.h" |
| 8091 | 41 | #include "util.h" |
| 1428 | 42 | #include "gtkimhtml.h" |
|
23304
3aba02105818
Modified patch from malu to "Add context menu alternative to add received
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23302
diff
changeset
|
43 | #include "gtksmiley.h" |
| 7358 | 44 | #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
|
45 | #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
|
46 | #include "gtksourceview-marshal.h" |
| 1428 | 47 | #include <gtk/gtk.h> |
| 4895 | 48 | #include <glib/gerror.h> |
| 4046 | 49 | #include <gdk/gdkkeysyms.h> |
| 1428 | 50 | #include <string.h> |
| 51 | #include <ctype.h> | |
| 52 | #include <stdio.h> | |
|
4629
7ac4830de853
[gaim-migrate @ 4920]
Mark Doliner <markdoliner@pidgin.im>
parents:
4612
diff
changeset
|
53 | #include <stdlib.h> |
| 1428 | 54 | #include <math.h> |
|
2541
0afd3aaba327
[gaim-migrate @ 2554]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2365
diff
changeset
|
55 | #ifdef HAVE_LANGINFO_CODESET |
|
0afd3aaba327
[gaim-migrate @ 2554]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2365
diff
changeset
|
56 | #include <langinfo.h> |
|
0afd3aaba327
[gaim-migrate @ 2554]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2365
diff
changeset
|
57 | #include <locale.h> |
|
0afd3aaba327
[gaim-migrate @ 2554]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2365
diff
changeset
|
58 | #endif |
| 8692 | 59 | #ifdef _WIN32 |
|
10901
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
60 | #include <gdk/gdkwin32.h> |
| 8692 | 61 | #include <windows.h> |
| 62 | #endif | |
| 1428 | 63 | |
| 4735 | 64 | #include <pango/pango-font.h> |
| 65 | ||
| 15577 | 66 | /* GTK+ < 2.4.x hack, see pidgin.h for details. */ |
|
10062
144767f0643a
[gaim-migrate @ 11037]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10016
diff
changeset
|
67 | #if (!GTK_CHECK_VERSION(2,4,0)) |
|
5105
3565a4c4de6a
[gaim-migrate @ 5468]
David J. Brigada <brigada@prism.net>
parents:
5104
diff
changeset
|
68 | #define GTK_WRAP_WORD_CHAR GTK_WRAP_WORD |
|
3565a4c4de6a
[gaim-migrate @ 5468]
David J. Brigada <brigada@prism.net>
parents:
5104
diff
changeset
|
69 | #endif |
|
3565a4c4de6a
[gaim-migrate @ 5468]
David J. Brigada <brigada@prism.net>
parents:
5104
diff
changeset
|
70 | |
| 4735 | 71 | #define TOOLTIP_TIMEOUT 500 |
| 72 | ||
| 8786 | 73 | /* GTK+ 2.0 hack */ |
| 74 | #if (!GTK_CHECK_VERSION(2,2,0)) | |
| 75 | #define gtk_widget_get_clipboard(x, y) gtk_clipboard_get(y) | |
| 76 | #endif | |
| 77 | ||
| 10100 | 78 | static GtkTextViewClass *parent_class = NULL; |
| 79 | ||
|
11224
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
80 | struct scalable_data { |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
81 | GtkIMHtmlScalable *scalable; |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
82 | GtkTextMark *mark; |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
83 | }; |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
84 | |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
85 | |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
86 | struct im_image_data { |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
87 | int id; |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
88 | GtkTextMark *mark; |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
89 | }; |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
90 | |
| 9300 | 91 | static gboolean |
| 92 | gtk_text_view_drag_motion (GtkWidget *widget, | |
| 93 | GdkDragContext *context, | |
| 94 | gint x, | |
| 95 | gint y, | |
| 96 | guint time); | |
| 97 | ||
| 8677 | 98 | static void preinsert_cb(GtkTextBuffer *buffer, GtkTextIter *iter, gchar *text, gint len, GtkIMHtml *imhtml); |
| 8061 | 99 | 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
|
100 | static void delete_cb(GtkTextBuffer *buffer, GtkTextIter *iter, GtkTextIter *end, GtkIMHtml *imhtml); |
| 10169 | 101 | static void insert_ca_cb(GtkTextBuffer *buffer, GtkTextIter *arg1, GtkTextChildAnchor *arg2, gpointer user_data); |
| 102 | static void gtk_imhtml_apply_tags_on_insert(GtkIMHtml *imhtml, GtkTextIter *start, GtkTextIter *end); | |
| 8698 | 103 | void gtk_imhtml_close_tags(GtkIMHtml *imhtml, GtkTextIter *iter); |
| 9300 | 104 | static void gtk_imhtml_link_drop_cb(GtkWidget *widget, GdkDragContext *context, gint x, gint y, guint time, gpointer user_data); |
| 8091 | 105 | 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 | 106 | static void mark_set_cb(GtkTextBuffer *buffer, GtkTextIter *arg1, GtkTextMark *mark, GtkIMHtml *imhtml); |
| 8931 | 107 | static void hijack_menu_cb(GtkIMHtml *imhtml, GtkMenu *menu, gpointer data); |
| 108 | static void paste_received_cb (GtkClipboard *clipboard, GtkSelectionData *selection_data, gpointer data); | |
| 109 | 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
|
110 | 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
|
111 | static void imhtml_toggle_bold(GtkIMHtml *imhtml); |
|
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
112 | static void imhtml_toggle_italic(GtkIMHtml *imhtml); |
|
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
113 | static void imhtml_toggle_strike(GtkIMHtml *imhtml); |
|
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
114 | static void imhtml_toggle_underline(GtkIMHtml *imhtml); |
|
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
115 | static void imhtml_font_grow(GtkIMHtml *imhtml); |
|
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
116 | static void imhtml_font_shrink(GtkIMHtml *imhtml); |
|
12672
673e2a1d2954
[gaim-migrate @ 15015]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12635
diff
changeset
|
117 | static void imhtml_clear_formatting(GtkIMHtml *imhtml); |
| 8061 | 118 | |
|
10899
87d9aec5b72d
[gaim-migrate @ 12619]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10871
diff
changeset
|
119 | /* POINT_SIZE converts from AIM font sizes to a point size scale factor. */ |
| 3922 | 120 | #define MAX_FONT_SIZE 7 |
|
10900
cc19dfd83910
[gaim-migrate @ 12621]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10899
diff
changeset
|
121 | #define POINT_SIZE(x) (_point_sizes [MIN ((x > 0 ? x : 1), MAX_FONT_SIZE) - 1]) |
|
21091
07fe1a99c47b
Patch from Andrew Gaul to constify a bunch of static variables to reduce
Ka-Hing Cheung <khc@pidgin.im>
parents:
21085
diff
changeset
|
122 | static const 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
|
123 | |
|
10184
543c9a84ce16
[gaim-migrate @ 11299]
Mark Doliner <markdoliner@pidgin.im>
parents:
10169
diff
changeset
|
124 | enum { |
| 8677 | 125 | TARGET_HTML, |
| 8061 | 126 | TARGET_UTF8_STRING, |
| 127 | TARGET_COMPOUND_TEXT, | |
| 128 | TARGET_STRING, | |
| 129 | TARGET_TEXT | |
| 130 | }; | |
| 131 | ||
| 8091 | 132 | enum { |
| 8420 | 133 | URL_CLICKED, |
| 134 | BUTTONS_UPDATE, | |
| 135 | TOGGLE_FORMAT, | |
| 8427 | 136 | CLEAR_FORMAT, |
| 8506 | 137 | UPDATE_FORMAT, |
| 10108 | 138 | 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
|
139 | 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
|
140 | REDO, |
| 8420 | 141 | LAST_SIGNAL |
| 142 | }; | |
| 143 | static guint signals [LAST_SIGNAL] = { 0 }; | |
| 144 | ||
|
17546
51b1c1e2c3fe
Maintain global poitners to the clipboard selection text, with the aim of
Sean Egan <seanegan@pidgin.im>
parents:
17406
diff
changeset
|
145 | 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
|
146 | static char *text_clipboard = NULL; |
|
21085
dff5e0bfb8f5
Don't assign ownership of the CLIPBOARD to the IMHtml - it doesn't really own the data and then we don't have problems of overwriting what others put in the clipboard. Fixes #3616.
Daniel Atallah <datallah@pidgin.im>
parents:
21076
diff
changeset
|
147 | static GtkClipboard *clipboard_selection = NULL; |
|
17546
51b1c1e2c3fe
Maintain global poitners to the clipboard selection text, with the aim of
Sean Egan <seanegan@pidgin.im>
parents:
17406
diff
changeset
|
148 | |
|
21091
07fe1a99c47b
Patch from Andrew Gaul to constify a bunch of static variables to reduce
Ka-Hing Cheung <khc@pidgin.im>
parents:
21085
diff
changeset
|
149 | static const GtkTargetEntry selection_targets[] = { |
|
15111
e427dd6f3b7e
[gaim-migrate @ 17833]
Daniel Atallah <datallah@pidgin.im>
parents:
15093
diff
changeset
|
150 | #ifndef _WIN32 |
| 8566 | 151 | { "text/html", 0, TARGET_HTML }, |
|
15111
e427dd6f3b7e
[gaim-migrate @ 17833]
Daniel Atallah <datallah@pidgin.im>
parents:
15093
diff
changeset
|
152 | #else |
|
e427dd6f3b7e
[gaim-migrate @ 17833]
Daniel Atallah <datallah@pidgin.im>
parents:
15093
diff
changeset
|
153 | { "HTML Format", 0, TARGET_HTML }, |
|
e427dd6f3b7e
[gaim-migrate @ 17833]
Daniel Atallah <datallah@pidgin.im>
parents:
15093
diff
changeset
|
154 | #endif |
| 8061 | 155 | { "UTF8_STRING", 0, TARGET_UTF8_STRING }, |
| 156 | { "COMPOUND_TEXT", 0, TARGET_COMPOUND_TEXT }, | |
| 157 | { "STRING", 0, TARGET_STRING }, | |
| 158 | { "TEXT", 0, TARGET_TEXT}}; | |
| 159 | ||
|
21091
07fe1a99c47b
Patch from Andrew Gaul to constify a bunch of static variables to reduce
Ka-Hing Cheung <khc@pidgin.im>
parents:
21085
diff
changeset
|
160 | static const GtkTargetEntry link_drag_drop_targets[] = { |
|
10145
f1405f65ff41
[gaim-migrate @ 11218]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10110
diff
changeset
|
161 | GTK_IMHTML_DND_TARGETS |
|
f1405f65ff41
[gaim-migrate @ 11218]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10110
diff
changeset
|
162 | }; |
| 8091 | 163 | |
| 8692 | 164 | #ifdef _WIN32 |
| 165 | static gchar * | |
| 166 | clipboard_win32_to_html(char *clipboard) { | |
| 9465 | 167 | const char *header; |
| 8693 | 168 | const char *begin, *end; |
|
10016
18418b9fa749
[gaim-migrate @ 10935]
Daniel Atallah <datallah@pidgin.im>
parents:
10013
diff
changeset
|
169 | gint start = 0; |
|
18418b9fa749
[gaim-migrate @ 10935]
Daniel Atallah <datallah@pidgin.im>
parents:
10013
diff
changeset
|
170 | gint finish = 0; |
| 8692 | 171 | gchar *html; |
|
10016
18418b9fa749
[gaim-migrate @ 10935]
Daniel Atallah <datallah@pidgin.im>
parents:
10013
diff
changeset
|
172 | gchar **split; |
|
18418b9fa749
[gaim-migrate @ 10935]
Daniel Atallah <datallah@pidgin.im>
parents:
10013
diff
changeset
|
173 | int clipboard_length = 0; |
| 9465 | 174 | |
| 175 | #if 0 /* Debugging for Windows clipboard */ | |
| 9467 | 176 | FILE *fd; |
| 177 | ||
| 15884 | 178 | purple_debug_info("imhtml clipboard", "from clipboard: %s\n", clipboard); |
| 179 | ||
| 180 | fd = g_fopen("e:\\purplecb.txt", "wb"); | |
| 9465 | 181 | fprintf(fd, "%s", clipboard); |
| 182 | fclose(fd); | |
| 183 | #endif | |
| 184 | ||
|
10016
18418b9fa749
[gaim-migrate @ 10935]
Daniel Atallah <datallah@pidgin.im>
parents:
10013
diff
changeset
|
185 | clipboard_length = strlen(clipboard); |
|
18418b9fa749
[gaim-migrate @ 10935]
Daniel Atallah <datallah@pidgin.im>
parents:
10013
diff
changeset
|
186 | |
|
18418b9fa749
[gaim-migrate @ 10935]
Daniel Atallah <datallah@pidgin.im>
parents:
10013
diff
changeset
|
187 | if (!(header = strstr(clipboard, "StartFragment:")) || (header - clipboard) >= clipboard_length) |
| 9465 | 188 | return NULL; |
| 189 | sscanf(header, "StartFragment:%d", &start); | |
| 190 | ||
|
10016
18418b9fa749
[gaim-migrate @ 10935]
Daniel Atallah <datallah@pidgin.im>
parents:
10013
diff
changeset
|
191 | if (!(header = strstr(clipboard, "EndFragment:")) || (header - clipboard) >= clipboard_length) |
|
18418b9fa749
[gaim-migrate @ 10935]
Daniel Atallah <datallah@pidgin.im>
parents:
10013
diff
changeset
|
192 | return NULL; |
| 9465 | 193 | sscanf(header, "EndFragment:%d", &finish); |
| 194 | ||
|
10016
18418b9fa749
[gaim-migrate @ 10935]
Daniel Atallah <datallah@pidgin.im>
parents:
10013
diff
changeset
|
195 | if (finish > clipboard_length) |
|
18418b9fa749
[gaim-migrate @ 10935]
Daniel Atallah <datallah@pidgin.im>
parents:
10013
diff
changeset
|
196 | finish = clipboard_length; |
|
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 | if (start > finish) |
|
18418b9fa749
[gaim-migrate @ 10935]
Daniel Atallah <datallah@pidgin.im>
parents:
10013
diff
changeset
|
199 | start = finish; |
|
18418b9fa749
[gaim-migrate @ 10935]
Daniel Atallah <datallah@pidgin.im>
parents:
10013
diff
changeset
|
200 | |
| 9465 | 201 | begin = clipboard + start; |
| 202 | ||
|
10016
18418b9fa749
[gaim-migrate @ 10935]
Daniel Atallah <datallah@pidgin.im>
parents:
10013
diff
changeset
|
203 | end = clipboard + finish; |
|
18418b9fa749
[gaim-migrate @ 10935]
Daniel Atallah <datallah@pidgin.im>
parents:
10013
diff
changeset
|
204 | |
|
18418b9fa749
[gaim-migrate @ 10935]
Daniel Atallah <datallah@pidgin.im>
parents:
10013
diff
changeset
|
205 | html = g_strndup(begin, end - begin); |
|
18418b9fa749
[gaim-migrate @ 10935]
Daniel Atallah <datallah@pidgin.im>
parents:
10013
diff
changeset
|
206 | |
|
18418b9fa749
[gaim-migrate @ 10935]
Daniel Atallah <datallah@pidgin.im>
parents:
10013
diff
changeset
|
207 | /* 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
|
208 | split = g_strsplit(html, "\r\n", 0); |
|
18418b9fa749
[gaim-migrate @ 10935]
Daniel Atallah <datallah@pidgin.im>
parents:
10013
diff
changeset
|
209 | g_free(html); |
|
18418b9fa749
[gaim-migrate @ 10935]
Daniel Atallah <datallah@pidgin.im>
parents:
10013
diff
changeset
|
210 | html = g_strjoinv("\n", split); |
|
18418b9fa749
[gaim-migrate @ 10935]
Daniel Atallah <datallah@pidgin.im>
parents:
10013
diff
changeset
|
211 | g_strfreev(split); |
|
18418b9fa749
[gaim-migrate @ 10935]
Daniel Atallah <datallah@pidgin.im>
parents:
10013
diff
changeset
|
212 | |
| 9465 | 213 | #if 0 /* Debugging for Windows clipboard */ |
| 15884 | 214 | purple_debug_info("imhtml clipboard", "HTML fragment: '%s'\n", html); |
| 9465 | 215 | #endif |
| 216 | ||
| 8707 | 217 | return html; |
| 8692 | 218 | } |
| 219 | ||
| 220 | static gchar * | |
| 221 | clipboard_html_to_win32(char *html) { | |
| 8693 | 222 | int length; |
|
11240
cd4ca16ff57c
[gaim-migrate @ 13399]
Richard Laager <rlaager@pidgin.im>
parents:
11234
diff
changeset
|
223 | GString *clipboard; |
| 8692 | 224 | |
| 8693 | 225 | if (html == NULL) |
| 226 | return NULL; | |
| 8692 | 227 | |
| 228 | length = strlen(html); | |
| 9465 | 229 | clipboard = g_string_new ("Version:1.0\r\n"); |
| 8692 | 230 | 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
|
231 | g_string_append_printf(clipboard, "EndHTML:%010d\r\n", 147 + length); |
| 9465 | 232 | 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
|
233 | g_string_append_printf(clipboard, "EndFragment:%010d\r\n", 127 + length); |
| 9465 | 234 | g_string_append(clipboard, "<!--StartFragment-->\r\n"); |
| 8692 | 235 | g_string_append(clipboard, html); |
| 9465 | 236 | g_string_append(clipboard, "\r\n<!--EndFragment-->"); |
|
14101
89a79c2a971e
[gaim-migrate @ 16643]
Mark Doliner <markdoliner@pidgin.im>
parents:
14097
diff
changeset
|
237 | |
|
89a79c2a971e
[gaim-migrate @ 16643]
Mark Doliner <markdoliner@pidgin.im>
parents:
14097
diff
changeset
|
238 | return g_string_free(clipboard, FALSE); |
| 8692 | 239 | } |
|
10901
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
240 | |
|
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
241 | static gboolean clipboard_paste_html_win32(GtkIMHtml *imhtml) { |
|
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
242 | gboolean pasted = FALSE; |
|
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
243 | |
|
15111
e427dd6f3b7e
[gaim-migrate @ 17833]
Daniel Atallah <datallah@pidgin.im>
parents:
15093
diff
changeset
|
244 | /* Win32 clipboard format value, and functions to convert back and |
|
e427dd6f3b7e
[gaim-migrate @ 17833]
Daniel Atallah <datallah@pidgin.im>
parents:
15093
diff
changeset
|
245 | * forth between HTML and the clipboard format. |
|
e427dd6f3b7e
[gaim-migrate @ 17833]
Daniel Atallah <datallah@pidgin.im>
parents:
15093
diff
changeset
|
246 | */ |
|
e427dd6f3b7e
[gaim-migrate @ 17833]
Daniel Atallah <datallah@pidgin.im>
parents:
15093
diff
changeset
|
247 | static UINT win_html_fmt = 0; |
|
e427dd6f3b7e
[gaim-migrate @ 17833]
Daniel Atallah <datallah@pidgin.im>
parents:
15093
diff
changeset
|
248 | |
|
e427dd6f3b7e
[gaim-migrate @ 17833]
Daniel Atallah <datallah@pidgin.im>
parents:
15093
diff
changeset
|
249 | /* Register HTML Format as desired clipboard format */ |
|
e427dd6f3b7e
[gaim-migrate @ 17833]
Daniel Atallah <datallah@pidgin.im>
parents:
15093
diff
changeset
|
250 | if (!win_html_fmt) |
|
e427dd6f3b7e
[gaim-migrate @ 17833]
Daniel Atallah <datallah@pidgin.im>
parents:
15093
diff
changeset
|
251 | win_html_fmt = RegisterClipboardFormat("HTML Format"); |
|
e427dd6f3b7e
[gaim-migrate @ 17833]
Daniel Atallah <datallah@pidgin.im>
parents:
15093
diff
changeset
|
252 | |
|
10901
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
253 | if (gtk_text_view_get_editable(GTK_TEXT_VIEW(imhtml)) |
|
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
254 | && IsClipboardFormatAvailable(win_html_fmt)) { |
|
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
255 | gboolean error_reading_clipboard = FALSE; |
|
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
256 | HWND hwnd = GDK_WINDOW_HWND(GTK_WIDGET(imhtml)->window); |
|
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
257 | |
|
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
258 | if (OpenClipboard(hwnd)) { |
|
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
259 | HGLOBAL hdata = GetClipboardData(win_html_fmt); |
|
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
260 | if (hdata == NULL) { |
|
15111
e427dd6f3b7e
[gaim-migrate @ 17833]
Daniel Atallah <datallah@pidgin.im>
parents:
15093
diff
changeset
|
261 | if (GetLastError() != ERROR_SUCCESS) |
|
e427dd6f3b7e
[gaim-migrate @ 17833]
Daniel Atallah <datallah@pidgin.im>
parents:
15093
diff
changeset
|
262 | error_reading_clipboard = TRUE; |
|
10901
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
263 | } else { |
|
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
264 | char *buffer = GlobalLock(hdata); |
|
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
265 | if (buffer == NULL) { |
|
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
266 | error_reading_clipboard = TRUE; |
|
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
267 | } else { |
|
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
268 | char *text = clipboard_win32_to_html( |
|
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
269 | buffer); |
|
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
270 | imhtml_paste_insert(imhtml, text, |
|
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
271 | FALSE); |
|
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
272 | g_free(text); |
|
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
273 | pasted = TRUE; |
|
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
274 | } |
|
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
275 | GlobalUnlock(hdata); |
|
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 | CloseClipboard(); |
|
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
279 | } else { |
|
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
280 | error_reading_clipboard = TRUE; |
|
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
281 | } |
|
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
282 | |
|
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
283 | if (error_reading_clipboard) { |
|
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
284 | gchar *err_msg = g_win32_error_message(GetLastError()); |
| 15884 | 285 | purple_debug_info("html clipboard", |
|
10901
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
286 | "Unable to read clipboard data: %s\n", |
|
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
287 | err_msg ? err_msg : "Unknown Error"); |
|
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
288 | g_free(err_msg); |
|
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
289 | } |
|
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
290 | } |
|
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
291 | |
|
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
292 | return pasted; |
|
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
293 | } |
| 8692 | 294 | #endif |
| 295 | ||
| 4032 | 296 | static GtkSmileyTree* |
|
22104
56970903b8e9
Probe for -Wstrict-prototypes to get some more warnings. I then cleaned up
Richard Laager <rlaager@pidgin.im>
parents:
22100
diff
changeset
|
297 | gtk_smiley_tree_new (void) |
| 4032 | 298 | { |
| 299 | return g_new0 (GtkSmileyTree, 1); | |
| 300 | } | |
| 301 | ||
| 302 | static void | |
| 303 | gtk_smiley_tree_insert (GtkSmileyTree *tree, | |
| 4263 | 304 | GtkIMHtmlSmiley *smiley) |
| 4032 | 305 | { |
| 306 | GtkSmileyTree *t = tree; | |
| 4263 | 307 | const gchar *x = smiley->smile; |
| 4032 | 308 | |
|
12229
ad8d3ae8fc1b
[gaim-migrate @ 14531]
Michael Carlson <corfe83@users.sourceforge.net>
parents:
12072
diff
changeset
|
309 | if (!(*x)) |
| 4032 | 310 | return; |
| 311 | ||
|
12229
ad8d3ae8fc1b
[gaim-migrate @ 14531]
Michael Carlson <corfe83@users.sourceforge.net>
parents:
12072
diff
changeset
|
312 | do { |
| 4032 | 313 | gchar *pos; |
| 314 | gint index; | |
| 315 | ||
| 316 | if (!t->values) | |
| 317 | t->values = g_string_new (""); | |
| 318 | ||
| 319 | pos = strchr (t->values->str, *x); | |
| 320 | if (!pos) { | |
| 321 | t->values = g_string_append_c (t->values, *x); | |
| 322 | index = t->values->len - 1; | |
| 323 | t->children = g_realloc (t->children, t->values->len * sizeof (GtkSmileyTree *)); | |
| 324 | t->children [index] = g_new0 (GtkSmileyTree, 1); | |
| 325 | } else | |
| 7386 | 326 | index = GPOINTER_TO_INT(pos) - GPOINTER_TO_INT(t->values->str); |
| 8061 | 327 | |
| 4032 | 328 | t = t->children [index]; |
| 8061 | 329 | |
| 4032 | 330 | x++; |
|
12229
ad8d3ae8fc1b
[gaim-migrate @ 14531]
Michael Carlson <corfe83@users.sourceforge.net>
parents:
12072
diff
changeset
|
331 | } while (*x); |
| 8061 | 332 | |
| 4263 | 333 | t->image = smiley; |
| 4032 | 334 | } |
| 4041 | 335 | |
| 4263 | 336 | |
|
11677
89c2ab8d2ebf
[gaim-migrate @ 13963]
Mark Doliner <markdoliner@pidgin.im>
parents:
11586
diff
changeset
|
337 | static void |
|
89c2ab8d2ebf
[gaim-migrate @ 13963]
Mark Doliner <markdoliner@pidgin.im>
parents:
11586
diff
changeset
|
338 | gtk_smiley_tree_destroy (GtkSmileyTree *tree) |
| 4032 | 339 | { |
|
11701
8cf812de5e92
[gaim-migrate @ 13992]
Michael Carlson <corfe83@users.sourceforge.net>
parents:
11677
diff
changeset
|
340 | GSList *list = g_slist_prepend (NULL, tree); |
| 4032 | 341 | |
| 342 | while (list) { | |
| 343 | GtkSmileyTree *t = list->data; | |
|
12229
ad8d3ae8fc1b
[gaim-migrate @ 14531]
Michael Carlson <corfe83@users.sourceforge.net>
parents:
12072
diff
changeset
|
344 | gsize i; |
| 4032 | 345 | list = g_slist_remove(list, t); |
| 7384 | 346 | if (t && t->values) { |
| 4032 | 347 | for (i = 0; i < t->values->len; i++) |
|
11701
8cf812de5e92
[gaim-migrate @ 13992]
Michael Carlson <corfe83@users.sourceforge.net>
parents:
11677
diff
changeset
|
348 | list = g_slist_prepend (list, t->children [i]); |
| 4032 | 349 | g_string_free (t->values, TRUE); |
| 350 | g_free (t->children); | |
| 351 | } | |
|
24511
19fe55ed0ea5
What was I thinking... The GtkIMHtmlSmileys in the smiley trees aren't owned
Marcus Lundblad <malu@pidgin.im>
parents:
24510
diff
changeset
|
352 | |
| 4032 | 353 | g_free (t); |
| 354 | } | |
| 355 | } | |
| 356 | ||
|
18968
2ddbe6473bc9
Cool! Override GtkTextView's size allocate function in GtkIMHtml to make sure that it stays scrolled to the bottom whenever it's resized. Fixes a major annoyance and possibly #938
Sean Egan <seanegan@pidgin.im>
parents:
18665
diff
changeset
|
357 | static void (*parent_size_allocate)(GtkWidget *widget, GtkAllocation *alloc); |
|
2ddbe6473bc9
Cool! Override GtkTextView's size allocate function in GtkIMHtml to make sure that it stays scrolled to the bottom whenever it's resized. Fixes a major annoyance and possibly #938
Sean Egan <seanegan@pidgin.im>
parents:
18665
diff
changeset
|
358 | |
|
2ddbe6473bc9
Cool! Override GtkTextView's size allocate function in GtkIMHtml to make sure that it stays scrolled to the bottom whenever it's resized. Fixes a major annoyance and possibly #938
Sean Egan <seanegan@pidgin.im>
parents:
18665
diff
changeset
|
359 | static void gtk_imhtml_size_allocate(GtkWidget *widget, GtkAllocation *alloc) |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
360 | { |
|
18968
2ddbe6473bc9
Cool! Override GtkTextView's size allocate function in GtkIMHtml to make sure that it stays scrolled to the bottom whenever it's resized. Fixes a major annoyance and possibly #938
Sean Egan <seanegan@pidgin.im>
parents:
18665
diff
changeset
|
361 | GtkIMHtml *imhtml = GTK_IMHTML(widget); |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
362 | GdkRectangle rect; |
| 8726 | 363 | int xminus; |
|
18968
2ddbe6473bc9
Cool! Override GtkTextView's size allocate function in GtkIMHtml to make sure that it stays scrolled to the bottom whenever it's resized. Fixes a major annoyance and possibly #938
Sean Egan <seanegan@pidgin.im>
parents:
18665
diff
changeset
|
364 | int height = 0, y = 0; |
|
2ddbe6473bc9
Cool! Override GtkTextView's size allocate function in GtkIMHtml to make sure that it stays scrolled to the bottom whenever it's resized. Fixes a major annoyance and possibly #938
Sean Egan <seanegan@pidgin.im>
parents:
18665
diff
changeset
|
365 | GtkTextIter iter; |
|
2ddbe6473bc9
Cool! Override GtkTextView's size allocate function in GtkIMHtml to make sure that it stays scrolled to the bottom whenever it's resized. Fixes a major annoyance and possibly #938
Sean Egan <seanegan@pidgin.im>
parents:
18665
diff
changeset
|
366 | gboolean scroll = TRUE; |
|
2ddbe6473bc9
Cool! Override GtkTextView's size allocate function in GtkIMHtml to make sure that it stays scrolled to the bottom whenever it's resized. Fixes a major annoyance and possibly #938
Sean Egan <seanegan@pidgin.im>
parents:
18665
diff
changeset
|
367 | |
|
22803
e1f64090d32e
Do not show tooltips for <HR> or <IMG>s in gtkimhtml. Fixes #5480.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22772
diff
changeset
|
368 | gtk_text_buffer_get_end_iter(imhtml->text_buffer, &iter); |
|
5967
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 | gtk_text_view_get_visible_rect(GTK_TEXT_VIEW(widget), &rect); |
|
22803
e1f64090d32e
Do not show tooltips for <HR> or <IMG>s in gtkimhtml. Fixes #5480.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22772
diff
changeset
|
371 | gtk_text_view_get_line_yrange(GTK_TEXT_VIEW(imhtml), &iter, &y, &height); |
|
e1f64090d32e
Do not show tooltips for <HR> or <IMG>s in gtkimhtml. Fixes #5480.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22772
diff
changeset
|
372 | |
|
e1f64090d32e
Do not show tooltips for <HR> or <IMG>s in gtkimhtml. Fixes #5480.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22772
diff
changeset
|
373 | if (((y + height) - (rect.y + rect.height)) > height && |
|
e1f64090d32e
Do not show tooltips for <HR> or <IMG>s in gtkimhtml. Fixes #5480.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22772
diff
changeset
|
374 | gtk_text_buffer_get_char_count(imhtml->text_buffer)) { |
|
e1f64090d32e
Do not show tooltips for <HR> or <IMG>s in gtkimhtml. Fixes #5480.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22772
diff
changeset
|
375 | scroll = FALSE; |
|
e1f64090d32e
Do not show tooltips for <HR> or <IMG>s in gtkimhtml. Fixes #5480.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22772
diff
changeset
|
376 | } |
|
e1f64090d32e
Do not show tooltips for <HR> or <IMG>s in gtkimhtml. Fixes #5480.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22772
diff
changeset
|
377 | |
|
e1f64090d32e
Do not show tooltips for <HR> or <IMG>s in gtkimhtml. Fixes #5480.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22772
diff
changeset
|
378 | if(imhtml->old_rect.width != rect.width || imhtml->old_rect.height != rect.height) { |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
379 | GList *iter = GTK_IMHTML(widget)->scalables; |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
380 | |
| 8726 | 381 | xminus = gtk_text_view_get_left_margin(GTK_TEXT_VIEW(widget)) + |
| 382 | gtk_text_view_get_right_margin(GTK_TEXT_VIEW(widget)); | |
| 383 | ||
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
384 | while(iter){ |
|
11224
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
385 | struct scalable_data *sd = iter->data; |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
386 | GtkIMHtmlScalable *scale = GTK_IMHTML_SCALABLE(sd->scalable); |
| 8726 | 387 | scale->scale(scale, rect.width - xminus, rect.height); |
|
5967
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 | iter = iter->next; |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
390 | } |
|
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 | |
|
18968
2ddbe6473bc9
Cool! Override GtkTextView's size allocate function in GtkIMHtml to make sure that it stays scrolled to the bottom whenever it's resized. Fixes a major annoyance and possibly #938
Sean Egan <seanegan@pidgin.im>
parents:
18665
diff
changeset
|
393 | imhtml->old_rect = rect; |
|
2ddbe6473bc9
Cool! Override GtkTextView's size allocate function in GtkIMHtml to make sure that it stays scrolled to the bottom whenever it's resized. Fixes a major annoyance and possibly #938
Sean Egan <seanegan@pidgin.im>
parents:
18665
diff
changeset
|
394 | parent_size_allocate(widget, alloc); |
|
22803
e1f64090d32e
Do not show tooltips for <HR> or <IMG>s in gtkimhtml. Fixes #5480.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22772
diff
changeset
|
395 | |
| 18985 | 396 | /* Don't scroll here if we're in the middle of a smooth scroll */ |
|
19326
d3071a414d6b
Don't scroll to bottom if imhtml is not realized. Fixes #2320
Sean Egan <seanegan@pidgin.im>
parents:
19325
diff
changeset
|
397 | if (scroll && imhtml->scroll_time == NULL && |
|
22803
e1f64090d32e
Do not show tooltips for <HR> or <IMG>s in gtkimhtml. Fixes #5480.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22772
diff
changeset
|
398 | GTK_WIDGET_REALIZED(imhtml)) |
|
e1f64090d32e
Do not show tooltips for <HR> or <IMG>s in gtkimhtml. Fixes #5480.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22772
diff
changeset
|
399 | gtk_imhtml_scroll_to_end(imhtml, FALSE); |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
400 | } |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
401 | |
|
23227
f2d8240d3487
Use text-tags to set the weight/color of the nick in conversations. This
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22970
diff
changeset
|
402 | #define DEFAULT_SEND_COLOR "#204a87" |
|
f2d8240d3487
Use text-tags to set the weight/color of the nick in conversations. This
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22970
diff
changeset
|
403 | #define DEFAULT_RECV_COLOR "#cc0000" |
|
f2d8240d3487
Use text-tags to set the weight/color of the nick in conversations. This
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22970
diff
changeset
|
404 | #define DEFAULT_HIGHLIGHT_COLOR "#AF7F00" |
|
f2d8240d3487
Use text-tags to set the weight/color of the nick in conversations. This
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22970
diff
changeset
|
405 | #define DEFAULT_ACTION_COLOR "#062585" |
|
f2d8240d3487
Use text-tags to set the weight/color of the nick in conversations. This
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22970
diff
changeset
|
406 | #define DEFAULT_WHISPER_ACTION_COLOR "#6C2585" |
|
f2d8240d3487
Use text-tags to set the weight/color of the nick in conversations. This
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22970
diff
changeset
|
407 | #define DEFAULT_WHISPER_COLOR "#00FF00" |
|
f2d8240d3487
Use text-tags to set the weight/color of the nick in conversations. This
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22970
diff
changeset
|
408 | |
|
f2d8240d3487
Use text-tags to set the weight/color of the nick in conversations. This
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22970
diff
changeset
|
409 | static void (*parent_style_set)(GtkWidget *widget, GtkStyle *prev_style); |
|
f2d8240d3487
Use text-tags to set the weight/color of the nick in conversations. This
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22970
diff
changeset
|
410 | |
|
f2d8240d3487
Use text-tags to set the weight/color of the nick in conversations. This
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22970
diff
changeset
|
411 | static void |
|
f2d8240d3487
Use text-tags to set the weight/color of the nick in conversations. This
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22970
diff
changeset
|
412 | gtk_imhtml_style_set(GtkWidget *widget, GtkStyle *prev_style) |
|
f2d8240d3487
Use text-tags to set the weight/color of the nick in conversations. This
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22970
diff
changeset
|
413 | { |
|
f2d8240d3487
Use text-tags to set the weight/color of the nick in conversations. This
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22970
diff
changeset
|
414 | int i; |
|
f2d8240d3487
Use text-tags to set the weight/color of the nick in conversations. This
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22970
diff
changeset
|
415 | struct { |
|
f2d8240d3487
Use text-tags to set the weight/color of the nick in conversations. This
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22970
diff
changeset
|
416 | const char *tag; |
|
f2d8240d3487
Use text-tags to set the weight/color of the nick in conversations. This
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22970
diff
changeset
|
417 | const char *color; |
|
f2d8240d3487
Use text-tags to set the weight/color of the nick in conversations. This
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22970
diff
changeset
|
418 | const char *def; |
|
f2d8240d3487
Use text-tags to set the weight/color of the nick in conversations. This
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22970
diff
changeset
|
419 | } styles[] = { |
|
f2d8240d3487
Use text-tags to set the weight/color of the nick in conversations. This
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22970
diff
changeset
|
420 | {"send-name", "send-name-color", DEFAULT_SEND_COLOR}, |
|
f2d8240d3487
Use text-tags to set the weight/color of the nick in conversations. This
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22970
diff
changeset
|
421 | {"receive-name", "receive-name-color", DEFAULT_RECV_COLOR}, |
|
f2d8240d3487
Use text-tags to set the weight/color of the nick in conversations. This
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22970
diff
changeset
|
422 | {"highlight-name", "highlight-name-color", DEFAULT_HIGHLIGHT_COLOR}, |
|
f2d8240d3487
Use text-tags to set the weight/color of the nick in conversations. This
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22970
diff
changeset
|
423 | {"action-name", "action-name-color", DEFAULT_ACTION_COLOR}, |
|
f2d8240d3487
Use text-tags to set the weight/color of the nick in conversations. This
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22970
diff
changeset
|
424 | {"whisper-action-name", "whisper-action-name-color", DEFAULT_WHISPER_ACTION_COLOR}, |
|
f2d8240d3487
Use text-tags to set the weight/color of the nick in conversations. This
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22970
diff
changeset
|
425 | {"whisper-name", "whisper-name-color", DEFAULT_WHISPER_COLOR}, |
|
f2d8240d3487
Use text-tags to set the weight/color of the nick in conversations. This
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22970
diff
changeset
|
426 | {NULL, NULL, NULL} |
|
f2d8240d3487
Use text-tags to set the weight/color of the nick in conversations. This
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22970
diff
changeset
|
427 | }; |
|
f2d8240d3487
Use text-tags to set the weight/color of the nick in conversations. This
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22970
diff
changeset
|
428 | GtkIMHtml *imhtml = GTK_IMHTML(widget); |
|
f2d8240d3487
Use text-tags to set the weight/color of the nick in conversations. This
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22970
diff
changeset
|
429 | GtkTextTagTable *table = gtk_text_buffer_get_tag_table(imhtml->text_buffer); |
|
f2d8240d3487
Use text-tags to set the weight/color of the nick in conversations. This
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22970
diff
changeset
|
430 | |
|
f2d8240d3487
Use text-tags to set the weight/color of the nick in conversations. This
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22970
diff
changeset
|
431 | for (i = 0; styles[i].tag; i++) { |
|
f2d8240d3487
Use text-tags to set the weight/color of the nick in conversations. This
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22970
diff
changeset
|
432 | GdkColor *color = NULL; |
|
f2d8240d3487
Use text-tags to set the weight/color of the nick in conversations. This
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22970
diff
changeset
|
433 | GtkTextTag *tag = gtk_text_tag_table_lookup(table, styles[i].tag); |
|
f2d8240d3487
Use text-tags to set the weight/color of the nick in conversations. This
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22970
diff
changeset
|
434 | if (!tag) { |
|
f2d8240d3487
Use text-tags to set the weight/color of the nick in conversations. This
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22970
diff
changeset
|
435 | purple_debug_warning("gtkimhtml", "Cannot find tag '%s'. This should never happen. Please file a bug.\n", styles[i].tag); |
|
f2d8240d3487
Use text-tags to set the weight/color of the nick in conversations. This
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22970
diff
changeset
|
436 | continue; |
|
f2d8240d3487
Use text-tags to set the weight/color of the nick in conversations. This
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22970
diff
changeset
|
437 | } |
|
f2d8240d3487
Use text-tags to set the weight/color of the nick in conversations. This
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22970
diff
changeset
|
438 | gtk_widget_style_get(widget, styles[i].color, &color, NULL); |
|
f2d8240d3487
Use text-tags to set the weight/color of the nick in conversations. This
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22970
diff
changeset
|
439 | if (color) { |
|
f2d8240d3487
Use text-tags to set the weight/color of the nick in conversations. This
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22970
diff
changeset
|
440 | g_object_set(tag, "foreground-gdk", color, NULL); |
|
f2d8240d3487
Use text-tags to set the weight/color of the nick in conversations. This
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22970
diff
changeset
|
441 | gdk_color_free(color); |
|
f2d8240d3487
Use text-tags to set the weight/color of the nick in conversations. This
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22970
diff
changeset
|
442 | } else { |
|
f2d8240d3487
Use text-tags to set the weight/color of the nick in conversations. This
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22970
diff
changeset
|
443 | GdkColor defcolor; |
|
f2d8240d3487
Use text-tags to set the weight/color of the nick in conversations. This
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22970
diff
changeset
|
444 | gdk_color_parse(styles[i].def, &defcolor); |
|
f2d8240d3487
Use text-tags to set the weight/color of the nick in conversations. This
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22970
diff
changeset
|
445 | g_object_set(tag, "foreground-gdk", &defcolor, NULL); |
|
f2d8240d3487
Use text-tags to set the weight/color of the nick in conversations. This
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22970
diff
changeset
|
446 | } |
|
f2d8240d3487
Use text-tags to set the weight/color of the nick in conversations. This
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22970
diff
changeset
|
447 | } |
|
f2d8240d3487
Use text-tags to set the weight/color of the nick in conversations. This
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22970
diff
changeset
|
448 | parent_style_set(widget, prev_style); |
|
f2d8240d3487
Use text-tags to set the weight/color of the nick in conversations. This
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22970
diff
changeset
|
449 | } |
|
f2d8240d3487
Use text-tags to set the weight/color of the nick in conversations. This
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22970
diff
changeset
|
450 | |
|
24328
7be2af5c9129
Show visited links in a different color. This also plugs a memory leak
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23548
diff
changeset
|
451 | static void |
|
7be2af5c9129
Show visited links in a different color. This also plugs a memory leak
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23548
diff
changeset
|
452 | gtk_imhtml_set_link_color(GtkIMHtml *imhtml, GtkTextTag *tag) |
|
7be2af5c9129
Show visited links in a different color. This also plugs a memory leak
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23548
diff
changeset
|
453 | { |
|
7be2af5c9129
Show visited links in a different color. This also plugs a memory leak
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23548
diff
changeset
|
454 | GdkColor *color = NULL; |
|
7be2af5c9129
Show visited links in a different color. This also plugs a memory leak
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23548
diff
changeset
|
455 | gboolean visited = !!g_object_get_data(G_OBJECT(tag), "visited"); |
|
7be2af5c9129
Show visited links in a different color. This also plugs a memory leak
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23548
diff
changeset
|
456 | gtk_widget_style_get(GTK_WIDGET(imhtml), visited ? "hyperlink-visited-color" : "hyperlink-color", &color, NULL); |
|
7be2af5c9129
Show visited links in a different color. This also plugs a memory leak
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23548
diff
changeset
|
457 | if (color) { |
|
7be2af5c9129
Show visited links in a different color. This also plugs a memory leak
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23548
diff
changeset
|
458 | g_object_set(G_OBJECT(tag), "foreground-gdk", color, NULL); |
|
7be2af5c9129
Show visited links in a different color. This also plugs a memory leak
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23548
diff
changeset
|
459 | gdk_color_free(color); |
|
7be2af5c9129
Show visited links in a different color. This also plugs a memory leak
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23548
diff
changeset
|
460 | } else { |
|
7be2af5c9129
Show visited links in a different color. This also plugs a memory leak
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23548
diff
changeset
|
461 | g_object_set(G_OBJECT(tag), "foreground", visited ? "#800000" : "blue", NULL); |
|
7be2af5c9129
Show visited links in a different color. This also plugs a memory leak
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23548
diff
changeset
|
462 | } |
|
7be2af5c9129
Show visited links in a different color. This also plugs a memory leak
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23548
diff
changeset
|
463 | } |
|
7be2af5c9129
Show visited links in a different color. This also plugs a memory leak
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23548
diff
changeset
|
464 | |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
465 | static gint |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
466 | gtk_imhtml_tip_paint (GtkIMHtml *imhtml) |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
467 | { |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
468 | PangoLayout *layout; |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
469 | |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
470 | g_return_val_if_fail(GTK_IS_IMHTML(imhtml), FALSE); |
|
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 | layout = gtk_widget_create_pango_layout(imhtml->tip_window, imhtml->tip); |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
473 | |
| 8061 | 474 | 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
|
475 | GTK_STATE_NORMAL, GTK_SHADOW_OUT, NULL, imhtml->tip_window, |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
476 | "tooltip", 0, 0, -1, -1); |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
477 | |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
478 | 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
|
479 | FALSE, NULL, imhtml->tip_window, NULL, 4, 4, layout); |
|
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 | g_object_unref(layout); |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
482 | return FALSE; |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
483 | } |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
484 | |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
485 | static gint |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
486 | gtk_imhtml_tip (gpointer data) |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
487 | { |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
488 | GtkIMHtml *imhtml = data; |
| 8526 | 489 | PangoFontMetrics *font_metrics; |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
490 | PangoLayout *layout; |
| 8526 | 491 | PangoFont *font; |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
492 | |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
493 | gint gap, x, y, h, w, scr_w, baseline_skip; |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
494 | |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
495 | g_return_val_if_fail(GTK_IS_IMHTML(imhtml), FALSE); |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
496 | |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
497 | if (!imhtml->tip || !GTK_WIDGET_DRAWABLE (GTK_WIDGET(imhtml))) { |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
498 | imhtml->tip_timer = 0; |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
499 | return FALSE; |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
500 | } |
| 8061 | 501 | |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
502 | if (imhtml->tip_window){ |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
503 | gtk_widget_destroy (imhtml->tip_window); |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
504 | imhtml->tip_window = NULL; |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
505 | } |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
506 | |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
507 | imhtml->tip_timer = 0; |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
508 | imhtml->tip_window = gtk_window_new (GTK_WINDOW_POPUP); |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
509 | gtk_widget_set_app_paintable (imhtml->tip_window, TRUE); |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
510 | gtk_window_set_resizable (GTK_WINDOW (imhtml->tip_window), FALSE); |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
511 | gtk_widget_set_name (imhtml->tip_window, "gtk-tooltips"); |
|
22595
5ce90eecd894
GDK_WINDOW_TYPE_HINT_TOOLTIP is new with Gtk 2.10
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22594
diff
changeset
|
512 | #if GTK_CHECK_VERSION(2,10,0) |
|
22594
4fe64dc3d266
Set the TOOLTIP hint on imhtml link tooltips. Thanks to Danny Baumann for
Will Thompson <resiak@pidgin.im>
parents:
22532
diff
changeset
|
513 | gtk_window_set_type_hint (GTK_WINDOW (imhtml->tip_window), |
|
4fe64dc3d266
Set the TOOLTIP hint on imhtml link tooltips. Thanks to Danny Baumann for
Will Thompson <resiak@pidgin.im>
parents:
22532
diff
changeset
|
514 | GDK_WINDOW_TYPE_HINT_TOOLTIP); |
|
22595
5ce90eecd894
GDK_WINDOW_TYPE_HINT_TOOLTIP is new with Gtk 2.10
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22594
diff
changeset
|
515 | #endif |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
516 | g_signal_connect_swapped (G_OBJECT (imhtml->tip_window), "expose_event", |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
517 | G_CALLBACK (gtk_imhtml_tip_paint), imhtml); |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
518 | |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
519 | gtk_widget_ensure_style (imhtml->tip_window); |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
520 | layout = gtk_widget_create_pango_layout(imhtml->tip_window, imhtml->tip); |
| 8526 | 521 | font = pango_context_load_font(pango_layout_get_context(layout), |
| 522 | imhtml->tip_window->style->font_desc); | |
| 523 | ||
| 524 | if (font == NULL) { | |
| 525 | char *tmp = pango_font_description_to_string( | |
| 526 | imhtml->tip_window->style->font_desc); | |
| 527 | ||
| 15884 | 528 | purple_debug(PURPLE_DEBUG_ERROR, "gtk_imhtml_tip", |
| 8526 | 529 | "pango_context_load_font() couldn't load font: '%s'\n", |
| 530 | tmp); | |
| 531 | g_free(tmp); | |
| 532 | ||
|
23174
6a5b2c601492
applied changes from a341780d901f6351a5cf768a08d30c8882d6cf2f
Daniel Atallah <datallah@pidgin.im>
parents:
22970
diff
changeset
|
533 | g_object_unref(layout); |
| 8526 | 534 | return FALSE; |
| 535 | } | |
| 536 | ||
| 537 | font_metrics = pango_font_get_metrics(font, NULL); | |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
538 | |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
539 | pango_layout_get_pixel_size(layout, &scr_w, NULL); |
| 8526 | 540 | gap = PANGO_PIXELS((pango_font_metrics_get_ascent(font_metrics) + |
| 541 | pango_font_metrics_get_descent(font_metrics))/ 4); | |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
542 | |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
543 | if (gap < 2) |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
544 | gap = 2; |
| 8526 | 545 | baseline_skip = PANGO_PIXELS(pango_font_metrics_get_ascent(font_metrics) + |
| 546 | pango_font_metrics_get_descent(font_metrics)); | |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
547 | w = 8 + scr_w; |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
548 | h = 8 + baseline_skip; |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
549 | |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
550 | gdk_window_get_pointer (NULL, &x, &y, NULL); |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
551 | if (GTK_WIDGET_NO_WINDOW (GTK_WIDGET(imhtml))) |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
552 | y += GTK_WIDGET(imhtml)->allocation.y; |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
553 | |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
554 | scr_w = gdk_screen_width(); |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
555 | |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
556 | x -= ((w >> 1) + 4); |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
557 | |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
558 | if ((x + w) > scr_w) |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
559 | x -= (x + w) - scr_w; |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
560 | else if (x < 0) |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
561 | x = 0; |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
562 | |
| 8526 | 563 | y = y + PANGO_PIXELS(pango_font_metrics_get_ascent(font_metrics) + |
| 564 | pango_font_metrics_get_descent(font_metrics)); | |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
565 | |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
566 | 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
|
567 | gtk_window_move (GTK_WINDOW(imhtml->tip_window), x, y); |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
568 | gtk_widget_show (imhtml->tip_window); |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
569 | |
| 8526 | 570 | pango_font_metrics_unref(font_metrics); |
|
23174
6a5b2c601492
applied changes from a341780d901f6351a5cf768a08d30c8882d6cf2f
Daniel Atallah <datallah@pidgin.im>
parents:
22970
diff
changeset
|
571 | g_object_unref(font); |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
572 | g_object_unref(layout); |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
573 | |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
574 | return FALSE; |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
575 | } |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
576 | |
|
11844
57ad7c52cc9c
[gaim-migrate @ 14135]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11840
diff
changeset
|
577 | static gboolean |
|
57ad7c52cc9c
[gaim-migrate @ 14135]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11840
diff
changeset
|
578 | gtk_motion_event_notify(GtkWidget *imhtml, GdkEventMotion *event, gpointer data) |
| 8061 | 579 | { |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
580 | GtkTextIter iter; |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
581 | GdkWindow *win = event->window; |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
582 | int x, y; |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
583 | char *tip = NULL; |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
584 | GSList *tags = NULL, *templist = NULL; |
| 10799 | 585 | GtkTextTag *tag = NULL, *oldprelit_tag; |
|
18543
c590aed61aa4
Show tooltip for smileys. Fixes #1981.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18371
diff
changeset
|
586 | GtkTextChildAnchor* anchor; |
|
c590aed61aa4
Show tooltip for smileys. Fixes #1981.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18371
diff
changeset
|
587 | gboolean hand = TRUE; |
| 10799 | 588 | |
| 589 | oldprelit_tag = GTK_IMHTML(imhtml)->prelit_tag; | |
| 590 | ||
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
591 | gdk_window_get_pointer(GTK_WIDGET(imhtml)->window, NULL, NULL, NULL); |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
592 | gtk_text_view_window_to_buffer_coords(GTK_TEXT_VIEW(imhtml), GTK_TEXT_WINDOW_WIDGET, |
| 10799 | 593 | event->x, event->y, &x, &y); |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
594 | 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
|
595 | tags = gtk_text_iter_get_tags(&iter); |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
596 | |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
597 | templist = tags; |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
598 | while (templist) { |
| 10799 | 599 | tag = templist->data; |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
600 | tip = g_object_get_data(G_OBJECT(tag), "link_url"); |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
601 | if (tip) |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
602 | break; |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
603 | templist = templist->next; |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
604 | } |
| 8061 | 605 | |
|
24328
7be2af5c9129
Show visited links in a different color. This also plugs a memory leak
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23548
diff
changeset
|
606 | if (tip && (!tag || !g_object_get_data(G_OBJECT(tag), "visited"))) { |
| 10799 | 607 | GTK_IMHTML(imhtml)->prelit_tag = tag; |
| 608 | if (tag != oldprelit_tag) { | |
|
24328
7be2af5c9129
Show visited links in a different color. This also plugs a memory leak
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23548
diff
changeset
|
609 | GdkColor *pre = NULL; |
|
7be2af5c9129
Show visited links in a different color. This also plugs a memory leak
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23548
diff
changeset
|
610 | gtk_widget_style_get(GTK_WIDGET(imhtml), "hyperlink-prelight-color", &pre, NULL); |
|
7be2af5c9129
Show visited links in a different color. This also plugs a memory leak
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23548
diff
changeset
|
611 | if (pre) { |
| 10799 | 612 | g_object_set(G_OBJECT(tag), "foreground-gdk", pre, NULL); |
|
24328
7be2af5c9129
Show visited links in a different color. This also plugs a memory leak
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23548
diff
changeset
|
613 | gdk_color_free(pre); |
|
7be2af5c9129
Show visited links in a different color. This also plugs a memory leak
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23548
diff
changeset
|
614 | } else |
|
12253
5025434b18f8
[gaim-migrate @ 14555]
Mark Doliner <markdoliner@pidgin.im>
parents:
12230
diff
changeset
|
615 | g_object_set(G_OBJECT(tag), "foreground", "#70a0ff", NULL); |
| 10799 | 616 | } |
| 617 | } else { | |
| 618 | GTK_IMHTML(imhtml)->prelit_tag = NULL; | |
| 619 | } | |
|
11572
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
620 | |
|
10834
5fd1dfd395e8
[gaim-migrate @ 12505]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10826
diff
changeset
|
621 | if ((oldprelit_tag != NULL) && (GTK_IMHTML(imhtml)->prelit_tag != oldprelit_tag)) { |
|
24328
7be2af5c9129
Show visited links in a different color. This also plugs a memory leak
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23548
diff
changeset
|
622 | gtk_imhtml_set_link_color(GTK_IMHTML(imhtml), oldprelit_tag); |
| 10799 | 623 | } |
| 624 | ||
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
625 | if (GTK_IMHTML(imhtml)->tip) { |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
626 | if ((tip == GTK_IMHTML(imhtml)->tip)) { |
| 21069 | 627 | g_slist_free(tags); |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
628 | return FALSE; |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
629 | } |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
630 | /* 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
|
631 | if (GTK_IMHTML(imhtml)->tip_window) { |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
632 | gtk_widget_destroy(GTK_IMHTML(imhtml)->tip_window); |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
633 | GTK_IMHTML(imhtml)->tip_window = NULL; |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
634 | } |
| 8061 | 635 | if (GTK_IMHTML(imhtml)->editable) |
| 636 | gdk_window_set_cursor(win, GTK_IMHTML(imhtml)->text_cursor); | |
| 637 | else | |
| 638 | gdk_window_set_cursor(win, GTK_IMHTML(imhtml)->arrow_cursor); | |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
639 | if (GTK_IMHTML(imhtml)->tip_timer) |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
640 | g_source_remove(GTK_IMHTML(imhtml)->tip_timer); |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
641 | GTK_IMHTML(imhtml)->tip_timer = 0; |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
642 | } |
| 8061 | 643 | |
|
18543
c590aed61aa4
Show tooltip for smileys. Fixes #1981.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18371
diff
changeset
|
644 | /* 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
|
645 | 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
|
646 | if (anchor) { |
|
22803
e1f64090d32e
Do not show tooltips for <HR> or <IMG>s in gtkimhtml. Fixes #5480.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22772
diff
changeset
|
647 | tip = g_object_get_data(G_OBJECT(anchor), "gtkimhtml_tiptext"); |
|
18543
c590aed61aa4
Show tooltip for smileys. Fixes #1981.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18371
diff
changeset
|
648 | hand = FALSE; |
|
c590aed61aa4
Show tooltip for smileys. Fixes #1981.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18371
diff
changeset
|
649 | } |
|
c590aed61aa4
Show tooltip for smileys. Fixes #1981.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18371
diff
changeset
|
650 | |
|
22803
e1f64090d32e
Do not show tooltips for <HR> or <IMG>s in gtkimhtml. Fixes #5480.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22772
diff
changeset
|
651 | if (tip && *tip) { |
|
18543
c590aed61aa4
Show tooltip for smileys. Fixes #1981.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18371
diff
changeset
|
652 | if (!GTK_IMHTML(imhtml)->editable && hand) |
| 8061 | 653 | gdk_window_set_cursor(win, GTK_IMHTML(imhtml)->hand_cursor); |
| 654 | GTK_IMHTML(imhtml)->tip_timer = g_timeout_add (TOOLTIP_TIMEOUT, | |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
655 | gtk_imhtml_tip, imhtml); |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
656 | } |
| 8061 | 657 | |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
658 | GTK_IMHTML(imhtml)->tip = tip; |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
659 | g_slist_free(tags); |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
660 | return FALSE; |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
661 | } |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
662 | |
|
11677
89c2ab8d2ebf
[gaim-migrate @ 13963]
Mark Doliner <markdoliner@pidgin.im>
parents:
11586
diff
changeset
|
663 | static gboolean |
|
89c2ab8d2ebf
[gaim-migrate @ 13963]
Mark Doliner <markdoliner@pidgin.im>
parents:
11586
diff
changeset
|
664 | gtk_enter_event_notify(GtkWidget *imhtml, GdkEventCrossing *event, gpointer data) |
|
10946
63a41710fc94
[gaim-migrate @ 12742]
Daniel Atallah <datallah@pidgin.im>
parents:
10936
diff
changeset
|
665 | { |
|
63a41710fc94
[gaim-migrate @ 12742]
Daniel Atallah <datallah@pidgin.im>
parents:
10936
diff
changeset
|
666 | if (GTK_IMHTML(imhtml)->editable) |
|
63a41710fc94
[gaim-migrate @ 12742]
Daniel Atallah <datallah@pidgin.im>
parents:
10936
diff
changeset
|
667 | gdk_window_set_cursor( |
|
63a41710fc94
[gaim-migrate @ 12742]
Daniel Atallah <datallah@pidgin.im>
parents:
10936
diff
changeset
|
668 | gtk_text_view_get_window(GTK_TEXT_VIEW(imhtml), |
|
63a41710fc94
[gaim-migrate @ 12742]
Daniel Atallah <datallah@pidgin.im>
parents:
10936
diff
changeset
|
669 | GTK_TEXT_WINDOW_TEXT), |
|
63a41710fc94
[gaim-migrate @ 12742]
Daniel Atallah <datallah@pidgin.im>
parents:
10936
diff
changeset
|
670 | GTK_IMHTML(imhtml)->text_cursor); |
|
63a41710fc94
[gaim-migrate @ 12742]
Daniel Atallah <datallah@pidgin.im>
parents:
10936
diff
changeset
|
671 | else |
|
63a41710fc94
[gaim-migrate @ 12742]
Daniel Atallah <datallah@pidgin.im>
parents:
10936
diff
changeset
|
672 | gdk_window_set_cursor( |
|
63a41710fc94
[gaim-migrate @ 12742]
Daniel Atallah <datallah@pidgin.im>
parents:
10936
diff
changeset
|
673 | gtk_text_view_get_window(GTK_TEXT_VIEW(imhtml), |
|
63a41710fc94
[gaim-migrate @ 12742]
Daniel Atallah <datallah@pidgin.im>
parents:
10936
diff
changeset
|
674 | GTK_TEXT_WINDOW_TEXT), |
|
63a41710fc94
[gaim-migrate @ 12742]
Daniel Atallah <datallah@pidgin.im>
parents:
10936
diff
changeset
|
675 | GTK_IMHTML(imhtml)->arrow_cursor); |
|
63a41710fc94
[gaim-migrate @ 12742]
Daniel Atallah <datallah@pidgin.im>
parents:
10936
diff
changeset
|
676 | |
|
63a41710fc94
[gaim-migrate @ 12742]
Daniel Atallah <datallah@pidgin.im>
parents:
10936
diff
changeset
|
677 | /* propagate the event normally */ |
|
63a41710fc94
[gaim-migrate @ 12742]
Daniel Atallah <datallah@pidgin.im>
parents:
10936
diff
changeset
|
678 | return FALSE; |
|
63a41710fc94
[gaim-migrate @ 12742]
Daniel Atallah <datallah@pidgin.im>
parents:
10936
diff
changeset
|
679 | } |
|
63a41710fc94
[gaim-migrate @ 12742]
Daniel Atallah <datallah@pidgin.im>
parents:
10936
diff
changeset
|
680 | |
|
11677
89c2ab8d2ebf
[gaim-migrate @ 13963]
Mark Doliner <markdoliner@pidgin.im>
parents:
11586
diff
changeset
|
681 | static gboolean |
|
89c2ab8d2ebf
[gaim-migrate @ 13963]
Mark Doliner <markdoliner@pidgin.im>
parents:
11586
diff
changeset
|
682 | gtk_leave_event_notify(GtkWidget *imhtml, GdkEventCrossing *event, gpointer data) |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
683 | { |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
684 | /* when leaving the widget, clear any current & pending tooltips and restore the cursor */ |
| 10799 | 685 | if (GTK_IMHTML(imhtml)->prelit_tag) { |
|
24328
7be2af5c9129
Show visited links in a different color. This also plugs a memory leak
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23548
diff
changeset
|
686 | gtk_imhtml_set_link_color(GTK_IMHTML(imhtml), GTK_IMHTML(imhtml)->prelit_tag); |
| 10799 | 687 | GTK_IMHTML(imhtml)->prelit_tag = NULL; |
| 688 | } | |
| 689 | ||
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
690 | if (GTK_IMHTML(imhtml)->tip_window) { |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
691 | gtk_widget_destroy(GTK_IMHTML(imhtml)->tip_window); |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
692 | GTK_IMHTML(imhtml)->tip_window = NULL; |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
693 | } |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
694 | if (GTK_IMHTML(imhtml)->tip_timer) { |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
695 | g_source_remove(GTK_IMHTML(imhtml)->tip_timer); |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
696 | GTK_IMHTML(imhtml)->tip_timer = 0; |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
697 | } |
|
10946
63a41710fc94
[gaim-migrate @ 12742]
Daniel Atallah <datallah@pidgin.im>
parents:
10936
diff
changeset
|
698 | gdk_window_set_cursor( |
|
63a41710fc94
[gaim-migrate @ 12742]
Daniel Atallah <datallah@pidgin.im>
parents:
10936
diff
changeset
|
699 | gtk_text_view_get_window(GTK_TEXT_VIEW(imhtml), |
|
63a41710fc94
[gaim-migrate @ 12742]
Daniel Atallah <datallah@pidgin.im>
parents:
10936
diff
changeset
|
700 | GTK_TEXT_WINDOW_TEXT), NULL); |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
701 | |
|
8568
66907b37ce85
[gaim-migrate @ 9316]
Mark Doliner <markdoliner@pidgin.im>
parents:
8566
diff
changeset
|
702 | /* propagate the event normally */ |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
703 | return FALSE; |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
704 | } |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
705 | |
|
10844
fb5b88957742
[gaim-migrate @ 12516]
Richard Laager <rlaager@pidgin.im>
parents:
10834
diff
changeset
|
706 | #if (!GTK_CHECK_VERSION(2,2,0)) |
| 6066 | 707 | /* |
| 708 | * XXX - This should be removed eventually. | |
| 709 | * | |
| 8061 | 710 | * This function exists to work around a gross bug in GtkTextView. |
| 711 | * Basically, we short circuit ctrl+a and ctrl+end because they make | |
| 6066 | 712 | * el program go boom. |
| 713 | * | |
| 8061 | 714 | * It's supposed to be fixed in gtk2.2. You can view the bug report at |
| 6066 | 715 | * http://bugzilla.gnome.org/show_bug.cgi?id=107939 |
| 716 | */ | |
|
10849
476d68d7a435
[gaim-migrate @ 12521]
Richard Laager <rlaager@pidgin.im>
parents:
10844
diff
changeset
|
717 | static gboolean |
|
476d68d7a435
[gaim-migrate @ 12521]
Richard Laager <rlaager@pidgin.im>
parents:
10844
diff
changeset
|
718 | gtk_key_pressed_cb(GtkIMHtml *imhtml, GdkEventKey *event, gpointer data) |
| 8677 | 719 | { |
|
10844
fb5b88957742
[gaim-migrate @ 12516]
Richard Laager <rlaager@pidgin.im>
parents:
10834
diff
changeset
|
720 | if (event->state & GDK_CONTROL_MASK) { |
| 6066 | 721 | switch (event->keyval) { |
|
10844
fb5b88957742
[gaim-migrate @ 12516]
Richard Laager <rlaager@pidgin.im>
parents:
10834
diff
changeset
|
722 | case 'a': |
|
fb5b88957742
[gaim-migrate @ 12516]
Richard Laager <rlaager@pidgin.im>
parents:
10834
diff
changeset
|
723 | case GDK_Home: |
|
fb5b88957742
[gaim-migrate @ 12516]
Richard Laager <rlaager@pidgin.im>
parents:
10834
diff
changeset
|
724 | case GDK_End: |
|
fb5b88957742
[gaim-migrate @ 12516]
Richard Laager <rlaager@pidgin.im>
parents:
10834
diff
changeset
|
725 | return TRUE; |
| 6066 | 726 | } |
|
10844
fb5b88957742
[gaim-migrate @ 12516]
Richard Laager <rlaager@pidgin.im>
parents:
10834
diff
changeset
|
727 | } |
| 6066 | 728 | return FALSE; |
| 729 | } | |
|
10844
fb5b88957742
[gaim-migrate @ 12516]
Richard Laager <rlaager@pidgin.im>
parents:
10834
diff
changeset
|
730 | #endif /* !(GTK+ >= 2.2.0) */ |
| 10692 | 731 | |
| 732 | static gint | |
| 733 | gtk_imhtml_expose_event (GtkWidget *widget, | |
| 734 | GdkEventExpose *event) | |
| 735 | { | |
| 10776 | 736 | GtkTextIter start, end, cur; |
| 737 | int buf_x, buf_y; | |
| 738 | GdkRectangle visible_rect; | |
| 10777 | 739 | GdkGC *gc = gdk_gc_new(GDK_DRAWABLE(event->window)); |
| 740 | GdkColor gcolor; | |
|
10844
fb5b88957742
[gaim-migrate @ 12516]
Richard Laager <rlaager@pidgin.im>
parents:
10834
diff
changeset
|
741 | |
| 10776 | 742 | gtk_text_view_get_visible_rect(GTK_TEXT_VIEW(widget), &visible_rect); |
| 743 | gtk_text_view_buffer_to_window_coords(GTK_TEXT_VIEW(widget), | |
| 744 | GTK_TEXT_WINDOW_TEXT, | |
| 745 | visible_rect.x, | |
| 746 | visible_rect.y, | |
| 747 | &visible_rect.x, | |
| 748 | &visible_rect.y); | |
| 749 | ||
| 750 | gtk_text_view_window_to_buffer_coords(GTK_TEXT_VIEW(widget), GTK_TEXT_WINDOW_TEXT, | |
| 751 | event->area.x, event->area.y, &buf_x, &buf_y); | |
| 752 | ||
| 10777 | 753 | if (GTK_IMHTML(widget)->editable || GTK_IMHTML(widget)->wbfo) { |
|
11572
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
754 | |
| 10777 | 755 | if (GTK_IMHTML(widget)->edit.background) { |
| 756 | gdk_color_parse(GTK_IMHTML(widget)->edit.background, &gcolor); | |
| 757 | gdk_gc_set_rgb_fg_color(gc, &gcolor); | |
| 758 | } else { | |
| 759 | gdk_gc_set_rgb_fg_color(gc, &(widget->style->base[GTK_WIDGET_STATE(widget)])); | |
| 760 | } | |
|
11572
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
761 | |
| 10777 | 762 | gdk_draw_rectangle(event->window, |
| 763 | gc, | |
| 764 | TRUE, | |
| 765 | visible_rect.x, visible_rect.y, visible_rect.width, visible_rect.height); | |
| 766 | gdk_gc_unref(gc); | |
|
11572
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
767 | |
| 10777 | 768 | if (GTK_WIDGET_CLASS (parent_class)->expose_event) |
| 769 | return (* GTK_WIDGET_CLASS (parent_class)->expose_event) | |
| 770 | (widget, event); | |
| 771 | return FALSE; | |
| 772 | ||
| 773 | } | |
|
11572
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
774 | |
| 10776 | 775 | gtk_text_view_get_iter_at_location(GTK_TEXT_VIEW(widget), &start, buf_x, buf_y); |
| 776 | gtk_text_view_get_iter_at_location(GTK_TEXT_VIEW(widget), &end, | |
| 777 | buf_x + event->area.width, buf_y + event->area.height); | |
| 778 | ||
|
23187
671e00775afb
*** Plucked rev 69b22e32f7ada182101e0746f02891389ceb0c52 (sadrul@pidgin.im):
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23174
diff
changeset
|
779 | gtk_text_iter_order(&start, &end); |
| 10776 | 780 | |
| 781 | cur = start; | |
| 782 | ||
| 783 | while (gtk_text_iter_in_range(&cur, &start, &end)) { | |
| 10795 | 784 | GSList *tags = gtk_text_iter_get_tags(&cur); |
| 785 | GSList *l; | |
| 10776 | 786 | |
| 787 | for (l = tags; l; l = l->next) { | |
| 788 | GtkTextTag *tag = l->data; | |
| 789 | GdkRectangle rect; | |
| 790 | GdkRectangle tag_area; | |
| 791 | const char *color; | |
|
11572
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
792 | |
| 10776 | 793 | if (strncmp(tag->name, "BACKGROUND ", 11)) |
| 794 | continue; | |
| 795 | ||
| 796 | if (gtk_text_iter_ends_tag(&cur, tag)) | |
| 797 | continue; | |
| 798 | ||
| 799 | gtk_text_view_get_iter_location(GTK_TEXT_VIEW(widget), &cur, &tag_area); | |
| 800 | gtk_text_view_buffer_to_window_coords(GTK_TEXT_VIEW(widget), | |
| 801 | GTK_TEXT_WINDOW_TEXT, | |
| 802 | tag_area.x, | |
| 803 | tag_area.y, | |
| 804 | &tag_area.x, | |
| 805 | &tag_area.y); | |
| 806 | rect.x = visible_rect.x; | |
| 807 | rect.y = tag_area.y; | |
|
11768
b45e26d7a4c9
[gaim-migrate @ 14059]
Gary Kramlich <grim@reaperworld.com>
parents:
11760
diff
changeset
|
808 | rect.width = visible_rect.width; |
| 10776 | 809 | |
| 10795 | 810 | do |
| 10776 | 811 | gtk_text_iter_forward_to_tag_toggle(&cur, tag); |
| 10795 | 812 | while (!gtk_text_iter_is_end(&cur) && gtk_text_iter_begins_tag(&cur, tag)); |
| 813 | ||
| 10776 | 814 | gtk_text_view_get_iter_location(GTK_TEXT_VIEW(widget), &cur, &tag_area); |
| 815 | gtk_text_view_buffer_to_window_coords(GTK_TEXT_VIEW(widget), | |
| 816 | GTK_TEXT_WINDOW_TEXT, | |
| 817 | tag_area.x, | |
| 818 | tag_area.y, | |
| 819 | &tag_area.x, | |
| 820 | &tag_area.y); | |
| 821 | ||
| 11760 | 822 | |
| 823 | rect.height = tag_area.y + tag_area.height - rect.y | |
|
22865
eeed3e121bed
Move 2 of the 5 pixels' padding between paragraphs to above the line.
Will Thompson <resiak@pidgin.im>
parents:
22834
diff
changeset
|
824 | + gtk_text_view_get_pixels_above_lines(GTK_TEXT_VIEW(widget)) |
| 11760 | 825 | + 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
|
826 | |
| 10776 | 827 | color = tag->name + 11; |
| 828 | ||
| 10857 | 829 | if (!gdk_color_parse(color, &gcolor)) { |
| 10858 | 830 | gchar tmp[8]; |
| 831 | tmp[0] = '#'; | |
| 832 | strncpy(&tmp[1], color, 7); | |
| 833 | tmp[7] = '\0'; | |
| 10857 | 834 | if (!gdk_color_parse(tmp, &gcolor)) |
| 835 | gdk_color_parse("white", &gcolor); | |
| 836 | } | |
| 10776 | 837 | gdk_gc_set_rgb_fg_color(gc, &gcolor); |
| 838 | ||
| 839 | gdk_draw_rectangle(event->window, | |
| 840 | gc, | |
| 841 | TRUE, | |
| 842 | rect.x, rect.y, rect.width, rect.height); | |
| 10795 | 843 | gtk_text_iter_backward_char(&cur); /* go back one, in case the end is the begining is the end |
| 844 | * note that above, we always moved cur ahead by at least | |
| 845 | * one character */ | |
| 10776 | 846 | break; |
| 847 | } | |
| 848 | ||
| 849 | g_slist_free(tags); | |
| 10795 | 850 | |
| 851 | /* loop until another tag begins, or no tag begins */ | |
| 852 | while (gtk_text_iter_forward_to_tag_toggle(&cur, NULL) && | |
| 853 | !gtk_text_iter_is_end(&cur) && | |
| 854 | !gtk_text_iter_begins_tag(&cur, NULL)); | |
|
11572
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
855 | } |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
856 | |
| 10777 | 857 | gdk_gc_unref(gc); |
| 858 | ||
| 10692 | 859 | if (GTK_WIDGET_CLASS (parent_class)->expose_event) |
| 860 | return (* GTK_WIDGET_CLASS (parent_class)->expose_event) | |
| 861 | (widget, event); | |
| 10776 | 862 | |
| 10692 | 863 | return FALSE; |
| 864 | } | |
| 865 | ||
| 866 | ||
| 8931 | 867 | static void paste_unformatted_cb(GtkMenuItem *menu, GtkIMHtml *imhtml) |
| 868 | { | |
| 869 | GtkClipboard *clipboard = gtk_widget_get_clipboard(GTK_WIDGET(imhtml), GDK_SELECTION_CLIPBOARD); | |
| 870 | ||
| 871 | gtk_clipboard_request_text(clipboard, paste_plaintext_received_cb, imhtml); | |
| 872 | ||
| 873 | } | |
| 874 | ||
| 13336 | 875 | static void clear_formatting_cb(GtkMenuItem *menu, GtkIMHtml *imhtml) |
| 876 | { | |
| 877 | gtk_imhtml_clear_formatting(imhtml); | |
| 878 | } | |
| 10692 | 879 | |
|
22970
87aef86d20c5
Allow replacing smileys with texts in conversations/logs. This should be
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22865
diff
changeset
|
880 | static void disable_smiley_selected(GtkMenuItem *item, GtkIMHtml *imhtml) |
|
87aef86d20c5
Allow replacing smileys with texts in conversations/logs. This should be
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22865
diff
changeset
|
881 | { |
|
87aef86d20c5
Allow replacing smileys with texts in conversations/logs. This should be
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22865
diff
changeset
|
882 | GtkTextIter start, end; |
|
87aef86d20c5
Allow replacing smileys with texts in conversations/logs. This should be
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22865
diff
changeset
|
883 | GtkTextMark *mark; |
|
87aef86d20c5
Allow replacing smileys with texts in conversations/logs. This should be
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22865
diff
changeset
|
884 | char *text; |
|
87aef86d20c5
Allow replacing smileys with texts in conversations/logs. This should be
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22865
diff
changeset
|
885 | |
|
87aef86d20c5
Allow replacing smileys with texts in conversations/logs. This should be
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22865
diff
changeset
|
886 | if (!gtk_text_buffer_get_selection_bounds(imhtml->text_buffer, &start, &end)) |
|
87aef86d20c5
Allow replacing smileys with texts in conversations/logs. This should be
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22865
diff
changeset
|
887 | return; |
|
87aef86d20c5
Allow replacing smileys with texts in conversations/logs. This should be
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22865
diff
changeset
|
888 | |
|
87aef86d20c5
Allow replacing smileys with texts in conversations/logs. This should be
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22865
diff
changeset
|
889 | text = gtk_imhtml_get_markup_range(imhtml, &start, &end); |
|
87aef86d20c5
Allow replacing smileys with texts in conversations/logs. This should be
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22865
diff
changeset
|
890 | |
|
87aef86d20c5
Allow replacing smileys with texts in conversations/logs. This should be
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22865
diff
changeset
|
891 | mark = gtk_text_buffer_get_selection_bound(imhtml->text_buffer); |
|
87aef86d20c5
Allow replacing smileys with texts in conversations/logs. This should be
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22865
diff
changeset
|
892 | gtk_text_buffer_delete_selection(imhtml->text_buffer, FALSE, FALSE); |
|
87aef86d20c5
Allow replacing smileys with texts in conversations/logs. This should be
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22865
diff
changeset
|
893 | |
|
87aef86d20c5
Allow replacing smileys with texts in conversations/logs. This should be
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22865
diff
changeset
|
894 | gtk_text_buffer_get_iter_at_mark(imhtml->text_buffer, &start, mark); |
|
87aef86d20c5
Allow replacing smileys with texts in conversations/logs. This should be
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22865
diff
changeset
|
895 | gtk_imhtml_insert_html_at_iter(imhtml, text, GTK_IMHTML_NO_NEWLINE | GTK_IMHTML_NO_SMILEY, &start); |
|
87aef86d20c5
Allow replacing smileys with texts in conversations/logs. This should be
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22865
diff
changeset
|
896 | |
|
87aef86d20c5
Allow replacing smileys with texts in conversations/logs. This should be
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22865
diff
changeset
|
897 | g_free(text); |
|
87aef86d20c5
Allow replacing smileys with texts in conversations/logs. This should be
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22865
diff
changeset
|
898 | } |
|
87aef86d20c5
Allow replacing smileys with texts in conversations/logs. This should be
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22865
diff
changeset
|
899 | |
| 8931 | 900 | static void hijack_menu_cb(GtkIMHtml *imhtml, GtkMenu *menu, gpointer data) |
| 901 | { | |
| 902 | GtkWidget *menuitem; | |
|
22970
87aef86d20c5
Allow replacing smileys with texts in conversations/logs. This should be
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22865
diff
changeset
|
903 | GtkTextIter start, end; |
| 8931 | 904 | |
|
12635
5b2fbc3da55b
[gaim-migrate @ 14971]
Richard Laager <rlaager@pidgin.im>
parents:
12605
diff
changeset
|
905 | menuitem = gtk_menu_item_new_with_mnemonic(_("Paste as Plain _Text")); |
| 8931 | 906 | gtk_widget_show(menuitem); |
|
14970
fd8984ce4fda
[gaim-migrate @ 17680]
Mark Doliner <markdoliner@pidgin.im>
parents:
14863
diff
changeset
|
907 | /* |
|
fd8984ce4fda
[gaim-migrate @ 17680]
Mark Doliner <markdoliner@pidgin.im>
parents:
14863
diff
changeset
|
908 | * TODO: gtk_clipboard_wait_is_text_available() iterates the glib |
|
fd8984ce4fda
[gaim-migrate @ 17680]
Mark Doliner <markdoliner@pidgin.im>
parents:
14863
diff
changeset
|
909 | * mainloop, which tends to be a source of bugs. It would |
|
fd8984ce4fda
[gaim-migrate @ 17680]
Mark Doliner <markdoliner@pidgin.im>
parents:
14863
diff
changeset
|
910 | * be good to audit this or change it to not wait. |
|
fd8984ce4fda
[gaim-migrate @ 17680]
Mark Doliner <markdoliner@pidgin.im>
parents:
14863
diff
changeset
|
911 | */ |
| 8931 | 912 | gtk_widget_set_sensitive(menuitem, |
|
12836
837fe5d43dac
[gaim-migrate @ 15184]
Richard Laager <rlaager@pidgin.im>
parents:
12833
diff
changeset
|
913 | (imhtml->editable && |
|
837fe5d43dac
[gaim-migrate @ 15184]
Richard Laager <rlaager@pidgin.im>
parents:
12833
diff
changeset
|
914 | gtk_clipboard_wait_is_text_available( |
|
837fe5d43dac
[gaim-migrate @ 15184]
Richard Laager <rlaager@pidgin.im>
parents:
12833
diff
changeset
|
915 | gtk_widget_get_clipboard(GTK_WIDGET(imhtml), GDK_SELECTION_CLIPBOARD)))); |
| 8931 | 916 | /* put it after "Paste" */ |
| 917 | gtk_menu_shell_insert(GTK_MENU_SHELL(menu), menuitem, 3); | |
| 918 | ||
| 919 | g_signal_connect(G_OBJECT(menuitem), "activate", | |
| 920 | G_CALLBACK(paste_unformatted_cb), imhtml); | |
| 13336 | 921 | |
|
13539
8036a635a316
[gaim-migrate @ 15915]
Richard Laager <rlaager@pidgin.im>
parents:
13340
diff
changeset
|
922 | menuitem = gtk_menu_item_new_with_mnemonic(_("_Reset formatting")); |
| 13336 | 923 | gtk_widget_show(menuitem); |
|
13340
e18166659513
[gaim-migrate @ 15709]
Richard Laager <rlaager@pidgin.im>
parents:
13336
diff
changeset
|
924 | gtk_widget_set_sensitive(menuitem, imhtml->editable); |
| 13336 | 925 | /* put it after Delete */ |
| 926 | gtk_menu_shell_insert(GTK_MENU_SHELL(menu), menuitem, 5); | |
| 927 | ||
| 928 | g_signal_connect(G_OBJECT(menuitem), "activate", G_CALLBACK(clear_formatting_cb), imhtml); | |
|
22970
87aef86d20c5
Allow replacing smileys with texts in conversations/logs. This should be
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22865
diff
changeset
|
929 | |
|
87aef86d20c5
Allow replacing smileys with texts in conversations/logs. This should be
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22865
diff
changeset
|
930 | menuitem = gtk_menu_item_new_with_mnemonic(_("Disable _smileys in selected text")); |
|
87aef86d20c5
Allow replacing smileys with texts in conversations/logs. This should be
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22865
diff
changeset
|
931 | gtk_widget_show(menuitem); |
|
87aef86d20c5
Allow replacing smileys with texts in conversations/logs. This should be
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22865
diff
changeset
|
932 | if (gtk_text_buffer_get_selection_bounds(imhtml->text_buffer, &start, &end)) { |
|
87aef86d20c5
Allow replacing smileys with texts in conversations/logs. This should be
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22865
diff
changeset
|
933 | g_signal_connect(G_OBJECT(menuitem), "activate", G_CALLBACK(disable_smiley_selected), imhtml); |
|
87aef86d20c5
Allow replacing smileys with texts in conversations/logs. This should be
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22865
diff
changeset
|
934 | } else { |
|
87aef86d20c5
Allow replacing smileys with texts in conversations/logs. This should be
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22865
diff
changeset
|
935 | gtk_widget_set_sensitive(menuitem, FALSE); |
|
87aef86d20c5
Allow replacing smileys with texts in conversations/logs. This should be
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22865
diff
changeset
|
936 | } |
|
87aef86d20c5
Allow replacing smileys with texts in conversations/logs. This should be
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22865
diff
changeset
|
937 | gtk_menu_shell_insert(GTK_MENU_SHELL(menu), menuitem, 6); |
| 8931 | 938 | } |
| 939 | ||
|
11572
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
940 | static char * |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
941 | ucs2_order(gboolean swap) |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
942 | { |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
943 | gboolean be; |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
944 | |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
945 | be = G_BYTE_ORDER == G_BIG_ENDIAN; |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
946 | be = swap ? be : !be; |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
947 | |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
948 | if (be) |
|
22596
0854ae660ef4
Further changes to use UTF-16 instead of UCS-2. Also, fix #5167 by making sure that the encoding conversion worked before using the result.
Daniel Atallah <datallah@pidgin.im>
parents:
22595
diff
changeset
|
949 | return "UTF-16BE"; |
|
11572
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
950 | else |
|
22596
0854ae660ef4
Further changes to use UTF-16 instead of UCS-2. Also, fix #5167 by making sure that the encoding conversion worked before using the result.
Daniel Atallah <datallah@pidgin.im>
parents:
22595
diff
changeset
|
951 | return "UTF-16LE"; |
|
11572
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
952 | |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
953 | } |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
954 | |
|
22596
0854ae660ef4
Further changes to use UTF-16 instead of UCS-2. Also, fix #5167 by making sure that the encoding conversion worked before using the result.
Daniel Atallah <datallah@pidgin.im>
parents:
22595
diff
changeset
|
955 | /* Convert from UTF-16LE to UTF-8, stripping the BOM if one is present.*/ |
|
11572
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
956 | static gchar * |
|
22596
0854ae660ef4
Further changes to use UTF-16 instead of UCS-2. Also, fix #5167 by making sure that the encoding conversion worked before using the result.
Daniel Atallah <datallah@pidgin.im>
parents:
22595
diff
changeset
|
957 | utf16_to_utf8_with_bom_check(gchar *data, guint len) { |
|
11572
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
958 | char *fromcode = NULL; |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
959 | GError *error = NULL; |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
960 | guint16 c; |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
961 | gchar *utf8_ret; |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
962 | |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
963 | /* |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
964 | * Unicode Techinical Report 20 |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
965 | * ( http://www.unicode.org/unicode/reports/tr20/ ) says to treat an |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
966 | * initial 0xfeff (ZWNBSP) as a byte order indicator so that is |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
967 | * 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
|
968 | * order |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
969 | */ |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
970 | |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
971 | memcpy(&c, data, 2); |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
972 | switch (c) { |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
973 | case 0xfeff: |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
974 | case 0xfffe: |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
975 | fromcode = ucs2_order(c == 0xfeff); |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
976 | data += 2; |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
977 | len -= 2; |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
978 | break; |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
979 | default: |
|
22596
0854ae660ef4
Further changes to use UTF-16 instead of UCS-2. Also, fix #5167 by making sure that the encoding conversion worked before using the result.
Daniel Atallah <datallah@pidgin.im>
parents:
22595
diff
changeset
|
980 | fromcode = "UTF-16"; |
|
11572
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
981 | break; |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
982 | } |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
983 | |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
984 | 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
|
985 | |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
986 | if (error) { |
| 15884 | 987 | 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
|
988 | g_error_free(error); |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
989 | } |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
990 | return utf8_ret; |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
991 | } |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
992 | |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
993 | |
| 8061 | 994 | 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
|
995 | 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
|
996 | gboolean primary = (clipboard != clipboard_selection); |
| 8061 | 997 | GtkTextIter start, end; |
|
21085
dff5e0bfb8f5
Don't assign ownership of the CLIPBOARD to the IMHtml - it doesn't really own the data and then we don't have problems of overwriting what others put in the clipboard. Fixes #3616.
Daniel Atallah <datallah@pidgin.im>
parents:
21076
diff
changeset
|
998 | |
|
dff5e0bfb8f5
Don't assign ownership of the CLIPBOARD to the IMHtml - it doesn't really own the data and then we don't have problems of overwriting what others put in the clipboard. Fixes #3616.
Daniel Atallah <datallah@pidgin.im>
parents:
21076
diff
changeset
|
999 | if (primary) { |
|
dff5e0bfb8f5
Don't assign ownership of the CLIPBOARD to the IMHtml - it doesn't really own the data and then we don't have problems of overwriting what others put in the clipboard. Fixes #3616.
Daniel Atallah <datallah@pidgin.im>
parents:
21076
diff
changeset
|
1000 | GtkTextMark *sel = NULL, *ins = NULL; |
|
21643
4d1a61e30199
There appears to be a new GTK+ bug that causes the clipboard_clear callback to be triggered *after* the clipboard_copy callback on the second copy attempt. This makes stuff still work correctly when this happens (and, most importantly, not crash). I'll report this upstream.
Daniel Atallah <datallah@pidgin.im>
parents:
21574
diff
changeset
|
1001 | |
|
4d1a61e30199
There appears to be a new GTK+ bug that causes the clipboard_clear callback to be triggered *after* the clipboard_copy callback on the second copy attempt. This makes stuff still work correctly when this happens (and, most importantly, not crash). I'll report this upstream.
Daniel Atallah <datallah@pidgin.im>
parents:
21574
diff
changeset
|
1002 | g_return_if_fail(imhtml != NULL); |
|
4d1a61e30199
There appears to be a new GTK+ bug that causes the clipboard_clear callback to be triggered *after* the clipboard_copy callback on the second copy attempt. This makes stuff still work correctly when this happens (and, most importantly, not crash). I'll report this upstream.
Daniel Atallah <datallah@pidgin.im>
parents:
21574
diff
changeset
|
1003 | |
|
17546
51b1c1e2c3fe
Maintain global poitners to the clipboard selection text, with the aim of
Sean Egan <seanegan@pidgin.im>
parents:
17406
diff
changeset
|
1004 | 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
|
1005 | 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
|
1006 | 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
|
1007 | 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
|
1008 | } |
| 8061 | 1009 | |
| 1010 | if (info == TARGET_HTML) { | |
|
15111
e427dd6f3b7e
[gaim-migrate @ 17833]
Daniel Atallah <datallah@pidgin.im>
parents:
15093
diff
changeset
|
1011 | char *selection; |
|
e427dd6f3b7e
[gaim-migrate @ 17833]
Daniel Atallah <datallah@pidgin.im>
parents:
15093
diff
changeset
|
1012 | #ifndef _WIN32 |
| 8907 | 1013 | gsize len; |
| 8681 | 1014 | if (primary) { |
| 1015 | text = gtk_imhtml_get_markup_range(imhtml, &start, &end); | |
| 10013 | 1016 | } else |
|
17546
51b1c1e2c3fe
Maintain global poitners to the clipboard selection text, with the aim of
Sean Egan <seanegan@pidgin.im>
parents:
17406
diff
changeset
|
1017 | text = html_clipboard; |
| 8061 | 1018 | |
| 1019 | /* Mozilla asks that we start our text/html with the Unicode byte order mark */ | |
|
23201
a9efe9add251
*** Plucked rev da43d671 (sadrul@pidgin.im):
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23187
diff
changeset
|
1020 | selection = g_convert(text, -1, "UTF-16", "UTF-8", NULL, &len, NULL); |
|
11143
f606fb334190
[gaim-migrate @ 13207]
Mark Doliner <markdoliner@pidgin.im>
parents:
11069
diff
changeset
|
1021 | gtk_selection_data_set(selection_data, gdk_atom_intern("text/html", FALSE), 16, (const guchar *)selection, len); |
|
15111
e427dd6f3b7e
[gaim-migrate @ 17833]
Daniel Atallah <datallah@pidgin.im>
parents:
15093
diff
changeset
|
1022 | #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
|
1023 | selection = clipboard_html_to_win32(html_clipboard); |
|
15111
e427dd6f3b7e
[gaim-migrate @ 17833]
Daniel Atallah <datallah@pidgin.im>
parents:
15093
diff
changeset
|
1024 | 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
|
1025 | #endif |
| 8061 | 1026 | g_free(selection); |
| 1027 | } else { | |
| 8681 | 1028 | if (primary) { |
| 1029 | text = gtk_imhtml_get_text(imhtml, &start, &end); | |
| 1030 | } else | |
|
17546
51b1c1e2c3fe
Maintain global poitners to the clipboard selection text, with the aim of
Sean Egan <seanegan@pidgin.im>
parents:
17406
diff
changeset
|
1031 | text = text_clipboard; |
| 8061 | 1032 | gtk_selection_data_set_text(selection_data, text, strlen(text)); |
| 1033 | } | |
| 8681 | 1034 | if (primary) /* This was allocated here */ |
| 1035 | g_free(text); | |
| 1036 | } | |
| 8061 | 1037 | |
| 1038 | static void gtk_imhtml_primary_clipboard_clear(GtkClipboard *clipboard, GtkIMHtml *imhtml) | |
| 7749 | 1039 | { |
| 8061 | 1040 | GtkTextIter insert; |
| 1041 | GtkTextIter selection_bound; | |
| 1042 | ||
| 1043 | gtk_text_buffer_get_iter_at_mark (imhtml->text_buffer, &insert, | |
| 1044 | gtk_text_buffer_get_mark (imhtml->text_buffer, "insert")); | |
| 1045 | gtk_text_buffer_get_iter_at_mark (imhtml->text_buffer, &selection_bound, | |
| 1046 | gtk_text_buffer_get_mark (imhtml->text_buffer, "selection_bound")); | |
| 1047 | ||
| 1048 | if (!gtk_text_iter_equal (&insert, &selection_bound)) | |
| 1049 | gtk_text_buffer_move_mark (imhtml->text_buffer, | |
| 1050 | gtk_text_buffer_get_mark (imhtml->text_buffer, "selection_bound"), | |
| 1051 | &insert); | |
| 7749 | 1052 | } |
| 7742 | 1053 | |
|
17546
51b1c1e2c3fe
Maintain global poitners to the clipboard selection text, with the aim of
Sean Egan <seanegan@pidgin.im>
parents:
17406
diff
changeset
|
1054 | 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
|
1055 | 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
|
1056 | { |
|
51b1c1e2c3fe
Maintain global poitners to the clipboard selection text, with the aim of
Sean Egan <seanegan@pidgin.im>
parents:
17406
diff
changeset
|
1057 | } |
|
51b1c1e2c3fe
Maintain global poitners to the clipboard selection text, with the aim of
Sean Egan <seanegan@pidgin.im>
parents:
17406
diff
changeset
|
1058 | |
| 8677 | 1059 | static void copy_clipboard_cb(GtkIMHtml *imhtml, gpointer unused) |
| 7749 | 1060 | { |
| 8681 | 1061 | 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
|
1062 | 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
|
1063 | 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
|
1064 | clipboard_selection = gtk_widget_get_clipboard(GTK_WIDGET(imhtml), GDK_SELECTION_CLIPBOARD); |
|
21085
dff5e0bfb8f5
Don't assign ownership of the CLIPBOARD to the IMHtml - it doesn't really own the data and then we don't have problems of overwriting what others put in the clipboard. Fixes #3616.
Daniel Atallah <datallah@pidgin.im>
parents:
21076
diff
changeset
|
1065 | gtk_clipboard_set_with_data(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
|
1066 | 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
|
1067 | (GtkClipboardGetFunc)gtk_imhtml_clipboard_get, |
|
21085
dff5e0bfb8f5
Don't assign ownership of the CLIPBOARD to the IMHtml - it doesn't really own the data and then we don't have problems of overwriting what others put in the clipboard. Fixes #3616.
Daniel Atallah <datallah@pidgin.im>
parents:
21076
diff
changeset
|
1068 | (GtkClipboardClearFunc)gtk_imhtml_clipboard_clear, NULL); |
|
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
|
1069 | |
|
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
|
1070 | 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
|
1071 | 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
|
1072 | |
|
21085
dff5e0bfb8f5
Don't assign ownership of the CLIPBOARD to the IMHtml - it doesn't really own the data and then we don't have problems of overwriting what others put in the clipboard. Fixes #3616.
Daniel Atallah <datallah@pidgin.im>
parents:
21076
diff
changeset
|
1073 | html_clipboard = gtk_imhtml_get_markup_range(imhtml, &start, &end); |
|
dff5e0bfb8f5
Don't assign ownership of the CLIPBOARD to the IMHtml - it doesn't really own the data and then we don't have problems of overwriting what others put in the clipboard. Fixes #3616.
Daniel Atallah <datallah@pidgin.im>
parents:
21076
diff
changeset
|
1074 | text_clipboard = gtk_imhtml_get_text(imhtml, &start, &end); |
| 8681 | 1075 | } |
| 1076 | ||
| 8061 | 1077 | g_signal_stop_emission_by_name(imhtml, "copy-clipboard"); |
| 1078 | } | |
| 1079 | ||
| 8698 | 1080 | static void cut_clipboard_cb(GtkIMHtml *imhtml, gpointer unused) |
| 1081 | { | |
| 1082 | 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
|
1083 | 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
|
1084 | 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
|
1085 | clipboard_selection = gtk_widget_get_clipboard(GTK_WIDGET(imhtml), GDK_SELECTION_CLIPBOARD); |
|
21085
dff5e0bfb8f5
Don't assign ownership of the CLIPBOARD to the IMHtml - it doesn't really own the data and then we don't have problems of overwriting what others put in the clipboard. Fixes #3616.
Daniel Atallah <datallah@pidgin.im>
parents:
21076
diff
changeset
|
1086 | gtk_clipboard_set_with_data(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
|
1087 | 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
|
1088 | (GtkClipboardGetFunc)gtk_imhtml_clipboard_get, |
|
21085
dff5e0bfb8f5
Don't assign ownership of the CLIPBOARD to the IMHtml - it doesn't really own the data and then we don't have problems of overwriting what others put in the clipboard. Fixes #3616.
Daniel Atallah <datallah@pidgin.im>
parents:
21076
diff
changeset
|
1089 | (GtkClipboardClearFunc)gtk_imhtml_clipboard_clear, NULL); |
|
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
|
1090 | |
|
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
|
1091 | 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
|
1092 | 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
|
1093 | |
|
21085
dff5e0bfb8f5
Don't assign ownership of the CLIPBOARD to the IMHtml - it doesn't really own the data and then we don't have problems of overwriting what others put in the clipboard. Fixes #3616.
Daniel Atallah <datallah@pidgin.im>
parents:
21076
diff
changeset
|
1094 | html_clipboard = gtk_imhtml_get_markup_range(imhtml, &start, &end); |
|
dff5e0bfb8f5
Don't assign ownership of the CLIPBOARD to the IMHtml - it doesn't really own the data and then we don't have problems of overwriting what others put in the clipboard. Fixes #3616.
Daniel Atallah <datallah@pidgin.im>
parents:
21076
diff
changeset
|
1095 | text_clipboard = 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
|
1096 | |
|
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
|
1097 | 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
|
1098 | gtk_text_buffer_delete_selection(imhtml->text_buffer, FALSE, FALSE); |
| 8698 | 1099 | } |
| 1100 | ||
| 1101 | g_signal_stop_emission_by_name(imhtml, "cut-clipboard"); | |
| 1102 | } | |
| 1103 | ||
| 8931 | 1104 | static void imhtml_paste_insert(GtkIMHtml *imhtml, const char *text, gboolean plaintext) |
| 1105 | { | |
| 1106 | GtkTextIter iter; | |
|
22003
904ebe8d6058
Patch from 'goutnet' to not insert smileys when pasting as plain text.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21765
diff
changeset
|
1107 | GtkIMHtmlOptions flags = plaintext ? GTK_IMHTML_NO_SMILEY : (GTK_IMHTML_NO_NEWLINE | GTK_IMHTML_NO_COMMENTS); |
| 8931 | 1108 | |
| 9028 | 1109 | if (gtk_text_buffer_get_selection_bounds(imhtml->text_buffer, NULL, NULL)) |
| 1110 | gtk_text_buffer_delete_selection(imhtml->text_buffer, TRUE, TRUE); | |
| 1111 | ||
| 8931 | 1112 | gtk_text_buffer_get_iter_at_mark(imhtml->text_buffer, &iter, gtk_text_buffer_get_insert(imhtml->text_buffer)); |
| 1113 | if (!imhtml->wbfo && !plaintext) | |
| 1114 | gtk_imhtml_close_tags(imhtml, &iter); | |
| 1115 | ||
| 1116 | gtk_imhtml_insert_html_at_iter(imhtml, text, flags, &iter); | |
|
11267
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
1117 | gtk_text_buffer_move_mark_by_name(imhtml->text_buffer, "insert", &iter); |
| 8931 | 1118 | gtk_text_view_scroll_to_mark(GTK_TEXT_VIEW(imhtml), gtk_text_buffer_get_insert(imhtml->text_buffer), |
| 1119 | 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
|
1120 | 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
|
1121 | 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
|
1122 | |
| 8931 | 1123 | } |
| 1124 | ||
| 1125 | static void paste_plaintext_received_cb (GtkClipboard *clipboard, const gchar *text, gpointer data) | |
| 1126 | { | |
| 1127 | char *tmp; | |
| 1128 | ||
|
19332
06b251c98872
malloc(0) returns a null pointer. Fixes #2472.
Daniel Atallah <datallah@pidgin.im>
parents:
19103
diff
changeset
|
1129 | if (text == NULL || !(*text)) |
| 8931 | 1130 | return; |
| 1131 | ||
|
10732
5e314ab498bf
[gaim-migrate @ 12334]
Richard Laager <rlaager@pidgin.im>
parents:
10699
diff
changeset
|
1132 | tmp = g_markup_escape_text(text, -1); |
| 8931 | 1133 | imhtml_paste_insert(data, tmp, TRUE); |
| 1134 | g_free(tmp); | |
| 1135 | } | |
| 1136 | ||
| 8061 | 1137 | static void paste_received_cb (GtkClipboard *clipboard, GtkSelectionData *selection_data, gpointer data) |
| 1138 | { | |
| 1139 | char *text; | |
| 1140 | GtkIMHtml *imhtml = data; | |
| 7809 | 1141 | |
|
8123
e09c75f511c2
[gaim-migrate @ 8827]
Mark Doliner <markdoliner@pidgin.im>
parents:
8120
diff
changeset
|
1142 | if (!gtk_text_view_get_editable(GTK_TEXT_VIEW(imhtml))) |
|
8105
54ea897b764e
[gaim-migrate @ 8805]
Nathan Fredrickson <nathan@silverorange.com>
parents:
8091
diff
changeset
|
1143 | return; |
|
54ea897b764e
[gaim-migrate @ 8805]
Nathan Fredrickson <nathan@silverorange.com>
parents:
8091
diff
changeset
|
1144 | |
|
19332
06b251c98872
malloc(0) returns a null pointer. Fixes #2472.
Daniel Atallah <datallah@pidgin.im>
parents:
19103
diff
changeset
|
1145 | if (imhtml->wbfo || selection_data->length <= 0) { |
| 8931 | 1146 | gtk_clipboard_request_text(clipboard, paste_plaintext_received_cb, imhtml); |
| 1147 | return; | |
| 8061 | 1148 | } else { |
| 8719 | 1149 | #if 0 |
| 1150 | /* Here's some debug code, for figuring out what sent to us over the clipboard. */ | |
| 1151 | { | |
| 1152 | int i; | |
| 1153 | ||
| 15884 | 1154 | purple_debug_misc("gtkimhtml", "In paste_received_cb():\n\tformat = %d, length = %d\n\t", |
| 8719 | 1155 | selection_data->format, selection_data->length); |
| 1156 | ||
| 1157 | for (i = 0; i < (/*(selection_data->format / 8) **/ selection_data->length); i++) { | |
| 1158 | if ((i % 70) == 0) | |
| 1159 | printf("\n\t"); | |
| 1160 | if (selection_data->data[i] == '\0') | |
| 1161 | printf("."); | |
| 1162 | else | |
| 1163 | printf("%c", selection_data->data[i]); | |
| 1164 | } | |
| 1165 | printf("\n"); | |
| 1166 | } | |
| 1167 | #endif | |
| 1168 | text = g_malloc(selection_data->length); | |
| 1169 | memcpy(text, selection_data->data, selection_data->length); | |
| 7766 | 1170 | } |
| 8061 | 1171 | |
| 8869 | 1172 | if (selection_data->length >= 2 && |
| 1173 | (*(guint16 *)text == 0xfeff || *(guint16 *)text == 0xfffe)) { | |
|
22596
0854ae660ef4
Further changes to use UTF-16 instead of UCS-2. Also, fix #5167 by making sure that the encoding conversion worked before using the result.
Daniel Atallah <datallah@pidgin.im>
parents:
22595
diff
changeset
|
1174 | /* This is UTF-16 */ |
|
0854ae660ef4
Further changes to use UTF-16 instead of UCS-2. Also, fix #5167 by making sure that the encoding conversion worked before using the result.
Daniel Atallah <datallah@pidgin.im>
parents:
22595
diff
changeset
|
1175 | char *utf8 = utf16_to_utf8_with_bom_check(text, selection_data->length); |
| 8061 | 1176 | g_free(text); |
| 1177 | text = utf8; | |
| 8698 | 1178 | if (!text) { |
|
22596
0854ae660ef4
Further changes to use UTF-16 instead of UCS-2. Also, fix #5167 by making sure that the encoding conversion worked before using the result.
Daniel Atallah <datallah@pidgin.im>
parents:
22595
diff
changeset
|
1179 | purple_debug_warning("gtkimhtml", "g_convert from UTF-16 failed in paste_received_cb\n"); |
| 8698 | 1180 | return; |
| 1181 | } | |
| 8061 | 1182 | } |
|
11572
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
1183 | |
| 8698 | 1184 | if (!(*text) || !g_utf8_validate(text, -1, NULL)) { |
| 15884 | 1185 | purple_debug_warning("gtkimhtml", "empty string or invalid UTF-8 in paste_received_cb\n"); |
| 8698 | 1186 | g_free(text); |
| 1187 | return; | |
| 1188 | } | |
| 1189 | ||
| 8931 | 1190 | imhtml_paste_insert(imhtml, text, FALSE); |
| 8681 | 1191 | g_free(text); |
| 8061 | 1192 | } |
| 1193 | ||
|
21765
b9271e416f6d
Patch from 'goutnet': Pressing backspace on a smiley will replace the smiley
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21644
diff
changeset
|
1194 | |
|
b9271e416f6d
Patch from 'goutnet': Pressing backspace on a smiley will replace the smiley
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21644
diff
changeset
|
1195 | static void smart_backspace_cb(GtkIMHtml *imhtml, gpointer blah) |
|
b9271e416f6d
Patch from 'goutnet': Pressing backspace on a smiley will replace the smiley
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21644
diff
changeset
|
1196 | { |
|
b9271e416f6d
Patch from 'goutnet': Pressing backspace on a smiley will replace the smiley
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21644
diff
changeset
|
1197 | GtkTextIter iter; |
|
b9271e416f6d
Patch from 'goutnet': Pressing backspace on a smiley will replace the smiley
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21644
diff
changeset
|
1198 | GtkTextChildAnchor* anchor; |
|
b9271e416f6d
Patch from 'goutnet': Pressing backspace on a smiley will replace the smiley
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21644
diff
changeset
|
1199 | char * text; |
|
b9271e416f6d
Patch from 'goutnet': Pressing backspace on a smiley will replace the smiley
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21644
diff
changeset
|
1200 | gint offset; |
|
b9271e416f6d
Patch from 'goutnet': Pressing backspace on a smiley will replace the smiley
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21644
diff
changeset
|
1201 | |
|
b9271e416f6d
Patch from 'goutnet': Pressing backspace on a smiley will replace the smiley
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21644
diff
changeset
|
1202 | if (!imhtml->editable) |
|
b9271e416f6d
Patch from 'goutnet': Pressing backspace on a smiley will replace the smiley
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21644
diff
changeset
|
1203 | return; |
|
b9271e416f6d
Patch from 'goutnet': Pressing backspace on a smiley will replace the smiley
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21644
diff
changeset
|
1204 | |
|
b9271e416f6d
Patch from 'goutnet': Pressing backspace on a smiley will replace the smiley
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21644
diff
changeset
|
1205 | gtk_text_buffer_get_iter_at_mark(imhtml->text_buffer, &iter, gtk_text_buffer_get_insert(imhtml->text_buffer)); |
|
b9271e416f6d
Patch from 'goutnet': Pressing backspace on a smiley will replace the smiley
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21644
diff
changeset
|
1206 | |
|
b9271e416f6d
Patch from 'goutnet': Pressing backspace on a smiley will replace the smiley
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21644
diff
changeset
|
1207 | /* Get the character before the insertion point */ |
|
b9271e416f6d
Patch from 'goutnet': Pressing backspace on a smiley will replace the smiley
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21644
diff
changeset
|
1208 | offset = gtk_text_iter_get_offset(&iter); |
|
b9271e416f6d
Patch from 'goutnet': Pressing backspace on a smiley will replace the smiley
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21644
diff
changeset
|
1209 | if (offset <= 0) |
|
b9271e416f6d
Patch from 'goutnet': Pressing backspace on a smiley will replace the smiley
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21644
diff
changeset
|
1210 | return; |
|
b9271e416f6d
Patch from 'goutnet': Pressing backspace on a smiley will replace the smiley
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21644
diff
changeset
|
1211 | |
|
b9271e416f6d
Patch from 'goutnet': Pressing backspace on a smiley will replace the smiley
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21644
diff
changeset
|
1212 | gtk_text_iter_backward_char(&iter); |
|
b9271e416f6d
Patch from 'goutnet': Pressing backspace on a smiley will replace the smiley
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21644
diff
changeset
|
1213 | anchor = gtk_text_iter_get_child_anchor(&iter); |
|
b9271e416f6d
Patch from 'goutnet': Pressing backspace on a smiley will replace the smiley
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21644
diff
changeset
|
1214 | |
|
b9271e416f6d
Patch from 'goutnet': Pressing backspace on a smiley will replace the smiley
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21644
diff
changeset
|
1215 | if (!anchor) |
|
b9271e416f6d
Patch from 'goutnet': Pressing backspace on a smiley will replace the smiley
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21644
diff
changeset
|
1216 | return; /* No smiley here */ |
|
b9271e416f6d
Patch from 'goutnet': Pressing backspace on a smiley will replace the smiley
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21644
diff
changeset
|
1217 | |
|
b9271e416f6d
Patch from 'goutnet': Pressing backspace on a smiley will replace the smiley
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21644
diff
changeset
|
1218 | text = g_object_get_data(G_OBJECT(anchor), "gtkimhtml_plaintext"); |
|
b9271e416f6d
Patch from 'goutnet': Pressing backspace on a smiley will replace the smiley
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21644
diff
changeset
|
1219 | if (!text) |
|
b9271e416f6d
Patch from 'goutnet': Pressing backspace on a smiley will replace the smiley
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21644
diff
changeset
|
1220 | return; |
|
b9271e416f6d
Patch from 'goutnet': Pressing backspace on a smiley will replace the smiley
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21644
diff
changeset
|
1221 | |
|
b9271e416f6d
Patch from 'goutnet': Pressing backspace on a smiley will replace the smiley
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21644
diff
changeset
|
1222 | /* ok, then we need to insert the image buffer text before the anchor */ |
|
b9271e416f6d
Patch from 'goutnet': Pressing backspace on a smiley will replace the smiley
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21644
diff
changeset
|
1223 | gtk_text_buffer_insert(imhtml->text_buffer, &iter, text, -1); |
|
b9271e416f6d
Patch from 'goutnet': Pressing backspace on a smiley will replace the smiley
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21644
diff
changeset
|
1224 | } |
|
b9271e416f6d
Patch from 'goutnet': Pressing backspace on a smiley will replace the smiley
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21644
diff
changeset
|
1225 | |
| 8061 | 1226 | static void paste_clipboard_cb(GtkIMHtml *imhtml, gpointer blah) |
| 1227 | { | |
| 8931 | 1228 | #ifdef _WIN32 |
| 1229 | /* 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
|
1230 | clipboard before we try to paste from the GTK buffer */ |
|
21985
bf0e936998e4
Move some curly braces around so static analysis tools can properly detect
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
21955
diff
changeset
|
1231 | if (!clipboard_paste_html_win32(imhtml)) |
| 8931 | 1232 | #endif |
|
21985
bf0e936998e4
Move some curly braces around so static analysis tools can properly detect
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
21955
diff
changeset
|
1233 | { |
| 8061 | 1234 | GtkClipboard *clipboard = gtk_widget_get_clipboard(GTK_WIDGET(imhtml), GDK_SELECTION_CLIPBOARD); |
| 1235 | gtk_clipboard_request_contents(clipboard, gdk_atom_intern("text/html", FALSE), | |
| 1236 | paste_received_cb, imhtml); | |
| 8931 | 1237 | } |
| 8061 | 1238 | g_signal_stop_emission_by_name(imhtml, "paste-clipboard"); |
| 7766 | 1239 | } |
| 1240 | ||
| 8677 | 1241 | static void imhtml_realized_remove_primary(GtkIMHtml *imhtml, gpointer unused) |
| 1242 | { | |
| 1243 | gtk_text_buffer_remove_selection_clipboard(GTK_IMHTML(imhtml)->text_buffer, | |
| 1244 | gtk_widget_get_clipboard(GTK_WIDGET(imhtml), GDK_SELECTION_PRIMARY)); | |
| 1245 | ||
| 1246 | } | |
| 1247 | ||
|
8740
098a43943bba
[gaim-migrate @ 9495]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
1248 | static void imhtml_destroy_add_primary(GtkIMHtml *imhtml, gpointer unused) |
|
098a43943bba
[gaim-migrate @ 9495]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
1249 | { |
|
098a43943bba
[gaim-migrate @ 9495]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
1250 | gtk_text_buffer_add_selection_clipboard(GTK_IMHTML(imhtml)->text_buffer, |
|
098a43943bba
[gaim-migrate @ 9495]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
1251 | gtk_widget_get_clipboard(GTK_WIDGET(imhtml), GDK_SELECTION_PRIMARY)); |
|
098a43943bba
[gaim-migrate @ 9495]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
1252 | } |
| 8677 | 1253 | |
| 1254 | static void mark_set_so_update_selection_cb(GtkTextBuffer *buffer, GtkTextIter *arg1, GtkTextMark *mark, GtkIMHtml *imhtml) | |
| 1255 | { | |
| 1256 | if (gtk_text_buffer_get_selection_bounds(buffer, NULL, NULL)) { | |
| 1257 | gtk_clipboard_set_with_owner(gtk_widget_get_clipboard(GTK_WIDGET(imhtml), GDK_SELECTION_PRIMARY), | |
| 1258 | selection_targets, sizeof(selection_targets) / sizeof(GtkTargetEntry), | |
| 1259 | (GtkClipboardGetFunc)gtk_imhtml_clipboard_get, | |
| 1260 | (GtkClipboardClearFunc)gtk_imhtml_primary_clipboard_clear, G_OBJECT(imhtml)); | |
| 1261 | } | |
| 1262 | } | |
| 1263 | ||
| 1264 | static gboolean gtk_imhtml_button_press_event(GtkIMHtml *imhtml, GdkEventButton *event, gpointer unused) | |
| 7346 | 1265 | { |
| 8677 | 1266 | if (event->button == 2) { |
| 1267 | int x, y; | |
| 1268 | GtkTextIter iter; | |
| 1269 | GtkClipboard *clipboard = gtk_widget_get_clipboard(GTK_WIDGET(imhtml), GDK_SELECTION_PRIMARY); | |
| 1270 | ||
| 1271 | if (!imhtml->editable) | |
| 1272 | return FALSE; | |
| 1273 | ||
| 1274 | gtk_text_view_window_to_buffer_coords(GTK_TEXT_VIEW(imhtml), | |
| 1275 | GTK_TEXT_WINDOW_TEXT, | |
| 1276 | event->x, | |
| 1277 | event->y, | |
| 1278 | &x, | |
| 1279 | &y); | |
| 1280 | gtk_text_view_get_iter_at_location(GTK_TEXT_VIEW(imhtml), &iter, x, y); | |
| 1281 | gtk_text_buffer_place_cursor(imhtml->text_buffer, &iter); | |
| 1282 | ||
| 1283 | gtk_clipboard_request_contents(clipboard, gdk_atom_intern("text/html", FALSE), | |
| 1284 | paste_received_cb, imhtml); | |
| 1285 | ||
| 1286 | return TRUE; | |
| 1287 | } | |
| 1288 | ||
| 7346 | 1289 | return FALSE; |
| 1290 | } | |
| 4263 | 1291 | |
|
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
|
1292 | static void |
|
22834
1394e7efb818
Smiley insertions can be undone with this fix. References #5577. But redo
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22810
diff
changeset
|
1293 | gtk_imhtml_undo(GtkIMHtml *imhtml) |
|
1394e7efb818
Smiley insertions can be undone with this fix. References #5577. But redo
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22810
diff
changeset
|
1294 | { |
|
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
|
1295 | g_return_if_fail(GTK_IS_IMHTML(imhtml)); |
|
22834
1394e7efb818
Smiley insertions can be undone with this fix. References #5577. But redo
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22810
diff
changeset
|
1296 | if (imhtml->editable && |
|
1394e7efb818
Smiley insertions can be undone with this fix. References #5577. But redo
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22810
diff
changeset
|
1297 | gtk_source_undo_manager_can_undo(imhtml->undo_manager)) |
|
21574
b27c242d1288
Fix #3930 by correctly detecting when we're no longer immediately following a br.
Daniel Atallah <datallah@pidgin.im>
parents:
21425
diff
changeset
|
1298 | gtk_source_undo_manager_undo(imhtml->undo_manager); |
|
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
|
1299 | } |
|
5e73968467e0
Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@pidgin.im>
parents:
17288
diff
changeset
|
1300 | |
|
5e73968467e0
Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@pidgin.im>
parents:
17288
diff
changeset
|
1301 | static void |
|
22834
1394e7efb818
Smiley insertions can be undone with this fix. References #5577. But redo
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22810
diff
changeset
|
1302 | gtk_imhtml_redo(GtkIMHtml *imhtml) |
|
1394e7efb818
Smiley insertions can be undone with this fix. References #5577. But redo
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22810
diff
changeset
|
1303 | { |
|
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
|
1304 | g_return_if_fail(GTK_IS_IMHTML(imhtml)); |
|
22834
1394e7efb818
Smiley insertions can be undone with this fix. References #5577. But redo
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22810
diff
changeset
|
1305 | if (imhtml->editable && |
|
1394e7efb818
Smiley insertions can be undone with this fix. References #5577. But redo
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22810
diff
changeset
|
1306 | gtk_source_undo_manager_can_redo(imhtml->undo_manager)) |
|
21574
b27c242d1288
Fix #3930 by correctly detecting when we're no longer immediately following a br.
Daniel Atallah <datallah@pidgin.im>
parents:
21425
diff
changeset
|
1307 | gtk_source_undo_manager_redo(imhtml->undo_manager); |
|
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
|
1308 | |
|
5e73968467e0
Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@pidgin.im>
parents:
17288
diff
changeset
|
1309 | } |
|
5e73968467e0
Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@pidgin.im>
parents:
17288
diff
changeset
|
1310 | |
| 10108 | 1311 | static gboolean imhtml_message_send(GtkIMHtml *imhtml) |
| 1312 | { | |
| 1313 | return FALSE; | |
| 1314 | } | |
| 1315 | ||
| 10100 | 1316 | static void imhtml_toggle_format(GtkIMHtml *imhtml, GtkIMHtmlButtons buttons) |
| 1317 | { | |
|
10699
7f9fa4f13758
[gaim-migrate @ 12256]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10695
diff
changeset
|
1318 | /* since this function is the handler for the formatting keystrokes, |
|
7f9fa4f13758
[gaim-migrate @ 12256]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10695
diff
changeset
|
1319 | 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
|
1320 | buttons &= imhtml->format_functions; |
|
10699
7f9fa4f13758
[gaim-migrate @ 12256]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10695
diff
changeset
|
1321 | |
| 10100 | 1322 | switch (buttons) { |
| 1323 | case GTK_IMHTML_BOLD: | |
|
11267
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
1324 | imhtml_toggle_bold(imhtml); |
| 10100 | 1325 | break; |
| 1326 | case GTK_IMHTML_ITALIC: | |
|
11267
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
1327 | imhtml_toggle_italic(imhtml); |
| 10100 | 1328 | break; |
| 1329 | case GTK_IMHTML_UNDERLINE: | |
|
11267
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
1330 | imhtml_toggle_underline(imhtml); |
|
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
1331 | break; |
|
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
1332 | case GTK_IMHTML_STRIKE: |
|
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
1333 | imhtml_toggle_strike(imhtml); |
| 10100 | 1334 | break; |
| 1335 | case GTK_IMHTML_SHRINK: | |
|
11267
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
1336 | imhtml_font_shrink(imhtml); |
| 10100 | 1337 | break; |
| 1338 | case GTK_IMHTML_GROW: | |
|
11267
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
1339 | imhtml_font_grow(imhtml); |
| 10100 | 1340 | break; |
| 1341 | default: | |
| 1342 | break; | |
| 1343 | } | |
| 1344 | } | |
| 4032 | 1345 | |
| 1346 | static void | |
| 1347 | gtk_imhtml_finalize (GObject *object) | |
| 1348 | { | |
| 1349 | GtkIMHtml *imhtml = GTK_IMHTML(object); | |
| 4895 | 1350 | GList *scalables; |
| 8962 | 1351 | GSList *l; |
| 8061 | 1352 | |
| 10798 | 1353 | if (imhtml->scroll_src) |
| 1354 | g_source_remove(imhtml->scroll_src); | |
| 1355 | if (imhtml->scroll_time) | |
| 1356 | g_timer_destroy(imhtml->scroll_time); | |
| 1357 | ||
| 4138 | 1358 | g_hash_table_destroy(imhtml->smiley_data); |
| 4032 | 1359 | gtk_smiley_tree_destroy(imhtml->default_smilies); |
| 4138 | 1360 | gdk_cursor_unref(imhtml->hand_cursor); |
| 1361 | gdk_cursor_unref(imhtml->arrow_cursor); | |
| 8061 | 1362 | gdk_cursor_unref(imhtml->text_cursor); |
| 8677 | 1363 | |
| 4735 | 1364 | if(imhtml->tip_window){ |
| 1365 | gtk_widget_destroy(imhtml->tip_window); | |
| 1366 | } | |
| 1367 | if(imhtml->tip_timer) | |
| 1368 | gtk_timeout_remove(imhtml->tip_timer); | |
| 1369 | ||
| 4895 | 1370 | for(scalables = imhtml->scalables; scalables; scalables = scalables->next) { |
|
11224
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
1371 | struct scalable_data *sd = scalables->data; |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
1372 | GtkIMHtmlScalable *scale = GTK_IMHTML_SCALABLE(sd->scalable); |
| 4895 | 1373 | scale->free(scale); |
|
11224
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
1374 | g_free(sd); |
| 4895 | 1375 | } |
| 7991 | 1376 | |
| 8962 | 1377 | for (l = imhtml->im_images; l; l = l->next) { |
|
11224
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
1378 | struct im_image_data *img_data = l->data; |
| 8962 | 1379 | if (imhtml->funcs->image_unref) |
|
11224
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
1380 | imhtml->funcs->image_unref(img_data->id); |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
1381 | g_free(img_data); |
| 8962 | 1382 | } |
| 1383 | ||
| 4895 | 1384 | g_list_free(imhtml->scalables); |
| 8962 | 1385 | 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
|
1386 | g_queue_free(imhtml->animations); |
|
14097
0c340861ab79
[gaim-migrate @ 16638]
Mark Doliner <markdoliner@pidgin.im>
parents:
14010
diff
changeset
|
1387 | g_free(imhtml->protocol_name); |
|
0c340861ab79
[gaim-migrate @ 16638]
Mark Doliner <markdoliner@pidgin.im>
parents:
14010
diff
changeset
|
1388 | 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
|
1389 | g_object_unref(imhtml->undo_manager); |
| 4032 | 1390 | 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
|
1391 | |
| 4032 | 1392 | } |
| 1428 | 1393 | |
|
10814
7e17cb56b019
[gaim-migrate @ 12468]
Luke Schierer <lschiere@pidgin.im>
parents:
10799
diff
changeset
|
1394 | /* Boring GTK+ stuff */ |
| 8519 | 1395 | static void gtk_imhtml_class_init (GtkIMHtmlClass *klass) |
| 1428 | 1396 | { |
| 9007 | 1397 | GtkWidgetClass *widget_class = (GtkWidgetClass *) klass; |
| 3922 | 1398 | GtkObjectClass *object_class; |
| 10100 | 1399 | GtkBindingSet *binding_set; |
| 4032 | 1400 | GObjectClass *gobject_class; |
| 8519 | 1401 | object_class = (GtkObjectClass*) klass; |
| 1402 | gobject_class = (GObjectClass*) klass; | |
| 4032 | 1403 | parent_class = gtk_type_class(GTK_TYPE_TEXT_VIEW); |
| 4417 | 1404 | signals[URL_CLICKED] = g_signal_new("url_clicked", |
| 1405 | G_TYPE_FROM_CLASS(gobject_class), | |
| 1406 | G_SIGNAL_RUN_FIRST, | |
| 1407 | G_STRUCT_OFFSET(GtkIMHtmlClass, url_clicked), | |
| 1408 | NULL, | |
| 1409 | 0, | |
| 1410 | g_cclosure_marshal_VOID__POINTER, | |
| 1411 | G_TYPE_NONE, 1, | |
| 1412 | G_TYPE_POINTER); | |
| 8506 | 1413 | signals[BUTTONS_UPDATE] = g_signal_new("format_buttons_update", |
| 8420 | 1414 | G_TYPE_FROM_CLASS(gobject_class), |
| 1415 | G_SIGNAL_RUN_FIRST, | |
| 1416 | G_STRUCT_OFFSET(GtkIMHtmlClass, buttons_update), | |
| 1417 | NULL, | |
| 1418 | 0, | |
|
10076
1ccc0286a4ae
[gaim-migrate @ 11057]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10062
diff
changeset
|
1419 | g_cclosure_marshal_VOID__INT, |
| 8420 | 1420 | G_TYPE_NONE, 1, |
| 1421 | G_TYPE_INT); | |
| 1422 | signals[TOGGLE_FORMAT] = g_signal_new("format_function_toggle", | |
| 1423 | G_TYPE_FROM_CLASS(gobject_class), | |
| 10100 | 1424 | G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION, |
| 8420 | 1425 | G_STRUCT_OFFSET(GtkIMHtmlClass, toggle_format), |
| 1426 | NULL, | |
| 1427 | 0, | |
|
10076
1ccc0286a4ae
[gaim-migrate @ 11057]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10062
diff
changeset
|
1428 | g_cclosure_marshal_VOID__INT, |
|
1ccc0286a4ae
[gaim-migrate @ 11057]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10062
diff
changeset
|
1429 | G_TYPE_NONE, 1, |
| 8420 | 1430 | G_TYPE_INT); |
| 8427 | 1431 | signals[CLEAR_FORMAT] = g_signal_new("format_function_clear", |
| 1432 | G_TYPE_FROM_CLASS(gobject_class), | |
|
11385
38ca1438e055
[gaim-migrate @ 13612]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11315
diff
changeset
|
1433 | G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION, |
| 8427 | 1434 | G_STRUCT_OFFSET(GtkIMHtmlClass, clear_format), |
| 1435 | NULL, | |
| 1436 | 0, | |
| 10100 | 1437 | g_cclosure_marshal_VOID__VOID, |
| 1438 | G_TYPE_NONE, 0); | |
| 8506 | 1439 | signals[UPDATE_FORMAT] = g_signal_new("format_function_update", |
| 10100 | 1440 | G_TYPE_FROM_CLASS(gobject_class), |
| 1441 | G_SIGNAL_RUN_FIRST, | |
| 1442 | G_STRUCT_OFFSET(GtkIMHtmlClass, update_format), | |
| 1443 | NULL, | |
| 1444 | 0, | |
| 1445 | g_cclosure_marshal_VOID__VOID, | |
| 1446 | G_TYPE_NONE, 0); | |
| 10108 | 1447 | signals[MESSAGE_SEND] = g_signal_new("message_send", |
| 1448 | G_TYPE_FROM_CLASS(gobject_class), | |
| 1449 | G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION, | |
| 1450 | G_STRUCT_OFFSET(GtkIMHtmlClass, message_send), | |
| 1451 | NULL, | |
| 1452 | 0, g_cclosure_marshal_VOID__VOID, | |
| 1453 | 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
|
1454 | 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
|
1455 | 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
|
1456 | 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
|
1457 | 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
|
1458 | 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
|
1459 | 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
|
1460 | 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
|
1461 | 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
|
1462 | 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
|
1463 | 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
|
1464 | 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
|
1465 | 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
|
1466 | 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
|
1467 | 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
|
1468 | 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
|
1469 | 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
|
1470 | 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
|
1471 | 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
|
1472 | |
|
5e73968467e0
Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@pidgin.im>
parents:
17288
diff
changeset
|
1473 | |
| 10100 | 1474 | |
| 1475 | klass->toggle_format = imhtml_toggle_format; | |
| 10108 | 1476 | klass->message_send = imhtml_message_send; |
|
12672
673e2a1d2954
[gaim-migrate @ 15015]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12635
diff
changeset
|
1477 | 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
|
1478 | 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
|
1479 | klass->redo = gtk_imhtml_redo; |
|
10184
543c9a84ce16
[gaim-migrate @ 11299]
Mark Doliner <markdoliner@pidgin.im>
parents:
10169
diff
changeset
|
1480 | |
| 4032 | 1481 | gobject_class->finalize = gtk_imhtml_finalize; |
|
10184
543c9a84ce16
[gaim-migrate @ 11299]
Mark Doliner <markdoliner@pidgin.im>
parents:
10169
diff
changeset
|
1482 | widget_class->drag_motion = gtk_text_view_drag_motion; |
| 10692 | 1483 | widget_class->expose_event = gtk_imhtml_expose_event; |
|
18968
2ddbe6473bc9
Cool! Override GtkTextView's size allocate function in GtkIMHtml to make sure that it stays scrolled to the bottom whenever it's resized. Fixes a major annoyance and possibly #938
Sean Egan <seanegan@pidgin.im>
parents:
18665
diff
changeset
|
1484 | parent_size_allocate = widget_class->size_allocate; |
|
2ddbe6473bc9
Cool! Override GtkTextView's size allocate function in GtkIMHtml to make sure that it stays scrolled to the bottom whenever it's resized. Fixes a major annoyance and possibly #938
Sean Egan <seanegan@pidgin.im>
parents:
18665
diff
changeset
|
1485 | widget_class->size_allocate = gtk_imhtml_size_allocate; |
|
23227
f2d8240d3487
Use text-tags to set the weight/color of the nick in conversations. This
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22970
diff
changeset
|
1486 | parent_style_set = widget_class->style_set; |
|
f2d8240d3487
Use text-tags to set the weight/color of the nick in conversations. This
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22970
diff
changeset
|
1487 | widget_class->style_set = gtk_imhtml_style_set; |
|
18968
2ddbe6473bc9
Cool! Override GtkTextView's size allocate function in GtkIMHtml to make sure that it stays scrolled to the bottom whenever it's resized. Fixes a major annoyance and possibly #938
Sean Egan <seanegan@pidgin.im>
parents:
18665
diff
changeset
|
1488 | |
| 9007 | 1489 | gtk_widget_class_install_style_property(widget_class, g_param_spec_boxed("hyperlink-color", |
| 1490 | _("Hyperlink color"), | |
| 1491 | _("Color to draw hyperlinks."), | |
| 1492 | GDK_TYPE_COLOR, G_PARAM_READABLE)); | |
|
24328
7be2af5c9129
Show visited links in a different color. This also plugs a memory leak
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23548
diff
changeset
|
1493 | gtk_widget_class_install_style_property(widget_class, g_param_spec_boxed("hyperlink-visited-color", |
|
7be2af5c9129
Show visited links in a different color. This also plugs a memory leak
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23548
diff
changeset
|
1494 | _("Hyperlink visited color"), |
|
7be2af5c9129
Show visited links in a different color. This also plugs a memory leak
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23548
diff
changeset
|
1495 | _("Color to draw hyperlinks after it has been visited (or activated)."), |
|
7be2af5c9129
Show visited links in a different color. This also plugs a memory leak
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23548
diff
changeset
|
1496 | GDK_TYPE_COLOR, G_PARAM_READABLE)); |
| 10799 | 1497 | gtk_widget_class_install_style_property(widget_class, g_param_spec_boxed("hyperlink-prelight-color", |
| 1498 | _("Hyperlink prelight color"), | |
| 1499 | _("Color to draw hyperlinks when mouse is over them."), | |
| 1500 | GDK_TYPE_COLOR, G_PARAM_READABLE)); | |
|
21955
4014918b95fc
Another patch from DHowett. This one adds conversation nick colors to gtkrc
Sean Egan <seanegan@pidgin.im>
parents:
21896
diff
changeset
|
1501 | gtk_widget_class_install_style_property(widget_class, g_param_spec_boxed("send-name-color", |
|
4014918b95fc
Another patch from DHowett. This one adds conversation nick colors to gtkrc
Sean Egan <seanegan@pidgin.im>
parents:
21896
diff
changeset
|
1502 | _("Sent Message Name Color"), |
|
4014918b95fc
Another patch from DHowett. This one adds conversation nick colors to gtkrc
Sean Egan <seanegan@pidgin.im>
parents:
21896
diff
changeset
|
1503 | _("Color to draw the name of a message you sent."), |
|
4014918b95fc
Another patch from DHowett. This one adds conversation nick colors to gtkrc
Sean Egan <seanegan@pidgin.im>
parents:
21896
diff
changeset
|
1504 | GDK_TYPE_COLOR, G_PARAM_READABLE)); |
|
4014918b95fc
Another patch from DHowett. This one adds conversation nick colors to gtkrc
Sean Egan <seanegan@pidgin.im>
parents:
21896
diff
changeset
|
1505 | gtk_widget_class_install_style_property(widget_class, g_param_spec_boxed("receive-name-color", |
|
4014918b95fc
Another patch from DHowett. This one adds conversation nick colors to gtkrc
Sean Egan <seanegan@pidgin.im>
parents:
21896
diff
changeset
|
1506 | _("Received Message Name Color"), |
|
4014918b95fc
Another patch from DHowett. This one adds conversation nick colors to gtkrc
Sean Egan <seanegan@pidgin.im>
parents:
21896
diff
changeset
|
1507 | _("Color to draw the name of a message you received."), |
|
4014918b95fc
Another patch from DHowett. This one adds conversation nick colors to gtkrc
Sean Egan <seanegan@pidgin.im>
parents:
21896
diff
changeset
|
1508 | GDK_TYPE_COLOR, G_PARAM_READABLE)); |
|
4014918b95fc
Another patch from DHowett. This one adds conversation nick colors to gtkrc
Sean Egan <seanegan@pidgin.im>
parents:
21896
diff
changeset
|
1509 | gtk_widget_class_install_style_property(widget_class, g_param_spec_boxed("highlight-name-color", |
|
4014918b95fc
Another patch from DHowett. This one adds conversation nick colors to gtkrc
Sean Egan <seanegan@pidgin.im>
parents:
21896
diff
changeset
|
1510 | _("\"Attention\" Name Color"), |
|
4014918b95fc
Another patch from DHowett. This one adds conversation nick colors to gtkrc
Sean Egan <seanegan@pidgin.im>
parents:
21896
diff
changeset
|
1511 | _("Color to draw the name of a message you received containing your name."), |
|
4014918b95fc
Another patch from DHowett. This one adds conversation nick colors to gtkrc
Sean Egan <seanegan@pidgin.im>
parents:
21896
diff
changeset
|
1512 | GDK_TYPE_COLOR, G_PARAM_READABLE)); |
|
4014918b95fc
Another patch from DHowett. This one adds conversation nick colors to gtkrc
Sean Egan <seanegan@pidgin.im>
parents:
21896
diff
changeset
|
1513 | gtk_widget_class_install_style_property(widget_class, g_param_spec_boxed("action-name-color", |
|
4014918b95fc
Another patch from DHowett. This one adds conversation nick colors to gtkrc
Sean Egan <seanegan@pidgin.im>
parents:
21896
diff
changeset
|
1514 | _("Action Message Name Color"), |
|
4014918b95fc
Another patch from DHowett. This one adds conversation nick colors to gtkrc
Sean Egan <seanegan@pidgin.im>
parents:
21896
diff
changeset
|
1515 | _("Color to draw the name of an action message."), |
|
4014918b95fc
Another patch from DHowett. This one adds conversation nick colors to gtkrc
Sean Egan <seanegan@pidgin.im>
parents:
21896
diff
changeset
|
1516 | GDK_TYPE_COLOR, G_PARAM_READABLE)); |
|
23227
f2d8240d3487
Use text-tags to set the weight/color of the nick in conversations. This
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22970
diff
changeset
|
1517 | gtk_widget_class_install_style_property(widget_class, g_param_spec_boxed("whisper-action-name-color", |
|
f2d8240d3487
Use text-tags to set the weight/color of the nick in conversations. This
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22970
diff
changeset
|
1518 | _("Action Message Name Color for Whispered Message"), |
|
f2d8240d3487
Use text-tags to set the weight/color of the nick in conversations. This
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22970
diff
changeset
|
1519 | _("Color to draw the name of an action message."), |
|
f2d8240d3487
Use text-tags to set the weight/color of the nick in conversations. This
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22970
diff
changeset
|
1520 | GDK_TYPE_COLOR, G_PARAM_READABLE)); |
|
f2d8240d3487
Use text-tags to set the weight/color of the nick in conversations. This
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22970
diff
changeset
|
1521 | gtk_widget_class_install_style_property(widget_class, g_param_spec_boxed("whisper-name-color", |
|
f2d8240d3487
Use text-tags to set the weight/color of the nick in conversations. This
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22970
diff
changeset
|
1522 | _("Whisper Message Name Color"), |
|
f2d8240d3487
Use text-tags to set the weight/color of the nick in conversations. This
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22970
diff
changeset
|
1523 | _("Color to draw the name of an action message."), |
|
f2d8240d3487
Use text-tags to set the weight/color of the nick in conversations. This
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22970
diff
changeset
|
1524 | GDK_TYPE_COLOR, G_PARAM_READABLE)); |
| 10100 | 1525 | |
|
22772
34ab3bb905cc
Customize/disable the typing notification from gtkrc-2.0.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22703
diff
changeset
|
1526 | /* Customizable typing notification ... sort of. Example: |
|
34ab3bb905cc
Customize/disable the typing notification from gtkrc-2.0.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22703
diff
changeset
|
1527 | * GtkIMHtml::typing-notification-font = "monospace italic light 8.0" |
|
34ab3bb905cc
Customize/disable the typing notification from gtkrc-2.0.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22703
diff
changeset
|
1528 | * GtkIMHtml::typing-notification-color = "#ff0000" |
|
34ab3bb905cc
Customize/disable the typing notification from gtkrc-2.0.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22703
diff
changeset
|
1529 | * GtkIMHtml::typing-notification-enable = 1 |
|
34ab3bb905cc
Customize/disable the typing notification from gtkrc-2.0.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22703
diff
changeset
|
1530 | */ |
|
34ab3bb905cc
Customize/disable the typing notification from gtkrc-2.0.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22703
diff
changeset
|
1531 | gtk_widget_class_install_style_property(widget_class, g_param_spec_boxed("typing-notification-color", |
|
34ab3bb905cc
Customize/disable the typing notification from gtkrc-2.0.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22703
diff
changeset
|
1532 | _("Typing notification color"), |
|
34ab3bb905cc
Customize/disable the typing notification from gtkrc-2.0.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22703
diff
changeset
|
1533 | _("The color to use for the typing notification font"), |
|
34ab3bb905cc
Customize/disable the typing notification from gtkrc-2.0.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22703
diff
changeset
|
1534 | GDK_TYPE_COLOR, G_PARAM_READABLE)); |
|
34ab3bb905cc
Customize/disable the typing notification from gtkrc-2.0.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22703
diff
changeset
|
1535 | gtk_widget_class_install_style_property(widget_class, g_param_spec_string("typing-notification-font", |
|
34ab3bb905cc
Customize/disable the typing notification from gtkrc-2.0.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22703
diff
changeset
|
1536 | _("Typing notification font"), |
|
34ab3bb905cc
Customize/disable the typing notification from gtkrc-2.0.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22703
diff
changeset
|
1537 | _("The font to use for the typing notification"), |
|
34ab3bb905cc
Customize/disable the typing notification from gtkrc-2.0.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22703
diff
changeset
|
1538 | "light 8.0", G_PARAM_READABLE)); |
|
34ab3bb905cc
Customize/disable the typing notification from gtkrc-2.0.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22703
diff
changeset
|
1539 | gtk_widget_class_install_style_property(widget_class, g_param_spec_boolean("typing-notification-enable", |
|
34ab3bb905cc
Customize/disable the typing notification from gtkrc-2.0.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22703
diff
changeset
|
1540 | _("Enable typing notification"), |
|
34ab3bb905cc
Customize/disable the typing notification from gtkrc-2.0.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22703
diff
changeset
|
1541 | _("Enable typing notification"), |
|
34ab3bb905cc
Customize/disable the typing notification from gtkrc-2.0.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22703
diff
changeset
|
1542 | TRUE, G_PARAM_READABLE)); |
|
34ab3bb905cc
Customize/disable the typing notification from gtkrc-2.0.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22703
diff
changeset
|
1543 | |
| 10100 | 1544 | binding_set = gtk_binding_set_by_class (parent_class); |
| 10110 | 1545 | gtk_binding_entry_add_signal (binding_set, GDK_b, GDK_CONTROL_MASK, "format_function_toggle", 1, G_TYPE_INT, GTK_IMHTML_BOLD); |
| 10100 | 1546 | gtk_binding_entry_add_signal (binding_set, GDK_i, GDK_CONTROL_MASK, "format_function_toggle", 1, G_TYPE_INT, GTK_IMHTML_ITALIC); |
| 1547 | gtk_binding_entry_add_signal (binding_set, GDK_u, GDK_CONTROL_MASK, "format_function_toggle", 1, G_TYPE_INT, GTK_IMHTML_UNDERLINE); | |
| 1548 | gtk_binding_entry_add_signal (binding_set, GDK_plus, GDK_CONTROL_MASK, "format_function_toggle", 1, G_TYPE_INT, GTK_IMHTML_GROW); | |
| 1549 | gtk_binding_entry_add_signal (binding_set, GDK_equal, GDK_CONTROL_MASK, "format_function_toggle", 1, G_TYPE_INT, GTK_IMHTML_GROW); | |
| 1550 | gtk_binding_entry_add_signal (binding_set, GDK_minus, GDK_CONTROL_MASK, "format_function_toggle", 1, G_TYPE_INT, GTK_IMHTML_SHRINK); | |
| 10108 | 1551 | binding_set = gtk_binding_set_by_class(klass); |
|
11385
38ca1438e055
[gaim-migrate @ 13612]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11315
diff
changeset
|
1552 | gtk_binding_entry_add_signal (binding_set, GDK_r, GDK_CONTROL_MASK, "format_function_clear", 0); |
| 10108 | 1553 | gtk_binding_entry_add_signal (binding_set, GDK_KP_Enter, 0, "message_send", 0); |
| 1554 | 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
|
1555 | 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
|
1556 | 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
|
1557 | 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
|
1558 | |
| 1428 | 1559 | } |
| 1560 | ||
| 3922 | 1561 | static void gtk_imhtml_init (GtkIMHtml *imhtml) |
| 1428 | 1562 | { |
| 3922 | 1563 | 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
|
1564 | imhtml->undo_manager = gtk_source_undo_manager_new(imhtml->text_buffer); |
| 3922 | 1565 | 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
|
1566 | gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(imhtml), GTK_WRAP_WORD_CHAR); |
|
22865
eeed3e121bed
Move 2 of the 5 pixels' padding between paragraphs to above the line.
Will Thompson <resiak@pidgin.im>
parents:
22834
diff
changeset
|
1567 | gtk_text_view_set_pixels_above_lines(GTK_TEXT_VIEW(imhtml), 2); |
|
eeed3e121bed
Move 2 of the 5 pixels' padding between paragraphs to above the line.
Will Thompson <resiak@pidgin.im>
parents:
22834
diff
changeset
|
1568 | gtk_text_view_set_pixels_below_lines(GTK_TEXT_VIEW(imhtml), 3); |
| 8677 | 1569 | gtk_text_view_set_left_margin(GTK_TEXT_VIEW(imhtml), 2); |
| 1570 | gtk_text_view_set_right_margin(GTK_TEXT_VIEW(imhtml), 2); | |
| 8061 | 1571 | /*gtk_text_view_set_indent(GTK_TEXT_VIEW(imhtml), -15);*/ |
| 3922 | 1572 | /*gtk_text_view_set_justification(GTK_TEXT_VIEW(imhtml), GTK_JUSTIFY_FILL);*/ |
| 8061 | 1573 | |
| 3922 | 1574 | /* These tags will be used often and can be reused--we create them on init and then apply them by name |
| 8932 | 1575 | * other tags (color, size, face, etc.) will have to be created and applied dynamically |
| 9924 | 1576 | * Note that even though we created SUB, SUP, and PRE tags here, we don't really |
| 8932 | 1577 | * apply them anywhere yet. */ |
| 3922 | 1578 | gtk_text_buffer_create_tag(imhtml->text_buffer, "BOLD", "weight", PANGO_WEIGHT_BOLD, NULL); |
| 1579 | gtk_text_buffer_create_tag(imhtml->text_buffer, "ITALICS", "style", PANGO_STYLE_ITALIC, NULL); | |
| 1580 | gtk_text_buffer_create_tag(imhtml->text_buffer, "UNDERLINE", "underline", PANGO_UNDERLINE_SINGLE, NULL); | |
| 1581 | gtk_text_buffer_create_tag(imhtml->text_buffer, "STRIKE", "strikethrough", TRUE, NULL); | |
| 1582 | gtk_text_buffer_create_tag(imhtml->text_buffer, "SUB", "rise", -5000, NULL); | |
| 1583 | gtk_text_buffer_create_tag(imhtml->text_buffer, "SUP", "rise", 5000, NULL); | |
| 1584 | gtk_text_buffer_create_tag(imhtml->text_buffer, "PRE", "family", "Monospace", NULL); | |
| 7295 | 1585 | gtk_text_buffer_create_tag(imhtml->text_buffer, "search", "background", "#22ff00", "weight", "bold", NULL); |
|
23308
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
1586 | gtk_text_buffer_create_tag(imhtml->text_buffer, "comment", "weight", PANGO_WEIGHT_NORMAL, |
|
22486
e77232ab761f
Disable invisible text things, if someone can conclusively prove this is
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22276
diff
changeset
|
1587 | #if FALSE && GTK_CHECK_VERSION(2,10,10) |
|
23308
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
1588 | "invisible", FALSE, |
|
22211
7f3cecdb079c
disapproval of revision '2c96f5a301400781ce5fbf144ffdbae44f895281'
Sean Egan <seanegan@pidgin.im>
parents:
22210
diff
changeset
|
1589 | #endif |
|
23308
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
1590 | NULL); |
| 8677 | 1591 | |
|
23227
f2d8240d3487
Use text-tags to set the weight/color of the nick in conversations. This
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22970
diff
changeset
|
1592 | gtk_text_buffer_create_tag(imhtml->text_buffer, "send-name", "weight", PANGO_WEIGHT_BOLD, NULL); |
|
f2d8240d3487
Use text-tags to set the weight/color of the nick in conversations. This
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22970
diff
changeset
|
1593 | gtk_text_buffer_create_tag(imhtml->text_buffer, "receive-name", "weight", PANGO_WEIGHT_BOLD, NULL); |
|
f2d8240d3487
Use text-tags to set the weight/color of the nick in conversations. This
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22970
diff
changeset
|
1594 | gtk_text_buffer_create_tag(imhtml->text_buffer, "highlight-name", "weight", PANGO_WEIGHT_BOLD, NULL); |
|
f2d8240d3487
Use text-tags to set the weight/color of the nick in conversations. This
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22970
diff
changeset
|
1595 | gtk_text_buffer_create_tag(imhtml->text_buffer, "action-name", "weight", PANGO_WEIGHT_BOLD, NULL); |
|
f2d8240d3487
Use text-tags to set the weight/color of the nick in conversations. This
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22970
diff
changeset
|
1596 | gtk_text_buffer_create_tag(imhtml->text_buffer, "whisper-action-name", "weight", PANGO_WEIGHT_BOLD, NULL); |
|
f2d8240d3487
Use text-tags to set the weight/color of the nick in conversations. This
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22970
diff
changeset
|
1597 | gtk_text_buffer_create_tag(imhtml->text_buffer, "whisper-name", "weight", PANGO_WEIGHT_BOLD, NULL); |
| 8677 | 1598 | |
| 3922 | 1599 | /* When hovering over a link, we show the hand cursor--elsewhere we show the plain ol' pointer cursor */ |
| 1600 | imhtml->hand_cursor = gdk_cursor_new (GDK_HAND2); | |
| 1601 | imhtml->arrow_cursor = gdk_cursor_new (GDK_LEFT_PTR); | |
| 8061 | 1602 | imhtml->text_cursor = gdk_cursor_new (GDK_XTERM); |
| 2993 | 1603 | |
|
6124
322206d79652
[gaim-migrate @ 6598]
Mark Doliner <markdoliner@pidgin.im>
parents:
6066
diff
changeset
|
1604 | imhtml->show_comments = TRUE; |
| 4253 | 1605 | |
| 4892 | 1606 | imhtml->smiley_data = g_hash_table_new_full(g_str_hash, g_str_equal, |
| 4902 | 1607 | g_free, (GDestroyNotify)gtk_smiley_tree_destroy); |
| 4032 | 1608 | imhtml->default_smilies = gtk_smiley_tree_new(); |
| 4735 | 1609 | |
| 1610 | 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
|
1611 | 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
|
1612 | 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
|
1613 | #if (!GTK_CHECK_VERSION(2,2,0)) |
|
fb5b88957742
[gaim-migrate @ 12516]
Richard Laager <rlaager@pidgin.im>
parents:
10834
diff
changeset
|
1614 | /* See the comment for gtk_key_pressed_cb */ |
| 6066 | 1615 | 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
|
1616 | #endif |
| 8677 | 1617 | g_signal_connect(G_OBJECT(imhtml), "button_press_event", G_CALLBACK(gtk_imhtml_button_press_event), NULL); |
| 1618 | 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
|
1619 | g_signal_connect(G_OBJECT(imhtml->text_buffer), "delete_range", G_CALLBACK(delete_cb), imhtml); |
| 8061 | 1620 | g_signal_connect_after(G_OBJECT(imhtml->text_buffer), "insert-text", G_CALLBACK(insert_cb), imhtml); |
| 10169 | 1621 | g_signal_connect_after(G_OBJECT(imhtml->text_buffer), "insert-child-anchor", G_CALLBACK(insert_ca_cb), imhtml); |
| 8091 | 1622 | gtk_drag_dest_set(GTK_WIDGET(imhtml), 0, |
| 1623 | link_drag_drop_targets, sizeof(link_drag_drop_targets) / sizeof(GtkTargetEntry), | |
| 1624 | GDK_ACTION_COPY); | |
| 1625 | g_signal_connect(G_OBJECT(imhtml), "drag_data_received", G_CALLBACK(gtk_imhtml_link_drag_rcv_cb), imhtml); | |
| 9300 | 1626 | g_signal_connect(G_OBJECT(imhtml), "drag_drop", G_CALLBACK(gtk_imhtml_link_drop_cb), imhtml); |
| 8091 | 1627 | |
| 7353 | 1628 | g_signal_connect(G_OBJECT(imhtml), "copy-clipboard", G_CALLBACK(copy_clipboard_cb), NULL); |
| 8698 | 1629 | g_signal_connect(G_OBJECT(imhtml), "cut-clipboard", G_CALLBACK(cut_clipboard_cb), NULL); |
| 8061 | 1630 | g_signal_connect(G_OBJECT(imhtml), "paste-clipboard", G_CALLBACK(paste_clipboard_cb), NULL); |
| 8677 | 1631 | 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
|
1632 | g_signal_connect(G_OBJECT(imhtml), "unrealize", G_CALLBACK(imhtml_destroy_add_primary), NULL); |
| 8677 | 1633 | |
| 1634 | g_signal_connect_after(G_OBJECT(GTK_IMHTML(imhtml)->text_buffer), "mark-set", | |
| 1635 | G_CALLBACK(mark_set_so_update_selection_cb), imhtml); | |
| 1636 | ||
|
10946
63a41710fc94
[gaim-migrate @ 12742]
Daniel Atallah <datallah@pidgin.im>
parents:
10936
diff
changeset
|
1637 | gtk_widget_add_events(GTK_WIDGET(imhtml), |
|
63a41710fc94
[gaim-migrate @ 12742]
Daniel Atallah <datallah@pidgin.im>
parents:
10936
diff
changeset
|
1638 | GDK_LEAVE_NOTIFY_MASK | GDK_ENTER_NOTIFY_MASK); |
| 4735 | 1639 | |
| 1640 | imhtml->tip = NULL; | |
| 1641 | imhtml->tip_timer = 0; | |
| 1642 | imhtml->tip_window = NULL; | |
| 4895 | 1643 | |
| 8677 | 1644 | imhtml->edit.bold = FALSE; |
| 1645 | imhtml->edit.italic = FALSE; | |
| 1646 | imhtml->edit.underline = FALSE; | |
| 8061 | 1647 | imhtml->edit.forecolor = NULL; |
| 1648 | imhtml->edit.backcolor = NULL; | |
| 1649 | imhtml->edit.fontface = NULL; | |
| 8677 | 1650 | imhtml->edit.fontsize = 0; |
| 1651 | imhtml->edit.link = NULL; | |
| 1652 | ||
|
11572
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
1653 | |
| 4895 | 1654 | 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
|
1655 | imhtml->animations = g_queue_new(); |
| 8061 | 1656 | gtk_imhtml_set_editable(imhtml, FALSE); |
|
11572
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
1657 | g_signal_connect(G_OBJECT(imhtml), "populate-popup", |
| 8931 | 1658 | G_CALLBACK(hijack_menu_cb), NULL); |
| 2993 | 1659 | } |
| 1660 | ||
| 3922 | 1661 | GtkWidget *gtk_imhtml_new(void *a, void *b) |
| 1428 | 1662 | { |
| 4635 | 1663 | return GTK_WIDGET(g_object_new(gtk_imhtml_get_type(), NULL)); |
| 1428 | 1664 | } |
| 1665 | ||
| 9037 | 1666 | GType gtk_imhtml_get_type() |
| 1428 | 1667 | { |
| 9037 | 1668 | static GType imhtml_type = 0; |
| 1428 | 1669 | |
| 1670 | if (!imhtml_type) { | |
| 9037 | 1671 | static const GTypeInfo imhtml_info = { |
| 4635 | 1672 | sizeof(GtkIMHtmlClass), |
| 1673 | NULL, | |
| 1674 | NULL, | |
| 1675 | (GClassInitFunc) gtk_imhtml_class_init, | |
| 1676 | NULL, | |
| 1677 | NULL, | |
| 1428 | 1678 | sizeof (GtkIMHtml), |
| 4635 | 1679 | 0, |
|
12600
7ecd4441fdc7
[gaim-migrate @ 14934]
Richard Laager <rlaager@pidgin.im>
parents:
12553
diff
changeset
|
1680 | (GInstanceInitFunc) gtk_imhtml_init, |
|
7ecd4441fdc7
[gaim-migrate @ 14934]
Richard Laager <rlaager@pidgin.im>
parents:
12553
diff
changeset
|
1681 | NULL |
| 1428 | 1682 | }; |
| 4635 | 1683 | |
| 1684 | imhtml_type = g_type_register_static(gtk_text_view_get_type(), | |
| 1685 | "GtkIMHtml", &imhtml_info, 0); | |
| 1428 | 1686 | } |
| 1687 | ||
| 1688 | return imhtml_type; | |
| 1689 | } | |
| 1690 | ||
| 4417 | 1691 | struct url_data { |
| 1692 | GObject *object; | |
| 1693 | gchar *url; | |
|
24328
7be2af5c9129
Show visited links in a different color. This also plugs a memory leak
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23548
diff
changeset
|
1694 | GtkTextTag *tag; |
| 4417 | 1695 | }; |
| 1696 | ||
| 8677 | 1697 | static void url_data_destroy(gpointer mydata) |
| 1698 | { | |
| 1699 | struct url_data *data = mydata; | |
| 1700 | g_object_unref(data->object); | |
|
24328
7be2af5c9129
Show visited links in a different color. This also plugs a memory leak
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23548
diff
changeset
|
1701 | g_object_unref(data->tag); |
| 8677 | 1702 | g_free(data->url); |
| 1703 | g_free(data); | |
| 1704 | } | |
| 1705 | ||
|
24328
7be2af5c9129
Show visited links in a different color. This also plugs a memory leak
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23548
diff
changeset
|
1706 | static void url_open(GtkWidget *w, struct url_data *data) |
|
7be2af5c9129
Show visited links in a different color. This also plugs a memory leak
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23548
diff
changeset
|
1707 | { |
| 4417 | 1708 | if(!data) return; |
| 8061 | 1709 | g_signal_emit(data->object, signals[URL_CLICKED], 0, data->url); |
|
24328
7be2af5c9129
Show visited links in a different color. This also plugs a memory leak
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23548
diff
changeset
|
1710 | g_object_set_data(G_OBJECT(data->tag), "visited", GINT_TO_POINTER(TRUE)); |
|
7be2af5c9129
Show visited links in a different color. This also plugs a memory leak
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23548
diff
changeset
|
1711 | gtk_imhtml_set_link_color(GTK_IMHTML(data->object), data->tag); |
| 4417 | 1712 | } |
|
5582
2e5da5db947b
[gaim-migrate @ 5986]
Robert McQueen <robot101@debian.org>
parents:
5367
diff
changeset
|
1713 | |
| 4417 | 1714 | static void url_copy(GtkWidget *w, gchar *url) { |
| 1715 | GtkClipboard *clipboard; | |
| 1716 | ||
| 8931 | 1717 | clipboard = gtk_widget_get_clipboard(w, GDK_SELECTION_PRIMARY); |
| 4417 | 1718 | gtk_clipboard_set_text(clipboard, url, -1); |
|
5582
2e5da5db947b
[gaim-migrate @ 5986]
Robert McQueen <robot101@debian.org>
parents:
5367
diff
changeset
|
1719 | |
| 8931 | 1720 | clipboard = gtk_widget_get_clipboard(w, GDK_SELECTION_CLIPBOARD); |
|
5582
2e5da5db947b
[gaim-migrate @ 5986]
Robert McQueen <robot101@debian.org>
parents:
5367
diff
changeset
|
1721 | gtk_clipboard_set_text(clipboard, url, -1); |
| 4417 | 1722 | } |
| 1723 | ||
| 1724 | /* The callback for an event on a link tag. */ | |
|
24328
7be2af5c9129
Show visited links in a different color. This also plugs a memory leak
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23548
diff
changeset
|
1725 | static gboolean tag_event(GtkTextTag *tag, GObject *imhtml, GdkEvent *event, GtkTextIter *arg2, gpointer unused) |
|
7be2af5c9129
Show visited links in a different color. This also plugs a memory leak
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23548
diff
changeset
|
1726 | { |
| 4417 | 1727 | GdkEventButton *event_button = (GdkEventButton *) event; |
| 8061 | 1728 | if (GTK_IMHTML(imhtml)->editable) |
| 1729 | return FALSE; | |
| 3922 | 1730 | if (event->type == GDK_BUTTON_RELEASE) { |
| 8957 | 1731 | if ((event_button->button == 1) || (event_button->button == 2)) { |
| 4417 | 1732 | GtkTextIter start, end; |
| 1733 | /* we shouldn't open a URL if the user has selected something: */ | |
| 8677 | 1734 | if (gtk_text_buffer_get_selection_bounds( |
| 1735 | gtk_text_iter_get_buffer(arg2), &start, &end)) | |
| 4417 | 1736 | return FALSE; |
| 1737 | ||
| 1738 | /* A link was clicked--we emit the "url_clicked" signal | |
| 1739 | * with the URL as the argument */ | |
| 8677 | 1740 | g_object_ref(G_OBJECT(tag)); |
| 1741 | g_signal_emit(imhtml, signals[URL_CLICKED], 0, g_object_get_data(G_OBJECT(tag), "link_url")); | |
| 1742 | g_object_unref(G_OBJECT(tag)); | |
|
24328
7be2af5c9129
Show visited links in a different color. This also plugs a memory leak
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23548
diff
changeset
|
1743 | g_object_set_data(G_OBJECT(tag), "visited", GINT_TO_POINTER(TRUE)); |
|
7be2af5c9129
Show visited links in a different color. This also plugs a memory leak
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23548
diff
changeset
|
1744 | gtk_imhtml_set_link_color(GTK_IMHTML(imhtml), tag); |
| 4417 | 1745 | return FALSE; |
| 1746 | } else if(event_button->button == 3) { | |
| 4745 | 1747 | GtkWidget *img, *item, *menu; |
| 4417 | 1748 | struct url_data *tempdata = g_new(struct url_data, 1); |
| 5091 | 1749 | tempdata->object = g_object_ref(imhtml); |
| 8677 | 1750 | tempdata->url = g_strdup(g_object_get_data(G_OBJECT(tag), "link_url")); |
|
24328
7be2af5c9129
Show visited links in a different color. This also plugs a memory leak
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23548
diff
changeset
|
1751 | tempdata->tag = g_object_ref(tag); |
| 4745 | 1752 | |
| 5091 | 1753 | /* Don't want the tooltip around if user right-clicked on link */ |
| 1754 | if (GTK_IMHTML(imhtml)->tip_window) { | |
| 1755 | gtk_widget_destroy(GTK_IMHTML(imhtml)->tip_window); | |
| 1756 | GTK_IMHTML(imhtml)->tip_window = NULL; | |
| 1757 | } | |
| 1758 | if (GTK_IMHTML(imhtml)->tip_timer) { | |
| 1759 | g_source_remove(GTK_IMHTML(imhtml)->tip_timer); | |
| 1760 | GTK_IMHTML(imhtml)->tip_timer = 0; | |
| 1761 | } | |
| 8061 | 1762 | if (GTK_IMHTML(imhtml)->editable) |
| 1763 | gdk_window_set_cursor(event_button->window, GTK_IMHTML(imhtml)->text_cursor); | |
| 1764 | else | |
| 1765 | gdk_window_set_cursor(event_button->window, GTK_IMHTML(imhtml)->arrow_cursor); | |
| 4417 | 1766 | menu = gtk_menu_new(); |
| 8677 | 1767 | g_object_set_data_full(G_OBJECT(menu), "x-imhtml-url-data", tempdata, url_data_destroy); |
| 4745 | 1768 | |
| 4417 | 1769 | /* buttons and such */ |
| 1770 | ||
| 8677 | 1771 | if (!strncmp(tempdata->url, "mailto:", 7)) |
|
7140
2670fa7da352
[gaim-migrate @ 7707]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
1772 | { |
|
23325
a374a26fe217
Use "email" and "Email" consistently. This is potentially controversial,
Richard Laager <rlaager@pidgin.im>
parents:
23310
diff
changeset
|
1773 | /* Copy Email Address */ |
|
7140
2670fa7da352
[gaim-migrate @ 7707]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
1774 | img = gtk_image_new_from_stock(GTK_STOCK_COPY, |
|
2670fa7da352
[gaim-migrate @ 7707]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
1775 | GTK_ICON_SIZE_MENU); |
|
2670fa7da352
[gaim-migrate @ 7707]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
1776 | item = gtk_image_menu_item_new_with_mnemonic( |
|
23325
a374a26fe217
Use "email" and "Email" consistently. This is potentially controversial,
Richard Laager <rlaager@pidgin.im>
parents:
23310
diff
changeset
|
1777 | _("_Copy Email Address")); |
|
7140
2670fa7da352
[gaim-migrate @ 7707]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
1778 | 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
|
1779 | g_signal_connect(G_OBJECT(item), "activate", |
| 8677 | 1780 | G_CALLBACK(url_copy), tempdata->url + 7); |
|
7140
2670fa7da352
[gaim-migrate @ 7707]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
1781 | gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); |
|
2670fa7da352
[gaim-migrate @ 7707]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
1782 | } |
|
2670fa7da352
[gaim-migrate @ 7707]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
1783 | else |
|
2670fa7da352
[gaim-migrate @ 7707]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
1784 | { |
| 10936 | 1785 | /* Open Link in Browser */ |
| 1786 | img = gtk_image_new_from_stock(GTK_STOCK_JUMP_TO, | |
| 1787 | GTK_ICON_SIZE_MENU); | |
| 1788 | item = gtk_image_menu_item_new_with_mnemonic( | |
| 1789 | _("_Open Link in Browser")); | |
| 1790 | gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(item), img); | |
| 1791 | g_signal_connect(G_OBJECT(item), "activate", | |
| 1792 | G_CALLBACK(url_open), tempdata); | |
| 1793 | gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); | |
| 1794 | ||
|
7140
2670fa7da352
[gaim-migrate @ 7707]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
1795 | /* Copy Link Location */ |
|
2670fa7da352
[gaim-migrate @ 7707]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
1796 | img = gtk_image_new_from_stock(GTK_STOCK_COPY, |
|
2670fa7da352
[gaim-migrate @ 7707]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
1797 | GTK_ICON_SIZE_MENU); |
|
2670fa7da352
[gaim-migrate @ 7707]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
1798 | item = gtk_image_menu_item_new_with_mnemonic( |
|
2670fa7da352
[gaim-migrate @ 7707]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
1799 | _("_Copy Link Location")); |
|
2670fa7da352
[gaim-migrate @ 7707]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
1800 | 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
|
1801 | g_signal_connect(G_OBJECT(item), "activate", |
| 8677 | 1802 | G_CALLBACK(url_copy), tempdata->url); |
|
7140
2670fa7da352
[gaim-migrate @ 7707]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
1803 | gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); |
|
2670fa7da352
[gaim-migrate @ 7707]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
1804 | } |
|
2670fa7da352
[gaim-migrate @ 7707]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
1805 | |
|
4756
ee19a87a495f
[gaim-migrate @ 5073]
Mark Doliner <markdoliner@pidgin.im>
parents:
4745
diff
changeset
|
1806 | |
| 4417 | 1807 | gtk_widget_show_all(menu); |
|
4756
ee19a87a495f
[gaim-migrate @ 5073]
Mark Doliner <markdoliner@pidgin.im>
parents:
4745
diff
changeset
|
1808 | gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL, |
|
ee19a87a495f
[gaim-migrate @ 5073]
Mark Doliner <markdoliner@pidgin.im>
parents:
4745
diff
changeset
|
1809 | event_button->button, event_button->time); |
| 4745 | 1810 | |
| 4417 | 1811 | return TRUE; |
| 1812 | } | |
| 1428 | 1813 | } |
| 4417 | 1814 | if(event->type == GDK_BUTTON_PRESS && event_button->button == 3) |
| 1815 | return TRUE; /* Clicking the right mouse button on a link shouldn't | |
| 1816 | be caught by the regular GtkTextView menu */ | |
| 1817 | else | |
| 1818 | return FALSE; /* Let clicks go through if we didn't catch anything */ | |
| 1428 | 1819 | } |
| 1820 | ||
| 9300 | 1821 | static gboolean |
| 1822 | gtk_text_view_drag_motion (GtkWidget *widget, | |
| 1823 | GdkDragContext *context, | |
| 1824 | gint x, | |
| 1825 | gint y, | |
| 1826 | guint time) | |
| 1827 | { | |
|
11572
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
1828 | GdkDragAction suggested_action = 0; |
| 9300 | 1829 | |
|
10145
f1405f65ff41
[gaim-migrate @ 11218]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10110
diff
changeset
|
1830 | 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
|
1831 | /* can't accept any of the offered targets */ |
| 9300 | 1832 | } else { |
| 1833 | GtkWidget *source_widget; | |
| 1834 | suggested_action = context->suggested_action; | |
| 1835 | source_widget = gtk_drag_get_source_widget (context); | |
| 1836 | if (source_widget == widget) { | |
| 1837 | /* Default to MOVE, unless the user has | |
| 1838 | * pressed ctrl or alt to affect available actions | |
| 1839 | */ | |
| 1840 | if ((context->actions & GDK_ACTION_MOVE) != 0) | |
| 1841 | suggested_action = GDK_ACTION_MOVE; | |
| 1842 | } | |
|
11572
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
1843 | } |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
1844 | |
|
10145
f1405f65ff41
[gaim-migrate @ 11218]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10110
diff
changeset
|
1845 | gdk_drag_status (context, suggested_action, time); |
|
11572
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
1846 | |
| 9300 | 1847 | /* TRUE return means don't propagate the drag motion to parent |
| 1848 | * widgets that may also be drop sites. | |
| 1849 | */ | |
| 1850 | return TRUE; | |
| 1851 | } | |
| 1852 | ||
| 1853 | static void | |
| 1854 | gtk_imhtml_link_drop_cb(GtkWidget *widget, GdkDragContext *context, gint x, gint y, guint time, gpointer user_data) | |
| 1855 | { | |
| 1856 | GdkAtom target = gtk_drag_dest_find_target (widget, context, NULL); | |
|
11572
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
1857 | |
| 9300 | 1858 | if (target != GDK_NONE) |
| 1859 | gtk_drag_get_data (widget, context, target, time); | |
| 1860 | else | |
| 1861 | gtk_drag_finish (context, FALSE, FALSE, time); | |
| 1862 | ||
| 1863 | return; | |
| 1864 | } | |
| 1865 | ||
| 8091 | 1866 | static void |
| 1867 | 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
|
1868 | GtkSelectionData *sd, guint info, guint t, GtkIMHtml *imhtml) |
| 8091 | 1869 | { |
| 9300 | 1870 | gchar **links; |
| 1871 | gchar *link; | |
|
11143
f606fb334190
[gaim-migrate @ 13207]
Mark Doliner <markdoliner@pidgin.im>
parents:
11069
diff
changeset
|
1872 | char *text = (char *)sd->data; |
| 9300 | 1873 | GtkTextMark *mark = gtk_text_buffer_get_insert(imhtml->text_buffer); |
| 1874 | GtkTextIter iter; | |
|
10782
18cc41076f4e
[gaim-migrate @ 12410]
Luke Schierer <lschiere@pidgin.im>
parents:
10777
diff
changeset
|
1875 | gint i = 0; |
| 9300 | 1876 | |
| 1877 | gtk_text_buffer_get_iter_at_mark(imhtml->text_buffer, &iter, mark); | |
| 1878 | ||
| 8091 | 1879 | if(gtk_imhtml_get_editable(imhtml) && sd->data){ |
| 9300 | 1880 | switch (info) { |
|
10145
f1405f65ff41
[gaim-migrate @ 11218]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10110
diff
changeset
|
1881 | case GTK_IMHTML_DRAG_URL: |
|
11143
f606fb334190
[gaim-migrate @ 13207]
Mark Doliner <markdoliner@pidgin.im>
parents:
11069
diff
changeset
|
1882 | /* TODO: Is it really ok to change sd->data...? */ |
| 15884 | 1883 | purple_str_strip_char((char *)sd->data, '\r'); |
|
11143
f606fb334190
[gaim-migrate @ 13207]
Mark Doliner <markdoliner@pidgin.im>
parents:
11069
diff
changeset
|
1884 | |
|
f606fb334190
[gaim-migrate @ 13207]
Mark Doliner <markdoliner@pidgin.im>
parents:
11069
diff
changeset
|
1885 | links = g_strsplit((char *)sd->data, "\n", 0); |
|
10782
18cc41076f4e
[gaim-migrate @ 12410]
Luke Schierer <lschiere@pidgin.im>
parents:
10777
diff
changeset
|
1886 | while((link = links[i]) != NULL){ |
| 15884 | 1887 | if(purple_str_has_prefix(link, "http://") || |
| 1888 | purple_str_has_prefix(link, "https://") || | |
| 1889 | purple_str_has_prefix(link, "ftp://")) | |
|
10782
18cc41076f4e
[gaim-migrate @ 12410]
Luke Schierer <lschiere@pidgin.im>
parents:
10777
diff
changeset
|
1890 | { |
|
18cc41076f4e
[gaim-migrate @ 12410]
Luke Schierer <lschiere@pidgin.im>
parents:
10777
diff
changeset
|
1891 | gchar *label; |
|
18cc41076f4e
[gaim-migrate @ 12410]
Luke Schierer <lschiere@pidgin.im>
parents:
10777
diff
changeset
|
1892 | |
|
18cc41076f4e
[gaim-migrate @ 12410]
Luke Schierer <lschiere@pidgin.im>
parents:
10777
diff
changeset
|
1893 | if(links[i + 1]) |
|
18cc41076f4e
[gaim-migrate @ 12410]
Luke Schierer <lschiere@pidgin.im>
parents:
10777
diff
changeset
|
1894 | i++; |
|
18cc41076f4e
[gaim-migrate @ 12410]
Luke Schierer <lschiere@pidgin.im>
parents:
10777
diff
changeset
|
1895 | |
|
18cc41076f4e
[gaim-migrate @ 12410]
Luke Schierer <lschiere@pidgin.im>
parents:
10777
diff
changeset
|
1896 | label = links[i]; |
|
18cc41076f4e
[gaim-migrate @ 12410]
Luke Schierer <lschiere@pidgin.im>
parents:
10777
diff
changeset
|
1897 | |
|
18cc41076f4e
[gaim-migrate @ 12410]
Luke Schierer <lschiere@pidgin.im>
parents:
10777
diff
changeset
|
1898 | gtk_imhtml_insert_link(imhtml, mark, link, label); |
| 9300 | 1899 | } else if (link=='\0') { |
| 1900 | /* Ignore blank lines */ | |
| 1901 | } else { | |
| 1902 | /* 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
|
1903 | /* ... don't pretend we handled it if we didn't */ |
|
7d7f8cfa2b4f
[gaim-migrate @ 11556]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
10297
diff
changeset
|
1904 | gtk_drag_finish(dc, FALSE, FALSE, t); |
|
10782
18cc41076f4e
[gaim-migrate @ 12410]
Luke Schierer <lschiere@pidgin.im>
parents:
10777
diff
changeset
|
1905 | g_strfreev(links); |
|
10345
7d7f8cfa2b4f
[gaim-migrate @ 11556]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
10297
diff
changeset
|
1906 | return; |
| 9300 | 1907 | } |
|
10782
18cc41076f4e
[gaim-migrate @ 12410]
Luke Schierer <lschiere@pidgin.im>
parents:
10777
diff
changeset
|
1908 | |
|
18cc41076f4e
[gaim-migrate @ 12410]
Luke Schierer <lschiere@pidgin.im>
parents:
10777
diff
changeset
|
1909 | i++; |
| 8091 | 1910 | } |
|
10782
18cc41076f4e
[gaim-migrate @ 12410]
Luke Schierer <lschiere@pidgin.im>
parents:
10777
diff
changeset
|
1911 | g_strfreev(links); |
| 9300 | 1912 | break; |
|
10145
f1405f65ff41
[gaim-migrate @ 11218]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10110
diff
changeset
|
1913 | case GTK_IMHTML_DRAG_HTML: |
|
10243
6d75b29afc71
[gaim-migrate @ 11383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10217
diff
changeset
|
1914 | { |
|
6d75b29afc71
[gaim-migrate @ 11383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10217
diff
changeset
|
1915 | char *utf8 = NULL; |
|
6d75b29afc71
[gaim-migrate @ 11383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10217
diff
changeset
|
1916 | /* 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
|
1917 | * as explained by this comment in gtkhtml: |
|
6d75b29afc71
[gaim-migrate @ 11383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10217
diff
changeset
|
1918 | * |
|
6d75b29afc71
[gaim-migrate @ 11383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10217
diff
changeset
|
1919 | * 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
|
1920 | * mozilla/netscape alway use ucs2 for text/html |
|
6d75b29afc71
[gaim-migrate @ 11383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10217
diff
changeset
|
1921 | * 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
|
1922 | * 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
|
1923 | * |
|
6d75b29afc71
[gaim-migrate @ 11383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10217
diff
changeset
|
1924 | * See also the comment on text/html here: |
|
6d75b29afc71
[gaim-migrate @ 11383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10217
diff
changeset
|
1925 | * 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
|
1926 | */ |
|
6d75b29afc71
[gaim-migrate @ 11383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10217
diff
changeset
|
1927 | if (sd->length >= 2 && !g_utf8_validate(text, sd->length - 1, NULL)) { |
|
22596
0854ae660ef4
Further changes to use UTF-16 instead of UCS-2. Also, fix #5167 by making sure that the encoding conversion worked before using the result.
Daniel Atallah <datallah@pidgin.im>
parents:
22595
diff
changeset
|
1928 | utf8 = utf16_to_utf8_with_bom_check(text, sd->length); |
|
10243
6d75b29afc71
[gaim-migrate @ 11383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10217
diff
changeset
|
1929 | |
|
6d75b29afc71
[gaim-migrate @ 11383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10217
diff
changeset
|
1930 | if (!utf8) { |
|
22596
0854ae660ef4
Further changes to use UTF-16 instead of UCS-2. Also, fix #5167 by making sure that the encoding conversion worked before using the result.
Daniel Atallah <datallah@pidgin.im>
parents:
22595
diff
changeset
|
1931 | purple_debug_warning("gtkimhtml", "g_convert from UTF-16 failed in drag_rcv_cb\n"); |
| 9300 | 1932 | return; |
| 1933 | } | |
|
10243
6d75b29afc71
[gaim-migrate @ 11383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10217
diff
changeset
|
1934 | } else if (!(*text) || !g_utf8_validate(text, -1, NULL)) { |
| 15884 | 1935 | purple_debug_warning("gtkimhtml", "empty string or invalid UTF-8 in drag_rcv_cb\n"); |
| 9300 | 1936 | return; |
| 1937 | } | |
|
10243
6d75b29afc71
[gaim-migrate @ 11383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10217
diff
changeset
|
1938 | |
|
6d75b29afc71
[gaim-migrate @ 11383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10217
diff
changeset
|
1939 | 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
|
1940 | g_free(utf8); |
| 9300 | 1941 | break; |
|
10243
6d75b29afc71
[gaim-migrate @ 11383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10217
diff
changeset
|
1942 | } |
|
10145
f1405f65ff41
[gaim-migrate @ 11218]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10110
diff
changeset
|
1943 | case GTK_IMHTML_DRAG_TEXT: |
|
f1405f65ff41
[gaim-migrate @ 11218]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10110
diff
changeset
|
1944 | if (!(*text) || !g_utf8_validate(text, -1, NULL)) { |
| 15884 | 1945 | 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
|
1946 | return; |
|
f1405f65ff41
[gaim-migrate @ 11218]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10110
diff
changeset
|
1947 | } else { |
|
10732
5e314ab498bf
[gaim-migrate @ 12334]
Richard Laager <rlaager@pidgin.im>
parents:
10699
diff
changeset
|
1948 | char *tmp = g_markup_escape_text(text, -1); |
|
10145
f1405f65ff41
[gaim-migrate @ 11218]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10110
diff
changeset
|
1949 | gtk_imhtml_insert_html_at_iter(imhtml, tmp, 0, &iter); |
|
f1405f65ff41
[gaim-migrate @ 11218]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10110
diff
changeset
|
1950 | g_free(tmp); |
|
f1405f65ff41
[gaim-migrate @ 11218]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10110
diff
changeset
|
1951 | } |
|
f1405f65ff41
[gaim-migrate @ 11218]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10110
diff
changeset
|
1952 | break; |
| 9300 | 1953 | default: |
|
10145
f1405f65ff41
[gaim-migrate @ 11218]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10110
diff
changeset
|
1954 | gtk_drag_finish(dc, FALSE, FALSE, t); |
|
f1405f65ff41
[gaim-migrate @ 11218]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10110
diff
changeset
|
1955 | return; |
| 8091 | 1956 | } |
| 1957 | gtk_drag_finish(dc, TRUE, (dc->action == GDK_ACTION_MOVE), t); | |
| 1958 | } else { | |
| 1959 | gtk_drag_finish(dc, FALSE, FALSE, t); | |
| 1960 | } | |
| 1961 | } | |
| 1962 | ||
| 9300 | 1963 | static void gtk_smiley_tree_remove (GtkSmileyTree *tree, |
| 4263 | 1964 | GtkIMHtmlSmiley *smiley) |
| 4032 | 1965 | { |
| 1966 | GtkSmileyTree *t = tree; | |
| 4263 | 1967 | const gchar *x = smiley->smile; |
| 4032 | 1968 | gint len = 0; |
| 1969 | ||
| 1970 | while (*x) { | |
| 1971 | gchar *pos; | |
| 1972 | ||
| 1973 | if (!t->values) | |
| 1974 | return; | |
| 1975 | ||
| 1976 | pos = strchr (t->values->str, *x); | |
| 1977 | if (pos) | |
|
24544
75266af2c12b
Fixed a compiler warning (and remove an unnessesary cast)
Marcus Lundblad <malu@pidgin.im>
parents:
24511
diff
changeset
|
1978 | t = t->children [pos - t->values->str]; |
| 4032 | 1979 | else |
| 1980 | return; | |
| 1981 | ||
| 1982 | x++; len++; | |
| 1983 | } | |
| 1984 | ||
| 4141 | 1985 | if (t->image) { |
| 4032 | 1986 | t->image = NULL; |
| 4141 | 1987 | } |
| 4032 | 1988 | } |
| 1989 | ||
| 1990 | static gint | |
| 1991 | gtk_smiley_tree_lookup (GtkSmileyTree *tree, | |
| 1992 | const gchar *text) | |
| 1993 | { | |
| 1994 | GtkSmileyTree *t = tree; | |
| 1995 | const gchar *x = text; | |
| 1996 | gint len = 0; | |
|
16143
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
1997 | const gchar *amp; |
| 8505 | 1998 | gint alen; |
| 4032 | 1999 | |
| 2000 | while (*x) { | |
| 2001 | gchar *pos; | |
| 2002 | ||
| 2003 | if (!t->values) | |
| 2004 | break; | |
| 2005 | ||
| 16144 | 2006 | if(*x == '&' && (amp = purple_markup_unescape_entity(x, &alen))) { |
|
10865
f5bb66be81a0
[gaim-migrate @ 12549]
Daniel Atallah <datallah@pidgin.im>
parents:
10858
diff
changeset
|
2007 | gboolean matched = TRUE; |
|
f5bb66be81a0
[gaim-migrate @ 12549]
Daniel Atallah <datallah@pidgin.im>
parents:
10858
diff
changeset
|
2008 | /* Make sure all chars of the unescaped value match */ |
|
f5bb66be81a0
[gaim-migrate @ 12549]
Daniel Atallah <datallah@pidgin.im>
parents:
10858
diff
changeset
|
2009 | while (*(amp + 1)) { |
|
f5bb66be81a0
[gaim-migrate @ 12549]
Daniel Atallah <datallah@pidgin.im>
parents:
10858
diff
changeset
|
2010 | pos = strchr (t->values->str, *amp); |
|
f5bb66be81a0
[gaim-migrate @ 12549]
Daniel Atallah <datallah@pidgin.im>
parents:
10858
diff
changeset
|
2011 | if (pos) |
|
f5bb66be81a0
[gaim-migrate @ 12549]
Daniel Atallah <datallah@pidgin.im>
parents:
10858
diff
changeset
|
2012 | 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
|
2013 | else { |
|
f5bb66be81a0
[gaim-migrate @ 12549]
Daniel Atallah <datallah@pidgin.im>
parents:
10858
diff
changeset
|
2014 | matched = FALSE; |
|
f5bb66be81a0
[gaim-migrate @ 12549]
Daniel Atallah <datallah@pidgin.im>
parents:
10858
diff
changeset
|
2015 | break; |
|
f5bb66be81a0
[gaim-migrate @ 12549]
Daniel Atallah <datallah@pidgin.im>
parents:
10858
diff
changeset
|
2016 | } |
|
f5bb66be81a0
[gaim-migrate @ 12549]
Daniel Atallah <datallah@pidgin.im>
parents:
10858
diff
changeset
|
2017 | amp++; |
|
f5bb66be81a0
[gaim-migrate @ 12549]
Daniel Atallah <datallah@pidgin.im>
parents:
10858
diff
changeset
|
2018 | } |
|
f5bb66be81a0
[gaim-migrate @ 12549]
Daniel Atallah <datallah@pidgin.im>
parents:
10858
diff
changeset
|
2019 | if (!matched) |
|
f5bb66be81a0
[gaim-migrate @ 12549]
Daniel Atallah <datallah@pidgin.im>
parents:
10858
diff
changeset
|
2020 | break; |
|
f5bb66be81a0
[gaim-migrate @ 12549]
Daniel Atallah <datallah@pidgin.im>
parents:
10858
diff
changeset
|
2021 | |
|
f5bb66be81a0
[gaim-migrate @ 12549]
Daniel Atallah <datallah@pidgin.im>
parents:
10858
diff
changeset
|
2022 | pos = strchr (t->values->str, *amp); |
| 8505 | 2023 | } |
|
11572
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
2024 | else if (*x == '<') /* Because we're all WYSIWYG now, a '<' |
| 9636 | 2025 | * char should only appear as the start of a tag. Perhaps a safer (but costlier) |
| 2026 | * check would be to call gtk_imhtml_is_tag on it */ | |
| 10600 | 2027 | break; |
|
10865
f5bb66be81a0
[gaim-migrate @ 12549]
Daniel Atallah <datallah@pidgin.im>
parents:
10858
diff
changeset
|
2028 | else { |
|
f5bb66be81a0
[gaim-migrate @ 12549]
Daniel Atallah <datallah@pidgin.im>
parents:
10858
diff
changeset
|
2029 | alen = 1; |
|
f5bb66be81a0
[gaim-migrate @ 12549]
Daniel Atallah <datallah@pidgin.im>
parents:
10858
diff
changeset
|
2030 | pos = strchr (t->values->str, *x); |
|
f5bb66be81a0
[gaim-migrate @ 12549]
Daniel Atallah <datallah@pidgin.im>
parents:
10858
diff
changeset
|
2031 | } |
| 8505 | 2032 | |
| 4032 | 2033 | if (pos) |
| 7371 | 2034 | t = t->children [GPOINTER_TO_INT(pos) - GPOINTER_TO_INT(t->values->str)]; |
| 4032 | 2035 | else |
| 2036 | break; | |
| 2037 | ||
|
10865
f5bb66be81a0
[gaim-migrate @ 12549]
Daniel Atallah <datallah@pidgin.im>
parents:
10858
diff
changeset
|
2038 | x += alen; |
|
f5bb66be81a0
[gaim-migrate @ 12549]
Daniel Atallah <datallah@pidgin.im>
parents:
10858
diff
changeset
|
2039 | len += alen; |
| 4032 | 2040 | } |
| 2041 | ||
| 2042 | if (t->image) | |
| 2043 | return len; | |
| 2044 | ||
| 2045 | return 0; | |
| 2046 | } | |
| 2047 | ||
|
24392
51b7f65a712d
Clean up the GtkSmileyTrees on active GtkIMHtml instances when a custom smiley
Marcus Lundblad <malu@pidgin.im>
parents:
24328
diff
changeset
|
2048 | static void |
|
51b7f65a712d
Clean up the GtkSmileyTrees on active GtkIMHtml instances when a custom smiley
Marcus Lundblad <malu@pidgin.im>
parents:
24328
diff
changeset
|
2049 | gtk_imhtml_disassociate_smiley_foreach(gpointer key, gpointer value, |
|
51b7f65a712d
Clean up the GtkSmileyTrees on active GtkIMHtml instances when a custom smiley
Marcus Lundblad <malu@pidgin.im>
parents:
24328
diff
changeset
|
2050 | gpointer user_data) |
|
51b7f65a712d
Clean up the GtkSmileyTrees on active GtkIMHtml instances when a custom smiley
Marcus Lundblad <malu@pidgin.im>
parents:
24328
diff
changeset
|
2051 | { |
|
51b7f65a712d
Clean up the GtkSmileyTrees on active GtkIMHtml instances when a custom smiley
Marcus Lundblad <malu@pidgin.im>
parents:
24328
diff
changeset
|
2052 | GtkSmileyTree *tree = (GtkSmileyTree *) value; |
|
51b7f65a712d
Clean up the GtkSmileyTrees on active GtkIMHtml instances when a custom smiley
Marcus Lundblad <malu@pidgin.im>
parents:
24328
diff
changeset
|
2053 | GtkIMHtmlSmiley *smiley = (GtkIMHtmlSmiley *) user_data; |
|
51b7f65a712d
Clean up the GtkSmileyTrees on active GtkIMHtml instances when a custom smiley
Marcus Lundblad <malu@pidgin.im>
parents:
24328
diff
changeset
|
2054 | gtk_smiley_tree_remove(tree, smiley); |
|
51b7f65a712d
Clean up the GtkSmileyTrees on active GtkIMHtml instances when a custom smiley
Marcus Lundblad <malu@pidgin.im>
parents:
24328
diff
changeset
|
2055 | } |
|
51b7f65a712d
Clean up the GtkSmileyTrees on active GtkIMHtml instances when a custom smiley
Marcus Lundblad <malu@pidgin.im>
parents:
24328
diff
changeset
|
2056 | |
|
51b7f65a712d
Clean up the GtkSmileyTrees on active GtkIMHtml instances when a custom smiley
Marcus Lundblad <malu@pidgin.im>
parents:
24328
diff
changeset
|
2057 | static void |
|
24588
b2c89babe134
Remove that hack involving GtkIMHtmlSmileys
Marcus Lundblad <malu@pidgin.im>
parents:
24587
diff
changeset
|
2058 | gtk_imhtml_disconnect_smiley(GtkIMHtml *imhtml, GtkIMHtmlSmiley *smiley) |
|
b2c89babe134
Remove that hack involving GtkIMHtmlSmileys
Marcus Lundblad <malu@pidgin.im>
parents:
24587
diff
changeset
|
2059 | { |
|
b2c89babe134
Remove that hack involving GtkIMHtmlSmileys
Marcus Lundblad <malu@pidgin.im>
parents:
24587
diff
changeset
|
2060 | smiley->imhtml = NULL; |
|
b2c89babe134
Remove that hack involving GtkIMHtmlSmileys
Marcus Lundblad <malu@pidgin.im>
parents:
24587
diff
changeset
|
2061 | g_signal_handlers_disconnect_matched(imhtml, G_SIGNAL_MATCH_DATA, 0, 0, |
|
b2c89babe134
Remove that hack involving GtkIMHtmlSmileys
Marcus Lundblad <malu@pidgin.im>
parents:
24587
diff
changeset
|
2062 | NULL, NULL, smiley); |
|
b2c89babe134
Remove that hack involving GtkIMHtmlSmileys
Marcus Lundblad <malu@pidgin.im>
parents:
24587
diff
changeset
|
2063 | } |
|
b2c89babe134
Remove that hack involving GtkIMHtmlSmileys
Marcus Lundblad <malu@pidgin.im>
parents:
24587
diff
changeset
|
2064 | |
|
b2c89babe134
Remove that hack involving GtkIMHtmlSmileys
Marcus Lundblad <malu@pidgin.im>
parents:
24587
diff
changeset
|
2065 | static void |
|
24392
51b7f65a712d
Clean up the GtkSmileyTrees on active GtkIMHtml instances when a custom smiley
Marcus Lundblad <malu@pidgin.im>
parents:
24328
diff
changeset
|
2066 | gtk_imhtml_disassociate_smiley(GtkIMHtmlSmiley *smiley) |
|
51b7f65a712d
Clean up the GtkSmileyTrees on active GtkIMHtml instances when a custom smiley
Marcus Lundblad <malu@pidgin.im>
parents:
24328
diff
changeset
|
2067 | { |
|
24588
b2c89babe134
Remove that hack involving GtkIMHtmlSmileys
Marcus Lundblad <malu@pidgin.im>
parents:
24587
diff
changeset
|
2068 | if (smiley->imhtml) { |
|
24392
51b7f65a712d
Clean up the GtkSmileyTrees on active GtkIMHtml instances when a custom smiley
Marcus Lundblad <malu@pidgin.im>
parents:
24328
diff
changeset
|
2069 | gtk_smiley_tree_remove(smiley->imhtml->default_smilies, smiley); |
|
51b7f65a712d
Clean up the GtkSmileyTrees on active GtkIMHtml instances when a custom smiley
Marcus Lundblad <malu@pidgin.im>
parents:
24328
diff
changeset
|
2070 | g_hash_table_foreach(smiley->imhtml->smiley_data, |
|
51b7f65a712d
Clean up the GtkSmileyTrees on active GtkIMHtml instances when a custom smiley
Marcus Lundblad <malu@pidgin.im>
parents:
24328
diff
changeset
|
2071 | gtk_imhtml_disassociate_smiley_foreach, smiley); |
|
24588
b2c89babe134
Remove that hack involving GtkIMHtmlSmileys
Marcus Lundblad <malu@pidgin.im>
parents:
24587
diff
changeset
|
2072 | g_signal_handlers_disconnect_matched(smiley->imhtml, G_SIGNAL_MATCH_DATA, |
|
b2c89babe134
Remove that hack involving GtkIMHtmlSmileys
Marcus Lundblad <malu@pidgin.im>
parents:
24587
diff
changeset
|
2073 | 0, 0, NULL, NULL, smiley); |
|
24587
16c4d6e6e192
Don't try to remove GtkIMHtmlSmileys from smiley trees if the GtkIMHtml
Marcus Lundblad <malu@pidgin.im>
parents:
24569
diff
changeset
|
2074 | smiley->imhtml = NULL; |
|
24392
51b7f65a712d
Clean up the GtkSmileyTrees on active GtkIMHtml instances when a custom smiley
Marcus Lundblad <malu@pidgin.im>
parents:
24328
diff
changeset
|
2075 | } |
|
51b7f65a712d
Clean up the GtkSmileyTrees on active GtkIMHtml instances when a custom smiley
Marcus Lundblad <malu@pidgin.im>
parents:
24328
diff
changeset
|
2076 | } |
|
51b7f65a712d
Clean up the GtkSmileyTrees on active GtkIMHtml instances when a custom smiley
Marcus Lundblad <malu@pidgin.im>
parents:
24328
diff
changeset
|
2077 | |
| 4032 | 2078 | void |
| 4263 | 2079 | gtk_imhtml_associate_smiley (GtkIMHtml *imhtml, |
|
10537
9ece7671fa62
[gaim-migrate @ 11890]
Mark Doliner <markdoliner@pidgin.im>
parents:
10526
diff
changeset
|
2080 | const gchar *sml, |
| 4263 | 2081 | GtkIMHtmlSmiley *smiley) |
| 4032 | 2082 | { |
| 2083 | GtkSmileyTree *tree; | |
| 2084 | g_return_if_fail (imhtml != NULL); | |
| 2085 | g_return_if_fail (GTK_IS_IMHTML (imhtml)); | |
| 7371 | 2086 | |
| 4032 | 2087 | if (sml == NULL) |
| 2088 | tree = imhtml->default_smilies; | |
|
12833
1f461f275b90
[gaim-migrate @ 15181]
Richard Laager <rlaager@pidgin.im>
parents:
12796
diff
changeset
|
2089 | else if (!(tree = g_hash_table_lookup(imhtml->smiley_data, sml))) { |
| 4032 | 2090 | tree = gtk_smiley_tree_new(); |
| 4892 | 2091 | g_hash_table_insert(imhtml->smiley_data, g_strdup(sml), tree); |
| 4032 | 2092 | } |
| 2093 | ||
|
24588
b2c89babe134
Remove that hack involving GtkIMHtmlSmileys
Marcus Lundblad <malu@pidgin.im>
parents:
24587
diff
changeset
|
2094 | /* need to disconnect old imhtml, if there is one */ |
|
b2c89babe134
Remove that hack involving GtkIMHtmlSmileys
Marcus Lundblad <malu@pidgin.im>
parents:
24587
diff
changeset
|
2095 | if (smiley->imhtml) { |
|
b2c89babe134
Remove that hack involving GtkIMHtmlSmileys
Marcus Lundblad <malu@pidgin.im>
parents:
24587
diff
changeset
|
2096 | g_signal_handlers_disconnect_matched(smiley->imhtml, G_SIGNAL_MATCH_DATA, |
|
b2c89babe134
Remove that hack involving GtkIMHtmlSmileys
Marcus Lundblad <malu@pidgin.im>
parents:
24587
diff
changeset
|
2097 | 0, 0, NULL, NULL, smiley); |
|
b2c89babe134
Remove that hack involving GtkIMHtmlSmileys
Marcus Lundblad <malu@pidgin.im>
parents:
24587
diff
changeset
|
2098 | } |
|
b2c89babe134
Remove that hack involving GtkIMHtmlSmileys
Marcus Lundblad <malu@pidgin.im>
parents:
24587
diff
changeset
|
2099 | |
| 12335 | 2100 | smiley->imhtml = imhtml; |
| 2101 | ||
| 4263 | 2102 | gtk_smiley_tree_insert (tree, smiley); |
|
24588
b2c89babe134
Remove that hack involving GtkIMHtmlSmileys
Marcus Lundblad <malu@pidgin.im>
parents:
24587
diff
changeset
|
2103 | |
|
b2c89babe134
Remove that hack involving GtkIMHtmlSmileys
Marcus Lundblad <malu@pidgin.im>
parents:
24587
diff
changeset
|
2104 | /* connect destroy signal for the imhtml */ |
|
b2c89babe134
Remove that hack involving GtkIMHtmlSmileys
Marcus Lundblad <malu@pidgin.im>
parents:
24587
diff
changeset
|
2105 | g_signal_connect(imhtml, "destroy", G_CALLBACK(gtk_imhtml_disconnect_smiley), |
|
b2c89babe134
Remove that hack involving GtkIMHtmlSmileys
Marcus Lundblad <malu@pidgin.im>
parents:
24587
diff
changeset
|
2106 | smiley); |
| 4032 | 2107 | } |
| 2108 | ||
| 2109 | static gboolean | |
| 2110 | gtk_imhtml_is_smiley (GtkIMHtml *imhtml, | |
| 2111 | GSList *fonts, | |
| 2112 | const gchar *text, | |
| 2113 | gint *len) | |
| 2114 | { | |
| 2115 | GtkSmileyTree *tree; | |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
2116 | GtkIMHtmlFontDetail *font; |
| 4032 | 2117 | char *sml = NULL; |
| 2118 | ||
| 2119 | if (fonts) { | |
| 2120 | font = fonts->data; | |
| 2121 | sml = font->sml; | |
| 2122 | } | |
| 2123 | ||
| 9029 | 2124 | if (!sml) |
| 2125 | sml = imhtml->protocol_name; | |
| 2126 | ||
| 2127 | if (!sml || !(tree = g_hash_table_lookup(imhtml->smiley_data, sml))) | |
| 4032 | 2128 | tree = imhtml->default_smilies; |
| 9029 | 2129 | |
| 4032 | 2130 | if (tree == NULL) |
| 2131 | return FALSE; | |
| 7371 | 2132 | |
| 8505 | 2133 | *len = gtk_smiley_tree_lookup (tree, text); |
| 4032 | 2134 | return (*len > 0); |
| 2135 | } | |
| 2136 | ||
| 10526 | 2137 | GtkIMHtmlSmiley * |
| 2138 | gtk_imhtml_smiley_get(GtkIMHtml *imhtml, | |
| 2139 | const gchar *sml, | |
| 2140 | const gchar *text) | |
| 4032 | 2141 | { |
| 2142 | GtkSmileyTree *t; | |
| 2143 | const gchar *x = text; | |
| 2144 | if (sml == NULL) | |
| 2145 | t = imhtml->default_smilies; | |
| 7371 | 2146 | else |
| 4032 | 2147 | t = g_hash_table_lookup(imhtml->smiley_data, sml); |
| 7371 | 2148 | |
| 4032 | 2149 | |
| 2150 | if (t == NULL) | |
| 10526 | 2151 | return sml ? gtk_imhtml_smiley_get(imhtml, NULL, text) : NULL; |
| 4032 | 2152 | |
| 2153 | while (*x) { | |
| 2154 | gchar *pos; | |
| 2155 | ||
| 2156 | if (!t->values) { | |
| 10526 | 2157 | return sml ? gtk_imhtml_smiley_get(imhtml, NULL, text) : NULL; |
| 4032 | 2158 | } |
| 7371 | 2159 | |
| 4032 | 2160 | pos = strchr (t->values->str, *x); |
| 2161 | if (pos) { | |
| 7371 | 2162 | t = t->children [GPOINTER_TO_INT(pos) - GPOINTER_TO_INT(t->values->str)]; |
| 4032 | 2163 | } else { |
| 10526 | 2164 | return sml ? gtk_imhtml_smiley_get(imhtml, NULL, text) : NULL; |
| 4032 | 2165 | } |
| 2166 | x++; | |
| 2167 | } | |
| 2168 | ||
| 10526 | 2169 | return t->image; |
| 2170 | } | |
| 2171 | ||
|
11677
89c2ab8d2ebf
[gaim-migrate @ 13963]
Mark Doliner <markdoliner@pidgin.im>
parents:
11586
diff
changeset
|
2172 | 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
|
2173 | gtk_smiley_get_image(GtkIMHtmlSmiley *smiley) |
| 10526 | 2174 | { |
| 2175 | if (!smiley->icon && smiley->file) { | |
| 2176 | smiley->icon = gdk_pixbuf_animation_new_from_file(smiley->file, NULL); | |
| 2177 | } else if (!smiley->icon && smiley->loader) { | |
| 2178 | smiley->icon = gdk_pixbuf_loader_get_animation(smiley->loader); | |
| 2179 | if (smiley->icon) | |
| 2180 | g_object_ref(G_OBJECT(smiley->icon)); | |
| 2181 | } | |
|
11572
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
2182 | |
| 10526 | 2183 | return smiley->icon; |
| 4032 | 2184 | } |
| 8890 | 2185 | |
|
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
|
2186 | 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
|
2187 | 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
|
2188 | 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
|
2189 | 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
|
2190 | { |
|
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
|
2191 | 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
|
2192 | |
|
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
|
2193 | 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
|
2194 | |
|
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
|
2195 | 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
|
2196 | 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
|
2197 | |
|
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
|
2198 | 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
|
2199 | } |
|
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
|
2200 | |
| 4793 | 2201 | #define VALID_TAG(x) if (!g_ascii_strncasecmp (string, x ">", strlen (x ">"))) { \ |
| 3922 | 2202 | *tag = g_strndup (string, strlen (x)); \ |
| 2203 | *len = strlen (x) + 1; \ | |
| 2204 | return TRUE; \ | |
| 2205 | } \ | |
| 2206 | (*type)++ | |
| 1428 | 2207 | |
| 4793 | 2208 | #define VALID_OPT_TAG(x) if (!g_ascii_strncasecmp (string, x " ", strlen (x " "))) { \ |
| 3922 | 2209 | const gchar *c = string + strlen (x " "); \ |
| 2210 | gchar e = '"'; \ | |
| 2211 | gboolean quote = FALSE; \ | |
| 2212 | while (*c) { \ | |
| 2213 | if (*c == '"' || *c == '\'') { \ | |
| 2214 | if (quote && (*c == e)) \ | |
| 2215 | quote = !quote; \ | |
| 2216 | else if (!quote) { \ | |
| 2217 | quote = !quote; \ | |
| 2218 | e = *c; \ | |
| 2219 | } \ | |
| 2220 | } else if (!quote && (*c == '>')) \ | |
| 2221 | break; \ | |
| 2222 | c++; \ | |
| 2223 | } \ | |
| 2224 | if (*c) { \ | |
| 2225 | *tag = g_strndup (string, c - string); \ | |
| 2226 | *len = c - string + 1; \ | |
| 2227 | return TRUE; \ | |
| 2228 | } \ | |
| 2229 | } \ | |
| 2230 | (*type)++ | |
| 1428 | 2231 | |
| 2232 | ||
|
1472
ce83d12b7df9
[gaim-migrate @ 1482]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
1463
diff
changeset
|
2233 | static gboolean |
|
2856
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2234 | gtk_imhtml_is_tag (const gchar *string, |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2235 | gchar **tag, |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2236 | gint *len, |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2237 | gint *type) |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2238 | { |
| 8061 | 2239 | char *close; |
|
2856
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2240 | *type = 1; |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2241 | |
|
8118
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
2242 | |
| 8061 | 2243 | if (!(close = strchr (string, '>'))) |
|
2856
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2244 | return FALSE; |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2245 | |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2246 | VALID_TAG ("B"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2247 | VALID_TAG ("BOLD"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2248 | VALID_TAG ("/B"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2249 | VALID_TAG ("/BOLD"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2250 | VALID_TAG ("I"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2251 | VALID_TAG ("ITALIC"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2252 | VALID_TAG ("/I"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2253 | VALID_TAG ("/ITALIC"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2254 | VALID_TAG ("U"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2255 | VALID_TAG ("UNDERLINE"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2256 | VALID_TAG ("/U"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2257 | VALID_TAG ("/UNDERLINE"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2258 | VALID_TAG ("S"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2259 | VALID_TAG ("STRIKE"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2260 | VALID_TAG ("/S"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2261 | VALID_TAG ("/STRIKE"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2262 | VALID_TAG ("SUB"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2263 | VALID_TAG ("/SUB"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2264 | VALID_TAG ("SUP"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2265 | VALID_TAG ("/SUP"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2266 | VALID_TAG ("PRE"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2267 | VALID_TAG ("/PRE"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2268 | VALID_TAG ("TITLE"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2269 | VALID_TAG ("/TITLE"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2270 | VALID_TAG ("BR"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2271 | VALID_TAG ("HR"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2272 | VALID_TAG ("/FONT"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2273 | VALID_TAG ("/A"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2274 | VALID_TAG ("P"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2275 | VALID_TAG ("/P"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2276 | VALID_TAG ("H3"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2277 | VALID_TAG ("/H3"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2278 | VALID_TAG ("HTML"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2279 | VALID_TAG ("/HTML"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2280 | VALID_TAG ("BODY"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2281 | VALID_TAG ("/BODY"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2282 | VALID_TAG ("FONT"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2283 | VALID_TAG ("HEAD"); |
| 2993 | 2284 | VALID_TAG ("/HEAD"); |
| 2285 | VALID_TAG ("BINARY"); | |
| 2286 | VALID_TAG ("/BINARY"); | |
| 5093 | 2287 | |
|
2856
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2288 | VALID_OPT_TAG ("HR"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2289 | VALID_OPT_TAG ("FONT"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2290 | VALID_OPT_TAG ("BODY"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2291 | VALID_OPT_TAG ("A"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2292 | VALID_OPT_TAG ("IMG"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2293 | VALID_OPT_TAG ("P"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2294 | VALID_OPT_TAG ("H3"); |
| 5093 | 2295 | VALID_OPT_TAG ("HTML"); |
|
2856
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2296 | |
| 5101 | 2297 | VALID_TAG ("CITE"); |
| 2298 | VALID_TAG ("/CITE"); | |
| 2299 | VALID_TAG ("EM"); | |
| 2300 | VALID_TAG ("/EM"); | |
| 2301 | VALID_TAG ("STRONG"); | |
| 2302 | VALID_TAG ("/STRONG"); | |
| 2303 | ||
| 5104 | 2304 | VALID_OPT_TAG ("SPAN"); |
| 2305 | VALID_TAG ("/SPAN"); | |
| 5174 | 2306 | VALID_TAG ("BR/"); /* hack until gtkimhtml handles things better */ |
|
6982
12f08de92674
[gaim-migrate @ 7538]
Mark Doliner <markdoliner@pidgin.im>
parents:
6882
diff
changeset
|
2307 | VALID_TAG ("IMG"); |
| 8026 | 2308 | VALID_TAG("SPAN"); |
| 8061 | 2309 | VALID_OPT_TAG("BR"); |
| 7988 | 2310 | |
| 4793 | 2311 | if (!g_ascii_strncasecmp(string, "!--", strlen ("!--"))) { |
|
2954
fc07d855731d
[gaim-migrate @ 2967]
Christian Hammond <chipx86@chipx86.com>
parents:
2898
diff
changeset
|
2312 | gchar *e = strstr (string + strlen("!--"), "-->"); |
|
2856
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2313 | if (e) { |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2314 | *len = e - string + strlen ("-->"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2315 | *tag = g_strndup (string + strlen ("!--"), *len - strlen ("!---->")); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2316 | return TRUE; |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2317 | } |
|
8118
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
2318 | } |
|
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
2319 | |
| 8061 | 2320 | *type = -1; |
|
19733
ec657d978c5a
disapproval of revision 'f08436883bb16f29affdc63e9fd86ff278ed368f'
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
19732
diff
changeset
|
2321 | *len = close - string + 1; |
|
ec657d978c5a
disapproval of revision 'f08436883bb16f29affdc63e9fd86ff278ed368f'
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
19732
diff
changeset
|
2322 | *tag = g_strndup(string, *len - 1); |
|
ec657d978c5a
disapproval of revision 'f08436883bb16f29affdc63e9fd86ff278ed368f'
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
19732
diff
changeset
|
2323 | return TRUE; |
|
2856
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2324 | } |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2325 | |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2326 | static gchar* |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2327 | gtk_imhtml_get_html_opt (gchar *tag, |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2328 | const gchar *opt) |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2329 | { |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2330 | gchar *t = tag; |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2331 | gchar *e, *a; |
| 5177 | 2332 | gchar *val; |
| 2333 | gint len; | |
|
16143
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
2334 | const gchar *c; |
| 5177 | 2335 | GString *ret; |
|
2856
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2336 | |
| 4793 | 2337 | while (g_ascii_strncasecmp (t, opt, strlen (opt))) { |
|
2856
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2338 | gboolean quote = FALSE; |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2339 | if (*t == '\0') break; |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2340 | while (*t && !((*t == ' ') && !quote)) { |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2341 | if (*t == '\"') |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2342 | quote = ! quote; |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2343 | t++; |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2344 | } |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2345 | while (*t && (*t == ' ')) t++; |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2346 | } |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2347 | |
| 4793 | 2348 | if (!g_ascii_strncasecmp (t, opt, strlen (opt))) { |
|
2856
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2349 | t += strlen (opt); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2350 | } else { |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2351 | return NULL; |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2352 | } |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2353 | |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2354 | if ((*t == '\"') || (*t == '\'')) { |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2355 | e = a = ++t; |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2356 | while (*e && (*e != *(t - 1))) e++; |
| 2993 | 2357 | if (*e == '\0') { |
|
2856
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2358 | return NULL; |
| 5177 | 2359 | } else |
| 2360 | val = g_strndup(a, e - a); | |
|
2856
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2361 | } else { |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2362 | e = a = t; |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2363 | while (*e && !isspace ((gint) *e)) e++; |
| 5177 | 2364 | val = g_strndup(a, e - a); |
|
2856
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2365 | } |
| 5177 | 2366 | |
| 2367 | ret = g_string_new(""); | |
| 2368 | e = val; | |
| 2369 | while(*e) { | |
| 16144 | 2370 | if((c = purple_markup_unescape_entity(e, &len))) { |
| 7280 | 2371 | ret = g_string_append(ret, c); |
| 5177 | 2372 | e += len; |
| 2373 | } else { | |
|
19325
4ae1add93886
Thanks sadrul. Fixes #2277
Sean Egan <seanegan@pidgin.im>
parents:
19103
diff
changeset
|
2374 | gunichar uni = g_utf8_get_char(e); |
|
4ae1add93886
Thanks sadrul. Fixes #2277
Sean Egan <seanegan@pidgin.im>
parents:
19103
diff
changeset
|
2375 | ret = g_string_append_unichar(ret, uni); |
|
4ae1add93886
Thanks sadrul. Fixes #2277
Sean Egan <seanegan@pidgin.im>
parents:
19103
diff
changeset
|
2376 | e = g_utf8_next_char(e); |
| 5177 | 2377 | } |
| 2378 | } | |
| 2379 | ||
| 2380 | g_free(val); | |
|
8568
66907b37ce85
[gaim-migrate @ 9316]
Mark Doliner <markdoliner@pidgin.im>
parents:
8566
diff
changeset
|
2381 | |
|
66907b37ce85
[gaim-migrate @ 9316]
Mark Doliner <markdoliner@pidgin.im>
parents:
8566
diff
changeset
|
2382 | return g_string_free(ret, FALSE); |
|
2856
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2383 | } |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2384 | |
| 8334 | 2385 | static const char *accepted_protocols[] = { |
| 2386 | "http://", | |
| 2387 | "https://", | |
| 2388 | "ftp://" | |
| 2389 | }; | |
|
11572
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
2390 | |
| 8334 | 2391 | static const int accepted_protocols_size = 3; |
| 2392 | ||
| 2393 | /* returns if the beginning of the text is a protocol. If it is the protocol, returns the length so | |
| 2394 | the caller knows how long the protocol string is. */ | |
|
12412
8abe3226695e
[gaim-migrate @ 14719]
Richard Laager <rlaager@pidgin.im>
parents:
12335
diff
changeset
|
2395 | static int gtk_imhtml_is_protocol(const char *text) |
| 8334 | 2396 | { |
| 2397 | gint i; | |
| 2398 | ||
| 2399 | 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
|
2400 | if( g_ascii_strncasecmp(text, accepted_protocols[i], strlen(accepted_protocols[i])) == 0 ){ |
| 8334 | 2401 | return strlen(accepted_protocols[i]); |
| 2402 | } | |
| 2403 | } | |
| 2404 | return 0; | |
| 2405 | } | |
| 2406 | ||
| 8677 | 2407 | /* |
| 15884 | 2408 | <KingAnt> marv: The two IM image functions in oscar are purple_odc_send_im and purple_odc_incoming |
| 8677 | 2409 | |
| 2410 | ||
| 2411 | [19:58] <Robot101> marv: images go into the imgstore, a refcounted... well.. hash. :) | |
| 2412 | [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
|
2413 | [19:59] Ro0tSiEgE robert42 RobFlynn Robot101 ross22 roz |
| 15884 | 2414 | [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 | 2415 | [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? |
| 2416 | [20:00] <KingAnt> marv: Right | |
| 2417 | [20:00] <marv> alright | |
| 2418 | ||
| 2419 | Here's my plan with IMImages. make gtk_imhtml_[append|insert]_text_with_images instead just | |
| 2420 | gtkimhtml_[append|insert]_text (hrm maybe it should be called html instead of text), add a | |
| 15884 | 2421 | function for purple to register for look up images, i.e. gtk_imhtml_set_get_img_fnc, so that |
| 8677 | 2422 | images can be looked up like that, instead of passing a GSList of them. |
| 2423 | */ | |
| 2424 | ||
| 2425 | void gtk_imhtml_append_text_with_images (GtkIMHtml *imhtml, | |
| 2426 | const gchar *text, | |
| 2427 | GtkIMHtmlOptions options, | |
| 2428 | GSList *unused) | |
| 1428 | 2429 | { |
| 8677 | 2430 | GtkTextIter iter, ins, sel; |
|
22803
e1f64090d32e
Do not show tooltips for <HR> or <IMG>s in gtkimhtml. Fixes #5480.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22772
diff
changeset
|
2431 | int ins_offset = 0, sel_offset = 0; |
| 8677 | 2432 | gboolean fixins = FALSE, fixsel = FALSE; |
| 2433 | ||
| 2434 | g_return_if_fail (imhtml != NULL); | |
| 2435 | g_return_if_fail (GTK_IS_IMHTML (imhtml)); | |
| 2436 | g_return_if_fail (text != NULL); | |
| 2437 | ||
| 2438 | ||
| 2439 | gtk_text_buffer_get_end_iter(imhtml->text_buffer, &iter); | |
| 2440 | gtk_text_buffer_get_iter_at_mark(imhtml->text_buffer, &ins, gtk_text_buffer_get_insert(imhtml->text_buffer)); | |
| 2441 | if (gtk_text_iter_equal(&iter, &ins) && gtk_text_buffer_get_selection_bounds(imhtml->text_buffer, NULL, NULL)) { | |
| 2442 | fixins = TRUE; | |
| 2443 | ins_offset = gtk_text_iter_get_offset(&ins); | |
| 2444 | } | |
| 2445 | ||
| 2446 | gtk_text_buffer_get_iter_at_mark(imhtml->text_buffer, &sel, gtk_text_buffer_get_selection_bound(imhtml->text_buffer)); | |
| 2447 | if (gtk_text_iter_equal(&iter, &sel) && gtk_text_buffer_get_selection_bounds(imhtml->text_buffer, NULL, NULL)) { | |
| 2448 | fixsel = TRUE; | |
| 2449 | sel_offset = gtk_text_iter_get_offset(&sel); | |
| 2450 | } | |
| 2451 | ||
|
22803
e1f64090d32e
Do not show tooltips for <HR> or <IMG>s in gtkimhtml. Fixes #5480.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22772
diff
changeset
|
2452 | if (!(options & GTK_IMHTML_NO_SCROLL)) { |
|
e1f64090d32e
Do not show tooltips for <HR> or <IMG>s in gtkimhtml. Fixes #5480.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22772
diff
changeset
|
2453 | GdkRectangle rect; |
|
e1f64090d32e
Do not show tooltips for <HR> or <IMG>s in gtkimhtml. Fixes #5480.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22772
diff
changeset
|
2454 | int y, height; |
|
e1f64090d32e
Do not show tooltips for <HR> or <IMG>s in gtkimhtml. Fixes #5480.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22772
diff
changeset
|
2455 | |
|
e1f64090d32e
Do not show tooltips for <HR> or <IMG>s in gtkimhtml. Fixes #5480.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22772
diff
changeset
|
2456 | gtk_text_view_get_visible_rect(GTK_TEXT_VIEW(imhtml), &rect); |
|
e1f64090d32e
Do not show tooltips for <HR> or <IMG>s in gtkimhtml. Fixes #5480.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22772
diff
changeset
|
2457 | gtk_text_view_get_line_yrange(GTK_TEXT_VIEW(imhtml), &iter, &y, &height); |
|
e1f64090d32e
Do not show tooltips for <HR> or <IMG>s in gtkimhtml. Fixes #5480.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22772
diff
changeset
|
2458 | |
|
e1f64090d32e
Do not show tooltips for <HR> or <IMG>s in gtkimhtml. Fixes #5480.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22772
diff
changeset
|
2459 | if (((y + height) - (rect.y + rect.height)) > height && |
|
e1f64090d32e
Do not show tooltips for <HR> or <IMG>s in gtkimhtml. Fixes #5480.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22772
diff
changeset
|
2460 | gtk_text_buffer_get_char_count(imhtml->text_buffer)) { |
|
e1f64090d32e
Do not show tooltips for <HR> or <IMG>s in gtkimhtml. Fixes #5480.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22772
diff
changeset
|
2461 | options |= GTK_IMHTML_NO_SCROLL; |
|
e1f64090d32e
Do not show tooltips for <HR> or <IMG>s in gtkimhtml. Fixes #5480.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22772
diff
changeset
|
2462 | } |
| 8677 | 2463 | } |
| 2464 | ||
| 2465 | gtk_imhtml_insert_html_at_iter(imhtml, text, options, &iter); | |
| 2466 | ||
| 2467 | if (fixins) { | |
| 2468 | gtk_text_buffer_get_iter_at_offset(imhtml->text_buffer, &ins, ins_offset); | |
| 2469 | gtk_text_buffer_move_mark(imhtml->text_buffer, gtk_text_buffer_get_insert(imhtml->text_buffer), &ins); | |
| 2470 | } | |
| 2471 | ||
| 2472 | if (fixsel) { | |
| 2473 | gtk_text_buffer_get_iter_at_offset(imhtml->text_buffer, &sel, sel_offset); | |
| 2474 | gtk_text_buffer_move_mark(imhtml->text_buffer, gtk_text_buffer_get_selection_bound(imhtml->text_buffer), &sel); | |
| 2475 | } | |
| 2476 | ||
| 2477 | if (!(options & GTK_IMHTML_NO_SCROLL)) { | |
| 12553 | 2478 | gtk_imhtml_scroll_to_end(imhtml, (options & GTK_IMHTML_USE_SMOOTHSCROLLING)); |
| 8677 | 2479 | } |
| 2480 | } | |
| 2481 | ||
| 11006 | 2482 | #define MAX_SCROLL_TIME 0.4 /* seconds */ |
| 2483 | #define SCROLL_DELAY 33 /* milliseconds */ | |
| 2484 | ||
| 2485 | /* | |
| 2486 | * Smoothly scroll a GtkIMHtml. | |
| 2487 | * | |
| 2488 | * @return TRUE if the window needs to be scrolled further, FALSE if we're at the bottom. | |
| 2489 | */ | |
|
10871
c0282a4f2250
[gaim-migrate @ 12558]
Mark Doliner <markdoliner@pidgin.im>
parents:
10865
diff
changeset
|
2490 | static gboolean scroll_cb(gpointer data) |
| 10798 | 2491 | { |
| 2492 | GtkIMHtml *imhtml = data; | |
| 2493 | GtkAdjustment *adj = GTK_TEXT_VIEW(imhtml)->vadjustment; | |
| 11006 | 2494 | gdouble max_val = adj->upper - adj->page_size; |
|
19055
43f5771c45f4
Eliminate some unnecessary scrolling activity.
Daniel Atallah <datallah@pidgin.im>
parents:
18985
diff
changeset
|
2495 | gdouble scroll_val = gtk_adjustment_get_value(adj) + ((max_val - gtk_adjustment_get_value(adj)) / 3); |
| 11006 | 2496 | |
| 2497 | g_return_val_if_fail(imhtml->scroll_time != NULL, FALSE); | |
| 2498 | ||
|
19055
43f5771c45f4
Eliminate some unnecessary scrolling activity.
Daniel Atallah <datallah@pidgin.im>
parents:
18985
diff
changeset
|
2499 | if (g_timer_elapsed(imhtml->scroll_time, NULL) > MAX_SCROLL_TIME || scroll_val >= max_val) { |
| 11006 | 2500 | /* time's up. jump to the end and kill the timer */ |
| 2501 | gtk_adjustment_set_value(adj, max_val); | |
| 10798 | 2502 | g_timer_destroy(imhtml->scroll_time); |
| 2503 | imhtml->scroll_time = NULL; | |
| 2504 | return FALSE; | |
| 11006 | 2505 | } |
| 2506 | ||
| 2507 | /* scroll by 1/3rd the remaining distance */ | |
|
19055
43f5771c45f4
Eliminate some unnecessary scrolling activity.
Daniel Atallah <datallah@pidgin.im>
parents:
18985
diff
changeset
|
2508 | gtk_adjustment_set_value(adj, scroll_val); |
| 11006 | 2509 | return TRUE; |
| 10798 | 2510 | } |
| 2511 | ||
| 12553 | 2512 | static gboolean smooth_scroll_idle_cb(gpointer data) |
| 10797 | 2513 | { |
| 10798 | 2514 | GtkIMHtml *imhtml = data; |
| 11006 | 2515 | imhtml->scroll_src = g_timeout_add(SCROLL_DELAY, scroll_cb, imhtml); |
| 10797 | 2516 | return FALSE; |
| 2517 | } | |
| 2518 | ||
| 12553 | 2519 | static gboolean scroll_idle_cb(gpointer data) |
| 2520 | { | |
| 2521 | GtkIMHtml *imhtml = data; | |
| 2522 | GtkAdjustment *adj = GTK_TEXT_VIEW(imhtml)->vadjustment; | |
| 2523 | if(adj) { | |
| 2524 | gtk_adjustment_set_value(adj, adj->upper - adj->page_size); | |
| 2525 | } | |
| 2526 | imhtml->scroll_src = 0; | |
| 2527 | return FALSE; | |
| 2528 | } | |
| 2529 | ||
| 2530 | void gtk_imhtml_scroll_to_end(GtkIMHtml *imhtml, gboolean smooth) | |
| 8729 | 2531 | { |
| 10798 | 2532 | if (imhtml->scroll_time) |
| 2533 | g_timer_destroy(imhtml->scroll_time); | |
| 2534 | if (imhtml->scroll_src) | |
| 2535 | g_source_remove(imhtml->scroll_src); | |
| 12553 | 2536 | if(smooth) { |
| 2537 | imhtml->scroll_time = g_timer_new(); | |
| 2538 | imhtml->scroll_src = g_idle_add_full(G_PRIORITY_LOW, smooth_scroll_idle_cb, imhtml, NULL); | |
| 2539 | } else { | |
| 2540 | imhtml->scroll_time = NULL; | |
| 2541 | imhtml->scroll_src = g_idle_add_full(G_PRIORITY_LOW, scroll_idle_cb, imhtml, NULL); | |
| 2542 | } | |
| 8729 | 2543 | } |
| 2544 | ||
|
24509
afdf30801940
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <datallah@pidgin.im>
parents:
24392
diff
changeset
|
2545 | /* CSS colors are either rgb (x,y,z) or #hex |
|
afdf30801940
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <datallah@pidgin.im>
parents:
24392
diff
changeset
|
2546 | * we need to convert to hex if it is RGB */ |
|
afdf30801940
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <datallah@pidgin.im>
parents:
24392
diff
changeset
|
2547 | static gchar* |
|
afdf30801940
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <datallah@pidgin.im>
parents:
24392
diff
changeset
|
2548 | parse_css_color(gchar *in_color) |
|
afdf30801940
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <datallah@pidgin.im>
parents:
24392
diff
changeset
|
2549 | { |
|
afdf30801940
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <datallah@pidgin.im>
parents:
24392
diff
changeset
|
2550 | char *tmp = in_color; |
|
afdf30801940
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <datallah@pidgin.im>
parents:
24392
diff
changeset
|
2551 | |
|
24510
925061f2b31e
Make the CSS rgb() color parsing more robust. khc noted that it wouldn't work
Daniel Atallah <datallah@pidgin.im>
parents:
24509
diff
changeset
|
2552 | if (*tmp == 'r' && *(++tmp) == 'g' && *(++tmp) == 'b' && *(++tmp)) { |
|
24509
afdf30801940
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <datallah@pidgin.im>
parents:
24392
diff
changeset
|
2553 | int rgbval[] = {0, 0, 0}; |
|
afdf30801940
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <datallah@pidgin.im>
parents:
24392
diff
changeset
|
2554 | int count = 0; |
|
afdf30801940
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <datallah@pidgin.im>
parents:
24392
diff
changeset
|
2555 | const char *v_start; |
|
afdf30801940
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <datallah@pidgin.im>
parents:
24392
diff
changeset
|
2556 | |
|
24510
925061f2b31e
Make the CSS rgb() color parsing more robust. khc noted that it wouldn't work
Daniel Atallah <datallah@pidgin.im>
parents:
24509
diff
changeset
|
2557 | while (*tmp && g_ascii_isspace(*tmp)) |
|
925061f2b31e
Make the CSS rgb() color parsing more robust. khc noted that it wouldn't work
Daniel Atallah <datallah@pidgin.im>
parents:
24509
diff
changeset
|
2558 | tmp++; |
|
925061f2b31e
Make the CSS rgb() color parsing more robust. khc noted that it wouldn't work
Daniel Atallah <datallah@pidgin.im>
parents:
24509
diff
changeset
|
2559 | if (*tmp != '(') { |
|
925061f2b31e
Make the CSS rgb() color parsing more robust. khc noted that it wouldn't work
Daniel Atallah <datallah@pidgin.im>
parents:
24509
diff
changeset
|
2560 | /* We don't support rgba() */ |
|
925061f2b31e
Make the CSS rgb() color parsing more robust. khc noted that it wouldn't work
Daniel Atallah <datallah@pidgin.im>
parents:
24509
diff
changeset
|
2561 | purple_debug_warning("gtkimhtml", "Invalid rgb CSS color in '%s'!\n", in_color); |
|
925061f2b31e
Make the CSS rgb() color parsing more robust. khc noted that it wouldn't work
Daniel Atallah <datallah@pidgin.im>
parents:
24509
diff
changeset
|
2562 | return in_color; |
|
925061f2b31e
Make the CSS rgb() color parsing more robust. khc noted that it wouldn't work
Daniel Atallah <datallah@pidgin.im>
parents:
24509
diff
changeset
|
2563 | } |
|
925061f2b31e
Make the CSS rgb() color parsing more robust. khc noted that it wouldn't work
Daniel Atallah <datallah@pidgin.im>
parents:
24509
diff
changeset
|
2564 | tmp++; |
|
925061f2b31e
Make the CSS rgb() color parsing more robust. khc noted that it wouldn't work
Daniel Atallah <datallah@pidgin.im>
parents:
24509
diff
changeset
|
2565 | |
|
24509
afdf30801940
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <datallah@pidgin.im>
parents:
24392
diff
changeset
|
2566 | while (count < 3) { |
|
afdf30801940
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <datallah@pidgin.im>
parents:
24392
diff
changeset
|
2567 | /* Skip any leading spaces */ |
|
afdf30801940
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <datallah@pidgin.im>
parents:
24392
diff
changeset
|
2568 | while (*tmp && g_ascii_isspace(*tmp)) |
|
afdf30801940
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <datallah@pidgin.im>
parents:
24392
diff
changeset
|
2569 | tmp++; |
|
afdf30801940
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <datallah@pidgin.im>
parents:
24392
diff
changeset
|
2570 | |
|
afdf30801940
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <datallah@pidgin.im>
parents:
24392
diff
changeset
|
2571 | /* Find the subsequent contiguous digits */ |
|
afdf30801940
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <datallah@pidgin.im>
parents:
24392
diff
changeset
|
2572 | v_start = tmp; |
|
24510
925061f2b31e
Make the CSS rgb() color parsing more robust. khc noted that it wouldn't work
Daniel Atallah <datallah@pidgin.im>
parents:
24509
diff
changeset
|
2573 | if (*v_start == '-') |
|
925061f2b31e
Make the CSS rgb() color parsing more robust. khc noted that it wouldn't work
Daniel Atallah <datallah@pidgin.im>
parents:
24509
diff
changeset
|
2574 | tmp++; |
|
24509
afdf30801940
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <datallah@pidgin.im>
parents:
24392
diff
changeset
|
2575 | while (*tmp && g_ascii_isdigit(*tmp)) |
|
afdf30801940
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <datallah@pidgin.im>
parents:
24392
diff
changeset
|
2576 | tmp++; |
|
afdf30801940
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <datallah@pidgin.im>
parents:
24392
diff
changeset
|
2577 | |
|
afdf30801940
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <datallah@pidgin.im>
parents:
24392
diff
changeset
|
2578 | if (tmp != v_start) { |
|
afdf30801940
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <datallah@pidgin.im>
parents:
24392
diff
changeset
|
2579 | char prev = *tmp; |
|
afdf30801940
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <datallah@pidgin.im>
parents:
24392
diff
changeset
|
2580 | *tmp = '\0'; |
|
afdf30801940
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <datallah@pidgin.im>
parents:
24392
diff
changeset
|
2581 | rgbval[count] = atoi(v_start); |
|
afdf30801940
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <datallah@pidgin.im>
parents:
24392
diff
changeset
|
2582 | *tmp = prev; |
|
afdf30801940
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <datallah@pidgin.im>
parents:
24392
diff
changeset
|
2583 | |
|
afdf30801940
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <datallah@pidgin.im>
parents:
24392
diff
changeset
|
2584 | /* deal with % */ |
|
afdf30801940
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <datallah@pidgin.im>
parents:
24392
diff
changeset
|
2585 | while (*tmp && g_ascii_isspace(*tmp)) |
|
afdf30801940
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <datallah@pidgin.im>
parents:
24392
diff
changeset
|
2586 | tmp++; |
|
afdf30801940
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <datallah@pidgin.im>
parents:
24392
diff
changeset
|
2587 | if (*tmp == '%') { |
|
afdf30801940
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <datallah@pidgin.im>
parents:
24392
diff
changeset
|
2588 | rgbval[count] = (rgbval[count] / 100.0) * 255; |
|
afdf30801940
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <datallah@pidgin.im>
parents:
24392
diff
changeset
|
2589 | tmp++; |
|
afdf30801940
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <datallah@pidgin.im>
parents:
24392
diff
changeset
|
2590 | } |
|
afdf30801940
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <datallah@pidgin.im>
parents:
24392
diff
changeset
|
2591 | } else { |
|
afdf30801940
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <datallah@pidgin.im>
parents:
24392
diff
changeset
|
2592 | purple_debug_warning("gtkimhtml", "Invalid rgb CSS color in '%s'!\n", in_color); |
|
afdf30801940
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <datallah@pidgin.im>
parents:
24392
diff
changeset
|
2593 | return in_color; |
|
afdf30801940
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <datallah@pidgin.im>
parents:
24392
diff
changeset
|
2594 | } |
|
afdf30801940
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <datallah@pidgin.im>
parents:
24392
diff
changeset
|
2595 | |
|
afdf30801940
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <datallah@pidgin.im>
parents:
24392
diff
changeset
|
2596 | if (rgbval[count] > 255) { |
|
afdf30801940
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <datallah@pidgin.im>
parents:
24392
diff
changeset
|
2597 | rgbval[count] = 255; |
|
afdf30801940
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <datallah@pidgin.im>
parents:
24392
diff
changeset
|
2598 | } else if (rgbval[count] < 0) { |
|
afdf30801940
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <datallah@pidgin.im>
parents:
24392
diff
changeset
|
2599 | rgbval[count] = 0; |
|
afdf30801940
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <datallah@pidgin.im>
parents:
24392
diff
changeset
|
2600 | } |
|
afdf30801940
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <datallah@pidgin.im>
parents:
24392
diff
changeset
|
2601 | |
|
afdf30801940
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <datallah@pidgin.im>
parents:
24392
diff
changeset
|
2602 | while (*tmp && g_ascii_isspace(*tmp)) |
|
afdf30801940
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <datallah@pidgin.im>
parents:
24392
diff
changeset
|
2603 | tmp++; |
|
afdf30801940
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <datallah@pidgin.im>
parents:
24392
diff
changeset
|
2604 | if (*tmp == ',') |
|
afdf30801940
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <datallah@pidgin.im>
parents:
24392
diff
changeset
|
2605 | tmp++; |
|
afdf30801940
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <datallah@pidgin.im>
parents:
24392
diff
changeset
|
2606 | |
|
afdf30801940
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <datallah@pidgin.im>
parents:
24392
diff
changeset
|
2607 | count++; |
|
afdf30801940
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <datallah@pidgin.im>
parents:
24392
diff
changeset
|
2608 | } |
|
afdf30801940
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <datallah@pidgin.im>
parents:
24392
diff
changeset
|
2609 | |
|
afdf30801940
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <datallah@pidgin.im>
parents:
24392
diff
changeset
|
2610 | g_free(in_color); |
|
afdf30801940
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <datallah@pidgin.im>
parents:
24392
diff
changeset
|
2611 | return g_strdup_printf("#%02X%02X%02X", rgbval[0], rgbval[1], rgbval[2]); |
|
afdf30801940
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <datallah@pidgin.im>
parents:
24392
diff
changeset
|
2612 | } |
|
afdf30801940
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <datallah@pidgin.im>
parents:
24392
diff
changeset
|
2613 | |
|
afdf30801940
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <datallah@pidgin.im>
parents:
24392
diff
changeset
|
2614 | return in_color; |
|
afdf30801940
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <datallah@pidgin.im>
parents:
24392
diff
changeset
|
2615 | } |
|
afdf30801940
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <datallah@pidgin.im>
parents:
24392
diff
changeset
|
2616 | |
| 8677 | 2617 | void gtk_imhtml_insert_html_at_iter(GtkIMHtml *imhtml, |
| 2618 | const gchar *text, | |
| 2619 | GtkIMHtmlOptions options, | |
| 2620 | GtkTextIter *iter) | |
| 2621 | { | |
| 8061 | 2622 | GdkRectangle rect; |
|
2856
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2623 | gint pos = 0; |
| 3922 | 2624 | gchar *ws; |
|
2856
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2625 | gchar *tag; |
| 3922 | 2626 | gchar *bg = NULL; |
|
6982
12f08de92674
[gaim-migrate @ 7538]
Mark Doliner <markdoliner@pidgin.im>
parents:
6882
diff
changeset
|
2627 | gint len; |
| 4032 | 2628 | gint tlen, smilelen, wpos=0; |
|
2856
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2629 | gint type; |
| 3922 | 2630 | const gchar *c; |
|
16143
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
2631 | const gchar *amp; |
| 8334 | 2632 | gint len_protocol; |
| 15379 | 2633 | |
| 1428 | 2634 | guint bold = 0, |
| 2635 | italics = 0, | |
| 2636 | underline = 0, | |
| 2637 | strike = 0, | |
| 2638 | sub = 0, | |
| 2639 | sup = 0, | |
|
1691
c8bd41036372
[gaim-migrate @ 1701]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
1647
diff
changeset
|
2640 | title = 0, |
| 8061 | 2641 | pre = 0; |
| 1428 | 2642 | |
| 10217 | 2643 | gboolean br = FALSE; |
|
16143
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
2644 | gboolean align_right = FALSE; |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
2645 | gboolean rtl_direction = FALSE; |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
2646 | gint align_line = 0; |
| 15420 | 2647 | |
| 3922 | 2648 | GSList *fonts = NULL; |
| 8506 | 2649 | GObject *object; |
| 8061 | 2650 | GtkIMHtmlScalable *scalable = NULL; |
| 8677 | 2651 | |
| 2652 | g_return_if_fail (imhtml != NULL); | |
| 2653 | g_return_if_fail (GTK_IS_IMHTML (imhtml)); | |
| 2654 | g_return_if_fail (text != NULL); | |
| 3922 | 2655 | c = text; |
|
6982
12f08de92674
[gaim-migrate @ 7538]
Mark Doliner <markdoliner@pidgin.im>
parents:
6882
diff
changeset
|
2656 | len = strlen(text); |
| 3922 | 2657 | ws = g_malloc(len + 1); |
| 2658 | ws[0] = 0; | |
| 1428 | 2659 | |
|
22834
1394e7efb818
Smiley insertions can be undone with this fix. References #5577. But redo
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22810
diff
changeset
|
2660 | gtk_text_buffer_begin_user_action(imhtml->text_buffer); |
|
2856
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2661 | while (pos < len) { |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2662 | if (*c == '<' && gtk_imhtml_is_tag (c + 1, &tag, &tlen, &type)) { |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2663 | c++; |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2664 | pos++; |
| 8061 | 2665 | ws[wpos] = '\0'; |
| 10217 | 2666 | br = FALSE; |
| 8061 | 2667 | switch (type) |
| 3922 | 2668 | { |
| 2669 | case 1: /* B */ | |
| 2670 | case 2: /* BOLD */ | |
| 5101 | 2671 | case 54: /* STRONG */ |
|
11485
fe334b13d1d0
[gaim-migrate @ 13727]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11385
diff
changeset
|
2672 | if (!(options & GTK_IMHTML_NO_FORMATTING)) { |
|
fe334b13d1d0
[gaim-migrate @ 13727]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11385
diff
changeset
|
2673 | gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos); |
|
fe334b13d1d0
[gaim-migrate @ 13727]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11385
diff
changeset
|
2674 | |
|
fe334b13d1d0
[gaim-migrate @ 13727]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11385
diff
changeset
|
2675 | if ((bold == 0) && (imhtml->format_functions & GTK_IMHTML_BOLD)) |
|
fe334b13d1d0
[gaim-migrate @ 13727]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11385
diff
changeset
|
2676 | gtk_imhtml_toggle_bold(imhtml); |
|
fe334b13d1d0
[gaim-migrate @ 13727]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11385
diff
changeset
|
2677 | bold++; |
|
fe334b13d1d0
[gaim-migrate @ 13727]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11385
diff
changeset
|
2678 | ws[0] = '\0'; wpos = 0; |
|
fe334b13d1d0
[gaim-migrate @ 13727]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11385
diff
changeset
|
2679 | } |
| 3922 | 2680 | break; |
| 2681 | case 3: /* /B */ | |
| 2682 | case 4: /* /BOLD */ | |
| 5101 | 2683 | case 55: /* /STRONG */ |
|
11485
fe334b13d1d0
[gaim-migrate @ 13727]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11385
diff
changeset
|
2684 | if (!(options & GTK_IMHTML_NO_FORMATTING)) { |
|
fe334b13d1d0
[gaim-migrate @ 13727]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11385
diff
changeset
|
2685 | gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos); |
|
fe334b13d1d0
[gaim-migrate @ 13727]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11385
diff
changeset
|
2686 | ws[0] = '\0'; wpos = 0; |
|
fe334b13d1d0
[gaim-migrate @ 13727]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11385
diff
changeset
|
2687 | |
|
14010
a47143a57c82
[gaim-migrate @ 16489]
Gary Kramlich <grim@reaperworld.com>
parents:
13552
diff
changeset
|
2688 | if (bold) { |
|
11485
fe334b13d1d0
[gaim-migrate @ 13727]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11385
diff
changeset
|
2689 | bold--; |
|
14010
a47143a57c82
[gaim-migrate @ 16489]
Gary Kramlich <grim@reaperworld.com>
parents:
13552
diff
changeset
|
2690 | if ((bold == 0) && (imhtml->format_functions & GTK_IMHTML_BOLD) && !imhtml->wbfo) |
|
a47143a57c82
[gaim-migrate @ 16489]
Gary Kramlich <grim@reaperworld.com>
parents:
13552
diff
changeset
|
2691 | gtk_imhtml_toggle_bold(imhtml); |
|
a47143a57c82
[gaim-migrate @ 16489]
Gary Kramlich <grim@reaperworld.com>
parents:
13552
diff
changeset
|
2692 | } |
|
11485
fe334b13d1d0
[gaim-migrate @ 13727]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11385
diff
changeset
|
2693 | } |
| 3922 | 2694 | break; |
| 2695 | case 5: /* I */ | |
| 2696 | case 6: /* ITALIC */ | |
| 5101 | 2697 | case 52: /* EM */ |
|
11485
fe334b13d1d0
[gaim-migrate @ 13727]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11385
diff
changeset
|
2698 | if (!(options & GTK_IMHTML_NO_FORMATTING)) { |
|
fe334b13d1d0
[gaim-migrate @ 13727]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11385
diff
changeset
|
2699 | gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos); |
|
fe334b13d1d0
[gaim-migrate @ 13727]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11385
diff
changeset
|
2700 | ws[0] = '\0'; wpos = 0; |
|
fe334b13d1d0
[gaim-migrate @ 13727]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11385
diff
changeset
|
2701 | if ((italics == 0) && (imhtml->format_functions & GTK_IMHTML_ITALIC)) |
|
fe334b13d1d0
[gaim-migrate @ 13727]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11385
diff
changeset
|
2702 | gtk_imhtml_toggle_italic(imhtml); |
|
fe334b13d1d0
[gaim-migrate @ 13727]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11385
diff
changeset
|
2703 | italics++; |
|
fe334b13d1d0
[gaim-migrate @ 13727]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11385
diff
changeset
|
2704 | } |
| 3922 | 2705 | break; |
| 2706 | case 7: /* /I */ | |
| 2707 | case 8: /* /ITALIC */ | |
| 5101 | 2708 | case 53: /* /EM */ |
|
11485
fe334b13d1d0
[gaim-migrate @ 13727]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11385
diff
changeset
|
2709 | if (!(options & GTK_IMHTML_NO_FORMATTING)) { |
|
fe334b13d1d0
[gaim-migrate @ 13727]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11385
diff
changeset
|
2710 | gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos); |
|
fe334b13d1d0
[gaim-migrate @ 13727]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11385
diff
changeset
|
2711 | ws[0] = '\0'; wpos = 0; |
|
14010
a47143a57c82
[gaim-migrate @ 16489]
Gary Kramlich <grim@reaperworld.com>
parents:
13552
diff
changeset
|
2712 | if (italics) { |
|
11485
fe334b13d1d0
[gaim-migrate @ 13727]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11385
diff
changeset
|
2713 | italics--; |
|
14010
a47143a57c82
[gaim-migrate @ 16489]
Gary Kramlich <grim@reaperworld.com>
parents:
13552
diff
changeset
|
2714 | if ((italics == 0) && (imhtml->format_functions & GTK_IMHTML_ITALIC) && !imhtml->wbfo) |
|
a47143a57c82
[gaim-migrate @ 16489]
Gary Kramlich <grim@reaperworld.com>
parents:
13552
diff
changeset
|
2715 | gtk_imhtml_toggle_italic(imhtml); |
|
a47143a57c82
[gaim-migrate @ 16489]
Gary Kramlich <grim@reaperworld.com>
parents:
13552
diff
changeset
|
2716 | } |
|
11485
fe334b13d1d0
[gaim-migrate @ 13727]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11385
diff
changeset
|
2717 | } |
| 3922 | 2718 | break; |
| 2719 | case 9: /* U */ | |
| 2720 | case 10: /* UNDERLINE */ | |
|
11485
fe334b13d1d0
[gaim-migrate @ 13727]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11385
diff
changeset
|
2721 | if (!(options & GTK_IMHTML_NO_FORMATTING)) { |
|
fe334b13d1d0
[gaim-migrate @ 13727]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11385
diff
changeset
|
2722 | gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos); |
|
fe334b13d1d0
[gaim-migrate @ 13727]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11385
diff
changeset
|
2723 | ws[0] = '\0'; wpos = 0; |
|
fe334b13d1d0
[gaim-migrate @ 13727]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11385
diff
changeset
|
2724 | if ((underline == 0) && (imhtml->format_functions & GTK_IMHTML_UNDERLINE)) |
|
fe334b13d1d0
[gaim-migrate @ 13727]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11385
diff
changeset
|
2725 | gtk_imhtml_toggle_underline(imhtml); |
|
fe334b13d1d0
[gaim-migrate @ 13727]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11385
diff
changeset
|
2726 | underline++; |
|
fe334b13d1d0
[gaim-migrate @ 13727]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11385
diff
changeset
|
2727 | } |
| 3922 | 2728 | break; |
| 2729 | case 11: /* /U */ | |
| 2730 | case 12: /* /UNDERLINE */ | |
|
11485
fe334b13d1d0
[gaim-migrate @ 13727]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11385
diff
changeset
|
2731 | if (!(options & GTK_IMHTML_NO_FORMATTING)) { |
|
fe334b13d1d0
[gaim-migrate @ 13727]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11385
diff
changeset
|
2732 | gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos); |
|
fe334b13d1d0
[gaim-migrate @ 13727]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11385
diff
changeset
|
2733 | ws[0] = '\0'; wpos = 0; |
|
14010
a47143a57c82
[gaim-migrate @ 16489]
Gary Kramlich <grim@reaperworld.com>
parents:
13552
diff
changeset
|
2734 | if (underline) { |
|
11485
fe334b13d1d0
[gaim-migrate @ 13727]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11385
diff
changeset
|
2735 | underline--; |
|
14010
a47143a57c82
[gaim-migrate @ 16489]
Gary Kramlich <grim@reaperworld.com>
parents:
13552
diff
changeset
|
2736 | if ((underline == 0) && (imhtml->format_functions & GTK_IMHTML_UNDERLINE) && !imhtml->wbfo) |
|
a47143a57c82
[gaim-migrate @ 16489]
Gary Kramlich <grim@reaperworld.com>
parents:
13552
diff
changeset
|
2737 | gtk_imhtml_toggle_underline(imhtml); |
|
a47143a57c82
[gaim-migrate @ 16489]
Gary Kramlich <grim@reaperworld.com>
parents:
13552
diff
changeset
|
2738 | } |
|
11485
fe334b13d1d0
[gaim-migrate @ 13727]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11385
diff
changeset
|
2739 | } |
| 3922 | 2740 | break; |
| 2741 | case 13: /* S */ | |
| 2742 | case 14: /* STRIKE */ | |
| 9924 | 2743 | gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos); |
| 2744 | ws[0] = '\0'; wpos = 0; | |
| 2745 | if ((strike == 0) && (imhtml->format_functions & GTK_IMHTML_STRIKE)) | |
| 2746 | gtk_imhtml_toggle_strike(imhtml); | |
| 3922 | 2747 | strike++; |
| 2748 | break; | |
| 2749 | case 15: /* /S */ | |
| 2750 | case 16: /* /STRIKE */ | |
| 9924 | 2751 | gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos); |
| 2752 | ws[0] = '\0'; wpos = 0; | |
| 3922 | 2753 | if (strike) |
| 2754 | strike--; | |
| 9924 | 2755 | if ((strike == 0) && (imhtml->format_functions & GTK_IMHTML_STRIKE) && !imhtml->wbfo) |
| 2756 | gtk_imhtml_toggle_strike(imhtml); | |
| 3922 | 2757 | break; |
| 2758 | case 17: /* SUB */ | |
| 8677 | 2759 | /* FIXME: reimpliment this */ |
| 3922 | 2760 | sub++; |
| 2761 | break; | |
| 2762 | case 18: /* /SUB */ | |
| 8677 | 2763 | /* FIXME: reimpliment this */ |
| 3922 | 2764 | if (sub) |
| 2765 | sub--; | |
| 2766 | break; | |
| 2767 | case 19: /* SUP */ | |
| 8677 | 2768 | /* FIXME: reimplement this */ |
| 3922 | 2769 | sup++; |
|
2856
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2770 | break; |
| 3922 | 2771 | case 20: /* /SUP */ |
| 8677 | 2772 | /* FIXME: reimplement this */ |
| 3922 | 2773 | if (sup) |
| 2774 | sup--; | |
| 2775 | break; | |
| 2776 | case 21: /* PRE */ | |
| 8677 | 2777 | /* FIXME: reimplement this */ |
| 3922 | 2778 | pre++; |
| 2779 | break; | |
| 2780 | case 22: /* /PRE */ | |
| 8677 | 2781 | /* FIXME: reimplement this */ |
| 3922 | 2782 | if (pre) |
| 2783 | pre--; | |
| 2784 | break; | |
| 2785 | case 23: /* TITLE */ | |
| 8677 | 2786 | /* FIXME: what was this supposed to do anyway? */ |
| 3922 | 2787 | title++; |
| 2788 | break; | |
| 2789 | case 24: /* /TITLE */ | |
| 8677 | 2790 | /* FIXME: make this undo whatever 23 was supposed to do */ |
| 3922 | 2791 | if (title) { |
| 2792 | if (options & GTK_IMHTML_NO_TITLE) { | |
| 2793 | wpos = 0; | |
| 2794 | ws [wpos] = '\0'; | |
| 2795 | } | |
| 2796 | title--; | |
|
2856
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2797 | } |
| 3922 | 2798 | break; |
| 2799 | case 25: /* BR */ | |
| 5174 | 2800 | case 58: /* BR/ */ |
| 8061 | 2801 | case 61: /* BR (opt) */ |
| 3922 | 2802 | ws[wpos] = '\n'; |
| 2803 | wpos++; | |
| 10217 | 2804 | br = TRUE; |
|
6982
12f08de92674
[gaim-migrate @ 7538]
Mark Doliner <markdoliner@pidgin.im>
parents:
6882
diff
changeset
|
2805 | break; |
| 3922 | 2806 | case 26: /* HR */ |
| 2807 | case 42: /* HR (opt) */ | |
| 8726 | 2808 | { |
| 2809 | int minus; | |
|
11224
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
2810 | struct scalable_data *sd = g_new(struct scalable_data, 1); |
| 8726 | 2811 | |
| 3922 | 2812 | ws[wpos++] = '\n'; |
| 8677 | 2813 | gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos); |
| 2814 | ||
|
11224
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
2815 | sd->scalable = scalable = gtk_imhtml_hr_new(); |
|
11233
28c0f184a2d4
[gaim-migrate @ 13373]
Daniel Atallah <datallah@pidgin.im>
parents:
11224
diff
changeset
|
2816 | sd->mark = gtk_text_buffer_create_mark(imhtml->text_buffer, NULL, iter, TRUE); |
| 8061 | 2817 | gtk_text_view_get_visible_rect(GTK_TEXT_VIEW(imhtml), &rect); |
| 8677 | 2818 | scalable->add_to(scalable, imhtml, iter); |
| 8726 | 2819 | minus = gtk_text_view_get_left_margin(GTK_TEXT_VIEW(imhtml)) + |
| 2820 | gtk_text_view_get_right_margin(GTK_TEXT_VIEW(imhtml)); | |
| 2821 | scalable->scale(scalable, rect.width - minus, rect.height); | |
|
11224
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
2822 | imhtml->scalables = g_list_append(imhtml->scalables, sd); |
| 8061 | 2823 | ws[0] = '\0'; wpos = 0; |
| 7942 | 2824 | ws[wpos++] = '\n'; |
| 8061 | 2825 | |
| 3922 | 2826 | break; |
| 8726 | 2827 | } |
| 3922 | 2828 | case 27: /* /FONT */ |
| 8677 | 2829 | if (fonts && !imhtml->wbfo) { |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
2830 | GtkIMHtmlFontDetail *font = fonts->data; |
| 8677 | 2831 | gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos); |
| 8061 | 2832 | ws[0] = '\0'; wpos = 0; |
|
8177
33b3a01c6318
[gaim-migrate @ 8891]
Mark Doliner <markdoliner@pidgin.im>
parents:
8149
diff
changeset
|
2833 | /* NEW_BIT (NEW_TEXT_BIT); */ |
| 8677 | 2834 | |
| 8698 | 2835 | if (font->face && (imhtml->format_functions & GTK_IMHTML_FACE)) { |
| 8061 | 2836 | gtk_imhtml_toggle_fontface(imhtml, NULL); |
| 2837 | } | |
|
14821
c91127e2b784
[gaim-migrate @ 17516]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14741
diff
changeset
|
2838 | g_free (font->face); |
| 8698 | 2839 | if (font->fore && (imhtml->format_functions & GTK_IMHTML_FORECOLOR)) { |
| 8061 | 2840 | gtk_imhtml_toggle_forecolor(imhtml, NULL); |
| 2841 | } | |
|
14821
c91127e2b784
[gaim-migrate @ 17516]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14741
diff
changeset
|
2842 | g_free (font->fore); |
| 8698 | 2843 | if (font->back && (imhtml->format_functions & GTK_IMHTML_BACKCOLOR)) { |
| 8061 | 2844 | gtk_imhtml_toggle_backcolor(imhtml, NULL); |
| 2845 | } | |
|
14821
c91127e2b784
[gaim-migrate @ 17516]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14741
diff
changeset
|
2846 | g_free (font->back); |
|
c91127e2b784
[gaim-migrate @ 17516]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14741
diff
changeset
|
2847 | g_free (font->sml); |
| 8309 | 2848 | |
| 8698 | 2849 | if ((font->size != 3) && (imhtml->format_functions & (GTK_IMHTML_GROW|GTK_IMHTML_SHRINK))) |
| 8309 | 2850 | gtk_imhtml_font_set_size(imhtml, 3); |
| 2851 | ||
| 10761 | 2852 | fonts = g_slist_remove (fonts, font); |
| 9245 | 2853 | g_free(font); |
| 2854 | ||
| 8309 | 2855 | if (fonts) { |
| 2856 | GtkIMHtmlFontDetail *font = fonts->data; | |
| 8677 | 2857 | |
| 8698 | 2858 | if (font->face && (imhtml->format_functions & GTK_IMHTML_FACE)) |
| 8309 | 2859 | gtk_imhtml_toggle_fontface(imhtml, font->face); |
| 8698 | 2860 | if (font->fore && (imhtml->format_functions & GTK_IMHTML_FORECOLOR)) |
| 8309 | 2861 | gtk_imhtml_toggle_forecolor(imhtml, font->fore); |
| 8698 | 2862 | if (font->back && (imhtml->format_functions & GTK_IMHTML_BACKCOLOR)) |
| 8309 | 2863 | gtk_imhtml_toggle_backcolor(imhtml, font->back); |
| 8698 | 2864 | if ((font->size != 3) && (imhtml->format_functions & (GTK_IMHTML_GROW|GTK_IMHTML_SHRINK))) |
| 8309 | 2865 | gtk_imhtml_font_set_size(imhtml, font->size); |
| 2866 | } | |
| 3922 | 2867 | } |
| 8309 | 2868 | break; |
| 3922 | 2869 | case 28: /* /A */ |
| 8677 | 2870 | gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos); |
| 2871 | gtk_imhtml_toggle_link(imhtml, NULL); | |
| 2872 | ws[0] = '\0'; wpos = 0; | |
| 8061 | 2873 | break; |
|
8118
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
2874 | |
| 3922 | 2875 | case 29: /* P */ |
| 2876 | case 30: /* /P */ | |
| 2877 | case 31: /* H3 */ | |
| 2878 | case 32: /* /H3 */ | |
| 2879 | case 33: /* HTML */ | |
| 2880 | case 34: /* /HTML */ | |
| 2881 | case 35: /* BODY */ | |
| 10776 | 2882 | break; |
| 3922 | 2883 | case 36: /* /BODY */ |
| 10786 | 2884 | gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos); |
| 2885 | ws[0] = '\0'; wpos = 0; | |
| 10776 | 2886 | gtk_imhtml_toggle_background(imhtml, NULL); |
| 2887 | break; | |
| 3922 | 2888 | case 37: /* FONT */ |
| 2889 | case 38: /* HEAD */ | |
| 2890 | case 39: /* /HEAD */ | |
|
6982
12f08de92674
[gaim-migrate @ 7538]
Mark Doliner <markdoliner@pidgin.im>
parents:
6882
diff
changeset
|
2891 | case 40: /* BINARY */ |
|
12f08de92674
[gaim-migrate @ 7538]
Mark Doliner <markdoliner@pidgin.im>
parents:
6882
diff
changeset
|
2892 | case 41: /* /BINARY */ |
| 3922 | 2893 | break; |
| 2894 | case 43: /* FONT (opt) */ | |
| 2895 | { | |
| 4032 | 2896 | gchar *color, *back, *face, *size, *sml; |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
2897 | GtkIMHtmlFontDetail *font, *oldfont = NULL; |
| 3922 | 2898 | color = gtk_imhtml_get_html_opt (tag, "COLOR="); |
| 2899 | back = gtk_imhtml_get_html_opt (tag, "BACK="); | |
| 2900 | face = gtk_imhtml_get_html_opt (tag, "FACE="); | |
| 2901 | size = gtk_imhtml_get_html_opt (tag, "SIZE="); | |
| 4032 | 2902 | sml = gtk_imhtml_get_html_opt (tag, "SML="); |
| 2903 | if (!(color || back || face || size || sml)) | |
| 3922 | 2904 | break; |
| 8061 | 2905 | |
| 8677 | 2906 | gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos); |
| 8061 | 2907 | ws[0] = '\0'; wpos = 0; |
| 2908 | ||
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
2909 | font = g_new0 (GtkIMHtmlFontDetail, 1); |
| 3922 | 2910 | if (fonts) |
| 2911 | oldfont = fonts->data; | |
|
2856
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2912 | |
| 8677 | 2913 | if (color && !(options & GTK_IMHTML_NO_COLOURS) && (imhtml->format_functions & GTK_IMHTML_FORECOLOR)) { |
| 3922 | 2914 | font->fore = color; |
| 8061 | 2915 | gtk_imhtml_toggle_forecolor(imhtml, font->fore); |
|
14821
c91127e2b784
[gaim-migrate @ 17516]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14741
diff
changeset
|
2916 | } else |
|
c91127e2b784
[gaim-migrate @ 17516]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14741
diff
changeset
|
2917 | g_free(color); |
| 8677 | 2918 | |
| 2919 | if (back && !(options & GTK_IMHTML_NO_COLOURS) && (imhtml->format_functions & GTK_IMHTML_BACKCOLOR)) { | |
| 3922 | 2920 | font->back = back; |
| 8061 | 2921 | gtk_imhtml_toggle_backcolor(imhtml, font->back); |
|
14821
c91127e2b784
[gaim-migrate @ 17516]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14741
diff
changeset
|
2922 | } else |
|
c91127e2b784
[gaim-migrate @ 17516]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14741
diff
changeset
|
2923 | g_free(back); |
| 8677 | 2924 | |
| 2925 | if (face && !(options & GTK_IMHTML_NO_FONTS) && (imhtml->format_functions & GTK_IMHTML_FACE)) { | |
| 3922 | 2926 | font->face = face; |
| 8061 | 2927 | gtk_imhtml_toggle_fontface(imhtml, font->face); |
|
14821
c91127e2b784
[gaim-migrate @ 17516]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14741
diff
changeset
|
2928 | } else |
|
c91127e2b784
[gaim-migrate @ 17516]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14741
diff
changeset
|
2929 | g_free(face); |
| 4032 | 2930 | |
| 2931 | if (sml) | |
| 2932 | font->sml = sml; | |
|
22810
ede0b51be7c3
Patch from Gaul to plug a small leak, with an additional fix to free
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22803
diff
changeset
|
2933 | else { |
|
ede0b51be7c3
Patch from Gaul to plug a small leak, with an additional fix to free
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22803
diff
changeset
|
2934 | g_free(sml); |
|
ede0b51be7c3
Patch from Gaul to plug a small leak, with an additional fix to free
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22803
diff
changeset
|
2935 | if (oldfont && oldfont->sml) |
|
ede0b51be7c3
Patch from Gaul to plug a small leak, with an additional fix to free
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22803
diff
changeset
|
2936 | font->sml = g_strdup(oldfont->sml); |
|
ede0b51be7c3
Patch from Gaul to plug a small leak, with an additional fix to free
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22803
diff
changeset
|
2937 | } |
| 4032 | 2938 | |
| 8677 | 2939 | if (size && !(options & GTK_IMHTML_NO_SIZES) && (imhtml->format_functions & (GTK_IMHTML_GROW|GTK_IMHTML_SHRINK))) { |
| 3922 | 2940 | if (*size == '+') { |
| 2941 | sscanf (size + 1, "%hd", &font->size); | |
| 2942 | font->size += 3; | |
| 2943 | } else if (*size == '-') { | |
| 2944 | sscanf (size + 1, "%hd", &font->size); | |
| 2945 | font->size = MAX (0, 3 - font->size); | |
| 2946 | } else if (isdigit (*size)) { | |
| 2947 | sscanf (size, "%hd", &font->size); | |
|
14821
c91127e2b784
[gaim-migrate @ 17516]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14741
diff
changeset
|
2948 | } |
|
6042
e329fe962c9a
[gaim-migrate @ 6492]
Mark Doliner <markdoliner@pidgin.im>
parents:
5967
diff
changeset
|
2949 | if (font->size > 100) |
|
e329fe962c9a
[gaim-migrate @ 6492]
Mark Doliner <markdoliner@pidgin.im>
parents:
5967
diff
changeset
|
2950 | font->size = 100; |
| 3922 | 2951 | } else if (oldfont) |
| 2952 | font->size = oldfont->size; | |
| 8309 | 2953 | else |
| 2954 | font->size = 3; | |
| 8698 | 2955 | if ((imhtml->format_functions & (GTK_IMHTML_GROW|GTK_IMHTML_SHRINK))) |
| 2956 | gtk_imhtml_font_set_size(imhtml, font->size); | |
| 3922 | 2957 | g_free(size); |
| 2958 | fonts = g_slist_prepend (fonts, font); | |
| 2959 | } | |
| 2960 | break; | |
| 2961 | case 44: /* BODY (opt) */ | |
| 2962 | if (!(options & GTK_IMHTML_NO_COLOURS)) { | |
| 2963 | char *bgcolor = gtk_imhtml_get_html_opt (tag, "BGCOLOR="); | |
| 8677 | 2964 | if (bgcolor && (imhtml->format_functions & GTK_IMHTML_BACKCOLOR)) { |
| 2965 | gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos); | |
| 8061 | 2966 | ws[0] = '\0'; wpos = 0; |
|
8177
33b3a01c6318
[gaim-migrate @ 8891]
Mark Doliner <markdoliner@pidgin.im>
parents:
8149
diff
changeset
|
2967 | /* NEW_BIT(NEW_TEXT_BIT); */ |
|
14097
0c340861ab79
[gaim-migrate @ 16638]
Mark Doliner <markdoliner@pidgin.im>
parents:
14010
diff
changeset
|
2968 | g_free(bg); |
| 3922 | 2969 | bg = bgcolor; |
| 10776 | 2970 | gtk_imhtml_toggle_background(imhtml, bg); |
|
14821
c91127e2b784
[gaim-migrate @ 17516]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14741
diff
changeset
|
2971 | } else |
|
c91127e2b784
[gaim-migrate @ 17516]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14741
diff
changeset
|
2972 | g_free(bgcolor); |
| 1428 | 2973 | } |
|
2856
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2974 | break; |
| 3922 | 2975 | case 45: /* A (opt) */ |
| 2976 | { | |
| 2977 | gchar *href = gtk_imhtml_get_html_opt (tag, "HREF="); | |
| 8677 | 2978 | if (href && (imhtml->format_functions & GTK_IMHTML_LINK)) { |
| 2979 | gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos); | |
| 8061 | 2980 | ws[0] = '\0'; wpos = 0; |
| 8677 | 2981 | gtk_imhtml_toggle_link(imhtml, href); |
| 3922 | 2982 | } |
|
14097
0c340861ab79
[gaim-migrate @ 16638]
Mark Doliner <markdoliner@pidgin.im>
parents:
14010
diff
changeset
|
2983 | g_free(href); |
| 2993 | 2984 | } |
| 3922 | 2985 | break; |
| 4895 | 2986 | case 46: /* IMG (opt) */ |
|
6982
12f08de92674
[gaim-migrate @ 7538]
Mark Doliner <markdoliner@pidgin.im>
parents:
6882
diff
changeset
|
2987 | case 59: /* IMG */ |
| 4895 | 2988 | { |
|
22810
ede0b51be7c3
Patch from Gaul to plug a small leak, with an additional fix to free
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22803
diff
changeset
|
2989 | char *id; |
| 8962 | 2990 | |
| 2991 | gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos); | |
| 2992 | ws[0] = '\0'; wpos = 0; | |
| 4895 | 2993 | |
| 8677 | 2994 | if (!(imhtml->format_functions & GTK_IMHTML_IMAGE)) |
| 2995 | break; | |
| 2996 | ||
| 8962 | 2997 | id = gtk_imhtml_get_html_opt(tag, "ID="); |
| 9186 | 2998 | if (!id) |
| 2999 | break; | |
| 8962 | 3000 | gtk_imhtml_insert_image_at_iter(imhtml, atoi(id), iter); |
|
22810
ede0b51be7c3
Patch from Gaul to plug a small leak, with an additional fix to free
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22803
diff
changeset
|
3001 | g_free(id); |
| 8962 | 3002 | break; |
| 4895 | 3003 | } |
| 3922 | 3004 | case 47: /* P (opt) */ |
| 3005 | case 48: /* H3 (opt) */ | |
| 5093 | 3006 | case 49: /* HTML (opt) */ |
| 5101 | 3007 | case 50: /* CITE */ |
| 3008 | case 51: /* /CITE */ | |
| 8026 | 3009 | case 56: /* SPAN (opt) */ |
|
8118
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
3010 | /* Inline CSS Support - Douglas Thrift |
|
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
3011 | * |
|
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
3012 | * color |
| 8686 | 3013 | * background |
|
8118
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
3014 | * font-family |
|
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
3015 | * font-size |
| 8686 | 3016 | * text-decoration: underline |
| 14395 | 3017 | * font-weight: bold |
|
16143
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
3018 | * direction: rtl |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
3019 | * text-align: right |
| 10483 | 3020 | * |
| 3021 | * TODO: | |
| 3022 | * background-color | |
| 3023 | * font-style | |
|
8118
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
3024 | */ |
|
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
3025 | { |
|
16143
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
3026 | gchar *style, *color, *background, *family, *size, *direction, *alignment; |
| 14395 | 3027 | gchar *textdec, *weight; |
|
8118
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
3028 | GtkIMHtmlFontDetail *font, *oldfont = NULL; |
|
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
3029 | style = gtk_imhtml_get_html_opt (tag, "style="); |
|
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
3030 | |
|
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
3031 | if (!style) break; |
|
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
3032 | |
|
16143
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
3033 | color = purple_markup_get_css_property (style, "color"); |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
3034 | background = purple_markup_get_css_property (style, "background"); |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
3035 | 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
|
3036 | 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
|
3037 | 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
|
3038 | 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
|
3039 | direction = purple_markup_get_css_property (style, "direction"); |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
3040 | 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
|
3041 | |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
3042 | |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
3043 | if (!(color || family || size || background || textdec || weight || direction || alignment)) { |
| 8120 | 3044 | g_free(style); |
| 3045 | break; | |
| 3046 | } | |
|
8118
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
3047 | |
| 8677 | 3048 | |
| 3049 | gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos); | |
|
8118
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
3050 | ws[0] = '\0'; wpos = 0; |
|
8177
33b3a01c6318
[gaim-migrate @ 8891]
Mark Doliner <markdoliner@pidgin.im>
parents:
8149
diff
changeset
|
3051 | /* NEW_BIT (NEW_TEXT_BIT); */ |
|
8118
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
3052 | |
|
16143
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
3053 | /* 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
|
3054 | 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
|
3055 | rtl_direction = TRUE; |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
3056 | /* insert RLE character to set direction */ |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
3057 | ws[wpos++] = 0xE2; |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
3058 | ws[wpos++] = 0x80; |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
3059 | ws[wpos++] = 0xAB; |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
3060 | ws[wpos] = '\0'; |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
3061 | 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
|
3062 | ws[0] = '\0'; wpos = 0; |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
3063 | } |
| 16144 | 3064 | g_free(direction); |
| 3065 | ||
|
18552
810a338ef085
Use the glib strcasecmp functions everywhere, as we've had reports of
Richard Laager <rlaager@pidgin.im>
parents:
18543
diff
changeset
|
3066 | 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
|
3067 | align_right = TRUE; |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
3068 | align_line = gtk_text_iter_get_line(iter); |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
3069 | } |
| 16144 | 3070 | g_free(alignment); |
|
16143
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
3071 | |
|
8118
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
3072 | font = g_new0 (GtkIMHtmlFontDetail, 1); |
|
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
3073 | if (fonts) |
|
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
3074 | oldfont = fonts->data; |
|
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
3075 | |
|
14821
c91127e2b784
[gaim-migrate @ 17516]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14741
diff
changeset
|
3076 | if (color && !(options & GTK_IMHTML_NO_COLOURS) && (imhtml->format_functions & GTK_IMHTML_FORECOLOR)) { |
|
24509
afdf30801940
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <datallah@pidgin.im>
parents:
24392
diff
changeset
|
3077 | font->fore = parse_css_color(color); |
| 8686 | 3078 | gtk_imhtml_toggle_forecolor(imhtml, font->fore); |
|
14821
c91127e2b784
[gaim-migrate @ 17516]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14741
diff
changeset
|
3079 | } else { |
|
c91127e2b784
[gaim-migrate @ 17516]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14741
diff
changeset
|
3080 | if (oldfont && oldfont->fore) |
|
c91127e2b784
[gaim-migrate @ 17516]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14741
diff
changeset
|
3081 | font->fore = g_strdup(oldfont->fore); |
|
c91127e2b784
[gaim-migrate @ 17516]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14741
diff
changeset
|
3082 | g_free(color); |
| 8686 | 3083 | } |
|
14821
c91127e2b784
[gaim-migrate @ 17516]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14741
diff
changeset
|
3084 | |
|
c91127e2b784
[gaim-migrate @ 17516]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14741
diff
changeset
|
3085 | if (background && !(options & GTK_IMHTML_NO_COLOURS) && (imhtml->format_functions & GTK_IMHTML_BACKCOLOR)) { |
|
24509
afdf30801940
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <datallah@pidgin.im>
parents:
24392
diff
changeset
|
3086 | font->back = parse_css_color(background); |
| 8686 | 3087 | gtk_imhtml_toggle_backcolor(imhtml, font->back); |
|
14821
c91127e2b784
[gaim-migrate @ 17516]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14741
diff
changeset
|
3088 | } else { |
|
c91127e2b784
[gaim-migrate @ 17516]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14741
diff
changeset
|
3089 | if (oldfont && oldfont->back) |
|
c91127e2b784
[gaim-migrate @ 17516]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14741
diff
changeset
|
3090 | font->back = g_strdup(oldfont->back); |
|
c91127e2b784
[gaim-migrate @ 17516]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14741
diff
changeset
|
3091 | g_free(background); |
| 8686 | 3092 | } |
|
14821
c91127e2b784
[gaim-migrate @ 17516]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14741
diff
changeset
|
3093 | |
|
c91127e2b784
[gaim-migrate @ 17516]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14741
diff
changeset
|
3094 | 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
|
3095 | font->face = family; |
| 8686 | 3096 | gtk_imhtml_toggle_fontface(imhtml, font->face); |
|
14821
c91127e2b784
[gaim-migrate @ 17516]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14741
diff
changeset
|
3097 | } else { |
|
c91127e2b784
[gaim-migrate @ 17516]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14741
diff
changeset
|
3098 | if (oldfont && oldfont->face) |
|
c91127e2b784
[gaim-migrate @ 17516]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14741
diff
changeset
|
3099 | font->face = g_strdup(oldfont->face); |
|
c91127e2b784
[gaim-migrate @ 17516]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14741
diff
changeset
|
3100 | g_free(family); |
| 8686 | 3101 | } |
|
8118
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
3102 | if (font->face && (atoi(font->face) > 100)) { |
| 8677 | 3103 | /* WTF is this? */ |
|
11572
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
3104 | /* 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
|
3105 | * remember bad things happening if the font size was |
|
9696
9d62e1ec5977
[gaim-migrate @ 10555]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9636
diff
changeset
|
3106 | * 2 billion */ |
|
8118
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
3107 | g_free(font->face); |
|
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
3108 | font->face = g_strdup("100"); |
|
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
3109 | } |
|
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
3110 | |
|
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
3111 | if (oldfont && oldfont->sml) |
|
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
3112 | font->sml = g_strdup(oldfont->sml); |
|
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
3113 | |
| 8677 | 3114 | if (size && !(options & GTK_IMHTML_NO_SIZES) && (imhtml->format_functions & (GTK_IMHTML_SHRINK|GTK_IMHTML_GROW))) { |
| 8686 | 3115 | if (g_ascii_strcasecmp(size, "xx-small") == 0) |
| 3116 | font->size = 1; | |
| 3117 | else if (g_ascii_strcasecmp(size, "smaller") == 0 | |
| 3118 | || g_ascii_strcasecmp(size, "x-small") == 0) | |
|
8118
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
3119 | font->size = 2; |
|
25299
82d682722b68
Change our font mapping in gtkimhtml to match the suggested values
Mark Doliner <markdoliner@pidgin.im>
parents:
25168
diff
changeset
|
3120 | else if (g_ascii_strcasecmp(size, "medium") == 0) |
|
82d682722b68
Change our font mapping in gtkimhtml to match the suggested values
Mark Doliner <markdoliner@pidgin.im>
parents:
25168
diff
changeset
|
3121 | font->size = 3; |
|
82d682722b68
Change our font mapping in gtkimhtml to match the suggested values
Mark Doliner <markdoliner@pidgin.im>
parents:
25168
diff
changeset
|
3122 | else if (g_ascii_strcasecmp(size, "large") == 0 |
|
82d682722b68
Change our font mapping in gtkimhtml to match the suggested values
Mark Doliner <markdoliner@pidgin.im>
parents:
25168
diff
changeset
|
3123 | || g_ascii_strcasecmp(size, "larger") == 0) |
|
8118
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
3124 | font->size = 4; |
|
25299
82d682722b68
Change our font mapping in gtkimhtml to match the suggested values
Mark Doliner <markdoliner@pidgin.im>
parents:
25168
diff
changeset
|
3125 | else if (g_ascii_strcasecmp(size, "x-large") == 0) |
| 8686 | 3126 | font->size = 5; |
|
25299
82d682722b68
Change our font mapping in gtkimhtml to match the suggested values
Mark Doliner <markdoliner@pidgin.im>
parents:
25168
diff
changeset
|
3127 | else if (g_ascii_strcasecmp(size, "xx-large") == 0) |
| 8686 | 3128 | font->size = 6; |
|
25168
4f508dba5218
Change the way we handle <span style='font-size: whatever;'> tags slightly.
Mark Doliner <markdoliner@pidgin.im>
parents:
24588
diff
changeset
|
3129 | |
|
4f508dba5218
Change the way we handle <span style='font-size: whatever;'> tags slightly.
Mark Doliner <markdoliner@pidgin.im>
parents:
24588
diff
changeset
|
3130 | /* |
|
4f508dba5218
Change the way we handle <span style='font-size: whatever;'> tags slightly.
Mark Doliner <markdoliner@pidgin.im>
parents:
24588
diff
changeset
|
3131 | * TODO: Handle other values, like percentages, or |
|
4f508dba5218
Change the way we handle <span style='font-size: whatever;'> tags slightly.
Mark Doliner <markdoliner@pidgin.im>
parents:
24588
diff
changeset
|
3132 | * lengths specified as em, ex, px, in, cm, mm, pt |
|
4f508dba5218
Change the way we handle <span style='font-size: whatever;'> tags slightly.
Mark Doliner <markdoliner@pidgin.im>
parents:
24588
diff
changeset
|
3133 | * or pc. Or even better, use an actual HTML |
|
4f508dba5218
Change the way we handle <span style='font-size: whatever;'> tags slightly.
Mark Doliner <markdoliner@pidgin.im>
parents:
24588
diff
changeset
|
3134 | * renderer like webkit. |
|
4f508dba5218
Change the way we handle <span style='font-size: whatever;'> tags slightly.
Mark Doliner <markdoliner@pidgin.im>
parents:
24588
diff
changeset
|
3135 | */ |
|
4f508dba5218
Change the way we handle <span style='font-size: whatever;'> tags slightly.
Mark Doliner <markdoliner@pidgin.im>
parents:
24588
diff
changeset
|
3136 | if (font->size > 0) |
|
4f508dba5218
Change the way we handle <span style='font-size: whatever;'> tags slightly.
Mark Doliner <markdoliner@pidgin.im>
parents:
24588
diff
changeset
|
3137 | gtk_imhtml_font_set_size(imhtml, font->size); |
| 8686 | 3138 | } |
| 3139 | else if (oldfont) | |
| 3140 | { | |
| 3141 | font->size = oldfont->size; | |
| 3142 | } | |
| 3143 | ||
| 3144 | if (oldfont) | |
| 3145 | { | |
| 3146 | font->underline = oldfont->underline; | |
| 3147 | } | |
| 3148 | if (textdec && font->underline != 1 | |
| 9025 | 3149 | && 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
|
3150 | && (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
|
3151 | && !(options & GTK_IMHTML_NO_FORMATTING)) |
| 8686 | 3152 | { |
| 3153 | gtk_imhtml_toggle_underline(imhtml); | |
| 3154 | font->underline = 1; | |
| 21425 | 3155 | } |
| 3156 | g_free(textdec); | |
|
8118
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
3157 | |
| 14395 | 3158 | if (oldfont) |
| 3159 | { | |
| 3160 | font->bold = oldfont->bold; | |
| 3161 | } | |
| 3162 | if (weight) | |
| 3163 | { | |
| 3164 | if(!g_ascii_strcasecmp(weight, "normal")) { | |
| 3165 | font->bold = 0; | |
| 3166 | } else if(!g_ascii_strcasecmp(weight, "bold")) { | |
| 3167 | font->bold = 1; | |
| 3168 | } else if(!g_ascii_strcasecmp(weight, "bolder")) { | |
| 3169 | font->bold++; | |
| 3170 | } else if(!g_ascii_strcasecmp(weight, "lighter")) { | |
| 3171 | if(font->bold > 0) | |
| 3172 | font->bold--; | |
| 3173 | } else { | |
| 3174 | int num = atoi(weight); | |
| 3175 | if(num >= 700) | |
| 3176 | font->bold = 1; | |
| 3177 | else | |
| 3178 | font->bold = 0; | |
| 3179 | } | |
|
17088
1ecea6e2fd97
Ignore bold, underline and other formatting type things in SPAN tags if
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17009
diff
changeset
|
3180 | if (((font->bold && oldfont && !oldfont->bold) || (oldfont && oldfont->bold && !font->bold) || (font->bold && !oldfont)) && !(options & GTK_IMHTML_NO_FORMATTING)) |
| 14395 | 3181 | { |
| 3182 | gtk_imhtml_toggle_bold(imhtml); | |
| 3183 | } | |
|
14821
c91127e2b784
[gaim-migrate @ 17516]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14741
diff
changeset
|
3184 | g_free(weight); |
| 14395 | 3185 | } |
| 3186 | ||
|
8118
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
3187 | g_free(style); |
|
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
3188 | g_free(size); |
|
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
3189 | fonts = g_slist_prepend (fonts, font); |
|
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
3190 | } |
|
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
3191 | break; |
| 5104 | 3192 | case 57: /* /SPAN */ |
|
8118
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
3193 | /* Inline CSS Support - Douglas Thrift */ |
| 8677 | 3194 | if (fonts && !imhtml->wbfo) { |
| 8686 | 3195 | GtkIMHtmlFontDetail *oldfont = NULL; |
|
8118
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
3196 | GtkIMHtmlFontDetail *font = fonts->data; |
| 8677 | 3197 | gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos); |
|
8118
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
3198 | ws[0] = '\0'; wpos = 0; |
|
8177
33b3a01c6318
[gaim-migrate @ 8891]
Mark Doliner <markdoliner@pidgin.im>
parents:
8149
diff
changeset
|
3199 | /* NEW_BIT (NEW_TEXT_BIT); */ |
|
8118
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
3200 | fonts = g_slist_remove (fonts, font); |
| 8692 | 3201 | if (fonts) |
| 3202 | oldfont = fonts->data; | |
| 3203 | ||
| 3204 | if (!oldfont) { | |
| 3205 | 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
|
3206 | if (font->underline && !(options & GTK_IMHTML_NO_FORMATTING)) |
| 8692 | 3207 | 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
|
3208 | if (font->bold && !(options & GTK_IMHTML_NO_FORMATTING)) |
| 14395 | 3209 | 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
|
3210 | 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
|
3211 | 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
|
3212 | 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
|
3213 | 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
|
3214 | 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
|
3215 | gtk_imhtml_toggle_backcolor(imhtml, NULL); |
| 8686 | 3216 | } |
| 8692 | 3217 | else |
| 8686 | 3218 | { |
| 8692 | 3219 | |
|
17088
1ecea6e2fd97
Ignore bold, underline and other formatting type things in SPAN tags if
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17009
diff
changeset
|
3220 | if ((font->size != oldfont->size) && !(options & GTK_IMHTML_NO_SIZES)) |
| 8692 | 3221 | gtk_imhtml_font_set_size(imhtml, oldfont->size); |
| 3222 | ||
|
17088
1ecea6e2fd97
Ignore bold, underline and other formatting type things in SPAN tags if
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17009
diff
changeset
|
3223 | if ((font->underline != oldfont->underline) && !(options & GTK_IMHTML_NO_FORMATTING)) |
| 8692 | 3224 | gtk_imhtml_toggle_underline(imhtml); |
| 3225 | ||
|
17088
1ecea6e2fd97
Ignore bold, underline and other formatting type things in SPAN tags if
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17009
diff
changeset
|
3226 | if (((font->bold && !oldfont->bold) || (oldfont->bold && !font->bold)) && !(options & GTK_IMHTML_NO_FORMATTING)) |
| 14395 | 3227 | gtk_imhtml_toggle_bold(imhtml); |
| 3228 | ||
|
17088
1ecea6e2fd97
Ignore bold, underline and other formatting type things in SPAN tags if
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17009
diff
changeset
|
3229 | if (font->face && (!oldfont->face || strcmp(font->face, oldfont->face) != 0) && !(options & GTK_IMHTML_NO_FONTS)) |
| 8692 | 3230 | gtk_imhtml_toggle_fontface(imhtml, oldfont->face); |
| 3231 | ||
|
17088
1ecea6e2fd97
Ignore bold, underline and other formatting type things in SPAN tags if
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17009
diff
changeset
|
3232 | if (font->fore && (!oldfont->fore || strcmp(font->fore, oldfont->fore) != 0) && !(options & GTK_IMHTML_NO_COLOURS)) |
| 8692 | 3233 | gtk_imhtml_toggle_forecolor(imhtml, oldfont->fore); |
| 3234 | ||
|
17088
1ecea6e2fd97
Ignore bold, underline and other formatting type things in SPAN tags if
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17009
diff
changeset
|
3235 | if (font->back && (!oldfont->back || strcmp(font->back, oldfont->back) != 0) && !(options & GTK_IMHTML_NO_COLOURS)) |
| 8692 | 3236 | gtk_imhtml_toggle_backcolor(imhtml, oldfont->back); |
| 8686 | 3237 | } |
| 8692 | 3238 | |
| 3239 | g_free (font->face); | |
| 3240 | g_free (font->fore); | |
| 3241 | g_free (font->back); | |
| 3242 | g_free (font->sml); | |
| 3243 | ||
|
8118
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
3244 | g_free (font); |
|
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
3245 | } |
|
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
3246 | break; |
| 8026 | 3247 | case 60: /* SPAN */ |
| 2993 | 3248 | break; |
| 8061 | 3249 | case 62: /* comment */ |
|
8177
33b3a01c6318
[gaim-migrate @ 8891]
Mark Doliner <markdoliner@pidgin.im>
parents:
8149
diff
changeset
|
3250 | /* NEW_BIT (NEW_TEXT_BIT); */ |
| 8317 | 3251 | ws[wpos] = '\0'; |
| 9465 | 3252 | |
| 8677 | 3253 | gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos); |
| 3254 | ||
|
22486
e77232ab761f
Disable invisible text things, if someone can conclusively prove this is
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22276
diff
changeset
|
3255 | #if FALSE && GTK_CHECK_VERSION(2,10,10) |
|
22211
7f3cecdb079c
disapproval of revision '2c96f5a301400781ce5fbf144ffdbae44f895281'
Sean Egan <seanegan@pidgin.im>
parents:
22210
diff
changeset
|
3256 | wpos = g_snprintf (ws, len, "%s", tag); |
|
7f3cecdb079c
disapproval of revision '2c96f5a301400781ce5fbf144ffdbae44f895281'
Sean Egan <seanegan@pidgin.im>
parents:
22210
diff
changeset
|
3257 | gtk_text_buffer_insert_with_tags_by_name(imhtml->text_buffer, iter, ws, wpos, "comment", NULL); |
|
7f3cecdb079c
disapproval of revision '2c96f5a301400781ce5fbf144ffdbae44f895281'
Sean Egan <seanegan@pidgin.im>
parents:
22210
diff
changeset
|
3258 | #else |
|
10815
b1ca28de65d3
[gaim-migrate @ 12470]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10814
diff
changeset
|
3259 | if (imhtml->show_comments && !(options & GTK_IMHTML_NO_COMMENTS)) { |
|
6124
322206d79652
[gaim-migrate @ 6598]
Mark Doliner <markdoliner@pidgin.im>
parents:
6066
diff
changeset
|
3260 | wpos = g_snprintf (ws, len, "%s", tag); |
|
23308
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
3261 | gtk_text_buffer_insert_with_tags_by_name(imhtml->text_buffer, iter, ws, wpos, "comment", NULL); |
|
10815
b1ca28de65d3
[gaim-migrate @ 12470]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10814
diff
changeset
|
3262 | } |
|
22211
7f3cecdb079c
disapproval of revision '2c96f5a301400781ce5fbf144ffdbae44f895281'
Sean Egan <seanegan@pidgin.im>
parents:
22210
diff
changeset
|
3263 | #endif |
|
10815
b1ca28de65d3
[gaim-migrate @ 12470]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10814
diff
changeset
|
3264 | ws[0] = '\0'; wpos = 0; |
|
b1ca28de65d3
[gaim-migrate @ 12470]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10814
diff
changeset
|
3265 | |
|
8177
33b3a01c6318
[gaim-migrate @ 8891]
Mark Doliner <markdoliner@pidgin.im>
parents:
8149
diff
changeset
|
3266 | /* NEW_BIT (NEW_COMMENT_BIT); */ |
| 3922 | 3267 | break; |
| 3268 | default: | |
| 6882 | 3269 | break; |
| 2993 | 3270 | } |
|
2856
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
3271 | c += tlen; |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
3272 | pos += tlen; |
|
13138
4d3bd039da3e
[gaim-migrate @ 15499]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13137
diff
changeset
|
3273 | 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
|
3274 | } else if (imhtml->edit.link == NULL && |
|
22003
904ebe8d6058
Patch from 'goutnet' to not insert smileys when pasting as plain text.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21765
diff
changeset
|
3275 | !(options & GTK_IMHTML_NO_SMILEY) && |
|
15331
a8ef18791524
[gaim-migrate @ 18059]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15111
diff
changeset
|
3276 | gtk_imhtml_is_smiley(imhtml, fonts, c, &smilelen)) { |
| 8473 | 3277 | GtkIMHtmlFontDetail *fd; |
| 3278 | gchar *sml = NULL; | |
|
21574
b27c242d1288
Fix #3930 by correctly detecting when we're no longer immediately following a br.
Daniel Atallah <datallah@pidgin.im>
parents:
21425
diff
changeset
|
3279 | |
|
b27c242d1288
Fix #3930 by correctly detecting when we're no longer immediately following a br.
Daniel Atallah <datallah@pidgin.im>
parents:
21425
diff
changeset
|
3280 | br = FALSE; |
|
b27c242d1288
Fix #3930 by correctly detecting when we're no longer immediately following a br.
Daniel Atallah <datallah@pidgin.im>
parents:
21425
diff
changeset
|
3281 | |
| 8473 | 3282 | if (fonts) { |
| 3283 | fd = fonts->data; | |
| 3284 | sml = fd->sml; | |
| 3285 | } | |
| 9029 | 3286 | if (!sml) |
| 3287 | sml = imhtml->protocol_name; | |
| 3288 | ||
| 8677 | 3289 | gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos); |
| 8505 | 3290 | wpos = g_snprintf (ws, smilelen + 1, "%s", c); |
| 8473 | 3291 | |
| 8677 | 3292 | gtk_imhtml_insert_smiley_at_iter(imhtml, sml, ws, iter); |
| 8473 | 3293 | |
| 8505 | 3294 | c += smilelen; |
| 3295 | pos += smilelen; | |
| 8473 | 3296 | wpos = 0; |
| 3297 | ws[0] = 0; | |
| 16144 | 3298 | } else if (*c == '&' && (amp = purple_markup_unescape_entity(c, &tlen))) { |
|
21574
b27c242d1288
Fix #3930 by correctly detecting when we're no longer immediately following a br.
Daniel Atallah <datallah@pidgin.im>
parents:
21425
diff
changeset
|
3299 | br = FALSE; |
| 7280 | 3300 | while(*amp) { |
| 3301 | ws [wpos++] = *amp++; | |
| 3302 | } | |
|
2856
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
3303 | c += tlen; |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
3304 | pos += tlen; |
| 1428 | 3305 | } else if (*c == '\n') { |
| 3306 | if (!(options & GTK_IMHTML_NO_NEWLINE)) { | |
| 3922 | 3307 | ws[wpos] = '\n'; |
| 3308 | wpos++; | |
| 8677 | 3309 | gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos); |
| 8061 | 3310 | ws[0] = '\0'; |
| 3311 | wpos = 0; | |
|
8177
33b3a01c6318
[gaim-migrate @ 8891]
Mark Doliner <markdoliner@pidgin.im>
parents:
8149
diff
changeset
|
3312 | /* NEW_BIT (NEW_TEXT_BIT); */ |
| 10217 | 3313 | } else if (!br) { /* Don't insert a space immediately after an HTML break */ |
| 9621 | 3314 | /* A newline is defined by HTML as whitespace, which means we have to replace it with a word boundary. |
| 3315 | * word breaks vary depending on the language used, so the correct thing to do is to use Pango to determine | |
| 3316 | * what language this is, determine the proper word boundary to use, and insert that. I'm just going to insert | |
| 3317 | * a space instead. What are the non-English speakers going to do? Complain in a language I'll understand? | |
| 3318 | * Bu-wahaha! */ | |
| 3319 | ws[wpos] = ' '; | |
| 3320 | wpos++; | |
| 3321 | gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos); | |
| 3322 | ws[0] = '\0'; | |
| 3323 | wpos = 0; | |
| 1428 | 3324 | } |
| 3325 | c++; | |
|
2856
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
3326 | pos++; |
| 8334 | 3327 | } else if ((len_protocol = gtk_imhtml_is_protocol(c)) > 0){ |
|
21574
b27c242d1288
Fix #3930 by correctly detecting when we're no longer immediately following a br.
Daniel Atallah <datallah@pidgin.im>
parents:
21425
diff
changeset
|
3328 | br = FALSE; |
| 8334 | 3329 | while(len_protocol--){ |
| 8677 | 3330 | /* Skip the next len_protocol characters, but make sure they're |
| 8334 | 3331 | copied into the ws array. |
| 3332 | */ | |
| 3333 | ws [wpos++] = *c++; | |
| 3334 | pos++; | |
| 3335 | } | |
| 8061 | 3336 | } else if (*c) { |
|
21574
b27c242d1288
Fix #3930 by correctly detecting when we're no longer immediately following a br.
Daniel Atallah <datallah@pidgin.im>
parents:
21425
diff
changeset
|
3337 | br = FALSE; |
| 1428 | 3338 | ws [wpos++] = *c++; |
|
2856
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
3339 | pos++; |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
3340 | } else { |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
3341 | break; |
| 1428 | 3342 | } |
| 3343 | } | |
| 8677 | 3344 | gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos); |
| 8061 | 3345 | ws[0] = '\0'; wpos = 0; |
| 3346 | ||
|
8177
33b3a01c6318
[gaim-migrate @ 8891]
Mark Doliner <markdoliner@pidgin.im>
parents:
8149
diff
changeset
|
3347 | /* NEW_BIT(NEW_TEXT_BIT); */ |
| 8061 | 3348 | |
|
16143
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
3349 | if(align_right) { |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
3350 | /* 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
|
3351 | GtkTextIter line_iter; |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
3352 | line_iter = *iter; |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
3353 | 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
|
3354 | /* insert RLM character to set alignment */ |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
3355 | ws[wpos++] = 0xE2; |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
3356 | ws[wpos++] = 0x80; |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
3357 | ws[wpos++] = 0x8F; |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
3358 | |
| 16144 | 3359 | if (!rtl_direction) |
|
16143
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
3360 | { |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
3361 | /* insert LRM character to set direction */ |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
3362 | /* (alignment=right and direction=LTR) */ |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
3363 | ws[wpos++] = 0xE2; |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
3364 | ws[wpos++] = 0x80; |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
3365 | ws[wpos++] = 0x8E; |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
3366 | } |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
3367 | |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
3368 | ws[wpos] = '\0'; |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
3369 | 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
|
3370 | 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
|
3371 | ws[0] = '\0'; |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
3372 | wpos = 0; |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
3373 | } |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
3374 | |
| 4032 | 3375 | while (fonts) { |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
3376 | GtkIMHtmlFontDetail *font = fonts->data; |
| 4032 | 3377 | fonts = g_slist_remove (fonts, font); |
|
14097
0c340861ab79
[gaim-migrate @ 16638]
Mark Doliner <markdoliner@pidgin.im>
parents:
14010
diff
changeset
|
3378 | g_free (font->face); |
|
0c340861ab79
[gaim-migrate @ 16638]
Mark Doliner <markdoliner@pidgin.im>
parents:
14010
diff
changeset
|
3379 | g_free (font->fore); |
|
0c340861ab79
[gaim-migrate @ 16638]
Mark Doliner <markdoliner@pidgin.im>
parents:
14010
diff
changeset
|
3380 | g_free (font->back); |
|
0c340861ab79
[gaim-migrate @ 16638]
Mark Doliner <markdoliner@pidgin.im>
parents:
14010
diff
changeset
|
3381 | g_free (font->sml); |
| 4032 | 3382 | g_free (font); |
| 3383 | } | |
| 8932 | 3384 | |
| 3385 | g_free(ws); | |
|
13138
4d3bd039da3e
[gaim-migrate @ 15499]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13137
diff
changeset
|
3386 | g_free(bg); |
| 8677 | 3387 | |
| 3388 | if (!imhtml->wbfo) | |
| 8698 | 3389 | gtk_imhtml_close_tags(imhtml, iter); |
| 8506 | 3390 | |
| 15403 | 3391 | object = g_object_ref(G_OBJECT(imhtml)); |
| 8506 | 3392 | g_signal_emit(object, signals[UPDATE_FORMAT], 0); |
| 3393 | g_object_unref(object); | |
| 15420 | 3394 | |
|
22834
1394e7efb818
Smiley insertions can be undone with this fix. References #5577. But redo
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22810
diff
changeset
|
3395 | gtk_text_buffer_end_user_action(imhtml->text_buffer); |
| 3922 | 3396 | } |
| 3397 | ||
| 4892 | 3398 | void gtk_imhtml_remove_smileys(GtkIMHtml *imhtml) |
| 3399 | { | |
| 4288 | 3400 | g_hash_table_destroy(imhtml->smiley_data); |
| 3401 | gtk_smiley_tree_destroy(imhtml->default_smilies); | |
| 4892 | 3402 | imhtml->smiley_data = g_hash_table_new_full(g_str_hash, g_str_equal, |
| 4902 | 3403 | g_free, (GDestroyNotify)gtk_smiley_tree_destroy); |
| 4288 | 3404 | imhtml->default_smilies = gtk_smiley_tree_new(); |
| 3405 | } | |
| 8481 | 3406 | |
| 3922 | 3407 | void gtk_imhtml_show_comments (GtkIMHtml *imhtml, |
| 4253 | 3408 | gboolean show) |
| 3409 | { | |
|
22486
e77232ab761f
Disable invisible text things, if someone can conclusively prove this is
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22276
diff
changeset
|
3410 | #if FALSE && GTK_CHECK_VERSION(2,10,10) |
|
22211
7f3cecdb079c
disapproval of revision '2c96f5a301400781ce5fbf144ffdbae44f895281'
Sean Egan <seanegan@pidgin.im>
parents:
22210
diff
changeset
|
3411 | GtkTextTag *tag; |
|
7f3cecdb079c
disapproval of revision '2c96f5a301400781ce5fbf144ffdbae44f895281'
Sean Egan <seanegan@pidgin.im>
parents:
22210
diff
changeset
|
3412 | tag = gtk_text_tag_table_lookup(gtk_text_buffer_get_tag_table(imhtml->text_buffer), "comment"); |
|
7f3cecdb079c
disapproval of revision '2c96f5a301400781ce5fbf144ffdbae44f895281'
Sean Egan <seanegan@pidgin.im>
parents:
22210
diff
changeset
|
3413 | if (tag) |
|
7f3cecdb079c
disapproval of revision '2c96f5a301400781ce5fbf144ffdbae44f895281'
Sean Egan <seanegan@pidgin.im>
parents:
22210
diff
changeset
|
3414 | g_object_set(G_OBJECT(tag), "invisible", !show, NULL); |
|
7f3cecdb079c
disapproval of revision '2c96f5a301400781ce5fbf144ffdbae44f895281'
Sean Egan <seanegan@pidgin.im>
parents:
22210
diff
changeset
|
3415 | #endif |
|
6124
322206d79652
[gaim-migrate @ 6598]
Mark Doliner <markdoliner@pidgin.im>
parents:
6066
diff
changeset
|
3416 | imhtml->show_comments = show; |
| 4253 | 3417 | } |
|
1780
431333222954
[gaim-migrate @ 1790]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
1738
diff
changeset
|
3418 | |
|
11814
5003711283c0
[gaim-migrate @ 14105]
Richard Laager <rlaager@pidgin.im>
parents:
11768
diff
changeset
|
3419 | const char * |
|
5003711283c0
[gaim-migrate @ 14105]
Richard Laager <rlaager@pidgin.im>
parents:
11768
diff
changeset
|
3420 | gtk_imhtml_get_protocol_name(GtkIMHtml *imhtml) { |
|
5003711283c0
[gaim-migrate @ 14105]
Richard Laager <rlaager@pidgin.im>
parents:
11768
diff
changeset
|
3421 | return imhtml->protocol_name; |
|
5003711283c0
[gaim-migrate @ 14105]
Richard Laager <rlaager@pidgin.im>
parents:
11768
diff
changeset
|
3422 | } |
|
5003711283c0
[gaim-migrate @ 14105]
Richard Laager <rlaager@pidgin.im>
parents:
11768
diff
changeset
|
3423 | |
| 8962 | 3424 | void |
| 9029 | 3425 | 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
|
3426 | g_free(imhtml->protocol_name); |
|
0c340861ab79
[gaim-migrate @ 16638]
Mark Doliner <markdoliner@pidgin.im>
parents:
14010
diff
changeset
|
3427 | imhtml->protocol_name = g_strdup(protocol_name); |
| 8456 | 3428 | } |
| 3429 | ||
|
1780
431333222954
[gaim-migrate @ 1790]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
1738
diff
changeset
|
3430 | void |
|
11224
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3431 | gtk_imhtml_delete(GtkIMHtml *imhtml, GtkTextIter *start, GtkTextIter *end) { |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3432 | GList *l; |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3433 | GSList *sl; |
|
11234
e23fd86e7581
[gaim-migrate @ 13377]
Daniel Atallah <datallah@pidgin.im>
parents:
11233
diff
changeset
|
3434 | GtkTextIter i, i_s, i_e; |
| 8427 | 3435 | GObject *object = g_object_ref(G_OBJECT(imhtml)); |
|
11224
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3436 | |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3437 | if (start == NULL) { |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3438 | gtk_text_buffer_get_start_iter(imhtml->text_buffer, &i_s); |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3439 | start = &i_s; |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3440 | } |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3441 | |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3442 | if (end == NULL) { |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3443 | gtk_text_buffer_get_end_iter(imhtml->text_buffer, &i_e); |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3444 | end = &i_e; |
| 7991 | 3445 | } |
|
11224
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3446 | |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3447 | l = imhtml->scalables; |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3448 | while (l) { |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3449 | GList *next = l->next; |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3450 | struct scalable_data *sd = l->data; |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3451 | gtk_text_buffer_get_iter_at_mark(imhtml->text_buffer, |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3452 | &i, sd->mark); |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3453 | if (gtk_text_iter_in_range(&i, start, end)) { |
|
21063
911e85f207c7
Fix some leaks caused by misuse of g_list_remove_link() instead of g_list_delete_link().
Daniel Atallah <datallah@pidgin.im>
parents:
20638
diff
changeset
|
3454 | GtkIMHtmlScalable *scale = GTK_IMHTML_SCALABLE(sd->scalable); |
|
11224
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3455 | scale->free(scale); |
|
21063
911e85f207c7
Fix some leaks caused by misuse of g_list_remove_link() instead of g_list_delete_link().
Daniel Atallah <datallah@pidgin.im>
parents:
20638
diff
changeset
|
3456 | g_free(sd); |
|
911e85f207c7
Fix some leaks caused by misuse of g_list_remove_link() instead of g_list_delete_link().
Daniel Atallah <datallah@pidgin.im>
parents:
20638
diff
changeset
|
3457 | imhtml->scalables = g_list_delete_link(imhtml->scalables, l); |
|
11224
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3458 | } |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3459 | l = next; |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3460 | } |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3461 | |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3462 | sl = imhtml->im_images; |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3463 | while (sl) { |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3464 | GSList *next = sl->next; |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3465 | struct im_image_data *img_data = sl->data; |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3466 | gtk_text_buffer_get_iter_at_mark(imhtml->text_buffer, |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3467 | &i, img_data->mark); |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3468 | if (gtk_text_iter_in_range(&i, start, end)) { |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3469 | if (imhtml->funcs->image_unref) |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3470 | imhtml->funcs->image_unref(img_data->id); |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3471 | imhtml->im_images = g_slist_delete_link(imhtml->im_images, sl); |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3472 | g_free(img_data); |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3473 | } |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3474 | sl = next; |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3475 | } |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3476 | gtk_text_buffer_delete(imhtml->text_buffer, start, end); |
| 8061 | 3477 | |
| 8427 | 3478 | g_object_unref(object); |
|
1780
431333222954
[gaim-migrate @ 1790]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
1738
diff
changeset
|
3479 | } |
|
2363
0767c14d7879
[gaim-migrate @ 2376]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2349
diff
changeset
|
3480 | |
| 4046 | 3481 | void gtk_imhtml_page_up (GtkIMHtml *imhtml) |
| 3482 | { | |
| 5282 | 3483 | GdkRectangle rect; |
| 3484 | GtkTextIter iter; | |
| 4046 | 3485 | |
| 5282 | 3486 | gtk_text_view_get_visible_rect(GTK_TEXT_VIEW(imhtml), &rect); |
| 3487 | gtk_text_view_get_iter_at_location(GTK_TEXT_VIEW(imhtml), &iter, rect.x, | |
| 3488 | rect.y - rect.height); | |
| 3489 | gtk_text_view_scroll_to_iter(GTK_TEXT_VIEW(imhtml), &iter, 0, TRUE, 0, 0); | |
| 8061 | 3490 | |
| 4046 | 3491 | } |
| 5282 | 3492 | void gtk_imhtml_page_down (GtkIMHtml *imhtml) |
| 3493 | { | |
| 3494 | GdkRectangle rect; | |
| 3495 | GtkTextIter iter; | |
| 3496 | ||
| 3497 | gtk_text_view_get_visible_rect(GTK_TEXT_VIEW(imhtml), &rect); | |
| 3498 | gtk_text_view_get_iter_at_location(GTK_TEXT_VIEW(imhtml), &iter, rect.x, | |
| 3499 | rect.y + rect.height); | |
| 3500 | gtk_text_view_scroll_to_iter(GTK_TEXT_VIEW(imhtml), &iter, 0, TRUE, 0, 0); | |
| 3501 | } | |
| 4735 | 3502 | |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
3503 | /* GtkIMHtmlScalable, gtk_imhtml_image, gtk_imhtml_hr */ |
| 8962 | 3504 | GtkIMHtmlScalable *gtk_imhtml_image_new(GdkPixbuf *img, const gchar *filename, int id) |
| 4735 | 3505 | { |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
3506 | GtkIMHtmlImage *im_image = g_malloc(sizeof(GtkIMHtmlImage)); |
| 4895 | 3507 | |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
3508 | GTK_IMHTML_SCALABLE(im_image)->scale = gtk_imhtml_image_scale; |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
3509 | 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
|
3510 | GTK_IMHTML_SCALABLE(im_image)->free = gtk_imhtml_image_free; |
| 5046 | 3511 | |
| 3512 | 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
|
3513 | im_image->image = GTK_IMAGE(gtk_image_new_from_pixbuf(im_image->pixbuf)); |
| 4895 | 3514 | im_image->width = gdk_pixbuf_get_width(img); |
| 3515 | im_image->height = gdk_pixbuf_get_height(img); | |
| 3516 | im_image->mark = NULL; | |
|
14097
0c340861ab79
[gaim-migrate @ 16638]
Mark Doliner <markdoliner@pidgin.im>
parents:
14010
diff
changeset
|
3517 | im_image->filename = g_strdup(filename); |
| 8962 | 3518 | im_image->id = id; |
|
9573
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3519 | im_image->filesel = NULL; |
| 4895 | 3520 | |
| 5046 | 3521 | g_object_ref(img); |
| 4895 | 3522 | return GTK_IMHTML_SCALABLE(im_image); |
| 3523 | } | |
| 3524 | ||
|
18151
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
3525 | static gboolean |
|
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
3526 | 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
|
3527 | { |
|
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
3528 | GtkIMHtmlImage *im_image; |
|
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
3529 | int width, height; |
|
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
3530 | int delay; |
|
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
3531 | |
|
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
3532 | im_image = data; |
|
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
3533 | |
|
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
3534 | /* Update the pointer to this GdkPixbuf frame of the animation */ |
|
20638
38507ef4007f
Fix some crashes with animated smileys. Fixes #3179, #938, #3134, #2872, #1594
Daniel Atallah <datallah@pidgin.im>
parents:
20330
diff
changeset
|
3535 | if (gdk_pixbuf_animation_iter_advance(GTK_IMHTML_ANIMATION(im_image)->iter, NULL)) { |
|
38507ef4007f
Fix some crashes with animated smileys. Fixes #3179, #938, #3134, #2872, #1594
Daniel Atallah <datallah@pidgin.im>
parents:
20330
diff
changeset
|
3536 | GdkPixbuf *pb = gdk_pixbuf_animation_iter_get_pixbuf(GTK_IMHTML_ANIMATION(im_image)->iter); |
|
38507ef4007f
Fix some crashes with animated smileys. Fixes #3179, #938, #3134, #2872, #1594
Daniel Atallah <datallah@pidgin.im>
parents:
20330
diff
changeset
|
3537 | g_object_unref(G_OBJECT(im_image->pixbuf)); |
|
38507ef4007f
Fix some crashes with animated smileys. Fixes #3179, #938, #3134, #2872, #1594
Daniel Atallah <datallah@pidgin.im>
parents:
20330
diff
changeset
|
3538 | im_image->pixbuf = gdk_pixbuf_copy(pb); |
|
38507ef4007f
Fix some crashes with animated smileys. Fixes #3179, #938, #3134, #2872, #1594
Daniel Atallah <datallah@pidgin.im>
parents:
20330
diff
changeset
|
3539 | |
|
38507ef4007f
Fix some crashes with animated smileys. Fixes #3179, #938, #3134, #2872, #1594
Daniel Atallah <datallah@pidgin.im>
parents:
20330
diff
changeset
|
3540 | /* Update the displayed GtkImage */ |
|
38507ef4007f
Fix some crashes with animated smileys. Fixes #3179, #938, #3134, #2872, #1594
Daniel Atallah <datallah@pidgin.im>
parents:
20330
diff
changeset
|
3541 | width = gdk_pixbuf_get_width(gtk_image_get_pixbuf(im_image->image)); |
|
38507ef4007f
Fix some crashes with animated smileys. Fixes #3179, #938, #3134, #2872, #1594
Daniel Atallah <datallah@pidgin.im>
parents:
20330
diff
changeset
|
3542 | height = gdk_pixbuf_get_height(gtk_image_get_pixbuf(im_image->image)); |
|
38507ef4007f
Fix some crashes with animated smileys. Fixes #3179, #938, #3134, #2872, #1594
Daniel Atallah <datallah@pidgin.im>
parents:
20330
diff
changeset
|
3543 | if (width > 0 && height > 0) |
|
38507ef4007f
Fix some crashes with animated smileys. Fixes #3179, #938, #3134, #2872, #1594
Daniel Atallah <datallah@pidgin.im>
parents:
20330
diff
changeset
|
3544 | { |
|
38507ef4007f
Fix some crashes with animated smileys. Fixes #3179, #938, #3134, #2872, #1594
Daniel Atallah <datallah@pidgin.im>
parents:
20330
diff
changeset
|
3545 | /* Need to scale the new frame to the same size as the old frame */ |
|
38507ef4007f
Fix some crashes with animated smileys. Fixes #3179, #938, #3134, #2872, #1594
Daniel Atallah <datallah@pidgin.im>
parents:
20330
diff
changeset
|
3546 | GdkPixbuf *tmp; |
|
38507ef4007f
Fix some crashes with animated smileys. Fixes #3179, #938, #3134, #2872, #1594
Daniel Atallah <datallah@pidgin.im>
parents:
20330
diff
changeset
|
3547 | tmp = gdk_pixbuf_scale_simple(im_image->pixbuf, width, height, GDK_INTERP_BILINEAR); |
|
38507ef4007f
Fix some crashes with animated smileys. Fixes #3179, #938, #3134, #2872, #1594
Daniel Atallah <datallah@pidgin.im>
parents:
20330
diff
changeset
|
3548 | gtk_image_set_from_pixbuf(im_image->image, tmp); |
|
38507ef4007f
Fix some crashes with animated smileys. Fixes #3179, #938, #3134, #2872, #1594
Daniel Atallah <datallah@pidgin.im>
parents:
20330
diff
changeset
|
3549 | g_object_unref(G_OBJECT(tmp)); |
|
38507ef4007f
Fix some crashes with animated smileys. Fixes #3179, #938, #3134, #2872, #1594
Daniel Atallah <datallah@pidgin.im>
parents:
20330
diff
changeset
|
3550 | } else { |
|
38507ef4007f
Fix some crashes with animated smileys. Fixes #3179, #938, #3134, #2872, #1594
Daniel Atallah <datallah@pidgin.im>
parents:
20330
diff
changeset
|
3551 | /* Display at full-size */ |
|
38507ef4007f
Fix some crashes with animated smileys. Fixes #3179, #938, #3134, #2872, #1594
Daniel Atallah <datallah@pidgin.im>
parents:
20330
diff
changeset
|
3552 | gtk_image_set_from_pixbuf(im_image->image, im_image->pixbuf); |
|
38507ef4007f
Fix some crashes with animated smileys. Fixes #3179, #938, #3134, #2872, #1594
Daniel Atallah <datallah@pidgin.im>
parents:
20330
diff
changeset
|
3553 | } |
|
18151
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
3554 | } |
|
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
3555 | |
|
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
3556 | 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
|
3557 | 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
|
3558 | |
|
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
3559 | return FALSE; |
|
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
3560 | } |
|
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 | 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
|
3563 | { |
|
22703
2cc5d0981559
Fix animated icons that have been right-clicked causing crashes when the imhtml is destroyed. Fixes #5217.
Daniel Atallah <datallah@pidgin.im>
parents:
22596
diff
changeset
|
3564 | GtkIMHtmlImage *im_image = (GtkIMHtmlImage *) g_new0(GtkIMHtmlAnimation, 1); |
|
18151
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
3565 | |
|
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
3566 | 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
|
3567 | 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
|
3568 | 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
|
3569 | |
|
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
3570 | 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
|
3571 | 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
|
3572 | im_image->pixbuf = gdk_pixbuf_animation_get_static_image(anim); |
|
20638
38507ef4007f
Fix some crashes with animated smileys. Fixes #3179, #938, #3134, #2872, #1594
Daniel Atallah <datallah@pidgin.im>
parents:
20330
diff
changeset
|
3573 | g_object_ref(im_image->pixbuf); |
|
18151
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
3574 | } else { |
|
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
3575 | int delay; |
|
20638
38507ef4007f
Fix some crashes with animated smileys. Fixes #3179, #938, #3134, #2872, #1594
Daniel Atallah <datallah@pidgin.im>
parents:
20330
diff
changeset
|
3576 | GdkPixbuf *pb; |
|
18151
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
3577 | GTK_IMHTML_ANIMATION(im_image)->iter = gdk_pixbuf_animation_get_iter(anim, NULL); |
|
20638
38507ef4007f
Fix some crashes with animated smileys. Fixes #3179, #938, #3134, #2872, #1594
Daniel Atallah <datallah@pidgin.im>
parents:
20330
diff
changeset
|
3578 | pb = gdk_pixbuf_animation_iter_get_pixbuf(GTK_IMHTML_ANIMATION(im_image)->iter); |
|
38507ef4007f
Fix some crashes with animated smileys. Fixes #3179, #938, #3134, #2872, #1594
Daniel Atallah <datallah@pidgin.im>
parents:
20330
diff
changeset
|
3579 | im_image->pixbuf = gdk_pixbuf_copy(pb); |
|
18151
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
3580 | 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
|
3581 | 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
|
3582 | } |
|
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
3583 | 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
|
3584 | 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
|
3585 | 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
|
3586 | 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
|
3587 | 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
|
3588 | |
|
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
3589 | 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
|
3590 | |
|
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
3591 | 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
|
3592 | } |
|
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
3593 | |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
3594 | void gtk_imhtml_image_scale(GtkIMHtmlScalable *scale, int width, int height) |
| 4895 | 3595 | { |
|
11867
de448bc5da1a
[gaim-migrate @ 14158]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11844
diff
changeset
|
3596 | GtkIMHtmlImage *im_image = (GtkIMHtmlImage *)scale; |
|
de448bc5da1a
[gaim-migrate @ 14158]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11844
diff
changeset
|
3597 | |
|
de448bc5da1a
[gaim-migrate @ 14158]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11844
diff
changeset
|
3598 | if (im_image->width > width || im_image->height > height) { |
|
11840
c9ec5a42d420
[gaim-migrate @ 14131]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11820
diff
changeset
|
3599 | double ratio_w, ratio_h, ratio; |
|
c9ec5a42d420
[gaim-migrate @ 14131]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11820
diff
changeset
|
3600 | int new_h, new_w; |
| 4895 | 3601 | GdkPixbuf *new_image = NULL; |
|
11840
c9ec5a42d420
[gaim-migrate @ 14131]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11820
diff
changeset
|
3602 | |
|
11867
de448bc5da1a
[gaim-migrate @ 14158]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11844
diff
changeset
|
3603 | ratio_w = ((double)width - 2) / im_image->width; |
|
de448bc5da1a
[gaim-migrate @ 14158]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11844
diff
changeset
|
3604 | ratio_h = ((double)height - 2) / im_image->height; |
|
11840
c9ec5a42d420
[gaim-migrate @ 14131]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11820
diff
changeset
|
3605 | |
|
c9ec5a42d420
[gaim-migrate @ 14131]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11820
diff
changeset
|
3606 | ratio = (ratio_w < ratio_h) ? ratio_w : ratio_h; |
|
c9ec5a42d420
[gaim-migrate @ 14131]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11820
diff
changeset
|
3607 | |
|
11867
de448bc5da1a
[gaim-migrate @ 14158]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11844
diff
changeset
|
3608 | new_w = (int)(im_image->width * ratio); |
|
de448bc5da1a
[gaim-migrate @ 14158]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11844
diff
changeset
|
3609 | new_h = (int)(im_image->height * ratio); |
|
de448bc5da1a
[gaim-migrate @ 14158]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11844
diff
changeset
|
3610 | |
|
de448bc5da1a
[gaim-migrate @ 14158]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11844
diff
changeset
|
3611 | 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
|
3612 | gtk_image_set_from_pixbuf(im_image->image, new_image); |
|
de448bc5da1a
[gaim-migrate @ 14158]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11844
diff
changeset
|
3613 | g_object_unref(G_OBJECT(new_image)); |
|
de448bc5da1a
[gaim-migrate @ 14158]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11844
diff
changeset
|
3614 | } 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
|
3615 | /* Enough space to show the full-size of the image. */ |
|
de448bc5da1a
[gaim-migrate @ 14158]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11844
diff
changeset
|
3616 | GdkPixbuf *new_image; |
|
de448bc5da1a
[gaim-migrate @ 14158]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11844
diff
changeset
|
3617 | |
|
de448bc5da1a
[gaim-migrate @ 14158]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11844
diff
changeset
|
3618 | 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
|
3619 | gtk_image_set_from_pixbuf(im_image->image, new_image); |
| 4895 | 3620 | g_object_unref(G_OBJECT(new_image)); |
| 3621 | } | |
| 3622 | } | |
| 3623 | ||
|
9573
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3624 | static void |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3625 | image_save_yes_cb(GtkIMHtmlImage *image, const char *filename) |
| 5012 | 3626 | { |
| 3627 | gchar *type = NULL; | |
| 5019 | 3628 | GError *error = NULL; |
| 5015 | 3629 | #if GTK_CHECK_VERSION(2,2,0) |
| 5012 | 3630 | GSList *formats = gdk_pixbuf_get_formats(); |
|
6162
aed29c41bdfa
[gaim-migrate @ 6642]
Mark Doliner <markdoliner@pidgin.im>
parents:
6124
diff
changeset
|
3631 | #else |
|
aed29c41bdfa
[gaim-migrate @ 6642]
Mark Doliner <markdoliner@pidgin.im>
parents:
6124
diff
changeset
|
3632 | char *basename = g_path_get_basename(filename); |
|
aed29c41bdfa
[gaim-migrate @ 6642]
Mark Doliner <markdoliner@pidgin.im>
parents:
6124
diff
changeset
|
3633 | char *ext = strrchr(basename, '.'); |
|
5959
827dbe4b5bb2
[gaim-migrate @ 6405]
Mark Doliner <markdoliner@pidgin.im>
parents:
5582
diff
changeset
|
3634 | #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
|
3635 | char *newfilename; |
| 5012 | 3636 | |
|
9573
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3637 | gtk_widget_destroy(image->filesel); |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3638 | image->filesel = NULL; |
|
5959
827dbe4b5bb2
[gaim-migrate @ 6405]
Mark Doliner <markdoliner@pidgin.im>
parents:
5582
diff
changeset
|
3639 | |
|
827dbe4b5bb2
[gaim-migrate @ 6405]
Mark Doliner <markdoliner@pidgin.im>
parents:
5582
diff
changeset
|
3640 | #if GTK_CHECK_VERSION(2,2,0) |
|
9573
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3641 | while (formats) { |
| 5012 | 3642 | GdkPixbufFormat *format = formats->data; |
| 3643 | gchar **extensions = gdk_pixbuf_format_get_extensions(format); | |
| 3644 | gpointer p = extensions; | |
| 3645 | ||
| 3646 | while(gdk_pixbuf_format_is_writable(format) && extensions && extensions[0]){ | |
| 3647 | gchar *fmt_ext = extensions[0]; | |
| 3648 | const gchar* file_ext = filename + strlen(filename) - strlen(fmt_ext); | |
| 3649 | ||
|
17695
5e7fcc2f23cc
Compare the user-entered file extension to the GDK file extension
Mark Doliner <markdoliner@pidgin.im>
parents:
17694
diff
changeset
|
3650 | if(!g_ascii_strcasecmp(fmt_ext, file_ext)){ |
| 5012 | 3651 | type = gdk_pixbuf_format_get_name(format); |
| 3652 | break; | |
| 3653 | } | |
| 3654 | ||
| 3655 | extensions++; | |
| 3656 | } | |
| 3657 | ||
| 3658 | g_strfreev(p); | |
| 3659 | ||
|
9573
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3660 | if (type) |
| 5012 | 3661 | break; |
| 3662 | ||
| 3663 | formats = formats->next; | |
| 3664 | } | |
| 3665 | ||
| 5020 | 3666 | g_slist_free(formats); |
| 3667 | #else | |
| 3668 | /* 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
|
3669 | if (ext) { |
| 5020 | 3670 | ext++; |
|
9573
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3671 | if (!g_ascii_strcasecmp(ext, "jpeg") || !g_ascii_strcasecmp(ext, "jpg")) |
| 5020 | 3672 | type = g_strdup("jpeg"); |
|
9573
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3673 | else if (!g_ascii_strcasecmp(ext, "png")) |
| 5020 | 3674 | type = g_strdup("png"); |
| 3675 | } | |
| 3676 | ||
| 3677 | g_free(basename); | |
| 3678 | #endif | |
| 3679 | ||
| 5012 | 3680 | /* If I can't find a valid type, I will just tell the user about it and then assume |
| 3681 | it's a png */ | |
|
9573
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3682 | 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
|
3683 | char *basename, *tmp; |
|
11069
3cc1cdd931e9
[gaim-migrate @ 13065]
Richard Laager <rlaager@pidgin.im>
parents:
11019
diff
changeset
|
3684 | #if GTK_CHECK_VERSION(2,4,0) |
|
11019
6786068b00ab
[gaim-migrate @ 12890]
Richard Laager <rlaager@pidgin.im>
parents:
11006
diff
changeset
|
3685 | 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
|
3686 | _("<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
|
3687 | #else |
|
3cc1cdd931e9
[gaim-migrate @ 13065]
Richard Laager <rlaager@pidgin.im>
parents:
11019
diff
changeset
|
3688 | 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
|
3689 | _("Unrecognized file type\n\nDefaulting to PNG.")); |
|
3cc1cdd931e9
[gaim-migrate @ 13065]
Richard Laager <rlaager@pidgin.im>
parents:
11019
diff
changeset
|
3690 | #endif |
|
3cc1cdd931e9
[gaim-migrate @ 13065]
Richard Laager <rlaager@pidgin.im>
parents:
11019
diff
changeset
|
3691 | |
|
11019
6786068b00ab
[gaim-migrate @ 12890]
Richard Laager <rlaager@pidgin.im>
parents:
11006
diff
changeset
|
3692 | 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
|
3693 | 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
|
3694 | |
|
9717
3c8f42ca313e
[gaim-migrate @ 10578]
Mark Doliner <markdoliner@pidgin.im>
parents:
9709
diff
changeset
|
3695 | 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
|
3696 | 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
|
3697 | 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
|
3698 | 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
|
3699 | 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
|
3700 | 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
|
3701 | 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
|
3702 | } 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
|
3703 | /* |
|
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
|
3704 | * 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
|
3705 | * 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
|
3706 | */ |
|
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
|
3707 | newfilename = g_strdup(filename); |
| 5012 | 3708 | } |
| 3709 | ||
|
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
|
3710 | 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
|
3711 | |
|
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
|
3712 | 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
|
3713 | g_free(type); |
| 5012 | 3714 | |
|
9573
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3715 | if (error){ |
|
11069
3cc1cdd931e9
[gaim-migrate @ 13065]
Richard Laager <rlaager@pidgin.im>
parents:
11019
diff
changeset
|
3716 | #if GTK_CHECK_VERSION(2,4,0) |
|
11019
6786068b00ab
[gaim-migrate @ 12890]
Richard Laager <rlaager@pidgin.im>
parents:
11006
diff
changeset
|
3717 | 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
|
3718 | _("<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
|
3719 | #else |
|
3cc1cdd931e9
[gaim-migrate @ 13065]
Richard Laager <rlaager@pidgin.im>
parents:
11019
diff
changeset
|
3720 | 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
|
3721 | _("Error saving image\n\n%s"), error->message); |
|
3cc1cdd931e9
[gaim-migrate @ 13065]
Richard Laager <rlaager@pidgin.im>
parents:
11019
diff
changeset
|
3722 | #endif |
|
11019
6786068b00ab
[gaim-migrate @ 12890]
Richard Laager <rlaager@pidgin.im>
parents:
11006
diff
changeset
|
3723 | 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
|
3724 | gtk_widget_show(dialog); |
| 5012 | 3725 | g_error_free(error); |
| 3726 | } | |
| 3727 | } | |
| 3728 | ||
|
9573
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3729 | #if GTK_CHECK_VERSION(2,4,0) /* FILECHOOSER */ |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3730 | static void |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3731 | 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
|
3732 | { |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3733 | gchar *filename; |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3734 | |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3735 | if (response != GTK_RESPONSE_ACCEPT) { |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3736 | gtk_widget_destroy(widget); |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3737 | image->filesel = NULL; |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3738 | return; |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3739 | } |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3740 | |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3741 | filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(widget)); |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3742 | #else /* FILECHOOSER */ |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3743 | static void |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3744 | image_save_check_if_exists_cb(GtkWidget *button, GtkIMHtmlImage *image) |
| 5012 | 3745 | { |
|
9573
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3746 | gchar *filename; |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3747 | |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3748 | 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
|
3749 | |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3750 | if (g_file_test(filename, G_FILE_TEST_IS_DIR)) { |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3751 | gchar *dirname; |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3752 | /* append a / is needed */ |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3753 | if (filename[strlen(filename) - 1] != G_DIR_SEPARATOR) { |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3754 | dirname = g_strconcat(filename, G_DIR_SEPARATOR_S, NULL); |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3755 | } else { |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3756 | dirname = g_strdup(filename); |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3757 | } |
|
9574
d5a2c770adcd
[gaim-migrate @ 10417]
Mark Doliner <markdoliner@pidgin.im>
parents:
9573
diff
changeset
|
3758 | 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
|
3759 | g_free(dirname); |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3760 | g_free(filename); |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3761 | return; |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3762 | } |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3763 | #endif /* FILECHOOSER */ |
|
21985
bf0e936998e4
Move some curly braces around so static analysis tools can properly detect
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
21955
diff
changeset
|
3764 | #if 0 /* mismatched curly braces */ |
|
bf0e936998e4
Move some curly braces around so static analysis tools can properly detect
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
21955
diff
changeset
|
3765 | } |
|
bf0e936998e4
Move some curly braces around so static analysis tools can properly detect
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
21955
diff
changeset
|
3766 | #endif |
|
9573
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3767 | |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3768 | /* |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3769 | * 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
|
3770 | * 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
|
3771 | * 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
|
3772 | */ |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3773 | /* |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3774 | if (g_file_test(filename, G_FILE_TEST_EXISTS)) { |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3775 | } else |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3776 | image_save_yes_cb(image, filename); |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3777 | */ |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3778 | |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3779 | image_save_yes_cb(image, filename); |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3780 | |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3781 | g_free(filename); |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3782 | } |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3783 | |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3784 | #if !GTK_CHECK_VERSION(2,4,0) /* FILECHOOSER */ |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3785 | static void |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3786 | image_save_cancel_cb(GtkIMHtmlImage *image) |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3787 | { |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3788 | gtk_widget_destroy(image->filesel); |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3789 | image->filesel = NULL; |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3790 | } |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3791 | #endif /* FILECHOOSER */ |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3792 | |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3793 | static void |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3794 | gtk_imhtml_image_save(GtkWidget *w, GtkIMHtmlImage *image) |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3795 | { |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3796 | if (image->filesel != NULL) { |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3797 | gtk_window_present(GTK_WINDOW(image->filesel)); |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3798 | return; |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3799 | } |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3800 | |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3801 | #if GTK_CHECK_VERSION(2,4,0) /* FILECHOOSER */ |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3802 | image->filesel = gtk_file_chooser_dialog_new(_("Save Image"), |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3803 | NULL, |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3804 | GTK_FILE_CHOOSER_ACTION_SAVE, |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3805 | GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3806 | GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT, |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3807 | NULL); |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3808 | 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
|
3809 | if (image->filename != NULL) |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3810 | 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
|
3811 | g_signal_connect(G_OBJECT(GTK_FILE_CHOOSER(image->filesel)), "response", |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3812 | G_CALLBACK(image_save_check_if_exists_cb), image); |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3813 | #else /* FILECHOOSER */ |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3814 | image->filesel = gtk_file_selection_new(_("Save Image")); |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3815 | if (image->filename != NULL) |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3816 | 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
|
3817 | 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
|
3818 | G_CALLBACK(image_save_cancel_cb), image); |
|
d5a2c770adcd
[gaim-migrate @ 10417]
Mark Doliner <markdoliner@pidgin.im>
parents:
9573
diff
changeset
|
3819 | 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
|
3820 | "clicked", G_CALLBACK(image_save_cancel_cb), image); |
|
9573
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3821 | 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
|
3822 | G_CALLBACK(image_save_check_if_exists_cb), image); |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3823 | #endif /* FILECHOOSER */ |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3824 | |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3825 | gtk_widget_show(image->filesel); |
| 5012 | 3826 | } |
| 3827 | ||
|
23304
3aba02105818
Modified patch from malu to "Add context menu alternative to add received
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23302
diff
changeset
|
3828 | static void |
|
3aba02105818
Modified patch from malu to "Add context menu alternative to add received
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23302
diff
changeset
|
3829 | gtk_imhtml_custom_smiley_save(GtkWidget *w, GtkIMHtmlImage *image) |
|
3aba02105818
Modified patch from malu to "Add context menu alternative to add received
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23302
diff
changeset
|
3830 | { |
|
3aba02105818
Modified patch from malu to "Add context menu alternative to add received
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23302
diff
changeset
|
3831 | /* Create an add dialog */ |
|
3aba02105818
Modified patch from malu to "Add context menu alternative to add received
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23302
diff
changeset
|
3832 | PidginSmiley *editor = pidgin_smiley_edit(NULL, NULL); |
|
3aba02105818
Modified patch from malu to "Add context menu alternative to add received
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23302
diff
changeset
|
3833 | pidgin_smiley_editor_set_shortcut(editor, image->filename); |
|
3aba02105818
Modified patch from malu to "Add context menu alternative to add received
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23302
diff
changeset
|
3834 | pidgin_smiley_editor_set_image(editor, image->pixbuf); |
|
3aba02105818
Modified patch from malu to "Add context menu alternative to add received
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23302
diff
changeset
|
3835 | } |
|
3aba02105818
Modified patch from malu to "Add context menu alternative to add received
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23302
diff
changeset
|
3836 | |
|
9815
fcbbbce0e1ff
[gaim-migrate @ 10686]
Mark Doliner <markdoliner@pidgin.im>
parents:
9726
diff
changeset
|
3837 | /* |
|
fcbbbce0e1ff
[gaim-migrate @ 10686]
Mark Doliner <markdoliner@pidgin.im>
parents:
9726
diff
changeset
|
3838 | * 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
|
3839 | * 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
|
3840 | * basically like file transfer, except there is an icon to open the file |
| 15884 | 3841 | * 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
|
3842 | * all of that. |
|
fcbbbce0e1ff
[gaim-migrate @ 10686]
Mark Doliner <markdoliner@pidgin.im>
parents:
9726
diff
changeset
|
3843 | */ |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
3844 | static gboolean gtk_imhtml_image_clicked(GtkWidget *w, GdkEvent *event, GtkIMHtmlImage *image) |
| 5012 | 3845 | { |
| 3846 | GdkEventButton *event_button = (GdkEventButton *) event; | |
| 3847 | ||
| 3848 | if (event->type == GDK_BUTTON_RELEASE) { | |
| 3849 | if(event_button->button == 3) { | |
| 3850 | GtkWidget *img, *item, *menu; | |
| 3851 | gchar *text = g_strdup_printf(_("_Save Image...")); | |
| 3852 | menu = gtk_menu_new(); | |
| 3853 | ||
| 3854 | /* buttons and such */ | |
| 3855 | img = gtk_image_new_from_stock(GTK_STOCK_SAVE, GTK_ICON_SIZE_MENU); | |
| 3856 | item = gtk_image_menu_item_new_with_mnemonic(text); | |
| 3857 | 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
|
3858 | g_signal_connect(G_OBJECT(item), "activate", G_CALLBACK(gtk_imhtml_image_save), image); |
| 5012 | 3859 | gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); |
| 3860 | ||
|
23304
3aba02105818
Modified patch from malu to "Add context menu alternative to add received
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23302
diff
changeset
|
3861 | /* Add menu item for adding custom smiley to local smileys */ |
|
3aba02105818
Modified patch from malu to "Add context menu alternative to add received
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23302
diff
changeset
|
3862 | /* we only add the menu if the image is of "custom smiley size" |
|
3aba02105818
Modified patch from malu to "Add context menu alternative to add received
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23302
diff
changeset
|
3863 | <= 96x96 pixels */ |
|
3aba02105818
Modified patch from malu to "Add context menu alternative to add received
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23302
diff
changeset
|
3864 | if (image->width <= 96 && image->height <= 96) { |
|
3aba02105818
Modified patch from malu to "Add context menu alternative to add received
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23302
diff
changeset
|
3865 | text = g_strdup_printf(_("_Add Custom Smiley...")); |
|
3aba02105818
Modified patch from malu to "Add context menu alternative to add received
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23302
diff
changeset
|
3866 | img = gtk_image_new_from_stock(GTK_STOCK_ADD, GTK_ICON_SIZE_MENU); |
|
3aba02105818
Modified patch from malu to "Add context menu alternative to add received
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23302
diff
changeset
|
3867 | item = gtk_image_menu_item_new_with_mnemonic(text); |
|
3aba02105818
Modified patch from malu to "Add context menu alternative to add received
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23302
diff
changeset
|
3868 | gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(item), img); |
|
3aba02105818
Modified patch from malu to "Add context menu alternative to add received
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23302
diff
changeset
|
3869 | g_signal_connect(G_OBJECT(item), "activate", |
|
3aba02105818
Modified patch from malu to "Add context menu alternative to add received
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23302
diff
changeset
|
3870 | G_CALLBACK(gtk_imhtml_custom_smiley_save), image); |
|
3aba02105818
Modified patch from malu to "Add context menu alternative to add received
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23302
diff
changeset
|
3871 | gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); |
|
3aba02105818
Modified patch from malu to "Add context menu alternative to add received
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23302
diff
changeset
|
3872 | } |
|
3aba02105818
Modified patch from malu to "Add context menu alternative to add received
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23302
diff
changeset
|
3873 | |
| 5012 | 3874 | gtk_widget_show_all(menu); |
| 3875 | gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL, | |
| 3876 | event_button->button, event_button->time); | |
| 3877 | ||
| 3878 | g_free(text); | |
| 3879 | return TRUE; | |
| 3880 | } | |
| 3881 | } | |
| 3882 | if(event->type == GDK_BUTTON_PRESS && event_button->button == 3) | |
| 3883 | return TRUE; /* Clicking the right mouse button on a link shouldn't | |
| 3884 | be caught by the regular GtkTextView menu */ | |
| 3885 | else | |
| 3886 | return FALSE; /* Let clicks go through if we didn't catch anything */ | |
| 3887 | ||
| 3888 | } | |
|
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
|
3889 | |
|
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
|
3890 | 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
|
3891 | { |
|
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
|
3892 | 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
|
3893 | 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
|
3894 | gboolean ret; |
|
23304
3aba02105818
Modified patch from malu to "Add context menu alternative to add received
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23302
diff
changeset
|
3895 | |
|
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
|
3896 | 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
|
3897 | 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
|
3898 | |
|
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
|
3899 | 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
|
3900 | 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
|
3901 | 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
|
3902 | |
|
18151
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
3903 | 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
|
3904 | ret = gtk_imhtml_image_clicked(w, event, (GtkIMHtmlImage*)image); |
|
22703
2cc5d0981559
Fix animated icons that have been right-clicked causing crashes when the imhtml is destroyed. Fixes #5217.
Daniel Atallah <datallah@pidgin.im>
parents:
22596
diff
changeset
|
3905 | g_object_set_data_full(G_OBJECT(w), "image-data", image, (GDestroyNotify)gtk_imhtml_animation_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
|
3906 | 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
|
3907 | } |
|
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
|
3908 | |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
3909 | void gtk_imhtml_image_free(GtkIMHtmlScalable *scale) |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
3910 | { |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
3911 | GtkIMHtmlImage *image = (GtkIMHtmlImage *)scale; |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
3912 | |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
3913 | g_object_unref(image->pixbuf); |
|
14097
0c340861ab79
[gaim-migrate @ 16638]
Mark Doliner <markdoliner@pidgin.im>
parents:
14010
diff
changeset
|
3914 | g_free(image->filename); |
|
9573
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3915 | if (image->filesel) |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3916 | gtk_widget_destroy(image->filesel); |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
3917 | g_free(scale); |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
3918 | } |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
3919 | |
|
18151
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
3920 | 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
|
3921 | { |
|
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
3922 | 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
|
3923 | |
|
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
3924 | 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
|
3925 | 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
|
3926 | 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
|
3927 | 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
|
3928 | 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
|
3929 | |
|
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
3930 | 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
|
3931 | } |
|
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
3932 | |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
3933 | 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
|
3934 | { |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
3935 | GtkIMHtmlImage *image = (GtkIMHtmlImage *)scale; |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
3936 | GtkWidget *box = gtk_event_box_new(); |
| 8962 | 3937 | char *tag; |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
3938 | 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
|
3939 | |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
3940 | gtk_container_add(GTK_CONTAINER(box), GTK_WIDGET(image->image)); |
| 9229 | 3941 | |
| 3942 | if(!gtk_check_version(2, 4, 0)) | |
| 3943 | g_object_set(G_OBJECT(box), "visible-window", FALSE, NULL); | |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
3944 | |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
3945 | gtk_widget_show(GTK_WIDGET(image->image)); |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
3946 | gtk_widget_show(box); |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
3947 | |
| 8962 | 3948 | tag = g_strdup_printf("<IMG ID=\"%d\">", image->id); |
| 3949 | g_object_set_data_full(G_OBJECT(anchor), "gtkimhtml_htmltext", tag, g_free); | |
| 3950 | g_object_set_data(G_OBJECT(anchor), "gtkimhtml_plaintext", "[Image]"); | |
| 3951 | ||
| 15420 | 3952 | 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
|
3953 | 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
|
3954 | } |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
3955 | |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
3956 | GtkIMHtmlScalable *gtk_imhtml_hr_new() |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
3957 | { |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
3958 | GtkIMHtmlHr *hr = g_malloc(sizeof(GtkIMHtmlHr)); |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
3959 | |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
3960 | GTK_IMHTML_SCALABLE(hr)->scale = gtk_imhtml_hr_scale; |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
3961 | GTK_IMHTML_SCALABLE(hr)->add_to = gtk_imhtml_hr_add_to; |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
3962 | GTK_IMHTML_SCALABLE(hr)->free = gtk_imhtml_hr_free; |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
3963 | |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
3964 | hr->sep = gtk_hseparator_new(); |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
3965 | gtk_widget_set_size_request(hr->sep, 5000, 2); |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
3966 | gtk_widget_show(hr->sep); |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
3967 | |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
3968 | return GTK_IMHTML_SCALABLE(hr); |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
3969 | } |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
3970 | |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
3971 | void gtk_imhtml_hr_scale(GtkIMHtmlScalable *scale, int width, int height) |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
3972 | { |
|
8588
6bcf7ed80ed8
[gaim-migrate @ 9339]
Mark Doliner <markdoliner@pidgin.im>
parents:
8568
diff
changeset
|
3973 | 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
|
3974 | } |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
3975 | |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
3976 | 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
|
3977 | { |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
3978 | GtkIMHtmlHr *hr = (GtkIMHtmlHr *)scale; |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
3979 | GtkTextChildAnchor *anchor = gtk_text_buffer_create_child_anchor(imhtml->text_buffer, iter); |
| 8698 | 3980 | g_object_set_data(G_OBJECT(anchor), "gtkimhtml_htmltext", "<hr>"); |
| 3981 | g_object_set_data(G_OBJECT(anchor), "gtkimhtml_plaintext", "\n---\n"); | |
| 15420 | 3982 | 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
|
3983 | } |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
3984 | |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
3985 | void gtk_imhtml_hr_free(GtkIMHtmlScalable *scale) |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
3986 | { |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
3987 | g_free(scale); |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
3988 | } |
| 7295 | 3989 | |
| 3990 | gboolean gtk_imhtml_search_find(GtkIMHtml *imhtml, const gchar *text) | |
| 3991 | { | |
| 3992 | GtkTextIter iter, start, end; | |
| 3993 | gboolean new_search = TRUE; | |
|
14863
82888d51234c
[gaim-migrate @ 17566]
Daniel Atallah <datallah@pidgin.im>
parents:
14821
diff
changeset
|
3994 | GtkTextMark *start_mark; |
| 7295 | 3995 | |
| 3996 | g_return_val_if_fail(imhtml != NULL, FALSE); | |
| 3997 | g_return_val_if_fail(text != NULL, FALSE); | |
| 8061 | 3998 | |
|
14863
82888d51234c
[gaim-migrate @ 17566]
Daniel Atallah <datallah@pidgin.im>
parents:
14821
diff
changeset
|
3999 | start_mark = gtk_text_buffer_get_mark(imhtml->text_buffer, "search"); |
|
82888d51234c
[gaim-migrate @ 17566]
Daniel Atallah <datallah@pidgin.im>
parents:
14821
diff
changeset
|
4000 | |
|
82888d51234c
[gaim-migrate @ 17566]
Daniel Atallah <datallah@pidgin.im>
parents:
14821
diff
changeset
|
4001 | if (start_mark && imhtml->search_string && !strcmp(text, imhtml->search_string)) |
| 7295 | 4002 | new_search = FALSE; |
| 8061 | 4003 | |
| 7295 | 4004 | if (new_search) { |
| 4005 | gtk_imhtml_search_clear(imhtml); | |
|
14863
82888d51234c
[gaim-migrate @ 17566]
Daniel Atallah <datallah@pidgin.im>
parents:
14821
diff
changeset
|
4006 | g_free(imhtml->search_string); |
|
82888d51234c
[gaim-migrate @ 17566]
Daniel Atallah <datallah@pidgin.im>
parents:
14821
diff
changeset
|
4007 | imhtml->search_string = g_strdup(text); |
| 15093 | 4008 | gtk_text_buffer_get_end_iter(imhtml->text_buffer, &iter); |
| 7295 | 4009 | } else { |
| 4010 | 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
|
4011 | start_mark); |
| 7295 | 4012 | } |
| 4013 | ||
| 15093 | 4014 | if (gtk_source_iter_backward_search(&iter, imhtml->search_string, |
|
14400
953baf2eba1a
[gaim-migrate @ 17035]
Richard Laager <rlaager@pidgin.im>
parents:
14395
diff
changeset
|
4015 | GTK_SOURCE_SEARCH_VISIBLE_ONLY | GTK_SOURCE_SEARCH_CASE_INSENSITIVE, |
|
953baf2eba1a
[gaim-migrate @ 17035]
Richard Laager <rlaager@pidgin.im>
parents:
14395
diff
changeset
|
4016 | &start, &end, NULL)) |
|
953baf2eba1a
[gaim-migrate @ 17035]
Richard Laager <rlaager@pidgin.im>
parents:
14395
diff
changeset
|
4017 | { |
| 7295 | 4018 | gtk_text_view_scroll_to_iter(GTK_TEXT_VIEW(imhtml), &start, 0, TRUE, 0, 0); |
| 15093 | 4019 | 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
|
4020 | if (new_search) |
|
953baf2eba1a
[gaim-migrate @ 17035]
Richard Laager <rlaager@pidgin.im>
parents:
14395
diff
changeset
|
4021 | { |
| 7295 | 4022 | gtk_text_buffer_remove_tag_by_name(imhtml->text_buffer, "search", &iter, &end); |
| 8061 | 4023 | do |
| 7295 | 4024 | gtk_text_buffer_apply_tag_by_name(imhtml->text_buffer, "search", &start, &end); |
| 15093 | 4025 | while (gtk_source_iter_backward_search(&start, imhtml->search_string, |
| 8061 | 4026 | GTK_SOURCE_SEARCH_VISIBLE_ONLY | |
| 7358 | 4027 | GTK_SOURCE_SEARCH_CASE_INSENSITIVE, |
| 7295 | 4028 | &start, &end, NULL)); |
| 4029 | } | |
| 4030 | return TRUE; | |
| 4031 | } | |
|
14400
953baf2eba1a
[gaim-migrate @ 17035]
Richard Laager <rlaager@pidgin.im>
parents:
14395
diff
changeset
|
4032 | else if (!new_search) |
|
953baf2eba1a
[gaim-migrate @ 17035]
Richard Laager <rlaager@pidgin.im>
parents:
14395
diff
changeset
|
4033 | { |
|
953baf2eba1a
[gaim-migrate @ 17035]
Richard Laager <rlaager@pidgin.im>
parents:
14395
diff
changeset
|
4034 | /* We hit the end, so start at the beginning again. */ |
| 15093 | 4035 | gtk_text_buffer_get_end_iter(imhtml->text_buffer, &iter); |
| 4036 | ||
| 4037 | if (gtk_source_iter_backward_search(&iter, imhtml->search_string, | |
|
14400
953baf2eba1a
[gaim-migrate @ 17035]
Richard Laager <rlaager@pidgin.im>
parents:
14395
diff
changeset
|
4038 | GTK_SOURCE_SEARCH_VISIBLE_ONLY | GTK_SOURCE_SEARCH_CASE_INSENSITIVE, |
|
953baf2eba1a
[gaim-migrate @ 17035]
Richard Laager <rlaager@pidgin.im>
parents:
14395
diff
changeset
|
4039 | &start, &end, NULL)) |
|
953baf2eba1a
[gaim-migrate @ 17035]
Richard Laager <rlaager@pidgin.im>
parents:
14395
diff
changeset
|
4040 | { |
|
953baf2eba1a
[gaim-migrate @ 17035]
Richard Laager <rlaager@pidgin.im>
parents:
14395
diff
changeset
|
4041 | gtk_text_view_scroll_to_iter(GTK_TEXT_VIEW(imhtml), &start, 0, TRUE, 0, 0); |
| 15093 | 4042 | 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
|
4043 | |
|
953baf2eba1a
[gaim-migrate @ 17035]
Richard Laager <rlaager@pidgin.im>
parents:
14395
diff
changeset
|
4044 | return TRUE; |
|
953baf2eba1a
[gaim-migrate @ 17035]
Richard Laager <rlaager@pidgin.im>
parents:
14395
diff
changeset
|
4045 | } |
|
953baf2eba1a
[gaim-migrate @ 17035]
Richard Laager <rlaager@pidgin.im>
parents:
14395
diff
changeset
|
4046 | |
|
953baf2eba1a
[gaim-migrate @ 17035]
Richard Laager <rlaager@pidgin.im>
parents:
14395
diff
changeset
|
4047 | } |
| 8061 | 4048 | |
| 7295 | 4049 | return FALSE; |
| 4050 | } | |
| 4051 | ||
| 4052 | void gtk_imhtml_search_clear(GtkIMHtml *imhtml) | |
| 4053 | { | |
| 4054 | GtkTextIter start, end; | |
| 8061 | 4055 | |
| 7295 | 4056 | g_return_if_fail(imhtml != NULL); |
| 8061 | 4057 | |
| 7295 | 4058 | gtk_text_buffer_get_start_iter(imhtml->text_buffer, &start); |
| 4059 | gtk_text_buffer_get_end_iter(imhtml->text_buffer, &end); | |
| 4060 | ||
| 4061 | 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
|
4062 | g_free(imhtml->search_string); |
| 7295 | 4063 | imhtml->search_string = NULL; |
| 4064 | } | |
| 8061 | 4065 | |
| 8677 | 4066 | static GtkTextTag *find_font_forecolor_tag(GtkIMHtml *imhtml, gchar *color) |
| 4067 | { | |
| 4068 | gchar str[18]; | |
| 4069 | GtkTextTag *tag; | |
| 4070 | ||
| 4071 | g_snprintf(str, sizeof(str), "FORECOLOR %s", color); | |
| 4072 | ||
| 4073 | tag = gtk_text_tag_table_lookup(gtk_text_buffer_get_tag_table(imhtml->text_buffer), str); | |
| 10858 | 4074 | if (!tag) { |
| 4075 | GdkColor gcolor; | |
| 4076 | if (!gdk_color_parse(color, &gcolor)) { | |
| 4077 | gchar tmp[8]; | |
| 4078 | tmp[0] = '#'; | |
| 4079 | strncpy(&tmp[1], color, 7); | |
| 4080 | tmp[7] = '\0'; | |
| 4081 | if (!gdk_color_parse(tmp, &gcolor)) | |
| 4082 | gdk_color_parse("black", &gcolor); | |
| 4083 | } | |
| 4084 | tag = gtk_text_buffer_create_tag(imhtml->text_buffer, str, "foreground-gdk", &gcolor, NULL); | |
| 4085 | } | |
| 8677 | 4086 | |
| 4087 | return tag; | |
| 4088 | } | |
| 4089 | ||
| 4090 | static GtkTextTag *find_font_backcolor_tag(GtkIMHtml *imhtml, gchar *color) | |
| 4091 | { | |
| 4092 | gchar str[18]; | |
| 4093 | GtkTextTag *tag; | |
| 4094 | ||
| 4095 | g_snprintf(str, sizeof(str), "BACKCOLOR %s", color); | |
| 4096 | ||
| 4097 | tag = gtk_text_tag_table_lookup(gtk_text_buffer_get_tag_table(imhtml->text_buffer), str); | |
| 10858 | 4098 | if (!tag) { |
| 4099 | GdkColor gcolor; | |
| 4100 | if (!gdk_color_parse(color, &gcolor)) { | |
| 4101 | gchar tmp[8]; | |
| 4102 | tmp[0] = '#'; | |
| 4103 | strncpy(&tmp[1], color, 7); | |
| 4104 | tmp[7] = '\0'; | |
| 4105 | if (!gdk_color_parse(tmp, &gcolor)) | |
| 4106 | gdk_color_parse("white", &gcolor); | |
| 4107 | } | |
| 4108 | tag = gtk_text_buffer_create_tag(imhtml->text_buffer, str, "background-gdk", &gcolor, NULL); | |
| 4109 | } | |
| 8677 | 4110 | |
| 4111 | return tag; | |
| 4112 | } | |
| 4113 | ||
| 10776 | 4114 | static GtkTextTag *find_font_background_tag(GtkIMHtml *imhtml, gchar *color) |
| 4115 | { | |
| 4116 | gchar str[19]; | |
| 4117 | GtkTextTag *tag; | |
| 4118 | ||
| 4119 | g_snprintf(str, sizeof(str), "BACKGROUND %s", color); | |
| 4120 | ||
| 4121 | tag = gtk_text_tag_table_lookup(gtk_text_buffer_get_tag_table(imhtml->text_buffer), str); | |
| 4122 | if (!tag) | |
| 4123 | tag = gtk_text_buffer_create_tag(imhtml->text_buffer, str, NULL); | |
| 4124 | ||
| 4125 | return tag; | |
| 4126 | } | |
| 4127 | ||
| 8677 | 4128 | static GtkTextTag *find_font_face_tag(GtkIMHtml *imhtml, gchar *face) |
| 8061 | 4129 | { |
| 8677 | 4130 | gchar str[256]; |
| 4131 | GtkTextTag *tag; | |
| 4132 | ||
| 4133 | g_snprintf(str, sizeof(str), "FONT FACE %s", face); | |
| 4134 | str[255] = '\0'; | |
| 4135 | ||
| 4136 | tag = gtk_text_tag_table_lookup(gtk_text_buffer_get_tag_table(imhtml->text_buffer), str); | |
| 4137 | if (!tag) | |
| 4138 | tag = gtk_text_buffer_create_tag(imhtml->text_buffer, str, "family", face, NULL); | |
| 4139 | ||
| 4140 | return tag; | |
| 4141 | } | |
| 4142 | ||
| 4143 | static GtkTextTag *find_font_size_tag(GtkIMHtml *imhtml, int size) | |
| 4144 | { | |
| 4145 | gchar str[24]; | |
| 4146 | GtkTextTag *tag; | |
| 4147 | ||
| 4148 | g_snprintf(str, sizeof(str), "FONT SIZE %d", size); | |
| 4149 | str[23] = '\0'; | |
| 4150 | ||
| 4151 | tag = gtk_text_tag_table_lookup(gtk_text_buffer_get_tag_table(imhtml->text_buffer), str); | |
| 4152 | if (!tag) { | |
| 10525 | 4153 | /* For reasons I don't understand, setting "scale" here scaled |
| 4154 | * based on some default size other than my theme's default | |
| 4155 | * size. Our size 4 was actually smaller than our size 3 for | |
| 4156 | * me. So this works around that oddity. | |
| 8677 | 4157 | */ |
| 10525 | 4158 | GtkTextAttributes *attr = gtk_text_view_get_default_attributes(GTK_TEXT_VIEW(imhtml)); |
| 8677 | 4159 | tag = gtk_text_buffer_create_tag(imhtml->text_buffer, str, "size", |
| 10525 | 4160 | (gint) (pango_font_description_get_size(attr->font) * |
|
10899
87d9aec5b72d
[gaim-migrate @ 12619]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10871
diff
changeset
|
4161 | (double) POINT_SIZE(size)), NULL); |
| 10525 | 4162 | gtk_text_attributes_unref(attr); |
| 8061 | 4163 | } |
| 4164 | ||
| 8677 | 4165 | return tag; |
| 4166 | } | |
| 4167 | ||
| 4168 | static void remove_tag_by_prefix(GtkIMHtml *imhtml, const GtkTextIter *i, const GtkTextIter *e, | |
| 4169 | const char *prefix, guint len, gboolean homo) | |
| 4170 | { | |
| 4171 | GSList *tags, *l; | |
| 4172 | GtkTextIter iter; | |
| 4173 | ||
| 4174 | tags = gtk_text_iter_get_tags(i); | |
| 4175 | ||
| 4176 | for (l = tags; l; l = l->next) { | |
| 4177 | GtkTextTag *tag = l->data; | |
| 4178 | ||
| 4179 | if (tag->name && !strncmp(tag->name, prefix, len)) | |
| 4180 | gtk_text_buffer_remove_tag(imhtml->text_buffer, tag, i, e); | |
| 8061 | 4181 | } |
| 4182 | ||
| 8677 | 4183 | g_slist_free(tags); |
| 4184 | ||
| 4185 | if (homo) | |
| 4186 | return; | |
| 4187 | ||
| 4188 | iter = *i; | |
| 4189 | ||
| 4190 | while (gtk_text_iter_forward_char(&iter) && !gtk_text_iter_equal(&iter, e)) { | |
| 4191 | if (gtk_text_iter_begins_tag(&iter, NULL)) { | |
| 4192 | tags = gtk_text_iter_get_toggled_tags(&iter, TRUE); | |
| 4193 | ||
| 4194 | for (l = tags; l; l = l->next) { | |
| 4195 | GtkTextTag *tag = l->data; | |
| 4196 | ||
| 4197 | if (tag->name && !strncmp(tag->name, prefix, len)) | |
| 4198 | gtk_text_buffer_remove_tag(imhtml->text_buffer, tag, &iter, e); | |
| 4199 | } | |
| 4200 | ||
| 4201 | g_slist_free(tags); | |
| 4202 | } | |
| 8061 | 4203 | } |
| 8677 | 4204 | } |
| 4205 | ||
| 4206 | static void remove_font_size(GtkIMHtml *imhtml, GtkTextIter *i, GtkTextIter *e, gboolean homo) | |
| 4207 | { | |
| 4208 | remove_tag_by_prefix(imhtml, i, e, "FONT SIZE ", 10, homo); | |
| 4209 | } | |
| 4210 | ||
| 4211 | static void remove_font_face(GtkIMHtml *imhtml, GtkTextIter *i, GtkTextIter *e, gboolean homo) | |
| 4212 | { | |
| 4213 | remove_tag_by_prefix(imhtml, i, e, "FONT FACE ", 10, homo); | |
| 4214 | } | |
| 4215 | ||
| 4216 | static void remove_font_forecolor(GtkIMHtml *imhtml, GtkTextIter *i, GtkTextIter *e, gboolean homo) | |
| 4217 | { | |
| 4218 | remove_tag_by_prefix(imhtml, i, e, "FORECOLOR ", 10, homo); | |
| 4219 | } | |
| 4220 | ||
| 4221 | static void remove_font_backcolor(GtkIMHtml *imhtml, GtkTextIter *i, GtkTextIter *e, gboolean homo) | |
| 4222 | { | |
| 4223 | remove_tag_by_prefix(imhtml, i, e, "BACKCOLOR ", 10, homo); | |
| 4224 | } | |
| 4225 | ||
| 10776 | 4226 | static void remove_font_background(GtkIMHtml *imhtml, GtkTextIter *i, GtkTextIter *e, gboolean homo) |
| 4227 | { | |
| 4228 | remove_tag_by_prefix(imhtml, i, e, "BACKGROUND ", 10, homo); | |
| 4229 | } | |
| 4230 | ||
| 8677 | 4231 | static void remove_font_link(GtkIMHtml *imhtml, GtkTextIter *i, GtkTextIter *e, gboolean homo) |
| 4232 | { | |
| 4233 | remove_tag_by_prefix(imhtml, i, e, "LINK ", 5, homo); | |
| 4234 | } | |
| 4235 | ||
|
12672
673e2a1d2954
[gaim-migrate @ 15015]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12635
diff
changeset
|
4236 | static void |
|
673e2a1d2954
[gaim-migrate @ 15015]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12635
diff
changeset
|
4237 | imhtml_clear_formatting(GtkIMHtml *imhtml) |
|
673e2a1d2954
[gaim-migrate @ 15015]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12635
diff
changeset
|
4238 | { |
|
673e2a1d2954
[gaim-migrate @ 15015]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12635
diff
changeset
|
4239 | GtkTextIter start, end; |
|
673e2a1d2954
[gaim-migrate @ 15015]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12635
diff
changeset
|
4240 | |
|
12796
8fb3611a91e1
[gaim-migrate @ 15143]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12673
diff
changeset
|
4241 | if (!imhtml->editable) |
|
8fb3611a91e1
[gaim-migrate @ 15143]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12673
diff
changeset
|
4242 | return; |
|
8fb3611a91e1
[gaim-migrate @ 15143]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12673
diff
changeset
|
4243 | |
|
8fb3611a91e1
[gaim-migrate @ 15143]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12673
diff
changeset
|
4244 | if (imhtml->wbfo) |
|
8fb3611a91e1
[gaim-migrate @ 15143]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12673
diff
changeset
|
4245 | gtk_text_buffer_get_bounds(imhtml->text_buffer, &start, &end); |
|
8fb3611a91e1
[gaim-migrate @ 15143]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12673
diff
changeset
|
4246 | else |
|
8fb3611a91e1
[gaim-migrate @ 15143]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12673
diff
changeset
|
4247 | 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
|
4248 | 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
|
4249 | |
|
673e2a1d2954
[gaim-migrate @ 15015]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12635
diff
changeset
|
4250 | 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
|
4251 | 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
|
4252 | 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
|
4253 | 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
|
4254 | remove_font_size(imhtml, &start, &end, FALSE); |
|
485977c61b47
[gaim-migrate @ 15587]
Richard Laager <rlaager@pidgin.im>
parents:
13138
diff
changeset
|
4255 | remove_font_face(imhtml, &start, &end, FALSE); |
|
485977c61b47
[gaim-migrate @ 15587]
Richard Laager <rlaager@pidgin.im>
parents:
13138
diff
changeset
|
4256 | remove_font_forecolor(imhtml, &start, &end, FALSE); |
|
485977c61b47
[gaim-migrate @ 15587]
Richard Laager <rlaager@pidgin.im>
parents:
13138
diff
changeset
|
4257 | remove_font_backcolor(imhtml, &start, &end, FALSE); |
|
485977c61b47
[gaim-migrate @ 15587]
Richard Laager <rlaager@pidgin.im>
parents:
13138
diff
changeset
|
4258 | remove_font_background(imhtml, &start, &end, FALSE); |
|
485977c61b47
[gaim-migrate @ 15587]
Richard Laager <rlaager@pidgin.im>
parents:
13138
diff
changeset
|
4259 | remove_font_link(imhtml, &start, &end, FALSE); |
|
12672
673e2a1d2954
[gaim-migrate @ 15015]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12635
diff
changeset
|
4260 | |
|
673e2a1d2954
[gaim-migrate @ 15015]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12635
diff
changeset
|
4261 | imhtml->edit.bold = 0; |
|
673e2a1d2954
[gaim-migrate @ 15015]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12635
diff
changeset
|
4262 | imhtml->edit.italic = 0; |
|
673e2a1d2954
[gaim-migrate @ 15015]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12635
diff
changeset
|
4263 | imhtml->edit.underline = 0; |
|
673e2a1d2954
[gaim-migrate @ 15015]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12635
diff
changeset
|
4264 | imhtml->edit.strike = 0; |
|
673e2a1d2954
[gaim-migrate @ 15015]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12635
diff
changeset
|
4265 | imhtml->edit.fontsize = 0; |
|
13224
485977c61b47
[gaim-migrate @ 15587]
Richard Laager <rlaager@pidgin.im>
parents:
13138
diff
changeset
|
4266 | |
|
485977c61b47
[gaim-migrate @ 15587]
Richard Laager <rlaager@pidgin.im>
parents:
13138
diff
changeset
|
4267 | g_free(imhtml->edit.fontface); |
|
485977c61b47
[gaim-migrate @ 15587]
Richard Laager <rlaager@pidgin.im>
parents:
13138
diff
changeset
|
4268 | imhtml->edit.fontface = NULL; |
|
485977c61b47
[gaim-migrate @ 15587]
Richard Laager <rlaager@pidgin.im>
parents:
13138
diff
changeset
|
4269 | |
|
485977c61b47
[gaim-migrate @ 15587]
Richard Laager <rlaager@pidgin.im>
parents:
13138
diff
changeset
|
4270 | g_free(imhtml->edit.forecolor); |
|
12672
673e2a1d2954
[gaim-migrate @ 15015]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12635
diff
changeset
|
4271 | imhtml->edit.forecolor = NULL; |
|
13224
485977c61b47
[gaim-migrate @ 15587]
Richard Laager <rlaager@pidgin.im>
parents:
13138
diff
changeset
|
4272 | |
|
485977c61b47
[gaim-migrate @ 15587]
Richard Laager <rlaager@pidgin.im>
parents:
13138
diff
changeset
|
4273 | g_free(imhtml->edit.backcolor); |
|
12672
673e2a1d2954
[gaim-migrate @ 15015]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12635
diff
changeset
|
4274 | imhtml->edit.backcolor = NULL; |
|
13224
485977c61b47
[gaim-migrate @ 15587]
Richard Laager <rlaager@pidgin.im>
parents:
13138
diff
changeset
|
4275 | |
|
485977c61b47
[gaim-migrate @ 15587]
Richard Laager <rlaager@pidgin.im>
parents:
13138
diff
changeset
|
4276 | g_free(imhtml->edit.background); |
|
12672
673e2a1d2954
[gaim-migrate @ 15015]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12635
diff
changeset
|
4277 | imhtml->edit.background = NULL; |
|
673e2a1d2954
[gaim-migrate @ 15015]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12635
diff
changeset
|
4278 | } |
|
673e2a1d2954
[gaim-migrate @ 15015]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12635
diff
changeset
|
4279 | |
| 8677 | 4280 | /* Editable stuff */ |
| 4281 | static void preinsert_cb(GtkTextBuffer *buffer, GtkTextIter *iter, gchar *text, gint len, GtkIMHtml *imhtml) | |
| 4282 | { | |
| 4283 | imhtml->insert_offset = gtk_text_iter_get_offset(iter); | |
| 4284 | } | |
| 4285 | ||
| 10169 | 4286 | static void insert_ca_cb(GtkTextBuffer *buffer, GtkTextIter *arg1, GtkTextChildAnchor *arg2, gpointer user_data) |
| 4287 | { | |
| 4288 | GtkTextIter start; | |
| 4289 | ||
| 4290 | start = *arg1; | |
| 4291 | gtk_text_iter_backward_char(&start); | |
| 4292 | ||
| 4293 | gtk_imhtml_apply_tags_on_insert(user_data, &start, arg1); | |
| 4294 | } | |
| 4295 | ||
| 8677 | 4296 | static void insert_cb(GtkTextBuffer *buffer, GtkTextIter *end, gchar *text, gint len, GtkIMHtml *imhtml) |
| 4297 | { | |
| 4298 | GtkTextIter start; | |
| 4299 | ||
| 4300 | if (!len) | |
| 4301 | return; | |
| 4302 | ||
| 4303 | start = *end; | |
| 4304 | gtk_text_iter_set_offset(&start, imhtml->insert_offset); | |
| 4305 | ||
| 10169 | 4306 | gtk_imhtml_apply_tags_on_insert(imhtml, &start, end); |
| 4307 | } | |
| 4308 | ||
|
12673
4c8a20955e0b
[gaim-migrate @ 15016]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12672
diff
changeset
|
4309 | 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
|
4310 | { |
|
4c8a20955e0b
[gaim-migrate @ 15016]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12672
diff
changeset
|
4311 | GSList *tags, *l; |
|
4c8a20955e0b
[gaim-migrate @ 15016]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12672
diff
changeset
|
4312 | |
|
4c8a20955e0b
[gaim-migrate @ 15016]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12672
diff
changeset
|
4313 | tags = gtk_text_iter_get_tags(start); |
|
4c8a20955e0b
[gaim-migrate @ 15016]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12672
diff
changeset
|
4314 | for (l = tags; l != NULL; l = l->next) { |
|
4c8a20955e0b
[gaim-migrate @ 15016]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12672
diff
changeset
|
4315 | GtkTextTag *tag = GTK_TEXT_TAG(l->data); |
|
4c8a20955e0b
[gaim-migrate @ 15016]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12672
diff
changeset
|
4316 | |
|
4c8a20955e0b
[gaim-migrate @ 15016]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12672
diff
changeset
|
4317 | if (tag && /* Remove the formatting only if */ |
|
4c8a20955e0b
[gaim-migrate @ 15016]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12672
diff
changeset
|
4318 | gtk_text_iter_starts_word(start) && /* beginning of a word */ |
|
4c8a20955e0b
[gaim-migrate @ 15016]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12672
diff
changeset
|
4319 | 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
|
4320 | (!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
|
4321 | gtk_text_iter_ends_tag(end, tag))) { |
|
4c8a20955e0b
[gaim-migrate @ 15016]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12672
diff
changeset
|
4322 | 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
|
4323 | if (tag->name && |
|
4c8a20955e0b
[gaim-migrate @ 15016]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12672
diff
changeset
|
4324 | strncmp(tag->name, "LINK ", 5) == 0 && imhtml->edit.link) { |
|
4c8a20955e0b
[gaim-migrate @ 15016]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12672
diff
changeset
|
4325 | gtk_imhtml_toggle_link(imhtml, NULL); |
|
4c8a20955e0b
[gaim-migrate @ 15016]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12672
diff
changeset
|
4326 | } |
|
14097
0c340861ab79
[gaim-migrate @ 16638]
Mark Doliner <markdoliner@pidgin.im>
parents:
14010
diff
changeset
|
4327 | } |
|
12673
4c8a20955e0b
[gaim-migrate @ 15016]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12672
diff
changeset
|
4328 | } |
|
4c8a20955e0b
[gaim-migrate @ 15016]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12672
diff
changeset
|
4329 | g_slist_free(tags); |
|
4c8a20955e0b
[gaim-migrate @ 15016]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12672
diff
changeset
|
4330 | } |
|
4c8a20955e0b
[gaim-migrate @ 15016]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12672
diff
changeset
|
4331 | |
| 10169 | 4332 | static void gtk_imhtml_apply_tags_on_insert(GtkIMHtml *imhtml, GtkTextIter *start, GtkTextIter *end) |
| 4333 | { | |
| 8677 | 4334 | if (imhtml->edit.bold) |
| 10169 | 4335 | gtk_text_buffer_apply_tag_by_name(imhtml->text_buffer, "BOLD", start, end); |
| 8677 | 4336 | else |
| 10169 | 4337 | gtk_text_buffer_remove_tag_by_name(imhtml->text_buffer, "BOLD", start, end); |
| 8677 | 4338 | |
| 4339 | if (imhtml->edit.italic) | |
| 10169 | 4340 | gtk_text_buffer_apply_tag_by_name(imhtml->text_buffer, "ITALICS", start, end); |
| 8677 | 4341 | else |
| 10169 | 4342 | gtk_text_buffer_remove_tag_by_name(imhtml->text_buffer, "ITALICS", start, end); |
| 8677 | 4343 | |
| 4344 | if (imhtml->edit.underline) | |
| 10169 | 4345 | gtk_text_buffer_apply_tag_by_name(imhtml->text_buffer, "UNDERLINE", start, end); |
| 8677 | 4346 | else |
| 10169 | 4347 | gtk_text_buffer_remove_tag_by_name(imhtml->text_buffer, "UNDERLINE", start, end); |
| 8677 | 4348 | |
| 9924 | 4349 | if (imhtml->edit.strike) |
| 10169 | 4350 | gtk_text_buffer_apply_tag_by_name(imhtml->text_buffer, "STRIKE", start, end); |
| 9924 | 4351 | else |
| 10169 | 4352 | gtk_text_buffer_remove_tag_by_name(imhtml->text_buffer, "STRIKE", start, end); |
| 9924 | 4353 | |
| 8677 | 4354 | if (imhtml->edit.forecolor) { |
| 10169 | 4355 | remove_font_forecolor(imhtml, start, end, TRUE); |
| 8677 | 4356 | gtk_text_buffer_apply_tag(imhtml->text_buffer, |
| 4357 | find_font_forecolor_tag(imhtml, imhtml->edit.forecolor), | |
| 10169 | 4358 | start, end); |
| 8061 | 4359 | } |
| 4360 | ||
| 8677 | 4361 | if (imhtml->edit.backcolor) { |
| 10169 | 4362 | remove_font_backcolor(imhtml, start, end, TRUE); |
| 8677 | 4363 | gtk_text_buffer_apply_tag(imhtml->text_buffer, |
| 4364 | find_font_backcolor_tag(imhtml, imhtml->edit.backcolor), | |
| 10169 | 4365 | start, end); |
| 8677 | 4366 | } |
| 4367 | ||
| 10776 | 4368 | if (imhtml->edit.background) { |
| 4369 | remove_font_background(imhtml, start, end, TRUE); | |
| 4370 | gtk_text_buffer_apply_tag(imhtml->text_buffer, | |
| 4371 | find_font_background_tag(imhtml, imhtml->edit.background), | |
| 4372 | start, end); | |
| 4373 | } | |
| 8677 | 4374 | if (imhtml->edit.fontface) { |
| 10169 | 4375 | remove_font_face(imhtml, start, end, TRUE); |
| 8677 | 4376 | gtk_text_buffer_apply_tag(imhtml->text_buffer, |
| 4377 | find_font_face_tag(imhtml, imhtml->edit.fontface), | |
| 10169 | 4378 | start, end); |
| 8061 | 4379 | } |
| 8677 | 4380 | |
| 4381 | if (imhtml->edit.fontsize) { | |
| 10169 | 4382 | remove_font_size(imhtml, start, end, TRUE); |
| 8677 | 4383 | gtk_text_buffer_apply_tag(imhtml->text_buffer, |
| 4384 | find_font_size_tag(imhtml, imhtml->edit.fontsize), | |
| 10169 | 4385 | start, end); |
| 8677 | 4386 | } |
| 4387 | ||
| 4388 | if (imhtml->edit.link) { | |
| 10169 | 4389 | remove_font_link(imhtml, start, end, TRUE); |
| 8677 | 4390 | gtk_text_buffer_apply_tag(imhtml->text_buffer, |
| 4391 | imhtml->edit.link, | |
| 10169 | 4392 | start, end); |
| 8677 | 4393 | } |
| 8061 | 4394 | } |
| 4395 | ||
| 4396 | void gtk_imhtml_set_editable(GtkIMHtml *imhtml, gboolean editable) | |
| 4397 | { | |
| 4398 | gtk_text_view_set_editable(GTK_TEXT_VIEW(imhtml), editable); | |
|
8177
33b3a01c6318
[gaim-migrate @ 8891]
Mark Doliner <markdoliner@pidgin.im>
parents:
8149
diff
changeset
|
4399 | /* |
|
33b3a01c6318
[gaim-migrate @ 8891]
Mark Doliner <markdoliner@pidgin.im>
parents:
8149
diff
changeset
|
4400 | * We need a visible caret for accessibility, so mouseless |
|
33b3a01c6318
[gaim-migrate @ 8891]
Mark Doliner <markdoliner@pidgin.im>
parents:
8149
diff
changeset
|
4401 | * people can highlight stuff. |
|
33b3a01c6318
[gaim-migrate @ 8891]
Mark Doliner <markdoliner@pidgin.im>
parents:
8149
diff
changeset
|
4402 | */ |
|
33b3a01c6318
[gaim-migrate @ 8891]
Mark Doliner <markdoliner@pidgin.im>
parents:
8149
diff
changeset
|
4403 | /* gtk_text_view_set_cursor_visible(GTK_TEXT_VIEW(imhtml), editable); */ |
| 8061 | 4404 | imhtml->editable = editable; |
| 8677 | 4405 | imhtml->format_functions = GTK_IMHTML_ALL; |
| 4406 | ||
| 4407 | if (editable) | |
|
21765
b9271e416f6d
Patch from 'goutnet': Pressing backspace on a smiley will replace the smiley
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21644
diff
changeset
|
4408 | { |
| 8677 | 4409 | g_signal_connect_after(G_OBJECT(GTK_IMHTML(imhtml)->text_buffer), "mark-set", |
|
21765
b9271e416f6d
Patch from 'goutnet': Pressing backspace on a smiley will replace the smiley
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21644
diff
changeset
|
4410 | G_CALLBACK(mark_set_cb), imhtml); |
|
b9271e416f6d
Patch from 'goutnet': Pressing backspace on a smiley will replace the smiley
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21644
diff
changeset
|
4411 | g_signal_connect(G_OBJECT(imhtml), "backspace", G_CALLBACK(smart_backspace_cb), NULL); |
|
b9271e416f6d
Patch from 'goutnet': Pressing backspace on a smiley will replace the smiley
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21644
diff
changeset
|
4412 | } |
| 8677 | 4413 | } |
| 4414 | ||
| 4415 | void gtk_imhtml_set_whole_buffer_formatting_only(GtkIMHtml *imhtml, gboolean wbfo) | |
| 4416 | { | |
| 4417 | g_return_if_fail(imhtml != NULL); | |
| 4418 | ||
| 4419 | imhtml->wbfo = wbfo; | |
| 8420 | 4420 | } |
| 4421 | ||
| 4422 | void gtk_imhtml_set_format_functions(GtkIMHtml *imhtml, GtkIMHtmlButtons buttons) | |
| 4423 | { | |
| 4424 | GObject *object = g_object_ref(G_OBJECT(imhtml)); | |
| 8677 | 4425 | imhtml->format_functions = buttons; |
| 8420 | 4426 | g_signal_emit(object, signals[BUTTONS_UPDATE], 0, buttons); |
| 4427 | g_object_unref(object); | |
| 8061 | 4428 | } |
| 4429 | ||
|
8788
a13634443a38
[gaim-migrate @ 9550]
Mark Doliner <markdoliner@pidgin.im>
parents:
8786
diff
changeset
|
4430 | GtkIMHtmlButtons gtk_imhtml_get_format_functions(GtkIMHtml *imhtml) |
|
a13634443a38
[gaim-migrate @ 9550]
Mark Doliner <markdoliner@pidgin.im>
parents:
8786
diff
changeset
|
4431 | { |
|
a13634443a38
[gaim-migrate @ 9550]
Mark Doliner <markdoliner@pidgin.im>
parents:
8786
diff
changeset
|
4432 | return imhtml->format_functions; |
|
a13634443a38
[gaim-migrate @ 9550]
Mark Doliner <markdoliner@pidgin.im>
parents:
8786
diff
changeset
|
4433 | } |
| 8516 | 4434 | |
| 4435 | void gtk_imhtml_get_current_format(GtkIMHtml *imhtml, gboolean *bold, | |
| 4436 | gboolean *italic, gboolean *underline) | |
| 8481 | 4437 | { |
|
12900
7fe519669e07
[gaim-migrate @ 15253]
Richard Laager <rlaager@pidgin.im>
parents:
12836
diff
changeset
|
4438 | if (bold != NULL) |
|
7fe519669e07
[gaim-migrate @ 15253]
Richard Laager <rlaager@pidgin.im>
parents:
12836
diff
changeset
|
4439 | (*bold) = imhtml->edit.bold; |
|
7fe519669e07
[gaim-migrate @ 15253]
Richard Laager <rlaager@pidgin.im>
parents:
12836
diff
changeset
|
4440 | if (italic != NULL) |
|
7fe519669e07
[gaim-migrate @ 15253]
Richard Laager <rlaager@pidgin.im>
parents:
12836
diff
changeset
|
4441 | (*italic) = imhtml->edit.italic; |
|
7fe519669e07
[gaim-migrate @ 15253]
Richard Laager <rlaager@pidgin.im>
parents:
12836
diff
changeset
|
4442 | if (underline != NULL) |
|
7fe519669e07
[gaim-migrate @ 15253]
Richard Laager <rlaager@pidgin.im>
parents:
12836
diff
changeset
|
4443 | (*underline) = imhtml->edit.underline; |
| 8481 | 4444 | } |
| 4445 | ||
| 9025 | 4446 | char * |
| 4447 | gtk_imhtml_get_current_fontface(GtkIMHtml *imhtml) | |
| 4448 | { | |
|
14097
0c340861ab79
[gaim-migrate @ 16638]
Mark Doliner <markdoliner@pidgin.im>
parents:
14010
diff
changeset
|
4449 | return g_strdup(imhtml->edit.fontface); |
| 9025 | 4450 | } |
| 4451 | ||
| 4452 | char * | |
| 4453 | gtk_imhtml_get_current_forecolor(GtkIMHtml *imhtml) | |
| 4454 | { | |
|
14097
0c340861ab79
[gaim-migrate @ 16638]
Mark Doliner <markdoliner@pidgin.im>
parents:
14010
diff
changeset
|
4455 | return g_strdup(imhtml->edit.forecolor); |
| 9025 | 4456 | } |
| 4457 | ||
| 4458 | char * | |
| 4459 | gtk_imhtml_get_current_backcolor(GtkIMHtml *imhtml) | |
| 4460 | { | |
|
14097
0c340861ab79
[gaim-migrate @ 16638]
Mark Doliner <markdoliner@pidgin.im>
parents:
14010
diff
changeset
|
4461 | return g_strdup(imhtml->edit.backcolor); |
| 9025 | 4462 | } |
| 4463 | ||
|
11267
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
4464 | char * |
|
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
4465 | gtk_imhtml_get_current_background(GtkIMHtml *imhtml) |
|
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
4466 | { |
|
14097
0c340861ab79
[gaim-migrate @ 16638]
Mark Doliner <markdoliner@pidgin.im>
parents:
14010
diff
changeset
|
4467 | return g_strdup(imhtml->edit.background); |
|
11267
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
4468 | } |
|
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
4469 | |
| 9025 | 4470 | gint |
| 4471 | gtk_imhtml_get_current_fontsize(GtkIMHtml *imhtml) | |
| 4472 | { | |
| 4473 | return imhtml->edit.fontsize; | |
| 4474 | } | |
| 4475 | ||
| 8061 | 4476 | gboolean gtk_imhtml_get_editable(GtkIMHtml *imhtml) |
| 4477 | { | |
| 4478 | return imhtml->editable; | |
| 4479 | } | |
| 4480 | ||
|
11269
ca63789d57b9
[gaim-migrate @ 13451]
Richard Laager <rlaager@pidgin.im>
parents:
11267
diff
changeset
|
4481 | void |
|
ca63789d57b9
[gaim-migrate @ 13451]
Richard Laager <rlaager@pidgin.im>
parents:
11267
diff
changeset
|
4482 | gtk_imhtml_clear_formatting(GtkIMHtml *imhtml) |
|
ca63789d57b9
[gaim-migrate @ 13451]
Richard Laager <rlaager@pidgin.im>
parents:
11267
diff
changeset
|
4483 | { |
|
11275
cdcc651d7ecd
[gaim-migrate @ 13461]
Richard Laager <rlaager@pidgin.im>
parents:
11269
diff
changeset
|
4484 | GObject *object; |
|
cdcc651d7ecd
[gaim-migrate @ 13461]
Richard Laager <rlaager@pidgin.im>
parents:
11269
diff
changeset
|
4485 | |
|
cdcc651d7ecd
[gaim-migrate @ 13461]
Richard Laager <rlaager@pidgin.im>
parents:
11269
diff
changeset
|
4486 | object = g_object_ref(G_OBJECT(imhtml)); |
|
cdcc651d7ecd
[gaim-migrate @ 13461]
Richard Laager <rlaager@pidgin.im>
parents:
11269
diff
changeset
|
4487 | g_signal_emit(object, signals[CLEAR_FORMAT], 0); |
|
11276
aec923529d31
[gaim-migrate @ 13463]
Richard Laager <rlaager@pidgin.im>
parents:
11275
diff
changeset
|
4488 | |
|
11269
ca63789d57b9
[gaim-migrate @ 13451]
Richard Laager <rlaager@pidgin.im>
parents:
11267
diff
changeset
|
4489 | gtk_widget_grab_focus(GTK_WIDGET(imhtml)); |
|
11276
aec923529d31
[gaim-migrate @ 13463]
Richard Laager <rlaager@pidgin.im>
parents:
11275
diff
changeset
|
4490 | |
|
aec923529d31
[gaim-migrate @ 13463]
Richard Laager <rlaager@pidgin.im>
parents:
11275
diff
changeset
|
4491 | g_object_unref(object); |
|
11269
ca63789d57b9
[gaim-migrate @ 13451]
Richard Laager <rlaager@pidgin.im>
parents:
11267
diff
changeset
|
4492 | } |
|
ca63789d57b9
[gaim-migrate @ 13451]
Richard Laager <rlaager@pidgin.im>
parents:
11267
diff
changeset
|
4493 | |
| 8677 | 4494 | /* |
| 4495 | * I had this crazy idea about changing the text cursor color to reflex the foreground color | |
| 4496 | * of the text about to be entered. This is the place you'd do it, along with the place where | |
| 4497 | * we actually set a new foreground color. | |
| 15884 | 4498 | * I may not do this, because people will bitch about Purple overriding their gtk theme's cursor |
| 8677 | 4499 | * colors. |
| 4500 | * | |
| 4501 | * Just in case I do do this, I asked about what to set the secondary text cursor to. | |
| 4502 | * | |
| 8719 | 4503 | * (12:45:27) ?? ???: secondary_cursor_color = (rgb(background) + rgb(primary_cursor_color) ) / 2 |
| 4504 | * (12:45:55) ?? ???: understand? | |
| 8677 | 4505 | * (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
|
4506 | * (12:46:56) ?? ???: u might need to extract separate each color from RGB |
| 8677 | 4507 | */ |
| 4508 | ||
| 4509 | static void mark_set_cb(GtkTextBuffer *buffer, GtkTextIter *arg1, GtkTextMark *mark, | |
| 4510 | GtkIMHtml *imhtml) | |
| 4511 | { | |
| 4512 | GSList *tags, *l; | |
| 4513 | GtkTextIter iter; | |
| 4514 | ||
| 4515 | if (mark != gtk_text_buffer_get_insert(buffer)) | |
| 4516 | return; | |
| 4517 | ||
| 4518 | if (!gtk_text_buffer_get_char_count(buffer)) | |
| 4519 | return; | |
| 4520 | ||
| 9924 | 4521 | 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
|
4522 | g_free(imhtml->edit.forecolor); |
| 8677 | 4523 | imhtml->edit.forecolor = NULL; |
|
14097
0c340861ab79
[gaim-migrate @ 16638]
Mark Doliner <markdoliner@pidgin.im>
parents:
14010
diff
changeset
|
4524 | |
|
0c340861ab79
[gaim-migrate @ 16638]
Mark Doliner <markdoliner@pidgin.im>
parents:
14010
diff
changeset
|
4525 | g_free(imhtml->edit.backcolor); |
| 8677 | 4526 | imhtml->edit.backcolor = NULL; |
|
14097
0c340861ab79
[gaim-migrate @ 16638]
Mark Doliner <markdoliner@pidgin.im>
parents:
14010
diff
changeset
|
4527 | |
|
0c340861ab79
[gaim-migrate @ 16638]
Mark Doliner <markdoliner@pidgin.im>
parents:
14010
diff
changeset
|
4528 | g_free(imhtml->edit.fontface); |
| 8677 | 4529 | imhtml->edit.fontface = NULL; |
|
14097
0c340861ab79
[gaim-migrate @ 16638]
Mark Doliner <markdoliner@pidgin.im>
parents:
14010
diff
changeset
|
4530 | |
| 8677 | 4531 | imhtml->edit.fontsize = 0; |
| 4532 | imhtml->edit.link = NULL; | |
| 4533 | ||
| 4534 | gtk_text_buffer_get_iter_at_mark(imhtml->text_buffer, &iter, mark); | |
| 4535 | ||
| 4536 | ||
| 4537 | if (gtk_text_iter_is_end(&iter)) | |
| 4538 | tags = gtk_text_iter_get_toggled_tags(&iter, FALSE); | |
| 4539 | else | |
| 4540 | tags = gtk_text_iter_get_tags(&iter); | |
| 4541 | ||
| 4542 | for (l = tags; l != NULL; l = l->next) { | |
| 4543 | GtkTextTag *tag = GTK_TEXT_TAG(l->data); | |
| 4544 | ||
| 4545 | if (tag->name) { | |
| 4546 | if (strcmp(tag->name, "BOLD") == 0) | |
| 4547 | imhtml->edit.bold = TRUE; | |
|
13138
4d3bd039da3e
[gaim-migrate @ 15499]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13137
diff
changeset
|
4548 | else if (strcmp(tag->name, "ITALICS") == 0) |
| 8677 | 4549 | imhtml->edit.italic = TRUE; |
|
13138
4d3bd039da3e
[gaim-migrate @ 15499]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13137
diff
changeset
|
4550 | else if (strcmp(tag->name, "UNDERLINE") == 0) |
| 8677 | 4551 | imhtml->edit.underline = TRUE; |
|
13138
4d3bd039da3e
[gaim-migrate @ 15499]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13137
diff
changeset
|
4552 | else if (strcmp(tag->name, "STRIKE") == 0) |
| 9924 | 4553 | imhtml->edit.strike = TRUE; |
|
13138
4d3bd039da3e
[gaim-migrate @ 15499]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13137
diff
changeset
|
4554 | else if (strncmp(tag->name, "FORECOLOR ", 10) == 0) |
| 8677 | 4555 | imhtml->edit.forecolor = g_strdup(&(tag->name)[10]); |
|
13138
4d3bd039da3e
[gaim-migrate @ 15499]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13137
diff
changeset
|
4556 | else if (strncmp(tag->name, "BACKCOLOR ", 10) == 0) |
| 8677 | 4557 | imhtml->edit.backcolor = g_strdup(&(tag->name)[10]); |
|
13138
4d3bd039da3e
[gaim-migrate @ 15499]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13137
diff
changeset
|
4558 | else if (strncmp(tag->name, "FONT FACE ", 10) == 0) |
| 8677 | 4559 | imhtml->edit.fontface = g_strdup(&(tag->name)[10]); |
|
13138
4d3bd039da3e
[gaim-migrate @ 15499]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13137
diff
changeset
|
4560 | else if (strncmp(tag->name, "FONT SIZE ", 10) == 0) |
| 8677 | 4561 | imhtml->edit.fontsize = strtol(&(tag->name)[10], NULL, 10); |
|
13138
4d3bd039da3e
[gaim-migrate @ 15499]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13137
diff
changeset
|
4562 | else if ((strncmp(tag->name, "LINK ", 5) == 0) && !gtk_text_iter_is_end(&iter)) |
| 8677 | 4563 | imhtml->edit.link = tag; |
| 4564 | } | |
| 4565 | } | |
| 4566 | ||
| 4567 | g_slist_free(tags); | |
| 4568 | } | |
| 4569 | ||
|
12605
7390627a6aaf
[gaim-migrate @ 14940]
Richard Laager <rlaager@pidgin.im>
parents:
12600
diff
changeset
|
4570 | static void imhtml_emit_signal_for_format(GtkIMHtml *imhtml, GtkIMHtmlButtons button) |
|
7390627a6aaf
[gaim-migrate @ 14940]
Richard Laager <rlaager@pidgin.im>
parents:
12600
diff
changeset
|
4571 | { |
|
7390627a6aaf
[gaim-migrate @ 14940]
Richard Laager <rlaager@pidgin.im>
parents:
12600
diff
changeset
|
4572 | GObject *object; |
|
7390627a6aaf
[gaim-migrate @ 14940]
Richard Laager <rlaager@pidgin.im>
parents:
12600
diff
changeset
|
4573 | |
|
7390627a6aaf
[gaim-migrate @ 14940]
Richard Laager <rlaager@pidgin.im>
parents:
12600
diff
changeset
|
4574 | g_return_if_fail(imhtml != NULL); |
|
7390627a6aaf
[gaim-migrate @ 14940]
Richard Laager <rlaager@pidgin.im>
parents:
12600
diff
changeset
|
4575 | |
|
7390627a6aaf
[gaim-migrate @ 14940]
Richard Laager <rlaager@pidgin.im>
parents:
12600
diff
changeset
|
4576 | object = g_object_ref(G_OBJECT(imhtml)); |
|
7390627a6aaf
[gaim-migrate @ 14940]
Richard Laager <rlaager@pidgin.im>
parents:
12600
diff
changeset
|
4577 | g_signal_emit(object, signals[TOGGLE_FORMAT], 0, button); |
|
7390627a6aaf
[gaim-migrate @ 14940]
Richard Laager <rlaager@pidgin.im>
parents:
12600
diff
changeset
|
4578 | g_object_unref(object); |
|
7390627a6aaf
[gaim-migrate @ 14940]
Richard Laager <rlaager@pidgin.im>
parents:
12600
diff
changeset
|
4579 | } |
|
7390627a6aaf
[gaim-migrate @ 14940]
Richard Laager <rlaager@pidgin.im>
parents:
12600
diff
changeset
|
4580 | |
|
11267
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
4581 | static void imhtml_toggle_bold(GtkIMHtml *imhtml) |
| 8061 | 4582 | { |
| 8677 | 4583 | GtkTextIter start, end; |
| 4584 | ||
| 4585 | imhtml->edit.bold = !imhtml->edit.bold; | |
| 4586 | ||
| 4587 | if (imhtml->wbfo) { | |
| 4588 | gtk_text_buffer_get_bounds(imhtml->text_buffer, &start, &end); | |
| 4589 | if (imhtml->edit.bold) | |
| 4590 | gtk_text_buffer_apply_tag_by_name(imhtml->text_buffer, "BOLD", &start, &end); | |
| 4591 | else | |
| 4592 | 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
|
4593 | } else if (imhtml->editable && gtk_text_buffer_get_selection_bounds(imhtml->text_buffer, &start, &end)) { |
| 8677 | 4594 | if (imhtml->edit.bold) |
| 4595 | gtk_text_buffer_apply_tag_by_name(imhtml->text_buffer, "BOLD", &start, &end); | |
| 4596 | else | |
| 4597 | 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
|
4598 | |
| 8061 | 4599 | } |
| 4600 | } | |
| 4601 | ||
|
11267
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
4602 | void gtk_imhtml_toggle_bold(GtkIMHtml *imhtml) |
| 8061 | 4603 | { |
|
12605
7390627a6aaf
[gaim-migrate @ 14940]
Richard Laager <rlaager@pidgin.im>
parents:
12600
diff
changeset
|
4604 | imhtml_emit_signal_for_format(imhtml, GTK_IMHTML_BOLD); |
|
11267
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
4605 | } |
|
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
4606 | |
|
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
4607 | static void imhtml_toggle_italic(GtkIMHtml *imhtml) |
|
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
4608 | { |
| 8677 | 4609 | GtkTextIter start, end; |
| 4610 | ||
| 4611 | imhtml->edit.italic = !imhtml->edit.italic; | |
| 4612 | ||
| 4613 | if (imhtml->wbfo) { | |
| 4614 | gtk_text_buffer_get_bounds(imhtml->text_buffer, &start, &end); | |
| 4615 | if (imhtml->edit.italic) | |
| 4616 | gtk_text_buffer_apply_tag_by_name(imhtml->text_buffer, "ITALICS", &start, &end); | |
| 4617 | else | |
| 4618 | 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
|
4619 | } 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
|
4620 | if (imhtml->edit.italic) |
| 8677 | 4621 | gtk_text_buffer_apply_tag_by_name(imhtml->text_buffer, "ITALICS", &start, &end); |
| 4622 | else | |
| 4623 | gtk_text_buffer_remove_tag_by_name(imhtml->text_buffer, "ITALICS", &start, &end); | |
| 8061 | 4624 | } |
| 4625 | } | |
| 4626 | ||
|
11267
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
4627 | void gtk_imhtml_toggle_italic(GtkIMHtml *imhtml) |
| 8061 | 4628 | { |
|
12605
7390627a6aaf
[gaim-migrate @ 14940]
Richard Laager <rlaager@pidgin.im>
parents:
12600
diff
changeset
|
4629 | imhtml_emit_signal_for_format(imhtml, GTK_IMHTML_ITALIC); |
|
7390627a6aaf
[gaim-migrate @ 14940]
Richard Laager <rlaager@pidgin.im>
parents:
12600
diff
changeset
|
4630 | } |
|
11267
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
4631 | |
|
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
4632 | static void imhtml_toggle_underline(GtkIMHtml *imhtml) |
|
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
4633 | { |
| 8677 | 4634 | GtkTextIter start, end; |
| 4635 | ||
| 4636 | imhtml->edit.underline = !imhtml->edit.underline; | |
| 4637 | ||
| 4638 | if (imhtml->wbfo) { | |
| 4639 | gtk_text_buffer_get_bounds(imhtml->text_buffer, &start, &end); | |
| 4640 | if (imhtml->edit.underline) | |
| 4641 | gtk_text_buffer_apply_tag_by_name(imhtml->text_buffer, "UNDERLINE", &start, &end); | |
| 4642 | else | |
| 4643 | 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
|
4644 | } 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
|
4645 | if (imhtml->edit.underline) |
| 8677 | 4646 | gtk_text_buffer_apply_tag_by_name(imhtml->text_buffer, "UNDERLINE", &start, &end); |
| 4647 | else | |
| 4648 | gtk_text_buffer_remove_tag_by_name(imhtml->text_buffer, "UNDERLINE", &start, &end); | |
| 8061 | 4649 | } |
| 4650 | } | |
| 4651 | ||
|
11267
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
4652 | void gtk_imhtml_toggle_underline(GtkIMHtml *imhtml) |
| 9924 | 4653 | { |
|
12605
7390627a6aaf
[gaim-migrate @ 14940]
Richard Laager <rlaager@pidgin.im>
parents:
12600
diff
changeset
|
4654 | imhtml_emit_signal_for_format(imhtml, GTK_IMHTML_UNDERLINE); |
|
11267
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
4655 | } |
|
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
4656 | |
|
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
4657 | static void imhtml_toggle_strike(GtkIMHtml *imhtml) |
|
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
4658 | { |
| 9924 | 4659 | GtkTextIter start, end; |
| 4660 | ||
| 4661 | imhtml->edit.strike = !imhtml->edit.strike; | |
| 4662 | ||
| 4663 | if (imhtml->wbfo) { | |
| 4664 | gtk_text_buffer_get_bounds(imhtml->text_buffer, &start, &end); | |
| 4665 | if (imhtml->edit.strike) | |
| 4666 | gtk_text_buffer_apply_tag_by_name(imhtml->text_buffer, "STRIKE", &start, &end); | |
| 4667 | else | |
| 4668 | 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
|
4669 | } 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
|
4670 | if (imhtml->edit.strike) |
| 9924 | 4671 | gtk_text_buffer_apply_tag_by_name(imhtml->text_buffer, "STRIKE", &start, &end); |
| 4672 | else | |
| 4673 | gtk_text_buffer_remove_tag_by_name(imhtml->text_buffer, "STRIKE", &start, &end); | |
| 4674 | } | |
|
11267
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
4675 | } |
|
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
4676 | |
|
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
4677 | void gtk_imhtml_toggle_strike(GtkIMHtml *imhtml) |
|
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
4678 | { |
|
12605
7390627a6aaf
[gaim-migrate @ 14940]
Richard Laager <rlaager@pidgin.im>
parents:
12600
diff
changeset
|
4679 | imhtml_emit_signal_for_format(imhtml, GTK_IMHTML_STRIKE); |
| 9924 | 4680 | } |
| 4681 | ||
| 8061 | 4682 | void gtk_imhtml_font_set_size(GtkIMHtml *imhtml, gint size) |
| 4683 | { | |
| 9025 | 4684 | GObject *object; |
| 8677 | 4685 | GtkTextIter start, end; |
| 8061 | 4686 | |
| 4687 | imhtml->edit.fontsize = size; | |
| 4688 | ||
| 8677 | 4689 | if (imhtml->wbfo) { |
| 4690 | gtk_text_buffer_get_bounds(imhtml->text_buffer, &start, &end); | |
| 4691 | remove_font_size(imhtml, &start, &end, TRUE); | |
| 4692 | gtk_text_buffer_apply_tag(imhtml->text_buffer, | |
| 4693 | find_font_size_tag(imhtml, imhtml->edit.fontsize), &start, &end); | |
|
11276
aec923529d31
[gaim-migrate @ 13463]
Richard Laager <rlaager@pidgin.im>
parents:
11275
diff
changeset
|
4694 | } else if (imhtml->editable && gtk_text_buffer_get_selection_bounds(imhtml->text_buffer, &start, &end)) { |
| 8677 | 4695 | remove_font_size(imhtml, &start, &end, FALSE); |
| 4696 | gtk_text_buffer_apply_tag(imhtml->text_buffer, | |
| 4697 | find_font_size_tag(imhtml, imhtml->edit.fontsize), &start, &end); | |
| 8061 | 4698 | } |
| 8677 | 4699 | |
| 9025 | 4700 | object = g_object_ref(G_OBJECT(imhtml)); |
|
11267
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
4701 | g_signal_emit(object, signals[TOGGLE_FORMAT], 0, GTK_IMHTML_SHRINK | GTK_IMHTML_GROW); |
| 9025 | 4702 | g_object_unref(object); |
| 8061 | 4703 | } |
| 4704 | ||
|
11267
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
4705 | static void imhtml_font_shrink(GtkIMHtml *imhtml) |
| 8061 | 4706 | { |
| 8677 | 4707 | GtkTextIter start, end; |
| 4708 | ||
| 8061 | 4709 | if (imhtml->edit.fontsize == 1) |
| 4710 | return; | |
| 4711 | ||
| 8677 | 4712 | if (!imhtml->edit.fontsize) |
| 4713 | imhtml->edit.fontsize = 2; | |
| 4714 | else | |
| 4715 | imhtml->edit.fontsize--; | |
| 4716 | ||
| 4717 | if (imhtml->wbfo) { | |
| 4718 | gtk_text_buffer_get_bounds(imhtml->text_buffer, &start, &end); | |
| 4719 | remove_font_size(imhtml, &start, &end, TRUE); | |
| 4720 | gtk_text_buffer_apply_tag(imhtml->text_buffer, | |
| 4721 | find_font_size_tag(imhtml, imhtml->edit.fontsize), &start, &end); | |
|
11276
aec923529d31
[gaim-migrate @ 13463]
Richard Laager <rlaager@pidgin.im>
parents:
11275
diff
changeset
|
4722 | } else if (imhtml->editable && gtk_text_buffer_get_selection_bounds(imhtml->text_buffer, &start, &end)) { |
| 8677 | 4723 | remove_font_size(imhtml, &start, &end, FALSE); |
| 4724 | gtk_text_buffer_apply_tag(imhtml->text_buffer, | |
| 4725 | find_font_size_tag(imhtml, imhtml->edit.fontsize), &start, &end); | |
| 8061 | 4726 | } |
|
11267
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
4727 | } |
|
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
4728 | |
|
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
4729 | void gtk_imhtml_font_shrink(GtkIMHtml *imhtml) |
|
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
4730 | { |
|
12605
7390627a6aaf
[gaim-migrate @ 14940]
Richard Laager <rlaager@pidgin.im>
parents:
12600
diff
changeset
|
4731 | imhtml_emit_signal_for_format(imhtml, GTK_IMHTML_SHRINK); |
| 8061 | 4732 | } |
| 4733 | ||
|
11267
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
4734 | static void imhtml_font_grow(GtkIMHtml *imhtml) |
| 8061 | 4735 | { |
| 8677 | 4736 | GtkTextIter start, end; |
| 4737 | ||
| 8061 | 4738 | if (imhtml->edit.fontsize == MAX_FONT_SIZE) |
| 4739 | return; | |
| 4740 | ||
| 8677 | 4741 | if (!imhtml->edit.fontsize) |
| 4742 | imhtml->edit.fontsize = 4; | |
| 4743 | else | |
| 4744 | imhtml->edit.fontsize++; | |
| 4745 | ||
| 4746 | if (imhtml->wbfo) { | |
| 4747 | gtk_text_buffer_get_bounds(imhtml->text_buffer, &start, &end); | |
| 4748 | remove_font_size(imhtml, &start, &end, TRUE); | |
| 4749 | gtk_text_buffer_apply_tag(imhtml->text_buffer, | |
| 4750 | find_font_size_tag(imhtml, imhtml->edit.fontsize), &start, &end); | |
|
11276
aec923529d31
[gaim-migrate @ 13463]
Richard Laager <rlaager@pidgin.im>
parents:
11275
diff
changeset
|
4751 | } else if (imhtml->editable && gtk_text_buffer_get_selection_bounds(imhtml->text_buffer, &start, &end)) { |
| 8677 | 4752 | remove_font_size(imhtml, &start, &end, FALSE); |
| 4753 | gtk_text_buffer_apply_tag(imhtml->text_buffer, | |
| 4754 | find_font_size_tag(imhtml, imhtml->edit.fontsize), &start, &end); | |
| 8061 | 4755 | } |
|
11267
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
4756 | } |
|
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
4757 | |
|
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
4758 | void gtk_imhtml_font_grow(GtkIMHtml *imhtml) |
|
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
4759 | { |
|
12605
7390627a6aaf
[gaim-migrate @ 14940]
Richard Laager <rlaager@pidgin.im>
parents:
12600
diff
changeset
|
4760 | imhtml_emit_signal_for_format(imhtml, GTK_IMHTML_GROW); |
| 8061 | 4761 | } |
| 4762 | ||
|
13225
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4763 | 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
|
4764 | void (*remove_func)(GtkIMHtml *imhtml, GtkTextIter *i, GtkTextIter *e, gboolean homo), |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4765 | GtkTextTag *(find_func)(GtkIMHtml *imhtml, gchar *color), GtkIMHtmlButtons button) |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4766 | { |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4767 | GObject *object; |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4768 | GtkTextIter start; |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4769 | GtkTextIter end; |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4770 | |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4771 | g_free(*edit_field); |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4772 | *edit_field = NULL; |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4773 | |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4774 | if (value && strcmp(value, "") != 0) |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4775 | { |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4776 | *edit_field = g_strdup(value); |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4777 | |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4778 | if (imhtml->wbfo) |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4779 | { |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4780 | gtk_text_buffer_get_bounds(imhtml->text_buffer, &start, &end); |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4781 | remove_func(imhtml, &start, &end, TRUE); |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4782 | gtk_text_buffer_apply_tag(imhtml->text_buffer, |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4783 | find_func(imhtml, *edit_field), &start, &end); |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4784 | } |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4785 | else |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4786 | { |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4787 | gtk_text_buffer_get_iter_at_mark(imhtml->text_buffer, &start, |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4788 | gtk_text_buffer_get_mark(imhtml->text_buffer, "insert")); |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4789 | 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
|
4790 | { |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4791 | remove_func(imhtml, &start, &end, FALSE); |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4792 | gtk_text_buffer_apply_tag(imhtml->text_buffer, |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4793 | find_func(imhtml, |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4794 | *edit_field), |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4795 | &start, &end); |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4796 | } |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4797 | } |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4798 | } |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4799 | else |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4800 | { |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4801 | if (imhtml->wbfo) |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4802 | { |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4803 | gtk_text_buffer_get_bounds(imhtml->text_buffer, &start, &end); |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4804 | remove_func(imhtml, &start, &end, TRUE); |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4805 | } |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4806 | else |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4807 | { |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4808 | 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
|
4809 | remove_func(imhtml, &start, &end, TRUE); |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4810 | } |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4811 | } |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4812 | |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4813 | object = g_object_ref(G_OBJECT(imhtml)); |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4814 | g_signal_emit(object, signals[TOGGLE_FORMAT], 0, button); |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4815 | g_object_unref(object); |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4816 | |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4817 | return *edit_field != NULL; |
| 10776 | 4818 | } |
| 4819 | ||
| 8061 | 4820 | gboolean gtk_imhtml_toggle_forecolor(GtkIMHtml *imhtml, const char *color) |
| 4821 | { | |
|
13225
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4822 | return gtk_imhtml_toggle_str_tag(imhtml, color, &imhtml->edit.forecolor, |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4823 | remove_font_forecolor, find_font_forecolor_tag, |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4824 | GTK_IMHTML_FORECOLOR); |
| 8061 | 4825 | } |
| 4826 | ||
| 4827 | gboolean gtk_imhtml_toggle_backcolor(GtkIMHtml *imhtml, const char *color) | |
| 4828 | { | |
|
13225
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4829 | return gtk_imhtml_toggle_str_tag(imhtml, color, &imhtml->edit.backcolor, |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4830 | remove_font_backcolor, find_font_backcolor_tag, |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4831 | GTK_IMHTML_BACKCOLOR); |
| 10776 | 4832 | } |
| 4833 | ||
| 4834 | gboolean gtk_imhtml_toggle_background(GtkIMHtml *imhtml, const char *color) | |
| 4835 | { | |
|
13225
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4836 | return gtk_imhtml_toggle_str_tag(imhtml, color, &imhtml->edit.background, |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4837 | remove_font_background, find_font_background_tag, |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4838 | GTK_IMHTML_BACKGROUND); |
| 8061 | 4839 | } |
| 4840 | ||
| 4841 | gboolean gtk_imhtml_toggle_fontface(GtkIMHtml *imhtml, const char *face) | |
| 4842 | { | |
|
13225
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4843 | return gtk_imhtml_toggle_str_tag(imhtml, face, &imhtml->edit.fontface, |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4844 | remove_font_face, find_font_face_tag, |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4845 | GTK_IMHTML_FACE); |
| 8061 | 4846 | } |
| 4847 | ||
| 8677 | 4848 | void gtk_imhtml_toggle_link(GtkIMHtml *imhtml, const char *url) |
| 8061 | 4849 | { |
| 9025 | 4850 | GObject *object; |
| 8677 | 4851 | GtkTextIter start, end; |
| 4852 | GtkTextTag *linktag; | |
| 4853 | static guint linkno = 0; | |
| 4854 | gchar str[48]; | |
| 9007 | 4855 | GdkColor *color = NULL; |
| 8677 | 4856 | |
| 4857 | imhtml->edit.link = NULL; | |
| 4858 | ||
| 4859 | if (url) { | |
| 4860 | g_snprintf(str, sizeof(str), "LINK %d", linkno++); | |
| 4861 | str[47] = '\0'; | |
| 4862 | ||
| 9007 | 4863 | gtk_widget_style_get(GTK_WIDGET(imhtml), "hyperlink-color", &color, NULL); |
| 9008 | 4864 | if (color) { |
| 9007 | 4865 | imhtml->edit.link = linktag = gtk_text_buffer_create_tag(imhtml->text_buffer, str, "foreground-gdk", color, "underline", PANGO_UNDERLINE_SINGLE, NULL); |
| 9008 | 4866 | gdk_color_free(color); |
| 4867 | } else { | |
| 9007 | 4868 | imhtml->edit.link = linktag = gtk_text_buffer_create_tag(imhtml->text_buffer, str, "foreground", "blue", "underline", PANGO_UNDERLINE_SINGLE, NULL); |
| 9008 | 4869 | } |
| 8677 | 4870 | g_object_set_data_full(G_OBJECT(linktag), "link_url", g_strdup(url), g_free); |
| 4871 | g_signal_connect(G_OBJECT(linktag), "event", G_CALLBACK(tag_event), NULL); | |
| 4872 | ||
|
11276
aec923529d31
[gaim-migrate @ 13463]
Richard Laager <rlaager@pidgin.im>
parents:
11275
diff
changeset
|
4873 | if (imhtml->editable && gtk_text_buffer_get_selection_bounds(imhtml->text_buffer, &start, &end)) { |
| 8677 | 4874 | remove_font_link(imhtml, &start, &end, FALSE); |
| 4875 | gtk_text_buffer_apply_tag(imhtml->text_buffer, linktag, &start, &end); | |
| 4876 | } | |
| 4877 | } | |
| 9025 | 4878 | |
| 4879 | object = g_object_ref(G_OBJECT(imhtml)); | |
| 4880 | g_signal_emit(object, signals[TOGGLE_FORMAT], 0, GTK_IMHTML_LINK); | |
| 4881 | g_object_unref(object); | |
| 8677 | 4882 | } |
| 4883 | ||
| 4884 | void gtk_imhtml_insert_link(GtkIMHtml *imhtml, GtkTextMark *mark, const char *url, const char *text) | |
| 4885 | { | |
| 8061 | 4886 | GtkTextIter iter; |
| 8677 | 4887 | |
| 9599 | 4888 | if (gtk_text_buffer_get_selection_bounds(imhtml->text_buffer, NULL, NULL)) |
| 4889 | gtk_text_buffer_delete_selection(imhtml->text_buffer, TRUE, TRUE); | |
| 4890 | ||
| 8677 | 4891 | gtk_imhtml_toggle_link(imhtml, url); |
| 8061 | 4892 | gtk_text_buffer_get_iter_at_mark(imhtml->text_buffer, &iter, mark); |
| 8677 | 4893 | gtk_text_buffer_insert(imhtml->text_buffer, &iter, text, -1); |
| 4894 | gtk_imhtml_toggle_link(imhtml, NULL); | |
| 8061 | 4895 | } |
| 4896 | ||
| 4897 | void gtk_imhtml_insert_smiley(GtkIMHtml *imhtml, const char *sml, char *smiley) | |
| 4898 | { | |
| 8677 | 4899 | GtkTextMark *mark; |
| 8061 | 4900 | GtkTextIter iter; |
| 8677 | 4901 | |
|
11750
63f951281392
[gaim-migrate @ 14041]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11701
diff
changeset
|
4902 | 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
|
4903 | gtk_text_buffer_delete_selection(imhtml->text_buffer, TRUE, TRUE); |
|
63f951281392
[gaim-migrate @ 14041]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11701
diff
changeset
|
4904 | |
| 8677 | 4905 | mark = gtk_text_buffer_get_insert(imhtml->text_buffer); |
| 4906 | ||
| 4907 | gtk_text_buffer_get_iter_at_mark(imhtml->text_buffer, &iter, mark); | |
| 4908 | gtk_imhtml_insert_smiley_at_iter(imhtml, sml, smiley, &iter); | |
| 4909 | } | |
| 4910 | ||
| 13552 | 4911 | static gboolean |
| 4912 | image_expose(GtkWidget *widget, GdkEventExpose *event, gpointer user_data) | |
| 4913 | { | |
| 4914 | GTK_WIDGET_CLASS(GTK_WIDGET_GET_CLASS(widget))->expose_event(widget, event); | |
| 4915 | ||
| 4916 | return TRUE; | |
| 4917 | } | |
| 4918 | ||
|
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
|
4919 | /* 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
|
4920 | 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
|
4921 | { |
|
aa5b9456e258
Fixes #213 This allows only 20 animated smileys to be animnating at a time
Sean Egan <seanegan@pidgin.im>
parents:
16291
diff
changeset
|
4922 | 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
|
4923 | 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
|
4924 | 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
|
4925 | 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
|
4926 | 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
|
4927 | 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
|
4928 | 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
|
4929 | 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
|
4930 | } |
|
aa5b9456e258
Fixes #213 This allows only 20 animated smileys to be animnating at a time
Sean Egan <seanegan@pidgin.im>
parents:
16291
diff
changeset
|
4931 | 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
|
4932 | } |
|
aa5b9456e258
Fixes #213 This allows only 20 animated smileys to be animnating at a time
Sean Egan <seanegan@pidgin.im>
parents:
16291
diff
changeset
|
4933 | } |
|
aa5b9456e258
Fixes #213 This allows only 20 animated smileys to be animnating at a time
Sean Egan <seanegan@pidgin.im>
parents:
16291
diff
changeset
|
4934 | |
| 8677 | 4935 | void gtk_imhtml_insert_smiley_at_iter(GtkIMHtml *imhtml, const char *sml, char *smiley, GtkTextIter *iter) |
| 4936 | { | |
| 8061 | 4937 | GdkPixbuf *pixbuf = NULL; |
| 4938 | GdkPixbufAnimation *annipixbuf = NULL; | |
| 4939 | 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
|
4940 | GtkTextChildAnchor *anchor = NULL; |
| 15884 | 4941 | char *unescaped = purple_unescape_html(smiley); |
|
11525
1d06283bdcc9
[gaim-migrate @ 13773]
Francesco Fracassi <ffracassi@users.sourceforge.net>
parents:
11485
diff
changeset
|
4942 | 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
|
4943 | GtkWidget *ebox = NULL; |
| 8061 | 4944 | |
| 10526 | 4945 | if (imhtml->format_functions & GTK_IMHTML_SMILEY) { |
|
10522
d505522bcc93
[gaim-migrate @ 11838]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10504
diff
changeset
|
4946 | annipixbuf = gtk_smiley_tree_image(imhtml, sml, unescaped); |
| 10526 | 4947 | if (annipixbuf) { |
| 4948 | if (gdk_pixbuf_animation_is_static_image(annipixbuf)) { | |
|
10522
d505522bcc93
[gaim-migrate @ 11838]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10504
diff
changeset
|
4949 | pixbuf = gdk_pixbuf_animation_get_static_image(annipixbuf); |
| 10526 | 4950 | if (pixbuf) |
|
10522
d505522bcc93
[gaim-migrate @ 11838]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10504
diff
changeset
|
4951 | icon = gtk_image_new_from_pixbuf(pixbuf); |
|
d505522bcc93
[gaim-migrate @ 11838]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10504
diff
changeset
|
4952 | } else { |
|
d505522bcc93
[gaim-migrate @ 11838]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10504
diff
changeset
|
4953 | 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
|
4954 | 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
|
4955 | 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
|
4956 | GdkPixbufAnimation *anim = gtk_image_get_animation(image); |
|
20638
38507ef4007f
Fix some crashes with animated smileys. Fixes #3179, #938, #3134, #2872, #1594
Daniel Atallah <datallah@pidgin.im>
parents:
20330
diff
changeset
|
4957 | g_signal_handlers_disconnect_matched(G_OBJECT(image), G_SIGNAL_MATCH_FUNC, |
|
38507ef4007f
Fix some crashes with animated smileys. Fixes #3179, #938, #3134, #2872, #1594
Daniel Atallah <datallah@pidgin.im>
parents:
20330
diff
changeset
|
4958 | 0, 0, NULL, G_CALLBACK(animated_smiley_destroy_cb), 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
|
4959 | 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
|
4960 | GdkPixbuf *pb = gdk_pixbuf_animation_get_static_image(anim); |
|
20638
38507ef4007f
Fix some crashes with animated smileys. Fixes #3179, #938, #3134, #2872, #1594
Daniel Atallah <datallah@pidgin.im>
parents:
20330
diff
changeset
|
4961 | if (pb != NULL) { |
|
38507ef4007f
Fix some crashes with animated smileys. Fixes #3179, #938, #3134, #2872, #1594
Daniel Atallah <datallah@pidgin.im>
parents:
20330
diff
changeset
|
4962 | GdkPixbuf *copy = gdk_pixbuf_copy(pb); |
|
38507ef4007f
Fix some crashes with animated smileys. Fixes #3179, #938, #3134, #2872, #1594
Daniel Atallah <datallah@pidgin.im>
parents:
20330
diff
changeset
|
4963 | gtk_image_set_from_pixbuf(image, copy); |
|
38507ef4007f
Fix some crashes with animated smileys. Fixes #3179, #938, #3134, #2872, #1594
Daniel Atallah <datallah@pidgin.im>
parents:
20330
diff
changeset
|
4964 | g_object_unref(G_OBJECT(copy)); |
|
38507ef4007f
Fix some crashes with animated smileys. Fixes #3179, #938, #3134, #2872, #1594
Daniel Atallah <datallah@pidgin.im>
parents:
20330
diff
changeset
|
4965 | } |
|
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
|
4966 | } |
|
aa5b9456e258
Fixes #213 This allows only 20 animated smileys to be animnating at a time
Sean Egan <seanegan@pidgin.im>
parents:
16291
diff
changeset
|
4967 | } 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
|
4968 | 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
|
4969 | } |
|
aa5b9456e258
Fixes #213 This allows only 20 animated smileys to be animnating at a time
Sean Egan <seanegan@pidgin.im>
parents:
16291
diff
changeset
|
4970 | 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
|
4971 | g_queue_push_tail(imhtml->animations, icon); |
|
10522
d505522bcc93
[gaim-migrate @ 11838]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10504
diff
changeset
|
4972 | } |
| 8061 | 4973 | } |
| 4974 | } | |
| 4975 | ||
|
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
|
4976 | 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
|
4977 | ebox = gtk_event_box_new(); |
| 17406 | 4978 | #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
|
4979 | gtk_event_box_set_visible_window(GTK_EVENT_BOX(ebox), FALSE); |
| 17406 | 4980 | #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
|
4981 | 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
|
4982 | } |
|
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
|
4983 | |
| 8061 | 4984 | if (icon) { |
|
22803
e1f64090d32e
Do not show tooltips for <HR> or <IMG>s in gtkimhtml. Fixes #5480.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22772
diff
changeset
|
4985 | char *text = g_strdup(unescaped); /* Do not g_free 'text'. |
|
e1f64090d32e
Do not show tooltips for <HR> or <IMG>s in gtkimhtml. Fixes #5480.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22772
diff
changeset
|
4986 | It will be destroyed when 'anchor' is destroyed. */ |
| 8890 | 4987 | anchor = gtk_text_buffer_create_child_anchor(imhtml->text_buffer, iter); |
|
22803
e1f64090d32e
Do not show tooltips for <HR> or <IMG>s in gtkimhtml. Fixes #5480.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22772
diff
changeset
|
4988 | g_object_set_data_full(G_OBJECT(anchor), "gtkimhtml_plaintext", text, g_free); |
|
e1f64090d32e
Do not show tooltips for <HR> or <IMG>s in gtkimhtml. Fixes #5480.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22772
diff
changeset
|
4989 | g_object_set_data(G_OBJECT(anchor), "gtkimhtml_tiptext", text); |
| 8890 | 4990 | g_object_set_data_full(G_OBJECT(anchor), "gtkimhtml_htmltext", g_strdup(smiley), g_free); |
| 4991 | ||
| 13552 | 4992 | /* This catches the expose events generated by animated |
| 4993 | * images, and ensures that they are handled by the image | |
| 4994 | * itself, without propagating to the textview and causing | |
| 4995 | * a complete refresh */ | |
| 4996 | g_signal_connect(G_OBJECT(icon), "expose-event", G_CALLBACK(image_expose), NULL); | |
| 4997 | ||
| 8061 | 4998 | 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
|
4999 | 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
|
5000 | 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
|
5001 | 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
|
5002 | } 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
|
5003 | anchor = gtk_text_buffer_create_child_anchor(imhtml->text_buffer, iter); |
|
23398
4de581ccaf1e
Do not try to update received custom smileys in a deleted child anchor.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23377
diff
changeset
|
5004 | imhtml_smiley->anchors = g_slist_append(imhtml_smiley->anchors, g_object_ref(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
|
5005 | 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
|
5006 | GtkWidget *img = gtk_image_new_from_stock(GTK_STOCK_MISSING_IMAGE, GTK_ICON_SIZE_MENU); |
|
22803
e1f64090d32e
Do not show tooltips for <HR> or <IMG>s in gtkimhtml. Fixes #5480.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22772
diff
changeset
|
5007 | char *text = g_strdup(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
|
5008 | 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
|
5009 | gtk_widget_show(img); |
|
22803
e1f64090d32e
Do not show tooltips for <HR> or <IMG>s in gtkimhtml. Fixes #5480.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22772
diff
changeset
|
5010 | g_object_set_data_full(G_OBJECT(anchor), "gtkimhtml_plaintext", text, g_free); |
|
e1f64090d32e
Do not show tooltips for <HR> or <IMG>s in gtkimhtml. Fixes #5480.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22772
diff
changeset
|
5011 | g_object_set_data(G_OBJECT(anchor), "gtkimhtml_tiptext", text); |
|
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
|
5012 | 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
|
5013 | } |
| 8890 | 5014 | } else { |
| 5015 | gtk_text_buffer_insert(imhtml->text_buffer, iter, smiley, -1); | |
| 8061 | 5016 | } |
| 8890 | 5017 | |
|
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
|
5018 | 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
|
5019 | 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
|
5020 | } |
|
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
|
5021 | |
| 8890 | 5022 | g_free(unescaped); |
| 8061 | 5023 | } |
| 5024 | ||
| 8962 | 5025 | void gtk_imhtml_insert_image_at_iter(GtkIMHtml *imhtml, int id, GtkTextIter *iter) |
| 5026 | { | |
|
18151
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
5027 | GdkPixbufAnimation *anim = NULL; |
| 8962 | 5028 | const char *filename = NULL; |
| 5029 | gpointer image; | |
| 5030 | GdkRectangle rect; | |
| 5031 | GtkIMHtmlScalable *scalable = NULL; | |
|
11224
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
5032 | struct scalable_data *sd; |
| 8962 | 5033 | int minus; |
| 5034 | ||
| 5035 | if (!imhtml->funcs || !imhtml->funcs->image_get || | |
| 5036 | !imhtml->funcs->image_get_size || !imhtml->funcs->image_get_data || | |
| 5037 | !imhtml->funcs->image_get_filename || !imhtml->funcs->image_ref || | |
| 5038 | !imhtml->funcs->image_unref) | |
| 5039 | return; | |
| 5040 | ||
| 5041 | image = imhtml->funcs->image_get(id); | |
| 5042 | ||
| 5043 | if (image) { | |
| 5044 | gpointer data; | |
| 5045 | size_t len; | |
| 5046 | ||
| 5047 | data = imhtml->funcs->image_get_data(image); | |
| 5048 | len = imhtml->funcs->image_get_size(image); | |
| 5049 | ||
| 5050 | if (data && len) { | |
| 5051 | GdkPixbufLoader *loader = gdk_pixbuf_loader_new(); | |
| 5052 | gdk_pixbuf_loader_write(loader, data, len, NULL); | |
|
12230
2f327bccf63b
[gaim-migrate @ 14532]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12229
diff
changeset
|
5053 | 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
|
5054 | 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
|
5055 | if (anim) |
|
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
5056 | g_object_ref(G_OBJECT(anim)); |
| 9337 | 5057 | g_object_unref(G_OBJECT(loader)); |
| 8962 | 5058 | } |
| 5059 | ||
| 5060 | } | |
| 5061 | ||
|
18151
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
5062 | if (anim) { |
|
11299
06bb44ed0cf3
[gaim-migrate @ 13499]
Richard Laager <rlaager@pidgin.im>
parents:
11276
diff
changeset
|
5063 | struct im_image_data *t = g_new(struct im_image_data, 1); |
| 8962 | 5064 | filename = imhtml->funcs->image_get_filename(image); |
| 5065 | imhtml->funcs->image_ref(id); | |
|
11224
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
5066 | t->id = id; |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
5067 | 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
|
5068 | 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
|
5069 | 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
|
5070 | g_object_unref(G_OBJECT(anim)); |
| 8962 | 5071 | } else { |
|
18151
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
5072 | GdkPixbuf *pixbuf; |
| 8962 | 5073 | pixbuf = gtk_widget_render_icon(GTK_WIDGET(imhtml), GTK_STOCK_MISSING_IMAGE, |
| 5074 | 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
|
5075 | 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
|
5076 | g_object_unref(G_OBJECT(pixbuf)); |
| 8962 | 5077 | } |
| 5078 | ||
|
11224
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
5079 | 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
|
5080 | sd->scalable = scalable; |
|
11233
28c0f184a2d4
[gaim-migrate @ 13373]
Daniel Atallah <datallah@pidgin.im>
parents:
11224
diff
changeset
|
5081 | sd->mark = gtk_text_buffer_create_mark(imhtml->text_buffer, NULL, iter, TRUE); |
| 8962 | 5082 | gtk_text_view_get_visible_rect(GTK_TEXT_VIEW(imhtml), &rect); |
| 5083 | scalable->add_to(scalable, imhtml, iter); | |
| 5084 | minus = gtk_text_view_get_left_margin(GTK_TEXT_VIEW(imhtml)) + | |
| 5085 | gtk_text_view_get_right_margin(GTK_TEXT_VIEW(imhtml)); | |
| 5086 | scalable->scale(scalable, rect.width - minus, rect.height); | |
|
11224
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
5087 | imhtml->scalables = g_list_append(imhtml->scalables, sd); |
| 8962 | 5088 | } |
| 5089 | ||
| 8677 | 5090 | static const gchar *tag_to_html_start(GtkTextTag *tag) |
| 8061 | 5091 | { |
| 8677 | 5092 | const gchar *name; |
| 5093 | static gchar buf[1024]; | |
| 5094 | ||
| 5095 | name = tag->name; | |
| 5096 | g_return_val_if_fail(name != NULL, ""); | |
| 5097 | ||
| 5098 | if (strcmp(name, "BOLD") == 0) { | |
| 5099 | return "<b>"; | |
| 5100 | } else if (strcmp(name, "ITALICS") == 0) { | |
| 5101 | return "<i>"; | |
| 5102 | } else if (strcmp(name, "UNDERLINE") == 0) { | |
| 5103 | return "<u>"; | |
| 9924 | 5104 | } else if (strcmp(name, "STRIKE") == 0) { |
| 5105 | return "<s>"; | |
| 8677 | 5106 | } else if (strncmp(name, "LINK ", 5) == 0) { |
| 5107 | char *tmp = g_object_get_data(G_OBJECT(tag), "link_url"); | |
| 5108 | if (tmp) { | |
| 5109 | g_snprintf(buf, sizeof(buf), "<a href=\"%s\">", tmp); | |
| 5110 | buf[sizeof(buf)-1] = '\0'; | |
| 5111 | return buf; | |
| 5112 | } else { | |
| 5113 | return ""; | |
| 5114 | } | |
| 5115 | } else if (strncmp(name, "FORECOLOR ", 10) == 0) { | |
| 5116 | g_snprintf(buf, sizeof(buf), "<font color=\"%s\">", &name[10]); | |
| 5117 | return buf; | |
| 5118 | } else if (strncmp(name, "BACKCOLOR ", 10) == 0) { | |
| 5119 | g_snprintf(buf, sizeof(buf), "<font back=\"%s\">", &name[10]); | |
| 5120 | return buf; | |
| 10776 | 5121 | } else if (strncmp(name, "BACKGROUND ", 10) == 0) { |
| 5122 | g_snprintf(buf, sizeof(buf), "<body bgcolor=\"%s\">", &name[11]); | |
| 5123 | return buf; | |
| 8677 | 5124 | } else if (strncmp(name, "FONT FACE ", 10) == 0) { |
| 5125 | g_snprintf(buf, sizeof(buf), "<font face=\"%s\">", &name[10]); | |
| 5126 | return buf; | |
| 5127 | } else if (strncmp(name, "FONT SIZE ", 10) == 0) { | |
| 5128 | g_snprintf(buf, sizeof(buf), "<font size=\"%s\">", &name[10]); | |
| 5129 | return buf; | |
| 5130 | } else { | |
|
23308
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5131 | char *str = buf; |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5132 | gboolean isset; |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5133 | int ivalue = 0; |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5134 | GdkColor *color = NULL; |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5135 | GObject *obj = G_OBJECT(tag); |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5136 | gboolean empty = TRUE; |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5137 | |
|
23310
e34473be13db
Get rid of the boldness of the bold timestamps.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23308
diff
changeset
|
5138 | str += g_snprintf(str, sizeof(buf) - (str - buf), "<span style='"); |
|
23308
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5139 | |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5140 | /* Weight */ |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5141 | g_object_get(obj, "weight-set", &isset, "weight", &ivalue, NULL); |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5142 | if (isset) { |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5143 | const char *weight = ""; |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5144 | if (ivalue >= PANGO_WEIGHT_ULTRABOLD) |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5145 | weight = "bolder"; |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5146 | else if (ivalue >= PANGO_WEIGHT_BOLD) |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5147 | weight = "bold"; |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5148 | else if (ivalue >= PANGO_WEIGHT_NORMAL) |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5149 | weight = "normal"; |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5150 | else |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5151 | weight = "lighter"; |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5152 | |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5153 | str += g_snprintf(str, sizeof(buf) - (str - buf), "font-weight: %s;", weight); |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5154 | empty = FALSE; |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5155 | } |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5156 | |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5157 | /* Foreground color */ |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5158 | g_object_get(obj, "foreground-set", &isset, "foreground-gdk", &color, NULL); |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5159 | if (isset && color) { |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5160 | str += g_snprintf(str, sizeof(buf) - (str - buf), |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5161 | "color: #%02x%02x%02x;", |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5162 | color->red >> 8, color->green >> 8, color->blue >> 8); |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5163 | empty = FALSE; |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5164 | } |
|
23466
7380df2e12f1
Patch from Andrew Gaul that fixes another leak:
Ka-Hing Cheung <khc@pidgin.im>
parents:
23465
diff
changeset
|
5165 | gdk_color_free(color); |
|
23308
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5166 | |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5167 | /* Background color */ |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5168 | g_object_get(obj, "background-set", &isset, "background-gdk", &color, NULL); |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5169 | if (isset && color) { |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5170 | str += g_snprintf(str, sizeof(buf) - (str - buf), |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5171 | "background: #%02x%02x%02x;", |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5172 | color->red >> 8, color->green >> 8, color->blue >> 8); |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5173 | empty = FALSE; |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5174 | } |
|
23466
7380df2e12f1
Patch from Andrew Gaul that fixes another leak:
Ka-Hing Cheung <khc@pidgin.im>
parents:
23465
diff
changeset
|
5175 | gdk_color_free(color); |
|
23308
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5176 | |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5177 | /* Underline */ |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5178 | g_object_get(obj, "underline-set", &isset, "underline", &ivalue, NULL); |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5179 | if (isset) { |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5180 | switch (ivalue) { |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5181 | case PANGO_UNDERLINE_NONE: |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5182 | case PANGO_UNDERLINE_ERROR: |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5183 | break; |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5184 | default: |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5185 | str += g_snprintf(str, sizeof(buf) - (str - buf), "text-decoration: underline;"); |
|
23365
fc1df3495580
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23332
diff
changeset
|
5186 | empty = FALSE; |
|
23308
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5187 | } |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5188 | } |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5189 | |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5190 | g_snprintf(str, sizeof(buf) - (str - buf), "'>"); |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5191 | |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5192 | return (empty ? "" : buf); |
| 8677 | 5193 | } |
| 8061 | 5194 | } |
| 5195 | ||
| 8677 | 5196 | static const gchar *tag_to_html_end(GtkTextTag *tag) |
| 8061 | 5197 | { |
| 8677 | 5198 | const gchar *name; |
| 5199 | ||
| 5200 | name = tag->name; | |
| 5201 | g_return_val_if_fail(name != NULL, ""); | |
| 5202 | ||
| 5203 | if (strcmp(name, "BOLD") == 0) { | |
| 5204 | return "</b>"; | |
| 5205 | } else if (strcmp(name, "ITALICS") == 0) { | |
| 5206 | return "</i>"; | |
| 5207 | } else if (strcmp(name, "UNDERLINE") == 0) { | |
| 5208 | return "</u>"; | |
| 9924 | 5209 | } else if (strcmp(name, "STRIKE") == 0) { |
| 5210 | return "</s>"; | |
| 8677 | 5211 | } else if (strncmp(name, "LINK ", 5) == 0) { |
| 5212 | return "</a>"; | |
| 5213 | } else if (strncmp(name, "FORECOLOR ", 10) == 0) { | |
| 5214 | return "</font>"; | |
| 5215 | } else if (strncmp(name, "BACKCOLOR ", 10) == 0) { | |
| 5216 | return "</font>"; | |
| 10776 | 5217 | } else if (strncmp(name, "BACKGROUND ", 10) == 0) { |
| 5218 | return "</body>"; | |
| 8677 | 5219 | } else if (strncmp(name, "FONT FACE ", 10) == 0) { |
| 5220 | return "</font>"; | |
| 5221 | } else if (strncmp(name, "FONT SIZE ", 10) == 0) { | |
| 5222 | return "</font>"; | |
| 5223 | } else { | |
|
23308
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5224 | const char *props[] = {"weight-set", "foreground-set", "background-set", |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5225 | "size-set", "underline-set", NULL}; |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5226 | int i; |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5227 | for (i = 0; props[i]; i++) { |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5228 | gboolean set = FALSE; |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5229 | g_object_get(G_OBJECT(tag), props[i], &set, NULL); |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5230 | if (set) |
|
23310
e34473be13db
Get rid of the boldness of the bold timestamps.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23308
diff
changeset
|
5231 | return "</span>"; |
|
23308
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5232 | } |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5233 | |
| 8677 | 5234 | return ""; |
| 5235 | } | |
| 5236 | } | |
| 5237 | ||
|
23365
fc1df3495580
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23332
diff
changeset
|
5238 | typedef struct { |
|
fc1df3495580
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23332
diff
changeset
|
5239 | GtkTextTag *tag; |
|
fc1df3495580
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23332
diff
changeset
|
5240 | char *end; |
|
fc1df3495580
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23332
diff
changeset
|
5241 | char *start; |
|
fc1df3495580
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23332
diff
changeset
|
5242 | } PidginTextTagData; |
|
fc1df3495580
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23332
diff
changeset
|
5243 | |
|
fc1df3495580
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23332
diff
changeset
|
5244 | static PidginTextTagData *text_tag_data_new(GtkTextTag *tag) |
|
fc1df3495580
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23332
diff
changeset
|
5245 | { |
|
fc1df3495580
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23332
diff
changeset
|
5246 | const char *start, *end; |
|
fc1df3495580
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23332
diff
changeset
|
5247 | PidginTextTagData *ret = NULL; |
|
fc1df3495580
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23332
diff
changeset
|
5248 | |
|
fc1df3495580
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23332
diff
changeset
|
5249 | start = tag_to_html_start(tag); |
|
fc1df3495580
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23332
diff
changeset
|
5250 | if (!start || !*start) |
|
fc1df3495580
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23332
diff
changeset
|
5251 | return NULL; |
|
fc1df3495580
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23332
diff
changeset
|
5252 | end = tag_to_html_end(tag); |
|
fc1df3495580
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23332
diff
changeset
|
5253 | if (!end || !*end) |
|
fc1df3495580
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23332
diff
changeset
|
5254 | return NULL; |
|
fc1df3495580
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23332
diff
changeset
|
5255 | |
|
fc1df3495580
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23332
diff
changeset
|
5256 | ret = g_new0(PidginTextTagData, 1); |
|
fc1df3495580
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23332
diff
changeset
|
5257 | ret->start = g_strdup(start); |
|
fc1df3495580
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23332
diff
changeset
|
5258 | ret->end = g_strdup(end); |
|
fc1df3495580
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23332
diff
changeset
|
5259 | ret->tag = tag; |
|
fc1df3495580
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23332
diff
changeset
|
5260 | return ret; |
|
fc1df3495580
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23332
diff
changeset
|
5261 | } |
|
fc1df3495580
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23332
diff
changeset
|
5262 | |
|
fc1df3495580
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23332
diff
changeset
|
5263 | static void text_tag_data_destroy(PidginTextTagData *data) |
|
fc1df3495580
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23332
diff
changeset
|
5264 | { |
|
fc1df3495580
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23332
diff
changeset
|
5265 | g_free(data->start); |
|
fc1df3495580
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23332
diff
changeset
|
5266 | g_free(data->end); |
|
fc1df3495580
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23332
diff
changeset
|
5267 | g_free(data); |
|
fc1df3495580
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23332
diff
changeset
|
5268 | } |
|
fc1df3495580
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23332
diff
changeset
|
5269 | |
| 8677 | 5270 | static gboolean tag_ends_here(GtkTextTag *tag, GtkTextIter *iter, GtkTextIter *niter) |
| 5271 | { | |
| 5272 | return ((gtk_text_iter_has_tag(iter, GTK_TEXT_TAG(tag)) && | |
| 5273 | !gtk_text_iter_has_tag(niter, GTK_TEXT_TAG(tag))) || | |
| 5274 | gtk_text_iter_is_end(niter)); | |
| 8061 | 5275 | } |
| 5276 | ||
| 5277 | /* Basic notion here: traverse through the text buffer one-by-one, non-character elements, such | |
| 5278 | * as smileys and IM images are represented by the Unicode "unknown" character. Handle them. Else | |
| 8677 | 5279 | * check for tags that are toggled on, insert their html form, and push them on the queue. Then insert |
| 5280 | * 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
|
5281 | * Finally, replace <, >, &, and " with their HTML equivalent. |
| 8677 | 5282 | */ |
| 8061 | 5283 | char *gtk_imhtml_get_markup_range(GtkIMHtml *imhtml, GtkTextIter *start, GtkTextIter *end) |
| 5284 | { | |
| 5285 | gunichar c; | |
|
16143
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
5286 | GtkTextIter iter, next_iter, non_neutral_iter; |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
5287 | gboolean is_rtl_message = FALSE; |
| 8061 | 5288 | GString *str = g_string_new(""); |
| 8677 | 5289 | GSList *tags, *sl; |
|
23365
fc1df3495580
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23332
diff
changeset
|
5290 | GQueue *q; |
| 8677 | 5291 | GtkTextTag *tag; |
|
23365
fc1df3495580
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23332
diff
changeset
|
5292 | PidginTextTagData *tagdata; |
| 8677 | 5293 | |
| 5294 | q = g_queue_new(); | |
| 8061 | 5295 | |
| 5296 | gtk_text_iter_order(start, end); | |
|
16143
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
5297 | non_neutral_iter = next_iter = iter = *start; |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
5298 | gtk_text_iter_forward_char(&next_iter); |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
5299 | |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
5300 | /* Bi-directional text support */ |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
5301 | /* 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
|
5302 | #ifdef HAVE_PANGO14 |
| 16144 | 5303 | 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
|
5304 | && gtk_text_iter_forward_char(&non_neutral_iter)); |
| 16144 | 5305 | 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
|
5306 | is_rtl_message = TRUE; |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
5307 | 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
|
5308 | } |
|
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
|
5309 | #endif |
| 8677 | 5310 | |
| 9071 | 5311 | /* First add the tags that are already in progress (we don't care about non-printing tags)*/ |
| 8677 | 5312 | tags = gtk_text_iter_get_tags(start); |
| 5313 | ||
| 5314 | for (sl = tags; sl; sl = sl->next) { | |
| 5315 | tag = sl->data; | |
| 5316 | if (!gtk_text_iter_toggles_tag(start, GTK_TEXT_TAG(tag))) { | |
|
23365
fc1df3495580
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23332
diff
changeset
|
5317 | PidginTextTagData *data = text_tag_data_new(tag); |
|
fc1df3495580
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23332
diff
changeset
|
5318 | if (data) { |
|
fc1df3495580
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23332
diff
changeset
|
5319 | g_string_append(str, data->start); |
|
fc1df3495580
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23332
diff
changeset
|
5320 | g_queue_push_tail(q, data); |
|
fc1df3495580
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23332
diff
changeset
|
5321 | } |
| 8061 | 5322 | } |
| 5323 | } | |
| 8677 | 5324 | g_slist_free(tags); |
| 8061 | 5325 | |
| 5326 | while ((c = gtk_text_iter_get_char(&iter)) != 0 && !gtk_text_iter_equal(&iter, end)) { | |
| 8677 | 5327 | |
| 5328 | tags = gtk_text_iter_get_tags(&iter); | |
| 5329 | ||
| 5330 | for (sl = tags; sl; sl = sl->next) { | |
| 5331 | tag = sl->data; | |
| 5332 | if (gtk_text_iter_begins_tag(&iter, GTK_TEXT_TAG(tag))) { | |
|
23365
fc1df3495580
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23332
diff
changeset
|
5333 | PidginTextTagData *data = text_tag_data_new(tag); |
|
fc1df3495580
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23332
diff
changeset
|
5334 | if (data) { |
|
fc1df3495580
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23332
diff
changeset
|
5335 | g_string_append(str, data->start); |
|
fc1df3495580
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23332
diff
changeset
|
5336 | g_queue_push_tail(q, data); |
|
fc1df3495580
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23332
diff
changeset
|
5337 | } |
| 8677 | 5338 | } |
| 5339 | } | |
| 5340 | ||
| 8061 | 5341 | if (c == 0xFFFC) { |
| 5342 | GtkTextChildAnchor* anchor = gtk_text_iter_get_child_anchor(&iter); | |
| 9071 | 5343 | if (anchor) { |
| 5344 | char *text = g_object_get_data(G_OBJECT(anchor), "gtkimhtml_htmltext"); | |
| 5345 | if (text) | |
| 5346 | str = g_string_append(str, text); | |
| 5347 | } | |
|
11572
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
5348 | } else if (c == '<') { |
| 8677 | 5349 | str = g_string_append(str, "<"); |
| 5350 | } else if (c == '>') { | |
| 5351 | str = g_string_append(str, ">"); | |
| 5352 | } else if (c == '&') { | |
| 5353 | str = g_string_append(str, "&"); | |
| 5354 | } else if (c == '"') { | |
| 5355 | str = g_string_append(str, """); | |
| 5356 | } else if (c == '\n') { | |
|
19746
4537d921dab4
disapproval of revision '10d0834255f911ca2359c74b430025155af2b22e'
Kevin Stange <kstange@pidgin.im>
parents:
19745
diff
changeset
|
5357 | str = g_string_append(str, "<br>"); |
| 8061 | 5358 | } else { |
| 8677 | 5359 | str = g_string_append_unichar(str, c); |
| 5360 | } | |
| 5361 | ||
| 5362 | tags = g_slist_reverse(tags); | |
| 5363 | for (sl = tags; sl; sl = sl->next) { | |
| 5364 | tag = sl->data; | |
| 9071 | 5365 | /** don't worry about non-printing tags ending */ |
|
23365
fc1df3495580
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23332
diff
changeset
|
5366 | if (tag_ends_here(tag, &iter, &next_iter) && |
|
fc1df3495580
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23332
diff
changeset
|
5367 | strlen(tag_to_html_end(tag)) > 0 && |
|
fc1df3495580
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23332
diff
changeset
|
5368 | strlen(tag_to_html_start(tag)) > 0) { |
|
fc1df3495580
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23332
diff
changeset
|
5369 | |
|
fc1df3495580
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23332
diff
changeset
|
5370 | PidginTextTagData *tmp; |
|
fc1df3495580
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23332
diff
changeset
|
5371 | GQueue *r = g_queue_new(); |
|
fc1df3495580
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23332
diff
changeset
|
5372 | |
|
fc1df3495580
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23332
diff
changeset
|
5373 | while ((tmp = g_queue_pop_tail(q)) && tmp->tag != tag) { |
|
fc1df3495580
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23332
diff
changeset
|
5374 | g_string_append(str, tmp->end); |
|
fc1df3495580
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23332
diff
changeset
|
5375 | if (!tag_ends_here(tmp->tag, &iter, &next_iter)) |
| 8677 | 5376 | g_queue_push_tail(r, tmp); |
|
23365
fc1df3495580
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23332
diff
changeset
|
5377 | else |
|
fc1df3495580
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23332
diff
changeset
|
5378 | text_tag_data_destroy(tmp); |
| 8677 | 5379 | } |
| 5380 | ||
|
25470
b1777c3ab2bb
Prevent a crash that can occur while copying the contents of the Debug Window. This ends up masking mismatched tags in the imhtml output, but that is
Daniel Atallah <datallah@pidgin.im>
parents:
25299
diff
changeset
|
5381 | if (tmp != NULL) { |
|
23365
fc1df3495580
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23332
diff
changeset
|
5382 | g_string_append(str, tmp->end); |
|
23465
e20729245830
Patch from Andrew Gaul that fixes a leak:
Ka-Hing Cheung <khc@pidgin.im>
parents:
23398
diff
changeset
|
5383 | text_tag_data_destroy(tmp); |
|
e20729245830
Patch from Andrew Gaul that fixes a leak:
Ka-Hing Cheung <khc@pidgin.im>
parents:
23398
diff
changeset
|
5384 | } |
|
25470
b1777c3ab2bb
Prevent a crash that can occur while copying the contents of the Debug Window. This ends up masking mismatched tags in the imhtml output, but that is
Daniel Atallah <datallah@pidgin.im>
parents:
25299
diff
changeset
|
5385 | #if 0 /* This can't be allowed to happen because it causes the iters to be invalidated in the debug window imhtml during text copying */ |
|
b1777c3ab2bb
Prevent a crash that can occur while copying the contents of the Debug Window. This ends up masking mismatched tags in the imhtml output, but that is
Daniel Atallah <datallah@pidgin.im>
parents:
25299
diff
changeset
|
5386 | else |
|
b1777c3ab2bb
Prevent a crash that can occur while copying the contents of the Debug Window. This ends up masking mismatched tags in the imhtml output, but that is
Daniel Atallah <datallah@pidgin.im>
parents:
25299
diff
changeset
|
5387 | purple_debug_warning("gtkimhtml", "empty queue, more closing tags than open tags!\n"); |
|
b1777c3ab2bb
Prevent a crash that can occur while copying the contents of the Debug Window. This ends up masking mismatched tags in the imhtml output, but that is
Daniel Atallah <datallah@pidgin.im>
parents:
25299
diff
changeset
|
5388 | #endif |
| 8677 | 5389 | |
| 5390 | while ((tmp = g_queue_pop_head(r))) { | |
|
23365
fc1df3495580
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23332
diff
changeset
|
5391 | g_string_append(str, tmp->start); |
| 8677 | 5392 | g_queue_push_tail(q, tmp); |
| 8061 | 5393 | } |
|
23365
fc1df3495580
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23332
diff
changeset
|
5394 | g_queue_free(r); |
| 8061 | 5395 | } |
| 5396 | } | |
| 8677 | 5397 | |
| 5398 | g_slist_free(tags); | |
| 8061 | 5399 | gtk_text_iter_forward_char(&iter); |
|
16143
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
5400 | gtk_text_iter_forward_char(&next_iter); |
| 8061 | 5401 | } |
| 8677 | 5402 | |
|
23365
fc1df3495580
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23332
diff
changeset
|
5403 | while ((tagdata = g_queue_pop_tail(q))) { |
|
fc1df3495580
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23332
diff
changeset
|
5404 | g_string_append(str, tagdata->end); |
|
fc1df3495580
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23332
diff
changeset
|
5405 | text_tag_data_destroy(tagdata); |
|
fc1df3495580
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23332
diff
changeset
|
5406 | } |
| 8677 | 5407 | |
|
16143
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
5408 | /* Bi-directional text support - close tags */ |
| 16144 | 5409 | if (is_rtl_message) |
|
16143
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
5410 | g_string_append(str, "</SPAN>"); |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
5411 | |
| 8677 | 5412 | g_queue_free(q); |
| 8061 | 5413 | return g_string_free(str, FALSE); |
| 5414 | } | |
| 5415 | ||
| 8698 | 5416 | void gtk_imhtml_close_tags(GtkIMHtml *imhtml, GtkTextIter *iter) |
| 8061 | 5417 | { |
| 5418 | if (imhtml->edit.bold) | |
| 5419 | gtk_imhtml_toggle_bold(imhtml); | |
| 5420 | ||
| 5421 | if (imhtml->edit.italic) | |
| 5422 | gtk_imhtml_toggle_italic(imhtml); | |
| 5423 | ||
| 5424 | if (imhtml->edit.underline) | |
| 5425 | gtk_imhtml_toggle_underline(imhtml); | |
| 5426 | ||
| 9924 | 5427 | if (imhtml->edit.strike) |
| 5428 | gtk_imhtml_toggle_strike(imhtml); | |
| 5429 | ||
| 8061 | 5430 | if (imhtml->edit.forecolor) |
| 5431 | gtk_imhtml_toggle_forecolor(imhtml, NULL); | |
| 5432 | ||
| 5433 | if (imhtml->edit.backcolor) | |
| 5434 | gtk_imhtml_toggle_backcolor(imhtml, NULL); | |
| 5435 | ||
| 5436 | if (imhtml->edit.fontface) | |
| 5437 | gtk_imhtml_toggle_fontface(imhtml, NULL); | |
| 5438 | ||
| 8677 | 5439 | imhtml->edit.fontsize = 0; |
| 5440 | ||
| 8719 | 5441 | if (imhtml->edit.link) |
| 5442 | gtk_imhtml_toggle_link(imhtml, NULL); | |
| 8061 | 5443 | } |
| 5444 | ||
| 5445 | char *gtk_imhtml_get_markup(GtkIMHtml *imhtml) | |
| 5446 | { | |
| 5447 | GtkTextIter start, end; | |
| 5448 | ||
| 5449 | gtk_text_buffer_get_start_iter(imhtml->text_buffer, &start); | |
| 5450 | gtk_text_buffer_get_end_iter(imhtml->text_buffer, &end); | |
| 5451 | return gtk_imhtml_get_markup_range(imhtml, &start, &end); | |
| 5452 | } | |
| 5453 | ||
| 8677 | 5454 | char **gtk_imhtml_get_markup_lines(GtkIMHtml *imhtml) |
| 5455 | { | |
| 5456 | int i, j, lines; | |
| 5457 | GtkTextIter start, end; | |
| 5458 | char **ret; | |
| 5459 | ||
| 5460 | lines = gtk_text_buffer_get_line_count(imhtml->text_buffer); | |
| 5461 | ret = g_new0(char *, lines + 1); | |
| 5462 | gtk_text_buffer_get_start_iter(imhtml->text_buffer, &start); | |
| 5463 | end = start; | |
| 5464 | gtk_text_iter_forward_to_line_end(&end); | |
| 5465 | ||
| 5466 | for (i = 0, j = 0; i < lines; i++) { | |
| 9612 | 5467 | if (gtk_text_iter_get_char(&start) != '\n') { |
| 5468 | ret[j] = gtk_imhtml_get_markup_range(imhtml, &start, &end); | |
| 5469 | if (ret[j] != NULL) | |
| 5470 | j++; | |
| 5471 | } | |
| 5472 | ||
| 8677 | 5473 | gtk_text_iter_forward_line(&start); |
| 5474 | end = start; | |
| 5475 | gtk_text_iter_forward_to_line_end(&end); | |
| 5476 | } | |
| 5477 | ||
| 5478 | return ret; | |
| 5479 | } | |
| 5480 | ||
| 5481 | char *gtk_imhtml_get_text(GtkIMHtml *imhtml, GtkTextIter *start, GtkTextIter *stop) | |
| 8061 | 5482 | { |
| 8519 | 5483 | GString *str = g_string_new(""); |
| 5484 | GtkTextIter iter, end; | |
| 5485 | gunichar c; | |
| 5486 | ||
| 8677 | 5487 | if (start == NULL) |
| 5488 | gtk_text_buffer_get_start_iter(imhtml->text_buffer, &iter); | |
| 5489 | else | |
| 5490 | iter = *start; | |
| 5491 | ||
| 5492 | if (stop == NULL) | |
| 5493 | gtk_text_buffer_get_end_iter(imhtml->text_buffer, &end); | |
| 5494 | else | |
| 5495 | end = *stop; | |
| 5496 | ||
| 5497 | gtk_text_iter_order(&iter, &end); | |
| 8519 | 5498 | |
| 5499 | while ((c = gtk_text_iter_get_char(&iter)) != 0 && !gtk_text_iter_equal(&iter, &end)) { | |
| 5500 | if (c == 0xFFFC) { | |
| 8677 | 5501 | GtkTextChildAnchor* anchor; |
| 5502 | char *text = NULL; | |
| 5503 | ||
| 5504 | anchor = gtk_text_iter_get_child_anchor(&iter); | |
| 5505 | if (anchor) | |
| 8698 | 5506 | text = g_object_get_data(G_OBJECT(anchor), "gtkimhtml_plaintext"); |
| 8677 | 5507 | if (text) |
| 5508 | str = g_string_append(str, text); | |
| 8519 | 5509 | } else { |
| 5510 | g_string_append_unichar(str, c); | |
| 5511 | } | |
| 5512 | gtk_text_iter_forward_char(&iter); | |
| 5513 | } | |
| 5514 | ||
| 5515 | return g_string_free(str, FALSE); | |
| 8061 | 5516 | } |
| 8962 | 5517 | |
| 5518 | void gtk_imhtml_set_funcs(GtkIMHtml *imhtml, GtkIMHtmlFuncs *f) | |
| 5519 | { | |
| 5520 | g_return_if_fail(imhtml != NULL); | |
| 5521 | imhtml->funcs = f; | |
| 5522 | } | |
|
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
|
5523 | |
|
8be39f0de528
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17288
diff
changeset
|
5524 | 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
|
5525 | { |
|
18240
0a7d2fde749b
Fix setting the sensitivity of the toolbar items in a number of places
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
18185
diff
changeset
|
5526 | 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
|
5527 | |
|
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
|
5528 | 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
|
5529 | 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
|
5530 | 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
|
5531 | |
|
18240
0a7d2fde749b
Fix setting the sensitivity of the toolbar items in a number of places
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
18185
diff
changeset
|
5532 | 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
|
5533 | |
|
0a7d2fde749b
Fix setting the sensitivity of the toolbar items in a number of places
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
18185
diff
changeset
|
5534 | 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
|
5535 | 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
|
5536 | 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
|
5537 | { |
|
0a7d2fde749b
Fix setting the sensitivity of the toolbar items in a number of places
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
18185
diff
changeset
|
5538 | 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
|
5539 | 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
|
5540 | } |
|
0a7d2fde749b
Fix setting the sensitivity of the toolbar items in a number of places
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
18185
diff
changeset
|
5541 | 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
|
5542 | 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
|
5543 | |
|
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
|
5544 | 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
|
5545 | 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
|
5546 | 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
|
5547 | |
|
8be39f0de528
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17288
diff
changeset
|
5548 | 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
|
5549 | 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
|
5550 | |
|
8be39f0de528
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17288
diff
changeset
|
5551 | 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
|
5552 | 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
|
5553 | |
|
8be39f0de528
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17288
diff
changeset
|
5554 | 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
|
5555 | 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
|
5556 | |
|
8be39f0de528
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17288
diff
changeset
|
5557 | 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
|
5558 | { |
|
8be39f0de528
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17288
diff
changeset
|
5559 | 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
|
5560 | |
|
8be39f0de528
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17288
diff
changeset
|
5561 | /* 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
|
5562 | 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
|
5563 | 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
|
5564 | } |
|
8be39f0de528
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17288
diff
changeset
|
5565 | |
|
8be39f0de528
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17288
diff
changeset
|
5566 | 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
|
5567 | { |
|
8be39f0de528
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17288
diff
changeset
|
5568 | 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
|
5569 | &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
|
5570 | 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
|
5571 | 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
|
5572 | 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
|
5573 | 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
|
5574 | } 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
|
5575 | 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
|
5576 | |
|
8be39f0de528
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17288
diff
changeset
|
5577 | 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
|
5578 | |
|
8be39f0de528
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17288
diff
changeset
|
5579 | 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
|
5580 | 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
|
5581 | { |
|
8be39f0de528
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17288
diff
changeset
|
5582 | 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
|
5583 | &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
|
5584 | 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
|
5585 | 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
|
5586 | 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
|
5587 | 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
|
5588 | } 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
|
5589 | 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
|
5590 | |
|
8be39f0de528
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17288
diff
changeset
|
5591 | 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
|
5592 | |
|
8be39f0de528
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17288
diff
changeset
|
5593 | 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
|
5594 | 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
|
5595 | 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
|
5596 | 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
|
5597 | } 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
|
5598 | 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
|
5599 | 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
|
5600 | } |
|
18240
0a7d2fde749b
Fix setting the sensitivity of the toolbar items in a number of places
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
18185
diff
changeset
|
5601 | |
|
0a7d2fde749b
Fix setting the sensitivity of the toolbar items in a number of places
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
18185
diff
changeset
|
5602 | 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
|
5603 | 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
|
5604 | |
|
23010
6230fac29cee
Show the custom smileys only on accounts that support it. References
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23008
diff
changeset
|
5605 | if (flags & PURPLE_CONNECTION_ALLOW_CUSTOM_SMILEY) |
|
6230fac29cee
Show the custom smileys only on accounts that support it. References
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23008
diff
changeset
|
5606 | buttons |= GTK_IMHTML_CUSTOM_SMILEY; |
|
6230fac29cee
Show the custom smileys only on accounts that support it. References
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23008
diff
changeset
|
5607 | else |
|
6230fac29cee
Show the custom smileys only on accounts that support it. References
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23008
diff
changeset
|
5608 | buttons &= ~GTK_IMHTML_CUSTOM_SMILEY; |
|
6230fac29cee
Show the custom smileys only on accounts that support it. References
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23008
diff
changeset
|
5609 | |
|
18240
0a7d2fde749b
Fix setting the sensitivity of the toolbar items in a number of places
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
18185
diff
changeset
|
5610 | 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
|
5611 | } |
|
8be39f0de528
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17288
diff
changeset
|
5612 | |
|
22655
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5613 | /******* |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5614 | * GtkIMHtmlSmiley functions |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5615 | *******/ |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5616 | static void gtk_custom_smiley_allocated(GdkPixbufLoader *loader, gpointer user_data) |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5617 | { |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5618 | GtkIMHtmlSmiley *smiley; |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5619 | |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5620 | smiley = (GtkIMHtmlSmiley *)user_data; |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5621 | smiley->icon = gdk_pixbuf_loader_get_animation(loader); |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5622 | |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5623 | if (smiley->icon) |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5624 | g_object_ref(G_OBJECT(smiley->icon)); |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5625 | #ifdef DEBUG_CUSTOM_SMILEY |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5626 | purple_debug_info("custom-smiley", "gtk_custom_smiley_allocated(): got GdkPixbufAnimation %p for smiley '%s'\n", smiley->icon, smiley->smile); |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5627 | #endif |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5628 | } |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5629 | |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5630 | static void gtk_custom_smiley_closed(GdkPixbufLoader *loader, gpointer user_data) |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5631 | { |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5632 | GtkIMHtmlSmiley *smiley; |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5633 | GtkWidget *icon = NULL; |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5634 | GtkTextChildAnchor *anchor = NULL; |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5635 | GSList *current = NULL; |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5636 | |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5637 | smiley = (GtkIMHtmlSmiley *)user_data; |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5638 | if (!smiley->imhtml) { |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5639 | #ifdef DEBUG_CUSTOM_SMILEY |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5640 | purple_debug_error("custom-smiley", "gtk_custom_smiley_closed(): orphan smiley found: %p\n", smiley); |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5641 | #endif |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5642 | g_object_unref(G_OBJECT(loader)); |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5643 | smiley->loader = NULL; |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5644 | return; |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5645 | } |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5646 | |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5647 | for (current = smiley->anchors; current; current = g_slist_next(current)) { |
|
23398
4de581ccaf1e
Do not try to update received custom smileys in a deleted child anchor.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23377
diff
changeset
|
5648 | anchor = GTK_TEXT_CHILD_ANCHOR(current->data); |
|
4de581ccaf1e
Do not try to update received custom smileys in a deleted child anchor.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23377
diff
changeset
|
5649 | if (gtk_text_child_anchor_get_deleted(anchor)) |
|
4de581ccaf1e
Do not try to update received custom smileys in a deleted child anchor.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23377
diff
changeset
|
5650 | icon = NULL; |
|
4de581ccaf1e
Do not try to update received custom smileys in a deleted child anchor.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23377
diff
changeset
|
5651 | else |
|
4de581ccaf1e
Do not try to update received custom smileys in a deleted child anchor.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23377
diff
changeset
|
5652 | icon = gtk_image_new_from_animation(smiley->icon); |
|
22655
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5653 | |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5654 | #ifdef DEBUG_CUSTOM_SMILEY |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5655 | purple_debug_info("custom-smiley", "gtk_custom_smiley_closed(): got GtkImage %p from GtkPixbufAnimation %p for smiley '%s'\n", |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5656 | icon, smiley->icon, smiley->smile); |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5657 | #endif |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5658 | if (icon) { |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5659 | GList *wids; |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5660 | gtk_widget_show(icon); |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5661 | |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5662 | wids = gtk_text_child_anchor_get_widgets(anchor); |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5663 | |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5664 | g_object_set_data_full(G_OBJECT(anchor), "gtkimhtml_plaintext", purple_unescape_html(smiley->smile), g_free); |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5665 | g_object_set_data_full(G_OBJECT(anchor), "gtkimhtml_htmltext", g_strdup(smiley->smile), g_free); |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5666 | |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5667 | if (smiley->imhtml) { |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5668 | if (wids) { |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5669 | GList *children = gtk_container_get_children(GTK_CONTAINER(wids->data)); |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5670 | g_list_foreach(children, (GFunc)gtk_widget_destroy, NULL); |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5671 | g_list_free(children); |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5672 | gtk_container_add(GTK_CONTAINER(wids->data), icon); |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5673 | } else |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5674 | gtk_text_view_add_child_at_anchor(GTK_TEXT_VIEW(smiley->imhtml), icon, anchor); |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5675 | } |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5676 | g_list_free(wids); |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5677 | } |
|
23398
4de581ccaf1e
Do not try to update received custom smileys in a deleted child anchor.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23377
diff
changeset
|
5678 | g_object_unref(anchor); |
|
22655
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5679 | } |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5680 | |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5681 | g_slist_free(smiley->anchors); |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5682 | smiley->anchors = NULL; |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5683 | |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5684 | g_object_unref(G_OBJECT(loader)); |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5685 | smiley->loader = NULL; |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5686 | } |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5687 | |
|
23018
39c5be5ca1e9
Patch from Masca to restrict the size of incoming custom smileys to a
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23010
diff
changeset
|
5688 | static void |
|
39c5be5ca1e9
Patch from Masca to restrict the size of incoming custom smileys to a
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23010
diff
changeset
|
5689 | gtk_custom_smiley_size_prepared(GdkPixbufLoader *loader, gint width, gint height, gpointer data) |
|
39c5be5ca1e9
Patch from Masca to restrict the size of incoming custom smileys to a
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23010
diff
changeset
|
5690 | { |
|
39c5be5ca1e9
Patch from Masca to restrict the size of incoming custom smileys to a
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23010
diff
changeset
|
5691 | #define CUSTOM_SMILEY_SIZE 96 /* XXX: Should this be a theme setting? */ |
|
39c5be5ca1e9
Patch from Masca to restrict the size of incoming custom smileys to a
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23010
diff
changeset
|
5692 | if (width <= CUSTOM_SMILEY_SIZE && height <= CUSTOM_SMILEY_SIZE) |
|
39c5be5ca1e9
Patch from Masca to restrict the size of incoming custom smileys to a
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23010
diff
changeset
|
5693 | return; |
|
39c5be5ca1e9
Patch from Masca to restrict the size of incoming custom smileys to a
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23010
diff
changeset
|
5694 | |
|
39c5be5ca1e9
Patch from Masca to restrict the size of incoming custom smileys to a
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23010
diff
changeset
|
5695 | if (width >= height) { |
|
39c5be5ca1e9
Patch from Masca to restrict the size of incoming custom smileys to a
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23010
diff
changeset
|
5696 | height = height * CUSTOM_SMILEY_SIZE / width; |
|
39c5be5ca1e9
Patch from Masca to restrict the size of incoming custom smileys to a
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23010
diff
changeset
|
5697 | width = CUSTOM_SMILEY_SIZE; |
|
39c5be5ca1e9
Patch from Masca to restrict the size of incoming custom smileys to a
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23010
diff
changeset
|
5698 | } else { |
|
39c5be5ca1e9
Patch from Masca to restrict the size of incoming custom smileys to a
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23010
diff
changeset
|
5699 | width = width * CUSTOM_SMILEY_SIZE / height; |
|
39c5be5ca1e9
Patch from Masca to restrict the size of incoming custom smileys to a
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23010
diff
changeset
|
5700 | height = CUSTOM_SMILEY_SIZE; |
|
39c5be5ca1e9
Patch from Masca to restrict the size of incoming custom smileys to a
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23010
diff
changeset
|
5701 | } |
|
39c5be5ca1e9
Patch from Masca to restrict the size of incoming custom smileys to a
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23010
diff
changeset
|
5702 | |
|
39c5be5ca1e9
Patch from Masca to restrict the size of incoming custom smileys to a
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23010
diff
changeset
|
5703 | gdk_pixbuf_loader_set_size(loader, width, height); |
|
39c5be5ca1e9
Patch from Masca to restrict the size of incoming custom smileys to a
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23010
diff
changeset
|
5704 | } |
|
39c5be5ca1e9
Patch from Masca to restrict the size of incoming custom smileys to a
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23010
diff
changeset
|
5705 | |
|
22655
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5706 | void |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5707 | gtk_imhtml_smiley_reload(GtkIMHtmlSmiley *smiley) |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5708 | { |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5709 | if (smiley->icon) |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5710 | g_object_unref(smiley->icon); |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5711 | if (smiley->loader) |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5712 | g_object_unref(smiley->loader); /* XXX: does this crash? */ |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5713 | |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5714 | smiley->icon = NULL; |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5715 | smiley->loader = NULL; |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5716 | |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5717 | if (smiley->file) { |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5718 | /* We do not use the pixbuf loader for a smiley that can be loaded |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5719 | * from a file. (e.g., local custom smileys) |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5720 | */ |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5721 | return; |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5722 | } |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5723 | |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5724 | smiley->loader = gdk_pixbuf_loader_new(); |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5725 | |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5726 | g_signal_connect(smiley->loader, "area_prepared", G_CALLBACK(gtk_custom_smiley_allocated), smiley); |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5727 | g_signal_connect(smiley->loader, "closed", G_CALLBACK(gtk_custom_smiley_closed), smiley); |
|
23018
39c5be5ca1e9
Patch from Masca to restrict the size of incoming custom smileys to a
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23010
diff
changeset
|
5728 | g_signal_connect(smiley->loader, "size_prepared", G_CALLBACK(gtk_custom_smiley_size_prepared), smiley); |
|
22655
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5729 | } |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5730 | |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5731 | GtkIMHtmlSmiley *gtk_imhtml_smiley_create(const char *file, const char *shortcut, gboolean hide, |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5732 | GtkIMHtmlSmileyFlags flags) |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5733 | { |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5734 | GtkIMHtmlSmiley *smiley = g_new0(GtkIMHtmlSmiley, 1); |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5735 | smiley->file = g_strdup(file); |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5736 | smiley->smile = g_strdup(shortcut); |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5737 | smiley->hidden = hide; |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5738 | smiley->flags = flags; |
|
24392
51b7f65a712d
Clean up the GtkSmileyTrees on active GtkIMHtml instances when a custom smiley
Marcus Lundblad <malu@pidgin.im>
parents:
24328
diff
changeset
|
5739 | smiley->imhtml = NULL; |
|
22655
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5740 | gtk_imhtml_smiley_reload(smiley); |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5741 | return smiley; |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5742 | } |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5743 | |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5744 | void gtk_imhtml_smiley_destroy(GtkIMHtmlSmiley *smiley) |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5745 | { |
|
24392
51b7f65a712d
Clean up the GtkSmileyTrees on active GtkIMHtml instances when a custom smiley
Marcus Lundblad <malu@pidgin.im>
parents:
24328
diff
changeset
|
5746 | gtk_imhtml_disassociate_smiley(smiley); |
|
22655
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5747 | g_free(smiley->smile); |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5748 | g_free(smiley->file); |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5749 | if (smiley->icon) |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5750 | g_object_unref(smiley->icon); |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5751 | if (smiley->loader) |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5752 | g_object_unref(smiley->loader); |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5753 | g_free(smiley); |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5754 | } |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5755 |