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