Tue, 22 Jan 2013 00:05:35 -0800
Rename two functions.
purple_imgstore_add --> purple_imgstore_new
purple_imgstore_add_with_id --> purple_imgstore_new_with_id
The first function was really misnamed... it doesn't actually add the
function to anything. The second function was more accurate, in that
it adds the image to a hash table. But it also allocates a new image,
so I thought it was better to be consistent, to make it more clear
that these functions are similar.
| 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 | ||
|
33170
ce4447562d64
Add checks for old GTK+2 stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33132
diff
changeset
|
68 | #include "gtk3compat.h" |
|
ce4447562d64
Add checks for old GTK+2 stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33132
diff
changeset
|
69 | |
| 10100 | 70 | static GtkTextViewClass *parent_class = NULL; |
| 71 | ||
|
11224
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
72 | struct scalable_data { |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
73 | GtkIMHtmlScalable *scalable; |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
74 | GtkTextMark *mark; |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
75 | }; |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
76 | |
|
27123
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
77 | typedef struct { |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
78 | GtkIMHtmlScalable *image; |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
79 | gpointer data; |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
80 | gsize datasize; |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
81 | } GtkIMHtmlImageSave; |
|
11224
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
82 | |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
83 | struct im_image_data { |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
84 | int id; |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
85 | GtkTextMark *mark; |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
86 | }; |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
87 | |
|
32656
d26e0b6b9d2c
Hide unused gtkimhtml structs (aka, the easy ones).
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32604
diff
changeset
|
88 | struct _GtkIMHtmlScalable { |
|
d26e0b6b9d2c
Hide unused gtkimhtml structs (aka, the easy ones).
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32604
diff
changeset
|
89 | void (*scale)(struct _GtkIMHtmlScalable *, int, int); |
|
d26e0b6b9d2c
Hide unused gtkimhtml structs (aka, the easy ones).
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32604
diff
changeset
|
90 | void (*add_to)(struct _GtkIMHtmlScalable *, GtkIMHtml *, GtkTextIter *); |
|
d26e0b6b9d2c
Hide unused gtkimhtml structs (aka, the easy ones).
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32604
diff
changeset
|
91 | void (*free)(struct _GtkIMHtmlScalable *); |
|
d26e0b6b9d2c
Hide unused gtkimhtml structs (aka, the easy ones).
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32604
diff
changeset
|
92 | }; |
|
d26e0b6b9d2c
Hide unused gtkimhtml structs (aka, the easy ones).
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32604
diff
changeset
|
93 | |
|
d26e0b6b9d2c
Hide unused gtkimhtml structs (aka, the easy ones).
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32604
diff
changeset
|
94 | struct _GtkIMHtmlHr { |
|
d26e0b6b9d2c
Hide unused gtkimhtml structs (aka, the easy ones).
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32604
diff
changeset
|
95 | GtkIMHtmlScalable scalable; |
|
d26e0b6b9d2c
Hide unused gtkimhtml structs (aka, the easy ones).
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32604
diff
changeset
|
96 | GtkWidget *sep; |
|
d26e0b6b9d2c
Hide unused gtkimhtml structs (aka, the easy ones).
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32604
diff
changeset
|
97 | }; |
|
d26e0b6b9d2c
Hide unused gtkimhtml structs (aka, the easy ones).
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32604
diff
changeset
|
98 | |
|
d26e0b6b9d2c
Hide unused gtkimhtml structs (aka, the easy ones).
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32604
diff
changeset
|
99 | struct _GtkIMHtmlImage { |
|
d26e0b6b9d2c
Hide unused gtkimhtml structs (aka, the easy ones).
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32604
diff
changeset
|
100 | GtkIMHtmlScalable scalable; |
|
d26e0b6b9d2c
Hide unused gtkimhtml structs (aka, the easy ones).
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32604
diff
changeset
|
101 | GtkImage *image; /**< Contains the scaled version of this pixbuf. */ |
|
d26e0b6b9d2c
Hide unused gtkimhtml structs (aka, the easy ones).
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32604
diff
changeset
|
102 | GdkPixbuf *pixbuf; /**< The original pixbuf, before any scaling. */ |
|
d26e0b6b9d2c
Hide unused gtkimhtml structs (aka, the easy ones).
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32604
diff
changeset
|
103 | GtkTextMark *mark; |
|
d26e0b6b9d2c
Hide unused gtkimhtml structs (aka, the easy ones).
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32604
diff
changeset
|
104 | gchar *filename; |
|
d26e0b6b9d2c
Hide unused gtkimhtml structs (aka, the easy ones).
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32604
diff
changeset
|
105 | int width; |
|
d26e0b6b9d2c
Hide unused gtkimhtml structs (aka, the easy ones).
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32604
diff
changeset
|
106 | int height; |
|
d26e0b6b9d2c
Hide unused gtkimhtml structs (aka, the easy ones).
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32604
diff
changeset
|
107 | int id; |
|
d26e0b6b9d2c
Hide unused gtkimhtml structs (aka, the easy ones).
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32604
diff
changeset
|
108 | GtkWidget *filesel; |
|
d26e0b6b9d2c
Hide unused gtkimhtml structs (aka, the easy ones).
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32604
diff
changeset
|
109 | }; |
|
d26e0b6b9d2c
Hide unused gtkimhtml structs (aka, the easy ones).
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32604
diff
changeset
|
110 | |
|
d26e0b6b9d2c
Hide unused gtkimhtml structs (aka, the easy ones).
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32604
diff
changeset
|
111 | struct _GtkIMHtmlAnimation { |
|
d26e0b6b9d2c
Hide unused gtkimhtml structs (aka, the easy ones).
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32604
diff
changeset
|
112 | GtkIMHtmlImage imhtmlimage; |
|
d26e0b6b9d2c
Hide unused gtkimhtml structs (aka, the easy ones).
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32604
diff
changeset
|
113 | GdkPixbufAnimation *anim; /**< The original animation, before any scaling. */ |
|
d26e0b6b9d2c
Hide unused gtkimhtml structs (aka, the easy ones).
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32604
diff
changeset
|
114 | GdkPixbufAnimationIter *iter; |
|
d26e0b6b9d2c
Hide unused gtkimhtml structs (aka, the easy ones).
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32604
diff
changeset
|
115 | guint timer; |
|
d26e0b6b9d2c
Hide unused gtkimhtml structs (aka, the easy ones).
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32604
diff
changeset
|
116 | }; |
|
d26e0b6b9d2c
Hide unused gtkimhtml structs (aka, the easy ones).
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32604
diff
changeset
|
117 | |
|
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
|
118 | 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
|
119 | { |
|
f9dd7117ade0
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24675
diff
changeset
|
120 | 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
|
121 | 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
|
122 | 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
|
123 | }; |
|
f9dd7117ade0
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24675
diff
changeset
|
124 | |
|
32656
d26e0b6b9d2c
Hide unused gtkimhtml structs (aka, the easy ones).
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32604
diff
changeset
|
125 | struct _GtkSmileyTree { |
|
d26e0b6b9d2c
Hide unused gtkimhtml structs (aka, the easy ones).
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32604
diff
changeset
|
126 | GString *values; |
|
d26e0b6b9d2c
Hide unused gtkimhtml structs (aka, the easy ones).
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32604
diff
changeset
|
127 | GtkSmileyTree **children; |
|
d26e0b6b9d2c
Hide unused gtkimhtml structs (aka, the easy ones).
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32604
diff
changeset
|
128 | GtkIMHtmlSmiley *image; |
|
d26e0b6b9d2c
Hide unused gtkimhtml structs (aka, the easy ones).
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32604
diff
changeset
|
129 | }; |
|
d26e0b6b9d2c
Hide unused gtkimhtml structs (aka, the easy ones).
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32604
diff
changeset
|
130 | |
|
32291
394209616656
Hide GtkIMHtmlFontDetail
Mark Doliner <markdoliner@pidgin.im>
parents:
32189
diff
changeset
|
131 | 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
|
132 | char *name; |
|
36bf974a7d78
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24588
diff
changeset
|
133 | int length; |
|
36bf974a7d78
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24588
diff
changeset
|
134 | |
|
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
|
135 | 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
|
136 | 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
|
137 | } GtkIMHtmlProtocol; |
|
36bf974a7d78
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24588
diff
changeset
|
138 | |
|
32291
394209616656
Hide GtkIMHtmlFontDetail
Mark Doliner <markdoliner@pidgin.im>
parents:
32189
diff
changeset
|
139 | /* The five elements contained in a FONT tag */ |
|
394209616656
Hide GtkIMHtmlFontDetail
Mark Doliner <markdoliner@pidgin.im>
parents:
32189
diff
changeset
|
140 | typedef struct { |
|
31310
7835bac46b07
Add support for rendering strikethrough when received as in-line CSS,
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
31294
diff
changeset
|
141 | gushort size; |
|
7835bac46b07
Add support for rendering strikethrough when received as in-line CSS,
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
31294
diff
changeset
|
142 | gchar *face; |
|
7835bac46b07
Add support for rendering strikethrough when received as in-line CSS,
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
31294
diff
changeset
|
143 | gchar *fore; |
|
7835bac46b07
Add support for rendering strikethrough when received as in-line CSS,
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
31294
diff
changeset
|
144 | gchar *back; |
|
7835bac46b07
Add support for rendering strikethrough when received as in-line CSS,
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
31294
diff
changeset
|
145 | gchar *bg; |
|
7835bac46b07
Add support for rendering strikethrough when received as in-line CSS,
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
31294
diff
changeset
|
146 | gchar *sml; |
|
7835bac46b07
Add support for rendering strikethrough when received as in-line CSS,
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
31294
diff
changeset
|
147 | gboolean underline; |
|
7835bac46b07
Add support for rendering strikethrough when received as in-line CSS,
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
31294
diff
changeset
|
148 | gboolean strike; |
|
7835bac46b07
Add support for rendering strikethrough when received as in-line CSS,
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
31294
diff
changeset
|
149 | gshort bold; |
|
7835bac46b07
Add support for rendering strikethrough when received as in-line CSS,
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
31294
diff
changeset
|
150 | } GtkIMHtmlFontDetail; |
|
7835bac46b07
Add support for rendering strikethrough when received as in-line CSS,
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
31294
diff
changeset
|
151 | |
| 9300 | 152 | static gboolean |
| 153 | gtk_text_view_drag_motion (GtkWidget *widget, | |
| 154 | GdkDragContext *context, | |
| 155 | gint x, | |
| 156 | gint y, | |
| 157 | guint time); | |
| 158 | ||
| 8677 | 159 | static void preinsert_cb(GtkTextBuffer *buffer, GtkTextIter *iter, gchar *text, gint len, GtkIMHtml *imhtml); |
| 8061 | 160 | 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
|
161 | static void delete_cb(GtkTextBuffer *buffer, GtkTextIter *iter, GtkTextIter *end, GtkIMHtml *imhtml); |
| 10169 | 162 | static void insert_ca_cb(GtkTextBuffer *buffer, GtkTextIter *arg1, GtkTextChildAnchor *arg2, gpointer user_data); |
| 163 | static void gtk_imhtml_apply_tags_on_insert(GtkIMHtml *imhtml, GtkTextIter *start, GtkTextIter *end); | |
| 8698 | 164 | void gtk_imhtml_close_tags(GtkIMHtml *imhtml, GtkTextIter *iter); |
| 9300 | 165 | static void gtk_imhtml_link_drop_cb(GtkWidget *widget, GdkDragContext *context, gint x, gint y, guint time, gpointer user_data); |
| 8091 | 166 | 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 | 167 | static void mark_set_cb(GtkTextBuffer *buffer, GtkTextIter *arg1, GtkTextMark *mark, GtkIMHtml *imhtml); |
| 8931 | 168 | static void hijack_menu_cb(GtkIMHtml *imhtml, GtkMenu *menu, gpointer data); |
| 169 | static void paste_received_cb (GtkClipboard *clipboard, GtkSelectionData *selection_data, gpointer data); | |
| 170 | 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
|
171 | 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
|
172 | static void imhtml_toggle_bold(GtkIMHtml *imhtml); |
|
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
173 | static void imhtml_toggle_italic(GtkIMHtml *imhtml); |
|
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
174 | static void imhtml_toggle_strike(GtkIMHtml *imhtml); |
|
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
175 | static void imhtml_toggle_underline(GtkIMHtml *imhtml); |
|
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
176 | static void imhtml_font_grow(GtkIMHtml *imhtml); |
|
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
177 | static void imhtml_font_shrink(GtkIMHtml *imhtml); |
|
12672
673e2a1d2954
[gaim-migrate @ 15015]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12635
diff
changeset
|
178 | 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
|
179 | 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
|
180 | 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
|
181 | static void gtk_imhtml_link_destroy(GtkIMHtmlLink *link); |
| 8061 | 182 | |
|
10899
87d9aec5b72d
[gaim-migrate @ 12619]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10871
diff
changeset
|
183 | /* POINT_SIZE converts from AIM font sizes to a point size scale factor. */ |
| 3922 | 184 | #define MAX_FONT_SIZE 7 |
|
10900
cc19dfd83910
[gaim-migrate @ 12621]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10899
diff
changeset
|
185 | #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
|
186 | 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
|
187 | |
|
10184
543c9a84ce16
[gaim-migrate @ 11299]
Mark Doliner <markdoliner@pidgin.im>
parents:
10169
diff
changeset
|
188 | enum { |
| 8677 | 189 | TARGET_HTML, |
| 8061 | 190 | TARGET_UTF8_STRING, |
| 191 | TARGET_COMPOUND_TEXT, | |
| 192 | TARGET_STRING, | |
| 193 | TARGET_TEXT | |
| 194 | }; | |
| 195 | ||
| 8091 | 196 | enum { |
| 8420 | 197 | URL_CLICKED, |
| 198 | BUTTONS_UPDATE, | |
| 199 | TOGGLE_FORMAT, | |
| 8427 | 200 | CLEAR_FORMAT, |
| 8506 | 201 | UPDATE_FORMAT, |
| 10108 | 202 | 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
|
203 | 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
|
204 | REDO, |
|
29909
3b74346e22d5
Allow binding 'Paste as Plain Text'.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
29855
diff
changeset
|
205 | PASTE, |
| 8420 | 206 | LAST_SIGNAL |
| 207 | }; | |
| 208 | static guint signals [LAST_SIGNAL] = { 0 }; | |
| 209 | ||
|
17546
51b1c1e2c3fe
Maintain global poitners to the clipboard selection text, with the aim of
Sean Egan <seanegan@pidgin.im>
parents:
17406
diff
changeset
|
210 | 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
|
211 | 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
|
212 | 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
|
213 | |
|
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
|
214 | static const GtkTargetEntry selection_targets[] = { |
|
15111
e427dd6f3b7e
[gaim-migrate @ 17833]
Daniel Atallah <datallah@pidgin.im>
parents:
15093
diff
changeset
|
215 | #ifndef _WIN32 |
| 8566 | 216 | { "text/html", 0, TARGET_HTML }, |
|
15111
e427dd6f3b7e
[gaim-migrate @ 17833]
Daniel Atallah <datallah@pidgin.im>
parents:
15093
diff
changeset
|
217 | #else |
|
e427dd6f3b7e
[gaim-migrate @ 17833]
Daniel Atallah <datallah@pidgin.im>
parents:
15093
diff
changeset
|
218 | { "HTML Format", 0, TARGET_HTML }, |
|
e427dd6f3b7e
[gaim-migrate @ 17833]
Daniel Atallah <datallah@pidgin.im>
parents:
15093
diff
changeset
|
219 | #endif |
| 8061 | 220 | { "UTF8_STRING", 0, TARGET_UTF8_STRING }, |
| 221 | { "COMPOUND_TEXT", 0, TARGET_COMPOUND_TEXT }, | |
| 222 | { "STRING", 0, TARGET_STRING }, | |
| 223 | { "TEXT", 0, TARGET_TEXT}}; | |
| 224 | ||
|
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
|
225 | static const GtkTargetEntry link_drag_drop_targets[] = { |
|
10145
f1405f65ff41
[gaim-migrate @ 11218]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10110
diff
changeset
|
226 | GTK_IMHTML_DND_TARGETS |
|
f1405f65ff41
[gaim-migrate @ 11218]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10110
diff
changeset
|
227 | }; |
| 8091 | 228 | |
| 8692 | 229 | #ifdef _WIN32 |
| 230 | static gchar * | |
| 231 | clipboard_win32_to_html(char *clipboard) { | |
| 9465 | 232 | const char *header; |
| 8693 | 233 | const char *begin, *end; |
|
10016
18418b9fa749
[gaim-migrate @ 10935]
Daniel Atallah <datallah@pidgin.im>
parents:
10013
diff
changeset
|
234 | gint start = 0; |
|
18418b9fa749
[gaim-migrate @ 10935]
Daniel Atallah <datallah@pidgin.im>
parents:
10013
diff
changeset
|
235 | gint finish = 0; |
| 8692 | 236 | gchar *html; |
|
10016
18418b9fa749
[gaim-migrate @ 10935]
Daniel Atallah <datallah@pidgin.im>
parents:
10013
diff
changeset
|
237 | gchar **split; |
|
18418b9fa749
[gaim-migrate @ 10935]
Daniel Atallah <datallah@pidgin.im>
parents:
10013
diff
changeset
|
238 | int clipboard_length = 0; |
| 9465 | 239 | |
| 240 | #if 0 /* Debugging for Windows clipboard */ | |
| 9467 | 241 | FILE *fd; |
| 242 | ||
| 15884 | 243 | purple_debug_info("imhtml clipboard", "from clipboard: %s\n", clipboard); |
| 244 | ||
|
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
|
245 | fd = g_fopen("c:\\purplecb.txt", "wb"); |
| 9465 | 246 | fprintf(fd, "%s", clipboard); |
| 247 | fclose(fd); | |
| 248 | #endif | |
| 249 | ||
|
10016
18418b9fa749
[gaim-migrate @ 10935]
Daniel Atallah <datallah@pidgin.im>
parents:
10013
diff
changeset
|
250 | clipboard_length = strlen(clipboard); |
|
18418b9fa749
[gaim-migrate @ 10935]
Daniel Atallah <datallah@pidgin.im>
parents:
10013
diff
changeset
|
251 | |
|
18418b9fa749
[gaim-migrate @ 10935]
Daniel Atallah <datallah@pidgin.im>
parents:
10013
diff
changeset
|
252 | if (!(header = strstr(clipboard, "StartFragment:")) || (header - clipboard) >= clipboard_length) |
| 9465 | 253 | return NULL; |
| 254 | sscanf(header, "StartFragment:%d", &start); | |
| 255 | ||
|
10016
18418b9fa749
[gaim-migrate @ 10935]
Daniel Atallah <datallah@pidgin.im>
parents:
10013
diff
changeset
|
256 | if (!(header = strstr(clipboard, "EndFragment:")) || (header - clipboard) >= clipboard_length) |
|
18418b9fa749
[gaim-migrate @ 10935]
Daniel Atallah <datallah@pidgin.im>
parents:
10013
diff
changeset
|
257 | return NULL; |
| 9465 | 258 | sscanf(header, "EndFragment:%d", &finish); |
| 259 | ||
|
10016
18418b9fa749
[gaim-migrate @ 10935]
Daniel Atallah <datallah@pidgin.im>
parents:
10013
diff
changeset
|
260 | if (finish > clipboard_length) |
|
18418b9fa749
[gaim-migrate @ 10935]
Daniel Atallah <datallah@pidgin.im>
parents:
10013
diff
changeset
|
261 | finish = clipboard_length; |
|
18418b9fa749
[gaim-migrate @ 10935]
Daniel Atallah <datallah@pidgin.im>
parents:
10013
diff
changeset
|
262 | |
|
18418b9fa749
[gaim-migrate @ 10935]
Daniel Atallah <datallah@pidgin.im>
parents:
10013
diff
changeset
|
263 | if (start > finish) |
|
18418b9fa749
[gaim-migrate @ 10935]
Daniel Atallah <datallah@pidgin.im>
parents:
10013
diff
changeset
|
264 | start = finish; |
|
18418b9fa749
[gaim-migrate @ 10935]
Daniel Atallah <datallah@pidgin.im>
parents:
10013
diff
changeset
|
265 | |
| 9465 | 266 | begin = clipboard + start; |
| 267 | ||
|
10016
18418b9fa749
[gaim-migrate @ 10935]
Daniel Atallah <datallah@pidgin.im>
parents:
10013
diff
changeset
|
268 | end = clipboard + finish; |
|
18418b9fa749
[gaim-migrate @ 10935]
Daniel Atallah <datallah@pidgin.im>
parents:
10013
diff
changeset
|
269 | |
|
18418b9fa749
[gaim-migrate @ 10935]
Daniel Atallah <datallah@pidgin.im>
parents:
10013
diff
changeset
|
270 | html = g_strndup(begin, end - begin); |
|
18418b9fa749
[gaim-migrate @ 10935]
Daniel Atallah <datallah@pidgin.im>
parents:
10013
diff
changeset
|
271 | |
|
18418b9fa749
[gaim-migrate @ 10935]
Daniel Atallah <datallah@pidgin.im>
parents:
10013
diff
changeset
|
272 | /* 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
|
273 | split = g_strsplit(html, "\r\n", 0); |
|
18418b9fa749
[gaim-migrate @ 10935]
Daniel Atallah <datallah@pidgin.im>
parents:
10013
diff
changeset
|
274 | g_free(html); |
|
18418b9fa749
[gaim-migrate @ 10935]
Daniel Atallah <datallah@pidgin.im>
parents:
10013
diff
changeset
|
275 | html = g_strjoinv("\n", split); |
|
18418b9fa749
[gaim-migrate @ 10935]
Daniel Atallah <datallah@pidgin.im>
parents:
10013
diff
changeset
|
276 | g_strfreev(split); |
|
18418b9fa749
[gaim-migrate @ 10935]
Daniel Atallah <datallah@pidgin.im>
parents:
10013
diff
changeset
|
277 | |
| 9465 | 278 | #if 0 /* Debugging for Windows clipboard */ |
| 15884 | 279 | purple_debug_info("imhtml clipboard", "HTML fragment: '%s'\n", html); |
| 9465 | 280 | #endif |
| 281 | ||
| 8707 | 282 | return html; |
| 8692 | 283 | } |
| 284 | ||
| 285 | static gchar * | |
| 286 | clipboard_html_to_win32(char *html) { | |
| 8693 | 287 | int length; |
|
11240
cd4ca16ff57c
[gaim-migrate @ 13399]
Richard Laager <rlaager@pidgin.im>
parents:
11234
diff
changeset
|
288 | GString *clipboard; |
| 8692 | 289 | |
| 8693 | 290 | if (html == NULL) |
| 291 | return NULL; | |
| 8692 | 292 | |
| 293 | length = strlen(html); | |
| 9465 | 294 | clipboard = g_string_new ("Version:1.0\r\n"); |
| 8692 | 295 | 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
|
296 | g_string_append_printf(clipboard, "EndHTML:%010d\r\n", 147 + length); |
| 9465 | 297 | 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
|
298 | g_string_append_printf(clipboard, "EndFragment:%010d\r\n", 127 + length); |
| 9465 | 299 | g_string_append(clipboard, "<!--StartFragment-->\r\n"); |
| 8692 | 300 | g_string_append(clipboard, html); |
| 9465 | 301 | g_string_append(clipboard, "\r\n<!--EndFragment-->"); |
|
14101
89a79c2a971e
[gaim-migrate @ 16643]
Mark Doliner <markdoliner@pidgin.im>
parents:
14097
diff
changeset
|
302 | |
|
89a79c2a971e
[gaim-migrate @ 16643]
Mark Doliner <markdoliner@pidgin.im>
parents:
14097
diff
changeset
|
303 | return g_string_free(clipboard, FALSE); |
| 8692 | 304 | } |
|
10901
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
305 | |
|
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
306 | static gboolean clipboard_paste_html_win32(GtkIMHtml *imhtml) { |
|
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
307 | gboolean pasted = FALSE; |
|
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
308 | |
|
15111
e427dd6f3b7e
[gaim-migrate @ 17833]
Daniel Atallah <datallah@pidgin.im>
parents:
15093
diff
changeset
|
309 | /* Win32 clipboard format value, and functions to convert back and |
|
e427dd6f3b7e
[gaim-migrate @ 17833]
Daniel Atallah <datallah@pidgin.im>
parents:
15093
diff
changeset
|
310 | * forth between HTML and the clipboard format. |
|
e427dd6f3b7e
[gaim-migrate @ 17833]
Daniel Atallah <datallah@pidgin.im>
parents:
15093
diff
changeset
|
311 | */ |
|
e427dd6f3b7e
[gaim-migrate @ 17833]
Daniel Atallah <datallah@pidgin.im>
parents:
15093
diff
changeset
|
312 | static UINT win_html_fmt = 0; |
|
e427dd6f3b7e
[gaim-migrate @ 17833]
Daniel Atallah <datallah@pidgin.im>
parents:
15093
diff
changeset
|
313 | |
|
e427dd6f3b7e
[gaim-migrate @ 17833]
Daniel Atallah <datallah@pidgin.im>
parents:
15093
diff
changeset
|
314 | /* Register HTML Format as desired clipboard format */ |
|
e427dd6f3b7e
[gaim-migrate @ 17833]
Daniel Atallah <datallah@pidgin.im>
parents:
15093
diff
changeset
|
315 | if (!win_html_fmt) |
|
e427dd6f3b7e
[gaim-migrate @ 17833]
Daniel Atallah <datallah@pidgin.im>
parents:
15093
diff
changeset
|
316 | win_html_fmt = RegisterClipboardFormat("HTML Format"); |
|
e427dd6f3b7e
[gaim-migrate @ 17833]
Daniel Atallah <datallah@pidgin.im>
parents:
15093
diff
changeset
|
317 | |
|
10901
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
318 | if (gtk_text_view_get_editable(GTK_TEXT_VIEW(imhtml)) |
|
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
319 | && IsClipboardFormatAvailable(win_html_fmt)) { |
|
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
320 | gboolean error_reading_clipboard = FALSE; |
|
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
321 | HWND hwnd = GDK_WINDOW_HWND(GTK_WIDGET(imhtml)->window); |
|
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
322 | |
|
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
323 | if (OpenClipboard(hwnd)) { |
|
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
324 | HGLOBAL hdata = GetClipboardData(win_html_fmt); |
|
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
325 | if (hdata == NULL) { |
|
15111
e427dd6f3b7e
[gaim-migrate @ 17833]
Daniel Atallah <datallah@pidgin.im>
parents:
15093
diff
changeset
|
326 | if (GetLastError() != ERROR_SUCCESS) |
|
e427dd6f3b7e
[gaim-migrate @ 17833]
Daniel Atallah <datallah@pidgin.im>
parents:
15093
diff
changeset
|
327 | error_reading_clipboard = TRUE; |
|
10901
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
328 | } else { |
|
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
329 | char *buffer = GlobalLock(hdata); |
|
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
330 | if (buffer == NULL) { |
|
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
331 | error_reading_clipboard = TRUE; |
|
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
332 | } else { |
|
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
333 | char *text = clipboard_win32_to_html( |
|
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
334 | buffer); |
|
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
335 | imhtml_paste_insert(imhtml, text, |
|
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
336 | FALSE); |
|
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
337 | g_free(text); |
|
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
338 | pasted = TRUE; |
|
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
339 | } |
|
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
340 | GlobalUnlock(hdata); |
|
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
341 | } |
|
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
342 | |
|
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
343 | CloseClipboard(); |
|
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
344 | } else { |
|
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
345 | error_reading_clipboard = TRUE; |
|
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
346 | } |
|
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
347 | |
|
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
348 | if (error_reading_clipboard) { |
|
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
349 | gchar *err_msg = g_win32_error_message(GetLastError()); |
| 15884 | 350 | purple_debug_info("html clipboard", |
|
10901
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
351 | "Unable to read clipboard data: %s\n", |
|
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
352 | err_msg ? err_msg : "Unknown Error"); |
|
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
353 | g_free(err_msg); |
|
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
354 | } |
|
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
355 | } |
|
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
356 | |
|
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
357 | return pasted; |
|
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
358 | } |
| 8692 | 359 | #endif |
| 360 | ||
| 4032 | 361 | 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
|
362 | gtk_smiley_tree_new (void) |
| 4032 | 363 | { |
| 364 | return g_new0 (GtkSmileyTree, 1); | |
| 365 | } | |
| 366 | ||
| 367 | static void | |
| 368 | gtk_smiley_tree_insert (GtkSmileyTree *tree, | |
| 4263 | 369 | GtkIMHtmlSmiley *smiley) |
| 4032 | 370 | { |
| 371 | GtkSmileyTree *t = tree; | |
| 4263 | 372 | const gchar *x = smiley->smile; |
| 4032 | 373 | |
|
12229
ad8d3ae8fc1b
[gaim-migrate @ 14531]
Michael Carlson <corfe83@users.sourceforge.net>
parents:
12072
diff
changeset
|
374 | if (!(*x)) |
| 4032 | 375 | return; |
| 376 | ||
|
12229
ad8d3ae8fc1b
[gaim-migrate @ 14531]
Michael Carlson <corfe83@users.sourceforge.net>
parents:
12072
diff
changeset
|
377 | do { |
| 4032 | 378 | gchar *pos; |
| 379 | gint index; | |
| 380 | ||
| 381 | if (!t->values) | |
| 382 | t->values = g_string_new (""); | |
| 383 | ||
| 384 | pos = strchr (t->values->str, *x); | |
| 385 | if (!pos) { | |
| 386 | t->values = g_string_append_c (t->values, *x); | |
| 387 | index = t->values->len - 1; | |
| 388 | t->children = g_realloc (t->children, t->values->len * sizeof (GtkSmileyTree *)); | |
| 389 | t->children [index] = g_new0 (GtkSmileyTree, 1); | |
| 390 | } else | |
| 7386 | 391 | index = GPOINTER_TO_INT(pos) - GPOINTER_TO_INT(t->values->str); |
| 8061 | 392 | |
| 4032 | 393 | t = t->children [index]; |
| 8061 | 394 | |
| 4032 | 395 | x++; |
|
12229
ad8d3ae8fc1b
[gaim-migrate @ 14531]
Michael Carlson <corfe83@users.sourceforge.net>
parents:
12072
diff
changeset
|
396 | } while (*x); |
| 8061 | 397 | |
| 4263 | 398 | t->image = smiley; |
| 4032 | 399 | } |
| 4041 | 400 | |
| 4263 | 401 | |
|
11677
89c2ab8d2ebf
[gaim-migrate @ 13963]
Mark Doliner <markdoliner@pidgin.im>
parents:
11586
diff
changeset
|
402 | static void |
|
89c2ab8d2ebf
[gaim-migrate @ 13963]
Mark Doliner <markdoliner@pidgin.im>
parents:
11586
diff
changeset
|
403 | gtk_smiley_tree_destroy (GtkSmileyTree *tree) |
| 4032 | 404 | { |
|
11701
8cf812de5e92
[gaim-migrate @ 13992]
Michael Carlson <corfe83@users.sourceforge.net>
parents:
11677
diff
changeset
|
405 | GSList *list = g_slist_prepend (NULL, tree); |
| 4032 | 406 | |
| 407 | while (list) { | |
| 408 | GtkSmileyTree *t = list->data; | |
|
12229
ad8d3ae8fc1b
[gaim-migrate @ 14531]
Michael Carlson <corfe83@users.sourceforge.net>
parents:
12072
diff
changeset
|
409 | gsize i; |
| 4032 | 410 | list = g_slist_remove(list, t); |
| 7384 | 411 | if (t && t->values) { |
| 4032 | 412 | for (i = 0; i < t->values->len; i++) |
|
11701
8cf812de5e92
[gaim-migrate @ 13992]
Michael Carlson <corfe83@users.sourceforge.net>
parents:
11677
diff
changeset
|
413 | list = g_slist_prepend (list, t->children [i]); |
| 4032 | 414 | g_string_free (t->values, TRUE); |
| 415 | g_free (t->children); | |
| 416 | } | |
|
25888
d0fdd378a635
Remove trailing whitespace
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
417 | |
| 4032 | 418 | g_free (t); |
| 419 | } | |
| 420 | } | |
| 421 | ||
|
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
|
422 | 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
|
423 | |
|
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
|
424 | static void gtk_imhtml_size_allocate(GtkWidget *widget, GtkAllocation *alloc) |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
425 | { |
|
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
|
426 | GtkIMHtml *imhtml = GTK_IMHTML(widget); |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
427 | GdkRectangle rect; |
| 8726 | 428 | 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
|
429 | 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
|
430 | 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
|
431 | 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
|
432 | |
|
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
|
433 | gtk_text_buffer_get_end_iter(imhtml->text_buffer, &iter); |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
434 | |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
435 | 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
|
436 | 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
|
437 | |
|
e1f64090d32e
Do not show tooltips for <HR> or <IMG>s in gtkimhtml. Fixes #5480.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22772
diff
changeset
|
438 | 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
|
439 | 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
|
440 | 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
|
441 | } |
|
e1f64090d32e
Do not show tooltips for <HR> or <IMG>s in gtkimhtml. Fixes #5480.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22772
diff
changeset
|
442 | |
|
e1f64090d32e
Do not show tooltips for <HR> or <IMG>s in gtkimhtml. Fixes #5480.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22772
diff
changeset
|
443 | 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
|
444 | GList *iter = GTK_IMHTML(widget)->scalables; |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
445 | |
| 8726 | 446 | xminus = gtk_text_view_get_left_margin(GTK_TEXT_VIEW(widget)) + |
| 447 | gtk_text_view_get_right_margin(GTK_TEXT_VIEW(widget)); | |
| 448 | ||
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
449 | while(iter){ |
|
11224
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
450 | struct scalable_data *sd = iter->data; |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
451 | GtkIMHtmlScalable *scale = GTK_IMHTML_SCALABLE(sd->scalable); |
| 8726 | 452 | scale->scale(scale, rect.width - xminus, rect.height); |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
453 | |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
454 | iter = iter->next; |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
455 | } |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
456 | } |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
457 | |
|
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
|
458 | 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
|
459 | 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
|
460 | |
| 18985 | 461 | /* 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
|
462 | if (scroll && imhtml->scroll_time == NULL && |
|
32913
af2c726febce
Fix all deprecated GTK_WIDGET_* macros.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32604
diff
changeset
|
463 | gtk_widget_get_realized(GTK_WIDGET(imhtml))) |
|
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
|
464 | gtk_imhtml_scroll_to_end(imhtml, FALSE); |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
465 | } |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
466 | |
|
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
|
467 | #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
|
468 | #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
|
469 | #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
|
470 | #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
|
471 | #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
|
472 | #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
|
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 | 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
|
475 | |
|
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 | 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
|
477 | 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
|
478 | { |
|
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
|
479 | 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
|
480 | 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
|
481 | 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
|
482 | 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
|
483 | 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
|
484 | } 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
|
485 | {"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
|
486 | {"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
|
487 | {"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
|
488 | {"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
|
489 | {"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
|
490 | {"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
|
491 | {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
|
492 | }; |
|
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
|
493 | 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
|
494 | 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
|
495 | |
|
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
|
496 | 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
|
497 | 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
|
498 | 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
|
499 | 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
|
500 | 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
|
501 | 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
|
502 | } |
|
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
|
503 | 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
|
504 | 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
|
505 | 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
|
506 | 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
|
507 | } 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
|
508 | 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
|
509 | 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
|
510 | 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
|
511 | } |
|
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
|
512 | } |
|
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
|
513 | 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
|
514 | } |
|
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
|
515 | |
|
28935
84dbc0ca215d
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28932
diff
changeset
|
516 | static gboolean |
|
84dbc0ca215d
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28932
diff
changeset
|
517 | 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
|
518 | { |
|
84dbc0ca215d
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28932
diff
changeset
|
519 | if (imhtml->wbfo) { |
|
84dbc0ca215d
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28932
diff
changeset
|
520 | 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
|
521 | return TRUE; |
|
84dbc0ca215d
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28932
diff
changeset
|
522 | } else if (imhtml->editable) { |
|
84dbc0ca215d
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28932
diff
changeset
|
523 | 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
|
524 | 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
|
525 | 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
|
526 | *end = *start; |
|
84dbc0ca215d
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28932
diff
changeset
|
527 | } |
|
84dbc0ca215d
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28932
diff
changeset
|
528 | return TRUE; |
|
84dbc0ca215d
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28932
diff
changeset
|
529 | } |
|
84dbc0ca215d
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28932
diff
changeset
|
530 | |
|
84dbc0ca215d
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28932
diff
changeset
|
531 | return FALSE; |
|
84dbc0ca215d
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28932
diff
changeset
|
532 | } |
|
84dbc0ca215d
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28932
diff
changeset
|
533 | |
|
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
|
534 | 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
|
535 | 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
|
536 | { |
|
7be2af5c9129
Show visited links in a different color. This also plugs a memory leak
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23548
diff
changeset
|
537 | 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
|
538 | 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
|
539 | 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
|
540 | 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
|
541 | 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
|
542 | 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
|
543 | } 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
|
544 | 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
|
545 | } |
|
7be2af5c9129
Show visited links in a different color. This also plugs a memory leak
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23548
diff
changeset
|
546 | } |
|
7be2af5c9129
Show visited links in a different color. This also plugs a memory leak
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23548
diff
changeset
|
547 | |
|
33176
6594cdb0ab40
Fix imhtml tooltip paint function.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33170
diff
changeset
|
548 | #if GTK_CHECK_VERSION(3,0,0) |
|
6594cdb0ab40
Fix imhtml tooltip paint function.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33170
diff
changeset
|
549 | static gboolean |
|
6594cdb0ab40
Fix imhtml tooltip paint function.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33170
diff
changeset
|
550 | gtk_imhtml_tip_paint(GtkIMHtml *imhtml, cairo_t *cr, GtkWidget *w) |
|
6594cdb0ab40
Fix imhtml tooltip paint function.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33170
diff
changeset
|
551 | #else |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
552 | static gint |
|
33176
6594cdb0ab40
Fix imhtml tooltip paint function.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33170
diff
changeset
|
553 | gtk_imhtml_tip_paint(GtkIMHtml *imhtml, GdkEvent *event, GtkWidget *w) |
|
6594cdb0ab40
Fix imhtml tooltip paint function.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33170
diff
changeset
|
554 | #endif |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
555 | { |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
556 | PangoLayout *layout; |
|
33176
6594cdb0ab40
Fix imhtml tooltip paint function.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33170
diff
changeset
|
557 | GtkStyle *style; |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
558 | |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
559 | g_return_val_if_fail(GTK_IS_IMHTML(imhtml), FALSE); |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
560 | |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
561 | layout = gtk_widget_create_pango_layout(imhtml->tip_window, imhtml->tip); |
|
33176
6594cdb0ab40
Fix imhtml tooltip paint function.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33170
diff
changeset
|
562 | style = gtk_widget_get_style(imhtml->tip_window); |
|
6594cdb0ab40
Fix imhtml tooltip paint function.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33170
diff
changeset
|
563 | |
|
6594cdb0ab40
Fix imhtml tooltip paint function.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33170
diff
changeset
|
564 | #if GTK_CHECK_VERSION(3,0,0) |
|
6594cdb0ab40
Fix imhtml tooltip paint function.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33170
diff
changeset
|
565 | gtk_paint_flat_box(style, cr, |
|
6594cdb0ab40
Fix imhtml tooltip paint function.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33170
diff
changeset
|
566 | GTK_STATE_NORMAL, GTK_SHADOW_OUT, |
|
6594cdb0ab40
Fix imhtml tooltip paint function.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33170
diff
changeset
|
567 | imhtml->tip_window, "tooltip", |
|
6594cdb0ab40
Fix imhtml tooltip paint function.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33170
diff
changeset
|
568 | 0, 0, -1, -1); |
|
6594cdb0ab40
Fix imhtml tooltip paint function.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33170
diff
changeset
|
569 | |
|
6594cdb0ab40
Fix imhtml tooltip paint function.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33170
diff
changeset
|
570 | gtk_paint_layout(style, cr, |
|
6594cdb0ab40
Fix imhtml tooltip paint function.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33170
diff
changeset
|
571 | GTK_STATE_NORMAL, TRUE, imhtml->tip_window, NULL, |
|
6594cdb0ab40
Fix imhtml tooltip paint function.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33170
diff
changeset
|
572 | 4, 4, layout); |
|
6594cdb0ab40
Fix imhtml tooltip paint function.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33170
diff
changeset
|
573 | #else |
|
6594cdb0ab40
Fix imhtml tooltip paint function.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33170
diff
changeset
|
574 | gtk_paint_flat_box(style, gtk_widget_get_window(imhtml->tip_window), |
|
6594cdb0ab40
Fix imhtml tooltip paint function.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33170
diff
changeset
|
575 | GTK_STATE_NORMAL, GTK_SHADOW_OUT, |
|
6594cdb0ab40
Fix imhtml tooltip paint function.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33170
diff
changeset
|
576 | NULL, imhtml->tip_window, |
|
6594cdb0ab40
Fix imhtml tooltip paint function.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33170
diff
changeset
|
577 | "tooltip", 0, 0, -1, -1); |
|
6594cdb0ab40
Fix imhtml tooltip paint function.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33170
diff
changeset
|
578 | |
|
6594cdb0ab40
Fix imhtml tooltip paint function.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33170
diff
changeset
|
579 | gtk_paint_layout(style, gtk_widget_get_window(imhtml->tip_window), |
|
6594cdb0ab40
Fix imhtml tooltip paint function.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33170
diff
changeset
|
580 | GTK_STATE_NORMAL, FALSE, NULL, imhtml->tip_window, NULL, |
|
6594cdb0ab40
Fix imhtml tooltip paint function.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33170
diff
changeset
|
581 | 4, 4, layout); |
|
6594cdb0ab40
Fix imhtml tooltip paint function.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33170
diff
changeset
|
582 | #endif |
|
6594cdb0ab40
Fix imhtml tooltip paint function.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33170
diff
changeset
|
583 | |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
584 | g_object_unref(layout); |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
585 | return FALSE; |
|
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 | |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
588 | static gint |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
589 | gtk_imhtml_tip (gpointer data) |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
590 | { |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
591 | GtkIMHtml *imhtml = data; |
| 8526 | 592 | PangoFontMetrics *font_metrics; |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
593 | PangoLayout *layout; |
| 8526 | 594 | PangoFont *font; |
|
32413
00ad036bdf3d
Fix some indenting.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32412
diff
changeset
|
595 | GtkStyle *style = gtk_widget_get_style(imhtml->tip_window); |
|
00ad036bdf3d
Fix some indenting.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32412
diff
changeset
|
596 | GtkAllocation allocation; |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
597 | gint gap, x, y, h, w, scr_w, baseline_skip; |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
598 | |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
599 | g_return_val_if_fail(GTK_IS_IMHTML(imhtml), FALSE); |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
600 | |
|
32413
00ad036bdf3d
Fix some indenting.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32412
diff
changeset
|
601 | gtk_widget_get_allocation(GTK_WIDGET(imhtml), &allocation); |
|
00ad036bdf3d
Fix some indenting.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32412
diff
changeset
|
602 | |
|
32394
f883709bdba4
compiles using GTK+ 3 from git, beware it does not yet run, in fact it crashes...
Marcus Lundblad <malu@pidgin.im>
parents:
31207
diff
changeset
|
603 | if (!imhtml->tip || !gtk_widget_is_drawable(GTK_WIDGET(imhtml))) { |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
604 | imhtml->tip_timer = 0; |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
605 | return FALSE; |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
606 | } |
| 8061 | 607 | |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
608 | if (imhtml->tip_window){ |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
609 | gtk_widget_destroy (imhtml->tip_window); |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
610 | imhtml->tip_window = NULL; |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
611 | } |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
612 | |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
613 | imhtml->tip_timer = 0; |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
614 | imhtml->tip_window = gtk_window_new (GTK_WINDOW_POPUP); |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
615 | 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
|
616 | gtk_window_set_title(GTK_WINDOW(imhtml->tip_window), "GtkIMHtml"); |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
617 | gtk_window_set_resizable (GTK_WINDOW (imhtml->tip_window), FALSE); |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
618 | 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
|
619 | 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
|
620 | GDK_WINDOW_TYPE_HINT_TOOLTIP); |
|
33176
6594cdb0ab40
Fix imhtml tooltip paint function.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33170
diff
changeset
|
621 | #if GTK_CHECK_VERSION(3,0,0) |
|
6594cdb0ab40
Fix imhtml tooltip paint function.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33170
diff
changeset
|
622 | g_signal_connect_swapped(G_OBJECT(imhtml->tip_window), "draw", |
|
6594cdb0ab40
Fix imhtml tooltip paint function.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33170
diff
changeset
|
623 | G_CALLBACK(gtk_imhtml_tip_paint), imhtml); |
|
6594cdb0ab40
Fix imhtml tooltip paint function.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33170
diff
changeset
|
624 | #else |
|
6594cdb0ab40
Fix imhtml tooltip paint function.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33170
diff
changeset
|
625 | g_signal_connect_swapped(G_OBJECT(imhtml->tip_window), "expose_event", |
|
6594cdb0ab40
Fix imhtml tooltip paint function.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33170
diff
changeset
|
626 | G_CALLBACK(gtk_imhtml_tip_paint), imhtml); |
|
6594cdb0ab40
Fix imhtml tooltip paint function.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33170
diff
changeset
|
627 | #endif |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
628 | |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
629 | gtk_widget_ensure_style (imhtml->tip_window); |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
630 | layout = gtk_widget_create_pango_layout(imhtml->tip_window, imhtml->tip); |
| 8526 | 631 | font = pango_context_load_font(pango_layout_get_context(layout), |
|
32413
00ad036bdf3d
Fix some indenting.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32412
diff
changeset
|
632 | style->font_desc); |
| 8526 | 633 | |
| 634 | if (font == NULL) { | |
|
32394
f883709bdba4
compiles using GTK+ 3 from git, beware it does not yet run, in fact it crashes...
Marcus Lundblad <malu@pidgin.im>
parents:
31207
diff
changeset
|
635 | char *tmp = pango_font_description_to_string(style->font_desc); |
| 8526 | 636 | |
| 15884 | 637 | purple_debug(PURPLE_DEBUG_ERROR, "gtk_imhtml_tip", |
| 8526 | 638 | "pango_context_load_font() couldn't load font: '%s'\n", |
| 639 | tmp); | |
| 640 | g_free(tmp); | |
| 641 | ||
|
23174
6a5b2c601492
applied changes from a341780d901f6351a5cf768a08d30c8882d6cf2f
Daniel Atallah <datallah@pidgin.im>
parents:
22970
diff
changeset
|
642 | g_object_unref(layout); |
| 8526 | 643 | return FALSE; |
| 644 | } | |
| 645 | ||
| 646 | font_metrics = pango_font_get_metrics(font, NULL); | |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
647 | |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
648 | pango_layout_get_pixel_size(layout, &scr_w, NULL); |
| 8526 | 649 | gap = PANGO_PIXELS((pango_font_metrics_get_ascent(font_metrics) + |
| 650 | pango_font_metrics_get_descent(font_metrics))/ 4); | |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
651 | |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
652 | if (gap < 2) |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
653 | gap = 2; |
| 8526 | 654 | baseline_skip = PANGO_PIXELS(pango_font_metrics_get_ascent(font_metrics) + |
| 655 | pango_font_metrics_get_descent(font_metrics)); | |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
656 | w = 8 + scr_w; |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
657 | h = 8 + baseline_skip; |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
658 | |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
659 | gdk_window_get_pointer (NULL, &x, &y, NULL); |
|
32394
f883709bdba4
compiles using GTK+ 3 from git, beware it does not yet run, in fact it crashes...
Marcus Lundblad <malu@pidgin.im>
parents:
31207
diff
changeset
|
660 | if ((!gtk_widget_get_has_window(GTK_WIDGET(imhtml)))) |
|
f883709bdba4
compiles using GTK+ 3 from git, beware it does not yet run, in fact it crashes...
Marcus Lundblad <malu@pidgin.im>
parents:
31207
diff
changeset
|
661 | y += allocation.y; |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
662 | |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
663 | scr_w = gdk_screen_width(); |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
664 | |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
665 | x -= ((w >> 1) + 4); |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
666 | |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
667 | if ((x + w) > scr_w) |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
668 | x -= (x + w) - scr_w; |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
669 | else if (x < 0) |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
670 | x = 0; |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
671 | |
| 8526 | 672 | y = y + PANGO_PIXELS(pango_font_metrics_get_ascent(font_metrics) + |
| 673 | pango_font_metrics_get_descent(font_metrics)); | |
|
5967
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 | 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
|
676 | gtk_window_move (GTK_WINDOW(imhtml->tip_window), x, y); |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
677 | gtk_widget_show (imhtml->tip_window); |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
678 | |
| 8526 | 679 | pango_font_metrics_unref(font_metrics); |
|
23174
6a5b2c601492
applied changes from a341780d901f6351a5cf768a08d30c8882d6cf2f
Daniel Atallah <datallah@pidgin.im>
parents:
22970
diff
changeset
|
680 | g_object_unref(font); |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
681 | g_object_unref(layout); |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
682 | |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
683 | return FALSE; |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
684 | } |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
685 | |
|
11844
57ad7c52cc9c
[gaim-migrate @ 14135]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11840
diff
changeset
|
686 | static gboolean |
|
57ad7c52cc9c
[gaim-migrate @ 14135]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11840
diff
changeset
|
687 | gtk_motion_event_notify(GtkWidget *imhtml, GdkEventMotion *event, gpointer data) |
| 8061 | 688 | { |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
689 | GtkTextIter iter; |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
690 | GdkWindow *win = event->window; |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
691 | int x, y; |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
692 | char *tip = NULL; |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
693 | GSList *tags = NULL, *templist = NULL; |
| 10799 | 694 | GtkTextTag *tag = NULL, *oldprelit_tag; |
|
18543
c590aed61aa4
Show tooltip for smileys. Fixes #1981.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18371
diff
changeset
|
695 | GtkTextChildAnchor* anchor; |
|
c590aed61aa4
Show tooltip for smileys. Fixes #1981.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18371
diff
changeset
|
696 | 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
|
697 | GdkCursor *cursor = NULL; |
| 10799 | 698 | |
| 699 | oldprelit_tag = GTK_IMHTML(imhtml)->prelit_tag; | |
| 700 | ||
|
32394
f883709bdba4
compiles using GTK+ 3 from git, beware it does not yet run, in fact it crashes...
Marcus Lundblad <malu@pidgin.im>
parents:
31207
diff
changeset
|
701 | gdk_window_get_pointer(gtk_widget_get_window(GTK_WIDGET(imhtml)), NULL, NULL, NULL); |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
702 | gtk_text_view_window_to_buffer_coords(GTK_TEXT_VIEW(imhtml), GTK_TEXT_WINDOW_WIDGET, |
| 10799 | 703 | event->x, event->y, &x, &y); |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
704 | 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
|
705 | tags = gtk_text_iter_get_tags(&iter); |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
706 | |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
707 | templist = tags; |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
708 | while (templist) { |
| 10799 | 709 | tag = templist->data; |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
710 | tip = g_object_get_data(G_OBJECT(tag), "link_url"); |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
711 | if (tip) |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
712 | break; |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
713 | templist = templist->next; |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
714 | } |
| 8061 | 715 | |
|
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
|
716 | if (tip && (!tag || !g_object_get_data(G_OBJECT(tag), "visited"))) { |
| 10799 | 717 | GTK_IMHTML(imhtml)->prelit_tag = tag; |
| 718 | 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
|
719 | 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
|
720 | 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
|
721 | if (pre) { |
| 10799 | 722 | 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
|
723 | 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
|
724 | } else |
|
12253
5025434b18f8
[gaim-migrate @ 14555]
Mark Doliner <markdoliner@pidgin.im>
parents:
12230
diff
changeset
|
725 | g_object_set(G_OBJECT(tag), "foreground", "#70a0ff", NULL); |
| 10799 | 726 | } |
| 727 | } else { | |
| 728 | GTK_IMHTML(imhtml)->prelit_tag = NULL; | |
| 729 | } | |
|
11572
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
730 | |
|
10834
5fd1dfd395e8
[gaim-migrate @ 12505]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10826
diff
changeset
|
731 | 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
|
732 | gtk_imhtml_set_link_color(GTK_IMHTML(imhtml), oldprelit_tag); |
| 10799 | 733 | } |
| 734 | ||
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
735 | if (GTK_IMHTML(imhtml)->tip) { |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
736 | if ((tip == GTK_IMHTML(imhtml)->tip)) { |
| 21069 | 737 | g_slist_free(tags); |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
738 | return FALSE; |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
739 | } |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
740 | /* 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
|
741 | if (GTK_IMHTML(imhtml)->tip_window) { |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
742 | gtk_widget_destroy(GTK_IMHTML(imhtml)->tip_window); |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
743 | GTK_IMHTML(imhtml)->tip_window = NULL; |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
744 | } |
| 8061 | 745 | 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
|
746 | cursor = GTK_IMHTML(imhtml)->text_cursor; |
| 8061 | 747 | 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
|
748 | cursor = GTK_IMHTML(imhtml)->arrow_cursor; |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
749 | if (GTK_IMHTML(imhtml)->tip_timer) |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
750 | g_source_remove(GTK_IMHTML(imhtml)->tip_timer); |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
751 | GTK_IMHTML(imhtml)->tip_timer = 0; |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
752 | } |
| 8061 | 753 | |
|
18543
c590aed61aa4
Show tooltip for smileys. Fixes #1981.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18371
diff
changeset
|
754 | /* 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
|
755 | 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
|
756 | 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
|
757 | 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
|
758 | hand = FALSE; |
|
c590aed61aa4
Show tooltip for smileys. Fixes #1981.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18371
diff
changeset
|
759 | } |
|
c590aed61aa4
Show tooltip for smileys. Fixes #1981.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18371
diff
changeset
|
760 | |
|
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
|
761 | if (tip && *tip) { |
| 8061 | 762 | GTK_IMHTML(imhtml)->tip_timer = g_timeout_add (TOOLTIP_TIMEOUT, |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
763 | 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
|
764 | } 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
|
765 | 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
|
766 | 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
|
767 | 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
|
768 | 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
|
769 | 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
|
770 | 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
|
771 | } |
|
b94fa8bc1a03
Change the cursor and act on double click on usernames in chat history.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
29288
diff
changeset
|
772 | } |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
773 | } |
| 8061 | 774 | |
|
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
|
775 | 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
|
776 | 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
|
777 | |
|
b94fa8bc1a03
Change the cursor and act on double click on usernames in chat history.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
29288
diff
changeset
|
778 | 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
|
779 | 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
|
780 | |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
781 | GTK_IMHTML(imhtml)->tip = tip; |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
782 | g_slist_free(tags); |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
783 | return FALSE; |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
784 | } |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
785 | |
|
11677
89c2ab8d2ebf
[gaim-migrate @ 13963]
Mark Doliner <markdoliner@pidgin.im>
parents:
11586
diff
changeset
|
786 | static gboolean |
|
89c2ab8d2ebf
[gaim-migrate @ 13963]
Mark Doliner <markdoliner@pidgin.im>
parents:
11586
diff
changeset
|
787 | gtk_enter_event_notify(GtkWidget *imhtml, GdkEventCrossing *event, gpointer data) |
|
10946
63a41710fc94
[gaim-migrate @ 12742]
Daniel Atallah <datallah@pidgin.im>
parents:
10936
diff
changeset
|
788 | { |
|
63a41710fc94
[gaim-migrate @ 12742]
Daniel Atallah <datallah@pidgin.im>
parents:
10936
diff
changeset
|
789 | if (GTK_IMHTML(imhtml)->editable) |
|
63a41710fc94
[gaim-migrate @ 12742]
Daniel Atallah <datallah@pidgin.im>
parents:
10936
diff
changeset
|
790 | gdk_window_set_cursor( |
|
63a41710fc94
[gaim-migrate @ 12742]
Daniel Atallah <datallah@pidgin.im>
parents:
10936
diff
changeset
|
791 | gtk_text_view_get_window(GTK_TEXT_VIEW(imhtml), |
|
63a41710fc94
[gaim-migrate @ 12742]
Daniel Atallah <datallah@pidgin.im>
parents:
10936
diff
changeset
|
792 | GTK_TEXT_WINDOW_TEXT), |
|
63a41710fc94
[gaim-migrate @ 12742]
Daniel Atallah <datallah@pidgin.im>
parents:
10936
diff
changeset
|
793 | GTK_IMHTML(imhtml)->text_cursor); |
|
63a41710fc94
[gaim-migrate @ 12742]
Daniel Atallah <datallah@pidgin.im>
parents:
10936
diff
changeset
|
794 | else |
|
63a41710fc94
[gaim-migrate @ 12742]
Daniel Atallah <datallah@pidgin.im>
parents:
10936
diff
changeset
|
795 | gdk_window_set_cursor( |
|
63a41710fc94
[gaim-migrate @ 12742]
Daniel Atallah <datallah@pidgin.im>
parents:
10936
diff
changeset
|
796 | gtk_text_view_get_window(GTK_TEXT_VIEW(imhtml), |
|
63a41710fc94
[gaim-migrate @ 12742]
Daniel Atallah <datallah@pidgin.im>
parents:
10936
diff
changeset
|
797 | GTK_TEXT_WINDOW_TEXT), |
|
63a41710fc94
[gaim-migrate @ 12742]
Daniel Atallah <datallah@pidgin.im>
parents:
10936
diff
changeset
|
798 | GTK_IMHTML(imhtml)->arrow_cursor); |
|
63a41710fc94
[gaim-migrate @ 12742]
Daniel Atallah <datallah@pidgin.im>
parents:
10936
diff
changeset
|
799 | |
|
63a41710fc94
[gaim-migrate @ 12742]
Daniel Atallah <datallah@pidgin.im>
parents:
10936
diff
changeset
|
800 | /* propagate the event normally */ |
|
63a41710fc94
[gaim-migrate @ 12742]
Daniel Atallah <datallah@pidgin.im>
parents:
10936
diff
changeset
|
801 | return FALSE; |
|
63a41710fc94
[gaim-migrate @ 12742]
Daniel Atallah <datallah@pidgin.im>
parents:
10936
diff
changeset
|
802 | } |
|
63a41710fc94
[gaim-migrate @ 12742]
Daniel Atallah <datallah@pidgin.im>
parents:
10936
diff
changeset
|
803 | |
|
11677
89c2ab8d2ebf
[gaim-migrate @ 13963]
Mark Doliner <markdoliner@pidgin.im>
parents:
11586
diff
changeset
|
804 | static gboolean |
|
89c2ab8d2ebf
[gaim-migrate @ 13963]
Mark Doliner <markdoliner@pidgin.im>
parents:
11586
diff
changeset
|
805 | gtk_leave_event_notify(GtkWidget *imhtml, GdkEventCrossing *event, gpointer data) |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
806 | { |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
807 | /* when leaving the widget, clear any current & pending tooltips and restore the cursor */ |
| 10799 | 808 | 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
|
809 | gtk_imhtml_set_link_color(GTK_IMHTML(imhtml), GTK_IMHTML(imhtml)->prelit_tag); |
| 10799 | 810 | GTK_IMHTML(imhtml)->prelit_tag = NULL; |
| 811 | } | |
| 812 | ||
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
813 | if (GTK_IMHTML(imhtml)->tip_window) { |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
814 | gtk_widget_destroy(GTK_IMHTML(imhtml)->tip_window); |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
815 | GTK_IMHTML(imhtml)->tip_window = NULL; |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
816 | } |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
817 | if (GTK_IMHTML(imhtml)->tip_timer) { |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
818 | g_source_remove(GTK_IMHTML(imhtml)->tip_timer); |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
819 | GTK_IMHTML(imhtml)->tip_timer = 0; |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
820 | } |
|
10946
63a41710fc94
[gaim-migrate @ 12742]
Daniel Atallah <datallah@pidgin.im>
parents:
10936
diff
changeset
|
821 | gdk_window_set_cursor( |
|
63a41710fc94
[gaim-migrate @ 12742]
Daniel Atallah <datallah@pidgin.im>
parents:
10936
diff
changeset
|
822 | gtk_text_view_get_window(GTK_TEXT_VIEW(imhtml), |
|
63a41710fc94
[gaim-migrate @ 12742]
Daniel Atallah <datallah@pidgin.im>
parents:
10936
diff
changeset
|
823 | GTK_TEXT_WINDOW_TEXT), NULL); |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
824 | |
|
8568
66907b37ce85
[gaim-migrate @ 9316]
Mark Doliner <markdoliner@pidgin.im>
parents:
8566
diff
changeset
|
825 | /* propagate the event normally */ |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
826 | return FALSE; |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
827 | } |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
828 | |
|
32413
00ad036bdf3d
Fix some indenting.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32412
diff
changeset
|
829 | /* TODO: I think this can be removed for GTK+ 3.0... */ |
|
33170
ce4447562d64
Add checks for old GTK+2 stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33132
diff
changeset
|
830 | #if !GTK_CHECK_VERSION(3,0,0) |
| 10692 | 831 | static gint |
| 832 | gtk_imhtml_expose_event (GtkWidget *widget, | |
| 833 | GdkEventExpose *event) | |
| 834 | { | |
| 10776 | 835 | GtkTextIter start, end, cur; |
| 836 | int buf_x, buf_y; | |
| 837 | 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
|
838 | cairo_t *cr = gdk_cairo_create(GDK_DRAWABLE(event->window)); |
| 10777 | 839 | GdkColor gcolor; |
|
10844
fb5b88957742
[gaim-migrate @ 12516]
Richard Laager <rlaager@pidgin.im>
parents:
10834
diff
changeset
|
840 | |
| 10776 | 841 | gtk_text_view_get_visible_rect(GTK_TEXT_VIEW(widget), &visible_rect); |
| 842 | gtk_text_view_buffer_to_window_coords(GTK_TEXT_VIEW(widget), | |
| 843 | GTK_TEXT_WINDOW_TEXT, | |
| 844 | visible_rect.x, | |
| 845 | visible_rect.y, | |
| 846 | &visible_rect.x, | |
| 847 | &visible_rect.y); | |
| 848 | ||
| 849 | gtk_text_view_window_to_buffer_coords(GTK_TEXT_VIEW(widget), GTK_TEXT_WINDOW_TEXT, | |
| 850 | event->area.x, event->area.y, &buf_x, &buf_y); | |
| 851 | ||
| 10777 | 852 | if (GTK_IMHTML(widget)->editable || GTK_IMHTML(widget)->wbfo) { |
|
11572
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
853 | |
| 10777 | 854 | if (GTK_IMHTML(widget)->edit.background) { |
| 855 | 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
|
856 | gdk_cairo_set_source_color(cr, &gcolor); |
| 10777 | 857 | } else { |
|
32394
f883709bdba4
compiles using GTK+ 3 from git, beware it does not yet run, in fact it crashes...
Marcus Lundblad <malu@pidgin.im>
parents:
31207
diff
changeset
|
858 | gdk_cairo_set_source_color(cr, |
|
32413
00ad036bdf3d
Fix some indenting.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32412
diff
changeset
|
859 | &(gtk_widget_get_style(widget)->base[gtk_widget_get_state(widget)])); |
| 10777 | 860 | } |
|
11572
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
861 | |
|
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
|
862 | 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
|
863 | 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
|
864 | 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
|
865 | 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
|
866 | cairo_destroy(cr); |
|
11572
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
867 | |
| 10777 | 868 | if (GTK_WIDGET_CLASS (parent_class)->expose_event) |
| 869 | return (* GTK_WIDGET_CLASS (parent_class)->expose_event) | |
| 870 | (widget, event); | |
| 871 | return FALSE; | |
| 872 | ||
| 873 | } | |
|
11572
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
874 | |
| 10776 | 875 | gtk_text_view_get_iter_at_location(GTK_TEXT_VIEW(widget), &start, buf_x, buf_y); |
| 876 | gtk_text_view_get_iter_at_location(GTK_TEXT_VIEW(widget), &end, | |
| 877 | buf_x + event->area.width, buf_y + event->area.height); | |
| 878 | ||
|
23187
671e00775afb
*** Plucked rev 69b22e32f7ada182101e0746f02891389ceb0c52 (sadrul@pidgin.im):
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23174
diff
changeset
|
879 | gtk_text_iter_order(&start, &end); |
| 10776 | 880 | |
| 881 | cur = start; | |
| 882 | ||
| 883 | while (gtk_text_iter_in_range(&cur, &start, &end)) { | |
| 10795 | 884 | GSList *tags = gtk_text_iter_get_tags(&cur); |
| 885 | GSList *l; | |
| 10776 | 886 | |
| 887 | for (l = tags; l; l = l->next) { | |
| 888 | GtkTextTag *tag = l->data; | |
| 889 | GdkRectangle rect; | |
| 890 | GdkRectangle tag_area; | |
| 891 | const char *color; | |
|
11572
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
892 | |
| 10776 | 893 | if (strncmp(tag->name, "BACKGROUND ", 11)) |
| 894 | continue; | |
| 895 | ||
| 896 | if (gtk_text_iter_ends_tag(&cur, tag)) | |
| 897 | continue; | |
| 898 | ||
| 899 | gtk_text_view_get_iter_location(GTK_TEXT_VIEW(widget), &cur, &tag_area); | |
| 900 | gtk_text_view_buffer_to_window_coords(GTK_TEXT_VIEW(widget), | |
| 901 | GTK_TEXT_WINDOW_TEXT, | |
| 902 | tag_area.x, | |
| 903 | tag_area.y, | |
| 904 | &tag_area.x, | |
| 905 | &tag_area.y); | |
| 906 | rect.x = visible_rect.x; | |
| 907 | rect.y = tag_area.y; | |
|
11768
b45e26d7a4c9
[gaim-migrate @ 14059]
Gary Kramlich <grim@reaperworld.com>
parents:
11760
diff
changeset
|
908 | rect.width = visible_rect.width; |
| 10776 | 909 | |
| 10795 | 910 | do |
| 10776 | 911 | gtk_text_iter_forward_to_tag_toggle(&cur, tag); |
| 10795 | 912 | while (!gtk_text_iter_is_end(&cur) && gtk_text_iter_begins_tag(&cur, tag)); |
| 913 | ||
| 10776 | 914 | gtk_text_view_get_iter_location(GTK_TEXT_VIEW(widget), &cur, &tag_area); |
| 915 | gtk_text_view_buffer_to_window_coords(GTK_TEXT_VIEW(widget), | |
| 916 | GTK_TEXT_WINDOW_TEXT, | |
| 917 | tag_area.x, | |
| 918 | tag_area.y, | |
| 919 | &tag_area.x, | |
| 920 | &tag_area.y); | |
| 921 | ||
|
25888
d0fdd378a635
Remove trailing whitespace
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
922 | |
| 11760 | 923 | 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
|
924 | + gtk_text_view_get_pixels_above_lines(GTK_TEXT_VIEW(widget)) |
| 11760 | 925 | + 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
|
926 | |
| 10776 | 927 | color = tag->name + 11; |
| 928 | ||
| 10857 | 929 | if (!gdk_color_parse(color, &gcolor)) { |
| 10858 | 930 | gchar tmp[8]; |
| 931 | tmp[0] = '#'; | |
| 932 | strncpy(&tmp[1], color, 7); | |
| 933 | tmp[7] = '\0'; | |
| 10857 | 934 | if (!gdk_color_parse(tmp, &gcolor)) |
| 935 | gdk_color_parse("white", &gcolor); | |
| 936 | } | |
|
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
|
937 | 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
|
938 | |
|
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
|
939 | 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
|
940 | 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
|
941 | 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
|
942 | cairo_fill(cr); |
| 10795 | 943 | gtk_text_iter_backward_char(&cur); /* go back one, in case the end is the begining is the end |
| 944 | * note that above, we always moved cur ahead by at least | |
| 945 | * one character */ | |
| 10776 | 946 | break; |
| 947 | } | |
| 948 | ||
| 949 | g_slist_free(tags); | |
| 10795 | 950 | |
| 951 | /* loop until another tag begins, or no tag begins */ | |
| 952 | while (gtk_text_iter_forward_to_tag_toggle(&cur, NULL) && | |
| 953 | !gtk_text_iter_is_end(&cur) && | |
| 954 | !gtk_text_iter_begins_tag(&cur, NULL)); | |
|
11572
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
955 | } |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
956 | |
|
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
|
957 | cairo_destroy(cr); |
| 10777 | 958 | |
| 10692 | 959 | if (GTK_WIDGET_CLASS (parent_class)->expose_event) |
| 960 | return (* GTK_WIDGET_CLASS (parent_class)->expose_event) | |
| 961 | (widget, event); | |
| 10776 | 962 | |
| 10692 | 963 | return FALSE; |
| 964 | } | |
|
32394
f883709bdba4
compiles using GTK+ 3 from git, beware it does not yet run, in fact it crashes...
Marcus Lundblad <malu@pidgin.im>
parents:
31207
diff
changeset
|
965 | #endif |
| 10692 | 966 | |
| 967 | ||
| 8931 | 968 | static void paste_unformatted_cb(GtkMenuItem *menu, GtkIMHtml *imhtml) |
| 969 | { | |
| 970 | GtkClipboard *clipboard = gtk_widget_get_clipboard(GTK_WIDGET(imhtml), GDK_SELECTION_CLIPBOARD); | |
| 971 | ||
| 972 | gtk_clipboard_request_text(clipboard, paste_plaintext_received_cb, imhtml); | |
| 973 | ||
| 974 | } | |
| 975 | ||
| 13336 | 976 | static void clear_formatting_cb(GtkMenuItem *menu, GtkIMHtml *imhtml) |
| 977 | { | |
| 978 | gtk_imhtml_clear_formatting(imhtml); | |
| 979 | } | |
| 10692 | 980 | |
|
22970
87aef86d20c5
Allow replacing smileys with texts in conversations/logs. This should be
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22865
diff
changeset
|
981 | 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
|
982 | { |
|
87aef86d20c5
Allow replacing smileys with texts in conversations/logs. This should be
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22865
diff
changeset
|
983 | 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
|
984 | GtkTextMark *mark; |
|
87aef86d20c5
Allow replacing smileys with texts in conversations/logs. This should be
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22865
diff
changeset
|
985 | char *text; |
|
87aef86d20c5
Allow replacing smileys with texts in conversations/logs. This should be
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22865
diff
changeset
|
986 | |
|
87aef86d20c5
Allow replacing smileys with texts in conversations/logs. This should be
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22865
diff
changeset
|
987 | 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
|
988 | return; |
|
87aef86d20c5
Allow replacing smileys with texts in conversations/logs. This should be
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22865
diff
changeset
|
989 | |
|
87aef86d20c5
Allow replacing smileys with texts in conversations/logs. This should be
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22865
diff
changeset
|
990 | 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
|
991 | |
|
87aef86d20c5
Allow replacing smileys with texts in conversations/logs. This should be
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22865
diff
changeset
|
992 | 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
|
993 | 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
|
994 | |
|
87aef86d20c5
Allow replacing smileys with texts in conversations/logs. This should be
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22865
diff
changeset
|
995 | 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
|
996 | 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
|
997 | |
|
87aef86d20c5
Allow replacing smileys with texts in conversations/logs. This should be
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22865
diff
changeset
|
998 | 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
|
999 | } |
|
87aef86d20c5
Allow replacing smileys with texts in conversations/logs. This should be
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22865
diff
changeset
|
1000 | |
| 8931 | 1001 | static void hijack_menu_cb(GtkIMHtml *imhtml, GtkMenu *menu, gpointer data) |
| 1002 | { | |
| 1003 | 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
|
1004 | GtkTextIter start, end; |
| 8931 | 1005 | |
|
12635
5b2fbc3da55b
[gaim-migrate @ 14971]
Richard Laager <rlaager@pidgin.im>
parents:
12605
diff
changeset
|
1006 | menuitem = gtk_menu_item_new_with_mnemonic(_("Paste as Plain _Text")); |
| 8931 | 1007 | gtk_widget_show(menuitem); |
|
14970
fd8984ce4fda
[gaim-migrate @ 17680]
Mark Doliner <markdoliner@pidgin.im>
parents:
14863
diff
changeset
|
1008 | /* |
|
fd8984ce4fda
[gaim-migrate @ 17680]
Mark Doliner <markdoliner@pidgin.im>
parents:
14863
diff
changeset
|
1009 | * TODO: gtk_clipboard_wait_is_text_available() iterates the glib |
|
fd8984ce4fda
[gaim-migrate @ 17680]
Mark Doliner <markdoliner@pidgin.im>
parents:
14863
diff
changeset
|
1010 | * mainloop, which tends to be a source of bugs. It would |
|
fd8984ce4fda
[gaim-migrate @ 17680]
Mark Doliner <markdoliner@pidgin.im>
parents:
14863
diff
changeset
|
1011 | * be good to audit this or change it to not wait. |
|
fd8984ce4fda
[gaim-migrate @ 17680]
Mark Doliner <markdoliner@pidgin.im>
parents:
14863
diff
changeset
|
1012 | */ |
| 8931 | 1013 | gtk_widget_set_sensitive(menuitem, |
|
12836
837fe5d43dac
[gaim-migrate @ 15184]
Richard Laager <rlaager@pidgin.im>
parents:
12833
diff
changeset
|
1014 | (imhtml->editable && |
|
837fe5d43dac
[gaim-migrate @ 15184]
Richard Laager <rlaager@pidgin.im>
parents:
12833
diff
changeset
|
1015 | gtk_clipboard_wait_is_text_available( |
|
837fe5d43dac
[gaim-migrate @ 15184]
Richard Laager <rlaager@pidgin.im>
parents:
12833
diff
changeset
|
1016 | gtk_widget_get_clipboard(GTK_WIDGET(imhtml), GDK_SELECTION_CLIPBOARD)))); |
| 8931 | 1017 | /* put it after "Paste" */ |
| 1018 | gtk_menu_shell_insert(GTK_MENU_SHELL(menu), menuitem, 3); | |
| 1019 | ||
| 1020 | g_signal_connect(G_OBJECT(menuitem), "activate", | |
| 1021 | G_CALLBACK(paste_unformatted_cb), imhtml); | |
| 13336 | 1022 | |
|
13539
8036a635a316
[gaim-migrate @ 15915]
Richard Laager <rlaager@pidgin.im>
parents:
13340
diff
changeset
|
1023 | menuitem = gtk_menu_item_new_with_mnemonic(_("_Reset formatting")); |
| 13336 | 1024 | gtk_widget_show(menuitem); |
|
13340
e18166659513
[gaim-migrate @ 15709]
Richard Laager <rlaager@pidgin.im>
parents:
13336
diff
changeset
|
1025 | gtk_widget_set_sensitive(menuitem, imhtml->editable); |
| 13336 | 1026 | /* put it after Delete */ |
| 1027 | gtk_menu_shell_insert(GTK_MENU_SHELL(menu), menuitem, 5); | |
| 1028 | ||
| 1029 | 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
|
1030 | |
|
87aef86d20c5
Allow replacing smileys with texts in conversations/logs. This should be
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22865
diff
changeset
|
1031 | 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
|
1032 | 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
|
1033 | 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
|
1034 | 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
|
1035 | } else { |
|
87aef86d20c5
Allow replacing smileys with texts in conversations/logs. This should be
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22865
diff
changeset
|
1036 | 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
|
1037 | } |
|
87aef86d20c5
Allow replacing smileys with texts in conversations/logs. This should be
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22865
diff
changeset
|
1038 | gtk_menu_shell_insert(GTK_MENU_SHELL(menu), menuitem, 6); |
| 8931 | 1039 | } |
| 1040 | ||
|
11572
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
1041 | static char * |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
1042 | ucs2_order(gboolean swap) |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
1043 | { |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
1044 | gboolean be; |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
1045 | |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
1046 | be = G_BYTE_ORDER == G_BIG_ENDIAN; |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
1047 | be = swap ? be : !be; |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
1048 | |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
1049 | 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
|
1050 | return "UTF-16BE"; |
|
11572
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
1051 | 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
|
1052 | return "UTF-16LE"; |
|
11572
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
1053 | |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
1054 | } |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
1055 | |
|
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
|
1056 | /* 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
|
1057 | 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
|
1058 | utf16_to_utf8_with_bom_check(gchar *data, guint len) { |
|
11572
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
1059 | char *fromcode = NULL; |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
1060 | GError *error = NULL; |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
1061 | guint16 c; |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
1062 | gchar *utf8_ret; |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
1063 | |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
1064 | /* |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
1065 | * Unicode Techinical Report 20 |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
1066 | * ( http://www.unicode.org/unicode/reports/tr20/ ) says to treat an |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
1067 | * initial 0xfeff (ZWNBSP) as a byte order indicator so that is |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
1068 | * 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
|
1069 | * order |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
1070 | */ |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
1071 | |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
1072 | memcpy(&c, data, 2); |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
1073 | switch (c) { |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
1074 | case 0xfeff: |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
1075 | case 0xfffe: |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
1076 | fromcode = ucs2_order(c == 0xfeff); |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
1077 | data += 2; |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
1078 | len -= 2; |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
1079 | break; |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
1080 | 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
|
1081 | fromcode = "UTF-16"; |
|
11572
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
1082 | break; |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
1083 | } |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
1084 | |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
1085 | 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
|
1086 | |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
1087 | if (error) { |
| 15884 | 1088 | 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
|
1089 | g_error_free(error); |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
1090 | } |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
1091 | return utf8_ret; |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
1092 | } |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
1093 | |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
1094 | |
| 8061 | 1095 | 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
|
1096 | 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
|
1097 | gboolean primary = (clipboard != clipboard_selection); |
| 8061 | 1098 | 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
|
1099 | |
|
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 | 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
|
1101 | 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
|
1102 | |
|
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
|
1103 | 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
|
1104 | |
|
17546
51b1c1e2c3fe
Maintain global poitners to the clipboard selection text, with the aim of
Sean Egan <seanegan@pidgin.im>
parents:
17406
diff
changeset
|
1105 | 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
|
1106 | 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
|
1107 | 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
|
1108 | 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
|
1109 | } |
| 8061 | 1110 | |
| 1111 | if (info == TARGET_HTML) { | |
|
15111
e427dd6f3b7e
[gaim-migrate @ 17833]
Daniel Atallah <datallah@pidgin.im>
parents:
15093
diff
changeset
|
1112 | char *selection; |
|
e427dd6f3b7e
[gaim-migrate @ 17833]
Daniel Atallah <datallah@pidgin.im>
parents:
15093
diff
changeset
|
1113 | #ifndef _WIN32 |
| 8907 | 1114 | gsize len; |
| 8681 | 1115 | if (primary) { |
| 1116 | text = gtk_imhtml_get_markup_range(imhtml, &start, &end); | |
| 10013 | 1117 | } else |
|
17546
51b1c1e2c3fe
Maintain global poitners to the clipboard selection text, with the aim of
Sean Egan <seanegan@pidgin.im>
parents:
17406
diff
changeset
|
1118 | text = html_clipboard; |
| 8061 | 1119 | |
| 1120 | /* 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
|
1121 | 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
|
1122 | 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
|
1123 | #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
|
1124 | selection = clipboard_html_to_win32(html_clipboard); |
|
15111
e427dd6f3b7e
[gaim-migrate @ 17833]
Daniel Atallah <datallah@pidgin.im>
parents:
15093
diff
changeset
|
1125 | 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
|
1126 | #endif |
| 8061 | 1127 | g_free(selection); |
| 1128 | } else { | |
| 8681 | 1129 | if (primary) { |
| 1130 | text = gtk_imhtml_get_text(imhtml, &start, &end); | |
| 1131 | } else | |
|
17546
51b1c1e2c3fe
Maintain global poitners to the clipboard selection text, with the aim of
Sean Egan <seanegan@pidgin.im>
parents:
17406
diff
changeset
|
1132 | text = text_clipboard; |
| 8061 | 1133 | gtk_selection_data_set_text(selection_data, text, strlen(text)); |
| 1134 | } | |
| 8681 | 1135 | if (primary) /* This was allocated here */ |
| 1136 | g_free(text); | |
|
32422
c215bc5d85e4
Whitespace fixes. Try and check your editor settings before writing
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32414
diff
changeset
|
1137 | } |
| 8061 | 1138 | |
| 1139 | static void gtk_imhtml_primary_clipboard_clear(GtkClipboard *clipboard, GtkIMHtml *imhtml) | |
| 7749 | 1140 | { |
| 8061 | 1141 | GtkTextIter insert; |
| 1142 | GtkTextIter selection_bound; | |
| 1143 | ||
| 1144 | gtk_text_buffer_get_iter_at_mark (imhtml->text_buffer, &insert, | |
| 1145 | gtk_text_buffer_get_mark (imhtml->text_buffer, "insert")); | |
| 1146 | gtk_text_buffer_get_iter_at_mark (imhtml->text_buffer, &selection_bound, | |
| 1147 | gtk_text_buffer_get_mark (imhtml->text_buffer, "selection_bound")); | |
| 1148 | ||
| 1149 | if (!gtk_text_iter_equal (&insert, &selection_bound)) | |
| 1150 | gtk_text_buffer_move_mark (imhtml->text_buffer, | |
| 1151 | gtk_text_buffer_get_mark (imhtml->text_buffer, "selection_bound"), | |
| 1152 | &insert); | |
| 7749 | 1153 | } |
| 7742 | 1154 | |
|
17546
51b1c1e2c3fe
Maintain global poitners to the clipboard selection text, with the aim of
Sean Egan <seanegan@pidgin.im>
parents:
17406
diff
changeset
|
1155 | 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
|
1156 | 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
|
1157 | { |
|
51b1c1e2c3fe
Maintain global poitners to the clipboard selection text, with the aim of
Sean Egan <seanegan@pidgin.im>
parents:
17406
diff
changeset
|
1158 | } |
|
51b1c1e2c3fe
Maintain global poitners to the clipboard selection text, with the aim of
Sean Egan <seanegan@pidgin.im>
parents:
17406
diff
changeset
|
1159 | |
| 8677 | 1160 | static void copy_clipboard_cb(GtkIMHtml *imhtml, gpointer unused) |
| 7749 | 1161 | { |
| 8681 | 1162 | 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
|
1163 | 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
|
1164 | 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
|
1165 | 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
|
1166 | 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
|
1167 | 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
|
1168 | (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
|
1169 | (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
|
1170 | |
|
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
|
1171 | 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
|
1172 | 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
|
1173 | |
|
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
|
1174 | 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
|
1175 | text_clipboard = gtk_imhtml_get_text(imhtml, &start, &end); |
| 8681 | 1176 | } |
| 1177 | ||
| 8061 | 1178 | g_signal_stop_emission_by_name(imhtml, "copy-clipboard"); |
| 1179 | } | |
| 1180 | ||
| 8698 | 1181 | static void cut_clipboard_cb(GtkIMHtml *imhtml, gpointer unused) |
| 1182 | { | |
| 1183 | 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
|
1184 | 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
|
1185 | 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
|
1186 | 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
|
1187 | 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
|
1188 | 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
|
1189 | (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
|
1190 | (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
|
1191 | |
|
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
|
1192 | 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
|
1193 | 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
|
1194 | |
|
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
|
1195 | 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
|
1196 | 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
|
1197 | |
|
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
|
1198 | 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
|
1199 | gtk_text_buffer_delete_selection(imhtml->text_buffer, FALSE, FALSE); |
| 8698 | 1200 | } |
| 1201 | ||
| 1202 | g_signal_stop_emission_by_name(imhtml, "cut-clipboard"); | |
| 1203 | } | |
| 1204 | ||
| 8931 | 1205 | static void imhtml_paste_insert(GtkIMHtml *imhtml, const char *text, gboolean plaintext) |
| 1206 | { | |
| 1207 | 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
|
1208 | GtkIMHtmlOptions flags = plaintext ? GTK_IMHTML_NO_SMILEY : (GTK_IMHTML_NO_NEWLINE | GTK_IMHTML_NO_COMMENTS); |
| 8931 | 1209 | |
|
25899
da25a7ed382e
The first thing gtk_text_buffer_delete_selection does is call
Mark Doliner <markdoliner@pidgin.im>
parents:
25888
diff
changeset
|
1210 | /* 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
|
1211 | gtk_text_buffer_delete_selection(imhtml->text_buffer, TRUE, TRUE); |
| 9028 | 1212 | |
| 8931 | 1213 | gtk_text_buffer_get_iter_at_mark(imhtml->text_buffer, &iter, gtk_text_buffer_get_insert(imhtml->text_buffer)); |
| 1214 | if (!imhtml->wbfo && !plaintext) | |
| 1215 | gtk_imhtml_close_tags(imhtml, &iter); | |
| 1216 | ||
| 1217 | gtk_imhtml_insert_html_at_iter(imhtml, text, flags, &iter); | |
|
11267
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
1218 | gtk_text_buffer_move_mark_by_name(imhtml->text_buffer, "insert", &iter); |
| 8931 | 1219 | gtk_text_view_scroll_to_mark(GTK_TEXT_VIEW(imhtml), gtk_text_buffer_get_insert(imhtml->text_buffer), |
| 1220 | 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
|
1221 | 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
|
1222 | 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
|
1223 | |
| 8931 | 1224 | } |
| 1225 | ||
| 1226 | static void paste_plaintext_received_cb (GtkClipboard *clipboard, const gchar *text, gpointer data) | |
| 1227 | { | |
| 1228 | char *tmp; | |
| 1229 | ||
|
19332
06b251c98872
malloc(0) returns a null pointer. Fixes #2472.
Daniel Atallah <datallah@pidgin.im>
parents:
19103
diff
changeset
|
1230 | if (text == NULL || !(*text)) |
| 8931 | 1231 | return; |
| 1232 | ||
|
10732
5e314ab498bf
[gaim-migrate @ 12334]
Richard Laager <rlaager@pidgin.im>
parents:
10699
diff
changeset
|
1233 | tmp = g_markup_escape_text(text, -1); |
| 8931 | 1234 | imhtml_paste_insert(data, tmp, TRUE); |
| 1235 | g_free(tmp); | |
| 1236 | } | |
| 1237 | ||
| 8061 | 1238 | static void paste_received_cb (GtkClipboard *clipboard, GtkSelectionData *selection_data, gpointer data) |
| 1239 | { | |
| 1240 | char *text; | |
| 1241 | GtkIMHtml *imhtml = data; | |
|
32413
00ad036bdf3d
Fix some indenting.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32412
diff
changeset
|
1242 | gint length = gtk_selection_data_get_length(selection_data); |
| 7809 | 1243 | |
|
8123
e09c75f511c2
[gaim-migrate @ 8827]
Mark Doliner <markdoliner@pidgin.im>
parents:
8120
diff
changeset
|
1244 | if (!gtk_text_view_get_editable(GTK_TEXT_VIEW(imhtml))) |
|
8105
54ea897b764e
[gaim-migrate @ 8805]
Nathan Fredrickson <nathan@silverorange.com>
parents:
8091
diff
changeset
|
1245 | return; |
|
54ea897b764e
[gaim-migrate @ 8805]
Nathan Fredrickson <nathan@silverorange.com>
parents:
8091
diff
changeset
|
1246 | |
|
32394
f883709bdba4
compiles using GTK+ 3 from git, beware it does not yet run, in fact it crashes...
Marcus Lundblad <malu@pidgin.im>
parents:
31207
diff
changeset
|
1247 | if (imhtml->wbfo || length <= 0) { |
| 8931 | 1248 | gtk_clipboard_request_text(clipboard, paste_plaintext_received_cb, imhtml); |
| 1249 | return; | |
| 8061 | 1250 | } else { |
| 8719 | 1251 | #if 0 |
| 1252 | /* Here's some debug code, for figuring out what sent to us over the clipboard. */ | |
| 1253 | { | |
| 1254 | int i; | |
| 1255 | ||
| 15884 | 1256 | purple_debug_misc("gtkimhtml", "In paste_received_cb():\n\tformat = %d, length = %d\n\t", |
| 8719 | 1257 | selection_data->format, selection_data->length); |
| 1258 | ||
| 1259 | for (i = 0; i < (/*(selection_data->format / 8) **/ selection_data->length); i++) { | |
| 1260 | if ((i % 70) == 0) | |
| 1261 | printf("\n\t"); | |
| 1262 | if (selection_data->data[i] == '\0') | |
| 1263 | printf("."); | |
| 1264 | else | |
| 1265 | printf("%c", selection_data->data[i]); | |
| 1266 | } | |
| 1267 | printf("\n"); | |
| 1268 | } | |
| 1269 | #endif | |
|
30033
391b14824468
gtkimhtml: Fix handling of pastes whose data isn't NULL-terminated
Paul Aurich <darkrain42@pidgin.im>
parents:
29909
diff
changeset
|
1270 | |
|
32394
f883709bdba4
compiles using GTK+ 3 from git, beware it does not yet run, in fact it crashes...
Marcus Lundblad <malu@pidgin.im>
parents:
31207
diff
changeset
|
1271 | text = g_malloc(length + 1); |
|
f883709bdba4
compiles using GTK+ 3 from git, beware it does not yet run, in fact it crashes...
Marcus Lundblad <malu@pidgin.im>
parents:
31207
diff
changeset
|
1272 | memcpy(text, gtk_selection_data_get_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
|
1273 | /* Make sure the paste data is null-terminated. Given that |
| 30034 | 1274 | * we're passed length (but assume later that it is |
| 1275 | * 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
|
1276 | */ |
|
32394
f883709bdba4
compiles using GTK+ 3 from git, beware it does not yet run, in fact it crashes...
Marcus Lundblad <malu@pidgin.im>
parents:
31207
diff
changeset
|
1277 | text[length] = '\0'; |
| 7766 | 1278 | } |
| 8061 | 1279 | |
|
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
|
1280 | #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
|
1281 | 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
|
1282 | 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
|
1283 | 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
|
1284 | 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
|
1285 | } |
|
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 |
|
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
|
1287 | |
|
32394
f883709bdba4
compiles using GTK+ 3 from git, beware it does not yet run, in fact it crashes...
Marcus Lundblad <malu@pidgin.im>
parents:
31207
diff
changeset
|
1288 | if (length >= 2 && |
| 8869 | 1289 | (*(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
|
1290 | /* This is UTF-16 */ |
|
32394
f883709bdba4
compiles using GTK+ 3 from git, beware it does not yet run, in fact it crashes...
Marcus Lundblad <malu@pidgin.im>
parents:
31207
diff
changeset
|
1291 | char *utf8 = utf16_to_utf8_with_bom_check(text, length); |
| 8061 | 1292 | g_free(text); |
| 1293 | text = utf8; | |
| 8698 | 1294 | 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
|
1295 | purple_debug_warning("gtkimhtml", "g_convert from UTF-16 failed in paste_received_cb\n"); |
| 8698 | 1296 | return; |
| 1297 | } | |
| 8061 | 1298 | } |
|
11572
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
1299 | |
| 8698 | 1300 | if (!(*text) || !g_utf8_validate(text, -1, NULL)) { |
| 15884 | 1301 | purple_debug_warning("gtkimhtml", "empty string or invalid UTF-8 in paste_received_cb\n"); |
| 8698 | 1302 | g_free(text); |
| 1303 | return; | |
| 1304 | } | |
| 1305 | ||
| 8931 | 1306 | imhtml_paste_insert(imhtml, text, FALSE); |
| 8681 | 1307 | g_free(text); |
| 8061 | 1308 | } |
| 1309 | ||
|
21765
b9271e416f6d
Patch from 'goutnet': Pressing backspace on a smiley will replace the smiley
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21644
diff
changeset
|
1310 | |
|
b9271e416f6d
Patch from 'goutnet': Pressing backspace on a smiley will replace the smiley
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21644
diff
changeset
|
1311 | 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
|
1312 | { |
|
b9271e416f6d
Patch from 'goutnet': Pressing backspace on a smiley will replace the smiley
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21644
diff
changeset
|
1313 | 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
|
1314 | 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
|
1315 | 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
|
1316 | 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
|
1317 | |
|
b9271e416f6d
Patch from 'goutnet': Pressing backspace on a smiley will replace the smiley
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21644
diff
changeset
|
1318 | 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
|
1319 | return; |
|
b9271e416f6d
Patch from 'goutnet': Pressing backspace on a smiley will replace the smiley
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21644
diff
changeset
|
1320 | |
|
b9271e416f6d
Patch from 'goutnet': Pressing backspace on a smiley will replace the smiley
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21644
diff
changeset
|
1321 | 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
|
1322 | |
|
b9271e416f6d
Patch from 'goutnet': Pressing backspace on a smiley will replace the smiley
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21644
diff
changeset
|
1323 | /* 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
|
1324 | 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
|
1325 | 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
|
1326 | return; |
|
b9271e416f6d
Patch from 'goutnet': Pressing backspace on a smiley will replace the smiley
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21644
diff
changeset
|
1327 | |
|
b9271e416f6d
Patch from 'goutnet': Pressing backspace on a smiley will replace the smiley
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21644
diff
changeset
|
1328 | 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
|
1329 | 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
|
1330 | |
|
b9271e416f6d
Patch from 'goutnet': Pressing backspace on a smiley will replace the smiley
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21644
diff
changeset
|
1331 | 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
|
1332 | 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
|
1333 | |
|
b9271e416f6d
Patch from 'goutnet': Pressing backspace on a smiley will replace the smiley
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21644
diff
changeset
|
1334 | 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
|
1335 | 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
|
1336 | return; |
|
b9271e416f6d
Patch from 'goutnet': Pressing backspace on a smiley will replace the smiley
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21644
diff
changeset
|
1337 | |
|
b9271e416f6d
Patch from 'goutnet': Pressing backspace on a smiley will replace the smiley
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21644
diff
changeset
|
1338 | /* 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
|
1339 | 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
|
1340 | } |
|
b9271e416f6d
Patch from 'goutnet': Pressing backspace on a smiley will replace the smiley
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21644
diff
changeset
|
1341 | |
| 8061 | 1342 | static void paste_clipboard_cb(GtkIMHtml *imhtml, gpointer blah) |
| 1343 | { | |
| 8931 | 1344 | #ifdef _WIN32 |
| 1345 | /* 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
|
1346 | 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
|
1347 | 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
|
1348 | 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
|
1349 | 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
|
1350 | |
|
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
|
1351 | } |
|
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
|
1352 | #else |
| 8061 | 1353 | GtkClipboard *clipboard = gtk_widget_get_clipboard(GTK_WIDGET(imhtml), GDK_SELECTION_CLIPBOARD); |
| 1354 | gtk_clipboard_request_contents(clipboard, gdk_atom_intern("text/html", FALSE), | |
| 1355 | 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
|
1356 | #endif |
| 8061 | 1357 | g_signal_stop_emission_by_name(imhtml, "paste-clipboard"); |
| 7766 | 1358 | } |
| 1359 | ||
| 8677 | 1360 | static void imhtml_realized_remove_primary(GtkIMHtml *imhtml, gpointer unused) |
| 1361 | { | |
| 1362 | gtk_text_buffer_remove_selection_clipboard(GTK_IMHTML(imhtml)->text_buffer, | |
| 1363 | gtk_widget_get_clipboard(GTK_WIDGET(imhtml), GDK_SELECTION_PRIMARY)); | |
| 1364 | ||
| 1365 | } | |
| 1366 | ||
|
8740
098a43943bba
[gaim-migrate @ 9495]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
1367 | static void imhtml_destroy_add_primary(GtkIMHtml *imhtml, gpointer unused) |
|
098a43943bba
[gaim-migrate @ 9495]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
1368 | { |
|
098a43943bba
[gaim-migrate @ 9495]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
1369 | gtk_text_buffer_add_selection_clipboard(GTK_IMHTML(imhtml)->text_buffer, |
|
098a43943bba
[gaim-migrate @ 9495]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
1370 | gtk_widget_get_clipboard(GTK_WIDGET(imhtml), GDK_SELECTION_PRIMARY)); |
|
098a43943bba
[gaim-migrate @ 9495]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
1371 | } |
| 8677 | 1372 | |
| 1373 | static void mark_set_so_update_selection_cb(GtkTextBuffer *buffer, GtkTextIter *arg1, GtkTextMark *mark, GtkIMHtml *imhtml) | |
| 1374 | { | |
| 1375 | if (gtk_text_buffer_get_selection_bounds(buffer, NULL, NULL)) { | |
| 1376 | gtk_clipboard_set_with_owner(gtk_widget_get_clipboard(GTK_WIDGET(imhtml), GDK_SELECTION_PRIMARY), | |
| 1377 | selection_targets, sizeof(selection_targets) / sizeof(GtkTargetEntry), | |
| 1378 | (GtkClipboardGetFunc)gtk_imhtml_clipboard_get, | |
| 1379 | (GtkClipboardClearFunc)gtk_imhtml_primary_clipboard_clear, G_OBJECT(imhtml)); | |
| 1380 | } | |
| 1381 | } | |
| 1382 | ||
| 1383 | static gboolean gtk_imhtml_button_press_event(GtkIMHtml *imhtml, GdkEventButton *event, gpointer unused) | |
| 7346 | 1384 | { |
| 8677 | 1385 | if (event->button == 2) { |
| 1386 | int x, y; | |
| 1387 | GtkTextIter iter; | |
| 1388 | GtkClipboard *clipboard = gtk_widget_get_clipboard(GTK_WIDGET(imhtml), GDK_SELECTION_PRIMARY); | |
| 1389 | ||
| 1390 | if (!imhtml->editable) | |
| 1391 | return FALSE; | |
| 1392 | ||
| 1393 | gtk_text_view_window_to_buffer_coords(GTK_TEXT_VIEW(imhtml), | |
| 1394 | GTK_TEXT_WINDOW_TEXT, | |
| 1395 | event->x, | |
| 1396 | event->y, | |
| 1397 | &x, | |
| 1398 | &y); | |
| 1399 | gtk_text_view_get_iter_at_location(GTK_TEXT_VIEW(imhtml), &iter, x, y); | |
| 1400 | gtk_text_buffer_place_cursor(imhtml->text_buffer, &iter); | |
| 1401 | ||
| 1402 | gtk_clipboard_request_contents(clipboard, gdk_atom_intern("text/html", FALSE), | |
| 1403 | paste_received_cb, imhtml); | |
| 1404 | ||
| 1405 | return TRUE; | |
|
32422
c215bc5d85e4
Whitespace fixes. Try and check your editor settings before writing
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32414
diff
changeset
|
1406 | } |
| 8677 | 1407 | |
| 7346 | 1408 | return FALSE; |
| 1409 | } | |
| 4263 | 1410 | |
|
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
|
1411 | 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
|
1412 | 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
|
1413 | { |
|
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
|
1414 | 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
|
1415 | 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
|
1416 | 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
|
1417 | 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
|
1418 | } |
|
5e73968467e0
Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@pidgin.im>
parents:
17288
diff
changeset
|
1419 | |
|
5e73968467e0
Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@pidgin.im>
parents:
17288
diff
changeset
|
1420 | 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
|
1421 | 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
|
1422 | { |
|
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
|
1423 | 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
|
1424 | 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
|
1425 | 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
|
1426 | 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
|
1427 | |
|
5e73968467e0
Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@pidgin.im>
parents:
17288
diff
changeset
|
1428 | } |
|
5e73968467e0
Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@pidgin.im>
parents:
17288
diff
changeset
|
1429 | |
| 10108 | 1430 | static gboolean imhtml_message_send(GtkIMHtml *imhtml) |
| 1431 | { | |
| 1432 | return FALSE; | |
| 1433 | } | |
| 1434 | ||
|
29909
3b74346e22d5
Allow binding 'Paste as Plain Text'.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
29855
diff
changeset
|
1435 | static void |
|
3b74346e22d5
Allow binding 'Paste as Plain Text'.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
29855
diff
changeset
|
1436 | 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
|
1437 | { |
|
30417
ee5cccb21cc7
Do not paste in a read-only imhtml. Fixes #12109.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
30264
diff
changeset
|
1438 | 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
|
1439 | return; |
|
ee5cccb21cc7
Do not paste in a read-only imhtml. Fixes #12109.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
30264
diff
changeset
|
1440 | |
|
29909
3b74346e22d5
Allow binding 'Paste as Plain Text'.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
29855
diff
changeset
|
1441 | if (!str || !*str || !strcmp(str, "html")) |
|
3b74346e22d5
Allow binding 'Paste as Plain Text'.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
29855
diff
changeset
|
1442 | 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
|
1443 | else if (!strcmp(str, "text")) |
|
3b74346e22d5
Allow binding 'Paste as Plain Text'.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
29855
diff
changeset
|
1444 | paste_unformatted_cb(NULL, imhtml); |
|
3b74346e22d5
Allow binding 'Paste as Plain Text'.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
29855
diff
changeset
|
1445 | } |
|
3b74346e22d5
Allow binding 'Paste as Plain Text'.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
29855
diff
changeset
|
1446 | |
| 10100 | 1447 | static void imhtml_toggle_format(GtkIMHtml *imhtml, GtkIMHtmlButtons buttons) |
| 1448 | { | |
|
10699
7f9fa4f13758
[gaim-migrate @ 12256]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10695
diff
changeset
|
1449 | /* since this function is the handler for the formatting keystrokes, |
|
7f9fa4f13758
[gaim-migrate @ 12256]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10695
diff
changeset
|
1450 | 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
|
1451 | buttons &= imhtml->format_functions; |
|
10699
7f9fa4f13758
[gaim-migrate @ 12256]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10695
diff
changeset
|
1452 | |
| 10100 | 1453 | switch (buttons) { |
| 1454 | case GTK_IMHTML_BOLD: | |
|
11267
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
1455 | imhtml_toggle_bold(imhtml); |
| 10100 | 1456 | break; |
| 1457 | case GTK_IMHTML_ITALIC: | |
|
11267
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
1458 | imhtml_toggle_italic(imhtml); |
| 10100 | 1459 | break; |
| 1460 | case GTK_IMHTML_UNDERLINE: | |
|
11267
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
1461 | imhtml_toggle_underline(imhtml); |
|
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
1462 | break; |
|
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
1463 | case GTK_IMHTML_STRIKE: |
|
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
1464 | imhtml_toggle_strike(imhtml); |
| 10100 | 1465 | break; |
| 1466 | case GTK_IMHTML_SHRINK: | |
|
11267
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
1467 | imhtml_font_shrink(imhtml); |
| 10100 | 1468 | break; |
| 1469 | case GTK_IMHTML_GROW: | |
|
11267
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
1470 | imhtml_font_grow(imhtml); |
| 10100 | 1471 | break; |
| 1472 | default: | |
| 1473 | break; | |
| 1474 | } | |
| 1475 | } | |
| 4032 | 1476 | |
| 1477 | static void | |
| 1478 | gtk_imhtml_finalize (GObject *object) | |
| 1479 | { | |
| 1480 | GtkIMHtml *imhtml = GTK_IMHTML(object); | |
| 4895 | 1481 | GList *scalables; |
| 8962 | 1482 | GSList *l; |
| 8061 | 1483 | |
| 10798 | 1484 | if (imhtml->scroll_src) |
| 1485 | g_source_remove(imhtml->scroll_src); | |
| 1486 | if (imhtml->scroll_time) | |
| 1487 | g_timer_destroy(imhtml->scroll_time); | |
| 1488 | ||
| 4138 | 1489 | g_hash_table_destroy(imhtml->smiley_data); |
| 4032 | 1490 | gtk_smiley_tree_destroy(imhtml->default_smilies); |
| 4138 | 1491 | gdk_cursor_unref(imhtml->hand_cursor); |
| 1492 | gdk_cursor_unref(imhtml->arrow_cursor); | |
| 8061 | 1493 | gdk_cursor_unref(imhtml->text_cursor); |
| 8677 | 1494 | |
| 4735 | 1495 | if(imhtml->tip_window){ |
| 1496 | gtk_widget_destroy(imhtml->tip_window); | |
| 1497 | } | |
| 1498 | 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
|
1499 | g_source_remove(imhtml->tip_timer); |
| 4735 | 1500 | |
| 4895 | 1501 | for(scalables = imhtml->scalables; scalables; scalables = scalables->next) { |
|
11224
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
1502 | struct scalable_data *sd = scalables->data; |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
1503 | GtkIMHtmlScalable *scale = GTK_IMHTML_SCALABLE(sd->scalable); |
| 4895 | 1504 | scale->free(scale); |
|
11224
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
1505 | g_free(sd); |
| 4895 | 1506 | } |
| 7991 | 1507 | |
| 8962 | 1508 | for (l = imhtml->im_images; l; l = l->next) { |
|
11224
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
1509 | struct im_image_data *img_data = l->data; |
| 8962 | 1510 | if (imhtml->funcs->image_unref) |
|
11224
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
1511 | imhtml->funcs->image_unref(img_data->id); |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
1512 | g_free(img_data); |
| 8962 | 1513 | } |
| 1514 | ||
| 4895 | 1515 | g_list_free(imhtml->scalables); |
| 8962 | 1516 | 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
|
1517 | g_queue_free(imhtml->animations); |
|
14097
0c340861ab79
[gaim-migrate @ 16638]
Mark Doliner <markdoliner@pidgin.im>
parents:
14010
diff
changeset
|
1518 | g_free(imhtml->protocol_name); |
|
0c340861ab79
[gaim-migrate @ 16638]
Mark Doliner <markdoliner@pidgin.im>
parents:
14010
diff
changeset
|
1519 | 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
|
1520 | g_object_unref(imhtml->undo_manager); |
| 4032 | 1521 | 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
|
1522 | |
| 4032 | 1523 | } |
| 1428 | 1524 | |
|
24674
36bf974a7d78
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24588
diff
changeset
|
1525 | static GtkIMHtmlProtocol * |
|
25013
956b2f650d31
Detect duplication registrations by substring.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
25011
diff
changeset
|
1526 | 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
|
1527 | { |
|
36bf974a7d78
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24588
diff
changeset
|
1528 | GtkIMHtmlClass *klass; |
|
36bf974a7d78
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24588
diff
changeset
|
1529 | GList *iter; |
|
36bf974a7d78
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24588
diff
changeset
|
1530 | GtkIMHtmlProtocol *proto = NULL; |
|
25013
956b2f650d31
Detect duplication registrations by substring.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
25011
diff
changeset
|
1531 | 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
|
1532 | |
|
36bf974a7d78
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24588
diff
changeset
|
1533 | 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
|
1534 | 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
|
1535 | proto = iter->data; |
|
25013
956b2f650d31
Detect duplication registrations by substring.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
25011
diff
changeset
|
1536 | 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
|
1537 | return proto; |
|
36bf974a7d78
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24588
diff
changeset
|
1538 | } |
|
36bf974a7d78
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24588
diff
changeset
|
1539 | } |
|
36bf974a7d78
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24588
diff
changeset
|
1540 | return NULL; |
|
36bf974a7d78
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24588
diff
changeset
|
1541 | } |
|
36bf974a7d78
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24588
diff
changeset
|
1542 | |
|
36bf974a7d78
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24588
diff
changeset
|
1543 | static void |
|
36bf974a7d78
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24588
diff
changeset
|
1544 | 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
|
1545 | { |
|
25013
956b2f650d31
Detect duplication registrations by substring.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
25011
diff
changeset
|
1546 | 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
|
1547 | 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
|
1548 | if (!proto) |
|
36bf974a7d78
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24588
diff
changeset
|
1549 | 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
|
1550 | 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
|
1551 | 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
|
1552 | 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
|
1553 | 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
|
1554 | 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
|
1555 | } |
|
36bf974a7d78
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24588
diff
changeset
|
1556 | |
|
10814
7e17cb56b019
[gaim-migrate @ 12468]
Luke Schierer <lschiere@pidgin.im>
parents:
10799
diff
changeset
|
1557 | /* Boring GTK+ stuff */ |
| 8519 | 1558 | static void gtk_imhtml_class_init (GtkIMHtmlClass *klass) |
| 1428 | 1559 | { |
| 9007 | 1560 | GtkWidgetClass *widget_class = (GtkWidgetClass *) klass; |
| 10100 | 1561 | GtkBindingSet *binding_set; |
| 4032 | 1562 | GObjectClass *gobject_class; |
| 8519 | 1563 | 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
|
1564 | parent_class = g_type_class_ref(GTK_TYPE_TEXT_VIEW); |
| 4417 | 1565 | signals[URL_CLICKED] = g_signal_new("url_clicked", |
| 1566 | G_TYPE_FROM_CLASS(gobject_class), | |
| 1567 | G_SIGNAL_RUN_FIRST, | |
| 1568 | G_STRUCT_OFFSET(GtkIMHtmlClass, url_clicked), | |
| 1569 | NULL, | |
| 1570 | 0, | |
| 1571 | g_cclosure_marshal_VOID__POINTER, | |
| 1572 | G_TYPE_NONE, 1, | |
| 1573 | G_TYPE_POINTER); | |
| 8506 | 1574 | signals[BUTTONS_UPDATE] = g_signal_new("format_buttons_update", |
| 8420 | 1575 | G_TYPE_FROM_CLASS(gobject_class), |
| 1576 | G_SIGNAL_RUN_FIRST, | |
| 1577 | G_STRUCT_OFFSET(GtkIMHtmlClass, buttons_update), | |
| 1578 | NULL, | |
| 1579 | 0, | |
|
10076
1ccc0286a4ae
[gaim-migrate @ 11057]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10062
diff
changeset
|
1580 | g_cclosure_marshal_VOID__INT, |
| 8420 | 1581 | G_TYPE_NONE, 1, |
| 1582 | G_TYPE_INT); | |
| 1583 | signals[TOGGLE_FORMAT] = g_signal_new("format_function_toggle", | |
| 1584 | G_TYPE_FROM_CLASS(gobject_class), | |
| 10100 | 1585 | G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION, |
| 8420 | 1586 | G_STRUCT_OFFSET(GtkIMHtmlClass, toggle_format), |
| 1587 | NULL, | |
| 1588 | 0, | |
|
10076
1ccc0286a4ae
[gaim-migrate @ 11057]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10062
diff
changeset
|
1589 | g_cclosure_marshal_VOID__INT, |
|
1ccc0286a4ae
[gaim-migrate @ 11057]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10062
diff
changeset
|
1590 | G_TYPE_NONE, 1, |
| 8420 | 1591 | G_TYPE_INT); |
| 8427 | 1592 | signals[CLEAR_FORMAT] = g_signal_new("format_function_clear", |
| 1593 | G_TYPE_FROM_CLASS(gobject_class), | |
|
11385
38ca1438e055
[gaim-migrate @ 13612]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11315
diff
changeset
|
1594 | G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION, |
| 8427 | 1595 | G_STRUCT_OFFSET(GtkIMHtmlClass, clear_format), |
| 1596 | NULL, | |
| 1597 | 0, | |
| 10100 | 1598 | g_cclosure_marshal_VOID__VOID, |
| 1599 | G_TYPE_NONE, 0); | |
| 8506 | 1600 | signals[UPDATE_FORMAT] = g_signal_new("format_function_update", |
| 10100 | 1601 | G_TYPE_FROM_CLASS(gobject_class), |
| 1602 | G_SIGNAL_RUN_FIRST, | |
| 1603 | G_STRUCT_OFFSET(GtkIMHtmlClass, update_format), | |
| 1604 | NULL, | |
| 1605 | 0, | |
| 1606 | g_cclosure_marshal_VOID__VOID, | |
| 1607 | G_TYPE_NONE, 0); | |
| 10108 | 1608 | signals[MESSAGE_SEND] = g_signal_new("message_send", |
| 1609 | G_TYPE_FROM_CLASS(gobject_class), | |
| 1610 | G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION, | |
| 1611 | G_STRUCT_OFFSET(GtkIMHtmlClass, message_send), | |
| 1612 | NULL, | |
| 1613 | 0, g_cclosure_marshal_VOID__VOID, | |
| 1614 | G_TYPE_NONE, 0); | |
|
29909
3b74346e22d5
Allow binding 'Paste as Plain Text'.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
29855
diff
changeset
|
1615 | signals[PASTE] = g_signal_new("paste", |
|
3b74346e22d5
Allow binding 'Paste as Plain Text'.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
29855
diff
changeset
|
1616 | G_TYPE_FROM_CLASS(gobject_class), |
|
3b74346e22d5
Allow binding 'Paste as Plain Text'.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
29855
diff
changeset
|
1617 | G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION, |
|
3b74346e22d5
Allow binding 'Paste as Plain Text'.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
29855
diff
changeset
|
1618 | 0, |
|
3b74346e22d5
Allow binding 'Paste as Plain Text'.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
29855
diff
changeset
|
1619 | NULL, |
|
3b74346e22d5
Allow binding 'Paste as Plain Text'.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
29855
diff
changeset
|
1620 | 0, g_cclosure_marshal_VOID__STRING, |
|
3b74346e22d5
Allow binding 'Paste as Plain Text'.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
29855
diff
changeset
|
1621 | G_TYPE_NONE, 1, G_TYPE_STRING); |
|
3b74346e22d5
Allow binding 'Paste as Plain Text'.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
29855
diff
changeset
|
1622 | signals [UNDO] = g_signal_new ("undo", |
|
3b74346e22d5
Allow binding 'Paste as Plain Text'.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
29855
diff
changeset
|
1623 | G_TYPE_FROM_CLASS (klass), |
|
3b74346e22d5
Allow binding 'Paste as Plain Text'.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
29855
diff
changeset
|
1624 | G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION, |
|
3b74346e22d5
Allow binding 'Paste as Plain Text'.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
29855
diff
changeset
|
1625 | G_STRUCT_OFFSET (GtkIMHtmlClass, undo), |
|
3b74346e22d5
Allow binding 'Paste as Plain Text'.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
29855
diff
changeset
|
1626 | NULL, |
|
3b74346e22d5
Allow binding 'Paste as Plain Text'.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
29855
diff
changeset
|
1627 | NULL, |
|
3b74346e22d5
Allow binding 'Paste as Plain Text'.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
29855
diff
changeset
|
1628 | gtksourceview_marshal_VOID__VOID, |
|
3b74346e22d5
Allow binding 'Paste as Plain Text'.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
29855
diff
changeset
|
1629 | G_TYPE_NONE, |
|
3b74346e22d5
Allow binding 'Paste as Plain Text'.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
29855
diff
changeset
|
1630 | 0); |
|
3b74346e22d5
Allow binding 'Paste as Plain Text'.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
29855
diff
changeset
|
1631 | signals [REDO] = g_signal_new ("redo", |
|
3b74346e22d5
Allow binding 'Paste as Plain Text'.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
29855
diff
changeset
|
1632 | G_TYPE_FROM_CLASS (klass), |
|
3b74346e22d5
Allow binding 'Paste as Plain Text'.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
29855
diff
changeset
|
1633 | G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION, |
|
3b74346e22d5
Allow binding 'Paste as Plain Text'.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
29855
diff
changeset
|
1634 | G_STRUCT_OFFSET (GtkIMHtmlClass, redo), |
|
3b74346e22d5
Allow binding 'Paste as Plain Text'.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
29855
diff
changeset
|
1635 | NULL, |
|
3b74346e22d5
Allow binding 'Paste as Plain Text'.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
29855
diff
changeset
|
1636 | NULL, |
|
3b74346e22d5
Allow binding 'Paste as Plain Text'.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
29855
diff
changeset
|
1637 | gtksourceview_marshal_VOID__VOID, |
|
3b74346e22d5
Allow binding 'Paste as Plain Text'.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
29855
diff
changeset
|
1638 | G_TYPE_NONE, |
|
3b74346e22d5
Allow binding 'Paste as Plain Text'.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
29855
diff
changeset
|
1639 | 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
|
1640 | |
|
5e73968467e0
Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@pidgin.im>
parents:
17288
diff
changeset
|
1641 | |
| 10100 | 1642 | |
| 1643 | klass->toggle_format = imhtml_toggle_format; | |
| 10108 | 1644 | klass->message_send = imhtml_message_send; |
|
12672
673e2a1d2954
[gaim-migrate @ 15015]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12635
diff
changeset
|
1645 | 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
|
1646 | 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
|
1647 | 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
|
1648 | klass->redo = gtk_imhtml_redo; |
|
10184
543c9a84ce16
[gaim-migrate @ 11299]
Mark Doliner <markdoliner@pidgin.im>
parents:
10169
diff
changeset
|
1649 | |
| 4032 | 1650 | gobject_class->finalize = gtk_imhtml_finalize; |
|
10184
543c9a84ce16
[gaim-migrate @ 11299]
Mark Doliner <markdoliner@pidgin.im>
parents:
10169
diff
changeset
|
1651 | widget_class->drag_motion = gtk_text_view_drag_motion; |
|
32413
00ad036bdf3d
Fix some indenting.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32412
diff
changeset
|
1652 | /* TODO: I _think_ this should be removed for GTK+ 3.0 */ |
|
33170
ce4447562d64
Add checks for old GTK+2 stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33132
diff
changeset
|
1653 | #if !GTK_CHECK_VERSION(3,0,0) |
|
ce4447562d64
Add checks for old GTK+2 stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33132
diff
changeset
|
1654 | widget_class->expose_event = gtk_imhtml_expose_event; |
|
ce4447562d64
Add checks for old GTK+2 stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33132
diff
changeset
|
1655 | #endif |
|
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
|
1656 | 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
|
1657 | 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
|
1658 | 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
|
1659 | 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
|
1660 | |
| 9007 | 1661 | gtk_widget_class_install_style_property(widget_class, g_param_spec_boxed("hyperlink-color", |
| 1662 | _("Hyperlink color"), | |
| 1663 | _("Color to draw hyperlinks."), | |
| 1664 | 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
|
1665 | 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
|
1666 | _("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
|
1667 | _("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
|
1668 | GDK_TYPE_COLOR, G_PARAM_READABLE)); |
| 10799 | 1669 | gtk_widget_class_install_style_property(widget_class, g_param_spec_boxed("hyperlink-prelight-color", |
| 1670 | _("Hyperlink prelight color"), | |
| 1671 | _("Color to draw hyperlinks when mouse is over them."), | |
| 1672 | 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
|
1673 | 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
|
1674 | _("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
|
1675 | _("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
|
1676 | 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
|
1677 | 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
|
1678 | _("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
|
1679 | _("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
|
1680 | 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
|
1681 | 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
|
1682 | _("\"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
|
1683 | _("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
|
1684 | 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
|
1685 | 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
|
1686 | _("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
|
1687 | _("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
|
1688 | 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
|
1689 | 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
|
1690 | _("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
|
1691 | _("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
|
1692 | 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
|
1693 | 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
|
1694 | _("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
|
1695 | _("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
|
1696 | GDK_TYPE_COLOR, G_PARAM_READABLE)); |
| 10100 | 1697 | |
|
22772
34ab3bb905cc
Customize/disable the typing notification from gtkrc-2.0.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22703
diff
changeset
|
1698 | /* 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
|
1699 | * 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
|
1700 | * 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
|
1701 | * 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
|
1702 | */ |
|
34ab3bb905cc
Customize/disable the typing notification from gtkrc-2.0.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22703
diff
changeset
|
1703 | 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
|
1704 | _("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
|
1705 | _("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
|
1706 | 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
|
1707 | 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
|
1708 | _("Typing notification font"), |
|
34ab3bb905cc
Customize/disable the typing notification from gtkrc-2.0.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22703
diff
changeset
|
1709 | _("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
|
1710 | "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
|
1711 | 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
|
1712 | _("Enable typing notification"), |
|
34ab3bb905cc
Customize/disable the typing notification from gtkrc-2.0.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22703
diff
changeset
|
1713 | _("Enable typing notification"), |
|
34ab3bb905cc
Customize/disable the typing notification from gtkrc-2.0.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22703
diff
changeset
|
1714 | TRUE, G_PARAM_READABLE)); |
|
34ab3bb905cc
Customize/disable the typing notification from gtkrc-2.0.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22703
diff
changeset
|
1715 | |
|
33258
7f35c2552b63
Disable GtkIMHtml key bindings.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33176
diff
changeset
|
1716 | #if 0 |
| 10100 | 1717 | binding_set = gtk_binding_set_by_class (parent_class); |
|
32394
f883709bdba4
compiles using GTK+ 3 from git, beware it does not yet run, in fact it crashes...
Marcus Lundblad <malu@pidgin.im>
parents:
31207
diff
changeset
|
1718 | gtk_binding_entry_add_signal (binding_set, GDK_KEY_b, GDK_CONTROL_MASK, "format_function_toggle", 1, G_TYPE_INT, GTK_IMHTML_BOLD); |
|
f883709bdba4
compiles using GTK+ 3 from git, beware it does not yet run, in fact it crashes...
Marcus Lundblad <malu@pidgin.im>
parents:
31207
diff
changeset
|
1719 | gtk_binding_entry_add_signal (binding_set, GDK_KEY_i, GDK_CONTROL_MASK, "format_function_toggle", 1, G_TYPE_INT, GTK_IMHTML_ITALIC); |
|
f883709bdba4
compiles using GTK+ 3 from git, beware it does not yet run, in fact it crashes...
Marcus Lundblad <malu@pidgin.im>
parents:
31207
diff
changeset
|
1720 | gtk_binding_entry_add_signal (binding_set, GDK_KEY_u, GDK_CONTROL_MASK, "format_function_toggle", 1, G_TYPE_INT, GTK_IMHTML_UNDERLINE); |
|
f883709bdba4
compiles using GTK+ 3 from git, beware it does not yet run, in fact it crashes...
Marcus Lundblad <malu@pidgin.im>
parents:
31207
diff
changeset
|
1721 | gtk_binding_entry_add_signal (binding_set, GDK_KEY_plus, GDK_CONTROL_MASK, "format_function_toggle", 1, G_TYPE_INT, GTK_IMHTML_GROW); |
|
f883709bdba4
compiles using GTK+ 3 from git, beware it does not yet run, in fact it crashes...
Marcus Lundblad <malu@pidgin.im>
parents:
31207
diff
changeset
|
1722 | gtk_binding_entry_add_signal (binding_set, GDK_KEY_equal, GDK_CONTROL_MASK, "format_function_toggle", 1, G_TYPE_INT, GTK_IMHTML_GROW); |
|
f883709bdba4
compiles using GTK+ 3 from git, beware it does not yet run, in fact it crashes...
Marcus Lundblad <malu@pidgin.im>
parents:
31207
diff
changeset
|
1723 | gtk_binding_entry_add_signal (binding_set, GDK_KEY_minus, GDK_CONTROL_MASK, "format_function_toggle", 1, G_TYPE_INT, GTK_IMHTML_SHRINK); |
| 10108 | 1724 | binding_set = gtk_binding_set_by_class(klass); |
|
32394
f883709bdba4
compiles using GTK+ 3 from git, beware it does not yet run, in fact it crashes...
Marcus Lundblad <malu@pidgin.im>
parents:
31207
diff
changeset
|
1725 | gtk_binding_entry_add_signal (binding_set, GDK_KEY_r, GDK_CONTROL_MASK, "format_function_clear", 0); |
|
f883709bdba4
compiles using GTK+ 3 from git, beware it does not yet run, in fact it crashes...
Marcus Lundblad <malu@pidgin.im>
parents:
31207
diff
changeset
|
1726 | gtk_binding_entry_add_signal (binding_set, GDK_KEY_KP_Enter, 0, "message_send", 0); |
|
f883709bdba4
compiles using GTK+ 3 from git, beware it does not yet run, in fact it crashes...
Marcus Lundblad <malu@pidgin.im>
parents:
31207
diff
changeset
|
1727 | gtk_binding_entry_add_signal (binding_set, GDK_KEY_Return, 0, "message_send", 0); |
|
f883709bdba4
compiles using GTK+ 3 from git, beware it does not yet run, in fact it crashes...
Marcus Lundblad <malu@pidgin.im>
parents:
31207
diff
changeset
|
1728 | gtk_binding_entry_add_signal (binding_set, GDK_KEY_z, GDK_CONTROL_MASK, "undo", 0); |
|
f883709bdba4
compiles using GTK+ 3 from git, beware it does not yet run, in fact it crashes...
Marcus Lundblad <malu@pidgin.im>
parents:
31207
diff
changeset
|
1729 | gtk_binding_entry_add_signal (binding_set, GDK_KEY_z, GDK_CONTROL_MASK | GDK_SHIFT_MASK, "redo", 0); |
|
f883709bdba4
compiles using GTK+ 3 from git, beware it does not yet run, in fact it crashes...
Marcus Lundblad <malu@pidgin.im>
parents:
31207
diff
changeset
|
1730 | gtk_binding_entry_add_signal (binding_set, GDK_KEY_F14, 0, "undo", 0); |
|
f883709bdba4
compiles using GTK+ 3 from git, beware it does not yet run, in fact it crashes...
Marcus Lundblad <malu@pidgin.im>
parents:
31207
diff
changeset
|
1731 | gtk_binding_entry_add_signal(binding_set, GDK_KEY_v, GDK_CONTROL_MASK | GDK_SHIFT_MASK, "paste", 1, G_TYPE_STRING, "text"); |
|
33258
7f35c2552b63
Disable GtkIMHtml key bindings.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33176
diff
changeset
|
1732 | #endif |
| 1428 | 1733 | } |
| 1734 | ||
| 3922 | 1735 | static void gtk_imhtml_init (GtkIMHtml *imhtml) |
| 1428 | 1736 | { |
| 3922 | 1737 | 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
|
1738 | imhtml->undo_manager = gtk_source_undo_manager_new(imhtml->text_buffer); |
| 3922 | 1739 | 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
|
1740 | 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
|
1741 | 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
|
1742 | gtk_text_view_set_pixels_below_lines(GTK_TEXT_VIEW(imhtml), 3); |
| 8677 | 1743 | gtk_text_view_set_left_margin(GTK_TEXT_VIEW(imhtml), 2); |
| 1744 | gtk_text_view_set_right_margin(GTK_TEXT_VIEW(imhtml), 2); | |
| 8061 | 1745 | /*gtk_text_view_set_indent(GTK_TEXT_VIEW(imhtml), -15);*/ |
| 3922 | 1746 | /*gtk_text_view_set_justification(GTK_TEXT_VIEW(imhtml), GTK_JUSTIFY_FILL);*/ |
| 8061 | 1747 | |
| 3922 | 1748 | /* These tags will be used often and can be reused--we create them on init and then apply them by name |
| 8932 | 1749 | * other tags (color, size, face, etc.) will have to be created and applied dynamically |
| 9924 | 1750 | * Note that even though we created SUB, SUP, and PRE tags here, we don't really |
| 8932 | 1751 | * apply them anywhere yet. */ |
| 3922 | 1752 | gtk_text_buffer_create_tag(imhtml->text_buffer, "BOLD", "weight", PANGO_WEIGHT_BOLD, NULL); |
| 1753 | gtk_text_buffer_create_tag(imhtml->text_buffer, "ITALICS", "style", PANGO_STYLE_ITALIC, NULL); | |
| 1754 | gtk_text_buffer_create_tag(imhtml->text_buffer, "UNDERLINE", "underline", PANGO_UNDERLINE_SINGLE, NULL); | |
| 1755 | gtk_text_buffer_create_tag(imhtml->text_buffer, "STRIKE", "strikethrough", TRUE, NULL); | |
| 1756 | gtk_text_buffer_create_tag(imhtml->text_buffer, "SUB", "rise", -5000, NULL); | |
| 1757 | gtk_text_buffer_create_tag(imhtml->text_buffer, "SUP", "rise", 5000, NULL); | |
| 1758 | gtk_text_buffer_create_tag(imhtml->text_buffer, "PRE", "family", "Monospace", NULL); | |
| 7295 | 1759 | 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
|
1760 | 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
|
1761 | #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
|
1762 | "invisible", FALSE, |
|
22211
7f3cecdb079c
disapproval of revision '2c96f5a301400781ce5fbf144ffdbae44f895281'
Sean Egan <seanegan@pidgin.im>
parents:
22210
diff
changeset
|
1763 | #endif |
|
23308
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
1764 | NULL); |
| 8677 | 1765 | |
|
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
|
1766 | 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
|
1767 | 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
|
1768 | 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
|
1769 | 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
|
1770 | 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
|
1771 | gtk_text_buffer_create_tag(imhtml->text_buffer, "whisper-name", "weight", PANGO_WEIGHT_BOLD, NULL); |
| 8677 | 1772 | |
| 3922 | 1773 | /* When hovering over a link, we show the hand cursor--elsewhere we show the plain ol' pointer cursor */ |
| 1774 | imhtml->hand_cursor = gdk_cursor_new (GDK_HAND2); | |
| 1775 | imhtml->arrow_cursor = gdk_cursor_new (GDK_LEFT_PTR); | |
| 8061 | 1776 | imhtml->text_cursor = gdk_cursor_new (GDK_XTERM); |
| 2993 | 1777 | |
|
6124
322206d79652
[gaim-migrate @ 6598]
Mark Doliner <markdoliner@pidgin.im>
parents:
6066
diff
changeset
|
1778 | imhtml->show_comments = TRUE; |
| 4253 | 1779 | |
| 4892 | 1780 | imhtml->smiley_data = g_hash_table_new_full(g_str_hash, g_str_equal, |
| 4902 | 1781 | g_free, (GDestroyNotify)gtk_smiley_tree_destroy); |
| 4032 | 1782 | imhtml->default_smilies = gtk_smiley_tree_new(); |
| 4735 | 1783 | |
| 1784 | 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
|
1785 | 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
|
1786 | g_signal_connect(G_OBJECT(imhtml), "enter-notify-event", G_CALLBACK(gtk_enter_event_notify), NULL); |
| 8677 | 1787 | g_signal_connect(G_OBJECT(imhtml), "button_press_event", G_CALLBACK(gtk_imhtml_button_press_event), NULL); |
| 1788 | 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
|
1789 | g_signal_connect(G_OBJECT(imhtml->text_buffer), "delete_range", G_CALLBACK(delete_cb), imhtml); |
| 8061 | 1790 | g_signal_connect_after(G_OBJECT(imhtml->text_buffer), "insert-text", G_CALLBACK(insert_cb), imhtml); |
| 10169 | 1791 | g_signal_connect_after(G_OBJECT(imhtml->text_buffer), "insert-child-anchor", G_CALLBACK(insert_ca_cb), imhtml); |
| 8091 | 1792 | gtk_drag_dest_set(GTK_WIDGET(imhtml), 0, |
| 1793 | link_drag_drop_targets, sizeof(link_drag_drop_targets) / sizeof(GtkTargetEntry), | |
| 1794 | GDK_ACTION_COPY); | |
| 1795 | g_signal_connect(G_OBJECT(imhtml), "drag_data_received", G_CALLBACK(gtk_imhtml_link_drag_rcv_cb), imhtml); | |
| 9300 | 1796 | g_signal_connect(G_OBJECT(imhtml), "drag_drop", G_CALLBACK(gtk_imhtml_link_drop_cb), imhtml); |
| 8091 | 1797 | |
| 7353 | 1798 | g_signal_connect(G_OBJECT(imhtml), "copy-clipboard", G_CALLBACK(copy_clipboard_cb), NULL); |
| 8698 | 1799 | g_signal_connect(G_OBJECT(imhtml), "cut-clipboard", G_CALLBACK(cut_clipboard_cb), NULL); |
| 8061 | 1800 | g_signal_connect(G_OBJECT(imhtml), "paste-clipboard", G_CALLBACK(paste_clipboard_cb), NULL); |
| 8677 | 1801 | 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
|
1802 | 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
|
1803 | g_signal_connect(G_OBJECT(imhtml), "paste", G_CALLBACK(imhtml_paste_cb), NULL); |
| 8677 | 1804 | |
|
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
|
1805 | #ifndef _WIN32 |
| 8677 | 1806 | g_signal_connect_after(G_OBJECT(GTK_IMHTML(imhtml)->text_buffer), "mark-set", |
| 1807 | 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
|
1808 | #endif |
| 8677 | 1809 | |
|
10946
63a41710fc94
[gaim-migrate @ 12742]
Daniel Atallah <datallah@pidgin.im>
parents:
10936
diff
changeset
|
1810 | gtk_widget_add_events(GTK_WIDGET(imhtml), |
|
63a41710fc94
[gaim-migrate @ 12742]
Daniel Atallah <datallah@pidgin.im>
parents:
10936
diff
changeset
|
1811 | GDK_LEAVE_NOTIFY_MASK | GDK_ENTER_NOTIFY_MASK); |
| 4735 | 1812 | |
| 1813 | imhtml->tip = NULL; | |
| 1814 | imhtml->tip_timer = 0; | |
| 1815 | imhtml->tip_window = NULL; | |
| 4895 | 1816 | |
| 8677 | 1817 | imhtml->edit.bold = FALSE; |
| 1818 | imhtml->edit.italic = FALSE; | |
| 1819 | imhtml->edit.underline = FALSE; | |
| 8061 | 1820 | imhtml->edit.forecolor = NULL; |
| 1821 | imhtml->edit.backcolor = NULL; | |
| 1822 | imhtml->edit.fontface = NULL; | |
| 8677 | 1823 | imhtml->edit.fontsize = 0; |
| 1824 | imhtml->edit.link = NULL; | |
| 1825 | ||
|
11572
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
1826 | |
| 4895 | 1827 | 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
|
1828 | imhtml->animations = g_queue_new(); |
| 8061 | 1829 | gtk_imhtml_set_editable(imhtml, FALSE); |
|
11572
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
1830 | g_signal_connect(G_OBJECT(imhtml), "populate-popup", |
| 8931 | 1831 | G_CALLBACK(hijack_menu_cb), NULL); |
| 2993 | 1832 | } |
| 1833 | ||
| 3922 | 1834 | GtkWidget *gtk_imhtml_new(void *a, void *b) |
| 1428 | 1835 | { |
| 4635 | 1836 | return GTK_WIDGET(g_object_new(gtk_imhtml_get_type(), NULL)); |
| 1428 | 1837 | } |
| 1838 | ||
| 9037 | 1839 | GType gtk_imhtml_get_type() |
| 1428 | 1840 | { |
| 9037 | 1841 | static GType imhtml_type = 0; |
| 1428 | 1842 | |
| 1843 | if (!imhtml_type) { | |
| 9037 | 1844 | static const GTypeInfo imhtml_info = { |
| 4635 | 1845 | sizeof(GtkIMHtmlClass), |
| 1846 | NULL, | |
| 1847 | NULL, | |
| 1848 | (GClassInitFunc) gtk_imhtml_class_init, | |
| 1849 | NULL, | |
| 1850 | NULL, | |
| 1428 | 1851 | sizeof (GtkIMHtml), |
| 4635 | 1852 | 0, |
|
12600
7ecd4441fdc7
[gaim-migrate @ 14934]
Richard Laager <rlaager@pidgin.im>
parents:
12553
diff
changeset
|
1853 | (GInstanceInitFunc) gtk_imhtml_init, |
|
7ecd4441fdc7
[gaim-migrate @ 14934]
Richard Laager <rlaager@pidgin.im>
parents:
12553
diff
changeset
|
1854 | NULL |
| 1428 | 1855 | }; |
| 4635 | 1856 | |
| 1857 | imhtml_type = g_type_register_static(gtk_text_view_get_type(), | |
| 1858 | "GtkIMHtml", &imhtml_info, 0); | |
| 1428 | 1859 | } |
| 1860 | ||
| 1861 | return imhtml_type; | |
| 1862 | } | |
| 1863 | ||
|
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
|
1864 | 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
|
1865 | { |
|
f9dd7117ade0
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24675
diff
changeset
|
1866 | 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
|
1867 | 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
|
1868 | 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
|
1869 | 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
|
1870 | 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
|
1871 | g_free(link); |
| 4417 | 1872 | } |
| 1873 | ||
| 1874 | /* 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
|
1875 | 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
|
1876 | { |
| 4417 | 1877 | GdkEventButton *event_button = (GdkEventButton *) event; |
| 8061 | 1878 | if (GTK_IMHTML(imhtml)->editable) |
| 1879 | return FALSE; | |
| 3922 | 1880 | if (event->type == GDK_BUTTON_RELEASE) { |
| 8957 | 1881 | if ((event_button->button == 1) || (event_button->button == 2)) { |
| 4417 | 1882 | GtkTextIter start, end; |
| 1883 | /* we shouldn't open a URL if the user has selected something: */ | |
| 8677 | 1884 | if (gtk_text_buffer_get_selection_bounds( |
| 1885 | gtk_text_iter_get_buffer(arg2), &start, &end)) | |
| 4417 | 1886 | 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
|
1887 | gtk_imhtml_activate_tag(GTK_IMHTML(imhtml), tag); |
| 4417 | 1888 | return FALSE; |
| 1889 | } 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
|
1890 | 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
|
1891 | 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
|
1892 | 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
|
1893 | 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
|
1894 | 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
|
1895 | 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
|
1896 | link->tag = g_object_ref(tag); |
| 4745 | 1897 | |
| 5091 | 1898 | /* Don't want the tooltip around if user right-clicked on link */ |
| 1899 | if (GTK_IMHTML(imhtml)->tip_window) { | |
| 1900 | gtk_widget_destroy(GTK_IMHTML(imhtml)->tip_window); | |
| 1901 | GTK_IMHTML(imhtml)->tip_window = NULL; | |
| 1902 | } | |
| 1903 | if (GTK_IMHTML(imhtml)->tip_timer) { | |
| 1904 | g_source_remove(GTK_IMHTML(imhtml)->tip_timer); | |
| 1905 | GTK_IMHTML(imhtml)->tip_timer = 0; | |
| 1906 | } | |
| 8061 | 1907 | if (GTK_IMHTML(imhtml)->editable) |
| 1908 | gdk_window_set_cursor(event_button->window, GTK_IMHTML(imhtml)->text_cursor); | |
| 1909 | else | |
| 1910 | gdk_window_set_cursor(event_button->window, GTK_IMHTML(imhtml)->arrow_cursor); | |
| 4417 | 1911 | 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
|
1912 | 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
|
1913 | (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
|
1914 | |
|
25013
956b2f650d31
Detect duplication registrations by substring.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
25011
diff
changeset
|
1915 | 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
|
1916 | |
|
f9dd7117ade0
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24675
diff
changeset
|
1917 | 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
|
1918 | proto->context_menu(GTK_IMHTML(link->imhtml), link, menu); |
|
7140
2670fa7da352
[gaim-migrate @ 7707]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
1919 | } |
|
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
|
1920 | |
|
f9dd7117ade0
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24675
diff
changeset
|
1921 | 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
|
1922 | 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
|
1923 | 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
|
1924 | 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
|
1925 | gtk_widget_set_sensitive(item, FALSE); |
| 10936 | 1926 | 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
|
1927 | } 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
|
1928 | g_list_free(children); |
|
7140
2670fa7da352
[gaim-migrate @ 7707]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
1929 | } |
|
2670fa7da352
[gaim-migrate @ 7707]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
1930 | |
|
4756
ee19a87a495f
[gaim-migrate @ 5073]
Mark Doliner <markdoliner@pidgin.im>
parents:
4745
diff
changeset
|
1931 | |
| 4417 | 1932 | gtk_widget_show_all(menu); |
|
4756
ee19a87a495f
[gaim-migrate @ 5073]
Mark Doliner <markdoliner@pidgin.im>
parents:
4745
diff
changeset
|
1933 | gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL, |
|
ee19a87a495f
[gaim-migrate @ 5073]
Mark Doliner <markdoliner@pidgin.im>
parents:
4745
diff
changeset
|
1934 | event_button->button, event_button->time); |
| 4745 | 1935 | |
| 4417 | 1936 | return TRUE; |
| 1937 | } | |
| 1428 | 1938 | } |
| 4417 | 1939 | if(event->type == GDK_BUTTON_PRESS && event_button->button == 3) |
| 1940 | return TRUE; /* Clicking the right mouse button on a link shouldn't | |
| 1941 | be caught by the regular GtkTextView menu */ | |
| 1942 | else | |
| 1943 | return FALSE; /* Let clicks go through if we didn't catch anything */ | |
| 1428 | 1944 | } |
| 1945 | ||
| 9300 | 1946 | static gboolean |
| 1947 | gtk_text_view_drag_motion (GtkWidget *widget, | |
| 1948 | GdkDragContext *context, | |
| 1949 | gint x, | |
| 1950 | gint y, | |
| 1951 | guint time) | |
| 1952 | { | |
|
11572
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
1953 | GdkDragAction suggested_action = 0; |
| 9300 | 1954 | |
|
10145
f1405f65ff41
[gaim-migrate @ 11218]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10110
diff
changeset
|
1955 | 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
|
1956 | /* can't accept any of the offered targets */ |
| 9300 | 1957 | } else { |
| 1958 | GtkWidget *source_widget; | |
|
32394
f883709bdba4
compiles using GTK+ 3 from git, beware it does not yet run, in fact it crashes...
Marcus Lundblad <malu@pidgin.im>
parents:
31207
diff
changeset
|
1959 | suggested_action = gdk_drag_context_get_suggested_action(context); |
| 9300 | 1960 | source_widget = gtk_drag_get_source_widget (context); |
| 1961 | if (source_widget == widget) { | |
| 1962 | /* Default to MOVE, unless the user has | |
| 1963 | * pressed ctrl or alt to affect available actions | |
| 1964 | */ | |
|
32394
f883709bdba4
compiles using GTK+ 3 from git, beware it does not yet run, in fact it crashes...
Marcus Lundblad <malu@pidgin.im>
parents:
31207
diff
changeset
|
1965 | if ((gdk_drag_context_get_actions(context) & GDK_ACTION_MOVE) != 0) |
| 9300 | 1966 | suggested_action = GDK_ACTION_MOVE; |
| 1967 | } | |
|
11572
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
1968 | } |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
1969 | |
|
10145
f1405f65ff41
[gaim-migrate @ 11218]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10110
diff
changeset
|
1970 | gdk_drag_status (context, suggested_action, time); |
|
11572
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
1971 | |
|
32422
c215bc5d85e4
Whitespace fixes. Try and check your editor settings before writing
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32414
diff
changeset
|
1972 | /* TRUE return means don't propagate the drag motion to parent |
|
c215bc5d85e4
Whitespace fixes. Try and check your editor settings before writing
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32414
diff
changeset
|
1973 | * widgets that may also be drop sites. |
|
c215bc5d85e4
Whitespace fixes. Try and check your editor settings before writing
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32414
diff
changeset
|
1974 | */ |
|
c215bc5d85e4
Whitespace fixes. Try and check your editor settings before writing
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32414
diff
changeset
|
1975 | return TRUE; |
| 9300 | 1976 | } |
| 1977 | ||
| 1978 | static void | |
| 1979 | gtk_imhtml_link_drop_cb(GtkWidget *widget, GdkDragContext *context, gint x, gint y, guint time, gpointer user_data) | |
| 1980 | { | |
| 1981 | GdkAtom target = gtk_drag_dest_find_target (widget, context, NULL); | |
|
11572
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
1982 | |
| 9300 | 1983 | if (target != GDK_NONE) |
| 1984 | gtk_drag_get_data (widget, context, target, time); | |
| 1985 | else | |
| 1986 | gtk_drag_finish (context, FALSE, FALSE, time); | |
| 1987 | ||
| 1988 | return; | |
| 1989 | } | |
| 1990 | ||
| 8091 | 1991 | static void |
| 1992 | 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
|
1993 | GtkSelectionData *sd, guint info, guint t, GtkIMHtml *imhtml) |
| 8091 | 1994 | { |
| 9300 | 1995 | gchar **links; |
| 1996 | gchar *link; | |
|
32394
f883709bdba4
compiles using GTK+ 3 from git, beware it does not yet run, in fact it crashes...
Marcus Lundblad <malu@pidgin.im>
parents:
31207
diff
changeset
|
1997 | char *text = (char *) gtk_selection_data_get_data(sd); |
| 9300 | 1998 | GtkTextMark *mark = gtk_text_buffer_get_insert(imhtml->text_buffer); |
| 1999 | GtkTextIter iter; | |
|
10782
18cc41076f4e
[gaim-migrate @ 12410]
Luke Schierer <lschiere@pidgin.im>
parents:
10777
diff
changeset
|
2000 | gint i = 0; |
|
32413
00ad036bdf3d
Fix some indenting.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32412
diff
changeset
|
2001 | gint length = gtk_selection_data_get_length(sd); |
| 9300 | 2002 | |
| 2003 | gtk_text_buffer_get_iter_at_mark(imhtml->text_buffer, &iter, mark); | |
| 2004 | ||
|
32413
00ad036bdf3d
Fix some indenting.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32412
diff
changeset
|
2005 | if (gtk_imhtml_get_editable(imhtml) && text) { |
| 9300 | 2006 | switch (info) { |
|
10145
f1405f65ff41
[gaim-migrate @ 11218]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10110
diff
changeset
|
2007 | case GTK_IMHTML_DRAG_URL: |
|
11143
f606fb334190
[gaim-migrate @ 13207]
Mark Doliner <markdoliner@pidgin.im>
parents:
11069
diff
changeset
|
2008 | /* TODO: Is it really ok to change sd->data...? */ |
|
32394
f883709bdba4
compiles using GTK+ 3 from git, beware it does not yet run, in fact it crashes...
Marcus Lundblad <malu@pidgin.im>
parents:
31207
diff
changeset
|
2009 | purple_str_strip_char(text, '\r'); |
|
f883709bdba4
compiles using GTK+ 3 from git, beware it does not yet run, in fact it crashes...
Marcus Lundblad <malu@pidgin.im>
parents:
31207
diff
changeset
|
2010 | |
|
f883709bdba4
compiles using GTK+ 3 from git, beware it does not yet run, in fact it crashes...
Marcus Lundblad <malu@pidgin.im>
parents:
31207
diff
changeset
|
2011 | links = g_strsplit(text, "\n", 0); |
|
32413
00ad036bdf3d
Fix some indenting.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32412
diff
changeset
|
2012 | 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
|
2013 | if (gtk_imhtml_is_protocol(link)) { |
|
10782
18cc41076f4e
[gaim-migrate @ 12410]
Luke Schierer <lschiere@pidgin.im>
parents:
10777
diff
changeset
|
2014 | gchar *label; |
|
18cc41076f4e
[gaim-migrate @ 12410]
Luke Schierer <lschiere@pidgin.im>
parents:
10777
diff
changeset
|
2015 | |
|
18cc41076f4e
[gaim-migrate @ 12410]
Luke Schierer <lschiere@pidgin.im>
parents:
10777
diff
changeset
|
2016 | if(links[i + 1]) |
|
18cc41076f4e
[gaim-migrate @ 12410]
Luke Schierer <lschiere@pidgin.im>
parents:
10777
diff
changeset
|
2017 | i++; |
|
18cc41076f4e
[gaim-migrate @ 12410]
Luke Schierer <lschiere@pidgin.im>
parents:
10777
diff
changeset
|
2018 | |
|
18cc41076f4e
[gaim-migrate @ 12410]
Luke Schierer <lschiere@pidgin.im>
parents:
10777
diff
changeset
|
2019 | label = links[i]; |
|
18cc41076f4e
[gaim-migrate @ 12410]
Luke Schierer <lschiere@pidgin.im>
parents:
10777
diff
changeset
|
2020 | |
|
18cc41076f4e
[gaim-migrate @ 12410]
Luke Schierer <lschiere@pidgin.im>
parents:
10777
diff
changeset
|
2021 | 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
|
2022 | } else if (*link == '\0') { |
| 9300 | 2023 | /* Ignore blank lines */ |
| 2024 | } else { | |
| 2025 | /* 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
|
2026 | /* ... don't pretend we handled it if we didn't */ |
|
7d7f8cfa2b4f
[gaim-migrate @ 11556]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
10297
diff
changeset
|
2027 | gtk_drag_finish(dc, FALSE, FALSE, t); |
|
10782
18cc41076f4e
[gaim-migrate @ 12410]
Luke Schierer <lschiere@pidgin.im>
parents:
10777
diff
changeset
|
2028 | g_strfreev(links); |
|
10345
7d7f8cfa2b4f
[gaim-migrate @ 11556]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
10297
diff
changeset
|
2029 | return; |
| 9300 | 2030 | } |
|
10782
18cc41076f4e
[gaim-migrate @ 12410]
Luke Schierer <lschiere@pidgin.im>
parents:
10777
diff
changeset
|
2031 | |
|
18cc41076f4e
[gaim-migrate @ 12410]
Luke Schierer <lschiere@pidgin.im>
parents:
10777
diff
changeset
|
2032 | i++; |
| 8091 | 2033 | } |
|
32422
c215bc5d85e4
Whitespace fixes. Try and check your editor settings before writing
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32414
diff
changeset
|
2034 | g_strfreev(links); |
| 9300 | 2035 | break; |
|
10145
f1405f65ff41
[gaim-migrate @ 11218]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10110
diff
changeset
|
2036 | case GTK_IMHTML_DRAG_HTML: |
|
10243
6d75b29afc71
[gaim-migrate @ 11383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10217
diff
changeset
|
2037 | { |
|
6d75b29afc71
[gaim-migrate @ 11383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10217
diff
changeset
|
2038 | char *utf8 = NULL; |
|
6d75b29afc71
[gaim-migrate @ 11383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10217
diff
changeset
|
2039 | /* 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
|
2040 | * as explained by this comment in gtkhtml: |
|
6d75b29afc71
[gaim-migrate @ 11383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10217
diff
changeset
|
2041 | * |
|
6d75b29afc71
[gaim-migrate @ 11383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10217
diff
changeset
|
2042 | * 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
|
2043 | * mozilla/netscape alway use ucs2 for text/html |
|
6d75b29afc71
[gaim-migrate @ 11383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10217
diff
changeset
|
2044 | * 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
|
2045 | * 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
|
2046 | * |
|
6d75b29afc71
[gaim-migrate @ 11383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10217
diff
changeset
|
2047 | * See also the comment on text/html here: |
|
6d75b29afc71
[gaim-migrate @ 11383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10217
diff
changeset
|
2048 | * 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
|
2049 | */ |
|
32394
f883709bdba4
compiles using GTK+ 3 from git, beware it does not yet run, in fact it crashes...
Marcus Lundblad <malu@pidgin.im>
parents:
31207
diff
changeset
|
2050 | if (length >= 2 && !g_utf8_validate(text, length - 1, NULL)) { |
|
f883709bdba4
compiles using GTK+ 3 from git, beware it does not yet run, in fact it crashes...
Marcus Lundblad <malu@pidgin.im>
parents:
31207
diff
changeset
|
2051 | utf8 = utf16_to_utf8_with_bom_check(text, length); |
|
10243
6d75b29afc71
[gaim-migrate @ 11383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10217
diff
changeset
|
2052 | |
|
6d75b29afc71
[gaim-migrate @ 11383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10217
diff
changeset
|
2053 | 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
|
2054 | purple_debug_warning("gtkimhtml", "g_convert from UTF-16 failed in drag_rcv_cb\n"); |
| 9300 | 2055 | return; |
| 2056 | } | |
|
10243
6d75b29afc71
[gaim-migrate @ 11383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10217
diff
changeset
|
2057 | } else if (!(*text) || !g_utf8_validate(text, -1, NULL)) { |
| 15884 | 2058 | purple_debug_warning("gtkimhtml", "empty string or invalid UTF-8 in drag_rcv_cb\n"); |
| 9300 | 2059 | return; |
| 2060 | } | |
|
10243
6d75b29afc71
[gaim-migrate @ 11383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10217
diff
changeset
|
2061 | |
|
6d75b29afc71
[gaim-migrate @ 11383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10217
diff
changeset
|
2062 | 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
|
2063 | g_free(utf8); |
| 9300 | 2064 | break; |
|
10243
6d75b29afc71
[gaim-migrate @ 11383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10217
diff
changeset
|
2065 | } |
|
10145
f1405f65ff41
[gaim-migrate @ 11218]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10110
diff
changeset
|
2066 | case GTK_IMHTML_DRAG_TEXT: |
|
f1405f65ff41
[gaim-migrate @ 11218]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10110
diff
changeset
|
2067 | if (!(*text) || !g_utf8_validate(text, -1, NULL)) { |
| 15884 | 2068 | 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
|
2069 | return; |
|
f1405f65ff41
[gaim-migrate @ 11218]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10110
diff
changeset
|
2070 | } else { |
|
10732
5e314ab498bf
[gaim-migrate @ 12334]
Richard Laager <rlaager@pidgin.im>
parents:
10699
diff
changeset
|
2071 | char *tmp = g_markup_escape_text(text, -1); |
|
10145
f1405f65ff41
[gaim-migrate @ 11218]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10110
diff
changeset
|
2072 | gtk_imhtml_insert_html_at_iter(imhtml, tmp, 0, &iter); |
|
f1405f65ff41
[gaim-migrate @ 11218]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10110
diff
changeset
|
2073 | g_free(tmp); |
|
f1405f65ff41
[gaim-migrate @ 11218]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10110
diff
changeset
|
2074 | } |
|
f1405f65ff41
[gaim-migrate @ 11218]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10110
diff
changeset
|
2075 | break; |
| 9300 | 2076 | default: |
|
10145
f1405f65ff41
[gaim-migrate @ 11218]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10110
diff
changeset
|
2077 | gtk_drag_finish(dc, FALSE, FALSE, t); |
|
f1405f65ff41
[gaim-migrate @ 11218]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10110
diff
changeset
|
2078 | return; |
| 8091 | 2079 | } |
|
32394
f883709bdba4
compiles using GTK+ 3 from git, beware it does not yet run, in fact it crashes...
Marcus Lundblad <malu@pidgin.im>
parents:
31207
diff
changeset
|
2080 | gtk_drag_finish(dc, TRUE, |
|
32413
00ad036bdf3d
Fix some indenting.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32412
diff
changeset
|
2081 | gdk_drag_context_get_actions(dc) == GDK_ACTION_MOVE, t); |
| 8091 | 2082 | } else { |
| 2083 | gtk_drag_finish(dc, FALSE, FALSE, t); | |
| 2084 | } | |
| 2085 | } | |
| 2086 | ||
| 9300 | 2087 | static void gtk_smiley_tree_remove (GtkSmileyTree *tree, |
| 4263 | 2088 | GtkIMHtmlSmiley *smiley) |
| 4032 | 2089 | { |
| 2090 | GtkSmileyTree *t = tree; | |
| 4263 | 2091 | const gchar *x = smiley->smile; |
| 4032 | 2092 | gint len = 0; |
| 2093 | ||
| 2094 | while (*x) { | |
| 2095 | gchar *pos; | |
| 2096 | ||
| 2097 | if (!t->values) | |
| 2098 | return; | |
| 2099 | ||
| 2100 | pos = strchr (t->values->str, *x); | |
| 2101 | if (pos) | |
|
24544
75266af2c12b
Fixed a compiler warning (and remove an unnessesary cast)
Marcus Lundblad <malu@pidgin.im>
parents:
24511
diff
changeset
|
2102 | t = t->children [pos - t->values->str]; |
| 4032 | 2103 | else |
| 2104 | return; | |
| 2105 | ||
| 2106 | x++; len++; | |
| 2107 | } | |
| 2108 | ||
| 4141 | 2109 | if (t->image) { |
| 4032 | 2110 | t->image = NULL; |
| 4141 | 2111 | } |
| 4032 | 2112 | } |
| 2113 | ||
| 2114 | static gint | |
| 2115 | gtk_smiley_tree_lookup (GtkSmileyTree *tree, | |
| 2116 | const gchar *text) | |
| 2117 | { | |
| 2118 | GtkSmileyTree *t = tree; | |
| 2119 | const gchar *x = text; | |
| 2120 | gint len = 0; | |
|
16143
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
2121 | const gchar *amp; |
| 8505 | 2122 | gint alen; |
| 4032 | 2123 | |
| 2124 | while (*x) { | |
| 2125 | gchar *pos; | |
| 2126 | ||
| 2127 | if (!t->values) | |
| 2128 | break; | |
| 2129 | ||
| 16144 | 2130 | if(*x == '&' && (amp = purple_markup_unescape_entity(x, &alen))) { |
|
10865
f5bb66be81a0
[gaim-migrate @ 12549]
Daniel Atallah <datallah@pidgin.im>
parents:
10858
diff
changeset
|
2131 | gboolean matched = TRUE; |
|
f5bb66be81a0
[gaim-migrate @ 12549]
Daniel Atallah <datallah@pidgin.im>
parents:
10858
diff
changeset
|
2132 | /* Make sure all chars of the unescaped value match */ |
|
f5bb66be81a0
[gaim-migrate @ 12549]
Daniel Atallah <datallah@pidgin.im>
parents:
10858
diff
changeset
|
2133 | while (*(amp + 1)) { |
|
f5bb66be81a0
[gaim-migrate @ 12549]
Daniel Atallah <datallah@pidgin.im>
parents:
10858
diff
changeset
|
2134 | pos = strchr (t->values->str, *amp); |
|
f5bb66be81a0
[gaim-migrate @ 12549]
Daniel Atallah <datallah@pidgin.im>
parents:
10858
diff
changeset
|
2135 | if (pos) |
|
f5bb66be81a0
[gaim-migrate @ 12549]
Daniel Atallah <datallah@pidgin.im>
parents:
10858
diff
changeset
|
2136 | 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
|
2137 | else { |
|
f5bb66be81a0
[gaim-migrate @ 12549]
Daniel Atallah <datallah@pidgin.im>
parents:
10858
diff
changeset
|
2138 | matched = FALSE; |
|
f5bb66be81a0
[gaim-migrate @ 12549]
Daniel Atallah <datallah@pidgin.im>
parents:
10858
diff
changeset
|
2139 | break; |
|
f5bb66be81a0
[gaim-migrate @ 12549]
Daniel Atallah <datallah@pidgin.im>
parents:
10858
diff
changeset
|
2140 | } |
|
f5bb66be81a0
[gaim-migrate @ 12549]
Daniel Atallah <datallah@pidgin.im>
parents:
10858
diff
changeset
|
2141 | amp++; |
|
f5bb66be81a0
[gaim-migrate @ 12549]
Daniel Atallah <datallah@pidgin.im>
parents:
10858
diff
changeset
|
2142 | } |
|
f5bb66be81a0
[gaim-migrate @ 12549]
Daniel Atallah <datallah@pidgin.im>
parents:
10858
diff
changeset
|
2143 | if (!matched) |
|
f5bb66be81a0
[gaim-migrate @ 12549]
Daniel Atallah <datallah@pidgin.im>
parents:
10858
diff
changeset
|
2144 | break; |
|
f5bb66be81a0
[gaim-migrate @ 12549]
Daniel Atallah <datallah@pidgin.im>
parents:
10858
diff
changeset
|
2145 | |
|
f5bb66be81a0
[gaim-migrate @ 12549]
Daniel Atallah <datallah@pidgin.im>
parents:
10858
diff
changeset
|
2146 | pos = strchr (t->values->str, *amp); |
| 8505 | 2147 | } |
|
11572
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
2148 | else if (*x == '<') /* Because we're all WYSIWYG now, a '<' |
| 9636 | 2149 | * char should only appear as the start of a tag. Perhaps a safer (but costlier) |
| 2150 | * check would be to call gtk_imhtml_is_tag on it */ | |
| 10600 | 2151 | break; |
|
10865
f5bb66be81a0
[gaim-migrate @ 12549]
Daniel Atallah <datallah@pidgin.im>
parents:
10858
diff
changeset
|
2152 | else { |
|
f5bb66be81a0
[gaim-migrate @ 12549]
Daniel Atallah <datallah@pidgin.im>
parents:
10858
diff
changeset
|
2153 | alen = 1; |
|
f5bb66be81a0
[gaim-migrate @ 12549]
Daniel Atallah <datallah@pidgin.im>
parents:
10858
diff
changeset
|
2154 | pos = strchr (t->values->str, *x); |
|
f5bb66be81a0
[gaim-migrate @ 12549]
Daniel Atallah <datallah@pidgin.im>
parents:
10858
diff
changeset
|
2155 | } |
| 8505 | 2156 | |
| 4032 | 2157 | if (pos) |
| 7371 | 2158 | t = t->children [GPOINTER_TO_INT(pos) - GPOINTER_TO_INT(t->values->str)]; |
| 4032 | 2159 | else |
| 2160 | break; | |
| 2161 | ||
|
10865
f5bb66be81a0
[gaim-migrate @ 12549]
Daniel Atallah <datallah@pidgin.im>
parents:
10858
diff
changeset
|
2162 | x += alen; |
|
f5bb66be81a0
[gaim-migrate @ 12549]
Daniel Atallah <datallah@pidgin.im>
parents:
10858
diff
changeset
|
2163 | len += alen; |
| 4032 | 2164 | } |
| 2165 | ||
| 2166 | if (t->image) | |
| 2167 | return len; | |
| 2168 | ||
| 2169 | return 0; | |
| 2170 | } | |
| 2171 | ||
|
24392
51b7f65a712d
Clean up the GtkSmileyTrees on active GtkIMHtml instances when a custom smiley
Marcus Lundblad <malu@pidgin.im>
parents:
24328
diff
changeset
|
2172 | static void |
|
51b7f65a712d
Clean up the GtkSmileyTrees on active GtkIMHtml instances when a custom smiley
Marcus Lundblad <malu@pidgin.im>
parents:
24328
diff
changeset
|
2173 | 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
|
2174 | 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
|
2175 | { |
|
51b7f65a712d
Clean up the GtkSmileyTrees on active GtkIMHtml instances when a custom smiley
Marcus Lundblad <malu@pidgin.im>
parents:
24328
diff
changeset
|
2176 | 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
|
2177 | 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
|
2178 | 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
|
2179 | } |
|
51b7f65a712d
Clean up the GtkSmileyTrees on active GtkIMHtml instances when a custom smiley
Marcus Lundblad <malu@pidgin.im>
parents:
24328
diff
changeset
|
2180 | |
|
51b7f65a712d
Clean up the GtkSmileyTrees on active GtkIMHtml instances when a custom smiley
Marcus Lundblad <malu@pidgin.im>
parents:
24328
diff
changeset
|
2181 | static void |
|
24588
b2c89babe134
Remove that hack involving GtkIMHtmlSmileys
Marcus Lundblad <malu@pidgin.im>
parents:
24587
diff
changeset
|
2182 | gtk_imhtml_disconnect_smiley(GtkIMHtml *imhtml, GtkIMHtmlSmiley *smiley) |
|
b2c89babe134
Remove that hack involving GtkIMHtmlSmileys
Marcus Lundblad <malu@pidgin.im>
parents:
24587
diff
changeset
|
2183 | { |
|
b2c89babe134
Remove that hack involving GtkIMHtmlSmileys
Marcus Lundblad <malu@pidgin.im>
parents:
24587
diff
changeset
|
2184 | smiley->imhtml = NULL; |
|
b2c89babe134
Remove that hack involving GtkIMHtmlSmileys
Marcus Lundblad <malu@pidgin.im>
parents:
24587
diff
changeset
|
2185 | 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
|
2186 | NULL, NULL, smiley); |
|
b2c89babe134
Remove that hack involving GtkIMHtmlSmileys
Marcus Lundblad <malu@pidgin.im>
parents:
24587
diff
changeset
|
2187 | } |
|
b2c89babe134
Remove that hack involving GtkIMHtmlSmileys
Marcus Lundblad <malu@pidgin.im>
parents:
24587
diff
changeset
|
2188 | |
|
b2c89babe134
Remove that hack involving GtkIMHtmlSmileys
Marcus Lundblad <malu@pidgin.im>
parents:
24587
diff
changeset
|
2189 | 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
|
2190 | 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
|
2191 | { |
|
24588
b2c89babe134
Remove that hack involving GtkIMHtmlSmileys
Marcus Lundblad <malu@pidgin.im>
parents:
24587
diff
changeset
|
2192 | 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
|
2193 | gtk_smiley_tree_remove(smiley->imhtml->default_smilies, smiley); |
|
25888
d0fdd378a635
Remove trailing whitespace
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
2194 | 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
|
2195 | gtk_imhtml_disassociate_smiley_foreach, smiley); |
|
24588
b2c89babe134
Remove that hack involving GtkIMHtmlSmileys
Marcus Lundblad <malu@pidgin.im>
parents:
24587
diff
changeset
|
2196 | 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
|
2197 | 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
|
2198 | 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
|
2199 | } |
|
51b7f65a712d
Clean up the GtkSmileyTrees on active GtkIMHtml instances when a custom smiley
Marcus Lundblad <malu@pidgin.im>
parents:
24328
diff
changeset
|
2200 | } |
|
51b7f65a712d
Clean up the GtkSmileyTrees on active GtkIMHtml instances when a custom smiley
Marcus Lundblad <malu@pidgin.im>
parents:
24328
diff
changeset
|
2201 | |
| 4032 | 2202 | void |
| 4263 | 2203 | gtk_imhtml_associate_smiley (GtkIMHtml *imhtml, |
|
10537
9ece7671fa62
[gaim-migrate @ 11890]
Mark Doliner <markdoliner@pidgin.im>
parents:
10526
diff
changeset
|
2204 | const gchar *sml, |
| 4263 | 2205 | GtkIMHtmlSmiley *smiley) |
| 4032 | 2206 | { |
| 2207 | GtkSmileyTree *tree; | |
| 2208 | g_return_if_fail (imhtml != NULL); | |
| 2209 | g_return_if_fail (GTK_IS_IMHTML (imhtml)); | |
| 7371 | 2210 | |
| 4032 | 2211 | if (sml == NULL) |
| 2212 | tree = imhtml->default_smilies; | |
|
12833
1f461f275b90
[gaim-migrate @ 15181]
Richard Laager <rlaager@pidgin.im>
parents:
12796
diff
changeset
|
2213 | else if (!(tree = g_hash_table_lookup(imhtml->smiley_data, sml))) { |
| 4032 | 2214 | tree = gtk_smiley_tree_new(); |
| 4892 | 2215 | g_hash_table_insert(imhtml->smiley_data, g_strdup(sml), tree); |
| 4032 | 2216 | } |
| 2217 | ||
|
24588
b2c89babe134
Remove that hack involving GtkIMHtmlSmileys
Marcus Lundblad <malu@pidgin.im>
parents:
24587
diff
changeset
|
2218 | /* need to disconnect old imhtml, if there is one */ |
|
b2c89babe134
Remove that hack involving GtkIMHtmlSmileys
Marcus Lundblad <malu@pidgin.im>
parents:
24587
diff
changeset
|
2219 | if (smiley->imhtml) { |
|
b2c89babe134
Remove that hack involving GtkIMHtmlSmileys
Marcus Lundblad <malu@pidgin.im>
parents:
24587
diff
changeset
|
2220 | 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
|
2221 | 0, 0, NULL, NULL, smiley); |
|
b2c89babe134
Remove that hack involving GtkIMHtmlSmileys
Marcus Lundblad <malu@pidgin.im>
parents:
24587
diff
changeset
|
2222 | } |
|
25888
d0fdd378a635
Remove trailing whitespace
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
2223 | |
| 12335 | 2224 | smiley->imhtml = imhtml; |
| 2225 | ||
| 4263 | 2226 | gtk_smiley_tree_insert (tree, smiley); |
|
25888
d0fdd378a635
Remove trailing whitespace
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
2227 | |
|
24588
b2c89babe134
Remove that hack involving GtkIMHtmlSmileys
Marcus Lundblad <malu@pidgin.im>
parents:
24587
diff
changeset
|
2228 | /* connect destroy signal for the imhtml */ |
|
25888
d0fdd378a635
Remove trailing whitespace
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
2229 | 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
|
2230 | smiley); |
| 4032 | 2231 | } |
| 2232 | ||
| 2233 | static gboolean | |
| 2234 | gtk_imhtml_is_smiley (GtkIMHtml *imhtml, | |
| 2235 | GSList *fonts, | |
| 2236 | const gchar *text, | |
| 2237 | gint *len) | |
| 2238 | { | |
| 2239 | GtkSmileyTree *tree; | |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
2240 | GtkIMHtmlFontDetail *font; |
| 4032 | 2241 | char *sml = NULL; |
| 2242 | ||
| 2243 | if (fonts) { | |
| 2244 | font = fonts->data; | |
| 2245 | sml = font->sml; | |
| 2246 | } | |
| 2247 | ||
| 9029 | 2248 | if (!sml) |
| 2249 | sml = imhtml->protocol_name; | |
| 2250 | ||
| 2251 | if (!sml || !(tree = g_hash_table_lookup(imhtml->smiley_data, sml))) | |
| 4032 | 2252 | tree = imhtml->default_smilies; |
| 9029 | 2253 | |
| 4032 | 2254 | if (tree == NULL) |
| 2255 | return FALSE; | |
| 7371 | 2256 | |
| 8505 | 2257 | *len = gtk_smiley_tree_lookup (tree, text); |
| 4032 | 2258 | return (*len > 0); |
| 2259 | } | |
| 2260 | ||
|
29724
1a6689974d33
Minor cleanup. Hopefully this code has a little less duplication and
Mark Doliner <markdoliner@pidgin.im>
parents:
29721
diff
changeset
|
2261 | 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
|
2262 | { |
| 4032 | 2263 | 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
|
2264 | gchar *pos; |
| 4032 | 2265 | |
| 2266 | 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
|
2267 | return NULL; |
| 4032 | 2268 | |
| 2269 | while (*x) { | |
|
29724
1a6689974d33
Minor cleanup. Hopefully this code has a little less duplication and
Mark Doliner <markdoliner@pidgin.im>
parents:
29721
diff
changeset
|
2270 | if (!t->values) |
|
1a6689974d33
Minor cleanup. Hopefully this code has a little less duplication and
Mark Doliner <markdoliner@pidgin.im>
parents:
29721
diff
changeset
|
2271 | return NULL; |
|
1a6689974d33
Minor cleanup. Hopefully this code has a little less duplication and
Mark Doliner <markdoliner@pidgin.im>
parents:
29721
diff
changeset
|
2272 | |
|
1a6689974d33
Minor cleanup. Hopefully this code has a little less duplication and
Mark Doliner <markdoliner@pidgin.im>
parents:
29721
diff
changeset
|
2273 | 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
|
2274 | if (!pos) |
|
1a6689974d33
Minor cleanup. Hopefully this code has a little less duplication and
Mark Doliner <markdoliner@pidgin.im>
parents:
29721
diff
changeset
|
2275 | return NULL; |
|
1a6689974d33
Minor cleanup. Hopefully this code has a little less duplication and
Mark Doliner <markdoliner@pidgin.im>
parents:
29721
diff
changeset
|
2276 | |
|
1a6689974d33
Minor cleanup. Hopefully this code has a little less duplication and
Mark Doliner <markdoliner@pidgin.im>
parents:
29721
diff
changeset
|
2277 | t = t->children[GPOINTER_TO_INT(pos) - GPOINTER_TO_INT(t->values->str)]; |
| 4032 | 2278 | x++; |
| 2279 | } | |
| 2280 | ||
| 10526 | 2281 | return t->image; |
| 2282 | } | |
| 2283 | ||
|
29724
1a6689974d33
Minor cleanup. Hopefully this code has a little less duplication and
Mark Doliner <markdoliner@pidgin.im>
parents:
29721
diff
changeset
|
2284 | GtkIMHtmlSmiley * |
|
1a6689974d33
Minor cleanup. Hopefully this code has a little less duplication and
Mark Doliner <markdoliner@pidgin.im>
parents:
29721
diff
changeset
|
2285 | 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
|
2286 | { |
|
1a6689974d33
Minor cleanup. Hopefully this code has a little less duplication and
Mark Doliner <markdoliner@pidgin.im>
parents:
29721
diff
changeset
|
2287 | GtkIMHtmlSmiley *ret; |
|
1a6689974d33
Minor cleanup. Hopefully this code has a little less duplication and
Mark Doliner <markdoliner@pidgin.im>
parents:
29721
diff
changeset
|
2288 | |
|
1a6689974d33
Minor cleanup. Hopefully this code has a little less duplication and
Mark Doliner <markdoliner@pidgin.im>
parents:
29721
diff
changeset
|
2289 | /* 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
|
2290 | if (sml != NULL) { |
|
1a6689974d33
Minor cleanup. Hopefully this code has a little less duplication and
Mark Doliner <markdoliner@pidgin.im>
parents:
29721
diff
changeset
|
2291 | 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
|
2292 | if (ret != NULL) |
|
1a6689974d33
Minor cleanup. Hopefully this code has a little less duplication and
Mark Doliner <markdoliner@pidgin.im>
parents:
29721
diff
changeset
|
2293 | return ret; |
|
1a6689974d33
Minor cleanup. Hopefully this code has a little less duplication and
Mark Doliner <markdoliner@pidgin.im>
parents:
29721
diff
changeset
|
2294 | } |
|
1a6689974d33
Minor cleanup. Hopefully this code has a little less duplication and
Mark Doliner <markdoliner@pidgin.im>
parents:
29721
diff
changeset
|
2295 | |
|
1a6689974d33
Minor cleanup. Hopefully this code has a little less duplication and
Mark Doliner <markdoliner@pidgin.im>
parents:
29721
diff
changeset
|
2296 | /* 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
|
2297 | 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
|
2298 | } |
|
1a6689974d33
Minor cleanup. Hopefully this code has a little less duplication and
Mark Doliner <markdoliner@pidgin.im>
parents:
29721
diff
changeset
|
2299 | |
|
11677
89c2ab8d2ebf
[gaim-migrate @ 13963]
Mark Doliner <markdoliner@pidgin.im>
parents:
11586
diff
changeset
|
2300 | 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
|
2301 | gtk_smiley_get_image(GtkIMHtmlSmiley *smiley) |
| 10526 | 2302 | { |
|
29724
1a6689974d33
Minor cleanup. Hopefully this code has a little less duplication and
Mark Doliner <markdoliner@pidgin.im>
parents:
29721
diff
changeset
|
2303 | if (!smiley->icon) { |
|
1a6689974d33
Minor cleanup. Hopefully this code has a little less duplication and
Mark Doliner <markdoliner@pidgin.im>
parents:
29721
diff
changeset
|
2304 | if (smiley->file) { |
|
1a6689974d33
Minor cleanup. Hopefully this code has a little less duplication and
Mark Doliner <markdoliner@pidgin.im>
parents:
29721
diff
changeset
|
2305 | 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
|
2306 | } 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
|
2307 | 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
|
2308 | if (smiley->icon) |
|
1a6689974d33
Minor cleanup. Hopefully this code has a little less duplication and
Mark Doliner <markdoliner@pidgin.im>
parents:
29721
diff
changeset
|
2309 | 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
|
2310 | } |
| 10526 | 2311 | } |
|
11572
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
2312 | |
| 10526 | 2313 | return smiley->icon; |
| 4032 | 2314 | } |
| 8890 | 2315 | |
|
25017
139df1ee9854
Fix the linkification error where bad things happened if you copy/pasted
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
25014
diff
changeset
|
2316 | #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
|
2317 | 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
|
2318 | 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
|
2319 | if (len) *len = strlen (x) + 1; \ |
| 3922 | 2320 | return TRUE; \ |
| 2321 | } \ | |
|
25017
139df1ee9854
Fix the linkification error where bad things happened if you copy/pasted
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
25014
diff
changeset
|
2322 | 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
|
2323 | } 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
|
2324 | |
|
139df1ee9854
Fix the linkification error where bad things happened if you copy/pasted
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
25014
diff
changeset
|
2325 | #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
|
2326 | if (!g_ascii_strncasecmp (string, x " ", strlen (x " "))) { \ |
| 3922 | 2327 | const gchar *c = string + strlen (x " "); \ |
| 2328 | gchar e = '"'; \ | |
| 2329 | gboolean quote = FALSE; \ | |
| 2330 | while (*c) { \ | |
| 2331 | if (*c == '"' || *c == '\'') { \ | |
| 2332 | if (quote && (*c == e)) \ | |
| 2333 | quote = !quote; \ | |
| 2334 | else if (!quote) { \ | |
| 2335 | quote = !quote; \ | |
| 2336 | e = *c; \ | |
| 2337 | } \ | |
| 2338 | } else if (!quote && (*c == '>')) \ | |
| 2339 | break; \ | |
| 2340 | c++; \ | |
| 2341 | } \ | |
| 2342 | 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
|
2343 | 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
|
2344 | if (len) *len = c - string + 1; \ |
| 3922 | 2345 | return TRUE; \ |
| 2346 | } \ | |
| 2347 | } \ | |
|
25017
139df1ee9854
Fix the linkification error where bad things happened if you copy/pasted
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
25014
diff
changeset
|
2348 | 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
|
2349 | } while (0) |
| 1428 | 2350 | |
| 2351 | ||
|
1472
ce83d12b7df9
[gaim-migrate @ 1482]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
1463
diff
changeset
|
2352 | static gboolean |
|
2856
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2353 | gtk_imhtml_is_tag (const gchar *string, |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2354 | gchar **tag, |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2355 | gint *len, |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2356 | gint *type) |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2357 | { |
| 8061 | 2358 | 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
|
2359 | 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
|
2360 | *type = 1; |
|
8118
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
2361 | |
| 8061 | 2362 | if (!(close = strchr (string, '>'))) |
|
2856
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2363 | return FALSE; |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2364 | |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2365 | VALID_TAG ("B"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2366 | VALID_TAG ("BOLD"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2367 | VALID_TAG ("/B"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2368 | VALID_TAG ("/BOLD"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2369 | VALID_TAG ("I"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2370 | VALID_TAG ("ITALIC"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2371 | VALID_TAG ("/I"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2372 | VALID_TAG ("/ITALIC"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2373 | VALID_TAG ("U"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2374 | VALID_TAG ("UNDERLINE"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2375 | VALID_TAG ("/U"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2376 | VALID_TAG ("/UNDERLINE"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2377 | VALID_TAG ("S"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2378 | VALID_TAG ("STRIKE"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2379 | VALID_TAG ("/S"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2380 | VALID_TAG ("/STRIKE"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2381 | VALID_TAG ("SUB"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2382 | VALID_TAG ("/SUB"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2383 | VALID_TAG ("SUP"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2384 | VALID_TAG ("/SUP"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2385 | VALID_TAG ("PRE"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2386 | VALID_TAG ("/PRE"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2387 | VALID_TAG ("TITLE"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2388 | VALID_TAG ("/TITLE"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2389 | VALID_TAG ("BR"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2390 | VALID_TAG ("HR"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2391 | VALID_TAG ("/FONT"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2392 | VALID_TAG ("/A"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2393 | VALID_TAG ("P"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2394 | VALID_TAG ("/P"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2395 | VALID_TAG ("H3"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2396 | VALID_TAG ("/H3"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2397 | VALID_TAG ("HTML"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2398 | VALID_TAG ("/HTML"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2399 | VALID_TAG ("BODY"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2400 | VALID_TAG ("/BODY"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2401 | VALID_TAG ("FONT"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2402 | VALID_TAG ("HEAD"); |
| 2993 | 2403 | VALID_TAG ("/HEAD"); |
| 2404 | VALID_TAG ("BINARY"); | |
| 2405 | VALID_TAG ("/BINARY"); | |
| 5093 | 2406 | |
|
2856
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2407 | VALID_OPT_TAG ("HR"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2408 | VALID_OPT_TAG ("FONT"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2409 | VALID_OPT_TAG ("BODY"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2410 | VALID_OPT_TAG ("A"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2411 | VALID_OPT_TAG ("IMG"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2412 | VALID_OPT_TAG ("P"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2413 | VALID_OPT_TAG ("H3"); |
| 5093 | 2414 | VALID_OPT_TAG ("HTML"); |
|
2856
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2415 | |
| 5101 | 2416 | VALID_TAG ("CITE"); |
| 2417 | VALID_TAG ("/CITE"); | |
| 2418 | VALID_TAG ("EM"); | |
| 2419 | VALID_TAG ("/EM"); | |
| 2420 | VALID_TAG ("STRONG"); | |
| 2421 | VALID_TAG ("/STRONG"); | |
| 2422 | ||
| 5104 | 2423 | VALID_OPT_TAG ("SPAN"); |
| 2424 | VALID_TAG ("/SPAN"); | |
| 5174 | 2425 | VALID_TAG ("BR/"); /* hack until gtkimhtml handles things better */ |
|
6982
12f08de92674
[gaim-migrate @ 7538]
Mark Doliner <markdoliner@pidgin.im>
parents:
6882
diff
changeset
|
2426 | VALID_TAG ("IMG"); |
| 8026 | 2427 | VALID_TAG("SPAN"); |
| 8061 | 2428 | VALID_OPT_TAG("BR"); |
| 7988 | 2429 | |
| 4793 | 2430 | if (!g_ascii_strncasecmp(string, "!--", strlen ("!--"))) { |
|
2954
fc07d855731d
[gaim-migrate @ 2967]
Christian Hammond <chipx86@chipx86.com>
parents:
2898
diff
changeset
|
2431 | gchar *e = strstr (string + strlen("!--"), "-->"); |
|
2856
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2432 | 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
|
2433 | 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
|
2434 | *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
|
2435 | 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
|
2436 | *tag = g_strndup (string + strlen ("!--"), *len - strlen ("!---->")); |
|
2856
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2437 | return TRUE; |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2438 | } |
|
8118
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
2439 | } |
|
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
2440 | |
|
25017
139df1ee9854
Fix the linkification error where bad things happened if you copy/pasted
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
25014
diff
changeset
|
2441 | 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
|
2442 | *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
|
2443 | 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
|
2444 | *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
|
2445 | 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
|
2446 | *tag = g_strndup(string, *len - 1); |
|
19733
ec657d978c5a
disapproval of revision 'f08436883bb16f29affdc63e9fd86ff278ed368f'
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
19732
diff
changeset
|
2447 | return TRUE; |
|
2856
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2448 | } |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2449 | |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2450 | static gchar* |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2451 | gtk_imhtml_get_html_opt (gchar *tag, |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2452 | const gchar *opt) |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2453 | { |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2454 | gchar *t = tag; |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2455 | gchar *e, *a; |
| 5177 | 2456 | gchar *val; |
| 2457 | gint len; | |
|
16143
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
2458 | const gchar *c; |
| 5177 | 2459 | GString *ret; |
|
2856
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2460 | |
| 4793 | 2461 | while (g_ascii_strncasecmp (t, opt, strlen (opt))) { |
|
2856
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2462 | gboolean quote = FALSE; |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2463 | if (*t == '\0') break; |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2464 | while (*t && !((*t == ' ') && !quote)) { |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2465 | if (*t == '\"') |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2466 | quote = ! quote; |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2467 | t++; |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2468 | } |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2469 | while (*t && (*t == ' ')) t++; |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2470 | } |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2471 | |
| 4793 | 2472 | if (!g_ascii_strncasecmp (t, opt, strlen (opt))) { |
|
2856
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2473 | t += strlen (opt); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2474 | } else { |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2475 | return NULL; |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2476 | } |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2477 | |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2478 | if ((*t == '\"') || (*t == '\'')) { |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2479 | e = a = ++t; |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2480 | while (*e && (*e != *(t - 1))) e++; |
| 2993 | 2481 | if (*e == '\0') { |
|
2856
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2482 | return NULL; |
| 5177 | 2483 | } else |
| 2484 | val = g_strndup(a, e - a); | |
|
2856
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2485 | } else { |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2486 | e = a = t; |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2487 | while (*e && !isspace ((gint) *e)) e++; |
| 5177 | 2488 | val = g_strndup(a, e - a); |
|
2856
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2489 | } |
| 5177 | 2490 | |
| 2491 | ret = g_string_new(""); | |
| 2492 | e = val; | |
| 2493 | while(*e) { | |
| 16144 | 2494 | if((c = purple_markup_unescape_entity(e, &len))) { |
| 7280 | 2495 | ret = g_string_append(ret, c); |
| 5177 | 2496 | e += len; |
| 2497 | } else { | |
|
19325
4ae1add93886
Thanks sadrul. Fixes #2277
Sean Egan <seanegan@pidgin.im>
parents:
19103
diff
changeset
|
2498 | gunichar uni = g_utf8_get_char(e); |
|
4ae1add93886
Thanks sadrul. Fixes #2277
Sean Egan <seanegan@pidgin.im>
parents:
19103
diff
changeset
|
2499 | ret = g_string_append_unichar(ret, uni); |
|
4ae1add93886
Thanks sadrul. Fixes #2277
Sean Egan <seanegan@pidgin.im>
parents:
19103
diff
changeset
|
2500 | e = g_utf8_next_char(e); |
| 5177 | 2501 | } |
| 2502 | } | |
| 2503 | ||
| 2504 | g_free(val); | |
|
8568
66907b37ce85
[gaim-migrate @ 9316]
Mark Doliner <markdoliner@pidgin.im>
parents:
8566
diff
changeset
|
2505 | |
|
66907b37ce85
[gaim-migrate @ 9316]
Mark Doliner <markdoliner@pidgin.im>
parents:
8566
diff
changeset
|
2506 | return g_string_free(ret, FALSE); |
|
2856
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2507 | } |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2508 | |
| 8334 | 2509 | /* returns if the beginning of the text is a protocol. If it is the protocol, returns the length so |
| 2510 | the caller knows how long the protocol string is. */ | |
|
12412
8abe3226695e
[gaim-migrate @ 14719]
Richard Laager <rlaager@pidgin.im>
parents:
12335
diff
changeset
|
2511 | static int gtk_imhtml_is_protocol(const char *text) |
| 8334 | 2512 | { |
|
25013
956b2f650d31
Detect duplication registrations by substring.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
25011
diff
changeset
|
2513 | 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
|
2514 | return proto ? proto->length : 0; |
| 8334 | 2515 | } |
| 2516 | ||
|
28940
e0f3781f6397
Fix scrolling bug for very busy chat rooms.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28935
diff
changeset
|
2517 | 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
|
2518 | |
| 8677 | 2519 | /* |
| 15884 | 2520 | <KingAnt> marv: The two IM image functions in oscar are purple_odc_send_im and purple_odc_incoming |
| 8677 | 2521 | |
| 2522 | ||
| 2523 | [19:58] <Robot101> marv: images go into the imgstore, a refcounted... well.. hash. :) | |
| 2524 | [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
|
2525 | [19:59] Ro0tSiEgE robert42 RobFlynn Robot101 ross22 roz |
| 33661 | 2526 | [20:00] <KingAnt> marv: Where the ID is the what is returned when you add the image to the imgstore using purple_imgstore_new |
| 8677 | 2527 | [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? |
| 2528 | [20:00] <KingAnt> marv: Right | |
| 2529 | [20:00] <marv> alright | |
| 2530 | ||
| 2531 | Here's my plan with IMImages. make gtk_imhtml_[append|insert]_text_with_images instead just | |
| 2532 | gtkimhtml_[append|insert]_text (hrm maybe it should be called html instead of text), add a | |
| 15884 | 2533 | function for purple to register for look up images, i.e. gtk_imhtml_set_get_img_fnc, so that |
| 8677 | 2534 | images can be looked up like that, instead of passing a GSList of them. |
| 2535 | */ | |
| 2536 | ||
| 2537 | void gtk_imhtml_append_text_with_images (GtkIMHtml *imhtml, | |
| 2538 | const gchar *text, | |
| 2539 | GtkIMHtmlOptions options, | |
| 2540 | GSList *unused) | |
| 1428 | 2541 | { |
| 8677 | 2542 | 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
|
2543 | int ins_offset = 0, sel_offset = 0; |
| 8677 | 2544 | gboolean fixins = FALSE, fixsel = FALSE; |
| 2545 | ||
| 2546 | g_return_if_fail (imhtml != NULL); | |
| 2547 | g_return_if_fail (GTK_IS_IMHTML (imhtml)); | |
| 2548 | g_return_if_fail (text != NULL); | |
| 2549 | ||
| 2550 | ||
| 2551 | gtk_text_buffer_get_end_iter(imhtml->text_buffer, &iter); | |
| 2552 | gtk_text_buffer_get_iter_at_mark(imhtml->text_buffer, &ins, gtk_text_buffer_get_insert(imhtml->text_buffer)); | |
| 2553 | if (gtk_text_iter_equal(&iter, &ins) && gtk_text_buffer_get_selection_bounds(imhtml->text_buffer, NULL, NULL)) { | |
| 2554 | fixins = TRUE; | |
| 2555 | ins_offset = gtk_text_iter_get_offset(&ins); | |
| 2556 | } | |
| 2557 | ||
| 2558 | gtk_text_buffer_get_iter_at_mark(imhtml->text_buffer, &sel, gtk_text_buffer_get_selection_bound(imhtml->text_buffer)); | |
| 2559 | if (gtk_text_iter_equal(&iter, &sel) && gtk_text_buffer_get_selection_bounds(imhtml->text_buffer, NULL, NULL)) { | |
| 2560 | fixsel = TRUE; | |
| 2561 | sel_offset = gtk_text_iter_get_offset(&sel); | |
| 2562 | } | |
| 2563 | ||
|
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
|
2564 | 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
|
2565 | 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
|
2566 | 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
|
2567 | |
|
e1f64090d32e
Do not show tooltips for <HR> or <IMG>s in gtkimhtml. Fixes #5480.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22772
diff
changeset
|
2568 | 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
|
2569 | 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
|
2570 | |
|
e1f64090d32e
Do not show tooltips for <HR> or <IMG>s in gtkimhtml. Fixes #5480.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22772
diff
changeset
|
2571 | 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
|
2572 | 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
|
2573 | /* 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
|
2574 | * 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
|
2575 | * 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
|
2576 | * so do not scroll. */ |
|
e0f3781f6397
Fix scrolling bug for very busy chat rooms.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28935
diff
changeset
|
2577 | if (imhtml->scroll_time) |
|
e0f3781f6397
Fix scrolling bug for very busy chat rooms.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28935
diff
changeset
|
2578 | smooth_scroll_cb(imhtml); |
|
e0f3781f6397
Fix scrolling bug for very busy chat rooms.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28935
diff
changeset
|
2579 | else |
|
e0f3781f6397
Fix scrolling bug for very busy chat rooms.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28935
diff
changeset
|
2580 | 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
|
2581 | } |
| 8677 | 2582 | } |
| 2583 | ||
| 2584 | gtk_imhtml_insert_html_at_iter(imhtml, text, options, &iter); | |
| 2585 | ||
| 2586 | if (fixins) { | |
| 2587 | gtk_text_buffer_get_iter_at_offset(imhtml->text_buffer, &ins, ins_offset); | |
| 2588 | gtk_text_buffer_move_mark(imhtml->text_buffer, gtk_text_buffer_get_insert(imhtml->text_buffer), &ins); | |
| 2589 | } | |
| 2590 | ||
| 2591 | if (fixsel) { | |
| 2592 | gtk_text_buffer_get_iter_at_offset(imhtml->text_buffer, &sel, sel_offset); | |
| 2593 | gtk_text_buffer_move_mark(imhtml->text_buffer, gtk_text_buffer_get_selection_bound(imhtml->text_buffer), &sel); | |
| 2594 | } | |
| 2595 | ||
| 2596 | if (!(options & GTK_IMHTML_NO_SCROLL)) { | |
| 12553 | 2597 | gtk_imhtml_scroll_to_end(imhtml, (options & GTK_IMHTML_USE_SMOOTHSCROLLING)); |
| 8677 | 2598 | } |
| 2599 | } | |
| 2600 | ||
| 11006 | 2601 | #define MAX_SCROLL_TIME 0.4 /* seconds */ |
| 2602 | #define SCROLL_DELAY 33 /* milliseconds */ | |
| 2603 | ||
| 2604 | /* | |
| 2605 | * Smoothly scroll a GtkIMHtml. | |
| 2606 | * | |
| 2607 | * @return TRUE if the window needs to be scrolled further, FALSE if we're at the bottom. | |
| 2608 | */ | |
|
28940
e0f3781f6397
Fix scrolling bug for very busy chat rooms.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28935
diff
changeset
|
2609 | static gboolean smooth_scroll_cb(gpointer data) |
| 10798 | 2610 | { |
| 2611 | GtkIMHtml *imhtml = data; | |
|
32394
f883709bdba4
compiles using GTK+ 3 from git, beware it does not yet run, in fact it crashes...
Marcus Lundblad <malu@pidgin.im>
parents:
31207
diff
changeset
|
2612 | GtkAdjustment *adj = gtk_text_view_get_vadjustment(GTK_TEXT_VIEW(imhtml)); |
|
f883709bdba4
compiles using GTK+ 3 from git, beware it does not yet run, in fact it crashes...
Marcus Lundblad <malu@pidgin.im>
parents:
31207
diff
changeset
|
2613 | gdouble max_val = gtk_adjustment_get_upper(adj) - gtk_adjustment_get_page_size(adj); |
|
19055
43f5771c45f4
Eliminate some unnecessary scrolling activity.
Daniel Atallah <datallah@pidgin.im>
parents:
18985
diff
changeset
|
2614 | gdouble scroll_val = gtk_adjustment_get_value(adj) + ((max_val - gtk_adjustment_get_value(adj)) / 3); |
| 11006 | 2615 | |
| 2616 | g_return_val_if_fail(imhtml->scroll_time != NULL, FALSE); | |
| 2617 | ||
|
19055
43f5771c45f4
Eliminate some unnecessary scrolling activity.
Daniel Atallah <datallah@pidgin.im>
parents:
18985
diff
changeset
|
2618 | if (g_timer_elapsed(imhtml->scroll_time, NULL) > MAX_SCROLL_TIME || scroll_val >= max_val) { |
| 11006 | 2619 | /* time's up. jump to the end and kill the timer */ |
| 2620 | gtk_adjustment_set_value(adj, max_val); | |
| 10798 | 2621 | g_timer_destroy(imhtml->scroll_time); |
| 2622 | imhtml->scroll_time = NULL; | |
|
28940
e0f3781f6397
Fix scrolling bug for very busy chat rooms.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28935
diff
changeset
|
2623 | 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
|
2624 | imhtml->scroll_src = 0; |
| 10798 | 2625 | return FALSE; |
| 11006 | 2626 | } |
| 2627 | ||
| 2628 | /* scroll by 1/3rd the remaining distance */ | |
|
19055
43f5771c45f4
Eliminate some unnecessary scrolling activity.
Daniel Atallah <datallah@pidgin.im>
parents:
18985
diff
changeset
|
2629 | gtk_adjustment_set_value(adj, scroll_val); |
| 11006 | 2630 | return TRUE; |
| 10798 | 2631 | } |
| 2632 | ||
| 12553 | 2633 | static gboolean scroll_idle_cb(gpointer data) |
| 2634 | { | |
| 2635 | GtkIMHtml *imhtml = data; | |
|
32394
f883709bdba4
compiles using GTK+ 3 from git, beware it does not yet run, in fact it crashes...
Marcus Lundblad <malu@pidgin.im>
parents:
31207
diff
changeset
|
2636 | GtkAdjustment *adj = gtk_text_view_get_vadjustment(GTK_TEXT_VIEW(imhtml)); |
|
32413
00ad036bdf3d
Fix some indenting.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32412
diff
changeset
|
2637 | if (adj) { |
|
32394
f883709bdba4
compiles using GTK+ 3 from git, beware it does not yet run, in fact it crashes...
Marcus Lundblad <malu@pidgin.im>
parents:
31207
diff
changeset
|
2638 | gtk_adjustment_set_value(adj, gtk_adjustment_get_upper(adj) - |
|
32413
00ad036bdf3d
Fix some indenting.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32412
diff
changeset
|
2639 | gtk_adjustment_get_page_size(adj)); |
| 12553 | 2640 | } |
| 2641 | imhtml->scroll_src = 0; | |
| 2642 | return FALSE; | |
| 2643 | } | |
| 2644 | ||
| 2645 | void gtk_imhtml_scroll_to_end(GtkIMHtml *imhtml, gboolean smooth) | |
| 8729 | 2646 | { |
| 10798 | 2647 | if (imhtml->scroll_time) |
| 2648 | g_timer_destroy(imhtml->scroll_time); | |
| 2649 | if (imhtml->scroll_src) | |
| 2650 | g_source_remove(imhtml->scroll_src); | |
| 12553 | 2651 | if(smooth) { |
| 2652 | 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
|
2653 | imhtml->scroll_src = g_timeout_add_full(G_PRIORITY_LOW, SCROLL_DELAY, smooth_scroll_cb, imhtml, NULL); |
| 12553 | 2654 | } else { |
| 2655 | imhtml->scroll_time = NULL; | |
| 2656 | imhtml->scroll_src = g_idle_add_full(G_PRIORITY_LOW, scroll_idle_cb, imhtml, NULL); | |
| 2657 | } | |
| 8729 | 2658 | } |
| 2659 | ||
|
24509
afdf30801940
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <datallah@pidgin.im>
parents:
24392
diff
changeset
|
2660 | /* 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
|
2661 | * 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
|
2662 | static gchar* |
|
afdf30801940
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <datallah@pidgin.im>
parents:
24392
diff
changeset
|
2663 | 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
|
2664 | { |
|
afdf30801940
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <datallah@pidgin.im>
parents:
24392
diff
changeset
|
2665 | 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
|
2666 | |
|
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
|
2667 | 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
|
2668 | 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
|
2669 | int count = 0; |
|
afdf30801940
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <datallah@pidgin.im>
parents:
24392
diff
changeset
|
2670 | 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
|
2671 | |
|
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
|
2672 | 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
|
2673 | 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
|
2674 | 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
|
2675 | /* 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
|
2676 | 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
|
2677 | 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
|
2678 | } |
|
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
|
2679 | 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
|
2680 | |
|
24509
afdf30801940
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <datallah@pidgin.im>
parents:
24392
diff
changeset
|
2681 | while (count < 3) { |
|
afdf30801940
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <datallah@pidgin.im>
parents:
24392
diff
changeset
|
2682 | /* 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
|
2683 | 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
|
2684 | tmp++; |
|
afdf30801940
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <datallah@pidgin.im>
parents:
24392
diff
changeset
|
2685 | |
|
afdf30801940
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <datallah@pidgin.im>
parents:
24392
diff
changeset
|
2686 | /* 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
|
2687 | 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
|
2688 | 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
|
2689 | tmp++; |
|
24509
afdf30801940
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <datallah@pidgin.im>
parents:
24392
diff
changeset
|
2690 | 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
|
2691 | tmp++; |
|
afdf30801940
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <datallah@pidgin.im>
parents:
24392
diff
changeset
|
2692 | |
|
afdf30801940
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <datallah@pidgin.im>
parents:
24392
diff
changeset
|
2693 | 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
|
2694 | char prev = *tmp; |
|
afdf30801940
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <datallah@pidgin.im>
parents:
24392
diff
changeset
|
2695 | *tmp = '\0'; |
|
afdf30801940
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <datallah@pidgin.im>
parents:
24392
diff
changeset
|
2696 | 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
|
2697 | *tmp = prev; |
|
afdf30801940
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <datallah@pidgin.im>
parents:
24392
diff
changeset
|
2698 | |
|
afdf30801940
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <datallah@pidgin.im>
parents:
24392
diff
changeset
|
2699 | /* deal with % */ |
|
afdf30801940
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <datallah@pidgin.im>
parents:
24392
diff
changeset
|
2700 | 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
|
2701 | tmp++; |
|
afdf30801940
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <datallah@pidgin.im>
parents:
24392
diff
changeset
|
2702 | if (*tmp == '%') { |
|
afdf30801940
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <datallah@pidgin.im>
parents:
24392
diff
changeset
|
2703 | 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
|
2704 | tmp++; |
|
afdf30801940
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <datallah@pidgin.im>
parents:
24392
diff
changeset
|
2705 | } |
|
afdf30801940
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <datallah@pidgin.im>
parents:
24392
diff
changeset
|
2706 | } else { |
|
afdf30801940
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <datallah@pidgin.im>
parents:
24392
diff
changeset
|
2707 | 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
|
2708 | return in_color; |
|
afdf30801940
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <datallah@pidgin.im>
parents:
24392
diff
changeset
|
2709 | } |
|
afdf30801940
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <datallah@pidgin.im>
parents:
24392
diff
changeset
|
2710 | |
|
afdf30801940
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <datallah@pidgin.im>
parents:
24392
diff
changeset
|
2711 | 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
|
2712 | rgbval[count] = 255; |
|
afdf30801940
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <datallah@pidgin.im>
parents:
24392
diff
changeset
|
2713 | } 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
|
2714 | rgbval[count] = 0; |
|
afdf30801940
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <datallah@pidgin.im>
parents:
24392
diff
changeset
|
2715 | } |
|
afdf30801940
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <datallah@pidgin.im>
parents:
24392
diff
changeset
|
2716 | |
|
afdf30801940
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <datallah@pidgin.im>
parents:
24392
diff
changeset
|
2717 | 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
|
2718 | tmp++; |
|
afdf30801940
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <datallah@pidgin.im>
parents:
24392
diff
changeset
|
2719 | if (*tmp == ',') |
|
afdf30801940
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <datallah@pidgin.im>
parents:
24392
diff
changeset
|
2720 | tmp++; |
|
afdf30801940
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <datallah@pidgin.im>
parents:
24392
diff
changeset
|
2721 | |
|
afdf30801940
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <datallah@pidgin.im>
parents:
24392
diff
changeset
|
2722 | count++; |
|
afdf30801940
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <datallah@pidgin.im>
parents:
24392
diff
changeset
|
2723 | } |
|
25888
d0fdd378a635
Remove trailing whitespace
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
2724 | |
|
24509
afdf30801940
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <datallah@pidgin.im>
parents:
24392
diff
changeset
|
2725 | 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
|
2726 | 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
|
2727 | } |
|
afdf30801940
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <datallah@pidgin.im>
parents:
24392
diff
changeset
|
2728 | |
|
afdf30801940
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <datallah@pidgin.im>
parents:
24392
diff
changeset
|
2729 | return in_color; |
|
afdf30801940
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <datallah@pidgin.im>
parents:
24392
diff
changeset
|
2730 | } |
|
afdf30801940
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <datallah@pidgin.im>
parents:
24392
diff
changeset
|
2731 | |
| 8677 | 2732 | void gtk_imhtml_insert_html_at_iter(GtkIMHtml *imhtml, |
| 2733 | const gchar *text, | |
| 2734 | GtkIMHtmlOptions options, | |
| 2735 | GtkTextIter *iter) | |
| 2736 | { | |
| 8061 | 2737 | GdkRectangle rect; |
|
2856
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2738 | gint pos = 0; |
| 3922 | 2739 | gchar *ws; |
|
2856
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2740 | gchar *tag; |
| 3922 | 2741 | gchar *bg = NULL; |
|
6982
12f08de92674
[gaim-migrate @ 7538]
Mark Doliner <markdoliner@pidgin.im>
parents:
6882
diff
changeset
|
2742 | gint len; |
| 4032 | 2743 | gint tlen, smilelen, wpos=0; |
|
2856
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2744 | gint type; |
| 3922 | 2745 | const gchar *c; |
|
16143
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
2746 | const gchar *amp; |
| 8334 | 2747 | gint len_protocol; |
| 15379 | 2748 | |
| 1428 | 2749 | guint bold = 0, |
| 2750 | italics = 0, | |
| 2751 | underline = 0, | |
| 2752 | strike = 0, | |
| 2753 | sub = 0, | |
| 2754 | sup = 0, | |
|
1691
c8bd41036372
[gaim-migrate @ 1701]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
1647
diff
changeset
|
2755 | title = 0, |
| 8061 | 2756 | pre = 0; |
| 1428 | 2757 | |
| 10217 | 2758 | gboolean br = FALSE; |
|
16143
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
2759 | gboolean align_right = FALSE; |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
2760 | gboolean rtl_direction = FALSE; |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
2761 | gint align_line = 0; |
| 15420 | 2762 | |
| 3922 | 2763 | GSList *fonts = NULL; |
| 8506 | 2764 | GObject *object; |
| 8061 | 2765 | GtkIMHtmlScalable *scalable = NULL; |
| 8677 | 2766 | |
| 2767 | g_return_if_fail (imhtml != NULL); | |
| 2768 | g_return_if_fail (GTK_IS_IMHTML (imhtml)); | |
| 2769 | g_return_if_fail (text != NULL); | |
| 3922 | 2770 | c = text; |
|
6982
12f08de92674
[gaim-migrate @ 7538]
Mark Doliner <markdoliner@pidgin.im>
parents:
6882
diff
changeset
|
2771 | len = strlen(text); |
| 3922 | 2772 | 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
|
2773 | ws[0] = '\0'; |
| 1428 | 2774 | |
|
29378
a783b23a05da
Fix CVE-2010-0423, a denial of service attack due to the parsing
Mark Doliner <markdoliner@pidgin.im>
parents:
29371
diff
changeset
|
2775 | 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
|
2776 | |
|
22834
1394e7efb818
Smiley insertions can be undone with this fix. References #5577. But redo
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22810
diff
changeset
|
2777 | gtk_text_buffer_begin_user_action(imhtml->text_buffer); |
|
2856
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2778 | while (pos < len) { |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2779 | if (*c == '<' && gtk_imhtml_is_tag (c + 1, &tag, &tlen, &type)) { |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2780 | c++; |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2781 | pos++; |
| 8061 | 2782 | ws[wpos] = '\0'; |
| 10217 | 2783 | br = FALSE; |
| 8061 | 2784 | switch (type) |
| 3922 | 2785 | { |
| 2786 | case 1: /* B */ | |
| 2787 | case 2: /* BOLD */ | |
| 5101 | 2788 | case 54: /* STRONG */ |
|
11485
fe334b13d1d0
[gaim-migrate @ 13727]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11385
diff
changeset
|
2789 | if (!(options & GTK_IMHTML_NO_FORMATTING)) { |
|
fe334b13d1d0
[gaim-migrate @ 13727]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11385
diff
changeset
|
2790 | gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos); |
|
fe334b13d1d0
[gaim-migrate @ 13727]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11385
diff
changeset
|
2791 | |
|
fe334b13d1d0
[gaim-migrate @ 13727]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11385
diff
changeset
|
2792 | if ((bold == 0) && (imhtml->format_functions & GTK_IMHTML_BOLD)) |
|
fe334b13d1d0
[gaim-migrate @ 13727]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11385
diff
changeset
|
2793 | gtk_imhtml_toggle_bold(imhtml); |
|
fe334b13d1d0
[gaim-migrate @ 13727]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11385
diff
changeset
|
2794 | bold++; |
|
fe334b13d1d0
[gaim-migrate @ 13727]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11385
diff
changeset
|
2795 | ws[0] = '\0'; wpos = 0; |
|
fe334b13d1d0
[gaim-migrate @ 13727]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11385
diff
changeset
|
2796 | } |
| 3922 | 2797 | break; |
| 2798 | case 3: /* /B */ | |
| 2799 | case 4: /* /BOLD */ | |
| 5101 | 2800 | case 55: /* /STRONG */ |
|
11485
fe334b13d1d0
[gaim-migrate @ 13727]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11385
diff
changeset
|
2801 | if (!(options & GTK_IMHTML_NO_FORMATTING)) { |
|
fe334b13d1d0
[gaim-migrate @ 13727]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11385
diff
changeset
|
2802 | gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos); |
|
fe334b13d1d0
[gaim-migrate @ 13727]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11385
diff
changeset
|
2803 | ws[0] = '\0'; wpos = 0; |
|
fe334b13d1d0
[gaim-migrate @ 13727]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11385
diff
changeset
|
2804 | |
|
14010
a47143a57c82
[gaim-migrate @ 16489]
Gary Kramlich <grim@reaperworld.com>
parents:
13552
diff
changeset
|
2805 | if (bold) { |
|
11485
fe334b13d1d0
[gaim-migrate @ 13727]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11385
diff
changeset
|
2806 | bold--; |
|
14010
a47143a57c82
[gaim-migrate @ 16489]
Gary Kramlich <grim@reaperworld.com>
parents:
13552
diff
changeset
|
2807 | if ((bold == 0) && (imhtml->format_functions & GTK_IMHTML_BOLD) && !imhtml->wbfo) |
|
a47143a57c82
[gaim-migrate @ 16489]
Gary Kramlich <grim@reaperworld.com>
parents:
13552
diff
changeset
|
2808 | gtk_imhtml_toggle_bold(imhtml); |
|
a47143a57c82
[gaim-migrate @ 16489]
Gary Kramlich <grim@reaperworld.com>
parents:
13552
diff
changeset
|
2809 | } |
|
11485
fe334b13d1d0
[gaim-migrate @ 13727]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11385
diff
changeset
|
2810 | } |
| 3922 | 2811 | break; |
| 2812 | case 5: /* I */ | |
| 2813 | case 6: /* ITALIC */ | |
| 5101 | 2814 | case 52: /* EM */ |
|
11485
fe334b13d1d0
[gaim-migrate @ 13727]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11385
diff
changeset
|
2815 | if (!(options & GTK_IMHTML_NO_FORMATTING)) { |
|
fe334b13d1d0
[gaim-migrate @ 13727]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11385
diff
changeset
|
2816 | gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos); |
|
fe334b13d1d0
[gaim-migrate @ 13727]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11385
diff
changeset
|
2817 | ws[0] = '\0'; wpos = 0; |
|
fe334b13d1d0
[gaim-migrate @ 13727]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11385
diff
changeset
|
2818 | if ((italics == 0) && (imhtml->format_functions & GTK_IMHTML_ITALIC)) |
|
fe334b13d1d0
[gaim-migrate @ 13727]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11385
diff
changeset
|
2819 | gtk_imhtml_toggle_italic(imhtml); |
|
fe334b13d1d0
[gaim-migrate @ 13727]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11385
diff
changeset
|
2820 | italics++; |
|
fe334b13d1d0
[gaim-migrate @ 13727]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11385
diff
changeset
|
2821 | } |
| 3922 | 2822 | break; |
| 2823 | case 7: /* /I */ | |
| 2824 | case 8: /* /ITALIC */ | |
| 5101 | 2825 | case 53: /* /EM */ |
|
11485
fe334b13d1d0
[gaim-migrate @ 13727]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11385
diff
changeset
|
2826 | if (!(options & GTK_IMHTML_NO_FORMATTING)) { |
|
fe334b13d1d0
[gaim-migrate @ 13727]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11385
diff
changeset
|
2827 | gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos); |
|
fe334b13d1d0
[gaim-migrate @ 13727]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11385
diff
changeset
|
2828 | ws[0] = '\0'; wpos = 0; |
|
14010
a47143a57c82
[gaim-migrate @ 16489]
Gary Kramlich <grim@reaperworld.com>
parents:
13552
diff
changeset
|
2829 | if (italics) { |
|
11485
fe334b13d1d0
[gaim-migrate @ 13727]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11385
diff
changeset
|
2830 | italics--; |
|
14010
a47143a57c82
[gaim-migrate @ 16489]
Gary Kramlich <grim@reaperworld.com>
parents:
13552
diff
changeset
|
2831 | if ((italics == 0) && (imhtml->format_functions & GTK_IMHTML_ITALIC) && !imhtml->wbfo) |
|
a47143a57c82
[gaim-migrate @ 16489]
Gary Kramlich <grim@reaperworld.com>
parents:
13552
diff
changeset
|
2832 | gtk_imhtml_toggle_italic(imhtml); |
|
a47143a57c82
[gaim-migrate @ 16489]
Gary Kramlich <grim@reaperworld.com>
parents:
13552
diff
changeset
|
2833 | } |
|
11485
fe334b13d1d0
[gaim-migrate @ 13727]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11385
diff
changeset
|
2834 | } |
| 3922 | 2835 | break; |
| 2836 | case 9: /* U */ | |
| 2837 | case 10: /* UNDERLINE */ | |
|
11485
fe334b13d1d0
[gaim-migrate @ 13727]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11385
diff
changeset
|
2838 | if (!(options & GTK_IMHTML_NO_FORMATTING)) { |
|
fe334b13d1d0
[gaim-migrate @ 13727]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11385
diff
changeset
|
2839 | gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos); |
|
fe334b13d1d0
[gaim-migrate @ 13727]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11385
diff
changeset
|
2840 | ws[0] = '\0'; wpos = 0; |
|
fe334b13d1d0
[gaim-migrate @ 13727]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11385
diff
changeset
|
2841 | if ((underline == 0) && (imhtml->format_functions & GTK_IMHTML_UNDERLINE)) |
|
fe334b13d1d0
[gaim-migrate @ 13727]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11385
diff
changeset
|
2842 | gtk_imhtml_toggle_underline(imhtml); |
|
fe334b13d1d0
[gaim-migrate @ 13727]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11385
diff
changeset
|
2843 | underline++; |
|
fe334b13d1d0
[gaim-migrate @ 13727]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11385
diff
changeset
|
2844 | } |
| 3922 | 2845 | break; |
| 2846 | case 11: /* /U */ | |
| 2847 | case 12: /* /UNDERLINE */ | |
|
11485
fe334b13d1d0
[gaim-migrate @ 13727]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11385
diff
changeset
|
2848 | if (!(options & GTK_IMHTML_NO_FORMATTING)) { |
|
fe334b13d1d0
[gaim-migrate @ 13727]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11385
diff
changeset
|
2849 | gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos); |
|
fe334b13d1d0
[gaim-migrate @ 13727]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11385
diff
changeset
|
2850 | ws[0] = '\0'; wpos = 0; |
|
14010
a47143a57c82
[gaim-migrate @ 16489]
Gary Kramlich <grim@reaperworld.com>
parents:
13552
diff
changeset
|
2851 | if (underline) { |
|
11485
fe334b13d1d0
[gaim-migrate @ 13727]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11385
diff
changeset
|
2852 | underline--; |
|
14010
a47143a57c82
[gaim-migrate @ 16489]
Gary Kramlich <grim@reaperworld.com>
parents:
13552
diff
changeset
|
2853 | if ((underline == 0) && (imhtml->format_functions & GTK_IMHTML_UNDERLINE) && !imhtml->wbfo) |
|
a47143a57c82
[gaim-migrate @ 16489]
Gary Kramlich <grim@reaperworld.com>
parents:
13552
diff
changeset
|
2854 | gtk_imhtml_toggle_underline(imhtml); |
|
a47143a57c82
[gaim-migrate @ 16489]
Gary Kramlich <grim@reaperworld.com>
parents:
13552
diff
changeset
|
2855 | } |
|
11485
fe334b13d1d0
[gaim-migrate @ 13727]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11385
diff
changeset
|
2856 | } |
| 3922 | 2857 | break; |
| 2858 | case 13: /* S */ | |
| 2859 | case 14: /* STRIKE */ | |
| 9924 | 2860 | gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos); |
| 2861 | ws[0] = '\0'; wpos = 0; | |
| 2862 | if ((strike == 0) && (imhtml->format_functions & GTK_IMHTML_STRIKE)) | |
| 2863 | gtk_imhtml_toggle_strike(imhtml); | |
| 3922 | 2864 | strike++; |
| 2865 | break; | |
| 2866 | case 15: /* /S */ | |
| 2867 | case 16: /* /STRIKE */ | |
| 9924 | 2868 | gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos); |
| 2869 | ws[0] = '\0'; wpos = 0; | |
| 3922 | 2870 | if (strike) |
| 2871 | strike--; | |
| 9924 | 2872 | if ((strike == 0) && (imhtml->format_functions & GTK_IMHTML_STRIKE) && !imhtml->wbfo) |
| 2873 | gtk_imhtml_toggle_strike(imhtml); | |
| 3922 | 2874 | break; |
| 2875 | case 17: /* SUB */ | |
| 8677 | 2876 | /* FIXME: reimpliment this */ |
| 3922 | 2877 | sub++; |
| 2878 | break; | |
| 2879 | case 18: /* /SUB */ | |
| 8677 | 2880 | /* FIXME: reimpliment this */ |
| 3922 | 2881 | if (sub) |
| 2882 | sub--; | |
| 2883 | break; | |
| 2884 | case 19: /* SUP */ | |
| 8677 | 2885 | /* FIXME: reimplement this */ |
| 3922 | 2886 | sup++; |
|
2856
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2887 | break; |
| 3922 | 2888 | case 20: /* /SUP */ |
| 8677 | 2889 | /* FIXME: reimplement this */ |
| 3922 | 2890 | if (sup) |
| 2891 | sup--; | |
| 2892 | break; | |
| 2893 | case 21: /* PRE */ | |
| 8677 | 2894 | /* FIXME: reimplement this */ |
| 3922 | 2895 | pre++; |
| 2896 | break; | |
| 2897 | case 22: /* /PRE */ | |
| 8677 | 2898 | /* FIXME: reimplement this */ |
| 3922 | 2899 | if (pre) |
| 2900 | pre--; | |
| 2901 | break; | |
| 2902 | case 23: /* TITLE */ | |
| 8677 | 2903 | /* FIXME: what was this supposed to do anyway? */ |
| 3922 | 2904 | title++; |
| 2905 | break; | |
| 2906 | case 24: /* /TITLE */ | |
| 8677 | 2907 | /* FIXME: make this undo whatever 23 was supposed to do */ |
| 3922 | 2908 | if (title) { |
| 2909 | if (options & GTK_IMHTML_NO_TITLE) { | |
| 2910 | wpos = 0; | |
| 2911 | ws [wpos] = '\0'; | |
| 2912 | } | |
| 2913 | title--; | |
|
2856
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2914 | } |
| 3922 | 2915 | break; |
| 2916 | case 25: /* BR */ | |
| 5174 | 2917 | case 58: /* BR/ */ |
| 8061 | 2918 | case 61: /* BR (opt) */ |
| 3922 | 2919 | ws[wpos] = '\n'; |
| 2920 | wpos++; | |
| 10217 | 2921 | br = TRUE; |
|
6982
12f08de92674
[gaim-migrate @ 7538]
Mark Doliner <markdoliner@pidgin.im>
parents:
6882
diff
changeset
|
2922 | break; |
| 3922 | 2923 | case 26: /* HR */ |
| 2924 | case 42: /* HR (opt) */ | |
| 8726 | 2925 | { |
| 2926 | int minus; | |
|
11224
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
2927 | struct scalable_data *sd = g_new(struct scalable_data, 1); |
| 8726 | 2928 | |
| 3922 | 2929 | ws[wpos++] = '\n'; |
| 8677 | 2930 | gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos); |
| 2931 | ||
|
11224
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
2932 | sd->scalable = scalable = gtk_imhtml_hr_new(); |
|
11233
28c0f184a2d4
[gaim-migrate @ 13373]
Daniel Atallah <datallah@pidgin.im>
parents:
11224
diff
changeset
|
2933 | sd->mark = gtk_text_buffer_create_mark(imhtml->text_buffer, NULL, iter, TRUE); |
| 8061 | 2934 | gtk_text_view_get_visible_rect(GTK_TEXT_VIEW(imhtml), &rect); |
| 8677 | 2935 | scalable->add_to(scalable, imhtml, iter); |
| 8726 | 2936 | minus = gtk_text_view_get_left_margin(GTK_TEXT_VIEW(imhtml)) + |
| 2937 | gtk_text_view_get_right_margin(GTK_TEXT_VIEW(imhtml)); | |
| 2938 | scalable->scale(scalable, rect.width - minus, rect.height); | |
|
11224
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
2939 | imhtml->scalables = g_list_append(imhtml->scalables, sd); |
| 8061 | 2940 | ws[0] = '\0'; wpos = 0; |
| 7942 | 2941 | ws[wpos++] = '\n'; |
| 8061 | 2942 | |
| 3922 | 2943 | break; |
| 8726 | 2944 | } |
| 3922 | 2945 | case 27: /* /FONT */ |
| 8677 | 2946 | if (fonts && !imhtml->wbfo) { |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
2947 | GtkIMHtmlFontDetail *font = fonts->data; |
| 8677 | 2948 | gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos); |
| 8061 | 2949 | ws[0] = '\0'; wpos = 0; |
|
8177
33b3a01c6318
[gaim-migrate @ 8891]
Mark Doliner <markdoliner@pidgin.im>
parents:
8149
diff
changeset
|
2950 | /* NEW_BIT (NEW_TEXT_BIT); */ |
| 8677 | 2951 | |
| 8698 | 2952 | if (font->face && (imhtml->format_functions & GTK_IMHTML_FACE)) { |
| 8061 | 2953 | gtk_imhtml_toggle_fontface(imhtml, NULL); |
| 2954 | } | |
|
14821
c91127e2b784
[gaim-migrate @ 17516]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14741
diff
changeset
|
2955 | g_free (font->face); |
| 8698 | 2956 | if (font->fore && (imhtml->format_functions & GTK_IMHTML_FORECOLOR)) { |
| 8061 | 2957 | gtk_imhtml_toggle_forecolor(imhtml, NULL); |
| 2958 | } | |
|
14821
c91127e2b784
[gaim-migrate @ 17516]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14741
diff
changeset
|
2959 | g_free (font->fore); |
| 8698 | 2960 | if (font->back && (imhtml->format_functions & GTK_IMHTML_BACKCOLOR)) { |
| 8061 | 2961 | gtk_imhtml_toggle_backcolor(imhtml, NULL); |
| 2962 | } | |
|
14821
c91127e2b784
[gaim-migrate @ 17516]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14741
diff
changeset
|
2963 | g_free (font->back); |
|
c91127e2b784
[gaim-migrate @ 17516]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14741
diff
changeset
|
2964 | g_free (font->sml); |
| 8309 | 2965 | |
| 8698 | 2966 | if ((font->size != 3) && (imhtml->format_functions & (GTK_IMHTML_GROW|GTK_IMHTML_SHRINK))) |
| 8309 | 2967 | gtk_imhtml_font_set_size(imhtml, 3); |
| 2968 | ||
| 10761 | 2969 | fonts = g_slist_remove (fonts, font); |
| 9245 | 2970 | g_free(font); |
| 2971 | ||
| 8309 | 2972 | if (fonts) { |
| 2973 | GtkIMHtmlFontDetail *font = fonts->data; | |
| 8677 | 2974 | |
| 8698 | 2975 | if (font->face && (imhtml->format_functions & GTK_IMHTML_FACE)) |
| 8309 | 2976 | gtk_imhtml_toggle_fontface(imhtml, font->face); |
| 8698 | 2977 | if (font->fore && (imhtml->format_functions & GTK_IMHTML_FORECOLOR)) |
| 8309 | 2978 | gtk_imhtml_toggle_forecolor(imhtml, font->fore); |
| 8698 | 2979 | if (font->back && (imhtml->format_functions & GTK_IMHTML_BACKCOLOR)) |
| 8309 | 2980 | gtk_imhtml_toggle_backcolor(imhtml, font->back); |
| 8698 | 2981 | if ((font->size != 3) && (imhtml->format_functions & (GTK_IMHTML_GROW|GTK_IMHTML_SHRINK))) |
| 8309 | 2982 | gtk_imhtml_font_set_size(imhtml, font->size); |
| 2983 | } | |
| 3922 | 2984 | } |
| 8309 | 2985 | break; |
| 3922 | 2986 | case 28: /* /A */ |
| 8677 | 2987 | gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos); |
| 2988 | gtk_imhtml_toggle_link(imhtml, NULL); | |
| 2989 | ws[0] = '\0'; wpos = 0; | |
| 8061 | 2990 | break; |
|
8118
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
2991 | |
| 3922 | 2992 | case 29: /* P */ |
| 2993 | case 30: /* /P */ | |
| 2994 | case 31: /* H3 */ | |
| 2995 | case 32: /* /H3 */ | |
| 2996 | case 33: /* HTML */ | |
| 2997 | case 34: /* /HTML */ | |
| 2998 | case 35: /* BODY */ | |
| 10776 | 2999 | break; |
| 3922 | 3000 | case 36: /* /BODY */ |
| 10786 | 3001 | gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos); |
| 3002 | ws[0] = '\0'; wpos = 0; | |
| 10776 | 3003 | gtk_imhtml_toggle_background(imhtml, NULL); |
| 3004 | break; | |
| 3922 | 3005 | case 37: /* FONT */ |
| 3006 | case 38: /* HEAD */ | |
| 3007 | case 39: /* /HEAD */ | |
|
6982
12f08de92674
[gaim-migrate @ 7538]
Mark Doliner <markdoliner@pidgin.im>
parents:
6882
diff
changeset
|
3008 | case 40: /* BINARY */ |
|
12f08de92674
[gaim-migrate @ 7538]
Mark Doliner <markdoliner@pidgin.im>
parents:
6882
diff
changeset
|
3009 | case 41: /* /BINARY */ |
| 3922 | 3010 | break; |
| 3011 | case 43: /* FONT (opt) */ | |
| 3012 | { | |
| 4032 | 3013 | gchar *color, *back, *face, *size, *sml; |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
3014 | GtkIMHtmlFontDetail *font, *oldfont = NULL; |
| 3922 | 3015 | color = gtk_imhtml_get_html_opt (tag, "COLOR="); |
| 3016 | back = gtk_imhtml_get_html_opt (tag, "BACK="); | |
| 3017 | face = gtk_imhtml_get_html_opt (tag, "FACE="); | |
| 3018 | size = gtk_imhtml_get_html_opt (tag, "SIZE="); | |
| 4032 | 3019 | sml = gtk_imhtml_get_html_opt (tag, "SML="); |
| 3020 | if (!(color || back || face || size || sml)) | |
| 3922 | 3021 | break; |
| 8061 | 3022 | |
| 8677 | 3023 | gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos); |
| 8061 | 3024 | ws[0] = '\0'; wpos = 0; |
| 3025 | ||
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
3026 | font = g_new0 (GtkIMHtmlFontDetail, 1); |
| 3922 | 3027 | if (fonts) |
| 3028 | oldfont = fonts->data; | |
|
2856
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
3029 | |
| 8677 | 3030 | if (color && !(options & GTK_IMHTML_NO_COLOURS) && (imhtml->format_functions & GTK_IMHTML_FORECOLOR)) { |
| 3922 | 3031 | font->fore = color; |
| 8061 | 3032 | gtk_imhtml_toggle_forecolor(imhtml, font->fore); |
|
14821
c91127e2b784
[gaim-migrate @ 17516]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14741
diff
changeset
|
3033 | } else |
|
c91127e2b784
[gaim-migrate @ 17516]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14741
diff
changeset
|
3034 | g_free(color); |
| 8677 | 3035 | |
| 3036 | if (back && !(options & GTK_IMHTML_NO_COLOURS) && (imhtml->format_functions & GTK_IMHTML_BACKCOLOR)) { | |
| 3922 | 3037 | font->back = back; |
| 8061 | 3038 | gtk_imhtml_toggle_backcolor(imhtml, font->back); |
|
14821
c91127e2b784
[gaim-migrate @ 17516]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14741
diff
changeset
|
3039 | } else |
|
c91127e2b784
[gaim-migrate @ 17516]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14741
diff
changeset
|
3040 | g_free(back); |
| 8677 | 3041 | |
| 3042 | if (face && !(options & GTK_IMHTML_NO_FONTS) && (imhtml->format_functions & GTK_IMHTML_FACE)) { | |
| 3922 | 3043 | font->face = face; |
| 8061 | 3044 | gtk_imhtml_toggle_fontface(imhtml, font->face); |
|
14821
c91127e2b784
[gaim-migrate @ 17516]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14741
diff
changeset
|
3045 | } else |
|
c91127e2b784
[gaim-migrate @ 17516]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14741
diff
changeset
|
3046 | g_free(face); |
| 4032 | 3047 | |
| 3048 | if (sml) | |
| 3049 | 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
|
3050 | 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
|
3051 | 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
|
3052 | 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
|
3053 | 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
|
3054 | } |
| 4032 | 3055 | |
| 8677 | 3056 | if (size && !(options & GTK_IMHTML_NO_SIZES) && (imhtml->format_functions & (GTK_IMHTML_GROW|GTK_IMHTML_SHRINK))) { |
| 3922 | 3057 | if (*size == '+') { |
| 3058 | sscanf (size + 1, "%hd", &font->size); | |
| 3059 | font->size += 3; | |
| 3060 | } else if (*size == '-') { | |
| 3061 | sscanf (size + 1, "%hd", &font->size); | |
| 3062 | font->size = MAX (0, 3 - font->size); | |
| 3063 | } else if (isdigit (*size)) { | |
| 3064 | sscanf (size, "%hd", &font->size); | |
|
14821
c91127e2b784
[gaim-migrate @ 17516]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14741
diff
changeset
|
3065 | } |
|
6042
e329fe962c9a
[gaim-migrate @ 6492]
Mark Doliner <markdoliner@pidgin.im>
parents:
5967
diff
changeset
|
3066 | if (font->size > 100) |
|
e329fe962c9a
[gaim-migrate @ 6492]
Mark Doliner <markdoliner@pidgin.im>
parents:
5967
diff
changeset
|
3067 | font->size = 100; |
| 3922 | 3068 | } else if (oldfont) |
| 3069 | font->size = oldfont->size; | |
| 8309 | 3070 | else |
| 3071 | 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
|
3072 | if ((imhtml->format_functions & (GTK_IMHTML_GROW|GTK_IMHTML_SHRINK)) && (font->size != 3 || (oldfont && oldfont->size == 3))) |
| 8698 | 3073 | gtk_imhtml_font_set_size(imhtml, font->size); |
| 3922 | 3074 | g_free(size); |
| 3075 | fonts = g_slist_prepend (fonts, font); | |
| 3076 | } | |
| 3077 | break; | |
| 3078 | case 44: /* BODY (opt) */ | |
| 3079 | if (!(options & GTK_IMHTML_NO_COLOURS)) { | |
| 3080 | char *bgcolor = gtk_imhtml_get_html_opt (tag, "BGCOLOR="); | |
| 8677 | 3081 | if (bgcolor && (imhtml->format_functions & GTK_IMHTML_BACKCOLOR)) { |
| 3082 | gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos); | |
| 8061 | 3083 | ws[0] = '\0'; wpos = 0; |
|
8177
33b3a01c6318
[gaim-migrate @ 8891]
Mark Doliner <markdoliner@pidgin.im>
parents:
8149
diff
changeset
|
3084 | /* NEW_BIT(NEW_TEXT_BIT); */ |
|
14097
0c340861ab79
[gaim-migrate @ 16638]
Mark Doliner <markdoliner@pidgin.im>
parents:
14010
diff
changeset
|
3085 | g_free(bg); |
| 3922 | 3086 | bg = bgcolor; |
| 10776 | 3087 | gtk_imhtml_toggle_background(imhtml, bg); |
|
14821
c91127e2b784
[gaim-migrate @ 17516]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14741
diff
changeset
|
3088 | } else |
|
c91127e2b784
[gaim-migrate @ 17516]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14741
diff
changeset
|
3089 | g_free(bgcolor); |
| 1428 | 3090 | } |
|
2856
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
3091 | break; |
| 3922 | 3092 | case 45: /* A (opt) */ |
| 3093 | { | |
| 3094 | gchar *href = gtk_imhtml_get_html_opt (tag, "HREF="); | |
| 8677 | 3095 | if (href && (imhtml->format_functions & GTK_IMHTML_LINK)) { |
| 3096 | gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos); | |
| 8061 | 3097 | ws[0] = '\0'; wpos = 0; |
| 8677 | 3098 | gtk_imhtml_toggle_link(imhtml, href); |
| 3922 | 3099 | } |
|
14097
0c340861ab79
[gaim-migrate @ 16638]
Mark Doliner <markdoliner@pidgin.im>
parents:
14010
diff
changeset
|
3100 | g_free(href); |
| 2993 | 3101 | } |
| 3922 | 3102 | break; |
| 4895 | 3103 | case 46: /* IMG (opt) */ |
|
6982
12f08de92674
[gaim-migrate @ 7538]
Mark Doliner <markdoliner@pidgin.im>
parents:
6882
diff
changeset
|
3104 | case 59: /* IMG */ |
| 4895 | 3105 | { |
|
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
|
3106 | char *id; |
| 8962 | 3107 | |
| 3108 | gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos); | |
| 3109 | ws[0] = '\0'; wpos = 0; | |
| 4895 | 3110 | |
| 8677 | 3111 | if (!(imhtml->format_functions & GTK_IMHTML_IMAGE)) |
| 3112 | break; | |
| 3113 | ||
| 8962 | 3114 | 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
|
3115 | 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
|
3116 | 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
|
3117 | 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
|
3118 | } else { |
|
3d884bc7b99e
Transform id-less <img> tags to links using src and alt attributes.
Dmitry Petroff <dmitry.petroff@gmail.com>
parents:
27259
diff
changeset
|
3119 | 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
|
3120 | 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
|
3121 | 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
|
3122 | 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
|
3123 | 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
|
3124 | 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
|
3125 | 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
|
3126 | } |
|
3d884bc7b99e
Transform id-less <img> tags to links using src and alt attributes.
Dmitry Petroff <dmitry.petroff@gmail.com>
parents:
27259
diff
changeset
|
3127 | 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
|
3128 | 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
|
3129 | } |
| 8962 | 3130 | break; |
| 4895 | 3131 | } |
| 3922 | 3132 | case 47: /* P (opt) */ |
| 3133 | case 48: /* H3 (opt) */ | |
| 5093 | 3134 | case 49: /* HTML (opt) */ |
| 5101 | 3135 | case 50: /* CITE */ |
| 3136 | case 51: /* /CITE */ | |
| 8026 | 3137 | case 56: /* SPAN (opt) */ |
|
8118
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
3138 | /* Inline CSS Support - Douglas Thrift |
|
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
3139 | * |
|
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
3140 | * color |
| 8686 | 3141 | * background |
|
8118
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
3142 | * font-family |
|
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
3143 | * font-size |
| 8686 | 3144 | * text-decoration: underline |
| 14395 | 3145 | * font-weight: bold |
|
16143
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
3146 | * direction: rtl |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
3147 | * text-align: right |
| 10483 | 3148 | * |
| 3149 | * TODO: | |
| 3150 | * background-color | |
| 3151 | * font-style | |
|
8118
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
3152 | */ |
|
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
3153 | { |
|
16143
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
3154 | gchar *style, *color, *background, *family, *size, *direction, *alignment; |
| 14395 | 3155 | gchar *textdec, *weight; |
|
8118
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
3156 | GtkIMHtmlFontDetail *font, *oldfont = NULL; |
|
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
3157 | style = gtk_imhtml_get_html_opt (tag, "style="); |
|
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
3158 | |
|
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
3159 | if (!style) break; |
|
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
3160 | |
|
16143
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
3161 | color = purple_markup_get_css_property (style, "color"); |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
3162 | background = purple_markup_get_css_property (style, "background"); |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
3163 | 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
|
3164 | 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
|
3165 | 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
|
3166 | 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
|
3167 | direction = purple_markup_get_css_property (style, "direction"); |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
3168 | 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
|
3169 | |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
3170 | |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
3171 | if (!(color || family || size || background || textdec || weight || direction || alignment)) { |
| 8120 | 3172 | g_free(style); |
| 3173 | break; | |
| 3174 | } | |
|
8118
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
3175 | |
| 8677 | 3176 | |
| 3177 | gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos); | |
|
8118
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
3178 | ws[0] = '\0'; wpos = 0; |
|
8177
33b3a01c6318
[gaim-migrate @ 8891]
Mark Doliner <markdoliner@pidgin.im>
parents:
8149
diff
changeset
|
3179 | /* NEW_BIT (NEW_TEXT_BIT); */ |
|
8118
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
3180 | |
|
16143
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
3181 | /* 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
|
3182 | 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
|
3183 | rtl_direction = TRUE; |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
3184 | /* insert RLE character to set direction */ |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
3185 | ws[wpos++] = 0xE2; |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
3186 | ws[wpos++] = 0x80; |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
3187 | ws[wpos++] = 0xAB; |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
3188 | ws[wpos] = '\0'; |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
3189 | 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
|
3190 | ws[0] = '\0'; wpos = 0; |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
3191 | } |
| 16144 | 3192 | g_free(direction); |
| 3193 | ||
|
18552
810a338ef085
Use the glib strcasecmp functions everywhere, as we've had reports of
Richard Laager <rlaager@pidgin.im>
parents:
18543
diff
changeset
|
3194 | 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
|
3195 | align_right = TRUE; |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
3196 | align_line = gtk_text_iter_get_line(iter); |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
3197 | } |
| 16144 | 3198 | g_free(alignment); |
|
16143
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
3199 | |
|
8118
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
3200 | font = g_new0 (GtkIMHtmlFontDetail, 1); |
|
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
3201 | if (fonts) |
|
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
3202 | oldfont = fonts->data; |
|
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
3203 | |
|
14821
c91127e2b784
[gaim-migrate @ 17516]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14741
diff
changeset
|
3204 | 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
|
3205 | font->fore = parse_css_color(color); |
| 8686 | 3206 | gtk_imhtml_toggle_forecolor(imhtml, font->fore); |
|
14821
c91127e2b784
[gaim-migrate @ 17516]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14741
diff
changeset
|
3207 | } else { |
|
c91127e2b784
[gaim-migrate @ 17516]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14741
diff
changeset
|
3208 | if (oldfont && oldfont->fore) |
|
c91127e2b784
[gaim-migrate @ 17516]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14741
diff
changeset
|
3209 | font->fore = g_strdup(oldfont->fore); |
|
c91127e2b784
[gaim-migrate @ 17516]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14741
diff
changeset
|
3210 | g_free(color); |
| 8686 | 3211 | } |
|
14821
c91127e2b784
[gaim-migrate @ 17516]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14741
diff
changeset
|
3212 | |
|
c91127e2b784
[gaim-migrate @ 17516]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14741
diff
changeset
|
3213 | 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
|
3214 | font->back = parse_css_color(background); |
| 8686 | 3215 | gtk_imhtml_toggle_backcolor(imhtml, font->back); |
|
14821
c91127e2b784
[gaim-migrate @ 17516]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14741
diff
changeset
|
3216 | } else { |
|
c91127e2b784
[gaim-migrate @ 17516]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14741
diff
changeset
|
3217 | if (oldfont && oldfont->back) |
|
c91127e2b784
[gaim-migrate @ 17516]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14741
diff
changeset
|
3218 | font->back = g_strdup(oldfont->back); |
|
c91127e2b784
[gaim-migrate @ 17516]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14741
diff
changeset
|
3219 | g_free(background); |
| 8686 | 3220 | } |
|
14821
c91127e2b784
[gaim-migrate @ 17516]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14741
diff
changeset
|
3221 | |
|
c91127e2b784
[gaim-migrate @ 17516]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14741
diff
changeset
|
3222 | 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
|
3223 | font->face = family; |
| 8686 | 3224 | gtk_imhtml_toggle_fontface(imhtml, font->face); |
|
14821
c91127e2b784
[gaim-migrate @ 17516]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14741
diff
changeset
|
3225 | } else { |
|
c91127e2b784
[gaim-migrate @ 17516]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14741
diff
changeset
|
3226 | if (oldfont && oldfont->face) |
|
c91127e2b784
[gaim-migrate @ 17516]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14741
diff
changeset
|
3227 | font->face = g_strdup(oldfont->face); |
|
c91127e2b784
[gaim-migrate @ 17516]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14741
diff
changeset
|
3228 | g_free(family); |
| 8686 | 3229 | } |
|
8118
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
3230 | if (font->face && (atoi(font->face) > 100)) { |
| 8677 | 3231 | /* WTF is this? */ |
|
11572
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
3232 | /* 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
|
3233 | * remember bad things happening if the font size was |
|
9696
9d62e1ec5977
[gaim-migrate @ 10555]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9636
diff
changeset
|
3234 | * 2 billion */ |
|
8118
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
3235 | g_free(font->face); |
|
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
3236 | font->face = g_strdup("100"); |
|
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
3237 | } |
|
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
3238 | |
|
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
3239 | if (oldfont && oldfont->sml) |
|
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
3240 | font->sml = g_strdup(oldfont->sml); |
|
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
3241 | |
| 8677 | 3242 | if (size && !(options & GTK_IMHTML_NO_SIZES) && (imhtml->format_functions & (GTK_IMHTML_SHRINK|GTK_IMHTML_GROW))) { |
| 8686 | 3243 | if (g_ascii_strcasecmp(size, "xx-small") == 0) |
| 3244 | font->size = 1; | |
| 3245 | else if (g_ascii_strcasecmp(size, "smaller") == 0 | |
| 3246 | || g_ascii_strcasecmp(size, "x-small") == 0) | |
|
8118
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
3247 | 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
|
3248 | 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
|
3249 | font->size = 3; |
|
82d682722b68
Change our font mapping in gtkimhtml to match the suggested values
Mark Doliner <markdoliner@pidgin.im>
parents:
25168
diff
changeset
|
3250 | 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
|
3251 | || g_ascii_strcasecmp(size, "larger") == 0) |
|
8118
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
3252 | 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
|
3253 | else if (g_ascii_strcasecmp(size, "x-large") == 0) |
| 8686 | 3254 | 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
|
3255 | else if (g_ascii_strcasecmp(size, "xx-large") == 0) |
| 8686 | 3256 | 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
|
3257 | |
|
4f508dba5218
Change the way we handle <span style='font-size: whatever;'> tags slightly.
Mark Doliner <markdoliner@pidgin.im>
parents:
24588
diff
changeset
|
3258 | /* |
|
4f508dba5218
Change the way we handle <span style='font-size: whatever;'> tags slightly.
Mark Doliner <markdoliner@pidgin.im>
parents:
24588
diff
changeset
|
3259 | * 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
|
3260 | * 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
|
3261 | * 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
|
3262 | * 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
|
3263 | */ |
|
4f508dba5218
Change the way we handle <span style='font-size: whatever;'> tags slightly.
Mark Doliner <markdoliner@pidgin.im>
parents:
24588
diff
changeset
|
3264 | 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
|
3265 | gtk_imhtml_font_set_size(imhtml, font->size); |
| 8686 | 3266 | } |
| 3267 | else if (oldfont) | |
| 3268 | { | |
| 3269 | font->size = oldfont->size; | |
| 3270 | } | |
| 3271 | ||
| 3272 | if (oldfont) | |
| 3273 | { | |
| 3274 | font->underline = oldfont->underline; | |
| 3275 | } | |
| 3276 | if (textdec && font->underline != 1 | |
| 9025 | 3277 | && 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
|
3278 | && (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
|
3279 | && !(options & GTK_IMHTML_NO_FORMATTING)) |
| 8686 | 3280 | { |
| 3281 | gtk_imhtml_toggle_underline(imhtml); | |
| 3282 | font->underline = 1; | |
| 21425 | 3283 | } |
|
31310
7835bac46b07
Add support for rendering strikethrough when received as in-line CSS,
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
31294
diff
changeset
|
3284 | |
|
7835bac46b07
Add support for rendering strikethrough when received as in-line CSS,
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
31294
diff
changeset
|
3285 | if (oldfont) |
|
7835bac46b07
Add support for rendering strikethrough when received as in-line CSS,
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
31294
diff
changeset
|
3286 | { |
|
7835bac46b07
Add support for rendering strikethrough when received as in-line CSS,
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
31294
diff
changeset
|
3287 | 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
|
3288 | } |
|
7835bac46b07
Add support for rendering strikethrough when received as in-line CSS,
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
31294
diff
changeset
|
3289 | 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
|
3290 | && 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
|
3291 | && (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
|
3292 | && !(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
|
3293 | { |
|
7835bac46b07
Add support for rendering strikethrough when received as in-line CSS,
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
31294
diff
changeset
|
3294 | 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
|
3295 | font->strike = 1; |
|
7835bac46b07
Add support for rendering strikethrough when received as in-line CSS,
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
31294
diff
changeset
|
3296 | } |
| 21425 | 3297 | g_free(textdec); |
|
8118
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
3298 | |
| 14395 | 3299 | if (oldfont) |
| 3300 | { | |
| 3301 | font->bold = oldfont->bold; | |
| 3302 | } | |
| 3303 | if (weight) | |
| 3304 | { | |
| 3305 | if(!g_ascii_strcasecmp(weight, "normal")) { | |
| 3306 | font->bold = 0; | |
| 3307 | } else if(!g_ascii_strcasecmp(weight, "bold")) { | |
| 3308 | font->bold = 1; | |
| 3309 | } else if(!g_ascii_strcasecmp(weight, "bolder")) { | |
| 3310 | font->bold++; | |
| 3311 | } else if(!g_ascii_strcasecmp(weight, "lighter")) { | |
| 3312 | if(font->bold > 0) | |
| 3313 | font->bold--; | |
| 3314 | } else { | |
| 3315 | int num = atoi(weight); | |
| 3316 | if(num >= 700) | |
| 3317 | font->bold = 1; | |
| 3318 | else | |
| 3319 | font->bold = 0; | |
| 3320 | } | |
|
17088
1ecea6e2fd97
Ignore bold, underline and other formatting type things in SPAN tags if
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17009
diff
changeset
|
3321 | if (((font->bold && oldfont && !oldfont->bold) || (oldfont && oldfont->bold && !font->bold) || (font->bold && !oldfont)) && !(options & GTK_IMHTML_NO_FORMATTING)) |
| 14395 | 3322 | { |
| 3323 | gtk_imhtml_toggle_bold(imhtml); | |
| 3324 | } | |
|
14821
c91127e2b784
[gaim-migrate @ 17516]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14741
diff
changeset
|
3325 | g_free(weight); |
| 14395 | 3326 | } |
| 3327 | ||
|
8118
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
3328 | g_free(style); |
|
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
3329 | g_free(size); |
|
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
3330 | fonts = g_slist_prepend (fonts, font); |
|
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
3331 | } |
|
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
3332 | break; |
| 5104 | 3333 | case 57: /* /SPAN */ |
|
8118
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
3334 | /* Inline CSS Support - Douglas Thrift */ |
| 8677 | 3335 | if (fonts && !imhtml->wbfo) { |
| 8686 | 3336 | GtkIMHtmlFontDetail *oldfont = NULL; |
|
8118
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
3337 | GtkIMHtmlFontDetail *font = fonts->data; |
| 8677 | 3338 | gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos); |
|
8118
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
3339 | ws[0] = '\0'; wpos = 0; |
|
8177
33b3a01c6318
[gaim-migrate @ 8891]
Mark Doliner <markdoliner@pidgin.im>
parents:
8149
diff
changeset
|
3340 | /* NEW_BIT (NEW_TEXT_BIT); */ |
|
8118
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
3341 | fonts = g_slist_remove (fonts, font); |
| 8692 | 3342 | if (fonts) |
| 3343 | oldfont = fonts->data; | |
| 3344 | ||
| 3345 | if (!oldfont) { | |
| 3346 | 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
|
3347 | if (font->underline && !(options & GTK_IMHTML_NO_FORMATTING)) |
| 8692 | 3348 | 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
|
3349 | 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
|
3350 | 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
|
3351 | if (font->bold && !(options & GTK_IMHTML_NO_FORMATTING)) |
| 14395 | 3352 | 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
|
3353 | 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
|
3354 | 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
|
3355 | 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
|
3356 | 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
|
3357 | 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
|
3358 | gtk_imhtml_toggle_backcolor(imhtml, NULL); |
| 8686 | 3359 | } |
| 8692 | 3360 | else |
| 8686 | 3361 | { |
| 8692 | 3362 | |
|
31310
7835bac46b07
Add support for rendering strikethrough when received as in-line CSS,
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
31294
diff
changeset
|
3363 | if ((font->size != oldfont->size) && !(options & GTK_IMHTML_NO_SIZES)) |
| 8692 | 3364 | gtk_imhtml_font_set_size(imhtml, oldfont->size); |
| 3365 | ||
|
17088
1ecea6e2fd97
Ignore bold, underline and other formatting type things in SPAN tags if
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17009
diff
changeset
|
3366 | if ((font->underline != oldfont->underline) && !(options & GTK_IMHTML_NO_FORMATTING)) |
| 8692 | 3367 | gtk_imhtml_toggle_underline(imhtml); |
| 3368 | ||
|
31310
7835bac46b07
Add support for rendering strikethrough when received as in-line CSS,
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
31294
diff
changeset
|
3369 | 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
|
3370 | 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
|
3371 | |
|
17088
1ecea6e2fd97
Ignore bold, underline and other formatting type things in SPAN tags if
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17009
diff
changeset
|
3372 | 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
|
3373 | gtk_imhtml_toggle_bold(imhtml); |
| 14395 | 3374 | |
|
17088
1ecea6e2fd97
Ignore bold, underline and other formatting type things in SPAN tags if
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17009
diff
changeset
|
3375 | if (font->face && (!oldfont->face || strcmp(font->face, oldfont->face) != 0) && !(options & GTK_IMHTML_NO_FONTS)) |
| 8692 | 3376 | gtk_imhtml_toggle_fontface(imhtml, oldfont->face); |
| 3377 | ||
|
17088
1ecea6e2fd97
Ignore bold, underline and other formatting type things in SPAN tags if
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17009
diff
changeset
|
3378 | if (font->fore && (!oldfont->fore || strcmp(font->fore, oldfont->fore) != 0) && !(options & GTK_IMHTML_NO_COLOURS)) |
| 8692 | 3379 | gtk_imhtml_toggle_forecolor(imhtml, oldfont->fore); |
| 3380 | ||
|
17088
1ecea6e2fd97
Ignore bold, underline and other formatting type things in SPAN tags if
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17009
diff
changeset
|
3381 | 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
|
3382 | gtk_imhtml_toggle_backcolor(imhtml, oldfont->back); |
| 8686 | 3383 | } |
| 8692 | 3384 | |
| 3385 | g_free (font->face); | |
| 3386 | g_free (font->fore); | |
| 3387 | g_free (font->back); | |
| 3388 | g_free (font->sml); | |
| 3389 | ||
|
8118
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
3390 | g_free (font); |
|
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
3391 | } |
|
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
3392 | break; |
| 8026 | 3393 | case 60: /* SPAN */ |
| 2993 | 3394 | break; |
| 8061 | 3395 | case 62: /* comment */ |
|
8177
33b3a01c6318
[gaim-migrate @ 8891]
Mark Doliner <markdoliner@pidgin.im>
parents:
8149
diff
changeset
|
3396 | /* NEW_BIT (NEW_TEXT_BIT); */ |
| 8317 | 3397 | ws[wpos] = '\0'; |
| 9465 | 3398 | |
| 8677 | 3399 | gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos); |
| 3400 | ||
|
22486
e77232ab761f
Disable invisible text things, if someone can conclusively prove this is
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22276
diff
changeset
|
3401 | #if FALSE && GTK_CHECK_VERSION(2,10,10) |
|
22211
7f3cecdb079c
disapproval of revision '2c96f5a301400781ce5fbf144ffdbae44f895281'
Sean Egan <seanegan@pidgin.im>
parents:
22210
diff
changeset
|
3402 | wpos = g_snprintf (ws, len, "%s", tag); |
|
7f3cecdb079c
disapproval of revision '2c96f5a301400781ce5fbf144ffdbae44f895281'
Sean Egan <seanegan@pidgin.im>
parents:
22210
diff
changeset
|
3403 | 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
|
3404 | #else |
|
10815
b1ca28de65d3
[gaim-migrate @ 12470]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10814
diff
changeset
|
3405 | if (imhtml->show_comments && !(options & GTK_IMHTML_NO_COMMENTS)) { |
|
6124
322206d79652
[gaim-migrate @ 6598]
Mark Doliner <markdoliner@pidgin.im>
parents:
6066
diff
changeset
|
3406 | 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
|
3407 | 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
|
3408 | } |
|
22211
7f3cecdb079c
disapproval of revision '2c96f5a301400781ce5fbf144ffdbae44f895281'
Sean Egan <seanegan@pidgin.im>
parents:
22210
diff
changeset
|
3409 | #endif |
|
10815
b1ca28de65d3
[gaim-migrate @ 12470]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10814
diff
changeset
|
3410 | ws[0] = '\0'; wpos = 0; |
|
b1ca28de65d3
[gaim-migrate @ 12470]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10814
diff
changeset
|
3411 | |
|
8177
33b3a01c6318
[gaim-migrate @ 8891]
Mark Doliner <markdoliner@pidgin.im>
parents:
8149
diff
changeset
|
3412 | /* NEW_BIT (NEW_COMMENT_BIT); */ |
| 3922 | 3413 | break; |
| 3414 | default: | |
| 6882 | 3415 | break; |
| 2993 | 3416 | } |
|
2856
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
3417 | c += tlen; |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
3418 | pos += tlen; |
|
13138
4d3bd039da3e
[gaim-migrate @ 15499]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13137
diff
changeset
|
3419 | 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
|
3420 | } 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
|
3421 | !(options & GTK_IMHTML_NO_SMILEY) && |
|
15331
a8ef18791524
[gaim-migrate @ 18059]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15111
diff
changeset
|
3422 | gtk_imhtml_is_smiley(imhtml, fonts, c, &smilelen)) { |
| 8473 | 3423 | GtkIMHtmlFontDetail *fd; |
| 3424 | 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
|
3425 | |
|
b27c242d1288
Fix #3930 by correctly detecting when we're no longer immediately following a br.
Daniel Atallah <datallah@pidgin.im>
parents:
21425
diff
changeset
|
3426 | 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
|
3427 | |
| 8473 | 3428 | if (fonts) { |
| 3429 | fd = fonts->data; | |
| 3430 | sml = fd->sml; | |
| 3431 | } | |
| 9029 | 3432 | if (!sml) |
| 3433 | sml = imhtml->protocol_name; | |
| 3434 | ||
| 8677 | 3435 | gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos); |
| 8505 | 3436 | wpos = g_snprintf (ws, smilelen + 1, "%s", c); |
| 8473 | 3437 | |
| 8677 | 3438 | gtk_imhtml_insert_smiley_at_iter(imhtml, sml, ws, iter); |
| 8473 | 3439 | |
| 8505 | 3440 | c += smilelen; |
| 3441 | pos += smilelen; | |
| 8473 | 3442 | wpos = 0; |
| 3443 | ws[0] = 0; | |
| 16144 | 3444 | } 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
|
3445 | br = FALSE; |
| 7280 | 3446 | while(*amp) { |
| 3447 | ws [wpos++] = *amp++; | |
| 3448 | } | |
|
2856
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
3449 | c += tlen; |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
3450 | pos += tlen; |
| 1428 | 3451 | } else if (*c == '\n') { |
| 3452 | if (!(options & GTK_IMHTML_NO_NEWLINE)) { | |
| 3922 | 3453 | ws[wpos] = '\n'; |
| 3454 | wpos++; | |
| 8677 | 3455 | 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
|
3456 | ws[0] = '\0'; wpos = 0; |
|
8177
33b3a01c6318
[gaim-migrate @ 8891]
Mark Doliner <markdoliner@pidgin.im>
parents:
8149
diff
changeset
|
3457 | /* NEW_BIT (NEW_TEXT_BIT); */ |
| 10217 | 3458 | } else if (!br) { /* Don't insert a space immediately after an HTML break */ |
| 9621 | 3459 | /* A newline is defined by HTML as whitespace, which means we have to replace it with a word boundary. |
| 3460 | * word breaks vary depending on the language used, so the correct thing to do is to use Pango to determine | |
| 3461 | * what language this is, determine the proper word boundary to use, and insert that. I'm just going to insert | |
| 3462 | * a space instead. What are the non-English speakers going to do? Complain in a language I'll understand? | |
| 3463 | * Bu-wahaha! */ | |
| 3464 | ws[wpos] = ' '; | |
| 3465 | wpos++; | |
| 3466 | 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
|
3467 | ws[0] = '\0'; wpos = 0; |
| 1428 | 3468 | } |
| 3469 | c++; | |
|
2856
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
3470 | 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
|
3471 | } 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
|
3472 | (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
|
3473 | c[len_protocol] && !isspace(c[len_protocol]) && |
|
95790807b4d7
Fix the auto-linking of protocols.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
25908
diff
changeset
|
3474 | (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
|
3475 | 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
|
3476 | 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
|
3477 | 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
|
3478 | 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
|
3479 | } |
|
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
|
3480 | 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
|
3481 | /* 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
|
3482 | * 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
|
3483 | */ |
|
ef8bc1f4a6ba
Pass only the URL scheme to gtkimhtml and let it add the colon automatically.
Richard Laager <rlaager@pidgin.im>
parents:
24698
diff
changeset
|
3484 | 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
|
3485 | pos++; |
| 8334 | 3486 | } |
|
25017
139df1ee9854
Fix the linkification error where bad things happened if you copy/pasted
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
25014
diff
changeset
|
3487 | 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
|
3488 | 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
|
3489 | (*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
|
3490 | 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
|
3491 | 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
|
3492 | 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
|
3493 | 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
|
3494 | 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
|
3495 | } else { |
|
139df1ee9854
Fix the linkification error where bad things happened if you copy/pasted
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
25014
diff
changeset
|
3496 | 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
|
3497 | pos++; |
|
139df1ee9854
Fix the linkification error where bad things happened if you copy/pasted
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
25014
diff
changeset
|
3498 | } |
|
24674
36bf974a7d78
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24588
diff
changeset
|
3499 | } |
|
36bf974a7d78
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24588
diff
changeset
|
3500 | 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
|
3501 | 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
|
3502 | 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
|
3503 | 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
|
3504 | gtk_imhtml_toggle_link(imhtml, NULL); |
| 8334 | 3505 | } |
| 8061 | 3506 | } 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
|
3507 | br = FALSE; |
| 1428 | 3508 | ws [wpos++] = *c++; |
|
2856
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
3509 | pos++; |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
3510 | } else { |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
3511 | break; |
| 1428 | 3512 | } |
| 3513 | } | |
| 8677 | 3514 | gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos); |
| 8061 | 3515 | ws[0] = '\0'; wpos = 0; |
| 3516 | ||
|
8177
33b3a01c6318
[gaim-migrate @ 8891]
Mark Doliner <markdoliner@pidgin.im>
parents:
8149
diff
changeset
|
3517 | /* NEW_BIT(NEW_TEXT_BIT); */ |
| 8061 | 3518 | |
|
16143
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
3519 | if(align_right) { |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
3520 | /* 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
|
3521 | GtkTextIter line_iter; |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
3522 | line_iter = *iter; |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
3523 | 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
|
3524 | /* insert RLM character to set alignment */ |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
3525 | ws[wpos++] = 0xE2; |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
3526 | ws[wpos++] = 0x80; |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
3527 | ws[wpos++] = 0x8F; |
|
25888
d0fdd378a635
Remove trailing whitespace
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
3528 | |
| 16144 | 3529 | if (!rtl_direction) |
|
16143
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
3530 | { |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
3531 | /* insert LRM character to set direction */ |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
3532 | /* (alignment=right and direction=LTR) */ |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
3533 | ws[wpos++] = 0xE2; |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
3534 | ws[wpos++] = 0x80; |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
3535 | ws[wpos++] = 0x8E; |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
3536 | } |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
3537 | |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
3538 | ws[wpos] = '\0'; |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
3539 | 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
|
3540 | 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
|
3541 | ws[0] = '\0'; wpos = 0; |
|
16143
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
3542 | } |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
3543 | |
| 4032 | 3544 | while (fonts) { |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
3545 | GtkIMHtmlFontDetail *font = fonts->data; |
| 4032 | 3546 | fonts = g_slist_remove (fonts, font); |
|
14097
0c340861ab79
[gaim-migrate @ 16638]
Mark Doliner <markdoliner@pidgin.im>
parents:
14010
diff
changeset
|
3547 | g_free (font->face); |
|
0c340861ab79
[gaim-migrate @ 16638]
Mark Doliner <markdoliner@pidgin.im>
parents:
14010
diff
changeset
|
3548 | g_free (font->fore); |
|
0c340861ab79
[gaim-migrate @ 16638]
Mark Doliner <markdoliner@pidgin.im>
parents:
14010
diff
changeset
|
3549 | g_free (font->back); |
|
0c340861ab79
[gaim-migrate @ 16638]
Mark Doliner <markdoliner@pidgin.im>
parents:
14010
diff
changeset
|
3550 | g_free (font->sml); |
| 4032 | 3551 | g_free (font); |
| 3552 | } | |
| 8932 | 3553 | |
| 3554 | g_free(ws); | |
|
13138
4d3bd039da3e
[gaim-migrate @ 15499]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13137
diff
changeset
|
3555 | g_free(bg); |
| 8677 | 3556 | |
| 3557 | if (!imhtml->wbfo) | |
| 8698 | 3558 | gtk_imhtml_close_tags(imhtml, iter); |
| 8506 | 3559 | |
| 15403 | 3560 | object = g_object_ref(G_OBJECT(imhtml)); |
| 8506 | 3561 | g_signal_emit(object, signals[UPDATE_FORMAT], 0); |
| 3562 | g_object_unref(object); | |
| 15420 | 3563 | |
|
22834
1394e7efb818
Smiley insertions can be undone with this fix. References #5577. But redo
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22810
diff
changeset
|
3564 | gtk_text_buffer_end_user_action(imhtml->text_buffer); |
| 3922 | 3565 | } |
| 3566 | ||
| 4892 | 3567 | void gtk_imhtml_remove_smileys(GtkIMHtml *imhtml) |
| 3568 | { | |
| 4288 | 3569 | g_hash_table_destroy(imhtml->smiley_data); |
| 3570 | gtk_smiley_tree_destroy(imhtml->default_smilies); | |
| 4892 | 3571 | imhtml->smiley_data = g_hash_table_new_full(g_str_hash, g_str_equal, |
| 4902 | 3572 | g_free, (GDestroyNotify)gtk_smiley_tree_destroy); |
| 4288 | 3573 | imhtml->default_smilies = gtk_smiley_tree_new(); |
| 3574 | } | |
| 8481 | 3575 | |
| 3922 | 3576 | void gtk_imhtml_show_comments (GtkIMHtml *imhtml, |
| 4253 | 3577 | gboolean show) |
| 3578 | { | |
|
22486
e77232ab761f
Disable invisible text things, if someone can conclusively prove this is
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22276
diff
changeset
|
3579 | #if FALSE && GTK_CHECK_VERSION(2,10,10) |
|
22211
7f3cecdb079c
disapproval of revision '2c96f5a301400781ce5fbf144ffdbae44f895281'
Sean Egan <seanegan@pidgin.im>
parents:
22210
diff
changeset
|
3580 | GtkTextTag *tag; |
|
7f3cecdb079c
disapproval of revision '2c96f5a301400781ce5fbf144ffdbae44f895281'
Sean Egan <seanegan@pidgin.im>
parents:
22210
diff
changeset
|
3581 | 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
|
3582 | if (tag) |
|
7f3cecdb079c
disapproval of revision '2c96f5a301400781ce5fbf144ffdbae44f895281'
Sean Egan <seanegan@pidgin.im>
parents:
22210
diff
changeset
|
3583 | g_object_set(G_OBJECT(tag), "invisible", !show, NULL); |
|
7f3cecdb079c
disapproval of revision '2c96f5a301400781ce5fbf144ffdbae44f895281'
Sean Egan <seanegan@pidgin.im>
parents:
22210
diff
changeset
|
3584 | #endif |
|
6124
322206d79652
[gaim-migrate @ 6598]
Mark Doliner <markdoliner@pidgin.im>
parents:
6066
diff
changeset
|
3585 | imhtml->show_comments = show; |
| 4253 | 3586 | } |
|
1780
431333222954
[gaim-migrate @ 1790]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
1738
diff
changeset
|
3587 | |
|
11814
5003711283c0
[gaim-migrate @ 14105]
Richard Laager <rlaager@pidgin.im>
parents:
11768
diff
changeset
|
3588 | const char * |
|
5003711283c0
[gaim-migrate @ 14105]
Richard Laager <rlaager@pidgin.im>
parents:
11768
diff
changeset
|
3589 | gtk_imhtml_get_protocol_name(GtkIMHtml *imhtml) { |
|
5003711283c0
[gaim-migrate @ 14105]
Richard Laager <rlaager@pidgin.im>
parents:
11768
diff
changeset
|
3590 | return imhtml->protocol_name; |
|
5003711283c0
[gaim-migrate @ 14105]
Richard Laager <rlaager@pidgin.im>
parents:
11768
diff
changeset
|
3591 | } |
|
5003711283c0
[gaim-migrate @ 14105]
Richard Laager <rlaager@pidgin.im>
parents:
11768
diff
changeset
|
3592 | |
| 8962 | 3593 | void |
| 9029 | 3594 | 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
|
3595 | g_free(imhtml->protocol_name); |
|
0c340861ab79
[gaim-migrate @ 16638]
Mark Doliner <markdoliner@pidgin.im>
parents:
14010
diff
changeset
|
3596 | imhtml->protocol_name = g_strdup(protocol_name); |
| 8456 | 3597 | } |
| 3598 | ||
|
1780
431333222954
[gaim-migrate @ 1790]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
1738
diff
changeset
|
3599 | void |
|
11224
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3600 | gtk_imhtml_delete(GtkIMHtml *imhtml, GtkTextIter *start, GtkTextIter *end) { |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3601 | GList *l; |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3602 | GSList *sl; |
|
11234
e23fd86e7581
[gaim-migrate @ 13377]
Daniel Atallah <datallah@pidgin.im>
parents:
11233
diff
changeset
|
3603 | GtkTextIter i, i_s, i_e; |
| 8427 | 3604 | GObject *object = g_object_ref(G_OBJECT(imhtml)); |
|
11224
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3605 | |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3606 | if (start == NULL) { |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3607 | gtk_text_buffer_get_start_iter(imhtml->text_buffer, &i_s); |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3608 | start = &i_s; |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3609 | } |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3610 | |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3611 | if (end == NULL) { |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3612 | gtk_text_buffer_get_end_iter(imhtml->text_buffer, &i_e); |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3613 | end = &i_e; |
| 7991 | 3614 | } |
|
11224
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3615 | |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3616 | l = imhtml->scalables; |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3617 | while (l) { |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3618 | GList *next = l->next; |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3619 | struct scalable_data *sd = l->data; |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3620 | gtk_text_buffer_get_iter_at_mark(imhtml->text_buffer, |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3621 | &i, sd->mark); |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3622 | 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
|
3623 | GtkIMHtmlScalable *scale = GTK_IMHTML_SCALABLE(sd->scalable); |
|
11224
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3624 | 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
|
3625 | 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
|
3626 | imhtml->scalables = g_list_delete_link(imhtml->scalables, l); |
|
11224
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3627 | } |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3628 | l = next; |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3629 | } |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3630 | |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3631 | sl = imhtml->im_images; |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3632 | while (sl) { |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3633 | GSList *next = sl->next; |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3634 | struct im_image_data *img_data = sl->data; |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3635 | gtk_text_buffer_get_iter_at_mark(imhtml->text_buffer, |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3636 | &i, img_data->mark); |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3637 | if (gtk_text_iter_in_range(&i, start, end)) { |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3638 | if (imhtml->funcs->image_unref) |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3639 | imhtml->funcs->image_unref(img_data->id); |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3640 | imhtml->im_images = g_slist_delete_link(imhtml->im_images, sl); |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3641 | g_free(img_data); |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3642 | } |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3643 | sl = next; |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3644 | } |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3645 | gtk_text_buffer_delete(imhtml->text_buffer, start, end); |
| 8061 | 3646 | |
|
29378
a783b23a05da
Fix CVE-2010-0423, a denial of service attack due to the parsing
Mark Doliner <markdoliner@pidgin.im>
parents:
29371
diff
changeset
|
3647 | 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
|
3648 | |
| 8427 | 3649 | g_object_unref(object); |
|
1780
431333222954
[gaim-migrate @ 1790]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
1738
diff
changeset
|
3650 | } |
|
2363
0767c14d7879
[gaim-migrate @ 2376]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2349
diff
changeset
|
3651 | |
| 4046 | 3652 | void gtk_imhtml_page_up (GtkIMHtml *imhtml) |
| 3653 | { | |
| 5282 | 3654 | GdkRectangle rect; |
| 3655 | GtkTextIter iter; | |
| 4046 | 3656 | |
| 5282 | 3657 | gtk_text_view_get_visible_rect(GTK_TEXT_VIEW(imhtml), &rect); |
| 3658 | gtk_text_view_get_iter_at_location(GTK_TEXT_VIEW(imhtml), &iter, rect.x, | |
| 3659 | rect.y - rect.height); | |
| 3660 | gtk_text_view_scroll_to_iter(GTK_TEXT_VIEW(imhtml), &iter, 0, TRUE, 0, 0); | |
| 8061 | 3661 | |
| 4046 | 3662 | } |
| 5282 | 3663 | void gtk_imhtml_page_down (GtkIMHtml *imhtml) |
| 3664 | { | |
| 3665 | GdkRectangle rect; | |
| 3666 | GtkTextIter iter; | |
| 3667 | ||
| 3668 | gtk_text_view_get_visible_rect(GTK_TEXT_VIEW(imhtml), &rect); | |
| 3669 | gtk_text_view_get_iter_at_location(GTK_TEXT_VIEW(imhtml), &iter, rect.x, | |
| 3670 | rect.y + rect.height); | |
| 3671 | gtk_text_view_scroll_to_iter(GTK_TEXT_VIEW(imhtml), &iter, 0, TRUE, 0, 0); | |
| 3672 | } | |
| 4735 | 3673 | |
|
32295
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3674 | /** |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3675 | * Destroys and frees a GTK+ IM/HTML scalable image. |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3676 | * |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3677 | * @param scale The GTK+ IM/HTML scalable. |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3678 | */ |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3679 | static void gtk_imhtml_image_free(GtkIMHtmlScalable *scale) |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3680 | { |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3681 | GtkIMHtmlImage *image = (GtkIMHtmlImage *)scale; |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3682 | |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3683 | g_object_unref(image->pixbuf); |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3684 | g_free(image->filename); |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3685 | if (image->filesel) |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3686 | gtk_widget_destroy(image->filesel); |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3687 | g_free(scale); |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3688 | } |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3689 | |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3690 | /** |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3691 | * Destroys and frees a GTK+ IM/HTML scalable animation. |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3692 | * |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3693 | * @param scale The GTK+ IM/HTML scalable. |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3694 | */ |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3695 | static void gtk_imhtml_animation_free(GtkIMHtmlScalable *scale) |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3696 | { |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3697 | GtkIMHtmlAnimation *animation = (GtkIMHtmlAnimation *)scale; |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3698 | |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3699 | if (animation->timer > 0) |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3700 | g_source_remove(animation->timer); |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3701 | if (animation->iter != NULL) |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3702 | g_object_unref(animation->iter); |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3703 | g_object_unref(animation->anim); |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3704 | |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3705 | gtk_imhtml_image_free(scale); |
| 4895 | 3706 | } |
| 3707 | ||
|
9573
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3708 | static void |
|
27123
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3709 | 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
|
3710 | { |
| 5019 | 3711 | GError *error = NULL; |
|
27123
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3712 | GtkIMHtmlImage *image = (GtkIMHtmlImage *)save->image; |
| 5012 | 3713 | |
|
9573
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3714 | gtk_widget_destroy(image->filesel); |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3715 | image->filesel = NULL; |
|
5959
827dbe4b5bb2
[gaim-migrate @ 6405]
Mark Doliner <markdoliner@pidgin.im>
parents:
5582
diff
changeset
|
3716 | |
|
27123
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3717 | if (save->data && save->datasize) { |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3718 | 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
|
3719 | } else { |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3720 | gchar *type = NULL; |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3721 | 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
|
3722 | char *newfilename; |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3723 | |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3724 | while (formats) { |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3725 | GdkPixbufFormat *format = formats->data; |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3726 | 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
|
3727 | gpointer p = extensions; |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3728 | |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3729 | 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
|
3730 | gchar *fmt_ext = extensions[0]; |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3731 | 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
|
3732 | |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3733 | 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
|
3734 | 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
|
3735 | break; |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3736 | } |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3737 | |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3738 | extensions++; |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3739 | } |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3740 | |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3741 | g_strfreev(p); |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3742 | |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3743 | if (type) |
| 5012 | 3744 | break; |
|
27123
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3745 | |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3746 | formats = formats->next; |
| 5012 | 3747 | } |
| 3748 | ||
|
27123
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3749 | g_slist_free(formats); |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3750 | |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3751 | /* 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
|
3752 | it's a png */ |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3753 | if (!type){ |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3754 | 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
|
3755 | char *dirname; |
|
27123
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3756 | 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
|
3757 | _("<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
|
3758 | |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3759 | 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
|
3760 | gtk_widget_show(dialog); |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3761 | |
| 5020 | 3762 | 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
|
3763 | 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
|
3764 | 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
|
3765 | tmp = strrchr(basename, '.'); |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3766 | if (tmp != NULL) |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3767 | 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
|
3768 | 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
|
3769 | g_free(dirname); |
|
27123
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3770 | g_free(basename); |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3771 | } else { |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3772 | /* |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3773 | * 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
|
3774 | * 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
|
3775 | */ |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3776 | newfilename = g_strdup(filename); |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3777 | } |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3778 | |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3779 | 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
|
3780 | |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3781 | g_free(newfilename); |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3782 | g_free(type); |
| 5020 | 3783 | } |
| 3784 | ||
|
9573
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3785 | if (error){ |
|
11019
6786068b00ab
[gaim-migrate @ 12890]
Richard Laager <rlaager@pidgin.im>
parents:
11006
diff
changeset
|
3786 | 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
|
3787 | _("<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
|
3788 | 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
|
3789 | gtk_widget_show(dialog); |
| 5012 | 3790 | g_error_free(error); |
| 3791 | } | |
| 3792 | } | |
| 3793 | ||
|
9573
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3794 | static void |
|
27123
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3795 | 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
|
3796 | { |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3797 | gchar *filename; |
|
27123
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3798 | GtkIMHtmlImage *image = (GtkIMHtmlImage *)save->image; |
|
9573
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3799 | |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3800 | if (response != GTK_RESPONSE_ACCEPT) { |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3801 | gtk_widget_destroy(widget); |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3802 | image->filesel = NULL; |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3803 | return; |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3804 | } |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3805 | |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3806 | filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(widget)); |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3807 | |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3808 | /* |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3809 | * 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
|
3810 | * 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
|
3811 | * 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
|
3812 | */ |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3813 | /* |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3814 | if (g_file_test(filename, G_FILE_TEST_EXISTS)) { |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3815 | } else |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3816 | image_save_yes_cb(image, filename); |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3817 | */ |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3818 | |
|
27123
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3819 | image_save_yes_cb(save, filename); |
|
9573
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3820 | |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3821 | g_free(filename); |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3822 | } |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3823 | |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3824 | static void |
|
27123
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3825 | 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
|
3826 | { |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3827 | GtkIMHtmlImage *image = (GtkIMHtmlImage *)save->image; |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3828 | |
|
9573
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3829 | if (image->filesel != NULL) { |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3830 | gtk_window_present(GTK_WINDOW(image->filesel)); |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3831 | return; |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3832 | } |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3833 | |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3834 | image->filesel = gtk_file_chooser_dialog_new(_("Save Image"), |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3835 | NULL, |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3836 | GTK_FILE_CHOOSER_ACTION_SAVE, |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3837 | GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3838 | GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT, |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3839 | NULL); |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3840 | 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
|
3841 | if (image->filename != NULL) |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3842 | 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
|
3843 | 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
|
3844 | G_CALLBACK(image_save_check_if_exists_cb), save); |
|
9573
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3845 | |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3846 | gtk_widget_show(image->filesel); |
| 5012 | 3847 | } |
| 3848 | ||
|
23304
3aba02105818
Modified patch from malu to "Add context menu alternative to add received
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23302
diff
changeset
|
3849 | static void |
|
27259
50ab3ce89cdb
Allow adding received animated custom smileys to locale custom smiley
Andrea Piccinelli <frasten@gmail.com>
parents:
27173
diff
changeset
|
3850 | 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
|
3851 | { |
|
50ab3ce89cdb
Allow adding received animated custom smileys to locale custom smiley
Andrea Piccinelli <frasten@gmail.com>
parents:
27173
diff
changeset
|
3852 | GtkIMHtmlImage *image = (GtkIMHtmlImage *)save->image; |
|
31294
73607ab89c6f
Remove trailing whitespace
Richard Laager <rlaager@pidgin.im>
parents:
31208
diff
changeset
|
3853 | |
|
23304
3aba02105818
Modified patch from malu to "Add context menu alternative to add received
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23302
diff
changeset
|
3854 | /* 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
|
3855 | 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
|
3856 | 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
|
3857 | 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
|
3858 | 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
|
3859 | } |
|
3aba02105818
Modified patch from malu to "Add context menu alternative to add received
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23302
diff
changeset
|
3860 | |
|
9815
fcbbbce0e1ff
[gaim-migrate @ 10686]
Mark Doliner <markdoliner@pidgin.im>
parents:
9726
diff
changeset
|
3861 | /* |
|
fcbbbce0e1ff
[gaim-migrate @ 10686]
Mark Doliner <markdoliner@pidgin.im>
parents:
9726
diff
changeset
|
3862 | * 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
|
3863 | * 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
|
3864 | * basically like file transfer, except there is an icon to open the file |
| 15884 | 3865 | * 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
|
3866 | * all of that. |
|
fcbbbce0e1ff
[gaim-migrate @ 10686]
Mark Doliner <markdoliner@pidgin.im>
parents:
9726
diff
changeset
|
3867 | */ |
|
27123
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3868 | static gboolean gtk_imhtml_image_clicked(GtkWidget *w, GdkEvent *event, GtkIMHtmlImageSave *save) |
| 5012 | 3869 | { |
| 3870 | 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
|
3871 | GtkIMHtmlImage *image = (GtkIMHtmlImage *)save->image; |
| 5012 | 3872 | |
| 3873 | if (event->type == GDK_BUTTON_RELEASE) { | |
| 3874 | if(event_button->button == 3) { | |
| 3875 | GtkWidget *img, *item, *menu; | |
| 3876 | menu = gtk_menu_new(); | |
| 3877 | ||
| 3878 | /* buttons and such */ | |
| 3879 | 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
|
3880 | item = gtk_image_menu_item_new_with_mnemonic(_("_Save Image...")); |
| 5012 | 3881 | 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
|
3882 | g_signal_connect(G_OBJECT(item), "activate", G_CALLBACK(gtk_imhtml_image_save), save); |
| 5012 | 3883 | gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); |
| 3884 | ||
|
23304
3aba02105818
Modified patch from malu to "Add context menu alternative to add received
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23302
diff
changeset
|
3885 | /* 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
|
3886 | /* 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
|
3887 | <= 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
|
3888 | 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
|
3889 | 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
|
3890 | 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
|
3891 | 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
|
3892 | 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
|
3893 | 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
|
3894 | 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
|
3895 | } |
|
3aba02105818
Modified patch from malu to "Add context menu alternative to add received
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23302
diff
changeset
|
3896 | |
| 5012 | 3897 | gtk_widget_show_all(menu); |
| 3898 | gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL, | |
| 3899 | event_button->button, event_button->time); | |
| 3900 | ||
| 3901 | return TRUE; | |
| 3902 | } | |
| 3903 | } | |
| 3904 | if(event->type == GDK_BUTTON_PRESS && event_button->button == 3) | |
| 3905 | return TRUE; /* Clicking the right mouse button on a link shouldn't | |
| 3906 | be caught by the regular GtkTextView menu */ | |
| 3907 | else | |
| 3908 | return FALSE; /* Let clicks go through if we didn't catch anything */ | |
| 3909 | ||
| 3910 | } | |
|
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
|
3911 | |
|
32295
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3912 | /** |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3913 | * 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
|
3914 | * |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3915 | * @param scale The GTK+ IM/HTML scalable. |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3916 | * @param width The new width. |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3917 | * @param height The new height. |
|
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 | 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
|
3920 | { |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3921 | GtkIMHtmlImage *im_image = (GtkIMHtmlImage *)scale; |
|
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 | if (im_image->width > width || im_image->height > height) { |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3924 | double ratio_w, ratio_h, ratio; |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3925 | int new_h, new_w; |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3926 | GdkPixbuf *new_image = NULL; |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3927 | |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3928 | ratio_w = ((double)width - 2) / im_image->width; |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3929 | ratio_h = ((double)height - 2) / im_image->height; |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3930 | |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3931 | ratio = (ratio_w < ratio_h) ? ratio_w : ratio_h; |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3932 | |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3933 | new_w = (int)(im_image->width * ratio); |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3934 | new_h = (int)(im_image->height * ratio); |
|
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 | 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
|
3937 | 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
|
3938 | g_object_unref(G_OBJECT(new_image)); |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3939 | } 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
|
3940 | /* 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
|
3941 | GdkPixbuf *new_image; |
|
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 | 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
|
3944 | 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
|
3945 | g_object_unref(G_OBJECT(new_image)); |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3946 | } |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3947 | } |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3948 | |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3949 | /** |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3950 | * 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
|
3951 | * |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3952 | * @param scale The GTK+ IM/HTML scalable. |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3953 | * @param imhtml The GTK+ IM/HTML. |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3954 | * @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
|
3955 | */ |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3956 | 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
|
3957 | { |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
3958 | GtkIMHtmlImage *image = (GtkIMHtmlImage *)scale; |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
3959 | GtkWidget *box = gtk_event_box_new(); |
| 8962 | 3960 | char *tag; |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
3961 | 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
|
3962 | GtkIMHtmlImageSave *save; |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
3963 | |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
3964 | gtk_container_add(GTK_CONTAINER(box), GTK_WIDGET(image->image)); |
| 9229 | 3965 | |
|
33609
52c8d399c1ad
Remove unneeded version check.
Mark Doliner <mark@kingant.net>
parents:
33258
diff
changeset
|
3966 | g_object_set(G_OBJECT(box), "visible-window", FALSE, NULL); |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
3967 | |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
3968 | gtk_widget_show(GTK_WIDGET(image->image)); |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
3969 | gtk_widget_show(box); |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
3970 | |
| 8962 | 3971 | tag = g_strdup_printf("<IMG ID=\"%d\">", image->id); |
| 3972 | g_object_set_data_full(G_OBJECT(anchor), "gtkimhtml_htmltext", tag, g_free); | |
| 3973 | g_object_set_data(G_OBJECT(anchor), "gtkimhtml_plaintext", "[Image]"); | |
| 3974 | ||
| 15420 | 3975 | 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
|
3976 | |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3977 | save = g_new0(GtkIMHtmlImageSave, 1); |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3978 | save->image = scale; |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3979 | 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
|
3980 | 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
|
3981 | } |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
3982 | |
|
32296
7212bb468518
Make another gtkimhtml function private.
Mark Doliner <markdoliner@pidgin.im>
parents:
32295
diff
changeset
|
3983 | /** |
|
7212bb468518
Make another gtkimhtml function private.
Mark Doliner <markdoliner@pidgin.im>
parents:
32295
diff
changeset
|
3984 | * 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
|
3985 | * |
|
7212bb468518
Make another gtkimhtml function private.
Mark Doliner <markdoliner@pidgin.im>
parents:
32295
diff
changeset
|
3986 | * @param img A GdkPixbuf of the image to add. |
|
7212bb468518
Make another gtkimhtml function private.
Mark Doliner <markdoliner@pidgin.im>
parents:
32295
diff
changeset
|
3987 | * @param filename The filename to associate with the image. |
|
7212bb468518
Make another gtkimhtml function private.
Mark Doliner <markdoliner@pidgin.im>
parents:
32295
diff
changeset
|
3988 | * @param id The id to associate with the image. |
|
7212bb468518
Make another gtkimhtml function private.
Mark Doliner <markdoliner@pidgin.im>
parents:
32295
diff
changeset
|
3989 | * |
|
7212bb468518
Make another gtkimhtml function private.
Mark Doliner <markdoliner@pidgin.im>
parents:
32295
diff
changeset
|
3990 | * @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
|
3991 | */ |
|
7212bb468518
Make another gtkimhtml function private.
Mark Doliner <markdoliner@pidgin.im>
parents:
32295
diff
changeset
|
3992 | 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
|
3993 | { |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3994 | GtkIMHtmlImage *im_image = g_malloc(sizeof(GtkIMHtmlImage)); |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3995 | |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
3996 | 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
|
3997 | 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
|
3998 | 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
|
3999 | |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
4000 | im_image->pixbuf = img; |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
4001 | 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
|
4002 | im_image->width = gdk_pixbuf_get_width(img); |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
4003 | im_image->height = gdk_pixbuf_get_height(img); |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
4004 | im_image->mark = NULL; |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
4005 | im_image->filename = g_strdup(filename); |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
4006 | im_image->id = id; |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
4007 | im_image->filesel = NULL; |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
4008 | |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
4009 | g_object_ref(img); |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
4010 | return GTK_IMHTML_SCALABLE(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 | |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
4013 | static gboolean |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
4014 | animate_image_cb(gpointer data) |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
4015 | { |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
4016 | GtkIMHtmlImage *im_image; |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
4017 | int width, height; |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
4018 | int delay; |
|
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 | im_image = data; |
|
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 | /* 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
|
4023 | 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
|
4024 | 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
|
4025 | g_object_unref(G_OBJECT(im_image->pixbuf)); |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
4026 | im_image->pixbuf = gdk_pixbuf_copy(pb); |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
4027 | |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
4028 | /* Update the displayed GtkImage */ |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
4029 | 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
|
4030 | 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
|
4031 | if (width > 0 && height > 0) |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
4032 | { |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
4033 | /* 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
|
4034 | GdkPixbuf *tmp; |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
4035 | 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
|
4036 | gtk_image_set_from_pixbuf(im_image->image, tmp); |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
4037 | g_object_unref(G_OBJECT(tmp)); |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
4038 | } else { |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
4039 | /* Display at full-size */ |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
4040 | 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
|
4041 | } |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
4042 | } |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
4043 | |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
4044 | 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
|
4045 | 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
|
4046 | |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
4047 | return FALSE; |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
4048 | } |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
4049 | |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
4050 | /** |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
4051 | * 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
|
4052 | * animated image. |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
4053 | * |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
4054 | * @param img A GdkPixbufAnimation of the image to add. |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
4055 | * @param filename The filename to associate with the image. |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
4056 | * @param id The id to associate with the image. |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
4057 | * |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
4058 | * @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
|
4059 | */ |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
4060 | /* |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
4061 | * 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
|
4062 | * 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
|
4063 | * because it requires breaking backward compatibility. It |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
4064 | * 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
|
4065 | */ |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
4066 | 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
|
4067 | { |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
4068 | GtkIMHtmlImage *im_image = (GtkIMHtmlImage *) g_new0(GtkIMHtmlAnimation, 1); |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
4069 | |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
4070 | 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
|
4071 | 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
|
4072 | 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
|
4073 | |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
4074 | GTK_IMHTML_ANIMATION(im_image)->anim = anim; |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
4075 | if (gdk_pixbuf_animation_is_static_image(anim)) { |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
4076 | 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
|
4077 | g_object_ref(im_image->pixbuf); |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
4078 | } else { |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
4079 | int delay; |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
4080 | GdkPixbuf *pb; |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
4081 | 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
|
4082 | 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
|
4083 | im_image->pixbuf = gdk_pixbuf_copy(pb); |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
4084 | 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
|
4085 | 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
|
4086 | } |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
4087 | 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
|
4088 | im_image->width = gdk_pixbuf_animation_get_width(anim); |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
4089 | im_image->height = gdk_pixbuf_animation_get_height(anim); |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
4090 | im_image->filename = g_strdup(filename); |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
4091 | im_image->id = id; |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
4092 | |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
4093 | g_object_ref(anim); |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
4094 | |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
4095 | return GTK_IMHTML_SCALABLE(im_image); |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
4096 | } |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
4097 | |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
4098 | GtkIMHtmlScalable *gtk_imhtml_hr_new() |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
4099 | { |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
4100 | GtkIMHtmlHr *hr = g_malloc(sizeof(GtkIMHtmlHr)); |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
4101 | |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
4102 | GTK_IMHTML_SCALABLE(hr)->scale = gtk_imhtml_hr_scale; |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
4103 | GTK_IMHTML_SCALABLE(hr)->add_to = gtk_imhtml_hr_add_to; |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
4104 | GTK_IMHTML_SCALABLE(hr)->free = gtk_imhtml_hr_free; |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
4105 | |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
4106 | hr->sep = gtk_hseparator_new(); |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
4107 | gtk_widget_set_size_request(hr->sep, 5000, 2); |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
4108 | gtk_widget_show(hr->sep); |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
4109 | |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
4110 | return GTK_IMHTML_SCALABLE(hr); |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
4111 | } |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
4112 | |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
4113 | void gtk_imhtml_hr_scale(GtkIMHtmlScalable *scale, int width, int height) |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
4114 | { |
|
8588
6bcf7ed80ed8
[gaim-migrate @ 9339]
Mark Doliner <markdoliner@pidgin.im>
parents:
8568
diff
changeset
|
4115 | 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
|
4116 | } |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
4117 | |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
4118 | 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
|
4119 | { |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
4120 | GtkIMHtmlHr *hr = (GtkIMHtmlHr *)scale; |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
4121 | GtkTextChildAnchor *anchor = gtk_text_buffer_create_child_anchor(imhtml->text_buffer, iter); |
| 8698 | 4122 | g_object_set_data(G_OBJECT(anchor), "gtkimhtml_htmltext", "<hr>"); |
| 4123 | g_object_set_data(G_OBJECT(anchor), "gtkimhtml_plaintext", "\n---\n"); | |
| 15420 | 4124 | 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
|
4125 | } |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
4126 | |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
4127 | void gtk_imhtml_hr_free(GtkIMHtmlScalable *scale) |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
4128 | { |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
4129 | g_free(scale); |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
4130 | } |
| 7295 | 4131 | |
| 4132 | gboolean gtk_imhtml_search_find(GtkIMHtml *imhtml, const gchar *text) | |
| 4133 | { | |
| 4134 | GtkTextIter iter, start, end; | |
| 4135 | gboolean new_search = TRUE; | |
|
14863
82888d51234c
[gaim-migrate @ 17566]
Daniel Atallah <datallah@pidgin.im>
parents:
14821
diff
changeset
|
4136 | GtkTextMark *start_mark; |
| 7295 | 4137 | |
| 4138 | g_return_val_if_fail(imhtml != NULL, FALSE); | |
| 4139 | g_return_val_if_fail(text != NULL, FALSE); | |
| 8061 | 4140 | |
|
14863
82888d51234c
[gaim-migrate @ 17566]
Daniel Atallah <datallah@pidgin.im>
parents:
14821
diff
changeset
|
4141 | start_mark = gtk_text_buffer_get_mark(imhtml->text_buffer, "search"); |
|
82888d51234c
[gaim-migrate @ 17566]
Daniel Atallah <datallah@pidgin.im>
parents:
14821
diff
changeset
|
4142 | |
|
82888d51234c
[gaim-migrate @ 17566]
Daniel Atallah <datallah@pidgin.im>
parents:
14821
diff
changeset
|
4143 | if (start_mark && imhtml->search_string && !strcmp(text, imhtml->search_string)) |
| 7295 | 4144 | new_search = FALSE; |
| 8061 | 4145 | |
| 7295 | 4146 | if (new_search) { |
| 4147 | gtk_imhtml_search_clear(imhtml); | |
|
14863
82888d51234c
[gaim-migrate @ 17566]
Daniel Atallah <datallah@pidgin.im>
parents:
14821
diff
changeset
|
4148 | g_free(imhtml->search_string); |
|
82888d51234c
[gaim-migrate @ 17566]
Daniel Atallah <datallah@pidgin.im>
parents:
14821
diff
changeset
|
4149 | imhtml->search_string = g_strdup(text); |
| 15093 | 4150 | gtk_text_buffer_get_end_iter(imhtml->text_buffer, &iter); |
| 7295 | 4151 | } else { |
| 4152 | 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
|
4153 | start_mark); |
| 7295 | 4154 | } |
| 4155 | ||
| 15093 | 4156 | if (gtk_source_iter_backward_search(&iter, imhtml->search_string, |
|
14400
953baf2eba1a
[gaim-migrate @ 17035]
Richard Laager <rlaager@pidgin.im>
parents:
14395
diff
changeset
|
4157 | GTK_SOURCE_SEARCH_VISIBLE_ONLY | GTK_SOURCE_SEARCH_CASE_INSENSITIVE, |
|
953baf2eba1a
[gaim-migrate @ 17035]
Richard Laager <rlaager@pidgin.im>
parents:
14395
diff
changeset
|
4158 | &start, &end, NULL)) |
|
953baf2eba1a
[gaim-migrate @ 17035]
Richard Laager <rlaager@pidgin.im>
parents:
14395
diff
changeset
|
4159 | { |
| 7295 | 4160 | gtk_text_view_scroll_to_iter(GTK_TEXT_VIEW(imhtml), &start, 0, TRUE, 0, 0); |
| 15093 | 4161 | 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
|
4162 | if (new_search) |
|
953baf2eba1a
[gaim-migrate @ 17035]
Richard Laager <rlaager@pidgin.im>
parents:
14395
diff
changeset
|
4163 | { |
| 7295 | 4164 | gtk_text_buffer_remove_tag_by_name(imhtml->text_buffer, "search", &iter, &end); |
| 8061 | 4165 | do |
| 7295 | 4166 | gtk_text_buffer_apply_tag_by_name(imhtml->text_buffer, "search", &start, &end); |
| 15093 | 4167 | while (gtk_source_iter_backward_search(&start, imhtml->search_string, |
| 8061 | 4168 | GTK_SOURCE_SEARCH_VISIBLE_ONLY | |
| 7358 | 4169 | GTK_SOURCE_SEARCH_CASE_INSENSITIVE, |
| 7295 | 4170 | &start, &end, NULL)); |
| 4171 | } | |
| 4172 | return TRUE; | |
| 4173 | } | |
|
14400
953baf2eba1a
[gaim-migrate @ 17035]
Richard Laager <rlaager@pidgin.im>
parents:
14395
diff
changeset
|
4174 | else if (!new_search) |
|
953baf2eba1a
[gaim-migrate @ 17035]
Richard Laager <rlaager@pidgin.im>
parents:
14395
diff
changeset
|
4175 | { |
|
953baf2eba1a
[gaim-migrate @ 17035]
Richard Laager <rlaager@pidgin.im>
parents:
14395
diff
changeset
|
4176 | /* We hit the end, so start at the beginning again. */ |
| 15093 | 4177 | gtk_text_buffer_get_end_iter(imhtml->text_buffer, &iter); |
| 4178 | ||
| 4179 | if (gtk_source_iter_backward_search(&iter, imhtml->search_string, | |
|
14400
953baf2eba1a
[gaim-migrate @ 17035]
Richard Laager <rlaager@pidgin.im>
parents:
14395
diff
changeset
|
4180 | GTK_SOURCE_SEARCH_VISIBLE_ONLY | GTK_SOURCE_SEARCH_CASE_INSENSITIVE, |
|
953baf2eba1a
[gaim-migrate @ 17035]
Richard Laager <rlaager@pidgin.im>
parents:
14395
diff
changeset
|
4181 | &start, &end, NULL)) |
|
953baf2eba1a
[gaim-migrate @ 17035]
Richard Laager <rlaager@pidgin.im>
parents:
14395
diff
changeset
|
4182 | { |
|
953baf2eba1a
[gaim-migrate @ 17035]
Richard Laager <rlaager@pidgin.im>
parents:
14395
diff
changeset
|
4183 | gtk_text_view_scroll_to_iter(GTK_TEXT_VIEW(imhtml), &start, 0, TRUE, 0, 0); |
| 15093 | 4184 | 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
|
4185 | |
|
953baf2eba1a
[gaim-migrate @ 17035]
Richard Laager <rlaager@pidgin.im>
parents:
14395
diff
changeset
|
4186 | return TRUE; |
|
953baf2eba1a
[gaim-migrate @ 17035]
Richard Laager <rlaager@pidgin.im>
parents:
14395
diff
changeset
|
4187 | } |
|
953baf2eba1a
[gaim-migrate @ 17035]
Richard Laager <rlaager@pidgin.im>
parents:
14395
diff
changeset
|
4188 | |
|
953baf2eba1a
[gaim-migrate @ 17035]
Richard Laager <rlaager@pidgin.im>
parents:
14395
diff
changeset
|
4189 | } |
| 8061 | 4190 | |
| 7295 | 4191 | return FALSE; |
| 4192 | } | |
| 4193 | ||
| 4194 | void gtk_imhtml_search_clear(GtkIMHtml *imhtml) | |
| 4195 | { | |
| 4196 | GtkTextIter start, end; | |
| 8061 | 4197 | |
| 7295 | 4198 | g_return_if_fail(imhtml != NULL); |
| 8061 | 4199 | |
| 7295 | 4200 | gtk_text_buffer_get_start_iter(imhtml->text_buffer, &start); |
| 4201 | gtk_text_buffer_get_end_iter(imhtml->text_buffer, &end); | |
| 4202 | ||
| 4203 | 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
|
4204 | g_free(imhtml->search_string); |
| 7295 | 4205 | imhtml->search_string = NULL; |
| 4206 | } | |
| 8061 | 4207 | |
| 8677 | 4208 | static GtkTextTag *find_font_forecolor_tag(GtkIMHtml *imhtml, gchar *color) |
| 4209 | { | |
| 4210 | gchar str[18]; | |
| 4211 | GtkTextTag *tag; | |
| 4212 | ||
| 4213 | g_snprintf(str, sizeof(str), "FORECOLOR %s", color); | |
| 4214 | ||
| 4215 | tag = gtk_text_tag_table_lookup(gtk_text_buffer_get_tag_table(imhtml->text_buffer), str); | |
| 10858 | 4216 | if (!tag) { |
| 4217 | GdkColor gcolor; | |
| 4218 | if (!gdk_color_parse(color, &gcolor)) { | |
| 4219 | gchar tmp[8]; | |
| 4220 | tmp[0] = '#'; | |
| 4221 | strncpy(&tmp[1], color, 7); | |
| 4222 | tmp[7] = '\0'; | |
| 4223 | if (!gdk_color_parse(tmp, &gcolor)) | |
| 4224 | gdk_color_parse("black", &gcolor); | |
| 4225 | } | |
| 4226 | tag = gtk_text_buffer_create_tag(imhtml->text_buffer, str, "foreground-gdk", &gcolor, NULL); | |
| 4227 | } | |
| 8677 | 4228 | |
| 4229 | return tag; | |
| 4230 | } | |
| 4231 | ||
| 4232 | static GtkTextTag *find_font_backcolor_tag(GtkIMHtml *imhtml, gchar *color) | |
| 4233 | { | |
| 4234 | gchar str[18]; | |
| 4235 | GtkTextTag *tag; | |
| 4236 | ||
| 4237 | g_snprintf(str, sizeof(str), "BACKCOLOR %s", color); | |
| 4238 | ||
| 4239 | tag = gtk_text_tag_table_lookup(gtk_text_buffer_get_tag_table(imhtml->text_buffer), str); | |
| 10858 | 4240 | if (!tag) { |
| 4241 | GdkColor gcolor; | |
| 4242 | if (!gdk_color_parse(color, &gcolor)) { | |
| 4243 | gchar tmp[8]; | |
| 4244 | tmp[0] = '#'; | |
| 4245 | strncpy(&tmp[1], color, 7); | |
| 4246 | tmp[7] = '\0'; | |
| 4247 | if (!gdk_color_parse(tmp, &gcolor)) | |
| 4248 | gdk_color_parse("white", &gcolor); | |
| 4249 | } | |
| 4250 | tag = gtk_text_buffer_create_tag(imhtml->text_buffer, str, "background-gdk", &gcolor, NULL); | |
| 4251 | } | |
| 8677 | 4252 | |
| 4253 | return tag; | |
| 4254 | } | |
| 4255 | ||
| 10776 | 4256 | static GtkTextTag *find_font_background_tag(GtkIMHtml *imhtml, gchar *color) |
| 4257 | { | |
| 4258 | gchar str[19]; | |
| 4259 | GtkTextTag *tag; | |
| 4260 | ||
| 4261 | g_snprintf(str, sizeof(str), "BACKGROUND %s", color); | |
| 4262 | ||
| 4263 | tag = gtk_text_tag_table_lookup(gtk_text_buffer_get_tag_table(imhtml->text_buffer), str); | |
| 4264 | if (!tag) | |
| 4265 | tag = gtk_text_buffer_create_tag(imhtml->text_buffer, str, NULL); | |
| 4266 | ||
| 4267 | return tag; | |
| 4268 | } | |
| 4269 | ||
| 8677 | 4270 | static GtkTextTag *find_font_face_tag(GtkIMHtml *imhtml, gchar *face) |
| 8061 | 4271 | { |
| 8677 | 4272 | gchar str[256]; |
| 4273 | GtkTextTag *tag; | |
| 4274 | ||
| 4275 | g_snprintf(str, sizeof(str), "FONT FACE %s", face); | |
| 4276 | str[255] = '\0'; | |
| 4277 | ||
| 4278 | tag = gtk_text_tag_table_lookup(gtk_text_buffer_get_tag_table(imhtml->text_buffer), str); | |
| 4279 | if (!tag) | |
| 4280 | tag = gtk_text_buffer_create_tag(imhtml->text_buffer, str, "family", face, NULL); | |
| 4281 | ||
| 4282 | return tag; | |
| 4283 | } | |
| 4284 | ||
| 4285 | static GtkTextTag *find_font_size_tag(GtkIMHtml *imhtml, int size) | |
| 4286 | { | |
| 4287 | gchar str[24]; | |
| 4288 | GtkTextTag *tag; | |
| 4289 | ||
| 4290 | g_snprintf(str, sizeof(str), "FONT SIZE %d", size); | |
| 4291 | str[23] = '\0'; | |
| 4292 | ||
| 4293 | tag = gtk_text_tag_table_lookup(gtk_text_buffer_get_tag_table(imhtml->text_buffer), str); | |
| 4294 | if (!tag) { | |
| 10525 | 4295 | /* For reasons I don't understand, setting "scale" here scaled |
| 4296 | * based on some default size other than my theme's default | |
| 4297 | * size. Our size 4 was actually smaller than our size 3 for | |
| 4298 | * me. So this works around that oddity. | |
| 8677 | 4299 | */ |
| 10525 | 4300 | GtkTextAttributes *attr = gtk_text_view_get_default_attributes(GTK_TEXT_VIEW(imhtml)); |
| 8677 | 4301 | tag = gtk_text_buffer_create_tag(imhtml->text_buffer, str, "size", |
| 10525 | 4302 | (gint) (pango_font_description_get_size(attr->font) * |
|
10899
87d9aec5b72d
[gaim-migrate @ 12619]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10871
diff
changeset
|
4303 | (double) POINT_SIZE(size)), NULL); |
| 10525 | 4304 | gtk_text_attributes_unref(attr); |
| 8061 | 4305 | } |
| 4306 | ||
| 8677 | 4307 | return tag; |
| 4308 | } | |
| 4309 | ||
| 4310 | static void remove_tag_by_prefix(GtkIMHtml *imhtml, const GtkTextIter *i, const GtkTextIter *e, | |
| 4311 | const char *prefix, guint len, gboolean homo) | |
| 4312 | { | |
| 4313 | GSList *tags, *l; | |
| 4314 | GtkTextIter iter; | |
| 4315 | ||
| 4316 | tags = gtk_text_iter_get_tags(i); | |
| 4317 | ||
| 4318 | for (l = tags; l; l = l->next) { | |
| 4319 | GtkTextTag *tag = l->data; | |
|
32413
00ad036bdf3d
Fix some indenting.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32412
diff
changeset
|
4320 | gchar *name = NULL; |
|
00ad036bdf3d
Fix some indenting.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32412
diff
changeset
|
4321 | |
|
00ad036bdf3d
Fix some indenting.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32412
diff
changeset
|
4322 | g_object_get(G_OBJECT(tag), "name", &name, NULL); |
|
00ad036bdf3d
Fix some indenting.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32412
diff
changeset
|
4323 | |
|
32394
f883709bdba4
compiles using GTK+ 3 from git, beware it does not yet run, in fact it crashes...
Marcus Lundblad <malu@pidgin.im>
parents:
31207
diff
changeset
|
4324 | if (name && !strncmp(name, prefix, len)) |
| 8677 | 4325 | gtk_text_buffer_remove_tag(imhtml->text_buffer, tag, i, e); |
|
32394
f883709bdba4
compiles using GTK+ 3 from git, beware it does not yet run, in fact it crashes...
Marcus Lundblad <malu@pidgin.im>
parents:
31207
diff
changeset
|
4326 | |
|
32413
00ad036bdf3d
Fix some indenting.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32412
diff
changeset
|
4327 | g_free(name); |
| 8061 | 4328 | } |
| 4329 | ||
| 8677 | 4330 | g_slist_free(tags); |
| 4331 | ||
| 4332 | if (homo) | |
| 4333 | return; | |
| 4334 | ||
| 4335 | iter = *i; | |
| 4336 | ||
| 4337 | while (gtk_text_iter_forward_char(&iter) && !gtk_text_iter_equal(&iter, e)) { | |
| 4338 | if (gtk_text_iter_begins_tag(&iter, NULL)) { | |
| 4339 | tags = gtk_text_iter_get_toggled_tags(&iter, TRUE); | |
| 4340 | ||
| 4341 | for (l = tags; l; l = l->next) { | |
| 4342 | GtkTextTag *tag = l->data; | |
|
32413
00ad036bdf3d
Fix some indenting.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32412
diff
changeset
|
4343 | gchar *name = NULL; |
|
00ad036bdf3d
Fix some indenting.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32412
diff
changeset
|
4344 | |
|
00ad036bdf3d
Fix some indenting.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32412
diff
changeset
|
4345 | g_object_get(G_OBJECT(tag), "name", &name, NULL); |
|
32394
f883709bdba4
compiles using GTK+ 3 from git, beware it does not yet run, in fact it crashes...
Marcus Lundblad <malu@pidgin.im>
parents:
31207
diff
changeset
|
4346 | |
|
f883709bdba4
compiles using GTK+ 3 from git, beware it does not yet run, in fact it crashes...
Marcus Lundblad <malu@pidgin.im>
parents:
31207
diff
changeset
|
4347 | if (name && !strncmp(name, prefix, len)) |
| 8677 | 4348 | gtk_text_buffer_remove_tag(imhtml->text_buffer, tag, &iter, e); |
|
32394
f883709bdba4
compiles using GTK+ 3 from git, beware it does not yet run, in fact it crashes...
Marcus Lundblad <malu@pidgin.im>
parents:
31207
diff
changeset
|
4349 | |
|
32413
00ad036bdf3d
Fix some indenting.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32412
diff
changeset
|
4350 | g_free(name); |
| 8677 | 4351 | } |
| 4352 | ||
| 4353 | g_slist_free(tags); | |
| 4354 | } | |
| 8061 | 4355 | } |
| 8677 | 4356 | } |
| 4357 | ||
| 4358 | static void remove_font_size(GtkIMHtml *imhtml, GtkTextIter *i, GtkTextIter *e, gboolean homo) | |
| 4359 | { | |
| 4360 | remove_tag_by_prefix(imhtml, i, e, "FONT SIZE ", 10, homo); | |
| 4361 | } | |
| 4362 | ||
| 4363 | static void remove_font_face(GtkIMHtml *imhtml, GtkTextIter *i, GtkTextIter *e, gboolean homo) | |
| 4364 | { | |
| 4365 | remove_tag_by_prefix(imhtml, i, e, "FONT FACE ", 10, homo); | |
| 4366 | } | |
| 4367 | ||
| 4368 | static void remove_font_forecolor(GtkIMHtml *imhtml, GtkTextIter *i, GtkTextIter *e, gboolean homo) | |
| 4369 | { | |
| 4370 | remove_tag_by_prefix(imhtml, i, e, "FORECOLOR ", 10, homo); | |
| 4371 | } | |
| 4372 | ||
| 4373 | static void remove_font_backcolor(GtkIMHtml *imhtml, GtkTextIter *i, GtkTextIter *e, gboolean homo) | |
| 4374 | { | |
| 4375 | remove_tag_by_prefix(imhtml, i, e, "BACKCOLOR ", 10, homo); | |
| 4376 | } | |
| 4377 | ||
| 10776 | 4378 | static void remove_font_background(GtkIMHtml *imhtml, GtkTextIter *i, GtkTextIter *e, gboolean homo) |
| 4379 | { | |
| 4380 | remove_tag_by_prefix(imhtml, i, e, "BACKGROUND ", 10, homo); | |
| 4381 | } | |
| 4382 | ||
| 8677 | 4383 | static void remove_font_link(GtkIMHtml *imhtml, GtkTextIter *i, GtkTextIter *e, gboolean homo) |
| 4384 | { | |
| 4385 | remove_tag_by_prefix(imhtml, i, e, "LINK ", 5, homo); | |
| 4386 | } | |
| 4387 | ||
|
12672
673e2a1d2954
[gaim-migrate @ 15015]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12635
diff
changeset
|
4388 | static void |
|
673e2a1d2954
[gaim-migrate @ 15015]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12635
diff
changeset
|
4389 | imhtml_clear_formatting(GtkIMHtml *imhtml) |
|
673e2a1d2954
[gaim-migrate @ 15015]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12635
diff
changeset
|
4390 | { |
|
673e2a1d2954
[gaim-migrate @ 15015]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12635
diff
changeset
|
4391 | GtkTextIter start, end; |
|
673e2a1d2954
[gaim-migrate @ 15015]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12635
diff
changeset
|
4392 | |
|
12796
8fb3611a91e1
[gaim-migrate @ 15143]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12673
diff
changeset
|
4393 | if (!imhtml->editable) |
|
8fb3611a91e1
[gaim-migrate @ 15143]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12673
diff
changeset
|
4394 | return; |
|
8fb3611a91e1
[gaim-migrate @ 15143]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12673
diff
changeset
|
4395 | |
|
28935
84dbc0ca215d
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28932
diff
changeset
|
4396 | 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
|
4397 | return; |
|
12672
673e2a1d2954
[gaim-migrate @ 15015]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12635
diff
changeset
|
4398 | |
|
673e2a1d2954
[gaim-migrate @ 15015]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12635
diff
changeset
|
4399 | 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
|
4400 | 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
|
4401 | 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
|
4402 | 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
|
4403 | remove_font_size(imhtml, &start, &end, FALSE); |
|
485977c61b47
[gaim-migrate @ 15587]
Richard Laager <rlaager@pidgin.im>
parents:
13138
diff
changeset
|
4404 | remove_font_face(imhtml, &start, &end, FALSE); |
|
485977c61b47
[gaim-migrate @ 15587]
Richard Laager <rlaager@pidgin.im>
parents:
13138
diff
changeset
|
4405 | remove_font_forecolor(imhtml, &start, &end, FALSE); |
|
485977c61b47
[gaim-migrate @ 15587]
Richard Laager <rlaager@pidgin.im>
parents:
13138
diff
changeset
|
4406 | remove_font_backcolor(imhtml, &start, &end, FALSE); |
|
485977c61b47
[gaim-migrate @ 15587]
Richard Laager <rlaager@pidgin.im>
parents:
13138
diff
changeset
|
4407 | remove_font_background(imhtml, &start, &end, FALSE); |
|
485977c61b47
[gaim-migrate @ 15587]
Richard Laager <rlaager@pidgin.im>
parents:
13138
diff
changeset
|
4408 | remove_font_link(imhtml, &start, &end, FALSE); |
|
12672
673e2a1d2954
[gaim-migrate @ 15015]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12635
diff
changeset
|
4409 | |
|
673e2a1d2954
[gaim-migrate @ 15015]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12635
diff
changeset
|
4410 | imhtml->edit.bold = 0; |
|
673e2a1d2954
[gaim-migrate @ 15015]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12635
diff
changeset
|
4411 | imhtml->edit.italic = 0; |
|
673e2a1d2954
[gaim-migrate @ 15015]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12635
diff
changeset
|
4412 | imhtml->edit.underline = 0; |
|
673e2a1d2954
[gaim-migrate @ 15015]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12635
diff
changeset
|
4413 | imhtml->edit.strike = 0; |
|
673e2a1d2954
[gaim-migrate @ 15015]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12635
diff
changeset
|
4414 | imhtml->edit.fontsize = 0; |
|
13224
485977c61b47
[gaim-migrate @ 15587]
Richard Laager <rlaager@pidgin.im>
parents:
13138
diff
changeset
|
4415 | |
|
485977c61b47
[gaim-migrate @ 15587]
Richard Laager <rlaager@pidgin.im>
parents:
13138
diff
changeset
|
4416 | g_free(imhtml->edit.fontface); |
|
485977c61b47
[gaim-migrate @ 15587]
Richard Laager <rlaager@pidgin.im>
parents:
13138
diff
changeset
|
4417 | imhtml->edit.fontface = NULL; |
|
485977c61b47
[gaim-migrate @ 15587]
Richard Laager <rlaager@pidgin.im>
parents:
13138
diff
changeset
|
4418 | |
|
485977c61b47
[gaim-migrate @ 15587]
Richard Laager <rlaager@pidgin.im>
parents:
13138
diff
changeset
|
4419 | g_free(imhtml->edit.forecolor); |
|
12672
673e2a1d2954
[gaim-migrate @ 15015]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12635
diff
changeset
|
4420 | imhtml->edit.forecolor = NULL; |
|
13224
485977c61b47
[gaim-migrate @ 15587]
Richard Laager <rlaager@pidgin.im>
parents:
13138
diff
changeset
|
4421 | |
|
485977c61b47
[gaim-migrate @ 15587]
Richard Laager <rlaager@pidgin.im>
parents:
13138
diff
changeset
|
4422 | g_free(imhtml->edit.backcolor); |
|
12672
673e2a1d2954
[gaim-migrate @ 15015]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12635
diff
changeset
|
4423 | imhtml->edit.backcolor = NULL; |
|
13224
485977c61b47
[gaim-migrate @ 15587]
Richard Laager <rlaager@pidgin.im>
parents:
13138
diff
changeset
|
4424 | |
|
485977c61b47
[gaim-migrate @ 15587]
Richard Laager <rlaager@pidgin.im>
parents:
13138
diff
changeset
|
4425 | g_free(imhtml->edit.background); |
|
12672
673e2a1d2954
[gaim-migrate @ 15015]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12635
diff
changeset
|
4426 | imhtml->edit.background = NULL; |
|
673e2a1d2954
[gaim-migrate @ 15015]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12635
diff
changeset
|
4427 | } |
|
673e2a1d2954
[gaim-migrate @ 15015]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12635
diff
changeset
|
4428 | |
| 8677 | 4429 | /* Editable stuff */ |
| 4430 | static void preinsert_cb(GtkTextBuffer *buffer, GtkTextIter *iter, gchar *text, gint len, GtkIMHtml *imhtml) | |
| 4431 | { | |
| 4432 | imhtml->insert_offset = gtk_text_iter_get_offset(iter); | |
| 4433 | } | |
| 4434 | ||
| 10169 | 4435 | static void insert_ca_cb(GtkTextBuffer *buffer, GtkTextIter *arg1, GtkTextChildAnchor *arg2, gpointer user_data) |
| 4436 | { | |
| 4437 | GtkTextIter start; | |
| 4438 | ||
| 4439 | start = *arg1; | |
| 4440 | gtk_text_iter_backward_char(&start); | |
| 4441 | ||
| 4442 | gtk_imhtml_apply_tags_on_insert(user_data, &start, arg1); | |
| 4443 | } | |
| 4444 | ||
| 8677 | 4445 | static void insert_cb(GtkTextBuffer *buffer, GtkTextIter *end, gchar *text, gint len, GtkIMHtml *imhtml) |
| 4446 | { | |
| 4447 | GtkTextIter start; | |
| 4448 | ||
| 4449 | if (!len) | |
| 4450 | return; | |
| 4451 | ||
| 4452 | start = *end; | |
| 4453 | gtk_text_iter_set_offset(&start, imhtml->insert_offset); | |
| 4454 | ||
| 10169 | 4455 | gtk_imhtml_apply_tags_on_insert(imhtml, &start, end); |
| 4456 | } | |
| 4457 | ||
|
12673
4c8a20955e0b
[gaim-migrate @ 15016]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12672
diff
changeset
|
4458 | 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
|
4459 | { |
|
4c8a20955e0b
[gaim-migrate @ 15016]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12672
diff
changeset
|
4460 | GSList *tags, *l; |
|
4c8a20955e0b
[gaim-migrate @ 15016]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12672
diff
changeset
|
4461 | |
|
4c8a20955e0b
[gaim-migrate @ 15016]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12672
diff
changeset
|
4462 | tags = gtk_text_iter_get_tags(start); |
|
4c8a20955e0b
[gaim-migrate @ 15016]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12672
diff
changeset
|
4463 | for (l = tags; l != NULL; l = l->next) { |
|
4c8a20955e0b
[gaim-migrate @ 15016]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12672
diff
changeset
|
4464 | GtkTextTag *tag = GTK_TEXT_TAG(l->data); |
|
4c8a20955e0b
[gaim-migrate @ 15016]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12672
diff
changeset
|
4465 | |
|
4c8a20955e0b
[gaim-migrate @ 15016]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12672
diff
changeset
|
4466 | if (tag && /* Remove the formatting only if */ |
|
4c8a20955e0b
[gaim-migrate @ 15016]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12672
diff
changeset
|
4467 | gtk_text_iter_starts_word(start) && /* beginning of a word */ |
|
4c8a20955e0b
[gaim-migrate @ 15016]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12672
diff
changeset
|
4468 | 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
|
4469 | (!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
|
4470 | gtk_text_iter_ends_tag(end, tag))) { |
|
32413
00ad036bdf3d
Fix some indenting.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32412
diff
changeset
|
4471 | gchar *name = NULL; |
|
00ad036bdf3d
Fix some indenting.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32412
diff
changeset
|
4472 | |
|
00ad036bdf3d
Fix some indenting.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32412
diff
changeset
|
4473 | g_object_get(G_OBJECT(tag), "name", &name, NULL); |
|
12673
4c8a20955e0b
[gaim-migrate @ 15016]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12672
diff
changeset
|
4474 | gtk_text_buffer_remove_tag(imhtml->text_buffer, tag, start, end); |
|
32394
f883709bdba4
compiles using GTK+ 3 from git, beware it does not yet run, in fact it crashes...
Marcus Lundblad <malu@pidgin.im>
parents:
31207
diff
changeset
|
4475 | |
|
32413
00ad036bdf3d
Fix some indenting.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32412
diff
changeset
|
4476 | if (name && strncmp(name, "LINK ", 5) == 0 && imhtml->edit.link) { |
|
12673
4c8a20955e0b
[gaim-migrate @ 15016]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12672
diff
changeset
|
4477 | gtk_imhtml_toggle_link(imhtml, NULL); |
|
4c8a20955e0b
[gaim-migrate @ 15016]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12672
diff
changeset
|
4478 | } |
|
32394
f883709bdba4
compiles using GTK+ 3 from git, beware it does not yet run, in fact it crashes...
Marcus Lundblad <malu@pidgin.im>
parents:
31207
diff
changeset
|
4479 | |
|
32413
00ad036bdf3d
Fix some indenting.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32412
diff
changeset
|
4480 | g_free(name); |
|
14097
0c340861ab79
[gaim-migrate @ 16638]
Mark Doliner <markdoliner@pidgin.im>
parents:
14010
diff
changeset
|
4481 | } |
|
12673
4c8a20955e0b
[gaim-migrate @ 15016]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12672
diff
changeset
|
4482 | } |
|
4c8a20955e0b
[gaim-migrate @ 15016]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12672
diff
changeset
|
4483 | g_slist_free(tags); |
|
4c8a20955e0b
[gaim-migrate @ 15016]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12672
diff
changeset
|
4484 | } |
|
4c8a20955e0b
[gaim-migrate @ 15016]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12672
diff
changeset
|
4485 | |
| 10169 | 4486 | static void gtk_imhtml_apply_tags_on_insert(GtkIMHtml *imhtml, GtkTextIter *start, GtkTextIter *end) |
| 4487 | { | |
| 8677 | 4488 | if (imhtml->edit.bold) |
| 10169 | 4489 | gtk_text_buffer_apply_tag_by_name(imhtml->text_buffer, "BOLD", start, end); |
| 8677 | 4490 | else |
| 10169 | 4491 | gtk_text_buffer_remove_tag_by_name(imhtml->text_buffer, "BOLD", start, end); |
| 8677 | 4492 | |
| 4493 | if (imhtml->edit.italic) | |
| 10169 | 4494 | gtk_text_buffer_apply_tag_by_name(imhtml->text_buffer, "ITALICS", start, end); |
| 8677 | 4495 | else |
| 10169 | 4496 | gtk_text_buffer_remove_tag_by_name(imhtml->text_buffer, "ITALICS", start, end); |
| 8677 | 4497 | |
| 4498 | if (imhtml->edit.underline) | |
| 10169 | 4499 | gtk_text_buffer_apply_tag_by_name(imhtml->text_buffer, "UNDERLINE", start, end); |
| 8677 | 4500 | else |
| 10169 | 4501 | gtk_text_buffer_remove_tag_by_name(imhtml->text_buffer, "UNDERLINE", start, end); |
| 8677 | 4502 | |
| 9924 | 4503 | if (imhtml->edit.strike) |
| 10169 | 4504 | gtk_text_buffer_apply_tag_by_name(imhtml->text_buffer, "STRIKE", start, end); |
| 9924 | 4505 | else |
| 10169 | 4506 | gtk_text_buffer_remove_tag_by_name(imhtml->text_buffer, "STRIKE", start, end); |
| 9924 | 4507 | |
| 8677 | 4508 | if (imhtml->edit.forecolor) { |
| 10169 | 4509 | remove_font_forecolor(imhtml, start, end, TRUE); |
| 8677 | 4510 | gtk_text_buffer_apply_tag(imhtml->text_buffer, |
| 4511 | find_font_forecolor_tag(imhtml, imhtml->edit.forecolor), | |
| 10169 | 4512 | start, end); |
| 8061 | 4513 | } |
| 4514 | ||
| 8677 | 4515 | if (imhtml->edit.backcolor) { |
| 10169 | 4516 | remove_font_backcolor(imhtml, start, end, TRUE); |
| 8677 | 4517 | gtk_text_buffer_apply_tag(imhtml->text_buffer, |
| 4518 | find_font_backcolor_tag(imhtml, imhtml->edit.backcolor), | |
| 10169 | 4519 | start, end); |
| 8677 | 4520 | } |
| 4521 | ||
| 10776 | 4522 | if (imhtml->edit.background) { |
| 4523 | remove_font_background(imhtml, start, end, TRUE); | |
| 4524 | gtk_text_buffer_apply_tag(imhtml->text_buffer, | |
| 4525 | find_font_background_tag(imhtml, imhtml->edit.background), | |
| 4526 | start, end); | |
| 4527 | } | |
| 8677 | 4528 | if (imhtml->edit.fontface) { |
| 10169 | 4529 | remove_font_face(imhtml, start, end, TRUE); |
| 8677 | 4530 | gtk_text_buffer_apply_tag(imhtml->text_buffer, |
| 4531 | find_font_face_tag(imhtml, imhtml->edit.fontface), | |
| 10169 | 4532 | start, end); |
| 8061 | 4533 | } |
| 8677 | 4534 | |
| 4535 | if (imhtml->edit.fontsize) { | |
| 10169 | 4536 | remove_font_size(imhtml, start, end, TRUE); |
| 8677 | 4537 | gtk_text_buffer_apply_tag(imhtml->text_buffer, |
| 4538 | find_font_size_tag(imhtml, imhtml->edit.fontsize), | |
| 10169 | 4539 | start, end); |
| 8677 | 4540 | } |
| 4541 | ||
| 4542 | if (imhtml->edit.link) { | |
| 10169 | 4543 | remove_font_link(imhtml, start, end, TRUE); |
| 8677 | 4544 | gtk_text_buffer_apply_tag(imhtml->text_buffer, |
| 4545 | imhtml->edit.link, | |
| 10169 | 4546 | start, end); |
| 8677 | 4547 | } |
| 8061 | 4548 | } |
| 4549 | ||
| 4550 | void gtk_imhtml_set_editable(GtkIMHtml *imhtml, gboolean editable) | |
| 4551 | { | |
| 4552 | gtk_text_view_set_editable(GTK_TEXT_VIEW(imhtml), editable); | |
|
8177
33b3a01c6318
[gaim-migrate @ 8891]
Mark Doliner <markdoliner@pidgin.im>
parents:
8149
diff
changeset
|
4553 | /* |
|
33b3a01c6318
[gaim-migrate @ 8891]
Mark Doliner <markdoliner@pidgin.im>
parents:
8149
diff
changeset
|
4554 | * We need a visible caret for accessibility, so mouseless |
|
33b3a01c6318
[gaim-migrate @ 8891]
Mark Doliner <markdoliner@pidgin.im>
parents:
8149
diff
changeset
|
4555 | * people can highlight stuff. |
|
33b3a01c6318
[gaim-migrate @ 8891]
Mark Doliner <markdoliner@pidgin.im>
parents:
8149
diff
changeset
|
4556 | */ |
|
33b3a01c6318
[gaim-migrate @ 8891]
Mark Doliner <markdoliner@pidgin.im>
parents:
8149
diff
changeset
|
4557 | /* 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
|
4558 | if (editable && !imhtml->editable) { |
| 8677 | 4559 | 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
|
4560 | 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
|
4561 | 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
|
4562 | } 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
|
4563 | 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
|
4564 | 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
|
4565 | 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
|
4566 | 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
|
4567 | } |
|
27031
6779a535047e
Avoid adding several callbacks on repeated invocations of gtk_imhtml_set_editable.
Daniel Atallah <datallah@pidgin.im>
parents:
26829
diff
changeset
|
4568 | |
|
6779a535047e
Avoid adding several callbacks on repeated invocations of gtk_imhtml_set_editable.
Daniel Atallah <datallah@pidgin.im>
parents:
26829
diff
changeset
|
4569 | 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
|
4570 | imhtml->format_functions = GTK_IMHTML_ALL; |
| 8677 | 4571 | } |
| 4572 | ||
| 4573 | void gtk_imhtml_set_whole_buffer_formatting_only(GtkIMHtml *imhtml, gboolean wbfo) | |
| 4574 | { | |
| 4575 | g_return_if_fail(imhtml != NULL); | |
| 4576 | ||
| 4577 | imhtml->wbfo = wbfo; | |
| 8420 | 4578 | } |
| 4579 | ||
| 4580 | void gtk_imhtml_set_format_functions(GtkIMHtml *imhtml, GtkIMHtmlButtons buttons) | |
| 4581 | { | |
| 4582 | GObject *object = g_object_ref(G_OBJECT(imhtml)); | |
| 8677 | 4583 | imhtml->format_functions = buttons; |
| 8420 | 4584 | g_signal_emit(object, signals[BUTTONS_UPDATE], 0, buttons); |
| 4585 | g_object_unref(object); | |
| 8061 | 4586 | } |
| 4587 | ||
|
8788
a13634443a38
[gaim-migrate @ 9550]
Mark Doliner <markdoliner@pidgin.im>
parents:
8786
diff
changeset
|
4588 | GtkIMHtmlButtons gtk_imhtml_get_format_functions(GtkIMHtml *imhtml) |
|
a13634443a38
[gaim-migrate @ 9550]
Mark Doliner <markdoliner@pidgin.im>
parents:
8786
diff
changeset
|
4589 | { |
|
a13634443a38
[gaim-migrate @ 9550]
Mark Doliner <markdoliner@pidgin.im>
parents:
8786
diff
changeset
|
4590 | return imhtml->format_functions; |
|
a13634443a38
[gaim-migrate @ 9550]
Mark Doliner <markdoliner@pidgin.im>
parents:
8786
diff
changeset
|
4591 | } |
| 8516 | 4592 | |
| 4593 | void gtk_imhtml_get_current_format(GtkIMHtml *imhtml, gboolean *bold, | |
| 4594 | gboolean *italic, gboolean *underline) | |
| 8481 | 4595 | { |
|
12900
7fe519669e07
[gaim-migrate @ 15253]
Richard Laager <rlaager@pidgin.im>
parents:
12836
diff
changeset
|
4596 | if (bold != NULL) |
|
7fe519669e07
[gaim-migrate @ 15253]
Richard Laager <rlaager@pidgin.im>
parents:
12836
diff
changeset
|
4597 | (*bold) = imhtml->edit.bold; |
|
7fe519669e07
[gaim-migrate @ 15253]
Richard Laager <rlaager@pidgin.im>
parents:
12836
diff
changeset
|
4598 | if (italic != NULL) |
|
7fe519669e07
[gaim-migrate @ 15253]
Richard Laager <rlaager@pidgin.im>
parents:
12836
diff
changeset
|
4599 | (*italic) = imhtml->edit.italic; |
|
7fe519669e07
[gaim-migrate @ 15253]
Richard Laager <rlaager@pidgin.im>
parents:
12836
diff
changeset
|
4600 | if (underline != NULL) |
|
7fe519669e07
[gaim-migrate @ 15253]
Richard Laager <rlaager@pidgin.im>
parents:
12836
diff
changeset
|
4601 | (*underline) = imhtml->edit.underline; |
| 8481 | 4602 | } |
| 4603 | ||
| 9025 | 4604 | char * |
| 4605 | gtk_imhtml_get_current_fontface(GtkIMHtml *imhtml) | |
| 4606 | { | |
|
14097
0c340861ab79
[gaim-migrate @ 16638]
Mark Doliner <markdoliner@pidgin.im>
parents:
14010
diff
changeset
|
4607 | return g_strdup(imhtml->edit.fontface); |
| 9025 | 4608 | } |
| 4609 | ||
| 4610 | char * | |
| 4611 | gtk_imhtml_get_current_forecolor(GtkIMHtml *imhtml) | |
| 4612 | { | |
|
14097
0c340861ab79
[gaim-migrate @ 16638]
Mark Doliner <markdoliner@pidgin.im>
parents:
14010
diff
changeset
|
4613 | return g_strdup(imhtml->edit.forecolor); |
| 9025 | 4614 | } |
| 4615 | ||
| 4616 | char * | |
| 4617 | gtk_imhtml_get_current_backcolor(GtkIMHtml *imhtml) | |
| 4618 | { | |
|
14097
0c340861ab79
[gaim-migrate @ 16638]
Mark Doliner <markdoliner@pidgin.im>
parents:
14010
diff
changeset
|
4619 | return g_strdup(imhtml->edit.backcolor); |
| 9025 | 4620 | } |
| 4621 | ||
|
11267
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
4622 | char * |
|
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
4623 | gtk_imhtml_get_current_background(GtkIMHtml *imhtml) |
|
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
4624 | { |
|
14097
0c340861ab79
[gaim-migrate @ 16638]
Mark Doliner <markdoliner@pidgin.im>
parents:
14010
diff
changeset
|
4625 | return g_strdup(imhtml->edit.background); |
|
11267
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
4626 | } |
|
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
4627 | |
| 9025 | 4628 | gint |
| 4629 | gtk_imhtml_get_current_fontsize(GtkIMHtml *imhtml) | |
| 4630 | { | |
| 4631 | return imhtml->edit.fontsize; | |
| 4632 | } | |
| 4633 | ||
| 8061 | 4634 | gboolean gtk_imhtml_get_editable(GtkIMHtml *imhtml) |
| 4635 | { | |
| 4636 | return imhtml->editable; | |
| 4637 | } | |
| 4638 | ||
|
11269
ca63789d57b9
[gaim-migrate @ 13451]
Richard Laager <rlaager@pidgin.im>
parents:
11267
diff
changeset
|
4639 | void |
|
ca63789d57b9
[gaim-migrate @ 13451]
Richard Laager <rlaager@pidgin.im>
parents:
11267
diff
changeset
|
4640 | gtk_imhtml_clear_formatting(GtkIMHtml *imhtml) |
|
ca63789d57b9
[gaim-migrate @ 13451]
Richard Laager <rlaager@pidgin.im>
parents:
11267
diff
changeset
|
4641 | { |
|
11275
cdcc651d7ecd
[gaim-migrate @ 13461]
Richard Laager <rlaager@pidgin.im>
parents:
11269
diff
changeset
|
4642 | GObject *object; |
|
cdcc651d7ecd
[gaim-migrate @ 13461]
Richard Laager <rlaager@pidgin.im>
parents:
11269
diff
changeset
|
4643 | |
|
cdcc651d7ecd
[gaim-migrate @ 13461]
Richard Laager <rlaager@pidgin.im>
parents:
11269
diff
changeset
|
4644 | object = g_object_ref(G_OBJECT(imhtml)); |
|
cdcc651d7ecd
[gaim-migrate @ 13461]
Richard Laager <rlaager@pidgin.im>
parents:
11269
diff
changeset
|
4645 | g_signal_emit(object, signals[CLEAR_FORMAT], 0); |
|
11276
aec923529d31
[gaim-migrate @ 13463]
Richard Laager <rlaager@pidgin.im>
parents:
11275
diff
changeset
|
4646 | |
|
11269
ca63789d57b9
[gaim-migrate @ 13451]
Richard Laager <rlaager@pidgin.im>
parents:
11267
diff
changeset
|
4647 | gtk_widget_grab_focus(GTK_WIDGET(imhtml)); |
|
11276
aec923529d31
[gaim-migrate @ 13463]
Richard Laager <rlaager@pidgin.im>
parents:
11275
diff
changeset
|
4648 | |
|
aec923529d31
[gaim-migrate @ 13463]
Richard Laager <rlaager@pidgin.im>
parents:
11275
diff
changeset
|
4649 | g_object_unref(object); |
|
11269
ca63789d57b9
[gaim-migrate @ 13451]
Richard Laager <rlaager@pidgin.im>
parents:
11267
diff
changeset
|
4650 | } |
|
ca63789d57b9
[gaim-migrate @ 13451]
Richard Laager <rlaager@pidgin.im>
parents:
11267
diff
changeset
|
4651 | |
| 8677 | 4652 | /* |
| 4653 | * I had this crazy idea about changing the text cursor color to reflex the foreground color | |
| 4654 | * of the text about to be entered. This is the place you'd do it, along with the place where | |
| 4655 | * we actually set a new foreground color. | |
| 15884 | 4656 | * I may not do this, because people will bitch about Purple overriding their gtk theme's cursor |
| 8677 | 4657 | * colors. |
| 4658 | * | |
| 4659 | * Just in case I do do this, I asked about what to set the secondary text cursor to. | |
| 4660 | * | |
| 8719 | 4661 | * (12:45:27) ?? ???: secondary_cursor_color = (rgb(background) + rgb(primary_cursor_color) ) / 2 |
| 4662 | * (12:45:55) ?? ???: understand? | |
| 8677 | 4663 | * (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
|
4664 | * (12:46:56) ?? ???: u might need to extract separate each color from RGB |
| 8677 | 4665 | */ |
| 4666 | ||
| 4667 | static void mark_set_cb(GtkTextBuffer *buffer, GtkTextIter *arg1, GtkTextMark *mark, | |
| 4668 | GtkIMHtml *imhtml) | |
| 4669 | { | |
| 4670 | GSList *tags, *l; | |
| 4671 | GtkTextIter iter; | |
| 4672 | ||
| 4673 | if (mark != gtk_text_buffer_get_insert(buffer)) | |
| 4674 | return; | |
| 4675 | ||
| 4676 | if (!gtk_text_buffer_get_char_count(buffer)) | |
| 4677 | return; | |
| 4678 | ||
| 9924 | 4679 | 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
|
4680 | g_free(imhtml->edit.forecolor); |
| 8677 | 4681 | imhtml->edit.forecolor = NULL; |
|
14097
0c340861ab79
[gaim-migrate @ 16638]
Mark Doliner <markdoliner@pidgin.im>
parents:
14010
diff
changeset
|
4682 | |
|
0c340861ab79
[gaim-migrate @ 16638]
Mark Doliner <markdoliner@pidgin.im>
parents:
14010
diff
changeset
|
4683 | g_free(imhtml->edit.backcolor); |
| 8677 | 4684 | imhtml->edit.backcolor = NULL; |
|
14097
0c340861ab79
[gaim-migrate @ 16638]
Mark Doliner <markdoliner@pidgin.im>
parents:
14010
diff
changeset
|
4685 | |
|
0c340861ab79
[gaim-migrate @ 16638]
Mark Doliner <markdoliner@pidgin.im>
parents:
14010
diff
changeset
|
4686 | g_free(imhtml->edit.fontface); |
| 8677 | 4687 | imhtml->edit.fontface = NULL; |
|
14097
0c340861ab79
[gaim-migrate @ 16638]
Mark Doliner <markdoliner@pidgin.im>
parents:
14010
diff
changeset
|
4688 | |
| 8677 | 4689 | imhtml->edit.fontsize = 0; |
| 4690 | imhtml->edit.link = NULL; | |
| 4691 | ||
| 4692 | gtk_text_buffer_get_iter_at_mark(imhtml->text_buffer, &iter, mark); | |
| 4693 | ||
| 4694 | ||
| 4695 | if (gtk_text_iter_is_end(&iter)) | |
| 4696 | tags = gtk_text_iter_get_toggled_tags(&iter, FALSE); | |
| 4697 | else | |
| 4698 | tags = gtk_text_iter_get_tags(&iter); | |
| 4699 | ||
| 4700 | for (l = tags; l != NULL; l = l->next) { | |
| 4701 | GtkTextTag *tag = GTK_TEXT_TAG(l->data); | |
|
32413
00ad036bdf3d
Fix some indenting.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32412
diff
changeset
|
4702 | gchar *name = NULL; |
|
00ad036bdf3d
Fix some indenting.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32412
diff
changeset
|
4703 | |
|
00ad036bdf3d
Fix some indenting.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32412
diff
changeset
|
4704 | g_object_get(G_OBJECT(tag), "name", &name, NULL); |
|
00ad036bdf3d
Fix some indenting.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32412
diff
changeset
|
4705 | |
|
32394
f883709bdba4
compiles using GTK+ 3 from git, beware it does not yet run, in fact it crashes...
Marcus Lundblad <malu@pidgin.im>
parents:
31207
diff
changeset
|
4706 | if (name) { |
|
f883709bdba4
compiles using GTK+ 3 from git, beware it does not yet run, in fact it crashes...
Marcus Lundblad <malu@pidgin.im>
parents:
31207
diff
changeset
|
4707 | if (strcmp(name, "BOLD") == 0) |
| 8677 | 4708 | imhtml->edit.bold = TRUE; |
|
32394
f883709bdba4
compiles using GTK+ 3 from git, beware it does not yet run, in fact it crashes...
Marcus Lundblad <malu@pidgin.im>
parents:
31207
diff
changeset
|
4709 | else if (strcmp(name, "ITALICS") == 0) |
| 8677 | 4710 | imhtml->edit.italic = TRUE; |
|
32394
f883709bdba4
compiles using GTK+ 3 from git, beware it does not yet run, in fact it crashes...
Marcus Lundblad <malu@pidgin.im>
parents:
31207
diff
changeset
|
4711 | else if (strcmp(name, "UNDERLINE") == 0) |
| 8677 | 4712 | imhtml->edit.underline = TRUE; |
|
32394
f883709bdba4
compiles using GTK+ 3 from git, beware it does not yet run, in fact it crashes...
Marcus Lundblad <malu@pidgin.im>
parents:
31207
diff
changeset
|
4713 | else if (strcmp(name, "STRIKE") == 0) |
| 9924 | 4714 | imhtml->edit.strike = TRUE; |
|
32394
f883709bdba4
compiles using GTK+ 3 from git, beware it does not yet run, in fact it crashes...
Marcus Lundblad <malu@pidgin.im>
parents:
31207
diff
changeset
|
4715 | else if (strncmp(name, "FORECOLOR ", 10) == 0) |
|
f883709bdba4
compiles using GTK+ 3 from git, beware it does not yet run, in fact it crashes...
Marcus Lundblad <malu@pidgin.im>
parents:
31207
diff
changeset
|
4716 | imhtml->edit.forecolor = g_strdup(&(name)[10]); |
|
f883709bdba4
compiles using GTK+ 3 from git, beware it does not yet run, in fact it crashes...
Marcus Lundblad <malu@pidgin.im>
parents:
31207
diff
changeset
|
4717 | else if (strncmp(name, "BACKCOLOR ", 10) == 0) |
|
f883709bdba4
compiles using GTK+ 3 from git, beware it does not yet run, in fact it crashes...
Marcus Lundblad <malu@pidgin.im>
parents:
31207
diff
changeset
|
4718 | imhtml->edit.backcolor = g_strdup(&(name)[10]); |
|
f883709bdba4
compiles using GTK+ 3 from git, beware it does not yet run, in fact it crashes...
Marcus Lundblad <malu@pidgin.im>
parents:
31207
diff
changeset
|
4719 | else if (strncmp(name, "FONT FACE ", 10) == 0) |
|
f883709bdba4
compiles using GTK+ 3 from git, beware it does not yet run, in fact it crashes...
Marcus Lundblad <malu@pidgin.im>
parents:
31207
diff
changeset
|
4720 | imhtml->edit.fontface = g_strdup(&(name)[10]); |
|
f883709bdba4
compiles using GTK+ 3 from git, beware it does not yet run, in fact it crashes...
Marcus Lundblad <malu@pidgin.im>
parents:
31207
diff
changeset
|
4721 | else if (strncmp(name, "FONT SIZE ", 10) == 0) |
|
f883709bdba4
compiles using GTK+ 3 from git, beware it does not yet run, in fact it crashes...
Marcus Lundblad <malu@pidgin.im>
parents:
31207
diff
changeset
|
4722 | imhtml->edit.fontsize = strtol(&(name)[10], NULL, 10); |
|
f883709bdba4
compiles using GTK+ 3 from git, beware it does not yet run, in fact it crashes...
Marcus Lundblad <malu@pidgin.im>
parents:
31207
diff
changeset
|
4723 | else if ((strncmp(name, "LINK ", 5) == 0) && !gtk_text_iter_is_end(&iter)) |
| 8677 | 4724 | imhtml->edit.link = tag; |
| 4725 | } | |
|
32394
f883709bdba4
compiles using GTK+ 3 from git, beware it does not yet run, in fact it crashes...
Marcus Lundblad <malu@pidgin.im>
parents:
31207
diff
changeset
|
4726 | |
|
32413
00ad036bdf3d
Fix some indenting.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32412
diff
changeset
|
4727 | g_free(name); |
| 8677 | 4728 | } |
| 4729 | ||
| 4730 | g_slist_free(tags); | |
| 4731 | } | |
| 4732 | ||
|
12605
7390627a6aaf
[gaim-migrate @ 14940]
Richard Laager <rlaager@pidgin.im>
parents:
12600
diff
changeset
|
4733 | static void imhtml_emit_signal_for_format(GtkIMHtml *imhtml, GtkIMHtmlButtons button) |
|
7390627a6aaf
[gaim-migrate @ 14940]
Richard Laager <rlaager@pidgin.im>
parents:
12600
diff
changeset
|
4734 | { |
|
7390627a6aaf
[gaim-migrate @ 14940]
Richard Laager <rlaager@pidgin.im>
parents:
12600
diff
changeset
|
4735 | GObject *object; |
|
7390627a6aaf
[gaim-migrate @ 14940]
Richard Laager <rlaager@pidgin.im>
parents:
12600
diff
changeset
|
4736 | |
|
7390627a6aaf
[gaim-migrate @ 14940]
Richard Laager <rlaager@pidgin.im>
parents:
12600
diff
changeset
|
4737 | g_return_if_fail(imhtml != NULL); |
|
7390627a6aaf
[gaim-migrate @ 14940]
Richard Laager <rlaager@pidgin.im>
parents:
12600
diff
changeset
|
4738 | |
|
7390627a6aaf
[gaim-migrate @ 14940]
Richard Laager <rlaager@pidgin.im>
parents:
12600
diff
changeset
|
4739 | object = g_object_ref(G_OBJECT(imhtml)); |
|
7390627a6aaf
[gaim-migrate @ 14940]
Richard Laager <rlaager@pidgin.im>
parents:
12600
diff
changeset
|
4740 | g_signal_emit(object, signals[TOGGLE_FORMAT], 0, button); |
|
7390627a6aaf
[gaim-migrate @ 14940]
Richard Laager <rlaager@pidgin.im>
parents:
12600
diff
changeset
|
4741 | g_object_unref(object); |
|
7390627a6aaf
[gaim-migrate @ 14940]
Richard Laager <rlaager@pidgin.im>
parents:
12600
diff
changeset
|
4742 | } |
|
7390627a6aaf
[gaim-migrate @ 14940]
Richard Laager <rlaager@pidgin.im>
parents:
12600
diff
changeset
|
4743 | |
|
11267
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
4744 | static void imhtml_toggle_bold(GtkIMHtml *imhtml) |
| 8061 | 4745 | { |
| 8677 | 4746 | GtkTextIter start, end; |
| 4747 | ||
| 4748 | imhtml->edit.bold = !imhtml->edit.bold; | |
| 4749 | ||
|
28935
84dbc0ca215d
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28932
diff
changeset
|
4750 | 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
|
4751 | return; |
|
84dbc0ca215d
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28932
diff
changeset
|
4752 | |
|
84dbc0ca215d
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28932
diff
changeset
|
4753 | if (imhtml->edit.bold) |
|
84dbc0ca215d
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28932
diff
changeset
|
4754 | 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
|
4755 | else |
|
84dbc0ca215d
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28932
diff
changeset
|
4756 | gtk_text_buffer_remove_tag_by_name(imhtml->text_buffer, "BOLD", &start, &end); |
| 8061 | 4757 | } |
| 4758 | ||
|
11267
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
4759 | void gtk_imhtml_toggle_bold(GtkIMHtml *imhtml) |
| 8061 | 4760 | { |
|
12605
7390627a6aaf
[gaim-migrate @ 14940]
Richard Laager <rlaager@pidgin.im>
parents:
12600
diff
changeset
|
4761 | imhtml_emit_signal_for_format(imhtml, GTK_IMHTML_BOLD); |
|
11267
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
4762 | } |
|
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
4763 | |
|
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
4764 | static void imhtml_toggle_italic(GtkIMHtml *imhtml) |
|
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
4765 | { |
| 8677 | 4766 | GtkTextIter start, end; |
| 4767 | ||
| 4768 | imhtml->edit.italic = !imhtml->edit.italic; | |
| 4769 | ||
|
28935
84dbc0ca215d
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28932
diff
changeset
|
4770 | 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
|
4771 | return; |
|
84dbc0ca215d
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28932
diff
changeset
|
4772 | |
|
84dbc0ca215d
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28932
diff
changeset
|
4773 | if (imhtml->edit.italic) |
|
84dbc0ca215d
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28932
diff
changeset
|
4774 | 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
|
4775 | else |
|
84dbc0ca215d
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28932
diff
changeset
|
4776 | gtk_text_buffer_remove_tag_by_name(imhtml->text_buffer, "ITALICS", &start, &end); |
| 8061 | 4777 | } |
| 4778 | ||
|
11267
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
4779 | void gtk_imhtml_toggle_italic(GtkIMHtml *imhtml) |
| 8061 | 4780 | { |
|
12605
7390627a6aaf
[gaim-migrate @ 14940]
Richard Laager <rlaager@pidgin.im>
parents:
12600
diff
changeset
|
4781 | imhtml_emit_signal_for_format(imhtml, GTK_IMHTML_ITALIC); |
|
7390627a6aaf
[gaim-migrate @ 14940]
Richard Laager <rlaager@pidgin.im>
parents:
12600
diff
changeset
|
4782 | } |
|
11267
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
4783 | |
|
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
4784 | static void imhtml_toggle_underline(GtkIMHtml *imhtml) |
|
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
4785 | { |
| 8677 | 4786 | GtkTextIter start, end; |
| 4787 | ||
| 4788 | imhtml->edit.underline = !imhtml->edit.underline; | |
| 4789 | ||
|
28935
84dbc0ca215d
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28932
diff
changeset
|
4790 | 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
|
4791 | return; |
|
84dbc0ca215d
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28932
diff
changeset
|
4792 | |
|
84dbc0ca215d
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28932
diff
changeset
|
4793 | if (imhtml->edit.underline) |
|
84dbc0ca215d
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28932
diff
changeset
|
4794 | 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
|
4795 | else |
|
84dbc0ca215d
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28932
diff
changeset
|
4796 | gtk_text_buffer_remove_tag_by_name(imhtml->text_buffer, "UNDERLINE", &start, &end); |
| 8061 | 4797 | } |
| 4798 | ||
|
11267
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
4799 | void gtk_imhtml_toggle_underline(GtkIMHtml *imhtml) |
| 9924 | 4800 | { |
|
12605
7390627a6aaf
[gaim-migrate @ 14940]
Richard Laager <rlaager@pidgin.im>
parents:
12600
diff
changeset
|
4801 | imhtml_emit_signal_for_format(imhtml, GTK_IMHTML_UNDERLINE); |
|
11267
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
4802 | } |
|
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
4803 | |
|
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
4804 | static void imhtml_toggle_strike(GtkIMHtml *imhtml) |
|
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
4805 | { |
| 9924 | 4806 | GtkTextIter start, end; |
| 4807 | ||
| 4808 | imhtml->edit.strike = !imhtml->edit.strike; | |
| 4809 | ||
|
28935
84dbc0ca215d
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28932
diff
changeset
|
4810 | 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
|
4811 | return; |
|
84dbc0ca215d
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28932
diff
changeset
|
4812 | |
|
84dbc0ca215d
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28932
diff
changeset
|
4813 | if (imhtml->edit.strike) |
|
84dbc0ca215d
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28932
diff
changeset
|
4814 | 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
|
4815 | else |
|
84dbc0ca215d
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28932
diff
changeset
|
4816 | 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
|
4817 | } |
|
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
4818 | |
|
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
4819 | void gtk_imhtml_toggle_strike(GtkIMHtml *imhtml) |
|
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
4820 | { |
|
12605
7390627a6aaf
[gaim-migrate @ 14940]
Richard Laager <rlaager@pidgin.im>
parents:
12600
diff
changeset
|
4821 | imhtml_emit_signal_for_format(imhtml, GTK_IMHTML_STRIKE); |
| 9924 | 4822 | } |
| 4823 | ||
| 8061 | 4824 | void gtk_imhtml_font_set_size(GtkIMHtml *imhtml, gint size) |
| 4825 | { | |
| 9025 | 4826 | GObject *object; |
| 8677 | 4827 | GtkTextIter start, end; |
| 8061 | 4828 | |
| 4829 | imhtml->edit.fontsize = size; | |
| 4830 | ||
|
28935
84dbc0ca215d
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28932
diff
changeset
|
4831 | 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
|
4832 | return; |
|
84dbc0ca215d
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28932
diff
changeset
|
4833 | |
|
84dbc0ca215d
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28932
diff
changeset
|
4834 | 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
|
4835 | 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
|
4836 | find_font_size_tag(imhtml, imhtml->edit.fontsize), &start, &end); |
| 8677 | 4837 | |
| 9025 | 4838 | object = g_object_ref(G_OBJECT(imhtml)); |
|
11267
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
4839 | g_signal_emit(object, signals[TOGGLE_FORMAT], 0, GTK_IMHTML_SHRINK | GTK_IMHTML_GROW); |
| 9025 | 4840 | g_object_unref(object); |
| 8061 | 4841 | } |
| 4842 | ||
|
11267
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
4843 | static void imhtml_font_shrink(GtkIMHtml *imhtml) |
| 8061 | 4844 | { |
| 8677 | 4845 | GtkTextIter start, end; |
| 4846 | ||
| 8061 | 4847 | if (imhtml->edit.fontsize == 1) |
| 4848 | return; | |
| 4849 | ||
| 8677 | 4850 | if (!imhtml->edit.fontsize) |
| 4851 | imhtml->edit.fontsize = 2; | |
| 4852 | else | |
| 4853 | imhtml->edit.fontsize--; | |
| 4854 | ||
|
28935
84dbc0ca215d
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28932
diff
changeset
|
4855 | 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
|
4856 | return; |
|
84dbc0ca215d
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28932
diff
changeset
|
4857 | 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
|
4858 | gtk_text_buffer_apply_tag(imhtml->text_buffer, |
| 8677 | 4859 | find_font_size_tag(imhtml, imhtml->edit.fontsize), &start, &end); |
|
11267
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
4860 | } |
|
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
4861 | |
|
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
4862 | void gtk_imhtml_font_shrink(GtkIMHtml *imhtml) |
|
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
4863 | { |
|
12605
7390627a6aaf
[gaim-migrate @ 14940]
Richard Laager <rlaager@pidgin.im>
parents:
12600
diff
changeset
|
4864 | imhtml_emit_signal_for_format(imhtml, GTK_IMHTML_SHRINK); |
| 8061 | 4865 | } |
| 4866 | ||
|
11267
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
4867 | static void imhtml_font_grow(GtkIMHtml *imhtml) |
| 8061 | 4868 | { |
| 8677 | 4869 | GtkTextIter start, end; |
| 4870 | ||
| 8061 | 4871 | if (imhtml->edit.fontsize == MAX_FONT_SIZE) |
| 4872 | return; | |
| 4873 | ||
| 8677 | 4874 | if (!imhtml->edit.fontsize) |
| 4875 | imhtml->edit.fontsize = 4; | |
| 4876 | else | |
| 4877 | imhtml->edit.fontsize++; | |
| 4878 | ||
|
28935
84dbc0ca215d
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28932
diff
changeset
|
4879 | 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
|
4880 | return; |
|
84dbc0ca215d
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28932
diff
changeset
|
4881 | 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
|
4882 | 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
|
4883 | find_font_size_tag(imhtml, imhtml->edit.fontsize), &start, &end); |
|
11267
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
4884 | } |
|
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
4885 | |
|
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
4886 | void gtk_imhtml_font_grow(GtkIMHtml *imhtml) |
|
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
4887 | { |
|
12605
7390627a6aaf
[gaim-migrate @ 14940]
Richard Laager <rlaager@pidgin.im>
parents:
12600
diff
changeset
|
4888 | imhtml_emit_signal_for_format(imhtml, GTK_IMHTML_GROW); |
| 8061 | 4889 | } |
| 4890 | ||
|
13225
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4891 | 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
|
4892 | void (*remove_func)(GtkIMHtml *imhtml, GtkTextIter *i, GtkTextIter *e, gboolean homo), |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4893 | GtkTextTag *(find_func)(GtkIMHtml *imhtml, gchar *color), GtkIMHtmlButtons button) |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4894 | { |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4895 | GObject *object; |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4896 | GtkTextIter start; |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4897 | GtkTextIter end; |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4898 | |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4899 | g_free(*edit_field); |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4900 | *edit_field = NULL; |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4901 | |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4902 | if (value && strcmp(value, "") != 0) |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4903 | { |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4904 | *edit_field = g_strdup(value); |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4905 | |
|
28935
84dbc0ca215d
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28932
diff
changeset
|
4906 | 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
|
4907 | remove_func(imhtml, &start, &end, imhtml->wbfo); |
|
13225
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4908 | 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
|
4909 | find_func(imhtml, *edit_field), &start, &end); |
|
13225
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4910 | } |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4911 | } |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4912 | else |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4913 | { |
|
28935
84dbc0ca215d
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28932
diff
changeset
|
4914 | 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
|
4915 | remove_func(imhtml, &start, &end, TRUE); /* 'TRUE' or 'imhtml->wbfo'? */ |
|
13225
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4916 | } |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4917 | |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4918 | object = g_object_ref(G_OBJECT(imhtml)); |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4919 | g_signal_emit(object, signals[TOGGLE_FORMAT], 0, button); |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4920 | g_object_unref(object); |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4921 | |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4922 | return *edit_field != NULL; |
| 10776 | 4923 | } |
| 4924 | ||
| 8061 | 4925 | gboolean gtk_imhtml_toggle_forecolor(GtkIMHtml *imhtml, const char *color) |
| 4926 | { | |
|
13225
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4927 | return gtk_imhtml_toggle_str_tag(imhtml, color, &imhtml->edit.forecolor, |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4928 | remove_font_forecolor, find_font_forecolor_tag, |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4929 | GTK_IMHTML_FORECOLOR); |
| 8061 | 4930 | } |
| 4931 | ||
| 4932 | gboolean gtk_imhtml_toggle_backcolor(GtkIMHtml *imhtml, const char *color) | |
| 4933 | { | |
|
13225
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4934 | return gtk_imhtml_toggle_str_tag(imhtml, color, &imhtml->edit.backcolor, |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4935 | remove_font_backcolor, find_font_backcolor_tag, |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4936 | GTK_IMHTML_BACKCOLOR); |
| 10776 | 4937 | } |
| 4938 | ||
| 4939 | gboolean gtk_imhtml_toggle_background(GtkIMHtml *imhtml, const char *color) | |
| 4940 | { | |
|
13225
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4941 | return gtk_imhtml_toggle_str_tag(imhtml, color, &imhtml->edit.background, |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4942 | remove_font_background, find_font_background_tag, |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4943 | GTK_IMHTML_BACKGROUND); |
| 8061 | 4944 | } |
| 4945 | ||
| 4946 | gboolean gtk_imhtml_toggle_fontface(GtkIMHtml *imhtml, const char *face) | |
| 4947 | { | |
|
13225
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4948 | return gtk_imhtml_toggle_str_tag(imhtml, face, &imhtml->edit.fontface, |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4949 | remove_font_face, find_font_face_tag, |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4950 | GTK_IMHTML_FACE); |
| 8061 | 4951 | } |
| 4952 | ||
| 8677 | 4953 | void gtk_imhtml_toggle_link(GtkIMHtml *imhtml, const char *url) |
| 8061 | 4954 | { |
| 9025 | 4955 | GObject *object; |
| 8677 | 4956 | GtkTextIter start, end; |
| 4957 | GtkTextTag *linktag; | |
| 4958 | static guint linkno = 0; | |
| 4959 | gchar str[48]; | |
| 9007 | 4960 | GdkColor *color = NULL; |
| 8677 | 4961 | |
| 4962 | imhtml->edit.link = NULL; | |
| 4963 | ||
| 4964 | if (url) { | |
| 4965 | g_snprintf(str, sizeof(str), "LINK %d", linkno++); | |
| 4966 | str[47] = '\0'; | |
| 4967 | ||
| 9007 | 4968 | gtk_widget_style_get(GTK_WIDGET(imhtml), "hyperlink-color", &color, NULL); |
| 9008 | 4969 | if (color) { |
| 9007 | 4970 | imhtml->edit.link = linktag = gtk_text_buffer_create_tag(imhtml->text_buffer, str, "foreground-gdk", color, "underline", PANGO_UNDERLINE_SINGLE, NULL); |
| 9008 | 4971 | gdk_color_free(color); |
| 4972 | } else { | |
| 9007 | 4973 | imhtml->edit.link = linktag = gtk_text_buffer_create_tag(imhtml->text_buffer, str, "foreground", "blue", "underline", PANGO_UNDERLINE_SINGLE, NULL); |
| 9008 | 4974 | } |
| 8677 | 4975 | g_object_set_data_full(G_OBJECT(linktag), "link_url", g_strdup(url), g_free); |
| 4976 | g_signal_connect(G_OBJECT(linktag), "event", G_CALLBACK(tag_event), NULL); | |
| 4977 | ||
|
11276
aec923529d31
[gaim-migrate @ 13463]
Richard Laager <rlaager@pidgin.im>
parents:
11275
diff
changeset
|
4978 | if (imhtml->editable && gtk_text_buffer_get_selection_bounds(imhtml->text_buffer, &start, &end)) { |
| 8677 | 4979 | remove_font_link(imhtml, &start, &end, FALSE); |
| 4980 | gtk_text_buffer_apply_tag(imhtml->text_buffer, linktag, &start, &end); | |
| 4981 | } | |
| 4982 | } | |
| 9025 | 4983 | |
| 4984 | object = g_object_ref(G_OBJECT(imhtml)); | |
| 4985 | g_signal_emit(object, signals[TOGGLE_FORMAT], 0, GTK_IMHTML_LINK); | |
| 4986 | g_object_unref(object); | |
| 8677 | 4987 | } |
| 4988 | ||
| 4989 | void gtk_imhtml_insert_link(GtkIMHtml *imhtml, GtkTextMark *mark, const char *url, const char *text) | |
| 4990 | { | |
| 8061 | 4991 | GtkTextIter iter; |
| 8677 | 4992 | |
|
25899
da25a7ed382e
The first thing gtk_text_buffer_delete_selection does is call
Mark Doliner <markdoliner@pidgin.im>
parents:
25888
diff
changeset
|
4993 | /* 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
|
4994 | gtk_text_buffer_delete_selection(imhtml->text_buffer, TRUE, TRUE); |
| 9599 | 4995 | |
| 8677 | 4996 | gtk_imhtml_toggle_link(imhtml, url); |
| 8061 | 4997 | gtk_text_buffer_get_iter_at_mark(imhtml->text_buffer, &iter, mark); |
| 8677 | 4998 | gtk_text_buffer_insert(imhtml->text_buffer, &iter, text, -1); |
| 4999 | gtk_imhtml_toggle_link(imhtml, NULL); | |
| 8061 | 5000 | } |
| 5001 | ||
| 5002 | void gtk_imhtml_insert_smiley(GtkIMHtml *imhtml, const char *sml, char *smiley) | |
| 5003 | { | |
| 8677 | 5004 | GtkTextMark *mark; |
| 8061 | 5005 | GtkTextIter iter; |
| 8677 | 5006 | |
|
25899
da25a7ed382e
The first thing gtk_text_buffer_delete_selection does is call
Mark Doliner <markdoliner@pidgin.im>
parents:
25888
diff
changeset
|
5007 | /* 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
|
5008 | gtk_text_buffer_delete_selection(imhtml->text_buffer, TRUE, TRUE); |
|
11750
63f951281392
[gaim-migrate @ 14041]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11701
diff
changeset
|
5009 | |
| 8677 | 5010 | mark = gtk_text_buffer_get_insert(imhtml->text_buffer); |
| 5011 | ||
| 5012 | 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
|
5013 | gtk_text_buffer_begin_user_action(imhtml->text_buffer); |
| 8677 | 5014 | 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
|
5015 | gtk_text_buffer_end_user_action(imhtml->text_buffer); |
| 8677 | 5016 | } |
| 5017 | ||
|
32394
f883709bdba4
compiles using GTK+ 3 from git, beware it does not yet run, in fact it crashes...
Marcus Lundblad <malu@pidgin.im>
parents:
31207
diff
changeset
|
5018 | /* TODO: I think this can be removed for GTK+ 3.0... */ |
|
33170
ce4447562d64
Add checks for old GTK+2 stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33132
diff
changeset
|
5019 | #if !GTK_CHECK_VERSION(3,0,0) |
| 13552 | 5020 | static gboolean |
| 5021 | image_expose(GtkWidget *widget, GdkEventExpose *event, gpointer user_data) | |
| 5022 | { | |
| 5023 | GTK_WIDGET_CLASS(GTK_WIDGET_GET_CLASS(widget))->expose_event(widget, event); | |
| 5024 | ||
| 5025 | return TRUE; | |
| 5026 | } | |
|
32394
f883709bdba4
compiles using GTK+ 3 from git, beware it does not yet run, in fact it crashes...
Marcus Lundblad <malu@pidgin.im>
parents:
31207
diff
changeset
|
5027 | #endif |
| 13552 | 5028 | |
|
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
|
5029 | /* In case the smiley gets removed from the imhtml before it gets removed from the queue */ |
|
32394
f883709bdba4
compiles using GTK+ 3 from git, beware it does not yet run, in fact it crashes...
Marcus Lundblad <malu@pidgin.im>
parents:
31207
diff
changeset
|
5030 | static void animated_smiley_destroy_cb(GtkWidget *widget, GtkIMHtml *imhtml) |
|
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
|
5031 | { |
|
aa5b9456e258
Fixes #213 This allows only 20 animated smileys to be animnating at a time
Sean Egan <seanegan@pidgin.im>
parents:
16291
diff
changeset
|
5032 | 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
|
5033 | 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
|
5034 | 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
|
5035 | 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
|
5036 | 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
|
5037 | 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
|
5038 | 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
|
5039 | 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
|
5040 | } |
|
aa5b9456e258
Fixes #213 This allows only 20 animated smileys to be animnating at a time
Sean Egan <seanegan@pidgin.im>
parents:
16291
diff
changeset
|
5041 | 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
|
5042 | } |
|
aa5b9456e258
Fixes #213 This allows only 20 animated smileys to be animnating at a time
Sean Egan <seanegan@pidgin.im>
parents:
16291
diff
changeset
|
5043 | } |
|
aa5b9456e258
Fixes #213 This allows only 20 animated smileys to be animnating at a time
Sean Egan <seanegan@pidgin.im>
parents:
16291
diff
changeset
|
5044 | |
|
32295
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
5045 | 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
|
5046 | { |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
5047 | GdkPixbufAnimation *anim = NULL; |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
5048 | GtkIMHtmlImageSave *save = NULL; |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
5049 | gboolean ret; |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
5050 | |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
5051 | 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
|
5052 | return FALSE; |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
5053 | |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
5054 | anim = gtk_smiley_get_image(smiley); |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
5055 | if (!anim) |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
5056 | return FALSE; |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
5057 | |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
5058 | save = g_new0(GtkIMHtmlImageSave, 1); |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
5059 | 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
|
5060 | 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
|
5061 | destroyed before this GtkIMHtmlImageSave */ |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
5062 | save->datasize = smiley->datasize; |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
5063 | ret = gtk_imhtml_image_clicked(w, event, save); |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
5064 | 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
|
5065 | 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
|
5066 | return ret; |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
5067 | } |
|
5308ecfcf029
Make some gtkimhtml functions private
Mark Doliner <markdoliner@pidgin.im>
parents:
32291
diff
changeset
|
5068 | |
| 8677 | 5069 | void gtk_imhtml_insert_smiley_at_iter(GtkIMHtml *imhtml, const char *sml, char *smiley, GtkTextIter *iter) |
| 5070 | { | |
| 8061 | 5071 | GdkPixbuf *pixbuf = NULL; |
| 5072 | GdkPixbufAnimation *annipixbuf = NULL; | |
| 5073 | 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
|
5074 | 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
|
5075 | 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
|
5076 | 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
|
5077 | 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
|
5078 | 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
|
5079 | |
|
a783b23a05da
Fix CVE-2010-0423, a denial of service attack due to the parsing
Mark Doliner <markdoliner@pidgin.im>
parents:
29371
diff
changeset
|
5080 | /* |
|
a783b23a05da
Fix CVE-2010-0423, a denial of service attack due to the parsing
Mark Doliner <markdoliner@pidgin.im>
parents:
29371
diff
changeset
|
5081 | * 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
|
5082 | * 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
|
5083 | * 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
|
5084 | * 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
|
5085 | */ |
|
31192
57ce28c7314f
gtkimhtml: Display "<3" instead of "<3" after too many smileys in convo
Paul Aurich <darkrain42@pidgin.im>
parents:
30706
diff
changeset
|
5086 | 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
|
5087 | 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
|
5088 | 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
|
5089 | 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
|
5090 | 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
|
5091 | return; |
|
a783b23a05da
Fix CVE-2010-0423, a denial of service attack due to the parsing
Mark Doliner <markdoliner@pidgin.im>
parents:
29371
diff
changeset
|
5092 | } |
|
a783b23a05da
Fix CVE-2010-0423, a denial of service attack due to the parsing
Mark Doliner <markdoliner@pidgin.im>
parents:
29371
diff
changeset
|
5093 | 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
|
5094 | 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
|
5095 | 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
|
5096 | 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
|
5097 | return; |
|
a783b23a05da
Fix CVE-2010-0423, a denial of service attack due to the parsing
Mark Doliner <markdoliner@pidgin.im>
parents:
29371
diff
changeset
|
5098 | } |
|
a783b23a05da
Fix CVE-2010-0423, a denial of service attack due to the parsing
Mark Doliner <markdoliner@pidgin.im>
parents:
29371
diff
changeset
|
5099 | |
|
a783b23a05da
Fix CVE-2010-0423, a denial of service attack due to the parsing
Mark Doliner <markdoliner@pidgin.im>
parents:
29371
diff
changeset
|
5100 | imhtml_smiley = gtk_imhtml_smiley_get(imhtml, sml, unescaped); |
| 8061 | 5101 | |
| 10526 | 5102 | 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
|
5103 | annipixbuf = imhtml_smiley ? gtk_smiley_get_image(imhtml_smiley) : NULL; |
| 10526 | 5104 | if (annipixbuf) { |
| 5105 | if (gdk_pixbuf_animation_is_static_image(annipixbuf)) { | |
|
10522
d505522bcc93
[gaim-migrate @ 11838]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10504
diff
changeset
|
5106 | pixbuf = gdk_pixbuf_animation_get_static_image(annipixbuf); |
| 10526 | 5107 | if (pixbuf) |
|
10522
d505522bcc93
[gaim-migrate @ 11838]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10504
diff
changeset
|
5108 | icon = gtk_image_new_from_pixbuf(pixbuf); |
|
d505522bcc93
[gaim-migrate @ 11838]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10504
diff
changeset
|
5109 | } else { |
|
d505522bcc93
[gaim-migrate @ 11838]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10504
diff
changeset
|
5110 | 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
|
5111 | 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
|
5112 | 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
|
5113 | 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
|
5114 | 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
|
5115 | 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
|
5116 | 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
|
5117 | 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
|
5118 | 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
|
5119 | 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
|
5120 | 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
|
5121 | 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
|
5122 | } |
|
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
|
5123 | } |
|
aa5b9456e258
Fixes #213 This allows only 20 animated smileys to be animnating at a time
Sean Egan <seanegan@pidgin.im>
parents:
16291
diff
changeset
|
5124 | } else { |
|
32422
c215bc5d85e4
Whitespace fixes. Try and check your editor settings before writing
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32414
diff
changeset
|
5125 | imhtml->num_animations++; |
|
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
|
5126 | } |
|
aa5b9456e258
Fixes #213 This allows only 20 animated smileys to be animnating at a time
Sean Egan <seanegan@pidgin.im>
parents:
16291
diff
changeset
|
5127 | 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
|
5128 | g_queue_push_tail(imhtml->animations, icon); |
|
10522
d505522bcc93
[gaim-migrate @ 11838]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10504
diff
changeset
|
5129 | } |
| 8061 | 5130 | } |
| 5131 | } | |
| 5132 | ||
|
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
|
5133 | 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
|
5134 | 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
|
5135 | 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
|
5136 | 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
|
5137 | } |
|
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
|
5138 | |
| 8061 | 5139 | if (icon) { |
| 8890 | 5140 | anchor = gtk_text_buffer_create_child_anchor(imhtml->text_buffer, iter); |
| 29371 | 5141 | g_object_set_data_full(G_OBJECT(anchor), "gtkimhtml_plaintext", g_strdup(unescaped), g_free); |
| 5142 | g_object_set_data_full(G_OBJECT(anchor), "gtkimhtml_tiptext", g_strdup(unescaped), g_free); | |
| 8890 | 5143 | g_object_set_data_full(G_OBJECT(anchor), "gtkimhtml_htmltext", g_strdup(smiley), g_free); |
| 5144 | ||
| 13552 | 5145 | /* This catches the expose events generated by animated |
| 5146 | * images, and ensures that they are handled by the image | |
| 5147 | * itself, without propagating to the textview and causing | |
| 5148 | * a complete refresh */ | |
|
33170
ce4447562d64
Add checks for old GTK+2 stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33132
diff
changeset
|
5149 | /* TODO: I think this should be removed for GTK+ 3.0? */ |
|
ce4447562d64
Add checks for old GTK+2 stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33132
diff
changeset
|
5150 | #if !GTK_CHECK_VERSION(3,0,0) |
| 13552 | 5151 | g_signal_connect(G_OBJECT(icon), "expose-event", G_CALLBACK(image_expose), NULL); |
|
33170
ce4447562d64
Add checks for old GTK+2 stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33132
diff
changeset
|
5152 | #endif |
| 13552 | 5153 | |
| 8061 | 5154 | 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
|
5155 | 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
|
5156 | 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
|
5157 | 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
|
5158 | |
|
a783b23a05da
Fix CVE-2010-0423, a denial of service attack due to the parsing
Mark Doliner <markdoliner@pidgin.im>
parents:
29371
diff
changeset
|
5159 | 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
|
5160 | 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
|
5161 | } 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
|
5162 | 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
|
5163 | 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
|
5164 | 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
|
5165 | 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
|
5166 | 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
|
5167 | gtk_widget_show(img); |
| 29371 | 5168 | g_object_set_data_full(G_OBJECT(anchor), "gtkimhtml_plaintext", g_strdup(unescaped), g_free); |
| 5169 | 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
|
5170 | 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
|
5171 | 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
|
5172 | } |
|
29378
a783b23a05da
Fix CVE-2010-0423, a denial of service attack due to the parsing
Mark Doliner <markdoliner@pidgin.im>
parents:
29371
diff
changeset
|
5173 | |
|
a783b23a05da
Fix CVE-2010-0423, a denial of service attack due to the parsing
Mark Doliner <markdoliner@pidgin.im>
parents:
29371
diff
changeset
|
5174 | 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
|
5175 | g_object_set_data(G_OBJECT(imhtml), "gtkimhtml_numsmileys_total", GINT_TO_POINTER(numsmileys_total + 1)); |
| 8890 | 5176 | } else { |
|
31192
57ce28c7314f
gtkimhtml: Display "<3" instead of "<3" after too many smileys in convo
Paul Aurich <darkrain42@pidgin.im>
parents:
30706
diff
changeset
|
5177 | gtk_text_buffer_insert(imhtml->text_buffer, iter, unescaped, -1); |
| 8061 | 5178 | } |
| 8890 | 5179 | |
|
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
|
5180 | 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
|
5181 | 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
|
5182 | } |
|
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
|
5183 | |
| 8890 | 5184 | g_free(unescaped); |
| 8061 | 5185 | } |
| 5186 | ||
| 8962 | 5187 | void gtk_imhtml_insert_image_at_iter(GtkIMHtml *imhtml, int id, GtkTextIter *iter) |
| 5188 | { | |
|
18151
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
5189 | GdkPixbufAnimation *anim = NULL; |
| 8962 | 5190 | const char *filename = NULL; |
| 5191 | gpointer image; | |
| 5192 | GdkRectangle rect; | |
| 5193 | GtkIMHtmlScalable *scalable = NULL; | |
|
11224
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
5194 | struct scalable_data *sd; |
| 8962 | 5195 | int minus; |
| 5196 | ||
| 5197 | if (!imhtml->funcs || !imhtml->funcs->image_get || | |
| 5198 | !imhtml->funcs->image_get_size || !imhtml->funcs->image_get_data || | |
| 5199 | !imhtml->funcs->image_get_filename || !imhtml->funcs->image_ref || | |
| 5200 | !imhtml->funcs->image_unref) | |
| 5201 | return; | |
| 5202 | ||
| 5203 | image = imhtml->funcs->image_get(id); | |
| 5204 | ||
| 5205 | if (image) { | |
| 5206 | gpointer data; | |
| 5207 | size_t len; | |
| 5208 | ||
| 5209 | data = imhtml->funcs->image_get_data(image); | |
| 5210 | 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
|
5211 | 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
|
5212 | anim = pidgin_pixbuf_anim_from_data(data, len); |
| 8962 | 5213 | |
| 5214 | } | |
| 5215 | ||
|
18151
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
5216 | if (anim) { |
|
11299
06bb44ed0cf3
[gaim-migrate @ 13499]
Richard Laager <rlaager@pidgin.im>
parents:
11276
diff
changeset
|
5217 | struct im_image_data *t = g_new(struct im_image_data, 1); |
| 8962 | 5218 | filename = imhtml->funcs->image_get_filename(image); |
| 5219 | imhtml->funcs->image_ref(id); | |
|
11224
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
5220 | t->id = id; |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
5221 | 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
|
5222 | 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
|
5223 | 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
|
5224 | g_object_unref(G_OBJECT(anim)); |
| 8962 | 5225 | } else { |
|
18151
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
5226 | GdkPixbuf *pixbuf; |
| 8962 | 5227 | pixbuf = gtk_widget_render_icon(GTK_WIDGET(imhtml), GTK_STOCK_MISSING_IMAGE, |
| 5228 | 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
|
5229 | 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
|
5230 | g_object_unref(G_OBJECT(pixbuf)); |
| 8962 | 5231 | } |
| 5232 | ||
|
11224
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
5233 | 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
|
5234 | sd->scalable = scalable; |
|
11233
28c0f184a2d4
[gaim-migrate @ 13373]
Daniel Atallah <datallah@pidgin.im>
parents:
11224
diff
changeset
|
5235 | sd->mark = gtk_text_buffer_create_mark(imhtml->text_buffer, NULL, iter, TRUE); |
| 8962 | 5236 | gtk_text_view_get_visible_rect(GTK_TEXT_VIEW(imhtml), &rect); |
| 5237 | scalable->add_to(scalable, imhtml, iter); | |
| 5238 | minus = gtk_text_view_get_left_margin(GTK_TEXT_VIEW(imhtml)) + | |
| 5239 | gtk_text_view_get_right_margin(GTK_TEXT_VIEW(imhtml)); | |
| 5240 | scalable->scale(scalable, rect.width - minus, rect.height); | |
|
11224
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
5241 | imhtml->scalables = g_list_append(imhtml->scalables, sd); |
| 8962 | 5242 | } |
| 5243 | ||
| 8677 | 5244 | static const gchar *tag_to_html_start(GtkTextTag *tag) |
| 8061 | 5245 | { |
| 8677 | 5246 | static gchar buf[1024]; |
|
32413
00ad036bdf3d
Fix some indenting.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32412
diff
changeset
|
5247 | gchar *name = NULL; |
|
00ad036bdf3d
Fix some indenting.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32412
diff
changeset
|
5248 | |
|
33170
ce4447562d64
Add checks for old GTK+2 stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33132
diff
changeset
|
5249 | g_object_get(G_OBJECT(tag), "name", &name, NULL); |
| 8677 | 5250 | g_return_val_if_fail(name != NULL, ""); |
| 5251 | ||
| 5252 | if (strcmp(name, "BOLD") == 0) { | |
|
32413
00ad036bdf3d
Fix some indenting.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32412
diff
changeset
|
5253 | g_free(name); |
| 8677 | 5254 | return "<b>"; |
| 5255 | } else if (strcmp(name, "ITALICS") == 0) { | |
|
32413
00ad036bdf3d
Fix some indenting.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32412
diff
changeset
|
5256 | g_free(name); |
| 8677 | 5257 | return "<i>"; |
| 5258 | } else if (strcmp(name, "UNDERLINE") == 0) { | |
|
32413
00ad036bdf3d
Fix some indenting.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32412
diff
changeset
|
5259 | g_free(name); |
| 8677 | 5260 | return "<u>"; |
| 9924 | 5261 | } else if (strcmp(name, "STRIKE") == 0) { |
|
32413
00ad036bdf3d
Fix some indenting.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32412
diff
changeset
|
5262 | g_free(name); |
| 9924 | 5263 | return "<s>"; |
| 8677 | 5264 | } else if (strncmp(name, "LINK ", 5) == 0) { |
| 5265 | char *tmp = g_object_get_data(G_OBJECT(tag), "link_url"); | |
|
32394
f883709bdba4
compiles using GTK+ 3 from git, beware it does not yet run, in fact it crashes...
Marcus Lundblad <malu@pidgin.im>
parents:
31207
diff
changeset
|
5266 | |
|
32413
00ad036bdf3d
Fix some indenting.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32412
diff
changeset
|
5267 | g_free(name); |
|
00ad036bdf3d
Fix some indenting.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32412
diff
changeset
|
5268 | |
| 8677 | 5269 | if (tmp) { |
| 5270 | g_snprintf(buf, sizeof(buf), "<a href=\"%s\">", tmp); | |
| 5271 | buf[sizeof(buf)-1] = '\0'; | |
| 5272 | return buf; | |
| 5273 | } else { | |
| 5274 | return ""; | |
| 5275 | } | |
| 5276 | } else if (strncmp(name, "FORECOLOR ", 10) == 0) { | |
| 5277 | g_snprintf(buf, sizeof(buf), "<font color=\"%s\">", &name[10]); | |
|
32394
f883709bdba4
compiles using GTK+ 3 from git, beware it does not yet run, in fact it crashes...
Marcus Lundblad <malu@pidgin.im>
parents:
31207
diff
changeset
|
5278 | |
|
32413
00ad036bdf3d
Fix some indenting.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32412
diff
changeset
|
5279 | g_free(name); |
|
00ad036bdf3d
Fix some indenting.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32412
diff
changeset
|
5280 | |
| 8677 | 5281 | return buf; |
| 5282 | } else if (strncmp(name, "BACKCOLOR ", 10) == 0) { | |
| 5283 | g_snprintf(buf, sizeof(buf), "<font back=\"%s\">", &name[10]); | |
|
32413
00ad036bdf3d
Fix some indenting.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32412
diff
changeset
|
5284 | g_free(name); |
|
00ad036bdf3d
Fix some indenting.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32412
diff
changeset
|
5285 | |
| 8677 | 5286 | return buf; |
| 10776 | 5287 | } else if (strncmp(name, "BACKGROUND ", 10) == 0) { |
| 5288 | g_snprintf(buf, sizeof(buf), "<body bgcolor=\"%s\">", &name[11]); | |
|
32413
00ad036bdf3d
Fix some indenting.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32412
diff
changeset
|
5289 | g_free(name); |
|
00ad036bdf3d
Fix some indenting.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32412
diff
changeset
|
5290 | |
| 10776 | 5291 | return buf; |
| 8677 | 5292 | } else if (strncmp(name, "FONT FACE ", 10) == 0) { |
| 5293 | g_snprintf(buf, sizeof(buf), "<font face=\"%s\">", &name[10]); | |
|
32413
00ad036bdf3d
Fix some indenting.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32412
diff
changeset
|
5294 | g_free(name); |
|
00ad036bdf3d
Fix some indenting.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32412
diff
changeset
|
5295 | |
| 8677 | 5296 | return buf; |
| 5297 | } else if (strncmp(name, "FONT SIZE ", 10) == 0) { | |
| 5298 | g_snprintf(buf, sizeof(buf), "<font size=\"%s\">", &name[10]); | |
|
32413
00ad036bdf3d
Fix some indenting.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32412
diff
changeset
|
5299 | g_free(name); |
|
00ad036bdf3d
Fix some indenting.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32412
diff
changeset
|
5300 | |
| 8677 | 5301 | return buf; |
| 5302 | } else { | |
|
23308
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5303 | char *str = buf; |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5304 | gboolean isset; |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5305 | int ivalue = 0; |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5306 | GdkColor *color = NULL; |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5307 | GObject *obj = G_OBJECT(tag); |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5308 | gboolean empty = TRUE; |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5309 | |
|
23310
e34473be13db
Get rid of the boldness of the bold timestamps.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23308
diff
changeset
|
5310 | 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
|
5311 | |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5312 | /* Weight */ |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5313 | 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
|
5314 | if (isset) { |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5315 | const char *weight = ""; |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5316 | if (ivalue >= PANGO_WEIGHT_ULTRABOLD) |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5317 | weight = "bolder"; |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5318 | else if (ivalue >= PANGO_WEIGHT_BOLD) |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5319 | weight = "bold"; |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5320 | else if (ivalue >= PANGO_WEIGHT_NORMAL) |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5321 | weight = "normal"; |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5322 | else |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5323 | weight = "lighter"; |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5324 | |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5325 | 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
|
5326 | empty = FALSE; |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5327 | } |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5328 | |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5329 | /* Foreground color */ |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5330 | 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
|
5331 | if (isset && color) { |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5332 | 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
|
5333 | "color: #%02x%02x%02x;", |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5334 | 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
|
5335 | empty = FALSE; |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5336 | } |
|
23466
7380df2e12f1
Patch from Andrew Gaul that fixes another leak:
Ka-Hing Cheung <khc@pidgin.im>
parents:
23465
diff
changeset
|
5337 | gdk_color_free(color); |
|
23308
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5338 | |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5339 | /* Background color */ |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5340 | 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
|
5341 | if (isset && color) { |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5342 | 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
|
5343 | "background: #%02x%02x%02x;", |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5344 | 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
|
5345 | empty = FALSE; |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5346 | } |
|
23466
7380df2e12f1
Patch from Andrew Gaul that fixes another leak:
Ka-Hing Cheung <khc@pidgin.im>
parents:
23465
diff
changeset
|
5347 | gdk_color_free(color); |
|
23308
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5348 | |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5349 | /* Underline */ |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5350 | 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
|
5351 | if (isset) { |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5352 | switch (ivalue) { |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5353 | case PANGO_UNDERLINE_NONE: |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5354 | case PANGO_UNDERLINE_ERROR: |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5355 | break; |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5356 | default: |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5357 | 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
|
5358 | empty = FALSE; |
|
23308
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5359 | } |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5360 | } |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5361 | |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5362 | g_snprintf(str, sizeof(buf) - (str - buf), "'>"); |
|
32413
00ad036bdf3d
Fix some indenting.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32412
diff
changeset
|
5363 | g_free(name); |
|
23308
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5364 | |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5365 | return (empty ? "" : buf); |
| 8677 | 5366 | } |
| 8061 | 5367 | } |
| 5368 | ||
| 8677 | 5369 | static const gchar *tag_to_html_end(GtkTextTag *tag) |
| 8061 | 5370 | { |
|
32394
f883709bdba4
compiles using GTK+ 3 from git, beware it does not yet run, in fact it crashes...
Marcus Lundblad <malu@pidgin.im>
parents:
31207
diff
changeset
|
5371 | gchar *name; |
|
f883709bdba4
compiles using GTK+ 3 from git, beware it does not yet run, in fact it crashes...
Marcus Lundblad <malu@pidgin.im>
parents:
31207
diff
changeset
|
5372 | |
|
33170
ce4447562d64
Add checks for old GTK+2 stuff.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
33132
diff
changeset
|
5373 | g_object_get(G_OBJECT(tag), "name", &name, NULL); |
| 8677 | 5374 | g_return_val_if_fail(name != NULL, ""); |
| 5375 | ||
| 5376 | if (strcmp(name, "BOLD") == 0) { | |
|
32413
00ad036bdf3d
Fix some indenting.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32412
diff
changeset
|
5377 | g_free(name); |
| 8677 | 5378 | return "</b>"; |
| 5379 | } else if (strcmp(name, "ITALICS") == 0) { | |
|
32413
00ad036bdf3d
Fix some indenting.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32412
diff
changeset
|
5380 | g_free(name); |
| 8677 | 5381 | return "</i>"; |
| 5382 | } else if (strcmp(name, "UNDERLINE") == 0) { | |
|
32413
00ad036bdf3d
Fix some indenting.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32412
diff
changeset
|
5383 | g_free(name); |
| 8677 | 5384 | return "</u>"; |
| 9924 | 5385 | } else if (strcmp(name, "STRIKE") == 0) { |
|
32413
00ad036bdf3d
Fix some indenting.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32412
diff
changeset
|
5386 | g_free(name); |
| 9924 | 5387 | return "</s>"; |
| 8677 | 5388 | } else if (strncmp(name, "LINK ", 5) == 0) { |
|
32413
00ad036bdf3d
Fix some indenting.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32412
diff
changeset
|
5389 | g_free(name); |
| 8677 | 5390 | return "</a>"; |
| 5391 | } else if (strncmp(name, "FORECOLOR ", 10) == 0) { | |
|
32413
00ad036bdf3d
Fix some indenting.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32412
diff
changeset
|
5392 | g_free(name); |
| 8677 | 5393 | return "</font>"; |
| 5394 | } else if (strncmp(name, "BACKCOLOR ", 10) == 0) { | |
|
32413
00ad036bdf3d
Fix some indenting.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32412
diff
changeset
|
5395 | g_free(name); |
| 8677 | 5396 | return "</font>"; |
| 10776 | 5397 | } else if (strncmp(name, "BACKGROUND ", 10) == 0) { |
|
32413
00ad036bdf3d
Fix some indenting.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32412
diff
changeset
|
5398 | g_free(name); |
| 10776 | 5399 | return "</body>"; |
| 8677 | 5400 | } else if (strncmp(name, "FONT FACE ", 10) == 0) { |
|
32413
00ad036bdf3d
Fix some indenting.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32412
diff
changeset
|
5401 | g_free(name); |
| 8677 | 5402 | return "</font>"; |
| 5403 | } else if (strncmp(name, "FONT SIZE ", 10) == 0) { | |
|
32413
00ad036bdf3d
Fix some indenting.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32412
diff
changeset
|
5404 | g_free(name); |
| 8677 | 5405 | return "</font>"; |
| 5406 | } else { | |
|
23308
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5407 | 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
|
5408 | "size-set", "underline-set", NULL}; |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5409 | int i; |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5410 | for (i = 0; props[i]; i++) { |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5411 | gboolean set = FALSE; |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5412 | 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
|
5413 | if (set) |
|
23310
e34473be13db
Get rid of the boldness of the bold timestamps.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23308
diff
changeset
|
5414 | return "</span>"; |
|
23308
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5415 | } |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5416 | |
|
32413
00ad036bdf3d
Fix some indenting.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
32412
diff
changeset
|
5417 | g_free(name); |
|
32394
f883709bdba4
compiles using GTK+ 3 from git, beware it does not yet run, in fact it crashes...
Marcus Lundblad <malu@pidgin.im>
parents:
31207
diff
changeset
|
5418 | |
| 8677 | 5419 | return ""; |
| 5420 | } | |
| 5421 | } | |
| 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 | 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
|
5424 | 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
|
5425 | 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
|
5426 | 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
|
5427 | } 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
|
5428 | |
|
fc1df3495580
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23332
diff
changeset
|
5429 | 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
|
5430 | { |
|
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 | 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
|
5432 | 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
|
5433 | |
|
fc1df3495580
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23332
diff
changeset
|
5434 | 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
|
5435 | 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
|
5436 | 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
|
5437 | 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
|
5438 | 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
|
5439 | 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
|
5440 | |
|
fc1df3495580
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23332
diff
changeset
|
5441 | 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
|
5442 | 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
|
5443 | 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
|
5444 | 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
|
5445 | 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
|
5446 | } |
|
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 | |
|
fc1df3495580
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23332
diff
changeset
|
5448 | 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
|
5449 | { |
|
fc1df3495580
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23332
diff
changeset
|
5450 | 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
|
5451 | 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
|
5452 | 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
|
5453 | } |
|
fc1df3495580
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23332
diff
changeset
|
5454 | |
| 8677 | 5455 | static gboolean tag_ends_here(GtkTextTag *tag, GtkTextIter *iter, GtkTextIter *niter) |
| 5456 | { | |
| 5457 | return ((gtk_text_iter_has_tag(iter, GTK_TEXT_TAG(tag)) && | |
| 5458 | !gtk_text_iter_has_tag(niter, GTK_TEXT_TAG(tag))) || | |
| 5459 | gtk_text_iter_is_end(niter)); | |
| 8061 | 5460 | } |
| 5461 | ||
| 5462 | /* Basic notion here: traverse through the text buffer one-by-one, non-character elements, such | |
| 5463 | * as smileys and IM images are represented by the Unicode "unknown" character. Handle them. Else | |
| 8677 | 5464 | * check for tags that are toggled on, insert their html form, and push them on the queue. Then insert |
| 5465 | * 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
|
5466 | * Finally, replace <, >, &, and " with their HTML equivalent. |
| 8677 | 5467 | */ |
| 8061 | 5468 | char *gtk_imhtml_get_markup_range(GtkIMHtml *imhtml, GtkTextIter *start, GtkTextIter *end) |
| 5469 | { | |
| 5470 | gunichar c; | |
|
16143
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
5471 | GtkTextIter iter, next_iter, non_neutral_iter; |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
5472 | gboolean is_rtl_message = FALSE; |
| 8061 | 5473 | GString *str = g_string_new(""); |
| 8677 | 5474 | 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
|
5475 | GQueue *q; |
| 8677 | 5476 | 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
|
5477 | PidginTextTagData *tagdata; |
| 8677 | 5478 | |
| 5479 | q = g_queue_new(); | |
| 8061 | 5480 | |
| 5481 | gtk_text_iter_order(start, end); | |
|
16143
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
5482 | non_neutral_iter = next_iter = iter = *start; |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
5483 | gtk_text_iter_forward_char(&next_iter); |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
5484 | |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
5485 | /* Bi-directional text support */ |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
5486 | /* 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
|
5487 | #ifdef HAVE_PANGO14 |
| 16144 | 5488 | 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
|
5489 | && gtk_text_iter_forward_char(&non_neutral_iter)); |
| 16144 | 5490 | 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
|
5491 | is_rtl_message = TRUE; |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
5492 | 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
|
5493 | } |
|
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
|
5494 | #endif |
| 8677 | 5495 | |
| 9071 | 5496 | /* First add the tags that are already in progress (we don't care about non-printing tags)*/ |
| 8677 | 5497 | tags = gtk_text_iter_get_tags(start); |
| 5498 | ||
| 5499 | for (sl = tags; sl; sl = sl->next) { | |
| 5500 | tag = sl->data; | |
| 5501 | 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
|
5502 | 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
|
5503 | 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
|
5504 | 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
|
5505 | 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
|
5506 | } |
| 8061 | 5507 | } |
| 5508 | } | |
| 8677 | 5509 | g_slist_free(tags); |
| 8061 | 5510 | |
| 5511 | while ((c = gtk_text_iter_get_char(&iter)) != 0 && !gtk_text_iter_equal(&iter, end)) { | |
| 8677 | 5512 | |
| 5513 | tags = gtk_text_iter_get_tags(&iter); | |
| 5514 | ||
| 5515 | for (sl = tags; sl; sl = sl->next) { | |
| 5516 | tag = sl->data; | |
| 5517 | 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
|
5518 | 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
|
5519 | 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
|
5520 | 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
|
5521 | 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
|
5522 | } |
| 8677 | 5523 | } |
| 5524 | } | |
| 5525 | ||
| 8061 | 5526 | if (c == 0xFFFC) { |
| 5527 | GtkTextChildAnchor* anchor = gtk_text_iter_get_child_anchor(&iter); | |
| 9071 | 5528 | if (anchor) { |
| 5529 | char *text = g_object_get_data(G_OBJECT(anchor), "gtkimhtml_htmltext"); | |
| 5530 | if (text) | |
| 5531 | str = g_string_append(str, text); | |
| 5532 | } | |
|
11572
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
5533 | } else if (c == '<') { |
| 8677 | 5534 | str = g_string_append(str, "<"); |
| 5535 | } else if (c == '>') { | |
| 5536 | str = g_string_append(str, ">"); | |
| 5537 | } else if (c == '&') { | |
| 5538 | str = g_string_append(str, "&"); | |
| 5539 | } else if (c == '"') { | |
| 5540 | str = g_string_append(str, """); | |
| 5541 | } else if (c == '\n') { | |
|
19746
4537d921dab4
disapproval of revision '10d0834255f911ca2359c74b430025155af2b22e'
Kevin Stange <kstange@pidgin.im>
parents:
19745
diff
changeset
|
5542 | str = g_string_append(str, "<br>"); |
| 8061 | 5543 | } else { |
| 8677 | 5544 | str = g_string_append_unichar(str, c); |
| 5545 | } | |
| 5546 | ||
| 5547 | tags = g_slist_reverse(tags); | |
| 5548 | for (sl = tags; sl; sl = sl->next) { | |
| 5549 | tag = sl->data; | |
| 9071 | 5550 | /** 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
|
5551 | 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
|
5552 | *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
|
5553 | *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
|
5554 | { |
|
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
|
5555 | 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
|
5556 | 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
|
5557 | |
|
fc1df3495580
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23332
diff
changeset
|
5558 | 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
|
5559 | 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
|
5560 | if (!tag_ends_here(tmp->tag, &iter, &next_iter)) |
| 8677 | 5561 | 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
|
5562 | 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
|
5563 | text_tag_data_destroy(tmp); |
| 8677 | 5564 | } |
| 5565 | ||
|
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
|
5566 | 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
|
5567 | 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
|
5568 | text_tag_data_destroy(tmp); |
|
e20729245830
Patch from Andrew Gaul that fixes a leak:
Ka-Hing Cheung <khc@pidgin.im>
parents:
23398
diff
changeset
|
5569 | } |
|
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
|
5570 | #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
|
5571 | 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
|
5572 | 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
|
5573 | #endif |
| 8677 | 5574 | |
| 5575 | 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
|
5576 | g_string_append(str, tmp->start); |
| 8677 | 5577 | g_queue_push_tail(q, tmp); |
| 8061 | 5578 | } |
|
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
|
5579 | g_queue_free(r); |
| 8061 | 5580 | } |
| 5581 | } | |
| 8677 | 5582 | |
| 5583 | g_slist_free(tags); | |
| 8061 | 5584 | gtk_text_iter_forward_char(&iter); |
|
16143
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
5585 | gtk_text_iter_forward_char(&next_iter); |
| 8061 | 5586 | } |
| 8677 | 5587 | |
|
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
|
5588 | 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
|
5589 | 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
|
5590 | 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
|
5591 | } |
| 8677 | 5592 | |
|
16143
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
5593 | /* Bi-directional text support - close tags */ |
| 16144 | 5594 | if (is_rtl_message) |
|
16143
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
5595 | g_string_append(str, "</SPAN>"); |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
5596 | |
| 8677 | 5597 | g_queue_free(q); |
| 8061 | 5598 | return g_string_free(str, FALSE); |
| 5599 | } | |
| 5600 | ||
| 8698 | 5601 | void gtk_imhtml_close_tags(GtkIMHtml *imhtml, GtkTextIter *iter) |
| 8061 | 5602 | { |
| 5603 | if (imhtml->edit.bold) | |
| 5604 | gtk_imhtml_toggle_bold(imhtml); | |
| 5605 | ||
| 5606 | if (imhtml->edit.italic) | |
| 5607 | gtk_imhtml_toggle_italic(imhtml); | |
| 5608 | ||
| 5609 | if (imhtml->edit.underline) | |
| 5610 | gtk_imhtml_toggle_underline(imhtml); | |
| 5611 | ||
| 9924 | 5612 | if (imhtml->edit.strike) |
| 5613 | gtk_imhtml_toggle_strike(imhtml); | |
| 5614 | ||
| 8061 | 5615 | if (imhtml->edit.forecolor) |
| 5616 | gtk_imhtml_toggle_forecolor(imhtml, NULL); | |
| 5617 | ||
| 5618 | if (imhtml->edit.backcolor) | |
| 5619 | gtk_imhtml_toggle_backcolor(imhtml, NULL); | |
| 5620 | ||
| 5621 | if (imhtml->edit.fontface) | |
| 5622 | gtk_imhtml_toggle_fontface(imhtml, NULL); | |
| 5623 | ||
| 8677 | 5624 | imhtml->edit.fontsize = 0; |
| 5625 | ||
| 8719 | 5626 | if (imhtml->edit.link) |
| 5627 | gtk_imhtml_toggle_link(imhtml, NULL); | |
| 8061 | 5628 | } |
| 5629 | ||
| 5630 | char *gtk_imhtml_get_markup(GtkIMHtml *imhtml) | |
| 5631 | { | |
| 5632 | GtkTextIter start, end; | |
| 5633 | ||
| 5634 | gtk_text_buffer_get_start_iter(imhtml->text_buffer, &start); | |
| 5635 | gtk_text_buffer_get_end_iter(imhtml->text_buffer, &end); | |
| 5636 | return gtk_imhtml_get_markup_range(imhtml, &start, &end); | |
| 5637 | } | |
| 5638 | ||
| 8677 | 5639 | char **gtk_imhtml_get_markup_lines(GtkIMHtml *imhtml) |
| 5640 | { | |
| 5641 | int i, j, lines; | |
| 5642 | GtkTextIter start, end; | |
| 5643 | char **ret; | |
| 5644 | ||
| 5645 | lines = gtk_text_buffer_get_line_count(imhtml->text_buffer); | |
| 5646 | ret = g_new0(char *, lines + 1); | |
| 5647 | gtk_text_buffer_get_start_iter(imhtml->text_buffer, &start); | |
| 5648 | end = start; | |
| 5649 | gtk_text_iter_forward_to_line_end(&end); | |
| 5650 | ||
| 5651 | for (i = 0, j = 0; i < lines; i++) { | |
| 9612 | 5652 | if (gtk_text_iter_get_char(&start) != '\n') { |
| 5653 | ret[j] = gtk_imhtml_get_markup_range(imhtml, &start, &end); | |
| 5654 | if (ret[j] != NULL) | |
| 5655 | j++; | |
| 5656 | } | |
| 5657 | ||
| 8677 | 5658 | gtk_text_iter_forward_line(&start); |
| 5659 | end = start; | |
| 5660 | gtk_text_iter_forward_to_line_end(&end); | |
| 5661 | } | |
| 5662 | ||
| 5663 | return ret; | |
| 5664 | } | |
| 5665 | ||
| 5666 | char *gtk_imhtml_get_text(GtkIMHtml *imhtml, GtkTextIter *start, GtkTextIter *stop) | |
| 8061 | 5667 | { |
| 8519 | 5668 | GString *str = g_string_new(""); |
| 5669 | GtkTextIter iter, end; | |
| 5670 | gunichar c; | |
| 5671 | ||
| 8677 | 5672 | if (start == NULL) |
| 5673 | gtk_text_buffer_get_start_iter(imhtml->text_buffer, &iter); | |
| 5674 | else | |
| 5675 | iter = *start; | |
| 5676 | ||
| 5677 | if (stop == NULL) | |
| 5678 | gtk_text_buffer_get_end_iter(imhtml->text_buffer, &end); | |
| 5679 | else | |
| 5680 | end = *stop; | |
| 5681 | ||
| 5682 | gtk_text_iter_order(&iter, &end); | |
| 8519 | 5683 | |
| 5684 | while ((c = gtk_text_iter_get_char(&iter)) != 0 && !gtk_text_iter_equal(&iter, &end)) { | |
| 5685 | if (c == 0xFFFC) { | |
| 8677 | 5686 | GtkTextChildAnchor* anchor; |
| 5687 | char *text = NULL; | |
| 5688 | ||
| 5689 | anchor = gtk_text_iter_get_child_anchor(&iter); | |
| 5690 | if (anchor) | |
| 8698 | 5691 | text = g_object_get_data(G_OBJECT(anchor), "gtkimhtml_plaintext"); |
| 8677 | 5692 | if (text) |
| 5693 | str = g_string_append(str, text); | |
| 8519 | 5694 | } else { |
| 5695 | g_string_append_unichar(str, c); | |
| 5696 | } | |
| 5697 | gtk_text_iter_forward_char(&iter); | |
| 5698 | } | |
| 5699 | ||
| 5700 | return g_string_free(str, FALSE); | |
| 8061 | 5701 | } |
| 8962 | 5702 | |
| 5703 | void gtk_imhtml_set_funcs(GtkIMHtml *imhtml, GtkIMHtmlFuncs *f) | |
| 5704 | { | |
| 5705 | g_return_if_fail(imhtml != NULL); | |
| 5706 | imhtml->funcs = f; | |
| 5707 | } | |
|
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
|
5708 | |
|
8be39f0de528
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17288
diff
changeset
|
5709 | 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
|
5710 | { |
|
18240
0a7d2fde749b
Fix setting the sensitivity of the toolbar items in a number of places
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
18185
diff
changeset
|
5711 | 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
|
5712 | |
|
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
|
5713 | 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
|
5714 | 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
|
5715 | 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
|
5716 | |
|
18240
0a7d2fde749b
Fix setting the sensitivity of the toolbar items in a number of places
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
18185
diff
changeset
|
5717 | 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
|
5718 | |
|
0a7d2fde749b
Fix setting the sensitivity of the toolbar items in a number of places
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
18185
diff
changeset
|
5719 | 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
|
5720 | 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
|
5721 | 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
|
5722 | { |
|
0a7d2fde749b
Fix setting the sensitivity of the toolbar items in a number of places
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
18185
diff
changeset
|
5723 | 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
|
5724 | 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
|
5725 | } |
|
0a7d2fde749b
Fix setting the sensitivity of the toolbar items in a number of places
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
18185
diff
changeset
|
5726 | 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
|
5727 | 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
|
5728 | |
|
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
|
5729 | 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
|
5730 | 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
|
5731 | 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
|
5732 | |
|
8be39f0de528
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17288
diff
changeset
|
5733 | 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
|
5734 | 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
|
5735 | |
|
8be39f0de528
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17288
diff
changeset
|
5736 | 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
|
5737 | 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
|
5738 | |
|
8be39f0de528
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17288
diff
changeset
|
5739 | 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
|
5740 | 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
|
5741 | |
|
8be39f0de528
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17288
diff
changeset
|
5742 | 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
|
5743 | { |
|
8be39f0de528
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17288
diff
changeset
|
5744 | 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
|
5745 | |
|
8be39f0de528
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17288
diff
changeset
|
5746 | /* 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
|
5747 | 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
|
5748 | 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
|
5749 | } |
|
8be39f0de528
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17288
diff
changeset
|
5750 | |
|
8be39f0de528
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17288
diff
changeset
|
5751 | 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
|
5752 | { |
|
8be39f0de528
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17288
diff
changeset
|
5753 | 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
|
5754 | &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
|
5755 | 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
|
5756 | 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
|
5757 | 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
|
5758 | 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
|
5759 | } 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
|
5760 | 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
|
5761 | |
|
8be39f0de528
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17288
diff
changeset
|
5762 | 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
|
5763 | |
|
8be39f0de528
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17288
diff
changeset
|
5764 | 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
|
5765 | 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
|
5766 | { |
|
8be39f0de528
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17288
diff
changeset
|
5767 | 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
|
5768 | &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
|
5769 | 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
|
5770 | 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
|
5771 | 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
|
5772 | 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
|
5773 | } 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
|
5774 | 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
|
5775 | |
|
8be39f0de528
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17288
diff
changeset
|
5776 | 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
|
5777 | |
|
8be39f0de528
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17288
diff
changeset
|
5778 | 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
|
5779 | 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
|
5780 | 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
|
5781 | 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
|
5782 | } 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
|
5783 | 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
|
5784 | 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
|
5785 | } |
|
18240
0a7d2fde749b
Fix setting the sensitivity of the toolbar items in a number of places
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
18185
diff
changeset
|
5786 | |
|
0a7d2fde749b
Fix setting the sensitivity of the toolbar items in a number of places
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
18185
diff
changeset
|
5787 | 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
|
5788 | 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
|
5789 | |
|
23010
6230fac29cee
Show the custom smileys only on accounts that support it. References
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23008
diff
changeset
|
5790 | 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
|
5791 | 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
|
5792 | else |
|
6230fac29cee
Show the custom smileys only on accounts that support it. References
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23008
diff
changeset
|
5793 | 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
|
5794 | |
|
18240
0a7d2fde749b
Fix setting the sensitivity of the toolbar items in a number of places
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
18185
diff
changeset
|
5795 | 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
|
5796 | } |
|
8be39f0de528
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17288
diff
changeset
|
5797 | |
|
22655
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5798 | /******* |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5799 | * 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
|
5800 | *******/ |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5801 | 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
|
5802 | { |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5803 | 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
|
5804 | |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5805 | 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
|
5806 | 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
|
5807 | |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5808 | 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
|
5809 | 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
|
5810 | #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
|
5811 | 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
|
5812 | #endif |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5813 | } |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5814 | |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5815 | 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
|
5816 | { |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5817 | 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
|
5818 | 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
|
5819 | 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
|
5820 | 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
|
5821 | |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5822 | 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
|
5823 | 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
|
5824 | #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
|
5825 | 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
|
5826 | #endif |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5827 | 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
|
5828 | 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
|
5829 | return; |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5830 | } |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5831 | |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5832 | 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
|
5833 | 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
|
5834 | 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
|
5835 | 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
|
5836 | 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
|
5837 | 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
|
5838 | |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5839 | #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
|
5840 | 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
|
5841 | 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
|
5842 | #endif |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5843 | 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
|
5844 | 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
|
5845 | 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
|
5846 | |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5847 | 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
|
5848 | |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5849 | 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
|
5850 | 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
|
5851 | |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5852 | 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
|
5853 | 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
|
5854 | 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
|
5855 | 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
|
5856 | 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
|
5857 | 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
|
5858 | } else |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5859 | 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
|
5860 | } |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5861 | 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
|
5862 | } |
|
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
|
5863 | 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
|
5864 | } |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5865 | |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5866 | 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
|
5867 | 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
|
5868 | |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5869 | 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
|
5870 | 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
|
5871 | } |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5872 | |
|
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
|
5873 | 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
|
5874 | 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
|
5875 | { |
|
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
|
5876 | 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
|
5877 | 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
|
5878 | 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
|
5879 | 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
|
5880 | |
|
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
|
5881 | 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
|
5882 | 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
|
5883 | 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
|
5884 | } 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
|
5885 | 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
|
5886 | 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
|
5887 | } |
|
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
|
5888 | } |
|
39c5be5ca1e9
Patch from Masca to restrict the size of incoming custom smileys to a
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23010
diff
changeset
|
5889 | 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
|
5890 | } |
|
39c5be5ca1e9
Patch from Masca to restrict the size of incoming custom smileys to a
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23010
diff
changeset
|
5891 | |
|
22655
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5892 | void |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5893 | 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
|
5894 | { |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5895 | 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
|
5896 | 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
|
5897 | 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
|
5898 | 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
|
5899 | |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5900 | 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
|
5901 | 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
|
5902 | |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5903 | 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
|
5904 | /* 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
|
5905 | * 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
|
5906 | */ |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5907 | return; |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5908 | } |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5909 | |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5910 | 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
|
5911 | |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5912 | 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
|
5913 | 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
|
5914 | 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
|
5915 | } |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5916 | |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5917 | 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
|
5918 | 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
|
5919 | { |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5920 | 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
|
5921 | 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
|
5922 | 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
|
5923 | 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
|
5924 | 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
|
5925 | 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
|
5926 | 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
|
5927 | 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
|
5928 | } |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5929 | |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5930 | 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
|
5931 | { |
|
24392
51b7f65a712d
Clean up the GtkSmileyTrees on active GtkIMHtml instances when a custom smiley
Marcus Lundblad <malu@pidgin.im>
parents:
24328
diff
changeset
|
5932 | 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
|
5933 | 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
|
5934 | 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
|
5935 | 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
|
5936 | 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
|
5937 | 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
|
5938 | 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
|
5939 | 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
|
5940 | 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
|
5941 | } |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5942 | |
|
24674
36bf974a7d78
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24588
diff
changeset
|
5943 | 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
|
5944 | 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
|
5945 | 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
|
5946 | { |
|
36bf974a7d78
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24588
diff
changeset
|
5947 | GtkIMHtmlClass *klass; |
|
36bf974a7d78
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24588
diff
changeset
|
5948 | GtkIMHtmlProtocol *proto; |
|
36bf974a7d78
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24588
diff
changeset
|
5949 | |
|
36bf974a7d78
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24588
diff
changeset
|
5950 | 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
|
5951 | |
|
36bf974a7d78
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24588
diff
changeset
|
5952 | 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
|
5953 | 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
|
5954 | |
|
25013
956b2f650d31
Detect duplication registrations by substring.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
25011
diff
changeset
|
5955 | 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
|
5956 | if (activate) { |
|
5bf71146f93e
Replace the URL registration assertions with regular checks.
Richard Laager <rlaager@pidgin.im>
parents:
25013
diff
changeset
|
5957 | return FALSE; |
|
5bf71146f93e
Replace the URL registration assertions with regular checks.
Richard Laager <rlaager@pidgin.im>
parents:
25013
diff
changeset
|
5958 | } |
|
28077
c2b493e058f1
Don't use pointers (even opaquely) once they're freed. Closes #9822.
Paul Aurich <darkrain42@pidgin.im>
parents:
27525
diff
changeset
|
5959 | 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
|
5960 | 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
|
5961 | 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
|
5962 | return TRUE; |
|
25014
5bf71146f93e
Replace the URL registration assertions with regular checks.
Richard Laager <rlaager@pidgin.im>
parents:
25013
diff
changeset
|
5963 | } else if (!activate) { |
|
5bf71146f93e
Replace the URL registration assertions with regular checks.
Richard Laager <rlaager@pidgin.im>
parents:
25013
diff
changeset
|
5964 | 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
|
5965 | } |
|
36bf974a7d78
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24588
diff
changeset
|
5966 | |
|
36bf974a7d78
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24588
diff
changeset
|
5967 | 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
|
5968 | 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
|
5969 | 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
|
5970 | 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
|
5971 | 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
|
5972 | 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
|
5973 | |
|
36bf974a7d78
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24588
diff
changeset
|
5974 | return TRUE; |
|
36bf974a7d78
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24588
diff
changeset
|
5975 | } |
|
36bf974a7d78
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24588
diff
changeset
|
5976 | |
|
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
|
5977 | 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
|
5978 | 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
|
5979 | { |
|
f9dd7117ade0
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24675
diff
changeset
|
5980 | /* 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
|
5981 | * 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
|
5982 | 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
|
5983 | 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
|
5984 | 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
|
5985 | 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
|
5986 | 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
|
5987 | } |
|
f9dd7117ade0
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24675
diff
changeset
|
5988 | |
|
f9dd7117ade0
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24675
diff
changeset
|
5989 | 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
|
5990 | { |
|
f9dd7117ade0
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24675
diff
changeset
|
5991 | 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
|
5992 | |
|
f9dd7117ade0
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24675
diff
changeset
|
5993 | 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
|
5994 | 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
|
5995 | } 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
|
5996 | 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
|
5997 | } 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
|
5998 | 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
|
5999 | 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
|
6000 | } |
|
f9dd7117ade0
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24675
diff
changeset
|
6001 | |
|
f9dd7117ade0
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24675
diff
changeset
|
6002 | 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
|
6003 | { |
|
f9dd7117ade0
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24675
diff
changeset
|
6004 | 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
|
6005 | } |
|
f9dd7117ade0
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24675
diff
changeset
|
6006 | |
|
f9dd7117ade0
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24675
diff
changeset
|
6007 | 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
|
6008 | { |
|
f9dd7117ade0
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24675
diff
changeset
|
6009 | 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
|
6010 | } |
|
f9dd7117ade0
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24675
diff
changeset
|
6011 | |
|
25900
0be61f1b3dd1
Add a GtkIMHtml function that causes the widget to actually insert a
Mark Doliner <markdoliner@pidgin.im>
parents:
25899
diff
changeset
|
6012 | 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
|
6013 | { |
|
0be61f1b3dd1
Add a GtkIMHtml function that causes the widget to actually insert a
Mark Doliner <markdoliner@pidgin.im>
parents:
25899
diff
changeset
|
6014 | GtkTextBuffer *buffer; |
|
0be61f1b3dd1
Add a GtkIMHtml function that causes the widget to actually insert a
Mark Doliner <markdoliner@pidgin.im>
parents:
25899
diff
changeset
|
6015 | GtkTextMark *mark; |
|
0be61f1b3dd1
Add a GtkIMHtml function that causes the widget to actually insert a
Mark Doliner <markdoliner@pidgin.im>
parents:
25899
diff
changeset
|
6016 | GtkTextIter iter; |
|
0be61f1b3dd1
Add a GtkIMHtml function that causes the widget to actually insert a
Mark Doliner <markdoliner@pidgin.im>
parents:
25899
diff
changeset
|
6017 | |
|
0be61f1b3dd1
Add a GtkIMHtml function that causes the widget to actually insert a
Mark Doliner <markdoliner@pidgin.im>
parents:
25899
diff
changeset
|
6018 | 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
|
6019 | |
|
0be61f1b3dd1
Add a GtkIMHtml function that causes the widget to actually insert a
Mark Doliner <markdoliner@pidgin.im>
parents:
25899
diff
changeset
|
6020 | /* 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
|
6021 | 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
|
6022 | |
|
0be61f1b3dd1
Add a GtkIMHtml function that causes the widget to actually insert a
Mark Doliner <markdoliner@pidgin.im>
parents:
25899
diff
changeset
|
6023 | /* 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
|
6024 | 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
|
6025 | 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
|
6026 | 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
|
6027 | |
|
0be61f1b3dd1
Add a GtkIMHtml function that causes the widget to actually insert a
Mark Doliner <markdoliner@pidgin.im>
parents:
25899
diff
changeset
|
6028 | /* |
|
0be61f1b3dd1
Add a GtkIMHtml function that causes the widget to actually insert a
Mark Doliner <markdoliner@pidgin.im>
parents:
25899
diff
changeset
|
6029 | * 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
|
6030 | * 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
|
6031 | */ |
|
0be61f1b3dd1
Add a GtkIMHtml function that causes the widget to actually insert a
Mark Doliner <markdoliner@pidgin.im>
parents:
25899
diff
changeset
|
6032 | 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
|
6033 | 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
|
6034 | 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
|
6035 | |
|
0be61f1b3dd1
Add a GtkIMHtml function that causes the widget to actually insert a
Mark Doliner <markdoliner@pidgin.im>
parents:
25899
diff
changeset
|
6036 | return TRUE; |
|
0be61f1b3dd1
Add a GtkIMHtml function that causes the widget to actually insert a
Mark Doliner <markdoliner@pidgin.im>
parents:
25899
diff
changeset
|
6037 | } |
|
0be61f1b3dd1
Add a GtkIMHtml function that causes the widget to actually insert a
Mark Doliner <markdoliner@pidgin.im>
parents:
25899
diff
changeset
|
6038 | |
|
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
|
6039 | /* |
|
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
|
6040 | * 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
|
6041 | * 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
|
6042 | * 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
|
6043 | * 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
|
6044 | * 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
|
6045 | */ |
|
25900
0be61f1b3dd1
Add a GtkIMHtml function that causes the widget to actually insert a
Mark Doliner <markdoliner@pidgin.im>
parents:
25899
diff
changeset
|
6046 | 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
|
6047 | { |
|
0be61f1b3dd1
Add a GtkIMHtml function that causes the widget to actually insert a
Mark Doliner <markdoliner@pidgin.im>
parents:
25899
diff
changeset
|
6048 | 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
|
6049 | 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
|
6050 | } |
|
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
|
6051 | |
|
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
|
6052 | 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
|
6053 | { |
|
27114
63f35ec28622
Block/Unblock the signal handler when if it's unblocked/blocked.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27032
diff
changeset
|
6054 | 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
|
6055 | 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
|
6056 | 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
|
6057 | 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
|
6058 | 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
|
6059 | 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
|
6060 | /* 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
|
6061 | 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
|
6062 | 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
|
6063 | 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
|
6064 | -- sad |
|
63f35ec28622
Block/Unblock the signal handler when if it's unblocked/blocked.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27032
diff
changeset
|
6065 | */ |
|
63f35ec28622
Block/Unblock the signal handler when if it's unblocked/blocked.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27032
diff
changeset
|
6066 | 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
|
6067 | 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
|
6068 | 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
|
6069 | } |
|
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
|
6070 | } else { |
|
27114
63f35ec28622
Block/Unblock the signal handler when if it's unblocked/blocked.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27032
diff
changeset
|
6071 | /* 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
|
6072 | 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
|
6073 | 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
|
6074 | } |
|
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
|
6075 | } |