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