Fri, 04 Dec 2009 06:18:05 +0000
jabber: Fix that leak I mentioned (and fix a mistake where error/response weren't NULL-initialized)
| 1428 | 1 | /* |
|
10297
b36800725b7a
[gaim-migrate @ 11480]
Evan Schoenberg <evands@pidgin.im>
parents:
10243
diff
changeset
|
2 | * @file gtkimhtml.c GTK+ IMHtml |
|
16254
eeb2bba4dc94
Rename the Doxygen group from gtkui to pidgin.
Richard Laager <rlaager@pidgin.im>
parents:
16144
diff
changeset
|
3 | * @ingroup pidgin |
|
20330
650a7af9c238
remove gpl boilerplate from doxygen docs
Sean Egan <seanegan@pidgin.im>
parents:
19859
diff
changeset
|
4 | */ |
|
650a7af9c238
remove gpl boilerplate from doxygen docs
Sean Egan <seanegan@pidgin.im>
parents:
19859
diff
changeset
|
5 | |
|
650a7af9c238
remove gpl boilerplate from doxygen docs
Sean Egan <seanegan@pidgin.im>
parents:
19859
diff
changeset
|
6 | /* pidgin |
| 1428 | 7 | * |
|
15931
716b5fac1895
Re-sed the copyright notices so they don't all talk about Purple.
Richard Laager <rlaager@pidgin.im>
parents:
15884
diff
changeset
|
8 | * Pidgin is the legal property of its developers, whose names are too numerous |
| 8046 | 9 | * to list here. Please refer to the COPYRIGHT file distributed with this |
| 10 | * source distribution. | |
| 1428 | 11 | * |
| 12 | * This program is free software; you can redistribute it and/or modify | |
| 13 | * under the terms of the GNU General Public License as published by | |
| 14 | * the Free Software Foundation; either version 2 of the License, or | |
| 15 | * (at your option) any later version. | |
| 16 | * | |
| 17 | * This program is distributed in the hope that it will be useful, | |
| 18 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 19 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 20 | * GNU General Public License for more details. | |
| 21 | * | |
| 22 | * You should have received a copy of the GNU General Public License | |
| 23 | * along with this program; if not, write to the Free Software | |
|
19859
71d37b57eff2
The FSF changed its address a while ago; our files were out of date.
John Bailey <rekkanoryo@rekkanoryo.org>
parents:
19746
diff
changeset
|
24 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111-1301 USA |
| 1428 | 25 | * |
| 26 | */ | |
|
24569
5dbd0617a27d
Build everything with the *_DISABLE_DEPRECATED flags set. This allows us
Richard Laager <rlaager@pidgin.im>
parents:
24544
diff
changeset
|
27 | #define _PIDGIN_GTKIMHTML_C_ |
| 1428 | 28 | |
|
2541
0afd3aaba327
[gaim-migrate @ 2554]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2365
diff
changeset
|
29 | #ifdef HAVE_CONFIG_H |
|
0afd3aaba327
[gaim-migrate @ 2554]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2365
diff
changeset
|
30 | #include <config.h> |
|
0afd3aaba327
[gaim-migrate @ 2554]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2365
diff
changeset
|
31 | #endif |
|
18119
699d876e3db0
Include pidgin.h to make this compile.
Richard Laager <rlaager@pidgin.im>
parents:
18108
diff
changeset
|
32 | |
|
18633
34ba43198355
Fix the win32 build. Thanks to Etan and Lee Roach. Fixes #1929.
Daniel Atallah <datallah@pidgin.im>
parents:
18552
diff
changeset
|
33 | #include "internal.h" |
|
18119
699d876e3db0
Include pidgin.h to make this compile.
Richard Laager <rlaager@pidgin.im>
parents:
18108
diff
changeset
|
34 | #include "pidgin.h" |
|
21777
0662651f6902
Kevin says we're ok defaulting persistent IMs on
Sean Egan <seanegan@pidgin.im>
parents:
21765
diff
changeset
|
35 | #include "pidginstock.h" |
|
23304
3aba02105818
Modified patch from malu to "Add context menu alternative to add received
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23302
diff
changeset
|
36 | #include "gtkutils.h" |
|
3aba02105818
Modified patch from malu to "Add context menu alternative to add received
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23302
diff
changeset
|
37 | #include "smiley.h" |
|
3aba02105818
Modified patch from malu to "Add context menu alternative to add received
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23302
diff
changeset
|
38 | #include "imgstore.h" |
|
18119
699d876e3db0
Include pidgin.h to make this compile.
Richard Laager <rlaager@pidgin.im>
parents:
18108
diff
changeset
|
39 | |
| 8526 | 40 | #include "debug.h" |
| 8091 | 41 | #include "util.h" |
| 1428 | 42 | #include "gtkimhtml.h" |
|
23304
3aba02105818
Modified patch from malu to "Add context menu alternative to add received
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23302
diff
changeset
|
43 | #include "gtksmiley.h" |
| 7358 | 44 | #include "gtksourceiter.h" |
|
17880
5e73968467e0
Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@pidgin.im>
parents:
17288
diff
changeset
|
45 | #include "gtksourceundomanager.h" |
|
5e73968467e0
Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@pidgin.im>
parents:
17288
diff
changeset
|
46 | #include "gtksourceview-marshal.h" |
| 1428 | 47 | #include <gtk/gtk.h> |
|
26727
b8885bab55ab
More updates for GTK+ 3.0. This only fixes the single-includes. Fixing all
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26655
diff
changeset
|
48 | #include <glib.h> |
| 4046 | 49 | #include <gdk/gdkkeysyms.h> |
| 1428 | 50 | #include <string.h> |
| 51 | #include <ctype.h> | |
| 52 | #include <stdio.h> | |
|
4629
7ac4830de853
[gaim-migrate @ 4920]
Mark Doliner <markdoliner@pidgin.im>
parents:
4612
diff
changeset
|
53 | #include <stdlib.h> |
| 1428 | 54 | #include <math.h> |
|
2541
0afd3aaba327
[gaim-migrate @ 2554]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2365
diff
changeset
|
55 | #ifdef HAVE_LANGINFO_CODESET |
|
0afd3aaba327
[gaim-migrate @ 2554]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2365
diff
changeset
|
56 | #include <langinfo.h> |
|
0afd3aaba327
[gaim-migrate @ 2554]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2365
diff
changeset
|
57 | #include <locale.h> |
|
0afd3aaba327
[gaim-migrate @ 2554]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2365
diff
changeset
|
58 | #endif |
| 8692 | 59 | #ifdef _WIN32 |
|
10901
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
60 | #include <gdk/gdkwin32.h> |
| 8692 | 61 | #include <windows.h> |
| 62 | #endif | |
| 1428 | 63 | |
| 4735 | 64 | #include <pango/pango-font.h> |
| 65 | ||
| 15577 | 66 | /* GTK+ < 2.4.x hack, see pidgin.h for details. */ |
|
10062
144767f0643a
[gaim-migrate @ 11037]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10016
diff
changeset
|
67 | #if (!GTK_CHECK_VERSION(2,4,0)) |
|
5105
3565a4c4de6a
[gaim-migrate @ 5468]
David J. Brigada <brigada@prism.net>
parents:
5104
diff
changeset
|
68 | #define GTK_WRAP_WORD_CHAR GTK_WRAP_WORD |
|
3565a4c4de6a
[gaim-migrate @ 5468]
David J. Brigada <brigada@prism.net>
parents:
5104
diff
changeset
|
69 | #endif |
|
3565a4c4de6a
[gaim-migrate @ 5468]
David J. Brigada <brigada@prism.net>
parents:
5104
diff
changeset
|
70 | |
| 4735 | 71 | #define TOOLTIP_TIMEOUT 500 |
| 72 | ||
| 8786 | 73 | /* GTK+ 2.0 hack */ |
| 74 | #if (!GTK_CHECK_VERSION(2,2,0)) | |
| 75 | #define gtk_widget_get_clipboard(x, y) gtk_clipboard_get(y) | |
| 76 | #endif | |
| 77 | ||
| 10100 | 78 | static GtkTextViewClass *parent_class = NULL; |
| 79 | ||
|
11224
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
80 | struct scalable_data { |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
81 | GtkIMHtmlScalable *scalable; |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
82 | GtkTextMark *mark; |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
83 | }; |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
84 | |
|
27123
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
85 | typedef struct { |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
86 | GtkIMHtmlScalable *image; |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
87 | gpointer data; |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
88 | gsize datasize; |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
89 | } GtkIMHtmlImageSave; |
|
11224
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
90 | |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
91 | struct im_image_data { |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
92 | int id; |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
93 | GtkTextMark *mark; |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
94 | }; |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
95 | |
|
24698
f9dd7117ade0
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24675
diff
changeset
|
96 | struct _GtkIMHtmlLink |
|
f9dd7117ade0
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24675
diff
changeset
|
97 | { |
|
f9dd7117ade0
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24675
diff
changeset
|
98 | GtkIMHtml *imhtml; |
|
f9dd7117ade0
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24675
diff
changeset
|
99 | gchar *url; |
|
f9dd7117ade0
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24675
diff
changeset
|
100 | GtkTextTag *tag; |
|
f9dd7117ade0
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24675
diff
changeset
|
101 | }; |
|
f9dd7117ade0
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24675
diff
changeset
|
102 | |
|
24674
36bf974a7d78
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24588
diff
changeset
|
103 | typedef struct _GtkIMHtmlProtocol |
|
36bf974a7d78
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24588
diff
changeset
|
104 | { |
|
36bf974a7d78
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24588
diff
changeset
|
105 | char *name; |
|
36bf974a7d78
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24588
diff
changeset
|
106 | int length; |
|
36bf974a7d78
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24588
diff
changeset
|
107 | |
|
24698
f9dd7117ade0
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24675
diff
changeset
|
108 | gboolean (*activate)(GtkIMHtml *imhtml, GtkIMHtmlLink *link); |
|
f9dd7117ade0
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24675
diff
changeset
|
109 | gboolean (*context_menu)(GtkIMHtml *imhtml, GtkIMHtmlLink *link, GtkWidget *menu); |
|
24674
36bf974a7d78
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24588
diff
changeset
|
110 | } GtkIMHtmlProtocol; |
|
36bf974a7d78
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24588
diff
changeset
|
111 | |
| 9300 | 112 | static gboolean |
| 113 | gtk_text_view_drag_motion (GtkWidget *widget, | |
| 114 | GdkDragContext *context, | |
| 115 | gint x, | |
| 116 | gint y, | |
| 117 | guint time); | |
| 118 | ||
| 8677 | 119 | static void preinsert_cb(GtkTextBuffer *buffer, GtkTextIter *iter, gchar *text, gint len, GtkIMHtml *imhtml); |
| 8061 | 120 | static void insert_cb(GtkTextBuffer *buffer, GtkTextIter *iter, gchar *text, gint len, GtkIMHtml *imhtml); |
|
12673
4c8a20955e0b
[gaim-migrate @ 15016]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12672
diff
changeset
|
121 | static void delete_cb(GtkTextBuffer *buffer, GtkTextIter *iter, GtkTextIter *end, GtkIMHtml *imhtml); |
| 10169 | 122 | static void insert_ca_cb(GtkTextBuffer *buffer, GtkTextIter *arg1, GtkTextChildAnchor *arg2, gpointer user_data); |
| 123 | static void gtk_imhtml_apply_tags_on_insert(GtkIMHtml *imhtml, GtkTextIter *start, GtkTextIter *end); | |
| 8698 | 124 | void gtk_imhtml_close_tags(GtkIMHtml *imhtml, GtkTextIter *iter); |
| 9300 | 125 | static void gtk_imhtml_link_drop_cb(GtkWidget *widget, GdkDragContext *context, gint x, gint y, guint time, gpointer user_data); |
| 8091 | 126 | static void gtk_imhtml_link_drag_rcv_cb(GtkWidget *widget, GdkDragContext *dc, guint x, guint y, GtkSelectionData *sd, guint info, guint t, GtkIMHtml *imhtml); |
| 8677 | 127 | static void mark_set_cb(GtkTextBuffer *buffer, GtkTextIter *arg1, GtkTextMark *mark, GtkIMHtml *imhtml); |
| 8931 | 128 | static void hijack_menu_cb(GtkIMHtml *imhtml, GtkMenu *menu, gpointer data); |
| 129 | static void paste_received_cb (GtkClipboard *clipboard, GtkSelectionData *selection_data, gpointer data); | |
| 130 | static void paste_plaintext_received_cb (GtkClipboard *clipboard, const gchar *text, gpointer data); | |
|
10901
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
131 | static void imhtml_paste_insert(GtkIMHtml *imhtml, const char *text, gboolean plaintext); |
|
11267
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
132 | static void imhtml_toggle_bold(GtkIMHtml *imhtml); |
|
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
133 | static void imhtml_toggle_italic(GtkIMHtml *imhtml); |
|
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
134 | static void imhtml_toggle_strike(GtkIMHtml *imhtml); |
|
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
135 | static void imhtml_toggle_underline(GtkIMHtml *imhtml); |
|
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
136 | static void imhtml_font_grow(GtkIMHtml *imhtml); |
|
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
137 | static void imhtml_font_shrink(GtkIMHtml *imhtml); |
|
12672
673e2a1d2954
[gaim-migrate @ 15015]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12635
diff
changeset
|
138 | static void imhtml_clear_formatting(GtkIMHtml *imhtml); |
|
24674
36bf974a7d78
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24588
diff
changeset
|
139 | static int gtk_imhtml_is_protocol(const char *text); |
|
24698
f9dd7117ade0
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24675
diff
changeset
|
140 | static void gtk_imhtml_activate_tag(GtkIMHtml *imhtml, GtkTextTag *tag); |
|
f9dd7117ade0
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24675
diff
changeset
|
141 | static void gtk_imhtml_link_destroy(GtkIMHtmlLink *link); |
| 8061 | 142 | |
|
10899
87d9aec5b72d
[gaim-migrate @ 12619]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10871
diff
changeset
|
143 | /* POINT_SIZE converts from AIM font sizes to a point size scale factor. */ |
| 3922 | 144 | #define MAX_FONT_SIZE 7 |
|
10900
cc19dfd83910
[gaim-migrate @ 12621]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10899
diff
changeset
|
145 | #define POINT_SIZE(x) (_point_sizes [MIN ((x > 0 ? x : 1), MAX_FONT_SIZE) - 1]) |
|
21091
07fe1a99c47b
Patch from Andrew Gaul to constify a bunch of static variables to reduce
Ka-Hing Cheung <khc@pidgin.im>
parents:
21085
diff
changeset
|
146 | static const gdouble _point_sizes [] = { .85, .95, 1, 1.2, 1.44, 1.728, 2.0736}; |
|
2349
9832b57ded64
[gaim-migrate @ 2362]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2348
diff
changeset
|
147 | |
|
10184
543c9a84ce16
[gaim-migrate @ 11299]
Mark Doliner <markdoliner@pidgin.im>
parents:
10169
diff
changeset
|
148 | enum { |
| 8677 | 149 | TARGET_HTML, |
| 8061 | 150 | TARGET_UTF8_STRING, |
| 151 | TARGET_COMPOUND_TEXT, | |
| 152 | TARGET_STRING, | |
| 153 | TARGET_TEXT | |
| 154 | }; | |
| 155 | ||
| 8091 | 156 | enum { |
| 8420 | 157 | URL_CLICKED, |
| 158 | BUTTONS_UPDATE, | |
| 159 | TOGGLE_FORMAT, | |
| 8427 | 160 | CLEAR_FORMAT, |
| 8506 | 161 | UPDATE_FORMAT, |
| 10108 | 162 | MESSAGE_SEND, |
|
17880
5e73968467e0
Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@pidgin.im>
parents:
17288
diff
changeset
|
163 | UNDO, |
|
5e73968467e0
Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@pidgin.im>
parents:
17288
diff
changeset
|
164 | REDO, |
| 8420 | 165 | LAST_SIGNAL |
| 166 | }; | |
| 167 | static guint signals [LAST_SIGNAL] = { 0 }; | |
| 168 | ||
|
17546
51b1c1e2c3fe
Maintain global poitners to the clipboard selection text, with the aim of
Sean Egan <seanegan@pidgin.im>
parents:
17406
diff
changeset
|
169 | static char *html_clipboard = NULL; |
|
51b1c1e2c3fe
Maintain global poitners to the clipboard selection text, with the aim of
Sean Egan <seanegan@pidgin.im>
parents:
17406
diff
changeset
|
170 | static char *text_clipboard = NULL; |
|
21085
dff5e0bfb8f5
Don't assign ownership of the CLIPBOARD to the IMHtml - it doesn't really own the data and then we don't have problems of overwriting what others put in the clipboard. Fixes #3616.
Daniel Atallah <datallah@pidgin.im>
parents:
21076
diff
changeset
|
171 | static GtkClipboard *clipboard_selection = NULL; |
|
17546
51b1c1e2c3fe
Maintain global poitners to the clipboard selection text, with the aim of
Sean Egan <seanegan@pidgin.im>
parents:
17406
diff
changeset
|
172 | |
|
21091
07fe1a99c47b
Patch from Andrew Gaul to constify a bunch of static variables to reduce
Ka-Hing Cheung <khc@pidgin.im>
parents:
21085
diff
changeset
|
173 | static const GtkTargetEntry selection_targets[] = { |
|
15111
e427dd6f3b7e
[gaim-migrate @ 17833]
Daniel Atallah <datallah@pidgin.im>
parents:
15093
diff
changeset
|
174 | #ifndef _WIN32 |
| 8566 | 175 | { "text/html", 0, TARGET_HTML }, |
|
15111
e427dd6f3b7e
[gaim-migrate @ 17833]
Daniel Atallah <datallah@pidgin.im>
parents:
15093
diff
changeset
|
176 | #else |
|
e427dd6f3b7e
[gaim-migrate @ 17833]
Daniel Atallah <datallah@pidgin.im>
parents:
15093
diff
changeset
|
177 | { "HTML Format", 0, TARGET_HTML }, |
|
e427dd6f3b7e
[gaim-migrate @ 17833]
Daniel Atallah <datallah@pidgin.im>
parents:
15093
diff
changeset
|
178 | #endif |
| 8061 | 179 | { "UTF8_STRING", 0, TARGET_UTF8_STRING }, |
| 180 | { "COMPOUND_TEXT", 0, TARGET_COMPOUND_TEXT }, | |
| 181 | { "STRING", 0, TARGET_STRING }, | |
| 182 | { "TEXT", 0, TARGET_TEXT}}; | |
| 183 | ||
|
21091
07fe1a99c47b
Patch from Andrew Gaul to constify a bunch of static variables to reduce
Ka-Hing Cheung <khc@pidgin.im>
parents:
21085
diff
changeset
|
184 | static const GtkTargetEntry link_drag_drop_targets[] = { |
|
10145
f1405f65ff41
[gaim-migrate @ 11218]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10110
diff
changeset
|
185 | GTK_IMHTML_DND_TARGETS |
|
f1405f65ff41
[gaim-migrate @ 11218]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10110
diff
changeset
|
186 | }; |
| 8091 | 187 | |
| 8692 | 188 | #ifdef _WIN32 |
| 189 | static gchar * | |
| 190 | clipboard_win32_to_html(char *clipboard) { | |
| 9465 | 191 | const char *header; |
| 8693 | 192 | const char *begin, *end; |
|
10016
18418b9fa749
[gaim-migrate @ 10935]
Daniel Atallah <datallah@pidgin.im>
parents:
10013
diff
changeset
|
193 | gint start = 0; |
|
18418b9fa749
[gaim-migrate @ 10935]
Daniel Atallah <datallah@pidgin.im>
parents:
10013
diff
changeset
|
194 | gint finish = 0; |
| 8692 | 195 | gchar *html; |
|
10016
18418b9fa749
[gaim-migrate @ 10935]
Daniel Atallah <datallah@pidgin.im>
parents:
10013
diff
changeset
|
196 | gchar **split; |
|
18418b9fa749
[gaim-migrate @ 10935]
Daniel Atallah <datallah@pidgin.im>
parents:
10013
diff
changeset
|
197 | int clipboard_length = 0; |
| 9465 | 198 | |
| 199 | #if 0 /* Debugging for Windows clipboard */ | |
| 9467 | 200 | FILE *fd; |
| 201 | ||
| 15884 | 202 | purple_debug_info("imhtml clipboard", "from clipboard: %s\n", clipboard); |
| 203 | ||
| 204 | fd = g_fopen("e:\\purplecb.txt", "wb"); | |
| 9465 | 205 | fprintf(fd, "%s", clipboard); |
| 206 | fclose(fd); | |
| 207 | #endif | |
| 208 | ||
|
10016
18418b9fa749
[gaim-migrate @ 10935]
Daniel Atallah <datallah@pidgin.im>
parents:
10013
diff
changeset
|
209 | clipboard_length = strlen(clipboard); |
|
18418b9fa749
[gaim-migrate @ 10935]
Daniel Atallah <datallah@pidgin.im>
parents:
10013
diff
changeset
|
210 | |
|
18418b9fa749
[gaim-migrate @ 10935]
Daniel Atallah <datallah@pidgin.im>
parents:
10013
diff
changeset
|
211 | if (!(header = strstr(clipboard, "StartFragment:")) || (header - clipboard) >= clipboard_length) |
| 9465 | 212 | return NULL; |
| 213 | sscanf(header, "StartFragment:%d", &start); | |
| 214 | ||
|
10016
18418b9fa749
[gaim-migrate @ 10935]
Daniel Atallah <datallah@pidgin.im>
parents:
10013
diff
changeset
|
215 | if (!(header = strstr(clipboard, "EndFragment:")) || (header - clipboard) >= clipboard_length) |
|
18418b9fa749
[gaim-migrate @ 10935]
Daniel Atallah <datallah@pidgin.im>
parents:
10013
diff
changeset
|
216 | return NULL; |
| 9465 | 217 | sscanf(header, "EndFragment:%d", &finish); |
| 218 | ||
|
10016
18418b9fa749
[gaim-migrate @ 10935]
Daniel Atallah <datallah@pidgin.im>
parents:
10013
diff
changeset
|
219 | if (finish > clipboard_length) |
|
18418b9fa749
[gaim-migrate @ 10935]
Daniel Atallah <datallah@pidgin.im>
parents:
10013
diff
changeset
|
220 | finish = clipboard_length; |
|
18418b9fa749
[gaim-migrate @ 10935]
Daniel Atallah <datallah@pidgin.im>
parents:
10013
diff
changeset
|
221 | |
|
18418b9fa749
[gaim-migrate @ 10935]
Daniel Atallah <datallah@pidgin.im>
parents:
10013
diff
changeset
|
222 | if (start > finish) |
|
18418b9fa749
[gaim-migrate @ 10935]
Daniel Atallah <datallah@pidgin.im>
parents:
10013
diff
changeset
|
223 | start = finish; |
|
18418b9fa749
[gaim-migrate @ 10935]
Daniel Atallah <datallah@pidgin.im>
parents:
10013
diff
changeset
|
224 | |
| 9465 | 225 | begin = clipboard + start; |
| 226 | ||
|
10016
18418b9fa749
[gaim-migrate @ 10935]
Daniel Atallah <datallah@pidgin.im>
parents:
10013
diff
changeset
|
227 | end = clipboard + finish; |
|
18418b9fa749
[gaim-migrate @ 10935]
Daniel Atallah <datallah@pidgin.im>
parents:
10013
diff
changeset
|
228 | |
|
18418b9fa749
[gaim-migrate @ 10935]
Daniel Atallah <datallah@pidgin.im>
parents:
10013
diff
changeset
|
229 | html = g_strndup(begin, end - begin); |
|
18418b9fa749
[gaim-migrate @ 10935]
Daniel Atallah <datallah@pidgin.im>
parents:
10013
diff
changeset
|
230 | |
|
18418b9fa749
[gaim-migrate @ 10935]
Daniel Atallah <datallah@pidgin.im>
parents:
10013
diff
changeset
|
231 | /* any newlines in the string will now be \r\n, so we need to strip out the \r */ |
|
18418b9fa749
[gaim-migrate @ 10935]
Daniel Atallah <datallah@pidgin.im>
parents:
10013
diff
changeset
|
232 | split = g_strsplit(html, "\r\n", 0); |
|
18418b9fa749
[gaim-migrate @ 10935]
Daniel Atallah <datallah@pidgin.im>
parents:
10013
diff
changeset
|
233 | g_free(html); |
|
18418b9fa749
[gaim-migrate @ 10935]
Daniel Atallah <datallah@pidgin.im>
parents:
10013
diff
changeset
|
234 | html = g_strjoinv("\n", split); |
|
18418b9fa749
[gaim-migrate @ 10935]
Daniel Atallah <datallah@pidgin.im>
parents:
10013
diff
changeset
|
235 | g_strfreev(split); |
|
18418b9fa749
[gaim-migrate @ 10935]
Daniel Atallah <datallah@pidgin.im>
parents:
10013
diff
changeset
|
236 | |
| 9465 | 237 | #if 0 /* Debugging for Windows clipboard */ |
| 15884 | 238 | purple_debug_info("imhtml clipboard", "HTML fragment: '%s'\n", html); |
| 9465 | 239 | #endif |
| 240 | ||
| 8707 | 241 | return html; |
| 8692 | 242 | } |
| 243 | ||
| 244 | static gchar * | |
| 245 | clipboard_html_to_win32(char *html) { | |
| 8693 | 246 | int length; |
|
11240
cd4ca16ff57c
[gaim-migrate @ 13399]
Richard Laager <rlaager@pidgin.im>
parents:
11234
diff
changeset
|
247 | GString *clipboard; |
| 8692 | 248 | |
| 8693 | 249 | if (html == NULL) |
| 250 | return NULL; | |
| 8692 | 251 | |
| 252 | length = strlen(html); | |
| 9465 | 253 | clipboard = g_string_new ("Version:1.0\r\n"); |
| 8692 | 254 | g_string_append(clipboard, "StartHTML:0000000105\r\n"); |
|
18665
157820042a6f
Fix #1727 and also plug a possible leak and make a little efficiency improvement to the win32 clipboard handling.
Daniel Atallah <datallah@pidgin.im>
parents:
18633
diff
changeset
|
255 | g_string_append_printf(clipboard, "EndHTML:%010d\r\n", 147 + length); |
| 9465 | 256 | g_string_append(clipboard, "StartFragment:0000000127\r\n"); |
|
18665
157820042a6f
Fix #1727 and also plug a possible leak and make a little efficiency improvement to the win32 clipboard handling.
Daniel Atallah <datallah@pidgin.im>
parents:
18633
diff
changeset
|
257 | g_string_append_printf(clipboard, "EndFragment:%010d\r\n", 127 + length); |
| 9465 | 258 | g_string_append(clipboard, "<!--StartFragment-->\r\n"); |
| 8692 | 259 | g_string_append(clipboard, html); |
| 9465 | 260 | g_string_append(clipboard, "\r\n<!--EndFragment-->"); |
|
14101
89a79c2a971e
[gaim-migrate @ 16643]
Mark Doliner <markdoliner@pidgin.im>
parents:
14097
diff
changeset
|
261 | |
|
89a79c2a971e
[gaim-migrate @ 16643]
Mark Doliner <markdoliner@pidgin.im>
parents:
14097
diff
changeset
|
262 | return g_string_free(clipboard, FALSE); |
| 8692 | 263 | } |
|
10901
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
264 | |
|
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
265 | static gboolean clipboard_paste_html_win32(GtkIMHtml *imhtml) { |
|
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
266 | gboolean pasted = FALSE; |
|
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
267 | |
|
15111
e427dd6f3b7e
[gaim-migrate @ 17833]
Daniel Atallah <datallah@pidgin.im>
parents:
15093
diff
changeset
|
268 | /* Win32 clipboard format value, and functions to convert back and |
|
e427dd6f3b7e
[gaim-migrate @ 17833]
Daniel Atallah <datallah@pidgin.im>
parents:
15093
diff
changeset
|
269 | * forth between HTML and the clipboard format. |
|
e427dd6f3b7e
[gaim-migrate @ 17833]
Daniel Atallah <datallah@pidgin.im>
parents:
15093
diff
changeset
|
270 | */ |
|
e427dd6f3b7e
[gaim-migrate @ 17833]
Daniel Atallah <datallah@pidgin.im>
parents:
15093
diff
changeset
|
271 | static UINT win_html_fmt = 0; |
|
e427dd6f3b7e
[gaim-migrate @ 17833]
Daniel Atallah <datallah@pidgin.im>
parents:
15093
diff
changeset
|
272 | |
|
e427dd6f3b7e
[gaim-migrate @ 17833]
Daniel Atallah <datallah@pidgin.im>
parents:
15093
diff
changeset
|
273 | /* Register HTML Format as desired clipboard format */ |
|
e427dd6f3b7e
[gaim-migrate @ 17833]
Daniel Atallah <datallah@pidgin.im>
parents:
15093
diff
changeset
|
274 | if (!win_html_fmt) |
|
e427dd6f3b7e
[gaim-migrate @ 17833]
Daniel Atallah <datallah@pidgin.im>
parents:
15093
diff
changeset
|
275 | win_html_fmt = RegisterClipboardFormat("HTML Format"); |
|
e427dd6f3b7e
[gaim-migrate @ 17833]
Daniel Atallah <datallah@pidgin.im>
parents:
15093
diff
changeset
|
276 | |
|
10901
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
277 | if (gtk_text_view_get_editable(GTK_TEXT_VIEW(imhtml)) |
|
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
278 | && IsClipboardFormatAvailable(win_html_fmt)) { |
|
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
279 | gboolean error_reading_clipboard = FALSE; |
|
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
280 | HWND hwnd = GDK_WINDOW_HWND(GTK_WIDGET(imhtml)->window); |
|
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
281 | |
|
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
282 | if (OpenClipboard(hwnd)) { |
|
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
283 | HGLOBAL hdata = GetClipboardData(win_html_fmt); |
|
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
284 | if (hdata == NULL) { |
|
15111
e427dd6f3b7e
[gaim-migrate @ 17833]
Daniel Atallah <datallah@pidgin.im>
parents:
15093
diff
changeset
|
285 | if (GetLastError() != ERROR_SUCCESS) |
|
e427dd6f3b7e
[gaim-migrate @ 17833]
Daniel Atallah <datallah@pidgin.im>
parents:
15093
diff
changeset
|
286 | error_reading_clipboard = TRUE; |
|
10901
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
287 | } else { |
|
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
288 | char *buffer = GlobalLock(hdata); |
|
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
289 | if (buffer == NULL) { |
|
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
290 | error_reading_clipboard = TRUE; |
|
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
291 | } else { |
|
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
292 | char *text = clipboard_win32_to_html( |
|
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
293 | buffer); |
|
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
294 | imhtml_paste_insert(imhtml, text, |
|
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
295 | FALSE); |
|
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
296 | g_free(text); |
|
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
297 | pasted = TRUE; |
|
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
298 | } |
|
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
299 | GlobalUnlock(hdata); |
|
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
300 | } |
|
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
301 | |
|
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
302 | CloseClipboard(); |
|
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
303 | } else { |
|
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
304 | error_reading_clipboard = TRUE; |
|
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
305 | } |
|
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
306 | |
|
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
307 | if (error_reading_clipboard) { |
|
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
308 | gchar *err_msg = g_win32_error_message(GetLastError()); |
| 15884 | 309 | purple_debug_info("html clipboard", |
|
10901
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
310 | "Unable to read clipboard data: %s\n", |
|
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
311 | err_msg ? err_msg : "Unknown Error"); |
|
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
312 | g_free(err_msg); |
|
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
313 | } |
|
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
314 | } |
|
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
315 | |
|
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
316 | return pasted; |
|
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
317 | } |
| 8692 | 318 | #endif |
| 319 | ||
| 4032 | 320 | static GtkSmileyTree* |
|
22104
56970903b8e9
Probe for -Wstrict-prototypes to get some more warnings. I then cleaned up
Richard Laager <rlaager@pidgin.im>
parents:
22100
diff
changeset
|
321 | gtk_smiley_tree_new (void) |
| 4032 | 322 | { |
| 323 | return g_new0 (GtkSmileyTree, 1); | |
| 324 | } | |
| 325 | ||
| 326 | static void | |
| 327 | gtk_smiley_tree_insert (GtkSmileyTree *tree, | |
| 4263 | 328 | GtkIMHtmlSmiley *smiley) |
| 4032 | 329 | { |
| 330 | GtkSmileyTree *t = tree; | |
| 4263 | 331 | const gchar *x = smiley->smile; |
| 4032 | 332 | |
|
12229
ad8d3ae8fc1b
[gaim-migrate @ 14531]
Michael Carlson <corfe83@users.sourceforge.net>
parents:
12072
diff
changeset
|
333 | if (!(*x)) |
| 4032 | 334 | return; |
| 335 | ||
|
12229
ad8d3ae8fc1b
[gaim-migrate @ 14531]
Michael Carlson <corfe83@users.sourceforge.net>
parents:
12072
diff
changeset
|
336 | do { |
| 4032 | 337 | gchar *pos; |
| 338 | gint index; | |
| 339 | ||
| 340 | if (!t->values) | |
| 341 | t->values = g_string_new (""); | |
| 342 | ||
| 343 | pos = strchr (t->values->str, *x); | |
| 344 | if (!pos) { | |
| 345 | t->values = g_string_append_c (t->values, *x); | |
| 346 | index = t->values->len - 1; | |
| 347 | t->children = g_realloc (t->children, t->values->len * sizeof (GtkSmileyTree *)); | |
| 348 | t->children [index] = g_new0 (GtkSmileyTree, 1); | |
| 349 | } else | |
| 7386 | 350 | index = GPOINTER_TO_INT(pos) - GPOINTER_TO_INT(t->values->str); |
| 8061 | 351 | |
| 4032 | 352 | t = t->children [index]; |
| 8061 | 353 | |
| 4032 | 354 | x++; |
|
12229
ad8d3ae8fc1b
[gaim-migrate @ 14531]
Michael Carlson <corfe83@users.sourceforge.net>
parents:
12072
diff
changeset
|
355 | } while (*x); |
| 8061 | 356 | |
| 4263 | 357 | t->image = smiley; |
| 4032 | 358 | } |
| 4041 | 359 | |
| 4263 | 360 | |
|
11677
89c2ab8d2ebf
[gaim-migrate @ 13963]
Mark Doliner <markdoliner@pidgin.im>
parents:
11586
diff
changeset
|
361 | static void |
|
89c2ab8d2ebf
[gaim-migrate @ 13963]
Mark Doliner <markdoliner@pidgin.im>
parents:
11586
diff
changeset
|
362 | gtk_smiley_tree_destroy (GtkSmileyTree *tree) |
| 4032 | 363 | { |
|
11701
8cf812de5e92
[gaim-migrate @ 13992]
Michael Carlson <corfe83@users.sourceforge.net>
parents:
11677
diff
changeset
|
364 | GSList *list = g_slist_prepend (NULL, tree); |
| 4032 | 365 | |
| 366 | while (list) { | |
| 367 | GtkSmileyTree *t = list->data; | |
|
12229
ad8d3ae8fc1b
[gaim-migrate @ 14531]
Michael Carlson <corfe83@users.sourceforge.net>
parents:
12072
diff
changeset
|
368 | gsize i; |
| 4032 | 369 | list = g_slist_remove(list, t); |
| 7384 | 370 | if (t && t->values) { |
| 4032 | 371 | for (i = 0; i < t->values->len; i++) |
|
11701
8cf812de5e92
[gaim-migrate @ 13992]
Michael Carlson <corfe83@users.sourceforge.net>
parents:
11677
diff
changeset
|
372 | list = g_slist_prepend (list, t->children [i]); |
| 4032 | 373 | g_string_free (t->values, TRUE); |
| 374 | g_free (t->children); | |
| 375 | } | |
|
25888
d0fdd378a635
Remove trailing whitespace
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
376 | |
| 4032 | 377 | g_free (t); |
| 378 | } | |
| 379 | } | |
| 380 | ||
|
18968
2ddbe6473bc9
Cool! Override GtkTextView's size allocate function in GtkIMHtml to make sure that it stays scrolled to the bottom whenever it's resized. Fixes a major annoyance and possibly #938
Sean Egan <seanegan@pidgin.im>
parents:
18665
diff
changeset
|
381 | static void (*parent_size_allocate)(GtkWidget *widget, GtkAllocation *alloc); |
|
2ddbe6473bc9
Cool! Override GtkTextView's size allocate function in GtkIMHtml to make sure that it stays scrolled to the bottom whenever it's resized. Fixes a major annoyance and possibly #938
Sean Egan <seanegan@pidgin.im>
parents:
18665
diff
changeset
|
382 | |
|
2ddbe6473bc9
Cool! Override GtkTextView's size allocate function in GtkIMHtml to make sure that it stays scrolled to the bottom whenever it's resized. Fixes a major annoyance and possibly #938
Sean Egan <seanegan@pidgin.im>
parents:
18665
diff
changeset
|
383 | static void gtk_imhtml_size_allocate(GtkWidget *widget, GtkAllocation *alloc) |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
384 | { |
|
18968
2ddbe6473bc9
Cool! Override GtkTextView's size allocate function in GtkIMHtml to make sure that it stays scrolled to the bottom whenever it's resized. Fixes a major annoyance and possibly #938
Sean Egan <seanegan@pidgin.im>
parents:
18665
diff
changeset
|
385 | GtkIMHtml *imhtml = GTK_IMHTML(widget); |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
386 | GdkRectangle rect; |
| 8726 | 387 | int xminus; |
|
18968
2ddbe6473bc9
Cool! Override GtkTextView's size allocate function in GtkIMHtml to make sure that it stays scrolled to the bottom whenever it's resized. Fixes a major annoyance and possibly #938
Sean Egan <seanegan@pidgin.im>
parents:
18665
diff
changeset
|
388 | int height = 0, y = 0; |
|
2ddbe6473bc9
Cool! Override GtkTextView's size allocate function in GtkIMHtml to make sure that it stays scrolled to the bottom whenever it's resized. Fixes a major annoyance and possibly #938
Sean Egan <seanegan@pidgin.im>
parents:
18665
diff
changeset
|
389 | GtkTextIter iter; |
|
2ddbe6473bc9
Cool! Override GtkTextView's size allocate function in GtkIMHtml to make sure that it stays scrolled to the bottom whenever it's resized. Fixes a major annoyance and possibly #938
Sean Egan <seanegan@pidgin.im>
parents:
18665
diff
changeset
|
390 | gboolean scroll = TRUE; |
|
2ddbe6473bc9
Cool! Override GtkTextView's size allocate function in GtkIMHtml to make sure that it stays scrolled to the bottom whenever it's resized. Fixes a major annoyance and possibly #938
Sean Egan <seanegan@pidgin.im>
parents:
18665
diff
changeset
|
391 | |
|
22803
e1f64090d32e
Do not show tooltips for <HR> or <IMG>s in gtkimhtml. Fixes #5480.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22772
diff
changeset
|
392 | gtk_text_buffer_get_end_iter(imhtml->text_buffer, &iter); |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
393 | |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
394 | gtk_text_view_get_visible_rect(GTK_TEXT_VIEW(widget), &rect); |
|
22803
e1f64090d32e
Do not show tooltips for <HR> or <IMG>s in gtkimhtml. Fixes #5480.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22772
diff
changeset
|
395 | gtk_text_view_get_line_yrange(GTK_TEXT_VIEW(imhtml), &iter, &y, &height); |
|
e1f64090d32e
Do not show tooltips for <HR> or <IMG>s in gtkimhtml. Fixes #5480.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22772
diff
changeset
|
396 | |
|
e1f64090d32e
Do not show tooltips for <HR> or <IMG>s in gtkimhtml. Fixes #5480.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22772
diff
changeset
|
397 | if (((y + height) - (rect.y + rect.height)) > height && |
|
e1f64090d32e
Do not show tooltips for <HR> or <IMG>s in gtkimhtml. Fixes #5480.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22772
diff
changeset
|
398 | gtk_text_buffer_get_char_count(imhtml->text_buffer)) { |
|
e1f64090d32e
Do not show tooltips for <HR> or <IMG>s in gtkimhtml. Fixes #5480.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22772
diff
changeset
|
399 | scroll = FALSE; |
|
e1f64090d32e
Do not show tooltips for <HR> or <IMG>s in gtkimhtml. Fixes #5480.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22772
diff
changeset
|
400 | } |
|
e1f64090d32e
Do not show tooltips for <HR> or <IMG>s in gtkimhtml. Fixes #5480.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22772
diff
changeset
|
401 | |
|
e1f64090d32e
Do not show tooltips for <HR> or <IMG>s in gtkimhtml. Fixes #5480.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22772
diff
changeset
|
402 | if(imhtml->old_rect.width != rect.width || imhtml->old_rect.height != rect.height) { |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
403 | GList *iter = GTK_IMHTML(widget)->scalables; |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
404 | |
| 8726 | 405 | xminus = gtk_text_view_get_left_margin(GTK_TEXT_VIEW(widget)) + |
| 406 | gtk_text_view_get_right_margin(GTK_TEXT_VIEW(widget)); | |
| 407 | ||
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
408 | while(iter){ |
|
11224
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
409 | struct scalable_data *sd = iter->data; |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
410 | GtkIMHtmlScalable *scale = GTK_IMHTML_SCALABLE(sd->scalable); |
| 8726 | 411 | scale->scale(scale, rect.width - xminus, rect.height); |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
412 | |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
413 | iter = iter->next; |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
414 | } |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
415 | } |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
416 | |
|
18968
2ddbe6473bc9
Cool! Override GtkTextView's size allocate function in GtkIMHtml to make sure that it stays scrolled to the bottom whenever it's resized. Fixes a major annoyance and possibly #938
Sean Egan <seanegan@pidgin.im>
parents:
18665
diff
changeset
|
417 | imhtml->old_rect = rect; |
|
2ddbe6473bc9
Cool! Override GtkTextView's size allocate function in GtkIMHtml to make sure that it stays scrolled to the bottom whenever it's resized. Fixes a major annoyance and possibly #938
Sean Egan <seanegan@pidgin.im>
parents:
18665
diff
changeset
|
418 | parent_size_allocate(widget, alloc); |
|
22803
e1f64090d32e
Do not show tooltips for <HR> or <IMG>s in gtkimhtml. Fixes #5480.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22772
diff
changeset
|
419 | |
| 18985 | 420 | /* Don't scroll here if we're in the middle of a smooth scroll */ |
|
19326
d3071a414d6b
Don't scroll to bottom if imhtml is not realized. Fixes #2320
Sean Egan <seanegan@pidgin.im>
parents:
19325
diff
changeset
|
421 | if (scroll && imhtml->scroll_time == NULL && |
|
22803
e1f64090d32e
Do not show tooltips for <HR> or <IMG>s in gtkimhtml. Fixes #5480.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22772
diff
changeset
|
422 | GTK_WIDGET_REALIZED(imhtml)) |
|
e1f64090d32e
Do not show tooltips for <HR> or <IMG>s in gtkimhtml. Fixes #5480.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22772
diff
changeset
|
423 | gtk_imhtml_scroll_to_end(imhtml, FALSE); |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
424 | } |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
425 | |
|
23227
f2d8240d3487
Use text-tags to set the weight/color of the nick in conversations. This
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22970
diff
changeset
|
426 | #define DEFAULT_SEND_COLOR "#204a87" |
|
f2d8240d3487
Use text-tags to set the weight/color of the nick in conversations. This
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22970
diff
changeset
|
427 | #define DEFAULT_RECV_COLOR "#cc0000" |
|
f2d8240d3487
Use text-tags to set the weight/color of the nick in conversations. This
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22970
diff
changeset
|
428 | #define DEFAULT_HIGHLIGHT_COLOR "#AF7F00" |
|
f2d8240d3487
Use text-tags to set the weight/color of the nick in conversations. This
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22970
diff
changeset
|
429 | #define DEFAULT_ACTION_COLOR "#062585" |
|
f2d8240d3487
Use text-tags to set the weight/color of the nick in conversations. This
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22970
diff
changeset
|
430 | #define DEFAULT_WHISPER_ACTION_COLOR "#6C2585" |
|
f2d8240d3487
Use text-tags to set the weight/color of the nick in conversations. This
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22970
diff
changeset
|
431 | #define DEFAULT_WHISPER_COLOR "#00FF00" |
|
f2d8240d3487
Use text-tags to set the weight/color of the nick in conversations. This
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22970
diff
changeset
|
432 | |
|
f2d8240d3487
Use text-tags to set the weight/color of the nick in conversations. This
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22970
diff
changeset
|
433 | static void (*parent_style_set)(GtkWidget *widget, GtkStyle *prev_style); |
|
f2d8240d3487
Use text-tags to set the weight/color of the nick in conversations. This
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22970
diff
changeset
|
434 | |
|
f2d8240d3487
Use text-tags to set the weight/color of the nick in conversations. This
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22970
diff
changeset
|
435 | static void |
|
f2d8240d3487
Use text-tags to set the weight/color of the nick in conversations. This
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22970
diff
changeset
|
436 | gtk_imhtml_style_set(GtkWidget *widget, GtkStyle *prev_style) |
|
f2d8240d3487
Use text-tags to set the weight/color of the nick in conversations. This
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22970
diff
changeset
|
437 | { |
|
f2d8240d3487
Use text-tags to set the weight/color of the nick in conversations. This
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22970
diff
changeset
|
438 | int i; |
|
f2d8240d3487
Use text-tags to set the weight/color of the nick in conversations. This
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22970
diff
changeset
|
439 | struct { |
|
f2d8240d3487
Use text-tags to set the weight/color of the nick in conversations. This
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22970
diff
changeset
|
440 | const char *tag; |
|
f2d8240d3487
Use text-tags to set the weight/color of the nick in conversations. This
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22970
diff
changeset
|
441 | const char *color; |
|
f2d8240d3487
Use text-tags to set the weight/color of the nick in conversations. This
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22970
diff
changeset
|
442 | const char *def; |
|
f2d8240d3487
Use text-tags to set the weight/color of the nick in conversations. This
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22970
diff
changeset
|
443 | } styles[] = { |
|
f2d8240d3487
Use text-tags to set the weight/color of the nick in conversations. This
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22970
diff
changeset
|
444 | {"send-name", "send-name-color", DEFAULT_SEND_COLOR}, |
|
f2d8240d3487
Use text-tags to set the weight/color of the nick in conversations. This
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22970
diff
changeset
|
445 | {"receive-name", "receive-name-color", DEFAULT_RECV_COLOR}, |
|
f2d8240d3487
Use text-tags to set the weight/color of the nick in conversations. This
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22970
diff
changeset
|
446 | {"highlight-name", "highlight-name-color", DEFAULT_HIGHLIGHT_COLOR}, |
|
f2d8240d3487
Use text-tags to set the weight/color of the nick in conversations. This
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22970
diff
changeset
|
447 | {"action-name", "action-name-color", DEFAULT_ACTION_COLOR}, |
|
f2d8240d3487
Use text-tags to set the weight/color of the nick in conversations. This
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22970
diff
changeset
|
448 | {"whisper-action-name", "whisper-action-name-color", DEFAULT_WHISPER_ACTION_COLOR}, |
|
f2d8240d3487
Use text-tags to set the weight/color of the nick in conversations. This
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22970
diff
changeset
|
449 | {"whisper-name", "whisper-name-color", DEFAULT_WHISPER_COLOR}, |
|
f2d8240d3487
Use text-tags to set the weight/color of the nick in conversations. This
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22970
diff
changeset
|
450 | {NULL, NULL, NULL} |
|
f2d8240d3487
Use text-tags to set the weight/color of the nick in conversations. This
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22970
diff
changeset
|
451 | }; |
|
f2d8240d3487
Use text-tags to set the weight/color of the nick in conversations. This
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22970
diff
changeset
|
452 | GtkIMHtml *imhtml = GTK_IMHTML(widget); |
|
f2d8240d3487
Use text-tags to set the weight/color of the nick in conversations. This
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22970
diff
changeset
|
453 | GtkTextTagTable *table = gtk_text_buffer_get_tag_table(imhtml->text_buffer); |
|
f2d8240d3487
Use text-tags to set the weight/color of the nick in conversations. This
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22970
diff
changeset
|
454 | |
|
f2d8240d3487
Use text-tags to set the weight/color of the nick in conversations. This
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22970
diff
changeset
|
455 | for (i = 0; styles[i].tag; i++) { |
|
f2d8240d3487
Use text-tags to set the weight/color of the nick in conversations. This
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22970
diff
changeset
|
456 | GdkColor *color = NULL; |
|
f2d8240d3487
Use text-tags to set the weight/color of the nick in conversations. This
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22970
diff
changeset
|
457 | GtkTextTag *tag = gtk_text_tag_table_lookup(table, styles[i].tag); |
|
f2d8240d3487
Use text-tags to set the weight/color of the nick in conversations. This
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22970
diff
changeset
|
458 | if (!tag) { |
|
f2d8240d3487
Use text-tags to set the weight/color of the nick in conversations. This
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22970
diff
changeset
|
459 | purple_debug_warning("gtkimhtml", "Cannot find tag '%s'. This should never happen. Please file a bug.\n", styles[i].tag); |
|
f2d8240d3487
Use text-tags to set the weight/color of the nick in conversations. This
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22970
diff
changeset
|
460 | continue; |
|
f2d8240d3487
Use text-tags to set the weight/color of the nick in conversations. This
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22970
diff
changeset
|
461 | } |
|
f2d8240d3487
Use text-tags to set the weight/color of the nick in conversations. This
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22970
diff
changeset
|
462 | gtk_widget_style_get(widget, styles[i].color, &color, NULL); |
|
f2d8240d3487
Use text-tags to set the weight/color of the nick in conversations. This
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22970
diff
changeset
|
463 | if (color) { |
|
f2d8240d3487
Use text-tags to set the weight/color of the nick in conversations. This
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22970
diff
changeset
|
464 | g_object_set(tag, "foreground-gdk", color, NULL); |
|
f2d8240d3487
Use text-tags to set the weight/color of the nick in conversations. This
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22970
diff
changeset
|
465 | gdk_color_free(color); |
|
f2d8240d3487
Use text-tags to set the weight/color of the nick in conversations. This
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22970
diff
changeset
|
466 | } else { |
|
f2d8240d3487
Use text-tags to set the weight/color of the nick in conversations. This
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22970
diff
changeset
|
467 | GdkColor defcolor; |
|
f2d8240d3487
Use text-tags to set the weight/color of the nick in conversations. This
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22970
diff
changeset
|
468 | gdk_color_parse(styles[i].def, &defcolor); |
|
f2d8240d3487
Use text-tags to set the weight/color of the nick in conversations. This
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22970
diff
changeset
|
469 | g_object_set(tag, "foreground-gdk", &defcolor, NULL); |
|
f2d8240d3487
Use text-tags to set the weight/color of the nick in conversations. This
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22970
diff
changeset
|
470 | } |
|
f2d8240d3487
Use text-tags to set the weight/color of the nick in conversations. This
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22970
diff
changeset
|
471 | } |
|
f2d8240d3487
Use text-tags to set the weight/color of the nick in conversations. This
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22970
diff
changeset
|
472 | parent_style_set(widget, prev_style); |
|
f2d8240d3487
Use text-tags to set the weight/color of the nick in conversations. This
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22970
diff
changeset
|
473 | } |
|
f2d8240d3487
Use text-tags to set the weight/color of the nick in conversations. This
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22970
diff
changeset
|
474 | |
|
28935
84dbc0ca215d
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28932
diff
changeset
|
475 | static gboolean |
|
84dbc0ca215d
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28932
diff
changeset
|
476 | imhtml_get_iter_bounds(GtkIMHtml *imhtml, GtkTextIter *start, GtkTextIter *end) |
|
84dbc0ca215d
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28932
diff
changeset
|
477 | { |
|
84dbc0ca215d
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28932
diff
changeset
|
478 | if (imhtml->wbfo) { |
|
84dbc0ca215d
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28932
diff
changeset
|
479 | gtk_text_buffer_get_bounds(imhtml->text_buffer, start, end); |
|
84dbc0ca215d
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28932
diff
changeset
|
480 | return TRUE; |
|
84dbc0ca215d
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28932
diff
changeset
|
481 | } else if (imhtml->editable) { |
|
84dbc0ca215d
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28932
diff
changeset
|
482 | if (!gtk_text_buffer_get_selection_bounds(imhtml->text_buffer, start, end)) { |
|
84dbc0ca215d
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28932
diff
changeset
|
483 | GtkTextMark *mark = gtk_text_buffer_get_insert(imhtml->text_buffer); |
|
84dbc0ca215d
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28932
diff
changeset
|
484 | gtk_text_buffer_get_iter_at_mark(imhtml->text_buffer, start, mark); |
|
84dbc0ca215d
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28932
diff
changeset
|
485 | *end = *start; |
|
84dbc0ca215d
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28932
diff
changeset
|
486 | } |
|
84dbc0ca215d
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28932
diff
changeset
|
487 | return TRUE; |
|
84dbc0ca215d
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28932
diff
changeset
|
488 | } |
|
84dbc0ca215d
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28932
diff
changeset
|
489 | |
|
84dbc0ca215d
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28932
diff
changeset
|
490 | return FALSE; |
|
84dbc0ca215d
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28932
diff
changeset
|
491 | } |
|
84dbc0ca215d
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28932
diff
changeset
|
492 | |
|
24328
7be2af5c9129
Show visited links in a different color. This also plugs a memory leak
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23548
diff
changeset
|
493 | static void |
|
7be2af5c9129
Show visited links in a different color. This also plugs a memory leak
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23548
diff
changeset
|
494 | gtk_imhtml_set_link_color(GtkIMHtml *imhtml, GtkTextTag *tag) |
|
7be2af5c9129
Show visited links in a different color. This also plugs a memory leak
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23548
diff
changeset
|
495 | { |
|
7be2af5c9129
Show visited links in a different color. This also plugs a memory leak
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23548
diff
changeset
|
496 | GdkColor *color = NULL; |
|
7be2af5c9129
Show visited links in a different color. This also plugs a memory leak
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23548
diff
changeset
|
497 | gboolean visited = !!g_object_get_data(G_OBJECT(tag), "visited"); |
|
7be2af5c9129
Show visited links in a different color. This also plugs a memory leak
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23548
diff
changeset
|
498 | gtk_widget_style_get(GTK_WIDGET(imhtml), visited ? "hyperlink-visited-color" : "hyperlink-color", &color, NULL); |
|
7be2af5c9129
Show visited links in a different color. This also plugs a memory leak
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23548
diff
changeset
|
499 | if (color) { |
|
7be2af5c9129
Show visited links in a different color. This also plugs a memory leak
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23548
diff
changeset
|
500 | g_object_set(G_OBJECT(tag), "foreground-gdk", color, NULL); |
|
7be2af5c9129
Show visited links in a different color. This also plugs a memory leak
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23548
diff
changeset
|
501 | gdk_color_free(color); |
|
7be2af5c9129
Show visited links in a different color. This also plugs a memory leak
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23548
diff
changeset
|
502 | } else { |
|
7be2af5c9129
Show visited links in a different color. This also plugs a memory leak
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23548
diff
changeset
|
503 | g_object_set(G_OBJECT(tag), "foreground", visited ? "#800000" : "blue", NULL); |
|
7be2af5c9129
Show visited links in a different color. This also plugs a memory leak
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23548
diff
changeset
|
504 | } |
|
7be2af5c9129
Show visited links in a different color. This also plugs a memory leak
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23548
diff
changeset
|
505 | } |
|
7be2af5c9129
Show visited links in a different color. This also plugs a memory leak
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23548
diff
changeset
|
506 | |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
507 | static gint |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
508 | gtk_imhtml_tip_paint (GtkIMHtml *imhtml) |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
509 | { |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
510 | PangoLayout *layout; |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
511 | |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
512 | g_return_val_if_fail(GTK_IS_IMHTML(imhtml), FALSE); |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
513 | |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
514 | layout = gtk_widget_create_pango_layout(imhtml->tip_window, imhtml->tip); |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
515 | |
| 8061 | 516 | gtk_paint_flat_box (imhtml->tip_window->style, imhtml->tip_window->window, |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
517 | GTK_STATE_NORMAL, GTK_SHADOW_OUT, NULL, imhtml->tip_window, |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
518 | "tooltip", 0, 0, -1, -1); |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
519 | |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
520 | gtk_paint_layout (imhtml->tip_window->style, imhtml->tip_window->window, GTK_STATE_NORMAL, |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
521 | FALSE, NULL, imhtml->tip_window, NULL, 4, 4, layout); |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
522 | |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
523 | g_object_unref(layout); |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
524 | return FALSE; |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
525 | } |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
526 | |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
527 | static gint |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
528 | gtk_imhtml_tip (gpointer data) |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
529 | { |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
530 | GtkIMHtml *imhtml = data; |
| 8526 | 531 | PangoFontMetrics *font_metrics; |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
532 | PangoLayout *layout; |
| 8526 | 533 | PangoFont *font; |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
534 | |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
535 | gint gap, x, y, h, w, scr_w, baseline_skip; |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
536 | |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
537 | g_return_val_if_fail(GTK_IS_IMHTML(imhtml), FALSE); |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
538 | |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
539 | if (!imhtml->tip || !GTK_WIDGET_DRAWABLE (GTK_WIDGET(imhtml))) { |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
540 | imhtml->tip_timer = 0; |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
541 | return FALSE; |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
542 | } |
| 8061 | 543 | |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
544 | if (imhtml->tip_window){ |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
545 | gtk_widget_destroy (imhtml->tip_window); |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
546 | imhtml->tip_window = NULL; |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
547 | } |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
548 | |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
549 | imhtml->tip_timer = 0; |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
550 | imhtml->tip_window = gtk_window_new (GTK_WINDOW_POPUP); |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
551 | gtk_widget_set_app_paintable (imhtml->tip_window, TRUE); |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
552 | gtk_window_set_resizable (GTK_WINDOW (imhtml->tip_window), FALSE); |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
553 | gtk_widget_set_name (imhtml->tip_window, "gtk-tooltips"); |
|
22595
5ce90eecd894
GDK_WINDOW_TYPE_HINT_TOOLTIP is new with Gtk 2.10
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22594
diff
changeset
|
554 | #if GTK_CHECK_VERSION(2,10,0) |
|
22594
4fe64dc3d266
Set the TOOLTIP hint on imhtml link tooltips. Thanks to Danny Baumann for
Will Thompson <resiak@pidgin.im>
parents:
22532
diff
changeset
|
555 | gtk_window_set_type_hint (GTK_WINDOW (imhtml->tip_window), |
|
4fe64dc3d266
Set the TOOLTIP hint on imhtml link tooltips. Thanks to Danny Baumann for
Will Thompson <resiak@pidgin.im>
parents:
22532
diff
changeset
|
556 | GDK_WINDOW_TYPE_HINT_TOOLTIP); |
|
22595
5ce90eecd894
GDK_WINDOW_TYPE_HINT_TOOLTIP is new with Gtk 2.10
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22594
diff
changeset
|
557 | #endif |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
558 | g_signal_connect_swapped (G_OBJECT (imhtml->tip_window), "expose_event", |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
559 | G_CALLBACK (gtk_imhtml_tip_paint), imhtml); |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
560 | |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
561 | gtk_widget_ensure_style (imhtml->tip_window); |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
562 | layout = gtk_widget_create_pango_layout(imhtml->tip_window, imhtml->tip); |
| 8526 | 563 | font = pango_context_load_font(pango_layout_get_context(layout), |
| 564 | imhtml->tip_window->style->font_desc); | |
| 565 | ||
| 566 | if (font == NULL) { | |
| 567 | char *tmp = pango_font_description_to_string( | |
| 568 | imhtml->tip_window->style->font_desc); | |
| 569 | ||
| 15884 | 570 | purple_debug(PURPLE_DEBUG_ERROR, "gtk_imhtml_tip", |
| 8526 | 571 | "pango_context_load_font() couldn't load font: '%s'\n", |
| 572 | tmp); | |
| 573 | g_free(tmp); | |
| 574 | ||
|
23174
6a5b2c601492
applied changes from a341780d901f6351a5cf768a08d30c8882d6cf2f
Daniel Atallah <datallah@pidgin.im>
parents:
22970
diff
changeset
|
575 | g_object_unref(layout); |
| 8526 | 576 | return FALSE; |
| 577 | } | |
| 578 | ||
| 579 | font_metrics = pango_font_get_metrics(font, NULL); | |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
580 | |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
581 | pango_layout_get_pixel_size(layout, &scr_w, NULL); |
| 8526 | 582 | gap = PANGO_PIXELS((pango_font_metrics_get_ascent(font_metrics) + |
| 583 | pango_font_metrics_get_descent(font_metrics))/ 4); | |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
584 | |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
585 | if (gap < 2) |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
586 | gap = 2; |
| 8526 | 587 | baseline_skip = PANGO_PIXELS(pango_font_metrics_get_ascent(font_metrics) + |
| 588 | pango_font_metrics_get_descent(font_metrics)); | |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
589 | w = 8 + scr_w; |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
590 | h = 8 + baseline_skip; |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
591 | |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
592 | gdk_window_get_pointer (NULL, &x, &y, NULL); |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
593 | if (GTK_WIDGET_NO_WINDOW (GTK_WIDGET(imhtml))) |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
594 | y += GTK_WIDGET(imhtml)->allocation.y; |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
595 | |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
596 | scr_w = gdk_screen_width(); |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
597 | |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
598 | x -= ((w >> 1) + 4); |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
599 | |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
600 | if ((x + w) > scr_w) |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
601 | x -= (x + w) - scr_w; |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
602 | else if (x < 0) |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
603 | x = 0; |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
604 | |
| 8526 | 605 | y = y + PANGO_PIXELS(pango_font_metrics_get_ascent(font_metrics) + |
| 606 | pango_font_metrics_get_descent(font_metrics)); | |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
607 | |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
608 | gtk_widget_set_size_request (imhtml->tip_window, w, h); |
|
15865
e046bdae3964
Move the tooltip window before showing the tooltip to avoid a transient
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
15577
diff
changeset
|
609 | gtk_window_move (GTK_WINDOW(imhtml->tip_window), x, y); |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
610 | gtk_widget_show (imhtml->tip_window); |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
611 | |
| 8526 | 612 | pango_font_metrics_unref(font_metrics); |
|
23174
6a5b2c601492
applied changes from a341780d901f6351a5cf768a08d30c8882d6cf2f
Daniel Atallah <datallah@pidgin.im>
parents:
22970
diff
changeset
|
613 | g_object_unref(font); |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
614 | g_object_unref(layout); |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
615 | |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
616 | return FALSE; |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
617 | } |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
618 | |
|
11844
57ad7c52cc9c
[gaim-migrate @ 14135]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11840
diff
changeset
|
619 | static gboolean |
|
57ad7c52cc9c
[gaim-migrate @ 14135]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11840
diff
changeset
|
620 | gtk_motion_event_notify(GtkWidget *imhtml, GdkEventMotion *event, gpointer data) |
| 8061 | 621 | { |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
622 | GtkTextIter iter; |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
623 | GdkWindow *win = event->window; |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
624 | int x, y; |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
625 | char *tip = NULL; |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
626 | GSList *tags = NULL, *templist = NULL; |
| 10799 | 627 | GtkTextTag *tag = NULL, *oldprelit_tag; |
|
18543
c590aed61aa4
Show tooltip for smileys. Fixes #1981.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18371
diff
changeset
|
628 | GtkTextChildAnchor* anchor; |
|
c590aed61aa4
Show tooltip for smileys. Fixes #1981.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18371
diff
changeset
|
629 | gboolean hand = TRUE; |
| 10799 | 630 | |
| 631 | oldprelit_tag = GTK_IMHTML(imhtml)->prelit_tag; | |
| 632 | ||
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
633 | gdk_window_get_pointer(GTK_WIDGET(imhtml)->window, NULL, NULL, NULL); |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
634 | gtk_text_view_window_to_buffer_coords(GTK_TEXT_VIEW(imhtml), GTK_TEXT_WINDOW_WIDGET, |
| 10799 | 635 | event->x, event->y, &x, &y); |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
636 | gtk_text_view_get_iter_at_location(GTK_TEXT_VIEW(imhtml), &iter, x, y); |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
637 | tags = gtk_text_iter_get_tags(&iter); |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
638 | |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
639 | templist = tags; |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
640 | while (templist) { |
| 10799 | 641 | tag = templist->data; |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
642 | tip = g_object_get_data(G_OBJECT(tag), "link_url"); |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
643 | if (tip) |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
644 | break; |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
645 | templist = templist->next; |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
646 | } |
| 8061 | 647 | |
|
24328
7be2af5c9129
Show visited links in a different color. This also plugs a memory leak
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23548
diff
changeset
|
648 | if (tip && (!tag || !g_object_get_data(G_OBJECT(tag), "visited"))) { |
| 10799 | 649 | GTK_IMHTML(imhtml)->prelit_tag = tag; |
| 650 | if (tag != oldprelit_tag) { | |
|
24328
7be2af5c9129
Show visited links in a different color. This also plugs a memory leak
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23548
diff
changeset
|
651 | GdkColor *pre = NULL; |
|
7be2af5c9129
Show visited links in a different color. This also plugs a memory leak
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23548
diff
changeset
|
652 | gtk_widget_style_get(GTK_WIDGET(imhtml), "hyperlink-prelight-color", &pre, NULL); |
|
7be2af5c9129
Show visited links in a different color. This also plugs a memory leak
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23548
diff
changeset
|
653 | if (pre) { |
| 10799 | 654 | g_object_set(G_OBJECT(tag), "foreground-gdk", pre, NULL); |
|
24328
7be2af5c9129
Show visited links in a different color. This also plugs a memory leak
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23548
diff
changeset
|
655 | gdk_color_free(pre); |
|
7be2af5c9129
Show visited links in a different color. This also plugs a memory leak
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23548
diff
changeset
|
656 | } else |
|
12253
5025434b18f8
[gaim-migrate @ 14555]
Mark Doliner <markdoliner@pidgin.im>
parents:
12230
diff
changeset
|
657 | g_object_set(G_OBJECT(tag), "foreground", "#70a0ff", NULL); |
| 10799 | 658 | } |
| 659 | } else { | |
| 660 | GTK_IMHTML(imhtml)->prelit_tag = NULL; | |
| 661 | } | |
|
11572
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
662 | |
|
10834
5fd1dfd395e8
[gaim-migrate @ 12505]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10826
diff
changeset
|
663 | if ((oldprelit_tag != NULL) && (GTK_IMHTML(imhtml)->prelit_tag != oldprelit_tag)) { |
|
24328
7be2af5c9129
Show visited links in a different color. This also plugs a memory leak
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23548
diff
changeset
|
664 | gtk_imhtml_set_link_color(GTK_IMHTML(imhtml), oldprelit_tag); |
| 10799 | 665 | } |
| 666 | ||
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
667 | if (GTK_IMHTML(imhtml)->tip) { |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
668 | if ((tip == GTK_IMHTML(imhtml)->tip)) { |
| 21069 | 669 | g_slist_free(tags); |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
670 | return FALSE; |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
671 | } |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
672 | /* We've left the cell. Remove the timeout and create a new one below */ |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
673 | if (GTK_IMHTML(imhtml)->tip_window) { |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
674 | gtk_widget_destroy(GTK_IMHTML(imhtml)->tip_window); |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
675 | GTK_IMHTML(imhtml)->tip_window = NULL; |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
676 | } |
| 8061 | 677 | if (GTK_IMHTML(imhtml)->editable) |
| 678 | gdk_window_set_cursor(win, GTK_IMHTML(imhtml)->text_cursor); | |
| 679 | else | |
| 680 | gdk_window_set_cursor(win, GTK_IMHTML(imhtml)->arrow_cursor); | |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
681 | if (GTK_IMHTML(imhtml)->tip_timer) |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
682 | g_source_remove(GTK_IMHTML(imhtml)->tip_timer); |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
683 | GTK_IMHTML(imhtml)->tip_timer = 0; |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
684 | } |
| 8061 | 685 | |
|
18543
c590aed61aa4
Show tooltip for smileys. Fixes #1981.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18371
diff
changeset
|
686 | /* If we don't have a tip from a URL, let's see if we have a tip from a smiley */ |
|
c590aed61aa4
Show tooltip for smileys. Fixes #1981.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18371
diff
changeset
|
687 | anchor = gtk_text_iter_get_child_anchor(&iter); |
|
c590aed61aa4
Show tooltip for smileys. Fixes #1981.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18371
diff
changeset
|
688 | if (anchor) { |
|
22803
e1f64090d32e
Do not show tooltips for <HR> or <IMG>s in gtkimhtml. Fixes #5480.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22772
diff
changeset
|
689 | tip = g_object_get_data(G_OBJECT(anchor), "gtkimhtml_tiptext"); |
|
18543
c590aed61aa4
Show tooltip for smileys. Fixes #1981.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18371
diff
changeset
|
690 | hand = FALSE; |
|
c590aed61aa4
Show tooltip for smileys. Fixes #1981.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18371
diff
changeset
|
691 | } |
|
c590aed61aa4
Show tooltip for smileys. Fixes #1981.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18371
diff
changeset
|
692 | |
|
22803
e1f64090d32e
Do not show tooltips for <HR> or <IMG>s in gtkimhtml. Fixes #5480.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22772
diff
changeset
|
693 | if (tip && *tip) { |
|
18543
c590aed61aa4
Show tooltip for smileys. Fixes #1981.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
18371
diff
changeset
|
694 | if (!GTK_IMHTML(imhtml)->editable && hand) |
| 8061 | 695 | gdk_window_set_cursor(win, GTK_IMHTML(imhtml)->hand_cursor); |
| 696 | GTK_IMHTML(imhtml)->tip_timer = g_timeout_add (TOOLTIP_TIMEOUT, | |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
697 | gtk_imhtml_tip, imhtml); |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
698 | } |
| 8061 | 699 | |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
700 | GTK_IMHTML(imhtml)->tip = tip; |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
701 | g_slist_free(tags); |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
702 | return FALSE; |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
703 | } |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
704 | |
|
11677
89c2ab8d2ebf
[gaim-migrate @ 13963]
Mark Doliner <markdoliner@pidgin.im>
parents:
11586
diff
changeset
|
705 | static gboolean |
|
89c2ab8d2ebf
[gaim-migrate @ 13963]
Mark Doliner <markdoliner@pidgin.im>
parents:
11586
diff
changeset
|
706 | gtk_enter_event_notify(GtkWidget *imhtml, GdkEventCrossing *event, gpointer data) |
|
10946
63a41710fc94
[gaim-migrate @ 12742]
Daniel Atallah <datallah@pidgin.im>
parents:
10936
diff
changeset
|
707 | { |
|
63a41710fc94
[gaim-migrate @ 12742]
Daniel Atallah <datallah@pidgin.im>
parents:
10936
diff
changeset
|
708 | if (GTK_IMHTML(imhtml)->editable) |
|
63a41710fc94
[gaim-migrate @ 12742]
Daniel Atallah <datallah@pidgin.im>
parents:
10936
diff
changeset
|
709 | gdk_window_set_cursor( |
|
63a41710fc94
[gaim-migrate @ 12742]
Daniel Atallah <datallah@pidgin.im>
parents:
10936
diff
changeset
|
710 | gtk_text_view_get_window(GTK_TEXT_VIEW(imhtml), |
|
63a41710fc94
[gaim-migrate @ 12742]
Daniel Atallah <datallah@pidgin.im>
parents:
10936
diff
changeset
|
711 | GTK_TEXT_WINDOW_TEXT), |
|
63a41710fc94
[gaim-migrate @ 12742]
Daniel Atallah <datallah@pidgin.im>
parents:
10936
diff
changeset
|
712 | GTK_IMHTML(imhtml)->text_cursor); |
|
63a41710fc94
[gaim-migrate @ 12742]
Daniel Atallah <datallah@pidgin.im>
parents:
10936
diff
changeset
|
713 | else |
|
63a41710fc94
[gaim-migrate @ 12742]
Daniel Atallah <datallah@pidgin.im>
parents:
10936
diff
changeset
|
714 | gdk_window_set_cursor( |
|
63a41710fc94
[gaim-migrate @ 12742]
Daniel Atallah <datallah@pidgin.im>
parents:
10936
diff
changeset
|
715 | gtk_text_view_get_window(GTK_TEXT_VIEW(imhtml), |
|
63a41710fc94
[gaim-migrate @ 12742]
Daniel Atallah <datallah@pidgin.im>
parents:
10936
diff
changeset
|
716 | GTK_TEXT_WINDOW_TEXT), |
|
63a41710fc94
[gaim-migrate @ 12742]
Daniel Atallah <datallah@pidgin.im>
parents:
10936
diff
changeset
|
717 | GTK_IMHTML(imhtml)->arrow_cursor); |
|
63a41710fc94
[gaim-migrate @ 12742]
Daniel Atallah <datallah@pidgin.im>
parents:
10936
diff
changeset
|
718 | |
|
63a41710fc94
[gaim-migrate @ 12742]
Daniel Atallah <datallah@pidgin.im>
parents:
10936
diff
changeset
|
719 | /* propagate the event normally */ |
|
63a41710fc94
[gaim-migrate @ 12742]
Daniel Atallah <datallah@pidgin.im>
parents:
10936
diff
changeset
|
720 | return FALSE; |
|
63a41710fc94
[gaim-migrate @ 12742]
Daniel Atallah <datallah@pidgin.im>
parents:
10936
diff
changeset
|
721 | } |
|
63a41710fc94
[gaim-migrate @ 12742]
Daniel Atallah <datallah@pidgin.im>
parents:
10936
diff
changeset
|
722 | |
|
11677
89c2ab8d2ebf
[gaim-migrate @ 13963]
Mark Doliner <markdoliner@pidgin.im>
parents:
11586
diff
changeset
|
723 | static gboolean |
|
89c2ab8d2ebf
[gaim-migrate @ 13963]
Mark Doliner <markdoliner@pidgin.im>
parents:
11586
diff
changeset
|
724 | gtk_leave_event_notify(GtkWidget *imhtml, GdkEventCrossing *event, gpointer data) |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
725 | { |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
726 | /* when leaving the widget, clear any current & pending tooltips and restore the cursor */ |
| 10799 | 727 | if (GTK_IMHTML(imhtml)->prelit_tag) { |
|
24328
7be2af5c9129
Show visited links in a different color. This also plugs a memory leak
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23548
diff
changeset
|
728 | gtk_imhtml_set_link_color(GTK_IMHTML(imhtml), GTK_IMHTML(imhtml)->prelit_tag); |
| 10799 | 729 | GTK_IMHTML(imhtml)->prelit_tag = NULL; |
| 730 | } | |
| 731 | ||
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
732 | if (GTK_IMHTML(imhtml)->tip_window) { |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
733 | gtk_widget_destroy(GTK_IMHTML(imhtml)->tip_window); |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
734 | GTK_IMHTML(imhtml)->tip_window = NULL; |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
735 | } |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
736 | if (GTK_IMHTML(imhtml)->tip_timer) { |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
737 | g_source_remove(GTK_IMHTML(imhtml)->tip_timer); |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
738 | GTK_IMHTML(imhtml)->tip_timer = 0; |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
739 | } |
|
10946
63a41710fc94
[gaim-migrate @ 12742]
Daniel Atallah <datallah@pidgin.im>
parents:
10936
diff
changeset
|
740 | gdk_window_set_cursor( |
|
63a41710fc94
[gaim-migrate @ 12742]
Daniel Atallah <datallah@pidgin.im>
parents:
10936
diff
changeset
|
741 | gtk_text_view_get_window(GTK_TEXT_VIEW(imhtml), |
|
63a41710fc94
[gaim-migrate @ 12742]
Daniel Atallah <datallah@pidgin.im>
parents:
10936
diff
changeset
|
742 | GTK_TEXT_WINDOW_TEXT), NULL); |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
743 | |
|
8568
66907b37ce85
[gaim-migrate @ 9316]
Mark Doliner <markdoliner@pidgin.im>
parents:
8566
diff
changeset
|
744 | /* propagate the event normally */ |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
745 | return FALSE; |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
746 | } |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
747 | |
|
10844
fb5b88957742
[gaim-migrate @ 12516]
Richard Laager <rlaager@pidgin.im>
parents:
10834
diff
changeset
|
748 | #if (!GTK_CHECK_VERSION(2,2,0)) |
| 6066 | 749 | /* |
| 750 | * XXX - This should be removed eventually. | |
| 751 | * | |
| 8061 | 752 | * This function exists to work around a gross bug in GtkTextView. |
| 753 | * Basically, we short circuit ctrl+a and ctrl+end because they make | |
| 6066 | 754 | * el program go boom. |
| 755 | * | |
| 8061 | 756 | * It's supposed to be fixed in gtk2.2. You can view the bug report at |
| 6066 | 757 | * http://bugzilla.gnome.org/show_bug.cgi?id=107939 |
| 758 | */ | |
|
10849
476d68d7a435
[gaim-migrate @ 12521]
Richard Laager <rlaager@pidgin.im>
parents:
10844
diff
changeset
|
759 | static gboolean |
|
476d68d7a435
[gaim-migrate @ 12521]
Richard Laager <rlaager@pidgin.im>
parents:
10844
diff
changeset
|
760 | gtk_key_pressed_cb(GtkIMHtml *imhtml, GdkEventKey *event, gpointer data) |
| 8677 | 761 | { |
|
10844
fb5b88957742
[gaim-migrate @ 12516]
Richard Laager <rlaager@pidgin.im>
parents:
10834
diff
changeset
|
762 | if (event->state & GDK_CONTROL_MASK) { |
| 6066 | 763 | switch (event->keyval) { |
|
10844
fb5b88957742
[gaim-migrate @ 12516]
Richard Laager <rlaager@pidgin.im>
parents:
10834
diff
changeset
|
764 | case 'a': |
|
fb5b88957742
[gaim-migrate @ 12516]
Richard Laager <rlaager@pidgin.im>
parents:
10834
diff
changeset
|
765 | case GDK_Home: |
|
fb5b88957742
[gaim-migrate @ 12516]
Richard Laager <rlaager@pidgin.im>
parents:
10834
diff
changeset
|
766 | case GDK_End: |
|
fb5b88957742
[gaim-migrate @ 12516]
Richard Laager <rlaager@pidgin.im>
parents:
10834
diff
changeset
|
767 | return TRUE; |
| 6066 | 768 | } |
|
10844
fb5b88957742
[gaim-migrate @ 12516]
Richard Laager <rlaager@pidgin.im>
parents:
10834
diff
changeset
|
769 | } |
| 6066 | 770 | return FALSE; |
| 771 | } | |
|
10844
fb5b88957742
[gaim-migrate @ 12516]
Richard Laager <rlaager@pidgin.im>
parents:
10834
diff
changeset
|
772 | #endif /* !(GTK+ >= 2.2.0) */ |
| 10692 | 773 | |
| 774 | static gint | |
| 775 | gtk_imhtml_expose_event (GtkWidget *widget, | |
| 776 | GdkEventExpose *event) | |
| 777 | { | |
| 10776 | 778 | GtkTextIter start, end, cur; |
| 779 | int buf_x, buf_y; | |
| 780 | GdkRectangle visible_rect; | |
| 10777 | 781 | GdkGC *gc = gdk_gc_new(GDK_DRAWABLE(event->window)); |
| 782 | GdkColor gcolor; | |
|
10844
fb5b88957742
[gaim-migrate @ 12516]
Richard Laager <rlaager@pidgin.im>
parents:
10834
diff
changeset
|
783 | |
| 10776 | 784 | gtk_text_view_get_visible_rect(GTK_TEXT_VIEW(widget), &visible_rect); |
| 785 | gtk_text_view_buffer_to_window_coords(GTK_TEXT_VIEW(widget), | |
| 786 | GTK_TEXT_WINDOW_TEXT, | |
| 787 | visible_rect.x, | |
| 788 | visible_rect.y, | |
| 789 | &visible_rect.x, | |
| 790 | &visible_rect.y); | |
| 791 | ||
| 792 | gtk_text_view_window_to_buffer_coords(GTK_TEXT_VIEW(widget), GTK_TEXT_WINDOW_TEXT, | |
| 793 | event->area.x, event->area.y, &buf_x, &buf_y); | |
| 794 | ||
| 10777 | 795 | if (GTK_IMHTML(widget)->editable || GTK_IMHTML(widget)->wbfo) { |
|
11572
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
796 | |
| 10777 | 797 | if (GTK_IMHTML(widget)->edit.background) { |
| 798 | gdk_color_parse(GTK_IMHTML(widget)->edit.background, &gcolor); | |
| 799 | gdk_gc_set_rgb_fg_color(gc, &gcolor); | |
| 800 | } else { | |
| 801 | gdk_gc_set_rgb_fg_color(gc, &(widget->style->base[GTK_WIDGET_STATE(widget)])); | |
| 802 | } | |
|
11572
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
803 | |
| 10777 | 804 | gdk_draw_rectangle(event->window, |
| 805 | gc, | |
| 806 | TRUE, | |
| 807 | visible_rect.x, visible_rect.y, visible_rect.width, visible_rect.height); | |
|
26828
ca76e7ad0d4b
Oops, I must have been tired. I only replaced the first occurrence of these
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26727
diff
changeset
|
808 | g_object_unref(G_OBJECT(gc)); |
|
11572
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
809 | |
| 10777 | 810 | if (GTK_WIDGET_CLASS (parent_class)->expose_event) |
| 811 | return (* GTK_WIDGET_CLASS (parent_class)->expose_event) | |
| 812 | (widget, event); | |
| 813 | return FALSE; | |
| 814 | ||
| 815 | } | |
|
11572
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
816 | |
| 10776 | 817 | gtk_text_view_get_iter_at_location(GTK_TEXT_VIEW(widget), &start, buf_x, buf_y); |
| 818 | gtk_text_view_get_iter_at_location(GTK_TEXT_VIEW(widget), &end, | |
| 819 | buf_x + event->area.width, buf_y + event->area.height); | |
| 820 | ||
|
23187
671e00775afb
*** Plucked rev 69b22e32f7ada182101e0746f02891389ceb0c52 (sadrul@pidgin.im):
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23174
diff
changeset
|
821 | gtk_text_iter_order(&start, &end); |
| 10776 | 822 | |
| 823 | cur = start; | |
| 824 | ||
| 825 | while (gtk_text_iter_in_range(&cur, &start, &end)) { | |
| 10795 | 826 | GSList *tags = gtk_text_iter_get_tags(&cur); |
| 827 | GSList *l; | |
| 10776 | 828 | |
| 829 | for (l = tags; l; l = l->next) { | |
| 830 | GtkTextTag *tag = l->data; | |
| 831 | GdkRectangle rect; | |
| 832 | GdkRectangle tag_area; | |
| 833 | const char *color; | |
|
11572
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
834 | |
| 10776 | 835 | if (strncmp(tag->name, "BACKGROUND ", 11)) |
| 836 | continue; | |
| 837 | ||
| 838 | if (gtk_text_iter_ends_tag(&cur, tag)) | |
| 839 | continue; | |
| 840 | ||
| 841 | gtk_text_view_get_iter_location(GTK_TEXT_VIEW(widget), &cur, &tag_area); | |
| 842 | gtk_text_view_buffer_to_window_coords(GTK_TEXT_VIEW(widget), | |
| 843 | GTK_TEXT_WINDOW_TEXT, | |
| 844 | tag_area.x, | |
| 845 | tag_area.y, | |
| 846 | &tag_area.x, | |
| 847 | &tag_area.y); | |
| 848 | rect.x = visible_rect.x; | |
| 849 | rect.y = tag_area.y; | |
|
11768
b45e26d7a4c9
[gaim-migrate @ 14059]
Gary Kramlich <grim@reaperworld.com>
parents:
11760
diff
changeset
|
850 | rect.width = visible_rect.width; |
| 10776 | 851 | |
| 10795 | 852 | do |
| 10776 | 853 | gtk_text_iter_forward_to_tag_toggle(&cur, tag); |
| 10795 | 854 | while (!gtk_text_iter_is_end(&cur) && gtk_text_iter_begins_tag(&cur, tag)); |
| 855 | ||
| 10776 | 856 | gtk_text_view_get_iter_location(GTK_TEXT_VIEW(widget), &cur, &tag_area); |
| 857 | gtk_text_view_buffer_to_window_coords(GTK_TEXT_VIEW(widget), | |
| 858 | GTK_TEXT_WINDOW_TEXT, | |
| 859 | tag_area.x, | |
| 860 | tag_area.y, | |
| 861 | &tag_area.x, | |
| 862 | &tag_area.y); | |
| 863 | ||
|
25888
d0fdd378a635
Remove trailing whitespace
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
864 | |
| 11760 | 865 | rect.height = tag_area.y + tag_area.height - rect.y |
|
22865
eeed3e121bed
Move 2 of the 5 pixels' padding between paragraphs to above the line.
Will Thompson <resiak@pidgin.im>
parents:
22834
diff
changeset
|
866 | + gtk_text_view_get_pixels_above_lines(GTK_TEXT_VIEW(widget)) |
| 11760 | 867 | + gtk_text_view_get_pixels_below_lines(GTK_TEXT_VIEW(widget)); |
|
11572
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
868 | |
| 10776 | 869 | color = tag->name + 11; |
| 870 | ||
| 10857 | 871 | if (!gdk_color_parse(color, &gcolor)) { |
| 10858 | 872 | gchar tmp[8]; |
| 873 | tmp[0] = '#'; | |
| 874 | strncpy(&tmp[1], color, 7); | |
| 875 | tmp[7] = '\0'; | |
| 10857 | 876 | if (!gdk_color_parse(tmp, &gcolor)) |
| 877 | gdk_color_parse("white", &gcolor); | |
| 878 | } | |
| 10776 | 879 | gdk_gc_set_rgb_fg_color(gc, &gcolor); |
| 880 | ||
| 881 | gdk_draw_rectangle(event->window, | |
| 882 | gc, | |
| 883 | TRUE, | |
| 884 | rect.x, rect.y, rect.width, rect.height); | |
| 10795 | 885 | gtk_text_iter_backward_char(&cur); /* go back one, in case the end is the begining is the end |
| 886 | * note that above, we always moved cur ahead by at least | |
| 887 | * one character */ | |
| 10776 | 888 | break; |
| 889 | } | |
| 890 | ||
| 891 | g_slist_free(tags); | |
| 10795 | 892 | |
| 893 | /* loop until another tag begins, or no tag begins */ | |
| 894 | while (gtk_text_iter_forward_to_tag_toggle(&cur, NULL) && | |
| 895 | !gtk_text_iter_is_end(&cur) && | |
| 896 | !gtk_text_iter_begins_tag(&cur, NULL)); | |
|
11572
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
897 | } |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
898 | |
|
26828
ca76e7ad0d4b
Oops, I must have been tired. I only replaced the first occurrence of these
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26727
diff
changeset
|
899 | g_object_unref(G_OBJECT(gc)); |
| 10777 | 900 | |
| 10692 | 901 | if (GTK_WIDGET_CLASS (parent_class)->expose_event) |
| 902 | return (* GTK_WIDGET_CLASS (parent_class)->expose_event) | |
| 903 | (widget, event); | |
| 10776 | 904 | |
| 10692 | 905 | return FALSE; |
| 906 | } | |
| 907 | ||
| 908 | ||
| 8931 | 909 | static void paste_unformatted_cb(GtkMenuItem *menu, GtkIMHtml *imhtml) |
| 910 | { | |
| 911 | GtkClipboard *clipboard = gtk_widget_get_clipboard(GTK_WIDGET(imhtml), GDK_SELECTION_CLIPBOARD); | |
| 912 | ||
| 913 | gtk_clipboard_request_text(clipboard, paste_plaintext_received_cb, imhtml); | |
| 914 | ||
| 915 | } | |
| 916 | ||
| 13336 | 917 | static void clear_formatting_cb(GtkMenuItem *menu, GtkIMHtml *imhtml) |
| 918 | { | |
| 919 | gtk_imhtml_clear_formatting(imhtml); | |
| 920 | } | |
| 10692 | 921 | |
|
22970
87aef86d20c5
Allow replacing smileys with texts in conversations/logs. This should be
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22865
diff
changeset
|
922 | static void disable_smiley_selected(GtkMenuItem *item, GtkIMHtml *imhtml) |
|
87aef86d20c5
Allow replacing smileys with texts in conversations/logs. This should be
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22865
diff
changeset
|
923 | { |
|
87aef86d20c5
Allow replacing smileys with texts in conversations/logs. This should be
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22865
diff
changeset
|
924 | GtkTextIter start, end; |
|
87aef86d20c5
Allow replacing smileys with texts in conversations/logs. This should be
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22865
diff
changeset
|
925 | GtkTextMark *mark; |
|
87aef86d20c5
Allow replacing smileys with texts in conversations/logs. This should be
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22865
diff
changeset
|
926 | char *text; |
|
87aef86d20c5
Allow replacing smileys with texts in conversations/logs. This should be
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22865
diff
changeset
|
927 | |
|
87aef86d20c5
Allow replacing smileys with texts in conversations/logs. This should be
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22865
diff
changeset
|
928 | if (!gtk_text_buffer_get_selection_bounds(imhtml->text_buffer, &start, &end)) |
|
87aef86d20c5
Allow replacing smileys with texts in conversations/logs. This should be
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22865
diff
changeset
|
929 | return; |
|
87aef86d20c5
Allow replacing smileys with texts in conversations/logs. This should be
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22865
diff
changeset
|
930 | |
|
87aef86d20c5
Allow replacing smileys with texts in conversations/logs. This should be
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22865
diff
changeset
|
931 | text = gtk_imhtml_get_markup_range(imhtml, &start, &end); |
|
87aef86d20c5
Allow replacing smileys with texts in conversations/logs. This should be
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22865
diff
changeset
|
932 | |
|
87aef86d20c5
Allow replacing smileys with texts in conversations/logs. This should be
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22865
diff
changeset
|
933 | mark = gtk_text_buffer_get_selection_bound(imhtml->text_buffer); |
|
87aef86d20c5
Allow replacing smileys with texts in conversations/logs. This should be
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22865
diff
changeset
|
934 | gtk_text_buffer_delete_selection(imhtml->text_buffer, FALSE, FALSE); |
|
87aef86d20c5
Allow replacing smileys with texts in conversations/logs. This should be
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22865
diff
changeset
|
935 | |
|
87aef86d20c5
Allow replacing smileys with texts in conversations/logs. This should be
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22865
diff
changeset
|
936 | gtk_text_buffer_get_iter_at_mark(imhtml->text_buffer, &start, mark); |
|
87aef86d20c5
Allow replacing smileys with texts in conversations/logs. This should be
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22865
diff
changeset
|
937 | gtk_imhtml_insert_html_at_iter(imhtml, text, GTK_IMHTML_NO_NEWLINE | GTK_IMHTML_NO_SMILEY, &start); |
|
87aef86d20c5
Allow replacing smileys with texts in conversations/logs. This should be
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22865
diff
changeset
|
938 | |
|
87aef86d20c5
Allow replacing smileys with texts in conversations/logs. This should be
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22865
diff
changeset
|
939 | g_free(text); |
|
87aef86d20c5
Allow replacing smileys with texts in conversations/logs. This should be
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22865
diff
changeset
|
940 | } |
|
87aef86d20c5
Allow replacing smileys with texts in conversations/logs. This should be
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22865
diff
changeset
|
941 | |
| 8931 | 942 | static void hijack_menu_cb(GtkIMHtml *imhtml, GtkMenu *menu, gpointer data) |
| 943 | { | |
| 944 | GtkWidget *menuitem; | |
|
22970
87aef86d20c5
Allow replacing smileys with texts in conversations/logs. This should be
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22865
diff
changeset
|
945 | GtkTextIter start, end; |
| 8931 | 946 | |
|
12635
5b2fbc3da55b
[gaim-migrate @ 14971]
Richard Laager <rlaager@pidgin.im>
parents:
12605
diff
changeset
|
947 | menuitem = gtk_menu_item_new_with_mnemonic(_("Paste as Plain _Text")); |
| 8931 | 948 | gtk_widget_show(menuitem); |
|
14970
fd8984ce4fda
[gaim-migrate @ 17680]
Mark Doliner <markdoliner@pidgin.im>
parents:
14863
diff
changeset
|
949 | /* |
|
fd8984ce4fda
[gaim-migrate @ 17680]
Mark Doliner <markdoliner@pidgin.im>
parents:
14863
diff
changeset
|
950 | * TODO: gtk_clipboard_wait_is_text_available() iterates the glib |
|
fd8984ce4fda
[gaim-migrate @ 17680]
Mark Doliner <markdoliner@pidgin.im>
parents:
14863
diff
changeset
|
951 | * mainloop, which tends to be a source of bugs. It would |
|
fd8984ce4fda
[gaim-migrate @ 17680]
Mark Doliner <markdoliner@pidgin.im>
parents:
14863
diff
changeset
|
952 | * be good to audit this or change it to not wait. |
|
fd8984ce4fda
[gaim-migrate @ 17680]
Mark Doliner <markdoliner@pidgin.im>
parents:
14863
diff
changeset
|
953 | */ |
| 8931 | 954 | gtk_widget_set_sensitive(menuitem, |
|
12836
837fe5d43dac
[gaim-migrate @ 15184]
Richard Laager <rlaager@pidgin.im>
parents:
12833
diff
changeset
|
955 | (imhtml->editable && |
|
837fe5d43dac
[gaim-migrate @ 15184]
Richard Laager <rlaager@pidgin.im>
parents:
12833
diff
changeset
|
956 | gtk_clipboard_wait_is_text_available( |
|
837fe5d43dac
[gaim-migrate @ 15184]
Richard Laager <rlaager@pidgin.im>
parents:
12833
diff
changeset
|
957 | gtk_widget_get_clipboard(GTK_WIDGET(imhtml), GDK_SELECTION_CLIPBOARD)))); |
| 8931 | 958 | /* put it after "Paste" */ |
| 959 | gtk_menu_shell_insert(GTK_MENU_SHELL(menu), menuitem, 3); | |
| 960 | ||
| 961 | g_signal_connect(G_OBJECT(menuitem), "activate", | |
| 962 | G_CALLBACK(paste_unformatted_cb), imhtml); | |
| 13336 | 963 | |
|
13539
8036a635a316
[gaim-migrate @ 15915]
Richard Laager <rlaager@pidgin.im>
parents:
13340
diff
changeset
|
964 | menuitem = gtk_menu_item_new_with_mnemonic(_("_Reset formatting")); |
| 13336 | 965 | gtk_widget_show(menuitem); |
|
13340
e18166659513
[gaim-migrate @ 15709]
Richard Laager <rlaager@pidgin.im>
parents:
13336
diff
changeset
|
966 | gtk_widget_set_sensitive(menuitem, imhtml->editable); |
| 13336 | 967 | /* put it after Delete */ |
| 968 | gtk_menu_shell_insert(GTK_MENU_SHELL(menu), menuitem, 5); | |
| 969 | ||
| 970 | g_signal_connect(G_OBJECT(menuitem), "activate", G_CALLBACK(clear_formatting_cb), imhtml); | |
|
22970
87aef86d20c5
Allow replacing smileys with texts in conversations/logs. This should be
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22865
diff
changeset
|
971 | |
|
87aef86d20c5
Allow replacing smileys with texts in conversations/logs. This should be
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22865
diff
changeset
|
972 | menuitem = gtk_menu_item_new_with_mnemonic(_("Disable _smileys in selected text")); |
|
87aef86d20c5
Allow replacing smileys with texts in conversations/logs. This should be
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22865
diff
changeset
|
973 | gtk_widget_show(menuitem); |
|
87aef86d20c5
Allow replacing smileys with texts in conversations/logs. This should be
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22865
diff
changeset
|
974 | if (gtk_text_buffer_get_selection_bounds(imhtml->text_buffer, &start, &end)) { |
|
87aef86d20c5
Allow replacing smileys with texts in conversations/logs. This should be
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22865
diff
changeset
|
975 | g_signal_connect(G_OBJECT(menuitem), "activate", G_CALLBACK(disable_smiley_selected), imhtml); |
|
87aef86d20c5
Allow replacing smileys with texts in conversations/logs. This should be
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22865
diff
changeset
|
976 | } else { |
|
87aef86d20c5
Allow replacing smileys with texts in conversations/logs. This should be
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22865
diff
changeset
|
977 | gtk_widget_set_sensitive(menuitem, FALSE); |
|
87aef86d20c5
Allow replacing smileys with texts in conversations/logs. This should be
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22865
diff
changeset
|
978 | } |
|
87aef86d20c5
Allow replacing smileys with texts in conversations/logs. This should be
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22865
diff
changeset
|
979 | gtk_menu_shell_insert(GTK_MENU_SHELL(menu), menuitem, 6); |
| 8931 | 980 | } |
| 981 | ||
|
11572
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
982 | static char * |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
983 | ucs2_order(gboolean swap) |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
984 | { |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
985 | gboolean be; |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
986 | |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
987 | be = G_BYTE_ORDER == G_BIG_ENDIAN; |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
988 | be = swap ? be : !be; |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
989 | |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
990 | if (be) |
|
22596
0854ae660ef4
Further changes to use UTF-16 instead of UCS-2. Also, fix #5167 by making sure that the encoding conversion worked before using the result.
Daniel Atallah <datallah@pidgin.im>
parents:
22595
diff
changeset
|
991 | return "UTF-16BE"; |
|
11572
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
992 | else |
|
22596
0854ae660ef4
Further changes to use UTF-16 instead of UCS-2. Also, fix #5167 by making sure that the encoding conversion worked before using the result.
Daniel Atallah <datallah@pidgin.im>
parents:
22595
diff
changeset
|
993 | return "UTF-16LE"; |
|
11572
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
994 | |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
995 | } |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
996 | |
|
22596
0854ae660ef4
Further changes to use UTF-16 instead of UCS-2. Also, fix #5167 by making sure that the encoding conversion worked before using the result.
Daniel Atallah <datallah@pidgin.im>
parents:
22595
diff
changeset
|
997 | /* Convert from UTF-16LE to UTF-8, stripping the BOM if one is present.*/ |
|
11572
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
998 | static gchar * |
|
22596
0854ae660ef4
Further changes to use UTF-16 instead of UCS-2. Also, fix #5167 by making sure that the encoding conversion worked before using the result.
Daniel Atallah <datallah@pidgin.im>
parents:
22595
diff
changeset
|
999 | utf16_to_utf8_with_bom_check(gchar *data, guint len) { |
|
11572
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
1000 | char *fromcode = NULL; |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
1001 | GError *error = NULL; |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
1002 | guint16 c; |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
1003 | gchar *utf8_ret; |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
1004 | |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
1005 | /* |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
1006 | * Unicode Techinical Report 20 |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
1007 | * ( http://www.unicode.org/unicode/reports/tr20/ ) says to treat an |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
1008 | * initial 0xfeff (ZWNBSP) as a byte order indicator so that is |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
1009 | * what we do. If there is no indicator assume it is in the default |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
1010 | * order |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
1011 | */ |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
1012 | |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
1013 | memcpy(&c, data, 2); |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
1014 | switch (c) { |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
1015 | case 0xfeff: |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
1016 | case 0xfffe: |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
1017 | fromcode = ucs2_order(c == 0xfeff); |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
1018 | data += 2; |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
1019 | len -= 2; |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
1020 | break; |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
1021 | default: |
|
22596
0854ae660ef4
Further changes to use UTF-16 instead of UCS-2. Also, fix #5167 by making sure that the encoding conversion worked before using the result.
Daniel Atallah <datallah@pidgin.im>
parents:
22595
diff
changeset
|
1022 | fromcode = "UTF-16"; |
|
11572
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
1023 | break; |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
1024 | } |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
1025 | |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
1026 | utf8_ret = g_convert(data, len, "UTF-8", fromcode, NULL, NULL, &error); |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
1027 | |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
1028 | if (error) { |
| 15884 | 1029 | purple_debug_warning("gtkimhtml", "g_convert error: %s\n", error->message); |
|
11572
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
1030 | g_error_free(error); |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
1031 | } |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
1032 | return utf8_ret; |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
1033 | } |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
1034 | |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
1035 | |
| 8061 | 1036 | static void gtk_imhtml_clipboard_get(GtkClipboard *clipboard, GtkSelectionData *selection_data, guint info, GtkIMHtml *imhtml) { |
|
15111
e427dd6f3b7e
[gaim-migrate @ 17833]
Daniel Atallah <datallah@pidgin.im>
parents:
15093
diff
changeset
|
1037 | char *text = NULL; |
|
17546
51b1c1e2c3fe
Maintain global poitners to the clipboard selection text, with the aim of
Sean Egan <seanegan@pidgin.im>
parents:
17406
diff
changeset
|
1038 | gboolean primary = (clipboard != clipboard_selection); |
| 8061 | 1039 | GtkTextIter start, end; |
|
21085
dff5e0bfb8f5
Don't assign ownership of the CLIPBOARD to the IMHtml - it doesn't really own the data and then we don't have problems of overwriting what others put in the clipboard. Fixes #3616.
Daniel Atallah <datallah@pidgin.im>
parents:
21076
diff
changeset
|
1040 | |
|
dff5e0bfb8f5
Don't assign ownership of the CLIPBOARD to the IMHtml - it doesn't really own the data and then we don't have problems of overwriting what others put in the clipboard. Fixes #3616.
Daniel Atallah <datallah@pidgin.im>
parents:
21076
diff
changeset
|
1041 | if (primary) { |
|
dff5e0bfb8f5
Don't assign ownership of the CLIPBOARD to the IMHtml - it doesn't really own the data and then we don't have problems of overwriting what others put in the clipboard. Fixes #3616.
Daniel Atallah <datallah@pidgin.im>
parents:
21076
diff
changeset
|
1042 | GtkTextMark *sel = NULL, *ins = NULL; |
|
21643
4d1a61e30199
There appears to be a new GTK+ bug that causes the clipboard_clear callback to be triggered *after* the clipboard_copy callback on the second copy attempt. This makes stuff still work correctly when this happens (and, most importantly, not crash). I'll report this upstream.
Daniel Atallah <datallah@pidgin.im>
parents:
21574
diff
changeset
|
1043 | |
|
4d1a61e30199
There appears to be a new GTK+ bug that causes the clipboard_clear callback to be triggered *after* the clipboard_copy callback on the second copy attempt. This makes stuff still work correctly when this happens (and, most importantly, not crash). I'll report this upstream.
Daniel Atallah <datallah@pidgin.im>
parents:
21574
diff
changeset
|
1044 | g_return_if_fail(imhtml != NULL); |
|
4d1a61e30199
There appears to be a new GTK+ bug that causes the clipboard_clear callback to be triggered *after* the clipboard_copy callback on the second copy attempt. This makes stuff still work correctly when this happens (and, most importantly, not crash). I'll report this upstream.
Daniel Atallah <datallah@pidgin.im>
parents:
21574
diff
changeset
|
1045 | |
|
17546
51b1c1e2c3fe
Maintain global poitners to the clipboard selection text, with the aim of
Sean Egan <seanegan@pidgin.im>
parents:
17406
diff
changeset
|
1046 | ins = gtk_text_buffer_get_insert(imhtml->text_buffer); |
|
51b1c1e2c3fe
Maintain global poitners to the clipboard selection text, with the aim of
Sean Egan <seanegan@pidgin.im>
parents:
17406
diff
changeset
|
1047 | sel = gtk_text_buffer_get_selection_bound(imhtml->text_buffer); |
|
51b1c1e2c3fe
Maintain global poitners to the clipboard selection text, with the aim of
Sean Egan <seanegan@pidgin.im>
parents:
17406
diff
changeset
|
1048 | gtk_text_buffer_get_iter_at_mark(imhtml->text_buffer, &start, sel); |
|
51b1c1e2c3fe
Maintain global poitners to the clipboard selection text, with the aim of
Sean Egan <seanegan@pidgin.im>
parents:
17406
diff
changeset
|
1049 | gtk_text_buffer_get_iter_at_mark(imhtml->text_buffer, &end, ins); |
|
51b1c1e2c3fe
Maintain global poitners to the clipboard selection text, with the aim of
Sean Egan <seanegan@pidgin.im>
parents:
17406
diff
changeset
|
1050 | } |
| 8061 | 1051 | |
| 1052 | if (info == TARGET_HTML) { | |
|
15111
e427dd6f3b7e
[gaim-migrate @ 17833]
Daniel Atallah <datallah@pidgin.im>
parents:
15093
diff
changeset
|
1053 | char *selection; |
|
e427dd6f3b7e
[gaim-migrate @ 17833]
Daniel Atallah <datallah@pidgin.im>
parents:
15093
diff
changeset
|
1054 | #ifndef _WIN32 |
| 8907 | 1055 | gsize len; |
| 8681 | 1056 | if (primary) { |
| 1057 | text = gtk_imhtml_get_markup_range(imhtml, &start, &end); | |
| 10013 | 1058 | } else |
|
17546
51b1c1e2c3fe
Maintain global poitners to the clipboard selection text, with the aim of
Sean Egan <seanegan@pidgin.im>
parents:
17406
diff
changeset
|
1059 | text = html_clipboard; |
| 8061 | 1060 | |
| 1061 | /* Mozilla asks that we start our text/html with the Unicode byte order mark */ | |
|
23201
a9efe9add251
*** Plucked rev da43d671 (sadrul@pidgin.im):
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23187
diff
changeset
|
1062 | selection = g_convert(text, -1, "UTF-16", "UTF-8", NULL, &len, NULL); |
|
11143
f606fb334190
[gaim-migrate @ 13207]
Mark Doliner <markdoliner@pidgin.im>
parents:
11069
diff
changeset
|
1063 | gtk_selection_data_set(selection_data, gdk_atom_intern("text/html", FALSE), 16, (const guchar *)selection, len); |
|
15111
e427dd6f3b7e
[gaim-migrate @ 17833]
Daniel Atallah <datallah@pidgin.im>
parents:
15093
diff
changeset
|
1064 | #else |
|
18665
157820042a6f
Fix #1727 and also plug a possible leak and make a little efficiency improvement to the win32 clipboard handling.
Daniel Atallah <datallah@pidgin.im>
parents:
18633
diff
changeset
|
1065 | selection = clipboard_html_to_win32(html_clipboard); |
|
15111
e427dd6f3b7e
[gaim-migrate @ 17833]
Daniel Atallah <datallah@pidgin.im>
parents:
15093
diff
changeset
|
1066 | gtk_selection_data_set(selection_data, gdk_atom_intern("HTML Format", FALSE), 8, (const guchar *)selection, strlen(selection)); |
|
e427dd6f3b7e
[gaim-migrate @ 17833]
Daniel Atallah <datallah@pidgin.im>
parents:
15093
diff
changeset
|
1067 | #endif |
| 8061 | 1068 | g_free(selection); |
| 1069 | } else { | |
| 8681 | 1070 | if (primary) { |
| 1071 | text = gtk_imhtml_get_text(imhtml, &start, &end); | |
| 1072 | } else | |
|
17546
51b1c1e2c3fe
Maintain global poitners to the clipboard selection text, with the aim of
Sean Egan <seanegan@pidgin.im>
parents:
17406
diff
changeset
|
1073 | text = text_clipboard; |
| 8061 | 1074 | gtk_selection_data_set_text(selection_data, text, strlen(text)); |
| 1075 | } | |
| 8681 | 1076 | if (primary) /* This was allocated here */ |
| 1077 | g_free(text); | |
| 1078 | } | |
| 8061 | 1079 | |
| 1080 | static void gtk_imhtml_primary_clipboard_clear(GtkClipboard *clipboard, GtkIMHtml *imhtml) | |
| 7749 | 1081 | { |
| 8061 | 1082 | GtkTextIter insert; |
| 1083 | GtkTextIter selection_bound; | |
| 1084 | ||
| 1085 | gtk_text_buffer_get_iter_at_mark (imhtml->text_buffer, &insert, | |
| 1086 | gtk_text_buffer_get_mark (imhtml->text_buffer, "insert")); | |
| 1087 | gtk_text_buffer_get_iter_at_mark (imhtml->text_buffer, &selection_bound, | |
| 1088 | gtk_text_buffer_get_mark (imhtml->text_buffer, "selection_bound")); | |
| 1089 | ||
| 1090 | if (!gtk_text_iter_equal (&insert, &selection_bound)) | |
| 1091 | gtk_text_buffer_move_mark (imhtml->text_buffer, | |
| 1092 | gtk_text_buffer_get_mark (imhtml->text_buffer, "selection_bound"), | |
| 1093 | &insert); | |
| 7749 | 1094 | } |
| 7742 | 1095 | |
|
17546
51b1c1e2c3fe
Maintain global poitners to the clipboard selection text, with the aim of
Sean Egan <seanegan@pidgin.im>
parents:
17406
diff
changeset
|
1096 | static void gtk_imhtml_clipboard_clear (GtkClipboard *clipboard, GtkSelectionData *sel_data, |
|
51b1c1e2c3fe
Maintain global poitners to the clipboard selection text, with the aim of
Sean Egan <seanegan@pidgin.im>
parents:
17406
diff
changeset
|
1097 | guint info, gpointer user_data_or_owner) |
|
51b1c1e2c3fe
Maintain global poitners to the clipboard selection text, with the aim of
Sean Egan <seanegan@pidgin.im>
parents:
17406
diff
changeset
|
1098 | { |
|
51b1c1e2c3fe
Maintain global poitners to the clipboard selection text, with the aim of
Sean Egan <seanegan@pidgin.im>
parents:
17406
diff
changeset
|
1099 | } |
|
51b1c1e2c3fe
Maintain global poitners to the clipboard selection text, with the aim of
Sean Egan <seanegan@pidgin.im>
parents:
17406
diff
changeset
|
1100 | |
| 8677 | 1101 | static void copy_clipboard_cb(GtkIMHtml *imhtml, gpointer unused) |
| 7749 | 1102 | { |
| 8681 | 1103 | GtkTextIter start, end; |
|
17288
ffda972c2fb4
Ignore copy/cut requests when there is no selection instead of clearing the clipboard. This is consistent with the rest of how GTK+ works. Fixes #1030
Daniel Atallah <datallah@pidgin.im>
parents:
17189
diff
changeset
|
1104 | if (gtk_text_buffer_get_selection_bounds(imhtml->text_buffer, &start, &end)) { |
|
17546
51b1c1e2c3fe
Maintain global poitners to the clipboard selection text, with the aim of
Sean Egan <seanegan@pidgin.im>
parents:
17406
diff
changeset
|
1105 | if (!clipboard_selection) |
|
51b1c1e2c3fe
Maintain global poitners to the clipboard selection text, with the aim of
Sean Egan <seanegan@pidgin.im>
parents:
17406
diff
changeset
|
1106 | clipboard_selection = gtk_widget_get_clipboard(GTK_WIDGET(imhtml), GDK_SELECTION_CLIPBOARD); |
|
21085
dff5e0bfb8f5
Don't assign ownership of the CLIPBOARD to the IMHtml - it doesn't really own the data and then we don't have problems of overwriting what others put in the clipboard. Fixes #3616.
Daniel Atallah <datallah@pidgin.im>
parents:
21076
diff
changeset
|
1107 | gtk_clipboard_set_with_data(clipboard_selection, |
|
17288
ffda972c2fb4
Ignore copy/cut requests when there is no selection instead of clearing the clipboard. This is consistent with the rest of how GTK+ works. Fixes #1030
Daniel Atallah <datallah@pidgin.im>
parents:
17189
diff
changeset
|
1108 | selection_targets, sizeof(selection_targets) / sizeof(GtkTargetEntry), |
|
ffda972c2fb4
Ignore copy/cut requests when there is no selection instead of clearing the clipboard. This is consistent with the rest of how GTK+ works. Fixes #1030
Daniel Atallah <datallah@pidgin.im>
parents:
17189
diff
changeset
|
1109 | (GtkClipboardGetFunc)gtk_imhtml_clipboard_get, |
|
21085
dff5e0bfb8f5
Don't assign ownership of the CLIPBOARD to the IMHtml - it doesn't really own the data and then we don't have problems of overwriting what others put in the clipboard. Fixes #3616.
Daniel Atallah <datallah@pidgin.im>
parents:
21076
diff
changeset
|
1110 | (GtkClipboardClearFunc)gtk_imhtml_clipboard_clear, NULL); |
|
17288
ffda972c2fb4
Ignore copy/cut requests when there is no selection instead of clearing the clipboard. This is consistent with the rest of how GTK+ works. Fixes #1030
Daniel Atallah <datallah@pidgin.im>
parents:
17189
diff
changeset
|
1111 | |
|
18665
157820042a6f
Fix #1727 and also plug a possible leak and make a little efficiency improvement to the win32 clipboard handling.
Daniel Atallah <datallah@pidgin.im>
parents:
18633
diff
changeset
|
1112 | g_free(html_clipboard); |
|
157820042a6f
Fix #1727 and also plug a possible leak and make a little efficiency improvement to the win32 clipboard handling.
Daniel Atallah <datallah@pidgin.im>
parents:
18633
diff
changeset
|
1113 | g_free(text_clipboard); |
|
17288
ffda972c2fb4
Ignore copy/cut requests when there is no selection instead of clearing the clipboard. This is consistent with the rest of how GTK+ works. Fixes #1030
Daniel Atallah <datallah@pidgin.im>
parents:
17189
diff
changeset
|
1114 | |
|
21085
dff5e0bfb8f5
Don't assign ownership of the CLIPBOARD to the IMHtml - it doesn't really own the data and then we don't have problems of overwriting what others put in the clipboard. Fixes #3616.
Daniel Atallah <datallah@pidgin.im>
parents:
21076
diff
changeset
|
1115 | html_clipboard = gtk_imhtml_get_markup_range(imhtml, &start, &end); |
|
dff5e0bfb8f5
Don't assign ownership of the CLIPBOARD to the IMHtml - it doesn't really own the data and then we don't have problems of overwriting what others put in the clipboard. Fixes #3616.
Daniel Atallah <datallah@pidgin.im>
parents:
21076
diff
changeset
|
1116 | text_clipboard = gtk_imhtml_get_text(imhtml, &start, &end); |
| 8681 | 1117 | } |
| 1118 | ||
| 8061 | 1119 | g_signal_stop_emission_by_name(imhtml, "copy-clipboard"); |
| 1120 | } | |
| 1121 | ||
| 8698 | 1122 | static void cut_clipboard_cb(GtkIMHtml *imhtml, gpointer unused) |
| 1123 | { | |
| 1124 | GtkTextIter start, end; | |
|
17288
ffda972c2fb4
Ignore copy/cut requests when there is no selection instead of clearing the clipboard. This is consistent with the rest of how GTK+ works. Fixes #1030
Daniel Atallah <datallah@pidgin.im>
parents:
17189
diff
changeset
|
1125 | if (gtk_text_buffer_get_selection_bounds(imhtml->text_buffer, &start, &end)) { |
|
17546
51b1c1e2c3fe
Maintain global poitners to the clipboard selection text, with the aim of
Sean Egan <seanegan@pidgin.im>
parents:
17406
diff
changeset
|
1126 | if (!clipboard_selection) |
|
51b1c1e2c3fe
Maintain global poitners to the clipboard selection text, with the aim of
Sean Egan <seanegan@pidgin.im>
parents:
17406
diff
changeset
|
1127 | clipboard_selection = gtk_widget_get_clipboard(GTK_WIDGET(imhtml), GDK_SELECTION_CLIPBOARD); |
|
21085
dff5e0bfb8f5
Don't assign ownership of the CLIPBOARD to the IMHtml - it doesn't really own the data and then we don't have problems of overwriting what others put in the clipboard. Fixes #3616.
Daniel Atallah <datallah@pidgin.im>
parents:
21076
diff
changeset
|
1128 | gtk_clipboard_set_with_data(clipboard_selection, |
|
17288
ffda972c2fb4
Ignore copy/cut requests when there is no selection instead of clearing the clipboard. This is consistent with the rest of how GTK+ works. Fixes #1030
Daniel Atallah <datallah@pidgin.im>
parents:
17189
diff
changeset
|
1129 | selection_targets, sizeof(selection_targets) / sizeof(GtkTargetEntry), |
|
ffda972c2fb4
Ignore copy/cut requests when there is no selection instead of clearing the clipboard. This is consistent with the rest of how GTK+ works. Fixes #1030
Daniel Atallah <datallah@pidgin.im>
parents:
17189
diff
changeset
|
1130 | (GtkClipboardGetFunc)gtk_imhtml_clipboard_get, |
|
21085
dff5e0bfb8f5
Don't assign ownership of the CLIPBOARD to the IMHtml - it doesn't really own the data and then we don't have problems of overwriting what others put in the clipboard. Fixes #3616.
Daniel Atallah <datallah@pidgin.im>
parents:
21076
diff
changeset
|
1131 | (GtkClipboardClearFunc)gtk_imhtml_clipboard_clear, NULL); |
|
17288
ffda972c2fb4
Ignore copy/cut requests when there is no selection instead of clearing the clipboard. This is consistent with the rest of how GTK+ works. Fixes #1030
Daniel Atallah <datallah@pidgin.im>
parents:
17189
diff
changeset
|
1132 | |
|
18665
157820042a6f
Fix #1727 and also plug a possible leak and make a little efficiency improvement to the win32 clipboard handling.
Daniel Atallah <datallah@pidgin.im>
parents:
18633
diff
changeset
|
1133 | g_free(html_clipboard); |
|
157820042a6f
Fix #1727 and also plug a possible leak and make a little efficiency improvement to the win32 clipboard handling.
Daniel Atallah <datallah@pidgin.im>
parents:
18633
diff
changeset
|
1134 | g_free(text_clipboard); |
|
17288
ffda972c2fb4
Ignore copy/cut requests when there is no selection instead of clearing the clipboard. This is consistent with the rest of how GTK+ works. Fixes #1030
Daniel Atallah <datallah@pidgin.im>
parents:
17189
diff
changeset
|
1135 | |
|
21085
dff5e0bfb8f5
Don't assign ownership of the CLIPBOARD to the IMHtml - it doesn't really own the data and then we don't have problems of overwriting what others put in the clipboard. Fixes #3616.
Daniel Atallah <datallah@pidgin.im>
parents:
21076
diff
changeset
|
1136 | html_clipboard = gtk_imhtml_get_markup_range(imhtml, &start, &end); |
|
dff5e0bfb8f5
Don't assign ownership of the CLIPBOARD to the IMHtml - it doesn't really own the data and then we don't have problems of overwriting what others put in the clipboard. Fixes #3616.
Daniel Atallah <datallah@pidgin.im>
parents:
21076
diff
changeset
|
1137 | text_clipboard = gtk_imhtml_get_text(imhtml, &start, &end); |
|
17546
51b1c1e2c3fe
Maintain global poitners to the clipboard selection text, with the aim of
Sean Egan <seanegan@pidgin.im>
parents:
17406
diff
changeset
|
1138 | |
|
17288
ffda972c2fb4
Ignore copy/cut requests when there is no selection instead of clearing the clipboard. This is consistent with the rest of how GTK+ works. Fixes #1030
Daniel Atallah <datallah@pidgin.im>
parents:
17189
diff
changeset
|
1139 | if (imhtml->editable) |
|
ffda972c2fb4
Ignore copy/cut requests when there is no selection instead of clearing the clipboard. This is consistent with the rest of how GTK+ works. Fixes #1030
Daniel Atallah <datallah@pidgin.im>
parents:
17189
diff
changeset
|
1140 | gtk_text_buffer_delete_selection(imhtml->text_buffer, FALSE, FALSE); |
| 8698 | 1141 | } |
| 1142 | ||
| 1143 | g_signal_stop_emission_by_name(imhtml, "cut-clipboard"); | |
| 1144 | } | |
| 1145 | ||
| 8931 | 1146 | static void imhtml_paste_insert(GtkIMHtml *imhtml, const char *text, gboolean plaintext) |
| 1147 | { | |
| 1148 | GtkTextIter iter; | |
|
22003
904ebe8d6058
Patch from 'goutnet' to not insert smileys when pasting as plain text.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21765
diff
changeset
|
1149 | GtkIMHtmlOptions flags = plaintext ? GTK_IMHTML_NO_SMILEY : (GTK_IMHTML_NO_NEWLINE | GTK_IMHTML_NO_COMMENTS); |
| 8931 | 1150 | |
|
25899
da25a7ed382e
The first thing gtk_text_buffer_delete_selection does is call
Mark Doliner <markdoliner@pidgin.im>
parents:
25888
diff
changeset
|
1151 | /* Delete any currently selected text */ |
|
da25a7ed382e
The first thing gtk_text_buffer_delete_selection does is call
Mark Doliner <markdoliner@pidgin.im>
parents:
25888
diff
changeset
|
1152 | gtk_text_buffer_delete_selection(imhtml->text_buffer, TRUE, TRUE); |
| 9028 | 1153 | |
| 8931 | 1154 | gtk_text_buffer_get_iter_at_mark(imhtml->text_buffer, &iter, gtk_text_buffer_get_insert(imhtml->text_buffer)); |
| 1155 | if (!imhtml->wbfo && !plaintext) | |
| 1156 | gtk_imhtml_close_tags(imhtml, &iter); | |
| 1157 | ||
| 1158 | gtk_imhtml_insert_html_at_iter(imhtml, text, flags, &iter); | |
|
11267
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
1159 | gtk_text_buffer_move_mark_by_name(imhtml->text_buffer, "insert", &iter); |
| 8931 | 1160 | gtk_text_view_scroll_to_mark(GTK_TEXT_VIEW(imhtml), gtk_text_buffer_get_insert(imhtml->text_buffer), |
| 1161 | 0, FALSE, 0.0, 0.0); | |
|
18363
3e2a0ab4d6f8
Re-arrange a few lines in gtkimhtml's paste function so that we reset formatting after moving the cursor to the new location. Fixes #1198
Sean Egan <seanegan@pidgin.im>
parents:
18283
diff
changeset
|
1162 | if (!imhtml->wbfo && !plaintext) |
|
3e2a0ab4d6f8
Re-arrange a few lines in gtkimhtml's paste function so that we reset formatting after moving the cursor to the new location. Fixes #1198
Sean Egan <seanegan@pidgin.im>
parents:
18283
diff
changeset
|
1163 | gtk_imhtml_close_tags(imhtml, &iter); |
|
3e2a0ab4d6f8
Re-arrange a few lines in gtkimhtml's paste function so that we reset formatting after moving the cursor to the new location. Fixes #1198
Sean Egan <seanegan@pidgin.im>
parents:
18283
diff
changeset
|
1164 | |
| 8931 | 1165 | } |
| 1166 | ||
| 1167 | static void paste_plaintext_received_cb (GtkClipboard *clipboard, const gchar *text, gpointer data) | |
| 1168 | { | |
| 1169 | char *tmp; | |
| 1170 | ||
|
19332
06b251c98872
malloc(0) returns a null pointer. Fixes #2472.
Daniel Atallah <datallah@pidgin.im>
parents:
19103
diff
changeset
|
1171 | if (text == NULL || !(*text)) |
| 8931 | 1172 | return; |
| 1173 | ||
|
10732
5e314ab498bf
[gaim-migrate @ 12334]
Richard Laager <rlaager@pidgin.im>
parents:
10699
diff
changeset
|
1174 | tmp = g_markup_escape_text(text, -1); |
| 8931 | 1175 | imhtml_paste_insert(data, tmp, TRUE); |
| 1176 | g_free(tmp); | |
| 1177 | } | |
| 1178 | ||
| 8061 | 1179 | static void paste_received_cb (GtkClipboard *clipboard, GtkSelectionData *selection_data, gpointer data) |
| 1180 | { | |
| 1181 | char *text; | |
| 1182 | GtkIMHtml *imhtml = data; | |
| 7809 | 1183 | |
|
8123
e09c75f511c2
[gaim-migrate @ 8827]
Mark Doliner <markdoliner@pidgin.im>
parents:
8120
diff
changeset
|
1184 | if (!gtk_text_view_get_editable(GTK_TEXT_VIEW(imhtml))) |
|
8105
54ea897b764e
[gaim-migrate @ 8805]
Nathan Fredrickson <nathan@silverorange.com>
parents:
8091
diff
changeset
|
1185 | return; |
|
54ea897b764e
[gaim-migrate @ 8805]
Nathan Fredrickson <nathan@silverorange.com>
parents:
8091
diff
changeset
|
1186 | |
|
19332
06b251c98872
malloc(0) returns a null pointer. Fixes #2472.
Daniel Atallah <datallah@pidgin.im>
parents:
19103
diff
changeset
|
1187 | if (imhtml->wbfo || selection_data->length <= 0) { |
| 8931 | 1188 | gtk_clipboard_request_text(clipboard, paste_plaintext_received_cb, imhtml); |
| 1189 | return; | |
| 8061 | 1190 | } else { |
| 8719 | 1191 | #if 0 |
| 1192 | /* Here's some debug code, for figuring out what sent to us over the clipboard. */ | |
| 1193 | { | |
| 1194 | int i; | |
| 1195 | ||
| 15884 | 1196 | purple_debug_misc("gtkimhtml", "In paste_received_cb():\n\tformat = %d, length = %d\n\t", |
| 8719 | 1197 | selection_data->format, selection_data->length); |
| 1198 | ||
| 1199 | for (i = 0; i < (/*(selection_data->format / 8) **/ selection_data->length); i++) { | |
| 1200 | if ((i % 70) == 0) | |
| 1201 | printf("\n\t"); | |
| 1202 | if (selection_data->data[i] == '\0') | |
| 1203 | printf("."); | |
| 1204 | else | |
| 1205 | printf("%c", selection_data->data[i]); | |
| 1206 | } | |
| 1207 | printf("\n"); | |
| 1208 | } | |
| 1209 | #endif | |
| 1210 | text = g_malloc(selection_data->length); | |
| 1211 | memcpy(text, selection_data->data, selection_data->length); | |
| 7766 | 1212 | } |
| 8061 | 1213 | |
| 8869 | 1214 | if (selection_data->length >= 2 && |
| 1215 | (*(guint16 *)text == 0xfeff || *(guint16 *)text == 0xfffe)) { | |
|
22596
0854ae660ef4
Further changes to use UTF-16 instead of UCS-2. Also, fix #5167 by making sure that the encoding conversion worked before using the result.
Daniel Atallah <datallah@pidgin.im>
parents:
22595
diff
changeset
|
1216 | /* This is UTF-16 */ |
|
0854ae660ef4
Further changes to use UTF-16 instead of UCS-2. Also, fix #5167 by making sure that the encoding conversion worked before using the result.
Daniel Atallah <datallah@pidgin.im>
parents:
22595
diff
changeset
|
1217 | char *utf8 = utf16_to_utf8_with_bom_check(text, selection_data->length); |
| 8061 | 1218 | g_free(text); |
| 1219 | text = utf8; | |
| 8698 | 1220 | if (!text) { |
|
22596
0854ae660ef4
Further changes to use UTF-16 instead of UCS-2. Also, fix #5167 by making sure that the encoding conversion worked before using the result.
Daniel Atallah <datallah@pidgin.im>
parents:
22595
diff
changeset
|
1221 | purple_debug_warning("gtkimhtml", "g_convert from UTF-16 failed in paste_received_cb\n"); |
| 8698 | 1222 | return; |
| 1223 | } | |
| 8061 | 1224 | } |
|
11572
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
1225 | |
| 8698 | 1226 | if (!(*text) || !g_utf8_validate(text, -1, NULL)) { |
| 15884 | 1227 | purple_debug_warning("gtkimhtml", "empty string or invalid UTF-8 in paste_received_cb\n"); |
| 8698 | 1228 | g_free(text); |
| 1229 | return; | |
| 1230 | } | |
| 1231 | ||
| 8931 | 1232 | imhtml_paste_insert(imhtml, text, FALSE); |
| 8681 | 1233 | g_free(text); |
| 8061 | 1234 | } |
| 1235 | ||
|
21765
b9271e416f6d
Patch from 'goutnet': Pressing backspace on a smiley will replace the smiley
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21644
diff
changeset
|
1236 | |
|
b9271e416f6d
Patch from 'goutnet': Pressing backspace on a smiley will replace the smiley
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21644
diff
changeset
|
1237 | static void smart_backspace_cb(GtkIMHtml *imhtml, gpointer blah) |
|
b9271e416f6d
Patch from 'goutnet': Pressing backspace on a smiley will replace the smiley
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21644
diff
changeset
|
1238 | { |
|
b9271e416f6d
Patch from 'goutnet': Pressing backspace on a smiley will replace the smiley
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21644
diff
changeset
|
1239 | GtkTextIter iter; |
|
b9271e416f6d
Patch from 'goutnet': Pressing backspace on a smiley will replace the smiley
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21644
diff
changeset
|
1240 | GtkTextChildAnchor* anchor; |
|
b9271e416f6d
Patch from 'goutnet': Pressing backspace on a smiley will replace the smiley
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21644
diff
changeset
|
1241 | char * text; |
|
b9271e416f6d
Patch from 'goutnet': Pressing backspace on a smiley will replace the smiley
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21644
diff
changeset
|
1242 | gint offset; |
|
b9271e416f6d
Patch from 'goutnet': Pressing backspace on a smiley will replace the smiley
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21644
diff
changeset
|
1243 | |
|
b9271e416f6d
Patch from 'goutnet': Pressing backspace on a smiley will replace the smiley
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21644
diff
changeset
|
1244 | if (!imhtml->editable) |
|
b9271e416f6d
Patch from 'goutnet': Pressing backspace on a smiley will replace the smiley
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21644
diff
changeset
|
1245 | return; |
|
b9271e416f6d
Patch from 'goutnet': Pressing backspace on a smiley will replace the smiley
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21644
diff
changeset
|
1246 | |
|
b9271e416f6d
Patch from 'goutnet': Pressing backspace on a smiley will replace the smiley
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21644
diff
changeset
|
1247 | gtk_text_buffer_get_iter_at_mark(imhtml->text_buffer, &iter, gtk_text_buffer_get_insert(imhtml->text_buffer)); |
|
b9271e416f6d
Patch from 'goutnet': Pressing backspace on a smiley will replace the smiley
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21644
diff
changeset
|
1248 | |
|
b9271e416f6d
Patch from 'goutnet': Pressing backspace on a smiley will replace the smiley
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21644
diff
changeset
|
1249 | /* Get the character before the insertion point */ |
|
b9271e416f6d
Patch from 'goutnet': Pressing backspace on a smiley will replace the smiley
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21644
diff
changeset
|
1250 | offset = gtk_text_iter_get_offset(&iter); |
|
b9271e416f6d
Patch from 'goutnet': Pressing backspace on a smiley will replace the smiley
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21644
diff
changeset
|
1251 | if (offset <= 0) |
|
b9271e416f6d
Patch from 'goutnet': Pressing backspace on a smiley will replace the smiley
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21644
diff
changeset
|
1252 | return; |
|
b9271e416f6d
Patch from 'goutnet': Pressing backspace on a smiley will replace the smiley
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21644
diff
changeset
|
1253 | |
|
b9271e416f6d
Patch from 'goutnet': Pressing backspace on a smiley will replace the smiley
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21644
diff
changeset
|
1254 | gtk_text_iter_backward_char(&iter); |
|
b9271e416f6d
Patch from 'goutnet': Pressing backspace on a smiley will replace the smiley
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21644
diff
changeset
|
1255 | anchor = gtk_text_iter_get_child_anchor(&iter); |
|
b9271e416f6d
Patch from 'goutnet': Pressing backspace on a smiley will replace the smiley
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21644
diff
changeset
|
1256 | |
|
b9271e416f6d
Patch from 'goutnet': Pressing backspace on a smiley will replace the smiley
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21644
diff
changeset
|
1257 | if (!anchor) |
|
b9271e416f6d
Patch from 'goutnet': Pressing backspace on a smiley will replace the smiley
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21644
diff
changeset
|
1258 | return; /* No smiley here */ |
|
b9271e416f6d
Patch from 'goutnet': Pressing backspace on a smiley will replace the smiley
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21644
diff
changeset
|
1259 | |
|
b9271e416f6d
Patch from 'goutnet': Pressing backspace on a smiley will replace the smiley
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21644
diff
changeset
|
1260 | text = g_object_get_data(G_OBJECT(anchor), "gtkimhtml_plaintext"); |
|
b9271e416f6d
Patch from 'goutnet': Pressing backspace on a smiley will replace the smiley
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21644
diff
changeset
|
1261 | if (!text) |
|
b9271e416f6d
Patch from 'goutnet': Pressing backspace on a smiley will replace the smiley
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21644
diff
changeset
|
1262 | return; |
|
b9271e416f6d
Patch from 'goutnet': Pressing backspace on a smiley will replace the smiley
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21644
diff
changeset
|
1263 | |
|
b9271e416f6d
Patch from 'goutnet': Pressing backspace on a smiley will replace the smiley
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21644
diff
changeset
|
1264 | /* ok, then we need to insert the image buffer text before the anchor */ |
|
b9271e416f6d
Patch from 'goutnet': Pressing backspace on a smiley will replace the smiley
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21644
diff
changeset
|
1265 | gtk_text_buffer_insert(imhtml->text_buffer, &iter, text, -1); |
|
b9271e416f6d
Patch from 'goutnet': Pressing backspace on a smiley will replace the smiley
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21644
diff
changeset
|
1266 | } |
|
b9271e416f6d
Patch from 'goutnet': Pressing backspace on a smiley will replace the smiley
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21644
diff
changeset
|
1267 | |
| 8061 | 1268 | static void paste_clipboard_cb(GtkIMHtml *imhtml, gpointer blah) |
| 1269 | { | |
| 8931 | 1270 | #ifdef _WIN32 |
| 1271 | /* If we're on windows, let's see if we can get data from the HTML Format | |
|
10901
5d81e32bd258
[gaim-migrate @ 12622]
Daniel Atallah <datallah@pidgin.im>
parents:
10900
diff
changeset
|
1272 | clipboard before we try to paste from the GTK buffer */ |
|
21985
bf0e936998e4
Move some curly braces around so static analysis tools can properly detect
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
21955
diff
changeset
|
1273 | if (!clipboard_paste_html_win32(imhtml)) |
| 8931 | 1274 | #endif |
|
21985
bf0e936998e4
Move some curly braces around so static analysis tools can properly detect
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
21955
diff
changeset
|
1275 | { |
| 8061 | 1276 | GtkClipboard *clipboard = gtk_widget_get_clipboard(GTK_WIDGET(imhtml), GDK_SELECTION_CLIPBOARD); |
| 1277 | gtk_clipboard_request_contents(clipboard, gdk_atom_intern("text/html", FALSE), | |
| 1278 | paste_received_cb, imhtml); | |
| 8931 | 1279 | } |
| 8061 | 1280 | g_signal_stop_emission_by_name(imhtml, "paste-clipboard"); |
| 7766 | 1281 | } |
| 1282 | ||
| 8677 | 1283 | static void imhtml_realized_remove_primary(GtkIMHtml *imhtml, gpointer unused) |
| 1284 | { | |
| 1285 | gtk_text_buffer_remove_selection_clipboard(GTK_IMHTML(imhtml)->text_buffer, | |
| 1286 | gtk_widget_get_clipboard(GTK_WIDGET(imhtml), GDK_SELECTION_PRIMARY)); | |
| 1287 | ||
| 1288 | } | |
| 1289 | ||
|
8740
098a43943bba
[gaim-migrate @ 9495]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
1290 | static void imhtml_destroy_add_primary(GtkIMHtml *imhtml, gpointer unused) |
|
098a43943bba
[gaim-migrate @ 9495]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
1291 | { |
|
098a43943bba
[gaim-migrate @ 9495]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
1292 | gtk_text_buffer_add_selection_clipboard(GTK_IMHTML(imhtml)->text_buffer, |
|
098a43943bba
[gaim-migrate @ 9495]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
1293 | gtk_widget_get_clipboard(GTK_WIDGET(imhtml), GDK_SELECTION_PRIMARY)); |
|
098a43943bba
[gaim-migrate @ 9495]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
1294 | } |
| 8677 | 1295 | |
| 1296 | static void mark_set_so_update_selection_cb(GtkTextBuffer *buffer, GtkTextIter *arg1, GtkTextMark *mark, GtkIMHtml *imhtml) | |
| 1297 | { | |
| 1298 | if (gtk_text_buffer_get_selection_bounds(buffer, NULL, NULL)) { | |
| 1299 | gtk_clipboard_set_with_owner(gtk_widget_get_clipboard(GTK_WIDGET(imhtml), GDK_SELECTION_PRIMARY), | |
| 1300 | selection_targets, sizeof(selection_targets) / sizeof(GtkTargetEntry), | |
| 1301 | (GtkClipboardGetFunc)gtk_imhtml_clipboard_get, | |
| 1302 | (GtkClipboardClearFunc)gtk_imhtml_primary_clipboard_clear, G_OBJECT(imhtml)); | |
| 1303 | } | |
| 1304 | } | |
| 1305 | ||
| 1306 | static gboolean gtk_imhtml_button_press_event(GtkIMHtml *imhtml, GdkEventButton *event, gpointer unused) | |
| 7346 | 1307 | { |
| 8677 | 1308 | if (event->button == 2) { |
| 1309 | int x, y; | |
| 1310 | GtkTextIter iter; | |
| 1311 | GtkClipboard *clipboard = gtk_widget_get_clipboard(GTK_WIDGET(imhtml), GDK_SELECTION_PRIMARY); | |
| 1312 | ||
| 1313 | if (!imhtml->editable) | |
| 1314 | return FALSE; | |
| 1315 | ||
| 1316 | gtk_text_view_window_to_buffer_coords(GTK_TEXT_VIEW(imhtml), | |
| 1317 | GTK_TEXT_WINDOW_TEXT, | |
| 1318 | event->x, | |
| 1319 | event->y, | |
| 1320 | &x, | |
| 1321 | &y); | |
| 1322 | gtk_text_view_get_iter_at_location(GTK_TEXT_VIEW(imhtml), &iter, x, y); | |
| 1323 | gtk_text_buffer_place_cursor(imhtml->text_buffer, &iter); | |
| 1324 | ||
| 1325 | gtk_clipboard_request_contents(clipboard, gdk_atom_intern("text/html", FALSE), | |
| 1326 | paste_received_cb, imhtml); | |
| 1327 | ||
| 1328 | return TRUE; | |
| 1329 | } | |
| 1330 | ||
| 7346 | 1331 | return FALSE; |
| 1332 | } | |
| 4263 | 1333 | |
|
17880
5e73968467e0
Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@pidgin.im>
parents:
17288
diff
changeset
|
1334 | static void |
|
22834
1394e7efb818
Smiley insertions can be undone with this fix. References #5577. But redo
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22810
diff
changeset
|
1335 | gtk_imhtml_undo(GtkIMHtml *imhtml) |
|
1394e7efb818
Smiley insertions can be undone with this fix. References #5577. But redo
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22810
diff
changeset
|
1336 | { |
|
17880
5e73968467e0
Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@pidgin.im>
parents:
17288
diff
changeset
|
1337 | g_return_if_fail(GTK_IS_IMHTML(imhtml)); |
|
22834
1394e7efb818
Smiley insertions can be undone with this fix. References #5577. But redo
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22810
diff
changeset
|
1338 | if (imhtml->editable && |
|
1394e7efb818
Smiley insertions can be undone with this fix. References #5577. But redo
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22810
diff
changeset
|
1339 | gtk_source_undo_manager_can_undo(imhtml->undo_manager)) |
|
21574
b27c242d1288
Fix #3930 by correctly detecting when we're no longer immediately following a br.
Daniel Atallah <datallah@pidgin.im>
parents:
21425
diff
changeset
|
1340 | gtk_source_undo_manager_undo(imhtml->undo_manager); |
|
17880
5e73968467e0
Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@pidgin.im>
parents:
17288
diff
changeset
|
1341 | } |
|
5e73968467e0
Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@pidgin.im>
parents:
17288
diff
changeset
|
1342 | |
|
5e73968467e0
Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@pidgin.im>
parents:
17288
diff
changeset
|
1343 | static void |
|
22834
1394e7efb818
Smiley insertions can be undone with this fix. References #5577. But redo
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22810
diff
changeset
|
1344 | gtk_imhtml_redo(GtkIMHtml *imhtml) |
|
1394e7efb818
Smiley insertions can be undone with this fix. References #5577. But redo
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22810
diff
changeset
|
1345 | { |
|
17880
5e73968467e0
Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@pidgin.im>
parents:
17288
diff
changeset
|
1346 | g_return_if_fail(GTK_IS_IMHTML(imhtml)); |
|
22834
1394e7efb818
Smiley insertions can be undone with this fix. References #5577. But redo
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22810
diff
changeset
|
1347 | if (imhtml->editable && |
|
1394e7efb818
Smiley insertions can be undone with this fix. References #5577. But redo
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22810
diff
changeset
|
1348 | gtk_source_undo_manager_can_redo(imhtml->undo_manager)) |
|
21574
b27c242d1288
Fix #3930 by correctly detecting when we're no longer immediately following a br.
Daniel Atallah <datallah@pidgin.im>
parents:
21425
diff
changeset
|
1349 | gtk_source_undo_manager_redo(imhtml->undo_manager); |
|
17880
5e73968467e0
Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@pidgin.im>
parents:
17288
diff
changeset
|
1350 | |
|
5e73968467e0
Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@pidgin.im>
parents:
17288
diff
changeset
|
1351 | } |
|
5e73968467e0
Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@pidgin.im>
parents:
17288
diff
changeset
|
1352 | |
| 10108 | 1353 | static gboolean imhtml_message_send(GtkIMHtml *imhtml) |
| 1354 | { | |
| 1355 | return FALSE; | |
| 1356 | } | |
| 1357 | ||
| 10100 | 1358 | static void imhtml_toggle_format(GtkIMHtml *imhtml, GtkIMHtmlButtons buttons) |
| 1359 | { | |
|
10699
7f9fa4f13758
[gaim-migrate @ 12256]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10695
diff
changeset
|
1360 | /* since this function is the handler for the formatting keystrokes, |
|
7f9fa4f13758
[gaim-migrate @ 12256]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10695
diff
changeset
|
1361 | we need to check here that the formatting attempted is permitted */ |
|
11275
cdcc651d7ecd
[gaim-migrate @ 13461]
Richard Laager <rlaager@pidgin.im>
parents:
11269
diff
changeset
|
1362 | buttons &= imhtml->format_functions; |
|
10699
7f9fa4f13758
[gaim-migrate @ 12256]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10695
diff
changeset
|
1363 | |
| 10100 | 1364 | switch (buttons) { |
| 1365 | case GTK_IMHTML_BOLD: | |
|
11267
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
1366 | imhtml_toggle_bold(imhtml); |
| 10100 | 1367 | break; |
| 1368 | case GTK_IMHTML_ITALIC: | |
|
11267
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
1369 | imhtml_toggle_italic(imhtml); |
| 10100 | 1370 | break; |
| 1371 | case GTK_IMHTML_UNDERLINE: | |
|
11267
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
1372 | imhtml_toggle_underline(imhtml); |
|
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
1373 | break; |
|
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
1374 | case GTK_IMHTML_STRIKE: |
|
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
1375 | imhtml_toggle_strike(imhtml); |
| 10100 | 1376 | break; |
| 1377 | case GTK_IMHTML_SHRINK: | |
|
11267
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
1378 | imhtml_font_shrink(imhtml); |
| 10100 | 1379 | break; |
| 1380 | case GTK_IMHTML_GROW: | |
|
11267
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
1381 | imhtml_font_grow(imhtml); |
| 10100 | 1382 | break; |
| 1383 | default: | |
| 1384 | break; | |
| 1385 | } | |
| 1386 | } | |
| 4032 | 1387 | |
| 1388 | static void | |
| 1389 | gtk_imhtml_finalize (GObject *object) | |
| 1390 | { | |
| 1391 | GtkIMHtml *imhtml = GTK_IMHTML(object); | |
| 4895 | 1392 | GList *scalables; |
| 8962 | 1393 | GSList *l; |
| 8061 | 1394 | |
| 10798 | 1395 | if (imhtml->scroll_src) |
| 1396 | g_source_remove(imhtml->scroll_src); | |
| 1397 | if (imhtml->scroll_time) | |
| 1398 | g_timer_destroy(imhtml->scroll_time); | |
| 1399 | ||
| 4138 | 1400 | g_hash_table_destroy(imhtml->smiley_data); |
| 4032 | 1401 | gtk_smiley_tree_destroy(imhtml->default_smilies); |
| 4138 | 1402 | gdk_cursor_unref(imhtml->hand_cursor); |
| 1403 | gdk_cursor_unref(imhtml->arrow_cursor); | |
| 8061 | 1404 | gdk_cursor_unref(imhtml->text_cursor); |
| 8677 | 1405 | |
| 4735 | 1406 | if(imhtml->tip_window){ |
| 1407 | gtk_widget_destroy(imhtml->tip_window); | |
| 1408 | } | |
| 1409 | if(imhtml->tip_timer) | |
|
26829
ac9a76ef6ef0
Replace gtk_timeout_remove with g_source_remove.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26828
diff
changeset
|
1410 | g_source_remove(imhtml->tip_timer); |
| 4735 | 1411 | |
| 4895 | 1412 | for(scalables = imhtml->scalables; scalables; scalables = scalables->next) { |
|
11224
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
1413 | struct scalable_data *sd = scalables->data; |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
1414 | GtkIMHtmlScalable *scale = GTK_IMHTML_SCALABLE(sd->scalable); |
| 4895 | 1415 | scale->free(scale); |
|
11224
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
1416 | g_free(sd); |
| 4895 | 1417 | } |
| 7991 | 1418 | |
| 8962 | 1419 | for (l = imhtml->im_images; l; l = l->next) { |
|
11224
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
1420 | struct im_image_data *img_data = l->data; |
| 8962 | 1421 | if (imhtml->funcs->image_unref) |
|
11224
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
1422 | imhtml->funcs->image_unref(img_data->id); |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
1423 | g_free(img_data); |
| 8962 | 1424 | } |
| 1425 | ||
| 4895 | 1426 | g_list_free(imhtml->scalables); |
| 8962 | 1427 | g_slist_free(imhtml->im_images); |
|
16385
aa5b9456e258
Fixes #213 This allows only 20 animated smileys to be animnating at a time
Sean Egan <seanegan@pidgin.im>
parents:
16291
diff
changeset
|
1428 | g_queue_free(imhtml->animations); |
|
14097
0c340861ab79
[gaim-migrate @ 16638]
Mark Doliner <markdoliner@pidgin.im>
parents:
14010
diff
changeset
|
1429 | g_free(imhtml->protocol_name); |
|
0c340861ab79
[gaim-migrate @ 16638]
Mark Doliner <markdoliner@pidgin.im>
parents:
14010
diff
changeset
|
1430 | g_free(imhtml->search_string); |
|
17880
5e73968467e0
Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@pidgin.im>
parents:
17288
diff
changeset
|
1431 | g_object_unref(imhtml->undo_manager); |
| 4032 | 1432 | G_OBJECT_CLASS(parent_class)->finalize (object); |
|
17546
51b1c1e2c3fe
Maintain global poitners to the clipboard selection text, with the aim of
Sean Egan <seanegan@pidgin.im>
parents:
17406
diff
changeset
|
1433 | |
| 4032 | 1434 | } |
| 1428 | 1435 | |
|
24674
36bf974a7d78
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24588
diff
changeset
|
1436 | static GtkIMHtmlProtocol * |
|
25013
956b2f650d31
Detect duplication registrations by substring.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
25011
diff
changeset
|
1437 | imhtml_find_protocol(const char *url, gboolean reverse) |
|
24674
36bf974a7d78
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24588
diff
changeset
|
1438 | { |
|
36bf974a7d78
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24588
diff
changeset
|
1439 | GtkIMHtmlClass *klass; |
|
36bf974a7d78
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24588
diff
changeset
|
1440 | GList *iter; |
|
36bf974a7d78
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24588
diff
changeset
|
1441 | GtkIMHtmlProtocol *proto = NULL; |
|
25013
956b2f650d31
Detect duplication registrations by substring.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
25011
diff
changeset
|
1442 | int length = reverse ? strlen(url) : -1; |
|
24674
36bf974a7d78
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24588
diff
changeset
|
1443 | |
|
36bf974a7d78
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24588
diff
changeset
|
1444 | klass = g_type_class_ref(GTK_TYPE_IMHTML); |
|
36bf974a7d78
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24588
diff
changeset
|
1445 | for (iter = klass->protocols; iter; iter = iter->next) { |
|
36bf974a7d78
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24588
diff
changeset
|
1446 | proto = iter->data; |
|
25013
956b2f650d31
Detect duplication registrations by substring.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
25011
diff
changeset
|
1447 | if (g_ascii_strncasecmp(url, proto->name, reverse ? MIN(length, proto->length) : proto->length) == 0) { |
|
24674
36bf974a7d78
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24588
diff
changeset
|
1448 | return proto; |
|
36bf974a7d78
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24588
diff
changeset
|
1449 | } |
|
36bf974a7d78
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24588
diff
changeset
|
1450 | } |
|
36bf974a7d78
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24588
diff
changeset
|
1451 | return NULL; |
|
36bf974a7d78
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24588
diff
changeset
|
1452 | } |
|
36bf974a7d78
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24588
diff
changeset
|
1453 | |
|
36bf974a7d78
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24588
diff
changeset
|
1454 | static void |
|
36bf974a7d78
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24588
diff
changeset
|
1455 | imhtml_url_clicked(GtkIMHtml *imhtml, const char *url) |
|
36bf974a7d78
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24588
diff
changeset
|
1456 | { |
|
25013
956b2f650d31
Detect duplication registrations by substring.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
25011
diff
changeset
|
1457 | GtkIMHtmlProtocol *proto = imhtml_find_protocol(url, FALSE); |
|
24698
f9dd7117ade0
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24675
diff
changeset
|
1458 | GtkIMHtmlLink *link; |
|
24674
36bf974a7d78
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24588
diff
changeset
|
1459 | if (!proto) |
|
36bf974a7d78
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24588
diff
changeset
|
1460 | return; |
|
24698
f9dd7117ade0
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24675
diff
changeset
|
1461 | link = g_new0(GtkIMHtmlLink, 1); |
|
f9dd7117ade0
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24675
diff
changeset
|
1462 | link->imhtml = g_object_ref(imhtml); |
|
f9dd7117ade0
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24675
diff
changeset
|
1463 | link->url = g_strdup(url); |
|
f9dd7117ade0
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24675
diff
changeset
|
1464 | proto->activate(imhtml, link); /* XXX: Do something with the return value? */ |
|
f9dd7117ade0
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24675
diff
changeset
|
1465 | gtk_imhtml_link_destroy(link); |
|
24674
36bf974a7d78
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24588
diff
changeset
|
1466 | } |
|
36bf974a7d78
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24588
diff
changeset
|
1467 | |
|
10814
7e17cb56b019
[gaim-migrate @ 12468]
Luke Schierer <lschiere@pidgin.im>
parents:
10799
diff
changeset
|
1468 | /* Boring GTK+ stuff */ |
| 8519 | 1469 | static void gtk_imhtml_class_init (GtkIMHtmlClass *klass) |
| 1428 | 1470 | { |
| 9007 | 1471 | GtkWidgetClass *widget_class = (GtkWidgetClass *) klass; |
| 3922 | 1472 | GtkObjectClass *object_class; |
| 10100 | 1473 | GtkBindingSet *binding_set; |
| 4032 | 1474 | GObjectClass *gobject_class; |
| 8519 | 1475 | object_class = (GtkObjectClass*) klass; |
| 1476 | gobject_class = (GObjectClass*) klass; | |
|
26828
ca76e7ad0d4b
Oops, I must have been tired. I only replaced the first occurrence of these
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
26727
diff
changeset
|
1477 | parent_class = g_type_class_ref(GTK_TYPE_TEXT_VIEW); |
| 4417 | 1478 | signals[URL_CLICKED] = g_signal_new("url_clicked", |
| 1479 | G_TYPE_FROM_CLASS(gobject_class), | |
| 1480 | G_SIGNAL_RUN_FIRST, | |
| 1481 | G_STRUCT_OFFSET(GtkIMHtmlClass, url_clicked), | |
| 1482 | NULL, | |
| 1483 | 0, | |
| 1484 | g_cclosure_marshal_VOID__POINTER, | |
| 1485 | G_TYPE_NONE, 1, | |
| 1486 | G_TYPE_POINTER); | |
| 8506 | 1487 | signals[BUTTONS_UPDATE] = g_signal_new("format_buttons_update", |
| 8420 | 1488 | G_TYPE_FROM_CLASS(gobject_class), |
| 1489 | G_SIGNAL_RUN_FIRST, | |
| 1490 | G_STRUCT_OFFSET(GtkIMHtmlClass, buttons_update), | |
| 1491 | NULL, | |
| 1492 | 0, | |
|
10076
1ccc0286a4ae
[gaim-migrate @ 11057]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10062
diff
changeset
|
1493 | g_cclosure_marshal_VOID__INT, |
| 8420 | 1494 | G_TYPE_NONE, 1, |
| 1495 | G_TYPE_INT); | |
| 1496 | signals[TOGGLE_FORMAT] = g_signal_new("format_function_toggle", | |
| 1497 | G_TYPE_FROM_CLASS(gobject_class), | |
| 10100 | 1498 | G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION, |
| 8420 | 1499 | G_STRUCT_OFFSET(GtkIMHtmlClass, toggle_format), |
| 1500 | NULL, | |
| 1501 | 0, | |
|
10076
1ccc0286a4ae
[gaim-migrate @ 11057]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10062
diff
changeset
|
1502 | g_cclosure_marshal_VOID__INT, |
|
1ccc0286a4ae
[gaim-migrate @ 11057]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10062
diff
changeset
|
1503 | G_TYPE_NONE, 1, |
| 8420 | 1504 | G_TYPE_INT); |
| 8427 | 1505 | signals[CLEAR_FORMAT] = g_signal_new("format_function_clear", |
| 1506 | G_TYPE_FROM_CLASS(gobject_class), | |
|
11385
38ca1438e055
[gaim-migrate @ 13612]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11315
diff
changeset
|
1507 | G_SIGNAL_RUN_FIRST | G_SIGNAL_ACTION, |
| 8427 | 1508 | G_STRUCT_OFFSET(GtkIMHtmlClass, clear_format), |
| 1509 | NULL, | |
| 1510 | 0, | |
| 10100 | 1511 | g_cclosure_marshal_VOID__VOID, |
| 1512 | G_TYPE_NONE, 0); | |
| 8506 | 1513 | signals[UPDATE_FORMAT] = g_signal_new("format_function_update", |
| 10100 | 1514 | G_TYPE_FROM_CLASS(gobject_class), |
| 1515 | G_SIGNAL_RUN_FIRST, | |
| 1516 | G_STRUCT_OFFSET(GtkIMHtmlClass, update_format), | |
| 1517 | NULL, | |
| 1518 | 0, | |
| 1519 | g_cclosure_marshal_VOID__VOID, | |
| 1520 | G_TYPE_NONE, 0); | |
| 10108 | 1521 | signals[MESSAGE_SEND] = g_signal_new("message_send", |
| 1522 | G_TYPE_FROM_CLASS(gobject_class), | |
| 1523 | G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION, | |
| 1524 | G_STRUCT_OFFSET(GtkIMHtmlClass, message_send), | |
| 1525 | NULL, | |
| 1526 | 0, g_cclosure_marshal_VOID__VOID, | |
| 1527 | G_TYPE_NONE, 0); | |
|
17880
5e73968467e0
Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@pidgin.im>
parents:
17288
diff
changeset
|
1528 | signals [UNDO] = g_signal_new ("undo", |
|
5e73968467e0
Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@pidgin.im>
parents:
17288
diff
changeset
|
1529 | G_TYPE_FROM_CLASS (klass), |
|
5e73968467e0
Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@pidgin.im>
parents:
17288
diff
changeset
|
1530 | G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION, |
|
5e73968467e0
Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@pidgin.im>
parents:
17288
diff
changeset
|
1531 | G_STRUCT_OFFSET (GtkIMHtmlClass, undo), |
|
5e73968467e0
Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@pidgin.im>
parents:
17288
diff
changeset
|
1532 | NULL, |
|
5e73968467e0
Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@pidgin.im>
parents:
17288
diff
changeset
|
1533 | NULL, |
|
5e73968467e0
Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@pidgin.im>
parents:
17288
diff
changeset
|
1534 | gtksourceview_marshal_VOID__VOID, |
|
5e73968467e0
Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@pidgin.im>
parents:
17288
diff
changeset
|
1535 | G_TYPE_NONE, |
|
5e73968467e0
Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@pidgin.im>
parents:
17288
diff
changeset
|
1536 | 0); |
|
5e73968467e0
Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@pidgin.im>
parents:
17288
diff
changeset
|
1537 | signals [REDO] = g_signal_new ("redo", |
|
5e73968467e0
Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@pidgin.im>
parents:
17288
diff
changeset
|
1538 | G_TYPE_FROM_CLASS (klass), |
|
5e73968467e0
Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@pidgin.im>
parents:
17288
diff
changeset
|
1539 | G_SIGNAL_RUN_LAST | G_SIGNAL_ACTION, |
|
5e73968467e0
Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@pidgin.im>
parents:
17288
diff
changeset
|
1540 | G_STRUCT_OFFSET (GtkIMHtmlClass, redo), |
|
5e73968467e0
Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@pidgin.im>
parents:
17288
diff
changeset
|
1541 | NULL, |
|
5e73968467e0
Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@pidgin.im>
parents:
17288
diff
changeset
|
1542 | NULL, |
|
5e73968467e0
Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@pidgin.im>
parents:
17288
diff
changeset
|
1543 | gtksourceview_marshal_VOID__VOID, |
|
5e73968467e0
Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@pidgin.im>
parents:
17288
diff
changeset
|
1544 | G_TYPE_NONE, |
|
5e73968467e0
Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@pidgin.im>
parents:
17288
diff
changeset
|
1545 | 0); |
|
5e73968467e0
Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@pidgin.im>
parents:
17288
diff
changeset
|
1546 | |
|
5e73968467e0
Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@pidgin.im>
parents:
17288
diff
changeset
|
1547 | |
| 10100 | 1548 | |
| 1549 | klass->toggle_format = imhtml_toggle_format; | |
| 10108 | 1550 | klass->message_send = imhtml_message_send; |
|
12672
673e2a1d2954
[gaim-migrate @ 15015]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12635
diff
changeset
|
1551 | klass->clear_format = imhtml_clear_formatting; |
|
24674
36bf974a7d78
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24588
diff
changeset
|
1552 | klass->url_clicked = imhtml_url_clicked; |
|
17880
5e73968467e0
Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@pidgin.im>
parents:
17288
diff
changeset
|
1553 | klass->undo = gtk_imhtml_undo; |
|
5e73968467e0
Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@pidgin.im>
parents:
17288
diff
changeset
|
1554 | klass->redo = gtk_imhtml_redo; |
|
10184
543c9a84ce16
[gaim-migrate @ 11299]
Mark Doliner <markdoliner@pidgin.im>
parents:
10169
diff
changeset
|
1555 | |
| 4032 | 1556 | gobject_class->finalize = gtk_imhtml_finalize; |
|
10184
543c9a84ce16
[gaim-migrate @ 11299]
Mark Doliner <markdoliner@pidgin.im>
parents:
10169
diff
changeset
|
1557 | widget_class->drag_motion = gtk_text_view_drag_motion; |
| 10692 | 1558 | widget_class->expose_event = gtk_imhtml_expose_event; |
|
18968
2ddbe6473bc9
Cool! Override GtkTextView's size allocate function in GtkIMHtml to make sure that it stays scrolled to the bottom whenever it's resized. Fixes a major annoyance and possibly #938
Sean Egan <seanegan@pidgin.im>
parents:
18665
diff
changeset
|
1559 | parent_size_allocate = widget_class->size_allocate; |
|
2ddbe6473bc9
Cool! Override GtkTextView's size allocate function in GtkIMHtml to make sure that it stays scrolled to the bottom whenever it's resized. Fixes a major annoyance and possibly #938
Sean Egan <seanegan@pidgin.im>
parents:
18665
diff
changeset
|
1560 | widget_class->size_allocate = gtk_imhtml_size_allocate; |
|
23227
f2d8240d3487
Use text-tags to set the weight/color of the nick in conversations. This
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22970
diff
changeset
|
1561 | parent_style_set = widget_class->style_set; |
|
f2d8240d3487
Use text-tags to set the weight/color of the nick in conversations. This
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22970
diff
changeset
|
1562 | widget_class->style_set = gtk_imhtml_style_set; |
|
18968
2ddbe6473bc9
Cool! Override GtkTextView's size allocate function in GtkIMHtml to make sure that it stays scrolled to the bottom whenever it's resized. Fixes a major annoyance and possibly #938
Sean Egan <seanegan@pidgin.im>
parents:
18665
diff
changeset
|
1563 | |
| 9007 | 1564 | gtk_widget_class_install_style_property(widget_class, g_param_spec_boxed("hyperlink-color", |
| 1565 | _("Hyperlink color"), | |
| 1566 | _("Color to draw hyperlinks."), | |
| 1567 | GDK_TYPE_COLOR, G_PARAM_READABLE)); | |
|
24328
7be2af5c9129
Show visited links in a different color. This also plugs a memory leak
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23548
diff
changeset
|
1568 | gtk_widget_class_install_style_property(widget_class, g_param_spec_boxed("hyperlink-visited-color", |
|
7be2af5c9129
Show visited links in a different color. This also plugs a memory leak
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23548
diff
changeset
|
1569 | _("Hyperlink visited color"), |
|
27525
579b9d64b364
A semi-random collection of English spelling and grammatical changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27359
diff
changeset
|
1570 | _("Color to draw hyperlink after it has been visited (or activated)."), |
|
24328
7be2af5c9129
Show visited links in a different color. This also plugs a memory leak
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23548
diff
changeset
|
1571 | GDK_TYPE_COLOR, G_PARAM_READABLE)); |
| 10799 | 1572 | gtk_widget_class_install_style_property(widget_class, g_param_spec_boxed("hyperlink-prelight-color", |
| 1573 | _("Hyperlink prelight color"), | |
| 1574 | _("Color to draw hyperlinks when mouse is over them."), | |
| 1575 | GDK_TYPE_COLOR, G_PARAM_READABLE)); | |
|
21955
4014918b95fc
Another patch from DHowett. This one adds conversation nick colors to gtkrc
Sean Egan <seanegan@pidgin.im>
parents:
21896
diff
changeset
|
1576 | gtk_widget_class_install_style_property(widget_class, g_param_spec_boxed("send-name-color", |
|
4014918b95fc
Another patch from DHowett. This one adds conversation nick colors to gtkrc
Sean Egan <seanegan@pidgin.im>
parents:
21896
diff
changeset
|
1577 | _("Sent Message Name Color"), |
|
4014918b95fc
Another patch from DHowett. This one adds conversation nick colors to gtkrc
Sean Egan <seanegan@pidgin.im>
parents:
21896
diff
changeset
|
1578 | _("Color to draw the name of a message you sent."), |
|
4014918b95fc
Another patch from DHowett. This one adds conversation nick colors to gtkrc
Sean Egan <seanegan@pidgin.im>
parents:
21896
diff
changeset
|
1579 | GDK_TYPE_COLOR, G_PARAM_READABLE)); |
|
4014918b95fc
Another patch from DHowett. This one adds conversation nick colors to gtkrc
Sean Egan <seanegan@pidgin.im>
parents:
21896
diff
changeset
|
1580 | gtk_widget_class_install_style_property(widget_class, g_param_spec_boxed("receive-name-color", |
|
4014918b95fc
Another patch from DHowett. This one adds conversation nick colors to gtkrc
Sean Egan <seanegan@pidgin.im>
parents:
21896
diff
changeset
|
1581 | _("Received Message Name Color"), |
|
4014918b95fc
Another patch from DHowett. This one adds conversation nick colors to gtkrc
Sean Egan <seanegan@pidgin.im>
parents:
21896
diff
changeset
|
1582 | _("Color to draw the name of a message you received."), |
|
4014918b95fc
Another patch from DHowett. This one adds conversation nick colors to gtkrc
Sean Egan <seanegan@pidgin.im>
parents:
21896
diff
changeset
|
1583 | GDK_TYPE_COLOR, G_PARAM_READABLE)); |
|
4014918b95fc
Another patch from DHowett. This one adds conversation nick colors to gtkrc
Sean Egan <seanegan@pidgin.im>
parents:
21896
diff
changeset
|
1584 | gtk_widget_class_install_style_property(widget_class, g_param_spec_boxed("highlight-name-color", |
|
4014918b95fc
Another patch from DHowett. This one adds conversation nick colors to gtkrc
Sean Egan <seanegan@pidgin.im>
parents:
21896
diff
changeset
|
1585 | _("\"Attention\" Name Color"), |
|
4014918b95fc
Another patch from DHowett. This one adds conversation nick colors to gtkrc
Sean Egan <seanegan@pidgin.im>
parents:
21896
diff
changeset
|
1586 | _("Color to draw the name of a message you received containing your name."), |
|
4014918b95fc
Another patch from DHowett. This one adds conversation nick colors to gtkrc
Sean Egan <seanegan@pidgin.im>
parents:
21896
diff
changeset
|
1587 | GDK_TYPE_COLOR, G_PARAM_READABLE)); |
|
4014918b95fc
Another patch from DHowett. This one adds conversation nick colors to gtkrc
Sean Egan <seanegan@pidgin.im>
parents:
21896
diff
changeset
|
1588 | gtk_widget_class_install_style_property(widget_class, g_param_spec_boxed("action-name-color", |
|
4014918b95fc
Another patch from DHowett. This one adds conversation nick colors to gtkrc
Sean Egan <seanegan@pidgin.im>
parents:
21896
diff
changeset
|
1589 | _("Action Message Name Color"), |
|
4014918b95fc
Another patch from DHowett. This one adds conversation nick colors to gtkrc
Sean Egan <seanegan@pidgin.im>
parents:
21896
diff
changeset
|
1590 | _("Color to draw the name of an action message."), |
|
4014918b95fc
Another patch from DHowett. This one adds conversation nick colors to gtkrc
Sean Egan <seanegan@pidgin.im>
parents:
21896
diff
changeset
|
1591 | GDK_TYPE_COLOR, G_PARAM_READABLE)); |
|
23227
f2d8240d3487
Use text-tags to set the weight/color of the nick in conversations. This
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22970
diff
changeset
|
1592 | gtk_widget_class_install_style_property(widget_class, g_param_spec_boxed("whisper-action-name-color", |
|
f2d8240d3487
Use text-tags to set the weight/color of the nick in conversations. This
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22970
diff
changeset
|
1593 | _("Action Message Name Color for Whispered Message"), |
|
27525
579b9d64b364
A semi-random collection of English spelling and grammatical changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27359
diff
changeset
|
1594 | _("Color to draw the name of a whispered action message."), |
|
23227
f2d8240d3487
Use text-tags to set the weight/color of the nick in conversations. This
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22970
diff
changeset
|
1595 | GDK_TYPE_COLOR, G_PARAM_READABLE)); |
|
f2d8240d3487
Use text-tags to set the weight/color of the nick in conversations. This
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22970
diff
changeset
|
1596 | gtk_widget_class_install_style_property(widget_class, g_param_spec_boxed("whisper-name-color", |
|
f2d8240d3487
Use text-tags to set the weight/color of the nick in conversations. This
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22970
diff
changeset
|
1597 | _("Whisper Message Name Color"), |
|
27525
579b9d64b364
A semi-random collection of English spelling and grammatical changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27359
diff
changeset
|
1598 | _("Color to draw the name of a whispered message."), |
|
23227
f2d8240d3487
Use text-tags to set the weight/color of the nick in conversations. This
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22970
diff
changeset
|
1599 | GDK_TYPE_COLOR, G_PARAM_READABLE)); |
| 10100 | 1600 | |
|
22772
34ab3bb905cc
Customize/disable the typing notification from gtkrc-2.0.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22703
diff
changeset
|
1601 | /* Customizable typing notification ... sort of. Example: |
|
34ab3bb905cc
Customize/disable the typing notification from gtkrc-2.0.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22703
diff
changeset
|
1602 | * GtkIMHtml::typing-notification-font = "monospace italic light 8.0" |
|
34ab3bb905cc
Customize/disable the typing notification from gtkrc-2.0.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22703
diff
changeset
|
1603 | * GtkIMHtml::typing-notification-color = "#ff0000" |
|
34ab3bb905cc
Customize/disable the typing notification from gtkrc-2.0.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22703
diff
changeset
|
1604 | * GtkIMHtml::typing-notification-enable = 1 |
|
34ab3bb905cc
Customize/disable the typing notification from gtkrc-2.0.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22703
diff
changeset
|
1605 | */ |
|
34ab3bb905cc
Customize/disable the typing notification from gtkrc-2.0.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22703
diff
changeset
|
1606 | gtk_widget_class_install_style_property(widget_class, g_param_spec_boxed("typing-notification-color", |
|
34ab3bb905cc
Customize/disable the typing notification from gtkrc-2.0.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22703
diff
changeset
|
1607 | _("Typing notification color"), |
|
27525
579b9d64b364
A semi-random collection of English spelling and grammatical changes.
Elliott Sales de Andrade <qulogic@pidgin.im>
parents:
27359
diff
changeset
|
1608 | _("The color to use for the typing notification"), |
|
22772
34ab3bb905cc
Customize/disable the typing notification from gtkrc-2.0.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22703
diff
changeset
|
1609 | GDK_TYPE_COLOR, G_PARAM_READABLE)); |
|
34ab3bb905cc
Customize/disable the typing notification from gtkrc-2.0.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22703
diff
changeset
|
1610 | gtk_widget_class_install_style_property(widget_class, g_param_spec_string("typing-notification-font", |
|
34ab3bb905cc
Customize/disable the typing notification from gtkrc-2.0.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22703
diff
changeset
|
1611 | _("Typing notification font"), |
|
34ab3bb905cc
Customize/disable the typing notification from gtkrc-2.0.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22703
diff
changeset
|
1612 | _("The font to use for the typing notification"), |
|
34ab3bb905cc
Customize/disable the typing notification from gtkrc-2.0.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22703
diff
changeset
|
1613 | "light 8.0", G_PARAM_READABLE)); |
|
34ab3bb905cc
Customize/disable the typing notification from gtkrc-2.0.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22703
diff
changeset
|
1614 | gtk_widget_class_install_style_property(widget_class, g_param_spec_boolean("typing-notification-enable", |
|
34ab3bb905cc
Customize/disable the typing notification from gtkrc-2.0.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22703
diff
changeset
|
1615 | _("Enable typing notification"), |
|
34ab3bb905cc
Customize/disable the typing notification from gtkrc-2.0.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22703
diff
changeset
|
1616 | _("Enable typing notification"), |
|
34ab3bb905cc
Customize/disable the typing notification from gtkrc-2.0.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22703
diff
changeset
|
1617 | TRUE, G_PARAM_READABLE)); |
|
34ab3bb905cc
Customize/disable the typing notification from gtkrc-2.0.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22703
diff
changeset
|
1618 | |
| 10100 | 1619 | binding_set = gtk_binding_set_by_class (parent_class); |
| 10110 | 1620 | gtk_binding_entry_add_signal (binding_set, GDK_b, GDK_CONTROL_MASK, "format_function_toggle", 1, G_TYPE_INT, GTK_IMHTML_BOLD); |
| 10100 | 1621 | gtk_binding_entry_add_signal (binding_set, GDK_i, GDK_CONTROL_MASK, "format_function_toggle", 1, G_TYPE_INT, GTK_IMHTML_ITALIC); |
| 1622 | gtk_binding_entry_add_signal (binding_set, GDK_u, GDK_CONTROL_MASK, "format_function_toggle", 1, G_TYPE_INT, GTK_IMHTML_UNDERLINE); | |
| 1623 | gtk_binding_entry_add_signal (binding_set, GDK_plus, GDK_CONTROL_MASK, "format_function_toggle", 1, G_TYPE_INT, GTK_IMHTML_GROW); | |
| 1624 | gtk_binding_entry_add_signal (binding_set, GDK_equal, GDK_CONTROL_MASK, "format_function_toggle", 1, G_TYPE_INT, GTK_IMHTML_GROW); | |
| 1625 | gtk_binding_entry_add_signal (binding_set, GDK_minus, GDK_CONTROL_MASK, "format_function_toggle", 1, G_TYPE_INT, GTK_IMHTML_SHRINK); | |
| 10108 | 1626 | binding_set = gtk_binding_set_by_class(klass); |
|
11385
38ca1438e055
[gaim-migrate @ 13612]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11315
diff
changeset
|
1627 | gtk_binding_entry_add_signal (binding_set, GDK_r, GDK_CONTROL_MASK, "format_function_clear", 0); |
| 10108 | 1628 | gtk_binding_entry_add_signal (binding_set, GDK_KP_Enter, 0, "message_send", 0); |
| 1629 | gtk_binding_entry_add_signal (binding_set, GDK_Return, 0, "message_send", 0); | |
|
17880
5e73968467e0
Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@pidgin.im>
parents:
17288
diff
changeset
|
1630 | gtk_binding_entry_add_signal (binding_set, GDK_z, GDK_CONTROL_MASK, "undo", 0); |
|
5e73968467e0
Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@pidgin.im>
parents:
17288
diff
changeset
|
1631 | gtk_binding_entry_add_signal (binding_set, GDK_z, GDK_CONTROL_MASK | GDK_SHIFT_MASK, "redo", 0); |
|
5e73968467e0
Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@pidgin.im>
parents:
17288
diff
changeset
|
1632 | gtk_binding_entry_add_signal (binding_set, GDK_F14, 0, "undo", 0); |
|
5e73968467e0
Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@pidgin.im>
parents:
17288
diff
changeset
|
1633 | |
| 1428 | 1634 | } |
| 1635 | ||
| 3922 | 1636 | static void gtk_imhtml_init (GtkIMHtml *imhtml) |
| 1428 | 1637 | { |
| 3922 | 1638 | imhtml->text_buffer = gtk_text_buffer_new(NULL); |
|
17880
5e73968467e0
Undo/Redo in GtkImHtml from GtkSourceView. This may not be adaquate enough for us.
Sean Egan <seanegan@pidgin.im>
parents:
17288
diff
changeset
|
1639 | imhtml->undo_manager = gtk_source_undo_manager_new(imhtml->text_buffer); |
| 3922 | 1640 | gtk_text_view_set_buffer(GTK_TEXT_VIEW(imhtml), imhtml->text_buffer); |
|
5105
3565a4c4de6a
[gaim-migrate @ 5468]
David J. Brigada <brigada@prism.net>
parents:
5104
diff
changeset
|
1641 | gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(imhtml), GTK_WRAP_WORD_CHAR); |
|
22865
eeed3e121bed
Move 2 of the 5 pixels' padding between paragraphs to above the line.
Will Thompson <resiak@pidgin.im>
parents:
22834
diff
changeset
|
1642 | gtk_text_view_set_pixels_above_lines(GTK_TEXT_VIEW(imhtml), 2); |
|
eeed3e121bed
Move 2 of the 5 pixels' padding between paragraphs to above the line.
Will Thompson <resiak@pidgin.im>
parents:
22834
diff
changeset
|
1643 | gtk_text_view_set_pixels_below_lines(GTK_TEXT_VIEW(imhtml), 3); |
| 8677 | 1644 | gtk_text_view_set_left_margin(GTK_TEXT_VIEW(imhtml), 2); |
| 1645 | gtk_text_view_set_right_margin(GTK_TEXT_VIEW(imhtml), 2); | |
| 8061 | 1646 | /*gtk_text_view_set_indent(GTK_TEXT_VIEW(imhtml), -15);*/ |
| 3922 | 1647 | /*gtk_text_view_set_justification(GTK_TEXT_VIEW(imhtml), GTK_JUSTIFY_FILL);*/ |
| 8061 | 1648 | |
| 3922 | 1649 | /* These tags will be used often and can be reused--we create them on init and then apply them by name |
| 8932 | 1650 | * other tags (color, size, face, etc.) will have to be created and applied dynamically |
| 9924 | 1651 | * Note that even though we created SUB, SUP, and PRE tags here, we don't really |
| 8932 | 1652 | * apply them anywhere yet. */ |
| 3922 | 1653 | gtk_text_buffer_create_tag(imhtml->text_buffer, "BOLD", "weight", PANGO_WEIGHT_BOLD, NULL); |
| 1654 | gtk_text_buffer_create_tag(imhtml->text_buffer, "ITALICS", "style", PANGO_STYLE_ITALIC, NULL); | |
| 1655 | gtk_text_buffer_create_tag(imhtml->text_buffer, "UNDERLINE", "underline", PANGO_UNDERLINE_SINGLE, NULL); | |
| 1656 | gtk_text_buffer_create_tag(imhtml->text_buffer, "STRIKE", "strikethrough", TRUE, NULL); | |
| 1657 | gtk_text_buffer_create_tag(imhtml->text_buffer, "SUB", "rise", -5000, NULL); | |
| 1658 | gtk_text_buffer_create_tag(imhtml->text_buffer, "SUP", "rise", 5000, NULL); | |
| 1659 | gtk_text_buffer_create_tag(imhtml->text_buffer, "PRE", "family", "Monospace", NULL); | |
| 7295 | 1660 | gtk_text_buffer_create_tag(imhtml->text_buffer, "search", "background", "#22ff00", "weight", "bold", NULL); |
|
23308
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
1661 | gtk_text_buffer_create_tag(imhtml->text_buffer, "comment", "weight", PANGO_WEIGHT_NORMAL, |
|
22486
e77232ab761f
Disable invisible text things, if someone can conclusively prove this is
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22276
diff
changeset
|
1662 | #if FALSE && GTK_CHECK_VERSION(2,10,10) |
|
23308
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
1663 | "invisible", FALSE, |
|
22211
7f3cecdb079c
disapproval of revision '2c96f5a301400781ce5fbf144ffdbae44f895281'
Sean Egan <seanegan@pidgin.im>
parents:
22210
diff
changeset
|
1664 | #endif |
|
23308
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
1665 | NULL); |
| 8677 | 1666 | |
|
23227
f2d8240d3487
Use text-tags to set the weight/color of the nick in conversations. This
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22970
diff
changeset
|
1667 | gtk_text_buffer_create_tag(imhtml->text_buffer, "send-name", "weight", PANGO_WEIGHT_BOLD, NULL); |
|
f2d8240d3487
Use text-tags to set the weight/color of the nick in conversations. This
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22970
diff
changeset
|
1668 | gtk_text_buffer_create_tag(imhtml->text_buffer, "receive-name", "weight", PANGO_WEIGHT_BOLD, NULL); |
|
f2d8240d3487
Use text-tags to set the weight/color of the nick in conversations. This
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22970
diff
changeset
|
1669 | gtk_text_buffer_create_tag(imhtml->text_buffer, "highlight-name", "weight", PANGO_WEIGHT_BOLD, NULL); |
|
f2d8240d3487
Use text-tags to set the weight/color of the nick in conversations. This
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22970
diff
changeset
|
1670 | gtk_text_buffer_create_tag(imhtml->text_buffer, "action-name", "weight", PANGO_WEIGHT_BOLD, NULL); |
|
f2d8240d3487
Use text-tags to set the weight/color of the nick in conversations. This
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22970
diff
changeset
|
1671 | gtk_text_buffer_create_tag(imhtml->text_buffer, "whisper-action-name", "weight", PANGO_WEIGHT_BOLD, NULL); |
|
f2d8240d3487
Use text-tags to set the weight/color of the nick in conversations. This
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22970
diff
changeset
|
1672 | gtk_text_buffer_create_tag(imhtml->text_buffer, "whisper-name", "weight", PANGO_WEIGHT_BOLD, NULL); |
| 8677 | 1673 | |
| 3922 | 1674 | /* When hovering over a link, we show the hand cursor--elsewhere we show the plain ol' pointer cursor */ |
| 1675 | imhtml->hand_cursor = gdk_cursor_new (GDK_HAND2); | |
| 1676 | imhtml->arrow_cursor = gdk_cursor_new (GDK_LEFT_PTR); | |
| 8061 | 1677 | imhtml->text_cursor = gdk_cursor_new (GDK_XTERM); |
| 2993 | 1678 | |
|
6124
322206d79652
[gaim-migrate @ 6598]
Mark Doliner <markdoliner@pidgin.im>
parents:
6066
diff
changeset
|
1679 | imhtml->show_comments = TRUE; |
| 4253 | 1680 | |
| 4892 | 1681 | imhtml->smiley_data = g_hash_table_new_full(g_str_hash, g_str_equal, |
| 4902 | 1682 | g_free, (GDestroyNotify)gtk_smiley_tree_destroy); |
| 4032 | 1683 | imhtml->default_smilies = gtk_smiley_tree_new(); |
| 4735 | 1684 | |
| 1685 | g_signal_connect(G_OBJECT(imhtml), "motion-notify-event", G_CALLBACK(gtk_motion_event_notify), NULL); | |
|
4944
032dac83798e
[gaim-migrate @ 5278]
Robert McQueen <robot101@debian.org>
parents:
4926
diff
changeset
|
1686 | g_signal_connect(G_OBJECT(imhtml), "leave-notify-event", G_CALLBACK(gtk_leave_event_notify), NULL); |
|
10946
63a41710fc94
[gaim-migrate @ 12742]
Daniel Atallah <datallah@pidgin.im>
parents:
10936
diff
changeset
|
1687 | g_signal_connect(G_OBJECT(imhtml), "enter-notify-event", G_CALLBACK(gtk_enter_event_notify), NULL); |
|
10844
fb5b88957742
[gaim-migrate @ 12516]
Richard Laager <rlaager@pidgin.im>
parents:
10834
diff
changeset
|
1688 | #if (!GTK_CHECK_VERSION(2,2,0)) |
|
fb5b88957742
[gaim-migrate @ 12516]
Richard Laager <rlaager@pidgin.im>
parents:
10834
diff
changeset
|
1689 | /* See the comment for gtk_key_pressed_cb */ |
| 6066 | 1690 | g_signal_connect(G_OBJECT(imhtml), "key_press_event", G_CALLBACK(gtk_key_pressed_cb), NULL); |
|
10844
fb5b88957742
[gaim-migrate @ 12516]
Richard Laager <rlaager@pidgin.im>
parents:
10834
diff
changeset
|
1691 | #endif |
| 8677 | 1692 | g_signal_connect(G_OBJECT(imhtml), "button_press_event", G_CALLBACK(gtk_imhtml_button_press_event), NULL); |
| 1693 | g_signal_connect(G_OBJECT(imhtml->text_buffer), "insert-text", G_CALLBACK(preinsert_cb), imhtml); | |
|
12673
4c8a20955e0b
[gaim-migrate @ 15016]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12672
diff
changeset
|
1694 | g_signal_connect(G_OBJECT(imhtml->text_buffer), "delete_range", G_CALLBACK(delete_cb), imhtml); |
| 8061 | 1695 | g_signal_connect_after(G_OBJECT(imhtml->text_buffer), "insert-text", G_CALLBACK(insert_cb), imhtml); |
| 10169 | 1696 | g_signal_connect_after(G_OBJECT(imhtml->text_buffer), "insert-child-anchor", G_CALLBACK(insert_ca_cb), imhtml); |
| 8091 | 1697 | gtk_drag_dest_set(GTK_WIDGET(imhtml), 0, |
| 1698 | link_drag_drop_targets, sizeof(link_drag_drop_targets) / sizeof(GtkTargetEntry), | |
| 1699 | GDK_ACTION_COPY); | |
| 1700 | g_signal_connect(G_OBJECT(imhtml), "drag_data_received", G_CALLBACK(gtk_imhtml_link_drag_rcv_cb), imhtml); | |
| 9300 | 1701 | g_signal_connect(G_OBJECT(imhtml), "drag_drop", G_CALLBACK(gtk_imhtml_link_drop_cb), imhtml); |
| 8091 | 1702 | |
| 7353 | 1703 | g_signal_connect(G_OBJECT(imhtml), "copy-clipboard", G_CALLBACK(copy_clipboard_cb), NULL); |
| 8698 | 1704 | g_signal_connect(G_OBJECT(imhtml), "cut-clipboard", G_CALLBACK(cut_clipboard_cb), NULL); |
| 8061 | 1705 | g_signal_connect(G_OBJECT(imhtml), "paste-clipboard", G_CALLBACK(paste_clipboard_cb), NULL); |
| 8677 | 1706 | g_signal_connect_after(G_OBJECT(imhtml), "realize", G_CALLBACK(imhtml_realized_remove_primary), NULL); |
|
8740
098a43943bba
[gaim-migrate @ 9495]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
1707 | g_signal_connect(G_OBJECT(imhtml), "unrealize", G_CALLBACK(imhtml_destroy_add_primary), NULL); |
| 8677 | 1708 | |
| 1709 | g_signal_connect_after(G_OBJECT(GTK_IMHTML(imhtml)->text_buffer), "mark-set", | |
| 1710 | G_CALLBACK(mark_set_so_update_selection_cb), imhtml); | |
| 1711 | ||
|
10946
63a41710fc94
[gaim-migrate @ 12742]
Daniel Atallah <datallah@pidgin.im>
parents:
10936
diff
changeset
|
1712 | gtk_widget_add_events(GTK_WIDGET(imhtml), |
|
63a41710fc94
[gaim-migrate @ 12742]
Daniel Atallah <datallah@pidgin.im>
parents:
10936
diff
changeset
|
1713 | GDK_LEAVE_NOTIFY_MASK | GDK_ENTER_NOTIFY_MASK); |
| 4735 | 1714 | |
| 1715 | imhtml->tip = NULL; | |
| 1716 | imhtml->tip_timer = 0; | |
| 1717 | imhtml->tip_window = NULL; | |
| 4895 | 1718 | |
| 8677 | 1719 | imhtml->edit.bold = FALSE; |
| 1720 | imhtml->edit.italic = FALSE; | |
| 1721 | imhtml->edit.underline = FALSE; | |
| 8061 | 1722 | imhtml->edit.forecolor = NULL; |
| 1723 | imhtml->edit.backcolor = NULL; | |
| 1724 | imhtml->edit.fontface = NULL; | |
| 8677 | 1725 | imhtml->edit.fontsize = 0; |
| 1726 | imhtml->edit.link = NULL; | |
| 1727 | ||
|
11572
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
1728 | |
| 4895 | 1729 | imhtml->scalables = NULL; |
|
16385
aa5b9456e258
Fixes #213 This allows only 20 animated smileys to be animnating at a time
Sean Egan <seanegan@pidgin.im>
parents:
16291
diff
changeset
|
1730 | imhtml->animations = g_queue_new(); |
| 8061 | 1731 | gtk_imhtml_set_editable(imhtml, FALSE); |
|
11572
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
1732 | g_signal_connect(G_OBJECT(imhtml), "populate-popup", |
| 8931 | 1733 | G_CALLBACK(hijack_menu_cb), NULL); |
| 2993 | 1734 | } |
| 1735 | ||
| 3922 | 1736 | GtkWidget *gtk_imhtml_new(void *a, void *b) |
| 1428 | 1737 | { |
| 4635 | 1738 | return GTK_WIDGET(g_object_new(gtk_imhtml_get_type(), NULL)); |
| 1428 | 1739 | } |
| 1740 | ||
| 9037 | 1741 | GType gtk_imhtml_get_type() |
| 1428 | 1742 | { |
| 9037 | 1743 | static GType imhtml_type = 0; |
| 1428 | 1744 | |
| 1745 | if (!imhtml_type) { | |
| 9037 | 1746 | static const GTypeInfo imhtml_info = { |
| 4635 | 1747 | sizeof(GtkIMHtmlClass), |
| 1748 | NULL, | |
| 1749 | NULL, | |
| 1750 | (GClassInitFunc) gtk_imhtml_class_init, | |
| 1751 | NULL, | |
| 1752 | NULL, | |
| 1428 | 1753 | sizeof (GtkIMHtml), |
| 4635 | 1754 | 0, |
|
12600
7ecd4441fdc7
[gaim-migrate @ 14934]
Richard Laager <rlaager@pidgin.im>
parents:
12553
diff
changeset
|
1755 | (GInstanceInitFunc) gtk_imhtml_init, |
|
7ecd4441fdc7
[gaim-migrate @ 14934]
Richard Laager <rlaager@pidgin.im>
parents:
12553
diff
changeset
|
1756 | NULL |
| 1428 | 1757 | }; |
| 4635 | 1758 | |
| 1759 | imhtml_type = g_type_register_static(gtk_text_view_get_type(), | |
| 1760 | "GtkIMHtml", &imhtml_info, 0); | |
| 1428 | 1761 | } |
| 1762 | ||
| 1763 | return imhtml_type; | |
| 1764 | } | |
| 1765 | ||
|
24698
f9dd7117ade0
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24675
diff
changeset
|
1766 | static void gtk_imhtml_link_destroy(GtkIMHtmlLink *link) |
|
f9dd7117ade0
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24675
diff
changeset
|
1767 | { |
|
f9dd7117ade0
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24675
diff
changeset
|
1768 | if (link->imhtml) |
|
f9dd7117ade0
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24675
diff
changeset
|
1769 | g_object_unref(link->imhtml); |
|
f9dd7117ade0
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24675
diff
changeset
|
1770 | if (link->tag) |
|
f9dd7117ade0
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24675
diff
changeset
|
1771 | g_object_unref(link->tag); |
|
f9dd7117ade0
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24675
diff
changeset
|
1772 | g_free(link->url); |
|
f9dd7117ade0
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24675
diff
changeset
|
1773 | g_free(link); |
| 4417 | 1774 | } |
| 1775 | ||
| 1776 | /* The callback for an event on a link tag. */ | |
|
24328
7be2af5c9129
Show visited links in a different color. This also plugs a memory leak
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23548
diff
changeset
|
1777 | static gboolean tag_event(GtkTextTag *tag, GObject *imhtml, GdkEvent *event, GtkTextIter *arg2, gpointer unused) |
|
7be2af5c9129
Show visited links in a different color. This also plugs a memory leak
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23548
diff
changeset
|
1778 | { |
| 4417 | 1779 | GdkEventButton *event_button = (GdkEventButton *) event; |
| 8061 | 1780 | if (GTK_IMHTML(imhtml)->editable) |
| 1781 | return FALSE; | |
| 3922 | 1782 | if (event->type == GDK_BUTTON_RELEASE) { |
| 8957 | 1783 | if ((event_button->button == 1) || (event_button->button == 2)) { |
| 4417 | 1784 | GtkTextIter start, end; |
| 1785 | /* we shouldn't open a URL if the user has selected something: */ | |
| 8677 | 1786 | if (gtk_text_buffer_get_selection_bounds( |
| 1787 | gtk_text_iter_get_buffer(arg2), &start, &end)) | |
| 4417 | 1788 | return FALSE; |
|
24698
f9dd7117ade0
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24675
diff
changeset
|
1789 | gtk_imhtml_activate_tag(GTK_IMHTML(imhtml), tag); |
| 4417 | 1790 | return FALSE; |
| 1791 | } else if(event_button->button == 3) { | |
|
24698
f9dd7117ade0
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24675
diff
changeset
|
1792 | GList *children; |
|
f9dd7117ade0
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24675
diff
changeset
|
1793 | GtkWidget *menu; |
|
24674
36bf974a7d78
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24588
diff
changeset
|
1794 | GtkIMHtmlProtocol *proto; |
|
24698
f9dd7117ade0
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24675
diff
changeset
|
1795 | GtkIMHtmlLink *link = g_new(GtkIMHtmlLink, 1); |
|
f9dd7117ade0
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24675
diff
changeset
|
1796 | link->imhtml = g_object_ref(imhtml); |
|
f9dd7117ade0
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24675
diff
changeset
|
1797 | link->url = g_strdup(g_object_get_data(G_OBJECT(tag), "link_url")); |
|
f9dd7117ade0
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24675
diff
changeset
|
1798 | link->tag = g_object_ref(tag); |
| 4745 | 1799 | |
| 5091 | 1800 | /* Don't want the tooltip around if user right-clicked on link */ |
| 1801 | if (GTK_IMHTML(imhtml)->tip_window) { | |
| 1802 | gtk_widget_destroy(GTK_IMHTML(imhtml)->tip_window); | |
| 1803 | GTK_IMHTML(imhtml)->tip_window = NULL; | |
| 1804 | } | |
| 1805 | if (GTK_IMHTML(imhtml)->tip_timer) { | |
| 1806 | g_source_remove(GTK_IMHTML(imhtml)->tip_timer); | |
| 1807 | GTK_IMHTML(imhtml)->tip_timer = 0; | |
| 1808 | } | |
| 8061 | 1809 | if (GTK_IMHTML(imhtml)->editable) |
| 1810 | gdk_window_set_cursor(event_button->window, GTK_IMHTML(imhtml)->text_cursor); | |
| 1811 | else | |
| 1812 | gdk_window_set_cursor(event_button->window, GTK_IMHTML(imhtml)->arrow_cursor); | |
| 4417 | 1813 | menu = gtk_menu_new(); |
|
24698
f9dd7117ade0
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24675
diff
changeset
|
1814 | g_object_set_data_full(G_OBJECT(menu), "x-imhtml-url-data", link, |
|
f9dd7117ade0
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24675
diff
changeset
|
1815 | (GDestroyNotify)gtk_imhtml_link_destroy); |
|
f9dd7117ade0
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24675
diff
changeset
|
1816 | |
|
25013
956b2f650d31
Detect duplication registrations by substring.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
25011
diff
changeset
|
1817 | proto = imhtml_find_protocol(link->url, FALSE); |
|
24698
f9dd7117ade0
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24675
diff
changeset
|
1818 | |
|
f9dd7117ade0
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24675
diff
changeset
|
1819 | if (proto && proto->context_menu) { |
|
f9dd7117ade0
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24675
diff
changeset
|
1820 | proto->context_menu(GTK_IMHTML(link->imhtml), link, menu); |
|
7140
2670fa7da352
[gaim-migrate @ 7707]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
1821 | } |
|
24698
f9dd7117ade0
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24675
diff
changeset
|
1822 | |
|
f9dd7117ade0
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24675
diff
changeset
|
1823 | children = gtk_container_get_children(GTK_CONTAINER(menu)); |
|
f9dd7117ade0
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24675
diff
changeset
|
1824 | if (!children) { |
|
f9dd7117ade0
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24675
diff
changeset
|
1825 | GtkWidget *item = gtk_menu_item_new_with_label(_("No actions available")); |
|
f9dd7117ade0
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24675
diff
changeset
|
1826 | gtk_widget_show(item); |
|
f9dd7117ade0
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24675
diff
changeset
|
1827 | gtk_widget_set_sensitive(item, FALSE); |
| 10936 | 1828 | gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); |
|
24698
f9dd7117ade0
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24675
diff
changeset
|
1829 | } else { |
|
f9dd7117ade0
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24675
diff
changeset
|
1830 | g_list_free(children); |
|
7140
2670fa7da352
[gaim-migrate @ 7707]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
1831 | } |
|
2670fa7da352
[gaim-migrate @ 7707]
Christian Hammond <chipx86@chipx86.com>
parents:
6982
diff
changeset
|
1832 | |
|
4756
ee19a87a495f
[gaim-migrate @ 5073]
Mark Doliner <markdoliner@pidgin.im>
parents:
4745
diff
changeset
|
1833 | |
| 4417 | 1834 | gtk_widget_show_all(menu); |
|
4756
ee19a87a495f
[gaim-migrate @ 5073]
Mark Doliner <markdoliner@pidgin.im>
parents:
4745
diff
changeset
|
1835 | gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL, |
|
ee19a87a495f
[gaim-migrate @ 5073]
Mark Doliner <markdoliner@pidgin.im>
parents:
4745
diff
changeset
|
1836 | event_button->button, event_button->time); |
| 4745 | 1837 | |
| 4417 | 1838 | return TRUE; |
| 1839 | } | |
| 1428 | 1840 | } |
| 4417 | 1841 | if(event->type == GDK_BUTTON_PRESS && event_button->button == 3) |
| 1842 | return TRUE; /* Clicking the right mouse button on a link shouldn't | |
| 1843 | be caught by the regular GtkTextView menu */ | |
| 1844 | else | |
| 1845 | return FALSE; /* Let clicks go through if we didn't catch anything */ | |
| 1428 | 1846 | } |
| 1847 | ||
| 9300 | 1848 | static gboolean |
| 1849 | gtk_text_view_drag_motion (GtkWidget *widget, | |
| 1850 | GdkDragContext *context, | |
| 1851 | gint x, | |
| 1852 | gint y, | |
| 1853 | guint time) | |
| 1854 | { | |
|
11572
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
1855 | GdkDragAction suggested_action = 0; |
| 9300 | 1856 | |
|
10145
f1405f65ff41
[gaim-migrate @ 11218]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10110
diff
changeset
|
1857 | if (gtk_drag_dest_find_target (widget, context, NULL) == GDK_NONE) { |
|
11572
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
1858 | /* can't accept any of the offered targets */ |
| 9300 | 1859 | } else { |
| 1860 | GtkWidget *source_widget; | |
| 1861 | suggested_action = context->suggested_action; | |
| 1862 | source_widget = gtk_drag_get_source_widget (context); | |
| 1863 | if (source_widget == widget) { | |
| 1864 | /* Default to MOVE, unless the user has | |
| 1865 | * pressed ctrl or alt to affect available actions | |
| 1866 | */ | |
| 1867 | if ((context->actions & GDK_ACTION_MOVE) != 0) | |
| 1868 | suggested_action = GDK_ACTION_MOVE; | |
| 1869 | } | |
|
11572
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
1870 | } |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
1871 | |
|
10145
f1405f65ff41
[gaim-migrate @ 11218]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10110
diff
changeset
|
1872 | gdk_drag_status (context, suggested_action, time); |
|
11572
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
1873 | |
| 9300 | 1874 | /* TRUE return means don't propagate the drag motion to parent |
| 1875 | * widgets that may also be drop sites. | |
| 1876 | */ | |
| 1877 | return TRUE; | |
| 1878 | } | |
| 1879 | ||
| 1880 | static void | |
| 1881 | gtk_imhtml_link_drop_cb(GtkWidget *widget, GdkDragContext *context, gint x, gint y, guint time, gpointer user_data) | |
| 1882 | { | |
| 1883 | GdkAtom target = gtk_drag_dest_find_target (widget, context, NULL); | |
|
11572
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
1884 | |
| 9300 | 1885 | if (target != GDK_NONE) |
| 1886 | gtk_drag_get_data (widget, context, target, time); | |
| 1887 | else | |
| 1888 | gtk_drag_finish (context, FALSE, FALSE, time); | |
| 1889 | ||
| 1890 | return; | |
| 1891 | } | |
| 1892 | ||
| 8091 | 1893 | static void |
| 1894 | gtk_imhtml_link_drag_rcv_cb(GtkWidget *widget, GdkDragContext *dc, guint x, guint y, | |
|
11143
f606fb334190
[gaim-migrate @ 13207]
Mark Doliner <markdoliner@pidgin.im>
parents:
11069
diff
changeset
|
1895 | GtkSelectionData *sd, guint info, guint t, GtkIMHtml *imhtml) |
| 8091 | 1896 | { |
| 9300 | 1897 | gchar **links; |
| 1898 | gchar *link; | |
|
11143
f606fb334190
[gaim-migrate @ 13207]
Mark Doliner <markdoliner@pidgin.im>
parents:
11069
diff
changeset
|
1899 | char *text = (char *)sd->data; |
| 9300 | 1900 | GtkTextMark *mark = gtk_text_buffer_get_insert(imhtml->text_buffer); |
| 1901 | GtkTextIter iter; | |
|
10782
18cc41076f4e
[gaim-migrate @ 12410]
Luke Schierer <lschiere@pidgin.im>
parents:
10777
diff
changeset
|
1902 | gint i = 0; |
| 9300 | 1903 | |
| 1904 | gtk_text_buffer_get_iter_at_mark(imhtml->text_buffer, &iter, mark); | |
| 1905 | ||
| 8091 | 1906 | if(gtk_imhtml_get_editable(imhtml) && sd->data){ |
| 9300 | 1907 | switch (info) { |
|
10145
f1405f65ff41
[gaim-migrate @ 11218]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10110
diff
changeset
|
1908 | case GTK_IMHTML_DRAG_URL: |
|
11143
f606fb334190
[gaim-migrate @ 13207]
Mark Doliner <markdoliner@pidgin.im>
parents:
11069
diff
changeset
|
1909 | /* TODO: Is it really ok to change sd->data...? */ |
| 15884 | 1910 | purple_str_strip_char((char *)sd->data, '\r'); |
|
11143
f606fb334190
[gaim-migrate @ 13207]
Mark Doliner <markdoliner@pidgin.im>
parents:
11069
diff
changeset
|
1911 | |
|
f606fb334190
[gaim-migrate @ 13207]
Mark Doliner <markdoliner@pidgin.im>
parents:
11069
diff
changeset
|
1912 | links = g_strsplit((char *)sd->data, "\n", 0); |
|
10782
18cc41076f4e
[gaim-migrate @ 12410]
Luke Schierer <lschiere@pidgin.im>
parents:
10777
diff
changeset
|
1913 | while((link = links[i]) != NULL){ |
|
24674
36bf974a7d78
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24588
diff
changeset
|
1914 | if (gtk_imhtml_is_protocol(link)) { |
|
10782
18cc41076f4e
[gaim-migrate @ 12410]
Luke Schierer <lschiere@pidgin.im>
parents:
10777
diff
changeset
|
1915 | gchar *label; |
|
18cc41076f4e
[gaim-migrate @ 12410]
Luke Schierer <lschiere@pidgin.im>
parents:
10777
diff
changeset
|
1916 | |
|
18cc41076f4e
[gaim-migrate @ 12410]
Luke Schierer <lschiere@pidgin.im>
parents:
10777
diff
changeset
|
1917 | if(links[i + 1]) |
|
18cc41076f4e
[gaim-migrate @ 12410]
Luke Schierer <lschiere@pidgin.im>
parents:
10777
diff
changeset
|
1918 | i++; |
|
18cc41076f4e
[gaim-migrate @ 12410]
Luke Schierer <lschiere@pidgin.im>
parents:
10777
diff
changeset
|
1919 | |
|
18cc41076f4e
[gaim-migrate @ 12410]
Luke Schierer <lschiere@pidgin.im>
parents:
10777
diff
changeset
|
1920 | label = links[i]; |
|
18cc41076f4e
[gaim-migrate @ 12410]
Luke Schierer <lschiere@pidgin.im>
parents:
10777
diff
changeset
|
1921 | |
|
18cc41076f4e
[gaim-migrate @ 12410]
Luke Schierer <lschiere@pidgin.im>
parents:
10777
diff
changeset
|
1922 | gtk_imhtml_insert_link(imhtml, mark, link, label); |
|
24674
36bf974a7d78
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24588
diff
changeset
|
1923 | } else if (*link == '\0') { |
| 9300 | 1924 | /* Ignore blank lines */ |
| 1925 | } else { | |
| 1926 | /* Special reasons, aka images being put in via other tag, etc. */ | |
|
10345
7d7f8cfa2b4f
[gaim-migrate @ 11556]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
10297
diff
changeset
|
1927 | /* ... don't pretend we handled it if we didn't */ |
|
7d7f8cfa2b4f
[gaim-migrate @ 11556]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
10297
diff
changeset
|
1928 | gtk_drag_finish(dc, FALSE, FALSE, t); |
|
10782
18cc41076f4e
[gaim-migrate @ 12410]
Luke Schierer <lschiere@pidgin.im>
parents:
10777
diff
changeset
|
1929 | g_strfreev(links); |
|
10345
7d7f8cfa2b4f
[gaim-migrate @ 11556]
Felipe Contreras <felipe.contreras@gmail.com>
parents:
10297
diff
changeset
|
1930 | return; |
| 9300 | 1931 | } |
|
10782
18cc41076f4e
[gaim-migrate @ 12410]
Luke Schierer <lschiere@pidgin.im>
parents:
10777
diff
changeset
|
1932 | |
|
18cc41076f4e
[gaim-migrate @ 12410]
Luke Schierer <lschiere@pidgin.im>
parents:
10777
diff
changeset
|
1933 | i++; |
| 8091 | 1934 | } |
|
10782
18cc41076f4e
[gaim-migrate @ 12410]
Luke Schierer <lschiere@pidgin.im>
parents:
10777
diff
changeset
|
1935 | g_strfreev(links); |
| 9300 | 1936 | break; |
|
10145
f1405f65ff41
[gaim-migrate @ 11218]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10110
diff
changeset
|
1937 | case GTK_IMHTML_DRAG_HTML: |
|
10243
6d75b29afc71
[gaim-migrate @ 11383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10217
diff
changeset
|
1938 | { |
|
6d75b29afc71
[gaim-migrate @ 11383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10217
diff
changeset
|
1939 | char *utf8 = NULL; |
|
6d75b29afc71
[gaim-migrate @ 11383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10217
diff
changeset
|
1940 | /* Ewww. This is all because mozilla thinks that text/html is 'for internal use only.' |
|
6d75b29afc71
[gaim-migrate @ 11383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10217
diff
changeset
|
1941 | * as explained by this comment in gtkhtml: |
|
6d75b29afc71
[gaim-migrate @ 11383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10217
diff
changeset
|
1942 | * |
|
6d75b29afc71
[gaim-migrate @ 11383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10217
diff
changeset
|
1943 | * FIXME This hack decides the charset of the selection. It seems that |
|
6d75b29afc71
[gaim-migrate @ 11383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10217
diff
changeset
|
1944 | * mozilla/netscape alway use ucs2 for text/html |
|
6d75b29afc71
[gaim-migrate @ 11383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10217
diff
changeset
|
1945 | * and openoffice.org seems to always use utf8 so we try to validate |
|
6d75b29afc71
[gaim-migrate @ 11383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10217
diff
changeset
|
1946 | * the string as utf8 and if that fails we assume it is ucs2 |
|
6d75b29afc71
[gaim-migrate @ 11383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10217
diff
changeset
|
1947 | * |
|
6d75b29afc71
[gaim-migrate @ 11383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10217
diff
changeset
|
1948 | * See also the comment on text/html here: |
|
6d75b29afc71
[gaim-migrate @ 11383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10217
diff
changeset
|
1949 | * http://mail.gnome.org/archives/gtk-devel-list/2001-September/msg00114.html |
|
6d75b29afc71
[gaim-migrate @ 11383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10217
diff
changeset
|
1950 | */ |
|
6d75b29afc71
[gaim-migrate @ 11383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10217
diff
changeset
|
1951 | if (sd->length >= 2 && !g_utf8_validate(text, sd->length - 1, NULL)) { |
|
22596
0854ae660ef4
Further changes to use UTF-16 instead of UCS-2. Also, fix #5167 by making sure that the encoding conversion worked before using the result.
Daniel Atallah <datallah@pidgin.im>
parents:
22595
diff
changeset
|
1952 | utf8 = utf16_to_utf8_with_bom_check(text, sd->length); |
|
10243
6d75b29afc71
[gaim-migrate @ 11383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10217
diff
changeset
|
1953 | |
|
6d75b29afc71
[gaim-migrate @ 11383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10217
diff
changeset
|
1954 | if (!utf8) { |
|
22596
0854ae660ef4
Further changes to use UTF-16 instead of UCS-2. Also, fix #5167 by making sure that the encoding conversion worked before using the result.
Daniel Atallah <datallah@pidgin.im>
parents:
22595
diff
changeset
|
1955 | purple_debug_warning("gtkimhtml", "g_convert from UTF-16 failed in drag_rcv_cb\n"); |
| 9300 | 1956 | return; |
| 1957 | } | |
|
10243
6d75b29afc71
[gaim-migrate @ 11383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10217
diff
changeset
|
1958 | } else if (!(*text) || !g_utf8_validate(text, -1, NULL)) { |
| 15884 | 1959 | purple_debug_warning("gtkimhtml", "empty string or invalid UTF-8 in drag_rcv_cb\n"); |
| 9300 | 1960 | return; |
| 1961 | } | |
|
10243
6d75b29afc71
[gaim-migrate @ 11383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10217
diff
changeset
|
1962 | |
|
6d75b29afc71
[gaim-migrate @ 11383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10217
diff
changeset
|
1963 | gtk_imhtml_insert_html_at_iter(imhtml, utf8 ? utf8 : text, 0, &iter); |
|
6d75b29afc71
[gaim-migrate @ 11383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10217
diff
changeset
|
1964 | g_free(utf8); |
| 9300 | 1965 | break; |
|
10243
6d75b29afc71
[gaim-migrate @ 11383]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10217
diff
changeset
|
1966 | } |
|
10145
f1405f65ff41
[gaim-migrate @ 11218]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10110
diff
changeset
|
1967 | case GTK_IMHTML_DRAG_TEXT: |
|
f1405f65ff41
[gaim-migrate @ 11218]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10110
diff
changeset
|
1968 | if (!(*text) || !g_utf8_validate(text, -1, NULL)) { |
| 15884 | 1969 | purple_debug_warning("gtkimhtml", "empty string or invalid UTF-8 in drag_rcv_cb\n"); |
|
10145
f1405f65ff41
[gaim-migrate @ 11218]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10110
diff
changeset
|
1970 | return; |
|
f1405f65ff41
[gaim-migrate @ 11218]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10110
diff
changeset
|
1971 | } else { |
|
10732
5e314ab498bf
[gaim-migrate @ 12334]
Richard Laager <rlaager@pidgin.im>
parents:
10699
diff
changeset
|
1972 | char *tmp = g_markup_escape_text(text, -1); |
|
10145
f1405f65ff41
[gaim-migrate @ 11218]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10110
diff
changeset
|
1973 | gtk_imhtml_insert_html_at_iter(imhtml, tmp, 0, &iter); |
|
f1405f65ff41
[gaim-migrate @ 11218]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10110
diff
changeset
|
1974 | g_free(tmp); |
|
f1405f65ff41
[gaim-migrate @ 11218]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10110
diff
changeset
|
1975 | } |
|
f1405f65ff41
[gaim-migrate @ 11218]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10110
diff
changeset
|
1976 | break; |
| 9300 | 1977 | default: |
|
10145
f1405f65ff41
[gaim-migrate @ 11218]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10110
diff
changeset
|
1978 | gtk_drag_finish(dc, FALSE, FALSE, t); |
|
f1405f65ff41
[gaim-migrate @ 11218]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10110
diff
changeset
|
1979 | return; |
| 8091 | 1980 | } |
| 1981 | gtk_drag_finish(dc, TRUE, (dc->action == GDK_ACTION_MOVE), t); | |
| 1982 | } else { | |
| 1983 | gtk_drag_finish(dc, FALSE, FALSE, t); | |
| 1984 | } | |
| 1985 | } | |
| 1986 | ||
| 9300 | 1987 | static void gtk_smiley_tree_remove (GtkSmileyTree *tree, |
| 4263 | 1988 | GtkIMHtmlSmiley *smiley) |
| 4032 | 1989 | { |
| 1990 | GtkSmileyTree *t = tree; | |
| 4263 | 1991 | const gchar *x = smiley->smile; |
| 4032 | 1992 | gint len = 0; |
| 1993 | ||
| 1994 | while (*x) { | |
| 1995 | gchar *pos; | |
| 1996 | ||
| 1997 | if (!t->values) | |
| 1998 | return; | |
| 1999 | ||
| 2000 | pos = strchr (t->values->str, *x); | |
| 2001 | if (pos) | |
|
24544
75266af2c12b
Fixed a compiler warning (and remove an unnessesary cast)
Marcus Lundblad <malu@pidgin.im>
parents:
24511
diff
changeset
|
2002 | t = t->children [pos - t->values->str]; |
| 4032 | 2003 | else |
| 2004 | return; | |
| 2005 | ||
| 2006 | x++; len++; | |
| 2007 | } | |
| 2008 | ||
| 4141 | 2009 | if (t->image) { |
| 4032 | 2010 | t->image = NULL; |
| 4141 | 2011 | } |
| 4032 | 2012 | } |
| 2013 | ||
| 2014 | static gint | |
| 2015 | gtk_smiley_tree_lookup (GtkSmileyTree *tree, | |
| 2016 | const gchar *text) | |
| 2017 | { | |
| 2018 | GtkSmileyTree *t = tree; | |
| 2019 | const gchar *x = text; | |
| 2020 | gint len = 0; | |
|
16143
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
2021 | const gchar *amp; |
| 8505 | 2022 | gint alen; |
| 4032 | 2023 | |
| 2024 | while (*x) { | |
| 2025 | gchar *pos; | |
| 2026 | ||
| 2027 | if (!t->values) | |
| 2028 | break; | |
| 2029 | ||
| 16144 | 2030 | if(*x == '&' && (amp = purple_markup_unescape_entity(x, &alen))) { |
|
10865
f5bb66be81a0
[gaim-migrate @ 12549]
Daniel Atallah <datallah@pidgin.im>
parents:
10858
diff
changeset
|
2031 | gboolean matched = TRUE; |
|
f5bb66be81a0
[gaim-migrate @ 12549]
Daniel Atallah <datallah@pidgin.im>
parents:
10858
diff
changeset
|
2032 | /* Make sure all chars of the unescaped value match */ |
|
f5bb66be81a0
[gaim-migrate @ 12549]
Daniel Atallah <datallah@pidgin.im>
parents:
10858
diff
changeset
|
2033 | while (*(amp + 1)) { |
|
f5bb66be81a0
[gaim-migrate @ 12549]
Daniel Atallah <datallah@pidgin.im>
parents:
10858
diff
changeset
|
2034 | pos = strchr (t->values->str, *amp); |
|
f5bb66be81a0
[gaim-migrate @ 12549]
Daniel Atallah <datallah@pidgin.im>
parents:
10858
diff
changeset
|
2035 | if (pos) |
|
f5bb66be81a0
[gaim-migrate @ 12549]
Daniel Atallah <datallah@pidgin.im>
parents:
10858
diff
changeset
|
2036 | t = t->children [GPOINTER_TO_INT(pos) - GPOINTER_TO_INT(t->values->str)]; |
|
f5bb66be81a0
[gaim-migrate @ 12549]
Daniel Atallah <datallah@pidgin.im>
parents:
10858
diff
changeset
|
2037 | else { |
|
f5bb66be81a0
[gaim-migrate @ 12549]
Daniel Atallah <datallah@pidgin.im>
parents:
10858
diff
changeset
|
2038 | matched = FALSE; |
|
f5bb66be81a0
[gaim-migrate @ 12549]
Daniel Atallah <datallah@pidgin.im>
parents:
10858
diff
changeset
|
2039 | break; |
|
f5bb66be81a0
[gaim-migrate @ 12549]
Daniel Atallah <datallah@pidgin.im>
parents:
10858
diff
changeset
|
2040 | } |
|
f5bb66be81a0
[gaim-migrate @ 12549]
Daniel Atallah <datallah@pidgin.im>
parents:
10858
diff
changeset
|
2041 | amp++; |
|
f5bb66be81a0
[gaim-migrate @ 12549]
Daniel Atallah <datallah@pidgin.im>
parents:
10858
diff
changeset
|
2042 | } |
|
f5bb66be81a0
[gaim-migrate @ 12549]
Daniel Atallah <datallah@pidgin.im>
parents:
10858
diff
changeset
|
2043 | if (!matched) |
|
f5bb66be81a0
[gaim-migrate @ 12549]
Daniel Atallah <datallah@pidgin.im>
parents:
10858
diff
changeset
|
2044 | break; |
|
f5bb66be81a0
[gaim-migrate @ 12549]
Daniel Atallah <datallah@pidgin.im>
parents:
10858
diff
changeset
|
2045 | |
|
f5bb66be81a0
[gaim-migrate @ 12549]
Daniel Atallah <datallah@pidgin.im>
parents:
10858
diff
changeset
|
2046 | pos = strchr (t->values->str, *amp); |
| 8505 | 2047 | } |
|
11572
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
2048 | else if (*x == '<') /* Because we're all WYSIWYG now, a '<' |
| 9636 | 2049 | * char should only appear as the start of a tag. Perhaps a safer (but costlier) |
| 2050 | * check would be to call gtk_imhtml_is_tag on it */ | |
| 10600 | 2051 | break; |
|
10865
f5bb66be81a0
[gaim-migrate @ 12549]
Daniel Atallah <datallah@pidgin.im>
parents:
10858
diff
changeset
|
2052 | else { |
|
f5bb66be81a0
[gaim-migrate @ 12549]
Daniel Atallah <datallah@pidgin.im>
parents:
10858
diff
changeset
|
2053 | alen = 1; |
|
f5bb66be81a0
[gaim-migrate @ 12549]
Daniel Atallah <datallah@pidgin.im>
parents:
10858
diff
changeset
|
2054 | pos = strchr (t->values->str, *x); |
|
f5bb66be81a0
[gaim-migrate @ 12549]
Daniel Atallah <datallah@pidgin.im>
parents:
10858
diff
changeset
|
2055 | } |
| 8505 | 2056 | |
| 4032 | 2057 | if (pos) |
| 7371 | 2058 | t = t->children [GPOINTER_TO_INT(pos) - GPOINTER_TO_INT(t->values->str)]; |
| 4032 | 2059 | else |
| 2060 | break; | |
| 2061 | ||
|
10865
f5bb66be81a0
[gaim-migrate @ 12549]
Daniel Atallah <datallah@pidgin.im>
parents:
10858
diff
changeset
|
2062 | x += alen; |
|
f5bb66be81a0
[gaim-migrate @ 12549]
Daniel Atallah <datallah@pidgin.im>
parents:
10858
diff
changeset
|
2063 | len += alen; |
| 4032 | 2064 | } |
| 2065 | ||
| 2066 | if (t->image) | |
| 2067 | return len; | |
| 2068 | ||
| 2069 | return 0; | |
| 2070 | } | |
| 2071 | ||
|
24392
51b7f65a712d
Clean up the GtkSmileyTrees on active GtkIMHtml instances when a custom smiley
Marcus Lundblad <malu@pidgin.im>
parents:
24328
diff
changeset
|
2072 | static void |
|
51b7f65a712d
Clean up the GtkSmileyTrees on active GtkIMHtml instances when a custom smiley
Marcus Lundblad <malu@pidgin.im>
parents:
24328
diff
changeset
|
2073 | gtk_imhtml_disassociate_smiley_foreach(gpointer key, gpointer value, |
|
51b7f65a712d
Clean up the GtkSmileyTrees on active GtkIMHtml instances when a custom smiley
Marcus Lundblad <malu@pidgin.im>
parents:
24328
diff
changeset
|
2074 | gpointer user_data) |
|
51b7f65a712d
Clean up the GtkSmileyTrees on active GtkIMHtml instances when a custom smiley
Marcus Lundblad <malu@pidgin.im>
parents:
24328
diff
changeset
|
2075 | { |
|
51b7f65a712d
Clean up the GtkSmileyTrees on active GtkIMHtml instances when a custom smiley
Marcus Lundblad <malu@pidgin.im>
parents:
24328
diff
changeset
|
2076 | GtkSmileyTree *tree = (GtkSmileyTree *) value; |
|
51b7f65a712d
Clean up the GtkSmileyTrees on active GtkIMHtml instances when a custom smiley
Marcus Lundblad <malu@pidgin.im>
parents:
24328
diff
changeset
|
2077 | GtkIMHtmlSmiley *smiley = (GtkIMHtmlSmiley *) user_data; |
|
51b7f65a712d
Clean up the GtkSmileyTrees on active GtkIMHtml instances when a custom smiley
Marcus Lundblad <malu@pidgin.im>
parents:
24328
diff
changeset
|
2078 | gtk_smiley_tree_remove(tree, smiley); |
|
51b7f65a712d
Clean up the GtkSmileyTrees on active GtkIMHtml instances when a custom smiley
Marcus Lundblad <malu@pidgin.im>
parents:
24328
diff
changeset
|
2079 | } |
|
51b7f65a712d
Clean up the GtkSmileyTrees on active GtkIMHtml instances when a custom smiley
Marcus Lundblad <malu@pidgin.im>
parents:
24328
diff
changeset
|
2080 | |
|
51b7f65a712d
Clean up the GtkSmileyTrees on active GtkIMHtml instances when a custom smiley
Marcus Lundblad <malu@pidgin.im>
parents:
24328
diff
changeset
|
2081 | static void |
|
24588
b2c89babe134
Remove that hack involving GtkIMHtmlSmileys
Marcus Lundblad <malu@pidgin.im>
parents:
24587
diff
changeset
|
2082 | gtk_imhtml_disconnect_smiley(GtkIMHtml *imhtml, GtkIMHtmlSmiley *smiley) |
|
b2c89babe134
Remove that hack involving GtkIMHtmlSmileys
Marcus Lundblad <malu@pidgin.im>
parents:
24587
diff
changeset
|
2083 | { |
|
b2c89babe134
Remove that hack involving GtkIMHtmlSmileys
Marcus Lundblad <malu@pidgin.im>
parents:
24587
diff
changeset
|
2084 | smiley->imhtml = NULL; |
|
b2c89babe134
Remove that hack involving GtkIMHtmlSmileys
Marcus Lundblad <malu@pidgin.im>
parents:
24587
diff
changeset
|
2085 | g_signal_handlers_disconnect_matched(imhtml, G_SIGNAL_MATCH_DATA, 0, 0, |
|
b2c89babe134
Remove that hack involving GtkIMHtmlSmileys
Marcus Lundblad <malu@pidgin.im>
parents:
24587
diff
changeset
|
2086 | NULL, NULL, smiley); |
|
b2c89babe134
Remove that hack involving GtkIMHtmlSmileys
Marcus Lundblad <malu@pidgin.im>
parents:
24587
diff
changeset
|
2087 | } |
|
b2c89babe134
Remove that hack involving GtkIMHtmlSmileys
Marcus Lundblad <malu@pidgin.im>
parents:
24587
diff
changeset
|
2088 | |
|
b2c89babe134
Remove that hack involving GtkIMHtmlSmileys
Marcus Lundblad <malu@pidgin.im>
parents:
24587
diff
changeset
|
2089 | static void |
|
24392
51b7f65a712d
Clean up the GtkSmileyTrees on active GtkIMHtml instances when a custom smiley
Marcus Lundblad <malu@pidgin.im>
parents:
24328
diff
changeset
|
2090 | gtk_imhtml_disassociate_smiley(GtkIMHtmlSmiley *smiley) |
|
51b7f65a712d
Clean up the GtkSmileyTrees on active GtkIMHtml instances when a custom smiley
Marcus Lundblad <malu@pidgin.im>
parents:
24328
diff
changeset
|
2091 | { |
|
24588
b2c89babe134
Remove that hack involving GtkIMHtmlSmileys
Marcus Lundblad <malu@pidgin.im>
parents:
24587
diff
changeset
|
2092 | if (smiley->imhtml) { |
|
24392
51b7f65a712d
Clean up the GtkSmileyTrees on active GtkIMHtml instances when a custom smiley
Marcus Lundblad <malu@pidgin.im>
parents:
24328
diff
changeset
|
2093 | gtk_smiley_tree_remove(smiley->imhtml->default_smilies, smiley); |
|
25888
d0fdd378a635
Remove trailing whitespace
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
2094 | g_hash_table_foreach(smiley->imhtml->smiley_data, |
|
24392
51b7f65a712d
Clean up the GtkSmileyTrees on active GtkIMHtml instances when a custom smiley
Marcus Lundblad <malu@pidgin.im>
parents:
24328
diff
changeset
|
2095 | gtk_imhtml_disassociate_smiley_foreach, smiley); |
|
24588
b2c89babe134
Remove that hack involving GtkIMHtmlSmileys
Marcus Lundblad <malu@pidgin.im>
parents:
24587
diff
changeset
|
2096 | g_signal_handlers_disconnect_matched(smiley->imhtml, G_SIGNAL_MATCH_DATA, |
|
b2c89babe134
Remove that hack involving GtkIMHtmlSmileys
Marcus Lundblad <malu@pidgin.im>
parents:
24587
diff
changeset
|
2097 | 0, 0, NULL, NULL, smiley); |
|
24587
16c4d6e6e192
Don't try to remove GtkIMHtmlSmileys from smiley trees if the GtkIMHtml
Marcus Lundblad <malu@pidgin.im>
parents:
24569
diff
changeset
|
2098 | smiley->imhtml = NULL; |
|
24392
51b7f65a712d
Clean up the GtkSmileyTrees on active GtkIMHtml instances when a custom smiley
Marcus Lundblad <malu@pidgin.im>
parents:
24328
diff
changeset
|
2099 | } |
|
51b7f65a712d
Clean up the GtkSmileyTrees on active GtkIMHtml instances when a custom smiley
Marcus Lundblad <malu@pidgin.im>
parents:
24328
diff
changeset
|
2100 | } |
|
51b7f65a712d
Clean up the GtkSmileyTrees on active GtkIMHtml instances when a custom smiley
Marcus Lundblad <malu@pidgin.im>
parents:
24328
diff
changeset
|
2101 | |
| 4032 | 2102 | void |
| 4263 | 2103 | gtk_imhtml_associate_smiley (GtkIMHtml *imhtml, |
|
10537
9ece7671fa62
[gaim-migrate @ 11890]
Mark Doliner <markdoliner@pidgin.im>
parents:
10526
diff
changeset
|
2104 | const gchar *sml, |
| 4263 | 2105 | GtkIMHtmlSmiley *smiley) |
| 4032 | 2106 | { |
| 2107 | GtkSmileyTree *tree; | |
| 2108 | g_return_if_fail (imhtml != NULL); | |
| 2109 | g_return_if_fail (GTK_IS_IMHTML (imhtml)); | |
| 7371 | 2110 | |
| 4032 | 2111 | if (sml == NULL) |
| 2112 | tree = imhtml->default_smilies; | |
|
12833
1f461f275b90
[gaim-migrate @ 15181]
Richard Laager <rlaager@pidgin.im>
parents:
12796
diff
changeset
|
2113 | else if (!(tree = g_hash_table_lookup(imhtml->smiley_data, sml))) { |
| 4032 | 2114 | tree = gtk_smiley_tree_new(); |
| 4892 | 2115 | g_hash_table_insert(imhtml->smiley_data, g_strdup(sml), tree); |
| 4032 | 2116 | } |
| 2117 | ||
|
24588
b2c89babe134
Remove that hack involving GtkIMHtmlSmileys
Marcus Lundblad <malu@pidgin.im>
parents:
24587
diff
changeset
|
2118 | /* need to disconnect old imhtml, if there is one */ |
|
b2c89babe134
Remove that hack involving GtkIMHtmlSmileys
Marcus Lundblad <malu@pidgin.im>
parents:
24587
diff
changeset
|
2119 | if (smiley->imhtml) { |
|
b2c89babe134
Remove that hack involving GtkIMHtmlSmileys
Marcus Lundblad <malu@pidgin.im>
parents:
24587
diff
changeset
|
2120 | g_signal_handlers_disconnect_matched(smiley->imhtml, G_SIGNAL_MATCH_DATA, |
|
b2c89babe134
Remove that hack involving GtkIMHtmlSmileys
Marcus Lundblad <malu@pidgin.im>
parents:
24587
diff
changeset
|
2121 | 0, 0, NULL, NULL, smiley); |
|
b2c89babe134
Remove that hack involving GtkIMHtmlSmileys
Marcus Lundblad <malu@pidgin.im>
parents:
24587
diff
changeset
|
2122 | } |
|
25888
d0fdd378a635
Remove trailing whitespace
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
2123 | |
| 12335 | 2124 | smiley->imhtml = imhtml; |
| 2125 | ||
| 4263 | 2126 | gtk_smiley_tree_insert (tree, smiley); |
|
25888
d0fdd378a635
Remove trailing whitespace
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
2127 | |
|
24588
b2c89babe134
Remove that hack involving GtkIMHtmlSmileys
Marcus Lundblad <malu@pidgin.im>
parents:
24587
diff
changeset
|
2128 | /* connect destroy signal for the imhtml */ |
|
25888
d0fdd378a635
Remove trailing whitespace
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
2129 | g_signal_connect(imhtml, "destroy", G_CALLBACK(gtk_imhtml_disconnect_smiley), |
|
24588
b2c89babe134
Remove that hack involving GtkIMHtmlSmileys
Marcus Lundblad <malu@pidgin.im>
parents:
24587
diff
changeset
|
2130 | smiley); |
| 4032 | 2131 | } |
| 2132 | ||
| 2133 | static gboolean | |
| 2134 | gtk_imhtml_is_smiley (GtkIMHtml *imhtml, | |
| 2135 | GSList *fonts, | |
| 2136 | const gchar *text, | |
| 2137 | gint *len) | |
| 2138 | { | |
| 2139 | GtkSmileyTree *tree; | |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
2140 | GtkIMHtmlFontDetail *font; |
| 4032 | 2141 | char *sml = NULL; |
| 2142 | ||
| 2143 | if (fonts) { | |
| 2144 | font = fonts->data; | |
| 2145 | sml = font->sml; | |
| 2146 | } | |
| 2147 | ||
| 9029 | 2148 | if (!sml) |
| 2149 | sml = imhtml->protocol_name; | |
| 2150 | ||
| 2151 | if (!sml || !(tree = g_hash_table_lookup(imhtml->smiley_data, sml))) | |
| 4032 | 2152 | tree = imhtml->default_smilies; |
| 9029 | 2153 | |
| 4032 | 2154 | if (tree == NULL) |
| 2155 | return FALSE; | |
| 7371 | 2156 | |
| 8505 | 2157 | *len = gtk_smiley_tree_lookup (tree, text); |
| 4032 | 2158 | return (*len > 0); |
| 2159 | } | |
| 2160 | ||
| 10526 | 2161 | GtkIMHtmlSmiley * |
| 2162 | gtk_imhtml_smiley_get(GtkIMHtml *imhtml, | |
| 2163 | const gchar *sml, | |
| 2164 | const gchar *text) | |
| 4032 | 2165 | { |
| 2166 | GtkSmileyTree *t; | |
| 2167 | const gchar *x = text; | |
| 2168 | if (sml == NULL) | |
| 2169 | t = imhtml->default_smilies; | |
| 7371 | 2170 | else |
| 4032 | 2171 | t = g_hash_table_lookup(imhtml->smiley_data, sml); |
| 7371 | 2172 | |
| 4032 | 2173 | |
| 2174 | if (t == NULL) | |
| 10526 | 2175 | return sml ? gtk_imhtml_smiley_get(imhtml, NULL, text) : NULL; |
| 4032 | 2176 | |
| 2177 | while (*x) { | |
| 2178 | gchar *pos; | |
| 2179 | ||
| 2180 | if (!t->values) { | |
| 10526 | 2181 | return sml ? gtk_imhtml_smiley_get(imhtml, NULL, text) : NULL; |
| 4032 | 2182 | } |
| 7371 | 2183 | |
| 4032 | 2184 | pos = strchr (t->values->str, *x); |
| 2185 | if (pos) { | |
| 7371 | 2186 | t = t->children [GPOINTER_TO_INT(pos) - GPOINTER_TO_INT(t->values->str)]; |
| 4032 | 2187 | } else { |
| 10526 | 2188 | return sml ? gtk_imhtml_smiley_get(imhtml, NULL, text) : NULL; |
| 4032 | 2189 | } |
| 2190 | x++; | |
| 2191 | } | |
| 2192 | ||
| 10526 | 2193 | return t->image; |
| 2194 | } | |
| 2195 | ||
|
11677
89c2ab8d2ebf
[gaim-migrate @ 13963]
Mark Doliner <markdoliner@pidgin.im>
parents:
11586
diff
changeset
|
2196 | static GdkPixbufAnimation * |
|
17009
2cc9edf33feb
Allow saving custom smileys by right-clicking on them. And use the custom smileys only on the received messages, not for the system/etc. messages.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16385
diff
changeset
|
2197 | gtk_smiley_get_image(GtkIMHtmlSmiley *smiley) |
| 10526 | 2198 | { |
| 2199 | if (!smiley->icon && smiley->file) { | |
| 2200 | smiley->icon = gdk_pixbuf_animation_new_from_file(smiley->file, NULL); | |
| 2201 | } else if (!smiley->icon && smiley->loader) { | |
| 2202 | smiley->icon = gdk_pixbuf_loader_get_animation(smiley->loader); | |
| 2203 | if (smiley->icon) | |
| 2204 | g_object_ref(G_OBJECT(smiley->icon)); | |
| 2205 | } | |
|
11572
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
2206 | |
| 10526 | 2207 | return smiley->icon; |
| 4032 | 2208 | } |
| 8890 | 2209 | |
|
17009
2cc9edf33feb
Allow saving custom smileys by right-clicking on them. And use the custom smileys only on the received messages, not for the system/etc. messages.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16385
diff
changeset
|
2210 | static GdkPixbufAnimation * |
|
2cc9edf33feb
Allow saving custom smileys by right-clicking on them. And use the custom smileys only on the received messages, not for the system/etc. messages.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16385
diff
changeset
|
2211 | gtk_smiley_tree_image (GtkIMHtml *imhtml, |
|
2cc9edf33feb
Allow saving custom smileys by right-clicking on them. And use the custom smileys only on the received messages, not for the system/etc. messages.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16385
diff
changeset
|
2212 | const gchar *sml, |
|
2cc9edf33feb
Allow saving custom smileys by right-clicking on them. And use the custom smileys only on the received messages, not for the system/etc. messages.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16385
diff
changeset
|
2213 | const gchar *text) |
|
2cc9edf33feb
Allow saving custom smileys by right-clicking on them. And use the custom smileys only on the received messages, not for the system/etc. messages.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16385
diff
changeset
|
2214 | { |
|
2cc9edf33feb
Allow saving custom smileys by right-clicking on them. And use the custom smileys only on the received messages, not for the system/etc. messages.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16385
diff
changeset
|
2215 | GtkIMHtmlSmiley *smiley; |
|
2cc9edf33feb
Allow saving custom smileys by right-clicking on them. And use the custom smileys only on the received messages, not for the system/etc. messages.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16385
diff
changeset
|
2216 | |
|
2cc9edf33feb
Allow saving custom smileys by right-clicking on them. And use the custom smileys only on the received messages, not for the system/etc. messages.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16385
diff
changeset
|
2217 | smiley = gtk_imhtml_smiley_get(imhtml,sml,text); |
|
2cc9edf33feb
Allow saving custom smileys by right-clicking on them. And use the custom smileys only on the received messages, not for the system/etc. messages.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16385
diff
changeset
|
2218 | |
|
2cc9edf33feb
Allow saving custom smileys by right-clicking on them. And use the custom smileys only on the received messages, not for the system/etc. messages.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16385
diff
changeset
|
2219 | if (!smiley) |
|
2cc9edf33feb
Allow saving custom smileys by right-clicking on them. And use the custom smileys only on the received messages, not for the system/etc. messages.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16385
diff
changeset
|
2220 | return NULL; |
|
2cc9edf33feb
Allow saving custom smileys by right-clicking on them. And use the custom smileys only on the received messages, not for the system/etc. messages.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16385
diff
changeset
|
2221 | |
|
2cc9edf33feb
Allow saving custom smileys by right-clicking on them. And use the custom smileys only on the received messages, not for the system/etc. messages.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16385
diff
changeset
|
2222 | return gtk_smiley_get_image(smiley); |
|
2cc9edf33feb
Allow saving custom smileys by right-clicking on them. And use the custom smileys only on the received messages, not for the system/etc. messages.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16385
diff
changeset
|
2223 | } |
|
2cc9edf33feb
Allow saving custom smileys by right-clicking on them. And use the custom smileys only on the received messages, not for the system/etc. messages.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16385
diff
changeset
|
2224 | |
|
25017
139df1ee9854
Fix the linkification error where bad things happened if you copy/pasted
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
25014
diff
changeset
|
2225 | #define VALID_TAG(x) do { \ |
|
139df1ee9854
Fix the linkification error where bad things happened if you copy/pasted
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
25014
diff
changeset
|
2226 | if (!g_ascii_strncasecmp (string, x ">", strlen (x ">"))) { \ |
|
139df1ee9854
Fix the linkification error where bad things happened if you copy/pasted
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
25014
diff
changeset
|
2227 | if (tag) *tag = g_strndup (string, strlen (x)); \ |
|
139df1ee9854
Fix the linkification error where bad things happened if you copy/pasted
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
25014
diff
changeset
|
2228 | if (len) *len = strlen (x) + 1; \ |
| 3922 | 2229 | return TRUE; \ |
| 2230 | } \ | |
|
25017
139df1ee9854
Fix the linkification error where bad things happened if you copy/pasted
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
25014
diff
changeset
|
2231 | if (type) (*type)++; \ |
|
139df1ee9854
Fix the linkification error where bad things happened if you copy/pasted
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
25014
diff
changeset
|
2232 | } while (0) |
|
139df1ee9854
Fix the linkification error where bad things happened if you copy/pasted
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
25014
diff
changeset
|
2233 | |
|
139df1ee9854
Fix the linkification error where bad things happened if you copy/pasted
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
25014
diff
changeset
|
2234 | #define VALID_OPT_TAG(x) do { \ |
|
139df1ee9854
Fix the linkification error where bad things happened if you copy/pasted
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
25014
diff
changeset
|
2235 | if (!g_ascii_strncasecmp (string, x " ", strlen (x " "))) { \ |
| 3922 | 2236 | const gchar *c = string + strlen (x " "); \ |
| 2237 | gchar e = '"'; \ | |
| 2238 | gboolean quote = FALSE; \ | |
| 2239 | while (*c) { \ | |
| 2240 | if (*c == '"' || *c == '\'') { \ | |
| 2241 | if (quote && (*c == e)) \ | |
| 2242 | quote = !quote; \ | |
| 2243 | else if (!quote) { \ | |
| 2244 | quote = !quote; \ | |
| 2245 | e = *c; \ | |
| 2246 | } \ | |
| 2247 | } else if (!quote && (*c == '>')) \ | |
| 2248 | break; \ | |
| 2249 | c++; \ | |
| 2250 | } \ | |
| 2251 | if (*c) { \ | |
|
25017
139df1ee9854
Fix the linkification error where bad things happened if you copy/pasted
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
25014
diff
changeset
|
2252 | if (tag) *tag = g_strndup (string, c - string); \ |
|
139df1ee9854
Fix the linkification error where bad things happened if you copy/pasted
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
25014
diff
changeset
|
2253 | if (len) *len = c - string + 1; \ |
| 3922 | 2254 | return TRUE; \ |
| 2255 | } \ | |
| 2256 | } \ | |
|
25017
139df1ee9854
Fix the linkification error where bad things happened if you copy/pasted
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
25014
diff
changeset
|
2257 | if (type) (*type)++; \ |
|
139df1ee9854
Fix the linkification error where bad things happened if you copy/pasted
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
25014
diff
changeset
|
2258 | } while (0) |
| 1428 | 2259 | |
| 2260 | ||
|
1472
ce83d12b7df9
[gaim-migrate @ 1482]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
1463
diff
changeset
|
2261 | static gboolean |
|
2856
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2262 | gtk_imhtml_is_tag (const gchar *string, |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2263 | gchar **tag, |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2264 | gint *len, |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2265 | gint *type) |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2266 | { |
| 8061 | 2267 | char *close; |
|
25017
139df1ee9854
Fix the linkification error where bad things happened if you copy/pasted
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
25014
diff
changeset
|
2268 | if (type) |
|
139df1ee9854
Fix the linkification error where bad things happened if you copy/pasted
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
25014
diff
changeset
|
2269 | *type = 1; |
|
8118
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
2270 | |
| 8061 | 2271 | if (!(close = strchr (string, '>'))) |
|
2856
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2272 | return FALSE; |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2273 | |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2274 | VALID_TAG ("B"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2275 | VALID_TAG ("BOLD"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2276 | VALID_TAG ("/B"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2277 | VALID_TAG ("/BOLD"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2278 | VALID_TAG ("I"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2279 | VALID_TAG ("ITALIC"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2280 | VALID_TAG ("/I"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2281 | VALID_TAG ("/ITALIC"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2282 | VALID_TAG ("U"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2283 | VALID_TAG ("UNDERLINE"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2284 | VALID_TAG ("/U"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2285 | VALID_TAG ("/UNDERLINE"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2286 | VALID_TAG ("S"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2287 | VALID_TAG ("STRIKE"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2288 | VALID_TAG ("/S"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2289 | VALID_TAG ("/STRIKE"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2290 | VALID_TAG ("SUB"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2291 | VALID_TAG ("/SUB"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2292 | VALID_TAG ("SUP"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2293 | VALID_TAG ("/SUP"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2294 | VALID_TAG ("PRE"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2295 | VALID_TAG ("/PRE"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2296 | VALID_TAG ("TITLE"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2297 | VALID_TAG ("/TITLE"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2298 | VALID_TAG ("BR"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2299 | VALID_TAG ("HR"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2300 | VALID_TAG ("/FONT"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2301 | VALID_TAG ("/A"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2302 | VALID_TAG ("P"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2303 | VALID_TAG ("/P"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2304 | VALID_TAG ("H3"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2305 | VALID_TAG ("/H3"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2306 | VALID_TAG ("HTML"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2307 | VALID_TAG ("/HTML"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2308 | VALID_TAG ("BODY"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2309 | VALID_TAG ("/BODY"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2310 | VALID_TAG ("FONT"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2311 | VALID_TAG ("HEAD"); |
| 2993 | 2312 | VALID_TAG ("/HEAD"); |
| 2313 | VALID_TAG ("BINARY"); | |
| 2314 | VALID_TAG ("/BINARY"); | |
| 5093 | 2315 | |
|
2856
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2316 | VALID_OPT_TAG ("HR"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2317 | VALID_OPT_TAG ("FONT"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2318 | VALID_OPT_TAG ("BODY"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2319 | VALID_OPT_TAG ("A"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2320 | VALID_OPT_TAG ("IMG"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2321 | VALID_OPT_TAG ("P"); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2322 | VALID_OPT_TAG ("H3"); |
| 5093 | 2323 | VALID_OPT_TAG ("HTML"); |
|
2856
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2324 | |
| 5101 | 2325 | VALID_TAG ("CITE"); |
| 2326 | VALID_TAG ("/CITE"); | |
| 2327 | VALID_TAG ("EM"); | |
| 2328 | VALID_TAG ("/EM"); | |
| 2329 | VALID_TAG ("STRONG"); | |
| 2330 | VALID_TAG ("/STRONG"); | |
| 2331 | ||
| 5104 | 2332 | VALID_OPT_TAG ("SPAN"); |
| 2333 | VALID_TAG ("/SPAN"); | |
| 5174 | 2334 | VALID_TAG ("BR/"); /* hack until gtkimhtml handles things better */ |
|
6982
12f08de92674
[gaim-migrate @ 7538]
Mark Doliner <markdoliner@pidgin.im>
parents:
6882
diff
changeset
|
2335 | VALID_TAG ("IMG"); |
| 8026 | 2336 | VALID_TAG("SPAN"); |
| 8061 | 2337 | VALID_OPT_TAG("BR"); |
| 7988 | 2338 | |
| 4793 | 2339 | if (!g_ascii_strncasecmp(string, "!--", strlen ("!--"))) { |
|
2954
fc07d855731d
[gaim-migrate @ 2967]
Christian Hammond <chipx86@chipx86.com>
parents:
2898
diff
changeset
|
2340 | gchar *e = strstr (string + strlen("!--"), "-->"); |
|
2856
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2341 | if (e) { |
|
25017
139df1ee9854
Fix the linkification error where bad things happened if you copy/pasted
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
25014
diff
changeset
|
2342 | if (len) |
|
139df1ee9854
Fix the linkification error where bad things happened if you copy/pasted
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
25014
diff
changeset
|
2343 | *len = e - string + strlen ("-->"); |
|
139df1ee9854
Fix the linkification error where bad things happened if you copy/pasted
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
25014
diff
changeset
|
2344 | if (tag) |
|
139df1ee9854
Fix the linkification error where bad things happened if you copy/pasted
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
25014
diff
changeset
|
2345 | *tag = g_strndup (string + strlen ("!--"), *len - strlen ("!---->")); |
|
2856
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2346 | return TRUE; |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2347 | } |
|
8118
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
2348 | } |
|
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
2349 | |
|
25017
139df1ee9854
Fix the linkification error where bad things happened if you copy/pasted
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
25014
diff
changeset
|
2350 | if (type) |
|
139df1ee9854
Fix the linkification error where bad things happened if you copy/pasted
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
25014
diff
changeset
|
2351 | *type = -1; |
|
139df1ee9854
Fix the linkification error where bad things happened if you copy/pasted
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
25014
diff
changeset
|
2352 | if (len) |
|
139df1ee9854
Fix the linkification error where bad things happened if you copy/pasted
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
25014
diff
changeset
|
2353 | *len = close - string + 1; |
|
139df1ee9854
Fix the linkification error where bad things happened if you copy/pasted
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
25014
diff
changeset
|
2354 | if (tag) |
|
139df1ee9854
Fix the linkification error where bad things happened if you copy/pasted
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
25014
diff
changeset
|
2355 | *tag = g_strndup(string, *len - 1); |
|
19733
ec657d978c5a
disapproval of revision 'f08436883bb16f29affdc63e9fd86ff278ed368f'
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
19732
diff
changeset
|
2356 | return TRUE; |
|
2856
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2357 | } |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2358 | |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2359 | static gchar* |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2360 | gtk_imhtml_get_html_opt (gchar *tag, |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2361 | const gchar *opt) |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2362 | { |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2363 | gchar *t = tag; |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2364 | gchar *e, *a; |
| 5177 | 2365 | gchar *val; |
| 2366 | gint len; | |
|
16143
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
2367 | const gchar *c; |
| 5177 | 2368 | GString *ret; |
|
2856
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2369 | |
| 4793 | 2370 | while (g_ascii_strncasecmp (t, opt, strlen (opt))) { |
|
2856
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2371 | gboolean quote = FALSE; |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2372 | if (*t == '\0') break; |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2373 | while (*t && !((*t == ' ') && !quote)) { |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2374 | if (*t == '\"') |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2375 | quote = ! quote; |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2376 | t++; |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2377 | } |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2378 | while (*t && (*t == ' ')) t++; |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2379 | } |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2380 | |
| 4793 | 2381 | if (!g_ascii_strncasecmp (t, opt, strlen (opt))) { |
|
2856
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2382 | t += strlen (opt); |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2383 | } else { |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2384 | return NULL; |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2385 | } |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2386 | |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2387 | if ((*t == '\"') || (*t == '\'')) { |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2388 | e = a = ++t; |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2389 | while (*e && (*e != *(t - 1))) e++; |
| 2993 | 2390 | if (*e == '\0') { |
|
2856
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2391 | return NULL; |
| 5177 | 2392 | } else |
| 2393 | val = g_strndup(a, e - a); | |
|
2856
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2394 | } else { |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2395 | e = a = t; |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2396 | while (*e && !isspace ((gint) *e)) e++; |
| 5177 | 2397 | val = g_strndup(a, e - a); |
|
2856
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2398 | } |
| 5177 | 2399 | |
| 2400 | ret = g_string_new(""); | |
| 2401 | e = val; | |
| 2402 | while(*e) { | |
| 16144 | 2403 | if((c = purple_markup_unescape_entity(e, &len))) { |
| 7280 | 2404 | ret = g_string_append(ret, c); |
| 5177 | 2405 | e += len; |
| 2406 | } else { | |
|
19325
4ae1add93886
Thanks sadrul. Fixes #2277
Sean Egan <seanegan@pidgin.im>
parents:
19103
diff
changeset
|
2407 | gunichar uni = g_utf8_get_char(e); |
|
4ae1add93886
Thanks sadrul. Fixes #2277
Sean Egan <seanegan@pidgin.im>
parents:
19103
diff
changeset
|
2408 | ret = g_string_append_unichar(ret, uni); |
|
4ae1add93886
Thanks sadrul. Fixes #2277
Sean Egan <seanegan@pidgin.im>
parents:
19103
diff
changeset
|
2409 | e = g_utf8_next_char(e); |
| 5177 | 2410 | } |
| 2411 | } | |
| 2412 | ||
| 2413 | g_free(val); | |
|
8568
66907b37ce85
[gaim-migrate @ 9316]
Mark Doliner <markdoliner@pidgin.im>
parents:
8566
diff
changeset
|
2414 | |
|
66907b37ce85
[gaim-migrate @ 9316]
Mark Doliner <markdoliner@pidgin.im>
parents:
8566
diff
changeset
|
2415 | return g_string_free(ret, FALSE); |
|
2856
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2416 | } |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2417 | |
| 8334 | 2418 | /* returns if the beginning of the text is a protocol. If it is the protocol, returns the length so |
| 2419 | the caller knows how long the protocol string is. */ | |
|
12412
8abe3226695e
[gaim-migrate @ 14719]
Richard Laager <rlaager@pidgin.im>
parents:
12335
diff
changeset
|
2420 | static int gtk_imhtml_is_protocol(const char *text) |
| 8334 | 2421 | { |
|
25013
956b2f650d31
Detect duplication registrations by substring.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
25011
diff
changeset
|
2422 | GtkIMHtmlProtocol *proto = imhtml_find_protocol(text, FALSE); |
|
24674
36bf974a7d78
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24588
diff
changeset
|
2423 | return proto ? proto->length : 0; |
| 8334 | 2424 | } |
| 2425 | ||
|
28940
e0f3781f6397
Fix scrolling bug for very busy chat rooms.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28935
diff
changeset
|
2426 | static gboolean smooth_scroll_cb(gpointer data); |
|
e0f3781f6397
Fix scrolling bug for very busy chat rooms.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28935
diff
changeset
|
2427 | |
| 8677 | 2428 | /* |
| 15884 | 2429 | <KingAnt> marv: The two IM image functions in oscar are purple_odc_send_im and purple_odc_incoming |
| 8677 | 2430 | |
| 2431 | ||
| 2432 | [19:58] <Robot101> marv: images go into the imgstore, a refcounted... well.. hash. :) | |
| 2433 | [19:59] <KingAnt> marv: I think the image tag used by the core is something like <img id="#"/> | |
|
11572
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
2434 | [19:59] Ro0tSiEgE robert42 RobFlynn Robot101 ross22 roz |
| 15884 | 2435 | [20:00] <KingAnt> marv: Where the ID is the what is returned when you add the image to the imgstore using purple_imgstore_add |
| 8677 | 2436 | [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? |
| 2437 | [20:00] <KingAnt> marv: Right | |
| 2438 | [20:00] <marv> alright | |
| 2439 | ||
| 2440 | Here's my plan with IMImages. make gtk_imhtml_[append|insert]_text_with_images instead just | |
| 2441 | gtkimhtml_[append|insert]_text (hrm maybe it should be called html instead of text), add a | |
| 15884 | 2442 | function for purple to register for look up images, i.e. gtk_imhtml_set_get_img_fnc, so that |
| 8677 | 2443 | images can be looked up like that, instead of passing a GSList of them. |
| 2444 | */ | |
| 2445 | ||
| 2446 | void gtk_imhtml_append_text_with_images (GtkIMHtml *imhtml, | |
| 2447 | const gchar *text, | |
| 2448 | GtkIMHtmlOptions options, | |
| 2449 | GSList *unused) | |
| 1428 | 2450 | { |
| 8677 | 2451 | GtkTextIter iter, ins, sel; |
|
22803
e1f64090d32e
Do not show tooltips for <HR> or <IMG>s in gtkimhtml. Fixes #5480.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22772
diff
changeset
|
2452 | int ins_offset = 0, sel_offset = 0; |
| 8677 | 2453 | gboolean fixins = FALSE, fixsel = FALSE; |
| 2454 | ||
| 2455 | g_return_if_fail (imhtml != NULL); | |
| 2456 | g_return_if_fail (GTK_IS_IMHTML (imhtml)); | |
| 2457 | g_return_if_fail (text != NULL); | |
| 2458 | ||
| 2459 | ||
| 2460 | gtk_text_buffer_get_end_iter(imhtml->text_buffer, &iter); | |
| 2461 | gtk_text_buffer_get_iter_at_mark(imhtml->text_buffer, &ins, gtk_text_buffer_get_insert(imhtml->text_buffer)); | |
| 2462 | if (gtk_text_iter_equal(&iter, &ins) && gtk_text_buffer_get_selection_bounds(imhtml->text_buffer, NULL, NULL)) { | |
| 2463 | fixins = TRUE; | |
| 2464 | ins_offset = gtk_text_iter_get_offset(&ins); | |
| 2465 | } | |
| 2466 | ||
| 2467 | gtk_text_buffer_get_iter_at_mark(imhtml->text_buffer, &sel, gtk_text_buffer_get_selection_bound(imhtml->text_buffer)); | |
| 2468 | if (gtk_text_iter_equal(&iter, &sel) && gtk_text_buffer_get_selection_bounds(imhtml->text_buffer, NULL, NULL)) { | |
| 2469 | fixsel = TRUE; | |
| 2470 | sel_offset = gtk_text_iter_get_offset(&sel); | |
| 2471 | } | |
| 2472 | ||
|
22803
e1f64090d32e
Do not show tooltips for <HR> or <IMG>s in gtkimhtml. Fixes #5480.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22772
diff
changeset
|
2473 | if (!(options & GTK_IMHTML_NO_SCROLL)) { |
|
e1f64090d32e
Do not show tooltips for <HR> or <IMG>s in gtkimhtml. Fixes #5480.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22772
diff
changeset
|
2474 | GdkRectangle rect; |
|
e1f64090d32e
Do not show tooltips for <HR> or <IMG>s in gtkimhtml. Fixes #5480.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22772
diff
changeset
|
2475 | int y, height; |
|
e1f64090d32e
Do not show tooltips for <HR> or <IMG>s in gtkimhtml. Fixes #5480.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22772
diff
changeset
|
2476 | |
|
e1f64090d32e
Do not show tooltips for <HR> or <IMG>s in gtkimhtml. Fixes #5480.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22772
diff
changeset
|
2477 | gtk_text_view_get_visible_rect(GTK_TEXT_VIEW(imhtml), &rect); |
|
e1f64090d32e
Do not show tooltips for <HR> or <IMG>s in gtkimhtml. Fixes #5480.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22772
diff
changeset
|
2478 | gtk_text_view_get_line_yrange(GTK_TEXT_VIEW(imhtml), &iter, &y, &height); |
|
e1f64090d32e
Do not show tooltips for <HR> or <IMG>s in gtkimhtml. Fixes #5480.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22772
diff
changeset
|
2479 | |
|
e1f64090d32e
Do not show tooltips for <HR> or <IMG>s in gtkimhtml. Fixes #5480.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22772
diff
changeset
|
2480 | if (((y + height) - (rect.y + rect.height)) > height && |
|
e1f64090d32e
Do not show tooltips for <HR> or <IMG>s in gtkimhtml. Fixes #5480.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22772
diff
changeset
|
2481 | gtk_text_buffer_get_char_count(imhtml->text_buffer)) { |
|
28940
e0f3781f6397
Fix scrolling bug for very busy chat rooms.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28935
diff
changeset
|
2482 | /* If we are in the middle of smooth-scrolling, then take a scroll step. |
|
e0f3781f6397
Fix scrolling bug for very busy chat rooms.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28935
diff
changeset
|
2483 | * If we are not in the middle of smooth-scrolling, that means we were |
|
e0f3781f6397
Fix scrolling bug for very busy chat rooms.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28935
diff
changeset
|
2484 | * not looking at the end of the buffer before the new text was added, |
|
e0f3781f6397
Fix scrolling bug for very busy chat rooms.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28935
diff
changeset
|
2485 | * so do not scroll. */ |
|
e0f3781f6397
Fix scrolling bug for very busy chat rooms.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28935
diff
changeset
|
2486 | if (imhtml->scroll_time) |
|
e0f3781f6397
Fix scrolling bug for very busy chat rooms.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28935
diff
changeset
|
2487 | smooth_scroll_cb(imhtml); |
|
e0f3781f6397
Fix scrolling bug for very busy chat rooms.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28935
diff
changeset
|
2488 | else |
|
e0f3781f6397
Fix scrolling bug for very busy chat rooms.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28935
diff
changeset
|
2489 | options |= GTK_IMHTML_NO_SCROLL; |
|
22803
e1f64090d32e
Do not show tooltips for <HR> or <IMG>s in gtkimhtml. Fixes #5480.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22772
diff
changeset
|
2490 | } |
| 8677 | 2491 | } |
| 2492 | ||
| 2493 | gtk_imhtml_insert_html_at_iter(imhtml, text, options, &iter); | |
| 2494 | ||
| 2495 | if (fixins) { | |
| 2496 | gtk_text_buffer_get_iter_at_offset(imhtml->text_buffer, &ins, ins_offset); | |
| 2497 | gtk_text_buffer_move_mark(imhtml->text_buffer, gtk_text_buffer_get_insert(imhtml->text_buffer), &ins); | |
| 2498 | } | |
| 2499 | ||
| 2500 | if (fixsel) { | |
| 2501 | gtk_text_buffer_get_iter_at_offset(imhtml->text_buffer, &sel, sel_offset); | |
| 2502 | gtk_text_buffer_move_mark(imhtml->text_buffer, gtk_text_buffer_get_selection_bound(imhtml->text_buffer), &sel); | |
| 2503 | } | |
| 2504 | ||
| 2505 | if (!(options & GTK_IMHTML_NO_SCROLL)) { | |
| 12553 | 2506 | gtk_imhtml_scroll_to_end(imhtml, (options & GTK_IMHTML_USE_SMOOTHSCROLLING)); |
| 8677 | 2507 | } |
| 2508 | } | |
| 2509 | ||
| 11006 | 2510 | #define MAX_SCROLL_TIME 0.4 /* seconds */ |
| 2511 | #define SCROLL_DELAY 33 /* milliseconds */ | |
| 2512 | ||
| 2513 | /* | |
| 2514 | * Smoothly scroll a GtkIMHtml. | |
| 2515 | * | |
| 2516 | * @return TRUE if the window needs to be scrolled further, FALSE if we're at the bottom. | |
| 2517 | */ | |
|
28940
e0f3781f6397
Fix scrolling bug for very busy chat rooms.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28935
diff
changeset
|
2518 | static gboolean smooth_scroll_cb(gpointer data) |
| 10798 | 2519 | { |
| 2520 | GtkIMHtml *imhtml = data; | |
| 2521 | GtkAdjustment *adj = GTK_TEXT_VIEW(imhtml)->vadjustment; | |
| 11006 | 2522 | gdouble max_val = adj->upper - adj->page_size; |
|
19055
43f5771c45f4
Eliminate some unnecessary scrolling activity.
Daniel Atallah <datallah@pidgin.im>
parents:
18985
diff
changeset
|
2523 | gdouble scroll_val = gtk_adjustment_get_value(adj) + ((max_val - gtk_adjustment_get_value(adj)) / 3); |
| 11006 | 2524 | |
| 2525 | g_return_val_if_fail(imhtml->scroll_time != NULL, FALSE); | |
| 2526 | ||
|
19055
43f5771c45f4
Eliminate some unnecessary scrolling activity.
Daniel Atallah <datallah@pidgin.im>
parents:
18985
diff
changeset
|
2527 | if (g_timer_elapsed(imhtml->scroll_time, NULL) > MAX_SCROLL_TIME || scroll_val >= max_val) { |
| 11006 | 2528 | /* time's up. jump to the end and kill the timer */ |
| 2529 | gtk_adjustment_set_value(adj, max_val); | |
| 10798 | 2530 | g_timer_destroy(imhtml->scroll_time); |
| 2531 | imhtml->scroll_time = NULL; | |
|
28940
e0f3781f6397
Fix scrolling bug for very busy chat rooms.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28935
diff
changeset
|
2532 | g_source_remove(imhtml->scroll_src); |
|
e0f3781f6397
Fix scrolling bug for very busy chat rooms.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28935
diff
changeset
|
2533 | imhtml->scroll_src = 0; |
| 10798 | 2534 | return FALSE; |
| 11006 | 2535 | } |
| 2536 | ||
| 2537 | /* scroll by 1/3rd the remaining distance */ | |
|
19055
43f5771c45f4
Eliminate some unnecessary scrolling activity.
Daniel Atallah <datallah@pidgin.im>
parents:
18985
diff
changeset
|
2538 | gtk_adjustment_set_value(adj, scroll_val); |
| 11006 | 2539 | return TRUE; |
| 10798 | 2540 | } |
| 2541 | ||
| 12553 | 2542 | static gboolean scroll_idle_cb(gpointer data) |
| 2543 | { | |
| 2544 | GtkIMHtml *imhtml = data; | |
| 2545 | GtkAdjustment *adj = GTK_TEXT_VIEW(imhtml)->vadjustment; | |
| 2546 | if(adj) { | |
| 2547 | gtk_adjustment_set_value(adj, adj->upper - adj->page_size); | |
| 2548 | } | |
| 2549 | imhtml->scroll_src = 0; | |
| 2550 | return FALSE; | |
| 2551 | } | |
| 2552 | ||
| 2553 | void gtk_imhtml_scroll_to_end(GtkIMHtml *imhtml, gboolean smooth) | |
| 8729 | 2554 | { |
| 10798 | 2555 | if (imhtml->scroll_time) |
| 2556 | g_timer_destroy(imhtml->scroll_time); | |
| 2557 | if (imhtml->scroll_src) | |
| 2558 | g_source_remove(imhtml->scroll_src); | |
| 12553 | 2559 | if(smooth) { |
| 2560 | imhtml->scroll_time = g_timer_new(); | |
|
28940
e0f3781f6397
Fix scrolling bug for very busy chat rooms.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28935
diff
changeset
|
2561 | imhtml->scroll_src = g_timeout_add_full(G_PRIORITY_LOW, SCROLL_DELAY, smooth_scroll_cb, imhtml, NULL); |
| 12553 | 2562 | } else { |
| 2563 | imhtml->scroll_time = NULL; | |
| 2564 | imhtml->scroll_src = g_idle_add_full(G_PRIORITY_LOW, scroll_idle_cb, imhtml, NULL); | |
| 2565 | } | |
| 8729 | 2566 | } |
| 2567 | ||
|
24509
afdf30801940
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <datallah@pidgin.im>
parents:
24392
diff
changeset
|
2568 | /* CSS colors are either rgb (x,y,z) or #hex |
|
afdf30801940
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <datallah@pidgin.im>
parents:
24392
diff
changeset
|
2569 | * we need to convert to hex if it is RGB */ |
|
afdf30801940
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <datallah@pidgin.im>
parents:
24392
diff
changeset
|
2570 | static gchar* |
|
afdf30801940
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <datallah@pidgin.im>
parents:
24392
diff
changeset
|
2571 | parse_css_color(gchar *in_color) |
|
afdf30801940
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <datallah@pidgin.im>
parents:
24392
diff
changeset
|
2572 | { |
|
afdf30801940
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <datallah@pidgin.im>
parents:
24392
diff
changeset
|
2573 | char *tmp = in_color; |
|
afdf30801940
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <datallah@pidgin.im>
parents:
24392
diff
changeset
|
2574 | |
|
24510
925061f2b31e
Make the CSS rgb() color parsing more robust. khc noted that it wouldn't work
Daniel Atallah <datallah@pidgin.im>
parents:
24509
diff
changeset
|
2575 | if (*tmp == 'r' && *(++tmp) == 'g' && *(++tmp) == 'b' && *(++tmp)) { |
|
24509
afdf30801940
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <datallah@pidgin.im>
parents:
24392
diff
changeset
|
2576 | int rgbval[] = {0, 0, 0}; |
|
afdf30801940
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <datallah@pidgin.im>
parents:
24392
diff
changeset
|
2577 | int count = 0; |
|
afdf30801940
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <datallah@pidgin.im>
parents:
24392
diff
changeset
|
2578 | const char *v_start; |
|
afdf30801940
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <datallah@pidgin.im>
parents:
24392
diff
changeset
|
2579 | |
|
24510
925061f2b31e
Make the CSS rgb() color parsing more robust. khc noted that it wouldn't work
Daniel Atallah <datallah@pidgin.im>
parents:
24509
diff
changeset
|
2580 | while (*tmp && g_ascii_isspace(*tmp)) |
|
925061f2b31e
Make the CSS rgb() color parsing more robust. khc noted that it wouldn't work
Daniel Atallah <datallah@pidgin.im>
parents:
24509
diff
changeset
|
2581 | tmp++; |
|
925061f2b31e
Make the CSS rgb() color parsing more robust. khc noted that it wouldn't work
Daniel Atallah <datallah@pidgin.im>
parents:
24509
diff
changeset
|
2582 | if (*tmp != '(') { |
|
925061f2b31e
Make the CSS rgb() color parsing more robust. khc noted that it wouldn't work
Daniel Atallah <datallah@pidgin.im>
parents:
24509
diff
changeset
|
2583 | /* We don't support rgba() */ |
|
925061f2b31e
Make the CSS rgb() color parsing more robust. khc noted that it wouldn't work
Daniel Atallah <datallah@pidgin.im>
parents:
24509
diff
changeset
|
2584 | purple_debug_warning("gtkimhtml", "Invalid rgb CSS color in '%s'!\n", in_color); |
|
925061f2b31e
Make the CSS rgb() color parsing more robust. khc noted that it wouldn't work
Daniel Atallah <datallah@pidgin.im>
parents:
24509
diff
changeset
|
2585 | return in_color; |
|
925061f2b31e
Make the CSS rgb() color parsing more robust. khc noted that it wouldn't work
Daniel Atallah <datallah@pidgin.im>
parents:
24509
diff
changeset
|
2586 | } |
|
925061f2b31e
Make the CSS rgb() color parsing more robust. khc noted that it wouldn't work
Daniel Atallah <datallah@pidgin.im>
parents:
24509
diff
changeset
|
2587 | tmp++; |
|
925061f2b31e
Make the CSS rgb() color parsing more robust. khc noted that it wouldn't work
Daniel Atallah <datallah@pidgin.im>
parents:
24509
diff
changeset
|
2588 | |
|
24509
afdf30801940
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <datallah@pidgin.im>
parents:
24392
diff
changeset
|
2589 | while (count < 3) { |
|
afdf30801940
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <datallah@pidgin.im>
parents:
24392
diff
changeset
|
2590 | /* Skip any leading spaces */ |
|
afdf30801940
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <datallah@pidgin.im>
parents:
24392
diff
changeset
|
2591 | while (*tmp && g_ascii_isspace(*tmp)) |
|
afdf30801940
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <datallah@pidgin.im>
parents:
24392
diff
changeset
|
2592 | tmp++; |
|
afdf30801940
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <datallah@pidgin.im>
parents:
24392
diff
changeset
|
2593 | |
|
afdf30801940
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <datallah@pidgin.im>
parents:
24392
diff
changeset
|
2594 | /* Find the subsequent contiguous digits */ |
|
afdf30801940
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <datallah@pidgin.im>
parents:
24392
diff
changeset
|
2595 | v_start = tmp; |
|
24510
925061f2b31e
Make the CSS rgb() color parsing more robust. khc noted that it wouldn't work
Daniel Atallah <datallah@pidgin.im>
parents:
24509
diff
changeset
|
2596 | if (*v_start == '-') |
|
925061f2b31e
Make the CSS rgb() color parsing more robust. khc noted that it wouldn't work
Daniel Atallah <datallah@pidgin.im>
parents:
24509
diff
changeset
|
2597 | tmp++; |
|
24509
afdf30801940
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <datallah@pidgin.im>
parents:
24392
diff
changeset
|
2598 | while (*tmp && g_ascii_isdigit(*tmp)) |
|
afdf30801940
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <datallah@pidgin.im>
parents:
24392
diff
changeset
|
2599 | tmp++; |
|
afdf30801940
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <datallah@pidgin.im>
parents:
24392
diff
changeset
|
2600 | |
|
afdf30801940
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <datallah@pidgin.im>
parents:
24392
diff
changeset
|
2601 | if (tmp != v_start) { |
|
afdf30801940
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <datallah@pidgin.im>
parents:
24392
diff
changeset
|
2602 | char prev = *tmp; |
|
afdf30801940
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <datallah@pidgin.im>
parents:
24392
diff
changeset
|
2603 | *tmp = '\0'; |
|
afdf30801940
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <datallah@pidgin.im>
parents:
24392
diff
changeset
|
2604 | rgbval[count] = atoi(v_start); |
|
afdf30801940
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <datallah@pidgin.im>
parents:
24392
diff
changeset
|
2605 | *tmp = prev; |
|
afdf30801940
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <datallah@pidgin.im>
parents:
24392
diff
changeset
|
2606 | |
|
afdf30801940
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <datallah@pidgin.im>
parents:
24392
diff
changeset
|
2607 | /* deal with % */ |
|
afdf30801940
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <datallah@pidgin.im>
parents:
24392
diff
changeset
|
2608 | while (*tmp && g_ascii_isspace(*tmp)) |
|
afdf30801940
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <datallah@pidgin.im>
parents:
24392
diff
changeset
|
2609 | tmp++; |
|
afdf30801940
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <datallah@pidgin.im>
parents:
24392
diff
changeset
|
2610 | if (*tmp == '%') { |
|
afdf30801940
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <datallah@pidgin.im>
parents:
24392
diff
changeset
|
2611 | rgbval[count] = (rgbval[count] / 100.0) * 255; |
|
afdf30801940
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <datallah@pidgin.im>
parents:
24392
diff
changeset
|
2612 | tmp++; |
|
afdf30801940
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <datallah@pidgin.im>
parents:
24392
diff
changeset
|
2613 | } |
|
afdf30801940
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <datallah@pidgin.im>
parents:
24392
diff
changeset
|
2614 | } else { |
|
afdf30801940
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <datallah@pidgin.im>
parents:
24392
diff
changeset
|
2615 | purple_debug_warning("gtkimhtml", "Invalid rgb CSS color in '%s'!\n", in_color); |
|
afdf30801940
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <datallah@pidgin.im>
parents:
24392
diff
changeset
|
2616 | return in_color; |
|
afdf30801940
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <datallah@pidgin.im>
parents:
24392
diff
changeset
|
2617 | } |
|
afdf30801940
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <datallah@pidgin.im>
parents:
24392
diff
changeset
|
2618 | |
|
afdf30801940
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <datallah@pidgin.im>
parents:
24392
diff
changeset
|
2619 | if (rgbval[count] > 255) { |
|
afdf30801940
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <datallah@pidgin.im>
parents:
24392
diff
changeset
|
2620 | rgbval[count] = 255; |
|
afdf30801940
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <datallah@pidgin.im>
parents:
24392
diff
changeset
|
2621 | } else if (rgbval[count] < 0) { |
|
afdf30801940
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <datallah@pidgin.im>
parents:
24392
diff
changeset
|
2622 | rgbval[count] = 0; |
|
afdf30801940
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <datallah@pidgin.im>
parents:
24392
diff
changeset
|
2623 | } |
|
afdf30801940
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <datallah@pidgin.im>
parents:
24392
diff
changeset
|
2624 | |
|
afdf30801940
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <datallah@pidgin.im>
parents:
24392
diff
changeset
|
2625 | while (*tmp && g_ascii_isspace(*tmp)) |
|
afdf30801940
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <datallah@pidgin.im>
parents:
24392
diff
changeset
|
2626 | tmp++; |
|
afdf30801940
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <datallah@pidgin.im>
parents:
24392
diff
changeset
|
2627 | if (*tmp == ',') |
|
afdf30801940
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <datallah@pidgin.im>
parents:
24392
diff
changeset
|
2628 | tmp++; |
|
afdf30801940
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <datallah@pidgin.im>
parents:
24392
diff
changeset
|
2629 | |
|
afdf30801940
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <datallah@pidgin.im>
parents:
24392
diff
changeset
|
2630 | count++; |
|
afdf30801940
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <datallah@pidgin.im>
parents:
24392
diff
changeset
|
2631 | } |
|
25888
d0fdd378a635
Remove trailing whitespace
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
2632 | |
|
24509
afdf30801940
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <datallah@pidgin.im>
parents:
24392
diff
changeset
|
2633 | g_free(in_color); |
|
afdf30801940
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <datallah@pidgin.im>
parents:
24392
diff
changeset
|
2634 | return g_strdup_printf("#%02X%02X%02X", rgbval[0], rgbval[1], rgbval[2]); |
|
afdf30801940
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <datallah@pidgin.im>
parents:
24392
diff
changeset
|
2635 | } |
|
afdf30801940
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <datallah@pidgin.im>
parents:
24392
diff
changeset
|
2636 | |
|
afdf30801940
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <datallah@pidgin.im>
parents:
24392
diff
changeset
|
2637 | return in_color; |
|
afdf30801940
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <datallah@pidgin.im>
parents:
24392
diff
changeset
|
2638 | } |
|
afdf30801940
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <datallah@pidgin.im>
parents:
24392
diff
changeset
|
2639 | |
| 8677 | 2640 | void gtk_imhtml_insert_html_at_iter(GtkIMHtml *imhtml, |
| 2641 | const gchar *text, | |
| 2642 | GtkIMHtmlOptions options, | |
| 2643 | GtkTextIter *iter) | |
| 2644 | { | |
| 8061 | 2645 | GdkRectangle rect; |
|
2856
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2646 | gint pos = 0; |
| 3922 | 2647 | gchar *ws; |
|
2856
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2648 | gchar *tag; |
| 3922 | 2649 | gchar *bg = NULL; |
|
6982
12f08de92674
[gaim-migrate @ 7538]
Mark Doliner <markdoliner@pidgin.im>
parents:
6882
diff
changeset
|
2650 | gint len; |
| 4032 | 2651 | gint tlen, smilelen, wpos=0; |
|
2856
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2652 | gint type; |
| 3922 | 2653 | const gchar *c; |
|
16143
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
2654 | const gchar *amp; |
| 8334 | 2655 | gint len_protocol; |
| 15379 | 2656 | |
| 1428 | 2657 | guint bold = 0, |
| 2658 | italics = 0, | |
| 2659 | underline = 0, | |
| 2660 | strike = 0, | |
| 2661 | sub = 0, | |
| 2662 | sup = 0, | |
|
1691
c8bd41036372
[gaim-migrate @ 1701]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
1647
diff
changeset
|
2663 | title = 0, |
| 8061 | 2664 | pre = 0; |
| 1428 | 2665 | |
| 10217 | 2666 | gboolean br = FALSE; |
|
16143
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
2667 | gboolean align_right = FALSE; |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
2668 | gboolean rtl_direction = FALSE; |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
2669 | gint align_line = 0; |
| 15420 | 2670 | |
| 3922 | 2671 | GSList *fonts = NULL; |
| 8506 | 2672 | GObject *object; |
| 8061 | 2673 | GtkIMHtmlScalable *scalable = NULL; |
| 8677 | 2674 | |
| 2675 | g_return_if_fail (imhtml != NULL); | |
| 2676 | g_return_if_fail (GTK_IS_IMHTML (imhtml)); | |
| 2677 | g_return_if_fail (text != NULL); | |
| 3922 | 2678 | c = text; |
|
6982
12f08de92674
[gaim-migrate @ 7538]
Mark Doliner <markdoliner@pidgin.im>
parents:
6882
diff
changeset
|
2679 | len = strlen(text); |
| 3922 | 2680 | ws = g_malloc(len + 1); |
|
25007
ef8bc1f4a6ba
Pass only the URL scheme to gtkimhtml and let it add the colon automatically.
Richard Laager <rlaager@pidgin.im>
parents:
24698
diff
changeset
|
2681 | ws[0] = '\0'; |
| 1428 | 2682 | |
|
22834
1394e7efb818
Smiley insertions can be undone with this fix. References #5577. But redo
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22810
diff
changeset
|
2683 | gtk_text_buffer_begin_user_action(imhtml->text_buffer); |
|
2856
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2684 | while (pos < len) { |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2685 | if (*c == '<' && gtk_imhtml_is_tag (c + 1, &tag, &tlen, &type)) { |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2686 | c++; |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2687 | pos++; |
| 8061 | 2688 | ws[wpos] = '\0'; |
| 10217 | 2689 | br = FALSE; |
| 8061 | 2690 | switch (type) |
| 3922 | 2691 | { |
| 2692 | case 1: /* B */ | |
| 2693 | case 2: /* BOLD */ | |
| 5101 | 2694 | case 54: /* STRONG */ |
|
11485
fe334b13d1d0
[gaim-migrate @ 13727]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11385
diff
changeset
|
2695 | if (!(options & GTK_IMHTML_NO_FORMATTING)) { |
|
fe334b13d1d0
[gaim-migrate @ 13727]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11385
diff
changeset
|
2696 | gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos); |
|
fe334b13d1d0
[gaim-migrate @ 13727]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11385
diff
changeset
|
2697 | |
|
fe334b13d1d0
[gaim-migrate @ 13727]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11385
diff
changeset
|
2698 | if ((bold == 0) && (imhtml->format_functions & GTK_IMHTML_BOLD)) |
|
fe334b13d1d0
[gaim-migrate @ 13727]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11385
diff
changeset
|
2699 | gtk_imhtml_toggle_bold(imhtml); |
|
fe334b13d1d0
[gaim-migrate @ 13727]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11385
diff
changeset
|
2700 | bold++; |
|
fe334b13d1d0
[gaim-migrate @ 13727]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11385
diff
changeset
|
2701 | ws[0] = '\0'; wpos = 0; |
|
fe334b13d1d0
[gaim-migrate @ 13727]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11385
diff
changeset
|
2702 | } |
| 3922 | 2703 | break; |
| 2704 | case 3: /* /B */ | |
| 2705 | case 4: /* /BOLD */ | |
| 5101 | 2706 | case 55: /* /STRONG */ |
|
11485
fe334b13d1d0
[gaim-migrate @ 13727]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11385
diff
changeset
|
2707 | if (!(options & GTK_IMHTML_NO_FORMATTING)) { |
|
fe334b13d1d0
[gaim-migrate @ 13727]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11385
diff
changeset
|
2708 | gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos); |
|
fe334b13d1d0
[gaim-migrate @ 13727]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11385
diff
changeset
|
2709 | ws[0] = '\0'; wpos = 0; |
|
fe334b13d1d0
[gaim-migrate @ 13727]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11385
diff
changeset
|
2710 | |
|
14010
a47143a57c82
[gaim-migrate @ 16489]
Gary Kramlich <grim@reaperworld.com>
parents:
13552
diff
changeset
|
2711 | if (bold) { |
|
11485
fe334b13d1d0
[gaim-migrate @ 13727]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11385
diff
changeset
|
2712 | bold--; |
|
14010
a47143a57c82
[gaim-migrate @ 16489]
Gary Kramlich <grim@reaperworld.com>
parents:
13552
diff
changeset
|
2713 | if ((bold == 0) && (imhtml->format_functions & GTK_IMHTML_BOLD) && !imhtml->wbfo) |
|
a47143a57c82
[gaim-migrate @ 16489]
Gary Kramlich <grim@reaperworld.com>
parents:
13552
diff
changeset
|
2714 | gtk_imhtml_toggle_bold(imhtml); |
|
a47143a57c82
[gaim-migrate @ 16489]
Gary Kramlich <grim@reaperworld.com>
parents:
13552
diff
changeset
|
2715 | } |
|
11485
fe334b13d1d0
[gaim-migrate @ 13727]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11385
diff
changeset
|
2716 | } |
| 3922 | 2717 | break; |
| 2718 | case 5: /* I */ | |
| 2719 | case 6: /* ITALIC */ | |
| 5101 | 2720 | case 52: /* EM */ |
|
11485
fe334b13d1d0
[gaim-migrate @ 13727]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11385
diff
changeset
|
2721 | if (!(options & GTK_IMHTML_NO_FORMATTING)) { |
|
fe334b13d1d0
[gaim-migrate @ 13727]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11385
diff
changeset
|
2722 | gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos); |
|
fe334b13d1d0
[gaim-migrate @ 13727]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11385
diff
changeset
|
2723 | ws[0] = '\0'; wpos = 0; |
|
fe334b13d1d0
[gaim-migrate @ 13727]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11385
diff
changeset
|
2724 | if ((italics == 0) && (imhtml->format_functions & GTK_IMHTML_ITALIC)) |
|
fe334b13d1d0
[gaim-migrate @ 13727]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11385
diff
changeset
|
2725 | gtk_imhtml_toggle_italic(imhtml); |
|
fe334b13d1d0
[gaim-migrate @ 13727]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11385
diff
changeset
|
2726 | italics++; |
|
fe334b13d1d0
[gaim-migrate @ 13727]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11385
diff
changeset
|
2727 | } |
| 3922 | 2728 | break; |
| 2729 | case 7: /* /I */ | |
| 2730 | case 8: /* /ITALIC */ | |
| 5101 | 2731 | case 53: /* /EM */ |
|
11485
fe334b13d1d0
[gaim-migrate @ 13727]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11385
diff
changeset
|
2732 | if (!(options & GTK_IMHTML_NO_FORMATTING)) { |
|
fe334b13d1d0
[gaim-migrate @ 13727]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11385
diff
changeset
|
2733 | gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos); |
|
fe334b13d1d0
[gaim-migrate @ 13727]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11385
diff
changeset
|
2734 | ws[0] = '\0'; wpos = 0; |
|
14010
a47143a57c82
[gaim-migrate @ 16489]
Gary Kramlich <grim@reaperworld.com>
parents:
13552
diff
changeset
|
2735 | if (italics) { |
|
11485
fe334b13d1d0
[gaim-migrate @ 13727]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11385
diff
changeset
|
2736 | italics--; |
|
14010
a47143a57c82
[gaim-migrate @ 16489]
Gary Kramlich <grim@reaperworld.com>
parents:
13552
diff
changeset
|
2737 | if ((italics == 0) && (imhtml->format_functions & GTK_IMHTML_ITALIC) && !imhtml->wbfo) |
|
a47143a57c82
[gaim-migrate @ 16489]
Gary Kramlich <grim@reaperworld.com>
parents:
13552
diff
changeset
|
2738 | gtk_imhtml_toggle_italic(imhtml); |
|
a47143a57c82
[gaim-migrate @ 16489]
Gary Kramlich <grim@reaperworld.com>
parents:
13552
diff
changeset
|
2739 | } |
|
11485
fe334b13d1d0
[gaim-migrate @ 13727]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11385
diff
changeset
|
2740 | } |
| 3922 | 2741 | break; |
| 2742 | case 9: /* U */ | |
| 2743 | case 10: /* UNDERLINE */ | |
|
11485
fe334b13d1d0
[gaim-migrate @ 13727]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11385
diff
changeset
|
2744 | if (!(options & GTK_IMHTML_NO_FORMATTING)) { |
|
fe334b13d1d0
[gaim-migrate @ 13727]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11385
diff
changeset
|
2745 | gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos); |
|
fe334b13d1d0
[gaim-migrate @ 13727]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11385
diff
changeset
|
2746 | ws[0] = '\0'; wpos = 0; |
|
fe334b13d1d0
[gaim-migrate @ 13727]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11385
diff
changeset
|
2747 | if ((underline == 0) && (imhtml->format_functions & GTK_IMHTML_UNDERLINE)) |
|
fe334b13d1d0
[gaim-migrate @ 13727]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11385
diff
changeset
|
2748 | gtk_imhtml_toggle_underline(imhtml); |
|
fe334b13d1d0
[gaim-migrate @ 13727]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11385
diff
changeset
|
2749 | underline++; |
|
fe334b13d1d0
[gaim-migrate @ 13727]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11385
diff
changeset
|
2750 | } |
| 3922 | 2751 | break; |
| 2752 | case 11: /* /U */ | |
| 2753 | case 12: /* /UNDERLINE */ | |
|
11485
fe334b13d1d0
[gaim-migrate @ 13727]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11385
diff
changeset
|
2754 | if (!(options & GTK_IMHTML_NO_FORMATTING)) { |
|
fe334b13d1d0
[gaim-migrate @ 13727]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11385
diff
changeset
|
2755 | gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos); |
|
fe334b13d1d0
[gaim-migrate @ 13727]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11385
diff
changeset
|
2756 | ws[0] = '\0'; wpos = 0; |
|
14010
a47143a57c82
[gaim-migrate @ 16489]
Gary Kramlich <grim@reaperworld.com>
parents:
13552
diff
changeset
|
2757 | if (underline) { |
|
11485
fe334b13d1d0
[gaim-migrate @ 13727]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11385
diff
changeset
|
2758 | underline--; |
|
14010
a47143a57c82
[gaim-migrate @ 16489]
Gary Kramlich <grim@reaperworld.com>
parents:
13552
diff
changeset
|
2759 | if ((underline == 0) && (imhtml->format_functions & GTK_IMHTML_UNDERLINE) && !imhtml->wbfo) |
|
a47143a57c82
[gaim-migrate @ 16489]
Gary Kramlich <grim@reaperworld.com>
parents:
13552
diff
changeset
|
2760 | gtk_imhtml_toggle_underline(imhtml); |
|
a47143a57c82
[gaim-migrate @ 16489]
Gary Kramlich <grim@reaperworld.com>
parents:
13552
diff
changeset
|
2761 | } |
|
11485
fe334b13d1d0
[gaim-migrate @ 13727]
Peter Lawler <pidgin@bleeter.id.au>
parents:
11385
diff
changeset
|
2762 | } |
| 3922 | 2763 | break; |
| 2764 | case 13: /* S */ | |
| 2765 | case 14: /* STRIKE */ | |
| 9924 | 2766 | gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos); |
| 2767 | ws[0] = '\0'; wpos = 0; | |
| 2768 | if ((strike == 0) && (imhtml->format_functions & GTK_IMHTML_STRIKE)) | |
| 2769 | gtk_imhtml_toggle_strike(imhtml); | |
| 3922 | 2770 | strike++; |
| 2771 | break; | |
| 2772 | case 15: /* /S */ | |
| 2773 | case 16: /* /STRIKE */ | |
| 9924 | 2774 | gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos); |
| 2775 | ws[0] = '\0'; wpos = 0; | |
| 3922 | 2776 | if (strike) |
| 2777 | strike--; | |
| 9924 | 2778 | if ((strike == 0) && (imhtml->format_functions & GTK_IMHTML_STRIKE) && !imhtml->wbfo) |
| 2779 | gtk_imhtml_toggle_strike(imhtml); | |
| 3922 | 2780 | break; |
| 2781 | case 17: /* SUB */ | |
| 8677 | 2782 | /* FIXME: reimpliment this */ |
| 3922 | 2783 | sub++; |
| 2784 | break; | |
| 2785 | case 18: /* /SUB */ | |
| 8677 | 2786 | /* FIXME: reimpliment this */ |
| 3922 | 2787 | if (sub) |
| 2788 | sub--; | |
| 2789 | break; | |
| 2790 | case 19: /* SUP */ | |
| 8677 | 2791 | /* FIXME: reimplement this */ |
| 3922 | 2792 | sup++; |
|
2856
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2793 | break; |
| 3922 | 2794 | case 20: /* /SUP */ |
| 8677 | 2795 | /* FIXME: reimplement this */ |
| 3922 | 2796 | if (sup) |
| 2797 | sup--; | |
| 2798 | break; | |
| 2799 | case 21: /* PRE */ | |
| 8677 | 2800 | /* FIXME: reimplement this */ |
| 3922 | 2801 | pre++; |
| 2802 | break; | |
| 2803 | case 22: /* /PRE */ | |
| 8677 | 2804 | /* FIXME: reimplement this */ |
| 3922 | 2805 | if (pre) |
| 2806 | pre--; | |
| 2807 | break; | |
| 2808 | case 23: /* TITLE */ | |
| 8677 | 2809 | /* FIXME: what was this supposed to do anyway? */ |
| 3922 | 2810 | title++; |
| 2811 | break; | |
| 2812 | case 24: /* /TITLE */ | |
| 8677 | 2813 | /* FIXME: make this undo whatever 23 was supposed to do */ |
| 3922 | 2814 | if (title) { |
| 2815 | if (options & GTK_IMHTML_NO_TITLE) { | |
| 2816 | wpos = 0; | |
| 2817 | ws [wpos] = '\0'; | |
| 2818 | } | |
| 2819 | title--; | |
|
2856
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2820 | } |
| 3922 | 2821 | break; |
| 2822 | case 25: /* BR */ | |
| 5174 | 2823 | case 58: /* BR/ */ |
| 8061 | 2824 | case 61: /* BR (opt) */ |
| 3922 | 2825 | ws[wpos] = '\n'; |
| 2826 | wpos++; | |
| 10217 | 2827 | br = TRUE; |
|
6982
12f08de92674
[gaim-migrate @ 7538]
Mark Doliner <markdoliner@pidgin.im>
parents:
6882
diff
changeset
|
2828 | break; |
| 3922 | 2829 | case 26: /* HR */ |
| 2830 | case 42: /* HR (opt) */ | |
| 8726 | 2831 | { |
| 2832 | int minus; | |
|
11224
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
2833 | struct scalable_data *sd = g_new(struct scalable_data, 1); |
| 8726 | 2834 | |
| 3922 | 2835 | ws[wpos++] = '\n'; |
| 8677 | 2836 | gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos); |
| 2837 | ||
|
11224
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
2838 | sd->scalable = scalable = gtk_imhtml_hr_new(); |
|
11233
28c0f184a2d4
[gaim-migrate @ 13373]
Daniel Atallah <datallah@pidgin.im>
parents:
11224
diff
changeset
|
2839 | sd->mark = gtk_text_buffer_create_mark(imhtml->text_buffer, NULL, iter, TRUE); |
| 8061 | 2840 | gtk_text_view_get_visible_rect(GTK_TEXT_VIEW(imhtml), &rect); |
| 8677 | 2841 | scalable->add_to(scalable, imhtml, iter); |
| 8726 | 2842 | minus = gtk_text_view_get_left_margin(GTK_TEXT_VIEW(imhtml)) + |
| 2843 | gtk_text_view_get_right_margin(GTK_TEXT_VIEW(imhtml)); | |
| 2844 | scalable->scale(scalable, rect.width - minus, rect.height); | |
|
11224
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
2845 | imhtml->scalables = g_list_append(imhtml->scalables, sd); |
| 8061 | 2846 | ws[0] = '\0'; wpos = 0; |
| 7942 | 2847 | ws[wpos++] = '\n'; |
| 8061 | 2848 | |
| 3922 | 2849 | break; |
| 8726 | 2850 | } |
| 3922 | 2851 | case 27: /* /FONT */ |
| 8677 | 2852 | if (fonts && !imhtml->wbfo) { |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
2853 | GtkIMHtmlFontDetail *font = fonts->data; |
| 8677 | 2854 | gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos); |
| 8061 | 2855 | ws[0] = '\0'; wpos = 0; |
|
8177
33b3a01c6318
[gaim-migrate @ 8891]
Mark Doliner <markdoliner@pidgin.im>
parents:
8149
diff
changeset
|
2856 | /* NEW_BIT (NEW_TEXT_BIT); */ |
| 8677 | 2857 | |
| 8698 | 2858 | if (font->face && (imhtml->format_functions & GTK_IMHTML_FACE)) { |
| 8061 | 2859 | gtk_imhtml_toggle_fontface(imhtml, NULL); |
| 2860 | } | |
|
14821
c91127e2b784
[gaim-migrate @ 17516]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14741
diff
changeset
|
2861 | g_free (font->face); |
| 8698 | 2862 | if (font->fore && (imhtml->format_functions & GTK_IMHTML_FORECOLOR)) { |
| 8061 | 2863 | gtk_imhtml_toggle_forecolor(imhtml, NULL); |
| 2864 | } | |
|
14821
c91127e2b784
[gaim-migrate @ 17516]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14741
diff
changeset
|
2865 | g_free (font->fore); |
| 8698 | 2866 | if (font->back && (imhtml->format_functions & GTK_IMHTML_BACKCOLOR)) { |
| 8061 | 2867 | gtk_imhtml_toggle_backcolor(imhtml, NULL); |
| 2868 | } | |
|
14821
c91127e2b784
[gaim-migrate @ 17516]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14741
diff
changeset
|
2869 | g_free (font->back); |
|
c91127e2b784
[gaim-migrate @ 17516]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14741
diff
changeset
|
2870 | g_free (font->sml); |
| 8309 | 2871 | |
| 8698 | 2872 | if ((font->size != 3) && (imhtml->format_functions & (GTK_IMHTML_GROW|GTK_IMHTML_SHRINK))) |
| 8309 | 2873 | gtk_imhtml_font_set_size(imhtml, 3); |
| 2874 | ||
| 10761 | 2875 | fonts = g_slist_remove (fonts, font); |
| 9245 | 2876 | g_free(font); |
| 2877 | ||
| 8309 | 2878 | if (fonts) { |
| 2879 | GtkIMHtmlFontDetail *font = fonts->data; | |
| 8677 | 2880 | |
| 8698 | 2881 | if (font->face && (imhtml->format_functions & GTK_IMHTML_FACE)) |
| 8309 | 2882 | gtk_imhtml_toggle_fontface(imhtml, font->face); |
| 8698 | 2883 | if (font->fore && (imhtml->format_functions & GTK_IMHTML_FORECOLOR)) |
| 8309 | 2884 | gtk_imhtml_toggle_forecolor(imhtml, font->fore); |
| 8698 | 2885 | if (font->back && (imhtml->format_functions & GTK_IMHTML_BACKCOLOR)) |
| 8309 | 2886 | gtk_imhtml_toggle_backcolor(imhtml, font->back); |
| 8698 | 2887 | if ((font->size != 3) && (imhtml->format_functions & (GTK_IMHTML_GROW|GTK_IMHTML_SHRINK))) |
| 8309 | 2888 | gtk_imhtml_font_set_size(imhtml, font->size); |
| 2889 | } | |
| 3922 | 2890 | } |
| 8309 | 2891 | break; |
| 3922 | 2892 | case 28: /* /A */ |
| 8677 | 2893 | gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos); |
| 2894 | gtk_imhtml_toggle_link(imhtml, NULL); | |
| 2895 | ws[0] = '\0'; wpos = 0; | |
| 8061 | 2896 | break; |
|
8118
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
2897 | |
| 3922 | 2898 | case 29: /* P */ |
| 2899 | case 30: /* /P */ | |
| 2900 | case 31: /* H3 */ | |
| 2901 | case 32: /* /H3 */ | |
| 2902 | case 33: /* HTML */ | |
| 2903 | case 34: /* /HTML */ | |
| 2904 | case 35: /* BODY */ | |
| 10776 | 2905 | break; |
| 3922 | 2906 | case 36: /* /BODY */ |
| 10786 | 2907 | gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos); |
| 2908 | ws[0] = '\0'; wpos = 0; | |
| 10776 | 2909 | gtk_imhtml_toggle_background(imhtml, NULL); |
| 2910 | break; | |
| 3922 | 2911 | case 37: /* FONT */ |
| 2912 | case 38: /* HEAD */ | |
| 2913 | case 39: /* /HEAD */ | |
|
6982
12f08de92674
[gaim-migrate @ 7538]
Mark Doliner <markdoliner@pidgin.im>
parents:
6882
diff
changeset
|
2914 | case 40: /* BINARY */ |
|
12f08de92674
[gaim-migrate @ 7538]
Mark Doliner <markdoliner@pidgin.im>
parents:
6882
diff
changeset
|
2915 | case 41: /* /BINARY */ |
| 3922 | 2916 | break; |
| 2917 | case 43: /* FONT (opt) */ | |
| 2918 | { | |
| 4032 | 2919 | gchar *color, *back, *face, *size, *sml; |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
2920 | GtkIMHtmlFontDetail *font, *oldfont = NULL; |
| 3922 | 2921 | color = gtk_imhtml_get_html_opt (tag, "COLOR="); |
| 2922 | back = gtk_imhtml_get_html_opt (tag, "BACK="); | |
| 2923 | face = gtk_imhtml_get_html_opt (tag, "FACE="); | |
| 2924 | size = gtk_imhtml_get_html_opt (tag, "SIZE="); | |
| 4032 | 2925 | sml = gtk_imhtml_get_html_opt (tag, "SML="); |
| 2926 | if (!(color || back || face || size || sml)) | |
| 3922 | 2927 | break; |
| 8061 | 2928 | |
| 8677 | 2929 | gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos); |
| 8061 | 2930 | ws[0] = '\0'; wpos = 0; |
| 2931 | ||
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
2932 | font = g_new0 (GtkIMHtmlFontDetail, 1); |
| 3922 | 2933 | if (fonts) |
| 2934 | oldfont = fonts->data; | |
|
2856
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2935 | |
| 8677 | 2936 | if (color && !(options & GTK_IMHTML_NO_COLOURS) && (imhtml->format_functions & GTK_IMHTML_FORECOLOR)) { |
| 3922 | 2937 | font->fore = color; |
| 8061 | 2938 | gtk_imhtml_toggle_forecolor(imhtml, font->fore); |
|
14821
c91127e2b784
[gaim-migrate @ 17516]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14741
diff
changeset
|
2939 | } else |
|
c91127e2b784
[gaim-migrate @ 17516]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14741
diff
changeset
|
2940 | g_free(color); |
| 8677 | 2941 | |
| 2942 | if (back && !(options & GTK_IMHTML_NO_COLOURS) && (imhtml->format_functions & GTK_IMHTML_BACKCOLOR)) { | |
| 3922 | 2943 | font->back = back; |
| 8061 | 2944 | gtk_imhtml_toggle_backcolor(imhtml, font->back); |
|
14821
c91127e2b784
[gaim-migrate @ 17516]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14741
diff
changeset
|
2945 | } else |
|
c91127e2b784
[gaim-migrate @ 17516]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14741
diff
changeset
|
2946 | g_free(back); |
| 8677 | 2947 | |
| 2948 | if (face && !(options & GTK_IMHTML_NO_FONTS) && (imhtml->format_functions & GTK_IMHTML_FACE)) { | |
| 3922 | 2949 | font->face = face; |
| 8061 | 2950 | gtk_imhtml_toggle_fontface(imhtml, font->face); |
|
14821
c91127e2b784
[gaim-migrate @ 17516]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14741
diff
changeset
|
2951 | } else |
|
c91127e2b784
[gaim-migrate @ 17516]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14741
diff
changeset
|
2952 | g_free(face); |
| 4032 | 2953 | |
| 2954 | if (sml) | |
| 2955 | font->sml = sml; | |
|
22810
ede0b51be7c3
Patch from Gaul to plug a small leak, with an additional fix to free
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22803
diff
changeset
|
2956 | else { |
|
ede0b51be7c3
Patch from Gaul to plug a small leak, with an additional fix to free
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22803
diff
changeset
|
2957 | g_free(sml); |
|
ede0b51be7c3
Patch from Gaul to plug a small leak, with an additional fix to free
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22803
diff
changeset
|
2958 | if (oldfont && oldfont->sml) |
|
ede0b51be7c3
Patch from Gaul to plug a small leak, with an additional fix to free
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22803
diff
changeset
|
2959 | font->sml = g_strdup(oldfont->sml); |
|
ede0b51be7c3
Patch from Gaul to plug a small leak, with an additional fix to free
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22803
diff
changeset
|
2960 | } |
| 4032 | 2961 | |
| 8677 | 2962 | if (size && !(options & GTK_IMHTML_NO_SIZES) && (imhtml->format_functions & (GTK_IMHTML_GROW|GTK_IMHTML_SHRINK))) { |
| 3922 | 2963 | if (*size == '+') { |
| 2964 | sscanf (size + 1, "%hd", &font->size); | |
| 2965 | font->size += 3; | |
| 2966 | } else if (*size == '-') { | |
| 2967 | sscanf (size + 1, "%hd", &font->size); | |
| 2968 | font->size = MAX (0, 3 - font->size); | |
| 2969 | } else if (isdigit (*size)) { | |
| 2970 | sscanf (size, "%hd", &font->size); | |
|
14821
c91127e2b784
[gaim-migrate @ 17516]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14741
diff
changeset
|
2971 | } |
|
6042
e329fe962c9a
[gaim-migrate @ 6492]
Mark Doliner <markdoliner@pidgin.im>
parents:
5967
diff
changeset
|
2972 | if (font->size > 100) |
|
e329fe962c9a
[gaim-migrate @ 6492]
Mark Doliner <markdoliner@pidgin.im>
parents:
5967
diff
changeset
|
2973 | font->size = 100; |
| 3922 | 2974 | } else if (oldfont) |
| 2975 | font->size = oldfont->size; | |
| 8309 | 2976 | else |
| 2977 | font->size = 3; | |
|
28144
fd25bc3ab207
imhtml: When inserting html, only set a font if it's a change from the default. Fixes #7648.
Paul Aurich <darkrain42@pidgin.im>
parents:
28077
diff
changeset
|
2978 | if ((imhtml->format_functions & (GTK_IMHTML_GROW|GTK_IMHTML_SHRINK)) && (font->size != 3 || (oldfont && oldfont->size == 3))) |
| 8698 | 2979 | gtk_imhtml_font_set_size(imhtml, font->size); |
| 3922 | 2980 | g_free(size); |
| 2981 | fonts = g_slist_prepend (fonts, font); | |
| 2982 | } | |
| 2983 | break; | |
| 2984 | case 44: /* BODY (opt) */ | |
| 2985 | if (!(options & GTK_IMHTML_NO_COLOURS)) { | |
| 2986 | char *bgcolor = gtk_imhtml_get_html_opt (tag, "BGCOLOR="); | |
| 8677 | 2987 | if (bgcolor && (imhtml->format_functions & GTK_IMHTML_BACKCOLOR)) { |
| 2988 | gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos); | |
| 8061 | 2989 | ws[0] = '\0'; wpos = 0; |
|
8177
33b3a01c6318
[gaim-migrate @ 8891]
Mark Doliner <markdoliner@pidgin.im>
parents:
8149
diff
changeset
|
2990 | /* NEW_BIT(NEW_TEXT_BIT); */ |
|
14097
0c340861ab79
[gaim-migrate @ 16638]
Mark Doliner <markdoliner@pidgin.im>
parents:
14010
diff
changeset
|
2991 | g_free(bg); |
| 3922 | 2992 | bg = bgcolor; |
| 10776 | 2993 | gtk_imhtml_toggle_background(imhtml, bg); |
|
14821
c91127e2b784
[gaim-migrate @ 17516]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14741
diff
changeset
|
2994 | } else |
|
c91127e2b784
[gaim-migrate @ 17516]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14741
diff
changeset
|
2995 | g_free(bgcolor); |
| 1428 | 2996 | } |
|
2856
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
2997 | break; |
| 3922 | 2998 | case 45: /* A (opt) */ |
| 2999 | { | |
| 3000 | gchar *href = gtk_imhtml_get_html_opt (tag, "HREF="); | |
| 8677 | 3001 | if (href && (imhtml->format_functions & GTK_IMHTML_LINK)) { |
| 3002 | gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos); | |
| 8061 | 3003 | ws[0] = '\0'; wpos = 0; |
| 8677 | 3004 | gtk_imhtml_toggle_link(imhtml, href); |
| 3922 | 3005 | } |
|
14097
0c340861ab79
[gaim-migrate @ 16638]
Mark Doliner <markdoliner@pidgin.im>
parents:
14010
diff
changeset
|
3006 | g_free(href); |
| 2993 | 3007 | } |
| 3922 | 3008 | break; |
| 4895 | 3009 | case 46: /* IMG (opt) */ |
|
6982
12f08de92674
[gaim-migrate @ 7538]
Mark Doliner <markdoliner@pidgin.im>
parents:
6882
diff
changeset
|
3010 | case 59: /* IMG */ |
| 4895 | 3011 | { |
|
22810
ede0b51be7c3
Patch from Gaul to plug a small leak, with an additional fix to free
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22803
diff
changeset
|
3012 | char *id; |
| 8962 | 3013 | |
| 3014 | gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos); | |
| 3015 | ws[0] = '\0'; wpos = 0; | |
| 4895 | 3016 | |
| 8677 | 3017 | if (!(imhtml->format_functions & GTK_IMHTML_IMAGE)) |
| 3018 | break; | |
| 3019 | ||
| 8962 | 3020 | id = gtk_imhtml_get_html_opt(tag, "ID="); |
|
27359
3d884bc7b99e
Transform id-less <img> tags to links using src and alt attributes.
Dmitry Petroff <dmitry.petroff@gmail.com>
parents:
27259
diff
changeset
|
3021 | if (id) { |
|
3d884bc7b99e
Transform id-less <img> tags to links using src and alt attributes.
Dmitry Petroff <dmitry.petroff@gmail.com>
parents:
27259
diff
changeset
|
3022 | gtk_imhtml_insert_image_at_iter(imhtml, atoi(id), iter); |
|
3d884bc7b99e
Transform id-less <img> tags to links using src and alt attributes.
Dmitry Petroff <dmitry.petroff@gmail.com>
parents:
27259
diff
changeset
|
3023 | g_free(id); |
|
3d884bc7b99e
Transform id-less <img> tags to links using src and alt attributes.
Dmitry Petroff <dmitry.petroff@gmail.com>
parents:
27259
diff
changeset
|
3024 | } else { |
|
3d884bc7b99e
Transform id-less <img> tags to links using src and alt attributes.
Dmitry Petroff <dmitry.petroff@gmail.com>
parents:
27259
diff
changeset
|
3025 | char *src, *alt; |
|
3d884bc7b99e
Transform id-less <img> tags to links using src and alt attributes.
Dmitry Petroff <dmitry.petroff@gmail.com>
parents:
27259
diff
changeset
|
3026 | src = gtk_imhtml_get_html_opt(tag, "SRC="); |
|
3d884bc7b99e
Transform id-less <img> tags to links using src and alt attributes.
Dmitry Petroff <dmitry.petroff@gmail.com>
parents:
27259
diff
changeset
|
3027 | alt = gtk_imhtml_get_html_opt(tag, "ALT="); |
|
3d884bc7b99e
Transform id-less <img> tags to links using src and alt attributes.
Dmitry Petroff <dmitry.petroff@gmail.com>
parents:
27259
diff
changeset
|
3028 | if (src) { |
|
3d884bc7b99e
Transform id-less <img> tags to links using src and alt attributes.
Dmitry Petroff <dmitry.petroff@gmail.com>
parents:
27259
diff
changeset
|
3029 | gtk_imhtml_toggle_link(imhtml, src); |
|
3d884bc7b99e
Transform id-less <img> tags to links using src and alt attributes.
Dmitry Petroff <dmitry.petroff@gmail.com>
parents:
27259
diff
changeset
|
3030 | gtk_text_buffer_insert(imhtml->text_buffer, iter, alt ? alt : src, -1); |
|
3d884bc7b99e
Transform id-less <img> tags to links using src and alt attributes.
Dmitry Petroff <dmitry.petroff@gmail.com>
parents:
27259
diff
changeset
|
3031 | gtk_imhtml_toggle_link(imhtml, NULL); |
|
3d884bc7b99e
Transform id-less <img> tags to links using src and alt attributes.
Dmitry Petroff <dmitry.petroff@gmail.com>
parents:
27259
diff
changeset
|
3032 | } |
|
3d884bc7b99e
Transform id-less <img> tags to links using src and alt attributes.
Dmitry Petroff <dmitry.petroff@gmail.com>
parents:
27259
diff
changeset
|
3033 | g_free (src); |
|
3d884bc7b99e
Transform id-less <img> tags to links using src and alt attributes.
Dmitry Petroff <dmitry.petroff@gmail.com>
parents:
27259
diff
changeset
|
3034 | g_free (alt); |
|
3d884bc7b99e
Transform id-less <img> tags to links using src and alt attributes.
Dmitry Petroff <dmitry.petroff@gmail.com>
parents:
27259
diff
changeset
|
3035 | } |
| 8962 | 3036 | break; |
| 4895 | 3037 | } |
| 3922 | 3038 | case 47: /* P (opt) */ |
| 3039 | case 48: /* H3 (opt) */ | |
| 5093 | 3040 | case 49: /* HTML (opt) */ |
| 5101 | 3041 | case 50: /* CITE */ |
| 3042 | case 51: /* /CITE */ | |
| 8026 | 3043 | case 56: /* SPAN (opt) */ |
|
8118
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
3044 | /* Inline CSS Support - Douglas Thrift |
|
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
3045 | * |
|
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
3046 | * color |
| 8686 | 3047 | * background |
|
8118
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
3048 | * font-family |
|
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
3049 | * font-size |
| 8686 | 3050 | * text-decoration: underline |
| 14395 | 3051 | * font-weight: bold |
|
16143
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
3052 | * direction: rtl |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
3053 | * text-align: right |
| 10483 | 3054 | * |
| 3055 | * TODO: | |
| 3056 | * background-color | |
| 3057 | * font-style | |
|
8118
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
3058 | */ |
|
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
3059 | { |
|
16143
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
3060 | gchar *style, *color, *background, *family, *size, *direction, *alignment; |
| 14395 | 3061 | gchar *textdec, *weight; |
|
8118
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
3062 | GtkIMHtmlFontDetail *font, *oldfont = NULL; |
|
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
3063 | style = gtk_imhtml_get_html_opt (tag, "style="); |
|
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
3064 | |
|
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
3065 | if (!style) break; |
|
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
3066 | |
|
16143
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
3067 | color = purple_markup_get_css_property (style, "color"); |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
3068 | background = purple_markup_get_css_property (style, "background"); |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
3069 | family = purple_markup_get_css_property (style, "font-family"); |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
3070 | size = purple_markup_get_css_property (style, "font-size"); |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
3071 | textdec = purple_markup_get_css_property (style, "text-decoration"); |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
3072 | weight = purple_markup_get_css_property (style, "font-weight"); |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
3073 | direction = purple_markup_get_css_property (style, "direction"); |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
3074 | alignment = purple_markup_get_css_property (style, "text-align"); |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
3075 | |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
3076 | |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
3077 | if (!(color || family || size || background || textdec || weight || direction || alignment)) { |
| 8120 | 3078 | g_free(style); |
| 3079 | break; | |
| 3080 | } | |
|
8118
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
3081 | |
| 8677 | 3082 | |
| 3083 | gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos); | |
|
8118
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
3084 | ws[0] = '\0'; wpos = 0; |
|
8177
33b3a01c6318
[gaim-migrate @ 8891]
Mark Doliner <markdoliner@pidgin.im>
parents:
8149
diff
changeset
|
3085 | /* NEW_BIT (NEW_TEXT_BIT); */ |
|
8118
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
3086 | |
|
16143
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
3087 | /* Bi-Directional text support */ |
|
18552
810a338ef085
Use the glib strcasecmp functions everywhere, as we've had reports of
Richard Laager <rlaager@pidgin.im>
parents:
18543
diff
changeset
|
3088 | if (direction && (!g_ascii_strncasecmp(direction, "RTL", 3))) { |
|
16143
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
3089 | rtl_direction = TRUE; |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
3090 | /* insert RLE character to set direction */ |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
3091 | ws[wpos++] = 0xE2; |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
3092 | ws[wpos++] = 0x80; |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
3093 | ws[wpos++] = 0xAB; |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
3094 | ws[wpos] = '\0'; |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
3095 | gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos); |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
3096 | ws[0] = '\0'; wpos = 0; |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
3097 | } |
| 16144 | 3098 | g_free(direction); |
| 3099 | ||
|
18552
810a338ef085
Use the glib strcasecmp functions everywhere, as we've had reports of
Richard Laager <rlaager@pidgin.im>
parents:
18543
diff
changeset
|
3100 | if (alignment && (!g_ascii_strncasecmp(alignment, "RIGHT", 5))) { |
|
16143
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
3101 | align_right = TRUE; |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
3102 | align_line = gtk_text_iter_get_line(iter); |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
3103 | } |
| 16144 | 3104 | g_free(alignment); |
|
16143
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
3105 | |
|
8118
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
3106 | font = g_new0 (GtkIMHtmlFontDetail, 1); |
|
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
3107 | if (fonts) |
|
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
3108 | oldfont = fonts->data; |
|
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
3109 | |
|
14821
c91127e2b784
[gaim-migrate @ 17516]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14741
diff
changeset
|
3110 | if (color && !(options & GTK_IMHTML_NO_COLOURS) && (imhtml->format_functions & GTK_IMHTML_FORECOLOR)) { |
|
24509
afdf30801940
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <datallah@pidgin.im>
parents:
24392
diff
changeset
|
3111 | font->fore = parse_css_color(color); |
| 8686 | 3112 | gtk_imhtml_toggle_forecolor(imhtml, font->fore); |
|
14821
c91127e2b784
[gaim-migrate @ 17516]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14741
diff
changeset
|
3113 | } else { |
|
c91127e2b784
[gaim-migrate @ 17516]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14741
diff
changeset
|
3114 | if (oldfont && oldfont->fore) |
|
c91127e2b784
[gaim-migrate @ 17516]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14741
diff
changeset
|
3115 | font->fore = g_strdup(oldfont->fore); |
|
c91127e2b784
[gaim-migrate @ 17516]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14741
diff
changeset
|
3116 | g_free(color); |
| 8686 | 3117 | } |
|
14821
c91127e2b784
[gaim-migrate @ 17516]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14741
diff
changeset
|
3118 | |
|
c91127e2b784
[gaim-migrate @ 17516]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14741
diff
changeset
|
3119 | if (background && !(options & GTK_IMHTML_NO_COLOURS) && (imhtml->format_functions & GTK_IMHTML_BACKCOLOR)) { |
|
24509
afdf30801940
Support rgb(r,g,b) style css color definitions. Fixes #7288.
Daniel Atallah <datallah@pidgin.im>
parents:
24392
diff
changeset
|
3120 | font->back = parse_css_color(background); |
| 8686 | 3121 | gtk_imhtml_toggle_backcolor(imhtml, font->back); |
|
14821
c91127e2b784
[gaim-migrate @ 17516]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14741
diff
changeset
|
3122 | } else { |
|
c91127e2b784
[gaim-migrate @ 17516]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14741
diff
changeset
|
3123 | if (oldfont && oldfont->back) |
|
c91127e2b784
[gaim-migrate @ 17516]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14741
diff
changeset
|
3124 | font->back = g_strdup(oldfont->back); |
|
c91127e2b784
[gaim-migrate @ 17516]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14741
diff
changeset
|
3125 | g_free(background); |
| 8686 | 3126 | } |
|
14821
c91127e2b784
[gaim-migrate @ 17516]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14741
diff
changeset
|
3127 | |
|
c91127e2b784
[gaim-migrate @ 17516]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14741
diff
changeset
|
3128 | if (family && !(options & GTK_IMHTML_NO_FONTS) && (imhtml->format_functions & GTK_IMHTML_FACE)) { |
|
8118
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
3129 | font->face = family; |
| 8686 | 3130 | gtk_imhtml_toggle_fontface(imhtml, font->face); |
|
14821
c91127e2b784
[gaim-migrate @ 17516]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14741
diff
changeset
|
3131 | } else { |
|
c91127e2b784
[gaim-migrate @ 17516]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14741
diff
changeset
|
3132 | if (oldfont && oldfont->face) |
|
c91127e2b784
[gaim-migrate @ 17516]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14741
diff
changeset
|
3133 | font->face = g_strdup(oldfont->face); |
|
c91127e2b784
[gaim-migrate @ 17516]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14741
diff
changeset
|
3134 | g_free(family); |
| 8686 | 3135 | } |
|
8118
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
3136 | if (font->face && (atoi(font->face) > 100)) { |
| 8677 | 3137 | /* WTF is this? */ |
|
11572
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
3138 | /* Maybe it sets a max size on the font face? I seem to |
|
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
3139 | * remember bad things happening if the font size was |
|
9696
9d62e1ec5977
[gaim-migrate @ 10555]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
9636
diff
changeset
|
3140 | * 2 billion */ |
|
8118
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
3141 | g_free(font->face); |
|
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
3142 | font->face = g_strdup("100"); |
|
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
3143 | } |
|
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
3144 | |
|
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
3145 | if (oldfont && oldfont->sml) |
|
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
3146 | font->sml = g_strdup(oldfont->sml); |
|
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
3147 | |
| 8677 | 3148 | if (size && !(options & GTK_IMHTML_NO_SIZES) && (imhtml->format_functions & (GTK_IMHTML_SHRINK|GTK_IMHTML_GROW))) { |
| 8686 | 3149 | if (g_ascii_strcasecmp(size, "xx-small") == 0) |
| 3150 | font->size = 1; | |
| 3151 | else if (g_ascii_strcasecmp(size, "smaller") == 0 | |
| 3152 | || g_ascii_strcasecmp(size, "x-small") == 0) | |
|
8118
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
3153 | font->size = 2; |
|
25299
82d682722b68
Change our font mapping in gtkimhtml to match the suggested values
Mark Doliner <markdoliner@pidgin.im>
parents:
25168
diff
changeset
|
3154 | else if (g_ascii_strcasecmp(size, "medium") == 0) |
|
82d682722b68
Change our font mapping in gtkimhtml to match the suggested values
Mark Doliner <markdoliner@pidgin.im>
parents:
25168
diff
changeset
|
3155 | font->size = 3; |
|
82d682722b68
Change our font mapping in gtkimhtml to match the suggested values
Mark Doliner <markdoliner@pidgin.im>
parents:
25168
diff
changeset
|
3156 | else if (g_ascii_strcasecmp(size, "large") == 0 |
|
82d682722b68
Change our font mapping in gtkimhtml to match the suggested values
Mark Doliner <markdoliner@pidgin.im>
parents:
25168
diff
changeset
|
3157 | || g_ascii_strcasecmp(size, "larger") == 0) |
|
8118
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
3158 | font->size = 4; |
|
25299
82d682722b68
Change our font mapping in gtkimhtml to match the suggested values
Mark Doliner <markdoliner@pidgin.im>
parents:
25168
diff
changeset
|
3159 | else if (g_ascii_strcasecmp(size, "x-large") == 0) |
| 8686 | 3160 | font->size = 5; |
|
25299
82d682722b68
Change our font mapping in gtkimhtml to match the suggested values
Mark Doliner <markdoliner@pidgin.im>
parents:
25168
diff
changeset
|
3161 | else if (g_ascii_strcasecmp(size, "xx-large") == 0) |
| 8686 | 3162 | font->size = 6; |
|
25168
4f508dba5218
Change the way we handle <span style='font-size: whatever;'> tags slightly.
Mark Doliner <markdoliner@pidgin.im>
parents:
24588
diff
changeset
|
3163 | |
|
4f508dba5218
Change the way we handle <span style='font-size: whatever;'> tags slightly.
Mark Doliner <markdoliner@pidgin.im>
parents:
24588
diff
changeset
|
3164 | /* |
|
4f508dba5218
Change the way we handle <span style='font-size: whatever;'> tags slightly.
Mark Doliner <markdoliner@pidgin.im>
parents:
24588
diff
changeset
|
3165 | * TODO: Handle other values, like percentages, or |
|
4f508dba5218
Change the way we handle <span style='font-size: whatever;'> tags slightly.
Mark Doliner <markdoliner@pidgin.im>
parents:
24588
diff
changeset
|
3166 | * lengths specified as em, ex, px, in, cm, mm, pt |
|
4f508dba5218
Change the way we handle <span style='font-size: whatever;'> tags slightly.
Mark Doliner <markdoliner@pidgin.im>
parents:
24588
diff
changeset
|
3167 | * or pc. Or even better, use an actual HTML |
|
4f508dba5218
Change the way we handle <span style='font-size: whatever;'> tags slightly.
Mark Doliner <markdoliner@pidgin.im>
parents:
24588
diff
changeset
|
3168 | * renderer like webkit. |
|
4f508dba5218
Change the way we handle <span style='font-size: whatever;'> tags slightly.
Mark Doliner <markdoliner@pidgin.im>
parents:
24588
diff
changeset
|
3169 | */ |
|
4f508dba5218
Change the way we handle <span style='font-size: whatever;'> tags slightly.
Mark Doliner <markdoliner@pidgin.im>
parents:
24588
diff
changeset
|
3170 | if (font->size > 0) |
|
4f508dba5218
Change the way we handle <span style='font-size: whatever;'> tags slightly.
Mark Doliner <markdoliner@pidgin.im>
parents:
24588
diff
changeset
|
3171 | gtk_imhtml_font_set_size(imhtml, font->size); |
| 8686 | 3172 | } |
| 3173 | else if (oldfont) | |
| 3174 | { | |
| 3175 | font->size = oldfont->size; | |
| 3176 | } | |
| 3177 | ||
| 3178 | if (oldfont) | |
| 3179 | { | |
| 3180 | font->underline = oldfont->underline; | |
| 3181 | } | |
| 3182 | if (textdec && font->underline != 1 | |
| 9025 | 3183 | && g_ascii_strcasecmp(textdec, "underline") == 0 |
|
17088
1ecea6e2fd97
Ignore bold, underline and other formatting type things in SPAN tags if
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17009
diff
changeset
|
3184 | && (imhtml->format_functions & GTK_IMHTML_UNDERLINE) |
|
1ecea6e2fd97
Ignore bold, underline and other formatting type things in SPAN tags if
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17009
diff
changeset
|
3185 | && !(options & GTK_IMHTML_NO_FORMATTING)) |
| 8686 | 3186 | { |
| 3187 | gtk_imhtml_toggle_underline(imhtml); | |
| 3188 | font->underline = 1; | |
| 21425 | 3189 | } |
| 3190 | g_free(textdec); | |
|
8118
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
3191 | |
| 14395 | 3192 | if (oldfont) |
| 3193 | { | |
| 3194 | font->bold = oldfont->bold; | |
| 3195 | } | |
| 3196 | if (weight) | |
| 3197 | { | |
| 3198 | if(!g_ascii_strcasecmp(weight, "normal")) { | |
| 3199 | font->bold = 0; | |
| 3200 | } else if(!g_ascii_strcasecmp(weight, "bold")) { | |
| 3201 | font->bold = 1; | |
| 3202 | } else if(!g_ascii_strcasecmp(weight, "bolder")) { | |
| 3203 | font->bold++; | |
| 3204 | } else if(!g_ascii_strcasecmp(weight, "lighter")) { | |
| 3205 | if(font->bold > 0) | |
| 3206 | font->bold--; | |
| 3207 | } else { | |
| 3208 | int num = atoi(weight); | |
| 3209 | if(num >= 700) | |
| 3210 | font->bold = 1; | |
| 3211 | else | |
| 3212 | font->bold = 0; | |
| 3213 | } | |
|
17088
1ecea6e2fd97
Ignore bold, underline and other formatting type things in SPAN tags if
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17009
diff
changeset
|
3214 | if (((font->bold && oldfont && !oldfont->bold) || (oldfont && oldfont->bold && !font->bold) || (font->bold && !oldfont)) && !(options & GTK_IMHTML_NO_FORMATTING)) |
| 14395 | 3215 | { |
| 3216 | gtk_imhtml_toggle_bold(imhtml); | |
| 3217 | } | |
|
14821
c91127e2b784
[gaim-migrate @ 17516]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
14741
diff
changeset
|
3218 | g_free(weight); |
| 14395 | 3219 | } |
| 3220 | ||
|
8118
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
3221 | g_free(style); |
|
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
3222 | g_free(size); |
|
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
3223 | fonts = g_slist_prepend (fonts, font); |
|
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
3224 | } |
|
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
3225 | break; |
| 5104 | 3226 | case 57: /* /SPAN */ |
|
8118
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
3227 | /* Inline CSS Support - Douglas Thrift */ |
| 8677 | 3228 | if (fonts && !imhtml->wbfo) { |
| 8686 | 3229 | GtkIMHtmlFontDetail *oldfont = NULL; |
|
8118
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
3230 | GtkIMHtmlFontDetail *font = fonts->data; |
| 8677 | 3231 | gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos); |
|
8118
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
3232 | ws[0] = '\0'; wpos = 0; |
|
8177
33b3a01c6318
[gaim-migrate @ 8891]
Mark Doliner <markdoliner@pidgin.im>
parents:
8149
diff
changeset
|
3233 | /* NEW_BIT (NEW_TEXT_BIT); */ |
|
8118
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
3234 | fonts = g_slist_remove (fonts, font); |
| 8692 | 3235 | if (fonts) |
| 3236 | oldfont = fonts->data; | |
| 3237 | ||
| 3238 | if (!oldfont) { | |
| 3239 | gtk_imhtml_font_set_size(imhtml, 3); | |
|
17088
1ecea6e2fd97
Ignore bold, underline and other formatting type things in SPAN tags if
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17009
diff
changeset
|
3240 | if (font->underline && !(options & GTK_IMHTML_NO_FORMATTING)) |
| 8692 | 3241 | gtk_imhtml_toggle_underline(imhtml); |
|
17088
1ecea6e2fd97
Ignore bold, underline and other formatting type things in SPAN tags if
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17009
diff
changeset
|
3242 | if (font->bold && !(options & GTK_IMHTML_NO_FORMATTING)) |
| 14395 | 3243 | gtk_imhtml_toggle_bold(imhtml); |
|
17088
1ecea6e2fd97
Ignore bold, underline and other formatting type things in SPAN tags if
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17009
diff
changeset
|
3244 | if (!(options & GTK_IMHTML_NO_FONTS)) |
|
1ecea6e2fd97
Ignore bold, underline and other formatting type things in SPAN tags if
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17009
diff
changeset
|
3245 | gtk_imhtml_toggle_fontface(imhtml, NULL); |
|
1ecea6e2fd97
Ignore bold, underline and other formatting type things in SPAN tags if
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17009
diff
changeset
|
3246 | if (!(options & GTK_IMHTML_NO_COLOURS)) |
|
1ecea6e2fd97
Ignore bold, underline and other formatting type things in SPAN tags if
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17009
diff
changeset
|
3247 | gtk_imhtml_toggle_forecolor(imhtml, NULL); |
|
1ecea6e2fd97
Ignore bold, underline and other formatting type things in SPAN tags if
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17009
diff
changeset
|
3248 | if (!(options & GTK_IMHTML_NO_COLOURS)) |
|
1ecea6e2fd97
Ignore bold, underline and other formatting type things in SPAN tags if
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17009
diff
changeset
|
3249 | gtk_imhtml_toggle_backcolor(imhtml, NULL); |
| 8686 | 3250 | } |
| 8692 | 3251 | else |
| 8686 | 3252 | { |
| 8692 | 3253 | |
|
17088
1ecea6e2fd97
Ignore bold, underline and other formatting type things in SPAN tags if
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17009
diff
changeset
|
3254 | if ((font->size != oldfont->size) && !(options & GTK_IMHTML_NO_SIZES)) |
| 8692 | 3255 | gtk_imhtml_font_set_size(imhtml, oldfont->size); |
| 3256 | ||
|
17088
1ecea6e2fd97
Ignore bold, underline and other formatting type things in SPAN tags if
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17009
diff
changeset
|
3257 | if ((font->underline != oldfont->underline) && !(options & GTK_IMHTML_NO_FORMATTING)) |
| 8692 | 3258 | gtk_imhtml_toggle_underline(imhtml); |
| 3259 | ||
|
17088
1ecea6e2fd97
Ignore bold, underline and other formatting type things in SPAN tags if
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17009
diff
changeset
|
3260 | if (((font->bold && !oldfont->bold) || (oldfont->bold && !font->bold)) && !(options & GTK_IMHTML_NO_FORMATTING)) |
| 14395 | 3261 | gtk_imhtml_toggle_bold(imhtml); |
| 3262 | ||
|
17088
1ecea6e2fd97
Ignore bold, underline and other formatting type things in SPAN tags if
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17009
diff
changeset
|
3263 | if (font->face && (!oldfont->face || strcmp(font->face, oldfont->face) != 0) && !(options & GTK_IMHTML_NO_FONTS)) |
| 8692 | 3264 | gtk_imhtml_toggle_fontface(imhtml, oldfont->face); |
| 3265 | ||
|
17088
1ecea6e2fd97
Ignore bold, underline and other formatting type things in SPAN tags if
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17009
diff
changeset
|
3266 | if (font->fore && (!oldfont->fore || strcmp(font->fore, oldfont->fore) != 0) && !(options & GTK_IMHTML_NO_COLOURS)) |
| 8692 | 3267 | gtk_imhtml_toggle_forecolor(imhtml, oldfont->fore); |
| 3268 | ||
|
17088
1ecea6e2fd97
Ignore bold, underline and other formatting type things in SPAN tags if
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
17009
diff
changeset
|
3269 | if (font->back && (!oldfont->back || strcmp(font->back, oldfont->back) != 0) && !(options & GTK_IMHTML_NO_COLOURS)) |
| 8692 | 3270 | gtk_imhtml_toggle_backcolor(imhtml, oldfont->back); |
| 8686 | 3271 | } |
| 8692 | 3272 | |
| 3273 | g_free (font->face); | |
| 3274 | g_free (font->fore); | |
| 3275 | g_free (font->back); | |
| 3276 | g_free (font->sml); | |
| 3277 | ||
|
8118
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
3278 | g_free (font); |
|
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
3279 | } |
|
7f5315bb4506
[gaim-migrate @ 8822]
Douglas Thrift <douglas@douglasthrift.net>
parents:
8105
diff
changeset
|
3280 | break; |
| 8026 | 3281 | case 60: /* SPAN */ |
| 2993 | 3282 | break; |
| 8061 | 3283 | case 62: /* comment */ |
|
8177
33b3a01c6318
[gaim-migrate @ 8891]
Mark Doliner <markdoliner@pidgin.im>
parents:
8149
diff
changeset
|
3284 | /* NEW_BIT (NEW_TEXT_BIT); */ |
| 8317 | 3285 | ws[wpos] = '\0'; |
| 9465 | 3286 | |
| 8677 | 3287 | gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos); |
| 3288 | ||
|
22486
e77232ab761f
Disable invisible text things, if someone can conclusively prove this is
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22276
diff
changeset
|
3289 | #if FALSE && GTK_CHECK_VERSION(2,10,10) |
|
22211
7f3cecdb079c
disapproval of revision '2c96f5a301400781ce5fbf144ffdbae44f895281'
Sean Egan <seanegan@pidgin.im>
parents:
22210
diff
changeset
|
3290 | wpos = g_snprintf (ws, len, "%s", tag); |
|
7f3cecdb079c
disapproval of revision '2c96f5a301400781ce5fbf144ffdbae44f895281'
Sean Egan <seanegan@pidgin.im>
parents:
22210
diff
changeset
|
3291 | gtk_text_buffer_insert_with_tags_by_name(imhtml->text_buffer, iter, ws, wpos, "comment", NULL); |
|
7f3cecdb079c
disapproval of revision '2c96f5a301400781ce5fbf144ffdbae44f895281'
Sean Egan <seanegan@pidgin.im>
parents:
22210
diff
changeset
|
3292 | #else |
|
10815
b1ca28de65d3
[gaim-migrate @ 12470]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10814
diff
changeset
|
3293 | if (imhtml->show_comments && !(options & GTK_IMHTML_NO_COMMENTS)) { |
|
6124
322206d79652
[gaim-migrate @ 6598]
Mark Doliner <markdoliner@pidgin.im>
parents:
6066
diff
changeset
|
3294 | wpos = g_snprintf (ws, len, "%s", tag); |
|
23308
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
3295 | gtk_text_buffer_insert_with_tags_by_name(imhtml->text_buffer, iter, ws, wpos, "comment", NULL); |
|
10815
b1ca28de65d3
[gaim-migrate @ 12470]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10814
diff
changeset
|
3296 | } |
|
22211
7f3cecdb079c
disapproval of revision '2c96f5a301400781ce5fbf144ffdbae44f895281'
Sean Egan <seanegan@pidgin.im>
parents:
22210
diff
changeset
|
3297 | #endif |
|
10815
b1ca28de65d3
[gaim-migrate @ 12470]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10814
diff
changeset
|
3298 | ws[0] = '\0'; wpos = 0; |
|
b1ca28de65d3
[gaim-migrate @ 12470]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10814
diff
changeset
|
3299 | |
|
8177
33b3a01c6318
[gaim-migrate @ 8891]
Mark Doliner <markdoliner@pidgin.im>
parents:
8149
diff
changeset
|
3300 | /* NEW_BIT (NEW_COMMENT_BIT); */ |
| 3922 | 3301 | break; |
| 3302 | default: | |
| 6882 | 3303 | break; |
| 2993 | 3304 | } |
|
2856
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
3305 | c += tlen; |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
3306 | pos += tlen; |
|
13138
4d3bd039da3e
[gaim-migrate @ 15499]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13137
diff
changeset
|
3307 | g_free(tag); /* This was allocated back in VALID_TAG() */ |
|
15331
a8ef18791524
[gaim-migrate @ 18059]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15111
diff
changeset
|
3308 | } else if (imhtml->edit.link == NULL && |
|
22003
904ebe8d6058
Patch from 'goutnet' to not insert smileys when pasting as plain text.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21765
diff
changeset
|
3309 | !(options & GTK_IMHTML_NO_SMILEY) && |
|
15331
a8ef18791524
[gaim-migrate @ 18059]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
15111
diff
changeset
|
3310 | gtk_imhtml_is_smiley(imhtml, fonts, c, &smilelen)) { |
| 8473 | 3311 | GtkIMHtmlFontDetail *fd; |
| 3312 | gchar *sml = NULL; | |
|
21574
b27c242d1288
Fix #3930 by correctly detecting when we're no longer immediately following a br.
Daniel Atallah <datallah@pidgin.im>
parents:
21425
diff
changeset
|
3313 | |
|
b27c242d1288
Fix #3930 by correctly detecting when we're no longer immediately following a br.
Daniel Atallah <datallah@pidgin.im>
parents:
21425
diff
changeset
|
3314 | br = FALSE; |
|
b27c242d1288
Fix #3930 by correctly detecting when we're no longer immediately following a br.
Daniel Atallah <datallah@pidgin.im>
parents:
21425
diff
changeset
|
3315 | |
| 8473 | 3316 | if (fonts) { |
| 3317 | fd = fonts->data; | |
| 3318 | sml = fd->sml; | |
| 3319 | } | |
| 9029 | 3320 | if (!sml) |
| 3321 | sml = imhtml->protocol_name; | |
| 3322 | ||
| 8677 | 3323 | gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos); |
| 8505 | 3324 | wpos = g_snprintf (ws, smilelen + 1, "%s", c); |
| 8473 | 3325 | |
| 8677 | 3326 | gtk_imhtml_insert_smiley_at_iter(imhtml, sml, ws, iter); |
| 8473 | 3327 | |
| 8505 | 3328 | c += smilelen; |
| 3329 | pos += smilelen; | |
| 8473 | 3330 | wpos = 0; |
| 3331 | ws[0] = 0; | |
| 16144 | 3332 | } else if (*c == '&' && (amp = purple_markup_unescape_entity(c, &tlen))) { |
|
21574
b27c242d1288
Fix #3930 by correctly detecting when we're no longer immediately following a br.
Daniel Atallah <datallah@pidgin.im>
parents:
21425
diff
changeset
|
3333 | br = FALSE; |
| 7280 | 3334 | while(*amp) { |
| 3335 | ws [wpos++] = *amp++; | |
| 3336 | } | |
|
2856
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
3337 | c += tlen; |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
3338 | pos += tlen; |
| 1428 | 3339 | } else if (*c == '\n') { |
| 3340 | if (!(options & GTK_IMHTML_NO_NEWLINE)) { | |
| 3922 | 3341 | ws[wpos] = '\n'; |
| 3342 | wpos++; | |
| 8677 | 3343 | gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos); |
|
25007
ef8bc1f4a6ba
Pass only the URL scheme to gtkimhtml and let it add the colon automatically.
Richard Laager <rlaager@pidgin.im>
parents:
24698
diff
changeset
|
3344 | ws[0] = '\0'; wpos = 0; |
|
8177
33b3a01c6318
[gaim-migrate @ 8891]
Mark Doliner <markdoliner@pidgin.im>
parents:
8149
diff
changeset
|
3345 | /* NEW_BIT (NEW_TEXT_BIT); */ |
| 10217 | 3346 | } else if (!br) { /* Don't insert a space immediately after an HTML break */ |
| 9621 | 3347 | /* A newline is defined by HTML as whitespace, which means we have to replace it with a word boundary. |
| 3348 | * word breaks vary depending on the language used, so the correct thing to do is to use Pango to determine | |
| 3349 | * what language this is, determine the proper word boundary to use, and insert that. I'm just going to insert | |
| 3350 | * a space instead. What are the non-English speakers going to do? Complain in a language I'll understand? | |
| 3351 | * Bu-wahaha! */ | |
| 3352 | ws[wpos] = ' '; | |
| 3353 | wpos++; | |
| 3354 | gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos); | |
|
25007
ef8bc1f4a6ba
Pass only the URL scheme to gtkimhtml and let it add the colon automatically.
Richard Laager <rlaager@pidgin.im>
parents:
24698
diff
changeset
|
3355 | ws[0] = '\0'; wpos = 0; |
| 1428 | 3356 | } |
| 3357 | c++; | |
|
2856
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
3358 | pos++; |
|
25011
39bfe35b2980
Only find URLs on word boundaries to fix a bug rlaager noticed.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
25008
diff
changeset
|
3359 | } else if ((pos == 0 || wpos == 0 || isspace(*(c - 1))) && |
|
25908
c863fcecb7dd
Do not linkify unless <proto> is followed by some non-whitespace string.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
25906
diff
changeset
|
3360 | (len_protocol = gtk_imhtml_is_protocol(c)) > 0 && |
|
26655
95790807b4d7
Fix the auto-linking of protocols.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
25908
diff
changeset
|
3361 | c[len_protocol] && !isspace(c[len_protocol]) && |
|
95790807b4d7
Fix the auto-linking of protocols.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
25908
diff
changeset
|
3362 | (c[len_protocol] != '<' || !gtk_imhtml_is_tag(c + 1, NULL, NULL, NULL))) { |
|
21574
b27c242d1288
Fix #3930 by correctly detecting when we're no longer immediately following a br.
Daniel Atallah <datallah@pidgin.im>
parents:
21425
diff
changeset
|
3363 | br = FALSE; |
|
24674
36bf974a7d78
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24588
diff
changeset
|
3364 | if (wpos > 0) { |
|
36bf974a7d78
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24588
diff
changeset
|
3365 | gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos); |
|
25007
ef8bc1f4a6ba
Pass only the URL scheme to gtkimhtml and let it add the colon automatically.
Richard Laager <rlaager@pidgin.im>
parents:
24698
diff
changeset
|
3366 | ws[0] = '\0'; wpos = 0; |
|
24674
36bf974a7d78
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24588
diff
changeset
|
3367 | } |
|
25007
ef8bc1f4a6ba
Pass only the URL scheme to gtkimhtml and let it add the colon automatically.
Richard Laager <rlaager@pidgin.im>
parents:
24698
diff
changeset
|
3368 | while (len_protocol--) { |
|
ef8bc1f4a6ba
Pass only the URL scheme to gtkimhtml and let it add the colon automatically.
Richard Laager <rlaager@pidgin.im>
parents:
24698
diff
changeset
|
3369 | /* Skip the next len_protocol characters, but |
|
ef8bc1f4a6ba
Pass only the URL scheme to gtkimhtml and let it add the colon automatically.
Richard Laager <rlaager@pidgin.im>
parents:
24698
diff
changeset
|
3370 | * make sure they're copied into the ws array. |
|
ef8bc1f4a6ba
Pass only the URL scheme to gtkimhtml and let it add the colon automatically.
Richard Laager <rlaager@pidgin.im>
parents:
24698
diff
changeset
|
3371 | */ |
|
ef8bc1f4a6ba
Pass only the URL scheme to gtkimhtml and let it add the colon automatically.
Richard Laager <rlaager@pidgin.im>
parents:
24698
diff
changeset
|
3372 | ws [wpos++] = *c++; |
|
ef8bc1f4a6ba
Pass only the URL scheme to gtkimhtml and let it add the colon automatically.
Richard Laager <rlaager@pidgin.im>
parents:
24698
diff
changeset
|
3373 | pos++; |
| 8334 | 3374 | } |
|
25017
139df1ee9854
Fix the linkification error where bad things happened if you copy/pasted
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
25014
diff
changeset
|
3375 | if (!imhtml->edit.link && (imhtml->format_functions & GTK_IMHTML_LINK)) { |
|
139df1ee9854
Fix the linkification error where bad things happened if you copy/pasted
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
25014
diff
changeset
|
3376 | while (*c && !isspace((int)*c) && |
|
139df1ee9854
Fix the linkification error where bad things happened if you copy/pasted
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
25014
diff
changeset
|
3377 | (*c != '<' || !gtk_imhtml_is_tag(c + 1, NULL, NULL, NULL))) { |
|
139df1ee9854
Fix the linkification error where bad things happened if you copy/pasted
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
25014
diff
changeset
|
3378 | if (*c == '&' && (amp = purple_markup_unescape_entity(c, &tlen))) { |
|
139df1ee9854
Fix the linkification error where bad things happened if you copy/pasted
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
25014
diff
changeset
|
3379 | while (*amp) |
|
139df1ee9854
Fix the linkification error where bad things happened if you copy/pasted
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
25014
diff
changeset
|
3380 | ws[wpos++] = *amp++; |
|
139df1ee9854
Fix the linkification error where bad things happened if you copy/pasted
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
25014
diff
changeset
|
3381 | c += tlen; |
|
139df1ee9854
Fix the linkification error where bad things happened if you copy/pasted
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
25014
diff
changeset
|
3382 | pos += tlen; |
|
139df1ee9854
Fix the linkification error where bad things happened if you copy/pasted
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
25014
diff
changeset
|
3383 | } else { |
|
139df1ee9854
Fix the linkification error where bad things happened if you copy/pasted
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
25014
diff
changeset
|
3384 | ws [wpos++] = *c++; |
|
139df1ee9854
Fix the linkification error where bad things happened if you copy/pasted
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
25014
diff
changeset
|
3385 | pos++; |
|
139df1ee9854
Fix the linkification error where bad things happened if you copy/pasted
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
25014
diff
changeset
|
3386 | } |
|
24674
36bf974a7d78
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24588
diff
changeset
|
3387 | } |
|
36bf974a7d78
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24588
diff
changeset
|
3388 | ws[wpos] = '\0'; |
|
36bf974a7d78
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24588
diff
changeset
|
3389 | gtk_imhtml_toggle_link(imhtml, ws); |
|
36bf974a7d78
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24588
diff
changeset
|
3390 | gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos); |
|
36bf974a7d78
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24588
diff
changeset
|
3391 | ws[0] = '\0'; wpos = 0; |
|
36bf974a7d78
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24588
diff
changeset
|
3392 | gtk_imhtml_toggle_link(imhtml, NULL); |
| 8334 | 3393 | } |
| 8061 | 3394 | } else if (*c) { |
|
21574
b27c242d1288
Fix #3930 by correctly detecting when we're no longer immediately following a br.
Daniel Atallah <datallah@pidgin.im>
parents:
21425
diff
changeset
|
3395 | br = FALSE; |
| 1428 | 3396 | ws [wpos++] = *c++; |
|
2856
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
3397 | pos++; |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
3398 | } else { |
|
046ed5e89321
[gaim-migrate @ 2869]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2826
diff
changeset
|
3399 | break; |
| 1428 | 3400 | } |
| 3401 | } | |
| 8677 | 3402 | gtk_text_buffer_insert(imhtml->text_buffer, iter, ws, wpos); |
| 8061 | 3403 | ws[0] = '\0'; wpos = 0; |
| 3404 | ||
|
8177
33b3a01c6318
[gaim-migrate @ 8891]
Mark Doliner <markdoliner@pidgin.im>
parents:
8149
diff
changeset
|
3405 | /* NEW_BIT(NEW_TEXT_BIT); */ |
| 8061 | 3406 | |
|
16143
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
3407 | if(align_right) { |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
3408 | /* insert RLM+LRM at beginning of the line to set alignment */ |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
3409 | GtkTextIter line_iter; |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
3410 | line_iter = *iter; |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
3411 | gtk_text_iter_set_line(&line_iter, align_line); |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
3412 | /* insert RLM character to set alignment */ |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
3413 | ws[wpos++] = 0xE2; |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
3414 | ws[wpos++] = 0x80; |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
3415 | ws[wpos++] = 0x8F; |
|
25888
d0fdd378a635
Remove trailing whitespace
Mark Doliner <markdoliner@pidgin.im>
parents:
25854
diff
changeset
|
3416 | |
| 16144 | 3417 | if (!rtl_direction) |
|
16143
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
3418 | { |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
3419 | /* insert LRM character to set direction */ |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
3420 | /* (alignment=right and direction=LTR) */ |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
3421 | ws[wpos++] = 0xE2; |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
3422 | ws[wpos++] = 0x80; |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
3423 | ws[wpos++] = 0x8E; |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
3424 | } |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
3425 | |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
3426 | ws[wpos] = '\0'; |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
3427 | gtk_text_buffer_insert(imhtml->text_buffer, &line_iter, ws, wpos); |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
3428 | gtk_text_buffer_get_end_iter(gtk_text_iter_get_buffer(&line_iter), iter); |
|
25007
ef8bc1f4a6ba
Pass only the URL scheme to gtkimhtml and let it add the colon automatically.
Richard Laager <rlaager@pidgin.im>
parents:
24698
diff
changeset
|
3429 | ws[0] = '\0'; wpos = 0; |
|
16143
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
3430 | } |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
3431 | |
| 4032 | 3432 | while (fonts) { |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
3433 | GtkIMHtmlFontDetail *font = fonts->data; |
| 4032 | 3434 | fonts = g_slist_remove (fonts, font); |
|
14097
0c340861ab79
[gaim-migrate @ 16638]
Mark Doliner <markdoliner@pidgin.im>
parents:
14010
diff
changeset
|
3435 | g_free (font->face); |
|
0c340861ab79
[gaim-migrate @ 16638]
Mark Doliner <markdoliner@pidgin.im>
parents:
14010
diff
changeset
|
3436 | g_free (font->fore); |
|
0c340861ab79
[gaim-migrate @ 16638]
Mark Doliner <markdoliner@pidgin.im>
parents:
14010
diff
changeset
|
3437 | g_free (font->back); |
|
0c340861ab79
[gaim-migrate @ 16638]
Mark Doliner <markdoliner@pidgin.im>
parents:
14010
diff
changeset
|
3438 | g_free (font->sml); |
| 4032 | 3439 | g_free (font); |
| 3440 | } | |
| 8932 | 3441 | |
| 3442 | g_free(ws); | |
|
13138
4d3bd039da3e
[gaim-migrate @ 15499]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13137
diff
changeset
|
3443 | g_free(bg); |
| 8677 | 3444 | |
| 3445 | if (!imhtml->wbfo) | |
| 8698 | 3446 | gtk_imhtml_close_tags(imhtml, iter); |
| 8506 | 3447 | |
| 15403 | 3448 | object = g_object_ref(G_OBJECT(imhtml)); |
| 8506 | 3449 | g_signal_emit(object, signals[UPDATE_FORMAT], 0); |
| 3450 | g_object_unref(object); | |
| 15420 | 3451 | |
|
22834
1394e7efb818
Smiley insertions can be undone with this fix. References #5577. But redo
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22810
diff
changeset
|
3452 | gtk_text_buffer_end_user_action(imhtml->text_buffer); |
| 3922 | 3453 | } |
| 3454 | ||
| 4892 | 3455 | void gtk_imhtml_remove_smileys(GtkIMHtml *imhtml) |
| 3456 | { | |
| 4288 | 3457 | g_hash_table_destroy(imhtml->smiley_data); |
| 3458 | gtk_smiley_tree_destroy(imhtml->default_smilies); | |
| 4892 | 3459 | imhtml->smiley_data = g_hash_table_new_full(g_str_hash, g_str_equal, |
| 4902 | 3460 | g_free, (GDestroyNotify)gtk_smiley_tree_destroy); |
| 4288 | 3461 | imhtml->default_smilies = gtk_smiley_tree_new(); |
| 3462 | } | |
| 8481 | 3463 | |
| 3922 | 3464 | void gtk_imhtml_show_comments (GtkIMHtml *imhtml, |
| 4253 | 3465 | gboolean show) |
| 3466 | { | |
|
22486
e77232ab761f
Disable invisible text things, if someone can conclusively prove this is
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
22276
diff
changeset
|
3467 | #if FALSE && GTK_CHECK_VERSION(2,10,10) |
|
22211
7f3cecdb079c
disapproval of revision '2c96f5a301400781ce5fbf144ffdbae44f895281'
Sean Egan <seanegan@pidgin.im>
parents:
22210
diff
changeset
|
3468 | GtkTextTag *tag; |
|
7f3cecdb079c
disapproval of revision '2c96f5a301400781ce5fbf144ffdbae44f895281'
Sean Egan <seanegan@pidgin.im>
parents:
22210
diff
changeset
|
3469 | tag = gtk_text_tag_table_lookup(gtk_text_buffer_get_tag_table(imhtml->text_buffer), "comment"); |
|
7f3cecdb079c
disapproval of revision '2c96f5a301400781ce5fbf144ffdbae44f895281'
Sean Egan <seanegan@pidgin.im>
parents:
22210
diff
changeset
|
3470 | if (tag) |
|
7f3cecdb079c
disapproval of revision '2c96f5a301400781ce5fbf144ffdbae44f895281'
Sean Egan <seanegan@pidgin.im>
parents:
22210
diff
changeset
|
3471 | g_object_set(G_OBJECT(tag), "invisible", !show, NULL); |
|
7f3cecdb079c
disapproval of revision '2c96f5a301400781ce5fbf144ffdbae44f895281'
Sean Egan <seanegan@pidgin.im>
parents:
22210
diff
changeset
|
3472 | #endif |
|
6124
322206d79652
[gaim-migrate @ 6598]
Mark Doliner <markdoliner@pidgin.im>
parents:
6066
diff
changeset
|
3473 | imhtml->show_comments = show; |
| 4253 | 3474 | } |
|
1780
431333222954
[gaim-migrate @ 1790]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
1738
diff
changeset
|
3475 | |
|
11814
5003711283c0
[gaim-migrate @ 14105]
Richard Laager <rlaager@pidgin.im>
parents:
11768
diff
changeset
|
3476 | const char * |
|
5003711283c0
[gaim-migrate @ 14105]
Richard Laager <rlaager@pidgin.im>
parents:
11768
diff
changeset
|
3477 | gtk_imhtml_get_protocol_name(GtkIMHtml *imhtml) { |
|
5003711283c0
[gaim-migrate @ 14105]
Richard Laager <rlaager@pidgin.im>
parents:
11768
diff
changeset
|
3478 | return imhtml->protocol_name; |
|
5003711283c0
[gaim-migrate @ 14105]
Richard Laager <rlaager@pidgin.im>
parents:
11768
diff
changeset
|
3479 | } |
|
5003711283c0
[gaim-migrate @ 14105]
Richard Laager <rlaager@pidgin.im>
parents:
11768
diff
changeset
|
3480 | |
| 8962 | 3481 | void |
| 9029 | 3482 | gtk_imhtml_set_protocol_name(GtkIMHtml *imhtml, const gchar *protocol_name) { |
|
14097
0c340861ab79
[gaim-migrate @ 16638]
Mark Doliner <markdoliner@pidgin.im>
parents:
14010
diff
changeset
|
3483 | g_free(imhtml->protocol_name); |
|
0c340861ab79
[gaim-migrate @ 16638]
Mark Doliner <markdoliner@pidgin.im>
parents:
14010
diff
changeset
|
3484 | imhtml->protocol_name = g_strdup(protocol_name); |
| 8456 | 3485 | } |
| 3486 | ||
|
1780
431333222954
[gaim-migrate @ 1790]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
1738
diff
changeset
|
3487 | void |
|
11224
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3488 | gtk_imhtml_delete(GtkIMHtml *imhtml, GtkTextIter *start, GtkTextIter *end) { |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3489 | GList *l; |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3490 | GSList *sl; |
|
11234
e23fd86e7581
[gaim-migrate @ 13377]
Daniel Atallah <datallah@pidgin.im>
parents:
11233
diff
changeset
|
3491 | GtkTextIter i, i_s, i_e; |
| 8427 | 3492 | GObject *object = g_object_ref(G_OBJECT(imhtml)); |
|
11224
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3493 | |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3494 | if (start == NULL) { |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3495 | gtk_text_buffer_get_start_iter(imhtml->text_buffer, &i_s); |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3496 | start = &i_s; |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3497 | } |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3498 | |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3499 | if (end == NULL) { |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3500 | gtk_text_buffer_get_end_iter(imhtml->text_buffer, &i_e); |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3501 | end = &i_e; |
| 7991 | 3502 | } |
|
11224
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3503 | |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3504 | l = imhtml->scalables; |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3505 | while (l) { |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3506 | GList *next = l->next; |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3507 | struct scalable_data *sd = l->data; |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3508 | gtk_text_buffer_get_iter_at_mark(imhtml->text_buffer, |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3509 | &i, sd->mark); |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3510 | if (gtk_text_iter_in_range(&i, start, end)) { |
|
21063
911e85f207c7
Fix some leaks caused by misuse of g_list_remove_link() instead of g_list_delete_link().
Daniel Atallah <datallah@pidgin.im>
parents:
20638
diff
changeset
|
3511 | GtkIMHtmlScalable *scale = GTK_IMHTML_SCALABLE(sd->scalable); |
|
11224
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3512 | scale->free(scale); |
|
21063
911e85f207c7
Fix some leaks caused by misuse of g_list_remove_link() instead of g_list_delete_link().
Daniel Atallah <datallah@pidgin.im>
parents:
20638
diff
changeset
|
3513 | g_free(sd); |
|
911e85f207c7
Fix some leaks caused by misuse of g_list_remove_link() instead of g_list_delete_link().
Daniel Atallah <datallah@pidgin.im>
parents:
20638
diff
changeset
|
3514 | imhtml->scalables = g_list_delete_link(imhtml->scalables, l); |
|
11224
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3515 | } |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3516 | l = next; |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3517 | } |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3518 | |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3519 | sl = imhtml->im_images; |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3520 | while (sl) { |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3521 | GSList *next = sl->next; |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3522 | struct im_image_data *img_data = sl->data; |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3523 | gtk_text_buffer_get_iter_at_mark(imhtml->text_buffer, |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3524 | &i, img_data->mark); |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3525 | if (gtk_text_iter_in_range(&i, start, end)) { |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3526 | if (imhtml->funcs->image_unref) |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3527 | imhtml->funcs->image_unref(img_data->id); |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3528 | imhtml->im_images = g_slist_delete_link(imhtml->im_images, sl); |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3529 | g_free(img_data); |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3530 | } |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3531 | sl = next; |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3532 | } |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
3533 | gtk_text_buffer_delete(imhtml->text_buffer, start, end); |
| 8061 | 3534 | |
| 8427 | 3535 | g_object_unref(object); |
|
1780
431333222954
[gaim-migrate @ 1790]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
1738
diff
changeset
|
3536 | } |
|
2363
0767c14d7879
[gaim-migrate @ 2376]
Eric Warmenhoven <warmenhoven@yahoo.com>
parents:
2349
diff
changeset
|
3537 | |
| 4046 | 3538 | void gtk_imhtml_page_up (GtkIMHtml *imhtml) |
| 3539 | { | |
| 5282 | 3540 | GdkRectangle rect; |
| 3541 | GtkTextIter iter; | |
| 4046 | 3542 | |
| 5282 | 3543 | gtk_text_view_get_visible_rect(GTK_TEXT_VIEW(imhtml), &rect); |
| 3544 | gtk_text_view_get_iter_at_location(GTK_TEXT_VIEW(imhtml), &iter, rect.x, | |
| 3545 | rect.y - rect.height); | |
| 3546 | gtk_text_view_scroll_to_iter(GTK_TEXT_VIEW(imhtml), &iter, 0, TRUE, 0, 0); | |
| 8061 | 3547 | |
| 4046 | 3548 | } |
| 5282 | 3549 | void gtk_imhtml_page_down (GtkIMHtml *imhtml) |
| 3550 | { | |
| 3551 | GdkRectangle rect; | |
| 3552 | GtkTextIter iter; | |
| 3553 | ||
| 3554 | gtk_text_view_get_visible_rect(GTK_TEXT_VIEW(imhtml), &rect); | |
| 3555 | gtk_text_view_get_iter_at_location(GTK_TEXT_VIEW(imhtml), &iter, rect.x, | |
| 3556 | rect.y + rect.height); | |
| 3557 | gtk_text_view_scroll_to_iter(GTK_TEXT_VIEW(imhtml), &iter, 0, TRUE, 0, 0); | |
| 3558 | } | |
| 4735 | 3559 | |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
3560 | /* GtkIMHtmlScalable, gtk_imhtml_image, gtk_imhtml_hr */ |
| 8962 | 3561 | GtkIMHtmlScalable *gtk_imhtml_image_new(GdkPixbuf *img, const gchar *filename, int id) |
| 4735 | 3562 | { |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
3563 | GtkIMHtmlImage *im_image = g_malloc(sizeof(GtkIMHtmlImage)); |
| 4895 | 3564 | |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
3565 | GTK_IMHTML_SCALABLE(im_image)->scale = gtk_imhtml_image_scale; |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
3566 | GTK_IMHTML_SCALABLE(im_image)->add_to = gtk_imhtml_image_add_to; |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
3567 | GTK_IMHTML_SCALABLE(im_image)->free = gtk_imhtml_image_free; |
| 5046 | 3568 | |
| 3569 | im_image->pixbuf = img; | |
|
18151
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
3570 | im_image->image = GTK_IMAGE(gtk_image_new_from_pixbuf(im_image->pixbuf)); |
| 4895 | 3571 | im_image->width = gdk_pixbuf_get_width(img); |
| 3572 | im_image->height = gdk_pixbuf_get_height(img); | |
| 3573 | im_image->mark = NULL; | |
|
14097
0c340861ab79
[gaim-migrate @ 16638]
Mark Doliner <markdoliner@pidgin.im>
parents:
14010
diff
changeset
|
3574 | im_image->filename = g_strdup(filename); |
| 8962 | 3575 | im_image->id = id; |
|
9573
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3576 | im_image->filesel = NULL; |
| 4895 | 3577 | |
| 5046 | 3578 | g_object_ref(img); |
| 4895 | 3579 | return GTK_IMHTML_SCALABLE(im_image); |
| 3580 | } | |
| 3581 | ||
|
18151
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
3582 | static gboolean |
|
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
3583 | animate_image_cb(gpointer data) |
|
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
3584 | { |
|
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
3585 | GtkIMHtmlImage *im_image; |
|
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
3586 | int width, height; |
|
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
3587 | int delay; |
|
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
3588 | |
|
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
3589 | im_image = data; |
|
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
3590 | |
|
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
3591 | /* Update the pointer to this GdkPixbuf frame of the animation */ |
|
20638
38507ef4007f
Fix some crashes with animated smileys. Fixes #3179, #938, #3134, #2872, #1594
Daniel Atallah <datallah@pidgin.im>
parents:
20330
diff
changeset
|
3592 | if (gdk_pixbuf_animation_iter_advance(GTK_IMHTML_ANIMATION(im_image)->iter, NULL)) { |
|
38507ef4007f
Fix some crashes with animated smileys. Fixes #3179, #938, #3134, #2872, #1594
Daniel Atallah <datallah@pidgin.im>
parents:
20330
diff
changeset
|
3593 | GdkPixbuf *pb = gdk_pixbuf_animation_iter_get_pixbuf(GTK_IMHTML_ANIMATION(im_image)->iter); |
|
38507ef4007f
Fix some crashes with animated smileys. Fixes #3179, #938, #3134, #2872, #1594
Daniel Atallah <datallah@pidgin.im>
parents:
20330
diff
changeset
|
3594 | g_object_unref(G_OBJECT(im_image->pixbuf)); |
|
38507ef4007f
Fix some crashes with animated smileys. Fixes #3179, #938, #3134, #2872, #1594
Daniel Atallah <datallah@pidgin.im>
parents:
20330
diff
changeset
|
3595 | im_image->pixbuf = gdk_pixbuf_copy(pb); |
|
38507ef4007f
Fix some crashes with animated smileys. Fixes #3179, #938, #3134, #2872, #1594
Daniel Atallah <datallah@pidgin.im>
parents:
20330
diff
changeset
|
3596 | |
|
38507ef4007f
Fix some crashes with animated smileys. Fixes #3179, #938, #3134, #2872, #1594
Daniel Atallah <datallah@pidgin.im>
parents:
20330
diff
changeset
|
3597 | /* Update the displayed GtkImage */ |
|
38507ef4007f
Fix some crashes with animated smileys. Fixes #3179, #938, #3134, #2872, #1594
Daniel Atallah <datallah@pidgin.im>
parents:
20330
diff
changeset
|
3598 | width = gdk_pixbuf_get_width(gtk_image_get_pixbuf(im_image->image)); |
|
38507ef4007f
Fix some crashes with animated smileys. Fixes #3179, #938, #3134, #2872, #1594
Daniel Atallah <datallah@pidgin.im>
parents:
20330
diff
changeset
|
3599 | height = gdk_pixbuf_get_height(gtk_image_get_pixbuf(im_image->image)); |
|
38507ef4007f
Fix some crashes with animated smileys. Fixes #3179, #938, #3134, #2872, #1594
Daniel Atallah <datallah@pidgin.im>
parents:
20330
diff
changeset
|
3600 | if (width > 0 && height > 0) |
|
38507ef4007f
Fix some crashes with animated smileys. Fixes #3179, #938, #3134, #2872, #1594
Daniel Atallah <datallah@pidgin.im>
parents:
20330
diff
changeset
|
3601 | { |
|
38507ef4007f
Fix some crashes with animated smileys. Fixes #3179, #938, #3134, #2872, #1594
Daniel Atallah <datallah@pidgin.im>
parents:
20330
diff
changeset
|
3602 | /* Need to scale the new frame to the same size as the old frame */ |
|
38507ef4007f
Fix some crashes with animated smileys. Fixes #3179, #938, #3134, #2872, #1594
Daniel Atallah <datallah@pidgin.im>
parents:
20330
diff
changeset
|
3603 | GdkPixbuf *tmp; |
|
38507ef4007f
Fix some crashes with animated smileys. Fixes #3179, #938, #3134, #2872, #1594
Daniel Atallah <datallah@pidgin.im>
parents:
20330
diff
changeset
|
3604 | tmp = gdk_pixbuf_scale_simple(im_image->pixbuf, width, height, GDK_INTERP_BILINEAR); |
|
38507ef4007f
Fix some crashes with animated smileys. Fixes #3179, #938, #3134, #2872, #1594
Daniel Atallah <datallah@pidgin.im>
parents:
20330
diff
changeset
|
3605 | gtk_image_set_from_pixbuf(im_image->image, tmp); |
|
38507ef4007f
Fix some crashes with animated smileys. Fixes #3179, #938, #3134, #2872, #1594
Daniel Atallah <datallah@pidgin.im>
parents:
20330
diff
changeset
|
3606 | g_object_unref(G_OBJECT(tmp)); |
|
38507ef4007f
Fix some crashes with animated smileys. Fixes #3179, #938, #3134, #2872, #1594
Daniel Atallah <datallah@pidgin.im>
parents:
20330
diff
changeset
|
3607 | } else { |
|
38507ef4007f
Fix some crashes with animated smileys. Fixes #3179, #938, #3134, #2872, #1594
Daniel Atallah <datallah@pidgin.im>
parents:
20330
diff
changeset
|
3608 | /* Display at full-size */ |
|
38507ef4007f
Fix some crashes with animated smileys. Fixes #3179, #938, #3134, #2872, #1594
Daniel Atallah <datallah@pidgin.im>
parents:
20330
diff
changeset
|
3609 | gtk_image_set_from_pixbuf(im_image->image, im_image->pixbuf); |
|
38507ef4007f
Fix some crashes with animated smileys. Fixes #3179, #938, #3134, #2872, #1594
Daniel Atallah <datallah@pidgin.im>
parents:
20330
diff
changeset
|
3610 | } |
|
18151
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
3611 | } |
|
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
3612 | |
|
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
3613 | delay = MIN(gdk_pixbuf_animation_iter_get_delay_time(GTK_IMHTML_ANIMATION(im_image)->iter), 100); |
|
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
3614 | GTK_IMHTML_ANIMATION(im_image)->timer = g_timeout_add(delay, animate_image_cb, im_image); |
|
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
3615 | |
|
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
3616 | return FALSE; |
|
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
3617 | } |
|
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
3618 | |
|
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
3619 | GtkIMHtmlScalable *gtk_imhtml_animation_new(GdkPixbufAnimation *anim, const gchar *filename, int id) |
|
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
3620 | { |
|
22703
2cc5d0981559
Fix animated icons that have been right-clicked causing crashes when the imhtml is destroyed. Fixes #5217.
Daniel Atallah <datallah@pidgin.im>
parents:
22596
diff
changeset
|
3621 | GtkIMHtmlImage *im_image = (GtkIMHtmlImage *) g_new0(GtkIMHtmlAnimation, 1); |
|
18151
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
3622 | |
|
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
3623 | GTK_IMHTML_SCALABLE(im_image)->scale = gtk_imhtml_image_scale; |
|
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
3624 | GTK_IMHTML_SCALABLE(im_image)->add_to = gtk_imhtml_image_add_to; |
|
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
3625 | GTK_IMHTML_SCALABLE(im_image)->free = gtk_imhtml_animation_free; |
|
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
3626 | |
|
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
3627 | GTK_IMHTML_ANIMATION(im_image)->anim = anim; |
|
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
3628 | if (gdk_pixbuf_animation_is_static_image(anim)) { |
|
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
3629 | im_image->pixbuf = gdk_pixbuf_animation_get_static_image(anim); |
|
20638
38507ef4007f
Fix some crashes with animated smileys. Fixes #3179, #938, #3134, #2872, #1594
Daniel Atallah <datallah@pidgin.im>
parents:
20330
diff
changeset
|
3630 | g_object_ref(im_image->pixbuf); |
|
18151
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
3631 | } else { |
|
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
3632 | int delay; |
|
20638
38507ef4007f
Fix some crashes with animated smileys. Fixes #3179, #938, #3134, #2872, #1594
Daniel Atallah <datallah@pidgin.im>
parents:
20330
diff
changeset
|
3633 | GdkPixbuf *pb; |
|
18151
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
3634 | GTK_IMHTML_ANIMATION(im_image)->iter = gdk_pixbuf_animation_get_iter(anim, NULL); |
|
20638
38507ef4007f
Fix some crashes with animated smileys. Fixes #3179, #938, #3134, #2872, #1594
Daniel Atallah <datallah@pidgin.im>
parents:
20330
diff
changeset
|
3635 | pb = gdk_pixbuf_animation_iter_get_pixbuf(GTK_IMHTML_ANIMATION(im_image)->iter); |
|
38507ef4007f
Fix some crashes with animated smileys. Fixes #3179, #938, #3134, #2872, #1594
Daniel Atallah <datallah@pidgin.im>
parents:
20330
diff
changeset
|
3636 | im_image->pixbuf = gdk_pixbuf_copy(pb); |
|
18151
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
3637 | delay = MIN(gdk_pixbuf_animation_iter_get_delay_time(GTK_IMHTML_ANIMATION(im_image)->iter), 100); |
|
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
3638 | GTK_IMHTML_ANIMATION(im_image)->timer = g_timeout_add(delay, animate_image_cb, im_image); |
|
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
3639 | } |
|
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
3640 | im_image->image = GTK_IMAGE(gtk_image_new_from_pixbuf(im_image->pixbuf)); |
|
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
3641 | im_image->width = gdk_pixbuf_animation_get_width(anim); |
|
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
3642 | im_image->height = gdk_pixbuf_animation_get_height(anim); |
|
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
3643 | im_image->filename = g_strdup(filename); |
|
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
3644 | im_image->id = id; |
|
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
3645 | |
|
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
3646 | g_object_ref(anim); |
|
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
3647 | |
|
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
3648 | return GTK_IMHTML_SCALABLE(im_image); |
|
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
3649 | } |
|
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
3650 | |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
3651 | void gtk_imhtml_image_scale(GtkIMHtmlScalable *scale, int width, int height) |
| 4895 | 3652 | { |
|
11867
de448bc5da1a
[gaim-migrate @ 14158]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11844
diff
changeset
|
3653 | GtkIMHtmlImage *im_image = (GtkIMHtmlImage *)scale; |
|
de448bc5da1a
[gaim-migrate @ 14158]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11844
diff
changeset
|
3654 | |
|
de448bc5da1a
[gaim-migrate @ 14158]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11844
diff
changeset
|
3655 | if (im_image->width > width || im_image->height > height) { |
|
11840
c9ec5a42d420
[gaim-migrate @ 14131]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11820
diff
changeset
|
3656 | double ratio_w, ratio_h, ratio; |
|
c9ec5a42d420
[gaim-migrate @ 14131]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11820
diff
changeset
|
3657 | int new_h, new_w; |
| 4895 | 3658 | GdkPixbuf *new_image = NULL; |
|
11840
c9ec5a42d420
[gaim-migrate @ 14131]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11820
diff
changeset
|
3659 | |
|
11867
de448bc5da1a
[gaim-migrate @ 14158]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11844
diff
changeset
|
3660 | ratio_w = ((double)width - 2) / im_image->width; |
|
de448bc5da1a
[gaim-migrate @ 14158]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11844
diff
changeset
|
3661 | ratio_h = ((double)height - 2) / im_image->height; |
|
11840
c9ec5a42d420
[gaim-migrate @ 14131]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11820
diff
changeset
|
3662 | |
|
c9ec5a42d420
[gaim-migrate @ 14131]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11820
diff
changeset
|
3663 | ratio = (ratio_w < ratio_h) ? ratio_w : ratio_h; |
|
c9ec5a42d420
[gaim-migrate @ 14131]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11820
diff
changeset
|
3664 | |
|
11867
de448bc5da1a
[gaim-migrate @ 14158]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11844
diff
changeset
|
3665 | new_w = (int)(im_image->width * ratio); |
|
de448bc5da1a
[gaim-migrate @ 14158]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11844
diff
changeset
|
3666 | new_h = (int)(im_image->height * ratio); |
|
de448bc5da1a
[gaim-migrate @ 14158]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11844
diff
changeset
|
3667 | |
|
de448bc5da1a
[gaim-migrate @ 14158]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11844
diff
changeset
|
3668 | new_image = gdk_pixbuf_scale_simple(im_image->pixbuf, new_w, new_h, GDK_INTERP_BILINEAR); |
|
de448bc5da1a
[gaim-migrate @ 14158]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11844
diff
changeset
|
3669 | gtk_image_set_from_pixbuf(im_image->image, new_image); |
|
de448bc5da1a
[gaim-migrate @ 14158]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11844
diff
changeset
|
3670 | g_object_unref(G_OBJECT(new_image)); |
|
de448bc5da1a
[gaim-migrate @ 14158]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11844
diff
changeset
|
3671 | } else if (gdk_pixbuf_get_width(gtk_image_get_pixbuf(im_image->image)) != im_image->width) { |
|
de448bc5da1a
[gaim-migrate @ 14158]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11844
diff
changeset
|
3672 | /* Enough space to show the full-size of the image. */ |
|
de448bc5da1a
[gaim-migrate @ 14158]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11844
diff
changeset
|
3673 | GdkPixbuf *new_image; |
|
de448bc5da1a
[gaim-migrate @ 14158]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11844
diff
changeset
|
3674 | |
|
de448bc5da1a
[gaim-migrate @ 14158]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11844
diff
changeset
|
3675 | new_image = gdk_pixbuf_scale_simple(im_image->pixbuf, im_image->width, im_image->height, GDK_INTERP_BILINEAR); |
|
de448bc5da1a
[gaim-migrate @ 14158]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
11844
diff
changeset
|
3676 | gtk_image_set_from_pixbuf(im_image->image, new_image); |
| 4895 | 3677 | g_object_unref(G_OBJECT(new_image)); |
| 3678 | } | |
| 3679 | } | |
| 3680 | ||
|
9573
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3681 | static void |
|
27123
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3682 | image_save_yes_cb(GtkIMHtmlImageSave *save, const char *filename) |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3683 | { |
| 5019 | 3684 | GError *error = NULL; |
|
27123
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3685 | GtkIMHtmlImage *image = (GtkIMHtmlImage *)save->image; |
| 5012 | 3686 | |
|
9573
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3687 | gtk_widget_destroy(image->filesel); |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3688 | image->filesel = NULL; |
|
5959
827dbe4b5bb2
[gaim-migrate @ 6405]
Mark Doliner <markdoliner@pidgin.im>
parents:
5582
diff
changeset
|
3689 | |
|
27123
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3690 | if (save->data && save->datasize) { |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3691 | #if GLIB_CHECK_VERSION(2,8,0) |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3692 | g_file_set_contents(filename, save->data, save->datasize, &error); |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3693 | #else |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3694 | purple_util_write_data_to_file_absolute(filename, save->data, save->datasize); |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3695 | #endif |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3696 | } else { |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3697 | gchar *type = NULL; |
|
5959
827dbe4b5bb2
[gaim-migrate @ 6405]
Mark Doliner <markdoliner@pidgin.im>
parents:
5582
diff
changeset
|
3698 | #if GTK_CHECK_VERSION(2,2,0) |
|
27123
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3699 | GSList *formats = gdk_pixbuf_get_formats(); |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3700 | #else |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3701 | char *basename = g_path_get_basename(filename); |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3702 | char *ext = strrchr(basename, '.'); |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3703 | #endif |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3704 | char *newfilename; |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3705 | |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3706 | #if GTK_CHECK_VERSION(2,2,0) |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3707 | while (formats) { |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3708 | GdkPixbufFormat *format = formats->data; |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3709 | gchar **extensions = gdk_pixbuf_format_get_extensions(format); |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3710 | gpointer p = extensions; |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3711 | |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3712 | while(gdk_pixbuf_format_is_writable(format) && extensions && extensions[0]){ |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3713 | gchar *fmt_ext = extensions[0]; |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3714 | const gchar* file_ext = filename + strlen(filename) - strlen(fmt_ext); |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3715 | |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3716 | if(!g_ascii_strcasecmp(fmt_ext, file_ext)){ |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3717 | type = gdk_pixbuf_format_get_name(format); |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3718 | break; |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3719 | } |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3720 | |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3721 | extensions++; |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3722 | } |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3723 | |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3724 | g_strfreev(p); |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3725 | |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3726 | if (type) |
| 5012 | 3727 | break; |
|
27123
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3728 | |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3729 | formats = formats->next; |
| 5012 | 3730 | } |
| 3731 | ||
|
27123
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3732 | g_slist_free(formats); |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3733 | #else |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3734 | /* this is really ugly code, but I think it will work */ |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3735 | if (ext) { |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3736 | ext++; |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3737 | if (!g_ascii_strcasecmp(ext, "jpeg") || !g_ascii_strcasecmp(ext, "jpg")) |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3738 | type = g_strdup("jpeg"); |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3739 | else if (!g_ascii_strcasecmp(ext, "png")) |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3740 | type = g_strdup("png"); |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3741 | } |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3742 | |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3743 | g_free(basename); |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3744 | #endif |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3745 | |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3746 | /* If I can't find a valid type, I will just tell the user about it and then assume |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3747 | it's a png */ |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3748 | if (!type){ |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3749 | char *basename, *tmp; |
|
27125
60349fcd9f2b
Preserve the location when defaulting to png for saving unsupported image format.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27123
diff
changeset
|
3750 | char *dirname; |
|
27123
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3751 | #if GTK_CHECK_VERSION(2,4,0) |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3752 | GtkWidget *dialog = gtk_message_dialog_new_with_markup(NULL, 0, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3753 | _("<span size='larger' weight='bold'>Unrecognized file type</span>\n\nDefaulting to PNG.")); |
| 5020 | 3754 | #else |
|
27123
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3755 | GtkWidget *dialog = gtk_message_dialog_new(NULL, 0, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3756 | _("Unrecognized file type\n\nDefaulting to PNG.")); |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3757 | #endif |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3758 | |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3759 | g_signal_connect_swapped(dialog, "response", G_CALLBACK (gtk_widget_destroy), dialog); |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3760 | gtk_widget_show(dialog); |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3761 | |
| 5020 | 3762 | type = g_strdup("png"); |
|
27125
60349fcd9f2b
Preserve the location when defaulting to png for saving unsupported image format.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27123
diff
changeset
|
3763 | dirname = g_path_get_dirname(filename); |
|
27123
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3764 | basename = g_path_get_basename(filename); |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3765 | tmp = strrchr(basename, '.'); |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3766 | if (tmp != NULL) |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3767 | tmp[0] = '\0'; |
|
27125
60349fcd9f2b
Preserve the location when defaulting to png for saving unsupported image format.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27123
diff
changeset
|
3768 | newfilename = g_strdup_printf("%s" G_DIR_SEPARATOR_S "%s.png", dirname, basename); |
|
60349fcd9f2b
Preserve the location when defaulting to png for saving unsupported image format.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27123
diff
changeset
|
3769 | g_free(dirname); |
|
27123
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3770 | g_free(basename); |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3771 | } else { |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3772 | /* |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3773 | * We're able to save the file in it's original format, so we |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3774 | * can use the original file name. |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3775 | */ |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3776 | newfilename = g_strdup(filename); |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3777 | } |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3778 | |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3779 | gdk_pixbuf_save(image->pixbuf, newfilename, type, &error, NULL); |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3780 | |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3781 | g_free(newfilename); |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3782 | g_free(type); |
| 5020 | 3783 | } |
| 3784 | ||
|
9573
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3785 | if (error){ |
|
11069
3cc1cdd931e9
[gaim-migrate @ 13065]
Richard Laager <rlaager@pidgin.im>
parents:
11019
diff
changeset
|
3786 | #if GTK_CHECK_VERSION(2,4,0) |
|
11019
6786068b00ab
[gaim-migrate @ 12890]
Richard Laager <rlaager@pidgin.im>
parents:
11006
diff
changeset
|
3787 | GtkWidget *dialog = gtk_message_dialog_new_with_markup(NULL, 0, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, |
|
6786068b00ab
[gaim-migrate @ 12890]
Richard Laager <rlaager@pidgin.im>
parents:
11006
diff
changeset
|
3788 | _("<span size='larger' weight='bold'>Error saving image</span>\n\n%s"), error->message); |
|
11069
3cc1cdd931e9
[gaim-migrate @ 13065]
Richard Laager <rlaager@pidgin.im>
parents:
11019
diff
changeset
|
3789 | #else |
|
3cc1cdd931e9
[gaim-migrate @ 13065]
Richard Laager <rlaager@pidgin.im>
parents:
11019
diff
changeset
|
3790 | GtkWidget *dialog = gtk_message_dialog_new(NULL, 0, GTK_MESSAGE_ERROR, GTK_BUTTONS_OK, |
|
3cc1cdd931e9
[gaim-migrate @ 13065]
Richard Laager <rlaager@pidgin.im>
parents:
11019
diff
changeset
|
3791 | _("Error saving image\n\n%s"), error->message); |
|
3cc1cdd931e9
[gaim-migrate @ 13065]
Richard Laager <rlaager@pidgin.im>
parents:
11019
diff
changeset
|
3792 | #endif |
|
11019
6786068b00ab
[gaim-migrate @ 12890]
Richard Laager <rlaager@pidgin.im>
parents:
11006
diff
changeset
|
3793 | g_signal_connect_swapped(dialog, "response", G_CALLBACK (gtk_widget_destroy), dialog); |
|
6786068b00ab
[gaim-migrate @ 12890]
Richard Laager <rlaager@pidgin.im>
parents:
11006
diff
changeset
|
3794 | gtk_widget_show(dialog); |
| 5012 | 3795 | g_error_free(error); |
| 3796 | } | |
| 3797 | } | |
| 3798 | ||
|
9573
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3799 | #if GTK_CHECK_VERSION(2,4,0) /* FILECHOOSER */ |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3800 | static void |
|
27123
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3801 | image_save_check_if_exists_cb(GtkWidget *widget, gint response, GtkIMHtmlImageSave *save) |
|
9573
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3802 | { |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3803 | gchar *filename; |
|
27123
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3804 | GtkIMHtmlImage *image = (GtkIMHtmlImage *)save->image; |
|
9573
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3805 | |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3806 | if (response != GTK_RESPONSE_ACCEPT) { |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3807 | gtk_widget_destroy(widget); |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3808 | image->filesel = NULL; |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3809 | return; |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3810 | } |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3811 | |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3812 | filename = gtk_file_chooser_get_filename(GTK_FILE_CHOOSER(widget)); |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3813 | #else /* FILECHOOSER */ |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3814 | static void |
|
27123
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3815 | image_save_check_if_exists_cb(GtkWidget *button, GtkIMHtmlImageSave *save) |
| 5012 | 3816 | { |
|
9573
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3817 | gchar *filename; |
|
27123
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3818 | GtkIMHtmlImage *image = (GtkIMHtmlImage *)save->image; |
|
9573
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3819 | |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3820 | filename = g_strdup(gtk_file_selection_get_filename(GTK_FILE_SELECTION(image->filesel))); |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3821 | |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3822 | if (g_file_test(filename, G_FILE_TEST_IS_DIR)) { |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3823 | gchar *dirname; |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3824 | /* append a / is needed */ |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3825 | if (filename[strlen(filename) - 1] != G_DIR_SEPARATOR) { |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3826 | dirname = g_strconcat(filename, G_DIR_SEPARATOR_S, NULL); |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3827 | } else { |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3828 | dirname = g_strdup(filename); |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3829 | } |
|
9574
d5a2c770adcd
[gaim-migrate @ 10417]
Mark Doliner <markdoliner@pidgin.im>
parents:
9573
diff
changeset
|
3830 | gtk_file_selection_set_filename(GTK_FILE_SELECTION(image->filesel), dirname); |
|
9573
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3831 | g_free(dirname); |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3832 | g_free(filename); |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3833 | return; |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3834 | } |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3835 | #endif /* FILECHOOSER */ |
|
21985
bf0e936998e4
Move some curly braces around so static analysis tools can properly detect
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
21955
diff
changeset
|
3836 | #if 0 /* mismatched curly braces */ |
|
bf0e936998e4
Move some curly braces around so static analysis tools can properly detect
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
21955
diff
changeset
|
3837 | } |
|
bf0e936998e4
Move some curly braces around so static analysis tools can properly detect
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
21955
diff
changeset
|
3838 | #endif |
|
9573
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3839 | |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3840 | /* |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3841 | * XXX - We should probably prompt the user to determine if they really |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3842 | * want to overwrite the file or not. However, I don't feel like doing |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3843 | * that, so we're just always going to overwrite if the file exists. |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3844 | */ |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3845 | /* |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3846 | if (g_file_test(filename, G_FILE_TEST_EXISTS)) { |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3847 | } else |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3848 | image_save_yes_cb(image, filename); |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3849 | */ |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3850 | |
|
27123
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3851 | image_save_yes_cb(save, filename); |
|
9573
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3852 | |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3853 | g_free(filename); |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3854 | } |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3855 | |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3856 | #if !GTK_CHECK_VERSION(2,4,0) /* FILECHOOSER */ |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3857 | static void |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3858 | image_save_cancel_cb(GtkIMHtmlImage *image) |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3859 | { |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3860 | gtk_widget_destroy(image->filesel); |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3861 | image->filesel = NULL; |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3862 | } |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3863 | #endif /* FILECHOOSER */ |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3864 | |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3865 | static void |
|
27123
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3866 | gtk_imhtml_image_save(GtkWidget *w, GtkIMHtmlImageSave *save) |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3867 | { |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3868 | GtkIMHtmlImage *image = (GtkIMHtmlImage *)save->image; |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3869 | |
|
9573
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3870 | if (image->filesel != NULL) { |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3871 | gtk_window_present(GTK_WINDOW(image->filesel)); |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3872 | return; |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3873 | } |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3874 | |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3875 | #if GTK_CHECK_VERSION(2,4,0) /* FILECHOOSER */ |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3876 | image->filesel = gtk_file_chooser_dialog_new(_("Save Image"), |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3877 | NULL, |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3878 | GTK_FILE_CHOOSER_ACTION_SAVE, |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3879 | GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3880 | GTK_STOCK_SAVE, GTK_RESPONSE_ACCEPT, |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3881 | NULL); |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3882 | gtk_dialog_set_default_response(GTK_DIALOG(image->filesel), GTK_RESPONSE_ACCEPT); |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3883 | if (image->filename != NULL) |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3884 | gtk_file_chooser_set_current_name(GTK_FILE_CHOOSER(image->filesel), image->filename); |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3885 | g_signal_connect(G_OBJECT(GTK_FILE_CHOOSER(image->filesel)), "response", |
|
27123
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3886 | G_CALLBACK(image_save_check_if_exists_cb), save); |
|
9573
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3887 | #else /* FILECHOOSER */ |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3888 | image->filesel = gtk_file_selection_new(_("Save Image")); |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3889 | if (image->filename != NULL) |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3890 | gtk_file_selection_set_filename(GTK_FILE_SELECTION(image->filesel), image->filename); |
|
9574
d5a2c770adcd
[gaim-migrate @ 10417]
Mark Doliner <markdoliner@pidgin.im>
parents:
9573
diff
changeset
|
3891 | g_signal_connect_swapped(G_OBJECT(GTK_FILE_SELECTION(image->filesel)), "delete_event", |
|
d5a2c770adcd
[gaim-migrate @ 10417]
Mark Doliner <markdoliner@pidgin.im>
parents:
9573
diff
changeset
|
3892 | G_CALLBACK(image_save_cancel_cb), image); |
|
d5a2c770adcd
[gaim-migrate @ 10417]
Mark Doliner <markdoliner@pidgin.im>
parents:
9573
diff
changeset
|
3893 | g_signal_connect_swapped(G_OBJECT(GTK_FILE_SELECTION(image->filesel)->cancel_button), |
|
d5a2c770adcd
[gaim-migrate @ 10417]
Mark Doliner <markdoliner@pidgin.im>
parents:
9573
diff
changeset
|
3894 | "clicked", G_CALLBACK(image_save_cancel_cb), image); |
|
9573
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3895 | g_signal_connect(G_OBJECT(GTK_FILE_SELECTION(image->filesel)->ok_button), "clicked", |
|
27123
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3896 | G_CALLBACK(image_save_check_if_exists_cb), save); |
|
9573
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3897 | #endif /* FILECHOOSER */ |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3898 | |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3899 | gtk_widget_show(image->filesel); |
| 5012 | 3900 | } |
| 3901 | ||
|
23304
3aba02105818
Modified patch from malu to "Add context menu alternative to add received
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23302
diff
changeset
|
3902 | static void |
|
27259
50ab3ce89cdb
Allow adding received animated custom smileys to locale custom smiley
Andrea Piccinelli <frasten@gmail.com>
parents:
27173
diff
changeset
|
3903 | gtk_imhtml_custom_smiley_save(GtkWidget *w, GtkIMHtmlImageSave *save) |
|
50ab3ce89cdb
Allow adding received animated custom smileys to locale custom smiley
Andrea Piccinelli <frasten@gmail.com>
parents:
27173
diff
changeset
|
3904 | { |
|
50ab3ce89cdb
Allow adding received animated custom smileys to locale custom smiley
Andrea Piccinelli <frasten@gmail.com>
parents:
27173
diff
changeset
|
3905 | GtkIMHtmlImage *image = (GtkIMHtmlImage *)save->image; |
|
50ab3ce89cdb
Allow adding received animated custom smileys to locale custom smiley
Andrea Piccinelli <frasten@gmail.com>
parents:
27173
diff
changeset
|
3906 | |
|
23304
3aba02105818
Modified patch from malu to "Add context menu alternative to add received
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23302
diff
changeset
|
3907 | /* Create an add dialog */ |
|
3aba02105818
Modified patch from malu to "Add context menu alternative to add received
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23302
diff
changeset
|
3908 | PidginSmiley *editor = pidgin_smiley_edit(NULL, NULL); |
|
3aba02105818
Modified patch from malu to "Add context menu alternative to add received
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23302
diff
changeset
|
3909 | pidgin_smiley_editor_set_shortcut(editor, image->filename); |
|
3aba02105818
Modified patch from malu to "Add context menu alternative to add received
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23302
diff
changeset
|
3910 | pidgin_smiley_editor_set_image(editor, image->pixbuf); |
|
27259
50ab3ce89cdb
Allow adding received animated custom smileys to locale custom smiley
Andrea Piccinelli <frasten@gmail.com>
parents:
27173
diff
changeset
|
3911 | pidgin_smiley_editor_set_data(editor, save->data, save->datasize); |
|
23304
3aba02105818
Modified patch from malu to "Add context menu alternative to add received
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23302
diff
changeset
|
3912 | } |
|
3aba02105818
Modified patch from malu to "Add context menu alternative to add received
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23302
diff
changeset
|
3913 | |
|
9815
fcbbbce0e1ff
[gaim-migrate @ 10686]
Mark Doliner <markdoliner@pidgin.im>
parents:
9726
diff
changeset
|
3914 | /* |
|
fcbbbce0e1ff
[gaim-migrate @ 10686]
Mark Doliner <markdoliner@pidgin.im>
parents:
9726
diff
changeset
|
3915 | * So, um, AIM Direct IM lets you send any file, not just images. You can |
|
fcbbbce0e1ff
[gaim-migrate @ 10686]
Mark Doliner <markdoliner@pidgin.im>
parents:
9726
diff
changeset
|
3916 | * just insert a sound or a file or whatever in a conversation. It's |
|
fcbbbce0e1ff
[gaim-migrate @ 10686]
Mark Doliner <markdoliner@pidgin.im>
parents:
9726
diff
changeset
|
3917 | * basically like file transfer, except there is an icon to open the file |
| 15884 | 3918 | * embedded in the conversation. Someone should make the Purple core handle |
|
9815
fcbbbce0e1ff
[gaim-migrate @ 10686]
Mark Doliner <markdoliner@pidgin.im>
parents:
9726
diff
changeset
|
3919 | * all of that. |
|
fcbbbce0e1ff
[gaim-migrate @ 10686]
Mark Doliner <markdoliner@pidgin.im>
parents:
9726
diff
changeset
|
3920 | */ |
|
27123
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3921 | static gboolean gtk_imhtml_image_clicked(GtkWidget *w, GdkEvent *event, GtkIMHtmlImageSave *save) |
| 5012 | 3922 | { |
| 3923 | GdkEventButton *event_button = (GdkEventButton *) event; | |
|
27123
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3924 | GtkIMHtmlImage *image = (GtkIMHtmlImage *)save->image; |
| 5012 | 3925 | |
| 3926 | if (event->type == GDK_BUTTON_RELEASE) { | |
| 3927 | if(event_button->button == 3) { | |
| 3928 | GtkWidget *img, *item, *menu; | |
| 3929 | menu = gtk_menu_new(); | |
| 3930 | ||
| 3931 | /* buttons and such */ | |
| 3932 | img = gtk_image_new_from_stock(GTK_STOCK_SAVE, GTK_ICON_SIZE_MENU); | |
|
27122
a926d9d18bde
Avoid unnecessary strdup's.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27114
diff
changeset
|
3933 | item = gtk_image_menu_item_new_with_mnemonic(_("_Save Image...")); |
| 5012 | 3934 | gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(item), img); |
|
27123
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3935 | g_signal_connect(G_OBJECT(item), "activate", G_CALLBACK(gtk_imhtml_image_save), save); |
| 5012 | 3936 | gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); |
| 3937 | ||
|
23304
3aba02105818
Modified patch from malu to "Add context menu alternative to add received
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23302
diff
changeset
|
3938 | /* Add menu item for adding custom smiley to local smileys */ |
|
3aba02105818
Modified patch from malu to "Add context menu alternative to add received
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23302
diff
changeset
|
3939 | /* we only add the menu if the image is of "custom smiley size" |
|
3aba02105818
Modified patch from malu to "Add context menu alternative to add received
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23302
diff
changeset
|
3940 | <= 96x96 pixels */ |
|
3aba02105818
Modified patch from malu to "Add context menu alternative to add received
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23302
diff
changeset
|
3941 | if (image->width <= 96 && image->height <= 96) { |
|
3aba02105818
Modified patch from malu to "Add context menu alternative to add received
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23302
diff
changeset
|
3942 | img = gtk_image_new_from_stock(GTK_STOCK_ADD, GTK_ICON_SIZE_MENU); |
|
27122
a926d9d18bde
Avoid unnecessary strdup's.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27114
diff
changeset
|
3943 | item = gtk_image_menu_item_new_with_mnemonic(_("_Add Custom Smiley...")); |
|
23304
3aba02105818
Modified patch from malu to "Add context menu alternative to add received
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23302
diff
changeset
|
3944 | gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(item), img); |
|
3aba02105818
Modified patch from malu to "Add context menu alternative to add received
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23302
diff
changeset
|
3945 | g_signal_connect(G_OBJECT(item), "activate", |
|
27259
50ab3ce89cdb
Allow adding received animated custom smileys to locale custom smiley
Andrea Piccinelli <frasten@gmail.com>
parents:
27173
diff
changeset
|
3946 | G_CALLBACK(gtk_imhtml_custom_smiley_save), save); |
|
23304
3aba02105818
Modified patch from malu to "Add context menu alternative to add received
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23302
diff
changeset
|
3947 | gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); |
|
3aba02105818
Modified patch from malu to "Add context menu alternative to add received
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23302
diff
changeset
|
3948 | } |
|
3aba02105818
Modified patch from malu to "Add context menu alternative to add received
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23302
diff
changeset
|
3949 | |
| 5012 | 3950 | gtk_widget_show_all(menu); |
| 3951 | gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL, | |
| 3952 | event_button->button, event_button->time); | |
| 3953 | ||
| 3954 | return TRUE; | |
| 3955 | } | |
| 3956 | } | |
| 3957 | if(event->type == GDK_BUTTON_PRESS && event_button->button == 3) | |
| 3958 | return TRUE; /* Clicking the right mouse button on a link shouldn't | |
| 3959 | be caught by the regular GtkTextView menu */ | |
| 3960 | else | |
| 3961 | return FALSE; /* Let clicks go through if we didn't catch anything */ | |
| 3962 | ||
| 3963 | } | |
|
17009
2cc9edf33feb
Allow saving custom smileys by right-clicking on them. And use the custom smileys only on the received messages, not for the system/etc. messages.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16385
diff
changeset
|
3964 | |
|
2cc9edf33feb
Allow saving custom smileys by right-clicking on them. And use the custom smileys only on the received messages, not for the system/etc. messages.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16385
diff
changeset
|
3965 | static gboolean gtk_imhtml_smiley_clicked(GtkWidget *w, GdkEvent *event, GtkIMHtmlSmiley *smiley) |
|
2cc9edf33feb
Allow saving custom smileys by right-clicking on them. And use the custom smileys only on the received messages, not for the system/etc. messages.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16385
diff
changeset
|
3966 | { |
|
2cc9edf33feb
Allow saving custom smileys by right-clicking on them. And use the custom smileys only on the received messages, not for the system/etc. messages.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16385
diff
changeset
|
3967 | GdkPixbufAnimation *anim = NULL; |
|
27123
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3968 | GtkIMHtmlImageSave *save = NULL; |
|
17009
2cc9edf33feb
Allow saving custom smileys by right-clicking on them. And use the custom smileys only on the received messages, not for the system/etc. messages.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16385
diff
changeset
|
3969 | gboolean ret; |
|
23304
3aba02105818
Modified patch from malu to "Add context menu alternative to add received
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23302
diff
changeset
|
3970 | |
|
17009
2cc9edf33feb
Allow saving custom smileys by right-clicking on them. And use the custom smileys only on the received messages, not for the system/etc. messages.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16385
diff
changeset
|
3971 | if (event->type != GDK_BUTTON_RELEASE || ((GdkEventButton*)event)->button != 3) |
|
2cc9edf33feb
Allow saving custom smileys by right-clicking on them. And use the custom smileys only on the received messages, not for the system/etc. messages.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16385
diff
changeset
|
3972 | return FALSE; |
|
2cc9edf33feb
Allow saving custom smileys by right-clicking on them. And use the custom smileys only on the received messages, not for the system/etc. messages.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16385
diff
changeset
|
3973 | |
|
2cc9edf33feb
Allow saving custom smileys by right-clicking on them. And use the custom smileys only on the received messages, not for the system/etc. messages.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16385
diff
changeset
|
3974 | anim = gtk_smiley_get_image(smiley); |
|
2cc9edf33feb
Allow saving custom smileys by right-clicking on them. And use the custom smileys only on the received messages, not for the system/etc. messages.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16385
diff
changeset
|
3975 | if (!anim) |
|
2cc9edf33feb
Allow saving custom smileys by right-clicking on them. And use the custom smileys only on the received messages, not for the system/etc. messages.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16385
diff
changeset
|
3976 | return FALSE; |
|
2cc9edf33feb
Allow saving custom smileys by right-clicking on them. And use the custom smileys only on the received messages, not for the system/etc. messages.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16385
diff
changeset
|
3977 | |
|
27123
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3978 | save = g_new0(GtkIMHtmlImageSave, 1); |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3979 | save->image = (GtkIMHtmlScalable *)gtk_imhtml_animation_new(anim, smiley->smile, 0); |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3980 | save->data = smiley->data; /* Do not need to memdup here, since the smiley is not |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3981 | destroyed before this GtkIMHtmlImageSave */ |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3982 | save->datasize = smiley->datasize; |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3983 | ret = gtk_imhtml_image_clicked(w, event, save); |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3984 | g_object_set_data_full(G_OBJECT(w), "image-data", save->image, (GDestroyNotify)gtk_imhtml_animation_free); |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
3985 | g_object_set_data_full(G_OBJECT(w), "image-save-data", save, (GDestroyNotify)g_free); |
|
17009
2cc9edf33feb
Allow saving custom smileys by right-clicking on them. And use the custom smileys only on the received messages, not for the system/etc. messages.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16385
diff
changeset
|
3986 | return ret; |
|
2cc9edf33feb
Allow saving custom smileys by right-clicking on them. And use the custom smileys only on the received messages, not for the system/etc. messages.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16385
diff
changeset
|
3987 | } |
|
2cc9edf33feb
Allow saving custom smileys by right-clicking on them. And use the custom smileys only on the received messages, not for the system/etc. messages.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16385
diff
changeset
|
3988 | |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
3989 | void gtk_imhtml_image_free(GtkIMHtmlScalable *scale) |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
3990 | { |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
3991 | GtkIMHtmlImage *image = (GtkIMHtmlImage *)scale; |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
3992 | |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
3993 | g_object_unref(image->pixbuf); |
|
14097
0c340861ab79
[gaim-migrate @ 16638]
Mark Doliner <markdoliner@pidgin.im>
parents:
14010
diff
changeset
|
3994 | g_free(image->filename); |
|
9573
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3995 | if (image->filesel) |
|
7fb26654aee8
[gaim-migrate @ 10416]
Mark Doliner <markdoliner@pidgin.im>
parents:
9467
diff
changeset
|
3996 | gtk_widget_destroy(image->filesel); |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
3997 | g_free(scale); |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
3998 | } |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
3999 | |
|
18151
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
4000 | void gtk_imhtml_animation_free(GtkIMHtmlScalable *scale) |
|
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
4001 | { |
|
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
4002 | GtkIMHtmlAnimation *animation = (GtkIMHtmlAnimation *)scale; |
|
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
4003 | |
|
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
4004 | if (animation->timer > 0) |
|
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
4005 | g_source_remove(animation->timer); |
|
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
4006 | if (animation->iter != NULL) |
|
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
4007 | g_object_unref(animation->iter); |
|
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
4008 | g_object_unref(animation->anim); |
|
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
4009 | |
|
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
4010 | gtk_imhtml_image_free(scale); |
|
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
4011 | } |
|
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
4012 | |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
4013 | void gtk_imhtml_image_add_to(GtkIMHtmlScalable *scale, GtkIMHtml *imhtml, GtkTextIter *iter) |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
4014 | { |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
4015 | GtkIMHtmlImage *image = (GtkIMHtmlImage *)scale; |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
4016 | GtkWidget *box = gtk_event_box_new(); |
| 8962 | 4017 | char *tag; |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
4018 | GtkTextChildAnchor *anchor = gtk_text_buffer_create_child_anchor(imhtml->text_buffer, iter); |
|
27123
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
4019 | GtkIMHtmlImageSave *save; |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
4020 | |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
4021 | gtk_container_add(GTK_CONTAINER(box), GTK_WIDGET(image->image)); |
| 9229 | 4022 | |
| 4023 | if(!gtk_check_version(2, 4, 0)) | |
| 4024 | g_object_set(G_OBJECT(box), "visible-window", FALSE, NULL); | |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
4025 | |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
4026 | gtk_widget_show(GTK_WIDGET(image->image)); |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
4027 | gtk_widget_show(box); |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
4028 | |
| 8962 | 4029 | tag = g_strdup_printf("<IMG ID=\"%d\">", image->id); |
| 4030 | g_object_set_data_full(G_OBJECT(anchor), "gtkimhtml_htmltext", tag, g_free); | |
| 4031 | g_object_set_data(G_OBJECT(anchor), "gtkimhtml_plaintext", "[Image]"); | |
| 4032 | ||
| 15420 | 4033 | gtk_text_view_add_child_at_anchor(GTK_TEXT_VIEW(imhtml), box, anchor); |
|
27123
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
4034 | |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
4035 | save = g_new0(GtkIMHtmlImageSave, 1); |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
4036 | save->image = scale; |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
4037 | g_signal_connect(G_OBJECT(box), "event", G_CALLBACK(gtk_imhtml_image_clicked), save); |
|
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
4038 | g_object_set_data_full(G_OBJECT(box), "image-save-data", save, (GDestroyNotify)g_free); |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
4039 | } |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
4040 | |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
4041 | GtkIMHtmlScalable *gtk_imhtml_hr_new() |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
4042 | { |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
4043 | GtkIMHtmlHr *hr = g_malloc(sizeof(GtkIMHtmlHr)); |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
4044 | |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
4045 | GTK_IMHTML_SCALABLE(hr)->scale = gtk_imhtml_hr_scale; |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
4046 | GTK_IMHTML_SCALABLE(hr)->add_to = gtk_imhtml_hr_add_to; |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
4047 | GTK_IMHTML_SCALABLE(hr)->free = gtk_imhtml_hr_free; |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
4048 | |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
4049 | hr->sep = gtk_hseparator_new(); |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
4050 | gtk_widget_set_size_request(hr->sep, 5000, 2); |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
4051 | gtk_widget_show(hr->sep); |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
4052 | |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
4053 | return GTK_IMHTML_SCALABLE(hr); |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
4054 | } |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
4055 | |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
4056 | void gtk_imhtml_hr_scale(GtkIMHtmlScalable *scale, int width, int height) |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
4057 | { |
|
8588
6bcf7ed80ed8
[gaim-migrate @ 9339]
Mark Doliner <markdoliner@pidgin.im>
parents:
8568
diff
changeset
|
4058 | gtk_widget_set_size_request(((GtkIMHtmlHr *)scale)->sep, width - 2, 2); |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
4059 | } |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
4060 | |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
4061 | void gtk_imhtml_hr_add_to(GtkIMHtmlScalable *scale, GtkIMHtml *imhtml, GtkTextIter *iter) |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
4062 | { |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
4063 | GtkIMHtmlHr *hr = (GtkIMHtmlHr *)scale; |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
4064 | GtkTextChildAnchor *anchor = gtk_text_buffer_create_child_anchor(imhtml->text_buffer, iter); |
| 8698 | 4065 | g_object_set_data(G_OBJECT(anchor), "gtkimhtml_htmltext", "<hr>"); |
| 4066 | g_object_set_data(G_OBJECT(anchor), "gtkimhtml_plaintext", "\n---\n"); | |
| 15420 | 4067 | gtk_text_view_add_child_at_anchor(GTK_TEXT_VIEW(imhtml), hr->sep, anchor); |
|
5967
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
4068 | } |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
4069 | |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
4070 | void gtk_imhtml_hr_free(GtkIMHtmlScalable *scale) |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
4071 | { |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
4072 | g_free(scale); |
|
df8268ccde45
[gaim-migrate @ 6414]
Mark Doliner <markdoliner@pidgin.im>
parents:
5966
diff
changeset
|
4073 | } |
| 7295 | 4074 | |
| 4075 | gboolean gtk_imhtml_search_find(GtkIMHtml *imhtml, const gchar *text) | |
| 4076 | { | |
| 4077 | GtkTextIter iter, start, end; | |
| 4078 | gboolean new_search = TRUE; | |
|
14863
82888d51234c
[gaim-migrate @ 17566]
Daniel Atallah <datallah@pidgin.im>
parents:
14821
diff
changeset
|
4079 | GtkTextMark *start_mark; |
| 7295 | 4080 | |
| 4081 | g_return_val_if_fail(imhtml != NULL, FALSE); | |
| 4082 | g_return_val_if_fail(text != NULL, FALSE); | |
| 8061 | 4083 | |
|
14863
82888d51234c
[gaim-migrate @ 17566]
Daniel Atallah <datallah@pidgin.im>
parents:
14821
diff
changeset
|
4084 | start_mark = gtk_text_buffer_get_mark(imhtml->text_buffer, "search"); |
|
82888d51234c
[gaim-migrate @ 17566]
Daniel Atallah <datallah@pidgin.im>
parents:
14821
diff
changeset
|
4085 | |
|
82888d51234c
[gaim-migrate @ 17566]
Daniel Atallah <datallah@pidgin.im>
parents:
14821
diff
changeset
|
4086 | if (start_mark && imhtml->search_string && !strcmp(text, imhtml->search_string)) |
| 7295 | 4087 | new_search = FALSE; |
| 8061 | 4088 | |
| 7295 | 4089 | if (new_search) { |
| 4090 | gtk_imhtml_search_clear(imhtml); | |
|
14863
82888d51234c
[gaim-migrate @ 17566]
Daniel Atallah <datallah@pidgin.im>
parents:
14821
diff
changeset
|
4091 | g_free(imhtml->search_string); |
|
82888d51234c
[gaim-migrate @ 17566]
Daniel Atallah <datallah@pidgin.im>
parents:
14821
diff
changeset
|
4092 | imhtml->search_string = g_strdup(text); |
| 15093 | 4093 | gtk_text_buffer_get_end_iter(imhtml->text_buffer, &iter); |
| 7295 | 4094 | } else { |
| 4095 | gtk_text_buffer_get_iter_at_mark(imhtml->text_buffer, &iter, | |
|
14863
82888d51234c
[gaim-migrate @ 17566]
Daniel Atallah <datallah@pidgin.im>
parents:
14821
diff
changeset
|
4096 | start_mark); |
| 7295 | 4097 | } |
| 4098 | ||
| 15093 | 4099 | if (gtk_source_iter_backward_search(&iter, imhtml->search_string, |
|
14400
953baf2eba1a
[gaim-migrate @ 17035]
Richard Laager <rlaager@pidgin.im>
parents:
14395
diff
changeset
|
4100 | GTK_SOURCE_SEARCH_VISIBLE_ONLY | GTK_SOURCE_SEARCH_CASE_INSENSITIVE, |
|
953baf2eba1a
[gaim-migrate @ 17035]
Richard Laager <rlaager@pidgin.im>
parents:
14395
diff
changeset
|
4101 | &start, &end, NULL)) |
|
953baf2eba1a
[gaim-migrate @ 17035]
Richard Laager <rlaager@pidgin.im>
parents:
14395
diff
changeset
|
4102 | { |
| 7295 | 4103 | gtk_text_view_scroll_to_iter(GTK_TEXT_VIEW(imhtml), &start, 0, TRUE, 0, 0); |
| 15093 | 4104 | gtk_text_buffer_create_mark(imhtml->text_buffer, "search", &start, FALSE); |
|
14400
953baf2eba1a
[gaim-migrate @ 17035]
Richard Laager <rlaager@pidgin.im>
parents:
14395
diff
changeset
|
4105 | if (new_search) |
|
953baf2eba1a
[gaim-migrate @ 17035]
Richard Laager <rlaager@pidgin.im>
parents:
14395
diff
changeset
|
4106 | { |
| 7295 | 4107 | gtk_text_buffer_remove_tag_by_name(imhtml->text_buffer, "search", &iter, &end); |
| 8061 | 4108 | do |
| 7295 | 4109 | gtk_text_buffer_apply_tag_by_name(imhtml->text_buffer, "search", &start, &end); |
| 15093 | 4110 | while (gtk_source_iter_backward_search(&start, imhtml->search_string, |
| 8061 | 4111 | GTK_SOURCE_SEARCH_VISIBLE_ONLY | |
| 7358 | 4112 | GTK_SOURCE_SEARCH_CASE_INSENSITIVE, |
| 7295 | 4113 | &start, &end, NULL)); |
| 4114 | } | |
| 4115 | return TRUE; | |
| 4116 | } | |
|
14400
953baf2eba1a
[gaim-migrate @ 17035]
Richard Laager <rlaager@pidgin.im>
parents:
14395
diff
changeset
|
4117 | else if (!new_search) |
|
953baf2eba1a
[gaim-migrate @ 17035]
Richard Laager <rlaager@pidgin.im>
parents:
14395
diff
changeset
|
4118 | { |
|
953baf2eba1a
[gaim-migrate @ 17035]
Richard Laager <rlaager@pidgin.im>
parents:
14395
diff
changeset
|
4119 | /* We hit the end, so start at the beginning again. */ |
| 15093 | 4120 | gtk_text_buffer_get_end_iter(imhtml->text_buffer, &iter); |
| 4121 | ||
| 4122 | if (gtk_source_iter_backward_search(&iter, imhtml->search_string, | |
|
14400
953baf2eba1a
[gaim-migrate @ 17035]
Richard Laager <rlaager@pidgin.im>
parents:
14395
diff
changeset
|
4123 | GTK_SOURCE_SEARCH_VISIBLE_ONLY | GTK_SOURCE_SEARCH_CASE_INSENSITIVE, |
|
953baf2eba1a
[gaim-migrate @ 17035]
Richard Laager <rlaager@pidgin.im>
parents:
14395
diff
changeset
|
4124 | &start, &end, NULL)) |
|
953baf2eba1a
[gaim-migrate @ 17035]
Richard Laager <rlaager@pidgin.im>
parents:
14395
diff
changeset
|
4125 | { |
|
953baf2eba1a
[gaim-migrate @ 17035]
Richard Laager <rlaager@pidgin.im>
parents:
14395
diff
changeset
|
4126 | gtk_text_view_scroll_to_iter(GTK_TEXT_VIEW(imhtml), &start, 0, TRUE, 0, 0); |
| 15093 | 4127 | gtk_text_buffer_create_mark(imhtml->text_buffer, "search", &start, FALSE); |
|
14400
953baf2eba1a
[gaim-migrate @ 17035]
Richard Laager <rlaager@pidgin.im>
parents:
14395
diff
changeset
|
4128 | |
|
953baf2eba1a
[gaim-migrate @ 17035]
Richard Laager <rlaager@pidgin.im>
parents:
14395
diff
changeset
|
4129 | return TRUE; |
|
953baf2eba1a
[gaim-migrate @ 17035]
Richard Laager <rlaager@pidgin.im>
parents:
14395
diff
changeset
|
4130 | } |
|
953baf2eba1a
[gaim-migrate @ 17035]
Richard Laager <rlaager@pidgin.im>
parents:
14395
diff
changeset
|
4131 | |
|
953baf2eba1a
[gaim-migrate @ 17035]
Richard Laager <rlaager@pidgin.im>
parents:
14395
diff
changeset
|
4132 | } |
| 8061 | 4133 | |
| 7295 | 4134 | return FALSE; |
| 4135 | } | |
| 4136 | ||
| 4137 | void gtk_imhtml_search_clear(GtkIMHtml *imhtml) | |
| 4138 | { | |
| 4139 | GtkTextIter start, end; | |
| 8061 | 4140 | |
| 7295 | 4141 | g_return_if_fail(imhtml != NULL); |
| 8061 | 4142 | |
| 7295 | 4143 | gtk_text_buffer_get_start_iter(imhtml->text_buffer, &start); |
| 4144 | gtk_text_buffer_get_end_iter(imhtml->text_buffer, &end); | |
| 4145 | ||
| 4146 | gtk_text_buffer_remove_tag_by_name(imhtml->text_buffer, "search", &start, &end); | |
|
14097
0c340861ab79
[gaim-migrate @ 16638]
Mark Doliner <markdoliner@pidgin.im>
parents:
14010
diff
changeset
|
4147 | g_free(imhtml->search_string); |
| 7295 | 4148 | imhtml->search_string = NULL; |
| 4149 | } | |
| 8061 | 4150 | |
| 8677 | 4151 | static GtkTextTag *find_font_forecolor_tag(GtkIMHtml *imhtml, gchar *color) |
| 4152 | { | |
| 4153 | gchar str[18]; | |
| 4154 | GtkTextTag *tag; | |
| 4155 | ||
| 4156 | g_snprintf(str, sizeof(str), "FORECOLOR %s", color); | |
| 4157 | ||
| 4158 | tag = gtk_text_tag_table_lookup(gtk_text_buffer_get_tag_table(imhtml->text_buffer), str); | |
| 10858 | 4159 | if (!tag) { |
| 4160 | GdkColor gcolor; | |
| 4161 | if (!gdk_color_parse(color, &gcolor)) { | |
| 4162 | gchar tmp[8]; | |
| 4163 | tmp[0] = '#'; | |
| 4164 | strncpy(&tmp[1], color, 7); | |
| 4165 | tmp[7] = '\0'; | |
| 4166 | if (!gdk_color_parse(tmp, &gcolor)) | |
| 4167 | gdk_color_parse("black", &gcolor); | |
| 4168 | } | |
| 4169 | tag = gtk_text_buffer_create_tag(imhtml->text_buffer, str, "foreground-gdk", &gcolor, NULL); | |
| 4170 | } | |
| 8677 | 4171 | |
| 4172 | return tag; | |
| 4173 | } | |
| 4174 | ||
| 4175 | static GtkTextTag *find_font_backcolor_tag(GtkIMHtml *imhtml, gchar *color) | |
| 4176 | { | |
| 4177 | gchar str[18]; | |
| 4178 | GtkTextTag *tag; | |
| 4179 | ||
| 4180 | g_snprintf(str, sizeof(str), "BACKCOLOR %s", color); | |
| 4181 | ||
| 4182 | tag = gtk_text_tag_table_lookup(gtk_text_buffer_get_tag_table(imhtml->text_buffer), str); | |
| 10858 | 4183 | if (!tag) { |
| 4184 | GdkColor gcolor; | |
| 4185 | if (!gdk_color_parse(color, &gcolor)) { | |
| 4186 | gchar tmp[8]; | |
| 4187 | tmp[0] = '#'; | |
| 4188 | strncpy(&tmp[1], color, 7); | |
| 4189 | tmp[7] = '\0'; | |
| 4190 | if (!gdk_color_parse(tmp, &gcolor)) | |
| 4191 | gdk_color_parse("white", &gcolor); | |
| 4192 | } | |
| 4193 | tag = gtk_text_buffer_create_tag(imhtml->text_buffer, str, "background-gdk", &gcolor, NULL); | |
| 4194 | } | |
| 8677 | 4195 | |
| 4196 | return tag; | |
| 4197 | } | |
| 4198 | ||
| 10776 | 4199 | static GtkTextTag *find_font_background_tag(GtkIMHtml *imhtml, gchar *color) |
| 4200 | { | |
| 4201 | gchar str[19]; | |
| 4202 | GtkTextTag *tag; | |
| 4203 | ||
| 4204 | g_snprintf(str, sizeof(str), "BACKGROUND %s", color); | |
| 4205 | ||
| 4206 | tag = gtk_text_tag_table_lookup(gtk_text_buffer_get_tag_table(imhtml->text_buffer), str); | |
| 4207 | if (!tag) | |
| 4208 | tag = gtk_text_buffer_create_tag(imhtml->text_buffer, str, NULL); | |
| 4209 | ||
| 4210 | return tag; | |
| 4211 | } | |
| 4212 | ||
| 8677 | 4213 | static GtkTextTag *find_font_face_tag(GtkIMHtml *imhtml, gchar *face) |
| 8061 | 4214 | { |
| 8677 | 4215 | gchar str[256]; |
| 4216 | GtkTextTag *tag; | |
| 4217 | ||
| 4218 | g_snprintf(str, sizeof(str), "FONT FACE %s", face); | |
| 4219 | str[255] = '\0'; | |
| 4220 | ||
| 4221 | tag = gtk_text_tag_table_lookup(gtk_text_buffer_get_tag_table(imhtml->text_buffer), str); | |
| 4222 | if (!tag) | |
| 4223 | tag = gtk_text_buffer_create_tag(imhtml->text_buffer, str, "family", face, NULL); | |
| 4224 | ||
| 4225 | return tag; | |
| 4226 | } | |
| 4227 | ||
| 4228 | static GtkTextTag *find_font_size_tag(GtkIMHtml *imhtml, int size) | |
| 4229 | { | |
| 4230 | gchar str[24]; | |
| 4231 | GtkTextTag *tag; | |
| 4232 | ||
| 4233 | g_snprintf(str, sizeof(str), "FONT SIZE %d", size); | |
| 4234 | str[23] = '\0'; | |
| 4235 | ||
| 4236 | tag = gtk_text_tag_table_lookup(gtk_text_buffer_get_tag_table(imhtml->text_buffer), str); | |
| 4237 | if (!tag) { | |
| 10525 | 4238 | /* For reasons I don't understand, setting "scale" here scaled |
| 4239 | * based on some default size other than my theme's default | |
| 4240 | * size. Our size 4 was actually smaller than our size 3 for | |
| 4241 | * me. So this works around that oddity. | |
| 8677 | 4242 | */ |
| 10525 | 4243 | GtkTextAttributes *attr = gtk_text_view_get_default_attributes(GTK_TEXT_VIEW(imhtml)); |
| 8677 | 4244 | tag = gtk_text_buffer_create_tag(imhtml->text_buffer, str, "size", |
| 10525 | 4245 | (gint) (pango_font_description_get_size(attr->font) * |
|
10899
87d9aec5b72d
[gaim-migrate @ 12619]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10871
diff
changeset
|
4246 | (double) POINT_SIZE(size)), NULL); |
| 10525 | 4247 | gtk_text_attributes_unref(attr); |
| 8061 | 4248 | } |
| 4249 | ||
| 8677 | 4250 | return tag; |
| 4251 | } | |
| 4252 | ||
| 4253 | static void remove_tag_by_prefix(GtkIMHtml *imhtml, const GtkTextIter *i, const GtkTextIter *e, | |
| 4254 | const char *prefix, guint len, gboolean homo) | |
| 4255 | { | |
| 4256 | GSList *tags, *l; | |
| 4257 | GtkTextIter iter; | |
| 4258 | ||
| 4259 | tags = gtk_text_iter_get_tags(i); | |
| 4260 | ||
| 4261 | for (l = tags; l; l = l->next) { | |
| 4262 | GtkTextTag *tag = l->data; | |
| 4263 | ||
| 4264 | if (tag->name && !strncmp(tag->name, prefix, len)) | |
| 4265 | gtk_text_buffer_remove_tag(imhtml->text_buffer, tag, i, e); | |
| 8061 | 4266 | } |
| 4267 | ||
| 8677 | 4268 | g_slist_free(tags); |
| 4269 | ||
| 4270 | if (homo) | |
| 4271 | return; | |
| 4272 | ||
| 4273 | iter = *i; | |
| 4274 | ||
| 4275 | while (gtk_text_iter_forward_char(&iter) && !gtk_text_iter_equal(&iter, e)) { | |
| 4276 | if (gtk_text_iter_begins_tag(&iter, NULL)) { | |
| 4277 | tags = gtk_text_iter_get_toggled_tags(&iter, TRUE); | |
| 4278 | ||
| 4279 | for (l = tags; l; l = l->next) { | |
| 4280 | GtkTextTag *tag = l->data; | |
| 4281 | ||
| 4282 | if (tag->name && !strncmp(tag->name, prefix, len)) | |
| 4283 | gtk_text_buffer_remove_tag(imhtml->text_buffer, tag, &iter, e); | |
| 4284 | } | |
| 4285 | ||
| 4286 | g_slist_free(tags); | |
| 4287 | } | |
| 8061 | 4288 | } |
| 8677 | 4289 | } |
| 4290 | ||
| 4291 | static void remove_font_size(GtkIMHtml *imhtml, GtkTextIter *i, GtkTextIter *e, gboolean homo) | |
| 4292 | { | |
| 4293 | remove_tag_by_prefix(imhtml, i, e, "FONT SIZE ", 10, homo); | |
| 4294 | } | |
| 4295 | ||
| 4296 | static void remove_font_face(GtkIMHtml *imhtml, GtkTextIter *i, GtkTextIter *e, gboolean homo) | |
| 4297 | { | |
| 4298 | remove_tag_by_prefix(imhtml, i, e, "FONT FACE ", 10, homo); | |
| 4299 | } | |
| 4300 | ||
| 4301 | static void remove_font_forecolor(GtkIMHtml *imhtml, GtkTextIter *i, GtkTextIter *e, gboolean homo) | |
| 4302 | { | |
| 4303 | remove_tag_by_prefix(imhtml, i, e, "FORECOLOR ", 10, homo); | |
| 4304 | } | |
| 4305 | ||
| 4306 | static void remove_font_backcolor(GtkIMHtml *imhtml, GtkTextIter *i, GtkTextIter *e, gboolean homo) | |
| 4307 | { | |
| 4308 | remove_tag_by_prefix(imhtml, i, e, "BACKCOLOR ", 10, homo); | |
| 4309 | } | |
| 4310 | ||
| 10776 | 4311 | static void remove_font_background(GtkIMHtml *imhtml, GtkTextIter *i, GtkTextIter *e, gboolean homo) |
| 4312 | { | |
| 4313 | remove_tag_by_prefix(imhtml, i, e, "BACKGROUND ", 10, homo); | |
| 4314 | } | |
| 4315 | ||
| 8677 | 4316 | static void remove_font_link(GtkIMHtml *imhtml, GtkTextIter *i, GtkTextIter *e, gboolean homo) |
| 4317 | { | |
| 4318 | remove_tag_by_prefix(imhtml, i, e, "LINK ", 5, homo); | |
| 4319 | } | |
| 4320 | ||
|
12672
673e2a1d2954
[gaim-migrate @ 15015]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12635
diff
changeset
|
4321 | static void |
|
673e2a1d2954
[gaim-migrate @ 15015]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12635
diff
changeset
|
4322 | imhtml_clear_formatting(GtkIMHtml *imhtml) |
|
673e2a1d2954
[gaim-migrate @ 15015]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12635
diff
changeset
|
4323 | { |
|
673e2a1d2954
[gaim-migrate @ 15015]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12635
diff
changeset
|
4324 | GtkTextIter start, end; |
|
673e2a1d2954
[gaim-migrate @ 15015]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12635
diff
changeset
|
4325 | |
|
12796
8fb3611a91e1
[gaim-migrate @ 15143]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12673
diff
changeset
|
4326 | if (!imhtml->editable) |
|
8fb3611a91e1
[gaim-migrate @ 15143]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12673
diff
changeset
|
4327 | return; |
|
8fb3611a91e1
[gaim-migrate @ 15143]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12673
diff
changeset
|
4328 | |
|
28935
84dbc0ca215d
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28932
diff
changeset
|
4329 | if (!imhtml_get_iter_bounds(imhtml, &start, &end)) |
|
84dbc0ca215d
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28932
diff
changeset
|
4330 | return; |
|
12672
673e2a1d2954
[gaim-migrate @ 15015]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12635
diff
changeset
|
4331 | |
|
673e2a1d2954
[gaim-migrate @ 15015]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12635
diff
changeset
|
4332 | gtk_text_buffer_remove_tag_by_name(imhtml->text_buffer, "BOLD", &start, &end); |
|
673e2a1d2954
[gaim-migrate @ 15015]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12635
diff
changeset
|
4333 | gtk_text_buffer_remove_tag_by_name(imhtml->text_buffer, "ITALICS", &start, &end); |
|
673e2a1d2954
[gaim-migrate @ 15015]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12635
diff
changeset
|
4334 | gtk_text_buffer_remove_tag_by_name(imhtml->text_buffer, "UNDERLINE", &start, &end); |
|
673e2a1d2954
[gaim-migrate @ 15015]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12635
diff
changeset
|
4335 | gtk_text_buffer_remove_tag_by_name(imhtml->text_buffer, "STRIKE", &start, &end); |
|
13224
485977c61b47
[gaim-migrate @ 15587]
Richard Laager <rlaager@pidgin.im>
parents:
13138
diff
changeset
|
4336 | remove_font_size(imhtml, &start, &end, FALSE); |
|
485977c61b47
[gaim-migrate @ 15587]
Richard Laager <rlaager@pidgin.im>
parents:
13138
diff
changeset
|
4337 | remove_font_face(imhtml, &start, &end, FALSE); |
|
485977c61b47
[gaim-migrate @ 15587]
Richard Laager <rlaager@pidgin.im>
parents:
13138
diff
changeset
|
4338 | remove_font_forecolor(imhtml, &start, &end, FALSE); |
|
485977c61b47
[gaim-migrate @ 15587]
Richard Laager <rlaager@pidgin.im>
parents:
13138
diff
changeset
|
4339 | remove_font_backcolor(imhtml, &start, &end, FALSE); |
|
485977c61b47
[gaim-migrate @ 15587]
Richard Laager <rlaager@pidgin.im>
parents:
13138
diff
changeset
|
4340 | remove_font_background(imhtml, &start, &end, FALSE); |
|
485977c61b47
[gaim-migrate @ 15587]
Richard Laager <rlaager@pidgin.im>
parents:
13138
diff
changeset
|
4341 | remove_font_link(imhtml, &start, &end, FALSE); |
|
12672
673e2a1d2954
[gaim-migrate @ 15015]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12635
diff
changeset
|
4342 | |
|
673e2a1d2954
[gaim-migrate @ 15015]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12635
diff
changeset
|
4343 | imhtml->edit.bold = 0; |
|
673e2a1d2954
[gaim-migrate @ 15015]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12635
diff
changeset
|
4344 | imhtml->edit.italic = 0; |
|
673e2a1d2954
[gaim-migrate @ 15015]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12635
diff
changeset
|
4345 | imhtml->edit.underline = 0; |
|
673e2a1d2954
[gaim-migrate @ 15015]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12635
diff
changeset
|
4346 | imhtml->edit.strike = 0; |
|
673e2a1d2954
[gaim-migrate @ 15015]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12635
diff
changeset
|
4347 | imhtml->edit.fontsize = 0; |
|
13224
485977c61b47
[gaim-migrate @ 15587]
Richard Laager <rlaager@pidgin.im>
parents:
13138
diff
changeset
|
4348 | |
|
485977c61b47
[gaim-migrate @ 15587]
Richard Laager <rlaager@pidgin.im>
parents:
13138
diff
changeset
|
4349 | g_free(imhtml->edit.fontface); |
|
485977c61b47
[gaim-migrate @ 15587]
Richard Laager <rlaager@pidgin.im>
parents:
13138
diff
changeset
|
4350 | imhtml->edit.fontface = NULL; |
|
485977c61b47
[gaim-migrate @ 15587]
Richard Laager <rlaager@pidgin.im>
parents:
13138
diff
changeset
|
4351 | |
|
485977c61b47
[gaim-migrate @ 15587]
Richard Laager <rlaager@pidgin.im>
parents:
13138
diff
changeset
|
4352 | g_free(imhtml->edit.forecolor); |
|
12672
673e2a1d2954
[gaim-migrate @ 15015]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12635
diff
changeset
|
4353 | imhtml->edit.forecolor = NULL; |
|
13224
485977c61b47
[gaim-migrate @ 15587]
Richard Laager <rlaager@pidgin.im>
parents:
13138
diff
changeset
|
4354 | |
|
485977c61b47
[gaim-migrate @ 15587]
Richard Laager <rlaager@pidgin.im>
parents:
13138
diff
changeset
|
4355 | g_free(imhtml->edit.backcolor); |
|
12672
673e2a1d2954
[gaim-migrate @ 15015]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12635
diff
changeset
|
4356 | imhtml->edit.backcolor = NULL; |
|
13224
485977c61b47
[gaim-migrate @ 15587]
Richard Laager <rlaager@pidgin.im>
parents:
13138
diff
changeset
|
4357 | |
|
485977c61b47
[gaim-migrate @ 15587]
Richard Laager <rlaager@pidgin.im>
parents:
13138
diff
changeset
|
4358 | g_free(imhtml->edit.background); |
|
12672
673e2a1d2954
[gaim-migrate @ 15015]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12635
diff
changeset
|
4359 | imhtml->edit.background = NULL; |
|
673e2a1d2954
[gaim-migrate @ 15015]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12635
diff
changeset
|
4360 | } |
|
673e2a1d2954
[gaim-migrate @ 15015]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12635
diff
changeset
|
4361 | |
| 8677 | 4362 | /* Editable stuff */ |
| 4363 | static void preinsert_cb(GtkTextBuffer *buffer, GtkTextIter *iter, gchar *text, gint len, GtkIMHtml *imhtml) | |
| 4364 | { | |
| 4365 | imhtml->insert_offset = gtk_text_iter_get_offset(iter); | |
| 4366 | } | |
| 4367 | ||
| 10169 | 4368 | static void insert_ca_cb(GtkTextBuffer *buffer, GtkTextIter *arg1, GtkTextChildAnchor *arg2, gpointer user_data) |
| 4369 | { | |
| 4370 | GtkTextIter start; | |
| 4371 | ||
| 4372 | start = *arg1; | |
| 4373 | gtk_text_iter_backward_char(&start); | |
| 4374 | ||
| 4375 | gtk_imhtml_apply_tags_on_insert(user_data, &start, arg1); | |
| 4376 | } | |
| 4377 | ||
| 8677 | 4378 | static void insert_cb(GtkTextBuffer *buffer, GtkTextIter *end, gchar *text, gint len, GtkIMHtml *imhtml) |
| 4379 | { | |
| 4380 | GtkTextIter start; | |
| 4381 | ||
| 4382 | if (!len) | |
| 4383 | return; | |
| 4384 | ||
| 4385 | start = *end; | |
| 4386 | gtk_text_iter_set_offset(&start, imhtml->insert_offset); | |
| 4387 | ||
| 10169 | 4388 | gtk_imhtml_apply_tags_on_insert(imhtml, &start, end); |
| 4389 | } | |
| 4390 | ||
|
12673
4c8a20955e0b
[gaim-migrate @ 15016]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12672
diff
changeset
|
4391 | static void delete_cb(GtkTextBuffer *buffer, GtkTextIter *start, GtkTextIter *end, GtkIMHtml *imhtml) |
|
4c8a20955e0b
[gaim-migrate @ 15016]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12672
diff
changeset
|
4392 | { |
|
4c8a20955e0b
[gaim-migrate @ 15016]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12672
diff
changeset
|
4393 | GSList *tags, *l; |
|
4c8a20955e0b
[gaim-migrate @ 15016]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12672
diff
changeset
|
4394 | |
|
4c8a20955e0b
[gaim-migrate @ 15016]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12672
diff
changeset
|
4395 | tags = gtk_text_iter_get_tags(start); |
|
4c8a20955e0b
[gaim-migrate @ 15016]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12672
diff
changeset
|
4396 | for (l = tags; l != NULL; l = l->next) { |
|
4c8a20955e0b
[gaim-migrate @ 15016]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12672
diff
changeset
|
4397 | GtkTextTag *tag = GTK_TEXT_TAG(l->data); |
|
4c8a20955e0b
[gaim-migrate @ 15016]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12672
diff
changeset
|
4398 | |
|
4c8a20955e0b
[gaim-migrate @ 15016]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12672
diff
changeset
|
4399 | if (tag && /* Remove the formatting only if */ |
|
4c8a20955e0b
[gaim-migrate @ 15016]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12672
diff
changeset
|
4400 | gtk_text_iter_starts_word(start) && /* beginning of a word */ |
|
4c8a20955e0b
[gaim-migrate @ 15016]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12672
diff
changeset
|
4401 | gtk_text_iter_begins_tag(start, tag) && /* the tag starts with the selection */ |
|
4c8a20955e0b
[gaim-migrate @ 15016]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12672
diff
changeset
|
4402 | (!gtk_text_iter_has_tag(end, tag) || /* the tag ends within the selection */ |
|
4c8a20955e0b
[gaim-migrate @ 15016]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12672
diff
changeset
|
4403 | gtk_text_iter_ends_tag(end, tag))) { |
|
4c8a20955e0b
[gaim-migrate @ 15016]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12672
diff
changeset
|
4404 | gtk_text_buffer_remove_tag(imhtml->text_buffer, tag, start, end); |
|
4c8a20955e0b
[gaim-migrate @ 15016]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12672
diff
changeset
|
4405 | if (tag->name && |
|
4c8a20955e0b
[gaim-migrate @ 15016]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12672
diff
changeset
|
4406 | strncmp(tag->name, "LINK ", 5) == 0 && imhtml->edit.link) { |
|
4c8a20955e0b
[gaim-migrate @ 15016]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12672
diff
changeset
|
4407 | gtk_imhtml_toggle_link(imhtml, NULL); |
|
4c8a20955e0b
[gaim-migrate @ 15016]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12672
diff
changeset
|
4408 | } |
|
14097
0c340861ab79
[gaim-migrate @ 16638]
Mark Doliner <markdoliner@pidgin.im>
parents:
14010
diff
changeset
|
4409 | } |
|
12673
4c8a20955e0b
[gaim-migrate @ 15016]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12672
diff
changeset
|
4410 | } |
|
4c8a20955e0b
[gaim-migrate @ 15016]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12672
diff
changeset
|
4411 | g_slist_free(tags); |
|
4c8a20955e0b
[gaim-migrate @ 15016]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12672
diff
changeset
|
4412 | } |
|
4c8a20955e0b
[gaim-migrate @ 15016]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12672
diff
changeset
|
4413 | |
| 10169 | 4414 | static void gtk_imhtml_apply_tags_on_insert(GtkIMHtml *imhtml, GtkTextIter *start, GtkTextIter *end) |
| 4415 | { | |
| 8677 | 4416 | if (imhtml->edit.bold) |
| 10169 | 4417 | gtk_text_buffer_apply_tag_by_name(imhtml->text_buffer, "BOLD", start, end); |
| 8677 | 4418 | else |
| 10169 | 4419 | gtk_text_buffer_remove_tag_by_name(imhtml->text_buffer, "BOLD", start, end); |
| 8677 | 4420 | |
| 4421 | if (imhtml->edit.italic) | |
| 10169 | 4422 | gtk_text_buffer_apply_tag_by_name(imhtml->text_buffer, "ITALICS", start, end); |
| 8677 | 4423 | else |
| 10169 | 4424 | gtk_text_buffer_remove_tag_by_name(imhtml->text_buffer, "ITALICS", start, end); |
| 8677 | 4425 | |
| 4426 | if (imhtml->edit.underline) | |
| 10169 | 4427 | gtk_text_buffer_apply_tag_by_name(imhtml->text_buffer, "UNDERLINE", start, end); |
| 8677 | 4428 | else |
| 10169 | 4429 | gtk_text_buffer_remove_tag_by_name(imhtml->text_buffer, "UNDERLINE", start, end); |
| 8677 | 4430 | |
| 9924 | 4431 | if (imhtml->edit.strike) |
| 10169 | 4432 | gtk_text_buffer_apply_tag_by_name(imhtml->text_buffer, "STRIKE", start, end); |
| 9924 | 4433 | else |
| 10169 | 4434 | gtk_text_buffer_remove_tag_by_name(imhtml->text_buffer, "STRIKE", start, end); |
| 9924 | 4435 | |
| 8677 | 4436 | if (imhtml->edit.forecolor) { |
| 10169 | 4437 | remove_font_forecolor(imhtml, start, end, TRUE); |
| 8677 | 4438 | gtk_text_buffer_apply_tag(imhtml->text_buffer, |
| 4439 | find_font_forecolor_tag(imhtml, imhtml->edit.forecolor), | |
| 10169 | 4440 | start, end); |
| 8061 | 4441 | } |
| 4442 | ||
| 8677 | 4443 | if (imhtml->edit.backcolor) { |
| 10169 | 4444 | remove_font_backcolor(imhtml, start, end, TRUE); |
| 8677 | 4445 | gtk_text_buffer_apply_tag(imhtml->text_buffer, |
| 4446 | find_font_backcolor_tag(imhtml, imhtml->edit.backcolor), | |
| 10169 | 4447 | start, end); |
| 8677 | 4448 | } |
| 4449 | ||
| 10776 | 4450 | if (imhtml->edit.background) { |
| 4451 | remove_font_background(imhtml, start, end, TRUE); | |
| 4452 | gtk_text_buffer_apply_tag(imhtml->text_buffer, | |
| 4453 | find_font_background_tag(imhtml, imhtml->edit.background), | |
| 4454 | start, end); | |
| 4455 | } | |
| 8677 | 4456 | if (imhtml->edit.fontface) { |
| 10169 | 4457 | remove_font_face(imhtml, start, end, TRUE); |
| 8677 | 4458 | gtk_text_buffer_apply_tag(imhtml->text_buffer, |
| 4459 | find_font_face_tag(imhtml, imhtml->edit.fontface), | |
| 10169 | 4460 | start, end); |
| 8061 | 4461 | } |
| 8677 | 4462 | |
| 4463 | if (imhtml->edit.fontsize) { | |
| 10169 | 4464 | remove_font_size(imhtml, start, end, TRUE); |
| 8677 | 4465 | gtk_text_buffer_apply_tag(imhtml->text_buffer, |
| 4466 | find_font_size_tag(imhtml, imhtml->edit.fontsize), | |
| 10169 | 4467 | start, end); |
| 8677 | 4468 | } |
| 4469 | ||
| 4470 | if (imhtml->edit.link) { | |
| 10169 | 4471 | remove_font_link(imhtml, start, end, TRUE); |
| 8677 | 4472 | gtk_text_buffer_apply_tag(imhtml->text_buffer, |
| 4473 | imhtml->edit.link, | |
| 10169 | 4474 | start, end); |
| 8677 | 4475 | } |
| 8061 | 4476 | } |
| 4477 | ||
| 4478 | void gtk_imhtml_set_editable(GtkIMHtml *imhtml, gboolean editable) | |
| 4479 | { | |
| 4480 | gtk_text_view_set_editable(GTK_TEXT_VIEW(imhtml), editable); | |
|
8177
33b3a01c6318
[gaim-migrate @ 8891]
Mark Doliner <markdoliner@pidgin.im>
parents:
8149
diff
changeset
|
4481 | /* |
|
33b3a01c6318
[gaim-migrate @ 8891]
Mark Doliner <markdoliner@pidgin.im>
parents:
8149
diff
changeset
|
4482 | * We need a visible caret for accessibility, so mouseless |
|
33b3a01c6318
[gaim-migrate @ 8891]
Mark Doliner <markdoliner@pidgin.im>
parents:
8149
diff
changeset
|
4483 | * people can highlight stuff. |
|
33b3a01c6318
[gaim-migrate @ 8891]
Mark Doliner <markdoliner@pidgin.im>
parents:
8149
diff
changeset
|
4484 | */ |
|
33b3a01c6318
[gaim-migrate @ 8891]
Mark Doliner <markdoliner@pidgin.im>
parents:
8149
diff
changeset
|
4485 | /* gtk_text_view_set_cursor_visible(GTK_TEXT_VIEW(imhtml), editable); */ |
|
27031
6779a535047e
Avoid adding several callbacks on repeated invocations of gtk_imhtml_set_editable.
Daniel Atallah <datallah@pidgin.im>
parents:
26829
diff
changeset
|
4486 | if (editable && !imhtml->editable) { |
| 8677 | 4487 | g_signal_connect_after(G_OBJECT(GTK_IMHTML(imhtml)->text_buffer), "mark-set", |
|
21765
b9271e416f6d
Patch from 'goutnet': Pressing backspace on a smiley will replace the smiley
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21644
diff
changeset
|
4488 | G_CALLBACK(mark_set_cb), imhtml); |
|
b9271e416f6d
Patch from 'goutnet': Pressing backspace on a smiley will replace the smiley
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21644
diff
changeset
|
4489 | g_signal_connect(G_OBJECT(imhtml), "backspace", G_CALLBACK(smart_backspace_cb), NULL); |
|
27031
6779a535047e
Avoid adding several callbacks on repeated invocations of gtk_imhtml_set_editable.
Daniel Atallah <datallah@pidgin.im>
parents:
26829
diff
changeset
|
4490 | } else if (!editable && imhtml->editable) { |
|
6779a535047e
Avoid adding several callbacks on repeated invocations of gtk_imhtml_set_editable.
Daniel Atallah <datallah@pidgin.im>
parents:
26829
diff
changeset
|
4491 | g_signal_handlers_disconnect_by_func(G_OBJECT(GTK_IMHTML(imhtml)->text_buffer), |
|
6779a535047e
Avoid adding several callbacks on repeated invocations of gtk_imhtml_set_editable.
Daniel Atallah <datallah@pidgin.im>
parents:
26829
diff
changeset
|
4492 | mark_set_cb, imhtml); |
|
6779a535047e
Avoid adding several callbacks on repeated invocations of gtk_imhtml_set_editable.
Daniel Atallah <datallah@pidgin.im>
parents:
26829
diff
changeset
|
4493 | g_signal_handlers_disconnect_by_func(G_OBJECT(imhtml), |
|
6779a535047e
Avoid adding several callbacks on repeated invocations of gtk_imhtml_set_editable.
Daniel Atallah <datallah@pidgin.im>
parents:
26829
diff
changeset
|
4494 | smart_backspace_cb, NULL); |
|
21765
b9271e416f6d
Patch from 'goutnet': Pressing backspace on a smiley will replace the smiley
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
21644
diff
changeset
|
4495 | } |
|
27031
6779a535047e
Avoid adding several callbacks on repeated invocations of gtk_imhtml_set_editable.
Daniel Atallah <datallah@pidgin.im>
parents:
26829
diff
changeset
|
4496 | |
|
6779a535047e
Avoid adding several callbacks on repeated invocations of gtk_imhtml_set_editable.
Daniel Atallah <datallah@pidgin.im>
parents:
26829
diff
changeset
|
4497 | imhtml->editable = editable; |
|
6779a535047e
Avoid adding several callbacks on repeated invocations of gtk_imhtml_set_editable.
Daniel Atallah <datallah@pidgin.im>
parents:
26829
diff
changeset
|
4498 | imhtml->format_functions = GTK_IMHTML_ALL; |
| 8677 | 4499 | } |
| 4500 | ||
| 4501 | void gtk_imhtml_set_whole_buffer_formatting_only(GtkIMHtml *imhtml, gboolean wbfo) | |
| 4502 | { | |
| 4503 | g_return_if_fail(imhtml != NULL); | |
| 4504 | ||
| 4505 | imhtml->wbfo = wbfo; | |
| 8420 | 4506 | } |
| 4507 | ||
| 4508 | void gtk_imhtml_set_format_functions(GtkIMHtml *imhtml, GtkIMHtmlButtons buttons) | |
| 4509 | { | |
| 4510 | GObject *object = g_object_ref(G_OBJECT(imhtml)); | |
| 8677 | 4511 | imhtml->format_functions = buttons; |
| 8420 | 4512 | g_signal_emit(object, signals[BUTTONS_UPDATE], 0, buttons); |
| 4513 | g_object_unref(object); | |
| 8061 | 4514 | } |
| 4515 | ||
|
8788
a13634443a38
[gaim-migrate @ 9550]
Mark Doliner <markdoliner@pidgin.im>
parents:
8786
diff
changeset
|
4516 | GtkIMHtmlButtons gtk_imhtml_get_format_functions(GtkIMHtml *imhtml) |
|
a13634443a38
[gaim-migrate @ 9550]
Mark Doliner <markdoliner@pidgin.im>
parents:
8786
diff
changeset
|
4517 | { |
|
a13634443a38
[gaim-migrate @ 9550]
Mark Doliner <markdoliner@pidgin.im>
parents:
8786
diff
changeset
|
4518 | return imhtml->format_functions; |
|
a13634443a38
[gaim-migrate @ 9550]
Mark Doliner <markdoliner@pidgin.im>
parents:
8786
diff
changeset
|
4519 | } |
| 8516 | 4520 | |
| 4521 | void gtk_imhtml_get_current_format(GtkIMHtml *imhtml, gboolean *bold, | |
| 4522 | gboolean *italic, gboolean *underline) | |
| 8481 | 4523 | { |
|
12900
7fe519669e07
[gaim-migrate @ 15253]
Richard Laager <rlaager@pidgin.im>
parents:
12836
diff
changeset
|
4524 | if (bold != NULL) |
|
7fe519669e07
[gaim-migrate @ 15253]
Richard Laager <rlaager@pidgin.im>
parents:
12836
diff
changeset
|
4525 | (*bold) = imhtml->edit.bold; |
|
7fe519669e07
[gaim-migrate @ 15253]
Richard Laager <rlaager@pidgin.im>
parents:
12836
diff
changeset
|
4526 | if (italic != NULL) |
|
7fe519669e07
[gaim-migrate @ 15253]
Richard Laager <rlaager@pidgin.im>
parents:
12836
diff
changeset
|
4527 | (*italic) = imhtml->edit.italic; |
|
7fe519669e07
[gaim-migrate @ 15253]
Richard Laager <rlaager@pidgin.im>
parents:
12836
diff
changeset
|
4528 | if (underline != NULL) |
|
7fe519669e07
[gaim-migrate @ 15253]
Richard Laager <rlaager@pidgin.im>
parents:
12836
diff
changeset
|
4529 | (*underline) = imhtml->edit.underline; |
| 8481 | 4530 | } |
| 4531 | ||
| 9025 | 4532 | char * |
| 4533 | gtk_imhtml_get_current_fontface(GtkIMHtml *imhtml) | |
| 4534 | { | |
|
14097
0c340861ab79
[gaim-migrate @ 16638]
Mark Doliner <markdoliner@pidgin.im>
parents:
14010
diff
changeset
|
4535 | return g_strdup(imhtml->edit.fontface); |
| 9025 | 4536 | } |
| 4537 | ||
| 4538 | char * | |
| 4539 | gtk_imhtml_get_current_forecolor(GtkIMHtml *imhtml) | |
| 4540 | { | |
|
14097
0c340861ab79
[gaim-migrate @ 16638]
Mark Doliner <markdoliner@pidgin.im>
parents:
14010
diff
changeset
|
4541 | return g_strdup(imhtml->edit.forecolor); |
| 9025 | 4542 | } |
| 4543 | ||
| 4544 | char * | |
| 4545 | gtk_imhtml_get_current_backcolor(GtkIMHtml *imhtml) | |
| 4546 | { | |
|
14097
0c340861ab79
[gaim-migrate @ 16638]
Mark Doliner <markdoliner@pidgin.im>
parents:
14010
diff
changeset
|
4547 | return g_strdup(imhtml->edit.backcolor); |
| 9025 | 4548 | } |
| 4549 | ||
|
11267
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
4550 | char * |
|
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
4551 | gtk_imhtml_get_current_background(GtkIMHtml *imhtml) |
|
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
4552 | { |
|
14097
0c340861ab79
[gaim-migrate @ 16638]
Mark Doliner <markdoliner@pidgin.im>
parents:
14010
diff
changeset
|
4553 | return g_strdup(imhtml->edit.background); |
|
11267
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
4554 | } |
|
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
4555 | |
| 9025 | 4556 | gint |
| 4557 | gtk_imhtml_get_current_fontsize(GtkIMHtml *imhtml) | |
| 4558 | { | |
| 4559 | return imhtml->edit.fontsize; | |
| 4560 | } | |
| 4561 | ||
| 8061 | 4562 | gboolean gtk_imhtml_get_editable(GtkIMHtml *imhtml) |
| 4563 | { | |
| 4564 | return imhtml->editable; | |
| 4565 | } | |
| 4566 | ||
|
11269
ca63789d57b9
[gaim-migrate @ 13451]
Richard Laager <rlaager@pidgin.im>
parents:
11267
diff
changeset
|
4567 | void |
|
ca63789d57b9
[gaim-migrate @ 13451]
Richard Laager <rlaager@pidgin.im>
parents:
11267
diff
changeset
|
4568 | gtk_imhtml_clear_formatting(GtkIMHtml *imhtml) |
|
ca63789d57b9
[gaim-migrate @ 13451]
Richard Laager <rlaager@pidgin.im>
parents:
11267
diff
changeset
|
4569 | { |
|
11275
cdcc651d7ecd
[gaim-migrate @ 13461]
Richard Laager <rlaager@pidgin.im>
parents:
11269
diff
changeset
|
4570 | GObject *object; |
|
cdcc651d7ecd
[gaim-migrate @ 13461]
Richard Laager <rlaager@pidgin.im>
parents:
11269
diff
changeset
|
4571 | |
|
cdcc651d7ecd
[gaim-migrate @ 13461]
Richard Laager <rlaager@pidgin.im>
parents:
11269
diff
changeset
|
4572 | object = g_object_ref(G_OBJECT(imhtml)); |
|
cdcc651d7ecd
[gaim-migrate @ 13461]
Richard Laager <rlaager@pidgin.im>
parents:
11269
diff
changeset
|
4573 | g_signal_emit(object, signals[CLEAR_FORMAT], 0); |
|
11276
aec923529d31
[gaim-migrate @ 13463]
Richard Laager <rlaager@pidgin.im>
parents:
11275
diff
changeset
|
4574 | |
|
11269
ca63789d57b9
[gaim-migrate @ 13451]
Richard Laager <rlaager@pidgin.im>
parents:
11267
diff
changeset
|
4575 | gtk_widget_grab_focus(GTK_WIDGET(imhtml)); |
|
11276
aec923529d31
[gaim-migrate @ 13463]
Richard Laager <rlaager@pidgin.im>
parents:
11275
diff
changeset
|
4576 | |
|
aec923529d31
[gaim-migrate @ 13463]
Richard Laager <rlaager@pidgin.im>
parents:
11275
diff
changeset
|
4577 | g_object_unref(object); |
|
11269
ca63789d57b9
[gaim-migrate @ 13451]
Richard Laager <rlaager@pidgin.im>
parents:
11267
diff
changeset
|
4578 | } |
|
ca63789d57b9
[gaim-migrate @ 13451]
Richard Laager <rlaager@pidgin.im>
parents:
11267
diff
changeset
|
4579 | |
| 8677 | 4580 | /* |
| 4581 | * I had this crazy idea about changing the text cursor color to reflex the foreground color | |
| 4582 | * of the text about to be entered. This is the place you'd do it, along with the place where | |
| 4583 | * we actually set a new foreground color. | |
| 15884 | 4584 | * I may not do this, because people will bitch about Purple overriding their gtk theme's cursor |
| 8677 | 4585 | * colors. |
| 4586 | * | |
| 4587 | * Just in case I do do this, I asked about what to set the secondary text cursor to. | |
| 4588 | * | |
| 8719 | 4589 | * (12:45:27) ?? ???: secondary_cursor_color = (rgb(background) + rgb(primary_cursor_color) ) / 2 |
| 4590 | * (12:45:55) ?? ???: understand? | |
| 8677 | 4591 | * (12:46:14) Tim: yeah. i didn't know there was an exact formula |
|
8735
01248ea222d3
[gaim-migrate @ 9490]
Jonathan Champ <royanee@users.sourceforge.net>
parents:
8729
diff
changeset
|
4592 | * (12:46:56) ?? ???: u might need to extract separate each color from RGB |
| 8677 | 4593 | */ |
| 4594 | ||
| 4595 | static void mark_set_cb(GtkTextBuffer *buffer, GtkTextIter *arg1, GtkTextMark *mark, | |
| 4596 | GtkIMHtml *imhtml) | |
| 4597 | { | |
| 4598 | GSList *tags, *l; | |
| 4599 | GtkTextIter iter; | |
| 4600 | ||
| 4601 | if (mark != gtk_text_buffer_get_insert(buffer)) | |
| 4602 | return; | |
| 4603 | ||
| 4604 | if (!gtk_text_buffer_get_char_count(buffer)) | |
| 4605 | return; | |
| 4606 | ||
| 9924 | 4607 | imhtml->edit.bold = imhtml->edit.italic = imhtml->edit.underline = imhtml->edit.strike = FALSE; |
|
14097
0c340861ab79
[gaim-migrate @ 16638]
Mark Doliner <markdoliner@pidgin.im>
parents:
14010
diff
changeset
|
4608 | g_free(imhtml->edit.forecolor); |
| 8677 | 4609 | imhtml->edit.forecolor = NULL; |
|
14097
0c340861ab79
[gaim-migrate @ 16638]
Mark Doliner <markdoliner@pidgin.im>
parents:
14010
diff
changeset
|
4610 | |
|
0c340861ab79
[gaim-migrate @ 16638]
Mark Doliner <markdoliner@pidgin.im>
parents:
14010
diff
changeset
|
4611 | g_free(imhtml->edit.backcolor); |
| 8677 | 4612 | imhtml->edit.backcolor = NULL; |
|
14097
0c340861ab79
[gaim-migrate @ 16638]
Mark Doliner <markdoliner@pidgin.im>
parents:
14010
diff
changeset
|
4613 | |
|
0c340861ab79
[gaim-migrate @ 16638]
Mark Doliner <markdoliner@pidgin.im>
parents:
14010
diff
changeset
|
4614 | g_free(imhtml->edit.fontface); |
| 8677 | 4615 | imhtml->edit.fontface = NULL; |
|
14097
0c340861ab79
[gaim-migrate @ 16638]
Mark Doliner <markdoliner@pidgin.im>
parents:
14010
diff
changeset
|
4616 | |
| 8677 | 4617 | imhtml->edit.fontsize = 0; |
| 4618 | imhtml->edit.link = NULL; | |
| 4619 | ||
| 4620 | gtk_text_buffer_get_iter_at_mark(imhtml->text_buffer, &iter, mark); | |
| 4621 | ||
| 4622 | ||
| 4623 | if (gtk_text_iter_is_end(&iter)) | |
| 4624 | tags = gtk_text_iter_get_toggled_tags(&iter, FALSE); | |
| 4625 | else | |
| 4626 | tags = gtk_text_iter_get_tags(&iter); | |
| 4627 | ||
| 4628 | for (l = tags; l != NULL; l = l->next) { | |
| 4629 | GtkTextTag *tag = GTK_TEXT_TAG(l->data); | |
| 4630 | ||
| 4631 | if (tag->name) { | |
| 4632 | if (strcmp(tag->name, "BOLD") == 0) | |
| 4633 | imhtml->edit.bold = TRUE; | |
|
13138
4d3bd039da3e
[gaim-migrate @ 15499]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13137
diff
changeset
|
4634 | else if (strcmp(tag->name, "ITALICS") == 0) |
| 8677 | 4635 | imhtml->edit.italic = TRUE; |
|
13138
4d3bd039da3e
[gaim-migrate @ 15499]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13137
diff
changeset
|
4636 | else if (strcmp(tag->name, "UNDERLINE") == 0) |
| 8677 | 4637 | imhtml->edit.underline = TRUE; |
|
13138
4d3bd039da3e
[gaim-migrate @ 15499]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13137
diff
changeset
|
4638 | else if (strcmp(tag->name, "STRIKE") == 0) |
| 9924 | 4639 | imhtml->edit.strike = TRUE; |
|
13138
4d3bd039da3e
[gaim-migrate @ 15499]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13137
diff
changeset
|
4640 | else if (strncmp(tag->name, "FORECOLOR ", 10) == 0) |
| 8677 | 4641 | imhtml->edit.forecolor = g_strdup(&(tag->name)[10]); |
|
13138
4d3bd039da3e
[gaim-migrate @ 15499]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13137
diff
changeset
|
4642 | else if (strncmp(tag->name, "BACKCOLOR ", 10) == 0) |
| 8677 | 4643 | imhtml->edit.backcolor = g_strdup(&(tag->name)[10]); |
|
13138
4d3bd039da3e
[gaim-migrate @ 15499]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13137
diff
changeset
|
4644 | else if (strncmp(tag->name, "FONT FACE ", 10) == 0) |
| 8677 | 4645 | imhtml->edit.fontface = g_strdup(&(tag->name)[10]); |
|
13138
4d3bd039da3e
[gaim-migrate @ 15499]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13137
diff
changeset
|
4646 | else if (strncmp(tag->name, "FONT SIZE ", 10) == 0) |
| 8677 | 4647 | imhtml->edit.fontsize = strtol(&(tag->name)[10], NULL, 10); |
|
13138
4d3bd039da3e
[gaim-migrate @ 15499]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
13137
diff
changeset
|
4648 | else if ((strncmp(tag->name, "LINK ", 5) == 0) && !gtk_text_iter_is_end(&iter)) |
| 8677 | 4649 | imhtml->edit.link = tag; |
| 4650 | } | |
| 4651 | } | |
| 4652 | ||
| 4653 | g_slist_free(tags); | |
| 4654 | } | |
| 4655 | ||
|
12605
7390627a6aaf
[gaim-migrate @ 14940]
Richard Laager <rlaager@pidgin.im>
parents:
12600
diff
changeset
|
4656 | static void imhtml_emit_signal_for_format(GtkIMHtml *imhtml, GtkIMHtmlButtons button) |
|
7390627a6aaf
[gaim-migrate @ 14940]
Richard Laager <rlaager@pidgin.im>
parents:
12600
diff
changeset
|
4657 | { |
|
7390627a6aaf
[gaim-migrate @ 14940]
Richard Laager <rlaager@pidgin.im>
parents:
12600
diff
changeset
|
4658 | GObject *object; |
|
7390627a6aaf
[gaim-migrate @ 14940]
Richard Laager <rlaager@pidgin.im>
parents:
12600
diff
changeset
|
4659 | |
|
7390627a6aaf
[gaim-migrate @ 14940]
Richard Laager <rlaager@pidgin.im>
parents:
12600
diff
changeset
|
4660 | g_return_if_fail(imhtml != NULL); |
|
7390627a6aaf
[gaim-migrate @ 14940]
Richard Laager <rlaager@pidgin.im>
parents:
12600
diff
changeset
|
4661 | |
|
7390627a6aaf
[gaim-migrate @ 14940]
Richard Laager <rlaager@pidgin.im>
parents:
12600
diff
changeset
|
4662 | object = g_object_ref(G_OBJECT(imhtml)); |
|
7390627a6aaf
[gaim-migrate @ 14940]
Richard Laager <rlaager@pidgin.im>
parents:
12600
diff
changeset
|
4663 | g_signal_emit(object, signals[TOGGLE_FORMAT], 0, button); |
|
7390627a6aaf
[gaim-migrate @ 14940]
Richard Laager <rlaager@pidgin.im>
parents:
12600
diff
changeset
|
4664 | g_object_unref(object); |
|
7390627a6aaf
[gaim-migrate @ 14940]
Richard Laager <rlaager@pidgin.im>
parents:
12600
diff
changeset
|
4665 | } |
|
7390627a6aaf
[gaim-migrate @ 14940]
Richard Laager <rlaager@pidgin.im>
parents:
12600
diff
changeset
|
4666 | |
|
11267
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
4667 | static void imhtml_toggle_bold(GtkIMHtml *imhtml) |
| 8061 | 4668 | { |
| 8677 | 4669 | GtkTextIter start, end; |
| 4670 | ||
| 4671 | imhtml->edit.bold = !imhtml->edit.bold; | |
| 4672 | ||
|
28935
84dbc0ca215d
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28932
diff
changeset
|
4673 | if (!imhtml_get_iter_bounds(imhtml, &start, &end)) |
|
84dbc0ca215d
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28932
diff
changeset
|
4674 | return; |
|
84dbc0ca215d
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28932
diff
changeset
|
4675 | |
|
84dbc0ca215d
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28932
diff
changeset
|
4676 | if (imhtml->edit.bold) |
|
84dbc0ca215d
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28932
diff
changeset
|
4677 | gtk_text_buffer_apply_tag_by_name(imhtml->text_buffer, "BOLD", &start, &end); |
|
84dbc0ca215d
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28932
diff
changeset
|
4678 | else |
|
84dbc0ca215d
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28932
diff
changeset
|
4679 | gtk_text_buffer_remove_tag_by_name(imhtml->text_buffer, "BOLD", &start, &end); |
| 8061 | 4680 | } |
| 4681 | ||
|
11267
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
4682 | void gtk_imhtml_toggle_bold(GtkIMHtml *imhtml) |
| 8061 | 4683 | { |
|
12605
7390627a6aaf
[gaim-migrate @ 14940]
Richard Laager <rlaager@pidgin.im>
parents:
12600
diff
changeset
|
4684 | imhtml_emit_signal_for_format(imhtml, GTK_IMHTML_BOLD); |
|
11267
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
4685 | } |
|
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
4686 | |
|
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
4687 | static void imhtml_toggle_italic(GtkIMHtml *imhtml) |
|
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
4688 | { |
| 8677 | 4689 | GtkTextIter start, end; |
| 4690 | ||
| 4691 | imhtml->edit.italic = !imhtml->edit.italic; | |
| 4692 | ||
|
28935
84dbc0ca215d
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28932
diff
changeset
|
4693 | if (!imhtml_get_iter_bounds(imhtml, &start, &end)) |
|
84dbc0ca215d
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28932
diff
changeset
|
4694 | return; |
|
84dbc0ca215d
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28932
diff
changeset
|
4695 | |
|
84dbc0ca215d
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28932
diff
changeset
|
4696 | if (imhtml->edit.italic) |
|
84dbc0ca215d
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28932
diff
changeset
|
4697 | gtk_text_buffer_apply_tag_by_name(imhtml->text_buffer, "ITALICS", &start, &end); |
|
84dbc0ca215d
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28932
diff
changeset
|
4698 | else |
|
84dbc0ca215d
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28932
diff
changeset
|
4699 | gtk_text_buffer_remove_tag_by_name(imhtml->text_buffer, "ITALICS", &start, &end); |
| 8061 | 4700 | } |
| 4701 | ||
|
11267
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
4702 | void gtk_imhtml_toggle_italic(GtkIMHtml *imhtml) |
| 8061 | 4703 | { |
|
12605
7390627a6aaf
[gaim-migrate @ 14940]
Richard Laager <rlaager@pidgin.im>
parents:
12600
diff
changeset
|
4704 | imhtml_emit_signal_for_format(imhtml, GTK_IMHTML_ITALIC); |
|
7390627a6aaf
[gaim-migrate @ 14940]
Richard Laager <rlaager@pidgin.im>
parents:
12600
diff
changeset
|
4705 | } |
|
11267
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
4706 | |
|
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
4707 | static void imhtml_toggle_underline(GtkIMHtml *imhtml) |
|
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
4708 | { |
| 8677 | 4709 | GtkTextIter start, end; |
| 4710 | ||
| 4711 | imhtml->edit.underline = !imhtml->edit.underline; | |
| 4712 | ||
|
28935
84dbc0ca215d
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28932
diff
changeset
|
4713 | if (!imhtml_get_iter_bounds(imhtml, &start, &end)) |
|
84dbc0ca215d
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28932
diff
changeset
|
4714 | return; |
|
84dbc0ca215d
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28932
diff
changeset
|
4715 | |
|
84dbc0ca215d
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28932
diff
changeset
|
4716 | if (imhtml->edit.underline) |
|
84dbc0ca215d
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28932
diff
changeset
|
4717 | gtk_text_buffer_apply_tag_by_name(imhtml->text_buffer, "UNDERLINE", &start, &end); |
|
84dbc0ca215d
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28932
diff
changeset
|
4718 | else |
|
84dbc0ca215d
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28932
diff
changeset
|
4719 | gtk_text_buffer_remove_tag_by_name(imhtml->text_buffer, "UNDERLINE", &start, &end); |
| 8061 | 4720 | } |
| 4721 | ||
|
11267
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
4722 | void gtk_imhtml_toggle_underline(GtkIMHtml *imhtml) |
| 9924 | 4723 | { |
|
12605
7390627a6aaf
[gaim-migrate @ 14940]
Richard Laager <rlaager@pidgin.im>
parents:
12600
diff
changeset
|
4724 | imhtml_emit_signal_for_format(imhtml, GTK_IMHTML_UNDERLINE); |
|
11267
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
4725 | } |
|
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
4726 | |
|
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
4727 | static void imhtml_toggle_strike(GtkIMHtml *imhtml) |
|
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
4728 | { |
| 9924 | 4729 | GtkTextIter start, end; |
| 4730 | ||
| 4731 | imhtml->edit.strike = !imhtml->edit.strike; | |
| 4732 | ||
|
28935
84dbc0ca215d
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28932
diff
changeset
|
4733 | if (!imhtml_get_iter_bounds(imhtml, &start, &end)) |
|
84dbc0ca215d
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28932
diff
changeset
|
4734 | return; |
|
84dbc0ca215d
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28932
diff
changeset
|
4735 | |
|
84dbc0ca215d
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28932
diff
changeset
|
4736 | if (imhtml->edit.strike) |
|
84dbc0ca215d
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28932
diff
changeset
|
4737 | gtk_text_buffer_apply_tag_by_name(imhtml->text_buffer, "STRIKE", &start, &end); |
|
84dbc0ca215d
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28932
diff
changeset
|
4738 | else |
|
84dbc0ca215d
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28932
diff
changeset
|
4739 | gtk_text_buffer_remove_tag_by_name(imhtml->text_buffer, "STRIKE", &start, &end); |
|
11267
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
4740 | } |
|
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
4741 | |
|
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
4742 | void gtk_imhtml_toggle_strike(GtkIMHtml *imhtml) |
|
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
4743 | { |
|
12605
7390627a6aaf
[gaim-migrate @ 14940]
Richard Laager <rlaager@pidgin.im>
parents:
12600
diff
changeset
|
4744 | imhtml_emit_signal_for_format(imhtml, GTK_IMHTML_STRIKE); |
| 9924 | 4745 | } |
| 4746 | ||
| 8061 | 4747 | void gtk_imhtml_font_set_size(GtkIMHtml *imhtml, gint size) |
| 4748 | { | |
| 9025 | 4749 | GObject *object; |
| 8677 | 4750 | GtkTextIter start, end; |
| 8061 | 4751 | |
| 4752 | imhtml->edit.fontsize = size; | |
| 4753 | ||
|
28935
84dbc0ca215d
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28932
diff
changeset
|
4754 | if (!imhtml_get_iter_bounds(imhtml, &start, &end)) |
|
84dbc0ca215d
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28932
diff
changeset
|
4755 | return; |
|
84dbc0ca215d
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28932
diff
changeset
|
4756 | |
|
84dbc0ca215d
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28932
diff
changeset
|
4757 | remove_font_size(imhtml, &start, &end, imhtml->wbfo); |
|
84dbc0ca215d
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28932
diff
changeset
|
4758 | gtk_text_buffer_apply_tag(imhtml->text_buffer, |
|
84dbc0ca215d
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28932
diff
changeset
|
4759 | find_font_size_tag(imhtml, imhtml->edit.fontsize), &start, &end); |
| 8677 | 4760 | |
| 9025 | 4761 | object = g_object_ref(G_OBJECT(imhtml)); |
|
11267
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
4762 | g_signal_emit(object, signals[TOGGLE_FORMAT], 0, GTK_IMHTML_SHRINK | GTK_IMHTML_GROW); |
| 9025 | 4763 | g_object_unref(object); |
| 8061 | 4764 | } |
| 4765 | ||
|
11267
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
4766 | static void imhtml_font_shrink(GtkIMHtml *imhtml) |
| 8061 | 4767 | { |
| 8677 | 4768 | GtkTextIter start, end; |
| 4769 | ||
| 8061 | 4770 | if (imhtml->edit.fontsize == 1) |
| 4771 | return; | |
| 4772 | ||
| 8677 | 4773 | if (!imhtml->edit.fontsize) |
| 4774 | imhtml->edit.fontsize = 2; | |
| 4775 | else | |
| 4776 | imhtml->edit.fontsize--; | |
| 4777 | ||
|
28935
84dbc0ca215d
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28932
diff
changeset
|
4778 | if (!imhtml_get_iter_bounds(imhtml, &start, &end)) |
|
84dbc0ca215d
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28932
diff
changeset
|
4779 | return; |
|
84dbc0ca215d
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28932
diff
changeset
|
4780 | remove_font_size(imhtml, &start, &end, imhtml->wbfo); |
|
84dbc0ca215d
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28932
diff
changeset
|
4781 | gtk_text_buffer_apply_tag(imhtml->text_buffer, |
| 8677 | 4782 | find_font_size_tag(imhtml, imhtml->edit.fontsize), &start, &end); |
|
11267
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
4783 | } |
|
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
4784 | |
|
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
4785 | void gtk_imhtml_font_shrink(GtkIMHtml *imhtml) |
|
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
4786 | { |
|
12605
7390627a6aaf
[gaim-migrate @ 14940]
Richard Laager <rlaager@pidgin.im>
parents:
12600
diff
changeset
|
4787 | imhtml_emit_signal_for_format(imhtml, GTK_IMHTML_SHRINK); |
| 8061 | 4788 | } |
| 4789 | ||
|
11267
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
4790 | static void imhtml_font_grow(GtkIMHtml *imhtml) |
| 8061 | 4791 | { |
| 8677 | 4792 | GtkTextIter start, end; |
| 4793 | ||
| 8061 | 4794 | if (imhtml->edit.fontsize == MAX_FONT_SIZE) |
| 4795 | return; | |
| 4796 | ||
| 8677 | 4797 | if (!imhtml->edit.fontsize) |
| 4798 | imhtml->edit.fontsize = 4; | |
| 4799 | else | |
| 4800 | imhtml->edit.fontsize++; | |
| 4801 | ||
|
28935
84dbc0ca215d
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28932
diff
changeset
|
4802 | if (!imhtml_get_iter_bounds(imhtml, &start, &end)) |
|
84dbc0ca215d
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28932
diff
changeset
|
4803 | return; |
|
84dbc0ca215d
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28932
diff
changeset
|
4804 | remove_font_size(imhtml, &start, &end, imhtml->wbfo); |
|
84dbc0ca215d
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28932
diff
changeset
|
4805 | gtk_text_buffer_apply_tag(imhtml->text_buffer, |
|
84dbc0ca215d
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28932
diff
changeset
|
4806 | find_font_size_tag(imhtml, imhtml->edit.fontsize), &start, &end); |
|
11267
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
4807 | } |
|
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
4808 | |
|
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
4809 | void gtk_imhtml_font_grow(GtkIMHtml *imhtml) |
|
78f1eb5b3d6e
[gaim-migrate @ 13449]
Richard Laager <rlaager@pidgin.im>
parents:
11240
diff
changeset
|
4810 | { |
|
12605
7390627a6aaf
[gaim-migrate @ 14940]
Richard Laager <rlaager@pidgin.im>
parents:
12600
diff
changeset
|
4811 | imhtml_emit_signal_for_format(imhtml, GTK_IMHTML_GROW); |
| 8061 | 4812 | } |
| 4813 | ||
|
13225
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4814 | static gboolean gtk_imhtml_toggle_str_tag(GtkIMHtml *imhtml, const char *value, char **edit_field, |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4815 | void (*remove_func)(GtkIMHtml *imhtml, GtkTextIter *i, GtkTextIter *e, gboolean homo), |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4816 | GtkTextTag *(find_func)(GtkIMHtml *imhtml, gchar *color), GtkIMHtmlButtons button) |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4817 | { |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4818 | GObject *object; |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4819 | GtkTextIter start; |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4820 | GtkTextIter end; |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4821 | |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4822 | g_free(*edit_field); |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4823 | *edit_field = NULL; |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4824 | |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4825 | if (value && strcmp(value, "") != 0) |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4826 | { |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4827 | *edit_field = g_strdup(value); |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4828 | |
|
28935
84dbc0ca215d
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28932
diff
changeset
|
4829 | if (imhtml_get_iter_bounds(imhtml, &start, &end)) { |
|
84dbc0ca215d
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28932
diff
changeset
|
4830 | remove_func(imhtml, &start, &end, imhtml->wbfo); |
|
13225
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4831 | gtk_text_buffer_apply_tag(imhtml->text_buffer, |
|
28935
84dbc0ca215d
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28932
diff
changeset
|
4832 | find_func(imhtml, *edit_field), &start, &end); |
|
13225
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4833 | } |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4834 | } |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4835 | else |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4836 | { |
|
28935
84dbc0ca215d
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28932
diff
changeset
|
4837 | if (imhtml_get_iter_bounds(imhtml, &start, &end)) |
|
84dbc0ca215d
Remove a bunch of code duplication.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
28932
diff
changeset
|
4838 | remove_func(imhtml, &start, &end, TRUE); /* 'TRUE' or 'imhtml->wbfo'? */ |
|
13225
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4839 | } |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4840 | |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4841 | object = g_object_ref(G_OBJECT(imhtml)); |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4842 | g_signal_emit(object, signals[TOGGLE_FORMAT], 0, button); |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4843 | g_object_unref(object); |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4844 | |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4845 | return *edit_field != NULL; |
| 10776 | 4846 | } |
| 4847 | ||
| 8061 | 4848 | gboolean gtk_imhtml_toggle_forecolor(GtkIMHtml *imhtml, const char *color) |
| 4849 | { | |
|
13225
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4850 | return gtk_imhtml_toggle_str_tag(imhtml, color, &imhtml->edit.forecolor, |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4851 | remove_font_forecolor, find_font_forecolor_tag, |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4852 | GTK_IMHTML_FORECOLOR); |
| 8061 | 4853 | } |
| 4854 | ||
| 4855 | gboolean gtk_imhtml_toggle_backcolor(GtkIMHtml *imhtml, const char *color) | |
| 4856 | { | |
|
13225
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4857 | return gtk_imhtml_toggle_str_tag(imhtml, color, &imhtml->edit.backcolor, |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4858 | remove_font_backcolor, find_font_backcolor_tag, |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4859 | GTK_IMHTML_BACKCOLOR); |
| 10776 | 4860 | } |
| 4861 | ||
| 4862 | gboolean gtk_imhtml_toggle_background(GtkIMHtml *imhtml, const char *color) | |
| 4863 | { | |
|
13225
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4864 | return gtk_imhtml_toggle_str_tag(imhtml, color, &imhtml->edit.background, |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4865 | remove_font_background, find_font_background_tag, |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4866 | GTK_IMHTML_BACKGROUND); |
| 8061 | 4867 | } |
| 4868 | ||
| 4869 | gboolean gtk_imhtml_toggle_fontface(GtkIMHtml *imhtml, const char *face) | |
| 4870 | { | |
|
13225
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4871 | return gtk_imhtml_toggle_str_tag(imhtml, face, &imhtml->edit.fontface, |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4872 | remove_font_face, find_font_face_tag, |
|
b82e04c17537
[gaim-migrate @ 15588]
Richard Laager <rlaager@pidgin.im>
parents:
13224
diff
changeset
|
4873 | GTK_IMHTML_FACE); |
| 8061 | 4874 | } |
| 4875 | ||
| 8677 | 4876 | void gtk_imhtml_toggle_link(GtkIMHtml *imhtml, const char *url) |
| 8061 | 4877 | { |
| 9025 | 4878 | GObject *object; |
| 8677 | 4879 | GtkTextIter start, end; |
| 4880 | GtkTextTag *linktag; | |
| 4881 | static guint linkno = 0; | |
| 4882 | gchar str[48]; | |
| 9007 | 4883 | GdkColor *color = NULL; |
| 8677 | 4884 | |
| 4885 | imhtml->edit.link = NULL; | |
| 4886 | ||
| 4887 | if (url) { | |
| 4888 | g_snprintf(str, sizeof(str), "LINK %d", linkno++); | |
| 4889 | str[47] = '\0'; | |
| 4890 | ||
| 9007 | 4891 | gtk_widget_style_get(GTK_WIDGET(imhtml), "hyperlink-color", &color, NULL); |
| 9008 | 4892 | if (color) { |
| 9007 | 4893 | imhtml->edit.link = linktag = gtk_text_buffer_create_tag(imhtml->text_buffer, str, "foreground-gdk", color, "underline", PANGO_UNDERLINE_SINGLE, NULL); |
| 9008 | 4894 | gdk_color_free(color); |
| 4895 | } else { | |
| 9007 | 4896 | imhtml->edit.link = linktag = gtk_text_buffer_create_tag(imhtml->text_buffer, str, "foreground", "blue", "underline", PANGO_UNDERLINE_SINGLE, NULL); |
| 9008 | 4897 | } |
| 8677 | 4898 | g_object_set_data_full(G_OBJECT(linktag), "link_url", g_strdup(url), g_free); |
| 4899 | g_signal_connect(G_OBJECT(linktag), "event", G_CALLBACK(tag_event), NULL); | |
| 4900 | ||
|
11276
aec923529d31
[gaim-migrate @ 13463]
Richard Laager <rlaager@pidgin.im>
parents:
11275
diff
changeset
|
4901 | if (imhtml->editable && gtk_text_buffer_get_selection_bounds(imhtml->text_buffer, &start, &end)) { |
| 8677 | 4902 | remove_font_link(imhtml, &start, &end, FALSE); |
| 4903 | gtk_text_buffer_apply_tag(imhtml->text_buffer, linktag, &start, &end); | |
| 4904 | } | |
| 4905 | } | |
| 9025 | 4906 | |
| 4907 | object = g_object_ref(G_OBJECT(imhtml)); | |
| 4908 | g_signal_emit(object, signals[TOGGLE_FORMAT], 0, GTK_IMHTML_LINK); | |
| 4909 | g_object_unref(object); | |
| 8677 | 4910 | } |
| 4911 | ||
| 4912 | void gtk_imhtml_insert_link(GtkIMHtml *imhtml, GtkTextMark *mark, const char *url, const char *text) | |
| 4913 | { | |
| 8061 | 4914 | GtkTextIter iter; |
| 8677 | 4915 | |
|
25899
da25a7ed382e
The first thing gtk_text_buffer_delete_selection does is call
Mark Doliner <markdoliner@pidgin.im>
parents:
25888
diff
changeset
|
4916 | /* Delete any currently selected text */ |
|
da25a7ed382e
The first thing gtk_text_buffer_delete_selection does is call
Mark Doliner <markdoliner@pidgin.im>
parents:
25888
diff
changeset
|
4917 | gtk_text_buffer_delete_selection(imhtml->text_buffer, TRUE, TRUE); |
| 9599 | 4918 | |
| 8677 | 4919 | gtk_imhtml_toggle_link(imhtml, url); |
| 8061 | 4920 | gtk_text_buffer_get_iter_at_mark(imhtml->text_buffer, &iter, mark); |
| 8677 | 4921 | gtk_text_buffer_insert(imhtml->text_buffer, &iter, text, -1); |
| 4922 | gtk_imhtml_toggle_link(imhtml, NULL); | |
| 8061 | 4923 | } |
| 4924 | ||
| 4925 | void gtk_imhtml_insert_smiley(GtkIMHtml *imhtml, const char *sml, char *smiley) | |
| 4926 | { | |
| 8677 | 4927 | GtkTextMark *mark; |
| 8061 | 4928 | GtkTextIter iter; |
| 8677 | 4929 | |
|
25899
da25a7ed382e
The first thing gtk_text_buffer_delete_selection does is call
Mark Doliner <markdoliner@pidgin.im>
parents:
25888
diff
changeset
|
4930 | /* Delete any currently selected text */ |
|
da25a7ed382e
The first thing gtk_text_buffer_delete_selection does is call
Mark Doliner <markdoliner@pidgin.im>
parents:
25888
diff
changeset
|
4931 | gtk_text_buffer_delete_selection(imhtml->text_buffer, TRUE, TRUE); |
|
11750
63f951281392
[gaim-migrate @ 14041]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
11701
diff
changeset
|
4932 | |
| 8677 | 4933 | mark = gtk_text_buffer_get_insert(imhtml->text_buffer); |
| 4934 | ||
| 4935 | gtk_text_buffer_get_iter_at_mark(imhtml->text_buffer, &iter, mark); | |
| 4936 | gtk_imhtml_insert_smiley_at_iter(imhtml, sml, smiley, &iter); | |
| 4937 | } | |
| 4938 | ||
| 13552 | 4939 | static gboolean |
| 4940 | image_expose(GtkWidget *widget, GdkEventExpose *event, gpointer user_data) | |
| 4941 | { | |
| 4942 | GTK_WIDGET_CLASS(GTK_WIDGET_GET_CLASS(widget))->expose_event(widget, event); | |
| 4943 | ||
| 4944 | return TRUE; | |
| 4945 | } | |
| 4946 | ||
|
16385
aa5b9456e258
Fixes #213 This allows only 20 animated smileys to be animnating at a time
Sean Egan <seanegan@pidgin.im>
parents:
16291
diff
changeset
|
4947 | /* In case the smiley gets removed from the imhtml before it gets removed from the queue */ |
|
aa5b9456e258
Fixes #213 This allows only 20 animated smileys to be animnating at a time
Sean Egan <seanegan@pidgin.im>
parents:
16291
diff
changeset
|
4948 | static void animated_smiley_destroy_cb(GtkObject *widget, GtkIMHtml *imhtml) |
|
aa5b9456e258
Fixes #213 This allows only 20 animated smileys to be animnating at a time
Sean Egan <seanegan@pidgin.im>
parents:
16291
diff
changeset
|
4949 | { |
|
aa5b9456e258
Fixes #213 This allows only 20 animated smileys to be animnating at a time
Sean Egan <seanegan@pidgin.im>
parents:
16291
diff
changeset
|
4950 | GList *l = imhtml->animations->head; |
|
aa5b9456e258
Fixes #213 This allows only 20 animated smileys to be animnating at a time
Sean Egan <seanegan@pidgin.im>
parents:
16291
diff
changeset
|
4951 | while (l) { |
|
aa5b9456e258
Fixes #213 This allows only 20 animated smileys to be animnating at a time
Sean Egan <seanegan@pidgin.im>
parents:
16291
diff
changeset
|
4952 | GList *next = l->next; |
|
aa5b9456e258
Fixes #213 This allows only 20 animated smileys to be animnating at a time
Sean Egan <seanegan@pidgin.im>
parents:
16291
diff
changeset
|
4953 | if (l->data == widget) { |
|
aa5b9456e258
Fixes #213 This allows only 20 animated smileys to be animnating at a time
Sean Egan <seanegan@pidgin.im>
parents:
16291
diff
changeset
|
4954 | if (l == imhtml->animations->tail) |
|
aa5b9456e258
Fixes #213 This allows only 20 animated smileys to be animnating at a time
Sean Egan <seanegan@pidgin.im>
parents:
16291
diff
changeset
|
4955 | imhtml->animations->tail = imhtml->animations->tail->prev; |
|
aa5b9456e258
Fixes #213 This allows only 20 animated smileys to be animnating at a time
Sean Egan <seanegan@pidgin.im>
parents:
16291
diff
changeset
|
4956 | imhtml->animations->head = g_list_delete_link(imhtml->animations->head, l); |
|
aa5b9456e258
Fixes #213 This allows only 20 animated smileys to be animnating at a time
Sean Egan <seanegan@pidgin.im>
parents:
16291
diff
changeset
|
4957 | imhtml->num_animations--; |
|
aa5b9456e258
Fixes #213 This allows only 20 animated smileys to be animnating at a time
Sean Egan <seanegan@pidgin.im>
parents:
16291
diff
changeset
|
4958 | } |
|
aa5b9456e258
Fixes #213 This allows only 20 animated smileys to be animnating at a time
Sean Egan <seanegan@pidgin.im>
parents:
16291
diff
changeset
|
4959 | l = next; |
|
aa5b9456e258
Fixes #213 This allows only 20 animated smileys to be animnating at a time
Sean Egan <seanegan@pidgin.im>
parents:
16291
diff
changeset
|
4960 | } |
|
aa5b9456e258
Fixes #213 This allows only 20 animated smileys to be animnating at a time
Sean Egan <seanegan@pidgin.im>
parents:
16291
diff
changeset
|
4961 | } |
|
aa5b9456e258
Fixes #213 This allows only 20 animated smileys to be animnating at a time
Sean Egan <seanegan@pidgin.im>
parents:
16291
diff
changeset
|
4962 | |
| 8677 | 4963 | void gtk_imhtml_insert_smiley_at_iter(GtkIMHtml *imhtml, const char *sml, char *smiley, GtkTextIter *iter) |
| 4964 | { | |
| 8061 | 4965 | GdkPixbuf *pixbuf = NULL; |
| 4966 | GdkPixbufAnimation *annipixbuf = NULL; | |
| 4967 | GtkWidget *icon = NULL; | |
|
17009
2cc9edf33feb
Allow saving custom smileys by right-clicking on them. And use the custom smileys only on the received messages, not for the system/etc. messages.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16385
diff
changeset
|
4968 | GtkTextChildAnchor *anchor = NULL; |
| 15884 | 4969 | char *unescaped = purple_unescape_html(smiley); |
|
11525
1d06283bdcc9
[gaim-migrate @ 13773]
Francesco Fracassi <ffracassi@users.sourceforge.net>
parents:
11485
diff
changeset
|
4970 | GtkIMHtmlSmiley *imhtml_smiley = gtk_imhtml_smiley_get(imhtml, sml, unescaped); |
|
17009
2cc9edf33feb
Allow saving custom smileys by right-clicking on them. And use the custom smileys only on the received messages, not for the system/etc. messages.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16385
diff
changeset
|
4971 | GtkWidget *ebox = NULL; |
| 8061 | 4972 | |
| 10526 | 4973 | if (imhtml->format_functions & GTK_IMHTML_SMILEY) { |
|
10522
d505522bcc93
[gaim-migrate @ 11838]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10504
diff
changeset
|
4974 | annipixbuf = gtk_smiley_tree_image(imhtml, sml, unescaped); |
| 10526 | 4975 | if (annipixbuf) { |
| 4976 | if (gdk_pixbuf_animation_is_static_image(annipixbuf)) { | |
|
10522
d505522bcc93
[gaim-migrate @ 11838]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10504
diff
changeset
|
4977 | pixbuf = gdk_pixbuf_animation_get_static_image(annipixbuf); |
| 10526 | 4978 | if (pixbuf) |
|
10522
d505522bcc93
[gaim-migrate @ 11838]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10504
diff
changeset
|
4979 | icon = gtk_image_new_from_pixbuf(pixbuf); |
|
d505522bcc93
[gaim-migrate @ 11838]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10504
diff
changeset
|
4980 | } else { |
|
d505522bcc93
[gaim-migrate @ 11838]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10504
diff
changeset
|
4981 | icon = gtk_image_new_from_animation(annipixbuf); |
|
16385
aa5b9456e258
Fixes #213 This allows only 20 animated smileys to be animnating at a time
Sean Egan <seanegan@pidgin.im>
parents:
16291
diff
changeset
|
4982 | if (imhtml->num_animations == 20) { |
|
aa5b9456e258
Fixes #213 This allows only 20 animated smileys to be animnating at a time
Sean Egan <seanegan@pidgin.im>
parents:
16291
diff
changeset
|
4983 | GtkImage *image = GTK_IMAGE(g_queue_pop_head(imhtml->animations)); |
|
aa5b9456e258
Fixes #213 This allows only 20 animated smileys to be animnating at a time
Sean Egan <seanegan@pidgin.im>
parents:
16291
diff
changeset
|
4984 | GdkPixbufAnimation *anim = gtk_image_get_animation(image); |
|
20638
38507ef4007f
Fix some crashes with animated smileys. Fixes #3179, #938, #3134, #2872, #1594
Daniel Atallah <datallah@pidgin.im>
parents:
20330
diff
changeset
|
4985 | g_signal_handlers_disconnect_matched(G_OBJECT(image), G_SIGNAL_MATCH_FUNC, |
|
38507ef4007f
Fix some crashes with animated smileys. Fixes #3179, #938, #3134, #2872, #1594
Daniel Atallah <datallah@pidgin.im>
parents:
20330
diff
changeset
|
4986 | 0, 0, NULL, G_CALLBACK(animated_smiley_destroy_cb), NULL); |
|
16385
aa5b9456e258
Fixes #213 This allows only 20 animated smileys to be animnating at a time
Sean Egan <seanegan@pidgin.im>
parents:
16291
diff
changeset
|
4987 | if (anim) { |
|
aa5b9456e258
Fixes #213 This allows only 20 animated smileys to be animnating at a time
Sean Egan <seanegan@pidgin.im>
parents:
16291
diff
changeset
|
4988 | GdkPixbuf *pb = gdk_pixbuf_animation_get_static_image(anim); |
|
20638
38507ef4007f
Fix some crashes with animated smileys. Fixes #3179, #938, #3134, #2872, #1594
Daniel Atallah <datallah@pidgin.im>
parents:
20330
diff
changeset
|
4989 | if (pb != NULL) { |
|
38507ef4007f
Fix some crashes with animated smileys. Fixes #3179, #938, #3134, #2872, #1594
Daniel Atallah <datallah@pidgin.im>
parents:
20330
diff
changeset
|
4990 | GdkPixbuf *copy = gdk_pixbuf_copy(pb); |
|
38507ef4007f
Fix some crashes with animated smileys. Fixes #3179, #938, #3134, #2872, #1594
Daniel Atallah <datallah@pidgin.im>
parents:
20330
diff
changeset
|
4991 | gtk_image_set_from_pixbuf(image, copy); |
|
38507ef4007f
Fix some crashes with animated smileys. Fixes #3179, #938, #3134, #2872, #1594
Daniel Atallah <datallah@pidgin.im>
parents:
20330
diff
changeset
|
4992 | g_object_unref(G_OBJECT(copy)); |
|
38507ef4007f
Fix some crashes with animated smileys. Fixes #3179, #938, #3134, #2872, #1594
Daniel Atallah <datallah@pidgin.im>
parents:
20330
diff
changeset
|
4993 | } |
|
16385
aa5b9456e258
Fixes #213 This allows only 20 animated smileys to be animnating at a time
Sean Egan <seanegan@pidgin.im>
parents:
16291
diff
changeset
|
4994 | } |
|
aa5b9456e258
Fixes #213 This allows only 20 animated smileys to be animnating at a time
Sean Egan <seanegan@pidgin.im>
parents:
16291
diff
changeset
|
4995 | } else { |
|
aa5b9456e258
Fixes #213 This allows only 20 animated smileys to be animnating at a time
Sean Egan <seanegan@pidgin.im>
parents:
16291
diff
changeset
|
4996 | imhtml->num_animations++; |
|
aa5b9456e258
Fixes #213 This allows only 20 animated smileys to be animnating at a time
Sean Egan <seanegan@pidgin.im>
parents:
16291
diff
changeset
|
4997 | } |
|
aa5b9456e258
Fixes #213 This allows only 20 animated smileys to be animnating at a time
Sean Egan <seanegan@pidgin.im>
parents:
16291
diff
changeset
|
4998 | g_signal_connect(G_OBJECT(icon), "destroy", G_CALLBACK(animated_smiley_destroy_cb), imhtml); |
|
aa5b9456e258
Fixes #213 This allows only 20 animated smileys to be animnating at a time
Sean Egan <seanegan@pidgin.im>
parents:
16291
diff
changeset
|
4999 | g_queue_push_tail(imhtml->animations, icon); |
|
10522
d505522bcc93
[gaim-migrate @ 11838]
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
10504
diff
changeset
|
5000 | } |
| 8061 | 5001 | } |
| 5002 | } | |
| 5003 | ||
|
17189
7d0cf54d0f32
Do not crash when trying to insert a smiley for a protocol not mentioned
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17136
diff
changeset
|
5004 | if (imhtml_smiley && imhtml_smiley->flags & GTK_IMHTML_SMILEY_CUSTOM) { |
|
17009
2cc9edf33feb
Allow saving custom smileys by right-clicking on them. And use the custom smileys only on the received messages, not for the system/etc. messages.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16385
diff
changeset
|
5005 | ebox = gtk_event_box_new(); |
| 17406 | 5006 | #if GTK_CHECK_VERSION(2,4,0) |
|
17009
2cc9edf33feb
Allow saving custom smileys by right-clicking on them. And use the custom smileys only on the received messages, not for the system/etc. messages.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16385
diff
changeset
|
5007 | gtk_event_box_set_visible_window(GTK_EVENT_BOX(ebox), FALSE); |
| 17406 | 5008 | #endif |
|
17009
2cc9edf33feb
Allow saving custom smileys by right-clicking on them. And use the custom smileys only on the received messages, not for the system/etc. messages.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16385
diff
changeset
|
5009 | gtk_widget_show(ebox); |
|
2cc9edf33feb
Allow saving custom smileys by right-clicking on them. And use the custom smileys only on the received messages, not for the system/etc. messages.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16385
diff
changeset
|
5010 | } |
|
2cc9edf33feb
Allow saving custom smileys by right-clicking on them. And use the custom smileys only on the received messages, not for the system/etc. messages.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16385
diff
changeset
|
5011 | |
| 8061 | 5012 | if (icon) { |
|
22803
e1f64090d32e
Do not show tooltips for <HR> or <IMG>s in gtkimhtml. Fixes #5480.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22772
diff
changeset
|
5013 | char *text = g_strdup(unescaped); /* Do not g_free 'text'. |
|
e1f64090d32e
Do not show tooltips for <HR> or <IMG>s in gtkimhtml. Fixes #5480.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22772
diff
changeset
|
5014 | It will be destroyed when 'anchor' is destroyed. */ |
| 8890 | 5015 | anchor = gtk_text_buffer_create_child_anchor(imhtml->text_buffer, iter); |
|
22803
e1f64090d32e
Do not show tooltips for <HR> or <IMG>s in gtkimhtml. Fixes #5480.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22772
diff
changeset
|
5016 | g_object_set_data_full(G_OBJECT(anchor), "gtkimhtml_plaintext", text, g_free); |
|
28753
13f3a9f6672f
Fix randomly broken tooltip for custom smileys.
Marcus Lundblad <malu@pidgin.im>
parents:
28144
diff
changeset
|
5017 | g_object_set_data_full(G_OBJECT(anchor), "gtkimhtml_tiptext", g_strdup(text), g_free); |
| 8890 | 5018 | g_object_set_data_full(G_OBJECT(anchor), "gtkimhtml_htmltext", g_strdup(smiley), g_free); |
| 5019 | ||
| 13552 | 5020 | /* This catches the expose events generated by animated |
| 5021 | * images, and ensures that they are handled by the image | |
| 5022 | * itself, without propagating to the textview and causing | |
| 5023 | * a complete refresh */ | |
| 5024 | g_signal_connect(G_OBJECT(icon), "expose-event", G_CALLBACK(image_expose), NULL); | |
| 5025 | ||
| 8061 | 5026 | gtk_widget_show(icon); |
|
17009
2cc9edf33feb
Allow saving custom smileys by right-clicking on them. And use the custom smileys only on the received messages, not for the system/etc. messages.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16385
diff
changeset
|
5027 | if (ebox) |
|
2cc9edf33feb
Allow saving custom smileys by right-clicking on them. And use the custom smileys only on the received messages, not for the system/etc. messages.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16385
diff
changeset
|
5028 | gtk_container_add(GTK_CONTAINER(ebox), icon); |
|
2cc9edf33feb
Allow saving custom smileys by right-clicking on them. And use the custom smileys only on the received messages, not for the system/etc. messages.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16385
diff
changeset
|
5029 | gtk_text_view_add_child_at_anchor(GTK_TEXT_VIEW(imhtml), ebox ? ebox : icon, anchor); |
|
11525
1d06283bdcc9
[gaim-migrate @ 13773]
Francesco Fracassi <ffracassi@users.sourceforge.net>
parents:
11485
diff
changeset
|
5030 | } else if (imhtml_smiley != NULL && (imhtml->format_functions & GTK_IMHTML_SMILEY)) { |
|
1d06283bdcc9
[gaim-migrate @ 13773]
Francesco Fracassi <ffracassi@users.sourceforge.net>
parents:
11485
diff
changeset
|
5031 | anchor = gtk_text_buffer_create_child_anchor(imhtml->text_buffer, iter); |
|
23398
4de581ccaf1e
Do not try to update received custom smileys in a deleted child anchor.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23377
diff
changeset
|
5032 | imhtml_smiley->anchors = g_slist_append(imhtml_smiley->anchors, g_object_ref(anchor)); |
|
17009
2cc9edf33feb
Allow saving custom smileys by right-clicking on them. And use the custom smileys only on the received messages, not for the system/etc. messages.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16385
diff
changeset
|
5033 | if (ebox) { |
|
2cc9edf33feb
Allow saving custom smileys by right-clicking on them. And use the custom smileys only on the received messages, not for the system/etc. messages.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16385
diff
changeset
|
5034 | GtkWidget *img = gtk_image_new_from_stock(GTK_STOCK_MISSING_IMAGE, GTK_ICON_SIZE_MENU); |
|
22803
e1f64090d32e
Do not show tooltips for <HR> or <IMG>s in gtkimhtml. Fixes #5480.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22772
diff
changeset
|
5035 | char *text = g_strdup(unescaped); |
|
17009
2cc9edf33feb
Allow saving custom smileys by right-clicking on them. And use the custom smileys only on the received messages, not for the system/etc. messages.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16385
diff
changeset
|
5036 | gtk_container_add(GTK_CONTAINER(ebox), img); |
|
2cc9edf33feb
Allow saving custom smileys by right-clicking on them. And use the custom smileys only on the received messages, not for the system/etc. messages.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16385
diff
changeset
|
5037 | gtk_widget_show(img); |
|
22803
e1f64090d32e
Do not show tooltips for <HR> or <IMG>s in gtkimhtml. Fixes #5480.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22772
diff
changeset
|
5038 | g_object_set_data_full(G_OBJECT(anchor), "gtkimhtml_plaintext", text, g_free); |
|
28754
1810a8fb2055
And that should be done in gtk_imhtml_insert_smiley_at_iter too...
Marcus Lundblad <malu@pidgin.im>
parents:
28753
diff
changeset
|
5039 | g_object_set_data_full(G_OBJECT(anchor), "gtkimhtml_tiptext", |
|
1810a8fb2055
And that should be done in gtk_imhtml_insert_smiley_at_iter too...
Marcus Lundblad <malu@pidgin.im>
parents:
28753
diff
changeset
|
5040 | g_strdup(text), g_free); |
|
27173
e601bcf2e1a6
We want to see what the missing custom smiley stands for.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27125
diff
changeset
|
5041 | g_object_set_data_full(G_OBJECT(anchor), "gtkimhtml_htmltext", g_strdup(smiley), g_free); |
|
17009
2cc9edf33feb
Allow saving custom smileys by right-clicking on them. And use the custom smileys only on the received messages, not for the system/etc. messages.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16385
diff
changeset
|
5042 | gtk_text_view_add_child_at_anchor(GTK_TEXT_VIEW(imhtml), ebox, anchor); |
|
2cc9edf33feb
Allow saving custom smileys by right-clicking on them. And use the custom smileys only on the received messages, not for the system/etc. messages.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16385
diff
changeset
|
5043 | } |
| 8890 | 5044 | } else { |
| 5045 | gtk_text_buffer_insert(imhtml->text_buffer, iter, smiley, -1); | |
| 8061 | 5046 | } |
| 8890 | 5047 | |
|
17009
2cc9edf33feb
Allow saving custom smileys by right-clicking on them. And use the custom smileys only on the received messages, not for the system/etc. messages.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16385
diff
changeset
|
5048 | if (ebox) { |
|
2cc9edf33feb
Allow saving custom smileys by right-clicking on them. And use the custom smileys only on the received messages, not for the system/etc. messages.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16385
diff
changeset
|
5049 | g_signal_connect(G_OBJECT(ebox), "event", G_CALLBACK(gtk_imhtml_smiley_clicked), imhtml_smiley); |
|
2cc9edf33feb
Allow saving custom smileys by right-clicking on them. And use the custom smileys only on the received messages, not for the system/etc. messages.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16385
diff
changeset
|
5050 | } |
|
2cc9edf33feb
Allow saving custom smileys by right-clicking on them. And use the custom smileys only on the received messages, not for the system/etc. messages.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
16385
diff
changeset
|
5051 | |
| 8890 | 5052 | g_free(unescaped); |
| 8061 | 5053 | } |
| 5054 | ||
| 8962 | 5055 | void gtk_imhtml_insert_image_at_iter(GtkIMHtml *imhtml, int id, GtkTextIter *iter) |
| 5056 | { | |
|
18151
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
5057 | GdkPixbufAnimation *anim = NULL; |
| 8962 | 5058 | const char *filename = NULL; |
| 5059 | gpointer image; | |
| 5060 | GdkRectangle rect; | |
| 5061 | GtkIMHtmlScalable *scalable = NULL; | |
|
11224
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
5062 | struct scalable_data *sd; |
| 8962 | 5063 | int minus; |
| 5064 | ||
| 5065 | if (!imhtml->funcs || !imhtml->funcs->image_get || | |
| 5066 | !imhtml->funcs->image_get_size || !imhtml->funcs->image_get_data || | |
| 5067 | !imhtml->funcs->image_get_filename || !imhtml->funcs->image_ref || | |
| 5068 | !imhtml->funcs->image_unref) | |
| 5069 | return; | |
| 5070 | ||
| 5071 | image = imhtml->funcs->image_get(id); | |
| 5072 | ||
| 5073 | if (image) { | |
| 5074 | gpointer data; | |
| 5075 | size_t len; | |
| 5076 | ||
| 5077 | data = imhtml->funcs->image_get_data(image); | |
| 5078 | len = imhtml->funcs->image_get_size(image); | |
| 5079 | ||
| 5080 | if (data && len) { | |
| 5081 | GdkPixbufLoader *loader = gdk_pixbuf_loader_new(); | |
| 5082 | gdk_pixbuf_loader_write(loader, data, len, NULL); | |
|
12230
2f327bccf63b
[gaim-migrate @ 14532]
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
12229
diff
changeset
|
5083 | gdk_pixbuf_loader_close(loader, NULL); |
|
18151
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
5084 | anim = gdk_pixbuf_loader_get_animation(loader); |
|
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
5085 | if (anim) |
|
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
5086 | g_object_ref(G_OBJECT(anim)); |
| 9337 | 5087 | g_object_unref(G_OBJECT(loader)); |
| 8962 | 5088 | } |
| 5089 | ||
| 5090 | } | |
| 5091 | ||
|
18151
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
5092 | if (anim) { |
|
11299
06bb44ed0cf3
[gaim-migrate @ 13499]
Richard Laager <rlaager@pidgin.im>
parents:
11276
diff
changeset
|
5093 | struct im_image_data *t = g_new(struct im_image_data, 1); |
| 8962 | 5094 | filename = imhtml->funcs->image_get_filename(image); |
| 5095 | imhtml->funcs->image_ref(id); | |
|
11224
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
5096 | t->id = id; |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
5097 | t->mark = gtk_text_buffer_create_mark(imhtml->text_buffer, NULL, iter, TRUE); |
|
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
5098 | imhtml->im_images = g_slist_prepend(imhtml->im_images, t); |
|
18151
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
5099 | scalable = gtk_imhtml_animation_new(anim, filename, id); |
|
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
5100 | g_object_unref(G_OBJECT(anim)); |
| 8962 | 5101 | } else { |
|
18151
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
5102 | GdkPixbuf *pixbuf; |
| 8962 | 5103 | pixbuf = gtk_widget_render_icon(GTK_WIDGET(imhtml), GTK_STOCK_MISSING_IMAGE, |
| 5104 | GTK_ICON_SIZE_BUTTON, "gtkimhtml-missing-image"); | |
|
18151
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
5105 | scalable = gtk_imhtml_image_new(pixbuf, filename, id); |
|
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
5106 | g_object_unref(G_OBJECT(pixbuf)); |
| 8962 | 5107 | } |
| 5108 | ||
|
11224
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
5109 | sd = g_new(struct scalable_data, 1); |
|
18151
97fd60f47229
When an animated image is inserted into a conversation window, animate
Mark Doliner <markdoliner@pidgin.im>
parents:
18119
diff
changeset
|
5110 | sd->scalable = scalable; |
|
11233
28c0f184a2d4
[gaim-migrate @ 13373]
Daniel Atallah <datallah@pidgin.im>
parents:
11224
diff
changeset
|
5111 | sd->mark = gtk_text_buffer_create_mark(imhtml->text_buffer, NULL, iter, TRUE); |
| 8962 | 5112 | gtk_text_view_get_visible_rect(GTK_TEXT_VIEW(imhtml), &rect); |
| 5113 | scalable->add_to(scalable, imhtml, iter); | |
| 5114 | minus = gtk_text_view_get_left_margin(GTK_TEXT_VIEW(imhtml)) + | |
| 5115 | gtk_text_view_get_right_margin(GTK_TEXT_VIEW(imhtml)); | |
| 5116 | scalable->scale(scalable, rect.width - minus, rect.height); | |
|
11224
04c1712bb953
[gaim-migrate @ 13360]
Daniel Atallah <datallah@pidgin.im>
parents:
11143
diff
changeset
|
5117 | imhtml->scalables = g_list_append(imhtml->scalables, sd); |
| 8962 | 5118 | } |
| 5119 | ||
| 8677 | 5120 | static const gchar *tag_to_html_start(GtkTextTag *tag) |
| 8061 | 5121 | { |
| 8677 | 5122 | const gchar *name; |
| 5123 | static gchar buf[1024]; | |
| 5124 | ||
| 5125 | name = tag->name; | |
| 5126 | g_return_val_if_fail(name != NULL, ""); | |
| 5127 | ||
| 5128 | if (strcmp(name, "BOLD") == 0) { | |
| 5129 | return "<b>"; | |
| 5130 | } else if (strcmp(name, "ITALICS") == 0) { | |
| 5131 | return "<i>"; | |
| 5132 | } else if (strcmp(name, "UNDERLINE") == 0) { | |
| 5133 | return "<u>"; | |
| 9924 | 5134 | } else if (strcmp(name, "STRIKE") == 0) { |
| 5135 | return "<s>"; | |
| 8677 | 5136 | } else if (strncmp(name, "LINK ", 5) == 0) { |
| 5137 | char *tmp = g_object_get_data(G_OBJECT(tag), "link_url"); | |
| 5138 | if (tmp) { | |
| 5139 | g_snprintf(buf, sizeof(buf), "<a href=\"%s\">", tmp); | |
| 5140 | buf[sizeof(buf)-1] = '\0'; | |
| 5141 | return buf; | |
| 5142 | } else { | |
| 5143 | return ""; | |
| 5144 | } | |
| 5145 | } else if (strncmp(name, "FORECOLOR ", 10) == 0) { | |
| 5146 | g_snprintf(buf, sizeof(buf), "<font color=\"%s\">", &name[10]); | |
| 5147 | return buf; | |
| 5148 | } else if (strncmp(name, "BACKCOLOR ", 10) == 0) { | |
| 5149 | g_snprintf(buf, sizeof(buf), "<font back=\"%s\">", &name[10]); | |
| 5150 | return buf; | |
| 10776 | 5151 | } else if (strncmp(name, "BACKGROUND ", 10) == 0) { |
| 5152 | g_snprintf(buf, sizeof(buf), "<body bgcolor=\"%s\">", &name[11]); | |
| 5153 | return buf; | |
| 8677 | 5154 | } else if (strncmp(name, "FONT FACE ", 10) == 0) { |
| 5155 | g_snprintf(buf, sizeof(buf), "<font face=\"%s\">", &name[10]); | |
| 5156 | return buf; | |
| 5157 | } else if (strncmp(name, "FONT SIZE ", 10) == 0) { | |
| 5158 | g_snprintf(buf, sizeof(buf), "<font size=\"%s\">", &name[10]); | |
| 5159 | return buf; | |
| 5160 | } else { | |
|
23308
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5161 | char *str = buf; |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5162 | gboolean isset; |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5163 | int ivalue = 0; |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5164 | GdkColor *color = NULL; |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5165 | GObject *obj = G_OBJECT(tag); |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5166 | gboolean empty = TRUE; |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5167 | |
|
23310
e34473be13db
Get rid of the boldness of the bold timestamps.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23308
diff
changeset
|
5168 | str += g_snprintf(str, sizeof(buf) - (str - buf), "<span style='"); |
|
23308
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5169 | |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5170 | /* Weight */ |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5171 | g_object_get(obj, "weight-set", &isset, "weight", &ivalue, NULL); |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5172 | if (isset) { |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5173 | const char *weight = ""; |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5174 | if (ivalue >= PANGO_WEIGHT_ULTRABOLD) |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5175 | weight = "bolder"; |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5176 | else if (ivalue >= PANGO_WEIGHT_BOLD) |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5177 | weight = "bold"; |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5178 | else if (ivalue >= PANGO_WEIGHT_NORMAL) |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5179 | weight = "normal"; |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5180 | else |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5181 | weight = "lighter"; |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5182 | |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5183 | str += g_snprintf(str, sizeof(buf) - (str - buf), "font-weight: %s;", weight); |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5184 | empty = FALSE; |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5185 | } |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5186 | |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5187 | /* Foreground color */ |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5188 | g_object_get(obj, "foreground-set", &isset, "foreground-gdk", &color, NULL); |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5189 | if (isset && color) { |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5190 | str += g_snprintf(str, sizeof(buf) - (str - buf), |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5191 | "color: #%02x%02x%02x;", |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5192 | color->red >> 8, color->green >> 8, color->blue >> 8); |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5193 | empty = FALSE; |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5194 | } |
|
23466
7380df2e12f1
Patch from Andrew Gaul that fixes another leak:
Ka-Hing Cheung <khc@pidgin.im>
parents:
23465
diff
changeset
|
5195 | gdk_color_free(color); |
|
23308
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5196 | |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5197 | /* Background color */ |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5198 | g_object_get(obj, "background-set", &isset, "background-gdk", &color, NULL); |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5199 | if (isset && color) { |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5200 | str += g_snprintf(str, sizeof(buf) - (str - buf), |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5201 | "background: #%02x%02x%02x;", |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5202 | color->red >> 8, color->green >> 8, color->blue >> 8); |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5203 | empty = FALSE; |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5204 | } |
|
23466
7380df2e12f1
Patch from Andrew Gaul that fixes another leak:
Ka-Hing Cheung <khc@pidgin.im>
parents:
23465
diff
changeset
|
5205 | gdk_color_free(color); |
|
23308
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5206 | |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5207 | /* Underline */ |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5208 | g_object_get(obj, "underline-set", &isset, "underline", &ivalue, NULL); |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5209 | if (isset) { |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5210 | switch (ivalue) { |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5211 | case PANGO_UNDERLINE_NONE: |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5212 | case PANGO_UNDERLINE_ERROR: |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5213 | break; |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5214 | default: |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5215 | str += g_snprintf(str, sizeof(buf) - (str - buf), "text-decoration: underline;"); |
|
23365
fc1df3495580
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23332
diff
changeset
|
5216 | empty = FALSE; |
|
23308
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5217 | } |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5218 | } |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5219 | |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5220 | g_snprintf(str, sizeof(buf) - (str - buf), "'>"); |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5221 | |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5222 | return (empty ? "" : buf); |
| 8677 | 5223 | } |
| 8061 | 5224 | } |
| 5225 | ||
| 8677 | 5226 | static const gchar *tag_to_html_end(GtkTextTag *tag) |
| 8061 | 5227 | { |
| 8677 | 5228 | const gchar *name; |
| 5229 | ||
| 5230 | name = tag->name; | |
| 5231 | g_return_val_if_fail(name != NULL, ""); | |
| 5232 | ||
| 5233 | if (strcmp(name, "BOLD") == 0) { | |
| 5234 | return "</b>"; | |
| 5235 | } else if (strcmp(name, "ITALICS") == 0) { | |
| 5236 | return "</i>"; | |
| 5237 | } else if (strcmp(name, "UNDERLINE") == 0) { | |
| 5238 | return "</u>"; | |
| 9924 | 5239 | } else if (strcmp(name, "STRIKE") == 0) { |
| 5240 | return "</s>"; | |
| 8677 | 5241 | } else if (strncmp(name, "LINK ", 5) == 0) { |
| 5242 | return "</a>"; | |
| 5243 | } else if (strncmp(name, "FORECOLOR ", 10) == 0) { | |
| 5244 | return "</font>"; | |
| 5245 | } else if (strncmp(name, "BACKCOLOR ", 10) == 0) { | |
| 5246 | return "</font>"; | |
| 10776 | 5247 | } else if (strncmp(name, "BACKGROUND ", 10) == 0) { |
| 5248 | return "</body>"; | |
| 8677 | 5249 | } else if (strncmp(name, "FONT FACE ", 10) == 0) { |
| 5250 | return "</font>"; | |
| 5251 | } else if (strncmp(name, "FONT SIZE ", 10) == 0) { | |
| 5252 | return "</font>"; | |
| 5253 | } else { | |
|
23308
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5254 | const char *props[] = {"weight-set", "foreground-set", "background-set", |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5255 | "size-set", "underline-set", NULL}; |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5256 | int i; |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5257 | for (i = 0; props[i]; i++) { |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5258 | gboolean set = FALSE; |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5259 | g_object_get(G_OBJECT(tag), props[i], &set, NULL); |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5260 | if (set) |
|
23310
e34473be13db
Get rid of the boldness of the bold timestamps.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23308
diff
changeset
|
5261 | return "</span>"; |
|
23308
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5262 | } |
|
ccc2815ee9a1
Fix exporting proper HTML for tags.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23304
diff
changeset
|
5263 | |
| 8677 | 5264 | return ""; |
| 5265 | } | |
| 5266 | } | |
| 5267 | ||
|
23365
fc1df3495580
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23332
diff
changeset
|
5268 | typedef struct { |
|
fc1df3495580
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23332
diff
changeset
|
5269 | GtkTextTag *tag; |
|
fc1df3495580
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23332
diff
changeset
|
5270 | char *end; |
|
fc1df3495580
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23332
diff
changeset
|
5271 | char *start; |
|
fc1df3495580
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23332
diff
changeset
|
5272 | } PidginTextTagData; |
|
fc1df3495580
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23332
diff
changeset
|
5273 | |
|
fc1df3495580
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23332
diff
changeset
|
5274 | static PidginTextTagData *text_tag_data_new(GtkTextTag *tag) |
|
fc1df3495580
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23332
diff
changeset
|
5275 | { |
|
fc1df3495580
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23332
diff
changeset
|
5276 | const char *start, *end; |
|
fc1df3495580
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23332
diff
changeset
|
5277 | PidginTextTagData *ret = NULL; |
|
fc1df3495580
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23332
diff
changeset
|
5278 | |
|
fc1df3495580
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23332
diff
changeset
|
5279 | start = tag_to_html_start(tag); |
|
fc1df3495580
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23332
diff
changeset
|
5280 | if (!start || !*start) |
|
fc1df3495580
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23332
diff
changeset
|
5281 | return NULL; |
|
fc1df3495580
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23332
diff
changeset
|
5282 | end = tag_to_html_end(tag); |
|
fc1df3495580
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23332
diff
changeset
|
5283 | if (!end || !*end) |
|
fc1df3495580
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23332
diff
changeset
|
5284 | return NULL; |
|
fc1df3495580
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23332
diff
changeset
|
5285 | |
|
fc1df3495580
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23332
diff
changeset
|
5286 | ret = g_new0(PidginTextTagData, 1); |
|
fc1df3495580
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23332
diff
changeset
|
5287 | ret->start = g_strdup(start); |
|
fc1df3495580
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23332
diff
changeset
|
5288 | ret->end = g_strdup(end); |
|
fc1df3495580
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23332
diff
changeset
|
5289 | ret->tag = tag; |
|
fc1df3495580
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23332
diff
changeset
|
5290 | return ret; |
|
fc1df3495580
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23332
diff
changeset
|
5291 | } |
|
fc1df3495580
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23332
diff
changeset
|
5292 | |
|
fc1df3495580
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23332
diff
changeset
|
5293 | static void text_tag_data_destroy(PidginTextTagData *data) |
|
fc1df3495580
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23332
diff
changeset
|
5294 | { |
|
fc1df3495580
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23332
diff
changeset
|
5295 | g_free(data->start); |
|
fc1df3495580
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23332
diff
changeset
|
5296 | g_free(data->end); |
|
fc1df3495580
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23332
diff
changeset
|
5297 | g_free(data); |
|
fc1df3495580
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23332
diff
changeset
|
5298 | } |
|
fc1df3495580
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23332
diff
changeset
|
5299 | |
| 8677 | 5300 | static gboolean tag_ends_here(GtkTextTag *tag, GtkTextIter *iter, GtkTextIter *niter) |
| 5301 | { | |
| 5302 | return ((gtk_text_iter_has_tag(iter, GTK_TEXT_TAG(tag)) && | |
| 5303 | !gtk_text_iter_has_tag(niter, GTK_TEXT_TAG(tag))) || | |
| 5304 | gtk_text_iter_is_end(niter)); | |
| 8061 | 5305 | } |
| 5306 | ||
| 5307 | /* Basic notion here: traverse through the text buffer one-by-one, non-character elements, such | |
| 5308 | * as smileys and IM images are represented by the Unicode "unknown" character. Handle them. Else | |
| 8677 | 5309 | * check for tags that are toggled on, insert their html form, and push them on the queue. Then insert |
| 5310 | * the actual text. Then check for tags that are toggled off and insert them, after checking the queue. | |
|
8735
01248ea222d3
[gaim-migrate @ 9490]
Jonathan Champ <royanee@users.sourceforge.net>
parents:
8729
diff
changeset
|
5311 | * Finally, replace <, >, &, and " with their HTML equivalent. |
| 8677 | 5312 | */ |
| 8061 | 5313 | char *gtk_imhtml_get_markup_range(GtkIMHtml *imhtml, GtkTextIter *start, GtkTextIter *end) |
| 5314 | { | |
| 5315 | gunichar c; | |
|
16143
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
5316 | GtkTextIter iter, next_iter, non_neutral_iter; |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
5317 | gboolean is_rtl_message = FALSE; |
| 8061 | 5318 | GString *str = g_string_new(""); |
| 8677 | 5319 | GSList *tags, *sl; |
|
23365
fc1df3495580
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23332
diff
changeset
|
5320 | GQueue *q; |
| 8677 | 5321 | GtkTextTag *tag; |
|
23365
fc1df3495580
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23332
diff
changeset
|
5322 | PidginTextTagData *tagdata; |
| 8677 | 5323 | |
| 5324 | q = g_queue_new(); | |
| 8061 | 5325 | |
| 5326 | gtk_text_iter_order(start, end); | |
|
16143
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
5327 | non_neutral_iter = next_iter = iter = *start; |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
5328 | gtk_text_iter_forward_char(&next_iter); |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
5329 | |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
5330 | /* Bi-directional text support */ |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
5331 | /* Get to the first non-neutral character */ |
|
16291
acbfc9276da1
Fix for using Pango < 1.4, will not have complete RTL support with older
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16254
diff
changeset
|
5332 | #ifdef HAVE_PANGO14 |
| 16144 | 5333 | while ((PANGO_DIRECTION_NEUTRAL == pango_unichar_direction(gtk_text_iter_get_char(&non_neutral_iter))) |
|
16143
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
5334 | && gtk_text_iter_forward_char(&non_neutral_iter)); |
| 16144 | 5335 | if (PANGO_DIRECTION_RTL == pango_unichar_direction(gtk_text_iter_get_char(&non_neutral_iter))) { |
|
16143
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
5336 | is_rtl_message = TRUE; |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
5337 | g_string_append(str, "<SPAN style=\"direction:rtl;text-align:right;\">"); |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
5338 | } |
|
16291
acbfc9276da1
Fix for using Pango < 1.4, will not have complete RTL support with older
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
16254
diff
changeset
|
5339 | #endif |
| 8677 | 5340 | |
| 9071 | 5341 | /* First add the tags that are already in progress (we don't care about non-printing tags)*/ |
| 8677 | 5342 | tags = gtk_text_iter_get_tags(start); |
| 5343 | ||
| 5344 | for (sl = tags; sl; sl = sl->next) { | |
| 5345 | tag = sl->data; | |
| 5346 | if (!gtk_text_iter_toggles_tag(start, GTK_TEXT_TAG(tag))) { | |
|
23365
fc1df3495580
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23332
diff
changeset
|
5347 | PidginTextTagData *data = text_tag_data_new(tag); |
|
fc1df3495580
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23332
diff
changeset
|
5348 | if (data) { |
|
fc1df3495580
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23332
diff
changeset
|
5349 | g_string_append(str, data->start); |
|
fc1df3495580
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23332
diff
changeset
|
5350 | g_queue_push_tail(q, data); |
|
fc1df3495580
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23332
diff
changeset
|
5351 | } |
| 8061 | 5352 | } |
| 5353 | } | |
| 8677 | 5354 | g_slist_free(tags); |
| 8061 | 5355 | |
| 5356 | while ((c = gtk_text_iter_get_char(&iter)) != 0 && !gtk_text_iter_equal(&iter, end)) { | |
| 8677 | 5357 | |
| 5358 | tags = gtk_text_iter_get_tags(&iter); | |
| 5359 | ||
| 5360 | for (sl = tags; sl; sl = sl->next) { | |
| 5361 | tag = sl->data; | |
| 5362 | if (gtk_text_iter_begins_tag(&iter, GTK_TEXT_TAG(tag))) { | |
|
23365
fc1df3495580
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23332
diff
changeset
|
5363 | PidginTextTagData *data = text_tag_data_new(tag); |
|
fc1df3495580
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23332
diff
changeset
|
5364 | if (data) { |
|
fc1df3495580
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23332
diff
changeset
|
5365 | g_string_append(str, data->start); |
|
fc1df3495580
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23332
diff
changeset
|
5366 | g_queue_push_tail(q, data); |
|
fc1df3495580
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23332
diff
changeset
|
5367 | } |
| 8677 | 5368 | } |
| 5369 | } | |
| 5370 | ||
| 8061 | 5371 | if (c == 0xFFFC) { |
| 5372 | GtkTextChildAnchor* anchor = gtk_text_iter_get_child_anchor(&iter); | |
| 9071 | 5373 | if (anchor) { |
| 5374 | char *text = g_object_get_data(G_OBJECT(anchor), "gtkimhtml_htmltext"); | |
| 5375 | if (text) | |
| 5376 | str = g_string_append(str, text); | |
| 5377 | } | |
|
11572
3aaac95fa1ec
[gaim-migrate @ 13840]
Daniel Atallah <datallah@pidgin.im>
parents:
11525
diff
changeset
|
5378 | } else if (c == '<') { |
| 8677 | 5379 | str = g_string_append(str, "<"); |
| 5380 | } else if (c == '>') { | |
| 5381 | str = g_string_append(str, ">"); | |
| 5382 | } else if (c == '&') { | |
| 5383 | str = g_string_append(str, "&"); | |
| 5384 | } else if (c == '"') { | |
| 5385 | str = g_string_append(str, """); | |
| 5386 | } else if (c == '\n') { | |
|
19746
4537d921dab4
disapproval of revision '10d0834255f911ca2359c74b430025155af2b22e'
Kevin Stange <kstange@pidgin.im>
parents:
19745
diff
changeset
|
5387 | str = g_string_append(str, "<br>"); |
| 8061 | 5388 | } else { |
| 8677 | 5389 | str = g_string_append_unichar(str, c); |
| 5390 | } | |
| 5391 | ||
| 5392 | tags = g_slist_reverse(tags); | |
| 5393 | for (sl = tags; sl; sl = sl->next) { | |
| 5394 | tag = sl->data; | |
| 9071 | 5395 | /** don't worry about non-printing tags ending */ |
|
23365
fc1df3495580
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23332
diff
changeset
|
5396 | if (tag_ends_here(tag, &iter, &next_iter) && |
|
fc1df3495580
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23332
diff
changeset
|
5397 | strlen(tag_to_html_end(tag)) > 0 && |
|
fc1df3495580
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23332
diff
changeset
|
5398 | strlen(tag_to_html_start(tag)) > 0) { |
|
fc1df3495580
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23332
diff
changeset
|
5399 | |
|
fc1df3495580
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23332
diff
changeset
|
5400 | PidginTextTagData *tmp; |
|
fc1df3495580
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23332
diff
changeset
|
5401 | GQueue *r = g_queue_new(); |
|
fc1df3495580
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23332
diff
changeset
|
5402 | |
|
fc1df3495580
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23332
diff
changeset
|
5403 | while ((tmp = g_queue_pop_tail(q)) && tmp->tag != tag) { |
|
fc1df3495580
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23332
diff
changeset
|
5404 | g_string_append(str, tmp->end); |
|
fc1df3495580
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23332
diff
changeset
|
5405 | if (!tag_ends_here(tmp->tag, &iter, &next_iter)) |
| 8677 | 5406 | g_queue_push_tail(r, tmp); |
|
23365
fc1df3495580
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23332
diff
changeset
|
5407 | else |
|
fc1df3495580
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23332
diff
changeset
|
5408 | text_tag_data_destroy(tmp); |
| 8677 | 5409 | } |
| 5410 | ||
|
25470
b1777c3ab2bb
Prevent a crash that can occur while copying the contents of the Debug Window. This ends up masking mismatched tags in the imhtml output, but that is
Daniel Atallah <datallah@pidgin.im>
parents:
25299
diff
changeset
|
5411 | if (tmp != NULL) { |
|
23365
fc1df3495580
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23332
diff
changeset
|
5412 | g_string_append(str, tmp->end); |
|
23465
e20729245830
Patch from Andrew Gaul that fixes a leak:
Ka-Hing Cheung <khc@pidgin.im>
parents:
23398
diff
changeset
|
5413 | text_tag_data_destroy(tmp); |
|
e20729245830
Patch from Andrew Gaul that fixes a leak:
Ka-Hing Cheung <khc@pidgin.im>
parents:
23398
diff
changeset
|
5414 | } |
|
25470
b1777c3ab2bb
Prevent a crash that can occur while copying the contents of the Debug Window. This ends up masking mismatched tags in the imhtml output, but that is
Daniel Atallah <datallah@pidgin.im>
parents:
25299
diff
changeset
|
5415 | #if 0 /* This can't be allowed to happen because it causes the iters to be invalidated in the debug window imhtml during text copying */ |
|
b1777c3ab2bb
Prevent a crash that can occur while copying the contents of the Debug Window. This ends up masking mismatched tags in the imhtml output, but that is
Daniel Atallah <datallah@pidgin.im>
parents:
25299
diff
changeset
|
5416 | else |
|
b1777c3ab2bb
Prevent a crash that can occur while copying the contents of the Debug Window. This ends up masking mismatched tags in the imhtml output, but that is
Daniel Atallah <datallah@pidgin.im>
parents:
25299
diff
changeset
|
5417 | purple_debug_warning("gtkimhtml", "empty queue, more closing tags than open tags!\n"); |
|
b1777c3ab2bb
Prevent a crash that can occur while copying the contents of the Debug Window. This ends up masking mismatched tags in the imhtml output, but that is
Daniel Atallah <datallah@pidgin.im>
parents:
25299
diff
changeset
|
5418 | #endif |
| 8677 | 5419 | |
| 5420 | while ((tmp = g_queue_pop_head(r))) { | |
|
23365
fc1df3495580
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23332
diff
changeset
|
5421 | g_string_append(str, tmp->start); |
| 8677 | 5422 | g_queue_push_tail(q, tmp); |
| 8061 | 5423 | } |
|
23365
fc1df3495580
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23332
diff
changeset
|
5424 | g_queue_free(r); |
| 8061 | 5425 | } |
| 5426 | } | |
| 8677 | 5427 | |
| 5428 | g_slist_free(tags); | |
| 8061 | 5429 | gtk_text_iter_forward_char(&iter); |
|
16143
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
5430 | gtk_text_iter_forward_char(&next_iter); |
| 8061 | 5431 | } |
| 8677 | 5432 | |
|
23365
fc1df3495580
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23332
diff
changeset
|
5433 | while ((tagdata = g_queue_pop_tail(q))) { |
|
fc1df3495580
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23332
diff
changeset
|
5434 | g_string_append(str, tagdata->end); |
|
fc1df3495580
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23332
diff
changeset
|
5435 | text_tag_data_destroy(tagdata); |
|
fc1df3495580
Fix the linkification. Also, remember the html-codes for a tag instead of
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23332
diff
changeset
|
5436 | } |
| 8677 | 5437 | |
|
16143
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
5438 | /* Bi-directional text support - close tags */ |
| 16144 | 5439 | if (is_rtl_message) |
|
16143
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
5440 | g_string_append(str, "</SPAN>"); |
|
6393e5b11ff5
Patch from shlomil in ticket #78.
Shlomi Loubaton <shlomister@gmail.com>
parents:
15931
diff
changeset
|
5441 | |
| 8677 | 5442 | g_queue_free(q); |
| 8061 | 5443 | return g_string_free(str, FALSE); |
| 5444 | } | |
| 5445 | ||
| 8698 | 5446 | void gtk_imhtml_close_tags(GtkIMHtml *imhtml, GtkTextIter *iter) |
| 8061 | 5447 | { |
| 5448 | if (imhtml->edit.bold) | |
| 5449 | gtk_imhtml_toggle_bold(imhtml); | |
| 5450 | ||
| 5451 | if (imhtml->edit.italic) | |
| 5452 | gtk_imhtml_toggle_italic(imhtml); | |
| 5453 | ||
| 5454 | if (imhtml->edit.underline) | |
| 5455 | gtk_imhtml_toggle_underline(imhtml); | |
| 5456 | ||
| 9924 | 5457 | if (imhtml->edit.strike) |
| 5458 | gtk_imhtml_toggle_strike(imhtml); | |
| 5459 | ||
| 8061 | 5460 | if (imhtml->edit.forecolor) |
| 5461 | gtk_imhtml_toggle_forecolor(imhtml, NULL); | |
| 5462 | ||
| 5463 | if (imhtml->edit.backcolor) | |
| 5464 | gtk_imhtml_toggle_backcolor(imhtml, NULL); | |
| 5465 | ||
| 5466 | if (imhtml->edit.fontface) | |
| 5467 | gtk_imhtml_toggle_fontface(imhtml, NULL); | |
| 5468 | ||
| 8677 | 5469 | imhtml->edit.fontsize = 0; |
| 5470 | ||
| 8719 | 5471 | if (imhtml->edit.link) |
| 5472 | gtk_imhtml_toggle_link(imhtml, NULL); | |
| 8061 | 5473 | } |
| 5474 | ||
| 5475 | char *gtk_imhtml_get_markup(GtkIMHtml *imhtml) | |
| 5476 | { | |
| 5477 | GtkTextIter start, end; | |
| 5478 | ||
| 5479 | gtk_text_buffer_get_start_iter(imhtml->text_buffer, &start); | |
| 5480 | gtk_text_buffer_get_end_iter(imhtml->text_buffer, &end); | |
| 5481 | return gtk_imhtml_get_markup_range(imhtml, &start, &end); | |
| 5482 | } | |
| 5483 | ||
| 8677 | 5484 | char **gtk_imhtml_get_markup_lines(GtkIMHtml *imhtml) |
| 5485 | { | |
| 5486 | int i, j, lines; | |
| 5487 | GtkTextIter start, end; | |
| 5488 | char **ret; | |
| 5489 | ||
| 5490 | lines = gtk_text_buffer_get_line_count(imhtml->text_buffer); | |
| 5491 | ret = g_new0(char *, lines + 1); | |
| 5492 | gtk_text_buffer_get_start_iter(imhtml->text_buffer, &start); | |
| 5493 | end = start; | |
| 5494 | gtk_text_iter_forward_to_line_end(&end); | |
| 5495 | ||
| 5496 | for (i = 0, j = 0; i < lines; i++) { | |
| 9612 | 5497 | if (gtk_text_iter_get_char(&start) != '\n') { |
| 5498 | ret[j] = gtk_imhtml_get_markup_range(imhtml, &start, &end); | |
| 5499 | if (ret[j] != NULL) | |
| 5500 | j++; | |
| 5501 | } | |
| 5502 | ||
| 8677 | 5503 | gtk_text_iter_forward_line(&start); |
| 5504 | end = start; | |
| 5505 | gtk_text_iter_forward_to_line_end(&end); | |
| 5506 | } | |
| 5507 | ||
| 5508 | return ret; | |
| 5509 | } | |
| 5510 | ||
| 5511 | char *gtk_imhtml_get_text(GtkIMHtml *imhtml, GtkTextIter *start, GtkTextIter *stop) | |
| 8061 | 5512 | { |
| 8519 | 5513 | GString *str = g_string_new(""); |
| 5514 | GtkTextIter iter, end; | |
| 5515 | gunichar c; | |
| 5516 | ||
| 8677 | 5517 | if (start == NULL) |
| 5518 | gtk_text_buffer_get_start_iter(imhtml->text_buffer, &iter); | |
| 5519 | else | |
| 5520 | iter = *start; | |
| 5521 | ||
| 5522 | if (stop == NULL) | |
| 5523 | gtk_text_buffer_get_end_iter(imhtml->text_buffer, &end); | |
| 5524 | else | |
| 5525 | end = *stop; | |
| 5526 | ||
| 5527 | gtk_text_iter_order(&iter, &end); | |
| 8519 | 5528 | |
| 5529 | while ((c = gtk_text_iter_get_char(&iter)) != 0 && !gtk_text_iter_equal(&iter, &end)) { | |
| 5530 | if (c == 0xFFFC) { | |
| 8677 | 5531 | GtkTextChildAnchor* anchor; |
| 5532 | char *text = NULL; | |
| 5533 | ||
| 5534 | anchor = gtk_text_iter_get_child_anchor(&iter); | |
| 5535 | if (anchor) | |
| 8698 | 5536 | text = g_object_get_data(G_OBJECT(anchor), "gtkimhtml_plaintext"); |
| 8677 | 5537 | if (text) |
| 5538 | str = g_string_append(str, text); | |
| 8519 | 5539 | } else { |
| 5540 | g_string_append_unichar(str, c); | |
| 5541 | } | |
| 5542 | gtk_text_iter_forward_char(&iter); | |
| 5543 | } | |
| 5544 | ||
| 5545 | return g_string_free(str, FALSE); | |
| 8061 | 5546 | } |
| 8962 | 5547 | |
| 5548 | void gtk_imhtml_set_funcs(GtkIMHtml *imhtml, GtkIMHtmlFuncs *f) | |
| 5549 | { | |
| 5550 | g_return_if_fail(imhtml != NULL); | |
| 5551 | imhtml->funcs = f; | |
| 5552 | } | |
|
17388
8be39f0de528
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17288
diff
changeset
|
5553 | |
|
8be39f0de528
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17288
diff
changeset
|
5554 | void gtk_imhtml_setup_entry(GtkIMHtml *imhtml, PurpleConnectionFlags flags) |
|
8be39f0de528
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17288
diff
changeset
|
5555 | { |
|
18240
0a7d2fde749b
Fix setting the sensitivity of the toolbar items in a number of places
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
18185
diff
changeset
|
5556 | GtkIMHtmlButtons buttons; |
|
0a7d2fde749b
Fix setting the sensitivity of the toolbar items in a number of places
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
18185
diff
changeset
|
5557 | |
|
17388
8be39f0de528
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17288
diff
changeset
|
5558 | if (flags & PURPLE_CONNECTION_HTML) { |
|
8be39f0de528
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17288
diff
changeset
|
5559 | char color[8]; |
|
8be39f0de528
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17288
diff
changeset
|
5560 | GdkColor fg_color, bg_color; |
|
8be39f0de528
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17288
diff
changeset
|
5561 | |
|
18240
0a7d2fde749b
Fix setting the sensitivity of the toolbar items in a number of places
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
18185
diff
changeset
|
5562 | buttons = GTK_IMHTML_ALL; |
|
0a7d2fde749b
Fix setting the sensitivity of the toolbar items in a number of places
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
18185
diff
changeset
|
5563 | |
|
0a7d2fde749b
Fix setting the sensitivity of the toolbar items in a number of places
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
18185
diff
changeset
|
5564 | if (flags & PURPLE_CONNECTION_NO_BGCOLOR) |
|
0a7d2fde749b
Fix setting the sensitivity of the toolbar items in a number of places
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
18185
diff
changeset
|
5565 | buttons &= ~GTK_IMHTML_BACKCOLOR; |
|
0a7d2fde749b
Fix setting the sensitivity of the toolbar items in a number of places
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
18185
diff
changeset
|
5566 | if (flags & PURPLE_CONNECTION_NO_FONTSIZE) |
|
0a7d2fde749b
Fix setting the sensitivity of the toolbar items in a number of places
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
18185
diff
changeset
|
5567 | { |
|
0a7d2fde749b
Fix setting the sensitivity of the toolbar items in a number of places
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
18185
diff
changeset
|
5568 | buttons &= ~GTK_IMHTML_GROW; |
|
0a7d2fde749b
Fix setting the sensitivity of the toolbar items in a number of places
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
18185
diff
changeset
|
5569 | buttons &= ~GTK_IMHTML_SHRINK; |
|
0a7d2fde749b
Fix setting the sensitivity of the toolbar items in a number of places
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
18185
diff
changeset
|
5570 | } |
|
0a7d2fde749b
Fix setting the sensitivity of the toolbar items in a number of places
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
18185
diff
changeset
|
5571 | if (flags & PURPLE_CONNECTION_NO_URLDESC) |
|
0a7d2fde749b
Fix setting the sensitivity of the toolbar items in a number of places
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
18185
diff
changeset
|
5572 | buttons &= ~GTK_IMHTML_LINKDESC; |
|
0a7d2fde749b
Fix setting the sensitivity of the toolbar items in a number of places
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
18185
diff
changeset
|
5573 | |
|
17388
8be39f0de528
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17288
diff
changeset
|
5574 | gtk_imhtml_set_format_functions(imhtml, GTK_IMHTML_ALL); |
|
8be39f0de528
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17288
diff
changeset
|
5575 | if (purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/conversations/send_bold") != imhtml->edit.bold) |
|
8be39f0de528
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17288
diff
changeset
|
5576 | gtk_imhtml_toggle_bold(imhtml); |
|
8be39f0de528
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17288
diff
changeset
|
5577 | |
|
8be39f0de528
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17288
diff
changeset
|
5578 | if (purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/conversations/send_italic") != imhtml->edit.italic) |
|
8be39f0de528
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17288
diff
changeset
|
5579 | gtk_imhtml_toggle_italic(imhtml); |
|
8be39f0de528
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17288
diff
changeset
|
5580 | |
|
8be39f0de528
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17288
diff
changeset
|
5581 | if (purple_prefs_get_bool(PIDGIN_PREFS_ROOT "/conversations/send_underline") != imhtml->edit.underline) |
|
8be39f0de528
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17288
diff
changeset
|
5582 | gtk_imhtml_toggle_underline(imhtml); |
|
8be39f0de528
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17288
diff
changeset
|
5583 | |
|
8be39f0de528
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17288
diff
changeset
|
5584 | gtk_imhtml_toggle_fontface(imhtml, |
|
8be39f0de528
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17288
diff
changeset
|
5585 | purple_prefs_get_string(PIDGIN_PREFS_ROOT "/conversations/font_face")); |
|
8be39f0de528
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17288
diff
changeset
|
5586 | |
|
8be39f0de528
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17288
diff
changeset
|
5587 | if (!(flags & PURPLE_CONNECTION_NO_FONTSIZE)) |
|
8be39f0de528
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17288
diff
changeset
|
5588 | { |
|
8be39f0de528
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17288
diff
changeset
|
5589 | int size = purple_prefs_get_int(PIDGIN_PREFS_ROOT "/conversations/font_size"); |
|
8be39f0de528
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17288
diff
changeset
|
5590 | |
|
8be39f0de528
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17288
diff
changeset
|
5591 | /* 3 is the default. */ |
|
8be39f0de528
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17288
diff
changeset
|
5592 | if (size != 3) |
|
8be39f0de528
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17288
diff
changeset
|
5593 | gtk_imhtml_font_set_size(imhtml, size); |
|
8be39f0de528
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17288
diff
changeset
|
5594 | } |
|
8be39f0de528
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17288
diff
changeset
|
5595 | |
|
8be39f0de528
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17288
diff
changeset
|
5596 | if(strcmp(purple_prefs_get_string(PIDGIN_PREFS_ROOT "/conversations/fgcolor"), "") != 0) |
|
8be39f0de528
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17288
diff
changeset
|
5597 | { |
|
8be39f0de528
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17288
diff
changeset
|
5598 | gdk_color_parse(purple_prefs_get_string(PIDGIN_PREFS_ROOT "/conversations/fgcolor"), |
|
8be39f0de528
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17288
diff
changeset
|
5599 | &fg_color); |
|
8be39f0de528
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17288
diff
changeset
|
5600 | g_snprintf(color, sizeof(color), "#%02x%02x%02x", |
|
8be39f0de528
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17288
diff
changeset
|
5601 | fg_color.red / 256, |
|
8be39f0de528
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17288
diff
changeset
|
5602 | fg_color.green / 256, |
|
8be39f0de528
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17288
diff
changeset
|
5603 | fg_color.blue / 256); |
|
8be39f0de528
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17288
diff
changeset
|
5604 | } else |
|
8be39f0de528
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17288
diff
changeset
|
5605 | strcpy(color, ""); |
|
8be39f0de528
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17288
diff
changeset
|
5606 | |
|
8be39f0de528
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17288
diff
changeset
|
5607 | gtk_imhtml_toggle_forecolor(imhtml, color); |
|
8be39f0de528
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17288
diff
changeset
|
5608 | |
|
8be39f0de528
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17288
diff
changeset
|
5609 | if(!(flags & PURPLE_CONNECTION_NO_BGCOLOR) && |
|
8be39f0de528
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17288
diff
changeset
|
5610 | strcmp(purple_prefs_get_string(PIDGIN_PREFS_ROOT "/conversations/bgcolor"), "") != 0) |
|
8be39f0de528
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17288
diff
changeset
|
5611 | { |
|
8be39f0de528
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17288
diff
changeset
|
5612 | gdk_color_parse(purple_prefs_get_string(PIDGIN_PREFS_ROOT "/conversations/bgcolor"), |
|
8be39f0de528
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17288
diff
changeset
|
5613 | &bg_color); |
|
8be39f0de528
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17288
diff
changeset
|
5614 | g_snprintf(color, sizeof(color), "#%02x%02x%02x", |
|
8be39f0de528
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17288
diff
changeset
|
5615 | bg_color.red / 256, |
|
8be39f0de528
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17288
diff
changeset
|
5616 | bg_color.green / 256, |
|
8be39f0de528
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17288
diff
changeset
|
5617 | bg_color.blue / 256); |
|
8be39f0de528
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17288
diff
changeset
|
5618 | } else |
|
8be39f0de528
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17288
diff
changeset
|
5619 | strcpy(color, ""); |
|
8be39f0de528
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17288
diff
changeset
|
5620 | |
|
8be39f0de528
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17288
diff
changeset
|
5621 | gtk_imhtml_toggle_background(imhtml, color); |
|
8be39f0de528
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17288
diff
changeset
|
5622 | |
|
8be39f0de528
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17288
diff
changeset
|
5623 | if (flags & PURPLE_CONNECTION_FORMATTING_WBFO) |
|
8be39f0de528
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17288
diff
changeset
|
5624 | gtk_imhtml_set_whole_buffer_formatting_only(imhtml, TRUE); |
|
8be39f0de528
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17288
diff
changeset
|
5625 | else |
|
8be39f0de528
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17288
diff
changeset
|
5626 | gtk_imhtml_set_whole_buffer_formatting_only(imhtml, FALSE); |
|
8be39f0de528
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17288
diff
changeset
|
5627 | } else { |
|
18240
0a7d2fde749b
Fix setting the sensitivity of the toolbar items in a number of places
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
18185
diff
changeset
|
5628 | buttons = GTK_IMHTML_SMILEY | GTK_IMHTML_IMAGE; |
|
17388
8be39f0de528
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17288
diff
changeset
|
5629 | imhtml_clear_formatting(imhtml); |
|
8be39f0de528
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17288
diff
changeset
|
5630 | } |
|
18240
0a7d2fde749b
Fix setting the sensitivity of the toolbar items in a number of places
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
18185
diff
changeset
|
5631 | |
|
0a7d2fde749b
Fix setting the sensitivity of the toolbar items in a number of places
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
18185
diff
changeset
|
5632 | if (flags & PURPLE_CONNECTION_NO_IMAGES) |
|
0a7d2fde749b
Fix setting the sensitivity of the toolbar items in a number of places
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
18185
diff
changeset
|
5633 | buttons &= ~GTK_IMHTML_IMAGE; |
|
0a7d2fde749b
Fix setting the sensitivity of the toolbar items in a number of places
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
18185
diff
changeset
|
5634 | |
|
23010
6230fac29cee
Show the custom smileys only on accounts that support it. References
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23008
diff
changeset
|
5635 | if (flags & PURPLE_CONNECTION_ALLOW_CUSTOM_SMILEY) |
|
6230fac29cee
Show the custom smileys only on accounts that support it. References
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23008
diff
changeset
|
5636 | buttons |= GTK_IMHTML_CUSTOM_SMILEY; |
|
6230fac29cee
Show the custom smileys only on accounts that support it. References
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23008
diff
changeset
|
5637 | else |
|
6230fac29cee
Show the custom smileys only on accounts that support it. References
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23008
diff
changeset
|
5638 | buttons &= ~GTK_IMHTML_CUSTOM_SMILEY; |
|
6230fac29cee
Show the custom smileys only on accounts that support it. References
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23008
diff
changeset
|
5639 | |
|
18240
0a7d2fde749b
Fix setting the sensitivity of the toolbar items in a number of places
Stu Tomlinson <nosnilmot@pidgin.im>
parents:
18185
diff
changeset
|
5640 | gtk_imhtml_set_format_functions(imhtml, buttons); |
|
17388
8be39f0de528
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17288
diff
changeset
|
5641 | } |
|
8be39f0de528
Allow formatted text in the pounce dialog. Also, use the same code to
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
17288
diff
changeset
|
5642 | |
|
22655
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5643 | /******* |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5644 | * GtkIMHtmlSmiley functions |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5645 | *******/ |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5646 | static void gtk_custom_smiley_allocated(GdkPixbufLoader *loader, gpointer user_data) |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5647 | { |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5648 | GtkIMHtmlSmiley *smiley; |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5649 | |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5650 | smiley = (GtkIMHtmlSmiley *)user_data; |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5651 | smiley->icon = gdk_pixbuf_loader_get_animation(loader); |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5652 | |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5653 | if (smiley->icon) |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5654 | g_object_ref(G_OBJECT(smiley->icon)); |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5655 | #ifdef DEBUG_CUSTOM_SMILEY |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5656 | purple_debug_info("custom-smiley", "gtk_custom_smiley_allocated(): got GdkPixbufAnimation %p for smiley '%s'\n", smiley->icon, smiley->smile); |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5657 | #endif |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5658 | } |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5659 | |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5660 | static void gtk_custom_smiley_closed(GdkPixbufLoader *loader, gpointer user_data) |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5661 | { |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5662 | GtkIMHtmlSmiley *smiley; |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5663 | GtkWidget *icon = NULL; |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5664 | GtkTextChildAnchor *anchor = NULL; |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5665 | GSList *current = NULL; |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5666 | |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5667 | smiley = (GtkIMHtmlSmiley *)user_data; |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5668 | if (!smiley->imhtml) { |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5669 | #ifdef DEBUG_CUSTOM_SMILEY |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5670 | purple_debug_error("custom-smiley", "gtk_custom_smiley_closed(): orphan smiley found: %p\n", smiley); |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5671 | #endif |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5672 | g_object_unref(G_OBJECT(loader)); |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5673 | smiley->loader = NULL; |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5674 | return; |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5675 | } |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5676 | |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5677 | for (current = smiley->anchors; current; current = g_slist_next(current)) { |
|
23398
4de581ccaf1e
Do not try to update received custom smileys in a deleted child anchor.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23377
diff
changeset
|
5678 | anchor = GTK_TEXT_CHILD_ANCHOR(current->data); |
|
4de581ccaf1e
Do not try to update received custom smileys in a deleted child anchor.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23377
diff
changeset
|
5679 | if (gtk_text_child_anchor_get_deleted(anchor)) |
|
4de581ccaf1e
Do not try to update received custom smileys in a deleted child anchor.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23377
diff
changeset
|
5680 | icon = NULL; |
|
4de581ccaf1e
Do not try to update received custom smileys in a deleted child anchor.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23377
diff
changeset
|
5681 | else |
|
4de581ccaf1e
Do not try to update received custom smileys in a deleted child anchor.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23377
diff
changeset
|
5682 | icon = gtk_image_new_from_animation(smiley->icon); |
|
22655
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5683 | |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5684 | #ifdef DEBUG_CUSTOM_SMILEY |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5685 | purple_debug_info("custom-smiley", "gtk_custom_smiley_closed(): got GtkImage %p from GtkPixbufAnimation %p for smiley '%s'\n", |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5686 | icon, smiley->icon, smiley->smile); |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5687 | #endif |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5688 | if (icon) { |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5689 | GList *wids; |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5690 | gtk_widget_show(icon); |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5691 | |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5692 | wids = gtk_text_child_anchor_get_widgets(anchor); |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5693 | |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5694 | g_object_set_data_full(G_OBJECT(anchor), "gtkimhtml_plaintext", purple_unescape_html(smiley->smile), g_free); |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5695 | g_object_set_data_full(G_OBJECT(anchor), "gtkimhtml_htmltext", g_strdup(smiley->smile), g_free); |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5696 | |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5697 | if (smiley->imhtml) { |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5698 | if (wids) { |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5699 | GList *children = gtk_container_get_children(GTK_CONTAINER(wids->data)); |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5700 | g_list_foreach(children, (GFunc)gtk_widget_destroy, NULL); |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5701 | g_list_free(children); |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5702 | gtk_container_add(GTK_CONTAINER(wids->data), icon); |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5703 | } else |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5704 | gtk_text_view_add_child_at_anchor(GTK_TEXT_VIEW(smiley->imhtml), icon, anchor); |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5705 | } |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5706 | g_list_free(wids); |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5707 | } |
|
23398
4de581ccaf1e
Do not try to update received custom smileys in a deleted child anchor.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23377
diff
changeset
|
5708 | g_object_unref(anchor); |
|
22655
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5709 | } |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5710 | |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5711 | g_slist_free(smiley->anchors); |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5712 | smiley->anchors = NULL; |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5713 | |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5714 | g_object_unref(G_OBJECT(loader)); |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5715 | smiley->loader = NULL; |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5716 | } |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5717 | |
|
23018
39c5be5ca1e9
Patch from Masca to restrict the size of incoming custom smileys to a
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23010
diff
changeset
|
5718 | static void |
|
39c5be5ca1e9
Patch from Masca to restrict the size of incoming custom smileys to a
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23010
diff
changeset
|
5719 | gtk_custom_smiley_size_prepared(GdkPixbufLoader *loader, gint width, gint height, gpointer data) |
|
39c5be5ca1e9
Patch from Masca to restrict the size of incoming custom smileys to a
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23010
diff
changeset
|
5720 | { |
|
39c5be5ca1e9
Patch from Masca to restrict the size of incoming custom smileys to a
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23010
diff
changeset
|
5721 | #define CUSTOM_SMILEY_SIZE 96 /* XXX: Should this be a theme setting? */ |
|
39c5be5ca1e9
Patch from Masca to restrict the size of incoming custom smileys to a
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23010
diff
changeset
|
5722 | if (width <= CUSTOM_SMILEY_SIZE && height <= CUSTOM_SMILEY_SIZE) |
|
39c5be5ca1e9
Patch from Masca to restrict the size of incoming custom smileys to a
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23010
diff
changeset
|
5723 | return; |
|
39c5be5ca1e9
Patch from Masca to restrict the size of incoming custom smileys to a
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23010
diff
changeset
|
5724 | |
|
39c5be5ca1e9
Patch from Masca to restrict the size of incoming custom smileys to a
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23010
diff
changeset
|
5725 | if (width >= height) { |
|
39c5be5ca1e9
Patch from Masca to restrict the size of incoming custom smileys to a
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23010
diff
changeset
|
5726 | height = height * CUSTOM_SMILEY_SIZE / width; |
|
39c5be5ca1e9
Patch from Masca to restrict the size of incoming custom smileys to a
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23010
diff
changeset
|
5727 | width = CUSTOM_SMILEY_SIZE; |
|
39c5be5ca1e9
Patch from Masca to restrict the size of incoming custom smileys to a
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23010
diff
changeset
|
5728 | } else { |
|
39c5be5ca1e9
Patch from Masca to restrict the size of incoming custom smileys to a
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23010
diff
changeset
|
5729 | width = width * CUSTOM_SMILEY_SIZE / height; |
|
39c5be5ca1e9
Patch from Masca to restrict the size of incoming custom smileys to a
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23010
diff
changeset
|
5730 | height = CUSTOM_SMILEY_SIZE; |
|
39c5be5ca1e9
Patch from Masca to restrict the size of incoming custom smileys to a
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23010
diff
changeset
|
5731 | } |
|
39c5be5ca1e9
Patch from Masca to restrict the size of incoming custom smileys to a
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23010
diff
changeset
|
5732 | |
|
39c5be5ca1e9
Patch from Masca to restrict the size of incoming custom smileys to a
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23010
diff
changeset
|
5733 | gdk_pixbuf_loader_set_size(loader, width, height); |
|
39c5be5ca1e9
Patch from Masca to restrict the size of incoming custom smileys to a
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23010
diff
changeset
|
5734 | } |
|
39c5be5ca1e9
Patch from Masca to restrict the size of incoming custom smileys to a
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23010
diff
changeset
|
5735 | |
|
22655
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5736 | void |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5737 | gtk_imhtml_smiley_reload(GtkIMHtmlSmiley *smiley) |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5738 | { |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5739 | if (smiley->icon) |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5740 | g_object_unref(smiley->icon); |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5741 | if (smiley->loader) |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5742 | g_object_unref(smiley->loader); /* XXX: does this crash? */ |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5743 | |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5744 | smiley->icon = NULL; |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5745 | smiley->loader = NULL; |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5746 | |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5747 | if (smiley->file) { |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5748 | /* We do not use the pixbuf loader for a smiley that can be loaded |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5749 | * from a file. (e.g., local custom smileys) |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5750 | */ |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5751 | return; |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5752 | } |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5753 | |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5754 | smiley->loader = gdk_pixbuf_loader_new(); |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5755 | |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5756 | g_signal_connect(smiley->loader, "area_prepared", G_CALLBACK(gtk_custom_smiley_allocated), smiley); |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5757 | g_signal_connect(smiley->loader, "closed", G_CALLBACK(gtk_custom_smiley_closed), smiley); |
|
23018
39c5be5ca1e9
Patch from Masca to restrict the size of incoming custom smileys to a
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
23010
diff
changeset
|
5758 | g_signal_connect(smiley->loader, "size_prepared", G_CALLBACK(gtk_custom_smiley_size_prepared), smiley); |
|
22655
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5759 | } |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5760 | |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5761 | GtkIMHtmlSmiley *gtk_imhtml_smiley_create(const char *file, const char *shortcut, gboolean hide, |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5762 | GtkIMHtmlSmileyFlags flags) |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5763 | { |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5764 | GtkIMHtmlSmiley *smiley = g_new0(GtkIMHtmlSmiley, 1); |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5765 | smiley->file = g_strdup(file); |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5766 | smiley->smile = g_strdup(shortcut); |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5767 | smiley->hidden = hide; |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5768 | smiley->flags = flags; |
|
24392
51b7f65a712d
Clean up the GtkSmileyTrees on active GtkIMHtml instances when a custom smiley
Marcus Lundblad <malu@pidgin.im>
parents:
24328
diff
changeset
|
5769 | smiley->imhtml = NULL; |
|
22655
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5770 | gtk_imhtml_smiley_reload(smiley); |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5771 | return smiley; |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5772 | } |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5773 | |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5774 | void gtk_imhtml_smiley_destroy(GtkIMHtmlSmiley *smiley) |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5775 | { |
|
24392
51b7f65a712d
Clean up the GtkSmileyTrees on active GtkIMHtml instances when a custom smiley
Marcus Lundblad <malu@pidgin.im>
parents:
24328
diff
changeset
|
5776 | gtk_imhtml_disassociate_smiley(smiley); |
|
22655
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5777 | g_free(smiley->smile); |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5778 | g_free(smiley->file); |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5779 | if (smiley->icon) |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5780 | g_object_unref(smiley->icon); |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5781 | if (smiley->loader) |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5782 | g_object_unref(smiley->loader); |
|
27123
90abaa4562b3
Save raw-data for an image when possible.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27122
diff
changeset
|
5783 | g_free(smiley->data); |
|
22655
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5784 | g_free(smiley); |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5785 | } |
|
718f1149a81c
Introduce API for GtkIMHtmlSmiley. Use this to prevent leaking remote custom emoticons.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
22532
diff
changeset
|
5786 | |
|
24674
36bf974a7d78
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24588
diff
changeset
|
5787 | gboolean gtk_imhtml_class_register_protocol(const char *name, |
|
24698
f9dd7117ade0
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24675
diff
changeset
|
5788 | gboolean (*activate)(GtkIMHtml *imhtml, GtkIMHtmlLink *link), |
|
f9dd7117ade0
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24675
diff
changeset
|
5789 | gboolean (*context_menu)(GtkIMHtml *imhtml, GtkIMHtmlLink *link, GtkWidget *menu)) |
|
24674
36bf974a7d78
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24588
diff
changeset
|
5790 | { |
|
36bf974a7d78
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24588
diff
changeset
|
5791 | GtkIMHtmlClass *klass; |
|
36bf974a7d78
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24588
diff
changeset
|
5792 | GtkIMHtmlProtocol *proto; |
|
36bf974a7d78
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24588
diff
changeset
|
5793 | |
|
36bf974a7d78
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24588
diff
changeset
|
5794 | g_return_val_if_fail(name, FALSE); |
|
36bf974a7d78
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24588
diff
changeset
|
5795 | |
|
36bf974a7d78
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24588
diff
changeset
|
5796 | klass = g_type_class_ref(GTK_TYPE_IMHTML); |
|
36bf974a7d78
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24588
diff
changeset
|
5797 | g_return_val_if_fail(klass, FALSE); |
|
36bf974a7d78
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24588
diff
changeset
|
5798 | |
|
25013
956b2f650d31
Detect duplication registrations by substring.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
25011
diff
changeset
|
5799 | if ((proto = imhtml_find_protocol(name, TRUE))) { |
|
25014
5bf71146f93e
Replace the URL registration assertions with regular checks.
Richard Laager <rlaager@pidgin.im>
parents:
25013
diff
changeset
|
5800 | if (activate) { |
|
5bf71146f93e
Replace the URL registration assertions with regular checks.
Richard Laager <rlaager@pidgin.im>
parents:
25013
diff
changeset
|
5801 | return FALSE; |
|
5bf71146f93e
Replace the URL registration assertions with regular checks.
Richard Laager <rlaager@pidgin.im>
parents:
25013
diff
changeset
|
5802 | } |
|
28077
c2b493e058f1
Don't use pointers (even opaquely) once they're freed. Closes #9822.
Paul Aurich <darkrain42@pidgin.im>
parents:
27525
diff
changeset
|
5803 | klass->protocols = g_list_remove(klass->protocols, proto); |
|
24674
36bf974a7d78
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24588
diff
changeset
|
5804 | g_free(proto->name); |
|
36bf974a7d78
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24588
diff
changeset
|
5805 | g_free(proto); |
|
36bf974a7d78
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24588
diff
changeset
|
5806 | return TRUE; |
|
25014
5bf71146f93e
Replace the URL registration assertions with regular checks.
Richard Laager <rlaager@pidgin.im>
parents:
25013
diff
changeset
|
5807 | } else if (!activate) { |
|
5bf71146f93e
Replace the URL registration assertions with regular checks.
Richard Laager <rlaager@pidgin.im>
parents:
25013
diff
changeset
|
5808 | return FALSE; |
|
24674
36bf974a7d78
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24588
diff
changeset
|
5809 | } |
|
36bf974a7d78
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24588
diff
changeset
|
5810 | |
|
36bf974a7d78
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24588
diff
changeset
|
5811 | proto = g_new0(GtkIMHtmlProtocol, 1); |
|
25008
f52b9372eb19
Revert the URL scheme passing changes, keeping the miscellaneous other stuff
Richard Laager <rlaager@pidgin.im>
parents:
25007
diff
changeset
|
5812 | proto->name = g_strdup(name); |
|
f52b9372eb19
Revert the URL scheme passing changes, keeping the miscellaneous other stuff
Richard Laager <rlaager@pidgin.im>
parents:
25007
diff
changeset
|
5813 | proto->length = strlen(name); |
|
24674
36bf974a7d78
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24588
diff
changeset
|
5814 | proto->activate = activate; |
|
36bf974a7d78
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24588
diff
changeset
|
5815 | proto->context_menu = context_menu; |
|
36bf974a7d78
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24588
diff
changeset
|
5816 | klass->protocols = g_list_prepend(klass->protocols, proto); |
|
36bf974a7d78
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24588
diff
changeset
|
5817 | |
|
36bf974a7d78
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24588
diff
changeset
|
5818 | return TRUE; |
|
36bf974a7d78
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24588
diff
changeset
|
5819 | } |
|
36bf974a7d78
Allow plugins to specify custom link types to the GtkIMHtml widget.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24588
diff
changeset
|
5820 | |
|
24698
f9dd7117ade0
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24675
diff
changeset
|
5821 | static void |
|
f9dd7117ade0
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24675
diff
changeset
|
5822 | gtk_imhtml_activate_tag(GtkIMHtml *imhtml, GtkTextTag *tag) |
|
f9dd7117ade0
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24675
diff
changeset
|
5823 | { |
|
f9dd7117ade0
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24675
diff
changeset
|
5824 | /* A link was clicked--we emit the "url_clicked" signal |
|
f9dd7117ade0
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24675
diff
changeset
|
5825 | * with the URL as the argument */ |
|
f9dd7117ade0
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24675
diff
changeset
|
5826 | g_object_ref(G_OBJECT(tag)); |
|
f9dd7117ade0
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24675
diff
changeset
|
5827 | g_signal_emit(imhtml, signals[URL_CLICKED], 0, g_object_get_data(G_OBJECT(tag), "link_url")); |
|
f9dd7117ade0
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24675
diff
changeset
|
5828 | g_object_unref(G_OBJECT(tag)); |
|
f9dd7117ade0
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24675
diff
changeset
|
5829 | g_object_set_data(G_OBJECT(tag), "visited", GINT_TO_POINTER(TRUE)); |
|
f9dd7117ade0
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24675
diff
changeset
|
5830 | gtk_imhtml_set_link_color(GTK_IMHTML(imhtml), tag); |
|
f9dd7117ade0
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24675
diff
changeset
|
5831 | } |
|
f9dd7117ade0
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24675
diff
changeset
|
5832 | |
|
f9dd7117ade0
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24675
diff
changeset
|
5833 | gboolean gtk_imhtml_link_activate(GtkIMHtmlLink *link) |
|
f9dd7117ade0
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24675
diff
changeset
|
5834 | { |
|
f9dd7117ade0
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24675
diff
changeset
|
5835 | g_return_val_if_fail(link, FALSE); |
|
f9dd7117ade0
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24675
diff
changeset
|
5836 | |
|
f9dd7117ade0
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24675
diff
changeset
|
5837 | if (link->tag) { |
|
f9dd7117ade0
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24675
diff
changeset
|
5838 | gtk_imhtml_activate_tag(link->imhtml, link->tag); |
|
f9dd7117ade0
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24675
diff
changeset
|
5839 | } else if (link->url) { |
|
f9dd7117ade0
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24675
diff
changeset
|
5840 | g_signal_emit(link->imhtml, signals[URL_CLICKED], 0, link->url); |
|
f9dd7117ade0
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24675
diff
changeset
|
5841 | } else |
|
f9dd7117ade0
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24675
diff
changeset
|
5842 | return FALSE; |
|
f9dd7117ade0
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24675
diff
changeset
|
5843 | return TRUE; |
|
f9dd7117ade0
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24675
diff
changeset
|
5844 | } |
|
f9dd7117ade0
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24675
diff
changeset
|
5845 | |
|
f9dd7117ade0
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24675
diff
changeset
|
5846 | const char *gtk_imhtml_link_get_url(GtkIMHtmlLink *link) |
|
f9dd7117ade0
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24675
diff
changeset
|
5847 | { |
|
f9dd7117ade0
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24675
diff
changeset
|
5848 | return link->url; |
|
f9dd7117ade0
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24675
diff
changeset
|
5849 | } |
|
f9dd7117ade0
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24675
diff
changeset
|
5850 | |
|
f9dd7117ade0
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24675
diff
changeset
|
5851 | const GtkTextTag * gtk_imhtml_link_get_text_tag(GtkIMHtmlLink *link) |
|
f9dd7117ade0
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24675
diff
changeset
|
5852 | { |
|
f9dd7117ade0
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24675
diff
changeset
|
5853 | return link->tag; |
|
f9dd7117ade0
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24675
diff
changeset
|
5854 | } |
|
f9dd7117ade0
Clean up some crufts. I think this is now mergeable with .next.minor.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
24675
diff
changeset
|
5855 | |
|
25900
0be61f1b3dd1
Add a GtkIMHtml function that causes the widget to actually insert a
Mark Doliner <markdoliner@pidgin.im>
parents:
25899
diff
changeset
|
5856 | static gboolean return_add_newline_cb(GtkWidget *widget, gpointer data) |
|
0be61f1b3dd1
Add a GtkIMHtml function that causes the widget to actually insert a
Mark Doliner <markdoliner@pidgin.im>
parents:
25899
diff
changeset
|
5857 | { |
|
0be61f1b3dd1
Add a GtkIMHtml function that causes the widget to actually insert a
Mark Doliner <markdoliner@pidgin.im>
parents:
25899
diff
changeset
|
5858 | GtkTextBuffer *buffer; |
|
0be61f1b3dd1
Add a GtkIMHtml function that causes the widget to actually insert a
Mark Doliner <markdoliner@pidgin.im>
parents:
25899
diff
changeset
|
5859 | GtkTextMark *mark; |
|
0be61f1b3dd1
Add a GtkIMHtml function that causes the widget to actually insert a
Mark Doliner <markdoliner@pidgin.im>
parents:
25899
diff
changeset
|
5860 | GtkTextIter iter; |
|
0be61f1b3dd1
Add a GtkIMHtml function that causes the widget to actually insert a
Mark Doliner <markdoliner@pidgin.im>
parents:
25899
diff
changeset
|
5861 | |
|
0be61f1b3dd1
Add a GtkIMHtml function that causes the widget to actually insert a
Mark Doliner <markdoliner@pidgin.im>
parents:
25899
diff
changeset
|
5862 | buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(widget)); |
|
0be61f1b3dd1
Add a GtkIMHtml function that causes the widget to actually insert a
Mark Doliner <markdoliner@pidgin.im>
parents:
25899
diff
changeset
|
5863 | |
|
0be61f1b3dd1
Add a GtkIMHtml function that causes the widget to actually insert a
Mark Doliner <markdoliner@pidgin.im>
parents:
25899
diff
changeset
|
5864 | /* Delete any currently selected text */ |
|
0be61f1b3dd1
Add a GtkIMHtml function that causes the widget to actually insert a
Mark Doliner <markdoliner@pidgin.im>
parents:
25899
diff
changeset
|
5865 | gtk_text_buffer_delete_selection(buffer, TRUE, TRUE); |
|
0be61f1b3dd1
Add a GtkIMHtml function that causes the widget to actually insert a
Mark Doliner <markdoliner@pidgin.im>
parents:
25899
diff
changeset
|
5866 | |
|
0be61f1b3dd1
Add a GtkIMHtml function that causes the widget to actually insert a
Mark Doliner <markdoliner@pidgin.im>
parents:
25899
diff
changeset
|
5867 | /* Insert a newline at the current cursor position */ |
|
0be61f1b3dd1
Add a GtkIMHtml function that causes the widget to actually insert a
Mark Doliner <markdoliner@pidgin.im>
parents:
25899
diff
changeset
|
5868 | mark = gtk_text_buffer_get_insert(buffer); |
|
0be61f1b3dd1
Add a GtkIMHtml function that causes the widget to actually insert a
Mark Doliner <markdoliner@pidgin.im>
parents:
25899
diff
changeset
|
5869 | gtk_text_buffer_get_iter_at_mark(buffer, &iter, mark); |
|
0be61f1b3dd1
Add a GtkIMHtml function that causes the widget to actually insert a
Mark Doliner <markdoliner@pidgin.im>
parents:
25899
diff
changeset
|
5870 | gtk_imhtml_insert_html_at_iter(GTK_IMHTML(widget), "\n", 0, &iter); |
|
0be61f1b3dd1
Add a GtkIMHtml function that causes the widget to actually insert a
Mark Doliner <markdoliner@pidgin.im>
parents:
25899
diff
changeset
|
5871 | |
|
0be61f1b3dd1
Add a GtkIMHtml function that causes the widget to actually insert a
Mark Doliner <markdoliner@pidgin.im>
parents:
25899
diff
changeset
|
5872 | /* |
|
0be61f1b3dd1
Add a GtkIMHtml function that causes the widget to actually insert a
Mark Doliner <markdoliner@pidgin.im>
parents:
25899
diff
changeset
|
5873 | * If we just newlined ourselves past the end of the visible area |
|
0be61f1b3dd1
Add a GtkIMHtml function that causes the widget to actually insert a
Mark Doliner <markdoliner@pidgin.im>
parents:
25899
diff
changeset
|
5874 | * then scroll down so the cursor is in view. |
|
0be61f1b3dd1
Add a GtkIMHtml function that causes the widget to actually insert a
Mark Doliner <markdoliner@pidgin.im>
parents:
25899
diff
changeset
|
5875 | */ |
|
0be61f1b3dd1
Add a GtkIMHtml function that causes the widget to actually insert a
Mark Doliner <markdoliner@pidgin.im>
parents:
25899
diff
changeset
|
5876 | gtk_text_view_scroll_to_mark(GTK_TEXT_VIEW(widget), |
|
0be61f1b3dd1
Add a GtkIMHtml function that causes the widget to actually insert a
Mark Doliner <markdoliner@pidgin.im>
parents:
25899
diff
changeset
|
5877 | gtk_text_buffer_get_insert(buffer), |
|
0be61f1b3dd1
Add a GtkIMHtml function that causes the widget to actually insert a
Mark Doliner <markdoliner@pidgin.im>
parents:
25899
diff
changeset
|
5878 | 0, FALSE, 0.0, 0.0); |
|
0be61f1b3dd1
Add a GtkIMHtml function that causes the widget to actually insert a
Mark Doliner <markdoliner@pidgin.im>
parents:
25899
diff
changeset
|
5879 | |
|
0be61f1b3dd1
Add a GtkIMHtml function that causes the widget to actually insert a
Mark Doliner <markdoliner@pidgin.im>
parents:
25899
diff
changeset
|
5880 | return TRUE; |
|
0be61f1b3dd1
Add a GtkIMHtml function that causes the widget to actually insert a
Mark Doliner <markdoliner@pidgin.im>
parents:
25899
diff
changeset
|
5881 | } |
|
0be61f1b3dd1
Add a GtkIMHtml function that causes the widget to actually insert a
Mark Doliner <markdoliner@pidgin.im>
parents:
25899
diff
changeset
|
5882 | |
|
25906
a64c9c871a23
Add a comment just noting that I think it's kind of annoying that we
Mark Doliner <markdoliner@pidgin.im>
parents:
25905
diff
changeset
|
5883 | /* |
|
a64c9c871a23
Add a comment just noting that I think it's kind of annoying that we
Mark Doliner <markdoliner@pidgin.im>
parents:
25905
diff
changeset
|
5884 | * It's kind of a pain that we need this function and the above just |
|
a64c9c871a23
Add a comment just noting that I think it's kind of annoying that we
Mark Doliner <markdoliner@pidgin.im>
parents:
25905
diff
changeset
|
5885 | * to reinstate the default GtkTextView behavior. It might be better |
|
a64c9c871a23
Add a comment just noting that I think it's kind of annoying that we
Mark Doliner <markdoliner@pidgin.im>
parents:
25905
diff
changeset
|
5886 | * if GtkIMHtml didn't intercept the enter key and just required the |
|
a64c9c871a23
Add a comment just noting that I think it's kind of annoying that we
Mark Doliner <markdoliner@pidgin.im>
parents:
25905
diff
changeset
|
5887 | * application to deal with it--it's really not much more work than it |
|
a64c9c871a23
Add a comment just noting that I think it's kind of annoying that we
Mark Doliner <markdoliner@pidgin.im>
parents:
25905
diff
changeset
|
5888 | * is to connect to the current "message_send" signal. |
|
a64c9c871a23
Add a comment just noting that I think it's kind of annoying that we
Mark Doliner <markdoliner@pidgin.im>
parents:
25905
diff
changeset
|
5889 | */ |
|
25900
0be61f1b3dd1
Add a GtkIMHtml function that causes the widget to actually insert a
Mark Doliner <markdoliner@pidgin.im>
parents:
25899
diff
changeset
|
5890 | void gtk_imhtml_set_return_inserts_newline(GtkIMHtml *imhtml) |
|
0be61f1b3dd1
Add a GtkIMHtml function that causes the widget to actually insert a
Mark Doliner <markdoliner@pidgin.im>
parents:
25899
diff
changeset
|
5891 | { |
|
0be61f1b3dd1
Add a GtkIMHtml function that causes the widget to actually insert a
Mark Doliner <markdoliner@pidgin.im>
parents:
25899
diff
changeset
|
5892 | g_signal_connect(G_OBJECT(imhtml), "message_send", |
|
0be61f1b3dd1
Add a GtkIMHtml function that causes the widget to actually insert a
Mark Doliner <markdoliner@pidgin.im>
parents:
25899
diff
changeset
|
5893 | G_CALLBACK(return_add_newline_cb), NULL); |
|
0be61f1b3dd1
Add a GtkIMHtml function that causes the widget to actually insert a
Mark Doliner <markdoliner@pidgin.im>
parents:
25899
diff
changeset
|
5894 | } |
|
27032
991e2899be82
Avoid overwriting the PRIMARY clipboard when we select-on-focus the status text for easy editing. Fixes #8781.
Daniel Atallah <datallah@pidgin.im>
parents:
27031
diff
changeset
|
5895 | |
|
991e2899be82
Avoid overwriting the PRIMARY clipboard when we select-on-focus the status text for easy editing. Fixes #8781.
Daniel Atallah <datallah@pidgin.im>
parents:
27031
diff
changeset
|
5896 | void gtk_imhtml_set_populate_primary_clipboard(GtkIMHtml *imhtml, gboolean populate) |
|
991e2899be82
Avoid overwriting the PRIMARY clipboard when we select-on-focus the status text for easy editing. Fixes #8781.
Daniel Atallah <datallah@pidgin.im>
parents:
27031
diff
changeset
|
5897 | { |
|
27114
63f35ec28622
Block/Unblock the signal handler when if it's unblocked/blocked.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27032
diff
changeset
|
5898 | gulong signal_id; |
|
63f35ec28622
Block/Unblock the signal handler when if it's unblocked/blocked.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27032
diff
changeset
|
5899 | signal_id = g_signal_handler_find(imhtml->text_buffer, |
|
63f35ec28622
Block/Unblock the signal handler when if it's unblocked/blocked.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27032
diff
changeset
|
5900 | G_SIGNAL_MATCH_FUNC | G_SIGNAL_MATCH_UNBLOCKED, 0, 0, NULL, |
|
63f35ec28622
Block/Unblock the signal handler when if it's unblocked/blocked.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27032
diff
changeset
|
5901 | mark_set_so_update_selection_cb, NULL); |
|
27032
991e2899be82
Avoid overwriting the PRIMARY clipboard when we select-on-focus the status text for easy editing. Fixes #8781.
Daniel Atallah <datallah@pidgin.im>
parents:
27031
diff
changeset
|
5902 | if (populate) { |
|
27114
63f35ec28622
Block/Unblock the signal handler when if it's unblocked/blocked.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27032
diff
changeset
|
5903 | if (!signal_id) { |
|
63f35ec28622
Block/Unblock the signal handler when if it's unblocked/blocked.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27032
diff
changeset
|
5904 | /* We didn't find an unblocked signal handler, which means there |
|
63f35ec28622
Block/Unblock the signal handler when if it's unblocked/blocked.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27032
diff
changeset
|
5905 | is a blocked handler. Now unblock it. |
|
63f35ec28622
Block/Unblock the signal handler when if it's unblocked/blocked.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27032
diff
changeset
|
5906 | This is necessary to avoid a mutex-lock when the debug message |
|
63f35ec28622
Block/Unblock the signal handler when if it's unblocked/blocked.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27032
diff
changeset
|
5907 | saying 'no handler is blocked' is printed in the debug window. |
|
63f35ec28622
Block/Unblock the signal handler when if it's unblocked/blocked.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27032
diff
changeset
|
5908 | -- sad |
|
63f35ec28622
Block/Unblock the signal handler when if it's unblocked/blocked.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27032
diff
changeset
|
5909 | */ |
|
63f35ec28622
Block/Unblock the signal handler when if it's unblocked/blocked.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27032
diff
changeset
|
5910 | g_signal_handlers_unblock_matched(imhtml->text_buffer, |
|
63f35ec28622
Block/Unblock the signal handler when if it's unblocked/blocked.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27032
diff
changeset
|
5911 | G_SIGNAL_MATCH_FUNC, 0, 0, NULL, |
|
63f35ec28622
Block/Unblock the signal handler when if it's unblocked/blocked.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27032
diff
changeset
|
5912 | mark_set_so_update_selection_cb, NULL); |
|
63f35ec28622
Block/Unblock the signal handler when if it's unblocked/blocked.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27032
diff
changeset
|
5913 | } |
|
27032
991e2899be82
Avoid overwriting the PRIMARY clipboard when we select-on-focus the status text for easy editing. Fixes #8781.
Daniel Atallah <datallah@pidgin.im>
parents:
27031
diff
changeset
|
5914 | } else { |
|
27114
63f35ec28622
Block/Unblock the signal handler when if it's unblocked/blocked.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27032
diff
changeset
|
5915 | /* Block only if we found an unblocked handler */ |
|
63f35ec28622
Block/Unblock the signal handler when if it's unblocked/blocked.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27032
diff
changeset
|
5916 | if (signal_id) |
|
63f35ec28622
Block/Unblock the signal handler when if it's unblocked/blocked.
Sadrul Habib Chowdhury <sadrul@pidgin.im>
parents:
27032
diff
changeset
|
5917 | g_signal_handler_block(imhtml->text_buffer, signal_id); |
|
27032
991e2899be82
Avoid overwriting the PRIMARY clipboard when we select-on-focus the status text for easy editing. Fixes #8781.
Daniel Atallah <datallah@pidgin.im>
parents:
27031
diff
changeset
|
5918 | } |
|
991e2899be82
Avoid overwriting the PRIMARY clipboard when we select-on-focus the status text for easy editing. Fixes #8781.
Daniel Atallah <datallah@pidgin.im>
parents:
27031
diff
changeset
|
5919 | } |