Mercurial > pidgin.yaz
annotate src/gtkconv.c @ 5040:9af91af51192
[gaim-migrate @ 5384]
0.60 update
committer: Tailor Script <tailor@pidgin.im>
author | Herman Bloggs <hermanator12002@yahoo.com> |
---|---|
date | Sat, 05 Apr 2003 18:46:37 +0000 |
parents | 8e55a4d362a3 |
children | 44945824ba60 |
rev | line source |
---|---|
4359 | 1 /* |
2 * gaim | |
3 * | |
4 * Copyright (C) 2002-2003, Christian Hammond <chipx86@gnupdate.org> | |
5 * | |
6 * This program is free software; you can redistribute it and/or modify | |
7 * it under the terms of the GNU General Public License as published by | |
8 * the Free Software Foundation; either version 2 of the License, or | |
9 * (at your option) any later version. | |
10 * | |
11 * This program is distributed in the hope that it will be useful, | |
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 * GNU General Public License for more details. | |
15 * | |
16 * You should have received a copy of the GNU General Public License | |
17 * along with this program; if not, write to the Free Software | |
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
19 * | |
20 */ | |
21 #ifdef HAVE_CONFIG_H | |
22 #include <config.h> | |
23 #endif | |
24 #include <string.h> | |
25 #ifndef _WIN32 | |
26 #include <sys/time.h> | |
27 #include <unistd.h> | |
28 #include <gdk/gdkx.h> | |
29 #include <X11/Xlib.h> | |
30 #endif /*_WIN32*/ | |
31 #include <sys/types.h> | |
32 #include <sys/stat.h> | |
33 #include <stdio.h> | |
34 #include <stdlib.h> | |
35 #include <errno.h> | |
36 #include <ctype.h> | |
37 #include <gtk/gtk.h> | |
38 #ifdef USE_GTKSPELL | |
39 #include <gtkspell/gtkspell.h> | |
40 #endif | |
41 #include "gtkimhtml.h" | |
42 #include <gdk/gdkkeysyms.h> | |
43 #include "prpl.h" | |
44 #include "gtkimhtml.h" | |
45 #include "dnd-hints.h" | |
4561 | 46 #include "sound.h" |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
47 #include "gtklist.h" |
4359 | 48 |
4373
dcc6c130c6d9
[gaim-migrate @ 4639]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4370
diff
changeset
|
49 #ifdef _WIN32 |
dcc6c130c6d9
[gaim-migrate @ 4639]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4370
diff
changeset
|
50 #include "win32dep.h" |
4859
a9a831508b43
[gaim-migrate @ 5186]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4851
diff
changeset
|
51 #include "wspell.h" |
4373
dcc6c130c6d9
[gaim-migrate @ 4639]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4370
diff
changeset
|
52 #endif |
dcc6c130c6d9
[gaim-migrate @ 4639]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4370
diff
changeset
|
53 |
4359 | 54 static char nick_colors[][8] = { |
55 "#ba55d3", /* Medium Orchid */ | |
56 "#ee82ee", /* Violet */ | |
57 "#c715b4", /* Medium Violet Red */ | |
58 "#ff69b4", /* Hot Pink */ | |
59 "#ff6347", /* Tomato */ | |
60 "#fa8c00", /* Dark Orange */ | |
61 "#fa8072", /* Salmon */ | |
62 "#b22222", /* Fire Brick */ | |
63 "#f4a460", /* Sandy Brown */ | |
64 "#cd5c5c", /* Indian Red */ | |
65 "#bc8f8f", /* Rosy Brown */ | |
66 "#f0e68c", /* Khaki */ | |
67 "#bdb76b", /* Dark Khaki */ | |
68 "#228b22", /* Forest Green */ | |
69 "#9acd32", /* Yellow Green */ | |
70 "#32cd32", /* Lime Green */ | |
71 "#3cb371", /* Medium Sea Green */ | |
72 "#2e8b57", /* Sea Green */ | |
73 "#8fbc8f", /* Dark Sea Green */ | |
74 "#66cdaa", /* Medium Aquamarine */ | |
75 "#5f9ea0", /* Cadet Blue */ | |
76 "#48d1cc", /* Medium Turquoise */ | |
77 "#00ced1", /* Dark Turquoise */ | |
78 "#4682b4", /* Stell Blue */ | |
79 "#00bfff", /* Deep Sky Blue */ | |
80 "#1690ff", /* Dodger Blue */ | |
81 "#4169ff", /* Royal Blue */ | |
82 "#6a5acd", /* Slate Blue */ | |
83 "#6495ed", /* Cornflower Blue */ | |
84 "#708090", /* Slate gray */ | |
85 "#ffdead", /* Navajo White */ | |
86 }; | |
87 #define NUM_NICK_COLORS (sizeof(nick_colors) / sizeof(*nick_colors)) | |
88 | |
89 #define SCALE(x) \ | |
90 ((gdk_pixbuf_animation_get_width(x) <= 48 && \ | |
91 gdk_pixbuf_animation_get_height(x) <= 48) ? 48 : 50) | |
92 | |
93 struct InviteBuddyInfo | |
94 { | |
95 GtkWidget *window; | |
96 | |
97 GtkWidget *entry; | |
98 GtkWidget *message; | |
99 | |
100 struct gaim_conversation *conv; | |
101 }; | |
102 | |
103 char fontface[128] = { 0 }; | |
104 int fontsize = 3; | |
105 | |
106 static GtkWidget *invite_dialog = NULL; | |
107 | |
108 /* Prototypes. <-- because Paco-Paco hates this comment. */ | |
109 static void check_everything(GtkTextBuffer *buffer); | |
4685 | 110 static void set_toggle(GtkWidget *tb, gboolean active); |
4359 | 111 static void move_next_tab(struct gaim_conversation *conv); |
112 static void do_bold(GtkWidget *bold, struct gaim_gtk_conversation *gtkconv); | |
113 static void do_italic(GtkWidget *italic, struct gaim_gtk_conversation *gtkconv); | |
114 static void do_underline(GtkWidget *underline, struct gaim_gtk_conversation *gtkconv); | |
115 static void do_small(GtkWidget *small, struct gaim_gtk_conversation *gtkconv); | |
116 static void do_normal(GtkWidget *small, struct gaim_gtk_conversation *gtkconv); | |
117 static void do_big(GtkWidget *small, struct gaim_gtk_conversation *gtkconv); | |
118 static void toggle_font(GtkWidget *font, struct gaim_conversation *conv); | |
119 static void toggle_fg_color(GtkWidget *color, struct gaim_conversation *conv); | |
120 static void toggle_bg_color(GtkWidget *color, struct gaim_conversation *conv); | |
121 static void got_typing_keypress(struct gaim_conversation *conv, gboolean first); | |
122 static GList *generate_invite_user_names(struct gaim_connection *gc); | |
123 static void add_chat_buddy_common(struct gaim_conversation *conv, | |
124 const char *name, int pos); | |
125 static void tab_complete(struct gaim_conversation *conv); | |
4736 | 126 static void update_typing_icon(struct gaim_conversation *conv); |
4685 | 127 static gboolean update_send_as_selection(struct gaim_window *win); |
4602
4128761bacb8
[gaim-migrate @ 4889]
Christian Hammond <chipx86@chipx86.com>
parents:
4598
diff
changeset
|
128 static char *item_factory_translate_func (const char *path, gpointer func_data); |
4359 | 129 |
130 /************************************************************************** | |
131 * Callbacks | |
132 **************************************************************************/ | |
133 static void | |
134 do_insert_image_cb(GObject *obj, GtkWidget *wid) | |
135 { | |
136 struct gaim_conversation *conv; | |
137 struct gaim_gtk_conversation *gtkconv; | |
138 struct gaim_im *im; | |
139 const char *name; | |
140 const char *filename; | |
141 char *buf; | |
142 struct stat st; | |
143 int id; | |
144 | |
145 conv = g_object_get_data(obj, "user_data"); | |
146 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
147 im = GAIM_IM(conv); | |
148 name = gtk_file_selection_get_filename(GTK_FILE_SELECTION(wid)); | |
149 id = g_slist_length(im->images) + 1; | |
150 | |
151 if (file_is_dir(name, wid)) | |
152 return; | |
153 | |
154 gtk_widget_destroy(wid); | |
155 | |
156 if (!name) | |
157 return; | |
158 | |
159 if (stat(name, &st) != 0) { | |
160 debug_printf("Could not stat %s\n", name); | |
161 return; | |
162 } | |
163 | |
164 filename = name; | |
165 while (strchr(filename, '/')) | |
166 filename = strchr(filename, '/') + 1; | |
167 | |
168 buf = g_strdup_printf("<IMG SRC=\"file://%s\" ID=\"%d\" DATASIZE=\"%d\">", | |
169 filename, id, (int)st.st_size); | |
170 im->images = g_slist_append(im->images, g_strdup(name)); | |
171 gtk_text_buffer_insert_at_cursor(GTK_TEXT_BUFFER(gtkconv->entry_buffer), | |
172 buf, -1); | |
173 g_free(buf); | |
174 } | |
175 | |
176 static gint | |
177 close_win_cb(GtkWidget *w, GdkEventAny *e, gpointer d) | |
178 { | |
179 struct gaim_window *win = (struct gaim_window *)d; | |
180 | |
181 gaim_window_destroy(win); | |
4361
25d5b2a7545f
[gaim-migrate @ 4627]
Christian Hammond <chipx86@chipx86.com>
parents:
4360
diff
changeset
|
182 |
25d5b2a7545f
[gaim-migrate @ 4627]
Christian Hammond <chipx86@chipx86.com>
parents:
4360
diff
changeset
|
183 return TRUE; |
4359 | 184 } |
185 | |
186 static gint | |
187 close_conv_cb(GtkWidget *w, gpointer d) | |
188 { | |
189 struct gaim_conversation *conv = (struct gaim_conversation *)d; | |
190 | |
191 gaim_conversation_destroy(conv); | |
4361
25d5b2a7545f
[gaim-migrate @ 4627]
Christian Hammond <chipx86@chipx86.com>
parents:
4360
diff
changeset
|
192 |
25d5b2a7545f
[gaim-migrate @ 4627]
Christian Hammond <chipx86@chipx86.com>
parents:
4360
diff
changeset
|
193 return TRUE; |
4359 | 194 } |
195 | |
196 static void | |
197 insert_image_cb(GtkWidget *save, struct gaim_conversation *conv) | |
198 { | |
199 struct gaim_gtk_conversation *gtkconv; | |
200 char buf[BUF_LONG]; | |
201 GtkWidget *window; | |
202 | |
203 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
204 | |
205 window = gtk_file_selection_new(_("Gaim - Insert Image")); | |
206 g_snprintf(buf, sizeof(buf), "%s" G_DIR_SEPARATOR_S, gaim_home_dir()); | |
207 gtk_file_selection_set_filename(GTK_FILE_SELECTION(window), buf); | |
208 | |
209 g_object_set_data(G_OBJECT(GTK_FILE_SELECTION(window)->ok_button), | |
210 "user_data", conv); | |
211 g_signal_connect(G_OBJECT(GTK_FILE_SELECTION(window)->ok_button), | |
212 "clicked", G_CALLBACK(do_insert_image_cb), window); | |
213 g_signal_connect_swapped( | |
214 G_OBJECT(GTK_FILE_SELECTION(window)->cancel_button), | |
215 "clicked", G_CALLBACK(gtk_widget_destroy), window); | |
216 | |
217 gtk_widget_show(window); | |
4895 | 218 /* |
4635 | 219 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(gtkconv->toolbar.image), |
4359 | 220 FALSE); |
4895 | 221 */ |
4359 | 222 } |
223 | |
224 static void | |
225 insert_link_cb(GtkWidget *w, struct gaim_conversation *conv) | |
226 { | |
227 struct gaim_gtk_conversation *gtkconv; | |
228 | |
229 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
230 | |
231 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(gtkconv->toolbar.link))) | |
232 show_insert_link(gtkconv->toolbar.link, conv); | |
233 else if (gtkconv->dialogs.link) | |
234 cancel_link(gtkconv->toolbar.link, conv); | |
235 else | |
236 gaim_gtk_advance_past(gtkconv, "<A HREF>", "</A>"); | |
237 | |
238 gtk_widget_grab_focus(gtkconv->entry); | |
239 } | |
240 | |
241 static void | |
242 insert_smiley_cb(GtkWidget *smiley, struct gaim_conversation *conv) | |
243 { | |
244 struct gaim_gtk_conversation *gtkconv; | |
245 | |
246 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
247 | |
248 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(smiley))) | |
249 show_smiley_dialog(conv, smiley); | |
250 else if (gtkconv->dialogs.smiley) | |
251 close_smiley_dialog(smiley, conv); | |
252 | |
253 gtk_widget_grab_focus(gtkconv->entry); | |
254 } | |
255 | |
256 static void | |
257 menu_save_as_cb(gpointer data, guint action, GtkWidget *widget) | |
258 { | |
259 struct gaim_window *win = (struct gaim_window *)data; | |
260 | |
261 save_convo(NULL, gaim_window_get_active_conversation(win)); | |
262 } | |
263 | |
264 static void | |
265 menu_view_history_cb(gpointer data, guint action, GtkWidget *widget) | |
266 { | |
267 struct gaim_window *win = (struct gaim_window *)data; | |
4387
a3fd5fe57a0b
[gaim-migrate @ 4653]
Christian Hammond <chipx86@chipx86.com>
parents:
4383
diff
changeset
|
268 struct gaim_conversation *conv; |
a3fd5fe57a0b
[gaim-migrate @ 4653]
Christian Hammond <chipx86@chipx86.com>
parents:
4383
diff
changeset
|
269 |
a3fd5fe57a0b
[gaim-migrate @ 4653]
Christian Hammond <chipx86@chipx86.com>
parents:
4383
diff
changeset
|
270 conv = gaim_window_get_active_conversation(win); |
a3fd5fe57a0b
[gaim-migrate @ 4653]
Christian Hammond <chipx86@chipx86.com>
parents:
4383
diff
changeset
|
271 |
a3fd5fe57a0b
[gaim-migrate @ 4653]
Christian Hammond <chipx86@chipx86.com>
parents:
4383
diff
changeset
|
272 conv_show_log(NULL, (char *)gaim_conversation_get_name(conv)); |
4359 | 273 } |
274 static void | |
275 menu_insert_link_cb(gpointer data, guint action, GtkWidget *widget) | |
276 { | |
277 struct gaim_window *win = (struct gaim_window *)data; | |
278 struct gaim_conversation *conv; | |
279 struct gaim_gtk_conversation *gtkconv; | |
280 | |
281 conv = gaim_window_get_active_conversation(win); | |
282 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
283 | |
284 show_insert_link(gtkconv->toolbar.link, conv); | |
285 } | |
286 | |
287 static void | |
288 menu_insert_image_cb(gpointer data, guint action, GtkWidget *widget) | |
289 { | |
290 struct gaim_window *win = (struct gaim_window *)data; | |
291 | |
292 insert_image_cb(NULL, gaim_window_get_active_conversation(win)); | |
293 } | |
294 | |
295 static void | |
296 menu_close_conv_cb(gpointer data, guint action, GtkWidget *widget) | |
297 { | |
298 struct gaim_window *win = (struct gaim_window *)data; | |
299 | |
300 close_conv_cb(NULL, gaim_window_get_active_conversation(win)); | |
301 } | |
302 | |
303 static void | |
304 menu_logging_cb(gpointer data, guint action, GtkWidget *widget) | |
305 { | |
306 struct gaim_window *win = (struct gaim_window *)data; | |
307 struct gaim_conversation *conv; | |
308 | |
309 conv = gaim_window_get_active_conversation(win); | |
310 | |
311 gaim_conversation_set_logging(conv, !gaim_conversation_is_logging(conv)); | |
312 } | |
313 | |
314 static void | |
315 menu_sounds_cb(gpointer data, guint action, GtkWidget *widget) | |
316 { | |
317 struct gaim_window *win = (struct gaim_window *)data; | |
318 struct gaim_conversation *conv; | |
319 struct gaim_gtk_conversation *gtkconv; | |
320 | |
4803
6f04901ef729
[gaim-migrate @ 5123]
Christian Hammond <chipx86@chipx86.com>
parents:
4793
diff
changeset
|
321 conv = gaim_window_get_active_conversation(win); |
6f04901ef729
[gaim-migrate @ 5123]
Christian Hammond <chipx86@chipx86.com>
parents:
4793
diff
changeset
|
322 |
6f04901ef729
[gaim-migrate @ 5123]
Christian Hammond <chipx86@chipx86.com>
parents:
4793
diff
changeset
|
323 if (!conv) |
4359 | 324 return; |
325 | |
326 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
327 | |
328 gtkconv->make_sound = !gtkconv->make_sound; | |
329 } | |
330 | |
331 static gboolean | |
332 entry_key_pressed_cb_1(GtkTextBuffer *buffer) | |
333 { | |
334 check_everything(buffer); | |
335 | |
336 return FALSE; | |
337 } | |
338 | |
339 static void | |
340 send_cb(GtkWidget *widget, struct gaim_conversation *conv) | |
341 { | |
342 struct gaim_gtk_conversation *gtkconv; | |
343 char *buf, *buf2; | |
344 GtkTextIter start_iter, end_iter; | |
345 int limit; | |
4505 | 346 struct gaim_connection *gc = gaim_conversation_get_gc(conv); |
4359 | 347 |
348 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
349 | |
350 gtk_text_buffer_get_start_iter(gtkconv->entry_buffer, &start_iter); | |
351 gtk_text_buffer_get_end_iter(gtkconv->entry_buffer, &end_iter); | |
352 buf2 = gtk_text_buffer_get_text(gtkconv->entry_buffer, | |
353 &start_iter, &end_iter, FALSE); | |
354 | |
4685 | 355 set_toggle(gtkconv->toolbar.bold, FALSE); |
356 set_toggle(gtkconv->toolbar.italic, FALSE); | |
357 set_toggle(gtkconv->toolbar.underline, FALSE); | |
358 set_toggle(gtkconv->toolbar.normal_size, FALSE); | |
359 set_toggle(gtkconv->toolbar.font, FALSE); | |
360 set_toggle(gtkconv->toolbar.fgcolor, FALSE); | |
361 set_toggle(gtkconv->toolbar.bgcolor, FALSE); | |
362 set_toggle(gtkconv->toolbar.link, FALSE); | |
4359 | 363 |
364 gtk_widget_grab_focus(gtkconv->entry); | |
365 | |
366 limit = 32 * 1024; /* This will be done again in gaim_im_send. *shrug* */ | |
367 | |
368 buf = g_malloc(limit); | |
369 strncpy(buf, buf2, limit); | |
370 | |
371 g_free(buf2); | |
372 | |
373 if (strlen(buf) == 0) { | |
374 g_free(buf); | |
375 | |
376 return; | |
377 } | |
378 | |
379 buf2 = g_malloc(limit); | |
380 | |
4505 | 381 if (gc && gc->flags & OPT_CONN_HTML) { |
4359 | 382 if (font_options & OPT_FONT_BOLD) { |
383 g_snprintf(buf2, limit, "<B>%s</B>", buf); | |
384 strcpy(buf, buf2); | |
385 } | |
386 | |
387 if (font_options & OPT_FONT_ITALIC) { | |
388 g_snprintf(buf2, limit, "<I>%s</I>", buf); | |
389 strcpy(buf, buf2); | |
390 } | |
391 | |
392 if (font_options & OPT_FONT_UNDERLINE) { | |
393 g_snprintf(buf2, limit, "<U>%s</U>", buf); | |
394 strcpy(buf, buf2); | |
395 } | |
396 | |
397 if (font_options & OPT_FONT_STRIKE) { | |
398 g_snprintf(buf2, limit, "<STRIKE>%s</STRIKE>", buf); | |
399 strcpy(buf, buf2); | |
400 } | |
401 | |
402 if ((font_options & OPT_FONT_FACE) || gtkconv->has_font) { | |
403 g_snprintf(buf2, limit, | |
404 "<FONT FACE=\"%s\">%s</FONT>", gtkconv->fontface, buf); | |
405 strcpy(buf, buf2); | |
406 } | |
407 | |
408 if (font_options & OPT_FONT_SIZE) { | |
409 g_snprintf(buf2, limit, | |
410 "<FONT SIZE=\"%d\">%s</FONT>", fontsize, buf); | |
411 strcpy(buf, buf2); | |
412 } | |
413 | |
4421 | 414 if (font_options & OPT_FONT_FGCOL) { |
4359 | 415 g_snprintf(buf2, limit, |
416 "<FONT COLOR=\"#%02X%02X%02X\">%s</FONT>", | |
417 gtkconv->fg_color.red / 256, | |
418 gtkconv->fg_color.green / 256, | |
419 gtkconv->fg_color.blue / 256, buf); | |
420 strcpy(buf, buf2); | |
421 } | |
422 | |
4421 | 423 if (font_options & OPT_FONT_BGCOL) { |
4359 | 424 g_snprintf(buf2, limit, |
425 "<BODY BGCOLOR=\"#%02X%02X%02X\">%s</BODY>", | |
4421 | 426 gtkconv->bg_color.red / 256, |
427 gtkconv->bg_color.green / 256, | |
428 gtkconv->bg_color.blue / 256, buf); | |
4359 | 429 strcpy(buf, buf2); |
430 } | |
431 } | |
432 | |
433 g_free(buf2); | |
434 | |
435 if (gaim_conversation_get_type(conv) == GAIM_CONV_IM) | |
436 gaim_im_send(GAIM_IM(conv), buf); | |
437 else | |
438 gaim_chat_send(GAIM_CHAT(conv), buf); | |
439 | |
440 g_free(buf); | |
441 | |
442 gtk_text_buffer_set_text(gtkconv->entry_buffer, "", -1); | |
443 } | |
444 | |
445 static void | |
446 add_cb(GtkWidget *widget, struct gaim_conversation *conv) | |
447 { | |
448 struct gaim_connection *gc; | |
449 struct buddy *b; | |
450 const char *name; | |
451 | |
452 gc = gaim_conversation_get_gc(conv); | |
453 name = gaim_conversation_get_name(conv); | |
4687 | 454 b = gaim_find_buddy(gc->account, name); |
4359 | 455 |
456 if (b != NULL) | |
457 show_confirm_del(gc, (char *)name); | |
458 else if (gc != NULL) | |
459 show_add_buddy(gc, (char *)name, NULL, NULL); | |
460 | |
461 gtk_widget_grab_focus(GAIM_GTK_CONVERSATION(conv)->entry); | |
462 } | |
463 | |
464 static void | |
465 info_cb(GtkWidget *widget, struct gaim_conversation *conv) | |
466 { | |
467 struct gaim_gtk_conversation *gtkconv; | |
468 | |
469 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
470 | |
471 if (gaim_conversation_get_type(conv) == GAIM_CONV_CHAT) { | |
472 struct gaim_gtk_chat_pane *gtkchat; | |
473 GtkTreeIter iter; | |
474 GtkTreeModel *model; | |
475 GtkTreeSelection *sel; | |
476 const char *name; | |
477 | |
478 gtkchat = gtkconv->u.chat; | |
479 | |
480 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); | |
481 sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(gtkchat->list)); | |
482 | |
483 if (gtk_tree_selection_get_selected(sel, NULL, &iter)) | |
484 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, 1, &name, -1); | |
485 else | |
486 return; | |
487 | |
488 serv_get_info(gaim_conversation_get_gc(conv), (char *)name); | |
489 } | |
490 else { | |
491 serv_get_info(gaim_conversation_get_gc(conv), | |
492 (char *)gaim_conversation_get_name(conv)); | |
493 | |
494 gtk_widget_grab_focus(gtkconv->entry); | |
495 } | |
496 } | |
497 | |
498 static void | |
499 warn_cb(GtkWidget *widget, struct gaim_conversation *conv) | |
500 { | |
501 show_warn_dialog(gaim_conversation_get_gc(conv), | |
502 (char *)gaim_conversation_get_name(conv)); | |
503 | |
504 gtk_widget_grab_focus(GAIM_GTK_CONVERSATION(conv)->entry); | |
505 } | |
506 | |
507 static void | |
508 block_cb(GtkWidget *widget, struct gaim_conversation *conv) | |
509 { | |
510 struct gaim_connection *gc; | |
511 | |
512 gc = gaim_conversation_get_gc(conv); | |
513 | |
514 if (gc != NULL) | |
515 show_add_perm(gc, (char *)gaim_conversation_get_name(conv), FALSE); | |
516 | |
517 gtk_widget_grab_focus(GAIM_GTK_CONVERSATION(conv)->entry); | |
518 } | |
519 | |
520 void | |
521 im_cb(GtkWidget *widget, struct gaim_conversation *conv) | |
522 { | |
523 struct gaim_conversation *conv2; | |
524 struct gaim_gtk_conversation *gtkconv; | |
525 struct gaim_gtk_chat_pane *gtkchat; | |
4491 | 526 struct gaim_account *account; |
4359 | 527 GtkTreeIter iter; |
528 GtkTreeModel *model; | |
529 GtkTreeSelection *sel; | |
530 const char *name; | |
531 | |
532 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
533 gtkchat = gtkconv->u.chat; | |
534 | |
535 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); | |
536 sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(gtkchat->list)); | |
537 | |
538 if (gtk_tree_selection_get_selected(sel, NULL, &iter)) | |
539 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, 1, &name, -1); | |
540 else | |
541 return; | |
542 | |
543 if (*name == '@') name++; | |
4621
69f028a6f357
[gaim-migrate @ 4912]
Christian Hammond <chipx86@chipx86.com>
parents:
4608
diff
changeset
|
544 if (*name == '%') name++; |
4359 | 545 if (*name == '+') name++; |
546 | |
4491 | 547 account = gaim_conversation_get_account(conv); |
4476
62c1e5e656d0
[gaim-migrate @ 4751]
Christian Hammond <chipx86@chipx86.com>
parents:
4466
diff
changeset
|
548 |
4359 | 549 conv2 = gaim_find_conversation(name); |
550 | |
4476
62c1e5e656d0
[gaim-migrate @ 4751]
Christian Hammond <chipx86@chipx86.com>
parents:
4466
diff
changeset
|
551 if (conv2 != NULL) { |
4359 | 552 gaim_window_raise(gaim_conversation_get_window(conv2)); |
4491 | 553 gaim_conversation_set_account(conv2, account); |
4476
62c1e5e656d0
[gaim-migrate @ 4751]
Christian Hammond <chipx86@chipx86.com>
parents:
4466
diff
changeset
|
554 } |
4359 | 555 else |
4491 | 556 conv2 = gaim_conversation_new(GAIM_CONV_IM, account, name); |
4359 | 557 } |
558 | |
559 static void | |
560 ignore_cb(GtkWidget *w, struct gaim_conversation *conv) | |
561 { | |
562 struct gaim_gtk_conversation *gtkconv; | |
563 struct gaim_gtk_chat_pane *gtkchat; | |
564 struct gaim_chat *chat; | |
565 GtkTreeIter iter; | |
566 GtkTreeModel *model; | |
567 GtkTreeSelection *sel; | |
568 const char *name; | |
569 int pos; | |
570 | |
571 chat = GAIM_CHAT(conv); | |
572 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
573 gtkchat = gtkconv->u.chat; | |
574 | |
575 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); | |
576 sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(gtkchat->list)); | |
577 | |
578 if (gtk_tree_selection_get_selected(sel, NULL, &iter)) { | |
579 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, 1, &name, -1); | |
580 gtk_list_store_remove(GTK_LIST_STORE(model), &iter); | |
581 } | |
582 else | |
583 return; | |
584 | |
585 pos = g_list_index(gaim_chat_get_users(chat), name); | |
586 | |
587 if (gaim_chat_is_user_ignored(chat, name)) | |
588 gaim_chat_unignore(chat, name); | |
589 else | |
590 gaim_chat_ignore(chat, name); | |
591 | |
592 add_chat_buddy_common(conv, name, pos); | |
593 } | |
594 | |
595 static void | |
596 menu_im_cb(GtkWidget *w, struct gaim_conversation *conv) | |
597 { | |
598 const char *who; | |
599 struct gaim_conversation *conv2; | |
4491 | 600 struct gaim_account *account; |
4359 | 601 |
602 who = g_object_get_data(G_OBJECT(w), "user_data"); | |
603 | |
4491 | 604 account = gaim_conversation_get_account(conv); |
4476
62c1e5e656d0
[gaim-migrate @ 4751]
Christian Hammond <chipx86@chipx86.com>
parents:
4466
diff
changeset
|
605 |
4359 | 606 conv2 = gaim_find_conversation(who); |
607 | |
608 if (conv2 != NULL) | |
609 gaim_window_show(gaim_conversation_get_window(conv2)); | |
4476
62c1e5e656d0
[gaim-migrate @ 4751]
Christian Hammond <chipx86@chipx86.com>
parents:
4466
diff
changeset
|
610 else |
4491 | 611 conv2 = gaim_conversation_new(GAIM_CONV_IM, account, who); |
4359 | 612 } |
613 | |
614 static void | |
615 menu_info_cb(GtkWidget *w, struct gaim_conversation *conv) | |
616 { | |
617 struct gaim_connection *gc; | |
618 char *who; | |
619 | |
620 gc = gaim_conversation_get_gc(conv); | |
621 who = g_object_get_data(G_OBJECT(w), "user_data"); | |
622 | |
623 if (gc != NULL) { | |
624 /* | |
625 * If there are special needs for getting info on users in | |
626 * buddy chat "rooms"... | |
627 */ | |
628 if (gc->prpl->get_cb_info != NULL) | |
629 gc->prpl->get_cb_info(gc, gaim_chat_get_id(GAIM_CHAT(conv)), who); | |
630 else | |
631 gc->prpl->get_info(gc, who); | |
632 } | |
633 } | |
634 | |
635 static void | |
636 menu_away_cb(GtkWidget *w, struct gaim_conversation *conv) | |
637 { | |
638 struct gaim_connection *gc; | |
639 char *who; | |
640 | |
641 gc = gaim_conversation_get_gc(conv); | |
642 who = g_object_get_data(G_OBJECT(w), "user_data"); | |
643 | |
644 if (gc != NULL) { | |
645 /* | |
646 * May want to expand this to work similarly to menu_info_cb? | |
647 */ | |
648 | |
649 if (gc->prpl->get_cb_away != NULL) | |
650 gc->prpl->get_cb_away(gc, gaim_chat_get_id(GAIM_CHAT(conv)), who); | |
651 } | |
652 } | |
653 | |
654 static void | |
655 menu_add_cb(GtkWidget *w, struct gaim_conversation *conv) | |
656 { | |
657 struct gaim_connection *gc; | |
658 struct buddy *b; | |
659 char *name; | |
660 | |
661 gc = gaim_conversation_get_gc(conv); | |
662 name = g_object_get_data(G_OBJECT(w), "user_data"); | |
4687 | 663 b = gaim_find_buddy(gc->account, name); |
4359 | 664 |
665 if (b != NULL) | |
666 show_confirm_del(gc, name); | |
667 else if (gc != NULL) | |
668 show_add_buddy(gc, name, NULL, NULL); | |
669 | |
670 gtk_widget_grab_focus(GAIM_GTK_CONVERSATION(conv)->entry); | |
671 } | |
672 | |
673 static gint | |
674 right_click_chat_cb(GtkWidget *widget, GdkEventButton *event, | |
675 struct gaim_conversation *conv) | |
676 { | |
677 struct gaim_gtk_conversation *gtkconv; | |
678 struct gaim_gtk_chat_pane *gtkchat; | |
679 struct gaim_connection *gc; | |
4491 | 680 struct gaim_account *account; |
4359 | 681 GtkTreePath *path; |
682 GtkTreeIter iter; | |
683 GtkTreeModel *model; | |
684 GtkTreeViewColumn *column; | |
685 gchar *who; | |
686 int x, y; | |
687 | |
688 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
689 gtkchat = gtkconv->u.chat; | |
4491 | 690 account = gaim_conversation_get_account(conv); |
691 gc = account->gc; | |
4359 | 692 |
693 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); | |
4685 | 694 |
4359 | 695 gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(gtkchat->list), |
696 event->x, event->y, &path, &column, &x, &y); | |
697 | |
698 if (path == NULL) | |
699 return FALSE; | |
700 | |
701 gtk_tree_selection_select_path(GTK_TREE_SELECTION( | |
702 gtk_tree_view_get_selection(GTK_TREE_VIEW(gtkchat->list))), path); | |
703 | |
704 gtk_tree_model_get_iter(GTK_TREE_MODEL(model), &iter, path); | |
705 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, 1, &who, -1); | |
706 | |
4621
69f028a6f357
[gaim-migrate @ 4912]
Christian Hammond <chipx86@chipx86.com>
parents:
4608
diff
changeset
|
707 if (*who == '@') who++; |
69f028a6f357
[gaim-migrate @ 4912]
Christian Hammond <chipx86@chipx86.com>
parents:
4608
diff
changeset
|
708 if (*who == '%') who++; |
69f028a6f357
[gaim-migrate @ 4912]
Christian Hammond <chipx86@chipx86.com>
parents:
4608
diff
changeset
|
709 if (*who == '+') who++; |
69f028a6f357
[gaim-migrate @ 4912]
Christian Hammond <chipx86@chipx86.com>
parents:
4608
diff
changeset
|
710 |
4359 | 711 if (event->button == 1 && event->type == GDK_2BUTTON_PRESS) { |
712 struct gaim_conversation *c; | |
713 | |
714 if ((c = gaim_find_conversation(who)) == NULL) | |
4491 | 715 c = gaim_conversation_new(GAIM_CONV_IM, account, who); |
4476
62c1e5e656d0
[gaim-migrate @ 4751]
Christian Hammond <chipx86@chipx86.com>
parents:
4466
diff
changeset
|
716 else |
4491 | 717 gaim_conversation_set_account(c, account); |
4359 | 718 } |
719 else if (event->button == 3 && event->type == GDK_BUTTON_PRESS) { | |
720 static GtkWidget *menu = NULL; | |
721 GtkWidget *button; | |
722 | |
723 /* | |
724 * If a menu already exists, destroy it before creating a new one, | |
725 * thus freeing-up the memory it occupied. | |
726 */ | |
727 | |
728 if (menu) | |
729 gtk_widget_destroy(menu); | |
730 | |
731 menu = gtk_menu_new(); | |
732 | |
733 button = gtk_menu_item_new_with_label(_("IM")); | |
734 g_signal_connect(G_OBJECT(button), "activate", | |
735 G_CALLBACK(menu_im_cb), conv); | |
736 g_object_set_data(G_OBJECT(button), "user_data", who); | |
4635 | 737 gtk_menu_shell_append(GTK_MENU_SHELL(menu), button); |
4359 | 738 gtk_widget_show(button); |
739 | |
740 if (gaim_chat_is_user_ignored(GAIM_CHAT(conv), who)) | |
741 button = gtk_menu_item_new_with_label(_("Un-Ignore")); | |
742 else | |
743 button = gtk_menu_item_new_with_label(_("Ignore")); | |
744 | |
745 g_signal_connect(G_OBJECT(button), "activate", | |
746 G_CALLBACK(ignore_cb), conv); | |
747 g_object_set_data(G_OBJECT(button), "user_data", who); | |
4635 | 748 gtk_menu_shell_append(GTK_MENU_SHELL(menu), button); |
4359 | 749 gtk_widget_show(button); |
750 | |
751 if (gc && gc->prpl->get_info) { | |
752 button = gtk_menu_item_new_with_label(_("Info")); | |
753 g_signal_connect(G_OBJECT(button), "activate", | |
754 G_CALLBACK(menu_info_cb), conv); | |
755 g_object_set_data(G_OBJECT(button), "user_data", who); | |
4635 | 756 gtk_menu_shell_append(GTK_MENU_SHELL(menu), button); |
4359 | 757 gtk_widget_show(button); |
758 } | |
759 | |
760 if (gc && gc->prpl->get_cb_away) { | |
761 button = gtk_menu_item_new_with_label(_("Get Away Msg")); | |
762 g_signal_connect(G_OBJECT(button), "activate", | |
763 G_CALLBACK(menu_away_cb), conv); | |
764 g_object_set_data(G_OBJECT(button), "user_data", who); | |
4635 | 765 gtk_menu_shell_append(GTK_MENU_SHELL(menu), button); |
4359 | 766 gtk_widget_show(button); |
767 } | |
768 | |
769 /* Added by Jonas <jonas@birme.se> */ | |
770 if (gc) { | |
4687 | 771 if (gaim_find_buddy(gc->account, who)) |
4359 | 772 button = gtk_menu_item_new_with_label(_("Remove")); |
773 else | |
774 button = gtk_menu_item_new_with_label(_("Add")); | |
775 | |
776 g_signal_connect(G_OBJECT(button), "activate", | |
777 G_CALLBACK(menu_add_cb), conv); | |
778 | |
779 g_object_set_data(G_OBJECT(button), "user_data", who); | |
4635 | 780 gtk_menu_shell_append(GTK_MENU_SHELL(menu), button); |
4359 | 781 gtk_widget_show(button); |
782 } | |
783 /* End Jonas */ | |
4635 | 784 |
4359 | 785 gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL, |
786 event->button, event->time); | |
787 } | |
788 | |
789 return TRUE; | |
790 } | |
791 | |
792 static void | |
793 do_invite(GtkWidget *w, int resp, struct InviteBuddyInfo *info) | |
794 { | |
795 const char *buddy, *message; | |
796 struct gaim_gtk_conversation *gtkconv; | |
797 | |
798 gtkconv = GAIM_GTK_CONVERSATION(info->conv); | |
799 | |
800 if (resp == GTK_RESPONSE_OK) { | |
801 buddy = gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(info->entry)->entry)); | |
802 message = gtk_entry_get_text(GTK_ENTRY(info->message)); | |
803 | |
4793 | 804 if (!g_ascii_strcasecmp(buddy, "")) { |
4359 | 805 g_free(info); |
806 | |
807 return; | |
808 } | |
809 | |
810 serv_chat_invite(gaim_conversation_get_gc(info->conv), | |
811 gaim_chat_get_id(GAIM_CHAT(info->conv)), | |
812 message, buddy); | |
813 } | |
814 | |
815 gtk_widget_destroy(invite_dialog); | |
816 invite_dialog = NULL; | |
817 | |
818 g_free(info); | |
819 } | |
820 | |
821 static void | |
822 invite_cb(GtkWidget *widget, struct gaim_conversation *conv) | |
823 { | |
824 struct InviteBuddyInfo *info = NULL; | |
825 | |
826 if (invite_dialog == NULL) { | |
827 struct gaim_connection *gc; | |
828 struct gaim_window *win; | |
829 struct gaim_gtk_window *gtkwin; | |
830 GtkWidget *label; | |
831 GtkWidget *vbox, *hbox; | |
832 GtkWidget *table; | |
833 GtkWidget *img; | |
834 | |
5024 | 835 img = gtk_image_new_from_stock(GAIM_STOCK_DIALOG_QUESTION, GTK_ICON_SIZE_DIALOG); |
4359 | 836 |
837 info = g_new0(struct InviteBuddyInfo, 1); | |
838 info->conv = conv; | |
839 | |
840 gc = gaim_conversation_get_gc(conv); | |
841 win = gaim_conversation_get_window(conv); | |
842 gtkwin = GAIM_GTK_WINDOW(win); | |
843 | |
844 /* Create the new dialog. */ | |
845 invite_dialog = gtk_dialog_new_with_buttons( | |
846 _("Gaim - Invite Buddy Into Chat Room"), | |
847 GTK_WINDOW(gtkwin->window), | |
848 GTK_DIALOG_MODAL, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, | |
849 GTK_STOCK_OK, GTK_RESPONSE_OK, NULL); | |
850 | |
851 gtk_dialog_set_default_response(GTK_DIALOG(invite_dialog), | |
852 GTK_RESPONSE_OK); | |
853 gtk_container_set_border_width(GTK_CONTAINER(invite_dialog), 6); | |
854 gtk_window_set_resizable(GTK_WINDOW(invite_dialog), FALSE); | |
855 gtk_dialog_set_has_separator(GTK_DIALOG(invite_dialog), FALSE); | |
856 | |
857 /* Setup the outside spacing. */ | |
858 vbox = GTK_DIALOG(invite_dialog)->vbox; | |
859 | |
860 gtk_box_set_spacing(GTK_BOX(vbox), 12); | |
861 gtk_container_set_border_width(GTK_CONTAINER(vbox), 6); | |
862 | |
863 /* Setup the inner hbox and put the dialog's icon in it. */ | |
864 hbox = gtk_hbox_new(FALSE, 12); | |
865 gtk_container_add(GTK_CONTAINER(vbox), hbox); | |
866 gtk_box_pack_start(GTK_BOX(hbox), img, FALSE, FALSE, 0); | |
867 gtk_misc_set_alignment(GTK_MISC(img), 0, 0); | |
868 | |
869 /* Setup the right vbox. */ | |
870 vbox = gtk_vbox_new(FALSE, 0); | |
871 gtk_container_add(GTK_CONTAINER(hbox), vbox); | |
872 | |
873 /* Put our happy label in it. */ | |
874 label = gtk_label_new(_("Please enter the name of the user you wish " | |
875 "to invite, along with an optional invite " | |
876 "message.")); | |
877 gtk_widget_set_size_request(label, 350, -1); | |
878 gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); | |
879 gtk_misc_set_alignment(GTK_MISC(label), 0, 0); | |
880 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); | |
881 | |
882 /* hbox for the table, and to give it some spacing on the left. */ | |
883 hbox = gtk_hbox_new(FALSE, 6); | |
884 gtk_container_add(GTK_CONTAINER(vbox), hbox); | |
885 | |
886 /* Setup the table we're going to use to lay stuff out. */ | |
887 table = gtk_table_new(2, 2, FALSE); | |
888 gtk_table_set_row_spacings(GTK_TABLE(table), 6); | |
889 gtk_table_set_col_spacings(GTK_TABLE(table), 6); | |
890 gtk_container_set_border_width(GTK_CONTAINER(table), 12); | |
891 gtk_box_pack_start(GTK_BOX(vbox), table, FALSE, FALSE, 0); | |
892 | |
893 /* Now the Buddy label */ | |
894 label = gtk_label_new(NULL); | |
895 gtk_label_set_markup_with_mnemonic(GTK_LABEL(label), _("_Buddy:")); | |
896 gtk_misc_set_alignment(GTK_MISC(label), 0, 0); | |
897 gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 0, 1); | |
898 | |
899 /* Now the Buddy drop-down entry field. */ | |
900 info->entry = gtk_combo_new(); | |
901 gtk_combo_set_case_sensitive(GTK_COMBO(info->entry), FALSE); | |
902 gtk_entry_set_activates_default( | |
903 GTK_ENTRY(GTK_COMBO(info->entry)->entry), TRUE); | |
904 | |
905 gtk_table_attach_defaults(GTK_TABLE(table), info->entry, 1, 2, 0, 1); | |
906 gtk_label_set_mnemonic_widget(GTK_LABEL(label), info->entry); | |
907 | |
908 /* Fill in the names. */ | |
909 gtk_combo_set_popdown_strings(GTK_COMBO(info->entry), | |
910 generate_invite_user_names(gc)); | |
911 | |
912 | |
913 /* Now the label for "Message" */ | |
914 label = gtk_label_new(NULL); | |
915 gtk_label_set_markup_with_mnemonic(GTK_LABEL(label), _("_Message:")); | |
916 gtk_misc_set_alignment(GTK_MISC(label), 0, 0); | |
917 gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 1, 2); | |
918 | |
919 | |
920 /* And finally, the Message entry field. */ | |
921 info->message = gtk_entry_new(); | |
922 gtk_entry_set_activates_default(GTK_ENTRY(info->message), TRUE); | |
923 | |
924 gtk_table_attach_defaults(GTK_TABLE(table), info->message, 1, 2, 1, 2); | |
925 gtk_label_set_mnemonic_widget(GTK_LABEL(label), info->message); | |
926 | |
927 /* Connect the signals. */ | |
928 g_signal_connect(G_OBJECT(invite_dialog), "response", | |
929 G_CALLBACK(do_invite), info); | |
930 } | |
931 | |
932 gtk_widget_show_all(invite_dialog); | |
933 | |
934 if (info != NULL) | |
935 gtk_widget_grab_focus(GTK_COMBO(info->entry)->entry); | |
936 } | |
937 | |
938 static gboolean | |
939 entry_key_pressed_cb_2(GtkWidget *entry, GdkEventKey *event, gpointer data) | |
940 { | |
941 struct gaim_window *win; | |
942 struct gaim_conversation *conv; | |
943 struct gaim_gtk_conversation *gtkconv; | |
4362 | 944 struct gaim_gtk_window *gtkwin; |
4359 | 945 |
946 conv = (struct gaim_conversation *)data; | |
947 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
948 win = gaim_conversation_get_window(conv); | |
4362 | 949 gtkwin = GAIM_GTK_WINDOW(win); |
4359 | 950 |
951 if (event->keyval == GDK_Escape) { | |
952 if (convo_options & OPT_CONVO_ESC_CAN_CLOSE) { | |
953 g_signal_stop_emission_by_name(G_OBJECT(entry), "key_press_event"); | |
954 gaim_conversation_destroy(conv); | |
955 } | |
956 } | |
957 else if (event->keyval == GDK_Page_Up) { | |
958 g_signal_stop_emission_by_name(G_OBJECT(entry), "key_press_event"); | |
959 | |
960 if (!(event->state & GDK_CONTROL_MASK)) | |
961 gtk_imhtml_page_up(GTK_IMHTML(gtkconv->imhtml)); | |
962 } | |
963 else if (event->keyval == GDK_Page_Down) { | |
964 g_signal_stop_emission_by_name(G_OBJECT(entry), "key_press_event"); | |
965 | |
966 if (!(event->state & GDK_CONTROL_MASK)) | |
967 gtk_imhtml_page_down(GTK_IMHTML(gtkconv->imhtml)); | |
968 } | |
969 else if ((event->keyval == GDK_F2) && | |
970 (convo_options & OPT_CONVO_F2_TOGGLES)) { | |
971 gtk_imhtml_show_comments(GTK_IMHTML(gtkconv->imhtml), | |
972 !GTK_IMHTML(gtkconv->imhtml)->comments); | |
973 } | |
974 else if (event->keyval == GDK_Return || event->keyval == GDK_KP_Enter) { | |
975 if ((event->state & GDK_CONTROL_MASK) && | |
976 (convo_options & OPT_CONVO_CTL_ENTER)) { | |
977 | |
978 send_cb(NULL, conv); | |
979 g_signal_stop_emission_by_name(G_OBJECT(entry), "key_press_event"); | |
980 | |
981 return TRUE; | |
982 } | |
983 else if (!(event->state & (GDK_SHIFT_MASK | GDK_CONTROL_MASK)) && | |
984 (convo_options & OPT_CONVO_ENTER_SENDS)) { | |
985 | |
986 send_cb(NULL, conv); | |
987 g_signal_stop_emission_by_name(G_OBJECT(entry), "key_press_event"); | |
988 | |
989 return TRUE; | |
990 } | |
991 | |
992 return FALSE; | |
993 } | |
994 else if ((event->state & GDK_CONTROL_MASK) && (event->keyval == 'm')) { | |
995 g_signal_stop_emission_by_name(G_OBJECT(entry), "key_press_event"); | |
996 gtk_text_buffer_insert_at_cursor(gtkconv->entry_buffer, "\n", 1); | |
997 } | |
998 else if (event->state & GDK_CONTROL_MASK) { | |
999 switch (event->keyval) { | |
1000 case GDK_Up: | |
1001 if (!conv->send_history) | |
1002 break; | |
1003 | |
1004 if (!conv->send_history->prev) { | |
1005 GtkTextIter start, end; | |
1006 | |
1007 if (conv->send_history->data) | |
1008 g_free(conv->send_history->data); | |
1009 | |
1010 gtk_text_buffer_get_start_iter(gtkconv->entry_buffer, | |
1011 &start); | |
1012 gtk_text_buffer_get_end_iter(gtkconv->entry_buffer, &end); | |
1013 | |
1014 conv->send_history->data = | |
1015 gtk_text_buffer_get_text(gtkconv->entry_buffer, | |
1016 &start, &end, FALSE); | |
1017 } | |
1018 | |
1019 if (conv->send_history->next && | |
1020 conv->send_history->next->data) { | |
1021 | |
1022 conv->send_history = conv->send_history->next; | |
1023 gtk_text_buffer_set_text(gtkconv->entry_buffer, | |
1024 conv->send_history->data, -1); | |
1025 } | |
1026 | |
1027 break; | |
1028 | |
1029 case GDK_Down: | |
1030 if (!conv->send_history) | |
1031 break; | |
1032 | |
1033 if (conv->send_history->prev) { | |
1034 conv->send_history = conv->send_history->prev; | |
1035 | |
1036 if (conv->send_history->data) | |
1037 gtk_text_buffer_set_text(gtkconv->entry_buffer, | |
1038 conv->send_history->data, -1); | |
1039 } | |
1040 | |
1041 break; | |
1042 } | |
1043 | |
1044 if (convo_options & OPT_CONVO_CTL_CHARS) { | |
1045 switch (event->keyval) { | |
1046 case 'i': | |
1047 case 'I': | |
4685 | 1048 set_toggle(gtkconv->toolbar.italic, |
4359 | 1049 !gtk_toggle_button_get_active( |
1050 GTK_TOGGLE_BUTTON(gtkconv->toolbar.italic))); | |
1051 | |
1052 g_signal_stop_emission_by_name(G_OBJECT(entry), | |
1053 "key_press_event"); | |
1054 break; | |
1055 | |
1056 case 'u': /* ctrl-u is GDK_Clear, which clears the line. */ | |
1057 case 'U': | |
4685 | 1058 set_toggle(gtkconv->toolbar.underline, |
4359 | 1059 !gtk_toggle_button_get_active( |
1060 GTK_TOGGLE_BUTTON(gtkconv->toolbar.underline))); | |
1061 | |
1062 g_signal_stop_emission_by_name(G_OBJECT(entry), | |
1063 "key_press_event"); | |
1064 break; | |
1065 | |
1066 case 'b': /* ctrl-b is GDK_Left, which moves backwards. */ | |
1067 case 'B': | |
4685 | 1068 set_toggle(gtkconv->toolbar.bold, |
4359 | 1069 !gtk_toggle_button_get_active( |
1070 GTK_TOGGLE_BUTTON(gtkconv->toolbar.bold))); | |
1071 | |
1072 g_signal_stop_emission_by_name(G_OBJECT(entry), | |
1073 "key_press_event"); | |
1074 break; | |
1075 | |
1076 case '-': | |
1077 do_small(NULL, gtkconv); | |
1078 | |
1079 g_signal_stop_emission_by_name(G_OBJECT(entry), | |
1080 "key_press_event"); | |
1081 break; | |
1082 | |
1083 case '=': | |
1084 case '+': | |
1085 do_big(NULL, gtkconv); | |
1086 | |
1087 g_signal_stop_emission_by_name(G_OBJECT(entry), | |
1088 "key_press_event"); | |
1089 break; | |
1090 | |
1091 case '0': | |
4685 | 1092 set_toggle(gtkconv->toolbar.normal_size, |
1093 !gtk_toggle_button_get_active( | |
1094 GTK_TOGGLE_BUTTON(gtkconv->toolbar.normal_size))); | |
4359 | 1095 |
1096 g_signal_stop_emission_by_name(G_OBJECT(entry), | |
1097 "key_press_event"); | |
1098 break; | |
1099 | |
1100 case 'f': | |
1101 case 'F': | |
4685 | 1102 set_toggle(gtkconv->toolbar.font, |
4359 | 1103 !gtk_toggle_button_get_active( |
4685 | 1104 GTK_TOGGLE_BUTTON(gtkconv->toolbar.font))); |
4359 | 1105 |
1106 g_signal_stop_emission_by_name(G_OBJECT(entry), | |
1107 "key_press_event"); | |
1108 break; | |
1109 } | |
1110 } | |
1111 | |
1112 if (convo_options & OPT_CONVO_CTL_SMILEYS) { | |
1113 char buf[7]; | |
1114 | |
1115 *buf = '\0'; | |
1116 | |
1117 switch (event->keyval) { | |
1118 case '1': strcpy(buf, ":-)"); break; | |
1119 case '2': strcpy(buf, ":-("); break; | |
1120 case '3': strcpy(buf, ";-)"); break; | |
1121 case '4': strcpy(buf, ":-P"); break; | |
1122 case '5': strcpy(buf, "=-O"); break; | |
1123 case '6': strcpy(buf, ":-*"); break; | |
1124 case '7': strcpy(buf, ">:o"); break; | |
1125 case '8': strcpy(buf, "8-)"); break; | |
1126 case '!': strcpy(buf, ":-$"); break; | |
1127 case '@': strcpy(buf, ":-!"); break; | |
1128 case '#': strcpy(buf, ":-["); break; | |
1129 case '$': strcpy(buf, "O:-)"); break; | |
1130 case '%': strcpy(buf, ":-/"); break; | |
1131 case '^': strcpy(buf, ":'("); break; | |
1132 case '&': strcpy(buf, ":-X"); break; | |
1133 case '*': strcpy(buf, ":-D"); break; | |
1134 default: break; | |
1135 } | |
1136 | |
1137 if (*buf) { | |
1138 gtk_text_buffer_insert_at_cursor(gtkconv->entry_buffer, | |
1139 buf, -1); | |
1140 g_signal_stop_emission_by_name(G_OBJECT(entry), "key_press_event"); | |
1141 } | |
1142 } | |
1143 | |
1144 if (event->keyval == 'l') { | |
1145 gtk_imhtml_clear(GTK_IMHTML(gtkconv->imhtml)); | |
1146 g_string_free(conv->history, TRUE); | |
1147 conv->history = g_string_new(""); | |
1148 } | |
1149 else if ((event->keyval == 'w') && | |
1150 (convo_options & OPT_CONVO_CTL_W_CLOSES)) { | |
1151 | |
1152 g_signal_stop_emission_by_name(G_OBJECT(entry), "key_press_event"); | |
1153 gaim_conversation_destroy(conv); | |
1154 return TRUE; | |
1155 } | |
1156 else if (event->keyval == 'n') { | |
1157 g_signal_stop_emission_by_name(G_OBJECT(entry), "key_press_event"); | |
1158 | |
1159 show_im_dialog(); | |
1160 } | |
1161 else if (event->keyval == 'z') { | |
1162 g_signal_stop_emission_by_name(G_OBJECT(entry), "key_press_event"); | |
1163 | |
4361
25d5b2a7545f
[gaim-migrate @ 4627]
Christian Hammond <chipx86@chipx86.com>
parents:
4360
diff
changeset
|
1164 #ifndef _WIN32 |
4359 | 1165 XIconifyWindow(GDK_DISPLAY(), |
1166 GDK_WINDOW_XWINDOW(gtkwin->window->window), | |
4362 | 1167 ((_XPrivDisplay)GDK_DISPLAY())->default_screen); |
4359 | 1168 #endif |
1169 } | |
1170 else if (event->keyval == '[') { | |
1171 gaim_window_switch_conversation(win, | |
1172 gaim_conversation_get_index(conv) - 1); | |
1173 | |
1174 g_signal_stop_emission_by_name(G_OBJECT(entry), "key_press_event"); | |
1175 } | |
1176 else if (event->keyval == ']') { | |
1177 gaim_window_switch_conversation(win, | |
1178 gaim_conversation_get_index(conv) + 1); | |
1179 | |
1180 g_signal_stop_emission_by_name(G_OBJECT(entry), "key_press_event"); | |
1181 } | |
1182 else if (event->keyval == GDK_Tab) { | |
1183 move_next_tab(conv); | |
1184 | |
1185 g_signal_stop_emission_by_name(G_OBJECT(entry), "key_press_event"); | |
1186 | |
1187 return TRUE; | |
1188 } | |
1189 } | |
1190 else if ((event->keyval == GDK_Tab) && | |
1191 gaim_conversation_get_type(conv) == GAIM_CONV_CHAT && | |
1192 (chat_options & OPT_CHAT_TAB_COMPLETE)) { | |
1193 | |
1194 tab_complete(conv); | |
1195 | |
1196 g_signal_stop_emission_by_name(G_OBJECT(entry), "key_press_event"); | |
1197 | |
1198 return TRUE; | |
1199 } | |
1200 else if ((event->state & GDK_MOD1_MASK) && | |
1201 event->keyval > '0' && event->keyval <= '9') { | |
1202 | |
1203 gaim_window_switch_conversation(win, event->keyval - '1'); | |
1204 | |
1205 g_signal_stop_emission_by_name(G_OBJECT(entry), "key_press_event"); | |
1206 } | |
1207 | |
1208 return FALSE; | |
1209 } | |
1210 | |
1211 /* | |
1212 * NOTE: | |
1213 * This guy just kills a single right click from being propagated any | |
1214 * further. I have no idea *why* we need this, but we do ... It | |
1215 * prevents right clicks on the GtkTextView in a convo dialog from | |
1216 * going all the way down to the notebook. I suspect a bug in | |
1217 * GtkTextView, but I'm not ready to point any fingers yet. | |
1218 */ | |
1219 static gboolean | |
1220 entry_stop_rclick_cb(GtkWidget *widget, GdkEventButton *event, gpointer data) | |
1221 { | |
1222 if (event->button == 3 && event->type == GDK_BUTTON_PRESS) { | |
1223 /* Right single click */ | |
1224 g_signal_stop_emission_by_name(G_OBJECT(widget), "button_press_event"); | |
1225 | |
1226 return TRUE; | |
1227 } | |
1228 | |
1229 return FALSE; | |
1230 } | |
1231 | |
1232 static void | |
4673 | 1233 menu_conv_sel_send_cb(GObject *m, gpointer data) |
4359 | 1234 { |
1235 struct gaim_window *win = g_object_get_data(m, "user_data"); | |
4673 | 1236 struct gaim_account *account = g_object_get_data(m, "gaim_account"); |
4359 | 1237 struct gaim_conversation *conv; |
1238 | |
1239 conv = gaim_window_get_active_conversation(win); | |
1240 | |
4491 | 1241 gaim_conversation_set_account(conv, account); |
4359 | 1242 } |
1243 | |
1244 static void | |
1245 insert_text_cb(GtkTextBuffer *textbuffer, GtkTextIter *position, | |
1246 gchar *new_text, gint new_text_length, gpointer user_data) | |
1247 { | |
1248 struct gaim_conversation *conv = (struct gaim_conversation *)user_data; | |
1249 | |
1250 if (conv == NULL) | |
1251 return; | |
1252 | |
1253 if (misc_options & OPT_MISC_STEALTH_TYPING) | |
1254 return; | |
1255 | |
1256 got_typing_keypress(conv, (gtk_text_iter_is_start(position) && | |
1257 gtk_text_iter_is_end(position))); | |
1258 } | |
1259 | |
1260 static void | |
1261 delete_text_cb(GtkTextBuffer *textbuffer, GtkTextIter *start_pos, | |
1262 GtkTextIter *end_pos, gpointer user_data) | |
1263 { | |
1264 struct gaim_conversation *conv = (struct gaim_conversation *)user_data; | |
1265 struct gaim_im *im; | |
1266 | |
1267 if (conv == NULL) | |
1268 return; | |
1269 | |
1270 if (misc_options & OPT_MISC_STEALTH_TYPING) | |
1271 return; | |
1272 | |
1273 im = GAIM_IM(conv); | |
1274 | |
1275 if (gtk_text_iter_is_start(start_pos) && gtk_text_iter_is_end(end_pos)) { | |
1276 | |
1277 /* We deleted all the text, so turn off typing. */ | |
1278 if (gaim_im_get_type_again_timeout(im)) | |
1279 gaim_im_stop_type_again_timeout(im); | |
1280 | |
1281 /* XXX The (char *) should go away! Somebody add consts to stuff! */ | |
1282 serv_send_typing(gaim_conversation_get_gc(conv), | |
1283 (char *)gaim_conversation_get_name(conv), | |
1284 NOT_TYPING); | |
1285 } | |
1286 else { | |
1287 /* We're deleting, but not all of it, so it counts as typing. */ | |
1288 got_typing_keypress(conv, FALSE); | |
1289 } | |
1290 } | |
1291 | |
1292 static void | |
1293 notebook_init_grab(struct gaim_gtk_window *gtkwin, GtkWidget *widget) | |
1294 { | |
1295 static GdkCursor *cursor = NULL; | |
1296 | |
1297 gtkwin->in_drag = TRUE; | |
1298 | |
1299 if (gtkwin->drag_leave_signal) { | |
1300 g_signal_handler_disconnect(G_OBJECT(widget), | |
1301 gtkwin->drag_leave_signal); | |
1302 | |
1303 gtkwin->drag_leave_signal = 0; | |
1304 } | |
1305 | |
1306 if (cursor == NULL) | |
1307 cursor = gdk_cursor_new(GDK_FLEUR); | |
1308 | |
1309 /* Grab the pointer */ | |
1310 gtk_grab_add(gtkwin->notebook); | |
4803
6f04901ef729
[gaim-migrate @ 5123]
Christian Hammond <chipx86@chipx86.com>
parents:
4793
diff
changeset
|
1311 |
6f04901ef729
[gaim-migrate @ 5123]
Christian Hammond <chipx86@chipx86.com>
parents:
4793
diff
changeset
|
1312 if (!gdk_pointer_is_grabbed()) |
6f04901ef729
[gaim-migrate @ 5123]
Christian Hammond <chipx86@chipx86.com>
parents:
4793
diff
changeset
|
1313 gdk_pointer_grab(gtkwin->notebook->window, FALSE, |
6f04901ef729
[gaim-migrate @ 5123]
Christian Hammond <chipx86@chipx86.com>
parents:
4793
diff
changeset
|
1314 GDK_BUTTON1_MOTION_MASK | GDK_BUTTON_RELEASE_MASK, |
6f04901ef729
[gaim-migrate @ 5123]
Christian Hammond <chipx86@chipx86.com>
parents:
4793
diff
changeset
|
1315 NULL, cursor, GDK_CURRENT_TIME); |
4359 | 1316 } |
1317 | |
1318 static gboolean | |
1319 notebook_motion_cb(GtkWidget *widget, GdkEventButton *e, | |
1320 struct gaim_window *win) | |
1321 { | |
1322 struct gaim_gtk_window *gtkwin; | |
1323 | |
1324 gtkwin = GAIM_GTK_WINDOW(win); | |
1325 | |
1326 /* | |
1327 * Make sure the user moved the mouse far enough for the | |
1328 * drag to be initiated. | |
1329 */ | |
1330 if (gtkwin->in_predrag) { | |
1331 if (e->x_root < gtkwin->drag_min_x || | |
1332 e->x_root >= gtkwin->drag_max_x || | |
1333 e->y_root < gtkwin->drag_min_y || | |
1334 e->y_root >= gtkwin->drag_max_y) { | |
1335 | |
1336 gtkwin->in_predrag = FALSE; | |
1337 notebook_init_grab(gtkwin, widget); | |
1338 } | |
1339 } | |
1340 else { /* Otherwise, draw the arrows. */ | |
1341 struct gaim_window *dest_win; | |
1342 struct gaim_gtk_window *dest_gtkwin; | |
1343 GtkNotebook *dest_notebook; | |
1344 GtkWidget *tab, *last_vis_tab = NULL; | |
1345 gint nb_x, nb_y, page_num, i, last_vis_tab_loc = -1; | |
1346 gint arrow1_x, arrow1_y, arrow2_x, arrow2_y; | |
1347 gboolean horiz_tabs = FALSE, tab_found = FALSE; | |
1348 GList *l; | |
1349 | |
1350 /* Get the window that the cursor is over. */ | |
1351 dest_win = gaim_gtkwin_get_at_xy(e->x_root, e->y_root); | |
1352 | |
1353 if (dest_win == NULL) { | |
1354 dnd_hints_hide_all(); | |
1355 | |
1356 return TRUE; | |
1357 } | |
1358 | |
1359 dest_gtkwin = GAIM_GTK_WINDOW(dest_win); | |
1360 | |
1361 dest_notebook = GTK_NOTEBOOK(dest_gtkwin->notebook); | |
1362 | |
1363 gdk_window_get_origin(GTK_WIDGET(dest_notebook)->window, &nb_x, &nb_y); | |
1364 | |
1365 arrow1_x = arrow2_x = nb_x; | |
1366 arrow1_y = arrow2_y = nb_y; | |
1367 | |
1368 page_num = gaim_gtkconv_get_dest_tab_at_xy(dest_win, | |
1369 e->x_root, e->y_root); | |
1370 | |
1371 if (gtk_notebook_get_tab_pos(dest_notebook) == GTK_POS_TOP || | |
1372 gtk_notebook_get_tab_pos(dest_notebook) == GTK_POS_BOTTOM) { | |
1373 | |
1374 horiz_tabs = TRUE; | |
1375 } | |
1376 | |
1377 /* Find out where to put the arrows. */ | |
1378 for (l = gaim_window_get_conversations(dest_win), i = 0; | |
1379 l != NULL; | |
1380 l = l->next, i++) { | |
1381 | |
1382 struct gaim_conversation *conv = l->data; | |
1383 | |
1384 tab = GAIM_GTK_CONVERSATION(conv)->tabby; | |
1385 | |
1386 /* | |
1387 * If this is the correct tab, record the positions | |
1388 * for the arrows. | |
1389 */ | |
1390 if (i == page_num) { | |
1391 if (horiz_tabs) { | |
1392 arrow1_x = arrow2_x = nb_x + tab->allocation.x; | |
1393 arrow1_y = nb_y + tab->allocation.y; | |
1394 arrow2_y = nb_y + tab->allocation.y + | |
1395 tab->allocation.height; | |
1396 } | |
1397 else { | |
1398 arrow1_x = nb_x + tab->allocation.x; | |
1399 arrow2_x = nb_x + tab->allocation.x + | |
1400 tab->allocation.width; | |
1401 arrow1_y = arrow2_y = nb_y + tab->allocation.y; | |
1402 } | |
1403 | |
1404 tab_found = TRUE; | |
1405 break; | |
1406 } | |
1407 else { /* Keep track of the right-most tab that we see. */ | |
1408 if (horiz_tabs && tab->allocation.x > last_vis_tab_loc) { | |
1409 last_vis_tab = tab; | |
1410 last_vis_tab_loc = tab->allocation.x; | |
1411 } | |
1412 else if (!horiz_tabs && tab->allocation.y > last_vis_tab_loc) { | |
1413 last_vis_tab = tab; | |
1414 last_vis_tab_loc = tab->allocation.y; | |
1415 } | |
1416 } | |
1417 } | |
1418 | |
1419 /* | |
1420 * If we didn't find the tab, then we'll just place the | |
1421 * arrows to the right/bottom of the last visible tab. | |
1422 */ | |
1423 if (!tab_found && last_vis_tab) { | |
1424 if (horiz_tabs) { | |
1425 arrow1_x = arrow2_x = nb_x + last_vis_tab->allocation.x + | |
1426 last_vis_tab->allocation.width; | |
1427 arrow1_y = nb_y + last_vis_tab->allocation.y; | |
1428 arrow2_y = nb_y + last_vis_tab->allocation.y + | |
1429 last_vis_tab->allocation.height; | |
1430 } | |
1431 else { | |
1432 arrow1_x = nb_x + last_vis_tab->allocation.x; | |
1433 arrow2_x = nb_x + last_vis_tab->allocation.x + | |
1434 last_vis_tab->allocation.width; | |
1435 arrow1_y = arrow2_y = nb_y + last_vis_tab->allocation.y + | |
1436 last_vis_tab->allocation.height; | |
1437 } | |
1438 } | |
1439 | |
1440 if (horiz_tabs) { | |
1441 dnd_hints_show(HINT_ARROW_DOWN, arrow1_x, arrow1_y); | |
1442 dnd_hints_show(HINT_ARROW_UP, arrow2_x, arrow2_y); | |
1443 } | |
1444 else { | |
1445 dnd_hints_show(HINT_ARROW_RIGHT, arrow1_x, arrow1_y); | |
1446 dnd_hints_show(HINT_ARROW_LEFT, arrow2_x, arrow2_y); | |
1447 } | |
1448 } | |
1449 | |
1450 return TRUE; | |
1451 } | |
1452 | |
1453 static gboolean | |
1454 notebook_leave_cb(GtkWidget *widget, GdkEventCrossing *e, | |
1455 struct gaim_window *win) | |
1456 { | |
1457 struct gaim_gtk_window *gtkwin; | |
1458 | |
1459 gtkwin = GAIM_GTK_WINDOW(win); | |
1460 | |
1461 if (gtkwin->in_drag) | |
1462 return FALSE; | |
1463 | |
1464 if (e->x_root < gtkwin->drag_min_x || | |
1465 e->x_root >= gtkwin->drag_max_x || | |
1466 e->y_root < gtkwin->drag_min_y || | |
1467 e->y_root >= gtkwin->drag_max_y) { | |
1468 | |
1469 gtkwin->in_predrag = FALSE; | |
1470 notebook_init_grab(gtkwin, widget); | |
1471 } | |
1472 | |
1473 return TRUE; | |
1474 } | |
1475 | |
1476 /* | |
1477 * THANK YOU GALEON! | |
1478 */ | |
1479 static gboolean | |
1480 notebook_press_cb(GtkWidget *widget, GdkEventButton *e, | |
1481 struct gaim_window *win) | |
1482 { | |
1483 struct gaim_gtk_window *gtkwin; | |
1484 gint nb_x, nb_y, x_rel, y_rel; | |
1485 GList *l; | |
1486 int tab_clicked; | |
1487 | |
1488 if (e->button != 1 || e->type != GDK_BUTTON_PRESS) | |
1489 return FALSE; | |
1490 | |
1491 gtkwin = GAIM_GTK_WINDOW(win); | |
1492 | |
1493 if (gtkwin->in_drag) { | |
1494 debug_printf("Already in the middle of a window " | |
4803
6f04901ef729
[gaim-migrate @ 5123]
Christian Hammond <chipx86@chipx86.com>
parents:
4793
diff
changeset
|
1495 "drag at tab_press_cb\n"); |
6f04901ef729
[gaim-migrate @ 5123]
Christian Hammond <chipx86@chipx86.com>
parents:
4793
diff
changeset
|
1496 return TRUE; |
4359 | 1497 } |
1498 | |
1499 /* | |
1500 * Make sure a tab was actually clicked. The arrow buttons | |
1501 * mess things up. | |
1502 */ | |
1503 tab_clicked = gaim_gtkconv_get_tab_at_xy(win, e->x_root, e->y_root); | |
1504 | |
1505 if (tab_clicked == -1) | |
1506 return FALSE; | |
1507 | |
1508 /* | |
1509 * Get the relative position of the press event, with regards to | |
1510 * the position of the notebook. | |
1511 */ | |
1512 gdk_window_get_origin(gtkwin->notebook->window, &nb_x, &nb_y); | |
1513 | |
1514 x_rel = e->x_root - nb_x; | |
1515 y_rel = e->y_root - nb_y; | |
1516 | |
1517 /* Reset the min/max x/y */ | |
1518 gtkwin->drag_min_x = 0; | |
1519 gtkwin->drag_min_y = 0; | |
1520 gtkwin->drag_max_x = 0; | |
1521 gtkwin->drag_max_y = 0; | |
1522 | |
1523 /* Find out which tab was dragged. */ | |
1524 for (l = gaim_window_get_conversations(win); l != NULL; l = l->next) { | |
1525 struct gaim_conversation *conv = l->data; | |
1526 GtkWidget *tab = GAIM_GTK_CONVERSATION(conv)->tabby; | |
1527 | |
1528 if (!GTK_WIDGET_VISIBLE(tab)) | |
1529 continue; | |
1530 | |
1531 if (tab->allocation.x > x_rel || tab->allocation.y > y_rel) | |
1532 break; | |
1533 | |
1534 /* Save the borders of the tab. */ | |
1535 gtkwin->drag_min_x = tab->allocation.x + nb_x; | |
1536 gtkwin->drag_min_y = tab->allocation.y + nb_y; | |
1537 gtkwin->drag_max_x = tab->allocation.width + gtkwin->drag_min_x; | |
1538 gtkwin->drag_max_y = tab->allocation.height + gtkwin->drag_min_y; | |
1539 } | |
1540 | |
1541 /* Make sure the click occurred in the tab. */ | |
1542 if (e->x_root < gtkwin->drag_min_x || | |
1543 e->x_root >= gtkwin->drag_max_x || | |
1544 e->y_root < gtkwin->drag_min_y || | |
1545 e->y_root >= gtkwin->drag_max_y) { | |
1546 | |
1547 return FALSE; | |
1548 } | |
1549 | |
1550 gtkwin->in_predrag = TRUE; | |
1551 | |
1552 /* Connect the new motion signals. */ | |
1553 gtkwin->drag_motion_signal = | |
1554 g_signal_connect(G_OBJECT(widget), "motion_notify_event", | |
1555 G_CALLBACK(notebook_motion_cb), win); | |
1556 | |
1557 gtkwin->drag_leave_signal = | |
1558 g_signal_connect(G_OBJECT(widget), "leave_notify_event", | |
1559 G_CALLBACK(notebook_leave_cb), win); | |
1560 | |
1561 return FALSE; | |
1562 } | |
1563 | |
1564 static gboolean | |
1565 notebook_release_cb(GtkWidget *widget, GdkEventButton *e, | |
1566 struct gaim_window *win) | |
1567 { | |
1568 struct gaim_window *dest_win; | |
1569 struct gaim_gtk_window *gtkwin; | |
1570 struct gaim_gtk_window *dest_gtkwin; | |
1571 struct gaim_conversation *conv; | |
1572 GtkNotebook *dest_notebook; | |
1573 gint dest_page_num; | |
1574 | |
1575 /* | |
1576 * Don't check to make sure that the event's window matches the | |
1577 * widget's, because we may be getting an event passed on from the | |
1578 * close button. | |
1579 */ | |
1580 if (e->button != 1 && e->type != GDK_BUTTON_RELEASE) | |
1581 return FALSE; | |
1582 | |
1583 if (gdk_pointer_is_grabbed()) { | |
1584 gdk_pointer_ungrab(GDK_CURRENT_TIME); | |
1585 gtk_grab_remove(widget); | |
1586 } | |
1587 | |
1588 gtkwin = GAIM_GTK_WINDOW(win); | |
1589 | |
4803
6f04901ef729
[gaim-migrate @ 5123]
Christian Hammond <chipx86@chipx86.com>
parents:
4793
diff
changeset
|
1590 if (!gtkwin->in_predrag && !gtkwin->in_drag) |
6f04901ef729
[gaim-migrate @ 5123]
Christian Hammond <chipx86@chipx86.com>
parents:
4793
diff
changeset
|
1591 return FALSE; |
4359 | 1592 |
1593 /* Disconnect the motion signal. */ | |
1594 if (gtkwin->drag_motion_signal) { | |
1595 g_signal_handler_disconnect(G_OBJECT(widget), | |
1596 gtkwin->drag_motion_signal); | |
1597 | |
1598 gtkwin->drag_motion_signal = 0; | |
1599 } | |
1600 | |
1601 /* | |
1602 * If we're in a pre-drag, we'll also need to disconnect the leave | |
1603 * signal. | |
1604 */ | |
1605 if (gtkwin->in_predrag) { | |
1606 gtkwin->in_predrag = FALSE; | |
1607 | |
1608 if (gtkwin->drag_leave_signal) { | |
1609 g_signal_handler_disconnect(G_OBJECT(widget), | |
1610 gtkwin->drag_leave_signal); | |
1611 | |
1612 gtkwin->drag_leave_signal = 0; | |
1613 } | |
1614 } | |
1615 | |
1616 /* If we're not in drag... */ | |
1617 /* We're perfectly normal people! */ | |
4803
6f04901ef729
[gaim-migrate @ 5123]
Christian Hammond <chipx86@chipx86.com>
parents:
4793
diff
changeset
|
1618 if (!gtkwin->in_drag) |
4359 | 1619 return FALSE; |
1620 | |
1621 gtkwin->in_drag = FALSE; | |
1622 | |
1623 dnd_hints_hide_all(); | |
1624 | |
4369
7e1fb422e5fd
[gaim-migrate @ 4635]
Christian Hammond <chipx86@chipx86.com>
parents:
4368
diff
changeset
|
1625 dest_win = gaim_gtkwin_get_at_xy(e->x_root, e->y_root); |
4359 | 1626 |
1627 conv = gaim_window_get_active_conversation(win); | |
1628 | |
1629 if (dest_win == NULL) { | |
1630 if (gaim_window_get_conversation_count(win) < 2) | |
1631 return FALSE; | |
1632 | |
1633 if (gaim_window_get_conversation_count(win) > 1) { | |
1634 /* Make a new window to stick this to. */ | |
1635 struct gaim_window *new_win; | |
4748
d3c09ddfd3aa
[gaim-migrate @ 5063]
Christian Hammond <chipx86@chipx86.com>
parents:
4736
diff
changeset
|
1636 struct gaim_gtk_window *new_gtkwin; |
d3c09ddfd3aa
[gaim-migrate @ 5063]
Christian Hammond <chipx86@chipx86.com>
parents:
4736
diff
changeset
|
1637 gint win_width, win_height; |
4359 | 1638 |
1639 new_win = gaim_window_new(); | |
1640 gaim_window_remove_conversation(win, | |
1641 gaim_conversation_get_index(conv)); | |
1642 gaim_window_add_conversation(new_win, conv); | |
4748
d3c09ddfd3aa
[gaim-migrate @ 5063]
Christian Hammond <chipx86@chipx86.com>
parents:
4736
diff
changeset
|
1643 |
d3c09ddfd3aa
[gaim-migrate @ 5063]
Christian Hammond <chipx86@chipx86.com>
parents:
4736
diff
changeset
|
1644 new_gtkwin = GAIM_GTK_WINDOW(new_win); |
d3c09ddfd3aa
[gaim-migrate @ 5063]
Christian Hammond <chipx86@chipx86.com>
parents:
4736
diff
changeset
|
1645 |
d3c09ddfd3aa
[gaim-migrate @ 5063]
Christian Hammond <chipx86@chipx86.com>
parents:
4736
diff
changeset
|
1646 gtk_window_get_size(GTK_WINDOW(new_gtkwin->window), |
d3c09ddfd3aa
[gaim-migrate @ 5063]
Christian Hammond <chipx86@chipx86.com>
parents:
4736
diff
changeset
|
1647 &win_width, &win_height); |
d3c09ddfd3aa
[gaim-migrate @ 5063]
Christian Hammond <chipx86@chipx86.com>
parents:
4736
diff
changeset
|
1648 |
d3c09ddfd3aa
[gaim-migrate @ 5063]
Christian Hammond <chipx86@chipx86.com>
parents:
4736
diff
changeset
|
1649 gtk_window_move(GTK_WINDOW(new_gtkwin->window), |
d3c09ddfd3aa
[gaim-migrate @ 5063]
Christian Hammond <chipx86@chipx86.com>
parents:
4736
diff
changeset
|
1650 e->x_root - (win_width / 2), |
d3c09ddfd3aa
[gaim-migrate @ 5063]
Christian Hammond <chipx86@chipx86.com>
parents:
4736
diff
changeset
|
1651 e->y_root - (win_height / 2)); |
d3c09ddfd3aa
[gaim-migrate @ 5063]
Christian Hammond <chipx86@chipx86.com>
parents:
4736
diff
changeset
|
1652 |
4359 | 1653 gaim_window_show(new_win); |
1654 } | |
1655 | |
1656 return TRUE; | |
1657 } | |
1658 | |
4369
7e1fb422e5fd
[gaim-migrate @ 4635]
Christian Hammond <chipx86@chipx86.com>
parents:
4368
diff
changeset
|
1659 dest_gtkwin = GAIM_GTK_WINDOW(dest_win); |
7e1fb422e5fd
[gaim-migrate @ 4635]
Christian Hammond <chipx86@chipx86.com>
parents:
4368
diff
changeset
|
1660 |
4359 | 1661 /* Get the destination notebook. */ |
1662 dest_notebook = GTK_NOTEBOOK(gtkwin->notebook); | |
1663 | |
1664 /* Get the destination page number. */ | |
1665 dest_page_num = gaim_gtkconv_get_dest_tab_at_xy(dest_win, | |
1666 e->x_root, e->y_root); | |
1667 | |
1668 if (win == dest_win) { | |
1669 gaim_window_move_conversation(win, | |
1670 gaim_conversation_get_index(conv), dest_page_num); | |
1671 } | |
1672 else { | |
1673 size_t pos; | |
1674 | |
1675 gaim_window_remove_conversation(win, | |
1676 gaim_conversation_get_index(conv)); | |
1677 | |
1678 pos = gaim_window_add_conversation(dest_win, conv); | |
1679 | |
1680 gaim_window_move_conversation(dest_win, pos, dest_page_num); | |
1681 | |
1682 gaim_window_switch_conversation(dest_win, dest_page_num); | |
1683 } | |
1684 | |
1685 gtk_widget_grab_focus(GAIM_GTK_CONVERSATION(conv)->entry); | |
1686 | |
1687 return TRUE; | |
1688 } | |
1689 | |
1690 static void | |
1691 switch_conv_cb(GtkNotebook *notebook, GtkWidget *page, gint page_num, | |
1692 gpointer user_data) | |
1693 { | |
1694 struct gaim_window *win; | |
1695 struct gaim_conversation *conv; | |
1696 struct gaim_gtk_conversation *gtkconv; | |
1697 struct gaim_gtk_window *gtkwin; | |
1698 struct gaim_connection *gc; | |
1699 | |
1700 win = (struct gaim_window *)user_data; | |
1701 | |
4598
a064e437d5eb
[gaim-migrate @ 4883]
Christian Hammond <chipx86@chipx86.com>
parents:
4596
diff
changeset
|
1702 conv = gaim_window_get_conversation_at(win, page_num); |
a064e437d5eb
[gaim-migrate @ 4883]
Christian Hammond <chipx86@chipx86.com>
parents:
4596
diff
changeset
|
1703 |
a064e437d5eb
[gaim-migrate @ 4883]
Christian Hammond <chipx86@chipx86.com>
parents:
4596
diff
changeset
|
1704 if (conv == NULL) |
a064e437d5eb
[gaim-migrate @ 4883]
Christian Hammond <chipx86@chipx86.com>
parents:
4596
diff
changeset
|
1705 return; |
a064e437d5eb
[gaim-migrate @ 4883]
Christian Hammond <chipx86@chipx86.com>
parents:
4596
diff
changeset
|
1706 |
4359 | 1707 gc = gaim_conversation_get_gc(conv); |
1708 gtkwin = GAIM_GTK_WINDOW(win); | |
1709 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
1710 | |
1711 gaim_conversation_set_unseen(conv, GAIM_UNSEEN_NONE); | |
1712 | |
4364
fa56829b9587
[gaim-migrate @ 4630]
Christian Hammond <chipx86@chipx86.com>
parents:
4363
diff
changeset
|
1713 if (gc != NULL) { |
fa56829b9587
[gaim-migrate @ 4630]
Christian Hammond <chipx86@chipx86.com>
parents:
4363
diff
changeset
|
1714 gtk_widget_set_sensitive(gtkwin->menu.insert_link, TRUE); |
fa56829b9587
[gaim-migrate @ 4630]
Christian Hammond <chipx86@chipx86.com>
parents:
4363
diff
changeset
|
1715 } |
fa56829b9587
[gaim-migrate @ 4630]
Christian Hammond <chipx86@chipx86.com>
parents:
4363
diff
changeset
|
1716 |
4359 | 1717 /* Update the menubar */ |
1718 if (gaim_conversation_get_type(conv) == GAIM_CONV_IM) { | |
1719 gtk_widget_set_sensitive(gtkwin->menu.view_history, TRUE); | |
1720 gtk_widget_set_sensitive(gtkwin->menu.insert_image, | |
1721 (gc && gc->prpl->options & OPT_PROTO_IM_IMAGE)); | |
1722 | |
1723 if (gtkwin->menu.send_as != NULL) | |
4685 | 1724 g_timeout_add(0, (GSourceFunc)update_send_as_selection, win); |
4359 | 1725 } |
1726 else { | |
1727 gtk_widget_set_sensitive(gtkwin->menu.view_history, FALSE); | |
1728 gtk_widget_set_sensitive(gtkwin->menu.insert_image, FALSE); | |
1729 | |
1730 if (gtkwin->menu.send_as != NULL) | |
1731 gtk_widget_hide(gtkwin->menu.send_as); | |
1732 } | |
1733 | |
4736 | 1734 update_typing_icon(conv); |
1735 | |
4359 | 1736 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(gtkwin->menu.logging), |
1737 gaim_conversation_is_logging(conv)); | |
1738 | |
1739 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(gtkwin->menu.sounds), | |
1740 gtkconv->make_sound); | |
1741 | |
1742 gtk_widget_grab_focus(gtkconv->entry); | |
4681 | 1743 |
4965 | 1744 gtk_window_set_title(GTK_WINDOW(gtkwin->window), |
1745 gtk_label_get_text(GTK_LABEL(gtkconv->tab_label))); | |
4359 | 1746 } |
1747 | |
1748 /************************************************************************** | |
1749 * Utility functions | |
1750 **************************************************************************/ | |
1751 static void | |
1752 do_bold(GtkWidget *bold, struct gaim_gtk_conversation *gtkconv) | |
1753 { | |
1754 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(bold))) | |
1755 gaim_gtk_surround(gtkconv, "<B>", "</B>"); | |
1756 else | |
1757 gaim_gtk_advance_past(gtkconv, "<B>", "</B>"); | |
1758 | |
1759 gtk_widget_grab_focus(gtkconv->entry); | |
1760 } | |
1761 | |
1762 static void | |
1763 do_italic(GtkWidget *italic, struct gaim_gtk_conversation *gtkconv) | |
1764 { | |
1765 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(italic))) | |
1766 gaim_gtk_surround(gtkconv, "<I>", "</I>"); | |
1767 else | |
1768 gaim_gtk_advance_past(gtkconv, "<I>", "</I>"); | |
1769 | |
1770 gtk_widget_grab_focus(gtkconv->entry); | |
1771 } | |
1772 | |
1773 static void | |
1774 do_underline(GtkWidget *underline, struct gaim_gtk_conversation *gtkconv) | |
1775 { | |
1776 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(underline))) | |
1777 gaim_gtk_surround(gtkconv, "<U>", "</U>"); | |
1778 else | |
1779 gaim_gtk_advance_past(gtkconv, "<U>", "</U>"); | |
1780 | |
1781 gtk_widget_grab_focus(gtkconv->entry); | |
1782 } | |
1783 | |
1784 static void | |
1785 do_small(GtkWidget *small, struct gaim_gtk_conversation *gtkconv) | |
1786 { | |
1787 gaim_gtk_surround(gtkconv, "<FONT SIZE=\"1\">", "</FONT>"); | |
1788 | |
1789 gtk_widget_grab_focus(gtkconv->entry); | |
1790 } | |
1791 | |
1792 static void | |
1793 do_normal(GtkWidget *small, struct gaim_gtk_conversation *gtkconv) | |
1794 { | |
1795 gaim_gtk_surround(gtkconv, "<FONT SIZE=\"3\">", "</FONT>"); | |
1796 | |
1797 gtk_widget_grab_focus(gtkconv->entry); | |
1798 } | |
1799 | |
1800 static void | |
1801 do_big(GtkWidget *small, struct gaim_gtk_conversation *gtkconv) | |
1802 { | |
1803 gaim_gtk_surround(gtkconv, "<FONT SIZE=\"5\">", "</FONT>"); | |
1804 | |
1805 gtk_widget_grab_focus(gtkconv->entry); | |
1806 } | |
1807 | |
1808 static void | |
1809 toggle_font(GtkWidget *font, struct gaim_conversation *conv) | |
1810 { | |
1811 struct gaim_gtk_conversation *gtkconv; | |
1812 | |
1813 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
1814 | |
1815 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(font))) | |
1816 show_font_dialog(conv, font); | |
1817 else if (gtkconv->dialogs.fg_color != NULL) | |
1818 cancel_font(font, conv); | |
1819 else | |
1820 gaim_gtk_advance_past(gtkconv, "<FONT FACE>", "</FONT>"); | |
1821 } | |
1822 | |
1823 static void | |
1824 toggle_fg_color(GtkWidget *color, struct gaim_conversation *conv) | |
1825 { | |
1826 struct gaim_gtk_conversation *gtkconv; | |
1827 | |
1828 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
1829 | |
1830 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(color))) | |
1831 show_fgcolor_dialog(conv, color); | |
1832 else if (gtkconv->dialogs.fg_color != NULL) | |
1833 cancel_fgcolor(color, conv); | |
1834 else | |
1835 gaim_gtk_advance_past(gtkconv, "<FONT COLOR>", "</FONT>"); | |
1836 } | |
1837 | |
1838 static void | |
1839 toggle_bg_color(GtkWidget *color, struct gaim_conversation *conv) | |
1840 { | |
1841 struct gaim_gtk_conversation *gtkconv; | |
1842 | |
1843 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
1844 | |
1845 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(color))) | |
1846 show_bgcolor_dialog(conv, color); | |
1847 else if (gtkconv->dialogs.bg_color != NULL) | |
1848 cancel_bgcolor(color, conv); | |
1849 else | |
1850 gaim_gtk_advance_past(gtkconv, "<BODY BGCOLOR>", "</BODY>"); | |
1851 } | |
1852 | |
1853 static void | |
1854 check_everything(GtkTextBuffer *buffer) | |
1855 { | |
1856 struct gaim_conversation *conv; | |
1857 struct gaim_gtk_conversation *gtkconv; | |
1858 | |
1859 conv = (struct gaim_conversation *)g_object_get_data(G_OBJECT(buffer), | |
1860 "user_data"); | |
1861 | |
1862 if (conv == NULL) | |
1863 return; | |
1864 | |
1865 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
1866 | |
1867 /* CONV TODO */ | |
1868 } | |
1869 | |
1870 static void | |
4685 | 1871 set_toggle(GtkWidget *tb, gboolean active) |
4359 | 1872 { |
1873 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(tb), active); | |
1874 } | |
1875 | |
1876 static void | |
1877 got_typing_keypress(struct gaim_conversation *conv, gboolean first) | |
1878 { | |
1879 struct gaim_im *im; | |
4685 | 1880 |
4359 | 1881 /* |
1882 * We know we got something, so we at least have to make sure we don't | |
1883 * send TYPED any time soon. | |
1884 */ | |
1885 | |
1886 im = GAIM_IM(conv); | |
1887 | |
1888 if (gaim_im_get_type_again_timeout(im)) | |
1889 gaim_im_stop_type_again_timeout(im); | |
1890 | |
1891 gaim_im_start_type_again_timeout(im); | |
1892 | |
1893 if (first || (gaim_im_get_type_again(im) != 0 && | |
1894 time(NULL) > gaim_im_get_type_again(im))) { | |
1895 | |
1896 int timeout = serv_send_typing(gaim_conversation_get_gc(conv), | |
1897 (char *)gaim_conversation_get_name(conv), | |
1898 TYPING); | |
1899 | |
1900 if (timeout) | |
1901 gaim_im_set_type_again(im, time(NULL) + timeout); | |
1902 else | |
1903 gaim_im_set_type_again(im, 0); | |
1904 } | |
1905 } | |
1906 | |
4736 | 1907 static void |
1908 update_typing_icon(struct gaim_conversation *conv) | |
1909 { | |
1910 struct gaim_gtk_window *gtkwin; | |
1911 struct gaim_im *im = NULL; | |
4757 | 1912 struct gaim_gtk_conversation *gtkconv = GAIM_GTK_CONVERSATION(conv); |
4736 | 1913 |
1914 gtkwin = GAIM_GTK_WINDOW(gaim_conversation_get_window(conv)); | |
1915 | |
1916 if(gaim_conversation_get_type(conv) == GAIM_CONV_IM) | |
1917 im = GAIM_IM(conv); | |
1918 | |
1919 if(gtkwin->menu.typing_icon) { | |
1920 gtk_widget_destroy(gtkwin->menu.typing_icon); | |
1921 gtkwin->menu.typing_icon = NULL; | |
1922 } | |
1923 if(im && gaim_im_get_typing_state(im) == TYPING) { | |
1924 gtkwin->menu.typing_icon = gtk_image_menu_item_new(); | |
1925 gtk_image_menu_item_set_image( | |
1926 GTK_IMAGE_MENU_ITEM(gtkwin->menu.typing_icon), | |
1927 gtk_image_new_from_stock(GAIM_STOCK_TYPING, | |
1928 GTK_ICON_SIZE_MENU)); | |
4757 | 1929 gtk_tooltips_set_tip(gtkconv->tooltips, gtkwin->menu.typing_icon, |
4736 | 1930 _("User is typing..."), NULL); |
1931 } else if(im && gaim_im_get_typing_state(im) == TYPED) { | |
1932 gtkwin->menu.typing_icon = gtk_image_menu_item_new(); | |
1933 gtk_image_menu_item_set_image( | |
1934 GTK_IMAGE_MENU_ITEM(gtkwin->menu.typing_icon), | |
1935 gtk_image_new_from_stock(GAIM_STOCK_TYPED, | |
1936 GTK_ICON_SIZE_MENU)); | |
4757 | 1937 gtk_tooltips_set_tip(gtkconv->tooltips, gtkwin->menu.typing_icon, |
4736 | 1938 _("User has typed something and paused"), NULL); |
1939 } | |
1940 | |
1941 if(gtkwin->menu.typing_icon) { | |
1942 gtk_menu_item_set_right_justified( | |
1943 GTK_MENU_ITEM(gtkwin->menu.typing_icon), TRUE); | |
1944 gtk_widget_show_all(gtkwin->menu.typing_icon); | |
1945 gtk_menu_shell_append(GTK_MENU_SHELL(gtkwin->menu.menubar), | |
1946 gtkwin->menu.typing_icon); | |
1947 } | |
1948 } | |
1949 | |
4685 | 1950 static gboolean |
4359 | 1951 update_send_as_selection(struct gaim_window *win) |
1952 { | |
4491 | 1953 struct gaim_account *account; |
4359 | 1954 struct gaim_conversation *conv; |
1955 struct gaim_gtk_window *gtkwin; | |
1956 GtkWidget *menu; | |
1957 GList *child; | |
1958 | |
4849 | 1959 if (g_list_find(gaim_get_windows(), win) == NULL) |
1960 return FALSE; | |
1961 | |
4359 | 1962 conv = gaim_window_get_active_conversation(win); |
1963 | |
4786 | 1964 |
4359 | 1965 if (conv == NULL) |
4685 | 1966 return FALSE; |
4359 | 1967 |
4491 | 1968 account = gaim_conversation_get_account(conv); |
4359 | 1969 gtkwin = GAIM_GTK_WINDOW(win); |
1970 | |
4491 | 1971 if (account == NULL) |
4685 | 1972 return FALSE; |
4466
473de7371a97
[gaim-migrate @ 4741]
Christian Hammond <chipx86@chipx86.com>
parents:
4465
diff
changeset
|
1973 |
4364
fa56829b9587
[gaim-migrate @ 4630]
Christian Hammond <chipx86@chipx86.com>
parents:
4363
diff
changeset
|
1974 if (gtkwin->menu.send_as == NULL) |
4685 | 1975 return FALSE; |
4364
fa56829b9587
[gaim-migrate @ 4630]
Christian Hammond <chipx86@chipx86.com>
parents:
4363
diff
changeset
|
1976 |
4359 | 1977 gtk_widget_show(gtkwin->menu.send_as); |
1978 | |
1979 menu = gtk_menu_item_get_submenu( | |
1980 GTK_MENU_ITEM(gtkwin->menu.send_as)); | |
1981 | |
1982 for (child = gtk_container_get_children(GTK_CONTAINER(menu)); | |
1983 child != NULL; | |
1984 child = child->next) { | |
1985 | |
1986 GtkWidget *item = child->data; | |
4673 | 1987 struct gaim_account *item_account = g_object_get_data(G_OBJECT(item), |
1988 "gaim_account"); | |
1989 | |
1990 if (account == item_account) { | |
4359 | 1991 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(item), TRUE); |
1992 break; | |
1993 } | |
1994 } | |
4685 | 1995 return FALSE; |
4359 | 1996 } |
1997 | |
1998 static void | |
4360
c435a29370b8
[gaim-migrate @ 4626]
Christian Hammond <chipx86@chipx86.com>
parents:
4359
diff
changeset
|
1999 generate_send_as_items(struct gaim_window *win, |
c435a29370b8
[gaim-migrate @ 4626]
Christian Hammond <chipx86@chipx86.com>
parents:
4359
diff
changeset
|
2000 struct gaim_conversation *deleted_conv) |
4359 | 2001 { |
2002 struct gaim_gtk_window *gtkwin; | |
2003 GtkWidget *menu; | |
2004 GtkWidget *menuitem; | |
2005 GSList *gcs; | |
2006 GList *convs; | |
2007 GSList *group = NULL; | |
2008 gboolean first_offline = TRUE; | |
2009 gboolean found_online = FALSE; | |
4669
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2010 GtkSizeGroup *sg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL); |
4359 | 2011 |
2012 gtkwin = GAIM_GTK_WINDOW(win); | |
2013 | |
2014 if (gtkwin->menu.send_as != NULL) | |
2015 gtk_widget_destroy(gtkwin->menu.send_as); | |
2016 | |
2017 /* See if we have > 1 connection active. */ | |
2018 if (g_slist_length(connections) < 2) { | |
2019 /* Now make sure we don't have any Offline entries. */ | |
2020 gboolean found_offline = FALSE; | |
2021 | |
2022 for (convs = gaim_get_conversations(); | |
2023 convs != NULL; | |
2024 convs = convs->next) { | |
2025 | |
2026 struct gaim_conversation *conv; | |
4491 | 2027 struct gaim_account *account; |
2028 | |
4359 | 2029 conv = (struct gaim_conversation *)convs->data; |
4491 | 2030 account = gaim_conversation_get_account(conv); |
2031 | |
2032 if (account->gc == NULL) { | |
4359 | 2033 found_offline = TRUE; |
2034 break; | |
2035 } | |
2036 } | |
2037 | |
2038 if (!found_offline) { | |
2039 gtkwin->menu.send_as = NULL; | |
2040 return; | |
2041 } | |
2042 } | |
2043 | |
2044 /* Build the Send As menu */ | |
2045 gtkwin->menu.send_as = gtk_menu_item_new_with_mnemonic(_("_Send As")); | |
2046 gtk_widget_show(gtkwin->menu.send_as); | |
2047 | |
2048 menu = gtk_menu_new(); | |
2049 | |
2050 gtk_menu_shell_append(GTK_MENU_SHELL(gtkwin->menu.menubar), | |
2051 gtkwin->menu.send_as); | |
2052 gtk_menu_item_set_submenu(GTK_MENU_ITEM(gtkwin->menu.send_as), menu); | |
2053 | |
2054 gtk_widget_show(menu); | |
2055 | |
2056 /* Fill it with entries. */ | |
2057 for (gcs = connections; gcs != NULL; gcs = gcs->next) { | |
4668
6e7196dcfd37
[gaim-migrate @ 4979]
Christian Hammond <chipx86@chipx86.com>
parents:
4640
diff
changeset
|
2058 |
4359 | 2059 struct gaim_connection *gc; |
4669
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2060 GtkWidget *box; |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2061 GtkWidget *label; |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2062 GtkWidget *image; |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
2063 GdkPixbuf *pixbuf, *scale; |
4359 | 2064 |
2065 found_online = TRUE; | |
2066 | |
2067 gc = (struct gaim_connection *)gcs->data; | |
2068 | |
4669
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2069 /* Create a pixmap for the protocol icon. */ |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
2070 pixbuf = create_prpl_icon(gc->account); |
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
2071 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
|
2072 |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2073 /* Now convert it to GtkImage */ |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
2074 if (pixbuf == NULL) |
4669
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2075 image = gtk_image_new(); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2076 else |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
2077 image = gtk_image_new_from_pixbuf(scale); |
4669
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2078 |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2079 gtk_size_group_add_widget(sg, image); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2080 |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
2081 g_object_unref(G_OBJECT(scale)); |
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
2082 g_object_unref(G_OBJECT(pixbuf)); |
4669
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2083 |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2084 /* Make our menu item */ |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2085 menuitem = gtk_radio_menu_item_new_with_label(group, gc->username); |
4793 | 2086 group = gtk_radio_menu_item_get_group(GTK_RADIO_MENU_ITEM(menuitem)); |
4359 | 2087 |
4669
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2088 /* Do some evil, see some evil, speak some evil. */ |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2089 box = gtk_hbox_new(FALSE, 0); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2090 |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2091 label = gtk_bin_get_child(GTK_BIN(menuitem)); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2092 g_object_ref(label); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2093 gtk_container_remove(GTK_CONTAINER(menuitem), label); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2094 |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2095 gtk_box_pack_start(GTK_BOX(box), image, FALSE, FALSE, 0); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2096 gtk_box_pack_start(GTK_BOX(box), label, TRUE, TRUE, 4); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2097 |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2098 g_object_unref(label); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2099 |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2100 gtk_container_add(GTK_CONTAINER(menuitem), box); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2101 |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2102 gtk_widget_show(label); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2103 gtk_widget_show(image); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2104 gtk_widget_show(box); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2105 |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2106 /* Set our data and callbacks. */ |
4359 | 2107 g_object_set_data(G_OBJECT(menuitem), "user_data", win); |
4673 | 2108 g_object_set_data(G_OBJECT(menuitem), "gaim_account", gc->account); |
4359 | 2109 |
4786 | 2110 g_signal_connect(G_OBJECT(menuitem), "activate", |
4673 | 2111 G_CALLBACK(menu_conv_sel_send_cb), NULL); |
4359 | 2112 |
2113 gtk_widget_show(menuitem); | |
2114 gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem); | |
2115 } | |
2116 | |
2117 /* | |
2118 * Fill it with any accounts that still has an open (yet disabled) window | |
2119 * (signed off accounts with a window open). | |
2120 */ | |
2121 for (convs = gaim_get_conversations(); | |
2122 convs != NULL; | |
2123 convs = convs->next) { | |
2124 | |
2125 struct gaim_conversation *conv; | |
4491 | 2126 struct gaim_account *account; |
4669
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2127 GtkWidget *box; |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2128 GtkWidget *label; |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2129 GtkWidget *image; |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
2130 GdkPixbuf *pixbuf, *scale; |
4359 | 2131 |
2132 conv = (struct gaim_conversation *)convs->data; | |
4360
c435a29370b8
[gaim-migrate @ 4626]
Christian Hammond <chipx86@chipx86.com>
parents:
4359
diff
changeset
|
2133 |
c435a29370b8
[gaim-migrate @ 4626]
Christian Hammond <chipx86@chipx86.com>
parents:
4359
diff
changeset
|
2134 if (conv == deleted_conv) |
c435a29370b8
[gaim-migrate @ 4626]
Christian Hammond <chipx86@chipx86.com>
parents:
4359
diff
changeset
|
2135 continue; |
c435a29370b8
[gaim-migrate @ 4626]
Christian Hammond <chipx86@chipx86.com>
parents:
4359
diff
changeset
|
2136 |
4491 | 2137 account = gaim_conversation_get_account(conv); |
2138 | |
4786 | 2139 |
4491 | 2140 if (account->gc == NULL) { |
4359 | 2141 if (first_offline && found_online) { |
2142 menuitem = gtk_separator_menu_item_new(); | |
2143 gtk_widget_show(menuitem); | |
2144 gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem); | |
2145 | |
2146 first_offline = FALSE; | |
2147 } | |
2148 | |
4669
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2149 /* Create a pixmap for the protocol icon. */ |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
2150 pixbuf = create_prpl_icon(account); |
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
2151 scale = gdk_pixbuf_scale_simple(pixbuf, 16, 16, |
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
2152 GDK_INTERP_BILINEAR); |
4669
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2153 |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2154 /* Now convert it to GtkImage */ |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
2155 if (pixbuf == NULL) |
4669
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2156 image = gtk_image_new(); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2157 else |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
2158 image = gtk_image_new_from_pixbuf(scale); |
4669
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2159 |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2160 gtk_size_group_add_widget(sg, image); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2161 |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
2162 if (scale != NULL) g_object_unref(scale); |
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
2163 if (pixbuf != NULL) g_object_unref(pixbuf); |
4669
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2164 |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2165 /* Make our menu item */ |
4359 | 2166 menuitem = gtk_radio_menu_item_new_with_label(group, |
4491 | 2167 account->username); |
4793 | 2168 group = gtk_radio_menu_item_get_group(GTK_RADIO_MENU_ITEM(menuitem)); |
4359 | 2169 |
4669
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2170 /* Do some evil, see some evil, speak some evil. */ |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2171 box = gtk_hbox_new(FALSE, 0); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2172 |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2173 label = gtk_bin_get_child(GTK_BIN(menuitem)); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2174 g_object_ref(label); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2175 gtk_container_remove(GTK_CONTAINER(menuitem), label); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2176 |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2177 gtk_box_pack_start(GTK_BOX(box), image, FALSE, FALSE, 0); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2178 gtk_box_pack_start(GTK_BOX(box), label, TRUE, TRUE, 4); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2179 |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2180 g_object_unref(label); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2181 |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2182 gtk_container_add(GTK_CONTAINER(menuitem), box); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2183 |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2184 gtk_widget_show(label); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2185 gtk_widget_show(image); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2186 gtk_widget_show(box); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2187 |
4359 | 2188 gtk_widget_set_sensitive(menuitem, FALSE); |
4786 | 2189 g_object_set_data(G_OBJECT(menuitem), "user_data", win); |
4674 | 2190 g_object_set_data(G_OBJECT(menuitem), "gaim_account", account); |
4359 | 2191 |
4786 | 2192 g_signal_connect(G_OBJECT(menuitem), "activate", |
2193 G_CALLBACK(menu_conv_sel_send_cb), NULL); | |
2194 | |
4359 | 2195 gtk_widget_show(menuitem); |
2196 gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem); | |
2197 } | |
2198 } | |
2199 | |
4669
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2200 g_object_unref(sg); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2201 |
4359 | 2202 gtk_widget_show(gtkwin->menu.send_as); |
2203 update_send_as_selection(win); | |
2204 } | |
2205 | |
2206 static GList * | |
2207 generate_invite_user_names(struct gaim_connection *gc) | |
2208 { | |
4785 | 2209 GaimBlistNode *gnode,*bnode; |
4359 | 2210 struct group *g; |
2211 struct buddy *buddy; | |
2212 static GList *tmp = NULL; | |
2213 | |
2214 if (tmp) | |
2215 g_list_free(tmp); | |
2216 | |
2217 tmp = g_list_append(NULL, ""); | |
2218 | |
2219 if (gc != NULL) { | |
4785 | 2220 for(gnode = gaim_get_blist()->root; gnode; gnode = gnode->next) { |
2221 if(!GAIM_BLIST_NODE_IS_GROUP(gnode)) | |
2222 continue; | |
2223 g = (struct group *)gnode; | |
2224 for(bnode = gnode->child; bnode; bnode = bnode->next) { | |
2225 if(!GAIM_BLIST_NODE_IS_BUDDY(bnode)) | |
2226 continue; | |
2227 buddy = (struct buddy *)bnode; | |
2228 | |
2229 if (buddy->account == gc->account && buddy->present) | |
4359 | 2230 tmp = g_list_append(tmp, buddy->name); |
2231 } | |
2232 } | |
2233 } | |
2234 | |
2235 return tmp; | |
2236 } | |
2237 | |
2238 static void | |
2239 add_chat_buddy_common(struct gaim_conversation *conv, const char *name, | |
2240 int pos) | |
2241 { | |
2242 struct gaim_gtk_conversation *gtkconv; | |
2243 struct gaim_gtk_chat_pane *gtkchat; | |
2244 struct gaim_chat *chat; | |
2245 GtkTreeIter iter; | |
2246 GtkListStore *ls; | |
2247 | |
2248 chat = GAIM_CHAT(conv); | |
2249 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
2250 gtkchat = gtkconv->u.chat; | |
2251 | |
2252 ls = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list))); | |
2253 | |
2254 gtk_list_store_append(ls, &iter); | |
2255 gtk_list_store_set(ls, &iter, 0, | |
2256 (gaim_chat_is_user_ignored(chat, name) ? "X" : " "), | |
2257 1, name, -1); | |
2258 gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(ls), 1, | |
2259 GTK_SORT_ASCENDING); | |
2260 } | |
2261 | |
2262 static void | |
2263 tab_complete(struct gaim_conversation *conv) | |
2264 { | |
2265 struct gaim_gtk_conversation *gtkconv; | |
2266 struct gaim_chat *chat; | |
2267 GtkTextIter cursor, word_start, start_buffer; | |
2268 int start; | |
2269 int most_matched = -1; | |
2270 char *entered, *partial = NULL; | |
2271 char *text; | |
2272 GList *matches = NULL; | |
2273 GList *nicks = NULL; | |
2274 | |
2275 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
2276 chat = GAIM_CHAT(conv); | |
2277 | |
2278 gtk_text_buffer_get_start_iter(gtkconv->entry_buffer, &start_buffer); | |
2279 gtk_text_buffer_get_iter_at_mark(gtkconv->entry_buffer, &cursor, | |
2280 gtk_text_buffer_get_insert(gtkconv->entry_buffer)); | |
2281 | |
2282 word_start = cursor; | |
2283 | |
2284 /* if there's nothing there just return */ | |
2285 if (!gtk_text_iter_compare(&cursor, &start_buffer)) | |
2286 return; | |
2287 | |
2288 text = gtk_text_buffer_get_text(gtkconv->entry_buffer, &start_buffer, | |
2289 &cursor, FALSE); | |
2290 | |
2291 /* if we're at the end of ": " we need to move back 2 spaces */ | |
2292 start = strlen(text) - 1; | |
2293 | |
2294 if (strlen(text) >= 2 && !strncmp(&text[start-1], ": ", 2)) | |
2295 gtk_text_iter_backward_chars(&word_start, 2); | |
2296 | |
2297 /* find the start of the word that we're tabbing */ | |
2298 while (start >= 0 && text[start] != ' ') { | |
2299 gtk_text_iter_backward_char(&word_start); | |
2300 start--; | |
2301 } | |
2302 | |
2303 g_free(text); | |
2304 | |
2305 entered = gtk_text_buffer_get_text(gtkconv->entry_buffer, &word_start, | |
2306 &cursor, FALSE); | |
2307 | |
2308 if (chat_options & OPT_CHAT_OLD_STYLE_TAB) { | |
2309 if (strlen(entered) >= 2 && | |
2310 !strncmp(": ", entered + strlen(entered) - 2, 2)) { | |
2311 | |
2312 entered[strlen(entered) - 2] = 0; | |
2313 } | |
2314 } | |
2315 | |
2316 if (!strlen(entered)) { | |
2317 g_free(entered); | |
2318 return; | |
2319 } | |
2320 | |
2321 for (nicks = gaim_chat_get_users(chat); | |
2322 nicks != NULL; | |
2323 nicks = nicks->next) { | |
2324 | |
2325 char *nick = nicks->data; | |
2326 /* this checks to see if the current nick could be a completion */ | |
4793 | 2327 if (g_ascii_strncasecmp(nick, entered, strlen(entered))) { |
4621
69f028a6f357
[gaim-migrate @ 4912]
Christian Hammond <chipx86@chipx86.com>
parents:
4608
diff
changeset
|
2328 if (*nick != '+' && *nick != '@' && *nick != '%') |
4359 | 2329 continue; |
2330 | |
4793 | 2331 if (g_ascii_strncasecmp(nick + 1, entered, strlen(entered))) { |
4359 | 2332 if (nick[0] != '@' || nick[1] != '+') |
2333 continue; | |
2334 | |
4793 | 2335 if (g_ascii_strncasecmp(nick + 2, entered, strlen(entered))) |
4359 | 2336 continue; |
2337 else | |
2338 nick += 2; | |
2339 } | |
2340 else | |
2341 nick++; | |
2342 } | |
2343 | |
2344 /* if we're here, it's a possible completion */ | |
2345 | |
2346 /* if we're doing old-style, just fill in the completion */ | |
2347 if (chat_options & OPT_CHAT_OLD_STYLE_TAB) { | |
2348 gtk_text_buffer_delete(gtkconv->entry_buffer, | |
2349 &word_start, &cursor); | |
2350 | |
2351 if (strlen(nick) == strlen(entered)) { | |
2352 nicks = (nicks->next | |
2353 ? nicks->next | |
2354 : gaim_chat_get_users(chat)); | |
2355 | |
2356 nick = nicks->data; | |
2357 | |
2358 if (*nick == '@') nick++; | |
4621
69f028a6f357
[gaim-migrate @ 4912]
Christian Hammond <chipx86@chipx86.com>
parents:
4608
diff
changeset
|
2359 if (*nick == '%') nick++; |
4359 | 2360 if (*nick == '+') nick++; |
2361 } | |
2362 | |
2363 gtk_text_buffer_get_start_iter(gtkconv->entry_buffer, | |
2364 &start_buffer); | |
2365 gtk_text_buffer_get_iter_at_mark(gtkconv->entry_buffer, &cursor, | |
2366 gtk_text_buffer_get_insert(gtkconv->entry_buffer)); | |
2367 | |
2368 if (!gtk_text_iter_compare(&cursor, &start_buffer)) { | |
2369 char *tmp = g_strdup_printf("%s: ", nick); | |
2370 gtk_text_buffer_insert_at_cursor(gtkconv->entry_buffer, | |
2371 tmp, -1); | |
2372 g_free(tmp); | |
2373 } | |
2374 else | |
2375 gtk_text_buffer_insert_at_cursor(gtkconv->entry_buffer, | |
2376 nick, -1); | |
2377 | |
2378 g_free(entered); | |
2379 | |
2380 return; | |
2381 } | |
2382 | |
2383 /* we're only here if we're doing new style */ | |
2384 if (most_matched == -1) { | |
2385 /* | |
2386 * this will only get called once, since from now | |
2387 * on most_matched is >= 0 | |
2388 */ | |
2389 most_matched = strlen(nick); | |
2390 partial = g_strdup(nick); | |
2391 } | |
2392 else if (most_matched) { | |
4793 | 2393 while (g_ascii_strncasecmp(nick, partial, most_matched)) |
4359 | 2394 most_matched--; |
2395 | |
2396 partial[most_matched] = 0; | |
2397 } | |
2398 | |
2399 matches = g_list_append(matches, nick); | |
2400 } | |
2401 | |
2402 /* we're only here if we're doing new style */ | |
2403 | |
2404 /* if there weren't any matches, return */ | |
2405 if (!matches) { | |
2406 /* if matches isn't set partials won't be either */ | |
2407 g_free(entered); | |
2408 return; | |
2409 } | |
2410 | |
2411 gtk_text_buffer_delete(gtkconv->entry_buffer, &word_start, &cursor); | |
2412 | |
2413 if (!matches->next) { | |
2414 /* there was only one match. fill it in. */ | |
2415 gtk_text_buffer_get_start_iter(gtkconv->entry_buffer, &start_buffer); | |
2416 gtk_text_buffer_get_iter_at_mark(gtkconv->entry_buffer, &cursor, | |
2417 gtk_text_buffer_get_insert(gtkconv->entry_buffer)); | |
2418 | |
2419 if (!gtk_text_iter_compare(&cursor, &start_buffer)) { | |
2420 char *tmp = g_strdup_printf("%s: ", (char *)matches->data); | |
2421 gtk_text_buffer_insert_at_cursor(gtkconv->entry_buffer, tmp, -1); | |
2422 g_free(tmp); | |
2423 } | |
2424 else | |
2425 gtk_text_buffer_insert_at_cursor(gtkconv->entry_buffer, | |
2426 matches->data, -1); | |
2427 | |
2428 matches = g_list_remove(matches, matches->data); | |
2429 } | |
2430 else { | |
2431 /* | |
2432 * there were lots of matches, fill in as much as possible | |
2433 * and display all of them | |
2434 */ | |
2435 char *addthis = g_malloc0(1); | |
2436 | |
2437 while (matches) { | |
2438 char *tmp = addthis; | |
2439 addthis = g_strconcat(tmp, matches->data, " ", NULL); | |
2440 g_free(tmp); | |
2441 matches = g_list_remove(matches, matches->data); | |
2442 } | |
2443 | |
2444 gaim_conversation_write(conv, NULL, addthis, -1, WFLAG_NOLOG, | |
2445 time(NULL)); | |
2446 gtk_text_buffer_insert_at_cursor(gtkconv->entry_buffer, partial, -1); | |
2447 g_free(addthis); | |
2448 } | |
2449 | |
2450 g_free(entered); | |
2451 g_free(partial); | |
2452 } | |
2453 | |
2454 static gboolean | |
2455 meify(char *message, size_t len) | |
2456 { | |
2457 /* | |
2458 * Read /me-ify: If the message (post-HTML) starts with /me, | |
2459 * remove the "/me " part of it (including that space) and return TRUE. | |
2460 */ | |
2461 char *c; | |
2462 gboolean inside_html = 0; | |
2463 | |
2464 if (message == NULL) | |
2465 return FALSE; /* Umm.. this would be very bad if this happens. */ | |
2466 | |
2467 if (len == -1) | |
2468 len = strlen(message); | |
2469 | |
2470 for (c = message; *c != '\0'; c++, len--) { | |
2471 if (inside_html) { | |
2472 if (*c == '>') | |
2473 inside_html = FALSE; | |
2474 } | |
2475 else { | |
2476 if (*c == '<') | |
2477 inside_html = TRUE; | |
2478 else | |
2479 break; | |
2480 } | |
2481 } | |
2482 | |
4793 | 2483 if (*c != '\0' && !g_ascii_strncasecmp(c, "/me ", 4)) { |
4359 | 2484 memmove(c, c + 4, len - 3); |
2485 | |
2486 return TRUE; | |
2487 } | |
2488 | |
2489 return FALSE; | |
2490 } | |
2491 | |
2492 static GtkItemFactoryEntry menu_items[] = | |
2493 { | |
2494 /* Conversation menu */ | |
4596 | 2495 { N_("/_Conversation"), NULL, NULL, 0, "<Branch>" }, |
2496 { N_("/Conversation/_Save As..."), NULL, menu_save_as_cb, 0, | |
4359 | 2497 "<StockItem>", GTK_STOCK_SAVE_AS }, |
4596 | 2498 { N_("/Conversation/View _History..."), NULL, menu_view_history_cb, 0, NULL }, |
4359 | 2499 { "/Conversation/sep1", NULL, NULL, 0, "<Separator>" }, |
4596 | 2500 { N_("/Conversation/Insert _URL..."), NULL, menu_insert_link_cb, 0, |
4359 | 2501 "<StockItem>", GAIM_STOCK_LINK }, |
4596 | 2502 { N_("/Conversation/Insert _Image..."), NULL, menu_insert_image_cb, 0, |
4359 | 2503 "<StockItem>", GAIM_STOCK_IMAGE }, |
2504 { "/Conversation/sep2", NULL, NULL, 0, "<Separator>" }, | |
4596 | 2505 { N_("/Conversation/_Close"), NULL, menu_close_conv_cb, 0, |
4359 | 2506 "<StockItem>", GTK_STOCK_CLOSE }, |
2507 | |
2508 /* Options */ | |
4596 | 2509 { N_("/_Options"), NULL, NULL, 0, "<Branch>" }, |
2510 { N_("/Options/Enable _Logging"), NULL, menu_logging_cb, 0, "<CheckItem>" }, | |
2511 { N_("/Options/Enable _Sounds"), NULL, menu_sounds_cb, 0, "<CheckItem>" }, | |
4359 | 2512 }; |
2513 | |
4602
4128761bacb8
[gaim-migrate @ 4889]
Christian Hammond <chipx86@chipx86.com>
parents:
4598
diff
changeset
|
2514 static const int menu_item_count = |
4359 | 2515 sizeof(menu_items) / sizeof(*menu_items); |
2516 | |
4602
4128761bacb8
[gaim-migrate @ 4889]
Christian Hammond <chipx86@chipx86.com>
parents:
4598
diff
changeset
|
2517 static char * |
4128761bacb8
[gaim-migrate @ 4889]
Christian Hammond <chipx86@chipx86.com>
parents:
4598
diff
changeset
|
2518 item_factory_translate_func (const char *path, gpointer func_data) |
4128761bacb8
[gaim-migrate @ 4889]
Christian Hammond <chipx86@chipx86.com>
parents:
4598
diff
changeset
|
2519 { |
4128761bacb8
[gaim-migrate @ 4889]
Christian Hammond <chipx86@chipx86.com>
parents:
4598
diff
changeset
|
2520 return _(path); |
4128761bacb8
[gaim-migrate @ 4889]
Christian Hammond <chipx86@chipx86.com>
parents:
4598
diff
changeset
|
2521 } |
4128761bacb8
[gaim-migrate @ 4889]
Christian Hammond <chipx86@chipx86.com>
parents:
4598
diff
changeset
|
2522 |
4359 | 2523 static GtkWidget * |
2524 setup_menubar(struct gaim_window *win) | |
2525 { | |
2526 struct gaim_gtk_window *gtkwin; | |
2527 gtkwin = GAIM_GTK_WINDOW(win); | |
2528 | |
4630 | 2529 gtkwin->menu.item_factory = gtk_item_factory_new(GTK_TYPE_MENU_BAR, |
2530 "<main>", NULL); | |
2531 | |
2532 gtk_item_factory_set_translate_func (gtkwin->menu.item_factory, | |
4602
4128761bacb8
[gaim-migrate @ 4889]
Christian Hammond <chipx86@chipx86.com>
parents:
4598
diff
changeset
|
2533 item_factory_translate_func, |
4128761bacb8
[gaim-migrate @ 4889]
Christian Hammond <chipx86@chipx86.com>
parents:
4598
diff
changeset
|
2534 NULL, NULL); |
4630 | 2535 |
2536 gtk_item_factory_create_items(gtkwin->menu.item_factory, menu_item_count, | |
4359 | 2537 menu_items, win); |
2538 | |
4630 | 2539 gtkwin->menu.menubar = gtk_item_factory_get_widget(gtkwin->menu.item_factory, |
2540 "<main>"); | |
2541 gtkwin->menu.view_history = gtk_item_factory_get_widget(gtkwin->menu.item_factory, | |
4834 | 2542 N_("/Conversation/View History...")); |
4630 | 2543 gtkwin->menu.insert_link = gtk_item_factory_get_widget(gtkwin->menu.item_factory, |
4834 | 2544 N_("/Conversation/Insert URL...")); |
4630 | 2545 gtkwin->menu.insert_image = gtk_item_factory_get_widget(gtkwin->menu.item_factory, |
4834 | 2546 N_("/Conversation/Insert Image...")); |
4630 | 2547 gtkwin->menu.logging = gtk_item_factory_get_widget(gtkwin->menu.item_factory, |
4834 | 2548 N_("/Options/Enable Logging")); |
4630 | 2549 gtkwin->menu.sounds = gtk_item_factory_get_widget(gtkwin->menu.item_factory, |
4834 | 2550 N_("/Options/Enable Sounds")); |
4359 | 2551 |
4360
c435a29370b8
[gaim-migrate @ 4626]
Christian Hammond <chipx86@chipx86.com>
parents:
4359
diff
changeset
|
2552 generate_send_as_items(win, NULL); |
4359 | 2553 |
2554 gtk_widget_show(gtkwin->menu.menubar); | |
4931 | 2555 |
2556 return gtkwin->menu.menubar; | |
4359 | 2557 } |
2558 | |
2559 static void | |
2560 setup_im_buttons(struct gaim_conversation *conv, GtkWidget *parent) | |
2561 { | |
2562 struct gaim_connection *gc; | |
2563 struct gaim_gtk_conversation *gtkconv; | |
2564 struct gaim_gtk_im_pane *gtkim; | |
2565 GaimConversationType type = GAIM_CONV_IM; | |
2566 | |
2567 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
2568 gtkim = gtkconv->u.im; | |
2569 gc = gaim_conversation_get_gc(conv); | |
2570 | |
2571 /* From right to left... */ | |
2572 | |
2573 /* Send button */ | |
2574 gtkconv->send = gaim_gtk_change_text(_("Send"), gtkconv->send, | |
2575 GAIM_STOCK_SEND, type); | |
2576 gtk_tooltips_set_tip(gtkconv->tooltips, gtkconv->send, _("Send"), NULL); | |
2577 | |
2578 gtk_box_pack_end(GTK_BOX(parent), gtkconv->send, FALSE, FALSE, 0); | |
2579 | |
2580 /* Separator */ | |
2581 if (gtkim->sep2 != NULL) | |
2582 gtk_widget_destroy(gtkim->sep2); | |
2583 | |
2584 gtkim->sep2 = gtk_vseparator_new(); | |
2585 gtk_box_pack_end(GTK_BOX(parent), gtkim->sep2, FALSE, TRUE, 0); | |
2586 gtk_widget_show(gtkim->sep2); | |
2587 | |
2588 /* Now, um, just kind of all over the place. Huh? */ | |
2589 | |
2590 /* Add button */ | |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
2591 if (gaim_find_buddy(gaim_conversation_get_account(conv), |
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
2592 gaim_conversation_get_name(conv)) == NULL) { |
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
2593 |
4359 | 2594 gtkim->add = gaim_gtk_change_text(_("Add"), gtkim->add, |
2595 GTK_STOCK_ADD, type); | |
2596 gtk_tooltips_set_tip(gtkconv->tooltips, gtkim->add, | |
4370
d856987c72ca
[gaim-migrate @ 4636]
Christian Hammond <chipx86@chipx86.com>
parents:
4369
diff
changeset
|
2597 _("Add the user to your buddy list"), NULL); |
4359 | 2598 } |
2599 else { | |
2600 gtkim->add = gaim_gtk_change_text(_("Remove"), gtkim->add, | |
2601 GTK_STOCK_REMOVE, type); | |
2602 gtk_tooltips_set_tip(gtkconv->tooltips, gtkim->add, | |
4370
d856987c72ca
[gaim-migrate @ 4636]
Christian Hammond <chipx86@chipx86.com>
parents:
4369
diff
changeset
|
2603 _("Remove the user from your buddy list"), NULL); |
4359 | 2604 } |
2605 | |
2606 gtk_box_pack_start(GTK_BOX(parent), gtkim->add, | |
2607 FALSE, FALSE, 0); | |
2608 | |
2609 /* Warn button */ | |
2610 gtkim->warn = gaim_gtk_change_text(_("Warn"), gtkim->warn, | |
2611 GAIM_STOCK_WARN, type); | |
2612 gtk_box_pack_start(GTK_BOX(parent), gtkim->warn, FALSE, FALSE, 0); | |
4370
d856987c72ca
[gaim-migrate @ 4636]
Christian Hammond <chipx86@chipx86.com>
parents:
4369
diff
changeset
|
2613 gtk_tooltips_set_tip(gtkconv->tooltips, gtkim->warn, |
d856987c72ca
[gaim-migrate @ 4636]
Christian Hammond <chipx86@chipx86.com>
parents:
4369
diff
changeset
|
2614 _("Warn the user"), NULL); |
4359 | 2615 |
2616 /* Info button */ | |
2617 gtkconv->info = gaim_gtk_change_text(_("Info"), gtkconv->info, | |
2618 GAIM_STOCK_INFO, type); | |
2619 gtk_box_pack_start(GTK_BOX(parent), gtkconv->info, FALSE, FALSE, 0); | |
2620 gtk_tooltips_set_tip(gtkconv->tooltips, gtkconv->info, | |
4370
d856987c72ca
[gaim-migrate @ 4636]
Christian Hammond <chipx86@chipx86.com>
parents:
4369
diff
changeset
|
2621 _("Get the user's information"), NULL); |
4359 | 2622 |
2623 /* Block button */ | |
2624 gtkim->block = gaim_gtk_change_text(_("Block"), gtkim->block, | |
2625 GAIM_STOCK_BLOCK, type); | |
2626 gtk_box_pack_start(GTK_BOX(parent), gtkim->block, FALSE, FALSE, 0); | |
2627 gtk_tooltips_set_tip(gtkconv->tooltips, gtkim->block, | |
4370
d856987c72ca
[gaim-migrate @ 4636]
Christian Hammond <chipx86@chipx86.com>
parents:
4369
diff
changeset
|
2628 _("Block the user"), NULL); |
4359 | 2629 |
2630 gtk_button_set_relief(GTK_BUTTON(gtkconv->info), GTK_RELIEF_NONE); | |
2631 gtk_button_set_relief(GTK_BUTTON(gtkim->add), GTK_RELIEF_NONE); | |
2632 gtk_button_set_relief(GTK_BUTTON(gtkim->warn), GTK_RELIEF_NONE); | |
2633 gtk_button_set_relief(GTK_BUTTON(gtkconv->send), GTK_RELIEF_NONE); | |
2634 gtk_button_set_relief(GTK_BUTTON(gtkim->block), GTK_RELIEF_NONE); | |
2635 | |
2636 gtk_size_group_add_widget(gtkconv->sg, gtkconv->info); | |
2637 gtk_size_group_add_widget(gtkconv->sg, gtkim->add); | |
2638 gtk_size_group_add_widget(gtkconv->sg, gtkim->warn); | |
2639 gtk_size_group_add_widget(gtkconv->sg, gtkconv->send); | |
2640 gtk_size_group_add_widget(gtkconv->sg, gtkim->block); | |
2641 | |
2642 gtk_box_reorder_child(GTK_BOX(parent), gtkim->warn, 1); | |
2643 gtk_box_reorder_child(GTK_BOX(parent), gtkim->block, 2); | |
4370
d856987c72ca
[gaim-migrate @ 4636]
Christian Hammond <chipx86@chipx86.com>
parents:
4369
diff
changeset
|
2644 gtk_box_reorder_child(GTK_BOX(parent), gtkim->add, 3); |
4359 | 2645 gtk_box_reorder_child(GTK_BOX(parent), gtkconv->info, 4); |
2646 | |
2647 gaim_gtkconv_update_buttons_by_protocol(conv); | |
2648 | |
2649 g_signal_connect(G_OBJECT(gtkconv->send), "clicked", | |
2650 G_CALLBACK(send_cb), conv); | |
2651 g_signal_connect(G_OBJECT(gtkconv->info), "clicked", | |
2652 G_CALLBACK(info_cb), conv); | |
2653 g_signal_connect(G_OBJECT(gtkim->warn), "clicked", | |
2654 G_CALLBACK(warn_cb), conv); | |
2655 g_signal_connect(G_OBJECT(gtkim->block), "clicked", | |
2656 G_CALLBACK(block_cb), conv); | |
2657 } | |
2658 | |
2659 static void | |
2660 setup_chat_buttons(struct gaim_conversation *conv, GtkWidget *parent) | |
2661 { | |
2662 struct gaim_connection *gc; | |
2663 struct gaim_gtk_conversation *gtkconv; | |
2664 struct gaim_gtk_chat_pane *gtkchat; | |
2665 struct gaim_gtk_window *gtkwin; | |
2666 GtkWidget *sep; | |
2667 | |
2668 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
2669 gtkchat = gtkconv->u.chat; | |
2670 gtkwin = GAIM_GTK_WINDOW(gaim_conversation_get_window(conv)); | |
2671 gc = gaim_conversation_get_gc(conv); | |
2672 | |
2673 /* Send button */ | |
2674 gtkconv->send = gaim_gtk_change_text(_("Send"), gtkconv->send, | |
2675 GAIM_STOCK_SEND, GAIM_CONV_CHAT); | |
2676 gtk_tooltips_set_tip(gtkconv->tooltips, gtkconv->send, _("Send"), NULL); | |
2677 | |
2678 gtk_box_pack_end(GTK_BOX(parent), gtkconv->send, FALSE, FALSE, 0); | |
2679 | |
2680 /* Separator */ | |
2681 sep = gtk_vseparator_new(); | |
2682 gtk_box_pack_end(GTK_BOX(parent), sep, FALSE, TRUE, 0); | |
2683 gtk_widget_show(sep); | |
2684 | |
2685 /* Invite */ | |
2686 gtkchat->invite = gaim_gtk_change_text(_("Invite"), gtkchat->invite, | |
2687 GAIM_STOCK_INVITE, GAIM_CONV_CHAT); | |
2688 gtk_tooltips_set_tip(gtkconv->tooltips, gtkchat->invite, | |
2689 _("Invite a user"), NULL); | |
2690 gtk_box_pack_end(GTK_BOX(parent), gtkchat->invite, FALSE, FALSE, 0); | |
2691 | |
2692 /* Set the relief on these. */ | |
2693 gtk_button_set_relief(GTK_BUTTON(gtkchat->invite), GTK_RELIEF_NONE); | |
2694 gtk_button_set_relief(GTK_BUTTON(gtkconv->send), GTK_RELIEF_NONE); | |
2695 | |
2696 /* Callbacks */ | |
2697 g_signal_connect(G_OBJECT(gtkconv->send), "clicked", | |
2698 G_CALLBACK(send_cb), conv); | |
2699 g_signal_connect(G_OBJECT(gtkchat->invite), "clicked", | |
2700 G_CALLBACK(invite_cb), conv); | |
2701 } | |
2702 | |
2703 static GtkWidget * | |
2704 build_conv_toolbar(struct gaim_conversation *conv) | |
2705 { | |
2706 struct gaim_gtk_conversation *gtkconv; | |
2707 GtkWidget *vbox; | |
2708 GtkWidget *hbox; | |
2709 GtkWidget *button; | |
2710 GtkWidget *sep; | |
2711 GtkSizeGroup *sg; | |
2712 | |
2713 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
2714 | |
2715 sg = gtk_size_group_new(GTK_SIZE_GROUP_BOTH); | |
2716 | |
2717 vbox = gtk_vbox_new(FALSE, 0); | |
2718 sep = gtk_hseparator_new(); | |
2719 gtk_box_pack_start(GTK_BOX(vbox), sep, FALSE, FALSE, 0); | |
2720 | |
2721 hbox = gtk_hbox_new(FALSE, 5); | |
2722 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); | |
2723 | |
2724 /* Bold */ | |
2725 button = gaim_pixbuf_toolbar_button_from_stock(GTK_STOCK_BOLD); | |
2726 gtk_size_group_add_widget(sg, button); | |
2727 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0); | |
2728 gtk_tooltips_set_tip(gtkconv->tooltips, button, _("Bold"), NULL); | |
2729 | |
2730 g_signal_connect(G_OBJECT(button), "clicked", | |
2731 G_CALLBACK(do_bold), gtkconv); | |
2732 | |
2733 gtkconv->toolbar.bold = button; | |
2734 | |
2735 /* Italic */ | |
2736 button = gaim_pixbuf_toolbar_button_from_stock(GTK_STOCK_ITALIC); | |
2737 gtk_size_group_add_widget(sg, button); | |
2738 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0); | |
2739 gtk_tooltips_set_tip(gtkconv->tooltips, button, _("Italic"), NULL); | |
2740 | |
2741 g_signal_connect(G_OBJECT(button), "clicked", | |
2742 G_CALLBACK(do_italic), gtkconv); | |
2743 | |
2744 gtkconv->toolbar.italic = button; | |
2745 | |
2746 /* Underline */ | |
2747 button = gaim_pixbuf_toolbar_button_from_stock(GTK_STOCK_UNDERLINE); | |
2748 gtk_size_group_add_widget(sg, button); | |
2749 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0); | |
2750 gtk_tooltips_set_tip(gtkconv->tooltips, button, _("Underline"), NULL); | |
2751 | |
2752 g_signal_connect(G_OBJECT(button), "clicked", | |
2753 G_CALLBACK(do_underline), gtkconv); | |
2754 | |
2755 gtkconv->toolbar.underline = button; | |
2756 | |
2757 /* Sep */ | |
2758 sep = gtk_vseparator_new(); | |
2759 gtk_box_pack_start(GTK_BOX(hbox), sep, FALSE, FALSE, 0); | |
2760 | |
2761 /* Increase font size */ | |
2762 button = gaim_pixbuf_toolbar_button_from_stock(GAIM_STOCK_TEXT_BIGGER); | |
2763 gtk_size_group_add_widget(sg, button); | |
2764 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0); | |
2765 gtk_tooltips_set_tip(gtkconv->tooltips, button, | |
2766 _("Larger font size"), NULL); | |
2767 | |
2768 g_signal_connect(G_OBJECT(button), "clicked", | |
2769 G_CALLBACK(do_big), gtkconv); | |
2770 | |
2771 /* Normal font size */ | |
2772 button = gaim_pixbuf_toolbar_button_from_stock(GAIM_STOCK_TEXT_NORMAL); | |
2773 gtk_size_group_add_widget(sg, button); | |
2774 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0); | |
2775 gtk_tooltips_set_tip(gtkconv->tooltips, button, | |
2776 _("Normal font size"), NULL); | |
2777 | |
2778 g_signal_connect(G_OBJECT(button), "clicked", | |
2779 G_CALLBACK(do_normal), gtkconv); | |
2780 | |
2781 gtkconv->toolbar.normal_size = button; | |
2782 | |
2783 /* Decrease font size */ | |
2784 button = gaim_pixbuf_toolbar_button_from_stock(GAIM_STOCK_TEXT_SMALLER); | |
2785 gtk_size_group_add_widget(sg, button); | |
2786 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0); | |
2787 gtk_tooltips_set_tip(gtkconv->tooltips, button, | |
2788 _("Smaller font size"), NULL); | |
2789 | |
2790 g_signal_connect(G_OBJECT(button), "clicked", | |
2791 G_CALLBACK(do_small), gtkconv); | |
2792 | |
2793 /* Sep */ | |
2794 sep = gtk_vseparator_new(); | |
2795 gtk_box_pack_start(GTK_BOX(hbox), sep, FALSE, FALSE, 0); | |
2796 | |
4685 | 2797 /* Font Face */ |
2798 | |
2799 button = gaim_pixbuf_toolbar_button_from_stock(GTK_STOCK_SELECT_FONT); | |
2800 gtk_size_group_add_widget(sg, button); | |
2801 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0); | |
2802 gtk_tooltips_set_tip(gtkconv->tooltips, button, | |
2803 _("Font Face"), NULL); | |
2804 | |
2805 g_signal_connect(G_OBJECT(button), "clicked", | |
2806 G_CALLBACK(toggle_font), conv); | |
2807 | |
2808 gtkconv->toolbar.font = button; | |
2809 | |
4359 | 2810 /* Foreground Color */ |
2811 button = gaim_pixbuf_toolbar_button_from_stock(GAIM_STOCK_FGCOLOR); | |
2812 gtk_size_group_add_widget(sg, button); | |
2813 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0); | |
2814 gtk_tooltips_set_tip(gtkconv->tooltips, button, | |
2815 _("Foreground font color"), NULL); | |
2816 | |
2817 g_signal_connect(G_OBJECT(button), "clicked", | |
2818 G_CALLBACK(toggle_fg_color), conv); | |
2819 | |
2820 gtkconv->toolbar.fgcolor = button; | |
2821 | |
2822 /* Background Color */ | |
2823 button = gaim_pixbuf_toolbar_button_from_stock(GAIM_STOCK_BGCOLOR); | |
2824 gtk_size_group_add_widget(sg, button); | |
2825 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0); | |
2826 gtk_tooltips_set_tip(gtkconv->tooltips, button, | |
2827 _("Background color"), NULL); | |
2828 | |
2829 g_signal_connect(G_OBJECT(button), "clicked", | |
2830 G_CALLBACK(toggle_bg_color), conv); | |
2831 | |
2832 gtkconv->toolbar.bgcolor = button; | |
2833 | |
2834 /* Sep */ | |
2835 sep = gtk_vseparator_new(); | |
2836 gtk_box_pack_start(GTK_BOX(hbox), sep, FALSE, FALSE, 0); | |
2837 | |
2838 /* Insert IM Image */ | |
2839 button = gaim_pixbuf_toolbar_button_from_stock(GAIM_STOCK_IMAGE); | |
2840 gtk_size_group_add_widget(sg, button); | |
2841 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0); | |
2842 gtk_tooltips_set_tip(gtkconv->tooltips, button, _("Insert image"), NULL); | |
2843 | |
2844 g_signal_connect(G_OBJECT(button), "clicked", | |
2845 G_CALLBACK(insert_image_cb), conv); | |
2846 | |
2847 gtkconv->toolbar.image = button; | |
2848 | |
2849 /* Insert Link */ | |
2850 button = gaim_pixbuf_toolbar_button_from_stock(GAIM_STOCK_LINK); | |
2851 gtk_size_group_add_widget(sg, button); | |
2852 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0); | |
2853 gtk_tooltips_set_tip(gtkconv->tooltips, button, _("Insert link"), NULL); | |
2854 | |
2855 g_signal_connect(G_OBJECT(button), "clicked", | |
2856 G_CALLBACK(insert_link_cb), conv); | |
2857 | |
2858 gtkconv->toolbar.link = button; | |
2859 | |
2860 /* Insert Smiley */ | |
2861 button = gaim_pixbuf_toolbar_button_from_stock(GAIM_STOCK_SMILEY); | |
2862 gtk_size_group_add_widget(sg, button); | |
2863 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0); | |
2864 gtk_tooltips_set_tip(gtkconv->tooltips, button, _("Insert smiley"), NULL); | |
2865 | |
2866 g_signal_connect(G_OBJECT(button), "clicked", | |
2867 G_CALLBACK(insert_smiley_cb), conv); | |
2868 | |
2869 gtkconv->toolbar.smiley = button; | |
2870 | |
2871 | |
2872 sep = gtk_hseparator_new(); | |
2873 gtk_box_pack_start(GTK_BOX(vbox), sep, FALSE, FALSE, 0); | |
2874 | |
2875 gtk_widget_show_all(vbox); | |
2876 | |
2877 return vbox; | |
2878 } | |
2879 | |
2880 static GtkWidget * | |
2881 setup_chat_pane(struct gaim_conversation *conv) | |
2882 { | |
2883 struct gaim_gtk_conversation *gtkconv; | |
2884 struct gaim_gtk_chat_pane *gtkchat; | |
2885 struct gaim_connection *gc; | |
2886 GtkWidget *vpaned, *hpaned; | |
2887 GtkWidget *vbox, *hbox; | |
2888 GtkWidget *lbox, *bbox; | |
2889 GtkWidget *label; | |
2890 GtkWidget *sw2; | |
2891 GtkWidget *list; | |
2892 GtkWidget *button; | |
2893 GtkWidget *frame; | |
2894 GtkListStore *ls; | |
2895 GtkCellRenderer *rend; | |
2896 GtkTreeViewColumn *col; | |
2897 | |
2898 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
2899 gtkchat = gtkconv->u.chat; | |
2900 gc = gaim_conversation_get_gc(conv); | |
2901 | |
2902 /* Setup the outer pane. */ | |
2903 vpaned = gtk_vpaned_new(); | |
2904 gtk_widget_show(vpaned); | |
2905 | |
2906 /* Setup the top part of the pane. */ | |
2907 vbox = gtk_vbox_new(FALSE, 5); | |
2908 gtk_paned_pack1(GTK_PANED(vpaned), vbox, TRUE, FALSE); | |
2909 gtk_widget_show(vbox); | |
2910 | |
2911 if (gc->prpl->options & OPT_PROTO_CHAT_TOPIC) | |
2912 { | |
2913 hbox = gtk_hbox_new(FALSE, 0); | |
2914 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 5); | |
2915 gtk_widget_show(hbox); | |
2916 | |
2917 label = gtk_label_new(_("Topic:")); | |
2918 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 5); | |
2919 gtk_widget_show(label); | |
2920 | |
2921 gtkchat->topic_text = gtk_entry_new(); | |
4635 | 2922 gtk_editable_set_editable(GTK_EDITABLE(gtkchat->topic_text), FALSE); |
4359 | 2923 gtk_box_pack_start(GTK_BOX(hbox), gtkchat->topic_text, TRUE, TRUE, 5); |
2924 gtk_widget_show(gtkchat->topic_text); | |
2925 } | |
2926 | |
2927 /* Setup the horizontal pane. */ | |
2928 hpaned = gtk_hpaned_new(); | |
2929 gtk_box_pack_start(GTK_BOX(vbox), hpaned, TRUE, TRUE, 5); | |
2930 gtk_widget_show(hpaned); | |
2931 | |
2932 /* Setup the scrolled window to put gtkimhtml in. */ | |
2933 gtkconv->sw = gtk_scrolled_window_new(NULL, NULL); | |
2934 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(gtkconv->sw), | |
2935 GTK_POLICY_NEVER, GTK_POLICY_ALWAYS); | |
2936 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(gtkconv->sw), | |
2937 GTK_SHADOW_IN); | |
2938 gtk_paned_pack1(GTK_PANED(hpaned), gtkconv->sw, TRUE, TRUE); | |
2939 | |
2940 gtk_widget_set_size_request(gtkconv->sw, | |
2941 buddy_chat_size.width, buddy_chat_size.height); | |
2942 gtk_widget_show(gtkconv->sw); | |
2943 | |
2944 /* Setup gtkihmtml. */ | |
2945 gtkconv->imhtml = gtk_imhtml_new(NULL, NULL); | |
2946 gtk_container_add(GTK_CONTAINER(gtkconv->sw), gtkconv->imhtml); | |
2947 | |
2948 gtk_imhtml_show_comments(GTK_IMHTML(gtkconv->imhtml), | |
2949 (convo_options & OPT_CONVO_SHOW_TIME)); | |
2950 | |
2951 g_signal_connect_after(G_OBJECT(gtkconv->imhtml), "button_press_event", | |
2952 G_CALLBACK(entry_stop_rclick_cb), NULL); | |
2953 | |
2954 gaim_setup_imhtml(gtkconv->imhtml); | |
2955 | |
2956 gtk_widget_show(gtkconv->imhtml); | |
2957 | |
2958 /* Build the right pane. */ | |
2959 lbox = gtk_vbox_new(FALSE, 5); | |
4409
0521eec12c33
[gaim-migrate @ 4682]
Christian Hammond <chipx86@chipx86.com>
parents:
4398
diff
changeset
|
2960 gtk_paned_pack2(GTK_PANED(hpaned), lbox, FALSE, TRUE); |
4359 | 2961 gtk_widget_show(lbox); |
2962 | |
2963 /* Setup the label telling how many people are in the room. */ | |
2964 gtkchat->count = gtk_label_new(_("0 people in room")); | |
2965 gtk_box_pack_start(GTK_BOX(lbox), gtkchat->count, FALSE, FALSE, 0); | |
2966 gtk_widget_show(gtkchat->count); | |
2967 | |
2968 /* Setup the list of users. */ | |
2969 sw2 = gtk_scrolled_window_new(NULL, NULL); | |
2970 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw2), | |
2971 GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC); | |
2972 gtk_box_pack_start(GTK_BOX(lbox), sw2, TRUE, TRUE, 0); | |
2973 gtk_widget_show(sw2); | |
2974 | |
2975 ls = gtk_list_store_new(2, G_TYPE_STRING, G_TYPE_STRING); | |
2976 gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(ls), 1, | |
2977 GTK_SORT_ASCENDING); | |
2978 | |
2979 list = gtk_tree_view_new_with_model(GTK_TREE_MODEL(ls)); | |
2980 | |
2981 rend = gtk_cell_renderer_text_new(); | |
2982 col = gtk_tree_view_column_new_with_attributes(NULL, rend, | |
2983 "text", 0, NULL); | |
2984 gtk_tree_view_column_set_clickable(GTK_TREE_VIEW_COLUMN(col), TRUE); | |
2985 | |
2986 g_signal_connect(G_OBJECT(list), "button_press_event", | |
2987 G_CALLBACK(right_click_chat_cb), conv); | |
2988 | |
2989 gtk_tree_view_append_column(GTK_TREE_VIEW(list), col); | |
2990 | |
2991 col = gtk_tree_view_column_new_with_attributes(NULL, rend, | |
2992 "text", 1, NULL); | |
2993 gtk_tree_view_column_set_clickable(GTK_TREE_VIEW_COLUMN(col), TRUE); | |
2994 | |
2995 #if 0 | |
2996 g_signal_connect(G_OBJECT(list), "button_press_event", | |
2997 G_CALLBACK(right_click_chat), conv); | |
2998 #endif | |
2999 | |
3000 gtk_tree_view_append_column(GTK_TREE_VIEW(list), col); | |
3001 | |
3002 gtk_widget_set_size_request(list, 150, -1); | |
3003 | |
3004 gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(list), FALSE); | |
3005 gtk_widget_show(list); | |
3006 | |
3007 gtkchat->list = list; | |
3008 | |
3009 gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(sw2), list); | |
3010 | |
3011 /* Setup the user list toolbar. */ | |
3012 bbox = gtk_hbox_new(TRUE, 5); | |
3013 gtk_box_pack_start(GTK_BOX(lbox), bbox, FALSE, FALSE, 0); | |
3014 gtk_widget_show(bbox); | |
3015 | |
3016 /* IM */ | |
3017 button = gaim_pixbuf_button_from_stock(NULL, GTK_STOCK_REDO, | |
3018 GAIM_BUTTON_VERTICAL); | |
3019 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE); | |
3020 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
|
3021 gtk_tooltips_set_tip(gtkconv->tooltips, button, _("IM the user"), NULL); |
4359 | 3022 g_signal_connect(G_OBJECT(button), "clicked", |
3023 G_CALLBACK(im_cb), conv); | |
3024 | |
3025 gtk_widget_show(button); | |
3026 | |
3027 /* Ignore */ | |
3028 button = gaim_pixbuf_button_from_stock(NULL, GAIM_STOCK_IGNORE, | |
3029 GAIM_BUTTON_VERTICAL); | |
3030 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE); | |
3031 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
|
3032 gtk_tooltips_set_tip(gtkconv->tooltips, button, |
d856987c72ca
[gaim-migrate @ 4636]
Christian Hammond <chipx86@chipx86.com>
parents:
4369
diff
changeset
|
3033 _("Ignore the user"), NULL); |
4359 | 3034 g_signal_connect(G_OBJECT(button), "clicked", |
3035 G_CALLBACK(ignore_cb), conv); | |
3036 gtk_widget_show(button); | |
3037 | |
3038 /* Info */ | |
3039 button = gaim_pixbuf_button_from_stock(NULL, GAIM_STOCK_INFO, | |
3040 GAIM_BUTTON_VERTICAL); | |
3041 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE); | |
3042 gtk_box_pack_start(GTK_BOX(bbox), button, FALSE, FALSE, 0); | |
3043 gtk_tooltips_set_tip(gtkconv->tooltips, button, | |
4370
d856987c72ca
[gaim-migrate @ 4636]
Christian Hammond <chipx86@chipx86.com>
parents:
4369
diff
changeset
|
3044 _("Get the user's information"), NULL); |
4359 | 3045 g_signal_connect(G_OBJECT(button), "clicked", |
3046 G_CALLBACK(info_cb), conv); | |
3047 | |
3048 gtk_widget_show(button); | |
3049 | |
3050 gtkconv->info = button; | |
3051 | |
4963
7f5e7f2ef317
[gaim-migrate @ 5297]
Christian Hammond <chipx86@chipx86.com>
parents:
4958
diff
changeset
|
3052 /* Build the toolbar. */ |
7f5e7f2ef317
[gaim-migrate @ 5297]
Christian Hammond <chipx86@chipx86.com>
parents:
4958
diff
changeset
|
3053 vbox = gtk_vbox_new(FALSE, 5); |
7f5e7f2ef317
[gaim-migrate @ 5297]
Christian Hammond <chipx86@chipx86.com>
parents:
4958
diff
changeset
|
3054 gtk_paned_pack2(GTK_PANED(vpaned), vbox, FALSE, FALSE); |
7f5e7f2ef317
[gaim-migrate @ 5297]
Christian Hammond <chipx86@chipx86.com>
parents:
4958
diff
changeset
|
3055 gtk_widget_show(vbox); |
7f5e7f2ef317
[gaim-migrate @ 5297]
Christian Hammond <chipx86@chipx86.com>
parents:
4958
diff
changeset
|
3056 |
7f5e7f2ef317
[gaim-migrate @ 5297]
Christian Hammond <chipx86@chipx86.com>
parents:
4958
diff
changeset
|
3057 gtkconv->toolbar.toolbar = build_conv_toolbar(conv); |
7f5e7f2ef317
[gaim-migrate @ 5297]
Christian Hammond <chipx86@chipx86.com>
parents:
4958
diff
changeset
|
3058 gtk_box_pack_start(GTK_BOX(vbox), gtkconv->toolbar.toolbar, |
7f5e7f2ef317
[gaim-migrate @ 5297]
Christian Hammond <chipx86@chipx86.com>
parents:
4958
diff
changeset
|
3059 FALSE, FALSE, 0); |
7f5e7f2ef317
[gaim-migrate @ 5297]
Christian Hammond <chipx86@chipx86.com>
parents:
4958
diff
changeset
|
3060 |
7f5e7f2ef317
[gaim-migrate @ 5297]
Christian Hammond <chipx86@chipx86.com>
parents:
4958
diff
changeset
|
3061 /* Setup the entry widget. */ |
7f5e7f2ef317
[gaim-migrate @ 5297]
Christian Hammond <chipx86@chipx86.com>
parents:
4958
diff
changeset
|
3062 frame = gtk_frame_new(NULL); |
7f5e7f2ef317
[gaim-migrate @ 5297]
Christian Hammond <chipx86@chipx86.com>
parents:
4958
diff
changeset
|
3063 gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_IN); |
7f5e7f2ef317
[gaim-migrate @ 5297]
Christian Hammond <chipx86@chipx86.com>
parents:
4958
diff
changeset
|
3064 gtk_box_pack_start(GTK_BOX(vbox), frame, TRUE, TRUE, 0); |
7f5e7f2ef317
[gaim-migrate @ 5297]
Christian Hammond <chipx86@chipx86.com>
parents:
4958
diff
changeset
|
3065 gtk_widget_show(frame); |
7f5e7f2ef317
[gaim-migrate @ 5297]
Christian Hammond <chipx86@chipx86.com>
parents:
4958
diff
changeset
|
3066 |
7f5e7f2ef317
[gaim-migrate @ 5297]
Christian Hammond <chipx86@chipx86.com>
parents:
4958
diff
changeset
|
3067 gtkconv->entry_buffer = gtk_text_buffer_new(NULL); |
7f5e7f2ef317
[gaim-migrate @ 5297]
Christian Hammond <chipx86@chipx86.com>
parents:
4958
diff
changeset
|
3068 g_object_set_data(G_OBJECT(gtkconv->entry_buffer), "user_data", conv); |
7f5e7f2ef317
[gaim-migrate @ 5297]
Christian Hammond <chipx86@chipx86.com>
parents:
4958
diff
changeset
|
3069 gtkconv->entry = gtk_text_view_new_with_buffer(gtkconv->entry_buffer); |
7f5e7f2ef317
[gaim-migrate @ 5297]
Christian Hammond <chipx86@chipx86.com>
parents:
4958
diff
changeset
|
3070 |
7f5e7f2ef317
[gaim-migrate @ 5297]
Christian Hammond <chipx86@chipx86.com>
parents:
4958
diff
changeset
|
3071 gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(gtkconv->entry), GTK_WRAP_WORD); |
7f5e7f2ef317
[gaim-migrate @ 5297]
Christian Hammond <chipx86@chipx86.com>
parents:
4958
diff
changeset
|
3072 gtk_widget_set_size_request(gtkconv->entry, -1, |
7f5e7f2ef317
[gaim-migrate @ 5297]
Christian Hammond <chipx86@chipx86.com>
parents:
4958
diff
changeset
|
3073 MAX(buddy_chat_size.entry_height, 25)); |
4359 | 3074 |
3075 /* Connect the signal handlers. */ | |
3076 g_signal_connect_swapped(G_OBJECT(gtkconv->entry), "key_press_event", | |
3077 G_CALLBACK(entry_key_pressed_cb_1), | |
3078 gtkconv->entry_buffer); | |
3079 g_signal_connect_after(G_OBJECT(gtkconv->entry), "button_press_event", | |
3080 G_CALLBACK(entry_stop_rclick_cb), NULL); | |
3081 g_signal_connect(G_OBJECT(gtkconv->entry), "key_press_event", | |
3082 G_CALLBACK(entry_key_pressed_cb_2), conv); | |
3083 | |
3084 #ifdef USE_GTKSPELL | |
3085 if (convo_options & OPT_CONVO_CHECK_SPELLING) | |
3086 gtkspell_new_attach(GTK_TEXT_VIEW(gtkconv->entry), NULL, NULL); | |
3087 #endif | |
3088 | |
3089 gtk_container_add(GTK_CONTAINER(frame), GTK_WIDGET(gtkconv->entry)); | |
3090 gtk_widget_show(gtkconv->entry); | |
3091 | |
3092 /* Setup the bottom button box. */ | |
3093 gtkconv->bbox = gtk_hbox_new(FALSE, 5); | |
3094 gtk_box_pack_start(GTK_BOX(vbox), gtkconv->bbox, FALSE, FALSE, 0); | |
3095 gtk_widget_show(gtkconv->bbox); | |
3096 | |
3097 setup_chat_buttons(conv, gtkconv->bbox); | |
3098 | |
3099 return vpaned; | |
3100 } | |
3101 | |
3102 static GtkWidget * | |
3103 setup_im_pane(struct gaim_conversation *conv) | |
3104 { | |
3105 struct gaim_gtk_conversation *gtkconv; | |
3106 struct gaim_gtk_im_pane *gtkim; | |
3107 GtkWidget *paned; | |
3108 GtkWidget *vbox; | |
3109 GtkWidget *vbox2; | |
3110 GtkWidget *frame; | |
3111 | |
3112 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
3113 gtkim = gtkconv->u.im; | |
3114 | |
3115 /* Setup the outer pane. */ | |
3116 paned = gtk_vpaned_new(); | |
3117 gtk_widget_show(paned); | |
3118 | |
3119 /* Setup the top part of the pane. */ | |
3120 vbox = gtk_vbox_new(FALSE, 5); | |
4409
0521eec12c33
[gaim-migrate @ 4682]
Christian Hammond <chipx86@chipx86.com>
parents:
4398
diff
changeset
|
3121 gtk_paned_pack1(GTK_PANED(paned), vbox, TRUE, TRUE); |
4359 | 3122 gtk_widget_show(vbox); |
3123 | |
3124 /* Setup the gtkimhtml widget. */ | |
3125 gtkconv->sw = gtk_scrolled_window_new(NULL, NULL); | |
3126 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(gtkconv->sw), | |
3127 GTK_POLICY_NEVER, GTK_POLICY_ALWAYS); | |
3128 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(gtkconv->sw), | |
3129 GTK_SHADOW_IN); | |
4963
7f5e7f2ef317
[gaim-migrate @ 5297]
Christian Hammond <chipx86@chipx86.com>
parents:
4958
diff
changeset
|
3130 gtk_box_pack_start(GTK_BOX(vbox), gtkconv->sw, TRUE, TRUE, 0); |
4851 | 3131 |
4359 | 3132 gtk_widget_set_size_request(gtkconv->sw, conv_size.width, conv_size.height); |
3133 gtk_widget_show(gtkconv->sw); | |
3134 | |
3135 gtkconv->imhtml = gtk_imhtml_new(NULL, NULL); | |
3136 gtk_container_add(GTK_CONTAINER(gtkconv->sw), gtkconv->imhtml); | |
3137 | |
3138 g_signal_connect_after(G_OBJECT(gtkconv->imhtml), "button_press_event", | |
3139 G_CALLBACK(entry_stop_rclick_cb), NULL); | |
3140 | |
3141 gtk_imhtml_show_comments(GTK_IMHTML(gtkconv->imhtml), | |
3142 (convo_options & OPT_CONVO_SHOW_TIME)); | |
3143 | |
3144 gaim_setup_imhtml(gtkconv->imhtml); | |
3145 | |
3146 gtk_widget_show(gtkconv->imhtml); | |
3147 | |
4963
7f5e7f2ef317
[gaim-migrate @ 5297]
Christian Hammond <chipx86@chipx86.com>
parents:
4958
diff
changeset
|
3148 vbox2 = gtk_vbox_new(FALSE, 5); |
7f5e7f2ef317
[gaim-migrate @ 5297]
Christian Hammond <chipx86@chipx86.com>
parents:
4958
diff
changeset
|
3149 gtk_paned_pack2(GTK_PANED(paned), vbox2, FALSE, FALSE); |
7f5e7f2ef317
[gaim-migrate @ 5297]
Christian Hammond <chipx86@chipx86.com>
parents:
4958
diff
changeset
|
3150 gtk_widget_show(vbox2); |
7f5e7f2ef317
[gaim-migrate @ 5297]
Christian Hammond <chipx86@chipx86.com>
parents:
4958
diff
changeset
|
3151 |
7f5e7f2ef317
[gaim-migrate @ 5297]
Christian Hammond <chipx86@chipx86.com>
parents:
4958
diff
changeset
|
3152 /* Build the toolbar. */ |
7f5e7f2ef317
[gaim-migrate @ 5297]
Christian Hammond <chipx86@chipx86.com>
parents:
4958
diff
changeset
|
3153 gtkconv->toolbar.toolbar = build_conv_toolbar(conv); |
7f5e7f2ef317
[gaim-migrate @ 5297]
Christian Hammond <chipx86@chipx86.com>
parents:
4958
diff
changeset
|
3154 gtk_box_pack_start(GTK_BOX(vbox2), gtkconv->toolbar.toolbar, |
7f5e7f2ef317
[gaim-migrate @ 5297]
Christian Hammond <chipx86@chipx86.com>
parents:
4958
diff
changeset
|
3155 FALSE, FALSE, 0); |
7f5e7f2ef317
[gaim-migrate @ 5297]
Christian Hammond <chipx86@chipx86.com>
parents:
4958
diff
changeset
|
3156 |
7f5e7f2ef317
[gaim-migrate @ 5297]
Christian Hammond <chipx86@chipx86.com>
parents:
4958
diff
changeset
|
3157 /* Setup the entry widget. */ |
7f5e7f2ef317
[gaim-migrate @ 5297]
Christian Hammond <chipx86@chipx86.com>
parents:
4958
diff
changeset
|
3158 frame = gtk_frame_new(NULL); |
7f5e7f2ef317
[gaim-migrate @ 5297]
Christian Hammond <chipx86@chipx86.com>
parents:
4958
diff
changeset
|
3159 gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_IN); |
7f5e7f2ef317
[gaim-migrate @ 5297]
Christian Hammond <chipx86@chipx86.com>
parents:
4958
diff
changeset
|
3160 gtk_box_pack_start(GTK_BOX(vbox2), frame, TRUE, TRUE, 0); |
7f5e7f2ef317
[gaim-migrate @ 5297]
Christian Hammond <chipx86@chipx86.com>
parents:
4958
diff
changeset
|
3161 gtk_widget_show(frame); |
7f5e7f2ef317
[gaim-migrate @ 5297]
Christian Hammond <chipx86@chipx86.com>
parents:
4958
diff
changeset
|
3162 |
7f5e7f2ef317
[gaim-migrate @ 5297]
Christian Hammond <chipx86@chipx86.com>
parents:
4958
diff
changeset
|
3163 gtkconv->entry_buffer = gtk_text_buffer_new(NULL); |
7f5e7f2ef317
[gaim-migrate @ 5297]
Christian Hammond <chipx86@chipx86.com>
parents:
4958
diff
changeset
|
3164 g_object_set_data(G_OBJECT(gtkconv->entry_buffer), "user_data", conv); |
7f5e7f2ef317
[gaim-migrate @ 5297]
Christian Hammond <chipx86@chipx86.com>
parents:
4958
diff
changeset
|
3165 gtkconv->entry = gtk_text_view_new_with_buffer(gtkconv->entry_buffer); |
7f5e7f2ef317
[gaim-migrate @ 5297]
Christian Hammond <chipx86@chipx86.com>
parents:
4958
diff
changeset
|
3166 |
7f5e7f2ef317
[gaim-migrate @ 5297]
Christian Hammond <chipx86@chipx86.com>
parents:
4958
diff
changeset
|
3167 gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(gtkconv->entry), GTK_WRAP_WORD); |
7f5e7f2ef317
[gaim-migrate @ 5297]
Christian Hammond <chipx86@chipx86.com>
parents:
4958
diff
changeset
|
3168 gtk_widget_set_size_request(gtkconv->entry, -1, |
7f5e7f2ef317
[gaim-migrate @ 5297]
Christian Hammond <chipx86@chipx86.com>
parents:
4958
diff
changeset
|
3169 MAX(conv_size.entry_height, 25)); |
7f5e7f2ef317
[gaim-migrate @ 5297]
Christian Hammond <chipx86@chipx86.com>
parents:
4958
diff
changeset
|
3170 |
4359 | 3171 /* Connect the signal handlers. */ |
3172 g_signal_connect_swapped(G_OBJECT(gtkconv->entry), "key_press_event", | |
3173 G_CALLBACK(entry_key_pressed_cb_1), | |
3174 gtkconv->entry_buffer); | |
3175 g_signal_connect(G_OBJECT(gtkconv->entry), "key_press_event", | |
3176 G_CALLBACK(entry_key_pressed_cb_2), conv); | |
3177 g_signal_connect_after(G_OBJECT(gtkconv->entry), "button_press_event", | |
3178 G_CALLBACK(entry_stop_rclick_cb), NULL); | |
3179 | |
3180 g_signal_connect(G_OBJECT(gtkconv->entry_buffer), "insert_text", | |
3181 G_CALLBACK(insert_text_cb), conv); | |
3182 g_signal_connect(G_OBJECT(gtkconv->entry_buffer), "delete_range", | |
3183 G_CALLBACK(delete_text_cb), conv); | |
3184 | |
3185 #ifdef USE_GTKSPELL | |
3186 if (convo_options & OPT_CONVO_CHECK_SPELLING) | |
3187 gtkspell_new_attach(GTK_TEXT_VIEW(gtkconv->entry), NULL, NULL); | |
3188 #endif | |
3189 | |
3190 gtk_container_add(GTK_CONTAINER(frame), GTK_WIDGET(gtkconv->entry)); | |
3191 gtk_widget_show(gtkconv->entry); | |
3192 | |
3193 gtkconv->bbox = gtk_hbox_new(FALSE, 5); | |
3194 gtk_box_pack_start(GTK_BOX(vbox2), gtkconv->bbox, FALSE, FALSE, 0); | |
3195 gtk_widget_show(gtkconv->bbox); | |
3196 | |
3197 setup_im_buttons(conv, gtkconv->bbox); | |
3198 | |
3199 return paned; | |
3200 } | |
3201 | |
3202 static void | |
3203 move_next_tab(struct gaim_conversation *conv) | |
3204 { | |
3205 struct gaim_conversation *next_conv = NULL; | |
3206 struct gaim_window *win; | |
3207 GList *l; | |
3208 int index, i; | |
3209 | |
3210 win = gaim_conversation_get_window(conv); | |
3211 index = gaim_conversation_get_index(conv); | |
3212 | |
3213 /* First check the tabs after this position. */ | |
3214 for (l = g_list_nth(gaim_window_get_conversations(win), index); | |
3215 l != NULL; | |
3216 l = l->next) { | |
3217 | |
3218 next_conv = (struct gaim_conversation *)l->data; | |
3219 | |
3220 if (gaim_conversation_get_unseen(next_conv) > 0) | |
3221 break; | |
3222 | |
3223 next_conv = NULL; | |
3224 } | |
3225 | |
3226 if (next_conv == NULL) { | |
3227 | |
3228 /* Now check before this position. */ | |
3229 for (l = gaim_window_get_conversations(win), i = 0; | |
3230 l != NULL && i < index; | |
3231 l = l->next) { | |
3232 | |
3233 next_conv = (struct gaim_conversation *)l->data; | |
3234 | |
3235 if (gaim_conversation_get_unseen(next_conv) > 0) | |
3236 break; | |
3237 | |
3238 next_conv = NULL; | |
3239 } | |
3240 | |
3241 if (next_conv == NULL) { | |
3242 /* Okay, just grab the next conversation tab. */ | |
3243 if (index == gaim_window_get_conversation_count(win) - 1) | |
3244 next_conv = gaim_window_get_conversation_at(win, 0); | |
3245 else | |
3246 next_conv = gaim_window_get_conversation_at(win, index + 1); | |
3247 } | |
3248 } | |
3249 | |
3250 if (next_conv != NULL && next_conv != conv) { | |
3251 gaim_window_switch_conversation(win, | |
3252 gaim_conversation_get_index(next_conv)); | |
3253 } | |
3254 } | |
3255 | |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3256 static void |
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3257 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
|
3258 GtkSelectionData *sd, guint info, guint t, |
4d50e125b0fa
[gaim-migrate @ 5273]
Christian Hammond <chipx86@chipx86.com>
parents:
4931
diff
changeset
|
3259 struct gaim_conversation *conv) |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3260 { |
4781 | 3261 struct gaim_window *win = conv->window; |
3262 struct gaim_conversation *c; | |
4939
4d50e125b0fa
[gaim-migrate @ 5273]
Christian Hammond <chipx86@chipx86.com>
parents:
4931
diff
changeset
|
3263 |
4d50e125b0fa
[gaim-migrate @ 5273]
Christian Hammond <chipx86@chipx86.com>
parents:
4931
diff
changeset
|
3264 if (sd->target == gdk_atom_intern("GAIM_BLIST_NODE", FALSE)) { |
4781 | 3265 GaimBlistNode *n = NULL; |
3266 memcpy(&n, sd->data, sizeof(n)); | |
4939
4d50e125b0fa
[gaim-migrate @ 5273]
Christian Hammond <chipx86@chipx86.com>
parents:
4931
diff
changeset
|
3267 |
4781 | 3268 if (!GAIM_BLIST_NODE_IS_BUDDY(n)) |
3269 return; | |
4939
4d50e125b0fa
[gaim-migrate @ 5273]
Christian Hammond <chipx86@chipx86.com>
parents:
4931
diff
changeset
|
3270 |
4d50e125b0fa
[gaim-migrate @ 5273]
Christian Hammond <chipx86@chipx86.com>
parents:
4931
diff
changeset
|
3271 c = gaim_conversation_new(GAIM_CONV_IM, |
4d50e125b0fa
[gaim-migrate @ 5273]
Christian Hammond <chipx86@chipx86.com>
parents:
4931
diff
changeset
|
3272 ((struct buddy *)n)->account, |
4d50e125b0fa
[gaim-migrate @ 5273]
Christian Hammond <chipx86@chipx86.com>
parents:
4931
diff
changeset
|
3273 ((struct buddy *)n)->name); |
4d50e125b0fa
[gaim-migrate @ 5273]
Christian Hammond <chipx86@chipx86.com>
parents:
4931
diff
changeset
|
3274 |
4d50e125b0fa
[gaim-migrate @ 5273]
Christian Hammond <chipx86@chipx86.com>
parents:
4931
diff
changeset
|
3275 gaim_window_add_conversation(win, c); |
4702 | 3276 } |
3277 | |
4939
4d50e125b0fa
[gaim-migrate @ 5273]
Christian Hammond <chipx86@chipx86.com>
parents:
4931
diff
changeset
|
3278 /* do_error_dialog("MWAHAHAHA! I AM A TROLL! I AM GOING TO EAT YOU!", |
4d50e125b0fa
[gaim-migrate @ 5273]
Christian Hammond <chipx86@chipx86.com>
parents:
4931
diff
changeset
|
3279 NULL, GAIM_WARNING); */ |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3280 } |
4359 | 3281 |
3282 /************************************************************************** | |
3283 * GTK+ window ops | |
3284 **************************************************************************/ | |
4465
6e37eb000b7a
[gaim-migrate @ 4740]
Christian Hammond <chipx86@chipx86.com>
parents:
4454
diff
changeset
|
3285 static struct gaim_conversation_ui_ops * |
6e37eb000b7a
[gaim-migrate @ 4740]
Christian Hammond <chipx86@chipx86.com>
parents:
4454
diff
changeset
|
3286 gaim_gtk_get_conversation_ui_ops(void) |
4359 | 3287 { |
4465
6e37eb000b7a
[gaim-migrate @ 4740]
Christian Hammond <chipx86@chipx86.com>
parents:
4454
diff
changeset
|
3288 return gaim_get_gtk_conversation_ui_ops(); |
4359 | 3289 } |
3290 | |
3291 static void | |
3292 gaim_gtk_new_window(struct gaim_window *win) | |
3293 { | |
3294 struct gaim_gtk_window *gtkwin; | |
3295 GtkPositionType pos; | |
3296 GtkWidget *testidea; | |
3297 GtkWidget *menubar; | |
3298 | |
3299 gtkwin = g_malloc0(sizeof(struct gaim_gtk_window)); | |
3300 | |
3301 win->ui_data = gtkwin; | |
3302 | |
3303 /* Create the window. */ | |
3304 gtkwin->window = gtk_window_new(GTK_WINDOW_TOPLEVEL); | |
3305 gtk_window_set_role(GTK_WINDOW(gtkwin->window), "conversation"); | |
4635 | 3306 gtk_window_set_resizable(GTK_WINDOW(gtkwin->window), TRUE); |
4510
4c394222c732
[gaim-migrate @ 4786]
Christian Hammond <chipx86@chipx86.com>
parents:
4505
diff
changeset
|
3307 gtk_container_set_border_width(GTK_CONTAINER(gtkwin->window), 0); |
4359 | 3308 gtk_widget_realize(gtkwin->window); |
3309 | |
3310 g_signal_connect(G_OBJECT(gtkwin->window), "delete_event", | |
3311 G_CALLBACK(close_win_cb), win); | |
3312 | |
3313 /* Create the notebook. */ | |
3314 gtkwin->notebook = gtk_notebook_new(); | |
3315 | |
3316 pos = ((im_options & OPT_IM_SIDE_TAB) | |
3317 ? ((im_options & OPT_IM_BR_TAB) ? GTK_POS_RIGHT : GTK_POS_LEFT) | |
3318 : ((im_options & OPT_IM_BR_TAB) ? GTK_POS_BOTTOM : GTK_POS_TOP)); | |
3319 | |
3320 #if 0 | |
3321 gtk_notebook_set_tab_hborder(GTK_NOTEBOOK(gtkwin->notebook), 0); | |
3322 gtk_notebook_set_tab_vborder(GTK_NOTEBOOK(gtkwin->notebook), 0); | |
3323 #endif | |
3324 gtk_notebook_set_tab_pos(GTK_NOTEBOOK(gtkwin->notebook), pos); | |
3325 gtk_notebook_set_scrollable(GTK_NOTEBOOK(gtkwin->notebook), TRUE); | |
3326 gtk_notebook_popup_enable(GTK_NOTEBOOK(gtkwin->notebook)); | |
4818 | 3327 gtk_notebook_set_show_tabs(GTK_NOTEBOOK(gtkwin->notebook), FALSE); |
3328 | |
4359 | 3329 gtk_widget_show(gtkwin->notebook); |
3330 | |
3331 g_signal_connect_after(G_OBJECT(gtkwin->notebook), "switch_page", | |
3332 G_CALLBACK(switch_conv_cb), win); | |
3333 | |
3334 /* Setup the tab drag and drop signals. */ | |
4486 | 3335 gtk_widget_add_events(gtkwin->notebook, |
3336 GDK_BUTTON1_MOTION_MASK | GDK_LEAVE_NOTIFY_MASK); | |
3337 g_signal_connect(G_OBJECT(gtkwin->notebook), "button_press_event", | |
4572
06084165a966
[gaim-migrate @ 4853]
Christian Hammond <chipx86@chipx86.com>
parents:
4571
diff
changeset
|
3338 G_CALLBACK(notebook_press_cb), win); |
4486 | 3339 g_signal_connect(G_OBJECT(gtkwin->notebook), "button_release_event", |
4572
06084165a966
[gaim-migrate @ 4853]
Christian Hammond <chipx86@chipx86.com>
parents:
4571
diff
changeset
|
3340 G_CALLBACK(notebook_release_cb), win); |
06084165a966
[gaim-migrate @ 4853]
Christian Hammond <chipx86@chipx86.com>
parents:
4571
diff
changeset
|
3341 |
4359 | 3342 testidea = gtk_vbox_new(FALSE, 0); |
4572
06084165a966
[gaim-migrate @ 4853]
Christian Hammond <chipx86@chipx86.com>
parents:
4571
diff
changeset
|
3343 |
4359 | 3344 /* Setup the menubar. */ |
3345 menubar = setup_menubar(win); | |
3346 gtk_box_pack_start(GTK_BOX(testidea), menubar, FALSE, TRUE, 0); | |
3347 | |
3348 gtk_box_pack_start(GTK_BOX(testidea), gtkwin->notebook, TRUE, TRUE, 0); | |
3349 | |
3350 gtk_container_add(GTK_CONTAINER(gtkwin->window), testidea); | |
3351 | |
3352 gtk_widget_show(testidea); | |
3353 } | |
3354 | |
3355 static void | |
3356 gaim_gtk_destroy_window(struct gaim_window *win) | |
3357 { | |
3358 struct gaim_gtk_window *gtkwin = GAIM_GTK_WINDOW(win); | |
3359 | |
3360 gtk_widget_destroy(gtkwin->window); | |
3361 | |
4630 | 3362 g_object_unref(G_OBJECT(gtkwin->menu.item_factory)); |
3363 | |
4359 | 3364 g_free(gtkwin); |
3365 win->ui_data = NULL; | |
3366 } | |
3367 | |
3368 static void | |
3369 gaim_gtk_show(struct gaim_window *win) | |
3370 { | |
3371 struct gaim_gtk_window *gtkwin = GAIM_GTK_WINDOW(win); | |
3372 | |
3373 gtk_widget_show(gtkwin->window); | |
3374 } | |
3375 | |
3376 static void | |
3377 gaim_gtk_hide(struct gaim_window *win) | |
3378 { | |
3379 struct gaim_gtk_window *gtkwin = GAIM_GTK_WINDOW(win); | |
3380 | |
3381 gtk_widget_hide(gtkwin->window); | |
3382 } | |
3383 | |
3384 static void | |
3385 gaim_gtk_raise(struct gaim_window *win) | |
3386 { | |
3387 struct gaim_gtk_window *gtkwin = GAIM_GTK_WINDOW(win); | |
3388 | |
4526 | 3389 gdk_window_raise(gtkwin->window->window); |
4359 | 3390 } |
3391 | |
3392 static void | |
3393 gaim_gtk_flash(struct gaim_window *win) | |
3394 { | |
3395 #ifdef _WIN32 | |
3396 struct gaim_gtk_window *gtkwin = GAIM_GTK_WINDOW(win); | |
3397 | |
3398 wgaim_im_blink(gtkwin->window); | |
3399 #endif | |
3400 } | |
3401 | |
3402 static void | |
3403 gaim_gtk_switch_conversation(struct gaim_window *win, unsigned int index) | |
3404 { | |
3405 struct gaim_gtk_window *gtkwin; | |
3406 | |
3407 gtkwin = GAIM_GTK_WINDOW(win); | |
3408 | |
3409 gtk_notebook_set_current_page(GTK_NOTEBOOK(gtkwin->notebook), index); | |
3410 } | |
3411 | |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3412 static const GtkTargetEntry te[] = |
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3413 { |
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3414 {"text/plain", 0, 0}, |
4702 | 3415 {"text/uri-list", 0, 1}, |
4781 | 3416 {"GAIM_BLIST_NODE", 0, 2}, |
4702 | 3417 {"STRING", 0, 3} |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3418 }; |
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3419 |
4359 | 3420 static void |
3421 gaim_gtk_add_conversation(struct gaim_window *win, | |
3422 struct gaim_conversation *conv) | |
3423 { | |
3424 struct gaim_gtk_window *gtkwin; | |
3425 struct gaim_gtk_conversation *gtkconv; | |
3426 GtkWidget *pane = NULL; | |
3427 GtkWidget *tab_cont; | |
3428 GtkWidget *tabby; | |
3429 gboolean new_ui; | |
4383
f7a84034f97f
[gaim-migrate @ 4649]
Christian Hammond <chipx86@chipx86.com>
parents:
4382
diff
changeset
|
3430 GaimConversationType conv_type; |
f7a84034f97f
[gaim-migrate @ 4649]
Christian Hammond <chipx86@chipx86.com>
parents:
4382
diff
changeset
|
3431 const char *name; |
f7a84034f97f
[gaim-migrate @ 4649]
Christian Hammond <chipx86@chipx86.com>
parents:
4382
diff
changeset
|
3432 |
f7a84034f97f
[gaim-migrate @ 4649]
Christian Hammond <chipx86@chipx86.com>
parents:
4382
diff
changeset
|
3433 name = gaim_conversation_get_name(conv); |
f7a84034f97f
[gaim-migrate @ 4649]
Christian Hammond <chipx86@chipx86.com>
parents:
4382
diff
changeset
|
3434 conv_type = gaim_conversation_get_type(conv); |
f7a84034f97f
[gaim-migrate @ 4649]
Christian Hammond <chipx86@chipx86.com>
parents:
4382
diff
changeset
|
3435 gtkwin = GAIM_GTK_WINDOW(win); |
4359 | 3436 |
3437 if (conv->ui_data != NULL) { | |
3438 gtkconv = (struct gaim_gtk_conversation *)conv->ui_data; | |
3439 | |
3440 tab_cont = gtkconv->tab_cont; | |
3441 | |
3442 new_ui = FALSE; | |
3443 } | |
3444 else { | |
3445 gtkconv = g_malloc0(sizeof(struct gaim_gtk_conversation)); | |
3446 conv->ui_data = gtkconv; | |
3447 | |
3448 /* Setup some initial variables. */ | |
3449 gtkconv->sg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL); | |
3450 gtkconv->tooltips = gtk_tooltips_new(); | |
3451 | |
4421 | 3452 /* Setup the foreground and background colors */ |
3453 gaim_gtkconv_update_font_colors(conv); | |
3454 | |
4438
2054d8429925
[gaim-migrate @ 4713]
Christian Hammond <chipx86@chipx86.com>
parents:
4421
diff
changeset
|
3455 /* Setup the font face */ |
2054d8429925
[gaim-migrate @ 4713]
Christian Hammond <chipx86@chipx86.com>
parents:
4421
diff
changeset
|
3456 gaim_gtkconv_update_font_face(conv); |
2054d8429925
[gaim-migrate @ 4713]
Christian Hammond <chipx86@chipx86.com>
parents:
4421
diff
changeset
|
3457 |
4383
f7a84034f97f
[gaim-migrate @ 4649]
Christian Hammond <chipx86@chipx86.com>
parents:
4382
diff
changeset
|
3458 if (conv_type == GAIM_CONV_CHAT) { |
4359 | 3459 gtkconv->u.chat = g_malloc0(sizeof(struct gaim_gtk_chat_pane)); |
3460 | |
3461 pane = setup_chat_pane(conv); | |
3462 } | |
4383
f7a84034f97f
[gaim-migrate @ 4649]
Christian Hammond <chipx86@chipx86.com>
parents:
4382
diff
changeset
|
3463 else if (conv_type == GAIM_CONV_IM) { |
4359 | 3464 gtkconv->u.im = g_malloc0(sizeof(struct gaim_gtk_im_pane)); |
3465 gtkconv->u.im->a_virgin = TRUE; | |
3466 | |
3467 pane = setup_im_pane(conv); | |
3468 } | |
3469 | |
3470 if (pane == NULL) { | |
4572
06084165a966
[gaim-migrate @ 4853]
Christian Hammond <chipx86@chipx86.com>
parents:
4571
diff
changeset
|
3471 if (conv_type == GAIM_CONV_CHAT) g_free(gtkconv->u.chat); |
06084165a966
[gaim-migrate @ 4853]
Christian Hammond <chipx86@chipx86.com>
parents:
4571
diff
changeset
|
3472 else if (conv_type == GAIM_CONV_IM) g_free(gtkconv->u.im); |
4359 | 3473 |
3474 g_free(gtkconv); | |
3475 conv->ui_data = NULL; | |
3476 | |
3477 return; | |
3478 } | |
3479 | |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3480 /* Setup drag-and-drop */ |
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3481 gtk_drag_dest_set(pane, |
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3482 GTK_DEST_DEFAULT_MOTION | |
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3483 GTK_DEST_DEFAULT_DROP, |
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3484 te, sizeof(te) / sizeof(GtkTargetEntry), |
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3485 GDK_ACTION_COPY); |
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3486 gtk_drag_dest_set(gtkconv->imhtml, |
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3487 GTK_DEST_DEFAULT_MOTION | |
4702 | 3488 GTK_DEST_DEFAULT_DROP, |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3489 te, sizeof(te) / sizeof(GtkTargetEntry), |
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3490 GDK_ACTION_DEFAULT | GDK_ACTION_COPY | GDK_ACTION_MOVE); |
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3491 gtk_drag_dest_set(gtkconv->entry, |
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3492 GTK_DEST_DEFAULT_MOTION | |
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3493 GTK_DEST_DEFAULT_DROP, |
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3494 te, sizeof(te) / sizeof(GtkTargetEntry), |
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3495 GDK_ACTION_COPY); |
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3496 |
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3497 g_signal_connect(G_OBJECT(pane), "drag_data_received", |
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3498 G_CALLBACK(conv_dnd_recv), conv); |
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3499 g_signal_connect(G_OBJECT(gtkconv->imhtml), "drag_data_received", |
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3500 G_CALLBACK(conv_dnd_recv), conv); |
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3501 #if 0 |
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3502 g_signal_connect(G_OBJECT(gtkconv->entry), "drag_data_received", |
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3503 G_CALLBACK(conv_dnd_recv), conv); |
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3504 #endif |
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3505 |
4383
f7a84034f97f
[gaim-migrate @ 4649]
Christian Hammond <chipx86@chipx86.com>
parents:
4382
diff
changeset
|
3506 /* |
f7a84034f97f
[gaim-migrate @ 4649]
Christian Hammond <chipx86@chipx86.com>
parents:
4382
diff
changeset
|
3507 * Write the New Conversation log string. |
f7a84034f97f
[gaim-migrate @ 4649]
Christian Hammond <chipx86@chipx86.com>
parents:
4382
diff
changeset
|
3508 * |
f7a84034f97f
[gaim-migrate @ 4649]
Christian Hammond <chipx86@chipx86.com>
parents:
4382
diff
changeset
|
3509 * This should probably be elsewhere, but then, logging should |
f7a84034f97f
[gaim-migrate @ 4649]
Christian Hammond <chipx86@chipx86.com>
parents:
4382
diff
changeset
|
3510 * be moved out in some way, either via plugin or via a new API. |
f7a84034f97f
[gaim-migrate @ 4649]
Christian Hammond <chipx86@chipx86.com>
parents:
4382
diff
changeset
|
3511 */ |
f7a84034f97f
[gaim-migrate @ 4649]
Christian Hammond <chipx86@chipx86.com>
parents:
4382
diff
changeset
|
3512 if (gaim_conversation_is_logging(conv) && |
f7a84034f97f
[gaim-migrate @ 4649]
Christian Hammond <chipx86@chipx86.com>
parents:
4382
diff
changeset
|
3513 conv_type != GAIM_CONV_MISC) { |
f7a84034f97f
[gaim-migrate @ 4649]
Christian Hammond <chipx86@chipx86.com>
parents:
4382
diff
changeset
|
3514 |
f7a84034f97f
[gaim-migrate @ 4649]
Christian Hammond <chipx86@chipx86.com>
parents:
4382
diff
changeset
|
3515 FILE *fd; |
f7a84034f97f
[gaim-migrate @ 4649]
Christian Hammond <chipx86@chipx86.com>
parents:
4382
diff
changeset
|
3516 char filename[256]; |
f7a84034f97f
[gaim-migrate @ 4649]
Christian Hammond <chipx86@chipx86.com>
parents:
4382
diff
changeset
|
3517 |
f7a84034f97f
[gaim-migrate @ 4649]
Christian Hammond <chipx86@chipx86.com>
parents:
4382
diff
changeset
|
3518 g_snprintf(filename, sizeof(filename), "%s%s", name, |
f7a84034f97f
[gaim-migrate @ 4649]
Christian Hammond <chipx86@chipx86.com>
parents:
4382
diff
changeset
|
3519 (conv_type == GAIM_CONV_CHAT ? ".chat" : "")); |
f7a84034f97f
[gaim-migrate @ 4649]
Christian Hammond <chipx86@chipx86.com>
parents:
4382
diff
changeset
|
3520 |
f7a84034f97f
[gaim-migrate @ 4649]
Christian Hammond <chipx86@chipx86.com>
parents:
4382
diff
changeset
|
3521 fd = open_log_file(filename, (conv_type == GAIM_CONV_CHAT)); |
f7a84034f97f
[gaim-migrate @ 4649]
Christian Hammond <chipx86@chipx86.com>
parents:
4382
diff
changeset
|
3522 |
f7a84034f97f
[gaim-migrate @ 4649]
Christian Hammond <chipx86@chipx86.com>
parents:
4382
diff
changeset
|
3523 if (fd) { |
f7a84034f97f
[gaim-migrate @ 4649]
Christian Hammond <chipx86@chipx86.com>
parents:
4382
diff
changeset
|
3524 if (!(logging_options & OPT_LOG_STRIP_HTML)) |
f7a84034f97f
[gaim-migrate @ 4649]
Christian Hammond <chipx86@chipx86.com>
parents:
4382
diff
changeset
|
3525 fprintf(fd, |
f7a84034f97f
[gaim-migrate @ 4649]
Christian Hammond <chipx86@chipx86.com>
parents:
4382
diff
changeset
|
3526 "<HR><BR><H3 Align=Center> " |
f7a84034f97f
[gaim-migrate @ 4649]
Christian Hammond <chipx86@chipx86.com>
parents:
4382
diff
changeset
|
3527 "---- New Conversation @ %s ----</H3><BR>\n", |
f7a84034f97f
[gaim-migrate @ 4649]
Christian Hammond <chipx86@chipx86.com>
parents:
4382
diff
changeset
|
3528 full_date()); |
f7a84034f97f
[gaim-migrate @ 4649]
Christian Hammond <chipx86@chipx86.com>
parents:
4382
diff
changeset
|
3529 else |
f7a84034f97f
[gaim-migrate @ 4649]
Christian Hammond <chipx86@chipx86.com>
parents:
4382
diff
changeset
|
3530 fprintf(fd, "---- New Conversation @ %s ----\n", |
f7a84034f97f
[gaim-migrate @ 4649]
Christian Hammond <chipx86@chipx86.com>
parents:
4382
diff
changeset
|
3531 full_date()); |
f7a84034f97f
[gaim-migrate @ 4649]
Christian Hammond <chipx86@chipx86.com>
parents:
4382
diff
changeset
|
3532 |
f7a84034f97f
[gaim-migrate @ 4649]
Christian Hammond <chipx86@chipx86.com>
parents:
4382
diff
changeset
|
3533 fclose(fd); |
f7a84034f97f
[gaim-migrate @ 4649]
Christian Hammond <chipx86@chipx86.com>
parents:
4382
diff
changeset
|
3534 } |
f7a84034f97f
[gaim-migrate @ 4649]
Christian Hammond <chipx86@chipx86.com>
parents:
4382
diff
changeset
|
3535 } |
f7a84034f97f
[gaim-migrate @ 4649]
Christian Hammond <chipx86@chipx86.com>
parents:
4382
diff
changeset
|
3536 |
4359 | 3537 /* Setup the container for the tab. */ |
3538 gtkconv->tab_cont = tab_cont = gtk_vbox_new(FALSE, 5); | |
3539 gtk_container_set_border_width(GTK_CONTAINER(tab_cont), 5); | |
3540 gtk_container_add(GTK_CONTAINER(tab_cont), pane); | |
3541 gtk_widget_show(pane); | |
3542 | |
3543 new_ui = TRUE; | |
4636 | 3544 |
4359 | 3545 gtkconv->make_sound = TRUE; |
3546 } | |
3547 | |
4939
4d50e125b0fa
[gaim-migrate @ 5273]
Christian Hammond <chipx86@chipx86.com>
parents:
4931
diff
changeset
|
3548 g_signal_connect_swapped(G_OBJECT(pane), "focus", |
4d50e125b0fa
[gaim-migrate @ 5273]
Christian Hammond <chipx86@chipx86.com>
parents:
4931
diff
changeset
|
3549 G_CALLBACK(gtk_widget_grab_focus), gtkconv->entry); |
4d50e125b0fa
[gaim-migrate @ 5273]
Christian Hammond <chipx86@chipx86.com>
parents:
4931
diff
changeset
|
3550 |
4359 | 3551 gtkconv->tabby = tabby = gtk_hbox_new(FALSE, 5); |
3552 | |
3553 /* Close button. */ | |
3554 gtkconv->close = gtk_button_new(); | |
3555 gtk_widget_set_size_request(GTK_WIDGET(gtkconv->close), 16, 16); | |
3556 gtk_container_add(GTK_CONTAINER(gtkconv->close), | |
4445 | 3557 gtk_image_new_from_stock(GTK_STOCK_CLOSE, |
3558 GTK_ICON_SIZE_MENU)); | |
4359 | 3559 gtk_button_set_relief(GTK_BUTTON(gtkconv->close), GTK_RELIEF_NONE); |
3560 gtk_tooltips_set_tip(gtkconv->tooltips, gtkconv->close, | |
4572
06084165a966
[gaim-migrate @ 4853]
Christian Hammond <chipx86@chipx86.com>
parents:
4571
diff
changeset
|
3561 _("Close conversation"), NULL); |
4359 | 3562 |
3563 g_signal_connect(G_OBJECT(gtkconv->close), "clicked", | |
4571
51e988d015ed
[gaim-migrate @ 4852]
Christian Hammond <chipx86@chipx86.com>
parents:
4561
diff
changeset
|
3564 G_CALLBACK(close_conv_cb), conv); |
4359 | 3565 |
3566 /* Tab label. */ | |
3567 gtkconv->tab_label = gtk_label_new(gaim_conversation_get_title(conv)); | |
3568 #if 0 | |
3569 gtk_misc_set_alignment(GTK_MISC(gtkconv->tab_label), 0.00, 0.5); | |
3570 gtk_misc_set_padding(GTK_MISC(gtkconv->tab_label), 4, 0); | |
3571 #endif | |
3572 | |
4939
4d50e125b0fa
[gaim-migrate @ 5273]
Christian Hammond <chipx86@chipx86.com>
parents:
4931
diff
changeset
|
3573 |
4359 | 3574 /* Pack it all together. */ |
3575 gtk_box_pack_start(GTK_BOX(tabby), gtkconv->tab_label, TRUE, TRUE, 0); | |
4445 | 3576 gtk_widget_show(gtkconv->tab_label); |
3577 gtk_box_pack_start(GTK_BOX(tabby), gtkconv->close, FALSE, FALSE, 0); | |
3578 if (!(convo_options & OPT_CONVO_NO_X_ON_TAB)) | |
3579 gtk_widget_show_all(gtkconv->close); | |
3580 gtk_widget_show(tabby); | |
4359 | 3581 |
3582 | |
3583 /* Add this pane to the conversations notebook. */ | |
3584 gtk_notebook_append_page(GTK_NOTEBOOK(gtkwin->notebook), tab_cont, tabby); | |
3585 gtk_notebook_set_menu_label_text(GTK_NOTEBOOK(gtkwin->notebook), tab_cont, | |
3586 gaim_conversation_get_title(conv)); | |
3587 | |
3588 gtk_widget_show(tab_cont); | |
3589 | |
4818 | 3590 if (gaim_window_get_conversation_count(win) == 1) { |
3591 /* Er, bug in notebooks? Switch to the page manually. */ | |
4359 | 3592 gtk_notebook_set_current_page(GTK_NOTEBOOK(gtkwin->notebook), 0); |
4851 | 3593 |
3594 if(conv_type == GAIM_CONV_IM) { | |
3595 gtk_notebook_set_show_tabs(GTK_NOTEBOOK(gtkwin->notebook), | |
3596 (im_options & OPT_IM_ONE_WINDOW)); | |
3597 } else if(conv_type == GAIM_CONV_CHAT) { | |
3598 gtk_notebook_set_show_tabs(GTK_NOTEBOOK(gtkwin->notebook), | |
3599 (chat_options & OPT_CHAT_ONE_WINDOW)); | |
3600 } | |
4818 | 3601 } else { |
3602 gtk_notebook_set_show_tabs(GTK_NOTEBOOK(gtkwin->notebook), TRUE); | |
3603 } | |
4359 | 3604 |
3605 if ((gtk_notebook_get_current_page(GTK_NOTEBOOK(gtkwin->notebook)) == 0) || | |
3606 (conv == g_list_nth_data(gaim_window_get_conversations(win), 0))) { | |
3607 | |
3608 gtk_widget_grab_focus(gtkconv->entry); | |
3609 } | |
3610 | |
3611 gaim_gtkconv_update_buddy_icon(conv); | |
3612 | |
3613 if (!new_ui) | |
3614 g_object_unref(gtkconv->tab_cont); | |
3615 | |
3616 if (gaim_window_get_conversation_count(win) == 1) | |
4685 | 3617 g_timeout_add(0, (GSourceFunc)update_send_as_selection, win); |
4359 | 3618 } |
3619 | |
3620 static void | |
3621 gaim_gtk_remove_conversation(struct gaim_window *win, | |
3622 struct gaim_conversation *conv) | |
3623 { | |
3624 struct gaim_gtk_window *gtkwin; | |
3625 struct gaim_gtk_conversation *gtkconv; | |
3626 unsigned int index; | |
4818 | 3627 GaimConversationType conv_type; |
3628 | |
3629 conv_type = gaim_conversation_get_type(conv); | |
4359 | 3630 index = gaim_conversation_get_index(conv); |
3631 | |
3632 gtkwin = GAIM_GTK_WINDOW(win); | |
3633 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
3634 | |
3635 g_object_ref(gtkconv->tab_cont); | |
3636 gtk_object_sink(GTK_OBJECT(gtkconv->tab_cont)); | |
3637 | |
3638 gtk_notebook_remove_page(GTK_NOTEBOOK(gtkwin->notebook), index); | |
3639 | |
4818 | 3640 /* go back to tabless if need be */ |
3641 if (gaim_window_get_conversation_count(win) <= 2) { | |
3642 gtk_notebook_set_show_tabs(GTK_NOTEBOOK(gtkwin->notebook), | |
3643 ((conv_type == GAIM_CONV_IM && im_options & OPT_IM_ONE_WINDOW) || | |
3644 (conv_type == GAIM_CONV_CHAT && im_options & OPT_CHAT_ONE_WINDOW))); | |
3645 } | |
3646 | |
3647 | |
4359 | 3648 /* If this window is setup with an inactive gc, regenerate the menu. */ |
4818 | 3649 if (conv_type == GAIM_CONV_IM && |
4359 | 3650 gaim_conversation_get_gc(conv) == NULL) { |
3651 | |
4360
c435a29370b8
[gaim-migrate @ 4626]
Christian Hammond <chipx86@chipx86.com>
parents:
4359
diff
changeset
|
3652 generate_send_as_items(win, conv); |
4359 | 3653 } |
3654 } | |
3655 | |
3656 static void | |
3657 gaim_gtk_move_conversation(struct gaim_window *win, | |
3658 struct gaim_conversation *conv, | |
3659 unsigned int new_index) | |
3660 { | |
3661 struct gaim_gtk_window *gtkwin; | |
3662 struct gaim_gtk_conversation *gtkconv; | |
3663 | |
3664 gtkwin = GAIM_GTK_WINDOW(win); | |
3665 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
3666 | |
4415
c90039137172
[gaim-migrate @ 4688]
Christian Hammond <chipx86@chipx86.com>
parents:
4409
diff
changeset
|
3667 if (new_index > gaim_conversation_get_index(conv)) |
c90039137172
[gaim-migrate @ 4688]
Christian Hammond <chipx86@chipx86.com>
parents:
4409
diff
changeset
|
3668 new_index--; |
c90039137172
[gaim-migrate @ 4688]
Christian Hammond <chipx86@chipx86.com>
parents:
4409
diff
changeset
|
3669 |
4359 | 3670 gtk_notebook_reorder_child(GTK_NOTEBOOK(gtkwin->notebook), |
3671 gtkconv->tab_cont, new_index); | |
3672 } | |
3673 | |
3674 static int | |
3675 gaim_gtk_get_active_index(const struct gaim_window *win) | |
3676 { | |
3677 struct gaim_gtk_window *gtkwin; | |
3678 | |
3679 gtkwin = GAIM_GTK_WINDOW(win); | |
3680 | |
3681 return gtk_notebook_get_current_page(GTK_NOTEBOOK(gtkwin->notebook)); | |
3682 } | |
3683 | |
4465
6e37eb000b7a
[gaim-migrate @ 4740]
Christian Hammond <chipx86@chipx86.com>
parents:
4454
diff
changeset
|
3684 static struct gaim_window_ui_ops window_ui_ops = |
4359 | 3685 { |
4465
6e37eb000b7a
[gaim-migrate @ 4740]
Christian Hammond <chipx86@chipx86.com>
parents:
4454
diff
changeset
|
3686 gaim_gtk_get_conversation_ui_ops, |
4359 | 3687 gaim_gtk_new_window, |
3688 gaim_gtk_destroy_window, | |
3689 gaim_gtk_show, | |
3690 gaim_gtk_hide, | |
3691 gaim_gtk_raise, | |
3692 gaim_gtk_flash, | |
3693 gaim_gtk_switch_conversation, | |
3694 gaim_gtk_add_conversation, | |
3695 gaim_gtk_remove_conversation, | |
3696 gaim_gtk_move_conversation, | |
3697 gaim_gtk_get_active_index | |
3698 }; | |
3699 | |
3700 static void | |
3701 update_convo_add_button(struct gaim_conversation *conv) | |
3702 { | |
3703 struct gaim_gtk_conversation *gtkconv; | |
3704 struct gaim_connection *gc; | |
3705 GaimConversationType type; | |
3706 GtkWidget *parent; | |
3707 | |
3708 type = gaim_conversation_get_type(conv); | |
3709 gc = gaim_conversation_get_gc(conv); | |
3710 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
3711 parent = gtk_widget_get_parent(gtkconv->u.im->add); | |
3712 | |
4687 | 3713 if (gaim_find_buddy(gc->account, gaim_conversation_get_name(conv))) { |
4397
ce3a0eba91ef
[gaim-migrate @ 4666]
Christian Hammond <chipx86@chipx86.com>
parents:
4387
diff
changeset
|
3714 gtkconv->u.im->add = |
ce3a0eba91ef
[gaim-migrate @ 4666]
Christian Hammond <chipx86@chipx86.com>
parents:
4387
diff
changeset
|
3715 gaim_gtk_change_text(_("Remove"), gtkconv->u.im->add, |
ce3a0eba91ef
[gaim-migrate @ 4666]
Christian Hammond <chipx86@chipx86.com>
parents:
4387
diff
changeset
|
3716 GTK_STOCK_REMOVE, type); |
ce3a0eba91ef
[gaim-migrate @ 4666]
Christian Hammond <chipx86@chipx86.com>
parents:
4387
diff
changeset
|
3717 gtk_tooltips_set_tip(gtkconv->tooltips, gtkconv->u.im->add, |
ce3a0eba91ef
[gaim-migrate @ 4666]
Christian Hammond <chipx86@chipx86.com>
parents:
4387
diff
changeset
|
3718 _("Remove the user from your buddy list"), NULL); |
ce3a0eba91ef
[gaim-migrate @ 4666]
Christian Hammond <chipx86@chipx86.com>
parents:
4387
diff
changeset
|
3719 |
4359 | 3720 gtk_widget_set_sensitive(gtkconv->u.im->add, |
3721 (gc != NULL && gc->prpl->remove_buddy != NULL)); | |
3722 } else { | |
4397
ce3a0eba91ef
[gaim-migrate @ 4666]
Christian Hammond <chipx86@chipx86.com>
parents:
4387
diff
changeset
|
3723 gtkconv->u.im->add = |
ce3a0eba91ef
[gaim-migrate @ 4666]
Christian Hammond <chipx86@chipx86.com>
parents:
4387
diff
changeset
|
3724 gaim_gtk_change_text(_("Add"), gtkconv->u.im->add, |
ce3a0eba91ef
[gaim-migrate @ 4666]
Christian Hammond <chipx86@chipx86.com>
parents:
4387
diff
changeset
|
3725 GTK_STOCK_ADD, type); |
ce3a0eba91ef
[gaim-migrate @ 4666]
Christian Hammond <chipx86@chipx86.com>
parents:
4387
diff
changeset
|
3726 gtk_tooltips_set_tip(gtkconv->tooltips, gtkconv->u.im->add, |
ce3a0eba91ef
[gaim-migrate @ 4666]
Christian Hammond <chipx86@chipx86.com>
parents:
4387
diff
changeset
|
3727 _("Add the user to your buddy list"), NULL); |
4359 | 3728 |
3729 gtk_widget_set_sensitive(gtkconv->u.im->add, | |
3730 (gc != NULL && gc->prpl->add_buddy != NULL)); | |
3731 } | |
3732 | |
4397
ce3a0eba91ef
[gaim-migrate @ 4666]
Christian Hammond <chipx86@chipx86.com>
parents:
4387
diff
changeset
|
3733 g_signal_connect(G_OBJECT(gtkconv->u.im->add), "clicked", |
ce3a0eba91ef
[gaim-migrate @ 4666]
Christian Hammond <chipx86@chipx86.com>
parents:
4387
diff
changeset
|
3734 G_CALLBACK(add_cb), conv); |
ce3a0eba91ef
[gaim-migrate @ 4666]
Christian Hammond <chipx86@chipx86.com>
parents:
4387
diff
changeset
|
3735 |
ce3a0eba91ef
[gaim-migrate @ 4666]
Christian Hammond <chipx86@chipx86.com>
parents:
4387
diff
changeset
|
3736 gtk_box_pack_start(GTK_BOX(parent), gtkconv->u.im->add, |
ce3a0eba91ef
[gaim-migrate @ 4666]
Christian Hammond <chipx86@chipx86.com>
parents:
4387
diff
changeset
|
3737 FALSE, FALSE, 0); |
ce3a0eba91ef
[gaim-migrate @ 4666]
Christian Hammond <chipx86@chipx86.com>
parents:
4387
diff
changeset
|
3738 gtk_box_reorder_child(GTK_BOX(parent), gtkconv->u.im->add, 3); |
ce3a0eba91ef
[gaim-migrate @ 4666]
Christian Hammond <chipx86@chipx86.com>
parents:
4387
diff
changeset
|
3739 gtk_button_set_relief(GTK_BUTTON(gtkconv->u.im->add), GTK_RELIEF_NONE); |
ce3a0eba91ef
[gaim-migrate @ 4666]
Christian Hammond <chipx86@chipx86.com>
parents:
4387
diff
changeset
|
3740 gtk_size_group_add_widget(gtkconv->sg, gtkconv->u.im->add); |
4359 | 3741 } |
3742 | |
4465
6e37eb000b7a
[gaim-migrate @ 4740]
Christian Hammond <chipx86@chipx86.com>
parents:
4454
diff
changeset
|
3743 struct gaim_window_ui_ops * |
6e37eb000b7a
[gaim-migrate @ 4740]
Christian Hammond <chipx86@chipx86.com>
parents:
4454
diff
changeset
|
3744 gaim_get_gtk_window_ui_ops(void) |
4359 | 3745 { |
4465
6e37eb000b7a
[gaim-migrate @ 4740]
Christian Hammond <chipx86@chipx86.com>
parents:
4454
diff
changeset
|
3746 return &window_ui_ops; |
4359 | 3747 } |
3748 | |
3749 /************************************************************************** | |
4465
6e37eb000b7a
[gaim-migrate @ 4740]
Christian Hammond <chipx86@chipx86.com>
parents:
4454
diff
changeset
|
3750 * Conversation UI operations |
4359 | 3751 **************************************************************************/ |
3752 static void | |
3753 gaim_gtkconv_destroy(struct gaim_conversation *conv) | |
3754 { | |
3755 struct gaim_gtk_conversation *gtkconv = GAIM_GTK_CONVERSATION(conv); | |
3756 | |
3757 if (gtkconv->dialogs.fg_color != NULL) | |
3758 gtk_widget_destroy(gtkconv->dialogs.fg_color); | |
3759 | |
3760 if (gtkconv->dialogs.bg_color != NULL) | |
3761 gtk_widget_destroy(gtkconv->dialogs.bg_color); | |
3762 | |
3763 if (gtkconv->dialogs.font != NULL) | |
3764 gtk_widget_destroy(gtkconv->dialogs.font); | |
3765 | |
3766 if (gtkconv->dialogs.smiley != NULL) | |
3767 gtk_widget_destroy(gtkconv->dialogs.smiley); | |
3768 | |
3769 if (gtkconv->dialogs.link != NULL) | |
3770 gtk_widget_destroy(gtkconv->dialogs.link); | |
3771 | |
3772 if (gtkconv->dialogs.log != NULL) | |
3773 gtk_widget_destroy(gtkconv->dialogs.log); | |
3774 | |
4571
51e988d015ed
[gaim-migrate @ 4852]
Christian Hammond <chipx86@chipx86.com>
parents:
4561
diff
changeset
|
3775 gtk_widget_destroy(gtkconv->tab_cont); |
4892 | 3776 g_object_unref(gtkconv->tab_cont); |
4571
51e988d015ed
[gaim-migrate @ 4852]
Christian Hammond <chipx86@chipx86.com>
parents:
4561
diff
changeset
|
3777 |
4359 | 3778 if (gaim_conversation_get_type(conv) == GAIM_CONV_IM) { |
4755 | 3779 if (gtkconv->u.im->icon_timer != 0) |
3780 g_source_remove(gtkconv->u.im->icon_timer); | |
3781 | |
4359 | 3782 if (gtkconv->u.im->save_icon != NULL) |
3783 gtk_widget_destroy(gtkconv->u.im->save_icon); | |
3784 | |
3785 if (gtkconv->u.im->anim != NULL) | |
4793 | 3786 g_object_unref(G_OBJECT(gtkconv->u.im->anim)); |
4359 | 3787 |
3788 g_free(gtkconv->u.im); | |
3789 } | |
3790 else if (gaim_conversation_get_type(conv) == GAIM_CONV_CHAT) { | |
3791 g_free(gtkconv->u.chat); | |
3792 } | |
3793 | |
4633 | 3794 gtk_object_sink(GTK_OBJECT(gtkconv->tooltips)); |
3795 | |
4359 | 3796 g_free(gtkconv); |
3797 } | |
3798 | |
3799 static void | |
3800 gaim_gtkconv_write_im(struct gaim_conversation *conv, const char *who, | |
3801 const char *message, size_t len, int flags, time_t mtime) | |
3802 { | |
3803 struct gaim_gtk_conversation *gtkconv; | |
3804 | |
3805 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
3806 | |
4382
76223649765b
[gaim-migrate @ 4648]
Christian Hammond <chipx86@chipx86.com>
parents:
4378
diff
changeset
|
3807 /* Play a sound, if specified in prefs. */ |
4359 | 3808 if (gtkconv->make_sound) { |
3809 if (flags & WFLAG_RECV) { | |
3810 if (gtkconv->u.im->a_virgin && | |
3811 (sound_options & OPT_SOUND_FIRST_RCV)) { | |
3812 | |
4561 | 3813 gaim_sound_play_event(GAIM_SOUND_FIRST_RECEIVE); |
4359 | 3814 } |
3815 else | |
4561 | 3816 gaim_sound_play_event(GAIM_SOUND_RECEIVE); |
4359 | 3817 } |
3818 else { | |
4561 | 3819 gaim_sound_play_event(GAIM_SOUND_SEND); |
4359 | 3820 } |
3821 } | |
3822 | |
3823 gtkconv->u.im->a_virgin = FALSE; | |
3824 | |
3825 gaim_conversation_write(conv, who, message, len, flags, mtime); | |
3826 } | |
3827 | |
3828 static void | |
3829 gaim_gtkconv_write_chat(struct gaim_conversation *conv, const char *who, | |
3830 const char *message, int flags, time_t mtime) | |
3831 { | |
3832 struct gaim_gtk_conversation *gtkconv; | |
3833 | |
3834 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
3835 | |
4382
76223649765b
[gaim-migrate @ 4648]
Christian Hammond <chipx86@chipx86.com>
parents:
4378
diff
changeset
|
3836 /* Play a sound, if specified in prefs. */ |
4359 | 3837 if (gtkconv->make_sound) { |
3838 if (!(flags & WFLAG_WHISPER) && (flags & WFLAG_SEND)) | |
4561 | 3839 gaim_sound_play_event(GAIM_SOUND_CHAT_YOU_SAY); |
4359 | 3840 else if (flags & WFLAG_RECV) { |
3841 if ((flags & WFLAG_NICK) && (sound_options & OPT_SOUND_CHAT_NICK)) | |
4561 | 3842 gaim_sound_play_event(GAIM_SOUND_CHAT_NICK); |
4359 | 3843 else |
4561 | 3844 gaim_sound_play_event(GAIM_SOUND_CHAT_SAY); |
4359 | 3845 } |
3846 } | |
3847 | |
3848 if (chat_options & OPT_CHAT_COLORIZE) | |
3849 flags |= WFLAG_COLORIZE; | |
3850 | |
3851 gaim_conversation_write(conv, who, message, -1, flags, mtime); | |
3852 } | |
3853 | |
3854 static void | |
3855 gaim_gtkconv_write_conv(struct gaim_conversation *conv, const char *who, | |
3856 const char *message, size_t length, int flags, | |
3857 time_t mtime) | |
3858 { | |
3859 struct gaim_gtk_conversation *gtkconv; | |
3860 struct gaim_connection *gc; | |
3861 int gtk_font_options = 0; | |
3862 GString *log_str; | |
3863 FILE *fd; | |
3864 char buf[BUF_LONG]; | |
3865 char buf2[BUF_LONG]; | |
3866 char mdate[64]; | |
3867 char color[10]; | |
3868 char *str; | |
3869 char *with_font_tag; | |
4896 | 3870 char *sml_attrib = NULL; |
4895 | 3871 |
3872 if(length == -1) | |
3873 length = strlen(message) + 1; | |
3874 | |
4359 | 3875 gtkconv = GAIM_GTK_CONVERSATION(conv); |
3876 gc = gaim_conversation_get_gc(conv); | |
3877 | |
3878 strftime(mdate, sizeof(mdate), "%H:%M:%S", localtime(&mtime)); | |
3879 | |
4896 | 3880 if(gc) |
3881 sml_attrib = g_strdup_printf("sml=\"%s\"", gc->prpl->name); | |
3882 | |
4359 | 3883 gtk_font_options ^= GTK_IMHTML_NO_COMMENTS; |
3884 | |
3885 if (convo_options & OPT_CONVO_IGNORE_COLOUR) | |
3886 gtk_font_options ^= GTK_IMHTML_NO_COLOURS; | |
3887 | |
3888 if (convo_options & OPT_CONVO_IGNORE_FONTS) | |
3889 gtk_font_options ^= GTK_IMHTML_NO_FONTS; | |
3890 | |
3891 if (convo_options & OPT_CONVO_IGNORE_SIZES) | |
3892 gtk_font_options ^= GTK_IMHTML_NO_SIZES; | |
3893 | |
3894 if (!(logging_options & OPT_LOG_STRIP_HTML)) | |
3895 gtk_font_options ^= GTK_IMHTML_RETURN_LOG; | |
3896 | |
3897 if (flags & WFLAG_SYSTEM) { | |
3898 if (convo_options & OPT_CONVO_SHOW_TIME) | |
3899 g_snprintf(buf, BUF_LONG, "<FONT SIZE=\"2\">(%s) </FONT><B>%s</B>", | |
3900 mdate, message); | |
3901 else | |
3902 g_snprintf(buf, BUF_LONG, "<B>%s</B>", message); | |
3903 | |
3904 g_snprintf(buf2, sizeof(buf2), | |
3905 "<FONT SIZE=\"2\"><!--(%s) --></FONT><B>%s</B><BR>", | |
3906 mdate, message); | |
3907 | |
3908 gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), buf2, -1, 0); | |
3909 | |
3910 if (logging_options & OPT_LOG_STRIP_HTML) { | |
3911 char *t1 = strip_html(buf); | |
3912 | |
3913 conv->history = g_string_append(conv->history, t1); | |
3914 conv->history = g_string_append(conv->history, "\n"); | |
3915 | |
3916 g_free(t1); | |
3917 } | |
3918 else { | |
3919 conv->history = g_string_append(conv->history, buf); | |
3920 conv->history = g_string_append(conv->history, "<BR>\n"); | |
3921 } | |
3922 | |
3923 if (!(flags & WFLAG_NOLOG) && gaim_conversation_is_logging(conv)) { | |
3924 | |
3925 char *t1; | |
3926 char nm[256]; | |
3927 | |
3928 if (logging_options & OPT_LOG_STRIP_HTML) | |
3929 t1 = strip_html(buf); | |
3930 else | |
3931 t1 = buf; | |
3932 | |
3933 if (gaim_conversation_get_type(conv) == GAIM_CONV_CHAT) | |
3934 g_snprintf(nm, sizeof(nm), "%s.chat", | |
3935 gaim_conversation_get_name(conv)); | |
3936 else | |
3937 strncpy(nm, gaim_conversation_get_name(conv), sizeof(nm)); | |
3938 | |
3939 fd = open_log_file(nm, | |
3940 (gaim_conversation_get_type(conv) == GAIM_CONV_CHAT)); | |
3941 | |
3942 if (fd) { | |
3943 if (logging_options & OPT_LOG_STRIP_HTML) | |
3944 fprintf(fd, "%s\n", t1); | |
3945 else | |
3946 fprintf(fd, "%s<BR>\n", t1); | |
3947 | |
3948 fclose(fd); | |
3949 } | |
3950 | |
3951 if (logging_options & OPT_LOG_STRIP_HTML) | |
3952 g_free(t1); | |
3953 } | |
3954 } | |
3955 else if (flags & WFLAG_NOLOG) { | |
3956 g_snprintf(buf, BUF_LONG, | |
3957 "<B><FONT COLOR=\"#777777\">%s</FONT></B><BR>", | |
3958 message); | |
3959 | |
3960 gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), buf, -1, 0); | |
3961 } | |
3962 else { | |
4895 | 3963 char *new_message = g_memdup(message, length); |
3964 | |
4359 | 3965 if (flags & WFLAG_WHISPER) { |
3966 str = g_malloc(1024); | |
3967 | |
3968 /* If we're whispering, it's not an autoresponse. */ | |
3969 if (meify(new_message, length)) { | |
3970 g_snprintf(str, 1024, "***%s", who); | |
3971 strcpy(color, "#6C2585"); | |
3972 } | |
3973 else { | |
3974 g_snprintf(str, 1024, "*%s*:", who); | |
3975 strcpy(color, "#00FF00"); | |
3976 } | |
3977 } | |
3978 else { | |
3979 if (meify(new_message, length)) { | |
3980 str = g_malloc(1024); | |
3981 | |
3982 if (flags & WFLAG_AUTO) | |
3983 g_snprintf(str, 1024, "%s ***%s", AUTO_RESPONSE, who); | |
3984 else | |
3985 g_snprintf(str, 1024, "***%s", who); | |
3986 | |
3987 if (flags & WFLAG_NICK) | |
3988 strcpy(color, "#AF7F00"); | |
3989 else | |
3990 strcpy(color, "#062585"); | |
3991 } | |
3992 else { | |
3993 str = g_malloc(1024); | |
3994 | |
3995 if (flags & WFLAG_AUTO) | |
3996 g_snprintf(str, 1024, "%s %s", who, AUTO_RESPONSE); | |
3997 else | |
3998 g_snprintf(str, 1024, "%s:", who); | |
3999 | |
4000 if (flags & WFLAG_NICK) | |
4001 strcpy(color, "#AF7F00"); | |
4002 else if (flags & WFLAG_RECV) { | |
4003 if (flags & WFLAG_COLORIZE) { | |
4004 const char *u; | |
4005 int m = 0; | |
4006 | |
4007 for (u = who; *u != '\0'; u++) | |
4008 m += *u; | |
4009 | |
4010 m = m % NUM_NICK_COLORS; | |
4011 | |
4012 strcpy(color, nick_colors[m]); | |
4013 } | |
4014 else | |
4015 strcpy(color, "#A82F2F"); | |
4016 } | |
4017 else if (flags & WFLAG_SEND) | |
4018 strcpy(color, "#16569E"); | |
4019 } | |
4020 } | |
4021 | |
4022 if (convo_options & OPT_CONVO_SHOW_TIME) | |
4023 g_snprintf(buf, BUF_LONG, | |
4896 | 4024 "<FONT COLOR=\"%s\" %s><FONT SIZE=\"2\">(%s) </FONT>" |
4025 "<B>%s</B></FONT> ", color, | |
4026 sml_attrib ? sml_attrib : "", mdate, str); | |
4359 | 4027 else |
4028 g_snprintf(buf, BUF_LONG, | |
4896 | 4029 "<FONT COLOR=\"%s\" %s><B>%s</B></FONT> ", color, |
4030 sml_attrib ? sml_attrib : "", str); | |
4359 | 4031 |
4032 g_snprintf(buf2, BUF_LONG, | |
4896 | 4033 "<FONT COLOR=\"%s\" %s><FONT SIZE=\"2\"><!--(%s) --></FONT>" |
4359 | 4034 "<B>%s</B></FONT> ", |
4896 | 4035 color, sml_attrib ? sml_attrib : "", mdate, str); |
4359 | 4036 |
4037 g_free(str); | |
4038 | |
4039 gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), buf2, -1, 0); | |
4040 | |
4895 | 4041 if(gc){ |
4896 | 4042 char *pre = g_strdup_printf("<font %s>", sml_attrib ? sml_attrib : ""); |
4895 | 4043 char *post = "</font>"; |
4044 int pre_len = strlen(pre); | |
4045 int post_len = strlen(post); | |
4046 | |
4047 with_font_tag = g_malloc(length + pre_len + post_len + 1); | |
4048 | |
4049 strcpy(with_font_tag, pre); | |
4050 memcpy(with_font_tag + pre_len, new_message, length); | |
4051 strcpy(with_font_tag + pre_len + length, post); | |
4052 | |
4053 length += pre_len + post_len; | |
4054 g_free(pre); | |
4055 } | |
4608 | 4056 else |
4895 | 4057 with_font_tag = g_memdup(new_message, length); |
4359 | 4058 |
4059 log_str = gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), | |
4895 | 4060 with_font_tag, length, gtk_font_options); |
4359 | 4061 |
4062 gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), "<BR>", -1, 0); | |
4063 | |
4064 /* XXX This needs to be updated for the new length argument. */ | |
4065 if (logging_options & OPT_LOG_STRIP_HTML) { | |
4066 char *t1, *t2; | |
4067 | |
4068 t1 = strip_html(buf); | |
4069 t2 = strip_html(new_message); | |
4070 | |
4071 conv->history = g_string_append(conv->history, t1); | |
4072 conv->history = g_string_append(conv->history, t2); | |
4073 conv->history = g_string_append(conv->history, "\n"); | |
4074 | |
4075 g_free(t1); | |
4076 g_free(t2); | |
4077 } | |
4078 else { | |
4079 char *t1, *t2; | |
4080 | |
4081 t1 = html_logize(buf); | |
4082 t2 = html_logize(new_message); | |
4083 | |
4084 conv->history = g_string_append(conv->history, t1); | |
4085 conv->history = g_string_append(conv->history, t2); | |
4086 conv->history = g_string_append(conv->history, "\n"); | |
4087 conv->history = g_string_append(conv->history, log_str->str); | |
4088 conv->history = g_string_append(conv->history, "<BR>\n"); | |
4089 | |
4090 g_free(t1); | |
4091 g_free(t2); | |
4092 } | |
4093 | |
4094 /* XXX This needs to be updated for the new length argument. */ | |
4095 if (gaim_conversation_is_logging(conv)) { | |
4096 char *t1, *t2; | |
4097 char nm[256]; | |
4098 | |
4099 if (gaim_conversation_get_type(conv) == GAIM_CONV_CHAT) | |
4100 g_snprintf(nm, sizeof(nm), "%s.chat", | |
4101 gaim_conversation_get_name(conv)); | |
4102 else | |
4103 strncpy(nm, gaim_conversation_get_name(conv), sizeof(nm)); | |
4104 | |
4105 if (logging_options & OPT_LOG_STRIP_HTML) { | |
4106 t1 = strip_html(buf); | |
4107 t2 = strip_html(with_font_tag); | |
4108 } | |
4109 else { | |
4110 t1 = html_logize(buf); | |
4111 t2 = html_logize(with_font_tag); | |
4112 } | |
4113 | |
4114 fd = open_log_file(nm, | |
4115 (gaim_conversation_get_type(conv) == GAIM_CONV_CHAT)); | |
4116 | |
4117 if (fd) { | |
4118 if (logging_options & OPT_LOG_STRIP_HTML) | |
4119 fprintf(fd, "%s%s\n", t1, t2); | |
4120 else { | |
4121 fprintf(fd, "%s%s%s<BR>\n", t1, t2, log_str->str); | |
4122 g_string_free(log_str, TRUE); | |
4123 } | |
4124 | |
4125 fclose(fd); | |
4126 } | |
4127 | |
4128 g_free(t1); | |
4129 g_free(t2); | |
4130 } | |
4131 | |
4132 g_free(with_font_tag); | |
4133 g_free(new_message); | |
4134 } | |
5012 | 4135 if(sml_attrib) |
4136 g_free(sml_attrib); | |
4359 | 4137 } |
4138 | |
4139 static void | |
4140 gaim_gtkconv_chat_add_user(struct gaim_conversation *conv, const char *user) | |
4141 { | |
4142 struct gaim_chat *chat; | |
4143 struct gaim_gtk_conversation *gtkconv; | |
4144 struct gaim_gtk_chat_pane *gtkchat; | |
4145 char tmp[BUF_LONG]; | |
4146 int num_users; | |
4147 int pos; | |
4148 | |
4149 chat = GAIM_CHAT(conv); | |
4150 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
4151 gtkchat = gtkconv->u.chat; | |
4152 | |
4153 num_users = g_list_length(gaim_chat_get_users(chat)); | |
4154 | |
4155 g_snprintf(tmp, sizeof(tmp), | |
4156 ngettext("%d person in room", "%d people in room", | |
4157 num_users), | |
4158 num_users); | |
4159 | |
4160 gtk_label_set_text(GTK_LABEL(gtkchat->count), tmp); | |
4161 | |
4162 if (gtkconv->make_sound) | |
4561 | 4163 gaim_sound_play_event(GAIM_SOUND_CHAT_JOIN); |
4359 | 4164 |
4165 pos = g_list_index(gaim_chat_get_users(chat), user); | |
4166 | |
4167 add_chat_buddy_common(conv, user, pos); | |
4168 } | |
4169 | |
4170 static void | |
4171 gaim_gtkconv_chat_rename_user(struct gaim_conversation *conv, | |
4172 const char *old_name, const char *new_name) | |
4173 { | |
4174 struct gaim_chat *chat; | |
4175 struct gaim_gtk_conversation *gtkconv; | |
4176 struct gaim_gtk_chat_pane *gtkchat; | |
4177 GtkTreeIter iter; | |
4178 GtkTreeModel *model; | |
4179 GList *names; | |
4180 int pos; | |
4181 int f = 1; | |
4182 | |
4183 chat = GAIM_CHAT(conv); | |
4184 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
4185 gtkchat = gtkconv->u.chat; | |
4186 | |
4187 for (names = gaim_chat_get_users(chat); | |
4188 names != NULL; | |
4189 names = names->next) { | |
4190 | |
4191 char *u = (char *)names->data; | |
4192 | |
4793 | 4193 if (!gaim_utf8_strcasecmp(u, old_name)) { |
4359 | 4194 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); |
4195 | |
4196 if (!gtk_tree_model_get_iter_first(GTK_TREE_MODEL(model), &iter)) | |
4197 break; | |
4198 | |
4199 while (f != 0) { | |
4200 char *val; | |
4201 | |
4202 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, 1, &val, -1); | |
4203 | |
4793 | 4204 if (!gaim_utf8_strcasecmp(old_name, val)) { |
4359 | 4205 gtk_list_store_remove(GTK_LIST_STORE(model), &iter); |
4640 | 4206 break; |
4207 } | |
4359 | 4208 |
4209 f = gtk_tree_model_iter_next(GTK_TREE_MODEL(model), &iter); | |
4210 | |
4211 g_free(val); | |
4212 } | |
4213 | |
4214 break; | |
4215 } | |
4216 } | |
4217 | |
4218 if (!names) | |
4219 return; | |
4220 | |
4221 pos = g_list_index(gaim_chat_get_users(chat), new_name); | |
4222 | |
4223 add_chat_buddy_common(conv, new_name, pos); | |
4224 } | |
4225 | |
4226 static void | |
4227 gaim_gtkconv_chat_remove_user(struct gaim_conversation *conv, const char *user) | |
4228 { | |
4229 struct gaim_chat *chat; | |
4230 struct gaim_gtk_conversation *gtkconv; | |
4231 struct gaim_gtk_chat_pane *gtkchat; | |
4232 GtkTreeIter iter; | |
4233 GtkTreeModel *model; | |
4234 GList *names; | |
4235 char tmp[BUF_LONG]; | |
4236 int num_users; | |
4237 int f = 1; | |
4238 | |
4239 chat = GAIM_CHAT(conv); | |
4240 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
4241 gtkchat = gtkconv->u.chat; | |
4242 | |
4243 num_users = g_list_length(gaim_chat_get_users(chat)) - 1; | |
4244 | |
4245 for (names = gaim_chat_get_users(chat); | |
4246 names != NULL; | |
4247 names = names->next) { | |
4248 | |
4249 char *u = (char *)names->data; | |
4250 | |
4793 | 4251 if (!gaim_utf8_strcasecmp(u, user)) { |
4359 | 4252 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); |
4253 | |
4254 if (!gtk_tree_model_get_iter_first(GTK_TREE_MODEL(model), &iter)) | |
4255 break; | |
4256 | |
4257 while (f != 0) { | |
4258 char *val; | |
4259 | |
4260 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, 1, &val, -1); | |
4261 | |
4793 | 4262 if (!gaim_utf8_strcasecmp(user, val)) |
4359 | 4263 gtk_list_store_remove(GTK_LIST_STORE(model), &iter); |
4264 | |
4265 f = gtk_tree_model_iter_next(GTK_TREE_MODEL(model), &iter); | |
4266 | |
4267 g_free(val); | |
4268 } | |
4269 | |
4270 break; | |
4271 } | |
4272 } | |
4273 | |
4274 if (names == NULL) | |
4275 return; | |
4276 | |
4277 g_snprintf(tmp, sizeof(tmp), | |
4278 ngettext("%d person in room", "%d people in room", | |
4279 num_users), num_users); | |
4280 | |
4281 gtk_label_set_text(GTK_LABEL(gtkchat->count), tmp); | |
4282 | |
4283 if (gtkconv->make_sound) | |
4561 | 4284 gaim_sound_play_event(GAIM_SOUND_CHAT_LEAVE); |
4359 | 4285 } |
4286 | |
4287 static void | |
4288 gaim_gtkconv_set_title(struct gaim_conversation *conv, const char *title) | |
4289 { | |
4290 struct gaim_gtk_conversation *gtkconv; | |
4681 | 4291 struct gaim_window *win; |
4292 struct gaim_gtk_window *gtkwin; | |
4293 | |
4294 win = gaim_conversation_get_window(conv); | |
4295 gtkwin = GAIM_GTK_WINDOW(win); | |
4359 | 4296 gtkconv = GAIM_GTK_CONVERSATION(conv); |
4297 | |
4298 gtk_label_set_text(GTK_LABEL(gtkconv->tab_label), title); | |
4681 | 4299 |
4300 if(conv == gaim_window_get_active_conversation(win)) | |
4301 gtk_window_set_title(GTK_WINDOW(gtkwin->window), title); | |
4359 | 4302 } |
4303 | |
4304 static void | |
4305 gaim_gtkconv_updated(struct gaim_conversation *conv, GaimConvUpdateType type) | |
4306 { | |
4307 struct gaim_window *win; | |
4736 | 4308 struct gaim_gtk_window *gtkwin; |
4359 | 4309 struct gaim_gtk_conversation *gtkconv; |
4310 struct gaim_gtk_chat_pane *gtkchat; | |
4311 struct gaim_chat *chat; | |
4312 | |
4313 win = gaim_conversation_get_window(conv); | |
4736 | 4314 gtkwin = GAIM_GTK_WINDOW(win); |
4359 | 4315 gtkconv = GAIM_GTK_CONVERSATION(conv); |
4316 | |
4491 | 4317 if (type == GAIM_CONV_UPDATE_ACCOUNT) { |
4359 | 4318 gaim_conversation_autoset_title(conv); |
4319 gaim_gtkconv_update_buddy_icon(conv); | |
4320 gaim_gtkconv_update_buttons_by_protocol(conv); | |
4321 | |
4685 | 4322 g_timeout_add(0, (GSourceFunc)update_send_as_selection, win); |
4359 | 4323 |
4324 smiley_themeize(gtkconv->imhtml); | |
4325 } | |
4326 else if (type == GAIM_CONV_UPDATE_TYPING || | |
4327 type == GAIM_CONV_UPDATE_UNSEEN) { | |
4328 GtkStyle *style; | |
4329 struct gaim_im *im = NULL; | |
4330 | |
4736 | 4331 |
4359 | 4332 if (gaim_conversation_get_type(conv) == GAIM_CONV_IM) |
4333 im = GAIM_IM(conv); | |
4334 | |
4335 style = gtk_style_new(); | |
4336 | |
4337 if (!GTK_WIDGET_REALIZED(gtkconv->tab_label)) | |
4338 gtk_widget_realize(gtkconv->tab_label); | |
4339 | |
4757 | 4340 pango_font_description_free(style->font_desc); |
4635 | 4341 style->font_desc = pango_font_description_copy( |
4342 gtk_widget_get_style(gtkconv->tab_label)->font_desc); | |
4359 | 4343 |
4344 if (im != NULL && gaim_im_get_typing_state(im) == TYPING) { | |
4577 | 4345 style->fg[GTK_STATE_NORMAL].red = 0x4646; |
4346 style->fg[GTK_STATE_NORMAL].green = 0xA0A0; | |
4347 style->fg[GTK_STATE_NORMAL].blue = 0x4646; | |
4348 style->fg[GTK_STATE_ACTIVE] = style->fg[GTK_STATE_NORMAL]; | |
4359 | 4349 } |
4350 else if (im != NULL && gaim_im_get_typing_state(im) == TYPED) { | |
4577 | 4351 style->fg[GTK_STATE_NORMAL].red = 0xD1D1; |
4352 style->fg[GTK_STATE_NORMAL].green = 0x9494; | |
4353 style->fg[GTK_STATE_NORMAL].blue = 0x0C0C; | |
4354 style->fg[GTK_STATE_ACTIVE] = style->fg[GTK_STATE_NORMAL]; | |
4359 | 4355 } |
4356 else if (gaim_conversation_get_unseen(conv) == GAIM_UNSEEN_NICK) { | |
4577 | 4357 style->fg[GTK_STATE_ACTIVE].red = 0x3131; |
4358 style->fg[GTK_STATE_ACTIVE].green = 0x4E4E; | |
4359 style->fg[GTK_STATE_ACTIVE].blue = 0x6C6C; | |
4578 | 4360 style->fg[GTK_STATE_NORMAL] = style->fg[GTK_STATE_ACTIVE]; |
4359 | 4361 } |
4362 else if (gaim_conversation_get_unseen(conv) == GAIM_UNSEEN_TEXT) { | |
4577 | 4363 style->fg[GTK_STATE_ACTIVE].red = 0xDFDF; |
4364 style->fg[GTK_STATE_ACTIVE].green = 0x4242; | |
4365 style->fg[GTK_STATE_ACTIVE].blue = 0x1E1E; | |
4578 | 4366 style->fg[GTK_STATE_NORMAL] = style->fg[GTK_STATE_ACTIVE]; |
4359 | 4367 } |
4368 | |
4369 gtk_widget_set_style(gtkconv->tab_label, style); | |
4635 | 4370 g_object_unref(G_OBJECT(style)); |
4736 | 4371 |
4812 | 4372 if(conv == gaim_window_get_active_conversation(win)) { |
4736 | 4373 update_typing_icon(conv); |
4374 } | |
4375 | |
4359 | 4376 } |
4377 else if (type == GAIM_CONV_UPDATE_TOPIC) { | |
4378 chat = GAIM_CHAT(conv); | |
4379 gtkchat = gtkconv->u.chat; | |
4380 | |
4381 gtk_entry_set_text(GTK_ENTRY(gtkchat->topic_text), | |
4382 gaim_chat_get_topic(chat)); | |
4383 } | |
4384 else if (type == GAIM_CONV_ACCOUNT_ONLINE || | |
4385 type == GAIM_CONV_ACCOUNT_OFFLINE) { | |
4386 | |
4360
c435a29370b8
[gaim-migrate @ 4626]
Christian Hammond <chipx86@chipx86.com>
parents:
4359
diff
changeset
|
4387 generate_send_as_items(win, NULL); |
4359 | 4388 } |
4397
ce3a0eba91ef
[gaim-migrate @ 4666]
Christian Hammond <chipx86@chipx86.com>
parents:
4387
diff
changeset
|
4389 else if(type == GAIM_CONV_UPDATE_ADD || |
ce3a0eba91ef
[gaim-migrate @ 4666]
Christian Hammond <chipx86@chipx86.com>
parents:
4387
diff
changeset
|
4390 type == GAIM_CONV_UPDATE_REMOVE) { |
4736 | 4391 |
4397
ce3a0eba91ef
[gaim-migrate @ 4666]
Christian Hammond <chipx86@chipx86.com>
parents:
4387
diff
changeset
|
4392 update_convo_add_button(conv); |
ce3a0eba91ef
[gaim-migrate @ 4666]
Christian Hammond <chipx86@chipx86.com>
parents:
4387
diff
changeset
|
4393 } |
4359 | 4394 } |
4395 | |
4465
6e37eb000b7a
[gaim-migrate @ 4740]
Christian Hammond <chipx86@chipx86.com>
parents:
4454
diff
changeset
|
4396 static struct gaim_conversation_ui_ops conversation_ui_ops = |
4359 | 4397 { |
4398 gaim_gtkconv_destroy, /* destroy_conversation */ | |
4399 gaim_gtkconv_write_chat, /* write_chat */ | |
4400 gaim_gtkconv_write_im, /* write_im */ | |
4401 gaim_gtkconv_write_conv, /* write_conv */ | |
4402 gaim_gtkconv_chat_add_user, /* chat_add_user */ | |
4403 gaim_gtkconv_chat_rename_user, /* chat_rename_user */ | |
4404 gaim_gtkconv_chat_remove_user, /* chat_remove_user */ | |
4405 gaim_gtkconv_set_title, /* set_title */ | |
4406 NULL, /* update_progress */ | |
4407 gaim_gtkconv_updated /* updated */ | |
4408 }; | |
4409 | |
4465
6e37eb000b7a
[gaim-migrate @ 4740]
Christian Hammond <chipx86@chipx86.com>
parents:
4454
diff
changeset
|
4410 struct gaim_conversation_ui_ops * |
6e37eb000b7a
[gaim-migrate @ 4740]
Christian Hammond <chipx86@chipx86.com>
parents:
4454
diff
changeset
|
4411 gaim_get_gtk_conversation_ui_ops(void) |
4359 | 4412 { |
4465
6e37eb000b7a
[gaim-migrate @ 4740]
Christian Hammond <chipx86@chipx86.com>
parents:
4454
diff
changeset
|
4413 return &conversation_ui_ops; |
4359 | 4414 } |
4415 | |
4416 /************************************************************************** | |
4417 * Public conversation utility functions | |
4418 **************************************************************************/ | |
4419 void | |
4420 gaim_gtkconv_toggle_smileys(void) | |
4421 { | |
4422 GList *cl; | |
4423 struct gaim_conversation *conv; | |
4424 struct gaim_gtk_conversation *gtkconv; | |
4425 | |
4426 for (cl = gaim_get_conversations(); cl != NULL; cl = cl->next) { | |
4427 | |
4428 conv = (struct gaim_conversation *)cl->data; | |
4429 | |
4398
a8249a5250b6
[gaim-migrate @ 4667]
Christian Hammond <chipx86@chipx86.com>
parents:
4397
diff
changeset
|
4430 if (!GAIM_IS_GTK_CONVERSATION(conv)) |
4359 | 4431 continue; |
4432 | |
4433 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
4434 | |
4435 gtk_imhtml_show_smileys(GTK_IMHTML(gtkconv->imhtml), | |
4436 (convo_options & OPT_CONVO_SHOW_SMILEY)); | |
4437 } | |
4438 } | |
4439 | |
4440 void | |
4441 gaim_gtkconv_toggle_timestamps(void) | |
4442 { | |
4443 GList *cl; | |
4444 struct gaim_conversation *conv; | |
4445 struct gaim_gtk_conversation *gtkconv; | |
4446 | |
4447 for (cl = gaim_get_conversations(); cl != NULL; cl = cl->next) { | |
4448 | |
4449 conv = (struct gaim_conversation *)cl->data; | |
4450 | |
4398
a8249a5250b6
[gaim-migrate @ 4667]
Christian Hammond <chipx86@chipx86.com>
parents:
4397
diff
changeset
|
4451 if (!GAIM_IS_GTK_CONVERSATION(conv)) |
4359 | 4452 continue; |
4453 | |
4454 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
4455 | |
4456 gtk_imhtml_show_comments(GTK_IMHTML(gtkconv->imhtml), | |
4457 (convo_options & OPT_CONVO_SHOW_TIME)); | |
4458 } | |
4459 } | |
4460 | |
4461 void | |
4462 gaim_gtkconv_toggle_spellchk(void) | |
4463 { | |
4464 #ifdef USE_GTKSPELL | |
4465 GList *cl; | |
4466 struct gaim_conversation *conv; | |
4467 struct gaim_gtk_conversation *gtkconv; | |
4468 GtkSpell *spell; | |
4469 | |
4859
a9a831508b43
[gaim-migrate @ 5186]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4851
diff
changeset
|
4470 debug_printf("gaim_gtkconv_toggle_spellchk\n"); |
4359 | 4471 for (cl = gaim_get_conversations(); cl != NULL; cl = cl->next) { |
4472 | |
4473 conv = (struct gaim_conversation *)cl->data; | |
4474 | |
4398
a8249a5250b6
[gaim-migrate @ 4667]
Christian Hammond <chipx86@chipx86.com>
parents:
4397
diff
changeset
|
4475 if (!GAIM_IS_GTK_CONVERSATION(conv)) |
4359 | 4476 continue; |
4477 | |
4478 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
4479 | |
4480 if (convo_options & OPT_CONVO_CHECK_SPELLING) | |
4481 gtkspell_new_attach(GTK_TEXT_VIEW(gtkconv->entry), NULL, NULL); | |
4482 else { | |
4483 spell = gtkspell_get_from_text_view(GTK_TEXT_VIEW(gtkconv->entry)); | |
4484 gtkspell_detach(spell); | |
4485 } | |
4486 } | |
4487 #endif | |
4488 } | |
4489 | |
4445 | 4490 void |
4491 gaim_gtkconv_toggle_close_buttons(void) | |
4492 { | |
4493 GList *cl; | |
4494 struct gaim_conversation *conv; | |
4495 struct gaim_gtk_conversation *gtkconv; | |
4496 | |
4497 for (cl = gaim_get_conversations(); cl != NULL; cl = cl->next) { | |
4498 conv = (struct gaim_conversation *)cl->data; | |
4499 if (!GAIM_IS_GTK_CONVERSATION(conv)) | |
4500 continue; | |
4501 | |
4502 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
4503 | |
4504 if (convo_options & OPT_CONVO_NO_X_ON_TAB) | |
4505 gtk_widget_hide(gtkconv->close); | |
4506 else | |
4507 gtk_widget_show_all(gtkconv->close); | |
4508 } | |
4509 } | |
4510 | |
4359 | 4511 static void |
4512 remove_icon(struct gaim_gtk_conversation *gtkconv) | |
4513 { | |
4514 if (gtkconv == NULL) | |
4515 return; | |
4516 | |
4517 if (gtkconv->u.im->icon != NULL) | |
4518 gtk_container_remove(GTK_CONTAINER(gtkconv->bbox), | |
4519 gtkconv->u.im->icon->parent->parent); | |
4520 | |
4521 if (gtkconv->u.im->anim != NULL) | |
4793 | 4522 g_object_unref(G_OBJECT(gtkconv->u.im->anim)); |
4359 | 4523 |
4524 if (gtkconv->u.im->icon_timer != 0) | |
4525 g_source_remove(gtkconv->u.im->icon_timer); | |
4526 | |
4527 if (gtkconv->u.im->iter != NULL) | |
4528 g_object_unref(G_OBJECT(gtkconv->u.im->iter)); | |
4529 | |
4530 gtkconv->u.im->icon_timer = 0; | |
4531 gtkconv->u.im->icon = NULL; | |
4532 gtkconv->u.im->anim = NULL; | |
4533 gtkconv->u.im->iter = NULL; | |
4534 } | |
4535 | |
4536 static gboolean | |
4537 redraw_icon(gpointer data) | |
4538 { | |
4539 struct gaim_conversation *conv = (struct gaim_conversation *)data; | |
4540 struct gaim_gtk_conversation *gtkconv; | |
4541 | |
4542 GdkPixbuf *buf; | |
4543 GdkPixbuf *scale; | |
4544 GdkPixmap *pm; | |
4545 GdkBitmap *bm; | |
4546 gint delay; | |
4547 | |
4548 if (!g_list_find(gaim_get_ims(), conv)) { | |
4549 debug_printf("I think this is a bug.\n"); | |
4550 return FALSE; | |
4551 } | |
4552 | |
4553 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
4554 | |
4555 gdk_pixbuf_animation_iter_advance(gtkconv->u.im->iter, NULL); | |
4556 buf = gdk_pixbuf_animation_iter_get_pixbuf(gtkconv->u.im->iter); | |
4557 | |
4558 scale = gdk_pixbuf_scale_simple(buf, | |
4559 MAX(gdk_pixbuf_get_width(buf) * SCALE(gtkconv->u.im->anim) / | |
4560 gdk_pixbuf_animation_get_width(gtkconv->u.im->anim), 1), | |
4561 MAX(gdk_pixbuf_get_height(buf) * SCALE(gtkconv->u.im->anim) / | |
4562 gdk_pixbuf_animation_get_height(gtkconv->u.im->anim), 1), | |
4563 GDK_INTERP_NEAREST); | |
4564 | |
4565 gdk_pixbuf_render_pixmap_and_mask(scale, &pm, &bm, 100); | |
4793 | 4566 g_object_unref(G_OBJECT(scale)); |
4635 | 4567 gtk_image_set_from_pixmap(GTK_IMAGE(gtkconv->u.im->icon), pm, bm); |
4793 | 4568 g_object_unref(G_OBJECT(pm)); |
4359 | 4569 gtk_widget_queue_draw(gtkconv->u.im->icon); |
4570 | |
4571 if (bm) | |
4793 | 4572 g_object_unref(G_OBJECT(bm)); |
4359 | 4573 |
4574 delay = gdk_pixbuf_animation_iter_get_delay_time(gtkconv->u.im->iter) / 10; | |
4575 | |
4576 gtkconv->u.im->icon_timer = g_timeout_add(delay * 10, redraw_icon, conv); | |
4577 | |
4578 return FALSE; | |
4579 } | |
4580 | |
4581 static void | |
4582 start_anim(GtkObject *obj, struct gaim_conversation *conv) | |
4583 { | |
4584 struct gaim_gtk_conversation *gtkconv; | |
4585 int delay; | |
4586 | |
4398
a8249a5250b6
[gaim-migrate @ 4667]
Christian Hammond <chipx86@chipx86.com>
parents:
4397
diff
changeset
|
4587 if (!GAIM_IS_GTK_CONVERSATION(conv)) |
4359 | 4588 return; |
4589 | |
4590 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
4591 | |
4592 delay = gdk_pixbuf_animation_iter_get_delay_time(gtkconv->u.im->iter) / 10; | |
4593 | |
4594 if (gtkconv->u.im->anim) | |
4595 gtkconv->u.im->icon_timer = g_timeout_add(delay * 10, redraw_icon, | |
4596 conv); | |
4597 } | |
4598 | |
4599 static void | |
4600 stop_anim(GtkObject *obj, struct gaim_conversation *conv) | |
4601 { | |
4602 struct gaim_gtk_conversation *gtkconv; | |
4603 | |
4398
a8249a5250b6
[gaim-migrate @ 4667]
Christian Hammond <chipx86@chipx86.com>
parents:
4397
diff
changeset
|
4604 if (!GAIM_IS_GTK_CONVERSATION(conv)) |
4359 | 4605 return; |
4606 | |
4607 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
4608 | |
4609 if (gtkconv->u.im->icon_timer != 0) | |
4610 g_source_remove(gtkconv->u.im->icon_timer); | |
4611 | |
4612 gtkconv->u.im->icon_timer = 0; | |
4613 } | |
4614 | |
4615 static gboolean | |
4616 icon_menu(GtkObject *obj, GdkEventButton *e, struct gaim_conversation *conv) | |
4617 { | |
4618 struct gaim_gtk_conversation *gtkconv; | |
4619 static GtkWidget *menu = NULL; | |
4620 GtkWidget *button; | |
4621 | |
4622 if (e->button != 3 || e->type != GDK_BUTTON_PRESS) | |
4623 return FALSE; | |
4624 | |
4625 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
4626 | |
4627 /* | |
4628 * If a menu already exists, destroy it before creating a new one, | |
4629 * thus freeing-up the memory it occupied. | |
4630 */ | |
4631 if (menu != NULL) | |
4632 gtk_widget_destroy(menu); | |
4633 | |
4634 menu = gtk_menu_new(); | |
4635 | |
4636 if (gtkconv->u.im->icon_timer) { | |
4637 button = gtk_menu_item_new_with_label(_("Disable Animation")); | |
4638 g_signal_connect(GTK_OBJECT(button), "activate", | |
4639 G_CALLBACK(stop_anim), conv); | |
4640 gtk_menu_shell_append(GTK_MENU_SHELL(menu), button); | |
4641 gtk_widget_show(button); | |
4642 } | |
4643 else if (gtkconv->u.im->anim && | |
4644 !(gdk_pixbuf_animation_is_static_image(gtkconv->u.im->anim))) | |
4645 { | |
4646 button = gtk_menu_item_new_with_label(_("Enable Animation")); | |
4647 g_signal_connect(GTK_OBJECT(button), "activate", | |
4648 G_CALLBACK(start_anim), conv); | |
4649 gtk_menu_shell_append(GTK_MENU_SHELL(menu), button); | |
4650 gtk_widget_show(button); | |
4651 } | |
4652 | |
4653 button = gtk_menu_item_new_with_label(_("Hide Icon")); | |
4654 g_signal_connect_swapped(GTK_OBJECT(button), "activate", | |
4515
9b9737a00a96
[gaim-migrate @ 4793]
Christian Hammond <chipx86@chipx86.com>
parents:
4513
diff
changeset
|
4655 G_CALLBACK(remove_icon), gtkconv); |
4359 | 4656 gtk_menu_shell_append(GTK_MENU_SHELL(menu), button); |
4657 gtk_widget_show(button); | |
4658 | |
4659 button = gtk_menu_item_new_with_label(_("Save Icon As...")); | |
4660 g_signal_connect(GTK_OBJECT(button), "activate", | |
4661 G_CALLBACK(gaim_gtk_save_icon_dialog), conv); | |
4662 gtk_menu_shell_append(GTK_MENU_SHELL(menu), button); | |
4663 gtk_widget_show(button); | |
4664 | |
4665 gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL, e->button, e->time); | |
4666 | |
4667 return TRUE; | |
4668 } | |
4669 | |
4670 void | |
4671 gaim_gtkconv_update_buddy_icon(struct gaim_conversation *conv) | |
4672 { | |
4673 struct gaim_gtk_conversation *gtkconv; | |
4674 | |
4675 char filename[256]; | |
4676 FILE *file; | |
4677 GError *err = NULL; | |
4678 | |
4757 | 4679 struct buddy *buddy; |
4680 | |
4359 | 4681 void *data; |
4682 int len, delay; | |
4683 | |
4684 GdkPixbuf *buf; | |
4685 | |
4686 GtkWidget *event; | |
4687 GtkWidget *frame; | |
4688 GdkPixbuf *scale; | |
4689 GdkPixmap *pm; | |
4690 GdkBitmap *bm; | |
4691 int sf = 0; | |
4692 | |
4398
a8249a5250b6
[gaim-migrate @ 4667]
Christian Hammond <chipx86@chipx86.com>
parents:
4397
diff
changeset
|
4693 if (conv == NULL || !GAIM_IS_GTK_CONVERSATION(conv) || |
4359 | 4694 gaim_conversation_get_type(conv) != GAIM_CONV_IM) { |
4695 | |
4696 return; | |
4697 } | |
4698 | |
4699 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
4700 | |
4701 remove_icon(gtkconv); | |
4702 | |
4703 if (im_options & OPT_IM_HIDE_ICONS) | |
4704 return; | |
4705 | |
4706 if (gaim_conversation_get_gc(conv) == NULL) | |
4707 return; | |
4708 | |
4793 | 4709 if(gtkconv->u.im->anim) |
4710 g_object_unref(G_OBJECT(gtkconv->u.im->anim)); | |
4711 | |
4757 | 4712 if((buddy = gaim_find_buddy(gaim_conversation_get_account(conv), |
4713 gaim_conversation_get_name(conv))) != NULL) { | |
4714 char *file = gaim_buddy_get_setting(buddy, "buddy_icon"); | |
4715 if(file) { | |
4716 gtkconv->u.im->anim = gdk_pixbuf_animation_new_from_file(file, &err); | |
4717 g_free(file); | |
4718 } | |
4719 } else { | |
4720 data = get_icon_data(gaim_conversation_get_gc(conv), | |
4721 normalize(gaim_conversation_get_name(conv)), | |
4722 &len); | |
4723 | |
4724 if (!data) | |
4725 return; | |
4726 | |
4727 /* this is such an evil hack, i don't know why i'm even considering it. | |
4728 * we'll do it differently when gdk-pixbuf-loader isn't leaky anymore. */ | |
4729 g_snprintf(filename, sizeof(filename), | |
4730 "%s" G_DIR_SEPARATOR_S "gaimicon-%s.%d", | |
4731 g_get_tmp_dir(), gaim_conversation_get_name(conv), getpid()); | |
4732 | |
4733 if (!(file = fopen(filename, "wb"))) | |
4734 return; | |
4735 | |
4736 fwrite(data, 1, len, file); | |
4737 fclose(file); | |
4738 | |
4739 gtkconv->u.im->anim = gdk_pixbuf_animation_new_from_file(filename, &err); | |
4740 /* make sure we remove the file as soon as possible */ | |
4741 unlink(filename); | |
4742 } | |
4359 | 4743 |
4744 if (err) { | |
4745 debug_printf("Buddy icon error: %s\n", err->message); | |
4746 g_error_free(err); | |
4747 } | |
4748 | |
4749 | |
4750 if (!gtkconv->u.im->anim) | |
4751 return; | |
4752 | |
4793 | 4753 if(gtkconv->u.im->iter) |
4754 g_object_unref(G_OBJECT(gtkconv->u.im->iter)); | |
4755 | |
4359 | 4756 if (gdk_pixbuf_animation_is_static_image(gtkconv->u.im->anim)) { |
4757 gtkconv->u.im->iter = NULL; | |
4758 delay = 0; | |
4759 buf = gdk_pixbuf_animation_get_static_image(gtkconv->u.im->anim); | |
4760 } else { | |
4761 gtkconv->u.im->iter = | |
4762 gdk_pixbuf_animation_get_iter(gtkconv->u.im->anim, NULL); | |
4763 buf = gdk_pixbuf_animation_iter_get_pixbuf(gtkconv->u.im->iter); | |
4764 delay = gdk_pixbuf_animation_iter_get_delay_time(gtkconv->u.im->iter); | |
4765 delay = delay / 10; | |
4766 } | |
4767 | |
4768 sf = SCALE(gtkconv->u.im->anim); | |
4769 scale = gdk_pixbuf_scale_simple(buf, | |
4770 MAX(gdk_pixbuf_get_width(buf) * sf / | |
4771 gdk_pixbuf_animation_get_width(gtkconv->u.im->anim), 1), | |
4772 MAX(gdk_pixbuf_get_height(buf) * sf / | |
4773 gdk_pixbuf_animation_get_height(gtkconv->u.im->anim), 1), | |
4774 GDK_INTERP_NEAREST); | |
4775 | |
4776 if (delay) | |
4777 gtkconv->u.im->icon_timer = g_timeout_add(delay * 10, redraw_icon, | |
4778 conv); | |
4779 | |
4780 gdk_pixbuf_render_pixmap_and_mask(scale, &pm, &bm, 100); | |
4793 | 4781 g_object_unref(G_OBJECT(scale)); |
4359 | 4782 |
4783 frame = gtk_frame_new(NULL); | |
4784 gtk_frame_set_shadow_type(GTK_FRAME(frame), | |
4785 (bm ? GTK_SHADOW_NONE : GTK_SHADOW_IN)); | |
4786 gtk_box_pack_start(GTK_BOX(gtkconv->bbox), frame, FALSE, FALSE, 5); | |
4787 gtk_box_reorder_child(GTK_BOX(gtkconv->bbox), frame, 0); | |
4788 gtk_widget_show(frame); | |
4789 | |
4790 event = gtk_event_box_new(); | |
4791 gtk_container_add(GTK_CONTAINER(frame), event); | |
4792 g_signal_connect(GTK_OBJECT(event), "button-press-event", | |
4793 G_CALLBACK(icon_menu), conv); | |
4794 gtk_widget_show(event); | |
4795 | |
4635 | 4796 gtkconv->u.im->icon = gtk_image_new_from_pixmap(pm, bm); |
4359 | 4797 gtk_widget_set_size_request(gtkconv->u.im->icon, sf, sf); |
4798 gtk_container_add(GTK_CONTAINER(event), gtkconv->u.im->icon); | |
4799 gtk_widget_show(gtkconv->u.im->icon); | |
4800 | |
4801 if(im_options & OPT_IM_NO_ANIMATION) | |
4802 stop_anim(NULL, conv); | |
4803 | |
4793 | 4804 g_object_unref(G_OBJECT(pm)); |
4359 | 4805 |
4806 if (bm) | |
4793 | 4807 g_object_unref(G_OBJECT(bm)); |
4359 | 4808 } |
4809 | |
4810 void | |
4811 gaim_gtkconv_hide_buddy_icons(void) | |
4812 { | |
4813 gaim_conversation_foreach(gaim_gtkconv_update_buddy_icon); | |
4814 } | |
4815 | |
4816 void | |
4817 gaim_gtkconv_set_anim(void) | |
4818 { | |
4819 GList *l; | |
4820 | |
4821 if (im_options & OPT_IM_HIDE_ICONS) | |
4822 return; | |
4823 | |
4824 if (im_options & OPT_IM_NO_ANIMATION) { | |
4825 for (l = gaim_get_ims(); l != NULL; l = l->next) | |
4826 stop_anim(NULL, (struct gaim_conversation *)l->data); | |
4827 } else { | |
4828 for (l = gaim_get_ims(); l != NULL; l = l->next) | |
4829 start_anim(NULL, (struct gaim_conversation *)l->data); | |
4830 } | |
4831 } | |
4832 | |
4833 void | |
4834 gaim_gtkconv_update_font_buttons(void) | |
4835 { | |
4836 GList *l; | |
4837 struct gaim_conversation *conv; | |
4838 struct gaim_gtk_conversation *gtkconv; | |
4839 | |
4840 for (l = gaim_get_ims(); l != NULL; l = l->next) { | |
4841 conv = (struct gaim_conversation *)l->data; | |
4842 | |
4398
a8249a5250b6
[gaim-migrate @ 4667]
Christian Hammond <chipx86@chipx86.com>
parents:
4397
diff
changeset
|
4843 if (!GAIM_IS_GTK_CONVERSATION(conv)) |
4359 | 4844 continue; |
4845 | |
4846 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
4847 | |
4848 if (gtkconv->toolbar.bold != NULL) | |
4849 gtk_widget_set_sensitive(gtkconv->toolbar.bold, | |
4850 (!(font_options & OPT_FONT_BOLD))); | |
4851 | |
4852 if (gtkconv->toolbar.italic != NULL) | |
4853 gtk_widget_set_sensitive(gtkconv->toolbar.italic, | |
4854 (!(font_options & OPT_FONT_ITALIC))); | |
4855 | |
4856 if (gtkconv->toolbar.underline != NULL) | |
4857 gtk_widget_set_sensitive(gtkconv->toolbar.underline, | |
4858 (!(font_options & OPT_FONT_UNDERLINE))); | |
4859 } | |
4860 } | |
4861 | |
4862 void | |
4421 | 4863 gaim_gtkconv_update_font_colors(struct gaim_conversation *conv) |
4864 { | |
4438
2054d8429925
[gaim-migrate @ 4713]
Christian Hammond <chipx86@chipx86.com>
parents:
4421
diff
changeset
|
4865 struct gaim_gtk_conversation *gtkconv; |
2054d8429925
[gaim-migrate @ 4713]
Christian Hammond <chipx86@chipx86.com>
parents:
4421
diff
changeset
|
4866 |
2054d8429925
[gaim-migrate @ 4713]
Christian Hammond <chipx86@chipx86.com>
parents:
4421
diff
changeset
|
4867 if (!GAIM_IS_GTK_CONVERSATION(conv)) |
2054d8429925
[gaim-migrate @ 4713]
Christian Hammond <chipx86@chipx86.com>
parents:
4421
diff
changeset
|
4868 return; |
2054d8429925
[gaim-migrate @ 4713]
Christian Hammond <chipx86@chipx86.com>
parents:
4421
diff
changeset
|
4869 |
2054d8429925
[gaim-migrate @ 4713]
Christian Hammond <chipx86@chipx86.com>
parents:
4421
diff
changeset
|
4870 gtkconv = GAIM_GTK_CONVERSATION(conv); |
4421 | 4871 |
4438
2054d8429925
[gaim-migrate @ 4713]
Christian Hammond <chipx86@chipx86.com>
parents:
4421
diff
changeset
|
4872 gtkconv->fg_color.red = fgcolor.red; |
2054d8429925
[gaim-migrate @ 4713]
Christian Hammond <chipx86@chipx86.com>
parents:
4421
diff
changeset
|
4873 gtkconv->fg_color.blue = fgcolor.blue; |
2054d8429925
[gaim-migrate @ 4713]
Christian Hammond <chipx86@chipx86.com>
parents:
4421
diff
changeset
|
4874 gtkconv->fg_color.green = fgcolor.green; |
2054d8429925
[gaim-migrate @ 4713]
Christian Hammond <chipx86@chipx86.com>
parents:
4421
diff
changeset
|
4875 |
2054d8429925
[gaim-migrate @ 4713]
Christian Hammond <chipx86@chipx86.com>
parents:
4421
diff
changeset
|
4876 gtkconv->bg_color.red = bgcolor.red; |
2054d8429925
[gaim-migrate @ 4713]
Christian Hammond <chipx86@chipx86.com>
parents:
4421
diff
changeset
|
4877 gtkconv->bg_color.blue = bgcolor.blue; |
2054d8429925
[gaim-migrate @ 4713]
Christian Hammond <chipx86@chipx86.com>
parents:
4421
diff
changeset
|
4878 gtkconv->bg_color.green = bgcolor.green; |
2054d8429925
[gaim-migrate @ 4713]
Christian Hammond <chipx86@chipx86.com>
parents:
4421
diff
changeset
|
4879 } |
2054d8429925
[gaim-migrate @ 4713]
Christian Hammond <chipx86@chipx86.com>
parents:
4421
diff
changeset
|
4880 |
2054d8429925
[gaim-migrate @ 4713]
Christian Hammond <chipx86@chipx86.com>
parents:
4421
diff
changeset
|
4881 void |
2054d8429925
[gaim-migrate @ 4713]
Christian Hammond <chipx86@chipx86.com>
parents:
4421
diff
changeset
|
4882 gaim_gtkconv_update_font_face(struct gaim_conversation *conv) |
2054d8429925
[gaim-migrate @ 4713]
Christian Hammond <chipx86@chipx86.com>
parents:
4421
diff
changeset
|
4883 { |
2054d8429925
[gaim-migrate @ 4713]
Christian Hammond <chipx86@chipx86.com>
parents:
4421
diff
changeset
|
4884 struct gaim_gtk_conversation *gtkconv; |
2054d8429925
[gaim-migrate @ 4713]
Christian Hammond <chipx86@chipx86.com>
parents:
4421
diff
changeset
|
4885 |
2054d8429925
[gaim-migrate @ 4713]
Christian Hammond <chipx86@chipx86.com>
parents:
4421
diff
changeset
|
4886 if (!GAIM_IS_GTK_CONVERSATION(conv)) |
2054d8429925
[gaim-migrate @ 4713]
Christian Hammond <chipx86@chipx86.com>
parents:
4421
diff
changeset
|
4887 return; |
2054d8429925
[gaim-migrate @ 4713]
Christian Hammond <chipx86@chipx86.com>
parents:
4421
diff
changeset
|
4888 |
2054d8429925
[gaim-migrate @ 4713]
Christian Hammond <chipx86@chipx86.com>
parents:
4421
diff
changeset
|
4889 gtkconv = GAIM_GTK_CONVERSATION(conv); |
2054d8429925
[gaim-migrate @ 4713]
Christian Hammond <chipx86@chipx86.com>
parents:
4421
diff
changeset
|
4890 |
2054d8429925
[gaim-migrate @ 4713]
Christian Hammond <chipx86@chipx86.com>
parents:
4421
diff
changeset
|
4891 strncpy(gtkconv->fontface, fontface, 128); |
4421 | 4892 } |
4893 | |
4894 void | |
4359 | 4895 gaim_gtkconv_update_tabs(void) |
4896 { | |
4897 GList *l; | |
4898 GtkPositionType pos; | |
4899 struct gaim_window *win; | |
4900 struct gaim_gtk_window *gtkwin; | |
4901 | |
4902 pos = ((im_options & OPT_IM_SIDE_TAB) | |
4903 ? ((im_options & OPT_IM_BR_TAB) ? GTK_POS_RIGHT : GTK_POS_LEFT) | |
4904 : ((im_options & OPT_IM_BR_TAB) ? GTK_POS_BOTTOM : GTK_POS_TOP)); | |
4905 | |
4906 for (l = gaim_get_windows(); l != NULL; l = l->next) { | |
4907 win = (struct gaim_window *)l->data; | |
4908 | |
4398
a8249a5250b6
[gaim-migrate @ 4667]
Christian Hammond <chipx86@chipx86.com>
parents:
4397
diff
changeset
|
4909 if (!GAIM_IS_GTK_WINDOW(win)) |
4359 | 4910 continue; |
4911 | |
4912 gtkwin = GAIM_GTK_WINDOW(win); | |
4913 | |
4914 gtk_notebook_set_tab_pos(GTK_NOTEBOOK(gtkwin->notebook), pos); | |
4915 } | |
4916 } | |
4917 | |
4918 void | |
4919 gaim_gtkconv_update_chat_button_style() | |
4920 { | |
4921 GSList *l; | |
4922 struct gaim_connection *g; | |
4923 GtkWidget *parent; | |
4924 GaimConversationType type = GAIM_CONV_CHAT; | |
4925 | |
4926 for (l = connections; l != NULL; l = l->next) { | |
4927 GSList *bcs; | |
4928 struct gaim_conversation *conv; | |
4929 struct gaim_gtk_conversation *gtkconv; | |
4930 struct gaim_gtk_window *gtkwin; | |
4931 | |
4932 g = (struct gaim_connection *)l->data; | |
4933 | |
4934 for (bcs = g->buddy_chats; bcs != NULL; bcs = bcs->next) { | |
4935 conv = (struct gaim_conversation *)bcs->data; | |
4936 | |
4937 if (gaim_conversation_get_type(conv) != GAIM_CONV_CHAT) | |
4938 continue; | |
4939 | |
4398
a8249a5250b6
[gaim-migrate @ 4667]
Christian Hammond <chipx86@chipx86.com>
parents:
4397
diff
changeset
|
4940 if (!GAIM_IS_GTK_CONVERSATION(conv)) |
4359 | 4941 continue; |
4942 | |
4943 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
4944 gtkwin = GAIM_GTK_WINDOW(gaim_conversation_get_window(conv)); | |
4945 parent = gtk_widget_get_parent(gtkconv->send); | |
4946 | |
4947 gtkconv->send = | |
4948 gaim_gtk_change_text(_("Send"), | |
4949 gtkconv->send, GAIM_STOCK_SEND, type); | |
4950 gtkconv->u.chat->invite = | |
4951 gaim_gtk_change_text(_("Invite"), | |
4952 gtkconv->u.chat->invite, | |
4953 GAIM_STOCK_INVITE, type); | |
4954 | |
4955 gtk_box_pack_end(GTK_BOX(parent), gtkconv->send, FALSE, FALSE, | |
4956 type); | |
4957 gtk_box_pack_end(GTK_BOX(parent), gtkconv->u.chat->invite, | |
4958 FALSE, FALSE, 0); | |
4959 | |
4960 g_signal_connect(G_OBJECT(gtkconv->send), "clicked", | |
4961 G_CALLBACK(send_cb), conv); | |
4962 g_signal_connect(G_OBJECT(gtkconv->u.chat->invite), "clicked", | |
4963 G_CALLBACK(invite_cb), conv); | |
4964 | |
4965 gtk_button_set_relief(GTK_BUTTON(gtkconv->send), | |
4966 GTK_RELIEF_NONE); | |
4967 gtk_button_set_relief(GTK_BUTTON(gtkconv->u.chat->invite), | |
4968 GTK_RELIEF_NONE); | |
4969 | |
4970 gaim_gtkconv_update_buttons_by_protocol(conv); | |
4971 } | |
4972 } | |
4973 } | |
4974 | |
4975 void | |
4976 gaim_gtkconv_update_im_button_style() | |
4977 { | |
4978 GList *l; | |
4979 struct gaim_conversation *conv; | |
4980 struct gaim_gtk_conversation *gtkconv; | |
4981 | |
4982 for (l = gaim_get_ims(); l != NULL; l = l->next) { | |
4983 conv = (struct gaim_conversation *)l->data; | |
4984 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
4985 | |
4986 setup_im_buttons(conv, gtk_widget_get_parent(gtkconv->send)); | |
4987 } | |
4988 } | |
4989 | |
4990 void | |
4991 gaim_gtkconv_update_buttons_by_protocol(struct gaim_conversation *conv) | |
4992 { | |
4993 struct gaim_window *win; | |
4994 struct gaim_gtk_window *gtkwin = NULL; | |
4995 struct gaim_gtk_conversation *gtkconv; | |
4996 struct gaim_connection *gc; | |
4997 | |
4398
a8249a5250b6
[gaim-migrate @ 4667]
Christian Hammond <chipx86@chipx86.com>
parents:
4397
diff
changeset
|
4998 if (!GAIM_IS_GTK_CONVERSATION(conv)) |
4359 | 4999 return; |
5000 | |
5001 gc = gaim_conversation_get_gc(conv); | |
5002 win = gaim_conversation_get_window(conv); | |
5003 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
5004 | |
5005 if (win != NULL) | |
5006 gtkwin = GAIM_GTK_WINDOW(win); | |
5007 | |
5008 if (gc == NULL) { | |
5009 gtk_widget_set_sensitive(gtkconv->send, FALSE); | |
5010 | |
4365
6e96ced6fb78
[gaim-migrate @ 4631]
Christian Hammond <chipx86@chipx86.com>
parents:
4364
diff
changeset
|
5011 if (win != NULL && gaim_window_get_active_conversation(win) == conv) { |
4359 | 5012 gtk_widget_set_sensitive(gtkwin->menu.insert_link, FALSE); |
5013 } | |
5014 } | |
4364
fa56829b9587
[gaim-migrate @ 4630]
Christian Hammond <chipx86@chipx86.com>
parents:
4363
diff
changeset
|
5015 else { |
4674 | 5016 gtk_widget_set_sensitive(gtkconv->send, TRUE); |
4365
6e96ced6fb78
[gaim-migrate @ 4631]
Christian Hammond <chipx86@chipx86.com>
parents:
4364
diff
changeset
|
5017 if (win != NULL) { |
6e96ced6fb78
[gaim-migrate @ 4631]
Christian Hammond <chipx86@chipx86.com>
parents:
4364
diff
changeset
|
5018 gtk_widget_set_sensitive(gtkwin->menu.insert_link, TRUE); |
6e96ced6fb78
[gaim-migrate @ 4631]
Christian Hammond <chipx86@chipx86.com>
parents:
4364
diff
changeset
|
5019 } |
4364
fa56829b9587
[gaim-migrate @ 4630]
Christian Hammond <chipx86@chipx86.com>
parents:
4363
diff
changeset
|
5020 } |
4359 | 5021 |
5022 if (gaim_conversation_get_type(conv) == GAIM_CONV_IM) { | |
5023 if (gc == NULL) { | |
5024 gtk_widget_set_sensitive(gtkconv->info, FALSE); | |
5025 gtk_widget_set_sensitive(gtkconv->u.im->warn, FALSE); | |
5026 gtk_widget_set_sensitive(gtkconv->u.im->block, FALSE); | |
5027 gtk_widget_set_sensitive(gtkconv->u.im->add, FALSE); | |
5028 | |
5029 if (win != NULL && | |
5030 gaim_window_get_active_conversation(win) == conv) { | |
5031 | |
5032 gtk_widget_set_sensitive(gtkwin->menu.insert_image, FALSE); | |
5033 } | |
5034 | |
5035 return; | |
5036 } | |
5037 | |
5038 gtk_widget_set_sensitive(gtkconv->info, | |
5039 (gc->prpl->get_info != NULL)); | |
5040 | |
5041 gtk_widget_set_sensitive(gtkconv->toolbar.image, | |
5042 (gc->prpl->options & OPT_PROTO_IM_IMAGE)); | |
5043 | |
5044 if (win != NULL && gaim_window_get_active_conversation(win) == conv) { | |
5045 gtk_widget_set_sensitive(gtkwin->menu.insert_image, | |
5046 (gc->prpl->options & OPT_PROTO_IM_IMAGE)); | |
5047 } | |
5048 | |
5049 gtk_widget_set_sensitive(gtkconv->u.im->warn, | |
5050 (gc->prpl->warn != NULL)); | |
5051 | |
5052 gtk_widget_set_sensitive(gtkconv->u.im->block, | |
5053 (gc->prpl->add_permit != NULL)); | |
5054 | |
5055 update_convo_add_button(conv); | |
5056 } | |
5057 else if (gaim_conversation_get_type(conv) == GAIM_CONV_CHAT) { | |
5058 if (gc == NULL) { | |
5059 gtk_widget_set_sensitive(gtkconv->u.chat->whisper, FALSE); | |
5060 gtk_widget_set_sensitive(gtkconv->u.chat->invite, FALSE); | |
5061 | |
5062 return; | |
5063 } | |
5064 | |
5065 gtk_widget_set_sensitive(gtkconv->send, (gc->prpl->chat_send != NULL)); | |
5066 | |
5067 gtk_widget_set_sensitive(gtkconv->toolbar.image, FALSE); | |
5068 /* gtk_widget_set_sensitive(gtkwin->menu.insert_image, FALSE); */ | |
5069 | |
5070 gtk_widget_set_sensitive(gtkconv->u.chat->whisper, | |
5071 (gc->prpl->chat_whisper != NULL)); | |
5072 | |
5073 gtk_widget_set_sensitive(gtkconv->u.chat->invite, | |
5074 (gc->prpl->chat_invite != NULL)); | |
5075 } | |
5076 } | |
5077 | |
5078 struct gaim_window * | |
5079 gaim_gtkwin_get_at_xy(int x, int y) | |
5080 { | |
5081 struct gaim_window *win = NULL; | |
5082 struct gaim_gtk_window *gtkwin; | |
5083 GdkWindow *gdkwin; | |
5084 GList *l; | |
5085 | |
5086 gdkwin = gdk_window_at_pointer(&x, &y); | |
5087 | |
5088 if (gdkwin) | |
5089 gdkwin = gdk_window_get_toplevel(gdkwin); | |
5090 | |
5091 for (l = gaim_get_windows(); l != NULL; l = l->next) { | |
5092 win = (struct gaim_window *)l->data; | |
5093 | |
4398
a8249a5250b6
[gaim-migrate @ 4667]
Christian Hammond <chipx86@chipx86.com>
parents:
4397
diff
changeset
|
5094 if (!GAIM_IS_GTK_WINDOW(win)) |
4359 | 5095 continue; |
5096 | |
5097 gtkwin = GAIM_GTK_WINDOW(win); | |
5098 | |
5099 if (gdkwin == gtkwin->window->window) | |
5100 return win; | |
5101 } | |
5102 | |
5103 return NULL; | |
5104 } | |
5105 | |
5106 int | |
5107 gaim_gtkconv_get_tab_at_xy(struct gaim_window *win, int x, int y) | |
5108 { | |
5109 struct gaim_gtk_window *gtkwin; | |
5110 GList *l; | |
5111 gint nb_x, nb_y, x_rel, y_rel; | |
5112 GtkNotebook *notebook; | |
5113 GtkWidget *tab; | |
5114 gint i, page_num = 0; | |
5115 gboolean first_visible = TRUE; | |
5116 | |
4398
a8249a5250b6
[gaim-migrate @ 4667]
Christian Hammond <chipx86@chipx86.com>
parents:
4397
diff
changeset
|
5117 if (!GAIM_IS_GTK_WINDOW(win)) |
4359 | 5118 return -1; |
5119 | |
5120 gtkwin = GAIM_GTK_WINDOW(win); | |
5121 notebook = GTK_NOTEBOOK(gtkwin->notebook); | |
5122 | |
5123 gdk_window_get_origin(gtkwin->notebook->window, &nb_x, &nb_y); | |
5124 x_rel = x - nb_x; | |
5125 y_rel = y - nb_y; | |
5126 | |
5127 for (l = gaim_window_get_conversations(win), i = 0; | |
5128 l != NULL; | |
5129 l = l->next, i++) { | |
5130 | |
5131 struct gaim_conversation *conv = l->data; | |
5132 tab = GAIM_GTK_CONVERSATION(conv)->tab_label; | |
5133 | |
5134 if (!GTK_WIDGET_MAPPED(tab)) | |
5135 continue; | |
5136 | |
5137 if (first_visible) { | |
5138 first_visible = FALSE; | |
5139 | |
5140 if (x_rel < tab->allocation.x) x_rel = tab->allocation.x; | |
5141 if (y_rel < tab->allocation.y) y_rel = tab->allocation.y; | |
5142 } | |
5143 | |
5144 if (gtk_notebook_get_tab_pos(notebook) == GTK_POS_TOP || | |
5145 gtk_notebook_get_tab_pos(notebook) == GTK_POS_BOTTOM) { | |
5146 | |
5147 if (tab->allocation.x <= x_rel) { | |
5148 if (tab->allocation.x + tab->allocation.width <= x_rel) | |
5149 page_num = i + 1; | |
5150 else | |
5151 page_num = i; | |
5152 } | |
5153 else | |
5154 break; | |
5155 } | |
5156 else { | |
5157 if (tab->allocation.y <= y_rel) { | |
5158 if (tab->allocation.y + tab->allocation.height <= y_rel) | |
5159 page_num = i + 1; | |
5160 else | |
5161 page_num = i; | |
5162 } | |
5163 else | |
5164 break; | |
5165 } | |
5166 } | |
5167 | |
5168 if (i == gaim_window_get_conversation_count(win) + 1) | |
5169 return -1; | |
5170 | |
5171 return page_num; | |
5172 } | |
5173 | |
5174 int | |
5175 gaim_gtkconv_get_dest_tab_at_xy(struct gaim_window *win, int x, int y) | |
5176 { | |
5177 struct gaim_gtk_window *gtkwin; | |
5178 GList *l; | |
5179 gint nb_x, nb_y, x_rel, y_rel; | |
5180 GtkNotebook *notebook; | |
5181 GtkWidget *tab; | |
5182 gint i, page_num = 0; | |
5183 | |
4398
a8249a5250b6
[gaim-migrate @ 4667]
Christian Hammond <chipx86@chipx86.com>
parents:
4397
diff
changeset
|
5184 if (!GAIM_IS_GTK_WINDOW(win)) |
4359 | 5185 return -1; |
5186 | |
5187 gtkwin = GAIM_GTK_WINDOW(win); | |
5188 notebook = GTK_NOTEBOOK(gtkwin->notebook); | |
5189 | |
5190 gdk_window_get_origin(gtkwin->notebook->window, &nb_x, &nb_y); | |
5191 x_rel = x - nb_x; | |
5192 y_rel = y - nb_y; | |
5193 | |
5194 for (l = gaim_window_get_conversations(win), i = 0; | |
5195 l != NULL; | |
5196 l = l->next, i++) { | |
5197 | |
5198 struct gaim_conversation *conv = l->data; | |
5199 tab = GAIM_GTK_CONVERSATION(conv)->tab_label; | |
5200 | |
5201 if (!GTK_WIDGET_MAPPED(tab)) | |
5202 continue; | |
5203 | |
5204 if (gtk_notebook_get_tab_pos(notebook) == GTK_POS_TOP || | |
5205 gtk_notebook_get_tab_pos(notebook) == GTK_POS_BOTTOM) { | |
5206 | |
5207 if (tab->allocation.x <= x_rel) { | |
5208 if (tab->allocation.x + (tab->allocation.width / 2) <= x_rel) | |
5209 page_num = i + 1; | |
5210 else | |
5211 page_num = i; | |
5212 } | |
5213 else | |
5214 break; | |
5215 } | |
5216 else { | |
5217 if (tab->allocation.y <= y_rel) { | |
5218 if (tab->allocation.y + (tab->allocation.height / 2) <= y_rel) | |
5219 page_num = i + 1; | |
5220 else | |
5221 page_num = i; | |
5222 } | |
5223 else | |
5224 break; | |
5225 } | |
5226 } | |
5227 | |
5228 if (i == gaim_window_get_conversation_count(win) + 1) | |
5229 return -1; | |
5230 | |
5231 return page_num; | |
5232 } | |
4940
3708545afe42
[gaim-migrate @ 5274]
Christian Hammond <chipx86@chipx86.com>
parents:
4939
diff
changeset
|
5233 |