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