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