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