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