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