Mercurial > pidgin.yaz
annotate src/gtkconv.c @ 4785:1e28e7d802a1
[gaim-migrate @ 5105]
fix a few things, get rid of a few stale functions, and get rid of the
compatibility functions. wee!
committer: Tailor Script <tailor@pidgin.im>
author | Nathan Walp <nwalp@pidgin.im> |
---|---|
date | Sat, 15 Mar 2003 03:23:30 +0000 |
parents | b6f33ba0a0c0 |
children | 01e349782075 |
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 | |
1966 if (conv == NULL) | |
4685 | 1967 return FALSE; |
4359 | 1968 |
4491 | 1969 account = gaim_conversation_get_account(conv); |
4359 | 1970 gtkwin = GAIM_GTK_WINDOW(win); |
1971 | |
4491 | 1972 if (account == NULL) |
4685 | 1973 return FALSE; |
4466
473de7371a97
[gaim-migrate @ 4741]
Christian Hammond <chipx86@chipx86.com>
parents:
4465
diff
changeset
|
1974 |
4364
fa56829b9587
[gaim-migrate @ 4630]
Christian Hammond <chipx86@chipx86.com>
parents:
4363
diff
changeset
|
1975 if (gtkwin->menu.send_as == NULL) |
4685 | 1976 return FALSE; |
4364
fa56829b9587
[gaim-migrate @ 4630]
Christian Hammond <chipx86@chipx86.com>
parents:
4363
diff
changeset
|
1977 |
4359 | 1978 gtk_widget_show(gtkwin->menu.send_as); |
1979 | |
1980 menu = gtk_menu_item_get_submenu( | |
1981 GTK_MENU_ITEM(gtkwin->menu.send_as)); | |
1982 | |
1983 for (child = gtk_container_get_children(GTK_CONTAINER(menu)); | |
1984 child != NULL; | |
1985 child = child->next) { | |
1986 | |
1987 GtkWidget *item = child->data; | |
4673 | 1988 struct gaim_account *item_account = g_object_get_data(G_OBJECT(item), |
1989 "gaim_account"); | |
1990 | |
1991 if (account == item_account) { | |
4359 | 1992 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(item), TRUE); |
1993 break; | |
1994 } | |
1995 } | |
4685 | 1996 return FALSE; |
4359 | 1997 } |
1998 | |
1999 static void | |
4360
c435a29370b8
[gaim-migrate @ 4626]
Christian Hammond <chipx86@chipx86.com>
parents:
4359
diff
changeset
|
2000 generate_send_as_items(struct gaim_window *win, |
c435a29370b8
[gaim-migrate @ 4626]
Christian Hammond <chipx86@chipx86.com>
parents:
4359
diff
changeset
|
2001 struct gaim_conversation *deleted_conv) |
4359 | 2002 { |
2003 struct gaim_gtk_window *gtkwin; | |
2004 GtkWidget *menu; | |
2005 GtkWidget *menuitem; | |
2006 GSList *gcs; | |
2007 GList *convs; | |
2008 GSList *group = NULL; | |
2009 gboolean first_offline = TRUE; | |
2010 gboolean found_online = FALSE; | |
4669
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2011 GtkSizeGroup *sg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL); |
4359 | 2012 |
2013 gtkwin = GAIM_GTK_WINDOW(win); | |
2014 | |
2015 if (gtkwin->menu.send_as != NULL) | |
2016 gtk_widget_destroy(gtkwin->menu.send_as); | |
2017 | |
2018 /* See if we have > 1 connection active. */ | |
2019 if (g_slist_length(connections) < 2) { | |
2020 /* Now make sure we don't have any Offline entries. */ | |
2021 gboolean found_offline = FALSE; | |
2022 | |
2023 for (convs = gaim_get_conversations(); | |
2024 convs != NULL; | |
2025 convs = convs->next) { | |
2026 | |
2027 struct gaim_conversation *conv; | |
4491 | 2028 struct gaim_account *account; |
2029 | |
4359 | 2030 conv = (struct gaim_conversation *)convs->data; |
4491 | 2031 account = gaim_conversation_get_account(conv); |
2032 | |
2033 if (account->gc == NULL) { | |
4359 | 2034 found_offline = TRUE; |
2035 break; | |
2036 } | |
2037 } | |
2038 | |
2039 if (!found_offline) { | |
2040 gtkwin->menu.send_as = NULL; | |
2041 return; | |
2042 } | |
2043 } | |
2044 | |
2045 /* Build the Send As menu */ | |
2046 gtkwin->menu.send_as = gtk_menu_item_new_with_mnemonic(_("_Send As")); | |
2047 gtk_widget_show(gtkwin->menu.send_as); | |
2048 | |
2049 menu = gtk_menu_new(); | |
2050 | |
2051 gtk_menu_shell_append(GTK_MENU_SHELL(gtkwin->menu.menubar), | |
2052 gtkwin->menu.send_as); | |
2053 gtk_menu_item_set_submenu(GTK_MENU_ITEM(gtkwin->menu.send_as), menu); | |
2054 | |
2055 gtk_widget_show(menu); | |
2056 | |
2057 /* Fill it with entries. */ | |
2058 for (gcs = connections; gcs != NULL; gcs = gcs->next) { | |
4668
6e7196dcfd37
[gaim-migrate @ 4979]
Christian Hammond <chipx86@chipx86.com>
parents:
4640
diff
changeset
|
2059 |
4359 | 2060 struct gaim_connection *gc; |
4669
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2061 GtkWidget *box; |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2062 GtkWidget *label; |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2063 GtkWidget *image; |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
2064 GdkPixbuf *pixbuf, *scale; |
4359 | 2065 |
2066 found_online = TRUE; | |
2067 | |
2068 gc = (struct gaim_connection *)gcs->data; | |
2069 | |
4669
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2070 /* Create a pixmap for the protocol icon. */ |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
2071 pixbuf = create_prpl_icon(gc->account); |
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
2072 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
|
2073 |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2074 /* Now convert it to GtkImage */ |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
2075 if (pixbuf == NULL) |
4669
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2076 image = gtk_image_new(); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2077 else |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
2078 image = gtk_image_new_from_pixbuf(scale); |
4669
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2079 |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2080 gtk_size_group_add_widget(sg, image); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2081 |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
2082 g_object_unref(G_OBJECT(scale)); |
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
2083 g_object_unref(G_OBJECT(pixbuf)); |
4669
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2084 |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2085 /* Make our menu item */ |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2086 menuitem = gtk_radio_menu_item_new_with_label(group, gc->username); |
4359 | 2087 group = gtk_radio_menu_item_group(GTK_RADIO_MENU_ITEM(menuitem)); |
2088 | |
4669
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2089 /* Do some evil, see some evil, speak some evil. */ |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2090 box = gtk_hbox_new(FALSE, 0); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2091 |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2092 label = gtk_bin_get_child(GTK_BIN(menuitem)); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2093 g_object_ref(label); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2094 gtk_container_remove(GTK_CONTAINER(menuitem), label); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2095 |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2096 gtk_box_pack_start(GTK_BOX(box), image, FALSE, FALSE, 0); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2097 gtk_box_pack_start(GTK_BOX(box), label, TRUE, TRUE, 4); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2098 |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2099 g_object_unref(label); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2100 |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2101 gtk_container_add(GTK_CONTAINER(menuitem), box); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2102 |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2103 gtk_widget_show(label); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2104 gtk_widget_show(image); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2105 gtk_widget_show(box); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2106 |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2107 /* Set our data and callbacks. */ |
4359 | 2108 g_object_set_data(G_OBJECT(menuitem), "user_data", win); |
4673 | 2109 g_object_set_data(G_OBJECT(menuitem), "gaim_account", gc->account); |
4359 | 2110 |
4685 | 2111 g_signal_connect_after(G_OBJECT(menuitem), "activate", |
4673 | 2112 G_CALLBACK(menu_conv_sel_send_cb), NULL); |
4359 | 2113 |
2114 gtk_widget_show(menuitem); | |
2115 gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem); | |
2116 } | |
2117 | |
2118 /* | |
2119 * Fill it with any accounts that still has an open (yet disabled) window | |
2120 * (signed off accounts with a window open). | |
2121 */ | |
2122 for (convs = gaim_get_conversations(); | |
2123 convs != NULL; | |
2124 convs = convs->next) { | |
2125 | |
2126 struct gaim_conversation *conv; | |
4491 | 2127 struct gaim_account *account; |
4669
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2128 GtkWidget *box; |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2129 GtkWidget *label; |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2130 GtkWidget *image; |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
2131 GdkPixbuf *pixbuf, *scale; |
4359 | 2132 |
2133 conv = (struct gaim_conversation *)convs->data; | |
4360
c435a29370b8
[gaim-migrate @ 4626]
Christian Hammond <chipx86@chipx86.com>
parents:
4359
diff
changeset
|
2134 |
c435a29370b8
[gaim-migrate @ 4626]
Christian Hammond <chipx86@chipx86.com>
parents:
4359
diff
changeset
|
2135 if (conv == deleted_conv) |
c435a29370b8
[gaim-migrate @ 4626]
Christian Hammond <chipx86@chipx86.com>
parents:
4359
diff
changeset
|
2136 continue; |
c435a29370b8
[gaim-migrate @ 4626]
Christian Hammond <chipx86@chipx86.com>
parents:
4359
diff
changeset
|
2137 |
4491 | 2138 account = gaim_conversation_get_account(conv); |
2139 | |
2140 if (account->gc == NULL) { | |
4359 | 2141 if (first_offline && found_online) { |
2142 menuitem = gtk_separator_menu_item_new(); | |
2143 gtk_widget_show(menuitem); | |
2144 gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem); | |
2145 | |
2146 first_offline = FALSE; | |
2147 } | |
2148 | |
4669
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2149 /* Create a pixmap for the protocol icon. */ |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
2150 pixbuf = create_prpl_icon(account); |
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
2151 scale = gdk_pixbuf_scale_simple(pixbuf, 16, 16, |
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
2152 GDK_INTERP_BILINEAR); |
4669
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2153 |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2154 /* Now convert it to GtkImage */ |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
2155 if (pixbuf == NULL) |
4669
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2156 image = gtk_image_new(); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2157 else |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
2158 image = gtk_image_new_from_pixbuf(scale); |
4669
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2159 |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2160 gtk_size_group_add_widget(sg, image); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2161 |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
2162 if (scale != NULL) g_object_unref(scale); |
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
2163 if (pixbuf != NULL) g_object_unref(pixbuf); |
4669
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2164 |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2165 /* Make our menu item */ |
4359 | 2166 menuitem = gtk_radio_menu_item_new_with_label(group, |
4491 | 2167 account->username); |
4359 | 2168 group = gtk_radio_menu_item_group(GTK_RADIO_MENU_ITEM(menuitem)); |
2169 | |
4669
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2170 /* Do some evil, see some evil, speak some evil. */ |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2171 box = gtk_hbox_new(FALSE, 0); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2172 |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2173 label = gtk_bin_get_child(GTK_BIN(menuitem)); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2174 g_object_ref(label); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2175 gtk_container_remove(GTK_CONTAINER(menuitem), label); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2176 |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2177 gtk_box_pack_start(GTK_BOX(box), image, FALSE, FALSE, 0); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2178 gtk_box_pack_start(GTK_BOX(box), label, TRUE, TRUE, 4); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2179 |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2180 g_object_unref(label); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2181 |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2182 gtk_container_add(GTK_CONTAINER(menuitem), box); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2183 |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2184 gtk_widget_show(label); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2185 gtk_widget_show(image); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2186 gtk_widget_show(box); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2187 |
4359 | 2188 gtk_widget_set_sensitive(menuitem, FALSE); |
4674 | 2189 g_object_set_data(G_OBJECT(menuitem), "gaim_account", account); |
4359 | 2190 |
2191 gtk_widget_show(menuitem); | |
2192 gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem); | |
2193 } | |
2194 } | |
2195 | |
4669
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2196 g_object_unref(sg); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2197 |
4359 | 2198 gtk_widget_show(gtkwin->menu.send_as); |
2199 update_send_as_selection(win); | |
2200 } | |
2201 | |
2202 static GList * | |
2203 generate_invite_user_names(struct gaim_connection *gc) | |
2204 { | |
4785 | 2205 GaimBlistNode *gnode,*bnode; |
4359 | 2206 struct group *g; |
2207 struct buddy *buddy; | |
2208 static GList *tmp = NULL; | |
2209 | |
2210 if (tmp) | |
2211 g_list_free(tmp); | |
2212 | |
2213 tmp = g_list_append(NULL, ""); | |
2214 | |
2215 if (gc != NULL) { | |
4785 | 2216 for(gnode = gaim_get_blist()->root; gnode; gnode = gnode->next) { |
2217 if(!GAIM_BLIST_NODE_IS_GROUP(gnode)) | |
2218 continue; | |
2219 g = (struct group *)gnode; | |
2220 for(bnode = gnode->child; bnode; bnode = bnode->next) { | |
2221 if(!GAIM_BLIST_NODE_IS_BUDDY(bnode)) | |
2222 continue; | |
2223 buddy = (struct buddy *)bnode; | |
2224 | |
2225 if (buddy->account == gc->account && buddy->present) | |
4359 | 2226 tmp = g_list_append(tmp, buddy->name); |
2227 } | |
2228 } | |
2229 } | |
2230 | |
2231 return tmp; | |
2232 } | |
2233 | |
2234 static void | |
2235 add_chat_buddy_common(struct gaim_conversation *conv, const char *name, | |
2236 int pos) | |
2237 { | |
2238 struct gaim_gtk_conversation *gtkconv; | |
2239 struct gaim_gtk_chat_pane *gtkchat; | |
2240 struct gaim_chat *chat; | |
2241 GtkTreeIter iter; | |
2242 GtkListStore *ls; | |
2243 | |
2244 chat = GAIM_CHAT(conv); | |
2245 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
2246 gtkchat = gtkconv->u.chat; | |
2247 | |
2248 ls = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list))); | |
2249 | |
2250 gtk_list_store_append(ls, &iter); | |
2251 gtk_list_store_set(ls, &iter, 0, | |
2252 (gaim_chat_is_user_ignored(chat, name) ? "X" : " "), | |
2253 1, name, -1); | |
2254 gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(ls), 1, | |
2255 GTK_SORT_ASCENDING); | |
2256 } | |
2257 | |
2258 static void | |
2259 tab_complete(struct gaim_conversation *conv) | |
2260 { | |
2261 struct gaim_gtk_conversation *gtkconv; | |
2262 struct gaim_chat *chat; | |
2263 GtkTextIter cursor, word_start, start_buffer; | |
2264 int start; | |
2265 int most_matched = -1; | |
2266 char *entered, *partial = NULL; | |
2267 char *text; | |
2268 GList *matches = NULL; | |
2269 GList *nicks = NULL; | |
2270 | |
2271 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
2272 chat = GAIM_CHAT(conv); | |
2273 | |
2274 gtk_text_buffer_get_start_iter(gtkconv->entry_buffer, &start_buffer); | |
2275 gtk_text_buffer_get_iter_at_mark(gtkconv->entry_buffer, &cursor, | |
2276 gtk_text_buffer_get_insert(gtkconv->entry_buffer)); | |
2277 | |
2278 word_start = cursor; | |
2279 | |
2280 /* if there's nothing there just return */ | |
2281 if (!gtk_text_iter_compare(&cursor, &start_buffer)) | |
2282 return; | |
2283 | |
2284 text = gtk_text_buffer_get_text(gtkconv->entry_buffer, &start_buffer, | |
2285 &cursor, FALSE); | |
2286 | |
2287 /* if we're at the end of ": " we need to move back 2 spaces */ | |
2288 start = strlen(text) - 1; | |
2289 | |
2290 if (strlen(text) >= 2 && !strncmp(&text[start-1], ": ", 2)) | |
2291 gtk_text_iter_backward_chars(&word_start, 2); | |
2292 | |
2293 /* find the start of the word that we're tabbing */ | |
2294 while (start >= 0 && text[start] != ' ') { | |
2295 gtk_text_iter_backward_char(&word_start); | |
2296 start--; | |
2297 } | |
2298 | |
2299 g_free(text); | |
2300 | |
2301 entered = gtk_text_buffer_get_text(gtkconv->entry_buffer, &word_start, | |
2302 &cursor, FALSE); | |
2303 | |
2304 if (chat_options & OPT_CHAT_OLD_STYLE_TAB) { | |
2305 if (strlen(entered) >= 2 && | |
2306 !strncmp(": ", entered + strlen(entered) - 2, 2)) { | |
2307 | |
2308 entered[strlen(entered) - 2] = 0; | |
2309 } | |
2310 } | |
2311 | |
2312 if (!strlen(entered)) { | |
2313 g_free(entered); | |
2314 return; | |
2315 } | |
2316 | |
2317 for (nicks = gaim_chat_get_users(chat); | |
2318 nicks != NULL; | |
2319 nicks = nicks->next) { | |
2320 | |
2321 char *nick = nicks->data; | |
2322 /* this checks to see if the current nick could be a completion */ | |
2323 if (g_strncasecmp(nick, entered, strlen(entered))) { | |
4621
69f028a6f357
[gaim-migrate @ 4912]
Christian Hammond <chipx86@chipx86.com>
parents:
4608
diff
changeset
|
2324 if (*nick != '+' && *nick != '@' && *nick != '%') |
4359 | 2325 continue; |
2326 | |
2327 if (g_strncasecmp(nick + 1, entered, strlen(entered))) { | |
2328 if (nick[0] != '@' || nick[1] != '+') | |
2329 continue; | |
2330 | |
2331 if (g_strncasecmp(nick + 2, entered, strlen(entered))) | |
2332 continue; | |
2333 else | |
2334 nick += 2; | |
2335 } | |
2336 else | |
2337 nick++; | |
2338 } | |
2339 | |
2340 /* if we're here, it's a possible completion */ | |
2341 | |
2342 /* if we're doing old-style, just fill in the completion */ | |
2343 if (chat_options & OPT_CHAT_OLD_STYLE_TAB) { | |
2344 gtk_text_buffer_delete(gtkconv->entry_buffer, | |
2345 &word_start, &cursor); | |
2346 | |
2347 if (strlen(nick) == strlen(entered)) { | |
2348 nicks = (nicks->next | |
2349 ? nicks->next | |
2350 : gaim_chat_get_users(chat)); | |
2351 | |
2352 nick = nicks->data; | |
2353 | |
2354 if (*nick == '@') nick++; | |
4621
69f028a6f357
[gaim-migrate @ 4912]
Christian Hammond <chipx86@chipx86.com>
parents:
4608
diff
changeset
|
2355 if (*nick == '%') nick++; |
4359 | 2356 if (*nick == '+') nick++; |
2357 } | |
2358 | |
2359 gtk_text_buffer_get_start_iter(gtkconv->entry_buffer, | |
2360 &start_buffer); | |
2361 gtk_text_buffer_get_iter_at_mark(gtkconv->entry_buffer, &cursor, | |
2362 gtk_text_buffer_get_insert(gtkconv->entry_buffer)); | |
2363 | |
2364 if (!gtk_text_iter_compare(&cursor, &start_buffer)) { | |
2365 char *tmp = g_strdup_printf("%s: ", nick); | |
2366 gtk_text_buffer_insert_at_cursor(gtkconv->entry_buffer, | |
2367 tmp, -1); | |
2368 g_free(tmp); | |
2369 } | |
2370 else | |
2371 gtk_text_buffer_insert_at_cursor(gtkconv->entry_buffer, | |
2372 nick, -1); | |
2373 | |
2374 g_free(entered); | |
2375 | |
2376 return; | |
2377 } | |
2378 | |
2379 /* we're only here if we're doing new style */ | |
2380 if (most_matched == -1) { | |
2381 /* | |
2382 * this will only get called once, since from now | |
2383 * on most_matched is >= 0 | |
2384 */ | |
2385 most_matched = strlen(nick); | |
2386 partial = g_strdup(nick); | |
2387 } | |
2388 else if (most_matched) { | |
2389 while (g_strncasecmp(nick, partial, most_matched)) | |
2390 most_matched--; | |
2391 | |
2392 partial[most_matched] = 0; | |
2393 } | |
2394 | |
2395 matches = g_list_append(matches, nick); | |
2396 } | |
2397 | |
2398 /* we're only here if we're doing new style */ | |
2399 | |
2400 /* if there weren't any matches, return */ | |
2401 if (!matches) { | |
2402 /* if matches isn't set partials won't be either */ | |
2403 g_free(entered); | |
2404 return; | |
2405 } | |
2406 | |
2407 gtk_text_buffer_delete(gtkconv->entry_buffer, &word_start, &cursor); | |
2408 | |
2409 if (!matches->next) { | |
2410 /* there was only one match. fill it in. */ | |
2411 gtk_text_buffer_get_start_iter(gtkconv->entry_buffer, &start_buffer); | |
2412 gtk_text_buffer_get_iter_at_mark(gtkconv->entry_buffer, &cursor, | |
2413 gtk_text_buffer_get_insert(gtkconv->entry_buffer)); | |
2414 | |
2415 if (!gtk_text_iter_compare(&cursor, &start_buffer)) { | |
2416 char *tmp = g_strdup_printf("%s: ", (char *)matches->data); | |
2417 gtk_text_buffer_insert_at_cursor(gtkconv->entry_buffer, tmp, -1); | |
2418 g_free(tmp); | |
2419 } | |
2420 else | |
2421 gtk_text_buffer_insert_at_cursor(gtkconv->entry_buffer, | |
2422 matches->data, -1); | |
2423 | |
2424 matches = g_list_remove(matches, matches->data); | |
2425 } | |
2426 else { | |
2427 /* | |
2428 * there were lots of matches, fill in as much as possible | |
2429 * and display all of them | |
2430 */ | |
2431 char *addthis = g_malloc0(1); | |
2432 | |
2433 while (matches) { | |
2434 char *tmp = addthis; | |
2435 addthis = g_strconcat(tmp, matches->data, " ", NULL); | |
2436 g_free(tmp); | |
2437 matches = g_list_remove(matches, matches->data); | |
2438 } | |
2439 | |
2440 gaim_conversation_write(conv, NULL, addthis, -1, WFLAG_NOLOG, | |
2441 time(NULL)); | |
2442 gtk_text_buffer_insert_at_cursor(gtkconv->entry_buffer, partial, -1); | |
2443 g_free(addthis); | |
2444 } | |
2445 | |
2446 g_free(entered); | |
2447 g_free(partial); | |
2448 } | |
2449 | |
2450 static gboolean | |
2451 meify(char *message, size_t len) | |
2452 { | |
2453 /* | |
2454 * Read /me-ify: If the message (post-HTML) starts with /me, | |
2455 * remove the "/me " part of it (including that space) and return TRUE. | |
2456 */ | |
2457 char *c; | |
2458 gboolean inside_html = 0; | |
2459 | |
2460 if (message == NULL) | |
2461 return FALSE; /* Umm.. this would be very bad if this happens. */ | |
2462 | |
2463 if (len == -1) | |
2464 len = strlen(message); | |
2465 | |
2466 for (c = message; *c != '\0'; c++, len--) { | |
2467 if (inside_html) { | |
2468 if (*c == '>') | |
2469 inside_html = FALSE; | |
2470 } | |
2471 else { | |
2472 if (*c == '<') | |
2473 inside_html = TRUE; | |
2474 else | |
2475 break; | |
2476 } | |
2477 } | |
2478 | |
2479 if (*c != '\0' && !g_strncasecmp(c, "/me ", 4)) { | |
2480 memmove(c, c + 4, len - 3); | |
2481 | |
2482 return TRUE; | |
2483 } | |
2484 | |
2485 return FALSE; | |
2486 } | |
2487 | |
2488 static GtkItemFactoryEntry menu_items[] = | |
2489 { | |
2490 /* Conversation menu */ | |
4596 | 2491 { N_("/_Conversation"), NULL, NULL, 0, "<Branch>" }, |
2492 { N_("/Conversation/_Save As..."), NULL, menu_save_as_cb, 0, | |
4359 | 2493 "<StockItem>", GTK_STOCK_SAVE_AS }, |
4596 | 2494 { N_("/Conversation/View _History..."), NULL, menu_view_history_cb, 0, NULL }, |
4359 | 2495 { "/Conversation/sep1", NULL, NULL, 0, "<Separator>" }, |
4596 | 2496 { N_("/Conversation/Insert _URL..."), NULL, menu_insert_link_cb, 0, |
4359 | 2497 "<StockItem>", GAIM_STOCK_LINK }, |
4596 | 2498 { N_("/Conversation/Insert _Image..."), NULL, menu_insert_image_cb, 0, |
4359 | 2499 "<StockItem>", GAIM_STOCK_IMAGE }, |
2500 { "/Conversation/sep2", NULL, NULL, 0, "<Separator>" }, | |
4596 | 2501 { N_("/Conversation/_Close"), NULL, menu_close_conv_cb, 0, |
4359 | 2502 "<StockItem>", GTK_STOCK_CLOSE }, |
2503 | |
2504 /* Options */ | |
4596 | 2505 { N_("/_Options"), NULL, NULL, 0, "<Branch>" }, |
2506 { N_("/Options/Enable _Logging"), NULL, menu_logging_cb, 0, "<CheckItem>" }, | |
2507 { N_("/Options/Enable _Sounds"), NULL, menu_sounds_cb, 0, "<CheckItem>" }, | |
4359 | 2508 }; |
2509 | |
4602
4128761bacb8
[gaim-migrate @ 4889]
Christian Hammond <chipx86@chipx86.com>
parents:
4598
diff
changeset
|
2510 static const int menu_item_count = |
4359 | 2511 sizeof(menu_items) / sizeof(*menu_items); |
2512 | |
4602
4128761bacb8
[gaim-migrate @ 4889]
Christian Hammond <chipx86@chipx86.com>
parents:
4598
diff
changeset
|
2513 static char * |
4128761bacb8
[gaim-migrate @ 4889]
Christian Hammond <chipx86@chipx86.com>
parents:
4598
diff
changeset
|
2514 item_factory_translate_func (const char *path, gpointer func_data) |
4128761bacb8
[gaim-migrate @ 4889]
Christian Hammond <chipx86@chipx86.com>
parents:
4598
diff
changeset
|
2515 { |
4128761bacb8
[gaim-migrate @ 4889]
Christian Hammond <chipx86@chipx86.com>
parents:
4598
diff
changeset
|
2516 return _(path); |
4128761bacb8
[gaim-migrate @ 4889]
Christian Hammond <chipx86@chipx86.com>
parents:
4598
diff
changeset
|
2517 } |
4128761bacb8
[gaim-migrate @ 4889]
Christian Hammond <chipx86@chipx86.com>
parents:
4598
diff
changeset
|
2518 |
4359 | 2519 static GtkWidget * |
2520 setup_menubar(struct gaim_window *win) | |
2521 { | |
2522 struct gaim_gtk_window *gtkwin; | |
2523 GtkWidget *hb; | |
2524 | |
2525 gtkwin = GAIM_GTK_WINDOW(win); | |
2526 | |
2527 /* Create the handle box. */ | |
2528 hb = gtk_handle_box_new(); | |
2529 | |
4630 | 2530 gtkwin->menu.item_factory = gtk_item_factory_new(GTK_TYPE_MENU_BAR, |
2531 "<main>", NULL); | |
2532 | |
2533 gtk_item_factory_set_translate_func (gtkwin->menu.item_factory, | |
4602
4128761bacb8
[gaim-migrate @ 4889]
Christian Hammond <chipx86@chipx86.com>
parents:
4598
diff
changeset
|
2534 item_factory_translate_func, |
4128761bacb8
[gaim-migrate @ 4889]
Christian Hammond <chipx86@chipx86.com>
parents:
4598
diff
changeset
|
2535 NULL, NULL); |
4630 | 2536 |
2537 gtk_item_factory_create_items(gtkwin->menu.item_factory, menu_item_count, | |
4359 | 2538 menu_items, win); |
2539 | |
4630 | 2540 gtkwin->menu.menubar = gtk_item_factory_get_widget(gtkwin->menu.item_factory, |
2541 "<main>"); | |
2542 gtkwin->menu.view_history = gtk_item_factory_get_widget(gtkwin->menu.item_factory, | |
4359 | 2543 "/Conversation/View History..."); |
4630 | 2544 gtkwin->menu.insert_link = gtk_item_factory_get_widget(gtkwin->menu.item_factory, |
4359 | 2545 "/Conversation/Insert URL..."); |
4630 | 2546 gtkwin->menu.insert_image = gtk_item_factory_get_widget(gtkwin->menu.item_factory, |
4359 | 2547 "/Conversation/Insert Image..."); |
4630 | 2548 gtkwin->menu.logging = gtk_item_factory_get_widget(gtkwin->menu.item_factory, |
4359 | 2549 "/Options/Enable Logging"); |
4630 | 2550 gtkwin->menu.sounds = gtk_item_factory_get_widget(gtkwin->menu.item_factory, |
4359 | 2551 "/Options/Enable Sounds"); |
2552 | |
4360
c435a29370b8
[gaim-migrate @ 4626]
Christian Hammond <chipx86@chipx86.com>
parents:
4359
diff
changeset
|
2553 generate_send_as_items(win, NULL); |
4359 | 2554 |
2555 gtk_container_add(GTK_CONTAINER(hb), gtkwin->menu.menubar); | |
2556 | |
2557 gtk_widget_show(gtkwin->menu.menubar); | |
2558 gtk_widget_show(hb); | |
2559 | |
2560 return hb; | |
2561 } | |
2562 | |
2563 static void | |
2564 setup_im_buttons(struct gaim_conversation *conv, GtkWidget *parent) | |
2565 { | |
2566 struct gaim_connection *gc; | |
2567 struct gaim_gtk_conversation *gtkconv; | |
2568 struct gaim_gtk_im_pane *gtkim; | |
2569 GaimConversationType type = GAIM_CONV_IM; | |
2570 | |
2571 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
2572 gtkim = gtkconv->u.im; | |
2573 gc = gaim_conversation_get_gc(conv); | |
2574 | |
2575 /* From right to left... */ | |
2576 | |
2577 /* Send button */ | |
2578 gtkconv->send = gaim_gtk_change_text(_("Send"), gtkconv->send, | |
2579 GAIM_STOCK_SEND, type); | |
2580 gtk_tooltips_set_tip(gtkconv->tooltips, gtkconv->send, _("Send"), NULL); | |
2581 | |
2582 gtk_box_pack_end(GTK_BOX(parent), gtkconv->send, FALSE, FALSE, 0); | |
2583 | |
2584 /* Separator */ | |
2585 if (gtkim->sep2 != NULL) | |
2586 gtk_widget_destroy(gtkim->sep2); | |
2587 | |
2588 gtkim->sep2 = gtk_vseparator_new(); | |
2589 gtk_box_pack_end(GTK_BOX(parent), gtkim->sep2, FALSE, TRUE, 0); | |
2590 gtk_widget_show(gtkim->sep2); | |
2591 | |
2592 /* Now, um, just kind of all over the place. Huh? */ | |
2593 | |
2594 /* Add button */ | |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
2595 if (gaim_find_buddy(gaim_conversation_get_account(conv), |
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
2596 gaim_conversation_get_name(conv)) == NULL) { |
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
2597 |
4359 | 2598 gtkim->add = gaim_gtk_change_text(_("Add"), gtkim->add, |
2599 GTK_STOCK_ADD, type); | |
2600 gtk_tooltips_set_tip(gtkconv->tooltips, gtkim->add, | |
4370
d856987c72ca
[gaim-migrate @ 4636]
Christian Hammond <chipx86@chipx86.com>
parents:
4369
diff
changeset
|
2601 _("Add the user to your buddy list"), NULL); |
4359 | 2602 } |
2603 else { | |
2604 gtkim->add = gaim_gtk_change_text(_("Remove"), gtkim->add, | |
2605 GTK_STOCK_REMOVE, 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 _("Remove the user from your buddy list"), NULL); |
4359 | 2608 } |
2609 | |
2610 gtk_box_pack_start(GTK_BOX(parent), gtkim->add, | |
2611 FALSE, FALSE, 0); | |
2612 | |
2613 /* Warn button */ | |
2614 gtkim->warn = gaim_gtk_change_text(_("Warn"), gtkim->warn, | |
2615 GAIM_STOCK_WARN, type); | |
2616 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
|
2617 gtk_tooltips_set_tip(gtkconv->tooltips, gtkim->warn, |
d856987c72ca
[gaim-migrate @ 4636]
Christian Hammond <chipx86@chipx86.com>
parents:
4369
diff
changeset
|
2618 _("Warn the user"), NULL); |
4359 | 2619 |
2620 /* Info button */ | |
2621 gtkconv->info = gaim_gtk_change_text(_("Info"), gtkconv->info, | |
2622 GAIM_STOCK_INFO, type); | |
2623 gtk_box_pack_start(GTK_BOX(parent), gtkconv->info, FALSE, FALSE, 0); | |
2624 gtk_tooltips_set_tip(gtkconv->tooltips, gtkconv->info, | |
4370
d856987c72ca
[gaim-migrate @ 4636]
Christian Hammond <chipx86@chipx86.com>
parents:
4369
diff
changeset
|
2625 _("Get the user's information"), NULL); |
4359 | 2626 |
2627 /* Block button */ | |
2628 gtkim->block = gaim_gtk_change_text(_("Block"), gtkim->block, | |
2629 GAIM_STOCK_BLOCK, type); | |
2630 gtk_box_pack_start(GTK_BOX(parent), gtkim->block, FALSE, FALSE, 0); | |
2631 gtk_tooltips_set_tip(gtkconv->tooltips, gtkim->block, | |
4370
d856987c72ca
[gaim-migrate @ 4636]
Christian Hammond <chipx86@chipx86.com>
parents:
4369
diff
changeset
|
2632 _("Block the user"), NULL); |
4359 | 2633 |
2634 gtk_button_set_relief(GTK_BUTTON(gtkconv->info), GTK_RELIEF_NONE); | |
2635 gtk_button_set_relief(GTK_BUTTON(gtkim->add), GTK_RELIEF_NONE); | |
2636 gtk_button_set_relief(GTK_BUTTON(gtkim->warn), GTK_RELIEF_NONE); | |
2637 gtk_button_set_relief(GTK_BUTTON(gtkconv->send), GTK_RELIEF_NONE); | |
2638 gtk_button_set_relief(GTK_BUTTON(gtkim->block), GTK_RELIEF_NONE); | |
2639 | |
2640 gtk_size_group_add_widget(gtkconv->sg, gtkconv->info); | |
2641 gtk_size_group_add_widget(gtkconv->sg, gtkim->add); | |
2642 gtk_size_group_add_widget(gtkconv->sg, gtkim->warn); | |
2643 gtk_size_group_add_widget(gtkconv->sg, gtkconv->send); | |
2644 gtk_size_group_add_widget(gtkconv->sg, gtkim->block); | |
2645 | |
2646 gtk_box_reorder_child(GTK_BOX(parent), gtkim->warn, 1); | |
2647 gtk_box_reorder_child(GTK_BOX(parent), gtkim->block, 2); | |
4370
d856987c72ca
[gaim-migrate @ 4636]
Christian Hammond <chipx86@chipx86.com>
parents:
4369
diff
changeset
|
2648 gtk_box_reorder_child(GTK_BOX(parent), gtkim->add, 3); |
4359 | 2649 gtk_box_reorder_child(GTK_BOX(parent), gtkconv->info, 4); |
2650 | |
2651 gaim_gtkconv_update_buttons_by_protocol(conv); | |
2652 | |
2653 g_signal_connect(G_OBJECT(gtkconv->send), "clicked", | |
2654 G_CALLBACK(send_cb), conv); | |
2655 g_signal_connect(G_OBJECT(gtkconv->info), "clicked", | |
2656 G_CALLBACK(info_cb), conv); | |
2657 g_signal_connect(G_OBJECT(gtkim->warn), "clicked", | |
2658 G_CALLBACK(warn_cb), conv); | |
2659 g_signal_connect(G_OBJECT(gtkim->block), "clicked", | |
2660 G_CALLBACK(block_cb), conv); | |
2661 } | |
2662 | |
2663 static void | |
2664 setup_chat_buttons(struct gaim_conversation *conv, GtkWidget *parent) | |
2665 { | |
2666 struct gaim_connection *gc; | |
2667 struct gaim_gtk_conversation *gtkconv; | |
2668 struct gaim_gtk_chat_pane *gtkchat; | |
2669 struct gaim_gtk_window *gtkwin; | |
2670 GtkWidget *sep; | |
2671 | |
2672 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
2673 gtkchat = gtkconv->u.chat; | |
2674 gtkwin = GAIM_GTK_WINDOW(gaim_conversation_get_window(conv)); | |
2675 gc = gaim_conversation_get_gc(conv); | |
2676 | |
2677 /* Send button */ | |
2678 gtkconv->send = gaim_gtk_change_text(_("Send"), gtkconv->send, | |
2679 GAIM_STOCK_SEND, GAIM_CONV_CHAT); | |
2680 gtk_tooltips_set_tip(gtkconv->tooltips, gtkconv->send, _("Send"), NULL); | |
2681 | |
2682 gtk_box_pack_end(GTK_BOX(parent), gtkconv->send, FALSE, FALSE, 0); | |
2683 | |
2684 /* Separator */ | |
2685 sep = gtk_vseparator_new(); | |
2686 gtk_box_pack_end(GTK_BOX(parent), sep, FALSE, TRUE, 0); | |
2687 gtk_widget_show(sep); | |
2688 | |
2689 /* Invite */ | |
2690 gtkchat->invite = gaim_gtk_change_text(_("Invite"), gtkchat->invite, | |
2691 GAIM_STOCK_INVITE, GAIM_CONV_CHAT); | |
2692 gtk_tooltips_set_tip(gtkconv->tooltips, gtkchat->invite, | |
2693 _("Invite a user"), NULL); | |
2694 gtk_box_pack_end(GTK_BOX(parent), gtkchat->invite, FALSE, FALSE, 0); | |
2695 | |
2696 /* Set the relief on these. */ | |
2697 gtk_button_set_relief(GTK_BUTTON(gtkchat->invite), GTK_RELIEF_NONE); | |
2698 gtk_button_set_relief(GTK_BUTTON(gtkconv->send), GTK_RELIEF_NONE); | |
2699 | |
2700 /* Callbacks */ | |
2701 g_signal_connect(G_OBJECT(gtkconv->send), "clicked", | |
2702 G_CALLBACK(send_cb), conv); | |
2703 g_signal_connect(G_OBJECT(gtkchat->invite), "clicked", | |
2704 G_CALLBACK(invite_cb), conv); | |
2705 } | |
2706 | |
2707 static GtkWidget * | |
2708 build_conv_toolbar(struct gaim_conversation *conv) | |
2709 { | |
2710 struct gaim_gtk_conversation *gtkconv; | |
2711 GtkWidget *vbox; | |
2712 GtkWidget *hbox; | |
2713 GtkWidget *button; | |
2714 GtkWidget *sep; | |
2715 GtkSizeGroup *sg; | |
2716 | |
2717 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
2718 | |
2719 sg = gtk_size_group_new(GTK_SIZE_GROUP_BOTH); | |
2720 | |
2721 vbox = gtk_vbox_new(FALSE, 0); | |
2722 sep = gtk_hseparator_new(); | |
2723 gtk_box_pack_start(GTK_BOX(vbox), sep, FALSE, FALSE, 0); | |
2724 | |
2725 hbox = gtk_hbox_new(FALSE, 5); | |
2726 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); | |
2727 | |
2728 /* Bold */ | |
2729 button = gaim_pixbuf_toolbar_button_from_stock(GTK_STOCK_BOLD); | |
2730 gtk_size_group_add_widget(sg, button); | |
2731 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0); | |
2732 gtk_tooltips_set_tip(gtkconv->tooltips, button, _("Bold"), NULL); | |
2733 | |
2734 g_signal_connect(G_OBJECT(button), "clicked", | |
2735 G_CALLBACK(do_bold), gtkconv); | |
2736 | |
2737 gtkconv->toolbar.bold = button; | |
2738 | |
2739 /* Italic */ | |
2740 button = gaim_pixbuf_toolbar_button_from_stock(GTK_STOCK_ITALIC); | |
2741 gtk_size_group_add_widget(sg, button); | |
2742 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0); | |
2743 gtk_tooltips_set_tip(gtkconv->tooltips, button, _("Italic"), NULL); | |
2744 | |
2745 g_signal_connect(G_OBJECT(button), "clicked", | |
2746 G_CALLBACK(do_italic), gtkconv); | |
2747 | |
2748 gtkconv->toolbar.italic = button; | |
2749 | |
2750 /* Underline */ | |
2751 button = gaim_pixbuf_toolbar_button_from_stock(GTK_STOCK_UNDERLINE); | |
2752 gtk_size_group_add_widget(sg, button); | |
2753 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0); | |
2754 gtk_tooltips_set_tip(gtkconv->tooltips, button, _("Underline"), NULL); | |
2755 | |
2756 g_signal_connect(G_OBJECT(button), "clicked", | |
2757 G_CALLBACK(do_underline), gtkconv); | |
2758 | |
2759 gtkconv->toolbar.underline = button; | |
2760 | |
2761 /* Sep */ | |
2762 sep = gtk_vseparator_new(); | |
2763 gtk_box_pack_start(GTK_BOX(hbox), sep, FALSE, FALSE, 0); | |
2764 | |
2765 /* Increase font size */ | |
2766 button = gaim_pixbuf_toolbar_button_from_stock(GAIM_STOCK_TEXT_BIGGER); | |
2767 gtk_size_group_add_widget(sg, button); | |
2768 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0); | |
2769 gtk_tooltips_set_tip(gtkconv->tooltips, button, | |
2770 _("Larger font size"), NULL); | |
2771 | |
2772 g_signal_connect(G_OBJECT(button), "clicked", | |
2773 G_CALLBACK(do_big), gtkconv); | |
2774 | |
2775 /* Normal font size */ | |
2776 button = gaim_pixbuf_toolbar_button_from_stock(GAIM_STOCK_TEXT_NORMAL); | |
2777 gtk_size_group_add_widget(sg, button); | |
2778 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0); | |
2779 gtk_tooltips_set_tip(gtkconv->tooltips, button, | |
2780 _("Normal font size"), NULL); | |
2781 | |
2782 g_signal_connect(G_OBJECT(button), "clicked", | |
2783 G_CALLBACK(do_normal), gtkconv); | |
2784 | |
2785 gtkconv->toolbar.normal_size = button; | |
2786 | |
2787 /* Decrease font size */ | |
2788 button = gaim_pixbuf_toolbar_button_from_stock(GAIM_STOCK_TEXT_SMALLER); | |
2789 gtk_size_group_add_widget(sg, button); | |
2790 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0); | |
2791 gtk_tooltips_set_tip(gtkconv->tooltips, button, | |
2792 _("Smaller font size"), NULL); | |
2793 | |
2794 g_signal_connect(G_OBJECT(button), "clicked", | |
2795 G_CALLBACK(do_small), gtkconv); | |
2796 | |
2797 /* Sep */ | |
2798 sep = gtk_vseparator_new(); | |
2799 gtk_box_pack_start(GTK_BOX(hbox), sep, FALSE, FALSE, 0); | |
2800 | |
4685 | 2801 /* Font Face */ |
2802 | |
2803 button = gaim_pixbuf_toolbar_button_from_stock(GTK_STOCK_SELECT_FONT); | |
2804 gtk_size_group_add_widget(sg, button); | |
2805 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0); | |
2806 gtk_tooltips_set_tip(gtkconv->tooltips, button, | |
2807 _("Font Face"), NULL); | |
2808 | |
2809 g_signal_connect(G_OBJECT(button), "clicked", | |
2810 G_CALLBACK(toggle_font), conv); | |
2811 | |
2812 gtkconv->toolbar.font = button; | |
2813 | |
4359 | 2814 /* Foreground Color */ |
2815 button = gaim_pixbuf_toolbar_button_from_stock(GAIM_STOCK_FGCOLOR); | |
2816 gtk_size_group_add_widget(sg, button); | |
2817 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0); | |
2818 gtk_tooltips_set_tip(gtkconv->tooltips, button, | |
2819 _("Foreground font color"), NULL); | |
2820 | |
2821 g_signal_connect(G_OBJECT(button), "clicked", | |
2822 G_CALLBACK(toggle_fg_color), conv); | |
2823 | |
2824 gtkconv->toolbar.fgcolor = button; | |
2825 | |
2826 /* Background Color */ | |
2827 button = gaim_pixbuf_toolbar_button_from_stock(GAIM_STOCK_BGCOLOR); | |
2828 gtk_size_group_add_widget(sg, button); | |
2829 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0); | |
2830 gtk_tooltips_set_tip(gtkconv->tooltips, button, | |
2831 _("Background color"), NULL); | |
2832 | |
2833 g_signal_connect(G_OBJECT(button), "clicked", | |
2834 G_CALLBACK(toggle_bg_color), conv); | |
2835 | |
2836 gtkconv->toolbar.bgcolor = button; | |
2837 | |
2838 /* Sep */ | |
2839 sep = gtk_vseparator_new(); | |
2840 gtk_box_pack_start(GTK_BOX(hbox), sep, FALSE, FALSE, 0); | |
2841 | |
2842 /* Insert IM Image */ | |
2843 button = gaim_pixbuf_toolbar_button_from_stock(GAIM_STOCK_IMAGE); | |
2844 gtk_size_group_add_widget(sg, button); | |
2845 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0); | |
2846 gtk_tooltips_set_tip(gtkconv->tooltips, button, _("Insert image"), NULL); | |
2847 | |
2848 g_signal_connect(G_OBJECT(button), "clicked", | |
2849 G_CALLBACK(insert_image_cb), conv); | |
2850 | |
2851 gtkconv->toolbar.image = button; | |
2852 | |
2853 /* Insert Link */ | |
2854 button = gaim_pixbuf_toolbar_button_from_stock(GAIM_STOCK_LINK); | |
2855 gtk_size_group_add_widget(sg, button); | |
2856 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0); | |
2857 gtk_tooltips_set_tip(gtkconv->tooltips, button, _("Insert link"), NULL); | |
2858 | |
2859 g_signal_connect(G_OBJECT(button), "clicked", | |
2860 G_CALLBACK(insert_link_cb), conv); | |
2861 | |
2862 gtkconv->toolbar.link = button; | |
2863 | |
2864 /* Insert Smiley */ | |
2865 button = gaim_pixbuf_toolbar_button_from_stock(GAIM_STOCK_SMILEY); | |
2866 gtk_size_group_add_widget(sg, button); | |
2867 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0); | |
2868 gtk_tooltips_set_tip(gtkconv->tooltips, button, _("Insert smiley"), NULL); | |
2869 | |
2870 g_signal_connect(G_OBJECT(button), "clicked", | |
2871 G_CALLBACK(insert_smiley_cb), conv); | |
2872 | |
2873 gtkconv->toolbar.smiley = button; | |
2874 | |
2875 | |
2876 sep = gtk_hseparator_new(); | |
2877 gtk_box_pack_start(GTK_BOX(vbox), sep, FALSE, FALSE, 0); | |
2878 | |
2879 gtk_widget_show_all(vbox); | |
2880 | |
2881 return vbox; | |
2882 } | |
2883 | |
2884 static GtkWidget * | |
2885 setup_chat_pane(struct gaim_conversation *conv) | |
2886 { | |
2887 struct gaim_gtk_conversation *gtkconv; | |
2888 struct gaim_gtk_chat_pane *gtkchat; | |
2889 struct gaim_connection *gc; | |
2890 GtkWidget *vpaned, *hpaned; | |
2891 GtkWidget *vbox, *hbox; | |
2892 GtkWidget *lbox, *bbox; | |
2893 GtkWidget *label; | |
2894 GtkWidget *sw2; | |
2895 GtkWidget *list; | |
2896 GtkWidget *button; | |
2897 GtkWidget *frame; | |
2898 GtkListStore *ls; | |
2899 GtkCellRenderer *rend; | |
2900 GtkTreeViewColumn *col; | |
2901 | |
2902 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
2903 gtkchat = gtkconv->u.chat; | |
2904 gc = gaim_conversation_get_gc(conv); | |
2905 | |
2906 /* Setup the outer pane. */ | |
2907 vpaned = gtk_vpaned_new(); | |
2908 gtk_widget_show(vpaned); | |
2909 | |
2910 /* Setup the top part of the pane. */ | |
2911 vbox = gtk_vbox_new(FALSE, 5); | |
2912 gtk_paned_pack1(GTK_PANED(vpaned), vbox, TRUE, FALSE); | |
2913 gtk_widget_show(vbox); | |
2914 | |
2915 if (gc->prpl->options & OPT_PROTO_CHAT_TOPIC) | |
2916 { | |
2917 hbox = gtk_hbox_new(FALSE, 0); | |
2918 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 5); | |
2919 gtk_widget_show(hbox); | |
2920 | |
2921 label = gtk_label_new(_("Topic:")); | |
2922 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 5); | |
2923 gtk_widget_show(label); | |
2924 | |
2925 gtkchat->topic_text = gtk_entry_new(); | |
4635 | 2926 gtk_editable_set_editable(GTK_EDITABLE(gtkchat->topic_text), FALSE); |
4359 | 2927 gtk_box_pack_start(GTK_BOX(hbox), gtkchat->topic_text, TRUE, TRUE, 5); |
2928 gtk_widget_show(gtkchat->topic_text); | |
2929 } | |
2930 | |
2931 /* Setup the horizontal pane. */ | |
2932 hpaned = gtk_hpaned_new(); | |
2933 gtk_box_pack_start(GTK_BOX(vbox), hpaned, TRUE, TRUE, 5); | |
2934 gtk_widget_show(hpaned); | |
2935 | |
2936 /* Setup the scrolled window to put gtkimhtml in. */ | |
2937 gtkconv->sw = gtk_scrolled_window_new(NULL, NULL); | |
2938 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(gtkconv->sw), | |
2939 GTK_POLICY_NEVER, GTK_POLICY_ALWAYS); | |
2940 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(gtkconv->sw), | |
2941 GTK_SHADOW_IN); | |
2942 gtk_paned_pack1(GTK_PANED(hpaned), gtkconv->sw, TRUE, TRUE); | |
2943 | |
2944 gtk_widget_set_size_request(gtkconv->sw, | |
2945 buddy_chat_size.width, buddy_chat_size.height); | |
2946 gtk_widget_show(gtkconv->sw); | |
2947 | |
2948 /* Setup gtkihmtml. */ | |
2949 gtkconv->imhtml = gtk_imhtml_new(NULL, NULL); | |
2950 gtk_container_add(GTK_CONTAINER(gtkconv->sw), gtkconv->imhtml); | |
2951 | |
2952 gtk_imhtml_show_comments(GTK_IMHTML(gtkconv->imhtml), | |
2953 (convo_options & OPT_CONVO_SHOW_TIME)); | |
2954 | |
2955 g_signal_connect_after(G_OBJECT(gtkconv->imhtml), "button_press_event", | |
2956 G_CALLBACK(entry_stop_rclick_cb), NULL); | |
2957 | |
2958 gaim_setup_imhtml(gtkconv->imhtml); | |
2959 | |
2960 gtk_widget_show(gtkconv->imhtml); | |
2961 | |
2962 /* Build the right pane. */ | |
2963 lbox = gtk_vbox_new(FALSE, 5); | |
4409
0521eec12c33
[gaim-migrate @ 4682]
Christian Hammond <chipx86@chipx86.com>
parents:
4398
diff
changeset
|
2964 gtk_paned_pack2(GTK_PANED(hpaned), lbox, FALSE, TRUE); |
4359 | 2965 gtk_widget_show(lbox); |
2966 | |
2967 /* Setup the label telling how many people are in the room. */ | |
2968 gtkchat->count = gtk_label_new(_("0 people in room")); | |
2969 gtk_box_pack_start(GTK_BOX(lbox), gtkchat->count, FALSE, FALSE, 0); | |
2970 gtk_widget_show(gtkchat->count); | |
2971 | |
2972 /* Setup the list of users. */ | |
2973 sw2 = gtk_scrolled_window_new(NULL, NULL); | |
2974 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw2), | |
2975 GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC); | |
2976 gtk_box_pack_start(GTK_BOX(lbox), sw2, TRUE, TRUE, 0); | |
2977 gtk_widget_show(sw2); | |
2978 | |
2979 ls = gtk_list_store_new(2, G_TYPE_STRING, G_TYPE_STRING); | |
2980 gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(ls), 1, | |
2981 GTK_SORT_ASCENDING); | |
2982 | |
2983 list = gtk_tree_view_new_with_model(GTK_TREE_MODEL(ls)); | |
2984 | |
2985 rend = gtk_cell_renderer_text_new(); | |
2986 col = gtk_tree_view_column_new_with_attributes(NULL, rend, | |
2987 "text", 0, NULL); | |
2988 gtk_tree_view_column_set_clickable(GTK_TREE_VIEW_COLUMN(col), TRUE); | |
2989 | |
2990 g_signal_connect(G_OBJECT(list), "button_press_event", | |
2991 G_CALLBACK(right_click_chat_cb), conv); | |
2992 | |
2993 gtk_tree_view_append_column(GTK_TREE_VIEW(list), col); | |
2994 | |
2995 col = gtk_tree_view_column_new_with_attributes(NULL, rend, | |
2996 "text", 1, NULL); | |
2997 gtk_tree_view_column_set_clickable(GTK_TREE_VIEW_COLUMN(col), TRUE); | |
2998 | |
2999 #if 0 | |
3000 g_signal_connect(G_OBJECT(list), "button_press_event", | |
3001 G_CALLBACK(right_click_chat), conv); | |
3002 #endif | |
3003 | |
3004 gtk_tree_view_append_column(GTK_TREE_VIEW(list), col); | |
3005 | |
3006 gtk_widget_set_size_request(list, 150, -1); | |
3007 | |
3008 gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(list), FALSE); | |
3009 gtk_widget_show(list); | |
3010 | |
3011 gtkchat->list = list; | |
3012 | |
3013 gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(sw2), list); | |
3014 | |
3015 /* Setup the user list toolbar. */ | |
3016 bbox = gtk_hbox_new(TRUE, 5); | |
3017 gtk_box_pack_start(GTK_BOX(lbox), bbox, FALSE, FALSE, 0); | |
3018 gtk_widget_show(bbox); | |
3019 | |
3020 /* IM */ | |
3021 button = gaim_pixbuf_button_from_stock(NULL, GTK_STOCK_REDO, | |
3022 GAIM_BUTTON_VERTICAL); | |
3023 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE); | |
3024 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
|
3025 gtk_tooltips_set_tip(gtkconv->tooltips, button, _("IM the user"), NULL); |
4359 | 3026 g_signal_connect(G_OBJECT(button), "clicked", |
3027 G_CALLBACK(im_cb), conv); | |
3028 | |
3029 gtk_widget_show(button); | |
3030 | |
3031 /* Ignore */ | |
3032 button = gaim_pixbuf_button_from_stock(NULL, GAIM_STOCK_IGNORE, | |
3033 GAIM_BUTTON_VERTICAL); | |
3034 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE); | |
3035 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
|
3036 gtk_tooltips_set_tip(gtkconv->tooltips, button, |
d856987c72ca
[gaim-migrate @ 4636]
Christian Hammond <chipx86@chipx86.com>
parents:
4369
diff
changeset
|
3037 _("Ignore the user"), NULL); |
4359 | 3038 g_signal_connect(G_OBJECT(button), "clicked", |
3039 G_CALLBACK(ignore_cb), conv); | |
3040 gtk_widget_show(button); | |
3041 | |
3042 /* Info */ | |
3043 button = gaim_pixbuf_button_from_stock(NULL, GAIM_STOCK_INFO, | |
3044 GAIM_BUTTON_VERTICAL); | |
3045 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE); | |
3046 gtk_box_pack_start(GTK_BOX(bbox), button, FALSE, FALSE, 0); | |
3047 gtk_tooltips_set_tip(gtkconv->tooltips, button, | |
4370
d856987c72ca
[gaim-migrate @ 4636]
Christian Hammond <chipx86@chipx86.com>
parents:
4369
diff
changeset
|
3048 _("Get the user's information"), NULL); |
4359 | 3049 g_signal_connect(G_OBJECT(button), "clicked", |
3050 G_CALLBACK(info_cb), conv); | |
3051 | |
3052 gtk_widget_show(button); | |
3053 | |
3054 gtkconv->info = button; | |
3055 | |
3056 /* Build the toolbar. */ | |
3057 vbox = gtk_vbox_new(FALSE, 5); | |
4409
0521eec12c33
[gaim-migrate @ 4682]
Christian Hammond <chipx86@chipx86.com>
parents:
4398
diff
changeset
|
3058 gtk_paned_pack2(GTK_PANED(vpaned), vbox, FALSE, FALSE); |
4359 | 3059 gtk_widget_show(vbox); |
3060 | |
3061 gtkconv->toolbar.toolbar = build_conv_toolbar(conv); | |
3062 gtk_box_pack_start(GTK_BOX(vbox), gtkconv->toolbar.toolbar, | |
3063 FALSE, FALSE, 0); | |
3064 | |
3065 /* Setup the entry widget. */ | |
3066 frame = gtk_frame_new(NULL); | |
3067 gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_IN); | |
3068 gtk_box_pack_start(GTK_BOX(vbox), frame, TRUE, TRUE, 0); | |
3069 gtk_widget_show(frame); | |
3070 | |
3071 gtkconv->entry_buffer = gtk_text_buffer_new(NULL); | |
3072 g_object_set_data(G_OBJECT(gtkconv->entry_buffer), "user_data", conv); | |
3073 gtkconv->entry = gtk_text_view_new_with_buffer(gtkconv->entry_buffer); | |
3074 | |
3075 gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(gtkconv->entry), GTK_WRAP_WORD); | |
3076 gtk_widget_set_size_request(gtkconv->entry, buddy_chat_size.width, | |
3077 MAX(buddy_chat_size.entry_height, 25)); | |
3078 | |
3079 /* Connect the signal handlers. */ | |
3080 g_signal_connect_swapped(G_OBJECT(gtkconv->entry), "key_press_event", | |
3081 G_CALLBACK(entry_key_pressed_cb_1), | |
3082 gtkconv->entry_buffer); | |
3083 g_signal_connect_after(G_OBJECT(gtkconv->entry), "button_press_event", | |
3084 G_CALLBACK(entry_stop_rclick_cb), NULL); | |
3085 g_signal_connect(G_OBJECT(gtkconv->entry), "key_press_event", | |
3086 G_CALLBACK(entry_key_pressed_cb_2), conv); | |
3087 | |
3088 #ifdef USE_GTKSPELL | |
3089 if (convo_options & OPT_CONVO_CHECK_SPELLING) | |
3090 gtkspell_new_attach(GTK_TEXT_VIEW(gtkconv->entry), NULL, NULL); | |
3091 #endif | |
3092 | |
3093 gtk_container_add(GTK_CONTAINER(frame), GTK_WIDGET(gtkconv->entry)); | |
3094 gtk_widget_show(gtkconv->entry); | |
3095 | |
3096 /* Setup the bottom button box. */ | |
3097 gtkconv->bbox = gtk_hbox_new(FALSE, 5); | |
3098 gtk_box_pack_start(GTK_BOX(vbox), gtkconv->bbox, FALSE, FALSE, 0); | |
3099 gtk_widget_show(gtkconv->bbox); | |
3100 | |
3101 setup_chat_buttons(conv, gtkconv->bbox); | |
3102 | |
3103 return vpaned; | |
3104 } | |
3105 | |
3106 static GtkWidget * | |
3107 setup_im_pane(struct gaim_conversation *conv) | |
3108 { | |
3109 struct gaim_gtk_conversation *gtkconv; | |
3110 struct gaim_gtk_im_pane *gtkim; | |
3111 GtkWidget *paned; | |
3112 GtkWidget *vbox; | |
3113 GtkWidget *vbox2; | |
3114 GtkWidget *frame; | |
3115 | |
3116 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
3117 gtkim = gtkconv->u.im; | |
3118 | |
3119 /* Setup the outer pane. */ | |
3120 paned = gtk_vpaned_new(); | |
3121 gtk_widget_show(paned); | |
3122 | |
3123 /* Setup the top part of the pane. */ | |
3124 vbox = gtk_vbox_new(FALSE, 5); | |
4409
0521eec12c33
[gaim-migrate @ 4682]
Christian Hammond <chipx86@chipx86.com>
parents:
4398
diff
changeset
|
3125 gtk_paned_pack1(GTK_PANED(paned), vbox, TRUE, TRUE); |
4359 | 3126 gtk_widget_show(vbox); |
3127 | |
3128 /* Setup the gtkimhtml widget. */ | |
3129 gtkconv->sw = gtk_scrolled_window_new(NULL, NULL); | |
3130 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(gtkconv->sw), | |
3131 GTK_POLICY_NEVER, GTK_POLICY_ALWAYS); | |
3132 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(gtkconv->sw), | |
3133 GTK_SHADOW_IN); | |
3134 gtk_box_pack_start(GTK_BOX(vbox), gtkconv->sw, TRUE, TRUE, 0); | |
3135 gtk_widget_set_size_request(gtkconv->sw, conv_size.width, conv_size.height); | |
3136 gtk_widget_show(gtkconv->sw); | |
3137 | |
3138 gtkconv->imhtml = gtk_imhtml_new(NULL, NULL); | |
3139 gtk_container_add(GTK_CONTAINER(gtkconv->sw), gtkconv->imhtml); | |
3140 | |
3141 g_signal_connect_after(G_OBJECT(gtkconv->imhtml), "button_press_event", | |
3142 G_CALLBACK(entry_stop_rclick_cb), NULL); | |
3143 | |
3144 gtk_imhtml_show_comments(GTK_IMHTML(gtkconv->imhtml), | |
3145 (convo_options & OPT_CONVO_SHOW_TIME)); | |
3146 | |
3147 gaim_setup_imhtml(gtkconv->imhtml); | |
3148 | |
3149 gtk_widget_show(gtkconv->imhtml); | |
3150 | |
3151 vbox2 = gtk_vbox_new(FALSE, 5); | |
3152 gtk_paned_pack2(GTK_PANED(paned), vbox2, FALSE, FALSE); | |
3153 gtk_widget_show(vbox2); | |
3154 | |
3155 /* Build the toolbar. */ | |
3156 gtkconv->toolbar.toolbar = build_conv_toolbar(conv); | |
3157 gtk_box_pack_start(GTK_BOX(vbox2), gtkconv->toolbar.toolbar, | |
3158 FALSE, FALSE, 0); | |
3159 | |
3160 /* Setup the entry widget. */ | |
3161 frame = gtk_frame_new(NULL); | |
3162 gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_IN); | |
3163 gtk_box_pack_start(GTK_BOX(vbox2), frame, TRUE, TRUE, 0); | |
3164 gtk_widget_show(frame); | |
3165 | |
3166 gtkconv->entry_buffer = gtk_text_buffer_new(NULL); | |
3167 g_object_set_data(G_OBJECT(gtkconv->entry_buffer), "user_data", conv); | |
3168 gtkconv->entry = gtk_text_view_new_with_buffer(gtkconv->entry_buffer); | |
3169 | |
3170 gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(gtkconv->entry), GTK_WRAP_WORD); | |
3171 gtk_widget_set_size_request(gtkconv->entry, conv_size.width - 20, | |
3172 MAX(conv_size.entry_height, 25)); | |
3173 | |
3174 /* Connect the signal handlers. */ | |
3175 g_signal_connect_swapped(G_OBJECT(gtkconv->entry), "key_press_event", | |
3176 G_CALLBACK(entry_key_pressed_cb_1), | |
3177 gtkconv->entry_buffer); | |
3178 g_signal_connect(G_OBJECT(gtkconv->entry), "key_press_event", | |
3179 G_CALLBACK(entry_key_pressed_cb_2), conv); | |
3180 g_signal_connect_after(G_OBJECT(gtkconv->entry), "button_press_event", | |
3181 G_CALLBACK(entry_stop_rclick_cb), NULL); | |
3182 | |
3183 g_signal_connect(G_OBJECT(gtkconv->entry_buffer), "insert_text", | |
3184 G_CALLBACK(insert_text_cb), conv); | |
3185 g_signal_connect(G_OBJECT(gtkconv->entry_buffer), "delete_range", | |
3186 G_CALLBACK(delete_text_cb), conv); | |
3187 | |
3188 #ifdef USE_GTKSPELL | |
3189 if (convo_options & OPT_CONVO_CHECK_SPELLING) | |
3190 gtkspell_new_attach(GTK_TEXT_VIEW(gtkconv->entry), NULL, NULL); | |
3191 #endif | |
3192 | |
3193 gtk_container_add(GTK_CONTAINER(frame), GTK_WIDGET(gtkconv->entry)); | |
3194 gtk_widget_show(gtkconv->entry); | |
3195 | |
3196 gtkconv->bbox = gtk_hbox_new(FALSE, 5); | |
3197 gtk_box_pack_start(GTK_BOX(vbox2), gtkconv->bbox, FALSE, FALSE, 0); | |
3198 gtk_widget_show(gtkconv->bbox); | |
3199 | |
3200 setup_im_buttons(conv, gtkconv->bbox); | |
3201 | |
3202 return paned; | |
3203 } | |
3204 | |
3205 static void | |
3206 move_next_tab(struct gaim_conversation *conv) | |
3207 { | |
3208 struct gaim_conversation *next_conv = NULL; | |
3209 struct gaim_window *win; | |
3210 GList *l; | |
3211 int index, i; | |
3212 | |
3213 win = gaim_conversation_get_window(conv); | |
3214 index = gaim_conversation_get_index(conv); | |
3215 | |
3216 /* First check the tabs after this position. */ | |
3217 for (l = g_list_nth(gaim_window_get_conversations(win), index); | |
3218 l != NULL; | |
3219 l = l->next) { | |
3220 | |
3221 next_conv = (struct gaim_conversation *)l->data; | |
3222 | |
3223 if (gaim_conversation_get_unseen(next_conv) > 0) | |
3224 break; | |
3225 | |
3226 next_conv = NULL; | |
3227 } | |
3228 | |
3229 if (next_conv == NULL) { | |
3230 | |
3231 /* Now check before this position. */ | |
3232 for (l = gaim_window_get_conversations(win), i = 0; | |
3233 l != NULL && i < index; | |
3234 l = l->next) { | |
3235 | |
3236 next_conv = (struct gaim_conversation *)l->data; | |
3237 | |
3238 if (gaim_conversation_get_unseen(next_conv) > 0) | |
3239 break; | |
3240 | |
3241 next_conv = NULL; | |
3242 } | |
3243 | |
3244 if (next_conv == NULL) { | |
3245 /* Okay, just grab the next conversation tab. */ | |
3246 if (index == gaim_window_get_conversation_count(win) - 1) | |
3247 next_conv = gaim_window_get_conversation_at(win, 0); | |
3248 else | |
3249 next_conv = gaim_window_get_conversation_at(win, index + 1); | |
3250 } | |
3251 } | |
3252 | |
3253 if (next_conv != NULL && next_conv != conv) { | |
3254 gaim_window_switch_conversation(win, | |
3255 gaim_conversation_get_index(next_conv)); | |
3256 } | |
3257 } | |
3258 | |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3259 static void |
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3260 conv_dnd_recv(GtkWidget *widget, GdkDragContext *dc, guint x, guint y, |
4781 | 3261 GtkSelectionData *sd, guint info, guint t, struct gaim_conversation *conv) |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3262 { |
4781 | 3263 struct gaim_window *win = conv->window; |
3264 struct gaim_conversation *c; | |
3265 if (sd->target == gdk_atom_intern("GAIM_BLIST_NODE", FALSE)) { | |
3266 GaimBlistNode *n = NULL; | |
3267 memcpy(&n, sd->data, sizeof(n)); | |
3268 if (!GAIM_BLIST_NODE_IS_BUDDY(n)) | |
3269 return; | |
3270 c = gaim_conversation_new(GAIM_CONV_IM, ((struct buddy*)n)->account, ((struct buddy*)n)->name); | |
3271 gaim_window_add_conversation (win, c); | |
4702 | 3272 } |
3273 | |
3274 /* do_error_dialog("MWAHAHAHA! I AM A TROLL! I AM GOING TO EAT YOU!", | |
3275 NULL, GAIM_WARNING); */ | |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3276 } |
4359 | 3277 |
3278 /************************************************************************** | |
3279 * GTK+ window ops | |
3280 **************************************************************************/ | |
4465
6e37eb000b7a
[gaim-migrate @ 4740]
Christian Hammond <chipx86@chipx86.com>
parents:
4454
diff
changeset
|
3281 static struct gaim_conversation_ui_ops * |
6e37eb000b7a
[gaim-migrate @ 4740]
Christian Hammond <chipx86@chipx86.com>
parents:
4454
diff
changeset
|
3282 gaim_gtk_get_conversation_ui_ops(void) |
4359 | 3283 { |
4465
6e37eb000b7a
[gaim-migrate @ 4740]
Christian Hammond <chipx86@chipx86.com>
parents:
4454
diff
changeset
|
3284 return gaim_get_gtk_conversation_ui_ops(); |
4359 | 3285 } |
3286 | |
3287 static void | |
3288 gaim_gtk_new_window(struct gaim_window *win) | |
3289 { | |
3290 struct gaim_gtk_window *gtkwin; | |
3291 GtkPositionType pos; | |
3292 GtkWidget *testidea; | |
3293 GtkWidget *menubar; | |
3294 | |
3295 gtkwin = g_malloc0(sizeof(struct gaim_gtk_window)); | |
3296 | |
3297 win->ui_data = gtkwin; | |
3298 | |
3299 /* Create the window. */ | |
3300 gtkwin->window = gtk_window_new(GTK_WINDOW_TOPLEVEL); | |
3301 gtk_window_set_role(GTK_WINDOW(gtkwin->window), "conversation"); | |
4635 | 3302 gtk_window_set_resizable(GTK_WINDOW(gtkwin->window), TRUE); |
4510
4c394222c732
[gaim-migrate @ 4786]
Christian Hammond <chipx86@chipx86.com>
parents:
4505
diff
changeset
|
3303 gtk_container_set_border_width(GTK_CONTAINER(gtkwin->window), 0); |
4359 | 3304 gtk_widget_realize(gtkwin->window); |
3305 | |
3306 g_signal_connect(G_OBJECT(gtkwin->window), "delete_event", | |
3307 G_CALLBACK(close_win_cb), win); | |
3308 | |
3309 /* Create the notebook. */ | |
3310 gtkwin->notebook = gtk_notebook_new(); | |
3311 | |
3312 pos = ((im_options & OPT_IM_SIDE_TAB) | |
3313 ? ((im_options & OPT_IM_BR_TAB) ? GTK_POS_RIGHT : GTK_POS_LEFT) | |
3314 : ((im_options & OPT_IM_BR_TAB) ? GTK_POS_BOTTOM : GTK_POS_TOP)); | |
3315 | |
3316 #if 0 | |
3317 gtk_notebook_set_tab_hborder(GTK_NOTEBOOK(gtkwin->notebook), 0); | |
3318 gtk_notebook_set_tab_vborder(GTK_NOTEBOOK(gtkwin->notebook), 0); | |
3319 #endif | |
3320 gtk_notebook_set_tab_pos(GTK_NOTEBOOK(gtkwin->notebook), pos); | |
3321 gtk_notebook_set_scrollable(GTK_NOTEBOOK(gtkwin->notebook), TRUE); | |
3322 gtk_notebook_popup_enable(GTK_NOTEBOOK(gtkwin->notebook)); | |
3323 gtk_widget_show(gtkwin->notebook); | |
3324 | |
3325 g_signal_connect_after(G_OBJECT(gtkwin->notebook), "switch_page", | |
3326 G_CALLBACK(switch_conv_cb), win); | |
3327 | |
3328 /* Setup the tab drag and drop signals. */ | |
4486 | 3329 gtk_widget_add_events(gtkwin->notebook, |
3330 GDK_BUTTON1_MOTION_MASK | GDK_LEAVE_NOTIFY_MASK); | |
3331 g_signal_connect(G_OBJECT(gtkwin->notebook), "button_press_event", | |
4572
06084165a966
[gaim-migrate @ 4853]
Christian Hammond <chipx86@chipx86.com>
parents:
4571
diff
changeset
|
3332 G_CALLBACK(notebook_press_cb), win); |
4486 | 3333 g_signal_connect(G_OBJECT(gtkwin->notebook), "button_release_event", |
4572
06084165a966
[gaim-migrate @ 4853]
Christian Hammond <chipx86@chipx86.com>
parents:
4571
diff
changeset
|
3334 G_CALLBACK(notebook_release_cb), win); |
06084165a966
[gaim-migrate @ 4853]
Christian Hammond <chipx86@chipx86.com>
parents:
4571
diff
changeset
|
3335 |
4359 | 3336 testidea = gtk_vbox_new(FALSE, 0); |
4572
06084165a966
[gaim-migrate @ 4853]
Christian Hammond <chipx86@chipx86.com>
parents:
4571
diff
changeset
|
3337 |
4359 | 3338 /* Setup the menubar. */ |
3339 menubar = setup_menubar(win); | |
3340 gtk_box_pack_start(GTK_BOX(testidea), menubar, FALSE, TRUE, 0); | |
3341 | |
3342 gtk_box_pack_start(GTK_BOX(testidea), gtkwin->notebook, TRUE, TRUE, 0); | |
3343 | |
3344 gtk_container_add(GTK_CONTAINER(gtkwin->window), testidea); | |
3345 | |
3346 gtk_widget_show(testidea); | |
3347 } | |
3348 | |
3349 static void | |
3350 gaim_gtk_destroy_window(struct gaim_window *win) | |
3351 { | |
3352 struct gaim_gtk_window *gtkwin = GAIM_GTK_WINDOW(win); | |
3353 | |
3354 gtk_widget_destroy(gtkwin->window); | |
3355 | |
4630 | 3356 g_object_unref(G_OBJECT(gtkwin->menu.item_factory)); |
3357 | |
4359 | 3358 g_free(gtkwin); |
3359 win->ui_data = NULL; | |
3360 } | |
3361 | |
3362 static void | |
3363 gaim_gtk_show(struct gaim_window *win) | |
3364 { | |
3365 struct gaim_gtk_window *gtkwin = GAIM_GTK_WINDOW(win); | |
3366 | |
3367 gtk_widget_show(gtkwin->window); | |
3368 } | |
3369 | |
3370 static void | |
3371 gaim_gtk_hide(struct gaim_window *win) | |
3372 { | |
3373 struct gaim_gtk_window *gtkwin = GAIM_GTK_WINDOW(win); | |
3374 | |
3375 gtk_widget_hide(gtkwin->window); | |
3376 } | |
3377 | |
3378 static void | |
3379 gaim_gtk_raise(struct gaim_window *win) | |
3380 { | |
3381 struct gaim_gtk_window *gtkwin = GAIM_GTK_WINDOW(win); | |
3382 | |
4526 | 3383 gdk_window_raise(gtkwin->window->window); |
4359 | 3384 } |
3385 | |
3386 static void | |
3387 gaim_gtk_flash(struct gaim_window *win) | |
3388 { | |
3389 #ifdef _WIN32 | |
3390 struct gaim_gtk_window *gtkwin = GAIM_GTK_WINDOW(win); | |
3391 | |
3392 wgaim_im_blink(gtkwin->window); | |
3393 #endif | |
3394 } | |
3395 | |
3396 static void | |
3397 gaim_gtk_switch_conversation(struct gaim_window *win, unsigned int index) | |
3398 { | |
3399 struct gaim_gtk_window *gtkwin; | |
3400 | |
3401 gtkwin = GAIM_GTK_WINDOW(win); | |
3402 | |
3403 gtk_notebook_set_current_page(GTK_NOTEBOOK(gtkwin->notebook), index); | |
3404 } | |
3405 | |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3406 static const GtkTargetEntry te[] = |
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3407 { |
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3408 {"text/plain", 0, 0}, |
4702 | 3409 {"text/uri-list", 0, 1}, |
4781 | 3410 {"GAIM_BLIST_NODE", 0, 2}, |
4702 | 3411 {"STRING", 0, 3} |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3412 }; |
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3413 |
4359 | 3414 static void |
3415 gaim_gtk_add_conversation(struct gaim_window *win, | |
3416 struct gaim_conversation *conv) | |
3417 { | |
3418 struct gaim_gtk_window *gtkwin; | |
3419 struct gaim_gtk_conversation *gtkconv; | |
3420 GtkWidget *pane = NULL; | |
3421 GtkWidget *tab_cont; | |
3422 GtkWidget *tabby; | |
3423 gboolean new_ui; | |
4383
f7a84034f97f
[gaim-migrate @ 4649]
Christian Hammond <chipx86@chipx86.com>
parents:
4382
diff
changeset
|
3424 GaimConversationType conv_type; |
f7a84034f97f
[gaim-migrate @ 4649]
Christian Hammond <chipx86@chipx86.com>
parents:
4382
diff
changeset
|
3425 const char *name; |
f7a84034f97f
[gaim-migrate @ 4649]
Christian Hammond <chipx86@chipx86.com>
parents:
4382
diff
changeset
|
3426 |
f7a84034f97f
[gaim-migrate @ 4649]
Christian Hammond <chipx86@chipx86.com>
parents:
4382
diff
changeset
|
3427 name = gaim_conversation_get_name(conv); |
f7a84034f97f
[gaim-migrate @ 4649]
Christian Hammond <chipx86@chipx86.com>
parents:
4382
diff
changeset
|
3428 conv_type = gaim_conversation_get_type(conv); |
f7a84034f97f
[gaim-migrate @ 4649]
Christian Hammond <chipx86@chipx86.com>
parents:
4382
diff
changeset
|
3429 gtkwin = GAIM_GTK_WINDOW(win); |
4359 | 3430 |
3431 if (conv->ui_data != NULL) { | |
3432 gtkconv = (struct gaim_gtk_conversation *)conv->ui_data; | |
3433 | |
3434 tab_cont = gtkconv->tab_cont; | |
3435 | |
3436 new_ui = FALSE; | |
3437 } | |
3438 else { | |
3439 gtkconv = g_malloc0(sizeof(struct gaim_gtk_conversation)); | |
3440 conv->ui_data = gtkconv; | |
3441 | |
3442 /* Setup some initial variables. */ | |
3443 gtkconv->sg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL); | |
3444 gtkconv->tooltips = gtk_tooltips_new(); | |
3445 | |
4421 | 3446 /* Setup the foreground and background colors */ |
3447 gaim_gtkconv_update_font_colors(conv); | |
3448 | |
4438
2054d8429925
[gaim-migrate @ 4713]
Christian Hammond <chipx86@chipx86.com>
parents:
4421
diff
changeset
|
3449 /* Setup the font face */ |
2054d8429925
[gaim-migrate @ 4713]
Christian Hammond <chipx86@chipx86.com>
parents:
4421
diff
changeset
|
3450 gaim_gtkconv_update_font_face(conv); |
2054d8429925
[gaim-migrate @ 4713]
Christian Hammond <chipx86@chipx86.com>
parents:
4421
diff
changeset
|
3451 |
4383
f7a84034f97f
[gaim-migrate @ 4649]
Christian Hammond <chipx86@chipx86.com>
parents:
4382
diff
changeset
|
3452 if (conv_type == GAIM_CONV_CHAT) { |
4359 | 3453 gtkconv->u.chat = g_malloc0(sizeof(struct gaim_gtk_chat_pane)); |
3454 | |
3455 pane = setup_chat_pane(conv); | |
3456 } | |
4383
f7a84034f97f
[gaim-migrate @ 4649]
Christian Hammond <chipx86@chipx86.com>
parents:
4382
diff
changeset
|
3457 else if (conv_type == GAIM_CONV_IM) { |
4359 | 3458 gtkconv->u.im = g_malloc0(sizeof(struct gaim_gtk_im_pane)); |
3459 gtkconv->u.im->a_virgin = TRUE; | |
3460 | |
3461 pane = setup_im_pane(conv); | |
3462 } | |
3463 | |
3464 if (pane == NULL) { | |
4572
06084165a966
[gaim-migrate @ 4853]
Christian Hammond <chipx86@chipx86.com>
parents:
4571
diff
changeset
|
3465 if (conv_type == GAIM_CONV_CHAT) g_free(gtkconv->u.chat); |
06084165a966
[gaim-migrate @ 4853]
Christian Hammond <chipx86@chipx86.com>
parents:
4571
diff
changeset
|
3466 else if (conv_type == GAIM_CONV_IM) g_free(gtkconv->u.im); |
4359 | 3467 |
3468 g_free(gtkconv); | |
3469 conv->ui_data = NULL; | |
3470 | |
3471 return; | |
3472 } | |
3473 | |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3474 /* Setup drag-and-drop */ |
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3475 gtk_drag_dest_set(pane, |
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3476 GTK_DEST_DEFAULT_MOTION | |
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3477 GTK_DEST_DEFAULT_DROP, |
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3478 te, sizeof(te) / sizeof(GtkTargetEntry), |
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3479 GDK_ACTION_COPY); |
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3480 gtk_drag_dest_set(gtkconv->imhtml, |
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3481 GTK_DEST_DEFAULT_MOTION | |
4702 | 3482 GTK_DEST_DEFAULT_DROP, |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3483 te, sizeof(te) / sizeof(GtkTargetEntry), |
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3484 GDK_ACTION_DEFAULT | GDK_ACTION_COPY | GDK_ACTION_MOVE); |
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3485 gtk_drag_dest_set(gtkconv->entry, |
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3486 GTK_DEST_DEFAULT_MOTION | |
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3487 GTK_DEST_DEFAULT_DROP, |
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3488 te, sizeof(te) / sizeof(GtkTargetEntry), |
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3489 GDK_ACTION_COPY); |
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3490 |
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3491 g_signal_connect(G_OBJECT(pane), "drag_data_received", |
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3492 G_CALLBACK(conv_dnd_recv), conv); |
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3493 g_signal_connect(G_OBJECT(gtkconv->imhtml), "drag_data_received", |
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3494 G_CALLBACK(conv_dnd_recv), conv); |
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3495 #if 0 |
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3496 g_signal_connect(G_OBJECT(gtkconv->entry), "drag_data_received", |
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3497 G_CALLBACK(conv_dnd_recv), conv); |
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3498 #endif |
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3499 |
4383
f7a84034f97f
[gaim-migrate @ 4649]
Christian Hammond <chipx86@chipx86.com>
parents:
4382
diff
changeset
|
3500 /* |
f7a84034f97f
[gaim-migrate @ 4649]
Christian Hammond <chipx86@chipx86.com>
parents:
4382
diff
changeset
|
3501 * Write the New Conversation log string. |
f7a84034f97f
[gaim-migrate @ 4649]
Christian Hammond <chipx86@chipx86.com>
parents:
4382
diff
changeset
|
3502 * |
f7a84034f97f
[gaim-migrate @ 4649]
Christian Hammond <chipx86@chipx86.com>
parents:
4382
diff
changeset
|
3503 * This should probably be elsewhere, but then, logging should |
f7a84034f97f
[gaim-migrate @ 4649]
Christian Hammond <chipx86@chipx86.com>
parents:
4382
diff
changeset
|
3504 * 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
|
3505 */ |
f7a84034f97f
[gaim-migrate @ 4649]
Christian Hammond <chipx86@chipx86.com>
parents:
4382
diff
changeset
|
3506 if (gaim_conversation_is_logging(conv) && |
f7a84034f97f
[gaim-migrate @ 4649]
Christian Hammond <chipx86@chipx86.com>
parents:
4382
diff
changeset
|
3507 conv_type != GAIM_CONV_MISC) { |
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 FILE *fd; |
f7a84034f97f
[gaim-migrate @ 4649]
Christian Hammond <chipx86@chipx86.com>
parents:
4382
diff
changeset
|
3510 char filename[256]; |
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 g_snprintf(filename, sizeof(filename), "%s%s", name, |
f7a84034f97f
[gaim-migrate @ 4649]
Christian Hammond <chipx86@chipx86.com>
parents:
4382
diff
changeset
|
3513 (conv_type == GAIM_CONV_CHAT ? ".chat" : "")); |
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 fd = open_log_file(filename, (conv_type == GAIM_CONV_CHAT)); |
f7a84034f97f
[gaim-migrate @ 4649]
Christian Hammond <chipx86@chipx86.com>
parents:
4382
diff
changeset
|
3516 |
f7a84034f97f
[gaim-migrate @ 4649]
Christian Hammond <chipx86@chipx86.com>
parents:
4382
diff
changeset
|
3517 if (fd) { |
f7a84034f97f
[gaim-migrate @ 4649]
Christian Hammond <chipx86@chipx86.com>
parents:
4382
diff
changeset
|
3518 if (!(logging_options & OPT_LOG_STRIP_HTML)) |
f7a84034f97f
[gaim-migrate @ 4649]
Christian Hammond <chipx86@chipx86.com>
parents:
4382
diff
changeset
|
3519 fprintf(fd, |
f7a84034f97f
[gaim-migrate @ 4649]
Christian Hammond <chipx86@chipx86.com>
parents:
4382
diff
changeset
|
3520 "<HR><BR><H3 Align=Center> " |
f7a84034f97f
[gaim-migrate @ 4649]
Christian Hammond <chipx86@chipx86.com>
parents:
4382
diff
changeset
|
3521 "---- New Conversation @ %s ----</H3><BR>\n", |
f7a84034f97f
[gaim-migrate @ 4649]
Christian Hammond <chipx86@chipx86.com>
parents:
4382
diff
changeset
|
3522 full_date()); |
f7a84034f97f
[gaim-migrate @ 4649]
Christian Hammond <chipx86@chipx86.com>
parents:
4382
diff
changeset
|
3523 else |
f7a84034f97f
[gaim-migrate @ 4649]
Christian Hammond <chipx86@chipx86.com>
parents:
4382
diff
changeset
|
3524 fprintf(fd, "---- New Conversation @ %s ----\n", |
f7a84034f97f
[gaim-migrate @ 4649]
Christian Hammond <chipx86@chipx86.com>
parents:
4382
diff
changeset
|
3525 full_date()); |
f7a84034f97f
[gaim-migrate @ 4649]
Christian Hammond <chipx86@chipx86.com>
parents:
4382
diff
changeset
|
3526 |
f7a84034f97f
[gaim-migrate @ 4649]
Christian Hammond <chipx86@chipx86.com>
parents:
4382
diff
changeset
|
3527 fclose(fd); |
f7a84034f97f
[gaim-migrate @ 4649]
Christian Hammond <chipx86@chipx86.com>
parents:
4382
diff
changeset
|
3528 } |
f7a84034f97f
[gaim-migrate @ 4649]
Christian Hammond <chipx86@chipx86.com>
parents:
4382
diff
changeset
|
3529 } |
f7a84034f97f
[gaim-migrate @ 4649]
Christian Hammond <chipx86@chipx86.com>
parents:
4382
diff
changeset
|
3530 |
4359 | 3531 /* Setup the container for the tab. */ |
3532 gtkconv->tab_cont = tab_cont = gtk_vbox_new(FALSE, 5); | |
3533 gtk_container_set_border_width(GTK_CONTAINER(tab_cont), 5); | |
3534 gtk_container_add(GTK_CONTAINER(tab_cont), pane); | |
3535 gtk_widget_show(pane); | |
3536 | |
3537 new_ui = TRUE; | |
4636 | 3538 |
3539 gtk_widget_grab_focus(pane); | |
3540 | |
4359 | 3541 gtkconv->make_sound = TRUE; |
3542 } | |
3543 | |
3544 gtkconv->tabby = tabby = gtk_hbox_new(FALSE, 5); | |
3545 | |
3546 /* Close button. */ | |
3547 gtkconv->close = gtk_button_new(); | |
3548 gtk_widget_set_size_request(GTK_WIDGET(gtkconv->close), 16, 16); | |
3549 gtk_container_add(GTK_CONTAINER(gtkconv->close), | |
4445 | 3550 gtk_image_new_from_stock(GTK_STOCK_CLOSE, |
3551 GTK_ICON_SIZE_MENU)); | |
4359 | 3552 gtk_button_set_relief(GTK_BUTTON(gtkconv->close), GTK_RELIEF_NONE); |
3553 gtk_tooltips_set_tip(gtkconv->tooltips, gtkconv->close, | |
4572
06084165a966
[gaim-migrate @ 4853]
Christian Hammond <chipx86@chipx86.com>
parents:
4571
diff
changeset
|
3554 _("Close conversation"), NULL); |
4359 | 3555 |
3556 g_signal_connect(G_OBJECT(gtkconv->close), "clicked", | |
4571
51e988d015ed
[gaim-migrate @ 4852]
Christian Hammond <chipx86@chipx86.com>
parents:
4561
diff
changeset
|
3557 G_CALLBACK(close_conv_cb), conv); |
4359 | 3558 |
3559 /* Tab label. */ | |
3560 gtkconv->tab_label = gtk_label_new(gaim_conversation_get_title(conv)); | |
3561 #if 0 | |
3562 gtk_misc_set_alignment(GTK_MISC(gtkconv->tab_label), 0.00, 0.5); | |
3563 gtk_misc_set_padding(GTK_MISC(gtkconv->tab_label), 4, 0); | |
3564 #endif | |
3565 | |
3566 /* Pack it all together. */ | |
3567 gtk_box_pack_start(GTK_BOX(tabby), gtkconv->tab_label, TRUE, TRUE, 0); | |
4445 | 3568 gtk_widget_show(gtkconv->tab_label); |
3569 gtk_box_pack_start(GTK_BOX(tabby), gtkconv->close, FALSE, FALSE, 0); | |
3570 if (!(convo_options & OPT_CONVO_NO_X_ON_TAB)) | |
3571 gtk_widget_show_all(gtkconv->close); | |
3572 gtk_widget_show(tabby); | |
4359 | 3573 |
3574 | |
3575 /* Add this pane to the conversations notebook. */ | |
3576 gtk_notebook_append_page(GTK_NOTEBOOK(gtkwin->notebook), tab_cont, tabby); | |
3577 gtk_notebook_set_menu_label_text(GTK_NOTEBOOK(gtkwin->notebook), tab_cont, | |
3578 gaim_conversation_get_title(conv)); | |
3579 | |
3580 gtk_widget_show(tab_cont); | |
3581 | |
3582 /* Er, bug in notebooks? Switch to the page manually. */ | |
3583 if (gaim_window_get_conversation_count(win) == 1) | |
3584 gtk_notebook_set_current_page(GTK_NOTEBOOK(gtkwin->notebook), 0); | |
3585 | |
3586 if ((gtk_notebook_get_current_page(GTK_NOTEBOOK(gtkwin->notebook)) == 0) || | |
3587 (conv == g_list_nth_data(gaim_window_get_conversations(win), 0))) { | |
3588 | |
3589 gtk_widget_grab_focus(gtkconv->entry); | |
3590 } | |
3591 | |
3592 gaim_gtkconv_update_buddy_icon(conv); | |
3593 | |
3594 if (!new_ui) | |
3595 g_object_unref(gtkconv->tab_cont); | |
3596 | |
3597 if (gaim_window_get_conversation_count(win) == 1) | |
4685 | 3598 g_timeout_add(0, (GSourceFunc)update_send_as_selection, win); |
4359 | 3599 } |
3600 | |
3601 static void | |
3602 gaim_gtk_remove_conversation(struct gaim_window *win, | |
3603 struct gaim_conversation *conv) | |
3604 { | |
3605 struct gaim_gtk_window *gtkwin; | |
3606 struct gaim_gtk_conversation *gtkconv; | |
3607 unsigned int index; | |
3608 | |
3609 index = gaim_conversation_get_index(conv); | |
3610 | |
3611 gtkwin = GAIM_GTK_WINDOW(win); | |
3612 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
3613 | |
3614 g_object_ref(gtkconv->tab_cont); | |
3615 gtk_object_sink(GTK_OBJECT(gtkconv->tab_cont)); | |
3616 | |
3617 gtk_notebook_remove_page(GTK_NOTEBOOK(gtkwin->notebook), index); | |
3618 | |
3619 /* If this window is setup with an inactive gc, regenerate the menu. */ | |
3620 if (gaim_conversation_get_type(conv) == GAIM_CONV_IM && | |
3621 gaim_conversation_get_gc(conv) == NULL) { | |
3622 | |
4360
c435a29370b8
[gaim-migrate @ 4626]
Christian Hammond <chipx86@chipx86.com>
parents:
4359
diff
changeset
|
3623 generate_send_as_items(win, conv); |
4359 | 3624 } |
3625 } | |
3626 | |
3627 static void | |
3628 gaim_gtk_move_conversation(struct gaim_window *win, | |
3629 struct gaim_conversation *conv, | |
3630 unsigned int new_index) | |
3631 { | |
3632 struct gaim_gtk_window *gtkwin; | |
3633 struct gaim_gtk_conversation *gtkconv; | |
3634 | |
3635 gtkwin = GAIM_GTK_WINDOW(win); | |
3636 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
3637 | |
4415
c90039137172
[gaim-migrate @ 4688]
Christian Hammond <chipx86@chipx86.com>
parents:
4409
diff
changeset
|
3638 if (new_index > gaim_conversation_get_index(conv)) |
c90039137172
[gaim-migrate @ 4688]
Christian Hammond <chipx86@chipx86.com>
parents:
4409
diff
changeset
|
3639 new_index--; |
c90039137172
[gaim-migrate @ 4688]
Christian Hammond <chipx86@chipx86.com>
parents:
4409
diff
changeset
|
3640 |
4359 | 3641 gtk_notebook_reorder_child(GTK_NOTEBOOK(gtkwin->notebook), |
3642 gtkconv->tab_cont, new_index); | |
3643 } | |
3644 | |
3645 static int | |
3646 gaim_gtk_get_active_index(const struct gaim_window *win) | |
3647 { | |
3648 struct gaim_gtk_window *gtkwin; | |
3649 | |
3650 gtkwin = GAIM_GTK_WINDOW(win); | |
3651 | |
3652 return gtk_notebook_get_current_page(GTK_NOTEBOOK(gtkwin->notebook)); | |
3653 } | |
3654 | |
4465
6e37eb000b7a
[gaim-migrate @ 4740]
Christian Hammond <chipx86@chipx86.com>
parents:
4454
diff
changeset
|
3655 static struct gaim_window_ui_ops window_ui_ops = |
4359 | 3656 { |
4465
6e37eb000b7a
[gaim-migrate @ 4740]
Christian Hammond <chipx86@chipx86.com>
parents:
4454
diff
changeset
|
3657 gaim_gtk_get_conversation_ui_ops, |
4359 | 3658 gaim_gtk_new_window, |
3659 gaim_gtk_destroy_window, | |
3660 gaim_gtk_show, | |
3661 gaim_gtk_hide, | |
3662 gaim_gtk_raise, | |
3663 gaim_gtk_flash, | |
3664 gaim_gtk_switch_conversation, | |
3665 gaim_gtk_add_conversation, | |
3666 gaim_gtk_remove_conversation, | |
3667 gaim_gtk_move_conversation, | |
3668 gaim_gtk_get_active_index | |
3669 }; | |
3670 | |
3671 static void | |
3672 update_convo_add_button(struct gaim_conversation *conv) | |
3673 { | |
3674 struct gaim_gtk_conversation *gtkconv; | |
3675 struct gaim_connection *gc; | |
3676 GaimConversationType type; | |
3677 GtkWidget *parent; | |
3678 | |
3679 type = gaim_conversation_get_type(conv); | |
3680 gc = gaim_conversation_get_gc(conv); | |
3681 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
3682 parent = gtk_widget_get_parent(gtkconv->u.im->add); | |
3683 | |
4687 | 3684 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
|
3685 gtkconv->u.im->add = |
ce3a0eba91ef
[gaim-migrate @ 4666]
Christian Hammond <chipx86@chipx86.com>
parents:
4387
diff
changeset
|
3686 gaim_gtk_change_text(_("Remove"), gtkconv->u.im->add, |
ce3a0eba91ef
[gaim-migrate @ 4666]
Christian Hammond <chipx86@chipx86.com>
parents:
4387
diff
changeset
|
3687 GTK_STOCK_REMOVE, type); |
ce3a0eba91ef
[gaim-migrate @ 4666]
Christian Hammond <chipx86@chipx86.com>
parents:
4387
diff
changeset
|
3688 gtk_tooltips_set_tip(gtkconv->tooltips, gtkconv->u.im->add, |
ce3a0eba91ef
[gaim-migrate @ 4666]
Christian Hammond <chipx86@chipx86.com>
parents:
4387
diff
changeset
|
3689 _("Remove the user from your buddy list"), NULL); |
ce3a0eba91ef
[gaim-migrate @ 4666]
Christian Hammond <chipx86@chipx86.com>
parents:
4387
diff
changeset
|
3690 |
4359 | 3691 gtk_widget_set_sensitive(gtkconv->u.im->add, |
3692 (gc != NULL && gc->prpl->remove_buddy != NULL)); | |
3693 } else { | |
4397
ce3a0eba91ef
[gaim-migrate @ 4666]
Christian Hammond <chipx86@chipx86.com>
parents:
4387
diff
changeset
|
3694 gtkconv->u.im->add = |
ce3a0eba91ef
[gaim-migrate @ 4666]
Christian Hammond <chipx86@chipx86.com>
parents:
4387
diff
changeset
|
3695 gaim_gtk_change_text(_("Add"), gtkconv->u.im->add, |
ce3a0eba91ef
[gaim-migrate @ 4666]
Christian Hammond <chipx86@chipx86.com>
parents:
4387
diff
changeset
|
3696 GTK_STOCK_ADD, type); |
ce3a0eba91ef
[gaim-migrate @ 4666]
Christian Hammond <chipx86@chipx86.com>
parents:
4387
diff
changeset
|
3697 gtk_tooltips_set_tip(gtkconv->tooltips, gtkconv->u.im->add, |
ce3a0eba91ef
[gaim-migrate @ 4666]
Christian Hammond <chipx86@chipx86.com>
parents:
4387
diff
changeset
|
3698 _("Add the user to your buddy list"), NULL); |
4359 | 3699 |
3700 gtk_widget_set_sensitive(gtkconv->u.im->add, | |
3701 (gc != NULL && gc->prpl->add_buddy != NULL)); | |
3702 } | |
3703 | |
4397
ce3a0eba91ef
[gaim-migrate @ 4666]
Christian Hammond <chipx86@chipx86.com>
parents:
4387
diff
changeset
|
3704 g_signal_connect(G_OBJECT(gtkconv->u.im->add), "clicked", |
ce3a0eba91ef
[gaim-migrate @ 4666]
Christian Hammond <chipx86@chipx86.com>
parents:
4387
diff
changeset
|
3705 G_CALLBACK(add_cb), conv); |
ce3a0eba91ef
[gaim-migrate @ 4666]
Christian Hammond <chipx86@chipx86.com>
parents:
4387
diff
changeset
|
3706 |
ce3a0eba91ef
[gaim-migrate @ 4666]
Christian Hammond <chipx86@chipx86.com>
parents:
4387
diff
changeset
|
3707 gtk_box_pack_start(GTK_BOX(parent), gtkconv->u.im->add, |
ce3a0eba91ef
[gaim-migrate @ 4666]
Christian Hammond <chipx86@chipx86.com>
parents:
4387
diff
changeset
|
3708 FALSE, FALSE, 0); |
ce3a0eba91ef
[gaim-migrate @ 4666]
Christian Hammond <chipx86@chipx86.com>
parents:
4387
diff
changeset
|
3709 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
|
3710 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
|
3711 gtk_size_group_add_widget(gtkconv->sg, gtkconv->u.im->add); |
4359 | 3712 } |
3713 | |
4465
6e37eb000b7a
[gaim-migrate @ 4740]
Christian Hammond <chipx86@chipx86.com>
parents:
4454
diff
changeset
|
3714 struct gaim_window_ui_ops * |
6e37eb000b7a
[gaim-migrate @ 4740]
Christian Hammond <chipx86@chipx86.com>
parents:
4454
diff
changeset
|
3715 gaim_get_gtk_window_ui_ops(void) |
4359 | 3716 { |
4465
6e37eb000b7a
[gaim-migrate @ 4740]
Christian Hammond <chipx86@chipx86.com>
parents:
4454
diff
changeset
|
3717 return &window_ui_ops; |
4359 | 3718 } |
3719 | |
3720 /************************************************************************** | |
4465
6e37eb000b7a
[gaim-migrate @ 4740]
Christian Hammond <chipx86@chipx86.com>
parents:
4454
diff
changeset
|
3721 * Conversation UI operations |
4359 | 3722 **************************************************************************/ |
3723 static void | |
3724 gaim_gtkconv_destroy(struct gaim_conversation *conv) | |
3725 { | |
3726 struct gaim_gtk_conversation *gtkconv = GAIM_GTK_CONVERSATION(conv); | |
3727 | |
3728 if (gtkconv->dialogs.fg_color != NULL) | |
3729 gtk_widget_destroy(gtkconv->dialogs.fg_color); | |
3730 | |
3731 if (gtkconv->dialogs.bg_color != NULL) | |
3732 gtk_widget_destroy(gtkconv->dialogs.bg_color); | |
3733 | |
3734 if (gtkconv->dialogs.font != NULL) | |
3735 gtk_widget_destroy(gtkconv->dialogs.font); | |
3736 | |
3737 if (gtkconv->dialogs.smiley != NULL) | |
3738 gtk_widget_destroy(gtkconv->dialogs.smiley); | |
3739 | |
3740 if (gtkconv->dialogs.link != NULL) | |
3741 gtk_widget_destroy(gtkconv->dialogs.link); | |
3742 | |
3743 if (gtkconv->dialogs.log != NULL) | |
3744 gtk_widget_destroy(gtkconv->dialogs.log); | |
3745 | |
4571
51e988d015ed
[gaim-migrate @ 4852]
Christian Hammond <chipx86@chipx86.com>
parents:
4561
diff
changeset
|
3746 gtk_widget_destroy(gtkconv->tab_cont); |
51e988d015ed
[gaim-migrate @ 4852]
Christian Hammond <chipx86@chipx86.com>
parents:
4561
diff
changeset
|
3747 |
4359 | 3748 if (gaim_conversation_get_type(conv) == GAIM_CONV_IM) { |
4755 | 3749 if (gtkconv->u.im->icon_timer != 0) |
3750 g_source_remove(gtkconv->u.im->icon_timer); | |
3751 | |
4359 | 3752 if (gtkconv->u.im->save_icon != NULL) |
3753 gtk_widget_destroy(gtkconv->u.im->save_icon); | |
3754 | |
3755 if (gtkconv->u.im->anim != NULL) | |
3756 gdk_pixbuf_animation_unref(gtkconv->u.im->anim); | |
3757 | |
3758 g_free(gtkconv->u.im); | |
3759 } | |
3760 else if (gaim_conversation_get_type(conv) == GAIM_CONV_CHAT) { | |
3761 g_free(gtkconv->u.chat); | |
3762 } | |
3763 | |
4633 | 3764 gtk_object_sink(GTK_OBJECT(gtkconv->tooltips)); |
3765 | |
4359 | 3766 g_free(gtkconv); |
3767 } | |
3768 | |
3769 static void | |
3770 gaim_gtkconv_write_im(struct gaim_conversation *conv, const char *who, | |
3771 const char *message, size_t len, int flags, time_t mtime) | |
3772 { | |
3773 struct gaim_gtk_conversation *gtkconv; | |
3774 | |
3775 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
3776 | |
4382
76223649765b
[gaim-migrate @ 4648]
Christian Hammond <chipx86@chipx86.com>
parents:
4378
diff
changeset
|
3777 /* Play a sound, if specified in prefs. */ |
4359 | 3778 if (gtkconv->make_sound) { |
3779 if (flags & WFLAG_RECV) { | |
3780 if (gtkconv->u.im->a_virgin && | |
3781 (sound_options & OPT_SOUND_FIRST_RCV)) { | |
3782 | |
4561 | 3783 gaim_sound_play_event(GAIM_SOUND_FIRST_RECEIVE); |
4359 | 3784 } |
3785 else | |
4561 | 3786 gaim_sound_play_event(GAIM_SOUND_RECEIVE); |
4359 | 3787 } |
3788 else { | |
4561 | 3789 gaim_sound_play_event(GAIM_SOUND_SEND); |
4359 | 3790 } |
3791 } | |
3792 | |
3793 gtkconv->u.im->a_virgin = FALSE; | |
3794 | |
3795 gaim_conversation_write(conv, who, message, len, flags, mtime); | |
3796 } | |
3797 | |
3798 static void | |
3799 gaim_gtkconv_write_chat(struct gaim_conversation *conv, const char *who, | |
3800 const char *message, int flags, time_t mtime) | |
3801 { | |
3802 struct gaim_gtk_conversation *gtkconv; | |
3803 | |
3804 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
3805 | |
4382
76223649765b
[gaim-migrate @ 4648]
Christian Hammond <chipx86@chipx86.com>
parents:
4378
diff
changeset
|
3806 /* Play a sound, if specified in prefs. */ |
4359 | 3807 if (gtkconv->make_sound) { |
3808 if (!(flags & WFLAG_WHISPER) && (flags & WFLAG_SEND)) | |
4561 | 3809 gaim_sound_play_event(GAIM_SOUND_CHAT_YOU_SAY); |
4359 | 3810 else if (flags & WFLAG_RECV) { |
3811 if ((flags & WFLAG_NICK) && (sound_options & OPT_SOUND_CHAT_NICK)) | |
4561 | 3812 gaim_sound_play_event(GAIM_SOUND_CHAT_NICK); |
4359 | 3813 else |
4561 | 3814 gaim_sound_play_event(GAIM_SOUND_CHAT_SAY); |
4359 | 3815 } |
3816 } | |
3817 | |
3818 if (chat_options & OPT_CHAT_COLORIZE) | |
3819 flags |= WFLAG_COLORIZE; | |
3820 | |
3821 gaim_conversation_write(conv, who, message, -1, flags, mtime); | |
3822 } | |
3823 | |
3824 static void | |
3825 gaim_gtkconv_write_conv(struct gaim_conversation *conv, const char *who, | |
3826 const char *message, size_t length, int flags, | |
3827 time_t mtime) | |
3828 { | |
3829 struct gaim_gtk_conversation *gtkconv; | |
3830 struct gaim_connection *gc; | |
3831 int gtk_font_options = 0; | |
3832 GString *log_str; | |
3833 FILE *fd; | |
3834 char buf[BUF_LONG]; | |
3835 char buf2[BUF_LONG]; | |
3836 char mdate[64]; | |
3837 char color[10]; | |
3838 char *str; | |
3839 char *with_font_tag; | |
3840 | |
3841 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
3842 gc = gaim_conversation_get_gc(conv); | |
3843 | |
3844 strftime(mdate, sizeof(mdate), "%H:%M:%S", localtime(&mtime)); | |
3845 | |
3846 gtk_font_options ^= GTK_IMHTML_NO_COMMENTS; | |
3847 | |
3848 if (convo_options & OPT_CONVO_IGNORE_COLOUR) | |
3849 gtk_font_options ^= GTK_IMHTML_NO_COLOURS; | |
3850 | |
3851 if (convo_options & OPT_CONVO_IGNORE_FONTS) | |
3852 gtk_font_options ^= GTK_IMHTML_NO_FONTS; | |
3853 | |
3854 if (convo_options & OPT_CONVO_IGNORE_SIZES) | |
3855 gtk_font_options ^= GTK_IMHTML_NO_SIZES; | |
3856 | |
3857 if (!(logging_options & OPT_LOG_STRIP_HTML)) | |
3858 gtk_font_options ^= GTK_IMHTML_RETURN_LOG; | |
3859 | |
3860 if (flags & WFLAG_SYSTEM) { | |
3861 if (convo_options & OPT_CONVO_SHOW_TIME) | |
3862 g_snprintf(buf, BUF_LONG, "<FONT SIZE=\"2\">(%s) </FONT><B>%s</B>", | |
3863 mdate, message); | |
3864 else | |
3865 g_snprintf(buf, BUF_LONG, "<B>%s</B>", message); | |
3866 | |
3867 g_snprintf(buf2, sizeof(buf2), | |
3868 "<FONT SIZE=\"2\"><!--(%s) --></FONT><B>%s</B><BR>", | |
3869 mdate, message); | |
3870 | |
3871 gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), buf2, -1, 0); | |
3872 | |
3873 if (logging_options & OPT_LOG_STRIP_HTML) { | |
3874 char *t1 = strip_html(buf); | |
3875 | |
3876 conv->history = g_string_append(conv->history, t1); | |
3877 conv->history = g_string_append(conv->history, "\n"); | |
3878 | |
3879 g_free(t1); | |
3880 } | |
3881 else { | |
3882 conv->history = g_string_append(conv->history, buf); | |
3883 conv->history = g_string_append(conv->history, "<BR>\n"); | |
3884 } | |
3885 | |
3886 if (!(flags & WFLAG_NOLOG) && gaim_conversation_is_logging(conv)) { | |
3887 | |
3888 char *t1; | |
3889 char nm[256]; | |
3890 | |
3891 if (logging_options & OPT_LOG_STRIP_HTML) | |
3892 t1 = strip_html(buf); | |
3893 else | |
3894 t1 = buf; | |
3895 | |
3896 if (gaim_conversation_get_type(conv) == GAIM_CONV_CHAT) | |
3897 g_snprintf(nm, sizeof(nm), "%s.chat", | |
3898 gaim_conversation_get_name(conv)); | |
3899 else | |
3900 strncpy(nm, gaim_conversation_get_name(conv), sizeof(nm)); | |
3901 | |
3902 fd = open_log_file(nm, | |
3903 (gaim_conversation_get_type(conv) == GAIM_CONV_CHAT)); | |
3904 | |
3905 if (fd) { | |
3906 if (logging_options & OPT_LOG_STRIP_HTML) | |
3907 fprintf(fd, "%s\n", t1); | |
3908 else | |
3909 fprintf(fd, "%s<BR>\n", t1); | |
3910 | |
3911 fclose(fd); | |
3912 } | |
3913 | |
3914 if (logging_options & OPT_LOG_STRIP_HTML) | |
3915 g_free(t1); | |
3916 } | |
3917 } | |
3918 else if (flags & WFLAG_NOLOG) { | |
3919 g_snprintf(buf, BUF_LONG, | |
3920 "<B><FONT COLOR=\"#777777\">%s</FONT></B><BR>", | |
3921 message); | |
3922 | |
3923 gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), buf, -1, 0); | |
3924 } | |
3925 else { | |
3926 char *new_message = g_strdup(message); | |
3927 | |
3928 if (flags & WFLAG_WHISPER) { | |
3929 str = g_malloc(1024); | |
3930 | |
3931 /* If we're whispering, it's not an autoresponse. */ | |
3932 if (meify(new_message, length)) { | |
3933 g_snprintf(str, 1024, "***%s", who); | |
3934 strcpy(color, "#6C2585"); | |
3935 } | |
3936 else { | |
3937 g_snprintf(str, 1024, "*%s*:", who); | |
3938 strcpy(color, "#00FF00"); | |
3939 } | |
3940 } | |
3941 else { | |
3942 if (meify(new_message, length)) { | |
3943 str = g_malloc(1024); | |
3944 | |
3945 if (flags & WFLAG_AUTO) | |
3946 g_snprintf(str, 1024, "%s ***%s", AUTO_RESPONSE, who); | |
3947 else | |
3948 g_snprintf(str, 1024, "***%s", who); | |
3949 | |
3950 if (flags & WFLAG_NICK) | |
3951 strcpy(color, "#AF7F00"); | |
3952 else | |
3953 strcpy(color, "#062585"); | |
3954 } | |
3955 else { | |
3956 str = g_malloc(1024); | |
3957 | |
3958 if (flags & WFLAG_AUTO) | |
3959 g_snprintf(str, 1024, "%s %s", who, AUTO_RESPONSE); | |
3960 else | |
3961 g_snprintf(str, 1024, "%s:", who); | |
3962 | |
3963 if (flags & WFLAG_NICK) | |
3964 strcpy(color, "#AF7F00"); | |
3965 else if (flags & WFLAG_RECV) { | |
3966 if (flags & WFLAG_COLORIZE) { | |
3967 const char *u; | |
3968 int m = 0; | |
3969 | |
3970 for (u = who; *u != '\0'; u++) | |
3971 m += *u; | |
3972 | |
3973 m = m % NUM_NICK_COLORS; | |
3974 | |
3975 strcpy(color, nick_colors[m]); | |
3976 } | |
3977 else | |
3978 strcpy(color, "#A82F2F"); | |
3979 } | |
3980 else if (flags & WFLAG_SEND) | |
3981 strcpy(color, "#16569E"); | |
3982 } | |
3983 } | |
3984 | |
3985 if (convo_options & OPT_CONVO_SHOW_TIME) | |
3986 g_snprintf(buf, BUF_LONG, | |
3987 "<FONT COLOR=\"%s\"><FONT SIZE=\"2\">(%s) </FONT>" | |
3988 "<B>%s</B></FONT> ", color, mdate, str); | |
3989 else | |
3990 g_snprintf(buf, BUF_LONG, | |
3991 "<FONT COLOR=\"%s\"><B>%s</B></FONT> ", color, str); | |
3992 | |
3993 g_snprintf(buf2, BUF_LONG, | |
3994 "<FONT COLOR=\"%s\"><FONT SIZE=\"2\"><!--(%s) --></FONT>" | |
3995 "<B>%s</B></FONT> ", | |
3996 color, mdate, str); | |
3997 | |
3998 g_free(str); | |
3999 | |
4000 gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), buf2, -1, 0); | |
4001 | |
4608 | 4002 if(gc) |
4003 with_font_tag = g_strdup_printf("<font sml=\"%s\">%s</font>", | |
4359 | 4004 gc->prpl->name, new_message); |
4608 | 4005 else |
4006 with_font_tag = g_strdup(new_message); | |
4359 | 4007 |
4008 log_str = gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), | |
4009 with_font_tag, length, | |
4010 gtk_font_options); | |
4011 | |
4012 gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), "<BR>", -1, 0); | |
4013 | |
4014 /* XXX This needs to be updated for the new length argument. */ | |
4015 if (logging_options & OPT_LOG_STRIP_HTML) { | |
4016 char *t1, *t2; | |
4017 | |
4018 t1 = strip_html(buf); | |
4019 t2 = strip_html(new_message); | |
4020 | |
4021 conv->history = g_string_append(conv->history, t1); | |
4022 conv->history = g_string_append(conv->history, t2); | |
4023 conv->history = g_string_append(conv->history, "\n"); | |
4024 | |
4025 g_free(t1); | |
4026 g_free(t2); | |
4027 } | |
4028 else { | |
4029 char *t1, *t2; | |
4030 | |
4031 t1 = html_logize(buf); | |
4032 t2 = html_logize(new_message); | |
4033 | |
4034 conv->history = g_string_append(conv->history, t1); | |
4035 conv->history = g_string_append(conv->history, t2); | |
4036 conv->history = g_string_append(conv->history, "\n"); | |
4037 conv->history = g_string_append(conv->history, log_str->str); | |
4038 conv->history = g_string_append(conv->history, "<BR>\n"); | |
4039 | |
4040 g_free(t1); | |
4041 g_free(t2); | |
4042 } | |
4043 | |
4044 /* XXX This needs to be updated for the new length argument. */ | |
4045 if (gaim_conversation_is_logging(conv)) { | |
4046 char *t1, *t2; | |
4047 char nm[256]; | |
4048 | |
4049 if (gaim_conversation_get_type(conv) == GAIM_CONV_CHAT) | |
4050 g_snprintf(nm, sizeof(nm), "%s.chat", | |
4051 gaim_conversation_get_name(conv)); | |
4052 else | |
4053 strncpy(nm, gaim_conversation_get_name(conv), sizeof(nm)); | |
4054 | |
4055 if (logging_options & OPT_LOG_STRIP_HTML) { | |
4056 t1 = strip_html(buf); | |
4057 t2 = strip_html(with_font_tag); | |
4058 } | |
4059 else { | |
4060 t1 = html_logize(buf); | |
4061 t2 = html_logize(with_font_tag); | |
4062 } | |
4063 | |
4064 fd = open_log_file(nm, | |
4065 (gaim_conversation_get_type(conv) == GAIM_CONV_CHAT)); | |
4066 | |
4067 if (fd) { | |
4068 if (logging_options & OPT_LOG_STRIP_HTML) | |
4069 fprintf(fd, "%s%s\n", t1, t2); | |
4070 else { | |
4071 fprintf(fd, "%s%s%s<BR>\n", t1, t2, log_str->str); | |
4072 g_string_free(log_str, TRUE); | |
4073 } | |
4074 | |
4075 fclose(fd); | |
4076 } | |
4077 | |
4078 g_free(t1); | |
4079 g_free(t2); | |
4080 } | |
4081 | |
4082 g_free(with_font_tag); | |
4083 g_free(new_message); | |
4084 } | |
4085 } | |
4086 | |
4087 static void | |
4088 gaim_gtkconv_chat_add_user(struct gaim_conversation *conv, const char *user) | |
4089 { | |
4090 struct gaim_chat *chat; | |
4091 struct gaim_gtk_conversation *gtkconv; | |
4092 struct gaim_gtk_chat_pane *gtkchat; | |
4093 char tmp[BUF_LONG]; | |
4094 int num_users; | |
4095 int pos; | |
4096 | |
4097 chat = GAIM_CHAT(conv); | |
4098 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
4099 gtkchat = gtkconv->u.chat; | |
4100 | |
4101 num_users = g_list_length(gaim_chat_get_users(chat)); | |
4102 | |
4103 g_snprintf(tmp, sizeof(tmp), | |
4104 ngettext("%d person in room", "%d people in room", | |
4105 num_users), | |
4106 num_users); | |
4107 | |
4108 gtk_label_set_text(GTK_LABEL(gtkchat->count), tmp); | |
4109 | |
4110 if (gtkconv->make_sound) | |
4561 | 4111 gaim_sound_play_event(GAIM_SOUND_CHAT_JOIN); |
4359 | 4112 |
4113 pos = g_list_index(gaim_chat_get_users(chat), user); | |
4114 | |
4115 add_chat_buddy_common(conv, user, pos); | |
4116 } | |
4117 | |
4118 static void | |
4119 gaim_gtkconv_chat_rename_user(struct gaim_conversation *conv, | |
4120 const char *old_name, const char *new_name) | |
4121 { | |
4122 struct gaim_chat *chat; | |
4123 struct gaim_gtk_conversation *gtkconv; | |
4124 struct gaim_gtk_chat_pane *gtkchat; | |
4125 GtkTreeIter iter; | |
4126 GtkTreeModel *model; | |
4127 GList *names; | |
4128 int pos; | |
4129 int f = 1; | |
4130 | |
4131 chat = GAIM_CHAT(conv); | |
4132 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
4133 gtkchat = gtkconv->u.chat; | |
4134 | |
4135 for (names = gaim_chat_get_users(chat); | |
4136 names != NULL; | |
4137 names = names->next) { | |
4138 | |
4139 char *u = (char *)names->data; | |
4140 | |
4141 if (!g_strcasecmp(u, old_name)) { | |
4142 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); | |
4143 | |
4144 if (!gtk_tree_model_get_iter_first(GTK_TREE_MODEL(model), &iter)) | |
4145 break; | |
4146 | |
4147 while (f != 0) { | |
4148 char *val; | |
4149 | |
4150 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, 1, &val, -1); | |
4151 | |
4640 | 4152 if (!g_strcasecmp(old_name, val)) { |
4359 | 4153 gtk_list_store_remove(GTK_LIST_STORE(model), &iter); |
4640 | 4154 break; |
4155 } | |
4359 | 4156 |
4157 f = gtk_tree_model_iter_next(GTK_TREE_MODEL(model), &iter); | |
4158 | |
4159 g_free(val); | |
4160 } | |
4161 | |
4162 break; | |
4163 } | |
4164 } | |
4165 | |
4166 if (!names) | |
4167 return; | |
4168 | |
4169 pos = g_list_index(gaim_chat_get_users(chat), new_name); | |
4170 | |
4171 add_chat_buddy_common(conv, new_name, pos); | |
4172 } | |
4173 | |
4174 static void | |
4175 gaim_gtkconv_chat_remove_user(struct gaim_conversation *conv, const char *user) | |
4176 { | |
4177 struct gaim_chat *chat; | |
4178 struct gaim_gtk_conversation *gtkconv; | |
4179 struct gaim_gtk_chat_pane *gtkchat; | |
4180 GtkTreeIter iter; | |
4181 GtkTreeModel *model; | |
4182 GList *names; | |
4183 char tmp[BUF_LONG]; | |
4184 int num_users; | |
4185 int f = 1; | |
4186 | |
4187 chat = GAIM_CHAT(conv); | |
4188 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
4189 gtkchat = gtkconv->u.chat; | |
4190 | |
4191 num_users = g_list_length(gaim_chat_get_users(chat)) - 1; | |
4192 | |
4193 for (names = gaim_chat_get_users(chat); | |
4194 names != NULL; | |
4195 names = names->next) { | |
4196 | |
4197 char *u = (char *)names->data; | |
4198 | |
4199 if (!g_strcasecmp(u, user)) { | |
4200 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); | |
4201 | |
4202 if (!gtk_tree_model_get_iter_first(GTK_TREE_MODEL(model), &iter)) | |
4203 break; | |
4204 | |
4205 while (f != 0) { | |
4206 char *val; | |
4207 | |
4208 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, 1, &val, -1); | |
4209 | |
4210 if (!g_strcasecmp(user, val)) | |
4211 gtk_list_store_remove(GTK_LIST_STORE(model), &iter); | |
4212 | |
4213 f = gtk_tree_model_iter_next(GTK_TREE_MODEL(model), &iter); | |
4214 | |
4215 g_free(val); | |
4216 } | |
4217 | |
4218 break; | |
4219 } | |
4220 } | |
4221 | |
4222 if (names == NULL) | |
4223 return; | |
4224 | |
4225 g_snprintf(tmp, sizeof(tmp), | |
4226 ngettext("%d person in room", "%d people in room", | |
4227 num_users), num_users); | |
4228 | |
4229 gtk_label_set_text(GTK_LABEL(gtkchat->count), tmp); | |
4230 | |
4231 if (gtkconv->make_sound) | |
4561 | 4232 gaim_sound_play_event(GAIM_SOUND_CHAT_LEAVE); |
4359 | 4233 } |
4234 | |
4235 static void | |
4236 gaim_gtkconv_set_title(struct gaim_conversation *conv, const char *title) | |
4237 { | |
4238 struct gaim_gtk_conversation *gtkconv; | |
4681 | 4239 struct gaim_window *win; |
4240 struct gaim_gtk_window *gtkwin; | |
4241 | |
4242 win = gaim_conversation_get_window(conv); | |
4243 gtkwin = GAIM_GTK_WINDOW(win); | |
4359 | 4244 gtkconv = GAIM_GTK_CONVERSATION(conv); |
4245 | |
4246 gtk_label_set_text(GTK_LABEL(gtkconv->tab_label), title); | |
4681 | 4247 |
4248 if(conv == gaim_window_get_active_conversation(win)) | |
4249 gtk_window_set_title(GTK_WINDOW(gtkwin->window), title); | |
4359 | 4250 } |
4251 | |
4252 static void | |
4253 gaim_gtkconv_updated(struct gaim_conversation *conv, GaimConvUpdateType type) | |
4254 { | |
4255 struct gaim_window *win; | |
4736 | 4256 struct gaim_gtk_window *gtkwin; |
4359 | 4257 struct gaim_gtk_conversation *gtkconv; |
4258 struct gaim_gtk_chat_pane *gtkchat; | |
4259 struct gaim_chat *chat; | |
4260 | |
4261 win = gaim_conversation_get_window(conv); | |
4736 | 4262 gtkwin = GAIM_GTK_WINDOW(win); |
4359 | 4263 gtkconv = GAIM_GTK_CONVERSATION(conv); |
4264 | |
4491 | 4265 if (type == GAIM_CONV_UPDATE_ACCOUNT) { |
4359 | 4266 gaim_conversation_autoset_title(conv); |
4267 gaim_gtkconv_update_buddy_icon(conv); | |
4268 gaim_gtkconv_update_buttons_by_protocol(conv); | |
4269 | |
4685 | 4270 g_timeout_add(0, (GSourceFunc)update_send_as_selection, win); |
4359 | 4271 |
4272 smiley_themeize(gtkconv->imhtml); | |
4273 } | |
4274 else if (type == GAIM_CONV_UPDATE_TYPING || | |
4275 type == GAIM_CONV_UPDATE_UNSEEN) { | |
4276 GtkStyle *style; | |
4277 struct gaim_im *im = NULL; | |
4278 | |
4736 | 4279 |
4359 | 4280 if (gaim_conversation_get_type(conv) == GAIM_CONV_IM) |
4281 im = GAIM_IM(conv); | |
4282 | |
4283 style = gtk_style_new(); | |
4284 | |
4285 if (!GTK_WIDGET_REALIZED(gtkconv->tab_label)) | |
4286 gtk_widget_realize(gtkconv->tab_label); | |
4287 | |
4757 | 4288 pango_font_description_free(style->font_desc); |
4635 | 4289 style->font_desc = pango_font_description_copy( |
4290 gtk_widget_get_style(gtkconv->tab_label)->font_desc); | |
4359 | 4291 |
4292 if (im != NULL && gaim_im_get_typing_state(im) == TYPING) { | |
4577 | 4293 style->fg[GTK_STATE_NORMAL].red = 0x4646; |
4294 style->fg[GTK_STATE_NORMAL].green = 0xA0A0; | |
4295 style->fg[GTK_STATE_NORMAL].blue = 0x4646; | |
4296 style->fg[GTK_STATE_ACTIVE] = style->fg[GTK_STATE_NORMAL]; | |
4359 | 4297 } |
4298 else if (im != NULL && gaim_im_get_typing_state(im) == TYPED) { | |
4577 | 4299 style->fg[GTK_STATE_NORMAL].red = 0xD1D1; |
4300 style->fg[GTK_STATE_NORMAL].green = 0x9494; | |
4301 style->fg[GTK_STATE_NORMAL].blue = 0x0C0C; | |
4302 style->fg[GTK_STATE_ACTIVE] = style->fg[GTK_STATE_NORMAL]; | |
4359 | 4303 } |
4304 else if (gaim_conversation_get_unseen(conv) == GAIM_UNSEEN_NICK) { | |
4577 | 4305 style->fg[GTK_STATE_ACTIVE].red = 0x3131; |
4306 style->fg[GTK_STATE_ACTIVE].green = 0x4E4E; | |
4307 style->fg[GTK_STATE_ACTIVE].blue = 0x6C6C; | |
4578 | 4308 style->fg[GTK_STATE_NORMAL] = style->fg[GTK_STATE_ACTIVE]; |
4359 | 4309 } |
4310 else if (gaim_conversation_get_unseen(conv) == GAIM_UNSEEN_TEXT) { | |
4577 | 4311 style->fg[GTK_STATE_ACTIVE].red = 0xDFDF; |
4312 style->fg[GTK_STATE_ACTIVE].green = 0x4242; | |
4313 style->fg[GTK_STATE_ACTIVE].blue = 0x1E1E; | |
4578 | 4314 style->fg[GTK_STATE_NORMAL] = style->fg[GTK_STATE_ACTIVE]; |
4359 | 4315 } |
4316 | |
4317 gtk_widget_set_style(gtkconv->tab_label, style); | |
4635 | 4318 g_object_unref(G_OBJECT(style)); |
4736 | 4319 |
4320 if(type == GAIM_CONV_UPDATE_TYPING && | |
4321 conv == gaim_window_get_active_conversation(win)) { | |
4322 update_typing_icon(conv); | |
4323 } | |
4324 | |
4359 | 4325 } |
4326 else if (type == GAIM_CONV_UPDATE_TOPIC) { | |
4327 chat = GAIM_CHAT(conv); | |
4328 gtkchat = gtkconv->u.chat; | |
4329 | |
4330 gtk_entry_set_text(GTK_ENTRY(gtkchat->topic_text), | |
4331 gaim_chat_get_topic(chat)); | |
4332 } | |
4333 else if (type == GAIM_CONV_ACCOUNT_ONLINE || | |
4334 type == GAIM_CONV_ACCOUNT_OFFLINE) { | |
4335 | |
4360
c435a29370b8
[gaim-migrate @ 4626]
Christian Hammond <chipx86@chipx86.com>
parents:
4359
diff
changeset
|
4336 generate_send_as_items(win, NULL); |
4359 | 4337 } |
4397
ce3a0eba91ef
[gaim-migrate @ 4666]
Christian Hammond <chipx86@chipx86.com>
parents:
4387
diff
changeset
|
4338 else if(type == GAIM_CONV_UPDATE_ADD || |
ce3a0eba91ef
[gaim-migrate @ 4666]
Christian Hammond <chipx86@chipx86.com>
parents:
4387
diff
changeset
|
4339 type == GAIM_CONV_UPDATE_REMOVE) { |
4736 | 4340 |
4397
ce3a0eba91ef
[gaim-migrate @ 4666]
Christian Hammond <chipx86@chipx86.com>
parents:
4387
diff
changeset
|
4341 update_convo_add_button(conv); |
ce3a0eba91ef
[gaim-migrate @ 4666]
Christian Hammond <chipx86@chipx86.com>
parents:
4387
diff
changeset
|
4342 } |
4359 | 4343 } |
4344 | |
4465
6e37eb000b7a
[gaim-migrate @ 4740]
Christian Hammond <chipx86@chipx86.com>
parents:
4454
diff
changeset
|
4345 static struct gaim_conversation_ui_ops conversation_ui_ops = |
4359 | 4346 { |
4347 gaim_gtkconv_destroy, /* destroy_conversation */ | |
4348 gaim_gtkconv_write_chat, /* write_chat */ | |
4349 gaim_gtkconv_write_im, /* write_im */ | |
4350 gaim_gtkconv_write_conv, /* write_conv */ | |
4351 gaim_gtkconv_chat_add_user, /* chat_add_user */ | |
4352 gaim_gtkconv_chat_rename_user, /* chat_rename_user */ | |
4353 gaim_gtkconv_chat_remove_user, /* chat_remove_user */ | |
4354 gaim_gtkconv_set_title, /* set_title */ | |
4355 NULL, /* update_progress */ | |
4356 gaim_gtkconv_updated /* updated */ | |
4357 }; | |
4358 | |
4465
6e37eb000b7a
[gaim-migrate @ 4740]
Christian Hammond <chipx86@chipx86.com>
parents:
4454
diff
changeset
|
4359 struct gaim_conversation_ui_ops * |
6e37eb000b7a
[gaim-migrate @ 4740]
Christian Hammond <chipx86@chipx86.com>
parents:
4454
diff
changeset
|
4360 gaim_get_gtk_conversation_ui_ops(void) |
4359 | 4361 { |
4465
6e37eb000b7a
[gaim-migrate @ 4740]
Christian Hammond <chipx86@chipx86.com>
parents:
4454
diff
changeset
|
4362 return &conversation_ui_ops; |
4359 | 4363 } |
4364 | |
4365 /************************************************************************** | |
4366 * Public conversation utility functions | |
4367 **************************************************************************/ | |
4368 void | |
4369 gaim_gtkconv_toggle_smileys(void) | |
4370 { | |
4371 GList *cl; | |
4372 struct gaim_conversation *conv; | |
4373 struct gaim_gtk_conversation *gtkconv; | |
4374 | |
4375 for (cl = gaim_get_conversations(); cl != NULL; cl = cl->next) { | |
4376 | |
4377 conv = (struct gaim_conversation *)cl->data; | |
4378 | |
4398
a8249a5250b6
[gaim-migrate @ 4667]
Christian Hammond <chipx86@chipx86.com>
parents:
4397
diff
changeset
|
4379 if (!GAIM_IS_GTK_CONVERSATION(conv)) |
4359 | 4380 continue; |
4381 | |
4382 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
4383 | |
4384 gtk_imhtml_show_smileys(GTK_IMHTML(gtkconv->imhtml), | |
4385 (convo_options & OPT_CONVO_SHOW_SMILEY)); | |
4386 } | |
4387 } | |
4388 | |
4389 void | |
4390 gaim_gtkconv_toggle_timestamps(void) | |
4391 { | |
4392 GList *cl; | |
4393 struct gaim_conversation *conv; | |
4394 struct gaim_gtk_conversation *gtkconv; | |
4395 | |
4396 for (cl = gaim_get_conversations(); cl != NULL; cl = cl->next) { | |
4397 | |
4398 conv = (struct gaim_conversation *)cl->data; | |
4399 | |
4398
a8249a5250b6
[gaim-migrate @ 4667]
Christian Hammond <chipx86@chipx86.com>
parents:
4397
diff
changeset
|
4400 if (!GAIM_IS_GTK_CONVERSATION(conv)) |
4359 | 4401 continue; |
4402 | |
4403 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
4404 | |
4405 gtk_imhtml_show_comments(GTK_IMHTML(gtkconv->imhtml), | |
4406 (convo_options & OPT_CONVO_SHOW_TIME)); | |
4407 } | |
4408 } | |
4409 | |
4410 void | |
4411 gaim_gtkconv_toggle_spellchk(void) | |
4412 { | |
4413 #ifdef USE_GTKSPELL | |
4414 GList *cl; | |
4415 struct gaim_conversation *conv; | |
4416 struct gaim_gtk_conversation *gtkconv; | |
4417 GtkSpell *spell; | |
4418 | |
4419 for (cl = gaim_get_conversations(); cl != NULL; cl = cl->next) { | |
4420 | |
4421 conv = (struct gaim_conversation *)cl->data; | |
4422 | |
4398
a8249a5250b6
[gaim-migrate @ 4667]
Christian Hammond <chipx86@chipx86.com>
parents:
4397
diff
changeset
|
4423 if (!GAIM_IS_GTK_CONVERSATION(conv)) |
4359 | 4424 continue; |
4425 | |
4426 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
4427 | |
4428 if (convo_options & OPT_CONVO_CHECK_SPELLING) | |
4429 gtkspell_new_attach(GTK_TEXT_VIEW(gtkconv->entry), NULL, NULL); | |
4430 else { | |
4431 spell = gtkspell_get_from_text_view(GTK_TEXT_VIEW(gtkconv->entry)); | |
4432 gtkspell_detach(spell); | |
4433 } | |
4434 } | |
4435 #endif | |
4436 } | |
4437 | |
4445 | 4438 void |
4439 gaim_gtkconv_toggle_close_buttons(void) | |
4440 { | |
4441 GList *cl; | |
4442 struct gaim_conversation *conv; | |
4443 struct gaim_gtk_conversation *gtkconv; | |
4444 | |
4445 for (cl = gaim_get_conversations(); cl != NULL; cl = cl->next) { | |
4446 conv = (struct gaim_conversation *)cl->data; | |
4447 if (!GAIM_IS_GTK_CONVERSATION(conv)) | |
4448 continue; | |
4449 | |
4450 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
4451 | |
4452 if (convo_options & OPT_CONVO_NO_X_ON_TAB) | |
4453 gtk_widget_hide(gtkconv->close); | |
4454 else | |
4455 gtk_widget_show_all(gtkconv->close); | |
4456 } | |
4457 } | |
4458 | |
4359 | 4459 static void |
4460 remove_icon(struct gaim_gtk_conversation *gtkconv) | |
4461 { | |
4462 if (gtkconv == NULL) | |
4463 return; | |
4464 | |
4465 if (gtkconv->u.im->icon != NULL) | |
4466 gtk_container_remove(GTK_CONTAINER(gtkconv->bbox), | |
4467 gtkconv->u.im->icon->parent->parent); | |
4468 | |
4469 if (gtkconv->u.im->anim != NULL) | |
4470 gdk_pixbuf_animation_unref(gtkconv->u.im->anim); | |
4471 | |
4472 if (gtkconv->u.im->icon_timer != 0) | |
4473 g_source_remove(gtkconv->u.im->icon_timer); | |
4474 | |
4475 if (gtkconv->u.im->iter != NULL) | |
4476 g_object_unref(G_OBJECT(gtkconv->u.im->iter)); | |
4477 | |
4478 gtkconv->u.im->icon_timer = 0; | |
4479 gtkconv->u.im->icon = NULL; | |
4480 gtkconv->u.im->anim = NULL; | |
4481 gtkconv->u.im->iter = NULL; | |
4482 } | |
4483 | |
4484 static gboolean | |
4485 redraw_icon(gpointer data) | |
4486 { | |
4487 struct gaim_conversation *conv = (struct gaim_conversation *)data; | |
4488 struct gaim_gtk_conversation *gtkconv; | |
4489 | |
4490 GdkPixbuf *buf; | |
4491 GdkPixbuf *scale; | |
4492 GdkPixmap *pm; | |
4493 GdkBitmap *bm; | |
4494 gint delay; | |
4495 | |
4496 if (!g_list_find(gaim_get_ims(), conv)) { | |
4497 debug_printf("I think this is a bug.\n"); | |
4498 return FALSE; | |
4499 } | |
4500 | |
4501 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
4502 | |
4503 gdk_pixbuf_animation_iter_advance(gtkconv->u.im->iter, NULL); | |
4504 buf = gdk_pixbuf_animation_iter_get_pixbuf(gtkconv->u.im->iter); | |
4505 | |
4506 scale = gdk_pixbuf_scale_simple(buf, | |
4507 MAX(gdk_pixbuf_get_width(buf) * SCALE(gtkconv->u.im->anim) / | |
4508 gdk_pixbuf_animation_get_width(gtkconv->u.im->anim), 1), | |
4509 MAX(gdk_pixbuf_get_height(buf) * SCALE(gtkconv->u.im->anim) / | |
4510 gdk_pixbuf_animation_get_height(gtkconv->u.im->anim), 1), | |
4511 GDK_INTERP_NEAREST); | |
4512 | |
4513 gdk_pixbuf_render_pixmap_and_mask(scale, &pm, &bm, 100); | |
4514 gdk_pixbuf_unref(scale); | |
4635 | 4515 gtk_image_set_from_pixmap(GTK_IMAGE(gtkconv->u.im->icon), pm, bm); |
4359 | 4516 gdk_pixmap_unref(pm); |
4517 gtk_widget_queue_draw(gtkconv->u.im->icon); | |
4518 | |
4519 if (bm) | |
4520 gdk_bitmap_unref(bm); | |
4521 | |
4522 delay = gdk_pixbuf_animation_iter_get_delay_time(gtkconv->u.im->iter) / 10; | |
4523 | |
4524 gtkconv->u.im->icon_timer = g_timeout_add(delay * 10, redraw_icon, conv); | |
4525 | |
4526 return FALSE; | |
4527 } | |
4528 | |
4529 static void | |
4530 start_anim(GtkObject *obj, struct gaim_conversation *conv) | |
4531 { | |
4532 struct gaim_gtk_conversation *gtkconv; | |
4533 int delay; | |
4534 | |
4398
a8249a5250b6
[gaim-migrate @ 4667]
Christian Hammond <chipx86@chipx86.com>
parents:
4397
diff
changeset
|
4535 if (!GAIM_IS_GTK_CONVERSATION(conv)) |
4359 | 4536 return; |
4537 | |
4538 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
4539 | |
4540 delay = gdk_pixbuf_animation_iter_get_delay_time(gtkconv->u.im->iter) / 10; | |
4541 | |
4542 if (gtkconv->u.im->anim) | |
4543 gtkconv->u.im->icon_timer = g_timeout_add(delay * 10, redraw_icon, | |
4544 conv); | |
4545 } | |
4546 | |
4547 static void | |
4548 stop_anim(GtkObject *obj, struct gaim_conversation *conv) | |
4549 { | |
4550 struct gaim_gtk_conversation *gtkconv; | |
4551 | |
4398
a8249a5250b6
[gaim-migrate @ 4667]
Christian Hammond <chipx86@chipx86.com>
parents:
4397
diff
changeset
|
4552 if (!GAIM_IS_GTK_CONVERSATION(conv)) |
4359 | 4553 return; |
4554 | |
4555 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
4556 | |
4557 if (gtkconv->u.im->icon_timer != 0) | |
4558 g_source_remove(gtkconv->u.im->icon_timer); | |
4559 | |
4560 gtkconv->u.im->icon_timer = 0; | |
4561 } | |
4562 | |
4563 static gboolean | |
4564 icon_menu(GtkObject *obj, GdkEventButton *e, struct gaim_conversation *conv) | |
4565 { | |
4566 struct gaim_gtk_conversation *gtkconv; | |
4567 static GtkWidget *menu = NULL; | |
4568 GtkWidget *button; | |
4569 | |
4570 if (e->button != 3 || e->type != GDK_BUTTON_PRESS) | |
4571 return FALSE; | |
4572 | |
4573 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
4574 | |
4575 /* | |
4576 * If a menu already exists, destroy it before creating a new one, | |
4577 * thus freeing-up the memory it occupied. | |
4578 */ | |
4579 if (menu != NULL) | |
4580 gtk_widget_destroy(menu); | |
4581 | |
4582 menu = gtk_menu_new(); | |
4583 | |
4584 if (gtkconv->u.im->icon_timer) { | |
4585 button = gtk_menu_item_new_with_label(_("Disable Animation")); | |
4586 g_signal_connect(GTK_OBJECT(button), "activate", | |
4587 G_CALLBACK(stop_anim), conv); | |
4588 gtk_menu_shell_append(GTK_MENU_SHELL(menu), button); | |
4589 gtk_widget_show(button); | |
4590 } | |
4591 else if (gtkconv->u.im->anim && | |
4592 !(gdk_pixbuf_animation_is_static_image(gtkconv->u.im->anim))) | |
4593 { | |
4594 button = gtk_menu_item_new_with_label(_("Enable Animation")); | |
4595 g_signal_connect(GTK_OBJECT(button), "activate", | |
4596 G_CALLBACK(start_anim), conv); | |
4597 gtk_menu_shell_append(GTK_MENU_SHELL(menu), button); | |
4598 gtk_widget_show(button); | |
4599 } | |
4600 | |
4601 button = gtk_menu_item_new_with_label(_("Hide Icon")); | |
4602 g_signal_connect_swapped(GTK_OBJECT(button), "activate", | |
4515
9b9737a00a96
[gaim-migrate @ 4793]
Christian Hammond <chipx86@chipx86.com>
parents:
4513
diff
changeset
|
4603 G_CALLBACK(remove_icon), gtkconv); |
4359 | 4604 gtk_menu_shell_append(GTK_MENU_SHELL(menu), button); |
4605 gtk_widget_show(button); | |
4606 | |
4607 button = gtk_menu_item_new_with_label(_("Save Icon As...")); | |
4608 g_signal_connect(GTK_OBJECT(button), "activate", | |
4609 G_CALLBACK(gaim_gtk_save_icon_dialog), conv); | |
4610 gtk_menu_shell_append(GTK_MENU_SHELL(menu), button); | |
4611 gtk_widget_show(button); | |
4612 | |
4613 gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL, e->button, e->time); | |
4614 | |
4615 return TRUE; | |
4616 } | |
4617 | |
4618 void | |
4619 gaim_gtkconv_update_buddy_icon(struct gaim_conversation *conv) | |
4620 { | |
4621 struct gaim_gtk_conversation *gtkconv; | |
4622 | |
4623 char filename[256]; | |
4624 FILE *file; | |
4625 GError *err = NULL; | |
4626 | |
4757 | 4627 struct buddy *buddy; |
4628 | |
4359 | 4629 void *data; |
4630 int len, delay; | |
4631 | |
4632 GdkPixbuf *buf; | |
4633 | |
4634 GtkWidget *event; | |
4635 GtkWidget *frame; | |
4636 GdkPixbuf *scale; | |
4637 GdkPixmap *pm; | |
4638 GdkBitmap *bm; | |
4639 int sf = 0; | |
4640 | |
4398
a8249a5250b6
[gaim-migrate @ 4667]
Christian Hammond <chipx86@chipx86.com>
parents:
4397
diff
changeset
|
4641 if (conv == NULL || !GAIM_IS_GTK_CONVERSATION(conv) || |
4359 | 4642 gaim_conversation_get_type(conv) != GAIM_CONV_IM) { |
4643 | |
4644 return; | |
4645 } | |
4646 | |
4647 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
4648 | |
4649 remove_icon(gtkconv); | |
4650 | |
4651 if (im_options & OPT_IM_HIDE_ICONS) | |
4652 return; | |
4653 | |
4654 if (gaim_conversation_get_gc(conv) == NULL) | |
4655 return; | |
4656 | |
4757 | 4657 if((buddy = gaim_find_buddy(gaim_conversation_get_account(conv), |
4658 gaim_conversation_get_name(conv))) != NULL) { | |
4659 char *file = gaim_buddy_get_setting(buddy, "buddy_icon"); | |
4660 if(file) { | |
4661 gtkconv->u.im->anim = gdk_pixbuf_animation_new_from_file(file, &err); | |
4662 g_free(file); | |
4663 } | |
4664 } else { | |
4665 data = get_icon_data(gaim_conversation_get_gc(conv), | |
4666 normalize(gaim_conversation_get_name(conv)), | |
4667 &len); | |
4668 | |
4669 if (!data) | |
4670 return; | |
4671 | |
4672 /* this is such an evil hack, i don't know why i'm even considering it. | |
4673 * we'll do it differently when gdk-pixbuf-loader isn't leaky anymore. */ | |
4674 g_snprintf(filename, sizeof(filename), | |
4675 "%s" G_DIR_SEPARATOR_S "gaimicon-%s.%d", | |
4676 g_get_tmp_dir(), gaim_conversation_get_name(conv), getpid()); | |
4677 | |
4678 if (!(file = fopen(filename, "wb"))) | |
4679 return; | |
4680 | |
4681 fwrite(data, 1, len, file); | |
4682 fclose(file); | |
4683 | |
4684 gtkconv->u.im->anim = gdk_pixbuf_animation_new_from_file(filename, &err); | |
4685 /* make sure we remove the file as soon as possible */ | |
4686 unlink(filename); | |
4687 } | |
4359 | 4688 |
4689 if (err) { | |
4690 debug_printf("Buddy icon error: %s\n", err->message); | |
4691 g_error_free(err); | |
4692 } | |
4693 | |
4694 | |
4695 if (!gtkconv->u.im->anim) | |
4696 return; | |
4697 | |
4698 if (gdk_pixbuf_animation_is_static_image(gtkconv->u.im->anim)) { | |
4699 gtkconv->u.im->iter = NULL; | |
4700 delay = 0; | |
4701 buf = gdk_pixbuf_animation_get_static_image(gtkconv->u.im->anim); | |
4702 } else { | |
4703 gtkconv->u.im->iter = | |
4704 gdk_pixbuf_animation_get_iter(gtkconv->u.im->anim, NULL); | |
4705 buf = gdk_pixbuf_animation_iter_get_pixbuf(gtkconv->u.im->iter); | |
4706 delay = gdk_pixbuf_animation_iter_get_delay_time(gtkconv->u.im->iter); | |
4707 delay = delay / 10; | |
4708 } | |
4709 | |
4710 sf = SCALE(gtkconv->u.im->anim); | |
4711 scale = gdk_pixbuf_scale_simple(buf, | |
4712 MAX(gdk_pixbuf_get_width(buf) * sf / | |
4713 gdk_pixbuf_animation_get_width(gtkconv->u.im->anim), 1), | |
4714 MAX(gdk_pixbuf_get_height(buf) * sf / | |
4715 gdk_pixbuf_animation_get_height(gtkconv->u.im->anim), 1), | |
4716 GDK_INTERP_NEAREST); | |
4717 | |
4718 if (delay) | |
4719 gtkconv->u.im->icon_timer = g_timeout_add(delay * 10, redraw_icon, | |
4720 conv); | |
4721 | |
4722 gdk_pixbuf_render_pixmap_and_mask(scale, &pm, &bm, 100); | |
4723 gdk_pixbuf_unref(scale); | |
4724 | |
4725 frame = gtk_frame_new(NULL); | |
4726 gtk_frame_set_shadow_type(GTK_FRAME(frame), | |
4727 (bm ? GTK_SHADOW_NONE : GTK_SHADOW_IN)); | |
4728 gtk_box_pack_start(GTK_BOX(gtkconv->bbox), frame, FALSE, FALSE, 5); | |
4729 gtk_box_reorder_child(GTK_BOX(gtkconv->bbox), frame, 0); | |
4730 gtk_widget_show(frame); | |
4731 | |
4732 event = gtk_event_box_new(); | |
4733 gtk_container_add(GTK_CONTAINER(frame), event); | |
4734 g_signal_connect(GTK_OBJECT(event), "button-press-event", | |
4735 G_CALLBACK(icon_menu), conv); | |
4736 gtk_widget_show(event); | |
4737 | |
4635 | 4738 gtkconv->u.im->icon = gtk_image_new_from_pixmap(pm, bm); |
4359 | 4739 gtk_widget_set_size_request(gtkconv->u.im->icon, sf, sf); |
4740 gtk_container_add(GTK_CONTAINER(event), gtkconv->u.im->icon); | |
4741 gtk_widget_show(gtkconv->u.im->icon); | |
4742 | |
4743 if(im_options & OPT_IM_NO_ANIMATION) | |
4744 stop_anim(NULL, conv); | |
4745 | |
4746 gdk_pixmap_unref(pm); | |
4747 | |
4748 if (bm) | |
4749 gdk_bitmap_unref(bm); | |
4750 } | |
4751 | |
4752 void | |
4753 gaim_gtkconv_hide_buddy_icons(void) | |
4754 { | |
4755 gaim_conversation_foreach(gaim_gtkconv_update_buddy_icon); | |
4756 } | |
4757 | |
4758 void | |
4759 gaim_gtkconv_set_anim(void) | |
4760 { | |
4761 GList *l; | |
4762 | |
4763 if (im_options & OPT_IM_HIDE_ICONS) | |
4764 return; | |
4765 | |
4766 if (im_options & OPT_IM_NO_ANIMATION) { | |
4767 for (l = gaim_get_ims(); l != NULL; l = l->next) | |
4768 stop_anim(NULL, (struct gaim_conversation *)l->data); | |
4769 } else { | |
4770 for (l = gaim_get_ims(); l != NULL; l = l->next) | |
4771 start_anim(NULL, (struct gaim_conversation *)l->data); | |
4772 } | |
4773 } | |
4774 | |
4775 void | |
4776 gaim_gtkconv_update_font_buttons(void) | |
4777 { | |
4778 GList *l; | |
4779 struct gaim_conversation *conv; | |
4780 struct gaim_gtk_conversation *gtkconv; | |
4781 | |
4782 for (l = gaim_get_ims(); l != NULL; l = l->next) { | |
4783 conv = (struct gaim_conversation *)l->data; | |
4784 | |
4398
a8249a5250b6
[gaim-migrate @ 4667]
Christian Hammond <chipx86@chipx86.com>
parents:
4397
diff
changeset
|
4785 if (!GAIM_IS_GTK_CONVERSATION(conv)) |
4359 | 4786 continue; |
4787 | |
4788 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
4789 | |
4790 if (gtkconv->toolbar.bold != NULL) | |
4791 gtk_widget_set_sensitive(gtkconv->toolbar.bold, | |
4792 (!(font_options & OPT_FONT_BOLD))); | |
4793 | |
4794 if (gtkconv->toolbar.italic != NULL) | |
4795 gtk_widget_set_sensitive(gtkconv->toolbar.italic, | |
4796 (!(font_options & OPT_FONT_ITALIC))); | |
4797 | |
4798 if (gtkconv->toolbar.underline != NULL) | |
4799 gtk_widget_set_sensitive(gtkconv->toolbar.underline, | |
4800 (!(font_options & OPT_FONT_UNDERLINE))); | |
4801 } | |
4802 } | |
4803 | |
4804 void | |
4421 | 4805 gaim_gtkconv_update_font_colors(struct gaim_conversation *conv) |
4806 { | |
4438
2054d8429925
[gaim-migrate @ 4713]
Christian Hammond <chipx86@chipx86.com>
parents:
4421
diff
changeset
|
4807 struct gaim_gtk_conversation *gtkconv; |
2054d8429925
[gaim-migrate @ 4713]
Christian Hammond <chipx86@chipx86.com>
parents:
4421
diff
changeset
|
4808 |
2054d8429925
[gaim-migrate @ 4713]
Christian Hammond <chipx86@chipx86.com>
parents:
4421
diff
changeset
|
4809 if (!GAIM_IS_GTK_CONVERSATION(conv)) |
2054d8429925
[gaim-migrate @ 4713]
Christian Hammond <chipx86@chipx86.com>
parents:
4421
diff
changeset
|
4810 return; |
2054d8429925
[gaim-migrate @ 4713]
Christian Hammond <chipx86@chipx86.com>
parents:
4421
diff
changeset
|
4811 |
2054d8429925
[gaim-migrate @ 4713]
Christian Hammond <chipx86@chipx86.com>
parents:
4421
diff
changeset
|
4812 gtkconv = GAIM_GTK_CONVERSATION(conv); |
4421 | 4813 |
4438
2054d8429925
[gaim-migrate @ 4713]
Christian Hammond <chipx86@chipx86.com>
parents:
4421
diff
changeset
|
4814 gtkconv->fg_color.red = fgcolor.red; |
2054d8429925
[gaim-migrate @ 4713]
Christian Hammond <chipx86@chipx86.com>
parents:
4421
diff
changeset
|
4815 gtkconv->fg_color.blue = fgcolor.blue; |
2054d8429925
[gaim-migrate @ 4713]
Christian Hammond <chipx86@chipx86.com>
parents:
4421
diff
changeset
|
4816 gtkconv->fg_color.green = fgcolor.green; |
2054d8429925
[gaim-migrate @ 4713]
Christian Hammond <chipx86@chipx86.com>
parents:
4421
diff
changeset
|
4817 |
2054d8429925
[gaim-migrate @ 4713]
Christian Hammond <chipx86@chipx86.com>
parents:
4421
diff
changeset
|
4818 gtkconv->bg_color.red = bgcolor.red; |
2054d8429925
[gaim-migrate @ 4713]
Christian Hammond <chipx86@chipx86.com>
parents:
4421
diff
changeset
|
4819 gtkconv->bg_color.blue = bgcolor.blue; |
2054d8429925
[gaim-migrate @ 4713]
Christian Hammond <chipx86@chipx86.com>
parents:
4421
diff
changeset
|
4820 gtkconv->bg_color.green = bgcolor.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 |
2054d8429925
[gaim-migrate @ 4713]
Christian Hammond <chipx86@chipx86.com>
parents:
4421
diff
changeset
|
4823 void |
2054d8429925
[gaim-migrate @ 4713]
Christian Hammond <chipx86@chipx86.com>
parents:
4421
diff
changeset
|
4824 gaim_gtkconv_update_font_face(struct gaim_conversation *conv) |
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 struct gaim_gtk_conversation *gtkconv; |
2054d8429925
[gaim-migrate @ 4713]
Christian Hammond <chipx86@chipx86.com>
parents:
4421
diff
changeset
|
4827 |
2054d8429925
[gaim-migrate @ 4713]
Christian Hammond <chipx86@chipx86.com>
parents:
4421
diff
changeset
|
4828 if (!GAIM_IS_GTK_CONVERSATION(conv)) |
2054d8429925
[gaim-migrate @ 4713]
Christian Hammond <chipx86@chipx86.com>
parents:
4421
diff
changeset
|
4829 return; |
2054d8429925
[gaim-migrate @ 4713]
Christian Hammond <chipx86@chipx86.com>
parents:
4421
diff
changeset
|
4830 |
2054d8429925
[gaim-migrate @ 4713]
Christian Hammond <chipx86@chipx86.com>
parents:
4421
diff
changeset
|
4831 gtkconv = GAIM_GTK_CONVERSATION(conv); |
2054d8429925
[gaim-migrate @ 4713]
Christian Hammond <chipx86@chipx86.com>
parents:
4421
diff
changeset
|
4832 |
2054d8429925
[gaim-migrate @ 4713]
Christian Hammond <chipx86@chipx86.com>
parents:
4421
diff
changeset
|
4833 strncpy(gtkconv->fontface, fontface, 128); |
4421 | 4834 } |
4835 | |
4836 void | |
4359 | 4837 gaim_gtkconv_update_tabs(void) |
4838 { | |
4839 GList *l; | |
4840 GtkPositionType pos; | |
4841 struct gaim_window *win; | |
4842 struct gaim_gtk_window *gtkwin; | |
4843 | |
4844 pos = ((im_options & OPT_IM_SIDE_TAB) | |
4845 ? ((im_options & OPT_IM_BR_TAB) ? GTK_POS_RIGHT : GTK_POS_LEFT) | |
4846 : ((im_options & OPT_IM_BR_TAB) ? GTK_POS_BOTTOM : GTK_POS_TOP)); | |
4847 | |
4848 for (l = gaim_get_windows(); l != NULL; l = l->next) { | |
4849 win = (struct gaim_window *)l->data; | |
4850 | |
4398
a8249a5250b6
[gaim-migrate @ 4667]
Christian Hammond <chipx86@chipx86.com>
parents:
4397
diff
changeset
|
4851 if (!GAIM_IS_GTK_WINDOW(win)) |
4359 | 4852 continue; |
4853 | |
4854 gtkwin = GAIM_GTK_WINDOW(win); | |
4855 | |
4856 gtk_notebook_set_tab_pos(GTK_NOTEBOOK(gtkwin->notebook), pos); | |
4857 } | |
4858 } | |
4859 | |
4860 void | |
4861 gaim_gtkconv_update_chat_button_style() | |
4862 { | |
4863 GSList *l; | |
4864 struct gaim_connection *g; | |
4865 GtkWidget *parent; | |
4866 GaimConversationType type = GAIM_CONV_CHAT; | |
4867 | |
4868 for (l = connections; l != NULL; l = l->next) { | |
4869 GSList *bcs; | |
4870 struct gaim_conversation *conv; | |
4871 struct gaim_gtk_conversation *gtkconv; | |
4872 struct gaim_gtk_window *gtkwin; | |
4873 | |
4874 g = (struct gaim_connection *)l->data; | |
4875 | |
4876 for (bcs = g->buddy_chats; bcs != NULL; bcs = bcs->next) { | |
4877 conv = (struct gaim_conversation *)bcs->data; | |
4878 | |
4879 if (gaim_conversation_get_type(conv) != GAIM_CONV_CHAT) | |
4880 continue; | |
4881 | |
4398
a8249a5250b6
[gaim-migrate @ 4667]
Christian Hammond <chipx86@chipx86.com>
parents:
4397
diff
changeset
|
4882 if (!GAIM_IS_GTK_CONVERSATION(conv)) |
4359 | 4883 continue; |
4884 | |
4885 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
4886 gtkwin = GAIM_GTK_WINDOW(gaim_conversation_get_window(conv)); | |
4887 parent = gtk_widget_get_parent(gtkconv->send); | |
4888 | |
4889 gtkconv->send = | |
4890 gaim_gtk_change_text(_("Send"), | |
4891 gtkconv->send, GAIM_STOCK_SEND, type); | |
4892 gtkconv->u.chat->invite = | |
4893 gaim_gtk_change_text(_("Invite"), | |
4894 gtkconv->u.chat->invite, | |
4895 GAIM_STOCK_INVITE, type); | |
4896 | |
4897 gtk_box_pack_end(GTK_BOX(parent), gtkconv->send, FALSE, FALSE, | |
4898 type); | |
4899 gtk_box_pack_end(GTK_BOX(parent), gtkconv->u.chat->invite, | |
4900 FALSE, FALSE, 0); | |
4901 | |
4902 g_signal_connect(G_OBJECT(gtkconv->send), "clicked", | |
4903 G_CALLBACK(send_cb), conv); | |
4904 g_signal_connect(G_OBJECT(gtkconv->u.chat->invite), "clicked", | |
4905 G_CALLBACK(invite_cb), conv); | |
4906 | |
4907 gtk_button_set_relief(GTK_BUTTON(gtkconv->send), | |
4908 GTK_RELIEF_NONE); | |
4909 gtk_button_set_relief(GTK_BUTTON(gtkconv->u.chat->invite), | |
4910 GTK_RELIEF_NONE); | |
4911 | |
4912 gaim_gtkconv_update_buttons_by_protocol(conv); | |
4913 } | |
4914 } | |
4915 } | |
4916 | |
4917 void | |
4918 gaim_gtkconv_update_im_button_style() | |
4919 { | |
4920 GList *l; | |
4921 struct gaim_conversation *conv; | |
4922 struct gaim_gtk_conversation *gtkconv; | |
4923 | |
4924 for (l = gaim_get_ims(); l != NULL; l = l->next) { | |
4925 conv = (struct gaim_conversation *)l->data; | |
4926 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
4927 | |
4928 setup_im_buttons(conv, gtk_widget_get_parent(gtkconv->send)); | |
4929 } | |
4930 } | |
4931 | |
4932 void | |
4933 gaim_gtkconv_update_buttons_by_protocol(struct gaim_conversation *conv) | |
4934 { | |
4935 struct gaim_window *win; | |
4936 struct gaim_gtk_window *gtkwin = NULL; | |
4937 struct gaim_gtk_conversation *gtkconv; | |
4938 struct gaim_connection *gc; | |
4939 | |
4398
a8249a5250b6
[gaim-migrate @ 4667]
Christian Hammond <chipx86@chipx86.com>
parents:
4397
diff
changeset
|
4940 if (!GAIM_IS_GTK_CONVERSATION(conv)) |
4359 | 4941 return; |
4942 | |
4943 gc = gaim_conversation_get_gc(conv); | |
4944 win = gaim_conversation_get_window(conv); | |
4945 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
4946 | |
4947 if (win != NULL) | |
4948 gtkwin = GAIM_GTK_WINDOW(win); | |
4949 | |
4950 if (gc == NULL) { | |
4951 gtk_widget_set_sensitive(gtkconv->send, FALSE); | |
4952 | |
4365
6e96ced6fb78
[gaim-migrate @ 4631]
Christian Hammond <chipx86@chipx86.com>
parents:
4364
diff
changeset
|
4953 if (win != NULL && gaim_window_get_active_conversation(win) == conv) { |
4359 | 4954 gtk_widget_set_sensitive(gtkwin->menu.insert_link, FALSE); |
4955 } | |
4956 } | |
4364
fa56829b9587
[gaim-migrate @ 4630]
Christian Hammond <chipx86@chipx86.com>
parents:
4363
diff
changeset
|
4957 else { |
4674 | 4958 gtk_widget_set_sensitive(gtkconv->send, TRUE); |
4365
6e96ced6fb78
[gaim-migrate @ 4631]
Christian Hammond <chipx86@chipx86.com>
parents:
4364
diff
changeset
|
4959 if (win != NULL) { |
6e96ced6fb78
[gaim-migrate @ 4631]
Christian Hammond <chipx86@chipx86.com>
parents:
4364
diff
changeset
|
4960 gtk_widget_set_sensitive(gtkwin->menu.insert_link, TRUE); |
6e96ced6fb78
[gaim-migrate @ 4631]
Christian Hammond <chipx86@chipx86.com>
parents:
4364
diff
changeset
|
4961 } |
4364
fa56829b9587
[gaim-migrate @ 4630]
Christian Hammond <chipx86@chipx86.com>
parents:
4363
diff
changeset
|
4962 } |
4359 | 4963 |
4964 if (gaim_conversation_get_type(conv) == GAIM_CONV_IM) { | |
4965 if (gc == NULL) { | |
4966 gtk_widget_set_sensitive(gtkconv->info, FALSE); | |
4967 gtk_widget_set_sensitive(gtkconv->u.im->warn, FALSE); | |
4968 gtk_widget_set_sensitive(gtkconv->u.im->block, FALSE); | |
4969 gtk_widget_set_sensitive(gtkconv->u.im->add, FALSE); | |
4970 | |
4971 if (win != NULL && | |
4972 gaim_window_get_active_conversation(win) == conv) { | |
4973 | |
4974 gtk_widget_set_sensitive(gtkwin->menu.insert_image, FALSE); | |
4975 } | |
4976 | |
4977 return; | |
4978 } | |
4979 | |
4980 gtk_widget_set_sensitive(gtkconv->info, | |
4981 (gc->prpl->get_info != NULL)); | |
4982 | |
4983 gtk_widget_set_sensitive(gtkconv->toolbar.image, | |
4984 (gc->prpl->options & OPT_PROTO_IM_IMAGE)); | |
4985 | |
4986 if (win != NULL && gaim_window_get_active_conversation(win) == conv) { | |
4987 gtk_widget_set_sensitive(gtkwin->menu.insert_image, | |
4988 (gc->prpl->options & OPT_PROTO_IM_IMAGE)); | |
4989 } | |
4990 | |
4991 gtk_widget_set_sensitive(gtkconv->u.im->warn, | |
4992 (gc->prpl->warn != NULL)); | |
4993 | |
4994 gtk_widget_set_sensitive(gtkconv->u.im->block, | |
4995 (gc->prpl->add_permit != NULL)); | |
4996 | |
4997 update_convo_add_button(conv); | |
4998 } | |
4999 else if (gaim_conversation_get_type(conv) == GAIM_CONV_CHAT) { | |
5000 if (gc == NULL) { | |
5001 gtk_widget_set_sensitive(gtkconv->u.chat->whisper, FALSE); | |
5002 gtk_widget_set_sensitive(gtkconv->u.chat->invite, FALSE); | |
5003 | |
5004 return; | |
5005 } | |
5006 | |
5007 gtk_widget_set_sensitive(gtkconv->send, (gc->prpl->chat_send != NULL)); | |
5008 | |
5009 gtk_widget_set_sensitive(gtkconv->toolbar.image, FALSE); | |
5010 /* gtk_widget_set_sensitive(gtkwin->menu.insert_image, FALSE); */ | |
5011 | |
5012 gtk_widget_set_sensitive(gtkconv->u.chat->whisper, | |
5013 (gc->prpl->chat_whisper != NULL)); | |
5014 | |
5015 gtk_widget_set_sensitive(gtkconv->u.chat->invite, | |
5016 (gc->prpl->chat_invite != NULL)); | |
5017 } | |
5018 } | |
5019 | |
5020 struct gaim_window * | |
5021 gaim_gtkwin_get_at_xy(int x, int y) | |
5022 { | |
5023 struct gaim_window *win = NULL; | |
5024 struct gaim_gtk_window *gtkwin; | |
5025 GdkWindow *gdkwin; | |
5026 GList *l; | |
5027 | |
5028 gdkwin = gdk_window_at_pointer(&x, &y); | |
5029 | |
5030 if (gdkwin) | |
5031 gdkwin = gdk_window_get_toplevel(gdkwin); | |
5032 | |
5033 for (l = gaim_get_windows(); l != NULL; l = l->next) { | |
5034 win = (struct gaim_window *)l->data; | |
5035 | |
4398
a8249a5250b6
[gaim-migrate @ 4667]
Christian Hammond <chipx86@chipx86.com>
parents:
4397
diff
changeset
|
5036 if (!GAIM_IS_GTK_WINDOW(win)) |
4359 | 5037 continue; |
5038 | |
5039 gtkwin = GAIM_GTK_WINDOW(win); | |
5040 | |
5041 if (gdkwin == gtkwin->window->window) | |
5042 return win; | |
5043 } | |
5044 | |
5045 return NULL; | |
5046 } | |
5047 | |
5048 int | |
5049 gaim_gtkconv_get_tab_at_xy(struct gaim_window *win, int x, int y) | |
5050 { | |
5051 struct gaim_gtk_window *gtkwin; | |
5052 GList *l; | |
5053 gint nb_x, nb_y, x_rel, y_rel; | |
5054 GtkNotebook *notebook; | |
5055 GtkWidget *tab; | |
5056 gint i, page_num = 0; | |
5057 gboolean first_visible = TRUE; | |
5058 | |
4398
a8249a5250b6
[gaim-migrate @ 4667]
Christian Hammond <chipx86@chipx86.com>
parents:
4397
diff
changeset
|
5059 if (!GAIM_IS_GTK_WINDOW(win)) |
4359 | 5060 return -1; |
5061 | |
5062 gtkwin = GAIM_GTK_WINDOW(win); | |
5063 notebook = GTK_NOTEBOOK(gtkwin->notebook); | |
5064 | |
5065 gdk_window_get_origin(gtkwin->notebook->window, &nb_x, &nb_y); | |
5066 x_rel = x - nb_x; | |
5067 y_rel = y - nb_y; | |
5068 | |
5069 for (l = gaim_window_get_conversations(win), i = 0; | |
5070 l != NULL; | |
5071 l = l->next, i++) { | |
5072 | |
5073 struct gaim_conversation *conv = l->data; | |
5074 tab = GAIM_GTK_CONVERSATION(conv)->tab_label; | |
5075 | |
5076 if (!GTK_WIDGET_MAPPED(tab)) | |
5077 continue; | |
5078 | |
5079 if (first_visible) { | |
5080 first_visible = FALSE; | |
5081 | |
5082 if (x_rel < tab->allocation.x) x_rel = tab->allocation.x; | |
5083 if (y_rel < tab->allocation.y) y_rel = tab->allocation.y; | |
5084 } | |
5085 | |
5086 if (gtk_notebook_get_tab_pos(notebook) == GTK_POS_TOP || | |
5087 gtk_notebook_get_tab_pos(notebook) == GTK_POS_BOTTOM) { | |
5088 | |
5089 if (tab->allocation.x <= x_rel) { | |
5090 if (tab->allocation.x + tab->allocation.width <= x_rel) | |
5091 page_num = i + 1; | |
5092 else | |
5093 page_num = i; | |
5094 } | |
5095 else | |
5096 break; | |
5097 } | |
5098 else { | |
5099 if (tab->allocation.y <= y_rel) { | |
5100 if (tab->allocation.y + tab->allocation.height <= y_rel) | |
5101 page_num = i + 1; | |
5102 else | |
5103 page_num = i; | |
5104 } | |
5105 else | |
5106 break; | |
5107 } | |
5108 } | |
5109 | |
5110 if (i == gaim_window_get_conversation_count(win) + 1) | |
5111 return -1; | |
5112 | |
5113 return page_num; | |
5114 } | |
5115 | |
5116 int | |
5117 gaim_gtkconv_get_dest_tab_at_xy(struct gaim_window *win, int x, int y) | |
5118 { | |
5119 struct gaim_gtk_window *gtkwin; | |
5120 GList *l; | |
5121 gint nb_x, nb_y, x_rel, y_rel; | |
5122 GtkNotebook *notebook; | |
5123 GtkWidget *tab; | |
5124 gint i, page_num = 0; | |
5125 | |
4398
a8249a5250b6
[gaim-migrate @ 4667]
Christian Hammond <chipx86@chipx86.com>
parents:
4397
diff
changeset
|
5126 if (!GAIM_IS_GTK_WINDOW(win)) |
4359 | 5127 return -1; |
5128 | |
5129 gtkwin = GAIM_GTK_WINDOW(win); | |
5130 notebook = GTK_NOTEBOOK(gtkwin->notebook); | |
5131 | |
5132 gdk_window_get_origin(gtkwin->notebook->window, &nb_x, &nb_y); | |
5133 x_rel = x - nb_x; | |
5134 y_rel = y - nb_y; | |
5135 | |
5136 for (l = gaim_window_get_conversations(win), i = 0; | |
5137 l != NULL; | |
5138 l = l->next, i++) { | |
5139 | |
5140 struct gaim_conversation *conv = l->data; | |
5141 tab = GAIM_GTK_CONVERSATION(conv)->tab_label; | |
5142 | |
5143 if (!GTK_WIDGET_MAPPED(tab)) | |
5144 continue; | |
5145 | |
5146 if (gtk_notebook_get_tab_pos(notebook) == GTK_POS_TOP || | |
5147 gtk_notebook_get_tab_pos(notebook) == GTK_POS_BOTTOM) { | |
5148 | |
5149 if (tab->allocation.x <= x_rel) { | |
5150 if (tab->allocation.x + (tab->allocation.width / 2) <= x_rel) | |
5151 page_num = i + 1; | |
5152 else | |
5153 page_num = i; | |
5154 } | |
5155 else | |
5156 break; | |
5157 } | |
5158 else { | |
5159 if (tab->allocation.y <= y_rel) { | |
5160 if (tab->allocation.y + (tab->allocation.height / 2) <= y_rel) | |
5161 page_num = i + 1; | |
5162 else | |
5163 page_num = i; | |
5164 } | |
5165 else | |
5166 break; | |
5167 } | |
5168 } | |
5169 | |
5170 if (i == gaim_window_get_conversation_count(win) + 1) | |
5171 return -1; | |
5172 | |
5173 return page_num; | |
5174 } |