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