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