Mercurial > pidgin.yaz
annotate pidgin/gtkimhtml.c @ 31604:85d5f1e37fdb
When drag-dropping an image into an IM window and sending as an inline
image in a direct IM, strip the full path from the filename and just use
the basename.ext. Fixes #13098
author | Mark Doliner <mark@kingant.net> |
---|---|
date | Tue, 25 Jan 2011 09:39:59 +0000 |
parents | ac2cf73dbab8 |
children | fa88dc1dcabb e2c6e4fc3c84 |
rev | line source |
---|---|
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1 /* |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2 * @file gtkimhtml.c GTK+ IMHtml |
16193
247e421c4fa6
Rename the Doxygen group from gtkui to pidgin.
Richard Laager <rlaager@wiktel.com>
parents:
16084
diff
changeset
|
3 * @ingroup pidgin |
20074
6bf32c9e15a7
remove gpl boilerplate from doxygen docs
Sean Egan <seanegan@gmail.com>
parents:
19680
diff
changeset
|
4 */ |
6bf32c9e15a7
remove gpl boilerplate from doxygen docs
Sean Egan <seanegan@gmail.com>
parents:
19680
diff
changeset
|
5 |
6bf32c9e15a7
remove gpl boilerplate from doxygen docs
Sean Egan <seanegan@gmail.com>
parents:
19680
diff
changeset
|
6 /* pidgin |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
7 * |
15871
66dff3dfdea6
Re-sed the copyright notices so they don't all talk about Purple.
Richard Laager <rlaager@wiktel.com>
parents:
15823
diff
changeset
|
8 * Pidgin is the legal property of its developers, whose names are too numerous |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
9 * to list here. Please refer to the COPYRIGHT file distributed with this |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
10 * source distribution. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
11 * |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
12 * This program is free software; you can redistribute it and/or modify |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
13 * under the terms of the GNU General Public License as published by |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
14 * the Free Software Foundation; either version 2 of the License, or |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
15 * (at your option) any later version. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
16 * |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
17 * This program is distributed in the hope that it will be useful, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
18 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
19 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
20 * GNU General Public License for more details. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
21 * |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
22 * You should have received a copy of the GNU General Public License |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
23 * along with this program; if not, write to the Free Software |
19680
44b4e8bd759b
The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19590
diff
changeset
|
24 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
25 * |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
26 */ |
24292
8282911d5e17
Build everything with the *_DISABLE_DEPRECATED flags set. This allows us
Richard Laager <rlaager@wiktel.com>
parents:
24269
diff
changeset
|
27 #define _PIDGIN_GTKIMHTML_C_ |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
28 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
29 #ifdef HAVE_CONFIG_H |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
30 #include <config.h> |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
31 #endif |
18056
6f7f54765822
Include pidgin.h to make this compile.
Richard Laager <rlaager@wiktel.com>
parents:
18046
diff
changeset
|
32 |
18448
4b1e2aefeb9d
Fix the win32 build. Thanks to Etan and Lee Roach. Fixes #1929.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
18398
diff
changeset
|
33 #include "internal.h" |
18056
6f7f54765822
Include pidgin.h to make this compile.
Richard Laager <rlaager@wiktel.com>
parents:
18046
diff
changeset
|
34 #include "pidgin.h" |
21664
c9946b9965c9
Kevin says we're ok defaulting persistent IMs on
Sean Egan <seanegan@gmail.com>
parents:
21648
diff
changeset
|
35 #include "pidginstock.h" |
23163
99ef50c8da91
Modified patch from malu to "Add context menu alternative to add received
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23161
diff
changeset
|
36 #include "gtkutils.h" |
99ef50c8da91
Modified patch from malu to "Add context menu alternative to add received
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23161
diff
changeset
|
37 #include "smiley.h" |
99ef50c8da91
Modified patch from malu to "Add context menu alternative to add received
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23161
diff
changeset
|
38 #include "imgstore.h" |
18056
6f7f54765822
Include pidgin.h to make this compile.
Richard Laager <rlaager@wiktel.com>
parents:
18046
diff
changeset
|
39 |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
40 #include "debug.h" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
41 #include "util.h" |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
42 #include "gtkimhtml.h" |
23163
99ef50c8da91
Modified patch from malu to "Add context menu alternative to add received
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23161
diff
changeset
|
43 #include "gtksmiley.h" |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
44 #include "gtksourceiter.h" |
17411
674d8bc2b980
Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
17245
diff
changeset
|
45 #include "gtksourceundomanager.h" |
674d8bc2b980
Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
17245
diff
changeset
|
46 #include "gtksourceview-marshal.h" |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
47 #include <gtk/gtk.h> |
26588
1a94a964bddf
More updates for GTK+ 3.0. This only fixes the single-includes. Fixing all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26526
diff
changeset
|
48 #include <glib.h> |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
49 #include <gdk/gdkkeysyms.h> |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
50 #include <string.h> |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
51 #include <ctype.h> |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
52 #include <stdio.h> |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
53 #include <stdlib.h> |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
54 #include <math.h> |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
55 #ifdef HAVE_LANGINFO_CODESET |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
56 #include <langinfo.h> |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
57 #include <locale.h> |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
58 #endif |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
59 #ifdef _WIN32 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
60 #include <gdk/gdkwin32.h> |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
61 #include <windows.h> |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
62 #endif |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
63 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
64 #include <pango/pango-font.h> |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
65 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
66 #define TOOLTIP_TIMEOUT 500 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
67 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
68 static GtkTextViewClass *parent_class = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
69 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
70 struct scalable_data { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
71 GtkIMHtmlScalable *scalable; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
72 GtkTextMark *mark; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
73 }; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
74 |
26965
655013f05eaa
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
26964
diff
changeset
|
75 typedef struct { |
655013f05eaa
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
26964
diff
changeset
|
76 GtkIMHtmlScalable *image; |
655013f05eaa
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
26964
diff
changeset
|
77 gpointer data; |
655013f05eaa
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
26964
diff
changeset
|
78 gsize datasize; |
655013f05eaa
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
26964
diff
changeset
|
79 } GtkIMHtmlImageSave; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
80 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
81 struct im_image_data { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
82 int id; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
83 GtkTextMark *mark; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
84 }; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
85 |
24548
284fd17c6020
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24397
diff
changeset
|
86 struct _GtkIMHtmlLink |
284fd17c6020
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24397
diff
changeset
|
87 { |
284fd17c6020
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24397
diff
changeset
|
88 GtkIMHtml *imhtml; |
284fd17c6020
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24397
diff
changeset
|
89 gchar *url; |
284fd17c6020
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24397
diff
changeset
|
90 GtkTextTag *tag; |
284fd17c6020
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24397
diff
changeset
|
91 }; |
284fd17c6020
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24397
diff
changeset
|
92 |
24396
38a2f78f80a7
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24311
diff
changeset
|
93 typedef struct _GtkIMHtmlProtocol |
38a2f78f80a7
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24311
diff
changeset
|
94 { |
38a2f78f80a7
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24311
diff
changeset
|
95 char *name; |
38a2f78f80a7
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24311
diff
changeset
|
96 int length; |
38a2f78f80a7
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24311
diff
changeset
|
97 |
24548
284fd17c6020
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24397
diff
changeset
|
98 gboolean (*activate)(GtkIMHtml *imhtml, GtkIMHtmlLink *link); |
284fd17c6020
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24397
diff
changeset
|
99 gboolean (*context_menu)(GtkIMHtml *imhtml, GtkIMHtmlLink *link, GtkWidget *menu); |
24396
38a2f78f80a7
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24311
diff
changeset
|
100 } GtkIMHtmlProtocol; |
38a2f78f80a7
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24311
diff
changeset
|
101 |
31550
ac2cf73dbab8
Add support for rendering strikethrough when received as in-line CSS,
Stu Tomlinson <stu@nosnilmot.com>
parents:
31534
diff
changeset
|
102 typedef struct _GtkIMHtmlFontDetail { |
ac2cf73dbab8
Add support for rendering strikethrough when received as in-line CSS,
Stu Tomlinson <stu@nosnilmot.com>
parents:
31534
diff
changeset
|
103 gushort size; |
ac2cf73dbab8
Add support for rendering strikethrough when received as in-line CSS,
Stu Tomlinson <stu@nosnilmot.com>
parents:
31534
diff
changeset
|
104 gchar *face; |
ac2cf73dbab8
Add support for rendering strikethrough when received as in-line CSS,
Stu Tomlinson <stu@nosnilmot.com>
parents:
31534
diff
changeset
|
105 gchar *fore; |
ac2cf73dbab8
Add support for rendering strikethrough when received as in-line CSS,
Stu Tomlinson <stu@nosnilmot.com>
parents:
31534
diff
changeset
|
106 gchar *back; |
ac2cf73dbab8
Add support for rendering strikethrough when received as in-line CSS,
Stu Tomlinson <stu@nosnilmot.com>
parents:
31534
diff
changeset
|
107 gchar *bg; |
ac2cf73dbab8
Add support for rendering strikethrough when received as in-line CSS,
Stu Tomlinson <stu@nosnilmot.com>
parents:
31534
diff
changeset
|
108 gchar *sml; |
ac2cf73dbab8
Add support for rendering strikethrough when received as in-line CSS,
Stu Tomlinson <stu@nosnilmot.com>
parents:
31534
diff
changeset
|
109 gboolean underline; |
ac2cf73dbab8
Add support for rendering strikethrough when received as in-line CSS,
Stu Tomlinson <stu@nosnilmot.com>
parents:
31534
diff
changeset
|
110 gboolean strike; |
ac2cf73dbab8
Add support for rendering strikethrough when received as in-line CSS,
Stu Tomlinson <stu@nosnilmot.com>
parents:
31534
diff
changeset
|
111 gshort bold; |
ac2cf73dbab8
Add support for rendering strikethrough when received as in-line CSS,
Stu Tomlinson <stu@nosnilmot.com>
parents:
31534
diff
changeset
|
112 } GtkIMHtmlFontDetail; |
ac2cf73dbab8
Add support for rendering strikethrough when received as in-line CSS,
Stu Tomlinson <stu@nosnilmot.com>
parents:
31534
diff
changeset
|
113 |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
114 static gboolean |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
115 gtk_text_view_drag_motion (GtkWidget *widget, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
116 GdkDragContext *context, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
117 gint x, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
118 gint y, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
119 guint time); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
120 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
121 static void preinsert_cb(GtkTextBuffer *buffer, GtkTextIter *iter, gchar *text, gint len, GtkIMHtml *imhtml); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
122 static void insert_cb(GtkTextBuffer *buffer, GtkTextIter *iter, gchar *text, gint len, GtkIMHtml *imhtml); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
123 static void delete_cb(GtkTextBuffer *buffer, GtkTextIter *iter, GtkTextIter *end, GtkIMHtml *imhtml); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
124 static void insert_ca_cb(GtkTextBuffer *buffer, GtkTextIter *arg1, GtkTextChildAnchor *arg2, gpointer user_data); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
125 static void gtk_imhtml_apply_tags_on_insert(GtkIMHtml *imhtml, GtkTextIter *start, GtkTextIter *end); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
126 void gtk_imhtml_close_tags(GtkIMHtml *imhtml, GtkTextIter *iter); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
127 static void gtk_imhtml_link_drop_cb(GtkWidget *widget, GdkDragContext *context, gint x, gint y, guint time, gpointer user_data); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
128 static void gtk_imhtml_link_drag_rcv_cb(GtkWidget *widget, GdkDragContext *dc, guint x, guint y, GtkSelectionData *sd, guint info, guint t, GtkIMHtml *imhtml); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
129 static void mark_set_cb(GtkTextBuffer *buffer, GtkTextIter *arg1, GtkTextMark *mark, GtkIMHtml *imhtml); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
130 static void hijack_menu_cb(GtkIMHtml *imhtml, GtkMenu *menu, gpointer data); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
131 static void paste_received_cb (GtkClipboard *clipboard, GtkSelectionData *selection_data, gpointer data); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
132 static void paste_plaintext_received_cb (GtkClipboard *clipboard, const gchar *text, gpointer data); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
133 static void imhtml_paste_insert(GtkIMHtml *imhtml, const char *text, gboolean plaintext); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
134 static void imhtml_toggle_bold(GtkIMHtml *imhtml); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
135 static void imhtml_toggle_italic(GtkIMHtml *imhtml); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
136 static void imhtml_toggle_strike(GtkIMHtml *imhtml); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
137 static void imhtml_toggle_underline(GtkIMHtml *imhtml); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
138 static void imhtml_font_grow(GtkIMHtml *imhtml); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
139 static void imhtml_font_shrink(GtkIMHtml *imhtml); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
140 static void imhtml_clear_formatting(GtkIMHtml *imhtml); |
24396
38a2f78f80a7
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24311
diff
changeset
|
141 static int gtk_imhtml_is_protocol(const char *text); |
24548
284fd17c6020
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24397
diff
changeset
|
142 static void gtk_imhtml_activate_tag(GtkIMHtml *imhtml, GtkTextTag *tag); |
284fd17c6020
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24397
diff
changeset
|
143 static void gtk_imhtml_link_destroy(GtkIMHtmlLink *link); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
144 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
145 /* POINT_SIZE converts from AIM font sizes to a point size scale factor. */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
146 #define MAX_FONT_SIZE 7 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
147 #define POINT_SIZE(x) (_point_sizes [MIN ((x > 0 ? x : 1), MAX_FONT_SIZE) - 1]) |
21015
787b3897ba9f
Patch from Andrew Gaul to constify a bunch of static variables to reduce
Ka-Hing Cheung <khc@hxbc.us>
parents:
21009
diff
changeset
|
148 static const gdouble _point_sizes [] = { .85, .95, 1, 1.2, 1.44, 1.728, 2.0736}; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
149 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
150 enum { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
151 TARGET_HTML, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
152 TARGET_UTF8_STRING, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
153 TARGET_COMPOUND_TEXT, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
154 TARGET_STRING, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
155 TARGET_TEXT |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
156 }; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
157 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
158 enum { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
159 URL_CLICKED, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
160 BUTTONS_UPDATE, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
161 TOGGLE_FORMAT, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
162 CLEAR_FORMAT, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
163 UPDATE_FORMAT, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
164 MESSAGE_SEND, |
17411
674d8bc2b980
Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
17245
diff
changeset
|
165 UNDO, |
674d8bc2b980
Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
17245
diff
changeset
|
166 REDO, |
30030
ffb8cd9fb528
Allow binding 'Paste as Plain Text'.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
29975
diff
changeset
|
167 PASTE, |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
168 LAST_SIGNAL |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
169 }; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
170 static guint signals [LAST_SIGNAL] = { 0 }; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
171 |
17678
2e1131c31941
Maintain global poitners to the clipboard selection text, with the aim of
Sean Egan <seanegan@gmail.com>
parents:
17424
diff
changeset
|
172 static char *html_clipboard = NULL; |
2e1131c31941
Maintain global poitners to the clipboard selection text, with the aim of
Sean Egan <seanegan@gmail.com>
parents:
17424
diff
changeset
|
173 static char *text_clipboard = NULL; |
21009
77e0fa7c5bdd
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 <daniel.atallah@gmail.com>
parents:
21000
diff
changeset
|
174 static GtkClipboard *clipboard_selection = NULL; |
17678
2e1131c31941
Maintain global poitners to the clipboard selection text, with the aim of
Sean Egan <seanegan@gmail.com>
parents:
17424
diff
changeset
|
175 |
21015
787b3897ba9f
Patch from Andrew Gaul to constify a bunch of static variables to reduce
Ka-Hing Cheung <khc@hxbc.us>
parents:
21009
diff
changeset
|
176 static const GtkTargetEntry selection_targets[] = { |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
177 #ifndef _WIN32 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
178 { "text/html", 0, TARGET_HTML }, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
179 #else |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
180 { "HTML Format", 0, TARGET_HTML }, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
181 #endif |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
182 { "UTF8_STRING", 0, TARGET_UTF8_STRING }, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
183 { "COMPOUND_TEXT", 0, TARGET_COMPOUND_TEXT }, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
184 { "STRING", 0, TARGET_STRING }, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
185 { "TEXT", 0, TARGET_TEXT}}; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
186 |
21015
787b3897ba9f
Patch from Andrew Gaul to constify a bunch of static variables to reduce
Ka-Hing Cheung <khc@hxbc.us>
parents:
21009
diff
changeset
|
187 static const GtkTargetEntry link_drag_drop_targets[] = { |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
188 GTK_IMHTML_DND_TARGETS |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
189 }; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
190 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
191 #ifdef _WIN32 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
192 static gchar * |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
193 clipboard_win32_to_html(char *clipboard) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
194 const char *header; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
195 const char *begin, *end; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
196 gint start = 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
197 gint finish = 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
198 gchar *html; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
199 gchar **split; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
200 int clipboard_length = 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
201 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
202 #if 0 /* Debugging for Windows clipboard */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
203 FILE *fd; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
204 |
15823 | 205 purple_debug_info("imhtml clipboard", "from clipboard: %s\n", clipboard); |
206 | |
29975
fce3282c1813
I think this works around the problem with the Win32 Clipboard and GTK+ 2.16.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
29789
diff
changeset
|
207 fd = g_fopen("c:\\purplecb.txt", "wb"); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
208 fprintf(fd, "%s", clipboard); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
209 fclose(fd); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
210 #endif |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
211 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
212 clipboard_length = strlen(clipboard); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
213 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
214 if (!(header = strstr(clipboard, "StartFragment:")) || (header - clipboard) >= clipboard_length) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
215 return NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
216 sscanf(header, "StartFragment:%d", &start); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
217 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
218 if (!(header = strstr(clipboard, "EndFragment:")) || (header - clipboard) >= clipboard_length) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
219 return NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
220 sscanf(header, "EndFragment:%d", &finish); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
221 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
222 if (finish > clipboard_length) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
223 finish = clipboard_length; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
224 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
225 if (start > finish) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
226 start = finish; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
227 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
228 begin = clipboard + start; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
229 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
230 end = clipboard + finish; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
231 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
232 html = g_strndup(begin, end - begin); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
233 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
234 /* any newlines in the string will now be \r\n, so we need to strip out the \r */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
235 split = g_strsplit(html, "\r\n", 0); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
236 g_free(html); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
237 html = g_strjoinv("\n", split); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
238 g_strfreev(split); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
239 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
240 #if 0 /* Debugging for Windows clipboard */ |
15823 | 241 purple_debug_info("imhtml clipboard", "HTML fragment: '%s'\n", html); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
242 #endif |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
243 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
244 return html; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
245 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
246 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
247 static gchar * |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
248 clipboard_html_to_win32(char *html) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
249 int length; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
250 GString *clipboard; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
251 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
252 if (html == NULL) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
253 return NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
254 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
255 length = strlen(html); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
256 clipboard = g_string_new ("Version:1.0\r\n"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
257 g_string_append(clipboard, "StartHTML:0000000105\r\n"); |
18453
f50a82a14122
Fix #1727 and also plug a possible leak and make a little efficiency improvement to the win32 clipboard handling.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
18448
diff
changeset
|
258 g_string_append_printf(clipboard, "EndHTML:%010d\r\n", 147 + length); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
259 g_string_append(clipboard, "StartFragment:0000000127\r\n"); |
18453
f50a82a14122
Fix #1727 and also plug a possible leak and make a little efficiency improvement to the win32 clipboard handling.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
18448
diff
changeset
|
260 g_string_append_printf(clipboard, "EndFragment:%010d\r\n", 127 + length); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
261 g_string_append(clipboard, "<!--StartFragment-->\r\n"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
262 g_string_append(clipboard, html); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
263 g_string_append(clipboard, "\r\n<!--EndFragment-->"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
264 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
265 return g_string_free(clipboard, FALSE); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
266 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
267 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
268 static gboolean clipboard_paste_html_win32(GtkIMHtml *imhtml) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
269 gboolean pasted = FALSE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
270 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
271 /* Win32 clipboard format value, and functions to convert back and |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
272 * forth between HTML and the clipboard format. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
273 */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
274 static UINT win_html_fmt = 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
275 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
276 /* Register HTML Format as desired clipboard format */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
277 if (!win_html_fmt) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
278 win_html_fmt = RegisterClipboardFormat("HTML Format"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
279 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
280 if (gtk_text_view_get_editable(GTK_TEXT_VIEW(imhtml)) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
281 && IsClipboardFormatAvailable(win_html_fmt)) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
282 gboolean error_reading_clipboard = FALSE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
283 HWND hwnd = GDK_WINDOW_HWND(GTK_WIDGET(imhtml)->window); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
284 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
285 if (OpenClipboard(hwnd)) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
286 HGLOBAL hdata = GetClipboardData(win_html_fmt); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
287 if (hdata == NULL) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
288 if (GetLastError() != ERROR_SUCCESS) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
289 error_reading_clipboard = TRUE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
290 } else { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
291 char *buffer = GlobalLock(hdata); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
292 if (buffer == NULL) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
293 error_reading_clipboard = TRUE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
294 } else { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
295 char *text = clipboard_win32_to_html( |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
296 buffer); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
297 imhtml_paste_insert(imhtml, text, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
298 FALSE); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
299 g_free(text); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
300 pasted = TRUE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
301 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
302 GlobalUnlock(hdata); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
303 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
304 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
305 CloseClipboard(); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
306 } else { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
307 error_reading_clipboard = TRUE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
308 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
309 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
310 if (error_reading_clipboard) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
311 gchar *err_msg = g_win32_error_message(GetLastError()); |
15823 | 312 purple_debug_info("html clipboard", |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
313 "Unable to read clipboard data: %s\n", |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
314 err_msg ? err_msg : "Unknown Error"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
315 g_free(err_msg); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
316 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
317 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
318 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
319 return pasted; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
320 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
321 #endif |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
322 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
323 static GtkSmileyTree* |
22007
c38d72677c8a
Probe for -Wstrict-prototypes to get some more warnings. I then cleaned up
Richard Laager <rlaager@wiktel.com>
parents:
21972
diff
changeset
|
324 gtk_smiley_tree_new (void) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
325 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
326 return g_new0 (GtkSmileyTree, 1); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
327 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
328 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
329 static void |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
330 gtk_smiley_tree_insert (GtkSmileyTree *tree, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
331 GtkIMHtmlSmiley *smiley) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
332 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
333 GtkSmileyTree *t = tree; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
334 const gchar *x = smiley->smile; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
335 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
336 if (!(*x)) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
337 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
338 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
339 do { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
340 gchar *pos; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
341 gint index; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
342 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
343 if (!t->values) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
344 t->values = g_string_new (""); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
345 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
346 pos = strchr (t->values->str, *x); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
347 if (!pos) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
348 t->values = g_string_append_c (t->values, *x); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
349 index = t->values->len - 1; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
350 t->children = g_realloc (t->children, t->values->len * sizeof (GtkSmileyTree *)); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
351 t->children [index] = g_new0 (GtkSmileyTree, 1); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
352 } else |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
353 index = GPOINTER_TO_INT(pos) - GPOINTER_TO_INT(t->values->str); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
354 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
355 t = t->children [index]; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
356 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
357 x++; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
358 } while (*x); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
359 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
360 t->image = smiley; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
361 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
362 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
363 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
364 static void |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
365 gtk_smiley_tree_destroy (GtkSmileyTree *tree) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
366 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
367 GSList *list = g_slist_prepend (NULL, tree); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
368 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
369 while (list) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
370 GtkSmileyTree *t = list->data; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
371 gsize i; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
372 list = g_slist_remove(list, t); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
373 if (t && t->values) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
374 for (i = 0; i < t->values->len; i++) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
375 list = g_slist_prepend (list, t->children [i]); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
376 g_string_free (t->values, TRUE); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
377 g_free (t->children); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
378 } |
25415
584063555949
Remove trailing whitespace
Mark Doliner <mark@kingant.net>
parents:
25381
diff
changeset
|
379 |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
380 g_free (t); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
381 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
382 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
383 |
18669
8425cbac2474
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@gmail.com>
parents:
18453
diff
changeset
|
384 static void (*parent_size_allocate)(GtkWidget *widget, GtkAllocation *alloc); |
8425cbac2474
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@gmail.com>
parents:
18453
diff
changeset
|
385 |
8425cbac2474
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@gmail.com>
parents:
18453
diff
changeset
|
386 static void gtk_imhtml_size_allocate(GtkWidget *widget, GtkAllocation *alloc) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
387 { |
18669
8425cbac2474
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@gmail.com>
parents:
18453
diff
changeset
|
388 GtkIMHtml *imhtml = GTK_IMHTML(widget); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
389 GdkRectangle rect; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
390 int xminus; |
18669
8425cbac2474
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@gmail.com>
parents:
18453
diff
changeset
|
391 int height = 0, y = 0; |
8425cbac2474
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@gmail.com>
parents:
18453
diff
changeset
|
392 GtkTextIter iter; |
8425cbac2474
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@gmail.com>
parents:
18453
diff
changeset
|
393 gboolean scroll = TRUE; |
8425cbac2474
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@gmail.com>
parents:
18453
diff
changeset
|
394 |
22643
0de4b47d36ab
Do not show tooltips for <HR> or <IMG>s in gtkimhtml. Fixes #5480.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22612
diff
changeset
|
395 gtk_text_buffer_get_end_iter(imhtml->text_buffer, &iter); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
396 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
397 gtk_text_view_get_visible_rect(GTK_TEXT_VIEW(widget), &rect); |
22643
0de4b47d36ab
Do not show tooltips for <HR> or <IMG>s in gtkimhtml. Fixes #5480.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22612
diff
changeset
|
398 gtk_text_view_get_line_yrange(GTK_TEXT_VIEW(imhtml), &iter, &y, &height); |
0de4b47d36ab
Do not show tooltips for <HR> or <IMG>s in gtkimhtml. Fixes #5480.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22612
diff
changeset
|
399 |
0de4b47d36ab
Do not show tooltips for <HR> or <IMG>s in gtkimhtml. Fixes #5480.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22612
diff
changeset
|
400 if (((y + height) - (rect.y + rect.height)) > height && |
0de4b47d36ab
Do not show tooltips for <HR> or <IMG>s in gtkimhtml. Fixes #5480.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22612
diff
changeset
|
401 gtk_text_buffer_get_char_count(imhtml->text_buffer)) { |
0de4b47d36ab
Do not show tooltips for <HR> or <IMG>s in gtkimhtml. Fixes #5480.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22612
diff
changeset
|
402 scroll = FALSE; |
0de4b47d36ab
Do not show tooltips for <HR> or <IMG>s in gtkimhtml. Fixes #5480.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22612
diff
changeset
|
403 } |
0de4b47d36ab
Do not show tooltips for <HR> or <IMG>s in gtkimhtml. Fixes #5480.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22612
diff
changeset
|
404 |
0de4b47d36ab
Do not show tooltips for <HR> or <IMG>s in gtkimhtml. Fixes #5480.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22612
diff
changeset
|
405 if(imhtml->old_rect.width != rect.width || imhtml->old_rect.height != rect.height) { |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
406 GList *iter = GTK_IMHTML(widget)->scalables; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
407 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
408 xminus = gtk_text_view_get_left_margin(GTK_TEXT_VIEW(widget)) + |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
409 gtk_text_view_get_right_margin(GTK_TEXT_VIEW(widget)); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
410 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
411 while(iter){ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
412 struct scalable_data *sd = iter->data; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
413 GtkIMHtmlScalable *scale = GTK_IMHTML_SCALABLE(sd->scalable); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
414 scale->scale(scale, rect.width - xminus, rect.height); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
415 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
416 iter = iter->next; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
417 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
418 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
419 |
18669
8425cbac2474
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@gmail.com>
parents:
18453
diff
changeset
|
420 imhtml->old_rect = rect; |
8425cbac2474
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@gmail.com>
parents:
18453
diff
changeset
|
421 parent_size_allocate(widget, alloc); |
22643
0de4b47d36ab
Do not show tooltips for <HR> or <IMG>s in gtkimhtml. Fixes #5480.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22612
diff
changeset
|
422 |
18736 | 423 /* Don't scroll here if we're in the middle of a smooth scroll */ |
19261
88c6bf371abb
Don't scroll to bottom if imhtml is not realized. Fixes #2320
Sean Egan <seanegan@gmail.com>
parents:
19260
diff
changeset
|
424 if (scroll && imhtml->scroll_time == NULL && |
22643
0de4b47d36ab
Do not show tooltips for <HR> or <IMG>s in gtkimhtml. Fixes #5480.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22612
diff
changeset
|
425 GTK_WIDGET_REALIZED(imhtml)) |
0de4b47d36ab
Do not show tooltips for <HR> or <IMG>s in gtkimhtml. Fixes #5480.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22612
diff
changeset
|
426 gtk_imhtml_scroll_to_end(imhtml, FALSE); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
427 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
428 |
23005
f11fc3fb5b8c
Use text-tags to set the weight/color of the nick in conversations. This
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22797
diff
changeset
|
429 #define DEFAULT_SEND_COLOR "#204a87" |
f11fc3fb5b8c
Use text-tags to set the weight/color of the nick in conversations. This
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22797
diff
changeset
|
430 #define DEFAULT_RECV_COLOR "#cc0000" |
f11fc3fb5b8c
Use text-tags to set the weight/color of the nick in conversations. This
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22797
diff
changeset
|
431 #define DEFAULT_HIGHLIGHT_COLOR "#AF7F00" |
f11fc3fb5b8c
Use text-tags to set the weight/color of the nick in conversations. This
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22797
diff
changeset
|
432 #define DEFAULT_ACTION_COLOR "#062585" |
f11fc3fb5b8c
Use text-tags to set the weight/color of the nick in conversations. This
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22797
diff
changeset
|
433 #define DEFAULT_WHISPER_ACTION_COLOR "#6C2585" |
f11fc3fb5b8c
Use text-tags to set the weight/color of the nick in conversations. This
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22797
diff
changeset
|
434 #define DEFAULT_WHISPER_COLOR "#00FF00" |
f11fc3fb5b8c
Use text-tags to set the weight/color of the nick in conversations. This
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22797
diff
changeset
|
435 |
f11fc3fb5b8c
Use text-tags to set the weight/color of the nick in conversations. This
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22797
diff
changeset
|
436 static void (*parent_style_set)(GtkWidget *widget, GtkStyle *prev_style); |
f11fc3fb5b8c
Use text-tags to set the weight/color of the nick in conversations. This
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22797
diff
changeset
|
437 |
f11fc3fb5b8c
Use text-tags to set the weight/color of the nick in conversations. This
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22797
diff
changeset
|
438 static void |
f11fc3fb5b8c
Use text-tags to set the weight/color of the nick in conversations. This
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22797
diff
changeset
|
439 gtk_imhtml_style_set(GtkWidget *widget, GtkStyle *prev_style) |
f11fc3fb5b8c
Use text-tags to set the weight/color of the nick in conversations. This
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22797
diff
changeset
|
440 { |
f11fc3fb5b8c
Use text-tags to set the weight/color of the nick in conversations. This
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22797
diff
changeset
|
441 int i; |
f11fc3fb5b8c
Use text-tags to set the weight/color of the nick in conversations. This
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22797
diff
changeset
|
442 struct { |
f11fc3fb5b8c
Use text-tags to set the weight/color of the nick in conversations. This
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22797
diff
changeset
|
443 const char *tag; |
f11fc3fb5b8c
Use text-tags to set the weight/color of the nick in conversations. This
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22797
diff
changeset
|
444 const char *color; |
f11fc3fb5b8c
Use text-tags to set the weight/color of the nick in conversations. This
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22797
diff
changeset
|
445 const char *def; |
f11fc3fb5b8c
Use text-tags to set the weight/color of the nick in conversations. This
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22797
diff
changeset
|
446 } styles[] = { |
f11fc3fb5b8c
Use text-tags to set the weight/color of the nick in conversations. This
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22797
diff
changeset
|
447 {"send-name", "send-name-color", DEFAULT_SEND_COLOR}, |
f11fc3fb5b8c
Use text-tags to set the weight/color of the nick in conversations. This
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22797
diff
changeset
|
448 {"receive-name", "receive-name-color", DEFAULT_RECV_COLOR}, |
f11fc3fb5b8c
Use text-tags to set the weight/color of the nick in conversations. This
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22797
diff
changeset
|
449 {"highlight-name", "highlight-name-color", DEFAULT_HIGHLIGHT_COLOR}, |
f11fc3fb5b8c
Use text-tags to set the weight/color of the nick in conversations. This
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22797
diff
changeset
|
450 {"action-name", "action-name-color", DEFAULT_ACTION_COLOR}, |
f11fc3fb5b8c
Use text-tags to set the weight/color of the nick in conversations. This
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22797
diff
changeset
|
451 {"whisper-action-name", "whisper-action-name-color", DEFAULT_WHISPER_ACTION_COLOR}, |
f11fc3fb5b8c
Use text-tags to set the weight/color of the nick in conversations. This
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22797
diff
changeset
|
452 {"whisper-name", "whisper-name-color", DEFAULT_WHISPER_COLOR}, |
f11fc3fb5b8c
Use text-tags to set the weight/color of the nick in conversations. This
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22797
diff
changeset
|
453 {NULL, NULL, NULL} |
f11fc3fb5b8c
Use text-tags to set the weight/color of the nick in conversations. This
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22797
diff
changeset
|
454 }; |
f11fc3fb5b8c
Use text-tags to set the weight/color of the nick in conversations. This
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22797
diff
changeset
|
455 GtkIMHtml *imhtml = GTK_IMHTML(widget); |
f11fc3fb5b8c
Use text-tags to set the weight/color of the nick in conversations. This
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22797
diff
changeset
|
456 GtkTextTagTable *table = gtk_text_buffer_get_tag_table(imhtml->text_buffer); |
f11fc3fb5b8c
Use text-tags to set the weight/color of the nick in conversations. This
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22797
diff
changeset
|
457 |
f11fc3fb5b8c
Use text-tags to set the weight/color of the nick in conversations. This
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22797
diff
changeset
|
458 for (i = 0; styles[i].tag; i++) { |
f11fc3fb5b8c
Use text-tags to set the weight/color of the nick in conversations. This
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22797
diff
changeset
|
459 GdkColor *color = NULL; |
f11fc3fb5b8c
Use text-tags to set the weight/color of the nick in conversations. This
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22797
diff
changeset
|
460 GtkTextTag *tag = gtk_text_tag_table_lookup(table, styles[i].tag); |
f11fc3fb5b8c
Use text-tags to set the weight/color of the nick in conversations. This
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22797
diff
changeset
|
461 if (!tag) { |
f11fc3fb5b8c
Use text-tags to set the weight/color of the nick in conversations. This
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22797
diff
changeset
|
462 purple_debug_warning("gtkimhtml", "Cannot find tag '%s'. This should never happen. Please file a bug.\n", styles[i].tag); |
f11fc3fb5b8c
Use text-tags to set the weight/color of the nick in conversations. This
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22797
diff
changeset
|
463 continue; |
f11fc3fb5b8c
Use text-tags to set the weight/color of the nick in conversations. This
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22797
diff
changeset
|
464 } |
f11fc3fb5b8c
Use text-tags to set the weight/color of the nick in conversations. This
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22797
diff
changeset
|
465 gtk_widget_style_get(widget, styles[i].color, &color, NULL); |
f11fc3fb5b8c
Use text-tags to set the weight/color of the nick in conversations. This
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22797
diff
changeset
|
466 if (color) { |
f11fc3fb5b8c
Use text-tags to set the weight/color of the nick in conversations. This
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22797
diff
changeset
|
467 g_object_set(tag, "foreground-gdk", color, NULL); |
f11fc3fb5b8c
Use text-tags to set the weight/color of the nick in conversations. This
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22797
diff
changeset
|
468 gdk_color_free(color); |
f11fc3fb5b8c
Use text-tags to set the weight/color of the nick in conversations. This
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22797
diff
changeset
|
469 } else { |
f11fc3fb5b8c
Use text-tags to set the weight/color of the nick in conversations. This
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22797
diff
changeset
|
470 GdkColor defcolor; |
f11fc3fb5b8c
Use text-tags to set the weight/color of the nick in conversations. This
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22797
diff
changeset
|
471 gdk_color_parse(styles[i].def, &defcolor); |
f11fc3fb5b8c
Use text-tags to set the weight/color of the nick in conversations. This
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22797
diff
changeset
|
472 g_object_set(tag, "foreground-gdk", &defcolor, NULL); |
f11fc3fb5b8c
Use text-tags to set the weight/color of the nick in conversations. This
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22797
diff
changeset
|
473 } |
f11fc3fb5b8c
Use text-tags to set the weight/color of the nick in conversations. This
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22797
diff
changeset
|
474 } |
f11fc3fb5b8c
Use text-tags to set the weight/color of the nick in conversations. This
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22797
diff
changeset
|
475 parent_style_set(widget, prev_style); |
f11fc3fb5b8c
Use text-tags to set the weight/color of the nick in conversations. This
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22797
diff
changeset
|
476 } |
f11fc3fb5b8c
Use text-tags to set the weight/color of the nick in conversations. This
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22797
diff
changeset
|
477 |
28982
a169c5c81ef5
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
28979
diff
changeset
|
478 static gboolean |
a169c5c81ef5
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
28979
diff
changeset
|
479 imhtml_get_iter_bounds(GtkIMHtml *imhtml, GtkTextIter *start, GtkTextIter *end) |
a169c5c81ef5
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
28979
diff
changeset
|
480 { |
a169c5c81ef5
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
28979
diff
changeset
|
481 if (imhtml->wbfo) { |
a169c5c81ef5
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
28979
diff
changeset
|
482 gtk_text_buffer_get_bounds(imhtml->text_buffer, start, end); |
a169c5c81ef5
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
28979
diff
changeset
|
483 return TRUE; |
a169c5c81ef5
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
28979
diff
changeset
|
484 } else if (imhtml->editable) { |
a169c5c81ef5
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
28979
diff
changeset
|
485 if (!gtk_text_buffer_get_selection_bounds(imhtml->text_buffer, start, end)) { |
a169c5c81ef5
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
28979
diff
changeset
|
486 GtkTextMark *mark = gtk_text_buffer_get_insert(imhtml->text_buffer); |
a169c5c81ef5
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
28979
diff
changeset
|
487 gtk_text_buffer_get_iter_at_mark(imhtml->text_buffer, start, mark); |
a169c5c81ef5
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
28979
diff
changeset
|
488 *end = *start; |
a169c5c81ef5
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
28979
diff
changeset
|
489 } |
a169c5c81ef5
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
28979
diff
changeset
|
490 return TRUE; |
a169c5c81ef5
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
28979
diff
changeset
|
491 } |
a169c5c81ef5
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
28979
diff
changeset
|
492 |
a169c5c81ef5
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
28979
diff
changeset
|
493 return FALSE; |
a169c5c81ef5
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
28979
diff
changeset
|
494 } |
a169c5c81ef5
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
28979
diff
changeset
|
495 |
24061
0d0f99cd425e
Show visited links in a different color. This also plugs a memory leak
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23411
diff
changeset
|
496 static void |
0d0f99cd425e
Show visited links in a different color. This also plugs a memory leak
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23411
diff
changeset
|
497 gtk_imhtml_set_link_color(GtkIMHtml *imhtml, GtkTextTag *tag) |
0d0f99cd425e
Show visited links in a different color. This also plugs a memory leak
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23411
diff
changeset
|
498 { |
0d0f99cd425e
Show visited links in a different color. This also plugs a memory leak
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23411
diff
changeset
|
499 GdkColor *color = NULL; |
0d0f99cd425e
Show visited links in a different color. This also plugs a memory leak
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23411
diff
changeset
|
500 gboolean visited = !!g_object_get_data(G_OBJECT(tag), "visited"); |
0d0f99cd425e
Show visited links in a different color. This also plugs a memory leak
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23411
diff
changeset
|
501 gtk_widget_style_get(GTK_WIDGET(imhtml), visited ? "hyperlink-visited-color" : "hyperlink-color", &color, NULL); |
0d0f99cd425e
Show visited links in a different color. This also plugs a memory leak
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23411
diff
changeset
|
502 if (color) { |
0d0f99cd425e
Show visited links in a different color. This also plugs a memory leak
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23411
diff
changeset
|
503 g_object_set(G_OBJECT(tag), "foreground-gdk", color, NULL); |
0d0f99cd425e
Show visited links in a different color. This also plugs a memory leak
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23411
diff
changeset
|
504 gdk_color_free(color); |
0d0f99cd425e
Show visited links in a different color. This also plugs a memory leak
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23411
diff
changeset
|
505 } else { |
0d0f99cd425e
Show visited links in a different color. This also plugs a memory leak
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23411
diff
changeset
|
506 g_object_set(G_OBJECT(tag), "foreground", visited ? "#800000" : "blue", NULL); |
0d0f99cd425e
Show visited links in a different color. This also plugs a memory leak
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23411
diff
changeset
|
507 } |
0d0f99cd425e
Show visited links in a different color. This also plugs a memory leak
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23411
diff
changeset
|
508 } |
0d0f99cd425e
Show visited links in a different color. This also plugs a memory leak
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23411
diff
changeset
|
509 |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
510 static gint |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
511 gtk_imhtml_tip_paint (GtkIMHtml *imhtml) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
512 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
513 PangoLayout *layout; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
514 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
515 g_return_val_if_fail(GTK_IS_IMHTML(imhtml), FALSE); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
516 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
517 layout = gtk_widget_create_pango_layout(imhtml->tip_window, imhtml->tip); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
518 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
519 gtk_paint_flat_box (imhtml->tip_window->style, imhtml->tip_window->window, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
520 GTK_STATE_NORMAL, GTK_SHADOW_OUT, NULL, imhtml->tip_window, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
521 "tooltip", 0, 0, -1, -1); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
522 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
523 gtk_paint_layout (imhtml->tip_window->style, imhtml->tip_window->window, GTK_STATE_NORMAL, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
524 FALSE, NULL, imhtml->tip_window, NULL, 4, 4, layout); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
525 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
526 g_object_unref(layout); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
527 return FALSE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
528 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
529 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
530 static gint |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
531 gtk_imhtml_tip (gpointer data) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
532 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
533 GtkIMHtml *imhtml = data; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
534 PangoFontMetrics *font_metrics; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
535 PangoLayout *layout; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
536 PangoFont *font; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
537 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
538 gint gap, x, y, h, w, scr_w, baseline_skip; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
539 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
540 g_return_val_if_fail(GTK_IS_IMHTML(imhtml), FALSE); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
541 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
542 if (!imhtml->tip || !GTK_WIDGET_DRAWABLE (GTK_WIDGET(imhtml))) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
543 imhtml->tip_timer = 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
544 return FALSE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
545 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
546 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
547 if (imhtml->tip_window){ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
548 gtk_widget_destroy (imhtml->tip_window); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
549 imhtml->tip_window = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
550 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
551 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
552 imhtml->tip_timer = 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
553 imhtml->tip_window = gtk_window_new (GTK_WINDOW_POPUP); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
554 gtk_widget_set_app_paintable (imhtml->tip_window, TRUE); |
29200
2df96ace4f33
Call gtk_window_set_title() for the GtkIMHtml tip window, to avoid the
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
28987
diff
changeset
|
555 gtk_window_set_title(GTK_WINDOW(imhtml->tip_window), "GtkIMHtml"); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
556 gtk_window_set_resizable (GTK_WINDOW (imhtml->tip_window), FALSE); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
557 gtk_widget_set_name (imhtml->tip_window, "gtk-tooltips"); |
22445
af83f19d8c08
Set the TOOLTIP hint on imhtml link tooltips. Thanks to Danny Baumann for
Will Thompson <will.thompson@collabora.co.uk>
parents:
22387
diff
changeset
|
558 gtk_window_set_type_hint (GTK_WINDOW (imhtml->tip_window), |
af83f19d8c08
Set the TOOLTIP hint on imhtml link tooltips. Thanks to Danny Baumann for
Will Thompson <will.thompson@collabora.co.uk>
parents:
22387
diff
changeset
|
559 GDK_WINDOW_TYPE_HINT_TOOLTIP); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
560 g_signal_connect_swapped (G_OBJECT (imhtml->tip_window), "expose_event", |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
561 G_CALLBACK (gtk_imhtml_tip_paint), imhtml); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
562 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
563 gtk_widget_ensure_style (imhtml->tip_window); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
564 layout = gtk_widget_create_pango_layout(imhtml->tip_window, imhtml->tip); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
565 font = pango_context_load_font(pango_layout_get_context(layout), |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
566 imhtml->tip_window->style->font_desc); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
567 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
568 if (font == NULL) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
569 char *tmp = pango_font_description_to_string( |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
570 imhtml->tip_window->style->font_desc); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
571 |
15823 | 572 purple_debug(PURPLE_DEBUG_ERROR, "gtk_imhtml_tip", |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
573 "pango_context_load_font() couldn't load font: '%s'\n", |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
574 tmp); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
575 g_free(tmp); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
576 |
23034
25233b528b66
applied changes from a341780d901f6351a5cf768a08d30c8882d6cf2f
Daniel Atallah <daniel.atallah@gmail.com>
parents:
22797
diff
changeset
|
577 g_object_unref(layout); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
578 return FALSE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
579 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
580 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
581 font_metrics = pango_font_get_metrics(font, NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
582 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
583 pango_layout_get_pixel_size(layout, &scr_w, NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
584 gap = PANGO_PIXELS((pango_font_metrics_get_ascent(font_metrics) + |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
585 pango_font_metrics_get_descent(font_metrics))/ 4); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
586 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
587 if (gap < 2) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
588 gap = 2; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
589 baseline_skip = PANGO_PIXELS(pango_font_metrics_get_ascent(font_metrics) + |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
590 pango_font_metrics_get_descent(font_metrics)); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
591 w = 8 + scr_w; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
592 h = 8 + baseline_skip; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
593 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
594 gdk_window_get_pointer (NULL, &x, &y, NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
595 if (GTK_WIDGET_NO_WINDOW (GTK_WIDGET(imhtml))) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
596 y += GTK_WIDGET(imhtml)->allocation.y; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
597 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
598 scr_w = gdk_screen_width(); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
599 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
600 x -= ((w >> 1) + 4); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
601 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
602 if ((x + w) > scr_w) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
603 x -= (x + w) - scr_w; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
604 else if (x < 0) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
605 x = 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
606 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
607 y = y + PANGO_PIXELS(pango_font_metrics_get_ascent(font_metrics) + |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
608 pango_font_metrics_get_descent(font_metrics)); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
609 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
610 gtk_widget_set_size_request (imhtml->tip_window, w, h); |
15804
ca5d548bd88d
Move the tooltip window before showing the tooltip to avoid a transient
Stu Tomlinson <stu@nosnilmot.com>
parents:
15514
diff
changeset
|
611 gtk_window_move (GTK_WINDOW(imhtml->tip_window), x, y); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
612 gtk_widget_show (imhtml->tip_window); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
613 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
614 pango_font_metrics_unref(font_metrics); |
23034
25233b528b66
applied changes from a341780d901f6351a5cf768a08d30c8882d6cf2f
Daniel Atallah <daniel.atallah@gmail.com>
parents:
22797
diff
changeset
|
615 g_object_unref(font); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
616 g_object_unref(layout); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
617 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
618 return FALSE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
619 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
620 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
621 static gboolean |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
622 gtk_motion_event_notify(GtkWidget *imhtml, GdkEventMotion *event, gpointer data) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
623 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
624 GtkTextIter iter; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
625 GdkWindow *win = event->window; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
626 int x, y; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
627 char *tip = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
628 GSList *tags = NULL, *templist = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
629 GtkTextTag *tag = NULL, *oldprelit_tag; |
18392
693f9b544e2b
Show tooltip for smileys. Fixes #1981.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18308
diff
changeset
|
630 GtkTextChildAnchor* anchor; |
693f9b544e2b
Show tooltip for smileys. Fixes #1981.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18308
diff
changeset
|
631 gboolean hand = TRUE; |
29378
fdb61f7e8576
Change the cursor and act on double click on usernames in chat history.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
29357
diff
changeset
|
632 GdkCursor *cursor = NULL; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
633 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
634 oldprelit_tag = GTK_IMHTML(imhtml)->prelit_tag; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
635 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
636 gdk_window_get_pointer(GTK_WIDGET(imhtml)->window, NULL, NULL, NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
637 gtk_text_view_window_to_buffer_coords(GTK_TEXT_VIEW(imhtml), GTK_TEXT_WINDOW_WIDGET, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
638 event->x, event->y, &x, &y); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
639 gtk_text_view_get_iter_at_location(GTK_TEXT_VIEW(imhtml), &iter, x, y); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
640 tags = gtk_text_iter_get_tags(&iter); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
641 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
642 templist = tags; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
643 while (templist) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
644 tag = templist->data; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
645 tip = g_object_get_data(G_OBJECT(tag), "link_url"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
646 if (tip) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
647 break; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
648 templist = templist->next; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
649 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
650 |
24061
0d0f99cd425e
Show visited links in a different color. This also plugs a memory leak
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23411
diff
changeset
|
651 if (tip && (!tag || !g_object_get_data(G_OBJECT(tag), "visited"))) { |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
652 GTK_IMHTML(imhtml)->prelit_tag = tag; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
653 if (tag != oldprelit_tag) { |
24061
0d0f99cd425e
Show visited links in a different color. This also plugs a memory leak
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23411
diff
changeset
|
654 GdkColor *pre = NULL; |
0d0f99cd425e
Show visited links in a different color. This also plugs a memory leak
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23411
diff
changeset
|
655 gtk_widget_style_get(GTK_WIDGET(imhtml), "hyperlink-prelight-color", &pre, NULL); |
0d0f99cd425e
Show visited links in a different color. This also plugs a memory leak
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23411
diff
changeset
|
656 if (pre) { |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
657 g_object_set(G_OBJECT(tag), "foreground-gdk", pre, NULL); |
24061
0d0f99cd425e
Show visited links in a different color. This also plugs a memory leak
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23411
diff
changeset
|
658 gdk_color_free(pre); |
0d0f99cd425e
Show visited links in a different color. This also plugs a memory leak
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23411
diff
changeset
|
659 } else |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
660 g_object_set(G_OBJECT(tag), "foreground", "#70a0ff", NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
661 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
662 } else { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
663 GTK_IMHTML(imhtml)->prelit_tag = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
664 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
665 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
666 if ((oldprelit_tag != NULL) && (GTK_IMHTML(imhtml)->prelit_tag != oldprelit_tag)) { |
24061
0d0f99cd425e
Show visited links in a different color. This also plugs a memory leak
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23411
diff
changeset
|
667 gtk_imhtml_set_link_color(GTK_IMHTML(imhtml), oldprelit_tag); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
668 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
669 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
670 if (GTK_IMHTML(imhtml)->tip) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
671 if ((tip == GTK_IMHTML(imhtml)->tip)) { |
20993 | 672 g_slist_free(tags); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
673 return FALSE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
674 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
675 /* We've left the cell. Remove the timeout and create a new one below */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
676 if (GTK_IMHTML(imhtml)->tip_window) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
677 gtk_widget_destroy(GTK_IMHTML(imhtml)->tip_window); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
678 GTK_IMHTML(imhtml)->tip_window = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
679 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
680 if (GTK_IMHTML(imhtml)->editable) |
29378
fdb61f7e8576
Change the cursor and act on double click on usernames in chat history.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
29357
diff
changeset
|
681 cursor = GTK_IMHTML(imhtml)->text_cursor; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
682 else |
29378
fdb61f7e8576
Change the cursor and act on double click on usernames in chat history.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
29357
diff
changeset
|
683 cursor = GTK_IMHTML(imhtml)->arrow_cursor; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
684 if (GTK_IMHTML(imhtml)->tip_timer) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
685 g_source_remove(GTK_IMHTML(imhtml)->tip_timer); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
686 GTK_IMHTML(imhtml)->tip_timer = 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
687 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
688 |
18392
693f9b544e2b
Show tooltip for smileys. Fixes #1981.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18308
diff
changeset
|
689 /* If we don't have a tip from a URL, let's see if we have a tip from a smiley */ |
693f9b544e2b
Show tooltip for smileys. Fixes #1981.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18308
diff
changeset
|
690 anchor = gtk_text_iter_get_child_anchor(&iter); |
693f9b544e2b
Show tooltip for smileys. Fixes #1981.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18308
diff
changeset
|
691 if (anchor) { |
22643
0de4b47d36ab
Do not show tooltips for <HR> or <IMG>s in gtkimhtml. Fixes #5480.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22612
diff
changeset
|
692 tip = g_object_get_data(G_OBJECT(anchor), "gtkimhtml_tiptext"); |
18392
693f9b544e2b
Show tooltip for smileys. Fixes #1981.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18308
diff
changeset
|
693 hand = FALSE; |
693f9b544e2b
Show tooltip for smileys. Fixes #1981.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18308
diff
changeset
|
694 } |
693f9b544e2b
Show tooltip for smileys. Fixes #1981.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
18308
diff
changeset
|
695 |
22643
0de4b47d36ab
Do not show tooltips for <HR> or <IMG>s in gtkimhtml. Fixes #5480.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22612
diff
changeset
|
696 if (tip && *tip) { |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
697 GTK_IMHTML(imhtml)->tip_timer = g_timeout_add (TOOLTIP_TIMEOUT, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
698 gtk_imhtml_tip, imhtml); |
29378
fdb61f7e8576
Change the cursor and act on double click on usernames in chat history.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
29357
diff
changeset
|
699 } else if (!tip) { |
fdb61f7e8576
Change the cursor and act on double click on usernames in chat history.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
29357
diff
changeset
|
700 hand = FALSE; |
fdb61f7e8576
Change the cursor and act on double click on usernames in chat history.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
29357
diff
changeset
|
701 for (templist = tags; templist; templist = templist->next) { |
fdb61f7e8576
Change the cursor and act on double click on usernames in chat history.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
29357
diff
changeset
|
702 tag = templist->data; |
fdb61f7e8576
Change the cursor and act on double click on usernames in chat history.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
29357
diff
changeset
|
703 if ((tip = g_object_get_data(G_OBJECT(tag), "cursor"))) { |
fdb61f7e8576
Change the cursor and act on double click on usernames in chat history.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
29357
diff
changeset
|
704 hand = TRUE; |
fdb61f7e8576
Change the cursor and act on double click on usernames in chat history.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
29357
diff
changeset
|
705 break; |
fdb61f7e8576
Change the cursor and act on double click on usernames in chat history.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
29357
diff
changeset
|
706 } |
fdb61f7e8576
Change the cursor and act on double click on usernames in chat history.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
29357
diff
changeset
|
707 } |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
708 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
709 |
29378
fdb61f7e8576
Change the cursor and act on double click on usernames in chat history.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
29357
diff
changeset
|
710 if (hand && !(GTK_IMHTML(imhtml)->editable)) |
fdb61f7e8576
Change the cursor and act on double click on usernames in chat history.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
29357
diff
changeset
|
711 cursor = GTK_IMHTML(imhtml)->hand_cursor; |
fdb61f7e8576
Change the cursor and act on double click on usernames in chat history.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
29357
diff
changeset
|
712 |
fdb61f7e8576
Change the cursor and act on double click on usernames in chat history.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
29357
diff
changeset
|
713 if (cursor) |
fdb61f7e8576
Change the cursor and act on double click on usernames in chat history.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
29357
diff
changeset
|
714 gdk_window_set_cursor(win, cursor); |
fdb61f7e8576
Change the cursor and act on double click on usernames in chat history.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
29357
diff
changeset
|
715 |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
716 GTK_IMHTML(imhtml)->tip = tip; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
717 g_slist_free(tags); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
718 return FALSE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
719 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
720 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
721 static gboolean |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
722 gtk_enter_event_notify(GtkWidget *imhtml, GdkEventCrossing *event, gpointer data) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
723 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
724 if (GTK_IMHTML(imhtml)->editable) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
725 gdk_window_set_cursor( |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
726 gtk_text_view_get_window(GTK_TEXT_VIEW(imhtml), |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
727 GTK_TEXT_WINDOW_TEXT), |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
728 GTK_IMHTML(imhtml)->text_cursor); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
729 else |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
730 gdk_window_set_cursor( |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
731 gtk_text_view_get_window(GTK_TEXT_VIEW(imhtml), |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
732 GTK_TEXT_WINDOW_TEXT), |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
733 GTK_IMHTML(imhtml)->arrow_cursor); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
734 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
735 /* propagate the event normally */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
736 return FALSE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
737 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
738 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
739 static gboolean |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
740 gtk_leave_event_notify(GtkWidget *imhtml, GdkEventCrossing *event, gpointer data) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
741 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
742 /* when leaving the widget, clear any current & pending tooltips and restore the cursor */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
743 if (GTK_IMHTML(imhtml)->prelit_tag) { |
24061
0d0f99cd425e
Show visited links in a different color. This also plugs a memory leak
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23411
diff
changeset
|
744 gtk_imhtml_set_link_color(GTK_IMHTML(imhtml), GTK_IMHTML(imhtml)->prelit_tag); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
745 GTK_IMHTML(imhtml)->prelit_tag = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
746 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
747 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
748 if (GTK_IMHTML(imhtml)->tip_window) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
749 gtk_widget_destroy(GTK_IMHTML(imhtml)->tip_window); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
750 GTK_IMHTML(imhtml)->tip_window = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
751 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
752 if (GTK_IMHTML(imhtml)->tip_timer) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
753 g_source_remove(GTK_IMHTML(imhtml)->tip_timer); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
754 GTK_IMHTML(imhtml)->tip_timer = 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
755 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
756 gdk_window_set_cursor( |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
757 gtk_text_view_get_window(GTK_TEXT_VIEW(imhtml), |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
758 GTK_TEXT_WINDOW_TEXT), NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
759 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
760 /* propagate the event normally */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
761 return FALSE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
762 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
763 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
764 static gint |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
765 gtk_imhtml_expose_event (GtkWidget *widget, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
766 GdkEventExpose *event) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
767 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
768 GtkTextIter start, end, cur; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
769 int buf_x, buf_y; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
770 GdkRectangle visible_rect; |
31442
25d93d273e9c
Replace GdkGC in GtkIMHtml. Just in case you were wondering, it's now
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30592
diff
changeset
|
771 cairo_t *cr = gdk_cairo_create(GDK_DRAWABLE(event->window)); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
772 GdkColor gcolor; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
773 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
774 gtk_text_view_get_visible_rect(GTK_TEXT_VIEW(widget), &visible_rect); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
775 gtk_text_view_buffer_to_window_coords(GTK_TEXT_VIEW(widget), |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
776 GTK_TEXT_WINDOW_TEXT, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
777 visible_rect.x, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
778 visible_rect.y, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
779 &visible_rect.x, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
780 &visible_rect.y); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
781 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
782 gtk_text_view_window_to_buffer_coords(GTK_TEXT_VIEW(widget), GTK_TEXT_WINDOW_TEXT, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
783 event->area.x, event->area.y, &buf_x, &buf_y); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
784 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
785 if (GTK_IMHTML(widget)->editable || GTK_IMHTML(widget)->wbfo) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
786 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
787 if (GTK_IMHTML(widget)->edit.background) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
788 gdk_color_parse(GTK_IMHTML(widget)->edit.background, &gcolor); |
31442
25d93d273e9c
Replace GdkGC in GtkIMHtml. Just in case you were wondering, it's now
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30592
diff
changeset
|
789 gdk_cairo_set_source_color(cr, &gcolor); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
790 } else { |
31442
25d93d273e9c
Replace GdkGC in GtkIMHtml. Just in case you were wondering, it's now
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30592
diff
changeset
|
791 gdk_cairo_set_source_color(cr, &(widget->style->base[GTK_WIDGET_STATE(widget)])); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
792 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
793 |
31442
25d93d273e9c
Replace GdkGC in GtkIMHtml. Just in case you were wondering, it's now
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30592
diff
changeset
|
794 cairo_rectangle(cr, |
25d93d273e9c
Replace GdkGC in GtkIMHtml. Just in case you were wondering, it's now
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30592
diff
changeset
|
795 visible_rect.x, visible_rect.y, |
25d93d273e9c
Replace GdkGC in GtkIMHtml. Just in case you were wondering, it's now
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30592
diff
changeset
|
796 visible_rect.width, visible_rect.height); |
25d93d273e9c
Replace GdkGC in GtkIMHtml. Just in case you were wondering, it's now
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30592
diff
changeset
|
797 cairo_fill(cr); |
25d93d273e9c
Replace GdkGC in GtkIMHtml. Just in case you were wondering, it's now
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30592
diff
changeset
|
798 cairo_destroy(cr); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
799 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
800 if (GTK_WIDGET_CLASS (parent_class)->expose_event) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
801 return (* GTK_WIDGET_CLASS (parent_class)->expose_event) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
802 (widget, event); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
803 return FALSE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
804 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
805 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
806 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
807 gtk_text_view_get_iter_at_location(GTK_TEXT_VIEW(widget), &start, buf_x, buf_y); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
808 gtk_text_view_get_iter_at_location(GTK_TEXT_VIEW(widget), &end, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
809 buf_x + event->area.width, buf_y + event->area.height); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
810 |
23047
76ae43c5e745
*** Plucked rev 69b22e32f7ada182101e0746f02891389ceb0c52 (sadrul@pidgin.im):
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23034
diff
changeset
|
811 gtk_text_iter_order(&start, &end); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
812 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
813 cur = start; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
814 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
815 while (gtk_text_iter_in_range(&cur, &start, &end)) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
816 GSList *tags = gtk_text_iter_get_tags(&cur); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
817 GSList *l; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
818 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
819 for (l = tags; l; l = l->next) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
820 GtkTextTag *tag = l->data; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
821 GdkRectangle rect; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
822 GdkRectangle tag_area; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
823 const char *color; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
824 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
825 if (strncmp(tag->name, "BACKGROUND ", 11)) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
826 continue; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
827 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
828 if (gtk_text_iter_ends_tag(&cur, tag)) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
829 continue; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
830 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
831 gtk_text_view_get_iter_location(GTK_TEXT_VIEW(widget), &cur, &tag_area); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
832 gtk_text_view_buffer_to_window_coords(GTK_TEXT_VIEW(widget), |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
833 GTK_TEXT_WINDOW_TEXT, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
834 tag_area.x, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
835 tag_area.y, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
836 &tag_area.x, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
837 &tag_area.y); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
838 rect.x = visible_rect.x; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
839 rect.y = tag_area.y; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
840 rect.width = visible_rect.width; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
841 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
842 do |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
843 gtk_text_iter_forward_to_tag_toggle(&cur, tag); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
844 while (!gtk_text_iter_is_end(&cur) && gtk_text_iter_begins_tag(&cur, tag)); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
845 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
846 gtk_text_view_get_iter_location(GTK_TEXT_VIEW(widget), &cur, &tag_area); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
847 gtk_text_view_buffer_to_window_coords(GTK_TEXT_VIEW(widget), |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
848 GTK_TEXT_WINDOW_TEXT, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
849 tag_area.x, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
850 tag_area.y, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
851 &tag_area.x, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
852 &tag_area.y); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
853 |
25415
584063555949
Remove trailing whitespace
Mark Doliner <mark@kingant.net>
parents:
25381
diff
changeset
|
854 |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
855 rect.height = tag_area.y + tag_area.height - rect.y |
22705
9bc93b4b0f92
Move 2 of the 5 pixels' padding between paragraphs to above the line.
Will Thompson <will.thompson@collabora.co.uk>
parents:
22674
diff
changeset
|
856 + gtk_text_view_get_pixels_above_lines(GTK_TEXT_VIEW(widget)) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
857 + gtk_text_view_get_pixels_below_lines(GTK_TEXT_VIEW(widget)); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
858 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
859 color = tag->name + 11; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
860 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
861 if (!gdk_color_parse(color, &gcolor)) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
862 gchar tmp[8]; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
863 tmp[0] = '#'; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
864 strncpy(&tmp[1], color, 7); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
865 tmp[7] = '\0'; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
866 if (!gdk_color_parse(tmp, &gcolor)) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
867 gdk_color_parse("white", &gcolor); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
868 } |
31442
25d93d273e9c
Replace GdkGC in GtkIMHtml. Just in case you were wondering, it's now
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30592
diff
changeset
|
869 gdk_cairo_set_source_color(cr, &gcolor); |
25d93d273e9c
Replace GdkGC in GtkIMHtml. Just in case you were wondering, it's now
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30592
diff
changeset
|
870 |
25d93d273e9c
Replace GdkGC in GtkIMHtml. Just in case you were wondering, it's now
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30592
diff
changeset
|
871 cairo_rectangle(cr, |
25d93d273e9c
Replace GdkGC in GtkIMHtml. Just in case you were wondering, it's now
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30592
diff
changeset
|
872 rect.x, rect.y, |
25d93d273e9c
Replace GdkGC in GtkIMHtml. Just in case you were wondering, it's now
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30592
diff
changeset
|
873 rect.width, rect.height); |
25d93d273e9c
Replace GdkGC in GtkIMHtml. Just in case you were wondering, it's now
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30592
diff
changeset
|
874 cairo_fill(cr); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
875 gtk_text_iter_backward_char(&cur); /* go back one, in case the end is the begining is the end |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
876 * note that above, we always moved cur ahead by at least |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
877 * one character */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
878 break; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
879 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
880 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
881 g_slist_free(tags); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
882 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
883 /* loop until another tag begins, or no tag begins */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
884 while (gtk_text_iter_forward_to_tag_toggle(&cur, NULL) && |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
885 !gtk_text_iter_is_end(&cur) && |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
886 !gtk_text_iter_begins_tag(&cur, NULL)); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
887 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
888 |
31442
25d93d273e9c
Replace GdkGC in GtkIMHtml. Just in case you were wondering, it's now
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
30592
diff
changeset
|
889 cairo_destroy(cr); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
890 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
891 if (GTK_WIDGET_CLASS (parent_class)->expose_event) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
892 return (* GTK_WIDGET_CLASS (parent_class)->expose_event) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
893 (widget, event); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
894 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
895 return FALSE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
896 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
897 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
898 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
899 static void paste_unformatted_cb(GtkMenuItem *menu, GtkIMHtml *imhtml) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
900 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
901 GtkClipboard *clipboard = gtk_widget_get_clipboard(GTK_WIDGET(imhtml), GDK_SELECTION_CLIPBOARD); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
902 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
903 gtk_clipboard_request_text(clipboard, paste_plaintext_received_cb, imhtml); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
904 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
905 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
906 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
907 static void clear_formatting_cb(GtkMenuItem *menu, GtkIMHtml *imhtml) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
908 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
909 gtk_imhtml_clear_formatting(imhtml); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
910 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
911 |
22797
900c7b5660d5
Allow replacing smileys with texts in conversations/logs. This should be
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22705
diff
changeset
|
912 static void disable_smiley_selected(GtkMenuItem *item, GtkIMHtml *imhtml) |
900c7b5660d5
Allow replacing smileys with texts in conversations/logs. This should be
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22705
diff
changeset
|
913 { |
900c7b5660d5
Allow replacing smileys with texts in conversations/logs. This should be
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22705
diff
changeset
|
914 GtkTextIter start, end; |
900c7b5660d5
Allow replacing smileys with texts in conversations/logs. This should be
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22705
diff
changeset
|
915 GtkTextMark *mark; |
900c7b5660d5
Allow replacing smileys with texts in conversations/logs. This should be
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22705
diff
changeset
|
916 char *text; |
900c7b5660d5
Allow replacing smileys with texts in conversations/logs. This should be
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22705
diff
changeset
|
917 |
900c7b5660d5
Allow replacing smileys with texts in conversations/logs. This should be
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22705
diff
changeset
|
918 if (!gtk_text_buffer_get_selection_bounds(imhtml->text_buffer, &start, &end)) |
900c7b5660d5
Allow replacing smileys with texts in conversations/logs. This should be
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22705
diff
changeset
|
919 return; |
900c7b5660d5
Allow replacing smileys with texts in conversations/logs. This should be
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22705
diff
changeset
|
920 |
900c7b5660d5
Allow replacing smileys with texts in conversations/logs. This should be
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22705
diff
changeset
|
921 text = gtk_imhtml_get_markup_range(imhtml, &start, &end); |
900c7b5660d5
Allow replacing smileys with texts in conversations/logs. This should be
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22705
diff
changeset
|
922 |
900c7b5660d5
Allow replacing smileys with texts in conversations/logs. This should be
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22705
diff
changeset
|
923 mark = gtk_text_buffer_get_selection_bound(imhtml->text_buffer); |
900c7b5660d5
Allow replacing smileys with texts in conversations/logs. This should be
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22705
diff
changeset
|
924 gtk_text_buffer_delete_selection(imhtml->text_buffer, FALSE, FALSE); |
900c7b5660d5
Allow replacing smileys with texts in conversations/logs. This should be
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22705
diff
changeset
|
925 |
900c7b5660d5
Allow replacing smileys with texts in conversations/logs. This should be
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22705
diff
changeset
|
926 gtk_text_buffer_get_iter_at_mark(imhtml->text_buffer, &start, mark); |
900c7b5660d5
Allow replacing smileys with texts in conversations/logs. This should be
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22705
diff
changeset
|
927 gtk_imhtml_insert_html_at_iter(imhtml, text, GTK_IMHTML_NO_NEWLINE | GTK_IMHTML_NO_SMILEY, &start); |
900c7b5660d5
Allow replacing smileys with texts in conversations/logs. This should be
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22705
diff
changeset
|
928 |
900c7b5660d5
Allow replacing smileys with texts in conversations/logs. This should be
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22705
diff
changeset
|
929 g_free(text); |
900c7b5660d5
Allow replacing smileys with texts in conversations/logs. This should be
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22705
diff
changeset
|
930 } |
900c7b5660d5
Allow replacing smileys with texts in conversations/logs. This should be
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22705
diff
changeset
|
931 |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
932 static void hijack_menu_cb(GtkIMHtml *imhtml, GtkMenu *menu, gpointer data) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
933 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
934 GtkWidget *menuitem; |
22797
900c7b5660d5
Allow replacing smileys with texts in conversations/logs. This should be
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22705
diff
changeset
|
935 GtkTextIter start, end; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
936 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
937 menuitem = gtk_menu_item_new_with_mnemonic(_("Paste as Plain _Text")); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
938 gtk_widget_show(menuitem); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
939 /* |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
940 * TODO: gtk_clipboard_wait_is_text_available() iterates the glib |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
941 * mainloop, which tends to be a source of bugs. It would |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
942 * be good to audit this or change it to not wait. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
943 */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
944 gtk_widget_set_sensitive(menuitem, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
945 (imhtml->editable && |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
946 gtk_clipboard_wait_is_text_available( |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
947 gtk_widget_get_clipboard(GTK_WIDGET(imhtml), GDK_SELECTION_CLIPBOARD)))); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
948 /* put it after "Paste" */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
949 gtk_menu_shell_insert(GTK_MENU_SHELL(menu), menuitem, 3); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
950 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
951 g_signal_connect(G_OBJECT(menuitem), "activate", |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
952 G_CALLBACK(paste_unformatted_cb), imhtml); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
953 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
954 menuitem = gtk_menu_item_new_with_mnemonic(_("_Reset formatting")); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
955 gtk_widget_show(menuitem); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
956 gtk_widget_set_sensitive(menuitem, imhtml->editable); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
957 /* put it after Delete */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
958 gtk_menu_shell_insert(GTK_MENU_SHELL(menu), menuitem, 5); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
959 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
960 g_signal_connect(G_OBJECT(menuitem), "activate", G_CALLBACK(clear_formatting_cb), imhtml); |
22797
900c7b5660d5
Allow replacing smileys with texts in conversations/logs. This should be
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22705
diff
changeset
|
961 |
900c7b5660d5
Allow replacing smileys with texts in conversations/logs. This should be
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22705
diff
changeset
|
962 menuitem = gtk_menu_item_new_with_mnemonic(_("Disable _smileys in selected text")); |
900c7b5660d5
Allow replacing smileys with texts in conversations/logs. This should be
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22705
diff
changeset
|
963 gtk_widget_show(menuitem); |
900c7b5660d5
Allow replacing smileys with texts in conversations/logs. This should be
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22705
diff
changeset
|
964 if (gtk_text_buffer_get_selection_bounds(imhtml->text_buffer, &start, &end)) { |
900c7b5660d5
Allow replacing smileys with texts in conversations/logs. This should be
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22705
diff
changeset
|
965 g_signal_connect(G_OBJECT(menuitem), "activate", G_CALLBACK(disable_smiley_selected), imhtml); |
900c7b5660d5
Allow replacing smileys with texts in conversations/logs. This should be
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22705
diff
changeset
|
966 } else { |
900c7b5660d5
Allow replacing smileys with texts in conversations/logs. This should be
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22705
diff
changeset
|
967 gtk_widget_set_sensitive(menuitem, FALSE); |
900c7b5660d5
Allow replacing smileys with texts in conversations/logs. This should be
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22705
diff
changeset
|
968 } |
900c7b5660d5
Allow replacing smileys with texts in conversations/logs. This should be
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22705
diff
changeset
|
969 gtk_menu_shell_insert(GTK_MENU_SHELL(menu), menuitem, 6); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
970 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
971 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
972 static char * |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
973 ucs2_order(gboolean swap) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
974 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
975 gboolean be; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
976 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
977 be = G_BYTE_ORDER == G_BIG_ENDIAN; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
978 be = swap ? be : !be; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
979 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
980 if (be) |
22447
9b154f484d64
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 <daniel.atallah@gmail.com>
parents:
22446
diff
changeset
|
981 return "UTF-16BE"; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
982 else |
22447
9b154f484d64
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 <daniel.atallah@gmail.com>
parents:
22446
diff
changeset
|
983 return "UTF-16LE"; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
984 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
985 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
986 |
22447
9b154f484d64
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 <daniel.atallah@gmail.com>
parents:
22446
diff
changeset
|
987 /* Convert from UTF-16LE to UTF-8, stripping the BOM if one is present.*/ |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
988 static gchar * |
22447
9b154f484d64
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 <daniel.atallah@gmail.com>
parents:
22446
diff
changeset
|
989 utf16_to_utf8_with_bom_check(gchar *data, guint len) { |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
990 char *fromcode = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
991 GError *error = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
992 guint16 c; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
993 gchar *utf8_ret; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
994 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
995 /* |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
996 * Unicode Techinical Report 20 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
997 * ( http://www.unicode.org/unicode/reports/tr20/ ) says to treat an |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
998 * initial 0xfeff (ZWNBSP) as a byte order indicator so that is |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
999 * what we do. If there is no indicator assume it is in the default |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1000 * order |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1001 */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1002 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1003 memcpy(&c, data, 2); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1004 switch (c) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1005 case 0xfeff: |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1006 case 0xfffe: |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1007 fromcode = ucs2_order(c == 0xfeff); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1008 data += 2; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1009 len -= 2; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1010 break; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1011 default: |
22447
9b154f484d64
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 <daniel.atallah@gmail.com>
parents:
22446
diff
changeset
|
1012 fromcode = "UTF-16"; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1013 break; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1014 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1015 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1016 utf8_ret = g_convert(data, len, "UTF-8", fromcode, NULL, NULL, &error); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1017 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1018 if (error) { |
15823 | 1019 purple_debug_warning("gtkimhtml", "g_convert error: %s\n", error->message); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1020 g_error_free(error); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1021 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1022 return utf8_ret; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1023 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1024 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1025 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1026 static void gtk_imhtml_clipboard_get(GtkClipboard *clipboard, GtkSelectionData *selection_data, guint info, GtkIMHtml *imhtml) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1027 char *text = NULL; |
17678
2e1131c31941
Maintain global poitners to the clipboard selection text, with the aim of
Sean Egan <seanegan@gmail.com>
parents:
17424
diff
changeset
|
1028 gboolean primary = (clipboard != clipboard_selection); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1029 GtkTextIter start, end; |
21009
77e0fa7c5bdd
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 <daniel.atallah@gmail.com>
parents:
21000
diff
changeset
|
1030 |
77e0fa7c5bdd
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 <daniel.atallah@gmail.com>
parents:
21000
diff
changeset
|
1031 if (primary) { |
77e0fa7c5bdd
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 <daniel.atallah@gmail.com>
parents:
21000
diff
changeset
|
1032 GtkTextMark *sel = NULL, *ins = NULL; |
21557
cba1683eeafc
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 <daniel.atallah@gmail.com>
parents:
21488
diff
changeset
|
1033 |
cba1683eeafc
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 <daniel.atallah@gmail.com>
parents:
21488
diff
changeset
|
1034 g_return_if_fail(imhtml != NULL); |
cba1683eeafc
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 <daniel.atallah@gmail.com>
parents:
21488
diff
changeset
|
1035 |
17678
2e1131c31941
Maintain global poitners to the clipboard selection text, with the aim of
Sean Egan <seanegan@gmail.com>
parents:
17424
diff
changeset
|
1036 ins = gtk_text_buffer_get_insert(imhtml->text_buffer); |
2e1131c31941
Maintain global poitners to the clipboard selection text, with the aim of
Sean Egan <seanegan@gmail.com>
parents:
17424
diff
changeset
|
1037 sel = gtk_text_buffer_get_selection_bound(imhtml->text_buffer); |
2e1131c31941
Maintain global poitners to the clipboard selection text, with the aim of
Sean Egan <seanegan@gmail.com>
parents:
17424
diff
changeset
|
1038 gtk_text_buffer_get_iter_at_mark(imhtml->text_buffer, &start, sel); |
2e1131c31941
Maintain global poitners to the clipboard selection text, with the aim of
Sean Egan <seanegan@gmail.com>
parents:
17424
diff
changeset
|
1039 gtk_text_buffer_get_iter_at_mark(imhtml->text_buffer, &end, ins); |
2e1131c31941
Maintain global poitners to the clipboard selection text, with the aim of
Sean Egan <seanegan@gmail.com>
parents:
17424
diff
changeset
|
1040 } |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1041 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1042 if (info == TARGET_HTML) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1043 char *selection; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1044 #ifndef _WIN32 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1045 gsize len; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1046 if (primary) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1047 text = gtk_imhtml_get_markup_range(imhtml, &start, &end); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1048 } else |
17678
2e1131c31941
Maintain global poitners to the clipboard selection text, with the aim of
Sean Egan <seanegan@gmail.com>
parents:
17424
diff
changeset
|
1049 text = html_clipboard; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1050 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1051 /* Mozilla asks that we start our text/html with the Unicode byte order mark */ |
23061
7b7744995791
*** Plucked rev da43d671 (sadrul@pidgin.im):
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23047
diff
changeset
|
1052 selection = g_convert(text, -1, "UTF-16", "UTF-8", NULL, &len, NULL); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1053 gtk_selection_data_set(selection_data, gdk_atom_intern("text/html", FALSE), 16, (const guchar *)selection, len); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1054 #else |
18453
f50a82a14122
Fix #1727 and also plug a possible leak and make a little efficiency improvement to the win32 clipboard handling.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
18448
diff
changeset
|
1055 selection = clipboard_html_to_win32(html_clipboard); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1056 gtk_selection_data_set(selection_data, gdk_atom_intern("HTML Format", FALSE), 8, (const guchar *)selection, strlen(selection)); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1057 #endif |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1058 g_free(selection); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1059 } else { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1060 if (primary) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1061 text = gtk_imhtml_get_text(imhtml, &start, &end); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1062 } else |
17678
2e1131c31941
Maintain global poitners to the clipboard selection text, with the aim of
Sean Egan <seanegan@gmail.com>
parents:
17424
diff
changeset
|
1063 text = text_clipboard; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1064 gtk_selection_data_set_text(selection_data, text, strlen(text)); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1065 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1066 if (primary) /* This was allocated here */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1067 g_free(text); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1068 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1069 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1070 static void gtk_imhtml_primary_clipboard_clear(GtkClipboard *clipboard, GtkIMHtml *imhtml) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1071 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1072 GtkTextIter insert; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1073 GtkTextIter selection_bound; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1074 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1075 gtk_text_buffer_get_iter_at_mark (imhtml->text_buffer, &insert, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1076 gtk_text_buffer_get_mark (imhtml->text_buffer, "insert")); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1077 gtk_text_buffer_get_iter_at_mark (imhtml->text_buffer, &selection_bound, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1078 gtk_text_buffer_get_mark (imhtml->text_buffer, "selection_bound")); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1079 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1080 if (!gtk_text_iter_equal (&insert, &selection_bound)) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1081 gtk_text_buffer_move_mark (imhtml->text_buffer, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1082 gtk_text_buffer_get_mark (imhtml->text_buffer, "selection_bound"), |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1083 &insert); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1084 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1085 |
17678
2e1131c31941
Maintain global poitners to the clipboard selection text, with the aim of
Sean Egan <seanegan@gmail.com>
parents:
17424
diff
changeset
|
1086 static void gtk_imhtml_clipboard_clear (GtkClipboard *clipboard, GtkSelectionData *sel_data, |
2e1131c31941
Maintain global poitners to the clipboard selection text, with the aim of
Sean Egan <seanegan@gmail.com>
parents:
17424
diff
changeset
|
1087 guint info, gpointer user_data_or_owner) |
2e1131c31941
Maintain global poitners to the clipboard selection text, with the aim of
Sean Egan <seanegan@gmail.com>
parents:
17424
diff
changeset
|
1088 { |
2e1131c31941
Maintain global poitners to the clipboard selection text, with the aim of
Sean Egan <seanegan@gmail.com>
parents:
17424
diff
changeset
|
1089 } |
2e1131c31941
Maintain global poitners to the clipboard selection text, with the aim of
Sean Egan <seanegan@gmail.com>
parents:
17424
diff
changeset
|
1090 |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1091 static void copy_clipboard_cb(GtkIMHtml *imhtml, gpointer unused) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1092 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1093 GtkTextIter start, end; |
17245
05fa005bdc59
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 <daniel.atallah@gmail.com>
parents:
17148
diff
changeset
|
1094 if (gtk_text_buffer_get_selection_bounds(imhtml->text_buffer, &start, &end)) { |
17678
2e1131c31941
Maintain global poitners to the clipboard selection text, with the aim of
Sean Egan <seanegan@gmail.com>
parents:
17424
diff
changeset
|
1095 if (!clipboard_selection) |
2e1131c31941
Maintain global poitners to the clipboard selection text, with the aim of
Sean Egan <seanegan@gmail.com>
parents:
17424
diff
changeset
|
1096 clipboard_selection = gtk_widget_get_clipboard(GTK_WIDGET(imhtml), GDK_SELECTION_CLIPBOARD); |
21009
77e0fa7c5bdd
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 <daniel.atallah@gmail.com>
parents:
21000
diff
changeset
|
1097 gtk_clipboard_set_with_data(clipboard_selection, |
17245
05fa005bdc59
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 <daniel.atallah@gmail.com>
parents:
17148
diff
changeset
|
1098 selection_targets, sizeof(selection_targets) / sizeof(GtkTargetEntry), |
05fa005bdc59
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 <daniel.atallah@gmail.com>
parents:
17148
diff
changeset
|
1099 (GtkClipboardGetFunc)gtk_imhtml_clipboard_get, |
21009
77e0fa7c5bdd
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 <daniel.atallah@gmail.com>
parents:
21000
diff
changeset
|
1100 (GtkClipboardClearFunc)gtk_imhtml_clipboard_clear, NULL); |
17245
05fa005bdc59
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 <daniel.atallah@gmail.com>
parents:
17148
diff
changeset
|
1101 |
18453
f50a82a14122
Fix #1727 and also plug a possible leak and make a little efficiency improvement to the win32 clipboard handling.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
18448
diff
changeset
|
1102 g_free(html_clipboard); |
f50a82a14122
Fix #1727 and also plug a possible leak and make a little efficiency improvement to the win32 clipboard handling.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
18448
diff
changeset
|
1103 g_free(text_clipboard); |
17245
05fa005bdc59
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 <daniel.atallah@gmail.com>
parents:
17148
diff
changeset
|
1104 |
21009
77e0fa7c5bdd
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 <daniel.atallah@gmail.com>
parents:
21000
diff
changeset
|
1105 html_clipboard = gtk_imhtml_get_markup_range(imhtml, &start, &end); |
77e0fa7c5bdd
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 <daniel.atallah@gmail.com>
parents:
21000
diff
changeset
|
1106 text_clipboard = gtk_imhtml_get_text(imhtml, &start, &end); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1107 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1108 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1109 g_signal_stop_emission_by_name(imhtml, "copy-clipboard"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1110 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1111 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1112 static void cut_clipboard_cb(GtkIMHtml *imhtml, gpointer unused) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1113 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1114 GtkTextIter start, end; |
17245
05fa005bdc59
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 <daniel.atallah@gmail.com>
parents:
17148
diff
changeset
|
1115 if (gtk_text_buffer_get_selection_bounds(imhtml->text_buffer, &start, &end)) { |
17678
2e1131c31941
Maintain global poitners to the clipboard selection text, with the aim of
Sean Egan <seanegan@gmail.com>
parents:
17424
diff
changeset
|
1116 if (!clipboard_selection) |
2e1131c31941
Maintain global poitners to the clipboard selection text, with the aim of
Sean Egan <seanegan@gmail.com>
parents:
17424
diff
changeset
|
1117 clipboard_selection = gtk_widget_get_clipboard(GTK_WIDGET(imhtml), GDK_SELECTION_CLIPBOARD); |
21009
77e0fa7c5bdd
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 <daniel.atallah@gmail.com>
parents:
21000
diff
changeset
|
1118 gtk_clipboard_set_with_data(clipboard_selection, |
17245
05fa005bdc59
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 <daniel.atallah@gmail.com>
parents:
17148
diff
changeset
|
1119 selection_targets, sizeof(selection_targets) / sizeof(GtkTargetEntry), |
05fa005bdc59
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 <daniel.atallah@gmail.com>
parents:
17148
diff
changeset
|
1120 (GtkClipboardGetFunc)gtk_imhtml_clipboard_get, |
21009
77e0fa7c5bdd
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 <daniel.atallah@gmail.com>
parents:
21000
diff
changeset
|
1121 (GtkClipboardClearFunc)gtk_imhtml_clipboard_clear, NULL); |
17245
05fa005bdc59
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 <daniel.atallah@gmail.com>
parents:
17148
diff
changeset
|
1122 |
18453
f50a82a14122
Fix #1727 and also plug a possible leak and make a little efficiency improvement to the win32 clipboard handling.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
18448
diff
changeset
|
1123 g_free(html_clipboard); |
f50a82a14122
Fix #1727 and also plug a possible leak and make a little efficiency improvement to the win32 clipboard handling.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
18448
diff
changeset
|
1124 g_free(text_clipboard); |
17245
05fa005bdc59
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 <daniel.atallah@gmail.com>
parents:
17148
diff
changeset
|
1125 |
21009
77e0fa7c5bdd
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 <daniel.atallah@gmail.com>
parents:
21000
diff
changeset
|
1126 html_clipboard = gtk_imhtml_get_markup_range(imhtml, &start, &end); |
77e0fa7c5bdd
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 <daniel.atallah@gmail.com>
parents:
21000
diff
changeset
|
1127 text_clipboard = gtk_imhtml_get_text(imhtml, &start, &end); |
17678
2e1131c31941
Maintain global poitners to the clipboard selection text, with the aim of
Sean Egan <seanegan@gmail.com>
parents:
17424
diff
changeset
|
1128 |
17245
05fa005bdc59
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 <daniel.atallah@gmail.com>
parents:
17148
diff
changeset
|
1129 if (imhtml->editable) |
05fa005bdc59
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 <daniel.atallah@gmail.com>
parents:
17148
diff
changeset
|
1130 gtk_text_buffer_delete_selection(imhtml->text_buffer, FALSE, FALSE); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1131 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1132 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1133 g_signal_stop_emission_by_name(imhtml, "cut-clipboard"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1134 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1135 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1136 static void imhtml_paste_insert(GtkIMHtml *imhtml, const char *text, gboolean plaintext) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1137 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1138 GtkTextIter iter; |
21650
1f6935a5d189
Patch from 'goutnet' to not insert smileys when pasting as plain text.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21648
diff
changeset
|
1139 GtkIMHtmlOptions flags = plaintext ? GTK_IMHTML_NO_SMILEY : (GTK_IMHTML_NO_NEWLINE | GTK_IMHTML_NO_COMMENTS); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1140 |
25426
7942287364c2
The first thing gtk_text_buffer_delete_selection does is call
Mark Doliner <mark@kingant.net>
parents:
25415
diff
changeset
|
1141 /* Delete any currently selected text */ |
7942287364c2
The first thing gtk_text_buffer_delete_selection does is call
Mark Doliner <mark@kingant.net>
parents:
25415
diff
changeset
|
1142 gtk_text_buffer_delete_selection(imhtml->text_buffer, TRUE, TRUE); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1143 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1144 gtk_text_buffer_get_iter_at_mark(imhtml->text_buffer, &iter, gtk_text_buffer_get_insert(imhtml->text_buffer)); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1145 if (!imhtml->wbfo && !plaintext) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1146 gtk_imhtml_close_tags(imhtml, &iter); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1147 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1148 gtk_imhtml_insert_html_at_iter(imhtml, text, flags, &iter); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1149 gtk_text_buffer_move_mark_by_name(imhtml->text_buffer, "insert", &iter); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1150 gtk_text_view_scroll_to_mark(GTK_TEXT_VIEW(imhtml), gtk_text_buffer_get_insert(imhtml->text_buffer), |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1151 0, FALSE, 0.0, 0.0); |
18291
db4b0aa4ed8c
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@gmail.com>
parents:
18220
diff
changeset
|
1152 if (!imhtml->wbfo && !plaintext) |
db4b0aa4ed8c
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@gmail.com>
parents:
18220
diff
changeset
|
1153 gtk_imhtml_close_tags(imhtml, &iter); |
db4b0aa4ed8c
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@gmail.com>
parents:
18220
diff
changeset
|
1154 |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1155 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1156 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1157 static void paste_plaintext_received_cb (GtkClipboard *clipboard, const gchar *text, gpointer data) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1158 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1159 char *tmp; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1160 |
19192
33fed83f56c8
malloc(0) returns a null pointer. Fixes #2472.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
18801
diff
changeset
|
1161 if (text == NULL || !(*text)) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1162 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1163 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1164 tmp = g_markup_escape_text(text, -1); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1165 imhtml_paste_insert(data, tmp, TRUE); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1166 g_free(tmp); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1167 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1168 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1169 static void paste_received_cb (GtkClipboard *clipboard, GtkSelectionData *selection_data, gpointer data) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1170 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1171 char *text; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1172 GtkIMHtml *imhtml = data; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1173 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1174 if (!gtk_text_view_get_editable(GTK_TEXT_VIEW(imhtml))) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1175 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1176 |
19192
33fed83f56c8
malloc(0) returns a null pointer. Fixes #2472.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
18801
diff
changeset
|
1177 if (imhtml->wbfo || selection_data->length <= 0) { |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1178 gtk_clipboard_request_text(clipboard, paste_plaintext_received_cb, imhtml); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1179 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1180 } else { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1181 #if 0 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1182 /* Here's some debug code, for figuring out what sent to us over the clipboard. */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1183 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1184 int i; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1185 |
15823 | 1186 purple_debug_misc("gtkimhtml", "In paste_received_cb():\n\tformat = %d, length = %d\n\t", |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1187 selection_data->format, selection_data->length); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1188 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1189 for (i = 0; i < (/*(selection_data->format / 8) **/ selection_data->length); i++) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1190 if ((i % 70) == 0) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1191 printf("\n\t"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1192 if (selection_data->data[i] == '\0') |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1193 printf("."); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1194 else |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1195 printf("%c", selection_data->data[i]); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1196 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1197 printf("\n"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1198 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1199 #endif |
30159
6eeb50155af8
gtkimhtml: Fix handling of pastes whose data isn't NULL-terminated
Paul Aurich <paul@darkrain42.org>
parents:
30030
diff
changeset
|
1200 |
6eeb50155af8
gtkimhtml: Fix handling of pastes whose data isn't NULL-terminated
Paul Aurich <paul@darkrain42.org>
parents:
30030
diff
changeset
|
1201 text = g_malloc(selection_data->length + 1); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1202 memcpy(text, selection_data->data, selection_data->length); |
30159
6eeb50155af8
gtkimhtml: Fix handling of pastes whose data isn't NULL-terminated
Paul Aurich <paul@darkrain42.org>
parents:
30030
diff
changeset
|
1203 /* Make sure the paste data is null-terminated. Given that |
30160 | 1204 * we're passed length (but assume later that it is |
1205 * null-terminated), this seems sensible to me. | |
30159
6eeb50155af8
gtkimhtml: Fix handling of pastes whose data isn't NULL-terminated
Paul Aurich <paul@darkrain42.org>
parents:
30030
diff
changeset
|
1206 */ |
6eeb50155af8
gtkimhtml: Fix handling of pastes whose data isn't NULL-terminated
Paul Aurich <paul@darkrain42.org>
parents:
30030
diff
changeset
|
1207 text[selection_data->length] = '\0'; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1208 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1209 |
29975
fce3282c1813
I think this works around the problem with the Win32 Clipboard and GTK+ 2.16.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
29789
diff
changeset
|
1210 #ifdef _WIN32 |
fce3282c1813
I think this works around the problem with the Win32 Clipboard and GTK+ 2.16.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
29789
diff
changeset
|
1211 if (gtk_selection_data_get_data_type(selection_data) == gdk_atom_intern("HTML Format", FALSE)) { |
fce3282c1813
I think this works around the problem with the Win32 Clipboard and GTK+ 2.16.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
29789
diff
changeset
|
1212 char *tmp = clipboard_win32_to_html(text); |
fce3282c1813
I think this works around the problem with the Win32 Clipboard and GTK+ 2.16.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
29789
diff
changeset
|
1213 g_free(text); |
fce3282c1813
I think this works around the problem with the Win32 Clipboard and GTK+ 2.16.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
29789
diff
changeset
|
1214 text = tmp; |
fce3282c1813
I think this works around the problem with the Win32 Clipboard and GTK+ 2.16.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
29789
diff
changeset
|
1215 } |
fce3282c1813
I think this works around the problem with the Win32 Clipboard and GTK+ 2.16.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
29789
diff
changeset
|
1216 #endif |
fce3282c1813
I think this works around the problem with the Win32 Clipboard and GTK+ 2.16.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
29789
diff
changeset
|
1217 |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1218 if (selection_data->length >= 2 && |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1219 (*(guint16 *)text == 0xfeff || *(guint16 *)text == 0xfffe)) { |
22447
9b154f484d64
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 <daniel.atallah@gmail.com>
parents:
22446
diff
changeset
|
1220 /* This is UTF-16 */ |
9b154f484d64
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 <daniel.atallah@gmail.com>
parents:
22446
diff
changeset
|
1221 char *utf8 = utf16_to_utf8_with_bom_check(text, selection_data->length); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1222 g_free(text); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1223 text = utf8; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1224 if (!text) { |
22447
9b154f484d64
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 <daniel.atallah@gmail.com>
parents:
22446
diff
changeset
|
1225 purple_debug_warning("gtkimhtml", "g_convert from UTF-16 failed in paste_received_cb\n"); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1226 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1227 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1228 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1229 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1230 if (!(*text) || !g_utf8_validate(text, -1, NULL)) { |
15823 | 1231 purple_debug_warning("gtkimhtml", "empty string or invalid UTF-8 in paste_received_cb\n"); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1232 g_free(text); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1233 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1234 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1235 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1236 imhtml_paste_insert(imhtml, text, FALSE); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1237 g_free(text); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1238 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1239 |
21648
3aa34d20d798
Patch from 'goutnet': Pressing backspace on a smiley will replace the smiley
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21558
diff
changeset
|
1240 |
3aa34d20d798
Patch from 'goutnet': Pressing backspace on a smiley will replace the smiley
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21558
diff
changeset
|
1241 static void smart_backspace_cb(GtkIMHtml *imhtml, gpointer blah) |
3aa34d20d798
Patch from 'goutnet': Pressing backspace on a smiley will replace the smiley
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21558
diff
changeset
|
1242 { |
3aa34d20d798
Patch from 'goutnet': Pressing backspace on a smiley will replace the smiley
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21558
diff
changeset
|
1243 GtkTextIter iter; |
3aa34d20d798
Patch from 'goutnet': Pressing backspace on a smiley will replace the smiley
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21558
diff
changeset
|
1244 GtkTextChildAnchor* anchor; |
3aa34d20d798
Patch from 'goutnet': Pressing backspace on a smiley will replace the smiley
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21558
diff
changeset
|
1245 char * text; |
3aa34d20d798
Patch from 'goutnet': Pressing backspace on a smiley will replace the smiley
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21558
diff
changeset
|
1246 gint offset; |
3aa34d20d798
Patch from 'goutnet': Pressing backspace on a smiley will replace the smiley
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21558
diff
changeset
|
1247 |
3aa34d20d798
Patch from 'goutnet': Pressing backspace on a smiley will replace the smiley
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21558
diff
changeset
|
1248 if (!imhtml->editable) |
3aa34d20d798
Patch from 'goutnet': Pressing backspace on a smiley will replace the smiley
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21558
diff
changeset
|
1249 return; |
3aa34d20d798
Patch from 'goutnet': Pressing backspace on a smiley will replace the smiley
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21558
diff
changeset
|
1250 |
3aa34d20d798
Patch from 'goutnet': Pressing backspace on a smiley will replace the smiley
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21558
diff
changeset
|
1251 gtk_text_buffer_get_iter_at_mark(imhtml->text_buffer, &iter, gtk_text_buffer_get_insert(imhtml->text_buffer)); |
3aa34d20d798
Patch from 'goutnet': Pressing backspace on a smiley will replace the smiley
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21558
diff
changeset
|
1252 |
3aa34d20d798
Patch from 'goutnet': Pressing backspace on a smiley will replace the smiley
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21558
diff
changeset
|
1253 /* Get the character before the insertion point */ |
3aa34d20d798
Patch from 'goutnet': Pressing backspace on a smiley will replace the smiley
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21558
diff
changeset
|
1254 offset = gtk_text_iter_get_offset(&iter); |
3aa34d20d798
Patch from 'goutnet': Pressing backspace on a smiley will replace the smiley
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21558
diff
changeset
|
1255 if (offset <= 0) |
3aa34d20d798
Patch from 'goutnet': Pressing backspace on a smiley will replace the smiley
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21558
diff
changeset
|
1256 return; |
3aa34d20d798
Patch from 'goutnet': Pressing backspace on a smiley will replace the smiley
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21558
diff
changeset
|
1257 |
3aa34d20d798
Patch from 'goutnet': Pressing backspace on a smiley will replace the smiley
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21558
diff
changeset
|
1258 gtk_text_iter_backward_char(&iter); |
3aa34d20d798
Patch from 'goutnet': Pressing backspace on a smiley will replace the smiley
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21558
diff
changeset
|
1259 anchor = gtk_text_iter_get_child_anchor(&iter); |
3aa34d20d798
Patch from 'goutnet': Pressing backspace on a smiley will replace the smiley
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21558
diff
changeset
|
1260 |
3aa34d20d798
Patch from 'goutnet': Pressing backspace on a smiley will replace the smiley
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21558
diff
changeset
|
1261 if (!anchor) |
3aa34d20d798
Patch from 'goutnet': Pressing backspace on a smiley will replace the smiley
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21558
diff
changeset
|
1262 return; /* No smiley here */ |
3aa34d20d798
Patch from 'goutnet': Pressing backspace on a smiley will replace the smiley
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21558
diff
changeset
|
1263 |
3aa34d20d798
Patch from 'goutnet': Pressing backspace on a smiley will replace the smiley
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21558
diff
changeset
|
1264 text = g_object_get_data(G_OBJECT(anchor), "gtkimhtml_plaintext"); |
3aa34d20d798
Patch from 'goutnet': Pressing backspace on a smiley will replace the smiley
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21558
diff
changeset
|
1265 if (!text) |
3aa34d20d798
Patch from 'goutnet': Pressing backspace on a smiley will replace the smiley
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21558
diff
changeset
|
1266 return; |
3aa34d20d798
Patch from 'goutnet': Pressing backspace on a smiley will replace the smiley
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21558
diff
changeset
|
1267 |
3aa34d20d798
Patch from 'goutnet': Pressing backspace on a smiley will replace the smiley
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21558
diff
changeset
|
1268 /* ok, then we need to insert the image buffer text before the anchor */ |
3aa34d20d798
Patch from 'goutnet': Pressing backspace on a smiley will replace the smiley
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21558
diff
changeset
|
1269 gtk_text_buffer_insert(imhtml->text_buffer, &iter, text, -1); |
3aa34d20d798
Patch from 'goutnet': Pressing backspace on a smiley will replace the smiley
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21558
diff
changeset
|
1270 } |
3aa34d20d798
Patch from 'goutnet': Pressing backspace on a smiley will replace the smiley
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21558
diff
changeset
|
1271 |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1272 static void paste_clipboard_cb(GtkIMHtml *imhtml, gpointer blah) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1273 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1274 #ifdef _WIN32 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1275 /* If we're on windows, let's see if we can get data from the HTML Format |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1276 clipboard before we try to paste from the GTK buffer */ |
30371
23406bea038f
Prevent pasting into readonly imhtmls on Windows. Fixes #11867
Daniel Atallah <daniel.atallah@gmail.com>
parents:
30160
diff
changeset
|
1277 if (!clipboard_paste_html_win32(imhtml) && gtk_text_view_get_editable(GTK_TEXT_VIEW(imhtml))) { |
29975
fce3282c1813
I think this works around the problem with the Win32 Clipboard and GTK+ 2.16.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
29789
diff
changeset
|
1278 GtkClipboard *clipboard = gtk_widget_get_clipboard(GTK_WIDGET(imhtml), GDK_SELECTION_CLIPBOARD); |
fce3282c1813
I think this works around the problem with the Win32 Clipboard and GTK+ 2.16.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
29789
diff
changeset
|
1279 gtk_clipboard_request_text(clipboard, paste_plaintext_received_cb, imhtml); |
fce3282c1813
I think this works around the problem with the Win32 Clipboard and GTK+ 2.16.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
29789
diff
changeset
|
1280 |
fce3282c1813
I think this works around the problem with the Win32 Clipboard and GTK+ 2.16.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
29789
diff
changeset
|
1281 } |
fce3282c1813
I think this works around the problem with the Win32 Clipboard and GTK+ 2.16.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
29789
diff
changeset
|
1282 #else |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1283 GtkClipboard *clipboard = gtk_widget_get_clipboard(GTK_WIDGET(imhtml), GDK_SELECTION_CLIPBOARD); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1284 gtk_clipboard_request_contents(clipboard, gdk_atom_intern("text/html", FALSE), |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1285 paste_received_cb, imhtml); |
29975
fce3282c1813
I think this works around the problem with the Win32 Clipboard and GTK+ 2.16.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
29789
diff
changeset
|
1286 #endif |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1287 g_signal_stop_emission_by_name(imhtml, "paste-clipboard"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1288 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1289 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1290 static void imhtml_realized_remove_primary(GtkIMHtml *imhtml, gpointer unused) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1291 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1292 gtk_text_buffer_remove_selection_clipboard(GTK_IMHTML(imhtml)->text_buffer, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1293 gtk_widget_get_clipboard(GTK_WIDGET(imhtml), GDK_SELECTION_PRIMARY)); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1294 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1295 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1296 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1297 static void imhtml_destroy_add_primary(GtkIMHtml *imhtml, gpointer unused) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1298 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1299 gtk_text_buffer_add_selection_clipboard(GTK_IMHTML(imhtml)->text_buffer, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1300 gtk_widget_get_clipboard(GTK_WIDGET(imhtml), GDK_SELECTION_PRIMARY)); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1301 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1302 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1303 static void mark_set_so_update_selection_cb(GtkTextBuffer *buffer, GtkTextIter *arg1, GtkTextMark *mark, GtkIMHtml *imhtml) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1304 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1305 if (gtk_text_buffer_get_selection_bounds(buffer, NULL, NULL)) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1306 gtk_clipboard_set_with_owner(gtk_widget_get_clipboard(GTK_WIDGET(imhtml), GDK_SELECTION_PRIMARY), |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1307 selection_targets, sizeof(selection_targets) / sizeof(GtkTargetEntry), |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1308 (GtkClipboardGetFunc)gtk_imhtml_clipboard_get, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1309 (GtkClipboardClearFunc)gtk_imhtml_primary_clipboard_clear, G_OBJECT(imhtml)); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1310 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1311 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1312 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1313 static gboolean gtk_imhtml_button_press_event(GtkIMHtml *imhtml, GdkEventButton *event, gpointer unused) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1314 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1315 if (event->button == 2) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1316 int x, y; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1317 GtkTextIter iter; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1318 GtkClipboard *clipboard = gtk_widget_get_clipboard(GTK_WIDGET(imhtml), GDK_SELECTION_PRIMARY); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1319 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1320 if (!imhtml->editable) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1321 return FALSE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1322 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1323 gtk_text_view_window_to_buffer_coords(GTK_TEXT_VIEW(imhtml), |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1324 GTK_TEXT_WINDOW_TEXT, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1325 event->x, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1326 event->y, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1327 &x, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1328 &y); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1329 gtk_text_view_get_iter_at_location(GTK_TEXT_VIEW(imhtml), &iter, x, y); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1330 gtk_text_buffer_place_cursor(imhtml->text_buffer, &iter); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1331 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1332 gtk_clipboard_request_contents(clipboard, gdk_atom_intern("text/html", FALSE), |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1333 paste_received_cb, imhtml); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1334 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1335 return TRUE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1336 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1337 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1338 return FALSE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1339 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1340 |
17411
674d8bc2b980
Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
17245
diff
changeset
|
1341 static void |
22674
27c9c55499f8
Smiley insertions can be undone with this fix. References #5577. But redo
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22650
diff
changeset
|
1342 gtk_imhtml_undo(GtkIMHtml *imhtml) |
27c9c55499f8
Smiley insertions can be undone with this fix. References #5577. But redo
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22650
diff
changeset
|
1343 { |
17411
674d8bc2b980
Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
17245
diff
changeset
|
1344 g_return_if_fail(GTK_IS_IMHTML(imhtml)); |
22674
27c9c55499f8
Smiley insertions can be undone with this fix. References #5577. But redo
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22650
diff
changeset
|
1345 if (imhtml->editable && |
27c9c55499f8
Smiley insertions can be undone with this fix. References #5577. But redo
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22650
diff
changeset
|
1346 gtk_source_undo_manager_can_undo(imhtml->undo_manager)) |
21488
277873603719
Fix #3930 by correctly detecting when we're no longer immediately following a br.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21156
diff
changeset
|
1347 gtk_source_undo_manager_undo(imhtml->undo_manager); |
17411
674d8bc2b980
Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
17245
diff
changeset
|
1348 } |
674d8bc2b980
Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
17245
diff
changeset
|
1349 |
674d8bc2b980
Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
17245
diff
changeset
|
1350 static void |
22674
27c9c55499f8
Smiley insertions can be undone with this fix. References #5577. But redo
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22650
diff
changeset
|
1351 gtk_imhtml_redo(GtkIMHtml *imhtml) |
27c9c55499f8
Smiley insertions can be undone with this fix. References #5577. But redo
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22650
diff
changeset
|
1352 { |
17411
674d8bc2b980
Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
17245
diff
changeset
|
1353 g_return_if_fail(GTK_IS_IMHTML(imhtml)); |
22674
27c9c55499f8
Smiley insertions can be undone with this fix. References #5577. But redo
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22650
diff
changeset
|
1354 if (imhtml->editable && |
27c9c55499f8
Smiley insertions can be undone with this fix. References #5577. But redo
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22650
diff
changeset
|
1355 gtk_source_undo_manager_can_redo(imhtml->undo_manager)) |
21488
277873603719
Fix #3930 by correctly detecting when we're no longer immediately following a br.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21156
diff
changeset
|
1356 gtk_source_undo_manager_redo(imhtml->undo_manager); |
17411
674d8bc2b980
Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
17245
diff
changeset
|
1357 |
674d8bc2b980
Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
17245
diff
changeset
|
1358 } |
674d8bc2b980
Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
17245
diff
changeset
|
1359 |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1360 static gboolean imhtml_message_send(GtkIMHtml *imhtml) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1361 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1362 return FALSE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1363 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1364 |
30030
ffb8cd9fb528
Allow binding 'Paste as Plain Text'.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
29975
diff
changeset
|
1365 static void |
ffb8cd9fb528
Allow binding 'Paste as Plain Text'.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
29975
diff
changeset
|
1366 imhtml_paste_cb(GtkIMHtml *imhtml, const char *str) |
ffb8cd9fb528
Allow binding 'Paste as Plain Text'.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
29975
diff
changeset
|
1367 { |
30592
9e7fc6d8ee18
Do not paste in a read-only imhtml. Fixes #12109.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
30371
diff
changeset
|
1368 if (!gtk_text_view_get_editable(GTK_TEXT_VIEW(imhtml))) |
9e7fc6d8ee18
Do not paste in a read-only imhtml. Fixes #12109.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
30371
diff
changeset
|
1369 return; |
9e7fc6d8ee18
Do not paste in a read-only imhtml. Fixes #12109.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
30371
diff
changeset
|
1370 |
30030
ffb8cd9fb528
Allow binding 'Paste as Plain Text'.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
29975
diff
changeset
|
1371 if (!str || !*str || !strcmp(str, "html")) |
ffb8cd9fb528
Allow binding 'Paste as Plain Text'.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
29975
diff
changeset
|
1372 g_signal_emit_by_name(imhtml, "paste_clipboard"); |
ffb8cd9fb528
Allow binding 'Paste as Plain Text'.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
29975
diff
changeset
|
1373 else if (!strcmp(str, "text")) |
ffb8cd9fb528
Allow binding 'Paste as Plain Text'.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
29975
diff
changeset
|
1374 paste_unformatted_cb(NULL, imhtml); |
ffb8cd9fb528
Allow binding 'Paste as Plain Text'.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
29975
diff
changeset
|
1375 } |
ffb8cd9fb528
Allow binding 'Paste as Plain Text'.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
29975
diff
changeset
|
1376 |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1377 static void imhtml_toggle_format(GtkIMHtml *imhtml, GtkIMHtmlButtons buttons) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1378 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1379 /* since this function is the handler for the formatting keystrokes, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1380 we need to check here that the formatting attempted is permitted */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1381 buttons &= imhtml->format_functions; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1382 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1383 switch (buttons) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1384 case GTK_IMHTML_BOLD: |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1385 imhtml_toggle_bold(imhtml); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1386 break; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1387 case GTK_IMHTML_ITALIC: |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1388 imhtml_toggle_italic(imhtml); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1389 break; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1390 case GTK_IMHTML_UNDERLINE: |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1391 imhtml_toggle_underline(imhtml); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1392 break; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1393 case GTK_IMHTML_STRIKE: |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1394 imhtml_toggle_strike(imhtml); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1395 break; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1396 case GTK_IMHTML_SHRINK: |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1397 imhtml_font_shrink(imhtml); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1398 break; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1399 case GTK_IMHTML_GROW: |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1400 imhtml_font_grow(imhtml); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1401 break; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1402 default: |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1403 break; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1404 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1405 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1406 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1407 static void |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1408 gtk_imhtml_finalize (GObject *object) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1409 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1410 GtkIMHtml *imhtml = GTK_IMHTML(object); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1411 GList *scalables; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1412 GSList *l; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1413 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1414 if (imhtml->scroll_src) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1415 g_source_remove(imhtml->scroll_src); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1416 if (imhtml->scroll_time) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1417 g_timer_destroy(imhtml->scroll_time); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1418 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1419 g_hash_table_destroy(imhtml->smiley_data); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1420 gtk_smiley_tree_destroy(imhtml->default_smilies); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1421 gdk_cursor_unref(imhtml->hand_cursor); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1422 gdk_cursor_unref(imhtml->arrow_cursor); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1423 gdk_cursor_unref(imhtml->text_cursor); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1424 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1425 if(imhtml->tip_window){ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1426 gtk_widget_destroy(imhtml->tip_window); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1427 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1428 if(imhtml->tip_timer) |
26713
618255d76deb
Replace gtk_timeout_remove with g_source_remove.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26712
diff
changeset
|
1429 g_source_remove(imhtml->tip_timer); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1430 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1431 for(scalables = imhtml->scalables; scalables; scalables = scalables->next) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1432 struct scalable_data *sd = scalables->data; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1433 GtkIMHtmlScalable *scale = GTK_IMHTML_SCALABLE(sd->scalable); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1434 scale->free(scale); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1435 g_free(sd); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1436 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1437 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1438 for (l = imhtml->im_images; l; l = l->next) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1439 struct im_image_data *img_data = l->data; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1440 if (imhtml->funcs->image_unref) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1441 imhtml->funcs->image_unref(img_data->id); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1442 g_free(img_data); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1443 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1444 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1445 g_list_free(imhtml->scalables); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1446 g_slist_free(imhtml->im_images); |
16309
a32325c04158
Fixes #213 This allows only 20 animated smileys to be animnating at a time
Sean Egan <seanegan@gmail.com>
parents:
16229
diff
changeset
|
1447 g_queue_free(imhtml->animations); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1448 g_free(imhtml->protocol_name); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1449 g_free(imhtml->search_string); |
17411
674d8bc2b980
Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
17245
diff
changeset
|
1450 g_object_unref(imhtml->undo_manager); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1451 G_OBJECT_CLASS(parent_class)->finalize (object); |
17678
2e1131c31941
Maintain global poitners to the clipboard selection text, with the aim of
Sean Egan <seanegan@gmail.com>
parents:
17424
diff
changeset
|
1452 |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1453 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1454 |
24396
38a2f78f80a7
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24311
diff
changeset
|
1455 static GtkIMHtmlProtocol * |
25357
b01a7f17a2bb
Detect duplication registrations by substring.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
25355
diff
changeset
|
1456 imhtml_find_protocol(const char *url, gboolean reverse) |
24396
38a2f78f80a7
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24311
diff
changeset
|
1457 { |
38a2f78f80a7
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24311
diff
changeset
|
1458 GtkIMHtmlClass *klass; |
38a2f78f80a7
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24311
diff
changeset
|
1459 GList *iter; |
38a2f78f80a7
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24311
diff
changeset
|
1460 GtkIMHtmlProtocol *proto = NULL; |
25357
b01a7f17a2bb
Detect duplication registrations by substring.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
25355
diff
changeset
|
1461 int length = reverse ? strlen(url) : -1; |
24396
38a2f78f80a7
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24311
diff
changeset
|
1462 |
38a2f78f80a7
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24311
diff
changeset
|
1463 klass = g_type_class_ref(GTK_TYPE_IMHTML); |
38a2f78f80a7
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24311
diff
changeset
|
1464 for (iter = klass->protocols; iter; iter = iter->next) { |
38a2f78f80a7
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24311
diff
changeset
|
1465 proto = iter->data; |
25357
b01a7f17a2bb
Detect duplication registrations by substring.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
25355
diff
changeset
|
1466 if (g_ascii_strncasecmp(url, proto->name, reverse ? MIN(length, proto->length) : proto->length) == 0) { |
24396
38a2f78f80a7
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24311
diff
changeset
|
1467 return proto; |
38a2f78f80a7
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24311
diff
changeset
|
1468 } |
38a2f78f80a7
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24311
diff
changeset
|
1469 } |
38a2f78f80a7
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24311
diff
changeset
|
1470 return NULL; |
38a2f78f80a7
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24311
diff
changeset
|
1471 } |
38a2f78f80a7
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24311
diff
changeset
|
1472 |
38a2f78f80a7
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24311
diff
changeset
|
1473 static void |
38a2f78f80a7
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24311
diff
changeset
|
1474 imhtml_url_clicked(GtkIMHtml *imhtml, const char *url) |
38a2f78f80a7
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24311
diff
changeset
|
1475 { |
25357
b01a7f17a2bb
Detect duplication registrations by substring.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
25355
diff
changeset
|
1476 GtkIMHtmlProtocol *proto = imhtml_find_protocol(url, FALSE); |
24548
284fd17c6020
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24397
diff
changeset
|
1477 GtkIMHtmlLink *link; |
24396
38a2f78f80a7
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24311
diff
changeset
|
1478 if (!proto) |
38a2f78f80a7
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24311
diff
changeset
|
1479 return; |
24548
284fd17c6020
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24397
diff
changeset
|
1480 link = g_new0(GtkIMHtmlLink, 1); |
284fd17c6020
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24397
diff
changeset
|
1481 link->imhtml = g_object_ref(imhtml); |
284fd17c6020
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24397
diff
changeset
|
1482 link->url = g_strdup(url); |
284fd17c6020
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24397
diff
changeset
|
1483 proto->activate(imhtml, link); /* XXX: Do something with the return value? */ |
284fd17c6020
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24397
diff
changeset
|
1484 gtk_imhtml_link_destroy(link); |
24396
38a2f78f80a7
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24311
diff
changeset
|
1485 } |
38a2f78f80a7
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24311
diff
changeset
|
1486 |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1487 /* Boring GTK+ stuff */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1488 static void gtk_imhtml_class_init (GtkIMHtmlClass *klass) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1489 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1490 GtkWidgetClass *widget_class = (GtkWidgetClass *) klass; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1491 GtkBindingSet *binding_set; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1492 GObjectClass *gobject_class; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1493 gobject_class = (GObjectClass*) klass; |
26712
38a5df43d525
Oops, I must have been tired. I only replaced the first occurrence of these
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26588
diff
changeset
|
1494 parent_class = g_type_class_ref(GTK_TYPE_TEXT_VIEW); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1495 signals[URL_CLICKED] = g_signal_new("url_clicked", |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1496 G_TYPE_FROM_CLASS(gobject_class), |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1497 G_SIGNAL_RUN_FIRST, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1498 G_STRUCT_OFFSET(GtkIMHtmlClass, url_clicked), |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1499 NULL, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1500 0, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1501 g_cclosure_marshal_VOID__POINTER, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1502 G_TYPE_NONE, 1, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1503 G_TYPE_POINTER); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1504 signals[BUTTONS_UPDATE] = g_signal_new("format_buttons_update", |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1505 G_TYPE_FROM_CLASS(gobject_class), |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1506 G_SIGNAL_RUN_FIRST, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1507 G_STRUCT_OFFSET(GtkIMHtmlClass, buttons_update), |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1508 NULL, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1509 0, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1510 g_cclosure_marshal_VOID__INT, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1511 G_TYPE_NONE, 1, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1512 G_TYPE_INT); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1513 signals[TOGGLE_FORMAT] = g_signal_new("format_function_toggle", |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1514 G_TYPE_FROM_CLASS(gobject_class), |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1515 G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1516 G_STRUCT_OFFSET(GtkIMHtmlClass, toggle_format), |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1517 NULL, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1518 0, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1519 g_cclosure_marshal_VOID__INT, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1520 G_TYPE_NONE, 1, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1521 G_TYPE_INT); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1522 signals[CLEAR_FORMAT] = g_signal_new("format_function_clear", |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1523 G_TYPE_FROM_CLASS(gobject_class), |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1524 G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1525 G_STRUCT_OFFSET(GtkIMHtmlClass, clear_format), |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1526 NULL, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1527 0, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1528 g_cclosure_marshal_VOID__VOID, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1529 G_TYPE_NONE, 0); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1530 signals[UPDATE_FORMAT] = g_signal_new("format_function_update", |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1531 G_TYPE_FROM_CLASS(gobject_class), |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1532 G_SIGNAL_RUN_FIRST, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1533 G_STRUCT_OFFSET(GtkIMHtmlClass, update_format), |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1534 NULL, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1535 0, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1536 g_cclosure_marshal_VOID__VOID, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1537 G_TYPE_NONE, 0); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1538 signals[MESSAGE_SEND] = g_signal_new("message_send", |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1539 G_TYPE_FROM_CLASS(gobject_class), |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1540 G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1541 G_STRUCT_OFFSET(GtkIMHtmlClass, message_send), |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1542 NULL, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1543 0, g_cclosure_marshal_VOID__VOID, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1544 G_TYPE_NONE, 0); |
30030
ffb8cd9fb528
Allow binding 'Paste as Plain Text'.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
29975
diff
changeset
|
1545 signals[PASTE] = g_signal_new("paste", |
ffb8cd9fb528
Allow binding 'Paste as Plain Text'.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
29975
diff
changeset
|
1546 G_TYPE_FROM_CLASS(gobject_class), |
ffb8cd9fb528
Allow binding 'Paste as Plain Text'.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
29975
diff
changeset
|
1547 G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION, |
ffb8cd9fb528
Allow binding 'Paste as Plain Text'.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
29975
diff
changeset
|
1548 0, |
ffb8cd9fb528
Allow binding 'Paste as Plain Text'.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
29975
diff
changeset
|
1549 NULL, |
ffb8cd9fb528
Allow binding 'Paste as Plain Text'.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
29975
diff
changeset
|
1550 0, g_cclosure_marshal_VOID__STRING, |
ffb8cd9fb528
Allow binding 'Paste as Plain Text'.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
29975
diff
changeset
|
1551 G_TYPE_NONE, 1, G_TYPE_STRING); |
ffb8cd9fb528
Allow binding 'Paste as Plain Text'.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
29975
diff
changeset
|
1552 signals [UNDO] = g_signal_new ("undo", |
ffb8cd9fb528
Allow binding 'Paste as Plain Text'.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
29975
diff
changeset
|
1553 G_TYPE_FROM_CLASS (klass), |
ffb8cd9fb528
Allow binding 'Paste as Plain Text'.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
29975
diff
changeset
|
1554 G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION, |
ffb8cd9fb528
Allow binding 'Paste as Plain Text'.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
29975
diff
changeset
|
1555 G_STRUCT_OFFSET (GtkIMHtmlClass, undo), |
ffb8cd9fb528
Allow binding 'Paste as Plain Text'.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
29975
diff
changeset
|
1556 NULL, |
ffb8cd9fb528
Allow binding 'Paste as Plain Text'.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
29975
diff
changeset
|
1557 NULL, |
ffb8cd9fb528
Allow binding 'Paste as Plain Text'.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
29975
diff
changeset
|
1558 gtksourceview_marshal_VOID__VOID, |
ffb8cd9fb528
Allow binding 'Paste as Plain Text'.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
29975
diff
changeset
|
1559 G_TYPE_NONE, |
ffb8cd9fb528
Allow binding 'Paste as Plain Text'.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
29975
diff
changeset
|
1560 0); |
ffb8cd9fb528
Allow binding 'Paste as Plain Text'.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
29975
diff
changeset
|
1561 signals [REDO] = g_signal_new ("redo", |
ffb8cd9fb528
Allow binding 'Paste as Plain Text'.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
29975
diff
changeset
|
1562 G_TYPE_FROM_CLASS (klass), |
ffb8cd9fb528
Allow binding 'Paste as Plain Text'.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
29975
diff
changeset
|
1563 G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION, |
ffb8cd9fb528
Allow binding 'Paste as Plain Text'.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
29975
diff
changeset
|
1564 G_STRUCT_OFFSET (GtkIMHtmlClass, redo), |
ffb8cd9fb528
Allow binding 'Paste as Plain Text'.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
29975
diff
changeset
|
1565 NULL, |
ffb8cd9fb528
Allow binding 'Paste as Plain Text'.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
29975
diff
changeset
|
1566 NULL, |
ffb8cd9fb528
Allow binding 'Paste as Plain Text'.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
29975
diff
changeset
|
1567 gtksourceview_marshal_VOID__VOID, |
ffb8cd9fb528
Allow binding 'Paste as Plain Text'.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
29975
diff
changeset
|
1568 G_TYPE_NONE, |
ffb8cd9fb528
Allow binding 'Paste as Plain Text'.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
29975
diff
changeset
|
1569 0); |
17411
674d8bc2b980
Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
17245
diff
changeset
|
1570 |
674d8bc2b980
Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
17245
diff
changeset
|
1571 |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1572 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1573 klass->toggle_format = imhtml_toggle_format; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1574 klass->message_send = imhtml_message_send; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1575 klass->clear_format = imhtml_clear_formatting; |
24396
38a2f78f80a7
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24311
diff
changeset
|
1576 klass->url_clicked = imhtml_url_clicked; |
17411
674d8bc2b980
Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
17245
diff
changeset
|
1577 klass->undo = gtk_imhtml_undo; |
674d8bc2b980
Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
17245
diff
changeset
|
1578 klass->redo = gtk_imhtml_redo; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1579 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1580 gobject_class->finalize = gtk_imhtml_finalize; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1581 widget_class->drag_motion = gtk_text_view_drag_motion; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1582 widget_class->expose_event = gtk_imhtml_expose_event; |
18669
8425cbac2474
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@gmail.com>
parents:
18453
diff
changeset
|
1583 parent_size_allocate = widget_class->size_allocate; |
8425cbac2474
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@gmail.com>
parents:
18453
diff
changeset
|
1584 widget_class->size_allocate = gtk_imhtml_size_allocate; |
23005
f11fc3fb5b8c
Use text-tags to set the weight/color of the nick in conversations. This
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22797
diff
changeset
|
1585 parent_style_set = widget_class->style_set; |
f11fc3fb5b8c
Use text-tags to set the weight/color of the nick in conversations. This
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22797
diff
changeset
|
1586 widget_class->style_set = gtk_imhtml_style_set; |
18669
8425cbac2474
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@gmail.com>
parents:
18453
diff
changeset
|
1587 |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1588 gtk_widget_class_install_style_property(widget_class, g_param_spec_boxed("hyperlink-color", |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1589 _("Hyperlink color"), |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1590 _("Color to draw hyperlinks."), |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1591 GDK_TYPE_COLOR, G_PARAM_READABLE)); |
24061
0d0f99cd425e
Show visited links in a different color. This also plugs a memory leak
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23411
diff
changeset
|
1592 gtk_widget_class_install_style_property(widget_class, g_param_spec_boxed("hyperlink-visited-color", |
0d0f99cd425e
Show visited links in a different color. This also plugs a memory leak
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23411
diff
changeset
|
1593 _("Hyperlink visited color"), |
27366
73c8e1964eef
A semi-random collection of English spelling and grammatical changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27217
diff
changeset
|
1594 _("Color to draw hyperlink after it has been visited (or activated)."), |
24061
0d0f99cd425e
Show visited links in a different color. This also plugs a memory leak
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23411
diff
changeset
|
1595 GDK_TYPE_COLOR, G_PARAM_READABLE)); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1596 gtk_widget_class_install_style_property(widget_class, g_param_spec_boxed("hyperlink-prelight-color", |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1597 _("Hyperlink prelight color"), |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1598 _("Color to draw hyperlinks when mouse is over them."), |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1599 GDK_TYPE_COLOR, G_PARAM_READABLE)); |
21840
9a39d47a9cd3
Another patch from DHowett. This one adds conversation nick colors to gtkrc
Sean Egan <seanegan@gmail.com>
parents:
21784
diff
changeset
|
1600 gtk_widget_class_install_style_property(widget_class, g_param_spec_boxed("send-name-color", |
9a39d47a9cd3
Another patch from DHowett. This one adds conversation nick colors to gtkrc
Sean Egan <seanegan@gmail.com>
parents:
21784
diff
changeset
|
1601 _("Sent Message Name Color"), |
9a39d47a9cd3
Another patch from DHowett. This one adds conversation nick colors to gtkrc
Sean Egan <seanegan@gmail.com>
parents:
21784
diff
changeset
|
1602 _("Color to draw the name of a message you sent."), |
9a39d47a9cd3
Another patch from DHowett. This one adds conversation nick colors to gtkrc
Sean Egan <seanegan@gmail.com>
parents:
21784
diff
changeset
|
1603 GDK_TYPE_COLOR, G_PARAM_READABLE)); |
9a39d47a9cd3
Another patch from DHowett. This one adds conversation nick colors to gtkrc
Sean Egan <seanegan@gmail.com>
parents:
21784
diff
changeset
|
1604 gtk_widget_class_install_style_property(widget_class, g_param_spec_boxed("receive-name-color", |
9a39d47a9cd3
Another patch from DHowett. This one adds conversation nick colors to gtkrc
Sean Egan <seanegan@gmail.com>
parents:
21784
diff
changeset
|
1605 _("Received Message Name Color"), |
9a39d47a9cd3
Another patch from DHowett. This one adds conversation nick colors to gtkrc
Sean Egan <seanegan@gmail.com>
parents:
21784
diff
changeset
|
1606 _("Color to draw the name of a message you received."), |
9a39d47a9cd3
Another patch from DHowett. This one adds conversation nick colors to gtkrc
Sean Egan <seanegan@gmail.com>
parents:
21784
diff
changeset
|
1607 GDK_TYPE_COLOR, G_PARAM_READABLE)); |
9a39d47a9cd3
Another patch from DHowett. This one adds conversation nick colors to gtkrc
Sean Egan <seanegan@gmail.com>
parents:
21784
diff
changeset
|
1608 gtk_widget_class_install_style_property(widget_class, g_param_spec_boxed("highlight-name-color", |
9a39d47a9cd3
Another patch from DHowett. This one adds conversation nick colors to gtkrc
Sean Egan <seanegan@gmail.com>
parents:
21784
diff
changeset
|
1609 _("\"Attention\" Name Color"), |
9a39d47a9cd3
Another patch from DHowett. This one adds conversation nick colors to gtkrc
Sean Egan <seanegan@gmail.com>
parents:
21784
diff
changeset
|
1610 _("Color to draw the name of a message you received containing your name."), |
9a39d47a9cd3
Another patch from DHowett. This one adds conversation nick colors to gtkrc
Sean Egan <seanegan@gmail.com>
parents:
21784
diff
changeset
|
1611 GDK_TYPE_COLOR, G_PARAM_READABLE)); |
9a39d47a9cd3
Another patch from DHowett. This one adds conversation nick colors to gtkrc
Sean Egan <seanegan@gmail.com>
parents:
21784
diff
changeset
|
1612 gtk_widget_class_install_style_property(widget_class, g_param_spec_boxed("action-name-color", |
9a39d47a9cd3
Another patch from DHowett. This one adds conversation nick colors to gtkrc
Sean Egan <seanegan@gmail.com>
parents:
21784
diff
changeset
|
1613 _("Action Message Name Color"), |
9a39d47a9cd3
Another patch from DHowett. This one adds conversation nick colors to gtkrc
Sean Egan <seanegan@gmail.com>
parents:
21784
diff
changeset
|
1614 _("Color to draw the name of an action message."), |
9a39d47a9cd3
Another patch from DHowett. This one adds conversation nick colors to gtkrc
Sean Egan <seanegan@gmail.com>
parents:
21784
diff
changeset
|
1615 GDK_TYPE_COLOR, G_PARAM_READABLE)); |
23005
f11fc3fb5b8c
Use text-tags to set the weight/color of the nick in conversations. This
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22797
diff
changeset
|
1616 gtk_widget_class_install_style_property(widget_class, g_param_spec_boxed("whisper-action-name-color", |
f11fc3fb5b8c
Use text-tags to set the weight/color of the nick in conversations. This
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22797
diff
changeset
|
1617 _("Action Message Name Color for Whispered Message"), |
27366
73c8e1964eef
A semi-random collection of English spelling and grammatical changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27217
diff
changeset
|
1618 _("Color to draw the name of a whispered action message."), |
23005
f11fc3fb5b8c
Use text-tags to set the weight/color of the nick in conversations. This
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22797
diff
changeset
|
1619 GDK_TYPE_COLOR, G_PARAM_READABLE)); |
f11fc3fb5b8c
Use text-tags to set the weight/color of the nick in conversations. This
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22797
diff
changeset
|
1620 gtk_widget_class_install_style_property(widget_class, g_param_spec_boxed("whisper-name-color", |
f11fc3fb5b8c
Use text-tags to set the weight/color of the nick in conversations. This
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22797
diff
changeset
|
1621 _("Whisper Message Name Color"), |
27366
73c8e1964eef
A semi-random collection of English spelling and grammatical changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27217
diff
changeset
|
1622 _("Color to draw the name of a whispered message."), |
23005
f11fc3fb5b8c
Use text-tags to set the weight/color of the nick in conversations. This
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22797
diff
changeset
|
1623 GDK_TYPE_COLOR, G_PARAM_READABLE)); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1624 |
22612
98775a5b4817
Customize/disable the typing notification from gtkrc-2.0.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22545
diff
changeset
|
1625 /* Customizable typing notification ... sort of. Example: |
98775a5b4817
Customize/disable the typing notification from gtkrc-2.0.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22545
diff
changeset
|
1626 * GtkIMHtml::typing-notification-font = "monospace italic light 8.0" |
98775a5b4817
Customize/disable the typing notification from gtkrc-2.0.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22545
diff
changeset
|
1627 * GtkIMHtml::typing-notification-color = "#ff0000" |
98775a5b4817
Customize/disable the typing notification from gtkrc-2.0.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22545
diff
changeset
|
1628 * GtkIMHtml::typing-notification-enable = 1 |
98775a5b4817
Customize/disable the typing notification from gtkrc-2.0.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22545
diff
changeset
|
1629 */ |
98775a5b4817
Customize/disable the typing notification from gtkrc-2.0.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22545
diff
changeset
|
1630 gtk_widget_class_install_style_property(widget_class, g_param_spec_boxed("typing-notification-color", |
98775a5b4817
Customize/disable the typing notification from gtkrc-2.0.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22545
diff
changeset
|
1631 _("Typing notification color"), |
27366
73c8e1964eef
A semi-random collection of English spelling and grammatical changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27217
diff
changeset
|
1632 _("The color to use for the typing notification"), |
22612
98775a5b4817
Customize/disable the typing notification from gtkrc-2.0.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22545
diff
changeset
|
1633 GDK_TYPE_COLOR, G_PARAM_READABLE)); |
98775a5b4817
Customize/disable the typing notification from gtkrc-2.0.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22545
diff
changeset
|
1634 gtk_widget_class_install_style_property(widget_class, g_param_spec_string("typing-notification-font", |
98775a5b4817
Customize/disable the typing notification from gtkrc-2.0.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22545
diff
changeset
|
1635 _("Typing notification font"), |
98775a5b4817
Customize/disable the typing notification from gtkrc-2.0.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22545
diff
changeset
|
1636 _("The font to use for the typing notification"), |
98775a5b4817
Customize/disable the typing notification from gtkrc-2.0.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22545
diff
changeset
|
1637 "light 8.0", G_PARAM_READABLE)); |
98775a5b4817
Customize/disable the typing notification from gtkrc-2.0.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22545
diff
changeset
|
1638 gtk_widget_class_install_style_property(widget_class, g_param_spec_boolean("typing-notification-enable", |
98775a5b4817
Customize/disable the typing notification from gtkrc-2.0.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22545
diff
changeset
|
1639 _("Enable typing notification"), |
98775a5b4817
Customize/disable the typing notification from gtkrc-2.0.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22545
diff
changeset
|
1640 _("Enable typing notification"), |
98775a5b4817
Customize/disable the typing notification from gtkrc-2.0.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22545
diff
changeset
|
1641 TRUE, G_PARAM_READABLE)); |
98775a5b4817
Customize/disable the typing notification from gtkrc-2.0.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22545
diff
changeset
|
1642 |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1643 binding_set = gtk_binding_set_by_class (parent_class); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1644 gtk_binding_entry_add_signal (binding_set, GDK_b, GDK_CONTROL_MASK, "format_function_toggle", 1, G_TYPE_INT, GTK_IMHTML_BOLD); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1645 gtk_binding_entry_add_signal (binding_set, GDK_i, GDK_CONTROL_MASK, "format_function_toggle", 1, G_TYPE_INT, GTK_IMHTML_ITALIC); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1646 gtk_binding_entry_add_signal (binding_set, GDK_u, GDK_CONTROL_MASK, "format_function_toggle", 1, G_TYPE_INT, GTK_IMHTML_UNDERLINE); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1647 gtk_binding_entry_add_signal (binding_set, GDK_plus, GDK_CONTROL_MASK, "format_function_toggle", 1, G_TYPE_INT, GTK_IMHTML_GROW); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1648 gtk_binding_entry_add_signal (binding_set, GDK_equal, GDK_CONTROL_MASK, "format_function_toggle", 1, G_TYPE_INT, GTK_IMHTML_GROW); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1649 gtk_binding_entry_add_signal (binding_set, GDK_minus, GDK_CONTROL_MASK, "format_function_toggle", 1, G_TYPE_INT, GTK_IMHTML_SHRINK); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1650 binding_set = gtk_binding_set_by_class(klass); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1651 gtk_binding_entry_add_signal (binding_set, GDK_r, GDK_CONTROL_MASK, "format_function_clear", 0); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1652 gtk_binding_entry_add_signal (binding_set, GDK_KP_Enter, 0, "message_send", 0); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1653 gtk_binding_entry_add_signal (binding_set, GDK_Return, 0, "message_send", 0); |
30030
ffb8cd9fb528
Allow binding 'Paste as Plain Text'.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
29975
diff
changeset
|
1654 gtk_binding_entry_add_signal (binding_set, GDK_z, GDK_CONTROL_MASK, "undo", 0); |
ffb8cd9fb528
Allow binding 'Paste as Plain Text'.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
29975
diff
changeset
|
1655 gtk_binding_entry_add_signal (binding_set, GDK_z, GDK_CONTROL_MASK | GDK_SHIFT_MASK, "redo", 0); |
ffb8cd9fb528
Allow binding 'Paste as Plain Text'.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
29975
diff
changeset
|
1656 gtk_binding_entry_add_signal (binding_set, GDK_F14, 0, "undo", 0); |
ffb8cd9fb528
Allow binding 'Paste as Plain Text'.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
29975
diff
changeset
|
1657 gtk_binding_entry_add_signal(binding_set, GDK_v, GDK_CONTROL_MASK | GDK_SHIFT_MASK, "paste", 1, G_TYPE_STRING, "text"); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1658 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1659 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1660 static void gtk_imhtml_init (GtkIMHtml *imhtml) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1661 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1662 imhtml->text_buffer = gtk_text_buffer_new(NULL); |
17411
674d8bc2b980
Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@gmail.com>
parents:
17245
diff
changeset
|
1663 imhtml->undo_manager = gtk_source_undo_manager_new(imhtml->text_buffer); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1664 gtk_text_view_set_buffer(GTK_TEXT_VIEW(imhtml), imhtml->text_buffer); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1665 gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(imhtml), GTK_WRAP_WORD_CHAR); |
22705
9bc93b4b0f92
Move 2 of the 5 pixels' padding between paragraphs to above the line.
Will Thompson <will.thompson@collabora.co.uk>
parents:
22674
diff
changeset
|
1666 gtk_text_view_set_pixels_above_lines(GTK_TEXT_VIEW(imhtml), 2); |
9bc93b4b0f92
Move 2 of the 5 pixels' padding between paragraphs to above the line.
Will Thompson <will.thompson@collabora.co.uk>
parents:
22674
diff
changeset
|
1667 gtk_text_view_set_pixels_below_lines(GTK_TEXT_VIEW(imhtml), 3); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1668 gtk_text_view_set_left_margin(GTK_TEXT_VIEW(imhtml), 2); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1669 gtk_text_view_set_right_margin(GTK_TEXT_VIEW(imhtml), 2); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1670 /*gtk_text_view_set_indent(GTK_TEXT_VIEW(imhtml), -15);*/ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1671 /*gtk_text_view_set_justification(GTK_TEXT_VIEW(imhtml), GTK_JUSTIFY_FILL);*/ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1672 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1673 /* These tags will be used often and can be reused--we create them on init and then apply them by name |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1674 * other tags (color, size, face, etc.) will have to be created and applied dynamically |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1675 * Note that even though we created SUB, SUP, and PRE tags here, we don't really |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1676 * apply them anywhere yet. */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1677 gtk_text_buffer_create_tag(imhtml->text_buffer, "BOLD", "weight", PANGO_WEIGHT_BOLD, NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1678 gtk_text_buffer_create_tag(imhtml->text_buffer, "ITALICS", "style", PANGO_STYLE_ITALIC, NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1679 gtk_text_buffer_create_tag(imhtml->text_buffer, "UNDERLINE", "underline", PANGO_UNDERLINE_SINGLE, NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1680 gtk_text_buffer_create_tag(imhtml->text_buffer, "STRIKE", "strikethrough", TRUE, NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1681 gtk_text_buffer_create_tag(imhtml->text_buffer, "SUB", "rise", -5000, NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1682 gtk_text_buffer_create_tag(imhtml->text_buffer, "SUP", "rise", 5000, NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1683 gtk_text_buffer_create_tag(imhtml->text_buffer, "PRE", "family", "Monospace", NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1684 gtk_text_buffer_create_tag(imhtml->text_buffer, "search", "background", "#22ff00", "weight", "bold", NULL); |
23167
9f94bf3743c2
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23163
diff
changeset
|
1685 gtk_text_buffer_create_tag(imhtml->text_buffer, "comment", "weight", PANGO_WEIGHT_NORMAL, |
22341
53873732f90a
Disable invisible text things, if someone can conclusively prove this is
Stu Tomlinson <stu@nosnilmot.com>
parents:
22148
diff
changeset
|
1686 #if FALSE && GTK_CHECK_VERSION(2,10,10) |
23167
9f94bf3743c2
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23163
diff
changeset
|
1687 "invisible", FALSE, |
22084
101b711a76de
disapproval of revision '4b5e932e01a84088124dee9791809545cdc9240b'
Sean Egan <seanegan@gmail.com>
parents:
22083
diff
changeset
|
1688 #endif |
23167
9f94bf3743c2
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23163
diff
changeset
|
1689 NULL); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1690 |
23005
f11fc3fb5b8c
Use text-tags to set the weight/color of the nick in conversations. This
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22797
diff
changeset
|
1691 gtk_text_buffer_create_tag(imhtml->text_buffer, "send-name", "weight", PANGO_WEIGHT_BOLD, NULL); |
f11fc3fb5b8c
Use text-tags to set the weight/color of the nick in conversations. This
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22797
diff
changeset
|
1692 gtk_text_buffer_create_tag(imhtml->text_buffer, "receive-name", "weight", PANGO_WEIGHT_BOLD, NULL); |
f11fc3fb5b8c
Use text-tags to set the weight/color of the nick in conversations. This
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22797
diff
changeset
|
1693 gtk_text_buffer_create_tag(imhtml->text_buffer, "highlight-name", "weight", PANGO_WEIGHT_BOLD, NULL); |
f11fc3fb5b8c
Use text-tags to set the weight/color of the nick in conversations. This
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22797
diff
changeset
|
1694 gtk_text_buffer_create_tag(imhtml->text_buffer, "action-name", "weight", PANGO_WEIGHT_BOLD, NULL); |
f11fc3fb5b8c
Use text-tags to set the weight/color of the nick in conversations. This
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22797
diff
changeset
|
1695 gtk_text_buffer_create_tag(imhtml->text_buffer, "whisper-action-name", "weight", PANGO_WEIGHT_BOLD, NULL); |
f11fc3fb5b8c
Use text-tags to set the weight/color of the nick in conversations. This
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22797
diff
changeset
|
1696 gtk_text_buffer_create_tag(imhtml->text_buffer, "whisper-name", "weight", PANGO_WEIGHT_BOLD, NULL); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1697 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1698 /* When hovering over a link, we show the hand cursor--elsewhere we show the plain ol' pointer cursor */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1699 imhtml->hand_cursor = gdk_cursor_new (GDK_HAND2); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1700 imhtml->arrow_cursor = gdk_cursor_new (GDK_LEFT_PTR); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1701 imhtml->text_cursor = gdk_cursor_new (GDK_XTERM); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1702 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1703 imhtml->show_comments = TRUE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1704 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1705 imhtml->smiley_data = g_hash_table_new_full(g_str_hash, g_str_equal, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1706 g_free, (GDestroyNotify)gtk_smiley_tree_destroy); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1707 imhtml->default_smilies = gtk_smiley_tree_new(); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1708 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1709 g_signal_connect(G_OBJECT(imhtml), "motion-notify-event", G_CALLBACK(gtk_motion_event_notify), NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1710 g_signal_connect(G_OBJECT(imhtml), "leave-notify-event", G_CALLBACK(gtk_leave_event_notify), NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1711 g_signal_connect(G_OBJECT(imhtml), "enter-notify-event", G_CALLBACK(gtk_enter_event_notify), NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1712 g_signal_connect(G_OBJECT(imhtml), "button_press_event", G_CALLBACK(gtk_imhtml_button_press_event), NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1713 g_signal_connect(G_OBJECT(imhtml->text_buffer), "insert-text", G_CALLBACK(preinsert_cb), imhtml); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1714 g_signal_connect(G_OBJECT(imhtml->text_buffer), "delete_range", G_CALLBACK(delete_cb), imhtml); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1715 g_signal_connect_after(G_OBJECT(imhtml->text_buffer), "insert-text", G_CALLBACK(insert_cb), imhtml); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1716 g_signal_connect_after(G_OBJECT(imhtml->text_buffer), "insert-child-anchor", G_CALLBACK(insert_ca_cb), imhtml); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1717 gtk_drag_dest_set(GTK_WIDGET(imhtml), 0, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1718 link_drag_drop_targets, sizeof(link_drag_drop_targets) / sizeof(GtkTargetEntry), |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1719 GDK_ACTION_COPY); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1720 g_signal_connect(G_OBJECT(imhtml), "drag_data_received", G_CALLBACK(gtk_imhtml_link_drag_rcv_cb), imhtml); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1721 g_signal_connect(G_OBJECT(imhtml), "drag_drop", G_CALLBACK(gtk_imhtml_link_drop_cb), imhtml); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1722 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1723 g_signal_connect(G_OBJECT(imhtml), "copy-clipboard", G_CALLBACK(copy_clipboard_cb), NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1724 g_signal_connect(G_OBJECT(imhtml), "cut-clipboard", G_CALLBACK(cut_clipboard_cb), NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1725 g_signal_connect(G_OBJECT(imhtml), "paste-clipboard", G_CALLBACK(paste_clipboard_cb), NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1726 g_signal_connect_after(G_OBJECT(imhtml), "realize", G_CALLBACK(imhtml_realized_remove_primary), NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1727 g_signal_connect(G_OBJECT(imhtml), "unrealize", G_CALLBACK(imhtml_destroy_add_primary), NULL); |
30030
ffb8cd9fb528
Allow binding 'Paste as Plain Text'.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
29975
diff
changeset
|
1728 g_signal_connect(G_OBJECT(imhtml), "paste", G_CALLBACK(imhtml_paste_cb), NULL); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1729 |
29975
fce3282c1813
I think this works around the problem with the Win32 Clipboard and GTK+ 2.16.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
29789
diff
changeset
|
1730 #ifndef _WIN32 |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1731 g_signal_connect_after(G_OBJECT(GTK_IMHTML(imhtml)->text_buffer), "mark-set", |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1732 G_CALLBACK(mark_set_so_update_selection_cb), imhtml); |
29975
fce3282c1813
I think this works around the problem with the Win32 Clipboard and GTK+ 2.16.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
29789
diff
changeset
|
1733 #endif |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1734 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1735 gtk_widget_add_events(GTK_WIDGET(imhtml), |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1736 GDK_LEAVE_NOTIFY_MASK | GDK_ENTER_NOTIFY_MASK); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1737 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1738 imhtml->tip = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1739 imhtml->tip_timer = 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1740 imhtml->tip_window = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1741 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1742 imhtml->edit.bold = FALSE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1743 imhtml->edit.italic = FALSE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1744 imhtml->edit.underline = FALSE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1745 imhtml->edit.forecolor = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1746 imhtml->edit.backcolor = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1747 imhtml->edit.fontface = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1748 imhtml->edit.fontsize = 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1749 imhtml->edit.link = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1750 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1751 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1752 imhtml->scalables = NULL; |
16309
a32325c04158
Fixes #213 This allows only 20 animated smileys to be animnating at a time
Sean Egan <seanegan@gmail.com>
parents:
16229
diff
changeset
|
1753 imhtml->animations = g_queue_new(); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1754 gtk_imhtml_set_editable(imhtml, FALSE); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1755 g_signal_connect(G_OBJECT(imhtml), "populate-popup", |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1756 G_CALLBACK(hijack_menu_cb), NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1757 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1758 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1759 GtkWidget *gtk_imhtml_new(void *a, void *b) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1760 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1761 return GTK_WIDGET(g_object_new(gtk_imhtml_get_type(), NULL)); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1762 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1763 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1764 GType gtk_imhtml_get_type() |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1765 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1766 static GType imhtml_type = 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1767 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1768 if (!imhtml_type) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1769 static const GTypeInfo imhtml_info = { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1770 sizeof(GtkIMHtmlClass), |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1771 NULL, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1772 NULL, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1773 (GClassInitFunc) gtk_imhtml_class_init, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1774 NULL, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1775 NULL, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1776 sizeof (GtkIMHtml), |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1777 0, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1778 (GInstanceInitFunc) gtk_imhtml_init, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1779 NULL |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1780 }; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1781 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1782 imhtml_type = g_type_register_static(gtk_text_view_get_type(), |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1783 "GtkIMHtml", &imhtml_info, 0); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1784 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1785 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1786 return imhtml_type; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1787 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1788 |
24548
284fd17c6020
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24397
diff
changeset
|
1789 static void gtk_imhtml_link_destroy(GtkIMHtmlLink *link) |
284fd17c6020
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24397
diff
changeset
|
1790 { |
284fd17c6020
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24397
diff
changeset
|
1791 if (link->imhtml) |
284fd17c6020
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24397
diff
changeset
|
1792 g_object_unref(link->imhtml); |
284fd17c6020
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24397
diff
changeset
|
1793 if (link->tag) |
284fd17c6020
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24397
diff
changeset
|
1794 g_object_unref(link->tag); |
284fd17c6020
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24397
diff
changeset
|
1795 g_free(link->url); |
284fd17c6020
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24397
diff
changeset
|
1796 g_free(link); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1797 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1798 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1799 /* The callback for an event on a link tag. */ |
24061
0d0f99cd425e
Show visited links in a different color. This also plugs a memory leak
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23411
diff
changeset
|
1800 static gboolean tag_event(GtkTextTag *tag, GObject *imhtml, GdkEvent *event, GtkTextIter *arg2, gpointer unused) |
0d0f99cd425e
Show visited links in a different color. This also plugs a memory leak
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23411
diff
changeset
|
1801 { |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1802 GdkEventButton *event_button = (GdkEventButton *) event; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1803 if (GTK_IMHTML(imhtml)->editable) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1804 return FALSE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1805 if (event->type == GDK_BUTTON_RELEASE) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1806 if ((event_button->button == 1) || (event_button->button == 2)) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1807 GtkTextIter start, end; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1808 /* we shouldn't open a URL if the user has selected something: */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1809 if (gtk_text_buffer_get_selection_bounds( |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1810 gtk_text_iter_get_buffer(arg2), &start, &end)) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1811 return FALSE; |
24548
284fd17c6020
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24397
diff
changeset
|
1812 gtk_imhtml_activate_tag(GTK_IMHTML(imhtml), tag); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1813 return FALSE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1814 } else if(event_button->button == 3) { |
24548
284fd17c6020
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24397
diff
changeset
|
1815 GList *children; |
284fd17c6020
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24397
diff
changeset
|
1816 GtkWidget *menu; |
24396
38a2f78f80a7
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24311
diff
changeset
|
1817 GtkIMHtmlProtocol *proto; |
24548
284fd17c6020
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24397
diff
changeset
|
1818 GtkIMHtmlLink *link = g_new(GtkIMHtmlLink, 1); |
284fd17c6020
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24397
diff
changeset
|
1819 link->imhtml = g_object_ref(imhtml); |
284fd17c6020
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24397
diff
changeset
|
1820 link->url = g_strdup(g_object_get_data(G_OBJECT(tag), "link_url")); |
284fd17c6020
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24397
diff
changeset
|
1821 link->tag = g_object_ref(tag); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1822 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1823 /* Don't want the tooltip around if user right-clicked on link */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1824 if (GTK_IMHTML(imhtml)->tip_window) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1825 gtk_widget_destroy(GTK_IMHTML(imhtml)->tip_window); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1826 GTK_IMHTML(imhtml)->tip_window = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1827 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1828 if (GTK_IMHTML(imhtml)->tip_timer) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1829 g_source_remove(GTK_IMHTML(imhtml)->tip_timer); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1830 GTK_IMHTML(imhtml)->tip_timer = 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1831 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1832 if (GTK_IMHTML(imhtml)->editable) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1833 gdk_window_set_cursor(event_button->window, GTK_IMHTML(imhtml)->text_cursor); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1834 else |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1835 gdk_window_set_cursor(event_button->window, GTK_IMHTML(imhtml)->arrow_cursor); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1836 menu = gtk_menu_new(); |
24548
284fd17c6020
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24397
diff
changeset
|
1837 g_object_set_data_full(G_OBJECT(menu), "x-imhtml-url-data", link, |
284fd17c6020
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24397
diff
changeset
|
1838 (GDestroyNotify)gtk_imhtml_link_destroy); |
284fd17c6020
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24397
diff
changeset
|
1839 |
25357
b01a7f17a2bb
Detect duplication registrations by substring.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
25355
diff
changeset
|
1840 proto = imhtml_find_protocol(link->url, FALSE); |
24548
284fd17c6020
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24397
diff
changeset
|
1841 |
284fd17c6020
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24397
diff
changeset
|
1842 if (proto && proto->context_menu) { |
284fd17c6020
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24397
diff
changeset
|
1843 proto->context_menu(GTK_IMHTML(link->imhtml), link, menu); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1844 } |
24548
284fd17c6020
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24397
diff
changeset
|
1845 |
284fd17c6020
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24397
diff
changeset
|
1846 children = gtk_container_get_children(GTK_CONTAINER(menu)); |
284fd17c6020
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24397
diff
changeset
|
1847 if (!children) { |
284fd17c6020
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24397
diff
changeset
|
1848 GtkWidget *item = gtk_menu_item_new_with_label(_("No actions available")); |
284fd17c6020
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24397
diff
changeset
|
1849 gtk_widget_show(item); |
284fd17c6020
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24397
diff
changeset
|
1850 gtk_widget_set_sensitive(item, FALSE); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1851 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); |
24548
284fd17c6020
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24397
diff
changeset
|
1852 } else { |
284fd17c6020
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24397
diff
changeset
|
1853 g_list_free(children); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1854 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1855 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1856 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1857 gtk_widget_show_all(menu); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1858 gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1859 event_button->button, event_button->time); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1860 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1861 return TRUE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1862 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1863 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1864 if(event->type == GDK_BUTTON_PRESS && event_button->button == 3) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1865 return TRUE; /* Clicking the right mouse button on a link shouldn't |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1866 be caught by the regular GtkTextView menu */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1867 else |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1868 return FALSE; /* Let clicks go through if we didn't catch anything */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1869 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1870 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1871 static gboolean |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1872 gtk_text_view_drag_motion (GtkWidget *widget, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1873 GdkDragContext *context, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1874 gint x, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1875 gint y, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1876 guint time) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1877 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1878 GdkDragAction suggested_action = 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1879 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1880 if (gtk_drag_dest_find_target (widget, context, NULL) == GDK_NONE) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1881 /* can't accept any of the offered targets */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1882 } else { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1883 GtkWidget *source_widget; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1884 suggested_action = context->suggested_action; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1885 source_widget = gtk_drag_get_source_widget (context); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1886 if (source_widget == widget) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1887 /* Default to MOVE, unless the user has |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1888 * pressed ctrl or alt to affect available actions |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1889 */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1890 if ((context->actions & GDK_ACTION_MOVE) != 0) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1891 suggested_action = GDK_ACTION_MOVE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1892 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1893 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1894 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1895 gdk_drag_status (context, suggested_action, time); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1896 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1897 /* TRUE return means don't propagate the drag motion to parent |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1898 * widgets that may also be drop sites. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1899 */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1900 return TRUE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1901 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1902 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1903 static void |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1904 gtk_imhtml_link_drop_cb(GtkWidget *widget, GdkDragContext *context, gint x, gint y, guint time, gpointer user_data) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1905 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1906 GdkAtom target = gtk_drag_dest_find_target (widget, context, NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1907 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1908 if (target != GDK_NONE) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1909 gtk_drag_get_data (widget, context, target, time); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1910 else |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1911 gtk_drag_finish (context, FALSE, FALSE, time); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1912 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1913 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1914 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1915 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1916 static void |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1917 gtk_imhtml_link_drag_rcv_cb(GtkWidget *widget, GdkDragContext *dc, guint x, guint y, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1918 GtkSelectionData *sd, guint info, guint t, GtkIMHtml *imhtml) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1919 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1920 gchar **links; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1921 gchar *link; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1922 char *text = (char *)sd->data; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1923 GtkTextMark *mark = gtk_text_buffer_get_insert(imhtml->text_buffer); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1924 GtkTextIter iter; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1925 gint i = 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1926 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1927 gtk_text_buffer_get_iter_at_mark(imhtml->text_buffer, &iter, mark); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1928 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1929 if(gtk_imhtml_get_editable(imhtml) && sd->data){ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1930 switch (info) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1931 case GTK_IMHTML_DRAG_URL: |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1932 /* TODO: Is it really ok to change sd->data...? */ |
15823 | 1933 purple_str_strip_char((char *)sd->data, '\r'); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1934 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1935 links = g_strsplit((char *)sd->data, "\n", 0); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1936 while((link = links[i]) != NULL){ |
24396
38a2f78f80a7
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24311
diff
changeset
|
1937 if (gtk_imhtml_is_protocol(link)) { |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1938 gchar *label; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1939 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1940 if(links[i + 1]) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1941 i++; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1942 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1943 label = links[i]; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1944 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1945 gtk_imhtml_insert_link(imhtml, mark, link, label); |
24396
38a2f78f80a7
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24311
diff
changeset
|
1946 } else if (*link == '\0') { |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1947 /* Ignore blank lines */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1948 } else { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1949 /* Special reasons, aka images being put in via other tag, etc. */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1950 /* ... don't pretend we handled it if we didn't */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1951 gtk_drag_finish(dc, FALSE, FALSE, t); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1952 g_strfreev(links); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1953 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1954 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1955 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1956 i++; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1957 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1958 g_strfreev(links); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1959 break; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1960 case GTK_IMHTML_DRAG_HTML: |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1961 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1962 char *utf8 = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1963 /* Ewww. This is all because mozilla thinks that text/html is 'for internal use only.' |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1964 * as explained by this comment in gtkhtml: |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1965 * |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1966 * FIXME This hack decides the charset of the selection. It seems that |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1967 * mozilla/netscape alway use ucs2 for text/html |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1968 * and openoffice.org seems to always use utf8 so we try to validate |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1969 * the string as utf8 and if that fails we assume it is ucs2 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1970 * |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1971 * See also the comment on text/html here: |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1972 * http://mail.gnome.org/archives/gtk-devel-list/2001-September/msg00114.html |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1973 */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1974 if (sd->length >= 2 && !g_utf8_validate(text, sd->length - 1, NULL)) { |
22447
9b154f484d64
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 <daniel.atallah@gmail.com>
parents:
22446
diff
changeset
|
1975 utf8 = utf16_to_utf8_with_bom_check(text, sd->length); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1976 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1977 if (!utf8) { |
22447
9b154f484d64
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 <daniel.atallah@gmail.com>
parents:
22446
diff
changeset
|
1978 purple_debug_warning("gtkimhtml", "g_convert from UTF-16 failed in drag_rcv_cb\n"); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1979 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1980 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1981 } else if (!(*text) || !g_utf8_validate(text, -1, NULL)) { |
15823 | 1982 purple_debug_warning("gtkimhtml", "empty string or invalid UTF-8 in drag_rcv_cb\n"); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1983 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1984 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1985 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1986 gtk_imhtml_insert_html_at_iter(imhtml, utf8 ? utf8 : text, 0, &iter); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1987 g_free(utf8); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1988 break; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1989 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1990 case GTK_IMHTML_DRAG_TEXT: |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1991 if (!(*text) || !g_utf8_validate(text, -1, NULL)) { |
15823 | 1992 purple_debug_warning("gtkimhtml", "empty string or invalid UTF-8 in drag_rcv_cb\n"); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1993 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1994 } else { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1995 char *tmp = g_markup_escape_text(text, -1); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1996 gtk_imhtml_insert_html_at_iter(imhtml, tmp, 0, &iter); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1997 g_free(tmp); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1998 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
1999 break; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2000 default: |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2001 gtk_drag_finish(dc, FALSE, FALSE, t); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2002 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2003 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2004 gtk_drag_finish(dc, TRUE, (dc->action == GDK_ACTION_MOVE), t); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2005 } else { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2006 gtk_drag_finish(dc, FALSE, FALSE, t); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2007 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2008 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2009 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2010 static void gtk_smiley_tree_remove (GtkSmileyTree *tree, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2011 GtkIMHtmlSmiley *smiley) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2012 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2013 GtkSmileyTree *t = tree; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2014 const gchar *x = smiley->smile; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2015 gint len = 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2016 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2017 while (*x) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2018 gchar *pos; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2019 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2020 if (!t->values) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2021 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2022 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2023 pos = strchr (t->values->str, *x); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2024 if (pos) |
24269
b6dc71133eb8
Fixed a compiler warning (and remove an unnessesary cast)
Marcus Lundblad <ml@update.uu.se>
parents:
24234
diff
changeset
|
2025 t = t->children [pos - t->values->str]; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2026 else |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2027 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2028 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2029 x++; len++; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2030 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2031 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2032 if (t->image) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2033 t->image = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2034 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2035 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2036 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2037 static gint |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2038 gtk_smiley_tree_lookup (GtkSmileyTree *tree, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2039 const gchar *text) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2040 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2041 GtkSmileyTree *t = tree; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2042 const gchar *x = text; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2043 gint len = 0; |
16083
f2a4b05407d7
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15871
diff
changeset
|
2044 const gchar *amp; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2045 gint alen; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2046 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2047 while (*x) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2048 gchar *pos; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2049 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2050 if (!t->values) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2051 break; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2052 |
16084 | 2053 if(*x == '&' && (amp = purple_markup_unescape_entity(x, &alen))) { |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2054 gboolean matched = TRUE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2055 /* Make sure all chars of the unescaped value match */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2056 while (*(amp + 1)) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2057 pos = strchr (t->values->str, *amp); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2058 if (pos) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2059 t = t->children [GPOINTER_TO_INT(pos) - GPOINTER_TO_INT(t->values->str)]; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2060 else { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2061 matched = FALSE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2062 break; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2063 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2064 amp++; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2065 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2066 if (!matched) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2067 break; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2068 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2069 pos = strchr (t->values->str, *amp); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2070 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2071 else if (*x == '<') /* Because we're all WYSIWYG now, a '<' |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2072 * char should only appear as the start of a tag. Perhaps a safer (but costlier) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2073 * check would be to call gtk_imhtml_is_tag on it */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2074 break; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2075 else { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2076 alen = 1; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2077 pos = strchr (t->values->str, *x); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2078 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2079 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2080 if (pos) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2081 t = t->children [GPOINTER_TO_INT(pos) - GPOINTER_TO_INT(t->values->str)]; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2082 else |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2083 break; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2084 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2085 x += alen; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2086 len += alen; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2087 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2088 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2089 if (t->image) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2090 return len; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2091 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2092 return 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2093 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2094 |
24115
9564593d170c
Clean up the GtkSmileyTrees on active GtkIMHtml instances when a custom smiley
Marcus Lundblad <ml@update.uu.se>
parents:
24061
diff
changeset
|
2095 static void |
9564593d170c
Clean up the GtkSmileyTrees on active GtkIMHtml instances when a custom smiley
Marcus Lundblad <ml@update.uu.se>
parents:
24061
diff
changeset
|
2096 gtk_imhtml_disassociate_smiley_foreach(gpointer key, gpointer value, |
9564593d170c
Clean up the GtkSmileyTrees on active GtkIMHtml instances when a custom smiley
Marcus Lundblad <ml@update.uu.se>
parents:
24061
diff
changeset
|
2097 gpointer user_data) |
9564593d170c
Clean up the GtkSmileyTrees on active GtkIMHtml instances when a custom smiley
Marcus Lundblad <ml@update.uu.se>
parents:
24061
diff
changeset
|
2098 { |
9564593d170c
Clean up the GtkSmileyTrees on active GtkIMHtml instances when a custom smiley
Marcus Lundblad <ml@update.uu.se>
parents:
24061
diff
changeset
|
2099 GtkSmileyTree *tree = (GtkSmileyTree *) value; |
9564593d170c
Clean up the GtkSmileyTrees on active GtkIMHtml instances when a custom smiley
Marcus Lundblad <ml@update.uu.se>
parents:
24061
diff
changeset
|
2100 GtkIMHtmlSmiley *smiley = (GtkIMHtmlSmiley *) user_data; |
9564593d170c
Clean up the GtkSmileyTrees on active GtkIMHtml instances when a custom smiley
Marcus Lundblad <ml@update.uu.se>
parents:
24061
diff
changeset
|
2101 gtk_smiley_tree_remove(tree, smiley); |
9564593d170c
Clean up the GtkSmileyTrees on active GtkIMHtml instances when a custom smiley
Marcus Lundblad <ml@update.uu.se>
parents:
24061
diff
changeset
|
2102 } |
9564593d170c
Clean up the GtkSmileyTrees on active GtkIMHtml instances when a custom smiley
Marcus Lundblad <ml@update.uu.se>
parents:
24061
diff
changeset
|
2103 |
9564593d170c
Clean up the GtkSmileyTrees on active GtkIMHtml instances when a custom smiley
Marcus Lundblad <ml@update.uu.se>
parents:
24061
diff
changeset
|
2104 static void |
24311
9ea84135db24
Remove that hack involving GtkIMHtmlSmileys
Marcus Lundblad <ml@update.uu.se>
parents:
24310
diff
changeset
|
2105 gtk_imhtml_disconnect_smiley(GtkIMHtml *imhtml, GtkIMHtmlSmiley *smiley) |
9ea84135db24
Remove that hack involving GtkIMHtmlSmileys
Marcus Lundblad <ml@update.uu.se>
parents:
24310
diff
changeset
|
2106 { |
9ea84135db24
Remove that hack involving GtkIMHtmlSmileys
Marcus Lundblad <ml@update.uu.se>
parents:
24310
diff
changeset
|
2107 smiley->imhtml = NULL; |
9ea84135db24
Remove that hack involving GtkIMHtmlSmileys
Marcus Lundblad <ml@update.uu.se>
parents:
24310
diff
changeset
|
2108 g_signal_handlers_disconnect_matched(imhtml, G_SIGNAL_MATCH_DATA, 0, 0, |
9ea84135db24
Remove that hack involving GtkIMHtmlSmileys
Marcus Lundblad <ml@update.uu.se>
parents:
24310
diff
changeset
|
2109 NULL, NULL, smiley); |
9ea84135db24
Remove that hack involving GtkIMHtmlSmileys
Marcus Lundblad <ml@update.uu.se>
parents:
24310
diff
changeset
|
2110 } |
9ea84135db24
Remove that hack involving GtkIMHtmlSmileys
Marcus Lundblad <ml@update.uu.se>
parents:
24310
diff
changeset
|
2111 |
9ea84135db24
Remove that hack involving GtkIMHtmlSmileys
Marcus Lundblad <ml@update.uu.se>
parents:
24310
diff
changeset
|
2112 static void |
24115
9564593d170c
Clean up the GtkSmileyTrees on active GtkIMHtml instances when a custom smiley
Marcus Lundblad <ml@update.uu.se>
parents:
24061
diff
changeset
|
2113 gtk_imhtml_disassociate_smiley(GtkIMHtmlSmiley *smiley) |
9564593d170c
Clean up the GtkSmileyTrees on active GtkIMHtml instances when a custom smiley
Marcus Lundblad <ml@update.uu.se>
parents:
24061
diff
changeset
|
2114 { |
24311
9ea84135db24
Remove that hack involving GtkIMHtmlSmileys
Marcus Lundblad <ml@update.uu.se>
parents:
24310
diff
changeset
|
2115 if (smiley->imhtml) { |
24115
9564593d170c
Clean up the GtkSmileyTrees on active GtkIMHtml instances when a custom smiley
Marcus Lundblad <ml@update.uu.se>
parents:
24061
diff
changeset
|
2116 gtk_smiley_tree_remove(smiley->imhtml->default_smilies, smiley); |
25415
584063555949
Remove trailing whitespace
Mark Doliner <mark@kingant.net>
parents:
25381
diff
changeset
|
2117 g_hash_table_foreach(smiley->imhtml->smiley_data, |
24115
9564593d170c
Clean up the GtkSmileyTrees on active GtkIMHtml instances when a custom smiley
Marcus Lundblad <ml@update.uu.se>
parents:
24061
diff
changeset
|
2118 gtk_imhtml_disassociate_smiley_foreach, smiley); |
24311
9ea84135db24
Remove that hack involving GtkIMHtmlSmileys
Marcus Lundblad <ml@update.uu.se>
parents:
24310
diff
changeset
|
2119 g_signal_handlers_disconnect_matched(smiley->imhtml, G_SIGNAL_MATCH_DATA, |
9ea84135db24
Remove that hack involving GtkIMHtmlSmileys
Marcus Lundblad <ml@update.uu.se>
parents:
24310
diff
changeset
|
2120 0, 0, NULL, NULL, smiley); |
24310
4acda11bf672
Don't try to remove GtkIMHtmlSmileys from smiley trees if the GtkIMHtml
Marcus Lundblad <ml@update.uu.se>
parents:
24292
diff
changeset
|
2121 smiley->imhtml = NULL; |
24115
9564593d170c
Clean up the GtkSmileyTrees on active GtkIMHtml instances when a custom smiley
Marcus Lundblad <ml@update.uu.se>
parents:
24061
diff
changeset
|
2122 } |
9564593d170c
Clean up the GtkSmileyTrees on active GtkIMHtml instances when a custom smiley
Marcus Lundblad <ml@update.uu.se>
parents:
24061
diff
changeset
|
2123 } |
9564593d170c
Clean up the GtkSmileyTrees on active GtkIMHtml instances when a custom smiley
Marcus Lundblad <ml@update.uu.se>
parents:
24061
diff
changeset
|
2124 |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2125 void |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2126 gtk_imhtml_associate_smiley (GtkIMHtml *imhtml, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2127 const gchar *sml, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2128 GtkIMHtmlSmiley *smiley) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2129 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2130 GtkSmileyTree *tree; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2131 g_return_if_fail (imhtml != NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2132 g_return_if_fail (GTK_IS_IMHTML (imhtml)); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2133 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2134 if (sml == NULL) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2135 tree = imhtml->default_smilies; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2136 else if (!(tree = g_hash_table_lookup(imhtml->smiley_data, sml))) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2137 tree = gtk_smiley_tree_new(); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2138 g_hash_table_insert(imhtml->smiley_data, g_strdup(sml), tree); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2139 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2140 |
24311
9ea84135db24
Remove that hack involving GtkIMHtmlSmileys
Marcus Lundblad <ml@update.uu.se>
parents:
24310
diff
changeset
|
2141 /* need to disconnect old imhtml, if there is one */ |
9ea84135db24
Remove that hack involving GtkIMHtmlSmileys
Marcus Lundblad <ml@update.uu.se>
parents:
24310
diff
changeset
|
2142 if (smiley->imhtml) { |
9ea84135db24
Remove that hack involving GtkIMHtmlSmileys
Marcus Lundblad <ml@update.uu.se>
parents:
24310
diff
changeset
|
2143 g_signal_handlers_disconnect_matched(smiley->imhtml, G_SIGNAL_MATCH_DATA, |
9ea84135db24
Remove that hack involving GtkIMHtmlSmileys
Marcus Lundblad <ml@update.uu.se>
parents:
24310
diff
changeset
|
2144 0, 0, NULL, NULL, smiley); |
9ea84135db24
Remove that hack involving GtkIMHtmlSmileys
Marcus Lundblad <ml@update.uu.se>
parents:
24310
diff
changeset
|
2145 } |
25415
584063555949
Remove trailing whitespace
Mark Doliner <mark@kingant.net>
parents:
25381
diff
changeset
|
2146 |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2147 smiley->imhtml = imhtml; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2148 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2149 gtk_smiley_tree_insert (tree, smiley); |
25415
584063555949
Remove trailing whitespace
Mark Doliner <mark@kingant.net>
parents:
25381
diff
changeset
|
2150 |
24311
9ea84135db24
Remove that hack involving GtkIMHtmlSmileys
Marcus Lundblad <ml@update.uu.se>
parents:
24310
diff
changeset
|
2151 /* connect destroy signal for the imhtml */ |
25415
584063555949
Remove trailing whitespace
Mark Doliner <mark@kingant.net>
parents:
25381
diff
changeset
|
2152 g_signal_connect(imhtml, "destroy", G_CALLBACK(gtk_imhtml_disconnect_smiley), |
24311
9ea84135db24
Remove that hack involving GtkIMHtmlSmileys
Marcus Lundblad <ml@update.uu.se>
parents:
24310
diff
changeset
|
2153 smiley); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2154 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2155 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2156 static gboolean |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2157 gtk_imhtml_is_smiley (GtkIMHtml *imhtml, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2158 GSList *fonts, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2159 const gchar *text, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2160 gint *len) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2161 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2162 GtkSmileyTree *tree; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2163 GtkIMHtmlFontDetail *font; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2164 char *sml = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2165 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2166 if (fonts) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2167 font = fonts->data; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2168 sml = font->sml; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2169 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2170 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2171 if (!sml) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2172 sml = imhtml->protocol_name; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2173 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2174 if (!sml || !(tree = g_hash_table_lookup(imhtml->smiley_data, sml))) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2175 tree = imhtml->default_smilies; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2176 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2177 if (tree == NULL) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2178 return FALSE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2179 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2180 *len = gtk_smiley_tree_lookup (tree, text); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2181 return (*len > 0); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2182 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2183 |
29789
89f0c974a6f9
Minor cleanup. Hopefully this code has a little less duplication and
Mark Doliner <mark@kingant.net>
parents:
29786
diff
changeset
|
2184 static GtkIMHtmlSmiley *gtk_imhtml_smiley_get_from_tree(GtkSmileyTree *t, const gchar *text) |
89f0c974a6f9
Minor cleanup. Hopefully this code has a little less duplication and
Mark Doliner <mark@kingant.net>
parents:
29786
diff
changeset
|
2185 { |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2186 const gchar *x = text; |
29789
89f0c974a6f9
Minor cleanup. Hopefully this code has a little less duplication and
Mark Doliner <mark@kingant.net>
parents:
29786
diff
changeset
|
2187 gchar *pos; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2188 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2189 if (t == NULL) |
29789
89f0c974a6f9
Minor cleanup. Hopefully this code has a little less duplication and
Mark Doliner <mark@kingant.net>
parents:
29786
diff
changeset
|
2190 return NULL; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2191 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2192 while (*x) { |
29789
89f0c974a6f9
Minor cleanup. Hopefully this code has a little less duplication and
Mark Doliner <mark@kingant.net>
parents:
29786
diff
changeset
|
2193 if (!t->values) |
89f0c974a6f9
Minor cleanup. Hopefully this code has a little less duplication and
Mark Doliner <mark@kingant.net>
parents:
29786
diff
changeset
|
2194 return NULL; |
89f0c974a6f9
Minor cleanup. Hopefully this code has a little less duplication and
Mark Doliner <mark@kingant.net>
parents:
29786
diff
changeset
|
2195 |
89f0c974a6f9
Minor cleanup. Hopefully this code has a little less duplication and
Mark Doliner <mark@kingant.net>
parents:
29786
diff
changeset
|
2196 pos = strchr(t->values->str, *x); |
89f0c974a6f9
Minor cleanup. Hopefully this code has a little less duplication and
Mark Doliner <mark@kingant.net>
parents:
29786
diff
changeset
|
2197 if (!pos) |
89f0c974a6f9
Minor cleanup. Hopefully this code has a little less duplication and
Mark Doliner <mark@kingant.net>
parents:
29786
diff
changeset
|
2198 return NULL; |
89f0c974a6f9
Minor cleanup. Hopefully this code has a little less duplication and
Mark Doliner <mark@kingant.net>
parents:
29786
diff
changeset
|
2199 |
89f0c974a6f9
Minor cleanup. Hopefully this code has a little less duplication and
Mark Doliner <mark@kingant.net>
parents:
29786
diff
changeset
|
2200 t = t->children[GPOINTER_TO_INT(pos) - GPOINTER_TO_INT(t->values->str)]; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2201 x++; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2202 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2203 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2204 return t->image; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2205 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2206 |
29789
89f0c974a6f9
Minor cleanup. Hopefully this code has a little less duplication and
Mark Doliner <mark@kingant.net>
parents:
29786
diff
changeset
|
2207 GtkIMHtmlSmiley * |
89f0c974a6f9
Minor cleanup. Hopefully this code has a little less duplication and
Mark Doliner <mark@kingant.net>
parents:
29786
diff
changeset
|
2208 gtk_imhtml_smiley_get(GtkIMHtml *imhtml, const gchar *sml, const gchar *text) |
89f0c974a6f9
Minor cleanup. Hopefully this code has a little less duplication and
Mark Doliner <mark@kingant.net>
parents:
29786
diff
changeset
|
2209 { |
89f0c974a6f9
Minor cleanup. Hopefully this code has a little less duplication and
Mark Doliner <mark@kingant.net>
parents:
29786
diff
changeset
|
2210 GtkIMHtmlSmiley *ret; |
89f0c974a6f9
Minor cleanup. Hopefully this code has a little less duplication and
Mark Doliner <mark@kingant.net>
parents:
29786
diff
changeset
|
2211 |
89f0c974a6f9
Minor cleanup. Hopefully this code has a little less duplication and
Mark Doliner <mark@kingant.net>
parents:
29786
diff
changeset
|
2212 /* Look for custom smileys first */ |
89f0c974a6f9
Minor cleanup. Hopefully this code has a little less duplication and
Mark Doliner <mark@kingant.net>
parents:
29786
diff
changeset
|
2213 if (sml != NULL) { |
89f0c974a6f9
Minor cleanup. Hopefully this code has a little less duplication and
Mark Doliner <mark@kingant.net>
parents:
29786
diff
changeset
|
2214 ret = gtk_imhtml_smiley_get_from_tree(g_hash_table_lookup(imhtml->smiley_data, sml), text); |
89f0c974a6f9
Minor cleanup. Hopefully this code has a little less duplication and
Mark Doliner <mark@kingant.net>
parents:
29786
diff
changeset
|
2215 if (ret != NULL) |
89f0c974a6f9
Minor cleanup. Hopefully this code has a little less duplication and
Mark Doliner <mark@kingant.net>
parents:
29786
diff
changeset
|
2216 return ret; |
89f0c974a6f9
Minor cleanup. Hopefully this code has a little less duplication and
Mark Doliner <mark@kingant.net>
parents:
29786
diff
changeset
|
2217 } |
89f0c974a6f9
Minor cleanup. Hopefully this code has a little less duplication and
Mark Doliner <mark@kingant.net>
parents:
29786
diff
changeset
|
2218 |
89f0c974a6f9
Minor cleanup. Hopefully this code has a little less duplication and
Mark Doliner <mark@kingant.net>
parents:
29786
diff
changeset
|
2219 /* Fall back to check for default smileys */ |
89f0c974a6f9
Minor cleanup. Hopefully this code has a little less duplication and
Mark Doliner <mark@kingant.net>
parents:
29786
diff
changeset
|
2220 return gtk_imhtml_smiley_get_from_tree(imhtml->default_smilies, text); |
89f0c974a6f9
Minor cleanup. Hopefully this code has a little less duplication and
Mark Doliner <mark@kingant.net>
parents:
29786
diff
changeset
|
2221 } |
89f0c974a6f9
Minor cleanup. Hopefully this code has a little less duplication and
Mark Doliner <mark@kingant.net>
parents:
29786
diff
changeset
|
2222 |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2223 static GdkPixbufAnimation * |
16964
ab45289d2c36
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 <imadil@gmail.com>
parents:
16309
diff
changeset
|
2224 gtk_smiley_get_image(GtkIMHtmlSmiley *smiley) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2225 { |
29789
89f0c974a6f9
Minor cleanup. Hopefully this code has a little less duplication and
Mark Doliner <mark@kingant.net>
parents:
29786
diff
changeset
|
2226 if (!smiley->icon) { |
89f0c974a6f9
Minor cleanup. Hopefully this code has a little less duplication and
Mark Doliner <mark@kingant.net>
parents:
29786
diff
changeset
|
2227 if (smiley->file) { |
89f0c974a6f9
Minor cleanup. Hopefully this code has a little less duplication and
Mark Doliner <mark@kingant.net>
parents:
29786
diff
changeset
|
2228 smiley->icon = gdk_pixbuf_animation_new_from_file(smiley->file, NULL); |
89f0c974a6f9
Minor cleanup. Hopefully this code has a little less duplication and
Mark Doliner <mark@kingant.net>
parents:
29786
diff
changeset
|
2229 } else if (smiley->loader) { |
89f0c974a6f9
Minor cleanup. Hopefully this code has a little less duplication and
Mark Doliner <mark@kingant.net>
parents:
29786
diff
changeset
|
2230 smiley->icon = gdk_pixbuf_loader_get_animation(smiley->loader); |
89f0c974a6f9
Minor cleanup. Hopefully this code has a little less duplication and
Mark Doliner <mark@kingant.net>
parents:
29786
diff
changeset
|
2231 if (smiley->icon) |
89f0c974a6f9
Minor cleanup. Hopefully this code has a little less duplication and
Mark Doliner <mark@kingant.net>
parents:
29786
diff
changeset
|
2232 g_object_ref(G_OBJECT(smiley->icon)); |
89f0c974a6f9
Minor cleanup. Hopefully this code has a little less duplication and
Mark Doliner <mark@kingant.net>
parents:
29786
diff
changeset
|
2233 } |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2234 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2235 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2236 return smiley->icon; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2237 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2238 |
25361
d9da15c9e2a1
Fix the linkification error where bad things happened if you copy/pasted
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
25358
diff
changeset
|
2239 #define VALID_TAG(x) do { \ |
d9da15c9e2a1
Fix the linkification error where bad things happened if you copy/pasted
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
25358
diff
changeset
|
2240 if (!g_ascii_strncasecmp (string, x ">", strlen (x ">"))) { \ |
d9da15c9e2a1
Fix the linkification error where bad things happened if you copy/pasted
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
25358
diff
changeset
|
2241 if (tag) *tag = g_strndup (string, strlen (x)); \ |
d9da15c9e2a1
Fix the linkification error where bad things happened if you copy/pasted
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
25358
diff
changeset
|
2242 if (len) *len = strlen (x) + 1; \ |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2243 return TRUE; \ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2244 } \ |
25361
d9da15c9e2a1
Fix the linkification error where bad things happened if you copy/pasted
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
25358
diff
changeset
|
2245 if (type) (*type)++; \ |
d9da15c9e2a1
Fix the linkification error where bad things happened if you copy/pasted
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
25358
diff
changeset
|
2246 } while (0) |
d9da15c9e2a1
Fix the linkification error where bad things happened if you copy/pasted
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
25358
diff
changeset
|
2247 |
d9da15c9e2a1
Fix the linkification error where bad things happened if you copy/pasted
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
25358
diff
changeset
|
2248 #define VALID_OPT_TAG(x) do { \ |
d9da15c9e2a1
Fix the linkification error where bad things happened if you copy/pasted
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
25358
diff
changeset
|
2249 if (!g_ascii_strncasecmp (string, x " ", strlen (x " "))) { \ |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2250 const gchar *c = string + strlen (x " "); \ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2251 gchar e = '"'; \ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2252 gboolean quote = FALSE; \ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2253 while (*c) { \ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2254 if (*c == '"' || *c == '\'') { \ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2255 if (quote && (*c == e)) \ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2256 quote = !quote; \ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2257 else if (!quote) { \ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2258 quote = !quote; \ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2259 e = *c; \ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2260 } \ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2261 } else if (!quote && (*c == '>')) \ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2262 break; \ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2263 c++; \ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2264 } \ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2265 if (*c) { \ |
25361
d9da15c9e2a1
Fix the linkification error where bad things happened if you copy/pasted
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
25358
diff
changeset
|
2266 if (tag) *tag = g_strndup (string, c - string); \ |
d9da15c9e2a1
Fix the linkification error where bad things happened if you copy/pasted
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
25358
diff
changeset
|
2267 if (len) *len = c - string + 1; \ |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2268 return TRUE; \ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2269 } \ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2270 } \ |
25361
d9da15c9e2a1
Fix the linkification error where bad things happened if you copy/pasted
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
25358
diff
changeset
|
2271 if (type) (*type)++; \ |
d9da15c9e2a1
Fix the linkification error where bad things happened if you copy/pasted
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
25358
diff
changeset
|
2272 } while (0) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2273 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2274 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2275 static gboolean |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2276 gtk_imhtml_is_tag (const gchar *string, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2277 gchar **tag, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2278 gint *len, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2279 gint *type) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2280 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2281 char *close; |
25361
d9da15c9e2a1
Fix the linkification error where bad things happened if you copy/pasted
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
25358
diff
changeset
|
2282 if (type) |
d9da15c9e2a1
Fix the linkification error where bad things happened if you copy/pasted
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
25358
diff
changeset
|
2283 *type = 1; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2284 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2285 if (!(close = strchr (string, '>'))) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2286 return FALSE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2287 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2288 VALID_TAG ("B"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2289 VALID_TAG ("BOLD"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2290 VALID_TAG ("/B"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2291 VALID_TAG ("/BOLD"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2292 VALID_TAG ("I"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2293 VALID_TAG ("ITALIC"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2294 VALID_TAG ("/I"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2295 VALID_TAG ("/ITALIC"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2296 VALID_TAG ("U"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2297 VALID_TAG ("UNDERLINE"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2298 VALID_TAG ("/U"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2299 VALID_TAG ("/UNDERLINE"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2300 VALID_TAG ("S"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2301 VALID_TAG ("STRIKE"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2302 VALID_TAG ("/S"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2303 VALID_TAG ("/STRIKE"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2304 VALID_TAG ("SUB"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2305 VALID_TAG ("/SUB"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2306 VALID_TAG ("SUP"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2307 VALID_TAG ("/SUP"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2308 VALID_TAG ("PRE"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2309 VALID_TAG ("/PRE"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2310 VALID_TAG ("TITLE"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2311 VALID_TAG ("/TITLE"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2312 VALID_TAG ("BR"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2313 VALID_TAG ("HR"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2314 VALID_TAG ("/FONT"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2315 VALID_TAG ("/A"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2316 VALID_TAG ("P"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2317 VALID_TAG ("/P"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2318 VALID_TAG ("H3"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2319 VALID_TAG ("/H3"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2320 VALID_TAG ("HTML"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2321 VALID_TAG ("/HTML"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2322 VALID_TAG ("BODY"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2323 VALID_TAG ("/BODY"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2324 VALID_TAG ("FONT"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2325 VALID_TAG ("HEAD"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2326 VALID_TAG ("/HEAD"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2327 VALID_TAG ("BINARY"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2328 VALID_TAG ("/BINARY"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2329 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2330 VALID_OPT_TAG ("HR"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2331 VALID_OPT_TAG ("FONT"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2332 VALID_OPT_TAG ("BODY"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2333 VALID_OPT_TAG ("A"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2334 VALID_OPT_TAG ("IMG"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2335 VALID_OPT_TAG ("P"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2336 VALID_OPT_TAG ("H3"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2337 VALID_OPT_TAG ("HTML"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2338 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2339 VALID_TAG ("CITE"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2340 VALID_TAG ("/CITE"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2341 VALID_TAG ("EM"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2342 VALID_TAG ("/EM"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2343 VALID_TAG ("STRONG"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2344 VALID_TAG ("/STRONG"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2345 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2346 VALID_OPT_TAG ("SPAN"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2347 VALID_TAG ("/SPAN"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2348 VALID_TAG ("BR/"); /* hack until gtkimhtml handles things better */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2349 VALID_TAG ("IMG"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2350 VALID_TAG("SPAN"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2351 VALID_OPT_TAG("BR"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2352 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2353 if (!g_ascii_strncasecmp(string, "!--", strlen ("!--"))) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2354 gchar *e = strstr (string + strlen("!--"), "-->"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2355 if (e) { |
25361
d9da15c9e2a1
Fix the linkification error where bad things happened if you copy/pasted
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
25358
diff
changeset
|
2356 if (len) |
d9da15c9e2a1
Fix the linkification error where bad things happened if you copy/pasted
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
25358
diff
changeset
|
2357 *len = e - string + strlen ("-->"); |
d9da15c9e2a1
Fix the linkification error where bad things happened if you copy/pasted
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
25358
diff
changeset
|
2358 if (tag) |
d9da15c9e2a1
Fix the linkification error where bad things happened if you copy/pasted
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
25358
diff
changeset
|
2359 *tag = g_strndup (string + strlen ("!--"), *len - strlen ("!---->")); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2360 return TRUE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2361 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2362 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2363 |
25361
d9da15c9e2a1
Fix the linkification error where bad things happened if you copy/pasted
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
25358
diff
changeset
|
2364 if (type) |
d9da15c9e2a1
Fix the linkification error where bad things happened if you copy/pasted
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
25358
diff
changeset
|
2365 *type = -1; |
d9da15c9e2a1
Fix the linkification error where bad things happened if you copy/pasted
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
25358
diff
changeset
|
2366 if (len) |
d9da15c9e2a1
Fix the linkification error where bad things happened if you copy/pasted
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
25358
diff
changeset
|
2367 *len = close - string + 1; |
d9da15c9e2a1
Fix the linkification error where bad things happened if you copy/pasted
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
25358
diff
changeset
|
2368 if (tag) |
d9da15c9e2a1
Fix the linkification error where bad things happened if you copy/pasted
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
25358
diff
changeset
|
2369 *tag = g_strndup(string, *len - 1); |
19567
b99a158ea85e
disapproval of revision 'c672802b647f1230fbd9b0edf383fb3d558cf719'
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
19566
diff
changeset
|
2370 return TRUE; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2371 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2372 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2373 static gchar* |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2374 gtk_imhtml_get_html_opt (gchar *tag, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2375 const gchar *opt) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2376 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2377 gchar *t = tag; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2378 gchar *e, *a; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2379 gchar *val; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2380 gint len; |
16083
f2a4b05407d7
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15871
diff
changeset
|
2381 const gchar *c; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2382 GString *ret; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2383 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2384 while (g_ascii_strncasecmp (t, opt, strlen (opt))) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2385 gboolean quote = FALSE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2386 if (*t == '\0') break; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2387 while (*t && !((*t == ' ') && !quote)) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2388 if (*t == '\"') |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2389 quote = ! quote; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2390 t++; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2391 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2392 while (*t && (*t == ' ')) t++; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2393 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2394 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2395 if (!g_ascii_strncasecmp (t, opt, strlen (opt))) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2396 t += strlen (opt); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2397 } else { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2398 return NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2399 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2400 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2401 if ((*t == '\"') || (*t == '\'')) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2402 e = a = ++t; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2403 while (*e && (*e != *(t - 1))) e++; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2404 if (*e == '\0') { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2405 return NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2406 } else |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2407 val = g_strndup(a, e - a); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2408 } else { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2409 e = a = t; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2410 while (*e && !isspace ((gint) *e)) e++; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2411 val = g_strndup(a, e - a); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2412 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2413 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2414 ret = g_string_new(""); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2415 e = val; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2416 while(*e) { |
16084 | 2417 if((c = purple_markup_unescape_entity(e, &len))) { |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2418 ret = g_string_append(ret, c); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2419 e += len; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2420 } else { |
19260
6ae4e6996c9f
Thanks sadrul. Fixes #2277
Sean Egan <seanegan@gmail.com>
parents:
18801
diff
changeset
|
2421 gunichar uni = g_utf8_get_char(e); |
6ae4e6996c9f
Thanks sadrul. Fixes #2277
Sean Egan <seanegan@gmail.com>
parents:
18801
diff
changeset
|
2422 ret = g_string_append_unichar(ret, uni); |
6ae4e6996c9f
Thanks sadrul. Fixes #2277
Sean Egan <seanegan@gmail.com>
parents:
18801
diff
changeset
|
2423 e = g_utf8_next_char(e); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2424 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2425 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2426 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2427 g_free(val); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2428 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2429 return g_string_free(ret, FALSE); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2430 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2431 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2432 /* returns if the beginning of the text is a protocol. If it is the protocol, returns the length so |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2433 the caller knows how long the protocol string is. */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2434 static int gtk_imhtml_is_protocol(const char *text) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2435 { |
25357
b01a7f17a2bb
Detect duplication registrations by substring.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
25355
diff
changeset
|
2436 GtkIMHtmlProtocol *proto = imhtml_find_protocol(text, FALSE); |
24396
38a2f78f80a7
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24311
diff
changeset
|
2437 return proto ? proto->length : 0; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2438 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2439 |
28987
ed0c4defd3dd
Fix scrolling bug for very busy chat rooms.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
28982
diff
changeset
|
2440 static gboolean smooth_scroll_cb(gpointer data); |
ed0c4defd3dd
Fix scrolling bug for very busy chat rooms.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
28982
diff
changeset
|
2441 |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2442 /* |
15823 | 2443 <KingAnt> marv: The two IM image functions in oscar are purple_odc_send_im and purple_odc_incoming |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2444 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2445 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2446 [19:58] <Robot101> marv: images go into the imgstore, a refcounted... well.. hash. :) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2447 [19:59] <KingAnt> marv: I think the image tag used by the core is something like <img id="#"/> |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2448 [19:59] Ro0tSiEgE robert42 RobFlynn Robot101 ross22 roz |
15823 | 2449 [20:00] <KingAnt> marv: Where the ID is the what is returned when you add the image to the imgstore using purple_imgstore_add |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2450 [20:00] <marv> Robot101: so how does the image get passed to serv_got_im() and serv_send_im()? just as the <img id="#" and then the prpl looks it up from the store? |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2451 [20:00] <KingAnt> marv: Right |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2452 [20:00] <marv> alright |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2453 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2454 Here's my plan with IMImages. make gtk_imhtml_[append|insert]_text_with_images instead just |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2455 gtkimhtml_[append|insert]_text (hrm maybe it should be called html instead of text), add a |
15823 | 2456 function for purple to register for look up images, i.e. gtk_imhtml_set_get_img_fnc, so that |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2457 images can be looked up like that, instead of passing a GSList of them. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2458 */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2459 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2460 void gtk_imhtml_append_text_with_images (GtkIMHtml *imhtml, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2461 const gchar *text, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2462 GtkIMHtmlOptions options, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2463 GSList *unused) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2464 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2465 GtkTextIter iter, ins, sel; |
22643
0de4b47d36ab
Do not show tooltips for <HR> or <IMG>s in gtkimhtml. Fixes #5480.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22612
diff
changeset
|
2466 int ins_offset = 0, sel_offset = 0; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2467 gboolean fixins = FALSE, fixsel = FALSE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2468 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2469 g_return_if_fail (imhtml != NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2470 g_return_if_fail (GTK_IS_IMHTML (imhtml)); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2471 g_return_if_fail (text != NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2472 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2473 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2474 gtk_text_buffer_get_end_iter(imhtml->text_buffer, &iter); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2475 gtk_text_buffer_get_iter_at_mark(imhtml->text_buffer, &ins, gtk_text_buffer_get_insert(imhtml->text_buffer)); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2476 if (gtk_text_iter_equal(&iter, &ins) && gtk_text_buffer_get_selection_bounds(imhtml->text_buffer, NULL, NULL)) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2477 fixins = TRUE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2478 ins_offset = gtk_text_iter_get_offset(&ins); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2479 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2480 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2481 gtk_text_buffer_get_iter_at_mark(imhtml->text_buffer, &sel, gtk_text_buffer_get_selection_bound(imhtml->text_buffer)); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2482 if (gtk_text_iter_equal(&iter, &sel) && gtk_text_buffer_get_selection_bounds(imhtml->text_buffer, NULL, NULL)) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2483 fixsel = TRUE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2484 sel_offset = gtk_text_iter_get_offset(&sel); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2485 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2486 |
22643
0de4b47d36ab
Do not show tooltips for <HR> or <IMG>s in gtkimhtml. Fixes #5480.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22612
diff
changeset
|
2487 if (!(options & GTK_IMHTML_NO_SCROLL)) { |
0de4b47d36ab
Do not show tooltips for <HR> or <IMG>s in gtkimhtml. Fixes #5480.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22612
diff
changeset
|
2488 GdkRectangle rect; |
0de4b47d36ab
Do not show tooltips for <HR> or <IMG>s in gtkimhtml. Fixes #5480.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22612
diff
changeset
|
2489 int y, height; |
0de4b47d36ab
Do not show tooltips for <HR> or <IMG>s in gtkimhtml. Fixes #5480.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22612
diff
changeset
|
2490 |
0de4b47d36ab
Do not show tooltips for <HR> or <IMG>s in gtkimhtml. Fixes #5480.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22612
diff
changeset
|
2491 gtk_text_view_get_visible_rect(GTK_TEXT_VIEW(imhtml), &rect); |
0de4b47d36ab
Do not show tooltips for <HR> or <IMG>s in gtkimhtml. Fixes #5480.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22612
diff
changeset
|
2492 gtk_text_view_get_line_yrange(GTK_TEXT_VIEW(imhtml), &iter, &y, &height); |
0de4b47d36ab
Do not show tooltips for <HR> or <IMG>s in gtkimhtml. Fixes #5480.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22612
diff
changeset
|
2493 |
0de4b47d36ab
Do not show tooltips for <HR> or <IMG>s in gtkimhtml. Fixes #5480.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22612
diff
changeset
|
2494 if (((y + height) - (rect.y + rect.height)) > height && |
0de4b47d36ab
Do not show tooltips for <HR> or <IMG>s in gtkimhtml. Fixes #5480.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22612
diff
changeset
|
2495 gtk_text_buffer_get_char_count(imhtml->text_buffer)) { |
28987
ed0c4defd3dd
Fix scrolling bug for very busy chat rooms.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
28982
diff
changeset
|
2496 /* If we are in the middle of smooth-scrolling, then take a scroll step. |
ed0c4defd3dd
Fix scrolling bug for very busy chat rooms.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
28982
diff
changeset
|
2497 * If we are not in the middle of smooth-scrolling, that means we were |
ed0c4defd3dd
Fix scrolling bug for very busy chat rooms.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
28982
diff
changeset
|
2498 * not looking at the end of the buffer before the new text was added, |
ed0c4defd3dd
Fix scrolling bug for very busy chat rooms.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
28982
diff
changeset
|
2499 * so do not scroll. */ |
ed0c4defd3dd
Fix scrolling bug for very busy chat rooms.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
28982
diff
changeset
|
2500 if (imhtml->scroll_time) |
ed0c4defd3dd
Fix scrolling bug for very busy chat rooms.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
28982
diff
changeset
|
2501 smooth_scroll_cb(imhtml); |
ed0c4defd3dd
Fix scrolling bug for very busy chat rooms.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
28982
diff
changeset
|
2502 else |
ed0c4defd3dd
Fix scrolling bug for very busy chat rooms.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
28982
diff
changeset
|
2503 options |= GTK_IMHTML_NO_SCROLL; |
22643
0de4b47d36ab
Do not show tooltips for <HR> or <IMG>s in gtkimhtml. Fixes #5480.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22612
diff
changeset
|
2504 } |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2505 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2506 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2507 gtk_imhtml_insert_html_at_iter(imhtml, text, options, &iter); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2508 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2509 if (fixins) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2510 gtk_text_buffer_get_iter_at_offset(imhtml->text_buffer, &ins, ins_offset); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2511 gtk_text_buffer_move_mark(imhtml->text_buffer, gtk_text_buffer_get_insert(imhtml->text_buffer), &ins); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2512 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2513 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2514 if (fixsel) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2515 gtk_text_buffer_get_iter_at_offset(imhtml->text_buffer, &sel, sel_offset); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2516 gtk_text_buffer_move_mark(imhtml->text_buffer, gtk_text_buffer_get_selection_bound(imhtml->text_buffer), &sel); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2517 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2518 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2519 if (!(options & GTK_IMHTML_NO_SCROLL)) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2520 gtk_imhtml_scroll_to_end(imhtml, (options & GTK_IMHTML_USE_SMOOTHSCROLLING)); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2521 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2522 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2523 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2524 #define MAX_SCROLL_TIME 0.4 /* seconds */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2525 #define SCROLL_DELAY 33 /* milliseconds */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2526 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2527 /* |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2528 * Smoothly scroll a GtkIMHtml. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2529 * |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2530 * @return TRUE if the window needs to be scrolled further, FALSE if we're at the bottom. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2531 */ |
28987
ed0c4defd3dd
Fix scrolling bug for very busy chat rooms.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
28982
diff
changeset
|
2532 static gboolean smooth_scroll_cb(gpointer data) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2533 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2534 GtkIMHtml *imhtml = data; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2535 GtkAdjustment *adj = GTK_TEXT_VIEW(imhtml)->vadjustment; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2536 gdouble max_val = adj->upper - adj->page_size; |
18760
bf47d0401a96
Eliminate some unnecessary scrolling activity.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
18736
diff
changeset
|
2537 gdouble scroll_val = gtk_adjustment_get_value(adj) + ((max_val - gtk_adjustment_get_value(adj)) / 3); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2538 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2539 g_return_val_if_fail(imhtml->scroll_time != NULL, FALSE); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2540 |
18760
bf47d0401a96
Eliminate some unnecessary scrolling activity.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
18736
diff
changeset
|
2541 if (g_timer_elapsed(imhtml->scroll_time, NULL) > MAX_SCROLL_TIME || scroll_val >= max_val) { |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2542 /* time's up. jump to the end and kill the timer */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2543 gtk_adjustment_set_value(adj, max_val); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2544 g_timer_destroy(imhtml->scroll_time); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2545 imhtml->scroll_time = NULL; |
28987
ed0c4defd3dd
Fix scrolling bug for very busy chat rooms.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
28982
diff
changeset
|
2546 g_source_remove(imhtml->scroll_src); |
ed0c4defd3dd
Fix scrolling bug for very busy chat rooms.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
28982
diff
changeset
|
2547 imhtml->scroll_src = 0; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2548 return FALSE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2549 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2550 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2551 /* scroll by 1/3rd the remaining distance */ |
18760
bf47d0401a96
Eliminate some unnecessary scrolling activity.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
18736
diff
changeset
|
2552 gtk_adjustment_set_value(adj, scroll_val); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2553 return TRUE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2554 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2555 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2556 static gboolean scroll_idle_cb(gpointer data) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2557 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2558 GtkIMHtml *imhtml = data; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2559 GtkAdjustment *adj = GTK_TEXT_VIEW(imhtml)->vadjustment; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2560 if(adj) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2561 gtk_adjustment_set_value(adj, adj->upper - adj->page_size); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2562 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2563 imhtml->scroll_src = 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2564 return FALSE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2565 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2566 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2567 void gtk_imhtml_scroll_to_end(GtkIMHtml *imhtml, gboolean smooth) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2568 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2569 if (imhtml->scroll_time) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2570 g_timer_destroy(imhtml->scroll_time); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2571 if (imhtml->scroll_src) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2572 g_source_remove(imhtml->scroll_src); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2573 if(smooth) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2574 imhtml->scroll_time = g_timer_new(); |
28987
ed0c4defd3dd
Fix scrolling bug for very busy chat rooms.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
28982
diff
changeset
|
2575 imhtml->scroll_src = g_timeout_add_full(G_PRIORITY_LOW, SCROLL_DELAY, smooth_scroll_cb, imhtml, NULL); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2576 } else { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2577 imhtml->scroll_time = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2578 imhtml->scroll_src = g_idle_add_full(G_PRIORITY_LOW, scroll_idle_cb, imhtml, NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2579 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2580 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2581 |
24232
15c30a63f124
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24115
diff
changeset
|
2582 /* CSS colors are either rgb (x,y,z) or #hex |
15c30a63f124
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24115
diff
changeset
|
2583 * we need to convert to hex if it is RGB */ |
15c30a63f124
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24115
diff
changeset
|
2584 static gchar* |
15c30a63f124
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24115
diff
changeset
|
2585 parse_css_color(gchar *in_color) |
15c30a63f124
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24115
diff
changeset
|
2586 { |
15c30a63f124
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24115
diff
changeset
|
2587 char *tmp = in_color; |
15c30a63f124
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24115
diff
changeset
|
2588 |
24233
e0cfdf4a5a38
Make the CSS rgb() color parsing more robust. khc noted that it wouldn't work
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24232
diff
changeset
|
2589 if (*tmp == 'r' && *(++tmp) == 'g' && *(++tmp) == 'b' && *(++tmp)) { |
24232
15c30a63f124
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24115
diff
changeset
|
2590 int rgbval[] = {0, 0, 0}; |
15c30a63f124
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24115
diff
changeset
|
2591 int count = 0; |
15c30a63f124
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24115
diff
changeset
|
2592 const char *v_start; |
15c30a63f124
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24115
diff
changeset
|
2593 |
24233
e0cfdf4a5a38
Make the CSS rgb() color parsing more robust. khc noted that it wouldn't work
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24232
diff
changeset
|
2594 while (*tmp && g_ascii_isspace(*tmp)) |
e0cfdf4a5a38
Make the CSS rgb() color parsing more robust. khc noted that it wouldn't work
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24232
diff
changeset
|
2595 tmp++; |
e0cfdf4a5a38
Make the CSS rgb() color parsing more robust. khc noted that it wouldn't work
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24232
diff
changeset
|
2596 if (*tmp != '(') { |
e0cfdf4a5a38
Make the CSS rgb() color parsing more robust. khc noted that it wouldn't work
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24232
diff
changeset
|
2597 /* We don't support rgba() */ |
e0cfdf4a5a38
Make the CSS rgb() color parsing more robust. khc noted that it wouldn't work
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24232
diff
changeset
|
2598 purple_debug_warning("gtkimhtml", "Invalid rgb CSS color in '%s'!\n", in_color); |
e0cfdf4a5a38
Make the CSS rgb() color parsing more robust. khc noted that it wouldn't work
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24232
diff
changeset
|
2599 return in_color; |
e0cfdf4a5a38
Make the CSS rgb() color parsing more robust. khc noted that it wouldn't work
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24232
diff
changeset
|
2600 } |
e0cfdf4a5a38
Make the CSS rgb() color parsing more robust. khc noted that it wouldn't work
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24232
diff
changeset
|
2601 tmp++; |
e0cfdf4a5a38
Make the CSS rgb() color parsing more robust. khc noted that it wouldn't work
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24232
diff
changeset
|
2602 |
24232
15c30a63f124
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24115
diff
changeset
|
2603 while (count < 3) { |
15c30a63f124
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24115
diff
changeset
|
2604 /* Skip any leading spaces */ |
15c30a63f124
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24115
diff
changeset
|
2605 while (*tmp && g_ascii_isspace(*tmp)) |
15c30a63f124
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24115
diff
changeset
|
2606 tmp++; |
15c30a63f124
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24115
diff
changeset
|
2607 |
15c30a63f124
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24115
diff
changeset
|
2608 /* Find the subsequent contiguous digits */ |
15c30a63f124
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24115
diff
changeset
|
2609 v_start = tmp; |
24233
e0cfdf4a5a38
Make the CSS rgb() color parsing more robust. khc noted that it wouldn't work
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24232
diff
changeset
|
2610 if (*v_start == '-') |
e0cfdf4a5a38
Make the CSS rgb() color parsing more robust. khc noted that it wouldn't work
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24232
diff
changeset
|
2611 tmp++; |
24232
15c30a63f124
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24115
diff
changeset
|
2612 while (*tmp && g_ascii_isdigit(*tmp)) |
15c30a63f124
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24115
diff
changeset
|
2613 tmp++; |
15c30a63f124
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24115
diff
changeset
|
2614 |
15c30a63f124
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24115
diff
changeset
|
2615 if (tmp != v_start) { |
15c30a63f124
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24115
diff
changeset
|
2616 char prev = *tmp; |
15c30a63f124
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24115
diff
changeset
|
2617 *tmp = '\0'; |
15c30a63f124
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24115
diff
changeset
|
2618 rgbval[count] = atoi(v_start); |
15c30a63f124
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24115
diff
changeset
|
2619 *tmp = prev; |
15c30a63f124
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24115
diff
changeset
|
2620 |
15c30a63f124
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24115
diff
changeset
|
2621 /* deal with % */ |
15c30a63f124
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24115
diff
changeset
|
2622 while (*tmp && g_ascii_isspace(*tmp)) |
15c30a63f124
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24115
diff
changeset
|
2623 tmp++; |
15c30a63f124
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24115
diff
changeset
|
2624 if (*tmp == '%') { |
15c30a63f124
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24115
diff
changeset
|
2625 rgbval[count] = (rgbval[count] / 100.0) * 255; |
15c30a63f124
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24115
diff
changeset
|
2626 tmp++; |
15c30a63f124
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24115
diff
changeset
|
2627 } |
15c30a63f124
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24115
diff
changeset
|
2628 } else { |
15c30a63f124
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24115
diff
changeset
|
2629 purple_debug_warning("gtkimhtml", "Invalid rgb CSS color in '%s'!\n", in_color); |
15c30a63f124
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24115
diff
changeset
|
2630 return in_color; |
15c30a63f124
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24115
diff
changeset
|
2631 } |
15c30a63f124
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24115
diff
changeset
|
2632 |
15c30a63f124
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24115
diff
changeset
|
2633 if (rgbval[count] > 255) { |
15c30a63f124
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24115
diff
changeset
|
2634 rgbval[count] = 255; |
15c30a63f124
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24115
diff
changeset
|
2635 } else if (rgbval[count] < 0) { |
15c30a63f124
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24115
diff
changeset
|
2636 rgbval[count] = 0; |
15c30a63f124
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24115
diff
changeset
|
2637 } |
15c30a63f124
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24115
diff
changeset
|
2638 |
15c30a63f124
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24115
diff
changeset
|
2639 while (*tmp && g_ascii_isspace(*tmp)) |
15c30a63f124
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24115
diff
changeset
|
2640 tmp++; |
15c30a63f124
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24115
diff
changeset
|
2641 if (*tmp == ',') |
15c30a63f124
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24115
diff
changeset
|
2642 tmp++; |
15c30a63f124
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24115
diff
changeset
|
2643 |
15c30a63f124
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24115
diff
changeset
|
2644 count++; |
15c30a63f124
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24115
diff
changeset
|
2645 } |
25415
584063555949
Remove trailing whitespace
Mark Doliner <mark@kingant.net>
parents:
25381
diff
changeset
|
2646 |
24232
15c30a63f124
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24115
diff
changeset
|
2647 g_free(in_color); |
15c30a63f124
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24115
diff
changeset
|
2648 return g_strdup_printf("#%02X%02X%02X", rgbval[0], rgbval[1], rgbval[2]); |
15c30a63f124
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24115
diff
changeset
|
2649 } |
15c30a63f124
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24115
diff
changeset
|
2650 |
15c30a63f124
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24115
diff
changeset
|
2651 return in_color; |
15c30a63f124
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24115
diff
changeset
|
2652 } |
15c30a63f124
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24115
diff
changeset
|
2653 |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2654 void gtk_imhtml_insert_html_at_iter(GtkIMHtml *imhtml, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2655 const gchar *text, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2656 GtkIMHtmlOptions options, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2657 GtkTextIter *iter) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2658 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2659 GdkRectangle rect; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2660 gint pos = 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2661 gchar *ws; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2662 gchar *tag; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2663 gchar *bg = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2664 gint len; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2665 gint tlen, smilelen, wpos=0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2666 gint type; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2667 const gchar *c; |
16083
f2a4b05407d7
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15871
diff
changeset
|
2668 const gchar *amp; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2669 gint len_protocol; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2670 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2671 guint bold = 0, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2672 italics = 0, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2673 underline = 0, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2674 strike = 0, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2675 sub = 0, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2676 sup = 0, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2677 title = 0, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2678 pre = 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2679 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2680 gboolean br = FALSE; |
16083
f2a4b05407d7
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15871
diff
changeset
|
2681 gboolean align_right = FALSE; |
f2a4b05407d7
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15871
diff
changeset
|
2682 gboolean rtl_direction = FALSE; |
f2a4b05407d7
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15871
diff
changeset
|
2683 gint align_line = 0; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2684 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2685 GSList *fonts = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2686 GObject *object; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2687 GtkIMHtmlScalable *scalable = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2688 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2689 g_return_if_fail (imhtml != NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2690 g_return_if_fail (GTK_IS_IMHTML (imhtml)); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2691 g_return_if_fail (text != NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2692 c = text; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2693 len = strlen(text); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2694 ws = g_malloc(len + 1); |
25351
5dedfe149cb3
Pass only the URL scheme to gtkimhtml and let it add the colon automatically.
Richard Laager <rlaager@wiktel.com>
parents:
24548
diff
changeset
|
2695 ws[0] = '\0'; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2696 |
29468
89b4054deba1
Fix CVE-2010-0423, a denial of service attack due to the parsing
Mark Doliner <mark@kingant.net>
parents:
29440
diff
changeset
|
2697 g_object_set_data(G_OBJECT(imhtml), "gtkimhtml_numsmileys_thismsg", GINT_TO_POINTER(0)); |
89b4054deba1
Fix CVE-2010-0423, a denial of service attack due to the parsing
Mark Doliner <mark@kingant.net>
parents:
29440
diff
changeset
|
2698 |
22674
27c9c55499f8
Smiley insertions can be undone with this fix. References #5577. But redo
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22650
diff
changeset
|
2699 gtk_text_buffer_begin_user_action(imhtml->text_buffer); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2700 while (pos < len) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2701 if (*c == '<' && gtk_imhtml_is_tag (c + 1, &tag, &tlen, &type)) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2702 c++; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2703 pos++; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2704 ws[wpos] = '\0'; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2705 br = FALSE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2706 switch (type) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2707 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2708 case 1: /* B */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2709 case 2: /* BOLD */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2710 case 54: /* STRONG */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2711 if (!(options & GTK_IMHTML_NO_FORMATTING)) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2712 gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2713 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2714 if ((bold == 0) && (imhtml->format_functions & GTK_IMHTML_BOLD)) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2715 gtk_imhtml_toggle_bold(imhtml); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2716 bold++; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2717 ws[0] = '\0'; wpos = 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2718 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2719 break; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2720 case 3: /* /B */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2721 case 4: /* /BOLD */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2722 case 55: /* /STRONG */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2723 if (!(options & GTK_IMHTML_NO_FORMATTING)) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2724 gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2725 ws[0] = '\0'; wpos = 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2726 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2727 if (bold) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2728 bold--; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2729 if ((bold == 0) && (imhtml->format_functions & GTK_IMHTML_BOLD) && !imhtml->wbfo) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2730 gtk_imhtml_toggle_bold(imhtml); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2731 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2732 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2733 break; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2734 case 5: /* I */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2735 case 6: /* ITALIC */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2736 case 52: /* EM */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2737 if (!(options & GTK_IMHTML_NO_FORMATTING)) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2738 gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2739 ws[0] = '\0'; wpos = 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2740 if ((italics == 0) && (imhtml->format_functions & GTK_IMHTML_ITALIC)) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2741 gtk_imhtml_toggle_italic(imhtml); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2742 italics++; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2743 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2744 break; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2745 case 7: /* /I */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2746 case 8: /* /ITALIC */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2747 case 53: /* /EM */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2748 if (!(options & GTK_IMHTML_NO_FORMATTING)) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2749 gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2750 ws[0] = '\0'; wpos = 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2751 if (italics) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2752 italics--; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2753 if ((italics == 0) && (imhtml->format_functions & GTK_IMHTML_ITALIC) && !imhtml->wbfo) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2754 gtk_imhtml_toggle_italic(imhtml); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2755 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2756 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2757 break; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2758 case 9: /* U */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2759 case 10: /* UNDERLINE */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2760 if (!(options & GTK_IMHTML_NO_FORMATTING)) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2761 gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2762 ws[0] = '\0'; wpos = 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2763 if ((underline == 0) && (imhtml->format_functions & GTK_IMHTML_UNDERLINE)) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2764 gtk_imhtml_toggle_underline(imhtml); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2765 underline++; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2766 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2767 break; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2768 case 11: /* /U */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2769 case 12: /* /UNDERLINE */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2770 if (!(options & GTK_IMHTML_NO_FORMATTING)) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2771 gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2772 ws[0] = '\0'; wpos = 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2773 if (underline) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2774 underline--; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2775 if ((underline == 0) && (imhtml->format_functions & GTK_IMHTML_UNDERLINE) && !imhtml->wbfo) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2776 gtk_imhtml_toggle_underline(imhtml); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2777 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2778 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2779 break; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2780 case 13: /* S */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2781 case 14: /* STRIKE */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2782 gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2783 ws[0] = '\0'; wpos = 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2784 if ((strike == 0) && (imhtml->format_functions & GTK_IMHTML_STRIKE)) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2785 gtk_imhtml_toggle_strike(imhtml); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2786 strike++; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2787 break; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2788 case 15: /* /S */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2789 case 16: /* /STRIKE */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2790 gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2791 ws[0] = '\0'; wpos = 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2792 if (strike) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2793 strike--; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2794 if ((strike == 0) && (imhtml->format_functions & GTK_IMHTML_STRIKE) && !imhtml->wbfo) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2795 gtk_imhtml_toggle_strike(imhtml); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2796 break; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2797 case 17: /* SUB */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2798 /* FIXME: reimpliment this */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2799 sub++; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2800 break; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2801 case 18: /* /SUB */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2802 /* FIXME: reimpliment this */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2803 if (sub) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2804 sub--; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2805 break; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2806 case 19: /* SUP */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2807 /* FIXME: reimplement this */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2808 sup++; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2809 break; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2810 case 20: /* /SUP */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2811 /* FIXME: reimplement this */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2812 if (sup) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2813 sup--; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2814 break; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2815 case 21: /* PRE */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2816 /* FIXME: reimplement this */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2817 pre++; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2818 break; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2819 case 22: /* /PRE */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2820 /* FIXME: reimplement this */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2821 if (pre) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2822 pre--; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2823 break; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2824 case 23: /* TITLE */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2825 /* FIXME: what was this supposed to do anyway? */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2826 title++; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2827 break; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2828 case 24: /* /TITLE */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2829 /* FIXME: make this undo whatever 23 was supposed to do */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2830 if (title) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2831 if (options & GTK_IMHTML_NO_TITLE) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2832 wpos = 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2833 ws [wpos] = '\0'; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2834 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2835 title--; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2836 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2837 break; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2838 case 25: /* BR */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2839 case 58: /* BR/ */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2840 case 61: /* BR (opt) */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2841 ws[wpos] = '\n'; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2842 wpos++; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2843 br = TRUE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2844 break; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2845 case 26: /* HR */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2846 case 42: /* HR (opt) */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2847 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2848 int minus; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2849 struct scalable_data *sd = g_new(struct scalable_data, 1); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2850 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2851 ws[wpos++] = '\n'; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2852 gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2853 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2854 sd->scalable = scalable = gtk_imhtml_hr_new(); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2855 sd->mark = gtk_text_buffer_create_mark(imhtml->text_buffer, NULL, iter, TRUE); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2856 gtk_text_view_get_visible_rect(GTK_TEXT_VIEW(imhtml), &rect); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2857 scalable->add_to(scalable, imhtml, iter); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2858 minus = gtk_text_view_get_left_margin(GTK_TEXT_VIEW(imhtml)) + |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2859 gtk_text_view_get_right_margin(GTK_TEXT_VIEW(imhtml)); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2860 scalable->scale(scalable, rect.width - minus, rect.height); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2861 imhtml->scalables = g_list_append(imhtml->scalables, sd); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2862 ws[0] = '\0'; wpos = 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2863 ws[wpos++] = '\n'; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2864 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2865 break; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2866 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2867 case 27: /* /FONT */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2868 if (fonts && !imhtml->wbfo) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2869 GtkIMHtmlFontDetail *font = fonts->data; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2870 gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2871 ws[0] = '\0'; wpos = 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2872 /* NEW_BIT (NEW_TEXT_BIT); */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2873 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2874 if (font->face && (imhtml->format_functions & GTK_IMHTML_FACE)) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2875 gtk_imhtml_toggle_fontface(imhtml, NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2876 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2877 g_free (font->face); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2878 if (font->fore && (imhtml->format_functions & GTK_IMHTML_FORECOLOR)) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2879 gtk_imhtml_toggle_forecolor(imhtml, NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2880 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2881 g_free (font->fore); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2882 if (font->back && (imhtml->format_functions & GTK_IMHTML_BACKCOLOR)) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2883 gtk_imhtml_toggle_backcolor(imhtml, NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2884 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2885 g_free (font->back); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2886 g_free (font->sml); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2887 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2888 if ((font->size != 3) && (imhtml->format_functions & (GTK_IMHTML_GROW|GTK_IMHTML_SHRINK))) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2889 gtk_imhtml_font_set_size(imhtml, 3); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2890 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2891 fonts = g_slist_remove (fonts, font); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2892 g_free(font); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2893 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2894 if (fonts) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2895 GtkIMHtmlFontDetail *font = fonts->data; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2896 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2897 if (font->face && (imhtml->format_functions & GTK_IMHTML_FACE)) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2898 gtk_imhtml_toggle_fontface(imhtml, font->face); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2899 if (font->fore && (imhtml->format_functions & GTK_IMHTML_FORECOLOR)) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2900 gtk_imhtml_toggle_forecolor(imhtml, font->fore); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2901 if (font->back && (imhtml->format_functions & GTK_IMHTML_BACKCOLOR)) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2902 gtk_imhtml_toggle_backcolor(imhtml, font->back); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2903 if ((font->size != 3) && (imhtml->format_functions & (GTK_IMHTML_GROW|GTK_IMHTML_SHRINK))) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2904 gtk_imhtml_font_set_size(imhtml, font->size); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2905 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2906 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2907 break; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2908 case 28: /* /A */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2909 gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2910 gtk_imhtml_toggle_link(imhtml, NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2911 ws[0] = '\0'; wpos = 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2912 break; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2913 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2914 case 29: /* P */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2915 case 30: /* /P */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2916 case 31: /* H3 */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2917 case 32: /* /H3 */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2918 case 33: /* HTML */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2919 case 34: /* /HTML */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2920 case 35: /* BODY */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2921 break; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2922 case 36: /* /BODY */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2923 gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2924 ws[0] = '\0'; wpos = 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2925 gtk_imhtml_toggle_background(imhtml, NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2926 break; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2927 case 37: /* FONT */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2928 case 38: /* HEAD */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2929 case 39: /* /HEAD */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2930 case 40: /* BINARY */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2931 case 41: /* /BINARY */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2932 break; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2933 case 43: /* FONT (opt) */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2934 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2935 gchar *color, *back, *face, *size, *sml; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2936 GtkIMHtmlFontDetail *font, *oldfont = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2937 color = gtk_imhtml_get_html_opt (tag, "COLOR="); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2938 back = gtk_imhtml_get_html_opt (tag, "BACK="); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2939 face = gtk_imhtml_get_html_opt (tag, "FACE="); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2940 size = gtk_imhtml_get_html_opt (tag, "SIZE="); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2941 sml = gtk_imhtml_get_html_opt (tag, "SML="); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2942 if (!(color || back || face || size || sml)) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2943 break; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2944 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2945 gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2946 ws[0] = '\0'; wpos = 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2947 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2948 font = g_new0 (GtkIMHtmlFontDetail, 1); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2949 if (fonts) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2950 oldfont = fonts->data; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2951 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2952 if (color && !(options & GTK_IMHTML_NO_COLOURS) && (imhtml->format_functions & GTK_IMHTML_FORECOLOR)) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2953 font->fore = color; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2954 gtk_imhtml_toggle_forecolor(imhtml, font->fore); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2955 } else |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2956 g_free(color); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2957 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2958 if (back && !(options & GTK_IMHTML_NO_COLOURS) && (imhtml->format_functions & GTK_IMHTML_BACKCOLOR)) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2959 font->back = back; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2960 gtk_imhtml_toggle_backcolor(imhtml, font->back); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2961 } else |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2962 g_free(back); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2963 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2964 if (face && !(options & GTK_IMHTML_NO_FONTS) && (imhtml->format_functions & GTK_IMHTML_FACE)) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2965 font->face = face; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2966 gtk_imhtml_toggle_fontface(imhtml, font->face); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2967 } else |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2968 g_free(face); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2969 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2970 if (sml) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2971 font->sml = sml; |
22650
6827600df4fc
Patch from Gaul to plug a small leak, with an additional fix to free
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22643
diff
changeset
|
2972 else { |
6827600df4fc
Patch from Gaul to plug a small leak, with an additional fix to free
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22643
diff
changeset
|
2973 g_free(sml); |
6827600df4fc
Patch from Gaul to plug a small leak, with an additional fix to free
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22643
diff
changeset
|
2974 if (oldfont && oldfont->sml) |
6827600df4fc
Patch from Gaul to plug a small leak, with an additional fix to free
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22643
diff
changeset
|
2975 font->sml = g_strdup(oldfont->sml); |
6827600df4fc
Patch from Gaul to plug a small leak, with an additional fix to free
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22643
diff
changeset
|
2976 } |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2977 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2978 if (size && !(options & GTK_IMHTML_NO_SIZES) && (imhtml->format_functions & (GTK_IMHTML_GROW|GTK_IMHTML_SHRINK))) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2979 if (*size == '+') { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2980 sscanf (size + 1, "%hd", &font->size); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2981 font->size += 3; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2982 } else if (*size == '-') { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2983 sscanf (size + 1, "%hd", &font->size); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2984 font->size = MAX (0, 3 - font->size); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2985 } else if (isdigit (*size)) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2986 sscanf (size, "%hd", &font->size); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2987 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2988 if (font->size > 100) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2989 font->size = 100; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2990 } else if (oldfont) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2991 font->size = oldfont->size; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2992 else |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2993 font->size = 3; |
28209
f27425877d29
imhtml: When inserting html, only set a font if it's a change from the default. Fixes #7648.
Paul Aurich <paul@darkrain42.org>
parents:
28138
diff
changeset
|
2994 if ((imhtml->format_functions & (GTK_IMHTML_GROW|GTK_IMHTML_SHRINK)) && (font->size != 3 || (oldfont && oldfont->size == 3))) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2995 gtk_imhtml_font_set_size(imhtml, font->size); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2996 g_free(size); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2997 fonts = g_slist_prepend (fonts, font); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2998 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
2999 break; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3000 case 44: /* BODY (opt) */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3001 if (!(options & GTK_IMHTML_NO_COLOURS)) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3002 char *bgcolor = gtk_imhtml_get_html_opt (tag, "BGCOLOR="); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3003 if (bgcolor && (imhtml->format_functions & GTK_IMHTML_BACKCOLOR)) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3004 gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3005 ws[0] = '\0'; wpos = 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3006 /* NEW_BIT(NEW_TEXT_BIT); */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3007 g_free(bg); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3008 bg = bgcolor; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3009 gtk_imhtml_toggle_background(imhtml, bg); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3010 } else |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3011 g_free(bgcolor); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3012 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3013 break; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3014 case 45: /* A (opt) */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3015 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3016 gchar *href = gtk_imhtml_get_html_opt (tag, "HREF="); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3017 if (href && (imhtml->format_functions & GTK_IMHTML_LINK)) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3018 gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3019 ws[0] = '\0'; wpos = 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3020 gtk_imhtml_toggle_link(imhtml, href); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3021 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3022 g_free(href); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3023 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3024 break; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3025 case 46: /* IMG (opt) */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3026 case 59: /* IMG */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3027 { |
22650
6827600df4fc
Patch from Gaul to plug a small leak, with an additional fix to free
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22643
diff
changeset
|
3028 char *id; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3029 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3030 gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3031 ws[0] = '\0'; wpos = 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3032 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3033 if (!(imhtml->format_functions & GTK_IMHTML_IMAGE)) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3034 break; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3035 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3036 id = gtk_imhtml_get_html_opt(tag, "ID="); |
27217
54de7746e148
Transform id-less <img> tags to links using src and alt attributes.
dmitry.petroff@gmail.com
parents:
27120
diff
changeset
|
3037 if (id) { |
54de7746e148
Transform id-less <img> tags to links using src and alt attributes.
dmitry.petroff@gmail.com
parents:
27120
diff
changeset
|
3038 gtk_imhtml_insert_image_at_iter(imhtml, atoi(id), iter); |
54de7746e148
Transform id-less <img> tags to links using src and alt attributes.
dmitry.petroff@gmail.com
parents:
27120
diff
changeset
|
3039 g_free(id); |
54de7746e148
Transform id-less <img> tags to links using src and alt attributes.
dmitry.petroff@gmail.com
parents:
27120
diff
changeset
|
3040 } else { |
54de7746e148
Transform id-less <img> tags to links using src and alt attributes.
dmitry.petroff@gmail.com
parents:
27120
diff
changeset
|
3041 char *src, *alt; |
54de7746e148
Transform id-less <img> tags to links using src and alt attributes.
dmitry.petroff@gmail.com
parents:
27120
diff
changeset
|
3042 src = gtk_imhtml_get_html_opt(tag, "SRC="); |
54de7746e148
Transform id-less <img> tags to links using src and alt attributes.
dmitry.petroff@gmail.com
parents:
27120
diff
changeset
|
3043 alt = gtk_imhtml_get_html_opt(tag, "ALT="); |
54de7746e148
Transform id-less <img> tags to links using src and alt attributes.
dmitry.petroff@gmail.com
parents:
27120
diff
changeset
|
3044 if (src) { |
54de7746e148
Transform id-less <img> tags to links using src and alt attributes.
dmitry.petroff@gmail.com
parents:
27120
diff
changeset
|
3045 gtk_imhtml_toggle_link(imhtml, src); |
54de7746e148
Transform id-less <img> tags to links using src and alt attributes.
dmitry.petroff@gmail.com
parents:
27120
diff
changeset
|
3046 gtk_text_buffer_insert(imhtml->text_buffer, iter, alt ? alt : src, -1); |
54de7746e148
Transform id-less <img> tags to links using src and alt attributes.
dmitry.petroff@gmail.com
parents:
27120
diff
changeset
|
3047 gtk_imhtml_toggle_link(imhtml, NULL); |
54de7746e148
Transform id-less <img> tags to links using src and alt attributes.
dmitry.petroff@gmail.com
parents:
27120
diff
changeset
|
3048 } |
54de7746e148
Transform id-less <img> tags to links using src and alt attributes.
dmitry.petroff@gmail.com
parents:
27120
diff
changeset
|
3049 g_free (src); |
54de7746e148
Transform id-less <img> tags to links using src and alt attributes.
dmitry.petroff@gmail.com
parents:
27120
diff
changeset
|
3050 g_free (alt); |
54de7746e148
Transform id-less <img> tags to links using src and alt attributes.
dmitry.petroff@gmail.com
parents:
27120
diff
changeset
|
3051 } |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3052 break; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3053 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3054 case 47: /* P (opt) */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3055 case 48: /* H3 (opt) */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3056 case 49: /* HTML (opt) */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3057 case 50: /* CITE */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3058 case 51: /* /CITE */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3059 case 56: /* SPAN (opt) */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3060 /* Inline CSS Support - Douglas Thrift |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3061 * |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3062 * color |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3063 * background |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3064 * font-family |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3065 * font-size |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3066 * text-decoration: underline |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3067 * font-weight: bold |
16083
f2a4b05407d7
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15871
diff
changeset
|
3068 * direction: rtl |
f2a4b05407d7
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15871
diff
changeset
|
3069 * text-align: right |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3070 * |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3071 * TODO: |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3072 * background-color |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3073 * font-style |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3074 */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3075 { |
16083
f2a4b05407d7
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15871
diff
changeset
|
3076 gchar *style, *color, *background, *family, *size, *direction, *alignment; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3077 gchar *textdec, *weight; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3078 GtkIMHtmlFontDetail *font, *oldfont = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3079 style = gtk_imhtml_get_html_opt (tag, "style="); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3080 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3081 if (!style) break; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3082 |
16083
f2a4b05407d7
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15871
diff
changeset
|
3083 color = purple_markup_get_css_property (style, "color"); |
f2a4b05407d7
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15871
diff
changeset
|
3084 background = purple_markup_get_css_property (style, "background"); |
f2a4b05407d7
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15871
diff
changeset
|
3085 family = purple_markup_get_css_property (style, "font-family"); |
f2a4b05407d7
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15871
diff
changeset
|
3086 size = purple_markup_get_css_property (style, "font-size"); |
f2a4b05407d7
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15871
diff
changeset
|
3087 textdec = purple_markup_get_css_property (style, "text-decoration"); |
f2a4b05407d7
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15871
diff
changeset
|
3088 weight = purple_markup_get_css_property (style, "font-weight"); |
f2a4b05407d7
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15871
diff
changeset
|
3089 direction = purple_markup_get_css_property (style, "direction"); |
f2a4b05407d7
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15871
diff
changeset
|
3090 alignment = purple_markup_get_css_property (style, "text-align"); |
f2a4b05407d7
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15871
diff
changeset
|
3091 |
f2a4b05407d7
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15871
diff
changeset
|
3092 |
f2a4b05407d7
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15871
diff
changeset
|
3093 if (!(color || family || size || background || textdec || weight || direction || alignment)) { |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3094 g_free(style); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3095 break; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3096 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3097 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3098 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3099 gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3100 ws[0] = '\0'; wpos = 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3101 /* NEW_BIT (NEW_TEXT_BIT); */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3102 |
16083
f2a4b05407d7
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15871
diff
changeset
|
3103 /* Bi-Directional text support */ |
18398
16bdcffb1c62
Use the glib strcasecmp functions everywhere, as we've had reports of
Richard Laager <rlaager@wiktel.com>
parents:
18392
diff
changeset
|
3104 if (direction && (!g_ascii_strncasecmp(direction, "RTL", 3))) { |
16083
f2a4b05407d7
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15871
diff
changeset
|
3105 rtl_direction = TRUE; |
f2a4b05407d7
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15871
diff
changeset
|
3106 /* insert RLE character to set direction */ |
f2a4b05407d7
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15871
diff
changeset
|
3107 ws[wpos++] = 0xE2; |
f2a4b05407d7
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15871
diff
changeset
|
3108 ws[wpos++] = 0x80; |
f2a4b05407d7
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15871
diff
changeset
|
3109 ws[wpos++] = 0xAB; |
f2a4b05407d7
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15871
diff
changeset
|
3110 ws[wpos] = '\0'; |
f2a4b05407d7
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15871
diff
changeset
|
3111 gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos); |
f2a4b05407d7
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15871
diff
changeset
|
3112 ws[0] = '\0'; wpos = 0; |
f2a4b05407d7
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15871
diff
changeset
|
3113 } |
16084 | 3114 g_free(direction); |
3115 | |
18398
16bdcffb1c62
Use the glib strcasecmp functions everywhere, as we've had reports of
Richard Laager <rlaager@wiktel.com>
parents:
18392
diff
changeset
|
3116 if (alignment && (!g_ascii_strncasecmp(alignment, "RIGHT", 5))) { |
16083
f2a4b05407d7
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15871
diff
changeset
|
3117 align_right = TRUE; |
f2a4b05407d7
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15871
diff
changeset
|
3118 align_line = gtk_text_iter_get_line(iter); |
f2a4b05407d7
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15871
diff
changeset
|
3119 } |
16084 | 3120 g_free(alignment); |
16083
f2a4b05407d7
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15871
diff
changeset
|
3121 |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3122 font = g_new0 (GtkIMHtmlFontDetail, 1); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3123 if (fonts) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3124 oldfont = fonts->data; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3125 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3126 if (color && !(options & GTK_IMHTML_NO_COLOURS) && (imhtml->format_functions & GTK_IMHTML_FORECOLOR)) { |
24232
15c30a63f124
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24115
diff
changeset
|
3127 font->fore = parse_css_color(color); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3128 gtk_imhtml_toggle_forecolor(imhtml, font->fore); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3129 } else { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3130 if (oldfont && oldfont->fore) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3131 font->fore = g_strdup(oldfont->fore); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3132 g_free(color); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3133 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3134 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3135 if (background && !(options & GTK_IMHTML_NO_COLOURS) && (imhtml->format_functions & GTK_IMHTML_BACKCOLOR)) { |
24232
15c30a63f124
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
24115
diff
changeset
|
3136 font->back = parse_css_color(background); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3137 gtk_imhtml_toggle_backcolor(imhtml, font->back); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3138 } else { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3139 if (oldfont && oldfont->back) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3140 font->back = g_strdup(oldfont->back); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3141 g_free(background); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3142 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3143 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3144 if (family && !(options & GTK_IMHTML_NO_FONTS) && (imhtml->format_functions & GTK_IMHTML_FACE)) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3145 font->face = family; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3146 gtk_imhtml_toggle_fontface(imhtml, font->face); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3147 } else { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3148 if (oldfont && oldfont->face) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3149 font->face = g_strdup(oldfont->face); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3150 g_free(family); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3151 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3152 if (font->face && (atoi(font->face) > 100)) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3153 /* WTF is this? */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3154 /* Maybe it sets a max size on the font face? I seem to |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3155 * remember bad things happening if the font size was |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3156 * 2 billion */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3157 g_free(font->face); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3158 font->face = g_strdup("100"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3159 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3160 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3161 if (oldfont && oldfont->sml) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3162 font->sml = g_strdup(oldfont->sml); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3163 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3164 if (size && !(options & GTK_IMHTML_NO_SIZES) && (imhtml->format_functions & (GTK_IMHTML_SHRINK|GTK_IMHTML_GROW))) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3165 if (g_ascii_strcasecmp(size, "xx-small") == 0) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3166 font->size = 1; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3167 else if (g_ascii_strcasecmp(size, "smaller") == 0 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3168 || g_ascii_strcasecmp(size, "x-small") == 0) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3169 font->size = 2; |
24829
01bd85f65fa1
Change our font mapping in gtkimhtml to match the suggested values
Mark Doliner <mark@kingant.net>
parents:
24688
diff
changeset
|
3170 else if (g_ascii_strcasecmp(size, "medium") == 0) |
01bd85f65fa1
Change our font mapping in gtkimhtml to match the suggested values
Mark Doliner <mark@kingant.net>
parents:
24688
diff
changeset
|
3171 font->size = 3; |
01bd85f65fa1
Change our font mapping in gtkimhtml to match the suggested values
Mark Doliner <mark@kingant.net>
parents:
24688
diff
changeset
|
3172 else if (g_ascii_strcasecmp(size, "large") == 0 |
01bd85f65fa1
Change our font mapping in gtkimhtml to match the suggested values
Mark Doliner <mark@kingant.net>
parents:
24688
diff
changeset
|
3173 || g_ascii_strcasecmp(size, "larger") == 0) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3174 font->size = 4; |
24829
01bd85f65fa1
Change our font mapping in gtkimhtml to match the suggested values
Mark Doliner <mark@kingant.net>
parents:
24688
diff
changeset
|
3175 else if (g_ascii_strcasecmp(size, "x-large") == 0) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3176 font->size = 5; |
24829
01bd85f65fa1
Change our font mapping in gtkimhtml to match the suggested values
Mark Doliner <mark@kingant.net>
parents:
24688
diff
changeset
|
3177 else if (g_ascii_strcasecmp(size, "xx-large") == 0) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3178 font->size = 6; |
24688
dce57ce0b860
Change the way we handle <span style='font-size: whatever;'> tags slightly.
Mark Doliner <mark@kingant.net>
parents:
24311
diff
changeset
|
3179 |
dce57ce0b860
Change the way we handle <span style='font-size: whatever;'> tags slightly.
Mark Doliner <mark@kingant.net>
parents:
24311
diff
changeset
|
3180 /* |
dce57ce0b860
Change the way we handle <span style='font-size: whatever;'> tags slightly.
Mark Doliner <mark@kingant.net>
parents:
24311
diff
changeset
|
3181 * TODO: Handle other values, like percentages, or |
dce57ce0b860
Change the way we handle <span style='font-size: whatever;'> tags slightly.
Mark Doliner <mark@kingant.net>
parents:
24311
diff
changeset
|
3182 * lengths specified as em, ex, px, in, cm, mm, pt |
dce57ce0b860
Change the way we handle <span style='font-size: whatever;'> tags slightly.
Mark Doliner <mark@kingant.net>
parents:
24311
diff
changeset
|
3183 * or pc. Or even better, use an actual HTML |
dce57ce0b860
Change the way we handle <span style='font-size: whatever;'> tags slightly.
Mark Doliner <mark@kingant.net>
parents:
24311
diff
changeset
|
3184 * renderer like webkit. |
dce57ce0b860
Change the way we handle <span style='font-size: whatever;'> tags slightly.
Mark Doliner <mark@kingant.net>
parents:
24311
diff
changeset
|
3185 */ |
dce57ce0b860
Change the way we handle <span style='font-size: whatever;'> tags slightly.
Mark Doliner <mark@kingant.net>
parents:
24311
diff
changeset
|
3186 if (font->size > 0) |
dce57ce0b860
Change the way we handle <span style='font-size: whatever;'> tags slightly.
Mark Doliner <mark@kingant.net>
parents:
24311
diff
changeset
|
3187 gtk_imhtml_font_set_size(imhtml, font->size); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3188 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3189 else if (oldfont) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3190 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3191 font->size = oldfont->size; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3192 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3193 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3194 if (oldfont) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3195 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3196 font->underline = oldfont->underline; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3197 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3198 if (textdec && font->underline != 1 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3199 && g_ascii_strcasecmp(textdec, "underline") == 0 |
17055
53e757c37e06
Ignore bold, underline and other formatting type things in SPAN tags if
Stu Tomlinson <stu@nosnilmot.com>
parents:
16964
diff
changeset
|
3200 && (imhtml->format_functions & GTK_IMHTML_UNDERLINE) |
53e757c37e06
Ignore bold, underline and other formatting type things in SPAN tags if
Stu Tomlinson <stu@nosnilmot.com>
parents:
16964
diff
changeset
|
3201 && !(options & GTK_IMHTML_NO_FORMATTING)) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3202 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3203 gtk_imhtml_toggle_underline(imhtml); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3204 font->underline = 1; |
21156
a4b8bdc5a05f
Another leak fix.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21057
diff
changeset
|
3205 } |
31550
ac2cf73dbab8
Add support for rendering strikethrough when received as in-line CSS,
Stu Tomlinson <stu@nosnilmot.com>
parents:
31534
diff
changeset
|
3206 |
ac2cf73dbab8
Add support for rendering strikethrough when received as in-line CSS,
Stu Tomlinson <stu@nosnilmot.com>
parents:
31534
diff
changeset
|
3207 if (oldfont) |
ac2cf73dbab8
Add support for rendering strikethrough when received as in-line CSS,
Stu Tomlinson <stu@nosnilmot.com>
parents:
31534
diff
changeset
|
3208 { |
ac2cf73dbab8
Add support for rendering strikethrough when received as in-line CSS,
Stu Tomlinson <stu@nosnilmot.com>
parents:
31534
diff
changeset
|
3209 font->strike = oldfont->strike; |
ac2cf73dbab8
Add support for rendering strikethrough when received as in-line CSS,
Stu Tomlinson <stu@nosnilmot.com>
parents:
31534
diff
changeset
|
3210 } |
ac2cf73dbab8
Add support for rendering strikethrough when received as in-line CSS,
Stu Tomlinson <stu@nosnilmot.com>
parents:
31534
diff
changeset
|
3211 if (textdec && font->strike != 1 |
ac2cf73dbab8
Add support for rendering strikethrough when received as in-line CSS,
Stu Tomlinson <stu@nosnilmot.com>
parents:
31534
diff
changeset
|
3212 && g_ascii_strcasecmp(textdec, "line-through") == 0 |
ac2cf73dbab8
Add support for rendering strikethrough when received as in-line CSS,
Stu Tomlinson <stu@nosnilmot.com>
parents:
31534
diff
changeset
|
3213 && (imhtml->format_functions & GTK_IMHTML_STRIKE) |
ac2cf73dbab8
Add support for rendering strikethrough when received as in-line CSS,
Stu Tomlinson <stu@nosnilmot.com>
parents:
31534
diff
changeset
|
3214 && !(options & GTK_IMHTML_NO_FORMATTING)) |
ac2cf73dbab8
Add support for rendering strikethrough when received as in-line CSS,
Stu Tomlinson <stu@nosnilmot.com>
parents:
31534
diff
changeset
|
3215 { |
ac2cf73dbab8
Add support for rendering strikethrough when received as in-line CSS,
Stu Tomlinson <stu@nosnilmot.com>
parents:
31534
diff
changeset
|
3216 gtk_imhtml_toggle_strike(imhtml); |
ac2cf73dbab8
Add support for rendering strikethrough when received as in-line CSS,
Stu Tomlinson <stu@nosnilmot.com>
parents:
31534
diff
changeset
|
3217 font->strike = 1; |
ac2cf73dbab8
Add support for rendering strikethrough when received as in-line CSS,
Stu Tomlinson <stu@nosnilmot.com>
parents:
31534
diff
changeset
|
3218 } |
21156
a4b8bdc5a05f
Another leak fix.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21057
diff
changeset
|
3219 g_free(textdec); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3220 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3221 if (oldfont) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3222 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3223 font->bold = oldfont->bold; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3224 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3225 if (weight) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3226 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3227 if(!g_ascii_strcasecmp(weight, "normal")) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3228 font->bold = 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3229 } else if(!g_ascii_strcasecmp(weight, "bold")) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3230 font->bold = 1; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3231 } else if(!g_ascii_strcasecmp(weight, "bolder")) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3232 font->bold++; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3233 } else if(!g_ascii_strcasecmp(weight, "lighter")) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3234 if(font->bold > 0) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3235 font->bold--; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3236 } else { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3237 int num = atoi(weight); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3238 if(num >= 700) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3239 font->bold = 1; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3240 else |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3241 font->bold = 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3242 } |
17055
53e757c37e06
Ignore bold, underline and other formatting type things in SPAN tags if
Stu Tomlinson <stu@nosnilmot.com>
parents:
16964
diff
changeset
|
3243 if (((font->bold && oldfont && !oldfont->bold) || (oldfont && oldfont->bold && !font->bold) || (font->bold && !oldfont)) && !(options & GTK_IMHTML_NO_FORMATTING)) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3244 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3245 gtk_imhtml_toggle_bold(imhtml); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3246 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3247 g_free(weight); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3248 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3249 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3250 g_free(style); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3251 g_free(size); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3252 fonts = g_slist_prepend (fonts, font); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3253 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3254 break; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3255 case 57: /* /SPAN */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3256 /* Inline CSS Support - Douglas Thrift */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3257 if (fonts && !imhtml->wbfo) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3258 GtkIMHtmlFontDetail *oldfont = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3259 GtkIMHtmlFontDetail *font = fonts->data; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3260 gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3261 ws[0] = '\0'; wpos = 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3262 /* NEW_BIT (NEW_TEXT_BIT); */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3263 fonts = g_slist_remove (fonts, font); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3264 if (fonts) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3265 oldfont = fonts->data; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3266 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3267 if (!oldfont) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3268 gtk_imhtml_font_set_size(imhtml, 3); |
17055
53e757c37e06
Ignore bold, underline and other formatting type things in SPAN tags if
Stu Tomlinson <stu@nosnilmot.com>
parents:
16964
diff
changeset
|
3269 if (font->underline && !(options & GTK_IMHTML_NO_FORMATTING)) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3270 gtk_imhtml_toggle_underline(imhtml); |
31550
ac2cf73dbab8
Add support for rendering strikethrough when received as in-line CSS,
Stu Tomlinson <stu@nosnilmot.com>
parents:
31534
diff
changeset
|
3271 if (font->strike && !(options & GTK_IMHTML_NO_FORMATTING)) |
ac2cf73dbab8
Add support for rendering strikethrough when received as in-line CSS,
Stu Tomlinson <stu@nosnilmot.com>
parents:
31534
diff
changeset
|
3272 gtk_imhtml_toggle_strike(imhtml); |
17055
53e757c37e06
Ignore bold, underline and other formatting type things in SPAN tags if
Stu Tomlinson <stu@nosnilmot.com>
parents:
16964
diff
changeset
|
3273 if (font->bold && !(options & GTK_IMHTML_NO_FORMATTING)) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3274 gtk_imhtml_toggle_bold(imhtml); |
17055
53e757c37e06
Ignore bold, underline and other formatting type things in SPAN tags if
Stu Tomlinson <stu@nosnilmot.com>
parents:
16964
diff
changeset
|
3275 if (!(options & GTK_IMHTML_NO_FONTS)) |
53e757c37e06
Ignore bold, underline and other formatting type things in SPAN tags if
Stu Tomlinson <stu@nosnilmot.com>
parents:
16964
diff
changeset
|
3276 gtk_imhtml_toggle_fontface(imhtml, NULL); |
53e757c37e06
Ignore bold, underline and other formatting type things in SPAN tags if
Stu Tomlinson <stu@nosnilmot.com>
parents:
16964
diff
changeset
|
3277 if (!(options & GTK_IMHTML_NO_COLOURS)) |
53e757c37e06
Ignore bold, underline and other formatting type things in SPAN tags if
Stu Tomlinson <stu@nosnilmot.com>
parents:
16964
diff
changeset
|
3278 gtk_imhtml_toggle_forecolor(imhtml, NULL); |
53e757c37e06
Ignore bold, underline and other formatting type things in SPAN tags if
Stu Tomlinson <stu@nosnilmot.com>
parents:
16964
diff
changeset
|
3279 if (!(options & GTK_IMHTML_NO_COLOURS)) |
53e757c37e06
Ignore bold, underline and other formatting type things in SPAN tags if
Stu Tomlinson <stu@nosnilmot.com>
parents:
16964
diff
changeset
|
3280 gtk_imhtml_toggle_backcolor(imhtml, NULL); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3281 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3282 else |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3283 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3284 |
31550
ac2cf73dbab8
Add support for rendering strikethrough when received as in-line CSS,
Stu Tomlinson <stu@nosnilmot.com>
parents:
31534
diff
changeset
|
3285 if ((font->size != oldfont->size) && !(options & GTK_IMHTML_NO_SIZES)) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3286 gtk_imhtml_font_set_size(imhtml, oldfont->size); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3287 |
17055
53e757c37e06
Ignore bold, underline and other formatting type things in SPAN tags if
Stu Tomlinson <stu@nosnilmot.com>
parents:
16964
diff
changeset
|
3288 if ((font->underline != oldfont->underline) && !(options & GTK_IMHTML_NO_FORMATTING)) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3289 gtk_imhtml_toggle_underline(imhtml); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3290 |
31550
ac2cf73dbab8
Add support for rendering strikethrough when received as in-line CSS,
Stu Tomlinson <stu@nosnilmot.com>
parents:
31534
diff
changeset
|
3291 if ((font->strike != oldfont->strike) && !(options & GTK_IMHTML_NO_FORMATTING)) |
ac2cf73dbab8
Add support for rendering strikethrough when received as in-line CSS,
Stu Tomlinson <stu@nosnilmot.com>
parents:
31534
diff
changeset
|
3292 gtk_imhtml_toggle_strike(imhtml); |
ac2cf73dbab8
Add support for rendering strikethrough when received as in-line CSS,
Stu Tomlinson <stu@nosnilmot.com>
parents:
31534
diff
changeset
|
3293 |
17055
53e757c37e06
Ignore bold, underline and other formatting type things in SPAN tags if
Stu Tomlinson <stu@nosnilmot.com>
parents:
16964
diff
changeset
|
3294 if (((font->bold && !oldfont->bold) || (oldfont->bold && !font->bold)) && !(options & GTK_IMHTML_NO_FORMATTING)) |
31550
ac2cf73dbab8
Add support for rendering strikethrough when received as in-line CSS,
Stu Tomlinson <stu@nosnilmot.com>
parents:
31534
diff
changeset
|
3295 gtk_imhtml_toggle_bold(imhtml); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3296 |
17055
53e757c37e06
Ignore bold, underline and other formatting type things in SPAN tags if
Stu Tomlinson <stu@nosnilmot.com>
parents:
16964
diff
changeset
|
3297 if (font->face && (!oldfont->face || strcmp(font->face, oldfont->face) != 0) && !(options & GTK_IMHTML_NO_FONTS)) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3298 gtk_imhtml_toggle_fontface(imhtml, oldfont->face); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3299 |
17055
53e757c37e06
Ignore bold, underline and other formatting type things in SPAN tags if
Stu Tomlinson <stu@nosnilmot.com>
parents:
16964
diff
changeset
|
3300 if (font->fore && (!oldfont->fore || strcmp(font->fore, oldfont->fore) != 0) && !(options & GTK_IMHTML_NO_COLOURS)) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3301 gtk_imhtml_toggle_forecolor(imhtml, oldfont->fore); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3302 |
17055
53e757c37e06
Ignore bold, underline and other formatting type things in SPAN tags if
Stu Tomlinson <stu@nosnilmot.com>
parents:
16964
diff
changeset
|
3303 if (font->back && (!oldfont->back || strcmp(font->back, oldfont->back) != 0) && !(options & GTK_IMHTML_NO_COLOURS)) |
31550
ac2cf73dbab8
Add support for rendering strikethrough when received as in-line CSS,
Stu Tomlinson <stu@nosnilmot.com>
parents:
31534
diff
changeset
|
3304 gtk_imhtml_toggle_backcolor(imhtml, oldfont->back); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3305 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3306 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3307 g_free (font->face); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3308 g_free (font->fore); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3309 g_free (font->back); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3310 g_free (font->sml); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3311 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3312 g_free (font); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3313 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3314 break; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3315 case 60: /* SPAN */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3316 break; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3317 case 62: /* comment */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3318 /* NEW_BIT (NEW_TEXT_BIT); */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3319 ws[wpos] = '\0'; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3320 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3321 gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3322 |
22341
53873732f90a
Disable invisible text things, if someone can conclusively prove this is
Stu Tomlinson <stu@nosnilmot.com>
parents:
22148
diff
changeset
|
3323 #if FALSE && GTK_CHECK_VERSION(2,10,10) |
22084
101b711a76de
disapproval of revision '4b5e932e01a84088124dee9791809545cdc9240b'
Sean Egan <seanegan@gmail.com>
parents:
22083
diff
changeset
|
3324 wpos = g_snprintf (ws, len, "%s", tag); |
101b711a76de
disapproval of revision '4b5e932e01a84088124dee9791809545cdc9240b'
Sean Egan <seanegan@gmail.com>
parents:
22083
diff
changeset
|
3325 gtk_text_buffer_insert_with_tags_by_name(imhtml->text_buffer, iter, ws, wpos, "comment", NULL); |
101b711a76de
disapproval of revision '4b5e932e01a84088124dee9791809545cdc9240b'
Sean Egan <seanegan@gmail.com>
parents:
22083
diff
changeset
|
3326 #else |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3327 if (imhtml->show_comments && !(options & GTK_IMHTML_NO_COMMENTS)) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3328 wpos = g_snprintf (ws, len, "%s", tag); |
23167
9f94bf3743c2
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23163
diff
changeset
|
3329 gtk_text_buffer_insert_with_tags_by_name(imhtml->text_buffer, iter, ws, wpos, "comment", NULL); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3330 } |
22084
101b711a76de
disapproval of revision '4b5e932e01a84088124dee9791809545cdc9240b'
Sean Egan <seanegan@gmail.com>
parents:
22083
diff
changeset
|
3331 #endif |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3332 ws[0] = '\0'; wpos = 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3333 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3334 /* NEW_BIT (NEW_COMMENT_BIT); */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3335 break; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3336 default: |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3337 break; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3338 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3339 c += tlen; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3340 pos += tlen; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3341 g_free(tag); /* This was allocated back in VALID_TAG() */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3342 } else if (imhtml->edit.link == NULL && |
21650
1f6935a5d189
Patch from 'goutnet' to not insert smileys when pasting as plain text.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21648
diff
changeset
|
3343 !(options & GTK_IMHTML_NO_SMILEY) && |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3344 gtk_imhtml_is_smiley(imhtml, fonts, c, &smilelen)) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3345 GtkIMHtmlFontDetail *fd; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3346 gchar *sml = NULL; |
21488
277873603719
Fix #3930 by correctly detecting when we're no longer immediately following a br.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21156
diff
changeset
|
3347 |
277873603719
Fix #3930 by correctly detecting when we're no longer immediately following a br.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21156
diff
changeset
|
3348 br = FALSE; |
277873603719
Fix #3930 by correctly detecting when we're no longer immediately following a br.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21156
diff
changeset
|
3349 |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3350 if (fonts) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3351 fd = fonts->data; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3352 sml = fd->sml; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3353 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3354 if (!sml) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3355 sml = imhtml->protocol_name; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3356 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3357 gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3358 wpos = g_snprintf (ws, smilelen + 1, "%s", c); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3359 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3360 gtk_imhtml_insert_smiley_at_iter(imhtml, sml, ws, iter); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3361 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3362 c += smilelen; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3363 pos += smilelen; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3364 wpos = 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3365 ws[0] = 0; |
16084 | 3366 } else if (*c == '&' && (amp = purple_markup_unescape_entity(c, &tlen))) { |
21488
277873603719
Fix #3930 by correctly detecting when we're no longer immediately following a br.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21156
diff
changeset
|
3367 br = FALSE; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3368 while(*amp) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3369 ws [wpos++] = *amp++; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3370 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3371 c += tlen; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3372 pos += tlen; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3373 } else if (*c == '\n') { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3374 if (!(options & GTK_IMHTML_NO_NEWLINE)) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3375 ws[wpos] = '\n'; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3376 wpos++; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3377 gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos); |
25351
5dedfe149cb3
Pass only the URL scheme to gtkimhtml and let it add the colon automatically.
Richard Laager <rlaager@wiktel.com>
parents:
24548
diff
changeset
|
3378 ws[0] = '\0'; wpos = 0; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3379 /* NEW_BIT (NEW_TEXT_BIT); */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3380 } else if (!br) { /* Don't insert a space immediately after an HTML break */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3381 /* A newline is defined by HTML as whitespace, which means we have to replace it with a word boundary. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3382 * word breaks vary depending on the language used, so the correct thing to do is to use Pango to determine |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3383 * what language this is, determine the proper word boundary to use, and insert that. I'm just going to insert |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3384 * a space instead. What are the non-English speakers going to do? Complain in a language I'll understand? |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3385 * Bu-wahaha! */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3386 ws[wpos] = ' '; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3387 wpos++; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3388 gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos); |
25351
5dedfe149cb3
Pass only the URL scheme to gtkimhtml and let it add the colon automatically.
Richard Laager <rlaager@wiktel.com>
parents:
24548
diff
changeset
|
3389 ws[0] = '\0'; wpos = 0; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3390 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3391 c++; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3392 pos++; |
25355
c6f7143cc7f4
Only find URLs on word boundaries to fix a bug rlaager noticed.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
25352
diff
changeset
|
3393 } else if ((pos == 0 || wpos == 0 || isspace(*(c - 1))) && |
25435
fabd8eda763d
Do not linkify unless <proto> is followed by some non-whitespace string.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
25433
diff
changeset
|
3394 (len_protocol = gtk_imhtml_is_protocol(c)) > 0 && |
26526
8e594c4cdae4
Fix the auto-linking of protocols.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
25435
diff
changeset
|
3395 c[len_protocol] && !isspace(c[len_protocol]) && |
8e594c4cdae4
Fix the auto-linking of protocols.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
25435
diff
changeset
|
3396 (c[len_protocol] != '<' || !gtk_imhtml_is_tag(c + 1, NULL, NULL, NULL))) { |
21488
277873603719
Fix #3930 by correctly detecting when we're no longer immediately following a br.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21156
diff
changeset
|
3397 br = FALSE; |
24396
38a2f78f80a7
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24311
diff
changeset
|
3398 if (wpos > 0) { |
38a2f78f80a7
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24311
diff
changeset
|
3399 gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos); |
25351
5dedfe149cb3
Pass only the URL scheme to gtkimhtml and let it add the colon automatically.
Richard Laager <rlaager@wiktel.com>
parents:
24548
diff
changeset
|
3400 ws[0] = '\0'; wpos = 0; |
24396
38a2f78f80a7
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24311
diff
changeset
|
3401 } |
25351
5dedfe149cb3
Pass only the URL scheme to gtkimhtml and let it add the colon automatically.
Richard Laager <rlaager@wiktel.com>
parents:
24548
diff
changeset
|
3402 while (len_protocol--) { |
5dedfe149cb3
Pass only the URL scheme to gtkimhtml and let it add the colon automatically.
Richard Laager <rlaager@wiktel.com>
parents:
24548
diff
changeset
|
3403 /* Skip the next len_protocol characters, but |
5dedfe149cb3
Pass only the URL scheme to gtkimhtml and let it add the colon automatically.
Richard Laager <rlaager@wiktel.com>
parents:
24548
diff
changeset
|
3404 * make sure they're copied into the ws array. |
5dedfe149cb3
Pass only the URL scheme to gtkimhtml and let it add the colon automatically.
Richard Laager <rlaager@wiktel.com>
parents:
24548
diff
changeset
|
3405 */ |
5dedfe149cb3
Pass only the URL scheme to gtkimhtml and let it add the colon automatically.
Richard Laager <rlaager@wiktel.com>
parents:
24548
diff
changeset
|
3406 ws [wpos++] = *c++; |
5dedfe149cb3
Pass only the URL scheme to gtkimhtml and let it add the colon automatically.
Richard Laager <rlaager@wiktel.com>
parents:
24548
diff
changeset
|
3407 pos++; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3408 } |
25361
d9da15c9e2a1
Fix the linkification error where bad things happened if you copy/pasted
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
25358
diff
changeset
|
3409 if (!imhtml->edit.link && (imhtml->format_functions & GTK_IMHTML_LINK)) { |
d9da15c9e2a1
Fix the linkification error where bad things happened if you copy/pasted
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
25358
diff
changeset
|
3410 while (*c && !isspace((int)*c) && |
d9da15c9e2a1
Fix the linkification error where bad things happened if you copy/pasted
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
25358
diff
changeset
|
3411 (*c != '<' || !gtk_imhtml_is_tag(c + 1, NULL, NULL, NULL))) { |
d9da15c9e2a1
Fix the linkification error where bad things happened if you copy/pasted
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
25358
diff
changeset
|
3412 if (*c == '&' && (amp = purple_markup_unescape_entity(c, &tlen))) { |
d9da15c9e2a1
Fix the linkification error where bad things happened if you copy/pasted
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
25358
diff
changeset
|
3413 while (*amp) |
d9da15c9e2a1
Fix the linkification error where bad things happened if you copy/pasted
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
25358
diff
changeset
|
3414 ws[wpos++] = *amp++; |
d9da15c9e2a1
Fix the linkification error where bad things happened if you copy/pasted
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
25358
diff
changeset
|
3415 c += tlen; |
d9da15c9e2a1
Fix the linkification error where bad things happened if you copy/pasted
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
25358
diff
changeset
|
3416 pos += tlen; |
d9da15c9e2a1
Fix the linkification error where bad things happened if you copy/pasted
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
25358
diff
changeset
|
3417 } else { |
d9da15c9e2a1
Fix the linkification error where bad things happened if you copy/pasted
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
25358
diff
changeset
|
3418 ws [wpos++] = *c++; |
d9da15c9e2a1
Fix the linkification error where bad things happened if you copy/pasted
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
25358
diff
changeset
|
3419 pos++; |
d9da15c9e2a1
Fix the linkification error where bad things happened if you copy/pasted
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
25358
diff
changeset
|
3420 } |
24396
38a2f78f80a7
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24311
diff
changeset
|
3421 } |
38a2f78f80a7
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24311
diff
changeset
|
3422 ws[wpos] = '\0'; |
38a2f78f80a7
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24311
diff
changeset
|
3423 gtk_imhtml_toggle_link(imhtml, ws); |
38a2f78f80a7
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24311
diff
changeset
|
3424 gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos); |
38a2f78f80a7
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24311
diff
changeset
|
3425 ws[0] = '\0'; wpos = 0; |
38a2f78f80a7
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24311
diff
changeset
|
3426 gtk_imhtml_toggle_link(imhtml, NULL); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3427 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3428 } else if (*c) { |
21488
277873603719
Fix #3930 by correctly detecting when we're no longer immediately following a br.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
21156
diff
changeset
|
3429 br = FALSE; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3430 ws [wpos++] = *c++; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3431 pos++; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3432 } else { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3433 break; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3434 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3435 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3436 gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3437 ws[0] = '\0'; wpos = 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3438 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3439 /* NEW_BIT(NEW_TEXT_BIT); */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3440 |
16083
f2a4b05407d7
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15871
diff
changeset
|
3441 if(align_right) { |
f2a4b05407d7
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15871
diff
changeset
|
3442 /* insert RLM+LRM at beginning of the line to set alignment */ |
f2a4b05407d7
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15871
diff
changeset
|
3443 GtkTextIter line_iter; |
f2a4b05407d7
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15871
diff
changeset
|
3444 line_iter = *iter; |
f2a4b05407d7
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15871
diff
changeset
|
3445 gtk_text_iter_set_line(&line_iter, align_line); |
f2a4b05407d7
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15871
diff
changeset
|
3446 /* insert RLM character to set alignment */ |
f2a4b05407d7
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15871
diff
changeset
|
3447 ws[wpos++] = 0xE2; |
f2a4b05407d7
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15871
diff
changeset
|
3448 ws[wpos++] = 0x80; |
f2a4b05407d7
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15871
diff
changeset
|
3449 ws[wpos++] = 0x8F; |
25415
584063555949
Remove trailing whitespace
Mark Doliner <mark@kingant.net>
parents:
25381
diff
changeset
|
3450 |
16084 | 3451 if (!rtl_direction) |
16083
f2a4b05407d7
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15871
diff
changeset
|
3452 { |
f2a4b05407d7
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15871
diff
changeset
|
3453 /* insert LRM character to set direction */ |
f2a4b05407d7
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15871
diff
changeset
|
3454 /* (alignment=right and direction=LTR) */ |
f2a4b05407d7
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15871
diff
changeset
|
3455 ws[wpos++] = 0xE2; |
f2a4b05407d7
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15871
diff
changeset
|
3456 ws[wpos++] = 0x80; |
f2a4b05407d7
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15871
diff
changeset
|
3457 ws[wpos++] = 0x8E; |
f2a4b05407d7
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15871
diff
changeset
|
3458 } |
f2a4b05407d7
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15871
diff
changeset
|
3459 |
f2a4b05407d7
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15871
diff
changeset
|
3460 ws[wpos] = '\0'; |
f2a4b05407d7
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15871
diff
changeset
|
3461 gtk_text_buffer_insert(imhtml->text_buffer, &line_iter, ws, wpos); |
f2a4b05407d7
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15871
diff
changeset
|
3462 gtk_text_buffer_get_end_iter(gtk_text_iter_get_buffer(&line_iter), iter); |
25351
5dedfe149cb3
Pass only the URL scheme to gtkimhtml and let it add the colon automatically.
Richard Laager <rlaager@wiktel.com>
parents:
24548
diff
changeset
|
3463 ws[0] = '\0'; wpos = 0; |
16083
f2a4b05407d7
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15871
diff
changeset
|
3464 } |
f2a4b05407d7
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15871
diff
changeset
|
3465 |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3466 while (fonts) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3467 GtkIMHtmlFontDetail *font = fonts->data; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3468 fonts = g_slist_remove (fonts, font); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3469 g_free (font->face); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3470 g_free (font->fore); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3471 g_free (font->back); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3472 g_free (font->sml); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3473 g_free (font); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3474 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3475 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3476 g_free(ws); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3477 g_free(bg); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3478 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3479 if (!imhtml->wbfo) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3480 gtk_imhtml_close_tags(imhtml, iter); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3481 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3482 object = g_object_ref(G_OBJECT(imhtml)); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3483 g_signal_emit(object, signals[UPDATE_FORMAT], 0); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3484 g_object_unref(object); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3485 |
22674
27c9c55499f8
Smiley insertions can be undone with this fix. References #5577. But redo
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22650
diff
changeset
|
3486 gtk_text_buffer_end_user_action(imhtml->text_buffer); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3487 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3488 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3489 void gtk_imhtml_remove_smileys(GtkIMHtml *imhtml) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3490 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3491 g_hash_table_destroy(imhtml->smiley_data); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3492 gtk_smiley_tree_destroy(imhtml->default_smilies); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3493 imhtml->smiley_data = g_hash_table_new_full(g_str_hash, g_str_equal, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3494 g_free, (GDestroyNotify)gtk_smiley_tree_destroy); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3495 imhtml->default_smilies = gtk_smiley_tree_new(); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3496 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3497 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3498 void gtk_imhtml_show_comments (GtkIMHtml *imhtml, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3499 gboolean show) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3500 { |
22341
53873732f90a
Disable invisible text things, if someone can conclusively prove this is
Stu Tomlinson <stu@nosnilmot.com>
parents:
22148
diff
changeset
|
3501 #if FALSE && GTK_CHECK_VERSION(2,10,10) |
22084
101b711a76de
disapproval of revision '4b5e932e01a84088124dee9791809545cdc9240b'
Sean Egan <seanegan@gmail.com>
parents:
22083
diff
changeset
|
3502 GtkTextTag *tag; |
101b711a76de
disapproval of revision '4b5e932e01a84088124dee9791809545cdc9240b'
Sean Egan <seanegan@gmail.com>
parents:
22083
diff
changeset
|
3503 tag = gtk_text_tag_table_lookup(gtk_text_buffer_get_tag_table(imhtml->text_buffer), "comment"); |
101b711a76de
disapproval of revision '4b5e932e01a84088124dee9791809545cdc9240b'
Sean Egan <seanegan@gmail.com>
parents:
22083
diff
changeset
|
3504 if (tag) |
101b711a76de
disapproval of revision '4b5e932e01a84088124dee9791809545cdc9240b'
Sean Egan <seanegan@gmail.com>
parents:
22083
diff
changeset
|
3505 g_object_set(G_OBJECT(tag), "invisible", !show, NULL); |
101b711a76de
disapproval of revision '4b5e932e01a84088124dee9791809545cdc9240b'
Sean Egan <seanegan@gmail.com>
parents:
22083
diff
changeset
|
3506 #endif |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3507 imhtml->show_comments = show; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3508 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3509 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3510 const char * |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3511 gtk_imhtml_get_protocol_name(GtkIMHtml *imhtml) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3512 return imhtml->protocol_name; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3513 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3514 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3515 void |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3516 gtk_imhtml_set_protocol_name(GtkIMHtml *imhtml, const gchar *protocol_name) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3517 g_free(imhtml->protocol_name); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3518 imhtml->protocol_name = g_strdup(protocol_name); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3519 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3520 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3521 void |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3522 gtk_imhtml_delete(GtkIMHtml *imhtml, GtkTextIter *start, GtkTextIter *end) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3523 GList *l; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3524 GSList *sl; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3525 GtkTextIter i, i_s, i_e; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3526 GObject *object = g_object_ref(G_OBJECT(imhtml)); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3527 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3528 if (start == NULL) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3529 gtk_text_buffer_get_start_iter(imhtml->text_buffer, &i_s); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3530 start = &i_s; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3531 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3532 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3533 if (end == NULL) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3534 gtk_text_buffer_get_end_iter(imhtml->text_buffer, &i_e); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3535 end = &i_e; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3536 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3537 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3538 l = imhtml->scalables; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3539 while (l) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3540 GList *next = l->next; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3541 struct scalable_data *sd = l->data; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3542 gtk_text_buffer_get_iter_at_mark(imhtml->text_buffer, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3543 &i, sd->mark); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3544 if (gtk_text_iter_in_range(&i, start, end)) { |
20987
0cbfc19e4909
Fix some leaks caused by misuse of g_list_remove_link() instead of g_list_delete_link().
Daniel Atallah <daniel.atallah@gmail.com>
parents:
20566
diff
changeset
|
3545 GtkIMHtmlScalable *scale = GTK_IMHTML_SCALABLE(sd->scalable); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3546 scale->free(scale); |
20987
0cbfc19e4909
Fix some leaks caused by misuse of g_list_remove_link() instead of g_list_delete_link().
Daniel Atallah <daniel.atallah@gmail.com>
parents:
20566
diff
changeset
|
3547 g_free(sd); |
0cbfc19e4909
Fix some leaks caused by misuse of g_list_remove_link() instead of g_list_delete_link().
Daniel Atallah <daniel.atallah@gmail.com>
parents:
20566
diff
changeset
|
3548 imhtml->scalables = g_list_delete_link(imhtml->scalables, l); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3549 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3550 l = next; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3551 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3552 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3553 sl = imhtml->im_images; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3554 while (sl) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3555 GSList *next = sl->next; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3556 struct im_image_data *img_data = sl->data; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3557 gtk_text_buffer_get_iter_at_mark(imhtml->text_buffer, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3558 &i, img_data->mark); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3559 if (gtk_text_iter_in_range(&i, start, end)) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3560 if (imhtml->funcs->image_unref) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3561 imhtml->funcs->image_unref(img_data->id); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3562 imhtml->im_images = g_slist_delete_link(imhtml->im_images, sl); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3563 g_free(img_data); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3564 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3565 sl = next; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3566 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3567 gtk_text_buffer_delete(imhtml->text_buffer, start, end); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3568 |
29468
89b4054deba1
Fix CVE-2010-0423, a denial of service attack due to the parsing
Mark Doliner <mark@kingant.net>
parents:
29440
diff
changeset
|
3569 g_object_set_data(G_OBJECT(imhtml), "gtkimhtml_numsmileys_total", GINT_TO_POINTER(0)); |
89b4054deba1
Fix CVE-2010-0423, a denial of service attack due to the parsing
Mark Doliner <mark@kingant.net>
parents:
29440
diff
changeset
|
3570 |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3571 g_object_unref(object); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3572 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3573 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3574 void gtk_imhtml_page_up (GtkIMHtml *imhtml) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3575 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3576 GdkRectangle rect; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3577 GtkTextIter iter; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3578 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3579 gtk_text_view_get_visible_rect(GTK_TEXT_VIEW(imhtml), &rect); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3580 gtk_text_view_get_iter_at_location(GTK_TEXT_VIEW(imhtml), &iter, rect.x, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3581 rect.y - rect.height); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3582 gtk_text_view_scroll_to_iter(GTK_TEXT_VIEW(imhtml), &iter, 0, TRUE, 0, 0); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3583 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3584 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3585 void gtk_imhtml_page_down (GtkIMHtml *imhtml) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3586 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3587 GdkRectangle rect; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3588 GtkTextIter iter; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3589 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3590 gtk_text_view_get_visible_rect(GTK_TEXT_VIEW(imhtml), &rect); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3591 gtk_text_view_get_iter_at_location(GTK_TEXT_VIEW(imhtml), &iter, rect.x, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3592 rect.y + rect.height); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3593 gtk_text_view_scroll_to_iter(GTK_TEXT_VIEW(imhtml), &iter, 0, TRUE, 0, 0); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3594 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3595 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3596 /* GtkIMHtmlScalable, gtk_imhtml_image, gtk_imhtml_hr */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3597 GtkIMHtmlScalable *gtk_imhtml_image_new(GdkPixbuf *img, const gchar *filename, int id) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3598 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3599 GtkIMHtmlImage *im_image = g_malloc(sizeof(GtkIMHtmlImage)); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3600 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3601 GTK_IMHTML_SCALABLE(im_image)->scale = gtk_imhtml_image_scale; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3602 GTK_IMHTML_SCALABLE(im_image)->add_to = gtk_imhtml_image_add_to; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3603 GTK_IMHTML_SCALABLE(im_image)->free = gtk_imhtml_image_free; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3604 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3605 im_image->pixbuf = img; |
18089
1f6599cd2d2b
When an animated image is inserted into a conversation window, animate
Mark Doliner <mark@kingant.net>
parents:
18056
diff
changeset
|
3606 im_image->image = GTK_IMAGE(gtk_image_new_from_pixbuf(im_image->pixbuf)); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3607 im_image->width = gdk_pixbuf_get_width(img); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3608 im_image->height = gdk_pixbuf_get_height(img); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3609 im_image->mark = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3610 im_image->filename = g_strdup(filename); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3611 im_image->id = id; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3612 im_image->filesel = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3613 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3614 g_object_ref(img); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3615 return GTK_IMHTML_SCALABLE(im_image); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3616 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3617 |
18089
1f6599cd2d2b
When an animated image is inserted into a conversation window, animate
Mark Doliner <mark@kingant.net>
parents:
18056
diff
changeset
|
3618 static gboolean |
1f6599cd2d2b
When an animated image is inserted into a conversation window, animate
Mark Doliner <mark@kingant.net>
parents:
18056
diff
changeset
|
3619 animate_image_cb(gpointer data) |
1f6599cd2d2b
When an animated image is inserted into a conversation window, animate
Mark Doliner <mark@kingant.net>
parents:
18056
diff
changeset
|
3620 { |
1f6599cd2d2b
When an animated image is inserted into a conversation window, animate
Mark Doliner <mark@kingant.net>
parents:
18056
diff
changeset
|
3621 GtkIMHtmlImage *im_image; |
1f6599cd2d2b
When an animated image is inserted into a conversation window, animate
Mark Doliner <mark@kingant.net>
parents:
18056
diff
changeset
|
3622 int width, height; |
1f6599cd2d2b
When an animated image is inserted into a conversation window, animate
Mark Doliner <mark@kingant.net>
parents:
18056
diff
changeset
|
3623 int delay; |
1f6599cd2d2b
When an animated image is inserted into a conversation window, animate
Mark Doliner <mark@kingant.net>
parents:
18056
diff
changeset
|
3624 |
1f6599cd2d2b
When an animated image is inserted into a conversation window, animate
Mark Doliner <mark@kingant.net>
parents:
18056
diff
changeset
|
3625 im_image = data; |
1f6599cd2d2b
When an animated image is inserted into a conversation window, animate
Mark Doliner <mark@kingant.net>
parents:
18056
diff
changeset
|
3626 |
1f6599cd2d2b
When an animated image is inserted into a conversation window, animate
Mark Doliner <mark@kingant.net>
parents:
18056
diff
changeset
|
3627 /* Update the pointer to this GdkPixbuf frame of the animation */ |
20566
3ef40e8de6ab
Fix some crashes with animated smileys. Fixes #3179, #938, #3134, #2872, #1594
Daniel Atallah <daniel.atallah@gmail.com>
parents:
20074
diff
changeset
|
3628 if (gdk_pixbuf_animation_iter_advance(GTK_IMHTML_ANIMATION(im_image)->iter, NULL)) { |
3ef40e8de6ab
Fix some crashes with animated smileys. Fixes #3179, #938, #3134, #2872, #1594
Daniel Atallah <daniel.atallah@gmail.com>
parents:
20074
diff
changeset
|
3629 GdkPixbuf *pb = gdk_pixbuf_animation_iter_get_pixbuf(GTK_IMHTML_ANIMATION(im_image)->iter); |
3ef40e8de6ab
Fix some crashes with animated smileys. Fixes #3179, #938, #3134, #2872, #1594
Daniel Atallah <daniel.atallah@gmail.com>
parents:
20074
diff
changeset
|
3630 g_object_unref(G_OBJECT(im_image->pixbuf)); |
3ef40e8de6ab
Fix some crashes with animated smileys. Fixes #3179, #938, #3134, #2872, #1594
Daniel Atallah <daniel.atallah@gmail.com>
parents:
20074
diff
changeset
|
3631 im_image->pixbuf = gdk_pixbuf_copy(pb); |
3ef40e8de6ab
Fix some crashes with animated smileys. Fixes #3179, #938, #3134, #2872, #1594
Daniel Atallah <daniel.atallah@gmail.com>
parents:
20074
diff
changeset
|
3632 |
3ef40e8de6ab
Fix some crashes with animated smileys. Fixes #3179, #938, #3134, #2872, #1594
Daniel Atallah <daniel.atallah@gmail.com>
parents:
20074
diff
changeset
|
3633 /* Update the displayed GtkImage */ |
3ef40e8de6ab
Fix some crashes with animated smileys. Fixes #3179, #938, #3134, #2872, #1594
Daniel Atallah <daniel.atallah@gmail.com>
parents:
20074
diff
changeset
|
3634 width = gdk_pixbuf_get_width(gtk_image_get_pixbuf(im_image->image)); |
3ef40e8de6ab
Fix some crashes with animated smileys. Fixes #3179, #938, #3134, #2872, #1594
Daniel Atallah <daniel.atallah@gmail.com>
parents:
20074
diff
changeset
|
3635 height = gdk_pixbuf_get_height(gtk_image_get_pixbuf(im_image->image)); |
3ef40e8de6ab
Fix some crashes with animated smileys. Fixes #3179, #938, #3134, #2872, #1594
Daniel Atallah <daniel.atallah@gmail.com>
parents:
20074
diff
changeset
|
3636 if (width > 0 && height > 0) |
3ef40e8de6ab
Fix some crashes with animated smileys. Fixes #3179, #938, #3134, #2872, #1594
Daniel Atallah <daniel.atallah@gmail.com>
parents:
20074
diff
changeset
|
3637 { |
3ef40e8de6ab
Fix some crashes with animated smileys. Fixes #3179, #938, #3134, #2872, #1594
Daniel Atallah <daniel.atallah@gmail.com>
parents:
20074
diff
changeset
|
3638 /* Need to scale the new frame to the same size as the old frame */ |
3ef40e8de6ab
Fix some crashes with animated smileys. Fixes #3179, #938, #3134, #2872, #1594
Daniel Atallah <daniel.atallah@gmail.com>
parents:
20074
diff
changeset
|
3639 GdkPixbuf *tmp; |
3ef40e8de6ab
Fix some crashes with animated smileys. Fixes #3179, #938, #3134, #2872, #1594
Daniel Atallah <daniel.atallah@gmail.com>
parents:
20074
diff
changeset
|
3640 tmp = gdk_pixbuf_scale_simple(im_image->pixbuf, width, height, GDK_INTERP_BILINEAR); |
3ef40e8de6ab
Fix some crashes with animated smileys. Fixes #3179, #938, #3134, #2872, #1594
Daniel Atallah <daniel.atallah@gmail.com>
parents:
20074
diff
changeset
|
3641 gtk_image_set_from_pixbuf(im_image->image, tmp); |
3ef40e8de6ab
Fix some crashes with animated smileys. Fixes #3179, #938, #3134, #2872, #1594
Daniel Atallah <daniel.atallah@gmail.com>
parents:
20074
diff
changeset
|
3642 g_object_unref(G_OBJECT(tmp)); |
3ef40e8de6ab
Fix some crashes with animated smileys. Fixes #3179, #938, #3134, #2872, #1594
Daniel Atallah <daniel.atallah@gmail.com>
parents:
20074
diff
changeset
|
3643 } else { |
3ef40e8de6ab
Fix some crashes with animated smileys. Fixes #3179, #938, #3134, #2872, #1594
Daniel Atallah <daniel.atallah@gmail.com>
parents:
20074
diff
changeset
|
3644 /* Display at full-size */ |
3ef40e8de6ab
Fix some crashes with animated smileys. Fixes #3179, #938, #3134, #2872, #1594
Daniel Atallah <daniel.atallah@gmail.com>
parents:
20074
diff
changeset
|
3645 gtk_image_set_from_pixbuf(im_image->image, im_image->pixbuf); |
3ef40e8de6ab
Fix some crashes with animated smileys. Fixes #3179, #938, #3134, #2872, #1594
Daniel Atallah <daniel.atallah@gmail.com>
parents:
20074
diff
changeset
|
3646 } |
18089
1f6599cd2d2b
When an animated image is inserted into a conversation window, animate
Mark Doliner <mark@kingant.net>
parents:
18056
diff
changeset
|
3647 } |
1f6599cd2d2b
When an animated image is inserted into a conversation window, animate
Mark Doliner <mark@kingant.net>
parents:
18056
diff
changeset
|
3648 |
1f6599cd2d2b
When an animated image is inserted into a conversation window, animate
Mark Doliner <mark@kingant.net>
parents:
18056
diff
changeset
|
3649 delay = MIN(gdk_pixbuf_animation_iter_get_delay_time(GTK_IMHTML_ANIMATION(im_image)->iter), 100); |
1f6599cd2d2b
When an animated image is inserted into a conversation window, animate
Mark Doliner <mark@kingant.net>
parents:
18056
diff
changeset
|
3650 GTK_IMHTML_ANIMATION(im_image)->timer = g_timeout_add(delay, animate_image_cb, im_image); |
1f6599cd2d2b
When an animated image is inserted into a conversation window, animate
Mark Doliner <mark@kingant.net>
parents:
18056
diff
changeset
|
3651 |
1f6599cd2d2b
When an animated image is inserted into a conversation window, animate
Mark Doliner <mark@kingant.net>
parents:
18056
diff
changeset
|
3652 return FALSE; |
1f6599cd2d2b
When an animated image is inserted into a conversation window, animate
Mark Doliner <mark@kingant.net>
parents:
18056
diff
changeset
|
3653 } |
1f6599cd2d2b
When an animated image is inserted into a conversation window, animate
Mark Doliner <mark@kingant.net>
parents:
18056
diff
changeset
|
3654 |
1f6599cd2d2b
When an animated image is inserted into a conversation window, animate
Mark Doliner <mark@kingant.net>
parents:
18056
diff
changeset
|
3655 GtkIMHtmlScalable *gtk_imhtml_animation_new(GdkPixbufAnimation *anim, const gchar *filename, int id) |
1f6599cd2d2b
When an animated image is inserted into a conversation window, animate
Mark Doliner <mark@kingant.net>
parents:
18056
diff
changeset
|
3656 { |
22545
e59156cf8752
Fix animated icons that have been right-clicked causing crashes when the imhtml is destroyed. Fixes #5217.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
22447
diff
changeset
|
3657 GtkIMHtmlImage *im_image = (GtkIMHtmlImage *) g_new0(GtkIMHtmlAnimation, 1); |
18089
1f6599cd2d2b
When an animated image is inserted into a conversation window, animate
Mark Doliner <mark@kingant.net>
parents:
18056
diff
changeset
|
3658 |
1f6599cd2d2b
When an animated image is inserted into a conversation window, animate
Mark Doliner <mark@kingant.net>
parents:
18056
diff
changeset
|
3659 GTK_IMHTML_SCALABLE(im_image)->scale = gtk_imhtml_image_scale; |
1f6599cd2d2b
When an animated image is inserted into a conversation window, animate
Mark Doliner <mark@kingant.net>
parents:
18056
diff
changeset
|
3660 GTK_IMHTML_SCALABLE(im_image)->add_to = gtk_imhtml_image_add_to; |
1f6599cd2d2b
When an animated image is inserted into a conversation window, animate
Mark Doliner <mark@kingant.net>
parents:
18056
diff
changeset
|
3661 GTK_IMHTML_SCALABLE(im_image)->free = gtk_imhtml_animation_free; |
1f6599cd2d2b
When an animated image is inserted into a conversation window, animate
Mark Doliner <mark@kingant.net>
parents:
18056
diff
changeset
|
3662 |
1f6599cd2d2b
When an animated image is inserted into a conversation window, animate
Mark Doliner <mark@kingant.net>
parents:
18056
diff
changeset
|
3663 GTK_IMHTML_ANIMATION(im_image)->anim = anim; |
1f6599cd2d2b
When an animated image is inserted into a conversation window, animate
Mark Doliner <mark@kingant.net>
parents:
18056
diff
changeset
|
3664 if (gdk_pixbuf_animation_is_static_image(anim)) { |
1f6599cd2d2b
When an animated image is inserted into a conversation window, animate
Mark Doliner <mark@kingant.net>
parents:
18056
diff
changeset
|
3665 im_image->pixbuf = gdk_pixbuf_animation_get_static_image(anim); |
20566
3ef40e8de6ab
Fix some crashes with animated smileys. Fixes #3179, #938, #3134, #2872, #1594
Daniel Atallah <daniel.atallah@gmail.com>
parents:
20074
diff
changeset
|
3666 g_object_ref(im_image->pixbuf); |
18089
1f6599cd2d2b
When an animated image is inserted into a conversation window, animate
Mark Doliner <mark@kingant.net>
parents:
18056
diff
changeset
|
3667 } else { |
1f6599cd2d2b
When an animated image is inserted into a conversation window, animate
Mark Doliner <mark@kingant.net>
parents:
18056
diff
changeset
|
3668 int delay; |
20566
3ef40e8de6ab
Fix some crashes with animated smileys. Fixes #3179, #938, #3134, #2872, #1594
Daniel Atallah <daniel.atallah@gmail.com>
parents:
20074
diff
changeset
|
3669 GdkPixbuf *pb; |
18089
1f6599cd2d2b
When an animated image is inserted into a conversation window, animate
Mark Doliner <mark@kingant.net>
parents:
18056
diff
changeset
|
3670 GTK_IMHTML_ANIMATION(im_image)->iter = gdk_pixbuf_animation_get_iter(anim, NULL); |
20566
3ef40e8de6ab
Fix some crashes with animated smileys. Fixes #3179, #938, #3134, #2872, #1594
Daniel Atallah <daniel.atallah@gmail.com>
parents:
20074
diff
changeset
|
3671 pb = gdk_pixbuf_animation_iter_get_pixbuf(GTK_IMHTML_ANIMATION(im_image)->iter); |
3ef40e8de6ab
Fix some crashes with animated smileys. Fixes #3179, #938, #3134, #2872, #1594
Daniel Atallah <daniel.atallah@gmail.com>
parents:
20074
diff
changeset
|
3672 im_image->pixbuf = gdk_pixbuf_copy(pb); |
18089
1f6599cd2d2b
When an animated image is inserted into a conversation window, animate
Mark Doliner <mark@kingant.net>
parents:
18056
diff
changeset
|
3673 delay = MIN(gdk_pixbuf_animation_iter_get_delay_time(GTK_IMHTML_ANIMATION(im_image)->iter), 100); |
1f6599cd2d2b
When an animated image is inserted into a conversation window, animate
Mark Doliner <mark@kingant.net>
parents:
18056
diff
changeset
|
3674 GTK_IMHTML_ANIMATION(im_image)->timer = g_timeout_add(delay, animate_image_cb, im_image); |
1f6599cd2d2b
When an animated image is inserted into a conversation window, animate
Mark Doliner <mark@kingant.net>
parents:
18056
diff
changeset
|
3675 } |
1f6599cd2d2b
When an animated image is inserted into a conversation window, animate
Mark Doliner <mark@kingant.net>
parents:
18056
diff
changeset
|
3676 im_image->image = GTK_IMAGE(gtk_image_new_from_pixbuf(im_image->pixbuf)); |
1f6599cd2d2b
When an animated image is inserted into a conversation window, animate
Mark Doliner <mark@kingant.net>
parents:
18056
diff
changeset
|
3677 im_image->width = gdk_pixbuf_animation_get_width(anim); |
1f6599cd2d2b
When an animated image is inserted into a conversation window, animate
Mark Doliner <mark@kingant.net>
parents:
18056
diff
changeset
|
3678 im_image->height = gdk_pixbuf_animation_get_height(anim); |
1f6599cd2d2b
When an animated image is inserted into a conversation window, animate
Mark Doliner <mark@kingant.net>
parents:
18056
diff
changeset
|
3679 im_image->filename = g_strdup(filename); |
1f6599cd2d2b
When an animated image is inserted into a conversation window, animate
Mark Doliner <mark@kingant.net>
parents:
18056
diff
changeset
|
3680 im_image->id = id; |
1f6599cd2d2b
When an animated image is inserted into a conversation window, animate
Mark Doliner <mark@kingant.net>
parents:
18056
diff
changeset
|
3681 |
1f6599cd2d2b
When an animated image is inserted into a conversation window, animate
Mark Doliner <mark@kingant.net>
parents:
18056
diff
changeset
|
3682 g_object_ref(anim); |
1f6599cd2d2b
When an animated image is inserted into a conversation window, animate
Mark Doliner <mark@kingant.net>
parents:
18056
diff
changeset
|
3683 |
1f6599cd2d2b
When an animated image is inserted into a conversation window, animate
Mark Doliner <mark@kingant.net>
parents:
18056
diff
changeset
|
3684 return GTK_IMHTML_SCALABLE(im_image); |
1f6599cd2d2b
When an animated image is inserted into a conversation window, animate
Mark Doliner <mark@kingant.net>
parents:
18056
diff
changeset
|
3685 } |
1f6599cd2d2b
When an animated image is inserted into a conversation window, animate
Mark Doliner <mark@kingant.net>
parents:
18056
diff
changeset
|
3686 |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3687 void gtk_imhtml_image_scale(GtkIMHtmlScalable *scale, int width, int height) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3688 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3689 GtkIMHtmlImage *im_image = (GtkIMHtmlImage *)scale; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3690 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3691 if (im_image->width > width || im_image->height > height) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3692 double ratio_w, ratio_h, ratio; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3693 int new_h, new_w; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3694 GdkPixbuf *new_image = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3695 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3696 ratio_w = ((double)width - 2) / im_image->width; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3697 ratio_h = ((double)height - 2) / im_image->height; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3698 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3699 ratio = (ratio_w < ratio_h) ? ratio_w : ratio_h; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3700 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3701 new_w = (int)(im_image->width * ratio); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3702 new_h = (int)(im_image->height * ratio); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3703 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3704 new_image = gdk_pixbuf_scale_simple(im_image->pixbuf, new_w, new_h, GDK_INTERP_BILINEAR); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3705 gtk_image_set_from_pixbuf(im_image->image, new_image); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3706 g_object_unref(G_OBJECT(new_image)); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3707 } else if (gdk_pixbuf_get_width(gtk_image_get_pixbuf(im_image->image)) != im_image->width) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3708 /* Enough space to show the full-size of the image. */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3709 GdkPixbuf *new_image; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3710 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3711 new_image = gdk_pixbuf_scale_simple(im_image->pixbuf, im_image->width, im_image->height, GDK_INTERP_BILINEAR); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3712 gtk_image_set_from_pixbuf(im_image->image, new_image); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3713 g_object_unref(G_OBJECT(new_image)); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3714 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3715 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3716 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3717 static void |
26965
655013f05eaa
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
26964
diff
changeset
|
3718 image_save_yes_cb(GtkIMHtmlImageSave *save, const char *filename) |
655013f05eaa
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
26964
diff
changeset
|
3719 { |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3720 GError *error = NULL; |
26965
655013f05eaa
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
26964
diff
changeset
|
3721 GtkIMHtmlImage *image = (GtkIMHtmlImage *)save->image; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3722 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3723 gtk_widget_destroy(image->filesel); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3724 image->filesel = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3725 |
26965
655013f05eaa
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
26964
diff
changeset
|
3726 if (save->data && save->datasize) { |
655013f05eaa
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
26964
diff
changeset
|
3727 g_file_set_contents(filename, save->data, save->datasize, &error); |
655013f05eaa
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
26964
diff
changeset
|
3728 } else { |
655013f05eaa
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
26964
diff
changeset
|
3729 gchar *type = NULL; |
655013f05eaa
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
26964
diff
changeset
|
3730 GSList *formats = gdk_pixbuf_get_formats(); |
655013f05eaa
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
26964
diff
changeset
|
3731 char *newfilename; |
655013f05eaa
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
26964
diff
changeset
|
3732 |
655013f05eaa
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
26964
diff
changeset
|
3733 while (formats) { |
655013f05eaa
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
26964
diff
changeset
|
3734 GdkPixbufFormat *format = formats->data; |
655013f05eaa
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
26964
diff
changeset
|
3735 gchar **extensions = gdk_pixbuf_format_get_extensions(format); |
655013f05eaa
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
26964
diff
changeset
|
3736 gpointer p = extensions; |
655013f05eaa
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
26964
diff
changeset
|
3737 |
655013f05eaa
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
26964
diff
changeset
|
3738 while(gdk_pixbuf_format_is_writable(format) && extensions && extensions[0]){ |
655013f05eaa
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
26964
diff
changeset
|
3739 gchar *fmt_ext = extensions[0]; |
655013f05eaa
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
26964
diff
changeset
|
3740 const gchar* file_ext = filename + strlen(filename) - strlen(fmt_ext); |
655013f05eaa
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
26964
diff
changeset
|
3741 |
655013f05eaa
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
26964
diff
changeset
|
3742 if(!g_ascii_strcasecmp(fmt_ext, file_ext)){ |
655013f05eaa
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
26964
diff
changeset
|
3743 type = gdk_pixbuf_format_get_name(format); |
655013f05eaa
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
26964
diff
changeset
|
3744 break; |
655013f05eaa
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
26964
diff
changeset
|
3745 } |
655013f05eaa
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
26964
diff
changeset
|
3746 |
655013f05eaa
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
26964
diff
changeset
|
3747 extensions++; |
655013f05eaa
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
26964
diff
changeset
|
3748 } |
655013f05eaa
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
26964
diff
changeset
|
3749 |
655013f05eaa
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
26964
diff
changeset
|
3750 g_strfreev(p); |
655013f05eaa
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
26964
diff
changeset
|
3751 |
655013f05eaa
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
26964
diff
changeset
|
3752 if (type) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3753 break; |
26965
655013f05eaa
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
26964
diff
changeset
|
3754 |
655013f05eaa
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
26964
diff
changeset
|
3755 formats = formats->next; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3756 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3757 |
26965
655013f05eaa
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
26964
diff
changeset
|
3758 g_slist_free(formats); |
655013f05eaa
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
26964
diff
changeset
|
3759 |
655013f05eaa
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
26964
diff
changeset
|
3760 /* If I can't find a valid type, I will just tell the user about it and then assume |
655013f05eaa
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
26964
diff
changeset
|
3761 it's a png */ |
655013f05eaa
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
26964
diff
changeset
|
3762 if (!type){ |
655013f05eaa
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
26964
diff
changeset
|
3763 char *basename, *tmp; |
26972
126ad6235023
Preserve the location when defaulting to png for saving unsupported image format.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
26965
diff
changeset
|
3764 char *dirname; |
26965
655013f05eaa
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
26964
diff
changeset
|
3765 GtkWidget *dialog = gtk_message_dialog_new_with_markup(NULL, 0, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, |
655013f05eaa
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
26964
diff
changeset
|
3766 _("<span size='larger' weight='bold'>Unrecognized file type</span>\n\nDefaulting to PNG.")); |
655013f05eaa
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
26964
diff
changeset
|
3767 |
655013f05eaa
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
26964
diff
changeset
|
3768 g_signal_connect_swapped(dialog, "response", G_CALLBACK (gtk_widget_destroy), dialog); |
655013f05eaa
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
26964
diff
changeset
|
3769 gtk_widget_show(dialog); |
655013f05eaa
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
26964
diff
changeset
|
3770 |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3771 type = g_strdup("png"); |
26972
126ad6235023
Preserve the location when defaulting to png for saving unsupported image format.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
26965
diff
changeset
|
3772 dirname = g_path_get_dirname(filename); |
26965
655013f05eaa
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
26964
diff
changeset
|
3773 basename = g_path_get_basename(filename); |
655013f05eaa
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
26964
diff
changeset
|
3774 tmp = strrchr(basename, '.'); |
655013f05eaa
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
26964
diff
changeset
|
3775 if (tmp != NULL) |
655013f05eaa
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
26964
diff
changeset
|
3776 tmp[0] = '\0'; |
26972
126ad6235023
Preserve the location when defaulting to png for saving unsupported image format.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
26965
diff
changeset
|
3777 newfilename = g_strdup_printf("%s" G_DIR_SEPARATOR_S "%s.png", dirname, basename); |
126ad6235023
Preserve the location when defaulting to png for saving unsupported image format.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
26965
diff
changeset
|
3778 g_free(dirname); |
26965
655013f05eaa
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
26964
diff
changeset
|
3779 g_free(basename); |
655013f05eaa
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
26964
diff
changeset
|
3780 } else { |
655013f05eaa
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
26964
diff
changeset
|
3781 /* |
655013f05eaa
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
26964
diff
changeset
|
3782 * We're able to save the file in it's original format, so we |
655013f05eaa
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
26964
diff
changeset
|
3783 * can use the original file name. |
655013f05eaa
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
26964
diff
changeset
|
3784 */ |
655013f05eaa
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
26964
diff
changeset
|
3785 newfilename = g_strdup(filename); |
655013f05eaa
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
26964
diff
changeset
|
3786 } |
655013f05eaa
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
26964
diff
changeset
|
3787 |
655013f05eaa
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
26964
diff
changeset
|
3788 gdk_pixbuf_save(image->pixbuf, newfilename, type, &error, NULL); |
655013f05eaa
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
26964
diff
changeset
|
3789 |
655013f05eaa
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
26964
diff
changeset
|
3790 g_free(newfilename); |
655013f05eaa
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
26964
diff
changeset
|
3791 g_free(type); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3792 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3793 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3794 if (error){ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3795 GtkWidget *dialog = gtk_message_dialog_new_with_markup(NULL, 0, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3796 _("<span size='larger' weight='bold'>Error saving image</span>\n\n%s"), error->message); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3797 g_signal_connect_swapped(dialog, "response", G_CALLBACK (gtk_widget_destroy), dialog); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3798 gtk_widget_show(dialog); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3799 g_error_free(error); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3800 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3801 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3802 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3803 static void |
26965
655013f05eaa
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
26964
diff
changeset
|
3804 image_save_check_if_exists_cb(GtkWidget *widget, gint response, GtkIMHtmlImageSave *save) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3805 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3806 gchar *filename; |
26965
655013f05eaa
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
26964
diff
changeset
|
3807 GtkIMHtmlImage *image = (GtkIMHtmlImage *)save->image; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3808 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3809 if (response != GTK_RESPONSE_ACCEPT) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3810 gtk_widget_destroy(widget); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3811 image->filesel = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3812 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3813 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3814 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3815 filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(widget)); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3816 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3817 /* |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3818 * XXX - We should probably prompt the user to determine if they really |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3819 * want to overwrite the file or not. However, I don't feel like doing |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3820 * that, so we're just always going to overwrite if the file exists. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3821 */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3822 /* |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3823 if (g_file_test(filename, G_FILE_TEST_EXISTS)) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3824 } else |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3825 image_save_yes_cb(image, filename); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3826 */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3827 |
26965
655013f05eaa
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
26964
diff
changeset
|
3828 image_save_yes_cb(save, filename); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3829 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3830 g_free(filename); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3831 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3832 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3833 static void |
26965
655013f05eaa
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
26964
diff
changeset
|
3834 gtk_imhtml_image_save(GtkWidget *w, GtkIMHtmlImageSave *save) |
655013f05eaa
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
26964
diff
changeset
|
3835 { |
655013f05eaa
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
26964
diff
changeset
|
3836 GtkIMHtmlImage *image = (GtkIMHtmlImage *)save->image; |
655013f05eaa
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
26964
diff
changeset
|
3837 |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3838 if (image->filesel != NULL) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3839 gtk_window_present(GTK_WINDOW(image->filesel)); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3840 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3841 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3842 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3843 image->filesel = gtk_file_chooser_dialog_new(_("Save Image"), |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3844 NULL, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3845 GTK_FILE_CHOOSER_ACTION_SAVE, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3846 GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3847 GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3848 NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3849 gtk_dialog_set_default_response(GTK_DIALOG(image->filesel), GTK_RESPONSE_ACCEPT); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3850 if (image->filename != NULL) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3851 gtk_file_chooser_set_current_name(GTK_FILE_CHOOSER(image->filesel), image->filename); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3852 g_signal_connect(G_OBJECT(GTK_FILE_CHOOSER(image->filesel)), "response", |
26965
655013f05eaa
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
26964
diff
changeset
|
3853 G_CALLBACK(image_save_check_if_exists_cb), save); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3854 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3855 gtk_widget_show(image->filesel); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3856 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3857 |
23163
99ef50c8da91
Modified patch from malu to "Add context menu alternative to add received
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23161
diff
changeset
|
3858 static void |
27120
804141095de5
Allow adding received animated custom smileys to locale custom smiley
Andrea Piccinelli <frasten@gmail.com>
parents:
27032
diff
changeset
|
3859 gtk_imhtml_custom_smiley_save(GtkWidget *w, GtkIMHtmlImageSave *save) |
804141095de5
Allow adding received animated custom smileys to locale custom smiley
Andrea Piccinelli <frasten@gmail.com>
parents:
27032
diff
changeset
|
3860 { |
804141095de5
Allow adding received animated custom smileys to locale custom smiley
Andrea Piccinelli <frasten@gmail.com>
parents:
27032
diff
changeset
|
3861 GtkIMHtmlImage *image = (GtkIMHtmlImage *)save->image; |
31534
a8cc50c2279f
Remove trailing whitespace
Richard Laager <rlaager@wiktel.com>
parents:
31451
diff
changeset
|
3862 |
23163
99ef50c8da91
Modified patch from malu to "Add context menu alternative to add received
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23161
diff
changeset
|
3863 /* Create an add dialog */ |
99ef50c8da91
Modified patch from malu to "Add context menu alternative to add received
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23161
diff
changeset
|
3864 PidginSmiley *editor = pidgin_smiley_edit(NULL, NULL); |
99ef50c8da91
Modified patch from malu to "Add context menu alternative to add received
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23161
diff
changeset
|
3865 pidgin_smiley_editor_set_shortcut(editor, image->filename); |
99ef50c8da91
Modified patch from malu to "Add context menu alternative to add received
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23161
diff
changeset
|
3866 pidgin_smiley_editor_set_image(editor, image->pixbuf); |
27120
804141095de5
Allow adding received animated custom smileys to locale custom smiley
Andrea Piccinelli <frasten@gmail.com>
parents:
27032
diff
changeset
|
3867 pidgin_smiley_editor_set_data(editor, save->data, save->datasize); |
23163
99ef50c8da91
Modified patch from malu to "Add context menu alternative to add received
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23161
diff
changeset
|
3868 } |
99ef50c8da91
Modified patch from malu to "Add context menu alternative to add received
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23161
diff
changeset
|
3869 |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3870 /* |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3871 * So, um, AIM Direct IM lets you send any file, not just images. You can |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3872 * just insert a sound or a file or whatever in a conversation. It's |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3873 * basically like file transfer, except there is an icon to open the file |
15823 | 3874 * embedded in the conversation. Someone should make the Purple core handle |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3875 * all of that. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3876 */ |
26965
655013f05eaa
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
26964
diff
changeset
|
3877 static gboolean gtk_imhtml_image_clicked(GtkWidget *w, GdkEvent *event, GtkIMHtmlImageSave *save) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3878 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3879 GdkEventButton *event_button = (GdkEventButton *) event; |
26965
655013f05eaa
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
26964
diff
changeset
|
3880 GtkIMHtmlImage *image = (GtkIMHtmlImage *)save->image; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3881 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3882 if (event->type == GDK_BUTTON_RELEASE) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3883 if(event_button->button == 3) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3884 GtkWidget *img, *item, *menu; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3885 menu = gtk_menu_new(); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3886 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3887 /* buttons and such */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3888 img = gtk_image_new_from_stock(GTK_STOCK_SAVE, GTK_ICON_SIZE_MENU); |
26964
8c1816137194
Avoid unnecessary strdup's.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
26961
diff
changeset
|
3889 item = gtk_image_menu_item_new_with_mnemonic(_("_Save Image...")); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3890 gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(item), img); |
26965
655013f05eaa
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
26964
diff
changeset
|
3891 g_signal_connect(G_OBJECT(item), "activate", G_CALLBACK(gtk_imhtml_image_save), save); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3892 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3893 |
23163
99ef50c8da91
Modified patch from malu to "Add context menu alternative to add received
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23161
diff
changeset
|
3894 /* Add menu item for adding custom smiley to local smileys */ |
99ef50c8da91
Modified patch from malu to "Add context menu alternative to add received
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23161
diff
changeset
|
3895 /* we only add the menu if the image is of "custom smiley size" |
99ef50c8da91
Modified patch from malu to "Add context menu alternative to add received
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23161
diff
changeset
|
3896 <= 96x96 pixels */ |
99ef50c8da91
Modified patch from malu to "Add context menu alternative to add received
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23161
diff
changeset
|
3897 if (image->width <= 96 && image->height <= 96) { |
99ef50c8da91
Modified patch from malu to "Add context menu alternative to add received
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23161
diff
changeset
|
3898 img = gtk_image_new_from_stock(GTK_STOCK_ADD, GTK_ICON_SIZE_MENU); |
26964
8c1816137194
Avoid unnecessary strdup's.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
26961
diff
changeset
|
3899 item = gtk_image_menu_item_new_with_mnemonic(_("_Add Custom Smiley...")); |
23163
99ef50c8da91
Modified patch from malu to "Add context menu alternative to add received
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23161
diff
changeset
|
3900 gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(item), img); |
99ef50c8da91
Modified patch from malu to "Add context menu alternative to add received
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23161
diff
changeset
|
3901 g_signal_connect(G_OBJECT(item), "activate", |
27120
804141095de5
Allow adding received animated custom smileys to locale custom smiley
Andrea Piccinelli <frasten@gmail.com>
parents:
27032
diff
changeset
|
3902 G_CALLBACK(gtk_imhtml_custom_smiley_save), save); |
23163
99ef50c8da91
Modified patch from malu to "Add context menu alternative to add received
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23161
diff
changeset
|
3903 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); |
99ef50c8da91
Modified patch from malu to "Add context menu alternative to add received
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23161
diff
changeset
|
3904 } |
99ef50c8da91
Modified patch from malu to "Add context menu alternative to add received
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23161
diff
changeset
|
3905 |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3906 gtk_widget_show_all(menu); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3907 gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3908 event_button->button, event_button->time); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3909 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3910 return TRUE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3911 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3912 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3913 if(event->type == GDK_BUTTON_PRESS && event_button->button == 3) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3914 return TRUE; /* Clicking the right mouse button on a link shouldn't |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3915 be caught by the regular GtkTextView menu */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3916 else |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3917 return FALSE; /* Let clicks go through if we didn't catch anything */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3918 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3919 } |
16964
ab45289d2c36
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 <imadil@gmail.com>
parents:
16309
diff
changeset
|
3920 |
ab45289d2c36
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 <imadil@gmail.com>
parents:
16309
diff
changeset
|
3921 static gboolean gtk_imhtml_smiley_clicked(GtkWidget *w, GdkEvent *event, GtkIMHtmlSmiley *smiley) |
ab45289d2c36
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 <imadil@gmail.com>
parents:
16309
diff
changeset
|
3922 { |
ab45289d2c36
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 <imadil@gmail.com>
parents:
16309
diff
changeset
|
3923 GdkPixbufAnimation *anim = NULL; |
26965
655013f05eaa
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
26964
diff
changeset
|
3924 GtkIMHtmlImageSave *save = NULL; |
16964
ab45289d2c36
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 <imadil@gmail.com>
parents:
16309
diff
changeset
|
3925 gboolean ret; |
23163
99ef50c8da91
Modified patch from malu to "Add context menu alternative to add received
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23161
diff
changeset
|
3926 |
16964
ab45289d2c36
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 <imadil@gmail.com>
parents:
16309
diff
changeset
|
3927 if (event->type != GDK_BUTTON_RELEASE || ((GdkEventButton*)event)->button != 3) |
ab45289d2c36
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 <imadil@gmail.com>
parents:
16309
diff
changeset
|
3928 return FALSE; |
ab45289d2c36
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 <imadil@gmail.com>
parents:
16309
diff
changeset
|
3929 |
ab45289d2c36
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 <imadil@gmail.com>
parents:
16309
diff
changeset
|
3930 anim = gtk_smiley_get_image(smiley); |
ab45289d2c36
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 <imadil@gmail.com>
parents:
16309
diff
changeset
|
3931 if (!anim) |
ab45289d2c36
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 <imadil@gmail.com>
parents:
16309
diff
changeset
|
3932 return FALSE; |
ab45289d2c36
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 <imadil@gmail.com>
parents:
16309
diff
changeset
|
3933 |
26965
655013f05eaa
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
26964
diff
changeset
|
3934 save = g_new0(GtkIMHtmlImageSave, 1); |
655013f05eaa
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
26964
diff
changeset
|
3935 save->image = (GtkIMHtmlScalable *)gtk_imhtml_animation_new(anim, smiley->smile, 0); |
655013f05eaa
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
26964
diff
changeset
|
3936 save->data = smiley->data; /* Do not need to memdup here, since the smiley is not |
655013f05eaa
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
26964
diff
changeset
|
3937 destroyed before this GtkIMHtmlImageSave */ |
655013f05eaa
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
26964
diff
changeset
|
3938 save->datasize = smiley->datasize; |
655013f05eaa
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
26964
diff
changeset
|
3939 ret = gtk_imhtml_image_clicked(w, event, save); |
655013f05eaa
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
26964
diff
changeset
|
3940 g_object_set_data_full(G_OBJECT(w), "image-data", save->image, (GDestroyNotify)gtk_imhtml_animation_free); |
655013f05eaa
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
26964
diff
changeset
|
3941 g_object_set_data_full(G_OBJECT(w), "image-save-data", save, (GDestroyNotify)g_free); |
16964
ab45289d2c36
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 <imadil@gmail.com>
parents:
16309
diff
changeset
|
3942 return ret; |
ab45289d2c36
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 <imadil@gmail.com>
parents:
16309
diff
changeset
|
3943 } |
ab45289d2c36
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 <imadil@gmail.com>
parents:
16309
diff
changeset
|
3944 |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3945 void gtk_imhtml_image_free(GtkIMHtmlScalable *scale) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3946 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3947 GtkIMHtmlImage *image = (GtkIMHtmlImage *)scale; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3948 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3949 g_object_unref(image->pixbuf); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3950 g_free(image->filename); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3951 if (image->filesel) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3952 gtk_widget_destroy(image->filesel); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3953 g_free(scale); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3954 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3955 |
18089
1f6599cd2d2b
When an animated image is inserted into a conversation window, animate
Mark Doliner <mark@kingant.net>
parents:
18056
diff
changeset
|
3956 void gtk_imhtml_animation_free(GtkIMHtmlScalable *scale) |
1f6599cd2d2b
When an animated image is inserted into a conversation window, animate
Mark Doliner <mark@kingant.net>
parents:
18056
diff
changeset
|
3957 { |
1f6599cd2d2b
When an animated image is inserted into a conversation window, animate
Mark Doliner <mark@kingant.net>
parents:
18056
diff
changeset
|
3958 GtkIMHtmlAnimation *animation = (GtkIMHtmlAnimation *)scale; |
1f6599cd2d2b
When an animated image is inserted into a conversation window, animate
Mark Doliner <mark@kingant.net>
parents:
18056
diff
changeset
|
3959 |
1f6599cd2d2b
When an animated image is inserted into a conversation window, animate
Mark Doliner <mark@kingant.net>
parents:
18056
diff
changeset
|
3960 if (animation->timer > 0) |
1f6599cd2d2b
When an animated image is inserted into a conversation window, animate
Mark Doliner <mark@kingant.net>
parents:
18056
diff
changeset
|
3961 g_source_remove(animation->timer); |
1f6599cd2d2b
When an animated image is inserted into a conversation window, animate
Mark Doliner <mark@kingant.net>
parents:
18056
diff
changeset
|
3962 if (animation->iter != NULL) |
1f6599cd2d2b
When an animated image is inserted into a conversation window, animate
Mark Doliner <mark@kingant.net>
parents:
18056
diff
changeset
|
3963 g_object_unref(animation->iter); |
1f6599cd2d2b
When an animated image is inserted into a conversation window, animate
Mark Doliner <mark@kingant.net>
parents:
18056
diff
changeset
|
3964 g_object_unref(animation->anim); |
1f6599cd2d2b
When an animated image is inserted into a conversation window, animate
Mark Doliner <mark@kingant.net>
parents:
18056
diff
changeset
|
3965 |
1f6599cd2d2b
When an animated image is inserted into a conversation window, animate
Mark Doliner <mark@kingant.net>
parents:
18056
diff
changeset
|
3966 gtk_imhtml_image_free(scale); |
1f6599cd2d2b
When an animated image is inserted into a conversation window, animate
Mark Doliner <mark@kingant.net>
parents:
18056
diff
changeset
|
3967 } |
1f6599cd2d2b
When an animated image is inserted into a conversation window, animate
Mark Doliner <mark@kingant.net>
parents:
18056
diff
changeset
|
3968 |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3969 void gtk_imhtml_image_add_to(GtkIMHtmlScalable *scale, GtkIMHtml *imhtml, GtkTextIter *iter) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3970 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3971 GtkIMHtmlImage *image = (GtkIMHtmlImage *)scale; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3972 GtkWidget *box = gtk_event_box_new(); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3973 char *tag; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3974 GtkTextChildAnchor *anchor = gtk_text_buffer_create_child_anchor(imhtml->text_buffer, iter); |
26965
655013f05eaa
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
26964
diff
changeset
|
3975 GtkIMHtmlImageSave *save; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3976 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3977 gtk_container_add(GTK_CONTAINER(box), GTK_WIDGET(image->image)); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3978 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3979 if(!gtk_check_version(2, 4, 0)) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3980 g_object_set(G_OBJECT(box), "visible-window", FALSE, NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3981 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3982 gtk_widget_show(GTK_WIDGET(image->image)); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3983 gtk_widget_show(box); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3984 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3985 tag = g_strdup_printf("<IMG ID=\"%d\">", image->id); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3986 g_object_set_data_full(G_OBJECT(anchor), "gtkimhtml_htmltext", tag, g_free); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3987 g_object_set_data(G_OBJECT(anchor), "gtkimhtml_plaintext", "[Image]"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3988 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3989 gtk_text_view_add_child_at_anchor(GTK_TEXT_VIEW(imhtml), box, anchor); |
26965
655013f05eaa
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
26964
diff
changeset
|
3990 |
655013f05eaa
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
26964
diff
changeset
|
3991 save = g_new0(GtkIMHtmlImageSave, 1); |
655013f05eaa
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
26964
diff
changeset
|
3992 save->image = scale; |
655013f05eaa
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
26964
diff
changeset
|
3993 g_signal_connect(G_OBJECT(box), "event", G_CALLBACK(gtk_imhtml_image_clicked), save); |
655013f05eaa
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
26964
diff
changeset
|
3994 g_object_set_data_full(G_OBJECT(box), "image-save-data", save, (GDestroyNotify)g_free); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3995 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3996 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3997 GtkIMHtmlScalable *gtk_imhtml_hr_new() |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3998 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
3999 GtkIMHtmlHr *hr = g_malloc(sizeof(GtkIMHtmlHr)); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4000 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4001 GTK_IMHTML_SCALABLE(hr)->scale = gtk_imhtml_hr_scale; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4002 GTK_IMHTML_SCALABLE(hr)->add_to = gtk_imhtml_hr_add_to; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4003 GTK_IMHTML_SCALABLE(hr)->free = gtk_imhtml_hr_free; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4004 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4005 hr->sep = gtk_hseparator_new(); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4006 gtk_widget_set_size_request(hr->sep, 5000, 2); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4007 gtk_widget_show(hr->sep); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4008 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4009 return GTK_IMHTML_SCALABLE(hr); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4010 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4011 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4012 void gtk_imhtml_hr_scale(GtkIMHtmlScalable *scale, int width, int height) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4013 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4014 gtk_widget_set_size_request(((GtkIMHtmlHr *)scale)->sep, width - 2, 2); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4015 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4016 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4017 void gtk_imhtml_hr_add_to(GtkIMHtmlScalable *scale, GtkIMHtml *imhtml, GtkTextIter *iter) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4018 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4019 GtkIMHtmlHr *hr = (GtkIMHtmlHr *)scale; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4020 GtkTextChildAnchor *anchor = gtk_text_buffer_create_child_anchor(imhtml->text_buffer, iter); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4021 g_object_set_data(G_OBJECT(anchor), "gtkimhtml_htmltext", "<hr>"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4022 g_object_set_data(G_OBJECT(anchor), "gtkimhtml_plaintext", "\n---\n"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4023 gtk_text_view_add_child_at_anchor(GTK_TEXT_VIEW(imhtml), hr->sep, anchor); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4024 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4025 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4026 void gtk_imhtml_hr_free(GtkIMHtmlScalable *scale) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4027 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4028 g_free(scale); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4029 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4030 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4031 gboolean gtk_imhtml_search_find(GtkIMHtml *imhtml, const gchar *text) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4032 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4033 GtkTextIter iter, start, end; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4034 gboolean new_search = TRUE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4035 GtkTextMark *start_mark; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4036 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4037 g_return_val_if_fail(imhtml != NULL, FALSE); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4038 g_return_val_if_fail(text != NULL, FALSE); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4039 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4040 start_mark = gtk_text_buffer_get_mark(imhtml->text_buffer, "search"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4041 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4042 if (start_mark && imhtml->search_string && !strcmp(text, imhtml->search_string)) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4043 new_search = FALSE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4044 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4045 if (new_search) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4046 gtk_imhtml_search_clear(imhtml); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4047 g_free(imhtml->search_string); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4048 imhtml->search_string = g_strdup(text); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4049 gtk_text_buffer_get_end_iter(imhtml->text_buffer, &iter); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4050 } else { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4051 gtk_text_buffer_get_iter_at_mark(imhtml->text_buffer, &iter, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4052 start_mark); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4053 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4054 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4055 if (gtk_source_iter_backward_search(&iter, imhtml->search_string, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4056 GTK_SOURCE_SEARCH_VISIBLE_ONLY | GTK_SOURCE_SEARCH_CASE_INSENSITIVE, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4057 &start, &end, NULL)) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4058 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4059 gtk_text_view_scroll_to_iter(GTK_TEXT_VIEW(imhtml), &start, 0, TRUE, 0, 0); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4060 gtk_text_buffer_create_mark(imhtml->text_buffer, "search", &start, FALSE); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4061 if (new_search) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4062 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4063 gtk_text_buffer_remove_tag_by_name(imhtml->text_buffer, "search", &iter, &end); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4064 do |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4065 gtk_text_buffer_apply_tag_by_name(imhtml->text_buffer, "search", &start, &end); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4066 while (gtk_source_iter_backward_search(&start, imhtml->search_string, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4067 GTK_SOURCE_SEARCH_VISIBLE_ONLY | |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4068 GTK_SOURCE_SEARCH_CASE_INSENSITIVE, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4069 &start, &end, NULL)); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4070 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4071 return TRUE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4072 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4073 else if (!new_search) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4074 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4075 /* We hit the end, so start at the beginning again. */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4076 gtk_text_buffer_get_end_iter(imhtml->text_buffer, &iter); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4077 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4078 if (gtk_source_iter_backward_search(&iter, imhtml->search_string, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4079 GTK_SOURCE_SEARCH_VISIBLE_ONLY | GTK_SOURCE_SEARCH_CASE_INSENSITIVE, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4080 &start, &end, NULL)) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4081 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4082 gtk_text_view_scroll_to_iter(GTK_TEXT_VIEW(imhtml), &start, 0, TRUE, 0, 0); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4083 gtk_text_buffer_create_mark(imhtml->text_buffer, "search", &start, FALSE); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4084 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4085 return TRUE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4086 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4087 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4088 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4089 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4090 return FALSE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4091 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4092 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4093 void gtk_imhtml_search_clear(GtkIMHtml *imhtml) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4094 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4095 GtkTextIter start, end; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4096 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4097 g_return_if_fail(imhtml != NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4098 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4099 gtk_text_buffer_get_start_iter(imhtml->text_buffer, &start); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4100 gtk_text_buffer_get_end_iter(imhtml->text_buffer, &end); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4101 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4102 gtk_text_buffer_remove_tag_by_name(imhtml->text_buffer, "search", &start, &end); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4103 g_free(imhtml->search_string); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4104 imhtml->search_string = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4105 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4106 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4107 static GtkTextTag *find_font_forecolor_tag(GtkIMHtml *imhtml, gchar *color) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4108 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4109 gchar str[18]; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4110 GtkTextTag *tag; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4111 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4112 g_snprintf(str, sizeof(str), "FORECOLOR %s", color); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4113 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4114 tag = gtk_text_tag_table_lookup(gtk_text_buffer_get_tag_table(imhtml->text_buffer), str); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4115 if (!tag) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4116 GdkColor gcolor; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4117 if (!gdk_color_parse(color, &gcolor)) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4118 gchar tmp[8]; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4119 tmp[0] = '#'; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4120 strncpy(&tmp[1], color, 7); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4121 tmp[7] = '\0'; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4122 if (!gdk_color_parse(tmp, &gcolor)) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4123 gdk_color_parse("black", &gcolor); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4124 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4125 tag = gtk_text_buffer_create_tag(imhtml->text_buffer, str, "foreground-gdk", &gcolor, NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4126 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4127 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4128 return tag; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4129 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4130 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4131 static GtkTextTag *find_font_backcolor_tag(GtkIMHtml *imhtml, gchar *color) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4132 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4133 gchar str[18]; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4134 GtkTextTag *tag; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4135 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4136 g_snprintf(str, sizeof(str), "BACKCOLOR %s", color); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4137 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4138 tag = gtk_text_tag_table_lookup(gtk_text_buffer_get_tag_table(imhtml->text_buffer), str); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4139 if (!tag) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4140 GdkColor gcolor; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4141 if (!gdk_color_parse(color, &gcolor)) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4142 gchar tmp[8]; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4143 tmp[0] = '#'; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4144 strncpy(&tmp[1], color, 7); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4145 tmp[7] = '\0'; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4146 if (!gdk_color_parse(tmp, &gcolor)) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4147 gdk_color_parse("white", &gcolor); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4148 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4149 tag = gtk_text_buffer_create_tag(imhtml->text_buffer, str, "background-gdk", &gcolor, NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4150 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4151 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4152 return tag; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4153 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4154 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4155 static GtkTextTag *find_font_background_tag(GtkIMHtml *imhtml, gchar *color) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4156 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4157 gchar str[19]; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4158 GtkTextTag *tag; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4159 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4160 g_snprintf(str, sizeof(str), "BACKGROUND %s", color); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4161 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4162 tag = gtk_text_tag_table_lookup(gtk_text_buffer_get_tag_table(imhtml->text_buffer), str); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4163 if (!tag) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4164 tag = gtk_text_buffer_create_tag(imhtml->text_buffer, str, NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4165 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4166 return tag; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4167 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4168 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4169 static GtkTextTag *find_font_face_tag(GtkIMHtml *imhtml, gchar *face) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4170 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4171 gchar str[256]; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4172 GtkTextTag *tag; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4173 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4174 g_snprintf(str, sizeof(str), "FONT FACE %s", face); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4175 str[255] = '\0'; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4176 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4177 tag = gtk_text_tag_table_lookup(gtk_text_buffer_get_tag_table(imhtml->text_buffer), str); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4178 if (!tag) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4179 tag = gtk_text_buffer_create_tag(imhtml->text_buffer, str, "family", face, NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4180 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4181 return tag; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4182 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4183 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4184 static GtkTextTag *find_font_size_tag(GtkIMHtml *imhtml, int size) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4185 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4186 gchar str[24]; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4187 GtkTextTag *tag; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4188 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4189 g_snprintf(str, sizeof(str), "FONT SIZE %d", size); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4190 str[23] = '\0'; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4191 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4192 tag = gtk_text_tag_table_lookup(gtk_text_buffer_get_tag_table(imhtml->text_buffer), str); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4193 if (!tag) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4194 /* For reasons I don't understand, setting "scale" here scaled |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4195 * based on some default size other than my theme's default |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4196 * size. Our size 4 was actually smaller than our size 3 for |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4197 * me. So this works around that oddity. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4198 */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4199 GtkTextAttributes *attr = gtk_text_view_get_default_attributes(GTK_TEXT_VIEW(imhtml)); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4200 tag = gtk_text_buffer_create_tag(imhtml->text_buffer, str, "size", |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4201 (gint) (pango_font_description_get_size(attr->font) * |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4202 (double) POINT_SIZE(size)), NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4203 gtk_text_attributes_unref(attr); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4204 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4205 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4206 return tag; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4207 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4208 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4209 static void remove_tag_by_prefix(GtkIMHtml *imhtml, const GtkTextIter *i, const GtkTextIter *e, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4210 const char *prefix, guint len, gboolean homo) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4211 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4212 GSList *tags, *l; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4213 GtkTextIter iter; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4214 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4215 tags = gtk_text_iter_get_tags(i); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4216 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4217 for (l = tags; l; l = l->next) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4218 GtkTextTag *tag = l->data; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4219 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4220 if (tag->name && !strncmp(tag->name, prefix, len)) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4221 gtk_text_buffer_remove_tag(imhtml->text_buffer, tag, i, e); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4222 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4223 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4224 g_slist_free(tags); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4225 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4226 if (homo) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4227 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4228 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4229 iter = *i; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4230 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4231 while (gtk_text_iter_forward_char(&iter) && !gtk_text_iter_equal(&iter, e)) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4232 if (gtk_text_iter_begins_tag(&iter, NULL)) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4233 tags = gtk_text_iter_get_toggled_tags(&iter, TRUE); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4234 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4235 for (l = tags; l; l = l->next) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4236 GtkTextTag *tag = l->data; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4237 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4238 if (tag->name && !strncmp(tag->name, prefix, len)) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4239 gtk_text_buffer_remove_tag(imhtml->text_buffer, tag, &iter, e); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4240 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4241 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4242 g_slist_free(tags); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4243 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4244 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4245 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4246 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4247 static void remove_font_size(GtkIMHtml *imhtml, GtkTextIter *i, GtkTextIter *e, gboolean homo) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4248 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4249 remove_tag_by_prefix(imhtml, i, e, "FONT SIZE ", 10, homo); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4250 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4251 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4252 static void remove_font_face(GtkIMHtml *imhtml, GtkTextIter *i, GtkTextIter *e, gboolean homo) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4253 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4254 remove_tag_by_prefix(imhtml, i, e, "FONT FACE ", 10, homo); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4255 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4256 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4257 static void remove_font_forecolor(GtkIMHtml *imhtml, GtkTextIter *i, GtkTextIter *e, gboolean homo) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4258 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4259 remove_tag_by_prefix(imhtml, i, e, "FORECOLOR ", 10, homo); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4260 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4261 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4262 static void remove_font_backcolor(GtkIMHtml *imhtml, GtkTextIter *i, GtkTextIter *e, gboolean homo) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4263 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4264 remove_tag_by_prefix(imhtml, i, e, "BACKCOLOR ", 10, homo); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4265 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4266 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4267 static void remove_font_background(GtkIMHtml *imhtml, GtkTextIter *i, GtkTextIter *e, gboolean homo) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4268 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4269 remove_tag_by_prefix(imhtml, i, e, "BACKGROUND ", 10, homo); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4270 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4271 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4272 static void remove_font_link(GtkIMHtml *imhtml, GtkTextIter *i, GtkTextIter *e, gboolean homo) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4273 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4274 remove_tag_by_prefix(imhtml, i, e, "LINK ", 5, homo); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4275 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4276 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4277 static void |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4278 imhtml_clear_formatting(GtkIMHtml *imhtml) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4279 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4280 GtkTextIter start, end; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4281 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4282 if (!imhtml->editable) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4283 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4284 |
28982
a169c5c81ef5
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
28979
diff
changeset
|
4285 if (!imhtml_get_iter_bounds(imhtml, &start, &end)) |
a169c5c81ef5
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
28979
diff
changeset
|
4286 return; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4287 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4288 gtk_text_buffer_remove_tag_by_name(imhtml->text_buffer, "BOLD", &start, &end); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4289 gtk_text_buffer_remove_tag_by_name(imhtml->text_buffer, "ITALICS", &start, &end); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4290 gtk_text_buffer_remove_tag_by_name(imhtml->text_buffer, "UNDERLINE", &start, &end); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4291 gtk_text_buffer_remove_tag_by_name(imhtml->text_buffer, "STRIKE", &start, &end); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4292 remove_font_size(imhtml, &start, &end, FALSE); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4293 remove_font_face(imhtml, &start, &end, FALSE); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4294 remove_font_forecolor(imhtml, &start, &end, FALSE); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4295 remove_font_backcolor(imhtml, &start, &end, FALSE); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4296 remove_font_background(imhtml, &start, &end, FALSE); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4297 remove_font_link(imhtml, &start, &end, FALSE); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4298 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4299 imhtml->edit.bold = 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4300 imhtml->edit.italic = 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4301 imhtml->edit.underline = 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4302 imhtml->edit.strike = 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4303 imhtml->edit.fontsize = 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4304 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4305 g_free(imhtml->edit.fontface); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4306 imhtml->edit.fontface = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4307 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4308 g_free(imhtml->edit.forecolor); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4309 imhtml->edit.forecolor = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4310 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4311 g_free(imhtml->edit.backcolor); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4312 imhtml->edit.backcolor = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4313 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4314 g_free(imhtml->edit.background); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4315 imhtml->edit.background = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4316 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4317 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4318 /* Editable stuff */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4319 static void preinsert_cb(GtkTextBuffer *buffer, GtkTextIter *iter, gchar *text, gint len, GtkIMHtml *imhtml) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4320 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4321 imhtml->insert_offset = gtk_text_iter_get_offset(iter); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4322 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4323 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4324 static void insert_ca_cb(GtkTextBuffer *buffer, GtkTextIter *arg1, GtkTextChildAnchor *arg2, gpointer user_data) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4325 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4326 GtkTextIter start; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4327 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4328 start = *arg1; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4329 gtk_text_iter_backward_char(&start); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4330 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4331 gtk_imhtml_apply_tags_on_insert(user_data, &start, arg1); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4332 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4333 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4334 static void insert_cb(GtkTextBuffer *buffer, GtkTextIter *end, gchar *text, gint len, GtkIMHtml *imhtml) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4335 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4336 GtkTextIter start; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4337 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4338 if (!len) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4339 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4340 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4341 start = *end; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4342 gtk_text_iter_set_offset(&start, imhtml->insert_offset); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4343 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4344 gtk_imhtml_apply_tags_on_insert(imhtml, &start, end); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4345 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4346 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4347 static void delete_cb(GtkTextBuffer *buffer, GtkTextIter *start, GtkTextIter *end, GtkIMHtml *imhtml) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4348 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4349 GSList *tags, *l; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4350 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4351 tags = gtk_text_iter_get_tags(start); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4352 for (l = tags; l != NULL; l = l->next) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4353 GtkTextTag *tag = GTK_TEXT_TAG(l->data); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4354 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4355 if (tag && /* Remove the formatting only if */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4356 gtk_text_iter_starts_word(start) && /* beginning of a word */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4357 gtk_text_iter_begins_tag(start, tag) && /* the tag starts with the selection */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4358 (!gtk_text_iter_has_tag(end, tag) || /* the tag ends within the selection */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4359 gtk_text_iter_ends_tag(end, tag))) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4360 gtk_text_buffer_remove_tag(imhtml->text_buffer, tag, start, end); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4361 if (tag->name && |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4362 strncmp(tag->name, "LINK ", 5) == 0 && imhtml->edit.link) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4363 gtk_imhtml_toggle_link(imhtml, NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4364 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4365 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4366 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4367 g_slist_free(tags); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4368 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4369 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4370 static void gtk_imhtml_apply_tags_on_insert(GtkIMHtml *imhtml, GtkTextIter *start, GtkTextIter *end) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4371 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4372 if (imhtml->edit.bold) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4373 gtk_text_buffer_apply_tag_by_name(imhtml->text_buffer, "BOLD", start, end); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4374 else |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4375 gtk_text_buffer_remove_tag_by_name(imhtml->text_buffer, "BOLD", start, end); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4376 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4377 if (imhtml->edit.italic) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4378 gtk_text_buffer_apply_tag_by_name(imhtml->text_buffer, "ITALICS", start, end); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4379 else |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4380 gtk_text_buffer_remove_tag_by_name(imhtml->text_buffer, "ITALICS", start, end); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4381 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4382 if (imhtml->edit.underline) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4383 gtk_text_buffer_apply_tag_by_name(imhtml->text_buffer, "UNDERLINE", start, end); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4384 else |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4385 gtk_text_buffer_remove_tag_by_name(imhtml->text_buffer, "UNDERLINE", start, end); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4386 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4387 if (imhtml->edit.strike) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4388 gtk_text_buffer_apply_tag_by_name(imhtml->text_buffer, "STRIKE", start, end); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4389 else |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4390 gtk_text_buffer_remove_tag_by_name(imhtml->text_buffer, "STRIKE", start, end); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4391 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4392 if (imhtml->edit.forecolor) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4393 remove_font_forecolor(imhtml, start, end, TRUE); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4394 gtk_text_buffer_apply_tag(imhtml->text_buffer, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4395 find_font_forecolor_tag(imhtml, imhtml->edit.forecolor), |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4396 start, end); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4397 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4398 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4399 if (imhtml->edit.backcolor) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4400 remove_font_backcolor(imhtml, start, end, TRUE); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4401 gtk_text_buffer_apply_tag(imhtml->text_buffer, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4402 find_font_backcolor_tag(imhtml, imhtml->edit.backcolor), |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4403 start, end); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4404 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4405 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4406 if (imhtml->edit.background) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4407 remove_font_background(imhtml, start, end, TRUE); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4408 gtk_text_buffer_apply_tag(imhtml->text_buffer, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4409 find_font_background_tag(imhtml, imhtml->edit.background), |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4410 start, end); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4411 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4412 if (imhtml->edit.fontface) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4413 remove_font_face(imhtml, start, end, TRUE); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4414 gtk_text_buffer_apply_tag(imhtml->text_buffer, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4415 find_font_face_tag(imhtml, imhtml->edit.fontface), |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4416 start, end); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4417 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4418 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4419 if (imhtml->edit.fontsize) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4420 remove_font_size(imhtml, start, end, TRUE); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4421 gtk_text_buffer_apply_tag(imhtml->text_buffer, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4422 find_font_size_tag(imhtml, imhtml->edit.fontsize), |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4423 start, end); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4424 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4425 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4426 if (imhtml->edit.link) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4427 remove_font_link(imhtml, start, end, TRUE); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4428 gtk_text_buffer_apply_tag(imhtml->text_buffer, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4429 imhtml->edit.link, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4430 start, end); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4431 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4432 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4433 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4434 void gtk_imhtml_set_editable(GtkIMHtml *imhtml, gboolean editable) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4435 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4436 gtk_text_view_set_editable(GTK_TEXT_VIEW(imhtml), editable); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4437 /* |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4438 * We need a visible caret for accessibility, so mouseless |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4439 * people can highlight stuff. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4440 */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4441 /* gtk_text_view_set_cursor_visible(GTK_TEXT_VIEW(imhtml), editable); */ |
26893
c791a82b5bb5
Avoid adding several callbacks on repeated invocations of gtk_imhtml_set_editable.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
26713
diff
changeset
|
4442 if (editable && !imhtml->editable) { |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4443 g_signal_connect_after(G_OBJECT(GTK_IMHTML(imhtml)->text_buffer), "mark-set", |
21648
3aa34d20d798
Patch from 'goutnet': Pressing backspace on a smiley will replace the smiley
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21558
diff
changeset
|
4444 G_CALLBACK(mark_set_cb), imhtml); |
3aa34d20d798
Patch from 'goutnet': Pressing backspace on a smiley will replace the smiley
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21558
diff
changeset
|
4445 g_signal_connect(G_OBJECT(imhtml), "backspace", G_CALLBACK(smart_backspace_cb), NULL); |
26893
c791a82b5bb5
Avoid adding several callbacks on repeated invocations of gtk_imhtml_set_editable.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
26713
diff
changeset
|
4446 } else if (!editable && imhtml->editable) { |
c791a82b5bb5
Avoid adding several callbacks on repeated invocations of gtk_imhtml_set_editable.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
26713
diff
changeset
|
4447 g_signal_handlers_disconnect_by_func(G_OBJECT(GTK_IMHTML(imhtml)->text_buffer), |
c791a82b5bb5
Avoid adding several callbacks on repeated invocations of gtk_imhtml_set_editable.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
26713
diff
changeset
|
4448 mark_set_cb, imhtml); |
c791a82b5bb5
Avoid adding several callbacks on repeated invocations of gtk_imhtml_set_editable.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
26713
diff
changeset
|
4449 g_signal_handlers_disconnect_by_func(G_OBJECT(imhtml), |
c791a82b5bb5
Avoid adding several callbacks on repeated invocations of gtk_imhtml_set_editable.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
26713
diff
changeset
|
4450 smart_backspace_cb, NULL); |
21648
3aa34d20d798
Patch from 'goutnet': Pressing backspace on a smiley will replace the smiley
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
21558
diff
changeset
|
4451 } |
26893
c791a82b5bb5
Avoid adding several callbacks on repeated invocations of gtk_imhtml_set_editable.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
26713
diff
changeset
|
4452 |
c791a82b5bb5
Avoid adding several callbacks on repeated invocations of gtk_imhtml_set_editable.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
26713
diff
changeset
|
4453 imhtml->editable = editable; |
c791a82b5bb5
Avoid adding several callbacks on repeated invocations of gtk_imhtml_set_editable.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
26713
diff
changeset
|
4454 imhtml->format_functions = GTK_IMHTML_ALL; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4455 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4456 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4457 void gtk_imhtml_set_whole_buffer_formatting_only(GtkIMHtml *imhtml, gboolean wbfo) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4458 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4459 g_return_if_fail(imhtml != NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4460 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4461 imhtml->wbfo = wbfo; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4462 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4463 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4464 void gtk_imhtml_set_format_functions(GtkIMHtml *imhtml, GtkIMHtmlButtons buttons) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4465 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4466 GObject *object = g_object_ref(G_OBJECT(imhtml)); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4467 imhtml->format_functions = buttons; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4468 g_signal_emit(object, signals[BUTTONS_UPDATE], 0, buttons); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4469 g_object_unref(object); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4470 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4471 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4472 GtkIMHtmlButtons gtk_imhtml_get_format_functions(GtkIMHtml *imhtml) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4473 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4474 return imhtml->format_functions; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4475 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4476 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4477 void gtk_imhtml_get_current_format(GtkIMHtml *imhtml, gboolean *bold, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4478 gboolean *italic, gboolean *underline) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4479 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4480 if (bold != NULL) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4481 (*bold) = imhtml->edit.bold; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4482 if (italic != NULL) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4483 (*italic) = imhtml->edit.italic; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4484 if (underline != NULL) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4485 (*underline) = imhtml->edit.underline; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4486 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4487 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4488 char * |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4489 gtk_imhtml_get_current_fontface(GtkIMHtml *imhtml) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4490 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4491 return g_strdup(imhtml->edit.fontface); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4492 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4493 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4494 char * |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4495 gtk_imhtml_get_current_forecolor(GtkIMHtml *imhtml) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4496 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4497 return g_strdup(imhtml->edit.forecolor); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4498 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4499 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4500 char * |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4501 gtk_imhtml_get_current_backcolor(GtkIMHtml *imhtml) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4502 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4503 return g_strdup(imhtml->edit.backcolor); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4504 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4505 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4506 char * |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4507 gtk_imhtml_get_current_background(GtkIMHtml *imhtml) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4508 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4509 return g_strdup(imhtml->edit.background); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4510 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4511 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4512 gint |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4513 gtk_imhtml_get_current_fontsize(GtkIMHtml *imhtml) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4514 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4515 return imhtml->edit.fontsize; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4516 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4517 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4518 gboolean gtk_imhtml_get_editable(GtkIMHtml *imhtml) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4519 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4520 return imhtml->editable; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4521 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4522 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4523 void |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4524 gtk_imhtml_clear_formatting(GtkIMHtml *imhtml) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4525 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4526 GObject *object; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4527 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4528 object = g_object_ref(G_OBJECT(imhtml)); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4529 g_signal_emit(object, signals[CLEAR_FORMAT], 0); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4530 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4531 gtk_widget_grab_focus(GTK_WIDGET(imhtml)); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4532 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4533 g_object_unref(object); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4534 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4535 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4536 /* |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4537 * I had this crazy idea about changing the text cursor color to reflex the foreground color |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4538 * of the text about to be entered. This is the place you'd do it, along with the place where |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4539 * we actually set a new foreground color. |
15823 | 4540 * I may not do this, because people will bitch about Purple overriding their gtk theme's cursor |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4541 * colors. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4542 * |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4543 * Just in case I do do this, I asked about what to set the secondary text cursor to. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4544 * |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4545 * (12:45:27) ?? ???: secondary_cursor_color = (rgb(background) + rgb(primary_cursor_color) ) / 2 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4546 * (12:45:55) ?? ???: understand? |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4547 * (12:46:14) Tim: yeah. i didn't know there was an exact formula |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4548 * (12:46:56) ?? ???: u might need to extract separate each color from RGB |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4549 */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4550 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4551 static void mark_set_cb(GtkTextBuffer *buffer, GtkTextIter *arg1, GtkTextMark *mark, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4552 GtkIMHtml *imhtml) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4553 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4554 GSList *tags, *l; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4555 GtkTextIter iter; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4556 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4557 if (mark != gtk_text_buffer_get_insert(buffer)) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4558 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4559 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4560 if (!gtk_text_buffer_get_char_count(buffer)) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4561 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4562 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4563 imhtml->edit.bold = imhtml->edit.italic = imhtml->edit.underline = imhtml->edit.strike = FALSE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4564 g_free(imhtml->edit.forecolor); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4565 imhtml->edit.forecolor = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4566 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4567 g_free(imhtml->edit.backcolor); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4568 imhtml->edit.backcolor = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4569 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4570 g_free(imhtml->edit.fontface); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4571 imhtml->edit.fontface = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4572 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4573 imhtml->edit.fontsize = 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4574 imhtml->edit.link = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4575 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4576 gtk_text_buffer_get_iter_at_mark(imhtml->text_buffer, &iter, mark); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4577 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4578 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4579 if (gtk_text_iter_is_end(&iter)) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4580 tags = gtk_text_iter_get_toggled_tags(&iter, FALSE); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4581 else |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4582 tags = gtk_text_iter_get_tags(&iter); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4583 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4584 for (l = tags; l != NULL; l = l->next) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4585 GtkTextTag *tag = GTK_TEXT_TAG(l->data); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4586 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4587 if (tag->name) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4588 if (strcmp(tag->name, "BOLD") == 0) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4589 imhtml->edit.bold = TRUE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4590 else if (strcmp(tag->name, "ITALICS") == 0) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4591 imhtml->edit.italic = TRUE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4592 else if (strcmp(tag->name, "UNDERLINE") == 0) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4593 imhtml->edit.underline = TRUE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4594 else if (strcmp(tag->name, "STRIKE") == 0) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4595 imhtml->edit.strike = TRUE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4596 else if (strncmp(tag->name, "FORECOLOR ", 10) == 0) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4597 imhtml->edit.forecolor = g_strdup(&(tag->name)[10]); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4598 else if (strncmp(tag->name, "BACKCOLOR ", 10) == 0) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4599 imhtml->edit.backcolor = g_strdup(&(tag->name)[10]); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4600 else if (strncmp(tag->name, "FONT FACE ", 10) == 0) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4601 imhtml->edit.fontface = g_strdup(&(tag->name)[10]); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4602 else if (strncmp(tag->name, "FONT SIZE ", 10) == 0) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4603 imhtml->edit.fontsize = strtol(&(tag->name)[10], NULL, 10); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4604 else if ((strncmp(tag->name, "LINK ", 5) == 0) && !gtk_text_iter_is_end(&iter)) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4605 imhtml->edit.link = tag; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4606 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4607 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4608 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4609 g_slist_free(tags); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4610 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4611 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4612 static void imhtml_emit_signal_for_format(GtkIMHtml *imhtml, GtkIMHtmlButtons button) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4613 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4614 GObject *object; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4615 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4616 g_return_if_fail(imhtml != NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4617 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4618 object = g_object_ref(G_OBJECT(imhtml)); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4619 g_signal_emit(object, signals[TOGGLE_FORMAT], 0, button); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4620 g_object_unref(object); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4621 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4622 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4623 static void imhtml_toggle_bold(GtkIMHtml *imhtml) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4624 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4625 GtkTextIter start, end; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4626 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4627 imhtml->edit.bold = !imhtml->edit.bold; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4628 |
28982
a169c5c81ef5
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
28979
diff
changeset
|
4629 if (!imhtml_get_iter_bounds(imhtml, &start, &end)) |
a169c5c81ef5
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
28979
diff
changeset
|
4630 return; |
a169c5c81ef5
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
28979
diff
changeset
|
4631 |
a169c5c81ef5
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
28979
diff
changeset
|
4632 if (imhtml->edit.bold) |
a169c5c81ef5
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
28979
diff
changeset
|
4633 gtk_text_buffer_apply_tag_by_name(imhtml->text_buffer, "BOLD", &start, &end); |
a169c5c81ef5
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
28979
diff
changeset
|
4634 else |
a169c5c81ef5
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
28979
diff
changeset
|
4635 gtk_text_buffer_remove_tag_by_name(imhtml->text_buffer, "BOLD", &start, &end); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4636 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4637 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4638 void gtk_imhtml_toggle_bold(GtkIMHtml *imhtml) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4639 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4640 imhtml_emit_signal_for_format(imhtml, GTK_IMHTML_BOLD); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4641 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4642 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4643 static void imhtml_toggle_italic(GtkIMHtml *imhtml) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4644 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4645 GtkTextIter start, end; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4646 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4647 imhtml->edit.italic = !imhtml->edit.italic; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4648 |
28982
a169c5c81ef5
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
28979
diff
changeset
|
4649 if (!imhtml_get_iter_bounds(imhtml, &start, &end)) |
a169c5c81ef5
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
28979
diff
changeset
|
4650 return; |
a169c5c81ef5
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
28979
diff
changeset
|
4651 |
a169c5c81ef5
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
28979
diff
changeset
|
4652 if (imhtml->edit.italic) |
a169c5c81ef5
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
28979
diff
changeset
|
4653 gtk_text_buffer_apply_tag_by_name(imhtml->text_buffer, "ITALICS", &start, &end); |
a169c5c81ef5
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
28979
diff
changeset
|
4654 else |
a169c5c81ef5
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
28979
diff
changeset
|
4655 gtk_text_buffer_remove_tag_by_name(imhtml->text_buffer, "ITALICS", &start, &end); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4656 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4657 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4658 void gtk_imhtml_toggle_italic(GtkIMHtml *imhtml) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4659 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4660 imhtml_emit_signal_for_format(imhtml, GTK_IMHTML_ITALIC); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4661 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4662 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4663 static void imhtml_toggle_underline(GtkIMHtml *imhtml) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4664 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4665 GtkTextIter start, end; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4666 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4667 imhtml->edit.underline = !imhtml->edit.underline; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4668 |
28982
a169c5c81ef5
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
28979
diff
changeset
|
4669 if (!imhtml_get_iter_bounds(imhtml, &start, &end)) |
a169c5c81ef5
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
28979
diff
changeset
|
4670 return; |
a169c5c81ef5
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
28979
diff
changeset
|
4671 |
a169c5c81ef5
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
28979
diff
changeset
|
4672 if (imhtml->edit.underline) |
a169c5c81ef5
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
28979
diff
changeset
|
4673 gtk_text_buffer_apply_tag_by_name(imhtml->text_buffer, "UNDERLINE", &start, &end); |
a169c5c81ef5
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
28979
diff
changeset
|
4674 else |
a169c5c81ef5
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
28979
diff
changeset
|
4675 gtk_text_buffer_remove_tag_by_name(imhtml->text_buffer, "UNDERLINE", &start, &end); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4676 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4677 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4678 void gtk_imhtml_toggle_underline(GtkIMHtml *imhtml) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4679 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4680 imhtml_emit_signal_for_format(imhtml, GTK_IMHTML_UNDERLINE); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4681 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4682 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4683 static void imhtml_toggle_strike(GtkIMHtml *imhtml) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4684 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4685 GtkTextIter start, end; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4686 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4687 imhtml->edit.strike = !imhtml->edit.strike; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4688 |
28982
a169c5c81ef5
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
28979
diff
changeset
|
4689 if (!imhtml_get_iter_bounds(imhtml, &start, &end)) |
a169c5c81ef5
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
28979
diff
changeset
|
4690 return; |
a169c5c81ef5
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
28979
diff
changeset
|
4691 |
a169c5c81ef5
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
28979
diff
changeset
|
4692 if (imhtml->edit.strike) |
a169c5c81ef5
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
28979
diff
changeset
|
4693 gtk_text_buffer_apply_tag_by_name(imhtml->text_buffer, "STRIKE", &start, &end); |
a169c5c81ef5
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
28979
diff
changeset
|
4694 else |
a169c5c81ef5
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
28979
diff
changeset
|
4695 gtk_text_buffer_remove_tag_by_name(imhtml->text_buffer, "STRIKE", &start, &end); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4696 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4697 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4698 void gtk_imhtml_toggle_strike(GtkIMHtml *imhtml) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4699 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4700 imhtml_emit_signal_for_format(imhtml, GTK_IMHTML_STRIKE); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4701 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4702 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4703 void gtk_imhtml_font_set_size(GtkIMHtml *imhtml, gint size) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4704 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4705 GObject *object; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4706 GtkTextIter start, end; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4707 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4708 imhtml->edit.fontsize = size; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4709 |
28982
a169c5c81ef5
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
28979
diff
changeset
|
4710 if (!imhtml_get_iter_bounds(imhtml, &start, &end)) |
a169c5c81ef5
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
28979
diff
changeset
|
4711 return; |
a169c5c81ef5
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
28979
diff
changeset
|
4712 |
a169c5c81ef5
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
28979
diff
changeset
|
4713 remove_font_size(imhtml, &start, &end, imhtml->wbfo); |
a169c5c81ef5
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
28979
diff
changeset
|
4714 gtk_text_buffer_apply_tag(imhtml->text_buffer, |
a169c5c81ef5
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
28979
diff
changeset
|
4715 find_font_size_tag(imhtml, imhtml->edit.fontsize), &start, &end); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4716 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4717 object = g_object_ref(G_OBJECT(imhtml)); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4718 g_signal_emit(object, signals[TOGGLE_FORMAT], 0, GTK_IMHTML_SHRINK | GTK_IMHTML_GROW); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4719 g_object_unref(object); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4720 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4721 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4722 static void imhtml_font_shrink(GtkIMHtml *imhtml) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4723 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4724 GtkTextIter start, end; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4725 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4726 if (imhtml->edit.fontsize == 1) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4727 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4728 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4729 if (!imhtml->edit.fontsize) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4730 imhtml->edit.fontsize = 2; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4731 else |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4732 imhtml->edit.fontsize--; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4733 |
28982
a169c5c81ef5
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
28979
diff
changeset
|
4734 if (!imhtml_get_iter_bounds(imhtml, &start, &end)) |
a169c5c81ef5
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
28979
diff
changeset
|
4735 return; |
a169c5c81ef5
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
28979
diff
changeset
|
4736 remove_font_size(imhtml, &start, &end, imhtml->wbfo); |
a169c5c81ef5
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
28979
diff
changeset
|
4737 gtk_text_buffer_apply_tag(imhtml->text_buffer, |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4738 find_font_size_tag(imhtml, imhtml->edit.fontsize), &start, &end); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4739 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4740 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4741 void gtk_imhtml_font_shrink(GtkIMHtml *imhtml) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4742 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4743 imhtml_emit_signal_for_format(imhtml, GTK_IMHTML_SHRINK); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4744 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4745 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4746 static void imhtml_font_grow(GtkIMHtml *imhtml) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4747 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4748 GtkTextIter start, end; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4749 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4750 if (imhtml->edit.fontsize == MAX_FONT_SIZE) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4751 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4752 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4753 if (!imhtml->edit.fontsize) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4754 imhtml->edit.fontsize = 4; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4755 else |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4756 imhtml->edit.fontsize++; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4757 |
28982
a169c5c81ef5
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
28979
diff
changeset
|
4758 if (!imhtml_get_iter_bounds(imhtml, &start, &end)) |
a169c5c81ef5
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
28979
diff
changeset
|
4759 return; |
a169c5c81ef5
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
28979
diff
changeset
|
4760 remove_font_size(imhtml, &start, &end, imhtml->wbfo); |
a169c5c81ef5
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
28979
diff
changeset
|
4761 gtk_text_buffer_apply_tag(imhtml->text_buffer, |
a169c5c81ef5
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
28979
diff
changeset
|
4762 find_font_size_tag(imhtml, imhtml->edit.fontsize), &start, &end); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4763 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4764 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4765 void gtk_imhtml_font_grow(GtkIMHtml *imhtml) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4766 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4767 imhtml_emit_signal_for_format(imhtml, GTK_IMHTML_GROW); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4768 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4769 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4770 static gboolean gtk_imhtml_toggle_str_tag(GtkIMHtml *imhtml, const char *value, char **edit_field, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4771 void (*remove_func)(GtkIMHtml *imhtml, GtkTextIter *i, GtkTextIter *e, gboolean homo), |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4772 GtkTextTag *(find_func)(GtkIMHtml *imhtml, gchar *color), GtkIMHtmlButtons button) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4773 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4774 GObject *object; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4775 GtkTextIter start; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4776 GtkTextIter end; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4777 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4778 g_free(*edit_field); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4779 *edit_field = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4780 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4781 if (value && strcmp(value, "") != 0) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4782 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4783 *edit_field = g_strdup(value); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4784 |
28982
a169c5c81ef5
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
28979
diff
changeset
|
4785 if (imhtml_get_iter_bounds(imhtml, &start, &end)) { |
a169c5c81ef5
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
28979
diff
changeset
|
4786 remove_func(imhtml, &start, &end, imhtml->wbfo); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4787 gtk_text_buffer_apply_tag(imhtml->text_buffer, |
28982
a169c5c81ef5
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
28979
diff
changeset
|
4788 find_func(imhtml, *edit_field), &start, &end); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4789 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4790 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4791 else |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4792 { |
28982
a169c5c81ef5
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
28979
diff
changeset
|
4793 if (imhtml_get_iter_bounds(imhtml, &start, &end)) |
a169c5c81ef5
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
28979
diff
changeset
|
4794 remove_func(imhtml, &start, &end, TRUE); /* 'TRUE' or 'imhtml->wbfo'? */ |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4795 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4796 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4797 object = g_object_ref(G_OBJECT(imhtml)); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4798 g_signal_emit(object, signals[TOGGLE_FORMAT], 0, button); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4799 g_object_unref(object); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4800 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4801 return *edit_field != NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4802 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4803 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4804 gboolean gtk_imhtml_toggle_forecolor(GtkIMHtml *imhtml, const char *color) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4805 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4806 return gtk_imhtml_toggle_str_tag(imhtml, color, &imhtml->edit.forecolor, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4807 remove_font_forecolor, find_font_forecolor_tag, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4808 GTK_IMHTML_FORECOLOR); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4809 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4810 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4811 gboolean gtk_imhtml_toggle_backcolor(GtkIMHtml *imhtml, const char *color) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4812 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4813 return gtk_imhtml_toggle_str_tag(imhtml, color, &imhtml->edit.backcolor, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4814 remove_font_backcolor, find_font_backcolor_tag, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4815 GTK_IMHTML_BACKCOLOR); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4816 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4817 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4818 gboolean gtk_imhtml_toggle_background(GtkIMHtml *imhtml, const char *color) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4819 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4820 return gtk_imhtml_toggle_str_tag(imhtml, color, &imhtml->edit.background, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4821 remove_font_background, find_font_background_tag, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4822 GTK_IMHTML_BACKGROUND); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4823 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4824 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4825 gboolean gtk_imhtml_toggle_fontface(GtkIMHtml *imhtml, const char *face) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4826 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4827 return gtk_imhtml_toggle_str_tag(imhtml, face, &imhtml->edit.fontface, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4828 remove_font_face, find_font_face_tag, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4829 GTK_IMHTML_FACE); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4830 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4831 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4832 void gtk_imhtml_toggle_link(GtkIMHtml *imhtml, const char *url) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4833 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4834 GObject *object; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4835 GtkTextIter start, end; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4836 GtkTextTag *linktag; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4837 static guint linkno = 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4838 gchar str[48]; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4839 GdkColor *color = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4840 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4841 imhtml->edit.link = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4842 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4843 if (url) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4844 g_snprintf(str, sizeof(str), "LINK %d", linkno++); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4845 str[47] = '\0'; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4846 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4847 gtk_widget_style_get(GTK_WIDGET(imhtml), "hyperlink-color", &color, NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4848 if (color) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4849 imhtml->edit.link = linktag = gtk_text_buffer_create_tag(imhtml->text_buffer, str, "foreground-gdk", color, "underline", PANGO_UNDERLINE_SINGLE, NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4850 gdk_color_free(color); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4851 } else { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4852 imhtml->edit.link = linktag = gtk_text_buffer_create_tag(imhtml->text_buffer, str, "foreground", "blue", "underline", PANGO_UNDERLINE_SINGLE, NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4853 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4854 g_object_set_data_full(G_OBJECT(linktag), "link_url", g_strdup(url), g_free); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4855 g_signal_connect(G_OBJECT(linktag), "event", G_CALLBACK(tag_event), NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4856 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4857 if (imhtml->editable && gtk_text_buffer_get_selection_bounds(imhtml->text_buffer, &start, &end)) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4858 remove_font_link(imhtml, &start, &end, FALSE); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4859 gtk_text_buffer_apply_tag(imhtml->text_buffer, linktag, &start, &end); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4860 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4861 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4862 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4863 object = g_object_ref(G_OBJECT(imhtml)); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4864 g_signal_emit(object, signals[TOGGLE_FORMAT], 0, GTK_IMHTML_LINK); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4865 g_object_unref(object); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4866 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4867 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4868 void gtk_imhtml_insert_link(GtkIMHtml *imhtml, GtkTextMark *mark, const char *url, const char *text) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4869 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4870 GtkTextIter iter; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4871 |
25426
7942287364c2
The first thing gtk_text_buffer_delete_selection does is call
Mark Doliner <mark@kingant.net>
parents:
25415
diff
changeset
|
4872 /* Delete any currently selected text */ |
7942287364c2
The first thing gtk_text_buffer_delete_selection does is call
Mark Doliner <mark@kingant.net>
parents:
25415
diff
changeset
|
4873 gtk_text_buffer_delete_selection(imhtml->text_buffer, TRUE, TRUE); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4874 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4875 gtk_imhtml_toggle_link(imhtml, url); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4876 gtk_text_buffer_get_iter_at_mark(imhtml->text_buffer, &iter, mark); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4877 gtk_text_buffer_insert(imhtml->text_buffer, &iter, text, -1); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4878 gtk_imhtml_toggle_link(imhtml, NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4879 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4880 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4881 void gtk_imhtml_insert_smiley(GtkIMHtml *imhtml, const char *sml, char *smiley) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4882 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4883 GtkTextMark *mark; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4884 GtkTextIter iter; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4885 |
25426
7942287364c2
The first thing gtk_text_buffer_delete_selection does is call
Mark Doliner <mark@kingant.net>
parents:
25415
diff
changeset
|
4886 /* Delete any currently selected text */ |
7942287364c2
The first thing gtk_text_buffer_delete_selection does is call
Mark Doliner <mark@kingant.net>
parents:
25415
diff
changeset
|
4887 gtk_text_buffer_delete_selection(imhtml->text_buffer, TRUE, TRUE); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4888 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4889 mark = gtk_text_buffer_get_insert(imhtml->text_buffer); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4890 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4891 gtk_text_buffer_get_iter_at_mark(imhtml->text_buffer, &iter, mark); |
29357
36bae5f00d32
Explicitly mark user-interaction when inserting smiley.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
29200
diff
changeset
|
4892 gtk_text_buffer_begin_user_action(imhtml->text_buffer); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4893 gtk_imhtml_insert_smiley_at_iter(imhtml, sml, smiley, &iter); |
29357
36bae5f00d32
Explicitly mark user-interaction when inserting smiley.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
29200
diff
changeset
|
4894 gtk_text_buffer_end_user_action(imhtml->text_buffer); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4895 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4896 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4897 static gboolean |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4898 image_expose(GtkWidget *widget, GdkEventExpose *event, gpointer user_data) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4899 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4900 GTK_WIDGET_CLASS(GTK_WIDGET_GET_CLASS(widget))->expose_event(widget, event); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4901 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4902 return TRUE; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4903 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4904 |
16309
a32325c04158
Fixes #213 This allows only 20 animated smileys to be animnating at a time
Sean Egan <seanegan@gmail.com>
parents:
16229
diff
changeset
|
4905 /* In case the smiley gets removed from the imhtml before it gets removed from the queue */ |
a32325c04158
Fixes #213 This allows only 20 animated smileys to be animnating at a time
Sean Egan <seanegan@gmail.com>
parents:
16229
diff
changeset
|
4906 static void animated_smiley_destroy_cb(GtkObject *widget, GtkIMHtml *imhtml) |
a32325c04158
Fixes #213 This allows only 20 animated smileys to be animnating at a time
Sean Egan <seanegan@gmail.com>
parents:
16229
diff
changeset
|
4907 { |
a32325c04158
Fixes #213 This allows only 20 animated smileys to be animnating at a time
Sean Egan <seanegan@gmail.com>
parents:
16229
diff
changeset
|
4908 GList *l = imhtml->animations->head; |
a32325c04158
Fixes #213 This allows only 20 animated smileys to be animnating at a time
Sean Egan <seanegan@gmail.com>
parents:
16229
diff
changeset
|
4909 while (l) { |
a32325c04158
Fixes #213 This allows only 20 animated smileys to be animnating at a time
Sean Egan <seanegan@gmail.com>
parents:
16229
diff
changeset
|
4910 GList *next = l->next; |
a32325c04158
Fixes #213 This allows only 20 animated smileys to be animnating at a time
Sean Egan <seanegan@gmail.com>
parents:
16229
diff
changeset
|
4911 if (l->data == widget) { |
a32325c04158
Fixes #213 This allows only 20 animated smileys to be animnating at a time
Sean Egan <seanegan@gmail.com>
parents:
16229
diff
changeset
|
4912 if (l == imhtml->animations->tail) |
a32325c04158
Fixes #213 This allows only 20 animated smileys to be animnating at a time
Sean Egan <seanegan@gmail.com>
parents:
16229
diff
changeset
|
4913 imhtml->animations->tail = imhtml->animations->tail->prev; |
a32325c04158
Fixes #213 This allows only 20 animated smileys to be animnating at a time
Sean Egan <seanegan@gmail.com>
parents:
16229
diff
changeset
|
4914 imhtml->animations->head = g_list_delete_link(imhtml->animations->head, l); |
a32325c04158
Fixes #213 This allows only 20 animated smileys to be animnating at a time
Sean Egan <seanegan@gmail.com>
parents:
16229
diff
changeset
|
4915 imhtml->num_animations--; |
a32325c04158
Fixes #213 This allows only 20 animated smileys to be animnating at a time
Sean Egan <seanegan@gmail.com>
parents:
16229
diff
changeset
|
4916 } |
a32325c04158
Fixes #213 This allows only 20 animated smileys to be animnating at a time
Sean Egan <seanegan@gmail.com>
parents:
16229
diff
changeset
|
4917 l = next; |
a32325c04158
Fixes #213 This allows only 20 animated smileys to be animnating at a time
Sean Egan <seanegan@gmail.com>
parents:
16229
diff
changeset
|
4918 } |
a32325c04158
Fixes #213 This allows only 20 animated smileys to be animnating at a time
Sean Egan <seanegan@gmail.com>
parents:
16229
diff
changeset
|
4919 } |
a32325c04158
Fixes #213 This allows only 20 animated smileys to be animnating at a time
Sean Egan <seanegan@gmail.com>
parents:
16229
diff
changeset
|
4920 |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4921 void gtk_imhtml_insert_smiley_at_iter(GtkIMHtml *imhtml, const char *sml, char *smiley, GtkTextIter *iter) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4922 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4923 GdkPixbuf *pixbuf = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4924 GdkPixbufAnimation *annipixbuf = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4925 GtkWidget *icon = NULL; |
16964
ab45289d2c36
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 <imadil@gmail.com>
parents:
16309
diff
changeset
|
4926 GtkTextChildAnchor *anchor = NULL; |
29468
89b4054deba1
Fix CVE-2010-0423, a denial of service attack due to the parsing
Mark Doliner <mark@kingant.net>
parents:
29440
diff
changeset
|
4927 char *unescaped; |
89b4054deba1
Fix CVE-2010-0423, a denial of service attack due to the parsing
Mark Doliner <mark@kingant.net>
parents:
29440
diff
changeset
|
4928 GtkIMHtmlSmiley *imhtml_smiley; |
16964
ab45289d2c36
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 <imadil@gmail.com>
parents:
16309
diff
changeset
|
4929 GtkWidget *ebox = NULL; |
29468
89b4054deba1
Fix CVE-2010-0423, a denial of service attack due to the parsing
Mark Doliner <mark@kingant.net>
parents:
29440
diff
changeset
|
4930 int numsmileys_thismsg, numsmileys_total; |
89b4054deba1
Fix CVE-2010-0423, a denial of service attack due to the parsing
Mark Doliner <mark@kingant.net>
parents:
29440
diff
changeset
|
4931 |
89b4054deba1
Fix CVE-2010-0423, a denial of service attack due to the parsing
Mark Doliner <mark@kingant.net>
parents:
29440
diff
changeset
|
4932 /* |
89b4054deba1
Fix CVE-2010-0423, a denial of service attack due to the parsing
Mark Doliner <mark@kingant.net>
parents:
29440
diff
changeset
|
4933 * This GtkIMHtml has the maximum number of smileys allowed, so don't |
89b4054deba1
Fix CVE-2010-0423, a denial of service attack due to the parsing
Mark Doliner <mark@kingant.net>
parents:
29440
diff
changeset
|
4934 * add any more. We do this for performance reasons, because smileys |
89b4054deba1
Fix CVE-2010-0423, a denial of service attack due to the parsing
Mark Doliner <mark@kingant.net>
parents:
29440
diff
changeset
|
4935 * are apparently pretty inefficient. Hopefully we can remove this |
89b4054deba1
Fix CVE-2010-0423, a denial of service attack due to the parsing
Mark Doliner <mark@kingant.net>
parents:
29440
diff
changeset
|
4936 * restriction when we're using a better HTML widget. |
89b4054deba1
Fix CVE-2010-0423, a denial of service attack due to the parsing
Mark Doliner <mark@kingant.net>
parents:
29440
diff
changeset
|
4937 */ |
31426
1203778744d0
gtkimhtml: Display "<3" instead of "<3" after too many smileys in convo
Paul Aurich <paul@darkrain42.org>
parents:
30863
diff
changeset
|
4938 unescaped = purple_unescape_html(smiley); |
29468
89b4054deba1
Fix CVE-2010-0423, a denial of service attack due to the parsing
Mark Doliner <mark@kingant.net>
parents:
29440
diff
changeset
|
4939 numsmileys_thismsg = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(imhtml), "gtkimhtml_numsmileys_thismsg")); |
89b4054deba1
Fix CVE-2010-0423, a denial of service attack due to the parsing
Mark Doliner <mark@kingant.net>
parents:
29440
diff
changeset
|
4940 if (numsmileys_thismsg >= 30) { |
31426
1203778744d0
gtkimhtml: Display "<3" instead of "<3" after too many smileys in convo
Paul Aurich <paul@darkrain42.org>
parents:
30863
diff
changeset
|
4941 gtk_text_buffer_insert(imhtml->text_buffer, iter, unescaped, -1); |
1203778744d0
gtkimhtml: Display "<3" instead of "<3" after too many smileys in convo
Paul Aurich <paul@darkrain42.org>
parents:
30863
diff
changeset
|
4942 g_free(unescaped); |
29468
89b4054deba1
Fix CVE-2010-0423, a denial of service attack due to the parsing
Mark Doliner <mark@kingant.net>
parents:
29440
diff
changeset
|
4943 return; |
89b4054deba1
Fix CVE-2010-0423, a denial of service attack due to the parsing
Mark Doliner <mark@kingant.net>
parents:
29440
diff
changeset
|
4944 } |
89b4054deba1
Fix CVE-2010-0423, a denial of service attack due to the parsing
Mark Doliner <mark@kingant.net>
parents:
29440
diff
changeset
|
4945 numsmileys_total = GPOINTER_TO_INT(g_object_get_data(G_OBJECT(imhtml), "gtkimhtml_numsmileys_total")); |
89b4054deba1
Fix CVE-2010-0423, a denial of service attack due to the parsing
Mark Doliner <mark@kingant.net>
parents:
29440
diff
changeset
|
4946 if (numsmileys_total >= 300) { |
31426
1203778744d0
gtkimhtml: Display "<3" instead of "<3" after too many smileys in convo
Paul Aurich <paul@darkrain42.org>
parents:
30863
diff
changeset
|
4947 gtk_text_buffer_insert(imhtml->text_buffer, iter, unescaped, -1); |
1203778744d0
gtkimhtml: Display "<3" instead of "<3" after too many smileys in convo
Paul Aurich <paul@darkrain42.org>
parents:
30863
diff
changeset
|
4948 g_free(unescaped); |
29468
89b4054deba1
Fix CVE-2010-0423, a denial of service attack due to the parsing
Mark Doliner <mark@kingant.net>
parents:
29440
diff
changeset
|
4949 return; |
89b4054deba1
Fix CVE-2010-0423, a denial of service attack due to the parsing
Mark Doliner <mark@kingant.net>
parents:
29440
diff
changeset
|
4950 } |
89b4054deba1
Fix CVE-2010-0423, a denial of service attack due to the parsing
Mark Doliner <mark@kingant.net>
parents:
29440
diff
changeset
|
4951 |
89b4054deba1
Fix CVE-2010-0423, a denial of service attack due to the parsing
Mark Doliner <mark@kingant.net>
parents:
29440
diff
changeset
|
4952 imhtml_smiley = gtk_imhtml_smiley_get(imhtml, sml, unescaped); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4953 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4954 if (imhtml->format_functions & GTK_IMHTML_SMILEY) { |
29468
89b4054deba1
Fix CVE-2010-0423, a denial of service attack due to the parsing
Mark Doliner <mark@kingant.net>
parents:
29440
diff
changeset
|
4955 annipixbuf = imhtml_smiley ? gtk_smiley_get_image(imhtml_smiley) : NULL; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4956 if (annipixbuf) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4957 if (gdk_pixbuf_animation_is_static_image(annipixbuf)) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4958 pixbuf = gdk_pixbuf_animation_get_static_image(annipixbuf); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4959 if (pixbuf) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4960 icon = gtk_image_new_from_pixbuf(pixbuf); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4961 } else { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4962 icon = gtk_image_new_from_animation(annipixbuf); |
16309
a32325c04158
Fixes #213 This allows only 20 animated smileys to be animnating at a time
Sean Egan <seanegan@gmail.com>
parents:
16229
diff
changeset
|
4963 if (imhtml->num_animations == 20) { |
a32325c04158
Fixes #213 This allows only 20 animated smileys to be animnating at a time
Sean Egan <seanegan@gmail.com>
parents:
16229
diff
changeset
|
4964 GtkImage *image = GTK_IMAGE(g_queue_pop_head(imhtml->animations)); |
a32325c04158
Fixes #213 This allows only 20 animated smileys to be animnating at a time
Sean Egan <seanegan@gmail.com>
parents:
16229
diff
changeset
|
4965 GdkPixbufAnimation *anim = gtk_image_get_animation(image); |
20566
3ef40e8de6ab
Fix some crashes with animated smileys. Fixes #3179, #938, #3134, #2872, #1594
Daniel Atallah <daniel.atallah@gmail.com>
parents:
20074
diff
changeset
|
4966 g_signal_handlers_disconnect_matched(G_OBJECT(image), G_SIGNAL_MATCH_FUNC, |
3ef40e8de6ab
Fix some crashes with animated smileys. Fixes #3179, #938, #3134, #2872, #1594
Daniel Atallah <daniel.atallah@gmail.com>
parents:
20074
diff
changeset
|
4967 0, 0, NULL, G_CALLBACK(animated_smiley_destroy_cb), NULL); |
16309
a32325c04158
Fixes #213 This allows only 20 animated smileys to be animnating at a time
Sean Egan <seanegan@gmail.com>
parents:
16229
diff
changeset
|
4968 if (anim) { |
a32325c04158
Fixes #213 This allows only 20 animated smileys to be animnating at a time
Sean Egan <seanegan@gmail.com>
parents:
16229
diff
changeset
|
4969 GdkPixbuf *pb = gdk_pixbuf_animation_get_static_image(anim); |
20566
3ef40e8de6ab
Fix some crashes with animated smileys. Fixes #3179, #938, #3134, #2872, #1594
Daniel Atallah <daniel.atallah@gmail.com>
parents:
20074
diff
changeset
|
4970 if (pb != NULL) { |
3ef40e8de6ab
Fix some crashes with animated smileys. Fixes #3179, #938, #3134, #2872, #1594
Daniel Atallah <daniel.atallah@gmail.com>
parents:
20074
diff
changeset
|
4971 GdkPixbuf *copy = gdk_pixbuf_copy(pb); |
3ef40e8de6ab
Fix some crashes with animated smileys. Fixes #3179, #938, #3134, #2872, #1594
Daniel Atallah <daniel.atallah@gmail.com>
parents:
20074
diff
changeset
|
4972 gtk_image_set_from_pixbuf(image, copy); |
3ef40e8de6ab
Fix some crashes with animated smileys. Fixes #3179, #938, #3134, #2872, #1594
Daniel Atallah <daniel.atallah@gmail.com>
parents:
20074
diff
changeset
|
4973 g_object_unref(G_OBJECT(copy)); |
3ef40e8de6ab
Fix some crashes with animated smileys. Fixes #3179, #938, #3134, #2872, #1594
Daniel Atallah <daniel.atallah@gmail.com>
parents:
20074
diff
changeset
|
4974 } |
16309
a32325c04158
Fixes #213 This allows only 20 animated smileys to be animnating at a time
Sean Egan <seanegan@gmail.com>
parents:
16229
diff
changeset
|
4975 } |
a32325c04158
Fixes #213 This allows only 20 animated smileys to be animnating at a time
Sean Egan <seanegan@gmail.com>
parents:
16229
diff
changeset
|
4976 } else { |
a32325c04158
Fixes #213 This allows only 20 animated smileys to be animnating at a time
Sean Egan <seanegan@gmail.com>
parents:
16229
diff
changeset
|
4977 imhtml->num_animations++; |
a32325c04158
Fixes #213 This allows only 20 animated smileys to be animnating at a time
Sean Egan <seanegan@gmail.com>
parents:
16229
diff
changeset
|
4978 } |
a32325c04158
Fixes #213 This allows only 20 animated smileys to be animnating at a time
Sean Egan <seanegan@gmail.com>
parents:
16229
diff
changeset
|
4979 g_signal_connect(G_OBJECT(icon), "destroy", G_CALLBACK(animated_smiley_destroy_cb), imhtml); |
a32325c04158
Fixes #213 This allows only 20 animated smileys to be animnating at a time
Sean Egan <seanegan@gmail.com>
parents:
16229
diff
changeset
|
4980 g_queue_push_tail(imhtml->animations, icon); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4981 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4982 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4983 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4984 |
17148
2e2f6cf3f85e
Do not crash when trying to insert a smiley for a protocol not mentioned
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17085
diff
changeset
|
4985 if (imhtml_smiley && imhtml_smiley->flags & GTK_IMHTML_SMILEY_CUSTOM) { |
16964
ab45289d2c36
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 <imadil@gmail.com>
parents:
16309
diff
changeset
|
4986 ebox = gtk_event_box_new(); |
ab45289d2c36
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 <imadil@gmail.com>
parents:
16309
diff
changeset
|
4987 gtk_event_box_set_visible_window(GTK_EVENT_BOX(ebox), FALSE); |
ab45289d2c36
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 <imadil@gmail.com>
parents:
16309
diff
changeset
|
4988 gtk_widget_show(ebox); |
ab45289d2c36
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 <imadil@gmail.com>
parents:
16309
diff
changeset
|
4989 } |
ab45289d2c36
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 <imadil@gmail.com>
parents:
16309
diff
changeset
|
4990 |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4991 if (icon) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4992 anchor = gtk_text_buffer_create_child_anchor(imhtml->text_buffer, iter); |
29440 | 4993 g_object_set_data_full(G_OBJECT(anchor), "gtkimhtml_plaintext", g_strdup(unescaped), g_free); |
4994 g_object_set_data_full(G_OBJECT(anchor), "gtkimhtml_tiptext", g_strdup(unescaped), g_free); | |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4995 g_object_set_data_full(G_OBJECT(anchor), "gtkimhtml_htmltext", g_strdup(smiley), g_free); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4996 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4997 /* This catches the expose events generated by animated |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4998 * images, and ensures that they are handled by the image |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
4999 * itself, without propagating to the textview and causing |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5000 * a complete refresh */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5001 g_signal_connect(G_OBJECT(icon), "expose-event", G_CALLBACK(image_expose), NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5002 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5003 gtk_widget_show(icon); |
16964
ab45289d2c36
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 <imadil@gmail.com>
parents:
16309
diff
changeset
|
5004 if (ebox) |
ab45289d2c36
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 <imadil@gmail.com>
parents:
16309
diff
changeset
|
5005 gtk_container_add(GTK_CONTAINER(ebox), icon); |
ab45289d2c36
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 <imadil@gmail.com>
parents:
16309
diff
changeset
|
5006 gtk_text_view_add_child_at_anchor(GTK_TEXT_VIEW(imhtml), ebox ? ebox : icon, anchor); |
29468
89b4054deba1
Fix CVE-2010-0423, a denial of service attack due to the parsing
Mark Doliner <mark@kingant.net>
parents:
29440
diff
changeset
|
5007 |
89b4054deba1
Fix CVE-2010-0423, a denial of service attack due to the parsing
Mark Doliner <mark@kingant.net>
parents:
29440
diff
changeset
|
5008 g_object_set_data(G_OBJECT(imhtml), "gtkimhtml_numsmileys_thismsg", GINT_TO_POINTER(numsmileys_thismsg + 1)); |
89b4054deba1
Fix CVE-2010-0423, a denial of service attack due to the parsing
Mark Doliner <mark@kingant.net>
parents:
29440
diff
changeset
|
5009 g_object_set_data(G_OBJECT(imhtml), "gtkimhtml_numsmileys_total", GINT_TO_POINTER(numsmileys_total + 1)); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5010 } else if (imhtml_smiley != NULL && (imhtml->format_functions & GTK_IMHTML_SMILEY)) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5011 anchor = gtk_text_buffer_create_child_anchor(imhtml->text_buffer, iter); |
23257
86bf0ce0d7ac
Do not try to update received custom smileys in a deleted child anchor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23237
diff
changeset
|
5012 imhtml_smiley->anchors = g_slist_append(imhtml_smiley->anchors, g_object_ref(anchor)); |
16964
ab45289d2c36
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 <imadil@gmail.com>
parents:
16309
diff
changeset
|
5013 if (ebox) { |
ab45289d2c36
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 <imadil@gmail.com>
parents:
16309
diff
changeset
|
5014 GtkWidget *img = gtk_image_new_from_stock(GTK_STOCK_MISSING_IMAGE, GTK_ICON_SIZE_MENU); |
ab45289d2c36
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 <imadil@gmail.com>
parents:
16309
diff
changeset
|
5015 gtk_container_add(GTK_CONTAINER(ebox), img); |
ab45289d2c36
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 <imadil@gmail.com>
parents:
16309
diff
changeset
|
5016 gtk_widget_show(img); |
29440 | 5017 g_object_set_data_full(G_OBJECT(anchor), "gtkimhtml_plaintext", g_strdup(unescaped), g_free); |
5018 g_object_set_data_full(G_OBJECT(anchor), "gtkimhtml_tiptext", g_strdup(unescaped), g_free); | |
27032
d9f2a7f18759
We want to see what the missing custom smiley stands for.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
26972
diff
changeset
|
5019 g_object_set_data_full(G_OBJECT(anchor), "gtkimhtml_htmltext", g_strdup(smiley), g_free); |
16964
ab45289d2c36
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 <imadil@gmail.com>
parents:
16309
diff
changeset
|
5020 gtk_text_view_add_child_at_anchor(GTK_TEXT_VIEW(imhtml), ebox, anchor); |
ab45289d2c36
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 <imadil@gmail.com>
parents:
16309
diff
changeset
|
5021 } |
29468
89b4054deba1
Fix CVE-2010-0423, a denial of service attack due to the parsing
Mark Doliner <mark@kingant.net>
parents:
29440
diff
changeset
|
5022 |
89b4054deba1
Fix CVE-2010-0423, a denial of service attack due to the parsing
Mark Doliner <mark@kingant.net>
parents:
29440
diff
changeset
|
5023 g_object_set_data(G_OBJECT(imhtml), "gtkimhtml_numsmileys_thismsg", GINT_TO_POINTER(numsmileys_thismsg + 1)); |
89b4054deba1
Fix CVE-2010-0423, a denial of service attack due to the parsing
Mark Doliner <mark@kingant.net>
parents:
29440
diff
changeset
|
5024 g_object_set_data(G_OBJECT(imhtml), "gtkimhtml_numsmileys_total", GINT_TO_POINTER(numsmileys_total + 1)); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5025 } else { |
31426
1203778744d0
gtkimhtml: Display "<3" instead of "<3" after too many smileys in convo
Paul Aurich <paul@darkrain42.org>
parents:
30863
diff
changeset
|
5026 gtk_text_buffer_insert(imhtml->text_buffer, iter, unescaped, -1); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5027 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5028 |
16964
ab45289d2c36
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 <imadil@gmail.com>
parents:
16309
diff
changeset
|
5029 if (ebox) { |
ab45289d2c36
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 <imadil@gmail.com>
parents:
16309
diff
changeset
|
5030 g_signal_connect(G_OBJECT(ebox), "event", G_CALLBACK(gtk_imhtml_smiley_clicked), imhtml_smiley); |
ab45289d2c36
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 <imadil@gmail.com>
parents:
16309
diff
changeset
|
5031 } |
ab45289d2c36
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 <imadil@gmail.com>
parents:
16309
diff
changeset
|
5032 |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5033 g_free(unescaped); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5034 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5035 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5036 void gtk_imhtml_insert_image_at_iter(GtkIMHtml *imhtml, int id, GtkTextIter *iter) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5037 { |
18089
1f6599cd2d2b
When an animated image is inserted into a conversation window, animate
Mark Doliner <mark@kingant.net>
parents:
18056
diff
changeset
|
5038 GdkPixbufAnimation *anim = NULL; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5039 const char *filename = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5040 gpointer image; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5041 GdkRectangle rect; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5042 GtkIMHtmlScalable *scalable = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5043 struct scalable_data *sd; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5044 int minus; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5045 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5046 if (!imhtml->funcs || !imhtml->funcs->image_get || |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5047 !imhtml->funcs->image_get_size || !imhtml->funcs->image_get_data || |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5048 !imhtml->funcs->image_get_filename || !imhtml->funcs->image_ref || |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5049 !imhtml->funcs->image_unref) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5050 return; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5051 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5052 image = imhtml->funcs->image_get(id); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5053 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5054 if (image) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5055 gpointer data; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5056 size_t len; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5057 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5058 data = imhtml->funcs->image_get_data(image); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5059 len = imhtml->funcs->image_get_size(image); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5060 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5061 if (data && len) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5062 GdkPixbufLoader *loader = gdk_pixbuf_loader_new(); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5063 gdk_pixbuf_loader_write(loader, data, len, NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5064 gdk_pixbuf_loader_close(loader, NULL); |
18089
1f6599cd2d2b
When an animated image is inserted into a conversation window, animate
Mark Doliner <mark@kingant.net>
parents:
18056
diff
changeset
|
5065 anim = gdk_pixbuf_loader_get_animation(loader); |
1f6599cd2d2b
When an animated image is inserted into a conversation window, animate
Mark Doliner <mark@kingant.net>
parents:
18056
diff
changeset
|
5066 if (anim) |
1f6599cd2d2b
When an animated image is inserted into a conversation window, animate
Mark Doliner <mark@kingant.net>
parents:
18056
diff
changeset
|
5067 g_object_ref(G_OBJECT(anim)); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5068 g_object_unref(G_OBJECT(loader)); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5069 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5070 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5071 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5072 |
18089
1f6599cd2d2b
When an animated image is inserted into a conversation window, animate
Mark Doliner <mark@kingant.net>
parents:
18056
diff
changeset
|
5073 if (anim) { |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5074 struct im_image_data *t = g_new(struct im_image_data, 1); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5075 filename = imhtml->funcs->image_get_filename(image); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5076 imhtml->funcs->image_ref(id); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5077 t->id = id; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5078 t->mark = gtk_text_buffer_create_mark(imhtml->text_buffer, NULL, iter, TRUE); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5079 imhtml->im_images = g_slist_prepend(imhtml->im_images, t); |
18089
1f6599cd2d2b
When an animated image is inserted into a conversation window, animate
Mark Doliner <mark@kingant.net>
parents:
18056
diff
changeset
|
5080 scalable = gtk_imhtml_animation_new(anim, filename, id); |
1f6599cd2d2b
When an animated image is inserted into a conversation window, animate
Mark Doliner <mark@kingant.net>
parents:
18056
diff
changeset
|
5081 g_object_unref(G_OBJECT(anim)); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5082 } else { |
18089
1f6599cd2d2b
When an animated image is inserted into a conversation window, animate
Mark Doliner <mark@kingant.net>
parents:
18056
diff
changeset
|
5083 GdkPixbuf *pixbuf; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5084 pixbuf = gtk_widget_render_icon(GTK_WIDGET(imhtml), GTK_STOCK_MISSING_IMAGE, |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5085 GTK_ICON_SIZE_BUTTON, "gtkimhtml-missing-image"); |
18089
1f6599cd2d2b
When an animated image is inserted into a conversation window, animate
Mark Doliner <mark@kingant.net>
parents:
18056
diff
changeset
|
5086 scalable = gtk_imhtml_image_new(pixbuf, filename, id); |
1f6599cd2d2b
When an animated image is inserted into a conversation window, animate
Mark Doliner <mark@kingant.net>
parents:
18056
diff
changeset
|
5087 g_object_unref(G_OBJECT(pixbuf)); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5088 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5089 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5090 sd = g_new(struct scalable_data, 1); |
18089
1f6599cd2d2b
When an animated image is inserted into a conversation window, animate
Mark Doliner <mark@kingant.net>
parents:
18056
diff
changeset
|
5091 sd->scalable = scalable; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5092 sd->mark = gtk_text_buffer_create_mark(imhtml->text_buffer, NULL, iter, TRUE); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5093 gtk_text_view_get_visible_rect(GTK_TEXT_VIEW(imhtml), &rect); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5094 scalable->add_to(scalable, imhtml, iter); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5095 minus = gtk_text_view_get_left_margin(GTK_TEXT_VIEW(imhtml)) + |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5096 gtk_text_view_get_right_margin(GTK_TEXT_VIEW(imhtml)); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5097 scalable->scale(scalable, rect.width - minus, rect.height); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5098 imhtml->scalables = g_list_append(imhtml->scalables, sd); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5099 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5100 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5101 static const gchar *tag_to_html_start(GtkTextTag *tag) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5102 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5103 const gchar *name; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5104 static gchar buf[1024]; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5105 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5106 name = tag->name; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5107 g_return_val_if_fail(name != NULL, ""); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5108 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5109 if (strcmp(name, "BOLD") == 0) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5110 return "<b>"; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5111 } else if (strcmp(name, "ITALICS") == 0) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5112 return "<i>"; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5113 } else if (strcmp(name, "UNDERLINE") == 0) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5114 return "<u>"; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5115 } else if (strcmp(name, "STRIKE") == 0) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5116 return "<s>"; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5117 } else if (strncmp(name, "LINK ", 5) == 0) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5118 char *tmp = g_object_get_data(G_OBJECT(tag), "link_url"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5119 if (tmp) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5120 g_snprintf(buf, sizeof(buf), "<a href=\"%s\">", tmp); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5121 buf[sizeof(buf)-1] = '\0'; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5122 return buf; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5123 } else { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5124 return ""; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5125 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5126 } else if (strncmp(name, "FORECOLOR ", 10) == 0) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5127 g_snprintf(buf, sizeof(buf), "<font color=\"%s\">", &name[10]); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5128 return buf; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5129 } else if (strncmp(name, "BACKCOLOR ", 10) == 0) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5130 g_snprintf(buf, sizeof(buf), "<font back=\"%s\">", &name[10]); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5131 return buf; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5132 } else if (strncmp(name, "BACKGROUND ", 10) == 0) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5133 g_snprintf(buf, sizeof(buf), "<body bgcolor=\"%s\">", &name[11]); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5134 return buf; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5135 } else if (strncmp(name, "FONT FACE ", 10) == 0) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5136 g_snprintf(buf, sizeof(buf), "<font face=\"%s\">", &name[10]); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5137 return buf; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5138 } else if (strncmp(name, "FONT SIZE ", 10) == 0) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5139 g_snprintf(buf, sizeof(buf), "<font size=\"%s\">", &name[10]); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5140 return buf; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5141 } else { |
23167
9f94bf3743c2
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23163
diff
changeset
|
5142 char *str = buf; |
9f94bf3743c2
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23163
diff
changeset
|
5143 gboolean isset; |
9f94bf3743c2
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23163
diff
changeset
|
5144 int ivalue = 0; |
9f94bf3743c2
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23163
diff
changeset
|
5145 GdkColor *color = NULL; |
9f94bf3743c2
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23163
diff
changeset
|
5146 GObject *obj = G_OBJECT(tag); |
9f94bf3743c2
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23163
diff
changeset
|
5147 gboolean empty = TRUE; |
9f94bf3743c2
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23163
diff
changeset
|
5148 |
23169
88d67b1bb52a
Get rid of the boldness of the bold timestamps.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23167
diff
changeset
|
5149 str += g_snprintf(str, sizeof(buf) - (str - buf), "<span style='"); |
23167
9f94bf3743c2
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23163
diff
changeset
|
5150 |
9f94bf3743c2
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23163
diff
changeset
|
5151 /* Weight */ |
9f94bf3743c2
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23163
diff
changeset
|
5152 g_object_get(obj, "weight-set", &isset, "weight", &ivalue, NULL); |
9f94bf3743c2
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23163
diff
changeset
|
5153 if (isset) { |
9f94bf3743c2
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23163
diff
changeset
|
5154 const char *weight = ""; |
9f94bf3743c2
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23163
diff
changeset
|
5155 if (ivalue >= PANGO_WEIGHT_ULTRABOLD) |
9f94bf3743c2
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23163
diff
changeset
|
5156 weight = "bolder"; |
9f94bf3743c2
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23163
diff
changeset
|
5157 else if (ivalue >= PANGO_WEIGHT_BOLD) |
9f94bf3743c2
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23163
diff
changeset
|
5158 weight = "bold"; |
9f94bf3743c2
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23163
diff
changeset
|
5159 else if (ivalue >= PANGO_WEIGHT_NORMAL) |
9f94bf3743c2
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23163
diff
changeset
|
5160 weight = "normal"; |
9f94bf3743c2
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23163
diff
changeset
|
5161 else |
9f94bf3743c2
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23163
diff
changeset
|
5162 weight = "lighter"; |
9f94bf3743c2
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23163
diff
changeset
|
5163 |
9f94bf3743c2
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23163
diff
changeset
|
5164 str += g_snprintf(str, sizeof(buf) - (str - buf), "font-weight: %s;", weight); |
9f94bf3743c2
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23163
diff
changeset
|
5165 empty = FALSE; |
9f94bf3743c2
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23163
diff
changeset
|
5166 } |
9f94bf3743c2
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23163
diff
changeset
|
5167 |
9f94bf3743c2
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23163
diff
changeset
|
5168 /* Foreground color */ |
9f94bf3743c2
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23163
diff
changeset
|
5169 g_object_get(obj, "foreground-set", &isset, "foreground-gdk", &color, NULL); |
9f94bf3743c2
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23163
diff
changeset
|
5170 if (isset && color) { |
9f94bf3743c2
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23163
diff
changeset
|
5171 str += g_snprintf(str, sizeof(buf) - (str - buf), |
9f94bf3743c2
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23163
diff
changeset
|
5172 "color: #%02x%02x%02x;", |
9f94bf3743c2
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23163
diff
changeset
|
5173 color->red >> 8, color->green >> 8, color->blue >> 8); |
9f94bf3743c2
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23163
diff
changeset
|
5174 empty = FALSE; |
9f94bf3743c2
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23163
diff
changeset
|
5175 } |
23325
8c315f969600
Patch from Andrew Gaul that fixes another leak:
Ka-Hing Cheung <khc@hxbc.us>
parents:
23324
diff
changeset
|
5176 gdk_color_free(color); |
23167
9f94bf3743c2
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23163
diff
changeset
|
5177 |
9f94bf3743c2
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23163
diff
changeset
|
5178 /* Background color */ |
9f94bf3743c2
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23163
diff
changeset
|
5179 g_object_get(obj, "background-set", &isset, "background-gdk", &color, NULL); |
9f94bf3743c2
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23163
diff
changeset
|
5180 if (isset && color) { |
9f94bf3743c2
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23163
diff
changeset
|
5181 str += g_snprintf(str, sizeof(buf) - (str - buf), |
9f94bf3743c2
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23163
diff
changeset
|
5182 "background: #%02x%02x%02x;", |
9f94bf3743c2
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23163
diff
changeset
|
5183 color->red >> 8, color->green >> 8, color->blue >> 8); |
9f94bf3743c2
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23163
diff
changeset
|
5184 empty = FALSE; |
9f94bf3743c2
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23163
diff
changeset
|
5185 } |
23325
8c315f969600
Patch from Andrew Gaul that fixes another leak:
Ka-Hing Cheung <khc@hxbc.us>
parents:
23324
diff
changeset
|
5186 gdk_color_free(color); |
23167
9f94bf3743c2
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23163
diff
changeset
|
5187 |
9f94bf3743c2
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23163
diff
changeset
|
5188 /* Underline */ |
9f94bf3743c2
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23163
diff
changeset
|
5189 g_object_get(obj, "underline-set", &isset, "underline", &ivalue, NULL); |
9f94bf3743c2
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23163
diff
changeset
|
5190 if (isset) { |
9f94bf3743c2
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23163
diff
changeset
|
5191 switch (ivalue) { |
9f94bf3743c2
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23163
diff
changeset
|
5192 case PANGO_UNDERLINE_NONE: |
9f94bf3743c2
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23163
diff
changeset
|
5193 case PANGO_UNDERLINE_ERROR: |
9f94bf3743c2
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23163
diff
changeset
|
5194 break; |
9f94bf3743c2
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23163
diff
changeset
|
5195 default: |
9f94bf3743c2
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23163
diff
changeset
|
5196 str += g_snprintf(str, sizeof(buf) - (str - buf), "text-decoration: underline;"); |
23224
dbde19256cab
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23196
diff
changeset
|
5197 empty = FALSE; |
23167
9f94bf3743c2
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23163
diff
changeset
|
5198 } |
9f94bf3743c2
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23163
diff
changeset
|
5199 } |
9f94bf3743c2
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23163
diff
changeset
|
5200 |
9f94bf3743c2
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23163
diff
changeset
|
5201 g_snprintf(str, sizeof(buf) - (str - buf), "'>"); |
9f94bf3743c2
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23163
diff
changeset
|
5202 |
9f94bf3743c2
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23163
diff
changeset
|
5203 return (empty ? "" : buf); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5204 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5205 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5206 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5207 static const gchar *tag_to_html_end(GtkTextTag *tag) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5208 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5209 const gchar *name; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5210 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5211 name = tag->name; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5212 g_return_val_if_fail(name != NULL, ""); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5213 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5214 if (strcmp(name, "BOLD") == 0) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5215 return "</b>"; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5216 } else if (strcmp(name, "ITALICS") == 0) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5217 return "</i>"; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5218 } else if (strcmp(name, "UNDERLINE") == 0) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5219 return "</u>"; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5220 } else if (strcmp(name, "STRIKE") == 0) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5221 return "</s>"; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5222 } else if (strncmp(name, "LINK ", 5) == 0) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5223 return "</a>"; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5224 } else if (strncmp(name, "FORECOLOR ", 10) == 0) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5225 return "</font>"; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5226 } else if (strncmp(name, "BACKCOLOR ", 10) == 0) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5227 return "</font>"; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5228 } else if (strncmp(name, "BACKGROUND ", 10) == 0) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5229 return "</body>"; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5230 } else if (strncmp(name, "FONT FACE ", 10) == 0) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5231 return "</font>"; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5232 } else if (strncmp(name, "FONT SIZE ", 10) == 0) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5233 return "</font>"; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5234 } else { |
23167
9f94bf3743c2
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23163
diff
changeset
|
5235 const char *props[] = {"weight-set", "foreground-set", "background-set", |
9f94bf3743c2
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23163
diff
changeset
|
5236 "size-set", "underline-set", NULL}; |
9f94bf3743c2
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23163
diff
changeset
|
5237 int i; |
9f94bf3743c2
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23163
diff
changeset
|
5238 for (i = 0; props[i]; i++) { |
9f94bf3743c2
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23163
diff
changeset
|
5239 gboolean set = FALSE; |
9f94bf3743c2
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23163
diff
changeset
|
5240 g_object_get(G_OBJECT(tag), props[i], &set, NULL); |
9f94bf3743c2
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23163
diff
changeset
|
5241 if (set) |
23169
88d67b1bb52a
Get rid of the boldness of the bold timestamps.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23167
diff
changeset
|
5242 return "</span>"; |
23167
9f94bf3743c2
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23163
diff
changeset
|
5243 } |
9f94bf3743c2
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23163
diff
changeset
|
5244 |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5245 return ""; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5246 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5247 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5248 |
23224
dbde19256cab
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23196
diff
changeset
|
5249 typedef struct { |
dbde19256cab
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23196
diff
changeset
|
5250 GtkTextTag *tag; |
dbde19256cab
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23196
diff
changeset
|
5251 char *end; |
dbde19256cab
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23196
diff
changeset
|
5252 char *start; |
dbde19256cab
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23196
diff
changeset
|
5253 } PidginTextTagData; |
dbde19256cab
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23196
diff
changeset
|
5254 |
dbde19256cab
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23196
diff
changeset
|
5255 static PidginTextTagData *text_tag_data_new(GtkTextTag *tag) |
dbde19256cab
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23196
diff
changeset
|
5256 { |
dbde19256cab
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23196
diff
changeset
|
5257 const char *start, *end; |
dbde19256cab
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23196
diff
changeset
|
5258 PidginTextTagData *ret = NULL; |
dbde19256cab
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23196
diff
changeset
|
5259 |
dbde19256cab
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23196
diff
changeset
|
5260 start = tag_to_html_start(tag); |
dbde19256cab
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23196
diff
changeset
|
5261 if (!start || !*start) |
dbde19256cab
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23196
diff
changeset
|
5262 return NULL; |
dbde19256cab
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23196
diff
changeset
|
5263 end = tag_to_html_end(tag); |
dbde19256cab
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23196
diff
changeset
|
5264 if (!end || !*end) |
dbde19256cab
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23196
diff
changeset
|
5265 return NULL; |
dbde19256cab
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23196
diff
changeset
|
5266 |
dbde19256cab
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23196
diff
changeset
|
5267 ret = g_new0(PidginTextTagData, 1); |
dbde19256cab
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23196
diff
changeset
|
5268 ret->start = g_strdup(start); |
dbde19256cab
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23196
diff
changeset
|
5269 ret->end = g_strdup(end); |
dbde19256cab
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23196
diff
changeset
|
5270 ret->tag = tag; |
dbde19256cab
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23196
diff
changeset
|
5271 return ret; |
dbde19256cab
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23196
diff
changeset
|
5272 } |
dbde19256cab
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23196
diff
changeset
|
5273 |
dbde19256cab
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23196
diff
changeset
|
5274 static void text_tag_data_destroy(PidginTextTagData *data) |
dbde19256cab
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23196
diff
changeset
|
5275 { |
dbde19256cab
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23196
diff
changeset
|
5276 g_free(data->start); |
dbde19256cab
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23196
diff
changeset
|
5277 g_free(data->end); |
dbde19256cab
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23196
diff
changeset
|
5278 g_free(data); |
dbde19256cab
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23196
diff
changeset
|
5279 } |
dbde19256cab
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23196
diff
changeset
|
5280 |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5281 static gboolean tag_ends_here(GtkTextTag *tag, GtkTextIter *iter, GtkTextIter *niter) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5282 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5283 return ((gtk_text_iter_has_tag(iter, GTK_TEXT_TAG(tag)) && |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5284 !gtk_text_iter_has_tag(niter, GTK_TEXT_TAG(tag))) || |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5285 gtk_text_iter_is_end(niter)); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5286 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5287 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5288 /* Basic notion here: traverse through the text buffer one-by-one, non-character elements, such |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5289 * as smileys and IM images are represented by the Unicode "unknown" character. Handle them. Else |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5290 * check for tags that are toggled on, insert their html form, and push them on the queue. Then insert |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5291 * the actual text. Then check for tags that are toggled off and insert them, after checking the queue. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5292 * Finally, replace <, >, &, and " with their HTML equivalent. |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5293 */ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5294 char *gtk_imhtml_get_markup_range(GtkIMHtml *imhtml, GtkTextIter *start, GtkTextIter *end) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5295 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5296 gunichar c; |
16083
f2a4b05407d7
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15871
diff
changeset
|
5297 GtkTextIter iter, next_iter, non_neutral_iter; |
f2a4b05407d7
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15871
diff
changeset
|
5298 gboolean is_rtl_message = FALSE; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5299 GString *str = g_string_new(""); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5300 GSList *tags, *sl; |
23224
dbde19256cab
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23196
diff
changeset
|
5301 GQueue *q; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5302 GtkTextTag *tag; |
23224
dbde19256cab
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23196
diff
changeset
|
5303 PidginTextTagData *tagdata; |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5304 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5305 q = g_queue_new(); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5306 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5307 gtk_text_iter_order(start, end); |
16083
f2a4b05407d7
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15871
diff
changeset
|
5308 non_neutral_iter = next_iter = iter = *start; |
f2a4b05407d7
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15871
diff
changeset
|
5309 gtk_text_iter_forward_char(&next_iter); |
f2a4b05407d7
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15871
diff
changeset
|
5310 |
f2a4b05407d7
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15871
diff
changeset
|
5311 /* Bi-directional text support */ |
f2a4b05407d7
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15871
diff
changeset
|
5312 /* Get to the first non-neutral character */ |
16229
12e2ee612d5f
Fix for using Pango < 1.4, will not have complete RTL support with older
Stu Tomlinson <stu@nosnilmot.com>
parents:
16193
diff
changeset
|
5313 #ifdef HAVE_PANGO14 |
16084 | 5314 while ((PANGO_DIRECTION_NEUTRAL == pango_unichar_direction(gtk_text_iter_get_char(&non_neutral_iter))) |
16083
f2a4b05407d7
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15871
diff
changeset
|
5315 && gtk_text_iter_forward_char(&non_neutral_iter)); |
16084 | 5316 if (PANGO_DIRECTION_RTL == pango_unichar_direction(gtk_text_iter_get_char(&non_neutral_iter))) { |
16083
f2a4b05407d7
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15871
diff
changeset
|
5317 is_rtl_message = TRUE; |
f2a4b05407d7
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15871
diff
changeset
|
5318 g_string_append(str, "<SPAN style=\"direction:rtl;text-align:right;\">"); |
f2a4b05407d7
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15871
diff
changeset
|
5319 } |
16229
12e2ee612d5f
Fix for using Pango < 1.4, will not have complete RTL support with older
Stu Tomlinson <stu@nosnilmot.com>
parents:
16193
diff
changeset
|
5320 #endif |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5321 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5322 /* First add the tags that are already in progress (we don't care about non-printing tags)*/ |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5323 tags = gtk_text_iter_get_tags(start); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5324 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5325 for (sl = tags; sl; sl = sl->next) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5326 tag = sl->data; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5327 if (!gtk_text_iter_toggles_tag(start, GTK_TEXT_TAG(tag))) { |
23224
dbde19256cab
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23196
diff
changeset
|
5328 PidginTextTagData *data = text_tag_data_new(tag); |
dbde19256cab
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23196
diff
changeset
|
5329 if (data) { |
dbde19256cab
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23196
diff
changeset
|
5330 g_string_append(str, data->start); |
dbde19256cab
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23196
diff
changeset
|
5331 g_queue_push_tail(q, data); |
dbde19256cab
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23196
diff
changeset
|
5332 } |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5333 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5334 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5335 g_slist_free(tags); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5336 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5337 while ((c = gtk_text_iter_get_char(&iter)) != 0 && !gtk_text_iter_equal(&iter, end)) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5338 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5339 tags = gtk_text_iter_get_tags(&iter); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5340 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5341 for (sl = tags; sl; sl = sl->next) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5342 tag = sl->data; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5343 if (gtk_text_iter_begins_tag(&iter, GTK_TEXT_TAG(tag))) { |
23224
dbde19256cab
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23196
diff
changeset
|
5344 PidginTextTagData *data = text_tag_data_new(tag); |
dbde19256cab
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23196
diff
changeset
|
5345 if (data) { |
dbde19256cab
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23196
diff
changeset
|
5346 g_string_append(str, data->start); |
dbde19256cab
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23196
diff
changeset
|
5347 g_queue_push_tail(q, data); |
dbde19256cab
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23196
diff
changeset
|
5348 } |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5349 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5350 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5351 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5352 if (c == 0xFFFC) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5353 GtkTextChildAnchor* anchor = gtk_text_iter_get_child_anchor(&iter); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5354 if (anchor) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5355 char *text = g_object_get_data(G_OBJECT(anchor), "gtkimhtml_htmltext"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5356 if (text) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5357 str = g_string_append(str, text); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5358 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5359 } else if (c == '<') { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5360 str = g_string_append(str, "<"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5361 } else if (c == '>') { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5362 str = g_string_append(str, ">"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5363 } else if (c == '&') { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5364 str = g_string_append(str, "&"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5365 } else if (c == '"') { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5366 str = g_string_append(str, """); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5367 } else if (c == '\n') { |
19590
2f7b3564bb7e
disapproval of revision '2887999526ff013d0ffa94da958cd30181ee3aa1'
Kevin Stange <kevin@simguy.net>
parents:
19589
diff
changeset
|
5368 str = g_string_append(str, "<br>"); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5369 } else { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5370 str = g_string_append_unichar(str, c); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5371 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5372 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5373 tags = g_slist_reverse(tags); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5374 for (sl = tags; sl; sl = sl->next) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5375 tag = sl->data; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5376 /** don't worry about non-printing tags ending */ |
23224
dbde19256cab
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23196
diff
changeset
|
5377 if (tag_ends_here(tag, &iter, &next_iter) && |
dbde19256cab
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23196
diff
changeset
|
5378 strlen(tag_to_html_end(tag)) > 0 && |
dbde19256cab
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23196
diff
changeset
|
5379 strlen(tag_to_html_start(tag)) > 0) { |
dbde19256cab
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23196
diff
changeset
|
5380 |
dbde19256cab
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23196
diff
changeset
|
5381 PidginTextTagData *tmp; |
dbde19256cab
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23196
diff
changeset
|
5382 GQueue *r = g_queue_new(); |
dbde19256cab
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23196
diff
changeset
|
5383 |
dbde19256cab
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23196
diff
changeset
|
5384 while ((tmp = g_queue_pop_tail(q)) && tmp->tag != tag) { |
dbde19256cab
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23196
diff
changeset
|
5385 g_string_append(str, tmp->end); |
dbde19256cab
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23196
diff
changeset
|
5386 if (!tag_ends_here(tmp->tag, &iter, &next_iter)) |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5387 g_queue_push_tail(r, tmp); |
23224
dbde19256cab
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23196
diff
changeset
|
5388 else |
dbde19256cab
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23196
diff
changeset
|
5389 text_tag_data_destroy(tmp); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5390 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5391 |
24997
3d456ca75ed9
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 <daniel.atallah@gmail.com>
parents:
24829
diff
changeset
|
5392 if (tmp != NULL) { |
23224
dbde19256cab
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23196
diff
changeset
|
5393 g_string_append(str, tmp->end); |
23324
0d47aab4ca5c
Patch from Andrew Gaul that fixes a leak:
Ka-Hing Cheung <khc@hxbc.us>
parents:
23257
diff
changeset
|
5394 text_tag_data_destroy(tmp); |
0d47aab4ca5c
Patch from Andrew Gaul that fixes a leak:
Ka-Hing Cheung <khc@hxbc.us>
parents:
23257
diff
changeset
|
5395 } |
24997
3d456ca75ed9
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 <daniel.atallah@gmail.com>
parents:
24829
diff
changeset
|
5396 #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 */ |
3d456ca75ed9
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 <daniel.atallah@gmail.com>
parents:
24829
diff
changeset
|
5397 else |
3d456ca75ed9
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 <daniel.atallah@gmail.com>
parents:
24829
diff
changeset
|
5398 purple_debug_warning("gtkimhtml", "empty queue, more closing tags than open tags!\n"); |
3d456ca75ed9
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 <daniel.atallah@gmail.com>
parents:
24829
diff
changeset
|
5399 #endif |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5400 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5401 while ((tmp = g_queue_pop_head(r))) { |
23224
dbde19256cab
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23196
diff
changeset
|
5402 g_string_append(str, tmp->start); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5403 g_queue_push_tail(q, tmp); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5404 } |
23224
dbde19256cab
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23196
diff
changeset
|
5405 g_queue_free(r); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5406 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5407 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5408 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5409 g_slist_free(tags); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5410 gtk_text_iter_forward_char(&iter); |
16083
f2a4b05407d7
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15871
diff
changeset
|
5411 gtk_text_iter_forward_char(&next_iter); |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5412 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5413 |
23224
dbde19256cab
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23196
diff
changeset
|
5414 while ((tagdata = g_queue_pop_tail(q))) { |
dbde19256cab
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23196
diff
changeset
|
5415 g_string_append(str, tagdata->end); |
dbde19256cab
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23196
diff
changeset
|
5416 text_tag_data_destroy(tagdata); |
dbde19256cab
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23196
diff
changeset
|
5417 } |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5418 |
16083
f2a4b05407d7
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15871
diff
changeset
|
5419 /* Bi-directional text support - close tags */ |
16084 | 5420 if (is_rtl_message) |
16083
f2a4b05407d7
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15871
diff
changeset
|
5421 g_string_append(str, "</SPAN>"); |
f2a4b05407d7
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15871
diff
changeset
|
5422 |
15374
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5423 g_queue_free(q); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5424 return g_string_free(str, FALSE); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5425 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5426 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5427 void gtk_imhtml_close_tags(GtkIMHtml *imhtml, GtkTextIter *iter) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5428 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5429 if (imhtml->edit.bold) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5430 gtk_imhtml_toggle_bold(imhtml); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5431 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5432 if (imhtml->edit.italic) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5433 gtk_imhtml_toggle_italic(imhtml); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5434 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5435 if (imhtml->edit.underline) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5436 gtk_imhtml_toggle_underline(imhtml); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5437 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5438 if (imhtml->edit.strike) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5439 gtk_imhtml_toggle_strike(imhtml); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5440 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5441 if (imhtml->edit.forecolor) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5442 gtk_imhtml_toggle_forecolor(imhtml, NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5443 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5444 if (imhtml->edit.backcolor) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5445 gtk_imhtml_toggle_backcolor(imhtml, NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5446 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5447 if (imhtml->edit.fontface) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5448 gtk_imhtml_toggle_fontface(imhtml, NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5449 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5450 imhtml->edit.fontsize = 0; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5451 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5452 if (imhtml->edit.link) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5453 gtk_imhtml_toggle_link(imhtml, NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5454 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5455 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5456 char *gtk_imhtml_get_markup(GtkIMHtml *imhtml) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5457 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5458 GtkTextIter start, end; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5459 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5460 gtk_text_buffer_get_start_iter(imhtml->text_buffer, &start); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5461 gtk_text_buffer_get_end_iter(imhtml->text_buffer, &end); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5462 return gtk_imhtml_get_markup_range(imhtml, &start, &end); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5463 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5464 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5465 char **gtk_imhtml_get_markup_lines(GtkIMHtml *imhtml) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5466 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5467 int i, j, lines; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5468 GtkTextIter start, end; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5469 char **ret; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5470 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5471 lines = gtk_text_buffer_get_line_count(imhtml->text_buffer); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5472 ret = g_new0(char *, lines + 1); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5473 gtk_text_buffer_get_start_iter(imhtml->text_buffer, &start); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5474 end = start; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5475 gtk_text_iter_forward_to_line_end(&end); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5476 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5477 for (i = 0, j = 0; i < lines; i++) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5478 if (gtk_text_iter_get_char(&start) != '\n') { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5479 ret[j] = gtk_imhtml_get_markup_range(imhtml, &start, &end); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5480 if (ret[j] != NULL) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5481 j++; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5482 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5483 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5484 gtk_text_iter_forward_line(&start); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5485 end = start; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5486 gtk_text_iter_forward_to_line_end(&end); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5487 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5488 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5489 return ret; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5490 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5491 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5492 char *gtk_imhtml_get_text(GtkIMHtml *imhtml, GtkTextIter *start, GtkTextIter *stop) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5493 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5494 GString *str = g_string_new(""); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5495 GtkTextIter iter, end; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5496 gunichar c; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5497 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5498 if (start == NULL) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5499 gtk_text_buffer_get_start_iter(imhtml->text_buffer, &iter); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5500 else |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5501 iter = *start; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5502 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5503 if (stop == NULL) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5504 gtk_text_buffer_get_end_iter(imhtml->text_buffer, &end); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5505 else |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5506 end = *stop; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5507 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5508 gtk_text_iter_order(&iter, &end); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5509 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5510 while ((c = gtk_text_iter_get_char(&iter)) != 0 && !gtk_text_iter_equal(&iter, &end)) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5511 if (c == 0xFFFC) { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5512 GtkTextChildAnchor* anchor; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5513 char *text = NULL; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5514 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5515 anchor = gtk_text_iter_get_child_anchor(&iter); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5516 if (anchor) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5517 text = g_object_get_data(G_OBJECT(anchor), "gtkimhtml_plaintext"); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5518 if (text) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5519 str = g_string_append(str, text); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5520 } else { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5521 g_string_append_unichar(str, c); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5522 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5523 gtk_text_iter_forward_char(&iter); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5524 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5525 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5526 return g_string_free(str, FALSE); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5527 } |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5528 |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5529 void gtk_imhtml_set_funcs(GtkIMHtml *imhtml, GtkIMHtmlFuncs *f) |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5530 { |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5531 g_return_if_fail(imhtml != NULL); |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5532 imhtml->funcs = f; |
5fe8042783c1
Rename gtk/ and libgaim/ to pidgin/ and libpurple/
Sean Egan <seanegan@gmail.com>
parents:
diff
changeset
|
5533 } |
17517
274ceb453176
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17245
diff
changeset
|
5534 |
274ceb453176
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17245
diff
changeset
|
5535 void gtk_imhtml_setup_entry(GtkIMHtml *imhtml, PurpleConnectionFlags flags) |
274ceb453176
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17245
diff
changeset
|
5536 { |
18167
b8b475f31008
Fix setting the sensitivity of the toolbar items in a number of places
Stu Tomlinson <stu@nosnilmot.com>
parents:
18113
diff
changeset
|
5537 GtkIMHtmlButtons buttons; |
b8b475f31008
Fix setting the sensitivity of the toolbar items in a number of places
Stu Tomlinson <stu@nosnilmot.com>
parents:
18113
diff
changeset
|
5538 |
17517
274ceb453176
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17245
diff
changeset
|
5539 if (flags & PURPLE_CONNECTION_HTML) { |
274ceb453176
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17245
diff
changeset
|
5540 char color[8]; |
274ceb453176
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17245
diff
changeset
|
5541 GdkColor fg_color, bg_color; |
274ceb453176
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17245
diff
changeset
|
5542 |
18167
b8b475f31008
Fix setting the sensitivity of the toolbar items in a number of places
Stu Tomlinson <stu@nosnilmot.com>
parents:
18113
diff
changeset
|
5543 buttons = GTK_IMHTML_ALL; |
b8b475f31008
Fix setting the sensitivity of the toolbar items in a number of places
Stu Tomlinson <stu@nosnilmot.com>
parents:
18113
diff
changeset
|
5544 |
b8b475f31008
Fix setting the sensitivity of the toolbar items in a number of places
Stu Tomlinson <stu@nosnilmot.com>
parents:
18113
diff
changeset
|
5545 if (flags & PURPLE_CONNECTION_NO_BGCOLOR) |
b8b475f31008
Fix setting the sensitivity of the toolbar items in a number of places
Stu Tomlinson <stu@nosnilmot.com>
parents:
18113
diff
changeset
|
5546 buttons &= ~GTK_IMHTML_BACKCOLOR; |
b8b475f31008
Fix setting the sensitivity of the toolbar items in a number of places
Stu Tomlinson <stu@nosnilmot.com>
parents:
18113
diff
changeset
|
5547 if (flags & PURPLE_CONNECTION_NO_FONTSIZE) |
b8b475f31008
Fix setting the sensitivity of the toolbar items in a number of places
Stu Tomlinson <stu@nosnilmot.com>
parents:
18113
diff
changeset
|
5548 { |
b8b475f31008
Fix setting the sensitivity of the toolbar items in a number of places
Stu Tomlinson <stu@nosnilmot.com>
parents:
18113
diff
changeset
|
5549 buttons &= ~GTK_IMHTML_GROW; |
b8b475f31008
Fix setting the sensitivity of the toolbar items in a number of places
Stu Tomlinson <stu@nosnilmot.com>
parents:
18113
diff
changeset
|
5550 buttons &= ~GTK_IMHTML_SHRINK; |
b8b475f31008
Fix setting the sensitivity of the toolbar items in a number of places
Stu Tomlinson <stu@nosnilmot.com>
parents:
18113
diff
changeset
|
5551 } |
b8b475f31008
Fix setting the sensitivity of the toolbar items in a number of places
Stu Tomlinson <stu@nosnilmot.com>
parents:
18113
diff
changeset
|
5552 if (flags & PURPLE_CONNECTION_NO_URLDESC) |
b8b475f31008
Fix setting the sensitivity of the toolbar items in a number of places
Stu Tomlinson <stu@nosnilmot.com>
parents:
18113
diff
changeset
|
5553 buttons &= ~GTK_IMHTML_LINKDESC; |
b8b475f31008
Fix setting the sensitivity of the toolbar items in a number of places
Stu Tomlinson <stu@nosnilmot.com>
parents:
18113
diff
changeset
|
5554 |
17517
274ceb453176
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17245
diff
changeset
|
5555 gtk_imhtml_set_format_functions(imhtml, GTK_IMHTML_ALL); |
274ceb453176
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17245
diff
changeset
|
5556 if (purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/conversations/send_bold") != imhtml->edit.bold) |
274ceb453176
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17245
diff
changeset
|
5557 gtk_imhtml_toggle_bold(imhtml); |
274ceb453176
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17245
diff
changeset
|
5558 |
274ceb453176
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17245
diff
changeset
|
5559 if (purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/conversations/send_italic") != imhtml->edit.italic) |
274ceb453176
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17245
diff
changeset
|
5560 gtk_imhtml_toggle_italic(imhtml); |
274ceb453176
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17245
diff
changeset
|
5561 |
274ceb453176
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17245
diff
changeset
|
5562 if (purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/conversations/send_underline") != imhtml->edit.underline) |
274ceb453176
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17245
diff
changeset
|
5563 gtk_imhtml_toggle_underline(imhtml); |
274ceb453176
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17245
diff
changeset
|
5564 |
274ceb453176
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17245
diff
changeset
|
5565 gtk_imhtml_toggle_fontface(imhtml, |
274ceb453176
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17245
diff
changeset
|
5566 purple_prefs_get_string(PIDGIN_PREFS_ROOT "/conversations/font_face")); |
274ceb453176
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17245
diff
changeset
|
5567 |
274ceb453176
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17245
diff
changeset
|
5568 if (!(flags & PURPLE_CONNECTION_NO_FONTSIZE)) |
274ceb453176
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17245
diff
changeset
|
5569 { |
274ceb453176
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17245
diff
changeset
|
5570 int size = purple_prefs_get_int(PIDGIN_PREFS_ROOT "/conversations/font_size"); |
274ceb453176
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17245
diff
changeset
|
5571 |
274ceb453176
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17245
diff
changeset
|
5572 /* 3 is the default. */ |
274ceb453176
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17245
diff
changeset
|
5573 if (size != 3) |
274ceb453176
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17245
diff
changeset
|
5574 gtk_imhtml_font_set_size(imhtml, size); |
274ceb453176
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17245
diff
changeset
|
5575 } |
274ceb453176
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17245
diff
changeset
|
5576 |
274ceb453176
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17245
diff
changeset
|
5577 if(strcmp(purple_prefs_get_string(PIDGIN_PREFS_ROOT "/conversations/fgcolor"), "") != 0) |
274ceb453176
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17245
diff
changeset
|
5578 { |
274ceb453176
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17245
diff
changeset
|
5579 gdk_color_parse(purple_prefs_get_string(PIDGIN_PREFS_ROOT "/conversations/fgcolor"), |
274ceb453176
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17245
diff
changeset
|
5580 &fg_color); |
274ceb453176
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17245
diff
changeset
|
5581 g_snprintf(color, sizeof(color), "#%02x%02x%02x", |
274ceb453176
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17245
diff
changeset
|
5582 fg_color.red / 256, |
274ceb453176
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17245
diff
changeset
|
5583 fg_color.green / 256, |
274ceb453176
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17245
diff
changeset
|
5584 fg_color.blue / 256); |
274ceb453176
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17245
diff
changeset
|
5585 } else |
274ceb453176
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17245
diff
changeset
|
5586 strcpy(color, ""); |
274ceb453176
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17245
diff
changeset
|
5587 |
274ceb453176
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17245
diff
changeset
|
5588 gtk_imhtml_toggle_forecolor(imhtml, color); |
274ceb453176
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17245
diff
changeset
|
5589 |
274ceb453176
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17245
diff
changeset
|
5590 if(!(flags & PURPLE_CONNECTION_NO_BGCOLOR) && |
274ceb453176
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17245
diff
changeset
|
5591 strcmp(purple_prefs_get_string(PIDGIN_PREFS_ROOT "/conversations/bgcolor"), "") != 0) |
274ceb453176
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17245
diff
changeset
|
5592 { |
274ceb453176
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17245
diff
changeset
|
5593 gdk_color_parse(purple_prefs_get_string(PIDGIN_PREFS_ROOT "/conversations/bgcolor"), |
274ceb453176
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17245
diff
changeset
|
5594 &bg_color); |
274ceb453176
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17245
diff
changeset
|
5595 g_snprintf(color, sizeof(color), "#%02x%02x%02x", |
274ceb453176
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17245
diff
changeset
|
5596 bg_color.red / 256, |
274ceb453176
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17245
diff
changeset
|
5597 bg_color.green / 256, |
274ceb453176
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17245
diff
changeset
|
5598 bg_color.blue / 256); |
274ceb453176
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17245
diff
changeset
|
5599 } else |
274ceb453176
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17245
diff
changeset
|
5600 strcpy(color, ""); |
274ceb453176
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17245
diff
changeset
|
5601 |
274ceb453176
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17245
diff
changeset
|
5602 gtk_imhtml_toggle_background(imhtml, color); |
274ceb453176
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17245
diff
changeset
|
5603 |
274ceb453176
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17245
diff
changeset
|
5604 if (flags & PURPLE_CONNECTION_FORMATTING_WBFO) |
274ceb453176
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17245
diff
changeset
|
5605 gtk_imhtml_set_whole_buffer_formatting_only(imhtml, TRUE); |
274ceb453176
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17245
diff
changeset
|
5606 else |
274ceb453176
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17245
diff
changeset
|
5607 gtk_imhtml_set_whole_buffer_formatting_only(imhtml, FALSE); |
274ceb453176
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17245
diff
changeset
|
5608 } else { |
18167
b8b475f31008
Fix setting the sensitivity of the toolbar items in a number of places
Stu Tomlinson <stu@nosnilmot.com>
parents:
18113
diff
changeset
|
5609 buttons = GTK_IMHTML_SMILEY | GTK_IMHTML_IMAGE; |
17517
274ceb453176
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17245
diff
changeset
|
5610 imhtml_clear_formatting(imhtml); |
274ceb453176
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17245
diff
changeset
|
5611 } |
18167
b8b475f31008
Fix setting the sensitivity of the toolbar items in a number of places
Stu Tomlinson <stu@nosnilmot.com>
parents:
18113
diff
changeset
|
5612 |
b8b475f31008
Fix setting the sensitivity of the toolbar items in a number of places
Stu Tomlinson <stu@nosnilmot.com>
parents:
18113
diff
changeset
|
5613 if (flags & PURPLE_CONNECTION_NO_IMAGES) |
b8b475f31008
Fix setting the sensitivity of the toolbar items in a number of places
Stu Tomlinson <stu@nosnilmot.com>
parents:
18113
diff
changeset
|
5614 buttons &= ~GTK_IMHTML_IMAGE; |
b8b475f31008
Fix setting the sensitivity of the toolbar items in a number of places
Stu Tomlinson <stu@nosnilmot.com>
parents:
18113
diff
changeset
|
5615 |
23133
9aa105267f46
Show the custom smileys only on accounts that support it. References
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23131
diff
changeset
|
5616 if (flags & PURPLE_CONNECTION_ALLOW_CUSTOM_SMILEY) |
9aa105267f46
Show the custom smileys only on accounts that support it. References
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23131
diff
changeset
|
5617 buttons |= GTK_IMHTML_CUSTOM_SMILEY; |
9aa105267f46
Show the custom smileys only on accounts that support it. References
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23131
diff
changeset
|
5618 else |
9aa105267f46
Show the custom smileys only on accounts that support it. References
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23131
diff
changeset
|
5619 buttons &= ~GTK_IMHTML_CUSTOM_SMILEY; |
9aa105267f46
Show the custom smileys only on accounts that support it. References
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23131
diff
changeset
|
5620 |
18167
b8b475f31008
Fix setting the sensitivity of the toolbar items in a number of places
Stu Tomlinson <stu@nosnilmot.com>
parents:
18113
diff
changeset
|
5621 gtk_imhtml_set_format_functions(imhtml, buttons); |
17517
274ceb453176
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17245
diff
changeset
|
5622 } |
274ceb453176
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
17245
diff
changeset
|
5623 |
22889
019052a807a3
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22387
diff
changeset
|
5624 /******* |
019052a807a3
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22387
diff
changeset
|
5625 * GtkIMHtmlSmiley functions |
019052a807a3
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22387
diff
changeset
|
5626 *******/ |
019052a807a3
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22387
diff
changeset
|
5627 static void gtk_custom_smiley_allocated(GdkPixbufLoader *loader, gpointer user_data) |
019052a807a3
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22387
diff
changeset
|
5628 { |
019052a807a3
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22387
diff
changeset
|
5629 GtkIMHtmlSmiley *smiley; |
019052a807a3
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22387
diff
changeset
|
5630 |
019052a807a3
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22387
diff
changeset
|
5631 smiley = (GtkIMHtmlSmiley *)user_data; |
019052a807a3
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22387
diff
changeset
|
5632 smiley->icon = gdk_pixbuf_loader_get_animation(loader); |
019052a807a3
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22387
diff
changeset
|
5633 |
019052a807a3
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22387
diff
changeset
|
5634 if (smiley->icon) |
019052a807a3
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22387
diff
changeset
|
5635 g_object_ref(G_OBJECT(smiley->icon)); |
019052a807a3
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22387
diff
changeset
|
5636 #ifdef DEBUG_CUSTOM_SMILEY |
019052a807a3
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22387
diff
changeset
|
5637 purple_debug_info("custom-smiley", "gtk_custom_smiley_allocated(): got GdkPixbufAnimation %p for smiley '%s'\n", smiley->icon, smiley->smile); |
019052a807a3
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22387
diff
changeset
|
5638 #endif |
019052a807a3
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22387
diff
changeset
|
5639 } |
019052a807a3
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22387
diff
changeset
|
5640 |
019052a807a3
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22387
diff
changeset
|
5641 static void gtk_custom_smiley_closed(GdkPixbufLoader *loader, gpointer user_data) |
019052a807a3
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22387
diff
changeset
|
5642 { |
019052a807a3
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22387
diff
changeset
|
5643 GtkIMHtmlSmiley *smiley; |
019052a807a3
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22387
diff
changeset
|
5644 GtkWidget *icon = NULL; |
019052a807a3
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22387
diff
changeset
|
5645 GtkTextChildAnchor *anchor = NULL; |
019052a807a3
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22387
diff
changeset
|
5646 GSList *current = NULL; |
019052a807a3
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22387
diff
changeset
|
5647 |
019052a807a3
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22387
diff
changeset
|
5648 smiley = (GtkIMHtmlSmiley *)user_data; |
019052a807a3
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22387
diff
changeset
|
5649 if (!smiley->imhtml) { |
019052a807a3
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22387
diff
changeset
|
5650 #ifdef DEBUG_CUSTOM_SMILEY |
019052a807a3
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22387
diff
changeset
|
5651 purple_debug_error("custom-smiley", "gtk_custom_smiley_closed(): orphan smiley found: %p\n", smiley); |
019052a807a3
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22387
diff
changeset
|
5652 #endif |
019052a807a3
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22387
diff
changeset
|
5653 g_object_unref(G_OBJECT(loader)); |
019052a807a3
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22387
diff
changeset
|
5654 smiley->loader = NULL; |
019052a807a3
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22387
diff
changeset
|
5655 return; |
019052a807a3
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22387
diff
changeset
|
5656 } |
019052a807a3
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22387
diff
changeset
|
5657 |
019052a807a3
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22387
diff
changeset
|
5658 for (current = smiley->anchors; current; current = g_slist_next(current)) { |
23257
86bf0ce0d7ac
Do not try to update received custom smileys in a deleted child anchor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23237
diff
changeset
|
5659 anchor = GTK_TEXT_CHILD_ANCHOR(current->data); |
86bf0ce0d7ac
Do not try to update received custom smileys in a deleted child anchor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23237
diff
changeset
|
5660 if (gtk_text_child_anchor_get_deleted(anchor)) |
86bf0ce0d7ac
Do not try to update received custom smileys in a deleted child anchor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23237
diff
changeset
|
5661 icon = NULL; |
86bf0ce0d7ac
Do not try to update received custom smileys in a deleted child anchor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23237
diff
changeset
|
5662 else |
86bf0ce0d7ac
Do not try to update received custom smileys in a deleted child anchor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23237
diff
changeset
|
5663 icon = gtk_image_new_from_animation(smiley->icon); |
22889
019052a807a3
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22387
diff
changeset
|
5664 |
019052a807a3
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22387
diff
changeset
|
5665 #ifdef DEBUG_CUSTOM_SMILEY |
019052a807a3
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22387
diff
changeset
|
5666 purple_debug_info("custom-smiley", "gtk_custom_smiley_closed(): got GtkImage %p from GtkPixbufAnimation %p for smiley '%s'\n", |
019052a807a3
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22387
diff
changeset
|
5667 icon, smiley->icon, smiley->smile); |
019052a807a3
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22387
diff
changeset
|
5668 #endif |
019052a807a3
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22387
diff
changeset
|
5669 if (icon) { |
019052a807a3
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22387
diff
changeset
|
5670 GList *wids; |
019052a807a3
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22387
diff
changeset
|
5671 gtk_widget_show(icon); |
019052a807a3
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22387
diff
changeset
|
5672 |
019052a807a3
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22387
diff
changeset
|
5673 wids = gtk_text_child_anchor_get_widgets(anchor); |
019052a807a3
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22387
diff
changeset
|
5674 |
019052a807a3
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22387
diff
changeset
|
5675 g_object_set_data_full(G_OBJECT(anchor), "gtkimhtml_plaintext", purple_unescape_html(smiley->smile), g_free); |
019052a807a3
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22387
diff
changeset
|
5676 g_object_set_data_full(G_OBJECT(anchor), "gtkimhtml_htmltext", g_strdup(smiley->smile), g_free); |
019052a807a3
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22387
diff
changeset
|
5677 |
019052a807a3
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22387
diff
changeset
|
5678 if (smiley->imhtml) { |
019052a807a3
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22387
diff
changeset
|
5679 if (wids) { |
019052a807a3
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22387
diff
changeset
|
5680 GList *children = gtk_container_get_children(GTK_CONTAINER(wids->data)); |
019052a807a3
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22387
diff
changeset
|
5681 g_list_foreach(children, (GFunc)gtk_widget_destroy, NULL); |
019052a807a3
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22387
diff
changeset
|
5682 g_list_free(children); |
019052a807a3
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22387
diff
changeset
|
5683 gtk_container_add(GTK_CONTAINER(wids->data), icon); |
019052a807a3
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22387
diff
changeset
|
5684 } else |
019052a807a3
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22387
diff
changeset
|
5685 gtk_text_view_add_child_at_anchor(GTK_TEXT_VIEW(smiley->imhtml), icon, anchor); |
019052a807a3
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22387
diff
changeset
|
5686 } |
019052a807a3
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22387
diff
changeset
|
5687 g_list_free(wids); |
019052a807a3
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22387
diff
changeset
|
5688 } |
23257
86bf0ce0d7ac
Do not try to update received custom smileys in a deleted child anchor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23237
diff
changeset
|
5689 g_object_unref(anchor); |
22889
019052a807a3
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22387
diff
changeset
|
5690 } |
019052a807a3
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22387
diff
changeset
|
5691 |
019052a807a3
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22387
diff
changeset
|
5692 g_slist_free(smiley->anchors); |
019052a807a3
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22387
diff
changeset
|
5693 smiley->anchors = NULL; |
019052a807a3
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22387
diff
changeset
|
5694 |
019052a807a3
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22387
diff
changeset
|
5695 g_object_unref(G_OBJECT(loader)); |
019052a807a3
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22387
diff
changeset
|
5696 smiley->loader = NULL; |
019052a807a3
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22387
diff
changeset
|
5697 } |
019052a807a3
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22387
diff
changeset
|
5698 |
23141
55e42ccdca4c
Patch from Masca to restrict the size of incoming custom smileys to a
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23133
diff
changeset
|
5699 static void |
55e42ccdca4c
Patch from Masca to restrict the size of incoming custom smileys to a
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23133
diff
changeset
|
5700 gtk_custom_smiley_size_prepared(GdkPixbufLoader *loader, gint width, gint height, gpointer data) |
55e42ccdca4c
Patch from Masca to restrict the size of incoming custom smileys to a
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23133
diff
changeset
|
5701 { |
55e42ccdca4c
Patch from Masca to restrict the size of incoming custom smileys to a
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23133
diff
changeset
|
5702 #define CUSTOM_SMILEY_SIZE 96 /* XXX: Should this be a theme setting? */ |
55e42ccdca4c
Patch from Masca to restrict the size of incoming custom smileys to a
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23133
diff
changeset
|
5703 if (width <= CUSTOM_SMILEY_SIZE && height <= CUSTOM_SMILEY_SIZE) |
55e42ccdca4c
Patch from Masca to restrict the size of incoming custom smileys to a
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23133
diff
changeset
|
5704 return; |
55e42ccdca4c
Patch from Masca to restrict the size of incoming custom smileys to a
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23133
diff
changeset
|
5705 |
55e42ccdca4c
Patch from Masca to restrict the size of incoming custom smileys to a
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23133
diff
changeset
|
5706 if (width >= height) { |
55e42ccdca4c
Patch from Masca to restrict the size of incoming custom smileys to a
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23133
diff
changeset
|
5707 height = height * CUSTOM_SMILEY_SIZE / width; |
55e42ccdca4c
Patch from Masca to restrict the size of incoming custom smileys to a
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23133
diff
changeset
|
5708 width = CUSTOM_SMILEY_SIZE; |
55e42ccdca4c
Patch from Masca to restrict the size of incoming custom smileys to a
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23133
diff
changeset
|
5709 } else { |
55e42ccdca4c
Patch from Masca to restrict the size of incoming custom smileys to a
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23133
diff
changeset
|
5710 width = width * CUSTOM_SMILEY_SIZE / height; |
55e42ccdca4c
Patch from Masca to restrict the size of incoming custom smileys to a
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23133
diff
changeset
|
5711 height = CUSTOM_SMILEY_SIZE; |
55e42ccdca4c
Patch from Masca to restrict the size of incoming custom smileys to a
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23133
diff
changeset
|
5712 } |
55e42ccdca4c
Patch from Masca to restrict the size of incoming custom smileys to a
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23133
diff
changeset
|
5713 |
55e42ccdca4c
Patch from Masca to restrict the size of incoming custom smileys to a
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23133
diff
changeset
|
5714 gdk_pixbuf_loader_set_size(loader, width, height); |
55e42ccdca4c
Patch from Masca to restrict the size of incoming custom smileys to a
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23133
diff
changeset
|
5715 } |
55e42ccdca4c
Patch from Masca to restrict the size of incoming custom smileys to a
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23133
diff
changeset
|
5716 |
22889
019052a807a3
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22387
diff
changeset
|
5717 void |
019052a807a3
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22387
diff
changeset
|
5718 gtk_imhtml_smiley_reload(GtkIMHtmlSmiley *smiley) |
019052a807a3
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22387
diff
changeset
|
5719 { |
019052a807a3
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22387
diff
changeset
|
5720 if (smiley->icon) |
019052a807a3
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22387
diff
changeset
|
5721 g_object_unref(smiley->icon); |
019052a807a3
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22387
diff
changeset
|
5722 if (smiley->loader) |
019052a807a3
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22387
diff
changeset
|
5723 g_object_unref(smiley->loader); /* XXX: does this crash? */ |
019052a807a3
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22387
diff
changeset
|
5724 |
019052a807a3
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22387
diff
changeset
|
5725 smiley->icon = NULL; |
019052a807a3
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22387
diff
changeset
|
5726 smiley->loader = NULL; |
019052a807a3
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22387
diff
changeset
|
5727 |
019052a807a3
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22387
diff
changeset
|
5728 if (smiley->file) { |
019052a807a3
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22387
diff
changeset
|
5729 /* We do not use the pixbuf loader for a smiley that can be loaded |
019052a807a3
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22387
diff
changeset
|
5730 * from a file. (e.g., local custom smileys) |
019052a807a3
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22387
diff
changeset
|
5731 */ |
019052a807a3
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22387
diff
changeset
|
5732 return; |
019052a807a3
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22387
diff
changeset
|
5733 } |
019052a807a3
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22387
diff
changeset
|
5734 |
019052a807a3
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22387
diff
changeset
|
5735 smiley->loader = gdk_pixbuf_loader_new(); |
019052a807a3
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22387
diff
changeset
|
5736 |
019052a807a3
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22387
diff
changeset
|
5737 g_signal_connect(smiley->loader, "area_prepared", G_CALLBACK(gtk_custom_smiley_allocated), smiley); |
019052a807a3
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22387
diff
changeset
|
5738 g_signal_connect(smiley->loader, "closed", G_CALLBACK(gtk_custom_smiley_closed), smiley); |
23141
55e42ccdca4c
Patch from Masca to restrict the size of incoming custom smileys to a
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
23133
diff
changeset
|
5739 g_signal_connect(smiley->loader, "size_prepared", G_CALLBACK(gtk_custom_smiley_size_prepared), smiley); |
22889
019052a807a3
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22387
diff
changeset
|
5740 } |
019052a807a3
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22387
diff
changeset
|
5741 |
019052a807a3
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22387
diff
changeset
|
5742 GtkIMHtmlSmiley *gtk_imhtml_smiley_create(const char *file, const char *shortcut, gboolean hide, |
019052a807a3
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22387
diff
changeset
|
5743 GtkIMHtmlSmileyFlags flags) |
019052a807a3
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22387
diff
changeset
|
5744 { |
019052a807a3
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22387
diff
changeset
|
5745 GtkIMHtmlSmiley *smiley = g_new0(GtkIMHtmlSmiley, 1); |
019052a807a3
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22387
diff
changeset
|
5746 smiley->file = g_strdup(file); |
019052a807a3
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22387
diff
changeset
|
5747 smiley->smile = g_strdup(shortcut); |
019052a807a3
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22387
diff
changeset
|
5748 smiley->hidden = hide; |
019052a807a3
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22387
diff
changeset
|
5749 smiley->flags = flags; |
24115
9564593d170c
Clean up the GtkSmileyTrees on active GtkIMHtml instances when a custom smiley
Marcus Lundblad <ml@update.uu.se>
parents:
24061
diff
changeset
|
5750 smiley->imhtml = NULL; |
22889
019052a807a3
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22387
diff
changeset
|
5751 gtk_imhtml_smiley_reload(smiley); |
019052a807a3
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22387
diff
changeset
|
5752 return smiley; |
019052a807a3
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22387
diff
changeset
|
5753 } |
019052a807a3
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22387
diff
changeset
|
5754 |
019052a807a3
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22387
diff
changeset
|
5755 void gtk_imhtml_smiley_destroy(GtkIMHtmlSmiley *smiley) |
019052a807a3
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22387
diff
changeset
|
5756 { |
24115
9564593d170c
Clean up the GtkSmileyTrees on active GtkIMHtml instances when a custom smiley
Marcus Lundblad <ml@update.uu.se>
parents:
24061
diff
changeset
|
5757 gtk_imhtml_disassociate_smiley(smiley); |
22889
019052a807a3
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22387
diff
changeset
|
5758 g_free(smiley->smile); |
019052a807a3
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22387
diff
changeset
|
5759 g_free(smiley->file); |
019052a807a3
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22387
diff
changeset
|
5760 if (smiley->icon) |
019052a807a3
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22387
diff
changeset
|
5761 g_object_unref(smiley->icon); |
019052a807a3
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22387
diff
changeset
|
5762 if (smiley->loader) |
019052a807a3
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22387
diff
changeset
|
5763 g_object_unref(smiley->loader); |
26965
655013f05eaa
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
26964
diff
changeset
|
5764 g_free(smiley->data); |
22889
019052a807a3
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22387
diff
changeset
|
5765 g_free(smiley); |
019052a807a3
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22387
diff
changeset
|
5766 } |
019052a807a3
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
22387
diff
changeset
|
5767 |
24396
38a2f78f80a7
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24311
diff
changeset
|
5768 gboolean gtk_imhtml_class_register_protocol(const char *name, |
24548
284fd17c6020
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24397
diff
changeset
|
5769 gboolean (*activate)(GtkIMHtml *imhtml, GtkIMHtmlLink *link), |
284fd17c6020
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24397
diff
changeset
|
5770 gboolean (*context_menu)(GtkIMHtml *imhtml, GtkIMHtmlLink *link, GtkWidget *menu)) |
24396
38a2f78f80a7
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24311
diff
changeset
|
5771 { |
38a2f78f80a7
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24311
diff
changeset
|
5772 GtkIMHtmlClass *klass; |
38a2f78f80a7
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24311
diff
changeset
|
5773 GtkIMHtmlProtocol *proto; |
38a2f78f80a7
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24311
diff
changeset
|
5774 |
38a2f78f80a7
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24311
diff
changeset
|
5775 g_return_val_if_fail(name, FALSE); |
38a2f78f80a7
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24311
diff
changeset
|
5776 |
38a2f78f80a7
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24311
diff
changeset
|
5777 klass = g_type_class_ref(GTK_TYPE_IMHTML); |
38a2f78f80a7
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24311
diff
changeset
|
5778 g_return_val_if_fail(klass, FALSE); |
38a2f78f80a7
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24311
diff
changeset
|
5779 |
25357
b01a7f17a2bb
Detect duplication registrations by substring.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
25355
diff
changeset
|
5780 if ((proto = imhtml_find_protocol(name, TRUE))) { |
25358
f1d814126801
Replace the URL registration assertions with regular checks.
Richard Laager <rlaager@wiktel.com>
parents:
25357
diff
changeset
|
5781 if (activate) { |
f1d814126801
Replace the URL registration assertions with regular checks.
Richard Laager <rlaager@wiktel.com>
parents:
25357
diff
changeset
|
5782 return FALSE; |
f1d814126801
Replace the URL registration assertions with regular checks.
Richard Laager <rlaager@wiktel.com>
parents:
25357
diff
changeset
|
5783 } |
28138
deecc1d663c4
Don't use pointers (even opaquely) once they're freed. Closes #9822.
Paul Aurich <paul@darkrain42.org>
parents:
27366
diff
changeset
|
5784 klass->protocols = g_list_remove(klass->protocols, proto); |
24396
38a2f78f80a7
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24311
diff
changeset
|
5785 g_free(proto->name); |
38a2f78f80a7
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24311
diff
changeset
|
5786 g_free(proto); |
38a2f78f80a7
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24311
diff
changeset
|
5787 return TRUE; |
25358
f1d814126801
Replace the URL registration assertions with regular checks.
Richard Laager <rlaager@wiktel.com>
parents:
25357
diff
changeset
|
5788 } else if (!activate) { |
f1d814126801
Replace the URL registration assertions with regular checks.
Richard Laager <rlaager@wiktel.com>
parents:
25357
diff
changeset
|
5789 return FALSE; |
24396
38a2f78f80a7
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24311
diff
changeset
|
5790 } |
38a2f78f80a7
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24311
diff
changeset
|
5791 |
38a2f78f80a7
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24311
diff
changeset
|
5792 proto = g_new0(GtkIMHtmlProtocol, 1); |
25352
48cf0a545621
Revert the URL scheme passing changes, keeping the miscellaneous other stuff
Richard Laager <rlaager@wiktel.com>
parents:
25351
diff
changeset
|
5793 proto->name = g_strdup(name); |
48cf0a545621
Revert the URL scheme passing changes, keeping the miscellaneous other stuff
Richard Laager <rlaager@wiktel.com>
parents:
25351
diff
changeset
|
5794 proto->length = strlen(name); |
24396
38a2f78f80a7
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24311
diff
changeset
|
5795 proto->activate = activate; |
38a2f78f80a7
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24311
diff
changeset
|
5796 proto->context_menu = context_menu; |
38a2f78f80a7
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24311
diff
changeset
|
5797 klass->protocols = g_list_prepend(klass->protocols, proto); |
38a2f78f80a7
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24311
diff
changeset
|
5798 |
38a2f78f80a7
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24311
diff
changeset
|
5799 return TRUE; |
38a2f78f80a7
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24311
diff
changeset
|
5800 } |
38a2f78f80a7
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24311
diff
changeset
|
5801 |
24548
284fd17c6020
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24397
diff
changeset
|
5802 static void |
284fd17c6020
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24397
diff
changeset
|
5803 gtk_imhtml_activate_tag(GtkIMHtml *imhtml, GtkTextTag *tag) |
284fd17c6020
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24397
diff
changeset
|
5804 { |
284fd17c6020
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24397
diff
changeset
|
5805 /* A link was clicked--we emit the "url_clicked" signal |
284fd17c6020
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24397
diff
changeset
|
5806 * with the URL as the argument */ |
284fd17c6020
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24397
diff
changeset
|
5807 g_object_ref(G_OBJECT(tag)); |
284fd17c6020
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24397
diff
changeset
|
5808 g_signal_emit(imhtml, signals[URL_CLICKED], 0, g_object_get_data(G_OBJECT(tag), "link_url")); |
284fd17c6020
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24397
diff
changeset
|
5809 g_object_unref(G_OBJECT(tag)); |
284fd17c6020
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24397
diff
changeset
|
5810 g_object_set_data(G_OBJECT(tag), "visited", GINT_TO_POINTER(TRUE)); |
284fd17c6020
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24397
diff
changeset
|
5811 gtk_imhtml_set_link_color(GTK_IMHTML(imhtml), tag); |
284fd17c6020
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24397
diff
changeset
|
5812 } |
284fd17c6020
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24397
diff
changeset
|
5813 |
284fd17c6020
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24397
diff
changeset
|
5814 gboolean gtk_imhtml_link_activate(GtkIMHtmlLink *link) |
284fd17c6020
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24397
diff
changeset
|
5815 { |
284fd17c6020
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24397
diff
changeset
|
5816 g_return_val_if_fail(link, FALSE); |
284fd17c6020
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24397
diff
changeset
|
5817 |
284fd17c6020
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24397
diff
changeset
|
5818 if (link->tag) { |
284fd17c6020
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24397
diff
changeset
|
5819 gtk_imhtml_activate_tag(link->imhtml, link->tag); |
284fd17c6020
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24397
diff
changeset
|
5820 } else if (link->url) { |
284fd17c6020
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24397
diff
changeset
|
5821 g_signal_emit(link->imhtml, signals[URL_CLICKED], 0, link->url); |
284fd17c6020
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24397
diff
changeset
|
5822 } else |
284fd17c6020
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24397
diff
changeset
|
5823 return FALSE; |
284fd17c6020
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24397
diff
changeset
|
5824 return TRUE; |
284fd17c6020
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24397
diff
changeset
|
5825 } |
284fd17c6020
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24397
diff
changeset
|
5826 |
284fd17c6020
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24397
diff
changeset
|
5827 const char *gtk_imhtml_link_get_url(GtkIMHtmlLink *link) |
284fd17c6020
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24397
diff
changeset
|
5828 { |
284fd17c6020
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24397
diff
changeset
|
5829 return link->url; |
284fd17c6020
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24397
diff
changeset
|
5830 } |
284fd17c6020
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24397
diff
changeset
|
5831 |
284fd17c6020
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24397
diff
changeset
|
5832 const GtkTextTag * gtk_imhtml_link_get_text_tag(GtkIMHtmlLink *link) |
284fd17c6020
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24397
diff
changeset
|
5833 { |
284fd17c6020
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24397
diff
changeset
|
5834 return link->tag; |
284fd17c6020
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24397
diff
changeset
|
5835 } |
284fd17c6020
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
24397
diff
changeset
|
5836 |
25427
2cf7d6a20e68
Add a GtkIMHtml function that causes the widget to actually insert a
Mark Doliner <mark@kingant.net>
parents:
25426
diff
changeset
|
5837 static gboolean return_add_newline_cb(GtkWidget *widget, gpointer data) |
2cf7d6a20e68
Add a GtkIMHtml function that causes the widget to actually insert a
Mark Doliner <mark@kingant.net>
parents:
25426
diff
changeset
|
5838 { |
2cf7d6a20e68
Add a GtkIMHtml function that causes the widget to actually insert a
Mark Doliner <mark@kingant.net>
parents:
25426
diff
changeset
|
5839 GtkTextBuffer *buffer; |
2cf7d6a20e68
Add a GtkIMHtml function that causes the widget to actually insert a
Mark Doliner <mark@kingant.net>
parents:
25426
diff
changeset
|
5840 GtkTextMark *mark; |
2cf7d6a20e68
Add a GtkIMHtml function that causes the widget to actually insert a
Mark Doliner <mark@kingant.net>
parents:
25426
diff
changeset
|
5841 GtkTextIter iter; |
2cf7d6a20e68
Add a GtkIMHtml function that causes the widget to actually insert a
Mark Doliner <mark@kingant.net>
parents:
25426
diff
changeset
|
5842 |
2cf7d6a20e68
Add a GtkIMHtml function that causes the widget to actually insert a
Mark Doliner <mark@kingant.net>
parents:
25426
diff
changeset
|
5843 buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(widget)); |
2cf7d6a20e68
Add a GtkIMHtml function that causes the widget to actually insert a
Mark Doliner <mark@kingant.net>
parents:
25426
diff
changeset
|
5844 |
2cf7d6a20e68
Add a GtkIMHtml function that causes the widget to actually insert a
Mark Doliner <mark@kingant.net>
parents:
25426
diff
changeset
|
5845 /* Delete any currently selected text */ |
2cf7d6a20e68
Add a GtkIMHtml function that causes the widget to actually insert a
Mark Doliner <mark@kingant.net>
parents:
25426
diff
changeset
|
5846 gtk_text_buffer_delete_selection(buffer, TRUE, TRUE); |
2cf7d6a20e68
Add a GtkIMHtml function that causes the widget to actually insert a
Mark Doliner <mark@kingant.net>
parents:
25426
diff
changeset
|
5847 |
2cf7d6a20e68
Add a GtkIMHtml function that causes the widget to actually insert a
Mark Doliner <mark@kingant.net>
parents:
25426
diff
changeset
|
5848 /* Insert a newline at the current cursor position */ |
2cf7d6a20e68
Add a GtkIMHtml function that causes the widget to actually insert a
Mark Doliner <mark@kingant.net>
parents:
25426
diff
changeset
|
5849 mark = gtk_text_buffer_get_insert(buffer); |
2cf7d6a20e68
Add a GtkIMHtml function that causes the widget to actually insert a
Mark Doliner <mark@kingant.net>
parents:
25426
diff
changeset
|
5850 gtk_text_buffer_get_iter_at_mark(buffer, &iter, mark); |
2cf7d6a20e68
Add a GtkIMHtml function that causes the widget to actually insert a
Mark Doliner <mark@kingant.net>
parents:
25426
diff
changeset
|
5851 gtk_imhtml_insert_html_at_iter(GTK_IMHTML(widget), "\n", 0, &iter); |
2cf7d6a20e68
Add a GtkIMHtml function that causes the widget to actually insert a
Mark Doliner <mark@kingant.net>
parents:
25426
diff
changeset
|
5852 |
2cf7d6a20e68
Add a GtkIMHtml function that causes the widget to actually insert a
Mark Doliner <mark@kingant.net>
parents:
25426
diff
changeset
|
5853 /* |
2cf7d6a20e68
Add a GtkIMHtml function that causes the widget to actually insert a
Mark Doliner <mark@kingant.net>
parents:
25426
diff
changeset
|
5854 * If we just newlined ourselves past the end of the visible area |
2cf7d6a20e68
Add a GtkIMHtml function that causes the widget to actually insert a
Mark Doliner <mark@kingant.net>
parents:
25426
diff
changeset
|
5855 * then scroll down so the cursor is in view. |
2cf7d6a20e68
Add a GtkIMHtml function that causes the widget to actually insert a
Mark Doliner <mark@kingant.net>
parents:
25426
diff
changeset
|
5856 */ |
2cf7d6a20e68
Add a GtkIMHtml function that causes the widget to actually insert a
Mark Doliner <mark@kingant.net>
parents:
25426
diff
changeset
|
5857 gtk_text_view_scroll_to_mark(GTK_TEXT_VIEW(widget), |
2cf7d6a20e68
Add a GtkIMHtml function that causes the widget to actually insert a
Mark Doliner <mark@kingant.net>
parents:
25426
diff
changeset
|
5858 gtk_text_buffer_get_insert(buffer), |
2cf7d6a20e68
Add a GtkIMHtml function that causes the widget to actually insert a
Mark Doliner <mark@kingant.net>
parents:
25426
diff
changeset
|
5859 0, FALSE, 0.0, 0.0); |
2cf7d6a20e68
Add a GtkIMHtml function that causes the widget to actually insert a
Mark Doliner <mark@kingant.net>
parents:
25426
diff
changeset
|
5860 |
2cf7d6a20e68
Add a GtkIMHtml function that causes the widget to actually insert a
Mark Doliner <mark@kingant.net>
parents:
25426
diff
changeset
|
5861 return TRUE; |
2cf7d6a20e68
Add a GtkIMHtml function that causes the widget to actually insert a
Mark Doliner <mark@kingant.net>
parents:
25426
diff
changeset
|
5862 } |
2cf7d6a20e68
Add a GtkIMHtml function that causes the widget to actually insert a
Mark Doliner <mark@kingant.net>
parents:
25426
diff
changeset
|
5863 |
25433
e0572c12265a
Add a comment just noting that I think it's kind of annoying that we
Mark Doliner <mark@kingant.net>
parents:
25432
diff
changeset
|
5864 /* |
e0572c12265a
Add a comment just noting that I think it's kind of annoying that we
Mark Doliner <mark@kingant.net>
parents:
25432
diff
changeset
|
5865 * It's kind of a pain that we need this function and the above just |
e0572c12265a
Add a comment just noting that I think it's kind of annoying that we
Mark Doliner <mark@kingant.net>
parents:
25432
diff
changeset
|
5866 * to reinstate the default GtkTextView behavior. It might be better |
e0572c12265a
Add a comment just noting that I think it's kind of annoying that we
Mark Doliner <mark@kingant.net>
parents:
25432
diff
changeset
|
5867 * if GtkIMHtml didn't intercept the enter key and just required the |
e0572c12265a
Add a comment just noting that I think it's kind of annoying that we
Mark Doliner <mark@kingant.net>
parents:
25432
diff
changeset
|
5868 * application to deal with it--it's really not much more work than it |
e0572c12265a
Add a comment just noting that I think it's kind of annoying that we
Mark Doliner <mark@kingant.net>
parents:
25432
diff
changeset
|
5869 * is to connect to the current "message_send" signal. |
e0572c12265a
Add a comment just noting that I think it's kind of annoying that we
Mark Doliner <mark@kingant.net>
parents:
25432
diff
changeset
|
5870 */ |
25427
2cf7d6a20e68
Add a GtkIMHtml function that causes the widget to actually insert a
Mark Doliner <mark@kingant.net>
parents:
25426
diff
changeset
|
5871 void gtk_imhtml_set_return_inserts_newline(GtkIMHtml *imhtml) |
2cf7d6a20e68
Add a GtkIMHtml function that causes the widget to actually insert a
Mark Doliner <mark@kingant.net>
parents:
25426
diff
changeset
|
5872 { |
2cf7d6a20e68
Add a GtkIMHtml function that causes the widget to actually insert a
Mark Doliner <mark@kingant.net>
parents:
25426
diff
changeset
|
5873 g_signal_connect(G_OBJECT(imhtml), "message_send", |
2cf7d6a20e68
Add a GtkIMHtml function that causes the widget to actually insert a
Mark Doliner <mark@kingant.net>
parents:
25426
diff
changeset
|
5874 G_CALLBACK(return_add_newline_cb), NULL); |
2cf7d6a20e68
Add a GtkIMHtml function that causes the widget to actually insert a
Mark Doliner <mark@kingant.net>
parents:
25426
diff
changeset
|
5875 } |
26894
3c06cd0e1717
Avoid overwriting the PRIMARY clipboard when we select-on-focus the status text for easy editing. Fixes #8781.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
26893
diff
changeset
|
5876 |
3c06cd0e1717
Avoid overwriting the PRIMARY clipboard when we select-on-focus the status text for easy editing. Fixes #8781.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
26893
diff
changeset
|
5877 void gtk_imhtml_set_populate_primary_clipboard(GtkIMHtml *imhtml, gboolean populate) |
3c06cd0e1717
Avoid overwriting the PRIMARY clipboard when we select-on-focus the status text for easy editing. Fixes #8781.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
26893
diff
changeset
|
5878 { |
26961
7c58f6f50f16
Block/Unblock the signal handler when if it's unblocked/blocked.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
26894
diff
changeset
|
5879 gulong signal_id; |
7c58f6f50f16
Block/Unblock the signal handler when if it's unblocked/blocked.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
26894
diff
changeset
|
5880 signal_id = g_signal_handler_find(imhtml->text_buffer, |
7c58f6f50f16
Block/Unblock the signal handler when if it's unblocked/blocked.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
26894
diff
changeset
|
5881 G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_UNBLOCKED, 0, 0, NULL, |
7c58f6f50f16
Block/Unblock the signal handler when if it's unblocked/blocked.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
26894
diff
changeset
|
5882 mark_set_so_update_selection_cb, NULL); |
26894
3c06cd0e1717
Avoid overwriting the PRIMARY clipboard when we select-on-focus the status text for easy editing. Fixes #8781.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
26893
diff
changeset
|
5883 if (populate) { |
26961
7c58f6f50f16
Block/Unblock the signal handler when if it's unblocked/blocked.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
26894
diff
changeset
|
5884 if (!signal_id) { |
7c58f6f50f16
Block/Unblock the signal handler when if it's unblocked/blocked.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
26894
diff
changeset
|
5885 /* We didn't find an unblocked signal handler, which means there |
7c58f6f50f16
Block/Unblock the signal handler when if it's unblocked/blocked.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
26894
diff
changeset
|
5886 is a blocked handler. Now unblock it. |
7c58f6f50f16
Block/Unblock the signal handler when if it's unblocked/blocked.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
26894
diff
changeset
|
5887 This is necessary to avoid a mutex-lock when the debug message |
7c58f6f50f16
Block/Unblock the signal handler when if it's unblocked/blocked.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
26894
diff
changeset
|
5888 saying 'no handler is blocked' is printed in the debug window. |
7c58f6f50f16
Block/Unblock the signal handler when if it's unblocked/blocked.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
26894
diff
changeset
|
5889 -- sad |
7c58f6f50f16
Block/Unblock the signal handler when if it's unblocked/blocked.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
26894
diff
changeset
|
5890 */ |
7c58f6f50f16
Block/Unblock the signal handler when if it's unblocked/blocked.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
26894
diff
changeset
|
5891 g_signal_handlers_unblock_matched(imhtml->text_buffer, |
7c58f6f50f16
Block/Unblock the signal handler when if it's unblocked/blocked.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
26894
diff
changeset
|
5892 G_SIGNAL_MATCH_FUNC, 0, 0, NULL, |
7c58f6f50f16
Block/Unblock the signal handler when if it's unblocked/blocked.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
26894
diff
changeset
|
5893 mark_set_so_update_selection_cb, NULL); |
7c58f6f50f16
Block/Unblock the signal handler when if it's unblocked/blocked.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
26894
diff
changeset
|
5894 } |
26894
3c06cd0e1717
Avoid overwriting the PRIMARY clipboard when we select-on-focus the status text for easy editing. Fixes #8781.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
26893
diff
changeset
|
5895 } else { |
26961
7c58f6f50f16
Block/Unblock the signal handler when if it's unblocked/blocked.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
26894
diff
changeset
|
5896 /* Block only if we found an unblocked handler */ |
7c58f6f50f16
Block/Unblock the signal handler when if it's unblocked/blocked.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
26894
diff
changeset
|
5897 if (signal_id) |
7c58f6f50f16
Block/Unblock the signal handler when if it's unblocked/blocked.
Sadrul Habib Chowdhury <imadil@gmail.com>
parents:
26894
diff
changeset
|
5898 g_signal_handler_block(imhtml->text_buffer, signal_id); |
26894
3c06cd0e1717
Avoid overwriting the PRIMARY clipboard when we select-on-focus the status text for easy editing. Fixes #8781.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
26893
diff
changeset
|
5899 } |
3c06cd0e1717
Avoid overwriting the PRIMARY clipboard when we select-on-focus the status text for easy editing. Fixes #8781.
Daniel Atallah <daniel.atallah@gmail.com>
parents:
26893
diff
changeset
|
5900 } |