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