Mercurial > pidgin
annotate src/gtkconv.c @ 12598:1c122dbc8e9e
[gaim-migrate @ 14928]
Fix an assertion failure. Remove a useless cast.
committer: Tailor Script <tailor@pidgin.im>
author | Richard Laager <rlaager@wiktel.com> |
---|---|
date | Wed, 21 Dec 2005 12:22:04 +0000 |
parents | 3d34460ecfd6 |
children | e856f985a0b9 |
rev | line source |
---|---|
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
1 /** |
10297
ec140184437b
[gaim-migrate @ 11480]
Luke Schierer <lschiere@pidgin.im>
parents:
10274
diff
changeset
|
2 * @file gtkconv.c GTK+ Conversation API |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
3 * @ingroup gtkui |
4359 | 4 * |
10297
ec140184437b
[gaim-migrate @ 11480]
Luke Schierer <lschiere@pidgin.im>
parents:
10274
diff
changeset
|
5 * gaim |
ec140184437b
[gaim-migrate @ 11480]
Luke Schierer <lschiere@pidgin.im>
parents:
10274
diff
changeset
|
6 * |
8046 | 7 * Gaim is the legal property of its developers, whose names are too numerous |
8 * to list here. Please refer to the COPYRIGHT file distributed with this | |
9 * source distribution. | |
6725
e62a504c83d0
[gaim-migrate @ 7252]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
10 * |
4359 | 11 * This program is free software; you can redistribute it and/or modify |
12 * it under the terms of the GNU General Public License as published by | |
13 * the Free Software Foundation; either version 2 of the License, or | |
14 * (at your option) any later version. | |
15 * | |
16 * This program is distributed in the hope that it will be useful, | |
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
19 * GNU General Public License for more details. | |
20 * | |
21 * You should have received a copy of the GNU General Public License | |
22 * along with this program; if not, write to the Free Software | |
23 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
24 * | |
25 */ | |
9791 | 26 #include "internal.h" |
27 #include "gtkgaim.h" | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
28 |
4359 | 29 #ifndef _WIN32 |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
30 # include <X11/Xlib.h> |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
31 #endif |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
32 |
4359 | 33 #ifdef USE_GTKSPELL |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
34 # include <gtkspell/gtkspell.h> |
7538
357eb1c39b72
[gaim-migrate @ 8151]
Christian Hammond <chipx86@chipx86.com>
parents:
7476
diff
changeset
|
35 # ifdef _WIN32 |
357eb1c39b72
[gaim-migrate @ 8151]
Christian Hammond <chipx86@chipx86.com>
parents:
7476
diff
changeset
|
36 # include "wspell.h" |
357eb1c39b72
[gaim-migrate @ 8151]
Christian Hammond <chipx86@chipx86.com>
parents:
7476
diff
changeset
|
37 # endif |
4359 | 38 #endif |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
39 |
4359 | 40 #include <gdk/gdkkeysyms.h> |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
41 |
9699 | 42 #include "account.h" |
9130 | 43 #include "cmds.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
44 #include "debug.h" |
12272 | 45 #include "idle.h" |
6982 | 46 #include "imgstore.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
47 #include "log.h" |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5402
diff
changeset
|
48 #include "notify.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
49 #include "prpl.h" |
6038 | 50 #include "request.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
51 #include "util.h" |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
52 |
10297
ec140184437b
[gaim-migrate @ 11480]
Luke Schierer <lschiere@pidgin.im>
parents:
10274
diff
changeset
|
53 #include "gtkdnd-hints.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
54 #include "gtkblist.h" |
5717 | 55 #include "gtkconv.h" |
11583 | 56 #include "gtkconvwin.h" |
9709 | 57 #include "gtkdialogs.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
58 #include "gtkimhtml.h" |
8317 | 59 #include "gtkimhtmltoolbar.h" |
7431 | 60 #include "gtklog.h" |
11554
f8443218b7fe
[gaim-migrate @ 13814]
Gary Kramlich <grim@reaperworld.com>
parents:
11552
diff
changeset
|
61 #include "gtkmenutray.h" |
5907
18486c860a46
[gaim-migrate @ 6339]
Christian Hammond <chipx86@chipx86.com>
parents:
5902
diff
changeset
|
62 #include "gtkpounce.h" |
11206
86d3ce670f05
[gaim-migrate @ 13334]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11145
diff
changeset
|
63 #include "gtkprefs.h" |
6371
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6291
diff
changeset
|
64 #include "gtkprivacy.h" |
11525 | 65 #include "gtkthemes.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
66 #include "gtkutils.h" |
10297
ec140184437b
[gaim-migrate @ 11480]
Luke Schierer <lschiere@pidgin.im>
parents:
10274
diff
changeset
|
67 #include "gtkstock.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
68 |
12360
3153661f4d5c
[gaim-migrate @ 14664]
Luke Schierer <lschiere@pidgin.im>
parents:
12359
diff
changeset
|
69 #include "gtknickcolors.h" |
3153661f4d5c
[gaim-migrate @ 14664]
Luke Schierer <lschiere@pidgin.im>
parents:
12359
diff
changeset
|
70 |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
71 #define AUTO_RESPONSE "<AUTO-REPLY> : " |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
72 |
12359
cbf9f2e26916
[gaim-migrate @ 14663]
Richard Laager <rlaager@wiktel.com>
parents:
12358
diff
changeset
|
73 #define SEND_COLOR "#204a87" |
cbf9f2e26916
[gaim-migrate @ 14663]
Richard Laager <rlaager@wiktel.com>
parents:
12358
diff
changeset
|
74 #define RECV_COLOR "#cc0000" |
12356
4b8c20fcecd6
[gaim-migrate @ 14660]
Richard Laager <rlaager@wiktel.com>
parents:
12354
diff
changeset
|
75 #define HIGHLIGHT_COLOR "#AF7F00" |
7854 | 76 |
12335 | 77 /* Undef this to turn off "custom-smiley" debug messages */ |
78 #define DEBUG_CUSTOM_SMILEY | |
79 | |
10108 | 80 #define LUMINANCE(c) (float)((0.3*(c.red))+(0.59*(c.green))+(0.11*(c.blue))) |
81 | |
12345
f6fa5d742c76
[gaim-migrate @ 14649]
Luke Schierer <lschiere@pidgin.im>
parents:
12335
diff
changeset
|
82 #if 0 |
10108 | 83 /* These colors come from the default GNOME palette */ |
84 static GdkColor nick_colors[] = { | |
10117
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
85 {0, 47616, 46336, 43776}, /* Basic 3D Medium */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
86 {0, 32768, 32000, 29696}, /* Basic 3D Dark */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
87 {0, 22016, 20992, 18432}, /* 3D Shadow */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
88 {0, 33536, 42496, 32512}, /* Green Medium */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
89 {0, 23808, 29952, 21760}, /* Green Dark */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
90 {0, 17408, 22016, 12800}, /* Green Shadow */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
91 {0, 57344, 46592, 44800}, /* Red Hilight */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
92 {0, 49408, 26112, 23040}, /* Red Medium */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
93 {0, 34816, 17920, 12544}, /* Red Dark */ |
10812
d087e928ffd1
[gaim-migrate @ 12465]
Luke Schierer <lschiere@pidgin.im>
parents:
10810
diff
changeset
|
94 {0, 49408, 14336, 8704}, /* Red Shadow */ |
10117
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
95 {0, 34816, 32512, 41728}, /* Purple Medium */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
96 {0, 25088, 23296, 33024}, /* Purple Dark */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
97 {0, 18688, 16384, 26112}, /* Purple Shadow */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
98 {0, 40192, 47104, 53760}, /* Blue Hilight */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
99 {0, 29952, 36864, 44544}, /* Blue Medium */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
100 {0, 57344, 49920, 40448}, /* Face Skin Medium */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
101 {0, 45824, 37120, 26880}, /* Face skin Dark */ |
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
102 {0, 33280, 26112, 18176}, /* Face Skin Shadow */ |
10812
d087e928ffd1
[gaim-migrate @ 12465]
Luke Schierer <lschiere@pidgin.im>
parents:
10810
diff
changeset
|
103 {0, 57088, 16896, 7680}, /* Accent Red */ |
d087e928ffd1
[gaim-migrate @ 12465]
Luke Schierer <lschiere@pidgin.im>
parents:
10810
diff
changeset
|
104 {0, 39168, 0, 0}, /* Accent Red Dark */ |
10117
d520ab74fe8f
[gaim-migrate @ 11154]
Luke Schierer <lschiere@pidgin.im>
parents:
10116
diff
changeset
|
105 {0, 17920, 40960, 17920}, /* Accent Green */ |
10812
d087e928ffd1
[gaim-migrate @ 12465]
Luke Schierer <lschiere@pidgin.im>
parents:
10810
diff
changeset
|
106 {0, 9728, 50944, 9728} /* Accent Green Dark */ |
4359 | 107 }; |
6291 | 108 |
4359 | 109 #define NUM_NICK_COLORS (sizeof(nick_colors) / sizeof(*nick_colors)) |
12345
f6fa5d742c76
[gaim-migrate @ 14649]
Luke Schierer <lschiere@pidgin.im>
parents:
12335
diff
changeset
|
110 #endif |
f6fa5d742c76
[gaim-migrate @ 14649]
Luke Schierer <lschiere@pidgin.im>
parents:
12335
diff
changeset
|
111 |
f6fa5d742c76
[gaim-migrate @ 14649]
Luke Schierer <lschiere@pidgin.im>
parents:
12335
diff
changeset
|
112 /* From http://www.w3.org/TR/AERT#color-contrast */ |
12354
709548d845a1
[gaim-migrate @ 14658]
Luke Schierer <lschiere@pidgin.im>
parents:
12353
diff
changeset
|
113 #define MIN_BRIGHTNESS_CONTRAST 75 |
709548d845a1
[gaim-migrate @ 14658]
Luke Schierer <lschiere@pidgin.im>
parents:
12353
diff
changeset
|
114 #define MIN_COLOR_CONTRAST 200 |
12345
f6fa5d742c76
[gaim-migrate @ 14649]
Luke Schierer <lschiere@pidgin.im>
parents:
12335
diff
changeset
|
115 |
f6fa5d742c76
[gaim-migrate @ 14649]
Luke Schierer <lschiere@pidgin.im>
parents:
12335
diff
changeset
|
116 #define NUM_NICK_COLORS 220 |
f6fa5d742c76
[gaim-migrate @ 14649]
Luke Schierer <lschiere@pidgin.im>
parents:
12335
diff
changeset
|
117 static GdkColor *nick_colors = NULL; |
4359 | 118 |
11581 | 119 typedef struct { |
4359 | 120 GtkWidget *window; |
121 | |
122 GtkWidget *entry; | |
123 GtkWidget *message; | |
124 | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
125 GaimConversation *conv; |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
126 |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
127 } InviteBuddyInfo; |
4359 | 128 |
129 static GtkWidget *invite_dialog = NULL; | |
11206
86d3ce670f05
[gaim-migrate @ 13334]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11145
diff
changeset
|
130 static GtkWidget *warn_close_dialog = NULL; |
4359 | 131 |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
132 static GaimGtkWindow *hidden_convwin = NULL; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
133 static GList *window_list = NULL; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
134 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
135 |
11594 | 136 static gboolean update_send_to_selection(GaimGtkWindow *win); |
137 static void generate_send_to_items(GaimGtkWindow *win); | |
11581 | 138 |
4359 | 139 /* Prototypes. <-- because Paco-Paco hates this comment. */ |
10810 | 140 static void got_typing_keypress(GaimGtkConversation *gtkconv, gboolean first); |
11604 | 141 static void gray_stuff_out(GaimGtkConversation *gtkconv); |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
142 static GList *generate_invite_user_names(GaimConnection *gc); |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
143 static void add_chat_buddy_common(GaimConversation *conv, const char *name, |
11869 | 144 GaimConvChatBuddyFlags flags, const char *alias, const char *old_name); |
9605 | 145 static gboolean tab_complete(GaimConversation *conv); |
11604 | 146 static void gaim_gtkconv_updated(GaimConversation *conv, GaimConvUpdateType type); |
11613 | 147 static void gtkconv_set_unseen(GaimGtkConversation *gtkconv, GaimUnseenState state); |
10810 | 148 static void update_typing_icon(GaimGtkConversation *gtkconv); |
4602
4128761bacb8
[gaim-migrate @ 4889]
Christian Hammond <chipx86@chipx86.com>
parents:
4598
diff
changeset
|
149 static char *item_factory_translate_func (const char *path, gpointer func_data); |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
150 gboolean gaim_gtkconv_has_focus(GaimConversation *conv); |
12335 | 151 static void gaim_gtkconv_custom_smiley_allocated(GdkPixbufLoader *loader, gpointer user_data); |
152 static void gaim_gtkconv_custom_smiley_closed(GdkPixbufLoader *loader, gpointer user_data); | |
12351
af152afe7bac
[gaim-migrate @ 14655]
Richard Laager <rlaager@wiktel.com>
parents:
12346
diff
changeset
|
153 static GdkColor* generate_nick_colors(guint numcolors, GdkColor background); |
12356
4b8c20fcecd6
[gaim-migrate @ 14660]
Richard Laager <rlaager@wiktel.com>
parents:
12354
diff
changeset
|
154 static gboolean color_is_visible(GdkColor foreground, GdkColor background, int color_contrast, int brightness_contrast); |
4359 | 155 |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
156 static GdkColor *get_nick_color(GaimGtkConversation *gtkconv, const char *name) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
157 static GdkColor col; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
158 GtkStyle *style = gtk_widget_get_style(gtkconv->imhtml); |
11480
e9251afae7b8
[gaim-migrate @ 13722]
Richard Laager <rlaager@wiktel.com>
parents:
11479
diff
changeset
|
159 float scale; |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
160 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
161 col = nick_colors[g_str_hash(name) % NUM_NICK_COLORS]; |
11480
e9251afae7b8
[gaim-migrate @ 13722]
Richard Laager <rlaager@wiktel.com>
parents:
11479
diff
changeset
|
162 scale = ((1-(LUMINANCE(style->base[GTK_STATE_NORMAL]) / LUMINANCE(style->white))) * |
e9251afae7b8
[gaim-migrate @ 13722]
Richard Laager <rlaager@wiktel.com>
parents:
11479
diff
changeset
|
163 (LUMINANCE(style->white)/MAX(MAX(col.red, col.blue), col.green))); |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
164 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
165 /* The colors are chosen to look fine on white; we should never have to darken */ |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
166 if (scale > 1) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
167 col.red *= scale; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
168 col.green *= scale; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
169 col.blue *= scale; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
170 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
171 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
172 return &col; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
173 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
174 |
4359 | 175 /************************************************************************** |
176 * Callbacks | |
177 **************************************************************************/ | |
10971 | 178 |
4359 | 179 static gint |
10810 | 180 close_conv_cb(GtkWidget *w, GaimGtkConversation *gtkconv) |
4359 | 181 { |
10810 | 182 GList *list = g_list_copy(gtkconv->convs), *l; |
11508 | 183 |
10810 | 184 l = list; |
185 while (l) { | |
186 GaimConversation *conv = l->data; | |
187 gaim_conversation_destroy(conv); | |
188 l = l->next; | |
189 } | |
11508 | 190 |
10810 | 191 g_list_free(list); |
11508 | 192 |
4361
25d5b2a7545f
[gaim-migrate @ 4627]
Christian Hammond <chipx86@chipx86.com>
parents:
4360
diff
changeset
|
193 return TRUE; |
4359 | 194 } |
195 | |
8914 | 196 static gboolean |
10810 | 197 size_allocate_cb(GtkWidget *w, GtkAllocation *allocation, GaimGtkConversation *gtkconv) |
8914 | 198 { |
10810 | 199 GaimConversation *conv = gtkconv->active_conv; |
11508 | 200 |
8914 | 201 if (!GTK_WIDGET_VISIBLE(w)) |
202 return FALSE; | |
203 | |
204 if (!GAIM_IS_GTK_CONVERSATION(conv)) | |
205 return FALSE; | |
206 | |
11620
fbc4eeab2227
[gaim-migrate @ 13894]
Luke Schierer <lschiere@pidgin.im>
parents:
11619
diff
changeset
|
207 /* I find that I resize the window when it has a bunch of conversations in it, mostly so that the |
fbc4eeab2227
[gaim-migrate @ 13894]
Luke Schierer <lschiere@pidgin.im>
parents:
11619
diff
changeset
|
208 * tab bar will fit, but then I don't want new windows taking up the entire screen. I check to see |
fbc4eeab2227
[gaim-migrate @ 13894]
Luke Schierer <lschiere@pidgin.im>
parents:
11619
diff
changeset
|
209 * if there is only one conversation in the window. This way we'll be setting new windows to the |
fbc4eeab2227
[gaim-migrate @ 13894]
Luke Schierer <lschiere@pidgin.im>
parents:
11619
diff
changeset
|
210 * size of the last resized new window. */ |
fbc4eeab2227
[gaim-migrate @ 13894]
Luke Schierer <lschiere@pidgin.im>
parents:
11619
diff
changeset
|
211 /* I think that the above justification is not the majority, and that the new tab resizing should |
fbc4eeab2227
[gaim-migrate @ 13894]
Luke Schierer <lschiere@pidgin.im>
parents:
11619
diff
changeset
|
212 * negate it anyway. --luke */ |
11338 | 213 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
8914 | 214 { |
11453
d446fcc2c63b
[gaim-migrate @ 13692]
Luke Schierer <lschiere@pidgin.im>
parents:
11452
diff
changeset
|
215 if (w == gtkconv->imhtml) { |
d446fcc2c63b
[gaim-migrate @ 13692]
Luke Schierer <lschiere@pidgin.im>
parents:
11452
diff
changeset
|
216 gaim_prefs_set_int("/gaim/gtk/conversations/im/default_width", allocation->width); |
d446fcc2c63b
[gaim-migrate @ 13692]
Luke Schierer <lschiere@pidgin.im>
parents:
11452
diff
changeset
|
217 gaim_prefs_set_int("/gaim/gtk/conversations/im/default_height", allocation->height); |
d446fcc2c63b
[gaim-migrate @ 13692]
Luke Schierer <lschiere@pidgin.im>
parents:
11452
diff
changeset
|
218 } |
8914 | 219 if (w == gtkconv->entry) |
220 gaim_prefs_set_int("/gaim/gtk/conversations/im/entry_height", allocation->height); | |
221 } | |
11338 | 222 else if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) |
8914 | 223 { |
11453
d446fcc2c63b
[gaim-migrate @ 13692]
Luke Schierer <lschiere@pidgin.im>
parents:
11452
diff
changeset
|
224 if (w == gtkconv->imhtml) { |
d446fcc2c63b
[gaim-migrate @ 13692]
Luke Schierer <lschiere@pidgin.im>
parents:
11452
diff
changeset
|
225 gaim_prefs_set_int("/gaim/gtk/conversations/chat/default_width", allocation->width); |
d446fcc2c63b
[gaim-migrate @ 13692]
Luke Schierer <lschiere@pidgin.im>
parents:
11452
diff
changeset
|
226 gaim_prefs_set_int("/gaim/gtk/conversations/chat/default_height", allocation->height); |
d446fcc2c63b
[gaim-migrate @ 13692]
Luke Schierer <lschiere@pidgin.im>
parents:
11452
diff
changeset
|
227 } |
8914 | 228 if (w == gtkconv->entry) |
229 gaim_prefs_set_int("/gaim/gtk/conversations/chat/entry_height", allocation->height); | |
230 } | |
231 | |
232 return FALSE; | |
233 } | |
234 | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
235 static void |
10810 | 236 default_formatize(GaimGtkConversation *c) |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
237 { |
10810 | 238 GaimConversation *conv = c->active_conv; |
11508 | 239 |
10665 | 240 if (conv->features & GAIM_CONNECTION_HTML) |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
241 { |
11267
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
242 char *color; |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
243 GdkColor fg_color, bg_color; |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
244 |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
245 if (gaim_prefs_get_bool("/gaim/gtk/conversations/send_bold") != GTK_IMHTML(c->entry)->edit.bold) |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
246 gtk_imhtml_toggle_bold(GTK_IMHTML(c->entry)); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
247 |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
248 if (gaim_prefs_get_bool("/gaim/gtk/conversations/send_italic") != GTK_IMHTML(c->entry)->edit.italic) |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
249 gtk_imhtml_toggle_italic(GTK_IMHTML(c->entry)); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
250 |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
251 if (gaim_prefs_get_bool("/gaim/gtk/conversations/send_underline") != GTK_IMHTML(c->entry)->edit.underline) |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
252 gtk_imhtml_toggle_underline(GTK_IMHTML(c->entry)); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
253 |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
254 gtk_imhtml_toggle_fontface(GTK_IMHTML(c->entry), |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
255 gaim_prefs_get_string("/gaim/gtk/conversations/font_face")); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
256 |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
257 if (!(conv->features & GAIM_CONNECTION_NO_FONTSIZE)) |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
258 gtk_imhtml_font_set_size(GTK_IMHTML(c->entry), |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
259 gaim_prefs_get_int("/gaim/gtk/conversations/font_size")); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
260 |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
261 if(strcmp(gaim_prefs_get_string("/gaim/gtk/conversations/fgcolor"), "") != 0) |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
262 { |
11267
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
263 gdk_color_parse(gaim_prefs_get_string("/gaim/gtk/conversations/fgcolor"), |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
264 &fg_color); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
265 color = g_strdup_printf("#%02x%02x%02x", |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
266 fg_color.red / 256, |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
267 fg_color.green / 256, |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
268 fg_color.blue / 256); |
8061 | 269 } |
11267
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
270 else |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
271 color = g_strdup(""); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
272 |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
273 gtk_imhtml_toggle_forecolor(GTK_IMHTML(c->entry), color); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
274 g_free(color); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
275 |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
276 if(!(conv->features & GAIM_CONNECTION_NO_BGCOLOR) && |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
277 strcmp(gaim_prefs_get_string("/gaim/gtk/conversations/bgcolor"), "") != 0) |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
278 { |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
279 gdk_color_parse(gaim_prefs_get_string("/gaim/gtk/conversations/bgcolor"), |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
280 &bg_color); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
281 color = g_strdup_printf("#%02x%02x%02x", |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
282 bg_color.red / 256, |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
283 bg_color.green / 256, |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
284 bg_color.blue / 256); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
285 } |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
286 else |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
287 color = g_strdup(""); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
288 |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
289 gtk_imhtml_toggle_background(GTK_IMHTML(c->entry), color); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
290 g_free(color); |
8677 | 291 |
9025 | 292 |
10665 | 293 if (conv->features & GAIM_CONNECTION_FORMATTING_WBFO) |
8677 | 294 gtk_imhtml_set_whole_buffer_formatting_only(GTK_IMHTML(c->entry), TRUE); |
295 else | |
296 gtk_imhtml_set_whole_buffer_formatting_only(GTK_IMHTML(c->entry), FALSE); | |
8061 | 297 } |
298 } | |
9130 | 299 |
11275
ffc86d9ad8b7
[gaim-migrate @ 13461]
Richard Laager <rlaager@wiktel.com>
parents:
11269
diff
changeset
|
300 static void |
ffc86d9ad8b7
[gaim-migrate @ 13461]
Richard Laager <rlaager@wiktel.com>
parents:
11269
diff
changeset
|
301 clear_formatting_cb(GtkIMHtml *imhtml, GaimGtkConversation *gtkconv) |
ffc86d9ad8b7
[gaim-migrate @ 13461]
Richard Laager <rlaager@wiktel.com>
parents:
11269
diff
changeset
|
302 { |
ffc86d9ad8b7
[gaim-migrate @ 13461]
Richard Laager <rlaager@wiktel.com>
parents:
11269
diff
changeset
|
303 default_formatize(gtkconv); |
ffc86d9ad8b7
[gaim-migrate @ 13461]
Richard Laager <rlaager@wiktel.com>
parents:
11269
diff
changeset
|
304 } |
ffc86d9ad8b7
[gaim-migrate @ 13461]
Richard Laager <rlaager@wiktel.com>
parents:
11269
diff
changeset
|
305 |
9130 | 306 static const char * |
307 gaim_gtk_get_cmd_prefix(void) | |
308 { | |
309 return "/"; | |
310 } | |
311 | |
9167 | 312 static GaimCmdRet |
9829 | 313 say_command_cb(GaimConversation *conv, |
314 const char *cmd, char **args, char **error, void *data) | |
315 { | |
11338 | 316 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
9829 | 317 gaim_conv_im_send(GAIM_CONV_IM(conv), args[0]); |
11338 | 318 else if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) |
9829 | 319 gaim_conv_chat_send(GAIM_CONV_CHAT(conv), args[0]); |
320 | |
321 return GAIM_CMD_RET_OK; | |
322 } | |
323 | |
324 static GaimCmdRet | |
9167 | 325 me_command_cb(GaimConversation *conv, |
9597 | 326 const char *cmd, char **args, char **error, void *data) |
9167 | 327 { |
328 char *tmp; | |
329 | |
330 tmp = g_strdup_printf("/me %s", args[0]); | |
9175 | 331 |
11338 | 332 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
9167 | 333 gaim_conv_im_send(GAIM_CONV_IM(conv), tmp); |
11338 | 334 else if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) |
9167 | 335 gaim_conv_chat_send(GAIM_CONV_CHAT(conv), tmp); |
336 | |
337 g_free(tmp); | |
338 return GAIM_CMD_RET_OK; | |
339 } | |
340 | |
9212 | 341 static GaimCmdRet |
342 debug_command_cb(GaimConversation *conv, | |
9597 | 343 const char *cmd, char **args, char **error, void *data) |
9212 | 344 { |
345 char *tmp, *markup; | |
346 GaimCmdStatus status; | |
347 | |
348 if (!g_ascii_strcasecmp(args[0], "version")) { | |
349 tmp = g_strdup_printf(_("me is using Gaim v%s."), VERSION); | |
10732
c4cb90065e1d
[gaim-migrate @ 12334]
Luke Schierer <lschiere@pidgin.im>
parents:
10698
diff
changeset
|
350 markup = g_markup_escape_text(tmp, -1); |
9212 | 351 |
352 status = gaim_cmd_do_command(conv, tmp, markup, error); | |
353 | |
354 g_free(tmp); | |
355 g_free(markup); | |
356 return status; | |
357 } else { | |
358 gaim_conversation_write(conv, NULL, _("Supported debug options are: version"), | |
359 GAIM_MESSAGE_NO_LOG|GAIM_MESSAGE_ERROR, time(NULL)); | |
360 return GAIM_CMD_STATUS_OK; | |
361 } | |
362 } | |
363 | |
9213 | 364 static GaimCmdRet |
11145
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
365 clear_command_cb(GaimConversation *conv, |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
366 const char *cmd, char **args, char **error, void *data) |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
367 { |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
368 GaimGtkConversation *gtkconv = NULL; |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
369 |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
370 gtkconv = GAIM_GTK_CONVERSATION(conv); |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
371 |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
372 gtk_imhtml_clear(GTK_IMHTML(gtkconv->imhtml)); |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
373 return GAIM_CMD_STATUS_OK; |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
374 } |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
375 |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
376 static GaimCmdRet |
9213 | 377 help_command_cb(GaimConversation *conv, |
9597 | 378 const char *cmd, char **args, char **error, void *data) |
9213 | 379 { |
9597 | 380 GList *l, *text; |
9213 | 381 GString *s; |
9597 | 382 |
383 if (args[0] != NULL) { | |
384 s = g_string_new(""); | |
385 text = gaim_cmd_help(conv, args[0]); | |
386 | |
387 if (text) { | |
388 for (l = text; l; l = l->next) | |
389 if (l->next) | |
9816 | 390 g_string_append_printf(s, "%s\n", (char *)l->data); |
9597 | 391 else |
9816 | 392 g_string_append_printf(s, "%s", (char *)l->data); |
9597 | 393 } else { |
394 g_string_append(s, _("No such command (in this context).")); | |
395 } | |
396 } else { | |
397 s = g_string_new(_("Use \"/help <command>\" for help on a specific command.\n" | |
398 "The following commands are available in this context:\n")); | |
399 | |
400 text = gaim_cmd_list(conv); | |
401 for (l = text; l; l = l->next) | |
9213 | 402 if (l->next) |
9597 | 403 g_string_append_printf(s, "%s, ", (char *)l->data); |
9213 | 404 else |
9597 | 405 g_string_append_printf(s, "%s.", (char *)l->data); |
9213 | 406 } |
407 | |
408 gaim_conversation_write(conv, NULL, s->str, GAIM_MESSAGE_NO_LOG, time(NULL)); | |
409 g_string_free(s, TRUE); | |
410 | |
411 return GAIM_CMD_STATUS_OK; | |
412 } | |
413 | |
4359 | 414 static void |
9374 | 415 send_history_add(GaimConversation *conv, const char *message) |
416 { | |
417 GList *first; | |
418 | |
419 first = g_list_first(conv->send_history); | |
420 | |
421 if (first->data) | |
422 g_free(first->data); | |
423 | |
424 first->data = g_strdup(message); | |
425 | |
426 conv->send_history = g_list_prepend(first, NULL); | |
427 } | |
428 | |
9832 | 429 static gboolean |
430 check_for_and_do_command(GaimConversation *conv) | |
431 { | |
432 GaimGtkConversation *gtkconv; | |
433 char *cmd; | |
434 const char *prefix; | |
435 GaimAccount *account; | |
436 GtkTextIter start; | |
437 | |
438 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
439 account = gaim_conversation_get_account(conv); | |
440 prefix = gaim_gtk_get_cmd_prefix(); | |
441 | |
442 cmd = gtk_imhtml_get_text(GTK_IMHTML(gtkconv->entry), NULL, NULL); | |
443 gtk_text_buffer_get_start_iter(GTK_IMHTML(gtkconv->entry)->text_buffer, &start); | |
444 | |
445 if (cmd && (strncmp(cmd, prefix, strlen(prefix)) == 0) | |
446 && !gtk_text_iter_get_child_anchor(&start)) { | |
447 GaimCmdStatus status; | |
448 char *error, *cmdline, *markup, *send_history; | |
449 GtkTextIter end; | |
450 | |
451 send_history = gtk_imhtml_get_markup(GTK_IMHTML(gtkconv->entry)); | |
452 send_history_add(conv, send_history); | |
453 g_free(send_history); | |
454 | |
455 cmdline = cmd + strlen(prefix); | |
456 | |
457 gtk_text_iter_forward_chars(&start, g_utf8_strlen(prefix, -1)); | |
458 gtk_text_buffer_get_end_iter(GTK_IMHTML(gtkconv->entry)->text_buffer, &end); | |
459 markup = gtk_imhtml_get_markup_range(GTK_IMHTML(gtkconv->entry), &start, &end); | |
460 status = gaim_cmd_do_command(conv, cmdline, markup, &error); | |
461 g_free(cmd); | |
462 g_free(markup); | |
463 | |
464 switch (status) { | |
465 case GAIM_CMD_STATUS_OK: | |
466 return TRUE; | |
467 case GAIM_CMD_STATUS_NOT_FOUND: | |
468 if (!gaim_prefs_get_bool("/gaim/gtk/conversations/passthrough_unknown_commands")) { | |
469 gaim_conversation_write(conv, "", _("No such command."), | |
470 GAIM_MESSAGE_NO_LOG, time(NULL)); | |
471 | |
472 return TRUE; | |
473 } | |
474 return FALSE; | |
475 case GAIM_CMD_STATUS_WRONG_ARGS: | |
476 gaim_conversation_write(conv, "", _("Syntax Error: You typed the wrong number of arguments " | |
477 "to that command."), | |
478 GAIM_MESSAGE_NO_LOG, time(NULL)); | |
479 return TRUE; | |
480 case GAIM_CMD_STATUS_FAILED: | |
481 gaim_conversation_write(conv, "", error ? error : _("Your command failed for an unknown reason."), | |
482 GAIM_MESSAGE_NO_LOG, time(NULL)); | |
483 if(error) | |
484 g_free(error); | |
485 return TRUE; | |
486 case GAIM_CMD_STATUS_WRONG_TYPE: | |
11338 | 487 if(gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
10843 | 488 gaim_conversation_write(conv, "", _("That command only works in chats, not IMs."), |
9832 | 489 GAIM_MESSAGE_NO_LOG, time(NULL)); |
490 else | |
10843 | 491 gaim_conversation_write(conv, "", _("That command only works in IMs, not chats."), |
9832 | 492 GAIM_MESSAGE_NO_LOG, time(NULL)); |
493 return TRUE; | |
494 case GAIM_CMD_STATUS_WRONG_PRPL: | |
495 gaim_conversation_write(conv, "", _("That command doesn't work on this protocol."), | |
496 GAIM_MESSAGE_NO_LOG, time(NULL)); | |
497 return TRUE; | |
498 } | |
499 } | |
500 | |
501 g_free(cmd); | |
502 return FALSE; | |
503 } | |
504 | |
9374 | 505 static void |
10810 | 506 send_cb(GtkWidget *widget, GaimGtkConversation *gtkconv) |
4359 | 507 { |
10810 | 508 GaimConversation *conv = gtkconv->active_conv; |
8655 | 509 GaimAccount *account; |
8677 | 510 GaimConnection *gc; |
12216 | 511 GaimMessageFlags flags = 0; |
8448 | 512 char *buf, *clean; |
4359 | 513 |
8655 | 514 account = gaim_conversation_get_account(conv); |
9130 | 515 |
9471 | 516 if (!gaim_account_is_connected(account)) |
517 return; | |
518 | |
11338 | 519 if ((gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) && |
9474 | 520 gaim_conv_chat_has_left(GAIM_CONV_CHAT(conv))) |
9471 | 521 return; |
522 | |
9832 | 523 if (check_for_and_do_command(conv)) { |
524 gtk_imhtml_clear(GTK_IMHTML(gtkconv->entry)); | |
525 return; | |
9130 | 526 } |
527 | |
8442 | 528 buf = gtk_imhtml_get_markup(GTK_IMHTML(gtkconv->entry)); |
8962 | 529 clean = gtk_imhtml_get_text(GTK_IMHTML(gtkconv->entry), NULL, NULL); |
8448 | 530 |
4359 | 531 gtk_widget_grab_focus(gtkconv->entry); |
532 | |
8448 | 533 if (strlen(clean) == 0) { |
534 g_free(clean); | |
4359 | 535 return; |
536 } | |
537 | |
12272 | 538 gaim_idle_touch(); |
539 | |
12216 | 540 /* XXX: is there a better way to tell if the message has images? */ |
541 if (GTK_IMHTML(gtkconv->entry)->im_images != NULL) | |
542 flags |= GAIM_MESSAGE_IMAGES; | |
543 | |
8677 | 544 gc = gaim_account_get_connection(account); |
10665 | 545 if (gc && (conv->features & GAIM_CONNECTION_NO_NEWLINES)) { |
8677 | 546 char **bufs; |
547 int i; | |
548 | |
549 bufs = gtk_imhtml_get_markup_lines(GTK_IMHTML(gtkconv->entry)); | |
550 for (i = 0; bufs[i]; i++) { | |
9374 | 551 send_history_add(conv, bufs[i]); |
11338 | 552 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
12216 | 553 gaim_conv_im_send_with_flags(GAIM_CONV_IM(conv), bufs[i], flags); |
11338 | 554 else if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) |
12216 | 555 gaim_conv_chat_send_with_flags(GAIM_CONV_CHAT(conv), bufs[i], flags); |
8677 | 556 } |
557 | |
558 g_strfreev(bufs); | |
559 | |
560 } else { | |
9374 | 561 send_history_add(conv, buf); |
11338 | 562 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
12216 | 563 gaim_conv_im_send_with_flags(GAIM_CONV_IM(conv), buf, flags); |
11338 | 564 else if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) |
12216 | 565 gaim_conv_chat_send_with_flags(GAIM_CONV_CHAT(conv), buf, flags); |
8677 | 566 } |
4359 | 567 |
8677 | 568 g_free(clean); |
4359 | 569 g_free(buf); |
570 | |
8061 | 571 gtk_imhtml_clear(GTK_IMHTML(gtkconv->entry)); |
11613 | 572 gtkconv_set_unseen(gtkconv, GAIM_UNSEEN_NONE); |
4359 | 573 } |
574 | |
575 static void | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
576 add_remove_cb(GtkWidget *widget, GaimGtkConversation *gtkconv) |
4359 | 577 { |
7060
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
578 GaimAccount *account; |
4359 | 579 const char *name; |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
580 GaimConversation *conv = gtkconv->active_conv; |
4359 | 581 |
7060
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
582 account = gaim_conversation_get_account(conv); |
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
583 name = gaim_conversation_get_name(conv); |
7879 | 584 |
11338 | 585 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) { |
7859 | 586 GaimBuddy *b; |
587 | |
588 b = gaim_find_buddy(account, name); | |
589 if (b != NULL) | |
9730 | 590 gaim_gtkdialogs_remove_buddy(b); |
7859 | 591 else if (account != NULL && gaim_account_is_connected(account)) |
592 gaim_blist_request_add_buddy(account, (char *)name, NULL, NULL); | |
11338 | 593 } else if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) { |
7859 | 594 GaimChat *c; |
595 | |
596 c = gaim_blist_find_chat(account, name); | |
597 if (c != NULL) | |
9730 | 598 gaim_gtkdialogs_remove_chat(c); |
7859 | 599 else if (account != NULL && gaim_account_is_connected(account)) |
9754 | 600 gaim_blist_request_add_chat(account, NULL, NULL, name); |
7859 | 601 } |
4359 | 602 |
603 gtk_widget_grab_focus(GAIM_GTK_CONVERSATION(conv)->entry); | |
604 } | |
605 | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
606 static void chat_do_info(GaimGtkConversation *gtkconv, const char *who) |
7975 | 607 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
608 GaimConversation *conv = gtkconv->active_conv; |
7975 | 609 GaimPluginProtocolInfo *prpl_info = NULL; |
610 GaimConnection *gc; | |
611 | |
612 if ((gc = gaim_conversation_get_gc(conv))) { | |
613 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); | |
614 | |
615 /* | |
616 * If there are special needs for getting info on users in | |
617 * buddy chat "rooms"... | |
618 */ | |
619 if (prpl_info->get_cb_info != NULL) | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
620 { |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
621 prpl_info->get_cb_info(gc, |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
622 gaim_conv_chat_get_id(GAIM_CONV_CHAT(conv)), who); |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
623 } |
7975 | 624 else |
625 prpl_info->get_info(gc, who); | |
626 } | |
627 } | |
628 | |
629 | |
4359 | 630 static void |
10810 | 631 info_cb(GtkWidget *widget, GaimGtkConversation *gtkconv) |
4359 | 632 { |
10810 | 633 GaimConversation *conv = gtkconv->active_conv; |
4359 | 634 |
11338 | 635 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) { |
7879 | 636 serv_get_info(gaim_conversation_get_gc(conv), |
637 gaim_conversation_get_name(conv)); | |
638 | |
639 gtk_widget_grab_focus(gtkconv->entry); | |
11338 | 640 } else if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) { |
7879 | 641 /* Get info of the person currently selected in the GtkTreeView */ |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
642 GaimGtkChatPane *gtkchat; |
4359 | 643 GtkTreeIter iter; |
644 GtkTreeModel *model; | |
645 GtkTreeSelection *sel; | |
9554 | 646 char *name; |
4359 | 647 |
648 gtkchat = gtkconv->u.chat; | |
649 | |
650 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); | |
651 sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(gtkchat->list)); | |
652 | |
653 if (gtk_tree_selection_get_selected(sel, NULL, &iter)) | |
9498 | 654 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, CHAT_USERS_NAME_COLUMN, &name, -1); |
4359 | 655 else |
656 return; | |
657 | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
658 chat_do_info(gtkconv, name); |
9554 | 659 g_free(name); |
4359 | 660 } |
661 } | |
662 | |
663 static void | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
664 block_cb(GtkWidget *widget, GaimGtkConversation *gtkconv) |
4359 | 665 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
666 GaimConversation *conv = gtkconv->active_conv; |
6371
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6291
diff
changeset
|
667 GaimAccount *account; |
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6291
diff
changeset
|
668 |
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6291
diff
changeset
|
669 account = gaim_conversation_get_account(conv); |
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6291
diff
changeset
|
670 |
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6291
diff
changeset
|
671 if (account != NULL && gaim_account_is_connected(account)) |
6399
d726a36628e8
[gaim-migrate @ 6904]
Christian Hammond <chipx86@chipx86.com>
parents:
6398
diff
changeset
|
672 gaim_gtk_request_add_block(account, gaim_conversation_get_name(conv)); |
4359 | 673 |
674 gtk_widget_grab_focus(GAIM_GTK_CONVERSATION(conv)->entry); | |
675 } | |
676 | |
677 static void | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
678 do_invite(GtkWidget *w, int resp, InviteBuddyInfo *info) |
4359 | 679 { |
680 const char *buddy, *message; | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
681 GaimGtkConversation *gtkconv; |
4359 | 682 |
683 gtkconv = GAIM_GTK_CONVERSATION(info->conv); | |
684 | |
685 if (resp == GTK_RESPONSE_OK) { | |
686 buddy = gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(info->entry)->entry)); | |
687 message = gtk_entry_get_text(GTK_ENTRY(info->message)); | |
688 | |
10113 | 689 if (!g_ascii_strcasecmp(buddy, "")) |
4359 | 690 return; |
691 | |
692 serv_chat_invite(gaim_conversation_get_gc(info->conv), | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
693 gaim_conv_chat_get_id(GAIM_CONV_CHAT(info->conv)), |
4359 | 694 message, buddy); |
695 } | |
696 | |
697 gtk_widget_destroy(invite_dialog); | |
698 invite_dialog = NULL; | |
699 | |
700 g_free(info); | |
701 } | |
702 | |
703 static void | |
9909 | 704 invite_dnd_recv(GtkWidget *widget, GdkDragContext *dc, gint x, gint y, |
705 GtkSelectionData *sd, guint inf, guint t, gpointer data) | |
706 { | |
707 InviteBuddyInfo *info = (InviteBuddyInfo *)data; | |
708 const char *convprotocol; | |
709 | |
710 convprotocol = gaim_account_get_protocol_id(gaim_conversation_get_account(info->conv)); | |
711 | |
712 if (sd->target == gdk_atom_intern("GAIM_BLIST_NODE", FALSE)) | |
713 { | |
714 GaimBlistNode *node = NULL; | |
715 GaimBuddy *buddy; | |
716 | |
717 memcpy(&node, sd->data, sizeof(node)); | |
718 | |
719 if (GAIM_BLIST_NODE_IS_CONTACT(node)) | |
720 buddy = gaim_contact_get_priority_buddy((GaimContact *)node); | |
721 else if (GAIM_BLIST_NODE_IS_BUDDY(node)) | |
722 buddy = (GaimBuddy *)node; | |
723 else | |
724 return; | |
725 | |
726 if (strcmp(convprotocol, gaim_account_get_protocol_id(buddy->account))) | |
727 { | |
728 gaim_notify_error(NULL, NULL, | |
729 _("That buddy is not on the same protocol as this " | |
10843 | 730 "chat."), NULL); |
9909 | 731 } |
732 else | |
733 gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(info->entry)->entry), buddy->name); | |
734 | |
735 gtk_drag_finish(dc, TRUE, (dc->action == GDK_ACTION_MOVE), t); | |
736 } | |
737 else if (sd->target == gdk_atom_intern("application/x-im-contact", FALSE)) | |
738 { | |
739 char *protocol = NULL; | |
740 char *username = NULL; | |
741 GaimAccount *account; | |
742 | |
11137 | 743 if (gaim_gtk_parse_x_im_contact((const char *)sd->data, FALSE, &account, |
9909 | 744 &protocol, &username, NULL)) |
745 { | |
746 if (account == NULL) | |
747 { | |
748 gaim_notify_error(NULL, NULL, | |
749 _("You are not currently signed on with an account that " | |
750 "can invite that buddy."), NULL); | |
751 } | |
752 else if (strcmp(convprotocol, gaim_account_get_protocol_id(account))) | |
753 { | |
754 gaim_notify_error(NULL, NULL, | |
755 _("That buddy is not on the same protocol as this " | |
10843 | 756 "chat."), NULL); |
9909 | 757 } |
758 else | |
759 { | |
760 gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(info->entry)->entry), username); | |
761 } | |
762 } | |
763 | |
764 if (username != NULL) g_free(username); | |
765 if (protocol != NULL) g_free(protocol); | |
766 | |
767 gtk_drag_finish(dc, TRUE, (dc->action == GDK_ACTION_MOVE), t); | |
768 } | |
769 } | |
770 | |
771 static const GtkTargetEntry dnd_targets[] = | |
772 { | |
773 {"GAIM_BLIST_NODE", GTK_TARGET_SAME_APP, 0}, | |
774 {"application/x-im-contact", 0, 1} | |
775 }; | |
776 | |
777 static void | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
778 invite_cb(GtkWidget *widget, GaimGtkConversation *gtkconv) |
4359 | 779 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
780 GaimConversation *conv = gtkconv->active_conv; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
781 InviteBuddyInfo *info = NULL; |
4359 | 782 |
783 if (invite_dialog == NULL) { | |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
784 GaimConnection *gc; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
785 GaimGtkWindow *gtkwin; |
4359 | 786 GtkWidget *label; |
787 GtkWidget *vbox, *hbox; | |
788 GtkWidget *table; | |
789 GtkWidget *img; | |
790 | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
791 img = gtk_image_new_from_stock(GAIM_STOCK_DIALOG_QUESTION, |
11581 | 792 GTK_ICON_SIZE_DIALOG); |
4359 | 793 |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
794 info = g_new0(InviteBuddyInfo, 1); |
4359 | 795 info->conv = conv; |
796 | |
11581 | 797 gc = gaim_conversation_get_gc(conv); |
798 gtkwin = gaim_gtkconv_get_window(gtkconv); | |
4359 | 799 |
800 /* Create the new dialog. */ | |
801 invite_dialog = gtk_dialog_new_with_buttons( | |
7859 | 802 _("Invite Buddy Into Chat Room"), |
7879 | 803 GTK_WINDOW(gtkwin->window), 0, |
804 GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, | |
9443
3584cdab1d0b
[gaim-migrate @ 10264]
Christian Hammond <chipx86@chipx86.com>
parents:
9374
diff
changeset
|
805 GAIM_STOCK_INVITE, GTK_RESPONSE_OK, NULL); |
4359 | 806 |
807 gtk_dialog_set_default_response(GTK_DIALOG(invite_dialog), | |
11581 | 808 GTK_RESPONSE_OK); |
11243 | 809 gtk_container_set_border_width(GTK_CONTAINER(invite_dialog), GAIM_HIG_BOX_SPACE); |
4359 | 810 gtk_window_set_resizable(GTK_WINDOW(invite_dialog), FALSE); |
811 gtk_dialog_set_has_separator(GTK_DIALOG(invite_dialog), FALSE); | |
812 | |
9909 | 813 info->window = GTK_WIDGET(invite_dialog); |
814 | |
4359 | 815 /* Setup the outside spacing. */ |
816 vbox = GTK_DIALOG(invite_dialog)->vbox; | |
817 | |
11243 | 818 gtk_box_set_spacing(GTK_BOX(vbox), GAIM_HIG_BORDER); |
819 gtk_container_set_border_width(GTK_CONTAINER(vbox), GAIM_HIG_BOX_SPACE); | |
4359 | 820 |
821 /* Setup the inner hbox and put the dialog's icon in it. */ | |
11243 | 822 hbox = gtk_hbox_new(FALSE, GAIM_HIG_BORDER); |
4359 | 823 gtk_container_add(GTK_CONTAINER(vbox), hbox); |
824 gtk_box_pack_start(GTK_BOX(hbox), img, FALSE, FALSE, 0); | |
825 gtk_misc_set_alignment(GTK_MISC(img), 0, 0); | |
826 | |
827 /* Setup the right vbox. */ | |
828 vbox = gtk_vbox_new(FALSE, 0); | |
829 gtk_container_add(GTK_CONTAINER(hbox), vbox); | |
830 | |
831 /* Put our happy label in it. */ | |
832 label = gtk_label_new(_("Please enter the name of the user you wish " | |
833 "to invite, along with an optional invite " | |
834 "message.")); | |
835 gtk_widget_set_size_request(label, 350, -1); | |
836 gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); | |
837 gtk_misc_set_alignment(GTK_MISC(label), 0, 0); | |
838 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); | |
839 | |
840 /* hbox for the table, and to give it some spacing on the left. */ | |
11243 | 841 hbox = gtk_hbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
4359 | 842 gtk_container_add(GTK_CONTAINER(vbox), hbox); |
843 | |
844 /* Setup the table we're going to use to lay stuff out. */ | |
845 table = gtk_table_new(2, 2, FALSE); | |
11243 | 846 gtk_table_set_row_spacings(GTK_TABLE(table), GAIM_HIG_BOX_SPACE); |
847 gtk_table_set_col_spacings(GTK_TABLE(table), GAIM_HIG_BOX_SPACE); | |
848 gtk_container_set_border_width(GTK_CONTAINER(table), GAIM_HIG_BORDER); | |
4359 | 849 gtk_box_pack_start(GTK_BOX(vbox), table, FALSE, FALSE, 0); |
850 | |
851 /* Now the Buddy label */ | |
852 label = gtk_label_new(NULL); | |
853 gtk_label_set_markup_with_mnemonic(GTK_LABEL(label), _("_Buddy:")); | |
854 gtk_misc_set_alignment(GTK_MISC(label), 0, 0); | |
855 gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 0, 1); | |
856 | |
857 /* Now the Buddy drop-down entry field. */ | |
858 info->entry = gtk_combo_new(); | |
859 gtk_combo_set_case_sensitive(GTK_COMBO(info->entry), FALSE); | |
860 gtk_entry_set_activates_default( | |
861 GTK_ENTRY(GTK_COMBO(info->entry)->entry), TRUE); | |
862 | |
863 gtk_table_attach_defaults(GTK_TABLE(table), info->entry, 1, 2, 0, 1); | |
864 gtk_label_set_mnemonic_widget(GTK_LABEL(label), info->entry); | |
865 | |
866 /* Fill in the names. */ | |
867 gtk_combo_set_popdown_strings(GTK_COMBO(info->entry), | |
868 generate_invite_user_names(gc)); | |
869 | |
870 | |
871 /* Now the label for "Message" */ | |
872 label = gtk_label_new(NULL); | |
873 gtk_label_set_markup_with_mnemonic(GTK_LABEL(label), _("_Message:")); | |
874 gtk_misc_set_alignment(GTK_MISC(label), 0, 0); | |
875 gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 1, 2); | |
876 | |
877 | |
878 /* And finally, the Message entry field. */ | |
879 info->message = gtk_entry_new(); | |
880 gtk_entry_set_activates_default(GTK_ENTRY(info->message), TRUE); | |
881 | |
882 gtk_table_attach_defaults(GTK_TABLE(table), info->message, 1, 2, 1, 2); | |
883 gtk_label_set_mnemonic_widget(GTK_LABEL(label), info->message); | |
884 | |
885 /* Connect the signals. */ | |
886 g_signal_connect(G_OBJECT(invite_dialog), "response", | |
887 G_CALLBACK(do_invite), info); | |
9909 | 888 /* Setup drag-and-drop */ |
889 gtk_drag_dest_set(info->window, | |
890 GTK_DEST_DEFAULT_MOTION | | |
891 GTK_DEST_DEFAULT_DROP, | |
892 dnd_targets, | |
893 sizeof(dnd_targets) / sizeof(GtkTargetEntry), | |
894 GDK_ACTION_COPY); | |
895 gtk_drag_dest_set(info->entry, | |
896 GTK_DEST_DEFAULT_MOTION | | |
897 GTK_DEST_DEFAULT_DROP, | |
898 dnd_targets, | |
899 sizeof(dnd_targets) / sizeof(GtkTargetEntry), | |
900 GDK_ACTION_COPY); | |
901 | |
902 g_signal_connect(G_OBJECT(info->window), "drag_data_received", | |
903 G_CALLBACK(invite_dnd_recv), info); | |
904 g_signal_connect(G_OBJECT(info->entry), "drag_data_received", | |
905 G_CALLBACK(invite_dnd_recv), info); | |
906 | |
4359 | 907 } |
908 | |
909 gtk_widget_show_all(invite_dialog); | |
910 | |
911 if (info != NULL) | |
912 gtk_widget_grab_focus(GTK_COMBO(info->entry)->entry); | |
913 } | |
914 | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
915 static void |
7748 | 916 menu_new_conv_cb(gpointer data, guint action, GtkWidget *widget) |
917 { | |
9714 | 918 gaim_gtkdialogs_im(); |
7748 | 919 } |
920 | |
921 static void | |
9504 | 922 savelog_writefile_cb(void *user_data, const char *filename) |
9489 | 923 { |
9504 | 924 GaimConversation *conv = (GaimConversation *)user_data; |
9489 | 925 FILE *fp; |
926 const char *name; | |
10849 | 927 gchar *text; |
9489 | 928 |
10589
0f7452b1f777
[gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10572
diff
changeset
|
929 if ((fp = g_fopen(filename, "w+")) == NULL) { |
9504 | 930 gaim_notify_error(conv, NULL, _("Unable to open file."), NULL); |
9489 | 931 return; |
932 } | |
933 | |
934 name = gaim_conversation_get_name(conv); | |
10849 | 935 fprintf(fp, "<html>\n<head><title>%s</title></head>\n<body>", name); |
9489 | 936 fprintf(fp, _("<h1>Conversation with %s</h1>\n"), name); |
10849 | 937 |
938 text = gtk_imhtml_get_markup( | |
939 GTK_IMHTML(GAIM_GTK_CONVERSATION(conv)->imhtml)); | |
940 fprintf(fp, "%s", text); | |
941 g_free(text); | |
942 | |
943 fprintf(fp, "\n</body>\n</html>\n"); | |
9489 | 944 fclose(fp); |
945 } | |
946 | |
10849 | 947 /* |
948 * It would be kinda cool if this gave the option of saving a | |
949 * plaintext v. HTML file. | |
950 */ | |
9489 | 951 static void |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
952 menu_save_as_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
953 { |
11581 | 954 GaimGtkWindow *win = data; |
955 GaimConversation *conv = gaim_gtk_conv_window_get_active_conversation(win); | |
9489 | 956 gchar *buf; |
957 | |
958 buf = g_strdup_printf("%s.html", gaim_normalize(conv->account, conv->name)); | |
9504 | 959 |
10849 | 960 gaim_request_file(conv, _("Save Conversation"), gaim_escape_filename(buf), |
961 TRUE, G_CALLBACK(savelog_writefile_cb), NULL, conv); | |
9489 | 962 |
963 g_free(buf); | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
964 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
965 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
966 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
967 menu_view_log_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
968 { |
11581 | 969 GaimGtkWindow *win = data; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
970 GaimConversation *conv; |
9917 | 971 GaimLogType type; |
12232
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
972 GaimGtkBuddyList *gtkblist; |
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
973 GdkCursor *cursor; |
10809
f9e01ccd6046
[gaim-migrate @ 12461]
Luke Schierer <lschiere@pidgin.im>
parents:
10807
diff
changeset
|
974 const char *name; |
f9e01ccd6046
[gaim-migrate @ 12461]
Luke Schierer <lschiere@pidgin.im>
parents:
10807
diff
changeset
|
975 GaimAccount *account; |
12232
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
976 GSList *buddies; |
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
977 GSList *cur; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
978 |
11581 | 979 conv = gaim_gtk_conv_window_get_active_conversation(win); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
980 |
11338 | 981 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
9917 | 982 type = GAIM_LOG_IM; |
11338 | 983 else if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) |
9917 | 984 type = GAIM_LOG_CHAT; |
985 else | |
986 return; | |
987 | |
12232
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
988 gtkblist = gaim_gtk_blist_get_default_gtk_blist(); |
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
989 cursor = gdk_cursor_new(GDK_WATCH); |
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
990 |
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
991 gdk_window_set_cursor(gtkblist->window->window, cursor); |
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
992 gdk_window_set_cursor(win->window->window, cursor); |
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
993 gdk_cursor_unref(cursor); |
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
994 while (gtk_events_pending()) |
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
995 gtk_main_iteration(); |
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
996 |
10809
f9e01ccd6046
[gaim-migrate @ 12461]
Luke Schierer <lschiere@pidgin.im>
parents:
10807
diff
changeset
|
997 name = gaim_conversation_get_name(conv); |
f9e01ccd6046
[gaim-migrate @ 12461]
Luke Schierer <lschiere@pidgin.im>
parents:
10807
diff
changeset
|
998 account = gaim_conversation_get_account(conv); |
f9e01ccd6046
[gaim-migrate @ 12461]
Luke Schierer <lschiere@pidgin.im>
parents:
10807
diff
changeset
|
999 |
10845 | 1000 buddies = gaim_find_buddies(account, name); |
1001 for (cur = buddies; cur != NULL; cur = cur->next) | |
1002 { | |
1003 GaimBlistNode *node = cur->data; | |
10846 | 1004 if ((node != NULL) && ((node->prev != NULL) || (node->next != NULL))) |
10845 | 1005 { |
1006 gaim_gtk_log_show_contact((GaimContact *)node->parent); | |
1007 g_slist_free(buddies); | |
12232
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
1008 gdk_window_set_cursor(gtkblist->window->window, NULL); |
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
1009 gdk_window_set_cursor(win->window->window, NULL); |
10845 | 1010 return; |
1011 } | |
10809
f9e01ccd6046
[gaim-migrate @ 12461]
Luke Schierer <lschiere@pidgin.im>
parents:
10807
diff
changeset
|
1012 } |
10845 | 1013 g_slist_free(buddies); |
10809
f9e01ccd6046
[gaim-migrate @ 12461]
Luke Schierer <lschiere@pidgin.im>
parents:
10807
diff
changeset
|
1014 |
f9e01ccd6046
[gaim-migrate @ 12461]
Luke Schierer <lschiere@pidgin.im>
parents:
10807
diff
changeset
|
1015 gaim_gtk_log_show(type, name, account); |
12232
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
1016 |
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
1017 gdk_window_set_cursor(gtkblist->window->window, NULL); |
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
1018 gdk_window_set_cursor(win->window->window, NULL); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1019 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1020 |
8974 | 1021 static void |
1022 menu_clear_cb(gpointer data, guint action, GtkWidget *widget) | |
1023 { | |
11581 | 1024 GaimGtkWindow *win = data; |
8974 | 1025 GaimConversation *conv; |
1026 GaimGtkConversation *gtkconv; | |
1027 | |
11581 | 1028 conv = gaim_gtk_conv_window_get_active_conversation(win); |
8974 | 1029 gtkconv = GAIM_GTK_CONVERSATION(conv); |
1030 | |
1031 gtk_imhtml_clear(GTK_IMHTML(gtkconv->imhtml)); | |
1032 } | |
1033 | |
7295 | 1034 struct _search { |
1035 GaimGtkConversation *gtkconv; | |
1036 GtkWidget *entry; | |
1037 }; | |
1038 | |
7929 | 1039 static void do_search_cb(GtkWidget *widget, gint resp, struct _search *s) |
7295 | 1040 { |
7929 | 1041 switch (resp) { |
1042 case GTK_RESPONSE_OK: | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1043 gtk_imhtml_search_find(GTK_IMHTML(s->gtkconv->imhtml), |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1044 gtk_entry_get_text(GTK_ENTRY(s->entry))); |
7929 | 1045 break; |
1046 | |
1047 case GTK_RESPONSE_DELETE_EVENT: | |
1048 case GTK_RESPONSE_CLOSE: | |
1049 gtk_imhtml_search_clear(GTK_IMHTML(s->gtkconv->imhtml)); | |
1050 gtk_widget_destroy(s->gtkconv->dialogs.search); | |
1051 s->gtkconv->dialogs.search = NULL; | |
1052 g_free(s); | |
1053 break; | |
1054 } | |
7295 | 1055 } |
1056 | |
1057 static void | |
7751 | 1058 menu_find_cb(gpointer data, guint action, GtkWidget *widget) |
7295 | 1059 { |
11581 | 1060 GaimGtkWindow *gtkwin = data; |
1061 GaimConversation *conv = gaim_gtk_conv_window_get_active_conversation(gtkwin); | |
7295 | 1062 GaimGtkConversation *gtkconv = GAIM_GTK_CONVERSATION(conv); |
7929 | 1063 GtkWidget *hbox; |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1064 GtkWidget *img = gtk_image_new_from_stock(GAIM_STOCK_DIALOG_QUESTION, |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1065 GTK_ICON_SIZE_DIALOG); |
7929 | 1066 GtkWidget *label; |
7295 | 1067 struct _search *s; |
1068 | |
7798 | 1069 if (gtkconv->dialogs.search) { |
1070 gtk_window_present(GTK_WINDOW(gtkconv->dialogs.search)); | |
7295 | 1071 return; |
7798 | 1072 } |
7300
41bbe5534441
[gaim-migrate @ 7884]
Christian Hammond <chipx86@chipx86.com>
parents:
7298
diff
changeset
|
1073 |
7295 | 1074 s = g_malloc(sizeof(struct _search)); |
1075 s->gtkconv = gtkconv; | |
7929 | 1076 |
1077 gtkconv->dialogs.search = gtk_dialog_new_with_buttons(_("Find"), | |
1078 GTK_WINDOW(gtkwin->window), GTK_DIALOG_DESTROY_WITH_PARENT, | |
1079 GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE, | |
1080 GTK_STOCK_FIND, GTK_RESPONSE_OK, NULL); | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1081 gtk_dialog_set_default_response(GTK_DIALOG(gtkconv->dialogs.search), |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1082 GTK_RESPONSE_OK); |
7929 | 1083 g_signal_connect(G_OBJECT(gtkconv->dialogs.search), "response", |
1084 G_CALLBACK(do_search_cb), s); | |
1085 | |
11243 | 1086 gtk_container_set_border_width(GTK_CONTAINER(gtkconv->dialogs.search), GAIM_HIG_BOX_SPACE); |
7929 | 1087 gtk_window_set_resizable(GTK_WINDOW(gtkconv->dialogs.search), FALSE); |
1088 gtk_dialog_set_has_separator(GTK_DIALOG(gtkconv->dialogs.search), FALSE); | |
11243 | 1089 gtk_box_set_spacing(GTK_BOX(GTK_DIALOG(gtkconv->dialogs.search)->vbox), GAIM_HIG_BORDER); |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1090 gtk_container_set_border_width( |
11243 | 1091 GTK_CONTAINER(GTK_DIALOG(gtkconv->dialogs.search)->vbox), GAIM_HIG_BOX_SPACE); |
1092 | |
1093 hbox = gtk_hbox_new(FALSE, GAIM_HIG_BORDER); | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1094 gtk_container_add(GTK_CONTAINER(GTK_DIALOG(gtkconv->dialogs.search)->vbox), |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1095 hbox); |
7929 | 1096 gtk_box_pack_start(GTK_BOX(hbox), img, FALSE, FALSE, 0); |
1097 | |
1098 gtk_misc_set_alignment(GTK_MISC(img), 0, 0); | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1099 gtk_dialog_set_response_sensitive(GTK_DIALOG(gtkconv->dialogs.search), |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1100 GTK_RESPONSE_OK, FALSE); |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1101 |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1102 label = gtk_label_new(NULL); |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1103 gtk_label_set_markup_with_mnemonic(GTK_LABEL(label), _("_Search for:")); |
7929 | 1104 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); |
1105 | |
1106 s->entry = gtk_entry_new(); | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1107 gtk_entry_set_activates_default(GTK_ENTRY(s->entry), TRUE); |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1108 gtk_label_set_mnemonic_widget(GTK_LABEL(label), GTK_WIDGET(s->entry)); |
7929 | 1109 g_signal_connect(G_OBJECT(s->entry), "changed", |
1110 G_CALLBACK(gaim_gtk_set_sensitive_if_input), | |
1111 gtkconv->dialogs.search); | |
1112 gtk_box_pack_start(GTK_BOX(hbox), s->entry, FALSE, FALSE, 0); | |
7300
41bbe5534441
[gaim-migrate @ 7884]
Christian Hammond <chipx86@chipx86.com>
parents:
7298
diff
changeset
|
1113 |
7295 | 1114 gtk_widget_show_all(gtkconv->dialogs.search); |
7929 | 1115 gtk_widget_grab_focus(s->entry); |
7295 | 1116 } |
1117 | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1118 static void |
9468 | 1119 menu_send_file_cb(gpointer data, guint action, GtkWidget *widget) |
1120 { | |
11581 | 1121 GaimGtkWindow *win = data; |
1122 GaimConversation *conv = gaim_gtk_conv_window_get_active_conversation(win); | |
9468 | 1123 |
11338 | 1124 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) { |
9468 | 1125 serv_send_file(gaim_conversation_get_gc(conv), gaim_conversation_get_name(conv), NULL); |
1126 } | |
1127 | |
1128 } | |
1129 | |
1130 static void | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1131 menu_add_pounce_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1132 { |
11581 | 1133 GaimGtkWindow *win = data; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1134 GaimConversation *conv; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1135 |
11581 | 1136 conv = gaim_gtk_conv_window_get_active_gtkconv(win)->active_conv; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1137 |
12136
370f9d7868f9
[gaim-migrate @ 14436]
Richard Laager <rlaager@wiktel.com>
parents:
12132
diff
changeset
|
1138 gaim_gtk_pounce_editor_show(gaim_conversation_get_account(conv), |
370f9d7868f9
[gaim-migrate @ 14436]
Richard Laager <rlaager@wiktel.com>
parents:
12132
diff
changeset
|
1139 gaim_conversation_get_name(conv), NULL); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1140 } |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1141 |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1142 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1143 menu_insert_link_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1144 { |
11581 | 1145 GaimGtkWindow *win = data; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1146 GaimGtkConversation *gtkconv; |
8756 | 1147 GtkIMHtmlToolbar *toolbar; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1148 |
11581 | 1149 gtkconv = gaim_gtk_conv_window_get_active_gtkconv(win); |
8756 | 1150 toolbar = GTK_IMHTMLTOOLBAR(gtkconv->toolbar); |
1151 | |
1152 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toolbar->link), | |
1153 !gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(toolbar->link))); | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1154 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1155 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1156 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1157 menu_insert_image_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1158 { |
11581 | 1159 GaimGtkWindow *win = data; |
8756 | 1160 GaimConversation *conv; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1161 GaimGtkConversation *gtkconv; |
8756 | 1162 GtkIMHtmlToolbar *toolbar; |
1163 | |
11581 | 1164 gtkconv = gaim_gtk_conv_window_get_active_gtkconv(win); |
1165 conv = gtkconv->active_conv; | |
8756 | 1166 toolbar = GTK_IMHTMLTOOLBAR(gtkconv->toolbar); |
1167 | |
1168 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toolbar->image), | |
1169 !gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(toolbar->image))); | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1170 } |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1171 |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1172 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1173 menu_alias_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1174 { |
11581 | 1175 GaimGtkWindow *win = data; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1176 GaimConversation *conv; |
7879 | 1177 GaimAccount *account; |
1178 const char *name; | |
1179 | |
11581 | 1180 conv = gaim_gtk_conv_window_get_active_conversation(win); |
7879 | 1181 account = gaim_conversation_get_account(conv); |
1182 name = gaim_conversation_get_name(conv); | |
1183 | |
11338 | 1184 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) { |
7879 | 1185 GaimBuddy *b; |
1186 | |
1187 b = gaim_find_buddy(account, name); | |
1188 if (b != NULL) | |
9730 | 1189 gaim_gtkdialogs_alias_buddy(b); |
11338 | 1190 } else if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) { |
7879 | 1191 GaimChat *c; |
1192 | |
1193 c = gaim_blist_find_chat(account, name); | |
1194 if (c != NULL) | |
9730 | 1195 gaim_gtkdialogs_alias_chat(c); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1196 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1197 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1198 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1199 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1200 menu_get_info_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1201 { |
11581 | 1202 GaimGtkWindow *win = data; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1203 GaimConversation *conv; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1204 |
11581 | 1205 conv = gaim_gtk_conv_window_get_active_conversation(win); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1206 |
10810 | 1207 info_cb(NULL, GAIM_GTK_CONVERSATION(conv)); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1208 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1209 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1210 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1211 menu_invite_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1212 { |
11581 | 1213 GaimGtkWindow *win = data; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1214 GaimConversation *conv; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1215 |
11581 | 1216 conv = gaim_gtk_conv_window_get_active_conversation(win); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1217 |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1218 invite_cb(NULL, GAIM_GTK_CONVERSATION(conv)); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1219 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1220 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1221 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1222 menu_block_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1223 { |
11581 | 1224 GaimGtkWindow *win = data; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1225 GaimConversation *conv; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1226 |
11581 | 1227 conv = gaim_gtk_conv_window_get_active_conversation(win); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1228 |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1229 block_cb(NULL, GAIM_GTK_CONVERSATION(conv)); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1230 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1231 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1232 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1233 menu_add_remove_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1234 { |
11581 | 1235 GaimGtkWindow *win = data; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1236 GaimConversation *conv; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1237 |
11581 | 1238 conv = gaim_gtk_conv_window_get_active_conversation(win); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1239 |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1240 add_remove_cb(NULL, GAIM_GTK_CONVERSATION(conv)); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1241 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1242 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1243 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1244 menu_close_conv_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1245 { |
11581 | 1246 GaimGtkWindow *win = data; |
1247 | |
1248 close_conv_cb(NULL, GAIM_GTK_CONVERSATION(gaim_gtk_conv_window_get_active_conversation(win))); | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1249 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1250 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1251 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1252 menu_logging_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1253 { |
11581 | 1254 GaimGtkWindow *win = data; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1255 GaimConversation *conv; |
11805
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1256 gboolean logging; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1257 |
11581 | 1258 conv = gaim_gtk_conv_window_get_active_conversation(win); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1259 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1260 if (conv == NULL) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1261 return; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1262 |
11805
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1263 logging = gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(widget)); |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1264 |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1265 if (logging == gaim_conversation_is_logging(conv)) |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1266 return; |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1267 |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1268 if (logging) |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1269 { |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1270 /* Enable logging first so the message below can be logged. */ |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1271 gaim_conversation_set_logging(conv, TRUE); |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1272 |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1273 gaim_conversation_write(conv, NULL, |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1274 _("Logging started. Future messages in this conversation will be logged."), |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1275 conv->logs ? (GAIM_MESSAGE_SYSTEM) : |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1276 (GAIM_MESSAGE_SYSTEM | GAIM_MESSAGE_NO_LOG), |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1277 time(NULL)); |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1278 } |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1279 else |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1280 { |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1281 gaim_conversation_write(conv, NULL, |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1282 _("Logging stopped. Future messages in this conversation will not be logged."), |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1283 conv->logs ? (GAIM_MESSAGE_SYSTEM) : |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1284 (GAIM_MESSAGE_SYSTEM | GAIM_MESSAGE_NO_LOG), |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1285 time(NULL)); |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1286 |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1287 /* Disable the logging second, so that the above message can be logged. */ |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1288 gaim_conversation_set_logging(conv, FALSE); |
615c2fd3d72e
[gaim-migrate @ 14096]
Richard Laager <rlaager@wiktel.com>
parents:
11799
diff
changeset
|
1289 } |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1290 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1291 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1292 static void |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1293 menu_toolbar_cb(gpointer data, guint action, GtkWidget *widget) |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1294 { |
11581 | 1295 GaimGtkWindow *win = data; |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1296 GaimConversation *conv; |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1297 GaimGtkConversation *gtkconv; |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1298 |
11581 | 1299 conv = gaim_gtk_conv_window_get_active_conversation(win); |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1300 |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1301 if (conv == NULL) |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1302 return; |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1303 |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1304 gtkconv = GAIM_GTK_CONVERSATION(conv); |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1305 |
10377 | 1306 gaim_prefs_set_bool("/gaim/gtk/conversations/show_formatting_toolbar", |
11581 | 1307 gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(widget))); |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1308 } |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1309 |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1310 static void |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1311 menu_sounds_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1312 { |
11581 | 1313 GaimGtkWindow *win = data; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1314 GaimConversation *conv; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1315 GaimGtkConversation *gtkconv; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1316 |
11581 | 1317 conv = gaim_gtk_conv_window_get_active_conversation(win); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1318 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1319 if (!conv) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1320 return; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1321 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1322 gtkconv = GAIM_GTK_CONVERSATION(conv); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1323 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1324 gtkconv->make_sound = |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1325 gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(widget)); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1326 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1327 |
7961 | 1328 static void |
9188 | 1329 menu_timestamps_cb(gpointer data, guint action, GtkWidget *widget) |
1330 { | |
11581 | 1331 GaimGtkWindow *win = data; |
9188 | 1332 GaimConversation *conv; |
1333 GaimGtkConversation *gtkconv; | |
1334 | |
11581 | 1335 conv = gaim_gtk_conv_window_get_active_conversation(win); |
9188 | 1336 |
1337 if (!conv) | |
1338 return; | |
1339 | |
1340 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
1341 | |
12188 | 1342 gaim_prefs_set_bool("/gaim/gtk/conversations/show_timestamps", |
9188 | 1343 gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(widget))); |
1344 } | |
1345 | |
1346 static void | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1347 chat_do_im(GaimGtkConversation *gtkconv, const char *who) |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1348 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1349 GaimConversation *conv = gtkconv->active_conv; |
10431 | 1350 GaimAccount *account; |
1351 GaimConnection *gc; | |
7961 | 1352 GaimPluginProtocolInfo *prpl_info = NULL; |
1353 char *real_who; | |
1354 | |
1355 account = gaim_conversation_get_account(conv); | |
10431 | 1356 g_return_if_fail(account != NULL); |
1357 | |
1358 gc = gaim_account_get_connection(account); | |
1359 g_return_if_fail(gc != NULL); | |
1360 | |
1361 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); | |
1362 | |
1363 if (prpl_info && prpl_info->get_cb_real_name) | |
1364 real_who = prpl_info->get_cb_real_name(gc, | |
7961 | 1365 gaim_conv_chat_get_id(GAIM_CONV_CHAT(conv)), who); |
1366 else | |
1367 real_who = g_strdup(who); | |
1368 | |
1369 if(!real_who) | |
1370 return; | |
1371 | |
10431 | 1372 gaim_gtkdialogs_im_with_user(account, real_who); |
7961 | 1373 |
1374 g_free(real_who); | |
1375 } | |
1376 | |
1377 static void | |
10810 | 1378 chat_im_button_cb(GtkWidget *widget, GaimGtkConversation *gtkconv) |
7961 | 1379 { |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1380 GaimGtkChatPane *gtkchat; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1381 GtkTreeIter iter; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1382 GtkTreeModel *model; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1383 GtkTreeSelection *sel; |
9554 | 1384 char *name; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1385 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1386 gtkchat = gtkconv->u.chat; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1387 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1388 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1389 sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(gtkchat->list)); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1390 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1391 if (gtk_tree_selection_get_selected(sel, NULL, &iter)) |
9498 | 1392 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, CHAT_USERS_NAME_COLUMN, &name, -1); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1393 else |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1394 return; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1395 |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1396 chat_do_im(gtkconv, name); |
9554 | 1397 g_free(name); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1398 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1399 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1400 static void |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1401 ignore_cb(GtkWidget *w, GaimGtkConversation *gtkconv) |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1402 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1403 GaimConversation *conv = gtkconv->active_conv; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1404 GaimGtkChatPane *gtkchat; |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1405 GaimConvChat *chat; |
11869 | 1406 GaimConvChatBuddyFlags flags; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1407 GtkTreeIter iter; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1408 GtkTreeModel *model; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1409 GtkTreeSelection *sel; |
10504 | 1410 char *name; |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1411 char *alias; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1412 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1413 chat = GAIM_CONV_CHAT(conv); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1414 gtkchat = gtkconv->u.chat; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1415 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1416 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1417 sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(gtkchat->list)); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1418 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1419 if (gtk_tree_selection_get_selected(sel, NULL, &iter)) { |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1420 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1421 CHAT_USERS_NAME_COLUMN, &name, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1422 CHAT_USERS_ALIAS_COLUMN, &alias, |
11869 | 1423 CHAT_USERS_FLAGS_COLUMN, &flags, |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1424 -1); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1425 gtk_list_store_remove(GTK_LIST_STORE(model), &iter); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1426 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1427 else |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1428 return; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1429 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1430 if (gaim_conv_chat_is_user_ignored(chat, name)) |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1431 gaim_conv_chat_unignore(chat, name); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1432 else |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1433 gaim_conv_chat_ignore(chat, name); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1434 |
11869 | 1435 add_chat_buddy_common(conv, name, flags, alias, NULL); |
10504 | 1436 g_free(name); |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1437 g_free(alias); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1438 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1439 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1440 static void |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1441 menu_chat_im_cb(GtkWidget *w, GaimGtkConversation *gtkconv) |
7398 | 1442 { |
1443 const char *who = g_object_get_data(G_OBJECT(w), "user_data"); | |
1444 | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1445 chat_do_im(gtkconv, who); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1446 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1447 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1448 static void |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1449 menu_chat_send_file_cb(GtkWidget *w, GaimGtkConversation *gtkconv) |
9468 | 1450 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1451 GaimConversation *conv = gtkconv->active_conv; |
9468 | 1452 const char *who = g_object_get_data(G_OBJECT(w), "user_data"); |
1453 GaimConnection *gc = gaim_conversation_get_gc(conv); | |
1454 | |
1455 serv_send_file(gc, who, NULL); | |
1456 } | |
1457 | |
1458 static void | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1459 menu_chat_info_cb(GtkWidget *w, GaimGtkConversation *gtkconv) |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1460 { |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1461 char *who; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1462 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1463 who = g_object_get_data(G_OBJECT(w), "user_data"); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1464 |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1465 chat_do_info(gtkconv, who); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1466 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1467 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1468 static void |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1469 menu_chat_get_away_cb(GtkWidget *w, GaimGtkConversation *gtkconv) |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1470 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1471 GaimConversation *conv = gtkconv->active_conv; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1472 GaimPluginProtocolInfo *prpl_info = NULL; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1473 GaimConnection *gc; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1474 char *who; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1475 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1476 gc = gaim_conversation_get_gc(conv); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1477 who = g_object_get_data(G_OBJECT(w), "user_data"); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1478 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1479 if (gc != NULL) { |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1480 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1481 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1482 /* |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1483 * May want to expand this to work similarly to menu_info_cb? |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1484 */ |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1485 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1486 if (prpl_info->get_cb_away != NULL) |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1487 { |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1488 prpl_info->get_cb_away(gc, |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1489 gaim_conv_chat_get_id(GAIM_CONV_CHAT(conv)), who); |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1490 } |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1491 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1492 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1493 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1494 static void |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1495 menu_chat_add_remove_cb(GtkWidget *w, GaimGtkConversation *gtkconv) |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1496 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1497 GaimConversation *conv = gtkconv->active_conv; |
7060
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
1498 GaimAccount *account; |
6695 | 1499 GaimBuddy *b; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1500 char *name; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1501 |
7060
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
1502 account = gaim_conversation_get_account(conv); |
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
1503 name = g_object_get_data(G_OBJECT(w), "user_data"); |
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
1504 b = gaim_find_buddy(account, name); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1505 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1506 if (b != NULL) |
9730 | 1507 gaim_gtkdialogs_remove_buddy(b); |
7060
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
1508 else if (account != NULL && gaim_account_is_connected(account)) |
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
1509 gaim_blist_request_add_buddy(account, name, NULL, NULL); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1510 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1511 gtk_widget_grab_focus(GAIM_GTK_CONVERSATION(conv)->entry); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1512 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1513 |
8143 | 1514 static GtkWidget * |
10504 | 1515 create_chat_menu(GaimConversation *conv, const char *who, |
8143 | 1516 GaimPluginProtocolInfo *prpl_info, GaimConnection *gc) |
1517 { | |
1518 static GtkWidget *menu = NULL; | |
11500
9fc7d0153332
[gaim-migrate @ 13745]
Richard Laager <rlaager@wiktel.com>
parents:
11486
diff
changeset
|
1519 GaimConvChat *chat = GAIM_CONV_CHAT(conv); |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1520 gboolean is_me = FALSE; |
8143 | 1521 GtkWidget *button; |
1522 | |
1523 /* | |
1524 * If a menu already exists, destroy it before creating a new one, | |
1525 * thus freeing-up the memory it occupied. | |
1526 */ | |
1527 if (menu) | |
1528 gtk_widget_destroy(menu); | |
1529 | |
11500
9fc7d0153332
[gaim-migrate @ 13745]
Richard Laager <rlaager@wiktel.com>
parents:
11486
diff
changeset
|
1530 if (!strcmp(chat->nick, gaim_normalize(conv->account, who))) |
9fc7d0153332
[gaim-migrate @ 13745]
Richard Laager <rlaager@wiktel.com>
parents:
11486
diff
changeset
|
1531 is_me = TRUE; |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1532 |
8143 | 1533 menu = gtk_menu_new(); |
1534 | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1535 if (!is_me) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1536 button = gaim_new_item_from_stock(menu, _("IM"), GAIM_STOCK_IM, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1537 G_CALLBACK(menu_chat_im_cb), GAIM_GTK_CONVERSATION(conv), 0, 0, NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1538 g_object_set_data_full(G_OBJECT(button), "user_data", g_strdup(who), g_free); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1539 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1540 if (prpl_info && prpl_info->send_file |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1541 && (!prpl_info->can_receive_file || prpl_info->can_receive_file(gc, who))) { |
11508 | 1542 button = gaim_new_item_from_stock(menu, _("Send File"), |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1543 GAIM_STOCK_FILE_TRANSFER, G_CALLBACK(menu_chat_send_file_cb), |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1544 GAIM_GTK_CONVERSATION(conv), 0, 0, NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1545 g_object_set_data_full(G_OBJECT(button), "user_data", g_strdup(who), g_free); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1546 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1547 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1548 if (gaim_conv_chat_is_user_ignored(GAIM_CONV_CHAT(conv), who)) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1549 button = gaim_new_item_from_stock(menu, _("Un-Ignore"), GAIM_STOCK_IGNORE, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1550 G_CALLBACK(ignore_cb), GAIM_GTK_CONVERSATION(conv), 0, 0, NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1551 else |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1552 button = gaim_new_item_from_stock(menu, _("Ignore"), GAIM_STOCK_IGNORE, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1553 G_CALLBACK(ignore_cb), GAIM_GTK_CONVERSATION(conv), 0, 0, NULL); |
10504 | 1554 g_object_set_data_full(G_OBJECT(button), "user_data", g_strdup(who), g_free); |
9468 | 1555 } |
9498 | 1556 |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1557 if (prpl_info->get_info || prpl_info->get_cb_info) { |
10221 | 1558 button = gaim_new_item_from_stock(menu, _("Info"), GAIM_STOCK_INFO, |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1559 G_CALLBACK(menu_chat_info_cb), GAIM_GTK_CONVERSATION(conv), 0, 0, NULL); |
10504 | 1560 g_object_set_data_full(G_OBJECT(button), "user_data", g_strdup(who), g_free); |
8143 | 1561 } |
1562 | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1563 if (prpl_info->get_cb_away) { |
10221 | 1564 button = gaim_new_item_from_stock(menu, _("Get Away Message"), GAIM_STOCK_AWAY, |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1565 G_CALLBACK(menu_chat_get_away_cb), GAIM_GTK_CONVERSATION(conv), 0, 0, NULL); |
10504 | 1566 g_object_set_data_full(G_OBJECT(button), "user_data", g_strdup(who), g_free); |
8143 | 1567 } |
1568 | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
1569 if (!is_me && !(prpl_info->options & OPT_PROTO_UNIQUE_CHATNAME)) { |
8143 | 1570 if (gaim_find_buddy(gc->account, who)) |
10221 | 1571 button = gaim_new_item_from_stock(menu, _("Remove"), GTK_STOCK_REMOVE, |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1572 G_CALLBACK(menu_chat_add_remove_cb), GAIM_GTK_CONVERSATION(conv), 0, 0, NULL); |
8143 | 1573 else |
10221 | 1574 button = gaim_new_item_from_stock(menu, _("Add"), GTK_STOCK_ADD, |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1575 G_CALLBACK(menu_chat_add_remove_cb), GAIM_GTK_CONVERSATION(conv), 0, 0, NULL); |
10504 | 1576 g_object_set_data_full(G_OBJECT(button), "user_data", g_strdup(who), g_free); |
8143 | 1577 } |
1578 | |
1579 return menu; | |
1580 } | |
1581 | |
1582 | |
1583 static gint | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1584 gtkconv_chat_popup_menu_cb(GtkWidget *widget, GaimGtkConversation *gtkconv) |
8143 | 1585 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1586 GaimConversation *conv = gtkconv->active_conv; |
8143 | 1587 GaimPluginProtocolInfo *prpl_info = NULL; |
1588 GaimGtkChatPane *gtkchat; | |
1589 GaimConnection *gc; | |
1590 GaimAccount *account; | |
1591 GtkTreeSelection *sel; | |
1592 GtkTreeIter iter; | |
1593 GtkTreeModel *model; | |
1594 GtkWidget *menu; | |
1595 gchar *who; | |
1596 | |
1597 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
1598 gtkchat = gtkconv->u.chat; | |
1599 account = gaim_conversation_get_account(conv); | |
1600 gc = account->gc; | |
1601 | |
1602 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); | |
1603 | |
1604 if (gc != NULL) | |
1605 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); | |
1606 | |
1607 sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(gtkchat->list)); | |
1608 if(!gtk_tree_selection_get_selected(sel, NULL, &iter)) | |
1609 return FALSE; | |
1610 | |
9498 | 1611 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, CHAT_USERS_NAME_COLUMN, &who, -1); |
8143 | 1612 menu = create_chat_menu (conv, who, prpl_info, gc); |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1613 gtk_menu_popup(GTK_MENU(menu), NULL, NULL, |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1614 gaim_gtk_treeview_popup_menu_position_func, widget, |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1615 0, GDK_CURRENT_TIME); |
10504 | 1616 g_free(who); |
8143 | 1617 |
1618 return TRUE; | |
1619 } | |
1620 | |
1621 | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1622 static gint |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1623 right_click_chat_cb(GtkWidget *widget, GdkEventButton *event, |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1624 GaimGtkConversation *gtkconv) |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1625 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1626 GaimConversation *conv = gtkconv->active_conv; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1627 GaimPluginProtocolInfo *prpl_info = NULL; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1628 GaimGtkChatPane *gtkchat; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1629 GaimConnection *gc; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1630 GaimAccount *account; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1631 GtkTreePath *path; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1632 GtkTreeIter iter; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1633 GtkTreeModel *model; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1634 GtkTreeViewColumn *column; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1635 gchar *who; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1636 int x, y; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1637 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1638 gtkchat = gtkconv->u.chat; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1639 account = gaim_conversation_get_account(conv); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1640 gc = account->gc; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1641 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1642 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1643 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1644 gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(gtkchat->list), |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1645 event->x, event->y, &path, &column, &x, &y); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1646 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1647 if (path == NULL) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1648 return FALSE; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1649 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1650 if (gc != NULL) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1651 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1652 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1653 gtk_tree_selection_select_path(GTK_TREE_SELECTION( |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1654 gtk_tree_view_get_selection(GTK_TREE_VIEW(gtkchat->list))), path); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1655 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1656 gtk_tree_model_get_iter(GTK_TREE_MODEL(model), &iter, path); |
9498 | 1657 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, CHAT_USERS_NAME_COLUMN, &who, -1); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1658 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1659 if (event->button == 1 && event->type == GDK_2BUTTON_PRESS) { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
1660 chat_do_im(gtkconv, who); |
7398 | 1661 } else if (event->button == 3 && event->type == GDK_BUTTON_PRESS) { |
8143 | 1662 GtkWidget *menu = create_chat_menu (conv, who, prpl_info, gc); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1663 gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL, |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1664 event->button, event->time); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1665 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1666 |
10504 | 1667 g_free(who); |
1668 gtk_tree_path_free(path); | |
1669 | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1670 return TRUE; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1671 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1672 |
8133 | 1673 static void |
11467
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1674 move_to_next_unread_tab(GaimGtkConversation *gtkconv, gboolean forward) |
8133 | 1675 { |
10827 | 1676 GaimGtkConversation *next_gtkconv = NULL; |
11581 | 1677 GaimGtkWindow *win; |
11467
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1678 int index, i, total, found = 0; |
8133 | 1679 |
11581 | 1680 win = gtkconv->win; |
1681 index = gtk_notebook_page_num(GTK_NOTEBOOK(win->notebook), gtkconv->tab_cont); | |
1682 total = gaim_gtk_conv_window_get_gtkconv_count(win); | |
11467
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1683 |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1684 /* First check the tabs after (forward) or before (!forward) this position. */ |
11620
fbc4eeab2227
[gaim-migrate @ 13894]
Luke Schierer <lschiere@pidgin.im>
parents:
11619
diff
changeset
|
1685 for (i = forward ? index + 1 : index - 1; |
11581 | 1686 !found && (next_gtkconv = gaim_gtk_conv_window_get_gtkconv_at_index(win, i)); |
11467
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1687 forward ? i++ : i--) { |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1688 if (i == -1) { |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1689 break; |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1690 } |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
1691 |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
1692 if (next_gtkconv->unseen_state > 0) |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
1693 found = 1; |
8133 | 1694 } |
11252 | 1695 |
10893
3f85d6fc763a
[gaim-migrate @ 12606]
Luke Schierer <lschiere@pidgin.im>
parents:
10892
diff
changeset
|
1696 if (!found) { |
11467
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1697 /* Now check from the beginning up to (forward) or end back to (!forward) this position. */ |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1698 for (i = forward ? 0 : total - 1; |
11620
fbc4eeab2227
[gaim-migrate @ 13894]
Luke Schierer <lschiere@pidgin.im>
parents:
11619
diff
changeset
|
1699 !found && (forward ? i < index : i >= 0) && |
fbc4eeab2227
[gaim-migrate @ 13894]
Luke Schierer <lschiere@pidgin.im>
parents:
11619
diff
changeset
|
1700 (next_gtkconv = gaim_gtk_conv_window_get_gtkconv_at_index(win, i)); |
11467
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1701 forward ? i++ : i--) { |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
1702 |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
1703 if (next_gtkconv->unseen_state > 0) |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
1704 found = 1; |
8133 | 1705 } |
10827 | 1706 |
10893
3f85d6fc763a
[gaim-migrate @ 12606]
Luke Schierer <lschiere@pidgin.im>
parents:
10892
diff
changeset
|
1707 if (!found) { |
11467
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1708 /* Okay, just grab the next (forward) or previous (!forward) conversation tab. */ |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1709 if (forward) { |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1710 index++; |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1711 } |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1712 else { |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1713 index = (index == 0) ? total - 1 : index - 1; |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1714 } |
11581 | 1715 if (!(next_gtkconv = gaim_gtk_conv_window_get_gtkconv_at_index(win, index))) |
1716 next_gtkconv = gaim_gtk_conv_window_get_gtkconv_at_index(win, 0); | |
10827 | 1717 } |
8133 | 1718 } |
1719 | |
10827 | 1720 if (next_gtkconv != NULL && next_gtkconv != gtkconv) |
11581 | 1721 gaim_gtk_conv_window_switch_gtkconv(win, next_gtkconv); |
8133 | 1722 } |
1723 | |
4359 | 1724 static gboolean |
8105 | 1725 entry_key_press_cb(GtkWidget *entry, GdkEventKey *event, gpointer data) |
4359 | 1726 { |
11581 | 1727 GaimGtkWindow *win; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
1728 GaimConversation *conv; |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
1729 GaimGtkConversation *gtkconv; |
8105 | 1730 int curconv; |
1731 | |
10810 | 1732 gtkconv = (GaimGtkConversation *)data; |
10849 | 1733 conv = gtkconv->active_conv; |
11581 | 1734 win = gtkconv->win; |
1735 curconv = gtk_notebook_get_current_page(GTK_NOTEBOOK(win->notebook)); | |
10839 | 1736 |
8105 | 1737 /* If CTRL was held down... */ |
1738 if (event->state & GDK_CONTROL_MASK) { | |
4359 | 1739 switch (event->keyval) { |
1740 case GDK_Up: | |
1741 if (!conv->send_history) | |
1742 break; | |
1743 | |
1744 if (!conv->send_history->prev) { | |
1745 GtkTextIter start, end; | |
1746 | |
1747 if (conv->send_history->data) | |
1748 g_free(conv->send_history->data); | |
1749 | |
1750 gtk_text_buffer_get_start_iter(gtkconv->entry_buffer, | |
1751 &start); | |
1752 gtk_text_buffer_get_end_iter(gtkconv->entry_buffer, &end); | |
1753 | |
1754 conv->send_history->data = | |
8506 | 1755 gtk_imhtml_get_markup(GTK_IMHTML(gtkconv->entry)); |
4359 | 1756 } |
8677 | 1757 |
11276
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1758 if (conv->send_history->next && conv->send_history->next->data) { |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1759 GObject *object; |
8677 | 1760 GtkTextIter iter; |
1761 GtkTextBuffer *buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(gtkconv->entry)); | |
4359 | 1762 |
1763 conv->send_history = conv->send_history->next; | |
11276
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1764 |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1765 /* Block the signal to prevent application of default formatting. */ |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1766 object = g_object_ref(G_OBJECT(gtkconv->entry)); |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1767 g_signal_handlers_block_matched(object, G_SIGNAL_MATCH_DATA, 0, 0, NULL, |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1768 NULL, gtkconv); |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1769 /* Clear the formatting. */ |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1770 gtk_imhtml_clear_formatting(GTK_IMHTML(gtkconv->entry)); |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1771 /* Unblock the signal. */ |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1772 g_signal_handlers_unblock_matched(object, G_SIGNAL_MATCH_DATA, 0, 0, NULL, |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1773 NULL, gtkconv); |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1774 g_object_unref(object); |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1775 |
8061 | 1776 gtk_imhtml_clear(GTK_IMHTML(gtkconv->entry)); |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1777 gtk_imhtml_append_text_with_images( |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1778 GTK_IMHTML(gtkconv->entry), conv->send_history->data, |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1779 0, NULL); |
8677 | 1780 /* this is mainly just a hack so the formatting at the |
1781 * cursor gets picked up. */ | |
1782 gtk_text_buffer_get_end_iter(buffer, &iter); | |
1783 gtk_text_buffer_move_mark_by_name(buffer, "insert", &iter); | |
4359 | 1784 } |
1785 | |
8105 | 1786 return TRUE; |
4359 | 1787 break; |
1788 | |
1789 case GDK_Down: | |
1790 if (!conv->send_history) | |
1791 break; | |
1792 | |
11276
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1793 if (conv->send_history->prev && conv->send_history->prev->data) { |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1794 GObject *object; |
8677 | 1795 GtkTextIter iter; |
1796 GtkTextBuffer *buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(gtkconv->entry)); | |
8105 | 1797 |
4359 | 1798 conv->send_history = conv->send_history->prev; |
11276
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1799 |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1800 /* Block the signal to prevent application of default formatting. */ |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1801 object = g_object_ref(G_OBJECT(gtkconv->entry)); |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1802 g_signal_handlers_block_matched(object, G_SIGNAL_MATCH_DATA, 0, 0, NULL, |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1803 NULL, gtkconv); |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1804 /* Clear the formatting. */ |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1805 gtk_imhtml_clear_formatting(GTK_IMHTML(gtkconv->entry)); |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1806 /* Unblock the signal. */ |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1807 g_signal_handlers_unblock_matched(object, G_SIGNAL_MATCH_DATA, 0, 0, NULL, |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1808 NULL, gtkconv); |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1809 g_object_unref(object); |
17ebda61c6ce
[gaim-migrate @ 13463]
Richard Laager <rlaager@wiktel.com>
parents:
11275
diff
changeset
|
1810 |
8105 | 1811 gtk_imhtml_clear(GTK_IMHTML(gtkconv->entry)); |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1812 gtk_imhtml_append_text_with_images( |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1813 GTK_IMHTML(gtkconv->entry), conv->send_history->data, |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1814 0, NULL); |
8677 | 1815 /* this is mainly just a hack so the formatting at the |
1816 * cursor gets picked up. */ | |
11267
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
1817 if (*(char *)conv->send_history->data) { |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
1818 gtk_text_buffer_get_end_iter(buffer, &iter); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
1819 gtk_text_buffer_move_mark_by_name(buffer, "insert", &iter); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
1820 } else { |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
1821 /* Restore the default formatting */ |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
1822 default_formatize(gtkconv); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
1823 } |
4359 | 1824 } |
1825 | |
8105 | 1826 return TRUE; |
4359 | 1827 break; |
8105 | 1828 |
8108 | 1829 case GDK_Page_Down: |
8143 | 1830 case ']': |
11581 | 1831 if (!gaim_gtk_conv_window_get_gtkconv_at_index(win, curconv + 1)) |
1832 gtk_notebook_set_current_page(GTK_NOTEBOOK(win->notebook), 0); | |
10827 | 1833 else |
11581 | 1834 gtk_notebook_set_current_page(GTK_NOTEBOOK(win->notebook), curconv + 1); |
8105 | 1835 return TRUE; |
1836 break; | |
1837 | |
8108 | 1838 case GDK_Page_Up: |
8143 | 1839 case '[': |
11581 | 1840 if (!gaim_gtk_conv_window_get_gtkconv_at_index(win, curconv - 1)) |
1841 gtk_notebook_set_current_page(GTK_NOTEBOOK(win->notebook), -1); | |
10827 | 1842 else |
11581 | 1843 gtk_notebook_set_current_page(GTK_NOTEBOOK(win->notebook), curconv - 1); |
8133 | 1844 return TRUE; |
1845 break; | |
1846 | |
8108 | 1847 case GDK_Tab: |
11467
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1848 case GDK_ISO_Left_Tab: |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1849 if (event->state & GDK_SHIFT_MASK) { |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1850 move_to_next_unread_tab(gtkconv, FALSE); |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1851 } else { |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1852 move_to_next_unread_tab(gtkconv, TRUE); |
2952c6dfa738
[gaim-migrate @ 13707]
Luke Schierer <lschiere@pidgin.im>
parents:
11460
diff
changeset
|
1853 } |
8108 | 1854 |
1855 return TRUE; | |
1856 break; | |
1857 | |
11252 | 1858 case GDK_comma: |
11581 | 1859 gtk_notebook_reorder_child(GTK_NOTEBOOK(win->notebook), |
1860 gtk_notebook_get_nth_page(GTK_NOTEBOOK(win->notebook), curconv), | |
11252 | 1861 curconv - 1); |
1862 break; | |
1863 | |
1864 case GDK_period: | |
11581 | 1865 gtk_notebook_reorder_child(GTK_NOTEBOOK(win->notebook), |
1866 gtk_notebook_get_nth_page(GTK_NOTEBOOK(win->notebook), curconv), | |
11780 | 1867 #if GTK_CHECK_VERSION(2,2,0) |
11581 | 1868 (curconv + 1) % gtk_notebook_get_n_pages(GTK_NOTEBOOK(win->notebook))); |
11780 | 1869 #else |
1870 (curconv + 1) % g_list_length(GTK_NOTEBOOK(win->notebook)->children)); | |
1871 #endif | |
11252 | 1872 break; |
1873 | |
8105 | 1874 } /* End of switch */ |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1875 } |
8758 | 1876 |
8105 | 1877 /* If ALT (or whatever) was held down... */ |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1878 else if (event->state & GDK_MOD1_MASK) |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1879 { |
10864 | 1880 if (event->keyval > '0' && event->keyval <= '9') |
1881 { | |
12232
375f1f3817a8
[gaim-migrate @ 14534]
Richard Laager <rlaager@wiktel.com>
parents:
12216
diff
changeset
|
1882 guint switchto = event->keyval - '1'; |
11581 | 1883 if (switchto < gaim_gtk_conv_window_get_gtkconv_count(win)) |
1884 gtk_notebook_set_current_page(GTK_NOTEBOOK(win->notebook), switchto); | |
4359 | 1885 |
1886 return TRUE; | |
1887 } | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1888 } |
8758 | 1889 |
8105 | 1890 /* If neither CTRL nor ALT were held down... */ |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1891 else |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1892 { |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1893 switch (event->keyval) |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1894 { |
10678
210e38f53b7b
[gaim-migrate @ 12221]
Etan Reisner <pidgin@unreliablesource.net>
parents:
10666
diff
changeset
|
1895 case GDK_Tab: |
9605 | 1896 return tab_complete(conv); |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1897 break; |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1898 |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1899 case GDK_Page_Up: |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1900 gtk_imhtml_page_up(GTK_IMHTML(gtkconv->imhtml)); |
8105 | 1901 return TRUE; |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1902 break; |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1903 |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1904 case GDK_Page_Down: |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1905 gtk_imhtml_page_down(GTK_IMHTML(gtkconv->imhtml)); |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1906 return TRUE; |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1907 break; |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1908 |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1909 } |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1910 } |
4359 | 1911 return FALSE; |
1912 } | |
1913 | |
1914 /* | |
1915 * NOTE: | |
6725
e62a504c83d0
[gaim-migrate @ 7252]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
1916 * This guy just kills a single right click from being propagated any |
e62a504c83d0
[gaim-migrate @ 7252]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
1917 * further. I have no idea *why* we need this, but we do ... It |
4359 | 1918 * prevents right clicks on the GtkTextView in a convo dialog from |
6725
e62a504c83d0
[gaim-migrate @ 7252]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
1919 * going all the way down to the notebook. I suspect a bug in |
4359 | 1920 * GtkTextView, but I'm not ready to point any fingers yet. |
1921 */ | |
1922 static gboolean | |
1923 entry_stop_rclick_cb(GtkWidget *widget, GdkEventButton *event, gpointer data) | |
1924 { | |
1925 if (event->button == 3 && event->type == GDK_BUTTON_PRESS) { | |
1926 /* Right single click */ | |
1927 g_signal_stop_emission_by_name(G_OBJECT(widget), "button_press_event"); | |
1928 | |
1929 return TRUE; | |
1930 } | |
1931 | |
1932 return FALSE; | |
1933 } | |
1934 | |
8173 | 1935 /* |
1936 * If someone tries to type into the conversation backlog of a | |
1937 * conversation window then we yank focus from the conversation backlog | |
1938 * and give it to the text entry box so that people can type | |
1939 * all the live long day and it will get entered into the entry box. | |
1940 */ | |
6057 | 1941 static gboolean |
8105 | 1942 refocus_entry_cb(GtkWidget *widget, GdkEventKey *event, gpointer data) |
6057 | 1943 { |
1944 GaimGtkConversation *gtkconv = data; | |
1945 | |
8237 | 1946 /* If we have a valid key for the conversation display, then exit */ |
8224 | 1947 if ((event->state & GDK_CONTROL_MASK) || |
8237 | 1948 (event->keyval == GDK_F10) || |
1949 (event->keyval == GDK_Shift_L) || | |
1950 (event->keyval == GDK_Shift_R) || | |
1951 (event->keyval == GDK_Escape) || | |
8177 | 1952 (event->keyval == GDK_Up) || |
1953 (event->keyval == GDK_Down) || | |
1954 (event->keyval == GDK_Left) || | |
8191 | 1955 (event->keyval == GDK_Right) || |
1956 (event->keyval == GDK_Home) || | |
9297 | 1957 (event->keyval == GDK_End) || |
1958 (event->keyval == GDK_Tab) || | |
1959 (event->keyval == GDK_ISO_Left_Tab)) | |
8177 | 1960 return FALSE; |
1961 | |
1962 if (event->type == GDK_KEY_RELEASE) | |
1963 gtk_widget_grab_focus(gtkconv->entry); | |
1964 | |
1965 gtk_widget_event(gtkconv->entry, (GdkEvent *)event); | |
1966 | |
1967 return TRUE; | |
6057 | 1968 } |
1969 | |
4359 | 1970 static void |
11672
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1971 gaim_gtkconv_set_active_conversation(GaimConversation *conv) |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1972 { |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1973 GaimGtkConversation *gtkconv; |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1974 |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1975 g_return_if_fail(conv != NULL); |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1976 |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1977 gtkconv = GAIM_GTK_CONVERSATION(conv); |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1978 |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1979 if (gtkconv->active_conv == conv) |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1980 return; |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1981 |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1982 gaim_conversation_close_logs(gtkconv->active_conv); |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1983 |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1984 gtkconv->active_conv = conv; |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1985 |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1986 gaim_conversation_set_logging(conv, |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1987 gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(gtkconv->win->menu.logging))); |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1988 } |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1989 |
11911
fe12abd6b879
[gaim-migrate @ 14202]
Richard Laager <rlaager@wiktel.com>
parents:
11908
diff
changeset
|
1990 void |
11604 | 1991 gaim_gtkconv_switch_active_conversation(GaimConversation *conv) |
1992 { | |
1993 GaimGtkConversation *gtkconv; | |
1994 | |
1995 g_return_if_fail(conv != NULL); | |
1996 | |
1997 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
1998 | |
11672
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
1999 gaim_gtkconv_set_active_conversation(conv); |
11604 | 2000 |
2001 gray_stuff_out(gtkconv); | |
2002 update_typing_icon(gtkconv); | |
2003 | |
2004 gtk_window_set_title(GTK_WINDOW(gtkconv->win->window), | |
2005 gtk_label_get_text(GTK_LABEL(gtkconv->tab_label))); | |
2006 | |
11671
4ebd27e664c4
[gaim-migrate @ 13957]
Luke Schierer <lschiere@pidgin.im>
parents:
11669
diff
changeset
|
2007 gaim_conversation_update(conv, GAIM_CONV_UPDATE_ACCOUNT); |
11604 | 2008 gtk_imhtml_set_protocol_name(GTK_IMHTML(gtkconv->entry), |
2009 gaim_account_get_protocol_name(conv->account)); | |
2010 } | |
2011 | |
2012 static void | |
4673 | 2013 menu_conv_sel_send_cb(GObject *m, gpointer data) |
4359 | 2014 { |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
2015 GaimAccount *account = g_object_get_data(m, "gaim_account"); |
11594 | 2016 gchar *name = g_object_get_data(m, "gaim_buddy_name"); |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
2017 GaimConversation *conv; |
4359 | 2018 |
10059
79fafe47d919
[gaim-migrate @ 11027]
Luke Schierer <lschiere@pidgin.im>
parents:
10053
diff
changeset
|
2019 if (gtk_check_menu_item_get_active((GtkCheckMenuItem*) m) == FALSE) |
79fafe47d919
[gaim-migrate @ 11027]
Luke Schierer <lschiere@pidgin.im>
parents:
10053
diff
changeset
|
2020 return; |
79fafe47d919
[gaim-migrate @ 11027]
Luke Schierer <lschiere@pidgin.im>
parents:
10053
diff
changeset
|
2021 |
11594 | 2022 conv = gaim_conversation_new(GAIM_CONV_TYPE_IM, account, name); |
11604 | 2023 gaim_gtkconv_switch_active_conversation(conv); |
4359 | 2024 } |
2025 | |
2026 static void | |
2027 insert_text_cb(GtkTextBuffer *textbuffer, GtkTextIter *position, | |
2028 gchar *new_text, gint new_text_length, gpointer user_data) | |
2029 { | |
10810 | 2030 GaimGtkConversation *gtkconv = (GaimGtkConversation *)user_data; |
2031 GaimConversation *conv; | |
2032 | |
2033 g_return_if_fail(gtkconv != NULL); | |
11508 | 2034 |
10810 | 2035 conv = gtkconv->active_conv; |
4359 | 2036 |
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5484
diff
changeset
|
2037 if (!gaim_prefs_get_bool("/core/conversations/im/send_typing")) |
4359 | 2038 return; |
2039 | |
10810 | 2040 got_typing_keypress(gtkconv, (gtk_text_iter_is_start(position) && |
2041 gtk_text_iter_is_end(position))); | |
4359 | 2042 } |
2043 | |
2044 static void | |
2045 delete_text_cb(GtkTextBuffer *textbuffer, GtkTextIter *start_pos, | |
2046 GtkTextIter *end_pos, gpointer user_data) | |
2047 { | |
10810 | 2048 GaimGtkConversation *gtkconv = (GaimGtkConversation *)user_data; |
2049 GaimConversation *conv; | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2050 GaimConvIm *im; |
4359 | 2051 |
10810 | 2052 g_return_if_fail(gtkconv != NULL); |
11508 | 2053 |
10810 | 2054 conv = gtkconv->active_conv; |
4359 | 2055 |
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5484
diff
changeset
|
2056 if (!gaim_prefs_get_bool("/core/conversations/im/send_typing")) |
4359 | 2057 return; |
2058 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2059 im = GAIM_CONV_IM(conv); |
4359 | 2060 |
2061 if (gtk_text_iter_is_start(start_pos) && gtk_text_iter_is_end(end_pos)) { | |
2062 | |
2063 /* We deleted all the text, so turn off typing. */ | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2064 if (gaim_conv_im_get_type_again_timeout(im)) |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2065 gaim_conv_im_stop_type_again_timeout(im); |
4359 | 2066 |
2067 serv_send_typing(gaim_conversation_get_gc(conv), | |
6695 | 2068 gaim_conversation_get_name(conv), |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
2069 GAIM_NOT_TYPING); |
4359 | 2070 } |
2071 else { | |
2072 /* We're deleting, but not all of it, so it counts as typing. */ | |
10810 | 2073 got_typing_keypress(gtkconv, FALSE); |
4359 | 2074 } |
2075 } | |
2076 | |
8189 | 2077 /************************************************************************** |
2078 * A bunch of buddy icon functions | |
2079 **************************************************************************/ | |
11581 | 2080 GdkPixbuf * |
2081 gaim_gtkconv_get_tab_icon(GaimConversation *conv, gboolean small_icon) | |
7143 | 2082 { |
10116 | 2083 GaimAccount *account = NULL; |
2084 const char *name = NULL; | |
7143 | 2085 GdkPixbuf *status = NULL; |
2086 | |
10116 | 2087 g_return_val_if_fail(conv != NULL, NULL); |
2088 | |
2089 account = gaim_conversation_get_account(conv); | |
2090 name = gaim_conversation_get_name(conv); | |
2091 | |
2092 g_return_val_if_fail(account != NULL, NULL); | |
2093 g_return_val_if_fail(name != NULL, NULL); | |
2094 | |
11338 | 2095 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) { |
7143 | 2096 GaimBuddy *b = gaim_find_buddy(account, name); |
2097 if (b != NULL) { | |
2098 status = gaim_gtk_blist_get_status_icon((GaimBlistNode*)b, | |
8755
d0364feabf96
[gaim-migrate @ 9510]
Christian Hammond <chipx86@chipx86.com>
parents:
8748
diff
changeset
|
2099 (small_icon ? GAIM_STATUS_ICON_SMALL : GAIM_STATUS_ICON_LARGE)); |
7143 | 2100 } |
2101 } | |
2102 | |
2103 if (!status) { | |
2104 GdkPixbuf *pixbuf; | |
10884 | 2105 pixbuf = gaim_gtk_create_prpl_icon(account); |
7143 | 2106 |
8755
d0364feabf96
[gaim-migrate @ 9510]
Christian Hammond <chipx86@chipx86.com>
parents:
8748
diff
changeset
|
2107 if (small_icon && pixbuf != NULL) |
8748
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2108 { |
7143 | 2109 status = gdk_pixbuf_scale_simple(pixbuf, 15, 15, |
2110 GDK_INTERP_BILINEAR); | |
2111 g_object_unref(pixbuf); | |
2112 } | |
8748
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2113 else |
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2114 status = pixbuf; |
7143 | 2115 } |
2116 return status; | |
2117 } | |
2118 | |
8189 | 2119 static void |
2120 update_tab_icon(GaimConversation *conv) | |
2121 { | |
2122 GaimGtkConversation *gtkconv; | |
11581 | 2123 GaimGtkWindow *win; |
8189 | 2124 GaimAccount *account; |
2125 const char *name; | |
2126 GdkPixbuf *status = NULL; | |
2127 | |
10116 | 2128 g_return_if_fail(conv != NULL); |
2129 | |
8189 | 2130 gtkconv = GAIM_GTK_CONVERSATION(conv); |
11581 | 2131 win = gtkconv->win; |
8189 | 2132 name = gaim_conversation_get_name(conv); |
2133 account = gaim_conversation_get_account(conv); | |
2134 | |
11581 | 2135 status = gaim_gtkconv_get_tab_icon(conv, TRUE); |
8189 | 2136 |
10116 | 2137 g_return_if_fail(status != NULL); |
2138 | |
8189 | 2139 gtk_image_set_from_pixbuf(GTK_IMAGE(gtkconv->icon), status); |
2140 gtk_image_set_from_pixbuf(GTK_IMAGE(gtkconv->menu_icon), status); | |
2141 | |
8748
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2142 if (status != NULL) |
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2143 g_object_unref(status); |
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2144 |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2145 if (gaim_gtk_conv_window_is_active_conversation(conv) && |
11338 | 2146 (gaim_conversation_get_type(conv) != GAIM_CONV_TYPE_IM || |
10504 | 2147 gtkconv->u.im->anim == NULL)) |
8748
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2148 { |
11581 | 2149 status = gaim_gtkconv_get_tab_icon(conv, FALSE); |
2150 | |
2151 gtk_window_set_icon(GTK_WINDOW(win->window), status); | |
8189 | 2152 |
8748
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2153 if (status != NULL) |
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2154 g_object_unref(status); |
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2155 } |
8189 | 2156 } |
2157 | |
2158 static gboolean | |
2159 redraw_icon(gpointer data) | |
2160 { | |
10810 | 2161 GaimGtkConversation *gtkconv = (GaimGtkConversation *)data; |
2162 GaimConversation *conv = gtkconv->active_conv; | |
9318 | 2163 GaimAccount *account; |
2164 GaimPluginProtocolInfo *prpl_info = NULL; | |
8189 | 2165 |
2166 GdkPixbuf *buf; | |
2167 GdkPixbuf *scale; | |
2168 GdkPixmap *pm; | |
2169 GdkBitmap *bm; | |
2170 gint delay; | |
9318 | 2171 int scale_width, scale_height; |
8189 | 2172 |
2173 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
9318 | 2174 account = gaim_conversation_get_account(conv); |
2175 if(account && account->gc) | |
2176 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(account->gc->prpl); | |
8189 | 2177 |
2178 gdk_pixbuf_animation_iter_advance(gtkconv->u.im->iter, NULL); | |
2179 buf = gdk_pixbuf_animation_iter_get_pixbuf(gtkconv->u.im->iter); | |
2180 | |
10483 | 2181 gaim_gtk_buddy_icon_get_scale_size(buf, prpl_info ? &prpl_info->icon_spec : |
9318 | 2182 NULL, &scale_width, &scale_height); |
2183 | |
2184 /* this code is ugly, and scares me */ | |
8189 | 2185 scale = gdk_pixbuf_scale_simple(buf, |
9318 | 2186 MAX(gdk_pixbuf_get_width(buf) * scale_width / |
8189 | 2187 gdk_pixbuf_animation_get_width(gtkconv->u.im->anim), 1), |
9318 | 2188 MAX(gdk_pixbuf_get_height(buf) * scale_height / |
8189 | 2189 gdk_pixbuf_animation_get_height(gtkconv->u.im->anim), 1), |
11324 | 2190 GDK_INTERP_BILINEAR); |
8189 | 2191 |
2192 gdk_pixbuf_render_pixmap_and_mask(scale, &pm, &bm, 100); | |
2193 g_object_unref(G_OBJECT(scale)); | |
2194 gtk_image_set_from_pixmap(GTK_IMAGE(gtkconv->u.im->icon), pm, bm); | |
2195 g_object_unref(G_OBJECT(pm)); | |
2196 gtk_widget_queue_draw(gtkconv->u.im->icon); | |
2197 | |
2198 if (bm) | |
2199 g_object_unref(G_OBJECT(bm)); | |
2200 | |
9131 | 2201 delay = gdk_pixbuf_animation_iter_get_delay_time(gtkconv->u.im->iter); |
10639 | 2202 |
2203 if (delay < 100) | |
9131 | 2204 delay = 100; |
2205 | |
11799
a3c28707ef4d
[gaim-migrate @ 14090]
Gary Kramlich <grim@reaperworld.com>
parents:
11787
diff
changeset
|
2206 gtkconv->u.im->icon_timer = g_timeout_add(delay, redraw_icon, gtkconv); |
8189 | 2207 |
2208 return FALSE; | |
2209 } | |
2210 | |
2211 static void | |
10810 | 2212 start_anim(GtkObject *obj, GaimGtkConversation *gtkconv) |
8189 | 2213 { |
2214 int delay; | |
2215 | |
8228 | 2216 if (gtkconv->u.im->anim == NULL) |
2217 return; | |
2218 | |
8202 | 2219 if (gtkconv->u.im->icon_timer != 0) |
2220 return; | |
2221 | |
8189 | 2222 if (gdk_pixbuf_animation_is_static_image(gtkconv->u.im->anim)) |
2223 return; | |
2224 | |
10639 | 2225 delay = gdk_pixbuf_animation_iter_get_delay_time(gtkconv->u.im->iter); |
2226 | |
2227 if (delay < 100) | |
2228 delay = 100; | |
2229 | |
11799
a3c28707ef4d
[gaim-migrate @ 14090]
Gary Kramlich <grim@reaperworld.com>
parents:
11787
diff
changeset
|
2230 gtkconv->u.im->icon_timer = g_timeout_add(delay, redraw_icon, gtkconv); |
8189 | 2231 } |
2232 | |
2233 static void | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
2234 remove_icon(GaimGtkConversation *gtkconv) |
8189 | 2235 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
2236 GaimConversation *conv = gtkconv->active_conv; |
10456 | 2237 GaimGtkWindow *gtkwin; |
2238 | |
2239 g_return_if_fail(conv != NULL); | |
2240 | |
9887 | 2241 if (gtkconv->u.im->icon_container != NULL) |
2242 gtk_widget_destroy(gtkconv->u.im->icon_container); | |
8189 | 2243 |
2244 if (gtkconv->u.im->anim != NULL) | |
2245 g_object_unref(G_OBJECT(gtkconv->u.im->anim)); | |
2246 | |
2247 if (gtkconv->u.im->icon_timer != 0) | |
2248 g_source_remove(gtkconv->u.im->icon_timer); | |
2249 | |
2250 if (gtkconv->u.im->iter != NULL) | |
2251 g_object_unref(G_OBJECT(gtkconv->u.im->iter)); | |
2252 | |
2253 gtkconv->u.im->icon_timer = 0; | |
2254 gtkconv->u.im->icon = NULL; | |
2255 gtkconv->u.im->anim = NULL; | |
2256 gtkconv->u.im->iter = NULL; | |
10456 | 2257 gtkconv->u.im->icon_container = NULL; |
9687 | 2258 gtkconv->u.im->show_icon = FALSE; |
10456 | 2259 |
11581 | 2260 gtkwin = gtkconv->win; |
10456 | 2261 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(gtkwin->menu.show_icon), FALSE); |
8189 | 2262 } |
2263 | |
9497 | 2264 static void |
9504 | 2265 saveicon_writefile_cb(void *user_data, const char *filename) |
9497 | 2266 { |
10810 | 2267 GaimGtkConversation *gtkconv = (GaimGtkConversation *)user_data; |
2268 GaimConversation *conv = gtkconv->active_conv; | |
9497 | 2269 FILE *fp; |
2270 GaimBuddyIcon *icon; | |
2271 const void *data; | |
2272 size_t len; | |
2273 | |
10589
0f7452b1f777
[gaim-migrate @ 11994]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10572
diff
changeset
|
2274 if ((fp = g_fopen(filename, "wb")) == NULL) { |
9504 | 2275 gaim_notify_error(conv, NULL, _("Unable to open file."), NULL); |
9497 | 2276 return; |
2277 } | |
2278 | |
2279 icon = gaim_conv_im_get_icon(GAIM_CONV_IM(conv)); | |
2280 data = gaim_buddy_icon_get_data(icon, &len); | |
2281 | |
2282 if ((len <= 0) || (data == NULL)) { | |
9504 | 2283 gaim_notify_error(conv, NULL, _("Unable to save icon file to disk."), NULL); |
9497 | 2284 return; |
2285 } | |
2286 | |
2287 fwrite(data, 1, len, fp); | |
2288 fclose(fp); | |
2289 } | |
2290 | |
2291 static void | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
2292 icon_menu_save_cb(GtkWidget *widget, GaimGtkConversation *gtkconv) |
9497 | 2293 { |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
2294 GaimConversation *conv = gtkconv->active_conv; |
10953 | 2295 const gchar *ext; |
9497 | 2296 gchar *buf; |
2297 | |
2298 g_return_if_fail(conv != NULL); | |
9504 | 2299 |
10953 | 2300 ext = gaim_buddy_icon_get_type(gaim_conv_im_get_icon(GAIM_CONV_IM(conv))); |
2301 if (ext == NULL) | |
2302 ext = "icon"; | |
2303 | |
2304 buf = g_strdup_printf("%s.%s", gaim_normalize(conv->account, conv->name), ext); | |
9504 | 2305 |
2306 gaim_request_file(conv, _("Save Icon"), buf, TRUE, | |
11799
a3c28707ef4d
[gaim-migrate @ 14090]
Gary Kramlich <grim@reaperworld.com>
parents:
11787
diff
changeset
|
2307 G_CALLBACK(saveicon_writefile_cb), NULL, gtkconv); |
9497 | 2308 |
2309 g_free(buf); | |
2310 } | |
2311 | |
11581 | 2312 static void |
2313 stop_anim(GtkObject *obj, GaimGtkConversation *gtkconv) | |
2314 { | |
2315 if (gtkconv->u.im->icon_timer != 0) | |
2316 g_source_remove(gtkconv->u.im->icon_timer); | |
2317 | |
2318 gtkconv->u.im->icon_timer = 0; | |
2319 } | |
2320 | |
2321 | |
2322 static void | |
2323 toggle_icon_animate_cb(GtkWidget *w, GaimGtkConversation *gtkconv) | |
2324 { | |
2325 gtkconv->u.im->animate = | |
2326 gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(w)); | |
2327 | |
2328 if (gtkconv->u.im->animate) | |
2329 start_anim(NULL, gtkconv); | |
2330 else | |
2331 stop_anim(NULL, gtkconv); | |
2332 } | |
2333 | |
8189 | 2334 static gboolean |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
2335 icon_menu(GtkObject *obj, GdkEventButton *e, GaimGtkConversation *gtkconv) |
8189 | 2336 { |
2337 static GtkWidget *menu = NULL; | |
2338 GtkWidget *button; | |
2339 | |
2340 if (e->button != 3 || e->type != GDK_BUTTON_PRESS) | |
2341 return FALSE; | |
2342 | |
2343 /* | |
2344 * If a menu already exists, destroy it before creating a new one, | |
2345 * thus freeing-up the memory it occupied. | |
2346 */ | |
2347 if (menu != NULL) | |
2348 gtk_widget_destroy(menu); | |
2349 | |
2350 menu = gtk_menu_new(); | |
2351 | |
2352 if (gtkconv->u.im->anim && | |
2353 !(gdk_pixbuf_animation_is_static_image(gtkconv->u.im->anim))) | |
2354 { | |
2355 gaim_new_check_item(menu, _("Animate"), | |
11799
a3c28707ef4d
[gaim-migrate @ 14090]
Gary Kramlich <grim@reaperworld.com>
parents:
11787
diff
changeset
|
2356 G_CALLBACK(toggle_icon_animate_cb), gtkconv, |
8189 | 2357 gtkconv->u.im->icon_timer); |
2358 } | |
2359 | |
2360 button = gtk_menu_item_new_with_label(_("Hide Icon")); | |
2361 g_signal_connect_swapped(G_OBJECT(button), "activate", | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
2362 G_CALLBACK(remove_icon), gtkconv); |
8189 | 2363 gtk_menu_shell_append(GTK_MENU_SHELL(menu), button); |
2364 gtk_widget_show(button); | |
2365 | |
2366 gaim_new_item_from_stock(menu, _("Save Icon As..."), GTK_STOCK_SAVE_AS, | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
2367 G_CALLBACK(icon_menu_save_cb), gtkconv, |
8189 | 2368 0, 0, NULL); |
2369 | |
2370 gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL, e->button, e->time); | |
2371 | |
2372 return TRUE; | |
2373 } | |
10456 | 2374 |
2375 static void | |
2376 menu_buddyicon_cb(gpointer data, guint action, GtkWidget *widget) | |
2377 { | |
11581 | 2378 GaimGtkWindow *win = data; |
10456 | 2379 GaimConversation *conv; |
2380 GaimGtkConversation *gtkconv; | |
2381 gboolean active; | |
2382 | |
11581 | 2383 conv = gaim_gtk_conv_window_get_active_conversation(win); |
10456 | 2384 |
2385 if (!conv) | |
2386 return; | |
2387 | |
11338 | 2388 g_return_if_fail(gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM); |
10456 | 2389 |
2390 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
2391 | |
2392 active = gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(widget)); | |
2393 gtkconv->u.im->show_icon = active; | |
2394 if (active) | |
2395 gaim_gtkconv_update_buddy_icon(conv); | |
2396 else | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
2397 remove_icon(gtkconv); |
10456 | 2398 } |
2399 | |
8189 | 2400 /************************************************************************** |
2401 * End of the bunch of buddy icon functions | |
2402 **************************************************************************/ | |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2403 void |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2404 gaim_gtkconv_present_conversation(GaimConversation *conv) |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2405 { |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2406 GaimGtkConversation *gtkconv = GAIM_GTK_CONVERSATION(conv); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2407 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2408 if(gtkconv->win==hidden_convwin) { |
12288
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
2409 gaim_gtk_conv_window_remove_gtkconv(hidden_convwin, gtkconv); |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2410 gaim_gtkconv_placement_place(gtkconv); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2411 } |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2412 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2413 gaim_gtkconv_set_active_conversation(conv); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2414 gaim_gtk_conv_window_switch_gtkconv(gtkconv->win, gtkconv); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2415 gaim_gtk_conv_window_raise(gtkconv->win); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2416 gtk_window_present(GTK_WINDOW(gtkconv->win->window)); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2417 } |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
2418 |
12468
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2419 GList * |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2420 gaim_gtk_conversations_find_unseen_list(GaimConversationType type, |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2421 GaimUnseenState min_state, |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2422 gboolean hidden_only, |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2423 guint max_count) |
12021
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2424 { |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2425 GList *l; |
12468
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2426 GList *r = NULL; |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2427 guint c = 0; |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2428 |
12469
f4efe0c0de88
[gaim-migrate @ 14779]
Richard Laager <rlaager@wiktel.com>
parents:
12468
diff
changeset
|
2429 if (type == GAIM_CONV_TYPE_IM) { |
12021
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2430 l = gaim_get_ims(); |
12469
f4efe0c0de88
[gaim-migrate @ 14779]
Richard Laager <rlaager@wiktel.com>
parents:
12468
diff
changeset
|
2431 } else if (type == GAIM_CONV_TYPE_CHAT) { |
12021
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2432 l = gaim_get_chats(); |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2433 } else { |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2434 l = gaim_get_conversations(); |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2435 } |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2436 |
12469
f4efe0c0de88
[gaim-migrate @ 14779]
Richard Laager <rlaager@wiktel.com>
parents:
12468
diff
changeset
|
2437 for (; l != NULL && (max_count == 0 || c < max_count); l = l->next) { |
12021
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2438 GaimConversation *conv = (GaimConversation*)l->data; |
12468
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2439 GaimGtkConversation *gtkconv = GAIM_GTK_CONVERSATION(conv); |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2440 |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2441 if(gtkconv->active_conv != conv) |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2442 continue; |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2443 |
12469
f4efe0c0de88
[gaim-migrate @ 14779]
Richard Laager <rlaager@wiktel.com>
parents:
12468
diff
changeset
|
2444 if (gtkconv->unseen_state >= min_state |
f4efe0c0de88
[gaim-migrate @ 14779]
Richard Laager <rlaager@wiktel.com>
parents:
12468
diff
changeset
|
2445 && (!hidden_only || |
f4efe0c0de88
[gaim-migrate @ 14779]
Richard Laager <rlaager@wiktel.com>
parents:
12468
diff
changeset
|
2446 (hidden_only && gtkconv->win == hidden_convwin))) { |
12468
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2447 |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2448 r = g_list_prepend(r, conv); |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2449 c++; |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2450 } |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2451 } |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2452 |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2453 return r; |
12021
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
2454 } |
8189 | 2455 |
12175
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2456 static void |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2457 unseen_conv_menu_cb(GtkMenuItem *item, GaimConversation *conv) |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2458 { |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2459 g_return_if_fail(conv != NULL); |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2460 gaim_gtkconv_present_conversation(conv); |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2461 } |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2462 |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2463 guint |
12468
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2464 gaim_gtk_conversations_fill_menu(GtkWidget *menu, GList *convs) |
12175
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2465 { |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2466 GList *l; |
12468
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2467 guint ret=0; |
12175
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2468 |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2469 g_return_val_if_fail(menu != NULL, 0); |
12468
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2470 g_return_val_if_fail(convs != NULL, 0); |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2471 |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2472 for (l = convs; l != NULL ; l = l->next) { |
12175
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2473 GaimConversation *conv = (GaimConversation*)l->data; |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2474 GaimGtkConversation *gtkconv = GAIM_GTK_CONVERSATION(conv); |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2475 |
12468
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2476 GtkWidget *icon = gtk_image_new(); |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2477 GdkPixbuf *pbuf = gaim_gtkconv_get_tab_icon(conv, TRUE); |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2478 GtkWidget *item; |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2479 gchar *text = g_strdup_printf("%s (%d)", |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2480 gtk_label_get_text(GTK_LABEL(gtkconv->tab_label)), |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2481 gtkconv->unseen_count); |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2482 |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2483 gtk_image_set_from_pixbuf(GTK_IMAGE(icon), pbuf); |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2484 g_object_unref(pbuf); |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2485 |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2486 item = gtk_image_menu_item_new_with_label(text); |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2487 gtk_image_menu_item_set_image(GTK_IMAGE_MENU_ITEM(item), icon); |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2488 g_signal_connect(G_OBJECT(item), "activate", G_CALLBACK(unseen_conv_menu_cb), conv); |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2489 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2490 g_free(text); |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
2491 ret++; |
12175
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2492 } |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2493 |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2494 return ret; |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2495 } |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
2496 |
11581 | 2497 GaimGtkWindow * |
2498 gaim_gtkconv_get_window(GaimGtkConversation *gtkconv) | |
2499 { | |
2500 g_return_val_if_fail(gtkconv != NULL, NULL); | |
2501 return gtkconv->win; | |
2502 } | |
2503 | |
2504 static GtkItemFactoryEntry menu_items[] = | |
2505 { | |
2506 /* Conversation menu */ | |
2507 { N_("/_Conversation"), NULL, NULL, 0, "<Branch>" }, | |
2508 | |
2509 { N_("/Conversation/New Instant _Message..."), "<CTL>M", menu_new_conv_cb, | |
2510 0, "<StockItem>", GAIM_STOCK_IM }, | |
2511 | |
2512 { "/Conversation/sep0", NULL, NULL, 0, "<Separator>" }, | |
2513 | |
2514 { N_("/Conversation/_Find..."), NULL, menu_find_cb, 0, | |
2515 "<StockItem>", GTK_STOCK_FIND }, | |
12191
bc2b9f925979
[gaim-migrate @ 14493]
Richard Laager <rlaager@wiktel.com>
parents:
12190
diff
changeset
|
2516 { N_("/Conversation/View _Log"), NULL, menu_view_log_cb, 0, "<StockItem>", GAIM_STOCK_LOG }, |
11581 | 2517 { N_("/Conversation/_Save As..."), NULL, menu_save_as_cb, 0, |
2518 "<StockItem>", GTK_STOCK_SAVE_AS }, | |
12240 | 2519 { N_("/Conversation/Clea_r"), "<CTL>L", menu_clear_cb, 0, "<StockItem>", GTK_STOCK_CLEAR }, |
11581 | 2520 |
2521 { "/Conversation/sep1", NULL, NULL, 0, "<Separator>" }, | |
2522 | |
2523 { N_("/Conversation/Se_nd File..."), NULL, menu_send_file_cb, 0, "<StockItem>", GAIM_STOCK_FILE_TRANSFER }, | |
2524 { N_("/Conversation/Add Buddy _Pounce..."), NULL, menu_add_pounce_cb, | |
12191
bc2b9f925979
[gaim-migrate @ 14493]
Richard Laager <rlaager@wiktel.com>
parents:
12190
diff
changeset
|
2525 0, "<StockItem>", GAIM_STOCK_POUNCE }, |
11581 | 2526 { N_("/Conversation/_Get Info"), "<CTL>O", menu_get_info_cb, 0, |
2527 "<StockItem>", GAIM_STOCK_INFO }, | |
2528 { N_("/Conversation/In_vite..."), NULL, menu_invite_cb, 0, | |
2529 "<StockItem>", GAIM_STOCK_INVITE }, | |
2530 | |
2531 { "/Conversation/sep2", NULL, NULL, 0, "<Separator>" }, | |
2532 | |
2533 { N_("/Conversation/Al_ias..."), NULL, menu_alias_cb, 0, | |
2534 "<StockItem>", GAIM_STOCK_EDIT }, | |
2535 { N_("/Conversation/_Block..."), NULL, menu_block_cb, 0, | |
2536 "<StockItem>", GAIM_STOCK_BLOCK }, | |
2537 { N_("/Conversation/_Add..."), NULL, menu_add_remove_cb, 0, | |
2538 "<StockItem>", GTK_STOCK_ADD }, | |
2539 { N_("/Conversation/_Remove..."), NULL, menu_add_remove_cb, 0, | |
2540 "<StockItem>", GTK_STOCK_REMOVE }, | |
2541 | |
2542 { "/Conversation/sep3", NULL, NULL, 0, "<Separator>" }, | |
2543 | |
2544 { N_("/Conversation/Insert Lin_k..."), NULL, menu_insert_link_cb, 0, | |
2545 "<StockItem>", GAIM_STOCK_LINK }, | |
2546 { N_("/Conversation/Insert Imag_e..."), NULL, menu_insert_image_cb, 0, | |
2547 "<StockItem>", GAIM_STOCK_IMAGE }, | |
2548 | |
2549 { "/Conversation/sep4", NULL, NULL, 0, "<Separator>" }, | |
2550 | |
2551 { N_("/Conversation/_Close"), NULL, menu_close_conv_cb, 0, | |
2552 "<StockItem>", GTK_STOCK_CLOSE }, | |
2553 | |
2554 /* Options */ | |
2555 { N_("/_Options"), NULL, NULL, 0, "<Branch>" }, | |
2556 { N_("/Options/Enable _Logging"), NULL, menu_logging_cb, 0, "<CheckItem>" }, | |
2557 { N_("/Options/Enable _Sounds"), NULL, menu_sounds_cb, 0, "<CheckItem>" }, | |
12395
4ed7663099ca
[gaim-migrate @ 14702]
Luke Schierer <lschiere@pidgin.im>
parents:
12363
diff
changeset
|
2558 { N_("/Options/Show Buddy _Icon"), NULL, menu_buddyicon_cb, 0, "<CheckItem>" }, |
4ed7663099ca
[gaim-migrate @ 14702]
Luke Schierer <lschiere@pidgin.im>
parents:
12363
diff
changeset
|
2559 { "/Options/sep0", NULL, NULL, 0, "<Separator>" }, |
11581 | 2560 { N_("/Options/Show Formatting _Toolbars"), NULL, menu_toolbar_cb, 0, "<CheckItem>" }, |
2561 { N_("/Options/Show Ti_mestamps"), "F2", menu_timestamps_cb, 0, "<CheckItem>" }, | |
2562 }; | |
2563 | |
2564 static const int menu_item_count = | |
2565 sizeof(menu_items) / sizeof(*menu_items); | |
2566 | |
2567 static char * | |
2568 item_factory_translate_func (const char *path, gpointer func_data) | |
2569 { | |
2570 return _((char *)path); | |
2571 } | |
2572 | |
12594
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2573 static void |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2574 sound_method_pref_changed_cb(const char *name, GaimPrefType type, gpointer value, gpointer data) |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2575 { |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2576 GaimGtkWindow *win = data; |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2577 const char *method = value; |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2578 |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2579 if (!strcmp(method, "none")) |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2580 { |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2581 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(win->menu.sounds), |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2582 FALSE); |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2583 gtk_widget_set_sensitive(win->menu.sounds, FALSE); |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2584 } |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2585 else |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2586 { |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2587 GaimGtkConversation *gtkconv = gaim_gtk_conv_window_get_active_gtkconv(win); |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2588 |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2589 if (gtkconv != NULL) |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2590 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(win->menu.sounds), |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2591 TRUE); |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2592 gtk_widget_set_sensitive(win->menu.sounds, TRUE); |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2593 |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2594 } |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2595 } |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2596 |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2597 static void |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2598 show_buddy_icons_pref_changed_cb(const char *name, GaimPrefType type, gpointer value, gpointer data) |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2599 { |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2600 GaimGtkWindow *win = data; |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2601 gboolean show_icons = GPOINTER_TO_INT(value); |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2602 |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2603 if (!show_icons) |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2604 { |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2605 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(win->menu.show_icon), |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2606 FALSE); |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2607 gtk_widget_set_sensitive(win->menu.show_icon, FALSE); |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2608 } |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2609 else |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2610 { |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2611 GaimGtkConversation *gtkconv = gaim_gtk_conv_window_get_active_gtkconv(win); |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2612 |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2613 if (gtkconv != NULL) |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2614 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(win->menu.show_icon), |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2615 TRUE); |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2616 gtk_widget_set_sensitive(win->menu.show_icon, TRUE); |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2617 |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2618 } |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2619 } |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2620 |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2621 |
11581 | 2622 static GtkWidget * |
2623 setup_menubar(GaimGtkWindow *win) | |
2624 { | |
2625 GtkAccelGroup *accel_group; | |
12594
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2626 const char *method; |
11581 | 2627 |
2628 accel_group = gtk_accel_group_new (); | |
2629 gtk_window_add_accel_group(GTK_WINDOW(win->window), accel_group); | |
2630 g_object_unref(accel_group); | |
2631 | |
2632 win->menu.item_factory = | |
2633 gtk_item_factory_new(GTK_TYPE_MENU_BAR, "<main>", accel_group); | |
2634 | |
2635 gtk_item_factory_set_translate_func(win->menu.item_factory, | |
2636 item_factory_translate_func, | |
2637 NULL, NULL); | |
2638 | |
2639 gtk_item_factory_create_items(win->menu.item_factory, menu_item_count, | |
2640 menu_items, win); | |
2641 g_signal_connect(G_OBJECT(accel_group), "accel-changed", | |
2642 G_CALLBACK(gaim_gtk_save_accels_cb), NULL); | |
2643 | |
2644 | |
2645 win->menu.menubar = | |
2646 gtk_item_factory_get_widget(win->menu.item_factory, "<main>"); | |
2647 | |
2648 | |
2649 win->menu.view_log = | |
2650 gtk_item_factory_get_widget(win->menu.item_factory, | |
2651 N_("/Conversation/View Log")); | |
2652 | |
2653 /* --- */ | |
2654 | |
2655 win->menu.send_file = | |
2656 gtk_item_factory_get_widget(win->menu.item_factory, | |
2657 N_("/Conversation/Send File...")); | |
2658 | |
2659 win->menu.add_pounce = | |
2660 gtk_item_factory_get_widget(win->menu.item_factory, | |
2661 N_("/Conversation/Add Buddy Pounce...")); | |
2662 | |
2663 /* --- */ | |
2664 | |
2665 win->menu.get_info = | |
2666 gtk_item_factory_get_widget(win->menu.item_factory, | |
2667 N_("/Conversation/Get Info")); | |
2668 | |
2669 win->menu.invite = | |
2670 gtk_item_factory_get_widget(win->menu.item_factory, | |
2671 N_("/Conversation/Invite...")); | |
2672 | |
2673 /* --- */ | |
2674 | |
2675 win->menu.alias = | |
2676 gtk_item_factory_get_widget(win->menu.item_factory, | |
2677 N_("/Conversation/Alias...")); | |
2678 | |
2679 win->menu.block = | |
2680 gtk_item_factory_get_widget(win->menu.item_factory, | |
2681 N_("/Conversation/Block...")); | |
2682 | |
2683 win->menu.add = | |
2684 gtk_item_factory_get_widget(win->menu.item_factory, | |
2685 N_("/Conversation/Add...")); | |
2686 | |
2687 win->menu.remove = | |
2688 gtk_item_factory_get_widget(win->menu.item_factory, | |
2689 N_("/Conversation/Remove...")); | |
2690 | |
2691 /* --- */ | |
2692 | |
2693 win->menu.insert_link = | |
2694 gtk_item_factory_get_widget(win->menu.item_factory, | |
2695 N_("/Conversation/Insert Link...")); | |
2696 | |
2697 win->menu.insert_image = | |
2698 gtk_item_factory_get_widget(win->menu.item_factory, | |
2699 N_("/Conversation/Insert Image...")); | |
2700 | |
2701 /* --- */ | |
2702 | |
2703 win->menu.logging = | |
2704 gtk_item_factory_get_widget(win->menu.item_factory, | |
2705 N_("/Options/Enable Logging")); | |
2706 win->menu.sounds = | |
2707 gtk_item_factory_get_widget(win->menu.item_factory, | |
2708 N_("/Options/Enable Sounds")); | |
12594
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2709 method = gaim_prefs_get_string("/gaim/gtk/sound/method"); |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2710 if (!strcmp(method, "none")) |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2711 { |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2712 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(win->menu.sounds), |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2713 FALSE); |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2714 gtk_widget_set_sensitive(win->menu.sounds, FALSE); |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2715 } |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2716 gaim_prefs_connect_callback(win, "/gaim/gtk/sound/method", |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2717 sound_method_pref_changed_cb, win); |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2718 |
11581 | 2719 win->menu.show_formatting_toolbar = |
2720 gtk_item_factory_get_widget(win->menu.item_factory, | |
2721 N_("/Options/Show Formatting Toolbars")); | |
2722 win->menu.show_timestamps = | |
2723 gtk_item_factory_get_widget(win->menu.item_factory, | |
2724 N_("/Options/Show Timestamps")); | |
2725 win->menu.show_icon = | |
2726 gtk_item_factory_get_widget(win->menu.item_factory, | |
2727 N_("/Options/Show Buddy Icon")); | |
12594
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2728 if (!gaim_prefs_get_bool("/gaim/gtk/conversations/im/show_buddy_icons")) |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2729 { |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2730 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(win->menu.show_icon), |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2731 FALSE); |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2732 gtk_widget_set_sensitive(win->menu.show_icon, FALSE); |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2733 } |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2734 gaim_prefs_connect_callback(win, "/gaim/gtk/conversations/im/show_buddy_icons", |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
2735 show_buddy_icons_pref_changed_cb, win); |
11581 | 2736 |
2737 win->menu.tray = gaim_gtk_menu_tray_new(); | |
2738 gtk_menu_shell_append(GTK_MENU_SHELL(win->menu.menubar), | |
2739 win->menu.tray); | |
2740 gtk_widget_show(win->menu.tray); | |
2741 | |
2742 gtk_widget_show(win->menu.menubar); | |
2743 | |
2744 return win->menu.menubar; | |
2745 } | |
2746 | |
4359 | 2747 |
2748 /************************************************************************** | |
2749 * Utility functions | |
2750 **************************************************************************/ | |
2751 | |
2752 static void | |
10810 | 2753 got_typing_keypress(GaimGtkConversation *gtkconv, gboolean first) |
4359 | 2754 { |
10810 | 2755 GaimConversation *conv = gtkconv->active_conv; |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2756 GaimConvIm *im; |
4685 | 2757 |
4359 | 2758 /* |
2759 * We know we got something, so we at least have to make sure we don't | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
2760 * send GAIM_TYPED any time soon. |
4359 | 2761 */ |
2762 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2763 im = GAIM_CONV_IM(conv); |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2764 |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2765 if (gaim_conv_im_get_type_again_timeout(im)) |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2766 gaim_conv_im_stop_type_again_timeout(im); |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2767 |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2768 gaim_conv_im_start_type_again_timeout(im); |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2769 |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2770 if (first || (gaim_conv_im_get_type_again(im) != 0 && |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2771 time(NULL) > gaim_conv_im_get_type_again(im))) { |
4359 | 2772 |
2773 int timeout = serv_send_typing(gaim_conversation_get_gc(conv), | |
2774 (char *)gaim_conversation_get_name(conv), | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
2775 GAIM_TYPING); |
4359 | 2776 |
2777 if (timeout) | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2778 gaim_conv_im_set_type_again(im, time(NULL) + timeout); |
4359 | 2779 else |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2780 gaim_conv_im_set_type_again(im, 0); |
4359 | 2781 } |
2782 } | |
2783 | |
4736 | 2784 static void |
10810 | 2785 update_typing_icon(GaimGtkConversation *gtkconv) |
4736 | 2786 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
2787 GaimGtkWindow *gtkwin; |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2788 GaimConvIm *im = NULL; |
10810 | 2789 GaimConversation *conv = gtkconv->active_conv; |
12008 | 2790 char *stock_id, *tooltip; |
11508 | 2791 |
11581 | 2792 gtkwin = gtkconv->win; |
4736 | 2793 |
12008 | 2794 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2795 im = GAIM_CONV_IM(conv); |
4736 | 2796 |
12008 | 2797 if (gtkwin->menu.typing_icon) { |
2798 gtk_widget_hide(gtkwin->menu.typing_icon); | |
11787
c9188d3eb9d3
[gaim-migrate @ 14078]
Gary Kramlich <grim@reaperworld.com>
parents:
11780
diff
changeset
|
2799 } |
c9188d3eb9d3
[gaim-migrate @ 14078]
Gary Kramlich <grim@reaperworld.com>
parents:
11780
diff
changeset
|
2800 |
12008 | 2801 if (!im || (gaim_conv_im_get_typing_state(im) == GAIM_NOT_TYPING)) |
2802 return; | |
2803 | |
2804 if (gaim_conv_im_get_typing_state(im) == GAIM_TYPING) { | |
2805 stock_id = GAIM_STOCK_TYPING; | |
2806 tooltip = _("User is typing..."); | |
2807 } else { | |
2808 stock_id = GAIM_STOCK_TYPED; | |
2809 tooltip = _("User has typed something and stopped"); | |
11787
c9188d3eb9d3
[gaim-migrate @ 14078]
Gary Kramlich <grim@reaperworld.com>
parents:
11780
diff
changeset
|
2810 } |
12008 | 2811 |
2812 if (gtkwin->menu.typing_icon == NULL) | |
2813 { | |
2814 gtkwin->menu.typing_icon = gtk_image_new_from_stock(stock_id, GTK_ICON_SIZE_MENU); | |
11787
c9188d3eb9d3
[gaim-migrate @ 14078]
Gary Kramlich <grim@reaperworld.com>
parents:
11780
diff
changeset
|
2815 gaim_gtk_menu_tray_append(GAIM_GTK_MENU_TRAY(gtkwin->menu.tray), |
11908
34ea75bdd0c9
[gaim-migrate @ 14199]
Richard Laager <rlaager@wiktel.com>
parents:
11869
diff
changeset
|
2816 gtkwin->menu.typing_icon, |
12008 | 2817 tooltip); |
4736 | 2818 } |
12008 | 2819 else |
2820 { | |
2821 gtk_image_set_from_stock(GTK_IMAGE(gtkwin->menu.typing_icon), stock_id, GTK_ICON_SIZE_MENU); | |
2822 gaim_gtk_menu_tray_set_tooltip(GAIM_GTK_MENU_TRAY(gtkwin->menu.tray), | |
2823 gtkwin->menu.typing_icon, | |
2824 tooltip); | |
2825 } | |
2826 | |
2827 gtk_widget_show(gtkwin->menu.typing_icon); | |
4736 | 2828 } |
2829 | |
4685 | 2830 static gboolean |
11594 | 2831 update_send_to_selection(GaimGtkWindow *win) |
4359 | 2832 { |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
2833 GaimAccount *account; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
2834 GaimConversation *conv; |
4359 | 2835 GtkWidget *menu; |
2836 GList *child; | |
11594 | 2837 GaimBuddy *b; |
11581 | 2838 |
2839 conv = gaim_gtk_conv_window_get_active_conversation(win); | |
4359 | 2840 |
5860
52d5fad43950
[gaim-migrate @ 6291]
Christian Hammond <chipx86@chipx86.com>
parents:
5858
diff
changeset
|
2841 if (conv == NULL) |
52d5fad43950
[gaim-migrate @ 6291]
Christian Hammond <chipx86@chipx86.com>
parents:
5858
diff
changeset
|
2842 return FALSE; |
5678
619bca773b2e
[gaim-migrate @ 6096]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
2843 |
619bca773b2e
[gaim-migrate @ 6096]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
2844 account = gaim_conversation_get_account(conv); |
11581 | 2845 |
11594 | 2846 if (win->menu.send_to == NULL) |
4685 | 2847 return FALSE; |
4364
fa56829b9587
[gaim-migrate @ 4630]
Christian Hammond <chipx86@chipx86.com>
parents:
4363
diff
changeset
|
2848 |
11594 | 2849 if (!(b = gaim_find_buddy(account, conv->name))) |
2850 return FALSE; | |
2851 | |
2852 | |
2853 gtk_widget_show(win->menu.send_to); | |
4359 | 2854 |
2855 menu = gtk_menu_item_get_submenu( | |
11594 | 2856 GTK_MENU_ITEM(win->menu.send_to)); |
4359 | 2857 |
2858 for (child = gtk_container_get_children(GTK_CONTAINER(menu)); | |
2859 child != NULL; | |
2860 child = child->next) { | |
2861 | |
2862 GtkWidget *item = child->data; | |
11594 | 2863 GaimBuddy *item_buddy; |
2864 GaimAccount *item_account = g_object_get_data(G_OBJECT(item), "gaim_account"); | |
2865 gchar *buddy_name = g_object_get_data(G_OBJECT(item), | |
2866 "gaim_buddy_name"); | |
2867 item_buddy = gaim_find_buddy(item_account, buddy_name); | |
2868 | |
2869 if (b == item_buddy) { | |
4359 | 2870 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(item), TRUE); |
2871 break; | |
2872 } | |
2873 } | |
6030
54c37db13279
[gaim-migrate @ 6480]
Christian Hammond <chipx86@chipx86.com>
parents:
6016
diff
changeset
|
2874 |
4685 | 2875 return FALSE; |
4359 | 2876 } |
2877 | |
2878 static void | |
11594 | 2879 create_sendto_item(GtkWidget *menu, GtkSizeGroup *sg, GSList **group, GaimBuddy *bud) |
2880 { | |
2881 GaimAccount *account; | |
2882 GtkWidget *box; | |
2883 GtkWidget *label; | |
2884 GtkWidget *image; | |
2885 GtkWidget *menuitem; | |
11625 | 2886 GdkPixbuf *pixbuf; |
11616 | 2887 gchar *text; |
11594 | 2888 |
2889 account = bud->account; | |
2890 | |
2891 /* Create a pixmap for the protocol icon. */ | |
11625 | 2892 pixbuf = gaim_gtk_blist_get_status_icon((GaimBlistNode*)bud, GAIM_STATUS_ICON_SMALL); |
11594 | 2893 /* Now convert it to GtkImage */ |
2894 if (pixbuf == NULL) | |
2895 image = gtk_image_new(); | |
2896 else | |
11625 | 2897 image = gtk_image_new_from_pixbuf(pixbuf); |
11594 | 2898 |
2899 gtk_size_group_add_widget(sg, image); | |
2900 | |
2901 g_object_unref(G_OBJECT(pixbuf)); | |
2902 | |
2903 /* Make our menu item */ | |
11616 | 2904 text = g_strdup_printf("%s (%s)", gaim_buddy_get_name(bud), gaim_account_get_username(bud->account)); |
2905 menuitem = gtk_radio_menu_item_new_with_label(*group, text); | |
2906 g_free(text); | |
11594 | 2907 *group = gtk_radio_menu_item_get_group(GTK_RADIO_MENU_ITEM(menuitem)); |
2908 | |
2909 /* Do some evil, see some evil, speak some evil. */ | |
2910 box = gtk_hbox_new(FALSE, 0); | |
2911 | |
2912 label = gtk_bin_get_child(GTK_BIN(menuitem)); | |
2913 g_object_ref(label); | |
2914 gtk_container_remove(GTK_CONTAINER(menuitem), label); | |
2915 | |
2916 gtk_box_pack_start(GTK_BOX(box), image, FALSE, FALSE, 0); | |
2917 gtk_box_pack_start(GTK_BOX(box), label, TRUE, TRUE, 4); | |
2918 | |
2919 g_object_unref(label); | |
2920 | |
2921 gtk_container_add(GTK_CONTAINER(menuitem), box); | |
2922 | |
2923 gtk_widget_show(label); | |
2924 gtk_widget_show(image); | |
2925 gtk_widget_show(box); | |
2926 | |
2927 /* Set our data and callbacks. */ | |
2928 g_object_set_data(G_OBJECT(menuitem), "gaim_account", account); | |
2929 g_object_set_data_full(G_OBJECT(menuitem), "gaim_buddy_name", g_strdup(gaim_buddy_get_name(bud)), g_free); | |
2930 | |
2931 g_signal_connect(G_OBJECT(menuitem), "activate", | |
2932 G_CALLBACK(menu_conv_sel_send_cb), NULL); | |
2933 | |
2934 gtk_widget_show(menuitem); | |
2935 gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem); | |
2936 } | |
2937 | |
2938 static void | |
2939 generate_send_to_items(GaimGtkWindow *win) | |
11581 | 2940 { |
4359 | 2941 GtkWidget *menu; |
2942 GSList *group = NULL; | |
4669
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2943 GtkSizeGroup *sg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL); |
11594 | 2944 GaimGtkConversation *gtkconv; |
2945 GSList *l, *buds; | |
2946 | |
2947 g_return_if_fail(win != NULL); | |
2948 | |
2949 gtkconv = gaim_gtk_conv_window_get_active_gtkconv(win); | |
2950 | |
11604 | 2951 g_return_if_fail(gtkconv != NULL); |
2952 | |
11594 | 2953 if (win->menu.send_to != NULL) |
2954 gtk_widget_destroy(win->menu.send_to); | |
2955 | |
12286
255e6912607b
[gaim-migrate @ 14590]
Etan Reisner <pidgin@unreliablesource.net>
parents:
12272
diff
changeset
|
2956 /* Build the Send To menu */ |
11594 | 2957 win->menu.send_to = gtk_menu_item_new_with_mnemonic(_("_Send To")); |
2958 gtk_widget_show(win->menu.send_to); | |
4359 | 2959 |
2960 menu = gtk_menu_new(); | |
11581 | 2961 gtk_menu_shell_insert(GTK_MENU_SHELL(win->menu.menubar), |
11594 | 2962 win->menu.send_to, 2); |
2963 gtk_menu_item_set_submenu(GTK_MENU_ITEM(win->menu.send_to), menu); | |
4359 | 2964 |
2965 gtk_widget_show(menu); | |
2966 | |
11604 | 2967 if (gtkconv->active_conv->type == GAIM_CONV_TYPE_IM) { |
2968 buds = gaim_find_buddies(gtkconv->active_conv->account, gtkconv->active_conv->name); | |
2969 for (l = buds; l != NULL; l = l->next) { | |
2970 GaimBuddy *b; | |
2971 GaimBlistNode *node; | |
2972 | |
2973 b = l->data; | |
2974 node = (GaimBlistNode *) gaim_buddy_get_contact(b); | |
2975 | |
2976 for (node = node->child; node != NULL; node = node->next) | |
2977 if (GAIM_BLIST_NODE_IS_BUDDY(node) && gaim_account_is_connected(((GaimBuddy *)node)->account)) | |
2978 create_sendto_item(menu, sg, &group, (GaimBuddy *) node); | |
2979 } | |
2980 | |
2981 g_slist_free(buds); | |
4359 | 2982 } |
2983 | |
4669
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2984 g_object_unref(sg); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2985 |
11594 | 2986 gtk_widget_show(win->menu.send_to); |
12455 | 2987 /* TODO: This should never be insensitive. Possibly hidden or not. */ |
11594 | 2988 if (!group) |
2989 gtk_widget_set_sensitive(win->menu.send_to, FALSE); | |
2990 update_send_to_selection(win); | |
4359 | 2991 } |
2992 | |
2993 static GList * | |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
2994 generate_invite_user_names(GaimConnection *gc) |
4359 | 2995 { |
6695 | 2996 GaimBlistNode *gnode,*cnode,*bnode; |
4359 | 2997 static GList *tmp = NULL; |
2998 | |
2999 if (tmp) | |
3000 g_list_free(tmp); | |
3001 | |
3002 tmp = g_list_append(NULL, ""); | |
3003 | |
3004 if (gc != NULL) { | |
4785 | 3005 for(gnode = gaim_get_blist()->root; gnode; gnode = gnode->next) { |
3006 if(!GAIM_BLIST_NODE_IS_GROUP(gnode)) | |
3007 continue; | |
6695 | 3008 for(cnode = gnode->child; cnode; cnode = cnode->next) { |
3009 if(!GAIM_BLIST_NODE_IS_CONTACT(cnode)) | |
4785 | 3010 continue; |
6695 | 3011 for(bnode = cnode->child; bnode; bnode = bnode->next) { |
3012 GaimBuddy *buddy; | |
3013 | |
3014 if(!GAIM_BLIST_NODE_IS_BUDDY(bnode)) | |
3015 continue; | |
3016 | |
3017 buddy = (GaimBuddy *)bnode; | |
3018 | |
3019 if (buddy->account == gc->account && | |
3020 GAIM_BUDDY_IS_ONLINE(buddy)) | |
10572 | 3021 tmp = g_list_insert_sorted(tmp, buddy->name, |
3022 (GCompareFunc)g_utf8_collate); | |
6695 | 3023 } |
4359 | 3024 } |
3025 } | |
3026 } | |
3027 | |
3028 return tmp; | |
3029 } | |
3030 | |
9498 | 3031 static GdkPixbuf * |
9554 | 3032 get_chat_buddy_status_icon(GaimConvChat *chat, const char *name, GaimConvChatBuddyFlags flags) |
9498 | 3033 { |
9554 | 3034 GdkPixbuf *pixbuf, *scale, *scale2; |
9498 | 3035 char *filename; |
10274 | 3036 const char *image = NULL; |
9554 | 3037 |
3038 if (flags & GAIM_CBFLAGS_FOUNDER) { | |
10274 | 3039 image = "founder.png"; |
9554 | 3040 } else if (flags & GAIM_CBFLAGS_OP) { |
10274 | 3041 image = "op.png"; |
9554 | 3042 } else if (flags & GAIM_CBFLAGS_HALFOP) { |
10274 | 3043 image = "halfop.png"; |
9554 | 3044 } else if (flags & GAIM_CBFLAGS_VOICE) { |
10274 | 3045 image = "voice.png"; |
9554 | 3046 } else if ((!flags) && gaim_conv_chat_is_user_ignored(chat, name)) { |
10274 | 3047 image = "ignored.png"; |
3048 } else { | |
3049 return NULL; | |
9554 | 3050 } |
10274 | 3051 |
3052 filename = g_build_filename(DATADIR, "pixmaps", "gaim", "status", "default", image, NULL); | |
3053 pixbuf = gdk_pixbuf_new_from_file(filename, NULL); | |
3054 g_free(filename); | |
3055 | |
3056 if (!pixbuf) | |
3057 return NULL; | |
3058 | |
3059 scale = gdk_pixbuf_scale_simple(pixbuf, 15, 15, GDK_INTERP_BILINEAR); | |
3060 g_object_unref(pixbuf); | |
3061 | |
3062 if (flags && gaim_conv_chat_is_user_ignored(chat, name)) { | |
3063 filename = g_build_filename(DATADIR, "pixmaps", "gaim", "status", "default", "ignored.png", NULL); | |
9498 | 3064 pixbuf = gdk_pixbuf_new_from_file(filename, NULL); |
3065 g_free(filename); | |
10274 | 3066 scale2 = gdk_pixbuf_scale_simple(pixbuf, 15, 15, GDK_INTERP_BILINEAR); |
9498 | 3067 g_object_unref(pixbuf); |
10274 | 3068 gdk_pixbuf_composite(scale2, scale, 0, 0, 15, 15, 0, 0, 1, 1, GDK_INTERP_BILINEAR, 192); |
3069 g_object_unref(scale2); | |
9498 | 3070 } |
3071 | |
10274 | 3072 return scale; |
9498 | 3073 } |
3074 | |
4359 | 3075 static void |
11869 | 3076 add_chat_buddy_common(GaimConversation *conv, const char *name, GaimConvChatBuddyFlags flags, const char *alias, const char *old_name) |
4359 | 3077 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
3078 GaimGtkConversation *gtkconv; |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
3079 GaimGtkChatPane *gtkchat; |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
3080 GaimConvChat *chat; |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3081 GaimConnection *gc; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3082 GaimPluginProtocolInfo *prpl_info; |
4359 | 3083 GtkListStore *ls; |
9498 | 3084 GdkPixbuf *pixbuf; |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3085 GtkTreeIter iter; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3086 gboolean is_me = FALSE; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3087 gboolean is_buddy; |
4359 | 3088 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
3089 chat = GAIM_CONV_CHAT(conv); |
4359 | 3090 gtkconv = GAIM_GTK_CONVERSATION(conv); |
3091 gtkchat = gtkconv->u.chat; | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3092 gc = gaim_conversation_get_gc(conv); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3093 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3094 if (!gc || !(prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl))) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3095 return; |
4359 | 3096 |
3097 ls = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list))); | |
3098 | |
9554 | 3099 pixbuf = get_chat_buddy_status_icon(chat, name, flags); |
9498 | 3100 |
11500
9fc7d0153332
[gaim-migrate @ 13745]
Richard Laager <rlaager@wiktel.com>
parents:
11486
diff
changeset
|
3101 if (!strcmp(chat->nick, gaim_normalize(conv->account, old_name != NULL ? old_name : name))) |
9fc7d0153332
[gaim-migrate @ 13745]
Richard Laager <rlaager@wiktel.com>
parents:
11486
diff
changeset
|
3102 is_me = TRUE; |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3103 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3104 is_buddy = (gaim_find_buddy(conv->account, name) != NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3105 |
4359 | 3106 gtk_list_store_append(ls, &iter); |
12358
d1af58b4a463
[gaim-migrate @ 14662]
Richard Laager <rlaager@wiktel.com>
parents:
12356
diff
changeset
|
3107 |
d1af58b4a463
[gaim-migrate @ 14662]
Richard Laager <rlaager@wiktel.com>
parents:
12356
diff
changeset
|
3108 if (is_me) |
d1af58b4a463
[gaim-migrate @ 14662]
Richard Laager <rlaager@wiktel.com>
parents:
12356
diff
changeset
|
3109 { |
d1af58b4a463
[gaim-migrate @ 14662]
Richard Laager <rlaager@wiktel.com>
parents:
12356
diff
changeset
|
3110 GdkColor send_color; |
d1af58b4a463
[gaim-migrate @ 14662]
Richard Laager <rlaager@wiktel.com>
parents:
12356
diff
changeset
|
3111 gdk_color_parse(SEND_COLOR, &send_color); |
d1af58b4a463
[gaim-migrate @ 14662]
Richard Laager <rlaager@wiktel.com>
parents:
12356
diff
changeset
|
3112 |
d1af58b4a463
[gaim-migrate @ 14662]
Richard Laager <rlaager@wiktel.com>
parents:
12356
diff
changeset
|
3113 gtk_list_store_set(ls, &iter, |
d1af58b4a463
[gaim-migrate @ 14662]
Richard Laager <rlaager@wiktel.com>
parents:
12356
diff
changeset
|
3114 CHAT_USERS_ICON_COLUMN, pixbuf, |
d1af58b4a463
[gaim-migrate @ 14662]
Richard Laager <rlaager@wiktel.com>
parents:
12356
diff
changeset
|
3115 CHAT_USERS_ALIAS_COLUMN, alias, |
d1af58b4a463
[gaim-migrate @ 14662]
Richard Laager <rlaager@wiktel.com>
parents:
12356
diff
changeset
|
3116 CHAT_USERS_NAME_COLUMN, name, |
d1af58b4a463
[gaim-migrate @ 14662]
Richard Laager <rlaager@wiktel.com>
parents:
12356
diff
changeset
|
3117 CHAT_USERS_FLAGS_COLUMN, flags, |
d1af58b4a463
[gaim-migrate @ 14662]
Richard Laager <rlaager@wiktel.com>
parents:
12356
diff
changeset
|
3118 CHAT_USERS_COLOR_COLUMN, &send_color, |
d1af58b4a463
[gaim-migrate @ 14662]
Richard Laager <rlaager@wiktel.com>
parents:
12356
diff
changeset
|
3119 CHAT_USERS_BUDDY_COLUMN, is_buddy, |
d1af58b4a463
[gaim-migrate @ 14662]
Richard Laager <rlaager@wiktel.com>
parents:
12356
diff
changeset
|
3120 -1); |
d1af58b4a463
[gaim-migrate @ 14662]
Richard Laager <rlaager@wiktel.com>
parents:
12356
diff
changeset
|
3121 } |
d1af58b4a463
[gaim-migrate @ 14662]
Richard Laager <rlaager@wiktel.com>
parents:
12356
diff
changeset
|
3122 else |
d1af58b4a463
[gaim-migrate @ 14662]
Richard Laager <rlaager@wiktel.com>
parents:
12356
diff
changeset
|
3123 { |
d1af58b4a463
[gaim-migrate @ 14662]
Richard Laager <rlaager@wiktel.com>
parents:
12356
diff
changeset
|
3124 gtk_list_store_set(ls, &iter, |
d1af58b4a463
[gaim-migrate @ 14662]
Richard Laager <rlaager@wiktel.com>
parents:
12356
diff
changeset
|
3125 CHAT_USERS_ICON_COLUMN, pixbuf, |
d1af58b4a463
[gaim-migrate @ 14662]
Richard Laager <rlaager@wiktel.com>
parents:
12356
diff
changeset
|
3126 CHAT_USERS_ALIAS_COLUMN, alias, |
d1af58b4a463
[gaim-migrate @ 14662]
Richard Laager <rlaager@wiktel.com>
parents:
12356
diff
changeset
|
3127 CHAT_USERS_NAME_COLUMN, name, |
d1af58b4a463
[gaim-migrate @ 14662]
Richard Laager <rlaager@wiktel.com>
parents:
12356
diff
changeset
|
3128 CHAT_USERS_FLAGS_COLUMN, flags, |
12579
5e81ae0736c9
[gaim-migrate @ 14904]
Richard Laager <rlaager@wiktel.com>
parents:
12553
diff
changeset
|
3129 CHAT_USERS_COLOR_COLUMN, get_nick_color(gtkconv, name), |
12358
d1af58b4a463
[gaim-migrate @ 14662]
Richard Laager <rlaager@wiktel.com>
parents:
12356
diff
changeset
|
3130 CHAT_USERS_BUDDY_COLUMN, is_buddy, |
d1af58b4a463
[gaim-migrate @ 14662]
Richard Laager <rlaager@wiktel.com>
parents:
12356
diff
changeset
|
3131 -1); |
d1af58b4a463
[gaim-migrate @ 14662]
Richard Laager <rlaager@wiktel.com>
parents:
12356
diff
changeset
|
3132 } |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3133 |
9554 | 3134 if (pixbuf) |
3135 g_object_unref(pixbuf); | |
4359 | 3136 } |
3137 | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3138 static void |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3139 tab_complete_process_item(int *most_matched, char *entered, char **partial, char *nick_partial, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3140 GList **matches, gboolean command, char *name) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3141 { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3142 strncpy(nick_partial, name, strlen(entered)); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3143 nick_partial[strlen(entered)] = '\0'; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3144 if (gaim_utf8_strcasecmp(nick_partial, entered)) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3145 return; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3146 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3147 /* if we're here, it's a possible completion */ |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3148 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3149 if (*most_matched == -1) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3150 /* |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3151 * this will only get called once, since from now |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3152 * on *most_matched is >= 0 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3153 */ |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3154 *most_matched = strlen(name); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3155 *partial = g_strdup(name); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3156 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3157 else if (*most_matched) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3158 char *tmp = g_strdup(name); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3159 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3160 while (gaim_utf8_strcasecmp(tmp, *partial)) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3161 (*partial)[*most_matched] = '\0'; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3162 if (*most_matched < strlen(tmp)) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3163 tmp[*most_matched] = '\0'; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3164 (*most_matched)--; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3165 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3166 (*most_matched)++; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3167 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3168 g_free(tmp); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3169 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3170 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3171 *matches = g_list_insert_sorted(*matches, g_strdup(name), |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3172 (GCompareFunc)gaim_utf8_strcasecmp); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3173 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3174 |
9605 | 3175 static gboolean |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
3176 tab_complete(GaimConversation *conv) |
4359 | 3177 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
3178 GaimGtkConversation *gtkconv; |
4359 | 3179 GtkTextIter cursor, word_start, start_buffer; |
3180 int start; | |
3181 int most_matched = -1; | |
3182 char *entered, *partial = NULL; | |
3183 char *text; | |
8021 | 3184 char *nick_partial; |
9605 | 3185 const char *prefix; |
4359 | 3186 GList *matches = NULL; |
9605 | 3187 gboolean command = FALSE; |
4359 | 3188 |
3189 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
3190 | |
3191 gtk_text_buffer_get_start_iter(gtkconv->entry_buffer, &start_buffer); | |
3192 gtk_text_buffer_get_iter_at_mark(gtkconv->entry_buffer, &cursor, | |
3193 gtk_text_buffer_get_insert(gtkconv->entry_buffer)); | |
3194 | |
3195 word_start = cursor; | |
3196 | |
3197 /* if there's nothing there just return */ | |
3198 if (!gtk_text_iter_compare(&cursor, &start_buffer)) | |
11338 | 3199 return (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) ? TRUE : FALSE; |
6725
e62a504c83d0
[gaim-migrate @ 7252]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
3200 |
4359 | 3201 text = gtk_text_buffer_get_text(gtkconv->entry_buffer, &start_buffer, |
3202 &cursor, FALSE); | |
3203 | |
3204 /* if we're at the end of ": " we need to move back 2 spaces */ | |
3205 start = strlen(text) - 1; | |
3206 | |
8021 | 3207 if (strlen(text) >= 2 && !strncmp(&text[start-1], ": ", 2)) { |
4359 | 3208 gtk_text_iter_backward_chars(&word_start, 2); |
8021 | 3209 start-=2; |
3210 } | |
4359 | 3211 |
3212 /* find the start of the word that we're tabbing */ | |
3213 while (start >= 0 && text[start] != ' ') { | |
3214 gtk_text_iter_backward_char(&word_start); | |
3215 start--; | |
3216 } | |
3217 | |
9605 | 3218 prefix = gaim_gtk_get_cmd_prefix(); |
3219 if (start == -1 && (strlen(text) >= strlen(prefix)) && !strncmp(text, prefix, strlen(prefix))) { | |
3220 command = TRUE; | |
3221 gtk_text_iter_forward_chars(&word_start, strlen(prefix)); | |
3222 } | |
3223 | |
4359 | 3224 g_free(text); |
3225 | |
3226 entered = gtk_text_buffer_get_text(gtkconv->entry_buffer, &word_start, | |
3227 &cursor, FALSE); | |
3228 | |
8021 | 3229 if (!g_utf8_strlen(entered, -1)) { |
4359 | 3230 g_free(entered); |
11338 | 3231 return (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) ? TRUE : FALSE; |
4359 | 3232 } |
3233 | |
8021 | 3234 nick_partial = g_malloc(strlen(entered)+1); |
3235 | |
9605 | 3236 if (command) { |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3237 GList *list = gaim_cmd_list(conv); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3238 GList *l; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3239 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3240 /* Commands */ |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3241 for (l = list; l != NULL; l = l->next) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3242 tab_complete_process_item(&most_matched, entered, &partial, nick_partial, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3243 &matches, TRUE, l->data); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3244 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3245 g_list_free(list); |
11338 | 3246 } else if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) { |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3247 GaimConvChat *chat = GAIM_CONV_CHAT(conv); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3248 GList *l = gaim_conv_chat_get_users(chat); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3249 GtkTreeModel *model = gtk_tree_view_get_model(GTK_TREE_VIEW(GAIM_GTK_CONVERSATION(conv)->u.chat->list)); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3250 GtkTreeIter iter; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3251 int f; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3252 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3253 /* Users */ |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3254 for (; l != NULL; l = l->next) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3255 tab_complete_process_item(&most_matched, entered, &partial, nick_partial, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3256 &matches, TRUE, ((GaimConvChatBuddy *)l->data)->name); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3257 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3258 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3259 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3260 /* Aliases */ |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3261 if (gtk_tree_model_get_iter_first(GTK_TREE_MODEL(model), &iter)) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3262 { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3263 do { |
11460
d68ca756e983
[gaim-migrate @ 13699]
Richard Laager <rlaager@wiktel.com>
parents:
11454
diff
changeset
|
3264 char *name; |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3265 char *alias; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3266 |
11460
d68ca756e983
[gaim-migrate @ 13699]
Richard Laager <rlaager@wiktel.com>
parents:
11454
diff
changeset
|
3267 gtk_tree_model_get(model, &iter, |
d68ca756e983
[gaim-migrate @ 13699]
Richard Laager <rlaager@wiktel.com>
parents:
11454
diff
changeset
|
3268 CHAT_USERS_NAME_COLUMN, &name, |
d68ca756e983
[gaim-migrate @ 13699]
Richard Laager <rlaager@wiktel.com>
parents:
11454
diff
changeset
|
3269 CHAT_USERS_ALIAS_COLUMN, &alias, |
d68ca756e983
[gaim-migrate @ 13699]
Richard Laager <rlaager@wiktel.com>
parents:
11454
diff
changeset
|
3270 -1); |
d68ca756e983
[gaim-migrate @ 13699]
Richard Laager <rlaager@wiktel.com>
parents:
11454
diff
changeset
|
3271 |
d68ca756e983
[gaim-migrate @ 13699]
Richard Laager <rlaager@wiktel.com>
parents:
11454
diff
changeset
|
3272 if (strcmp(name, alias)) |
d68ca756e983
[gaim-migrate @ 13699]
Richard Laager <rlaager@wiktel.com>
parents:
11454
diff
changeset
|
3273 tab_complete_process_item(&most_matched, entered, &partial, nick_partial, |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3274 &matches, FALSE, alias); |
11460
d68ca756e983
[gaim-migrate @ 13699]
Richard Laager <rlaager@wiktel.com>
parents:
11454
diff
changeset
|
3275 g_free(name); |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3276 g_free(alias); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3277 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3278 f = gtk_tree_model_iter_next(model, &iter); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3279 } while (f != 0); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3280 } |
9605 | 3281 } else { |
3282 g_free(nick_partial); | |
3283 g_free(entered); | |
3284 return FALSE; | |
3285 } | |
3286 | |
8021 | 3287 g_free(nick_partial); |
3288 | |
4359 | 3289 /* we're only here if we're doing new style */ |
3290 | |
3291 /* if there weren't any matches, return */ | |
3292 if (!matches) { | |
3293 /* if matches isn't set partials won't be either */ | |
3294 g_free(entered); | |
11338 | 3295 return (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) ? TRUE : FALSE; |
4359 | 3296 } |
3297 | |
3298 gtk_text_buffer_delete(gtkconv->entry_buffer, &word_start, &cursor); | |
3299 | |
3300 if (!matches->next) { | |
3301 /* there was only one match. fill it in. */ | |
3302 gtk_text_buffer_get_start_iter(gtkconv->entry_buffer, &start_buffer); | |
3303 gtk_text_buffer_get_iter_at_mark(gtkconv->entry_buffer, &cursor, | |
3304 gtk_text_buffer_get_insert(gtkconv->entry_buffer)); | |
3305 | |
3306 if (!gtk_text_iter_compare(&cursor, &start_buffer)) { | |
3307 char *tmp = g_strdup_printf("%s: ", (char *)matches->data); | |
3308 gtk_text_buffer_insert_at_cursor(gtkconv->entry_buffer, tmp, -1); | |
3309 g_free(tmp); | |
3310 } | |
3311 else | |
3312 gtk_text_buffer_insert_at_cursor(gtkconv->entry_buffer, | |
3313 matches->data, -1); | |
3314 | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3315 g_free(matches->data); |
4359 | 3316 matches = g_list_remove(matches, matches->data); |
3317 } | |
3318 else { | |
3319 /* | |
3320 * there were lots of matches, fill in as much as possible | |
3321 * and display all of them | |
3322 */ | |
3323 char *addthis = g_malloc0(1); | |
3324 | |
3325 while (matches) { | |
3326 char *tmp = addthis; | |
3327 addthis = g_strconcat(tmp, matches->data, " ", NULL); | |
3328 g_free(tmp); | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3329 g_free(matches->data); |
4359 | 3330 matches = g_list_remove(matches, matches->data); |
3331 } | |
3332 | |
6982 | 3333 gaim_conversation_write(conv, NULL, addthis, GAIM_MESSAGE_NO_LOG, |
4359 | 3334 time(NULL)); |
3335 gtk_text_buffer_insert_at_cursor(gtkconv->entry_buffer, partial, -1); | |
3336 g_free(addthis); | |
3337 } | |
3338 | |
3339 g_free(entered); | |
3340 g_free(partial); | |
9605 | 3341 |
3342 return TRUE; | |
4359 | 3343 } |
3344 | |
10810 | 3345 static void topic_callback(GtkWidget *w, GaimGtkConversation *gtkconv) |
7971 | 3346 { |
3347 GaimPluginProtocolInfo *prpl_info = NULL; | |
3348 GaimConnection *gc; | |
10810 | 3349 GaimConversation *conv = gtkconv->active_conv; |
7971 | 3350 GaimGtkChatPane *gtkchat; |
11261
b53606580f68
[gaim-migrate @ 13439]
Richard Laager <rlaager@wiktel.com>
parents:
11257
diff
changeset
|
3351 char *new_topic; |
8858 | 3352 const char *current_topic; |
7971 | 3353 |
3354 gc = gaim_conversation_get_gc(conv); | |
3355 | |
3356 if(!gc || !(prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl))) | |
3357 return; | |
3358 | |
3359 if(prpl_info->set_chat_topic == NULL) | |
3360 return; | |
3361 | |
3362 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
3363 gtkchat = gtkconv->u.chat; | |
11261
b53606580f68
[gaim-migrate @ 13439]
Richard Laager <rlaager@wiktel.com>
parents:
11257
diff
changeset
|
3364 new_topic = g_strdup(gtk_entry_get_text(GTK_ENTRY(gtkchat->topic_text))); |
8858 | 3365 current_topic = gaim_conv_chat_get_topic(GAIM_CONV_CHAT(conv)); |
3366 | |
11261
b53606580f68
[gaim-migrate @ 13439]
Richard Laager <rlaager@wiktel.com>
parents:
11257
diff
changeset
|
3367 if(current_topic && !g_utf8_collate(new_topic, current_topic)){ |
b53606580f68
[gaim-migrate @ 13439]
Richard Laager <rlaager@wiktel.com>
parents:
11257
diff
changeset
|
3368 g_free(new_topic); |
7971 | 3369 return; |
11261
b53606580f68
[gaim-migrate @ 13439]
Richard Laager <rlaager@wiktel.com>
parents:
11257
diff
changeset
|
3370 } |
b53606580f68
[gaim-migrate @ 13439]
Richard Laager <rlaager@wiktel.com>
parents:
11257
diff
changeset
|
3371 |
b53606580f68
[gaim-migrate @ 13439]
Richard Laager <rlaager@wiktel.com>
parents:
11257
diff
changeset
|
3372 gtk_entry_set_text(GTK_ENTRY(gtkchat->topic_text), current_topic); |
7971 | 3373 |
8858 | 3374 prpl_info->set_chat_topic(gc, gaim_conv_chat_get_id(GAIM_CONV_CHAT(conv)), |
3375 new_topic); | |
11261
b53606580f68
[gaim-migrate @ 13439]
Richard Laager <rlaager@wiktel.com>
parents:
11257
diff
changeset
|
3376 |
b53606580f68
[gaim-migrate @ 13439]
Richard Laager <rlaager@wiktel.com>
parents:
11257
diff
changeset
|
3377 g_free(new_topic); |
7971 | 3378 } |
3379 | |
9554 | 3380 static gint |
3381 sort_chat_users(GtkTreeModel *model, GtkTreeIter *a, GtkTreeIter *b, gpointer userdata) | |
3382 { | |
3383 GaimConvChatBuddyFlags f1 = 0, f2 = 0; | |
3384 char *user1 = NULL, *user2 = NULL; | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3385 gboolean buddy1 = FALSE, buddy2 = FALSE; |
9554 | 3386 gint ret = 0; |
3387 | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3388 gtk_tree_model_get(model, a, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3389 CHAT_USERS_ALIAS_COLUMN, &user1, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3390 CHAT_USERS_FLAGS_COLUMN, &f1, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3391 CHAT_USERS_BUDDY_COLUMN, &buddy1, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3392 -1); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3393 gtk_tree_model_get(model, b, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3394 CHAT_USERS_ALIAS_COLUMN, &user2, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3395 CHAT_USERS_FLAGS_COLUMN, &f2, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3396 CHAT_USERS_BUDDY_COLUMN, &buddy2, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3397 -1); |
9554 | 3398 |
3399 if (user1 == NULL || user2 == NULL) { | |
3400 if (!(user1 == NULL && user2 == NULL)) | |
3401 ret = (user1 == NULL) ? -1: 1; | |
3402 } else if (f1 != f2) { | |
3403 /* sort more important users first */ | |
3404 ret = (f1 > f2) ? -1 : 1; | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3405 } else if (buddy1 != buddy2) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3406 ret = buddy1 ? -1 : 1; |
9554 | 3407 } else { |
10904 | 3408 ret = gaim_utf8_strcasecmp(user1, user2); |
9554 | 3409 } |
3410 | |
3411 g_free(user1); | |
3412 g_free(user2); | |
3413 | |
3414 return ret; | |
3415 } | |
3416 | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3417 static void |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3418 update_chat_alias(GaimBuddy *buddy, GaimConversation *conv, GaimConnection *gc, GaimPluginProtocolInfo *prpl_info) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3419 { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3420 GaimGtkConversation *gtkconv = GAIM_GTK_CONVERSATION(conv); |
11500
9fc7d0153332
[gaim-migrate @ 13745]
Richard Laager <rlaager@wiktel.com>
parents:
11486
diff
changeset
|
3421 GaimConvChat *chat = GAIM_CONV_CHAT(conv); |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3422 GtkTreeModel *model; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3423 char *normalized_name; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3424 GtkTreeIter iter; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3425 int f; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3426 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3427 g_return_if_fail(buddy != NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3428 g_return_if_fail(conv != NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3429 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3430 /* This is safe because this callback is only used in chats, not IMs. */ |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3431 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkconv->u.chat->list)); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3432 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3433 if (!gtk_tree_model_get_iter_first(GTK_TREE_MODEL(model), &iter)) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3434 return; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3435 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3436 normalized_name = g_strdup(gaim_normalize(conv->account, buddy->name)); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3437 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3438 do { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3439 char *name; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3440 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3441 gtk_tree_model_get(model, &iter, CHAT_USERS_NAME_COLUMN, &name, -1); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3442 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3443 if (!strcmp(normalized_name, gaim_normalize(conv->account, name))) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3444 const char *alias = name; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3445 GaimBuddy *buddy2; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3446 |
11500
9fc7d0153332
[gaim-migrate @ 13745]
Richard Laager <rlaager@wiktel.com>
parents:
11486
diff
changeset
|
3447 if (strcmp(chat->nick, gaim_normalize(conv->account, name))) { |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3448 /* This user is not me, so look into updating the alias. */ |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3449 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3450 if ((buddy2 = gaim_find_buddy(conv->account, name)) != NULL) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3451 alias = gaim_buddy_get_contact_alias(buddy2); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3452 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3453 gtk_list_store_set(GTK_LIST_STORE(model), &iter, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3454 CHAT_USERS_ALIAS_COLUMN, alias, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3455 -1); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3456 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3457 g_free(name); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3458 break; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3459 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3460 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3461 f = gtk_tree_model_iter_next(model, &iter); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3462 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3463 g_free(name); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3464 } while (f != 0); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3465 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3466 g_free(normalized_name); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3467 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3468 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3469 static void |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3470 blist_node_aliased_cb(GaimBlistNode *node, const char *old_alias, GaimConversation *conv) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3471 { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3472 GaimConnection *gc; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3473 GaimPluginProtocolInfo *prpl_info; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3474 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3475 g_return_if_fail(node != NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3476 g_return_if_fail(conv != NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3477 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3478 gc = gaim_conversation_get_gc(conv); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3479 g_return_if_fail(gc != NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3480 g_return_if_fail(gc->prpl != NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3481 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3482 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3483 if (prpl_info->options & OPT_PROTO_UNIQUE_CHATNAME) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3484 return; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3485 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3486 if (GAIM_BLIST_NODE_IS_CONTACT(node)) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3487 { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3488 GaimBlistNode *bnode; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3489 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3490 for(bnode = node->child; bnode; bnode = bnode->next) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3491 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3492 if(!GAIM_BLIST_NODE_IS_BUDDY(bnode)) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3493 continue; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3494 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3495 update_chat_alias((GaimBuddy *)bnode, conv, gc, prpl_info); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3496 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3497 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3498 else if (GAIM_BLIST_NODE_IS_BUDDY(node)) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3499 update_chat_alias((GaimBuddy *)node, conv, gc, prpl_info); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3500 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3501 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3502 static void |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3503 buddy_cb_common(GaimBuddy *buddy, GaimConversation *conv, gboolean is_buddy) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3504 { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3505 GtkTreeModel *model; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3506 char *normalized_name; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3507 GtkTreeIter iter; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3508 int f; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3509 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3510 g_return_if_fail(buddy != NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3511 g_return_if_fail(conv != NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3512 |
11846
908ff9b56e99
[gaim-migrate @ 14137]
Richard Laager <rlaager@wiktel.com>
parents:
11815
diff
changeset
|
3513 /* Do nothing if the buddy does not belong to the conv's account */ |
908ff9b56e99
[gaim-migrate @ 14137]
Richard Laager <rlaager@wiktel.com>
parents:
11815
diff
changeset
|
3514 if (gaim_buddy_get_account(buddy) != gaim_conversation_get_account(conv)) |
908ff9b56e99
[gaim-migrate @ 14137]
Richard Laager <rlaager@wiktel.com>
parents:
11815
diff
changeset
|
3515 return; |
908ff9b56e99
[gaim-migrate @ 14137]
Richard Laager <rlaager@wiktel.com>
parents:
11815
diff
changeset
|
3516 |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3517 /* This is safe because this callback is only used in chats, not IMs. */ |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3518 model = gtk_tree_view_get_model(GTK_TREE_VIEW(GAIM_GTK_CONVERSATION(conv)->u.chat->list)); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3519 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3520 if (!gtk_tree_model_get_iter_first(GTK_TREE_MODEL(model), &iter)) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3521 return; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3522 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3523 normalized_name = g_strdup(gaim_normalize(conv->account, buddy->name)); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3524 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3525 do { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3526 char *name; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3527 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3528 gtk_tree_model_get(model, &iter, CHAT_USERS_NAME_COLUMN, &name, -1); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3529 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3530 if (!strcmp(normalized_name, gaim_normalize(conv->account, name))) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3531 gtk_list_store_set(GTK_LIST_STORE(model), &iter, CHAT_USERS_BUDDY_COLUMN, is_buddy, -1); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3532 g_free(name); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3533 break; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3534 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3535 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3536 f = gtk_tree_model_iter_next(model, &iter); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3537 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3538 g_free(name); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3539 } while (f != 0); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3540 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3541 g_free(normalized_name); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3542 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3543 blist_node_aliased_cb((GaimBlistNode *)buddy, NULL, conv); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3544 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3545 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3546 static void |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3547 buddy_added_cb(GaimBuddy *buddy, GaimConversation *conv) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3548 { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3549 buddy_cb_common(buddy, conv, TRUE); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3550 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3551 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3552 static void |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3553 buddy_removed_cb(GaimBuddy *buddy, GaimConversation *conv) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3554 { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3555 /* If there's another buddy for the same "dude" on the list, do nothing. */ |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3556 if (gaim_find_buddy(buddy->account, buddy->name) != NULL) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3557 return; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3558 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3559 buddy_cb_common(buddy, conv, FALSE); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3560 } |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3561 |
4359 | 3562 static GtkWidget * |
10810 | 3563 setup_chat_pane(GaimGtkConversation *gtkconv) |
4359 | 3564 { |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5204
diff
changeset
|
3565 GaimPluginProtocolInfo *prpl_info = NULL; |
10810 | 3566 GaimConversation *conv = gtkconv->active_conv; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
3567 GaimGtkChatPane *gtkchat; |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
3568 GaimConnection *gc; |
4359 | 3569 GtkWidget *vpaned, *hpaned; |
10175 | 3570 GtkWidget *vbox, *hbox, *frame; |
4359 | 3571 GtkWidget *lbox, *bbox; |
3572 GtkWidget *label; | |
3573 GtkWidget *list; | |
3574 GtkWidget *button; | |
7949 | 3575 GtkWidget *sw; |
4359 | 3576 GtkListStore *ls; |
3577 GtkCellRenderer *rend; | |
3578 GtkTreeViewColumn *col; | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3579 void *blist_handle = gaim_blist_get_handle(); |
9080 | 3580 GList *focus_chain = NULL; |
4359 | 3581 |
3582 gtkchat = gtkconv->u.chat; | |
3583 gc = gaim_conversation_get_gc(conv); | |
3584 | |
3585 /* Setup the outer pane. */ | |
3586 vpaned = gtk_vpaned_new(); | |
3587 gtk_widget_show(vpaned); | |
3588 | |
3589 /* Setup the top part of the pane. */ | |
11243 | 3590 vbox = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
8914 | 3591 gtk_paned_pack1(GTK_PANED(vpaned), vbox, TRUE, TRUE); |
4359 | 3592 gtk_widget_show(vbox); |
3593 | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5204
diff
changeset
|
3594 if (gc != NULL) |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5204
diff
changeset
|
3595 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5204
diff
changeset
|
3596 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5204
diff
changeset
|
3597 if (prpl_info->options & OPT_PROTO_CHAT_TOPIC) |
4359 | 3598 { |
11243 | 3599 hbox = gtk_hbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
8253
0c5977fd3101
[gaim-migrate @ 8976]
Christian Hammond <chipx86@chipx86.com>
parents:
8252
diff
changeset
|
3600 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); |
4359 | 3601 gtk_widget_show(hbox); |
3602 | |
3603 label = gtk_label_new(_("Topic:")); | |
8253
0c5977fd3101
[gaim-migrate @ 8976]
Christian Hammond <chipx86@chipx86.com>
parents:
8252
diff
changeset
|
3604 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); |
4359 | 3605 gtk_widget_show(label); |
3606 | |
3607 gtkchat->topic_text = gtk_entry_new(); | |
8253
0c5977fd3101
[gaim-migrate @ 8976]
Christian Hammond <chipx86@chipx86.com>
parents:
8252
diff
changeset
|
3608 |
7971 | 3609 if(prpl_info->set_chat_topic == NULL) { |
3610 gtk_editable_set_editable(GTK_EDITABLE(gtkchat->topic_text), FALSE); | |
3611 } else { | |
3612 g_signal_connect(GTK_OBJECT(gtkchat->topic_text), "activate", | |
10810 | 3613 G_CALLBACK(topic_callback), gtkconv); |
7971 | 3614 } |
3615 | |
8253
0c5977fd3101
[gaim-migrate @ 8976]
Christian Hammond <chipx86@chipx86.com>
parents:
8252
diff
changeset
|
3616 gtk_box_pack_start(GTK_BOX(hbox), gtkchat->topic_text, TRUE, TRUE, 0); |
4359 | 3617 gtk_widget_show(gtkchat->topic_text); |
3618 } | |
3619 | |
3620 /* Setup the horizontal pane. */ | |
3621 hpaned = gtk_hpaned_new(); | |
8253
0c5977fd3101
[gaim-migrate @ 8976]
Christian Hammond <chipx86@chipx86.com>
parents:
8252
diff
changeset
|
3622 gtk_box_pack_start(GTK_BOX(vbox), hpaned, TRUE, TRUE, 0); |
4359 | 3623 gtk_widget_show(hpaned); |
3624 | |
10175 | 3625 /* Setup gtkihmtml. */ |
3626 frame = gaim_gtk_create_imhtml(FALSE, >kconv->imhtml, NULL); | |
3627 gtk_widget_set_name(gtkconv->imhtml, "gaim_gtkconv_imhtml"); | |
10389 | 3628 gtk_imhtml_show_comments(GTK_IMHTML(gtkconv->imhtml), TRUE); |
10175 | 3629 gtk_paned_pack1(GTK_PANED(hpaned), frame, TRUE, TRUE); |
3630 gtk_widget_show(frame); | |
3631 | |
3632 gtk_widget_set_size_request(gtkconv->imhtml, | |
5550
b18c2a37cc96
[gaim-migrate @ 5951]
Christian Hammond <chipx86@chipx86.com>
parents:
5546
diff
changeset
|
3633 gaim_prefs_get_int("/gaim/gtk/conversations/chat/default_width"), |
b18c2a37cc96
[gaim-migrate @ 5951]
Christian Hammond <chipx86@chipx86.com>
parents:
5546
diff
changeset
|
3634 gaim_prefs_get_int("/gaim/gtk/conversations/chat/default_height")); |
10175 | 3635 g_signal_connect(G_OBJECT(gtkconv->imhtml), "size-allocate", |
10810 | 3636 G_CALLBACK(size_allocate_cb), gtkconv); |
8914 | 3637 |
4359 | 3638 g_signal_connect_after(G_OBJECT(gtkconv->imhtml), "button_press_event", |
3639 G_CALLBACK(entry_stop_rclick_cb), NULL); | |
8105 | 3640 g_signal_connect(G_OBJECT(gtkconv->imhtml), "key_press_event", |
6057 | 3641 G_CALLBACK(refocus_entry_cb), gtkconv); |
8109 | 3642 g_signal_connect(G_OBJECT(gtkconv->imhtml), "key_release_event", |
3643 G_CALLBACK(refocus_entry_cb), gtkconv); | |
4359 | 3644 |
3645 /* Build the right pane. */ | |
11243 | 3646 lbox = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
4409
0521eec12c33
[gaim-migrate @ 4682]
Christian Hammond <chipx86@chipx86.com>
parents:
4398
diff
changeset
|
3647 gtk_paned_pack2(GTK_PANED(hpaned), lbox, FALSE, TRUE); |
4359 | 3648 gtk_widget_show(lbox); |
3649 | |
3650 /* Setup the label telling how many people are in the room. */ | |
3651 gtkchat->count = gtk_label_new(_("0 people in room")); | |
3652 gtk_box_pack_start(GTK_BOX(lbox), gtkchat->count, FALSE, FALSE, 0); | |
3653 gtk_widget_show(gtkchat->count); | |
3654 | |
3655 /* Setup the list of users. */ | |
7949 | 3656 sw = gtk_scrolled_window_new(NULL, NULL); |
3657 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), | |
8076 | 3658 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); |
7949 | 3659 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(sw), GTK_SHADOW_IN); |
3660 gtk_box_pack_start(GTK_BOX(lbox), sw, TRUE, TRUE, 0); | |
3661 gtk_widget_show(sw); | |
4359 | 3662 |
9554 | 3663 ls = gtk_list_store_new(CHAT_USERS_COLUMNS, GDK_TYPE_PIXBUF, G_TYPE_STRING, |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3664 G_TYPE_STRING, G_TYPE_INT, GDK_TYPE_COLOR, G_TYPE_BOOLEAN); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3665 gtk_tree_sortable_set_sort_func(GTK_TREE_SORTABLE(ls), CHAT_USERS_ALIAS_COLUMN, |
9554 | 3666 sort_chat_users, NULL, NULL); |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3667 gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(ls), CHAT_USERS_ALIAS_COLUMN, |
4359 | 3668 GTK_SORT_ASCENDING); |
3669 | |
3670 list = gtk_tree_view_new_with_model(GTK_TREE_MODEL(ls)); | |
3671 | |
9498 | 3672 rend = gtk_cell_renderer_pixbuf_new(); |
3673 | |
4359 | 3674 col = gtk_tree_view_column_new_with_attributes(NULL, rend, |
9498 | 3675 "pixbuf", CHAT_USERS_ICON_COLUMN, NULL); |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3676 gtk_tree_view_column_set_sizing(col, GTK_TREE_VIEW_COLUMN_AUTOSIZE); |
9498 | 3677 gtk_tree_view_append_column(GTK_TREE_VIEW(list), col); |
4359 | 3678 |
3679 g_signal_connect(G_OBJECT(list), "button_press_event", | |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
3680 G_CALLBACK(right_click_chat_cb), gtkconv); |
8143 | 3681 g_signal_connect(G_OBJECT(list), "popup-menu", |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
3682 G_CALLBACK(gtkconv_chat_popup_menu_cb), gtkconv); |
4359 | 3683 |
9498 | 3684 rend = gtk_cell_renderer_text_new(); |
3685 | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3686 g_object_set(rend, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3687 "foreground-set", TRUE, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3688 "weight", PANGO_WEIGHT_BOLD, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3689 NULL); |
4359 | 3690 col = gtk_tree_view_column_new_with_attributes(NULL, rend, |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3691 "text", CHAT_USERS_ALIAS_COLUMN, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3692 "foreground-gdk", CHAT_USERS_COLOR_COLUMN, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3693 "weight-set", CHAT_USERS_BUDDY_COLUMN, |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3694 NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3695 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3696 gaim_signal_connect(blist_handle, "buddy-added", |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3697 gtkchat, GAIM_CALLBACK(buddy_added_cb), conv); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3698 gaim_signal_connect(blist_handle, "buddy-removed", |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3699 gtkchat, GAIM_CALLBACK(buddy_removed_cb), conv); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3700 gaim_signal_connect(blist_handle, "blist-node-aliased", |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3701 gtkchat, GAIM_CALLBACK(blist_node_aliased_cb), conv); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3702 |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3703 #if GTK_CHECK_VERSION(2,6,0) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3704 gtk_tree_view_column_set_expand(col, TRUE); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3705 g_object_set(rend, "ellipsize", PANGO_ELLIPSIZE_END, NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
3706 #endif |
4359 | 3707 |
3708 gtk_tree_view_append_column(GTK_TREE_VIEW(list), col); | |
3709 | |
3710 gtk_widget_set_size_request(list, 150, -1); | |
3711 | |
3712 gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(list), FALSE); | |
3713 gtk_widget_show(list); | |
3714 | |
3715 gtkchat->list = list; | |
3716 | |
7949 | 3717 gtk_container_add(GTK_CONTAINER(sw), list); |
4359 | 3718 |
3719 /* Setup the user list toolbar. */ | |
11243 | 3720 bbox = gtk_hbox_new(TRUE, GAIM_HIG_BOX_SPACE); |
4359 | 3721 gtk_box_pack_start(GTK_BOX(lbox), bbox, FALSE, FALSE, 0); |
3722 gtk_widget_show(bbox); | |
3723 | |
3724 /* IM */ | |
10221 | 3725 button = gaim_pixbuf_button_from_stock(NULL, GAIM_STOCK_IM, |
4359 | 3726 GAIM_BUTTON_VERTICAL); |
10500 | 3727 gtkchat->userlist_im = button; |
4359 | 3728 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE); |
3729 gtk_box_pack_start(GTK_BOX(bbox), button, FALSE, FALSE, 0); | |
4370
d856987c72ca
[gaim-migrate @ 4636]
Christian Hammond <chipx86@chipx86.com>
parents:
4369
diff
changeset
|
3730 gtk_tooltips_set_tip(gtkconv->tooltips, button, _("IM the user"), NULL); |
4359 | 3731 g_signal_connect(G_OBJECT(button), "clicked", |
10810 | 3732 G_CALLBACK(chat_im_button_cb), gtkconv); |
4359 | 3733 |
3734 gtk_widget_show(button); | |
3735 | |
3736 /* Ignore */ | |
3737 button = gaim_pixbuf_button_from_stock(NULL, GAIM_STOCK_IGNORE, | |
3738 GAIM_BUTTON_VERTICAL); | |
10500 | 3739 gtkchat->userlist_ignore = button; |
4359 | 3740 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE); |
3741 gtk_box_pack_start(GTK_BOX(bbox), button, FALSE, FALSE, 0); | |
4370
d856987c72ca
[gaim-migrate @ 4636]
Christian Hammond <chipx86@chipx86.com>
parents:
4369
diff
changeset
|
3742 gtk_tooltips_set_tip(gtkconv->tooltips, button, |
d856987c72ca
[gaim-migrate @ 4636]
Christian Hammond <chipx86@chipx86.com>
parents:
4369
diff
changeset
|
3743 _("Ignore the user"), NULL); |
4359 | 3744 g_signal_connect(G_OBJECT(button), "clicked", |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
3745 G_CALLBACK(ignore_cb), gtkconv); |
4359 | 3746 gtk_widget_show(button); |
3747 | |
3748 /* Info */ | |
3749 button = gaim_pixbuf_button_from_stock(NULL, GAIM_STOCK_INFO, | |
3750 GAIM_BUTTON_VERTICAL); | |
10500 | 3751 gtkchat->userlist_info = button; |
4359 | 3752 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE); |
3753 gtk_box_pack_start(GTK_BOX(bbox), button, FALSE, FALSE, 0); | |
3754 gtk_tooltips_set_tip(gtkconv->tooltips, button, | |
4370
d856987c72ca
[gaim-migrate @ 4636]
Christian Hammond <chipx86@chipx86.com>
parents:
4369
diff
changeset
|
3755 _("Get the user's information"), NULL); |
4359 | 3756 g_signal_connect(G_OBJECT(button), "clicked", |
10810 | 3757 G_CALLBACK(info_cb), gtkconv); |
4359 | 3758 |
3759 gtk_widget_show(button); | |
3760 | |
10175 | 3761 /* Setup the bottom half of the conversation window */ |
11243 | 3762 vbox = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
8914 | 3763 gtk_paned_pack2(GTK_PANED(vpaned), vbox, FALSE, TRUE); |
4963
7f5e7f2ef317
[gaim-migrate @ 5297]
Christian Hammond <chipx86@chipx86.com>
parents:
4958
diff
changeset
|
3764 gtk_widget_show(vbox); |
7f5e7f2ef317
[gaim-migrate @ 5297]
Christian Hammond <chipx86@chipx86.com>
parents:
4958
diff
changeset
|
3765 |
11243 | 3766 gtkconv->lower_hbox = gtk_hbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
9332 | 3767 gtk_box_pack_start(GTK_BOX(vbox), gtkconv->lower_hbox, TRUE, TRUE, 0); |
3768 gtk_widget_show(gtkconv->lower_hbox); | |
3769 | |
11243 | 3770 vbox = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
9332 | 3771 gtk_box_pack_end(GTK_BOX(gtkconv->lower_hbox), vbox, TRUE, TRUE, 0); |
3772 gtk_widget_show(vbox); | |
3773 | |
10175 | 3774 /* Setup the toolbar, entry widget and all signals */ |
3775 frame = gaim_gtk_create_imhtml(TRUE, >kconv->entry, >kconv->toolbar); | |
10080 | 3776 gtk_box_pack_start(GTK_BOX(vbox), frame, TRUE, TRUE, 0); |
10175 | 3777 gtk_widget_show(frame); |
3778 | |
9005 | 3779 gtk_widget_set_name(gtkconv->entry, "gaim_gtkconv_entry"); |
8456 | 3780 gtk_imhtml_set_protocol_name(GTK_IMHTML(gtkconv->entry), |
9699 | 3781 gaim_account_get_protocol_name(conv->account)); |
10175 | 3782 gtk_widget_set_size_request(gtkconv->entry, -1, |
3783 gaim_prefs_get_int("/gaim/gtk/conversations/chat/entry_height")); | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
3784 gtkconv->entry_buffer = |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
3785 gtk_text_view_get_buffer(GTK_TEXT_VIEW(gtkconv->entry)); |
10810 | 3786 g_object_set_data(G_OBJECT(gtkconv->entry_buffer), "user_data", gtkconv); |
7949 | 3787 |
3788 g_signal_connect(G_OBJECT(gtkconv->entry), "key_press_event", | |
10810 | 3789 G_CALLBACK(entry_key_press_cb), gtkconv); |
10115 | 3790 g_signal_connect(G_OBJECT(gtkconv->entry), "message_send", |
10810 | 3791 G_CALLBACK(send_cb), gtkconv); |
4359 | 3792 g_signal_connect_after(G_OBJECT(gtkconv->entry), "button_press_event", |
10810 | 3793 G_CALLBACK(entry_stop_rclick_cb), NULL); |
8914 | 3794 g_signal_connect(G_OBJECT(gtkconv->entry), "size-allocate", |
10810 | 3795 G_CALLBACK(size_allocate_cb), gtkconv); |
3796 | |
3797 default_formatize(gtkconv); | |
4359 | 3798 |
9080 | 3799 /* |
3800 * Focus for chat windows should be as follows: | |
3801 * Tab title -> chat topic -> conversation scrollback -> user list -> | |
3802 * user list buttons -> entry -> buttons at bottom | |
3803 */ | |
9332 | 3804 focus_chain = g_list_prepend(focus_chain, gtkconv->entry); |
9080 | 3805 gtk_container_set_focus_chain(GTK_CONTAINER(vbox), focus_chain); |
3806 | |
4359 | 3807 return vpaned; |
3808 } | |
3809 | |
3810 static GtkWidget * | |
10810 | 3811 setup_im_pane(GaimGtkConversation *gtkconv) |
4359 | 3812 { |
10810 | 3813 GaimConversation *conv = gtkconv->active_conv; |
10175 | 3814 GtkWidget *frame; |
4359 | 3815 GtkWidget *paned; |
10175 | 3816 GtkWidget *vbox; |
3817 GtkWidget *vbox2; | |
9080 | 3818 GList *focus_chain = NULL; |
4359 | 3819 |
10175 | 3820 /* Setup the outer pane */ |
4359 | 3821 paned = gtk_vpaned_new(); |
3822 gtk_widget_show(paned); | |
3823 | |
10175 | 3824 /* Setup the top part of the pane */ |
11243 | 3825 vbox = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
4409
0521eec12c33
[gaim-migrate @ 4682]
Christian Hammond <chipx86@chipx86.com>
parents:
4398
diff
changeset
|
3826 gtk_paned_pack1(GTK_PANED(paned), vbox, TRUE, TRUE); |
4359 | 3827 gtk_widget_show(vbox); |
3828 | |
10175 | 3829 /* Setup the gtkimhtml widget */ |
3830 frame = gaim_gtk_create_imhtml(FALSE, >kconv->imhtml, NULL); | |
3831 gtk_widget_set_name(gtkconv->imhtml, "gaim_gtkconv_imhtml"); | |
10389 | 3832 gtk_imhtml_show_comments(GTK_IMHTML(gtkconv->imhtml),TRUE); |
10175 | 3833 gtk_box_pack_start(GTK_BOX(vbox), frame, TRUE, TRUE, 0); |
3834 gtk_widget_show(frame); | |
3835 | |
3836 gtk_widget_set_size_request(gtkconv->imhtml, | |
5550
b18c2a37cc96
[gaim-migrate @ 5951]
Christian Hammond <chipx86@chipx86.com>
parents:
5546
diff
changeset
|
3837 gaim_prefs_get_int("/gaim/gtk/conversations/im/default_width"), |
b18c2a37cc96
[gaim-migrate @ 5951]
Christian Hammond <chipx86@chipx86.com>
parents:
5546
diff
changeset
|
3838 gaim_prefs_get_int("/gaim/gtk/conversations/im/default_height")); |
10175 | 3839 g_signal_connect(G_OBJECT(gtkconv->imhtml), "size-allocate", |
10810 | 3840 G_CALLBACK(size_allocate_cb), gtkconv); |
4359 | 3841 |
3842 g_signal_connect_after(G_OBJECT(gtkconv->imhtml), "button_press_event", | |
10810 | 3843 G_CALLBACK(entry_stop_rclick_cb), NULL); |
8105 | 3844 g_signal_connect(G_OBJECT(gtkconv->imhtml), "key_press_event", |
10810 | 3845 G_CALLBACK(refocus_entry_cb), gtkconv); |
8109 | 3846 g_signal_connect(G_OBJECT(gtkconv->imhtml), "key_release_event", |
10810 | 3847 G_CALLBACK(refocus_entry_cb), gtkconv); |
4359 | 3848 |
10175 | 3849 /* Setup the bottom half of the conversation window */ |
11243 | 3850 vbox2 = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
8914 | 3851 gtk_paned_pack2(GTK_PANED(paned), vbox2, FALSE, TRUE); |
4963
7f5e7f2ef317
[gaim-migrate @ 5297]
Christian Hammond <chipx86@chipx86.com>
parents:
4958
diff
changeset
|
3852 gtk_widget_show(vbox2); |
7f5e7f2ef317
[gaim-migrate @ 5297]
Christian Hammond <chipx86@chipx86.com>
parents:
4958
diff
changeset
|
3853 |
11243 | 3854 gtkconv->lower_hbox = gtk_hbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
9332 | 3855 gtk_box_pack_start(GTK_BOX(vbox2), gtkconv->lower_hbox, TRUE, TRUE, 0); |
3856 gtk_widget_show(gtkconv->lower_hbox); | |
3857 | |
11243 | 3858 vbox2 = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
9332 | 3859 gtk_box_pack_end(GTK_BOX(gtkconv->lower_hbox), vbox2, TRUE, TRUE, 0); |
3860 gtk_widget_show(vbox2); | |
8821 | 3861 |
10175 | 3862 /* Setup the toolbar, entry widget and all signals */ |
3863 frame = gaim_gtk_create_imhtml(TRUE, >kconv->entry, >kconv->toolbar); | |
10080 | 3864 gtk_box_pack_start(GTK_BOX(vbox2), frame, TRUE, TRUE, 0); |
10175 | 3865 gtk_widget_show(frame); |
3866 | |
9005 | 3867 gtk_widget_set_name(gtkconv->entry, "gaim_gtkconv_entry"); |
8456 | 3868 gtk_imhtml_set_protocol_name(GTK_IMHTML(gtkconv->entry), |
9699 | 3869 gaim_account_get_protocol_name(conv->account)); |
10175 | 3870 gtk_widget_set_size_request(gtkconv->entry, -1, |
3871 gaim_prefs_get_int("/gaim/gtk/conversations/im/entry_height")); | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
3872 gtkconv->entry_buffer = |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
3873 gtk_text_view_get_buffer(GTK_TEXT_VIEW(gtkconv->entry)); |
10810 | 3874 g_object_set_data(G_OBJECT(gtkconv->entry_buffer), "user_data", gtkconv); |
4963
7f5e7f2ef317
[gaim-migrate @ 5297]
Christian Hammond <chipx86@chipx86.com>
parents:
4958
diff
changeset
|
3875 |
4359 | 3876 g_signal_connect(G_OBJECT(gtkconv->entry), "key_press_event", |
10810 | 3877 G_CALLBACK(entry_key_press_cb), gtkconv); |
3878 g_signal_connect(G_OBJECT(gtkconv->entry), "message_send", G_CALLBACK(send_cb), gtkconv); | |
4359 | 3879 g_signal_connect_after(G_OBJECT(gtkconv->entry), "button_press_event", |
10810 | 3880 G_CALLBACK(entry_stop_rclick_cb), NULL); |
8914 | 3881 g_signal_connect(G_OBJECT(gtkconv->entry), "size-allocate", |
10810 | 3882 G_CALLBACK(size_allocate_cb), gtkconv); |
4359 | 3883 |
3884 g_signal_connect(G_OBJECT(gtkconv->entry_buffer), "insert_text", | |
10810 | 3885 G_CALLBACK(insert_text_cb), gtkconv); |
4359 | 3886 g_signal_connect(G_OBJECT(gtkconv->entry_buffer), "delete_range", |
10810 | 3887 G_CALLBACK(delete_text_cb), gtkconv); |
4359 | 3888 |
8481 | 3889 /* had to move this after the imtoolbar is attached so that the |
3890 * signals get fired to toggle the buttons on the toolbar as well. | |
3891 */ | |
10810 | 3892 default_formatize(gtkconv); |
4359 | 3893 |
11275
ffc86d9ad8b7
[gaim-migrate @ 13461]
Richard Laager <rlaager@wiktel.com>
parents:
11269
diff
changeset
|
3894 g_signal_connect_after(G_OBJECT(gtkconv->entry), "format_function_clear", |
ffc86d9ad8b7
[gaim-migrate @ 13461]
Richard Laager <rlaager@wiktel.com>
parents:
11269
diff
changeset
|
3895 G_CALLBACK(clear_formatting_cb), gtkconv); |
ffc86d9ad8b7
[gaim-migrate @ 13461]
Richard Laager <rlaager@wiktel.com>
parents:
11269
diff
changeset
|
3896 |
8758 | 3897 gtkconv->u.im->animate = gaim_prefs_get_bool("/gaim/gtk/conversations/im/animate_buddy_icons"); |
9687 | 3898 gtkconv->u.im->show_icon = TRUE; |
4359 | 3899 |
9080 | 3900 /* |
3901 * Focus for IM windows should be as follows: | |
10356 | 3902 * Tab title -> conversation scrollback -> entry |
9080 | 3903 */ |
9332 | 3904 focus_chain = g_list_prepend(focus_chain, gtkconv->entry); |
9080 | 3905 gtk_container_set_focus_chain(GTK_CONTAINER(vbox2), focus_chain); |
8143 | 3906 |
4359 | 3907 return paned; |
3908 } | |
3909 | |
3910 static void | |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3911 conv_dnd_recv(GtkWidget *widget, GdkDragContext *dc, guint x, guint y, |
10810 | 3912 GtkSelectionData *sd, guint info, guint t, |
3913 GaimGtkConversation *gtkconv) | |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3914 { |
10810 | 3915 GaimConversation *conv = gtkconv->active_conv; |
11581 | 3916 GaimGtkWindow *win = gtkconv->win; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
3917 GaimConversation *c; |
7712
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3918 if (sd->target == gdk_atom_intern("GAIM_BLIST_NODE", FALSE)) |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3919 { |
4781 | 3920 GaimBlistNode *n = NULL; |
6695 | 3921 GaimBuddy *b; |
11581 | 3922 GaimGtkConversation *gtkconv = NULL; |
9622 | 3923 |
11812 | 3924 n = *(GaimBlistNode **)sd->data; |
4939
4d50e125b0fa
[gaim-migrate @ 5273]
Christian Hammond <chipx86@chipx86.com>
parents:
4931
diff
changeset
|
3925 |
6695 | 3926 if (GAIM_BLIST_NODE_IS_CONTACT(n)) |
3927 b = gaim_contact_get_priority_buddy((GaimContact*)n); | |
3928 else if (GAIM_BLIST_NODE_IS_BUDDY(n)) | |
3929 b = (GaimBuddy*)n; | |
3930 else | |
4781 | 3931 return; |
4939
4d50e125b0fa
[gaim-migrate @ 5273]
Christian Hammond <chipx86@chipx86.com>
parents:
4931
diff
changeset
|
3932 |
9622 | 3933 /* |
3934 * If we already have an open conversation with this buddy, then | |
3935 * just move the conv to this window. Otherwise, create a new | |
3936 * conv and add it to this window. | |
3937 */ | |
11338 | 3938 c = gaim_find_conversation_with_account(GAIM_CONV_TYPE_IM, b->name, b->account); |
9622 | 3939 if (c != NULL) { |
11581 | 3940 GaimGtkWindow *oldwin; |
3941 gtkconv = GAIM_GTK_CONVERSATION(c); | |
3942 oldwin = gtkconv->win; | |
9622 | 3943 if (oldwin != win) { |
11581 | 3944 gaim_gtk_conv_window_remove_gtkconv(oldwin, gtkconv); |
3945 gaim_gtk_conv_window_add_gtkconv(win, gtkconv); | |
9622 | 3946 } |
3947 } else { | |
11338 | 3948 c = gaim_conversation_new(GAIM_CONV_TYPE_IM, b->account, b->name); |
11581 | 3949 gtkconv = GAIM_GTK_CONVERSATION(c); |
11812 | 3950 if (gtkconv->win != win) |
3951 { | |
3952 gaim_gtk_conv_window_remove_gtkconv(gtkconv->win, gtkconv); | |
3953 gaim_gtk_conv_window_add_gtkconv(win, gtkconv); | |
3954 } | |
9622 | 3955 } |
3956 | |
3957 /* Make this conversation the active conversation */ | |
11581 | 3958 gaim_gtk_conv_window_switch_gtkconv(win, gtkconv); |
8802
1076cd8579ea
[gaim-migrate @ 9564]
Christian Hammond <chipx86@chipx86.com>
parents:
8758
diff
changeset
|
3959 |
1076cd8579ea
[gaim-migrate @ 9564]
Christian Hammond <chipx86@chipx86.com>
parents:
8758
diff
changeset
|
3960 gtk_drag_finish(dc, TRUE, (dc->action == GDK_ACTION_MOVE), t); |
4702 | 3961 } |
7712
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3962 else if (sd->target == gdk_atom_intern("application/x-im-contact", FALSE)) |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3963 { |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3964 char *protocol = NULL; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3965 char *username = NULL; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3966 GaimAccount *account; |
11581 | 3967 GaimGtkConversation *gtkconv; |
7712
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3968 |
11137 | 3969 if (gaim_gtk_parse_x_im_contact((const char *)sd->data, FALSE, &account, |
7718 | 3970 &protocol, &username, NULL)) |
7712
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3971 { |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3972 if (account == NULL) |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3973 { |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3974 gaim_notify_error(NULL, NULL, |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3975 _("You are not currently signed on with an account that " |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3976 "can add that buddy."), NULL); |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3977 } |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3978 else |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3979 { |
11338 | 3980 c = gaim_conversation_new(GAIM_CONV_TYPE_IM, account, username); |
11581 | 3981 gtkconv = GAIM_GTK_CONVERSATION(c); |
11812 | 3982 if (gtkconv->win != win) |
3983 { | |
3984 gaim_gtk_conv_window_remove_gtkconv(gtkconv->win, gtkconv); | |
3985 gaim_gtk_conv_window_add_gtkconv(win, gtkconv); | |
3986 } | |
7712
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3987 } |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3988 } |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3989 |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3990 if (username != NULL) g_free(username); |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3991 if (protocol != NULL) g_free(protocol); |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3992 |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3993 gtk_drag_finish(dc, TRUE, (dc->action == GDK_ACTION_MOVE), t); |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
3994 } |
9525 | 3995 else if (sd->target == gdk_atom_intern("text/uri-list", FALSE)) { |
11338 | 3996 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
10229 | 3997 gaim_dnd_file_manage(sd, gaim_conversation_get_account(conv), gaim_conversation_get_name(conv)); |
10145 | 3998 gtk_drag_finish(dc, TRUE, (dc->action == GDK_ACTION_MOVE), t); |
9495 | 3999 } |
10145 | 4000 else |
4001 gtk_drag_finish(dc, FALSE, FALSE, t); | |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
4002 } |
4359 | 4003 |
4004 | |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
4005 static const GtkTargetEntry te[] = |
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
4006 { |
10145 | 4007 GTK_IMHTML_DND_TARGETS, |
4008 {"GAIM_BLIST_NODE", GTK_TARGET_SAME_APP, GTK_IMHTML_DRAG_NUM}, | |
4009 {"application/x-im-contact", 0, GTK_IMHTML_DRAG_NUM + 1} | |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
4010 }; |
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
4011 |
10810 | 4012 static GaimGtkConversation * |
4013 gaim_gtk_conv_find_gtkconv(GaimConversation * conv) | |
4014 { | |
4015 GaimBuddy *bud = gaim_find_buddy(conv->account, conv->name), *b; | |
4016 GaimContact *c; | |
4017 GaimBlistNode *cn; | |
10935 | 4018 |
10810 | 4019 if (!bud) |
4020 return NULL; | |
10935 | 4021 |
10810 | 4022 if (!(c = gaim_buddy_get_contact(bud))) |
4023 return NULL; | |
10935 | 4024 |
10810 | 4025 cn = (GaimBlistNode *)c; |
4026 for (b = (GaimBuddy *)cn->child; b; b = (GaimBuddy *) ((GaimBlistNode *)b)->next) { | |
4027 GaimConversation *conv; | |
11338 | 4028 if ((conv = gaim_find_conversation_with_account(GAIM_CONV_TYPE_IM, b->name, b->account))) { |
10810 | 4029 if (conv->ui_data) |
4030 return conv->ui_data; | |
4031 } | |
4032 } | |
10935 | 4033 |
10810 | 4034 return NULL; |
4035 } | |
4036 | |
11855 | 4037 static void |
4038 buddy_update_cb(GaimBlistNode *bnode, gpointer null) | |
4039 { | |
4040 GList *list; | |
4041 | |
4042 g_return_if_fail(bnode); | |
4043 g_return_if_fail(GAIM_BLIST_NODE_IS_BUDDY(bnode)); | |
4044 | |
4045 for (list = gaim_gtk_conv_windows_get_list(); list; list = list->next) | |
4046 { | |
4047 GaimGtkWindow *win = list->data; | |
4048 GaimConversation *conv = gaim_gtk_conv_window_get_active_conversation(win); | |
4049 | |
4050 if (gaim_conversation_get_type(conv) != GAIM_CONV_TYPE_IM) | |
4051 continue; | |
4052 | |
4053 gaim_conversation_update(conv, GAIM_CONV_ACCOUNT_ONLINE); | |
4054 } | |
4055 } | |
4056 | |
11581 | 4057 /************************************************************************** |
4058 * Conversation UI operations | |
4059 **************************************************************************/ | |
12288
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4060 static void |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4061 private_gtkconv_new(GaimConversation *conv, gboolean hidden) |
11581 | 4062 { |
4063 GaimGtkConversation *gtkconv; | |
4064 GaimConversationType conv_type = gaim_conversation_get_type(conv); | |
4359 | 4065 GtkWidget *pane = NULL; |
4066 GtkWidget *tab_cont; | |
11581 | 4067 |
4068 if (conv_type == GAIM_CONV_TYPE_IM && (gtkconv = gaim_gtk_conv_find_gtkconv(conv))) { | |
10810 | 4069 conv->ui_data = gtkconv; |
4070 if (!g_list_find(gtkconv->convs, conv)) | |
4071 gtkconv->convs = g_list_prepend(gtkconv->convs, conv); | |
11604 | 4072 gaim_gtkconv_switch_active_conversation(conv); |
10810 | 4073 return; |
4359 | 4074 } |
4075 | |
11581 | 4076 gtkconv = g_new0(GaimGtkConversation, 1); |
4077 conv->ui_data = gtkconv; | |
4078 gtkconv->active_conv = conv; | |
4079 gtkconv->convs = g_list_prepend(gtkconv->convs, conv); | |
4080 | |
4081 /* Setup some initial variables. */ | |
4082 gtkconv->sg = gtk_size_group_new(GTK_SIZE_GROUP_BOTH); | |
4083 gtkconv->tooltips = gtk_tooltips_new(); | |
12175
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
4084 gtkconv->unseen_state = GAIM_UNSEEN_NONE; |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
4085 gtkconv->unseen_count = 0; |
11581 | 4086 |
4087 if (conv_type == GAIM_CONV_TYPE_IM) { | |
4088 gtkconv->u.im = g_malloc0(sizeof(GaimGtkImPane)); | |
4089 | |
4090 pane = setup_im_pane(gtkconv); | |
4091 } else if (conv_type == GAIM_CONV_TYPE_CHAT) { | |
4092 gtkconv->u.chat = g_malloc0(sizeof(GaimGtkChatPane)); | |
4093 pane = setup_chat_pane(gtkconv); | |
4094 } | |
4095 | |
12101 | 4096 gtk_imhtml_set_format_functions(GTK_IMHTML(gtkconv->imhtml), |
4097 gtk_imhtml_get_format_functions(GTK_IMHTML(gtkconv->imhtml)) | GTK_IMHTML_IMAGE); | |
4098 | |
11581 | 4099 if (pane == NULL) { |
4100 if (conv_type == GAIM_CONV_TYPE_CHAT) | |
4101 g_free(gtkconv->u.chat); | |
4102 else if (conv_type == GAIM_CONV_TYPE_IM) | |
4103 g_free(gtkconv->u.im); | |
4104 | |
4105 g_free(gtkconv); | |
4106 conv->ui_data = NULL; | |
4107 return; | |
10449 | 4108 } |
11581 | 4109 |
4110 /* Setup drag-and-drop */ | |
4111 gtk_drag_dest_set(pane, | |
4112 GTK_DEST_DEFAULT_MOTION | | |
4113 GTK_DEST_DEFAULT_DROP, | |
4114 te, sizeof(te) / sizeof(GtkTargetEntry), | |
4115 GDK_ACTION_COPY); | |
4116 gtk_drag_dest_set(pane, | |
4117 GTK_DEST_DEFAULT_MOTION | | |
4118 GTK_DEST_DEFAULT_DROP, | |
4119 te, sizeof(te) / sizeof(GtkTargetEntry), | |
4120 GDK_ACTION_COPY); | |
4121 gtk_drag_dest_set(gtkconv->imhtml, 0, | |
4122 te, sizeof(te) / sizeof(GtkTargetEntry), | |
4123 GDK_ACTION_COPY); | |
4124 | |
4125 gtk_drag_dest_set(gtkconv->entry, 0, | |
4126 te, sizeof(te) / sizeof(GtkTargetEntry), | |
4127 GDK_ACTION_COPY); | |
4128 | |
4129 g_signal_connect(G_OBJECT(pane), "drag_data_received", | |
4130 G_CALLBACK(conv_dnd_recv), gtkconv); | |
4131 g_signal_connect(G_OBJECT(gtkconv->imhtml), "drag_data_received", | |
4132 G_CALLBACK(conv_dnd_recv), gtkconv); | |
4133 g_signal_connect(G_OBJECT(gtkconv->entry), "drag_data_received", | |
4134 G_CALLBACK(conv_dnd_recv), gtkconv); | |
4135 | |
4136 /* Setup the container for the tab. */ | |
4137 gtkconv->tab_cont = tab_cont = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE); | |
4138 g_object_set_data(G_OBJECT(tab_cont), "GaimGtkConversation", gtkconv); | |
4139 gtk_container_set_border_width(GTK_CONTAINER(tab_cont), GAIM_HIG_BOX_SPACE); | |
4140 gtk_container_add(GTK_CONTAINER(tab_cont), pane); | |
4141 gtk_widget_show(pane); | |
4142 | |
4143 gtkconv->make_sound = TRUE; | |
4144 | |
4145 if (gaim_prefs_get_bool("/gaim/gtk/conversations/show_formatting_toolbar")) | |
4146 gtk_widget_show(gtkconv->toolbar); | |
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5484
diff
changeset
|
4147 else |
11581 | 4148 gtk_widget_hide(gtkconv->toolbar); |
4149 | |
12188 | 4150 gtk_imhtml_show_comments(GTK_IMHTML(gtkconv->imhtml), |
4151 gaim_prefs_get_bool("/gaim/gtk/conversations/show_timestamps")); | |
11603
b97545f21b4c
[gaim-migrate @ 13874]
Gary Kramlich <grim@reaperworld.com>
parents:
11602
diff
changeset
|
4152 gtk_imhtml_set_protocol_name(GTK_IMHTML(gtkconv->imhtml), |
b97545f21b4c
[gaim-migrate @ 13874]
Gary Kramlich <grim@reaperworld.com>
parents:
11602
diff
changeset
|
4153 gaim_account_get_protocol_name(conv->account)); |
11581 | 4154 |
4155 g_signal_connect_swapped(G_OBJECT(pane), "focus", | |
4156 G_CALLBACK(gtk_widget_grab_focus), | |
4157 gtkconv->entry); | |
4158 | |
12288
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4159 if (hidden) |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4160 gaim_gtk_conv_window_add_gtkconv(hidden_convwin, gtkconv); |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4161 else |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4162 gaim_gtkconv_placement_place(gtkconv); |
12345
f6fa5d742c76
[gaim-migrate @ 14649]
Luke Schierer <lschiere@pidgin.im>
parents:
12335
diff
changeset
|
4163 |
12346
f81d458aba18
[gaim-migrate @ 14650]
Richard Laager <rlaager@wiktel.com>
parents:
12345
diff
changeset
|
4164 if (nick_colors == NULL) |
12345
f6fa5d742c76
[gaim-migrate @ 14649]
Luke Schierer <lschiere@pidgin.im>
parents:
12335
diff
changeset
|
4165 nick_colors = generate_nick_colors(NUM_NICK_COLORS, gtk_widget_get_style(gtkconv->imhtml)->base[GTK_STATE_NORMAL]); |
12288
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4166 } |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4167 |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4168 static void |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4169 gaim_gtkconv_new_hidden(GaimConversation *conv) |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4170 { |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4171 private_gtkconv_new(conv, TRUE); |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4172 } |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4173 |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4174 void |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4175 gaim_gtkconv_new(GaimConversation *conv) |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4176 { |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4177 private_gtkconv_new(conv, FALSE); |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4178 } |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4179 |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4180 static void |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4181 received_im_msg_cb(GaimAccount *account, char *sender, char *message, |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4182 GaimConversation *conv, int flags) |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4183 { |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4184 GaimConversationUiOps *ui_ops = gaim_gtk_conversations_get_conv_ui_ops(); |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4185 if(conv) |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4186 return; |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4187 |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4188 /* create hidden conv if hide_new pref is always */ |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4189 if(strcmp(gaim_prefs_get_string("/gaim/gtk/conversations/im/hide_new"), "always")==0) { |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4190 ui_ops->create_conversation = gaim_gtkconv_new_hidden; |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4191 gaim_conversation_new(GAIM_CONV_TYPE_IM, account, sender); |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4192 ui_ops->create_conversation = gaim_gtkconv_new; |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4193 return; |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4194 } |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4195 |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4196 /* create hidden conv if hide_new pref is away and account is away */ |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4197 if(strcmp(gaim_prefs_get_string("/gaim/gtk/conversations/im/hide_new"), "away")==0 |
12310 | 4198 && !gaim_status_is_available(gaim_account_get_active_status(account))) { |
12288
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4199 ui_ops->create_conversation = gaim_gtkconv_new_hidden; |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4200 gaim_conversation_new(GAIM_CONV_TYPE_IM, account, sender); |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4201 ui_ops->create_conversation = gaim_gtkconv_new; |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4202 return; |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
4203 } |
11581 | 4204 } |
4205 | |
4359 | 4206 static void |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4207 gaim_gtkconv_destroy(GaimConversation *conv) |
4359 | 4208 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4209 GaimGtkConversation *gtkconv = GAIM_GTK_CONVERSATION(conv); |
4359 | 4210 |
10810 | 4211 gtkconv->convs = g_list_remove(gtkconv->convs, conv); |
4212 /* Don't destroy ourselves until all our convos are gone */ | |
4213 if (gtkconv->convs) | |
4214 return; | |
11508 | 4215 |
11581 | 4216 gaim_gtk_conv_window_remove_gtkconv(gtkconv->win, gtkconv); |
4217 | |
9504 | 4218 /* If the "Save Conversation" or "Save Icon" dialogs are open then close them */ |
4219 gaim_request_close_with_handle(conv); | |
4359 | 4220 |
4571
51e988d015ed
[gaim-migrate @ 4852]
Christian Hammond <chipx86@chipx86.com>
parents:
4561
diff
changeset
|
4221 gtk_widget_destroy(gtkconv->tab_cont); |
4892 | 4222 g_object_unref(gtkconv->tab_cont); |
4571
51e988d015ed
[gaim-migrate @ 4852]
Christian Hammond <chipx86@chipx86.com>
parents:
4561
diff
changeset
|
4223 |
11338 | 4224 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) { |
4755 | 4225 if (gtkconv->u.im->icon_timer != 0) |
4226 g_source_remove(gtkconv->u.im->icon_timer); | |
4227 | |
4359 | 4228 if (gtkconv->u.im->anim != NULL) |
4793 | 4229 g_object_unref(G_OBJECT(gtkconv->u.im->anim)); |
4359 | 4230 |
4231 g_free(gtkconv->u.im); | |
11581 | 4232 } else if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) { |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4233 gaim_signals_disconnect_by_handle(gtkconv->u.chat); |
4359 | 4234 g_free(gtkconv->u.chat); |
4235 } | |
4236 | |
4633 | 4237 gtk_object_sink(GTK_OBJECT(gtkconv->tooltips)); |
4238 | |
4359 | 4239 g_free(gtkconv); |
4240 } | |
4241 | |
4242 static void | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4243 gaim_gtkconv_write_im(GaimConversation *conv, const char *who, |
6982 | 4244 const char *message, GaimMessageFlags flags, |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4245 time_t mtime) |
4359 | 4246 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4247 GaimGtkConversation *gtkconv; |
4359 | 4248 |
4249 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
11672
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
4250 gaim_gtkconv_set_active_conversation(conv); |
4359 | 4251 |
6982 | 4252 gaim_conversation_write(conv, who, message, flags, mtime); |
4359 | 4253 } |
4254 | |
4255 static void | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4256 gaim_gtkconv_write_chat(GaimConversation *conv, const char *who, |
6621 | 4257 const char *message, GaimMessageFlags flags, time_t mtime) |
4359 | 4258 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4259 GaimGtkConversation *gtkconv; |
4359 | 4260 |
4261 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
11672
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
4262 gaim_gtkconv_set_active_conversation(conv); |
4359 | 4263 |
10398 | 4264 flags |= GAIM_MESSAGE_COLORIZE; |
4359 | 4265 |
6982 | 4266 gaim_conversation_write(conv, who, message, flags, mtime); |
4359 | 4267 } |
4268 | |
10961
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4269 /* The callback for an event on a link tag. */ |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4270 static gboolean buddytag_event(GtkTextTag *tag, GObject *imhtml, |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4271 GdkEvent *event, GtkTextIter *arg2, gpointer data) { |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4272 if (event->type == GDK_BUTTON_PRESS |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4273 || event->type == GDK_2BUTTON_PRESS) { |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4274 GdkEventButton *btn_event = (GdkEventButton*) event; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4275 GaimConversation *conv = data; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4276 char *buddyname; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4277 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4278 /* strlen("BUDDY ") == 6 */ |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4279 g_return_val_if_fail((tag->name != NULL) |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4280 && (strlen(tag->name) > 6), FALSE); |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4281 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4282 buddyname = (tag->name) + 6; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4283 |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4284 if (btn_event->button == 2 |
10961
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4285 && event->type == GDK_2BUTTON_PRESS) { |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4286 chat_do_info(GAIM_GTK_CONVERSATION(conv), buddyname); |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4287 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4288 return TRUE; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4289 } else if (btn_event->button == 3 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4290 && event->type == GDK_BUTTON_PRESS) { |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4291 GtkTextIter start, end; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4292 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4293 /* we shouldn't display the popup |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4294 * if the user has selected something: */ |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4295 if (!gtk_text_buffer_get_selection_bounds( |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4296 gtk_text_iter_get_buffer(arg2), |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4297 &start, &end)) { |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4298 GaimPluginProtocolInfo *prpl_info = NULL; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4299 GtkWidget *menu = NULL; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4300 GaimConnection *gc = |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4301 gaim_conversation_get_gc(conv); |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4302 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4303 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4304 if (gc != NULL) |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4305 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO( |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4306 gc->prpl); |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4307 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4308 menu = create_chat_menu(conv, buddyname, |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4309 prpl_info, gc); |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4310 gtk_menu_popup(GTK_MENU(menu), NULL, NULL, |
10999
56cfc50d2a81
[gaim-migrate @ 12841]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10971
diff
changeset
|
4311 NULL, GTK_WIDGET(imhtml), |
56cfc50d2a81
[gaim-migrate @ 12841]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10971
diff
changeset
|
4312 btn_event->button, |
56cfc50d2a81
[gaim-migrate @ 12841]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10971
diff
changeset
|
4313 btn_event->time); |
10961
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4314 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4315 /* Don't propagate the event any further */ |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4316 return TRUE; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4317 } |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4318 } |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4319 } |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4320 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4321 return FALSE; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4322 } |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4323 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4324 static GtkTextTag *get_buddy_tag(GaimConversation *conv, const char *who) { |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4325 GaimGtkConversation *gtkconv = GAIM_GTK_CONVERSATION(conv); |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4326 GtkTextTag *buddytag; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4327 /* strlen("BUDDY ") == 6 */ |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4328 gchar str[strlen(who) + 7]; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4329 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4330 g_snprintf(str, sizeof(str), "BUDDY %s", who); |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4331 str[sizeof(str)] = '\0'; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4332 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4333 buddytag = gtk_text_tag_table_lookup( |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4334 gtk_text_buffer_get_tag_table( |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4335 GTK_IMHTML(gtkconv->imhtml)->text_buffer), str); |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4336 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4337 if (buddytag == NULL) { |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4338 buddytag = gtk_text_buffer_create_tag( |
11096 | 4339 GTK_IMHTML(gtkconv->imhtml)->text_buffer, str, NULL); |
10961
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4340 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4341 g_signal_connect(G_OBJECT(buddytag), "event", |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4342 G_CALLBACK(buddytag_event), conv); |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4343 } |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4344 |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4345 return buddytag; |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4346 } |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4347 |
4359 | 4348 static void |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4349 gaim_gtkconv_write_conv(GaimConversation *conv, const char *name, const char *alias, |
6982 | 4350 const char *message, GaimMessageFlags flags, |
4359 | 4351 time_t mtime) |
4352 { | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4353 GaimGtkConversation *gtkconv; |
11581 | 4354 GaimGtkWindow *win; |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
4355 GaimConnection *gc; |
11485
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4356 GaimAccount *account; |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4357 GaimPluginProtocolInfo *prpl_info; |
4359 | 4358 int gtk_font_options = 0; |
12553 | 4359 int gtk_font_options_all = 0; |
11224
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4360 int max_scrollback_lines = gaim_prefs_get_int( |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4361 "/gaim/gtk/conversations/scrollback_lines"); |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4362 int line_count; |
4359 | 4363 char buf2[BUF_LONG]; |
4364 char mdate[64]; | |
4365 char color[10]; | |
4366 char *str; | |
4367 char *with_font_tag; | |
4896 | 4368 char *sml_attrib = NULL; |
6982 | 4369 size_t length = strlen(message) + 1; |
4895 | 4370 |
4359 | 4371 gtkconv = GAIM_GTK_CONVERSATION(conv); |
11581 | 4372 |
12553 | 4373 if(gaim_prefs_get_bool("/gaim/gtk/conversations/use_smooth_scrolling")) |
4374 gtk_font_options_all |= GTK_IMHTML_USE_SMOOTHSCROLLING; | |
4375 | |
11581 | 4376 /* Set the active conversation to the one that just messaged us. */ |
4377 /* TODO: consider not doing this if the account is offline or something */ | |
11672
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
4378 gaim_gtkconv_set_active_conversation(conv); |
11581 | 4379 |
4359 | 4380 gc = gaim_conversation_get_gc(conv); |
11485
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4381 account = gaim_conversation_get_account(conv); |
11581 | 4382 win = gtkconv->win; |
11485
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4383 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); |
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5484
diff
changeset
|
4384 |
11224
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4385 line_count = gtk_text_buffer_get_line_count( |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4386 gtk_text_view_get_buffer(GTK_TEXT_VIEW( |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4387 gtkconv->imhtml))); |
11227
8b3d1b2c2c43
[gaim-migrate @ 13365]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11224
diff
changeset
|
4388 |
11224
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4389 /* If we're sitting at more than 100 lines more than the |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4390 max scrollback, trim down to max scrollback */ |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4391 if (max_scrollback_lines > 0 |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4392 && line_count > (max_scrollback_lines + 100)) { |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4393 GtkTextBuffer *text_buffer = gtk_text_view_get_buffer( |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4394 GTK_TEXT_VIEW(gtkconv->imhtml)); |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4395 GtkTextIter start, end; |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4396 |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4397 gtk_text_buffer_get_start_iter(text_buffer, &start); |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4398 gtk_text_buffer_get_iter_at_line(text_buffer, &end, |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4399 (line_count - max_scrollback_lines)); |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4400 gtk_imhtml_delete(GTK_IMHTML(gtkconv->imhtml), &start, &end); |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4401 } |
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
4402 |
8677 | 4403 if (gtk_text_buffer_get_char_count(gtk_text_view_get_buffer(GTK_TEXT_VIEW(gtkconv->imhtml)))) |
12553 | 4404 gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), "<BR>", gtk_font_options_all); |
8677 | 4405 |
5133 | 4406 if(time(NULL) > mtime + 20*60) /* show date if older than 20 minutes */ |
4407 strftime(mdate, sizeof(mdate), "%Y-%m-%d %H:%M:%S", localtime(&mtime)); | |
4408 else | |
4409 strftime(mdate, sizeof(mdate), "%H:%M:%S", localtime(&mtime)); | |
4359 | 4410 |
4896 | 4411 if(gc) |
9699 | 4412 sml_attrib = g_strdup_printf("sml=\"%s\"", |
4413 gaim_account_get_protocol_name(conv->account)); | |
7440 | 4414 |
10503 | 4415 gtk_font_options |= GTK_IMHTML_NO_COMMENTS; |
4359 | 4416 |
12064
658623020748
[gaim-migrate @ 14359]
Richard Laager <rlaager@wiktel.com>
parents:
12061
diff
changeset
|
4417 if ((flags & GAIM_MESSAGE_RECV) && |
658623020748
[gaim-migrate @ 14359]
Richard Laager <rlaager@wiktel.com>
parents:
12061
diff
changeset
|
4418 !gaim_prefs_get_bool("/gaim/gtk/conversations/show_incoming_formatting")) |
11485
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4419 gtk_font_options |= GTK_IMHTML_NO_COLOURS | GTK_IMHTML_NO_FONTS | GTK_IMHTML_NO_SIZES | GTK_IMHTML_NO_FORMATTING; |
4359 | 4420 |
7956 | 4421 /* this is gonna crash one day, I can feel it. */ |
4422 if (GAIM_PLUGIN_PROTOCOL_INFO(gaim_find_prpl(gaim_account_get_protocol_id(conv->account)))->options & | |
7431 | 4423 OPT_PROTO_USE_POINTSIZE) { |
10503 | 4424 gtk_font_options |= GTK_IMHTML_USE_POINTSIZE; |
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5484
diff
changeset
|
4425 } |
4359 | 4426 |
12553 | 4427 |
10737 | 4428 /* TODO: These colors should not be hardcoded so log.c can use them */ |
6621 | 4429 if (flags & GAIM_MESSAGE_SYSTEM) { |
4359 | 4430 g_snprintf(buf2, sizeof(buf2), |
8690 | 4431 "<FONT %s><FONT SIZE=\"2\"><!--(%s) --></FONT><B>%s</B></FONT>", |
10854
bdd72261ec8c
[gaim-migrate @ 12529]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10849
diff
changeset
|
4432 sml_attrib ? sml_attrib : "", mdate, message); |
7440 | 4433 |
12553 | 4434 gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), buf2, gtk_font_options_all); |
7440 | 4435 |
8722 | 4436 } else if (flags & GAIM_MESSAGE_ERROR) { |
4437 g_snprintf(buf2, sizeof(buf2), | |
9627 | 4438 "<FONT COLOR=\"#ff0000\"><FONT %s><FONT SIZE=\"2\"><!--(%s) --></FONT><B>%s</B></FONT></FONT>", |
10854
bdd72261ec8c
[gaim-migrate @ 12529]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10849
diff
changeset
|
4439 sml_attrib ? sml_attrib : "", mdate, message); |
9554 | 4440 |
12553 | 4441 gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), buf2, gtk_font_options_all); |
8962 | 4442 |
7431 | 4443 } else if (flags & GAIM_MESSAGE_NO_LOG) { |
10884 | 4444 g_snprintf(buf2, BUF_LONG, |
8690 | 4445 "<B><FONT %s COLOR=\"#777777\">%s</FONT></B>", |
10854
bdd72261ec8c
[gaim-migrate @ 12529]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10849
diff
changeset
|
4446 sml_attrib ? sml_attrib : "", message); |
7440 | 4447 |
12553 | 4448 gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), buf2, gtk_font_options_all); |
10346 | 4449 } else if (flags & GAIM_MESSAGE_RAW) { |
12553 | 4450 gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), message, gtk_font_options_all); |
10346 | 4451 } else { |
4895 | 4452 char *new_message = g_memdup(message, length); |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4453 char *alias_escaped = (alias ? g_markup_escape_text(alias, strlen(alias)) : g_strdup("")); |
10999
56cfc50d2a81
[gaim-migrate @ 12841]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10971
diff
changeset
|
4454 /* The initial offset is to deal with |
56cfc50d2a81
[gaim-migrate @ 12841]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10971
diff
changeset
|
4455 * escaped entities making the string longer */ |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4456 int tag_start_offset = alias ? (strlen(alias_escaped) - strlen(alias)) : 0; |
10999
56cfc50d2a81
[gaim-migrate @ 12841]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10971
diff
changeset
|
4457 int tag_end_offset = 0; |
7440 | 4458 |
6621 | 4459 if (flags & GAIM_MESSAGE_WHISPER) { |
4359 | 4460 str = g_malloc(1024); |
7440 | 4461 |
4359 | 4462 /* If we're whispering, it's not an autoresponse. */ |
10504 | 4463 if (gaim_message_meify(new_message, -1 )) { |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4464 g_snprintf(str, 1024, "***%s", alias_escaped); |
4359 | 4465 strcpy(color, "#6C2585"); |
10999
56cfc50d2a81
[gaim-migrate @ 12841]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10971
diff
changeset
|
4466 tag_start_offset += 3; |
4359 | 4467 } |
4468 else { | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4469 g_snprintf(str, 1024, "*%s*:", alias_escaped); |
10999
56cfc50d2a81
[gaim-migrate @ 12841]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10971
diff
changeset
|
4470 tag_start_offset += 1; |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4471 tag_end_offset = 2; |
4359 | 4472 strcpy(color, "#00FF00"); |
4473 } | |
7440 | 4474 } |
4359 | 4475 else { |
10504 | 4476 if (gaim_message_meify(new_message, -1)) { |
4359 | 4477 str = g_malloc(1024); |
7440 | 4478 |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4479 if (flags & GAIM_MESSAGE_AUTO_RESP) { |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4480 g_snprintf(str, 1024, "%s ***%s", AUTO_RESPONSE, alias_escaped); |
10999
56cfc50d2a81
[gaim-migrate @ 12841]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10971
diff
changeset
|
4481 tag_start_offset += 4 |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4482 + strlen(AUTO_RESPONSE); |
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4483 } else { |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4484 g_snprintf(str, 1024, "***%s", alias_escaped); |
10999
56cfc50d2a81
[gaim-migrate @ 12841]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10971
diff
changeset
|
4485 tag_start_offset += 3; |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4486 } |
7440 | 4487 |
6621 | 4488 if (flags & GAIM_MESSAGE_NICK) |
12356
4b8c20fcecd6
[gaim-migrate @ 14660]
Richard Laager <rlaager@wiktel.com>
parents:
12354
diff
changeset
|
4489 strcpy(color, HIGHLIGHT_COLOR); |
4359 | 4490 else |
4491 strcpy(color, "#062585"); | |
4492 } | |
4493 else { | |
4494 str = g_malloc(1024); | |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4495 if (flags & GAIM_MESSAGE_AUTO_RESP) { |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4496 g_snprintf(str, 1024, "%s %s", alias_escaped, AUTO_RESPONSE); |
10999
56cfc50d2a81
[gaim-migrate @ 12841]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10971
diff
changeset
|
4497 tag_start_offset += 1 |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4498 + strlen(AUTO_RESPONSE); |
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4499 } else { |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4500 g_snprintf(str, 1024, "%s:", alias_escaped); |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4501 tag_end_offset = 1; |
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4502 } |
6621 | 4503 if (flags & GAIM_MESSAGE_NICK) |
12356
4b8c20fcecd6
[gaim-migrate @ 14660]
Richard Laager <rlaager@wiktel.com>
parents:
12354
diff
changeset
|
4504 strcpy(color, HIGHLIGHT_COLOR); |
6621 | 4505 else if (flags & GAIM_MESSAGE_RECV) { |
10108 | 4506 if (flags & GAIM_MESSAGE_COLORIZE) { |
12579
5e81ae0736c9
[gaim-migrate @ 14904]
Richard Laager <rlaager@wiktel.com>
parents:
12553
diff
changeset
|
4507 GdkColor *col = get_nick_color(gtkconv, name); |
10346 | 4508 |
10108 | 4509 g_snprintf(color, sizeof(color), "#%02X%02X%02X", |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4510 col->red >> 8, col->green >> 8, col->blue >> 8); |
10108 | 4511 } else |
7854 | 4512 strcpy(color, RECV_COLOR); |
4359 | 4513 } |
6621 | 4514 else if (flags & GAIM_MESSAGE_SEND) |
7854 | 4515 strcpy(color, SEND_COLOR); |
10892 | 4516 else { |
4517 gaim_debug_error("gtkconv", "message missing flags\n"); | |
4518 strcpy(color, "#000000"); | |
4519 } | |
4359 | 4520 } |
4521 } | |
10892 | 4522 |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4523 if(alias_escaped) |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4524 g_free(alias_escaped); |
11508 | 4525 |
11485
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4526 /* Are we in a chat where we can tell which users are buddies? */ |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4527 if (!(prpl_info->options & OPT_PROTO_UNIQUE_CHATNAME) && |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4528 gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) { |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4529 |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4530 /* Bold buddies to make them stand out from non-buddies. */ |
11581 | 4531 if (flags & GAIM_MESSAGE_SEND || |
11530
2a13cfe607b5
[gaim-migrate @ 13779]
Richard Laager <rlaager@wiktel.com>
parents:
11525
diff
changeset
|
4532 flags & GAIM_MESSAGE_NICK || |
2a13cfe607b5
[gaim-migrate @ 13779]
Richard Laager <rlaager@wiktel.com>
parents:
11525
diff
changeset
|
4533 gaim_find_buddy(account, name) != NULL) { |
11485
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4534 g_snprintf(buf2, BUF_LONG, |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4535 "<FONT COLOR=\"%s\" %s><FONT SIZE=\"2\"><!--(%s) --></FONT>" |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4536 "<B>%s</B></FONT> ", |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4537 color, sml_attrib ? sml_attrib : "", mdate, str); |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4538 } else { |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4539 g_snprintf(buf2, BUF_LONG, |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4540 "<FONT COLOR=\"%s\" %s><FONT SIZE=\"2\"><!--(%s) --></FONT>" |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4541 "%s</FONT> ", |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4542 color, sml_attrib ? sml_attrib : "", mdate, str); |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4543 |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4544 } |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4545 } else { |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4546 /* Bold everyone's name to make the name stand out from the message. */ |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4547 g_snprintf(buf2, BUF_LONG, |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4548 "<FONT COLOR=\"%s\" %s><FONT SIZE=\"2\"><!--(%s) --></FONT>" |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4549 "<B>%s</B></FONT> ", |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4550 color, sml_attrib ? sml_attrib : "", mdate, str); |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4551 } |
7440 | 4552 |
12553 | 4553 gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), buf2, gtk_font_options_all); |
10961
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4554 |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4555 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT && |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4556 !(flags & GAIM_MESSAGE_SEND)) { |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4557 |
10961
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4558 GtkTextIter start, end; |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4559 GtkTextTag *buddytag = get_buddy_tag(conv, name); |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4560 |
10961
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4561 gtk_text_buffer_get_end_iter( |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4562 GTK_IMHTML(gtkconv->imhtml)->text_buffer, |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4563 &end); |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4564 gtk_text_iter_backward_chars(&end, |
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4565 tag_end_offset + 1); |
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4566 |
10961
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4567 gtk_text_buffer_get_end_iter( |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4568 GTK_IMHTML(gtkconv->imhtml)->text_buffer, |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4569 &start); |
10964
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4570 gtk_text_iter_backward_chars(&start, |
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4571 strlen(str) + 1 - tag_start_offset); |
aae07c7e23a3
[gaim-migrate @ 12771]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10961
diff
changeset
|
4572 |
10961
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4573 gtk_text_buffer_apply_tag( |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4574 GTK_IMHTML(gtkconv->imhtml)->text_buffer, |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4575 buddytag, &start, &end); |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4576 } |
42769b481935
[gaim-migrate @ 12764]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
10953
diff
changeset
|
4577 |
4359 | 4578 g_free(str); |
4579 | |
4895 | 4580 if(gc){ |
4896 | 4581 char *pre = g_strdup_printf("<font %s>", sml_attrib ? sml_attrib : ""); |
4895 | 4582 char *post = "</font>"; |
4583 int pre_len = strlen(pre); | |
4584 int post_len = strlen(post); | |
7440 | 4585 |
4895 | 4586 with_font_tag = g_malloc(length + pre_len + post_len + 1); |
7440 | 4587 |
4895 | 4588 strcpy(with_font_tag, pre); |
4589 memcpy(with_font_tag + pre_len, new_message, length); | |
4590 strcpy(with_font_tag + pre_len + length, post); | |
7440 | 4591 |
4895 | 4592 length += pre_len + post_len; |
4593 g_free(pre); | |
4594 } | |
4608 | 4595 else |
4895 | 4596 with_font_tag = g_memdup(new_message, length); |
7440 | 4597 |
8962 | 4598 gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), |
12553 | 4599 with_font_tag, gtk_font_options | gtk_font_options_all); |
7440 | 4600 |
4601 g_free(with_font_tag); | |
7447 | 4602 g_free(new_message); |
7440 | 4603 } |
4604 | |
5012 | 4605 if(sml_attrib) |
4606 g_free(sml_attrib); | |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4607 |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4608 /* Tab highlighting stuff */ |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4609 if (!gaim_gtkconv_has_focus(conv)) |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4610 { |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4611 GaimUnseenState unseen = GAIM_UNSEEN_NONE; |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4612 |
12021
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
4613 if ((flags & GAIM_MESSAGE_NICK) == GAIM_MESSAGE_NICK) |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4614 unseen = GAIM_UNSEEN_NICK; |
12021
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
4615 else if (((flags & GAIM_MESSAGE_SYSTEM) == GAIM_MESSAGE_SYSTEM) || |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
4616 ((flags & GAIM_MESSAGE_ERROR) == GAIM_MESSAGE_ERROR)) |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4617 unseen = GAIM_UNSEEN_EVENT; |
12021
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
4618 else if ((flags & GAIM_MESSAGE_NO_LOG) == GAIM_MESSAGE_NO_LOG) |
12132
95bffda9b762
[gaim-migrate @ 14432]
Richard Laager <rlaager@wiktel.com>
parents:
12131
diff
changeset
|
4619 unseen = GAIM_UNSEEN_NO_LOG; |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4620 else |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4621 unseen = GAIM_UNSEEN_TEXT; |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4622 |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4623 gtkconv_set_unseen(gtkconv, unseen); |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
4624 } |
4359 | 4625 } |
4626 | |
4627 static void | |
12463
b1717befbb26
[gaim-migrate @ 14773]
Richard Laager <rlaager@wiktel.com>
parents:
12455
diff
changeset
|
4628 gaim_gtkconv_chat_add_users(GaimConversation *conv, GList *users, GList *flags, GList *aliases, gboolean new_arrivals) |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4629 { |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4630 GaimConvChat *chat; |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4631 GaimGtkConversation *gtkconv; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4632 GaimGtkChatPane *gtkchat; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4633 GList *l; |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4634 GList *ll; |
11869 | 4635 GList *lll; |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4636 char tmp[BUF_LONG]; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4637 int num_users; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4638 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4639 chat = GAIM_CONV_CHAT(conv); |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4640 gtkconv = GAIM_GTK_CONVERSATION(conv); |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4641 gtkchat = gtkconv->u.chat; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4642 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4643 num_users = g_list_length(gaim_conv_chat_get_users(chat)); |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4644 |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4645 g_snprintf(tmp, sizeof(tmp), |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4646 ngettext("%d person in room", "%d people in room", |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4647 num_users), |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4648 num_users); |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4649 |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4650 gtk_label_set_text(GTK_LABEL(gtkchat->count), tmp); |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4651 |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4652 l = users; |
11869 | 4653 ll = flags; |
4654 lll = aliases; | |
4655 while (l != NULL && ll != NULL && lll != NULL) { | |
4656 add_chat_buddy_common(conv, (const char *)l->data, GPOINTER_TO_INT(ll->data), (const char *)lll->data, NULL); | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4657 l = l->next; |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4658 ll = ll->next; |
11869 | 4659 lll = lll->next; |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4660 } |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4661 } |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4662 |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4663 static void |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4664 gaim_gtkconv_chat_rename_user(GaimConversation *conv, const char *old_name, |
11485
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4665 const char *new_name, const char *new_alias) |
4359 | 4666 { |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4667 GaimConvChat *chat; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4668 GaimGtkConversation *gtkconv; |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4669 GaimGtkChatPane *gtkchat; |
11869 | 4670 GaimConvChatBuddyFlags flags; |
4359 | 4671 GtkTreeIter iter; |
4672 GtkTreeModel *model; | |
4673 int f = 1; | |
4674 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4675 chat = GAIM_CONV_CHAT(conv); |
4359 | 4676 gtkconv = GAIM_GTK_CONVERSATION(conv); |
4677 gtkchat = gtkconv->u.chat; | |
4678 | |
9554 | 4679 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); |
4680 | |
4681 if (!gtk_tree_model_get_iter_first(GTK_TREE_MODEL(model), &iter)) | |
4682 return; | |
4683 | |
4684 while (f != 0) { | |
4685 char *val; | |
4686 | |
11869 | 4687 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, CHAT_USERS_NAME_COLUMN, &val, CHAT_USERS_FLAGS_COLUMN, &flags, -1); |
9554 | 4688 |
4689 if (!gaim_utf8_strcasecmp(old_name, val)) { | |
4690 gtk_list_store_remove(GTK_LIST_STORE(model), &iter); | |
4691 g_free(val); | |
4359 | 4692 break; |
4693 } | |
9554 | 4694 |
4695 f = gtk_tree_model_iter_next(GTK_TREE_MODEL(model), &iter); | |
4696 | |
4697 g_free(val); | |
4359 | 4698 } |
4699 | |
9554 | 4700 if (!gaim_conv_chat_find_user(chat, old_name)) |
4359 | 4701 return; |
4702 | |
11485
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4703 g_return_if_fail(new_alias != NULL); |
16b0da1f376f
[gaim-migrate @ 13727]
Richard Laager <rlaager@wiktel.com>
parents:
11480
diff
changeset
|
4704 |
11869 | 4705 add_chat_buddy_common(conv, new_name, flags, new_alias, old_name); |
4359 | 4706 } |
4707 | |
4708 static void | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4709 gaim_gtkconv_chat_remove_user(GaimConversation *conv, const char *user) |
4359 | 4710 { |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4711 GaimConvChat *chat; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4712 GaimGtkConversation *gtkconv; |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4713 GaimGtkChatPane *gtkchat; |
4359 | 4714 GtkTreeIter iter; |
4715 GtkTreeModel *model; | |
4716 char tmp[BUF_LONG]; | |
4717 int num_users; | |
4718 int f = 1; | |
4719 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4720 chat = GAIM_CONV_CHAT(conv); |
4359 | 4721 gtkconv = GAIM_GTK_CONVERSATION(conv); |
4722 gtkchat = gtkconv->u.chat; | |
4723 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4724 num_users = g_list_length(gaim_conv_chat_get_users(chat)) - 1; |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4725 |
9554 | 4726 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); |
4727 | |
4728 if (!gtk_tree_model_get_iter_first(GTK_TREE_MODEL(model), &iter)) | |
4729 return; | |
4730 | |
4731 while (f != 0) { | |
4732 char *val; | |
4733 | |
4734 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, CHAT_USERS_NAME_COLUMN, &val, -1); | |
4735 | |
4736 if (!gaim_utf8_strcasecmp(user, val)) { | |
4737 gtk_list_store_remove(GTK_LIST_STORE(model), &iter); | |
4738 g_free(val); | |
4359 | 4739 break; |
4740 } | |
9554 | 4741 |
4742 f = gtk_tree_model_iter_next(GTK_TREE_MODEL(model), &iter); | |
4743 | |
4744 g_free(val); | |
4359 | 4745 } |
4746 | |
9554 | 4747 if (!gaim_conv_chat_find_user(chat, user)) |
4359 | 4748 return; |
4749 | |
4750 g_snprintf(tmp, sizeof(tmp), | |
9554 | 4751 ngettext("%d person in room", "%d people in room", |
4752 num_users), num_users); | |
4359 | 4753 |
4754 gtk_label_set_text(GTK_LABEL(gtkchat->count), tmp); | |
4755 | |
4756 } | |
4757 | |
4758 static void | |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4759 gaim_gtkconv_chat_remove_users(GaimConversation *conv, GList *users) |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4760 { |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4761 GaimConvChat *chat; |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4762 GaimGtkConversation *gtkconv; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4763 GaimGtkChatPane *gtkchat; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4764 GtkTreeIter iter; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4765 GtkTreeModel *model; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4766 GList *l; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4767 char tmp[BUF_LONG]; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4768 int num_users; |
8256
1d86096ae0f4
[gaim-migrate @ 8979]
Christian Hammond <chipx86@chipx86.com>
parents:
8253
diff
changeset
|
4769 gboolean f; |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4770 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4771 chat = GAIM_CONV_CHAT(conv); |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4772 gtkconv = GAIM_GTK_CONVERSATION(conv); |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4773 gtkchat = gtkconv->u.chat; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4774 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4775 num_users = g_list_length(gaim_conv_chat_get_users(chat)) - |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4776 g_list_length(users); |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4777 |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4778 for (l = users; l != NULL; l = l->next) { |
9554 | 4779 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); |
4780 | |
10812
d087e928ffd1
[gaim-migrate @ 12465]
Luke Schierer <lschiere@pidgin.im>
parents:
10810
diff
changeset
|
4781 if (!gtk_tree_model_get_iter_first(GTK_TREE_MODEL(model), &iter)) |
9554 | 4782 continue; |
4783 | |
4784 do { | |
4785 char *val; | |
4786 | |
4787 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, | |
4788 CHAT_USERS_NAME_COLUMN, &val, -1); | |
4789 | |
9696 | 4790 if (!gaim_utf8_strcasecmp((char *)l->data, val)) { |
4791 #if GTK_CHECK_VERSION(2,2,0) | |
9554 | 4792 f = gtk_list_store_remove(GTK_LIST_STORE(model), &iter); |
9696 | 4793 #else |
4794 gtk_list_store_remove(GTK_LIST_STORE(model), &iter); | |
4795 f = gtk_tree_model_iter_next(GTK_TREE_MODEL(model), &iter); | |
4796 #endif | |
4797 } | |
9554 | 4798 else |
4799 f = gtk_tree_model_iter_next(GTK_TREE_MODEL(model), &iter); | |
4800 | |
4801 g_free(val); | |
4802 } while (f); | |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4803 } |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4804 |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4805 g_snprintf(tmp, sizeof(tmp), |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4806 ngettext("%d person in room", "%d people in room", |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4807 num_users), num_users); |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4808 |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4809 gtk_label_set_text(GTK_LABEL(gtkchat->count), tmp); |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4810 } |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
4811 |
9554 | 4812 static void |
4813 gaim_gtkconv_chat_update_user(GaimConversation *conv, const char *user) | |
4814 { | |
4815 GaimConvChat *chat; | |
11869 | 4816 GaimConvChatBuddyFlags flags; |
9554 | 4817 GaimGtkConversation *gtkconv; |
4818 GaimGtkChatPane *gtkchat; | |
4819 GtkTreeIter iter; | |
4820 GtkTreeModel *model; | |
4821 int f = 1; | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4822 char *alias = NULL; |
9554 | 4823 |
4824 chat = GAIM_CONV_CHAT(conv); | |
4825 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
4826 gtkchat = gtkconv->u.chat; | |
4827 | |
4828 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); | |
4829 | |
4830 if (!gtk_tree_model_get_iter_first(GTK_TREE_MODEL(model), &iter)) | |
4831 return; | |
4832 | |
4833 while (f != 0) { | |
4834 char *val; | |
4835 | |
4836 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, CHAT_USERS_NAME_COLUMN, &val, -1); | |
4837 | |
4838 if (!gaim_utf8_strcasecmp(user, val)) { | |
11500
9fc7d0153332
[gaim-migrate @ 13745]
Richard Laager <rlaager@wiktel.com>
parents:
11486
diff
changeset
|
4839 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, CHAT_USERS_ALIAS_COLUMN, &alias, -1); |
9554 | 4840 gtk_list_store_remove(GTK_LIST_STORE(model), &iter); |
4841 g_free(val); | |
4842 break; | |
4843 } | |
4844 | |
4845 f = gtk_tree_model_iter_next(GTK_TREE_MODEL(model), &iter); | |
4846 | |
4847 g_free(val); | |
4848 } | |
4849 | |
4850 if (!gaim_conv_chat_find_user(chat, user)) | |
4851 return; | |
4852 | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4853 g_return_if_fail(alias != NULL); |
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4854 |
11869 | 4855 flags = gaim_conv_chat_user_get_flags(chat, user); |
4856 | |
4857 add_chat_buddy_common(conv, user, flags, alias, NULL); | |
11454
201617d49573
[gaim-migrate @ 13693]
Richard Laager <rlaager@wiktel.com>
parents:
11453
diff
changeset
|
4858 g_free(alias); |
9554 | 4859 } |
4860 | |
11581 | 4861 gboolean |
9260
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
4862 gaim_gtkconv_has_focus(GaimConversation *conv) |
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
4863 { |
11581 | 4864 GaimGtkConversation *gtkconv = GAIM_GTK_CONVERSATION(conv); |
4865 GaimGtkWindow *win; | |
9260
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
4866 gboolean has_focus; |
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
4867 |
11581 | 4868 win = gtkconv->win; |
4869 | |
4870 g_object_get(G_OBJECT(win->window), "has-toplevel-focus", &has_focus, NULL); | |
9260
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
4871 |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
4872 if (has_focus && gaim_gtk_conv_window_is_active_conversation(conv)) |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
4873 return TRUE; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
4874 |
11684
c1906dc6257c
[gaim-migrate @ 13970]
Luke Schierer <lschiere@pidgin.im>
parents:
11672
diff
changeset
|
4875 return FALSE; |
9260
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
4876 } |
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
4877 |
12335 | 4878 static void gaim_gtkconv_custom_smiley_allocated(GdkPixbufLoader *loader, gpointer user_data) |
4879 { | |
4880 GtkIMHtmlSmiley *smiley; | |
4881 | |
4882 smiley = (GtkIMHtmlSmiley *)user_data; | |
4883 smiley->icon = gdk_pixbuf_loader_get_animation(loader); | |
4884 | |
4885 if (smiley->icon) | |
4886 g_object_ref(G_OBJECT(smiley->icon)); | |
4887 #ifdef DEBUG_CUSTOM_SMILEY | |
4888 gaim_debug_info("custom-smiley", "%s(): got GdkPixbufAnimation %p for smiley '%s'\n", __FUNCTION__, smiley->icon, smiley->smile); | |
4889 #endif | |
4890 } | |
4891 | |
4892 static void gaim_gtkconv_custom_smiley_closed(GdkPixbufLoader *loader, gpointer user_data) | |
4893 { | |
4894 GtkIMHtmlSmiley *smiley; | |
4895 GtkWidget *icon = NULL; | |
4896 GtkTextChildAnchor *anchor = NULL; | |
4897 GSList *current = NULL; | |
4898 | |
4899 smiley = (GtkIMHtmlSmiley *)user_data; | |
4900 if (!smiley->imhtml) { | |
4901 #ifdef DEBUG_CUSTOM_SMILEY | |
4902 gaim_debug_error("custom-smiley", "%s(): orphan smiley found: %p\n", __FUNCTION__, smiley); | |
4903 #endif | |
4904 g_object_unref(G_OBJECT(loader)); | |
4905 smiley->loader = NULL; | |
4906 return; | |
4907 } | |
4908 | |
4909 for (current = smiley->anchors; current; current = g_slist_next(current)) { | |
4910 | |
4911 icon = gtk_image_new_from_animation(smiley->icon); | |
4912 | |
4913 #ifdef DEBUG_CUSTOM_SMILEY | |
4914 gaim_debug_info("custom-smiley", "%s(): got GtkImage %p from GtkPixbufAnimation %p for smiley '%s'\n", | |
4915 __FUNCTION__, icon, smiley->icon, smiley->smile); | |
4916 #endif | |
4917 if (icon) { | |
4918 gtk_widget_show(icon); | |
4919 | |
4920 anchor = GTK_TEXT_CHILD_ANCHOR(current->data); | |
4921 | |
4922 g_object_set_data_full(G_OBJECT(anchor), "gtkimhtml_plaintext", g_strdup(gaim_unescape_html(smiley->smile)), g_free); | |
4923 g_object_set_data_full(G_OBJECT(anchor), "gtkimhtml_htmltext", g_strdup(smiley->smile), g_free); | |
4924 | |
4925 if (smiley->imhtml) | |
4926 gtk_text_view_add_child_at_anchor(GTK_TEXT_VIEW(smiley->imhtml), icon, anchor); | |
4927 } | |
4928 | |
4929 } | |
4930 | |
4931 g_slist_free(smiley->anchors); | |
4932 smiley->anchors = NULL; | |
4933 | |
4934 g_object_unref(G_OBJECT(loader)); | |
4935 smiley->loader = NULL; | |
4936 } | |
4937 | |
10526 | 4938 static gboolean |
4939 gaim_gtkconv_custom_smiley_add(GaimConversation *conv, const char *smile) | |
4940 { | |
4941 GaimGtkConversation *gtkconv; | |
4942 GtkIMHtmlSmiley *smiley; | |
4943 GdkPixbufLoader *loader; | |
11525 | 4944 struct smiley_list *list; |
4945 const char *sml = NULL, *conv_sml; | |
4946 | |
4947 if (!conv || !smile || !*smile) { | |
10526 | 4948 return FALSE; |
4949 } | |
4950 | |
11525 | 4951 /* If smileys are off, return false */ |
4952 if (gaim_gtkthemes_smileys_disabled()) | |
4953 return FALSE; | |
4954 | |
4955 /* If possible add this smiley to the current theme. | |
4956 * The addition is only temporary: custom smilies aren't saved to disk. */ | |
4957 conv_sml = gaim_account_get_protocol_name(conv->account); | |
10526 | 4958 gtkconv = GAIM_GTK_CONVERSATION(conv); |
11525 | 4959 |
4960 for (list = (struct smiley_list *)current_smiley_theme->list; list; list = list->next) { | |
4961 if (!strcmp(list->sml, conv_sml)) { | |
4962 sml = list->sml; | |
4963 break; | |
4964 } | |
4965 } | |
4966 | |
10526 | 4967 smiley = gtk_imhtml_smiley_get(GTK_IMHTML(gtkconv->imhtml), sml, smile); |
4968 | |
4969 if (smiley) { | |
11525 | 4970 |
4971 if (!(smiley->flags & GTK_IMHTML_SMILEY_CUSTOM)) { | |
4972 return FALSE; | |
4973 } | |
4974 | |
4975 /* Close the old GdkPixbufAnimation, then create a new one for | |
4976 * the smiley we are about to receive */ | |
4977 g_object_unref(G_OBJECT(smiley->icon)); | |
4978 | |
4979 smiley->loader = gdk_pixbuf_loader_new(); | |
12335 | 4980 smiley->icon = NULL; |
4981 | |
4982 g_signal_connect(smiley->loader, "area_prepared", G_CALLBACK(gaim_gtkconv_custom_smiley_allocated), smiley); | |
4983 g_signal_connect(smiley->loader, "closed", G_CALLBACK(gaim_gtkconv_custom_smiley_closed), smiley); | |
4984 | |
11525 | 4985 return TRUE; |
10526 | 4986 } |
4987 | |
4988 loader = gdk_pixbuf_loader_new(); | |
4989 | |
4990 /* this is wrong, this file ought not call g_new on GtkIMHtmlSmiley */ | |
4991 /* Let gtk_imhtml have a gtk_imhtml_smiley_new function, and let | |
10812
d087e928ffd1
[gaim-migrate @ 12465]
Luke Schierer <lschiere@pidgin.im>
parents:
10810
diff
changeset
|
4992 GtkIMHtmlSmiley by opaque */ |
10526 | 4993 smiley = g_new0(GtkIMHtmlSmiley, 1); |
4994 smiley->file = NULL; | |
4995 smiley->smile = g_strdup(smile); | |
4996 smiley->loader = loader; | |
11525 | 4997 smiley->flags = smiley->flags | GTK_IMHTML_SMILEY_CUSTOM; |
10526 | 4998 |
12335 | 4999 g_signal_connect(smiley->loader, "area_prepared", G_CALLBACK(gaim_gtkconv_custom_smiley_allocated), smiley); |
5000 g_signal_connect(smiley->loader, "closed", G_CALLBACK(gaim_gtkconv_custom_smiley_closed), smiley); | |
11525 | 5001 |
10526 | 5002 gtk_imhtml_associate_smiley(GTK_IMHTML(gtkconv->imhtml), sml, smiley); |
10537 | 5003 |
10526 | 5004 return TRUE; |
5005 } | |
5006 | |
10537 | 5007 static void |
10526 | 5008 gaim_gtkconv_custom_smiley_write(GaimConversation *conv, const char *smile, |
11137 | 5009 const guchar *data, gsize size) |
10526 | 5010 { |
5011 GaimGtkConversation *gtkconv; | |
5012 GtkIMHtmlSmiley *smiley; | |
10537 | 5013 GdkPixbufLoader *loader; |
10526 | 5014 const char *sml; |
5015 | |
5016 sml = gaim_account_get_protocol_name(conv->account); | |
5017 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
5018 smiley = gtk_imhtml_smiley_get(GTK_IMHTML(gtkconv->imhtml), sml, smile); | |
5019 | |
10537 | 5020 if (!smiley) |
10526 | 5021 return; |
10537 | 5022 |
10526 | 5023 loader = smiley->loader; |
10537 | 5024 if (!loader) |
10526 | 5025 return; |
5026 | |
5027 gdk_pixbuf_loader_write(loader, data, size, NULL); | |
5028 } | |
5029 | |
5030 static void | |
5031 gaim_gtkconv_custom_smiley_close(GaimConversation *conv, const char *smile) | |
5032 { | |
5033 GaimGtkConversation *gtkconv; | |
5034 GtkIMHtmlSmiley *smiley; | |
5035 GdkPixbufLoader *loader; | |
5036 const char *sml; | |
5037 | |
5038 g_return_if_fail(conv != NULL); | |
5039 g_return_if_fail(smile != NULL); | |
5040 | |
5041 sml = gaim_account_get_protocol_name(conv->account); | |
5042 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
5043 smiley = gtk_imhtml_smiley_get(GTK_IMHTML(gtkconv->imhtml), sml, smile); | |
5044 | |
10537 | 5045 if (!smiley) |
10526 | 5046 return; |
5047 | |
5048 loader = smiley->loader; | |
5049 | |
10537 | 5050 if (!loader) |
10526 | 5051 return; |
10537 | 5052 |
12335 | 5053 |
11525 | 5054 |
10526 | 5055 gaim_debug_info("gtkconv", "About to close the smiley pixbuf\n"); |
5056 | |
5057 gdk_pixbuf_loader_close(loader, NULL); | |
12335 | 5058 |
10526 | 5059 } |
5060 | |
11581 | 5061 /* |
5062 * Makes sure all the menu items and all the buttons are hidden/shown and | |
5063 * sensitive/insensitive. This is called after changing tabs and when an | |
5064 * account signs on or off. | |
5065 */ | |
5066 static void | |
5067 gray_stuff_out(GaimGtkConversation *gtkconv) | |
5068 { | |
5069 GaimGtkWindow *win; | |
5070 GaimConversation *conv = gtkconv->active_conv; | |
5071 GaimConnection *gc; | |
5072 GaimPluginProtocolInfo *prpl_info = NULL; | |
5073 GdkPixbuf *window_icon = NULL; | |
5074 GtkIMHtmlButtons buttons; | |
5075 GaimAccount *account; | |
5076 | |
5077 win = gaim_gtkconv_get_window(gtkconv); | |
5078 gc = gaim_conversation_get_gc(conv); | |
5079 account = gaim_conversation_get_account(conv); | |
5080 | |
5081 if (gc != NULL) | |
5082 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); | |
5083 | |
11594 | 5084 if (win->menu.send_to != NULL) |
11734 | 5085 update_send_to_selection(win); |
11581 | 5086 |
5087 /* | |
5088 * Handle hiding and showing stuff based on what type of conv this is. | |
5089 * Stuff that Gaim IMs support in general should be shown for IM | |
5090 * conversations. Stuff that Gaim chats support in general should be | |
5091 * shown for chat conversations. It doesn't matter whether the PRPL | |
5092 * supports it or not--that only affects if the button or menu item | |
5093 * is sensitive or not. | |
5094 */ | |
5095 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) { | |
5096 /* Show stuff that applies to IMs, hide stuff that applies to chats */ | |
5097 | |
5098 /* Deal with menu items */ | |
5099 gtk_widget_show(win->menu.view_log); | |
5100 gtk_widget_show(win->menu.send_file); | |
5101 gtk_widget_show(win->menu.add_pounce); | |
5102 gtk_widget_show(win->menu.get_info); | |
5103 gtk_widget_hide(win->menu.invite); | |
5104 gtk_widget_show(win->menu.alias); | |
5105 gtk_widget_show(win->menu.block); | |
5106 | |
5107 if (gaim_find_buddy(account, gaim_conversation_get_name(conv)) == NULL) { | |
5108 gtk_widget_show(win->menu.add); | |
5109 gtk_widget_hide(win->menu.remove); | |
5110 } else { | |
5111 gtk_widget_show(win->menu.remove); | |
5112 gtk_widget_hide(win->menu.add); | |
5113 } | |
5114 | |
5115 gtk_widget_show(win->menu.insert_link); | |
5116 gtk_widget_show(win->menu.insert_image); | |
5117 gtk_widget_show(win->menu.show_icon); | |
5118 } else if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) { | |
5119 /* Show stuff that applies to Chats, hide stuff that applies to IMs */ | |
5120 | |
5121 /* Deal with menu items */ | |
5122 gtk_widget_show(win->menu.view_log); | |
5123 gtk_widget_hide(win->menu.send_file); | |
5124 gtk_widget_hide(win->menu.add_pounce); | |
5125 gtk_widget_hide(win->menu.get_info); | |
5126 gtk_widget_show(win->menu.invite); | |
5127 gtk_widget_show(win->menu.alias); | |
5128 gtk_widget_hide(win->menu.block); | |
5129 gtk_widget_hide(win->menu.show_icon); | |
5130 | |
5131 if (gaim_blist_find_chat(account, gaim_conversation_get_name(conv)) == NULL) { | |
5132 /* If the chat is NOT in the buddy list */ | |
5133 gtk_widget_show(win->menu.add); | |
5134 gtk_widget_hide(win->menu.remove); | |
5135 } else { | |
5136 /* If the chat IS in the buddy list */ | |
5137 gtk_widget_hide(win->menu.add); | |
5138 gtk_widget_show(win->menu.remove); | |
5139 } | |
5140 | |
5141 gtk_widget_show(win->menu.insert_link); | |
5142 gtk_widget_hide(win->menu.insert_image); | |
5143 } | |
5144 | |
5145 /* | |
5146 * Handle graying stuff out based on whether an account is connected | |
5147 * and what features that account supports. | |
5148 */ | |
5149 if ((gc != NULL) && | |
12012 | 5150 ((gaim_conversation_get_type(conv) != GAIM_CONV_TYPE_CHAT) || |
5151 !gaim_conv_chat_has_left(GAIM_CONV_CHAT(conv)) )) | |
5152 { | |
11581 | 5153 /* Account is online */ |
5154 /* Deal with the toolbar */ | |
12012 | 5155 if (conv->features & GAIM_CONNECTION_HTML) |
5156 { | |
5157 buttons = GTK_IMHTML_ALL; /* Everything on */ | |
5158 if (conv->features & GAIM_CONNECTION_NO_BGCOLOR) | |
5159 buttons &= ~GTK_IMHTML_BACKCOLOR; | |
5160 if (conv->features & GAIM_CONNECTION_NO_FONTSIZE) | |
5161 { | |
5162 buttons &= ~GTK_IMHTML_GROW; | |
5163 buttons &= ~GTK_IMHTML_SHRINK; | |
5164 } | |
5165 if (conv->features & GAIM_CONNECTION_NO_URLDESC) | |
5166 buttons &= ~GTK_IMHTML_LINKDESC; | |
5167 } else { | |
12216 | 5168 buttons = GTK_IMHTML_SMILEY | GTK_IMHTML_IMAGE; |
12012 | 5169 } |
12216 | 5170 |
5171 if (!(prpl_info->options & OPT_PROTO_IM_IMAGE) || | |
5172 conv->features & GAIM_CONNECTION_NO_IMAGES) | |
5173 buttons &= ~GTK_IMHTML_IMAGE; | |
5174 | |
12012 | 5175 gtk_imhtml_set_format_functions(GTK_IMHTML(gtkconv->entry), buttons); |
5176 gtk_imhtmltoolbar_associate_smileys(GTK_IMHTMLTOOLBAR(gtkconv->toolbar), gaim_account_get_protocol_id(account)); | |
11581 | 5177 |
5178 /* Deal with menu items */ | |
12012 | 5179 gtk_widget_set_sensitive(win->menu.view_log, TRUE); |
5180 gtk_widget_set_sensitive(win->menu.add_pounce, TRUE); | |
5181 gtk_widget_set_sensitive(win->menu.get_info, (prpl_info->get_info != NULL)); | |
5182 gtk_widget_set_sensitive(win->menu.invite, (prpl_info->chat_invite != NULL)); | |
5183 gtk_widget_set_sensitive(win->menu.block, (prpl_info->add_deny != NULL)); | |
5184 gtk_widget_set_sensitive(win->menu.insert_link, (conv->features & GAIM_CONNECTION_HTML)); | |
12099 | 5185 gtk_widget_set_sensitive(win->menu.insert_image, (prpl_info->options & OPT_PROTO_IM_IMAGE) && !(conv->features & GAIM_CONNECTION_NO_IMAGES)); |
12012 | 5186 |
5187 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) | |
5188 { | |
5189 gtk_widget_set_sensitive(win->menu.add, (prpl_info->add_buddy != NULL)); | |
5190 gtk_widget_set_sensitive(win->menu.remove, (prpl_info->remove_buddy != NULL)); | |
5191 gtk_widget_set_sensitive(win->menu.send_file, | |
5192 (prpl_info->send_file != NULL && (!prpl_info->can_receive_file || | |
5193 prpl_info->can_receive_file(gc, gaim_conversation_get_name(conv))))); | |
5194 gtk_widget_set_sensitive(win->menu.alias, | |
5195 (gaim_find_buddy(account, gaim_conversation_get_name(conv)) != NULL)); | |
5196 } | |
5197 else if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) | |
5198 { | |
5199 gtk_widget_set_sensitive(win->menu.add, (prpl_info->join_chat != NULL)); | |
5200 gtk_widget_set_sensitive(win->menu.remove, (prpl_info->join_chat != NULL)); | |
5201 gtk_widget_set_sensitive(win->menu.alias, | |
5202 (gaim_blist_find_chat(account, gaim_conversation_get_name(conv)) != NULL)); | |
5203 } | |
11581 | 5204 |
5205 /* Deal with chat userlist buttons */ | |
12012 | 5206 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) |
5207 { | |
5208 gtk_widget_set_sensitive(gtkconv->u.chat->userlist_im, TRUE); | |
5209 gtk_widget_set_sensitive(gtkconv->u.chat->userlist_ignore, TRUE); | |
5210 gtk_widget_set_sensitive(gtkconv->u.chat->userlist_info, (prpl_info->get_info != NULL)); | |
5211 } | |
5212 } else { | |
11581 | 5213 /* Account is offline */ |
5214 /* Or it's a chat that we've left. */ | |
5215 | |
5216 /* Then deal with menu items */ | |
12012 | 5217 gtk_widget_set_sensitive(win->menu.view_log, TRUE); |
5218 gtk_widget_set_sensitive(win->menu.send_file, FALSE); | |
5219 gtk_widget_set_sensitive(win->menu.add_pounce, TRUE); | |
5220 gtk_widget_set_sensitive(win->menu.get_info, FALSE); | |
5221 gtk_widget_set_sensitive(win->menu.invite, FALSE); | |
5222 gtk_widget_set_sensitive(win->menu.alias, FALSE); | |
5223 gtk_widget_set_sensitive(win->menu.block, FALSE); | |
5224 gtk_widget_set_sensitive(win->menu.add, FALSE); | |
5225 gtk_widget_set_sensitive(win->menu.remove, FALSE); | |
5226 gtk_widget_set_sensitive(win->menu.insert_link, TRUE); | |
5227 gtk_widget_set_sensitive(win->menu.insert_image, FALSE); | |
11581 | 5228 |
5229 /* Deal with chat userlist buttons */ | |
12012 | 5230 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) |
5231 { | |
5232 gtk_widget_set_sensitive(gtkconv->u.chat->userlist_im, FALSE); | |
5233 gtk_widget_set_sensitive(gtkconv->u.chat->userlist_ignore, FALSE); | |
5234 gtk_widget_set_sensitive(gtkconv->u.chat->userlist_info, FALSE); | |
5235 } | |
5236 } | |
11581 | 5237 |
5238 /* | |
5239 * Update the window's icon | |
5240 */ | |
12171 | 5241 if (gaim_gtk_conv_window_is_active_conversation(conv)) |
11581 | 5242 { |
12171 | 5243 if ((gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) && |
5244 (gtkconv->u.im->anim)) | |
5245 { | |
5246 window_icon = | |
5247 gdk_pixbuf_animation_get_static_image(gtkconv->u.im->anim); | |
5248 g_object_ref(window_icon); | |
5249 } else { | |
5250 window_icon = gaim_gtkconv_get_tab_icon(conv, FALSE); | |
5251 } | |
5252 gtk_window_set_icon(GTK_WINDOW(win->window), window_icon); | |
5253 if (window_icon != NULL) | |
5254 g_object_unref(G_OBJECT(window_icon)); | |
5255 } | |
11581 | 5256 } |
5257 | |
10526 | 5258 |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5259 static void |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5260 gaim_gtkconv_updated(GaimConversation *conv, GaimConvUpdateType type) |
4359 | 5261 { |
11581 | 5262 GaimGtkWindow *win; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5263 GaimGtkConversation *gtkconv; |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5264 GaimGtkChatPane *gtkchat; |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
5265 GaimConvChat *chat; |
4359 | 5266 |
10116 | 5267 g_return_if_fail(conv != NULL); |
5268 | |
4359 | 5269 gtkconv = GAIM_GTK_CONVERSATION(conv); |
11581 | 5270 win = gtkconv->win; |
10810 | 5271 conv = gtkconv->active_conv; /* Gross hack */ |
11581 | 5272 /* Maybe we should just ignore it if conv != gtkconv->active_conv, |
5273 * instead of the gross hack? | |
5274 */ | |
4359 | 5275 |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5276 if (type == GAIM_CONV_UPDATE_ACCOUNT) |
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5277 { |
4359 | 5278 gaim_conversation_autoset_title(conv); |
5881
cc7870e1e3b3
[gaim-migrate @ 6313]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
5279 |
11338 | 5280 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
5881
cc7870e1e3b3
[gaim-migrate @ 6313]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
5281 gaim_gtkconv_update_buddy_icon(conv); |
cc7870e1e3b3
[gaim-migrate @ 6313]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
5282 |
4359 | 5283 gaim_gtkconv_update_buttons_by_protocol(conv); |
5284 | |
11734 | 5285 update_send_to_selection(win); |
4359 | 5286 |
11525 | 5287 gaim_gtkthemes_smiley_themeize(gtkconv->imhtml); |
6394 | 5288 |
6395 | 5289 update_tab_icon(conv); |
4359 | 5290 } |
5291 else if (type == GAIM_CONV_UPDATE_TYPING || | |
8155
77d1252b3803
[gaim-migrate @ 8867]
Christian Hammond <chipx86@chipx86.com>
parents:
8143
diff
changeset
|
5292 type == GAIM_CONV_UPDATE_UNSEEN || |
77d1252b3803
[gaim-migrate @ 8867]
Christian Hammond <chipx86@chipx86.com>
parents:
8143
diff
changeset
|
5293 type == GAIM_CONV_UPDATE_TITLE) |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5294 { |
9472 | 5295 char *title; |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
5296 GaimConvIm *im = NULL; |
12131
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5297 GaimAccount *account = gaim_conversation_get_account(conv); |
11737
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5298 /* I think this is a little longer than it needs to be but I'm lazy. */ |
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5299 char style[51]; |
4736 | 5300 |
11338 | 5301 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
5302 im = GAIM_CONV_IM(conv); |
4359 | 5303 |
12131
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5304 if (!gaim_account_is_connected(account) |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5305 || ((gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_CHAT) |
9472 | 5306 && gaim_conv_chat_has_left(GAIM_CONV_CHAT(conv)))) |
5307 title = g_strdup_printf("(%s)", gaim_conversation_get_title(conv)); | |
5308 else | |
5309 title = g_strdup(gaim_conversation_get_title(conv)); | |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5310 |
11737
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5311 *style = '\0'; |
4359 | 5312 |
5313 if (!GTK_WIDGET_REALIZED(gtkconv->tab_label)) | |
5314 gtk_widget_realize(gtkconv->tab_label); | |
5315 | |
11737
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5316 if (im != NULL && |
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5317 gaim_conv_im_get_typing_state(im) == GAIM_TYPING) |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5318 { |
11759 | 5319 strncpy(style, "color=\"#47A046\"", sizeof(style)); |
4359 | 5320 } |
11737
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5321 else if (im != NULL && |
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5322 gaim_conv_im_get_typing_state(im) == GAIM_TYPED) |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5323 { |
11737
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5324 strncpy(style, "color=\"#D1940C\"", sizeof(style)); |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5325 } |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
5326 else if (gtkconv->unseen_state == GAIM_UNSEEN_NICK) |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5327 { |
11737
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5328 strncpy(style, "color=\"#0D4E91\" style=\"italic\" weight=\"bold\"", sizeof(style)); |
4359 | 5329 } |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
5330 else if (gtkconv->unseen_state == GAIM_UNSEEN_TEXT) |
8252 | 5331 { |
11737
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5332 strncpy(style, "color=\"#DF421E\" weight=\"bold\"", sizeof(style)); |
8252 | 5333 } |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
5334 else if (gtkconv->unseen_state == GAIM_UNSEEN_EVENT) |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5335 { |
11758 | 5336 strncpy(style, "color=\"#868272\" style=\"italic\"", sizeof(style)); |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5337 } |
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5338 |
11737
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5339 if (*style != '\0') |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5340 { |
8536 | 5341 char *html_title,*label; |
5342 | |
10732
c4cb90065e1d
[gaim-migrate @ 12334]
Luke Schierer <lschiere@pidgin.im>
parents:
10698
diff
changeset
|
5343 html_title = g_markup_escape_text(title, -1); |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5344 |
11737
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5345 label = g_strdup_printf("<span %s>%s</span>", |
3959c29f340f
[gaim-migrate @ 14028]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11734
diff
changeset
|
5346 style, html_title); |
8536 | 5347 g_free(html_title); |
7995
87d3260f961a
[gaim-migrate @ 8672]
Christian Hammond <chipx86@chipx86.com>
parents:
7990
diff
changeset
|
5348 gtk_label_set_markup(GTK_LABEL(gtkconv->tab_label), label); |
87d3260f961a
[gaim-migrate @ 8672]
Christian Hammond <chipx86@chipx86.com>
parents:
7990
diff
changeset
|
5349 g_free(label); |
4359 | 5350 } |
7995
87d3260f961a
[gaim-migrate @ 8672]
Christian Hammond <chipx86@chipx86.com>
parents:
7990
diff
changeset
|
5351 else |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5352 gtk_label_set_text(GTK_LABEL(gtkconv->tab_label), title); |
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5353 |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5354 if (gaim_gtk_conv_window_is_active_conversation(conv)) |
10810 | 5355 update_typing_icon(gtkconv); |
8155
77d1252b3803
[gaim-migrate @ 8867]
Christian Hammond <chipx86@chipx86.com>
parents:
8143
diff
changeset
|
5356 |
77d1252b3803
[gaim-migrate @ 8867]
Christian Hammond <chipx86@chipx86.com>
parents:
8143
diff
changeset
|
5357 if (type == GAIM_CONV_UPDATE_TITLE) { |
77d1252b3803
[gaim-migrate @ 8867]
Christian Hammond <chipx86@chipx86.com>
parents:
8143
diff
changeset
|
5358 gtk_label_set_text(GTK_LABEL(gtkconv->menu_label), title); |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5359 if (gaim_gtk_conv_window_is_active_conversation(conv)) |
11581 | 5360 gtk_window_set_title(GTK_WINDOW(win->window), title); |
8155
77d1252b3803
[gaim-migrate @ 8867]
Christian Hammond <chipx86@chipx86.com>
parents:
8143
diff
changeset
|
5361 } |
9472 | 5362 |
5363 g_free(title); | |
4359 | 5364 } |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5365 else if (type == GAIM_CONV_UPDATE_TOPIC) |
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5366 { |
7154 | 5367 const char *topic; |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
5368 chat = GAIM_CONV_CHAT(conv); |
4359 | 5369 gtkchat = gtkconv->u.chat; |
5370 | |
7154 | 5371 topic = gaim_conv_chat_get_topic(chat); |
5372 | |
9554 | 5373 gtk_entry_set_text(GTK_ENTRY(gtkchat->topic_text), topic ? topic : ""); |
7154 | 5374 gtk_tooltips_set_tip(gtkconv->tooltips, gtkchat->topic_text, |
9554 | 5375 topic ? topic : "", NULL); |
4359 | 5376 } |
5377 else if (type == GAIM_CONV_ACCOUNT_ONLINE || | |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5378 type == GAIM_CONV_ACCOUNT_OFFLINE) |
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5379 { |
11581 | 5380 gray_stuff_out(GAIM_GTK_CONVERSATION(gaim_gtk_conv_window_get_active_conversation(win))); |
11594 | 5381 generate_send_to_items(win); |
8946 | 5382 update_tab_icon(conv); |
9472 | 5383 gaim_conversation_autoset_title(conv); |
6392
e9974608b319
[gaim-migrate @ 6897]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
5384 } |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5385 else if (type == GAIM_CONV_UPDATE_AWAY) |
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5386 { |
8946 | 5387 update_tab_icon(conv); |
4359 | 5388 } |
8256
1d86096ae0f4
[gaim-migrate @ 8979]
Christian Hammond <chipx86@chipx86.com>
parents:
8253
diff
changeset
|
5389 else if (type == GAIM_CONV_UPDATE_ADD || type == GAIM_CONV_UPDATE_REMOVE || |
1d86096ae0f4
[gaim-migrate @ 8979]
Christian Hammond <chipx86@chipx86.com>
parents:
8253
diff
changeset
|
5390 type == GAIM_CONV_UPDATE_CHATLEFT) |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5391 { |
9472 | 5392 gaim_conversation_autoset_title(conv); |
10810 | 5393 gray_stuff_out(GAIM_GTK_CONVERSATION(conv)); |
4397
ce3a0eba91ef
[gaim-migrate @ 4666]
Christian Hammond <chipx86@chipx86.com>
parents:
4387
diff
changeset
|
5394 } |
6846
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6771
diff
changeset
|
5395 else if (type == GAIM_CONV_UPDATE_ICON) |
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6771
diff
changeset
|
5396 { |
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6771
diff
changeset
|
5397 gaim_gtkconv_update_buddy_icon(conv); |
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6771
diff
changeset
|
5398 } |
10665 | 5399 else if (type == GAIM_CONV_UPDATE_FEATURES) |
5400 { | |
10810 | 5401 gray_stuff_out(GAIM_GTK_CONVERSATION(conv)); |
10665 | 5402 } |
4359 | 5403 } |
5404 | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5405 static GaimConversationUiOps conversation_ui_ops = |
4359 | 5406 { |
11581 | 5407 gaim_gtkconv_new, |
4359 | 5408 gaim_gtkconv_destroy, /* destroy_conversation */ |
5409 gaim_gtkconv_write_chat, /* write_chat */ | |
5410 gaim_gtkconv_write_im, /* write_im */ | |
5411 gaim_gtkconv_write_conv, /* write_conv */ | |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5412 gaim_gtkconv_chat_add_users, /* chat_add_users */ |
4359 | 5413 gaim_gtkconv_chat_rename_user, /* chat_rename_user */ |
5414 gaim_gtkconv_chat_remove_user, /* chat_remove_user */ | |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5415 gaim_gtkconv_chat_remove_users, /* chat_remove_users */ |
9554 | 5416 gaim_gtkconv_chat_update_user, /* chat_update_user */ |
9260
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
5417 gaim_gtkconv_has_focus, /* has_focus */ |
10526 | 5418 gaim_gtkconv_custom_smiley_add, /* custom_smiley_add */ |
5419 gaim_gtkconv_custom_smiley_write, /* custom_smiley_write */ | |
5420 gaim_gtkconv_custom_smiley_close, /* custom_smiley_close */ | |
4359 | 5421 gaim_gtkconv_updated /* updated */ |
5422 }; | |
5423 | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5424 GaimConversationUiOps * |
7035
feb3d21a7794
[gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents:
7008
diff
changeset
|
5425 gaim_gtk_conversations_get_conv_ui_ops(void) |
4359 | 5426 { |
4465
6e37eb000b7a
[gaim-migrate @ 4740]
Christian Hammond <chipx86@chipx86.com>
parents:
4454
diff
changeset
|
5427 return &conversation_ui_ops; |
4359 | 5428 } |
5429 | |
5430 /************************************************************************** | |
5431 * Public conversation utility functions | |
5432 **************************************************************************/ | |
5433 void | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5434 gaim_gtkconv_update_buddy_icon(GaimConversation *conv) |
4359 | 5435 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5436 GaimGtkConversation *gtkconv; |
11581 | 5437 GaimGtkWindow *win; |
4359 | 5438 |
10381 | 5439 GdkPixbufLoader *loader; |
5440 GdkPixbufAnimation *anim; | |
4359 | 5441 GError *err = NULL; |
5442 | |
6846
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6771
diff
changeset
|
5443 const void *data; |
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6771
diff
changeset
|
5444 size_t len; |
4359 | 5445 |
5446 GdkPixbuf *buf; | |
5447 | |
5448 GtkWidget *event; | |
5449 GtkWidget *frame; | |
5450 GdkPixbuf *scale; | |
5451 GdkPixmap *pm; | |
5452 GdkBitmap *bm; | |
9318 | 5453 int scale_width, scale_height; |
5454 | |
5455 GaimAccount *account; | |
5456 GaimPluginProtocolInfo *prpl_info = NULL; | |
4359 | 5457 |
9324 | 5458 GaimBuddyIcon *icon; |
5459 | |
5678
619bca773b2e
[gaim-migrate @ 6096]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
5460 g_return_if_fail(conv != NULL); |
619bca773b2e
[gaim-migrate @ 6096]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
5461 g_return_if_fail(GAIM_IS_GTK_CONVERSATION(conv)); |
11338 | 5462 g_return_if_fail(gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM); |
4359 | 5463 |
5464 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
11581 | 5465 win = gtkconv->win; |
10175 | 5466 |
9687 | 5467 if (!gtkconv->u.im->show_icon) |
5468 return; | |
5469 | |
9318 | 5470 account = gaim_conversation_get_account(conv); |
5471 if(account && account->gc) | |
5472 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(account->gc->prpl); | |
4359 | 5473 |
9845 | 5474 /* Remove the current icon stuff */ |
9885 | 5475 if (gtkconv->u.im->icon_container != NULL) |
5476 gtk_widget_destroy(gtkconv->u.im->icon_container); | |
5477 gtkconv->u.im->icon_container = NULL; | |
9845 | 5478 |
5479 if (gtkconv->u.im->anim != NULL) | |
5480 g_object_unref(G_OBJECT(gtkconv->u.im->anim)); | |
5481 | |
9887 | 5482 gtkconv->u.im->anim = NULL; |
5483 | |
9845 | 5484 if (gtkconv->u.im->icon_timer != 0) |
5485 g_source_remove(gtkconv->u.im->icon_timer); | |
5486 | |
5487 gtkconv->u.im->icon_timer = 0; | |
5488 | |
5489 if (gtkconv->u.im->iter != NULL) | |
5490 g_object_unref(G_OBJECT(gtkconv->u.im->iter)); | |
4359 | 5491 |
10116 | 5492 gtkconv->u.im->iter = NULL; |
5493 | |
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5484
diff
changeset
|
5494 if (!gaim_prefs_get_bool("/gaim/gtk/conversations/im/show_buddy_icons")) |
4359 | 5495 return; |
5496 | |
5497 if (gaim_conversation_get_gc(conv) == NULL) | |
5498 return; | |
5499 | |
9324 | 5500 icon = gaim_conv_im_get_icon(GAIM_CONV_IM(conv)); |
5501 | |
5502 if (icon == NULL) | |
5503 return; | |
5504 | |
5505 data = gaim_buddy_icon_get_data(icon, &len); | |
5506 | |
10381 | 5507 loader = gdk_pixbuf_loader_new(); |
5508 gdk_pixbuf_loader_write(loader, data, len, NULL); | |
5509 anim = gdk_pixbuf_loader_get_animation(loader); | |
5510 if (anim) | |
5511 g_object_ref(G_OBJECT(anim)); | |
5512 gdk_pixbuf_loader_close(loader, &err); | |
5513 g_object_unref(loader); | |
5514 | |
5515 if (!anim) | |
9324 | 5516 return; |
10381 | 5517 gtkconv->u.im->anim = anim; |
9324 | 5518 |
4359 | 5519 if (err) { |
5211
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
5520 gaim_debug(GAIM_DEBUG_ERROR, "gtkconv", |
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
5521 "Buddy icon error: %s\n", err->message); |
4359 | 5522 g_error_free(err); |
5523 } | |
5524 | |
5525 if (!gtkconv->u.im->anim) | |
5526 return; | |
5527 | |
5528 if (gdk_pixbuf_animation_is_static_image(gtkconv->u.im->anim)) { | |
5529 gtkconv->u.im->iter = NULL; | |
5530 buf = gdk_pixbuf_animation_get_static_image(gtkconv->u.im->anim); | |
5531 } else { | |
5532 gtkconv->u.im->iter = | |
8496 | 5533 gdk_pixbuf_animation_get_iter(gtkconv->u.im->anim, NULL); /* LEAK */ |
4359 | 5534 buf = gdk_pixbuf_animation_iter_get_pixbuf(gtkconv->u.im->iter); |
8189 | 5535 if (gtkconv->u.im->animate) |
10810 | 5536 start_anim(NULL, gtkconv); |
4359 | 5537 } |
5538 | |
10483 | 5539 gaim_gtk_buddy_icon_get_scale_size(buf, prpl_info ? &prpl_info->icon_spec : |
9318 | 5540 NULL, &scale_width, &scale_height); |
4359 | 5541 scale = gdk_pixbuf_scale_simple(buf, |
9318 | 5542 MAX(gdk_pixbuf_get_width(buf) * scale_width / |
4359 | 5543 gdk_pixbuf_animation_get_width(gtkconv->u.im->anim), 1), |
9318 | 5544 MAX(gdk_pixbuf_get_height(buf) * scale_height / |
4359 | 5545 gdk_pixbuf_animation_get_height(gtkconv->u.im->anim), 1), |
11324 | 5546 GDK_INTERP_BILINEAR); |
4359 | 5547 |
5548 gdk_pixbuf_render_pixmap_and_mask(scale, &pm, &bm, 100); | |
4793 | 5549 g_object_unref(G_OBJECT(scale)); |
4359 | 5550 |
8821 | 5551 |
9885 | 5552 gtkconv->u.im->icon_container = gtk_vbox_new(FALSE, 0); |
8821 | 5553 |
4359 | 5554 frame = gtk_frame_new(NULL); |
5555 gtk_frame_set_shadow_type(GTK_FRAME(frame), | |
5556 (bm ? GTK_SHADOW_NONE : GTK_SHADOW_IN)); | |
9885 | 5557 gtk_box_pack_start(GTK_BOX(gtkconv->u.im->icon_container), frame, |
5558 FALSE, FALSE, 0); | |
8821 | 5559 |
4359 | 5560 event = gtk_event_box_new(); |
5561 gtk_container_add(GTK_CONTAINER(frame), event); | |
5314
1f901484599d
[gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
5562 g_signal_connect(G_OBJECT(event), "button-press-event", |
10883
b0fdadf463d4
[gaim-migrate @ 12581]
Gary Kramlich <grim@reaperworld.com>
parents:
10879
diff
changeset
|
5563 G_CALLBACK(icon_menu), gtkconv); |
4359 | 5564 gtk_widget_show(event); |
5565 | |
4635 | 5566 gtkconv->u.im->icon = gtk_image_new_from_pixmap(pm, bm); |
9318 | 5567 gtk_widget_set_size_request(gtkconv->u.im->icon, scale_width, scale_height); |
4359 | 5568 gtk_container_add(GTK_CONTAINER(event), gtkconv->u.im->icon); |
5569 gtk_widget_show(gtkconv->u.im->icon); | |
5570 | |
4793 | 5571 g_object_unref(G_OBJECT(pm)); |
4359 | 5572 |
5573 if (bm) | |
4793 | 5574 g_object_unref(G_OBJECT(bm)); |
7143 | 5575 |
10356 | 5576 gtk_box_pack_start(GTK_BOX(gtkconv->lower_hbox), |
5577 gtkconv->u.im->icon_container, FALSE, FALSE, 0); | |
9332 | 5578 |
9885 | 5579 gtk_widget_show(gtkconv->u.im->icon_container); |
9332 | 5580 gtk_widget_show(frame); |
5581 | |
7143 | 5582 /* The buddy icon code needs badly to be fixed. */ |
5583 buf = gdk_pixbuf_animation_get_static_image(gtkconv->u.im->anim); | |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5584 if(gaim_gtk_conv_window_is_active_conversation(conv)) |
11581 | 5585 gtk_window_set_icon(GTK_WINDOW(win->window), buf); |
4359 | 5586 } |
5587 | |
5588 void | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5589 gaim_gtkconv_update_buttons_by_protocol(GaimConversation *conv) |
4359 | 5590 { |
11581 | 5591 GaimGtkWindow *win; |
4359 | 5592 |
4398
a8249a5250b6
[gaim-migrate @ 4667]
Christian Hammond <chipx86@chipx86.com>
parents:
4397
diff
changeset
|
5593 if (!GAIM_IS_GTK_CONVERSATION(conv)) |
4359 | 5594 return; |
5595 | |
11581 | 5596 win = GAIM_GTK_CONVERSATION(conv)->win; |
5597 | |
5598 if (win != NULL && gaim_gtk_conv_window_is_active_conversation(conv)) | |
10810 | 5599 gray_stuff_out(GAIM_GTK_CONVERSATION(conv)); |
4359 | 5600 } |
5601 | |
5602 int | |
11614 | 5603 gaim_gtkconv_get_tab_at_xy(GaimGtkWindow *win, int x, int y, gboolean *to_right) |
11581 | 5604 { |
4359 | 5605 gint nb_x, nb_y, x_rel, y_rel; |
5606 GtkNotebook *notebook; | |
11279
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5607 GtkWidget *page, *tab; |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5608 gint i, page_num = -1; |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5609 gint count; |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5610 gboolean horiz; |
4359 | 5611 |
11614 | 5612 if (to_right) |
5613 *to_right = FALSE; | |
5614 | |
11581 | 5615 notebook = GTK_NOTEBOOK(win->notebook); |
5616 | |
5617 gdk_window_get_origin(win->notebook->window, &nb_x, &nb_y); | |
4359 | 5618 x_rel = x - nb_x; |
5619 y_rel = y - nb_y; | |
5620 | |
11279
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5621 horiz = (gtk_notebook_get_tab_pos(notebook) == GTK_POS_TOP || |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5622 gtk_notebook_get_tab_pos(notebook) == GTK_POS_BOTTOM); |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5623 |
11780 | 5624 #if GTK_CHECK_VERSION(2,2,0) |
11279
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5625 count = gtk_notebook_get_n_pages(GTK_NOTEBOOK(notebook)); |
11780 | 5626 #else |
5627 /* this is hacky, but it's only for Gtk 2.0.0... */ | |
5628 count = g_list_length(GTK_NOTEBOOK(notebook)->children); | |
5629 #endif | |
11279
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5630 |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5631 for (i = 0; i < count; i++) { |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5632 |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5633 page = gtk_notebook_get_nth_page(GTK_NOTEBOOK(notebook), i); |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5634 tab = gtk_notebook_get_tab_label(GTK_NOTEBOOK(notebook), page); |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5635 |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5636 if (horiz) { |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5637 if (x_rel >= tab->allocation.x - GAIM_HIG_BOX_SPACE && |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5638 x_rel <= tab->allocation.x + tab->allocation.width + GAIM_HIG_BOX_SPACE) { |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5639 page_num = i; |
11614 | 5640 |
5641 if (to_right && x_rel >= tab->allocation.x + tab->allocation.width/2) | |
5642 *to_right = TRUE; | |
5643 | |
11279
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5644 break; |
4359 | 5645 } |
11279
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5646 } else { |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5647 if (y_rel >= tab->allocation.y - GAIM_HIG_BOX_SPACE && |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5648 y_rel <= tab->allocation.y + tab->allocation.height + GAIM_HIG_BOX_SPACE) { |
ed5302df41b0
[gaim-migrate @ 13474]
Luke Schierer <lschiere@pidgin.im>
parents:
11276
diff
changeset
|
5649 page_num = i; |
11614 | 5650 |
5651 if (to_right && y_rel >= tab->allocation.y + tab->allocation.height/2) | |
5652 *to_right = TRUE; | |
5653 | |
4359 | 5654 break; |
5655 } | |
5656 } | |
5657 } | |
5658 | |
5659 return page_num; | |
5660 } | |
5661 | |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5662 static void |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5663 close_on_tabs_pref_cb(const char *name, GaimPrefType type, gpointer value, |
6392
e9974608b319
[gaim-migrate @ 6897]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
5664 gpointer data) |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5665 { |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5666 GList *l; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5667 GaimConversation *conv; |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5668 GaimGtkConversation *gtkconv; |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5669 |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5670 for (l = gaim_get_conversations(); l != NULL; l = l->next) { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5671 conv = (GaimConversation *)l->data; |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5672 |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5673 if (!GAIM_IS_GTK_CONVERSATION(conv)) |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5674 continue; |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5675 |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5676 gtkconv = GAIM_GTK_CONVERSATION(conv); |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5677 |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5678 if (value) |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5679 gtk_widget_show(gtkconv->close); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5680 else |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5681 gtk_widget_hide(gtkconv->close); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5682 } |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5683 } |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5684 |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5685 static void |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5686 spellcheck_pref_cb(const char *name, GaimPrefType type, gpointer value, |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5687 gpointer data) |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5688 { |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5689 #ifdef USE_GTKSPELL |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5690 GList *cl; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5691 GaimConversation *conv; |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5692 GaimGtkConversation *gtkconv; |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5693 GtkSpell *spell; |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5694 |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5695 for (cl = gaim_get_conversations(); cl != NULL; cl = cl->next) { |
6725
e62a504c83d0
[gaim-migrate @ 7252]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
5696 |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5697 conv = (GaimConversation *)cl->data; |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5698 |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5699 if (!GAIM_IS_GTK_CONVERSATION(conv)) |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5700 continue; |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5701 |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5702 gtkconv = GAIM_GTK_CONVERSATION(conv); |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5703 |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5704 if (value) |
12067
e859c1663a27
[gaim-migrate @ 14362]
Richard Laager <rlaager@wiktel.com>
parents:
12064
diff
changeset
|
5705 gaim_gtk_setup_gtkspell(GTK_TEXT_VIEW(gtkconv->entry)); |
e859c1663a27
[gaim-migrate @ 14362]
Richard Laager <rlaager@wiktel.com>
parents:
12064
diff
changeset
|
5706 else { |
e859c1663a27
[gaim-migrate @ 14362]
Richard Laager <rlaager@wiktel.com>
parents:
12064
diff
changeset
|
5707 spell = gtkspell_get_from_text_view(GTK_TEXT_VIEW(gtkconv->entry)); |
e859c1663a27
[gaim-migrate @ 14362]
Richard Laager <rlaager@wiktel.com>
parents:
12064
diff
changeset
|
5708 gtkspell_detach(spell); |
e859c1663a27
[gaim-migrate @ 14362]
Richard Laager <rlaager@wiktel.com>
parents:
12064
diff
changeset
|
5709 } |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5710 } |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5711 #endif |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5712 } |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5713 |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5714 static void |
5675
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5715 tab_side_pref_cb(const char *name, GaimPrefType type, gpointer value, |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5716 gpointer data) |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5717 { |
5675
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5718 GList *l; |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5719 GtkPositionType pos; |
11581 | 5720 GaimGtkWindow *win; |
5675
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5721 |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5722 pos = GPOINTER_TO_INT(value); |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5723 |
11581 | 5724 for (l = gaim_gtk_conv_windows_get_list(); l != NULL; l = l->next) { |
5725 win = l->data; | |
5726 | |
11619 | 5727 gtk_notebook_set_tab_pos(GTK_NOTEBOOK(win->notebook), pos&~8); |
5675
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5728 } |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5729 } |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5730 |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5731 static void |
12188 | 5732 show_timestamps_pref_cb(const char *name, GaimPrefType type, |
5733 gpointer value, gpointer data) | |
5734 { | |
5735 GList *l; | |
5736 GaimConversation *conv; | |
5737 GaimGtkConversation *gtkconv; | |
5738 GaimGtkWindow *win; | |
5739 | |
5740 for (l = gaim_get_conversations(); l != NULL; l = l->next) | |
5741 { | |
5742 conv = (GaimConversation *)l->data; | |
5743 | |
5744 if (!GAIM_IS_GTK_CONVERSATION(conv)) | |
5745 continue; | |
5746 | |
5747 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
5748 win = gtkconv->win; | |
5749 | |
5750 gtk_check_menu_item_set_active( | |
5751 GTK_CHECK_MENU_ITEM(win->menu.show_timestamps), | |
5752 (gboolean)GPOINTER_TO_INT(value)); | |
5753 | |
5754 gtk_imhtml_show_comments(GTK_IMHTML(gtkconv->imhtml), | |
5755 (gboolean)GPOINTER_TO_INT(value)); | |
5756 } | |
5757 } | |
5758 | |
5759 static void | |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5760 show_formatting_toolbar_pref_cb(const char *name, GaimPrefType type, |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5761 gpointer value, gpointer data) |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5762 { |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5763 GList *l; |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5764 GaimConversation *conv; |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5765 GaimGtkConversation *gtkconv; |
11581 | 5766 GaimGtkWindow *win; |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5767 |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5768 for (l = gaim_get_conversations(); l != NULL; l = l->next) |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5769 { |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5770 conv = (GaimConversation *)l->data; |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5771 |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5772 if (!GAIM_IS_GTK_CONVERSATION(conv)) |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5773 continue; |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5774 |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5775 gtkconv = GAIM_GTK_CONVERSATION(conv); |
11581 | 5776 win = gtkconv->win; |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5777 |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5778 gtk_check_menu_item_set_active( |
11581 | 5779 GTK_CHECK_MENU_ITEM(win->menu.show_formatting_toolbar), |
5780 (gboolean)GPOINTER_TO_INT(value)); | |
10377 | 5781 |
5782 if ((gboolean)GPOINTER_TO_INT(value)) | |
8317 | 5783 gtk_widget_show(gtkconv->toolbar); |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5784 else |
8317 | 5785 gtk_widget_hide(gtkconv->toolbar); |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5786 } |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5787 } |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5788 |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5789 static void |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5790 animate_buddy_icons_pref_cb(const char *name, GaimPrefType type, |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5791 gpointer value, gpointer data) |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5792 { |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5793 GList *l; |
8189 | 5794 GaimConversation *conv; |
5795 GaimGtkConversation *gtkconv; | |
11581 | 5796 GaimGtkWindow *win; |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5797 |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5798 if (!gaim_prefs_get_bool("/gaim/gtk/conversations/im/show_buddy_icons")) |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5799 return; |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5800 |
8189 | 5801 /* Set the "animate" flag for each icon based on the new preference */ |
5802 for (l = gaim_get_ims(); l != NULL; l = l->next) { | |
5803 conv = (GaimConversation *)l->data; | |
5804 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
10112 | 5805 gtkconv->u.im->animate = GPOINTER_TO_INT(value); |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5806 } |
8189 | 5807 |
5808 /* Now either stop or start animation for the active conversation in each window */ | |
11581 | 5809 for (l = gaim_gtk_conv_windows_get_list(); l != NULL; l = l->next) { |
5810 win = l->data; | |
5811 conv = gaim_gtk_conv_window_get_active_conversation(win); | |
8189 | 5812 gaim_gtkconv_update_buddy_icon(conv); |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5813 } |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5814 } |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
5815 |
5675
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5816 static void |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5817 show_buddy_icons_pref_cb(const char *name, GaimPrefType type, gpointer value, |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5818 gpointer data) |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5819 { |
5881
cc7870e1e3b3
[gaim-migrate @ 6313]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
5820 GList *l; |
cc7870e1e3b3
[gaim-migrate @ 6313]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
5821 |
cc7870e1e3b3
[gaim-migrate @ 6313]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
5822 for (l = gaim_get_conversations(); l != NULL; l = l->next) { |
cc7870e1e3b3
[gaim-migrate @ 6313]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
5823 GaimConversation *conv = l->data; |
cc7870e1e3b3
[gaim-migrate @ 6313]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
5824 |
11338 | 5825 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) |
12052 | 5826 gaim_gtkconv_update_buddy_icon(conv); |
5881
cc7870e1e3b3
[gaim-migrate @ 6313]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
5827 } |
5675
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5828 } |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
5829 |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5680
diff
changeset
|
5830 static void |
11936
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
5831 conv_placement_usetabs_cb(const char *name, GaimPrefType type, |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
5832 gpointer value, gpointer data) |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
5833 { |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
5834 gaim_prefs_trigger_callback("/gaim/gtk/conversations/placement"); |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
5835 } |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
5836 |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
5837 static void |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5838 account_status_changed_cb(GaimAccount *account, GaimStatus *oldstatus, |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5839 GaimStatus *newstatus) |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5840 { |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5841 GList *l; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5842 GaimConversation *conv = NULL; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5843 GaimGtkConversation *gtkconv; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5844 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5845 if(strcmp(gaim_prefs_get_string("/gaim/gtk/conversations/im/hide_new"), "away")!=0) |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5846 return; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5847 |
12310 | 5848 if(gaim_status_is_available(oldstatus) || !gaim_status_is_available(newstatus)) |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5849 return; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5850 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5851 for (l = hidden_convwin->gtkconvs; l != NULL; l = l->next) { |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5852 gtkconv = l->data; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5853 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5854 conv = gtkconv->active_conv; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5855 |
12310 | 5856 if(!gaim_status_is_available( |
5857 gaim_account_get_active_status( | |
5858 gaim_conversation_get_account(conv)))) | |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5859 continue; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5860 |
12288
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
5861 gaim_gtk_conv_window_remove_gtkconv(hidden_convwin, gtkconv); |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5862 gaim_gtkconv_placement_place(gtkconv); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5863 } |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5864 } |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5865 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5866 static void |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5867 hide_new_pref_cb(const char *name, GaimPrefType type, gpointer value, |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5868 gpointer data) |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5869 { |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5870 GList *l; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5871 GaimConversation *conv = NULL; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5872 GaimGtkConversation *gtkconv; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5873 gboolean when_away = FALSE; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5874 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5875 if(!hidden_convwin) |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5876 return; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5877 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5878 if(strcmp(gaim_prefs_get_string("/gaim/gtk/conversations/im/hide_new"), "always")==0) |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5879 return; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5880 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5881 if(strcmp(gaim_prefs_get_string("/gaim/gtk/conversations/im/hide_new"), "away")==0) |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5882 when_away = TRUE; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5883 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5884 for (l = hidden_convwin->gtkconvs; l != NULL; l = l->next) { |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5885 gtkconv = l->data; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5886 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5887 conv = gtkconv->active_conv; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5888 |
12310 | 5889 if(when_away && !gaim_status_is_available( |
5890 gaim_account_get_active_status( | |
5891 gaim_conversation_get_account(conv)))) | |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5892 continue; |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5893 |
12288
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
5894 gaim_gtk_conv_window_remove_gtkconv(hidden_convwin, gtkconv); |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5895 gaim_gtkconv_placement_place(gtkconv); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5896 } |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5897 } |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5898 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5899 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5900 static void |
7561
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5901 conv_placement_pref_cb(const char *name, GaimPrefType type, |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5902 gpointer value, gpointer data) |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5903 { |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5904 GaimConvPlacementFunc func; |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5905 |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5906 if (strcmp(name, "/gaim/gtk/conversations/placement")) |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5907 return; |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5908 |
11581 | 5909 func = gaim_gtkconv_placement_get_fnc(value); |
7561
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5910 |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5911 if (func == NULL) |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5912 return; |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5913 |
11581 | 5914 gaim_gtkconv_placement_set_current_func(func); |
7561
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5915 } |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5916 |
12131
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5917 static void |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5918 account_signed_off_cb(GaimConnection *gc, gpointer event) |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5919 { |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5920 GList *iter; |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5921 GaimAccount *account; |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5922 |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5923 account = gaim_connection_get_account(gc); |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5924 |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5925 for (iter = gaim_get_conversations(); iter; iter = iter->next) |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5926 { |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5927 GaimConversation *conv = iter->data; |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5928 |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5929 if (gaim_conversation_get_account(conv) == account) |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5930 gaim_conversation_update(conv, GPOINTER_TO_INT(event)); |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5931 } |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5932 } |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
5933 |
8582
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5934 void * |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5935 gaim_gtk_conversations_get_handle(void) |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5936 { |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5937 static int handle; |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5938 |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5939 return &handle; |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5940 } |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5941 |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5942 void |
7035
feb3d21a7794
[gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents:
7008
diff
changeset
|
5943 gaim_gtk_conversations_init(void) |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5944 { |
8582
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5945 void *handle = gaim_gtk_conversations_get_handle(); |
11856
fa7b84231ece
[gaim-migrate @ 14147]
Richard Laager <rlaager@wiktel.com>
parents:
11855
diff
changeset
|
5946 void *blist_handle = gaim_blist_get_handle(); |
8582
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
5947 |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5948 /* Conversations */ |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5949 gaim_prefs_add_none("/gaim/gtk/conversations"); |
12553 | 5950 gaim_prefs_add_bool("/gaim/gtk/conversations/use_smooth_scrolling", TRUE); |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5951 gaim_prefs_add_bool("/gaim/gtk/conversations/close_on_tabs", TRUE); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5952 gaim_prefs_add_bool("/gaim/gtk/conversations/send_bold", FALSE); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5953 gaim_prefs_add_bool("/gaim/gtk/conversations/send_italic", FALSE); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5954 gaim_prefs_add_bool("/gaim/gtk/conversations/send_underline", FALSE); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5955 gaim_prefs_add_bool("/gaim/gtk/conversations/spellcheck", TRUE); |
11267
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
5956 gaim_prefs_add_bool("/gaim/gtk/conversations/show_incoming_formatting", TRUE); |
477e5cca8287
[gaim-migrate @ 13449]
Richard Laager <rlaager@wiktel.com>
parents:
11261
diff
changeset
|
5957 |
12264 | 5958 gaim_prefs_add_bool("/gaim/gtk/conversations/show_timestamps", TRUE); |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
5959 gaim_prefs_add_bool("/gaim/gtk/conversations/show_formatting_toolbar", TRUE); |
9832 | 5960 gaim_prefs_add_bool("/gaim/gtk/conversations/passthrough_unknown_commands", FALSE); |
9130 | 5961 |
7561
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
5962 gaim_prefs_add_string("/gaim/gtk/conversations/placement", "last"); |
8998 | 5963 gaim_prefs_add_int("/gaim/gtk/conversations/placement_number", 1); |
9025 | 5964 gaim_prefs_add_string("/gaim/gtk/conversations/bgcolor", ""); |
5965 gaim_prefs_add_string("/gaim/gtk/conversations/fgcolor", ""); | |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5966 gaim_prefs_add_string("/gaim/gtk/conversations/font_face", ""); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5967 gaim_prefs_add_int("/gaim/gtk/conversations/font_size", 3); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5968 gaim_prefs_add_bool("/gaim/gtk/conversations/tabs", TRUE); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5969 gaim_prefs_add_int("/gaim/gtk/conversations/tab_side", GTK_POS_TOP); |
11224
409d6a11da51
[gaim-migrate @ 13360]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11209
diff
changeset
|
5970 gaim_prefs_add_int("/gaim/gtk/conversations/scrollback_lines", 4000); |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5971 |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5972 /* Conversations -> Chat */ |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5973 gaim_prefs_add_none("/gaim/gtk/conversations/chat"); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5974 gaim_prefs_add_int("/gaim/gtk/conversations/chat/default_width", 410); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5975 gaim_prefs_add_int("/gaim/gtk/conversations/chat/default_height", 160); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5976 gaim_prefs_add_int("/gaim/gtk/conversations/chat/entry_height", 50); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5977 |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5978 /* Conversations -> IM */ |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5979 gaim_prefs_add_none("/gaim/gtk/conversations/im"); |
9150 | 5980 |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5981 gaim_prefs_add_bool("/gaim/gtk/conversations/im/animate_buddy_icons", TRUE); |
9150 | 5982 |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5983 gaim_prefs_add_int("/gaim/gtk/conversations/im/default_width", 410); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5984 gaim_prefs_add_int("/gaim/gtk/conversations/im/default_height", 160); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5985 gaim_prefs_add_int("/gaim/gtk/conversations/im/entry_height", 50); |
9319 | 5986 gaim_prefs_add_bool("/gaim/gtk/conversations/im/show_buddy_icons", TRUE); |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
5987 |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5988 /* convert old queuing prefs to hide_new 3-way pref */ |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5989 if(gaim_prefs_exists("/plugins/gtk/docklet/queue_messages") && |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5990 gaim_prefs_get_bool("/plugins/gtk/docklet/queue_messages")) { |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5991 gaim_prefs_add_string("/gaim/gtk/conversations/im/hide_new", "always"); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5992 } |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5993 else if(gaim_prefs_exists("/gaim/gtk/away/queue_messages") && |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5994 gaim_prefs_get_bool("/gaim/gtk/away/queue_messages")) { |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5995 gaim_prefs_add_string("/gaim/gtk/conversations/im/hide_new", "away"); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5996 } |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5997 else { |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5998 gaim_prefs_add_string("/gaim/gtk/conversations/im/hide_new", "never"); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
5999 } |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6000 |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6001 /* Connect callbacks. */ |
10087 | 6002 gaim_prefs_connect_callback(handle, "/gaim/gtk/conversations/close_on_tabs", |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6003 close_on_tabs_pref_cb, NULL); |
12188 | 6004 gaim_prefs_connect_callback(handle, "/gaim/gtk/conversations/show_timestamps", |
6005 show_timestamps_pref_cb, NULL); | |
10087 | 6006 gaim_prefs_connect_callback(handle, "/gaim/gtk/conversations/show_formatting_toolbar", |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6007 show_formatting_toolbar_pref_cb, NULL); |
10087 | 6008 gaim_prefs_connect_callback(handle, "/gaim/gtk/conversations/spellcheck", |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6009 spellcheck_pref_cb, NULL); |
10087 | 6010 gaim_prefs_connect_callback(handle, "/gaim/gtk/conversations/tab_side", |
5675
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
6011 tab_side_pref_cb, NULL); |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
6012 |
11936
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
6013 gaim_prefs_connect_callback(handle, "/gaim/gtk/conversations/tabs", |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
6014 conv_placement_usetabs_cb, NULL); |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
6015 |
10087 | 6016 gaim_prefs_connect_callback(handle, "/gaim/gtk/conversations/placement", |
11856
fa7b84231ece
[gaim-migrate @ 14147]
Richard Laager <rlaager@wiktel.com>
parents:
11855
diff
changeset
|
6017 conv_placement_pref_cb, NULL); |
7561
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
6018 gaim_prefs_trigger_callback("/gaim/gtk/conversations/placement"); |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
6019 |
5675
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
6020 /* IM callbacks */ |
10087 | 6021 gaim_prefs_connect_callback(handle, "/gaim/gtk/conversations/im/animate_buddy_icons", |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6022 animate_buddy_icons_pref_cb, NULL); |
10087 | 6023 gaim_prefs_connect_callback(handle, "/gaim/gtk/conversations/im/show_buddy_icons", |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6024 show_buddy_icons_pref_cb, NULL); |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6025 gaim_prefs_connect_callback(handle, "/gaim/gtk/conversations/im/hide_new", |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6026 hide_new_pref_cb, NULL); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6027 |
5675
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
6028 |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
6029 |
8582
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6030 /********************************************************************** |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6031 * Register signals |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6032 **********************************************************************/ |
11447
ef6e94bdda08
[gaim-migrate @ 13686]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
11338
diff
changeset
|
6033 gaim_signal_register(handle, "conversation-dragging", |
8582
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6034 gaim_marshal_VOID__POINTER_POINTER, NULL, 2, |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6035 gaim_value_new(GAIM_TYPE_SUBTYPE, |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6036 GAIM_SUBTYPE_CONV_WINDOW), |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6037 gaim_value_new(GAIM_TYPE_SUBTYPE, |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6038 GAIM_SUBTYPE_CONV_WINDOW)); |
9167 | 6039 |
6040 /********************************************************************** | |
6041 * Register commands | |
6042 **********************************************************************/ | |
9829 | 6043 gaim_cmd_register("say", "S", GAIM_CMD_P_DEFAULT, |
6044 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_IM, NULL, | |
6045 say_command_cb, _("say <message>: Send a message normally as if you weren't using a command."), NULL); | |
9213 | 6046 gaim_cmd_register("me", "S", GAIM_CMD_P_DEFAULT, |
6047 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_IM, NULL, | |
9597 | 6048 me_command_cb, _("me <action>: Send an IRC style action to a buddy or chat."), NULL); |
9213 | 6049 gaim_cmd_register("debug", "w", GAIM_CMD_P_DEFAULT, |
6050 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_IM, NULL, | |
9597 | 6051 debug_command_cb, _("debug <option>: Send various debug information to the current conversation."), NULL); |
11145
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
6052 gaim_cmd_register("clear", "", GAIM_CMD_P_DEFAULT, |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
6053 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_IM, NULL, |
dbc518c453f2
[gaim-migrate @ 13209]
Etan Reisner <pidgin@unreliablesource.net>
parents:
11137
diff
changeset
|
6054 clear_command_cb, _("clear: Clears the conversation scrollback."), NULL); |
9213 | 6055 gaim_cmd_register("help", "w", GAIM_CMD_P_DEFAULT, |
9597 | 6056 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_ALLOW_WRONG_ARGS, NULL, |
6057 help_command_cb, _("help <command>: Help on a specific command."), NULL); | |
11581 | 6058 |
11856
fa7b84231ece
[gaim-migrate @ 14147]
Richard Laager <rlaager@wiktel.com>
parents:
11855
diff
changeset
|
6059 /********************************************************************** |
fa7b84231ece
[gaim-migrate @ 14147]
Richard Laager <rlaager@wiktel.com>
parents:
11855
diff
changeset
|
6060 * UI operations |
fa7b84231ece
[gaim-migrate @ 14147]
Richard Laager <rlaager@wiktel.com>
parents:
11855
diff
changeset
|
6061 **********************************************************************/ |
fa7b84231ece
[gaim-migrate @ 14147]
Richard Laager <rlaager@wiktel.com>
parents:
11855
diff
changeset
|
6062 |
12131
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
6063 gaim_signal_connect(gaim_connections_get_handle(), "signed-on", handle, |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
6064 G_CALLBACK(account_signed_off_cb), |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
6065 GINT_TO_POINTER(GAIM_CONV_ACCOUNT_ONLINE)); |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
6066 gaim_signal_connect(gaim_connections_get_handle(), "signed-off", handle, |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
6067 G_CALLBACK(account_signed_off_cb), |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
6068 GINT_TO_POINTER(GAIM_CONV_ACCOUNT_OFFLINE)); |
cb7ccb5048cf
[gaim-migrate @ 14431]
Richard Laager <rlaager@wiktel.com>
parents:
12116
diff
changeset
|
6069 |
11856
fa7b84231ece
[gaim-migrate @ 14147]
Richard Laager <rlaager@wiktel.com>
parents:
11855
diff
changeset
|
6070 gaim_signal_connect(blist_handle, "buddy-added", handle, |
11855 | 6071 G_CALLBACK(buddy_update_cb), NULL); |
11856
fa7b84231ece
[gaim-migrate @ 14147]
Richard Laager <rlaager@wiktel.com>
parents:
11855
diff
changeset
|
6072 gaim_signal_connect(blist_handle, "buddy-removed", handle, |
11855 | 6073 G_CALLBACK(buddy_update_cb), NULL); |
6074 | |
12288
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
6075 gaim_signal_connect(gaim_conversations_get_handle(), "received-im-msg", |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
6076 handle, G_CALLBACK(received_im_msg_cb), NULL); |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
6077 |
11581 | 6078 gaim_conversations_set_ui_ops(&conversation_ui_ops); |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6079 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6080 hidden_convwin = gaim_gtk_conv_window_new(); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6081 window_list = g_list_remove(window_list, hidden_convwin); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6082 |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6083 gaim_signal_connect(gaim_accounts_get_handle(), "account-status-changed", |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6084 handle, GAIM_CALLBACK(account_status_changed_cb), NULL); |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6085 } |
8582
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6086 |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6087 void |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6088 gaim_gtk_conversations_uninit(void) |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6089 { |
10443 | 6090 gaim_prefs_disconnect_by_handle(gaim_gtk_conversations_get_handle()); |
11855 | 6091 gaim_signals_disconnect_by_handle(gaim_gtk_conversations_get_handle()); |
8582
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6092 gaim_signals_unregister_by_instance(gaim_gtk_conversations_get_handle()); |
12116
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6093 gaim_gtk_conv_window_destroy(hidden_convwin); |
e75ef7aa913e
[gaim-migrate @ 14416]
Luke Schierer <lschiere@pidgin.im>
parents:
12101
diff
changeset
|
6094 hidden_convwin=NULL; |
8582
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6095 } |
11581 | 6096 |
6097 | |
6098 | |
6099 | |
6100 | |
6101 | |
6102 | |
6103 | |
6104 | |
6105 | |
6106 | |
6107 | |
6108 | |
6109 | |
6110 | |
6111 | |
6112 /* down here is where gtkconvwin.c ought to start. except they share like every freaking function, | |
6113 * and touch each others' private members all day long */ | |
6114 | |
6115 /** | |
6116 * @file gtkconvwin.c GTK+ Conversation Window API | |
6117 * @ingroup gtkui | |
6118 * | |
6119 * gaim | |
6120 * | |
6121 * Gaim is the legal property of its developers, whose names are too numerous | |
6122 * to list here. Please refer to the COPYRIGHT file distributed with this | |
6123 * source distribution. | |
6124 * | |
6125 * This program is free software; you can redistribute it and/or modify | |
6126 * it under the terms of the GNU General Public License as published by | |
6127 * the Free Software Foundation; either version 2 of the License, or | |
6128 * (at your option) any later version. | |
6129 * | |
6130 * This program is distributed in the hope that it will be useful, | |
6131 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
6132 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
6133 * GNU General Public License for more details. | |
6134 * | |
6135 * You should have received a copy of the GNU General Public License | |
6136 * along with this program; if not, write to the Free Software | |
6137 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
6138 * | |
6139 */ | |
6140 #include "internal.h" | |
6141 #include "gtkgaim.h" | |
6142 | |
6143 | |
6144 #include <gdk/gdkkeysyms.h> | |
6145 | |
6146 #include "account.h" | |
6147 #include "cmds.h" | |
6148 #include "debug.h" | |
6149 #include "imgstore.h" | |
6150 #include "log.h" | |
6151 #include "notify.h" | |
6152 #include "prpl.h" | |
6153 #include "request.h" | |
6154 #include "util.h" | |
6155 | |
6156 #include "gtkdnd-hints.h" | |
6157 #include "gtkblist.h" | |
6158 #include "gtkconv.h" | |
6159 #include "gtkdialogs.h" | |
6160 #include "gtkmenutray.h" | |
6161 #include "gtkpounce.h" | |
6162 #include "gtkprefs.h" | |
6163 #include "gtkprivacy.h" | |
6164 #include "gtkutils.h" | |
6165 #include "gtkstock.h" | |
6166 #include "gtkimhtml.h" | |
6167 #include "gtkimhtmltoolbar.h" | |
6168 | |
6169 static void | |
6170 do_close(GtkWidget *w, int resp, GaimGtkWindow *win) | |
6171 { | |
6172 gtk_widget_destroy(warn_close_dialog); | |
6173 warn_close_dialog = NULL; | |
6174 | |
6175 if (resp == GTK_RESPONSE_OK) | |
6176 gaim_gtk_conv_window_destroy(win); | |
6177 } | |
6178 | |
6179 static void | |
6180 build_warn_close_dialog(GaimGtkWindow *gtkwin) | |
6181 { | |
6182 GtkWidget *label; | |
6183 GtkWidget *vbox, *hbox; | |
6184 GtkWidget *img; | |
6185 | |
6186 g_return_if_fail(warn_close_dialog == NULL); | |
6187 | |
6188 | |
6189 warn_close_dialog = gtk_dialog_new_with_buttons( | |
6190 _("Confirm close"), | |
6191 GTK_WINDOW(gtkwin->window), GTK_DIALOG_MODAL, | |
6192 GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, | |
6193 GTK_STOCK_CLOSE, GTK_RESPONSE_OK, NULL); | |
6194 | |
6195 gtk_dialog_set_default_response(GTK_DIALOG(warn_close_dialog), | |
6196 GTK_RESPONSE_OK); | |
6197 | |
6198 gtk_container_set_border_width(GTK_CONTAINER(warn_close_dialog), | |
6199 6); | |
6200 gtk_window_set_resizable(GTK_WINDOW(warn_close_dialog), FALSE); | |
6201 gtk_dialog_set_has_separator(GTK_DIALOG(warn_close_dialog), | |
6202 FALSE); | |
6203 | |
6204 /* Setup the outside spacing. */ | |
6205 vbox = GTK_DIALOG(warn_close_dialog)->vbox; | |
6206 | |
6207 gtk_box_set_spacing(GTK_BOX(vbox), 12); | |
6208 gtk_container_set_border_width(GTK_CONTAINER(vbox), 6); | |
6209 | |
6210 img = gtk_image_new_from_stock(GAIM_STOCK_DIALOG_WARNING, | |
6211 GTK_ICON_SIZE_DIALOG); | |
6212 /* Setup the inner hbox and put the dialog's icon in it. */ | |
6213 hbox = gtk_hbox_new(FALSE, 12); | |
6214 gtk_container_add(GTK_CONTAINER(vbox), hbox); | |
6215 gtk_box_pack_start(GTK_BOX(hbox), img, FALSE, FALSE, 0); | |
6216 gtk_misc_set_alignment(GTK_MISC(img), 0, 0); | |
6217 | |
6218 /* Setup the right vbox. */ | |
6219 vbox = gtk_vbox_new(FALSE, 12); | |
6220 gtk_container_add(GTK_CONTAINER(hbox), vbox); | |
6221 | |
6222 label = gtk_label_new(_("You have unread messages. Are you sure you want to close the window?")); | |
6223 gtk_widget_set_size_request(label, 350, -1); | |
6224 gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); | |
6225 gtk_misc_set_alignment(GTK_MISC(label), 0, 0); | |
6226 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); | |
6227 | |
6228 /* Connect the signals. */ | |
6229 g_signal_connect(G_OBJECT(warn_close_dialog), "response", | |
6230 G_CALLBACK(do_close), gtkwin); | |
6231 | |
6232 } | |
6233 | |
6234 /************************************************************************** | |
6235 * Callbacks | |
6236 **************************************************************************/ | |
6237 | |
6238 static gboolean | |
6239 close_win_cb(GtkWidget *w, GdkEventAny *e, gpointer d) | |
6240 { | |
6241 GaimGtkWindow *win = d; | |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
6242 GList *l; |
11581 | 6243 |
6244 /* If there are unread messages then show a warning dialog */ | |
6245 for (l = gaim_gtk_conv_window_get_gtkconvs(win); | |
6246 l != NULL; l = l->next) | |
6247 { | |
6248 GaimGtkConversation *gtkconv = l->data; | |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
6249 if (gaim_conversation_get_type(gtkconv->active_conv) == GAIM_CONV_TYPE_IM && |
12175
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
6250 gtkconv->unseen_state >= GAIM_UNSEEN_TEXT) |
11664
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
6251 { |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
6252 build_warn_close_dialog(win); |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
6253 gtk_widget_show_all(warn_close_dialog); |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
6254 |
38bbb0f15453
[gaim-migrate @ 13949]
Luke Schierer <lschiere@pidgin.im>
parents:
11657
diff
changeset
|
6255 return TRUE; |
11581 | 6256 } |
6257 } | |
6258 | |
6259 gaim_gtk_conv_window_destroy(win); | |
6260 | |
6261 return TRUE; | |
6262 } | |
6263 | |
11604 | 6264 static void |
6265 gtkconv_set_unseen(GaimGtkConversation *gtkconv, GaimUnseenState state) | |
6266 { | |
12175
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
6267 if (state == GAIM_UNSEEN_NONE) |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
6268 { |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
6269 gtkconv->unseen_count = 0; |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
6270 gtkconv->unseen_state = GAIM_UNSEEN_NONE; |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
6271 } |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
6272 else |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
6273 { |
12468
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
6274 if (state >= GAIM_UNSEEN_TEXT) |
6faefbebcd24
[gaim-migrate @ 14778]
Richard Laager <rlaager@wiktel.com>
parents:
12463
diff
changeset
|
6275 gtkconv->unseen_count++; |
12175
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
6276 |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
6277 if (state > gtkconv->unseen_state) |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
6278 gtkconv->unseen_state = state; |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
6279 } |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
6280 |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
6281 /* emit update signal to notify of count and possible unseen state change */ |
a655bdeb561d
[gaim-migrate @ 14477]
Richard Laager <rlaager@wiktel.com>
parents:
12171
diff
changeset
|
6282 gaim_conversation_update(gtkconv->active_conv, GAIM_CONV_UPDATE_UNSEEN); |
12021
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
6283 } |
1a86417abfc8
[gaim-migrate @ 14314]
Daniel Atallah <daniel.atallah@gmail.com>
parents:
12012
diff
changeset
|
6284 |
11581 | 6285 /* |
6286 * When a conversation window is focused, we know the user | |
6287 * has looked at it so we know there are no longer unseen | |
6288 * messages. | |
6289 */ | |
6290 static gint | |
6291 focus_win_cb(GtkWidget *w, GdkEventFocus *e, gpointer d) | |
6292 { | |
6293 GaimGtkWindow *win = d; | |
11604 | 6294 GaimGtkConversation *gtkconv = gaim_gtk_conv_window_get_active_gtkconv(win); |
6295 | |
6296 gtkconv_set_unseen(gtkconv, GAIM_UNSEEN_NONE); | |
11581 | 6297 |
6298 return FALSE; | |
6299 } | |
6300 | |
11851 | 6301 #if !GTK_CHECK_VERSION(2,6,0) |
11581 | 6302 /* Courtesy of Galeon! */ |
6303 static void | |
6304 tab_close_button_state_changed_cb(GtkWidget *widget, GtkStateType prev_state) | |
6305 { | |
6306 if (GTK_WIDGET_STATE(widget) == GTK_STATE_ACTIVE) | |
6307 gtk_widget_set_state(widget, GTK_STATE_NORMAL); | |
6308 } | |
11851 | 6309 #endif |
11581 | 6310 |
6311 static void | |
6312 notebook_init_grab(GaimGtkWindow *gtkwin, GtkWidget *widget) | |
6313 { | |
6314 static GdkCursor *cursor = NULL; | |
6315 | |
6316 gtkwin->in_drag = TRUE; | |
6317 | |
6318 if (gtkwin->drag_leave_signal) { | |
6319 g_signal_handler_disconnect(G_OBJECT(widget), | |
6320 gtkwin->drag_leave_signal); | |
6321 gtkwin->drag_leave_signal = 0; | |
6322 } | |
6323 | |
6324 if (cursor == NULL) | |
6325 cursor = gdk_cursor_new(GDK_FLEUR); | |
6326 | |
6327 /* Grab the pointer */ | |
6328 gtk_grab_add(gtkwin->notebook); | |
6329 #ifndef _WIN32 | |
6330 /* Currently for win32 GTK+ (as of 2.2.1), gdk_pointer_is_grabbed will | |
6331 always be true after a button press. */ | |
6332 if (!gdk_pointer_is_grabbed()) | |
6333 #endif | |
6334 gdk_pointer_grab(gtkwin->notebook->window, FALSE, | |
6335 GDK_BUTTON1_MOTION_MASK | GDK_BUTTON_RELEASE_MASK, | |
6336 NULL, cursor, GDK_CURRENT_TIME); | |
6337 } | |
6338 | |
6339 static gboolean | |
6340 notebook_motion_cb(GtkWidget *widget, GdkEventButton *e, GaimGtkWindow *win) | |
6341 { | |
6342 | |
6343 /* | |
6344 * Make sure the user moved the mouse far enough for the | |
6345 * drag to be initiated. | |
6346 */ | |
6347 if (win->in_predrag) { | |
6348 if (e->x_root < win->drag_min_x || | |
6349 e->x_root >= win->drag_max_x || | |
6350 e->y_root < win->drag_min_y || | |
6351 e->y_root >= win->drag_max_y) { | |
6352 | |
6353 win->in_predrag = FALSE; | |
6354 notebook_init_grab(win, widget); | |
6355 } | |
6356 } | |
6357 else { /* Otherwise, draw the arrows. */ | |
6358 GaimGtkWindow *dest_win; | |
6359 GtkNotebook *dest_notebook; | |
6360 GtkWidget *tab; | |
6361 gint nb_x, nb_y, page_num; | |
6362 gint arrow1_x, arrow1_y, arrow2_x, arrow2_y; | |
6363 gboolean horiz_tabs = FALSE; | |
11614 | 6364 GaimGtkConversation *gtkconv; |
6365 gboolean to_right = FALSE; | |
11581 | 6366 |
6367 /* Get the window that the cursor is over. */ | |
6368 dest_win = gaim_gtk_conv_window_get_at_xy(e->x_root, e->y_root); | |
6369 | |
6370 if (dest_win == NULL) { | |
6371 dnd_hints_hide_all(); | |
6372 | |
6373 return TRUE; | |
6374 } | |
6375 | |
6376 dest_notebook = GTK_NOTEBOOK(dest_win->notebook); | |
6377 | |
6378 gdk_window_get_origin(GTK_WIDGET(dest_notebook)->window, &nb_x, &nb_y); | |
6379 | |
6380 arrow1_x = arrow2_x = nb_x; | |
6381 arrow1_y = arrow2_y = nb_y; | |
6382 | |
6383 page_num = gaim_gtkconv_get_tab_at_xy(dest_win, | |
11614 | 6384 e->x_root, e->y_root, &to_right); |
6385 to_right = to_right && (win != dest_win); | |
11581 | 6386 |
6387 if (gtk_notebook_get_tab_pos(dest_notebook) == GTK_POS_TOP || | |
6388 gtk_notebook_get_tab_pos(dest_notebook) == GTK_POS_BOTTOM) { | |
6389 | |
6390 horiz_tabs = TRUE; | |
6391 } | |
6392 | |
11614 | 6393 gtkconv = gaim_gtk_conv_window_get_gtkconv_at_index(dest_win, page_num); |
6394 tab = gtkconv->tabby; | |
11581 | 6395 |
6396 if (horiz_tabs) { | |
6397 arrow1_x = arrow2_x = nb_x + tab->allocation.x; | |
6398 | |
11614 | 6399 if (((gpointer)win == (gpointer)dest_win && win->drag_tab < page_num) || to_right) { |
11581 | 6400 arrow1_x += tab->allocation.width; |
6401 arrow2_x += tab->allocation.width; | |
6402 } | |
6403 | |
6404 arrow1_y = nb_y + tab->allocation.y; | |
6405 arrow2_y = nb_y + tab->allocation.y + | |
6406 tab->allocation.height; | |
6407 } else { | |
6408 arrow1_x = nb_x + tab->allocation.x; | |
6409 arrow2_x = nb_x + tab->allocation.x + | |
6410 tab->allocation.width; | |
6411 arrow1_y = arrow2_y = nb_y + tab->allocation.y + tab->allocation.height/2; | |
6412 | |
6413 if ((gpointer)win == (gpointer)dest_win && win->drag_tab < page_num) { | |
6414 arrow1_y += tab->allocation.height; | |
6415 arrow2_y += tab->allocation.height; | |
6416 } | |
6417 } | |
6418 | |
6419 if (horiz_tabs) { | |
6420 dnd_hints_show(HINT_ARROW_DOWN, arrow1_x, arrow1_y); | |
6421 dnd_hints_show(HINT_ARROW_UP, arrow2_x, arrow2_y); | |
6422 } else { | |
6423 dnd_hints_show(HINT_ARROW_RIGHT, arrow1_x, arrow1_y); | |
6424 dnd_hints_show(HINT_ARROW_LEFT, arrow2_x, arrow2_y); | |
6425 } | |
6426 } | |
6427 | |
6428 return TRUE; | |
6429 } | |
6430 | |
6431 static gboolean | |
6432 notebook_leave_cb(GtkWidget *widget, GdkEventCrossing *e, GaimGtkWindow *win) | |
6433 { | |
6434 if (win->in_drag) | |
6435 return FALSE; | |
6436 | |
6437 if (e->x_root < win->drag_min_x || | |
6438 e->x_root >= win->drag_max_x || | |
6439 e->y_root < win->drag_min_y || | |
6440 e->y_root >= win->drag_max_y) { | |
6441 | |
6442 win->in_predrag = FALSE; | |
6443 notebook_init_grab(win, widget); | |
6444 } | |
6445 | |
6446 return TRUE; | |
6447 } | |
6448 | |
6449 /* | |
6450 * THANK YOU GALEON! | |
6451 */ | |
6452 static gboolean | |
6453 notebook_press_cb(GtkWidget *widget, GdkEventButton *e, GaimGtkWindow *win) | |
6454 { | |
6455 gint nb_x, nb_y, x_rel, y_rel; | |
6456 int tab_clicked; | |
6457 GtkWidget *page; | |
6458 GtkWidget *tab; | |
6459 | |
6460 if (e->button != 1 || e->type != GDK_BUTTON_PRESS) | |
6461 return FALSE; | |
6462 | |
6463 | |
6464 if (win->in_drag) { | |
6465 gaim_debug(GAIM_DEBUG_WARNING, "gtkconv", | |
6466 "Already in the middle of a window drag at tab_press_cb\n"); | |
6467 return TRUE; | |
6468 } | |
6469 | |
6470 /* | |
6471 * Make sure a tab was actually clicked. The arrow buttons | |
6472 * mess things up. | |
6473 */ | |
11614 | 6474 tab_clicked = gaim_gtkconv_get_tab_at_xy(win, e->x_root, e->y_root, NULL); |
11581 | 6475 |
6476 if (tab_clicked == -1) | |
6477 return FALSE; | |
6478 | |
6479 /* | |
6480 * Get the relative position of the press event, with regards to | |
6481 * the position of the notebook. | |
6482 */ | |
6483 gdk_window_get_origin(win->notebook->window, &nb_x, &nb_y); | |
6484 | |
6485 x_rel = e->x_root - nb_x; | |
6486 y_rel = e->y_root - nb_y; | |
6487 | |
6488 /* Reset the min/max x/y */ | |
6489 win->drag_min_x = 0; | |
6490 win->drag_min_y = 0; | |
6491 win->drag_max_x = 0; | |
6492 win->drag_max_y = 0; | |
6493 | |
6494 /* Find out which tab was dragged. */ | |
6495 page = gtk_notebook_get_nth_page(GTK_NOTEBOOK(win->notebook), tab_clicked); | |
6496 tab = gtk_notebook_get_tab_label(GTK_NOTEBOOK(win->notebook), page); | |
6497 | |
6498 win->drag_min_x = tab->allocation.x + nb_x; | |
6499 win->drag_min_y = tab->allocation.y + nb_y; | |
6500 win->drag_max_x = tab->allocation.width + win->drag_min_x; | |
6501 win->drag_max_y = tab->allocation.height + win->drag_min_y; | |
6502 | |
6503 /* Make sure the click occurred in the tab. */ | |
6504 if (e->x_root < win->drag_min_x || | |
6505 e->x_root >= win->drag_max_x || | |
6506 e->y_root < win->drag_min_y || | |
6507 e->y_root >= win->drag_max_y) { | |
6508 | |
6509 return FALSE; | |
6510 } | |
6511 | |
6512 win->in_predrag = TRUE; | |
6513 win->drag_tab = tab_clicked; | |
6514 | |
6515 /* Connect the new motion signals. */ | |
6516 win->drag_motion_signal = | |
6517 g_signal_connect(G_OBJECT(widget), "motion_notify_event", | |
6518 G_CALLBACK(notebook_motion_cb), win); | |
6519 | |
6520 win->drag_leave_signal = | |
6521 g_signal_connect(G_OBJECT(widget), "leave_notify_event", | |
6522 G_CALLBACK(notebook_leave_cb), win); | |
6523 | |
6524 return FALSE; | |
6525 } | |
6526 | |
6527 static gboolean | |
6528 notebook_release_cb(GtkWidget *widget, GdkEventButton *e, GaimGtkWindow *win) | |
6529 { | |
6530 GaimGtkWindow *dest_win; | |
6531 GaimConversation *conv; | |
6532 GaimGtkConversation *gtkconv; | |
6533 gint dest_page_num = 0; | |
6534 gboolean new_window = FALSE; | |
11614 | 6535 gboolean to_right = FALSE; |
11581 | 6536 |
6537 /* | |
6538 * Don't check to make sure that the event's window matches the | |
6539 * widget's, because we may be getting an event passed on from the | |
6540 * close button. | |
6541 */ | |
6542 if (e->button != 1 && e->type != GDK_BUTTON_RELEASE) | |
6543 return FALSE; | |
6544 | |
6545 if (gdk_pointer_is_grabbed()) { | |
6546 gdk_pointer_ungrab(GDK_CURRENT_TIME); | |
6547 gtk_grab_remove(widget); | |
6548 } | |
6549 | |
6550 if (!win->in_predrag && !win->in_drag) | |
6551 return FALSE; | |
6552 | |
6553 /* Disconnect the motion signal. */ | |
6554 if (win->drag_motion_signal) { | |
6555 g_signal_handler_disconnect(G_OBJECT(widget), | |
6556 win->drag_motion_signal); | |
6557 | |
6558 win->drag_motion_signal = 0; | |
6559 } | |
6560 | |
6561 /* | |
6562 * If we're in a pre-drag, we'll also need to disconnect the leave | |
6563 * signal. | |
6564 */ | |
6565 if (win->in_predrag) { | |
6566 win->in_predrag = FALSE; | |
6567 | |
6568 if (win->drag_leave_signal) { | |
6569 g_signal_handler_disconnect(G_OBJECT(widget), | |
6570 win->drag_leave_signal); | |
6571 | |
6572 win->drag_leave_signal = 0; | |
6573 } | |
6574 } | |
6575 | |
6576 /* If we're not in drag... */ | |
6577 /* We're perfectly normal people! */ | |
6578 if (!win->in_drag) | |
6579 return FALSE; | |
6580 | |
6581 win->in_drag = FALSE; | |
6582 | |
6583 dnd_hints_hide_all(); | |
6584 | |
6585 dest_win = gaim_gtk_conv_window_get_at_xy(e->x_root, e->y_root); | |
6586 | |
6587 conv = gaim_gtk_conv_window_get_active_conversation(win); | |
6588 | |
6589 if (dest_win == NULL) { | |
6590 /* If the current window doesn't have any other conversations, | |
6591 * there isn't much point transferring the conv to a new window. */ | |
6592 if (gaim_gtk_conv_window_get_gtkconv_count(win) > 1) { | |
6593 /* Make a new window to stick this to. */ | |
6594 dest_win = gaim_gtk_conv_window_new(); | |
6595 new_window = TRUE; | |
6596 } | |
6597 } | |
6598 | |
6599 if (dest_win == NULL) | |
6600 return FALSE; | |
6601 | |
6602 gaim_signal_emit(gaim_gtk_conversations_get_handle(), | |
6603 "conversation-dragging", win, dest_win); | |
6604 | |
6605 /* Get the destination page number. */ | |
6606 if (!new_window) | |
6607 dest_page_num = gaim_gtkconv_get_tab_at_xy(dest_win, | |
11614 | 6608 e->x_root, e->y_root, &to_right); |
11581 | 6609 |
6610 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
6611 | |
6612 if (win == dest_win) { | |
6613 gtk_notebook_reorder_child(GTK_NOTEBOOK(win->notebook), gtkconv->tab_cont, dest_page_num); | |
6614 } else { | |
6615 gaim_gtk_conv_window_remove_gtkconv(win, gtkconv); | |
6616 gaim_gtk_conv_window_add_gtkconv(dest_win, gtkconv); | |
11614 | 6617 gtk_notebook_reorder_child(GTK_NOTEBOOK(dest_win->notebook), gtkconv->tab_cont, dest_page_num + to_right); |
11581 | 6618 gaim_gtk_conv_window_switch_gtkconv(dest_win, gtkconv); |
6619 if (new_window) { | |
6620 gint win_width, win_height; | |
6621 | |
6622 gtk_window_get_size(GTK_WINDOW(dest_win->window), | |
6623 &win_width, &win_height); | |
6624 | |
6625 gtk_window_move(GTK_WINDOW(dest_win->window), | |
6626 e->x_root - (win_width / 2), | |
6627 e->y_root - (win_height / 2)); | |
6628 | |
6629 gaim_gtk_conv_window_show(dest_win); | |
6630 } | |
6631 } | |
6632 | |
6633 gtk_widget_grab_focus(GAIM_GTK_CONVERSATION(conv)->entry); | |
6634 | |
6635 return TRUE; | |
6636 } | |
6637 | |
6638 | |
6639 static void | |
6640 before_switch_conv_cb(GtkNotebook *notebook, GtkWidget *page, gint page_num, | |
6641 gpointer user_data) | |
6642 { | |
6643 GaimGtkWindow *win; | |
6644 GaimConversation *conv; | |
6645 GaimGtkConversation *gtkconv; | |
6646 | |
6647 win = user_data; | |
6648 conv = gaim_gtk_conv_window_get_active_conversation(win); | |
6649 | |
6650 g_return_if_fail(conv != NULL); | |
6651 | |
6652 if (gaim_conversation_get_type(conv) != GAIM_CONV_TYPE_IM) | |
6653 return; | |
6654 | |
6655 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
6656 | |
6657 stop_anim(NULL, gtkconv); | |
6658 } | |
12085
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6659 static void |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6660 close_window(GtkWidget *w, GaimGtkWindow *win) |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6661 { |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6662 close_win_cb(w, NULL, win); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6663 } |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6664 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6665 static void |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6666 detach_tab_cb(GtkWidget *w, GObject *menu) |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6667 { |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6668 GaimGtkWindow *win, *new_window; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6669 GaimGtkConversation *gtkconv; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6670 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6671 gtkconv = g_object_get_data(menu, "clicked_tab"); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6672 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6673 if (!gtkconv) |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6674 return; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6675 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6676 win = gaim_gtkconv_get_window(gtkconv); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6677 /* Nothing to do if there's only one tab in the window */ |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6678 if (gaim_gtk_conv_window_get_gtkconv_count(win) == 1) |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6679 return; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6680 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6681 gaim_gtk_conv_window_remove_gtkconv(win, gtkconv); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6682 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6683 new_window = gaim_gtk_conv_window_new(); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6684 gaim_gtk_conv_window_add_gtkconv(new_window, gtkconv); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6685 gaim_gtk_conv_window_show(new_window); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6686 } |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6687 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6688 static void |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6689 close_others_cb(GtkWidget *w, GObject *menu) |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6690 { |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6691 GList *iter; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6692 GaimGtkConversation *gtkconv; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6693 GaimGtkWindow *win; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6694 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6695 gtkconv = g_object_get_data(menu, "clicked_tab"); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6696 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6697 if (!gtkconv) |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6698 return; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6699 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6700 win = gaim_gtkconv_get_window(gtkconv); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6701 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6702 for (iter = gaim_gtk_conv_window_get_gtkconvs(win); iter; ) |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6703 { |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6704 GaimGtkConversation *gconv = iter->data; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6705 iter = iter->next; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6706 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6707 if (gconv != gtkconv) |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6708 { |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6709 close_conv_cb(NULL, gconv); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6710 } |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6711 } |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6712 } |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6713 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6714 static void close_tab_cb(GtkWidget *w, GObject *menu) |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6715 { |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6716 GaimGtkConversation *gtkconv; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6717 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6718 gtkconv = g_object_get_data(menu, "clicked_tab"); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6719 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6720 if (gtkconv) |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6721 close_conv_cb(NULL, gtkconv); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6722 } |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6723 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6724 static gboolean |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6725 right_click_menu_cb(GtkNotebook *notebook, GdkEventButton *event, GaimGtkWindow *win) |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6726 { |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6727 GtkWidget *item, *menu; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6728 GaimGtkConversation *gtkconv; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6729 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6730 if (event->type != GDK_BUTTON_PRESS || event->button != 3) |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6731 return FALSE; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6732 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6733 gtkconv = gaim_gtk_conv_window_get_gtkconv_at_index(win, |
12140
ed6c64e5e0ed
[gaim-migrate @ 14441]
Richard Laager <rlaager@wiktel.com>
parents:
12136
diff
changeset
|
6734 gaim_gtkconv_get_tab_at_xy(win, event->x_root, event->y_root, NULL)); |
12085
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6735 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6736 if (g_object_get_data(G_OBJECT(notebook->menu), "clicked_tab")) |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6737 { |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6738 g_object_set_data(G_OBJECT(notebook->menu), "clicked_tab", gtkconv); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6739 return FALSE; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6740 } |
12188 | 6741 |
12085
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6742 g_object_set_data(G_OBJECT(notebook->menu), "clicked_tab", gtkconv); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6743 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6744 menu = notebook->menu; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6745 gaim_separator(GTK_WIDGET(menu)); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6746 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6747 item = gtk_menu_item_new_with_label("Detach this tab"); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6748 gtk_widget_show(item); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6749 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6750 g_signal_connect(G_OBJECT(item), "activate", |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6751 G_CALLBACK(detach_tab_cb), menu); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6752 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6753 item = gtk_menu_item_new_with_label("Close this tab"); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6754 gtk_widget_show(item); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6755 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6756 g_signal_connect(G_OBJECT(item), "activate", |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6757 G_CALLBACK(close_tab_cb), menu); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6758 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6759 gaim_separator(menu); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6760 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6761 item = gtk_menu_item_new_with_label("Close other tabs"); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6762 gtk_widget_show(item); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6763 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6764 g_signal_connect(G_OBJECT(item), "activate", |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6765 G_CALLBACK(close_others_cb), menu); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6766 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6767 item = gtk_menu_item_new_with_label("Close all tabs"); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6768 gtk_widget_show(item); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6769 gtk_menu_shell_append(GTK_MENU_SHELL(menu), item); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6770 g_signal_connect(G_OBJECT(item), "activate", |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6771 G_CALLBACK(close_window), win); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6772 |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6773 return FALSE; |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6774 } |
11581 | 6775 |
6776 static void | |
6777 switch_conv_cb(GtkNotebook *notebook, GtkWidget *page, gint page_num, | |
6778 gpointer user_data) | |
6779 { | |
6780 GaimGtkWindow *win; | |
6781 GaimConversation *conv; | |
6782 GaimGtkConversation *gtkconv; | |
12594
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
6783 const char *sound_method; |
11581 | 6784 |
6785 win = user_data; | |
6786 gtkconv = gaim_gtk_conv_window_get_gtkconv_at_index(win, page_num); | |
6787 conv = gtkconv->active_conv; | |
6788 | |
6789 g_return_if_fail(conv != NULL); | |
6790 | |
6791 /* | |
6792 * Only set "unseen" to "none" if the window has focus | |
6793 */ | |
6794 if (gaim_gtk_conv_window_has_focus(win)) | |
11604 | 6795 gtkconv_set_unseen(gtkconv, GAIM_UNSEEN_NONE); |
11581 | 6796 |
6797 /* Update the menubar */ | |
6798 | |
11672
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
6799 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(gtkconv->win->menu.logging), |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
6800 gaim_conversation_is_logging(conv)); |
04e0189bb519
[gaim-migrate @ 13958]
Richard Laager <rlaager@wiktel.com>
parents:
11671
diff
changeset
|
6801 |
11594 | 6802 generate_send_to_items(win); |
6803 | |
11604 | 6804 gaim_gtkconv_switch_active_conversation(conv); |
11581 | 6805 |
12594
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
6806 sound_method = gaim_prefs_get_string("/gaim/gtk/sound/method"); |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
6807 if (strcmp(sound_method, "none") != 0) |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
6808 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(win->menu.sounds), |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
6809 gtkconv->make_sound); |
11581 | 6810 |
6811 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(win->menu.show_formatting_toolbar), | |
6812 gaim_prefs_get_bool("/gaim/gtk/conversations/show_formatting_toolbar")); | |
6813 | |
6814 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(win->menu.show_timestamps), | |
12188 | 6815 gaim_prefs_get_bool("/gaim/gtk/conversations/show_timestamps")); |
11581 | 6816 |
12594
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
6817 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM && |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
6818 gaim_prefs_get_bool("/gaim/gtk/conversations/im/show_buddy_icons")) |
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
6819 { |
11581 | 6820 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(win->menu.show_icon), |
6821 gtkconv->u.im->show_icon); | |
12594
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
6822 } |
11604 | 6823 |
11581 | 6824 /* |
6825 * We pause icons when they are not visible. If this icon should | |
6826 * be animated then start it back up again. | |
6827 */ | |
6828 if ((gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) && | |
6829 (gtkconv->u.im->animate)) | |
6830 start_anim(NULL, gtkconv); | |
6831 } | |
6832 | |
6833 /************************************************************************** | |
6834 * GTK+ window ops | |
6835 **************************************************************************/ | |
6836 | |
6837 GList * | |
6838 gaim_gtk_conv_windows_get_list() | |
6839 { | |
6840 return window_list; | |
6841 } | |
6842 | |
6843 GaimGtkWindow * | |
6844 gaim_gtk_conv_window_new() | |
6845 { | |
6846 GaimGtkWindow *win; | |
6847 GtkPositionType pos; | |
6848 GtkWidget *testidea; | |
6849 GtkWidget *menubar; | |
6850 | |
6851 win = g_malloc0(sizeof(GaimGtkWindow)); | |
6852 | |
6853 window_list = g_list_append(window_list, win); | |
6854 | |
6855 /* Create the window. */ | |
6856 win->window = gtk_window_new(GTK_WINDOW_TOPLEVEL); | |
6857 gtk_window_set_role(GTK_WINDOW(win->window), "conversation"); | |
6858 gtk_window_set_resizable(GTK_WINDOW(win->window), TRUE); | |
6859 gtk_container_set_border_width(GTK_CONTAINER(win->window), 0); | |
6860 GTK_WINDOW(win->window)->allow_shrink = TRUE; | |
6861 | |
6862 g_signal_connect(G_OBJECT(win->window), "delete_event", | |
6863 G_CALLBACK(close_win_cb), win); | |
6864 | |
6865 g_signal_connect(G_OBJECT(win->window), "focus_in_event", | |
6866 G_CALLBACK(focus_win_cb), win); | |
6867 | |
6868 /* Create the notebook. */ | |
6869 win->notebook = gtk_notebook_new(); | |
6870 | |
6871 pos = gaim_prefs_get_int("/gaim/gtk/conversations/tab_side"); | |
6872 | |
6873 #if 0 | |
6874 gtk_notebook_set_tab_hborder(GTK_NOTEBOOK(win->notebook), 0); | |
6875 gtk_notebook_set_tab_vborder(GTK_NOTEBOOK(win->notebook), 0); | |
6876 #endif | |
6877 gtk_notebook_set_tab_pos(GTK_NOTEBOOK(win->notebook), pos); | |
6878 gtk_notebook_set_scrollable(GTK_NOTEBOOK(win->notebook), TRUE); | |
6879 gtk_notebook_popup_enable(GTK_NOTEBOOK(win->notebook)); | |
6880 gtk_notebook_set_show_tabs(GTK_NOTEBOOK(win->notebook), FALSE); | |
6881 gtk_notebook_set_show_border(GTK_NOTEBOOK(win->notebook), FALSE); | |
6882 | |
12085
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6883 g_signal_connect(G_OBJECT(win->notebook), "button-press-event", |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6884 G_CALLBACK(right_click_menu_cb), win); |
9b886b6e3002
[gaim-migrate @ 14382]
Gary Kramlich <grim@reaperworld.com>
parents:
12084
diff
changeset
|
6885 |
11581 | 6886 gtk_widget_show(win->notebook); |
6887 | |
6888 g_signal_connect(G_OBJECT(win->notebook), "switch_page", | |
6889 G_CALLBACK(before_switch_conv_cb), win); | |
6890 g_signal_connect_after(G_OBJECT(win->notebook), "switch_page", | |
6891 G_CALLBACK(switch_conv_cb), win); | |
6892 | |
6893 /* Setup the tab drag and drop signals. */ | |
6894 gtk_widget_add_events(win->notebook, | |
6895 GDK_BUTTON1_MOTION_MASK | GDK_LEAVE_NOTIFY_MASK); | |
6896 g_signal_connect(G_OBJECT(win->notebook), "button_press_event", | |
6897 G_CALLBACK(notebook_press_cb), win); | |
6898 g_signal_connect(G_OBJECT(win->notebook), "button_release_event", | |
6899 G_CALLBACK(notebook_release_cb), win); | |
6900 | |
6901 testidea = gtk_vbox_new(FALSE, 0); | |
6902 | |
6903 /* Setup the menubar. */ | |
6904 menubar = setup_menubar(win); | |
6905 gtk_box_pack_start(GTK_BOX(testidea), menubar, FALSE, TRUE, 0); | |
6906 | |
6907 gtk_box_pack_start(GTK_BOX(testidea), win->notebook, TRUE, TRUE, 0); | |
6908 | |
6909 gtk_container_add(GTK_CONTAINER(win->window), testidea); | |
6910 | |
6911 gtk_widget_show(testidea); | |
6912 | |
6913 return win; | |
6914 } | |
6915 | |
6916 void | |
6917 gaim_gtk_conv_window_destroy(GaimGtkWindow *win) | |
6918 { | |
12594
3d34460ecfd6
[gaim-migrate @ 14924]
Richard Laager <rlaager@wiktel.com>
parents:
12579
diff
changeset
|
6919 gaim_prefs_disconnect_by_handle(win); |
11581 | 6920 window_list = g_list_remove(window_list, win); |
6921 | |
11611 | 6922 if (win->gtkconvs) { |
6923 while (win->gtkconvs) { | |
6924 GList *nextgtk = win->gtkconvs->next; | |
6925 GaimGtkConversation *gtkconv = win->gtkconvs->data; | |
6926 GList *nextcore = gtkconv->convs->next; | |
6927 GaimConversation *conv = gtkconv->convs->data; | |
6928 gaim_conversation_destroy(conv); | |
6929 if (!nextgtk && !nextcore) | |
6930 /* we'll end up invoking ourselves when we destroy our last child */ | |
6931 /* so don't destroy ourselves right now */ | |
6932 return; | |
6933 } | |
6934 return; | |
6935 } | |
11581 | 6936 gtk_widget_destroy(win->window); |
6937 | |
6938 g_object_unref(G_OBJECT(win->menu.item_factory)); | |
6939 | |
6940 g_free(win); | |
6941 } | |
6942 | |
6943 void | |
6944 gaim_gtk_conv_window_show(GaimGtkWindow *win) | |
6945 { | |
6946 gtk_widget_show(win->window); | |
6947 } | |
6948 | |
6949 void | |
6950 gaim_gtk_conv_window_hide(GaimGtkWindow *win) | |
6951 { | |
6952 gtk_widget_hide(win->window); | |
6953 } | |
6954 | |
6955 void | |
6956 gaim_gtk_conv_window_raise(GaimGtkWindow *win) | |
6957 { | |
12084
d4728e1abe7b
[gaim-migrate @ 14381]
Gary Kramlich <grim@reaperworld.com>
parents:
12080
diff
changeset
|
6958 gtk_window_present(GTK_WINDOW(win->window)); |
11581 | 6959 } |
6960 | |
6961 void | |
6962 gaim_gtk_conv_window_switch_gtkconv(GaimGtkWindow *win, GaimGtkConversation *gtkconv) | |
6963 { | |
6964 gtk_notebook_set_current_page(GTK_NOTEBOOK(win->notebook), | |
6965 gtk_notebook_page_num(GTK_NOTEBOOK(win->notebook), | |
6966 gtkconv->tab_cont)); | |
6967 } | |
6968 | |
6969 void | |
6970 gaim_gtk_conv_window_add_gtkconv(GaimGtkWindow *win, GaimGtkConversation *gtkconv) | |
6971 { | |
6972 GaimConversation *conv = gtkconv->active_conv; | |
6973 GaimGtkConversation *focus_gtkconv; | |
6974 GtkWidget *tabby, *menu_tabby; | |
6975 GtkWidget *tab_cont = gtkconv->tab_cont; | |
6976 GtkWidget *close_image; | |
6977 GaimConversationType conv_type; | |
6978 const char *name; | |
6979 const gchar *tmp_lab; | |
6980 gint close_button_width, close_button_height, focus_width, focus_pad; | |
11619 | 6981 gboolean tabs_side = FALSE; |
6982 gint angle = 0; | |
11581 | 6983 |
6984 name = gaim_conversation_get_name(conv); | |
6985 conv_type = gaim_conversation_get_type(conv); | |
6986 | |
6987 | |
6988 win->gtkconvs = g_list_append(win->gtkconvs, gtkconv); | |
6989 gtkconv->win = win; | |
6990 | |
11619 | 6991 if (gaim_prefs_get_int("/gaim/gtk/conversations/tab_side") == GTK_POS_LEFT || |
6992 gaim_prefs_get_int("/gaim/gtk/conversations/tab_side") == GTK_POS_RIGHT) | |
6993 tabs_side = TRUE; | |
6994 else if (gaim_prefs_get_int("/gaim/gtk/conversations/tab_side") == (GTK_POS_LEFT|8)) | |
6995 angle = 90; | |
6996 else if (gaim_prefs_get_int("/gaim/gtk/conversations/tab_side") == (GTK_POS_RIGHT|8)) | |
6997 angle = 270; | |
6998 | |
6999 if (angle) | |
7000 gtkconv->tabby = tabby = gtk_vbox_new(FALSE, GAIM_HIG_BOX_SPACE); | |
7001 else | |
7002 gtkconv->tabby = tabby = gtk_hbox_new(FALSE, GAIM_HIG_BOX_SPACE); | |
11581 | 7003 gtkconv->menu_tabby = menu_tabby = gtk_hbox_new(FALSE, GAIM_HIG_BOX_SPACE); |
7004 | |
7005 /* Close button. */ | |
7006 gtkconv->close = gtk_button_new(); | |
7007 gtk_icon_size_lookup(GTK_ICON_SIZE_MENU, &close_button_width, &close_button_height); | |
7008 if (gtk_check_version(2, 4, 2) == NULL) { | |
7009 /* Need to account for extra padding around the gtkbutton */ | |
7010 gtk_widget_style_get(GTK_WIDGET(gtkconv->close), | |
7011 "focus-line-width", &focus_width, | |
7012 "focus-padding", &focus_pad, | |
7013 NULL); | |
7014 close_button_width += (focus_width + focus_pad) * 2; | |
7015 close_button_height += (focus_width + focus_pad) * 2; | |
7016 } | |
7017 gtk_widget_set_size_request(GTK_WIDGET(gtkconv->close), | |
7018 close_button_width, close_button_height); | |
7019 | |
7020 gtk_button_set_relief(GTK_BUTTON(gtkconv->close), GTK_RELIEF_NONE); | |
7021 close_image = gtk_image_new_from_stock(GTK_STOCK_CLOSE, GTK_ICON_SIZE_MENU); | |
7022 gtk_widget_show(close_image); | |
7023 gtk_container_add(GTK_CONTAINER(gtkconv->close), close_image); | |
7024 gtk_tooltips_set_tip(gtkconv->tooltips, gtkconv->close, | |
7025 _("Close conversation"), NULL); | |
7026 | |
7027 g_signal_connect(G_OBJECT(gtkconv->close), "clicked", | |
7028 G_CALLBACK(close_conv_cb), gtkconv); | |
7029 | |
11851 | 7030 #if !GTK_CHECK_VERSION(2,6,0) |
11581 | 7031 /* |
7032 * I love Galeon. They have a fix for that stupid annoying visible | |
7033 * border bug. I love you guys! -- ChipX86 | |
7034 */ | |
11851 | 7035 /* This is fixed properly in some version of Gtk before 2.6.0 */ |
11581 | 7036 g_signal_connect(G_OBJECT(gtkconv->close), "state_changed", |
7037 G_CALLBACK(tab_close_button_state_changed_cb), NULL); | |
11851 | 7038 #endif |
11581 | 7039 |
7040 /* Status icon. */ | |
7041 gtkconv->icon = gtk_image_new(); | |
7042 gtkconv->menu_icon = gtk_image_new(); | |
7043 update_tab_icon(conv); | |
7044 | |
7045 /* Tab label. */ | |
7046 gtkconv->tab_label = gtk_label_new(tmp_lab = gaim_conversation_get_title(conv)); | |
11619 | 7047 |
11581 | 7048 #if GTK_CHECK_VERSION(2,6,0) |
11619 | 7049 if (!angle) |
7050 g_object_set(G_OBJECT(gtkconv->tab_label), "ellipsize", PANGO_ELLIPSIZE_END, NULL); | |
11581 | 7051 gtk_label_set_width_chars(GTK_LABEL(gtkconv->tab_label), 6); |
11619 | 7052 if (tabs_side) { |
7053 gtk_label_set_width_chars(GTK_LABEL(gtkconv->tab_label), MIN(g_utf8_strlen(tmp_lab, -1), 18)); | |
7054 } | |
7055 if (angle) | |
7056 gtk_label_set_angle(GTK_LABEL(gtkconv->tab_label), angle); | |
11581 | 7057 #endif |
7058 gtkconv->menu_label = gtk_label_new(gaim_conversation_get_title(conv)); | |
7059 #if 0 | |
7060 gtk_misc_set_alignment(GTK_MISC(gtkconv->tab_label), 0.00, 0.5); | |
7061 gtk_misc_set_padding(GTK_MISC(gtkconv->tab_label), 4, 0); | |
7062 #endif | |
7063 | |
7064 /* Pack it all together. */ | |
11619 | 7065 if (angle == 90) |
7066 gtk_box_pack_start(GTK_BOX(tabby), gtkconv->close, FALSE, FALSE, 0); | |
7067 else | |
7068 gtk_box_pack_start(GTK_BOX(tabby), gtkconv->icon, FALSE, FALSE, 0); | |
11581 | 7069 gtk_box_pack_start(GTK_BOX(menu_tabby), gtkconv->menu_icon, |
7070 FALSE, FALSE, 0); | |
7071 | |
7072 gtk_widget_show_all(gtkconv->icon); | |
7073 gtk_widget_show_all(gtkconv->menu_icon); | |
7074 | |
7075 gtk_box_pack_start(GTK_BOX(tabby), gtkconv->tab_label, TRUE, TRUE, 0); | |
7076 gtk_box_pack_start(GTK_BOX(menu_tabby), gtkconv->menu_label, TRUE, TRUE, 0); | |
7077 gtk_widget_show(gtkconv->tab_label); | |
7078 gtk_widget_show(gtkconv->menu_label); | |
7079 gtk_misc_set_alignment(GTK_MISC(gtkconv->menu_label), 0, 0); | |
7080 | |
11619 | 7081 if (angle == 90) |
7082 gtk_box_pack_start(GTK_BOX(tabby), gtkconv->icon, FALSE, FALSE, 0); | |
7083 else | |
7084 gtk_box_pack_start(GTK_BOX(tabby), gtkconv->close, FALSE, FALSE, 0); | |
11581 | 7085 if (gaim_prefs_get_bool("/gaim/gtk/conversations/close_on_tabs")) |
7086 gtk_widget_show(gtkconv->close); | |
7087 | |
7088 gtk_widget_show(tabby); | |
7089 gtk_widget_show(menu_tabby); | |
7090 | |
7091 if (gaim_conversation_get_type(conv) == GAIM_CONV_TYPE_IM) | |
7092 gaim_gtkconv_update_buddy_icon(conv); | |
7093 | |
7094 /* Add this pane to the conversation's notebook. */ | |
7095 gtk_notebook_append_page_menu(GTK_NOTEBOOK(win->notebook), tab_cont, tabby, menu_tabby); | |
11619 | 7096 gtk_notebook_set_tab_label_packing(GTK_NOTEBOOK(win->notebook), tab_cont, !tabs_side && !angle, TRUE, GTK_PACK_START); |
11581 | 7097 |
7098 | |
7099 gtk_widget_show(tab_cont); | |
7100 | |
7101 if (gaim_gtk_conv_window_get_gtkconv_count(win) == 1) { | |
7102 /* Er, bug in notebooks? Switch to the page manually. */ | |
7103 gtk_notebook_set_current_page(GTK_NOTEBOOK(win->notebook), 0); | |
7104 | |
7105 gtk_notebook_set_show_tabs(GTK_NOTEBOOK(win->notebook), | |
7106 gaim_prefs_get_bool("/gaim/gtk/conversations/tabs")); | |
7107 } else | |
7108 gtk_notebook_set_show_tabs(GTK_NOTEBOOK(win->notebook), TRUE); | |
7109 | |
7110 focus_gtkconv = g_list_nth_data(gaim_gtk_conv_window_get_gtkconvs(win), | |
7111 gtk_notebook_get_current_page(GTK_NOTEBOOK(win->notebook))); | |
7112 gtk_widget_grab_focus(focus_gtkconv->entry); | |
7113 | |
7114 if (gaim_gtk_conv_window_get_gtkconv_count(win) == 1) | |
11734 | 7115 update_send_to_selection(win); |
11581 | 7116 } |
7117 | |
12288
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
7118 void |
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
7119 gaim_gtk_conv_window_remove_gtkconv(GaimGtkWindow *win, GaimGtkConversation *gtkconv) |
11581 | 7120 { |
7121 unsigned int index; | |
7122 GaimConversationType conv_type; | |
7123 | |
7124 conv_type = gaim_conversation_get_type(gtkconv->active_conv); | |
7125 index = gtk_notebook_page_num(GTK_NOTEBOOK(win->notebook), gtkconv->tab_cont); | |
7126 | |
7127 g_object_ref(gtkconv->tab_cont); | |
7128 gtk_object_sink(GTK_OBJECT(gtkconv->tab_cont)); | |
7129 | |
7130 gtk_notebook_remove_page(GTK_NOTEBOOK(win->notebook), index); | |
7131 | |
7132 /* go back to tabless if need be */ | |
7133 if (gaim_gtk_conv_window_get_gtkconv_count(win) <= 2) { | |
7134 gtk_notebook_set_show_tabs(GTK_NOTEBOOK(win->notebook), | |
7135 gaim_prefs_get_bool("/gaim/gtk/conversations/tabs")); | |
7136 } | |
7137 | |
7138 win->gtkconvs = g_list_remove(win->gtkconvs, gtkconv); | |
11582 | 7139 |
12288
3897229ccb33
[gaim-migrate @ 14592]
Luke Schierer <lschiere@pidgin.im>
parents:
12286
diff
changeset
|
7140 if (!win->gtkconvs && win != hidden_convwin) |
11582 | 7141 gaim_gtk_conv_window_destroy(win); |
11581 | 7142 } |
7143 | |
7144 GaimGtkConversation * | |
7145 gaim_gtk_conv_window_get_gtkconv_at_index(const GaimGtkWindow *win, int index) | |
7146 { | |
7147 GtkWidget *tab_cont; | |
7148 | |
7149 if (index == -1) | |
7150 index = 0; | |
7151 tab_cont = gtk_notebook_get_nth_page(GTK_NOTEBOOK(win->notebook), index); | |
11604 | 7152 return tab_cont ? g_object_get_data(G_OBJECT(tab_cont), "GaimGtkConversation") : NULL; |
11581 | 7153 } |
7154 | |
7155 GaimGtkConversation * | |
7156 gaim_gtk_conv_window_get_active_gtkconv(const GaimGtkWindow *win) | |
7157 { | |
7158 int index; | |
7159 GtkWidget *tab_cont; | |
7160 | |
7161 index = gtk_notebook_get_current_page(GTK_NOTEBOOK(win->notebook)); | |
7162 if (index == -1) | |
7163 index = 0; | |
7164 tab_cont = gtk_notebook_get_nth_page(GTK_NOTEBOOK(win->notebook), index); | |
7165 if (!tab_cont) | |
7166 return NULL; | |
7167 return g_object_get_data(G_OBJECT(tab_cont), "GaimGtkConversation"); | |
7168 } | |
7169 | |
7170 | |
7171 GaimConversation * | |
7172 gaim_gtk_conv_window_get_active_conversation(const GaimGtkWindow *win) | |
7173 { | |
7174 GaimGtkConversation *gtkconv; | |
7175 | |
7176 gtkconv = gaim_gtk_conv_window_get_active_gtkconv(win); | |
7177 return gtkconv ? gtkconv->active_conv : NULL; | |
7178 } | |
7179 | |
7180 gboolean | |
7181 gaim_gtk_conv_window_is_active_conversation(const GaimConversation *conv) | |
7182 { | |
7183 return conv == gaim_gtk_conv_window_get_active_conversation(GAIM_GTK_CONVERSATION(conv)->win); | |
7184 } | |
7185 | |
7186 gboolean | |
7187 gaim_gtk_conv_window_has_focus(GaimGtkWindow *win) | |
7188 { | |
7189 gboolean has_focus = FALSE; | |
7190 | |
7191 g_object_get(G_OBJECT(win->window), "has-toplevel-focus", &has_focus, NULL); | |
7192 | |
7193 return has_focus; | |
7194 } | |
7195 | |
7196 GaimGtkWindow * | |
7197 gaim_gtk_conv_window_get_at_xy(int x, int y) | |
7198 { | |
7199 GaimGtkWindow *win; | |
7200 GdkWindow *gdkwin; | |
7201 GList *l; | |
7202 | |
7203 gdkwin = gdk_window_at_pointer(&x, &y); | |
7204 | |
7205 if (gdkwin) | |
7206 gdkwin = gdk_window_get_toplevel(gdkwin); | |
7207 | |
7208 for (l = gaim_gtk_conv_windows_get_list(); l != NULL; l = l->next) { | |
7209 win = l->data; | |
7210 | |
7211 if (gdkwin == win->window->window) | |
7212 return win; | |
7213 } | |
7214 | |
7215 return NULL; | |
7216 } | |
7217 | |
7218 GList * | |
7219 gaim_gtk_conv_window_get_gtkconvs(GaimGtkWindow *win) | |
7220 { | |
7221 return win->gtkconvs; | |
7222 } | |
7223 | |
7224 guint | |
7225 gaim_gtk_conv_window_get_gtkconv_count(GaimGtkWindow *win) | |
7226 { | |
7227 return g_list_length(win->gtkconvs); | |
7228 } | |
7229 | |
7230 GaimGtkWindow * | |
7231 gaim_gtk_conv_window_first_with_type(GaimConversationType type) | |
7232 { | |
7233 GList *wins, *convs; | |
7234 GaimGtkWindow *win; | |
7235 GaimGtkConversation *conv; | |
7236 | |
7237 if (type == GAIM_CONV_TYPE_UNKNOWN) | |
7238 return NULL; | |
7239 | |
7240 for (wins = gaim_gtk_conv_windows_get_list(); wins != NULL; wins = wins->next) { | |
7241 win = wins->data; | |
7242 | |
7243 for (convs = win->gtkconvs; | |
7244 convs != NULL; | |
7245 convs = convs->next) { | |
7246 | |
7247 conv = convs->data; | |
7248 | |
7249 if (gaim_conversation_get_type(conv->active_conv) == type) | |
7250 return win; | |
7251 } | |
7252 } | |
7253 | |
7254 return NULL; | |
7255 } | |
7256 | |
7257 GaimGtkWindow * | |
7258 gaim_gtk_conv_window_last_with_type(GaimConversationType type) | |
7259 { | |
7260 GList *wins, *convs; | |
7261 GaimGtkWindow *win; | |
7262 GaimGtkConversation *conv; | |
7263 | |
7264 if (type == GAIM_CONV_TYPE_UNKNOWN) | |
7265 return NULL; | |
7266 | |
7267 for (wins = g_list_last(gaim_gtk_conv_windows_get_list()); | |
7268 wins != NULL; | |
7269 wins = wins->prev) { | |
7270 | |
7271 win = wins->data; | |
7272 | |
7273 for (convs = win->gtkconvs; | |
7274 convs != NULL; | |
7275 convs = convs->next) { | |
7276 | |
7277 conv = convs->data; | |
7278 | |
7279 if (gaim_conversation_get_type(conv->active_conv) == type) | |
7280 return win; | |
7281 } | |
7282 } | |
7283 | |
7284 return NULL; | |
7285 } | |
7286 | |
7287 | |
7288 /************************************************************************** | |
7289 * Conversation placement functions | |
7290 **************************************************************************/ | |
7291 typedef struct | |
7292 { | |
7293 char *id; | |
7294 char *name; | |
7295 GaimConvPlacementFunc fnc; | |
7296 | |
7297 } ConvPlacementData; | |
7298 | |
7299 static GList *conv_placement_fncs = NULL; | |
7300 static GaimConvPlacementFunc place_conv = NULL; | |
7301 | |
7302 /* This one places conversations in the last made window. */ | |
7303 static void | |
7304 conv_placement_last_created_win(GaimGtkConversation *conv) | |
7305 { | |
7306 GaimGtkWindow *win; | |
7307 | |
7308 GList *l = g_list_last(gaim_gtk_conv_windows_get_list()); | |
7309 win = l ? l->data : NULL;; | |
7310 | |
7311 if (win == NULL) { | |
7312 win = gaim_gtk_conv_window_new(); | |
7313 | |
7314 gaim_gtk_conv_window_add_gtkconv(win, conv); | |
7315 gaim_gtk_conv_window_show(win); | |
7316 } else { | |
7317 gaim_gtk_conv_window_add_gtkconv(win, conv); | |
7318 } | |
7319 } | |
7320 | |
7321 /* This one places conversations in the last made window of the same type. */ | |
7322 static void | |
7323 conv_placement_last_created_win_type(GaimGtkConversation *conv) | |
7324 { | |
7325 GaimGtkWindow *win; | |
7326 | |
7327 win = gaim_gtk_conv_window_last_with_type(gaim_conversation_get_type(conv->active_conv)); | |
7328 | |
7329 if (win == NULL) { | |
7330 win = gaim_gtk_conv_window_new(); | |
7331 | |
7332 gaim_gtk_conv_window_add_gtkconv(win, conv); | |
7333 gaim_gtk_conv_window_show(win); | |
7334 } else | |
7335 gaim_gtk_conv_window_add_gtkconv(win, conv); | |
7336 } | |
7337 | |
7338 /* This one places each conversation in its own window. */ | |
7339 static void | |
7340 conv_placement_new_window(GaimGtkConversation *conv) | |
7341 { | |
7342 GaimGtkWindow *win; | |
7343 | |
7344 win = gaim_gtk_conv_window_new(); | |
7345 | |
7346 gaim_gtk_conv_window_add_gtkconv(win, conv); | |
7347 | |
7348 gaim_gtk_conv_window_show(win); | |
7349 } | |
7350 | |
7351 static GaimGroup * | |
7352 conv_get_group(GaimGtkConversation *conv) | |
7353 { | |
7354 GaimGroup *group = NULL; | |
7355 | |
7356 if (gaim_conversation_get_type(conv->active_conv) == GAIM_CONV_TYPE_IM) { | |
7357 GaimBuddy *buddy; | |
7358 | |
7359 buddy = gaim_find_buddy(gaim_conversation_get_account(conv->active_conv), | |
7360 gaim_conversation_get_name(conv->active_conv)); | |
7361 | |
7362 if (buddy != NULL) | |
12088 | 7363 group = gaim_buddy_get_group(buddy); |
11581 | 7364 |
7365 } else if (gaim_conversation_get_type(conv->active_conv) == GAIM_CONV_TYPE_CHAT) { | |
7366 GaimChat *chat; | |
7367 | |
7368 chat = gaim_blist_find_chat(gaim_conversation_get_account(conv->active_conv), | |
7369 gaim_conversation_get_name(conv->active_conv)); | |
7370 | |
7371 if (chat != NULL) | |
7372 group = gaim_chat_get_group(chat); | |
7373 } | |
7374 | |
7375 return group; | |
7376 } | |
7377 | |
7378 /* | |
7379 * This groups things by, well, group. Buddies from groups will always be | |
7380 * grouped together, and a buddy from a group not belonging to any currently | |
7381 * open windows will get a new window. | |
7382 */ | |
7383 static void | |
7384 conv_placement_by_group(GaimGtkConversation *conv) | |
7385 { | |
7386 GaimConversationType type; | |
7387 GaimGroup *group = NULL; | |
7388 GList *wl, *cl; | |
7389 | |
7390 type = gaim_conversation_get_type(conv->active_conv); | |
7391 | |
7392 group = conv_get_group(conv); | |
7393 | |
7394 /* Go through the list of IMs and find one with this group. */ | |
7395 for (wl = gaim_gtk_conv_windows_get_list(); wl != NULL; wl = wl->next) { | |
7396 GaimGtkWindow *win2; | |
7397 GaimGtkConversation *conv2; | |
7398 GaimGroup *group2 = NULL; | |
7399 | |
7400 win2 = wl->data; | |
7401 | |
7402 for (cl = win2->gtkconvs; | |
7403 cl != NULL; | |
7404 cl = cl->next) { | |
7405 conv2 = cl->data; | |
7406 | |
7407 group2 = conv_get_group(conv2); | |
7408 | |
7409 if (group == group2) { | |
7410 gaim_gtk_conv_window_add_gtkconv(win2, conv); | |
7411 | |
7412 return; | |
7413 } | |
7414 } | |
7415 } | |
7416 | |
7417 /* Make a new window. */ | |
7418 conv_placement_new_window(conv); | |
7419 } | |
7420 | |
7421 /* This groups things by account. Otherwise, the same semantics as above */ | |
7422 static void | |
7423 conv_placement_by_account(GaimGtkConversation *conv) | |
7424 { | |
7425 GaimConversationType type; | |
7426 GList *wins, *convs; | |
7427 GaimAccount *account; | |
7428 | |
7429 account = gaim_conversation_get_account(conv->active_conv); | |
7430 type = gaim_conversation_get_type(conv->active_conv); | |
7431 | |
7432 /* Go through the list of IMs and find one with this group. */ | |
7433 for (wins = gaim_gtk_conv_windows_get_list(); wins != NULL; wins = wins->next) { | |
7434 GaimGtkWindow *win2; | |
7435 GaimGtkConversation *conv2; | |
7436 | |
7437 win2 = wins->data; | |
7438 | |
7439 for (convs = win2->gtkconvs; | |
7440 convs != NULL; | |
7441 convs = convs->next) { | |
7442 conv2 = convs->data; | |
7443 | |
7444 if (account == gaim_conversation_get_account(conv2->active_conv)) { | |
7445 gaim_gtk_conv_window_add_gtkconv(win2, conv); | |
7446 return; | |
7447 } | |
7448 } | |
7449 } | |
7450 | |
7451 /* Make a new window. */ | |
7452 conv_placement_new_window(conv); | |
7453 } | |
7454 | |
7455 static ConvPlacementData * | |
7456 get_conv_placement_data(const char *id) | |
7457 { | |
7458 ConvPlacementData *data = NULL; | |
7459 GList *n; | |
7460 | |
7461 for (n = conv_placement_fncs; n; n = n->next) { | |
7462 data = n->data; | |
7463 if (!strcmp(data->id, id)) | |
7464 return data; | |
7465 } | |
7466 | |
7467 return NULL; | |
7468 } | |
7469 | |
7470 static void | |
7471 add_conv_placement_fnc(const char *id, const char *name, | |
7472 GaimConvPlacementFunc fnc) | |
7473 { | |
7474 ConvPlacementData *data; | |
7475 | |
7476 data = g_new(ConvPlacementData, 1); | |
7477 | |
7478 data->id = g_strdup(id); | |
7479 data->name = g_strdup(name); | |
7480 data->fnc = fnc; | |
7481 | |
7482 conv_placement_fncs = g_list_append(conv_placement_fncs, data); | |
7483 } | |
7484 | |
7485 static void | |
7486 ensure_default_funcs(void) | |
7487 { | |
7488 if (conv_placement_fncs == NULL) { | |
7489 add_conv_placement_fnc("last", _("Last created window"), | |
7490 conv_placement_last_created_win); | |
7491 add_conv_placement_fnc("im_chat", _("Separate IM and Chat windows"), | |
7492 conv_placement_last_created_win_type); | |
7493 add_conv_placement_fnc("new", _("New window"), | |
7494 conv_placement_new_window); | |
7495 add_conv_placement_fnc("group", _("By group"), | |
7496 conv_placement_by_group); | |
7497 add_conv_placement_fnc("account", _("By account"), | |
7498 conv_placement_by_account); | |
7499 } | |
7500 } | |
7501 | |
7502 GList * | |
7503 gaim_gtkconv_placement_get_options(void) | |
7504 { | |
7505 GList *n, *list = NULL; | |
7506 ConvPlacementData *data; | |
7507 | |
7508 ensure_default_funcs(); | |
7509 | |
7510 for (n = conv_placement_fncs; n; n = n->next) { | |
7511 data = n->data; | |
7512 list = g_list_append(list, data->name); | |
7513 list = g_list_append(list, data->id); | |
7514 } | |
7515 | |
7516 return list; | |
7517 } | |
7518 | |
7519 | |
7520 void | |
7521 gaim_gtkconv_placement_add_fnc(const char *id, const char *name, | |
7522 GaimConvPlacementFunc fnc) | |
7523 { | |
7524 g_return_if_fail(id != NULL); | |
7525 g_return_if_fail(name != NULL); | |
7526 g_return_if_fail(fnc != NULL); | |
7527 | |
7528 ensure_default_funcs(); | |
7529 | |
7530 add_conv_placement_fnc(id, name, fnc); | |
7531 } | |
7532 | |
7533 void | |
7534 gaim_gtkconv_placement_remove_fnc(const char *id) | |
7535 { | |
7536 ConvPlacementData *data = get_conv_placement_data(id); | |
7537 | |
7538 if (data == NULL) | |
7539 return; | |
7540 | |
7541 conv_placement_fncs = g_list_remove(conv_placement_fncs, data); | |
7542 | |
7543 g_free(data->id); | |
7544 g_free(data->name); | |
7545 g_free(data); | |
7546 } | |
7547 | |
7548 const char * | |
7549 gaim_gtkconv_placement_get_name(const char *id) | |
7550 { | |
7551 ConvPlacementData *data; | |
7552 | |
7553 ensure_default_funcs(); | |
7554 | |
7555 data = get_conv_placement_data(id); | |
7556 | |
7557 if (data == NULL) | |
7558 return NULL; | |
7559 | |
7560 return data->name; | |
7561 } | |
7562 | |
7563 GaimConvPlacementFunc | |
7564 gaim_gtkconv_placement_get_fnc(const char *id) | |
7565 { | |
7566 ConvPlacementData *data; | |
7567 | |
7568 ensure_default_funcs(); | |
7569 | |
7570 data = get_conv_placement_data(id); | |
7571 | |
7572 if (data == NULL) | |
7573 return NULL; | |
7574 | |
7575 return data->fnc; | |
7576 } | |
7577 | |
7578 void | |
7579 gaim_gtkconv_placement_set_current_func(GaimConvPlacementFunc func) | |
7580 { | |
7581 g_return_if_fail(func != NULL); | |
7582 | |
11936
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
7583 /* If tabs are enabled, set the function, otherwise, NULL it out. */ |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
7584 if (gaim_prefs_get_bool("/gaim/gtk/conversations/tabs")) |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
7585 place_conv = func; |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
7586 else |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
7587 place_conv = NULL; |
11581 | 7588 } |
7589 | |
7590 GaimConvPlacementFunc | |
7591 gaim_gtkconv_placement_get_current_func(void) | |
7592 { | |
7593 return place_conv; | |
7594 } | |
7595 | |
7596 void | |
7597 gaim_gtkconv_placement_place(GaimGtkConversation *gtkconv) | |
7598 { | |
7599 if (place_conv) | |
7600 place_conv(gtkconv); | |
11936
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
7601 else |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
7602 conv_placement_new_window(gtkconv); |
2af814f836e6
[gaim-migrate @ 14227]
Gary Kramlich <grim@reaperworld.com>
parents:
11911
diff
changeset
|
7603 } |
12239 | 7604 |
7605 gboolean | |
7606 gaim_gtkconv_is_hidden(GaimGtkConversation *gtkconv) | |
7607 { | |
7608 g_return_val_if_fail(gtkconv != NULL, FALSE); | |
7609 | |
7610 return (gtkconv->win == hidden_convwin); | |
7611 } | |
12345
f6fa5d742c76
[gaim-migrate @ 14649]
Luke Schierer <lschiere@pidgin.im>
parents:
12335
diff
changeset
|
7612 |
f6fa5d742c76
[gaim-migrate @ 14649]
Luke Schierer <lschiere@pidgin.im>
parents:
12335
diff
changeset
|
7613 |
f6fa5d742c76
[gaim-migrate @ 14649]
Luke Schierer <lschiere@pidgin.im>
parents:
12335
diff
changeset
|
7614 /* Algorithm from http://www.w3.org/TR/AERT#color-contrast */ |
12351
af152afe7bac
[gaim-migrate @ 14655]
Richard Laager <rlaager@wiktel.com>
parents:
12346
diff
changeset
|
7615 static gboolean |
12356
4b8c20fcecd6
[gaim-migrate @ 14660]
Richard Laager <rlaager@wiktel.com>
parents:
12354
diff
changeset
|
7616 color_is_visible(GdkColor foreground, GdkColor background, int color_contrast, int brightness_contrast) |
12345
f6fa5d742c76
[gaim-migrate @ 14649]
Luke Schierer <lschiere@pidgin.im>
parents:
12335
diff
changeset
|
7617 { |
12346
f81d458aba18
[gaim-migrate @ 14650]
Richard Laager <rlaager@wiktel.com>
parents:
12345
diff
changeset
|
7618 gulong fg_brightness; |
f81d458aba18
[gaim-migrate @ 14650]
Richard Laager <rlaager@wiktel.com>
parents:
12345
diff
changeset
|
7619 gulong bg_brightness; |
f81d458aba18
[gaim-migrate @ 14650]
Richard Laager <rlaager@wiktel.com>
parents:
12345
diff
changeset
|
7620 gulong br_diff; |
f81d458aba18
[gaim-migrate @ 14650]
Richard Laager <rlaager@wiktel.com>
parents:
12345
diff
changeset
|
7621 gulong col_diff; |
12352
e3fefd3ebc72
[gaim-migrate @ 14656]
Luke Schierer <lschiere@pidgin.im>
parents:
12351
diff
changeset
|
7622 int fred, fgreen, fblue, bred, bgreen, bblue; |
e3fefd3ebc72
[gaim-migrate @ 14656]
Luke Schierer <lschiere@pidgin.im>
parents:
12351
diff
changeset
|
7623 |
e3fefd3ebc72
[gaim-migrate @ 14656]
Luke Schierer <lschiere@pidgin.im>
parents:
12351
diff
changeset
|
7624 /* this algorithm expects colors between 0 and 255 for each of red green and blue. |
e3fefd3ebc72
[gaim-migrate @ 14656]
Luke Schierer <lschiere@pidgin.im>
parents:
12351
diff
changeset
|
7625 * GTK on the other hand has values between 0 and 65535 |
e3fefd3ebc72
[gaim-migrate @ 14656]
Luke Schierer <lschiere@pidgin.im>
parents:
12351
diff
changeset
|
7626 * Err suggested I >> 8, which grabbed the high bits. |
e3fefd3ebc72
[gaim-migrate @ 14656]
Luke Schierer <lschiere@pidgin.im>
parents:
12351
diff
changeset
|
7627 */ |
12360
3153661f4d5c
[gaim-migrate @ 14664]
Luke Schierer <lschiere@pidgin.im>
parents:
12359
diff
changeset
|
7628 |
12352
e3fefd3ebc72
[gaim-migrate @ 14656]
Luke Schierer <lschiere@pidgin.im>
parents:
12351
diff
changeset
|
7629 fred = foreground.red >> 8 ; |
e3fefd3ebc72
[gaim-migrate @ 14656]
Luke Schierer <lschiere@pidgin.im>
parents:
12351
diff
changeset
|
7630 fgreen = foreground.green >> 8 ; |
e3fefd3ebc72
[gaim-migrate @ 14656]
Luke Schierer <lschiere@pidgin.im>
parents:
12351
diff
changeset
|
7631 fblue = foreground.blue >> 8 ; |
e3fefd3ebc72
[gaim-migrate @ 14656]
Luke Schierer <lschiere@pidgin.im>
parents:
12351
diff
changeset
|
7632 |
e3fefd3ebc72
[gaim-migrate @ 14656]
Luke Schierer <lschiere@pidgin.im>
parents:
12351
diff
changeset
|
7633 |
e3fefd3ebc72
[gaim-migrate @ 14656]
Luke Schierer <lschiere@pidgin.im>
parents:
12351
diff
changeset
|
7634 bred = background.red >> 8 ; |
e3fefd3ebc72
[gaim-migrate @ 14656]
Luke Schierer <lschiere@pidgin.im>
parents:
12351
diff
changeset
|
7635 bgreen = background.green >> 8 ; |
e3fefd3ebc72
[gaim-migrate @ 14656]
Luke Schierer <lschiere@pidgin.im>
parents:
12351
diff
changeset
|
7636 bblue = background.blue >> 8 ; |
e3fefd3ebc72
[gaim-migrate @ 14656]
Luke Schierer <lschiere@pidgin.im>
parents:
12351
diff
changeset
|
7637 |
e3fefd3ebc72
[gaim-migrate @ 14656]
Luke Schierer <lschiere@pidgin.im>
parents:
12351
diff
changeset
|
7638 fg_brightness = (fred * 299 + fgreen * 587 + fblue * 114) / 1000; |
e3fefd3ebc72
[gaim-migrate @ 14656]
Luke Schierer <lschiere@pidgin.im>
parents:
12351
diff
changeset
|
7639 bg_brightness = (bred * 299 + bgreen * 587 + bblue * 114) / 1000; |
12345
f6fa5d742c76
[gaim-migrate @ 14649]
Luke Schierer <lschiere@pidgin.im>
parents:
12335
diff
changeset
|
7640 br_diff = abs(fg_brightness - bg_brightness); |
f6fa5d742c76
[gaim-migrate @ 14649]
Luke Schierer <lschiere@pidgin.im>
parents:
12335
diff
changeset
|
7641 |
12352
e3fefd3ebc72
[gaim-migrate @ 14656]
Luke Schierer <lschiere@pidgin.im>
parents:
12351
diff
changeset
|
7642 col_diff = abs(fred - bred) + abs(fgreen - bgreen) + abs(fblue - bblue); |
e3fefd3ebc72
[gaim-migrate @ 14656]
Luke Schierer <lschiere@pidgin.im>
parents:
12351
diff
changeset
|
7643 |
12356
4b8c20fcecd6
[gaim-migrate @ 14660]
Richard Laager <rlaager@wiktel.com>
parents:
12354
diff
changeset
|
7644 return ((col_diff > color_contrast) && (br_diff > brightness_contrast)); |
12345
f6fa5d742c76
[gaim-migrate @ 14649]
Luke Schierer <lschiere@pidgin.im>
parents:
12335
diff
changeset
|
7645 } |
f6fa5d742c76
[gaim-migrate @ 14649]
Luke Schierer <lschiere@pidgin.im>
parents:
12335
diff
changeset
|
7646 |
f6fa5d742c76
[gaim-migrate @ 14649]
Luke Schierer <lschiere@pidgin.im>
parents:
12335
diff
changeset
|
7647 |
12351
af152afe7bac
[gaim-migrate @ 14655]
Richard Laager <rlaager@wiktel.com>
parents:
12346
diff
changeset
|
7648 static GdkColor* |
12345
f6fa5d742c76
[gaim-migrate @ 14649]
Luke Schierer <lschiere@pidgin.im>
parents:
12335
diff
changeset
|
7649 generate_nick_colors(guint numcolors, GdkColor background) |
f6fa5d742c76
[gaim-migrate @ 14649]
Luke Schierer <lschiere@pidgin.im>
parents:
12335
diff
changeset
|
7650 { |
12363
f758af0373cb
[gaim-migrate @ 14667]
Luke Schierer <lschiere@pidgin.im>
parents:
12360
diff
changeset
|
7651 guint i = 0, j = 0; |
12346
f81d458aba18
[gaim-migrate @ 14650]
Richard Laager <rlaager@wiktel.com>
parents:
12345
diff
changeset
|
7652 GdkColor *colors = g_new(GdkColor, numcolors); |
12356
4b8c20fcecd6
[gaim-migrate @ 14660]
Richard Laager <rlaager@wiktel.com>
parents:
12354
diff
changeset
|
7653 GdkColor nick_highlight; |
4b8c20fcecd6
[gaim-migrate @ 14660]
Richard Laager <rlaager@wiktel.com>
parents:
12354
diff
changeset
|
7654 GdkColor send_color; |
4b8c20fcecd6
[gaim-migrate @ 14660]
Richard Laager <rlaager@wiktel.com>
parents:
12354
diff
changeset
|
7655 |
4b8c20fcecd6
[gaim-migrate @ 14660]
Richard Laager <rlaager@wiktel.com>
parents:
12354
diff
changeset
|
7656 gdk_color_parse(HIGHLIGHT_COLOR, &nick_highlight); |
4b8c20fcecd6
[gaim-migrate @ 14660]
Richard Laager <rlaager@wiktel.com>
parents:
12354
diff
changeset
|
7657 gdk_color_parse(SEND_COLOR, &send_color); |
12346
f81d458aba18
[gaim-migrate @ 14650]
Richard Laager <rlaager@wiktel.com>
parents:
12345
diff
changeset
|
7658 |
f81d458aba18
[gaim-migrate @ 14650]
Richard Laager <rlaager@wiktel.com>
parents:
12345
diff
changeset
|
7659 srand(background.red + background.green + background.blue + 1); |
f81d458aba18
[gaim-migrate @ 14650]
Richard Laager <rlaager@wiktel.com>
parents:
12345
diff
changeset
|
7660 |
12363
f758af0373cb
[gaim-migrate @ 14667]
Luke Schierer <lschiere@pidgin.im>
parents:
12360
diff
changeset
|
7661 /* first we look through the list of "good" colors: colors that differ from every other color in the |
f758af0373cb
[gaim-migrate @ 14667]
Luke Schierer <lschiere@pidgin.im>
parents:
12360
diff
changeset
|
7662 * list. only some of them will differ from the background color though. lets see if we can find |
f758af0373cb
[gaim-migrate @ 14667]
Luke Schierer <lschiere@pidgin.im>
parents:
12360
diff
changeset
|
7663 * numcolors of them that do |
f758af0373cb
[gaim-migrate @ 14667]
Luke Schierer <lschiere@pidgin.im>
parents:
12360
diff
changeset
|
7664 */ |
f758af0373cb
[gaim-migrate @ 14667]
Luke Schierer <lschiere@pidgin.im>
parents:
12360
diff
changeset
|
7665 while (i < numcolors && j < NUM_NICK_SEED_COLORS ) |
12360
3153661f4d5c
[gaim-migrate @ 14664]
Luke Schierer <lschiere@pidgin.im>
parents:
12359
diff
changeset
|
7666 { |
12363
f758af0373cb
[gaim-migrate @ 14667]
Luke Schierer <lschiere@pidgin.im>
parents:
12360
diff
changeset
|
7667 GdkColor color = nick_seed_colors[j]; |
f758af0373cb
[gaim-migrate @ 14667]
Luke Schierer <lschiere@pidgin.im>
parents:
12360
diff
changeset
|
7668 |
f758af0373cb
[gaim-migrate @ 14667]
Luke Schierer <lschiere@pidgin.im>
parents:
12360
diff
changeset
|
7669 gaim_debug(GAIM_DEBUG_INFO, NULL, |
f758af0373cb
[gaim-migrate @ 14667]
Luke Schierer <lschiere@pidgin.im>
parents:
12360
diff
changeset
|
7670 "Looking for colors from safe list, I have found %i so far.\n",i); |
12360
3153661f4d5c
[gaim-migrate @ 14664]
Luke Schierer <lschiere@pidgin.im>
parents:
12359
diff
changeset
|
7671 |
3153661f4d5c
[gaim-migrate @ 14664]
Luke Schierer <lschiere@pidgin.im>
parents:
12359
diff
changeset
|
7672 if (color_is_visible(color, background, MIN_COLOR_CONTRAST, MIN_BRIGHTNESS_CONTRAST) && |
3153661f4d5c
[gaim-migrate @ 14664]
Luke Schierer <lschiere@pidgin.im>
parents:
12359
diff
changeset
|
7673 color_is_visible(color, nick_highlight, MIN_COLOR_CONTRAST / 2, 0) && |
3153661f4d5c
[gaim-migrate @ 14664]
Luke Schierer <lschiere@pidgin.im>
parents:
12359
diff
changeset
|
7674 color_is_visible(color, send_color, MIN_COLOR_CONTRAST / 4, 0)) |
3153661f4d5c
[gaim-migrate @ 14664]
Luke Schierer <lschiere@pidgin.im>
parents:
12359
diff
changeset
|
7675 { |
3153661f4d5c
[gaim-migrate @ 14664]
Luke Schierer <lschiere@pidgin.im>
parents:
12359
diff
changeset
|
7676 colors[i] = color; |
3153661f4d5c
[gaim-migrate @ 14664]
Luke Schierer <lschiere@pidgin.im>
parents:
12359
diff
changeset
|
7677 i++; |
3153661f4d5c
[gaim-migrate @ 14664]
Luke Schierer <lschiere@pidgin.im>
parents:
12359
diff
changeset
|
7678 } |
12363
f758af0373cb
[gaim-migrate @ 14667]
Luke Schierer <lschiere@pidgin.im>
parents:
12360
diff
changeset
|
7679 j++; |
f758af0373cb
[gaim-migrate @ 14667]
Luke Schierer <lschiere@pidgin.im>
parents:
12360
diff
changeset
|
7680 } |
f758af0373cb
[gaim-migrate @ 14667]
Luke Schierer <lschiere@pidgin.im>
parents:
12360
diff
changeset
|
7681 |
f758af0373cb
[gaim-migrate @ 14667]
Luke Schierer <lschiere@pidgin.im>
parents:
12360
diff
changeset
|
7682 /* we might not have found numcolors in the last loop. if we did, we'll never enter this one. |
f758af0373cb
[gaim-migrate @ 14667]
Luke Schierer <lschiere@pidgin.im>
parents:
12360
diff
changeset
|
7683 * if we did not, lets just find some colors that don't conflict with the background. its |
f758af0373cb
[gaim-migrate @ 14667]
Luke Schierer <lschiere@pidgin.im>
parents:
12360
diff
changeset
|
7684 * expensive to find colors that not only don't conflict with the background, but also do not |
f758af0373cb
[gaim-migrate @ 14667]
Luke Schierer <lschiere@pidgin.im>
parents:
12360
diff
changeset
|
7685 * conflict with each other. |
f758af0373cb
[gaim-migrate @ 14667]
Luke Schierer <lschiere@pidgin.im>
parents:
12360
diff
changeset
|
7686 */ |
f758af0373cb
[gaim-migrate @ 14667]
Luke Schierer <lschiere@pidgin.im>
parents:
12360
diff
changeset
|
7687 while(i < numcolors ) |
12346
f81d458aba18
[gaim-migrate @ 14650]
Richard Laager <rlaager@wiktel.com>
parents:
12345
diff
changeset
|
7688 { |
f81d458aba18
[gaim-migrate @ 14650]
Richard Laager <rlaager@wiktel.com>
parents:
12345
diff
changeset
|
7689 GdkColor color = { 0, rand() % 65536, rand() % 65536, rand() % 65536 }; |
12360
3153661f4d5c
[gaim-migrate @ 14664]
Luke Schierer <lschiere@pidgin.im>
parents:
12359
diff
changeset
|
7690 |
12363
f758af0373cb
[gaim-migrate @ 14667]
Luke Schierer <lschiere@pidgin.im>
parents:
12360
diff
changeset
|
7691 gaim_debug(GAIM_DEBUG_WARNING, NULL, |
f758af0373cb
[gaim-migrate @ 14667]
Luke Schierer <lschiere@pidgin.im>
parents:
12360
diff
changeset
|
7692 "Looking for random colors to fill the list, I have found %i so far.\n",i); |
f758af0373cb
[gaim-migrate @ 14667]
Luke Schierer <lschiere@pidgin.im>
parents:
12360
diff
changeset
|
7693 |
12356
4b8c20fcecd6
[gaim-migrate @ 14660]
Richard Laager <rlaager@wiktel.com>
parents:
12354
diff
changeset
|
7694 if (color_is_visible(color, background, MIN_COLOR_CONTRAST, MIN_BRIGHTNESS_CONTRAST) && |
4b8c20fcecd6
[gaim-migrate @ 14660]
Richard Laager <rlaager@wiktel.com>
parents:
12354
diff
changeset
|
7695 color_is_visible(color, nick_highlight, MIN_COLOR_CONTRAST / 2, 0) && |
4b8c20fcecd6
[gaim-migrate @ 14660]
Richard Laager <rlaager@wiktel.com>
parents:
12354
diff
changeset
|
7696 color_is_visible(color, send_color, MIN_COLOR_CONTRAST / 4, 0)) |
4b8c20fcecd6
[gaim-migrate @ 14660]
Richard Laager <rlaager@wiktel.com>
parents:
12354
diff
changeset
|
7697 { |
12345
f6fa5d742c76
[gaim-migrate @ 14649]
Luke Schierer <lschiere@pidgin.im>
parents:
12335
diff
changeset
|
7698 colors[i] = color; |
f6fa5d742c76
[gaim-migrate @ 14649]
Luke Schierer <lschiere@pidgin.im>
parents:
12335
diff
changeset
|
7699 i++; |
f6fa5d742c76
[gaim-migrate @ 14649]
Luke Schierer <lschiere@pidgin.im>
parents:
12335
diff
changeset
|
7700 } |
f6fa5d742c76
[gaim-migrate @ 14649]
Luke Schierer <lschiere@pidgin.im>
parents:
12335
diff
changeset
|
7701 } |
f6fa5d742c76
[gaim-migrate @ 14649]
Luke Schierer <lschiere@pidgin.im>
parents:
12335
diff
changeset
|
7702 |
f6fa5d742c76
[gaim-migrate @ 14649]
Luke Schierer <lschiere@pidgin.im>
parents:
12335
diff
changeset
|
7703 return colors; |
f6fa5d742c76
[gaim-migrate @ 14649]
Luke Schierer <lschiere@pidgin.im>
parents:
12335
diff
changeset
|
7704 } |