Thu, 01 Sep 2011 07:32:09 +0000
Make another gtkimhtml function private.
I'm definitely hoping we can get rid of all this code and switch to webkit
for 3.0.0. I haven't tried the branch.
| 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> |
|
26727
b8885bab55ab
More updates for GTK+ 3.0. This only fixes the single-includes. Fixing all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26655
diff
changeset
|
48 | #include <glib.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 | ||
| 66 | #define TOOLTIP_TIMEOUT 500 | |
| 67 | ||
| 10100 | 68 | static GtkTextViewClass *parent_class = NULL; |
| 69 | ||
|
11224
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
70 | struct scalable_data { |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
71 | GtkIMHtmlScalable *scalable; |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
72 | GtkTextMark *mark; |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
73 | }; |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
74 | |
|
27123
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
75 | typedef struct { |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
76 | GtkIMHtmlScalable *image; |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
77 | gpointer data; |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
78 | gsize datasize; |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
79 | } GtkIMHtmlImageSave; |
|
11224
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
80 | |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
81 | struct im_image_data { |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
82 | int id; |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
83 | GtkTextMark *mark; |
|
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 | |
|
24698
f9dd7117ade0
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24675
diff
changeset
|
86 | struct _GtkIMHtmlLink |
|
f9dd7117ade0
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24675
diff
changeset
|
87 | { |
|
f9dd7117ade0
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24675
diff
changeset
|
88 | GtkIMHtml *imhtml; |
|
f9dd7117ade0
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24675
diff
changeset
|
89 | gchar *url; |
|
f9dd7117ade0
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24675
diff
changeset
|
90 | GtkTextTag *tag; |
|
f9dd7117ade0
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24675
diff
changeset
|
91 | }; |
|
f9dd7117ade0
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24675
diff
changeset
|
92 | |
|
32291
394209616656
Hide GtkIMHtmlFontDetail
Mark Doliner <markdoliner@pidgin.im>
parents:
32189
diff
changeset
|
93 | typedef struct { |
|
24674
36bf974a7d78
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24588
diff
changeset
|
94 | char *name; |
|
36bf974a7d78
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24588
diff
changeset
|
95 | int length; |
|
36bf974a7d78
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24588
diff
changeset
|
96 | |
|
24698
f9dd7117ade0
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24675
diff
changeset
|
97 | gboolean (*activate)(GtkIMHtml *imhtml, GtkIMHtmlLink *link); |
|
f9dd7117ade0
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24675
diff
changeset
|
98 | gboolean (*context_menu)(GtkIMHtml *imhtml, GtkIMHtmlLink *link, GtkWidget *menu); |
|
24674
36bf974a7d78
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24588
diff
changeset
|
99 | } GtkIMHtmlProtocol; |
|
36bf974a7d78
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24588
diff
changeset
|
100 | |
|
32291
394209616656
Hide GtkIMHtmlFontDetail
Mark Doliner <markdoliner@pidgin.im>
parents:
32189
diff
changeset
|
101 | /* The five elements contained in a FONT tag */ |
|
394209616656
Hide GtkIMHtmlFontDetail
Mark Doliner <markdoliner@pidgin.im>
parents:
32189
diff
changeset
|
102 | typedef struct { |
|
31310
7835bac46b07
Add support for rendering strikethrough when received as in-line CSS,
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
31294
diff
changeset
|
103 | gushort size; |
|
7835bac46b07
Add support for rendering strikethrough when received as in-line CSS,
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
31294
diff
changeset
|
104 | gchar *face; |
|
7835bac46b07
Add support for rendering strikethrough when received as in-line CSS,
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
31294
diff
changeset
|
105 | gchar *fore; |
|
7835bac46b07
Add support for rendering strikethrough when received as in-line CSS,
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
31294
diff
changeset
|
106 | gchar *back; |
|
7835bac46b07
Add support for rendering strikethrough when received as in-line CSS,
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
31294
diff
changeset
|
107 | gchar *bg; |
|
7835bac46b07
Add support for rendering strikethrough when received as in-line CSS,
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
31294
diff
changeset
|
108 | gchar *sml; |
|
7835bac46b07
Add support for rendering strikethrough when received as in-line CSS,
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
31294
diff
changeset
|
109 | gboolean underline; |
|
7835bac46b07
Add support for rendering strikethrough when received as in-line CSS,
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
31294
diff
changeset
|
110 | gboolean strike; |
|
7835bac46b07
Add support for rendering strikethrough when received as in-line CSS,
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
31294
diff
changeset
|
111 | gshort bold; |
|
7835bac46b07
Add support for rendering strikethrough when received as in-line CSS,
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
31294
diff
changeset
|
112 | } GtkIMHtmlFontDetail; |
|
7835bac46b07
Add support for rendering strikethrough when received as in-line CSS,
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
31294
diff
changeset
|
113 | |
| 9300 | 114 | static gboolean |
| 115 | gtk_text_view_drag_motion (GtkWidget *widget, | |
| 116 | GdkDragContext *context, | |
| 117 | gint x, | |
| 118 | gint y, | |
| 119 | guint time); | |
| 120 | ||
| 8677 | 121 | static void preinsert_cb(GtkTextBuffer *buffer, GtkTextIter *iter, gchar *text, gint len, GtkIMHtml *imhtml); |
| 8061 | 122 | 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
|
123 | static void delete_cb(GtkTextBuffer *buffer, GtkTextIter *iter, GtkTextIter *end, GtkIMHtml *imhtml); |
| 10169 | 124 | static void insert_ca_cb(GtkTextBuffer *buffer, GtkTextIter *arg1, GtkTextChildAnchor *arg2, gpointer user_data); |
| 125 | static void gtk_imhtml_apply_tags_on_insert(GtkIMHtml *imhtml, GtkTextIter *start, GtkTextIter *end); | |
| 8698 | 126 | void gtk_imhtml_close_tags(GtkIMHtml *imhtml, GtkTextIter *iter); |
| 9300 | 127 | static void gtk_imhtml_link_drop_cb(GtkWidget *widget, GdkDragContext *context, gint x, gint y, guint time, gpointer user_data); |
| 8091 | 128 | 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 | 129 | static void mark_set_cb(GtkTextBuffer *buffer, GtkTextIter *arg1, GtkTextMark *mark, GtkIMHtml *imhtml); |
| 8931 | 130 | static void hijack_menu_cb(GtkIMHtml *imhtml, GtkMenu *menu, gpointer data); |
| 131 | static void paste_received_cb (GtkClipboard *clipboard, GtkSelectionData *selection_data, gpointer data); | |
| 132 | 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
|
133 | 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
|
134 | static void imhtml_toggle_bold(GtkIMHtml *imhtml); |
|
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
135 | static void imhtml_toggle_italic(GtkIMHtml *imhtml); |
|
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
136 | static void imhtml_toggle_strike(GtkIMHtml *imhtml); |
|
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
137 | static void imhtml_toggle_underline(GtkIMHtml *imhtml); |
|
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
138 | static void imhtml_font_grow(GtkIMHtml *imhtml); |
|
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
139 | static void imhtml_font_shrink(GtkIMHtml *imhtml); |
|
12672
673e2a1d2954
[gaim-migrate @ 15015]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12635
diff
changeset
|
140 | static void imhtml_clear_formatting(GtkIMHtml *imhtml); |
|
24674
36bf974a7d78
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24588
diff
changeset
|
141 | static int gtk_imhtml_is_protocol(const char *text); |
|
24698
f9dd7117ade0
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24675
diff
changeset
|
142 | static void gtk_imhtml_activate_tag(GtkIMHtml *imhtml, GtkTextTag *tag); |
|
f9dd7117ade0
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24675
diff
changeset
|
143 | static void gtk_imhtml_link_destroy(GtkIMHtmlLink *link); |
| 8061 | 144 | |
|
10899
87d9aec5b72d
[gaim-migrate @ 12619]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10871
diff
changeset
|
145 | /* POINT_SIZE converts from AIM font sizes to a point size scale factor. */ |
| 3922 | 146 | #define MAX_FONT_SIZE 7 |
|
10900
cc19dfd83910
[gaim-migrate @ 12621]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10899
diff
changeset
|
147 | #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
|
148 | 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
|
149 | |
|
10184
543c9a84ce16
[gaim-migrate @ 11299]
Mark Doliner <markdoliner@pidgin.im>
parents:
10169
diff
changeset
|
150 | enum { |
| 8677 | 151 | TARGET_HTML, |
| 8061 | 152 | TARGET_UTF8_STRING, |
| 153 | TARGET_COMPOUND_TEXT, | |
| 154 | TARGET_STRING, | |
| 155 | TARGET_TEXT | |
| 156 | }; | |
| 157 | ||
| 8091 | 158 | enum { |
| 8420 | 159 | URL_CLICKED, |
| 160 | BUTTONS_UPDATE, | |
| 161 | TOGGLE_FORMAT, | |
| 8427 | 162 | CLEAR_FORMAT, |
| 8506 | 163 | UPDATE_FORMAT, |
| 10108 | 164 | 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
|
165 | 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
|
166 | REDO, |
|
29909
3b74346e22d5
Allow binding 'Paste as Plain Text'.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
29855
diff
changeset
|
167 | PASTE, |
| 8420 | 168 | LAST_SIGNAL |
| 169 | }; | |
| 170 | static guint signals [LAST_SIGNAL] = { 0 }; | |
| 171 | ||
|
17546
51b1c1e2c3fe
Maintain global poitners to the clipboard selection text, with the aim of
Sean Egan <seanegan@pidgin.im>
parents:
17406
diff
changeset
|
172 | 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
|
173 | 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
|
174 | 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
|
175 | |
|
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
|
176 | static const GtkTargetEntry selection_targets[] = { |
|
15111
e427dd6f3b7e
[gaim-migrate @ 17833]
Daniel Atallah <datallah@pidgin.im>
parents:
15093
diff
changeset
|
177 | #ifndef _WIN32 |
| 8566 | 178 | { "text/html", 0, TARGET_HTML }, |
|
15111
e427dd6f3b7e
[gaim-migrate @ 17833]
Daniel Atallah <datallah@pidgin.im>
parents:
15093
diff
changeset
|
179 | #else |
|
e427dd6f3b7e
[gaim-migrate @ 17833]
Daniel Atallah <datallah@pidgin.im>
parents:
15093
diff
changeset
|
180 | { "HTML Format", 0, TARGET_HTML }, |
|
e427dd6f3b7e
[gaim-migrate @ 17833]
Daniel Atallah <datallah@pidgin.im>
parents:
15093
diff
changeset
|
181 | #endif |
| 8061 | 182 | { "UTF8_STRING", 0, TARGET_UTF8_STRING }, |
| 183 | { "COMPOUND_TEXT", 0, TARGET_COMPOUND_TEXT }, | |
| 184 | { "STRING", 0, TARGET_STRING }, | |
| 185 | { "TEXT", 0, TARGET_TEXT}}; | |
| 186 | ||
|
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
|
187 | static const GtkTargetEntry link_drag_drop_targets[] = { |
|
10145
f1405f65ff41
[gaim-migrate @ 11218]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10110
diff
changeset
|
188 | GTK_IMHTML_DND_TARGETS |
|
f1405f65ff41
[gaim-migrate @ 11218]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10110
diff
changeset
|
189 | }; |
| 8091 | 190 | |
| 8692 | 191 | #ifdef _WIN32 |
| 192 | static gchar * | |
| 193 | clipboard_win32_to_html(char *clipboard) { | |
| 9465 | 194 | const char *header; |
| 8693 | 195 | const char *begin, *end; |
|
10016
18418b9fa749
[gaim-migrate @ 10935]
Daniel Atallah <datallah@pidgin.im>
parents:
10013
diff
changeset
|
196 | gint start = 0; |
|
18418b9fa749
[gaim-migrate @ 10935]
Daniel Atallah <datallah@pidgin.im>
parents:
10013
diff
changeset
|
197 | gint finish = 0; |
| 8692 | 198 | gchar *html; |
|
10016
18418b9fa749
[gaim-migrate @ 10935]
Daniel Atallah <datallah@pidgin.im>
parents:
10013
diff
changeset
|
199 | gchar **split; |
|
18418b9fa749
[gaim-migrate @ 10935]
Daniel Atallah <datallah@pidgin.im>
parents:
10013
diff
changeset
|
200 | int clipboard_length = 0; |
| 9465 | 201 | |
| 202 | #if 0 /* Debugging for Windows clipboard */ | |
| 9467 | 203 | FILE *fd; |
| 204 | ||
| 15884 | 205 | purple_debug_info("imhtml clipboard", "from clipboard: %s\n", clipboard); |
| 206 | ||
|
29855
234f74a60570
I think this works around the problem with the Win32 Clipboard and GTK+ 2.16.
Daniel Atallah <datallah@pidgin.im>
parents:
29724
diff
changeset
|
207 | fd = g_fopen("c:\\purplecb.txt", "wb"); |
| 9465 | 208 | fprintf(fd, "%s", clipboard); |
| 209 | fclose(fd); | |
| 210 | #endif | |
| 211 | ||
|
10016
18418b9fa749
[gaim-migrate @ 10935]
Daniel Atallah <datallah@pidgin.im>
parents:
10013
diff
changeset
|
212 | clipboard_length = strlen(clipboard); |
|
18418b9fa749
[gaim-migrate @ 10935]
Daniel Atallah <datallah@pidgin.im>
parents:
10013
diff
changeset
|
213 | |
|
18418b9fa749
[gaim-migrate @ 10935]
Daniel Atallah <datallah@pidgin.im>
parents:
10013
diff
changeset
|
214 | if (!(header = strstr(clipboard, "StartFragment:")) || (header - clipboard) >= clipboard_length) |
| 9465 | 215 | return NULL; |
| 216 | sscanf(header, "StartFragment:%d", &start); | |
| 217 | ||
|
10016
18418b9fa749
[gaim-migrate @ 10935]
Daniel Atallah <datallah@pidgin.im>
parents:
10013
diff
changeset
|
218 | if (!(header = strstr(clipboard, "EndFragment:")) || (header - clipboard) >= clipboard_length) |
|
18418b9fa749
[gaim-migrate @ 10935]
Daniel Atallah <datallah@pidgin.im>
parents:
10013
diff
changeset
|
219 | return NULL; |
| 9465 | 220 | sscanf(header, "EndFragment:%d", &finish); |
| 221 | ||
|
10016
18418b9fa749
[gaim-migrate @ 10935]
Daniel Atallah <datallah@pidgin.im>
parents:
10013
diff
changeset
|
222 | if (finish > clipboard_length) |
|
18418b9fa749
[gaim-migrate @ 10935]
Daniel Atallah <datallah@pidgin.im>
parents:
10013
diff
changeset
|
223 | finish = clipboard_length; |
|
18418b9fa749
[gaim-migrate @ 10935]
Daniel Atallah <datallah@pidgin.im>
parents:
10013
diff
changeset
|
224 | |
|
18418b9fa749
[gaim-migrate @ 10935]
Daniel Atallah <datallah@pidgin.im>
parents:
10013
diff
changeset
|
225 | if (start > finish) |
|
18418b9fa749
[gaim-migrate @ 10935]
Daniel Atallah <datallah@pidgin.im>
parents:
10013
diff
changeset
|
226 | start = finish; |
|
18418b9fa749
[gaim-migrate @ 10935]
Daniel Atallah <datallah@pidgin.im>
parents:
10013
diff
changeset
|
227 | |
| 9465 | 228 | begin = clipboard + start; |
| 229 | ||
|
10016
18418b9fa749
[gaim-migrate @ 10935]
Daniel Atallah <datallah@pidgin.im>
parents:
10013
diff
changeset
|
230 | end = clipboard + finish; |
|
18418b9fa749
[gaim-migrate @ 10935]
Daniel Atallah <datallah@pidgin.im>
parents:
10013
diff
changeset
|
231 | |
|
18418b9fa749
[gaim-migrate @ 10935]
Daniel Atallah <datallah@pidgin.im>
parents:
10013
diff
changeset
|
232 | html = g_strndup(begin, end - begin); |
|
18418b9fa749
[gaim-migrate @ 10935]
Daniel Atallah <datallah@pidgin.im>
parents:
10013
diff
changeset
|
233 | |
|
18418b9fa749
[gaim-migrate @ 10935]
Daniel Atallah <datallah@pidgin.im>
parents:
10013
diff
changeset
|
234 | /* 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
|
235 | split = g_strsplit(html, "\r\n", 0); |
|
18418b9fa749
[gaim-migrate @ 10935]
Daniel Atallah <datallah@pidgin.im>
parents:
10013
diff
changeset
|
236 | g_free(html); |
|
18418b9fa749
[gaim-migrate @ 10935]
Daniel Atallah <datallah@pidgin.im>
parents:
10013
diff
changeset
|
237 | html = g_strjoinv("\n", split); |
|
18418b9fa749
[gaim-migrate @ 10935]
Daniel Atallah <datallah@pidgin.im>
parents:
10013
diff
changeset
|
238 | g_strfreev(split); |
|
18418b9fa749
[gaim-migrate @ 10935]
Daniel Atallah <datallah@pidgin.im>
parents:
10013
diff
changeset
|
239 | |
| 9465 | 240 | #if 0 /* Debugging for Windows clipboard */ |
| 15884 | 241 | purple_debug_info("imhtml clipboard", "HTML fragment: '%s'\n", html); |
| 9465 | 242 | #endif |
| 243 | ||
| 8707 | 244 | return html; |
| 8692 | 245 | } |
| 246 | ||
| 247 | static gchar * | |
| 248 | clipboard_html_to_win32(char *html) { | |
| 8693 | 249 | int length; |
|
11240
cd4ca16ff57c
[gaim-migrate @ 13399]
Richard Laager <rlaager@pidgin.im>
parents:
11234
diff
changeset
|
250 | GString *clipboard; |
| 8692 | 251 | |
| 8693 | 252 | if (html == NULL) |
| 253 | return NULL; | |
| 8692 | 254 | |
| 255 | length = strlen(html); | |
| 9465 | 256 | clipboard = g_string_new ("Version:1.0\r\n"); |
| 8692 | 257 | 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
|
258 | g_string_append_printf(clipboard, "EndHTML:%010d\r\n", 147 + length); |
| 9465 | 259 | 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
|
260 | g_string_append_printf(clipboard, "EndFragment:%010d\r\n", 127 + length); |
| 9465 | 261 | g_string_append(clipboard, "<!--StartFragment-->\r\n"); |
| 8692 | 262 | g_string_append(clipboard, html); |
| 9465 | 263 | g_string_append(clipboard, "\r\n<!--EndFragment-->"); |
|
14101
89a79c2a971e
[gaim-migrate @ 16643]
Mark Doliner <markdoliner@pidgin.im>
parents:
14097
diff
changeset
|
264 | |
|
89a79c2a971e
[gaim-migrate @ 16643]
Mark Doliner <markdoliner@pidgin.im>
parents:
14097
diff
changeset
|
265 | return g_string_free(clipboard, FALSE); |
| 8692 | 266 | } |
|
10901
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
267 | |
|
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
268 | static gboolean clipboard_paste_html_win32(GtkIMHtml *imhtml) { |
|
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
269 | gboolean pasted = FALSE; |
|
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
270 | |
|
15111
e427dd6f3b7e
[gaim-migrate @ 17833]
Daniel Atallah <datallah@pidgin.im>
parents:
15093
diff
changeset
|
271 | /* Win32 clipboard format value, and functions to convert back and |
|
e427dd6f3b7e
[gaim-migrate @ 17833]
Daniel Atallah <datallah@pidgin.im>
parents:
15093
diff
changeset
|
272 | * forth between HTML and the clipboard format. |
|
e427dd6f3b7e
[gaim-migrate @ 17833]
Daniel Atallah <datallah@pidgin.im>
parents:
15093
diff
changeset
|
273 | */ |
|
e427dd6f3b7e
[gaim-migrate @ 17833]
Daniel Atallah <datallah@pidgin.im>
parents:
15093
diff
changeset
|
274 | static UINT win_html_fmt = 0; |
|
e427dd6f3b7e
[gaim-migrate @ 17833]
Daniel Atallah <datallah@pidgin.im>
parents:
15093
diff
changeset
|
275 | |
|
e427dd6f3b7e
[gaim-migrate @ 17833]
Daniel Atallah <datallah@pidgin.im>
parents:
15093
diff
changeset
|
276 | /* Register HTML Format as desired clipboard format */ |
|
e427dd6f3b7e
[gaim-migrate @ 17833]
Daniel Atallah <datallah@pidgin.im>
parents:
15093
diff
changeset
|
277 | if (!win_html_fmt) |
|
e427dd6f3b7e
[gaim-migrate @ 17833]
Daniel Atallah <datallah@pidgin.im>
parents:
15093
diff
changeset
|
278 | win_html_fmt = RegisterClipboardFormat("HTML Format"); |
|
e427dd6f3b7e
[gaim-migrate @ 17833]
Daniel Atallah <datallah@pidgin.im>
parents:
15093
diff
changeset
|
279 | |
|
10901
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
280 | if (gtk_text_view_get_editable(GTK_TEXT_VIEW(imhtml)) |
|
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
281 | && IsClipboardFormatAvailable(win_html_fmt)) { |
|
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
282 | gboolean error_reading_clipboard = FALSE; |
|
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
283 | HWND hwnd = GDK_WINDOW_HWND(GTK_WIDGET(imhtml)->window); |
|
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
284 | |
|
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
285 | if (OpenClipboard(hwnd)) { |
|
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
286 | HGLOBAL hdata = GetClipboardData(win_html_fmt); |
|
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
287 | if (hdata == NULL) { |
|
15111
e427dd6f3b7e
[gaim-migrate @ 17833]
Daniel Atallah <datallah@pidgin.im>
parents:
15093
diff
changeset
|
288 | if (GetLastError() != ERROR_SUCCESS) |
|
e427dd6f3b7e
[gaim-migrate @ 17833]
Daniel Atallah <datallah@pidgin.im>
parents:
15093
diff
changeset
|
289 | error_reading_clipboard = TRUE; |
|
10901
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
290 | } else { |
|
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
291 | char *buffer = GlobalLock(hdata); |
|
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
292 | if (buffer == NULL) { |
|
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
293 | error_reading_clipboard = TRUE; |
|
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
294 | } else { |
|
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
295 | char *text = clipboard_win32_to_html( |
|
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
296 | buffer); |
|
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
297 | imhtml_paste_insert(imhtml, text, |
|
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
298 | FALSE); |
|
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
299 | g_free(text); |
|
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
300 | pasted = TRUE; |
|
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
301 | } |
|
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
302 | GlobalUnlock(hdata); |
|
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
303 | } |
|
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
304 | |
|
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
305 | CloseClipboard(); |
|
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
306 | } else { |
|
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
307 | error_reading_clipboard = TRUE; |
|
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
308 | } |
|
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
309 | |
|
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
310 | if (error_reading_clipboard) { |
|
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
311 | gchar *err_msg = g_win32_error_message(GetLastError()); |
| 15884 | 312 | purple_debug_info("html clipboard", |
|
10901
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
313 | "Unable to read clipboard data: %s\n", |
|
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
314 | err_msg ? err_msg : "Unknown Error"); |
|
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
315 | g_free(err_msg); |
|
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
316 | } |
|
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
317 | } |
|
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
318 | |
|
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
319 | return pasted; |
|
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
320 | } |
| 8692 | 321 | #endif |
| 322 | ||
| 4032 | 323 | 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
|
324 | gtk_smiley_tree_new (void) |
| 4032 | 325 | { |
| 326 | return g_new0 (GtkSmileyTree, 1); | |
| 327 | } | |
| 328 | ||
| 329 | static void | |
| 330 | gtk_smiley_tree_insert (GtkSmileyTree *tree, | |
| 4263 | 331 | GtkIMHtmlSmiley *smiley) |
| 4032 | 332 | { |
| 333 | GtkSmileyTree *t = tree; | |
| 4263 | 334 | const gchar *x = smiley->smile; |
| 4032 | 335 | |
|
12229
ad8d3ae8fc1b
[gaim-migrate @ 14531]
Michael Carlson <corfe83@users.sourceforge.net>
parents:
12072
diff
changeset
|
336 | if (!(*x)) |
| 4032 | 337 | return; |
| 338 | ||
|
12229
ad8d3ae8fc1b
[gaim-migrate @ 14531]
Michael Carlson <corfe83@users.sourceforge.net>
parents:
12072
diff
changeset
|
339 | do { |
| 4032 | 340 | gchar *pos; |
| 341 | gint index; | |
| 342 | ||
| 343 | if (!t->values) | |
| 344 | t->values = g_string_new (""); | |
| 345 | ||
| 346 | pos = strchr (t->values->str, *x); | |
| 347 | if (!pos) { | |
| 348 | t->values = g_string_append_c (t->values, *x); | |
| 349 | index = t->values->len - 1; | |
| 350 | t->children = g_realloc (t->children, t->values->len * sizeof (GtkSmileyTree *)); | |
| 351 | t->children [index] = g_new0 (GtkSmileyTree, 1); | |
| 352 | } else | |
| 7386 | 353 | index = GPOINTER_TO_INT(pos) - GPOINTER_TO_INT(t->values->str); |
| 8061 | 354 | |
| 4032 | 355 | t = t->children [index]; |
| 8061 | 356 | |
| 4032 | 357 | x++; |
|
12229
ad8d3ae8fc1b
[gaim-migrate @ 14531]
Michael Carlson <corfe83@users.sourceforge.net>
parents:
12072
diff
changeset
|
358 | } while (*x); |
| 8061 | 359 | |
| 4263 | 360 | t->image = smiley; |
| 4032 | 361 | } |
| 4041 | 362 | |
| 4263 | 363 | |
|
11677
89c2ab8d2ebf
[gaim-migrate @ 13963]
Mark Doliner <markdoliner@pidgin.im>
parents:
11586
diff
changeset
|
364 | static void |
|
89c2ab8d2ebf
[gaim-migrate @ 13963]
Mark Doliner <markdoliner@pidgin.im>
parents:
11586
diff
changeset
|
365 | gtk_smiley_tree_destroy (GtkSmileyTree *tree) |
| 4032 | 366 | { |
|
11701
8cf812de5e92
[gaim-migrate @ 13992]
Michael Carlson <corfe83@users.sourceforge.net>
parents:
11677
diff
changeset
|
367 | GSList *list = g_slist_prepend (NULL, tree); |
| 4032 | 368 | |
| 369 | while (list) { | |
| 370 | GtkSmileyTree *t = list->data; | |
|
12229
ad8d3ae8fc1b
[gaim-migrate @ 14531]
Michael Carlson <corfe83@users.sourceforge.net>
parents:
12072
diff
changeset
|
371 | gsize i; |
| 4032 | 372 | list = g_slist_remove(list, t); |
| 7384 | 373 | if (t && t->values) { |
| 4032 | 374 | for (i = 0; i < t->values->len; i++) |
|
11701
8cf812de5e92
[gaim-migrate @ 13992]
Michael Carlson <corfe83@users.sourceforge.net>
parents:
11677
diff
changeset
|
375 | list = g_slist_prepend (list, t->children [i]); |
| 4032 | 376 | g_string_free (t->values, TRUE); |
| 377 | g_free (t->children); | |
| 378 | } | |
|
25888
d0fdd378a635
Remove trailing whitespace
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
379 | |
| 4032 | 380 | g_free (t); |
| 381 | } | |
| 382 | } | |
| 383 | ||
|
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
|
384 | 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
|
385 | |
|
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
|
386 | static void gtk_imhtml_size_allocate(GtkWidget *widget, GtkAllocation *alloc) |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
387 | { |
|
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
|
388 | GtkIMHtml *imhtml = GTK_IMHTML(widget); |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
389 | GdkRectangle rect; |
| 8726 | 390 | 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
|
391 | 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
|
392 | 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
|
393 | 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
|
394 | |
|
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 | gtk_text_buffer_get_end_iter(imhtml->text_buffer, &iter); |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
396 | |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
397 | 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
|
398 | 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
|
399 | |
|
e1f64090d32e
Do not show tooltips for <HR> or <IMG>s in gtkimhtml. Fixes #5480.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22772
diff
changeset
|
400 | 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
|
401 | 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
|
402 | 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
|
403 | } |
|
e1f64090d32e
Do not show tooltips for <HR> or <IMG>s in gtkimhtml. Fixes #5480.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22772
diff
changeset
|
404 | |
|
e1f64090d32e
Do not show tooltips for <HR> or <IMG>s in gtkimhtml. Fixes #5480.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22772
diff
changeset
|
405 | 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
|
406 | GList *iter = GTK_IMHTML(widget)->scalables; |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
407 | |
| 8726 | 408 | xminus = gtk_text_view_get_left_margin(GTK_TEXT_VIEW(widget)) + |
| 409 | gtk_text_view_get_right_margin(GTK_TEXT_VIEW(widget)); | |
| 410 | ||
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
411 | while(iter){ |
|
11224
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
412 | struct scalable_data *sd = iter->data; |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
413 | GtkIMHtmlScalable *scale = GTK_IMHTML_SCALABLE(sd->scalable); |
| 8726 | 414 | scale->scale(scale, rect.width - xminus, rect.height); |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
415 | |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
416 | iter = iter->next; |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
417 | } |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
418 | } |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
419 | |
|
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
|
420 | 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
|
421 | 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
|
422 | |
| 18985 | 423 | /* 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
|
424 | 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
|
425 | 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
|
426 | gtk_imhtml_scroll_to_end(imhtml, FALSE); |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
427 | } |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
428 | |
|
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
|
429 | #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
|
430 | #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
|
431 | #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
|
432 | #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
|
433 | #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
|
434 | #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
|
435 | |
|
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 | 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
|
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 | 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
|
439 | 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
|
440 | { |
|
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 | 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
|
442 | 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
|
443 | 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
|
444 | 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
|
445 | 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
|
446 | } 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
|
447 | {"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
|
448 | {"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
|
449 | {"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
|
450 | {"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
|
451 | {"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
|
452 | {"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
|
453 | {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
|
454 | }; |
|
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
|
455 | 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
|
456 | 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
|
457 | |
|
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
|
458 | 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
|
459 | 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
|
460 | 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
|
461 | 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
|
462 | 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
|
463 | 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
|
464 | } |
|
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
|
465 | 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
|
466 | 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
|
467 | 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
|
468 | 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
|
469 | } 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
|
470 | 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
|
471 | 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
|
472 | 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
|
473 | } |
|
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
|
474 | } |
|
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
|
475 | 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
|
476 | } |
|
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
|
477 | |
|
28935
84dbc0ca215d
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28932
diff
changeset
|
478 | static gboolean |
|
84dbc0ca215d
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28932
diff
changeset
|
479 | imhtml_get_iter_bounds(GtkIMHtml *imhtml, GtkTextIter *start, GtkTextIter *end) |
|
84dbc0ca215d
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28932
diff
changeset
|
480 | { |
|
84dbc0ca215d
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28932
diff
changeset
|
481 | if (imhtml->wbfo) { |
|
84dbc0ca215d
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28932
diff
changeset
|
482 | gtk_text_buffer_get_bounds(imhtml->text_buffer, start, end); |
|
84dbc0ca215d
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28932
diff
changeset
|
483 | return TRUE; |
|
84dbc0ca215d
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28932
diff
changeset
|
484 | } else if (imhtml->editable) { |
|
84dbc0ca215d
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28932
diff
changeset
|
485 | if (!gtk_text_buffer_get_selection_bounds(imhtml->text_buffer, start, end)) { |
|
84dbc0ca215d
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28932
diff
changeset
|
486 | GtkTextMark *mark = gtk_text_buffer_get_insert(imhtml->text_buffer); |
|
84dbc0ca215d
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28932
diff
changeset
|
487 | gtk_text_buffer_get_iter_at_mark(imhtml->text_buffer, start, mark); |
|
84dbc0ca215d
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28932
diff
changeset
|
488 | *end = *start; |
|
84dbc0ca215d
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28932
diff
changeset
|
489 | } |
|
84dbc0ca215d
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28932
diff
changeset
|
490 | return TRUE; |
|
84dbc0ca215d
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28932
diff
changeset
|
491 | } |
|
84dbc0ca215d
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28932
diff
changeset
|
492 | |
|
84dbc0ca215d
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28932
diff
changeset
|
493 | return FALSE; |
|
84dbc0ca215d
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28932
diff
changeset
|
494 | } |
|
84dbc0ca215d
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28932
diff
changeset
|
495 | |
|
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
|
496 | 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
|
497 | 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
|
498 | { |
|
7be2af5c9129
Show visited links in a different color. This also plugs a memory leak
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23548
diff
changeset
|
499 | 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
|
500 | 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
|
501 | 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
|
502 | 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
|
503 | 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
|
504 | 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
|
505 | } 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
|
506 | 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
|
507 | } |
|
7be2af5c9129
Show visited links in a different color. This also plugs a memory leak
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23548
diff
changeset
|
508 | } |
|
7be2af5c9129
Show visited links in a different color. This also plugs a memory leak
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23548
diff
changeset
|
509 | |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
510 | static gint |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
511 | gtk_imhtml_tip_paint (GtkIMHtml *imhtml) |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
512 | { |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
513 | PangoLayout *layout; |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
514 | |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
515 | g_return_val_if_fail(GTK_IS_IMHTML(imhtml), FALSE); |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
516 | |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
517 | layout = gtk_widget_create_pango_layout(imhtml->tip_window, imhtml->tip); |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
518 | |
| 8061 | 519 | 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
|
520 | GTK_STATE_NORMAL, GTK_SHADOW_OUT, NULL, imhtml->tip_window, |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
521 | "tooltip", 0, 0, -1, -1); |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
522 | |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
523 | 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
|
524 | FALSE, NULL, imhtml->tip_window, NULL, 4, 4, layout); |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
525 | |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
526 | g_object_unref(layout); |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
527 | return FALSE; |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
528 | } |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
529 | |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
530 | static gint |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
531 | gtk_imhtml_tip (gpointer data) |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
532 | { |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
533 | GtkIMHtml *imhtml = data; |
| 8526 | 534 | PangoFontMetrics *font_metrics; |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
535 | PangoLayout *layout; |
| 8526 | 536 | PangoFont *font; |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
537 | |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
538 | gint gap, x, y, h, w, scr_w, baseline_skip; |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
539 | |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
540 | g_return_val_if_fail(GTK_IS_IMHTML(imhtml), FALSE); |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
541 | |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
542 | if (!imhtml->tip || !GTK_WIDGET_DRAWABLE (GTK_WIDGET(imhtml))) { |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
543 | imhtml->tip_timer = 0; |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
544 | return FALSE; |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
545 | } |
| 8061 | 546 | |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
547 | if (imhtml->tip_window){ |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
548 | gtk_widget_destroy (imhtml->tip_window); |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
549 | imhtml->tip_window = NULL; |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
550 | } |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
551 | |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
552 | imhtml->tip_timer = 0; |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
553 | imhtml->tip_window = gtk_window_new (GTK_WINDOW_POPUP); |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
554 | gtk_widget_set_app_paintable (imhtml->tip_window, TRUE); |
|
29153
ee7369d8f401
Call gtk_window_set_title() for the GtkIMHtml tip window, to avoid the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
28940
diff
changeset
|
555 | gtk_window_set_title(GTK_WINDOW(imhtml->tip_window), "GtkIMHtml"); |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
556 | gtk_window_set_resizable (GTK_WINDOW (imhtml->tip_window), FALSE); |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
557 | gtk_widget_set_name (imhtml->tip_window, "gtk-tooltips"); |
|
22594
4fe64dc3d266
Set the TOOLTIP hint on imhtml link tooltips. Thanks to Danny Baumann for
Will Thompson <resiak@pidgin.im>
parents:
22532
diff
changeset
|
558 | 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
|
559 | GDK_WINDOW_TYPE_HINT_TOOLTIP); |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
560 | g_signal_connect_swapped (G_OBJECT (imhtml->tip_window), "expose_event", |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
561 | G_CALLBACK (gtk_imhtml_tip_paint), imhtml); |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
562 | |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
563 | gtk_widget_ensure_style (imhtml->tip_window); |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
564 | layout = gtk_widget_create_pango_layout(imhtml->tip_window, imhtml->tip); |
| 8526 | 565 | font = pango_context_load_font(pango_layout_get_context(layout), |
| 566 | imhtml->tip_window->style->font_desc); | |
| 567 | ||
| 568 | if (font == NULL) { | |
| 569 | char *tmp = pango_font_description_to_string( | |
| 570 | imhtml->tip_window->style->font_desc); | |
| 571 | ||
| 15884 | 572 | purple_debug(PURPLE_DEBUG_ERROR, "gtk_imhtml_tip", |
| 8526 | 573 | "pango_context_load_font() couldn't load font: '%s'\n", |
| 574 | tmp); | |
| 575 | g_free(tmp); | |
| 576 | ||
|
23174
6a5b2c601492
applied changes from a341780d901f6351a5cf768a08d30c8882d6cf2f
Daniel Atallah <datallah@pidgin.im>
parents:
22970
diff
changeset
|
577 | g_object_unref(layout); |
| 8526 | 578 | return FALSE; |
| 579 | } | |
| 580 | ||
| 581 | font_metrics = pango_font_get_metrics(font, NULL); | |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
582 | |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
583 | pango_layout_get_pixel_size(layout, &scr_w, NULL); |
| 8526 | 584 | gap = PANGO_PIXELS((pango_font_metrics_get_ascent(font_metrics) + |
| 585 | pango_font_metrics_get_descent(font_metrics))/ 4); | |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
586 | |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
587 | if (gap < 2) |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
588 | gap = 2; |
| 8526 | 589 | baseline_skip = PANGO_PIXELS(pango_font_metrics_get_ascent(font_metrics) + |
| 590 | pango_font_metrics_get_descent(font_metrics)); | |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
591 | w = 8 + scr_w; |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
592 | h = 8 + baseline_skip; |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
593 | |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
594 | gdk_window_get_pointer (NULL, &x, &y, NULL); |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
595 | if (GTK_WIDGET_NO_WINDOW (GTK_WIDGET(imhtml))) |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
596 | y += GTK_WIDGET(imhtml)->allocation.y; |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
597 | |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
598 | scr_w = gdk_screen_width(); |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
599 | |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
600 | x -= ((w >> 1) + 4); |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
601 | |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
602 | if ((x + w) > scr_w) |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
603 | x -= (x + w) - scr_w; |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
604 | else if (x < 0) |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
605 | x = 0; |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
606 | |
| 8526 | 607 | y = y + PANGO_PIXELS(pango_font_metrics_get_ascent(font_metrics) + |
| 608 | pango_font_metrics_get_descent(font_metrics)); | |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
609 | |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
610 | 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
|
611 | gtk_window_move (GTK_WINDOW(imhtml->tip_window), x, y); |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
612 | gtk_widget_show (imhtml->tip_window); |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
613 | |
| 8526 | 614 | pango_font_metrics_unref(font_metrics); |
|
23174
6a5b2c601492
applied changes from a341780d901f6351a5cf768a08d30c8882d6cf2f
Daniel Atallah <datallah@pidgin.im>
parents:
22970
diff
changeset
|
615 | g_object_unref(font); |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
616 | g_object_unref(layout); |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
617 | |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
618 | return FALSE; |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
619 | } |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
620 | |
|
11844
57ad7c52cc9c
[gaim-migrate @ 14135]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11840
diff
changeset
|
621 | static gboolean |
|
57ad7c52cc9c
[gaim-migrate @ 14135]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11840
diff
changeset
|
622 | gtk_motion_event_notify(GtkWidget *imhtml, GdkEventMotion *event, gpointer data) |
| 8061 | 623 | { |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
624 | GtkTextIter iter; |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
625 | GdkWindow *win = event->window; |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
626 | int x, y; |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
627 | char *tip = NULL; |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
628 | GSList *tags = NULL, *templist = NULL; |
| 10799 | 629 | GtkTextTag *tag = NULL, *oldprelit_tag; |
|
18543
c590aed61aa4
Show tooltip for smileys. Fixes #1981.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18371
diff
changeset
|
630 | GtkTextChildAnchor* anchor; |
|
c590aed61aa4
Show tooltip for smileys. Fixes #1981.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18371
diff
changeset
|
631 | gboolean hand = TRUE; |
|
29309
b94fa8bc1a03
Change the cursor and act on double click on usernames in chat history.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
29288
diff
changeset
|
632 | GdkCursor *cursor = NULL; |
| 10799 | 633 | |
| 634 | oldprelit_tag = GTK_IMHTML(imhtml)->prelit_tag; | |
| 635 | ||
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
636 | gdk_window_get_pointer(GTK_WIDGET(imhtml)->window, NULL, NULL, NULL); |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
637 | gtk_text_view_window_to_buffer_coords(GTK_TEXT_VIEW(imhtml), GTK_TEXT_WINDOW_WIDGET, |
| 10799 | 638 | event->x, event->y, &x, &y); |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
639 | 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
|
640 | tags = gtk_text_iter_get_tags(&iter); |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
641 | |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
642 | templist = tags; |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
643 | while (templist) { |
| 10799 | 644 | tag = templist->data; |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
645 | tip = g_object_get_data(G_OBJECT(tag), "link_url"); |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
646 | if (tip) |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
647 | break; |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
648 | templist = templist->next; |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
649 | } |
| 8061 | 650 | |
|
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
|
651 | if (tip && (!tag || !g_object_get_data(G_OBJECT(tag), "visited"))) { |
| 10799 | 652 | GTK_IMHTML(imhtml)->prelit_tag = tag; |
| 653 | 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
|
654 | 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
|
655 | 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
|
656 | if (pre) { |
| 10799 | 657 | 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
|
658 | 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
|
659 | } else |
|
12253
5025434b18f8
[gaim-migrate @ 14555]
Mark Doliner <markdoliner@pidgin.im>
parents:
12230
diff
changeset
|
660 | g_object_set(G_OBJECT(tag), "foreground", "#70a0ff", NULL); |
| 10799 | 661 | } |
| 662 | } else { | |
| 663 | GTK_IMHTML(imhtml)->prelit_tag = NULL; | |
| 664 | } | |
|
11572
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
665 | |
|
10834
5fd1dfd395e8
[gaim-migrate @ 12505]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10826
diff
changeset
|
666 | 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
|
667 | gtk_imhtml_set_link_color(GTK_IMHTML(imhtml), oldprelit_tag); |
| 10799 | 668 | } |
| 669 | ||
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
670 | if (GTK_IMHTML(imhtml)->tip) { |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
671 | if ((tip == GTK_IMHTML(imhtml)->tip)) { |
| 21069 | 672 | g_slist_free(tags); |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
673 | return FALSE; |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
674 | } |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
675 | /* 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
|
676 | if (GTK_IMHTML(imhtml)->tip_window) { |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
677 | gtk_widget_destroy(GTK_IMHTML(imhtml)->tip_window); |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
678 | GTK_IMHTML(imhtml)->tip_window = NULL; |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
679 | } |
| 8061 | 680 | if (GTK_IMHTML(imhtml)->editable) |
|
29309
b94fa8bc1a03
Change the cursor and act on double click on usernames in chat history.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
29288
diff
changeset
|
681 | cursor = GTK_IMHTML(imhtml)->text_cursor; |
| 8061 | 682 | else |
|
29309
b94fa8bc1a03
Change the cursor and act on double click on usernames in chat history.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
29288
diff
changeset
|
683 | cursor = GTK_IMHTML(imhtml)->arrow_cursor; |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
684 | if (GTK_IMHTML(imhtml)->tip_timer) |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
685 | g_source_remove(GTK_IMHTML(imhtml)->tip_timer); |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
686 | GTK_IMHTML(imhtml)->tip_timer = 0; |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
687 | } |
| 8061 | 688 | |
|
18543
c590aed61aa4
Show tooltip for smileys. Fixes #1981.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18371
diff
changeset
|
689 | /* 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
|
690 | 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
|
691 | 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
|
692 | 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
|
693 | hand = FALSE; |
|
c590aed61aa4
Show tooltip for smileys. Fixes #1981.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18371
diff
changeset
|
694 | } |
|
c590aed61aa4
Show tooltip for smileys. Fixes #1981.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18371
diff
changeset
|
695 | |
|
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
|
696 | if (tip && *tip) { |
| 8061 | 697 | GTK_IMHTML(imhtml)->tip_timer = g_timeout_add (TOOLTIP_TIMEOUT, |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
698 | gtk_imhtml_tip, imhtml); |
|
29309
b94fa8bc1a03
Change the cursor and act on double click on usernames in chat history.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
29288
diff
changeset
|
699 | } else if (!tip) { |
|
b94fa8bc1a03
Change the cursor and act on double click on usernames in chat history.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
29288
diff
changeset
|
700 | hand = FALSE; |
|
b94fa8bc1a03
Change the cursor and act on double click on usernames in chat history.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
29288
diff
changeset
|
701 | for (templist = tags; templist; templist = templist->next) { |
|
b94fa8bc1a03
Change the cursor and act on double click on usernames in chat history.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
29288
diff
changeset
|
702 | tag = templist->data; |
|
b94fa8bc1a03
Change the cursor and act on double click on usernames in chat history.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
29288
diff
changeset
|
703 | if ((tip = g_object_get_data(G_OBJECT(tag), "cursor"))) { |
|
b94fa8bc1a03
Change the cursor and act on double click on usernames in chat history.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
29288
diff
changeset
|
704 | hand = TRUE; |
|
b94fa8bc1a03
Change the cursor and act on double click on usernames in chat history.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
29288
diff
changeset
|
705 | break; |
|
b94fa8bc1a03
Change the cursor and act on double click on usernames in chat history.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
29288
diff
changeset
|
706 | } |
|
b94fa8bc1a03
Change the cursor and act on double click on usernames in chat history.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
29288
diff
changeset
|
707 | } |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
708 | } |
| 8061 | 709 | |
|
29309
b94fa8bc1a03
Change the cursor and act on double click on usernames in chat history.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
29288
diff
changeset
|
710 | if (hand && !(GTK_IMHTML(imhtml)->editable)) |
|
b94fa8bc1a03
Change the cursor and act on double click on usernames in chat history.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
29288
diff
changeset
|
711 | cursor = GTK_IMHTML(imhtml)->hand_cursor; |
|
b94fa8bc1a03
Change the cursor and act on double click on usernames in chat history.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
29288
diff
changeset
|
712 | |
|
b94fa8bc1a03
Change the cursor and act on double click on usernames in chat history.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
29288
diff
changeset
|
713 | if (cursor) |
|
b94fa8bc1a03
Change the cursor and act on double click on usernames in chat history.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
29288
diff
changeset
|
714 | gdk_window_set_cursor(win, cursor); |
|
b94fa8bc1a03
Change the cursor and act on double click on usernames in chat history.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
29288
diff
changeset
|
715 | |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
716 | GTK_IMHTML(imhtml)->tip = tip; |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
717 | g_slist_free(tags); |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
718 | return FALSE; |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
719 | } |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
720 | |
|
11677
89c2ab8d2ebf
[gaim-migrate @ 13963]
Mark Doliner <markdoliner@pidgin.im>
parents:
11586
diff
changeset
|
721 | static gboolean |
|
89c2ab8d2ebf
[gaim-migrate @ 13963]
Mark Doliner <markdoliner@pidgin.im>
parents:
11586
diff
changeset
|
722 | gtk_enter_event_notify(GtkWidget *imhtml, GdkEventCrossing *event, gpointer data) |
|
10946
63a41710fc94
[gaim-migrate @ 12742]
Daniel Atallah <datallah@pidgin.im>
parents:
10936
diff
changeset
|
723 | { |
|
63a41710fc94
[gaim-migrate @ 12742]
Daniel Atallah <datallah@pidgin.im>
parents:
10936
diff
changeset
|
724 | if (GTK_IMHTML(imhtml)->editable) |
|
63a41710fc94
[gaim-migrate @ 12742]
Daniel Atallah <datallah@pidgin.im>
parents:
10936
diff
changeset
|
725 | gdk_window_set_cursor( |
|
63a41710fc94
[gaim-migrate @ 12742]
Daniel Atallah <datallah@pidgin.im>
parents:
10936
diff
changeset
|
726 | gtk_text_view_get_window(GTK_TEXT_VIEW(imhtml), |
|
63a41710fc94
[gaim-migrate @ 12742]
Daniel Atallah <datallah@pidgin.im>
parents:
10936
diff
changeset
|
727 | GTK_TEXT_WINDOW_TEXT), |
|
63a41710fc94
[gaim-migrate @ 12742]
Daniel Atallah <datallah@pidgin.im>
parents:
10936
diff
changeset
|
728 | GTK_IMHTML(imhtml)->text_cursor); |
|
63a41710fc94
[gaim-migrate @ 12742]
Daniel Atallah <datallah@pidgin.im>
parents:
10936
diff
changeset
|
729 | else |
|
63a41710fc94
[gaim-migrate @ 12742]
Daniel Atallah <datallah@pidgin.im>
parents:
10936
diff
changeset
|
730 | gdk_window_set_cursor( |
|
63a41710fc94
[gaim-migrate @ 12742]
Daniel Atallah <datallah@pidgin.im>
parents:
10936
diff
changeset
|
731 | gtk_text_view_get_window(GTK_TEXT_VIEW(imhtml), |
|
63a41710fc94
[gaim-migrate @ 12742]
Daniel Atallah <datallah@pidgin.im>
parents:
10936
diff
changeset
|
732 | GTK_TEXT_WINDOW_TEXT), |
|
63a41710fc94
[gaim-migrate @ 12742]
Daniel Atallah <datallah@pidgin.im>
parents:
10936
diff
changeset
|
733 | GTK_IMHTML(imhtml)->arrow_cursor); |
|
63a41710fc94
[gaim-migrate @ 12742]
Daniel Atallah <datallah@pidgin.im>
parents:
10936
diff
changeset
|
734 | |
|
63a41710fc94
[gaim-migrate @ 12742]
Daniel Atallah <datallah@pidgin.im>
parents:
10936
diff
changeset
|
735 | /* propagate the event normally */ |
|
63a41710fc94
[gaim-migrate @ 12742]
Daniel Atallah <datallah@pidgin.im>
parents:
10936
diff
changeset
|
736 | return FALSE; |
|
63a41710fc94
[gaim-migrate @ 12742]
Daniel Atallah <datallah@pidgin.im>
parents:
10936
diff
changeset
|
737 | } |
|
63a41710fc94
[gaim-migrate @ 12742]
Daniel Atallah <datallah@pidgin.im>
parents:
10936
diff
changeset
|
738 | |
|
11677
89c2ab8d2ebf
[gaim-migrate @ 13963]
Mark Doliner <markdoliner@pidgin.im>
parents:
11586
diff
changeset
|
739 | static gboolean |
|
89c2ab8d2ebf
[gaim-migrate @ 13963]
Mark Doliner <markdoliner@pidgin.im>
parents:
11586
diff
changeset
|
740 | gtk_leave_event_notify(GtkWidget *imhtml, GdkEventCrossing *event, gpointer data) |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
741 | { |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
742 | /* when leaving the widget, clear any current & pending tooltips and restore the cursor */ |
| 10799 | 743 | 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
|
744 | gtk_imhtml_set_link_color(GTK_IMHTML(imhtml), GTK_IMHTML(imhtml)->prelit_tag); |
| 10799 | 745 | GTK_IMHTML(imhtml)->prelit_tag = NULL; |
| 746 | } | |
| 747 | ||
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
748 | if (GTK_IMHTML(imhtml)->tip_window) { |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
749 | gtk_widget_destroy(GTK_IMHTML(imhtml)->tip_window); |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
750 | GTK_IMHTML(imhtml)->tip_window = NULL; |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
751 | } |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
752 | if (GTK_IMHTML(imhtml)->tip_timer) { |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
753 | g_source_remove(GTK_IMHTML(imhtml)->tip_timer); |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
754 | GTK_IMHTML(imhtml)->tip_timer = 0; |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
755 | } |
|
10946
63a41710fc94
[gaim-migrate @ 12742]
Daniel Atallah <datallah@pidgin.im>
parents:
10936
diff
changeset
|
756 | gdk_window_set_cursor( |
|
63a41710fc94
[gaim-migrate @ 12742]
Daniel Atallah <datallah@pidgin.im>
parents:
10936
diff
changeset
|
757 | gtk_text_view_get_window(GTK_TEXT_VIEW(imhtml), |
|
63a41710fc94
[gaim-migrate @ 12742]
Daniel Atallah <datallah@pidgin.im>
parents:
10936
diff
changeset
|
758 | GTK_TEXT_WINDOW_TEXT), NULL); |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
759 | |
|
8568
66907b37ce85
[gaim-migrate @ 9316]
Mark Doliner <markdoliner@pidgin.im>
parents:
8566
diff
changeset
|
760 | /* propagate the event normally */ |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
761 | return FALSE; |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
762 | } |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
763 | |
| 10692 | 764 | static gint |
| 765 | gtk_imhtml_expose_event (GtkWidget *widget, | |
| 766 | GdkEventExpose *event) | |
| 767 | { | |
| 10776 | 768 | GtkTextIter start, end, cur; |
| 769 | int buf_x, buf_y; | |
| 770 | GdkRectangle visible_rect; | |
|
30566
8263353b04de
Replace GdkGC in GtkIMHtml. Just in case you were wondering, it's now
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30417
diff
changeset
|
771 | cairo_t *cr = gdk_cairo_create(GDK_DRAWABLE(event->window)); |
| 10777 | 772 | GdkColor gcolor; |
|
10844
fb5b88957742
[gaim-migrate @ 12516]
Richard Laager <rlaager@pidgin.im>
parents:
10834
diff
changeset
|
773 | |
| 10776 | 774 | gtk_text_view_get_visible_rect(GTK_TEXT_VIEW(widget), &visible_rect); |
| 775 | gtk_text_view_buffer_to_window_coords(GTK_TEXT_VIEW(widget), | |
| 776 | GTK_TEXT_WINDOW_TEXT, | |
| 777 | visible_rect.x, | |
| 778 | visible_rect.y, | |
| 779 | &visible_rect.x, | |
| 780 | &visible_rect.y); | |
| 781 | ||
| 782 | gtk_text_view_window_to_buffer_coords(GTK_TEXT_VIEW(widget), GTK_TEXT_WINDOW_TEXT, | |
| 783 | event->area.x, event->area.y, &buf_x, &buf_y); | |
| 784 | ||
| 10777 | 785 | if (GTK_IMHTML(widget)->editable || GTK_IMHTML(widget)->wbfo) { |
|
11572
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
786 | |
| 10777 | 787 | if (GTK_IMHTML(widget)->edit.background) { |
| 788 | gdk_color_parse(GTK_IMHTML(widget)->edit.background, &gcolor); | |
|
30566
8263353b04de
Replace GdkGC in GtkIMHtml. Just in case you were wondering, it's now
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30417
diff
changeset
|
789 | gdk_cairo_set_source_color(cr, &gcolor); |
| 10777 | 790 | } else { |
|
30566
8263353b04de
Replace GdkGC in GtkIMHtml. Just in case you were wondering, it's now
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30417
diff
changeset
|
791 | gdk_cairo_set_source_color(cr, &(widget->style->base[GTK_WIDGET_STATE(widget)])); |
| 10777 | 792 | } |
|
11572
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
793 | |
|
30566
8263353b04de
Replace GdkGC in GtkIMHtml. Just in case you were wondering, it's now
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30417
diff
changeset
|
794 | cairo_rectangle(cr, |
|
8263353b04de
Replace GdkGC in GtkIMHtml. Just in case you were wondering, it's now
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30417
diff
changeset
|
795 | visible_rect.x, visible_rect.y, |
|
8263353b04de
Replace GdkGC in GtkIMHtml. Just in case you were wondering, it's now
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30417
diff
changeset
|
796 | visible_rect.width, visible_rect.height); |
|
8263353b04de
Replace GdkGC in GtkIMHtml. Just in case you were wondering, it's now
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30417
diff
changeset
|
797 | cairo_fill(cr); |
|
8263353b04de
Replace GdkGC in GtkIMHtml. Just in case you were wondering, it's now
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30417
diff
changeset
|
798 | cairo_destroy(cr); |
|
11572
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
799 | |
| 10777 | 800 | if (GTK_WIDGET_CLASS (parent_class)->expose_event) |
| 801 | return (* GTK_WIDGET_CLASS (parent_class)->expose_event) | |
| 802 | (widget, event); | |
| 803 | return FALSE; | |
| 804 | ||
| 805 | } | |
|
11572
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
806 | |
| 10776 | 807 | gtk_text_view_get_iter_at_location(GTK_TEXT_VIEW(widget), &start, buf_x, buf_y); |
| 808 | gtk_text_view_get_iter_at_location(GTK_TEXT_VIEW(widget), &end, | |
| 809 | buf_x + event->area.width, buf_y + event->area.height); | |
| 810 | ||
|
23187
671e00775afb
*** Plucked rev 69b22e32f7ada182101e0746f02891389ceb0c52 (sadrul@pidgin.im):
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23174
diff
changeset
|
811 | gtk_text_iter_order(&start, &end); |
| 10776 | 812 | |
| 813 | cur = start; | |
| 814 | ||
| 815 | while (gtk_text_iter_in_range(&cur, &start, &end)) { | |
| 10795 | 816 | GSList *tags = gtk_text_iter_get_tags(&cur); |
| 817 | GSList *l; | |
| 10776 | 818 | |
| 819 | for (l = tags; l; l = l->next) { | |
| 820 | GtkTextTag *tag = l->data; | |
| 821 | GdkRectangle rect; | |
| 822 | GdkRectangle tag_area; | |
| 823 | const char *color; | |
|
11572
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
824 | |
| 10776 | 825 | if (strncmp(tag->name, "BACKGROUND ", 11)) |
| 826 | continue; | |
| 827 | ||
| 828 | if (gtk_text_iter_ends_tag(&cur, tag)) | |
| 829 | continue; | |
| 830 | ||
| 831 | gtk_text_view_get_iter_location(GTK_TEXT_VIEW(widget), &cur, &tag_area); | |
| 832 | gtk_text_view_buffer_to_window_coords(GTK_TEXT_VIEW(widget), | |
| 833 | GTK_TEXT_WINDOW_TEXT, | |
| 834 | tag_area.x, | |
| 835 | tag_area.y, | |
| 836 | &tag_area.x, | |
| 837 | &tag_area.y); | |
| 838 | rect.x = visible_rect.x; | |
| 839 | rect.y = tag_area.y; | |
|
11768
b45e26d7a4c9
[gaim-migrate @ 14059]
Gary Kramlich <grim@reaperworld.com>
parents:
11760
diff
changeset
|
840 | rect.width = visible_rect.width; |
| 10776 | 841 | |
| 10795 | 842 | do |
| 10776 | 843 | gtk_text_iter_forward_to_tag_toggle(&cur, tag); |
| 10795 | 844 | while (!gtk_text_iter_is_end(&cur) && gtk_text_iter_begins_tag(&cur, tag)); |
| 845 | ||
| 10776 | 846 | gtk_text_view_get_iter_location(GTK_TEXT_VIEW(widget), &cur, &tag_area); |
| 847 | gtk_text_view_buffer_to_window_coords(GTK_TEXT_VIEW(widget), | |
| 848 | GTK_TEXT_WINDOW_TEXT, | |
| 849 | tag_area.x, | |
| 850 | tag_area.y, | |
| 851 | &tag_area.x, | |
| 852 | &tag_area.y); | |
| 853 | ||
|
25888
d0fdd378a635
Remove trailing whitespace
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
854 | |
| 11760 | 855 | 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
|
856 | + gtk_text_view_get_pixels_above_lines(GTK_TEXT_VIEW(widget)) |
| 11760 | 857 | + 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
|
858 | |
| 10776 | 859 | color = tag->name + 11; |
| 860 | ||
| 10857 | 861 | if (!gdk_color_parse(color, &gcolor)) { |
| 10858 | 862 | gchar tmp[8]; |
| 863 | tmp[0] = '#'; | |
| 864 | strncpy(&tmp[1], color, 7); | |
| 865 | tmp[7] = '\0'; | |
| 10857 | 866 | if (!gdk_color_parse(tmp, &gcolor)) |
| 867 | gdk_color_parse("white", &gcolor); | |
| 868 | } | |
|
30566
8263353b04de
Replace GdkGC in GtkIMHtml. Just in case you were wondering, it's now
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30417
diff
changeset
|
869 | gdk_cairo_set_source_color(cr, &gcolor); |
|
8263353b04de
Replace GdkGC in GtkIMHtml. Just in case you were wondering, it's now
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30417
diff
changeset
|
870 | |
|
8263353b04de
Replace GdkGC in GtkIMHtml. Just in case you were wondering, it's now
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30417
diff
changeset
|
871 | cairo_rectangle(cr, |
|
8263353b04de
Replace GdkGC in GtkIMHtml. Just in case you were wondering, it's now
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30417
diff
changeset
|
872 | rect.x, rect.y, |
|
8263353b04de
Replace GdkGC in GtkIMHtml. Just in case you were wondering, it's now
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30417
diff
changeset
|
873 | rect.width, rect.height); |
|
8263353b04de
Replace GdkGC in GtkIMHtml. Just in case you were wondering, it's now
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30417
diff
changeset
|
874 | cairo_fill(cr); |
| 10795 | 875 | gtk_text_iter_backward_char(&cur); /* go back one, in case the end is the begining is the end |
| 876 | * note that above, we always moved cur ahead by at least | |
| 877 | * one character */ | |
| 10776 | 878 | break; |
| 879 | } | |
| 880 | ||
| 881 | g_slist_free(tags); | |
| 10795 | 882 | |
| 883 | /* loop until another tag begins, or no tag begins */ | |
| 884 | while (gtk_text_iter_forward_to_tag_toggle(&cur, NULL) && | |
| 885 | !gtk_text_iter_is_end(&cur) && | |
| 886 | !gtk_text_iter_begins_tag(&cur, NULL)); | |
|
11572
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
887 | } |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
888 | |
|
30566
8263353b04de
Replace GdkGC in GtkIMHtml. Just in case you were wondering, it's now
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30417
diff
changeset
|
889 | cairo_destroy(cr); |
| 10777 | 890 | |
| 10692 | 891 | if (GTK_WIDGET_CLASS (parent_class)->expose_event) |
| 892 | return (* GTK_WIDGET_CLASS (parent_class)->expose_event) | |
| 893 | (widget, event); | |
| 10776 | 894 | |
| 10692 | 895 | return FALSE; |
| 896 | } | |
| 897 | ||
| 898 | ||
| 8931 | 899 | static void paste_unformatted_cb(GtkMenuItem *menu, GtkIMHtml *imhtml) |
| 900 | { | |
| 901 | GtkClipboard *clipboard = gtk_widget_get_clipboard(GTK_WIDGET(imhtml), GDK_SELECTION_CLIPBOARD); | |
| 902 | ||
| 903 | gtk_clipboard_request_text(clipboard, paste_plaintext_received_cb, imhtml); | |
| 904 | ||
| 905 | } | |
| 906 | ||
| 13336 | 907 | static void clear_formatting_cb(GtkMenuItem *menu, GtkIMHtml *imhtml) |
| 908 | { | |
| 909 | gtk_imhtml_clear_formatting(imhtml); | |
| 910 | } | |
| 10692 | 911 | |
|
22970
87aef86d20c5
Allow replacing smileys with texts in conversations/logs. This should be
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22865
diff
changeset
|
912 | 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
|
913 | { |
|
87aef86d20c5
Allow replacing smileys with texts in conversations/logs. This should be
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22865
diff
changeset
|
914 | 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
|
915 | GtkTextMark *mark; |
|
87aef86d20c5
Allow replacing smileys with texts in conversations/logs. This should be
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22865
diff
changeset
|
916 | char *text; |
|
87aef86d20c5
Allow replacing smileys with texts in conversations/logs. This should be
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22865
diff
changeset
|
917 | |
|
87aef86d20c5
Allow replacing smileys with texts in conversations/logs. This should be
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22865
diff
changeset
|
918 | 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
|
919 | return; |
|
87aef86d20c5
Allow replacing smileys with texts in conversations/logs. This should be
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22865
diff
changeset
|
920 | |
|
87aef86d20c5
Allow replacing smileys with texts in conversations/logs. This should be
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22865
diff
changeset
|
921 | 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
|
922 | |
|
87aef86d20c5
Allow replacing smileys with texts in conversations/logs. This should be
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22865
diff
changeset
|
923 | 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
|
924 | 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
|
925 | |
|
87aef86d20c5
Allow replacing smileys with texts in conversations/logs. This should be
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22865
diff
changeset
|
926 | 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
|
927 | 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
|
928 | |
|
87aef86d20c5
Allow replacing smileys with texts in conversations/logs. This should be
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22865
diff
changeset
|
929 | 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
|
930 | } |
|
87aef86d20c5
Allow replacing smileys with texts in conversations/logs. This should be
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22865
diff
changeset
|
931 | |
| 8931 | 932 | static void hijack_menu_cb(GtkIMHtml *imhtml, GtkMenu *menu, gpointer data) |
| 933 | { | |
| 934 | 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
|
935 | GtkTextIter start, end; |
| 8931 | 936 | |
|
12635
5b2fbc3da55b
[gaim-migrate @ 14971]
Richard Laager <rlaager@pidgin.im>
parents:
12605
diff
changeset
|
937 | menuitem = gtk_menu_item_new_with_mnemonic(_("Paste as Plain _Text")); |
| 8931 | 938 | gtk_widget_show(menuitem); |
|
14970
fd8984ce4fda
[gaim-migrate @ 17680]
Mark Doliner <markdoliner@pidgin.im>
parents:
14863
diff
changeset
|
939 | /* |
|
fd8984ce4fda
[gaim-migrate @ 17680]
Mark Doliner <markdoliner@pidgin.im>
parents:
14863
diff
changeset
|
940 | * TODO: gtk_clipboard_wait_is_text_available() iterates the glib |
|
fd8984ce4fda
[gaim-migrate @ 17680]
Mark Doliner <markdoliner@pidgin.im>
parents:
14863
diff
changeset
|
941 | * mainloop, which tends to be a source of bugs. It would |
|
fd8984ce4fda
[gaim-migrate @ 17680]
Mark Doliner <markdoliner@pidgin.im>
parents:
14863
diff
changeset
|
942 | * be good to audit this or change it to not wait. |
|
fd8984ce4fda
[gaim-migrate @ 17680]
Mark Doliner <markdoliner@pidgin.im>
parents:
14863
diff
changeset
|
943 | */ |
| 8931 | 944 | gtk_widget_set_sensitive(menuitem, |
|
12836
837fe5d43dac
[gaim-migrate @ 15184]
Richard Laager <rlaager@pidgin.im>
parents:
12833
diff
changeset
|
945 | (imhtml->editable && |
|
837fe5d43dac
[gaim-migrate @ 15184]
Richard Laager <rlaager@pidgin.im>
parents:
12833
diff
changeset
|
946 | gtk_clipboard_wait_is_text_available( |
|
837fe5d43dac
[gaim-migrate @ 15184]
Richard Laager <rlaager@pidgin.im>
parents:
12833
diff
changeset
|
947 | gtk_widget_get_clipboard(GTK_WIDGET(imhtml), GDK_SELECTION_CLIPBOARD)))); |
| 8931 | 948 | /* put it after "Paste" */ |
| 949 | gtk_menu_shell_insert(GTK_MENU_SHELL(menu), menuitem, 3); | |
| 950 | ||
| 951 | g_signal_connect(G_OBJECT(menuitem), "activate", | |
| 952 | G_CALLBACK(paste_unformatted_cb), imhtml); | |
| 13336 | 953 | |
|
13539
8036a635a316
[gaim-migrate @ 15915]
Richard Laager <rlaager@pidgin.im>
parents:
13340
diff
changeset
|
954 | menuitem = gtk_menu_item_new_with_mnemonic(_("_Reset formatting")); |
| 13336 | 955 | gtk_widget_show(menuitem); |
|
13340
e18166659513
[gaim-migrate @ 15709]
Richard Laager <rlaager@pidgin.im>
parents:
13336
diff
changeset
|
956 | gtk_widget_set_sensitive(menuitem, imhtml->editable); |
| 13336 | 957 | /* put it after Delete */ |
| 958 | gtk_menu_shell_insert(GTK_MENU_SHELL(menu), menuitem, 5); | |
| 959 | ||
| 960 | 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
|
961 | |
|
87aef86d20c5
Allow replacing smileys with texts in conversations/logs. This should be
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22865
diff
changeset
|
962 | 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
|
963 | 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
|
964 | 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
|
965 | 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
|
966 | } else { |
|
87aef86d20c5
Allow replacing smileys with texts in conversations/logs. This should be
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22865
diff
changeset
|
967 | 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
|
968 | } |
|
87aef86d20c5
Allow replacing smileys with texts in conversations/logs. This should be
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22865
diff
changeset
|
969 | gtk_menu_shell_insert(GTK_MENU_SHELL(menu), menuitem, 6); |
| 8931 | 970 | } |
| 971 | ||
|
11572
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
972 | static char * |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
973 | ucs2_order(gboolean swap) |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
974 | { |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
975 | gboolean be; |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
976 | |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
977 | be = G_BYTE_ORDER == G_BIG_ENDIAN; |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
978 | be = swap ? be : !be; |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
979 | |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
980 | 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
|
981 | return "UTF-16BE"; |
|
11572
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
982 | 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
|
983 | return "UTF-16LE"; |
|
11572
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
984 | |
|
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 | |
|
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
|
987 | /* 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
|
988 | 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
|
989 | utf16_to_utf8_with_bom_check(gchar *data, guint len) { |
|
11572
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
990 | char *fromcode = NULL; |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
991 | GError *error = NULL; |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
992 | guint16 c; |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
993 | gchar *utf8_ret; |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
994 | |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
995 | /* |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
996 | * Unicode Techinical Report 20 |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
997 | * ( http://www.unicode.org/unicode/reports/tr20/ ) says to treat an |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
998 | * initial 0xfeff (ZWNBSP) as a byte order indicator so that is |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
999 | * 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
|
1000 | * order |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
1001 | */ |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
1002 | |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
1003 | memcpy(&c, data, 2); |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
1004 | switch (c) { |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
1005 | case 0xfeff: |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
1006 | case 0xfffe: |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
1007 | fromcode = ucs2_order(c == 0xfeff); |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
1008 | data += 2; |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
1009 | len -= 2; |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
1010 | break; |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
1011 | 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
|
1012 | fromcode = "UTF-16"; |
|
11572
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
1013 | break; |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
1014 | } |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
1015 | |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
1016 | 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
|
1017 | |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
1018 | if (error) { |
| 15884 | 1019 | 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
|
1020 | g_error_free(error); |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
1021 | } |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
1022 | return utf8_ret; |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
1023 | } |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
1024 | |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
1025 | |
| 8061 | 1026 | 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
|
1027 | 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
|
1028 | gboolean primary = (clipboard != clipboard_selection); |
| 8061 | 1029 | 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
|
1030 | |
|
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
|
1031 | 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
|
1032 | 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
|
1033 | |
|
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
|
1034 | 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
|
1035 | |
|
17546
51b1c1e2c3fe
Maintain global poitners to the clipboard selection text, with the aim of
Sean Egan <seanegan@pidgin.im>
parents:
17406
diff
changeset
|
1036 | 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
|
1037 | 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
|
1038 | 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
|
1039 | 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
|
1040 | } |
| 8061 | 1041 | |
| 1042 | if (info == TARGET_HTML) { | |
|
15111
e427dd6f3b7e
[gaim-migrate @ 17833]
Daniel Atallah <datallah@pidgin.im>
parents:
15093
diff
changeset
|
1043 | char *selection; |
|
e427dd6f3b7e
[gaim-migrate @ 17833]
Daniel Atallah <datallah@pidgin.im>
parents:
15093
diff
changeset
|
1044 | #ifndef _WIN32 |
| 8907 | 1045 | gsize len; |
| 8681 | 1046 | if (primary) { |
| 1047 | text = gtk_imhtml_get_markup_range(imhtml, &start, &end); | |
| 10013 | 1048 | } else |
|
17546
51b1c1e2c3fe
Maintain global poitners to the clipboard selection text, with the aim of
Sean Egan <seanegan@pidgin.im>
parents:
17406
diff
changeset
|
1049 | text = html_clipboard; |
| 8061 | 1050 | |
| 1051 | /* 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
|
1052 | 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
|
1053 | 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
|
1054 | #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
|
1055 | selection = clipboard_html_to_win32(html_clipboard); |
|
15111
e427dd6f3b7e
[gaim-migrate @ 17833]
Daniel Atallah <datallah@pidgin.im>
parents:
15093
diff
changeset
|
1056 | 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
|
1057 | #endif |
| 8061 | 1058 | g_free(selection); |
| 1059 | } else { | |
| 8681 | 1060 | if (primary) { |
| 1061 | text = gtk_imhtml_get_text(imhtml, &start, &end); | |
| 1062 | } else | |
|
17546
51b1c1e2c3fe
Maintain global poitners to the clipboard selection text, with the aim of
Sean Egan <seanegan@pidgin.im>
parents:
17406
diff
changeset
|
1063 | text = text_clipboard; |
| 8061 | 1064 | gtk_selection_data_set_text(selection_data, text, strlen(text)); |
| 1065 | } | |
| 8681 | 1066 | if (primary) /* This was allocated here */ |
| 1067 | g_free(text); | |
| 1068 | } | |
| 8061 | 1069 | |
| 1070 | static void gtk_imhtml_primary_clipboard_clear(GtkClipboard *clipboard, GtkIMHtml *imhtml) | |
| 7749 | 1071 | { |
| 8061 | 1072 | GtkTextIter insert; |
| 1073 | GtkTextIter selection_bound; | |
| 1074 | ||
| 1075 | gtk_text_buffer_get_iter_at_mark (imhtml->text_buffer, &insert, | |
| 1076 | gtk_text_buffer_get_mark (imhtml->text_buffer, "insert")); | |
| 1077 | gtk_text_buffer_get_iter_at_mark (imhtml->text_buffer, &selection_bound, | |
| 1078 | gtk_text_buffer_get_mark (imhtml->text_buffer, "selection_bound")); | |
| 1079 | ||
| 1080 | if (!gtk_text_iter_equal (&insert, &selection_bound)) | |
| 1081 | gtk_text_buffer_move_mark (imhtml->text_buffer, | |
| 1082 | gtk_text_buffer_get_mark (imhtml->text_buffer, "selection_bound"), | |
| 1083 | &insert); | |
| 7749 | 1084 | } |
| 7742 | 1085 | |
|
17546
51b1c1e2c3fe
Maintain global poitners to the clipboard selection text, with the aim of
Sean Egan <seanegan@pidgin.im>
parents:
17406
diff
changeset
|
1086 | 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
|
1087 | 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
|
1088 | { |
|
51b1c1e2c3fe
Maintain global poitners to the clipboard selection text, with the aim of
Sean Egan <seanegan@pidgin.im>
parents:
17406
diff
changeset
|
1089 | } |
|
51b1c1e2c3fe
Maintain global poitners to the clipboard selection text, with the aim of
Sean Egan <seanegan@pidgin.im>
parents:
17406
diff
changeset
|
1090 | |
| 8677 | 1091 | static void copy_clipboard_cb(GtkIMHtml *imhtml, gpointer unused) |
| 7749 | 1092 | { |
| 8681 | 1093 | 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
|
1094 | 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
|
1095 | 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
|
1096 | 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
|
1097 | 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
|
1098 | 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
|
1099 | (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
|
1100 | (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
|
1101 | |
|
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
|
1102 | 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
|
1103 | 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
|
1104 | |
|
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
|
1105 | 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
|
1106 | text_clipboard = gtk_imhtml_get_text(imhtml, &start, &end); |
| 8681 | 1107 | } |
| 1108 | ||
| 8061 | 1109 | g_signal_stop_emission_by_name(imhtml, "copy-clipboard"); |
| 1110 | } | |
| 1111 | ||
| 8698 | 1112 | static void cut_clipboard_cb(GtkIMHtml *imhtml, gpointer unused) |
| 1113 | { | |
| 1114 | 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
|
1115 | 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
|
1116 | 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
|
1117 | 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
|
1118 | 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
|
1119 | 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
|
1120 | (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
|
1121 | (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
|
1122 | |
|
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
|
1123 | 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
|
1124 | 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
|
1125 | |
|
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
|
1126 | 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
|
1127 | 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
|
1128 | |
|
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
|
1129 | 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
|
1130 | gtk_text_buffer_delete_selection(imhtml->text_buffer, FALSE, FALSE); |
| 8698 | 1131 | } |
| 1132 | ||
| 1133 | g_signal_stop_emission_by_name(imhtml, "cut-clipboard"); | |
| 1134 | } | |
| 1135 | ||
| 8931 | 1136 | static void imhtml_paste_insert(GtkIMHtml *imhtml, const char *text, gboolean plaintext) |
| 1137 | { | |
| 1138 | 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
|
1139 | GtkIMHtmlOptions flags = plaintext ? GTK_IMHTML_NO_SMILEY : (GTK_IMHTML_NO_NEWLINE | GTK_IMHTML_NO_COMMENTS); |
| 8931 | 1140 | |
|
25899
da25a7ed382e
The first thing gtk_text_buffer_delete_selection does is call
Mark Doliner <markdoliner@pidgin.im>
parents:
25888
diff
changeset
|
1141 | /* Delete any currently selected text */ |
|
da25a7ed382e
The first thing gtk_text_buffer_delete_selection does is call
Mark Doliner <markdoliner@pidgin.im>
parents:
25888
diff
changeset
|
1142 | gtk_text_buffer_delete_selection(imhtml->text_buffer, TRUE, TRUE); |
| 9028 | 1143 | |
| 8931 | 1144 | gtk_text_buffer_get_iter_at_mark(imhtml->text_buffer, &iter, gtk_text_buffer_get_insert(imhtml->text_buffer)); |
| 1145 | if (!imhtml->wbfo && !plaintext) | |
| 1146 | gtk_imhtml_close_tags(imhtml, &iter); | |
| 1147 | ||
| 1148 | gtk_imhtml_insert_html_at_iter(imhtml, text, flags, &iter); | |
|
11267
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
1149 | gtk_text_buffer_move_mark_by_name(imhtml->text_buffer, "insert", &iter); |
| 8931 | 1150 | gtk_text_view_scroll_to_mark(GTK_TEXT_VIEW(imhtml), gtk_text_buffer_get_insert(imhtml->text_buffer), |
| 1151 | 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
|
1152 | 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
|
1153 | 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
|
1154 | |
| 8931 | 1155 | } |
| 1156 | ||
| 1157 | static void paste_plaintext_received_cb (GtkClipboard *clipboard, const gchar *text, gpointer data) | |
| 1158 | { | |
| 1159 | char *tmp; | |
| 1160 | ||
|
19332
06b251c98872
malloc(0) returns a null pointer. Fixes #2472.
Daniel Atallah <datallah@pidgin.im>
parents:
19103
diff
changeset
|
1161 | if (text == NULL || !(*text)) |
| 8931 | 1162 | return; |
| 1163 | ||
|
10732
5e314ab498bf
[gaim-migrate @ 12334]
Richard Laager <rlaager@pidgin.im>
parents:
10699
diff
changeset
|
1164 | tmp = g_markup_escape_text(text, -1); |
| 8931 | 1165 | imhtml_paste_insert(data, tmp, TRUE); |
| 1166 | g_free(tmp); | |
| 1167 | } | |
| 1168 | ||
| 8061 | 1169 | static void paste_received_cb (GtkClipboard *clipboard, GtkSelectionData *selection_data, gpointer data) |
| 1170 | { | |
| 1171 | char *text; | |
| 1172 | GtkIMHtml *imhtml = data; | |
| 7809 | 1173 | |
|
8123
e09c75f511c2
[gaim-migrate @ 8827]
Mark Doliner <markdoliner@pidgin.im>
parents:
8120
diff
changeset
|
1174 | if (!gtk_text_view_get_editable(GTK_TEXT_VIEW(imhtml))) |
|
8105
54ea897b764e
[gaim-migrate @ 8805]
Nathan Fredrickson <nathan@silverorange.com>
parents:
8091
diff
changeset
|
1175 | return; |
|
54ea897b764e
[gaim-migrate @ 8805]
Nathan Fredrickson <nathan@silverorange.com>
parents:
8091
diff
changeset
|
1176 | |
|
19332
06b251c98872
malloc(0) returns a null pointer. Fixes #2472.
Daniel Atallah <datallah@pidgin.im>
parents:
19103
diff
changeset
|
1177 | if (imhtml->wbfo || selection_data->length <= 0) { |
| 8931 | 1178 | gtk_clipboard_request_text(clipboard, paste_plaintext_received_cb, imhtml); |
| 1179 | return; | |
| 8061 | 1180 | } else { |
| 8719 | 1181 | #if 0 |
| 1182 | /* Here's some debug code, for figuring out what sent to us over the clipboard. */ | |
| 1183 | { | |
| 1184 | int i; | |
| 1185 | ||
| 15884 | 1186 | purple_debug_misc("gtkimhtml", "In paste_received_cb():\n\tformat = %d, length = %d\n\t", |
| 8719 | 1187 | selection_data->format, selection_data->length); |
| 1188 | ||
| 1189 | for (i = 0; i < (/*(selection_data->format / 8) **/ selection_data->length); i++) { | |
| 1190 | if ((i % 70) == 0) | |
| 1191 | printf("\n\t"); | |
| 1192 | if (selection_data->data[i] == '\0') | |
| 1193 | printf("."); | |
| 1194 | else | |
| 1195 | printf("%c", selection_data->data[i]); | |
| 1196 | } | |
| 1197 | printf("\n"); | |
| 1198 | } | |
| 1199 | #endif | |
|
30033
391b14824468
gtkimhtml: Fix handling of pastes whose data isn't NULL-terminated
Paul Aurich <darkrain42@pidgin.im>
parents:
29909
diff
changeset
|
1200 | |
|
391b14824468
gtkimhtml: Fix handling of pastes whose data isn't NULL-terminated
Paul Aurich <darkrain42@pidgin.im>
parents:
29909
diff
changeset
|
1201 | text = g_malloc(selection_data->length + 1); |
| 8719 | 1202 | memcpy(text, selection_data->data, selection_data->length); |
|
30033
391b14824468
gtkimhtml: Fix handling of pastes whose data isn't NULL-terminated
Paul Aurich <darkrain42@pidgin.im>
parents:
29909
diff
changeset
|
1203 | /* Make sure the paste data is null-terminated. Given that |
| 30034 | 1204 | * we're passed length (but assume later that it is |
| 1205 | * null-terminated), this seems sensible to me. | |
|
30033
391b14824468
gtkimhtml: Fix handling of pastes whose data isn't NULL-terminated
Paul Aurich <darkrain42@pidgin.im>
parents:
29909
diff
changeset
|
1206 | */ |
|
391b14824468
gtkimhtml: Fix handling of pastes whose data isn't NULL-terminated
Paul Aurich <darkrain42@pidgin.im>
parents:
29909
diff
changeset
|
1207 | text[selection_data->length] = '\0'; |
| 7766 | 1208 | } |
| 8061 | 1209 | |
|
29855
234f74a60570
I think this works around the problem with the Win32 Clipboard and GTK+ 2.16.
Daniel Atallah <datallah@pidgin.im>
parents:
29724
diff
changeset
|
1210 | #ifdef _WIN32 |
|
234f74a60570
I think this works around the problem with the Win32 Clipboard and GTK+ 2.16.
Daniel Atallah <datallah@pidgin.im>
parents:
29724
diff
changeset
|
1211 | if (gtk_selection_data_get_data_type(selection_data) == gdk_atom_intern("HTML Format", FALSE)) { |
|
234f74a60570
I think this works around the problem with the Win32 Clipboard and GTK+ 2.16.
Daniel Atallah <datallah@pidgin.im>
parents:
29724
diff
changeset
|
1212 | char *tmp = clipboard_win32_to_html(text); |
|
234f74a60570
I think this works around the problem with the Win32 Clipboard and GTK+ 2.16.
Daniel Atallah <datallah@pidgin.im>
parents:
29724
diff
changeset
|
1213 | g_free(text); |
|
234f74a60570
I think this works around the problem with the Win32 Clipboard and GTK+ 2.16.
Daniel Atallah <datallah@pidgin.im>
parents:
29724
diff
changeset
|
1214 | text = tmp; |
|
234f74a60570
I think this works around the problem with the Win32 Clipboard and GTK+ 2.16.
Daniel Atallah <datallah@pidgin.im>
parents:
29724
diff
changeset
|
1215 | } |
|
234f74a60570
I think this works around the problem with the Win32 Clipboard and GTK+ 2.16.
Daniel Atallah <datallah@pidgin.im>
parents:
29724
diff
changeset
|
1216 | #endif |
|
234f74a60570
I think this works around the problem with the Win32 Clipboard and GTK+ 2.16.
Daniel Atallah <datallah@pidgin.im>
parents:
29724
diff
changeset
|
1217 | |
| 8869 | 1218 | if (selection_data->length >= 2 && |
| 1219 | (*(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
|
1220 | /* 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
|
1221 | char *utf8 = utf16_to_utf8_with_bom_check(text, selection_data->length); |
| 8061 | 1222 | g_free(text); |
| 1223 | text = utf8; | |
| 8698 | 1224 | 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
|
1225 | purple_debug_warning("gtkimhtml", "g_convert from UTF-16 failed in paste_received_cb\n"); |
| 8698 | 1226 | return; |
| 1227 | } | |
| 8061 | 1228 | } |
|
11572
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
1229 | |
| 8698 | 1230 | if (!(*text) || !g_utf8_validate(text, -1, NULL)) { |
| 15884 | 1231 | purple_debug_warning("gtkimhtml", "empty string or invalid UTF-8 in paste_received_cb\n"); |
| 8698 | 1232 | g_free(text); |
| 1233 | return; | |
| 1234 | } | |
| 1235 | ||
| 8931 | 1236 | imhtml_paste_insert(imhtml, text, FALSE); |
| 8681 | 1237 | g_free(text); |
| 8061 | 1238 | } |
| 1239 | ||
|
21765
b9271e416f6d
Patch from 'goutnet': Pressing backspace on a smiley will replace the smiley
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21644
diff
changeset
|
1240 | |
|
b9271e416f6d
Patch from 'goutnet': Pressing backspace on a smiley will replace the smiley
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21644
diff
changeset
|
1241 | 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
|
1242 | { |
|
b9271e416f6d
Patch from 'goutnet': Pressing backspace on a smiley will replace the smiley
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21644
diff
changeset
|
1243 | 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
|
1244 | 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
|
1245 | 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
|
1246 | 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
|
1247 | |
|
b9271e416f6d
Patch from 'goutnet': Pressing backspace on a smiley will replace the smiley
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21644
diff
changeset
|
1248 | 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
|
1249 | return; |
|
b9271e416f6d
Patch from 'goutnet': Pressing backspace on a smiley will replace the smiley
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21644
diff
changeset
|
1250 | |
|
b9271e416f6d
Patch from 'goutnet': Pressing backspace on a smiley will replace the smiley
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21644
diff
changeset
|
1251 | 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
|
1252 | |
|
b9271e416f6d
Patch from 'goutnet': Pressing backspace on a smiley will replace the smiley
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21644
diff
changeset
|
1253 | /* 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
|
1254 | 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
|
1255 | 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
|
1256 | return; |
|
b9271e416f6d
Patch from 'goutnet': Pressing backspace on a smiley will replace the smiley
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21644
diff
changeset
|
1257 | |
|
b9271e416f6d
Patch from 'goutnet': Pressing backspace on a smiley will replace the smiley
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21644
diff
changeset
|
1258 | 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
|
1259 | 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
|
1260 | |
|
b9271e416f6d
Patch from 'goutnet': Pressing backspace on a smiley will replace the smiley
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21644
diff
changeset
|
1261 | 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
|
1262 | 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
|
1263 | |
|
b9271e416f6d
Patch from 'goutnet': Pressing backspace on a smiley will replace the smiley
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21644
diff
changeset
|
1264 | 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
|
1265 | 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
|
1266 | return; |
|
b9271e416f6d
Patch from 'goutnet': Pressing backspace on a smiley will replace the smiley
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21644
diff
changeset
|
1267 | |
|
b9271e416f6d
Patch from 'goutnet': Pressing backspace on a smiley will replace the smiley
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21644
diff
changeset
|
1268 | /* 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
|
1269 | 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
|
1270 | } |
|
b9271e416f6d
Patch from 'goutnet': Pressing backspace on a smiley will replace the smiley
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21644
diff
changeset
|
1271 | |
| 8061 | 1272 | static void paste_clipboard_cb(GtkIMHtml *imhtml, gpointer blah) |
| 1273 | { | |
| 8931 | 1274 | #ifdef _WIN32 |
| 1275 | /* 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
|
1276 | clipboard before we try to paste from the GTK buffer */ |
|
30264
9fd897f50d8c
Prevent pasting into readonly imhtmls on Windows. Fixes #11867
Daniel Atallah <datallah@pidgin.im>
parents:
30034
diff
changeset
|
1277 | if (!clipboard_paste_html_win32(imhtml) && gtk_text_view_get_editable(GTK_TEXT_VIEW(imhtml))) { |
|
29855
234f74a60570
I think this works around the problem with the Win32 Clipboard and GTK+ 2.16.
Daniel Atallah <datallah@pidgin.im>
parents:
29724
diff
changeset
|
1278 | GtkClipboard *clipboard = gtk_widget_get_clipboard(GTK_WIDGET(imhtml), GDK_SELECTION_CLIPBOARD); |
|
234f74a60570
I think this works around the problem with the Win32 Clipboard and GTK+ 2.16.
Daniel Atallah <datallah@pidgin.im>
parents:
29724
diff
changeset
|
1279 | gtk_clipboard_request_text(clipboard, paste_plaintext_received_cb, imhtml); |
|
234f74a60570
I think this works around the problem with the Win32 Clipboard and GTK+ 2.16.
Daniel Atallah <datallah@pidgin.im>
parents:
29724
diff
changeset
|
1280 | |
|
234f74a60570
I think this works around the problem with the Win32 Clipboard and GTK+ 2.16.
Daniel Atallah <datallah@pidgin.im>
parents:
29724
diff
changeset
|
1281 | } |
|
234f74a60570
I think this works around the problem with the Win32 Clipboard and GTK+ 2.16.
Daniel Atallah <datallah@pidgin.im>
parents:
29724
diff
changeset
|
1282 | #else |
| 8061 | 1283 | GtkClipboard *clipboard = gtk_widget_get_clipboard(GTK_WIDGET(imhtml), GDK_SELECTION_CLIPBOARD); |
| 1284 | gtk_clipboard_request_contents(clipboard, gdk_atom_intern("text/html", FALSE), | |
| 1285 | paste_received_cb, imhtml); | |
|
29855
234f74a60570
I think this works around the problem with the Win32 Clipboard and GTK+ 2.16.
Daniel Atallah <datallah@pidgin.im>
parents:
29724
diff
changeset
|
1286 | #endif |
| 8061 | 1287 | g_signal_stop_emission_by_name(imhtml, "paste-clipboard"); |
| 7766 | 1288 | } |
| 1289 | ||
| 8677 | 1290 | static void imhtml_realized_remove_primary(GtkIMHtml *imhtml, gpointer unused) |
| 1291 | { | |
| 1292 | gtk_text_buffer_remove_selection_clipboard(GTK_IMHTML(imhtml)->text_buffer, | |
| 1293 | gtk_widget_get_clipboard(GTK_WIDGET(imhtml), GDK_SELECTION_PRIMARY)); | |
| 1294 | ||
| 1295 | } | |
| 1296 | ||
|
8740
098a43943bba
[gaim-migrate @ 9495]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
1297 | static void imhtml_destroy_add_primary(GtkIMHtml *imhtml, gpointer unused) |
|
098a43943bba
[gaim-migrate @ 9495]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
1298 | { |
|
098a43943bba
[gaim-migrate @ 9495]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
1299 | gtk_text_buffer_add_selection_clipboard(GTK_IMHTML(imhtml)->text_buffer, |
|
098a43943bba
[gaim-migrate @ 9495]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
1300 | gtk_widget_get_clipboard(GTK_WIDGET(imhtml), GDK_SELECTION_PRIMARY)); |
|
098a43943bba
[gaim-migrate @ 9495]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
1301 | } |
| 8677 | 1302 | |
| 1303 | static void mark_set_so_update_selection_cb(GtkTextBuffer *buffer, GtkTextIter *arg1, GtkTextMark *mark, GtkIMHtml *imhtml) | |
| 1304 | { | |
| 1305 | if (gtk_text_buffer_get_selection_bounds(buffer, NULL, NULL)) { | |
| 1306 | gtk_clipboard_set_with_owner(gtk_widget_get_clipboard(GTK_WIDGET(imhtml), GDK_SELECTION_PRIMARY), | |
| 1307 | selection_targets, sizeof(selection_targets) / sizeof(GtkTargetEntry), | |
| 1308 | (GtkClipboardGetFunc)gtk_imhtml_clipboard_get, | |
| 1309 | (GtkClipboardClearFunc)gtk_imhtml_primary_clipboard_clear, G_OBJECT(imhtml)); | |
| 1310 | } | |
| 1311 | } | |
| 1312 | ||
| 1313 | static gboolean gtk_imhtml_button_press_event(GtkIMHtml *imhtml, GdkEventButton *event, gpointer unused) | |
| 7346 | 1314 | { |
| 8677 | 1315 | if (event->button == 2) { |
| 1316 | int x, y; | |
| 1317 | GtkTextIter iter; | |
| 1318 | GtkClipboard *clipboard = gtk_widget_get_clipboard(GTK_WIDGET(imhtml), GDK_SELECTION_PRIMARY); | |
| 1319 | ||
| 1320 | if (!imhtml->editable) | |
| 1321 | return FALSE; | |
| 1322 | ||
| 1323 | gtk_text_view_window_to_buffer_coords(GTK_TEXT_VIEW(imhtml), | |
| 1324 | GTK_TEXT_WINDOW_TEXT, | |
| 1325 | event->x, | |
| 1326 | event->y, | |
| 1327 | &x, | |
| 1328 | &y); | |
| 1329 | gtk_text_view_get_iter_at_location(GTK_TEXT_VIEW(imhtml), &iter, x, y); | |
| 1330 | gtk_text_buffer_place_cursor(imhtml->text_buffer, &iter); | |
| 1331 | ||
| 1332 | gtk_clipboard_request_contents(clipboard, gdk_atom_intern("text/html", FALSE), | |
| 1333 | paste_received_cb, imhtml); | |
| 1334 | ||
| 1335 | return TRUE; | |
| 1336 | } | |
| 1337 | ||
| 7346 | 1338 | return FALSE; |
| 1339 | } | |
| 4263 | 1340 | |
|
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
|
1341 | 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
|
1342 | 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
|
1343 | { |
|
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
|
1344 | 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
|
1345 | 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
|
1346 | 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
|
1347 | 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
|
1348 | } |
|
5e73968467e0
Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@pidgin.im>
parents:
17288
diff
changeset
|
1349 | |
|
5e73968467e0
Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@pidgin.im>
parents:
17288
diff
changeset
|
1350 | 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
|
1351 | 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
|
1352 | { |
|
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
|
1353 | 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
|
1354 | 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
|
1355 | 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
|
1356 | 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
|
1357 | |
|
5e73968467e0
Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@pidgin.im>
parents:
17288
diff
changeset
|
1358 | } |
|
5e73968467e0
Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@pidgin.im>
parents:
17288
diff
changeset
|
1359 | |
| 10108 | 1360 | static gboolean imhtml_message_send(GtkIMHtml *imhtml) |
| 1361 | { | |
| 1362 | return FALSE; | |
| 1363 | } | |
| 1364 | ||
|
29909
3b74346e22d5
Allow binding 'Paste as Plain Text'.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
29855
diff
changeset
|
1365 | static void |
|
3b74346e22d5
Allow binding 'Paste as Plain Text'.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
29855
diff
changeset
|
1366 | imhtml_paste_cb(GtkIMHtml *imhtml, const char *str) |
|
3b74346e22d5
Allow binding 'Paste as Plain Text'.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
29855
diff
changeset
|
1367 | { |
|
30417
ee5cccb21cc7
Do not paste in a read-only imhtml. Fixes #12109.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
30264
diff
changeset
|
1368 | if (!gtk_text_view_get_editable(GTK_TEXT_VIEW(imhtml))) |
|
ee5cccb21cc7
Do not paste in a read-only imhtml. Fixes #12109.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
30264
diff
changeset
|
1369 | return; |
|
ee5cccb21cc7
Do not paste in a read-only imhtml. Fixes #12109.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
30264
diff
changeset
|
1370 | |
|
29909
3b74346e22d5
Allow binding 'Paste as Plain Text'.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
29855
diff
changeset
|
1371 | if (!str || !*str || !strcmp(str, "html")) |
|
3b74346e22d5
Allow binding 'Paste as Plain Text'.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
29855
diff
changeset
|
1372 | g_signal_emit_by_name(imhtml, "paste_clipboard"); |
|
3b74346e22d5
Allow binding 'Paste as Plain Text'.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
29855
diff
changeset
|
1373 | else if (!strcmp(str, "text")) |
|
3b74346e22d5
Allow binding 'Paste as Plain Text'.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
29855
diff
changeset
|
1374 | paste_unformatted_cb(NULL, imhtml); |
|
3b74346e22d5
Allow binding 'Paste as Plain Text'.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
29855
diff
changeset
|
1375 | } |
|
3b74346e22d5
Allow binding 'Paste as Plain Text'.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
29855
diff
changeset
|
1376 | |
| 10100 | 1377 | static void imhtml_toggle_format(GtkIMHtml *imhtml, GtkIMHtmlButtons buttons) |
| 1378 | { | |
|
10699
7f9fa4f13758
[gaim-migrate @ 12256]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10695
diff
changeset
|
1379 | /* since this function is the handler for the formatting keystrokes, |
|
7f9fa4f13758
[gaim-migrate @ 12256]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10695
diff
changeset
|
1380 | 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
|
1381 | buttons &= imhtml->format_functions; |
|
10699
7f9fa4f13758
[gaim-migrate @ 12256]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10695
diff
changeset
|
1382 | |
| 10100 | 1383 | switch (buttons) { |
| 1384 | case GTK_IMHTML_BOLD: | |
|
11267
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
1385 | imhtml_toggle_bold(imhtml); |
| 10100 | 1386 | break; |
| 1387 | case GTK_IMHTML_ITALIC: | |
|
11267
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
1388 | imhtml_toggle_italic(imhtml); |
| 10100 | 1389 | break; |
| 1390 | case GTK_IMHTML_UNDERLINE: | |
|
11267
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
1391 | imhtml_toggle_underline(imhtml); |
|
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
1392 | break; |
|
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
1393 | case GTK_IMHTML_STRIKE: |
|
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
1394 | imhtml_toggle_strike(imhtml); |
| 10100 | 1395 | break; |
| 1396 | case GTK_IMHTML_SHRINK: | |
|
11267
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
1397 | imhtml_font_shrink(imhtml); |
| 10100 | 1398 | break; |
| 1399 | case GTK_IMHTML_GROW: | |
|
11267
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
1400 | imhtml_font_grow(imhtml); |
| 10100 | 1401 | break; |
| 1402 | default: | |
| 1403 | break; | |
| 1404 | } | |
| 1405 | } | |
| 4032 | 1406 | |
| 1407 | static void | |
| 1408 | gtk_imhtml_finalize (GObject *object) | |
| 1409 | { | |
| 1410 | GtkIMHtml *imhtml = GTK_IMHTML(object); | |
| 4895 | 1411 | GList *scalables; |
| 8962 | 1412 | GSList *l; |
| 8061 | 1413 | |
| 10798 | 1414 | if (imhtml->scroll_src) |
| 1415 | g_source_remove(imhtml->scroll_src); | |
| 1416 | if (imhtml->scroll_time) | |
| 1417 | g_timer_destroy(imhtml->scroll_time); | |
| 1418 | ||
| 4138 | 1419 | g_hash_table_destroy(imhtml->smiley_data); |
| 4032 | 1420 | gtk_smiley_tree_destroy(imhtml->default_smilies); |
| 4138 | 1421 | gdk_cursor_unref(imhtml->hand_cursor); |
| 1422 | gdk_cursor_unref(imhtml->arrow_cursor); | |
| 8061 | 1423 | gdk_cursor_unref(imhtml->text_cursor); |
| 8677 | 1424 | |
| 4735 | 1425 | if(imhtml->tip_window){ |
| 1426 | gtk_widget_destroy(imhtml->tip_window); | |
| 1427 | } | |
| 1428 | if(imhtml->tip_timer) | |
|
26829
ac9a76ef6ef0
Replace gtk_timeout_remove with g_source_remove.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26828
diff
changeset
|
1429 | g_source_remove(imhtml->tip_timer); |
| 4735 | 1430 | |
| 4895 | 1431 | for(scalables = imhtml->scalables; scalables; scalables = scalables->next) { |
|
11224
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
1432 | struct scalable_data *sd = scalables->data; |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
1433 | GtkIMHtmlScalable *scale = GTK_IMHTML_SCALABLE(sd->scalable); |
| 4895 | 1434 | scale->free(scale); |
|
11224
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
1435 | g_free(sd); |
| 4895 | 1436 | } |
| 7991 | 1437 | |
| 8962 | 1438 | for (l = imhtml->im_images; l; l = l->next) { |
|
11224
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
1439 | struct im_image_data *img_data = l->data; |
| 8962 | 1440 | if (imhtml->funcs->image_unref) |
|
11224
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
1441 | imhtml->funcs->image_unref(img_data->id); |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
1442 | g_free(img_data); |
| 8962 | 1443 | } |
| 1444 | ||
| 4895 | 1445 | g_list_free(imhtml->scalables); |
| 8962 | 1446 | 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
|
1447 | g_queue_free(imhtml->animations); |
|
14097
0c340861ab79
[gaim-migrate @ 16638]
Mark Doliner <markdoliner@pidgin.im>
parents:
14010
diff
changeset
|
1448 | g_free(imhtml->protocol_name); |
|
0c340861ab79
[gaim-migrate @ 16638]
Mark Doliner <markdoliner@pidgin.im>
parents:
14010
diff
changeset
|
1449 | 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
|
1450 | g_object_unref(imhtml->undo_manager); |
| 4032 | 1451 | 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
|
1452 | |
| 4032 | 1453 | } |
| 1428 | 1454 | |
|
24674
36bf974a7d78
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24588
diff
changeset
|
1455 | static GtkIMHtmlProtocol * |
|
25013
956b2f650d31
Detect duplication registrations by substring.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
25011
diff
changeset
|
1456 | imhtml_find_protocol(const char *url, gboolean reverse) |
|
24674
36bf974a7d78
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24588
diff
changeset
|
1457 | { |
|
36bf974a7d78
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24588
diff
changeset
|
1458 | GtkIMHtmlClass *klass; |
|
36bf974a7d78
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24588
diff
changeset
|
1459 | GList *iter; |
|
36bf974a7d78
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24588
diff
changeset
|
1460 | GtkIMHtmlProtocol *proto = NULL; |
|
25013
956b2f650d31
Detect duplication registrations by substring.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
25011
diff
changeset
|
1461 | int length = reverse ? strlen(url) : -1; |
|
24674
36bf974a7d78
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24588
diff
changeset
|
1462 | |
|
36bf974a7d78
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24588
diff
changeset
|
1463 | klass = g_type_class_ref(GTK_TYPE_IMHTML); |
|
36bf974a7d78
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24588
diff
changeset
|
1464 | for (iter = klass->protocols; iter; iter = iter->next) { |
|
36bf974a7d78
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24588
diff
changeset
|
1465 | proto = iter->data; |
|
25013
956b2f650d31
Detect duplication registrations by substring.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
25011
diff
changeset
|
1466 | if (g_ascii_strncasecmp(url, proto->name, reverse ? MIN(length, proto->length) : proto->length) == 0) { |
|
24674
36bf974a7d78
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24588
diff
changeset
|
1467 | return proto; |
|
36bf974a7d78
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24588
diff
changeset
|
1468 | } |
|
36bf974a7d78
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24588
diff
changeset
|
1469 | } |
|
36bf974a7d78
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24588
diff
changeset
|
1470 | return NULL; |
|
36bf974a7d78
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24588
diff
changeset
|
1471 | } |
|
36bf974a7d78
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24588
diff
changeset
|
1472 | |
|
36bf974a7d78
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24588
diff
changeset
|
1473 | static void |
|
36bf974a7d78
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24588
diff
changeset
|
1474 | imhtml_url_clicked(GtkIMHtml *imhtml, const char *url) |
|
36bf974a7d78
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24588
diff
changeset
|
1475 | { |
|
25013
956b2f650d31
Detect duplication registrations by substring.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
25011
diff
changeset
|
1476 | GtkIMHtmlProtocol *proto = imhtml_find_protocol(url, FALSE); |
|
24698
f9dd7117ade0
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24675
diff
changeset
|
1477 | GtkIMHtmlLink *link; |
|
24674
36bf974a7d78
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24588
diff
changeset
|
1478 | if (!proto) |
|
36bf974a7d78
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24588
diff
changeset
|
1479 | return; |
|
24698
f9dd7117ade0
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24675
diff
changeset
|
1480 | link = g_new0(GtkIMHtmlLink, 1); |
|
f9dd7117ade0
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24675
diff
changeset
|
1481 | link->imhtml = g_object_ref(imhtml); |
|
f9dd7117ade0
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24675
diff
changeset
|
1482 | link->url = g_strdup(url); |
|
f9dd7117ade0
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24675
diff
changeset
|
1483 | proto->activate(imhtml, link); /* XXX: Do something with the return value? */ |
|
f9dd7117ade0
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24675
diff
changeset
|
1484 | gtk_imhtml_link_destroy(link); |
|
24674
36bf974a7d78
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24588
diff
changeset
|
1485 | } |
|
36bf974a7d78
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24588
diff
changeset
|
1486 | |
|
10814
7e17cb56b019
[gaim-migrate @ 12468]
Luke Schierer <lschiere@pidgin.im>
parents:
10799
diff
changeset
|
1487 | /* Boring GTK+ stuff */ |
| 8519 | 1488 | static void gtk_imhtml_class_init (GtkIMHtmlClass *klass) |
| 1428 | 1489 | { |
| 9007 | 1490 | GtkWidgetClass *widget_class = (GtkWidgetClass *) klass; |
| 10100 | 1491 | GtkBindingSet *binding_set; |
| 4032 | 1492 | GObjectClass *gobject_class; |
| 8519 | 1493 | gobject_class = (GObjectClass*) klass; |
|
26828
ca76e7ad0d4b
Oops, I must have been tired. I only replaced the first occurrence of these
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26727
diff
changeset
|
1494 | parent_class = g_type_class_ref(GTK_TYPE_TEXT_VIEW); |
| 4417 | 1495 | signals[URL_CLICKED] = g_signal_new("url_clicked", |
| 1496 | G_TYPE_FROM_CLASS(gobject_class), | |
| 1497 | G_SIGNAL_RUN_FIRST, | |
| 1498 | G_STRUCT_OFFSET(GtkIMHtmlClass, url_clicked), | |
| 1499 | NULL, | |
| 1500 | 0, | |
| 1501 | g_cclosure_marshal_VOID__POINTER, | |
| 1502 | G_TYPE_NONE, 1, | |
| 1503 | G_TYPE_POINTER); | |
| 8506 | 1504 | signals[BUTTONS_UPDATE] = g_signal_new("format_buttons_update", |
| 8420 | 1505 | G_TYPE_FROM_CLASS(gobject_class), |
| 1506 | G_SIGNAL_RUN_FIRST, | |
| 1507 | G_STRUCT_OFFSET(GtkIMHtmlClass, buttons_update), | |
| 1508 | NULL, | |
| 1509 | 0, | |
|
10076
1ccc0286a4ae
[gaim-migrate @ 11057]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10062
diff
changeset
|
1510 | g_cclosure_marshal_VOID__INT, |
| 8420 | 1511 | G_TYPE_NONE, 1, |
| 1512 | G_TYPE_INT); | |
| 1513 | signals[TOGGLE_FORMAT] = g_signal_new("format_function_toggle", | |
| 1514 | G_TYPE_FROM_CLASS(gobject_class), | |
| 10100 | 1515 | G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION, |
| 8420 | 1516 | G_STRUCT_OFFSET(GtkIMHtmlClass, toggle_format), |
| 1517 | NULL, | |
| 1518 | 0, | |
|
10076
1ccc0286a4ae
[gaim-migrate @ 11057]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10062
diff
changeset
|
1519 | g_cclosure_marshal_VOID__INT, |
|
1ccc0286a4ae
[gaim-migrate @ 11057]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10062
diff
changeset
|
1520 | G_TYPE_NONE, 1, |
| 8420 | 1521 | G_TYPE_INT); |
| 8427 | 1522 | signals[CLEAR_FORMAT] = g_signal_new("format_function_clear", |
| 1523 | G_TYPE_FROM_CLASS(gobject_class), | |
|
11385
38ca1438e055
[gaim-migrate @ 13612]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11315
diff
changeset
|
1524 | G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION, |
| 8427 | 1525 | G_STRUCT_OFFSET(GtkIMHtmlClass, clear_format), |
| 1526 | NULL, | |
| 1527 | 0, | |
| 10100 | 1528 | g_cclosure_marshal_VOID__VOID, |
| 1529 | G_TYPE_NONE, 0); | |
| 8506 | 1530 | signals[UPDATE_FORMAT] = g_signal_new("format_function_update", |
| 10100 | 1531 | G_TYPE_FROM_CLASS(gobject_class), |
| 1532 | G_SIGNAL_RUN_FIRST, | |
| 1533 | G_STRUCT_OFFSET(GtkIMHtmlClass, update_format), | |
| 1534 | NULL, | |
| 1535 | 0, | |
| 1536 | g_cclosure_marshal_VOID__VOID, | |
| 1537 | G_TYPE_NONE, 0); | |
| 10108 | 1538 | signals[MESSAGE_SEND] = g_signal_new("message_send", |
| 1539 | G_TYPE_FROM_CLASS(gobject_class), | |
| 1540 | G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION, | |
| 1541 | G_STRUCT_OFFSET(GtkIMHtmlClass, message_send), | |
| 1542 | NULL, | |
| 1543 | 0, g_cclosure_marshal_VOID__VOID, | |
| 1544 | G_TYPE_NONE, 0); | |
|
29909
3b74346e22d5
Allow binding 'Paste as Plain Text'.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
29855
diff
changeset
|
1545 | signals[PASTE] = g_signal_new("paste", |
|
3b74346e22d5
Allow binding 'Paste as Plain Text'.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
29855
diff
changeset
|
1546 | G_TYPE_FROM_CLASS(gobject_class), |
|
3b74346e22d5
Allow binding 'Paste as Plain Text'.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
29855
diff
changeset
|
1547 | G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION, |
|
3b74346e22d5
Allow binding 'Paste as Plain Text'.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
29855
diff
changeset
|
1548 | 0, |
|
3b74346e22d5
Allow binding 'Paste as Plain Text'.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
29855
diff
changeset
|
1549 | NULL, |
|
3b74346e22d5
Allow binding 'Paste as Plain Text'.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
29855
diff
changeset
|
1550 | 0, g_cclosure_marshal_VOID__STRING, |
|
3b74346e22d5
Allow binding 'Paste as Plain Text'.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
29855
diff
changeset
|
1551 | G_TYPE_NONE, 1, G_TYPE_STRING); |
|
3b74346e22d5
Allow binding 'Paste as Plain Text'.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
29855
diff
changeset
|
1552 | signals [UNDO] = g_signal_new ("undo", |
|
3b74346e22d5
Allow binding 'Paste as Plain Text'.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
29855
diff
changeset
|
1553 | G_TYPE_FROM_CLASS (klass), |
|
3b74346e22d5
Allow binding 'Paste as Plain Text'.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
29855
diff
changeset
|
1554 | G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION, |
|
3b74346e22d5
Allow binding 'Paste as Plain Text'.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
29855
diff
changeset
|
1555 | G_STRUCT_OFFSET (GtkIMHtmlClass, undo), |
|
3b74346e22d5
Allow binding 'Paste as Plain Text'.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
29855
diff
changeset
|
1556 | NULL, |
|
3b74346e22d5
Allow binding 'Paste as Plain Text'.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
29855
diff
changeset
|
1557 | NULL, |
|
3b74346e22d5
Allow binding 'Paste as Plain Text'.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
29855
diff
changeset
|
1558 | gtksourceview_marshal_VOID__VOID, |
|
3b74346e22d5
Allow binding 'Paste as Plain Text'.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
29855
diff
changeset
|
1559 | G_TYPE_NONE, |
|
3b74346e22d5
Allow binding 'Paste as Plain Text'.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
29855
diff
changeset
|
1560 | 0); |
|
3b74346e22d5
Allow binding 'Paste as Plain Text'.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
29855
diff
changeset
|
1561 | signals [REDO] = g_signal_new ("redo", |
|
3b74346e22d5
Allow binding 'Paste as Plain Text'.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
29855
diff
changeset
|
1562 | G_TYPE_FROM_CLASS (klass), |
|
3b74346e22d5
Allow binding 'Paste as Plain Text'.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
29855
diff
changeset
|
1563 | G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION, |
|
3b74346e22d5
Allow binding 'Paste as Plain Text'.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
29855
diff
changeset
|
1564 | G_STRUCT_OFFSET (GtkIMHtmlClass, redo), |
|
3b74346e22d5
Allow binding 'Paste as Plain Text'.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
29855
diff
changeset
|
1565 | NULL, |
|
3b74346e22d5
Allow binding 'Paste as Plain Text'.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
29855
diff
changeset
|
1566 | NULL, |
|
3b74346e22d5
Allow binding 'Paste as Plain Text'.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
29855
diff
changeset
|
1567 | gtksourceview_marshal_VOID__VOID, |
|
3b74346e22d5
Allow binding 'Paste as Plain Text'.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
29855
diff
changeset
|
1568 | G_TYPE_NONE, |
|
3b74346e22d5
Allow binding 'Paste as Plain Text'.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
29855
diff
changeset
|
1569 | 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
|
1570 | |
|
5e73968467e0
Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@pidgin.im>
parents:
17288
diff
changeset
|
1571 | |
| 10100 | 1572 | |
| 1573 | klass->toggle_format = imhtml_toggle_format; | |
| 10108 | 1574 | klass->message_send = imhtml_message_send; |
|
12672
673e2a1d2954
[gaim-migrate @ 15015]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12635
diff
changeset
|
1575 | klass->clear_format = imhtml_clear_formatting; |
|
24674
36bf974a7d78
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24588
diff
changeset
|
1576 | klass->url_clicked = imhtml_url_clicked; |
|
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
|
1577 | 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
|
1578 | klass->redo = gtk_imhtml_redo; |
|
10184
543c9a84ce16
[gaim-migrate @ 11299]
Mark Doliner <markdoliner@pidgin.im>
parents:
10169
diff
changeset
|
1579 | |
| 4032 | 1580 | gobject_class->finalize = gtk_imhtml_finalize; |
|
10184
543c9a84ce16
[gaim-migrate @ 11299]
Mark Doliner <markdoliner@pidgin.im>
parents:
10169
diff
changeset
|
1581 | widget_class->drag_motion = gtk_text_view_drag_motion; |
| 10692 | 1582 | 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
|
1583 | 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
|
1584 | 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
|
1585 | 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
|
1586 | 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
|
1587 | |
| 9007 | 1588 | gtk_widget_class_install_style_property(widget_class, g_param_spec_boxed("hyperlink-color", |
| 1589 | _("Hyperlink color"), | |
| 1590 | _("Color to draw hyperlinks."), | |
| 1591 | 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
|
1592 | 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
|
1593 | _("Hyperlink visited color"), |
|
27525
579b9d64b364
A semi-random collection of English spelling and grammatical changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27359
diff
changeset
|
1594 | _("Color to draw hyperlink after it has been visited (or activated)."), |
|
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
|
1595 | GDK_TYPE_COLOR, G_PARAM_READABLE)); |
| 10799 | 1596 | gtk_widget_class_install_style_property(widget_class, g_param_spec_boxed("hyperlink-prelight-color", |
| 1597 | _("Hyperlink prelight color"), | |
| 1598 | _("Color to draw hyperlinks when mouse is over them."), | |
| 1599 | 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
|
1600 | 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
|
1601 | _("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
|
1602 | _("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
|
1603 | 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
|
1604 | 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
|
1605 | _("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
|
1606 | _("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
|
1607 | 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
|
1608 | 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
|
1609 | _("\"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
|
1610 | _("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
|
1611 | 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
|
1612 | 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
|
1613 | _("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
|
1614 | _("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
|
1615 | 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
|
1616 | 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
|
1617 | _("Action Message Name Color for Whispered Message"), |
|
27525
579b9d64b364
A semi-random collection of English spelling and grammatical changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27359
diff
changeset
|
1618 | _("Color to draw the name of a whispered action message."), |
|
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
|
1619 | 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
|
1620 | 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
|
1621 | _("Whisper Message Name Color"), |
|
27525
579b9d64b364
A semi-random collection of English spelling and grammatical changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27359
diff
changeset
|
1622 | _("Color to draw the name of a whispered message."), |
|
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
|
1623 | GDK_TYPE_COLOR, G_PARAM_READABLE)); |
| 10100 | 1624 | |
|
22772
34ab3bb905cc
Customize/disable the typing notification from gtkrc-2.0.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22703
diff
changeset
|
1625 | /* 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
|
1626 | * 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
|
1627 | * 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
|
1628 | * 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
|
1629 | */ |
|
34ab3bb905cc
Customize/disable the typing notification from gtkrc-2.0.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22703
diff
changeset
|
1630 | 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
|
1631 | _("Typing notification color"), |
|
27525
579b9d64b364
A semi-random collection of English spelling and grammatical changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27359
diff
changeset
|
1632 | _("The color to use for the typing notification"), |
|
22772
34ab3bb905cc
Customize/disable the typing notification from gtkrc-2.0.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22703
diff
changeset
|
1633 | 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
|
1634 | 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
|
1635 | _("Typing notification font"), |
|
34ab3bb905cc
Customize/disable the typing notification from gtkrc-2.0.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22703
diff
changeset
|
1636 | _("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
|
1637 | "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
|
1638 | 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
|
1639 | _("Enable typing notification"), |
|
34ab3bb905cc
Customize/disable the typing notification from gtkrc-2.0.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22703
diff
changeset
|
1640 | _("Enable typing notification"), |
|
34ab3bb905cc
Customize/disable the typing notification from gtkrc-2.0.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22703
diff
changeset
|
1641 | TRUE, G_PARAM_READABLE)); |
|
34ab3bb905cc
Customize/disable the typing notification from gtkrc-2.0.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22703
diff
changeset
|
1642 | |
| 10100 | 1643 | binding_set = gtk_binding_set_by_class (parent_class); |
| 10110 | 1644 | gtk_binding_entry_add_signal (binding_set, GDK_b, GDK_CONTROL_MASK, "format_function_toggle", 1, G_TYPE_INT, GTK_IMHTML_BOLD); |
| 10100 | 1645 | gtk_binding_entry_add_signal (binding_set, GDK_i, GDK_CONTROL_MASK, "format_function_toggle", 1, G_TYPE_INT, GTK_IMHTML_ITALIC); |
| 1646 | gtk_binding_entry_add_signal (binding_set, GDK_u, GDK_CONTROL_MASK, "format_function_toggle", 1, G_TYPE_INT, GTK_IMHTML_UNDERLINE); | |
| 1647 | gtk_binding_entry_add_signal (binding_set, GDK_plus, GDK_CONTROL_MASK, "format_function_toggle", 1, G_TYPE_INT, GTK_IMHTML_GROW); | |
| 1648 | gtk_binding_entry_add_signal (binding_set, GDK_equal, GDK_CONTROL_MASK, "format_function_toggle", 1, G_TYPE_INT, GTK_IMHTML_GROW); | |
| 1649 | gtk_binding_entry_add_signal (binding_set, GDK_minus, GDK_CONTROL_MASK, "format_function_toggle", 1, G_TYPE_INT, GTK_IMHTML_SHRINK); | |
| 10108 | 1650 | binding_set = gtk_binding_set_by_class(klass); |
|
11385
38ca1438e055
[gaim-migrate @ 13612]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11315
diff
changeset
|
1651 | gtk_binding_entry_add_signal (binding_set, GDK_r, GDK_CONTROL_MASK, "format_function_clear", 0); |
| 10108 | 1652 | gtk_binding_entry_add_signal (binding_set, GDK_KP_Enter, 0, "message_send", 0); |
| 1653 | gtk_binding_entry_add_signal (binding_set, GDK_Return, 0, "message_send", 0); | |
|
29909
3b74346e22d5
Allow binding 'Paste as Plain Text'.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
29855
diff
changeset
|
1654 | gtk_binding_entry_add_signal (binding_set, GDK_z, GDK_CONTROL_MASK, "undo", 0); |
|
3b74346e22d5
Allow binding 'Paste as Plain Text'.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
29855
diff
changeset
|
1655 | gtk_binding_entry_add_signal (binding_set, GDK_z, GDK_CONTROL_MASK | GDK_SHIFT_MASK, "redo", 0); |
|
3b74346e22d5
Allow binding 'Paste as Plain Text'.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
29855
diff
changeset
|
1656 | gtk_binding_entry_add_signal (binding_set, GDK_F14, 0, "undo", 0); |
|
3b74346e22d5
Allow binding 'Paste as Plain Text'.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
29855
diff
changeset
|
1657 | gtk_binding_entry_add_signal(binding_set, GDK_v, GDK_CONTROL_MASK | GDK_SHIFT_MASK, "paste", 1, G_TYPE_STRING, "text"); |
| 1428 | 1658 | } |
| 1659 | ||
| 3922 | 1660 | static void gtk_imhtml_init (GtkIMHtml *imhtml) |
| 1428 | 1661 | { |
| 3922 | 1662 | 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
|
1663 | imhtml->undo_manager = gtk_source_undo_manager_new(imhtml->text_buffer); |
| 3922 | 1664 | 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
|
1665 | 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
|
1666 | 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
|
1667 | gtk_text_view_set_pixels_below_lines(GTK_TEXT_VIEW(imhtml), 3); |
| 8677 | 1668 | gtk_text_view_set_left_margin(GTK_TEXT_VIEW(imhtml), 2); |
| 1669 | gtk_text_view_set_right_margin(GTK_TEXT_VIEW(imhtml), 2); | |
| 8061 | 1670 | /*gtk_text_view_set_indent(GTK_TEXT_VIEW(imhtml), -15);*/ |
| 3922 | 1671 | /*gtk_text_view_set_justification(GTK_TEXT_VIEW(imhtml), GTK_JUSTIFY_FILL);*/ |
| 8061 | 1672 | |
| 3922 | 1673 | /* These tags will be used often and can be reused--we create them on init and then apply them by name |
| 8932 | 1674 | * other tags (color, size, face, etc.) will have to be created and applied dynamically |
| 9924 | 1675 | * Note that even though we created SUB, SUP, and PRE tags here, we don't really |
| 8932 | 1676 | * apply them anywhere yet. */ |
| 3922 | 1677 | gtk_text_buffer_create_tag(imhtml->text_buffer, "BOLD", "weight", PANGO_WEIGHT_BOLD, NULL); |
| 1678 | gtk_text_buffer_create_tag(imhtml->text_buffer, "ITALICS", "style", PANGO_STYLE_ITALIC, NULL); | |
| 1679 | gtk_text_buffer_create_tag(imhtml->text_buffer, "UNDERLINE", "underline", PANGO_UNDERLINE_SINGLE, NULL); | |
| 1680 | gtk_text_buffer_create_tag(imhtml->text_buffer, "STRIKE", "strikethrough", TRUE, NULL); | |
| 1681 | gtk_text_buffer_create_tag(imhtml->text_buffer, "SUB", "rise", -5000, NULL); | |
| 1682 | gtk_text_buffer_create_tag(imhtml->text_buffer, "SUP", "rise", 5000, NULL); | |
| 1683 | gtk_text_buffer_create_tag(imhtml->text_buffer, "PRE", "family", "Monospace", NULL); | |
| 7295 | 1684 | 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
|
1685 | 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
|
1686 | #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
|
1687 | "invisible", FALSE, |
|
22211
7f3cecdb079c
disapproval of revision '2c96f5a301400781ce5fbf144ffdbae44f895281'
Sean Egan <seanegan@pidgin.im>
parents:
22210
diff
changeset
|
1688 | #endif |
|
23308
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
1689 | NULL); |
| 8677 | 1690 | |
|
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
|
1691 | 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
|
1692 | 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
|
1693 | 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
|
1694 | 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
|
1695 | 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
|
1696 | gtk_text_buffer_create_tag(imhtml->text_buffer, "whisper-name", "weight", PANGO_WEIGHT_BOLD, NULL); |
| 8677 | 1697 | |
| 3922 | 1698 | /* When hovering over a link, we show the hand cursor--elsewhere we show the plain ol' pointer cursor */ |
| 1699 | imhtml->hand_cursor = gdk_cursor_new (GDK_HAND2); | |
| 1700 | imhtml->arrow_cursor = gdk_cursor_new (GDK_LEFT_PTR); | |
| 8061 | 1701 | imhtml->text_cursor = gdk_cursor_new (GDK_XTERM); |
| 2993 | 1702 | |
|
6124
322206d79652
[gaim-migrate @ 6598]
Mark Doliner <markdoliner@pidgin.im>
parents:
6066
diff
changeset
|
1703 | imhtml->show_comments = TRUE; |
| 4253 | 1704 | |
| 4892 | 1705 | imhtml->smiley_data = g_hash_table_new_full(g_str_hash, g_str_equal, |
| 4902 | 1706 | g_free, (GDestroyNotify)gtk_smiley_tree_destroy); |
| 4032 | 1707 | imhtml->default_smilies = gtk_smiley_tree_new(); |
| 4735 | 1708 | |
| 1709 | 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
|
1710 | 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
|
1711 | g_signal_connect(G_OBJECT(imhtml), "enter-notify-event", G_CALLBACK(gtk_enter_event_notify), NULL); |
| 8677 | 1712 | g_signal_connect(G_OBJECT(imhtml), "button_press_event", G_CALLBACK(gtk_imhtml_button_press_event), NULL); |
| 1713 | 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
|
1714 | g_signal_connect(G_OBJECT(imhtml->text_buffer), "delete_range", G_CALLBACK(delete_cb), imhtml); |
| 8061 | 1715 | g_signal_connect_after(G_OBJECT(imhtml->text_buffer), "insert-text", G_CALLBACK(insert_cb), imhtml); |
| 10169 | 1716 | g_signal_connect_after(G_OBJECT(imhtml->text_buffer), "insert-child-anchor", G_CALLBACK(insert_ca_cb), imhtml); |
| 8091 | 1717 | gtk_drag_dest_set(GTK_WIDGET(imhtml), 0, |
| 1718 | link_drag_drop_targets, sizeof(link_drag_drop_targets) / sizeof(GtkTargetEntry), | |
| 1719 | GDK_ACTION_COPY); | |
| 1720 | g_signal_connect(G_OBJECT(imhtml), "drag_data_received", G_CALLBACK(gtk_imhtml_link_drag_rcv_cb), imhtml); | |
| 9300 | 1721 | g_signal_connect(G_OBJECT(imhtml), "drag_drop", G_CALLBACK(gtk_imhtml_link_drop_cb), imhtml); |
| 8091 | 1722 | |
| 7353 | 1723 | g_signal_connect(G_OBJECT(imhtml), "copy-clipboard", G_CALLBACK(copy_clipboard_cb), NULL); |
| 8698 | 1724 | g_signal_connect(G_OBJECT(imhtml), "cut-clipboard", G_CALLBACK(cut_clipboard_cb), NULL); |
| 8061 | 1725 | g_signal_connect(G_OBJECT(imhtml), "paste-clipboard", G_CALLBACK(paste_clipboard_cb), NULL); |
| 8677 | 1726 | 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
|
1727 | g_signal_connect(G_OBJECT(imhtml), "unrealize", G_CALLBACK(imhtml_destroy_add_primary), NULL); |
|
29909
3b74346e22d5
Allow binding 'Paste as Plain Text'.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
29855
diff
changeset
|
1728 | g_signal_connect(G_OBJECT(imhtml), "paste", G_CALLBACK(imhtml_paste_cb), NULL); |
| 8677 | 1729 | |
|
29855
234f74a60570
I think this works around the problem with the Win32 Clipboard and GTK+ 2.16.
Daniel Atallah <datallah@pidgin.im>
parents:
29724
diff
changeset
|
1730 | #ifndef _WIN32 |
| 8677 | 1731 | g_signal_connect_after(G_OBJECT(GTK_IMHTML(imhtml)->text_buffer), "mark-set", |
| 1732 | G_CALLBACK(mark_set_so_update_selection_cb), imhtml); | |
|
29855
234f74a60570
I think this works around the problem with the Win32 Clipboard and GTK+ 2.16.
Daniel Atallah <datallah@pidgin.im>
parents:
29724
diff
changeset
|
1733 | #endif |
| 8677 | 1734 | |
|
10946
63a41710fc94
[gaim-migrate @ 12742]
Daniel Atallah <datallah@pidgin.im>
parents:
10936
diff
changeset
|
1735 | gtk_widget_add_events(GTK_WIDGET(imhtml), |
|
63a41710fc94
[gaim-migrate @ 12742]
Daniel Atallah <datallah@pidgin.im>
parents:
10936
diff
changeset
|
1736 | GDK_LEAVE_NOTIFY_MASK | GDK_ENTER_NOTIFY_MASK); |
| 4735 | 1737 | |
| 1738 | imhtml->tip = NULL; | |
| 1739 | imhtml->tip_timer = 0; | |
| 1740 | imhtml->tip_window = NULL; | |
| 4895 | 1741 | |
| 8677 | 1742 | imhtml->edit.bold = FALSE; |
| 1743 | imhtml->edit.italic = FALSE; | |
| 1744 | imhtml->edit.underline = FALSE; | |
| 8061 | 1745 | imhtml->edit.forecolor = NULL; |
| 1746 | imhtml->edit.backcolor = NULL; | |
| 1747 | imhtml->edit.fontface = NULL; | |
| 8677 | 1748 | imhtml->edit.fontsize = 0; |
| 1749 | imhtml->edit.link = NULL; | |
| 1750 | ||
|
11572
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
1751 | |
| 4895 | 1752 | 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
|
1753 | imhtml->animations = g_queue_new(); |
| 8061 | 1754 | gtk_imhtml_set_editable(imhtml, FALSE); |
|
11572
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
1755 | g_signal_connect(G_OBJECT(imhtml), "populate-popup", |
| 8931 | 1756 | G_CALLBACK(hijack_menu_cb), NULL); |
| 2993 | 1757 | } |
| 1758 | ||
| 3922 | 1759 | GtkWidget *gtk_imhtml_new(void *a, void *b) |
| 1428 | 1760 | { |
| 4635 | 1761 | return GTK_WIDGET(g_object_new(gtk_imhtml_get_type(), NULL)); |
| 1428 | 1762 | } |
| 1763 | ||
| 9037 | 1764 | GType gtk_imhtml_get_type() |
| 1428 | 1765 | { |
| 9037 | 1766 | static GType imhtml_type = 0; |
| 1428 | 1767 | |
| 1768 | if (!imhtml_type) { | |
| 9037 | 1769 | static const GTypeInfo imhtml_info = { |
| 4635 | 1770 | sizeof(GtkIMHtmlClass), |
| 1771 | NULL, | |
| 1772 | NULL, | |
| 1773 | (GClassInitFunc) gtk_imhtml_class_init, | |
| 1774 | NULL, | |
| 1775 | NULL, | |
| 1428 | 1776 | sizeof (GtkIMHtml), |
| 4635 | 1777 | 0, |
|
12600
7ecd4441fdc7
[gaim-migrate @ 14934]
Richard Laager <rlaager@pidgin.im>
parents:
12553
diff
changeset
|
1778 | (GInstanceInitFunc) gtk_imhtml_init, |
|
7ecd4441fdc7
[gaim-migrate @ 14934]
Richard Laager <rlaager@pidgin.im>
parents:
12553
diff
changeset
|
1779 | NULL |
| 1428 | 1780 | }; |
| 4635 | 1781 | |
| 1782 | imhtml_type = g_type_register_static(gtk_text_view_get_type(), | |
| 1783 | "GtkIMHtml", &imhtml_info, 0); | |
| 1428 | 1784 | } |
| 1785 | ||
| 1786 | return imhtml_type; | |
| 1787 | } | |
| 1788 | ||
|
24698
f9dd7117ade0
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24675
diff
changeset
|
1789 | static void gtk_imhtml_link_destroy(GtkIMHtmlLink *link) |
|
f9dd7117ade0
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24675
diff
changeset
|
1790 | { |
|
f9dd7117ade0
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24675
diff
changeset
|
1791 | if (link->imhtml) |
|
f9dd7117ade0
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24675
diff
changeset
|
1792 | g_object_unref(link->imhtml); |
|
f9dd7117ade0
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24675
diff
changeset
|
1793 | if (link->tag) |
|
f9dd7117ade0
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24675
diff
changeset
|
1794 | g_object_unref(link->tag); |
|
f9dd7117ade0
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24675
diff
changeset
|
1795 | g_free(link->url); |
|
f9dd7117ade0
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24675
diff
changeset
|
1796 | g_free(link); |
| 4417 | 1797 | } |
| 1798 | ||
| 1799 | /* 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
|
1800 | 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
|
1801 | { |
| 4417 | 1802 | GdkEventButton *event_button = (GdkEventButton *) event; |
| 8061 | 1803 | if (GTK_IMHTML(imhtml)->editable) |
| 1804 | return FALSE; | |
| 3922 | 1805 | if (event->type == GDK_BUTTON_RELEASE) { |
| 8957 | 1806 | if ((event_button->button == 1) || (event_button->button == 2)) { |
| 4417 | 1807 | GtkTextIter start, end; |
| 1808 | /* we shouldn't open a URL if the user has selected something: */ | |
| 8677 | 1809 | if (gtk_text_buffer_get_selection_bounds( |
| 1810 | gtk_text_iter_get_buffer(arg2), &start, &end)) | |
| 4417 | 1811 | return FALSE; |
|
24698
f9dd7117ade0
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24675
diff
changeset
|
1812 | gtk_imhtml_activate_tag(GTK_IMHTML(imhtml), tag); |
| 4417 | 1813 | return FALSE; |
| 1814 | } else if(event_button->button == 3) { | |
|
24698
f9dd7117ade0
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24675
diff
changeset
|
1815 | GList *children; |
|
f9dd7117ade0
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24675
diff
changeset
|
1816 | GtkWidget *menu; |
|
24674
36bf974a7d78
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24588
diff
changeset
|
1817 | GtkIMHtmlProtocol *proto; |
|
24698
f9dd7117ade0
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24675
diff
changeset
|
1818 | GtkIMHtmlLink *link = g_new(GtkIMHtmlLink, 1); |
|
f9dd7117ade0
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24675
diff
changeset
|
1819 | link->imhtml = g_object_ref(imhtml); |
|
f9dd7117ade0
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24675
diff
changeset
|
1820 | link->url = g_strdup(g_object_get_data(G_OBJECT(tag), "link_url")); |
|
f9dd7117ade0
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24675
diff
changeset
|
1821 | link->tag = g_object_ref(tag); |
| 4745 | 1822 | |
| 5091 | 1823 | /* Don't want the tooltip around if user right-clicked on link */ |
| 1824 | if (GTK_IMHTML(imhtml)->tip_window) { | |
| 1825 | gtk_widget_destroy(GTK_IMHTML(imhtml)->tip_window); | |
| 1826 | GTK_IMHTML(imhtml)->tip_window = NULL; | |
| 1827 | } | |
| 1828 | if (GTK_IMHTML(imhtml)->tip_timer) { | |
| 1829 | g_source_remove(GTK_IMHTML(imhtml)->tip_timer); | |
| 1830 | GTK_IMHTML(imhtml)->tip_timer = 0; | |
| 1831 | } | |
| 8061 | 1832 | if (GTK_IMHTML(imhtml)->editable) |
| 1833 | gdk_window_set_cursor(event_button->window, GTK_IMHTML(imhtml)->text_cursor); | |
| 1834 | else | |
| 1835 | gdk_window_set_cursor(event_button->window, GTK_IMHTML(imhtml)->arrow_cursor); | |
| 4417 | 1836 | menu = gtk_menu_new(); |
|
24698
f9dd7117ade0
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24675
diff
changeset
|
1837 | g_object_set_data_full(G_OBJECT(menu), "x-imhtml-url-data", link, |
|
f9dd7117ade0
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24675
diff
changeset
|
1838 | (GDestroyNotify)gtk_imhtml_link_destroy); |
|
f9dd7117ade0
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24675
diff
changeset
|
1839 | |
|
25013
956b2f650d31
Detect duplication registrations by substring.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
25011
diff
changeset
|
1840 | proto = imhtml_find_protocol(link->url, FALSE); |
|
24698
f9dd7117ade0
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24675
diff
changeset
|
1841 | |
|
f9dd7117ade0
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24675
diff
changeset
|
1842 | if (proto && proto->context_menu) { |
|
f9dd7117ade0
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24675
diff
changeset
|
1843 | proto->context_menu(GTK_IMHTML(link->imhtml), link, menu); |
|
7140
2670fa7da352
[gaim-migrate @ 7707]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
1844 | } |
|
24698
f9dd7117ade0
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24675
diff
changeset
|
1845 | |
|
f9dd7117ade0
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24675
diff
changeset
|
1846 | children = gtk_container_get_children(GTK_CONTAINER(menu)); |
|
f9dd7117ade0
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24675
diff
changeset
|
1847 | if (!children) { |
|
f9dd7117ade0
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24675
diff
changeset
|
1848 | GtkWidget *item = gtk_menu_item_new_with_label(_("No actions available")); |
|
f9dd7117ade0
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24675
diff
changeset
|
1849 | gtk_widget_show(item); |
|
f9dd7117ade0
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24675
diff
changeset
|
1850 | gtk_widget_set_sensitive(item, FALSE); |
| 10936 | 1851 | gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); |
|
24698
f9dd7117ade0
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24675
diff
changeset
|
1852 | } else { |
|
f9dd7117ade0
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24675
diff
changeset
|
1853 | g_list_free(children); |
|
7140
2670fa7da352
[gaim-migrate @ 7707]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
1854 | } |
|
2670fa7da352
[gaim-migrate @ 7707]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
1855 | |
|
4756
ee19a87a495f
[gaim-migrate @ 5073]
Mark Doliner <markdoliner@pidgin.im>
parents:
4745
diff
changeset
|
1856 | |
| 4417 | 1857 | gtk_widget_show_all(menu); |
|
4756
ee19a87a495f
[gaim-migrate @ 5073]
Mark Doliner <markdoliner@pidgin.im>
parents:
4745
diff
changeset
|
1858 | gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL, |
|
ee19a87a495f
[gaim-migrate @ 5073]
Mark Doliner <markdoliner@pidgin.im>
parents:
4745
diff
changeset
|
1859 | event_button->button, event_button->time); |
| 4745 | 1860 | |
| 4417 | 1861 | return TRUE; |
| 1862 | } | |
| 1428 | 1863 | } |
| 4417 | 1864 | if(event->type == GDK_BUTTON_PRESS && event_button->button == 3) |
| 1865 | return TRUE; /* Clicking the right mouse button on a link shouldn't | |
| 1866 | be caught by the regular GtkTextView menu */ | |
| 1867 | else | |
| 1868 | return FALSE; /* Let clicks go through if we didn't catch anything */ | |
| 1428 | 1869 | } |
| 1870 | ||
| 9300 | 1871 | static gboolean |
| 1872 | gtk_text_view_drag_motion (GtkWidget *widget, | |
| 1873 | GdkDragContext *context, | |
| 1874 | gint x, | |
| 1875 | gint y, | |
| 1876 | guint time) | |
| 1877 | { | |
|
11572
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
1878 | GdkDragAction suggested_action = 0; |
| 9300 | 1879 | |
|
10145
f1405f65ff41
[gaim-migrate @ 11218]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10110
diff
changeset
|
1880 | 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
|
1881 | /* can't accept any of the offered targets */ |
| 9300 | 1882 | } else { |
| 1883 | GtkWidget *source_widget; | |
| 1884 | suggested_action = context->suggested_action; | |
| 1885 | source_widget = gtk_drag_get_source_widget (context); | |
| 1886 | if (source_widget == widget) { | |
| 1887 | /* Default to MOVE, unless the user has | |
| 1888 | * pressed ctrl or alt to affect available actions | |
| 1889 | */ | |
| 1890 | if ((context->actions & GDK_ACTION_MOVE) != 0) | |
| 1891 | suggested_action = GDK_ACTION_MOVE; | |
| 1892 | } | |
|
11572
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
1893 | } |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
1894 | |
|
10145
f1405f65ff41
[gaim-migrate @ 11218]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10110
diff
changeset
|
1895 | gdk_drag_status (context, suggested_action, time); |
|
11572
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
1896 | |
| 9300 | 1897 | /* TRUE return means don't propagate the drag motion to parent |
| 1898 | * widgets that may also be drop sites. | |
| 1899 | */ | |
| 1900 | return TRUE; | |
| 1901 | } | |
| 1902 | ||
| 1903 | static void | |
| 1904 | gtk_imhtml_link_drop_cb(GtkWidget *widget, GdkDragContext *context, gint x, gint y, guint time, gpointer user_data) | |
| 1905 | { | |
| 1906 | GdkAtom target = gtk_drag_dest_find_target (widget, context, NULL); | |
|
11572
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
1907 | |
| 9300 | 1908 | if (target != GDK_NONE) |
| 1909 | gtk_drag_get_data (widget, context, target, time); | |
| 1910 | else | |
| 1911 | gtk_drag_finish (context, FALSE, FALSE, time); | |
| 1912 | ||
| 1913 | return; | |
| 1914 | } | |
| 1915 | ||
| 8091 | 1916 | static void |
| 1917 | 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
|
1918 | GtkSelectionData *sd, guint info, guint t, GtkIMHtml *imhtml) |
| 8091 | 1919 | { |
| 9300 | 1920 | gchar **links; |
| 1921 | gchar *link; | |
|
11143
f606fb334190
[gaim-migrate @ 13207]
Mark Doliner <markdoliner@pidgin.im>
parents:
11069
diff
changeset
|
1922 | char *text = (char *)sd->data; |
| 9300 | 1923 | GtkTextMark *mark = gtk_text_buffer_get_insert(imhtml->text_buffer); |
| 1924 | GtkTextIter iter; | |
|
10782
18cc41076f4e
[gaim-migrate @ 12410]
Luke Schierer <lschiere@pidgin.im>
parents:
10777
diff
changeset
|
1925 | gint i = 0; |
| 9300 | 1926 | |
| 1927 | gtk_text_buffer_get_iter_at_mark(imhtml->text_buffer, &iter, mark); | |
| 1928 | ||
| 8091 | 1929 | if(gtk_imhtml_get_editable(imhtml) && sd->data){ |
| 9300 | 1930 | switch (info) { |
|
10145
f1405f65ff41
[gaim-migrate @ 11218]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10110
diff
changeset
|
1931 | case GTK_IMHTML_DRAG_URL: |
|
11143
f606fb334190
[gaim-migrate @ 13207]
Mark Doliner <markdoliner@pidgin.im>
parents:
11069
diff
changeset
|
1932 | /* TODO: Is it really ok to change sd->data...? */ |
| 15884 | 1933 | purple_str_strip_char((char *)sd->data, '\r'); |
|
11143
f606fb334190
[gaim-migrate @ 13207]
Mark Doliner <markdoliner@pidgin.im>
parents:
11069
diff
changeset
|
1934 | |
|
f606fb334190
[gaim-migrate @ 13207]
Mark Doliner <markdoliner@pidgin.im>
parents:
11069
diff
changeset
|
1935 | links = g_strsplit((char *)sd->data, "\n", 0); |
|
10782
18cc41076f4e
[gaim-migrate @ 12410]
Luke Schierer <lschiere@pidgin.im>
parents:
10777
diff
changeset
|
1936 | while((link = links[i]) != NULL){ |
|
24674
36bf974a7d78
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24588
diff
changeset
|
1937 | if (gtk_imhtml_is_protocol(link)) { |
|
10782
18cc41076f4e
[gaim-migrate @ 12410]
Luke Schierer <lschiere@pidgin.im>
parents:
10777
diff
changeset
|
1938 | gchar *label; |
|
18cc41076f4e
[gaim-migrate @ 12410]
Luke Schierer <lschiere@pidgin.im>
parents:
10777
diff
changeset
|
1939 | |
|
18cc41076f4e
[gaim-migrate @ 12410]
Luke Schierer <lschiere@pidgin.im>
parents:
10777
diff
changeset
|
1940 | if(links[i + 1]) |
|
18cc41076f4e
[gaim-migrate @ 12410]
Luke Schierer <lschiere@pidgin.im>
parents:
10777
diff
changeset
|
1941 | i++; |
|
18cc41076f4e
[gaim-migrate @ 12410]
Luke Schierer <lschiere@pidgin.im>
parents:
10777
diff
changeset
|
1942 | |
|
18cc41076f4e
[gaim-migrate @ 12410]
Luke Schierer <lschiere@pidgin.im>
parents:
10777
diff
changeset
|
1943 | label = links[i]; |
|
18cc41076f4e
[gaim-migrate @ 12410]
Luke Schierer <lschiere@pidgin.im>
parents:
10777
diff
changeset
|
1944 | |
|
18cc41076f4e
[gaim-migrate @ 12410]
Luke Schierer <lschiere@pidgin.im>
parents:
10777
diff
changeset
|
1945 | gtk_imhtml_insert_link(imhtml, mark, link, label); |
|
24674
36bf974a7d78
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24588
diff
changeset
|
1946 | } else if (*link == '\0') { |
| 9300 | 1947 | /* Ignore blank lines */ |
| 1948 | } else { | |
| 1949 | /* 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
|
1950 | /* ... don't pretend we handled it if we didn't */ |
|
7d7f8cfa2b4f
[gaim-migrate @ 11556]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
10297
diff
changeset
|
1951 | gtk_drag_finish(dc, FALSE, FALSE, t); |
|
10782
18cc41076f4e
[gaim-migrate @ 12410]
Luke Schierer <lschiere@pidgin.im>
parents:
10777
diff
changeset
|
1952 | g_strfreev(links); |
|
10345
7d7f8cfa2b4f
[gaim-migrate @ 11556]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
10297
diff
changeset
|
1953 | return; |
| 9300 | 1954 | } |
|
10782
18cc41076f4e
[gaim-migrate @ 12410]
Luke Schierer <lschiere@pidgin.im>
parents:
10777
diff
changeset
|
1955 | |
|
18cc41076f4e
[gaim-migrate @ 12410]
Luke Schierer <lschiere@pidgin.im>
parents:
10777
diff
changeset
|
1956 | i++; |
| 8091 | 1957 | } |
|
10782
18cc41076f4e
[gaim-migrate @ 12410]
Luke Schierer <lschiere@pidgin.im>
parents:
10777
diff
changeset
|
1958 | g_strfreev(links); |
| 9300 | 1959 | break; |
|
10145
f1405f65ff41
[gaim-migrate @ 11218]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10110
diff
changeset
|
1960 | case GTK_IMHTML_DRAG_HTML: |
|
10243
6d75b29afc71
[gaim-migrate @ 11383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10217
diff
changeset
|
1961 | { |
|
6d75b29afc71
[gaim-migrate @ 11383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10217
diff
changeset
|
1962 | char *utf8 = NULL; |
|
6d75b29afc71
[gaim-migrate @ 11383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10217
diff
changeset
|
1963 | /* 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
|
1964 | * as explained by this comment in gtkhtml: |
|
6d75b29afc71
[gaim-migrate @ 11383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10217
diff
changeset
|
1965 | * |
|
6d75b29afc71
[gaim-migrate @ 11383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10217
diff
changeset
|
1966 | * 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
|
1967 | * mozilla/netscape alway use ucs2 for text/html |
|
6d75b29afc71
[gaim-migrate @ 11383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10217
diff
changeset
|
1968 | * 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
|
1969 | * 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
|
1970 | * |
|
6d75b29afc71
[gaim-migrate @ 11383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10217
diff
changeset
|
1971 | * See also the comment on text/html here: |
|
6d75b29afc71
[gaim-migrate @ 11383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10217
diff
changeset
|
1972 | * 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
|
1973 | */ |
|
6d75b29afc71
[gaim-migrate @ 11383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10217
diff
changeset
|
1974 | 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
|
1975 | utf8 = utf16_to_utf8_with_bom_check(text, sd->length); |
|
10243
6d75b29afc71
[gaim-migrate @ 11383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10217
diff
changeset
|
1976 | |
|
6d75b29afc71
[gaim-migrate @ 11383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10217
diff
changeset
|
1977 | 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
|
1978 | purple_debug_warning("gtkimhtml", "g_convert from UTF-16 failed in drag_rcv_cb\n"); |
| 9300 | 1979 | return; |
| 1980 | } | |
|
10243
6d75b29afc71
[gaim-migrate @ 11383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10217
diff
changeset
|
1981 | } else if (!(*text) || !g_utf8_validate(text, -1, NULL)) { |
| 15884 | 1982 | purple_debug_warning("gtkimhtml", "empty string or invalid UTF-8 in drag_rcv_cb\n"); |
| 9300 | 1983 | return; |
| 1984 | } | |
|
10243
6d75b29afc71
[gaim-migrate @ 11383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10217
diff
changeset
|
1985 | |
|
6d75b29afc71
[gaim-migrate @ 11383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10217
diff
changeset
|
1986 | 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
|
1987 | g_free(utf8); |
| 9300 | 1988 | break; |
|
10243
6d75b29afc71
[gaim-migrate @ 11383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10217
diff
changeset
|
1989 | } |
|
10145
f1405f65ff41
[gaim-migrate @ 11218]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10110
diff
changeset
|
1990 | case GTK_IMHTML_DRAG_TEXT: |
|
f1405f65ff41
[gaim-migrate @ 11218]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10110
diff
changeset
|
1991 | if (!(*text) || !g_utf8_validate(text, -1, NULL)) { |
| 15884 | 1992 | 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
|
1993 | return; |
|
f1405f65ff41
[gaim-migrate @ 11218]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10110
diff
changeset
|
1994 | } else { |
|
10732
5e314ab498bf
[gaim-migrate @ 12334]
Richard Laager <rlaager@pidgin.im>
parents:
10699
diff
changeset
|
1995 | char *tmp = g_markup_escape_text(text, -1); |
|
10145
f1405f65ff41
[gaim-migrate @ 11218]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10110
diff
changeset
|
1996 | gtk_imhtml_insert_html_at_iter(imhtml, tmp, 0, &iter); |
|
f1405f65ff41
[gaim-migrate @ 11218]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10110
diff
changeset
|
1997 | g_free(tmp); |
|
f1405f65ff41
[gaim-migrate @ 11218]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10110
diff
changeset
|
1998 | } |
|
f1405f65ff41
[gaim-migrate @ 11218]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10110
diff
changeset
|
1999 | break; |
| 9300 | 2000 | default: |
|
10145
f1405f65ff41
[gaim-migrate @ 11218]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10110
diff
changeset
|
2001 | gtk_drag_finish(dc, FALSE, FALSE, t); |
|
f1405f65ff41
[gaim-migrate @ 11218]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10110
diff
changeset
|
2002 | return; |
| 8091 | 2003 | } |
| 2004 | gtk_drag_finish(dc, TRUE, (dc->action == GDK_ACTION_MOVE), t); | |
| 2005 | } else { | |
| 2006 | gtk_drag_finish(dc, FALSE, FALSE, t); | |
| 2007 | } | |
| 2008 | } | |
| 2009 | ||
| 9300 | 2010 | static void gtk_smiley_tree_remove (GtkSmileyTree *tree, |
| 4263 | 2011 | GtkIMHtmlSmiley *smiley) |
| 4032 | 2012 | { |
| 2013 | GtkSmileyTree *t = tree; | |
| 4263 | 2014 | const gchar *x = smiley->smile; |
| 4032 | 2015 | gint len = 0; |
| 2016 | ||
| 2017 | while (*x) { | |
| 2018 | gchar *pos; | |
| 2019 | ||
| 2020 | if (!t->values) | |
| 2021 | return; | |
| 2022 | ||
| 2023 | pos = strchr (t->values->str, *x); | |
| 2024 | if (pos) | |
|
24544
75266af2c12b
Fixed a compiler warning (and remove an unnessesary cast)
Marcus Lundblad <malu@pidgin.im>
parents:
24511
diff
changeset
|
2025 | t = t->children [pos - t->values->str]; |
| 4032 | 2026 | else |
| 2027 | return; | |
| 2028 | ||
| 2029 | x++; len++; | |
| 2030 | } | |
| 2031 | ||
| 4141 | 2032 | if (t->image) { |
| 4032 | 2033 | t->image = NULL; |
| 4141 | 2034 | } |
| 4032 | 2035 | } |
| 2036 | ||
| 2037 | static gint | |
| 2038 | gtk_smiley_tree_lookup (GtkSmileyTree *tree, | |
| 2039 | const gchar *text) | |
| 2040 | { | |
| 2041 | GtkSmileyTree *t = tree; | |
| 2042 | const gchar *x = text; | |
| 2043 | gint len = 0; | |
|
16143
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
2044 | const gchar *amp; |
| 8505 | 2045 | gint alen; |
| 4032 | 2046 | |
| 2047 | while (*x) { | |
| 2048 | gchar *pos; | |
| 2049 | ||
| 2050 | if (!t->values) | |
| 2051 | break; | |
| 2052 | ||
| 16144 | 2053 | if(*x == '&' && (amp = purple_markup_unescape_entity(x, &alen))) { |
|
10865
f5bb66be81a0
[gaim-migrate @ 12549]
Daniel Atallah <datallah@pidgin.im>
parents:
10858
diff
changeset
|
2054 | gboolean matched = TRUE; |
|
f5bb66be81a0
[gaim-migrate @ 12549]
Daniel Atallah <datallah@pidgin.im>
parents:
10858
diff
changeset
|
2055 | /* Make sure all chars of the unescaped value match */ |
|
f5bb66be81a0
[gaim-migrate @ 12549]
Daniel Atallah <datallah@pidgin.im>
parents:
10858
diff
changeset
|
2056 | while (*(amp + 1)) { |
|
f5bb66be81a0
[gaim-migrate @ 12549]
Daniel Atallah <datallah@pidgin.im>
parents:
10858
diff
changeset
|
2057 | pos = strchr (t->values->str, *amp); |
|
f5bb66be81a0
[gaim-migrate @ 12549]
Daniel Atallah <datallah@pidgin.im>
parents:
10858
diff
changeset
|
2058 | if (pos) |
|
f5bb66be81a0
[gaim-migrate @ 12549]
Daniel Atallah <datallah@pidgin.im>
parents:
10858
diff
changeset
|
2059 | 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
|
2060 | else { |
|
f5bb66be81a0
[gaim-migrate @ 12549]
Daniel Atallah <datallah@pidgin.im>
parents:
10858
diff
changeset
|
2061 | matched = FALSE; |
|
f5bb66be81a0
[gaim-migrate @ 12549]
Daniel Atallah <datallah@pidgin.im>
parents:
10858
diff
changeset
|
2062 | break; |
|
f5bb66be81a0
[gaim-migrate @ 12549]
Daniel Atallah <datallah@pidgin.im>
parents:
10858
diff
changeset
|
2063 | } |
|
f5bb66be81a0
[gaim-migrate @ 12549]
Daniel Atallah <datallah@pidgin.im>
parents:
10858
diff
changeset
|
2064 | amp++; |
|
f5bb66be81a0
[gaim-migrate @ 12549]
Daniel Atallah <datallah@pidgin.im>
parents:
10858
diff
changeset
|
2065 | } |
|
f5bb66be81a0
[gaim-migrate @ 12549]
Daniel Atallah <datallah@pidgin.im>
parents:
10858
diff
changeset
|
2066 | if (!matched) |
|
f5bb66be81a0
[gaim-migrate @ 12549]
Daniel Atallah <datallah@pidgin.im>
parents:
10858
diff
changeset
|
2067 | break; |
|
f5bb66be81a0
[gaim-migrate @ 12549]
Daniel Atallah <datallah@pidgin.im>
parents:
10858
diff
changeset
|
2068 | |
|
f5bb66be81a0
[gaim-migrate @ 12549]
Daniel Atallah <datallah@pidgin.im>
parents:
10858
diff
changeset
|
2069 | pos = strchr (t->values->str, *amp); |
| 8505 | 2070 | } |
|
11572
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
2071 | else if (*x == '<') /* Because we're all WYSIWYG now, a '<' |
| 9636 | 2072 | * char should only appear as the start of a tag. Perhaps a safer (but costlier) |
| 2073 | * check would be to call gtk_imhtml_is_tag on it */ | |
| 10600 | 2074 | break; |
|
10865
f5bb66be81a0
[gaim-migrate @ 12549]
Daniel Atallah <datallah@pidgin.im>
parents:
10858
diff
changeset
|
2075 | else { |
|
f5bb66be81a0
[gaim-migrate @ 12549]
Daniel Atallah <datallah@pidgin.im>
parents:
10858
diff
changeset
|
2076 | alen = 1; |
|
f5bb66be81a0
[gaim-migrate @ 12549]
Daniel Atallah <datallah@pidgin.im>
parents:
10858
diff
changeset
|
2077 | pos = strchr (t->values->str, *x); |
|
f5bb66be81a0
[gaim-migrate @ 12549]
Daniel Atallah <datallah@pidgin.im>
parents:
10858
diff
changeset
|
2078 | } |
| 8505 | 2079 | |
| 4032 | 2080 | if (pos) |
| 7371 | 2081 | t = t->children [GPOINTER_TO_INT(pos) - GPOINTER_TO_INT(t->values->str)]; |
| 4032 | 2082 | else |
| 2083 | break; | |
| 2084 | ||
|
10865
f5bb66be81a0
[gaim-migrate @ 12549]
Daniel Atallah <datallah@pidgin.im>
parents:
10858
diff
changeset
|
2085 | x += alen; |
|
f5bb66be81a0
[gaim-migrate @ 12549]
Daniel Atallah <datallah@pidgin.im>
parents:
10858
diff
changeset
|
2086 | len += alen; |
| 4032 | 2087 | } |
| 2088 | ||
| 2089 | if (t->image) | |
| 2090 | return len; | |
| 2091 | ||
| 2092 | return 0; | |
| 2093 | } | |
| 2094 | ||
|
24392
51b7f65a712d
Clean up the GtkSmileyTrees on active GtkIMHtml instances when a custom smiley
Marcus Lundblad <malu@pidgin.im>
parents:
24328
diff
changeset
|
2095 | static void |
|
51b7f65a712d
Clean up the GtkSmileyTrees on active GtkIMHtml instances when a custom smiley
Marcus Lundblad <malu@pidgin.im>
parents:
24328
diff
changeset
|
2096 | 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
|
2097 | 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
|
2098 | { |
|
51b7f65a712d
Clean up the GtkSmileyTrees on active GtkIMHtml instances when a custom smiley
Marcus Lundblad <malu@pidgin.im>
parents:
24328
diff
changeset
|
2099 | 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
|
2100 | 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
|
2101 | 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
|
2102 | } |
|
51b7f65a712d
Clean up the GtkSmileyTrees on active GtkIMHtml instances when a custom smiley
Marcus Lundblad <malu@pidgin.im>
parents:
24328
diff
changeset
|
2103 | |
|
51b7f65a712d
Clean up the GtkSmileyTrees on active GtkIMHtml instances when a custom smiley
Marcus Lundblad <malu@pidgin.im>
parents:
24328
diff
changeset
|
2104 | static void |
|
24588
b2c89babe134
Remove that hack involving GtkIMHtmlSmileys
Marcus Lundblad <malu@pidgin.im>
parents:
24587
diff
changeset
|
2105 | gtk_imhtml_disconnect_smiley(GtkIMHtml *imhtml, GtkIMHtmlSmiley *smiley) |
|
b2c89babe134
Remove that hack involving GtkIMHtmlSmileys
Marcus Lundblad <malu@pidgin.im>
parents:
24587
diff
changeset
|
2106 | { |
|
b2c89babe134
Remove that hack involving GtkIMHtmlSmileys
Marcus Lundblad <malu@pidgin.im>
parents:
24587
diff
changeset
|
2107 | smiley->imhtml = NULL; |
|
b2c89babe134
Remove that hack involving GtkIMHtmlSmileys
Marcus Lundblad <malu@pidgin.im>
parents:
24587
diff
changeset
|
2108 | 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
|
2109 | NULL, NULL, smiley); |
|
b2c89babe134
Remove that hack involving GtkIMHtmlSmileys
Marcus Lundblad <malu@pidgin.im>
parents:
24587
diff
changeset
|
2110 | } |
|
b2c89babe134
Remove that hack involving GtkIMHtmlSmileys
Marcus Lundblad <malu@pidgin.im>
parents:
24587
diff
changeset
|
2111 | |
|
b2c89babe134
Remove that hack involving GtkIMHtmlSmileys
Marcus Lundblad <malu@pidgin.im>
parents:
24587
diff
changeset
|
2112 | 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
|
2113 | 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
|
2114 | { |
|
24588
b2c89babe134
Remove that hack involving GtkIMHtmlSmileys
Marcus Lundblad <malu@pidgin.im>
parents:
24587
diff
changeset
|
2115 | 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
|
2116 | gtk_smiley_tree_remove(smiley->imhtml->default_smilies, smiley); |
|
25888
d0fdd378a635
Remove trailing whitespace
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
2117 | g_hash_table_foreach(smiley->imhtml->smiley_data, |
|
24392
51b7f65a712d
Clean up the GtkSmileyTrees on active GtkIMHtml instances when a custom smiley
Marcus Lundblad <malu@pidgin.im>
parents:
24328
diff
changeset
|
2118 | gtk_imhtml_disassociate_smiley_foreach, smiley); |
|
24588
b2c89babe134
Remove that hack involving GtkIMHtmlSmileys
Marcus Lundblad <malu@pidgin.im>
parents:
24587
diff
changeset
|
2119 | 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
|
2120 | 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
|
2121 | 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
|
2122 | } |
|
51b7f65a712d
Clean up the GtkSmileyTrees on active GtkIMHtml instances when a custom smiley
Marcus Lundblad <malu@pidgin.im>
parents:
24328
diff
changeset
|
2123 | } |
|
51b7f65a712d
Clean up the GtkSmileyTrees on active GtkIMHtml instances when a custom smiley
Marcus Lundblad <malu@pidgin.im>
parents:
24328
diff
changeset
|
2124 | |
| 4032 | 2125 | void |
| 4263 | 2126 | gtk_imhtml_associate_smiley (GtkIMHtml *imhtml, |
|
10537
9ece7671fa62
[gaim-migrate @ 11890]
Mark Doliner <markdoliner@pidgin.im>
parents:
10526
diff
changeset
|
2127 | const gchar *sml, |
| 4263 | 2128 | GtkIMHtmlSmiley *smiley) |
| 4032 | 2129 | { |
| 2130 | GtkSmileyTree *tree; | |
| 2131 | g_return_if_fail (imhtml != NULL); | |
| 2132 | g_return_if_fail (GTK_IS_IMHTML (imhtml)); | |
| 7371 | 2133 | |
| 4032 | 2134 | if (sml == NULL) |
| 2135 | tree = imhtml->default_smilies; | |
|
12833
1f461f275b90
[gaim-migrate @ 15181]
Richard Laager <rlaager@pidgin.im>
parents:
12796
diff
changeset
|
2136 | else if (!(tree = g_hash_table_lookup(imhtml->smiley_data, sml))) { |
| 4032 | 2137 | tree = gtk_smiley_tree_new(); |
| 4892 | 2138 | g_hash_table_insert(imhtml->smiley_data, g_strdup(sml), tree); |
| 4032 | 2139 | } |
| 2140 | ||
|
24588
b2c89babe134
Remove that hack involving GtkIMHtmlSmileys
Marcus Lundblad <malu@pidgin.im>
parents:
24587
diff
changeset
|
2141 | /* need to disconnect old imhtml, if there is one */ |
|
b2c89babe134
Remove that hack involving GtkIMHtmlSmileys
Marcus Lundblad <malu@pidgin.im>
parents:
24587
diff
changeset
|
2142 | if (smiley->imhtml) { |
|
b2c89babe134
Remove that hack involving GtkIMHtmlSmileys
Marcus Lundblad <malu@pidgin.im>
parents:
24587
diff
changeset
|
2143 | 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
|
2144 | 0, 0, NULL, NULL, smiley); |
|
b2c89babe134
Remove that hack involving GtkIMHtmlSmileys
Marcus Lundblad <malu@pidgin.im>
parents:
24587
diff
changeset
|
2145 | } |
|
25888
d0fdd378a635
Remove trailing whitespace
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
2146 | |
| 12335 | 2147 | smiley->imhtml = imhtml; |
| 2148 | ||
| 4263 | 2149 | gtk_smiley_tree_insert (tree, smiley); |
|
25888
d0fdd378a635
Remove trailing whitespace
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
2150 | |
|
24588
b2c89babe134
Remove that hack involving GtkIMHtmlSmileys
Marcus Lundblad <malu@pidgin.im>
parents:
24587
diff
changeset
|
2151 | /* connect destroy signal for the imhtml */ |
|
25888
d0fdd378a635
Remove trailing whitespace
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
2152 | g_signal_connect(imhtml, "destroy", G_CALLBACK(gtk_imhtml_disconnect_smiley), |
|
24588
b2c89babe134
Remove that hack involving GtkIMHtmlSmileys
Marcus Lundblad <malu@pidgin.im>
parents:
24587
diff
changeset
|
2153 | smiley); |
| 4032 | 2154 | } |
| 2155 | ||
| 2156 | static gboolean | |
| 2157 | gtk_imhtml_is_smiley (GtkIMHtml *imhtml, | |
| 2158 | GSList *fonts, | |
| 2159 | const gchar *text, | |
| 2160 | gint *len) | |
| 2161 | { | |
| 2162 | GtkSmileyTree *tree; | |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
2163 | GtkIMHtmlFontDetail *font; |
| 4032 | 2164 | char *sml = NULL; |
| 2165 | ||
| 2166 | if (fonts) { | |
| 2167 | font = fonts->data; | |
| 2168 | sml = font->sml; | |
| 2169 | } | |
| 2170 | ||
| 9029 | 2171 | if (!sml) |
| 2172 | sml = imhtml->protocol_name; | |
| 2173 | ||
| 2174 | if (!sml || !(tree = g_hash_table_lookup(imhtml->smiley_data, sml))) | |
| 4032 | 2175 | tree = imhtml->default_smilies; |
| 9029 | 2176 | |
| 4032 | 2177 | if (tree == NULL) |
| 2178 | return FALSE; | |
| 7371 | 2179 | |
| 8505 | 2180 | *len = gtk_smiley_tree_lookup (tree, text); |
| 4032 | 2181 | return (*len > 0); |
| 2182 | } | |
| 2183 | ||
|
29724
1a6689974d33
Minor cleanup. Hopefully this code has a little less duplication and
Mark Doliner <markdoliner@pidgin.im>
parents:
29721
diff
changeset
|
2184 | static GtkIMHtmlSmiley *gtk_imhtml_smiley_get_from_tree(GtkSmileyTree *t, const gchar *text) |
|
1a6689974d33
Minor cleanup. Hopefully this code has a little less duplication and
Mark Doliner <markdoliner@pidgin.im>
parents:
29721
diff
changeset
|
2185 | { |
| 4032 | 2186 | const gchar *x = text; |
|
29724
1a6689974d33
Minor cleanup. Hopefully this code has a little less duplication and
Mark Doliner <markdoliner@pidgin.im>
parents:
29721
diff
changeset
|
2187 | gchar *pos; |
| 4032 | 2188 | |
| 2189 | if (t == NULL) | |
|
29724
1a6689974d33
Minor cleanup. Hopefully this code has a little less duplication and
Mark Doliner <markdoliner@pidgin.im>
parents:
29721
diff
changeset
|
2190 | return NULL; |
| 4032 | 2191 | |
| 2192 | while (*x) { | |
|
29724
1a6689974d33
Minor cleanup. Hopefully this code has a little less duplication and
Mark Doliner <markdoliner@pidgin.im>
parents:
29721
diff
changeset
|
2193 | if (!t->values) |
|
1a6689974d33
Minor cleanup. Hopefully this code has a little less duplication and
Mark Doliner <markdoliner@pidgin.im>
parents:
29721
diff
changeset
|
2194 | return NULL; |
|
1a6689974d33
Minor cleanup. Hopefully this code has a little less duplication and
Mark Doliner <markdoliner@pidgin.im>
parents:
29721
diff
changeset
|
2195 | |
|
1a6689974d33
Minor cleanup. Hopefully this code has a little less duplication and
Mark Doliner <markdoliner@pidgin.im>
parents:
29721
diff
changeset
|
2196 | pos = strchr(t->values->str, *x); |
|
1a6689974d33
Minor cleanup. Hopefully this code has a little less duplication and
Mark Doliner <markdoliner@pidgin.im>
parents:
29721
diff
changeset
|
2197 | if (!pos) |
|
1a6689974d33
Minor cleanup. Hopefully this code has a little less duplication and
Mark Doliner <markdoliner@pidgin.im>
parents:
29721
diff
changeset
|
2198 | return NULL; |
|
1a6689974d33
Minor cleanup. Hopefully this code has a little less duplication and
Mark Doliner <markdoliner@pidgin.im>
parents:
29721
diff
changeset
|
2199 | |
|
1a6689974d33
Minor cleanup. Hopefully this code has a little less duplication and
Mark Doliner <markdoliner@pidgin.im>
parents:
29721
diff
changeset
|
2200 | t = t->children[GPOINTER_TO_INT(pos) - GPOINTER_TO_INT(t->values->str)]; |
| 4032 | 2201 | x++; |
| 2202 | } | |
| 2203 | ||
| 10526 | 2204 | return t->image; |
| 2205 | } | |
| 2206 | ||
|
29724
1a6689974d33
Minor cleanup. Hopefully this code has a little less duplication and
Mark Doliner <markdoliner@pidgin.im>
parents:
29721
diff
changeset
|
2207 | GtkIMHtmlSmiley * |
|
1a6689974d33
Minor cleanup. Hopefully this code has a little less duplication and
Mark Doliner <markdoliner@pidgin.im>
parents:
29721
diff
changeset
|
2208 | gtk_imhtml_smiley_get(GtkIMHtml *imhtml, const gchar *sml, const gchar *text) |
|
1a6689974d33
Minor cleanup. Hopefully this code has a little less duplication and
Mark Doliner <markdoliner@pidgin.im>
parents:
29721
diff
changeset
|
2209 | { |
|
1a6689974d33
Minor cleanup. Hopefully this code has a little less duplication and
Mark Doliner <markdoliner@pidgin.im>
parents:
29721
diff
changeset
|
2210 | GtkIMHtmlSmiley *ret; |
|
1a6689974d33
Minor cleanup. Hopefully this code has a little less duplication and
Mark Doliner <markdoliner@pidgin.im>
parents:
29721
diff
changeset
|
2211 | |
|
1a6689974d33
Minor cleanup. Hopefully this code has a little less duplication and
Mark Doliner <markdoliner@pidgin.im>
parents:
29721
diff
changeset
|
2212 | /* Look for custom smileys first */ |
|
1a6689974d33
Minor cleanup. Hopefully this code has a little less duplication and
Mark Doliner <markdoliner@pidgin.im>
parents:
29721
diff
changeset
|
2213 | if (sml != NULL) { |
|
1a6689974d33
Minor cleanup. Hopefully this code has a little less duplication and
Mark Doliner <markdoliner@pidgin.im>
parents:
29721
diff
changeset
|
2214 | ret = gtk_imhtml_smiley_get_from_tree(g_hash_table_lookup(imhtml->smiley_data, sml), text); |
|
1a6689974d33
Minor cleanup. Hopefully this code has a little less duplication and
Mark Doliner <markdoliner@pidgin.im>
parents:
29721
diff
changeset
|
2215 | if (ret != NULL) |
|
1a6689974d33
Minor cleanup. Hopefully this code has a little less duplication and
Mark Doliner <markdoliner@pidgin.im>
parents:
29721
diff
changeset
|
2216 | return ret; |
|
1a6689974d33
Minor cleanup. Hopefully this code has a little less duplication and
Mark Doliner <markdoliner@pidgin.im>
parents:
29721
diff
changeset
|
2217 | } |
|
1a6689974d33
Minor cleanup. Hopefully this code has a little less duplication and
Mark Doliner <markdoliner@pidgin.im>
parents:
29721
diff
changeset
|
2218 | |
|
1a6689974d33
Minor cleanup. Hopefully this code has a little less duplication and
Mark Doliner <markdoliner@pidgin.im>
parents:
29721
diff
changeset
|
2219 | /* Fall back to check for default smileys */ |
|
1a6689974d33
Minor cleanup. Hopefully this code has a little less duplication and
Mark Doliner <markdoliner@pidgin.im>
parents:
29721
diff
changeset
|
2220 | return gtk_imhtml_smiley_get_from_tree(imhtml->default_smilies, text); |
|
1a6689974d33
Minor cleanup. Hopefully this code has a little less duplication and
Mark Doliner <markdoliner@pidgin.im>
parents:
29721
diff
changeset
|
2221 | } |
|
1a6689974d33
Minor cleanup. Hopefully this code has a little less duplication and
Mark Doliner <markdoliner@pidgin.im>
parents:
29721
diff
changeset
|
2222 | |
|
11677
89c2ab8d2ebf
[gaim-migrate @ 13963]
Mark Doliner <markdoliner@pidgin.im>
parents:
11586
diff
changeset
|
2223 | 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
|
2224 | gtk_smiley_get_image(GtkIMHtmlSmiley *smiley) |
| 10526 | 2225 | { |
|
29724
1a6689974d33
Minor cleanup. Hopefully this code has a little less duplication and
Mark Doliner <markdoliner@pidgin.im>
parents:
29721
diff
changeset
|
2226 | if (!smiley->icon) { |
|
1a6689974d33
Minor cleanup. Hopefully this code has a little less duplication and
Mark Doliner <markdoliner@pidgin.im>
parents:
29721
diff
changeset
|
2227 | if (smiley->file) { |
|
1a6689974d33
Minor cleanup. Hopefully this code has a little less duplication and
Mark Doliner <markdoliner@pidgin.im>
parents:
29721
diff
changeset
|
2228 | smiley->icon = gdk_pixbuf_animation_new_from_file(smiley->file, NULL); |
|
1a6689974d33
Minor cleanup. Hopefully this code has a little less duplication and
Mark Doliner <markdoliner@pidgin.im>
parents:
29721
diff
changeset
|
2229 | } else if (smiley->loader) { |
|
1a6689974d33
Minor cleanup. Hopefully this code has a little less duplication and
Mark Doliner <markdoliner@pidgin.im>
parents:
29721
diff
changeset
|
2230 | smiley->icon = gdk_pixbuf_loader_get_animation(smiley->loader); |
|
1a6689974d33
Minor cleanup. Hopefully this code has a little less duplication and
Mark Doliner <markdoliner@pidgin.im>
parents:
29721
diff
changeset
|
2231 | if (smiley->icon) |
|
1a6689974d33
Minor cleanup. Hopefully this code has a little less duplication and
Mark Doliner <markdoliner@pidgin.im>
parents:
29721
diff
changeset
|
2232 | g_object_ref(G_OBJECT(smiley->icon)); |
|
1a6689974d33
Minor cleanup. Hopefully this code has a little less duplication and
Mark Doliner <markdoliner@pidgin.im>
parents:
29721
diff
changeset
|
2233 | } |
| 10526 | 2234 | } |
|
11572
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
2235 | |
| 10526 | 2236 | return smiley->icon; |
| 4032 | 2237 | } |
| 8890 | 2238 | |
|
25017
139df1ee9854
Fix the linkification error where bad things happened if you copy/pasted
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
25014
diff
changeset
|
2239 | #define VALID_TAG(x) do { \ |
|
139df1ee9854
Fix the linkification error where bad things happened if you copy/pasted
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
25014
diff
changeset
|
2240 | if (!g_ascii_strncasecmp (string, x ">", strlen (x ">"))) { \ |
|
139df1ee9854
Fix the linkification error where bad things happened if you copy/pasted
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
25014
diff
changeset
|
2241 | if (tag) *tag = g_strndup (string, strlen (x)); \ |
|
139df1ee9854
Fix the linkification error where bad things happened if you copy/pasted
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
25014
diff
changeset
|
2242 | if (len) *len = strlen (x) + 1; \ |
| 3922 | 2243 | return TRUE; \ |
| 2244 | } \ | |
|
25017
139df1ee9854
Fix the linkification error where bad things happened if you copy/pasted
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
25014
diff
changeset
|
2245 | if (type) (*type)++; \ |
|
139df1ee9854
Fix the linkification error where bad things happened if you copy/pasted
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
25014
diff
changeset
|
2246 | } while (0) |
|
139df1ee9854
Fix the linkification error where bad things happened if you copy/pasted
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
25014
diff
changeset
|
2247 | |
|
139df1ee9854
Fix the linkification error where bad things happened if you copy/pasted
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
25014
diff
changeset
|
2248 | #define VALID_OPT_TAG(x) do { \ |
|
139df1ee9854
Fix the linkification error where bad things happened if you copy/pasted
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
25014
diff
changeset
|
2249 | if (!g_ascii_strncasecmp (string, x " ", strlen (x " "))) { \ |
| 3922 | 2250 | const gchar *c = string + strlen (x " "); \ |
| 2251 | gchar e = '"'; \ | |
| 2252 | gboolean quote = FALSE; \ | |
| 2253 | while (*c) { \ | |
| 2254 | if (*c == '"' || *c == '\'') { \ | |
| 2255 | if (quote && (*c == e)) \ | |
| 2256 | quote = !quote; \ | |
| 2257 | else if (!quote) { \ | |
| 2258 | quote = !quote; \ | |
| 2259 | e = *c; \ | |
| 2260 | } \ | |
| 2261 | } else if (!quote && (*c == '>')) \ | |
| 2262 | break; \ | |
| 2263 | c++; \ | |
| 2264 | } \ | |
| 2265 | if (*c) { \ | |
|
25017
139df1ee9854
Fix the linkification error where bad things happened if you copy/pasted
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
25014
diff
changeset
|
2266 | if (tag) *tag = g_strndup (string, c - string); \ |
|
139df1ee9854
Fix the linkification error where bad things happened if you copy/pasted
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
25014
diff
changeset
|
2267 | if (len) *len = c - string + 1; \ |
| 3922 | 2268 | return TRUE; \ |
| 2269 | } \ | |
| 2270 | } \ | |
|
25017
139df1ee9854
Fix the linkification error where bad things happened if you copy/pasted
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
25014
diff
changeset
|
2271 | if (type) (*type)++; \ |
|
139df1ee9854
Fix the linkification error where bad things happened if you copy/pasted
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
25014
diff
changeset
|
2272 | } while (0) |
| 1428 | 2273 | |
| 2274 | ||
|
1472
ce83d12b7df9
[gaim-migrate @ 1482]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
1463
diff
changeset
|
2275 | static gboolean |
|
2856
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2276 | gtk_imhtml_is_tag (const gchar *string, |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2277 | gchar **tag, |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2278 | gint *len, |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2279 | gint *type) |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2280 | { |
| 8061 | 2281 | char *close; |
|
25017
139df1ee9854
Fix the linkification error where bad things happened if you copy/pasted
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
25014
diff
changeset
|
2282 | if (type) |
|
139df1ee9854
Fix the linkification error where bad things happened if you copy/pasted
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
25014
diff
changeset
|
2283 | *type = 1; |
|
8118
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
2284 | |
| 8061 | 2285 | if (!(close = strchr (string, '>'))) |
|
2856
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2286 | return FALSE; |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2287 | |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2288 | VALID_TAG ("B"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2289 | VALID_TAG ("BOLD"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2290 | VALID_TAG ("/B"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2291 | VALID_TAG ("/BOLD"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2292 | VALID_TAG ("I"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2293 | VALID_TAG ("ITALIC"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2294 | VALID_TAG ("/I"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2295 | VALID_TAG ("/ITALIC"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2296 | VALID_TAG ("U"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2297 | VALID_TAG ("UNDERLINE"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2298 | VALID_TAG ("/U"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2299 | VALID_TAG ("/UNDERLINE"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2300 | VALID_TAG ("S"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2301 | VALID_TAG ("STRIKE"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2302 | VALID_TAG ("/S"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2303 | VALID_TAG ("/STRIKE"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2304 | VALID_TAG ("SUB"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2305 | VALID_TAG ("/SUB"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2306 | VALID_TAG ("SUP"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2307 | VALID_TAG ("/SUP"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2308 | VALID_TAG ("PRE"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2309 | VALID_TAG ("/PRE"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2310 | VALID_TAG ("TITLE"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2311 | VALID_TAG ("/TITLE"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2312 | VALID_TAG ("BR"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2313 | VALID_TAG ("HR"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2314 | VALID_TAG ("/FONT"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2315 | VALID_TAG ("/A"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2316 | VALID_TAG ("P"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2317 | VALID_TAG ("/P"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2318 | VALID_TAG ("H3"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2319 | VALID_TAG ("/H3"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2320 | VALID_TAG ("HTML"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2321 | VALID_TAG ("/HTML"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2322 | VALID_TAG ("BODY"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2323 | VALID_TAG ("/BODY"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2324 | VALID_TAG ("FONT"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2325 | VALID_TAG ("HEAD"); |
| 2993 | 2326 | VALID_TAG ("/HEAD"); |
| 2327 | VALID_TAG ("BINARY"); | |
| 2328 | VALID_TAG ("/BINARY"); | |
| 5093 | 2329 | |
|
2856
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2330 | VALID_OPT_TAG ("HR"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2331 | VALID_OPT_TAG ("FONT"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2332 | VALID_OPT_TAG ("BODY"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2333 | VALID_OPT_TAG ("A"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2334 | VALID_OPT_TAG ("IMG"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2335 | VALID_OPT_TAG ("P"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2336 | VALID_OPT_TAG ("H3"); |
| 5093 | 2337 | VALID_OPT_TAG ("HTML"); |
|
2856
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2338 | |
| 5101 | 2339 | VALID_TAG ("CITE"); |
| 2340 | VALID_TAG ("/CITE"); | |
| 2341 | VALID_TAG ("EM"); | |
| 2342 | VALID_TAG ("/EM"); | |
| 2343 | VALID_TAG ("STRONG"); | |
| 2344 | VALID_TAG ("/STRONG"); | |
| 2345 | ||
| 5104 | 2346 | VALID_OPT_TAG ("SPAN"); |
| 2347 | VALID_TAG ("/SPAN"); | |
| 5174 | 2348 | VALID_TAG ("BR/"); /* hack until gtkimhtml handles things better */ |
|
6982
12f08de92674
[gaim-migrate @ 7538]
Mark Doliner <markdoliner@pidgin.im>
parents:
6882
diff
changeset
|
2349 | VALID_TAG ("IMG"); |
| 8026 | 2350 | VALID_TAG("SPAN"); |
| 8061 | 2351 | VALID_OPT_TAG("BR"); |
| 7988 | 2352 | |
| 4793 | 2353 | if (!g_ascii_strncasecmp(string, "!--", strlen ("!--"))) { |
|
2954
fc07d855731d
[gaim-migrate @ 2967]
Christian Hammond <chipx86@chipx86.com>
parents:
2898
diff
changeset
|
2354 | gchar *e = strstr (string + strlen("!--"), "-->"); |
|
2856
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2355 | if (e) { |
|
25017
139df1ee9854
Fix the linkification error where bad things happened if you copy/pasted
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
25014
diff
changeset
|
2356 | if (len) |
|
139df1ee9854
Fix the linkification error where bad things happened if you copy/pasted
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
25014
diff
changeset
|
2357 | *len = e - string + strlen ("-->"); |
|
139df1ee9854
Fix the linkification error where bad things happened if you copy/pasted
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
25014
diff
changeset
|
2358 | if (tag) |
|
139df1ee9854
Fix the linkification error where bad things happened if you copy/pasted
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
25014
diff
changeset
|
2359 | *tag = g_strndup (string + strlen ("!--"), *len - strlen ("!---->")); |
|
2856
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2360 | return TRUE; |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2361 | } |
|
8118
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
2362 | } |
|
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
2363 | |
|
25017
139df1ee9854
Fix the linkification error where bad things happened if you copy/pasted
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
25014
diff
changeset
|
2364 | if (type) |
|
139df1ee9854
Fix the linkification error where bad things happened if you copy/pasted
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
25014
diff
changeset
|
2365 | *type = -1; |
|
139df1ee9854
Fix the linkification error where bad things happened if you copy/pasted
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
25014
diff
changeset
|
2366 | if (len) |
|
139df1ee9854
Fix the linkification error where bad things happened if you copy/pasted
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
25014
diff
changeset
|
2367 | *len = close - string + 1; |
|
139df1ee9854
Fix the linkification error where bad things happened if you copy/pasted
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
25014
diff
changeset
|
2368 | if (tag) |
|
139df1ee9854
Fix the linkification error where bad things happened if you copy/pasted
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
25014
diff
changeset
|
2369 | *tag = g_strndup(string, *len - 1); |
|
19733
ec657d978c5a
disapproval of revision 'f08436883bb16f29affdc63e9fd86ff278ed368f'
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
19732
diff
changeset
|
2370 | return TRUE; |
|
2856
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2371 | } |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2372 | |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2373 | static gchar* |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2374 | gtk_imhtml_get_html_opt (gchar *tag, |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2375 | const gchar *opt) |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2376 | { |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2377 | gchar *t = tag; |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2378 | gchar *e, *a; |
| 5177 | 2379 | gchar *val; |
| 2380 | gint len; | |
|
16143
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
2381 | const gchar *c; |
| 5177 | 2382 | GString *ret; |
|
2856
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2383 | |
| 4793 | 2384 | while (g_ascii_strncasecmp (t, opt, strlen (opt))) { |
|
2856
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2385 | gboolean quote = FALSE; |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2386 | if (*t == '\0') break; |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2387 | while (*t && !((*t == ' ') && !quote)) { |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2388 | if (*t == '\"') |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2389 | quote = ! quote; |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2390 | t++; |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2391 | } |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2392 | while (*t && (*t == ' ')) t++; |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2393 | } |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2394 | |
| 4793 | 2395 | if (!g_ascii_strncasecmp (t, opt, strlen (opt))) { |
|
2856
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2396 | t += strlen (opt); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2397 | } else { |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2398 | return NULL; |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2399 | } |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2400 | |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2401 | if ((*t == '\"') || (*t == '\'')) { |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2402 | e = a = ++t; |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2403 | while (*e && (*e != *(t - 1))) e++; |
| 2993 | 2404 | if (*e == '\0') { |
|
2856
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2405 | return NULL; |
| 5177 | 2406 | } else |
| 2407 | val = g_strndup(a, e - a); | |
|
2856
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2408 | } else { |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2409 | e = a = t; |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2410 | while (*e && !isspace ((gint) *e)) e++; |
| 5177 | 2411 | val = g_strndup(a, e - a); |
|
2856
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2412 | } |
| 5177 | 2413 | |
| 2414 | ret = g_string_new(""); | |
| 2415 | e = val; | |
| 2416 | while(*e) { | |
| 16144 | 2417 | if((c = purple_markup_unescape_entity(e, &len))) { |
| 7280 | 2418 | ret = g_string_append(ret, c); |
| 5177 | 2419 | e += len; |
| 2420 | } else { | |
|
19325
4ae1add93886
Thanks sadrul. Fixes #2277
Sean Egan <seanegan@pidgin.im>
parents:
19103
diff
changeset
|
2421 | gunichar uni = g_utf8_get_char(e); |
|
4ae1add93886
Thanks sadrul. Fixes #2277
Sean Egan <seanegan@pidgin.im>
parents:
19103
diff
changeset
|
2422 | ret = g_string_append_unichar(ret, uni); |
|
4ae1add93886
Thanks sadrul. Fixes #2277
Sean Egan <seanegan@pidgin.im>
parents:
19103
diff
changeset
|
2423 | e = g_utf8_next_char(e); |
| 5177 | 2424 | } |
| 2425 | } | |
| 2426 | ||
| 2427 | g_free(val); | |
|
8568
66907b37ce85
[gaim-migrate @ 9316]
Mark Doliner <markdoliner@pidgin.im>
parents:
8566
diff
changeset
|
2428 | |
|
66907b37ce85
[gaim-migrate @ 9316]
Mark Doliner <markdoliner@pidgin.im>
parents:
8566
diff
changeset
|
2429 | return g_string_free(ret, FALSE); |
|
2856
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2430 | } |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2431 | |
| 8334 | 2432 | /* returns if the beginning of the text is a protocol. If it is the protocol, returns the length so |
| 2433 | the caller knows how long the protocol string is. */ | |
|
12412
8abe3226695e
[gaim-migrate @ 14719]
Richard Laager <rlaager@pidgin.im>
parents:
12335
diff
changeset
|
2434 | static int gtk_imhtml_is_protocol(const char *text) |
| 8334 | 2435 | { |
|
25013
956b2f650d31
Detect duplication registrations by substring.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
25011
diff
changeset
|
2436 | GtkIMHtmlProtocol *proto = imhtml_find_protocol(text, FALSE); |
|
24674
36bf974a7d78
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24588
diff
changeset
|
2437 | return proto ? proto->length : 0; |
| 8334 | 2438 | } |
| 2439 | ||
|
28940
e0f3781f6397
Fix scrolling bug for very busy chat rooms.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28935
diff
changeset
|
2440 | static gboolean smooth_scroll_cb(gpointer data); |
|
e0f3781f6397
Fix scrolling bug for very busy chat rooms.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28935
diff
changeset
|
2441 | |
| 8677 | 2442 | /* |
| 15884 | 2443 | <KingAnt> marv: The two IM image functions in oscar are purple_odc_send_im and purple_odc_incoming |
| 8677 | 2444 | |
| 2445 | ||
| 2446 | [19:58] <Robot101> marv: images go into the imgstore, a refcounted... well.. hash. :) | |
| 2447 | [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
|
2448 | [19:59] Ro0tSiEgE robert42 RobFlynn Robot101 ross22 roz |
| 15884 | 2449 | [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 | 2450 | [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? |
| 2451 | [20:00] <KingAnt> marv: Right | |
| 2452 | [20:00] <marv> alright | |
| 2453 | ||
| 2454 | Here's my plan with IMImages. make gtk_imhtml_[append|insert]_text_with_images instead just | |
| 2455 | gtkimhtml_[append|insert]_text (hrm maybe it should be called html instead of text), add a | |
| 15884 | 2456 | function for purple to register for look up images, i.e. gtk_imhtml_set_get_img_fnc, so that |
| 8677 | 2457 | images can be looked up like that, instead of passing a GSList of them. |
| 2458 | */ | |
| 2459 | ||
| 2460 | void gtk_imhtml_append_text_with_images (GtkIMHtml *imhtml, | |
| 2461 | const gchar *text, | |
| 2462 | GtkIMHtmlOptions options, | |
| 2463 | GSList *unused) | |
| 1428 | 2464 | { |
| 8677 | 2465 | 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
|
2466 | int ins_offset = 0, sel_offset = 0; |
| 8677 | 2467 | gboolean fixins = FALSE, fixsel = FALSE; |
| 2468 | ||
| 2469 | g_return_if_fail (imhtml != NULL); | |
| 2470 | g_return_if_fail (GTK_IS_IMHTML (imhtml)); | |
| 2471 | g_return_if_fail (text != NULL); | |
| 2472 | ||
| 2473 | ||
| 2474 | gtk_text_buffer_get_end_iter(imhtml->text_buffer, &iter); | |
| 2475 | gtk_text_buffer_get_iter_at_mark(imhtml->text_buffer, &ins, gtk_text_buffer_get_insert(imhtml->text_buffer)); | |
| 2476 | if (gtk_text_iter_equal(&iter, &ins) && gtk_text_buffer_get_selection_bounds(imhtml->text_buffer, NULL, NULL)) { | |
| 2477 | fixins = TRUE; | |
| 2478 | ins_offset = gtk_text_iter_get_offset(&ins); | |
| 2479 | } | |
| 2480 | ||
| 2481 | gtk_text_buffer_get_iter_at_mark(imhtml->text_buffer, &sel, gtk_text_buffer_get_selection_bound(imhtml->text_buffer)); | |
| 2482 | if (gtk_text_iter_equal(&iter, &sel) && gtk_text_buffer_get_selection_bounds(imhtml->text_buffer, NULL, NULL)) { | |
| 2483 | fixsel = TRUE; | |
| 2484 | sel_offset = gtk_text_iter_get_offset(&sel); | |
| 2485 | } | |
| 2486 | ||
|
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
|
2487 | 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
|
2488 | 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
|
2489 | 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
|
2490 | |
|
e1f64090d32e
Do not show tooltips for <HR> or <IMG>s in gtkimhtml. Fixes #5480.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22772
diff
changeset
|
2491 | 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
|
2492 | 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
|
2493 | |
|
e1f64090d32e
Do not show tooltips for <HR> or <IMG>s in gtkimhtml. Fixes #5480.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22772
diff
changeset
|
2494 | 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
|
2495 | gtk_text_buffer_get_char_count(imhtml->text_buffer)) { |
|
28940
e0f3781f6397
Fix scrolling bug for very busy chat rooms.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28935
diff
changeset
|
2496 | /* If we are in the middle of smooth-scrolling, then take a scroll step. |
|
e0f3781f6397
Fix scrolling bug for very busy chat rooms.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28935
diff
changeset
|
2497 | * If we are not in the middle of smooth-scrolling, that means we were |
|
e0f3781f6397
Fix scrolling bug for very busy chat rooms.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28935
diff
changeset
|
2498 | * not looking at the end of the buffer before the new text was added, |
|
e0f3781f6397
Fix scrolling bug for very busy chat rooms.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28935
diff
changeset
|
2499 | * so do not scroll. */ |
|
e0f3781f6397
Fix scrolling bug for very busy chat rooms.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28935
diff
changeset
|
2500 | if (imhtml->scroll_time) |
|
e0f3781f6397
Fix scrolling bug for very busy chat rooms.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28935
diff
changeset
|
2501 | smooth_scroll_cb(imhtml); |
|
e0f3781f6397
Fix scrolling bug for very busy chat rooms.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28935
diff
changeset
|
2502 | else |
|
e0f3781f6397
Fix scrolling bug for very busy chat rooms.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28935
diff
changeset
|
2503 | options |= GTK_IMHTML_NO_SCROLL; |
|
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
|
2504 | } |
| 8677 | 2505 | } |
| 2506 | ||
| 2507 | gtk_imhtml_insert_html_at_iter(imhtml, text, options, &iter); | |
| 2508 | ||
| 2509 | if (fixins) { | |
| 2510 | gtk_text_buffer_get_iter_at_offset(imhtml->text_buffer, &ins, ins_offset); | |
| 2511 | gtk_text_buffer_move_mark(imhtml->text_buffer, gtk_text_buffer_get_insert(imhtml->text_buffer), &ins); | |
| 2512 | } | |
| 2513 | ||
| 2514 | if (fixsel) { | |
| 2515 | gtk_text_buffer_get_iter_at_offset(imhtml->text_buffer, &sel, sel_offset); | |
| 2516 | gtk_text_buffer_move_mark(imhtml->text_buffer, gtk_text_buffer_get_selection_bound(imhtml->text_buffer), &sel); | |
| 2517 | } | |
| 2518 | ||
| 2519 | if (!(options & GTK_IMHTML_NO_SCROLL)) { | |
| 12553 | 2520 | gtk_imhtml_scroll_to_end(imhtml, (options & GTK_IMHTML_USE_SMOOTHSCROLLING)); |
| 8677 | 2521 | } |
| 2522 | } | |
| 2523 | ||
| 11006 | 2524 | #define MAX_SCROLL_TIME 0.4 /* seconds */ |
| 2525 | #define SCROLL_DELAY 33 /* milliseconds */ | |
| 2526 | ||
| 2527 | /* | |
| 2528 | * Smoothly scroll a GtkIMHtml. | |
| 2529 | * | |
| 2530 | * @return TRUE if the window needs to be scrolled further, FALSE if we're at the bottom. | |
| 2531 | */ | |
|
28940
e0f3781f6397
Fix scrolling bug for very busy chat rooms.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28935
diff
changeset
|
2532 | static gboolean smooth_scroll_cb(gpointer data) |
| 10798 | 2533 | { |
| 2534 | GtkIMHtml *imhtml = data; | |
| 2535 | GtkAdjustment *adj = GTK_TEXT_VIEW(imhtml)->vadjustment; | |
| 11006 | 2536 | gdouble max_val = adj->upper - adj->page_size; |
|
19055
43f5771c45f4
Eliminate some unnecessary scrolling activity.
Daniel Atallah <datallah@pidgin.im>
parents:
18985
diff
changeset
|
2537 | gdouble scroll_val = gtk_adjustment_get_value(adj) + ((max_val - gtk_adjustment_get_value(adj)) / 3); |
| 11006 | 2538 | |
| 2539 | g_return_val_if_fail(imhtml->scroll_time != NULL, FALSE); | |
| 2540 | ||
|
19055
43f5771c45f4
Eliminate some unnecessary scrolling activity.
Daniel Atallah <datallah@pidgin.im>
parents:
18985
diff
changeset
|
2541 | if (g_timer_elapsed(imhtml->scroll_time, NULL) > MAX_SCROLL_TIME || scroll_val >= max_val) { |
| 11006 | 2542 | /* time's up. jump to the end and kill the timer */ |
| 2543 | gtk_adjustment_set_value(adj, max_val); | |
| 10798 | 2544 | g_timer_destroy(imhtml->scroll_time); |
| 2545 | imhtml->scroll_time = NULL; | |
|
28940
e0f3781f6397
Fix scrolling bug for very busy chat rooms.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28935
diff
changeset
|
2546 | g_source_remove(imhtml->scroll_src); |
|
e0f3781f6397
Fix scrolling bug for very busy chat rooms.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28935
diff
changeset
|
2547 | imhtml->scroll_src = 0; |
| 10798 | 2548 | return FALSE; |
| 11006 | 2549 | } |
| 2550 | ||
| 2551 | /* scroll by 1/3rd the remaining distance */ | |
|
19055
43f5771c45f4
Eliminate some unnecessary scrolling activity.
Daniel Atallah <datallah@pidgin.im>
parents:
18985
diff
changeset
|
2552 | gtk_adjustment_set_value(adj, scroll_val); |
| 11006 | 2553 | return TRUE; |
| 10798 | 2554 | } |
| 2555 | ||
| 12553 | 2556 | static gboolean scroll_idle_cb(gpointer data) |
| 2557 | { | |
| 2558 | GtkIMHtml *imhtml = data; | |
| 2559 | GtkAdjustment *adj = GTK_TEXT_VIEW(imhtml)->vadjustment; | |
| 2560 | if(adj) { | |
| 2561 | gtk_adjustment_set_value(adj, adj->upper - adj->page_size); | |
| 2562 | } | |
| 2563 | imhtml->scroll_src = 0; | |
| 2564 | return FALSE; | |
| 2565 | } | |
| 2566 | ||
| 2567 | void gtk_imhtml_scroll_to_end(GtkIMHtml *imhtml, gboolean smooth) | |
| 8729 | 2568 | { |
| 10798 | 2569 | if (imhtml->scroll_time) |
| 2570 | g_timer_destroy(imhtml->scroll_time); | |
| 2571 | if (imhtml->scroll_src) | |
| 2572 | g_source_remove(imhtml->scroll_src); | |
| 12553 | 2573 | if(smooth) { |
| 2574 | imhtml->scroll_time = g_timer_new(); | |
|
28940
e0f3781f6397
Fix scrolling bug for very busy chat rooms.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28935
diff
changeset
|
2575 | imhtml->scroll_src = g_timeout_add_full(G_PRIORITY_LOW, SCROLL_DELAY, smooth_scroll_cb, imhtml, NULL); |
| 12553 | 2576 | } else { |
| 2577 | imhtml->scroll_time = NULL; | |
| 2578 | imhtml->scroll_src = g_idle_add_full(G_PRIORITY_LOW, scroll_idle_cb, imhtml, NULL); | |
| 2579 | } | |
| 8729 | 2580 | } |
| 2581 | ||
|
24509
afdf30801940
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <datallah@pidgin.im>
parents:
24392
diff
changeset
|
2582 | /* 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
|
2583 | * 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
|
2584 | static gchar* |
|
afdf30801940
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <datallah@pidgin.im>
parents:
24392
diff
changeset
|
2585 | 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
|
2586 | { |
|
afdf30801940
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <datallah@pidgin.im>
parents:
24392
diff
changeset
|
2587 | 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
|
2588 | |
|
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
|
2589 | 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
|
2590 | 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
|
2591 | int count = 0; |
|
afdf30801940
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <datallah@pidgin.im>
parents:
24392
diff
changeset
|
2592 | 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
|
2593 | |
|
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
|
2594 | 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
|
2595 | 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
|
2596 | 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
|
2597 | /* 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
|
2598 | 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
|
2599 | 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
|
2600 | } |
|
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
|
2601 | 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
|
2602 | |
|
24509
afdf30801940
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <datallah@pidgin.im>
parents:
24392
diff
changeset
|
2603 | while (count < 3) { |
|
afdf30801940
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <datallah@pidgin.im>
parents:
24392
diff
changeset
|
2604 | /* 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
|
2605 | 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
|
2606 | tmp++; |
|
afdf30801940
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <datallah@pidgin.im>
parents:
24392
diff
changeset
|
2607 | |
|
afdf30801940
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <datallah@pidgin.im>
parents:
24392
diff
changeset
|
2608 | /* 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
|
2609 | 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
|
2610 | 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
|
2611 | tmp++; |
|
24509
afdf30801940
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <datallah@pidgin.im>
parents:
24392
diff
changeset
|
2612 | 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
|
2613 | tmp++; |
|
afdf30801940
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <datallah@pidgin.im>
parents:
24392
diff
changeset
|
2614 | |
|
afdf30801940
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <datallah@pidgin.im>
parents:
24392
diff
changeset
|
2615 | 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
|
2616 | char prev = *tmp; |
|
afdf30801940
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <datallah@pidgin.im>
parents:
24392
diff
changeset
|
2617 | *tmp = '\0'; |
|
afdf30801940
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <datallah@pidgin.im>
parents:
24392
diff
changeset
|
2618 | 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
|
2619 | *tmp = prev; |
|
afdf30801940
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <datallah@pidgin.im>
parents:
24392
diff
changeset
|
2620 | |
|
afdf30801940
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <datallah@pidgin.im>
parents:
24392
diff
changeset
|
2621 | /* deal with % */ |
|
afdf30801940
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <datallah@pidgin.im>
parents:
24392
diff
changeset
|
2622 | 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
|
2623 | tmp++; |
|
afdf30801940
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <datallah@pidgin.im>
parents:
24392
diff
changeset
|
2624 | if (*tmp == '%') { |
|
afdf30801940
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <datallah@pidgin.im>
parents:
24392
diff
changeset
|
2625 | 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
|
2626 | tmp++; |
|
afdf30801940
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <datallah@pidgin.im>
parents:
24392
diff
changeset
|
2627 | } |
|
afdf30801940
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <datallah@pidgin.im>
parents:
24392
diff
changeset
|
2628 | } else { |
|
afdf30801940
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <datallah@pidgin.im>
parents:
24392
diff
changeset
|
2629 | 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
|
2630 | return in_color; |
|
afdf30801940
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <datallah@pidgin.im>
parents:
24392
diff
changeset
|
2631 | } |
|
afdf30801940
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <datallah@pidgin.im>
parents:
24392
diff
changeset
|
2632 | |
|
afdf30801940
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <datallah@pidgin.im>
parents:
24392
diff
changeset
|
2633 | 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
|
2634 | rgbval[count] = 255; |
|
afdf30801940
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <datallah@pidgin.im>
parents:
24392
diff
changeset
|
2635 | } 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
|
2636 | rgbval[count] = 0; |
|
afdf30801940
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <datallah@pidgin.im>
parents:
24392
diff
changeset
|
2637 | } |
|
afdf30801940
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <datallah@pidgin.im>
parents:
24392
diff
changeset
|
2638 | |
|
afdf30801940
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <datallah@pidgin.im>
parents:
24392
diff
changeset
|
2639 | 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
|
2640 | tmp++; |
|
afdf30801940
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <datallah@pidgin.im>
parents:
24392
diff
changeset
|
2641 | if (*tmp == ',') |
|
afdf30801940
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <datallah@pidgin.im>
parents:
24392
diff
changeset
|
2642 | tmp++; |
|
afdf30801940
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <datallah@pidgin.im>
parents:
24392
diff
changeset
|
2643 | |
|
afdf30801940
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <datallah@pidgin.im>
parents:
24392
diff
changeset
|
2644 | count++; |
|
afdf30801940
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <datallah@pidgin.im>
parents:
24392
diff
changeset
|
2645 | } |
|
25888
d0fdd378a635
Remove trailing whitespace
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
2646 | |
|
24509
afdf30801940
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <datallah@pidgin.im>
parents:
24392
diff
changeset
|
2647 | 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
|
2648 | 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
|
2649 | } |
|
afdf30801940
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <datallah@pidgin.im>
parents:
24392
diff
changeset
|
2650 | |
|
afdf30801940
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <datallah@pidgin.im>
parents:
24392
diff
changeset
|
2651 | return in_color; |
|
afdf30801940
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <datallah@pidgin.im>
parents:
24392
diff
changeset
|
2652 | } |
|
afdf30801940
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <datallah@pidgin.im>
parents:
24392
diff
changeset
|
2653 | |
| 8677 | 2654 | void gtk_imhtml_insert_html_at_iter(GtkIMHtml *imhtml, |
| 2655 | const gchar *text, | |
| 2656 | GtkIMHtmlOptions options, | |
| 2657 | GtkTextIter *iter) | |
| 2658 | { | |
| 8061 | 2659 | GdkRectangle rect; |
|
2856
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2660 | gint pos = 0; |
| 3922 | 2661 | gchar *ws; |
|
2856
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2662 | gchar *tag; |
| 3922 | 2663 | gchar *bg = NULL; |
|
6982
12f08de92674
[gaim-migrate @ 7538]
Mark Doliner <markdoliner@pidgin.im>
parents:
6882
diff
changeset
|
2664 | gint len; |
| 4032 | 2665 | gint tlen, smilelen, wpos=0; |
|
2856
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2666 | gint type; |
| 3922 | 2667 | const gchar *c; |
|
16143
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
2668 | const gchar *amp; |
| 8334 | 2669 | gint len_protocol; |
| 15379 | 2670 | |
| 1428 | 2671 | guint bold = 0, |
| 2672 | italics = 0, | |
| 2673 | underline = 0, | |
| 2674 | strike = 0, | |
| 2675 | sub = 0, | |
| 2676 | sup = 0, | |
|
1691
c8bd41036372
[gaim-migrate @ 1701]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
1647
diff
changeset
|
2677 | title = 0, |
| 8061 | 2678 | pre = 0; |
| 1428 | 2679 | |
| 10217 | 2680 | gboolean br = FALSE; |
|
16143
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
2681 | gboolean align_right = FALSE; |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
2682 | gboolean rtl_direction = FALSE; |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
2683 | gint align_line = 0; |
| 15420 | 2684 | |
| 3922 | 2685 | GSList *fonts = NULL; |
| 8506 | 2686 | GObject *object; |
| 8061 | 2687 | GtkIMHtmlScalable *scalable = NULL; |
| 8677 | 2688 | |
| 2689 | g_return_if_fail (imhtml != NULL); | |
| 2690 | g_return_if_fail (GTK_IS_IMHTML (imhtml)); | |
| 2691 | g_return_if_fail (text != NULL); | |
| 3922 | 2692 | c = text; |
|
6982
12f08de92674
[gaim-migrate @ 7538]
Mark Doliner <markdoliner@pidgin.im>
parents:
6882
diff
changeset
|
2693 | len = strlen(text); |
| 3922 | 2694 | ws = g_malloc(len + 1); |
|
25007
ef8bc1f4a6ba
Pass only the URL scheme to gtkimhtml and let it add the colon automatically.
Richard Laager <rlaager@pidgin.im>
parents:
24698
diff
changeset
|
2695 | ws[0] = '\0'; |
| 1428 | 2696 | |
|
29378
a783b23a05da
Fix CVE-2010-0423, a denial of service attack due to the parsing
Mark Doliner <markdoliner@pidgin.im>
parents:
29371
diff
changeset
|
2697 | g_object_set_data(G_OBJECT(imhtml), "gtkimhtml_numsmileys_thismsg", GINT_TO_POINTER(0)); |
|
a783b23a05da
Fix CVE-2010-0423, a denial of service attack due to the parsing
Mark Doliner <markdoliner@pidgin.im>
parents:
29371
diff
changeset
|
2698 | |
|
22834
1394e7efb818
Smiley insertions can be undone with this fix. References #5577. But redo
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22810
diff
changeset
|
2699 | gtk_text_buffer_begin_user_action(imhtml->text_buffer); |
|
2856
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2700 | while (pos < len) { |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2701 | if (*c == '<' && gtk_imhtml_is_tag (c + 1, &tag, &tlen, &type)) { |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2702 | c++; |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2703 | pos++; |
| 8061 | 2704 | ws[wpos] = '\0'; |
| 10217 | 2705 | br = FALSE; |
| 8061 | 2706 | switch (type) |
| 3922 | 2707 | { |
| 2708 | case 1: /* B */ | |
| 2709 | case 2: /* BOLD */ | |
| 5101 | 2710 | case 54: /* STRONG */ |
|
11485
fe334b13d1d0
[gaim-migrate @ 13727]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11385
diff
changeset
|
2711 | if (!(options & GTK_IMHTML_NO_FORMATTING)) { |
|
fe334b13d1d0
[gaim-migrate @ 13727]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11385
diff
changeset
|
2712 | gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos); |
|
fe334b13d1d0
[gaim-migrate @ 13727]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11385
diff
changeset
|
2713 | |
|
fe334b13d1d0
[gaim-migrate @ 13727]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11385
diff
changeset
|
2714 | if ((bold == 0) && (imhtml->format_functions & GTK_IMHTML_BOLD)) |
|
fe334b13d1d0
[gaim-migrate @ 13727]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11385
diff
changeset
|
2715 | gtk_imhtml_toggle_bold(imhtml); |
|
fe334b13d1d0
[gaim-migrate @ 13727]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11385
diff
changeset
|
2716 | bold++; |
|
fe334b13d1d0
[gaim-migrate @ 13727]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11385
diff
changeset
|
2717 | ws[0] = '\0'; wpos = 0; |
|
fe334b13d1d0
[gaim-migrate @ 13727]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11385
diff
changeset
|
2718 | } |
| 3922 | 2719 | break; |
| 2720 | case 3: /* /B */ | |
| 2721 | case 4: /* /BOLD */ | |
| 5101 | 2722 | case 55: /* /STRONG */ |
|
11485
fe334b13d1d0
[gaim-migrate @ 13727]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11385
diff
changeset
|
2723 | if (!(options & GTK_IMHTML_NO_FORMATTING)) { |
|
fe334b13d1d0
[gaim-migrate @ 13727]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11385
diff
changeset
|
2724 | gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos); |
|
fe334b13d1d0
[gaim-migrate @ 13727]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11385
diff
changeset
|
2725 | ws[0] = '\0'; wpos = 0; |
|
fe334b13d1d0
[gaim-migrate @ 13727]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11385
diff
changeset
|
2726 | |
|
14010
a47143a57c82
[gaim-migrate @ 16489]
Gary Kramlich <grim@reaperworld.com>
parents:
13552
diff
changeset
|
2727 | if (bold) { |
|
11485
fe334b13d1d0
[gaim-migrate @ 13727]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11385
diff
changeset
|
2728 | bold--; |
|
14010
a47143a57c82
[gaim-migrate @ 16489]
Gary Kramlich <grim@reaperworld.com>
parents:
13552
diff
changeset
|
2729 | if ((bold == 0) && (imhtml->format_functions & GTK_IMHTML_BOLD) && !imhtml->wbfo) |
|
a47143a57c82
[gaim-migrate @ 16489]
Gary Kramlich <grim@reaperworld.com>
parents:
13552
diff
changeset
|
2730 | gtk_imhtml_toggle_bold(imhtml); |
|
a47143a57c82
[gaim-migrate @ 16489]
Gary Kramlich <grim@reaperworld.com>
parents:
13552
diff
changeset
|
2731 | } |
|
11485
fe334b13d1d0
[gaim-migrate @ 13727]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11385
diff
changeset
|
2732 | } |
| 3922 | 2733 | break; |
| 2734 | case 5: /* I */ | |
| 2735 | case 6: /* ITALIC */ | |
| 5101 | 2736 | case 52: /* EM */ |
|
11485
fe334b13d1d0
[gaim-migrate @ 13727]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11385
diff
changeset
|
2737 | if (!(options & GTK_IMHTML_NO_FORMATTING)) { |
|
fe334b13d1d0
[gaim-migrate @ 13727]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11385
diff
changeset
|
2738 | gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos); |
|
fe334b13d1d0
[gaim-migrate @ 13727]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11385
diff
changeset
|
2739 | ws[0] = '\0'; wpos = 0; |
|
fe334b13d1d0
[gaim-migrate @ 13727]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11385
diff
changeset
|
2740 | if ((italics == 0) && (imhtml->format_functions & GTK_IMHTML_ITALIC)) |
|
fe334b13d1d0
[gaim-migrate @ 13727]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11385
diff
changeset
|
2741 | gtk_imhtml_toggle_italic(imhtml); |
|
fe334b13d1d0
[gaim-migrate @ 13727]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11385
diff
changeset
|
2742 | italics++; |
|
fe334b13d1d0
[gaim-migrate @ 13727]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11385
diff
changeset
|
2743 | } |
| 3922 | 2744 | break; |
| 2745 | case 7: /* /I */ | |
| 2746 | case 8: /* /ITALIC */ | |
| 5101 | 2747 | case 53: /* /EM */ |
|
11485
fe334b13d1d0
[gaim-migrate @ 13727]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11385
diff
changeset
|
2748 | if (!(options & GTK_IMHTML_NO_FORMATTING)) { |
|
fe334b13d1d0
[gaim-migrate @ 13727]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11385
diff
changeset
|
2749 | gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos); |
|
fe334b13d1d0
[gaim-migrate @ 13727]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11385
diff
changeset
|
2750 | ws[0] = '\0'; wpos = 0; |
|
14010
a47143a57c82
[gaim-migrate @ 16489]
Gary Kramlich <grim@reaperworld.com>
parents:
13552
diff
changeset
|
2751 | if (italics) { |
|
11485
fe334b13d1d0
[gaim-migrate @ 13727]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11385
diff
changeset
|
2752 | italics--; |
|
14010
a47143a57c82
[gaim-migrate @ 16489]
Gary Kramlich <grim@reaperworld.com>
parents:
13552
diff
changeset
|
2753 | if ((italics == 0) && (imhtml->format_functions & GTK_IMHTML_ITALIC) && !imhtml->wbfo) |
|
a47143a57c82
[gaim-migrate @ 16489]
Gary Kramlich <grim@reaperworld.com>
parents:
13552
diff
changeset
|
2754 | gtk_imhtml_toggle_italic(imhtml); |
|
a47143a57c82
[gaim-migrate @ 16489]
Gary Kramlich <grim@reaperworld.com>
parents:
13552
diff
changeset
|
2755 | } |
|
11485
fe334b13d1d0
[gaim-migrate @ 13727]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11385
diff
changeset
|
2756 | } |
| 3922 | 2757 | break; |
| 2758 | case 9: /* U */ | |
| 2759 | case 10: /* UNDERLINE */ | |
|
11485
fe334b13d1d0
[gaim-migrate @ 13727]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11385
diff
changeset
|
2760 | if (!(options & GTK_IMHTML_NO_FORMATTING)) { |
|
fe334b13d1d0
[gaim-migrate @ 13727]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11385
diff
changeset
|
2761 | gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos); |
|
fe334b13d1d0
[gaim-migrate @ 13727]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11385
diff
changeset
|
2762 | ws[0] = '\0'; wpos = 0; |
|
fe334b13d1d0
[gaim-migrate @ 13727]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11385
diff
changeset
|
2763 | if ((underline == 0) && (imhtml->format_functions & GTK_IMHTML_UNDERLINE)) |
|
fe334b13d1d0
[gaim-migrate @ 13727]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11385
diff
changeset
|
2764 | gtk_imhtml_toggle_underline(imhtml); |
|
fe334b13d1d0
[gaim-migrate @ 13727]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11385
diff
changeset
|
2765 | underline++; |
|
fe334b13d1d0
[gaim-migrate @ 13727]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11385
diff
changeset
|
2766 | } |
| 3922 | 2767 | break; |
| 2768 | case 11: /* /U */ | |
| 2769 | case 12: /* /UNDERLINE */ | |
|
11485
fe334b13d1d0
[gaim-migrate @ 13727]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11385
diff
changeset
|
2770 | if (!(options & GTK_IMHTML_NO_FORMATTING)) { |
|
fe334b13d1d0
[gaim-migrate @ 13727]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11385
diff
changeset
|
2771 | gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos); |
|
fe334b13d1d0
[gaim-migrate @ 13727]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11385
diff
changeset
|
2772 | ws[0] = '\0'; wpos = 0; |
|
14010
a47143a57c82
[gaim-migrate @ 16489]
Gary Kramlich <grim@reaperworld.com>
parents:
13552
diff
changeset
|
2773 | if (underline) { |
|
11485
fe334b13d1d0
[gaim-migrate @ 13727]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11385
diff
changeset
|
2774 | underline--; |
|
14010
a47143a57c82
[gaim-migrate @ 16489]
Gary Kramlich <grim@reaperworld.com>
parents:
13552
diff
changeset
|
2775 | if ((underline == 0) && (imhtml->format_functions & GTK_IMHTML_UNDERLINE) && !imhtml->wbfo) |
|
a47143a57c82
[gaim-migrate @ 16489]
Gary Kramlich <grim@reaperworld.com>
parents:
13552
diff
changeset
|
2776 | gtk_imhtml_toggle_underline(imhtml); |
|
a47143a57c82
[gaim-migrate @ 16489]
Gary Kramlich <grim@reaperworld.com>
parents:
13552
diff
changeset
|
2777 | } |
|
11485
fe334b13d1d0
[gaim-migrate @ 13727]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11385
diff
changeset
|
2778 | } |
| 3922 | 2779 | break; |
| 2780 | case 13: /* S */ | |
| 2781 | case 14: /* STRIKE */ | |
| 9924 | 2782 | gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos); |
| 2783 | ws[0] = '\0'; wpos = 0; | |
| 2784 | if ((strike == 0) && (imhtml->format_functions & GTK_IMHTML_STRIKE)) | |
| 2785 | gtk_imhtml_toggle_strike(imhtml); | |
| 3922 | 2786 | strike++; |
| 2787 | break; | |
| 2788 | case 15: /* /S */ | |
| 2789 | case 16: /* /STRIKE */ | |
| 9924 | 2790 | gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos); |
| 2791 | ws[0] = '\0'; wpos = 0; | |
| 3922 | 2792 | if (strike) |
| 2793 | strike--; | |
| 9924 | 2794 | if ((strike == 0) && (imhtml->format_functions & GTK_IMHTML_STRIKE) && !imhtml->wbfo) |
| 2795 | gtk_imhtml_toggle_strike(imhtml); | |
| 3922 | 2796 | break; |
| 2797 | case 17: /* SUB */ | |
| 8677 | 2798 | /* FIXME: reimpliment this */ |
| 3922 | 2799 | sub++; |
| 2800 | break; | |
| 2801 | case 18: /* /SUB */ | |
| 8677 | 2802 | /* FIXME: reimpliment this */ |
| 3922 | 2803 | if (sub) |
| 2804 | sub--; | |
| 2805 | break; | |
| 2806 | case 19: /* SUP */ | |
| 8677 | 2807 | /* FIXME: reimplement this */ |
| 3922 | 2808 | sup++; |
|
2856
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2809 | break; |
| 3922 | 2810 | case 20: /* /SUP */ |
| 8677 | 2811 | /* FIXME: reimplement this */ |
| 3922 | 2812 | if (sup) |
| 2813 | sup--; | |
| 2814 | break; | |
| 2815 | case 21: /* PRE */ | |
| 8677 | 2816 | /* FIXME: reimplement this */ |
| 3922 | 2817 | pre++; |
| 2818 | break; | |
| 2819 | case 22: /* /PRE */ | |
| 8677 | 2820 | /* FIXME: reimplement this */ |
| 3922 | 2821 | if (pre) |
| 2822 | pre--; | |
| 2823 | break; | |
| 2824 | case 23: /* TITLE */ | |
| 8677 | 2825 | /* FIXME: what was this supposed to do anyway? */ |
| 3922 | 2826 | title++; |
| 2827 | break; | |
| 2828 | case 24: /* /TITLE */ | |
| 8677 | 2829 | /* FIXME: make this undo whatever 23 was supposed to do */ |
| 3922 | 2830 | if (title) { |
| 2831 | if (options & GTK_IMHTML_NO_TITLE) { | |
| 2832 | wpos = 0; | |
| 2833 | ws [wpos] = '\0'; | |
| 2834 | } | |
| 2835 | title--; | |
|
2856
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2836 | } |
| 3922 | 2837 | break; |
| 2838 | case 25: /* BR */ | |
| 5174 | 2839 | case 58: /* BR/ */ |
| 8061 | 2840 | case 61: /* BR (opt) */ |
| 3922 | 2841 | ws[wpos] = '\n'; |
| 2842 | wpos++; | |
| 10217 | 2843 | br = TRUE; |
|
6982
12f08de92674
[gaim-migrate @ 7538]
Mark Doliner <markdoliner@pidgin.im>
parents:
6882
diff
changeset
|
2844 | break; |
| 3922 | 2845 | case 26: /* HR */ |
| 2846 | case 42: /* HR (opt) */ | |
| 8726 | 2847 | { |
| 2848 | int minus; | |
|
11224
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
2849 | struct scalable_data *sd = g_new(struct scalable_data, 1); |
| 8726 | 2850 | |
| 3922 | 2851 | ws[wpos++] = '\n'; |
| 8677 | 2852 | gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos); |
| 2853 | ||
|
11224
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
2854 | sd->scalable = scalable = gtk_imhtml_hr_new(); |
|
11233
28c0f184a2d4
[gaim-migrate @ 13373]
Daniel Atallah <datallah@pidgin.im>
parents:
11224
diff
changeset
|
2855 | sd->mark = gtk_text_buffer_create_mark(imhtml->text_buffer, NULL, iter, TRUE); |
| 8061 | 2856 | gtk_text_view_get_visible_rect(GTK_TEXT_VIEW(imhtml), &rect); |
| 8677 | 2857 | scalable->add_to(scalable, imhtml, iter); |
| 8726 | 2858 | minus = gtk_text_view_get_left_margin(GTK_TEXT_VIEW(imhtml)) + |
| 2859 | gtk_text_view_get_right_margin(GTK_TEXT_VIEW(imhtml)); | |
| 2860 | scalable->scale(scalable, rect.width - minus, rect.height); | |
|
11224
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
2861 | imhtml->scalables = g_list_append(imhtml->scalables, sd); |
| 8061 | 2862 | ws[0] = '\0'; wpos = 0; |
| 7942 | 2863 | ws[wpos++] = '\n'; |
| 8061 | 2864 | |
| 3922 | 2865 | break; |
| 8726 | 2866 | } |
| 3922 | 2867 | case 27: /* /FONT */ |
| 8677 | 2868 | if (fonts && !imhtml->wbfo) { |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
2869 | GtkIMHtmlFontDetail *font = fonts->data; |
| 8677 | 2870 | gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos); |
| 8061 | 2871 | ws[0] = '\0'; wpos = 0; |
|
8177
33b3a01c6318
[gaim-migrate @ 8891]
Mark Doliner <markdoliner@pidgin.im>
parents:
8149
diff
changeset
|
2872 | /* NEW_BIT (NEW_TEXT_BIT); */ |
| 8677 | 2873 | |
| 8698 | 2874 | if (font->face && (imhtml->format_functions & GTK_IMHTML_FACE)) { |
| 8061 | 2875 | gtk_imhtml_toggle_fontface(imhtml, NULL); |
| 2876 | } | |
|
14821
c91127e2b784
[gaim-migrate @ 17516]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14741
diff
changeset
|
2877 | g_free (font->face); |
| 8698 | 2878 | if (font->fore && (imhtml->format_functions & GTK_IMHTML_FORECOLOR)) { |
| 8061 | 2879 | gtk_imhtml_toggle_forecolor(imhtml, NULL); |
| 2880 | } | |
|
14821
c91127e2b784
[gaim-migrate @ 17516]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14741
diff
changeset
|
2881 | g_free (font->fore); |
| 8698 | 2882 | if (font->back && (imhtml->format_functions & GTK_IMHTML_BACKCOLOR)) { |
| 8061 | 2883 | gtk_imhtml_toggle_backcolor(imhtml, NULL); |
| 2884 | } | |
|
14821
c91127e2b784
[gaim-migrate @ 17516]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14741
diff
changeset
|
2885 | g_free (font->back); |
|
c91127e2b784
[gaim-migrate @ 17516]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14741
diff
changeset
|
2886 | g_free (font->sml); |
| 8309 | 2887 | |
| 8698 | 2888 | if ((font->size != 3) && (imhtml->format_functions & (GTK_IMHTML_GROW|GTK_IMHTML_SHRINK))) |
| 8309 | 2889 | gtk_imhtml_font_set_size(imhtml, 3); |
| 2890 | ||
| 10761 | 2891 | fonts = g_slist_remove (fonts, font); |
| 9245 | 2892 | g_free(font); |
| 2893 | ||
| 8309 | 2894 | if (fonts) { |
| 2895 | GtkIMHtmlFontDetail *font = fonts->data; | |
| 8677 | 2896 | |
| 8698 | 2897 | if (font->face && (imhtml->format_functions & GTK_IMHTML_FACE)) |
| 8309 | 2898 | gtk_imhtml_toggle_fontface(imhtml, font->face); |
| 8698 | 2899 | if (font->fore && (imhtml->format_functions & GTK_IMHTML_FORECOLOR)) |
| 8309 | 2900 | gtk_imhtml_toggle_forecolor(imhtml, font->fore); |
| 8698 | 2901 | if (font->back && (imhtml->format_functions & GTK_IMHTML_BACKCOLOR)) |
| 8309 | 2902 | gtk_imhtml_toggle_backcolor(imhtml, font->back); |
| 8698 | 2903 | if ((font->size != 3) && (imhtml->format_functions & (GTK_IMHTML_GROW|GTK_IMHTML_SHRINK))) |
| 8309 | 2904 | gtk_imhtml_font_set_size(imhtml, font->size); |
| 2905 | } | |
| 3922 | 2906 | } |
| 8309 | 2907 | break; |
| 3922 | 2908 | case 28: /* /A */ |
| 8677 | 2909 | gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos); |
| 2910 | gtk_imhtml_toggle_link(imhtml, NULL); | |
| 2911 | ws[0] = '\0'; wpos = 0; | |
| 8061 | 2912 | break; |
|
8118
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
2913 | |
| 3922 | 2914 | case 29: /* P */ |
| 2915 | case 30: /* /P */ | |
| 2916 | case 31: /* H3 */ | |
| 2917 | case 32: /* /H3 */ | |
| 2918 | case 33: /* HTML */ | |
| 2919 | case 34: /* /HTML */ | |
| 2920 | case 35: /* BODY */ | |
| 10776 | 2921 | break; |
| 3922 | 2922 | case 36: /* /BODY */ |
| 10786 | 2923 | gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos); |
| 2924 | ws[0] = '\0'; wpos = 0; | |
| 10776 | 2925 | gtk_imhtml_toggle_background(imhtml, NULL); |
| 2926 | break; | |
| 3922 | 2927 | case 37: /* FONT */ |
| 2928 | case 38: /* HEAD */ | |
| 2929 | case 39: /* /HEAD */ | |
|
6982
12f08de92674
[gaim-migrate @ 7538]
Mark Doliner <markdoliner@pidgin.im>
parents:
6882
diff
changeset
|
2930 | case 40: /* BINARY */ |
|
12f08de92674
[gaim-migrate @ 7538]
Mark Doliner <markdoliner@pidgin.im>
parents:
6882
diff
changeset
|
2931 | case 41: /* /BINARY */ |
| 3922 | 2932 | break; |
| 2933 | case 43: /* FONT (opt) */ | |
| 2934 | { | |
| 4032 | 2935 | gchar *color, *back, *face, *size, *sml; |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
2936 | GtkIMHtmlFontDetail *font, *oldfont = NULL; |
| 3922 | 2937 | color = gtk_imhtml_get_html_opt (tag, "COLOR="); |
| 2938 | back = gtk_imhtml_get_html_opt (tag, "BACK="); | |
| 2939 | face = gtk_imhtml_get_html_opt (tag, "FACE="); | |
| 2940 | size = gtk_imhtml_get_html_opt (tag, "SIZE="); | |
| 4032 | 2941 | sml = gtk_imhtml_get_html_opt (tag, "SML="); |
| 2942 | if (!(color || back || face || size || sml)) | |
| 3922 | 2943 | break; |
| 8061 | 2944 | |
| 8677 | 2945 | gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos); |
| 8061 | 2946 | ws[0] = '\0'; wpos = 0; |
| 2947 | ||
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
2948 | font = g_new0 (GtkIMHtmlFontDetail, 1); |
| 3922 | 2949 | if (fonts) |
| 2950 | oldfont = fonts->data; | |
|
2856
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2951 | |
| 8677 | 2952 | if (color && !(options & GTK_IMHTML_NO_COLOURS) && (imhtml->format_functions & GTK_IMHTML_FORECOLOR)) { |
| 3922 | 2953 | font->fore = color; |
| 8061 | 2954 | gtk_imhtml_toggle_forecolor(imhtml, font->fore); |
|
14821
c91127e2b784
[gaim-migrate @ 17516]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14741
diff
changeset
|
2955 | } else |
|
c91127e2b784
[gaim-migrate @ 17516]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14741
diff
changeset
|
2956 | g_free(color); |
| 8677 | 2957 | |
| 2958 | if (back && !(options & GTK_IMHTML_NO_COLOURS) && (imhtml->format_functions & GTK_IMHTML_BACKCOLOR)) { | |
| 3922 | 2959 | font->back = back; |
| 8061 | 2960 | gtk_imhtml_toggle_backcolor(imhtml, font->back); |
|
14821
c91127e2b784
[gaim-migrate @ 17516]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14741
diff
changeset
|
2961 | } else |
|
c91127e2b784
[gaim-migrate @ 17516]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14741
diff
changeset
|
2962 | g_free(back); |
| 8677 | 2963 | |
| 2964 | if (face && !(options & GTK_IMHTML_NO_FONTS) && (imhtml->format_functions & GTK_IMHTML_FACE)) { | |
| 3922 | 2965 | font->face = face; |
| 8061 | 2966 | gtk_imhtml_toggle_fontface(imhtml, font->face); |
|
14821
c91127e2b784
[gaim-migrate @ 17516]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14741
diff
changeset
|
2967 | } else |
|
c91127e2b784
[gaim-migrate @ 17516]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14741
diff
changeset
|
2968 | g_free(face); |
| 4032 | 2969 | |
| 2970 | if (sml) | |
| 2971 | 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
|
2972 | 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
|
2973 | 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
|
2974 | 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
|
2975 | 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
|
2976 | } |
| 4032 | 2977 | |
| 8677 | 2978 | if (size && !(options & GTK_IMHTML_NO_SIZES) && (imhtml->format_functions & (GTK_IMHTML_GROW|GTK_IMHTML_SHRINK))) { |
| 3922 | 2979 | if (*size == '+') { |
| 2980 | sscanf (size + 1, "%hd", &font->size); | |
| 2981 | font->size += 3; | |
| 2982 | } else if (*size == '-') { | |
| 2983 | sscanf (size + 1, "%hd", &font->size); | |
| 2984 | font->size = MAX (0, 3 - font->size); | |
| 2985 | } else if (isdigit (*size)) { | |
| 2986 | sscanf (size, "%hd", &font->size); | |
|
14821
c91127e2b784
[gaim-migrate @ 17516]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14741
diff
changeset
|
2987 | } |
|
6042
e329fe962c9a
[gaim-migrate @ 6492]
Mark Doliner <markdoliner@pidgin.im>
parents:
5967
diff
changeset
|
2988 | if (font->size > 100) |
|
e329fe962c9a
[gaim-migrate @ 6492]
Mark Doliner <markdoliner@pidgin.im>
parents:
5967
diff
changeset
|
2989 | font->size = 100; |
| 3922 | 2990 | } else if (oldfont) |
| 2991 | font->size = oldfont->size; | |
| 8309 | 2992 | else |
| 2993 | font->size = 3; | |
|
28144
fd25bc3ab207
imhtml: When inserting html, only set a font if it's a change from the default. Fixes #7648.
Paul Aurich <darkrain42@pidgin.im>
parents:
28077
diff
changeset
|
2994 | if ((imhtml->format_functions & (GTK_IMHTML_GROW|GTK_IMHTML_SHRINK)) && (font->size != 3 || (oldfont && oldfont->size == 3))) |
| 8698 | 2995 | gtk_imhtml_font_set_size(imhtml, font->size); |
| 3922 | 2996 | g_free(size); |
| 2997 | fonts = g_slist_prepend (fonts, font); | |
| 2998 | } | |
| 2999 | break; | |
| 3000 | case 44: /* BODY (opt) */ | |
| 3001 | if (!(options & GTK_IMHTML_NO_COLOURS)) { | |
| 3002 | char *bgcolor = gtk_imhtml_get_html_opt (tag, "BGCOLOR="); | |
| 8677 | 3003 | if (bgcolor && (imhtml->format_functions & GTK_IMHTML_BACKCOLOR)) { |
| 3004 | gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos); | |
| 8061 | 3005 | ws[0] = '\0'; wpos = 0; |
|
8177
33b3a01c6318
[gaim-migrate @ 8891]
Mark Doliner <markdoliner@pidgin.im>
parents:
8149
diff
changeset
|
3006 | /* NEW_BIT(NEW_TEXT_BIT); */ |
|
14097
0c340861ab79
[gaim-migrate @ 16638]
Mark Doliner <markdoliner@pidgin.im>
parents:
14010
diff
changeset
|
3007 | g_free(bg); |
| 3922 | 3008 | bg = bgcolor; |
| 10776 | 3009 | gtk_imhtml_toggle_background(imhtml, bg); |
|
14821
c91127e2b784
[gaim-migrate @ 17516]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14741
diff
changeset
|
3010 | } else |
|
c91127e2b784
[gaim-migrate @ 17516]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14741
diff
changeset
|
3011 | g_free(bgcolor); |
| 1428 | 3012 | } |
|
2856
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
3013 | break; |
| 3922 | 3014 | case 45: /* A (opt) */ |
| 3015 | { | |
| 3016 | gchar *href = gtk_imhtml_get_html_opt (tag, "HREF="); | |
| 8677 | 3017 | if (href && (imhtml->format_functions & GTK_IMHTML_LINK)) { |
| 3018 | gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos); | |
| 8061 | 3019 | ws[0] = '\0'; wpos = 0; |
| 8677 | 3020 | gtk_imhtml_toggle_link(imhtml, href); |
| 3922 | 3021 | } |
|
14097
0c340861ab79
[gaim-migrate @ 16638]
Mark Doliner <markdoliner@pidgin.im>
parents:
14010
diff
changeset
|
3022 | g_free(href); |
| 2993 | 3023 | } |
| 3922 | 3024 | break; |
| 4895 | 3025 | case 46: /* IMG (opt) */ |
|
6982
12f08de92674
[gaim-migrate @ 7538]
Mark Doliner <markdoliner@pidgin.im>
parents:
6882
diff
changeset
|
3026 | case 59: /* IMG */ |
| 4895 | 3027 | { |
|
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
|
3028 | char *id; |
| 8962 | 3029 | |
| 3030 | gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos); | |
| 3031 | ws[0] = '\0'; wpos = 0; | |
| 4895 | 3032 | |
| 8677 | 3033 | if (!(imhtml->format_functions & GTK_IMHTML_IMAGE)) |
| 3034 | break; | |
| 3035 | ||
| 8962 | 3036 | id = gtk_imhtml_get_html_opt(tag, "ID="); |
|
27359
3d884bc7b99e
Transform id-less <img> tags to links using src and alt attributes.
Dmitry Petroff <dmitry.petroff@gmail.com>
parents:
27259
diff
changeset
|
3037 | if (id) { |
|
3d884bc7b99e
Transform id-less <img> tags to links using src and alt attributes.
Dmitry Petroff <dmitry.petroff@gmail.com>
parents:
27259
diff
changeset
|
3038 | gtk_imhtml_insert_image_at_iter(imhtml, atoi(id), iter); |
|
3d884bc7b99e
Transform id-less <img> tags to links using src and alt attributes.
Dmitry Petroff <dmitry.petroff@gmail.com>
parents:
27259
diff
changeset
|
3039 | g_free(id); |
|
3d884bc7b99e
Transform id-less <img> tags to links using src and alt attributes.
Dmitry Petroff <dmitry.petroff@gmail.com>
parents:
27259
diff
changeset
|
3040 | } else { |
|
3d884bc7b99e
Transform id-less <img> tags to links using src and alt attributes.
Dmitry Petroff <dmitry.petroff@gmail.com>
parents:
27259
diff
changeset
|
3041 | char *src, *alt; |
|
3d884bc7b99e
Transform id-less <img> tags to links using src and alt attributes.
Dmitry Petroff <dmitry.petroff@gmail.com>
parents:
27259
diff
changeset
|
3042 | src = gtk_imhtml_get_html_opt(tag, "SRC="); |
|
3d884bc7b99e
Transform id-less <img> tags to links using src and alt attributes.
Dmitry Petroff <dmitry.petroff@gmail.com>
parents:
27259
diff
changeset
|
3043 | alt = gtk_imhtml_get_html_opt(tag, "ALT="); |
|
3d884bc7b99e
Transform id-less <img> tags to links using src and alt attributes.
Dmitry Petroff <dmitry.petroff@gmail.com>
parents:
27259
diff
changeset
|
3044 | if (src) { |
|
3d884bc7b99e
Transform id-less <img> tags to links using src and alt attributes.
Dmitry Petroff <dmitry.petroff@gmail.com>
parents:
27259
diff
changeset
|
3045 | gtk_imhtml_toggle_link(imhtml, src); |
|
3d884bc7b99e
Transform id-less <img> tags to links using src and alt attributes.
Dmitry Petroff <dmitry.petroff@gmail.com>
parents:
27259
diff
changeset
|
3046 | gtk_text_buffer_insert(imhtml->text_buffer, iter, alt ? alt : src, -1); |
|
3d884bc7b99e
Transform id-less <img> tags to links using src and alt attributes.
Dmitry Petroff <dmitry.petroff@gmail.com>
parents:
27259
diff
changeset
|
3047 | gtk_imhtml_toggle_link(imhtml, NULL); |
|
3d884bc7b99e
Transform id-less <img> tags to links using src and alt attributes.
Dmitry Petroff <dmitry.petroff@gmail.com>
parents:
27259
diff
changeset
|
3048 | } |
|
3d884bc7b99e
Transform id-less <img> tags to links using src and alt attributes.
Dmitry Petroff <dmitry.petroff@gmail.com>
parents:
27259
diff
changeset
|
3049 | g_free (src); |
|
3d884bc7b99e
Transform id-less <img> tags to links using src and alt attributes.
Dmitry Petroff <dmitry.petroff@gmail.com>
parents:
27259
diff
changeset
|
3050 | g_free (alt); |
|
3d884bc7b99e
Transform id-less <img> tags to links using src and alt attributes.
Dmitry Petroff <dmitry.petroff@gmail.com>
parents:
27259
diff
changeset
|
3051 | } |
| 8962 | 3052 | break; |
| 4895 | 3053 | } |
| 3922 | 3054 | case 47: /* P (opt) */ |
| 3055 | case 48: /* H3 (opt) */ | |
| 5093 | 3056 | case 49: /* HTML (opt) */ |
| 5101 | 3057 | case 50: /* CITE */ |
| 3058 | case 51: /* /CITE */ | |
| 8026 | 3059 | case 56: /* SPAN (opt) */ |
|
8118
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
3060 | /* Inline CSS Support - Douglas Thrift |
|
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
3061 | * |
|
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
3062 | * color |
| 8686 | 3063 | * background |
|
8118
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
3064 | * font-family |
|
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
3065 | * font-size |
| 8686 | 3066 | * text-decoration: underline |
| 14395 | 3067 | * font-weight: bold |
|
16143
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
3068 | * direction: rtl |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
3069 | * text-align: right |
| 10483 | 3070 | * |
| 3071 | * TODO: | |
| 3072 | * background-color | |
| 3073 | * font-style | |
|
8118
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
3074 | */ |
|
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
3075 | { |
|
16143
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
3076 | gchar *style, *color, *background, *family, *size, *direction, *alignment; |
| 14395 | 3077 | gchar *textdec, *weight; |
|
8118
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
3078 | GtkIMHtmlFontDetail *font, *oldfont = NULL; |
|
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
3079 | style = gtk_imhtml_get_html_opt (tag, "style="); |
|
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
3080 | |
|
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
3081 | if (!style) break; |
|
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
3082 | |
|
16143
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
3083 | color = purple_markup_get_css_property (style, "color"); |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
3084 | background = purple_markup_get_css_property (style, "background"); |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
3085 | 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
|
3086 | 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
|
3087 | 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
|
3088 | 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
|
3089 | direction = purple_markup_get_css_property (style, "direction"); |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
3090 | 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
|
3091 | |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
3092 | |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
3093 | if (!(color || family || size || background || textdec || weight || direction || alignment)) { |
| 8120 | 3094 | g_free(style); |
| 3095 | break; | |
| 3096 | } | |
|
8118
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
3097 | |
| 8677 | 3098 | |
| 3099 | gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos); | |
|
8118
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
3100 | ws[0] = '\0'; wpos = 0; |
|
8177
33b3a01c6318
[gaim-migrate @ 8891]
Mark Doliner <markdoliner@pidgin.im>
parents:
8149
diff
changeset
|
3101 | /* NEW_BIT (NEW_TEXT_BIT); */ |
|
8118
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
3102 | |
|
16143
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
3103 | /* 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
|
3104 | 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
|
3105 | rtl_direction = TRUE; |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
3106 | /* insert RLE character to set direction */ |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
3107 | ws[wpos++] = 0xE2; |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
3108 | ws[wpos++] = 0x80; |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
3109 | ws[wpos++] = 0xAB; |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
3110 | ws[wpos] = '\0'; |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
3111 | 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
|
3112 | ws[0] = '\0'; wpos = 0; |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
3113 | } |
| 16144 | 3114 | g_free(direction); |
| 3115 | ||
|
18552
810a338ef085
Use the glib strcasecmp functions everywhere, as we've had reports of
Richard Laager <rlaager@pidgin.im>
parents:
18543
diff
changeset
|
3116 | 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
|
3117 | align_right = TRUE; |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
3118 | align_line = gtk_text_iter_get_line(iter); |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
3119 | } |
| 16144 | 3120 | g_free(alignment); |
|
16143
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
3121 | |
|
8118
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
3122 | font = g_new0 (GtkIMHtmlFontDetail, 1); |
|
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
3123 | if (fonts) |
|
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
3124 | oldfont = fonts->data; |
|
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
3125 | |
|
14821
c91127e2b784
[gaim-migrate @ 17516]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14741
diff
changeset
|
3126 | 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
|
3127 | font->fore = parse_css_color(color); |
| 8686 | 3128 | gtk_imhtml_toggle_forecolor(imhtml, font->fore); |
|
14821
c91127e2b784
[gaim-migrate @ 17516]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14741
diff
changeset
|
3129 | } else { |
|
c91127e2b784
[gaim-migrate @ 17516]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14741
diff
changeset
|
3130 | if (oldfont && oldfont->fore) |
|
c91127e2b784
[gaim-migrate @ 17516]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14741
diff
changeset
|
3131 | font->fore = g_strdup(oldfont->fore); |
|
c91127e2b784
[gaim-migrate @ 17516]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14741
diff
changeset
|
3132 | g_free(color); |
| 8686 | 3133 | } |
|
14821
c91127e2b784
[gaim-migrate @ 17516]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14741
diff
changeset
|
3134 | |
|
c91127e2b784
[gaim-migrate @ 17516]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14741
diff
changeset
|
3135 | 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
|
3136 | font->back = parse_css_color(background); |
| 8686 | 3137 | gtk_imhtml_toggle_backcolor(imhtml, font->back); |
|
14821
c91127e2b784
[gaim-migrate @ 17516]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14741
diff
changeset
|
3138 | } else { |
|
c91127e2b784
[gaim-migrate @ 17516]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14741
diff
changeset
|
3139 | if (oldfont && oldfont->back) |
|
c91127e2b784
[gaim-migrate @ 17516]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14741
diff
changeset
|
3140 | font->back = g_strdup(oldfont->back); |
|
c91127e2b784
[gaim-migrate @ 17516]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14741
diff
changeset
|
3141 | g_free(background); |
| 8686 | 3142 | } |
|
14821
c91127e2b784
[gaim-migrate @ 17516]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14741
diff
changeset
|
3143 | |
|
c91127e2b784
[gaim-migrate @ 17516]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14741
diff
changeset
|
3144 | 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
|
3145 | font->face = family; |
| 8686 | 3146 | gtk_imhtml_toggle_fontface(imhtml, font->face); |
|
14821
c91127e2b784
[gaim-migrate @ 17516]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14741
diff
changeset
|
3147 | } else { |
|
c91127e2b784
[gaim-migrate @ 17516]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14741
diff
changeset
|
3148 | if (oldfont && oldfont->face) |
|
c91127e2b784
[gaim-migrate @ 17516]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14741
diff
changeset
|
3149 | font->face = g_strdup(oldfont->face); |
|
c91127e2b784
[gaim-migrate @ 17516]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14741
diff
changeset
|
3150 | g_free(family); |
| 8686 | 3151 | } |
|
8118
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
3152 | if (font->face && (atoi(font->face) > 100)) { |
| 8677 | 3153 | /* WTF is this? */ |
|
11572
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
3154 | /* 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
|
3155 | * remember bad things happening if the font size was |
|
9696
9d62e1ec5977
[gaim-migrate @ 10555]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9636
diff
changeset
|
3156 | * 2 billion */ |
|
8118
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
3157 | g_free(font->face); |
|
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
3158 | font->face = g_strdup("100"); |
|
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
3159 | } |
|
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
3160 | |
|
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
3161 | if (oldfont && oldfont->sml) |
|
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
3162 | font->sml = g_strdup(oldfont->sml); |
|
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
3163 | |
| 8677 | 3164 | if (size && !(options & GTK_IMHTML_NO_SIZES) && (imhtml->format_functions & (GTK_IMHTML_SHRINK|GTK_IMHTML_GROW))) { |
| 8686 | 3165 | if (g_ascii_strcasecmp(size, "xx-small") == 0) |
| 3166 | font->size = 1; | |
| 3167 | else if (g_ascii_strcasecmp(size, "smaller") == 0 | |
| 3168 | || g_ascii_strcasecmp(size, "x-small") == 0) | |
|
8118
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
3169 | 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
|
3170 | 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
|
3171 | font->size = 3; |
|
82d682722b68
Change our font mapping in gtkimhtml to match the suggested values
Mark Doliner <markdoliner@pidgin.im>
parents:
25168
diff
changeset
|
3172 | 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
|
3173 | || g_ascii_strcasecmp(size, "larger") == 0) |
|
8118
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
3174 | 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
|
3175 | else if (g_ascii_strcasecmp(size, "x-large") == 0) |
| 8686 | 3176 | 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
|
3177 | else if (g_ascii_strcasecmp(size, "xx-large") == 0) |
| 8686 | 3178 | 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
|
3179 | |
|
4f508dba5218
Change the way we handle <span style='font-size: whatever;'> tags slightly.
Mark Doliner <markdoliner@pidgin.im>
parents:
24588
diff
changeset
|
3180 | /* |
|
4f508dba5218
Change the way we handle <span style='font-size: whatever;'> tags slightly.
Mark Doliner <markdoliner@pidgin.im>
parents:
24588
diff
changeset
|
3181 | * 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
|
3182 | * 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
|
3183 | * 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
|
3184 | * 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
|
3185 | */ |
|
4f508dba5218
Change the way we handle <span style='font-size: whatever;'> tags slightly.
Mark Doliner <markdoliner@pidgin.im>
parents:
24588
diff
changeset
|
3186 | 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
|
3187 | gtk_imhtml_font_set_size(imhtml, font->size); |
| 8686 | 3188 | } |
| 3189 | else if (oldfont) | |
| 3190 | { | |
| 3191 | font->size = oldfont->size; | |
| 3192 | } | |
| 3193 | ||
| 3194 | if (oldfont) | |
| 3195 | { | |
| 3196 | font->underline = oldfont->underline; | |
| 3197 | } | |
| 3198 | if (textdec && font->underline != 1 | |
| 9025 | 3199 | && 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
|
3200 | && (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
|
3201 | && !(options & GTK_IMHTML_NO_FORMATTING)) |
| 8686 | 3202 | { |
| 3203 | gtk_imhtml_toggle_underline(imhtml); | |
| 3204 | font->underline = 1; | |
| 21425 | 3205 | } |
|
31310
7835bac46b07
Add support for rendering strikethrough when received as in-line CSS,
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
31294
diff
changeset
|
3206 | |
|
7835bac46b07
Add support for rendering strikethrough when received as in-line CSS,
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
31294
diff
changeset
|
3207 | if (oldfont) |
|
7835bac46b07
Add support for rendering strikethrough when received as in-line CSS,
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
31294
diff
changeset
|
3208 | { |
|
7835bac46b07
Add support for rendering strikethrough when received as in-line CSS,
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
31294
diff
changeset
|
3209 | font->strike = oldfont->strike; |
|
7835bac46b07
Add support for rendering strikethrough when received as in-line CSS,
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
31294
diff
changeset
|
3210 | } |
|
7835bac46b07
Add support for rendering strikethrough when received as in-line CSS,
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
31294
diff
changeset
|
3211 | if (textdec && font->strike != 1 |
|
7835bac46b07
Add support for rendering strikethrough when received as in-line CSS,
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
31294
diff
changeset
|
3212 | && g_ascii_strcasecmp(textdec, "line-through") == 0 |
|
7835bac46b07
Add support for rendering strikethrough when received as in-line CSS,
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
31294
diff
changeset
|
3213 | && (imhtml->format_functions & GTK_IMHTML_STRIKE) |
|
7835bac46b07
Add support for rendering strikethrough when received as in-line CSS,
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
31294
diff
changeset
|
3214 | && !(options & GTK_IMHTML_NO_FORMATTING)) |
|
7835bac46b07
Add support for rendering strikethrough when received as in-line CSS,
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
31294
diff
changeset
|
3215 | { |
|
7835bac46b07
Add support for rendering strikethrough when received as in-line CSS,
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
31294
diff
changeset
|
3216 | gtk_imhtml_toggle_strike(imhtml); |
|
7835bac46b07
Add support for rendering strikethrough when received as in-line CSS,
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
31294
diff
changeset
|
3217 | font->strike = 1; |
|
7835bac46b07
Add support for rendering strikethrough when received as in-line CSS,
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
31294
diff
changeset
|
3218 | } |
| 21425 | 3219 | g_free(textdec); |
|
8118
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
3220 | |
| 14395 | 3221 | if (oldfont) |
| 3222 | { | |
| 3223 | font->bold = oldfont->bold; | |
| 3224 | } | |
| 3225 | if (weight) | |
| 3226 | { | |
| 3227 | if(!g_ascii_strcasecmp(weight, "normal")) { | |
| 3228 | font->bold = 0; | |
| 3229 | } else if(!g_ascii_strcasecmp(weight, "bold")) { | |
| 3230 | font->bold = 1; | |
| 3231 | } else if(!g_ascii_strcasecmp(weight, "bolder")) { | |
| 3232 | font->bold++; | |
| 3233 | } else if(!g_ascii_strcasecmp(weight, "lighter")) { | |
| 3234 | if(font->bold > 0) | |
| 3235 | font->bold--; | |
| 3236 | } else { | |
| 3237 | int num = atoi(weight); | |
| 3238 | if(num >= 700) | |
| 3239 | font->bold = 1; | |
| 3240 | else | |
| 3241 | font->bold = 0; | |
| 3242 | } | |
|
17088
1ecea6e2fd97
Ignore bold, underline and other formatting type things in SPAN tags if
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17009
diff
changeset
|
3243 | if (((font->bold && oldfont && !oldfont->bold) || (oldfont && oldfont->bold && !font->bold) || (font->bold && !oldfont)) && !(options & GTK_IMHTML_NO_FORMATTING)) |
| 14395 | 3244 | { |
| 3245 | gtk_imhtml_toggle_bold(imhtml); | |
| 3246 | } | |
|
14821
c91127e2b784
[gaim-migrate @ 17516]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14741
diff
changeset
|
3247 | g_free(weight); |
| 14395 | 3248 | } |
| 3249 | ||
|
8118
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
3250 | g_free(style); |
|
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
3251 | g_free(size); |
|
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
3252 | fonts = g_slist_prepend (fonts, font); |
|
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
3253 | } |
|
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
3254 | break; |
| 5104 | 3255 | case 57: /* /SPAN */ |
|
8118
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
3256 | /* Inline CSS Support - Douglas Thrift */ |
| 8677 | 3257 | if (fonts && !imhtml->wbfo) { |
| 8686 | 3258 | GtkIMHtmlFontDetail *oldfont = NULL; |
|
8118
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
3259 | GtkIMHtmlFontDetail *font = fonts->data; |
| 8677 | 3260 | gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos); |
|
8118
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
3261 | ws[0] = '\0'; wpos = 0; |
|
8177
33b3a01c6318
[gaim-migrate @ 8891]
Mark Doliner <markdoliner@pidgin.im>
parents:
8149
diff
changeset
|
3262 | /* NEW_BIT (NEW_TEXT_BIT); */ |
|
8118
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
3263 | fonts = g_slist_remove (fonts, font); |
| 8692 | 3264 | if (fonts) |
| 3265 | oldfont = fonts->data; | |
| 3266 | ||
| 3267 | if (!oldfont) { | |
| 3268 | 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
|
3269 | if (font->underline && !(options & GTK_IMHTML_NO_FORMATTING)) |
| 8692 | 3270 | gtk_imhtml_toggle_underline(imhtml); |
|
31310
7835bac46b07
Add support for rendering strikethrough when received as in-line CSS,
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
31294
diff
changeset
|
3271 | if (font->strike && !(options & GTK_IMHTML_NO_FORMATTING)) |
|
7835bac46b07
Add support for rendering strikethrough when received as in-line CSS,
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
31294
diff
changeset
|
3272 | gtk_imhtml_toggle_strike(imhtml); |
|
17088
1ecea6e2fd97
Ignore bold, underline and other formatting type things in SPAN tags if
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17009
diff
changeset
|
3273 | if (font->bold && !(options & GTK_IMHTML_NO_FORMATTING)) |
| 14395 | 3274 | 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
|
3275 | 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
|
3276 | 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
|
3277 | 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
|
3278 | 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
|
3279 | 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
|
3280 | gtk_imhtml_toggle_backcolor(imhtml, NULL); |
| 8686 | 3281 | } |
| 8692 | 3282 | else |
| 8686 | 3283 | { |
| 8692 | 3284 | |
|
31310
7835bac46b07
Add support for rendering strikethrough when received as in-line CSS,
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
31294
diff
changeset
|
3285 | if ((font->size != oldfont->size) && !(options & GTK_IMHTML_NO_SIZES)) |
| 8692 | 3286 | gtk_imhtml_font_set_size(imhtml, oldfont->size); |
| 3287 | ||
|
17088
1ecea6e2fd97
Ignore bold, underline and other formatting type things in SPAN tags if
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17009
diff
changeset
|
3288 | if ((font->underline != oldfont->underline) && !(options & GTK_IMHTML_NO_FORMATTING)) |
| 8692 | 3289 | gtk_imhtml_toggle_underline(imhtml); |
| 3290 | ||
|
31310
7835bac46b07
Add support for rendering strikethrough when received as in-line CSS,
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
31294
diff
changeset
|
3291 | if ((font->strike != oldfont->strike) && !(options & GTK_IMHTML_NO_FORMATTING)) |
|
7835bac46b07
Add support for rendering strikethrough when received as in-line CSS,
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
31294
diff
changeset
|
3292 | gtk_imhtml_toggle_strike(imhtml); |
|
7835bac46b07
Add support for rendering strikethrough when received as in-line CSS,
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
31294
diff
changeset
|
3293 | |
|
17088
1ecea6e2fd97
Ignore bold, underline and other formatting type things in SPAN tags if
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17009
diff
changeset
|
3294 | if (((font->bold && !oldfont->bold) || (oldfont->bold && !font->bold)) && !(options & GTK_IMHTML_NO_FORMATTING)) |
|
31310
7835bac46b07
Add support for rendering strikethrough when received as in-line CSS,
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
31294
diff
changeset
|
3295 | gtk_imhtml_toggle_bold(imhtml); |
| 14395 | 3296 | |
|
17088
1ecea6e2fd97
Ignore bold, underline and other formatting type things in SPAN tags if
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17009
diff
changeset
|
3297 | if (font->face && (!oldfont->face || strcmp(font->face, oldfont->face) != 0) && !(options & GTK_IMHTML_NO_FONTS)) |
| 8692 | 3298 | gtk_imhtml_toggle_fontface(imhtml, oldfont->face); |
| 3299 | ||
|
17088
1ecea6e2fd97
Ignore bold, underline and other formatting type things in SPAN tags if
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17009
diff
changeset
|
3300 | if (font->fore && (!oldfont->fore || strcmp(font->fore, oldfont->fore) != 0) && !(options & GTK_IMHTML_NO_COLOURS)) |
| 8692 | 3301 | gtk_imhtml_toggle_forecolor(imhtml, oldfont->fore); |
| 3302 | ||
|
17088
1ecea6e2fd97
Ignore bold, underline and other formatting type things in SPAN tags if
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17009
diff
changeset
|
3303 | if (font->back && (!oldfont->back || strcmp(font->back, oldfont->back) != 0) && !(options & GTK_IMHTML_NO_COLOURS)) |
|
31310
7835bac46b07
Add support for rendering strikethrough when received as in-line CSS,
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
31294
diff
changeset
|
3304 | gtk_imhtml_toggle_backcolor(imhtml, oldfont->back); |
| 8686 | 3305 | } |
| 8692 | 3306 | |
| 3307 | g_free (font->face); | |
| 3308 | g_free (font->fore); | |
| 3309 | g_free (font->back); | |
| 3310 | g_free (font->sml); | |
| 3311 | ||
|
8118
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
3312 | g_free (font); |
|
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
3313 | } |
|
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
3314 | break; |
| 8026 | 3315 | case 60: /* SPAN */ |
| 2993 | 3316 | break; |
| 8061 | 3317 | case 62: /* comment */ |
|
8177
33b3a01c6318
[gaim-migrate @ 8891]
Mark Doliner <markdoliner@pidgin.im>
parents:
8149
diff
changeset
|
3318 | /* NEW_BIT (NEW_TEXT_BIT); */ |
| 8317 | 3319 | ws[wpos] = '\0'; |
| 9465 | 3320 | |
| 8677 | 3321 | gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos); |
| 3322 | ||
|
22486
e77232ab761f
Disable invisible text things, if someone can conclusively prove this is
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22276
diff
changeset
|
3323 | #if FALSE && GTK_CHECK_VERSION(2,10,10) |
|
22211
7f3cecdb079c
disapproval of revision '2c96f5a301400781ce5fbf144ffdbae44f895281'
Sean Egan <seanegan@pidgin.im>
parents:
22210
diff
changeset
|
3324 | wpos = g_snprintf (ws, len, "%s", tag); |
|
7f3cecdb079c
disapproval of revision '2c96f5a301400781ce5fbf144ffdbae44f895281'
Sean Egan <seanegan@pidgin.im>
parents:
22210
diff
changeset
|
3325 | 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
|
3326 | #else |
|
10815
b1ca28de65d3
[gaim-migrate @ 12470]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10814
diff
changeset
|
3327 | if (imhtml->show_comments && !(options & GTK_IMHTML_NO_COMMENTS)) { |
|
6124
322206d79652
[gaim-migrate @ 6598]
Mark Doliner <markdoliner@pidgin.im>
parents:
6066
diff
changeset
|
3328 | 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
|
3329 | 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
|
3330 | } |
|
22211
7f3cecdb079c
disapproval of revision '2c96f5a301400781ce5fbf144ffdbae44f895281'
Sean Egan <seanegan@pidgin.im>
parents:
22210
diff
changeset
|
3331 | #endif |
|
10815
b1ca28de65d3
[gaim-migrate @ 12470]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10814
diff
changeset
|
3332 | ws[0] = '\0'; wpos = 0; |
|
b1ca28de65d3
[gaim-migrate @ 12470]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10814
diff
changeset
|
3333 | |
|
8177
33b3a01c6318
[gaim-migrate @ 8891]
Mark Doliner <markdoliner@pidgin.im>
parents:
8149
diff
changeset
|
3334 | /* NEW_BIT (NEW_COMMENT_BIT); */ |
| 3922 | 3335 | break; |
| 3336 | default: | |
| 6882 | 3337 | break; |
| 2993 | 3338 | } |
|
2856
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
3339 | c += tlen; |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
3340 | pos += tlen; |
|
13138
4d3bd039da3e
[gaim-migrate @ 15499]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13137
diff
changeset
|
3341 | 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
|
3342 | } 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
|
3343 | !(options & GTK_IMHTML_NO_SMILEY) && |
|
15331
a8ef18791524
[gaim-migrate @ 18059]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15111
diff
changeset
|
3344 | gtk_imhtml_is_smiley(imhtml, fonts, c, &smilelen)) { |
| 8473 | 3345 | GtkIMHtmlFontDetail *fd; |
| 3346 | 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
|
3347 | |
|
b27c242d1288
Fix #3930 by correctly detecting when we're no longer immediately following a br.
Daniel Atallah <datallah@pidgin.im>
parents:
21425
diff
changeset
|
3348 | 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
|
3349 | |
| 8473 | 3350 | if (fonts) { |
| 3351 | fd = fonts->data; | |
| 3352 | sml = fd->sml; | |
| 3353 | } | |
| 9029 | 3354 | if (!sml) |
| 3355 | sml = imhtml->protocol_name; | |
| 3356 | ||
| 8677 | 3357 | gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos); |
| 8505 | 3358 | wpos = g_snprintf (ws, smilelen + 1, "%s", c); |
| 8473 | 3359 | |
| 8677 | 3360 | gtk_imhtml_insert_smiley_at_iter(imhtml, sml, ws, iter); |
| 8473 | 3361 | |
| 8505 | 3362 | c += smilelen; |
| 3363 | pos += smilelen; | |
| 8473 | 3364 | wpos = 0; |
| 3365 | ws[0] = 0; | |
| 16144 | 3366 | } 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
|
3367 | br = FALSE; |
| 7280 | 3368 | while(*amp) { |
| 3369 | ws [wpos++] = *amp++; | |
| 3370 | } | |
|
2856
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
3371 | c += tlen; |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
3372 | pos += tlen; |
| 1428 | 3373 | } else if (*c == '\n') { |
| 3374 | if (!(options & GTK_IMHTML_NO_NEWLINE)) { | |
| 3922 | 3375 | ws[wpos] = '\n'; |
| 3376 | wpos++; | |
| 8677 | 3377 | gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos); |
|
25007
ef8bc1f4a6ba
Pass only the URL scheme to gtkimhtml and let it add the colon automatically.
Richard Laager <rlaager@pidgin.im>
parents:
24698
diff
changeset
|
3378 | ws[0] = '\0'; wpos = 0; |
|
8177
33b3a01c6318
[gaim-migrate @ 8891]
Mark Doliner <markdoliner@pidgin.im>
parents:
8149
diff
changeset
|
3379 | /* NEW_BIT (NEW_TEXT_BIT); */ |
| 10217 | 3380 | } else if (!br) { /* Don't insert a space immediately after an HTML break */ |
| 9621 | 3381 | /* A newline is defined by HTML as whitespace, which means we have to replace it with a word boundary. |
| 3382 | * word breaks vary depending on the language used, so the correct thing to do is to use Pango to determine | |
| 3383 | * what language this is, determine the proper word boundary to use, and insert that. I'm just going to insert | |
| 3384 | * a space instead. What are the non-English speakers going to do? Complain in a language I'll understand? | |
| 3385 | * Bu-wahaha! */ | |
| 3386 | ws[wpos] = ' '; | |
| 3387 | wpos++; | |
| 3388 | gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos); | |
|
25007
ef8bc1f4a6ba
Pass only the URL scheme to gtkimhtml and let it add the colon automatically.
Richard Laager <rlaager@pidgin.im>
parents:
24698
diff
changeset
|
3389 | ws[0] = '\0'; wpos = 0; |
| 1428 | 3390 | } |
| 3391 | c++; | |
|
2856
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
3392 | pos++; |
|
25011
39bfe35b2980
Only find URLs on word boundaries to fix a bug rlaager noticed.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
25008
diff
changeset
|
3393 | } else if ((pos == 0 || wpos == 0 || isspace(*(c - 1))) && |
|
25908
c863fcecb7dd
Do not linkify unless <proto> is followed by some non-whitespace string.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
25906
diff
changeset
|
3394 | (len_protocol = gtk_imhtml_is_protocol(c)) > 0 && |
|
26655
95790807b4d7
Fix the auto-linking of protocols.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
25908
diff
changeset
|
3395 | c[len_protocol] && !isspace(c[len_protocol]) && |
|
95790807b4d7
Fix the auto-linking of protocols.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
25908
diff
changeset
|
3396 | (c[len_protocol] != '<' || !gtk_imhtml_is_tag(c + 1, NULL, NULL, 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
|
3397 | br = FALSE; |
|
24674
36bf974a7d78
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24588
diff
changeset
|
3398 | if (wpos > 0) { |
|
36bf974a7d78
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24588
diff
changeset
|
3399 | gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos); |
|
25007
ef8bc1f4a6ba
Pass only the URL scheme to gtkimhtml and let it add the colon automatically.
Richard Laager <rlaager@pidgin.im>
parents:
24698
diff
changeset
|
3400 | ws[0] = '\0'; wpos = 0; |
|
24674
36bf974a7d78
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24588
diff
changeset
|
3401 | } |
|
25007
ef8bc1f4a6ba
Pass only the URL scheme to gtkimhtml and let it add the colon automatically.
Richard Laager <rlaager@pidgin.im>
parents:
24698
diff
changeset
|
3402 | while (len_protocol--) { |
|
ef8bc1f4a6ba
Pass only the URL scheme to gtkimhtml and let it add the colon automatically.
Richard Laager <rlaager@pidgin.im>
parents:
24698
diff
changeset
|
3403 | /* Skip the next len_protocol characters, but |
|
ef8bc1f4a6ba
Pass only the URL scheme to gtkimhtml and let it add the colon automatically.
Richard Laager <rlaager@pidgin.im>
parents:
24698
diff
changeset
|
3404 | * make sure they're copied into the ws array. |
|
ef8bc1f4a6ba
Pass only the URL scheme to gtkimhtml and let it add the colon automatically.
Richard Laager <rlaager@pidgin.im>
parents:
24698
diff
changeset
|
3405 | */ |
|
ef8bc1f4a6ba
Pass only the URL scheme to gtkimhtml and let it add the colon automatically.
Richard Laager <rlaager@pidgin.im>
parents:
24698
diff
changeset
|
3406 | ws [wpos++] = *c++; |
|
ef8bc1f4a6ba
Pass only the URL scheme to gtkimhtml and let it add the colon automatically.
Richard Laager <rlaager@pidgin.im>
parents:
24698
diff
changeset
|
3407 | pos++; |
| 8334 | 3408 | } |
|
25017
139df1ee9854
Fix the linkification error where bad things happened if you copy/pasted
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
25014
diff
changeset
|
3409 | if (!imhtml->edit.link && (imhtml->format_functions & GTK_IMHTML_LINK)) { |
|
139df1ee9854
Fix the linkification error where bad things happened if you copy/pasted
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
25014
diff
changeset
|
3410 | while (*c && !isspace((int)*c) && |
|
139df1ee9854
Fix the linkification error where bad things happened if you copy/pasted
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
25014
diff
changeset
|
3411 | (*c != '<' || !gtk_imhtml_is_tag(c + 1, NULL, NULL, NULL))) { |
|
139df1ee9854
Fix the linkification error where bad things happened if you copy/pasted
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
25014
diff
changeset
|
3412 | if (*c == '&' && (amp = purple_markup_unescape_entity(c, &tlen))) { |
|
139df1ee9854
Fix the linkification error where bad things happened if you copy/pasted
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
25014
diff
changeset
|
3413 | while (*amp) |
|
139df1ee9854
Fix the linkification error where bad things happened if you copy/pasted
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
25014
diff
changeset
|
3414 | ws[wpos++] = *amp++; |
|
139df1ee9854
Fix the linkification error where bad things happened if you copy/pasted
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
25014
diff
changeset
|
3415 | c += tlen; |
|
139df1ee9854
Fix the linkification error where bad things happened if you copy/pasted
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
25014
diff
changeset
|
3416 | pos += tlen; |
|
139df1ee9854
Fix the linkification error where bad things happened if you copy/pasted
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
25014
diff
changeset
|
3417 | } else { |
|
139df1ee9854
Fix the linkification error where bad things happened if you copy/pasted
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
25014
diff
changeset
|
3418 | ws [wpos++] = *c++; |
|
139df1ee9854
Fix the linkification error where bad things happened if you copy/pasted
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
25014
diff
changeset
|
3419 | pos++; |
|
139df1ee9854
Fix the linkification error where bad things happened if you copy/pasted
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
25014
diff
changeset
|
3420 | } |
|
24674
36bf974a7d78
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24588
diff
changeset
|
3421 | } |
|
36bf974a7d78
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24588
diff
changeset
|
3422 | ws[wpos] = '\0'; |
|
36bf974a7d78
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24588
diff
changeset
|
3423 | gtk_imhtml_toggle_link(imhtml, ws); |
|
36bf974a7d78
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24588
diff
changeset
|
3424 | gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos); |
|
36bf974a7d78
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24588
diff
changeset
|
3425 | ws[0] = '\0'; wpos = 0; |
|
36bf974a7d78
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24588
diff
changeset
|
3426 | gtk_imhtml_toggle_link(imhtml, NULL); |
| 8334 | 3427 | } |
| 8061 | 3428 | } 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
|
3429 | br = FALSE; |
| 1428 | 3430 | ws [wpos++] = *c++; |
|
2856
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
3431 | pos++; |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
3432 | } else { |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
3433 | break; |
| 1428 | 3434 | } |
| 3435 | } | |
| 8677 | 3436 | gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos); |
| 8061 | 3437 | ws[0] = '\0'; wpos = 0; |
| 3438 | ||
|
8177
33b3a01c6318
[gaim-migrate @ 8891]
Mark Doliner <markdoliner@pidgin.im>
parents:
8149
diff
changeset
|
3439 | /* NEW_BIT(NEW_TEXT_BIT); */ |
| 8061 | 3440 | |
|
16143
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
3441 | if(align_right) { |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
3442 | /* 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
|
3443 | GtkTextIter line_iter; |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
3444 | line_iter = *iter; |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
3445 | 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
|
3446 | /* insert RLM character to set alignment */ |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
3447 | ws[wpos++] = 0xE2; |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
3448 | ws[wpos++] = 0x80; |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
3449 | ws[wpos++] = 0x8F; |
|
25888
d0fdd378a635
Remove trailing whitespace
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
3450 | |
| 16144 | 3451 | if (!rtl_direction) |
|
16143
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
3452 | { |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
3453 | /* insert LRM character to set direction */ |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
3454 | /* (alignment=right and direction=LTR) */ |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
3455 | ws[wpos++] = 0xE2; |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
3456 | ws[wpos++] = 0x80; |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
3457 | ws[wpos++] = 0x8E; |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
3458 | } |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
3459 | |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
3460 | ws[wpos] = '\0'; |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
3461 | 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
|
3462 | gtk_text_buffer_get_end_iter(gtk_text_iter_get_buffer(&line_iter), iter); |
|
25007
ef8bc1f4a6ba
Pass only the URL scheme to gtkimhtml and let it add the colon automatically.
Richard Laager <rlaager@pidgin.im>
parents:
24698
diff
changeset
|
3463 | ws[0] = '\0'; wpos = 0; |
|
16143
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
3464 | } |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
3465 | |
| 4032 | 3466 | while (fonts) { |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
3467 | GtkIMHtmlFontDetail *font = fonts->data; |
| 4032 | 3468 | fonts = g_slist_remove (fonts, font); |
|
14097
0c340861ab79
[gaim-migrate @ 16638]
Mark Doliner <markdoliner@pidgin.im>
parents:
14010
diff
changeset
|
3469 | g_free (font->face); |
|
0c340861ab79
[gaim-migrate @ 16638]
Mark Doliner <markdoliner@pidgin.im>
parents:
14010
diff
changeset
|
3470 | g_free (font->fore); |
|
0c340861ab79
[gaim-migrate @ 16638]
Mark Doliner <markdoliner@pidgin.im>
parents:
14010
diff
changeset
|
3471 | g_free (font->back); |
|
0c340861ab79
[gaim-migrate @ 16638]
Mark Doliner <markdoliner@pidgin.im>
parents:
14010
diff
changeset
|
3472 | g_free (font->sml); |
| 4032 | 3473 | g_free (font); |
| 3474 | } | |
| 8932 | 3475 | |
| 3476 | g_free(ws); | |
|
13138
4d3bd039da3e
[gaim-migrate @ 15499]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13137
diff
changeset
|
3477 | g_free(bg); |
| 8677 | 3478 | |
| 3479 | if (!imhtml->wbfo) | |
| 8698 | 3480 | gtk_imhtml_close_tags(imhtml, iter); |
| 8506 | 3481 | |
| 15403 | 3482 | object = g_object_ref(G_OBJECT(imhtml)); |
| 8506 | 3483 | g_signal_emit(object, signals[UPDATE_FORMAT], 0); |
| 3484 | g_object_unref(object); | |
| 15420 | 3485 | |
|
22834
1394e7efb818
Smiley insertions can be undone with this fix. References #5577. But redo
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22810
diff
changeset
|
3486 | gtk_text_buffer_end_user_action(imhtml->text_buffer); |
| 3922 | 3487 | } |
| 3488 | ||
| 4892 | 3489 | void gtk_imhtml_remove_smileys(GtkIMHtml *imhtml) |
| 3490 | { | |
| 4288 | 3491 | g_hash_table_destroy(imhtml->smiley_data); |
| 3492 | gtk_smiley_tree_destroy(imhtml->default_smilies); | |
| 4892 | 3493 | imhtml->smiley_data = g_hash_table_new_full(g_str_hash, g_str_equal, |
| 4902 | 3494 | g_free, (GDestroyNotify)gtk_smiley_tree_destroy); |
| 4288 | 3495 | imhtml->default_smilies = gtk_smiley_tree_new(); |
| 3496 | } | |
| 8481 | 3497 | |
| 3922 | 3498 | void gtk_imhtml_show_comments (GtkIMHtml *imhtml, |
| 4253 | 3499 | gboolean show) |
| 3500 | { | |
|
22486
e77232ab761f
Disable invisible text things, if someone can conclusively prove this is
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22276
diff
changeset
|
3501 | #if FALSE && GTK_CHECK_VERSION(2,10,10) |
|
22211
7f3cecdb079c
disapproval of revision '2c96f5a301400781ce5fbf144ffdbae44f895281'
Sean Egan <seanegan@pidgin.im>
parents:
22210
diff
changeset
|
3502 | GtkTextTag *tag; |
|
7f3cecdb079c
disapproval of revision '2c96f5a301400781ce5fbf144ffdbae44f895281'
Sean Egan <seanegan@pidgin.im>
parents:
22210
diff
changeset
|
3503 | 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
|
3504 | if (tag) |
|
7f3cecdb079c
disapproval of revision '2c96f5a301400781ce5fbf144ffdbae44f895281'
Sean Egan <seanegan@pidgin.im>
parents:
22210
diff
changeset
|
3505 | g_object_set(G_OBJECT(tag), "invisible", !show, NULL); |
|
7f3cecdb079c
disapproval of revision '2c96f5a301400781ce5fbf144ffdbae44f895281'
Sean Egan <seanegan@pidgin.im>
parents:
22210
diff
changeset
|
3506 | #endif |
|
6124
322206d79652
[gaim-migrate @ 6598]
Mark Doliner <markdoliner@pidgin.im>
parents:
6066
diff
changeset
|
3507 | imhtml->show_comments = show; |
| 4253 | 3508 | } |
|
1780
431333222954
[gaim-migrate @ 1790]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
1738
diff
changeset
|
3509 | |
|
11814
5003711283c0
[gaim-migrate @ 14105]
Richard Laager <rlaager@pidgin.im>
parents:
11768
diff
changeset
|
3510 | const char * |
|
5003711283c0
[gaim-migrate @ 14105]
Richard Laager <rlaager@pidgin.im>
parents:
11768
diff
changeset
|
3511 | gtk_imhtml_get_protocol_name(GtkIMHtml *imhtml) { |
|
5003711283c0
[gaim-migrate @ 14105]
Richard Laager <rlaager@pidgin.im>
parents:
11768
diff
changeset
|
3512 | return imhtml->protocol_name; |
|
5003711283c0
[gaim-migrate @ 14105]
Richard Laager <rlaager@pidgin.im>
parents:
11768
diff
changeset
|
3513 | } |
|
5003711283c0
[gaim-migrate @ 14105]
Richard Laager <rlaager@pidgin.im>
parents:
11768
diff
changeset
|
3514 | |
| 8962 | 3515 | void |
| 9029 | 3516 | 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
|
3517 | g_free(imhtml->protocol_name); |
|
0c340861ab79
[gaim-migrate @ 16638]
Mark Doliner <markdoliner@pidgin.im>
parents:
14010
diff
changeset
|
3518 | imhtml->protocol_name = g_strdup(protocol_name); |
| 8456 | 3519 | } |
| 3520 | ||
|
1780
431333222954
[gaim-migrate @ 1790]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
1738
diff
changeset
|
3521 | void |
|
11224
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3522 | gtk_imhtml_delete(GtkIMHtml *imhtml, GtkTextIter *start, GtkTextIter *end) { |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3523 | GList *l; |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3524 | GSList *sl; |
|
11234
e23fd86e7581
[gaim-migrate @ 13377]
Daniel Atallah <datallah@pidgin.im>
parents:
11233
diff
changeset
|
3525 | GtkTextIter i, i_s, i_e; |
| 8427 | 3526 | GObject *object = g_object_ref(G_OBJECT(imhtml)); |
|
11224
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3527 | |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3528 | if (start == NULL) { |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3529 | gtk_text_buffer_get_start_iter(imhtml->text_buffer, &i_s); |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3530 | start = &i_s; |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3531 | } |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3532 | |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3533 | if (end == NULL) { |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3534 | gtk_text_buffer_get_end_iter(imhtml->text_buffer, &i_e); |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3535 | end = &i_e; |
| 7991 | 3536 | } |
|
11224
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3537 | |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3538 | l = imhtml->scalables; |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3539 | while (l) { |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3540 | GList *next = l->next; |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3541 | struct scalable_data *sd = l->data; |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3542 | gtk_text_buffer_get_iter_at_mark(imhtml->text_buffer, |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3543 | &i, sd->mark); |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3544 | 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
|
3545 | GtkIMHtmlScalable *scale = GTK_IMHTML_SCALABLE(sd->scalable); |
|
11224
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3546 | 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
|
3547 | 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
|
3548 | imhtml->scalables = g_list_delete_link(imhtml->scalables, l); |
|
11224
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3549 | } |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3550 | l = next; |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3551 | } |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3552 | |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3553 | sl = imhtml->im_images; |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3554 | while (sl) { |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3555 | GSList *next = sl->next; |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3556 | struct im_image_data *img_data = sl->data; |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3557 | gtk_text_buffer_get_iter_at_mark(imhtml->text_buffer, |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3558 | &i, img_data->mark); |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3559 | if (gtk_text_iter_in_range(&i, start, end)) { |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3560 | if (imhtml->funcs->image_unref) |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3561 | imhtml->funcs->image_unref(img_data->id); |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3562 | imhtml->im_images = g_slist_delete_link(imhtml->im_images, sl); |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3563 | g_free(img_data); |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3564 | } |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3565 | sl = next; |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3566 | } |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3567 | gtk_text_buffer_delete(imhtml->text_buffer, start, end); |
| 8061 | 3568 | |
|
29378
a783b23a05da
Fix CVE-2010-0423, a denial of service attack due to the parsing
Mark Doliner <markdoliner@pidgin.im>
parents:
29371
diff
changeset
|
3569 | g_object_set_data(G_OBJECT(imhtml), "gtkimhtml_numsmileys_total", GINT_TO_POINTER(0)); |
|
a783b23a05da
Fix CVE-2010-0423, a denial of service attack due to the parsing
Mark Doliner <markdoliner@pidgin.im>
parents:
29371
diff
changeset
|
3570 | |
| 8427 | 3571 | g_object_unref(object); |
|
1780
431333222954
[gaim-migrate @ 1790]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
1738
diff
changeset
|
3572 | } |
|
2363
0767c14d7879
[gaim-migrate @ 2376]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2349
diff
changeset
|
3573 | |
| 4046 | 3574 | void gtk_imhtml_page_up (GtkIMHtml *imhtml) |
| 3575 | { | |
| 5282 | 3576 | GdkRectangle rect; |
| 3577 | GtkTextIter iter; | |
| 4046 | 3578 | |
| 5282 | 3579 | gtk_text_view_get_visible_rect(GTK_TEXT_VIEW(imhtml), &rect); |
| 3580 | gtk_text_view_get_iter_at_location(GTK_TEXT_VIEW(imhtml), &iter, rect.x, | |
| 3581 | rect.y - rect.height); | |
| 3582 | gtk_text_view_scroll_to_iter(GTK_TEXT_VIEW(imhtml), &iter, 0, TRUE, 0, 0); | |
| 8061 | 3583 | |
| 4046 | 3584 | } |
| 5282 | 3585 | void gtk_imhtml_page_down (GtkIMHtml *imhtml) |
| 3586 | { | |
| 3587 | GdkRectangle rect; | |
| 3588 | GtkTextIter iter; | |
| 3589 | ||
| 3590 | gtk_text_view_get_visible_rect(GTK_TEXT_VIEW(imhtml), &rect); | |
| 3591 | gtk_text_view_get_iter_at_location(GTK_TEXT_VIEW(imhtml), &iter, rect.x, | |
| 3592 | rect.y + rect.height); | |
| 3593 | gtk_text_view_scroll_to_iter(GTK_TEXT_VIEW(imhtml), &iter, 0, TRUE, 0, 0); | |
| 3594 | } | |
| 4735 | 3595 | |
|
32295
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3596 | /** |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3597 | * Destroys and frees a GTK+ IM/HTML scalable image. |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3598 | * |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3599 | * @param scale The GTK+ IM/HTML scalable. |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3600 | */ |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3601 | static void gtk_imhtml_image_free(GtkIMHtmlScalable *scale) |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3602 | { |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3603 | GtkIMHtmlImage *image = (GtkIMHtmlImage *)scale; |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3604 | |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3605 | g_object_unref(image->pixbuf); |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3606 | g_free(image->filename); |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3607 | if (image->filesel) |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3608 | gtk_widget_destroy(image->filesel); |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3609 | g_free(scale); |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3610 | } |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3611 | |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3612 | /** |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3613 | * Destroys and frees a GTK+ IM/HTML scalable animation. |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3614 | * |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3615 | * @param scale The GTK+ IM/HTML scalable. |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3616 | */ |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3617 | static void gtk_imhtml_animation_free(GtkIMHtmlScalable *scale) |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3618 | { |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3619 | GtkIMHtmlAnimation *animation = (GtkIMHtmlAnimation *)scale; |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3620 | |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3621 | if (animation->timer > 0) |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3622 | g_source_remove(animation->timer); |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3623 | if (animation->iter != NULL) |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3624 | g_object_unref(animation->iter); |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3625 | g_object_unref(animation->anim); |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3626 | |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3627 | gtk_imhtml_image_free(scale); |
| 4895 | 3628 | } |
| 3629 | ||
|
9573
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3630 | static void |
|
27123
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3631 | image_save_yes_cb(GtkIMHtmlImageSave *save, const char *filename) |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3632 | { |
| 5019 | 3633 | GError *error = NULL; |
|
27123
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3634 | GtkIMHtmlImage *image = (GtkIMHtmlImage *)save->image; |
| 5012 | 3635 | |
|
9573
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3636 | gtk_widget_destroy(image->filesel); |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3637 | image->filesel = NULL; |
|
5959
827dbe4b5bb2
[gaim-migrate @ 6405]
Mark Doliner <markdoliner@pidgin.im>
parents:
5582
diff
changeset
|
3638 | |
|
27123
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3639 | if (save->data && save->datasize) { |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3640 | g_file_set_contents(filename, save->data, save->datasize, &error); |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3641 | } else { |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3642 | gchar *type = NULL; |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3643 | GSList *formats = gdk_pixbuf_get_formats(); |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3644 | char *newfilename; |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3645 | |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3646 | while (formats) { |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3647 | GdkPixbufFormat *format = formats->data; |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3648 | gchar **extensions = gdk_pixbuf_format_get_extensions(format); |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3649 | gpointer p = extensions; |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3650 | |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3651 | while(gdk_pixbuf_format_is_writable(format) && extensions && extensions[0]){ |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3652 | gchar *fmt_ext = extensions[0]; |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3653 | const gchar* file_ext = filename + strlen(filename) - strlen(fmt_ext); |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3654 | |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3655 | if(!g_ascii_strcasecmp(fmt_ext, file_ext)){ |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3656 | type = gdk_pixbuf_format_get_name(format); |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3657 | break; |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3658 | } |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3659 | |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3660 | extensions++; |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3661 | } |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3662 | |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3663 | g_strfreev(p); |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3664 | |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3665 | if (type) |
| 5012 | 3666 | break; |
|
27123
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3667 | |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3668 | formats = formats->next; |
| 5012 | 3669 | } |
| 3670 | ||
|
27123
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3671 | g_slist_free(formats); |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3672 | |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3673 | /* If I can't find a valid type, I will just tell the user about it and then assume |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3674 | it's a png */ |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3675 | if (!type){ |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3676 | char *basename, *tmp; |
|
27125
60349fcd9f2b
Preserve the location when defaulting to png for saving unsupported image format.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27123
diff
changeset
|
3677 | char *dirname; |
|
27123
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3678 | GtkWidget *dialog = gtk_message_dialog_new_with_markup(NULL, 0, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3679 | _("<span size='larger' weight='bold'>Unrecognized file type</span>\n\nDefaulting to PNG.")); |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3680 | |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3681 | g_signal_connect_swapped(dialog, "response", G_CALLBACK (gtk_widget_destroy), dialog); |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3682 | gtk_widget_show(dialog); |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3683 | |
| 5020 | 3684 | type = g_strdup("png"); |
|
27125
60349fcd9f2b
Preserve the location when defaulting to png for saving unsupported image format.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27123
diff
changeset
|
3685 | dirname = g_path_get_dirname(filename); |
|
27123
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3686 | basename = g_path_get_basename(filename); |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3687 | tmp = strrchr(basename, '.'); |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3688 | if (tmp != NULL) |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3689 | tmp[0] = '\0'; |
|
27125
60349fcd9f2b
Preserve the location when defaulting to png for saving unsupported image format.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27123
diff
changeset
|
3690 | newfilename = g_strdup_printf("%s" G_DIR_SEPARATOR_S "%s.png", dirname, basename); |
|
60349fcd9f2b
Preserve the location when defaulting to png for saving unsupported image format.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27123
diff
changeset
|
3691 | g_free(dirname); |
|
27123
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3692 | g_free(basename); |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3693 | } else { |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3694 | /* |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3695 | * We're able to save the file in it's original format, so we |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3696 | * can use the original file name. |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3697 | */ |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3698 | newfilename = g_strdup(filename); |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3699 | } |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3700 | |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3701 | gdk_pixbuf_save(image->pixbuf, newfilename, type, &error, NULL); |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3702 | |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3703 | g_free(newfilename); |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3704 | g_free(type); |
| 5020 | 3705 | } |
| 3706 | ||
|
9573
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3707 | if (error){ |
|
11019
6786068b00ab
[gaim-migrate @ 12890]
Richard Laager <rlaager@pidgin.im>
parents:
11006
diff
changeset
|
3708 | 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
|
3709 | _("<span size='larger' weight='bold'>Error saving image</span>\n\n%s"), error->message); |
|
6786068b00ab
[gaim-migrate @ 12890]
Richard Laager <rlaager@pidgin.im>
parents:
11006
diff
changeset
|
3710 | 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
|
3711 | gtk_widget_show(dialog); |
| 5012 | 3712 | g_error_free(error); |
| 3713 | } | |
| 3714 | } | |
| 3715 | ||
|
9573
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3716 | static void |
|
27123
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3717 | image_save_check_if_exists_cb(GtkWidget *widget, gint response, GtkIMHtmlImageSave *save) |
|
9573
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3718 | { |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3719 | gchar *filename; |
|
27123
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3720 | GtkIMHtmlImage *image = (GtkIMHtmlImage *)save->image; |
|
9573
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3721 | |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3722 | if (response != GTK_RESPONSE_ACCEPT) { |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3723 | gtk_widget_destroy(widget); |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3724 | image->filesel = NULL; |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3725 | return; |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3726 | } |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3727 | |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3728 | filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(widget)); |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3729 | |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3730 | /* |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3731 | * 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
|
3732 | * 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
|
3733 | * 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
|
3734 | */ |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3735 | /* |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3736 | if (g_file_test(filename, G_FILE_TEST_EXISTS)) { |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3737 | } else |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3738 | image_save_yes_cb(image, filename); |
|
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 | |
|
27123
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3741 | image_save_yes_cb(save, filename); |
|
9573
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3742 | |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3743 | g_free(filename); |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3744 | } |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3745 | |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3746 | static void |
|
27123
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3747 | gtk_imhtml_image_save(GtkWidget *w, GtkIMHtmlImageSave *save) |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3748 | { |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3749 | GtkIMHtmlImage *image = (GtkIMHtmlImage *)save->image; |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3750 | |
|
9573
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3751 | if (image->filesel != NULL) { |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3752 | gtk_window_present(GTK_WINDOW(image->filesel)); |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3753 | return; |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3754 | } |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3755 | |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3756 | image->filesel = gtk_file_chooser_dialog_new(_("Save Image"), |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3757 | NULL, |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3758 | GTK_FILE_CHOOSER_ACTION_SAVE, |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3759 | GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3760 | GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT, |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3761 | NULL); |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3762 | 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
|
3763 | if (image->filename != NULL) |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3764 | 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
|
3765 | g_signal_connect(G_OBJECT(GTK_FILE_CHOOSER(image->filesel)), "response", |
|
27123
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3766 | G_CALLBACK(image_save_check_if_exists_cb), save); |
|
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 | gtk_widget_show(image->filesel); |
| 5012 | 3769 | } |
| 3770 | ||
|
23304
3aba02105818
Modified patch from malu to "Add context menu alternative to add received
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23302
diff
changeset
|
3771 | static void |
|
27259
50ab3ce89cdb
Allow adding received animated custom smileys to locale custom smiley
Andrea Piccinelli <frasten@gmail.com>
parents:
27173
diff
changeset
|
3772 | gtk_imhtml_custom_smiley_save(GtkWidget *w, GtkIMHtmlImageSave *save) |
|
50ab3ce89cdb
Allow adding received animated custom smileys to locale custom smiley
Andrea Piccinelli <frasten@gmail.com>
parents:
27173
diff
changeset
|
3773 | { |
|
50ab3ce89cdb
Allow adding received animated custom smileys to locale custom smiley
Andrea Piccinelli <frasten@gmail.com>
parents:
27173
diff
changeset
|
3774 | GtkIMHtmlImage *image = (GtkIMHtmlImage *)save->image; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
31208
diff
changeset
|
3775 | |
|
23304
3aba02105818
Modified patch from malu to "Add context menu alternative to add received
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23302
diff
changeset
|
3776 | /* 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
|
3777 | 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
|
3778 | 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
|
3779 | pidgin_smiley_editor_set_image(editor, image->pixbuf); |
|
27259
50ab3ce89cdb
Allow adding received animated custom smileys to locale custom smiley
Andrea Piccinelli <frasten@gmail.com>
parents:
27173
diff
changeset
|
3780 | pidgin_smiley_editor_set_data(editor, save->data, save->datasize); |
|
23304
3aba02105818
Modified patch from malu to "Add context menu alternative to add received
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23302
diff
changeset
|
3781 | } |
|
3aba02105818
Modified patch from malu to "Add context menu alternative to add received
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23302
diff
changeset
|
3782 | |
|
9815
fcbbbce0e1ff
[gaim-migrate @ 10686]
Mark Doliner <markdoliner@pidgin.im>
parents:
9726
diff
changeset
|
3783 | /* |
|
fcbbbce0e1ff
[gaim-migrate @ 10686]
Mark Doliner <markdoliner@pidgin.im>
parents:
9726
diff
changeset
|
3784 | * 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
|
3785 | * 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
|
3786 | * basically like file transfer, except there is an icon to open the file |
| 15884 | 3787 | * 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
|
3788 | * all of that. |
|
fcbbbce0e1ff
[gaim-migrate @ 10686]
Mark Doliner <markdoliner@pidgin.im>
parents:
9726
diff
changeset
|
3789 | */ |
|
27123
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3790 | static gboolean gtk_imhtml_image_clicked(GtkWidget *w, GdkEvent *event, GtkIMHtmlImageSave *save) |
| 5012 | 3791 | { |
| 3792 | GdkEventButton *event_button = (GdkEventButton *) event; | |
|
27123
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3793 | GtkIMHtmlImage *image = (GtkIMHtmlImage *)save->image; |
| 5012 | 3794 | |
| 3795 | if (event->type == GDK_BUTTON_RELEASE) { | |
| 3796 | if(event_button->button == 3) { | |
| 3797 | GtkWidget *img, *item, *menu; | |
| 3798 | menu = gtk_menu_new(); | |
| 3799 | ||
| 3800 | /* buttons and such */ | |
| 3801 | img = gtk_image_new_from_stock(GTK_STOCK_SAVE, GTK_ICON_SIZE_MENU); | |
|
27122
a926d9d18bde
Avoid unnecessary strdup's.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27114
diff
changeset
|
3802 | item = gtk_image_menu_item_new_with_mnemonic(_("_Save Image...")); |
| 5012 | 3803 | gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(item), img); |
|
27123
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3804 | g_signal_connect(G_OBJECT(item), "activate", G_CALLBACK(gtk_imhtml_image_save), save); |
| 5012 | 3805 | gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); |
| 3806 | ||
|
23304
3aba02105818
Modified patch from malu to "Add context menu alternative to add received
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23302
diff
changeset
|
3807 | /* 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
|
3808 | /* 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
|
3809 | <= 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
|
3810 | 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
|
3811 | img = gtk_image_new_from_stock(GTK_STOCK_ADD, GTK_ICON_SIZE_MENU); |
|
27122
a926d9d18bde
Avoid unnecessary strdup's.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27114
diff
changeset
|
3812 | item = gtk_image_menu_item_new_with_mnemonic(_("_Add Custom Smiley...")); |
|
23304
3aba02105818
Modified patch from malu to "Add context menu alternative to add received
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23302
diff
changeset
|
3813 | 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
|
3814 | g_signal_connect(G_OBJECT(item), "activate", |
|
27259
50ab3ce89cdb
Allow adding received animated custom smileys to locale custom smiley
Andrea Piccinelli <frasten@gmail.com>
parents:
27173
diff
changeset
|
3815 | G_CALLBACK(gtk_imhtml_custom_smiley_save), save); |
|
23304
3aba02105818
Modified patch from malu to "Add context menu alternative to add received
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23302
diff
changeset
|
3816 | 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
|
3817 | } |
|
3aba02105818
Modified patch from malu to "Add context menu alternative to add received
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23302
diff
changeset
|
3818 | |
| 5012 | 3819 | gtk_widget_show_all(menu); |
| 3820 | gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL, | |
| 3821 | event_button->button, event_button->time); | |
| 3822 | ||
| 3823 | return TRUE; | |
| 3824 | } | |
| 3825 | } | |
| 3826 | if(event->type == GDK_BUTTON_PRESS && event_button->button == 3) | |
| 3827 | return TRUE; /* Clicking the right mouse button on a link shouldn't | |
| 3828 | be caught by the regular GtkTextView menu */ | |
| 3829 | else | |
| 3830 | return FALSE; /* Let clicks go through if we didn't catch anything */ | |
| 3831 | ||
| 3832 | } | |
|
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
|
3833 | |
|
32295
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3834 | /** |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3835 | * Rescales a GTK+ IM/HTML scalable image to a given size. |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3836 | * |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3837 | * @param scale The GTK+ IM/HTML scalable. |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3838 | * @param width The new width. |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3839 | * @param height The new height. |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3840 | */ |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3841 | static void gtk_imhtml_image_scale(GtkIMHtmlScalable *scale, int width, int height) |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3842 | { |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3843 | GtkIMHtmlImage *im_image = (GtkIMHtmlImage *)scale; |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3844 | |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3845 | if (im_image->width > width || im_image->height > height) { |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3846 | double ratio_w, ratio_h, ratio; |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3847 | int new_h, new_w; |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3848 | GdkPixbuf *new_image = NULL; |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3849 | |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3850 | ratio_w = ((double)width - 2) / im_image->width; |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3851 | ratio_h = ((double)height - 2) / im_image->height; |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3852 | |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3853 | ratio = (ratio_w < ratio_h) ? ratio_w : ratio_h; |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3854 | |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3855 | new_w = (int)(im_image->width * ratio); |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3856 | new_h = (int)(im_image->height * ratio); |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3857 | |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3858 | new_image = gdk_pixbuf_scale_simple(im_image->pixbuf, new_w, new_h, GDK_INTERP_BILINEAR); |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3859 | gtk_image_set_from_pixbuf(im_image->image, new_image); |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3860 | g_object_unref(G_OBJECT(new_image)); |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3861 | } else if (gdk_pixbuf_get_width(gtk_image_get_pixbuf(im_image->image)) != im_image->width) { |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3862 | /* Enough space to show the full-size of the image. */ |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3863 | GdkPixbuf *new_image; |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3864 | |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3865 | new_image = gdk_pixbuf_scale_simple(im_image->pixbuf, im_image->width, im_image->height, GDK_INTERP_BILINEAR); |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3866 | gtk_image_set_from_pixbuf(im_image->image, new_image); |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3867 | g_object_unref(G_OBJECT(new_image)); |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3868 | } |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3869 | } |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3870 | |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3871 | /** |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3872 | * Adds a GTK+ IM/HTML scalable image to a given GTK+ IM/HTML at a given iter. |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3873 | * |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3874 | * @param scale The GTK+ IM/HTML scalable. |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3875 | * @param imhtml The GTK+ IM/HTML. |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3876 | * @param iter The GtkTextIter at which to add the scalable. |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3877 | */ |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3878 | static void gtk_imhtml_image_add_to(GtkIMHtmlScalable *scale, GtkIMHtml *imhtml, GtkTextIter *iter) |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
3879 | { |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
3880 | GtkIMHtmlImage *image = (GtkIMHtmlImage *)scale; |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
3881 | GtkWidget *box = gtk_event_box_new(); |
| 8962 | 3882 | char *tag; |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
3883 | GtkTextChildAnchor *anchor = gtk_text_buffer_create_child_anchor(imhtml->text_buffer, iter); |
|
27123
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3884 | GtkIMHtmlImageSave *save; |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
3885 | |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
3886 | gtk_container_add(GTK_CONTAINER(box), GTK_WIDGET(image->image)); |
| 9229 | 3887 | |
| 3888 | if(!gtk_check_version(2, 4, 0)) | |
| 3889 | g_object_set(G_OBJECT(box), "visible-window", FALSE, NULL); | |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
3890 | |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
3891 | gtk_widget_show(GTK_WIDGET(image->image)); |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
3892 | gtk_widget_show(box); |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
3893 | |
| 8962 | 3894 | tag = g_strdup_printf("<IMG ID=\"%d\">", image->id); |
| 3895 | g_object_set_data_full(G_OBJECT(anchor), "gtkimhtml_htmltext", tag, g_free); | |
| 3896 | g_object_set_data(G_OBJECT(anchor), "gtkimhtml_plaintext", "[Image]"); | |
| 3897 | ||
| 15420 | 3898 | gtk_text_view_add_child_at_anchor(GTK_TEXT_VIEW(imhtml), box, anchor); |
|
27123
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3899 | |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3900 | save = g_new0(GtkIMHtmlImageSave, 1); |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3901 | save->image = scale; |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3902 | g_signal_connect(G_OBJECT(box), "event", G_CALLBACK(gtk_imhtml_image_clicked), save); |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3903 | g_object_set_data_full(G_OBJECT(box), "image-save-data", save, (GDestroyNotify)g_free); |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
3904 | } |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
3905 | |
|
32296
7212bb468518
Make another gtkimhtml function private.
Mark Doliner <markdoliner@pidgin.im>
parents:
32295
diff
changeset
|
3906 | /** |
|
7212bb468518
Make another gtkimhtml function private.
Mark Doliner <markdoliner@pidgin.im>
parents:
32295
diff
changeset
|
3907 | * Creates and returns a new GTK+ IM/HTML scalable object with an image. |
|
7212bb468518
Make another gtkimhtml function private.
Mark Doliner <markdoliner@pidgin.im>
parents:
32295
diff
changeset
|
3908 | * |
|
7212bb468518
Make another gtkimhtml function private.
Mark Doliner <markdoliner@pidgin.im>
parents:
32295
diff
changeset
|
3909 | * @param img A GdkPixbuf of the image to add. |
|
7212bb468518
Make another gtkimhtml function private.
Mark Doliner <markdoliner@pidgin.im>
parents:
32295
diff
changeset
|
3910 | * @param filename The filename to associate with the image. |
|
7212bb468518
Make another gtkimhtml function private.
Mark Doliner <markdoliner@pidgin.im>
parents:
32295
diff
changeset
|
3911 | * @param id The id to associate with the image. |
|
7212bb468518
Make another gtkimhtml function private.
Mark Doliner <markdoliner@pidgin.im>
parents:
32295
diff
changeset
|
3912 | * |
|
7212bb468518
Make another gtkimhtml function private.
Mark Doliner <markdoliner@pidgin.im>
parents:
32295
diff
changeset
|
3913 | * @return A new IM/HTML Scalable object with an image. |
|
7212bb468518
Make another gtkimhtml function private.
Mark Doliner <markdoliner@pidgin.im>
parents:
32295
diff
changeset
|
3914 | */ |
|
7212bb468518
Make another gtkimhtml function private.
Mark Doliner <markdoliner@pidgin.im>
parents:
32295
diff
changeset
|
3915 | static GtkIMHtmlScalable *gtk_imhtml_image_new(GdkPixbuf *img, const gchar *filename, int id) |
|
32295
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3916 | { |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3917 | GtkIMHtmlImage *im_image = g_malloc(sizeof(GtkIMHtmlImage)); |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3918 | |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3919 | GTK_IMHTML_SCALABLE(im_image)->scale = gtk_imhtml_image_scale; |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3920 | GTK_IMHTML_SCALABLE(im_image)->add_to = gtk_imhtml_image_add_to; |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3921 | GTK_IMHTML_SCALABLE(im_image)->free = gtk_imhtml_image_free; |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3922 | |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3923 | im_image->pixbuf = img; |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3924 | im_image->image = GTK_IMAGE(gtk_image_new_from_pixbuf(im_image->pixbuf)); |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3925 | im_image->width = gdk_pixbuf_get_width(img); |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3926 | im_image->height = gdk_pixbuf_get_height(img); |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3927 | im_image->mark = NULL; |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3928 | im_image->filename = g_strdup(filename); |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3929 | im_image->id = id; |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3930 | im_image->filesel = NULL; |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3931 | |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3932 | g_object_ref(img); |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3933 | return GTK_IMHTML_SCALABLE(im_image); |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3934 | } |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3935 | |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3936 | static gboolean |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3937 | animate_image_cb(gpointer data) |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3938 | { |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3939 | GtkIMHtmlImage *im_image; |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3940 | int width, height; |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3941 | int delay; |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3942 | |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3943 | im_image = data; |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3944 | |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3945 | /* Update the pointer to this GdkPixbuf frame of the animation */ |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3946 | if (gdk_pixbuf_animation_iter_advance(GTK_IMHTML_ANIMATION(im_image)->iter, NULL)) { |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3947 | GdkPixbuf *pb = gdk_pixbuf_animation_iter_get_pixbuf(GTK_IMHTML_ANIMATION(im_image)->iter); |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3948 | g_object_unref(G_OBJECT(im_image->pixbuf)); |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3949 | im_image->pixbuf = gdk_pixbuf_copy(pb); |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3950 | |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3951 | /* Update the displayed GtkImage */ |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3952 | width = gdk_pixbuf_get_width(gtk_image_get_pixbuf(im_image->image)); |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3953 | height = gdk_pixbuf_get_height(gtk_image_get_pixbuf(im_image->image)); |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3954 | if (width > 0 && height > 0) |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3955 | { |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3956 | /* Need to scale the new frame to the same size as the old frame */ |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3957 | GdkPixbuf *tmp; |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3958 | tmp = gdk_pixbuf_scale_simple(im_image->pixbuf, width, height, GDK_INTERP_BILINEAR); |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3959 | gtk_image_set_from_pixbuf(im_image->image, tmp); |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3960 | g_object_unref(G_OBJECT(tmp)); |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3961 | } else { |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3962 | /* Display at full-size */ |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3963 | gtk_image_set_from_pixbuf(im_image->image, im_image->pixbuf); |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3964 | } |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3965 | } |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3966 | |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3967 | delay = MIN(gdk_pixbuf_animation_iter_get_delay_time(GTK_IMHTML_ANIMATION(im_image)->iter), 100); |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3968 | GTK_IMHTML_ANIMATION(im_image)->timer = g_timeout_add(delay, animate_image_cb, im_image); |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3969 | |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3970 | return FALSE; |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3971 | } |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3972 | |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3973 | /** |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3974 | * Creates and returns a new GTK+ IM/HTML scalable object with an |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3975 | * animated image. |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3976 | * |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3977 | * @param img A GdkPixbufAnimation of the image to add. |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3978 | * @param filename The filename to associate with the image. |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3979 | * @param id The id to associate with the image. |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3980 | * |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3981 | * @return A new IM/HTML Scalable object with an image. |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3982 | * |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3983 | * @since 2.1.0 |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3984 | */ |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3985 | /* |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3986 | * TODO: All this animation code could be combined much better with |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3987 | * the image code. It couldn't be done when it was written |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3988 | * because it requires breaking backward compatibility. It |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3989 | * would be good to do it for 3.0.0. |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3990 | */ |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3991 | static GtkIMHtmlScalable *gtk_imhtml_animation_new(GdkPixbufAnimation *anim, const gchar *filename, int id) |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3992 | { |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3993 | GtkIMHtmlImage *im_image = (GtkIMHtmlImage *) g_new0(GtkIMHtmlAnimation, 1); |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3994 | |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3995 | GTK_IMHTML_SCALABLE(im_image)->scale = gtk_imhtml_image_scale; |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3996 | GTK_IMHTML_SCALABLE(im_image)->add_to = gtk_imhtml_image_add_to; |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3997 | GTK_IMHTML_SCALABLE(im_image)->free = gtk_imhtml_animation_free; |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3998 | |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3999 | GTK_IMHTML_ANIMATION(im_image)->anim = anim; |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
4000 | if (gdk_pixbuf_animation_is_static_image(anim)) { |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
4001 | im_image->pixbuf = gdk_pixbuf_animation_get_static_image(anim); |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
4002 | g_object_ref(im_image->pixbuf); |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
4003 | } else { |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
4004 | int delay; |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
4005 | GdkPixbuf *pb; |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
4006 | GTK_IMHTML_ANIMATION(im_image)->iter = gdk_pixbuf_animation_get_iter(anim, NULL); |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
4007 | pb = gdk_pixbuf_animation_iter_get_pixbuf(GTK_IMHTML_ANIMATION(im_image)->iter); |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
4008 | im_image->pixbuf = gdk_pixbuf_copy(pb); |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
4009 | delay = MIN(gdk_pixbuf_animation_iter_get_delay_time(GTK_IMHTML_ANIMATION(im_image)->iter), 100); |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
4010 | GTK_IMHTML_ANIMATION(im_image)->timer = g_timeout_add(delay, animate_image_cb, im_image); |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
4011 | } |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
4012 | im_image->image = GTK_IMAGE(gtk_image_new_from_pixbuf(im_image->pixbuf)); |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
4013 | im_image->width = gdk_pixbuf_animation_get_width(anim); |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
4014 | im_image->height = gdk_pixbuf_animation_get_height(anim); |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
4015 | im_image->filename = g_strdup(filename); |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
4016 | im_image->id = id; |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
4017 | |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
4018 | g_object_ref(anim); |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
4019 | |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
4020 | return GTK_IMHTML_SCALABLE(im_image); |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
4021 | } |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
4022 | |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
4023 | GtkIMHtmlScalable *gtk_imhtml_hr_new() |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
4024 | { |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
4025 | GtkIMHtmlHr *hr = g_malloc(sizeof(GtkIMHtmlHr)); |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
4026 | |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
4027 | GTK_IMHTML_SCALABLE(hr)->scale = gtk_imhtml_hr_scale; |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
4028 | GTK_IMHTML_SCALABLE(hr)->add_to = gtk_imhtml_hr_add_to; |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
4029 | GTK_IMHTML_SCALABLE(hr)->free = gtk_imhtml_hr_free; |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
4030 | |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
4031 | hr->sep = gtk_hseparator_new(); |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
4032 | gtk_widget_set_size_request(hr->sep, 5000, 2); |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
4033 | gtk_widget_show(hr->sep); |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
4034 | |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
4035 | return GTK_IMHTML_SCALABLE(hr); |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
4036 | } |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
4037 | |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
4038 | void gtk_imhtml_hr_scale(GtkIMHtmlScalable *scale, int width, int height) |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
4039 | { |
|
8588
6bcf7ed80ed8
[gaim-migrate @ 9339]
Mark Doliner <markdoliner@pidgin.im>
parents:
8568
diff
changeset
|
4040 | 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
|
4041 | } |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
4042 | |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
4043 | 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
|
4044 | { |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
4045 | GtkIMHtmlHr *hr = (GtkIMHtmlHr *)scale; |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
4046 | GtkTextChildAnchor *anchor = gtk_text_buffer_create_child_anchor(imhtml->text_buffer, iter); |
| 8698 | 4047 | g_object_set_data(G_OBJECT(anchor), "gtkimhtml_htmltext", "<hr>"); |
| 4048 | g_object_set_data(G_OBJECT(anchor), "gtkimhtml_plaintext", "\n---\n"); | |
| 15420 | 4049 | 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
|
4050 | } |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
4051 | |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
4052 | void gtk_imhtml_hr_free(GtkIMHtmlScalable *scale) |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
4053 | { |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
4054 | g_free(scale); |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
4055 | } |
| 7295 | 4056 | |
| 4057 | gboolean gtk_imhtml_search_find(GtkIMHtml *imhtml, const gchar *text) | |
| 4058 | { | |
| 4059 | GtkTextIter iter, start, end; | |
| 4060 | gboolean new_search = TRUE; | |
|
14863
82888d51234c
[gaim-migrate @ 17566]
Daniel Atallah <datallah@pidgin.im>
parents:
14821
diff
changeset
|
4061 | GtkTextMark *start_mark; |
| 7295 | 4062 | |
| 4063 | g_return_val_if_fail(imhtml != NULL, FALSE); | |
| 4064 | g_return_val_if_fail(text != NULL, FALSE); | |
| 8061 | 4065 | |
|
14863
82888d51234c
[gaim-migrate @ 17566]
Daniel Atallah <datallah@pidgin.im>
parents:
14821
diff
changeset
|
4066 | start_mark = gtk_text_buffer_get_mark(imhtml->text_buffer, "search"); |
|
82888d51234c
[gaim-migrate @ 17566]
Daniel Atallah <datallah@pidgin.im>
parents:
14821
diff
changeset
|
4067 | |
|
82888d51234c
[gaim-migrate @ 17566]
Daniel Atallah <datallah@pidgin.im>
parents:
14821
diff
changeset
|
4068 | if (start_mark && imhtml->search_string && !strcmp(text, imhtml->search_string)) |
| 7295 | 4069 | new_search = FALSE; |
| 8061 | 4070 | |
| 7295 | 4071 | if (new_search) { |
| 4072 | gtk_imhtml_search_clear(imhtml); | |
|
14863
82888d51234c
[gaim-migrate @ 17566]
Daniel Atallah <datallah@pidgin.im>
parents:
14821
diff
changeset
|
4073 | g_free(imhtml->search_string); |
|
82888d51234c
[gaim-migrate @ 17566]
Daniel Atallah <datallah@pidgin.im>
parents:
14821
diff
changeset
|
4074 | imhtml->search_string = g_strdup(text); |
| 15093 | 4075 | gtk_text_buffer_get_end_iter(imhtml->text_buffer, &iter); |
| 7295 | 4076 | } else { |
| 4077 | 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
|
4078 | start_mark); |
| 7295 | 4079 | } |
| 4080 | ||
| 15093 | 4081 | if (gtk_source_iter_backward_search(&iter, imhtml->search_string, |
|
14400
953baf2eba1a
[gaim-migrate @ 17035]
Richard Laager <rlaager@pidgin.im>
parents:
14395
diff
changeset
|
4082 | GTK_SOURCE_SEARCH_VISIBLE_ONLY | GTK_SOURCE_SEARCH_CASE_INSENSITIVE, |
|
953baf2eba1a
[gaim-migrate @ 17035]
Richard Laager <rlaager@pidgin.im>
parents:
14395
diff
changeset
|
4083 | &start, &end, NULL)) |
|
953baf2eba1a
[gaim-migrate @ 17035]
Richard Laager <rlaager@pidgin.im>
parents:
14395
diff
changeset
|
4084 | { |
| 7295 | 4085 | gtk_text_view_scroll_to_iter(GTK_TEXT_VIEW(imhtml), &start, 0, TRUE, 0, 0); |
| 15093 | 4086 | 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
|
4087 | if (new_search) |
|
953baf2eba1a
[gaim-migrate @ 17035]
Richard Laager <rlaager@pidgin.im>
parents:
14395
diff
changeset
|
4088 | { |
| 7295 | 4089 | gtk_text_buffer_remove_tag_by_name(imhtml->text_buffer, "search", &iter, &end); |
| 8061 | 4090 | do |
| 7295 | 4091 | gtk_text_buffer_apply_tag_by_name(imhtml->text_buffer, "search", &start, &end); |
| 15093 | 4092 | while (gtk_source_iter_backward_search(&start, imhtml->search_string, |
| 8061 | 4093 | GTK_SOURCE_SEARCH_VISIBLE_ONLY | |
| 7358 | 4094 | GTK_SOURCE_SEARCH_CASE_INSENSITIVE, |
| 7295 | 4095 | &start, &end, NULL)); |
| 4096 | } | |
| 4097 | return TRUE; | |
| 4098 | } | |
|
14400
953baf2eba1a
[gaim-migrate @ 17035]
Richard Laager <rlaager@pidgin.im>
parents:
14395
diff
changeset
|
4099 | else if (!new_search) |
|
953baf2eba1a
[gaim-migrate @ 17035]
Richard Laager <rlaager@pidgin.im>
parents:
14395
diff
changeset
|
4100 | { |
|
953baf2eba1a
[gaim-migrate @ 17035]
Richard Laager <rlaager@pidgin.im>
parents:
14395
diff
changeset
|
4101 | /* We hit the end, so start at the beginning again. */ |
| 15093 | 4102 | gtk_text_buffer_get_end_iter(imhtml->text_buffer, &iter); |
| 4103 | ||
| 4104 | if (gtk_source_iter_backward_search(&iter, imhtml->search_string, | |
|
14400
953baf2eba1a
[gaim-migrate @ 17035]
Richard Laager <rlaager@pidgin.im>
parents:
14395
diff
changeset
|
4105 | GTK_SOURCE_SEARCH_VISIBLE_ONLY | GTK_SOURCE_SEARCH_CASE_INSENSITIVE, |
|
953baf2eba1a
[gaim-migrate @ 17035]
Richard Laager <rlaager@pidgin.im>
parents:
14395
diff
changeset
|
4106 | &start, &end, NULL)) |
|
953baf2eba1a
[gaim-migrate @ 17035]
Richard Laager <rlaager@pidgin.im>
parents:
14395
diff
changeset
|
4107 | { |
|
953baf2eba1a
[gaim-migrate @ 17035]
Richard Laager <rlaager@pidgin.im>
parents:
14395
diff
changeset
|
4108 | gtk_text_view_scroll_to_iter(GTK_TEXT_VIEW(imhtml), &start, 0, TRUE, 0, 0); |
| 15093 | 4109 | 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
|
4110 | |
|
953baf2eba1a
[gaim-migrate @ 17035]
Richard Laager <rlaager@pidgin.im>
parents:
14395
diff
changeset
|
4111 | return TRUE; |
|
953baf2eba1a
[gaim-migrate @ 17035]
Richard Laager <rlaager@pidgin.im>
parents:
14395
diff
changeset
|
4112 | } |
|
953baf2eba1a
[gaim-migrate @ 17035]
Richard Laager <rlaager@pidgin.im>
parents:
14395
diff
changeset
|
4113 | |
|
953baf2eba1a
[gaim-migrate @ 17035]
Richard Laager <rlaager@pidgin.im>
parents:
14395
diff
changeset
|
4114 | } |
| 8061 | 4115 | |
| 7295 | 4116 | return FALSE; |
| 4117 | } | |
| 4118 | ||
| 4119 | void gtk_imhtml_search_clear(GtkIMHtml *imhtml) | |
| 4120 | { | |
| 4121 | GtkTextIter start, end; | |
| 8061 | 4122 | |
| 7295 | 4123 | g_return_if_fail(imhtml != NULL); |
| 8061 | 4124 | |
| 7295 | 4125 | gtk_text_buffer_get_start_iter(imhtml->text_buffer, &start); |
| 4126 | gtk_text_buffer_get_end_iter(imhtml->text_buffer, &end); | |
| 4127 | ||
| 4128 | 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
|
4129 | g_free(imhtml->search_string); |
| 7295 | 4130 | imhtml->search_string = NULL; |
| 4131 | } | |
| 8061 | 4132 | |
| 8677 | 4133 | static GtkTextTag *find_font_forecolor_tag(GtkIMHtml *imhtml, gchar *color) |
| 4134 | { | |
| 4135 | gchar str[18]; | |
| 4136 | GtkTextTag *tag; | |
| 4137 | ||
| 4138 | g_snprintf(str, sizeof(str), "FORECOLOR %s", color); | |
| 4139 | ||
| 4140 | tag = gtk_text_tag_table_lookup(gtk_text_buffer_get_tag_table(imhtml->text_buffer), str); | |
| 10858 | 4141 | if (!tag) { |
| 4142 | GdkColor gcolor; | |
| 4143 | if (!gdk_color_parse(color, &gcolor)) { | |
| 4144 | gchar tmp[8]; | |
| 4145 | tmp[0] = '#'; | |
| 4146 | strncpy(&tmp[1], color, 7); | |
| 4147 | tmp[7] = '\0'; | |
| 4148 | if (!gdk_color_parse(tmp, &gcolor)) | |
| 4149 | gdk_color_parse("black", &gcolor); | |
| 4150 | } | |
| 4151 | tag = gtk_text_buffer_create_tag(imhtml->text_buffer, str, "foreground-gdk", &gcolor, NULL); | |
| 4152 | } | |
| 8677 | 4153 | |
| 4154 | return tag; | |
| 4155 | } | |
| 4156 | ||
| 4157 | static GtkTextTag *find_font_backcolor_tag(GtkIMHtml *imhtml, gchar *color) | |
| 4158 | { | |
| 4159 | gchar str[18]; | |
| 4160 | GtkTextTag *tag; | |
| 4161 | ||
| 4162 | g_snprintf(str, sizeof(str), "BACKCOLOR %s", color); | |
| 4163 | ||
| 4164 | tag = gtk_text_tag_table_lookup(gtk_text_buffer_get_tag_table(imhtml->text_buffer), str); | |
| 10858 | 4165 | if (!tag) { |
| 4166 | GdkColor gcolor; | |
| 4167 | if (!gdk_color_parse(color, &gcolor)) { | |
| 4168 | gchar tmp[8]; | |
| 4169 | tmp[0] = '#'; | |
| 4170 | strncpy(&tmp[1], color, 7); | |
| 4171 | tmp[7] = '\0'; | |
| 4172 | if (!gdk_color_parse(tmp, &gcolor)) | |
| 4173 | gdk_color_parse("white", &gcolor); | |
| 4174 | } | |
| 4175 | tag = gtk_text_buffer_create_tag(imhtml->text_buffer, str, "background-gdk", &gcolor, NULL); | |
| 4176 | } | |
| 8677 | 4177 | |
| 4178 | return tag; | |
| 4179 | } | |
| 4180 | ||
| 10776 | 4181 | static GtkTextTag *find_font_background_tag(GtkIMHtml *imhtml, gchar *color) |
| 4182 | { | |
| 4183 | gchar str[19]; | |
| 4184 | GtkTextTag *tag; | |
| 4185 | ||
| 4186 | g_snprintf(str, sizeof(str), "BACKGROUND %s", color); | |
| 4187 | ||
| 4188 | tag = gtk_text_tag_table_lookup(gtk_text_buffer_get_tag_table(imhtml->text_buffer), str); | |
| 4189 | if (!tag) | |
| 4190 | tag = gtk_text_buffer_create_tag(imhtml->text_buffer, str, NULL); | |
| 4191 | ||
| 4192 | return tag; | |
| 4193 | } | |
| 4194 | ||
| 8677 | 4195 | static GtkTextTag *find_font_face_tag(GtkIMHtml *imhtml, gchar *face) |
| 8061 | 4196 | { |
| 8677 | 4197 | gchar str[256]; |
| 4198 | GtkTextTag *tag; | |
| 4199 | ||
| 4200 | g_snprintf(str, sizeof(str), "FONT FACE %s", face); | |
| 4201 | str[255] = '\0'; | |
| 4202 | ||
| 4203 | tag = gtk_text_tag_table_lookup(gtk_text_buffer_get_tag_table(imhtml->text_buffer), str); | |
| 4204 | if (!tag) | |
| 4205 | tag = gtk_text_buffer_create_tag(imhtml->text_buffer, str, "family", face, NULL); | |
| 4206 | ||
| 4207 | return tag; | |
| 4208 | } | |
| 4209 | ||
| 4210 | static GtkTextTag *find_font_size_tag(GtkIMHtml *imhtml, int size) | |
| 4211 | { | |
| 4212 | gchar str[24]; | |
| 4213 | GtkTextTag *tag; | |
| 4214 | ||
| 4215 | g_snprintf(str, sizeof(str), "FONT SIZE %d", size); | |
| 4216 | str[23] = '\0'; | |
| 4217 | ||
| 4218 | tag = gtk_text_tag_table_lookup(gtk_text_buffer_get_tag_table(imhtml->text_buffer), str); | |
| 4219 | if (!tag) { | |
| 10525 | 4220 | /* For reasons I don't understand, setting "scale" here scaled |
| 4221 | * based on some default size other than my theme's default | |
| 4222 | * size. Our size 4 was actually smaller than our size 3 for | |
| 4223 | * me. So this works around that oddity. | |
| 8677 | 4224 | */ |
| 10525 | 4225 | GtkTextAttributes *attr = gtk_text_view_get_default_attributes(GTK_TEXT_VIEW(imhtml)); |
| 8677 | 4226 | tag = gtk_text_buffer_create_tag(imhtml->text_buffer, str, "size", |
| 10525 | 4227 | (gint) (pango_font_description_get_size(attr->font) * |
|
10899
87d9aec5b72d
[gaim-migrate @ 12619]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10871
diff
changeset
|
4228 | (double) POINT_SIZE(size)), NULL); |
| 10525 | 4229 | gtk_text_attributes_unref(attr); |
| 8061 | 4230 | } |
| 4231 | ||
| 8677 | 4232 | return tag; |
| 4233 | } | |
| 4234 | ||
| 4235 | static void remove_tag_by_prefix(GtkIMHtml *imhtml, const GtkTextIter *i, const GtkTextIter *e, | |
| 4236 | const char *prefix, guint len, gboolean homo) | |
| 4237 | { | |
| 4238 | GSList *tags, *l; | |
| 4239 | GtkTextIter iter; | |
| 4240 | ||
| 4241 | tags = gtk_text_iter_get_tags(i); | |
| 4242 | ||
| 4243 | for (l = tags; l; l = l->next) { | |
| 4244 | GtkTextTag *tag = l->data; | |
| 4245 | ||
| 4246 | if (tag->name && !strncmp(tag->name, prefix, len)) | |
| 4247 | gtk_text_buffer_remove_tag(imhtml->text_buffer, tag, i, e); | |
| 8061 | 4248 | } |
| 4249 | ||
| 8677 | 4250 | g_slist_free(tags); |
| 4251 | ||
| 4252 | if (homo) | |
| 4253 | return; | |
| 4254 | ||
| 4255 | iter = *i; | |
| 4256 | ||
| 4257 | while (gtk_text_iter_forward_char(&iter) && !gtk_text_iter_equal(&iter, e)) { | |
| 4258 | if (gtk_text_iter_begins_tag(&iter, NULL)) { | |
| 4259 | tags = gtk_text_iter_get_toggled_tags(&iter, TRUE); | |
| 4260 | ||
| 4261 | for (l = tags; l; l = l->next) { | |
| 4262 | GtkTextTag *tag = l->data; | |
| 4263 | ||
| 4264 | if (tag->name && !strncmp(tag->name, prefix, len)) | |
| 4265 | gtk_text_buffer_remove_tag(imhtml->text_buffer, tag, &iter, e); | |
| 4266 | } | |
| 4267 | ||
| 4268 | g_slist_free(tags); | |
| 4269 | } | |
| 8061 | 4270 | } |
| 8677 | 4271 | } |
| 4272 | ||
| 4273 | static void remove_font_size(GtkIMHtml *imhtml, GtkTextIter *i, GtkTextIter *e, gboolean homo) | |
| 4274 | { | |
| 4275 | remove_tag_by_prefix(imhtml, i, e, "FONT SIZE ", 10, homo); | |
| 4276 | } | |
| 4277 | ||
| 4278 | static void remove_font_face(GtkIMHtml *imhtml, GtkTextIter *i, GtkTextIter *e, gboolean homo) | |
| 4279 | { | |
| 4280 | remove_tag_by_prefix(imhtml, i, e, "FONT FACE ", 10, homo); | |
| 4281 | } | |
| 4282 | ||
| 4283 | static void remove_font_forecolor(GtkIMHtml *imhtml, GtkTextIter *i, GtkTextIter *e, gboolean homo) | |
| 4284 | { | |
| 4285 | remove_tag_by_prefix(imhtml, i, e, "FORECOLOR ", 10, homo); | |
| 4286 | } | |
| 4287 | ||
| 4288 | static void remove_font_backcolor(GtkIMHtml *imhtml, GtkTextIter *i, GtkTextIter *e, gboolean homo) | |
| 4289 | { | |
| 4290 | remove_tag_by_prefix(imhtml, i, e, "BACKCOLOR ", 10, homo); | |
| 4291 | } | |
| 4292 | ||
| 10776 | 4293 | static void remove_font_background(GtkIMHtml *imhtml, GtkTextIter *i, GtkTextIter *e, gboolean homo) |
| 4294 | { | |
| 4295 | remove_tag_by_prefix(imhtml, i, e, "BACKGROUND ", 10, homo); | |
| 4296 | } | |
| 4297 | ||
| 8677 | 4298 | static void remove_font_link(GtkIMHtml *imhtml, GtkTextIter *i, GtkTextIter *e, gboolean homo) |
| 4299 | { | |
| 4300 | remove_tag_by_prefix(imhtml, i, e, "LINK ", 5, homo); | |
| 4301 | } | |
| 4302 | ||
|
12672
673e2a1d2954
[gaim-migrate @ 15015]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12635
diff
changeset
|
4303 | static void |
|
673e2a1d2954
[gaim-migrate @ 15015]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12635
diff
changeset
|
4304 | imhtml_clear_formatting(GtkIMHtml *imhtml) |
|
673e2a1d2954
[gaim-migrate @ 15015]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12635
diff
changeset
|
4305 | { |
|
673e2a1d2954
[gaim-migrate @ 15015]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12635
diff
changeset
|
4306 | GtkTextIter start, end; |
|
673e2a1d2954
[gaim-migrate @ 15015]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12635
diff
changeset
|
4307 | |
|
12796
8fb3611a91e1
[gaim-migrate @ 15143]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12673
diff
changeset
|
4308 | if (!imhtml->editable) |
|
8fb3611a91e1
[gaim-migrate @ 15143]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12673
diff
changeset
|
4309 | return; |
|
8fb3611a91e1
[gaim-migrate @ 15143]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12673
diff
changeset
|
4310 | |
|
28935
84dbc0ca215d
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28932
diff
changeset
|
4311 | if (!imhtml_get_iter_bounds(imhtml, &start, &end)) |
|
84dbc0ca215d
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28932
diff
changeset
|
4312 | return; |
|
12672
673e2a1d2954
[gaim-migrate @ 15015]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12635
diff
changeset
|
4313 | |
|
673e2a1d2954
[gaim-migrate @ 15015]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12635
diff
changeset
|
4314 | 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
|
4315 | 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
|
4316 | 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
|
4317 | 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
|
4318 | remove_font_size(imhtml, &start, &end, FALSE); |
|
485977c61b47
[gaim-migrate @ 15587]
Richard Laager <rlaager@pidgin.im>
parents:
13138
diff
changeset
|
4319 | remove_font_face(imhtml, &start, &end, FALSE); |
|
485977c61b47
[gaim-migrate @ 15587]
Richard Laager <rlaager@pidgin.im>
parents:
13138
diff
changeset
|
4320 | remove_font_forecolor(imhtml, &start, &end, FALSE); |
|
485977c61b47
[gaim-migrate @ 15587]
Richard Laager <rlaager@pidgin.im>
parents:
13138
diff
changeset
|
4321 | remove_font_backcolor(imhtml, &start, &end, FALSE); |
|
485977c61b47
[gaim-migrate @ 15587]
Richard Laager <rlaager@pidgin.im>
parents:
13138
diff
changeset
|
4322 | remove_font_background(imhtml, &start, &end, FALSE); |
|
485977c61b47
[gaim-migrate @ 15587]
Richard Laager <rlaager@pidgin.im>
parents:
13138
diff
changeset
|
4323 | remove_font_link(imhtml, &start, &end, FALSE); |
|
12672
673e2a1d2954
[gaim-migrate @ 15015]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12635
diff
changeset
|
4324 | |
|
673e2a1d2954
[gaim-migrate @ 15015]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12635
diff
changeset
|
4325 | imhtml->edit.bold = 0; |
|
673e2a1d2954
[gaim-migrate @ 15015]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12635
diff
changeset
|
4326 | imhtml->edit.italic = 0; |
|
673e2a1d2954
[gaim-migrate @ 15015]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12635
diff
changeset
|
4327 | imhtml->edit.underline = 0; |
|
673e2a1d2954
[gaim-migrate @ 15015]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12635
diff
changeset
|
4328 | imhtml->edit.strike = 0; |
|
673e2a1d2954
[gaim-migrate @ 15015]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12635
diff
changeset
|
4329 | imhtml->edit.fontsize = 0; |
|
13224
485977c61b47
[gaim-migrate @ 15587]
Richard Laager <rlaager@pidgin.im>
parents:
13138
diff
changeset
|
4330 | |
|
485977c61b47
[gaim-migrate @ 15587]
Richard Laager <rlaager@pidgin.im>
parents:
13138
diff
changeset
|
4331 | g_free(imhtml->edit.fontface); |
|
485977c61b47
[gaim-migrate @ 15587]
Richard Laager <rlaager@pidgin.im>
parents:
13138
diff
changeset
|
4332 | imhtml->edit.fontface = NULL; |
|
485977c61b47
[gaim-migrate @ 15587]
Richard Laager <rlaager@pidgin.im>
parents:
13138
diff
changeset
|
4333 | |
|
485977c61b47
[gaim-migrate @ 15587]
Richard Laager <rlaager@pidgin.im>
parents:
13138
diff
changeset
|
4334 | g_free(imhtml->edit.forecolor); |
|
12672
673e2a1d2954
[gaim-migrate @ 15015]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12635
diff
changeset
|
4335 | imhtml->edit.forecolor = NULL; |
|
13224
485977c61b47
[gaim-migrate @ 15587]
Richard Laager <rlaager@pidgin.im>
parents:
13138
diff
changeset
|
4336 | |
|
485977c61b47
[gaim-migrate @ 15587]
Richard Laager <rlaager@pidgin.im>
parents:
13138
diff
changeset
|
4337 | g_free(imhtml->edit.backcolor); |
|
12672
673e2a1d2954
[gaim-migrate @ 15015]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12635
diff
changeset
|
4338 | imhtml->edit.backcolor = NULL; |
|
13224
485977c61b47
[gaim-migrate @ 15587]
Richard Laager <rlaager@pidgin.im>
parents:
13138
diff
changeset
|
4339 | |
|
485977c61b47
[gaim-migrate @ 15587]
Richard Laager <rlaager@pidgin.im>
parents:
13138
diff
changeset
|
4340 | g_free(imhtml->edit.background); |
|
12672
673e2a1d2954
[gaim-migrate @ 15015]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12635
diff
changeset
|
4341 | imhtml->edit.background = NULL; |
|
673e2a1d2954
[gaim-migrate @ 15015]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12635
diff
changeset
|
4342 | } |
|
673e2a1d2954
[gaim-migrate @ 15015]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12635
diff
changeset
|
4343 | |
| 8677 | 4344 | /* Editable stuff */ |
| 4345 | static void preinsert_cb(GtkTextBuffer *buffer, GtkTextIter *iter, gchar *text, gint len, GtkIMHtml *imhtml) | |
| 4346 | { | |
| 4347 | imhtml->insert_offset = gtk_text_iter_get_offset(iter); | |
| 4348 | } | |
| 4349 | ||
| 10169 | 4350 | static void insert_ca_cb(GtkTextBuffer *buffer, GtkTextIter *arg1, GtkTextChildAnchor *arg2, gpointer user_data) |
| 4351 | { | |
| 4352 | GtkTextIter start; | |
| 4353 | ||
| 4354 | start = *arg1; | |
| 4355 | gtk_text_iter_backward_char(&start); | |
| 4356 | ||
| 4357 | gtk_imhtml_apply_tags_on_insert(user_data, &start, arg1); | |
| 4358 | } | |
| 4359 | ||
| 8677 | 4360 | static void insert_cb(GtkTextBuffer *buffer, GtkTextIter *end, gchar *text, gint len, GtkIMHtml *imhtml) |
| 4361 | { | |
| 4362 | GtkTextIter start; | |
| 4363 | ||
| 4364 | if (!len) | |
| 4365 | return; | |
| 4366 | ||
| 4367 | start = *end; | |
| 4368 | gtk_text_iter_set_offset(&start, imhtml->insert_offset); | |
| 4369 | ||
| 10169 | 4370 | gtk_imhtml_apply_tags_on_insert(imhtml, &start, end); |
| 4371 | } | |
| 4372 | ||
|
12673
4c8a20955e0b
[gaim-migrate @ 15016]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12672
diff
changeset
|
4373 | 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
|
4374 | { |
|
4c8a20955e0b
[gaim-migrate @ 15016]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12672
diff
changeset
|
4375 | GSList *tags, *l; |
|
4c8a20955e0b
[gaim-migrate @ 15016]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12672
diff
changeset
|
4376 | |
|
4c8a20955e0b
[gaim-migrate @ 15016]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12672
diff
changeset
|
4377 | tags = gtk_text_iter_get_tags(start); |
|
4c8a20955e0b
[gaim-migrate @ 15016]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12672
diff
changeset
|
4378 | for (l = tags; l != NULL; l = l->next) { |
|
4c8a20955e0b
[gaim-migrate @ 15016]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12672
diff
changeset
|
4379 | GtkTextTag *tag = GTK_TEXT_TAG(l->data); |
|
4c8a20955e0b
[gaim-migrate @ 15016]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12672
diff
changeset
|
4380 | |
|
4c8a20955e0b
[gaim-migrate @ 15016]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12672
diff
changeset
|
4381 | if (tag && /* Remove the formatting only if */ |
|
4c8a20955e0b
[gaim-migrate @ 15016]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12672
diff
changeset
|
4382 | gtk_text_iter_starts_word(start) && /* beginning of a word */ |
|
4c8a20955e0b
[gaim-migrate @ 15016]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12672
diff
changeset
|
4383 | 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
|
4384 | (!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
|
4385 | gtk_text_iter_ends_tag(end, tag))) { |
|
4c8a20955e0b
[gaim-migrate @ 15016]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12672
diff
changeset
|
4386 | 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
|
4387 | if (tag->name && |
|
4c8a20955e0b
[gaim-migrate @ 15016]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12672
diff
changeset
|
4388 | strncmp(tag->name, "LINK ", 5) == 0 && imhtml->edit.link) { |
|
4c8a20955e0b
[gaim-migrate @ 15016]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12672
diff
changeset
|
4389 | gtk_imhtml_toggle_link(imhtml, NULL); |
|
4c8a20955e0b
[gaim-migrate @ 15016]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12672
diff
changeset
|
4390 | } |
|
14097
0c340861ab79
[gaim-migrate @ 16638]
Mark Doliner <markdoliner@pidgin.im>
parents:
14010
diff
changeset
|
4391 | } |
|
12673
4c8a20955e0b
[gaim-migrate @ 15016]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12672
diff
changeset
|
4392 | } |
|
4c8a20955e0b
[gaim-migrate @ 15016]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12672
diff
changeset
|
4393 | g_slist_free(tags); |
|
4c8a20955e0b
[gaim-migrate @ 15016]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12672
diff
changeset
|
4394 | } |
|
4c8a20955e0b
[gaim-migrate @ 15016]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12672
diff
changeset
|
4395 | |
| 10169 | 4396 | static void gtk_imhtml_apply_tags_on_insert(GtkIMHtml *imhtml, GtkTextIter *start, GtkTextIter *end) |
| 4397 | { | |
| 8677 | 4398 | if (imhtml->edit.bold) |
| 10169 | 4399 | gtk_text_buffer_apply_tag_by_name(imhtml->text_buffer, "BOLD", start, end); |
| 8677 | 4400 | else |
| 10169 | 4401 | gtk_text_buffer_remove_tag_by_name(imhtml->text_buffer, "BOLD", start, end); |
| 8677 | 4402 | |
| 4403 | if (imhtml->edit.italic) | |
| 10169 | 4404 | gtk_text_buffer_apply_tag_by_name(imhtml->text_buffer, "ITALICS", start, end); |
| 8677 | 4405 | else |
| 10169 | 4406 | gtk_text_buffer_remove_tag_by_name(imhtml->text_buffer, "ITALICS", start, end); |
| 8677 | 4407 | |
| 4408 | if (imhtml->edit.underline) | |
| 10169 | 4409 | gtk_text_buffer_apply_tag_by_name(imhtml->text_buffer, "UNDERLINE", start, end); |
| 8677 | 4410 | else |
| 10169 | 4411 | gtk_text_buffer_remove_tag_by_name(imhtml->text_buffer, "UNDERLINE", start, end); |
| 8677 | 4412 | |
| 9924 | 4413 | if (imhtml->edit.strike) |
| 10169 | 4414 | gtk_text_buffer_apply_tag_by_name(imhtml->text_buffer, "STRIKE", start, end); |
| 9924 | 4415 | else |
| 10169 | 4416 | gtk_text_buffer_remove_tag_by_name(imhtml->text_buffer, "STRIKE", start, end); |
| 9924 | 4417 | |
| 8677 | 4418 | if (imhtml->edit.forecolor) { |
| 10169 | 4419 | remove_font_forecolor(imhtml, start, end, TRUE); |
| 8677 | 4420 | gtk_text_buffer_apply_tag(imhtml->text_buffer, |
| 4421 | find_font_forecolor_tag(imhtml, imhtml->edit.forecolor), | |
| 10169 | 4422 | start, end); |
| 8061 | 4423 | } |
| 4424 | ||
| 8677 | 4425 | if (imhtml->edit.backcolor) { |
| 10169 | 4426 | remove_font_backcolor(imhtml, start, end, TRUE); |
| 8677 | 4427 | gtk_text_buffer_apply_tag(imhtml->text_buffer, |
| 4428 | find_font_backcolor_tag(imhtml, imhtml->edit.backcolor), | |
| 10169 | 4429 | start, end); |
| 8677 | 4430 | } |
| 4431 | ||
| 10776 | 4432 | if (imhtml->edit.background) { |
| 4433 | remove_font_background(imhtml, start, end, TRUE); | |
| 4434 | gtk_text_buffer_apply_tag(imhtml->text_buffer, | |
| 4435 | find_font_background_tag(imhtml, imhtml->edit.background), | |
| 4436 | start, end); | |
| 4437 | } | |
| 8677 | 4438 | if (imhtml->edit.fontface) { |
| 10169 | 4439 | remove_font_face(imhtml, start, end, TRUE); |
| 8677 | 4440 | gtk_text_buffer_apply_tag(imhtml->text_buffer, |
| 4441 | find_font_face_tag(imhtml, imhtml->edit.fontface), | |
| 10169 | 4442 | start, end); |
| 8061 | 4443 | } |
| 8677 | 4444 | |
| 4445 | if (imhtml->edit.fontsize) { | |
| 10169 | 4446 | remove_font_size(imhtml, start, end, TRUE); |
| 8677 | 4447 | gtk_text_buffer_apply_tag(imhtml->text_buffer, |
| 4448 | find_font_size_tag(imhtml, imhtml->edit.fontsize), | |
| 10169 | 4449 | start, end); |
| 8677 | 4450 | } |
| 4451 | ||
| 4452 | if (imhtml->edit.link) { | |
| 10169 | 4453 | remove_font_link(imhtml, start, end, TRUE); |
| 8677 | 4454 | gtk_text_buffer_apply_tag(imhtml->text_buffer, |
| 4455 | imhtml->edit.link, | |
| 10169 | 4456 | start, end); |
| 8677 | 4457 | } |
| 8061 | 4458 | } |
| 4459 | ||
| 4460 | void gtk_imhtml_set_editable(GtkIMHtml *imhtml, gboolean editable) | |
| 4461 | { | |
| 4462 | gtk_text_view_set_editable(GTK_TEXT_VIEW(imhtml), editable); | |
|
8177
33b3a01c6318
[gaim-migrate @ 8891]
Mark Doliner <markdoliner@pidgin.im>
parents:
8149
diff
changeset
|
4463 | /* |
|
33b3a01c6318
[gaim-migrate @ 8891]
Mark Doliner <markdoliner@pidgin.im>
parents:
8149
diff
changeset
|
4464 | * We need a visible caret for accessibility, so mouseless |
|
33b3a01c6318
[gaim-migrate @ 8891]
Mark Doliner <markdoliner@pidgin.im>
parents:
8149
diff
changeset
|
4465 | * people can highlight stuff. |
|
33b3a01c6318
[gaim-migrate @ 8891]
Mark Doliner <markdoliner@pidgin.im>
parents:
8149
diff
changeset
|
4466 | */ |
|
33b3a01c6318
[gaim-migrate @ 8891]
Mark Doliner <markdoliner@pidgin.im>
parents:
8149
diff
changeset
|
4467 | /* gtk_text_view_set_cursor_visible(GTK_TEXT_VIEW(imhtml), editable); */ |
|
27031
6779a535047e
Avoid adding several callbacks on repeated invocations of gtk_imhtml_set_editable.
Daniel Atallah <datallah@pidgin.im>
parents:
26829
diff
changeset
|
4468 | if (editable && !imhtml->editable) { |
| 8677 | 4469 | 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
|
4470 | 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
|
4471 | g_signal_connect(G_OBJECT(imhtml), "backspace", G_CALLBACK(smart_backspace_cb), NULL); |
|
27031
6779a535047e
Avoid adding several callbacks on repeated invocations of gtk_imhtml_set_editable.
Daniel Atallah <datallah@pidgin.im>
parents:
26829
diff
changeset
|
4472 | } else if (!editable && imhtml->editable) { |
|
6779a535047e
Avoid adding several callbacks on repeated invocations of gtk_imhtml_set_editable.
Daniel Atallah <datallah@pidgin.im>
parents:
26829
diff
changeset
|
4473 | g_signal_handlers_disconnect_by_func(G_OBJECT(GTK_IMHTML(imhtml)->text_buffer), |
|
6779a535047e
Avoid adding several callbacks on repeated invocations of gtk_imhtml_set_editable.
Daniel Atallah <datallah@pidgin.im>
parents:
26829
diff
changeset
|
4474 | mark_set_cb, imhtml); |
|
6779a535047e
Avoid adding several callbacks on repeated invocations of gtk_imhtml_set_editable.
Daniel Atallah <datallah@pidgin.im>
parents:
26829
diff
changeset
|
4475 | g_signal_handlers_disconnect_by_func(G_OBJECT(imhtml), |
|
6779a535047e
Avoid adding several callbacks on repeated invocations of gtk_imhtml_set_editable.
Daniel Atallah <datallah@pidgin.im>
parents:
26829
diff
changeset
|
4476 | smart_backspace_cb, NULL); |
|
21765
b9271e416f6d
Patch from 'goutnet': Pressing backspace on a smiley will replace the smiley
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21644
diff
changeset
|
4477 | } |
|
27031
6779a535047e
Avoid adding several callbacks on repeated invocations of gtk_imhtml_set_editable.
Daniel Atallah <datallah@pidgin.im>
parents:
26829
diff
changeset
|
4478 | |
|
6779a535047e
Avoid adding several callbacks on repeated invocations of gtk_imhtml_set_editable.
Daniel Atallah <datallah@pidgin.im>
parents:
26829
diff
changeset
|
4479 | imhtml->editable = editable; |
|
6779a535047e
Avoid adding several callbacks on repeated invocations of gtk_imhtml_set_editable.
Daniel Atallah <datallah@pidgin.im>
parents:
26829
diff
changeset
|
4480 | imhtml->format_functions = GTK_IMHTML_ALL; |
| 8677 | 4481 | } |
| 4482 | ||
| 4483 | void gtk_imhtml_set_whole_buffer_formatting_only(GtkIMHtml *imhtml, gboolean wbfo) | |
| 4484 | { | |
| 4485 | g_return_if_fail(imhtml != NULL); | |
| 4486 | ||
| 4487 | imhtml->wbfo = wbfo; | |
| 8420 | 4488 | } |
| 4489 | ||
| 4490 | void gtk_imhtml_set_format_functions(GtkIMHtml *imhtml, GtkIMHtmlButtons buttons) | |
| 4491 | { | |
| 4492 | GObject *object = g_object_ref(G_OBJECT(imhtml)); | |
| 8677 | 4493 | imhtml->format_functions = buttons; |
| 8420 | 4494 | g_signal_emit(object, signals[BUTTONS_UPDATE], 0, buttons); |
| 4495 | g_object_unref(object); | |
| 8061 | 4496 | } |
| 4497 | ||
|
8788
a13634443a38
[gaim-migrate @ 9550]
Mark Doliner <markdoliner@pidgin.im>
parents:
8786
diff
changeset
|
4498 | GtkIMHtmlButtons gtk_imhtml_get_format_functions(GtkIMHtml *imhtml) |
|
a13634443a38
[gaim-migrate @ 9550]
Mark Doliner <markdoliner@pidgin.im>
parents:
8786
diff
changeset
|
4499 | { |
|
a13634443a38
[gaim-migrate @ 9550]
Mark Doliner <markdoliner@pidgin.im>
parents:
8786
diff
changeset
|
4500 | return imhtml->format_functions; |
|
a13634443a38
[gaim-migrate @ 9550]
Mark Doliner <markdoliner@pidgin.im>
parents:
8786
diff
changeset
|
4501 | } |
| 8516 | 4502 | |
| 4503 | void gtk_imhtml_get_current_format(GtkIMHtml *imhtml, gboolean *bold, | |
| 4504 | gboolean *italic, gboolean *underline) | |
| 8481 | 4505 | { |
|
12900
7fe519669e07
[gaim-migrate @ 15253]
Richard Laager <rlaager@pidgin.im>
parents:
12836
diff
changeset
|
4506 | if (bold != NULL) |
|
7fe519669e07
[gaim-migrate @ 15253]
Richard Laager <rlaager@pidgin.im>
parents:
12836
diff
changeset
|
4507 | (*bold) = imhtml->edit.bold; |
|
7fe519669e07
[gaim-migrate @ 15253]
Richard Laager <rlaager@pidgin.im>
parents:
12836
diff
changeset
|
4508 | if (italic != NULL) |
|
7fe519669e07
[gaim-migrate @ 15253]
Richard Laager <rlaager@pidgin.im>
parents:
12836
diff
changeset
|
4509 | (*italic) = imhtml->edit.italic; |
|
7fe519669e07
[gaim-migrate @ 15253]
Richard Laager <rlaager@pidgin.im>
parents:
12836
diff
changeset
|
4510 | if (underline != NULL) |
|
7fe519669e07
[gaim-migrate @ 15253]
Richard Laager <rlaager@pidgin.im>
parents:
12836
diff
changeset
|
4511 | (*underline) = imhtml->edit.underline; |
| 8481 | 4512 | } |
| 4513 | ||
| 9025 | 4514 | char * |
| 4515 | gtk_imhtml_get_current_fontface(GtkIMHtml *imhtml) | |
| 4516 | { | |
|
14097
0c340861ab79
[gaim-migrate @ 16638]
Mark Doliner <markdoliner@pidgin.im>
parents:
14010
diff
changeset
|
4517 | return g_strdup(imhtml->edit.fontface); |
| 9025 | 4518 | } |
| 4519 | ||
| 4520 | char * | |
| 4521 | gtk_imhtml_get_current_forecolor(GtkIMHtml *imhtml) | |
| 4522 | { | |
|
14097
0c340861ab79
[gaim-migrate @ 16638]
Mark Doliner <markdoliner@pidgin.im>
parents:
14010
diff
changeset
|
4523 | return g_strdup(imhtml->edit.forecolor); |
| 9025 | 4524 | } |
| 4525 | ||
| 4526 | char * | |
| 4527 | gtk_imhtml_get_current_backcolor(GtkIMHtml *imhtml) | |
| 4528 | { | |
|
14097
0c340861ab79
[gaim-migrate @ 16638]
Mark Doliner <markdoliner@pidgin.im>
parents:
14010
diff
changeset
|
4529 | return g_strdup(imhtml->edit.backcolor); |
| 9025 | 4530 | } |
| 4531 | ||
|
11267
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
4532 | char * |
|
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
4533 | gtk_imhtml_get_current_background(GtkIMHtml *imhtml) |
|
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
4534 | { |
|
14097
0c340861ab79
[gaim-migrate @ 16638]
Mark Doliner <markdoliner@pidgin.im>
parents:
14010
diff
changeset
|
4535 | return g_strdup(imhtml->edit.background); |
|
11267
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
4536 | } |
|
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
4537 | |
| 9025 | 4538 | gint |
| 4539 | gtk_imhtml_get_current_fontsize(GtkIMHtml *imhtml) | |
| 4540 | { | |
| 4541 | return imhtml->edit.fontsize; | |
| 4542 | } | |
| 4543 | ||
| 8061 | 4544 | gboolean gtk_imhtml_get_editable(GtkIMHtml *imhtml) |
| 4545 | { | |
| 4546 | return imhtml->editable; | |
| 4547 | } | |
| 4548 | ||
|
11269
ca63789d57b9
[gaim-migrate @ 13451]
Richard Laager <rlaager@pidgin.im>
parents:
11267
diff
changeset
|
4549 | void |
|
ca63789d57b9
[gaim-migrate @ 13451]
Richard Laager <rlaager@pidgin.im>
parents:
11267
diff
changeset
|
4550 | gtk_imhtml_clear_formatting(GtkIMHtml *imhtml) |
|
ca63789d57b9
[gaim-migrate @ 13451]
Richard Laager <rlaager@pidgin.im>
parents:
11267
diff
changeset
|
4551 | { |
|
11275
cdcc651d7ecd
[gaim-migrate @ 13461]
Richard Laager <rlaager@pidgin.im>
parents:
11269
diff
changeset
|
4552 | GObject *object; |
|
cdcc651d7ecd
[gaim-migrate @ 13461]
Richard Laager <rlaager@pidgin.im>
parents:
11269
diff
changeset
|
4553 | |
|
cdcc651d7ecd
[gaim-migrate @ 13461]
Richard Laager <rlaager@pidgin.im>
parents:
11269
diff
changeset
|
4554 | object = g_object_ref(G_OBJECT(imhtml)); |
|
cdcc651d7ecd
[gaim-migrate @ 13461]
Richard Laager <rlaager@pidgin.im>
parents:
11269
diff
changeset
|
4555 | g_signal_emit(object, signals[CLEAR_FORMAT], 0); |
|
11276
aec923529d31
[gaim-migrate @ 13463]
Richard Laager <rlaager@pidgin.im>
parents:
11275
diff
changeset
|
4556 | |
|
11269
ca63789d57b9
[gaim-migrate @ 13451]
Richard Laager <rlaager@pidgin.im>
parents:
11267
diff
changeset
|
4557 | gtk_widget_grab_focus(GTK_WIDGET(imhtml)); |
|
11276
aec923529d31
[gaim-migrate @ 13463]
Richard Laager <rlaager@pidgin.im>
parents:
11275
diff
changeset
|
4558 | |
|
aec923529d31
[gaim-migrate @ 13463]
Richard Laager <rlaager@pidgin.im>
parents:
11275
diff
changeset
|
4559 | g_object_unref(object); |
|
11269
ca63789d57b9
[gaim-migrate @ 13451]
Richard Laager <rlaager@pidgin.im>
parents:
11267
diff
changeset
|
4560 | } |
|
ca63789d57b9
[gaim-migrate @ 13451]
Richard Laager <rlaager@pidgin.im>
parents:
11267
diff
changeset
|
4561 | |
| 8677 | 4562 | /* |
| 4563 | * I had this crazy idea about changing the text cursor color to reflex the foreground color | |
| 4564 | * of the text about to be entered. This is the place you'd do it, along with the place where | |
| 4565 | * we actually set a new foreground color. | |
| 15884 | 4566 | * I may not do this, because people will bitch about Purple overriding their gtk theme's cursor |
| 8677 | 4567 | * colors. |
| 4568 | * | |
| 4569 | * Just in case I do do this, I asked about what to set the secondary text cursor to. | |
| 4570 | * | |
| 8719 | 4571 | * (12:45:27) ?? ???: secondary_cursor_color = (rgb(background) + rgb(primary_cursor_color) ) / 2 |
| 4572 | * (12:45:55) ?? ???: understand? | |
| 8677 | 4573 | * (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
|
4574 | * (12:46:56) ?? ???: u might need to extract separate each color from RGB |
| 8677 | 4575 | */ |
| 4576 | ||
| 4577 | static void mark_set_cb(GtkTextBuffer *buffer, GtkTextIter *arg1, GtkTextMark *mark, | |
| 4578 | GtkIMHtml *imhtml) | |
| 4579 | { | |
| 4580 | GSList *tags, *l; | |
| 4581 | GtkTextIter iter; | |
| 4582 | ||
| 4583 | if (mark != gtk_text_buffer_get_insert(buffer)) | |
| 4584 | return; | |
| 4585 | ||
| 4586 | if (!gtk_text_buffer_get_char_count(buffer)) | |
| 4587 | return; | |
| 4588 | ||
| 9924 | 4589 | 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
|
4590 | g_free(imhtml->edit.forecolor); |
| 8677 | 4591 | imhtml->edit.forecolor = NULL; |
|
14097
0c340861ab79
[gaim-migrate @ 16638]
Mark Doliner <markdoliner@pidgin.im>
parents:
14010
diff
changeset
|
4592 | |
|
0c340861ab79
[gaim-migrate @ 16638]
Mark Doliner <markdoliner@pidgin.im>
parents:
14010
diff
changeset
|
4593 | g_free(imhtml->edit.backcolor); |
| 8677 | 4594 | imhtml->edit.backcolor = NULL; |
|
14097
0c340861ab79
[gaim-migrate @ 16638]
Mark Doliner <markdoliner@pidgin.im>
parents:
14010
diff
changeset
|
4595 | |
|
0c340861ab79
[gaim-migrate @ 16638]
Mark Doliner <markdoliner@pidgin.im>
parents:
14010
diff
changeset
|
4596 | g_free(imhtml->edit.fontface); |
| 8677 | 4597 | imhtml->edit.fontface = NULL; |
|
14097
0c340861ab79
[gaim-migrate @ 16638]
Mark Doliner <markdoliner@pidgin.im>
parents:
14010
diff
changeset
|
4598 | |
| 8677 | 4599 | imhtml->edit.fontsize = 0; |
| 4600 | imhtml->edit.link = NULL; | |
| 4601 | ||
| 4602 | gtk_text_buffer_get_iter_at_mark(imhtml->text_buffer, &iter, mark); | |
| 4603 | ||
| 4604 | ||
| 4605 | if (gtk_text_iter_is_end(&iter)) | |
| 4606 | tags = gtk_text_iter_get_toggled_tags(&iter, FALSE); | |
| 4607 | else | |
| 4608 | tags = gtk_text_iter_get_tags(&iter); | |
| 4609 | ||
| 4610 | for (l = tags; l != NULL; l = l->next) { | |
| 4611 | GtkTextTag *tag = GTK_TEXT_TAG(l->data); | |
| 4612 | ||
| 4613 | if (tag->name) { | |
| 4614 | if (strcmp(tag->name, "BOLD") == 0) | |
| 4615 | imhtml->edit.bold = TRUE; | |
|
13138
4d3bd039da3e
[gaim-migrate @ 15499]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13137
diff
changeset
|
4616 | else if (strcmp(tag->name, "ITALICS") == 0) |
| 8677 | 4617 | imhtml->edit.italic = TRUE; |
|
13138
4d3bd039da3e
[gaim-migrate @ 15499]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13137
diff
changeset
|
4618 | else if (strcmp(tag->name, "UNDERLINE") == 0) |
| 8677 | 4619 | imhtml->edit.underline = TRUE; |
|
13138
4d3bd039da3e
[gaim-migrate @ 15499]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13137
diff
changeset
|
4620 | else if (strcmp(tag->name, "STRIKE") == 0) |
| 9924 | 4621 | imhtml->edit.strike = TRUE; |
|
13138
4d3bd039da3e
[gaim-migrate @ 15499]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13137
diff
changeset
|
4622 | else if (strncmp(tag->name, "FORECOLOR ", 10) == 0) |
| 8677 | 4623 | imhtml->edit.forecolor = g_strdup(&(tag->name)[10]); |
|
13138
4d3bd039da3e
[gaim-migrate @ 15499]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13137
diff
changeset
|
4624 | else if (strncmp(tag->name, "BACKCOLOR ", 10) == 0) |
| 8677 | 4625 | imhtml->edit.backcolor = g_strdup(&(tag->name)[10]); |
|
13138
4d3bd039da3e
[gaim-migrate @ 15499]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13137
diff
changeset
|
4626 | else if (strncmp(tag->name, "FONT FACE ", 10) == 0) |
| 8677 | 4627 | imhtml->edit.fontface = g_strdup(&(tag->name)[10]); |
|
13138
4d3bd039da3e
[gaim-migrate @ 15499]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13137
diff
changeset
|
4628 | else if (strncmp(tag->name, "FONT SIZE ", 10) == 0) |
| 8677 | 4629 | imhtml->edit.fontsize = strtol(&(tag->name)[10], NULL, 10); |
|
13138
4d3bd039da3e
[gaim-migrate @ 15499]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13137
diff
changeset
|
4630 | else if ((strncmp(tag->name, "LINK ", 5) == 0) && !gtk_text_iter_is_end(&iter)) |
| 8677 | 4631 | imhtml->edit.link = tag; |
| 4632 | } | |
| 4633 | } | |
| 4634 | ||
| 4635 | g_slist_free(tags); | |
| 4636 | } | |
| 4637 | ||
|
12605
7390627a6aaf
[gaim-migrate @ 14940]
Richard Laager <rlaager@pidgin.im>
parents:
12600
diff
changeset
|
4638 | static void imhtml_emit_signal_for_format(GtkIMHtml *imhtml, GtkIMHtmlButtons button) |
|
7390627a6aaf
[gaim-migrate @ 14940]
Richard Laager <rlaager@pidgin.im>
parents:
12600
diff
changeset
|
4639 | { |
|
7390627a6aaf
[gaim-migrate @ 14940]
Richard Laager <rlaager@pidgin.im>
parents:
12600
diff
changeset
|
4640 | GObject *object; |
|
7390627a6aaf
[gaim-migrate @ 14940]
Richard Laager <rlaager@pidgin.im>
parents:
12600
diff
changeset
|
4641 | |
|
7390627a6aaf
[gaim-migrate @ 14940]
Richard Laager <rlaager@pidgin.im>
parents:
12600
diff
changeset
|
4642 | g_return_if_fail(imhtml != NULL); |
|
7390627a6aaf
[gaim-migrate @ 14940]
Richard Laager <rlaager@pidgin.im>
parents:
12600
diff
changeset
|
4643 | |
|
7390627a6aaf
[gaim-migrate @ 14940]
Richard Laager <rlaager@pidgin.im>
parents:
12600
diff
changeset
|
4644 | object = g_object_ref(G_OBJECT(imhtml)); |
|
7390627a6aaf
[gaim-migrate @ 14940]
Richard Laager <rlaager@pidgin.im>
parents:
12600
diff
changeset
|
4645 | g_signal_emit(object, signals[TOGGLE_FORMAT], 0, button); |
|
7390627a6aaf
[gaim-migrate @ 14940]
Richard Laager <rlaager@pidgin.im>
parents:
12600
diff
changeset
|
4646 | g_object_unref(object); |
|
7390627a6aaf
[gaim-migrate @ 14940]
Richard Laager <rlaager@pidgin.im>
parents:
12600
diff
changeset
|
4647 | } |
|
7390627a6aaf
[gaim-migrate @ 14940]
Richard Laager <rlaager@pidgin.im>
parents:
12600
diff
changeset
|
4648 | |
|
11267
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
4649 | static void imhtml_toggle_bold(GtkIMHtml *imhtml) |
| 8061 | 4650 | { |
| 8677 | 4651 | GtkTextIter start, end; |
| 4652 | ||
| 4653 | imhtml->edit.bold = !imhtml->edit.bold; | |
| 4654 | ||
|
28935
84dbc0ca215d
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28932
diff
changeset
|
4655 | if (!imhtml_get_iter_bounds(imhtml, &start, &end)) |
|
84dbc0ca215d
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28932
diff
changeset
|
4656 | return; |
|
84dbc0ca215d
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28932
diff
changeset
|
4657 | |
|
84dbc0ca215d
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28932
diff
changeset
|
4658 | if (imhtml->edit.bold) |
|
84dbc0ca215d
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28932
diff
changeset
|
4659 | gtk_text_buffer_apply_tag_by_name(imhtml->text_buffer, "BOLD", &start, &end); |
|
84dbc0ca215d
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28932
diff
changeset
|
4660 | else |
|
84dbc0ca215d
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28932
diff
changeset
|
4661 | gtk_text_buffer_remove_tag_by_name(imhtml->text_buffer, "BOLD", &start, &end); |
| 8061 | 4662 | } |
| 4663 | ||
|
11267
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
4664 | void gtk_imhtml_toggle_bold(GtkIMHtml *imhtml) |
| 8061 | 4665 | { |
|
12605
7390627a6aaf
[gaim-migrate @ 14940]
Richard Laager <rlaager@pidgin.im>
parents:
12600
diff
changeset
|
4666 | imhtml_emit_signal_for_format(imhtml, GTK_IMHTML_BOLD); |
|
11267
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
4667 | } |
|
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
4668 | |
|
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
4669 | static void imhtml_toggle_italic(GtkIMHtml *imhtml) |
|
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
4670 | { |
| 8677 | 4671 | GtkTextIter start, end; |
| 4672 | ||
| 4673 | imhtml->edit.italic = !imhtml->edit.italic; | |
| 4674 | ||
|
28935
84dbc0ca215d
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28932
diff
changeset
|
4675 | if (!imhtml_get_iter_bounds(imhtml, &start, &end)) |
|
84dbc0ca215d
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28932
diff
changeset
|
4676 | return; |
|
84dbc0ca215d
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28932
diff
changeset
|
4677 | |
|
84dbc0ca215d
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28932
diff
changeset
|
4678 | if (imhtml->edit.italic) |
|
84dbc0ca215d
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28932
diff
changeset
|
4679 | gtk_text_buffer_apply_tag_by_name(imhtml->text_buffer, "ITALICS", &start, &end); |
|
84dbc0ca215d
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28932
diff
changeset
|
4680 | else |
|
84dbc0ca215d
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28932
diff
changeset
|
4681 | gtk_text_buffer_remove_tag_by_name(imhtml->text_buffer, "ITALICS", &start, &end); |
| 8061 | 4682 | } |
| 4683 | ||
|
11267
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
4684 | void gtk_imhtml_toggle_italic(GtkIMHtml *imhtml) |
| 8061 | 4685 | { |
|
12605
7390627a6aaf
[gaim-migrate @ 14940]
Richard Laager <rlaager@pidgin.im>
parents:
12600
diff
changeset
|
4686 | imhtml_emit_signal_for_format(imhtml, GTK_IMHTML_ITALIC); |
|
7390627a6aaf
[gaim-migrate @ 14940]
Richard Laager <rlaager@pidgin.im>
parents:
12600
diff
changeset
|
4687 | } |
|
11267
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
4688 | |
|
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
4689 | static void imhtml_toggle_underline(GtkIMHtml *imhtml) |
|
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
4690 | { |
| 8677 | 4691 | GtkTextIter start, end; |
| 4692 | ||
| 4693 | imhtml->edit.underline = !imhtml->edit.underline; | |
| 4694 | ||
|
28935
84dbc0ca215d
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28932
diff
changeset
|
4695 | if (!imhtml_get_iter_bounds(imhtml, &start, &end)) |
|
84dbc0ca215d
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28932
diff
changeset
|
4696 | return; |
|
84dbc0ca215d
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28932
diff
changeset
|
4697 | |
|
84dbc0ca215d
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28932
diff
changeset
|
4698 | if (imhtml->edit.underline) |
|
84dbc0ca215d
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28932
diff
changeset
|
4699 | gtk_text_buffer_apply_tag_by_name(imhtml->text_buffer, "UNDERLINE", &start, &end); |
|
84dbc0ca215d
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28932
diff
changeset
|
4700 | else |
|
84dbc0ca215d
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28932
diff
changeset
|
4701 | gtk_text_buffer_remove_tag_by_name(imhtml->text_buffer, "UNDERLINE", &start, &end); |
| 8061 | 4702 | } |
| 4703 | ||
|
11267
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
4704 | void gtk_imhtml_toggle_underline(GtkIMHtml *imhtml) |
| 9924 | 4705 | { |
|
12605
7390627a6aaf
[gaim-migrate @ 14940]
Richard Laager <rlaager@pidgin.im>
parents:
12600
diff
changeset
|
4706 | imhtml_emit_signal_for_format(imhtml, GTK_IMHTML_UNDERLINE); |
|
11267
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
4707 | } |
|
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
4708 | |
|
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
4709 | static void imhtml_toggle_strike(GtkIMHtml *imhtml) |
|
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
4710 | { |
| 9924 | 4711 | GtkTextIter start, end; |
| 4712 | ||
| 4713 | imhtml->edit.strike = !imhtml->edit.strike; | |
| 4714 | ||
|
28935
84dbc0ca215d
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28932
diff
changeset
|
4715 | if (!imhtml_get_iter_bounds(imhtml, &start, &end)) |
|
84dbc0ca215d
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28932
diff
changeset
|
4716 | return; |
|
84dbc0ca215d
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28932
diff
changeset
|
4717 | |
|
84dbc0ca215d
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28932
diff
changeset
|
4718 | if (imhtml->edit.strike) |
|
84dbc0ca215d
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28932
diff
changeset
|
4719 | gtk_text_buffer_apply_tag_by_name(imhtml->text_buffer, "STRIKE", &start, &end); |
|
84dbc0ca215d
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28932
diff
changeset
|
4720 | else |
|
84dbc0ca215d
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28932
diff
changeset
|
4721 | gtk_text_buffer_remove_tag_by_name(imhtml->text_buffer, "STRIKE", &start, &end); |
|
11267
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
4722 | } |
|
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
4723 | |
|
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
4724 | void gtk_imhtml_toggle_strike(GtkIMHtml *imhtml) |
|
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
4725 | { |
|
12605
7390627a6aaf
[gaim-migrate @ 14940]
Richard Laager <rlaager@pidgin.im>
parents:
12600
diff
changeset
|
4726 | imhtml_emit_signal_for_format(imhtml, GTK_IMHTML_STRIKE); |
| 9924 | 4727 | } |
| 4728 | ||
| 8061 | 4729 | void gtk_imhtml_font_set_size(GtkIMHtml *imhtml, gint size) |
| 4730 | { | |
| 9025 | 4731 | GObject *object; |
| 8677 | 4732 | GtkTextIter start, end; |
| 8061 | 4733 | |
| 4734 | imhtml->edit.fontsize = size; | |
| 4735 | ||
|
28935
84dbc0ca215d
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28932
diff
changeset
|
4736 | if (!imhtml_get_iter_bounds(imhtml, &start, &end)) |
|
84dbc0ca215d
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28932
diff
changeset
|
4737 | return; |
|
84dbc0ca215d
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28932
diff
changeset
|
4738 | |
|
84dbc0ca215d
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28932
diff
changeset
|
4739 | remove_font_size(imhtml, &start, &end, imhtml->wbfo); |
|
84dbc0ca215d
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28932
diff
changeset
|
4740 | gtk_text_buffer_apply_tag(imhtml->text_buffer, |
|
84dbc0ca215d
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28932
diff
changeset
|
4741 | find_font_size_tag(imhtml, imhtml->edit.fontsize), &start, &end); |
| 8677 | 4742 | |
| 9025 | 4743 | object = g_object_ref(G_OBJECT(imhtml)); |
|
11267
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
4744 | g_signal_emit(object, signals[TOGGLE_FORMAT], 0, GTK_IMHTML_SHRINK | GTK_IMHTML_GROW); |
| 9025 | 4745 | g_object_unref(object); |
| 8061 | 4746 | } |
| 4747 | ||
|
11267
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
4748 | static void imhtml_font_shrink(GtkIMHtml *imhtml) |
| 8061 | 4749 | { |
| 8677 | 4750 | GtkTextIter start, end; |
| 4751 | ||
| 8061 | 4752 | if (imhtml->edit.fontsize == 1) |
| 4753 | return; | |
| 4754 | ||
| 8677 | 4755 | if (!imhtml->edit.fontsize) |
| 4756 | imhtml->edit.fontsize = 2; | |
| 4757 | else | |
| 4758 | imhtml->edit.fontsize--; | |
| 4759 | ||
|
28935
84dbc0ca215d
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28932
diff
changeset
|
4760 | if (!imhtml_get_iter_bounds(imhtml, &start, &end)) |
|
84dbc0ca215d
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28932
diff
changeset
|
4761 | return; |
|
84dbc0ca215d
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28932
diff
changeset
|
4762 | remove_font_size(imhtml, &start, &end, imhtml->wbfo); |
|
84dbc0ca215d
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28932
diff
changeset
|
4763 | gtk_text_buffer_apply_tag(imhtml->text_buffer, |
| 8677 | 4764 | find_font_size_tag(imhtml, imhtml->edit.fontsize), &start, &end); |
|
11267
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
4765 | } |
|
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
4766 | |
|
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
4767 | void gtk_imhtml_font_shrink(GtkIMHtml *imhtml) |
|
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
4768 | { |
|
12605
7390627a6aaf
[gaim-migrate @ 14940]
Richard Laager <rlaager@pidgin.im>
parents:
12600
diff
changeset
|
4769 | imhtml_emit_signal_for_format(imhtml, GTK_IMHTML_SHRINK); |
| 8061 | 4770 | } |
| 4771 | ||
|
11267
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
4772 | static void imhtml_font_grow(GtkIMHtml *imhtml) |
| 8061 | 4773 | { |
| 8677 | 4774 | GtkTextIter start, end; |
| 4775 | ||
| 8061 | 4776 | if (imhtml->edit.fontsize == MAX_FONT_SIZE) |
| 4777 | return; | |
| 4778 | ||
| 8677 | 4779 | if (!imhtml->edit.fontsize) |
| 4780 | imhtml->edit.fontsize = 4; | |
| 4781 | else | |
| 4782 | imhtml->edit.fontsize++; | |
| 4783 | ||
|
28935
84dbc0ca215d
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28932
diff
changeset
|
4784 | if (!imhtml_get_iter_bounds(imhtml, &start, &end)) |
|
84dbc0ca215d
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28932
diff
changeset
|
4785 | return; |
|
84dbc0ca215d
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28932
diff
changeset
|
4786 | remove_font_size(imhtml, &start, &end, imhtml->wbfo); |
|
84dbc0ca215d
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28932
diff
changeset
|
4787 | gtk_text_buffer_apply_tag(imhtml->text_buffer, |
|
84dbc0ca215d
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28932
diff
changeset
|
4788 | find_font_size_tag(imhtml, imhtml->edit.fontsize), &start, &end); |
|
11267
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
4789 | } |
|
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
4790 | |
|
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
4791 | void gtk_imhtml_font_grow(GtkIMHtml *imhtml) |
|
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
4792 | { |
|
12605
7390627a6aaf
[gaim-migrate @ 14940]
Richard Laager <rlaager@pidgin.im>
parents:
12600
diff
changeset
|
4793 | imhtml_emit_signal_for_format(imhtml, GTK_IMHTML_GROW); |
| 8061 | 4794 | } |
| 4795 | ||
|
13225
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4796 | 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
|
4797 | void (*remove_func)(GtkIMHtml *imhtml, GtkTextIter *i, GtkTextIter *e, gboolean homo), |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4798 | GtkTextTag *(find_func)(GtkIMHtml *imhtml, gchar *color), GtkIMHtmlButtons button) |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4799 | { |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4800 | GObject *object; |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4801 | GtkTextIter start; |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4802 | GtkTextIter end; |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4803 | |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4804 | g_free(*edit_field); |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4805 | *edit_field = NULL; |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4806 | |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4807 | if (value && strcmp(value, "") != 0) |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4808 | { |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4809 | *edit_field = g_strdup(value); |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4810 | |
|
28935
84dbc0ca215d
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28932
diff
changeset
|
4811 | if (imhtml_get_iter_bounds(imhtml, &start, &end)) { |
|
84dbc0ca215d
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28932
diff
changeset
|
4812 | remove_func(imhtml, &start, &end, imhtml->wbfo); |
|
13225
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4813 | gtk_text_buffer_apply_tag(imhtml->text_buffer, |
|
28935
84dbc0ca215d
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28932
diff
changeset
|
4814 | find_func(imhtml, *edit_field), &start, &end); |
|
13225
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4815 | } |
|
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 | else |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4818 | { |
|
28935
84dbc0ca215d
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28932
diff
changeset
|
4819 | if (imhtml_get_iter_bounds(imhtml, &start, &end)) |
|
84dbc0ca215d
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28932
diff
changeset
|
4820 | remove_func(imhtml, &start, &end, TRUE); /* 'TRUE' or 'imhtml->wbfo'? */ |
|
13225
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4821 | } |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4822 | |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4823 | object = g_object_ref(G_OBJECT(imhtml)); |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4824 | g_signal_emit(object, signals[TOGGLE_FORMAT], 0, button); |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4825 | g_object_unref(object); |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4826 | |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4827 | return *edit_field != NULL; |
| 10776 | 4828 | } |
| 4829 | ||
| 8061 | 4830 | gboolean gtk_imhtml_toggle_forecolor(GtkIMHtml *imhtml, const char *color) |
| 4831 | { | |
|
13225
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4832 | return gtk_imhtml_toggle_str_tag(imhtml, color, &imhtml->edit.forecolor, |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4833 | remove_font_forecolor, find_font_forecolor_tag, |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4834 | GTK_IMHTML_FORECOLOR); |
| 8061 | 4835 | } |
| 4836 | ||
| 4837 | gboolean gtk_imhtml_toggle_backcolor(GtkIMHtml *imhtml, const char *color) | |
| 4838 | { | |
|
13225
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4839 | return gtk_imhtml_toggle_str_tag(imhtml, color, &imhtml->edit.backcolor, |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4840 | remove_font_backcolor, find_font_backcolor_tag, |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4841 | GTK_IMHTML_BACKCOLOR); |
| 10776 | 4842 | } |
| 4843 | ||
| 4844 | gboolean gtk_imhtml_toggle_background(GtkIMHtml *imhtml, const char *color) | |
| 4845 | { | |
|
13225
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4846 | return gtk_imhtml_toggle_str_tag(imhtml, color, &imhtml->edit.background, |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4847 | remove_font_background, find_font_background_tag, |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4848 | GTK_IMHTML_BACKGROUND); |
| 8061 | 4849 | } |
| 4850 | ||
| 4851 | gboolean gtk_imhtml_toggle_fontface(GtkIMHtml *imhtml, const char *face) | |
| 4852 | { | |
|
13225
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4853 | return gtk_imhtml_toggle_str_tag(imhtml, face, &imhtml->edit.fontface, |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4854 | remove_font_face, find_font_face_tag, |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4855 | GTK_IMHTML_FACE); |
| 8061 | 4856 | } |
| 4857 | ||
| 8677 | 4858 | void gtk_imhtml_toggle_link(GtkIMHtml *imhtml, const char *url) |
| 8061 | 4859 | { |
| 9025 | 4860 | GObject *object; |
| 8677 | 4861 | GtkTextIter start, end; |
| 4862 | GtkTextTag *linktag; | |
| 4863 | static guint linkno = 0; | |
| 4864 | gchar str[48]; | |
| 9007 | 4865 | GdkColor *color = NULL; |
| 8677 | 4866 | |
| 4867 | imhtml->edit.link = NULL; | |
| 4868 | ||
| 4869 | if (url) { | |
| 4870 | g_snprintf(str, sizeof(str), "LINK %d", linkno++); | |
| 4871 | str[47] = '\0'; | |
| 4872 | ||
| 9007 | 4873 | gtk_widget_style_get(GTK_WIDGET(imhtml), "hyperlink-color", &color, NULL); |
| 9008 | 4874 | if (color) { |
| 9007 | 4875 | imhtml->edit.link = linktag = gtk_text_buffer_create_tag(imhtml->text_buffer, str, "foreground-gdk", color, "underline", PANGO_UNDERLINE_SINGLE, NULL); |
| 9008 | 4876 | gdk_color_free(color); |
| 4877 | } else { | |
| 9007 | 4878 | imhtml->edit.link = linktag = gtk_text_buffer_create_tag(imhtml->text_buffer, str, "foreground", "blue", "underline", PANGO_UNDERLINE_SINGLE, NULL); |
| 9008 | 4879 | } |
| 8677 | 4880 | g_object_set_data_full(G_OBJECT(linktag), "link_url", g_strdup(url), g_free); |
| 4881 | g_signal_connect(G_OBJECT(linktag), "event", G_CALLBACK(tag_event), NULL); | |
| 4882 | ||
|
11276
aec923529d31
[gaim-migrate @ 13463]
Richard Laager <rlaager@pidgin.im>
parents:
11275
diff
changeset
|
4883 | if (imhtml->editable && gtk_text_buffer_get_selection_bounds(imhtml->text_buffer, &start, &end)) { |
| 8677 | 4884 | remove_font_link(imhtml, &start, &end, FALSE); |
| 4885 | gtk_text_buffer_apply_tag(imhtml->text_buffer, linktag, &start, &end); | |
| 4886 | } | |
| 4887 | } | |
| 9025 | 4888 | |
| 4889 | object = g_object_ref(G_OBJECT(imhtml)); | |
| 4890 | g_signal_emit(object, signals[TOGGLE_FORMAT], 0, GTK_IMHTML_LINK); | |
| 4891 | g_object_unref(object); | |
| 8677 | 4892 | } |
| 4893 | ||
| 4894 | void gtk_imhtml_insert_link(GtkIMHtml *imhtml, GtkTextMark *mark, const char *url, const char *text) | |
| 4895 | { | |
| 8061 | 4896 | GtkTextIter iter; |
| 8677 | 4897 | |
|
25899
da25a7ed382e
The first thing gtk_text_buffer_delete_selection does is call
Mark Doliner <markdoliner@pidgin.im>
parents:
25888
diff
changeset
|
4898 | /* Delete any currently selected text */ |
|
da25a7ed382e
The first thing gtk_text_buffer_delete_selection does is call
Mark Doliner <markdoliner@pidgin.im>
parents:
25888
diff
changeset
|
4899 | gtk_text_buffer_delete_selection(imhtml->text_buffer, TRUE, TRUE); |
| 9599 | 4900 | |
| 8677 | 4901 | gtk_imhtml_toggle_link(imhtml, url); |
| 8061 | 4902 | gtk_text_buffer_get_iter_at_mark(imhtml->text_buffer, &iter, mark); |
| 8677 | 4903 | gtk_text_buffer_insert(imhtml->text_buffer, &iter, text, -1); |
| 4904 | gtk_imhtml_toggle_link(imhtml, NULL); | |
| 8061 | 4905 | } |
| 4906 | ||
| 4907 | void gtk_imhtml_insert_smiley(GtkIMHtml *imhtml, const char *sml, char *smiley) | |
| 4908 | { | |
| 8677 | 4909 | GtkTextMark *mark; |
| 8061 | 4910 | GtkTextIter iter; |
| 8677 | 4911 | |
|
25899
da25a7ed382e
The first thing gtk_text_buffer_delete_selection does is call
Mark Doliner <markdoliner@pidgin.im>
parents:
25888
diff
changeset
|
4912 | /* Delete any currently selected text */ |
|
da25a7ed382e
The first thing gtk_text_buffer_delete_selection does is call
Mark Doliner <markdoliner@pidgin.im>
parents:
25888
diff
changeset
|
4913 | gtk_text_buffer_delete_selection(imhtml->text_buffer, TRUE, TRUE); |
|
11750
63f951281392
[gaim-migrate @ 14041]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11701
diff
changeset
|
4914 | |
| 8677 | 4915 | mark = gtk_text_buffer_get_insert(imhtml->text_buffer); |
| 4916 | ||
| 4917 | gtk_text_buffer_get_iter_at_mark(imhtml->text_buffer, &iter, mark); | |
|
29288
56ad38f4d192
Explicitly mark user-interaction when inserting smiley.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
29153
diff
changeset
|
4918 | gtk_text_buffer_begin_user_action(imhtml->text_buffer); |
| 8677 | 4919 | gtk_imhtml_insert_smiley_at_iter(imhtml, sml, smiley, &iter); |
|
29288
56ad38f4d192
Explicitly mark user-interaction when inserting smiley.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
29153
diff
changeset
|
4920 | gtk_text_buffer_end_user_action(imhtml->text_buffer); |
| 8677 | 4921 | } |
| 4922 | ||
| 13552 | 4923 | static gboolean |
| 4924 | image_expose(GtkWidget *widget, GdkEventExpose *event, gpointer user_data) | |
| 4925 | { | |
| 4926 | GTK_WIDGET_CLASS(GTK_WIDGET_GET_CLASS(widget))->expose_event(widget, event); | |
| 4927 | ||
| 4928 | return TRUE; | |
| 4929 | } | |
| 4930 | ||
|
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
|
4931 | /* 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
|
4932 | 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
|
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 | 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
|
4935 | 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
|
4936 | 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
|
4937 | 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
|
4938 | 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
|
4939 | 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
|
4940 | 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
|
4941 | 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
|
4942 | } |
|
aa5b9456e258
Fixes #213 This allows only 20 animated smileys to be animnating at a time
Sean Egan <seanegan@pidgin.im>
parents:
16291
diff
changeset
|
4943 | 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
|
4944 | } |
|
aa5b9456e258
Fixes #213 This allows only 20 animated smileys to be animnating at a time
Sean Egan <seanegan@pidgin.im>
parents:
16291
diff
changeset
|
4945 | } |
|
aa5b9456e258
Fixes #213 This allows only 20 animated smileys to be animnating at a time
Sean Egan <seanegan@pidgin.im>
parents:
16291
diff
changeset
|
4946 | |
|
32295
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
4947 | static gboolean gtk_imhtml_smiley_clicked(GtkWidget *w, GdkEvent *event, GtkIMHtmlSmiley *smiley) |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
4948 | { |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
4949 | GdkPixbufAnimation *anim = NULL; |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
4950 | GtkIMHtmlImageSave *save = NULL; |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
4951 | gboolean ret; |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
4952 | |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
4953 | if (event->type != GDK_BUTTON_RELEASE || ((GdkEventButton*)event)->button != 3) |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
4954 | return FALSE; |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
4955 | |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
4956 | anim = gtk_smiley_get_image(smiley); |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
4957 | if (!anim) |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
4958 | return FALSE; |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
4959 | |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
4960 | save = g_new0(GtkIMHtmlImageSave, 1); |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
4961 | save->image = (GtkIMHtmlScalable *)gtk_imhtml_animation_new(anim, smiley->smile, 0); |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
4962 | save->data = smiley->data; /* Do not need to memdup here, since the smiley is not |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
4963 | destroyed before this GtkIMHtmlImageSave */ |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
4964 | save->datasize = smiley->datasize; |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
4965 | ret = gtk_imhtml_image_clicked(w, event, save); |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
4966 | g_object_set_data_full(G_OBJECT(w), "image-data", save->image, (GDestroyNotify)gtk_imhtml_animation_free); |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
4967 | g_object_set_data_full(G_OBJECT(w), "image-save-data", save, (GDestroyNotify)g_free); |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
4968 | return ret; |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
4969 | } |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
4970 | |
| 8677 | 4971 | void gtk_imhtml_insert_smiley_at_iter(GtkIMHtml *imhtml, const char *sml, char *smiley, GtkTextIter *iter) |
| 4972 | { | |
| 8061 | 4973 | GdkPixbuf *pixbuf = NULL; |
| 4974 | GdkPixbufAnimation *annipixbuf = NULL; | |
| 4975 | 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
|
4976 | GtkTextChildAnchor *anchor = NULL; |
|
29378
a783b23a05da
Fix CVE-2010-0423, a denial of service attack due to the parsing
Mark Doliner <markdoliner@pidgin.im>
parents:
29371
diff
changeset
|
4977 | char *unescaped; |
|
a783b23a05da
Fix CVE-2010-0423, a denial of service attack due to the parsing
Mark Doliner <markdoliner@pidgin.im>
parents:
29371
diff
changeset
|
4978 | GtkIMHtmlSmiley *imhtml_smiley; |
|
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 | GtkWidget *ebox = NULL; |
|
29378
a783b23a05da
Fix CVE-2010-0423, a denial of service attack due to the parsing
Mark Doliner <markdoliner@pidgin.im>
parents:
29371
diff
changeset
|
4980 | int numsmileys_thismsg, numsmileys_total; |
|
a783b23a05da
Fix CVE-2010-0423, a denial of service attack due to the parsing
Mark Doliner <markdoliner@pidgin.im>
parents:
29371
diff
changeset
|
4981 | |
|
a783b23a05da
Fix CVE-2010-0423, a denial of service attack due to the parsing
Mark Doliner <markdoliner@pidgin.im>
parents:
29371
diff
changeset
|
4982 | /* |
|
a783b23a05da
Fix CVE-2010-0423, a denial of service attack due to the parsing
Mark Doliner <markdoliner@pidgin.im>
parents:
29371
diff
changeset
|
4983 | * This GtkIMHtml has the maximum number of smileys allowed, so don't |
|
a783b23a05da
Fix CVE-2010-0423, a denial of service attack due to the parsing
Mark Doliner <markdoliner@pidgin.im>
parents:
29371
diff
changeset
|
4984 | * add any more. We do this for performance reasons, because smileys |
|
a783b23a05da
Fix CVE-2010-0423, a denial of service attack due to the parsing
Mark Doliner <markdoliner@pidgin.im>
parents:
29371
diff
changeset
|
4985 | * are apparently pretty inefficient. Hopefully we can remove this |
|
a783b23a05da
Fix CVE-2010-0423, a denial of service attack due to the parsing
Mark Doliner <markdoliner@pidgin.im>
parents:
29371
diff
changeset
|
4986 | * restriction when we're using a better HTML widget. |
|
a783b23a05da
Fix CVE-2010-0423, a denial of service attack due to the parsing
Mark Doliner <markdoliner@pidgin.im>
parents:
29371
diff
changeset
|
4987 | */ |
|
31192
57ce28c7314f
gtkimhtml: Display "<3" instead of "<3" after too many smileys in convo
Paul Aurich <darkrain42@pidgin.im>
parents:
30706
diff
changeset
|
4988 | unescaped = purple_unescape_html(smiley); |
|
29378
a783b23a05da
Fix CVE-2010-0423, a denial of service attack due to the parsing
Mark Doliner <markdoliner@pidgin.im>
parents:
29371
diff
changeset
|
4989 | numsmileys_thismsg = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(imhtml), "gtkimhtml_numsmileys_thismsg")); |
|
a783b23a05da
Fix CVE-2010-0423, a denial of service attack due to the parsing
Mark Doliner <markdoliner@pidgin.im>
parents:
29371
diff
changeset
|
4990 | if (numsmileys_thismsg >= 30) { |
|
31192
57ce28c7314f
gtkimhtml: Display "<3" instead of "<3" after too many smileys in convo
Paul Aurich <darkrain42@pidgin.im>
parents:
30706
diff
changeset
|
4991 | gtk_text_buffer_insert(imhtml->text_buffer, iter, unescaped, -1); |
|
57ce28c7314f
gtkimhtml: Display "<3" instead of "<3" after too many smileys in convo
Paul Aurich <darkrain42@pidgin.im>
parents:
30706
diff
changeset
|
4992 | g_free(unescaped); |
|
29378
a783b23a05da
Fix CVE-2010-0423, a denial of service attack due to the parsing
Mark Doliner <markdoliner@pidgin.im>
parents:
29371
diff
changeset
|
4993 | return; |
|
a783b23a05da
Fix CVE-2010-0423, a denial of service attack due to the parsing
Mark Doliner <markdoliner@pidgin.im>
parents:
29371
diff
changeset
|
4994 | } |
|
a783b23a05da
Fix CVE-2010-0423, a denial of service attack due to the parsing
Mark Doliner <markdoliner@pidgin.im>
parents:
29371
diff
changeset
|
4995 | numsmileys_total = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(imhtml), "gtkimhtml_numsmileys_total")); |
|
a783b23a05da
Fix CVE-2010-0423, a denial of service attack due to the parsing
Mark Doliner <markdoliner@pidgin.im>
parents:
29371
diff
changeset
|
4996 | if (numsmileys_total >= 300) { |
|
31192
57ce28c7314f
gtkimhtml: Display "<3" instead of "<3" after too many smileys in convo
Paul Aurich <darkrain42@pidgin.im>
parents:
30706
diff
changeset
|
4997 | gtk_text_buffer_insert(imhtml->text_buffer, iter, unescaped, -1); |
|
57ce28c7314f
gtkimhtml: Display "<3" instead of "<3" after too many smileys in convo
Paul Aurich <darkrain42@pidgin.im>
parents:
30706
diff
changeset
|
4998 | g_free(unescaped); |
|
29378
a783b23a05da
Fix CVE-2010-0423, a denial of service attack due to the parsing
Mark Doliner <markdoliner@pidgin.im>
parents:
29371
diff
changeset
|
4999 | return; |
|
a783b23a05da
Fix CVE-2010-0423, a denial of service attack due to the parsing
Mark Doliner <markdoliner@pidgin.im>
parents:
29371
diff
changeset
|
5000 | } |
|
a783b23a05da
Fix CVE-2010-0423, a denial of service attack due to the parsing
Mark Doliner <markdoliner@pidgin.im>
parents:
29371
diff
changeset
|
5001 | |
|
a783b23a05da
Fix CVE-2010-0423, a denial of service attack due to the parsing
Mark Doliner <markdoliner@pidgin.im>
parents:
29371
diff
changeset
|
5002 | imhtml_smiley = gtk_imhtml_smiley_get(imhtml, sml, unescaped); |
| 8061 | 5003 | |
| 10526 | 5004 | if (imhtml->format_functions & GTK_IMHTML_SMILEY) { |
|
29378
a783b23a05da
Fix CVE-2010-0423, a denial of service attack due to the parsing
Mark Doliner <markdoliner@pidgin.im>
parents:
29371
diff
changeset
|
5005 | annipixbuf = imhtml_smiley ? gtk_smiley_get_image(imhtml_smiley) : NULL; |
| 10526 | 5006 | if (annipixbuf) { |
| 5007 | if (gdk_pixbuf_animation_is_static_image(annipixbuf)) { | |
|
10522
d505522bcc93
[gaim-migrate @ 11838]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10504
diff
changeset
|
5008 | pixbuf = gdk_pixbuf_animation_get_static_image(annipixbuf); |
| 10526 | 5009 | if (pixbuf) |
|
10522
d505522bcc93
[gaim-migrate @ 11838]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10504
diff
changeset
|
5010 | icon = gtk_image_new_from_pixbuf(pixbuf); |
|
d505522bcc93
[gaim-migrate @ 11838]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10504
diff
changeset
|
5011 | } else { |
|
d505522bcc93
[gaim-migrate @ 11838]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10504
diff
changeset
|
5012 | 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
|
5013 | 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
|
5014 | 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
|
5015 | 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
|
5016 | 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
|
5017 | 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
|
5018 | 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
|
5019 | 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
|
5020 | 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
|
5021 | 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
|
5022 | 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
|
5023 | 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
|
5024 | } |
|
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
|
5025 | } |
|
aa5b9456e258
Fixes #213 This allows only 20 animated smileys to be animnating at a time
Sean Egan <seanegan@pidgin.im>
parents:
16291
diff
changeset
|
5026 | } 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
|
5027 | 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
|
5028 | } |
|
aa5b9456e258
Fixes #213 This allows only 20 animated smileys to be animnating at a time
Sean Egan <seanegan@pidgin.im>
parents:
16291
diff
changeset
|
5029 | 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
|
5030 | g_queue_push_tail(imhtml->animations, icon); |
|
10522
d505522bcc93
[gaim-migrate @ 11838]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10504
diff
changeset
|
5031 | } |
| 8061 | 5032 | } |
| 5033 | } | |
| 5034 | ||
|
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
|
5035 | 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
|
5036 | ebox = gtk_event_box_new(); |
|
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
|
5037 | gtk_event_box_set_visible_window(GTK_EVENT_BOX(ebox), 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
|
5038 | 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
|
5039 | } |
|
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
|
5040 | |
| 8061 | 5041 | if (icon) { |
| 8890 | 5042 | anchor = gtk_text_buffer_create_child_anchor(imhtml->text_buffer, iter); |
| 29371 | 5043 | g_object_set_data_full(G_OBJECT(anchor), "gtkimhtml_plaintext", g_strdup(unescaped), g_free); |
| 5044 | g_object_set_data_full(G_OBJECT(anchor), "gtkimhtml_tiptext", g_strdup(unescaped), g_free); | |
| 8890 | 5045 | g_object_set_data_full(G_OBJECT(anchor), "gtkimhtml_htmltext", g_strdup(smiley), g_free); |
| 5046 | ||
| 13552 | 5047 | /* This catches the expose events generated by animated |
| 5048 | * images, and ensures that they are handled by the image | |
| 5049 | * itself, without propagating to the textview and causing | |
| 5050 | * a complete refresh */ | |
| 5051 | g_signal_connect(G_OBJECT(icon), "expose-event", G_CALLBACK(image_expose), NULL); | |
| 5052 | ||
| 8061 | 5053 | 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
|
5054 | 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
|
5055 | 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
|
5056 | gtk_text_view_add_child_at_anchor(GTK_TEXT_VIEW(imhtml), ebox ? ebox : icon, anchor); |
|
29378
a783b23a05da
Fix CVE-2010-0423, a denial of service attack due to the parsing
Mark Doliner <markdoliner@pidgin.im>
parents:
29371
diff
changeset
|
5057 | |
|
a783b23a05da
Fix CVE-2010-0423, a denial of service attack due to the parsing
Mark Doliner <markdoliner@pidgin.im>
parents:
29371
diff
changeset
|
5058 | g_object_set_data(G_OBJECT(imhtml), "gtkimhtml_numsmileys_thismsg", GINT_TO_POINTER(numsmileys_thismsg + 1)); |
|
a783b23a05da
Fix CVE-2010-0423, a denial of service attack due to the parsing
Mark Doliner <markdoliner@pidgin.im>
parents:
29371
diff
changeset
|
5059 | g_object_set_data(G_OBJECT(imhtml), "gtkimhtml_numsmileys_total", GINT_TO_POINTER(numsmileys_total + 1)); |
|
11525
1d06283bdcc9
[gaim-migrate @ 13773]
Francesco Fracassi <ffracassi@users.sourceforge.net>
parents:
11485
diff
changeset
|
5060 | } 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
|
5061 | 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
|
5062 | 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
|
5063 | 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
|
5064 | GtkWidget *img = gtk_image_new_from_stock(GTK_STOCK_MISSING_IMAGE, GTK_ICON_SIZE_MENU); |
|
2cc9edf33feb
Allow saving custom smileys by right-clicking on them. And use the custom smileys only on the received messages, not for the system/etc. messages.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16385
diff
changeset
|
5065 | 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
|
5066 | gtk_widget_show(img); |
| 29371 | 5067 | g_object_set_data_full(G_OBJECT(anchor), "gtkimhtml_plaintext", g_strdup(unescaped), g_free); |
| 5068 | g_object_set_data_full(G_OBJECT(anchor), "gtkimhtml_tiptext", g_strdup(unescaped), g_free); | |
|
27173
e601bcf2e1a6
We want to see what the missing custom smiley stands for.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27125
diff
changeset
|
5069 | g_object_set_data_full(G_OBJECT(anchor), "gtkimhtml_htmltext", g_strdup(smiley), g_free); |
|
17009
2cc9edf33feb
Allow saving custom smileys by right-clicking on them. And use the custom smileys only on the received messages, not for the system/etc. messages.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16385
diff
changeset
|
5070 | 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
|
5071 | } |
|
29378
a783b23a05da
Fix CVE-2010-0423, a denial of service attack due to the parsing
Mark Doliner <markdoliner@pidgin.im>
parents:
29371
diff
changeset
|
5072 | |
|
a783b23a05da
Fix CVE-2010-0423, a denial of service attack due to the parsing
Mark Doliner <markdoliner@pidgin.im>
parents:
29371
diff
changeset
|
5073 | g_object_set_data(G_OBJECT(imhtml), "gtkimhtml_numsmileys_thismsg", GINT_TO_POINTER(numsmileys_thismsg + 1)); |
|
a783b23a05da
Fix CVE-2010-0423, a denial of service attack due to the parsing
Mark Doliner <markdoliner@pidgin.im>
parents:
29371
diff
changeset
|
5074 | g_object_set_data(G_OBJECT(imhtml), "gtkimhtml_numsmileys_total", GINT_TO_POINTER(numsmileys_total + 1)); |
| 8890 | 5075 | } else { |
|
31192
57ce28c7314f
gtkimhtml: Display "<3" instead of "<3" after too many smileys in convo
Paul Aurich <darkrain42@pidgin.im>
parents:
30706
diff
changeset
|
5076 | gtk_text_buffer_insert(imhtml->text_buffer, iter, unescaped, -1); |
| 8061 | 5077 | } |
| 8890 | 5078 | |
|
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
|
5079 | 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
|
5080 | 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
|
5081 | } |
|
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
|
5082 | |
| 8890 | 5083 | g_free(unescaped); |
| 8061 | 5084 | } |
| 5085 | ||
| 8962 | 5086 | void gtk_imhtml_insert_image_at_iter(GtkIMHtml *imhtml, int id, GtkTextIter *iter) |
| 5087 | { | |
|
18151
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
5088 | GdkPixbufAnimation *anim = NULL; |
| 8962 | 5089 | const char *filename = NULL; |
| 5090 | gpointer image; | |
| 5091 | GdkRectangle rect; | |
| 5092 | GtkIMHtmlScalable *scalable = NULL; | |
|
11224
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
5093 | struct scalable_data *sd; |
| 8962 | 5094 | int minus; |
| 5095 | ||
| 5096 | if (!imhtml->funcs || !imhtml->funcs->image_get || | |
| 5097 | !imhtml->funcs->image_get_size || !imhtml->funcs->image_get_data || | |
| 5098 | !imhtml->funcs->image_get_filename || !imhtml->funcs->image_ref || | |
| 5099 | !imhtml->funcs->image_unref) | |
| 5100 | return; | |
| 5101 | ||
| 5102 | image = imhtml->funcs->image_get(id); | |
| 5103 | ||
| 5104 | if (image) { | |
| 5105 | gpointer data; | |
| 5106 | size_t len; | |
| 5107 | ||
| 5108 | data = imhtml->funcs->image_get_data(image); | |
| 5109 | len = imhtml->funcs->image_get_size(image); | |
|
31889
96183796df0c
Start looking at the GError parameter every time we call these functions:
Mark Doliner <markdoliner@pidgin.im>
parents:
31310
diff
changeset
|
5110 | if (data && len) |
|
96183796df0c
Start looking at the GError parameter every time we call these functions:
Mark Doliner <markdoliner@pidgin.im>
parents:
31310
diff
changeset
|
5111 | anim = pidgin_pixbuf_anim_from_data(data, len); |
| 8962 | 5112 | |
| 5113 | } | |
| 5114 | ||
|
18151
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
5115 | if (anim) { |
|
11299
06bb44ed0cf3
[gaim-migrate @ 13499]
Richard Laager <rlaager@pidgin.im>
parents:
11276
diff
changeset
|
5116 | struct im_image_data *t = g_new(struct im_image_data, 1); |
| 8962 | 5117 | filename = imhtml->funcs->image_get_filename(image); |
| 5118 | imhtml->funcs->image_ref(id); | |
|
11224
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
5119 | t->id = id; |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
5120 | 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
|
5121 | 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
|
5122 | 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
|
5123 | g_object_unref(G_OBJECT(anim)); |
| 8962 | 5124 | } else { |
|
18151
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
5125 | GdkPixbuf *pixbuf; |
| 8962 | 5126 | pixbuf = gtk_widget_render_icon(GTK_WIDGET(imhtml), GTK_STOCK_MISSING_IMAGE, |
| 5127 | 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
|
5128 | 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
|
5129 | g_object_unref(G_OBJECT(pixbuf)); |
| 8962 | 5130 | } |
| 5131 | ||
|
11224
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
5132 | 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
|
5133 | sd->scalable = scalable; |
|
11233
28c0f184a2d4
[gaim-migrate @ 13373]
Daniel Atallah <datallah@pidgin.im>
parents:
11224
diff
changeset
|
5134 | sd->mark = gtk_text_buffer_create_mark(imhtml->text_buffer, NULL, iter, TRUE); |
| 8962 | 5135 | gtk_text_view_get_visible_rect(GTK_TEXT_VIEW(imhtml), &rect); |
| 5136 | scalable->add_to(scalable, imhtml, iter); | |
| 5137 | minus = gtk_text_view_get_left_margin(GTK_TEXT_VIEW(imhtml)) + | |
| 5138 | gtk_text_view_get_right_margin(GTK_TEXT_VIEW(imhtml)); | |
| 5139 | scalable->scale(scalable, rect.width - minus, rect.height); | |
|
11224
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
5140 | imhtml->scalables = g_list_append(imhtml->scalables, sd); |
| 8962 | 5141 | } |
| 5142 | ||
| 8677 | 5143 | static const gchar *tag_to_html_start(GtkTextTag *tag) |
| 8061 | 5144 | { |
| 8677 | 5145 | const gchar *name; |
| 5146 | static gchar buf[1024]; | |
| 5147 | ||
| 5148 | name = tag->name; | |
| 5149 | g_return_val_if_fail(name != NULL, ""); | |
| 5150 | ||
| 5151 | if (strcmp(name, "BOLD") == 0) { | |
| 5152 | return "<b>"; | |
| 5153 | } else if (strcmp(name, "ITALICS") == 0) { | |
| 5154 | return "<i>"; | |
| 5155 | } else if (strcmp(name, "UNDERLINE") == 0) { | |
| 5156 | return "<u>"; | |
| 9924 | 5157 | } else if (strcmp(name, "STRIKE") == 0) { |
| 5158 | return "<s>"; | |
| 8677 | 5159 | } else if (strncmp(name, "LINK ", 5) == 0) { |
| 5160 | char *tmp = g_object_get_data(G_OBJECT(tag), "link_url"); | |
| 5161 | if (tmp) { | |
| 5162 | g_snprintf(buf, sizeof(buf), "<a href=\"%s\">", tmp); | |
| 5163 | buf[sizeof(buf)-1] = '\0'; | |
| 5164 | return buf; | |
| 5165 | } else { | |
| 5166 | return ""; | |
| 5167 | } | |
| 5168 | } else if (strncmp(name, "FORECOLOR ", 10) == 0) { | |
| 5169 | g_snprintf(buf, sizeof(buf), "<font color=\"%s\">", &name[10]); | |
| 5170 | return buf; | |
| 5171 | } else if (strncmp(name, "BACKCOLOR ", 10) == 0) { | |
| 5172 | g_snprintf(buf, sizeof(buf), "<font back=\"%s\">", &name[10]); | |
| 5173 | return buf; | |
| 10776 | 5174 | } else if (strncmp(name, "BACKGROUND ", 10) == 0) { |
| 5175 | g_snprintf(buf, sizeof(buf), "<body bgcolor=\"%s\">", &name[11]); | |
| 5176 | return buf; | |
| 8677 | 5177 | } else if (strncmp(name, "FONT FACE ", 10) == 0) { |
| 5178 | g_snprintf(buf, sizeof(buf), "<font face=\"%s\">", &name[10]); | |
| 5179 | return buf; | |
| 5180 | } else if (strncmp(name, "FONT SIZE ", 10) == 0) { | |
| 5181 | g_snprintf(buf, sizeof(buf), "<font size=\"%s\">", &name[10]); | |
| 5182 | return buf; | |
| 5183 | } else { | |
|
23308
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5184 | char *str = buf; |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5185 | gboolean isset; |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5186 | int ivalue = 0; |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5187 | GdkColor *color = NULL; |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5188 | GObject *obj = G_OBJECT(tag); |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5189 | gboolean empty = TRUE; |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5190 | |
|
23310
e34473be13db
Get rid of the boldness of the bold timestamps.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23308
diff
changeset
|
5191 | 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
|
5192 | |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5193 | /* Weight */ |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5194 | 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
|
5195 | if (isset) { |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5196 | const char *weight = ""; |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5197 | if (ivalue >= PANGO_WEIGHT_ULTRABOLD) |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5198 | weight = "bolder"; |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5199 | else if (ivalue >= PANGO_WEIGHT_BOLD) |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5200 | weight = "bold"; |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5201 | else if (ivalue >= PANGO_WEIGHT_NORMAL) |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5202 | weight = "normal"; |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5203 | else |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5204 | weight = "lighter"; |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5205 | |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5206 | 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
|
5207 | empty = FALSE; |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5208 | } |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5209 | |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5210 | /* Foreground color */ |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5211 | 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
|
5212 | if (isset && color) { |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5213 | 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
|
5214 | "color: #%02x%02x%02x;", |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5215 | 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
|
5216 | empty = FALSE; |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5217 | } |
|
23466
7380df2e12f1
Patch from Andrew Gaul that fixes another leak:
Ka-Hing Cheung <khc@pidgin.im>
parents:
23465
diff
changeset
|
5218 | gdk_color_free(color); |
|
23308
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5219 | |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5220 | /* Background color */ |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5221 | 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
|
5222 | if (isset && color) { |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5223 | 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
|
5224 | "background: #%02x%02x%02x;", |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5225 | 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
|
5226 | empty = FALSE; |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5227 | } |
|
23466
7380df2e12f1
Patch from Andrew Gaul that fixes another leak:
Ka-Hing Cheung <khc@pidgin.im>
parents:
23465
diff
changeset
|
5228 | gdk_color_free(color); |
|
23308
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5229 | |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5230 | /* Underline */ |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5231 | 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
|
5232 | if (isset) { |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5233 | switch (ivalue) { |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5234 | case PANGO_UNDERLINE_NONE: |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5235 | case PANGO_UNDERLINE_ERROR: |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5236 | break; |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5237 | default: |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5238 | 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
|
5239 | empty = FALSE; |
|
23308
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5240 | } |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5241 | } |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5242 | |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5243 | g_snprintf(str, sizeof(buf) - (str - buf), "'>"); |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5244 | |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5245 | return (empty ? "" : buf); |
| 8677 | 5246 | } |
| 8061 | 5247 | } |
| 5248 | ||
| 8677 | 5249 | static const gchar *tag_to_html_end(GtkTextTag *tag) |
| 8061 | 5250 | { |
| 8677 | 5251 | const gchar *name; |
| 5252 | ||
| 5253 | name = tag->name; | |
| 5254 | g_return_val_if_fail(name != NULL, ""); | |
| 5255 | ||
| 5256 | if (strcmp(name, "BOLD") == 0) { | |
| 5257 | return "</b>"; | |
| 5258 | } else if (strcmp(name, "ITALICS") == 0) { | |
| 5259 | return "</i>"; | |
| 5260 | } else if (strcmp(name, "UNDERLINE") == 0) { | |
| 5261 | return "</u>"; | |
| 9924 | 5262 | } else if (strcmp(name, "STRIKE") == 0) { |
| 5263 | return "</s>"; | |
| 8677 | 5264 | } else if (strncmp(name, "LINK ", 5) == 0) { |
| 5265 | return "</a>"; | |
| 5266 | } else if (strncmp(name, "FORECOLOR ", 10) == 0) { | |
| 5267 | return "</font>"; | |
| 5268 | } else if (strncmp(name, "BACKCOLOR ", 10) == 0) { | |
| 5269 | return "</font>"; | |
| 10776 | 5270 | } else if (strncmp(name, "BACKGROUND ", 10) == 0) { |
| 5271 | return "</body>"; | |
| 8677 | 5272 | } else if (strncmp(name, "FONT FACE ", 10) == 0) { |
| 5273 | return "</font>"; | |
| 5274 | } else if (strncmp(name, "FONT SIZE ", 10) == 0) { | |
| 5275 | return "</font>"; | |
| 5276 | } else { | |
|
23308
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5277 | 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
|
5278 | "size-set", "underline-set", NULL}; |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5279 | int i; |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5280 | for (i = 0; props[i]; i++) { |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5281 | gboolean set = FALSE; |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5282 | 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
|
5283 | if (set) |
|
23310
e34473be13db
Get rid of the boldness of the bold timestamps.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23308
diff
changeset
|
5284 | return "</span>"; |
|
23308
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5285 | } |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5286 | |
| 8677 | 5287 | return ""; |
| 5288 | } | |
| 5289 | } | |
| 5290 | ||
|
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
|
5291 | 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
|
5292 | 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
|
5293 | 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
|
5294 | 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
|
5295 | } 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
|
5296 | |
|
fc1df3495580
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23332
diff
changeset
|
5297 | 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
|
5298 | { |
|
fc1df3495580
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23332
diff
changeset
|
5299 | 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
|
5300 | 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
|
5301 | |
|
fc1df3495580
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23332
diff
changeset
|
5302 | 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
|
5303 | 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
|
5304 | 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
|
5305 | 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
|
5306 | 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
|
5307 | 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
|
5308 | |
|
fc1df3495580
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23332
diff
changeset
|
5309 | 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
|
5310 | 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
|
5311 | 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
|
5312 | 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
|
5313 | 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
|
5314 | } |
|
fc1df3495580
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23332
diff
changeset
|
5315 | |
|
fc1df3495580
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23332
diff
changeset
|
5316 | 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
|
5317 | { |
|
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 | 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
|
5319 | 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
|
5320 | 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
|
5321 | } |
|
fc1df3495580
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23332
diff
changeset
|
5322 | |
| 8677 | 5323 | static gboolean tag_ends_here(GtkTextTag *tag, GtkTextIter *iter, GtkTextIter *niter) |
| 5324 | { | |
| 5325 | return ((gtk_text_iter_has_tag(iter, GTK_TEXT_TAG(tag)) && | |
| 5326 | !gtk_text_iter_has_tag(niter, GTK_TEXT_TAG(tag))) || | |
| 5327 | gtk_text_iter_is_end(niter)); | |
| 8061 | 5328 | } |
| 5329 | ||
| 5330 | /* Basic notion here: traverse through the text buffer one-by-one, non-character elements, such | |
| 5331 | * as smileys and IM images are represented by the Unicode "unknown" character. Handle them. Else | |
| 8677 | 5332 | * check for tags that are toggled on, insert their html form, and push them on the queue. Then insert |
| 5333 | * 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
|
5334 | * Finally, replace <, >, &, and " with their HTML equivalent. |
| 8677 | 5335 | */ |
| 8061 | 5336 | char *gtk_imhtml_get_markup_range(GtkIMHtml *imhtml, GtkTextIter *start, GtkTextIter *end) |
| 5337 | { | |
| 5338 | gunichar c; | |
|
16143
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
5339 | GtkTextIter iter, next_iter, non_neutral_iter; |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
5340 | gboolean is_rtl_message = FALSE; |
| 8061 | 5341 | GString *str = g_string_new(""); |
| 8677 | 5342 | 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
|
5343 | GQueue *q; |
| 8677 | 5344 | 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
|
5345 | PidginTextTagData *tagdata; |
| 8677 | 5346 | |
| 5347 | q = g_queue_new(); | |
| 8061 | 5348 | |
| 5349 | gtk_text_iter_order(start, end); | |
|
16143
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
5350 | non_neutral_iter = next_iter = iter = *start; |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
5351 | gtk_text_iter_forward_char(&next_iter); |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
5352 | |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
5353 | /* Bi-directional text support */ |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
5354 | /* 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
|
5355 | #ifdef HAVE_PANGO14 |
| 16144 | 5356 | 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
|
5357 | && gtk_text_iter_forward_char(&non_neutral_iter)); |
| 16144 | 5358 | 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
|
5359 | is_rtl_message = TRUE; |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
5360 | 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
|
5361 | } |
|
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
|
5362 | #endif |
| 8677 | 5363 | |
| 9071 | 5364 | /* First add the tags that are already in progress (we don't care about non-printing tags)*/ |
| 8677 | 5365 | tags = gtk_text_iter_get_tags(start); |
| 5366 | ||
| 5367 | for (sl = tags; sl; sl = sl->next) { | |
| 5368 | tag = sl->data; | |
| 5369 | 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
|
5370 | 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
|
5371 | 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
|
5372 | 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
|
5373 | 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
|
5374 | } |
| 8061 | 5375 | } |
| 5376 | } | |
| 8677 | 5377 | g_slist_free(tags); |
| 8061 | 5378 | |
| 5379 | while ((c = gtk_text_iter_get_char(&iter)) != 0 && !gtk_text_iter_equal(&iter, end)) { | |
| 8677 | 5380 | |
| 5381 | tags = gtk_text_iter_get_tags(&iter); | |
| 5382 | ||
| 5383 | for (sl = tags; sl; sl = sl->next) { | |
| 5384 | tag = sl->data; | |
| 5385 | 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
|
5386 | 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
|
5387 | 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
|
5388 | 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
|
5389 | 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
|
5390 | } |
| 8677 | 5391 | } |
| 5392 | } | |
| 5393 | ||
| 8061 | 5394 | if (c == 0xFFFC) { |
| 5395 | GtkTextChildAnchor* anchor = gtk_text_iter_get_child_anchor(&iter); | |
| 9071 | 5396 | if (anchor) { |
| 5397 | char *text = g_object_get_data(G_OBJECT(anchor), "gtkimhtml_htmltext"); | |
| 5398 | if (text) | |
| 5399 | str = g_string_append(str, text); | |
| 5400 | } | |
|
11572
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
5401 | } else if (c == '<') { |
| 8677 | 5402 | str = g_string_append(str, "<"); |
| 5403 | } else if (c == '>') { | |
| 5404 | str = g_string_append(str, ">"); | |
| 5405 | } else if (c == '&') { | |
| 5406 | str = g_string_append(str, "&"); | |
| 5407 | } else if (c == '"') { | |
| 5408 | str = g_string_append(str, """); | |
| 5409 | } else if (c == '\n') { | |
|
19746
4537d921dab4
disapproval of revision '10d0834255f911ca2359c74b430025155af2b22e'
Kevin Stange <kstange@pidgin.im>
parents:
19745
diff
changeset
|
5410 | str = g_string_append(str, "<br>"); |
| 8061 | 5411 | } else { |
| 8677 | 5412 | str = g_string_append_unichar(str, c); |
| 5413 | } | |
| 5414 | ||
| 5415 | tags = g_slist_reverse(tags); | |
| 5416 | for (sl = tags; sl; sl = sl->next) { | |
| 5417 | tag = sl->data; | |
| 9071 | 5418 | /** 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
|
5419 | if (tag_ends_here(tag, &iter, &next_iter) && |
|
32189
3af8d41121b6
Don't use strlen() when all you're trying to do is check if the string
Mark Doliner <markdoliner@pidgin.im>
parents:
31941
diff
changeset
|
5420 | *tag_to_html_end(tag) && |
|
3af8d41121b6
Don't use strlen() when all you're trying to do is check if the string
Mark Doliner <markdoliner@pidgin.im>
parents:
31941
diff
changeset
|
5421 | *tag_to_html_start(tag)) |
|
3af8d41121b6
Don't use strlen() when all you're trying to do is check if the string
Mark Doliner <markdoliner@pidgin.im>
parents:
31941
diff
changeset
|
5422 | { |
|
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
|
5423 | 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
|
5424 | 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
|
5425 | |
|
fc1df3495580
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23332
diff
changeset
|
5426 | 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
|
5427 | 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
|
5428 | if (!tag_ends_here(tmp->tag, &iter, &next_iter)) |
| 8677 | 5429 | 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
|
5430 | 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
|
5431 | text_tag_data_destroy(tmp); |
| 8677 | 5432 | } |
| 5433 | ||
|
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
|
5434 | 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
|
5435 | 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
|
5436 | text_tag_data_destroy(tmp); |
|
e20729245830
Patch from Andrew Gaul that fixes a leak:
Ka-Hing Cheung <khc@pidgin.im>
parents:
23398
diff
changeset
|
5437 | } |
|
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
|
5438 | #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
|
5439 | 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
|
5440 | 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
|
5441 | #endif |
| 8677 | 5442 | |
| 5443 | 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
|
5444 | g_string_append(str, tmp->start); |
| 8677 | 5445 | g_queue_push_tail(q, tmp); |
| 8061 | 5446 | } |
|
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
|
5447 | g_queue_free(r); |
| 8061 | 5448 | } |
| 5449 | } | |
| 8677 | 5450 | |
| 5451 | g_slist_free(tags); | |
| 8061 | 5452 | gtk_text_iter_forward_char(&iter); |
|
16143
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
5453 | gtk_text_iter_forward_char(&next_iter); |
| 8061 | 5454 | } |
| 8677 | 5455 | |
|
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
|
5456 | 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
|
5457 | 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
|
5458 | 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
|
5459 | } |
| 8677 | 5460 | |
|
16143
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
5461 | /* Bi-directional text support - close tags */ |
| 16144 | 5462 | if (is_rtl_message) |
|
16143
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
5463 | g_string_append(str, "</SPAN>"); |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
5464 | |
| 8677 | 5465 | g_queue_free(q); |
| 8061 | 5466 | return g_string_free(str, FALSE); |
| 5467 | } | |
| 5468 | ||
| 8698 | 5469 | void gtk_imhtml_close_tags(GtkIMHtml *imhtml, GtkTextIter *iter) |
| 8061 | 5470 | { |
| 5471 | if (imhtml->edit.bold) | |
| 5472 | gtk_imhtml_toggle_bold(imhtml); | |
| 5473 | ||
| 5474 | if (imhtml->edit.italic) | |
| 5475 | gtk_imhtml_toggle_italic(imhtml); | |
| 5476 | ||
| 5477 | if (imhtml->edit.underline) | |
| 5478 | gtk_imhtml_toggle_underline(imhtml); | |
| 5479 | ||
| 9924 | 5480 | if (imhtml->edit.strike) |
| 5481 | gtk_imhtml_toggle_strike(imhtml); | |
| 5482 | ||
| 8061 | 5483 | if (imhtml->edit.forecolor) |
| 5484 | gtk_imhtml_toggle_forecolor(imhtml, NULL); | |
| 5485 | ||
| 5486 | if (imhtml->edit.backcolor) | |
| 5487 | gtk_imhtml_toggle_backcolor(imhtml, NULL); | |
| 5488 | ||
| 5489 | if (imhtml->edit.fontface) | |
| 5490 | gtk_imhtml_toggle_fontface(imhtml, NULL); | |
| 5491 | ||
| 8677 | 5492 | imhtml->edit.fontsize = 0; |
| 5493 | ||
| 8719 | 5494 | if (imhtml->edit.link) |
| 5495 | gtk_imhtml_toggle_link(imhtml, NULL); | |
| 8061 | 5496 | } |
| 5497 | ||
| 5498 | char *gtk_imhtml_get_markup(GtkIMHtml *imhtml) | |
| 5499 | { | |
| 5500 | GtkTextIter start, end; | |
| 5501 | ||
| 5502 | gtk_text_buffer_get_start_iter(imhtml->text_buffer, &start); | |
| 5503 | gtk_text_buffer_get_end_iter(imhtml->text_buffer, &end); | |
| 5504 | return gtk_imhtml_get_markup_range(imhtml, &start, &end); | |
| 5505 | } | |
| 5506 | ||
| 8677 | 5507 | char **gtk_imhtml_get_markup_lines(GtkIMHtml *imhtml) |
| 5508 | { | |
| 5509 | int i, j, lines; | |
| 5510 | GtkTextIter start, end; | |
| 5511 | char **ret; | |
| 5512 | ||
| 5513 | lines = gtk_text_buffer_get_line_count(imhtml->text_buffer); | |
| 5514 | ret = g_new0(char *, lines + 1); | |
| 5515 | gtk_text_buffer_get_start_iter(imhtml->text_buffer, &start); | |
| 5516 | end = start; | |
| 5517 | gtk_text_iter_forward_to_line_end(&end); | |
| 5518 | ||
| 5519 | for (i = 0, j = 0; i < lines; i++) { | |
| 9612 | 5520 | if (gtk_text_iter_get_char(&start) != '\n') { |
| 5521 | ret[j] = gtk_imhtml_get_markup_range(imhtml, &start, &end); | |
| 5522 | if (ret[j] != NULL) | |
| 5523 | j++; | |
| 5524 | } | |
| 5525 | ||
| 8677 | 5526 | gtk_text_iter_forward_line(&start); |
| 5527 | end = start; | |
| 5528 | gtk_text_iter_forward_to_line_end(&end); | |
| 5529 | } | |
| 5530 | ||
| 5531 | return ret; | |
| 5532 | } | |
| 5533 | ||
| 5534 | char *gtk_imhtml_get_text(GtkIMHtml *imhtml, GtkTextIter *start, GtkTextIter *stop) | |
| 8061 | 5535 | { |
| 8519 | 5536 | GString *str = g_string_new(""); |
| 5537 | GtkTextIter iter, end; | |
| 5538 | gunichar c; | |
| 5539 | ||
| 8677 | 5540 | if (start == NULL) |
| 5541 | gtk_text_buffer_get_start_iter(imhtml->text_buffer, &iter); | |
| 5542 | else | |
| 5543 | iter = *start; | |
| 5544 | ||
| 5545 | if (stop == NULL) | |
| 5546 | gtk_text_buffer_get_end_iter(imhtml->text_buffer, &end); | |
| 5547 | else | |
| 5548 | end = *stop; | |
| 5549 | ||
| 5550 | gtk_text_iter_order(&iter, &end); | |
| 8519 | 5551 | |
| 5552 | while ((c = gtk_text_iter_get_char(&iter)) != 0 && !gtk_text_iter_equal(&iter, &end)) { | |
| 5553 | if (c == 0xFFFC) { | |
| 8677 | 5554 | GtkTextChildAnchor* anchor; |
| 5555 | char *text = NULL; | |
| 5556 | ||
| 5557 | anchor = gtk_text_iter_get_child_anchor(&iter); | |
| 5558 | if (anchor) | |
| 8698 | 5559 | text = g_object_get_data(G_OBJECT(anchor), "gtkimhtml_plaintext"); |
| 8677 | 5560 | if (text) |
| 5561 | str = g_string_append(str, text); | |
| 8519 | 5562 | } else { |
| 5563 | g_string_append_unichar(str, c); | |
| 5564 | } | |
| 5565 | gtk_text_iter_forward_char(&iter); | |
| 5566 | } | |
| 5567 | ||
| 5568 | return g_string_free(str, FALSE); | |
| 8061 | 5569 | } |
| 8962 | 5570 | |
| 5571 | void gtk_imhtml_set_funcs(GtkIMHtml *imhtml, GtkIMHtmlFuncs *f) | |
| 5572 | { | |
| 5573 | g_return_if_fail(imhtml != NULL); | |
| 5574 | imhtml->funcs = f; | |
| 5575 | } | |
|
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
|
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 | 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
|
5578 | { |
|
18240
0a7d2fde749b
Fix setting the sensitivity of the toolbar items in a number of places
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
18185
diff
changeset
|
5579 | 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
|
5580 | |
|
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
|
5581 | 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
|
5582 | 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
|
5583 | 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
|
5584 | |
|
18240
0a7d2fde749b
Fix setting the sensitivity of the toolbar items in a number of places
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
18185
diff
changeset
|
5585 | 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
|
5586 | |
|
0a7d2fde749b
Fix setting the sensitivity of the toolbar items in a number of places
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
18185
diff
changeset
|
5587 | 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
|
5588 | 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
|
5589 | 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
|
5590 | { |
|
0a7d2fde749b
Fix setting the sensitivity of the toolbar items in a number of places
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
18185
diff
changeset
|
5591 | 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
|
5592 | 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
|
5593 | } |
|
0a7d2fde749b
Fix setting the sensitivity of the toolbar items in a number of places
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
18185
diff
changeset
|
5594 | 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
|
5595 | 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
|
5596 | |
|
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
|
5597 | 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
|
5598 | 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
|
5599 | 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
|
5600 | |
|
8be39f0de528
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17288
diff
changeset
|
5601 | 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
|
5602 | 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
|
5603 | |
|
8be39f0de528
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17288
diff
changeset
|
5604 | 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
|
5605 | 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
|
5606 | |
|
8be39f0de528
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17288
diff
changeset
|
5607 | 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
|
5608 | 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
|
5609 | |
|
8be39f0de528
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17288
diff
changeset
|
5610 | 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
|
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 | 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
|
5613 | |
|
8be39f0de528
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17288
diff
changeset
|
5614 | /* 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
|
5615 | 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
|
5616 | 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
|
5617 | } |
|
8be39f0de528
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17288
diff
changeset
|
5618 | |
|
8be39f0de528
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17288
diff
changeset
|
5619 | 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
|
5620 | { |
|
8be39f0de528
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17288
diff
changeset
|
5621 | 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
|
5622 | &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
|
5623 | 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
|
5624 | 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
|
5625 | 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
|
5626 | 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
|
5627 | } 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
|
5628 | 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
|
5629 | |
|
8be39f0de528
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17288
diff
changeset
|
5630 | 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
|
5631 | |
|
8be39f0de528
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17288
diff
changeset
|
5632 | 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
|
5633 | 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
|
5634 | { |
|
8be39f0de528
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17288
diff
changeset
|
5635 | 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
|
5636 | &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
|
5637 | 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
|
5638 | 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
|
5639 | 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
|
5640 | 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
|
5641 | } 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
|
5642 | 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
|
5643 | |
|
8be39f0de528
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17288
diff
changeset
|
5644 | 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
|
5645 | |
|
8be39f0de528
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17288
diff
changeset
|
5646 | 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
|
5647 | 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
|
5648 | 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
|
5649 | 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
|
5650 | } 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
|
5651 | 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
|
5652 | 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
|
5653 | } |
|
18240
0a7d2fde749b
Fix setting the sensitivity of the toolbar items in a number of places
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
18185
diff
changeset
|
5654 | |
|
0a7d2fde749b
Fix setting the sensitivity of the toolbar items in a number of places
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
18185
diff
changeset
|
5655 | 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
|
5656 | 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
|
5657 | |
|
23010
6230fac29cee
Show the custom smileys only on accounts that support it. References
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23008
diff
changeset
|
5658 | 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
|
5659 | 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
|
5660 | else |
|
6230fac29cee
Show the custom smileys only on accounts that support it. References
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23008
diff
changeset
|
5661 | 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
|
5662 | |
|
18240
0a7d2fde749b
Fix setting the sensitivity of the toolbar items in a number of places
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
18185
diff
changeset
|
5663 | 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
|
5664 | } |
|
8be39f0de528
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17288
diff
changeset
|
5665 | |
|
22655
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 | * 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
|
5668 | *******/ |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5669 | 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
|
5670 | { |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5671 | 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
|
5672 | |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5673 | 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
|
5674 | 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
|
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 | 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
|
5677 | 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
|
5678 | #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
|
5679 | 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
|
5680 | #endif |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5681 | } |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5682 | |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5683 | 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
|
5684 | { |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5685 | 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
|
5686 | 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
|
5687 | 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
|
5688 | 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
|
5689 | |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5690 | 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
|
5691 | 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
|
5692 | #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
|
5693 | 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
|
5694 | #endif |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5695 | 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
|
5696 | 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
|
5697 | return; |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5698 | } |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5699 | |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5700 | 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
|
5701 | 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
|
5702 | 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
|
5703 | 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
|
5704 | 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
|
5705 | 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
|
5706 | |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5707 | #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
|
5708 | 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
|
5709 | 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
|
5710 | #endif |
|
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 (icon) { |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5712 | 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
|
5713 | 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
|
5714 | |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5715 | 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
|
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 | 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
|
5718 | 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
|
5719 | |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5720 | 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
|
5721 | 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
|
5722 | 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
|
5723 | 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
|
5724 | 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
|
5725 | 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
|
5726 | } else |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5727 | 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
|
5728 | } |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5729 | 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
|
5730 | } |
|
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
|
5731 | 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
|
5732 | } |
|
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 | 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
|
5735 | 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
|
5736 | |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5737 | 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
|
5738 | 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
|
5739 | } |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5740 | |
|
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
|
5741 | 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
|
5742 | 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
|
5743 | { |
|
31941
0ba7a6657b39
Make the max size of incoming smileys a pref instead of harcoding it. Patch from Xinef (with small modifications) Refs #5231
Jorge Villaseñor <masca@cpw.pidgin.im>
parents:
31889
diff
changeset
|
5744 | if (purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/conversations/resize_custom_smileys")) { |
|
0ba7a6657b39
Make the max size of incoming smileys a pref instead of harcoding it. Patch from Xinef (with small modifications) Refs #5231
Jorge Villaseñor <masca@cpw.pidgin.im>
parents:
31889
diff
changeset
|
5745 | int custom_smileys_size = purple_prefs_get_int(PIDGIN_PREFS_ROOT "/conversations/custom_smileys_size"); |
|
0ba7a6657b39
Make the max size of incoming smileys a pref instead of harcoding it. Patch from Xinef (with small modifications) Refs #5231
Jorge Villaseñor <masca@cpw.pidgin.im>
parents:
31889
diff
changeset
|
5746 | if (width <= custom_smileys_size && height <= custom_smileys_size) |
|
0ba7a6657b39
Make the max size of incoming smileys a pref instead of harcoding it. Patch from Xinef (with small modifications) Refs #5231
Jorge Villaseñor <masca@cpw.pidgin.im>
parents:
31889
diff
changeset
|
5747 | return; |
|
0ba7a6657b39
Make the max size of incoming smileys a pref instead of harcoding it. Patch from Xinef (with small modifications) Refs #5231
Jorge Villaseñor <masca@cpw.pidgin.im>
parents:
31889
diff
changeset
|
5748 | |
|
0ba7a6657b39
Make the max size of incoming smileys a pref instead of harcoding it. Patch from Xinef (with small modifications) Refs #5231
Jorge Villaseñor <masca@cpw.pidgin.im>
parents:
31889
diff
changeset
|
5749 | if (width >= height) { |
|
0ba7a6657b39
Make the max size of incoming smileys a pref instead of harcoding it. Patch from Xinef (with small modifications) Refs #5231
Jorge Villaseñor <masca@cpw.pidgin.im>
parents:
31889
diff
changeset
|
5750 | height = height * custom_smileys_size / width; |
|
0ba7a6657b39
Make the max size of incoming smileys a pref instead of harcoding it. Patch from Xinef (with small modifications) Refs #5231
Jorge Villaseñor <masca@cpw.pidgin.im>
parents:
31889
diff
changeset
|
5751 | width = custom_smileys_size; |
|
0ba7a6657b39
Make the max size of incoming smileys a pref instead of harcoding it. Patch from Xinef (with small modifications) Refs #5231
Jorge Villaseñor <masca@cpw.pidgin.im>
parents:
31889
diff
changeset
|
5752 | } else { |
|
0ba7a6657b39
Make the max size of incoming smileys a pref instead of harcoding it. Patch from Xinef (with small modifications) Refs #5231
Jorge Villaseñor <masca@cpw.pidgin.im>
parents:
31889
diff
changeset
|
5753 | width = width * custom_smileys_size / height; |
|
0ba7a6657b39
Make the max size of incoming smileys a pref instead of harcoding it. Patch from Xinef (with small modifications) Refs #5231
Jorge Villaseñor <masca@cpw.pidgin.im>
parents:
31889
diff
changeset
|
5754 | height = custom_smileys_size; |
|
0ba7a6657b39
Make the max size of incoming smileys a pref instead of harcoding it. Patch from Xinef (with small modifications) Refs #5231
Jorge Villaseñor <masca@cpw.pidgin.im>
parents:
31889
diff
changeset
|
5755 | } |
|
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
|
5756 | } |
|
39c5be5ca1e9
Patch from Masca to restrict the size of incoming custom smileys to a
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23010
diff
changeset
|
5757 | 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
|
5758 | } |
|
39c5be5ca1e9
Patch from Masca to restrict the size of incoming custom smileys to a
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23010
diff
changeset
|
5759 | |
|
22655
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5760 | void |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5761 | 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
|
5762 | { |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5763 | 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
|
5764 | 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
|
5765 | 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
|
5766 | 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
|
5767 | |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5768 | 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
|
5769 | 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
|
5770 | |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5771 | 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
|
5772 | /* 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
|
5773 | * 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
|
5774 | */ |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5775 | return; |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5776 | } |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5777 | |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5778 | 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
|
5779 | |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5780 | 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
|
5781 | 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
|
5782 | 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
|
5783 | } |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5784 | |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5785 | 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
|
5786 | 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
|
5787 | { |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5788 | 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
|
5789 | 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
|
5790 | 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
|
5791 | 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
|
5792 | 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
|
5793 | 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
|
5794 | 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
|
5795 | 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
|
5796 | } |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5797 | |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5798 | 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
|
5799 | { |
|
24392
51b7f65a712d
Clean up the GtkSmileyTrees on active GtkIMHtml instances when a custom smiley
Marcus Lundblad <malu@pidgin.im>
parents:
24328
diff
changeset
|
5800 | 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
|
5801 | 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
|
5802 | 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
|
5803 | 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
|
5804 | 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
|
5805 | 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
|
5806 | g_object_unref(smiley->loader); |
|
27123
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
5807 | g_free(smiley->data); |
|
22655
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5808 | 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
|
5809 | } |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5810 | |
|
24674
36bf974a7d78
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24588
diff
changeset
|
5811 | gboolean gtk_imhtml_class_register_protocol(const char *name, |
|
24698
f9dd7117ade0
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24675
diff
changeset
|
5812 | gboolean (*activate)(GtkIMHtml *imhtml, GtkIMHtmlLink *link), |
|
f9dd7117ade0
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24675
diff
changeset
|
5813 | gboolean (*context_menu)(GtkIMHtml *imhtml, GtkIMHtmlLink *link, GtkWidget *menu)) |
|
24674
36bf974a7d78
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24588
diff
changeset
|
5814 | { |
|
36bf974a7d78
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24588
diff
changeset
|
5815 | GtkIMHtmlClass *klass; |
|
36bf974a7d78
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24588
diff
changeset
|
5816 | GtkIMHtmlProtocol *proto; |
|
36bf974a7d78
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24588
diff
changeset
|
5817 | |
|
36bf974a7d78
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24588
diff
changeset
|
5818 | g_return_val_if_fail(name, FALSE); |
|
36bf974a7d78
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24588
diff
changeset
|
5819 | |
|
36bf974a7d78
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24588
diff
changeset
|
5820 | klass = g_type_class_ref(GTK_TYPE_IMHTML); |
|
36bf974a7d78
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24588
diff
changeset
|
5821 | g_return_val_if_fail(klass, FALSE); |
|
36bf974a7d78
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24588
diff
changeset
|
5822 | |
|
25013
956b2f650d31
Detect duplication registrations by substring.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
25011
diff
changeset
|
5823 | if ((proto = imhtml_find_protocol(name, TRUE))) { |
|
25014
5bf71146f93e
Replace the URL registration assertions with regular checks.
Richard Laager <rlaager@pidgin.im>
parents:
25013
diff
changeset
|
5824 | if (activate) { |
|
5bf71146f93e
Replace the URL registration assertions with regular checks.
Richard Laager <rlaager@pidgin.im>
parents:
25013
diff
changeset
|
5825 | return FALSE; |
|
5bf71146f93e
Replace the URL registration assertions with regular checks.
Richard Laager <rlaager@pidgin.im>
parents:
25013
diff
changeset
|
5826 | } |
|
28077
c2b493e058f1
Don't use pointers (even opaquely) once they're freed. Closes #9822.
Paul Aurich <darkrain42@pidgin.im>
parents:
27525
diff
changeset
|
5827 | klass->protocols = g_list_remove(klass->protocols, proto); |
|
24674
36bf974a7d78
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24588
diff
changeset
|
5828 | g_free(proto->name); |
|
36bf974a7d78
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24588
diff
changeset
|
5829 | g_free(proto); |
|
36bf974a7d78
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24588
diff
changeset
|
5830 | return TRUE; |
|
25014
5bf71146f93e
Replace the URL registration assertions with regular checks.
Richard Laager <rlaager@pidgin.im>
parents:
25013
diff
changeset
|
5831 | } else if (!activate) { |
|
5bf71146f93e
Replace the URL registration assertions with regular checks.
Richard Laager <rlaager@pidgin.im>
parents:
25013
diff
changeset
|
5832 | return FALSE; |
|
24674
36bf974a7d78
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24588
diff
changeset
|
5833 | } |
|
36bf974a7d78
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24588
diff
changeset
|
5834 | |
|
36bf974a7d78
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24588
diff
changeset
|
5835 | proto = g_new0(GtkIMHtmlProtocol, 1); |
|
25008
f52b9372eb19
Revert the URL scheme passing changes, keeping the miscellaneous other stuff
Richard Laager <rlaager@pidgin.im>
parents:
25007
diff
changeset
|
5836 | proto->name = g_strdup(name); |
|
f52b9372eb19
Revert the URL scheme passing changes, keeping the miscellaneous other stuff
Richard Laager <rlaager@pidgin.im>
parents:
25007
diff
changeset
|
5837 | proto->length = strlen(name); |
|
24674
36bf974a7d78
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24588
diff
changeset
|
5838 | proto->activate = activate; |
|
36bf974a7d78
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24588
diff
changeset
|
5839 | proto->context_menu = context_menu; |
|
36bf974a7d78
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24588
diff
changeset
|
5840 | klass->protocols = g_list_prepend(klass->protocols, proto); |
|
36bf974a7d78
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24588
diff
changeset
|
5841 | |
|
36bf974a7d78
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24588
diff
changeset
|
5842 | return TRUE; |
|
36bf974a7d78
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24588
diff
changeset
|
5843 | } |
|
36bf974a7d78
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24588
diff
changeset
|
5844 | |
|
24698
f9dd7117ade0
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24675
diff
changeset
|
5845 | static void |
|
f9dd7117ade0
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24675
diff
changeset
|
5846 | gtk_imhtml_activate_tag(GtkIMHtml *imhtml, GtkTextTag *tag) |
|
f9dd7117ade0
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24675
diff
changeset
|
5847 | { |
|
f9dd7117ade0
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24675
diff
changeset
|
5848 | /* A link was clicked--we emit the "url_clicked" signal |
|
f9dd7117ade0
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24675
diff
changeset
|
5849 | * with the URL as the argument */ |
|
f9dd7117ade0
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24675
diff
changeset
|
5850 | g_object_ref(G_OBJECT(tag)); |
|
f9dd7117ade0
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24675
diff
changeset
|
5851 | g_signal_emit(imhtml, signals[URL_CLICKED], 0, g_object_get_data(G_OBJECT(tag), "link_url")); |
|
f9dd7117ade0
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24675
diff
changeset
|
5852 | g_object_unref(G_OBJECT(tag)); |
|
f9dd7117ade0
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24675
diff
changeset
|
5853 | g_object_set_data(G_OBJECT(tag), "visited", GINT_TO_POINTER(TRUE)); |
|
f9dd7117ade0
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24675
diff
changeset
|
5854 | gtk_imhtml_set_link_color(GTK_IMHTML(imhtml), tag); |
|
f9dd7117ade0
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24675
diff
changeset
|
5855 | } |
|
f9dd7117ade0
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24675
diff
changeset
|
5856 | |
|
f9dd7117ade0
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24675
diff
changeset
|
5857 | gboolean gtk_imhtml_link_activate(GtkIMHtmlLink *link) |
|
f9dd7117ade0
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24675
diff
changeset
|
5858 | { |
|
f9dd7117ade0
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24675
diff
changeset
|
5859 | g_return_val_if_fail(link, FALSE); |
|
f9dd7117ade0
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24675
diff
changeset
|
5860 | |
|
f9dd7117ade0
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24675
diff
changeset
|
5861 | if (link->tag) { |
|
f9dd7117ade0
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24675
diff
changeset
|
5862 | gtk_imhtml_activate_tag(link->imhtml, link->tag); |
|
f9dd7117ade0
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24675
diff
changeset
|
5863 | } else if (link->url) { |
|
f9dd7117ade0
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24675
diff
changeset
|
5864 | g_signal_emit(link->imhtml, signals[URL_CLICKED], 0, link->url); |
|
f9dd7117ade0
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24675
diff
changeset
|
5865 | } else |
|
f9dd7117ade0
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24675
diff
changeset
|
5866 | return FALSE; |
|
f9dd7117ade0
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24675
diff
changeset
|
5867 | return TRUE; |
|
f9dd7117ade0
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24675
diff
changeset
|
5868 | } |
|
f9dd7117ade0
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24675
diff
changeset
|
5869 | |
|
f9dd7117ade0
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24675
diff
changeset
|
5870 | const char *gtk_imhtml_link_get_url(GtkIMHtmlLink *link) |
|
f9dd7117ade0
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24675
diff
changeset
|
5871 | { |
|
f9dd7117ade0
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24675
diff
changeset
|
5872 | return link->url; |
|
f9dd7117ade0
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24675
diff
changeset
|
5873 | } |
|
f9dd7117ade0
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24675
diff
changeset
|
5874 | |
|
f9dd7117ade0
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24675
diff
changeset
|
5875 | const GtkTextTag * gtk_imhtml_link_get_text_tag(GtkIMHtmlLink *link) |
|
f9dd7117ade0
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24675
diff
changeset
|
5876 | { |
|
f9dd7117ade0
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24675
diff
changeset
|
5877 | return link->tag; |
|
f9dd7117ade0
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24675
diff
changeset
|
5878 | } |
|
f9dd7117ade0
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24675
diff
changeset
|
5879 | |
|
25900
0be61f1b3dd1
Add a GtkIMHtml function that causes the widget to actually insert a
Mark Doliner <markdoliner@pidgin.im>
parents:
25899
diff
changeset
|
5880 | static gboolean return_add_newline_cb(GtkWidget *widget, gpointer data) |
|
0be61f1b3dd1
Add a GtkIMHtml function that causes the widget to actually insert a
Mark Doliner <markdoliner@pidgin.im>
parents:
25899
diff
changeset
|
5881 | { |
|
0be61f1b3dd1
Add a GtkIMHtml function that causes the widget to actually insert a
Mark Doliner <markdoliner@pidgin.im>
parents:
25899
diff
changeset
|
5882 | GtkTextBuffer *buffer; |
|
0be61f1b3dd1
Add a GtkIMHtml function that causes the widget to actually insert a
Mark Doliner <markdoliner@pidgin.im>
parents:
25899
diff
changeset
|
5883 | GtkTextMark *mark; |
|
0be61f1b3dd1
Add a GtkIMHtml function that causes the widget to actually insert a
Mark Doliner <markdoliner@pidgin.im>
parents:
25899
diff
changeset
|
5884 | GtkTextIter iter; |
|
0be61f1b3dd1
Add a GtkIMHtml function that causes the widget to actually insert a
Mark Doliner <markdoliner@pidgin.im>
parents:
25899
diff
changeset
|
5885 | |
|
0be61f1b3dd1
Add a GtkIMHtml function that causes the widget to actually insert a
Mark Doliner <markdoliner@pidgin.im>
parents:
25899
diff
changeset
|
5886 | buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(widget)); |
|
0be61f1b3dd1
Add a GtkIMHtml function that causes the widget to actually insert a
Mark Doliner <markdoliner@pidgin.im>
parents:
25899
diff
changeset
|
5887 | |
|
0be61f1b3dd1
Add a GtkIMHtml function that causes the widget to actually insert a
Mark Doliner <markdoliner@pidgin.im>
parents:
25899
diff
changeset
|
5888 | /* Delete any currently selected text */ |
|
0be61f1b3dd1
Add a GtkIMHtml function that causes the widget to actually insert a
Mark Doliner <markdoliner@pidgin.im>
parents:
25899
diff
changeset
|
5889 | gtk_text_buffer_delete_selection(buffer, TRUE, TRUE); |
|
0be61f1b3dd1
Add a GtkIMHtml function that causes the widget to actually insert a
Mark Doliner <markdoliner@pidgin.im>
parents:
25899
diff
changeset
|
5890 | |
|
0be61f1b3dd1
Add a GtkIMHtml function that causes the widget to actually insert a
Mark Doliner <markdoliner@pidgin.im>
parents:
25899
diff
changeset
|
5891 | /* Insert a newline at the current cursor position */ |
|
0be61f1b3dd1
Add a GtkIMHtml function that causes the widget to actually insert a
Mark Doliner <markdoliner@pidgin.im>
parents:
25899
diff
changeset
|
5892 | mark = gtk_text_buffer_get_insert(buffer); |
|
0be61f1b3dd1
Add a GtkIMHtml function that causes the widget to actually insert a
Mark Doliner <markdoliner@pidgin.im>
parents:
25899
diff
changeset
|
5893 | gtk_text_buffer_get_iter_at_mark(buffer, &iter, mark); |
|
0be61f1b3dd1
Add a GtkIMHtml function that causes the widget to actually insert a
Mark Doliner <markdoliner@pidgin.im>
parents:
25899
diff
changeset
|
5894 | gtk_imhtml_insert_html_at_iter(GTK_IMHTML(widget), "\n", 0, &iter); |
|
0be61f1b3dd1
Add a GtkIMHtml function that causes the widget to actually insert a
Mark Doliner <markdoliner@pidgin.im>
parents:
25899
diff
changeset
|
5895 | |
|
0be61f1b3dd1
Add a GtkIMHtml function that causes the widget to actually insert a
Mark Doliner <markdoliner@pidgin.im>
parents:
25899
diff
changeset
|
5896 | /* |
|
0be61f1b3dd1
Add a GtkIMHtml function that causes the widget to actually insert a
Mark Doliner <markdoliner@pidgin.im>
parents:
25899
diff
changeset
|
5897 | * If we just newlined ourselves past the end of the visible area |
|
0be61f1b3dd1
Add a GtkIMHtml function that causes the widget to actually insert a
Mark Doliner <markdoliner@pidgin.im>
parents:
25899
diff
changeset
|
5898 | * then scroll down so the cursor is in view. |
|
0be61f1b3dd1
Add a GtkIMHtml function that causes the widget to actually insert a
Mark Doliner <markdoliner@pidgin.im>
parents:
25899
diff
changeset
|
5899 | */ |
|
0be61f1b3dd1
Add a GtkIMHtml function that causes the widget to actually insert a
Mark Doliner <markdoliner@pidgin.im>
parents:
25899
diff
changeset
|
5900 | gtk_text_view_scroll_to_mark(GTK_TEXT_VIEW(widget), |
|
0be61f1b3dd1
Add a GtkIMHtml function that causes the widget to actually insert a
Mark Doliner <markdoliner@pidgin.im>
parents:
25899
diff
changeset
|
5901 | gtk_text_buffer_get_insert(buffer), |
|
0be61f1b3dd1
Add a GtkIMHtml function that causes the widget to actually insert a
Mark Doliner <markdoliner@pidgin.im>
parents:
25899
diff
changeset
|
5902 | 0, FALSE, 0.0, 0.0); |
|
0be61f1b3dd1
Add a GtkIMHtml function that causes the widget to actually insert a
Mark Doliner <markdoliner@pidgin.im>
parents:
25899
diff
changeset
|
5903 | |
|
0be61f1b3dd1
Add a GtkIMHtml function that causes the widget to actually insert a
Mark Doliner <markdoliner@pidgin.im>
parents:
25899
diff
changeset
|
5904 | return TRUE; |
|
0be61f1b3dd1
Add a GtkIMHtml function that causes the widget to actually insert a
Mark Doliner <markdoliner@pidgin.im>
parents:
25899
diff
changeset
|
5905 | } |
|
0be61f1b3dd1
Add a GtkIMHtml function that causes the widget to actually insert a
Mark Doliner <markdoliner@pidgin.im>
parents:
25899
diff
changeset
|
5906 | |
|
25906
a64c9c871a23
Add a comment just noting that I think it's kind of annoying that we
Mark Doliner <markdoliner@pidgin.im>
parents:
25905
diff
changeset
|
5907 | /* |
|
a64c9c871a23
Add a comment just noting that I think it's kind of annoying that we
Mark Doliner <markdoliner@pidgin.im>
parents:
25905
diff
changeset
|
5908 | * It's kind of a pain that we need this function and the above just |
|
a64c9c871a23
Add a comment just noting that I think it's kind of annoying that we
Mark Doliner <markdoliner@pidgin.im>
parents:
25905
diff
changeset
|
5909 | * to reinstate the default GtkTextView behavior. It might be better |
|
a64c9c871a23
Add a comment just noting that I think it's kind of annoying that we
Mark Doliner <markdoliner@pidgin.im>
parents:
25905
diff
changeset
|
5910 | * if GtkIMHtml didn't intercept the enter key and just required the |
|
a64c9c871a23
Add a comment just noting that I think it's kind of annoying that we
Mark Doliner <markdoliner@pidgin.im>
parents:
25905
diff
changeset
|
5911 | * application to deal with it--it's really not much more work than it |
|
a64c9c871a23
Add a comment just noting that I think it's kind of annoying that we
Mark Doliner <markdoliner@pidgin.im>
parents:
25905
diff
changeset
|
5912 | * is to connect to the current "message_send" signal. |
|
a64c9c871a23
Add a comment just noting that I think it's kind of annoying that we
Mark Doliner <markdoliner@pidgin.im>
parents:
25905
diff
changeset
|
5913 | */ |
|
25900
0be61f1b3dd1
Add a GtkIMHtml function that causes the widget to actually insert a
Mark Doliner <markdoliner@pidgin.im>
parents:
25899
diff
changeset
|
5914 | void gtk_imhtml_set_return_inserts_newline(GtkIMHtml *imhtml) |
|
0be61f1b3dd1
Add a GtkIMHtml function that causes the widget to actually insert a
Mark Doliner <markdoliner@pidgin.im>
parents:
25899
diff
changeset
|
5915 | { |
|
0be61f1b3dd1
Add a GtkIMHtml function that causes the widget to actually insert a
Mark Doliner <markdoliner@pidgin.im>
parents:
25899
diff
changeset
|
5916 | g_signal_connect(G_OBJECT(imhtml), "message_send", |
|
0be61f1b3dd1
Add a GtkIMHtml function that causes the widget to actually insert a
Mark Doliner <markdoliner@pidgin.im>
parents:
25899
diff
changeset
|
5917 | G_CALLBACK(return_add_newline_cb), NULL); |
|
0be61f1b3dd1
Add a GtkIMHtml function that causes the widget to actually insert a
Mark Doliner <markdoliner@pidgin.im>
parents:
25899
diff
changeset
|
5918 | } |
|
27032
991e2899be82
Avoid overwriting the PRIMARY clipboard when we select-on-focus the status text for easy editing. Fixes #8781.
Daniel Atallah <datallah@pidgin.im>
parents:
27031
diff
changeset
|
5919 | |
|
991e2899be82
Avoid overwriting the PRIMARY clipboard when we select-on-focus the status text for easy editing. Fixes #8781.
Daniel Atallah <datallah@pidgin.im>
parents:
27031
diff
changeset
|
5920 | void gtk_imhtml_set_populate_primary_clipboard(GtkIMHtml *imhtml, gboolean populate) |
|
991e2899be82
Avoid overwriting the PRIMARY clipboard when we select-on-focus the status text for easy editing. Fixes #8781.
Daniel Atallah <datallah@pidgin.im>
parents:
27031
diff
changeset
|
5921 | { |
|
27114
63f35ec28622
Block/Unblock the signal handler when if it's unblocked/blocked.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27032
diff
changeset
|
5922 | gulong signal_id; |
|
63f35ec28622
Block/Unblock the signal handler when if it's unblocked/blocked.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27032
diff
changeset
|
5923 | signal_id = g_signal_handler_find(imhtml->text_buffer, |
|
63f35ec28622
Block/Unblock the signal handler when if it's unblocked/blocked.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27032
diff
changeset
|
5924 | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_UNBLOCKED, 0, 0, NULL, |
|
63f35ec28622
Block/Unblock the signal handler when if it's unblocked/blocked.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27032
diff
changeset
|
5925 | mark_set_so_update_selection_cb, NULL); |
|
27032
991e2899be82
Avoid overwriting the PRIMARY clipboard when we select-on-focus the status text for easy editing. Fixes #8781.
Daniel Atallah <datallah@pidgin.im>
parents:
27031
diff
changeset
|
5926 | if (populate) { |
|
27114
63f35ec28622
Block/Unblock the signal handler when if it's unblocked/blocked.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27032
diff
changeset
|
5927 | if (!signal_id) { |
|
63f35ec28622
Block/Unblock the signal handler when if it's unblocked/blocked.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27032
diff
changeset
|
5928 | /* We didn't find an unblocked signal handler, which means there |
|
63f35ec28622
Block/Unblock the signal handler when if it's unblocked/blocked.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27032
diff
changeset
|
5929 | is a blocked handler. Now unblock it. |
|
63f35ec28622
Block/Unblock the signal handler when if it's unblocked/blocked.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27032
diff
changeset
|
5930 | This is necessary to avoid a mutex-lock when the debug message |
|
63f35ec28622
Block/Unblock the signal handler when if it's unblocked/blocked.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27032
diff
changeset
|
5931 | saying 'no handler is blocked' is printed in the debug window. |
|
63f35ec28622
Block/Unblock the signal handler when if it's unblocked/blocked.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27032
diff
changeset
|
5932 | -- sad |
|
63f35ec28622
Block/Unblock the signal handler when if it's unblocked/blocked.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27032
diff
changeset
|
5933 | */ |
|
63f35ec28622
Block/Unblock the signal handler when if it's unblocked/blocked.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27032
diff
changeset
|
5934 | g_signal_handlers_unblock_matched(imhtml->text_buffer, |
|
63f35ec28622
Block/Unblock the signal handler when if it's unblocked/blocked.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27032
diff
changeset
|
5935 | G_SIGNAL_MATCH_FUNC, 0, 0, NULL, |
|
63f35ec28622
Block/Unblock the signal handler when if it's unblocked/blocked.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27032
diff
changeset
|
5936 | mark_set_so_update_selection_cb, NULL); |
|
63f35ec28622
Block/Unblock the signal handler when if it's unblocked/blocked.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27032
diff
changeset
|
5937 | } |
|
27032
991e2899be82
Avoid overwriting the PRIMARY clipboard when we select-on-focus the status text for easy editing. Fixes #8781.
Daniel Atallah <datallah@pidgin.im>
parents:
27031
diff
changeset
|
5938 | } else { |
|
27114
63f35ec28622
Block/Unblock the signal handler when if it's unblocked/blocked.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27032
diff
changeset
|
5939 | /* Block only if we found an unblocked handler */ |
|
63f35ec28622
Block/Unblock the signal handler when if it's unblocked/blocked.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27032
diff
changeset
|
5940 | if (signal_id) |
|
63f35ec28622
Block/Unblock the signal handler when if it's unblocked/blocked.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27032
diff
changeset
|
5941 | g_signal_handler_block(imhtml->text_buffer, signal_id); |
|
27032
991e2899be82
Avoid overwriting the PRIMARY clipboard when we select-on-focus the status text for easy editing. Fixes #8781.
Daniel Atallah <datallah@pidgin.im>
parents:
27031
diff
changeset
|
5942 | } |
|
991e2899be82
Avoid overwriting the PRIMARY clipboard when we select-on-focus the status text for easy editing. Fixes #8781.
Daniel Atallah <datallah@pidgin.im>
parents:
27031
diff
changeset
|
5943 | } |