Mercurial > pidgin.yaz
annotate src/gtkconv.c @ 10108:f0100b414d98
[gaim-migrate @ 11141]
Two things:
a. Added Enter as a gtk_binding to GtkIMHtml. This fixes everything.
Input methods now work. The "Enter sends" and "Ctrl-Enter sends" preferences
were removed and defaulted to yes and no respectively, BUT, in a very super-cool
turn of events, you can now add your own bindings to .gtkrc to make WHATEVER
YOU WANT send. Awesome. Someone should use g_signal_accumulator_true_handled
or something to make profiles and away messages able to insert newlines.
b. Removed "Use multi-colored screennames in chats," defaulted to yes, and
wrote a nifty algorithm to automatically adjust the colors to accomodate the
background (see http://gaim.sf.net/sean/porn-chat.png). People should play
around and tweak it a bit. The algorithm takes into consideration the
luminosity of the current background and the base hue to use for the screenname
in generating the new colors. Note that it does this while maintaining the hues.
Someone should optimize this so it skips over the floating point arithmatic when
the background color is white.
committer: Tailor Script <tailor@pidgin.im>
author | Sean Egan <seanegan@gmail.com> |
---|---|
date | Sun, 17 Oct 2004 23:55:49 +0000 |
parents | 6cbeca0e8f58 |
children | 1a91e814e9d8 |
rev | line source |
---|---|
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
1 /** |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
2 * @file gtkconv.h GTK+ Conversation API |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
3 * @ingroup gtkui |
4359 | 4 * |
8046 | 5 * Gaim is the legal property of its developers, whose names are too numerous |
6 * to list here. Please refer to the COPYRIGHT file distributed with this | |
7 * source distribution. | |
6725
e62a504c83d0
[gaim-migrate @ 7252]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
8 * |
4359 | 9 * This program is free software; you can redistribute it and/or modify |
10 * it under the terms of the GNU General Public License as published by | |
11 * the Free Software Foundation; either version 2 of the License, or | |
12 * (at your option) any later version. | |
13 * | |
14 * This program is distributed in the hope that it will be useful, | |
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
17 * GNU General Public License for more details. | |
18 * | |
19 * You should have received a copy of the GNU General Public License | |
20 * along with this program; if not, write to the Free Software | |
21 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
22 * | |
23 */ | |
9791 | 24 #include "internal.h" |
25 #include "gtkgaim.h" | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
26 |
4359 | 27 #ifndef _WIN32 |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
28 # include <X11/Xlib.h> |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
29 #endif |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
30 |
4359 | 31 #ifdef USE_GTKSPELL |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
32 # include <gtkspell/gtkspell.h> |
7538
357eb1c39b72
[gaim-migrate @ 8151]
Christian Hammond <chipx86@chipx86.com>
parents:
7476
diff
changeset
|
33 # ifdef _WIN32 |
357eb1c39b72
[gaim-migrate @ 8151]
Christian Hammond <chipx86@chipx86.com>
parents:
7476
diff
changeset
|
34 # include "wspell.h" |
357eb1c39b72
[gaim-migrate @ 8151]
Christian Hammond <chipx86@chipx86.com>
parents:
7476
diff
changeset
|
35 # endif |
4359 | 36 #endif |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
37 |
4359 | 38 #include <gdk/gdkkeysyms.h> |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
39 |
9699 | 40 #include "account.h" |
9130 | 41 #include "cmds.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
42 #include "debug.h" |
6982 | 43 #include "imgstore.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
44 #include "log.h" |
5436
ad445074d239
[gaim-migrate @ 5818]
Christian Hammond <chipx86@chipx86.com>
parents:
5402
diff
changeset
|
45 #include "notify.h" |
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5484
diff
changeset
|
46 #include "prefs.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
47 #include "prpl.h" |
6038 | 48 #include "request.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
49 #include "sound.h" |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
50 #include "util.h" |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
51 |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
52 #include "dnd-hints.h" |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
53 #include "gtkblist.h" |
5717 | 54 #include "gtkconv.h" |
9709 | 55 #include "gtkdialogs.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
56 #include "gtkimhtml.h" |
8317 | 57 #include "gtkimhtmltoolbar.h" |
7431 | 58 #include "gtklog.h" |
5907
18486c860a46
[gaim-migrate @ 6339]
Christian Hammond <chipx86@chipx86.com>
parents:
5902
diff
changeset
|
59 #include "gtkpounce.h" |
6371
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6291
diff
changeset
|
60 #include "gtkprivacy.h" |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
61 #include "gtkutils.h" |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
62 #include "stock.h" |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
63 |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
64 /* XXX */ |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
65 #include "gaim.h" |
4359 | 66 |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
67 #define AUTO_RESPONSE "<AUTO-REPLY> : " |
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
68 |
10084 | 69 #define SEND_COLOR "#0d005d" |
70 #define RECV_COLOR "#fd4100" | |
7854 | 71 |
10108 | 72 #define LUMINANCE(c) (float)((0.3*(c.red))+(0.59*(c.green))+(0.11*(c.blue))) |
73 | |
74 /* These colors come from the default GNOME palette */ | |
75 static GdkColor nick_colors[] = { | |
76 {0, 47616, 46336, 43776}, /* Basic 3D Medium */ | |
77 {0, 33536, 42496, 32512}, /* Green Medium */ | |
78 {0, 49408, 26112, 23040}, /* Red Medium */ | |
79 {0, 23808, 29952, 21760}, /* Green Dark */ | |
80 {0, 34816, 17920, 12544}, /* Red Dark */ | |
81 {0, 45824, 37120, 26880}, /* Face skin Dark */ | |
82 {0, 32768, 32000, 29696}, /* Basic 3D Dark */ | |
83 {0, 33280, 26112, 18176}, /* Face Skin Shadow */ | |
84 {0, 57088, 16896, 7680}, /* Accent Red */ | |
85 {0, 17920, 40960, 17920}, /* Accent Green */ | |
86 {0, 39168, 0, 0}, /* Accent Red Dark */ | |
87 {0, 9728, 50944, 9728}, /* Accent Green Dark */ | |
88 {0, 34816, 32512, 41728}, /* Purple Medium */ | |
89 {0, 49408, 14336, 8704} /* Red Shadow */ | |
4359 | 90 }; |
6291 | 91 |
4359 | 92 #define NUM_NICK_COLORS (sizeof(nick_colors) / sizeof(*nick_colors)) |
93 | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
94 typedef struct |
4359 | 95 { |
96 GtkWidget *window; | |
97 | |
98 GtkWidget *entry; | |
99 GtkWidget *message; | |
100 | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
101 GaimConversation *conv; |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
102 |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
103 } InviteBuddyInfo; |
4359 | 104 |
105 static GtkWidget *invite_dialog = NULL; | |
106 | |
107 /* Prototypes. <-- because Paco-Paco hates this comment. */ | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
108 static void got_typing_keypress(GaimConversation *conv, gboolean first); |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
109 static GList *generate_invite_user_names(GaimConnection *gc); |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
110 static void add_chat_buddy_common(GaimConversation *conv, |
9554 | 111 const char *name); |
9605 | 112 static gboolean tab_complete(GaimConversation *conv); |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
113 static void update_typing_icon(GaimConversation *conv); |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
114 static gboolean update_send_as_selection(GaimConvWindow *win); |
4602
4128761bacb8
[gaim-migrate @ 4889]
Christian Hammond <chipx86@chipx86.com>
parents:
4598
diff
changeset
|
115 static char *item_factory_translate_func (const char *path, gpointer func_data); |
4359 | 116 |
117 /************************************************************************** | |
118 * Callbacks | |
119 **************************************************************************/ | |
120 static gint | |
121 close_win_cb(GtkWidget *w, GdkEventAny *e, gpointer d) | |
122 { | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
123 GaimConvWindow *win = (GaimConvWindow *)d; |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
124 |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
125 gaim_conv_window_destroy(win); |
4361
25d5b2a7545f
[gaim-migrate @ 4627]
Christian Hammond <chipx86@chipx86.com>
parents:
4360
diff
changeset
|
126 |
25d5b2a7545f
[gaim-migrate @ 4627]
Christian Hammond <chipx86@chipx86.com>
parents:
4360
diff
changeset
|
127 return TRUE; |
4359 | 128 } |
129 | |
130 static gint | |
131 close_conv_cb(GtkWidget *w, gpointer d) | |
132 { | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
133 GaimConversation *conv = (GaimConversation *)d; |
4359 | 134 |
135 gaim_conversation_destroy(conv); | |
4361
25d5b2a7545f
[gaim-migrate @ 4627]
Christian Hammond <chipx86@chipx86.com>
parents:
4360
diff
changeset
|
136 |
25d5b2a7545f
[gaim-migrate @ 4627]
Christian Hammond <chipx86@chipx86.com>
parents:
4360
diff
changeset
|
137 return TRUE; |
4359 | 138 } |
139 | |
8914 | 140 static gboolean |
141 size_allocate_cb(GtkWidget *w, GtkAllocation *allocation, GaimConversation *conv) | |
142 { | |
143 GaimGtkConversation *gtkconv; | |
9048 | 144 GaimConvWindow *win = gaim_conversation_get_window(conv); |
9459 | 145 gboolean saveheight; |
8914 | 146 |
147 if (!GTK_WIDGET_VISIBLE(w)) | |
148 return FALSE; | |
149 | |
150 if (!GAIM_IS_GTK_CONVERSATION(conv)) | |
151 return FALSE; | |
152 | |
153 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
154 | |
9459 | 155 /* we only save the new height if the formatting toolbar visibility matches the pref */ |
156 saveheight = (gtkconv->show_formatting_toolbar == gaim_prefs_get_bool("/gaim/gtk/conversations/show_formatting_toolbar")); | |
157 | |
9048 | 158 /* I find that I resize the window when it has a bunch of conversations in it, mostly so that the tab bar |
159 * will fit, but then I don't want new windows taking up the entire screen. I check to see if there is only one | |
160 * conversation in the window. This way we'll be setting new windows to the size of the last resized new window. */ | |
161 | |
8914 | 162 if (gaim_conversation_get_type(conv) == GAIM_CONV_IM) |
163 { | |
9048 | 164 if (w == gtkconv->sw && (gaim_conv_window_get_conversation_count(win) == 1)) |
8914 | 165 { |
166 gaim_prefs_set_int("/gaim/gtk/conversations/im/default_width", allocation->width); | |
9459 | 167 if (saveheight) |
168 gaim_prefs_set_int("/gaim/gtk/conversations/im/default_height", allocation->height); | |
8914 | 169 } |
170 if (w == gtkconv->entry) | |
171 gaim_prefs_set_int("/gaim/gtk/conversations/im/entry_height", allocation->height); | |
172 } | |
173 else if (gaim_conversation_get_type(conv) == GAIM_CONV_CHAT) | |
174 { | |
9048 | 175 if (w == gtkconv->sw && (gaim_conv_window_get_conversation_count(win) == 1)) |
8914 | 176 { |
177 gaim_prefs_set_int("/gaim/gtk/conversations/chat/default_width", allocation->width); | |
9459 | 178 if (saveheight) |
179 gaim_prefs_set_int("/gaim/gtk/conversations/chat/default_height", allocation->height); | |
8914 | 180 } |
181 if (w == gtkconv->entry) | |
182 gaim_prefs_set_int("/gaim/gtk/conversations/chat/entry_height", allocation->height); | |
183 } | |
184 | |
185 return FALSE; | |
186 } | |
187 | |
7446
064c697cc223
[gaim-migrate @ 8057]
Christian Hammond <chipx86@chipx86.com>
parents:
7440
diff
changeset
|
188 /* Courtesy of Galeon! */ |
064c697cc223
[gaim-migrate @ 8057]
Christian Hammond <chipx86@chipx86.com>
parents:
7440
diff
changeset
|
189 static void |
064c697cc223
[gaim-migrate @ 8057]
Christian Hammond <chipx86@chipx86.com>
parents:
7440
diff
changeset
|
190 tab_close_button_state_changed_cb(GtkWidget *widget, GtkStateType prev_state) |
064c697cc223
[gaim-migrate @ 8057]
Christian Hammond <chipx86@chipx86.com>
parents:
7440
diff
changeset
|
191 { |
064c697cc223
[gaim-migrate @ 8057]
Christian Hammond <chipx86@chipx86.com>
parents:
7440
diff
changeset
|
192 if (GTK_WIDGET_STATE(widget) == GTK_STATE_ACTIVE) |
064c697cc223
[gaim-migrate @ 8057]
Christian Hammond <chipx86@chipx86.com>
parents:
7440
diff
changeset
|
193 gtk_widget_set_state(widget, GTK_STATE_NORMAL); |
064c697cc223
[gaim-migrate @ 8057]
Christian Hammond <chipx86@chipx86.com>
parents:
7440
diff
changeset
|
194 } |
064c697cc223
[gaim-migrate @ 8057]
Christian Hammond <chipx86@chipx86.com>
parents:
7440
diff
changeset
|
195 |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
196 static void |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
197 default_formatize(GaimConversation *conv) |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
198 { |
8061 | 199 GaimGtkConversation *c = GAIM_GTK_CONVERSATION(conv); |
200 GaimConnection *gc = gaim_conversation_get_gc(conv); | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
201 |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
202 if (gc && gc->flags & GAIM_CONNECTION_HTML) |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
203 { |
9025 | 204 if (gaim_prefs_get_bool("/gaim/gtk/conversations/send_formatting")) |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
205 { |
9025 | 206 char *color; |
207 GdkColor fg_color, bg_color; | |
208 | |
209 if (gaim_prefs_get_bool("/gaim/gtk/conversations/send_bold")) | |
210 gtk_imhtml_toggle_bold(GTK_IMHTML(c->entry)); | |
211 | |
212 if (gaim_prefs_get_bool("/gaim/gtk/conversations/send_italic")) | |
213 gtk_imhtml_toggle_italic(GTK_IMHTML(c->entry)); | |
214 | |
215 if (gaim_prefs_get_bool("/gaim/gtk/conversations/send_underline")) | |
216 gtk_imhtml_toggle_underline(GTK_IMHTML(c->entry)); | |
217 | |
218 gtk_imhtml_toggle_fontface(GTK_IMHTML(c->entry), | |
219 gaim_prefs_get_string("/gaim/gtk/conversations/font_face")); | |
220 | |
221 if (!(gc->flags & GAIM_CONNECTION_NO_FONTSIZE)) | |
222 gtk_imhtml_font_set_size(GTK_IMHTML(c->entry), | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
223 gaim_prefs_get_int("/gaim/gtk/conversations/font_size")); |
9025 | 224 |
225 if(strcmp(gaim_prefs_get_string("/gaim/gtk/conversations/fgcolor"), "") != 0) | |
226 { | |
227 gdk_color_parse(gaim_prefs_get_string("/gaim/gtk/conversations/fgcolor"), | |
228 &fg_color); | |
229 color = g_strdup_printf("#%02x%02x%02x", | |
230 fg_color.red / 256, | |
231 fg_color.green / 256, | |
232 fg_color.blue / 256); | |
233 } | |
234 else | |
235 color = g_strdup(""); | |
236 | |
8061 | 237 gtk_imhtml_toggle_forecolor(GTK_IMHTML(c->entry), color); |
238 g_free(color); | |
9025 | 239 |
240 if(!(gc->flags & GAIM_CONNECTION_NO_BGCOLOR) && | |
241 strcmp(gaim_prefs_get_string("/gaim/gtk/conversations/bgcolor"), "") != 0) | |
242 { | |
243 gdk_color_parse(gaim_prefs_get_string("/gaim/gtk/conversations/bgcolor"), | |
244 &bg_color); | |
245 color = g_strdup_printf("#%02x%02x%02x", | |
246 bg_color.red / 256, | |
247 bg_color.green / 256, | |
248 bg_color.blue / 256); | |
249 } | |
250 else | |
251 color = g_strdup(""); | |
252 | |
8061 | 253 gtk_imhtml_toggle_backcolor(GTK_IMHTML(c->entry), color); |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
254 g_free(color); |
8061 | 255 } |
8677 | 256 |
9025 | 257 |
8677 | 258 if (gc->flags & GAIM_CONNECTION_FORMATTING_WBFO) |
259 gtk_imhtml_set_whole_buffer_formatting_only(GTK_IMHTML(c->entry), TRUE); | |
260 else | |
261 gtk_imhtml_set_whole_buffer_formatting_only(GTK_IMHTML(c->entry), FALSE); | |
8061 | 262 } |
263 } | |
9130 | 264 |
265 static const char * | |
266 gaim_gtk_get_cmd_prefix(void) | |
267 { | |
268 return "/"; | |
269 } | |
270 | |
9167 | 271 static GaimCmdRet |
9829 | 272 say_command_cb(GaimConversation *conv, |
273 const char *cmd, char **args, char **error, void *data) | |
274 { | |
275 if (gaim_conversation_get_type(conv) == GAIM_CONV_IM) | |
276 gaim_conv_im_send(GAIM_CONV_IM(conv), args[0]); | |
277 else if (gaim_conversation_get_type(conv) == GAIM_CONV_CHAT) | |
278 gaim_conv_chat_send(GAIM_CONV_CHAT(conv), args[0]); | |
279 | |
280 return GAIM_CMD_RET_OK; | |
281 } | |
282 | |
283 static GaimCmdRet | |
9167 | 284 me_command_cb(GaimConversation *conv, |
9597 | 285 const char *cmd, char **args, char **error, void *data) |
9167 | 286 { |
287 char *tmp; | |
288 | |
289 tmp = g_strdup_printf("/me %s", args[0]); | |
9175 | 290 |
9167 | 291 if (gaim_conversation_get_type(conv) == GAIM_CONV_IM) |
292 gaim_conv_im_send(GAIM_CONV_IM(conv), tmp); | |
293 else if (gaim_conversation_get_type(conv) == GAIM_CONV_CHAT) | |
294 gaim_conv_chat_send(GAIM_CONV_CHAT(conv), tmp); | |
295 | |
296 g_free(tmp); | |
297 return GAIM_CMD_RET_OK; | |
298 } | |
299 | |
9212 | 300 static GaimCmdRet |
301 debug_command_cb(GaimConversation *conv, | |
9597 | 302 const char *cmd, char **args, char **error, void *data) |
9212 | 303 { |
304 char *tmp, *markup; | |
305 GaimCmdStatus status; | |
306 | |
307 if (!g_ascii_strcasecmp(args[0], "version")) { | |
308 tmp = g_strdup_printf(_("me is using Gaim v%s."), VERSION); | |
309 markup = gaim_escape_html(tmp); | |
310 | |
311 status = gaim_cmd_do_command(conv, tmp, markup, error); | |
312 | |
313 g_free(tmp); | |
314 g_free(markup); | |
315 return status; | |
316 } else { | |
317 gaim_conversation_write(conv, NULL, _("Supported debug options are: version"), | |
318 GAIM_MESSAGE_NO_LOG|GAIM_MESSAGE_ERROR, time(NULL)); | |
319 return GAIM_CMD_STATUS_OK; | |
320 } | |
321 } | |
322 | |
9213 | 323 static GaimCmdRet |
324 help_command_cb(GaimConversation *conv, | |
9597 | 325 const char *cmd, char **args, char **error, void *data) |
9213 | 326 { |
9597 | 327 GList *l, *text; |
9213 | 328 GString *s; |
9597 | 329 |
330 if (args[0] != NULL) { | |
331 s = g_string_new(""); | |
332 text = gaim_cmd_help(conv, args[0]); | |
333 | |
334 if (text) { | |
335 for (l = text; l; l = l->next) | |
336 if (l->next) | |
9816 | 337 g_string_append_printf(s, "%s\n", (char *)l->data); |
9597 | 338 else |
9816 | 339 g_string_append_printf(s, "%s", (char *)l->data); |
9597 | 340 } else { |
341 g_string_append(s, _("No such command (in this context).")); | |
342 } | |
343 } else { | |
344 s = g_string_new(_("Use \"/help <command>\" for help on a specific command.\n" | |
345 "The following commands are available in this context:\n")); | |
346 | |
347 text = gaim_cmd_list(conv); | |
348 for (l = text; l; l = l->next) | |
9213 | 349 if (l->next) |
9597 | 350 g_string_append_printf(s, "%s, ", (char *)l->data); |
9213 | 351 else |
9597 | 352 g_string_append_printf(s, "%s.", (char *)l->data); |
9213 | 353 } |
354 | |
355 gaim_conversation_write(conv, NULL, s->str, GAIM_MESSAGE_NO_LOG, time(NULL)); | |
356 g_string_free(s, TRUE); | |
357 | |
358 return GAIM_CMD_STATUS_OK; | |
359 } | |
360 | |
4359 | 361 static void |
9374 | 362 send_history_add(GaimConversation *conv, const char *message) |
363 { | |
364 GList *first; | |
365 | |
366 first = g_list_first(conv->send_history); | |
367 | |
368 if (first->data) | |
369 g_free(first->data); | |
370 | |
371 first->data = g_strdup(message); | |
372 | |
373 conv->send_history = g_list_prepend(first, NULL); | |
374 } | |
375 | |
9832 | 376 static gboolean |
377 check_for_and_do_command(GaimConversation *conv) | |
378 { | |
379 GaimGtkConversation *gtkconv; | |
380 char *cmd; | |
381 const char *prefix; | |
382 GaimAccount *account; | |
383 GtkTextIter start; | |
384 | |
385 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
386 account = gaim_conversation_get_account(conv); | |
387 prefix = gaim_gtk_get_cmd_prefix(); | |
388 | |
389 cmd = gtk_imhtml_get_text(GTK_IMHTML(gtkconv->entry), NULL, NULL); | |
390 gtk_text_buffer_get_start_iter(GTK_IMHTML(gtkconv->entry)->text_buffer, &start); | |
391 | |
392 if (cmd && (strncmp(cmd, prefix, strlen(prefix)) == 0) | |
393 && !gtk_text_iter_get_child_anchor(&start)) { | |
394 GaimCmdStatus status; | |
395 char *error, *cmdline, *markup, *send_history; | |
396 GtkTextIter end; | |
397 | |
398 send_history = gtk_imhtml_get_markup(GTK_IMHTML(gtkconv->entry)); | |
399 send_history_add(conv, send_history); | |
400 g_free(send_history); | |
401 | |
402 cmdline = cmd + strlen(prefix); | |
403 | |
404 gtk_text_iter_forward_chars(&start, g_utf8_strlen(prefix, -1)); | |
405 gtk_text_buffer_get_end_iter(GTK_IMHTML(gtkconv->entry)->text_buffer, &end); | |
406 markup = gtk_imhtml_get_markup_range(GTK_IMHTML(gtkconv->entry), &start, &end); | |
407 status = gaim_cmd_do_command(conv, cmdline, markup, &error); | |
408 g_free(cmd); | |
409 g_free(markup); | |
410 | |
411 switch (status) { | |
412 case GAIM_CMD_STATUS_OK: | |
413 return TRUE; | |
414 case GAIM_CMD_STATUS_NOT_FOUND: | |
415 if (!gaim_prefs_get_bool("/gaim/gtk/conversations/passthrough_unknown_commands")) { | |
416 gaim_conversation_write(conv, "", _("No such command."), | |
417 GAIM_MESSAGE_NO_LOG, time(NULL)); | |
418 | |
419 return TRUE; | |
420 } | |
421 return FALSE; | |
422 case GAIM_CMD_STATUS_WRONG_ARGS: | |
423 gaim_conversation_write(conv, "", _("Syntax Error: You typed the wrong number of arguments " | |
424 "to that command."), | |
425 GAIM_MESSAGE_NO_LOG, time(NULL)); | |
426 return TRUE; | |
427 case GAIM_CMD_STATUS_FAILED: | |
428 gaim_conversation_write(conv, "", error ? error : _("Your command failed for an unknown reason."), | |
429 GAIM_MESSAGE_NO_LOG, time(NULL)); | |
430 if(error) | |
431 g_free(error); | |
432 return TRUE; | |
433 case GAIM_CMD_STATUS_WRONG_TYPE: | |
434 if(gaim_conversation_get_type(conv) == GAIM_CONV_IM) | |
435 gaim_conversation_write(conv, "", _("That command only works in Chats, not IMs."), | |
436 GAIM_MESSAGE_NO_LOG, time(NULL)); | |
437 else | |
438 gaim_conversation_write(conv, "", _("That command only works in IMs, not Chats."), | |
439 GAIM_MESSAGE_NO_LOG, time(NULL)); | |
440 return TRUE; | |
441 case GAIM_CMD_STATUS_WRONG_PRPL: | |
442 gaim_conversation_write(conv, "", _("That command doesn't work on this protocol."), | |
443 GAIM_MESSAGE_NO_LOG, time(NULL)); | |
444 return TRUE; | |
445 } | |
446 } | |
447 | |
448 g_free(cmd); | |
449 return FALSE; | |
450 } | |
451 | |
9374 | 452 static void |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
453 send_cb(GtkWidget *widget, GaimConversation *conv) |
4359 | 454 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
455 GaimGtkConversation *gtkconv; |
8655 | 456 GaimAccount *account; |
8677 | 457 GaimConnection *gc; |
8448 | 458 char *buf, *clean; |
4359 | 459 |
460 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
8655 | 461 account = gaim_conversation_get_account(conv); |
9130 | 462 |
9471 | 463 if (!gaim_account_is_connected(account)) |
464 return; | |
465 | |
9474 | 466 if ((gaim_conversation_get_type(conv) == GAIM_CONV_CHAT) && |
467 gaim_conv_chat_has_left(GAIM_CONV_CHAT(conv))) | |
9471 | 468 return; |
469 | |
9832 | 470 if (check_for_and_do_command(conv)) { |
471 gtk_imhtml_clear(GTK_IMHTML(gtkconv->entry)); | |
472 default_formatize(conv); | |
473 return; | |
9130 | 474 } |
475 | |
8442 | 476 buf = gtk_imhtml_get_markup(GTK_IMHTML(gtkconv->entry)); |
8962 | 477 clean = gtk_imhtml_get_text(GTK_IMHTML(gtkconv->entry), NULL, NULL); |
8448 | 478 |
4359 | 479 gtk_widget_grab_focus(gtkconv->entry); |
480 | |
8448 | 481 if (strlen(clean) == 0) { |
482 g_free(clean); | |
4359 | 483 return; |
484 } | |
485 | |
8677 | 486 gc = gaim_account_get_connection(account); |
487 if (gc && (gc->flags & GAIM_CONNECTION_NO_NEWLINES)) { | |
488 char **bufs; | |
489 int i; | |
490 | |
491 bufs = gtk_imhtml_get_markup_lines(GTK_IMHTML(gtkconv->entry)); | |
492 for (i = 0; bufs[i]; i++) { | |
9374 | 493 send_history_add(conv, bufs[i]); |
8677 | 494 if (gaim_conversation_get_type(conv) == GAIM_CONV_IM) |
495 gaim_conv_im_send(GAIM_CONV_IM(conv), bufs[i]); | |
496 else if (gaim_conversation_get_type(conv) == GAIM_CONV_CHAT) | |
497 gaim_conv_chat_send(GAIM_CONV_CHAT(conv), bufs[i]); | |
498 } | |
499 | |
500 g_strfreev(bufs); | |
501 | |
502 } else { | |
9374 | 503 send_history_add(conv, buf); |
8677 | 504 if (gaim_conversation_get_type(conv) == GAIM_CONV_IM) |
505 gaim_conv_im_send(GAIM_CONV_IM(conv), buf); | |
506 else if (gaim_conversation_get_type(conv) == GAIM_CONV_CHAT) | |
507 gaim_conv_chat_send(GAIM_CONV_CHAT(conv), buf); | |
508 } | |
4359 | 509 |
8677 | 510 g_free(clean); |
4359 | 511 g_free(buf); |
512 | |
8061 | 513 gtk_imhtml_clear(GTK_IMHTML(gtkconv->entry)); |
514 default_formatize(conv); | |
4359 | 515 } |
516 | |
517 static void | |
7928 | 518 add_remove_cb(GtkWidget *widget, GaimConversation *conv) |
4359 | 519 { |
7060
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
520 GaimAccount *account; |
4359 | 521 const char *name; |
522 | |
7060
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
523 account = gaim_conversation_get_account(conv); |
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
524 name = gaim_conversation_get_name(conv); |
7879 | 525 |
526 if (gaim_conversation_get_type(conv) == GAIM_CONV_IM) { | |
7859 | 527 GaimBuddy *b; |
528 | |
529 b = gaim_find_buddy(account, name); | |
530 if (b != NULL) | |
9730 | 531 gaim_gtkdialogs_remove_buddy(b); |
7859 | 532 else if (account != NULL && gaim_account_is_connected(account)) |
533 gaim_blist_request_add_buddy(account, (char *)name, NULL, NULL); | |
7879 | 534 } else if (gaim_conversation_get_type(conv) == GAIM_CONV_CHAT) { |
7859 | 535 GaimChat *c; |
536 | |
537 c = gaim_blist_find_chat(account, name); | |
538 if (c != NULL) | |
9730 | 539 gaim_gtkdialogs_remove_chat(c); |
7859 | 540 else if (account != NULL && gaim_account_is_connected(account)) |
9754 | 541 gaim_blist_request_add_chat(account, NULL, NULL, name); |
7859 | 542 } |
4359 | 543 |
544 gtk_widget_grab_focus(GAIM_GTK_CONVERSATION(conv)->entry); | |
545 } | |
546 | |
7975 | 547 static void chat_do_info(GaimConversation *conv, const char *who) |
548 { | |
549 GaimPluginProtocolInfo *prpl_info = NULL; | |
550 GaimConnection *gc; | |
551 | |
552 if ((gc = gaim_conversation_get_gc(conv))) { | |
553 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); | |
554 | |
555 /* | |
556 * If there are special needs for getting info on users in | |
557 * buddy chat "rooms"... | |
558 */ | |
559 if (prpl_info->get_cb_info != NULL) | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
560 { |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
561 prpl_info->get_cb_info(gc, |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
562 gaim_conv_chat_get_id(GAIM_CONV_CHAT(conv)), who); |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
563 } |
7975 | 564 else |
565 prpl_info->get_info(gc, who); | |
566 } | |
567 } | |
568 | |
569 | |
4359 | 570 static void |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
571 info_cb(GtkWidget *widget, GaimConversation *conv) |
4359 | 572 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
573 GaimGtkConversation *gtkconv; |
4359 | 574 |
575 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
576 | |
7879 | 577 if (gaim_conversation_get_type(conv) == GAIM_CONV_IM) { |
578 serv_get_info(gaim_conversation_get_gc(conv), | |
579 gaim_conversation_get_name(conv)); | |
580 | |
581 gtk_widget_grab_focus(gtkconv->entry); | |
582 } else if (gaim_conversation_get_type(conv) == GAIM_CONV_CHAT) { | |
583 /* Get info of the person currently selected in the GtkTreeView */ | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
584 GaimGtkChatPane *gtkchat; |
4359 | 585 GtkTreeIter iter; |
586 GtkTreeModel *model; | |
587 GtkTreeSelection *sel; | |
9554 | 588 char *name; |
4359 | 589 |
590 gtkchat = gtkconv->u.chat; | |
591 | |
592 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); | |
593 sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(gtkchat->list)); | |
594 | |
595 if (gtk_tree_selection_get_selected(sel, NULL, &iter)) | |
9498 | 596 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, CHAT_USERS_NAME_COLUMN, &name, -1); |
4359 | 597 else |
598 return; | |
599 | |
7975 | 600 chat_do_info(conv, name); |
9554 | 601 g_free(name); |
4359 | 602 } |
603 } | |
604 | |
605 static void | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
606 block_cb(GtkWidget *widget, GaimConversation *conv) |
4359 | 607 { |
6371
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6291
diff
changeset
|
608 GaimAccount *account; |
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6291
diff
changeset
|
609 |
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6291
diff
changeset
|
610 account = gaim_conversation_get_account(conv); |
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6291
diff
changeset
|
611 |
8f94cce8faa5
[gaim-migrate @ 6876]
Christian Hammond <chipx86@chipx86.com>
parents:
6291
diff
changeset
|
612 if (account != NULL && gaim_account_is_connected(account)) |
6399
d726a36628e8
[gaim-migrate @ 6904]
Christian Hammond <chipx86@chipx86.com>
parents:
6398
diff
changeset
|
613 gaim_gtk_request_add_block(account, gaim_conversation_get_name(conv)); |
4359 | 614 |
615 gtk_widget_grab_focus(GAIM_GTK_CONVERSATION(conv)->entry); | |
616 } | |
617 | |
618 static void | |
9468 | 619 send_file_cb(GtkWidget *widget, GaimConversation *conv) |
620 { | |
621 serv_send_file(gaim_conversation_get_gc(conv), gaim_conversation_get_name(conv), NULL); | |
622 } | |
623 | |
624 static void | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
625 do_invite(GtkWidget *w, int resp, InviteBuddyInfo *info) |
4359 | 626 { |
627 const char *buddy, *message; | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
628 GaimGtkConversation *gtkconv; |
4359 | 629 |
630 gtkconv = GAIM_GTK_CONVERSATION(info->conv); | |
631 | |
632 if (resp == GTK_RESPONSE_OK) { | |
633 buddy = gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(info->entry)->entry)); | |
634 message = gtk_entry_get_text(GTK_ENTRY(info->message)); | |
635 | |
4793 | 636 if (!g_ascii_strcasecmp(buddy, "")) { |
4359 | 637 g_free(info); |
638 | |
639 return; | |
640 } | |
641 | |
642 serv_chat_invite(gaim_conversation_get_gc(info->conv), | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
643 gaim_conv_chat_get_id(GAIM_CONV_CHAT(info->conv)), |
4359 | 644 message, buddy); |
645 } | |
646 | |
647 gtk_widget_destroy(invite_dialog); | |
648 invite_dialog = NULL; | |
649 | |
650 g_free(info); | |
651 } | |
652 | |
653 static void | |
9909 | 654 invite_dnd_recv(GtkWidget *widget, GdkDragContext *dc, gint x, gint y, |
655 GtkSelectionData *sd, guint inf, guint t, gpointer data) | |
656 { | |
657 InviteBuddyInfo *info = (InviteBuddyInfo *)data; | |
658 const char *convprotocol; | |
659 | |
660 convprotocol = gaim_account_get_protocol_id(gaim_conversation_get_account(info->conv)); | |
661 | |
662 if (sd->target == gdk_atom_intern("GAIM_BLIST_NODE", FALSE)) | |
663 { | |
664 GaimBlistNode *node = NULL; | |
665 GaimBuddy *buddy; | |
666 | |
667 memcpy(&node, sd->data, sizeof(node)); | |
668 | |
669 if (GAIM_BLIST_NODE_IS_CONTACT(node)) | |
670 buddy = gaim_contact_get_priority_buddy((GaimContact *)node); | |
671 else if (GAIM_BLIST_NODE_IS_BUDDY(node)) | |
672 buddy = (GaimBuddy *)node; | |
673 else | |
674 return; | |
675 | |
676 if (strcmp(convprotocol, gaim_account_get_protocol_id(buddy->account))) | |
677 { | |
678 gaim_notify_error(NULL, NULL, | |
679 _("That buddy is not on the same protocol as this " | |
680 "chat"), NULL); | |
681 } | |
682 else | |
683 gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(info->entry)->entry), buddy->name); | |
684 | |
685 gtk_drag_finish(dc, TRUE, (dc->action == GDK_ACTION_MOVE), t); | |
686 } | |
687 else if (sd->target == gdk_atom_intern("application/x-im-contact", FALSE)) | |
688 { | |
689 char *protocol = NULL; | |
690 char *username = NULL; | |
691 GaimAccount *account; | |
692 | |
693 if (gaim_gtk_parse_x_im_contact(sd->data, FALSE, &account, | |
694 &protocol, &username, NULL)) | |
695 { | |
696 if (account == NULL) | |
697 { | |
698 gaim_notify_error(NULL, NULL, | |
699 _("You are not currently signed on with an account that " | |
700 "can invite that buddy."), NULL); | |
701 } | |
702 else if (strcmp(convprotocol, gaim_account_get_protocol_id(account))) | |
703 { | |
704 gaim_notify_error(NULL, NULL, | |
705 _("That buddy is not on the same protocol as this " | |
706 "chat"), NULL); | |
707 } | |
708 else | |
709 { | |
710 gtk_entry_set_text(GTK_ENTRY(GTK_COMBO(info->entry)->entry), username); | |
711 } | |
712 } | |
713 | |
714 if (username != NULL) g_free(username); | |
715 if (protocol != NULL) g_free(protocol); | |
716 | |
717 gtk_drag_finish(dc, TRUE, (dc->action == GDK_ACTION_MOVE), t); | |
718 } | |
719 } | |
720 | |
721 static const GtkTargetEntry dnd_targets[] = | |
722 { | |
723 {"GAIM_BLIST_NODE", GTK_TARGET_SAME_APP, 0}, | |
724 {"application/x-im-contact", 0, 1} | |
725 }; | |
726 | |
727 static void | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
728 invite_cb(GtkWidget *widget, GaimConversation *conv) |
4359 | 729 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
730 InviteBuddyInfo *info = NULL; |
4359 | 731 |
732 if (invite_dialog == NULL) { | |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
733 GaimConnection *gc; |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
734 GaimConvWindow *win; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
735 GaimGtkWindow *gtkwin; |
4359 | 736 GtkWidget *label; |
737 GtkWidget *vbox, *hbox; | |
738 GtkWidget *table; | |
739 GtkWidget *img; | |
740 | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
741 img = gtk_image_new_from_stock(GAIM_STOCK_DIALOG_QUESTION, |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
742 GTK_ICON_SIZE_DIALOG); |
4359 | 743 |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
744 info = g_new0(InviteBuddyInfo, 1); |
4359 | 745 info->conv = conv; |
746 | |
747 gc = gaim_conversation_get_gc(conv); | |
748 win = gaim_conversation_get_window(conv); | |
749 gtkwin = GAIM_GTK_WINDOW(win); | |
750 | |
751 /* Create the new dialog. */ | |
752 invite_dialog = gtk_dialog_new_with_buttons( | |
7859 | 753 _("Invite Buddy Into Chat Room"), |
7879 | 754 GTK_WINDOW(gtkwin->window), 0, |
755 GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, | |
9443
3584cdab1d0b
[gaim-migrate @ 10264]
Christian Hammond <chipx86@chipx86.com>
parents:
9374
diff
changeset
|
756 GAIM_STOCK_INVITE, GTK_RESPONSE_OK, NULL); |
4359 | 757 |
758 gtk_dialog_set_default_response(GTK_DIALOG(invite_dialog), | |
759 GTK_RESPONSE_OK); | |
760 gtk_container_set_border_width(GTK_CONTAINER(invite_dialog), 6); | |
761 gtk_window_set_resizable(GTK_WINDOW(invite_dialog), FALSE); | |
762 gtk_dialog_set_has_separator(GTK_DIALOG(invite_dialog), FALSE); | |
763 | |
9909 | 764 info->window = GTK_WIDGET(invite_dialog); |
765 | |
4359 | 766 /* Setup the outside spacing. */ |
767 vbox = GTK_DIALOG(invite_dialog)->vbox; | |
768 | |
769 gtk_box_set_spacing(GTK_BOX(vbox), 12); | |
770 gtk_container_set_border_width(GTK_CONTAINER(vbox), 6); | |
771 | |
772 /* Setup the inner hbox and put the dialog's icon in it. */ | |
773 hbox = gtk_hbox_new(FALSE, 12); | |
774 gtk_container_add(GTK_CONTAINER(vbox), hbox); | |
775 gtk_box_pack_start(GTK_BOX(hbox), img, FALSE, FALSE, 0); | |
776 gtk_misc_set_alignment(GTK_MISC(img), 0, 0); | |
777 | |
778 /* Setup the right vbox. */ | |
779 vbox = gtk_vbox_new(FALSE, 0); | |
780 gtk_container_add(GTK_CONTAINER(hbox), vbox); | |
781 | |
782 /* Put our happy label in it. */ | |
783 label = gtk_label_new(_("Please enter the name of the user you wish " | |
784 "to invite, along with an optional invite " | |
785 "message.")); | |
786 gtk_widget_set_size_request(label, 350, -1); | |
787 gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); | |
788 gtk_misc_set_alignment(GTK_MISC(label), 0, 0); | |
789 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); | |
790 | |
791 /* hbox for the table, and to give it some spacing on the left. */ | |
792 hbox = gtk_hbox_new(FALSE, 6); | |
793 gtk_container_add(GTK_CONTAINER(vbox), hbox); | |
794 | |
795 /* Setup the table we're going to use to lay stuff out. */ | |
796 table = gtk_table_new(2, 2, FALSE); | |
797 gtk_table_set_row_spacings(GTK_TABLE(table), 6); | |
798 gtk_table_set_col_spacings(GTK_TABLE(table), 6); | |
799 gtk_container_set_border_width(GTK_CONTAINER(table), 12); | |
800 gtk_box_pack_start(GTK_BOX(vbox), table, FALSE, FALSE, 0); | |
801 | |
802 /* Now the Buddy label */ | |
803 label = gtk_label_new(NULL); | |
804 gtk_label_set_markup_with_mnemonic(GTK_LABEL(label), _("_Buddy:")); | |
805 gtk_misc_set_alignment(GTK_MISC(label), 0, 0); | |
806 gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 0, 1); | |
807 | |
808 /* Now the Buddy drop-down entry field. */ | |
809 info->entry = gtk_combo_new(); | |
810 gtk_combo_set_case_sensitive(GTK_COMBO(info->entry), FALSE); | |
811 gtk_entry_set_activates_default( | |
812 GTK_ENTRY(GTK_COMBO(info->entry)->entry), TRUE); | |
813 | |
814 gtk_table_attach_defaults(GTK_TABLE(table), info->entry, 1, 2, 0, 1); | |
815 gtk_label_set_mnemonic_widget(GTK_LABEL(label), info->entry); | |
816 | |
817 /* Fill in the names. */ | |
818 gtk_combo_set_popdown_strings(GTK_COMBO(info->entry), | |
819 generate_invite_user_names(gc)); | |
820 | |
821 | |
822 /* Now the label for "Message" */ | |
823 label = gtk_label_new(NULL); | |
824 gtk_label_set_markup_with_mnemonic(GTK_LABEL(label), _("_Message:")); | |
825 gtk_misc_set_alignment(GTK_MISC(label), 0, 0); | |
826 gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 1, 2); | |
827 | |
828 | |
829 /* And finally, the Message entry field. */ | |
830 info->message = gtk_entry_new(); | |
831 gtk_entry_set_activates_default(GTK_ENTRY(info->message), TRUE); | |
832 | |
833 gtk_table_attach_defaults(GTK_TABLE(table), info->message, 1, 2, 1, 2); | |
834 gtk_label_set_mnemonic_widget(GTK_LABEL(label), info->message); | |
835 | |
836 /* Connect the signals. */ | |
837 g_signal_connect(G_OBJECT(invite_dialog), "response", | |
838 G_CALLBACK(do_invite), info); | |
9909 | 839 /* Setup drag-and-drop */ |
840 gtk_drag_dest_set(info->window, | |
841 GTK_DEST_DEFAULT_MOTION | | |
842 GTK_DEST_DEFAULT_DROP, | |
843 dnd_targets, | |
844 sizeof(dnd_targets) / sizeof(GtkTargetEntry), | |
845 GDK_ACTION_COPY); | |
846 gtk_drag_dest_set(info->entry, | |
847 GTK_DEST_DEFAULT_MOTION | | |
848 GTK_DEST_DEFAULT_DROP, | |
849 dnd_targets, | |
850 sizeof(dnd_targets) / sizeof(GtkTargetEntry), | |
851 GDK_ACTION_COPY); | |
852 | |
853 g_signal_connect(G_OBJECT(info->window), "drag_data_received", | |
854 G_CALLBACK(invite_dnd_recv), info); | |
855 g_signal_connect(G_OBJECT(info->entry), "drag_data_received", | |
856 G_CALLBACK(invite_dnd_recv), info); | |
857 | |
4359 | 858 } |
859 | |
860 gtk_widget_show_all(invite_dialog); | |
861 | |
862 if (info != NULL) | |
863 gtk_widget_grab_focus(GTK_COMBO(info->entry)->entry); | |
864 } | |
865 | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
866 static void |
7748 | 867 menu_new_conv_cb(gpointer data, guint action, GtkWidget *widget) |
868 { | |
9714 | 869 gaim_gtkdialogs_im(); |
7748 | 870 } |
871 | |
872 static void | |
9504 | 873 savelog_writefile_cb(void *user_data, const char *filename) |
9489 | 874 { |
9504 | 875 GaimConversation *conv = (GaimConversation *)user_data; |
9489 | 876 FILE *fp; |
877 const char *name; | |
878 | |
879 if ((fp = fopen(filename, "w+")) == NULL) { | |
9504 | 880 gaim_notify_error(conv, NULL, _("Unable to open file."), NULL); |
9489 | 881 return; |
882 } | |
883 | |
884 name = gaim_conversation_get_name(conv); | |
885 fprintf(fp, _("<h1>Conversation with %s</h1>\n"), name); | |
886 fprintf(fp, "%s", conv->history->str); | |
887 fclose(fp); | |
888 } | |
889 | |
890 static void | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
891 menu_save_as_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
892 { |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
893 GaimConvWindow *win = (GaimConvWindow *)data; |
9489 | 894 GaimConversation *conv = gaim_conv_window_get_active_conversation(win); |
895 gchar *buf; | |
896 | |
897 buf = g_strdup_printf("%s.html", gaim_normalize(conv->account, conv->name)); | |
9504 | 898 |
899 gaim_request_file(conv, _("Save Conversation"), buf, TRUE, | |
900 G_CALLBACK(savelog_writefile_cb), NULL, conv); | |
9489 | 901 |
902 g_free(buf); | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
903 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
904 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
905 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
906 menu_view_log_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
907 { |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
908 GaimConvWindow *win = (GaimConvWindow *)data; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
909 GaimConversation *conv; |
9917 | 910 GaimLogType type; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
911 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
912 conv = gaim_conv_window_get_active_conversation(win); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
913 |
9917 | 914 if (gaim_conversation_get_type(conv) == GAIM_CONV_IM) |
915 type = GAIM_LOG_IM; | |
916 else if (gaim_conversation_get_type(conv) == GAIM_CONV_CHAT) | |
917 type = GAIM_LOG_CHAT; | |
918 else | |
919 return; | |
920 | |
921 gaim_gtk_log_show(type, gaim_conversation_get_name(conv), | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
922 gaim_conversation_get_account(conv)); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
923 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
924 |
8974 | 925 static void |
926 menu_clear_cb(gpointer data, guint action, GtkWidget *widget) | |
927 { | |
928 GaimConvWindow *win = (GaimConvWindow *)data; | |
929 GaimConversation *conv; | |
930 GaimGtkConversation *gtkconv; | |
931 | |
932 conv = gaim_conv_window_get_active_conversation(win); | |
933 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
934 | |
935 gtk_imhtml_clear(GTK_IMHTML(gtkconv->imhtml)); | |
936 g_string_free(conv->history, TRUE); | |
937 conv->history = g_string_new(""); | |
938 } | |
939 | |
7295 | 940 struct _search { |
941 GaimGtkConversation *gtkconv; | |
942 GtkWidget *entry; | |
943 }; | |
944 | |
7929 | 945 static void do_search_cb(GtkWidget *widget, gint resp, struct _search *s) |
7295 | 946 { |
7929 | 947 switch (resp) { |
948 case GTK_RESPONSE_OK: | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
949 gtk_imhtml_search_find(GTK_IMHTML(s->gtkconv->imhtml), |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
950 gtk_entry_get_text(GTK_ENTRY(s->entry))); |
7929 | 951 break; |
952 | |
953 case GTK_RESPONSE_DELETE_EVENT: | |
954 case GTK_RESPONSE_CLOSE: | |
955 gtk_imhtml_search_clear(GTK_IMHTML(s->gtkconv->imhtml)); | |
956 gtk_widget_destroy(s->gtkconv->dialogs.search); | |
957 s->gtkconv->dialogs.search = NULL; | |
958 g_free(s); | |
959 break; | |
960 } | |
7295 | 961 } |
962 | |
963 static void | |
7751 | 964 menu_find_cb(gpointer data, guint action, GtkWidget *widget) |
7295 | 965 { |
966 GaimConvWindow *win = (GaimConvWindow *)data; | |
967 GaimConversation *conv = gaim_conv_window_get_active_conversation(win); | |
968 GaimGtkWindow *gtkwin = GAIM_GTK_WINDOW(win); | |
969 GaimGtkConversation *gtkconv = GAIM_GTK_CONVERSATION(conv); | |
7929 | 970 GtkWidget *hbox; |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
971 GtkWidget *img = gtk_image_new_from_stock(GAIM_STOCK_DIALOG_QUESTION, |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
972 GTK_ICON_SIZE_DIALOG); |
7929 | 973 GtkWidget *label; |
7295 | 974 struct _search *s; |
975 | |
7798 | 976 if (gtkconv->dialogs.search) { |
977 gtk_window_present(GTK_WINDOW(gtkconv->dialogs.search)); | |
7295 | 978 return; |
7798 | 979 } |
7300
41bbe5534441
[gaim-migrate @ 7884]
Christian Hammond <chipx86@chipx86.com>
parents:
7298
diff
changeset
|
980 |
7295 | 981 s = g_malloc(sizeof(struct _search)); |
982 s->gtkconv = gtkconv; | |
7929 | 983 |
984 gtkconv->dialogs.search = gtk_dialog_new_with_buttons(_("Find"), | |
985 GTK_WINDOW(gtkwin->window), GTK_DIALOG_DESTROY_WITH_PARENT, | |
986 GTK_STOCK_CLOSE, GTK_RESPONSE_CLOSE, | |
987 GTK_STOCK_FIND, GTK_RESPONSE_OK, NULL); | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
988 gtk_dialog_set_default_response(GTK_DIALOG(gtkconv->dialogs.search), |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
989 GTK_RESPONSE_OK); |
7929 | 990 g_signal_connect(G_OBJECT(gtkconv->dialogs.search), "response", |
991 G_CALLBACK(do_search_cb), s); | |
992 | |
993 gtk_container_set_border_width(GTK_CONTAINER(gtkconv->dialogs.search), 6); | |
994 gtk_window_set_resizable(GTK_WINDOW(gtkconv->dialogs.search), FALSE); | |
995 gtk_dialog_set_has_separator(GTK_DIALOG(gtkconv->dialogs.search), FALSE); | |
996 gtk_box_set_spacing(GTK_BOX(GTK_DIALOG(gtkconv->dialogs.search)->vbox), 12); | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
997 gtk_container_set_border_width( |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
998 GTK_CONTAINER(GTK_DIALOG(gtkconv->dialogs.search)->vbox), 6); |
7929 | 999 |
1000 hbox = gtk_hbox_new(FALSE, 12); | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1001 gtk_container_add(GTK_CONTAINER(GTK_DIALOG(gtkconv->dialogs.search)->vbox), |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1002 hbox); |
7929 | 1003 gtk_box_pack_start(GTK_BOX(hbox), img, FALSE, FALSE, 0); |
1004 | |
1005 gtk_misc_set_alignment(GTK_MISC(img), 0, 0); | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1006 gtk_dialog_set_response_sensitive(GTK_DIALOG(gtkconv->dialogs.search), |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1007 GTK_RESPONSE_OK, FALSE); |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1008 |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1009 label = gtk_label_new(NULL); |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1010 gtk_label_set_markup_with_mnemonic(GTK_LABEL(label), _("_Search for:")); |
7929 | 1011 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); |
1012 | |
1013 s->entry = gtk_entry_new(); | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1014 gtk_entry_set_activates_default(GTK_ENTRY(s->entry), TRUE); |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1015 gtk_label_set_mnemonic_widget(GTK_LABEL(label), GTK_WIDGET(s->entry)); |
7929 | 1016 g_signal_connect(G_OBJECT(s->entry), "changed", |
1017 G_CALLBACK(gaim_gtk_set_sensitive_if_input), | |
1018 gtkconv->dialogs.search); | |
1019 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
|
1020 |
7295 | 1021 gtk_widget_show_all(gtkconv->dialogs.search); |
7929 | 1022 gtk_widget_grab_focus(s->entry); |
7295 | 1023 } |
1024 | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1025 static void |
9468 | 1026 menu_send_file_cb(gpointer data, guint action, GtkWidget *widget) |
1027 { | |
1028 GaimConvWindow *win = (GaimConvWindow *)data; | |
1029 GaimConversation *conv = gaim_conv_window_get_active_conversation(win); | |
1030 | |
1031 if (gaim_conversation_get_type(conv) == GAIM_CONV_IM) { | |
1032 serv_send_file(gaim_conversation_get_gc(conv), gaim_conversation_get_name(conv), NULL); | |
1033 } | |
1034 | |
1035 } | |
1036 | |
1037 static void | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1038 menu_add_pounce_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1039 { |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1040 GaimConvWindow *win = (GaimConvWindow *)data; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1041 GaimConversation *conv; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1042 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1043 conv = gaim_conv_window_get_active_conversation(win); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1044 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1045 gaim_gtkpounce_dialog_show(gaim_conversation_get_account(conv), |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1046 gaim_conversation_get_name(conv), NULL); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1047 } |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1048 |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1049 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1050 menu_insert_link_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1051 { |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1052 GaimConvWindow *win = (GaimConvWindow *)data; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1053 GaimConversation *conv; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1054 GaimGtkConversation *gtkconv; |
8756 | 1055 GtkIMHtmlToolbar *toolbar; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1056 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1057 conv = gaim_conv_window_get_active_conversation(win); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1058 gtkconv = GAIM_GTK_CONVERSATION(conv); |
8756 | 1059 toolbar = GTK_IMHTMLTOOLBAR(gtkconv->toolbar); |
1060 | |
1061 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toolbar->link), | |
1062 !gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(toolbar->link))); | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1063 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1064 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1065 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1066 menu_insert_image_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1067 { |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1068 GaimConvWindow *win = (GaimConvWindow *)data; |
8756 | 1069 GaimConversation *conv; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1070 GaimGtkConversation *gtkconv; |
8756 | 1071 GtkIMHtmlToolbar *toolbar; |
1072 | |
1073 conv = gaim_conv_window_get_active_conversation(win); | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1074 gtkconv = GAIM_GTK_CONVERSATION(gaim_conv_window_get_active_conversation(win)); |
8756 | 1075 toolbar = GTK_IMHTMLTOOLBAR(gtkconv->toolbar); |
1076 | |
1077 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(toolbar->image), | |
1078 !gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(toolbar->image))); | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1079 } |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1080 |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1081 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1082 menu_alias_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1083 { |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1084 GaimConvWindow *win = (GaimConvWindow *)data; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1085 GaimConversation *conv; |
7879 | 1086 GaimAccount *account; |
1087 const char *name; | |
1088 | |
1089 conv = gaim_conv_window_get_active_conversation(win); | |
1090 account = gaim_conversation_get_account(conv); | |
1091 name = gaim_conversation_get_name(conv); | |
1092 | |
1093 if (gaim_conversation_get_type(conv) == GAIM_CONV_IM) { | |
1094 GaimBuddy *b; | |
1095 | |
1096 b = gaim_find_buddy(account, name); | |
1097 if (b != NULL) | |
9730 | 1098 gaim_gtkdialogs_alias_buddy(b); |
7879 | 1099 } else if (gaim_conversation_get_type(conv) == GAIM_CONV_CHAT) { |
1100 GaimChat *c; | |
1101 | |
1102 c = gaim_blist_find_chat(account, name); | |
1103 if (c != NULL) | |
9730 | 1104 gaim_gtkdialogs_alias_chat(c); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1105 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1106 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1107 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1108 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1109 menu_get_info_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1110 { |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1111 GaimConvWindow *win = (GaimConvWindow *)data; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1112 GaimConversation *conv; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1113 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1114 conv = gaim_conv_window_get_active_conversation(win); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1115 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1116 info_cb(NULL, conv); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1117 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1118 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1119 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1120 menu_invite_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1121 { |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1122 GaimConvWindow *win = (GaimConvWindow *)data; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1123 GaimConversation *conv; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1124 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1125 conv = gaim_conv_window_get_active_conversation(win); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1126 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1127 invite_cb(NULL, conv); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1128 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1129 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1130 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1131 menu_warn_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1132 { |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1133 GaimConvWindow *win = (GaimConvWindow *)data; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1134 GaimConversation *conv; |
10025 | 1135 GaimConnection *gc; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1136 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1137 conv = gaim_conv_window_get_active_conversation(win); |
10025 | 1138 gc = gaim_conversation_get_gc(conv); |
1139 | |
1140 gaim_gtkdialogs_warn(gc, gaim_conversation_get_name(conv)); | |
1141 | |
1142 gtk_widget_grab_focus(GAIM_GTK_CONVERSATION(conv)->entry); | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1143 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1144 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1145 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1146 menu_block_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1147 { |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1148 GaimConvWindow *win = (GaimConvWindow *)data; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1149 GaimConversation *conv; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1150 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1151 conv = gaim_conv_window_get_active_conversation(win); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1152 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1153 block_cb(NULL, conv); |
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_add_remove_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1158 { |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1159 GaimConvWindow *win = (GaimConvWindow *)data; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1160 GaimConversation *conv; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1161 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1162 conv = gaim_conv_window_get_active_conversation(win); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1163 |
7928 | 1164 add_remove_cb(NULL, conv); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1165 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1166 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1167 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1168 menu_close_conv_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1169 { |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1170 GaimConvWindow *win = (GaimConvWindow *)data; |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1171 |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1172 close_conv_cb(NULL, gaim_conv_window_get_active_conversation(win)); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1173 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1174 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1175 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1176 menu_logging_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1177 { |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1178 GaimConvWindow *win = (GaimConvWindow *)data; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1179 GaimConversation *conv; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1180 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1181 conv = gaim_conv_window_get_active_conversation(win); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1182 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1183 if (conv == NULL) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1184 return; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1185 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1186 gaim_conversation_set_logging(conv, |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1187 gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(widget))); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1188 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1189 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1190 static void |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1191 menu_toolbar_cb(gpointer data, guint action, GtkWidget *widget) |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1192 { |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1193 GaimConvWindow *win = (GaimConvWindow *)data; |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1194 GaimConversation *conv; |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1195 GaimGtkConversation *gtkconv; |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1196 |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1197 conv = gaim_conv_window_get_active_conversation(win); |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1198 |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1199 if (conv == NULL) |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1200 return; |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1201 |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1202 gtkconv = GAIM_GTK_CONVERSATION(conv); |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1203 |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1204 gtkconv->show_formatting_toolbar = |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1205 gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(widget)); |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1206 |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1207 if (gtkconv->show_formatting_toolbar) |
8317 | 1208 gtk_widget_show(gtkconv->toolbar); |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1209 else |
8317 | 1210 gtk_widget_hide(gtkconv->toolbar); |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1211 } |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1212 |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
1213 static void |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1214 menu_sounds_cb(gpointer data, guint action, GtkWidget *widget) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1215 { |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1216 GaimConvWindow *win = (GaimConvWindow *)data; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1217 GaimConversation *conv; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1218 GaimGtkConversation *gtkconv; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1219 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1220 conv = gaim_conv_window_get_active_conversation(win); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1221 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1222 if (!conv) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1223 return; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1224 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1225 gtkconv = GAIM_GTK_CONVERSATION(conv); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1226 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1227 gtkconv->make_sound = |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1228 gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(widget)); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1229 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1230 |
7961 | 1231 static void |
9188 | 1232 menu_timestamps_cb(gpointer data, guint action, GtkWidget *widget) |
1233 { | |
1234 GaimConvWindow *win = (GaimConvWindow *)data; | |
1235 GaimConversation *conv; | |
1236 GaimGtkConversation *gtkconv; | |
1237 | |
1238 conv = gaim_conv_window_get_active_conversation(win); | |
1239 | |
1240 if (!conv) | |
1241 return; | |
1242 | |
1243 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
1244 | |
1245 gtkconv->show_timestamps = | |
1246 gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(widget)); | |
1247 gtk_imhtml_show_comments(GTK_IMHTML(gtkconv->imhtml), | |
1248 gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(widget))); | |
1249 } | |
1250 | |
1251 static void | |
7961 | 1252 chat_do_im(GaimConversation *conv, const char *who) |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1253 { |
7961 | 1254 GaimPluginProtocolInfo *prpl_info = NULL; |
1255 char *real_who; | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1256 GaimConversation *conv2; |
7961 | 1257 GaimAccount *account; |
1258 | |
1259 account = gaim_conversation_get_account(conv); | |
1260 | |
1261 if(account && account->gc) | |
1262 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(account->gc->prpl); | |
1263 | |
1264 if(prpl_info && prpl_info->get_cb_real_name) | |
1265 real_who = prpl_info->get_cb_real_name(account->gc, | |
1266 gaim_conv_chat_get_id(GAIM_CONV_CHAT(conv)), who); | |
1267 else | |
1268 real_who = g_strdup(who); | |
1269 | |
1270 if(!real_who) | |
1271 return; | |
1272 | |
1273 conv2 = gaim_find_conversation_with_account(real_who, account); | |
1274 | |
1275 if (conv2 != NULL) | |
1276 gaim_conv_window_show(gaim_conversation_get_window(conv2)); | |
1277 else | |
1278 conv2 = gaim_conversation_new(GAIM_CONV_IM, account, real_who); | |
1279 | |
1280 g_free(real_who); | |
1281 } | |
1282 | |
1283 | |
1284 static void | |
1285 chat_im_button_cb(GtkWidget *widget, GaimConversation *conv) | |
1286 { | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1287 GaimGtkConversation *gtkconv; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1288 GaimGtkChatPane *gtkchat; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1289 GtkTreeIter iter; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1290 GtkTreeModel *model; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1291 GtkTreeSelection *sel; |
9554 | 1292 char *name; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1293 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1294 gtkconv = GAIM_GTK_CONVERSATION(conv); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1295 gtkchat = gtkconv->u.chat; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1296 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1297 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1298 sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(gtkchat->list)); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1299 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1300 if (gtk_tree_selection_get_selected(sel, NULL, &iter)) |
9498 | 1301 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
|
1302 else |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1303 return; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1304 |
7961 | 1305 chat_do_im(conv, name); |
9554 | 1306 g_free(name); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1307 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1308 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1309 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1310 ignore_cb(GtkWidget *w, GaimConversation *conv) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1311 { |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1312 GaimGtkConversation *gtkconv; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1313 GaimGtkChatPane *gtkchat; |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1314 GaimConvChat *chat; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1315 GtkTreeIter iter; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1316 GtkTreeModel *model; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1317 GtkTreeSelection *sel; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1318 const char *name; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1319 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1320 chat = GAIM_CONV_CHAT(conv); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1321 gtkconv = GAIM_GTK_CONVERSATION(conv); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1322 gtkchat = gtkconv->u.chat; |
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 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1325 sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(gtkchat->list)); |
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 if (gtk_tree_selection_get_selected(sel, NULL, &iter)) { |
9498 | 1328 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
|
1329 gtk_list_store_remove(GTK_LIST_STORE(model), &iter); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1330 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1331 else |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1332 return; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1333 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1334 if (gaim_conv_chat_is_user_ignored(chat, name)) |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1335 gaim_conv_chat_unignore(chat, name); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1336 else |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1337 gaim_conv_chat_ignore(chat, name); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1338 |
9554 | 1339 add_chat_buddy_common(conv, name); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1340 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1341 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1342 static void |
7398 | 1343 menu_chat_im_cb(GtkWidget *w, GaimConversation *conv) |
1344 { | |
1345 const char *who = g_object_get_data(G_OBJECT(w), "user_data"); | |
1346 | |
1347 chat_do_im(conv, who); | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1348 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1349 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1350 static void |
9468 | 1351 menu_chat_send_file_cb(GtkWidget *w, GaimConversation *conv) |
1352 { | |
1353 const char *who = g_object_get_data(G_OBJECT(w), "user_data"); | |
1354 GaimConnection *gc = gaim_conversation_get_gc(conv); | |
1355 | |
1356 serv_send_file(gc, who, NULL); | |
1357 } | |
1358 | |
1359 static void | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1360 menu_chat_info_cb(GtkWidget *w, GaimConversation *conv) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1361 { |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1362 char *who; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1363 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1364 who = g_object_get_data(G_OBJECT(w), "user_data"); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1365 |
7975 | 1366 chat_do_info(conv, who); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1367 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1368 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1369 static void |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1370 menu_chat_get_away_cb(GtkWidget *w, GaimConversation *conv) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1371 { |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1372 GaimPluginProtocolInfo *prpl_info = NULL; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1373 GaimConnection *gc; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1374 char *who; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1375 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1376 gc = gaim_conversation_get_gc(conv); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1377 who = g_object_get_data(G_OBJECT(w), "user_data"); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1378 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1379 if (gc != NULL) { |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1380 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1381 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1382 /* |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1383 * 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
|
1384 */ |
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 if (prpl_info->get_cb_away != NULL) |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1387 { |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1388 prpl_info->get_cb_away(gc, |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1389 gaim_conv_chat_get_id(GAIM_CONV_CHAT(conv)), who); |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1390 } |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1391 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1392 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1393 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1394 static void |
7928 | 1395 menu_chat_add_remove_cb(GtkWidget *w, GaimConversation *conv) |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1396 { |
7060
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
1397 GaimAccount *account; |
6695 | 1398 GaimBuddy *b; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1399 char *name; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1400 |
7060
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
1401 account = gaim_conversation_get_account(conv); |
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
1402 name = g_object_get_data(G_OBJECT(w), "user_data"); |
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
1403 b = gaim_find_buddy(account, name); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1404 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1405 if (b != NULL) |
9730 | 1406 gaim_gtkdialogs_remove_buddy(b); |
7060
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
1407 else if (account != NULL && gaim_account_is_connected(account)) |
9946001989a3
[gaim-migrate @ 7623]
Christian Hammond <chipx86@chipx86.com>
parents:
7035
diff
changeset
|
1408 gaim_blist_request_add_buddy(account, name, NULL, NULL); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1409 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1410 gtk_widget_grab_focus(GAIM_GTK_CONVERSATION(conv)->entry); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1411 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1412 |
8143 | 1413 static GtkWidget * |
1414 create_chat_menu(GaimConversation *conv, gchar *who, | |
1415 GaimPluginProtocolInfo *prpl_info, GaimConnection *gc) | |
1416 { | |
1417 static GtkWidget *menu = NULL; | |
1418 GtkWidget *button; | |
1419 | |
1420 /* | |
1421 * If a menu already exists, destroy it before creating a new one, | |
1422 * thus freeing-up the memory it occupied. | |
1423 */ | |
1424 if (menu) | |
1425 gtk_widget_destroy(menu); | |
1426 | |
1427 menu = gtk_menu_new(); | |
1428 | |
1429 button = gtk_menu_item_new_with_label(_("IM")); | |
1430 g_signal_connect(G_OBJECT(button), "activate", | |
1431 G_CALLBACK(menu_chat_im_cb), conv); | |
1432 g_object_set_data(G_OBJECT(button), "user_data", who); | |
1433 gtk_menu_shell_append(GTK_MENU_SHELL(menu), button); | |
1434 gtk_widget_show(button); | |
1435 | |
9468 | 1436 if (gc && prpl_info && prpl_info->send_file |
1437 && (!prpl_info->can_receive_file || prpl_info->can_receive_file(gc, who))) { | |
1438 button = gtk_menu_item_new_with_label(_("Send File")); | |
1439 g_signal_connect(G_OBJECT(button), "activate", | |
1440 G_CALLBACK(menu_chat_send_file_cb), conv); | |
1441 g_object_set_data(G_OBJECT(button), "user_data", who); | |
1442 gtk_menu_shell_append(GTK_MENU_SHELL(menu), button); | |
1443 gtk_widget_show(button); | |
1444 } | |
9498 | 1445 |
8143 | 1446 if (gaim_conv_chat_is_user_ignored(GAIM_CONV_CHAT(conv), who)) |
1447 button = gtk_menu_item_new_with_label(_("Un-Ignore")); | |
1448 else | |
1449 button = gtk_menu_item_new_with_label(_("Ignore")); | |
1450 | |
1451 g_signal_connect(G_OBJECT(button), "activate", | |
1452 G_CALLBACK(ignore_cb), conv); | |
1453 g_object_set_data(G_OBJECT(button), "user_data", who); | |
1454 gtk_menu_shell_append(GTK_MENU_SHELL(menu), button); | |
1455 gtk_widget_show(button); | |
1456 | |
8170 | 1457 if (gc && (prpl_info->get_info || prpl_info->get_cb_info)) { |
8143 | 1458 button = gtk_menu_item_new_with_label(_("Info")); |
1459 g_signal_connect(G_OBJECT(button), "activate", | |
1460 G_CALLBACK(menu_chat_info_cb), conv); | |
1461 g_object_set_data(G_OBJECT(button), "user_data", who); | |
1462 gtk_menu_shell_append(GTK_MENU_SHELL(menu), button); | |
1463 gtk_widget_show(button); | |
1464 } | |
1465 | |
1466 if (gc && prpl_info->get_cb_away) { | |
1467 button = gtk_menu_item_new_with_label(_("Get Away Msg")); | |
1468 g_signal_connect(G_OBJECT(button), "activate", | |
1469 G_CALLBACK(menu_chat_get_away_cb), conv); | |
1470 g_object_set_data(G_OBJECT(button), "user_data", who); | |
1471 gtk_menu_shell_append(GTK_MENU_SHELL(menu), button); | |
1472 gtk_widget_show(button); | |
1473 } | |
1474 | |
8170 | 1475 /* XXX: jabber can only add buddies from here in certain circumstances */ |
8143 | 1476 /* Added by Jonas <jonas@birme.se> */ |
1477 if (gc) { | |
1478 if (gaim_find_buddy(gc->account, who)) | |
1479 button = gtk_menu_item_new_with_label(_("Remove")); | |
1480 else | |
1481 button = gtk_menu_item_new_with_label(_("Add")); | |
1482 | |
1483 g_signal_connect(G_OBJECT(button), "activate", | |
1484 G_CALLBACK(menu_chat_add_remove_cb), conv); | |
1485 | |
1486 g_object_set_data(G_OBJECT(button), "user_data", who); | |
1487 gtk_menu_shell_append(GTK_MENU_SHELL(menu), button); | |
1488 gtk_widget_show(button); | |
1489 } | |
1490 /* End Jonas */ | |
1491 | |
1492 return menu; | |
1493 } | |
1494 | |
1495 | |
1496 static gint | |
1497 gtkconv_chat_popup_menu_cb(GtkWidget *widget, GaimConversation *conv) | |
1498 { | |
1499 GaimGtkConversation *gtkconv; | |
1500 GaimPluginProtocolInfo *prpl_info = NULL; | |
1501 GaimGtkChatPane *gtkchat; | |
1502 GaimConnection *gc; | |
1503 GaimAccount *account; | |
1504 GtkTreeSelection *sel; | |
1505 GtkTreeIter iter; | |
1506 GtkTreeModel *model; | |
1507 GtkWidget *menu; | |
1508 gchar *who; | |
1509 | |
1510 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
1511 gtkchat = gtkconv->u.chat; | |
1512 account = gaim_conversation_get_account(conv); | |
1513 gc = account->gc; | |
1514 | |
1515 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); | |
1516 | |
1517 if (gc != NULL) | |
1518 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); | |
1519 | |
1520 sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(gtkchat->list)); | |
1521 if(!gtk_tree_selection_get_selected(sel, NULL, &iter)) | |
1522 return FALSE; | |
1523 | |
9498 | 1524 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, CHAT_USERS_NAME_COLUMN, &who, -1); |
8143 | 1525 menu = create_chat_menu (conv, who, prpl_info, gc); |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1526 gtk_menu_popup(GTK_MENU(menu), NULL, NULL, |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1527 gaim_gtk_treeview_popup_menu_position_func, widget, |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1528 0, GDK_CURRENT_TIME); |
8143 | 1529 |
1530 return TRUE; | |
1531 } | |
1532 | |
1533 | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1534 static gint |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1535 right_click_chat_cb(GtkWidget *widget, GdkEventButton *event, |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1536 GaimConversation *conv) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1537 { |
8143 | 1538 GaimGtkConversation *gtkconv; |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1539 GaimPluginProtocolInfo *prpl_info = NULL; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1540 GaimGtkChatPane *gtkchat; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1541 GaimConnection *gc; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1542 GaimAccount *account; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1543 GtkTreePath *path; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1544 GtkTreeIter iter; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1545 GtkTreeModel *model; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1546 GtkTreeViewColumn *column; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1547 gchar *who; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1548 int x, y; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1549 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1550 gtkconv = GAIM_GTK_CONVERSATION(conv); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1551 gtkchat = gtkconv->u.chat; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1552 account = gaim_conversation_get_account(conv); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1553 gc = account->gc; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1554 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1555 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1556 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1557 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
|
1558 event->x, event->y, &path, &column, &x, &y); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1559 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1560 if (path == NULL) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1561 return FALSE; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1562 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1563 if (gc != NULL) |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1564 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1565 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1566 gtk_tree_selection_select_path(GTK_TREE_SELECTION( |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1567 gtk_tree_view_get_selection(GTK_TREE_VIEW(gtkchat->list))), path); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1568 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1569 gtk_tree_model_get_iter(GTK_TREE_MODEL(model), &iter, path); |
9498 | 1570 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
|
1571 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1572 if (event->button == 1 && event->type == GDK_2BUTTON_PRESS) { |
7398 | 1573 chat_do_im(conv, who); |
9554 | 1574 g_free(who); |
7398 | 1575 } else if (event->button == 3 && event->type == GDK_BUTTON_PRESS) { |
8143 | 1576 GtkWidget *menu = create_chat_menu (conv, who, prpl_info, gc); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1577 gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL, |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1578 event->button, event->time); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1579 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1580 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1581 return TRUE; |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1582 } |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
1583 |
8133 | 1584 static void |
1585 move_to_next_unread_tab(GaimConversation *conv) | |
1586 { | |
1587 GaimConversation *next_conv = NULL; | |
1588 GaimConvWindow *win; | |
1589 GList *l; | |
1590 int index, i; | |
1591 | |
1592 win = gaim_conversation_get_window(conv); | |
1593 index = gaim_conversation_get_index(conv); | |
1594 | |
1595 /* First check the tabs after this position. */ | |
1596 for (l = g_list_nth(gaim_conv_window_get_conversations(win), index); | |
1597 l != NULL; | |
1598 l = l->next) { | |
1599 | |
1600 next_conv = (GaimConversation *)l->data; | |
1601 | |
1602 if (gaim_conversation_get_unseen(next_conv) > 0) | |
1603 break; | |
1604 | |
1605 next_conv = NULL; | |
1606 } | |
1607 | |
1608 if (next_conv == NULL) { | |
1609 | |
1610 /* Now check before this position. */ | |
1611 for (l = gaim_conv_window_get_conversations(win), i = 0; | |
1612 l != NULL && i < index; | |
1613 l = l->next) { | |
1614 | |
1615 next_conv = (GaimConversation *)l->data; | |
1616 | |
1617 if (gaim_conversation_get_unseen(next_conv) > 0) | |
1618 break; | |
1619 | |
1620 next_conv = NULL; | |
1621 } | |
1622 | |
1623 if (next_conv == NULL) { | |
1624 /* Okay, just grab the next conversation tab. */ | |
1625 if (index == gaim_conv_window_get_conversation_count(win) - 1) | |
1626 next_conv = gaim_conv_window_get_conversation_at(win, 0); | |
1627 else | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1628 { |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1629 next_conv = gaim_conv_window_get_conversation_at(win, |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1630 index + 1); |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1631 } |
8133 | 1632 } |
1633 } | |
1634 | |
1635 if (next_conv != NULL && next_conv != conv) { | |
1636 gaim_conv_window_switch_conversation(win, | |
1637 gaim_conversation_get_index(next_conv)); | |
1638 } | |
1639 } | |
1640 | |
4359 | 1641 static gboolean |
8105 | 1642 entry_key_press_cb(GtkWidget *entry, GdkEventKey *event, gpointer data) |
4359 | 1643 { |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1644 GaimConvWindow *win; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
1645 GaimConversation *conv; |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
1646 GaimGtkConversation *gtkconv; |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
1647 GaimGtkWindow *gtkwin; |
8105 | 1648 int numconvs; |
1649 int curconv; | |
1650 | |
1651 conv = (GaimConversation *)data; | |
1652 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
1653 win = gaim_conversation_get_window(conv); | |
1654 gtkwin = GAIM_GTK_WINDOW(win); | |
1655 numconvs = gaim_conv_window_get_conversation_count(win); | |
1656 curconv = gaim_conversation_get_index(conv); | |
1657 | |
1658 /* If CTRL was held down... */ | |
1659 if (event->state & GDK_CONTROL_MASK) { | |
4359 | 1660 switch (event->keyval) { |
8105 | 1661 case GDK_Return: |
1662 case GDK_KP_Enter: | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1663 if (gaim_prefs_get_bool( |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1664 "/gaim/gtk/conversations/ctrl_enter_sends")) |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1665 { |
8105 | 1666 send_cb(NULL, conv); |
1667 | |
1668 return TRUE; | |
1669 } | |
1670 break; | |
1671 | |
4359 | 1672 case GDK_Up: |
1673 if (!conv->send_history) | |
1674 break; | |
1675 | |
1676 if (!conv->send_history->prev) { | |
1677 GtkTextIter start, end; | |
1678 | |
1679 if (conv->send_history->data) | |
1680 g_free(conv->send_history->data); | |
1681 | |
1682 gtk_text_buffer_get_start_iter(gtkconv->entry_buffer, | |
1683 &start); | |
1684 gtk_text_buffer_get_end_iter(gtkconv->entry_buffer, &end); | |
1685 | |
1686 conv->send_history->data = | |
8506 | 1687 gtk_imhtml_get_markup(GTK_IMHTML(gtkconv->entry)); |
4359 | 1688 } |
8677 | 1689 |
4359 | 1690 if (conv->send_history->next && |
1691 conv->send_history->next->data) { | |
8677 | 1692 GtkTextIter iter; |
1693 GtkTextBuffer *buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(gtkconv->entry)); | |
4359 | 1694 |
1695 conv->send_history = conv->send_history->next; | |
8061 | 1696 gtk_imhtml_clear(GTK_IMHTML(gtkconv->entry)); |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1697 gtk_imhtml_append_text_with_images( |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1698 GTK_IMHTML(gtkconv->entry), conv->send_history->data, |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1699 0, NULL); |
8677 | 1700 /* this is mainly just a hack so the formatting at the |
1701 * cursor gets picked up. */ | |
1702 gtk_text_buffer_get_end_iter(buffer, &iter); | |
1703 gtk_text_buffer_move_mark_by_name(buffer, "insert", &iter); | |
4359 | 1704 } |
1705 | |
8105 | 1706 return TRUE; |
4359 | 1707 break; |
1708 | |
1709 case GDK_Down: | |
1710 if (!conv->send_history) | |
1711 break; | |
1712 | |
8105 | 1713 if (conv->send_history->prev && |
1714 conv->send_history->prev->data) { | |
8677 | 1715 GtkTextIter iter; |
1716 GtkTextBuffer *buffer = gtk_text_view_get_buffer(GTK_TEXT_VIEW(gtkconv->entry)); | |
8105 | 1717 |
4359 | 1718 conv->send_history = conv->send_history->prev; |
8105 | 1719 gtk_imhtml_clear(GTK_IMHTML(gtkconv->entry)); |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1720 gtk_imhtml_append_text_with_images( |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1721 GTK_IMHTML(gtkconv->entry), conv->send_history->data, |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1722 0, NULL); |
8677 | 1723 /* this is mainly just a hack so the formatting at the |
1724 * cursor gets picked up. */ | |
1725 gtk_text_buffer_get_end_iter(buffer, &iter); | |
1726 gtk_text_buffer_move_mark_by_name(buffer, "insert", &iter); | |
4359 | 1727 } |
1728 | |
8105 | 1729 return TRUE; |
4359 | 1730 break; |
8105 | 1731 |
8108 | 1732 case GDK_Page_Down: |
8143 | 1733 case ']': |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1734 gaim_conv_window_switch_conversation(win, |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1735 (curconv + 1) % numconvs); |
8105 | 1736 |
1737 return TRUE; | |
1738 break; | |
1739 | |
8108 | 1740 case GDK_Page_Up: |
8143 | 1741 case '[': |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1742 gaim_conv_window_switch_conversation(win, |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1743 (curconv + numconvs - 1) % numconvs); |
8133 | 1744 |
1745 return TRUE; | |
1746 break; | |
1747 | |
8108 | 1748 case GDK_Tab: |
8133 | 1749 move_to_next_unread_tab(conv); |
8108 | 1750 |
1751 return TRUE; | |
1752 break; | |
1753 | |
1754 case 'z': | |
1755 gtk_window_iconify(GTK_WINDOW(gtkwin->window)); | |
8105 | 1756 |
1757 return TRUE; | |
1758 break; | |
1759 | |
1760 } /* End of switch */ | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1761 } |
8758 | 1762 |
8105 | 1763 /* If ALT (or whatever) was held down... */ |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1764 else if (event->state & GDK_MOD1_MASK) |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1765 { |
8735
92cbf9713795
[gaim-migrate @ 9490]
Christian Hammond <chipx86@chipx86.com>
parents:
8730
diff
changeset
|
1766 /* XXX - Make sure the conv exists before switching to it */ |
8105 | 1767 if (event->keyval > '0' && event->keyval <= '9') { |
1768 int switchto = event->keyval - '1'; | |
1769 if (switchto < numconvs) | |
1770 gaim_conv_window_switch_conversation(win, switchto); | |
4359 | 1771 |
1772 return TRUE; | |
1773 } | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1774 } |
8758 | 1775 |
8105 | 1776 /* If neither CTRL nor ALT were held down... */ |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1777 else |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1778 { |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1779 switch (event->keyval) |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1780 { |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1781 case GDK_Return: |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1782 case GDK_KP_Enter: |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1783 if (!(event->state & (GDK_SHIFT_MASK | GDK_CONTROL_MASK)) && |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1784 gaim_prefs_get_bool("/gaim/gtk/conversations/enter_sends")) |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1785 { |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1786 send_cb(NULL, conv); |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1787 return TRUE; |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1788 } |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1789 break; |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1790 |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1791 case GDK_Tab: |
9605 | 1792 return tab_complete(conv); |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1793 break; |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1794 |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1795 case GDK_Page_Up: |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1796 gtk_imhtml_page_up(GTK_IMHTML(gtkconv->imhtml)); |
8105 | 1797 return TRUE; |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1798 break; |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1799 |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1800 case GDK_Page_Down: |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1801 gtk_imhtml_page_down(GTK_IMHTML(gtkconv->imhtml)); |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1802 return TRUE; |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1803 break; |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1804 |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1805 } |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
1806 } |
4359 | 1807 return FALSE; |
1808 } | |
1809 | |
1810 /* | |
1811 * NOTE: | |
6725
e62a504c83d0
[gaim-migrate @ 7252]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
1812 * 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
|
1813 * further. I have no idea *why* we need this, but we do ... It |
4359 | 1814 * 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
|
1815 * going all the way down to the notebook. I suspect a bug in |
4359 | 1816 * GtkTextView, but I'm not ready to point any fingers yet. |
1817 */ | |
1818 static gboolean | |
1819 entry_stop_rclick_cb(GtkWidget *widget, GdkEventButton *event, gpointer data) | |
1820 { | |
1821 if (event->button == 3 && event->type == GDK_BUTTON_PRESS) { | |
1822 /* Right single click */ | |
1823 g_signal_stop_emission_by_name(G_OBJECT(widget), "button_press_event"); | |
1824 | |
1825 return TRUE; | |
1826 } | |
1827 | |
1828 return FALSE; | |
1829 } | |
1830 | |
8173 | 1831 /* |
1832 * If someone tries to type into the conversation backlog of a | |
1833 * conversation window then we yank focus from the conversation backlog | |
1834 * and give it to the text entry box so that people can type | |
1835 * all the live long day and it will get entered into the entry box. | |
1836 */ | |
6057 | 1837 static gboolean |
8105 | 1838 refocus_entry_cb(GtkWidget *widget, GdkEventKey *event, gpointer data) |
6057 | 1839 { |
1840 GaimGtkConversation *gtkconv = data; | |
1841 | |
8237 | 1842 /* If we have a valid key for the conversation display, then exit */ |
8224 | 1843 if ((event->state & GDK_CONTROL_MASK) || |
8237 | 1844 (event->keyval == GDK_F10) || |
1845 (event->keyval == GDK_Shift_L) || | |
1846 (event->keyval == GDK_Shift_R) || | |
1847 (event->keyval == GDK_Escape) || | |
8177 | 1848 (event->keyval == GDK_Up) || |
1849 (event->keyval == GDK_Down) || | |
1850 (event->keyval == GDK_Left) || | |
8191 | 1851 (event->keyval == GDK_Right) || |
1852 (event->keyval == GDK_Home) || | |
9297 | 1853 (event->keyval == GDK_End) || |
1854 (event->keyval == GDK_Tab) || | |
1855 (event->keyval == GDK_ISO_Left_Tab)) | |
8177 | 1856 return FALSE; |
1857 | |
1858 if (event->type == GDK_KEY_RELEASE) | |
1859 gtk_widget_grab_focus(gtkconv->entry); | |
1860 | |
1861 gtk_widget_event(gtkconv->entry, (GdkEvent *)event); | |
1862 | |
1863 return TRUE; | |
6057 | 1864 } |
1865 | |
4359 | 1866 static void |
4673 | 1867 menu_conv_sel_send_cb(GObject *m, gpointer data) |
4359 | 1868 { |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1869 GaimConvWindow *win = g_object_get_data(m, "user_data"); |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
1870 GaimAccount *account = g_object_get_data(m, "gaim_account"); |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
1871 GaimConversation *conv; |
8456 | 1872 GaimGtkConversation *gtkconv; |
4359 | 1873 |
10059
79fafe47d919
[gaim-migrate @ 11027]
Luke Schierer <lschiere@pidgin.im>
parents:
10053
diff
changeset
|
1874 if (gtk_check_menu_item_get_active((GtkCheckMenuItem*) m) == FALSE) |
79fafe47d919
[gaim-migrate @ 11027]
Luke Schierer <lschiere@pidgin.im>
parents:
10053
diff
changeset
|
1875 return; |
79fafe47d919
[gaim-migrate @ 11027]
Luke Schierer <lschiere@pidgin.im>
parents:
10053
diff
changeset
|
1876 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1877 conv = gaim_conv_window_get_active_conversation(win); |
4359 | 1878 |
4491 | 1879 gaim_conversation_set_account(conv, account); |
8456 | 1880 |
1881 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
1882 gtk_imhtml_set_protocol_name(GTK_IMHTML(gtkconv->entry), | |
9699 | 1883 gaim_account_get_protocol_name(conv->account)); |
4359 | 1884 } |
1885 | |
1886 static void | |
1887 insert_text_cb(GtkTextBuffer *textbuffer, GtkTextIter *position, | |
1888 gchar *new_text, gint new_text_length, gpointer user_data) | |
1889 { | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
1890 GaimConversation *conv = (GaimConversation *)user_data; |
4359 | 1891 |
5678
619bca773b2e
[gaim-migrate @ 6096]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
1892 g_return_if_fail(conv != NULL); |
4359 | 1893 |
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5484
diff
changeset
|
1894 if (!gaim_prefs_get_bool("/core/conversations/im/send_typing")) |
4359 | 1895 return; |
1896 | |
1897 got_typing_keypress(conv, (gtk_text_iter_is_start(position) && | |
1898 gtk_text_iter_is_end(position))); | |
1899 } | |
1900 | |
1901 static void | |
1902 delete_text_cb(GtkTextBuffer *textbuffer, GtkTextIter *start_pos, | |
1903 GtkTextIter *end_pos, gpointer user_data) | |
1904 { | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
1905 GaimConversation *conv = (GaimConversation *)user_data; |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1906 GaimConvIm *im; |
4359 | 1907 |
5678
619bca773b2e
[gaim-migrate @ 6096]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
1908 g_return_if_fail(conv != NULL); |
4359 | 1909 |
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5484
diff
changeset
|
1910 if (!gaim_prefs_get_bool("/core/conversations/im/send_typing")) |
4359 | 1911 return; |
1912 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1913 im = GAIM_CONV_IM(conv); |
4359 | 1914 |
1915 if (gtk_text_iter_is_start(start_pos) && gtk_text_iter_is_end(end_pos)) { | |
1916 | |
1917 /* We deleted all the text, so turn off typing. */ | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1918 if (gaim_conv_im_get_type_again_timeout(im)) |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1919 gaim_conv_im_stop_type_again_timeout(im); |
4359 | 1920 |
1921 serv_send_typing(gaim_conversation_get_gc(conv), | |
6695 | 1922 gaim_conversation_get_name(conv), |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
1923 GAIM_NOT_TYPING); |
4359 | 1924 } |
1925 else { | |
1926 /* We're deleting, but not all of it, so it counts as typing. */ | |
1927 got_typing_keypress(conv, FALSE); | |
1928 } | |
1929 } | |
1930 | |
1931 static void | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
1932 notebook_init_grab(GaimGtkWindow *gtkwin, GtkWidget *widget) |
4359 | 1933 { |
1934 static GdkCursor *cursor = NULL; | |
1935 | |
1936 gtkwin->in_drag = TRUE; | |
1937 | |
1938 if (gtkwin->drag_leave_signal) { | |
1939 g_signal_handler_disconnect(G_OBJECT(widget), | |
1940 gtkwin->drag_leave_signal); | |
1941 | |
1942 gtkwin->drag_leave_signal = 0; | |
1943 } | |
1944 | |
1945 if (cursor == NULL) | |
1946 cursor = gdk_cursor_new(GDK_FLEUR); | |
1947 | |
1948 /* Grab the pointer */ | |
1949 gtk_grab_add(gtkwin->notebook); | |
5114
e245e686f62f
[gaim-migrate @ 5477]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
5106
diff
changeset
|
1950 #ifndef _WIN32 |
e245e686f62f
[gaim-migrate @ 5477]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
5106
diff
changeset
|
1951 /* Currently for win32 GTK+ (as of 2.2.1), gdk_pointer_is_grabbed will |
e245e686f62f
[gaim-migrate @ 5477]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
5106
diff
changeset
|
1952 always be true after a button press. */ |
4803
6f04901ef729
[gaim-migrate @ 5123]
Christian Hammond <chipx86@chipx86.com>
parents:
4793
diff
changeset
|
1953 if (!gdk_pointer_is_grabbed()) |
5114
e245e686f62f
[gaim-migrate @ 5477]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
5106
diff
changeset
|
1954 #endif |
4803
6f04901ef729
[gaim-migrate @ 5123]
Christian Hammond <chipx86@chipx86.com>
parents:
4793
diff
changeset
|
1955 gdk_pointer_grab(gtkwin->notebook->window, FALSE, |
6f04901ef729
[gaim-migrate @ 5123]
Christian Hammond <chipx86@chipx86.com>
parents:
4793
diff
changeset
|
1956 GDK_BUTTON1_MOTION_MASK | GDK_BUTTON_RELEASE_MASK, |
6f04901ef729
[gaim-migrate @ 5123]
Christian Hammond <chipx86@chipx86.com>
parents:
4793
diff
changeset
|
1957 NULL, cursor, GDK_CURRENT_TIME); |
4359 | 1958 } |
1959 | |
1960 static gboolean | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1961 notebook_motion_cb(GtkWidget *widget, GdkEventButton *e, GaimConvWindow *win) |
4359 | 1962 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
1963 GaimGtkWindow *gtkwin; |
4359 | 1964 |
1965 gtkwin = GAIM_GTK_WINDOW(win); | |
1966 | |
1967 /* | |
1968 * Make sure the user moved the mouse far enough for the | |
1969 * drag to be initiated. | |
1970 */ | |
1971 if (gtkwin->in_predrag) { | |
1972 if (e->x_root < gtkwin->drag_min_x || | |
1973 e->x_root >= gtkwin->drag_max_x || | |
1974 e->y_root < gtkwin->drag_min_y || | |
1975 e->y_root >= gtkwin->drag_max_y) { | |
1976 | |
1977 gtkwin->in_predrag = FALSE; | |
1978 notebook_init_grab(gtkwin, widget); | |
1979 } | |
1980 } | |
1981 else { /* Otherwise, draw the arrows. */ | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
1982 GaimConvWindow *dest_win; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
1983 GaimGtkWindow *dest_gtkwin; |
4359 | 1984 GtkNotebook *dest_notebook; |
1985 GtkWidget *tab, *last_vis_tab = NULL; | |
1986 gint nb_x, nb_y, page_num, i, last_vis_tab_loc = -1; | |
1987 gint arrow1_x, arrow1_y, arrow2_x, arrow2_y; | |
1988 gboolean horiz_tabs = FALSE, tab_found = FALSE; | |
1989 GList *l; | |
1990 | |
1991 /* Get the window that the cursor is over. */ | |
1992 dest_win = gaim_gtkwin_get_at_xy(e->x_root, e->y_root); | |
1993 | |
1994 if (dest_win == NULL) { | |
1995 dnd_hints_hide_all(); | |
1996 | |
1997 return TRUE; | |
1998 } | |
1999 | |
2000 dest_gtkwin = GAIM_GTK_WINDOW(dest_win); | |
2001 | |
2002 dest_notebook = GTK_NOTEBOOK(dest_gtkwin->notebook); | |
2003 | |
2004 gdk_window_get_origin(GTK_WIDGET(dest_notebook)->window, &nb_x, &nb_y); | |
2005 | |
2006 arrow1_x = arrow2_x = nb_x; | |
2007 arrow1_y = arrow2_y = nb_y; | |
2008 | |
2009 page_num = gaim_gtkconv_get_dest_tab_at_xy(dest_win, | |
2010 e->x_root, e->y_root); | |
2011 | |
2012 if (gtk_notebook_get_tab_pos(dest_notebook) == GTK_POS_TOP || | |
2013 gtk_notebook_get_tab_pos(dest_notebook) == GTK_POS_BOTTOM) { | |
2014 | |
2015 horiz_tabs = TRUE; | |
2016 } | |
2017 | |
2018 /* Find out where to put the arrows. */ | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2019 for (l = gaim_conv_window_get_conversations(dest_win), i = 0; |
4359 | 2020 l != NULL; |
2021 l = l->next, i++) { | |
2022 | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
2023 GaimConversation *conv = l->data; |
4359 | 2024 |
2025 tab = GAIM_GTK_CONVERSATION(conv)->tabby; | |
2026 | |
2027 /* | |
2028 * If this is the correct tab, record the positions | |
2029 * for the arrows. | |
2030 */ | |
2031 if (i == page_num) { | |
2032 if (horiz_tabs) { | |
2033 arrow1_x = arrow2_x = nb_x + tab->allocation.x; | |
2034 arrow1_y = nb_y + tab->allocation.y; | |
2035 arrow2_y = nb_y + tab->allocation.y + | |
2036 tab->allocation.height; | |
2037 } | |
2038 else { | |
2039 arrow1_x = nb_x + tab->allocation.x; | |
2040 arrow2_x = nb_x + tab->allocation.x + | |
2041 tab->allocation.width; | |
2042 arrow1_y = arrow2_y = nb_y + tab->allocation.y; | |
2043 } | |
2044 | |
2045 tab_found = TRUE; | |
2046 break; | |
2047 } | |
2048 else { /* Keep track of the right-most tab that we see. */ | |
2049 if (horiz_tabs && tab->allocation.x > last_vis_tab_loc) { | |
2050 last_vis_tab = tab; | |
2051 last_vis_tab_loc = tab->allocation.x; | |
2052 } | |
2053 else if (!horiz_tabs && tab->allocation.y > last_vis_tab_loc) { | |
2054 last_vis_tab = tab; | |
2055 last_vis_tab_loc = tab->allocation.y; | |
2056 } | |
2057 } | |
2058 } | |
2059 | |
2060 /* | |
2061 * If we didn't find the tab, then we'll just place the | |
2062 * arrows to the right/bottom of the last visible tab. | |
2063 */ | |
2064 if (!tab_found && last_vis_tab) { | |
2065 if (horiz_tabs) { | |
2066 arrow1_x = arrow2_x = nb_x + last_vis_tab->allocation.x + | |
2067 last_vis_tab->allocation.width; | |
2068 arrow1_y = nb_y + last_vis_tab->allocation.y; | |
2069 arrow2_y = nb_y + last_vis_tab->allocation.y + | |
2070 last_vis_tab->allocation.height; | |
2071 } | |
2072 else { | |
2073 arrow1_x = nb_x + last_vis_tab->allocation.x; | |
2074 arrow2_x = nb_x + last_vis_tab->allocation.x + | |
2075 last_vis_tab->allocation.width; | |
2076 arrow1_y = arrow2_y = nb_y + last_vis_tab->allocation.y + | |
2077 last_vis_tab->allocation.height; | |
2078 } | |
2079 } | |
2080 | |
2081 if (horiz_tabs) { | |
2082 dnd_hints_show(HINT_ARROW_DOWN, arrow1_x, arrow1_y); | |
2083 dnd_hints_show(HINT_ARROW_UP, arrow2_x, arrow2_y); | |
2084 } | |
2085 else { | |
2086 dnd_hints_show(HINT_ARROW_RIGHT, arrow1_x, arrow1_y); | |
2087 dnd_hints_show(HINT_ARROW_LEFT, arrow2_x, arrow2_y); | |
2088 } | |
2089 } | |
2090 | |
2091 return TRUE; | |
2092 } | |
2093 | |
2094 static gboolean | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2095 notebook_leave_cb(GtkWidget *widget, GdkEventCrossing *e, GaimConvWindow *win) |
4359 | 2096 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
2097 GaimGtkWindow *gtkwin; |
4359 | 2098 |
2099 gtkwin = GAIM_GTK_WINDOW(win); | |
2100 | |
2101 if (gtkwin->in_drag) | |
2102 return FALSE; | |
2103 | |
2104 if (e->x_root < gtkwin->drag_min_x || | |
2105 e->x_root >= gtkwin->drag_max_x || | |
2106 e->y_root < gtkwin->drag_min_y || | |
2107 e->y_root >= gtkwin->drag_max_y) { | |
2108 | |
2109 gtkwin->in_predrag = FALSE; | |
2110 notebook_init_grab(gtkwin, widget); | |
2111 } | |
2112 | |
2113 return TRUE; | |
2114 } | |
2115 | |
2116 /* | |
2117 * THANK YOU GALEON! | |
2118 */ | |
2119 static gboolean | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2120 notebook_press_cb(GtkWidget *widget, GdkEventButton *e, GaimConvWindow *win) |
4359 | 2121 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
2122 GaimGtkWindow *gtkwin; |
4359 | 2123 gint nb_x, nb_y, x_rel, y_rel; |
2124 GList *l; | |
2125 int tab_clicked; | |
2126 | |
2127 if (e->button != 1 || e->type != GDK_BUTTON_PRESS) | |
2128 return FALSE; | |
2129 | |
2130 gtkwin = GAIM_GTK_WINDOW(win); | |
2131 | |
2132 if (gtkwin->in_drag) { | |
5211
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
2133 gaim_debug(GAIM_DEBUG_WARNING, "gtkconv", |
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
2134 "Already in the middle of a window drag at tab_press_cb\n"); |
4803
6f04901ef729
[gaim-migrate @ 5123]
Christian Hammond <chipx86@chipx86.com>
parents:
4793
diff
changeset
|
2135 return TRUE; |
4359 | 2136 } |
2137 | |
6725
e62a504c83d0
[gaim-migrate @ 7252]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
2138 /* |
4359 | 2139 * Make sure a tab was actually clicked. The arrow buttons |
2140 * mess things up. | |
2141 */ | |
2142 tab_clicked = gaim_gtkconv_get_tab_at_xy(win, e->x_root, e->y_root); | |
2143 | |
2144 if (tab_clicked == -1) | |
2145 return FALSE; | |
2146 | |
2147 /* | |
2148 * Get the relative position of the press event, with regards to | |
2149 * the position of the notebook. | |
2150 */ | |
2151 gdk_window_get_origin(gtkwin->notebook->window, &nb_x, &nb_y); | |
2152 | |
2153 x_rel = e->x_root - nb_x; | |
2154 y_rel = e->y_root - nb_y; | |
2155 | |
2156 /* Reset the min/max x/y */ | |
2157 gtkwin->drag_min_x = 0; | |
2158 gtkwin->drag_min_y = 0; | |
2159 gtkwin->drag_max_x = 0; | |
2160 gtkwin->drag_max_y = 0; | |
2161 | |
2162 /* Find out which tab was dragged. */ | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2163 for (l = gaim_conv_window_get_conversations(win); l != NULL; l = l->next) { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
2164 GaimConversation *conv = l->data; |
4359 | 2165 GtkWidget *tab = GAIM_GTK_CONVERSATION(conv)->tabby; |
2166 | |
2167 if (!GTK_WIDGET_VISIBLE(tab)) | |
2168 continue; | |
2169 | |
2170 if (tab->allocation.x > x_rel || tab->allocation.y > y_rel) | |
2171 break; | |
2172 | |
2173 /* Save the borders of the tab. */ | |
2174 gtkwin->drag_min_x = tab->allocation.x + nb_x; | |
2175 gtkwin->drag_min_y = tab->allocation.y + nb_y; | |
2176 gtkwin->drag_max_x = tab->allocation.width + gtkwin->drag_min_x; | |
2177 gtkwin->drag_max_y = tab->allocation.height + gtkwin->drag_min_y; | |
2178 } | |
2179 | |
2180 /* Make sure the click occurred in the tab. */ | |
2181 if (e->x_root < gtkwin->drag_min_x || | |
2182 e->x_root >= gtkwin->drag_max_x || | |
2183 e->y_root < gtkwin->drag_min_y || | |
2184 e->y_root >= gtkwin->drag_max_y) { | |
2185 | |
2186 return FALSE; | |
2187 } | |
2188 | |
2189 gtkwin->in_predrag = TRUE; | |
2190 | |
2191 /* Connect the new motion signals. */ | |
2192 gtkwin->drag_motion_signal = | |
2193 g_signal_connect(G_OBJECT(widget), "motion_notify_event", | |
2194 G_CALLBACK(notebook_motion_cb), win); | |
2195 | |
2196 gtkwin->drag_leave_signal = | |
2197 g_signal_connect(G_OBJECT(widget), "leave_notify_event", | |
2198 G_CALLBACK(notebook_leave_cb), win); | |
2199 | |
2200 return FALSE; | |
2201 } | |
2202 | |
2203 static gboolean | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2204 notebook_release_cb(GtkWidget *widget, GdkEventButton *e, GaimConvWindow *win) |
4359 | 2205 { |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2206 GaimConvWindow *dest_win; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
2207 GaimGtkWindow *gtkwin; |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
2208 GaimGtkWindow *dest_gtkwin; |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
2209 GaimConversation *conv; |
4359 | 2210 GtkNotebook *dest_notebook; |
2211 gint dest_page_num; | |
2212 | |
2213 /* | |
2214 * Don't check to make sure that the event's window matches the | |
2215 * widget's, because we may be getting an event passed on from the | |
2216 * close button. | |
2217 */ | |
2218 if (e->button != 1 && e->type != GDK_BUTTON_RELEASE) | |
2219 return FALSE; | |
2220 | |
2221 if (gdk_pointer_is_grabbed()) { | |
2222 gdk_pointer_ungrab(GDK_CURRENT_TIME); | |
2223 gtk_grab_remove(widget); | |
2224 } | |
2225 | |
2226 gtkwin = GAIM_GTK_WINDOW(win); | |
2227 | |
4803
6f04901ef729
[gaim-migrate @ 5123]
Christian Hammond <chipx86@chipx86.com>
parents:
4793
diff
changeset
|
2228 if (!gtkwin->in_predrag && !gtkwin->in_drag) |
6f04901ef729
[gaim-migrate @ 5123]
Christian Hammond <chipx86@chipx86.com>
parents:
4793
diff
changeset
|
2229 return FALSE; |
4359 | 2230 |
2231 /* Disconnect the motion signal. */ | |
2232 if (gtkwin->drag_motion_signal) { | |
2233 g_signal_handler_disconnect(G_OBJECT(widget), | |
2234 gtkwin->drag_motion_signal); | |
2235 | |
2236 gtkwin->drag_motion_signal = 0; | |
2237 } | |
2238 | |
2239 /* | |
2240 * If we're in a pre-drag, we'll also need to disconnect the leave | |
2241 * signal. | |
2242 */ | |
2243 if (gtkwin->in_predrag) { | |
2244 gtkwin->in_predrag = FALSE; | |
2245 | |
2246 if (gtkwin->drag_leave_signal) { | |
2247 g_signal_handler_disconnect(G_OBJECT(widget), | |
2248 gtkwin->drag_leave_signal); | |
2249 | |
2250 gtkwin->drag_leave_signal = 0; | |
2251 } | |
2252 } | |
2253 | |
2254 /* If we're not in drag... */ | |
2255 /* We're perfectly normal people! */ | |
4803
6f04901ef729
[gaim-migrate @ 5123]
Christian Hammond <chipx86@chipx86.com>
parents:
4793
diff
changeset
|
2256 if (!gtkwin->in_drag) |
4359 | 2257 return FALSE; |
2258 | |
2259 gtkwin->in_drag = FALSE; | |
2260 | |
2261 dnd_hints_hide_all(); | |
2262 | |
4369
7e1fb422e5fd
[gaim-migrate @ 4635]
Christian Hammond <chipx86@chipx86.com>
parents:
4368
diff
changeset
|
2263 dest_win = gaim_gtkwin_get_at_xy(e->x_root, e->y_root); |
4359 | 2264 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2265 conv = gaim_conv_window_get_active_conversation(win); |
4359 | 2266 |
2267 if (dest_win == NULL) { | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2268 if (gaim_conv_window_get_conversation_count(win) < 2) |
4359 | 2269 return FALSE; |
2270 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2271 if (gaim_conv_window_get_conversation_count(win) > 1) { |
4359 | 2272 /* Make a new window to stick this to. */ |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
2273 GaimGtkConversation *gtkconv; |
4748
d3c09ddfd3aa
[gaim-migrate @ 5063]
Christian Hammond <chipx86@chipx86.com>
parents:
4736
diff
changeset
|
2274 gint win_width, win_height; |
5121 | 2275 |
2276 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
4359 | 2277 |
8582
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
2278 dest_win = gaim_conv_window_new(); |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
2279 |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
2280 gaim_conv_window_add_conversation(dest_win, |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2281 gaim_conv_window_remove_conversation(win, |
5139
d0182ae31ab8
[gaim-migrate @ 5503]
Christian Hammond <chipx86@chipx86.com>
parents:
5133
diff
changeset
|
2282 gaim_conversation_get_index(conv))); |
5121 | 2283 |
8582
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
2284 dest_gtkwin = GAIM_GTK_WINDOW(dest_win); |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
2285 |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
2286 gtk_window_get_size(GTK_WINDOW(dest_gtkwin->window), |
4748
d3c09ddfd3aa
[gaim-migrate @ 5063]
Christian Hammond <chipx86@chipx86.com>
parents:
4736
diff
changeset
|
2287 &win_width, &win_height); |
d3c09ddfd3aa
[gaim-migrate @ 5063]
Christian Hammond <chipx86@chipx86.com>
parents:
4736
diff
changeset
|
2288 |
8582
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
2289 gtk_window_move(GTK_WINDOW(dest_gtkwin->window), |
4748
d3c09ddfd3aa
[gaim-migrate @ 5063]
Christian Hammond <chipx86@chipx86.com>
parents:
4736
diff
changeset
|
2290 e->x_root - (win_width / 2), |
d3c09ddfd3aa
[gaim-migrate @ 5063]
Christian Hammond <chipx86@chipx86.com>
parents:
4736
diff
changeset
|
2291 e->y_root - (win_height / 2)); |
d3c09ddfd3aa
[gaim-migrate @ 5063]
Christian Hammond <chipx86@chipx86.com>
parents:
4736
diff
changeset
|
2292 |
8582
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
2293 gaim_conv_window_show(dest_win); |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
2294 } |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
2295 } else { |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
2296 dest_gtkwin = GAIM_GTK_WINDOW(dest_win); |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
2297 |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
2298 /* Get the destination notebook. */ |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
2299 dest_notebook = GTK_NOTEBOOK(gtkwin->notebook); |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
2300 |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
2301 /* Get the destination page number. */ |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
2302 dest_page_num = gaim_gtkconv_get_dest_tab_at_xy(dest_win, |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
2303 e->x_root, e->y_root); |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
2304 |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
2305 if (win == dest_win) { |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
2306 gaim_conv_window_move_conversation(win, |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
2307 gaim_conversation_get_index(conv), dest_page_num); |
4359 | 2308 } |
8582
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
2309 else { |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
2310 size_t pos; |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
2311 |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
2312 gaim_conv_window_remove_conversation(win, |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
2313 gaim_conversation_get_index(conv)); |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
2314 |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
2315 pos = gaim_conv_window_add_conversation(dest_win, conv); |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
2316 |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
2317 if (pos != dest_page_num) |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
2318 gaim_conv_window_move_conversation(dest_win, pos, dest_page_num); |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
2319 |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
2320 gaim_conv_window_switch_conversation(dest_win, dest_page_num); |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
2321 } |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
2322 |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
2323 gtk_widget_grab_focus(GAIM_GTK_CONVERSATION(conv)->entry); |
4359 | 2324 } |
2325 | |
8582
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
2326 gaim_signal_emit(gaim_gtk_conversations_get_handle(), "conversation-drag-ended", |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
2327 win, dest_win); |
4359 | 2328 |
2329 return TRUE; | |
2330 } | |
2331 | |
8189 | 2332 /************************************************************************** |
2333 * A bunch of buddy icon functions | |
2334 **************************************************************************/ | |
2335 static GdkPixbuf * | |
8755
d0364feabf96
[gaim-migrate @ 9510]
Christian Hammond <chipx86@chipx86.com>
parents:
8748
diff
changeset
|
2336 get_tab_icon(GaimConversation *conv, gboolean small_icon) |
7143 | 2337 { |
2338 GaimAccount *account = gaim_conversation_get_account(conv); | |
2339 const char *name = gaim_conversation_get_name(conv); | |
2340 GdkPixbuf *status = NULL; | |
2341 | |
2342 if (gaim_conversation_get_type(conv) == GAIM_CONV_IM) { | |
2343 GaimBuddy *b = gaim_find_buddy(account, name); | |
2344 if (b != NULL) { | |
2345 status = gaim_gtk_blist_get_status_icon((GaimBlistNode*)b, | |
8755
d0364feabf96
[gaim-migrate @ 9510]
Christian Hammond <chipx86@chipx86.com>
parents:
8748
diff
changeset
|
2346 (small_icon ? GAIM_STATUS_ICON_SMALL : GAIM_STATUS_ICON_LARGE)); |
7143 | 2347 } |
2348 } | |
2349 | |
2350 if (!status) { | |
2351 GdkPixbuf *pixbuf; | |
2352 pixbuf = create_prpl_icon(account); | |
2353 | |
8755
d0364feabf96
[gaim-migrate @ 9510]
Christian Hammond <chipx86@chipx86.com>
parents:
8748
diff
changeset
|
2354 if (small_icon && pixbuf != NULL) |
8748
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2355 { |
7143 | 2356 status = gdk_pixbuf_scale_simple(pixbuf, 15, 15, |
2357 GDK_INTERP_BILINEAR); | |
2358 g_object_unref(pixbuf); | |
2359 } | |
8748
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2360 else |
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2361 status = pixbuf; |
7143 | 2362 } |
2363 return status; | |
2364 } | |
2365 | |
8189 | 2366 static void |
2367 update_tab_icon(GaimConversation *conv) | |
2368 { | |
2369 GaimGtkConversation *gtkconv; | |
2370 GaimConvWindow *win = gaim_conversation_get_window(conv); | |
2371 GaimAccount *account; | |
2372 const char *name; | |
2373 GdkPixbuf *status = NULL; | |
2374 | |
2375 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
2376 name = gaim_conversation_get_name(conv); | |
2377 account = gaim_conversation_get_account(conv); | |
2378 | |
8748
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2379 status = get_tab_icon(conv, TRUE); |
8189 | 2380 |
2381 gtk_image_set_from_pixbuf(GTK_IMAGE(gtkconv->icon), status); | |
2382 gtk_image_set_from_pixbuf(GTK_IMAGE(gtkconv->menu_icon), status); | |
2383 | |
8748
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2384 if (status != NULL) |
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2385 g_object_unref(status); |
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2386 |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
2387 if (gaim_conv_window_get_active_conversation(win) == conv && |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
2388 gtkconv->u.im->anim == NULL) |
8748
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2389 { |
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2390 status = get_tab_icon(conv, FALSE); |
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2391 |
8189 | 2392 gtk_window_set_icon(GTK_WINDOW(GAIM_GTK_WINDOW(win)->window), status); |
2393 | |
8748
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2394 if (status != NULL) |
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2395 g_object_unref(status); |
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2396 } |
8189 | 2397 } |
2398 | |
9318 | 2399 static void |
2400 get_icon_scale_size(GdkPixbufAnimation *icon, GaimBuddyIconSpec *spec, int *width, int *height) | |
2401 { | |
2402 *width = gdk_pixbuf_animation_get_width(icon); | |
2403 *height = gdk_pixbuf_animation_get_height(icon); | |
2404 | |
2405 /* this should eventually get smarter about preserving the aspect | |
2406 * ratio when scaling, but gimmie a break, I just woke up */ | |
2407 if(spec && spec->scale_rules & GAIM_ICON_SCALE_DISPLAY) { | |
2408 if(*width < spec->min_width) | |
2409 *width = spec->min_width; | |
2410 else if(*width > spec->max_width) | |
2411 *width = spec->max_width; | |
2412 | |
2413 if(*height < spec->min_height) | |
2414 *height = spec->min_height; | |
9319 | 2415 else if(*height > spec->max_height) |
9318 | 2416 *height = spec->max_height; |
2417 } | |
2418 | |
2419 /* and now for some arbitrary sanity checks */ | |
2420 if(*width > 100) | |
2421 *width = 100; | |
2422 if(*height > 100) | |
2423 *height = 100; | |
2424 } | |
2425 | |
8189 | 2426 static gboolean |
2427 redraw_icon(gpointer data) | |
2428 { | |
2429 GaimConversation *conv = (GaimConversation *)data; | |
2430 GaimGtkConversation *gtkconv; | |
9318 | 2431 GaimAccount *account; |
2432 GaimPluginProtocolInfo *prpl_info = NULL; | |
8189 | 2433 |
2434 GdkPixbuf *buf; | |
2435 GdkPixbuf *scale; | |
2436 GdkPixmap *pm; | |
2437 GdkBitmap *bm; | |
2438 gint delay; | |
9318 | 2439 int scale_width, scale_height; |
8189 | 2440 |
2441 if (!g_list_find(gaim_get_ims(), conv)) { | |
2442 gaim_debug(GAIM_DEBUG_WARNING, "gtkconv", | |
2443 "Conversation not found in redraw_icon. I think this " | |
2444 "is a bug.\n"); | |
2445 return FALSE; | |
2446 } | |
2447 | |
2448 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
9318 | 2449 account = gaim_conversation_get_account(conv); |
2450 if(account && account->gc) | |
2451 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(account->gc->prpl); | |
8189 | 2452 |
2453 gdk_pixbuf_animation_iter_advance(gtkconv->u.im->iter, NULL); | |
2454 buf = gdk_pixbuf_animation_iter_get_pixbuf(gtkconv->u.im->iter); | |
2455 | |
9318 | 2456 get_icon_scale_size(gtkconv->u.im->anim, prpl_info ? &prpl_info->icon_spec : |
2457 NULL, &scale_width, &scale_height); | |
2458 | |
2459 /* this code is ugly, and scares me */ | |
8189 | 2460 scale = gdk_pixbuf_scale_simple(buf, |
9318 | 2461 MAX(gdk_pixbuf_get_width(buf) * scale_width / |
8189 | 2462 gdk_pixbuf_animation_get_width(gtkconv->u.im->anim), 1), |
9318 | 2463 MAX(gdk_pixbuf_get_height(buf) * scale_height / |
8189 | 2464 gdk_pixbuf_animation_get_height(gtkconv->u.im->anim), 1), |
2465 GDK_INTERP_NEAREST); | |
2466 | |
2467 gdk_pixbuf_render_pixmap_and_mask(scale, &pm, &bm, 100); | |
2468 g_object_unref(G_OBJECT(scale)); | |
2469 gtk_image_set_from_pixmap(GTK_IMAGE(gtkconv->u.im->icon), pm, bm); | |
2470 g_object_unref(G_OBJECT(pm)); | |
2471 gtk_widget_queue_draw(gtkconv->u.im->icon); | |
2472 | |
2473 if (bm) | |
2474 g_object_unref(G_OBJECT(bm)); | |
2475 | |
9131 | 2476 delay = gdk_pixbuf_animation_iter_get_delay_time(gtkconv->u.im->iter); |
2477 if (delay <= 0) | |
2478 delay = 100; | |
2479 | |
2480 gtkconv->u.im->icon_timer = g_timeout_add(delay, redraw_icon, conv); | |
8189 | 2481 |
2482 return FALSE; | |
2483 } | |
2484 | |
2485 static void | |
2486 start_anim(GtkObject *obj, GaimConversation *conv) | |
2487 { | |
2488 GaimGtkConversation *gtkconv; | |
2489 int delay; | |
2490 | |
2491 if (!GAIM_IS_GTK_CONVERSATION(conv)) | |
2492 return; | |
2493 | |
2494 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
2495 | |
8228 | 2496 if (gtkconv->u.im->anim == NULL) |
2497 return; | |
2498 | |
8202 | 2499 if (gtkconv->u.im->icon_timer != 0) |
2500 return; | |
2501 | |
8189 | 2502 if (gdk_pixbuf_animation_is_static_image(gtkconv->u.im->anim)) |
2503 return; | |
2504 | |
2505 delay = gdk_pixbuf_animation_iter_get_delay_time(gtkconv->u.im->iter) / 10; | |
2506 | |
8758 | 2507 gtkconv->u.im->icon_timer = g_timeout_add(delay * 10, redraw_icon, conv); |
8189 | 2508 } |
2509 | |
2510 static void | |
2511 stop_anim(GtkObject *obj, GaimConversation *conv) | |
2512 { | |
2513 GaimGtkConversation *gtkconv; | |
2514 | |
2515 if (!GAIM_IS_GTK_CONVERSATION(conv)) | |
2516 return; | |
2517 | |
2518 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
2519 | |
2520 if (gtkconv->u.im->icon_timer != 0) | |
2521 g_source_remove(gtkconv->u.im->icon_timer); | |
2522 | |
2523 gtkconv->u.im->icon_timer = 0; | |
2524 } | |
2525 | |
2526 static void | |
2527 toggle_icon_animate_cb(GtkWidget *w, GaimConversation *conv) | |
2528 { | |
2529 GaimGtkConversation *gtkconv; | |
2530 | |
2531 if (!GAIM_IS_GTK_CONVERSATION(conv)) | |
2532 return; | |
2533 | |
2534 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
2535 | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
2536 gtkconv->u.im->animate = |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
2537 gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(w)); |
8189 | 2538 |
2539 if (gtkconv->u.im->animate) | |
2540 start_anim(NULL, conv); | |
2541 else | |
2542 stop_anim(NULL, conv); | |
2543 } | |
9845 | 2544 |
8189 | 2545 static void |
2546 remove_icon(GaimGtkConversation *gtkconv) | |
2547 { | |
2548 g_return_if_fail(gtkconv != NULL); | |
2549 | |
9887 | 2550 if (gtkconv->u.im->icon_container != NULL) |
2551 gtk_widget_destroy(gtkconv->u.im->icon_container); | |
8189 | 2552 |
2553 if (gtkconv->u.im->anim != NULL) | |
2554 g_object_unref(G_OBJECT(gtkconv->u.im->anim)); | |
2555 | |
2556 if (gtkconv->u.im->icon_timer != 0) | |
2557 g_source_remove(gtkconv->u.im->icon_timer); | |
2558 | |
2559 if (gtkconv->u.im->iter != NULL) | |
2560 g_object_unref(G_OBJECT(gtkconv->u.im->iter)); | |
2561 | |
2562 gtkconv->u.im->icon_timer = 0; | |
2563 gtkconv->u.im->icon = NULL; | |
2564 gtkconv->u.im->anim = NULL; | |
2565 gtkconv->u.im->iter = NULL; | |
9687 | 2566 gtkconv->u.im->show_icon = FALSE; |
8189 | 2567 } |
2568 | |
9497 | 2569 static void |
9504 | 2570 saveicon_writefile_cb(void *user_data, const char *filename) |
9497 | 2571 { |
9504 | 2572 GaimConversation *conv = (GaimConversation *)user_data; |
9497 | 2573 FILE *fp; |
2574 GaimBuddyIcon *icon; | |
2575 const void *data; | |
2576 size_t len; | |
2577 | |
2578 if ((fp = fopen(filename, "wb")) == NULL) { | |
9504 | 2579 gaim_notify_error(conv, NULL, _("Unable to open file."), NULL); |
9497 | 2580 return; |
2581 } | |
2582 | |
2583 icon = gaim_conv_im_get_icon(GAIM_CONV_IM(conv)); | |
2584 data = gaim_buddy_icon_get_data(icon, &len); | |
2585 | |
2586 if ((len <= 0) || (data == NULL)) { | |
9504 | 2587 gaim_notify_error(conv, NULL, _("Unable to save icon file to disk."), NULL); |
9497 | 2588 return; |
2589 } | |
2590 | |
2591 fwrite(data, 1, len, fp); | |
2592 fclose(fp); | |
2593 } | |
2594 | |
2595 static void | |
2596 icon_menu_save_cb(GtkWidget *widget, GaimConversation *conv) | |
2597 { | |
2598 gchar *buf; | |
2599 | |
2600 g_return_if_fail(conv != NULL); | |
9504 | 2601 |
9706 | 2602 /* |
2603 * XXX - The file extension needs to be set to something that doesn't suck... | |
2604 * Maybe do what gtkimhtml.c does when saving an image? | |
2605 */ | |
9497 | 2606 buf = g_strdup_printf("%s.icon", gaim_normalize(conv->account, conv->name)); |
9504 | 2607 |
2608 gaim_request_file(conv, _("Save Icon"), buf, TRUE, | |
2609 G_CALLBACK(saveicon_writefile_cb), NULL, conv); | |
9497 | 2610 |
2611 g_free(buf); | |
2612 } | |
2613 | |
8189 | 2614 static gboolean |
2615 icon_menu(GtkObject *obj, GdkEventButton *e, GaimConversation *conv) | |
2616 { | |
2617 GaimGtkConversation *gtkconv; | |
2618 static GtkWidget *menu = NULL; | |
2619 GtkWidget *button; | |
2620 | |
2621 if (e->button != 3 || e->type != GDK_BUTTON_PRESS) | |
2622 return FALSE; | |
2623 | |
2624 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
2625 | |
2626 /* | |
2627 * If a menu already exists, destroy it before creating a new one, | |
2628 * thus freeing-up the memory it occupied. | |
2629 */ | |
2630 if (menu != NULL) | |
2631 gtk_widget_destroy(menu); | |
2632 | |
2633 menu = gtk_menu_new(); | |
2634 | |
2635 if (gtkconv->u.im->anim && | |
2636 !(gdk_pixbuf_animation_is_static_image(gtkconv->u.im->anim))) | |
2637 { | |
2638 gaim_new_check_item(menu, _("Animate"), | |
2639 G_CALLBACK(toggle_icon_animate_cb), conv, | |
2640 gtkconv->u.im->icon_timer); | |
2641 } | |
2642 | |
2643 button = gtk_menu_item_new_with_label(_("Hide Icon")); | |
2644 g_signal_connect_swapped(G_OBJECT(button), "activate", | |
2645 G_CALLBACK(remove_icon), gtkconv); | |
2646 gtk_menu_shell_append(GTK_MENU_SHELL(menu), button); | |
2647 gtk_widget_show(button); | |
2648 | |
2649 gaim_new_item_from_stock(menu, _("Save Icon As..."), GTK_STOCK_SAVE_AS, | |
9497 | 2650 G_CALLBACK(icon_menu_save_cb), conv, |
8189 | 2651 0, 0, NULL); |
2652 | |
2653 gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL, e->button, e->time); | |
2654 | |
2655 return TRUE; | |
2656 } | |
2657 /************************************************************************** | |
2658 * End of the bunch of buddy icon functions | |
2659 **************************************************************************/ | |
2660 | |
7887 | 2661 /* |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
2662 * Makes sure all the menu items and all the buttons are hidden/shown and |
8735
92cbf9713795
[gaim-migrate @ 9490]
Christian Hammond <chipx86@chipx86.com>
parents:
8730
diff
changeset
|
2663 * sensitive/insensitive. This is called after changing tabs and when an |
7887 | 2664 * account signs on or off. |
2665 */ | |
4359 | 2666 static void |
7887 | 2667 gray_stuff_out(GaimConversation *conv) |
4359 | 2668 { |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2669 GaimConvWindow *win; |
7887 | 2670 GaimGtkWindow *gtkwin; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
2671 GaimGtkConversation *gtkconv; |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
2672 GaimConnection *gc; |
7887 | 2673 GaimPluginProtocolInfo *prpl_info = NULL; |
7222 | 2674 GdkPixbuf *window_icon = NULL; |
8439 | 2675 GtkIMHtmlButtons buttons; |
9812 | 2676 GaimAccount *account; |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
2677 |
7887 | 2678 win = gaim_conversation_get_window(conv); |
4359 | 2679 gtkwin = GAIM_GTK_WINDOW(win); |
2680 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
7887 | 2681 gc = gaim_conversation_get_gc(conv); |
9909 | 2682 account = gaim_conversation_get_account(conv); |
8439 | 2683 |
7879 | 2684 if (gc != NULL) |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5204
diff
changeset
|
2685 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); |
4364
fa56829b9587
[gaim-migrate @ 4630]
Christian Hammond <chipx86@chipx86.com>
parents:
4363
diff
changeset
|
2686 |
7887 | 2687 if (gtkwin->menu.send_as != NULL) |
2688 g_timeout_add(0, (GSourceFunc)update_send_as_selection, win); | |
2689 | |
2690 /* | |
2691 * Handle hiding and showing stuff based on what type of conv this is. | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
2692 * Stuff that Gaim IMs support in general should be shown for IM |
8735
92cbf9713795
[gaim-migrate @ 9490]
Christian Hammond <chipx86@chipx86.com>
parents:
8730
diff
changeset
|
2693 * conversations. Stuff that Gaim chats support in general should be |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
2694 * shown for chat conversations. It doesn't matter whether the PRPL |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
2695 * supports it or not--that only affects if the button or menu item |
7929 | 2696 * is sensitive or not. |
7887 | 2697 */ |
4359 | 2698 if (gaim_conversation_get_type(conv) == GAIM_CONV_IM) { |
7887 | 2699 /* Show stuff that applies to IMs, hide stuff that applies to chats */ |
2700 | |
2701 /* Deal with buttons */ | |
2702 gtk_widget_show(gtkconv->info); | |
2703 gtk_widget_show(gtkconv->send); | |
2704 gtk_widget_show(gtkconv->u.im->block); | |
9468 | 2705 gtk_widget_show(gtkconv->u.im->send_file); |
7887 | 2706 |
2707 /* Deal with menu items */ | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
2708 gtk_widget_show(gtkwin->menu.view_log); |
9468 | 2709 gtk_widget_show(gtkwin->menu.send_file); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
2710 gtk_widget_show(gtkwin->menu.add_pounce); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
2711 gtk_widget_show(gtkwin->menu.get_info); |
7887 | 2712 gtk_widget_show(gtkwin->menu.warn); |
7859 | 2713 gtk_widget_hide(gtkwin->menu.invite); |
7887 | 2714 gtk_widget_show(gtkwin->menu.alias); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
2715 gtk_widget_show(gtkwin->menu.block); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
2716 |
9812 | 2717 if (gaim_find_buddy(account, gaim_conversation_get_name(conv)) == NULL) { |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
2718 gtk_widget_show(gtkwin->menu.add); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
2719 gtk_widget_hide(gtkwin->menu.remove); |
7929 | 2720 gtk_widget_show(gtkconv->add); |
2721 gtk_widget_hide(gtkconv->remove); | |
7859 | 2722 } else { |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
2723 gtk_widget_show(gtkwin->menu.remove); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
2724 gtk_widget_hide(gtkwin->menu.add); |
7929 | 2725 gtk_widget_hide(gtkconv->add); |
2726 gtk_widget_show(gtkconv->remove); | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
2727 } |
7887 | 2728 |
2729 gtk_widget_show(gtkwin->menu.insert_link); | |
9287 | 2730 gtk_widget_show(gtkwin->menu.insert_image); |
7887 | 2731 } else if (gaim_conversation_get_type(conv) == GAIM_CONV_CHAT) { |
9470 | 2732 /* Show stuff that applies to Chats, hide stuff that applies to IMs */ |
7887 | 2733 |
2734 /* Deal with buttons */ | |
7952 | 2735 gtk_widget_show(gtkconv->info); |
7887 | 2736 gtk_widget_show(gtkconv->send); |
2737 gtk_widget_show(gtkconv->u.chat->invite); | |
2738 | |
2739 /* Deal with menu items */ | |
9917 | 2740 gtk_widget_show(gtkwin->menu.view_log); |
9468 | 2741 gtk_widget_hide(gtkwin->menu.send_file); |
7859 | 2742 gtk_widget_hide(gtkwin->menu.add_pounce); |
2743 gtk_widget_hide(gtkwin->menu.get_info); | |
7887 | 2744 gtk_widget_hide(gtkwin->menu.warn); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
2745 gtk_widget_show(gtkwin->menu.invite); |
7887 | 2746 gtk_widget_show(gtkwin->menu.alias); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
2747 gtk_widget_hide(gtkwin->menu.block); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
2748 |
9812 | 2749 if (gaim_blist_find_chat(account, gaim_conversation_get_name(conv)) == NULL) { |
2750 /* If the chat is NOT in the buddy list */ | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
2751 gtk_widget_show(gtkwin->menu.add); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
2752 gtk_widget_hide(gtkwin->menu.remove); |
7929 | 2753 gtk_widget_show(gtkconv->add); |
2754 gtk_widget_hide(gtkconv->remove); | |
7859 | 2755 } else { |
9812 | 2756 /* If the chat IS in the buddy list */ |
2757 gtk_widget_hide(gtkwin->menu.add); | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
2758 gtk_widget_show(gtkwin->menu.remove); |
7929 | 2759 gtk_widget_hide(gtkconv->add); |
2760 gtk_widget_show(gtkconv->remove); | |
7887 | 2761 } |
2762 | |
2763 gtk_widget_show(gtkwin->menu.insert_link); | |
2764 gtk_widget_hide(gtkwin->menu.insert_image); | |
2765 } | |
2766 | |
2767 /* | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
2768 * Handle graying stuff out based on whether an account is connected |
7887 | 2769 * and what features that account supports. |
2770 */ | |
8256
1d86096ae0f4
[gaim-migrate @ 8979]
Christian Hammond <chipx86@chipx86.com>
parents:
8253
diff
changeset
|
2771 if ((gc != NULL) && |
1d86096ae0f4
[gaim-migrate @ 8979]
Christian Hammond <chipx86@chipx86.com>
parents:
8253
diff
changeset
|
2772 ( (gaim_conversation_get_type(conv) != GAIM_CONV_CHAT) || |
1d86096ae0f4
[gaim-migrate @ 8979]
Christian Hammond <chipx86@chipx86.com>
parents:
8253
diff
changeset
|
2773 !gaim_conv_chat_has_left(GAIM_CONV_CHAT(conv)) )) { |
7887 | 2774 /* Account is online */ |
2775 | |
2776 /* Deal with buttons */ | |
2777 gtk_widget_set_sensitive(gtkconv->info, (prpl_info->get_info != NULL)); | |
7929 | 2778 |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
2779 if (gaim_conversation_get_type(conv) == GAIM_CONV_IM) |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
2780 { |
9812 | 2781 gtk_widget_set_sensitive(gtkconv->add, (prpl_info->add_buddy != NULL)); |
2782 gtk_widget_set_sensitive(gtkconv->remove, (prpl_info->remove_buddy != NULL)); | |
2783 gtk_widget_set_sensitive(gtkconv->send, (prpl_info->send_im != NULL)); | |
2784 gtk_widget_set_sensitive(gtkconv->u.im->block, (prpl_info->add_deny != NULL)); | |
9468 | 2785 gtk_widget_set_sensitive(gtkconv->u.im->send_file, |
9812 | 2786 (prpl_info->send_file && (!prpl_info->can_receive_file || |
2787 prpl_info->can_receive_file(gc, gaim_conversation_get_name(conv))))); | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
2788 } |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
2789 else if (gaim_conversation_get_type(conv) == GAIM_CONV_CHAT) |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
2790 { |
9812 | 2791 /* Only allow adding/removing if this is a chat and not a conference */ |
2792 gtk_widget_set_sensitive(gtkconv->add, (prpl_info->join_chat != NULL)); | |
2793 gtk_widget_set_sensitive(gtkconv->remove, (prpl_info->join_chat != NULL)); | |
2794 gtk_widget_set_sensitive(gtkconv->send, (prpl_info->chat_send != NULL)); | |
2795 gtk_widget_set_sensitive(gtkconv->u.chat->invite, (prpl_info->chat_invite != NULL)); | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
2796 } |
7887 | 2797 |
2798 /* Deal with the toolbar */ | |
8420 | 2799 if (gc->flags & GAIM_CONNECTION_HTML) { |
8677 | 2800 buttons = GTK_IMHTML_ALL; /* Everything on */ |
8420 | 2801 if (!(prpl_info->options & OPT_PROTO_IM_IMAGE)) |
8422 | 2802 buttons &= ~GTK_IMHTML_IMAGE; |
8420 | 2803 if (gc->flags & GAIM_CONNECTION_NO_BGCOLOR) |
8422 | 2804 buttons &= ~GTK_IMHTML_BACKCOLOR; |
8691
0eb5161ef333
[gaim-migrate @ 9444]
Christian Hammond <chipx86@chipx86.com>
parents:
8690
diff
changeset
|
2805 if (gc->flags & GAIM_CONNECTION_NO_FONTSIZE) { |
0eb5161ef333
[gaim-migrate @ 9444]
Christian Hammond <chipx86@chipx86.com>
parents:
8690
diff
changeset
|
2806 buttons &= ~GTK_IMHTML_GROW; |
0eb5161ef333
[gaim-migrate @ 9444]
Christian Hammond <chipx86@chipx86.com>
parents:
8690
diff
changeset
|
2807 buttons &= ~GTK_IMHTML_SHRINK; |
0eb5161ef333
[gaim-migrate @ 9444]
Christian Hammond <chipx86@chipx86.com>
parents:
8690
diff
changeset
|
2808 } |
9041 | 2809 if (gc->flags & GAIM_CONNECTION_NO_URLDESC) |
2810 buttons &= ~GTK_IMHTML_LINKDESC; | |
8420 | 2811 } else { |
8422 | 2812 buttons = GTK_IMHTML_SMILEY; |
8420 | 2813 } |
2814 gtk_imhtml_set_format_functions(GTK_IMHTML(gtkconv->entry), buttons); | |
9812 | 2815 gtk_imhtmltoolbar_associate_smileys(GTK_IMHTMLTOOLBAR(gtkconv->toolbar), gaim_account_get_protocol_id(account)); |
8422 | 2816 |
8319
a2c5537a814b
[gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents:
8317
diff
changeset
|
2817 /* Deal with menu items */ |
7887 | 2818 gtk_widget_set_sensitive(gtkwin->menu.view_log, TRUE); |
2819 gtk_widget_set_sensitive(gtkwin->menu.add_pounce, TRUE); | |
2820 gtk_widget_set_sensitive(gtkwin->menu.get_info, (prpl_info->get_info != NULL)); | |
2821 gtk_widget_set_sensitive(gtkwin->menu.warn, (prpl_info->warn != NULL)); | |
9812 | 2822 gtk_widget_set_sensitive(gtkwin->menu.invite, (prpl_info->chat_invite != NULL)); |
2823 gtk_widget_set_sensitive(gtkwin->menu.block, (prpl_info->add_deny != NULL)); | |
2824 gtk_widget_set_sensitive(gtkwin->menu.insert_link, (gc->flags & GAIM_CONNECTION_HTML)); | |
2825 gtk_widget_set_sensitive(gtkwin->menu.insert_image, (prpl_info->options & OPT_PROTO_IM_IMAGE)); | |
8319
a2c5537a814b
[gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents:
8317
diff
changeset
|
2826 |
7887 | 2827 if (gaim_conversation_get_type(conv) == GAIM_CONV_IM) { |
9812 | 2828 gtk_widget_set_sensitive(gtkwin->menu.add, (prpl_info->add_buddy != NULL)); |
2829 gtk_widget_set_sensitive(gtkwin->menu.remove, (prpl_info->remove_buddy != NULL)); | |
9468 | 2830 gtk_widget_set_sensitive(gtkwin->menu.send_file, |
9812 | 2831 (prpl_info->send_file != NULL && (!prpl_info->can_receive_file || |
2832 prpl_info->can_receive_file(gc, gaim_conversation_get_name(conv))))); | |
2833 gtk_widget_set_sensitive(gtkwin->menu.alias, | |
2834 (gaim_find_buddy(account, gaim_conversation_get_name(conv)) != NULL)); | |
7887 | 2835 } else if (gaim_conversation_get_type(conv) == GAIM_CONV_CHAT) { |
9812 | 2836 gtk_widget_set_sensitive(gtkwin->menu.add, (prpl_info->join_chat != NULL)); |
2837 gtk_widget_set_sensitive(gtkwin->menu.remove, (prpl_info->join_chat != NULL)); | |
2838 gtk_widget_set_sensitive(gtkwin->menu.alias, | |
2839 (gaim_blist_find_chat(account, gaim_conversation_get_name(conv)) != NULL)); | |
7887 | 2840 } |
2841 } else { | |
2842 /* Account is offline */ | |
9812 | 2843 /* Or it's a chat that we've left. */ |
7887 | 2844 |
2845 /* Deal with buttons */ | |
7929 | 2846 gtk_widget_set_sensitive(gtkconv->add, FALSE); |
2847 gtk_widget_set_sensitive(gtkconv->remove, FALSE); | |
7887 | 2848 gtk_widget_set_sensitive(gtkconv->info, FALSE); |
2849 gtk_widget_set_sensitive(gtkconv->send, FALSE); | |
2850 if (gaim_conversation_get_type(conv) == GAIM_CONV_IM) { | |
2851 gtk_widget_set_sensitive(gtkconv->u.im->block, FALSE); | |
9468 | 2852 gtk_widget_set_sensitive(gtkconv->u.im->send_file, FALSE); |
7887 | 2853 } else if (gaim_conversation_get_type(conv) == GAIM_CONV_CHAT) { |
2854 gtk_widget_set_sensitive(gtkconv->u.chat->invite, FALSE); | |
2855 } | |
8748
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2856 |
7887 | 2857 /* Then deal with menu items */ |
2858 gtk_widget_set_sensitive(gtkwin->menu.view_log, TRUE); | |
9468 | 2859 gtk_widget_set_sensitive(gtkwin->menu.send_file, FALSE); |
7887 | 2860 gtk_widget_set_sensitive(gtkwin->menu.add_pounce, TRUE); |
2861 gtk_widget_set_sensitive(gtkwin->menu.get_info, FALSE); | |
2862 gtk_widget_set_sensitive(gtkwin->menu.warn, FALSE); | |
2863 gtk_widget_set_sensitive(gtkwin->menu.invite, FALSE); | |
2864 gtk_widget_set_sensitive(gtkwin->menu.alias, FALSE); | |
2865 gtk_widget_set_sensitive(gtkwin->menu.block, FALSE); | |
2866 gtk_widget_set_sensitive(gtkwin->menu.add, FALSE); | |
2867 gtk_widget_set_sensitive(gtkwin->menu.remove, FALSE); | |
7929 | 2868 gtk_widget_set_sensitive(gtkwin->menu.insert_link, TRUE); |
7887 | 2869 gtk_widget_set_sensitive(gtkwin->menu.insert_image, FALSE); |
2870 } | |
2871 | |
2872 /* | |
2873 * Update the window's icon | |
2874 */ | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
2875 if ((gaim_conversation_get_type(conv) == GAIM_CONV_IM) && |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
2876 (gtkconv->u.im->anim)) |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
2877 { |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
2878 window_icon = |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
2879 gdk_pixbuf_animation_get_static_image(gtkconv->u.im->anim); |
7887 | 2880 g_object_ref(window_icon); |
2881 } else { | |
8748
13d592f485d1
[gaim-migrate @ 9503]
Christian Hammond <chipx86@chipx86.com>
parents:
8735
diff
changeset
|
2882 window_icon = get_tab_icon(conv, FALSE); |
4359 | 2883 } |
7887 | 2884 gtk_window_set_icon(GTK_WINDOW(gtkwin->window), window_icon); |
2885 g_object_unref(G_OBJECT(window_icon)); | |
2886 } | |
2887 | |
2888 static void | |
8189 | 2889 before_switch_conv_cb(GtkNotebook *notebook, GtkWidget *page, gint page_num, |
2890 gpointer user_data) | |
2891 { | |
2892 GaimConvWindow *win; | |
2893 GaimConversation *conv; | |
2894 GaimGtkConversation *gtkconv; | |
2895 | |
2896 win = (GaimConvWindow *)user_data; | |
2897 conv = gaim_conv_window_get_active_conversation(win); | |
2898 | |
2899 g_return_if_fail(conv != NULL); | |
2900 | |
8192 | 2901 if (gaim_conversation_get_type(conv) != GAIM_CONV_IM) |
2902 return; | |
2903 | |
8189 | 2904 gtkconv = GAIM_GTK_CONVERSATION(conv); |
2905 | |
2906 stop_anim(NULL, conv); | |
2907 } | |
2908 | |
2909 static void | |
7887 | 2910 switch_conv_cb(GtkNotebook *notebook, GtkWidget *page, gint page_num, |
2911 gpointer user_data) | |
2912 { | |
2913 GaimConvWindow *win; | |
2914 GaimConversation *conv; | |
2915 GaimGtkConversation *gtkconv; | |
2916 GaimGtkWindow *gtkwin; | |
2917 | |
2918 win = (GaimConvWindow *)user_data; | |
2919 conv = gaim_conv_window_get_conversation_at(win, page_num); | |
2920 | |
2921 g_return_if_fail(conv != NULL); | |
2922 | |
2923 gtkwin = GAIM_GTK_WINDOW(win); | |
2924 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
2925 | |
2926 gaim_conversation_set_unseen(conv, GAIM_UNSEEN_NONE); | |
2927 | |
2928 /* Update the menubar */ | |
2929 gray_stuff_out(conv); | |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
2930 |
4736 | 2931 update_typing_icon(conv); |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
2932 |
4359 | 2933 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(gtkwin->menu.logging), |
7143 | 2934 gaim_conversation_is_logging(conv)); |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
2935 |
4359 | 2936 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(gtkwin->menu.sounds), |
7143 | 2937 gtkconv->make_sound); |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
2938 |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
2939 gtk_check_menu_item_set_active( |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
2940 GTK_CHECK_MENU_ITEM(gtkwin->menu.show_formatting_toolbar), |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
2941 gtkconv->show_formatting_toolbar); |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
2942 |
9188 | 2943 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(gtkwin->menu.show_timestamps), |
2944 gtkconv->show_timestamps); | |
2945 | |
8189 | 2946 /* |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
2947 * We pause icons when they are not visible. If this icon should |
9297 | 2948 * be animated then start it back up again. |
8189 | 2949 */ |
8192 | 2950 if ((gaim_conversation_get_type(conv) == GAIM_CONV_IM) && |
2951 (gtkconv->u.im->animate)) | |
8189 | 2952 start_anim(NULL, conv); |
2953 | |
4965 | 2954 gtk_window_set_title(GTK_WINDOW(gtkwin->window), |
7143 | 2955 gtk_label_get_text(GTK_LABEL(gtkconv->tab_label))); |
4359 | 2956 } |
2957 | |
2958 /************************************************************************** | |
2959 * Utility functions | |
2960 **************************************************************************/ | |
2961 | |
2962 static void | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
2963 got_typing_keypress(GaimConversation *conv, gboolean first) |
4359 | 2964 { |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2965 GaimConvIm *im; |
4685 | 2966 |
4359 | 2967 /* |
2968 * 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
|
2969 * send GAIM_TYPED any time soon. |
4359 | 2970 */ |
2971 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2972 im = GAIM_CONV_IM(conv); |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2973 |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2974 if (gaim_conv_im_get_type_again_timeout(im)) |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2975 gaim_conv_im_stop_type_again_timeout(im); |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2976 |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2977 gaim_conv_im_start_type_again_timeout(im); |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2978 |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2979 if (first || (gaim_conv_im_get_type_again(im) != 0 && |
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2980 time(NULL) > gaim_conv_im_get_type_again(im))) { |
4359 | 2981 |
2982 int timeout = serv_send_typing(gaim_conversation_get_gc(conv), | |
2983 (char *)gaim_conversation_get_name(conv), | |
5872
059d95c67cda
[gaim-migrate @ 6304]
Christian Hammond <chipx86@chipx86.com>
parents:
5860
diff
changeset
|
2984 GAIM_TYPING); |
4359 | 2985 |
2986 if (timeout) | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2987 gaim_conv_im_set_type_again(im, time(NULL) + timeout); |
4359 | 2988 else |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2989 gaim_conv_im_set_type_again(im, 0); |
4359 | 2990 } |
2991 } | |
2992 | |
4736 | 2993 static void |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
2994 update_typing_icon(GaimConversation *conv) |
4736 | 2995 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
2996 GaimGtkWindow *gtkwin; |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
2997 GaimConvIm *im = NULL; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
2998 GaimGtkConversation *gtkconv = GAIM_GTK_CONVERSATION(conv); |
4736 | 2999 |
3000 gtkwin = GAIM_GTK_WINDOW(gaim_conversation_get_window(conv)); | |
3001 | |
3002 if(gaim_conversation_get_type(conv) == GAIM_CONV_IM) | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
3003 im = GAIM_CONV_IM(conv); |
4736 | 3004 |
3005 if(gtkwin->menu.typing_icon) { | |
3006 gtk_widget_destroy(gtkwin->menu.typing_icon); | |
3007 gtkwin->menu.typing_icon = NULL; | |
3008 } | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
3009 if(im && gaim_conv_im_get_typing_state(im) == GAIM_TYPING) { |
4736 | 3010 gtkwin->menu.typing_icon = gtk_image_menu_item_new(); |
3011 gtk_image_menu_item_set_image( | |
3012 GTK_IMAGE_MENU_ITEM(gtkwin->menu.typing_icon), | |
3013 gtk_image_new_from_stock(GAIM_STOCK_TYPING, | |
3014 GTK_ICON_SIZE_MENU)); | |
4757 | 3015 gtk_tooltips_set_tip(gtkconv->tooltips, gtkwin->menu.typing_icon, |
4736 | 3016 _("User is typing..."), NULL); |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
3017 } else if(im && gaim_conv_im_get_typing_state(im) == GAIM_TYPED) { |
4736 | 3018 gtkwin->menu.typing_icon = gtk_image_menu_item_new(); |
3019 gtk_image_menu_item_set_image( | |
3020 GTK_IMAGE_MENU_ITEM(gtkwin->menu.typing_icon), | |
3021 gtk_image_new_from_stock(GAIM_STOCK_TYPED, | |
3022 GTK_ICON_SIZE_MENU)); | |
4757 | 3023 gtk_tooltips_set_tip(gtkconv->tooltips, gtkwin->menu.typing_icon, |
4736 | 3024 _("User has typed something and paused"), NULL); |
3025 } | |
3026 | |
3027 if(gtkwin->menu.typing_icon) { | |
3028 gtk_menu_item_set_right_justified( | |
3029 GTK_MENU_ITEM(gtkwin->menu.typing_icon), TRUE); | |
3030 gtk_widget_show_all(gtkwin->menu.typing_icon); | |
3031 gtk_menu_shell_append(GTK_MENU_SHELL(gtkwin->menu.menubar), | |
3032 gtkwin->menu.typing_icon); | |
3033 } | |
3034 } | |
3035 | |
4685 | 3036 static gboolean |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
3037 update_send_as_selection(GaimConvWindow *win) |
4359 | 3038 { |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
3039 GaimAccount *account; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
3040 GaimConversation *conv; |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
3041 GaimGtkWindow *gtkwin; |
4359 | 3042 GtkWidget *menu; |
3043 GList *child; | |
3044 | |
7090
04f9f7440bc3
[gaim-migrate @ 7655]
Christian Hammond <chipx86@chipx86.com>
parents:
7089
diff
changeset
|
3045 if (g_list_find(gaim_get_windows(), win) == NULL) |
04f9f7440bc3
[gaim-migrate @ 7655]
Christian Hammond <chipx86@chipx86.com>
parents:
7089
diff
changeset
|
3046 return FALSE; |
4849 | 3047 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
3048 conv = gaim_conv_window_get_active_conversation(win); |
4359 | 3049 |
5860
52d5fad43950
[gaim-migrate @ 6291]
Christian Hammond <chipx86@chipx86.com>
parents:
5858
diff
changeset
|
3050 if (conv == NULL) |
52d5fad43950
[gaim-migrate @ 6291]
Christian Hammond <chipx86@chipx86.com>
parents:
5858
diff
changeset
|
3051 return FALSE; |
5678
619bca773b2e
[gaim-migrate @ 6096]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
3052 |
619bca773b2e
[gaim-migrate @ 6096]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
3053 account = gaim_conversation_get_account(conv); |
619bca773b2e
[gaim-migrate @ 6096]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
3054 gtkwin = GAIM_GTK_WINDOW(win); |
619bca773b2e
[gaim-migrate @ 6096]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
3055 |
4364
fa56829b9587
[gaim-migrate @ 4630]
Christian Hammond <chipx86@chipx86.com>
parents:
4363
diff
changeset
|
3056 if (gtkwin->menu.send_as == NULL) |
4685 | 3057 return FALSE; |
4364
fa56829b9587
[gaim-migrate @ 4630]
Christian Hammond <chipx86@chipx86.com>
parents:
4363
diff
changeset
|
3058 |
4359 | 3059 gtk_widget_show(gtkwin->menu.send_as); |
3060 | |
3061 menu = gtk_menu_item_get_submenu( | |
3062 GTK_MENU_ITEM(gtkwin->menu.send_as)); | |
3063 | |
3064 for (child = gtk_container_get_children(GTK_CONTAINER(menu)); | |
3065 child != NULL; | |
3066 child = child->next) { | |
3067 | |
3068 GtkWidget *item = child->data; | |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
3069 GaimAccount *item_account = g_object_get_data(G_OBJECT(item), |
4673 | 3070 "gaim_account"); |
3071 | |
3072 if (account == item_account) { | |
4359 | 3073 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(item), TRUE); |
3074 break; | |
3075 } | |
3076 } | |
6030
54c37db13279
[gaim-migrate @ 6480]
Christian Hammond <chipx86@chipx86.com>
parents:
6016
diff
changeset
|
3077 |
4685 | 3078 return FALSE; |
4359 | 3079 } |
3080 | |
3081 static void | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
3082 generate_send_as_items(GaimConvWindow *win, GaimConversation *deleted_conv) |
4359 | 3083 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
3084 GaimGtkWindow *gtkwin; |
4359 | 3085 GtkWidget *menu; |
3086 GtkWidget *menuitem; | |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
3087 GList *gcs; |
4359 | 3088 GList *convs; |
3089 GSList *group = NULL; | |
3090 gboolean first_offline = TRUE; | |
3091 gboolean found_online = FALSE; | |
4669
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3092 GtkSizeGroup *sg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL); |
4359 | 3093 |
3094 gtkwin = GAIM_GTK_WINDOW(win); | |
3095 | |
3096 if (gtkwin->menu.send_as != NULL) | |
3097 gtk_widget_destroy(gtkwin->menu.send_as); | |
3098 | |
3099 /* See if we have > 1 connection active. */ | |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
3100 if (g_list_length(gaim_connections_get_all()) < 2) { |
4359 | 3101 /* Now make sure we don't have any Offline entries. */ |
3102 gboolean found_offline = FALSE; | |
3103 | |
3104 for (convs = gaim_get_conversations(); | |
3105 convs != NULL; | |
3106 convs = convs->next) { | |
3107 | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
3108 GaimConversation *conv; |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
3109 GaimAccount *account; |
4491 | 3110 |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
3111 conv = (GaimConversation *)convs->data; |
4491 | 3112 account = gaim_conversation_get_account(conv); |
3113 | |
6495
8ce66049ce68
[gaim-migrate @ 7010]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
3114 if (account != NULL && account->gc == NULL) { |
4359 | 3115 found_offline = TRUE; |
3116 break; | |
3117 } | |
3118 } | |
3119 | |
3120 if (!found_offline) { | |
3121 gtkwin->menu.send_as = NULL; | |
3122 return; | |
3123 } | |
3124 } | |
3125 | |
3126 /* Build the Send As menu */ | |
3127 gtkwin->menu.send_as = gtk_menu_item_new_with_mnemonic(_("_Send As")); | |
3128 gtk_widget_show(gtkwin->menu.send_as); | |
3129 | |
3130 menu = gtk_menu_new(); | |
7857
43f63ff8a6d8
[gaim-migrate @ 8511]
Christian Hammond <chipx86@chipx86.com>
parents:
7855
diff
changeset
|
3131 gtk_menu_shell_insert(GTK_MENU_SHELL(gtkwin->menu.menubar), |
43f63ff8a6d8
[gaim-migrate @ 8511]
Christian Hammond <chipx86@chipx86.com>
parents:
7855
diff
changeset
|
3132 gtkwin->menu.send_as, 2); |
4359 | 3133 gtk_menu_item_set_submenu(GTK_MENU_ITEM(gtkwin->menu.send_as), menu); |
3134 | |
3135 gtk_widget_show(menu); | |
3136 | |
3137 /* Fill it with entries. */ | |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
3138 for (gcs = gaim_connections_get_all(); gcs != NULL; gcs = gcs->next) { |
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
3139 |
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
3140 GaimConnection *gc; |
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
3141 GaimAccount *account; |
4669
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3142 GtkWidget *box; |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3143 GtkWidget *label; |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3144 GtkWidget *image; |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3145 GdkPixbuf *pixbuf, *scale; |
4359 | 3146 |
3147 found_online = TRUE; | |
3148 | |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
3149 gc = (GaimConnection *)gcs->data; |
4359 | 3150 |
4669
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3151 /* Create a pixmap for the protocol icon. */ |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3152 pixbuf = create_prpl_icon(gc->account); |
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3153 scale = gdk_pixbuf_scale_simple(pixbuf, 16, 16, GDK_INTERP_BILINEAR); |
4669
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3154 |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3155 /* Now convert it to GtkImage */ |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3156 if (pixbuf == NULL) |
4669
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3157 image = gtk_image_new(); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3158 else |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3159 image = gtk_image_new_from_pixbuf(scale); |
4669
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3160 |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3161 gtk_size_group_add_widget(sg, image); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3162 |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3163 g_object_unref(G_OBJECT(scale)); |
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3164 g_object_unref(G_OBJECT(pixbuf)); |
4669
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3165 |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
3166 account = gaim_connection_get_account(gc); |
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
3167 |
4669
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3168 /* Make our menu item */ |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
3169 menuitem = gtk_radio_menu_item_new_with_label(group, |
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
3170 gaim_account_get_username(account)); |
4793 | 3171 group = gtk_radio_menu_item_get_group(GTK_RADIO_MENU_ITEM(menuitem)); |
4359 | 3172 |
4669
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3173 /* Do some evil, see some evil, speak some evil. */ |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3174 box = gtk_hbox_new(FALSE, 0); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3175 |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3176 label = gtk_bin_get_child(GTK_BIN(menuitem)); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3177 g_object_ref(label); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3178 gtk_container_remove(GTK_CONTAINER(menuitem), label); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3179 |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3180 gtk_box_pack_start(GTK_BOX(box), image, FALSE, FALSE, 0); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3181 gtk_box_pack_start(GTK_BOX(box), label, TRUE, TRUE, 4); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3182 |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3183 g_object_unref(label); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3184 |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3185 gtk_container_add(GTK_CONTAINER(menuitem), box); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3186 |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3187 gtk_widget_show(label); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3188 gtk_widget_show(image); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3189 gtk_widget_show(box); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3190 |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3191 /* Set our data and callbacks. */ |
4359 | 3192 g_object_set_data(G_OBJECT(menuitem), "user_data", win); |
4673 | 3193 g_object_set_data(G_OBJECT(menuitem), "gaim_account", gc->account); |
4359 | 3194 |
4786 | 3195 g_signal_connect(G_OBJECT(menuitem), "activate", |
4673 | 3196 G_CALLBACK(menu_conv_sel_send_cb), NULL); |
4359 | 3197 |
3198 gtk_widget_show(menuitem); | |
3199 gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem); | |
3200 } | |
3201 | |
3202 /* | |
3203 * Fill it with any accounts that still has an open (yet disabled) window | |
3204 * (signed off accounts with a window open). | |
3205 */ | |
3206 for (convs = gaim_get_conversations(); | |
3207 convs != NULL; | |
3208 convs = convs->next) { | |
3209 | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
3210 GaimConversation *conv; |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
3211 GaimAccount *account; |
4669
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3212 GtkWidget *box; |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3213 GtkWidget *label; |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3214 GtkWidget *image; |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3215 GdkPixbuf *pixbuf, *scale; |
4359 | 3216 |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
3217 conv = (GaimConversation *)convs->data; |
4360
c435a29370b8
[gaim-migrate @ 4626]
Christian Hammond <chipx86@chipx86.com>
parents:
4359
diff
changeset
|
3218 |
c435a29370b8
[gaim-migrate @ 4626]
Christian Hammond <chipx86@chipx86.com>
parents:
4359
diff
changeset
|
3219 if (conv == deleted_conv) |
c435a29370b8
[gaim-migrate @ 4626]
Christian Hammond <chipx86@chipx86.com>
parents:
4359
diff
changeset
|
3220 continue; |
c435a29370b8
[gaim-migrate @ 4626]
Christian Hammond <chipx86@chipx86.com>
parents:
4359
diff
changeset
|
3221 |
4491 | 3222 account = gaim_conversation_get_account(conv); |
3223 | |
6495
8ce66049ce68
[gaim-migrate @ 7010]
Christian Hammond <chipx86@chipx86.com>
parents:
6485
diff
changeset
|
3224 if (account != NULL && account->gc == NULL) { |
4359 | 3225 if (first_offline && found_online) { |
3226 menuitem = gtk_separator_menu_item_new(); | |
3227 gtk_widget_show(menuitem); | |
3228 gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem); | |
3229 | |
3230 first_offline = FALSE; | |
3231 } | |
3232 | |
4669
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3233 /* Create a pixmap for the protocol icon. */ |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3234 pixbuf = create_prpl_icon(account); |
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3235 scale = gdk_pixbuf_scale_simple(pixbuf, 16, 16, |
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3236 GDK_INTERP_BILINEAR); |
4669
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3237 |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3238 /* Now convert it to GtkImage */ |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3239 if (pixbuf == NULL) |
4669
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3240 image = gtk_image_new(); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3241 else |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3242 image = gtk_image_new_from_pixbuf(scale); |
4669
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3243 |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3244 gtk_size_group_add_widget(sg, image); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3245 |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3246 if (scale != NULL) g_object_unref(scale); |
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3247 if (pixbuf != NULL) g_object_unref(pixbuf); |
4669
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3248 |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3249 /* Make our menu item */ |
4359 | 3250 menuitem = gtk_radio_menu_item_new_with_label(group, |
4491 | 3251 account->username); |
4793 | 3252 group = gtk_radio_menu_item_get_group(GTK_RADIO_MENU_ITEM(menuitem)); |
4359 | 3253 |
4669
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3254 /* Do some evil, see some evil, speak some evil. */ |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3255 box = gtk_hbox_new(FALSE, 0); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3256 |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3257 label = gtk_bin_get_child(GTK_BIN(menuitem)); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3258 g_object_ref(label); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3259 gtk_container_remove(GTK_CONTAINER(menuitem), label); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3260 |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3261 gtk_box_pack_start(GTK_BOX(box), image, FALSE, FALSE, 0); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3262 gtk_box_pack_start(GTK_BOX(box), label, TRUE, TRUE, 4); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3263 |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3264 g_object_unref(label); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3265 |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3266 gtk_container_add(GTK_CONTAINER(menuitem), box); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3267 |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3268 gtk_widget_show(label); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3269 gtk_widget_show(image); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3270 gtk_widget_show(box); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3271 |
4359 | 3272 gtk_widget_set_sensitive(menuitem, FALSE); |
4786 | 3273 g_object_set_data(G_OBJECT(menuitem), "user_data", win); |
4674 | 3274 g_object_set_data(G_OBJECT(menuitem), "gaim_account", account); |
4359 | 3275 |
4786 | 3276 g_signal_connect(G_OBJECT(menuitem), "activate", |
5902
6889b89cab90
[gaim-migrate @ 6334]
Christian Hammond <chipx86@chipx86.com>
parents:
5901
diff
changeset
|
3277 G_CALLBACK(menu_conv_sel_send_cb), NULL); |
4786 | 3278 |
4359 | 3279 gtk_widget_show(menuitem); |
3280 gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem); | |
3281 } | |
3282 } | |
3283 | |
4669
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3284 g_object_unref(sg); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
3285 |
4359 | 3286 gtk_widget_show(gtkwin->menu.send_as); |
3287 update_send_as_selection(win); | |
3288 } | |
3289 | |
3290 static GList * | |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
3291 generate_invite_user_names(GaimConnection *gc) |
4359 | 3292 { |
6695 | 3293 GaimBlistNode *gnode,*cnode,*bnode; |
4359 | 3294 static GList *tmp = NULL; |
3295 | |
3296 if (tmp) | |
3297 g_list_free(tmp); | |
3298 | |
3299 tmp = g_list_append(NULL, ""); | |
3300 | |
3301 if (gc != NULL) { | |
4785 | 3302 for(gnode = gaim_get_blist()->root; gnode; gnode = gnode->next) { |
3303 if(!GAIM_BLIST_NODE_IS_GROUP(gnode)) | |
3304 continue; | |
6695 | 3305 for(cnode = gnode->child; cnode; cnode = cnode->next) { |
3306 if(!GAIM_BLIST_NODE_IS_CONTACT(cnode)) | |
4785 | 3307 continue; |
6695 | 3308 for(bnode = cnode->child; bnode; bnode = bnode->next) { |
3309 GaimBuddy *buddy; | |
3310 | |
3311 if(!GAIM_BLIST_NODE_IS_BUDDY(bnode)) | |
3312 continue; | |
3313 | |
3314 buddy = (GaimBuddy *)bnode; | |
3315 | |
3316 if (buddy->account == gc->account && | |
3317 GAIM_BUDDY_IS_ONLINE(buddy)) | |
3318 tmp = g_list_append(tmp, buddy->name); | |
3319 } | |
4359 | 3320 } |
3321 } | |
3322 } | |
3323 | |
3324 return tmp; | |
3325 } | |
3326 | |
9498 | 3327 static GdkPixbuf * |
9554 | 3328 get_chat_buddy_status_icon(GaimConvChat *chat, const char *name, GaimConvChatBuddyFlags flags) |
9498 | 3329 { |
9554 | 3330 GdkPixbuf *pixbuf, *scale, *scale2; |
9498 | 3331 char *filename; |
9554 | 3332 char *image = NULL; |
3333 | |
3334 if (flags & GAIM_CBFLAGS_FOUNDER) { | |
9588 | 3335 image = g_strdup("founder.png"); |
9554 | 3336 } else if (flags & GAIM_CBFLAGS_OP) { |
9588 | 3337 image = g_strdup("op.png"); |
9554 | 3338 } else if (flags & GAIM_CBFLAGS_HALFOP) { |
9588 | 3339 image = g_strdup("halfop.png"); |
9554 | 3340 } else if (flags & GAIM_CBFLAGS_VOICE) { |
9588 | 3341 image = g_strdup("voice.png"); |
9554 | 3342 } else if ((!flags) && gaim_conv_chat_is_user_ignored(chat, name)) { |
9588 | 3343 image = g_strdup("ignored.png"); |
9554 | 3344 } |
3345 if (image) { | |
3346 filename = g_build_filename(DATADIR, "pixmaps", "gaim", "status", "default", image, NULL); | |
3347 g_free(image); | |
9498 | 3348 pixbuf = gdk_pixbuf_new_from_file(filename, NULL); |
3349 g_free(filename); | |
3350 if (!pixbuf) | |
3351 return NULL; | |
3352 scale = gdk_pixbuf_scale_simple(pixbuf, 15, 15, GDK_INTERP_BILINEAR); | |
3353 g_object_unref(pixbuf); | |
9554 | 3354 if (flags && gaim_conv_chat_is_user_ignored(chat, name)) { |
9588 | 3355 filename = g_build_filename(DATADIR, "pixmaps", "gaim", "status", "default", "ignored.png", NULL); |
9554 | 3356 pixbuf = gdk_pixbuf_new_from_file(filename, NULL); |
3357 g_free(filename); | |
3358 scale2 = gdk_pixbuf_scale_simple(pixbuf, 15, 15, GDK_INTERP_BILINEAR); | |
3359 g_object_unref(pixbuf); | |
3360 gdk_pixbuf_composite(scale2, scale, 0, 0, 15, 15, 0, 0, 1, 1, GDK_INTERP_BILINEAR, 192); | |
3361 g_object_unref(scale2); | |
3362 } | |
9498 | 3363 return scale; |
3364 } | |
3365 | |
3366 return NULL; | |
3367 } | |
3368 | |
4359 | 3369 static void |
9554 | 3370 add_chat_buddy_common(GaimConversation *conv, const char *name) |
4359 | 3371 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
3372 GaimGtkConversation *gtkconv; |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
3373 GaimGtkChatPane *gtkchat; |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
3374 GaimConvChat *chat; |
9554 | 3375 GaimConvChatBuddyFlags flags; |
4359 | 3376 GtkTreeIter iter; |
3377 GtkListStore *ls; | |
9498 | 3378 GdkPixbuf *pixbuf; |
4359 | 3379 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
3380 chat = GAIM_CONV_CHAT(conv); |
4359 | 3381 gtkconv = GAIM_GTK_CONVERSATION(conv); |
3382 gtkchat = gtkconv->u.chat; | |
3383 | |
3384 ls = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list))); | |
3385 | |
9554 | 3386 flags = gaim_conv_chat_user_get_flags(chat, name); |
3387 pixbuf = get_chat_buddy_status_icon(chat, name, flags); | |
9498 | 3388 |
4359 | 3389 gtk_list_store_append(ls, &iter); |
9498 | 3390 gtk_list_store_set(ls, &iter, CHAT_USERS_ICON_COLUMN, pixbuf, |
9554 | 3391 CHAT_USERS_NAME_COLUMN, name, CHAT_USERS_FLAGS_COLUMN, flags, -1); |
9498 | 3392 gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(ls), CHAT_USERS_NAME_COLUMN, |
4359 | 3393 GTK_SORT_ASCENDING); |
9554 | 3394 if (pixbuf) |
3395 g_object_unref(pixbuf); | |
4359 | 3396 } |
3397 | |
9605 | 3398 static gboolean |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
3399 tab_complete(GaimConversation *conv) |
4359 | 3400 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
3401 GaimGtkConversation *gtkconv; |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
3402 GaimConvChat *chat; |
4359 | 3403 GtkTextIter cursor, word_start, start_buffer; |
3404 int start; | |
3405 int most_matched = -1; | |
3406 char *entered, *partial = NULL; | |
3407 char *text; | |
8021 | 3408 char *nick_partial; |
9605 | 3409 const char *prefix; |
4359 | 3410 GList *matches = NULL; |
9605 | 3411 GList *list = NULL; |
3412 GList *l = NULL; | |
3413 gboolean command = FALSE; | |
4359 | 3414 |
3415 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
3416 | |
3417 gtk_text_buffer_get_start_iter(gtkconv->entry_buffer, &start_buffer); | |
3418 gtk_text_buffer_get_iter_at_mark(gtkconv->entry_buffer, &cursor, | |
3419 gtk_text_buffer_get_insert(gtkconv->entry_buffer)); | |
3420 | |
3421 word_start = cursor; | |
3422 | |
3423 /* if there's nothing there just return */ | |
3424 if (!gtk_text_iter_compare(&cursor, &start_buffer)) | |
9605 | 3425 return (gaim_conversation_get_type(conv) == GAIM_CONV_CHAT) ? TRUE : FALSE; |
6725
e62a504c83d0
[gaim-migrate @ 7252]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
3426 |
4359 | 3427 text = gtk_text_buffer_get_text(gtkconv->entry_buffer, &start_buffer, |
3428 &cursor, FALSE); | |
3429 | |
3430 /* if we're at the end of ": " we need to move back 2 spaces */ | |
3431 start = strlen(text) - 1; | |
3432 | |
8021 | 3433 if (strlen(text) >= 2 && !strncmp(&text[start-1], ": ", 2)) { |
4359 | 3434 gtk_text_iter_backward_chars(&word_start, 2); |
8021 | 3435 start-=2; |
3436 } | |
4359 | 3437 |
3438 /* find the start of the word that we're tabbing */ | |
3439 while (start >= 0 && text[start] != ' ') { | |
3440 gtk_text_iter_backward_char(&word_start); | |
3441 start--; | |
3442 } | |
3443 | |
9605 | 3444 prefix = gaim_gtk_get_cmd_prefix(); |
3445 if (start == -1 && (strlen(text) >= strlen(prefix)) && !strncmp(text, prefix, strlen(prefix))) { | |
3446 command = TRUE; | |
3447 gtk_text_iter_forward_chars(&word_start, strlen(prefix)); | |
3448 } | |
3449 | |
4359 | 3450 g_free(text); |
3451 | |
3452 entered = gtk_text_buffer_get_text(gtkconv->entry_buffer, &word_start, | |
3453 &cursor, FALSE); | |
3454 | |
8021 | 3455 if (!g_utf8_strlen(entered, -1)) { |
4359 | 3456 g_free(entered); |
9605 | 3457 return (gaim_conversation_get_type(conv) == GAIM_CONV_CHAT) ? TRUE : FALSE; |
4359 | 3458 } |
3459 | |
8021 | 3460 nick_partial = g_malloc(strlen(entered)+1); |
3461 | |
9605 | 3462 if (command) { |
3463 list = gaim_cmd_list(conv); | |
3464 } else if (gaim_conversation_get_type(conv) == GAIM_CONV_CHAT) { | |
3465 chat = GAIM_CONV_CHAT(conv); | |
3466 list = gaim_conv_chat_get_users(chat); | |
3467 } else { | |
3468 g_free(nick_partial); | |
3469 g_free(entered); | |
3470 return FALSE; | |
3471 } | |
3472 | |
3473 for (l = list; l; l = l->next) { | |
3474 char *name; | |
3475 | |
3476 if (command) | |
3477 name = l->data; | |
3478 else { | |
3479 GaimConvChatBuddy *cb = l->data; | |
3480 name = cb->name; | |
3481 } | |
3482 | |
3483 strncpy(nick_partial, name, strlen(entered)); | |
8172 | 3484 nick_partial[strlen(entered)] = '\0'; |
8021 | 3485 if(gaim_utf8_strcasecmp(nick_partial, entered)) |
3486 continue; | |
4359 | 3487 |
3488 /* if we're here, it's a possible completion */ | |
3489 | |
3490 if (most_matched == -1) { | |
3491 /* | |
3492 * this will only get called once, since from now | |
3493 * on most_matched is >= 0 | |
3494 */ | |
9605 | 3495 most_matched = strlen(name); |
3496 partial = g_strdup(name); | |
4359 | 3497 } |
3498 else if (most_matched) { | |
9605 | 3499 char *tmp = g_strdup(name); |
8021 | 3500 |
3501 while (gaim_utf8_strcasecmp(tmp, partial)) { | |
3502 partial[most_matched] = '\0'; | |
3503 if(most_matched < strlen(tmp)) | |
3504 tmp[most_matched] = '\0'; | |
4359 | 3505 most_matched--; |
8021 | 3506 } |
8079 | 3507 most_matched++; |
8021 | 3508 |
3509 g_free(tmp); | |
4359 | 3510 } |
3511 | |
9605 | 3512 matches = g_list_append(matches, name); |
4359 | 3513 } |
3514 | |
8021 | 3515 g_free(nick_partial); |
3516 | |
4359 | 3517 /* we're only here if we're doing new style */ |
3518 | |
3519 /* if there weren't any matches, return */ | |
3520 if (!matches) { | |
3521 /* if matches isn't set partials won't be either */ | |
3522 g_free(entered); | |
9605 | 3523 if (command) |
3524 g_list_free(list); | |
3525 return (gaim_conversation_get_type(conv) == GAIM_CONV_CHAT) ? TRUE : FALSE; | |
4359 | 3526 } |
3527 | |
3528 gtk_text_buffer_delete(gtkconv->entry_buffer, &word_start, &cursor); | |
3529 | |
3530 if (!matches->next) { | |
3531 /* there was only one match. fill it in. */ | |
3532 gtk_text_buffer_get_start_iter(gtkconv->entry_buffer, &start_buffer); | |
3533 gtk_text_buffer_get_iter_at_mark(gtkconv->entry_buffer, &cursor, | |
3534 gtk_text_buffer_get_insert(gtkconv->entry_buffer)); | |
3535 | |
3536 if (!gtk_text_iter_compare(&cursor, &start_buffer)) { | |
3537 char *tmp = g_strdup_printf("%s: ", (char *)matches->data); | |
3538 gtk_text_buffer_insert_at_cursor(gtkconv->entry_buffer, tmp, -1); | |
3539 g_free(tmp); | |
3540 } | |
3541 else | |
3542 gtk_text_buffer_insert_at_cursor(gtkconv->entry_buffer, | |
3543 matches->data, -1); | |
3544 | |
3545 matches = g_list_remove(matches, matches->data); | |
3546 } | |
3547 else { | |
3548 /* | |
3549 * there were lots of matches, fill in as much as possible | |
3550 * and display all of them | |
3551 */ | |
3552 char *addthis = g_malloc0(1); | |
3553 | |
3554 while (matches) { | |
3555 char *tmp = addthis; | |
3556 addthis = g_strconcat(tmp, matches->data, " ", NULL); | |
3557 g_free(tmp); | |
3558 matches = g_list_remove(matches, matches->data); | |
3559 } | |
3560 | |
6982 | 3561 gaim_conversation_write(conv, NULL, addthis, GAIM_MESSAGE_NO_LOG, |
4359 | 3562 time(NULL)); |
3563 gtk_text_buffer_insert_at_cursor(gtkconv->entry_buffer, partial, -1); | |
3564 g_free(addthis); | |
3565 } | |
3566 | |
9605 | 3567 if (command) |
3568 g_list_free(list); | |
4359 | 3569 g_free(entered); |
3570 g_free(partial); | |
9605 | 3571 |
3572 return TRUE; | |
4359 | 3573 } |
3574 | |
3575 static GtkItemFactoryEntry menu_items[] = | |
3576 { | |
3577 /* Conversation menu */ | |
4596 | 3578 { N_("/_Conversation"), NULL, NULL, 0, "<Branch>" }, |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3579 |
7887 | 3580 { N_("/Conversation/New Instant _Message..."), "<CTL>M", menu_new_conv_cb, |
7859 | 3581 0, "<StockItem>", GAIM_STOCK_IM }, |
3582 | |
3583 { "/Conversation/sep0", NULL, NULL, 0, "<Separator>" }, | |
3584 | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
3585 { N_("/Conversation/_Find..."), NULL, menu_find_cb, 0, |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
3586 "<StockItem>", GTK_STOCK_FIND }, |
7859 | 3587 { N_("/Conversation/View _Log"), NULL, menu_view_log_cb, 0, NULL }, |
4596 | 3588 { N_("/Conversation/_Save As..."), NULL, menu_save_as_cb, 0, |
4359 | 3589 "<StockItem>", GTK_STOCK_SAVE_AS }, |
8974 | 3590 { N_("/Conversation/Clear"), "<CTL>L", menu_clear_cb, 0, "<StockItem>", GTK_STOCK_CLEAR }, |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3591 |
4359 | 3592 { "/Conversation/sep1", NULL, NULL, 0, "<Separator>" }, |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3593 |
9468 | 3594 { N_("/Conversation/Se_nd File..."), NULL, menu_send_file_cb, 0, "<StockItem>", GAIM_STOCK_FILE_TRANSFER }, |
5907
18486c860a46
[gaim-migrate @ 6339]
Christian Hammond <chipx86@chipx86.com>
parents:
5902
diff
changeset
|
3595 { N_("/Conversation/Add Buddy _Pounce..."), NULL, menu_add_pounce_cb, |
18486c860a46
[gaim-migrate @ 6339]
Christian Hammond <chipx86@chipx86.com>
parents:
5902
diff
changeset
|
3596 0, NULL }, |
7859 | 3597 { N_("/Conversation/_Get Info"), NULL, menu_get_info_cb, 0, |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3598 "<StockItem>", GAIM_STOCK_INFO }, |
7859 | 3599 { N_("/Conversation/_Warn..."), NULL, menu_warn_cb, 0, |
3600 "<StockItem>", GAIM_STOCK_WARN }, | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3601 { N_("/Conversation/In_vite..."), NULL, menu_invite_cb, 0, |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3602 "<StockItem>", GAIM_STOCK_INVITE }, |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3603 |
5907
18486c860a46
[gaim-migrate @ 6339]
Christian Hammond <chipx86@chipx86.com>
parents:
5902
diff
changeset
|
3604 { "/Conversation/sep2", NULL, NULL, 0, "<Separator>" }, |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3605 |
7859 | 3606 { N_("/Conversation/A_lias..."), NULL, menu_alias_cb, 0, |
3607 "<StockItem>", GAIM_STOCK_EDIT }, | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3608 { N_("/Conversation/_Block..."), NULL, menu_block_cb, 0, |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3609 "<StockItem>", GAIM_STOCK_BLOCK }, |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3610 { N_("/Conversation/_Add..."), NULL, menu_add_remove_cb, 0, |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3611 "<StockItem>", GTK_STOCK_ADD }, |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3612 { N_("/Conversation/_Remove..."), NULL, menu_add_remove_cb, 0, |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3613 "<StockItem>", GTK_STOCK_REMOVE }, |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3614 |
7859 | 3615 { "/Conversation/sep3", NULL, NULL, 0, "<Separator>" }, |
3616 | |
8756 | 3617 { N_("/Conversation/Insert Lin_k..."), NULL, menu_insert_link_cb, 0, |
7859 | 3618 "<StockItem>", GAIM_STOCK_LINK }, |
9287 | 3619 { N_("/Conversation/Insert Imag_e..."), NULL, menu_insert_image_cb, 0, |
7859 | 3620 "<StockItem>", GAIM_STOCK_IMAGE }, |
3621 | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3622 { "/Conversation/sep4", NULL, NULL, 0, "<Separator>" }, |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3623 |
4596 | 3624 { N_("/Conversation/_Close"), NULL, menu_close_conv_cb, 0, |
4359 | 3625 "<StockItem>", GTK_STOCK_CLOSE }, |
3626 | |
3627 /* Options */ | |
4596 | 3628 { N_("/_Options"), NULL, NULL, 0, "<Branch>" }, |
3629 { N_("/Options/Enable _Logging"), NULL, menu_logging_cb, 0, "<CheckItem>" }, | |
3630 { N_("/Options/Enable _Sounds"), NULL, menu_sounds_cb, 0, "<CheckItem>" }, | |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
3631 { N_("/Options/Show Formatting _Toolbar"), NULL, menu_toolbar_cb, 0, "<CheckItem>" }, |
9188 | 3632 { N_("/Options/Show T_imestamps"), "F2", menu_timestamps_cb, 0, "<CheckItem>" }, |
4359 | 3633 }; |
3634 | |
6725
e62a504c83d0
[gaim-migrate @ 7252]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
3635 static const int menu_item_count = |
4359 | 3636 sizeof(menu_items) / sizeof(*menu_items); |
3637 | |
4602
4128761bacb8
[gaim-migrate @ 4889]
Christian Hammond <chipx86@chipx86.com>
parents:
4598
diff
changeset
|
3638 static char * |
4128761bacb8
[gaim-migrate @ 4889]
Christian Hammond <chipx86@chipx86.com>
parents:
4598
diff
changeset
|
3639 item_factory_translate_func (const char *path, gpointer func_data) |
4128761bacb8
[gaim-migrate @ 4889]
Christian Hammond <chipx86@chipx86.com>
parents:
4598
diff
changeset
|
3640 { |
7386 | 3641 return _((char *)path); |
4602
4128761bacb8
[gaim-migrate @ 4889]
Christian Hammond <chipx86@chipx86.com>
parents:
4598
diff
changeset
|
3642 } |
4128761bacb8
[gaim-migrate @ 4889]
Christian Hammond <chipx86@chipx86.com>
parents:
4598
diff
changeset
|
3643 |
4359 | 3644 static GtkWidget * |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
3645 setup_menubar(GaimConvWindow *win) |
4359 | 3646 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
3647 GaimGtkWindow *gtkwin; |
5116 | 3648 GtkAccelGroup *accel_group; |
4359 | 3649 gtkwin = GAIM_GTK_WINDOW(win); |
3650 | |
6398
c9894c0fbc6f
[gaim-migrate @ 6903]
Christian Hammond <chipx86@chipx86.com>
parents:
6395
diff
changeset
|
3651 accel_group = gtk_accel_group_new (); |
c9894c0fbc6f
[gaim-migrate @ 6903]
Christian Hammond <chipx86@chipx86.com>
parents:
6395
diff
changeset
|
3652 gtk_window_add_accel_group (GTK_WINDOW (gtkwin->window), accel_group); |
c9894c0fbc6f
[gaim-migrate @ 6903]
Christian Hammond <chipx86@chipx86.com>
parents:
6395
diff
changeset
|
3653 g_object_unref (accel_group); |
5116 | 3654 |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3655 gtkwin->menu.item_factory = |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3656 gtk_item_factory_new(GTK_TYPE_MENU_BAR, "<main>", accel_group); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3657 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3658 gtk_item_factory_set_translate_func(gtkwin->menu.item_factory, |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3659 item_factory_translate_func, |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3660 NULL, NULL); |
4630 | 3661 |
3662 gtk_item_factory_create_items(gtkwin->menu.item_factory, menu_item_count, | |
4359 | 3663 menu_items, win); |
7420 | 3664 g_signal_connect(G_OBJECT(accel_group), "accel-changed", |
3665 G_CALLBACK(gaim_gtk_save_accels_cb), NULL); | |
4359 | 3666 |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3667 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3668 gtkwin->menu.menubar = |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3669 gtk_item_factory_get_widget(gtkwin->menu.item_factory, "<main>"); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3670 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3671 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3672 gtkwin->menu.view_log = |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3673 gtk_item_factory_get_widget(gtkwin->menu.item_factory, |
7295 | 3674 N_("/Conversation/View Log")); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3675 /* --- */ |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3676 |
9468 | 3677 gtkwin->menu.send_file = |
3678 gtk_item_factory_get_widget(gtkwin->menu.item_factory, | |
3679 N_("/Conversation/Send File...")); | |
9498 | 3680 |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3681 gtkwin->menu.add_pounce = |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3682 gtk_item_factory_get_widget(gtkwin->menu.item_factory, |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3683 N_("/Conversation/Add Buddy Pounce...")); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3684 |
7879 | 3685 /* --- */ |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3686 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3687 gtkwin->menu.get_info = |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3688 gtk_item_factory_get_widget(gtkwin->menu.item_factory, |
7859 | 3689 N_("/Conversation/Get Info")); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3690 |
7879 | 3691 gtkwin->menu.warn = |
3692 gtk_item_factory_get_widget(gtkwin->menu.item_factory, | |
3693 N_("/Conversation/Warn...")); | |
3694 | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3695 gtkwin->menu.invite = |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3696 gtk_item_factory_get_widget(gtkwin->menu.item_factory, |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3697 N_("/Conversation/Invite...")); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3698 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3699 /* --- */ |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3700 |
7879 | 3701 gtkwin->menu.alias = |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3702 gtk_item_factory_get_widget(gtkwin->menu.item_factory, |
7879 | 3703 N_("/Conversation/Alias...")); |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3704 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3705 gtkwin->menu.block = |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3706 gtk_item_factory_get_widget(gtkwin->menu.item_factory, |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3707 N_("/Conversation/Block...")); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3708 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3709 gtkwin->menu.add = |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3710 gtk_item_factory_get_widget(gtkwin->menu.item_factory, |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3711 N_("/Conversation/Add...")); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3712 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3713 gtkwin->menu.remove = |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3714 gtk_item_factory_get_widget(gtkwin->menu.item_factory, |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3715 N_("/Conversation/Remove...")); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3716 |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3717 /* --- */ |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3718 |
7879 | 3719 gtkwin->menu.insert_link = |
3720 gtk_item_factory_get_widget(gtkwin->menu.item_factory, | |
3721 N_("/Conversation/Insert Link...")); | |
3722 | |
3723 gtkwin->menu.insert_image = | |
3724 gtk_item_factory_get_widget(gtkwin->menu.item_factory, | |
3725 N_("/Conversation/Insert Image...")); | |
3726 | |
3727 /* --- */ | |
3728 | |
5908
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3729 gtkwin->menu.logging = |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3730 gtk_item_factory_get_widget(gtkwin->menu.item_factory, |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3731 N_("/Options/Enable Logging")); |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3732 gtkwin->menu.sounds = |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3733 gtk_item_factory_get_widget(gtkwin->menu.item_factory, |
ed8a9a3bf7e2
[gaim-migrate @ 6340]
Christian Hammond <chipx86@chipx86.com>
parents:
5907
diff
changeset
|
3734 N_("/Options/Enable Sounds")); |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
3735 gtkwin->menu.show_formatting_toolbar = |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
3736 gtk_item_factory_get_widget(gtkwin->menu.item_factory, |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
3737 N_("/Options/Show Formatting Toolbar")); |
9188 | 3738 gtkwin->menu.show_timestamps = |
3739 gtk_item_factory_get_widget(gtkwin->menu.item_factory, | |
3740 N_("/Options/Show Timestamps")); | |
4359 | 3741 |
4360
c435a29370b8
[gaim-migrate @ 4626]
Christian Hammond <chipx86@chipx86.com>
parents:
4359
diff
changeset
|
3742 generate_send_as_items(win, NULL); |
4359 | 3743 |
3744 gtk_widget_show(gtkwin->menu.menubar); | |
4931 | 3745 |
3746 return gtkwin->menu.menubar; | |
4359 | 3747 } |
3748 | |
9759 | 3749 GtkWidget * |
3750 gaim_gtkconv_button_new(const char *icon, const char *text, const char *tooltip, GtkTooltips *tooltips, void *callback, void *data) | |
9749 | 3751 { |
3752 GtkWidget *button; | |
3753 int buttons; | |
3754 | |
3755 buttons = gaim_prefs_get_int("/gaim/gtk/conversations/button_type"); | |
3756 button = gaim_pixbuf_button_from_stock( | |
3757 (buttons == GAIM_BUTTON_IMAGE ? NULL : text), | |
3758 (buttons == GAIM_BUTTON_TEXT ? NULL : icon), | |
9750 | 3759 GAIM_BUTTON_VERTICAL); |
9766 | 3760 if (tooltip != NULL) |
3761 gtk_tooltips_set_tip(tooltips, button, tooltip, NULL); | |
9749 | 3762 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE); |
9766 | 3763 if (callback != NULL) |
3764 g_signal_connect(G_OBJECT(button), "clicked", | |
3765 G_CALLBACK(callback), data); | |
9749 | 3766 |
3767 return button; | |
3768 } | |
3769 | |
4359 | 3770 static void |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
3771 setup_im_buttons(GaimConversation *conv, GtkWidget *parent) |
4359 | 3772 { |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
3773 GaimConnection *gc; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
3774 GaimGtkConversation *gtkconv; |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
3775 GaimGtkImPane *gtkim; |
8811 | 3776 GaimButtonStyle button_type; |
9749 | 3777 GList *children; |
4359 | 3778 |
3779 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
3780 gtkim = gtkconv->u.im; | |
3781 gc = gaim_conversation_get_gc(conv); | |
3782 | |
9749 | 3783 /* Remove anything else in our parent */ |
3784 children = gtk_container_get_children(GTK_CONTAINER(parent)); | |
3785 while (children != NULL) { | |
9885 | 3786 if(children->data != gtkim->icon_container) |
3787 gtk_container_remove(GTK_CONTAINER(parent), children->data); | |
9749 | 3788 children = g_list_remove(children, children->data); |
3789 } | |
3790 | |
9750 | 3791 /* The buttons, from left to right */ |
9749 | 3792 |
3793 /* Block button */ | |
9759 | 3794 gtkim->block = gaim_gtkconv_button_new(GAIM_STOCK_BLOCK, _("Block"), |
9749 | 3795 _("Block the user"), |
3796 gtkconv->tooltips, block_cb, conv); | |
9750 | 3797 gtk_box_pack_start(GTK_BOX(parent), gtkim->block, TRUE, TRUE, 0); |
9749 | 3798 gtk_size_group_add_widget(gtkconv->sg, gtkim->block); |
3799 | |
3800 /* Send File button */ | |
9759 | 3801 gtkim->send_file = gaim_gtkconv_button_new(GAIM_STOCK_FILE_TRANSFER, _("Send File"), |
9749 | 3802 _("Send a file to the user"), |
3803 gtkconv->tooltips, send_file_cb, conv); | |
9750 | 3804 gtk_box_pack_start(GTK_BOX(parent), gtkim->send_file, TRUE, TRUE, 0); |
9749 | 3805 gtk_size_group_add_widget(gtkconv->sg, gtkim->send_file); |
3806 | |
3807 /* Add button */ | |
9759 | 3808 gtkconv->add = gaim_gtkconv_button_new(GTK_STOCK_ADD, _("Add"), |
9749 | 3809 _("Add the user to your buddy list"), |
3810 gtkconv->tooltips, add_remove_cb, conv); | |
9750 | 3811 gtk_box_pack_start(GTK_BOX(parent), gtkconv->add, TRUE, TRUE, 0); |
9749 | 3812 gtk_size_group_add_widget(gtkconv->sg, gtkconv->add); |
3813 | |
3814 /* Remove button */ | |
9759 | 3815 gtkconv->remove = gaim_gtkconv_button_new(GTK_STOCK_REMOVE, _("Remove"), |
9749 | 3816 _("Remove the user from your buddy list"), |
3817 gtkconv->tooltips, add_remove_cb, conv); | |
9750 | 3818 gtk_box_pack_start(GTK_BOX(parent), gtkconv->remove, TRUE, TRUE, 0); |
9749 | 3819 gtk_size_group_add_widget(gtkconv->sg, gtkconv->remove); |
3820 | |
3821 /* Info button */ | |
9759 | 3822 gtkconv->info = gaim_gtkconv_button_new(GAIM_STOCK_INFO, _("Info"), |
9749 | 3823 _("Get the user's information"), |
3824 gtkconv->tooltips, info_cb, conv); | |
9750 | 3825 gtk_box_pack_start(GTK_BOX(parent), gtkconv->info, TRUE, TRUE, 0); |
9749 | 3826 gtk_size_group_add_widget(gtkconv->sg, gtkconv->info); |
4359 | 3827 |
3828 /* Send button */ | |
9759 | 3829 gtkconv->send = gaim_gtkconv_button_new(GAIM_STOCK_SEND, _("Send"), |
9749 | 3830 _("Send message"), |
3831 gtkconv->tooltips, send_cb, conv); | |
4359 | 3832 gtk_box_pack_end(GTK_BOX(parent), gtkconv->send, FALSE, FALSE, 0); |
3833 | |
3834 /* Separator */ | |
3835 gtkim->sep2 = gtk_vseparator_new(); | |
3836 gtk_box_pack_end(GTK_BOX(parent), gtkim->sep2, FALSE, TRUE, 0); | |
3837 gtk_widget_show(gtkim->sep2); | |
3838 | |
3839 gaim_gtkconv_update_buttons_by_protocol(conv); | |
3840 | |
8811 | 3841 /* Check if the buttons should be visible or not */ |
9150 | 3842 button_type = gaim_prefs_get_int("/gaim/gtk/conversations/button_type"); |
8811 | 3843 if (button_type == GAIM_BUTTON_NONE) |
9749 | 3844 gtk_widget_hide(parent); |
8811 | 3845 else |
9749 | 3846 gtk_widget_show(parent); |
4359 | 3847 } |
3848 | |
3849 static void | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
3850 setup_chat_buttons(GaimConversation *conv, GtkWidget *parent) |
4359 | 3851 { |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
3852 GaimConnection *gc; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
3853 GaimGtkConversation *gtkconv; |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
3854 GaimGtkChatPane *gtkchat; |
8811 | 3855 GaimButtonStyle button_type; |
9750 | 3856 GList *children; |
4359 | 3857 |
3858 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
3859 gtkchat = gtkconv->u.chat; | |
3860 gc = gaim_conversation_get_gc(conv); | |
3861 | |
9750 | 3862 /* Remove anything else in our parent */ |
3863 children = gtk_container_get_children(GTK_CONTAINER(parent)); | |
3864 while (children != NULL) { | |
3865 gtk_container_remove(GTK_CONTAINER(parent), children->data); | |
3866 children = g_list_remove(children, children->data); | |
3867 } | |
3868 | |
3869 /* The buttons, from left to right */ | |
3870 | |
3871 /* Invite */ | |
9759 | 3872 gtkchat->invite = gaim_gtkconv_button_new(GAIM_STOCK_INVITE, _("Invite"), |
9817 | 3873 _("Invite a user"), |
9750 | 3874 gtkconv->tooltips, invite_cb, conv); |
3875 gtk_box_pack_start(GTK_BOX(parent), gtkchat->invite, TRUE, TRUE, 0); | |
3876 gtk_size_group_add_widget(gtkconv->sg, gtkchat->invite); | |
3877 | |
3878 /* Add button */ | |
9759 | 3879 gtkconv->add = gaim_gtkconv_button_new(GTK_STOCK_ADD, _("Add"), |
9750 | 3880 _("Add the chat to your buddy list"), |
3881 gtkconv->tooltips, add_remove_cb, conv); | |
3882 gtk_box_pack_start(GTK_BOX(parent), gtkconv->add, TRUE, TRUE, 0); | |
3883 gtk_size_group_add_widget(gtkconv->sg, gtkconv->add); | |
3884 | |
3885 /* Remove button */ | |
9759 | 3886 gtkconv->remove = gaim_gtkconv_button_new(GTK_STOCK_REMOVE, _("Remove"), |
9750 | 3887 _("Remove the chat from your buddy list"), |
3888 gtkconv->tooltips, add_remove_cb, conv); | |
3889 gtk_box_pack_start(GTK_BOX(parent), gtkconv->remove, TRUE, TRUE, 0); | |
3890 gtk_size_group_add_widget(gtkconv->sg, gtkconv->remove); | |
7996
334ab1319406
[gaim-migrate @ 8673]
Christian Hammond <chipx86@chipx86.com>
parents:
7995
diff
changeset
|
3891 |
4359 | 3892 /* Send button */ |
9759 | 3893 gtkconv->send = gaim_gtkconv_button_new(GAIM_STOCK_SEND, _("Send"), |
9750 | 3894 _("Send message"), |
3895 gtkconv->tooltips, send_cb, conv); | |
4359 | 3896 gtk_box_pack_end(GTK_BOX(parent), gtkconv->send, FALSE, FALSE, 0); |
9750 | 3897 gtk_size_group_add_widget(gtkconv->sg, gtkconv->send); |
4359 | 3898 |
3899 /* Separator */ | |
7996
334ab1319406
[gaim-migrate @ 8673]
Christian Hammond <chipx86@chipx86.com>
parents:
7995
diff
changeset
|
3900 gtkchat->sep = gtk_vseparator_new(); |
334ab1319406
[gaim-migrate @ 8673]
Christian Hammond <chipx86@chipx86.com>
parents:
7995
diff
changeset
|
3901 gtk_box_pack_end(GTK_BOX(parent), gtkchat->sep, FALSE, TRUE, 0); |
334ab1319406
[gaim-migrate @ 8673]
Christian Hammond <chipx86@chipx86.com>
parents:
7995
diff
changeset
|
3902 gtk_widget_show(gtkchat->sep); |
4359 | 3903 |
7996
334ab1319406
[gaim-migrate @ 8673]
Christian Hammond <chipx86@chipx86.com>
parents:
7995
diff
changeset
|
3904 gaim_gtkconv_update_buttons_by_protocol(conv); |
334ab1319406
[gaim-migrate @ 8673]
Christian Hammond <chipx86@chipx86.com>
parents:
7995
diff
changeset
|
3905 |
8811 | 3906 /* Check if the buttons should be visible or not */ |
9150 | 3907 button_type = gaim_prefs_get_int("/gaim/gtk/conversations/button_type"); |
8811 | 3908 if (button_type == GAIM_BUTTON_NONE) |
3909 gtk_widget_hide(gtkconv->bbox); | |
3910 else | |
3911 gtk_widget_show(gtkconv->bbox); | |
4359 | 3912 } |
3913 | |
3914 | |
7971 | 3915 static void topic_callback(GtkWidget *w, GaimConversation *conv) |
3916 { | |
3917 GaimPluginProtocolInfo *prpl_info = NULL; | |
3918 GaimConnection *gc; | |
3919 GaimGtkConversation *gtkconv; | |
3920 GaimGtkChatPane *gtkchat; | |
8858 | 3921 const char *new_topic; |
3922 const char *current_topic; | |
7971 | 3923 |
3924 gc = gaim_conversation_get_gc(conv); | |
3925 | |
3926 if(!gc || !(prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl))) | |
3927 return; | |
3928 | |
3929 if(prpl_info->set_chat_topic == NULL) | |
3930 return; | |
3931 | |
3932 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
3933 gtkchat = gtkconv->u.chat; | |
8858 | 3934 new_topic = gtk_entry_get_text(GTK_ENTRY(gtkchat->topic_text)); |
3935 current_topic = gaim_conv_chat_get_topic(GAIM_CONV_CHAT(conv)); | |
3936 | |
3937 if(current_topic && !g_utf8_collate(new_topic, current_topic)) | |
7971 | 3938 return; |
3939 | |
8858 | 3940 prpl_info->set_chat_topic(gc, gaim_conv_chat_get_id(GAIM_CONV_CHAT(conv)), |
3941 new_topic); | |
7971 | 3942 } |
3943 | |
9554 | 3944 static gint |
3945 sort_chat_users(GtkTreeModel *model, GtkTreeIter *a, GtkTreeIter *b, gpointer userdata) | |
3946 { | |
3947 GaimConvChatBuddyFlags f1 = 0, f2 = 0; | |
3948 char *user1 = NULL, *user2 = NULL; | |
3949 gint ret = 0; | |
3950 | |
3951 gtk_tree_model_get(model, a, CHAT_USERS_NAME_COLUMN, &user1, CHAT_USERS_FLAGS_COLUMN, &f1, -1); | |
3952 gtk_tree_model_get(model, b, CHAT_USERS_NAME_COLUMN, &user2, CHAT_USERS_FLAGS_COLUMN, &f2, -1); | |
3953 | |
3954 if (user1 == NULL || user2 == NULL) { | |
3955 if (!(user1 == NULL && user2 == NULL)) | |
3956 ret = (user1 == NULL) ? -1: 1; | |
3957 } else if (f1 != f2) { | |
3958 /* sort more important users first */ | |
3959 ret = (f1 > f2) ? -1 : 1; | |
3960 } else { | |
3961 ret = g_utf8_collate(user1, user2); | |
3962 } | |
3963 | |
3964 g_free(user1); | |
3965 g_free(user2); | |
3966 | |
3967 return ret; | |
3968 } | |
3969 | |
4359 | 3970 static GtkWidget * |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
3971 setup_chat_pane(GaimConversation *conv) |
4359 | 3972 { |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5204
diff
changeset
|
3973 GaimPluginProtocolInfo *prpl_info = NULL; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
3974 GaimGtkConversation *gtkconv; |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
3975 GaimGtkChatPane *gtkchat; |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
3976 GaimConnection *gc; |
4359 | 3977 GtkWidget *vpaned, *hpaned; |
10080 | 3978 GtkWidget *vbox, *hbox, *frame, *vbox2, *sep; |
4359 | 3979 GtkWidget *lbox, *bbox; |
3980 GtkWidget *label; | |
3981 GtkWidget *list; | |
3982 GtkWidget *button; | |
7949 | 3983 GtkWidget *sw; |
4359 | 3984 GtkListStore *ls; |
3985 GtkCellRenderer *rend; | |
3986 GtkTreeViewColumn *col; | |
9080 | 3987 GList *focus_chain = NULL; |
4359 | 3988 |
3989 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
3990 gtkchat = gtkconv->u.chat; | |
3991 gc = gaim_conversation_get_gc(conv); | |
3992 | |
3993 /* Setup the outer pane. */ | |
3994 vpaned = gtk_vpaned_new(); | |
3995 gtk_widget_show(vpaned); | |
3996 | |
3997 /* Setup the top part of the pane. */ | |
8253
0c5977fd3101
[gaim-migrate @ 8976]
Christian Hammond <chipx86@chipx86.com>
parents:
8252
diff
changeset
|
3998 vbox = gtk_vbox_new(FALSE, 6); |
8914 | 3999 gtk_paned_pack1(GTK_PANED(vpaned), vbox, TRUE, TRUE); |
4359 | 4000 gtk_widget_show(vbox); |
4001 | |
5205
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5204
diff
changeset
|
4002 if (gc != NULL) |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5204
diff
changeset
|
4003 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(gc->prpl); |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5204
diff
changeset
|
4004 |
fefad67de2c7
[gaim-migrate @ 5573]
Christian Hammond <chipx86@chipx86.com>
parents:
5204
diff
changeset
|
4005 if (prpl_info->options & OPT_PROTO_CHAT_TOPIC) |
4359 | 4006 { |
8253
0c5977fd3101
[gaim-migrate @ 8976]
Christian Hammond <chipx86@chipx86.com>
parents:
8252
diff
changeset
|
4007 hbox = gtk_hbox_new(FALSE, 6); |
0c5977fd3101
[gaim-migrate @ 8976]
Christian Hammond <chipx86@chipx86.com>
parents:
8252
diff
changeset
|
4008 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); |
4359 | 4009 gtk_widget_show(hbox); |
4010 | |
4011 label = gtk_label_new(_("Topic:")); | |
8253
0c5977fd3101
[gaim-migrate @ 8976]
Christian Hammond <chipx86@chipx86.com>
parents:
8252
diff
changeset
|
4012 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 0); |
4359 | 4013 gtk_widget_show(label); |
4014 | |
4015 gtkchat->topic_text = gtk_entry_new(); | |
8253
0c5977fd3101
[gaim-migrate @ 8976]
Christian Hammond <chipx86@chipx86.com>
parents:
8252
diff
changeset
|
4016 |
7971 | 4017 if(prpl_info->set_chat_topic == NULL) { |
4018 gtk_editable_set_editable(GTK_EDITABLE(gtkchat->topic_text), FALSE); | |
4019 } else { | |
4020 g_signal_connect(GTK_OBJECT(gtkchat->topic_text), "activate", | |
4021 G_CALLBACK(topic_callback), conv); | |
4022 } | |
4023 | |
8253
0c5977fd3101
[gaim-migrate @ 8976]
Christian Hammond <chipx86@chipx86.com>
parents:
8252
diff
changeset
|
4024 gtk_box_pack_start(GTK_BOX(hbox), gtkchat->topic_text, TRUE, TRUE, 0); |
4359 | 4025 gtk_widget_show(gtkchat->topic_text); |
4026 } | |
4027 | |
4028 /* Setup the horizontal pane. */ | |
4029 hpaned = gtk_hpaned_new(); | |
8253
0c5977fd3101
[gaim-migrate @ 8976]
Christian Hammond <chipx86@chipx86.com>
parents:
8252
diff
changeset
|
4030 gtk_box_pack_start(GTK_BOX(vbox), hpaned, TRUE, TRUE, 0); |
4359 | 4031 gtk_widget_show(hpaned); |
4032 | |
4033 /* Setup the scrolled window to put gtkimhtml in. */ | |
4034 gtkconv->sw = gtk_scrolled_window_new(NULL, NULL); | |
4035 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(gtkconv->sw), | |
8076 | 4036 GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS); |
4359 | 4037 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(gtkconv->sw), |
4038 GTK_SHADOW_IN); | |
4039 gtk_paned_pack1(GTK_PANED(hpaned), gtkconv->sw, TRUE, TRUE); | |
4040 | |
4041 gtk_widget_set_size_request(gtkconv->sw, | |
5550
b18c2a37cc96
[gaim-migrate @ 5951]
Christian Hammond <chipx86@chipx86.com>
parents:
5546
diff
changeset
|
4042 gaim_prefs_get_int("/gaim/gtk/conversations/chat/default_width"), |
b18c2a37cc96
[gaim-migrate @ 5951]
Christian Hammond <chipx86@chipx86.com>
parents:
5546
diff
changeset
|
4043 gaim_prefs_get_int("/gaim/gtk/conversations/chat/default_height")); |
b18c2a37cc96
[gaim-migrate @ 5951]
Christian Hammond <chipx86@chipx86.com>
parents:
5546
diff
changeset
|
4044 |
8914 | 4045 g_signal_connect(G_OBJECT(gtkconv->sw), "size-allocate", |
4046 G_CALLBACK(size_allocate_cb), conv); | |
4047 | |
4359 | 4048 gtk_widget_show(gtkconv->sw); |
4049 | |
4050 /* Setup gtkihmtml. */ | |
4051 gtkconv->imhtml = gtk_imhtml_new(NULL, NULL); | |
9005 | 4052 gtk_widget_set_name(gtkconv->imhtml, "gaim_gtkconv_imhtml"); |
4359 | 4053 gtk_container_add(GTK_CONTAINER(gtkconv->sw), gtkconv->imhtml); |
4054 | |
4055 gtk_imhtml_show_comments(GTK_IMHTML(gtkconv->imhtml), | |
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5484
diff
changeset
|
4056 gaim_prefs_get_bool("/gaim/gtk/conversations/show_timestamps")); |
4359 | 4057 |
4058 g_signal_connect_after(G_OBJECT(gtkconv->imhtml), "button_press_event", | |
4059 G_CALLBACK(entry_stop_rclick_cb), NULL); | |
8105 | 4060 g_signal_connect(G_OBJECT(gtkconv->imhtml), "key_press_event", |
6057 | 4061 G_CALLBACK(refocus_entry_cb), gtkconv); |
8109 | 4062 g_signal_connect(G_OBJECT(gtkconv->imhtml), "key_release_event", |
4063 G_CALLBACK(refocus_entry_cb), gtkconv); | |
4359 | 4064 |
4065 gaim_setup_imhtml(gtkconv->imhtml); | |
4066 gtk_widget_show(gtkconv->imhtml); | |
4067 | |
4068 /* Build the right pane. */ | |
8253
0c5977fd3101
[gaim-migrate @ 8976]
Christian Hammond <chipx86@chipx86.com>
parents:
8252
diff
changeset
|
4069 lbox = gtk_vbox_new(FALSE, 6); |
4409
0521eec12c33
[gaim-migrate @ 4682]
Christian Hammond <chipx86@chipx86.com>
parents:
4398
diff
changeset
|
4070 gtk_paned_pack2(GTK_PANED(hpaned), lbox, FALSE, TRUE); |
4359 | 4071 gtk_widget_show(lbox); |
4072 | |
4073 /* Setup the label telling how many people are in the room. */ | |
4074 gtkchat->count = gtk_label_new(_("0 people in room")); | |
4075 gtk_box_pack_start(GTK_BOX(lbox), gtkchat->count, FALSE, FALSE, 0); | |
4076 gtk_widget_show(gtkchat->count); | |
4077 | |
4078 /* Setup the list of users. */ | |
7949 | 4079 sw = gtk_scrolled_window_new(NULL, NULL); |
4080 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), | |
8076 | 4081 GTK_POLICY_AUTOMATIC, GTK_POLICY_AUTOMATIC); |
7949 | 4082 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(sw), GTK_SHADOW_IN); |
4083 gtk_box_pack_start(GTK_BOX(lbox), sw, TRUE, TRUE, 0); | |
4084 gtk_widget_show(sw); | |
4359 | 4085 |
9554 | 4086 ls = gtk_list_store_new(CHAT_USERS_COLUMNS, GDK_TYPE_PIXBUF, G_TYPE_STRING, |
4087 G_TYPE_INT); | |
4088 gtk_tree_sortable_set_sort_func(GTK_TREE_SORTABLE(ls), CHAT_USERS_NAME_COLUMN, | |
4089 sort_chat_users, NULL, NULL); | |
9498 | 4090 gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(ls), CHAT_USERS_NAME_COLUMN, |
4359 | 4091 GTK_SORT_ASCENDING); |
4092 | |
4093 list = gtk_tree_view_new_with_model(GTK_TREE_MODEL(ls)); | |
4094 | |
9498 | 4095 rend = gtk_cell_renderer_pixbuf_new(); |
4096 | |
4359 | 4097 col = gtk_tree_view_column_new_with_attributes(NULL, rend, |
9498 | 4098 "pixbuf", CHAT_USERS_ICON_COLUMN, NULL); |
9554 | 4099 gtk_tree_view_column_set_clickable(GTK_TREE_VIEW_COLUMN(col), TRUE); |
4100 | |
9498 | 4101 gtk_tree_view_append_column(GTK_TREE_VIEW(list), col); |
4359 | 4102 |
4103 g_signal_connect(G_OBJECT(list), "button_press_event", | |
4104 G_CALLBACK(right_click_chat_cb), conv); | |
8143 | 4105 g_signal_connect(G_OBJECT(list), "popup-menu", |
4106 G_CALLBACK(gtkconv_chat_popup_menu_cb), conv); | |
4359 | 4107 |
9498 | 4108 rend = gtk_cell_renderer_text_new(); |
4109 | |
4359 | 4110 col = gtk_tree_view_column_new_with_attributes(NULL, rend, |
9498 | 4111 "text", CHAT_USERS_NAME_COLUMN, NULL); |
4359 | 4112 gtk_tree_view_column_set_clickable(GTK_TREE_VIEW_COLUMN(col), TRUE); |
4113 | |
4114 gtk_tree_view_append_column(GTK_TREE_VIEW(list), col); | |
4115 | |
4116 gtk_widget_set_size_request(list, 150, -1); | |
4117 | |
4118 gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(list), FALSE); | |
4119 gtk_widget_show(list); | |
4120 | |
4121 gtkchat->list = list; | |
4122 | |
7949 | 4123 gtk_container_add(GTK_CONTAINER(sw), list); |
4359 | 4124 |
4125 /* Setup the user list toolbar. */ | |
8253
0c5977fd3101
[gaim-migrate @ 8976]
Christian Hammond <chipx86@chipx86.com>
parents:
8252
diff
changeset
|
4126 bbox = gtk_hbox_new(TRUE, 6); |
4359 | 4127 gtk_box_pack_start(GTK_BOX(lbox), bbox, FALSE, FALSE, 0); |
4128 gtk_widget_show(bbox); | |
4129 | |
4130 /* IM */ | |
4131 button = gaim_pixbuf_button_from_stock(NULL, GTK_STOCK_REDO, | |
4132 GAIM_BUTTON_VERTICAL); | |
4133 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE); | |
4134 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
|
4135 gtk_tooltips_set_tip(gtkconv->tooltips, button, _("IM the user"), NULL); |
4359 | 4136 g_signal_connect(G_OBJECT(button), "clicked", |
7961 | 4137 G_CALLBACK(chat_im_button_cb), conv); |
4359 | 4138 |
4139 gtk_widget_show(button); | |
4140 | |
4141 /* Ignore */ | |
4142 button = gaim_pixbuf_button_from_stock(NULL, GAIM_STOCK_IGNORE, | |
4143 GAIM_BUTTON_VERTICAL); | |
4144 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE); | |
4145 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
|
4146 gtk_tooltips_set_tip(gtkconv->tooltips, button, |
d856987c72ca
[gaim-migrate @ 4636]
Christian Hammond <chipx86@chipx86.com>
parents:
4369
diff
changeset
|
4147 _("Ignore the user"), NULL); |
4359 | 4148 g_signal_connect(G_OBJECT(button), "clicked", |
4149 G_CALLBACK(ignore_cb), conv); | |
4150 gtk_widget_show(button); | |
4151 | |
4152 /* Info */ | |
4153 button = gaim_pixbuf_button_from_stock(NULL, GAIM_STOCK_INFO, | |
4154 GAIM_BUTTON_VERTICAL); | |
4155 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE); | |
4156 gtk_box_pack_start(GTK_BOX(bbox), button, FALSE, FALSE, 0); | |
4157 gtk_tooltips_set_tip(gtkconv->tooltips, button, | |
4370
d856987c72ca
[gaim-migrate @ 4636]
Christian Hammond <chipx86@chipx86.com>
parents:
4369
diff
changeset
|
4158 _("Get the user's information"), NULL); |
4359 | 4159 g_signal_connect(G_OBJECT(button), "clicked", |
4160 G_CALLBACK(info_cb), conv); | |
4161 | |
4162 gtk_widget_show(button); | |
4163 | |
4164 gtkconv->info = button; | |
4165 | |
4963
7f5e7f2ef317
[gaim-migrate @ 5297]
Christian Hammond <chipx86@chipx86.com>
parents:
4958
diff
changeset
|
4166 /* Build the toolbar. */ |
10080 | 4167 frame = gtk_frame_new(NULL); |
4168 | |
8253
0c5977fd3101
[gaim-migrate @ 8976]
Christian Hammond <chipx86@chipx86.com>
parents:
8252
diff
changeset
|
4169 vbox = gtk_vbox_new(FALSE, 6); |
8914 | 4170 gtk_paned_pack2(GTK_PANED(vpaned), vbox, FALSE, TRUE); |
4963
7f5e7f2ef317
[gaim-migrate @ 5297]
Christian Hammond <chipx86@chipx86.com>
parents:
4958
diff
changeset
|
4171 gtk_widget_show(vbox); |
7f5e7f2ef317
[gaim-migrate @ 5297]
Christian Hammond <chipx86@chipx86.com>
parents:
4958
diff
changeset
|
4172 |
9332 | 4173 gtkconv->lower_hbox = gtk_hbox_new(FALSE, 6); |
4174 gtk_box_pack_start(GTK_BOX(vbox), gtkconv->lower_hbox, TRUE, TRUE, 0); | |
4175 gtk_widget_show(gtkconv->lower_hbox); | |
4176 | |
4177 vbox = gtk_vbox_new(FALSE, 6); | |
4178 gtk_box_pack_end(GTK_BOX(gtkconv->lower_hbox), vbox, TRUE, TRUE, 0); | |
4179 gtk_widget_show(vbox); | |
4180 | |
10080 | 4181 frame = gtk_frame_new(NULL); |
4182 gtk_box_pack_start(GTK_BOX(vbox), frame, TRUE, TRUE, 0); | |
4183 gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_IN); | |
4184 vbox2 = gtk_vbox_new(FALSE, 0); | |
4185 gtk_container_add(GTK_CONTAINER(frame), vbox2); | |
4186 gtk_widget_show_all(frame); | |
4187 | |
4188 gtkconv->toolbar = gtk_imhtmltoolbar_new(); | |
4189 gtk_box_pack_start(GTK_BOX(vbox2), gtkconv->toolbar, FALSE, FALSE, 0); | |
4190 | |
4191 sep = gtk_hseparator_new(); | |
4192 gtk_box_pack_start(GTK_BOX(vbox2), sep, FALSE, FALSE, 0); | |
4193 gtk_widget_show(sep); | |
4194 | |
8123 | 4195 /* Setup the entry widget. |
4196 * We never show the horizontal scrollbar because it was causing weird | |
4197 * lockups when typing text just as you type the character that would | |
4198 * cause both scrollbars to appear. Definitely seems like a gtk bug. | |
4199 */ | |
7949 | 4200 sw = gtk_scrolled_window_new(NULL, NULL); |
4201 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), | |
10080 | 4202 GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC); |
8061 | 4203 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(sw), |
10080 | 4204 GTK_SHADOW_NONE); |
4205 gtk_box_pack_start(GTK_BOX(vbox2), sw, TRUE, TRUE, 0); | |
7949 | 4206 gtk_widget_show(sw); |
4963
7f5e7f2ef317
[gaim-migrate @ 5297]
Christian Hammond <chipx86@chipx86.com>
parents:
4958
diff
changeset
|
4207 |
8061 | 4208 gtkconv->entry = gtk_imhtml_new(NULL, NULL); |
9005 | 4209 gtk_widget_set_name(gtkconv->entry, "gaim_gtkconv_entry"); |
8456 | 4210 gtk_imhtml_smiley_shortcuts(GTK_IMHTML(gtkconv->entry), |
4211 gaim_prefs_get_bool("/gaim/gtk/conversations/smiley_shortcuts")); | |
4212 gtk_imhtml_html_shortcuts(GTK_IMHTML(gtkconv->entry), | |
4213 gaim_prefs_get_bool("/gaim/gtk/conversations/html_shortcuts")); | |
4214 | |
4215 gtk_imhtml_set_protocol_name(GTK_IMHTML(gtkconv->entry), | |
9699 | 4216 gaim_account_get_protocol_name(conv->account)); |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
4217 gtkconv->entry_buffer = |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
4218 gtk_text_view_get_buffer(GTK_TEXT_VIEW(gtkconv->entry)); |
8061 | 4219 gaim_setup_imhtml(gtkconv->entry); |
4220 gtk_imhtml_set_editable(GTK_IMHTML(gtkconv->entry), TRUE); | |
4221 default_formatize(conv); | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
4222 gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(gtkconv->entry), |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
4223 GTK_WRAP_WORD_CHAR); |
4963
7f5e7f2ef317
[gaim-migrate @ 5297]
Christian Hammond <chipx86@chipx86.com>
parents:
4958
diff
changeset
|
4224 gtk_widget_set_size_request(gtkconv->entry, -1, |
8106 | 4225 gaim_prefs_get_int("/gaim/gtk/conversations/chat/entry_height")); |
7949 | 4226 g_object_set_data(G_OBJECT(gtkconv->entry_buffer), "user_data", conv); |
4227 | |
4228 g_signal_connect(G_OBJECT(gtkconv->entry), "key_press_event", | |
8105 | 4229 G_CALLBACK(entry_key_press_cb), conv); |
4359 | 4230 g_signal_connect_after(G_OBJECT(gtkconv->entry), "button_press_event", |
4231 G_CALLBACK(entry_stop_rclick_cb), NULL); | |
8914 | 4232 g_signal_connect(G_OBJECT(gtkconv->entry), "size-allocate", |
4233 G_CALLBACK(size_allocate_cb), conv); | |
4359 | 4234 |
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5484
diff
changeset
|
4235 if (gaim_prefs_get_bool("/gaim/gtk/conversations/spellcheck")) |
7538
357eb1c39b72
[gaim-migrate @ 8151]
Christian Hammond <chipx86@chipx86.com>
parents:
7476
diff
changeset
|
4236 gaim_gtk_setup_gtkspell(GTK_TEXT_VIEW(gtkconv->entry)); |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
4237 gtk_imhtmltoolbar_attach(GTK_IMHTMLTOOLBAR(gtkconv->toolbar), |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
4238 gtkconv->entry); |
4359 | 4239 |
7949 | 4240 gtk_container_add(GTK_CONTAINER(sw), GTK_WIDGET(gtkconv->entry)); |
4359 | 4241 gtk_widget_show(gtkconv->entry); |
4242 | |
4243 /* Setup the bottom button box. */ | |
8253
0c5977fd3101
[gaim-migrate @ 8976]
Christian Hammond <chipx86@chipx86.com>
parents:
8252
diff
changeset
|
4244 gtkconv->bbox = gtk_hbox_new(FALSE, 6); |
4359 | 4245 gtk_box_pack_start(GTK_BOX(vbox), gtkconv->bbox, FALSE, FALSE, 0); |
4246 setup_chat_buttons(conv, gtkconv->bbox); | |
4247 | |
9080 | 4248 /* |
4249 * Focus for chat windows should be as follows: | |
4250 * Tab title -> chat topic -> conversation scrollback -> user list -> | |
4251 * user list buttons -> entry -> buttons at bottom | |
4252 */ | |
4253 focus_chain = g_list_prepend(focus_chain, gtkconv->bbox); | |
9332 | 4254 focus_chain = g_list_prepend(focus_chain, gtkconv->entry); |
9080 | 4255 gtk_container_set_focus_chain(GTK_CONTAINER(vbox), focus_chain); |
4256 | |
4359 | 4257 return vpaned; |
4258 } | |
4259 | |
4260 static GtkWidget * | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4261 setup_im_pane(GaimConversation *conv) |
4359 | 4262 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4263 GaimGtkConversation *gtkconv; |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4264 GaimGtkImPane *gtkim; |
4359 | 4265 GtkWidget *paned; |
10080 | 4266 GtkWidget *vbox, *sep; |
4267 GtkWidget *vbox2, *vbox3, *frame; | |
7949 | 4268 GtkWidget *sw; |
9080 | 4269 GList *focus_chain = NULL; |
4359 | 4270 |
4271 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
4272 gtkim = gtkconv->u.im; | |
4273 | |
4274 /* Setup the outer pane. */ | |
4275 paned = gtk_vpaned_new(); | |
4276 gtk_widget_show(paned); | |
4277 | |
4278 /* Setup the top part of the pane. */ | |
8253
0c5977fd3101
[gaim-migrate @ 8976]
Christian Hammond <chipx86@chipx86.com>
parents:
8252
diff
changeset
|
4279 vbox = gtk_vbox_new(FALSE, 6); |
4409
0521eec12c33
[gaim-migrate @ 4682]
Christian Hammond <chipx86@chipx86.com>
parents:
4398
diff
changeset
|
4280 gtk_paned_pack1(GTK_PANED(paned), vbox, TRUE, TRUE); |
4359 | 4281 gtk_widget_show(vbox); |
4282 | |
4283 /* Setup the gtkimhtml widget. */ | |
4284 gtkconv->sw = gtk_scrolled_window_new(NULL, NULL); | |
4285 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(gtkconv->sw), | |
8076 | 4286 GTK_POLICY_AUTOMATIC, GTK_POLICY_ALWAYS); |
4359 | 4287 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(gtkconv->sw), |
4288 GTK_SHADOW_IN); | |
4963
7f5e7f2ef317
[gaim-migrate @ 5297]
Christian Hammond <chipx86@chipx86.com>
parents:
4958
diff
changeset
|
4289 gtk_box_pack_start(GTK_BOX(vbox), gtkconv->sw, TRUE, TRUE, 0); |
4851 | 4290 |
5550
b18c2a37cc96
[gaim-migrate @ 5951]
Christian Hammond <chipx86@chipx86.com>
parents:
5546
diff
changeset
|
4291 gtk_widget_set_size_request(gtkconv->sw, |
b18c2a37cc96
[gaim-migrate @ 5951]
Christian Hammond <chipx86@chipx86.com>
parents:
5546
diff
changeset
|
4292 gaim_prefs_get_int("/gaim/gtk/conversations/im/default_width"), |
b18c2a37cc96
[gaim-migrate @ 5951]
Christian Hammond <chipx86@chipx86.com>
parents:
5546
diff
changeset
|
4293 gaim_prefs_get_int("/gaim/gtk/conversations/im/default_height")); |
8914 | 4294 g_signal_connect(G_OBJECT(gtkconv->sw), "size-allocate", |
4295 G_CALLBACK(size_allocate_cb), conv); | |
4359 | 4296 gtk_widget_show(gtkconv->sw); |
4297 | |
4298 gtkconv->imhtml = gtk_imhtml_new(NULL, NULL); | |
9005 | 4299 gtk_widget_set_name(gtkconv->imhtml, "gaim_gtkconv_imhtml"); |
4359 | 4300 gtk_container_add(GTK_CONTAINER(gtkconv->sw), gtkconv->imhtml); |
4301 | |
4302 g_signal_connect_after(G_OBJECT(gtkconv->imhtml), "button_press_event", | |
4303 G_CALLBACK(entry_stop_rclick_cb), NULL); | |
8105 | 4304 g_signal_connect(G_OBJECT(gtkconv->imhtml), "key_press_event", |
6057 | 4305 G_CALLBACK(refocus_entry_cb), gtkconv); |
8109 | 4306 g_signal_connect(G_OBJECT(gtkconv->imhtml), "key_release_event", |
4307 G_CALLBACK(refocus_entry_cb), gtkconv); | |
4359 | 4308 |
4309 gtk_imhtml_show_comments(GTK_IMHTML(gtkconv->imhtml), | |
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5484
diff
changeset
|
4310 gaim_prefs_get_bool("/gaim/gtk/conversations/show_timestamps")); |
4359 | 4311 gaim_setup_imhtml(gtkconv->imhtml); |
4312 gtk_widget_show(gtkconv->imhtml); | |
8253
0c5977fd3101
[gaim-migrate @ 8976]
Christian Hammond <chipx86@chipx86.com>
parents:
8252
diff
changeset
|
4313 vbox2 = gtk_vbox_new(FALSE, 6); |
8914 | 4314 gtk_paned_pack2(GTK_PANED(paned), vbox2, FALSE, TRUE); |
4963
7f5e7f2ef317
[gaim-migrate @ 5297]
Christian Hammond <chipx86@chipx86.com>
parents:
4958
diff
changeset
|
4315 gtk_widget_show(vbox2); |
7f5e7f2ef317
[gaim-migrate @ 5297]
Christian Hammond <chipx86@chipx86.com>
parents:
4958
diff
changeset
|
4316 |
8123 | 4317 /* Setup the entry widget. |
4318 * We never show the horizontal scrollbar because it was causing weird | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
4319 * lockups when typing text just as you type the character that would |
8123 | 4320 * cause both scrollbars to appear. Definitely seems like a gtk bug. |
4321 */ | |
9332 | 4322 gtkconv->lower_hbox = gtk_hbox_new(FALSE, 6); |
4323 gtk_box_pack_start(GTK_BOX(vbox2), gtkconv->lower_hbox, TRUE, TRUE, 0); | |
4324 gtk_widget_show(gtkconv->lower_hbox); | |
4325 | |
4326 vbox2 = gtk_vbox_new(FALSE, 6); | |
4327 gtk_box_pack_end(GTK_BOX(gtkconv->lower_hbox), vbox2, TRUE, TRUE, 0); | |
4328 gtk_widget_show(vbox2); | |
8821 | 4329 |
10080 | 4330 frame = gtk_frame_new(NULL); |
4331 gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_IN); | |
4332 gtk_box_pack_start(GTK_BOX(vbox2), frame, TRUE, TRUE, 0); | |
4333 vbox3 = gtk_vbox_new(FALSE, 0); | |
4334 gtk_container_add(GTK_CONTAINER(frame), vbox3); | |
4335 gtk_widget_show_all(frame); | |
4336 | |
4337 /* Build the toolbar. */ | |
4338 gtkconv->toolbar = gtk_imhtmltoolbar_new(); | |
4339 gtk_box_pack_start(GTK_BOX(vbox3), gtkconv->toolbar, FALSE, FALSE, 0); | |
4340 | |
4341 sep = gtk_hseparator_new(); | |
4342 gtk_box_pack_start(GTK_BOX(vbox3), sep, FALSE, FALSE, 0); | |
4343 gtk_widget_show(sep); | |
4344 | |
7949 | 4345 sw = gtk_scrolled_window_new(NULL, NULL); |
4346 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw), | |
8112 | 4347 GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC); |
8061 | 4348 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(sw), |
10080 | 4349 GTK_SHADOW_NONE); |
4350 gtk_box_pack_start(GTK_BOX(vbox3), sw, TRUE, TRUE, 0); | |
7949 | 4351 gtk_widget_show(sw); |
4963
7f5e7f2ef317
[gaim-migrate @ 5297]
Christian Hammond <chipx86@chipx86.com>
parents:
4958
diff
changeset
|
4352 |
8061 | 4353 gtkconv->entry = gtk_imhtml_new(NULL, NULL); |
9005 | 4354 gtk_widget_set_name(gtkconv->entry, "gaim_gtkconv_entry"); |
8456 | 4355 |
4356 gtk_imhtml_smiley_shortcuts(GTK_IMHTML(gtkconv->entry), | |
4357 gaim_prefs_get_bool("/gaim/gtk/conversations/smiley_shortcuts")); | |
4358 gtk_imhtml_html_shortcuts(GTK_IMHTML(gtkconv->entry), | |
4359 gaim_prefs_get_bool("/gaim/gtk/conversations/html_shortcuts")); | |
4360 | |
4361 gtk_imhtml_set_protocol_name(GTK_IMHTML(gtkconv->entry), | |
9699 | 4362 gaim_account_get_protocol_name(conv->account)); |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
4363 gtkconv->entry_buffer = |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
4364 gtk_text_view_get_buffer(GTK_TEXT_VIEW(gtkconv->entry)); |
8061 | 4365 gaim_setup_imhtml(gtkconv->entry); |
4366 gtk_imhtml_set_editable(GTK_IMHTML(gtkconv->entry), TRUE); | |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
4367 gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(gtkconv->entry), |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
4368 GTK_WRAP_WORD_CHAR); |
4963
7f5e7f2ef317
[gaim-migrate @ 5297]
Christian Hammond <chipx86@chipx86.com>
parents:
4958
diff
changeset
|
4369 gtk_widget_set_size_request(gtkconv->entry, -1, |
8106 | 4370 gaim_prefs_get_int("/gaim/gtk/conversations/im/entry_height")); |
7949 | 4371 g_object_set_data(G_OBJECT(gtkconv->entry_buffer), "user_data", conv); |
4963
7f5e7f2ef317
[gaim-migrate @ 5297]
Christian Hammond <chipx86@chipx86.com>
parents:
4958
diff
changeset
|
4372 |
4359 | 4373 g_signal_connect(G_OBJECT(gtkconv->entry), "key_press_event", |
8105 | 4374 G_CALLBACK(entry_key_press_cb), conv); |
4359 | 4375 g_signal_connect_after(G_OBJECT(gtkconv->entry), "button_press_event", |
4376 G_CALLBACK(entry_stop_rclick_cb), NULL); | |
8914 | 4377 g_signal_connect(G_OBJECT(gtkconv->entry), "size-allocate", |
4378 G_CALLBACK(size_allocate_cb), conv); | |
4359 | 4379 |
4380 g_signal_connect(G_OBJECT(gtkconv->entry_buffer), "insert_text", | |
4381 G_CALLBACK(insert_text_cb), conv); | |
4382 g_signal_connect(G_OBJECT(gtkconv->entry_buffer), "delete_range", | |
4383 G_CALLBACK(delete_text_cb), conv); | |
4384 | |
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5484
diff
changeset
|
4385 if (gaim_prefs_get_bool("/gaim/gtk/conversations/spellcheck")) |
7538
357eb1c39b72
[gaim-migrate @ 8151]
Christian Hammond <chipx86@chipx86.com>
parents:
7476
diff
changeset
|
4386 gaim_gtk_setup_gtkspell(GTK_TEXT_VIEW(gtkconv->entry)); |
4359 | 4387 |
7949 | 4388 gtk_container_add(GTK_CONTAINER(sw), GTK_WIDGET(gtkconv->entry)); |
4359 | 4389 gtk_widget_show(gtkconv->entry); |
8319
a2c5537a814b
[gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents:
8317
diff
changeset
|
4390 gtk_imhtmltoolbar_attach(GTK_IMHTMLTOOLBAR(gtkconv->toolbar), |
a2c5537a814b
[gaim-migrate @ 9043]
Christian Hammond <chipx86@chipx86.com>
parents:
8317
diff
changeset
|
4391 gtkconv->entry); |
8481 | 4392 /* had to move this after the imtoolbar is attached so that the |
4393 * signals get fired to toggle the buttons on the toolbar as well. | |
4394 */ | |
4395 default_formatize(conv); | |
4359 | 4396 |
9749 | 4397 /* Setup the bottom button box. */ |
8253
0c5977fd3101
[gaim-migrate @ 8976]
Christian Hammond <chipx86@chipx86.com>
parents:
8252
diff
changeset
|
4398 gtkconv->bbox = gtk_hbox_new(FALSE, 6); |
4359 | 4399 gtk_box_pack_start(GTK_BOX(vbox2), gtkconv->bbox, FALSE, FALSE, 0); |
4400 setup_im_buttons(conv, gtkconv->bbox); | |
9749 | 4401 |
8758 | 4402 gtkconv->u.im->animate = gaim_prefs_get_bool("/gaim/gtk/conversations/im/animate_buddy_icons"); |
9687 | 4403 gtkconv->u.im->show_icon = TRUE; |
4359 | 4404 |
9080 | 4405 /* |
4406 * Focus for IM windows should be as follows: | |
4407 * Tab title -> conversation scrollback -> entry -> buttons at bottom | |
4408 */ | |
4409 focus_chain = g_list_prepend(focus_chain, gtkconv->bbox); | |
9332 | 4410 focus_chain = g_list_prepend(focus_chain, gtkconv->entry); |
9080 | 4411 gtk_container_set_focus_chain(GTK_CONTAINER(vbox2), focus_chain); |
8143 | 4412 |
4359 | 4413 return paned; |
4414 } | |
4415 | |
4416 static void | |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
4417 conv_dnd_recv(GtkWidget *widget, GdkDragContext *dc, guint x, guint y, |
4939
4d50e125b0fa
[gaim-migrate @ 5273]
Christian Hammond <chipx86@chipx86.com>
parents:
4931
diff
changeset
|
4418 GtkSelectionData *sd, guint info, guint t, |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4419 GaimConversation *conv) |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
4420 { |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4421 GaimConvWindow *win = conv->window; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4422 GaimConversation *c; |
7712
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4423 if (sd->target == gdk_atom_intern("GAIM_BLIST_NODE", FALSE)) |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4424 { |
4781 | 4425 GaimBlistNode *n = NULL; |
6695 | 4426 GaimBuddy *b; |
9622 | 4427 unsigned int index; |
4428 | |
4781 | 4429 memcpy(&n, sd->data, sizeof(n)); |
4939
4d50e125b0fa
[gaim-migrate @ 5273]
Christian Hammond <chipx86@chipx86.com>
parents:
4931
diff
changeset
|
4430 |
6695 | 4431 if (GAIM_BLIST_NODE_IS_CONTACT(n)) |
4432 b = gaim_contact_get_priority_buddy((GaimContact*)n); | |
4433 else if (GAIM_BLIST_NODE_IS_BUDDY(n)) | |
4434 b = (GaimBuddy*)n; | |
4435 else | |
4781 | 4436 return; |
4939
4d50e125b0fa
[gaim-migrate @ 5273]
Christian Hammond <chipx86@chipx86.com>
parents:
4931
diff
changeset
|
4437 |
9622 | 4438 /* |
4439 * If we already have an open conversation with this buddy, then | |
4440 * just move the conv to this window. Otherwise, create a new | |
4441 * conv and add it to this window. | |
4442 */ | |
4443 c = gaim_find_conversation(b->name); | |
4444 if (c != NULL) { | |
4445 GaimConvWindow *oldwin; | |
4446 oldwin = gaim_conversation_get_window(c); | |
4447 index = gaim_conversation_get_index(c); | |
4448 if (oldwin != win) { | |
4449 gaim_conv_window_remove_conversation(oldwin, index); | |
4450 gaim_conv_window_add_conversation(win, c); | |
4451 } | |
4452 } else { | |
4453 c = gaim_conversation_new(GAIM_CONV_IM, b->account, b->name); | |
4454 gaim_conv_window_add_conversation(win, c); | |
4455 } | |
4456 | |
4457 /* Make this conversation the active conversation */ | |
4458 index = gaim_conversation_get_index(c); | |
4459 gaim_conv_window_switch_conversation(win, index); | |
8802
1076cd8579ea
[gaim-migrate @ 9564]
Christian Hammond <chipx86@chipx86.com>
parents:
8758
diff
changeset
|
4460 |
1076cd8579ea
[gaim-migrate @ 9564]
Christian Hammond <chipx86@chipx86.com>
parents:
8758
diff
changeset
|
4461 gtk_drag_finish(dc, TRUE, (dc->action == GDK_ACTION_MOVE), t); |
4702 | 4462 } |
7712
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4463 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
|
4464 { |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4465 char *protocol = NULL; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4466 char *username = NULL; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4467 GaimAccount *account; |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4468 |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4469 if (gaim_gtk_parse_x_im_contact(sd->data, FALSE, &account, |
7718 | 4470 &protocol, &username, NULL)) |
7712
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4471 { |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4472 if (account == NULL) |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4473 { |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4474 gaim_notify_error(NULL, NULL, |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4475 _("You are not currently signed on with an account that " |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4476 "can add that buddy."), NULL); |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4477 } |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4478 else |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4479 { |
7718 | 4480 c = gaim_conversation_new(GAIM_CONV_IM, account, username); |
4481 gaim_conv_window_add_conversation(win, c); | |
7712
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4482 } |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4483 } |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4484 |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4485 if (username != NULL) g_free(username); |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4486 if (protocol != NULL) g_free(protocol); |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4487 |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4488 gtk_drag_finish(dc, TRUE, (dc->action == GDK_ACTION_MOVE), t); |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4489 } |
9525 | 4490 else if (sd->target == gdk_atom_intern("text/uri-list", FALSE)) { |
9673 | 4491 GList *tmp; |
4492 GList *files = gaim_uri_list_extract_filenames(sd->data); | |
4493 for(tmp = files; tmp != NULL ; tmp = g_list_next(tmp)) { | |
4494 gchar *filename = tmp->data; | |
4495 /* XXX - Make ft API support creating a transfer with more than one file */ | |
4496 if (g_file_test(filename, G_FILE_TEST_EXISTS) | |
4497 && !g_file_test(filename, G_FILE_TEST_IS_DIR) | |
4498 && gaim_conversation_get_type(conv) == GAIM_CONV_IM) { | |
4499 serv_send_file(gaim_conversation_get_gc(conv), | |
4500 gaim_conversation_get_name(conv), filename); | |
4501 } | |
4502 g_free(filename); | |
9495 | 4503 } |
9673 | 4504 g_list_free(files); |
4505 /* XXX - Attempt to load this file into gdk_pixbuf, or otherwise determine if it is an image. If it is, offer | |
4506 * the choice of a) sending this file b) inserting this file as an IM image or c) setting this file as a custom | |
4507 * buddy icon for this buddy */ | |
9495 | 4508 } |
4509 gtk_drag_finish(dc, FALSE, FALSE, t); | |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
4510 } |
4359 | 4511 |
4512 /************************************************************************** | |
4513 * GTK+ window ops | |
4514 **************************************************************************/ | |
4515 static void | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4516 gaim_gtk_new_window(GaimConvWindow *win) |
4359 | 4517 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4518 GaimGtkWindow *gtkwin; |
4359 | 4519 GtkPositionType pos; |
4520 GtkWidget *testidea; | |
4521 GtkWidget *menubar; | |
4522 | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4523 gtkwin = g_malloc0(sizeof(GaimGtkWindow)); |
4359 | 4524 |
4525 win->ui_data = gtkwin; | |
4526 | |
4527 /* Create the window. */ | |
4528 gtkwin->window = gtk_window_new(GTK_WINDOW_TOPLEVEL); | |
4529 gtk_window_set_role(GTK_WINDOW(gtkwin->window), "conversation"); | |
9614 | 4530 gtk_window_set_resizable(GTK_WINDOW(gtkwin->window), TRUE); |
4510
4c394222c732
[gaim-migrate @ 4786]
Christian Hammond <chipx86@chipx86.com>
parents:
4505
diff
changeset
|
4531 gtk_container_set_border_width(GTK_CONTAINER(gtkwin->window), 0); |
9614 | 4532 GTK_WINDOW(gtkwin->window)->allow_shrink = TRUE; |
4359 | 4533 |
4534 g_signal_connect(G_OBJECT(gtkwin->window), "delete_event", | |
4535 G_CALLBACK(close_win_cb), win); | |
4536 | |
4537 /* Create the notebook. */ | |
4538 gtkwin->notebook = gtk_notebook_new(); | |
4539 | |
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5484
diff
changeset
|
4540 pos = gaim_prefs_get_int("/gaim/gtk/conversations/tab_side"); |
4359 | 4541 |
4542 #if 0 | |
4543 gtk_notebook_set_tab_hborder(GTK_NOTEBOOK(gtkwin->notebook), 0); | |
4544 gtk_notebook_set_tab_vborder(GTK_NOTEBOOK(gtkwin->notebook), 0); | |
4545 #endif | |
4546 gtk_notebook_set_tab_pos(GTK_NOTEBOOK(gtkwin->notebook), pos); | |
4547 gtk_notebook_set_scrollable(GTK_NOTEBOOK(gtkwin->notebook), TRUE); | |
4548 gtk_notebook_popup_enable(GTK_NOTEBOOK(gtkwin->notebook)); | |
4818 | 4549 gtk_notebook_set_show_tabs(GTK_NOTEBOOK(gtkwin->notebook), FALSE); |
4550 | |
4359 | 4551 gtk_widget_show(gtkwin->notebook); |
4552 | |
8189 | 4553 g_signal_connect(G_OBJECT(gtkwin->notebook), "switch_page", |
4554 G_CALLBACK(before_switch_conv_cb), win); | |
4359 | 4555 g_signal_connect_after(G_OBJECT(gtkwin->notebook), "switch_page", |
4556 G_CALLBACK(switch_conv_cb), win); | |
4557 | |
4558 /* Setup the tab drag and drop signals. */ | |
4486 | 4559 gtk_widget_add_events(gtkwin->notebook, |
4560 GDK_BUTTON1_MOTION_MASK | GDK_LEAVE_NOTIFY_MASK); | |
4561 g_signal_connect(G_OBJECT(gtkwin->notebook), "button_press_event", | |
4572
06084165a966
[gaim-migrate @ 4853]
Christian Hammond <chipx86@chipx86.com>
parents:
4571
diff
changeset
|
4562 G_CALLBACK(notebook_press_cb), win); |
4486 | 4563 g_signal_connect(G_OBJECT(gtkwin->notebook), "button_release_event", |
4572
06084165a966
[gaim-migrate @ 4853]
Christian Hammond <chipx86@chipx86.com>
parents:
4571
diff
changeset
|
4564 G_CALLBACK(notebook_release_cb), win); |
06084165a966
[gaim-migrate @ 4853]
Christian Hammond <chipx86@chipx86.com>
parents:
4571
diff
changeset
|
4565 |
4359 | 4566 testidea = gtk_vbox_new(FALSE, 0); |
4572
06084165a966
[gaim-migrate @ 4853]
Christian Hammond <chipx86@chipx86.com>
parents:
4571
diff
changeset
|
4567 |
4359 | 4568 /* Setup the menubar. */ |
4569 menubar = setup_menubar(win); | |
4570 gtk_box_pack_start(GTK_BOX(testidea), menubar, FALSE, TRUE, 0); | |
4571 | |
4572 gtk_box_pack_start(GTK_BOX(testidea), gtkwin->notebook, TRUE, TRUE, 0); | |
4573 | |
4574 gtk_container_add(GTK_CONTAINER(gtkwin->window), testidea); | |
4575 | |
4576 gtk_widget_show(testidea); | |
4577 } | |
4578 | |
4579 static void | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4580 gaim_gtk_destroy_window(GaimConvWindow *win) |
4359 | 4581 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4582 GaimGtkWindow *gtkwin = GAIM_GTK_WINDOW(win); |
4359 | 4583 |
4584 gtk_widget_destroy(gtkwin->window); | |
4585 | |
4630 | 4586 g_object_unref(G_OBJECT(gtkwin->menu.item_factory)); |
4587 | |
4359 | 4588 g_free(gtkwin); |
4589 win->ui_data = NULL; | |
4590 } | |
4591 | |
4592 static void | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4593 gaim_gtk_show(GaimConvWindow *win) |
4359 | 4594 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4595 GaimGtkWindow *gtkwin = GAIM_GTK_WINDOW(win); |
4359 | 4596 |
4597 gtk_widget_show(gtkwin->window); | |
4598 } | |
4599 | |
4600 static void | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4601 gaim_gtk_hide(GaimConvWindow *win) |
4359 | 4602 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4603 GaimGtkWindow *gtkwin = GAIM_GTK_WINDOW(win); |
4359 | 4604 |
4605 gtk_widget_hide(gtkwin->window); | |
4606 } | |
4607 | |
4608 static void | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4609 gaim_gtk_raise(GaimConvWindow *win) |
4359 | 4610 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4611 GaimGtkWindow *gtkwin = GAIM_GTK_WINDOW(win); |
4359 | 4612 |
9728 | 4613 gtk_widget_show(gtkwin->window); |
4614 gtk_window_deiconify(GTK_WINDOW(gtkwin->window)); | |
4615 gdk_window_raise(gtkwin->window->window); | |
4359 | 4616 } |
4617 | |
4618 static void | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4619 gaim_gtk_flash(GaimConvWindow *win) |
4359 | 4620 { |
4621 #ifdef _WIN32 | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4622 GaimGtkWindow *gtkwin = GAIM_GTK_WINDOW(win); |
4359 | 4623 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4624 wgaim_conv_im_blink(gtkwin->window); |
4359 | 4625 #endif |
4626 } | |
4627 | |
4628 static void | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4629 gaim_gtk_switch_conversation(GaimConvWindow *win, unsigned int index) |
4359 | 4630 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4631 GaimGtkWindow *gtkwin; |
4359 | 4632 |
4633 gtkwin = GAIM_GTK_WINDOW(win); | |
4634 | |
4635 gtk_notebook_set_current_page(GTK_NOTEBOOK(gtkwin->notebook), index); | |
4636 } | |
4637 | |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
4638 static const GtkTargetEntry te[] = |
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
4639 { |
9525 | 4640 {"text/uri-list", 0, 0}, |
4641 {"GAIM_BLIST_NODE", GTK_TARGET_SAME_APP, 1}, | |
4642 {"text/plain", 0, 2}, | |
7712
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4643 {"STRING", 0, 3}, |
2823111061ba
[gaim-migrate @ 8357]
Christian Hammond <chipx86@chipx86.com>
parents:
7700
diff
changeset
|
4644 {"application/x-im-contact", 0, 4} |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
4645 }; |
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
4646 |
4359 | 4647 static void |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4648 gaim_gtk_add_conversation(GaimConvWindow *win, GaimConversation *conv) |
4359 | 4649 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4650 GaimGtkWindow *gtkwin; |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4651 GaimGtkConversation *gtkconv, *focus_gtkconv; |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4652 GaimConversation *focus_conv; |
4359 | 4653 GtkWidget *pane = NULL; |
4654 GtkWidget *tab_cont; | |
6771
8eebba08b44b
[gaim-migrate @ 7308]
Christian Hammond <chipx86@chipx86.com>
parents:
6760
diff
changeset
|
4655 GtkWidget *tabby, *menu_tabby; |
10053
a4ceacb1816d
[gaim-migrate @ 11016]
Luke Schierer <lschiere@pidgin.im>
parents:
10025
diff
changeset
|
4656 GtkWidget *close_image; |
4359 | 4657 gboolean new_ui; |
4383
f7a84034f97f
[gaim-migrate @ 4649]
Christian Hammond <chipx86@chipx86.com>
parents:
4382
diff
changeset
|
4658 GaimConversationType conv_type; |
f7a84034f97f
[gaim-migrate @ 4649]
Christian Hammond <chipx86@chipx86.com>
parents:
4382
diff
changeset
|
4659 const char *name; |
f7a84034f97f
[gaim-migrate @ 4649]
Christian Hammond <chipx86@chipx86.com>
parents:
4382
diff
changeset
|
4660 |
f7a84034f97f
[gaim-migrate @ 4649]
Christian Hammond <chipx86@chipx86.com>
parents:
4382
diff
changeset
|
4661 name = gaim_conversation_get_name(conv); |
f7a84034f97f
[gaim-migrate @ 4649]
Christian Hammond <chipx86@chipx86.com>
parents:
4382
diff
changeset
|
4662 conv_type = gaim_conversation_get_type(conv); |
f7a84034f97f
[gaim-migrate @ 4649]
Christian Hammond <chipx86@chipx86.com>
parents:
4382
diff
changeset
|
4663 gtkwin = GAIM_GTK_WINDOW(win); |
4359 | 4664 |
4665 if (conv->ui_data != NULL) { | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4666 gtkconv = (GaimGtkConversation *)conv->ui_data; |
4359 | 4667 |
4668 tab_cont = gtkconv->tab_cont; | |
4669 | |
4670 new_ui = FALSE; | |
4671 } | |
4672 else { | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4673 gtkconv = g_malloc0(sizeof(GaimGtkConversation)); |
4359 | 4674 conv->ui_data = gtkconv; |
4675 | |
4676 /* Setup some initial variables. */ | |
9749 | 4677 gtkconv->sg = gtk_size_group_new(GTK_SIZE_GROUP_BOTH); |
4359 | 4678 gtkconv->tooltips = gtk_tooltips_new(); |
4679 | |
7879 | 4680 if (conv_type == GAIM_CONV_IM) { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4681 gtkconv->u.im = g_malloc0(sizeof(GaimGtkImPane)); |
4359 | 4682 gtkconv->u.im->a_virgin = TRUE; |
4683 | |
4684 pane = setup_im_pane(conv); | |
4685 } | |
7879 | 4686 else if (conv_type == GAIM_CONV_CHAT) { |
4687 gtkconv->u.chat = g_malloc0(sizeof(GaimGtkChatPane)); | |
4688 | |
4689 pane = setup_chat_pane(conv); | |
4690 } | |
4359 | 4691 |
4692 if (pane == NULL) { | |
4572
06084165a966
[gaim-migrate @ 4853]
Christian Hammond <chipx86@chipx86.com>
parents:
4571
diff
changeset
|
4693 if (conv_type == GAIM_CONV_CHAT) g_free(gtkconv->u.chat); |
06084165a966
[gaim-migrate @ 4853]
Christian Hammond <chipx86@chipx86.com>
parents:
4571
diff
changeset
|
4694 else if (conv_type == GAIM_CONV_IM) g_free(gtkconv->u.im); |
4359 | 4695 |
4696 g_free(gtkconv); | |
4697 conv->ui_data = NULL; | |
4698 | |
4699 return; | |
4700 } | |
4701 | |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
4702 /* Setup drag-and-drop */ |
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
4703 gtk_drag_dest_set(pane, |
9300 | 4704 GTK_DEST_DEFAULT_MOTION | |
4705 GTK_DEST_DEFAULT_DROP, | |
4706 te, sizeof(te) / sizeof(GtkTargetEntry), | |
4707 GDK_ACTION_COPY); | |
4708 gtk_drag_dest_set(pane, | |
4709 GTK_DEST_DEFAULT_MOTION | | |
4710 GTK_DEST_DEFAULT_DROP, | |
4711 te, sizeof(te) / sizeof(GtkTargetEntry), | |
4712 GDK_ACTION_COPY); | |
4713 gtk_drag_dest_set(gtkconv->imhtml, 0, | |
4714 te, sizeof(te) / sizeof(GtkTargetEntry), | |
4715 GDK_ACTION_COPY); | |
4716 | |
4717 gtk_drag_dest_set(gtkconv->entry, 0, | |
4718 te, sizeof(te) / sizeof(GtkTargetEntry), | |
4719 GDK_ACTION_COPY); | |
4720 | |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
4721 g_signal_connect(G_OBJECT(pane), "drag_data_received", |
9300 | 4722 G_CALLBACK(conv_dnd_recv), conv); |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
4723 g_signal_connect(G_OBJECT(gtkconv->imhtml), "drag_data_received", |
9300 | 4724 G_CALLBACK(conv_dnd_recv), conv); |
8105 | 4725 g_signal_connect(G_OBJECT(gtkconv->entry), "drag_data_received", |
9300 | 4726 G_CALLBACK(conv_dnd_recv), conv); |
4727 | |
4359 | 4728 /* Setup the container for the tab. */ |
8253
0c5977fd3101
[gaim-migrate @ 8976]
Christian Hammond <chipx86@chipx86.com>
parents:
8252
diff
changeset
|
4729 gtkconv->tab_cont = tab_cont = gtk_vbox_new(FALSE, 6); |
0c5977fd3101
[gaim-migrate @ 8976]
Christian Hammond <chipx86@chipx86.com>
parents:
8252
diff
changeset
|
4730 gtk_container_set_border_width(GTK_CONTAINER(tab_cont), 6); |
4359 | 4731 gtk_container_add(GTK_CONTAINER(tab_cont), pane); |
4732 gtk_widget_show(pane); | |
4733 | |
4734 new_ui = TRUE; | |
6725
e62a504c83d0
[gaim-migrate @ 7252]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
4735 |
4359 | 4736 gtkconv->make_sound = TRUE; |
5902
6889b89cab90
[gaim-migrate @ 6334]
Christian Hammond <chipx86@chipx86.com>
parents:
5901
diff
changeset
|
4737 |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
4738 gtkconv->show_formatting_toolbar = gaim_prefs_get_bool( |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
4739 "/gaim/gtk/conversations/show_formatting_toolbar"); |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
4740 |
8329
9dd7c75ed433
[gaim-migrate @ 9053]
Christian Hammond <chipx86@chipx86.com>
parents:
8319
diff
changeset
|
4741 if (gtkconv->show_formatting_toolbar) |
9dd7c75ed433
[gaim-migrate @ 9053]
Christian Hammond <chipx86@chipx86.com>
parents:
8319
diff
changeset
|
4742 gtk_widget_show(gtkconv->toolbar); |
9dd7c75ed433
[gaim-migrate @ 9053]
Christian Hammond <chipx86@chipx86.com>
parents:
8319
diff
changeset
|
4743 |
9188 | 4744 gtkconv->show_timestamps = gaim_prefs_get_bool( |
4745 "/gaim/gtk/conversations/show_timestamps"); | |
4746 | |
4747 gtk_imhtml_show_comments(GTK_IMHTML(gtkconv->imhtml), | |
4748 gtkconv->show_timestamps); | |
4749 | |
8176 | 4750 g_signal_connect_swapped(G_OBJECT(pane), "focus", |
9080 | 4751 G_CALLBACK(gtk_widget_grab_focus), |
4752 gtkconv->entry); | |
4359 | 4753 } |
4754 | |
8253
0c5977fd3101
[gaim-migrate @ 8976]
Christian Hammond <chipx86@chipx86.com>
parents:
8252
diff
changeset
|
4755 gtkconv->tabby = tabby = gtk_hbox_new(FALSE, 6); |
0c5977fd3101
[gaim-migrate @ 8976]
Christian Hammond <chipx86@chipx86.com>
parents:
8252
diff
changeset
|
4756 gtkconv->menu_tabby = menu_tabby = gtk_hbox_new(FALSE, 6); |
4359 | 4757 |
4758 /* Close button. */ | |
4759 gtkconv->close = gtk_button_new(); | |
4760 gtk_widget_set_size_request(GTK_WIDGET(gtkconv->close), 16, 16); | |
7446
064c697cc223
[gaim-migrate @ 8057]
Christian Hammond <chipx86@chipx86.com>
parents:
7440
diff
changeset
|
4761 gtk_button_set_relief(GTK_BUTTON(gtkconv->close), GTK_RELIEF_NONE); |
10053
a4ceacb1816d
[gaim-migrate @ 11016]
Luke Schierer <lschiere@pidgin.im>
parents:
10025
diff
changeset
|
4762 close_image = gtk_image_new_from_stock(GTK_STOCK_CLOSE, GTK_ICON_SIZE_MENU); |
a4ceacb1816d
[gaim-migrate @ 11016]
Luke Schierer <lschiere@pidgin.im>
parents:
10025
diff
changeset
|
4763 gtk_widget_show(close_image); |
a4ceacb1816d
[gaim-migrate @ 11016]
Luke Schierer <lschiere@pidgin.im>
parents:
10025
diff
changeset
|
4764 gtk_container_add(GTK_CONTAINER(gtkconv->close), close_image); |
4359 | 4765 gtk_tooltips_set_tip(gtkconv->tooltips, gtkconv->close, |
4572
06084165a966
[gaim-migrate @ 4853]
Christian Hammond <chipx86@chipx86.com>
parents:
4571
diff
changeset
|
4766 _("Close conversation"), NULL); |
4359 | 4767 |
4768 g_signal_connect(G_OBJECT(gtkconv->close), "clicked", | |
4571
51e988d015ed
[gaim-migrate @ 4852]
Christian Hammond <chipx86@chipx86.com>
parents:
4561
diff
changeset
|
4769 G_CALLBACK(close_conv_cb), conv); |
4359 | 4770 |
7446
064c697cc223
[gaim-migrate @ 8057]
Christian Hammond <chipx86@chipx86.com>
parents:
7440
diff
changeset
|
4771 /* |
064c697cc223
[gaim-migrate @ 8057]
Christian Hammond <chipx86@chipx86.com>
parents:
7440
diff
changeset
|
4772 * I love Galeon. They have a fix for that stupid annoying visible |
064c697cc223
[gaim-migrate @ 8057]
Christian Hammond <chipx86@chipx86.com>
parents:
7440
diff
changeset
|
4773 * border bug. I love you guys! -- ChipX86 |
064c697cc223
[gaim-migrate @ 8057]
Christian Hammond <chipx86@chipx86.com>
parents:
7440
diff
changeset
|
4774 */ |
064c697cc223
[gaim-migrate @ 8057]
Christian Hammond <chipx86@chipx86.com>
parents:
7440
diff
changeset
|
4775 g_signal_connect(G_OBJECT(gtkconv->close), "state_changed", |
064c697cc223
[gaim-migrate @ 8057]
Christian Hammond <chipx86@chipx86.com>
parents:
7440
diff
changeset
|
4776 G_CALLBACK(tab_close_button_state_changed_cb), NULL); |
064c697cc223
[gaim-migrate @ 8057]
Christian Hammond <chipx86@chipx86.com>
parents:
7440
diff
changeset
|
4777 |
6392
e9974608b319
[gaim-migrate @ 6897]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
4778 /* Status icon. */ |
6440 | 4779 gtkconv->icon = gtk_image_new(); |
6771
8eebba08b44b
[gaim-migrate @ 7308]
Christian Hammond <chipx86@chipx86.com>
parents:
6760
diff
changeset
|
4780 gtkconv->menu_icon = gtk_image_new(); |
6440 | 4781 update_tab_icon(conv); |
6392
e9974608b319
[gaim-migrate @ 6897]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
4782 |
4359 | 4783 /* Tab label. */ |
4784 gtkconv->tab_label = gtk_label_new(gaim_conversation_get_title(conv)); | |
6771
8eebba08b44b
[gaim-migrate @ 7308]
Christian Hammond <chipx86@chipx86.com>
parents:
6760
diff
changeset
|
4785 gtkconv->menu_label = gtk_label_new(gaim_conversation_get_title(conv)); |
4359 | 4786 #if 0 |
4787 gtk_misc_set_alignment(GTK_MISC(gtkconv->tab_label), 0.00, 0.5); | |
4788 gtk_misc_set_padding(GTK_MISC(gtkconv->tab_label), 4, 0); | |
4789 #endif | |
4790 | |
4791 /* Pack it all together. */ | |
6392
e9974608b319
[gaim-migrate @ 6897]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
4792 gtk_box_pack_start(GTK_BOX(tabby), gtkconv->icon, FALSE, FALSE, 0); |
8407
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
4793 gtk_box_pack_start(GTK_BOX(menu_tabby), gtkconv->menu_icon, |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
4794 FALSE, FALSE, 0); |
15614a7cdc13
[gaim-migrate @ 9137]
Christian Hammond <chipx86@chipx86.com>
parents:
8380
diff
changeset
|
4795 |
8946 | 4796 gtk_widget_show_all(gtkconv->icon); |
4797 gtk_widget_show_all(gtkconv->menu_icon); | |
6392
e9974608b319
[gaim-migrate @ 6897]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
4798 |
4359 | 4799 gtk_box_pack_start(GTK_BOX(tabby), gtkconv->tab_label, TRUE, TRUE, 0); |
6771
8eebba08b44b
[gaim-migrate @ 7308]
Christian Hammond <chipx86@chipx86.com>
parents:
6760
diff
changeset
|
4800 gtk_box_pack_start(GTK_BOX(menu_tabby), gtkconv->menu_label, TRUE, TRUE, 0); |
4445 | 4801 gtk_widget_show(gtkconv->tab_label); |
6771
8eebba08b44b
[gaim-migrate @ 7308]
Christian Hammond <chipx86@chipx86.com>
parents:
6760
diff
changeset
|
4802 gtk_widget_show(gtkconv->menu_label); |
8eebba08b44b
[gaim-migrate @ 7308]
Christian Hammond <chipx86@chipx86.com>
parents:
6760
diff
changeset
|
4803 gtk_misc_set_alignment(GTK_MISC(gtkconv->menu_label), 0, 0); |
6392
e9974608b319
[gaim-migrate @ 6897]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
4804 |
4445 | 4805 gtk_box_pack_start(GTK_BOX(tabby), gtkconv->close, FALSE, FALSE, 0); |
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5484
diff
changeset
|
4806 if (gaim_prefs_get_bool("/gaim/gtk/conversations/close_on_tabs")) |
10053
a4ceacb1816d
[gaim-migrate @ 11016]
Luke Schierer <lschiere@pidgin.im>
parents:
10025
diff
changeset
|
4807 gtk_widget_show(gtkconv->close); |
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5484
diff
changeset
|
4808 |
4445 | 4809 gtk_widget_show(tabby); |
6771
8eebba08b44b
[gaim-migrate @ 7308]
Christian Hammond <chipx86@chipx86.com>
parents:
6760
diff
changeset
|
4810 gtk_widget_show(menu_tabby); |
4359 | 4811 |
7143 | 4812 if (gaim_conversation_get_type(conv) == GAIM_CONV_IM) |
4813 gaim_gtkconv_update_buddy_icon(conv); | |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
4814 |
9297 | 4815 /* Add this pane to the conversation's notebook. */ |
9606 | 4816 gtk_notebook_append_page_menu(GTK_NOTEBOOK(gtkwin->notebook), tab_cont, tabby, menu_tabby); |
4359 | 4817 |
4818 gtk_widget_show(tab_cont); | |
4819 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4820 if (gaim_conv_window_get_conversation_count(win) == 1) { |
4818 | 4821 /* Er, bug in notebooks? Switch to the page manually. */ |
4359 | 4822 gtk_notebook_set_current_page(GTK_NOTEBOOK(gtkwin->notebook), 0); |
4851 | 4823 |
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5484
diff
changeset
|
4824 gtk_notebook_set_show_tabs(GTK_NOTEBOOK(gtkwin->notebook), |
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5484
diff
changeset
|
4825 gaim_prefs_get_bool("/gaim/gtk/conversations/tabs")); |
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5484
diff
changeset
|
4826 } |
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5484
diff
changeset
|
4827 else |
4818 | 4828 gtk_notebook_set_show_tabs(GTK_NOTEBOOK(gtkwin->notebook), TRUE); |
4359 | 4829 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4830 focus_conv = g_list_nth_data(gaim_conv_window_get_conversations(win), |
5204 | 4831 gtk_notebook_get_current_page(GTK_NOTEBOOK(gtkwin->notebook))); |
4832 focus_gtkconv = GAIM_GTK_CONVERSATION(focus_conv); | |
4833 gtk_widget_grab_focus(focus_gtkconv->entry); | |
4359 | 4834 |
4835 if (!new_ui) | |
4836 g_object_unref(gtkconv->tab_cont); | |
4837 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4838 if (gaim_conv_window_get_conversation_count(win) == 1) |
4685 | 4839 g_timeout_add(0, (GSourceFunc)update_send_as_selection, win); |
4359 | 4840 } |
4841 | |
4842 static void | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4843 gaim_gtk_remove_conversation(GaimConvWindow *win, GaimConversation *conv) |
4359 | 4844 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4845 GaimGtkWindow *gtkwin; |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4846 GaimGtkConversation *gtkconv; |
4359 | 4847 unsigned int index; |
4818 | 4848 GaimConversationType conv_type; |
4849 | |
4850 conv_type = gaim_conversation_get_type(conv); | |
4359 | 4851 index = gaim_conversation_get_index(conv); |
4852 | |
4853 gtkwin = GAIM_GTK_WINDOW(win); | |
4854 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
4855 | |
4856 g_object_ref(gtkconv->tab_cont); | |
4857 gtk_object_sink(GTK_OBJECT(gtkconv->tab_cont)); | |
4858 | |
4859 gtk_notebook_remove_page(GTK_NOTEBOOK(gtkwin->notebook), index); | |
4860 | |
4818 | 4861 /* go back to tabless if need be */ |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4862 if (gaim_conv_window_get_conversation_count(win) <= 2) { |
4818 | 4863 gtk_notebook_set_show_tabs(GTK_NOTEBOOK(gtkwin->notebook), |
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5484
diff
changeset
|
4864 gaim_prefs_get_bool("/gaim/gtk/conversations/tabs")); |
4818 | 4865 } |
4866 | |
4867 | |
4359 | 4868 /* If this window is setup with an inactive gc, regenerate the menu. */ |
4818 | 4869 if (conv_type == GAIM_CONV_IM && |
4359 | 4870 gaim_conversation_get_gc(conv) == NULL) { |
4871 | |
4360
c435a29370b8
[gaim-migrate @ 4626]
Christian Hammond <chipx86@chipx86.com>
parents:
4359
diff
changeset
|
4872 generate_send_as_items(win, conv); |
4359 | 4873 } |
4874 } | |
4875 | |
4876 static void | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4877 gaim_gtk_move_conversation(GaimConvWindow *win, GaimConversation *conv, |
4359 | 4878 unsigned int new_index) |
4879 { | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4880 GaimGtkWindow *gtkwin; |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4881 GaimGtkConversation *gtkconv; |
4359 | 4882 |
4883 gtkwin = GAIM_GTK_WINDOW(win); | |
4884 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
4885 | |
4415
c90039137172
[gaim-migrate @ 4688]
Christian Hammond <chipx86@chipx86.com>
parents:
4409
diff
changeset
|
4886 if (new_index > gaim_conversation_get_index(conv)) |
c90039137172
[gaim-migrate @ 4688]
Christian Hammond <chipx86@chipx86.com>
parents:
4409
diff
changeset
|
4887 new_index--; |
c90039137172
[gaim-migrate @ 4688]
Christian Hammond <chipx86@chipx86.com>
parents:
4409
diff
changeset
|
4888 |
4359 | 4889 gtk_notebook_reorder_child(GTK_NOTEBOOK(gtkwin->notebook), |
4890 gtkconv->tab_cont, new_index); | |
4891 } | |
4892 | |
4893 static int | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4894 gaim_gtk_get_active_index(const GaimConvWindow *win) |
4359 | 4895 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4896 GaimGtkWindow *gtkwin; |
5680
71cc0d5376c2
[gaim-migrate @ 6098]
Christian Hammond <chipx86@chipx86.com>
parents:
5678
diff
changeset
|
4897 int index; |
4359 | 4898 |
4899 gtkwin = GAIM_GTK_WINDOW(win); | |
4900 | |
5680
71cc0d5376c2
[gaim-migrate @ 6098]
Christian Hammond <chipx86@chipx86.com>
parents:
5678
diff
changeset
|
4901 index = gtk_notebook_get_current_page(GTK_NOTEBOOK(gtkwin->notebook)); |
71cc0d5376c2
[gaim-migrate @ 6098]
Christian Hammond <chipx86@chipx86.com>
parents:
5678
diff
changeset
|
4902 |
71cc0d5376c2
[gaim-migrate @ 6098]
Christian Hammond <chipx86@chipx86.com>
parents:
5678
diff
changeset
|
4903 /* |
71cc0d5376c2
[gaim-migrate @ 6098]
Christian Hammond <chipx86@chipx86.com>
parents:
5678
diff
changeset
|
4904 * A fix, because the first conversation may be active, but not |
71cc0d5376c2
[gaim-migrate @ 6098]
Christian Hammond <chipx86@chipx86.com>
parents:
5678
diff
changeset
|
4905 * appear in the notebook just yet. -- ChipX86 |
71cc0d5376c2
[gaim-migrate @ 6098]
Christian Hammond <chipx86@chipx86.com>
parents:
5678
diff
changeset
|
4906 */ |
71cc0d5376c2
[gaim-migrate @ 6098]
Christian Hammond <chipx86@chipx86.com>
parents:
5678
diff
changeset
|
4907 return (index == -1 ? 0 : index); |
4359 | 4908 } |
4909 | |
9260
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
4910 static gboolean |
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
4911 gaim_gtk_has_focus(GaimConvWindow *win) |
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
4912 { |
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
4913 GaimGtkWindow *gtkwin; |
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
4914 gboolean has_focus = FALSE; |
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
4915 |
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
4916 gtkwin = GAIM_GTK_WINDOW(win); |
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
4917 g_object_get(G_OBJECT(gtkwin->window), "has-toplevel-focus", &has_focus, NULL); |
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
4918 |
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
4919 return has_focus; |
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
4920 } |
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
4921 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4922 static GaimConvWindowUiOps window_ui_ops = |
4359 | 4923 { |
7035
feb3d21a7794
[gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents:
7008
diff
changeset
|
4924 gaim_gtk_conversations_get_conv_ui_ops, |
4359 | 4925 gaim_gtk_new_window, |
4926 gaim_gtk_destroy_window, | |
4927 gaim_gtk_show, | |
4928 gaim_gtk_hide, | |
4929 gaim_gtk_raise, | |
4930 gaim_gtk_flash, | |
4931 gaim_gtk_switch_conversation, | |
4932 gaim_gtk_add_conversation, | |
4933 gaim_gtk_remove_conversation, | |
4934 gaim_gtk_move_conversation, | |
9260
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
4935 gaim_gtk_get_active_index, |
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
4936 gaim_gtk_has_focus |
4359 | 4937 }; |
4938 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4939 GaimConvWindowUiOps * |
7035
feb3d21a7794
[gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents:
7008
diff
changeset
|
4940 gaim_gtk_conversations_get_win_ui_ops(void) |
4359 | 4941 { |
4465
6e37eb000b7a
[gaim-migrate @ 4740]
Christian Hammond <chipx86@chipx86.com>
parents:
4454
diff
changeset
|
4942 return &window_ui_ops; |
4359 | 4943 } |
4944 | |
4945 /************************************************************************** | |
4465
6e37eb000b7a
[gaim-migrate @ 4740]
Christian Hammond <chipx86@chipx86.com>
parents:
4454
diff
changeset
|
4946 * Conversation UI operations |
4359 | 4947 **************************************************************************/ |
4948 static void | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4949 gaim_gtkconv_destroy(GaimConversation *conv) |
4359 | 4950 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4951 GaimGtkConversation *gtkconv = GAIM_GTK_CONVERSATION(conv); |
4359 | 4952 |
9504 | 4953 /* If the "Save Conversation" or "Save Icon" dialogs are open then close them */ |
4954 gaim_request_close_with_handle(conv); | |
4359 | 4955 |
4571
51e988d015ed
[gaim-migrate @ 4852]
Christian Hammond <chipx86@chipx86.com>
parents:
4561
diff
changeset
|
4956 gtk_widget_destroy(gtkconv->tab_cont); |
4892 | 4957 g_object_unref(gtkconv->tab_cont); |
4571
51e988d015ed
[gaim-migrate @ 4852]
Christian Hammond <chipx86@chipx86.com>
parents:
4561
diff
changeset
|
4958 |
4359 | 4959 if (gaim_conversation_get_type(conv) == GAIM_CONV_IM) { |
4755 | 4960 if (gtkconv->u.im->icon_timer != 0) |
4961 g_source_remove(gtkconv->u.im->icon_timer); | |
4962 | |
4359 | 4963 if (gtkconv->u.im->anim != NULL) |
4793 | 4964 g_object_unref(G_OBJECT(gtkconv->u.im->anim)); |
4359 | 4965 |
4966 g_free(gtkconv->u.im); | |
4967 } | |
4968 else if (gaim_conversation_get_type(conv) == GAIM_CONV_CHAT) { | |
4969 g_free(gtkconv->u.chat); | |
4970 } | |
4971 | |
4633 | 4972 gtk_object_sink(GTK_OBJECT(gtkconv->tooltips)); |
4973 | |
4359 | 4974 g_free(gtkconv); |
4975 } | |
4976 | |
4977 static void | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4978 gaim_gtkconv_write_im(GaimConversation *conv, const char *who, |
6982 | 4979 const char *message, GaimMessageFlags flags, |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4980 time_t mtime) |
4359 | 4981 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
4982 GaimGtkConversation *gtkconv; |
8630 | 4983 GaimConvWindow *gaimwin; |
4984 GaimGtkWindow *gtkwin; | |
4985 gboolean has_focus; | |
4359 | 4986 |
4987 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
8630 | 4988 gaimwin = gaim_conversation_get_window(conv); |
4989 gtkwin = GAIM_GTK_WINDOW(gaimwin); | |
4990 | |
4991 g_object_get(G_OBJECT(gtkwin->window), "has-toplevel-focus", &has_focus, NULL); | |
4359 | 4992 |
6621 | 4993 if (!(flags & GAIM_MESSAGE_NO_LOG) && |
9301 | 4994 gaim_prefs_get_bool("/gaim/gtk/conversations/im/raise_on_events")) { |
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5484
diff
changeset
|
4995 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
4996 gaim_conv_window_raise(gaim_conversation_get_window(conv)); |
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5484
diff
changeset
|
4997 } |
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5484
diff
changeset
|
4998 |
4382
76223649765b
[gaim-migrate @ 4648]
Christian Hammond <chipx86@chipx86.com>
parents:
4378
diff
changeset
|
4999 /* Play a sound, if specified in prefs. */ |
8630 | 5000 if (gtkconv->make_sound && !((gaim_conv_window_get_active_conversation(gaimwin) == conv) && |
8633 | 5001 !gaim_prefs_get_bool("/gaim/gtk/sound/conv_focus") && has_focus)) { |
6621 | 5002 if (flags & GAIM_MESSAGE_RECV) { |
4359 | 5003 if (gtkconv->u.im->a_virgin && |
5820 | 5004 gaim_prefs_get_bool("/gaim/gtk/sound/enabled/first_im_recv")) { |
4359 | 5005 |
4561 | 5006 gaim_sound_play_event(GAIM_SOUND_FIRST_RECEIVE); |
4359 | 5007 } |
5008 else | |
4561 | 5009 gaim_sound_play_event(GAIM_SOUND_RECEIVE); |
4359 | 5010 } |
5011 else { | |
4561 | 5012 gaim_sound_play_event(GAIM_SOUND_SEND); |
4359 | 5013 } |
5014 } | |
5015 | |
5016 gtkconv->u.im->a_virgin = FALSE; | |
5017 | |
6982 | 5018 gaim_conversation_write(conv, who, message, flags, mtime); |
4359 | 5019 } |
5020 | |
5021 static void | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5022 gaim_gtkconv_write_chat(GaimConversation *conv, const char *who, |
6621 | 5023 const char *message, GaimMessageFlags flags, time_t mtime) |
4359 | 5024 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5025 GaimGtkConversation *gtkconv; |
8630 | 5026 GaimConvWindow *gaimwin; |
5027 GaimGtkWindow *gtkwin; | |
5028 gboolean has_focus; | |
4359 | 5029 |
5030 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
8630 | 5031 gaimwin = gaim_conversation_get_window(conv); |
5032 gtkwin = GAIM_GTK_WINDOW(gaimwin); | |
5033 | |
5034 g_object_get(G_OBJECT(gtkwin->window), "has-toplevel-focus", &has_focus, NULL); | |
4359 | 5035 |
4382
76223649765b
[gaim-migrate @ 4648]
Christian Hammond <chipx86@chipx86.com>
parents:
4378
diff
changeset
|
5036 /* Play a sound, if specified in prefs. */ |
8630 | 5037 if (gtkconv->make_sound && !((gaim_conv_window_get_active_conversation(gaimwin) == conv) && |
9704 | 5038 !gaim_prefs_get_bool("/gaim/gtk/sound/conv_focus") && has_focus) && |
5039 !(flags & GAIM_MESSAGE_DELAYED) && | |
5040 !(flags & GAIM_MESSAGE_SYSTEM)) { | |
5041 | |
6621 | 5042 if (!(flags & GAIM_MESSAGE_WHISPER) && (flags & GAIM_MESSAGE_SEND)) |
4561 | 5043 gaim_sound_play_event(GAIM_SOUND_CHAT_YOU_SAY); |
9704 | 5044 else if (flags & GAIM_MESSAGE_RECV) { |
6621 | 5045 if ((flags & GAIM_MESSAGE_NICK) && |
9584 | 5046 gaim_prefs_get_bool("/gaim/gtk/sound/enabled/nick_said")) { |
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5484
diff
changeset
|
5047 |
4561 | 5048 gaim_sound_play_event(GAIM_SOUND_CHAT_NICK); |
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5484
diff
changeset
|
5049 } |
4359 | 5050 else |
4561 | 5051 gaim_sound_play_event(GAIM_SOUND_CHAT_SAY); |
4359 | 5052 } |
5053 } | |
5054 | |
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5484
diff
changeset
|
5055 if (gaim_prefs_get_bool("/gaim/gtk/conversations/chat/color_nicks")) |
6621 | 5056 flags |= GAIM_MESSAGE_COLORIZE; |
4359 | 5057 |
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5484
diff
changeset
|
5058 /* Raise the window, if specified in prefs. */ |
6621 | 5059 if (!(flags & GAIM_MESSAGE_NO_LOG) && |
9150 | 5060 /* we may want to change this */ |
9301 | 5061 gaim_prefs_get_bool("/gaim/gtk/conversations/chat/raise_on_events")) { |
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5484
diff
changeset
|
5062 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
5063 gaim_conv_window_raise(gaim_conversation_get_window(conv)); |
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5484
diff
changeset
|
5064 } |
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5484
diff
changeset
|
5065 |
6982 | 5066 gaim_conversation_write(conv, who, message, flags, mtime); |
4359 | 5067 } |
5068 | |
5069 static void | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5070 gaim_gtkconv_write_conv(GaimConversation *conv, const char *who, |
6982 | 5071 const char *message, GaimMessageFlags flags, |
4359 | 5072 time_t mtime) |
5073 { | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5074 GaimGtkConversation *gtkconv; |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
5075 GaimConvWindow *win; |
5563
9eb5b13fd412
[gaim-migrate @ 5965]
Christian Hammond <chipx86@chipx86.com>
parents:
5551
diff
changeset
|
5076 GaimConnection *gc; |
4359 | 5077 int gtk_font_options = 0; |
7440 | 5078 char buf[BUF_LONG]; |
4359 | 5079 char buf2[BUF_LONG]; |
5080 char mdate[64]; | |
5081 char color[10]; | |
5082 char *str; | |
5083 char *with_font_tag; | |
4896 | 5084 char *sml_attrib = NULL; |
6982 | 5085 size_t length = strlen(message) + 1; |
4895 | 5086 |
4359 | 5087 gtkconv = GAIM_GTK_CONVERSATION(conv); |
5088 gc = gaim_conversation_get_gc(conv); | |
5089 | |
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5484
diff
changeset
|
5090 win = gaim_conversation_get_window(conv); |
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5484
diff
changeset
|
5091 |
9301 | 5092 if (!(flags & GAIM_MESSAGE_NO_LOG) && |
5093 ((gaim_conversation_get_type(conv) == GAIM_CONV_CHAT && | |
5094 gaim_prefs_get_bool("/gaim/gtk/conversations/chat/raise_on_events")) || | |
5095 (gaim_conversation_get_type(conv) == GAIM_CONV_IM && | |
5096 gaim_prefs_get_bool("/gaim/gtk/conversations/im/raise_on_events")))) { | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
5097 gaim_conv_window_show(win); |
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5484
diff
changeset
|
5098 } |
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5484
diff
changeset
|
5099 |
8677 | 5100 if (gtk_text_buffer_get_char_count(gtk_text_view_get_buffer(GTK_TEXT_VIEW(gtkconv->imhtml)))) |
5101 gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), "<BR>", 0); | |
5102 | |
5133 | 5103 if(time(NULL) > mtime + 20*60) /* show date if older than 20 minutes */ |
5104 strftime(mdate, sizeof(mdate), "%Y-%m-%d %H:%M:%S", localtime(&mtime)); | |
5105 else | |
5106 strftime(mdate, sizeof(mdate), "%H:%M:%S", localtime(&mtime)); | |
4359 | 5107 |
4896 | 5108 if(gc) |
9699 | 5109 sml_attrib = g_strdup_printf("sml=\"%s\"", |
5110 gaim_account_get_protocol_name(conv->account)); | |
7440 | 5111 |
4359 | 5112 gtk_font_options ^= GTK_IMHTML_NO_COMMENTS; |
5113 | |
9049 | 5114 if (gaim_prefs_get_bool("/gaim/gtk/conversations/ignore_colors")) |
5115 gtk_font_options ^= GTK_IMHTML_NO_COLOURS; | |
5116 if (gaim_prefs_get_bool("/gaim/gtk/conversations/ignore_fonts")) | |
5117 gtk_font_options ^= GTK_IMHTML_NO_FONTS; | |
5118 if (gaim_prefs_get_bool("/gaim/gtk/conversations/ignore_font_sizes")) | |
5119 gtk_font_options ^= GTK_IMHTML_NO_SIZES; | |
4359 | 5120 |
7956 | 5121 /* this is gonna crash one day, I can feel it. */ |
5122 if (GAIM_PLUGIN_PROTOCOL_INFO(gaim_find_prpl(gaim_account_get_protocol_id(conv->account)))->options & | |
7431 | 5123 OPT_PROTO_USE_POINTSIZE) { |
5367 | 5124 gtk_font_options ^= GTK_IMHTML_USE_POINTSIZE; |
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5484
diff
changeset
|
5125 } |
4359 | 5126 |
6621 | 5127 if (flags & GAIM_MESSAGE_SYSTEM) { |
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5484
diff
changeset
|
5128 if (gaim_prefs_get_bool("/gaim/gtk/conversations/show_timestamps")) |
8380 | 5129 g_snprintf(buf, BUF_LONG, "<FONT SIZE=\"2\">(%s)</FONT> <B>%s</B>", |
7431 | 5130 mdate, message); |
4359 | 5131 else |
5132 g_snprintf(buf, BUF_LONG, "<B>%s</B>", message); | |
7440 | 5133 |
4359 | 5134 g_snprintf(buf2, sizeof(buf2), |
8690 | 5135 "<FONT %s><FONT SIZE=\"2\"><!--(%s) --></FONT><B>%s</B></FONT>", |
7850 | 5136 sml_attrib, mdate, message); |
7440 | 5137 |
8962 | 5138 gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), buf2, 0); |
7440 | 5139 |
7583 | 5140 /* Add the message to a conversations scrollback buffer */ |
5141 conv->history = g_string_append(conv->history, buf); | |
5142 conv->history = g_string_append(conv->history, "<BR>\n"); | |
7440 | 5143 |
8722 | 5144 } else if (flags & GAIM_MESSAGE_ERROR) { |
5145 if (gaim_prefs_get_bool("/gaim/gtk/conversations/show_timestamps")) | |
9627 | 5146 g_snprintf(buf, BUF_LONG, "<FONT COLOR=\"#ff0000\"><FONT SIZE=\"2\">(%s)</FONT> <B>%s</B></FONT>", |
8722 | 5147 mdate, message); |
5148 else | |
5149 g_snprintf(buf, BUF_LONG, "<FONT COLOR=\"#ff0000\"><B>%s</B></FONT>", message); | |
9554 | 5150 |
8722 | 5151 g_snprintf(buf2, sizeof(buf2), |
9627 | 5152 "<FONT COLOR=\"#ff0000\"><FONT %s><FONT SIZE=\"2\"><!--(%s) --></FONT><B>%s</B></FONT></FONT>", |
8722 | 5153 sml_attrib, mdate, message); |
9554 | 5154 |
8962 | 5155 gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), buf2, 0); |
5156 | |
8722 | 5157 /* Add the message to a conversations scrollback buffer */ |
5158 conv->history = g_string_append(conv->history, buf); | |
5159 conv->history = g_string_append(conv->history, "<BR>\n"); | |
7431 | 5160 } else if (flags & GAIM_MESSAGE_NO_LOG) { |
4359 | 5161 g_snprintf(buf, BUF_LONG, |
8690 | 5162 "<B><FONT %s COLOR=\"#777777\">%s</FONT></B>", |
7850 | 5163 sml_attrib, message); |
7440 | 5164 |
8962 | 5165 gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), buf, 0); |
4359 | 5166 } |
5167 else { | |
4895 | 5168 char *new_message = g_memdup(message, length); |
9613 | 5169 char *who_escaped = (who ? g_markup_escape_text(who, strlen(who)) : g_strdup("")); |
7440 | 5170 |
6621 | 5171 if (flags & GAIM_MESSAGE_WHISPER) { |
4359 | 5172 str = g_malloc(1024); |
7440 | 5173 |
4359 | 5174 /* If we're whispering, it's not an autoresponse. */ |
7564 | 5175 if (gaim_message_meify(new_message, length)) { |
8908 | 5176 g_snprintf(str, 1024, "***%s", who_escaped); |
4359 | 5177 strcpy(color, "#6C2585"); |
5178 } | |
5179 else { | |
8908 | 5180 g_snprintf(str, 1024, "*%s*:", who_escaped); |
4359 | 5181 strcpy(color, "#00FF00"); |
5182 } | |
7440 | 5183 } |
4359 | 5184 else { |
7564 | 5185 if (gaim_message_meify(new_message, length)) { |
4359 | 5186 str = g_malloc(1024); |
7440 | 5187 |
6621 | 5188 if (flags & GAIM_MESSAGE_AUTO_RESP) |
8908 | 5189 g_snprintf(str, 1024, "%s ***%s", AUTO_RESPONSE, who_escaped); |
4359 | 5190 else |
8908 | 5191 g_snprintf(str, 1024, "***%s", who_escaped); |
7440 | 5192 |
6621 | 5193 if (flags & GAIM_MESSAGE_NICK) |
4359 | 5194 strcpy(color, "#AF7F00"); |
5195 else | |
5196 strcpy(color, "#062585"); | |
5197 } | |
5198 else { | |
5199 str = g_malloc(1024); | |
6621 | 5200 if (flags & GAIM_MESSAGE_AUTO_RESP) |
8908 | 5201 g_snprintf(str, 1024, "%s %s", who_escaped, AUTO_RESPONSE); |
4359 | 5202 else |
8908 | 5203 g_snprintf(str, 1024, "%s:", who_escaped); |
6621 | 5204 if (flags & GAIM_MESSAGE_NICK) |
4359 | 5205 strcpy(color, "#AF7F00"); |
6621 | 5206 else if (flags & GAIM_MESSAGE_RECV) { |
10108 | 5207 if (flags & GAIM_MESSAGE_COLORIZE) { |
5208 GtkStyle *style = gtk_widget_get_style(gtkconv->imhtml); | |
5209 GdkColor col = nick_colors[g_str_hash(who) % NUM_NICK_COLORS]; | |
5210 float scale = ((1-(LUMINANCE(style->base[GTK_STATE_NORMAL]) / LUMINANCE(style->white))) * | |
5211 (LUMINANCE(style->white)/MAX(MAX(col.red, col.blue), col.green))); | |
5212 if (scale > 1) { /* The colors are chosen to look fine on white; we should never have to darken */ | |
5213 col.red = col.red * scale; | |
5214 col.green = col.green * scale; | |
5215 col.blue = col.blue * scale; | |
5216 } | |
5217 | |
5218 g_snprintf(color, sizeof(color), "#%02X%02X%02X", | |
5219 col.red >> 8, col.green >> 8, col.blue >> 8); | |
5220 } else | |
7854 | 5221 strcpy(color, RECV_COLOR); |
4359 | 5222 } |
6621 | 5223 else if (flags & GAIM_MESSAGE_SEND) |
7854 | 5224 strcpy(color, SEND_COLOR); |
4359 | 5225 } |
8908 | 5226 |
5227 if(who_escaped) | |
5228 g_free(who_escaped); | |
4359 | 5229 } |
7440 | 5230 |
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5484
diff
changeset
|
5231 if (gaim_prefs_get_bool("/gaim/gtk/conversations/show_timestamps")) |
4359 | 5232 g_snprintf(buf, BUF_LONG, |
8380 | 5233 "<FONT COLOR=\"%s\" %s><FONT SIZE=\"2\">(%s)</FONT> " |
7431 | 5234 "<B>%s</B></FONT> ", color, |
5235 sml_attrib ? sml_attrib : "", mdate, str); | |
4359 | 5236 else |
5237 g_snprintf(buf, BUF_LONG, | |
7431 | 5238 "<FONT COLOR=\"%s\" %s><B>%s</B></FONT> ", color, |
5239 sml_attrib ? sml_attrib : "", str); | |
7440 | 5240 |
4359 | 5241 g_snprintf(buf2, BUF_LONG, |
8380 | 5242 "<FONT COLOR=\"%s\" %s><FONT SIZE=\"2\"><!--(%s) --></FONT>" |
7431 | 5243 "<B>%s</B></FONT> ", |
5244 color, sml_attrib ? sml_attrib : "", mdate, str); | |
7440 | 5245 |
4359 | 5246 g_free(str); |
5247 | |
8962 | 5248 gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), |
5249 buf2, 0); | |
4359 | 5250 |
4895 | 5251 if(gc){ |
4896 | 5252 char *pre = g_strdup_printf("<font %s>", sml_attrib ? sml_attrib : ""); |
4895 | 5253 char *post = "</font>"; |
5254 int pre_len = strlen(pre); | |
5255 int post_len = strlen(post); | |
7440 | 5256 |
4895 | 5257 with_font_tag = g_malloc(length + pre_len + post_len + 1); |
7440 | 5258 |
4895 | 5259 strcpy(with_font_tag, pre); |
5260 memcpy(with_font_tag + pre_len, new_message, length); | |
5261 strcpy(with_font_tag + pre_len + length, post); | |
7440 | 5262 |
4895 | 5263 length += pre_len + post_len; |
5264 g_free(pre); | |
5265 } | |
4608 | 5266 else |
4895 | 5267 with_font_tag = g_memdup(new_message, length); |
7440 | 5268 |
8962 | 5269 gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), |
5270 with_font_tag, gtk_font_options); | |
7440 | 5271 |
8557 | 5272 conv->history = g_string_append(conv->history, buf); |
5273 conv->history = g_string_append(conv->history, new_message); | |
5274 conv->history = g_string_append(conv->history, "<BR>\n"); | |
7440 | 5275 |
5276 g_free(with_font_tag); | |
7447 | 5277 g_free(new_message); |
7440 | 5278 } |
5279 | |
6062 | 5280 |
5012 | 5281 if(sml_attrib) |
5282 g_free(sml_attrib); | |
4359 | 5283 } |
5284 | |
5285 static void | |
9846 | 5286 gaim_gtkconv_chat_add_user(GaimConversation *conv, const char *user, gboolean new_arrival) |
4359 | 5287 { |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
5288 GaimConvChat *chat; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5289 GaimGtkConversation *gtkconv; |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5290 GaimGtkChatPane *gtkchat; |
4359 | 5291 char tmp[BUF_LONG]; |
5292 int num_users; | |
5293 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
5294 chat = GAIM_CONV_CHAT(conv); |
4359 | 5295 gtkconv = GAIM_GTK_CONVERSATION(conv); |
5296 gtkchat = gtkconv->u.chat; | |
5297 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
5298 num_users = g_list_length(gaim_conv_chat_get_users(chat)); |
4359 | 5299 |
5300 g_snprintf(tmp, sizeof(tmp), | |
5301 ngettext("%d person in room", "%d people in room", | |
5302 num_users), | |
5303 num_users); | |
5304 | |
5305 gtk_label_set_text(GTK_LABEL(gtkchat->count), tmp); | |
5306 | |
9846 | 5307 if (gtkconv->make_sound && new_arrival) |
4561 | 5308 gaim_sound_play_event(GAIM_SOUND_CHAT_JOIN); |
4359 | 5309 |
9554 | 5310 add_chat_buddy_common(conv, user); |
4359 | 5311 } |
5312 | |
5313 static void | |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5314 gaim_gtkconv_chat_add_users(GaimConversation *conv, GList *users) |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5315 { |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
5316 GaimConvChat *chat; |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5317 GaimGtkConversation *gtkconv; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5318 GaimGtkChatPane *gtkchat; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5319 GList *l; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5320 char tmp[BUF_LONG]; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5321 int num_users; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5322 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
5323 chat = GAIM_CONV_CHAT(conv); |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5324 gtkconv = GAIM_GTK_CONVERSATION(conv); |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5325 gtkchat = gtkconv->u.chat; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5326 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
5327 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
|
5328 |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5329 g_snprintf(tmp, sizeof(tmp), |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5330 ngettext("%d person in room", "%d people in room", |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5331 num_users), |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5332 num_users); |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5333 |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5334 gtk_label_set_text(GTK_LABEL(gtkchat->count), tmp); |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5335 |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5336 for (l = users; l != NULL; l = l->next) { |
9554 | 5337 add_chat_buddy_common(conv, (char *)l->data); |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5338 } |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5339 } |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5340 |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5341 static void |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5342 gaim_gtkconv_chat_rename_user(GaimConversation *conv, const char *old_name, |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5343 const char *new_name) |
4359 | 5344 { |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
5345 GaimConvChat *chat; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5346 GaimGtkConversation *gtkconv; |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5347 GaimGtkChatPane *gtkchat; |
4359 | 5348 GtkTreeIter iter; |
5349 GtkTreeModel *model; | |
5350 int f = 1; | |
5351 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
5352 chat = GAIM_CONV_CHAT(conv); |
4359 | 5353 gtkconv = GAIM_GTK_CONVERSATION(conv); |
5354 gtkchat = gtkconv->u.chat; | |
5355 | |
9554 | 5356 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); |
5357 | |
5358 if (!gtk_tree_model_get_iter_first(GTK_TREE_MODEL(model), &iter)) | |
5359 return; | |
5360 | |
5361 while (f != 0) { | |
5362 char *val; | |
5363 | |
5364 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, CHAT_USERS_NAME_COLUMN, &val, -1); | |
5365 | |
5366 if (!gaim_utf8_strcasecmp(old_name, val)) { | |
5367 gtk_list_store_remove(GTK_LIST_STORE(model), &iter); | |
5368 g_free(val); | |
4359 | 5369 break; |
5370 } | |
9554 | 5371 |
5372 f = gtk_tree_model_iter_next(GTK_TREE_MODEL(model), &iter); | |
5373 | |
5374 g_free(val); | |
4359 | 5375 } |
5376 | |
9554 | 5377 if (!gaim_conv_chat_find_user(chat, old_name)) |
4359 | 5378 return; |
5379 | |
9554 | 5380 add_chat_buddy_common(conv, new_name); |
4359 | 5381 } |
5382 | |
5383 static void | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5384 gaim_gtkconv_chat_remove_user(GaimConversation *conv, const char *user) |
4359 | 5385 { |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
5386 GaimConvChat *chat; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5387 GaimGtkConversation *gtkconv; |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5388 GaimGtkChatPane *gtkchat; |
4359 | 5389 GtkTreeIter iter; |
5390 GtkTreeModel *model; | |
5391 char tmp[BUF_LONG]; | |
5392 int num_users; | |
5393 int f = 1; | |
5394 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
5395 chat = GAIM_CONV_CHAT(conv); |
4359 | 5396 gtkconv = GAIM_GTK_CONVERSATION(conv); |
5397 gtkchat = gtkconv->u.chat; | |
5398 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
5399 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
|
5400 |
9554 | 5401 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); |
5402 | |
5403 if (!gtk_tree_model_get_iter_first(GTK_TREE_MODEL(model), &iter)) | |
5404 return; | |
5405 | |
5406 while (f != 0) { | |
5407 char *val; | |
5408 | |
5409 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, CHAT_USERS_NAME_COLUMN, &val, -1); | |
5410 | |
5411 if (!gaim_utf8_strcasecmp(user, val)) { | |
5412 gtk_list_store_remove(GTK_LIST_STORE(model), &iter); | |
5413 g_free(val); | |
4359 | 5414 break; |
5415 } | |
9554 | 5416 |
5417 f = gtk_tree_model_iter_next(GTK_TREE_MODEL(model), &iter); | |
5418 | |
5419 g_free(val); | |
4359 | 5420 } |
5421 | |
9554 | 5422 if (!gaim_conv_chat_find_user(chat, user)) |
4359 | 5423 return; |
5424 | |
5425 g_snprintf(tmp, sizeof(tmp), | |
9554 | 5426 ngettext("%d person in room", "%d people in room", |
5427 num_users), num_users); | |
4359 | 5428 |
5429 gtk_label_set_text(GTK_LABEL(gtkchat->count), tmp); | |
5430 | |
5431 if (gtkconv->make_sound) | |
4561 | 5432 gaim_sound_play_event(GAIM_SOUND_CHAT_LEAVE); |
4359 | 5433 } |
5434 | |
5435 static void | |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5436 gaim_gtkconv_chat_remove_users(GaimConversation *conv, GList *users) |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5437 { |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
5438 GaimConvChat *chat; |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5439 GaimGtkConversation *gtkconv; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5440 GaimGtkChatPane *gtkchat; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5441 GtkTreeIter iter; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5442 GtkTreeModel *model; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5443 GList *l; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5444 char tmp[BUF_LONG]; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5445 int num_users; |
8256
1d86096ae0f4
[gaim-migrate @ 8979]
Christian Hammond <chipx86@chipx86.com>
parents:
8253
diff
changeset
|
5446 gboolean f; |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5447 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
5448 chat = GAIM_CONV_CHAT(conv); |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5449 gtkconv = GAIM_GTK_CONVERSATION(conv); |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5450 gtkchat = gtkconv->u.chat; |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5451 |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
5452 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
|
5453 g_list_length(users); |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5454 |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5455 for (l = users; l != NULL; l = l->next) { |
9554 | 5456 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); |
5457 | |
5458 if (!gtk_tree_model_get_iter_first(GTK_TREE_MODEL(model), | |
5459 &iter)) | |
5460 continue; | |
5461 | |
5462 do { | |
5463 char *val; | |
5464 | |
5465 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, | |
5466 CHAT_USERS_NAME_COLUMN, &val, -1); | |
5467 | |
9696 | 5468 if (!gaim_utf8_strcasecmp((char *)l->data, val)) { |
5469 #if GTK_CHECK_VERSION(2,2,0) | |
9554 | 5470 f = gtk_list_store_remove(GTK_LIST_STORE(model), &iter); |
9696 | 5471 #else |
5472 gtk_list_store_remove(GTK_LIST_STORE(model), &iter); | |
5473 f = gtk_tree_model_iter_next(GTK_TREE_MODEL(model), &iter); | |
5474 #endif | |
5475 } | |
9554 | 5476 else |
5477 f = gtk_tree_model_iter_next(GTK_TREE_MODEL(model), &iter); | |
5478 | |
5479 g_free(val); | |
5480 } while (f); | |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5481 } |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5482 |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5483 g_snprintf(tmp, sizeof(tmp), |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5484 ngettext("%d person in room", "%d people in room", |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5485 num_users), num_users); |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5486 |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5487 gtk_label_set_text(GTK_LABEL(gtkchat->count), tmp); |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5488 } |
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5489 |
9554 | 5490 static void |
5491 gaim_gtkconv_chat_update_user(GaimConversation *conv, const char *user) | |
5492 { | |
5493 GaimConvChat *chat; | |
5494 GaimGtkConversation *gtkconv; | |
5495 GaimGtkChatPane *gtkchat; | |
5496 GtkTreeIter iter; | |
5497 GtkTreeModel *model; | |
5498 int f = 1; | |
5499 | |
5500 chat = GAIM_CONV_CHAT(conv); | |
5501 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
5502 gtkchat = gtkconv->u.chat; | |
5503 | |
5504 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); | |
5505 | |
5506 if (!gtk_tree_model_get_iter_first(GTK_TREE_MODEL(model), &iter)) | |
5507 return; | |
5508 | |
5509 while (f != 0) { | |
5510 char *val; | |
5511 | |
5512 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, CHAT_USERS_NAME_COLUMN, &val, -1); | |
5513 | |
5514 if (!gaim_utf8_strcasecmp(user, val)) { | |
5515 gtk_list_store_remove(GTK_LIST_STORE(model), &iter); | |
5516 g_free(val); | |
5517 break; | |
5518 } | |
5519 | |
5520 f = gtk_tree_model_iter_next(GTK_TREE_MODEL(model), &iter); | |
5521 | |
5522 g_free(val); | |
5523 } | |
5524 | |
5525 if (!gaim_conv_chat_find_user(chat, user)) | |
5526 return; | |
5527 | |
5528 add_chat_buddy_common(conv, user); | |
5529 } | |
5530 | |
9260
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
5531 static gboolean |
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
5532 gaim_gtkconv_has_focus(GaimConversation *conv) |
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
5533 { |
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
5534 GaimConvWindow *win; |
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
5535 GaimGtkWindow *gtkwin; |
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
5536 gboolean has_focus; |
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
5537 |
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
5538 win = gaim_conversation_get_window(conv); |
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
5539 gtkwin = GAIM_GTK_WINDOW(win); |
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
5540 |
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
5541 g_object_get(G_OBJECT(gtkwin->window), "has-toplevel-focus", &has_focus, NULL); |
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
5542 |
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
5543 return has_focus; |
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
5544 } |
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
5545 |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5546 static void |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5547 gaim_gtkconv_updated(GaimConversation *conv, GaimConvUpdateType type) |
4359 | 5548 { |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
5549 GaimConvWindow *win; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5550 GaimGtkWindow *gtkwin; |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5551 GaimGtkConversation *gtkconv; |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5552 GaimGtkChatPane *gtkchat; |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
5553 GaimConvChat *chat; |
4359 | 5554 |
5555 win = gaim_conversation_get_window(conv); | |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5556 gtkwin = GAIM_GTK_WINDOW(win); |
4359 | 5557 gtkconv = GAIM_GTK_CONVERSATION(conv); |
5558 | |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5559 if (type == GAIM_CONV_UPDATE_ACCOUNT) |
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5560 { |
4359 | 5561 gaim_conversation_autoset_title(conv); |
5881
cc7870e1e3b3
[gaim-migrate @ 6313]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
5562 |
cc7870e1e3b3
[gaim-migrate @ 6313]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
5563 if (gaim_conversation_get_type(conv) == GAIM_CONV_IM) |
cc7870e1e3b3
[gaim-migrate @ 6313]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
5564 gaim_gtkconv_update_buddy_icon(conv); |
cc7870e1e3b3
[gaim-migrate @ 6313]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
5565 |
4359 | 5566 gaim_gtkconv_update_buttons_by_protocol(conv); |
5567 | |
4685 | 5568 g_timeout_add(0, (GSourceFunc)update_send_as_selection, win); |
4359 | 5569 |
5570 smiley_themeize(gtkconv->imhtml); | |
6394 | 5571 |
6395 | 5572 update_tab_icon(conv); |
4359 | 5573 } |
5574 else if (type == GAIM_CONV_UPDATE_TYPING || | |
8155
77d1252b3803
[gaim-migrate @ 8867]
Christian Hammond <chipx86@chipx86.com>
parents:
8143
diff
changeset
|
5575 type == GAIM_CONV_UPDATE_UNSEEN || |
77d1252b3803
[gaim-migrate @ 8867]
Christian Hammond <chipx86@chipx86.com>
parents:
8143
diff
changeset
|
5576 type == GAIM_CONV_UPDATE_TITLE) |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5577 { |
9472 | 5578 char *title; |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
5579 GaimConvIm *im = NULL; |
9472 | 5580 GaimConnection *gc = gaim_conversation_get_gc(conv); |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5581 char color[8]; |
4736 | 5582 |
4359 | 5583 if (gaim_conversation_get_type(conv) == GAIM_CONV_IM) |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
5584 im = GAIM_CONV_IM(conv); |
4359 | 5585 |
9472 | 5586 if (!gc || ((gaim_conversation_get_type(conv) == GAIM_CONV_CHAT) |
5587 && gaim_conv_chat_has_left(GAIM_CONV_CHAT(conv)))) | |
5588 title = g_strdup_printf("(%s)", gaim_conversation_get_title(conv)); | |
5589 | |
5590 else | |
5591 title = g_strdup(gaim_conversation_get_title(conv)); | |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5592 |
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5593 *color = '\0'; |
4359 | 5594 |
5595 if (!GTK_WIDGET_REALIZED(gtkconv->tab_label)) | |
5596 gtk_widget_realize(gtkconv->tab_label); | |
5597 | |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5598 if (im != NULL && gaim_conv_im_get_typing_state(im) == GAIM_TYPING) |
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5599 { |
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5600 strcpy(color, "#47A046"); |
4359 | 5601 } |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5602 else if (im != NULL && gaim_conv_im_get_typing_state(im) == GAIM_TYPED) |
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5603 { |
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5604 strcpy(color, "#D1940C"); |
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5605 } |
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5606 else if (gaim_conversation_get_unseen(conv) == GAIM_UNSEEN_NICK) |
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5607 { |
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5608 strcpy(color, "#314E6C"); |
4359 | 5609 } |
8252 | 5610 else if (gaim_conversation_get_unseen(conv) == GAIM_UNSEEN_TEXT) |
5611 { | |
5612 strcpy(color, "#DF421E"); | |
5613 } | |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5614 else if (gaim_conversation_get_unseen(conv) == GAIM_UNSEEN_EVENT) |
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5615 { |
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5616 strcpy(color, "#868272"); |
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5617 } |
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5618 |
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5619 if (*color != '\0') |
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5620 { |
8536 | 5621 char *html_title,*label; |
5622 | |
5623 html_title = gaim_escape_html(title); | |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5624 |
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5625 label = g_strdup_printf("<span color=\"%s\">%s</span>", |
8536 | 5626 color, html_title); |
5627 g_free(html_title); | |
7995
87d3260f961a
[gaim-migrate @ 8672]
Christian Hammond <chipx86@chipx86.com>
parents:
7990
diff
changeset
|
5628 gtk_label_set_markup(GTK_LABEL(gtkconv->tab_label), label); |
87d3260f961a
[gaim-migrate @ 8672]
Christian Hammond <chipx86@chipx86.com>
parents:
7990
diff
changeset
|
5629 g_free(label); |
4359 | 5630 } |
7995
87d3260f961a
[gaim-migrate @ 8672]
Christian Hammond <chipx86@chipx86.com>
parents:
7990
diff
changeset
|
5631 else |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5632 gtk_label_set_text(GTK_LABEL(gtkconv->tab_label), title); |
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5633 |
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5634 if (conv == gaim_conv_window_get_active_conversation(win)) |
4736 | 5635 update_typing_icon(conv); |
8155
77d1252b3803
[gaim-migrate @ 8867]
Christian Hammond <chipx86@chipx86.com>
parents:
8143
diff
changeset
|
5636 |
77d1252b3803
[gaim-migrate @ 8867]
Christian Hammond <chipx86@chipx86.com>
parents:
8143
diff
changeset
|
5637 if (type == GAIM_CONV_UPDATE_TITLE) { |
77d1252b3803
[gaim-migrate @ 8867]
Christian Hammond <chipx86@chipx86.com>
parents:
8143
diff
changeset
|
5638 gtk_label_set_text(GTK_LABEL(gtkconv->menu_label), title); |
77d1252b3803
[gaim-migrate @ 8867]
Christian Hammond <chipx86@chipx86.com>
parents:
8143
diff
changeset
|
5639 if (conv == gaim_conv_window_get_active_conversation(win)) |
77d1252b3803
[gaim-migrate @ 8867]
Christian Hammond <chipx86@chipx86.com>
parents:
8143
diff
changeset
|
5640 gtk_window_set_title(GTK_WINDOW(gtkwin->window), title); |
77d1252b3803
[gaim-migrate @ 8867]
Christian Hammond <chipx86@chipx86.com>
parents:
8143
diff
changeset
|
5641 } |
9472 | 5642 |
5643 g_free(title); | |
4359 | 5644 } |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5645 else if (type == GAIM_CONV_UPDATE_TOPIC) |
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5646 { |
7154 | 5647 const char *topic; |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
5648 chat = GAIM_CONV_CHAT(conv); |
4359 | 5649 gtkchat = gtkconv->u.chat; |
5650 | |
7154 | 5651 topic = gaim_conv_chat_get_topic(chat); |
5652 | |
9554 | 5653 gtk_entry_set_text(GTK_ENTRY(gtkchat->topic_text), topic ? topic : ""); |
7154 | 5654 gtk_tooltips_set_tip(gtkconv->tooltips, gtkchat->topic_text, |
9554 | 5655 topic ? topic : "", NULL); |
4359 | 5656 } |
5657 else if (type == GAIM_CONV_ACCOUNT_ONLINE || | |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5658 type == GAIM_CONV_ACCOUNT_OFFLINE) |
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5659 { |
7929 | 5660 gray_stuff_out(gaim_conv_window_get_active_conversation(win)); |
4360
c435a29370b8
[gaim-migrate @ 4626]
Christian Hammond <chipx86@chipx86.com>
parents:
4359
diff
changeset
|
5661 generate_send_as_items(win, NULL); |
8946 | 5662 update_tab_icon(conv); |
9472 | 5663 gaim_conversation_autoset_title(conv); |
6392
e9974608b319
[gaim-migrate @ 6897]
Christian Hammond <chipx86@chipx86.com>
parents:
6371
diff
changeset
|
5664 } |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5665 else if (type == GAIM_CONV_UPDATE_AWAY) |
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5666 { |
8946 | 5667 update_tab_icon(conv); |
4359 | 5668 } |
8256
1d86096ae0f4
[gaim-migrate @ 8979]
Christian Hammond <chipx86@chipx86.com>
parents:
8253
diff
changeset
|
5669 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
|
5670 type == GAIM_CONV_UPDATE_CHATLEFT) |
8001
934f5df83b29
[gaim-migrate @ 8678]
Christian Hammond <chipx86@chipx86.com>
parents:
7996
diff
changeset
|
5671 { |
9472 | 5672 gaim_conversation_autoset_title(conv); |
7929 | 5673 gray_stuff_out(conv); |
4397
ce3a0eba91ef
[gaim-migrate @ 4666]
Christian Hammond <chipx86@chipx86.com>
parents:
4387
diff
changeset
|
5674 } |
6846
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6771
diff
changeset
|
5675 else if (type == GAIM_CONV_UPDATE_ICON) |
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6771
diff
changeset
|
5676 { |
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6771
diff
changeset
|
5677 gaim_gtkconv_update_buddy_icon(conv); |
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6771
diff
changeset
|
5678 } |
4359 | 5679 } |
5680 | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5681 static GaimConversationUiOps conversation_ui_ops = |
4359 | 5682 { |
5683 gaim_gtkconv_destroy, /* destroy_conversation */ | |
5684 gaim_gtkconv_write_chat, /* write_chat */ | |
5685 gaim_gtkconv_write_im, /* write_im */ | |
5686 gaim_gtkconv_write_conv, /* write_conv */ | |
5687 gaim_gtkconv_chat_add_user, /* chat_add_user */ | |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5688 gaim_gtkconv_chat_add_users, /* chat_add_users */ |
4359 | 5689 gaim_gtkconv_chat_rename_user, /* chat_rename_user */ |
5690 gaim_gtkconv_chat_remove_user, /* chat_remove_user */ | |
6407
ba0b99a72be2
[gaim-migrate @ 6913]
Christian Hammond <chipx86@chipx86.com>
parents:
6405
diff
changeset
|
5691 gaim_gtkconv_chat_remove_users, /* chat_remove_users */ |
9554 | 5692 gaim_gtkconv_chat_update_user, /* chat_update_user */ |
4359 | 5693 NULL, /* update_progress */ |
9260
947876140943
[gaim-migrate @ 10059]
Christian Hammond <chipx86@chipx86.com>
parents:
9247
diff
changeset
|
5694 gaim_gtkconv_has_focus, /* has_focus */ |
4359 | 5695 gaim_gtkconv_updated /* updated */ |
5696 }; | |
5697 | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5698 GaimConversationUiOps * |
7035
feb3d21a7794
[gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents:
7008
diff
changeset
|
5699 gaim_gtk_conversations_get_conv_ui_ops(void) |
4359 | 5700 { |
4465
6e37eb000b7a
[gaim-migrate @ 4740]
Christian Hammond <chipx86@chipx86.com>
parents:
4454
diff
changeset
|
5701 return &conversation_ui_ops; |
4359 | 5702 } |
5703 | |
5704 /************************************************************************** | |
5705 * Public conversation utility functions | |
5706 **************************************************************************/ | |
5707 void | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5708 gaim_gtkconv_update_buddy_icon(GaimConversation *conv) |
4359 | 5709 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5710 GaimGtkConversation *gtkconv; |
7143 | 5711 GaimGtkWindow *gtkwin = GAIM_GTK_WINDOW(gaim_conversation_get_window(conv)); |
4359 | 5712 |
5713 char filename[256]; | |
5714 FILE *file; | |
5715 GError *err = NULL; | |
5716 | |
6846
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6771
diff
changeset
|
5717 const void *data; |
8ab95f4c9800
[gaim-migrate @ 7391]
Christian Hammond <chipx86@chipx86.com>
parents:
6771
diff
changeset
|
5718 size_t len; |
4359 | 5719 |
5720 GdkPixbuf *buf; | |
5721 | |
5722 GtkWidget *event; | |
5723 GtkWidget *frame; | |
5724 GdkPixbuf *scale; | |
5725 GdkPixmap *pm; | |
5726 GdkBitmap *bm; | |
9318 | 5727 int scale_width, scale_height; |
9332 | 5728 GtkRequisition requisition; |
9318 | 5729 |
5730 GaimAccount *account; | |
5731 GaimPluginProtocolInfo *prpl_info = NULL; | |
4359 | 5732 |
8821 | 5733 GaimButtonStyle button_type; |
5734 | |
9324 | 5735 GaimBuddyIcon *icon; |
5736 | |
5678
619bca773b2e
[gaim-migrate @ 6096]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
5737 g_return_if_fail(conv != NULL); |
619bca773b2e
[gaim-migrate @ 6096]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
5738 g_return_if_fail(GAIM_IS_GTK_CONVERSATION(conv)); |
619bca773b2e
[gaim-migrate @ 6096]
Christian Hammond <chipx86@chipx86.com>
parents:
5676
diff
changeset
|
5739 g_return_if_fail(gaim_conversation_get_type(conv) == GAIM_CONV_IM); |
4359 | 5740 |
5741 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
9687 | 5742 |
5743 if (!gtkconv->u.im->show_icon) | |
5744 return; | |
5745 | |
9318 | 5746 account = gaim_conversation_get_account(conv); |
5747 if(account && account->gc) | |
5748 prpl_info = GAIM_PLUGIN_PROTOCOL_INFO(account->gc->prpl); | |
4359 | 5749 |
9845 | 5750 /* Remove the current icon stuff */ |
9885 | 5751 if (gtkconv->u.im->icon_container != NULL) |
5752 gtk_widget_destroy(gtkconv->u.im->icon_container); | |
5753 gtkconv->u.im->icon_container = NULL; | |
9845 | 5754 |
5755 if (gtkconv->u.im->anim != NULL) | |
5756 g_object_unref(G_OBJECT(gtkconv->u.im->anim)); | |
5757 | |
9887 | 5758 gtkconv->u.im->anim = NULL; |
5759 | |
9845 | 5760 if (gtkconv->u.im->icon_timer != 0) |
5761 g_source_remove(gtkconv->u.im->icon_timer); | |
5762 | |
5763 gtkconv->u.im->icon_timer = 0; | |
5764 | |
5765 if (gtkconv->u.im->iter != NULL) | |
5766 g_object_unref(G_OBJECT(gtkconv->u.im->iter)); | |
4359 | 5767 |
5545
7a64114641c3
[gaim-migrate @ 5946]
Christian Hammond <chipx86@chipx86.com>
parents:
5484
diff
changeset
|
5768 if (!gaim_prefs_get_bool("/gaim/gtk/conversations/im/show_buddy_icons")) |
4359 | 5769 return; |
5770 | |
5771 if (gaim_conversation_get_gc(conv) == NULL) | |
5772 return; | |
5773 | |
9324 | 5774 icon = gaim_conv_im_get_icon(GAIM_CONV_IM(conv)); |
5775 | |
5776 if (icon == NULL) | |
5777 return; | |
5778 | |
5779 data = gaim_buddy_icon_get_data(icon, &len); | |
5780 | |
5781 /* this is such an evil hack, i don't know why i'm even considering it. | |
5782 * we'll do it differently when gdk-pixbuf-loader isn't leaky anymore. */ | |
5783 /* gdk-pixbuf-loader was leaky? is it still? */ | |
5784 g_snprintf(filename, sizeof(filename), | |
5785 "%s" G_DIR_SEPARATOR_S "gaimicon-%s.%d", | |
5786 g_get_tmp_dir(), gaim_conversation_get_name(conv), getpid()); | |
5787 | |
5788 if (!(file = fopen(filename, "wb"))) | |
5789 return; | |
5790 | |
5791 fwrite(data, 1, len, file); | |
5792 fclose(file); | |
5793 | |
5794 gtkconv->u.im->anim = gdk_pixbuf_animation_new_from_file(filename, &err); | |
5795 /* make sure we remove the file as soon as possible */ | |
5796 unlink(filename); | |
5797 | |
4359 | 5798 if (err) { |
5211
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
5799 gaim_debug(GAIM_DEBUG_ERROR, "gtkconv", |
0241d6b6702d
[gaim-migrate @ 5581]
Christian Hammond <chipx86@chipx86.com>
parents:
5205
diff
changeset
|
5800 "Buddy icon error: %s\n", err->message); |
4359 | 5801 g_error_free(err); |
5802 } | |
5803 | |
5804 if (!gtkconv->u.im->anim) | |
5805 return; | |
5806 | |
5807 if (gdk_pixbuf_animation_is_static_image(gtkconv->u.im->anim)) { | |
5808 gtkconv->u.im->iter = NULL; | |
5809 buf = gdk_pixbuf_animation_get_static_image(gtkconv->u.im->anim); | |
5810 } else { | |
5811 gtkconv->u.im->iter = | |
8496 | 5812 gdk_pixbuf_animation_get_iter(gtkconv->u.im->anim, NULL); /* LEAK */ |
4359 | 5813 buf = gdk_pixbuf_animation_iter_get_pixbuf(gtkconv->u.im->iter); |
8189 | 5814 if (gtkconv->u.im->animate) |
5815 start_anim(NULL, conv); | |
4359 | 5816 } |
5817 | |
9318 | 5818 get_icon_scale_size(gtkconv->u.im->anim, prpl_info ? &prpl_info->icon_spec : |
5819 NULL, &scale_width, &scale_height); | |
4359 | 5820 scale = gdk_pixbuf_scale_simple(buf, |
9318 | 5821 MAX(gdk_pixbuf_get_width(buf) * scale_width / |
4359 | 5822 gdk_pixbuf_animation_get_width(gtkconv->u.im->anim), 1), |
9318 | 5823 MAX(gdk_pixbuf_get_height(buf) * scale_height / |
4359 | 5824 gdk_pixbuf_animation_get_height(gtkconv->u.im->anim), 1), |
5825 GDK_INTERP_NEAREST); | |
5826 | |
5827 gdk_pixbuf_render_pixmap_and_mask(scale, &pm, &bm, 100); | |
4793 | 5828 g_object_unref(G_OBJECT(scale)); |
4359 | 5829 |
8821 | 5830 |
9885 | 5831 gtkconv->u.im->icon_container = gtk_vbox_new(FALSE, 0); |
8821 | 5832 |
4359 | 5833 frame = gtk_frame_new(NULL); |
5834 gtk_frame_set_shadow_type(GTK_FRAME(frame), | |
5835 (bm ? GTK_SHADOW_NONE : GTK_SHADOW_IN)); | |
9885 | 5836 gtk_box_pack_start(GTK_BOX(gtkconv->u.im->icon_container), frame, |
5837 FALSE, FALSE, 0); | |
8821 | 5838 |
4359 | 5839 event = gtk_event_box_new(); |
5840 gtk_container_add(GTK_CONTAINER(frame), event); | |
5314
1f901484599d
[gaim-migrate @ 5686]
Christian Hammond <chipx86@chipx86.com>
parents:
5228
diff
changeset
|
5841 g_signal_connect(G_OBJECT(event), "button-press-event", |
4359 | 5842 G_CALLBACK(icon_menu), conv); |
5843 gtk_widget_show(event); | |
5844 | |
4635 | 5845 gtkconv->u.im->icon = gtk_image_new_from_pixmap(pm, bm); |
9318 | 5846 gtk_widget_set_size_request(gtkconv->u.im->icon, scale_width, scale_height); |
4359 | 5847 gtk_container_add(GTK_CONTAINER(event), gtkconv->u.im->icon); |
5848 gtk_widget_show(gtkconv->u.im->icon); | |
5849 | |
4793 | 5850 g_object_unref(G_OBJECT(pm)); |
4359 | 5851 |
5852 if (bm) | |
4793 | 5853 g_object_unref(G_OBJECT(bm)); |
7143 | 5854 |
9332 | 5855 button_type = gaim_prefs_get_int("/gaim/gtk/conversations/button_type"); |
9876 | 5856 /* the button seems to get its size before the box, so... */ |
5857 gtk_widget_size_request(gtkconv->send, &requisition); | |
9683 | 5858 if (button_type == GAIM_BUTTON_NONE || requisition.height * 1.5 < scale_height) { |
9885 | 5859 gtk_box_pack_start(GTK_BOX(gtkconv->lower_hbox), |
5860 gtkconv->u.im->icon_container, FALSE, FALSE, 0); | |
9332 | 5861 /* gtk_box_reorder_child(GTK_BOX(gtkconv->lower_hbox), vbox, 0); */ |
5862 } else { | |
9885 | 5863 gtk_box_pack_start(GTK_BOX(gtkconv->bbox), |
5864 gtkconv->u.im->icon_container, FALSE, FALSE, 0); | |
5865 gtk_box_reorder_child(GTK_BOX(gtkconv->bbox), | |
5866 gtkconv->u.im->icon_container, 0); | |
9332 | 5867 } |
5868 | |
9885 | 5869 gtk_widget_show(gtkconv->u.im->icon_container); |
9332 | 5870 gtk_widget_show(frame); |
5871 | |
7143 | 5872 /* The buddy icon code needs badly to be fixed. */ |
5873 buf = gdk_pixbuf_animation_get_static_image(gtkconv->u.im->anim); | |
8068 | 5874 if(conv == gaim_conv_window_get_active_conversation(gaim_conversation_get_window(conv))) |
5875 gtk_window_set_icon(GTK_WINDOW(gtkwin->window), buf); | |
4359 | 5876 } |
5877 | |
5878 void | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5879 gaim_gtkconv_update_buttons_by_protocol(GaimConversation *conv) |
4359 | 5880 { |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
5881 GaimConvWindow *win; |
4359 | 5882 |
4398
a8249a5250b6
[gaim-migrate @ 4667]
Christian Hammond <chipx86@chipx86.com>
parents:
4397
diff
changeset
|
5883 if (!GAIM_IS_GTK_CONVERSATION(conv)) |
4359 | 5884 return; |
5885 | |
7887 | 5886 win = gaim_conversation_get_window(conv); |
5887 | |
5888 if (win != NULL && gaim_conv_window_get_active_conversation(win) == conv) | |
5889 gray_stuff_out(conv); | |
4359 | 5890 } |
5891 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
5892 GaimConvWindow * |
4359 | 5893 gaim_gtkwin_get_at_xy(int x, int y) |
5894 { | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
5895 GaimConvWindow *win = NULL; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5896 GaimGtkWindow *gtkwin; |
4359 | 5897 GdkWindow *gdkwin; |
5898 GList *l; | |
5899 | |
5900 gdkwin = gdk_window_at_pointer(&x, &y); | |
5901 | |
5902 if (gdkwin) | |
5903 gdkwin = gdk_window_get_toplevel(gdkwin); | |
5904 | |
5905 for (l = gaim_get_windows(); l != NULL; l = l->next) { | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
5906 win = (GaimConvWindow *)l->data; |
4359 | 5907 |
4398
a8249a5250b6
[gaim-migrate @ 4667]
Christian Hammond <chipx86@chipx86.com>
parents:
4397
diff
changeset
|
5908 if (!GAIM_IS_GTK_WINDOW(win)) |
4359 | 5909 continue; |
5910 | |
5911 gtkwin = GAIM_GTK_WINDOW(win); | |
5912 | |
5913 if (gdkwin == gtkwin->window->window) | |
5914 return win; | |
5915 } | |
5916 | |
5917 return NULL; | |
5918 } | |
5919 | |
5920 int | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
5921 gaim_gtkconv_get_tab_at_xy(GaimConvWindow *win, int x, int y) |
4359 | 5922 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5923 GaimGtkWindow *gtkwin; |
4359 | 5924 GList *l; |
5925 gint nb_x, nb_y, x_rel, y_rel; | |
5926 GtkNotebook *notebook; | |
5927 GtkWidget *tab; | |
5928 gint i, page_num = 0; | |
5929 gboolean first_visible = TRUE; | |
5930 | |
4398
a8249a5250b6
[gaim-migrate @ 4667]
Christian Hammond <chipx86@chipx86.com>
parents:
4397
diff
changeset
|
5931 if (!GAIM_IS_GTK_WINDOW(win)) |
4359 | 5932 return -1; |
5933 | |
5934 gtkwin = GAIM_GTK_WINDOW(win); | |
5935 notebook = GTK_NOTEBOOK(gtkwin->notebook); | |
5936 | |
5937 gdk_window_get_origin(gtkwin->notebook->window, &nb_x, &nb_y); | |
5938 x_rel = x - nb_x; | |
5939 y_rel = y - nb_y; | |
5940 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
5941 for (l = gaim_conv_window_get_conversations(win), i = 0; |
4359 | 5942 l != NULL; |
5943 l = l->next, i++) { | |
5944 | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5945 GaimConversation *conv = l->data; |
4359 | 5946 tab = GAIM_GTK_CONVERSATION(conv)->tab_label; |
5947 | |
5948 if (!GTK_WIDGET_MAPPED(tab)) | |
5949 continue; | |
5950 | |
5951 if (first_visible) { | |
5952 first_visible = FALSE; | |
5953 | |
5954 if (x_rel < tab->allocation.x) x_rel = tab->allocation.x; | |
5955 if (y_rel < tab->allocation.y) y_rel = tab->allocation.y; | |
5956 } | |
5957 | |
5958 if (gtk_notebook_get_tab_pos(notebook) == GTK_POS_TOP || | |
5959 gtk_notebook_get_tab_pos(notebook) == GTK_POS_BOTTOM) { | |
5960 | |
5961 if (tab->allocation.x <= x_rel) { | |
5962 if (tab->allocation.x + tab->allocation.width <= x_rel) | |
5963 page_num = i + 1; | |
5964 else | |
5965 page_num = i; | |
5966 } | |
5967 else | |
5968 break; | |
5969 } | |
5970 else { | |
5971 if (tab->allocation.y <= y_rel) { | |
5972 if (tab->allocation.y + tab->allocation.height <= y_rel) | |
5973 page_num = i + 1; | |
5974 else | |
5975 page_num = i; | |
5976 } | |
5977 else | |
5978 break; | |
5979 } | |
5980 } | |
5981 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
5982 if (i == gaim_conv_window_get_conversation_count(win) + 1) |
4359 | 5983 return -1; |
5984 | |
5985 return page_num; | |
5986 } | |
5987 | |
5988 int | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
5989 gaim_gtkconv_get_dest_tab_at_xy(GaimConvWindow *win, int x, int y) |
4359 | 5990 { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
5991 GaimGtkWindow *gtkwin; |
4359 | 5992 GList *l; |
5993 gint nb_x, nb_y, x_rel, y_rel; | |
5994 GtkNotebook *notebook; | |
5995 GtkWidget *tab; | |
5996 gint i, page_num = 0; | |
5997 | |
4398
a8249a5250b6
[gaim-migrate @ 4667]
Christian Hammond <chipx86@chipx86.com>
parents:
4397
diff
changeset
|
5998 if (!GAIM_IS_GTK_WINDOW(win)) |
4359 | 5999 return -1; |
6000 | |
6001 gtkwin = GAIM_GTK_WINDOW(win); | |
6002 notebook = GTK_NOTEBOOK(gtkwin->notebook); | |
6003 | |
6004 gdk_window_get_origin(gtkwin->notebook->window, &nb_x, &nb_y); | |
6005 x_rel = x - nb_x; | |
6006 y_rel = y - nb_y; | |
6007 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
6008 for (l = gaim_conv_window_get_conversations(win), i = 0; |
4359 | 6009 l != NULL; |
6010 l = l->next, i++) { | |
6011 | |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
6012 GaimConversation *conv = l->data; |
4359 | 6013 tab = GAIM_GTK_CONVERSATION(conv)->tab_label; |
6014 | |
6015 if (!GTK_WIDGET_MAPPED(tab)) | |
6016 continue; | |
6017 | |
6018 if (gtk_notebook_get_tab_pos(notebook) == GTK_POS_TOP || | |
6019 gtk_notebook_get_tab_pos(notebook) == GTK_POS_BOTTOM) { | |
6020 | |
6021 if (tab->allocation.x <= x_rel) { | |
6022 if (tab->allocation.x + (tab->allocation.width / 2) <= x_rel) | |
6023 page_num = i + 1; | |
6024 else | |
6025 page_num = i; | |
6026 } | |
6027 else | |
6028 break; | |
6029 } | |
6030 else { | |
6031 if (tab->allocation.y <= y_rel) { | |
6032 if (tab->allocation.y + (tab->allocation.height / 2) <= y_rel) | |
6033 page_num = i + 1; | |
6034 else | |
6035 page_num = i; | |
6036 } | |
6037 else | |
6038 break; | |
6039 } | |
6040 } | |
6041 | |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
6042 if (i == gaim_conv_window_get_conversation_count(win) + 1) |
4359 | 6043 return -1; |
6044 | |
6045 return page_num; | |
6046 } | |
4940
3708545afe42
[gaim-migrate @ 5274]
Christian Hammond <chipx86@chipx86.com>
parents:
4939
diff
changeset
|
6047 |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6048 static void |
6398
c9894c0fbc6f
[gaim-migrate @ 6903]
Christian Hammond <chipx86@chipx86.com>
parents:
6395
diff
changeset
|
6049 escape_closes_pref_cb(const char *name, GaimPrefType type, gpointer value, |
c9894c0fbc6f
[gaim-migrate @ 6903]
Christian Hammond <chipx86@chipx86.com>
parents:
6395
diff
changeset
|
6050 gpointer data) |
c9894c0fbc6f
[gaim-migrate @ 6903]
Christian Hammond <chipx86@chipx86.com>
parents:
6395
diff
changeset
|
6051 { |
c9894c0fbc6f
[gaim-migrate @ 6903]
Christian Hammond <chipx86@chipx86.com>
parents:
6395
diff
changeset
|
6052 if (value) |
c9894c0fbc6f
[gaim-migrate @ 6903]
Christian Hammond <chipx86@chipx86.com>
parents:
6395
diff
changeset
|
6053 gtk_accel_map_change_entry(N_("<main>/Conversation/Close"), |
c9894c0fbc6f
[gaim-migrate @ 6903]
Christian Hammond <chipx86@chipx86.com>
parents:
6395
diff
changeset
|
6054 GDK_Escape, 0, TRUE); |
c9894c0fbc6f
[gaim-migrate @ 6903]
Christian Hammond <chipx86@chipx86.com>
parents:
6395
diff
changeset
|
6055 else |
c9894c0fbc6f
[gaim-migrate @ 6903]
Christian Hammond <chipx86@chipx86.com>
parents:
6395
diff
changeset
|
6056 gtk_accel_map_change_entry(N_("<main>/Conversation/Close"), |
c9894c0fbc6f
[gaim-migrate @ 6903]
Christian Hammond <chipx86@chipx86.com>
parents:
6395
diff
changeset
|
6057 GDK_W, GDK_CONTROL_MASK, TRUE); |
c9894c0fbc6f
[gaim-migrate @ 6903]
Christian Hammond <chipx86@chipx86.com>
parents:
6395
diff
changeset
|
6058 } |
c9894c0fbc6f
[gaim-migrate @ 6903]
Christian Hammond <chipx86@chipx86.com>
parents:
6395
diff
changeset
|
6059 |
c9894c0fbc6f
[gaim-migrate @ 6903]
Christian Hammond <chipx86@chipx86.com>
parents:
6395
diff
changeset
|
6060 static void |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6061 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
|
6062 gpointer data) |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6063 { |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6064 GList *l; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
6065 GaimConversation *conv; |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
6066 GaimGtkConversation *gtkconv; |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6067 |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6068 for (l = gaim_get_conversations(); l != NULL; l = l->next) { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
6069 conv = (GaimConversation *)l->data; |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6070 |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6071 if (!GAIM_IS_GTK_CONVERSATION(conv)) |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6072 continue; |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6073 |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6074 gtkconv = GAIM_GTK_CONVERSATION(conv); |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6075 |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6076 if (value) |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6077 gtk_widget_show(gtkconv->close); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6078 else |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6079 gtk_widget_hide(gtkconv->close); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6080 } |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6081 } |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6082 |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6083 static void |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6084 show_timestamps_pref_cb(const char *name, GaimPrefType type, gpointer value, |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6085 gpointer data) |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6086 { |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6087 GList *l; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
6088 GaimConversation *conv; |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
6089 GaimGtkConversation *gtkconv; |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6090 |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6091 for (l = gaim_get_conversations(); l != NULL; l = l->next) { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
6092 conv = (GaimConversation *)l->data; |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6093 |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6094 if (!GAIM_IS_GTK_CONVERSATION(conv)) |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6095 continue; |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6096 |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6097 gtkconv = GAIM_GTK_CONVERSATION(conv); |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6098 |
7386 | 6099 gtk_imhtml_show_comments(GTK_IMHTML(gtkconv->imhtml), (gboolean)GPOINTER_TO_INT(value)); |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6100 } |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6101 } |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6102 |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6103 static void |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6104 spellcheck_pref_cb(const char *name, GaimPrefType type, gpointer value, |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6105 gpointer data) |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6106 { |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6107 #ifdef USE_GTKSPELL |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6108 GList *cl; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
6109 GaimConversation *conv; |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
6110 GaimGtkConversation *gtkconv; |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6111 GtkSpell *spell; |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6112 |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6113 for (cl = gaim_get_conversations(); cl != NULL; cl = cl->next) { |
6725
e62a504c83d0
[gaim-migrate @ 7252]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
6114 |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
6115 conv = (GaimConversation *)cl->data; |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6116 |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6117 if (!GAIM_IS_GTK_CONVERSATION(conv)) |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6118 continue; |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6119 |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6120 gtkconv = GAIM_GTK_CONVERSATION(conv); |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6121 |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6122 if (value) |
7538
357eb1c39b72
[gaim-migrate @ 8151]
Christian Hammond <chipx86@chipx86.com>
parents:
7476
diff
changeset
|
6123 gaim_gtk_setup_gtkspell(GTK_TEXT_VIEW(gtkconv->entry)); |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6124 else { |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6125 spell = gtkspell_get_from_text_view(GTK_TEXT_VIEW(gtkconv->entry)); |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6126 gtkspell_detach(spell); |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6127 } |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6128 } |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6129 #endif |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6130 } |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6131 |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6132 static void |
5675
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
6133 tab_side_pref_cb(const char *name, GaimPrefType type, gpointer value, |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
6134 gpointer data) |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6135 { |
5675
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
6136 GList *l; |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
6137 GtkPositionType pos; |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
6138 GaimConvWindow *win; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
6139 GaimGtkWindow *gtkwin; |
5675
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
6140 |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
6141 pos = GPOINTER_TO_INT(value); |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
6142 |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
6143 for (l = gaim_get_windows(); l != NULL; l = l->next) { |
7118
bf630f7dfdcd
[gaim-migrate @ 7685]
Christian Hammond <chipx86@chipx86.com>
parents:
7108
diff
changeset
|
6144 win = (GaimConvWindow *)l->data; |
5675
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
6145 |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
6146 if (!GAIM_IS_GTK_WINDOW(win)) |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
6147 continue; |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
6148 |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
6149 gtkwin = GAIM_GTK_WINDOW(win); |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
6150 |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
6151 gtk_notebook_set_tab_pos(GTK_NOTEBOOK(gtkwin->notebook), pos); |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
6152 } |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
6153 } |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
6154 |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
6155 static void |
8456 | 6156 html_shortcuts_pref_cb(const char *name, GaimPrefType type, |
6157 gpointer value, gpointer data) | |
6158 { | |
6159 GList *l; | |
6160 GaimConversation *conv; | |
6161 GaimGtkConversation *gtkconv; | |
9487 | 6162 |
8456 | 6163 for(l = gaim_get_conversations(); l != NULL; l = l->next) { |
6164 conv = (GaimConversation *)l->data; | |
9487 | 6165 |
8456 | 6166 if(!GAIM_IS_GTK_CONVERSATION(conv)) |
6167 continue; | |
9487 | 6168 |
8456 | 6169 gtkconv = GAIM_GTK_CONVERSATION(conv); |
9487 | 6170 |
8456 | 6171 gtk_imhtml_html_shortcuts(GTK_IMHTML(gtkconv->entry), |
6172 (gboolean)GPOINTER_TO_INT(value)); | |
6173 } | |
6174 } | |
6175 | |
6176 static void | |
6177 smiley_shortcuts_pref_cb(const char *name, GaimPrefType type, | |
6178 gpointer value, gpointer data) | |
6179 { | |
6180 GList *l; | |
6181 GaimConversation *conv; | |
6182 GaimGtkConversation *gtkconv; | |
9487 | 6183 |
8456 | 6184 for(l = gaim_get_conversations(); l != NULL; l = l->next) { |
6185 conv = (GaimConversation *)l->data; | |
9487 | 6186 |
8456 | 6187 if(!GAIM_IS_GTK_CONVERSATION(conv)) |
6188 continue; | |
9487 | 6189 |
8456 | 6190 gtkconv = GAIM_GTK_CONVERSATION(conv); |
9487 | 6191 |
6192 gtk_imhtml_smiley_shortcuts(GTK_IMHTML(gtkconv->entry), | |
8456 | 6193 (gboolean)GPOINTER_TO_INT(value)); |
6194 } | |
6195 } | |
6196 | |
6197 static void | |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6198 show_formatting_toolbar_pref_cb(const char *name, GaimPrefType type, |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6199 gpointer value, gpointer data) |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6200 { |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6201 GList *l; |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6202 GaimConversation *conv; |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6203 GaimGtkConversation *gtkconv; |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6204 GaimConvWindow *win; |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6205 GaimGtkWindow *gtkwin; |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6206 |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6207 for (l = gaim_get_conversations(); l != NULL; l = l->next) |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6208 { |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6209 conv = (GaimConversation *)l->data; |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6210 |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6211 if (!GAIM_IS_GTK_CONVERSATION(conv)) |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6212 continue; |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6213 |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6214 gtkconv = GAIM_GTK_CONVERSATION(conv); |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6215 win = gaim_conversation_get_window(conv); |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6216 gtkwin = GAIM_GTK_WINDOW(win); |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6217 |
7386 | 6218 gtkconv->show_formatting_toolbar = (gboolean)GPOINTER_TO_INT(value); |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6219 gtk_check_menu_item_set_active( |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6220 GTK_CHECK_MENU_ITEM(gtkwin->menu.show_formatting_toolbar), |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6221 gtkconv->show_formatting_toolbar); |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6222 |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6223 if (gtkconv->show_formatting_toolbar) |
8317 | 6224 gtk_widget_show(gtkconv->toolbar); |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6225 else |
8317 | 6226 gtk_widget_hide(gtkconv->toolbar); |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6227 } |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6228 } |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6229 |
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6230 static void |
9150 | 6231 button_type_pref_cb(const char *name, GaimPrefType type, |
5675
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
6232 gpointer value, gpointer data) |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
6233 { |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
6234 GList *l; |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
6235 GaimConversation *conv; |
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
6236 GaimGtkConversation *gtkconv; |
5675
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
6237 |
9150 | 6238 for (l = gaim_get_conversations(); l != NULL; l = l->next) { |
5676
dae79aefac8d
[gaim-migrate @ 6094]
Christian Hammond <chipx86@chipx86.com>
parents:
5675
diff
changeset
|
6239 conv = (GaimConversation *)l->data; |
5675
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
6240 gtkconv = GAIM_GTK_CONVERSATION(conv); |
9150 | 6241 switch (conv->type) { |
6242 case GAIM_CONV_IM: | |
9749 | 6243 setup_im_buttons(conv, gtkconv->bbox); |
9150 | 6244 gaim_gtkconv_update_buddy_icon(conv); |
6245 break; | |
6246 case GAIM_CONV_CHAT: | |
9749 | 6247 setup_chat_buttons(conv, gtkconv->bbox); |
9150 | 6248 break; |
6249 default: | |
6250 break; | |
6251 } | |
5675
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
6252 } |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6253 } |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6254 |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6255 static void |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6256 animate_buddy_icons_pref_cb(const char *name, GaimPrefType type, |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6257 gpointer value, gpointer data) |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6258 { |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6259 GList *l; |
8189 | 6260 GaimConversation *conv; |
6261 GaimGtkConversation *gtkconv; | |
6262 GaimConvWindow *win; | |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6263 |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6264 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
|
6265 return; |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6266 |
8189 | 6267 /* Set the "animate" flag for each icon based on the new preference */ |
6268 for (l = gaim_get_ims(); l != NULL; l = l->next) { | |
6269 conv = (GaimConversation *)l->data; | |
6270 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
6271 gtkconv->u.im->animate = (gboolean)value; | |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6272 } |
8189 | 6273 |
6274 /* Now either stop or start animation for the active conversation in each window */ | |
6275 for (l = gaim_get_windows(); l != NULL; l = l->next) { | |
6276 win = (GaimConvWindow *)l->data; | |
6277 conv = gaim_conv_window_get_active_conversation(win); | |
6278 gaim_gtkconv_update_buddy_icon(conv); | |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6279 } |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6280 } |
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6281 |
5675
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
6282 static void |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
6283 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
|
6284 gpointer data) |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
6285 { |
5881
cc7870e1e3b3
[gaim-migrate @ 6313]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
6286 GList *l; |
cc7870e1e3b3
[gaim-migrate @ 6313]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
6287 |
cc7870e1e3b3
[gaim-migrate @ 6313]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
6288 for (l = gaim_get_conversations(); l != NULL; l = l->next) { |
cc7870e1e3b3
[gaim-migrate @ 6313]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
6289 GaimConversation *conv = l->data; |
cc7870e1e3b3
[gaim-migrate @ 6313]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
6290 |
cc7870e1e3b3
[gaim-migrate @ 6313]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
6291 if (gaim_conversation_get_type(conv) == GAIM_CONV_IM) |
cc7870e1e3b3
[gaim-migrate @ 6313]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
6292 gaim_conversation_foreach(gaim_gtkconv_update_buddy_icon); |
cc7870e1e3b3
[gaim-migrate @ 6313]
Christian Hammond <chipx86@chipx86.com>
parents:
5872
diff
changeset
|
6293 } |
5675
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
6294 } |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
6295 |
5681
46d7ad0dfa26
[gaim-migrate @ 6100]
Christian Hammond <chipx86@chipx86.com>
parents:
5680
diff
changeset
|
6296 static void |
7561
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
6297 conv_placement_pref_cb(const char *name, GaimPrefType type, |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
6298 gpointer value, gpointer data) |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
6299 { |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
6300 GaimConvPlacementFunc func; |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
6301 |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
6302 if (strcmp(name, "/gaim/gtk/conversations/placement")) |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
6303 return; |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
6304 |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
6305 func = gaim_conv_placement_get_fnc(value); |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
6306 |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
6307 if (func == NULL) |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
6308 return; |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
6309 |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
6310 gaim_conv_placement_set_current_func(func); |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
6311 } |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
6312 |
8582
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6313 void * |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6314 gaim_gtk_conversations_get_handle(void) |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6315 { |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6316 static int handle; |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6317 |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6318 return &handle; |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6319 } |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6320 |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6321 void |
7035
feb3d21a7794
[gaim-migrate @ 7598]
Christian Hammond <chipx86@chipx86.com>
parents:
7008
diff
changeset
|
6322 gaim_gtk_conversations_init(void) |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6323 { |
8582
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6324 void *handle = gaim_gtk_conversations_get_handle(); |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6325 |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6326 /* Conversations */ |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6327 gaim_prefs_add_none("/gaim/gtk/conversations"); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6328 gaim_prefs_add_bool("/gaim/gtk/conversations/close_on_tabs", TRUE); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6329 gaim_prefs_add_bool("/gaim/gtk/conversations/escape_closes", FALSE); |
9025 | 6330 gaim_prefs_add_bool("/gaim/gtk/conversations/send_formatting", FALSE); |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6331 gaim_prefs_add_bool("/gaim/gtk/conversations/send_bold", FALSE); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6332 gaim_prefs_add_bool("/gaim/gtk/conversations/send_italic", FALSE); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6333 gaim_prefs_add_bool("/gaim/gtk/conversations/send_underline", FALSE); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6334 gaim_prefs_add_bool("/gaim/gtk/conversations/show_timestamps", TRUE); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6335 gaim_prefs_add_bool("/gaim/gtk/conversations/spellcheck", TRUE); |
9049 | 6336 #if 1 |
6337 gaim_prefs_add_bool("/gaim/gtk/conversations/ignore_colors", FALSE); | |
6338 gaim_prefs_add_bool("/gaim/gtk/conversations/ignore_fonts", FALSE); | |
6339 gaim_prefs_add_bool("/gaim/gtk/conversations/ignore_font_sizes", FALSE); | |
6340 #else | |
8944 | 6341 gaim_prefs_add_bool("/gaim/gtk/conversations/ignore_formatting", FALSE); |
9049 | 6342 #endif |
7326
00a9ab26d607
[gaim-migrate @ 7912]
Christian Hammond <chipx86@chipx86.com>
parents:
7322
diff
changeset
|
6343 gaim_prefs_add_bool("/gaim/gtk/conversations/show_formatting_toolbar", TRUE); |
9832 | 6344 gaim_prefs_add_bool("/gaim/gtk/conversations/passthrough_unknown_commands", FALSE); |
9130 | 6345 |
7561
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
6346 gaim_prefs_add_string("/gaim/gtk/conversations/placement", "last"); |
8998 | 6347 gaim_prefs_add_int("/gaim/gtk/conversations/placement_number", 1); |
9025 | 6348 gaim_prefs_add_string("/gaim/gtk/conversations/bgcolor", ""); |
6349 gaim_prefs_add_string("/gaim/gtk/conversations/fgcolor", ""); | |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6350 gaim_prefs_add_string("/gaim/gtk/conversations/font_face", ""); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6351 gaim_prefs_add_int("/gaim/gtk/conversations/font_size", 3); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6352 gaim_prefs_add_bool("/gaim/gtk/conversations/tabs", TRUE); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6353 gaim_prefs_add_int("/gaim/gtk/conversations/tab_side", GTK_POS_TOP); |
9150 | 6354 gaim_prefs_add_int("/gaim/gtk/conversations/button_type", |
6355 GAIM_BUTTON_TEXT_IMAGE); | |
6356 | |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6357 |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6358 /* Conversations -> Chat */ |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6359 gaim_prefs_add_none("/gaim/gtk/conversations/chat"); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6360 gaim_prefs_add_int("/gaim/gtk/conversations/chat/default_width", 410); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6361 gaim_prefs_add_int("/gaim/gtk/conversations/chat/default_height", 160); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6362 gaim_prefs_add_int("/gaim/gtk/conversations/chat/entry_height", 50); |
9319 | 6363 gaim_prefs_add_bool("/gaim/gtk/conversations/chat/raise_on_events", FALSE); |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6364 |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6365 /* Conversations -> IM */ |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6366 gaim_prefs_add_none("/gaim/gtk/conversations/im"); |
9150 | 6367 |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6368 gaim_prefs_add_bool("/gaim/gtk/conversations/im/animate_buddy_icons", TRUE); |
9150 | 6369 |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6370 gaim_prefs_add_int("/gaim/gtk/conversations/im/default_width", 410); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6371 gaim_prefs_add_int("/gaim/gtk/conversations/im/default_height", 160); |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6372 gaim_prefs_add_int("/gaim/gtk/conversations/im/entry_height", 50); |
9319 | 6373 gaim_prefs_add_bool("/gaim/gtk/conversations/im/raise_on_events", FALSE); |
6374 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
|
6375 |
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6376 /* Connect callbacks. */ |
10087 | 6377 gaim_prefs_connect_callback(handle, "/gaim/gtk/conversations/escape_closes", |
6398
c9894c0fbc6f
[gaim-migrate @ 6903]
Christian Hammond <chipx86@chipx86.com>
parents:
6395
diff
changeset
|
6378 escape_closes_pref_cb, NULL); |
10087 | 6379 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
|
6380 close_on_tabs_pref_cb, NULL); |
10087 | 6381 gaim_prefs_connect_callback(handle, "/gaim/gtk/conversations/show_timestamps", |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6382 show_timestamps_pref_cb, NULL); |
10087 | 6383 gaim_prefs_connect_callback(handle, "/gaim/gtk/conversations/html_shortcuts", |
8456 | 6384 html_shortcuts_pref_cb, NULL); |
10087 | 6385 gaim_prefs_connect_callback(handle, "/gaim/gtk/conversations/smiley_shortcuts", |
8456 | 6386 smiley_shortcuts_pref_cb, NULL); |
10087 | 6387 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
|
6388 show_formatting_toolbar_pref_cb, NULL); |
10087 | 6389 gaim_prefs_connect_callback(handle, "/gaim/gtk/conversations/spellcheck", |
5674
2d86a5fa6fef
[gaim-migrate @ 6092]
Christian Hammond <chipx86@chipx86.com>
parents:
5673
diff
changeset
|
6390 spellcheck_pref_cb, NULL); |
10087 | 6391 gaim_prefs_connect_callback(handle, "/gaim/gtk/conversations/tab_side", |
5675
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
6392 tab_side_pref_cb, NULL); |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
6393 |
10087 | 6394 gaim_prefs_connect_callback(handle, "/gaim/gtk/conversations/placement", |
7561
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
6395 conv_placement_pref_cb, NULL); |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
6396 gaim_prefs_trigger_callback("/gaim/gtk/conversations/placement"); |
cdfdbabd3266
[gaim-migrate @ 8175]
Christian Hammond <chipx86@chipx86.com>
parents:
7538
diff
changeset
|
6397 |
10087 | 6398 gaim_prefs_connect_callback(handle, "/gaim/gtk/conversations/button_type", |
9150 | 6399 button_type_pref_cb, NULL); |
6725
e62a504c83d0
[gaim-migrate @ 7252]
Christian Hammond <chipx86@chipx86.com>
parents:
6695
diff
changeset
|
6400 |
5675
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
6401 /* IM callbacks */ |
10087 | 6402 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
|
6403 animate_buddy_icons_pref_cb, NULL); |
10087 | 6404 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
|
6405 show_buddy_icons_pref_cb, NULL); |
5675
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
6406 |
17e345ffeddb
[gaim-migrate @ 6093]
Christian Hammond <chipx86@chipx86.com>
parents:
5674
diff
changeset
|
6407 |
8582
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6408 /********************************************************************** |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6409 * Register signals |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6410 **********************************************************************/ |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6411 gaim_signal_register(handle, "conversation-drag-ended", |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6412 gaim_marshal_VOID__POINTER_POINTER, NULL, 2, |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6413 gaim_value_new(GAIM_TYPE_SUBTYPE, |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6414 GAIM_SUBTYPE_CONV_WINDOW), |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6415 gaim_value_new(GAIM_TYPE_SUBTYPE, |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6416 GAIM_SUBTYPE_CONV_WINDOW)); |
9167 | 6417 |
6418 /********************************************************************** | |
6419 * Register commands | |
6420 **********************************************************************/ | |
9829 | 6421 gaim_cmd_register("say", "S", GAIM_CMD_P_DEFAULT, |
6422 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_IM, NULL, | |
6423 say_command_cb, _("say <message>: Send a message normally as if you weren't using a command."), NULL); | |
9213 | 6424 gaim_cmd_register("me", "S", GAIM_CMD_P_DEFAULT, |
6425 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_IM, NULL, | |
9597 | 6426 me_command_cb, _("me <action>: Send an IRC style action to a buddy or chat."), NULL); |
9213 | 6427 gaim_cmd_register("debug", "w", GAIM_CMD_P_DEFAULT, |
6428 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_IM, NULL, | |
9597 | 6429 debug_command_cb, _("debug <option>: Send various debug information to the current conversation."), NULL); |
9213 | 6430 |
6431 gaim_cmd_register("help", "w", GAIM_CMD_P_DEFAULT, | |
9597 | 6432 GAIM_CMD_FLAG_CHAT | GAIM_CMD_FLAG_IM | GAIM_CMD_FLAG_ALLOW_WRONG_ARGS, NULL, |
6433 help_command_cb, _("help <command>: Help on a specific command."), NULL); | |
5673
62f57ec16f29
[gaim-migrate @ 6091]
Christian Hammond <chipx86@chipx86.com>
parents:
5629
diff
changeset
|
6434 } |
8582
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6435 |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6436 void |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6437 gaim_gtk_conversations_uninit(void) |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6438 { |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6439 gaim_signals_unregister_by_instance(gaim_gtk_conversations_get_handle()); |
d7c85220c685
[gaim-migrate @ 9332]
Christian Hammond <chipx86@chipx86.com>
parents:
8573
diff
changeset
|
6440 } |