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