Mercurial > pidgin
annotate src/gtkconv.c @ 5152:e637e36ee45c
[gaim-migrate @ 5516]
...and the last of the cleaning out of this tree, I figured we should actually
keep the ChangeLog quasi up-to-date like we claimed we were going to
committer: Tailor Script <tailor@pidgin.im>
author | Nathan Walp <nwalp@pidgin.im> |
---|---|
date | Thu, 17 Apr 2003 23:43:34 +0000 |
parents | 8c71c0727a1c |
children | f55f87a82311 |
rev | line source |
---|---|
4359 | 1 /* |
2 * gaim | |
3 * | |
4 * Copyright (C) 2002-2003, Christian Hammond <chipx86@gnupdate.org> | |
5 * | |
6 * This program is free software; you can redistribute it and/or modify | |
7 * it under the terms of the GNU General Public License as published by | |
8 * the Free Software Foundation; either version 2 of the License, or | |
9 * (at your option) any later version. | |
10 * | |
11 * This program is distributed in the hope that it will be useful, | |
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
14 * GNU General Public License for more details. | |
15 * | |
16 * You should have received a copy of the GNU General Public License | |
17 * along with this program; if not, write to the Free Software | |
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
19 * | |
20 */ | |
21 #ifdef HAVE_CONFIG_H | |
22 #include <config.h> | |
23 #endif | |
24 #include <string.h> | |
25 #ifndef _WIN32 | |
26 #include <sys/time.h> | |
27 #include <unistd.h> | |
28 #include <gdk/gdkx.h> | |
29 #include <X11/Xlib.h> | |
30 #endif /*_WIN32*/ | |
31 #include <sys/types.h> | |
32 #include <sys/stat.h> | |
33 #include <stdio.h> | |
34 #include <stdlib.h> | |
35 #include <errno.h> | |
36 #include <ctype.h> | |
37 #include <gtk/gtk.h> | |
38 #ifdef USE_GTKSPELL | |
39 #include <gtkspell/gtkspell.h> | |
40 #endif | |
41 #include "gtkimhtml.h" | |
42 #include <gdk/gdkkeysyms.h> | |
43 #include "prpl.h" | |
44 #include "gtkimhtml.h" | |
45 #include "dnd-hints.h" | |
4561 | 46 #include "sound.h" |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
47 #include "gtklist.h" |
4359 | 48 |
4373
dcc6c130c6d9
[gaim-migrate @ 4639]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4370
diff
changeset
|
49 #ifdef _WIN32 |
dcc6c130c6d9
[gaim-migrate @ 4639]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4370
diff
changeset
|
50 #include "win32dep.h" |
4859
a9a831508b43
[gaim-migrate @ 5186]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4851
diff
changeset
|
51 #include "wspell.h" |
4373
dcc6c130c6d9
[gaim-migrate @ 4639]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4370
diff
changeset
|
52 #endif |
dcc6c130c6d9
[gaim-migrate @ 4639]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
4370
diff
changeset
|
53 |
4359 | 54 static char nick_colors[][8] = { |
55 "#ba55d3", /* Medium Orchid */ | |
56 "#ee82ee", /* Violet */ | |
57 "#c715b4", /* Medium Violet Red */ | |
58 "#ff69b4", /* Hot Pink */ | |
59 "#ff6347", /* Tomato */ | |
60 "#fa8c00", /* Dark Orange */ | |
61 "#fa8072", /* Salmon */ | |
62 "#b22222", /* Fire Brick */ | |
63 "#f4a460", /* Sandy Brown */ | |
64 "#cd5c5c", /* Indian Red */ | |
65 "#bc8f8f", /* Rosy Brown */ | |
66 "#f0e68c", /* Khaki */ | |
67 "#bdb76b", /* Dark Khaki */ | |
68 "#228b22", /* Forest Green */ | |
69 "#9acd32", /* Yellow Green */ | |
70 "#32cd32", /* Lime Green */ | |
71 "#3cb371", /* Medium Sea Green */ | |
72 "#2e8b57", /* Sea Green */ | |
73 "#8fbc8f", /* Dark Sea Green */ | |
74 "#66cdaa", /* Medium Aquamarine */ | |
75 "#5f9ea0", /* Cadet Blue */ | |
76 "#48d1cc", /* Medium Turquoise */ | |
77 "#00ced1", /* Dark Turquoise */ | |
78 "#4682b4", /* Stell Blue */ | |
79 "#00bfff", /* Deep Sky Blue */ | |
80 "#1690ff", /* Dodger Blue */ | |
81 "#4169ff", /* Royal Blue */ | |
82 "#6a5acd", /* Slate Blue */ | |
83 "#6495ed", /* Cornflower Blue */ | |
84 "#708090", /* Slate gray */ | |
85 "#ffdead", /* Navajo White */ | |
86 }; | |
87 #define NUM_NICK_COLORS (sizeof(nick_colors) / sizeof(*nick_colors)) | |
88 | |
89 #define SCALE(x) \ | |
90 ((gdk_pixbuf_animation_get_width(x) <= 48 && \ | |
91 gdk_pixbuf_animation_get_height(x) <= 48) ? 48 : 50) | |
92 | |
93 struct InviteBuddyInfo | |
94 { | |
95 GtkWidget *window; | |
96 | |
97 GtkWidget *entry; | |
98 GtkWidget *message; | |
99 | |
100 struct gaim_conversation *conv; | |
101 }; | |
102 | |
103 char fontface[128] = { 0 }; | |
104 int fontsize = 3; | |
105 | |
106 static GtkWidget *invite_dialog = NULL; | |
107 | |
108 /* Prototypes. <-- because Paco-Paco hates this comment. */ | |
109 static void check_everything(GtkTextBuffer *buffer); | |
4685 | 110 static void set_toggle(GtkWidget *tb, gboolean active); |
4359 | 111 static void move_next_tab(struct gaim_conversation *conv); |
112 static void do_bold(GtkWidget *bold, struct gaim_gtk_conversation *gtkconv); | |
113 static void do_italic(GtkWidget *italic, struct gaim_gtk_conversation *gtkconv); | |
114 static void do_underline(GtkWidget *underline, struct gaim_gtk_conversation *gtkconv); | |
115 static void do_small(GtkWidget *small, struct gaim_gtk_conversation *gtkconv); | |
116 static void do_normal(GtkWidget *small, struct gaim_gtk_conversation *gtkconv); | |
117 static void do_big(GtkWidget *small, struct gaim_gtk_conversation *gtkconv); | |
118 static void toggle_font(GtkWidget *font, struct gaim_conversation *conv); | |
119 static void toggle_fg_color(GtkWidget *color, struct gaim_conversation *conv); | |
120 static void toggle_bg_color(GtkWidget *color, struct gaim_conversation *conv); | |
121 static void got_typing_keypress(struct gaim_conversation *conv, gboolean first); | |
122 static GList *generate_invite_user_names(struct gaim_connection *gc); | |
123 static void add_chat_buddy_common(struct gaim_conversation *conv, | |
124 const char *name, int pos); | |
125 static void tab_complete(struct gaim_conversation *conv); | |
4736 | 126 static void update_typing_icon(struct gaim_conversation *conv); |
4685 | 127 static gboolean update_send_as_selection(struct gaim_window *win); |
4602
4128761bacb8
[gaim-migrate @ 4889]
Christian Hammond <chipx86@chipx86.com>
parents:
4598
diff
changeset
|
128 static char *item_factory_translate_func (const char *path, gpointer func_data); |
4359 | 129 |
130 /************************************************************************** | |
131 * Callbacks | |
132 **************************************************************************/ | |
133 static void | |
134 do_insert_image_cb(GObject *obj, GtkWidget *wid) | |
135 { | |
136 struct gaim_conversation *conv; | |
137 struct gaim_gtk_conversation *gtkconv; | |
138 struct gaim_im *im; | |
139 const char *name; | |
140 const char *filename; | |
141 char *buf; | |
142 struct stat st; | |
143 int id; | |
144 | |
5106 | 145 conv = g_object_get_data(G_OBJECT(wid), "user_data"); |
4359 | 146 gtkconv = GAIM_GTK_CONVERSATION(conv); |
147 im = GAIM_IM(conv); | |
148 name = gtk_file_selection_get_filename(GTK_FILE_SELECTION(wid)); | |
149 id = g_slist_length(im->images) + 1; | |
150 | |
151 if (file_is_dir(name, wid)) | |
152 return; | |
153 | |
154 gtk_widget_destroy(wid); | |
155 | |
156 if (!name) | |
157 return; | |
158 | |
159 if (stat(name, &st) != 0) { | |
160 debug_printf("Could not stat %s\n", name); | |
161 return; | |
162 } | |
163 | |
164 filename = name; | |
165 while (strchr(filename, '/')) | |
166 filename = strchr(filename, '/') + 1; | |
167 | |
168 buf = g_strdup_printf("<IMG SRC=\"file://%s\" ID=\"%d\" DATASIZE=\"%d\">", | |
169 filename, id, (int)st.st_size); | |
170 im->images = g_slist_append(im->images, g_strdup(name)); | |
171 gtk_text_buffer_insert_at_cursor(GTK_TEXT_BUFFER(gtkconv->entry_buffer), | |
172 buf, -1); | |
173 g_free(buf); | |
5046 | 174 |
175 set_toggle(gtkconv->toolbar.image, FALSE); | |
4359 | 176 } |
177 | |
178 static gint | |
179 close_win_cb(GtkWidget *w, GdkEventAny *e, gpointer d) | |
180 { | |
181 struct gaim_window *win = (struct gaim_window *)d; | |
182 | |
183 gaim_window_destroy(win); | |
4361
25d5b2a7545f
[gaim-migrate @ 4627]
Christian Hammond <chipx86@chipx86.com>
parents:
4360
diff
changeset
|
184 |
25d5b2a7545f
[gaim-migrate @ 4627]
Christian Hammond <chipx86@chipx86.com>
parents:
4360
diff
changeset
|
185 return TRUE; |
4359 | 186 } |
187 | |
188 static gint | |
189 close_conv_cb(GtkWidget *w, gpointer d) | |
190 { | |
191 struct gaim_conversation *conv = (struct gaim_conversation *)d; | |
192 | |
193 gaim_conversation_destroy(conv); | |
4361
25d5b2a7545f
[gaim-migrate @ 4627]
Christian Hammond <chipx86@chipx86.com>
parents:
4360
diff
changeset
|
194 |
25d5b2a7545f
[gaim-migrate @ 4627]
Christian Hammond <chipx86@chipx86.com>
parents:
4360
diff
changeset
|
195 return TRUE; |
4359 | 196 } |
197 | |
198 static void | |
5106 | 199 cancel_insert_image_cb(GtkWidget *unused, struct gaim_gtk_conversation *gtkconv) |
200 { | |
201 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(gtkconv->toolbar.image), FALSE); | |
202 | |
203 if (gtkconv->dialogs.image) | |
204 gtk_widget_destroy(gtkconv->dialogs.image); | |
205 gtkconv->dialogs.image = NULL; | |
206 } | |
207 | |
208 static void | |
4359 | 209 insert_image_cb(GtkWidget *save, struct gaim_conversation *conv) |
210 { | |
211 struct gaim_gtk_conversation *gtkconv; | |
212 char buf[BUF_LONG]; | |
213 GtkWidget *window; | |
214 | |
215 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
216 | |
5046 | 217 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(gtkconv->toolbar.image))) { |
218 window = gtk_file_selection_new(_("Gaim - Insert Image")); | |
219 g_snprintf(buf, sizeof(buf), "%s" G_DIR_SEPARATOR_S, gaim_home_dir()); | |
220 gtk_file_selection_set_filename(GTK_FILE_SELECTION(window), buf); | |
221 | |
5106 | 222 g_object_set_data(G_OBJECT(window), "user_data", conv); |
5046 | 223 g_signal_connect(G_OBJECT(GTK_FILE_SELECTION(window)->ok_button), |
224 "clicked", G_CALLBACK(do_insert_image_cb), window); | |
5106 | 225 g_signal_connect(G_OBJECT(GTK_FILE_SELECTION(window)->cancel_button), |
226 "clicked", G_CALLBACK(cancel_insert_image_cb), gtkconv); | |
5046 | 227 |
228 gtk_widget_show(window); | |
5106 | 229 gtkconv->dialogs.image = window; |
5046 | 230 } else { |
231 gtk_widget_grab_focus(gtkconv->entry); | |
5106 | 232 if(gtkconv->dialogs.image) |
233 gtk_widget_destroy(gtkconv->dialogs.image); | |
234 gtkconv->dialogs.image = NULL; | |
5046 | 235 } |
4359 | 236 } |
237 | |
5046 | 238 static void |
4359 | 239 insert_link_cb(GtkWidget *w, struct gaim_conversation *conv) |
240 { | |
241 struct gaim_gtk_conversation *gtkconv; | |
242 | |
243 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
244 | |
245 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(gtkconv->toolbar.link))) | |
246 show_insert_link(gtkconv->toolbar.link, conv); | |
247 else if (gtkconv->dialogs.link) | |
248 cancel_link(gtkconv->toolbar.link, conv); | |
249 else | |
250 gaim_gtk_advance_past(gtkconv, "<A HREF>", "</A>"); | |
251 | |
252 gtk_widget_grab_focus(gtkconv->entry); | |
253 } | |
254 | |
255 static void | |
256 insert_smiley_cb(GtkWidget *smiley, struct gaim_conversation *conv) | |
257 { | |
258 struct gaim_gtk_conversation *gtkconv; | |
259 | |
260 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
261 | |
262 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(smiley))) | |
263 show_smiley_dialog(conv, smiley); | |
264 else if (gtkconv->dialogs.smiley) | |
265 close_smiley_dialog(smiley, conv); | |
266 | |
267 gtk_widget_grab_focus(gtkconv->entry); | |
268 } | |
269 | |
270 static void | |
271 menu_save_as_cb(gpointer data, guint action, GtkWidget *widget) | |
272 { | |
273 struct gaim_window *win = (struct gaim_window *)data; | |
274 | |
275 save_convo(NULL, gaim_window_get_active_conversation(win)); | |
276 } | |
277 | |
278 static void | |
279 menu_view_history_cb(gpointer data, guint action, GtkWidget *widget) | |
280 { | |
281 struct gaim_window *win = (struct gaim_window *)data; | |
4387
a3fd5fe57a0b
[gaim-migrate @ 4653]
Christian Hammond <chipx86@chipx86.com>
parents:
4383
diff
changeset
|
282 struct gaim_conversation *conv; |
a3fd5fe57a0b
[gaim-migrate @ 4653]
Christian Hammond <chipx86@chipx86.com>
parents:
4383
diff
changeset
|
283 |
a3fd5fe57a0b
[gaim-migrate @ 4653]
Christian Hammond <chipx86@chipx86.com>
parents:
4383
diff
changeset
|
284 conv = gaim_window_get_active_conversation(win); |
a3fd5fe57a0b
[gaim-migrate @ 4653]
Christian Hammond <chipx86@chipx86.com>
parents:
4383
diff
changeset
|
285 |
a3fd5fe57a0b
[gaim-migrate @ 4653]
Christian Hammond <chipx86@chipx86.com>
parents:
4383
diff
changeset
|
286 conv_show_log(NULL, (char *)gaim_conversation_get_name(conv)); |
4359 | 287 } |
288 static void | |
289 menu_insert_link_cb(gpointer data, guint action, GtkWidget *widget) | |
290 { | |
291 struct gaim_window *win = (struct gaim_window *)data; | |
292 struct gaim_conversation *conv; | |
293 struct gaim_gtk_conversation *gtkconv; | |
294 | |
295 conv = gaim_window_get_active_conversation(win); | |
296 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
297 | |
298 show_insert_link(gtkconv->toolbar.link, conv); | |
299 } | |
300 | |
301 static void | |
302 menu_insert_image_cb(gpointer data, guint action, GtkWidget *widget) | |
303 { | |
304 struct gaim_window *win = (struct gaim_window *)data; | |
5106 | 305 struct gaim_gtk_conversation *gtkconv; |
306 | |
307 gtkconv = GAIM_GTK_CONVERSATION(gaim_window_get_active_conversation(win)); | |
308 | |
309 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(gtkconv->toolbar.image), | |
310 !gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(gtkconv->toolbar.image))); | |
4359 | 311 } |
312 | |
313 static void | |
314 menu_close_conv_cb(gpointer data, guint action, GtkWidget *widget) | |
315 { | |
316 struct gaim_window *win = (struct gaim_window *)data; | |
317 | |
318 close_conv_cb(NULL, gaim_window_get_active_conversation(win)); | |
319 } | |
320 | |
321 static void | |
322 menu_logging_cb(gpointer data, guint action, GtkWidget *widget) | |
323 { | |
324 struct gaim_window *win = (struct gaim_window *)data; | |
325 struct gaim_conversation *conv; | |
326 | |
327 conv = gaim_window_get_active_conversation(win); | |
328 | |
5139
d0182ae31ab8
[gaim-migrate @ 5503]
Christian Hammond <chipx86@chipx86.com>
parents:
5133
diff
changeset
|
329 gaim_conversation_set_logging(conv, |
d0182ae31ab8
[gaim-migrate @ 5503]
Christian Hammond <chipx86@chipx86.com>
parents:
5133
diff
changeset
|
330 gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(widget))); |
4359 | 331 } |
332 | |
333 static void | |
334 menu_sounds_cb(gpointer data, guint action, GtkWidget *widget) | |
335 { | |
336 struct gaim_window *win = (struct gaim_window *)data; | |
337 struct gaim_conversation *conv; | |
338 struct gaim_gtk_conversation *gtkconv; | |
339 | |
4803
6f04901ef729
[gaim-migrate @ 5123]
Christian Hammond <chipx86@chipx86.com>
parents:
4793
diff
changeset
|
340 conv = gaim_window_get_active_conversation(win); |
6f04901ef729
[gaim-migrate @ 5123]
Christian Hammond <chipx86@chipx86.com>
parents:
4793
diff
changeset
|
341 |
6f04901ef729
[gaim-migrate @ 5123]
Christian Hammond <chipx86@chipx86.com>
parents:
4793
diff
changeset
|
342 if (!conv) |
4359 | 343 return; |
344 | |
345 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
346 | |
5139
d0182ae31ab8
[gaim-migrate @ 5503]
Christian Hammond <chipx86@chipx86.com>
parents:
5133
diff
changeset
|
347 gtkconv->make_sound = |
d0182ae31ab8
[gaim-migrate @ 5503]
Christian Hammond <chipx86@chipx86.com>
parents:
5133
diff
changeset
|
348 gtk_check_menu_item_get_active(GTK_CHECK_MENU_ITEM(widget)); |
4359 | 349 } |
350 | |
351 static gboolean | |
352 entry_key_pressed_cb_1(GtkTextBuffer *buffer) | |
353 { | |
354 check_everything(buffer); | |
355 | |
356 return FALSE; | |
357 } | |
358 | |
359 static void | |
360 send_cb(GtkWidget *widget, struct gaim_conversation *conv) | |
361 { | |
362 struct gaim_gtk_conversation *gtkconv; | |
363 char *buf, *buf2; | |
364 GtkTextIter start_iter, end_iter; | |
365 int limit; | |
4505 | 366 struct gaim_connection *gc = gaim_conversation_get_gc(conv); |
4359 | 367 |
368 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
369 | |
370 gtk_text_buffer_get_start_iter(gtkconv->entry_buffer, &start_iter); | |
371 gtk_text_buffer_get_end_iter(gtkconv->entry_buffer, &end_iter); | |
372 buf2 = gtk_text_buffer_get_text(gtkconv->entry_buffer, | |
373 &start_iter, &end_iter, FALSE); | |
374 | |
4685 | 375 set_toggle(gtkconv->toolbar.bold, FALSE); |
376 set_toggle(gtkconv->toolbar.italic, FALSE); | |
377 set_toggle(gtkconv->toolbar.underline, FALSE); | |
5049 | 378 set_toggle(gtkconv->toolbar.larger_size, FALSE); |
4685 | 379 set_toggle(gtkconv->toolbar.normal_size, FALSE); |
5049 | 380 set_toggle(gtkconv->toolbar.smaller_size,FALSE); |
4685 | 381 set_toggle(gtkconv->toolbar.font, FALSE); |
382 set_toggle(gtkconv->toolbar.fgcolor, FALSE); | |
383 set_toggle(gtkconv->toolbar.bgcolor, FALSE); | |
384 set_toggle(gtkconv->toolbar.link, FALSE); | |
4359 | 385 |
386 gtk_widget_grab_focus(gtkconv->entry); | |
387 | |
388 limit = 32 * 1024; /* This will be done again in gaim_im_send. *shrug* */ | |
389 | |
390 buf = g_malloc(limit); | |
391 strncpy(buf, buf2, limit); | |
392 | |
393 g_free(buf2); | |
394 | |
395 if (strlen(buf) == 0) { | |
396 g_free(buf); | |
397 | |
398 return; | |
399 } | |
400 | |
401 buf2 = g_malloc(limit); | |
402 | |
4505 | 403 if (gc && gc->flags & OPT_CONN_HTML) { |
4359 | 404 if (font_options & OPT_FONT_BOLD) { |
405 g_snprintf(buf2, limit, "<B>%s</B>", buf); | |
406 strcpy(buf, buf2); | |
407 } | |
408 | |
409 if (font_options & OPT_FONT_ITALIC) { | |
410 g_snprintf(buf2, limit, "<I>%s</I>", buf); | |
411 strcpy(buf, buf2); | |
412 } | |
413 | |
414 if (font_options & OPT_FONT_UNDERLINE) { | |
415 g_snprintf(buf2, limit, "<U>%s</U>", buf); | |
416 strcpy(buf, buf2); | |
417 } | |
418 | |
419 if (font_options & OPT_FONT_STRIKE) { | |
420 g_snprintf(buf2, limit, "<STRIKE>%s</STRIKE>", buf); | |
421 strcpy(buf, buf2); | |
422 } | |
423 | |
424 if ((font_options & OPT_FONT_FACE) || gtkconv->has_font) { | |
425 g_snprintf(buf2, limit, | |
426 "<FONT FACE=\"%s\">%s</FONT>", gtkconv->fontface, buf); | |
427 strcpy(buf, buf2); | |
428 } | |
429 | |
430 if (font_options & OPT_FONT_SIZE) { | |
431 g_snprintf(buf2, limit, | |
432 "<FONT SIZE=\"%d\">%s</FONT>", fontsize, buf); | |
433 strcpy(buf, buf2); | |
434 } | |
435 | |
4421 | 436 if (font_options & OPT_FONT_FGCOL) { |
4359 | 437 g_snprintf(buf2, limit, |
438 "<FONT COLOR=\"#%02X%02X%02X\">%s</FONT>", | |
439 gtkconv->fg_color.red / 256, | |
440 gtkconv->fg_color.green / 256, | |
441 gtkconv->fg_color.blue / 256, buf); | |
442 strcpy(buf, buf2); | |
443 } | |
444 | |
4421 | 445 if (font_options & OPT_FONT_BGCOL) { |
4359 | 446 g_snprintf(buf2, limit, |
447 "<BODY BGCOLOR=\"#%02X%02X%02X\">%s</BODY>", | |
4421 | 448 gtkconv->bg_color.red / 256, |
449 gtkconv->bg_color.green / 256, | |
450 gtkconv->bg_color.blue / 256, buf); | |
4359 | 451 strcpy(buf, buf2); |
452 } | |
453 } | |
454 | |
455 g_free(buf2); | |
456 | |
457 if (gaim_conversation_get_type(conv) == GAIM_CONV_IM) | |
458 gaim_im_send(GAIM_IM(conv), buf); | |
459 else | |
460 gaim_chat_send(GAIM_CHAT(conv), buf); | |
461 | |
462 g_free(buf); | |
463 | |
464 gtk_text_buffer_set_text(gtkconv->entry_buffer, "", -1); | |
465 } | |
466 | |
467 static void | |
468 add_cb(GtkWidget *widget, struct gaim_conversation *conv) | |
469 { | |
470 struct gaim_connection *gc; | |
471 struct buddy *b; | |
472 const char *name; | |
473 | |
474 gc = gaim_conversation_get_gc(conv); | |
475 name = gaim_conversation_get_name(conv); | |
4687 | 476 b = gaim_find_buddy(gc->account, name); |
4359 | 477 |
478 if (b != NULL) | |
479 show_confirm_del(gc, (char *)name); | |
480 else if (gc != NULL) | |
481 show_add_buddy(gc, (char *)name, NULL, NULL); | |
482 | |
483 gtk_widget_grab_focus(GAIM_GTK_CONVERSATION(conv)->entry); | |
484 } | |
485 | |
486 static void | |
487 info_cb(GtkWidget *widget, struct gaim_conversation *conv) | |
488 { | |
489 struct gaim_gtk_conversation *gtkconv; | |
490 | |
491 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
492 | |
493 if (gaim_conversation_get_type(conv) == GAIM_CONV_CHAT) { | |
494 struct gaim_gtk_chat_pane *gtkchat; | |
495 GtkTreeIter iter; | |
496 GtkTreeModel *model; | |
497 GtkTreeSelection *sel; | |
498 const char *name; | |
499 | |
500 gtkchat = gtkconv->u.chat; | |
501 | |
502 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); | |
503 sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(gtkchat->list)); | |
504 | |
505 if (gtk_tree_selection_get_selected(sel, NULL, &iter)) | |
506 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, 1, &name, -1); | |
507 else | |
508 return; | |
509 | |
510 serv_get_info(gaim_conversation_get_gc(conv), (char *)name); | |
511 } | |
512 else { | |
513 serv_get_info(gaim_conversation_get_gc(conv), | |
514 (char *)gaim_conversation_get_name(conv)); | |
515 | |
516 gtk_widget_grab_focus(gtkconv->entry); | |
517 } | |
518 } | |
519 | |
520 static void | |
521 warn_cb(GtkWidget *widget, struct gaim_conversation *conv) | |
522 { | |
523 show_warn_dialog(gaim_conversation_get_gc(conv), | |
524 (char *)gaim_conversation_get_name(conv)); | |
525 | |
526 gtk_widget_grab_focus(GAIM_GTK_CONVERSATION(conv)->entry); | |
527 } | |
528 | |
529 static void | |
530 block_cb(GtkWidget *widget, struct gaim_conversation *conv) | |
531 { | |
532 struct gaim_connection *gc; | |
533 | |
534 gc = gaim_conversation_get_gc(conv); | |
535 | |
536 if (gc != NULL) | |
537 show_add_perm(gc, (char *)gaim_conversation_get_name(conv), FALSE); | |
538 | |
539 gtk_widget_grab_focus(GAIM_GTK_CONVERSATION(conv)->entry); | |
540 } | |
541 | |
542 void | |
543 im_cb(GtkWidget *widget, struct gaim_conversation *conv) | |
544 { | |
545 struct gaim_conversation *conv2; | |
546 struct gaim_gtk_conversation *gtkconv; | |
547 struct gaim_gtk_chat_pane *gtkchat; | |
4491 | 548 struct gaim_account *account; |
4359 | 549 GtkTreeIter iter; |
550 GtkTreeModel *model; | |
551 GtkTreeSelection *sel; | |
552 const char *name; | |
553 | |
554 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
555 gtkchat = gtkconv->u.chat; | |
556 | |
557 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); | |
558 sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(gtkchat->list)); | |
559 | |
560 if (gtk_tree_selection_get_selected(sel, NULL, &iter)) | |
561 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, 1, &name, -1); | |
562 else | |
563 return; | |
564 | |
565 if (*name == '@') name++; | |
4621
69f028a6f357
[gaim-migrate @ 4912]
Christian Hammond <chipx86@chipx86.com>
parents:
4608
diff
changeset
|
566 if (*name == '%') name++; |
4359 | 567 if (*name == '+') name++; |
568 | |
4491 | 569 account = gaim_conversation_get_account(conv); |
4476
62c1e5e656d0
[gaim-migrate @ 4751]
Christian Hammond <chipx86@chipx86.com>
parents:
4466
diff
changeset
|
570 |
4359 | 571 conv2 = gaim_find_conversation(name); |
572 | |
4476
62c1e5e656d0
[gaim-migrate @ 4751]
Christian Hammond <chipx86@chipx86.com>
parents:
4466
diff
changeset
|
573 if (conv2 != NULL) { |
4359 | 574 gaim_window_raise(gaim_conversation_get_window(conv2)); |
4491 | 575 gaim_conversation_set_account(conv2, account); |
4476
62c1e5e656d0
[gaim-migrate @ 4751]
Christian Hammond <chipx86@chipx86.com>
parents:
4466
diff
changeset
|
576 } |
4359 | 577 else |
4491 | 578 conv2 = gaim_conversation_new(GAIM_CONV_IM, account, name); |
4359 | 579 } |
580 | |
581 static void | |
582 ignore_cb(GtkWidget *w, struct gaim_conversation *conv) | |
583 { | |
584 struct gaim_gtk_conversation *gtkconv; | |
585 struct gaim_gtk_chat_pane *gtkchat; | |
586 struct gaim_chat *chat; | |
587 GtkTreeIter iter; | |
588 GtkTreeModel *model; | |
589 GtkTreeSelection *sel; | |
590 const char *name; | |
591 int pos; | |
592 | |
593 chat = GAIM_CHAT(conv); | |
594 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
595 gtkchat = gtkconv->u.chat; | |
596 | |
597 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); | |
598 sel = gtk_tree_view_get_selection(GTK_TREE_VIEW(gtkchat->list)); | |
599 | |
600 if (gtk_tree_selection_get_selected(sel, NULL, &iter)) { | |
601 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, 1, &name, -1); | |
602 gtk_list_store_remove(GTK_LIST_STORE(model), &iter); | |
603 } | |
604 else | |
605 return; | |
606 | |
607 pos = g_list_index(gaim_chat_get_users(chat), name); | |
608 | |
609 if (gaim_chat_is_user_ignored(chat, name)) | |
610 gaim_chat_unignore(chat, name); | |
611 else | |
612 gaim_chat_ignore(chat, name); | |
613 | |
614 add_chat_buddy_common(conv, name, pos); | |
615 } | |
616 | |
617 static void | |
618 menu_im_cb(GtkWidget *w, struct gaim_conversation *conv) | |
619 { | |
620 const char *who; | |
621 struct gaim_conversation *conv2; | |
4491 | 622 struct gaim_account *account; |
4359 | 623 |
624 who = g_object_get_data(G_OBJECT(w), "user_data"); | |
625 | |
4491 | 626 account = gaim_conversation_get_account(conv); |
4476
62c1e5e656d0
[gaim-migrate @ 4751]
Christian Hammond <chipx86@chipx86.com>
parents:
4466
diff
changeset
|
627 |
4359 | 628 conv2 = gaim_find_conversation(who); |
629 | |
630 if (conv2 != NULL) | |
631 gaim_window_show(gaim_conversation_get_window(conv2)); | |
4476
62c1e5e656d0
[gaim-migrate @ 4751]
Christian Hammond <chipx86@chipx86.com>
parents:
4466
diff
changeset
|
632 else |
4491 | 633 conv2 = gaim_conversation_new(GAIM_CONV_IM, account, who); |
4359 | 634 } |
635 | |
636 static void | |
637 menu_info_cb(GtkWidget *w, struct gaim_conversation *conv) | |
638 { | |
639 struct gaim_connection *gc; | |
640 char *who; | |
641 | |
642 gc = gaim_conversation_get_gc(conv); | |
643 who = g_object_get_data(G_OBJECT(w), "user_data"); | |
644 | |
645 if (gc != NULL) { | |
646 /* | |
647 * If there are special needs for getting info on users in | |
648 * buddy chat "rooms"... | |
649 */ | |
650 if (gc->prpl->get_cb_info != NULL) | |
651 gc->prpl->get_cb_info(gc, gaim_chat_get_id(GAIM_CHAT(conv)), who); | |
652 else | |
653 gc->prpl->get_info(gc, who); | |
654 } | |
655 } | |
656 | |
657 static void | |
658 menu_away_cb(GtkWidget *w, struct gaim_conversation *conv) | |
659 { | |
660 struct gaim_connection *gc; | |
661 char *who; | |
662 | |
663 gc = gaim_conversation_get_gc(conv); | |
664 who = g_object_get_data(G_OBJECT(w), "user_data"); | |
665 | |
666 if (gc != NULL) { | |
667 /* | |
668 * May want to expand this to work similarly to menu_info_cb? | |
669 */ | |
670 | |
671 if (gc->prpl->get_cb_away != NULL) | |
672 gc->prpl->get_cb_away(gc, gaim_chat_get_id(GAIM_CHAT(conv)), who); | |
673 } | |
674 } | |
675 | |
676 static void | |
677 menu_add_cb(GtkWidget *w, struct gaim_conversation *conv) | |
678 { | |
679 struct gaim_connection *gc; | |
680 struct buddy *b; | |
681 char *name; | |
682 | |
683 gc = gaim_conversation_get_gc(conv); | |
684 name = g_object_get_data(G_OBJECT(w), "user_data"); | |
4687 | 685 b = gaim_find_buddy(gc->account, name); |
4359 | 686 |
687 if (b != NULL) | |
688 show_confirm_del(gc, name); | |
689 else if (gc != NULL) | |
690 show_add_buddy(gc, name, NULL, NULL); | |
691 | |
692 gtk_widget_grab_focus(GAIM_GTK_CONVERSATION(conv)->entry); | |
693 } | |
694 | |
695 static gint | |
696 right_click_chat_cb(GtkWidget *widget, GdkEventButton *event, | |
697 struct gaim_conversation *conv) | |
698 { | |
699 struct gaim_gtk_conversation *gtkconv; | |
700 struct gaim_gtk_chat_pane *gtkchat; | |
701 struct gaim_connection *gc; | |
4491 | 702 struct gaim_account *account; |
4359 | 703 GtkTreePath *path; |
704 GtkTreeIter iter; | |
705 GtkTreeModel *model; | |
706 GtkTreeViewColumn *column; | |
707 gchar *who; | |
708 int x, y; | |
709 | |
710 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
711 gtkchat = gtkconv->u.chat; | |
4491 | 712 account = gaim_conversation_get_account(conv); |
713 gc = account->gc; | |
4359 | 714 |
715 model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); | |
4685 | 716 |
4359 | 717 gtk_tree_view_get_path_at_pos(GTK_TREE_VIEW(gtkchat->list), |
718 event->x, event->y, &path, &column, &x, &y); | |
719 | |
720 if (path == NULL) | |
721 return FALSE; | |
722 | |
723 gtk_tree_selection_select_path(GTK_TREE_SELECTION( | |
724 gtk_tree_view_get_selection(GTK_TREE_VIEW(gtkchat->list))), path); | |
725 | |
726 gtk_tree_model_get_iter(GTK_TREE_MODEL(model), &iter, path); | |
727 gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, 1, &who, -1); | |
728 | |
4621
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 if (*who == '+') who++; |
69f028a6f357
[gaim-migrate @ 4912]
Christian Hammond <chipx86@chipx86.com>
parents:
4608
diff
changeset
|
732 |
4359 | 733 if (event->button == 1 && event->type == GDK_2BUTTON_PRESS) { |
734 struct gaim_conversation *c; | |
735 | |
736 if ((c = gaim_find_conversation(who)) == NULL) | |
4491 | 737 c = gaim_conversation_new(GAIM_CONV_IM, account, who); |
4476
62c1e5e656d0
[gaim-migrate @ 4751]
Christian Hammond <chipx86@chipx86.com>
parents:
4466
diff
changeset
|
738 else |
4491 | 739 gaim_conversation_set_account(c, account); |
4359 | 740 } |
741 else if (event->button == 3 && event->type == GDK_BUTTON_PRESS) { | |
742 static GtkWidget *menu = NULL; | |
743 GtkWidget *button; | |
744 | |
745 /* | |
746 * If a menu already exists, destroy it before creating a new one, | |
747 * thus freeing-up the memory it occupied. | |
748 */ | |
749 | |
750 if (menu) | |
751 gtk_widget_destroy(menu); | |
752 | |
753 menu = gtk_menu_new(); | |
754 | |
755 button = gtk_menu_item_new_with_label(_("IM")); | |
756 g_signal_connect(G_OBJECT(button), "activate", | |
757 G_CALLBACK(menu_im_cb), conv); | |
758 g_object_set_data(G_OBJECT(button), "user_data", who); | |
4635 | 759 gtk_menu_shell_append(GTK_MENU_SHELL(menu), button); |
4359 | 760 gtk_widget_show(button); |
761 | |
762 if (gaim_chat_is_user_ignored(GAIM_CHAT(conv), who)) | |
763 button = gtk_menu_item_new_with_label(_("Un-Ignore")); | |
764 else | |
765 button = gtk_menu_item_new_with_label(_("Ignore")); | |
766 | |
767 g_signal_connect(G_OBJECT(button), "activate", | |
768 G_CALLBACK(ignore_cb), conv); | |
769 g_object_set_data(G_OBJECT(button), "user_data", who); | |
4635 | 770 gtk_menu_shell_append(GTK_MENU_SHELL(menu), button); |
4359 | 771 gtk_widget_show(button); |
772 | |
773 if (gc && gc->prpl->get_info) { | |
774 button = gtk_menu_item_new_with_label(_("Info")); | |
775 g_signal_connect(G_OBJECT(button), "activate", | |
776 G_CALLBACK(menu_info_cb), conv); | |
777 g_object_set_data(G_OBJECT(button), "user_data", who); | |
4635 | 778 gtk_menu_shell_append(GTK_MENU_SHELL(menu), button); |
4359 | 779 gtk_widget_show(button); |
780 } | |
781 | |
782 if (gc && gc->prpl->get_cb_away) { | |
783 button = gtk_menu_item_new_with_label(_("Get Away Msg")); | |
784 g_signal_connect(G_OBJECT(button), "activate", | |
785 G_CALLBACK(menu_away_cb), conv); | |
786 g_object_set_data(G_OBJECT(button), "user_data", who); | |
4635 | 787 gtk_menu_shell_append(GTK_MENU_SHELL(menu), button); |
4359 | 788 gtk_widget_show(button); |
789 } | |
790 | |
791 /* Added by Jonas <jonas@birme.se> */ | |
792 if (gc) { | |
4687 | 793 if (gaim_find_buddy(gc->account, who)) |
4359 | 794 button = gtk_menu_item_new_with_label(_("Remove")); |
795 else | |
796 button = gtk_menu_item_new_with_label(_("Add")); | |
797 | |
798 g_signal_connect(G_OBJECT(button), "activate", | |
799 G_CALLBACK(menu_add_cb), conv); | |
800 | |
801 g_object_set_data(G_OBJECT(button), "user_data", who); | |
4635 | 802 gtk_menu_shell_append(GTK_MENU_SHELL(menu), button); |
4359 | 803 gtk_widget_show(button); |
804 } | |
805 /* End Jonas */ | |
4635 | 806 |
4359 | 807 gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL, |
808 event->button, event->time); | |
809 } | |
810 | |
811 return TRUE; | |
812 } | |
813 | |
814 static void | |
815 do_invite(GtkWidget *w, int resp, struct InviteBuddyInfo *info) | |
816 { | |
817 const char *buddy, *message; | |
818 struct gaim_gtk_conversation *gtkconv; | |
819 | |
820 gtkconv = GAIM_GTK_CONVERSATION(info->conv); | |
821 | |
822 if (resp == GTK_RESPONSE_OK) { | |
823 buddy = gtk_entry_get_text(GTK_ENTRY(GTK_COMBO(info->entry)->entry)); | |
824 message = gtk_entry_get_text(GTK_ENTRY(info->message)); | |
825 | |
4793 | 826 if (!g_ascii_strcasecmp(buddy, "")) { |
4359 | 827 g_free(info); |
828 | |
829 return; | |
830 } | |
831 | |
832 serv_chat_invite(gaim_conversation_get_gc(info->conv), | |
833 gaim_chat_get_id(GAIM_CHAT(info->conv)), | |
834 message, buddy); | |
835 } | |
836 | |
837 gtk_widget_destroy(invite_dialog); | |
838 invite_dialog = NULL; | |
839 | |
840 g_free(info); | |
841 } | |
842 | |
843 static void | |
844 invite_cb(GtkWidget *widget, struct gaim_conversation *conv) | |
845 { | |
846 struct InviteBuddyInfo *info = NULL; | |
847 | |
848 if (invite_dialog == NULL) { | |
849 struct gaim_connection *gc; | |
850 struct gaim_window *win; | |
851 struct gaim_gtk_window *gtkwin; | |
852 GtkWidget *label; | |
853 GtkWidget *vbox, *hbox; | |
854 GtkWidget *table; | |
855 GtkWidget *img; | |
856 | |
5024 | 857 img = gtk_image_new_from_stock(GAIM_STOCK_DIALOG_QUESTION, GTK_ICON_SIZE_DIALOG); |
4359 | 858 |
859 info = g_new0(struct InviteBuddyInfo, 1); | |
860 info->conv = conv; | |
861 | |
862 gc = gaim_conversation_get_gc(conv); | |
863 win = gaim_conversation_get_window(conv); | |
864 gtkwin = GAIM_GTK_WINDOW(win); | |
865 | |
866 /* Create the new dialog. */ | |
867 invite_dialog = gtk_dialog_new_with_buttons( | |
868 _("Gaim - Invite Buddy Into Chat Room"), | |
869 GTK_WINDOW(gtkwin->window), | |
870 GTK_DIALOG_MODAL, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, | |
871 GTK_STOCK_OK, GTK_RESPONSE_OK, NULL); | |
872 | |
873 gtk_dialog_set_default_response(GTK_DIALOG(invite_dialog), | |
874 GTK_RESPONSE_OK); | |
875 gtk_container_set_border_width(GTK_CONTAINER(invite_dialog), 6); | |
876 gtk_window_set_resizable(GTK_WINDOW(invite_dialog), FALSE); | |
877 gtk_dialog_set_has_separator(GTK_DIALOG(invite_dialog), FALSE); | |
878 | |
879 /* Setup the outside spacing. */ | |
880 vbox = GTK_DIALOG(invite_dialog)->vbox; | |
881 | |
882 gtk_box_set_spacing(GTK_BOX(vbox), 12); | |
883 gtk_container_set_border_width(GTK_CONTAINER(vbox), 6); | |
884 | |
885 /* Setup the inner hbox and put the dialog's icon in it. */ | |
886 hbox = gtk_hbox_new(FALSE, 12); | |
887 gtk_container_add(GTK_CONTAINER(vbox), hbox); | |
888 gtk_box_pack_start(GTK_BOX(hbox), img, FALSE, FALSE, 0); | |
889 gtk_misc_set_alignment(GTK_MISC(img), 0, 0); | |
890 | |
891 /* Setup the right vbox. */ | |
892 vbox = gtk_vbox_new(FALSE, 0); | |
893 gtk_container_add(GTK_CONTAINER(hbox), vbox); | |
894 | |
895 /* Put our happy label in it. */ | |
896 label = gtk_label_new(_("Please enter the name of the user you wish " | |
897 "to invite, along with an optional invite " | |
898 "message.")); | |
899 gtk_widget_set_size_request(label, 350, -1); | |
900 gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); | |
901 gtk_misc_set_alignment(GTK_MISC(label), 0, 0); | |
902 gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); | |
903 | |
904 /* hbox for the table, and to give it some spacing on the left. */ | |
905 hbox = gtk_hbox_new(FALSE, 6); | |
906 gtk_container_add(GTK_CONTAINER(vbox), hbox); | |
907 | |
908 /* Setup the table we're going to use to lay stuff out. */ | |
909 table = gtk_table_new(2, 2, FALSE); | |
910 gtk_table_set_row_spacings(GTK_TABLE(table), 6); | |
911 gtk_table_set_col_spacings(GTK_TABLE(table), 6); | |
912 gtk_container_set_border_width(GTK_CONTAINER(table), 12); | |
913 gtk_box_pack_start(GTK_BOX(vbox), table, FALSE, FALSE, 0); | |
914 | |
915 /* Now the Buddy label */ | |
916 label = gtk_label_new(NULL); | |
917 gtk_label_set_markup_with_mnemonic(GTK_LABEL(label), _("_Buddy:")); | |
918 gtk_misc_set_alignment(GTK_MISC(label), 0, 0); | |
919 gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 0, 1); | |
920 | |
921 /* Now the Buddy drop-down entry field. */ | |
922 info->entry = gtk_combo_new(); | |
923 gtk_combo_set_case_sensitive(GTK_COMBO(info->entry), FALSE); | |
924 gtk_entry_set_activates_default( | |
925 GTK_ENTRY(GTK_COMBO(info->entry)->entry), TRUE); | |
926 | |
927 gtk_table_attach_defaults(GTK_TABLE(table), info->entry, 1, 2, 0, 1); | |
928 gtk_label_set_mnemonic_widget(GTK_LABEL(label), info->entry); | |
929 | |
930 /* Fill in the names. */ | |
931 gtk_combo_set_popdown_strings(GTK_COMBO(info->entry), | |
932 generate_invite_user_names(gc)); | |
933 | |
934 | |
935 /* Now the label for "Message" */ | |
936 label = gtk_label_new(NULL); | |
937 gtk_label_set_markup_with_mnemonic(GTK_LABEL(label), _("_Message:")); | |
938 gtk_misc_set_alignment(GTK_MISC(label), 0, 0); | |
939 gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 1, 2); | |
940 | |
941 | |
942 /* And finally, the Message entry field. */ | |
943 info->message = gtk_entry_new(); | |
944 gtk_entry_set_activates_default(GTK_ENTRY(info->message), TRUE); | |
945 | |
946 gtk_table_attach_defaults(GTK_TABLE(table), info->message, 1, 2, 1, 2); | |
947 gtk_label_set_mnemonic_widget(GTK_LABEL(label), info->message); | |
948 | |
949 /* Connect the signals. */ | |
950 g_signal_connect(G_OBJECT(invite_dialog), "response", | |
951 G_CALLBACK(do_invite), info); | |
952 } | |
953 | |
954 gtk_widget_show_all(invite_dialog); | |
955 | |
956 if (info != NULL) | |
957 gtk_widget_grab_focus(GTK_COMBO(info->entry)->entry); | |
958 } | |
959 | |
960 static gboolean | |
961 entry_key_pressed_cb_2(GtkWidget *entry, GdkEventKey *event, gpointer data) | |
962 { | |
963 struct gaim_window *win; | |
964 struct gaim_conversation *conv; | |
965 struct gaim_gtk_conversation *gtkconv; | |
4362 | 966 struct gaim_gtk_window *gtkwin; |
4359 | 967 |
968 conv = (struct gaim_conversation *)data; | |
969 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
970 win = gaim_conversation_get_window(conv); | |
4362 | 971 gtkwin = GAIM_GTK_WINDOW(win); |
4359 | 972 |
973 if (event->keyval == GDK_Escape) { | |
974 if (convo_options & OPT_CONVO_ESC_CAN_CLOSE) { | |
975 g_signal_stop_emission_by_name(G_OBJECT(entry), "key_press_event"); | |
976 gaim_conversation_destroy(conv); | |
977 } | |
978 } | |
979 else if (event->keyval == GDK_Page_Up) { | |
980 g_signal_stop_emission_by_name(G_OBJECT(entry), "key_press_event"); | |
981 | |
982 if (!(event->state & GDK_CONTROL_MASK)) | |
983 gtk_imhtml_page_up(GTK_IMHTML(gtkconv->imhtml)); | |
984 } | |
985 else if (event->keyval == GDK_Page_Down) { | |
986 g_signal_stop_emission_by_name(G_OBJECT(entry), "key_press_event"); | |
987 | |
988 if (!(event->state & GDK_CONTROL_MASK)) | |
989 gtk_imhtml_page_down(GTK_IMHTML(gtkconv->imhtml)); | |
990 } | |
991 else if ((event->keyval == GDK_F2) && | |
992 (convo_options & OPT_CONVO_F2_TOGGLES)) { | |
993 gtk_imhtml_show_comments(GTK_IMHTML(gtkconv->imhtml), | |
994 !GTK_IMHTML(gtkconv->imhtml)->comments); | |
995 } | |
996 else if (event->keyval == GDK_Return || event->keyval == GDK_KP_Enter) { | |
997 if ((event->state & GDK_CONTROL_MASK) && | |
998 (convo_options & OPT_CONVO_CTL_ENTER)) { | |
999 | |
1000 send_cb(NULL, conv); | |
1001 g_signal_stop_emission_by_name(G_OBJECT(entry), "key_press_event"); | |
1002 | |
1003 return TRUE; | |
1004 } | |
1005 else if (!(event->state & (GDK_SHIFT_MASK | GDK_CONTROL_MASK)) && | |
1006 (convo_options & OPT_CONVO_ENTER_SENDS)) { | |
1007 | |
1008 send_cb(NULL, conv); | |
1009 g_signal_stop_emission_by_name(G_OBJECT(entry), "key_press_event"); | |
1010 | |
1011 return TRUE; | |
1012 } | |
1013 | |
1014 return FALSE; | |
1015 } | |
1016 else if ((event->state & GDK_CONTROL_MASK) && (event->keyval == 'm')) { | |
1017 g_signal_stop_emission_by_name(G_OBJECT(entry), "key_press_event"); | |
1018 gtk_text_buffer_insert_at_cursor(gtkconv->entry_buffer, "\n", 1); | |
1019 } | |
1020 else if (event->state & GDK_CONTROL_MASK) { | |
1021 switch (event->keyval) { | |
1022 case GDK_Up: | |
1023 if (!conv->send_history) | |
1024 break; | |
1025 | |
1026 if (!conv->send_history->prev) { | |
1027 GtkTextIter start, end; | |
1028 | |
1029 if (conv->send_history->data) | |
1030 g_free(conv->send_history->data); | |
1031 | |
1032 gtk_text_buffer_get_start_iter(gtkconv->entry_buffer, | |
1033 &start); | |
1034 gtk_text_buffer_get_end_iter(gtkconv->entry_buffer, &end); | |
1035 | |
1036 conv->send_history->data = | |
1037 gtk_text_buffer_get_text(gtkconv->entry_buffer, | |
1038 &start, &end, FALSE); | |
1039 } | |
1040 | |
1041 if (conv->send_history->next && | |
1042 conv->send_history->next->data) { | |
1043 | |
1044 conv->send_history = conv->send_history->next; | |
1045 gtk_text_buffer_set_text(gtkconv->entry_buffer, | |
1046 conv->send_history->data, -1); | |
1047 } | |
1048 | |
1049 break; | |
1050 | |
1051 case GDK_Down: | |
1052 if (!conv->send_history) | |
1053 break; | |
1054 | |
1055 if (conv->send_history->prev) { | |
1056 conv->send_history = conv->send_history->prev; | |
1057 | |
1058 if (conv->send_history->data) | |
1059 gtk_text_buffer_set_text(gtkconv->entry_buffer, | |
1060 conv->send_history->data, -1); | |
1061 } | |
1062 | |
1063 break; | |
1064 } | |
1065 | |
1066 if (convo_options & OPT_CONVO_CTL_CHARS) { | |
1067 switch (event->keyval) { | |
1068 case 'i': | |
1069 case 'I': | |
4685 | 1070 set_toggle(gtkconv->toolbar.italic, |
4359 | 1071 !gtk_toggle_button_get_active( |
1072 GTK_TOGGLE_BUTTON(gtkconv->toolbar.italic))); | |
1073 | |
1074 g_signal_stop_emission_by_name(G_OBJECT(entry), | |
1075 "key_press_event"); | |
1076 break; | |
1077 | |
1078 case 'u': /* ctrl-u is GDK_Clear, which clears the line. */ | |
1079 case 'U': | |
4685 | 1080 set_toggle(gtkconv->toolbar.underline, |
4359 | 1081 !gtk_toggle_button_get_active( |
1082 GTK_TOGGLE_BUTTON(gtkconv->toolbar.underline))); | |
1083 | |
1084 g_signal_stop_emission_by_name(G_OBJECT(entry), | |
1085 "key_press_event"); | |
1086 break; | |
1087 | |
1088 case 'b': /* ctrl-b is GDK_Left, which moves backwards. */ | |
1089 case 'B': | |
4685 | 1090 set_toggle(gtkconv->toolbar.bold, |
4359 | 1091 !gtk_toggle_button_get_active( |
1092 GTK_TOGGLE_BUTTON(gtkconv->toolbar.bold))); | |
1093 | |
1094 g_signal_stop_emission_by_name(G_OBJECT(entry), | |
1095 "key_press_event"); | |
1096 break; | |
1097 | |
1098 case '-': | |
1099 do_small(NULL, gtkconv); | |
1100 | |
1101 g_signal_stop_emission_by_name(G_OBJECT(entry), | |
1102 "key_press_event"); | |
1103 break; | |
1104 | |
1105 case '=': | |
1106 case '+': | |
1107 do_big(NULL, gtkconv); | |
1108 | |
1109 g_signal_stop_emission_by_name(G_OBJECT(entry), | |
1110 "key_press_event"); | |
1111 break; | |
1112 | |
1113 case '0': | |
4685 | 1114 set_toggle(gtkconv->toolbar.normal_size, |
1115 !gtk_toggle_button_get_active( | |
1116 GTK_TOGGLE_BUTTON(gtkconv->toolbar.normal_size))); | |
4359 | 1117 |
1118 g_signal_stop_emission_by_name(G_OBJECT(entry), | |
1119 "key_press_event"); | |
1120 break; | |
1121 | |
1122 case 'f': | |
1123 case 'F': | |
4685 | 1124 set_toggle(gtkconv->toolbar.font, |
4359 | 1125 !gtk_toggle_button_get_active( |
4685 | 1126 GTK_TOGGLE_BUTTON(gtkconv->toolbar.font))); |
4359 | 1127 |
1128 g_signal_stop_emission_by_name(G_OBJECT(entry), | |
1129 "key_press_event"); | |
1130 break; | |
1131 } | |
1132 } | |
1133 | |
1134 if (convo_options & OPT_CONVO_CTL_SMILEYS) { | |
1135 char buf[7]; | |
1136 | |
1137 *buf = '\0'; | |
1138 | |
1139 switch (event->keyval) { | |
1140 case '1': strcpy(buf, ":-)"); break; | |
1141 case '2': strcpy(buf, ":-("); break; | |
1142 case '3': strcpy(buf, ";-)"); break; | |
1143 case '4': strcpy(buf, ":-P"); break; | |
1144 case '5': strcpy(buf, "=-O"); break; | |
1145 case '6': strcpy(buf, ":-*"); break; | |
1146 case '7': strcpy(buf, ">:o"); break; | |
1147 case '8': strcpy(buf, "8-)"); break; | |
1148 case '!': strcpy(buf, ":-$"); break; | |
1149 case '@': strcpy(buf, ":-!"); break; | |
1150 case '#': strcpy(buf, ":-["); break; | |
1151 case '$': strcpy(buf, "O:-)"); break; | |
1152 case '%': strcpy(buf, ":-/"); break; | |
1153 case '^': strcpy(buf, ":'("); break; | |
1154 case '&': strcpy(buf, ":-X"); break; | |
1155 case '*': strcpy(buf, ":-D"); break; | |
1156 default: break; | |
1157 } | |
1158 | |
1159 if (*buf) { | |
1160 gtk_text_buffer_insert_at_cursor(gtkconv->entry_buffer, | |
1161 buf, -1); | |
1162 g_signal_stop_emission_by_name(G_OBJECT(entry), "key_press_event"); | |
1163 } | |
1164 } | |
1165 | |
1166 if (event->keyval == 'l') { | |
1167 gtk_imhtml_clear(GTK_IMHTML(gtkconv->imhtml)); | |
1168 g_string_free(conv->history, TRUE); | |
1169 conv->history = g_string_new(""); | |
1170 } | |
1171 else if ((event->keyval == 'w') && | |
1172 (convo_options & OPT_CONVO_CTL_W_CLOSES)) { | |
1173 | |
1174 g_signal_stop_emission_by_name(G_OBJECT(entry), "key_press_event"); | |
1175 gaim_conversation_destroy(conv); | |
1176 return TRUE; | |
1177 } | |
1178 else if (event->keyval == 'n') { | |
1179 g_signal_stop_emission_by_name(G_OBJECT(entry), "key_press_event"); | |
1180 | |
1181 show_im_dialog(); | |
1182 } | |
1183 else if (event->keyval == 'z') { | |
1184 g_signal_stop_emission_by_name(G_OBJECT(entry), "key_press_event"); | |
5133 | 1185 |
1186 gtk_window_iconify(GTK_WINDOW(gtkwin->window)); | |
4359 | 1187 } |
1188 else if (event->keyval == '[') { | |
1189 gaim_window_switch_conversation(win, | |
1190 gaim_conversation_get_index(conv) - 1); | |
1191 | |
1192 g_signal_stop_emission_by_name(G_OBJECT(entry), "key_press_event"); | |
1193 } | |
1194 else if (event->keyval == ']') { | |
1195 gaim_window_switch_conversation(win, | |
1196 gaim_conversation_get_index(conv) + 1); | |
1197 | |
1198 g_signal_stop_emission_by_name(G_OBJECT(entry), "key_press_event"); | |
1199 } | |
1200 else if (event->keyval == GDK_Tab) { | |
1201 move_next_tab(conv); | |
1202 | |
1203 g_signal_stop_emission_by_name(G_OBJECT(entry), "key_press_event"); | |
1204 | |
1205 return TRUE; | |
1206 } | |
1207 } | |
1208 else if ((event->keyval == GDK_Tab) && | |
1209 gaim_conversation_get_type(conv) == GAIM_CONV_CHAT && | |
1210 (chat_options & OPT_CHAT_TAB_COMPLETE)) { | |
1211 | |
1212 tab_complete(conv); | |
1213 | |
1214 g_signal_stop_emission_by_name(G_OBJECT(entry), "key_press_event"); | |
1215 | |
1216 return TRUE; | |
1217 } | |
1218 else if ((event->state & GDK_MOD1_MASK) && | |
1219 event->keyval > '0' && event->keyval <= '9') { | |
1220 | |
1221 gaim_window_switch_conversation(win, event->keyval - '1'); | |
1222 | |
1223 g_signal_stop_emission_by_name(G_OBJECT(entry), "key_press_event"); | |
1224 } | |
1225 | |
1226 return FALSE; | |
1227 } | |
1228 | |
1229 /* | |
1230 * NOTE: | |
1231 * This guy just kills a single right click from being propagated any | |
1232 * further. I have no idea *why* we need this, but we do ... It | |
1233 * prevents right clicks on the GtkTextView in a convo dialog from | |
1234 * going all the way down to the notebook. I suspect a bug in | |
1235 * GtkTextView, but I'm not ready to point any fingers yet. | |
1236 */ | |
1237 static gboolean | |
1238 entry_stop_rclick_cb(GtkWidget *widget, GdkEventButton *event, gpointer data) | |
1239 { | |
1240 if (event->button == 3 && event->type == GDK_BUTTON_PRESS) { | |
1241 /* Right single click */ | |
1242 g_signal_stop_emission_by_name(G_OBJECT(widget), "button_press_event"); | |
1243 | |
1244 return TRUE; | |
1245 } | |
1246 | |
1247 return FALSE; | |
1248 } | |
1249 | |
1250 static void | |
4673 | 1251 menu_conv_sel_send_cb(GObject *m, gpointer data) |
4359 | 1252 { |
1253 struct gaim_window *win = g_object_get_data(m, "user_data"); | |
4673 | 1254 struct gaim_account *account = g_object_get_data(m, "gaim_account"); |
4359 | 1255 struct gaim_conversation *conv; |
1256 | |
1257 conv = gaim_window_get_active_conversation(win); | |
1258 | |
4491 | 1259 gaim_conversation_set_account(conv, account); |
4359 | 1260 } |
1261 | |
1262 static void | |
1263 insert_text_cb(GtkTextBuffer *textbuffer, GtkTextIter *position, | |
1264 gchar *new_text, gint new_text_length, gpointer user_data) | |
1265 { | |
1266 struct gaim_conversation *conv = (struct gaim_conversation *)user_data; | |
1267 | |
1268 if (conv == NULL) | |
1269 return; | |
1270 | |
1271 if (misc_options & OPT_MISC_STEALTH_TYPING) | |
1272 return; | |
1273 | |
1274 got_typing_keypress(conv, (gtk_text_iter_is_start(position) && | |
1275 gtk_text_iter_is_end(position))); | |
1276 } | |
1277 | |
1278 static void | |
1279 delete_text_cb(GtkTextBuffer *textbuffer, GtkTextIter *start_pos, | |
1280 GtkTextIter *end_pos, gpointer user_data) | |
1281 { | |
1282 struct gaim_conversation *conv = (struct gaim_conversation *)user_data; | |
1283 struct gaim_im *im; | |
1284 | |
1285 if (conv == NULL) | |
1286 return; | |
1287 | |
1288 if (misc_options & OPT_MISC_STEALTH_TYPING) | |
1289 return; | |
1290 | |
1291 im = GAIM_IM(conv); | |
1292 | |
1293 if (gtk_text_iter_is_start(start_pos) && gtk_text_iter_is_end(end_pos)) { | |
1294 | |
1295 /* We deleted all the text, so turn off typing. */ | |
1296 if (gaim_im_get_type_again_timeout(im)) | |
1297 gaim_im_stop_type_again_timeout(im); | |
1298 | |
1299 /* XXX The (char *) should go away! Somebody add consts to stuff! */ | |
1300 serv_send_typing(gaim_conversation_get_gc(conv), | |
1301 (char *)gaim_conversation_get_name(conv), | |
1302 NOT_TYPING); | |
1303 } | |
1304 else { | |
1305 /* We're deleting, but not all of it, so it counts as typing. */ | |
1306 got_typing_keypress(conv, FALSE); | |
1307 } | |
1308 } | |
1309 | |
1310 static void | |
1311 notebook_init_grab(struct gaim_gtk_window *gtkwin, GtkWidget *widget) | |
1312 { | |
1313 static GdkCursor *cursor = NULL; | |
1314 | |
1315 gtkwin->in_drag = TRUE; | |
1316 | |
1317 if (gtkwin->drag_leave_signal) { | |
1318 g_signal_handler_disconnect(G_OBJECT(widget), | |
1319 gtkwin->drag_leave_signal); | |
1320 | |
1321 gtkwin->drag_leave_signal = 0; | |
1322 } | |
1323 | |
1324 if (cursor == NULL) | |
1325 cursor = gdk_cursor_new(GDK_FLEUR); | |
1326 | |
1327 /* Grab the pointer */ | |
1328 gtk_grab_add(gtkwin->notebook); | |
5114
e245e686f62f
[gaim-migrate @ 5477]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
5106
diff
changeset
|
1329 #ifndef _WIN32 |
e245e686f62f
[gaim-migrate @ 5477]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
5106
diff
changeset
|
1330 /* 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
|
1331 always be true after a button press. */ |
4803
6f04901ef729
[gaim-migrate @ 5123]
Christian Hammond <chipx86@chipx86.com>
parents:
4793
diff
changeset
|
1332 if (!gdk_pointer_is_grabbed()) |
5114
e245e686f62f
[gaim-migrate @ 5477]
Herman Bloggs <hermanator12002@yahoo.com>
parents:
5106
diff
changeset
|
1333 #endif |
4803
6f04901ef729
[gaim-migrate @ 5123]
Christian Hammond <chipx86@chipx86.com>
parents:
4793
diff
changeset
|
1334 gdk_pointer_grab(gtkwin->notebook->window, FALSE, |
6f04901ef729
[gaim-migrate @ 5123]
Christian Hammond <chipx86@chipx86.com>
parents:
4793
diff
changeset
|
1335 GDK_BUTTON1_MOTION_MASK | GDK_BUTTON_RELEASE_MASK, |
6f04901ef729
[gaim-migrate @ 5123]
Christian Hammond <chipx86@chipx86.com>
parents:
4793
diff
changeset
|
1336 NULL, cursor, GDK_CURRENT_TIME); |
4359 | 1337 } |
1338 | |
1339 static gboolean | |
1340 notebook_motion_cb(GtkWidget *widget, GdkEventButton *e, | |
1341 struct gaim_window *win) | |
1342 { | |
1343 struct gaim_gtk_window *gtkwin; | |
1344 | |
1345 gtkwin = GAIM_GTK_WINDOW(win); | |
1346 | |
1347 /* | |
1348 * Make sure the user moved the mouse far enough for the | |
1349 * drag to be initiated. | |
1350 */ | |
1351 if (gtkwin->in_predrag) { | |
1352 if (e->x_root < gtkwin->drag_min_x || | |
1353 e->x_root >= gtkwin->drag_max_x || | |
1354 e->y_root < gtkwin->drag_min_y || | |
1355 e->y_root >= gtkwin->drag_max_y) { | |
1356 | |
1357 gtkwin->in_predrag = FALSE; | |
1358 notebook_init_grab(gtkwin, widget); | |
1359 } | |
1360 } | |
1361 else { /* Otherwise, draw the arrows. */ | |
1362 struct gaim_window *dest_win; | |
1363 struct gaim_gtk_window *dest_gtkwin; | |
1364 GtkNotebook *dest_notebook; | |
1365 GtkWidget *tab, *last_vis_tab = NULL; | |
1366 gint nb_x, nb_y, page_num, i, last_vis_tab_loc = -1; | |
1367 gint arrow1_x, arrow1_y, arrow2_x, arrow2_y; | |
1368 gboolean horiz_tabs = FALSE, tab_found = FALSE; | |
1369 GList *l; | |
1370 | |
1371 /* Get the window that the cursor is over. */ | |
1372 dest_win = gaim_gtkwin_get_at_xy(e->x_root, e->y_root); | |
1373 | |
1374 if (dest_win == NULL) { | |
1375 dnd_hints_hide_all(); | |
1376 | |
1377 return TRUE; | |
1378 } | |
1379 | |
1380 dest_gtkwin = GAIM_GTK_WINDOW(dest_win); | |
1381 | |
1382 dest_notebook = GTK_NOTEBOOK(dest_gtkwin->notebook); | |
1383 | |
1384 gdk_window_get_origin(GTK_WIDGET(dest_notebook)->window, &nb_x, &nb_y); | |
1385 | |
1386 arrow1_x = arrow2_x = nb_x; | |
1387 arrow1_y = arrow2_y = nb_y; | |
1388 | |
1389 page_num = gaim_gtkconv_get_dest_tab_at_xy(dest_win, | |
1390 e->x_root, e->y_root); | |
1391 | |
1392 if (gtk_notebook_get_tab_pos(dest_notebook) == GTK_POS_TOP || | |
1393 gtk_notebook_get_tab_pos(dest_notebook) == GTK_POS_BOTTOM) { | |
1394 | |
1395 horiz_tabs = TRUE; | |
1396 } | |
1397 | |
1398 /* Find out where to put the arrows. */ | |
1399 for (l = gaim_window_get_conversations(dest_win), i = 0; | |
1400 l != NULL; | |
1401 l = l->next, i++) { | |
1402 | |
1403 struct gaim_conversation *conv = l->data; | |
1404 | |
1405 tab = GAIM_GTK_CONVERSATION(conv)->tabby; | |
1406 | |
1407 /* | |
1408 * If this is the correct tab, record the positions | |
1409 * for the arrows. | |
1410 */ | |
1411 if (i == page_num) { | |
1412 if (horiz_tabs) { | |
1413 arrow1_x = arrow2_x = nb_x + tab->allocation.x; | |
1414 arrow1_y = nb_y + tab->allocation.y; | |
1415 arrow2_y = nb_y + tab->allocation.y + | |
1416 tab->allocation.height; | |
1417 } | |
1418 else { | |
1419 arrow1_x = nb_x + tab->allocation.x; | |
1420 arrow2_x = nb_x + tab->allocation.x + | |
1421 tab->allocation.width; | |
1422 arrow1_y = arrow2_y = nb_y + tab->allocation.y; | |
1423 } | |
1424 | |
1425 tab_found = TRUE; | |
1426 break; | |
1427 } | |
1428 else { /* Keep track of the right-most tab that we see. */ | |
1429 if (horiz_tabs && tab->allocation.x > last_vis_tab_loc) { | |
1430 last_vis_tab = tab; | |
1431 last_vis_tab_loc = tab->allocation.x; | |
1432 } | |
1433 else if (!horiz_tabs && tab->allocation.y > last_vis_tab_loc) { | |
1434 last_vis_tab = tab; | |
1435 last_vis_tab_loc = tab->allocation.y; | |
1436 } | |
1437 } | |
1438 } | |
1439 | |
1440 /* | |
1441 * If we didn't find the tab, then we'll just place the | |
1442 * arrows to the right/bottom of the last visible tab. | |
1443 */ | |
1444 if (!tab_found && last_vis_tab) { | |
1445 if (horiz_tabs) { | |
1446 arrow1_x = arrow2_x = nb_x + last_vis_tab->allocation.x + | |
1447 last_vis_tab->allocation.width; | |
1448 arrow1_y = nb_y + last_vis_tab->allocation.y; | |
1449 arrow2_y = nb_y + last_vis_tab->allocation.y + | |
1450 last_vis_tab->allocation.height; | |
1451 } | |
1452 else { | |
1453 arrow1_x = nb_x + last_vis_tab->allocation.x; | |
1454 arrow2_x = nb_x + last_vis_tab->allocation.x + | |
1455 last_vis_tab->allocation.width; | |
1456 arrow1_y = arrow2_y = nb_y + last_vis_tab->allocation.y + | |
1457 last_vis_tab->allocation.height; | |
1458 } | |
1459 } | |
1460 | |
1461 if (horiz_tabs) { | |
1462 dnd_hints_show(HINT_ARROW_DOWN, arrow1_x, arrow1_y); | |
1463 dnd_hints_show(HINT_ARROW_UP, arrow2_x, arrow2_y); | |
1464 } | |
1465 else { | |
1466 dnd_hints_show(HINT_ARROW_RIGHT, arrow1_x, arrow1_y); | |
1467 dnd_hints_show(HINT_ARROW_LEFT, arrow2_x, arrow2_y); | |
1468 } | |
1469 } | |
1470 | |
1471 return TRUE; | |
1472 } | |
1473 | |
1474 static gboolean | |
1475 notebook_leave_cb(GtkWidget *widget, GdkEventCrossing *e, | |
1476 struct gaim_window *win) | |
1477 { | |
1478 struct gaim_gtk_window *gtkwin; | |
1479 | |
1480 gtkwin = GAIM_GTK_WINDOW(win); | |
1481 | |
1482 if (gtkwin->in_drag) | |
1483 return FALSE; | |
1484 | |
1485 if (e->x_root < gtkwin->drag_min_x || | |
1486 e->x_root >= gtkwin->drag_max_x || | |
1487 e->y_root < gtkwin->drag_min_y || | |
1488 e->y_root >= gtkwin->drag_max_y) { | |
1489 | |
1490 gtkwin->in_predrag = FALSE; | |
1491 notebook_init_grab(gtkwin, widget); | |
1492 } | |
1493 | |
1494 return TRUE; | |
1495 } | |
1496 | |
1497 /* | |
1498 * THANK YOU GALEON! | |
1499 */ | |
1500 static gboolean | |
1501 notebook_press_cb(GtkWidget *widget, GdkEventButton *e, | |
1502 struct gaim_window *win) | |
1503 { | |
1504 struct gaim_gtk_window *gtkwin; | |
1505 gint nb_x, nb_y, x_rel, y_rel; | |
1506 GList *l; | |
1507 int tab_clicked; | |
1508 | |
1509 if (e->button != 1 || e->type != GDK_BUTTON_PRESS) | |
1510 return FALSE; | |
1511 | |
1512 gtkwin = GAIM_GTK_WINDOW(win); | |
1513 | |
1514 if (gtkwin->in_drag) { | |
1515 debug_printf("Already in the middle of a window " | |
4803
6f04901ef729
[gaim-migrate @ 5123]
Christian Hammond <chipx86@chipx86.com>
parents:
4793
diff
changeset
|
1516 "drag at tab_press_cb\n"); |
6f04901ef729
[gaim-migrate @ 5123]
Christian Hammond <chipx86@chipx86.com>
parents:
4793
diff
changeset
|
1517 return TRUE; |
4359 | 1518 } |
1519 | |
1520 /* | |
1521 * Make sure a tab was actually clicked. The arrow buttons | |
1522 * mess things up. | |
1523 */ | |
1524 tab_clicked = gaim_gtkconv_get_tab_at_xy(win, e->x_root, e->y_root); | |
1525 | |
1526 if (tab_clicked == -1) | |
1527 return FALSE; | |
1528 | |
1529 /* | |
1530 * Get the relative position of the press event, with regards to | |
1531 * the position of the notebook. | |
1532 */ | |
1533 gdk_window_get_origin(gtkwin->notebook->window, &nb_x, &nb_y); | |
1534 | |
1535 x_rel = e->x_root - nb_x; | |
1536 y_rel = e->y_root - nb_y; | |
1537 | |
1538 /* Reset the min/max x/y */ | |
1539 gtkwin->drag_min_x = 0; | |
1540 gtkwin->drag_min_y = 0; | |
1541 gtkwin->drag_max_x = 0; | |
1542 gtkwin->drag_max_y = 0; | |
1543 | |
1544 /* Find out which tab was dragged. */ | |
1545 for (l = gaim_window_get_conversations(win); l != NULL; l = l->next) { | |
1546 struct gaim_conversation *conv = l->data; | |
1547 GtkWidget *tab = GAIM_GTK_CONVERSATION(conv)->tabby; | |
1548 | |
1549 if (!GTK_WIDGET_VISIBLE(tab)) | |
1550 continue; | |
1551 | |
1552 if (tab->allocation.x > x_rel || tab->allocation.y > y_rel) | |
1553 break; | |
1554 | |
1555 /* Save the borders of the tab. */ | |
1556 gtkwin->drag_min_x = tab->allocation.x + nb_x; | |
1557 gtkwin->drag_min_y = tab->allocation.y + nb_y; | |
1558 gtkwin->drag_max_x = tab->allocation.width + gtkwin->drag_min_x; | |
1559 gtkwin->drag_max_y = tab->allocation.height + gtkwin->drag_min_y; | |
1560 } | |
1561 | |
1562 /* Make sure the click occurred in the tab. */ | |
1563 if (e->x_root < gtkwin->drag_min_x || | |
1564 e->x_root >= gtkwin->drag_max_x || | |
1565 e->y_root < gtkwin->drag_min_y || | |
1566 e->y_root >= gtkwin->drag_max_y) { | |
1567 | |
1568 return FALSE; | |
1569 } | |
1570 | |
1571 gtkwin->in_predrag = TRUE; | |
1572 | |
1573 /* Connect the new motion signals. */ | |
1574 gtkwin->drag_motion_signal = | |
1575 g_signal_connect(G_OBJECT(widget), "motion_notify_event", | |
1576 G_CALLBACK(notebook_motion_cb), win); | |
1577 | |
1578 gtkwin->drag_leave_signal = | |
1579 g_signal_connect(G_OBJECT(widget), "leave_notify_event", | |
1580 G_CALLBACK(notebook_leave_cb), win); | |
1581 | |
1582 return FALSE; | |
1583 } | |
1584 | |
1585 static gboolean | |
1586 notebook_release_cb(GtkWidget *widget, GdkEventButton *e, | |
1587 struct gaim_window *win) | |
1588 { | |
1589 struct gaim_window *dest_win; | |
1590 struct gaim_gtk_window *gtkwin; | |
1591 struct gaim_gtk_window *dest_gtkwin; | |
1592 struct gaim_conversation *conv; | |
1593 GtkNotebook *dest_notebook; | |
1594 gint dest_page_num; | |
1595 | |
1596 /* | |
1597 * Don't check to make sure that the event's window matches the | |
1598 * widget's, because we may be getting an event passed on from the | |
1599 * close button. | |
1600 */ | |
1601 if (e->button != 1 && e->type != GDK_BUTTON_RELEASE) | |
1602 return FALSE; | |
1603 | |
1604 if (gdk_pointer_is_grabbed()) { | |
1605 gdk_pointer_ungrab(GDK_CURRENT_TIME); | |
1606 gtk_grab_remove(widget); | |
1607 } | |
1608 | |
1609 gtkwin = GAIM_GTK_WINDOW(win); | |
1610 | |
4803
6f04901ef729
[gaim-migrate @ 5123]
Christian Hammond <chipx86@chipx86.com>
parents:
4793
diff
changeset
|
1611 if (!gtkwin->in_predrag && !gtkwin->in_drag) |
6f04901ef729
[gaim-migrate @ 5123]
Christian Hammond <chipx86@chipx86.com>
parents:
4793
diff
changeset
|
1612 return FALSE; |
4359 | 1613 |
1614 /* Disconnect the motion signal. */ | |
1615 if (gtkwin->drag_motion_signal) { | |
1616 g_signal_handler_disconnect(G_OBJECT(widget), | |
1617 gtkwin->drag_motion_signal); | |
1618 | |
1619 gtkwin->drag_motion_signal = 0; | |
1620 } | |
1621 | |
1622 /* | |
1623 * If we're in a pre-drag, we'll also need to disconnect the leave | |
1624 * signal. | |
1625 */ | |
1626 if (gtkwin->in_predrag) { | |
1627 gtkwin->in_predrag = FALSE; | |
1628 | |
1629 if (gtkwin->drag_leave_signal) { | |
1630 g_signal_handler_disconnect(G_OBJECT(widget), | |
1631 gtkwin->drag_leave_signal); | |
1632 | |
1633 gtkwin->drag_leave_signal = 0; | |
1634 } | |
1635 } | |
1636 | |
1637 /* If we're not in drag... */ | |
1638 /* We're perfectly normal people! */ | |
4803
6f04901ef729
[gaim-migrate @ 5123]
Christian Hammond <chipx86@chipx86.com>
parents:
4793
diff
changeset
|
1639 if (!gtkwin->in_drag) |
4359 | 1640 return FALSE; |
1641 | |
1642 gtkwin->in_drag = FALSE; | |
1643 | |
1644 dnd_hints_hide_all(); | |
1645 | |
4369
7e1fb422e5fd
[gaim-migrate @ 4635]
Christian Hammond <chipx86@chipx86.com>
parents:
4368
diff
changeset
|
1646 dest_win = gaim_gtkwin_get_at_xy(e->x_root, e->y_root); |
4359 | 1647 |
1648 conv = gaim_window_get_active_conversation(win); | |
1649 | |
1650 if (dest_win == NULL) { | |
1651 if (gaim_window_get_conversation_count(win) < 2) | |
1652 return FALSE; | |
1653 | |
1654 if (gaim_window_get_conversation_count(win) > 1) { | |
1655 /* Make a new window to stick this to. */ | |
1656 struct gaim_window *new_win; | |
4748
d3c09ddfd3aa
[gaim-migrate @ 5063]
Christian Hammond <chipx86@chipx86.com>
parents:
4736
diff
changeset
|
1657 struct gaim_gtk_window *new_gtkwin; |
5121 | 1658 struct gaim_gtk_conversation *gtkconv; |
4748
d3c09ddfd3aa
[gaim-migrate @ 5063]
Christian Hammond <chipx86@chipx86.com>
parents:
4736
diff
changeset
|
1659 gint win_width, win_height; |
5121 | 1660 |
1661 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
4359 | 1662 |
1663 new_win = gaim_window_new(); | |
5121 | 1664 |
5139
d0182ae31ab8
[gaim-migrate @ 5503]
Christian Hammond <chipx86@chipx86.com>
parents:
5133
diff
changeset
|
1665 gaim_window_add_conversation(new_win, |
d0182ae31ab8
[gaim-migrate @ 5503]
Christian Hammond <chipx86@chipx86.com>
parents:
5133
diff
changeset
|
1666 gaim_window_remove_conversation(win, |
d0182ae31ab8
[gaim-migrate @ 5503]
Christian Hammond <chipx86@chipx86.com>
parents:
5133
diff
changeset
|
1667 gaim_conversation_get_index(conv))); |
5121 | 1668 |
4748
d3c09ddfd3aa
[gaim-migrate @ 5063]
Christian Hammond <chipx86@chipx86.com>
parents:
4736
diff
changeset
|
1669 new_gtkwin = GAIM_GTK_WINDOW(new_win); |
d3c09ddfd3aa
[gaim-migrate @ 5063]
Christian Hammond <chipx86@chipx86.com>
parents:
4736
diff
changeset
|
1670 |
d3c09ddfd3aa
[gaim-migrate @ 5063]
Christian Hammond <chipx86@chipx86.com>
parents:
4736
diff
changeset
|
1671 gtk_window_get_size(GTK_WINDOW(new_gtkwin->window), |
d3c09ddfd3aa
[gaim-migrate @ 5063]
Christian Hammond <chipx86@chipx86.com>
parents:
4736
diff
changeset
|
1672 &win_width, &win_height); |
d3c09ddfd3aa
[gaim-migrate @ 5063]
Christian Hammond <chipx86@chipx86.com>
parents:
4736
diff
changeset
|
1673 |
d3c09ddfd3aa
[gaim-migrate @ 5063]
Christian Hammond <chipx86@chipx86.com>
parents:
4736
diff
changeset
|
1674 gtk_window_move(GTK_WINDOW(new_gtkwin->window), |
d3c09ddfd3aa
[gaim-migrate @ 5063]
Christian Hammond <chipx86@chipx86.com>
parents:
4736
diff
changeset
|
1675 e->x_root - (win_width / 2), |
d3c09ddfd3aa
[gaim-migrate @ 5063]
Christian Hammond <chipx86@chipx86.com>
parents:
4736
diff
changeset
|
1676 e->y_root - (win_height / 2)); |
d3c09ddfd3aa
[gaim-migrate @ 5063]
Christian Hammond <chipx86@chipx86.com>
parents:
4736
diff
changeset
|
1677 |
4359 | 1678 gaim_window_show(new_win); |
1679 } | |
1680 | |
1681 return TRUE; | |
1682 } | |
1683 | |
4369
7e1fb422e5fd
[gaim-migrate @ 4635]
Christian Hammond <chipx86@chipx86.com>
parents:
4368
diff
changeset
|
1684 dest_gtkwin = GAIM_GTK_WINDOW(dest_win); |
7e1fb422e5fd
[gaim-migrate @ 4635]
Christian Hammond <chipx86@chipx86.com>
parents:
4368
diff
changeset
|
1685 |
4359 | 1686 /* Get the destination notebook. */ |
1687 dest_notebook = GTK_NOTEBOOK(gtkwin->notebook); | |
1688 | |
1689 /* Get the destination page number. */ | |
1690 dest_page_num = gaim_gtkconv_get_dest_tab_at_xy(dest_win, | |
1691 e->x_root, e->y_root); | |
1692 | |
1693 if (win == dest_win) { | |
1694 gaim_window_move_conversation(win, | |
1695 gaim_conversation_get_index(conv), dest_page_num); | |
1696 } | |
1697 else { | |
1698 size_t pos; | |
1699 | |
1700 gaim_window_remove_conversation(win, | |
1701 gaim_conversation_get_index(conv)); | |
1702 | |
1703 pos = gaim_window_add_conversation(dest_win, conv); | |
1704 | |
1705 gaim_window_move_conversation(dest_win, pos, dest_page_num); | |
1706 | |
1707 gaim_window_switch_conversation(dest_win, dest_page_num); | |
1708 } | |
1709 | |
1710 gtk_widget_grab_focus(GAIM_GTK_CONVERSATION(conv)->entry); | |
1711 | |
1712 return TRUE; | |
1713 } | |
1714 | |
1715 static void | |
1716 switch_conv_cb(GtkNotebook *notebook, GtkWidget *page, gint page_num, | |
1717 gpointer user_data) | |
1718 { | |
1719 struct gaim_window *win; | |
1720 struct gaim_conversation *conv; | |
1721 struct gaim_gtk_conversation *gtkconv; | |
1722 struct gaim_gtk_window *gtkwin; | |
1723 struct gaim_connection *gc; | |
1724 | |
1725 win = (struct gaim_window *)user_data; | |
1726 | |
4598
a064e437d5eb
[gaim-migrate @ 4883]
Christian Hammond <chipx86@chipx86.com>
parents:
4596
diff
changeset
|
1727 conv = gaim_window_get_conversation_at(win, page_num); |
a064e437d5eb
[gaim-migrate @ 4883]
Christian Hammond <chipx86@chipx86.com>
parents:
4596
diff
changeset
|
1728 |
a064e437d5eb
[gaim-migrate @ 4883]
Christian Hammond <chipx86@chipx86.com>
parents:
4596
diff
changeset
|
1729 if (conv == NULL) |
a064e437d5eb
[gaim-migrate @ 4883]
Christian Hammond <chipx86@chipx86.com>
parents:
4596
diff
changeset
|
1730 return; |
a064e437d5eb
[gaim-migrate @ 4883]
Christian Hammond <chipx86@chipx86.com>
parents:
4596
diff
changeset
|
1731 |
4359 | 1732 gc = gaim_conversation_get_gc(conv); |
1733 gtkwin = GAIM_GTK_WINDOW(win); | |
1734 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
1735 | |
1736 gaim_conversation_set_unseen(conv, GAIM_UNSEEN_NONE); | |
1737 | |
4364
fa56829b9587
[gaim-migrate @ 4630]
Christian Hammond <chipx86@chipx86.com>
parents:
4363
diff
changeset
|
1738 if (gc != NULL) { |
fa56829b9587
[gaim-migrate @ 4630]
Christian Hammond <chipx86@chipx86.com>
parents:
4363
diff
changeset
|
1739 gtk_widget_set_sensitive(gtkwin->menu.insert_link, TRUE); |
fa56829b9587
[gaim-migrate @ 4630]
Christian Hammond <chipx86@chipx86.com>
parents:
4363
diff
changeset
|
1740 } |
fa56829b9587
[gaim-migrate @ 4630]
Christian Hammond <chipx86@chipx86.com>
parents:
4363
diff
changeset
|
1741 |
4359 | 1742 /* Update the menubar */ |
1743 if (gaim_conversation_get_type(conv) == GAIM_CONV_IM) { | |
1744 gtk_widget_set_sensitive(gtkwin->menu.view_history, TRUE); | |
1745 gtk_widget_set_sensitive(gtkwin->menu.insert_image, | |
1746 (gc && gc->prpl->options & OPT_PROTO_IM_IMAGE)); | |
1747 | |
1748 if (gtkwin->menu.send_as != NULL) | |
4685 | 1749 g_timeout_add(0, (GSourceFunc)update_send_as_selection, win); |
4359 | 1750 } |
1751 else { | |
1752 gtk_widget_set_sensitive(gtkwin->menu.view_history, FALSE); | |
1753 gtk_widget_set_sensitive(gtkwin->menu.insert_image, FALSE); | |
1754 | |
1755 if (gtkwin->menu.send_as != NULL) | |
1756 gtk_widget_hide(gtkwin->menu.send_as); | |
1757 } | |
1758 | |
4736 | 1759 update_typing_icon(conv); |
1760 | |
4359 | 1761 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(gtkwin->menu.logging), |
1762 gaim_conversation_is_logging(conv)); | |
1763 | |
1764 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(gtkwin->menu.sounds), | |
1765 gtkconv->make_sound); | |
1766 | |
1767 gtk_widget_grab_focus(gtkconv->entry); | |
4681 | 1768 |
4965 | 1769 gtk_window_set_title(GTK_WINDOW(gtkwin->window), |
1770 gtk_label_get_text(GTK_LABEL(gtkconv->tab_label))); | |
4359 | 1771 } |
1772 | |
1773 /************************************************************************** | |
1774 * Utility functions | |
1775 **************************************************************************/ | |
1776 static void | |
1777 do_bold(GtkWidget *bold, struct gaim_gtk_conversation *gtkconv) | |
1778 { | |
1779 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(bold))) | |
1780 gaim_gtk_surround(gtkconv, "<B>", "</B>"); | |
1781 else | |
1782 gaim_gtk_advance_past(gtkconv, "<B>", "</B>"); | |
1783 | |
1784 gtk_widget_grab_focus(gtkconv->entry); | |
1785 } | |
1786 | |
1787 static void | |
1788 do_italic(GtkWidget *italic, struct gaim_gtk_conversation *gtkconv) | |
1789 { | |
1790 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(italic))) | |
1791 gaim_gtk_surround(gtkconv, "<I>", "</I>"); | |
1792 else | |
1793 gaim_gtk_advance_past(gtkconv, "<I>", "</I>"); | |
1794 | |
1795 gtk_widget_grab_focus(gtkconv->entry); | |
1796 } | |
1797 | |
1798 static void | |
1799 do_underline(GtkWidget *underline, struct gaim_gtk_conversation *gtkconv) | |
1800 { | |
1801 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(underline))) | |
1802 gaim_gtk_surround(gtkconv, "<U>", "</U>"); | |
1803 else | |
1804 gaim_gtk_advance_past(gtkconv, "<U>", "</U>"); | |
1805 | |
1806 gtk_widget_grab_focus(gtkconv->entry); | |
1807 } | |
1808 | |
1809 static void | |
1810 do_small(GtkWidget *small, struct gaim_gtk_conversation *gtkconv) | |
1811 { | |
5049 | 1812 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(small))) |
1813 gaim_gtk_surround(gtkconv, "<FONT SIZE=\"1\">", "</FONT>"); | |
1814 else | |
1815 gaim_gtk_advance_past(gtkconv, "<FONT SIZE=\"1\">", "</FONT>"); | |
4359 | 1816 |
1817 gtk_widget_grab_focus(gtkconv->entry); | |
1818 } | |
1819 | |
1820 static void | |
5049 | 1821 do_normal(GtkWidget *normal, struct gaim_gtk_conversation *gtkconv) |
4359 | 1822 { |
5049 | 1823 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(normal))) |
1824 gaim_gtk_surround(gtkconv, "<FONT SIZE=\"3\">", "</FONT>"); | |
1825 else | |
1826 gaim_gtk_advance_past(gtkconv, "<FONT SIZE=\"3\">", "</FONT>"); | |
4359 | 1827 |
1828 gtk_widget_grab_focus(gtkconv->entry); | |
1829 } | |
1830 | |
1831 static void | |
5049 | 1832 do_big(GtkWidget *large, struct gaim_gtk_conversation *gtkconv) |
4359 | 1833 { |
5049 | 1834 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(large))) |
1835 gaim_gtk_surround(gtkconv, "<FONT SIZE=\"5\">", "</FONT>"); | |
1836 else | |
1837 gaim_gtk_advance_past(gtkconv, "<FONT SIZE=\"5\">", "</FONT>"); | |
4359 | 1838 |
1839 gtk_widget_grab_focus(gtkconv->entry); | |
1840 } | |
1841 | |
1842 static void | |
1843 toggle_font(GtkWidget *font, struct gaim_conversation *conv) | |
1844 { | |
1845 struct gaim_gtk_conversation *gtkconv; | |
1846 | |
1847 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
1848 | |
1849 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(font))) | |
1850 show_font_dialog(conv, font); | |
1851 else if (gtkconv->dialogs.fg_color != NULL) | |
1852 cancel_font(font, conv); | |
1853 else | |
1854 gaim_gtk_advance_past(gtkconv, "<FONT FACE>", "</FONT>"); | |
1855 } | |
1856 | |
1857 static void | |
1858 toggle_fg_color(GtkWidget *color, struct gaim_conversation *conv) | |
1859 { | |
1860 struct gaim_gtk_conversation *gtkconv; | |
1861 | |
1862 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
1863 | |
1864 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(color))) | |
1865 show_fgcolor_dialog(conv, color); | |
1866 else if (gtkconv->dialogs.fg_color != NULL) | |
1867 cancel_fgcolor(color, conv); | |
1868 else | |
1869 gaim_gtk_advance_past(gtkconv, "<FONT COLOR>", "</FONT>"); | |
1870 } | |
1871 | |
1872 static void | |
1873 toggle_bg_color(GtkWidget *color, struct gaim_conversation *conv) | |
1874 { | |
1875 struct gaim_gtk_conversation *gtkconv; | |
1876 | |
1877 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
1878 | |
1879 if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(color))) | |
1880 show_bgcolor_dialog(conv, color); | |
1881 else if (gtkconv->dialogs.bg_color != NULL) | |
1882 cancel_bgcolor(color, conv); | |
1883 else | |
1884 gaim_gtk_advance_past(gtkconv, "<BODY BGCOLOR>", "</BODY>"); | |
1885 } | |
1886 | |
1887 static void | |
1888 check_everything(GtkTextBuffer *buffer) | |
1889 { | |
1890 struct gaim_conversation *conv; | |
1891 struct gaim_gtk_conversation *gtkconv; | |
1892 | |
1893 conv = (struct gaim_conversation *)g_object_get_data(G_OBJECT(buffer), | |
1894 "user_data"); | |
1895 | |
1896 if (conv == NULL) | |
1897 return; | |
1898 | |
1899 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
1900 | |
1901 /* CONV TODO */ | |
1902 } | |
1903 | |
1904 static void | |
4685 | 1905 set_toggle(GtkWidget *tb, gboolean active) |
4359 | 1906 { |
1907 gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(tb), active); | |
1908 } | |
1909 | |
1910 static void | |
1911 got_typing_keypress(struct gaim_conversation *conv, gboolean first) | |
1912 { | |
1913 struct gaim_im *im; | |
4685 | 1914 |
4359 | 1915 /* |
1916 * We know we got something, so we at least have to make sure we don't | |
1917 * send TYPED any time soon. | |
1918 */ | |
1919 | |
1920 im = GAIM_IM(conv); | |
1921 | |
1922 if (gaim_im_get_type_again_timeout(im)) | |
1923 gaim_im_stop_type_again_timeout(im); | |
1924 | |
1925 gaim_im_start_type_again_timeout(im); | |
1926 | |
1927 if (first || (gaim_im_get_type_again(im) != 0 && | |
1928 time(NULL) > gaim_im_get_type_again(im))) { | |
1929 | |
1930 int timeout = serv_send_typing(gaim_conversation_get_gc(conv), | |
1931 (char *)gaim_conversation_get_name(conv), | |
1932 TYPING); | |
1933 | |
1934 if (timeout) | |
1935 gaim_im_set_type_again(im, time(NULL) + timeout); | |
1936 else | |
1937 gaim_im_set_type_again(im, 0); | |
1938 } | |
1939 } | |
1940 | |
4736 | 1941 static void |
1942 update_typing_icon(struct gaim_conversation *conv) | |
1943 { | |
1944 struct gaim_gtk_window *gtkwin; | |
1945 struct gaim_im *im = NULL; | |
4757 | 1946 struct gaim_gtk_conversation *gtkconv = GAIM_GTK_CONVERSATION(conv); |
4736 | 1947 |
1948 gtkwin = GAIM_GTK_WINDOW(gaim_conversation_get_window(conv)); | |
1949 | |
1950 if(gaim_conversation_get_type(conv) == GAIM_CONV_IM) | |
1951 im = GAIM_IM(conv); | |
1952 | |
1953 if(gtkwin->menu.typing_icon) { | |
1954 gtk_widget_destroy(gtkwin->menu.typing_icon); | |
1955 gtkwin->menu.typing_icon = NULL; | |
1956 } | |
1957 if(im && gaim_im_get_typing_state(im) == TYPING) { | |
1958 gtkwin->menu.typing_icon = gtk_image_menu_item_new(); | |
1959 gtk_image_menu_item_set_image( | |
1960 GTK_IMAGE_MENU_ITEM(gtkwin->menu.typing_icon), | |
1961 gtk_image_new_from_stock(GAIM_STOCK_TYPING, | |
1962 GTK_ICON_SIZE_MENU)); | |
4757 | 1963 gtk_tooltips_set_tip(gtkconv->tooltips, gtkwin->menu.typing_icon, |
4736 | 1964 _("User is typing..."), NULL); |
1965 } else if(im && gaim_im_get_typing_state(im) == TYPED) { | |
1966 gtkwin->menu.typing_icon = gtk_image_menu_item_new(); | |
1967 gtk_image_menu_item_set_image( | |
1968 GTK_IMAGE_MENU_ITEM(gtkwin->menu.typing_icon), | |
1969 gtk_image_new_from_stock(GAIM_STOCK_TYPED, | |
1970 GTK_ICON_SIZE_MENU)); | |
4757 | 1971 gtk_tooltips_set_tip(gtkconv->tooltips, gtkwin->menu.typing_icon, |
4736 | 1972 _("User has typed something and paused"), NULL); |
1973 } | |
1974 | |
1975 if(gtkwin->menu.typing_icon) { | |
1976 gtk_menu_item_set_right_justified( | |
1977 GTK_MENU_ITEM(gtkwin->menu.typing_icon), TRUE); | |
1978 gtk_widget_show_all(gtkwin->menu.typing_icon); | |
1979 gtk_menu_shell_append(GTK_MENU_SHELL(gtkwin->menu.menubar), | |
1980 gtkwin->menu.typing_icon); | |
1981 } | |
1982 } | |
1983 | |
4685 | 1984 static gboolean |
4359 | 1985 update_send_as_selection(struct gaim_window *win) |
1986 { | |
4491 | 1987 struct gaim_account *account; |
4359 | 1988 struct gaim_conversation *conv; |
1989 struct gaim_gtk_window *gtkwin; | |
1990 GtkWidget *menu; | |
1991 GList *child; | |
1992 | |
4849 | 1993 if (g_list_find(gaim_get_windows(), win) == NULL) |
1994 return FALSE; | |
1995 | |
4359 | 1996 conv = gaim_window_get_active_conversation(win); |
1997 | |
4786 | 1998 |
4359 | 1999 if (conv == NULL) |
4685 | 2000 return FALSE; |
4359 | 2001 |
4491 | 2002 account = gaim_conversation_get_account(conv); |
4359 | 2003 gtkwin = GAIM_GTK_WINDOW(win); |
2004 | |
4491 | 2005 if (account == NULL) |
4685 | 2006 return FALSE; |
4466
473de7371a97
[gaim-migrate @ 4741]
Christian Hammond <chipx86@chipx86.com>
parents:
4465
diff
changeset
|
2007 |
4364
fa56829b9587
[gaim-migrate @ 4630]
Christian Hammond <chipx86@chipx86.com>
parents:
4363
diff
changeset
|
2008 if (gtkwin->menu.send_as == NULL) |
4685 | 2009 return FALSE; |
4364
fa56829b9587
[gaim-migrate @ 4630]
Christian Hammond <chipx86@chipx86.com>
parents:
4363
diff
changeset
|
2010 |
4359 | 2011 gtk_widget_show(gtkwin->menu.send_as); |
2012 | |
2013 menu = gtk_menu_item_get_submenu( | |
2014 GTK_MENU_ITEM(gtkwin->menu.send_as)); | |
2015 | |
2016 for (child = gtk_container_get_children(GTK_CONTAINER(menu)); | |
2017 child != NULL; | |
2018 child = child->next) { | |
2019 | |
2020 GtkWidget *item = child->data; | |
4673 | 2021 struct gaim_account *item_account = g_object_get_data(G_OBJECT(item), |
2022 "gaim_account"); | |
2023 | |
2024 if (account == item_account) { | |
4359 | 2025 gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(item), TRUE); |
2026 break; | |
2027 } | |
2028 } | |
4685 | 2029 return FALSE; |
4359 | 2030 } |
2031 | |
2032 static void | |
4360
c435a29370b8
[gaim-migrate @ 4626]
Christian Hammond <chipx86@chipx86.com>
parents:
4359
diff
changeset
|
2033 generate_send_as_items(struct gaim_window *win, |
c435a29370b8
[gaim-migrate @ 4626]
Christian Hammond <chipx86@chipx86.com>
parents:
4359
diff
changeset
|
2034 struct gaim_conversation *deleted_conv) |
4359 | 2035 { |
2036 struct gaim_gtk_window *gtkwin; | |
2037 GtkWidget *menu; | |
2038 GtkWidget *menuitem; | |
2039 GSList *gcs; | |
2040 GList *convs; | |
2041 GSList *group = NULL; | |
2042 gboolean first_offline = TRUE; | |
2043 gboolean found_online = FALSE; | |
4669
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2044 GtkSizeGroup *sg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL); |
4359 | 2045 |
2046 gtkwin = GAIM_GTK_WINDOW(win); | |
2047 | |
2048 if (gtkwin->menu.send_as != NULL) | |
2049 gtk_widget_destroy(gtkwin->menu.send_as); | |
2050 | |
2051 /* See if we have > 1 connection active. */ | |
2052 if (g_slist_length(connections) < 2) { | |
2053 /* Now make sure we don't have any Offline entries. */ | |
2054 gboolean found_offline = FALSE; | |
2055 | |
2056 for (convs = gaim_get_conversations(); | |
2057 convs != NULL; | |
2058 convs = convs->next) { | |
2059 | |
2060 struct gaim_conversation *conv; | |
4491 | 2061 struct gaim_account *account; |
2062 | |
4359 | 2063 conv = (struct gaim_conversation *)convs->data; |
4491 | 2064 account = gaim_conversation_get_account(conv); |
2065 | |
2066 if (account->gc == NULL) { | |
4359 | 2067 found_offline = TRUE; |
2068 break; | |
2069 } | |
2070 } | |
2071 | |
2072 if (!found_offline) { | |
2073 gtkwin->menu.send_as = NULL; | |
2074 return; | |
2075 } | |
2076 } | |
2077 | |
2078 /* Build the Send As menu */ | |
2079 gtkwin->menu.send_as = gtk_menu_item_new_with_mnemonic(_("_Send As")); | |
2080 gtk_widget_show(gtkwin->menu.send_as); | |
2081 | |
2082 menu = gtk_menu_new(); | |
2083 | |
2084 gtk_menu_shell_append(GTK_MENU_SHELL(gtkwin->menu.menubar), | |
2085 gtkwin->menu.send_as); | |
2086 gtk_menu_item_set_submenu(GTK_MENU_ITEM(gtkwin->menu.send_as), menu); | |
2087 | |
2088 gtk_widget_show(menu); | |
2089 | |
2090 /* Fill it with entries. */ | |
2091 for (gcs = connections; gcs != NULL; gcs = gcs->next) { | |
4668
6e7196dcfd37
[gaim-migrate @ 4979]
Christian Hammond <chipx86@chipx86.com>
parents:
4640
diff
changeset
|
2092 |
4359 | 2093 struct gaim_connection *gc; |
4669
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2094 GtkWidget *box; |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2095 GtkWidget *label; |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2096 GtkWidget *image; |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
2097 GdkPixbuf *pixbuf, *scale; |
4359 | 2098 |
2099 found_online = TRUE; | |
2100 | |
2101 gc = (struct gaim_connection *)gcs->data; | |
2102 | |
4669
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2103 /* Create a pixmap for the protocol icon. */ |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
2104 pixbuf = create_prpl_icon(gc->account); |
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
2105 scale = gdk_pixbuf_scale_simple(pixbuf, 16, 16, GDK_INTERP_BILINEAR); |
4669
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2106 |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2107 /* Now convert it to GtkImage */ |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
2108 if (pixbuf == NULL) |
4669
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2109 image = gtk_image_new(); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2110 else |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
2111 image = gtk_image_new_from_pixbuf(scale); |
4669
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2112 |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2113 gtk_size_group_add_widget(sg, image); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2114 |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
2115 g_object_unref(G_OBJECT(scale)); |
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
2116 g_object_unref(G_OBJECT(pixbuf)); |
4669
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2117 |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2118 /* Make our menu item */ |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2119 menuitem = gtk_radio_menu_item_new_with_label(group, gc->username); |
4793 | 2120 group = gtk_radio_menu_item_get_group(GTK_RADIO_MENU_ITEM(menuitem)); |
4359 | 2121 |
4669
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2122 /* Do some evil, see some evil, speak some evil. */ |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2123 box = gtk_hbox_new(FALSE, 0); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2124 |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2125 label = gtk_bin_get_child(GTK_BIN(menuitem)); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2126 g_object_ref(label); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2127 gtk_container_remove(GTK_CONTAINER(menuitem), label); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2128 |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2129 gtk_box_pack_start(GTK_BOX(box), image, FALSE, FALSE, 0); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2130 gtk_box_pack_start(GTK_BOX(box), label, TRUE, TRUE, 4); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2131 |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2132 g_object_unref(label); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2133 |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2134 gtk_container_add(GTK_CONTAINER(menuitem), box); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2135 |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2136 gtk_widget_show(label); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2137 gtk_widget_show(image); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2138 gtk_widget_show(box); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2139 |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2140 /* Set our data and callbacks. */ |
4359 | 2141 g_object_set_data(G_OBJECT(menuitem), "user_data", win); |
4673 | 2142 g_object_set_data(G_OBJECT(menuitem), "gaim_account", gc->account); |
4359 | 2143 |
4786 | 2144 g_signal_connect(G_OBJECT(menuitem), "activate", |
4673 | 2145 G_CALLBACK(menu_conv_sel_send_cb), NULL); |
4359 | 2146 |
2147 gtk_widget_show(menuitem); | |
2148 gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem); | |
2149 } | |
2150 | |
2151 /* | |
2152 * Fill it with any accounts that still has an open (yet disabled) window | |
2153 * (signed off accounts with a window open). | |
2154 */ | |
2155 for (convs = gaim_get_conversations(); | |
2156 convs != NULL; | |
2157 convs = convs->next) { | |
2158 | |
2159 struct gaim_conversation *conv; | |
4491 | 2160 struct gaim_account *account; |
4669
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2161 GtkWidget *box; |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2162 GtkWidget *label; |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2163 GtkWidget *image; |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
2164 GdkPixbuf *pixbuf, *scale; |
4359 | 2165 |
2166 conv = (struct gaim_conversation *)convs->data; | |
4360
c435a29370b8
[gaim-migrate @ 4626]
Christian Hammond <chipx86@chipx86.com>
parents:
4359
diff
changeset
|
2167 |
c435a29370b8
[gaim-migrate @ 4626]
Christian Hammond <chipx86@chipx86.com>
parents:
4359
diff
changeset
|
2168 if (conv == deleted_conv) |
c435a29370b8
[gaim-migrate @ 4626]
Christian Hammond <chipx86@chipx86.com>
parents:
4359
diff
changeset
|
2169 continue; |
c435a29370b8
[gaim-migrate @ 4626]
Christian Hammond <chipx86@chipx86.com>
parents:
4359
diff
changeset
|
2170 |
4491 | 2171 account = gaim_conversation_get_account(conv); |
2172 | |
4786 | 2173 |
4491 | 2174 if (account->gc == NULL) { |
4359 | 2175 if (first_offline && found_online) { |
2176 menuitem = gtk_separator_menu_item_new(); | |
2177 gtk_widget_show(menuitem); | |
2178 gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem); | |
2179 | |
2180 first_offline = FALSE; | |
2181 } | |
2182 | |
4669
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2183 /* Create a pixmap for the protocol icon. */ |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
2184 pixbuf = create_prpl_icon(account); |
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
2185 scale = gdk_pixbuf_scale_simple(pixbuf, 16, 16, |
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
2186 GDK_INTERP_BILINEAR); |
4669
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2187 |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2188 /* Now convert it to GtkImage */ |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
2189 if (pixbuf == NULL) |
4669
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2190 image = gtk_image_new(); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2191 else |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
2192 image = gtk_image_new_from_pixbuf(scale); |
4669
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2193 |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2194 gtk_size_group_add_widget(sg, image); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2195 |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
2196 if (scale != NULL) g_object_unref(scale); |
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
2197 if (pixbuf != NULL) g_object_unref(pixbuf); |
4669
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2198 |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2199 /* Make our menu item */ |
4359 | 2200 menuitem = gtk_radio_menu_item_new_with_label(group, |
4491 | 2201 account->username); |
4793 | 2202 group = gtk_radio_menu_item_get_group(GTK_RADIO_MENU_ITEM(menuitem)); |
4359 | 2203 |
4669
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2204 /* Do some evil, see some evil, speak some evil. */ |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2205 box = gtk_hbox_new(FALSE, 0); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2206 |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2207 label = gtk_bin_get_child(GTK_BIN(menuitem)); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2208 g_object_ref(label); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2209 gtk_container_remove(GTK_CONTAINER(menuitem), label); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2210 |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2211 gtk_box_pack_start(GTK_BOX(box), image, FALSE, FALSE, 0); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2212 gtk_box_pack_start(GTK_BOX(box), label, TRUE, TRUE, 4); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2213 |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2214 g_object_unref(label); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2215 |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2216 gtk_container_add(GTK_CONTAINER(menuitem), box); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2217 |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2218 gtk_widget_show(label); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2219 gtk_widget_show(image); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2220 gtk_widget_show(box); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2221 |
4359 | 2222 gtk_widget_set_sensitive(menuitem, FALSE); |
4786 | 2223 g_object_set_data(G_OBJECT(menuitem), "user_data", win); |
4674 | 2224 g_object_set_data(G_OBJECT(menuitem), "gaim_account", account); |
4359 | 2225 |
4786 | 2226 g_signal_connect(G_OBJECT(menuitem), "activate", |
2227 G_CALLBACK(menu_conv_sel_send_cb), NULL); | |
2228 | |
4359 | 2229 gtk_widget_show(menuitem); |
2230 gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem); | |
2231 } | |
2232 } | |
2233 | |
4669
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2234 g_object_unref(sg); |
d715736164ae
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2235 |
4359 | 2236 gtk_widget_show(gtkwin->menu.send_as); |
2237 update_send_as_selection(win); | |
2238 } | |
2239 | |
2240 static GList * | |
2241 generate_invite_user_names(struct gaim_connection *gc) | |
2242 { | |
4785 | 2243 GaimBlistNode *gnode,*bnode; |
4359 | 2244 struct group *g; |
2245 struct buddy *buddy; | |
2246 static GList *tmp = NULL; | |
2247 | |
2248 if (tmp) | |
2249 g_list_free(tmp); | |
2250 | |
2251 tmp = g_list_append(NULL, ""); | |
2252 | |
2253 if (gc != NULL) { | |
4785 | 2254 for(gnode = gaim_get_blist()->root; gnode; gnode = gnode->next) { |
2255 if(!GAIM_BLIST_NODE_IS_GROUP(gnode)) | |
2256 continue; | |
2257 g = (struct group *)gnode; | |
2258 for(bnode = gnode->child; bnode; bnode = bnode->next) { | |
2259 if(!GAIM_BLIST_NODE_IS_BUDDY(bnode)) | |
2260 continue; | |
2261 buddy = (struct buddy *)bnode; | |
2262 | |
5068 | 2263 if (buddy->account == gc->account && GAIM_BUDDY_IS_ONLINE(buddy)) |
4359 | 2264 tmp = g_list_append(tmp, buddy->name); |
2265 } | |
2266 } | |
2267 } | |
2268 | |
2269 return tmp; | |
2270 } | |
2271 | |
2272 static void | |
2273 add_chat_buddy_common(struct gaim_conversation *conv, const char *name, | |
2274 int pos) | |
2275 { | |
2276 struct gaim_gtk_conversation *gtkconv; | |
2277 struct gaim_gtk_chat_pane *gtkchat; | |
2278 struct gaim_chat *chat; | |
2279 GtkTreeIter iter; | |
2280 GtkListStore *ls; | |
2281 | |
2282 chat = GAIM_CHAT(conv); | |
2283 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
2284 gtkchat = gtkconv->u.chat; | |
2285 | |
2286 ls = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list))); | |
2287 | |
2288 gtk_list_store_append(ls, &iter); | |
2289 gtk_list_store_set(ls, &iter, 0, | |
2290 (gaim_chat_is_user_ignored(chat, name) ? "X" : " "), | |
2291 1, name, -1); | |
2292 gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(ls), 1, | |
2293 GTK_SORT_ASCENDING); | |
2294 } | |
2295 | |
2296 static void | |
2297 tab_complete(struct gaim_conversation *conv) | |
2298 { | |
2299 struct gaim_gtk_conversation *gtkconv; | |
2300 struct gaim_chat *chat; | |
2301 GtkTextIter cursor, word_start, start_buffer; | |
2302 int start; | |
2303 int most_matched = -1; | |
2304 char *entered, *partial = NULL; | |
2305 char *text; | |
2306 GList *matches = NULL; | |
2307 GList *nicks = NULL; | |
2308 | |
2309 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
2310 chat = GAIM_CHAT(conv); | |
2311 | |
2312 gtk_text_buffer_get_start_iter(gtkconv->entry_buffer, &start_buffer); | |
2313 gtk_text_buffer_get_iter_at_mark(gtkconv->entry_buffer, &cursor, | |
2314 gtk_text_buffer_get_insert(gtkconv->entry_buffer)); | |
2315 | |
2316 word_start = cursor; | |
2317 | |
2318 /* if there's nothing there just return */ | |
2319 if (!gtk_text_iter_compare(&cursor, &start_buffer)) | |
2320 return; | |
2321 | |
2322 text = gtk_text_buffer_get_text(gtkconv->entry_buffer, &start_buffer, | |
2323 &cursor, FALSE); | |
2324 | |
2325 /* if we're at the end of ": " we need to move back 2 spaces */ | |
2326 start = strlen(text) - 1; | |
2327 | |
2328 if (strlen(text) >= 2 && !strncmp(&text[start-1], ": ", 2)) | |
2329 gtk_text_iter_backward_chars(&word_start, 2); | |
2330 | |
2331 /* find the start of the word that we're tabbing */ | |
2332 while (start >= 0 && text[start] != ' ') { | |
2333 gtk_text_iter_backward_char(&word_start); | |
2334 start--; | |
2335 } | |
2336 | |
2337 g_free(text); | |
2338 | |
2339 entered = gtk_text_buffer_get_text(gtkconv->entry_buffer, &word_start, | |
2340 &cursor, FALSE); | |
2341 | |
2342 if (chat_options & OPT_CHAT_OLD_STYLE_TAB) { | |
2343 if (strlen(entered) >= 2 && | |
2344 !strncmp(": ", entered + strlen(entered) - 2, 2)) { | |
2345 | |
2346 entered[strlen(entered) - 2] = 0; | |
2347 } | |
2348 } | |
2349 | |
2350 if (!strlen(entered)) { | |
2351 g_free(entered); | |
2352 return; | |
2353 } | |
2354 | |
2355 for (nicks = gaim_chat_get_users(chat); | |
2356 nicks != NULL; | |
2357 nicks = nicks->next) { | |
2358 | |
2359 char *nick = nicks->data; | |
2360 /* this checks to see if the current nick could be a completion */ | |
4793 | 2361 if (g_ascii_strncasecmp(nick, entered, strlen(entered))) { |
4621
69f028a6f357
[gaim-migrate @ 4912]
Christian Hammond <chipx86@chipx86.com>
parents:
4608
diff
changeset
|
2362 if (*nick != '+' && *nick != '@' && *nick != '%') |
4359 | 2363 continue; |
2364 | |
4793 | 2365 if (g_ascii_strncasecmp(nick + 1, entered, strlen(entered))) { |
4359 | 2366 if (nick[0] != '@' || nick[1] != '+') |
2367 continue; | |
2368 | |
4793 | 2369 if (g_ascii_strncasecmp(nick + 2, entered, strlen(entered))) |
4359 | 2370 continue; |
2371 else | |
2372 nick += 2; | |
2373 } | |
2374 else | |
2375 nick++; | |
2376 } | |
2377 | |
2378 /* if we're here, it's a possible completion */ | |
2379 | |
2380 /* if we're doing old-style, just fill in the completion */ | |
2381 if (chat_options & OPT_CHAT_OLD_STYLE_TAB) { | |
2382 gtk_text_buffer_delete(gtkconv->entry_buffer, | |
2383 &word_start, &cursor); | |
2384 | |
2385 if (strlen(nick) == strlen(entered)) { | |
2386 nicks = (nicks->next | |
2387 ? nicks->next | |
2388 : gaim_chat_get_users(chat)); | |
2389 | |
2390 nick = nicks->data; | |
2391 | |
2392 if (*nick == '@') nick++; | |
4621
69f028a6f357
[gaim-migrate @ 4912]
Christian Hammond <chipx86@chipx86.com>
parents:
4608
diff
changeset
|
2393 if (*nick == '%') nick++; |
4359 | 2394 if (*nick == '+') nick++; |
2395 } | |
2396 | |
2397 gtk_text_buffer_get_start_iter(gtkconv->entry_buffer, | |
2398 &start_buffer); | |
2399 gtk_text_buffer_get_iter_at_mark(gtkconv->entry_buffer, &cursor, | |
2400 gtk_text_buffer_get_insert(gtkconv->entry_buffer)); | |
2401 | |
2402 if (!gtk_text_iter_compare(&cursor, &start_buffer)) { | |
2403 char *tmp = g_strdup_printf("%s: ", nick); | |
2404 gtk_text_buffer_insert_at_cursor(gtkconv->entry_buffer, | |
2405 tmp, -1); | |
2406 g_free(tmp); | |
2407 } | |
2408 else | |
2409 gtk_text_buffer_insert_at_cursor(gtkconv->entry_buffer, | |
2410 nick, -1); | |
2411 | |
2412 g_free(entered); | |
2413 | |
2414 return; | |
2415 } | |
2416 | |
2417 /* we're only here if we're doing new style */ | |
2418 if (most_matched == -1) { | |
2419 /* | |
2420 * this will only get called once, since from now | |
2421 * on most_matched is >= 0 | |
2422 */ | |
2423 most_matched = strlen(nick); | |
2424 partial = g_strdup(nick); | |
2425 } | |
2426 else if (most_matched) { | |
4793 | 2427 while (g_ascii_strncasecmp(nick, partial, most_matched)) |
4359 | 2428 most_matched--; |
2429 | |
2430 partial[most_matched] = 0; | |
2431 } | |
2432 | |
2433 matches = g_list_append(matches, nick); | |
2434 } | |
2435 | |
2436 /* we're only here if we're doing new style */ | |
2437 | |
2438 /* if there weren't any matches, return */ | |
2439 if (!matches) { | |
2440 /* if matches isn't set partials won't be either */ | |
2441 g_free(entered); | |
2442 return; | |
2443 } | |
2444 | |
2445 gtk_text_buffer_delete(gtkconv->entry_buffer, &word_start, &cursor); | |
2446 | |
2447 if (!matches->next) { | |
2448 /* there was only one match. fill it in. */ | |
2449 gtk_text_buffer_get_start_iter(gtkconv->entry_buffer, &start_buffer); | |
2450 gtk_text_buffer_get_iter_at_mark(gtkconv->entry_buffer, &cursor, | |
2451 gtk_text_buffer_get_insert(gtkconv->entry_buffer)); | |
2452 | |
2453 if (!gtk_text_iter_compare(&cursor, &start_buffer)) { | |
2454 char *tmp = g_strdup_printf("%s: ", (char *)matches->data); | |
2455 gtk_text_buffer_insert_at_cursor(gtkconv->entry_buffer, tmp, -1); | |
2456 g_free(tmp); | |
2457 } | |
2458 else | |
2459 gtk_text_buffer_insert_at_cursor(gtkconv->entry_buffer, | |
2460 matches->data, -1); | |
2461 | |
2462 matches = g_list_remove(matches, matches->data); | |
2463 } | |
2464 else { | |
2465 /* | |
2466 * there were lots of matches, fill in as much as possible | |
2467 * and display all of them | |
2468 */ | |
2469 char *addthis = g_malloc0(1); | |
2470 | |
2471 while (matches) { | |
2472 char *tmp = addthis; | |
2473 addthis = g_strconcat(tmp, matches->data, " ", NULL); | |
2474 g_free(tmp); | |
2475 matches = g_list_remove(matches, matches->data); | |
2476 } | |
2477 | |
2478 gaim_conversation_write(conv, NULL, addthis, -1, WFLAG_NOLOG, | |
2479 time(NULL)); | |
2480 gtk_text_buffer_insert_at_cursor(gtkconv->entry_buffer, partial, -1); | |
2481 g_free(addthis); | |
2482 } | |
2483 | |
2484 g_free(entered); | |
2485 g_free(partial); | |
2486 } | |
2487 | |
2488 static gboolean | |
2489 meify(char *message, size_t len) | |
2490 { | |
2491 /* | |
2492 * Read /me-ify: If the message (post-HTML) starts with /me, | |
2493 * remove the "/me " part of it (including that space) and return TRUE. | |
2494 */ | |
2495 char *c; | |
2496 gboolean inside_html = 0; | |
2497 | |
2498 if (message == NULL) | |
2499 return FALSE; /* Umm.. this would be very bad if this happens. */ | |
2500 | |
2501 if (len == -1) | |
2502 len = strlen(message); | |
2503 | |
2504 for (c = message; *c != '\0'; c++, len--) { | |
2505 if (inside_html) { | |
2506 if (*c == '>') | |
2507 inside_html = FALSE; | |
2508 } | |
2509 else { | |
2510 if (*c == '<') | |
2511 inside_html = TRUE; | |
2512 else | |
2513 break; | |
2514 } | |
2515 } | |
2516 | |
4793 | 2517 if (*c != '\0' && !g_ascii_strncasecmp(c, "/me ", 4)) { |
4359 | 2518 memmove(c, c + 4, len - 3); |
2519 | |
2520 return TRUE; | |
2521 } | |
2522 | |
2523 return FALSE; | |
2524 } | |
2525 | |
2526 static GtkItemFactoryEntry menu_items[] = | |
2527 { | |
2528 /* Conversation menu */ | |
4596 | 2529 { N_("/_Conversation"), NULL, NULL, 0, "<Branch>" }, |
2530 { N_("/Conversation/_Save As..."), NULL, menu_save_as_cb, 0, | |
4359 | 2531 "<StockItem>", GTK_STOCK_SAVE_AS }, |
4596 | 2532 { N_("/Conversation/View _History..."), NULL, menu_view_history_cb, 0, NULL }, |
4359 | 2533 { "/Conversation/sep1", NULL, NULL, 0, "<Separator>" }, |
4596 | 2534 { N_("/Conversation/Insert _URL..."), NULL, menu_insert_link_cb, 0, |
4359 | 2535 "<StockItem>", GAIM_STOCK_LINK }, |
4596 | 2536 { N_("/Conversation/Insert _Image..."), NULL, menu_insert_image_cb, 0, |
4359 | 2537 "<StockItem>", GAIM_STOCK_IMAGE }, |
2538 { "/Conversation/sep2", NULL, NULL, 0, "<Separator>" }, | |
4596 | 2539 { N_("/Conversation/_Close"), NULL, menu_close_conv_cb, 0, |
4359 | 2540 "<StockItem>", GTK_STOCK_CLOSE }, |
2541 | |
2542 /* Options */ | |
4596 | 2543 { N_("/_Options"), NULL, NULL, 0, "<Branch>" }, |
2544 { N_("/Options/Enable _Logging"), NULL, menu_logging_cb, 0, "<CheckItem>" }, | |
2545 { N_("/Options/Enable _Sounds"), NULL, menu_sounds_cb, 0, "<CheckItem>" }, | |
4359 | 2546 }; |
2547 | |
4602
4128761bacb8
[gaim-migrate @ 4889]
Christian Hammond <chipx86@chipx86.com>
parents:
4598
diff
changeset
|
2548 static const int menu_item_count = |
4359 | 2549 sizeof(menu_items) / sizeof(*menu_items); |
2550 | |
4602
4128761bacb8
[gaim-migrate @ 4889]
Christian Hammond <chipx86@chipx86.com>
parents:
4598
diff
changeset
|
2551 static char * |
4128761bacb8
[gaim-migrate @ 4889]
Christian Hammond <chipx86@chipx86.com>
parents:
4598
diff
changeset
|
2552 item_factory_translate_func (const char *path, gpointer func_data) |
4128761bacb8
[gaim-migrate @ 4889]
Christian Hammond <chipx86@chipx86.com>
parents:
4598
diff
changeset
|
2553 { |
4128761bacb8
[gaim-migrate @ 4889]
Christian Hammond <chipx86@chipx86.com>
parents:
4598
diff
changeset
|
2554 return _(path); |
4128761bacb8
[gaim-migrate @ 4889]
Christian Hammond <chipx86@chipx86.com>
parents:
4598
diff
changeset
|
2555 } |
4128761bacb8
[gaim-migrate @ 4889]
Christian Hammond <chipx86@chipx86.com>
parents:
4598
diff
changeset
|
2556 |
4359 | 2557 static GtkWidget * |
2558 setup_menubar(struct gaim_window *win) | |
2559 { | |
2560 struct gaim_gtk_window *gtkwin; | |
5116 | 2561 GtkAccelGroup *accel_group; |
4359 | 2562 gtkwin = GAIM_GTK_WINDOW(win); |
2563 | |
5116 | 2564 accel_group = gtk_accel_group_new (); |
2565 gtk_window_add_accel_group (GTK_WINDOW (gtkwin->window), accel_group); | |
2566 g_object_unref (accel_group); | |
2567 | |
4630 | 2568 gtkwin->menu.item_factory = gtk_item_factory_new(GTK_TYPE_MENU_BAR, |
5116 | 2569 "<main>", accel_group); |
4630 | 2570 |
2571 gtk_item_factory_set_translate_func (gtkwin->menu.item_factory, | |
4602
4128761bacb8
[gaim-migrate @ 4889]
Christian Hammond <chipx86@chipx86.com>
parents:
4598
diff
changeset
|
2572 item_factory_translate_func, |
4128761bacb8
[gaim-migrate @ 4889]
Christian Hammond <chipx86@chipx86.com>
parents:
4598
diff
changeset
|
2573 NULL, NULL); |
4630 | 2574 |
2575 gtk_item_factory_create_items(gtkwin->menu.item_factory, menu_item_count, | |
4359 | 2576 menu_items, win); |
2577 | |
4630 | 2578 gtkwin->menu.menubar = gtk_item_factory_get_widget(gtkwin->menu.item_factory, |
2579 "<main>"); | |
2580 gtkwin->menu.view_history = gtk_item_factory_get_widget(gtkwin->menu.item_factory, | |
4834 | 2581 N_("/Conversation/View History...")); |
4630 | 2582 gtkwin->menu.insert_link = gtk_item_factory_get_widget(gtkwin->menu.item_factory, |
4834 | 2583 N_("/Conversation/Insert URL...")); |
4630 | 2584 gtkwin->menu.insert_image = gtk_item_factory_get_widget(gtkwin->menu.item_factory, |
4834 | 2585 N_("/Conversation/Insert Image...")); |
4630 | 2586 gtkwin->menu.logging = gtk_item_factory_get_widget(gtkwin->menu.item_factory, |
4834 | 2587 N_("/Options/Enable Logging")); |
4630 | 2588 gtkwin->menu.sounds = gtk_item_factory_get_widget(gtkwin->menu.item_factory, |
4834 | 2589 N_("/Options/Enable Sounds")); |
4359 | 2590 |
4360
c435a29370b8
[gaim-migrate @ 4626]
Christian Hammond <chipx86@chipx86.com>
parents:
4359
diff
changeset
|
2591 generate_send_as_items(win, NULL); |
4359 | 2592 |
2593 gtk_widget_show(gtkwin->menu.menubar); | |
4931 | 2594 |
2595 return gtkwin->menu.menubar; | |
4359 | 2596 } |
2597 | |
2598 static void | |
2599 setup_im_buttons(struct gaim_conversation *conv, GtkWidget *parent) | |
2600 { | |
2601 struct gaim_connection *gc; | |
2602 struct gaim_gtk_conversation *gtkconv; | |
2603 struct gaim_gtk_im_pane *gtkim; | |
2604 GaimConversationType type = GAIM_CONV_IM; | |
2605 | |
2606 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
2607 gtkim = gtkconv->u.im; | |
2608 gc = gaim_conversation_get_gc(conv); | |
2609 | |
2610 /* From right to left... */ | |
2611 | |
2612 /* Send button */ | |
2613 gtkconv->send = gaim_gtk_change_text(_("Send"), gtkconv->send, | |
2614 GAIM_STOCK_SEND, type); | |
2615 gtk_tooltips_set_tip(gtkconv->tooltips, gtkconv->send, _("Send"), NULL); | |
2616 | |
2617 gtk_box_pack_end(GTK_BOX(parent), gtkconv->send, FALSE, FALSE, 0); | |
2618 | |
2619 /* Separator */ | |
2620 if (gtkim->sep2 != NULL) | |
2621 gtk_widget_destroy(gtkim->sep2); | |
2622 | |
2623 gtkim->sep2 = gtk_vseparator_new(); | |
2624 gtk_box_pack_end(GTK_BOX(parent), gtkim->sep2, FALSE, TRUE, 0); | |
2625 gtk_widget_show(gtkim->sep2); | |
2626 | |
2627 /* Now, um, just kind of all over the place. Huh? */ | |
2628 | |
2629 /* Add button */ | |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
2630 if (gaim_find_buddy(gaim_conversation_get_account(conv), |
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
2631 gaim_conversation_get_name(conv)) == NULL) { |
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
2632 |
4359 | 2633 gtkim->add = gaim_gtk_change_text(_("Add"), gtkim->add, |
2634 GTK_STOCK_ADD, type); | |
2635 gtk_tooltips_set_tip(gtkconv->tooltips, gtkim->add, | |
4370
d856987c72ca
[gaim-migrate @ 4636]
Christian Hammond <chipx86@chipx86.com>
parents:
4369
diff
changeset
|
2636 _("Add the user to your buddy list"), NULL); |
4359 | 2637 } |
2638 else { | |
2639 gtkim->add = gaim_gtk_change_text(_("Remove"), gtkim->add, | |
2640 GTK_STOCK_REMOVE, type); | |
2641 gtk_tooltips_set_tip(gtkconv->tooltips, gtkim->add, | |
4370
d856987c72ca
[gaim-migrate @ 4636]
Christian Hammond <chipx86@chipx86.com>
parents:
4369
diff
changeset
|
2642 _("Remove the user from your buddy list"), NULL); |
4359 | 2643 } |
2644 | |
2645 gtk_box_pack_start(GTK_BOX(parent), gtkim->add, | |
2646 FALSE, FALSE, 0); | |
2647 | |
2648 /* Warn button */ | |
2649 gtkim->warn = gaim_gtk_change_text(_("Warn"), gtkim->warn, | |
2650 GAIM_STOCK_WARN, type); | |
2651 gtk_box_pack_start(GTK_BOX(parent), gtkim->warn, FALSE, FALSE, 0); | |
4370
d856987c72ca
[gaim-migrate @ 4636]
Christian Hammond <chipx86@chipx86.com>
parents:
4369
diff
changeset
|
2652 gtk_tooltips_set_tip(gtkconv->tooltips, gtkim->warn, |
d856987c72ca
[gaim-migrate @ 4636]
Christian Hammond <chipx86@chipx86.com>
parents:
4369
diff
changeset
|
2653 _("Warn the user"), NULL); |
4359 | 2654 |
2655 /* Info button */ | |
2656 gtkconv->info = gaim_gtk_change_text(_("Info"), gtkconv->info, | |
2657 GAIM_STOCK_INFO, type); | |
2658 gtk_box_pack_start(GTK_BOX(parent), gtkconv->info, FALSE, FALSE, 0); | |
2659 gtk_tooltips_set_tip(gtkconv->tooltips, gtkconv->info, | |
4370
d856987c72ca
[gaim-migrate @ 4636]
Christian Hammond <chipx86@chipx86.com>
parents:
4369
diff
changeset
|
2660 _("Get the user's information"), NULL); |
4359 | 2661 |
2662 /* Block button */ | |
2663 gtkim->block = gaim_gtk_change_text(_("Block"), gtkim->block, | |
2664 GAIM_STOCK_BLOCK, type); | |
2665 gtk_box_pack_start(GTK_BOX(parent), gtkim->block, FALSE, FALSE, 0); | |
2666 gtk_tooltips_set_tip(gtkconv->tooltips, gtkim->block, | |
4370
d856987c72ca
[gaim-migrate @ 4636]
Christian Hammond <chipx86@chipx86.com>
parents:
4369
diff
changeset
|
2667 _("Block the user"), NULL); |
4359 | 2668 |
2669 gtk_button_set_relief(GTK_BUTTON(gtkconv->info), GTK_RELIEF_NONE); | |
2670 gtk_button_set_relief(GTK_BUTTON(gtkim->add), GTK_RELIEF_NONE); | |
2671 gtk_button_set_relief(GTK_BUTTON(gtkim->warn), GTK_RELIEF_NONE); | |
2672 gtk_button_set_relief(GTK_BUTTON(gtkconv->send), GTK_RELIEF_NONE); | |
2673 gtk_button_set_relief(GTK_BUTTON(gtkim->block), GTK_RELIEF_NONE); | |
2674 | |
2675 gtk_size_group_add_widget(gtkconv->sg, gtkconv->info); | |
2676 gtk_size_group_add_widget(gtkconv->sg, gtkim->add); | |
2677 gtk_size_group_add_widget(gtkconv->sg, gtkim->warn); | |
2678 gtk_size_group_add_widget(gtkconv->sg, gtkconv->send); | |
2679 gtk_size_group_add_widget(gtkconv->sg, gtkim->block); | |
2680 | |
2681 gtk_box_reorder_child(GTK_BOX(parent), gtkim->warn, 1); | |
2682 gtk_box_reorder_child(GTK_BOX(parent), gtkim->block, 2); | |
4370
d856987c72ca
[gaim-migrate @ 4636]
Christian Hammond <chipx86@chipx86.com>
parents:
4369
diff
changeset
|
2683 gtk_box_reorder_child(GTK_BOX(parent), gtkim->add, 3); |
4359 | 2684 gtk_box_reorder_child(GTK_BOX(parent), gtkconv->info, 4); |
2685 | |
2686 gaim_gtkconv_update_buttons_by_protocol(conv); | |
2687 | |
2688 g_signal_connect(G_OBJECT(gtkconv->send), "clicked", | |
2689 G_CALLBACK(send_cb), conv); | |
2690 g_signal_connect(G_OBJECT(gtkconv->info), "clicked", | |
2691 G_CALLBACK(info_cb), conv); | |
2692 g_signal_connect(G_OBJECT(gtkim->warn), "clicked", | |
2693 G_CALLBACK(warn_cb), conv); | |
2694 g_signal_connect(G_OBJECT(gtkim->block), "clicked", | |
2695 G_CALLBACK(block_cb), conv); | |
2696 } | |
2697 | |
2698 static void | |
2699 setup_chat_buttons(struct gaim_conversation *conv, GtkWidget *parent) | |
2700 { | |
2701 struct gaim_connection *gc; | |
2702 struct gaim_gtk_conversation *gtkconv; | |
2703 struct gaim_gtk_chat_pane *gtkchat; | |
2704 struct gaim_gtk_window *gtkwin; | |
2705 GtkWidget *sep; | |
2706 | |
2707 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
2708 gtkchat = gtkconv->u.chat; | |
2709 gtkwin = GAIM_GTK_WINDOW(gaim_conversation_get_window(conv)); | |
2710 gc = gaim_conversation_get_gc(conv); | |
2711 | |
2712 /* Send button */ | |
2713 gtkconv->send = gaim_gtk_change_text(_("Send"), gtkconv->send, | |
2714 GAIM_STOCK_SEND, GAIM_CONV_CHAT); | |
2715 gtk_tooltips_set_tip(gtkconv->tooltips, gtkconv->send, _("Send"), NULL); | |
2716 | |
2717 gtk_box_pack_end(GTK_BOX(parent), gtkconv->send, FALSE, FALSE, 0); | |
2718 | |
2719 /* Separator */ | |
2720 sep = gtk_vseparator_new(); | |
2721 gtk_box_pack_end(GTK_BOX(parent), sep, FALSE, TRUE, 0); | |
2722 gtk_widget_show(sep); | |
2723 | |
2724 /* Invite */ | |
2725 gtkchat->invite = gaim_gtk_change_text(_("Invite"), gtkchat->invite, | |
2726 GAIM_STOCK_INVITE, GAIM_CONV_CHAT); | |
2727 gtk_tooltips_set_tip(gtkconv->tooltips, gtkchat->invite, | |
2728 _("Invite a user"), NULL); | |
2729 gtk_box_pack_end(GTK_BOX(parent), gtkchat->invite, FALSE, FALSE, 0); | |
2730 | |
2731 /* Set the relief on these. */ | |
2732 gtk_button_set_relief(GTK_BUTTON(gtkchat->invite), GTK_RELIEF_NONE); | |
2733 gtk_button_set_relief(GTK_BUTTON(gtkconv->send), GTK_RELIEF_NONE); | |
2734 | |
2735 /* Callbacks */ | |
2736 g_signal_connect(G_OBJECT(gtkconv->send), "clicked", | |
2737 G_CALLBACK(send_cb), conv); | |
2738 g_signal_connect(G_OBJECT(gtkchat->invite), "clicked", | |
2739 G_CALLBACK(invite_cb), conv); | |
2740 } | |
2741 | |
2742 static GtkWidget * | |
2743 build_conv_toolbar(struct gaim_conversation *conv) | |
2744 { | |
2745 struct gaim_gtk_conversation *gtkconv; | |
2746 GtkWidget *vbox; | |
2747 GtkWidget *hbox; | |
2748 GtkWidget *button; | |
2749 GtkWidget *sep; | |
2750 GtkSizeGroup *sg; | |
2751 | |
2752 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
2753 | |
2754 sg = gtk_size_group_new(GTK_SIZE_GROUP_BOTH); | |
2755 | |
2756 vbox = gtk_vbox_new(FALSE, 0); | |
2757 sep = gtk_hseparator_new(); | |
2758 gtk_box_pack_start(GTK_BOX(vbox), sep, FALSE, FALSE, 0); | |
2759 | |
2760 hbox = gtk_hbox_new(FALSE, 5); | |
2761 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); | |
2762 | |
2763 /* Bold */ | |
2764 button = gaim_pixbuf_toolbar_button_from_stock(GTK_STOCK_BOLD); | |
2765 gtk_size_group_add_widget(sg, button); | |
2766 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0); | |
2767 gtk_tooltips_set_tip(gtkconv->tooltips, button, _("Bold"), NULL); | |
2768 | |
2769 g_signal_connect(G_OBJECT(button), "clicked", | |
2770 G_CALLBACK(do_bold), gtkconv); | |
2771 | |
2772 gtkconv->toolbar.bold = button; | |
2773 | |
2774 /* Italic */ | |
2775 button = gaim_pixbuf_toolbar_button_from_stock(GTK_STOCK_ITALIC); | |
2776 gtk_size_group_add_widget(sg, button); | |
2777 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0); | |
2778 gtk_tooltips_set_tip(gtkconv->tooltips, button, _("Italic"), NULL); | |
2779 | |
2780 g_signal_connect(G_OBJECT(button), "clicked", | |
2781 G_CALLBACK(do_italic), gtkconv); | |
2782 | |
2783 gtkconv->toolbar.italic = button; | |
2784 | |
2785 /* Underline */ | |
2786 button = gaim_pixbuf_toolbar_button_from_stock(GTK_STOCK_UNDERLINE); | |
2787 gtk_size_group_add_widget(sg, button); | |
2788 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0); | |
2789 gtk_tooltips_set_tip(gtkconv->tooltips, button, _("Underline"), NULL); | |
2790 | |
2791 g_signal_connect(G_OBJECT(button), "clicked", | |
2792 G_CALLBACK(do_underline), gtkconv); | |
2793 | |
2794 gtkconv->toolbar.underline = button; | |
2795 | |
2796 /* Sep */ | |
2797 sep = gtk_vseparator_new(); | |
2798 gtk_box_pack_start(GTK_BOX(hbox), sep, FALSE, FALSE, 0); | |
2799 | |
2800 /* Increase font size */ | |
2801 button = gaim_pixbuf_toolbar_button_from_stock(GAIM_STOCK_TEXT_BIGGER); | |
2802 gtk_size_group_add_widget(sg, button); | |
2803 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0); | |
2804 gtk_tooltips_set_tip(gtkconv->tooltips, button, | |
2805 _("Larger font size"), NULL); | |
2806 | |
2807 g_signal_connect(G_OBJECT(button), "clicked", | |
2808 G_CALLBACK(do_big), gtkconv); | |
2809 | |
5049 | 2810 gtkconv->toolbar.larger_size = button; |
2811 | |
4359 | 2812 /* Normal font size */ |
2813 button = gaim_pixbuf_toolbar_button_from_stock(GAIM_STOCK_TEXT_NORMAL); | |
2814 gtk_size_group_add_widget(sg, button); | |
2815 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0); | |
2816 gtk_tooltips_set_tip(gtkconv->tooltips, button, | |
2817 _("Normal font size"), NULL); | |
2818 | |
2819 g_signal_connect(G_OBJECT(button), "clicked", | |
2820 G_CALLBACK(do_normal), gtkconv); | |
2821 | |
2822 gtkconv->toolbar.normal_size = button; | |
2823 | |
2824 /* Decrease font size */ | |
2825 button = gaim_pixbuf_toolbar_button_from_stock(GAIM_STOCK_TEXT_SMALLER); | |
2826 gtk_size_group_add_widget(sg, button); | |
2827 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0); | |
2828 gtk_tooltips_set_tip(gtkconv->tooltips, button, | |
2829 _("Smaller font size"), NULL); | |
2830 | |
2831 g_signal_connect(G_OBJECT(button), "clicked", | |
2832 G_CALLBACK(do_small), gtkconv); | |
2833 | |
5049 | 2834 gtkconv->toolbar.smaller_size = button; |
2835 | |
4359 | 2836 /* Sep */ |
2837 sep = gtk_vseparator_new(); | |
2838 gtk_box_pack_start(GTK_BOX(hbox), sep, FALSE, FALSE, 0); | |
2839 | |
4685 | 2840 /* Font Face */ |
2841 | |
2842 button = gaim_pixbuf_toolbar_button_from_stock(GTK_STOCK_SELECT_FONT); | |
2843 gtk_size_group_add_widget(sg, button); | |
2844 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0); | |
2845 gtk_tooltips_set_tip(gtkconv->tooltips, button, | |
2846 _("Font Face"), NULL); | |
2847 | |
2848 g_signal_connect(G_OBJECT(button), "clicked", | |
2849 G_CALLBACK(toggle_font), conv); | |
2850 | |
2851 gtkconv->toolbar.font = button; | |
2852 | |
4359 | 2853 /* Foreground Color */ |
2854 button = gaim_pixbuf_toolbar_button_from_stock(GAIM_STOCK_FGCOLOR); | |
2855 gtk_size_group_add_widget(sg, button); | |
2856 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0); | |
2857 gtk_tooltips_set_tip(gtkconv->tooltips, button, | |
2858 _("Foreground font color"), NULL); | |
2859 | |
2860 g_signal_connect(G_OBJECT(button), "clicked", | |
2861 G_CALLBACK(toggle_fg_color), conv); | |
2862 | |
2863 gtkconv->toolbar.fgcolor = button; | |
2864 | |
2865 /* Background Color */ | |
2866 button = gaim_pixbuf_toolbar_button_from_stock(GAIM_STOCK_BGCOLOR); | |
2867 gtk_size_group_add_widget(sg, button); | |
2868 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0); | |
2869 gtk_tooltips_set_tip(gtkconv->tooltips, button, | |
2870 _("Background color"), NULL); | |
2871 | |
2872 g_signal_connect(G_OBJECT(button), "clicked", | |
2873 G_CALLBACK(toggle_bg_color), conv); | |
2874 | |
2875 gtkconv->toolbar.bgcolor = button; | |
2876 | |
2877 /* Sep */ | |
2878 sep = gtk_vseparator_new(); | |
2879 gtk_box_pack_start(GTK_BOX(hbox), sep, FALSE, FALSE, 0); | |
2880 | |
2881 /* Insert IM Image */ | |
2882 button = gaim_pixbuf_toolbar_button_from_stock(GAIM_STOCK_IMAGE); | |
2883 gtk_size_group_add_widget(sg, button); | |
2884 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0); | |
2885 gtk_tooltips_set_tip(gtkconv->tooltips, button, _("Insert image"), NULL); | |
2886 | |
2887 g_signal_connect(G_OBJECT(button), "clicked", | |
2888 G_CALLBACK(insert_image_cb), conv); | |
2889 | |
2890 gtkconv->toolbar.image = button; | |
2891 | |
2892 /* Insert Link */ | |
2893 button = gaim_pixbuf_toolbar_button_from_stock(GAIM_STOCK_LINK); | |
2894 gtk_size_group_add_widget(sg, button); | |
2895 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0); | |
2896 gtk_tooltips_set_tip(gtkconv->tooltips, button, _("Insert link"), NULL); | |
2897 | |
2898 g_signal_connect(G_OBJECT(button), "clicked", | |
2899 G_CALLBACK(insert_link_cb), conv); | |
2900 | |
2901 gtkconv->toolbar.link = button; | |
2902 | |
2903 /* Insert Smiley */ | |
2904 button = gaim_pixbuf_toolbar_button_from_stock(GAIM_STOCK_SMILEY); | |
2905 gtk_size_group_add_widget(sg, button); | |
2906 gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0); | |
2907 gtk_tooltips_set_tip(gtkconv->tooltips, button, _("Insert smiley"), NULL); | |
2908 | |
2909 g_signal_connect(G_OBJECT(button), "clicked", | |
2910 G_CALLBACK(insert_smiley_cb), conv); | |
2911 | |
2912 gtkconv->toolbar.smiley = button; | |
2913 | |
2914 | |
2915 sep = gtk_hseparator_new(); | |
2916 gtk_box_pack_start(GTK_BOX(vbox), sep, FALSE, FALSE, 0); | |
2917 | |
2918 gtk_widget_show_all(vbox); | |
2919 | |
2920 return vbox; | |
2921 } | |
2922 | |
2923 static GtkWidget * | |
2924 setup_chat_pane(struct gaim_conversation *conv) | |
2925 { | |
2926 struct gaim_gtk_conversation *gtkconv; | |
2927 struct gaim_gtk_chat_pane *gtkchat; | |
2928 struct gaim_connection *gc; | |
2929 GtkWidget *vpaned, *hpaned; | |
2930 GtkWidget *vbox, *hbox; | |
2931 GtkWidget *lbox, *bbox; | |
2932 GtkWidget *label; | |
2933 GtkWidget *sw2; | |
2934 GtkWidget *list; | |
2935 GtkWidget *button; | |
2936 GtkWidget *frame; | |
2937 GtkListStore *ls; | |
2938 GtkCellRenderer *rend; | |
2939 GtkTreeViewColumn *col; | |
2940 | |
2941 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
2942 gtkchat = gtkconv->u.chat; | |
2943 gc = gaim_conversation_get_gc(conv); | |
2944 | |
2945 /* Setup the outer pane. */ | |
2946 vpaned = gtk_vpaned_new(); | |
2947 gtk_widget_show(vpaned); | |
2948 | |
2949 /* Setup the top part of the pane. */ | |
2950 vbox = gtk_vbox_new(FALSE, 5); | |
2951 gtk_paned_pack1(GTK_PANED(vpaned), vbox, TRUE, FALSE); | |
2952 gtk_widget_show(vbox); | |
2953 | |
2954 if (gc->prpl->options & OPT_PROTO_CHAT_TOPIC) | |
2955 { | |
2956 hbox = gtk_hbox_new(FALSE, 0); | |
2957 gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 5); | |
2958 gtk_widget_show(hbox); | |
2959 | |
2960 label = gtk_label_new(_("Topic:")); | |
2961 gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 5); | |
2962 gtk_widget_show(label); | |
2963 | |
2964 gtkchat->topic_text = gtk_entry_new(); | |
4635 | 2965 gtk_editable_set_editable(GTK_EDITABLE(gtkchat->topic_text), FALSE); |
4359 | 2966 gtk_box_pack_start(GTK_BOX(hbox), gtkchat->topic_text, TRUE, TRUE, 5); |
2967 gtk_widget_show(gtkchat->topic_text); | |
2968 } | |
2969 | |
2970 /* Setup the horizontal pane. */ | |
2971 hpaned = gtk_hpaned_new(); | |
2972 gtk_box_pack_start(GTK_BOX(vbox), hpaned, TRUE, TRUE, 5); | |
2973 gtk_widget_show(hpaned); | |
2974 | |
2975 /* Setup the scrolled window to put gtkimhtml in. */ | |
2976 gtkconv->sw = gtk_scrolled_window_new(NULL, NULL); | |
2977 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(gtkconv->sw), | |
2978 GTK_POLICY_NEVER, GTK_POLICY_ALWAYS); | |
2979 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(gtkconv->sw), | |
2980 GTK_SHADOW_IN); | |
2981 gtk_paned_pack1(GTK_PANED(hpaned), gtkconv->sw, TRUE, TRUE); | |
2982 | |
2983 gtk_widget_set_size_request(gtkconv->sw, | |
2984 buddy_chat_size.width, buddy_chat_size.height); | |
2985 gtk_widget_show(gtkconv->sw); | |
2986 | |
2987 /* Setup gtkihmtml. */ | |
2988 gtkconv->imhtml = gtk_imhtml_new(NULL, NULL); | |
2989 gtk_container_add(GTK_CONTAINER(gtkconv->sw), gtkconv->imhtml); | |
2990 | |
2991 gtk_imhtml_show_comments(GTK_IMHTML(gtkconv->imhtml), | |
2992 (convo_options & OPT_CONVO_SHOW_TIME)); | |
2993 | |
2994 g_signal_connect_after(G_OBJECT(gtkconv->imhtml), "button_press_event", | |
2995 G_CALLBACK(entry_stop_rclick_cb), NULL); | |
2996 | |
2997 gaim_setup_imhtml(gtkconv->imhtml); | |
2998 | |
2999 gtk_widget_show(gtkconv->imhtml); | |
3000 | |
3001 /* Build the right pane. */ | |
3002 lbox = gtk_vbox_new(FALSE, 5); | |
4409
0521eec12c33
[gaim-migrate @ 4682]
Christian Hammond <chipx86@chipx86.com>
parents:
4398
diff
changeset
|
3003 gtk_paned_pack2(GTK_PANED(hpaned), lbox, FALSE, TRUE); |
4359 | 3004 gtk_widget_show(lbox); |
3005 | |
3006 /* Setup the label telling how many people are in the room. */ | |
3007 gtkchat->count = gtk_label_new(_("0 people in room")); | |
3008 gtk_box_pack_start(GTK_BOX(lbox), gtkchat->count, FALSE, FALSE, 0); | |
3009 gtk_widget_show(gtkchat->count); | |
3010 | |
3011 /* Setup the list of users. */ | |
3012 sw2 = gtk_scrolled_window_new(NULL, NULL); | |
3013 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw2), | |
3014 GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC); | |
3015 gtk_box_pack_start(GTK_BOX(lbox), sw2, TRUE, TRUE, 0); | |
3016 gtk_widget_show(sw2); | |
3017 | |
3018 ls = gtk_list_store_new(2, G_TYPE_STRING, G_TYPE_STRING); | |
3019 gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(ls), 1, | |
3020 GTK_SORT_ASCENDING); | |
3021 | |
3022 list = gtk_tree_view_new_with_model(GTK_TREE_MODEL(ls)); | |
3023 | |
3024 rend = gtk_cell_renderer_text_new(); | |
3025 col = gtk_tree_view_column_new_with_attributes(NULL, rend, | |
3026 "text", 0, NULL); | |
3027 gtk_tree_view_column_set_clickable(GTK_TREE_VIEW_COLUMN(col), TRUE); | |
3028 | |
3029 g_signal_connect(G_OBJECT(list), "button_press_event", | |
3030 G_CALLBACK(right_click_chat_cb), conv); | |
3031 | |
3032 gtk_tree_view_append_column(GTK_TREE_VIEW(list), col); | |
3033 | |
3034 col = gtk_tree_view_column_new_with_attributes(NULL, rend, | |
3035 "text", 1, NULL); | |
3036 gtk_tree_view_column_set_clickable(GTK_TREE_VIEW_COLUMN(col), TRUE); | |
3037 | |
3038 #if 0 | |
3039 g_signal_connect(G_OBJECT(list), "button_press_event", | |
3040 G_CALLBACK(right_click_chat), conv); | |
3041 #endif | |
3042 | |
3043 gtk_tree_view_append_column(GTK_TREE_VIEW(list), col); | |
3044 | |
3045 gtk_widget_set_size_request(list, 150, -1); | |
3046 | |
3047 gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(list), FALSE); | |
3048 gtk_widget_show(list); | |
3049 | |
3050 gtkchat->list = list; | |
3051 | |
3052 gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(sw2), list); | |
3053 | |
3054 /* Setup the user list toolbar. */ | |
3055 bbox = gtk_hbox_new(TRUE, 5); | |
3056 gtk_box_pack_start(GTK_BOX(lbox), bbox, FALSE, FALSE, 0); | |
3057 gtk_widget_show(bbox); | |
3058 | |
3059 /* IM */ | |
3060 button = gaim_pixbuf_button_from_stock(NULL, GTK_STOCK_REDO, | |
3061 GAIM_BUTTON_VERTICAL); | |
3062 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE); | |
3063 gtk_box_pack_start(GTK_BOX(bbox), button, FALSE, FALSE, 0); | |
4370
d856987c72ca
[gaim-migrate @ 4636]
Christian Hammond <chipx86@chipx86.com>
parents:
4369
diff
changeset
|
3064 gtk_tooltips_set_tip(gtkconv->tooltips, button, _("IM the user"), NULL); |
4359 | 3065 g_signal_connect(G_OBJECT(button), "clicked", |
3066 G_CALLBACK(im_cb), conv); | |
3067 | |
3068 gtk_widget_show(button); | |
3069 | |
3070 /* Ignore */ | |
3071 button = gaim_pixbuf_button_from_stock(NULL, GAIM_STOCK_IGNORE, | |
3072 GAIM_BUTTON_VERTICAL); | |
3073 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE); | |
3074 gtk_box_pack_start(GTK_BOX(bbox), button, FALSE, FALSE, 0); | |
4370
d856987c72ca
[gaim-migrate @ 4636]
Christian Hammond <chipx86@chipx86.com>
parents:
4369
diff
changeset
|
3075 gtk_tooltips_set_tip(gtkconv->tooltips, button, |
d856987c72ca
[gaim-migrate @ 4636]
Christian Hammond <chipx86@chipx86.com>
parents:
4369
diff
changeset
|
3076 _("Ignore the user"), NULL); |
4359 | 3077 g_signal_connect(G_OBJECT(button), "clicked", |
3078 G_CALLBACK(ignore_cb), conv); | |
3079 gtk_widget_show(button); | |
3080 | |
3081 /* Info */ | |
3082 button = gaim_pixbuf_button_from_stock(NULL, GAIM_STOCK_INFO, | |
3083 GAIM_BUTTON_VERTICAL); | |
3084 gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE); | |
3085 gtk_box_pack_start(GTK_BOX(bbox), button, FALSE, FALSE, 0); | |
3086 gtk_tooltips_set_tip(gtkconv->tooltips, button, | |
4370
d856987c72ca
[gaim-migrate @ 4636]
Christian Hammond <chipx86@chipx86.com>
parents:
4369
diff
changeset
|
3087 _("Get the user's information"), NULL); |
4359 | 3088 g_signal_connect(G_OBJECT(button), "clicked", |
3089 G_CALLBACK(info_cb), conv); | |
3090 | |
3091 gtk_widget_show(button); | |
3092 | |
3093 gtkconv->info = button; | |
3094 | |
4963
7f5e7f2ef317
[gaim-migrate @ 5297]
Christian Hammond <chipx86@chipx86.com>
parents:
4958
diff
changeset
|
3095 /* Build the toolbar. */ |
7f5e7f2ef317
[gaim-migrate @ 5297]
Christian Hammond <chipx86@chipx86.com>
parents:
4958
diff
changeset
|
3096 vbox = gtk_vbox_new(FALSE, 5); |
7f5e7f2ef317
[gaim-migrate @ 5297]
Christian Hammond <chipx86@chipx86.com>
parents:
4958
diff
changeset
|
3097 gtk_paned_pack2(GTK_PANED(vpaned), vbox, FALSE, FALSE); |
7f5e7f2ef317
[gaim-migrate @ 5297]
Christian Hammond <chipx86@chipx86.com>
parents:
4958
diff
changeset
|
3098 gtk_widget_show(vbox); |
7f5e7f2ef317
[gaim-migrate @ 5297]
Christian Hammond <chipx86@chipx86.com>
parents:
4958
diff
changeset
|
3099 |
7f5e7f2ef317
[gaim-migrate @ 5297]
Christian Hammond <chipx86@chipx86.com>
parents:
4958
diff
changeset
|
3100 gtkconv->toolbar.toolbar = build_conv_toolbar(conv); |
7f5e7f2ef317
[gaim-migrate @ 5297]
Christian Hammond <chipx86@chipx86.com>
parents:
4958
diff
changeset
|
3101 gtk_box_pack_start(GTK_BOX(vbox), gtkconv->toolbar.toolbar, |
7f5e7f2ef317
[gaim-migrate @ 5297]
Christian Hammond <chipx86@chipx86.com>
parents:
4958
diff
changeset
|
3102 FALSE, FALSE, 0); |
7f5e7f2ef317
[gaim-migrate @ 5297]
Christian Hammond <chipx86@chipx86.com>
parents:
4958
diff
changeset
|
3103 |
7f5e7f2ef317
[gaim-migrate @ 5297]
Christian Hammond <chipx86@chipx86.com>
parents:
4958
diff
changeset
|
3104 /* Setup the entry widget. */ |
7f5e7f2ef317
[gaim-migrate @ 5297]
Christian Hammond <chipx86@chipx86.com>
parents:
4958
diff
changeset
|
3105 frame = gtk_frame_new(NULL); |
7f5e7f2ef317
[gaim-migrate @ 5297]
Christian Hammond <chipx86@chipx86.com>
parents:
4958
diff
changeset
|
3106 gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_IN); |
7f5e7f2ef317
[gaim-migrate @ 5297]
Christian Hammond <chipx86@chipx86.com>
parents:
4958
diff
changeset
|
3107 gtk_box_pack_start(GTK_BOX(vbox), frame, TRUE, TRUE, 0); |
7f5e7f2ef317
[gaim-migrate @ 5297]
Christian Hammond <chipx86@chipx86.com>
parents:
4958
diff
changeset
|
3108 gtk_widget_show(frame); |
7f5e7f2ef317
[gaim-migrate @ 5297]
Christian Hammond <chipx86@chipx86.com>
parents:
4958
diff
changeset
|
3109 |
7f5e7f2ef317
[gaim-migrate @ 5297]
Christian Hammond <chipx86@chipx86.com>
parents:
4958
diff
changeset
|
3110 gtkconv->entry_buffer = gtk_text_buffer_new(NULL); |
7f5e7f2ef317
[gaim-migrate @ 5297]
Christian Hammond <chipx86@chipx86.com>
parents:
4958
diff
changeset
|
3111 g_object_set_data(G_OBJECT(gtkconv->entry_buffer), "user_data", conv); |
7f5e7f2ef317
[gaim-migrate @ 5297]
Christian Hammond <chipx86@chipx86.com>
parents:
4958
diff
changeset
|
3112 gtkconv->entry = gtk_text_view_new_with_buffer(gtkconv->entry_buffer); |
7f5e7f2ef317
[gaim-migrate @ 5297]
Christian Hammond <chipx86@chipx86.com>
parents:
4958
diff
changeset
|
3113 |
5105 | 3114 gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(gtkconv->entry), GTK_WRAP_WORD_CHAR); |
4963
7f5e7f2ef317
[gaim-migrate @ 5297]
Christian Hammond <chipx86@chipx86.com>
parents:
4958
diff
changeset
|
3115 gtk_widget_set_size_request(gtkconv->entry, -1, |
7f5e7f2ef317
[gaim-migrate @ 5297]
Christian Hammond <chipx86@chipx86.com>
parents:
4958
diff
changeset
|
3116 MAX(buddy_chat_size.entry_height, 25)); |
4359 | 3117 |
3118 /* Connect the signal handlers. */ | |
3119 g_signal_connect_swapped(G_OBJECT(gtkconv->entry), "key_press_event", | |
3120 G_CALLBACK(entry_key_pressed_cb_1), | |
3121 gtkconv->entry_buffer); | |
3122 g_signal_connect_after(G_OBJECT(gtkconv->entry), "button_press_event", | |
3123 G_CALLBACK(entry_stop_rclick_cb), NULL); | |
3124 g_signal_connect(G_OBJECT(gtkconv->entry), "key_press_event", | |
3125 G_CALLBACK(entry_key_pressed_cb_2), conv); | |
3126 | |
3127 #ifdef USE_GTKSPELL | |
3128 if (convo_options & OPT_CONVO_CHECK_SPELLING) | |
3129 gtkspell_new_attach(GTK_TEXT_VIEW(gtkconv->entry), NULL, NULL); | |
3130 #endif | |
3131 | |
3132 gtk_container_add(GTK_CONTAINER(frame), GTK_WIDGET(gtkconv->entry)); | |
3133 gtk_widget_show(gtkconv->entry); | |
3134 | |
3135 /* Setup the bottom button box. */ | |
3136 gtkconv->bbox = gtk_hbox_new(FALSE, 5); | |
3137 gtk_box_pack_start(GTK_BOX(vbox), gtkconv->bbox, FALSE, FALSE, 0); | |
3138 gtk_widget_show(gtkconv->bbox); | |
3139 | |
3140 setup_chat_buttons(conv, gtkconv->bbox); | |
3141 | |
3142 return vpaned; | |
3143 } | |
3144 | |
3145 static GtkWidget * | |
3146 setup_im_pane(struct gaim_conversation *conv) | |
3147 { | |
3148 struct gaim_gtk_conversation *gtkconv; | |
3149 struct gaim_gtk_im_pane *gtkim; | |
3150 GtkWidget *paned; | |
3151 GtkWidget *vbox; | |
3152 GtkWidget *vbox2; | |
3153 GtkWidget *frame; | |
3154 | |
3155 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
3156 gtkim = gtkconv->u.im; | |
3157 | |
3158 /* Setup the outer pane. */ | |
3159 paned = gtk_vpaned_new(); | |
3160 gtk_widget_show(paned); | |
3161 | |
3162 /* Setup the top part of the pane. */ | |
3163 vbox = gtk_vbox_new(FALSE, 5); | |
4409
0521eec12c33
[gaim-migrate @ 4682]
Christian Hammond <chipx86@chipx86.com>
parents:
4398
diff
changeset
|
3164 gtk_paned_pack1(GTK_PANED(paned), vbox, TRUE, TRUE); |
4359 | 3165 gtk_widget_show(vbox); |
3166 | |
3167 /* Setup the gtkimhtml widget. */ | |
3168 gtkconv->sw = gtk_scrolled_window_new(NULL, NULL); | |
3169 gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(gtkconv->sw), | |
3170 GTK_POLICY_NEVER, GTK_POLICY_ALWAYS); | |
3171 gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(gtkconv->sw), | |
3172 GTK_SHADOW_IN); | |
4963
7f5e7f2ef317
[gaim-migrate @ 5297]
Christian Hammond <chipx86@chipx86.com>
parents:
4958
diff
changeset
|
3173 gtk_box_pack_start(GTK_BOX(vbox), gtkconv->sw, TRUE, TRUE, 0); |
4851 | 3174 |
4359 | 3175 gtk_widget_set_size_request(gtkconv->sw, conv_size.width, conv_size.height); |
3176 gtk_widget_show(gtkconv->sw); | |
3177 | |
3178 gtkconv->imhtml = gtk_imhtml_new(NULL, NULL); | |
3179 gtk_container_add(GTK_CONTAINER(gtkconv->sw), gtkconv->imhtml); | |
3180 | |
3181 g_signal_connect_after(G_OBJECT(gtkconv->imhtml), "button_press_event", | |
3182 G_CALLBACK(entry_stop_rclick_cb), NULL); | |
3183 | |
3184 gtk_imhtml_show_comments(GTK_IMHTML(gtkconv->imhtml), | |
3185 (convo_options & OPT_CONVO_SHOW_TIME)); | |
3186 | |
3187 gaim_setup_imhtml(gtkconv->imhtml); | |
3188 | |
3189 gtk_widget_show(gtkconv->imhtml); | |
3190 | |
4963
7f5e7f2ef317
[gaim-migrate @ 5297]
Christian Hammond <chipx86@chipx86.com>
parents:
4958
diff
changeset
|
3191 vbox2 = gtk_vbox_new(FALSE, 5); |
7f5e7f2ef317
[gaim-migrate @ 5297]
Christian Hammond <chipx86@chipx86.com>
parents:
4958
diff
changeset
|
3192 gtk_paned_pack2(GTK_PANED(paned), vbox2, FALSE, FALSE); |
7f5e7f2ef317
[gaim-migrate @ 5297]
Christian Hammond <chipx86@chipx86.com>
parents:
4958
diff
changeset
|
3193 gtk_widget_show(vbox2); |
7f5e7f2ef317
[gaim-migrate @ 5297]
Christian Hammond <chipx86@chipx86.com>
parents:
4958
diff
changeset
|
3194 |
7f5e7f2ef317
[gaim-migrate @ 5297]
Christian Hammond <chipx86@chipx86.com>
parents:
4958
diff
changeset
|
3195 /* Build the toolbar. */ |
7f5e7f2ef317
[gaim-migrate @ 5297]
Christian Hammond <chipx86@chipx86.com>
parents:
4958
diff
changeset
|
3196 gtkconv->toolbar.toolbar = build_conv_toolbar(conv); |
7f5e7f2ef317
[gaim-migrate @ 5297]
Christian Hammond <chipx86@chipx86.com>
parents:
4958
diff
changeset
|
3197 gtk_box_pack_start(GTK_BOX(vbox2), gtkconv->toolbar.toolbar, |
7f5e7f2ef317
[gaim-migrate @ 5297]
Christian Hammond <chipx86@chipx86.com>
parents:
4958
diff
changeset
|
3198 FALSE, FALSE, 0); |
7f5e7f2ef317
[gaim-migrate @ 5297]
Christian Hammond <chipx86@chipx86.com>
parents:
4958
diff
changeset
|
3199 |
7f5e7f2ef317
[gaim-migrate @ 5297]
Christian Hammond <chipx86@chipx86.com>
parents:
4958
diff
changeset
|
3200 /* Setup the entry widget. */ |
7f5e7f2ef317
[gaim-migrate @ 5297]
Christian Hammond <chipx86@chipx86.com>
parents:
4958
diff
changeset
|
3201 frame = gtk_frame_new(NULL); |
7f5e7f2ef317
[gaim-migrate @ 5297]
Christian Hammond <chipx86@chipx86.com>
parents:
4958
diff
changeset
|
3202 gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_IN); |
7f5e7f2ef317
[gaim-migrate @ 5297]
Christian Hammond <chipx86@chipx86.com>
parents:
4958
diff
changeset
|
3203 gtk_box_pack_start(GTK_BOX(vbox2), frame, TRUE, TRUE, 0); |
7f5e7f2ef317
[gaim-migrate @ 5297]
Christian Hammond <chipx86@chipx86.com>
parents:
4958
diff
changeset
|
3204 gtk_widget_show(frame); |
7f5e7f2ef317
[gaim-migrate @ 5297]
Christian Hammond <chipx86@chipx86.com>
parents:
4958
diff
changeset
|
3205 |
7f5e7f2ef317
[gaim-migrate @ 5297]
Christian Hammond <chipx86@chipx86.com>
parents:
4958
diff
changeset
|
3206 gtkconv->entry_buffer = gtk_text_buffer_new(NULL); |
7f5e7f2ef317
[gaim-migrate @ 5297]
Christian Hammond <chipx86@chipx86.com>
parents:
4958
diff
changeset
|
3207 g_object_set_data(G_OBJECT(gtkconv->entry_buffer), "user_data", conv); |
7f5e7f2ef317
[gaim-migrate @ 5297]
Christian Hammond <chipx86@chipx86.com>
parents:
4958
diff
changeset
|
3208 gtkconv->entry = gtk_text_view_new_with_buffer(gtkconv->entry_buffer); |
7f5e7f2ef317
[gaim-migrate @ 5297]
Christian Hammond <chipx86@chipx86.com>
parents:
4958
diff
changeset
|
3209 |
5105 | 3210 gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(gtkconv->entry), GTK_WRAP_WORD_CHAR); |
4963
7f5e7f2ef317
[gaim-migrate @ 5297]
Christian Hammond <chipx86@chipx86.com>
parents:
4958
diff
changeset
|
3211 gtk_widget_set_size_request(gtkconv->entry, -1, |
7f5e7f2ef317
[gaim-migrate @ 5297]
Christian Hammond <chipx86@chipx86.com>
parents:
4958
diff
changeset
|
3212 MAX(conv_size.entry_height, 25)); |
7f5e7f2ef317
[gaim-migrate @ 5297]
Christian Hammond <chipx86@chipx86.com>
parents:
4958
diff
changeset
|
3213 |
4359 | 3214 /* Connect the signal handlers. */ |
3215 g_signal_connect_swapped(G_OBJECT(gtkconv->entry), "key_press_event", | |
3216 G_CALLBACK(entry_key_pressed_cb_1), | |
3217 gtkconv->entry_buffer); | |
3218 g_signal_connect(G_OBJECT(gtkconv->entry), "key_press_event", | |
3219 G_CALLBACK(entry_key_pressed_cb_2), conv); | |
3220 g_signal_connect_after(G_OBJECT(gtkconv->entry), "button_press_event", | |
3221 G_CALLBACK(entry_stop_rclick_cb), NULL); | |
3222 | |
3223 g_signal_connect(G_OBJECT(gtkconv->entry_buffer), "insert_text", | |
3224 G_CALLBACK(insert_text_cb), conv); | |
3225 g_signal_connect(G_OBJECT(gtkconv->entry_buffer), "delete_range", | |
3226 G_CALLBACK(delete_text_cb), conv); | |
3227 | |
3228 #ifdef USE_GTKSPELL | |
3229 if (convo_options & OPT_CONVO_CHECK_SPELLING) | |
3230 gtkspell_new_attach(GTK_TEXT_VIEW(gtkconv->entry), NULL, NULL); | |
3231 #endif | |
3232 | |
3233 gtk_container_add(GTK_CONTAINER(frame), GTK_WIDGET(gtkconv->entry)); | |
3234 gtk_widget_show(gtkconv->entry); | |
3235 | |
3236 gtkconv->bbox = gtk_hbox_new(FALSE, 5); | |
3237 gtk_box_pack_start(GTK_BOX(vbox2), gtkconv->bbox, FALSE, FALSE, 0); | |
3238 gtk_widget_show(gtkconv->bbox); | |
3239 | |
3240 setup_im_buttons(conv, gtkconv->bbox); | |
3241 | |
3242 return paned; | |
3243 } | |
3244 | |
3245 static void | |
3246 move_next_tab(struct gaim_conversation *conv) | |
3247 { | |
3248 struct gaim_conversation *next_conv = NULL; | |
3249 struct gaim_window *win; | |
3250 GList *l; | |
3251 int index, i; | |
3252 | |
3253 win = gaim_conversation_get_window(conv); | |
3254 index = gaim_conversation_get_index(conv); | |
3255 | |
3256 /* First check the tabs after this position. */ | |
3257 for (l = g_list_nth(gaim_window_get_conversations(win), index); | |
3258 l != NULL; | |
3259 l = l->next) { | |
3260 | |
3261 next_conv = (struct gaim_conversation *)l->data; | |
3262 | |
3263 if (gaim_conversation_get_unseen(next_conv) > 0) | |
3264 break; | |
3265 | |
3266 next_conv = NULL; | |
3267 } | |
3268 | |
3269 if (next_conv == NULL) { | |
3270 | |
3271 /* Now check before this position. */ | |
3272 for (l = gaim_window_get_conversations(win), i = 0; | |
3273 l != NULL && i < index; | |
3274 l = l->next) { | |
3275 | |
3276 next_conv = (struct gaim_conversation *)l->data; | |
3277 | |
3278 if (gaim_conversation_get_unseen(next_conv) > 0) | |
3279 break; | |
3280 | |
3281 next_conv = NULL; | |
3282 } | |
3283 | |
3284 if (next_conv == NULL) { | |
3285 /* Okay, just grab the next conversation tab. */ | |
3286 if (index == gaim_window_get_conversation_count(win) - 1) | |
3287 next_conv = gaim_window_get_conversation_at(win, 0); | |
3288 else | |
3289 next_conv = gaim_window_get_conversation_at(win, index + 1); | |
3290 } | |
3291 } | |
3292 | |
3293 if (next_conv != NULL && next_conv != conv) { | |
3294 gaim_window_switch_conversation(win, | |
3295 gaim_conversation_get_index(next_conv)); | |
3296 } | |
3297 } | |
3298 | |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3299 static void |
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3300 conv_dnd_recv(GtkWidget *widget, GdkDragContext *dc, guint x, guint y, |
4939
4d50e125b0fa
[gaim-migrate @ 5273]
Christian Hammond <chipx86@chipx86.com>
parents:
4931
diff
changeset
|
3301 GtkSelectionData *sd, guint info, guint t, |
4d50e125b0fa
[gaim-migrate @ 5273]
Christian Hammond <chipx86@chipx86.com>
parents:
4931
diff
changeset
|
3302 struct gaim_conversation *conv) |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3303 { |
4781 | 3304 struct gaim_window *win = conv->window; |
3305 struct gaim_conversation *c; | |
4939
4d50e125b0fa
[gaim-migrate @ 5273]
Christian Hammond <chipx86@chipx86.com>
parents:
4931
diff
changeset
|
3306 |
4d50e125b0fa
[gaim-migrate @ 5273]
Christian Hammond <chipx86@chipx86.com>
parents:
4931
diff
changeset
|
3307 if (sd->target == gdk_atom_intern("GAIM_BLIST_NODE", FALSE)) { |
4781 | 3308 GaimBlistNode *n = NULL; |
3309 memcpy(&n, sd->data, sizeof(n)); | |
4939
4d50e125b0fa
[gaim-migrate @ 5273]
Christian Hammond <chipx86@chipx86.com>
parents:
4931
diff
changeset
|
3310 |
4781 | 3311 if (!GAIM_BLIST_NODE_IS_BUDDY(n)) |
3312 return; | |
4939
4d50e125b0fa
[gaim-migrate @ 5273]
Christian Hammond <chipx86@chipx86.com>
parents:
4931
diff
changeset
|
3313 |
4d50e125b0fa
[gaim-migrate @ 5273]
Christian Hammond <chipx86@chipx86.com>
parents:
4931
diff
changeset
|
3314 c = gaim_conversation_new(GAIM_CONV_IM, |
4d50e125b0fa
[gaim-migrate @ 5273]
Christian Hammond <chipx86@chipx86.com>
parents:
4931
diff
changeset
|
3315 ((struct buddy *)n)->account, |
4d50e125b0fa
[gaim-migrate @ 5273]
Christian Hammond <chipx86@chipx86.com>
parents:
4931
diff
changeset
|
3316 ((struct buddy *)n)->name); |
4d50e125b0fa
[gaim-migrate @ 5273]
Christian Hammond <chipx86@chipx86.com>
parents:
4931
diff
changeset
|
3317 |
4d50e125b0fa
[gaim-migrate @ 5273]
Christian Hammond <chipx86@chipx86.com>
parents:
4931
diff
changeset
|
3318 gaim_window_add_conversation(win, c); |
4702 | 3319 } |
3320 | |
4939
4d50e125b0fa
[gaim-migrate @ 5273]
Christian Hammond <chipx86@chipx86.com>
parents:
4931
diff
changeset
|
3321 /* do_error_dialog("MWAHAHAHA! I AM A TROLL! I AM GOING TO EAT YOU!", |
4d50e125b0fa
[gaim-migrate @ 5273]
Christian Hammond <chipx86@chipx86.com>
parents:
4931
diff
changeset
|
3322 NULL, GAIM_WARNING); */ |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3323 } |
4359 | 3324 |
3325 /************************************************************************** | |
3326 * GTK+ window ops | |
3327 **************************************************************************/ | |
4465
6e37eb000b7a
[gaim-migrate @ 4740]
Christian Hammond <chipx86@chipx86.com>
parents:
4454
diff
changeset
|
3328 static struct gaim_conversation_ui_ops * |
6e37eb000b7a
[gaim-migrate @ 4740]
Christian Hammond <chipx86@chipx86.com>
parents:
4454
diff
changeset
|
3329 gaim_gtk_get_conversation_ui_ops(void) |
4359 | 3330 { |
4465
6e37eb000b7a
[gaim-migrate @ 4740]
Christian Hammond <chipx86@chipx86.com>
parents:
4454
diff
changeset
|
3331 return gaim_get_gtk_conversation_ui_ops(); |
4359 | 3332 } |
3333 | |
3334 static void | |
3335 gaim_gtk_new_window(struct gaim_window *win) | |
3336 { | |
3337 struct gaim_gtk_window *gtkwin; | |
3338 GtkPositionType pos; | |
3339 GtkWidget *testidea; | |
3340 GtkWidget *menubar; | |
3341 | |
3342 gtkwin = g_malloc0(sizeof(struct gaim_gtk_window)); | |
3343 | |
3344 win->ui_data = gtkwin; | |
3345 | |
3346 /* Create the window. */ | |
3347 gtkwin->window = gtk_window_new(GTK_WINDOW_TOPLEVEL); | |
3348 gtk_window_set_role(GTK_WINDOW(gtkwin->window), "conversation"); | |
4635 | 3349 gtk_window_set_resizable(GTK_WINDOW(gtkwin->window), TRUE); |
4510
4c394222c732
[gaim-migrate @ 4786]
Christian Hammond <chipx86@chipx86.com>
parents:
4505
diff
changeset
|
3350 gtk_container_set_border_width(GTK_CONTAINER(gtkwin->window), 0); |
4359 | 3351 gtk_widget_realize(gtkwin->window); |
3352 | |
3353 g_signal_connect(G_OBJECT(gtkwin->window), "delete_event", | |
3354 G_CALLBACK(close_win_cb), win); | |
3355 | |
3356 /* Create the notebook. */ | |
3357 gtkwin->notebook = gtk_notebook_new(); | |
3358 | |
3359 pos = ((im_options & OPT_IM_SIDE_TAB) | |
3360 ? ((im_options & OPT_IM_BR_TAB) ? GTK_POS_RIGHT : GTK_POS_LEFT) | |
3361 : ((im_options & OPT_IM_BR_TAB) ? GTK_POS_BOTTOM : GTK_POS_TOP)); | |
3362 | |
3363 #if 0 | |
3364 gtk_notebook_set_tab_hborder(GTK_NOTEBOOK(gtkwin->notebook), 0); | |
3365 gtk_notebook_set_tab_vborder(GTK_NOTEBOOK(gtkwin->notebook), 0); | |
3366 #endif | |
3367 gtk_notebook_set_tab_pos(GTK_NOTEBOOK(gtkwin->notebook), pos); | |
3368 gtk_notebook_set_scrollable(GTK_NOTEBOOK(gtkwin->notebook), TRUE); | |
3369 gtk_notebook_popup_enable(GTK_NOTEBOOK(gtkwin->notebook)); | |
4818 | 3370 gtk_notebook_set_show_tabs(GTK_NOTEBOOK(gtkwin->notebook), FALSE); |
3371 | |
4359 | 3372 gtk_widget_show(gtkwin->notebook); |
3373 | |
3374 g_signal_connect_after(G_OBJECT(gtkwin->notebook), "switch_page", | |
3375 G_CALLBACK(switch_conv_cb), win); | |
3376 | |
3377 /* Setup the tab drag and drop signals. */ | |
4486 | 3378 gtk_widget_add_events(gtkwin->notebook, |
3379 GDK_BUTTON1_MOTION_MASK | GDK_LEAVE_NOTIFY_MASK); | |
3380 g_signal_connect(G_OBJECT(gtkwin->notebook), "button_press_event", | |
4572
06084165a966
[gaim-migrate @ 4853]
Christian Hammond <chipx86@chipx86.com>
parents:
4571
diff
changeset
|
3381 G_CALLBACK(notebook_press_cb), win); |
4486 | 3382 g_signal_connect(G_OBJECT(gtkwin->notebook), "button_release_event", |
4572
06084165a966
[gaim-migrate @ 4853]
Christian Hammond <chipx86@chipx86.com>
parents:
4571
diff
changeset
|
3383 G_CALLBACK(notebook_release_cb), win); |
06084165a966
[gaim-migrate @ 4853]
Christian Hammond <chipx86@chipx86.com>
parents:
4571
diff
changeset
|
3384 |
4359 | 3385 testidea = gtk_vbox_new(FALSE, 0); |
4572
06084165a966
[gaim-migrate @ 4853]
Christian Hammond <chipx86@chipx86.com>
parents:
4571
diff
changeset
|
3386 |
4359 | 3387 /* Setup the menubar. */ |
3388 menubar = setup_menubar(win); | |
3389 gtk_box_pack_start(GTK_BOX(testidea), menubar, FALSE, TRUE, 0); | |
3390 | |
3391 gtk_box_pack_start(GTK_BOX(testidea), gtkwin->notebook, TRUE, TRUE, 0); | |
3392 | |
3393 gtk_container_add(GTK_CONTAINER(gtkwin->window), testidea); | |
3394 | |
3395 gtk_widget_show(testidea); | |
3396 } | |
3397 | |
3398 static void | |
3399 gaim_gtk_destroy_window(struct gaim_window *win) | |
3400 { | |
3401 struct gaim_gtk_window *gtkwin = GAIM_GTK_WINDOW(win); | |
3402 | |
3403 gtk_widget_destroy(gtkwin->window); | |
3404 | |
4630 | 3405 g_object_unref(G_OBJECT(gtkwin->menu.item_factory)); |
3406 | |
4359 | 3407 g_free(gtkwin); |
3408 win->ui_data = NULL; | |
3409 } | |
3410 | |
3411 static void | |
3412 gaim_gtk_show(struct gaim_window *win) | |
3413 { | |
3414 struct gaim_gtk_window *gtkwin = GAIM_GTK_WINDOW(win); | |
3415 | |
3416 gtk_widget_show(gtkwin->window); | |
3417 } | |
3418 | |
3419 static void | |
3420 gaim_gtk_hide(struct gaim_window *win) | |
3421 { | |
3422 struct gaim_gtk_window *gtkwin = GAIM_GTK_WINDOW(win); | |
3423 | |
3424 gtk_widget_hide(gtkwin->window); | |
3425 } | |
3426 | |
3427 static void | |
3428 gaim_gtk_raise(struct gaim_window *win) | |
3429 { | |
3430 struct gaim_gtk_window *gtkwin = GAIM_GTK_WINDOW(win); | |
3431 | |
5103 | 3432 gtk_window_deiconify(GTK_WINDOW(gtkwin->window)); |
4526 | 3433 gdk_window_raise(gtkwin->window->window); |
4359 | 3434 } |
3435 | |
3436 static void | |
3437 gaim_gtk_flash(struct gaim_window *win) | |
3438 { | |
3439 #ifdef _WIN32 | |
3440 struct gaim_gtk_window *gtkwin = GAIM_GTK_WINDOW(win); | |
3441 | |
3442 wgaim_im_blink(gtkwin->window); | |
3443 #endif | |
3444 } | |
3445 | |
3446 static void | |
3447 gaim_gtk_switch_conversation(struct gaim_window *win, unsigned int index) | |
3448 { | |
3449 struct gaim_gtk_window *gtkwin; | |
3450 | |
3451 gtkwin = GAIM_GTK_WINDOW(win); | |
3452 | |
3453 gtk_notebook_set_current_page(GTK_NOTEBOOK(gtkwin->notebook), index); | |
3454 } | |
3455 | |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3456 static const GtkTargetEntry te[] = |
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3457 { |
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3458 {"text/plain", 0, 0}, |
4702 | 3459 {"text/uri-list", 0, 1}, |
4781 | 3460 {"GAIM_BLIST_NODE", 0, 2}, |
4702 | 3461 {"STRING", 0, 3} |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3462 }; |
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3463 |
4359 | 3464 static void |
3465 gaim_gtk_add_conversation(struct gaim_window *win, | |
3466 struct gaim_conversation *conv) | |
3467 { | |
3468 struct gaim_gtk_window *gtkwin; | |
3469 struct gaim_gtk_conversation *gtkconv; | |
3470 GtkWidget *pane = NULL; | |
3471 GtkWidget *tab_cont; | |
3472 GtkWidget *tabby; | |
3473 gboolean new_ui; | |
4383
f7a84034f97f
[gaim-migrate @ 4649]
Christian Hammond <chipx86@chipx86.com>
parents:
4382
diff
changeset
|
3474 GaimConversationType conv_type; |
f7a84034f97f
[gaim-migrate @ 4649]
Christian Hammond <chipx86@chipx86.com>
parents:
4382
diff
changeset
|
3475 const char *name; |
f7a84034f97f
[gaim-migrate @ 4649]
Christian Hammond <chipx86@chipx86.com>
parents:
4382
diff
changeset
|
3476 |
f7a84034f97f
[gaim-migrate @ 4649]
Christian Hammond <chipx86@chipx86.com>
parents:
4382
diff
changeset
|
3477 name = gaim_conversation_get_name(conv); |
f7a84034f97f
[gaim-migrate @ 4649]
Christian Hammond <chipx86@chipx86.com>
parents:
4382
diff
changeset
|
3478 conv_type = gaim_conversation_get_type(conv); |
f7a84034f97f
[gaim-migrate @ 4649]
Christian Hammond <chipx86@chipx86.com>
parents:
4382
diff
changeset
|
3479 gtkwin = GAIM_GTK_WINDOW(win); |
4359 | 3480 |
3481 if (conv->ui_data != NULL) { | |
3482 gtkconv = (struct gaim_gtk_conversation *)conv->ui_data; | |
3483 | |
3484 tab_cont = gtkconv->tab_cont; | |
3485 | |
3486 new_ui = FALSE; | |
3487 } | |
3488 else { | |
3489 gtkconv = g_malloc0(sizeof(struct gaim_gtk_conversation)); | |
3490 conv->ui_data = gtkconv; | |
3491 | |
3492 /* Setup some initial variables. */ | |
3493 gtkconv->sg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL); | |
3494 gtkconv->tooltips = gtk_tooltips_new(); | |
3495 | |
4421 | 3496 /* Setup the foreground and background colors */ |
3497 gaim_gtkconv_update_font_colors(conv); | |
3498 | |
4438
2054d8429925
[gaim-migrate @ 4713]
Christian Hammond <chipx86@chipx86.com>
parents:
4421
diff
changeset
|
3499 /* Setup the font face */ |
2054d8429925
[gaim-migrate @ 4713]
Christian Hammond <chipx86@chipx86.com>
parents:
4421
diff
changeset
|
3500 gaim_gtkconv_update_font_face(conv); |
2054d8429925
[gaim-migrate @ 4713]
Christian Hammond <chipx86@chipx86.com>
parents:
4421
diff
changeset
|
3501 |
4383
f7a84034f97f
[gaim-migrate @ 4649]
Christian Hammond <chipx86@chipx86.com>
parents:
4382
diff
changeset
|
3502 if (conv_type == GAIM_CONV_CHAT) { |
4359 | 3503 gtkconv->u.chat = g_malloc0(sizeof(struct gaim_gtk_chat_pane)); |
3504 | |
3505 pane = setup_chat_pane(conv); | |
3506 } | |
4383
f7a84034f97f
[gaim-migrate @ 4649]
Christian Hammond <chipx86@chipx86.com>
parents:
4382
diff
changeset
|
3507 else if (conv_type == GAIM_CONV_IM) { |
4359 | 3508 gtkconv->u.im = g_malloc0(sizeof(struct gaim_gtk_im_pane)); |
3509 gtkconv->u.im->a_virgin = TRUE; | |
3510 | |
3511 pane = setup_im_pane(conv); | |
3512 } | |
3513 | |
3514 if (pane == NULL) { | |
4572
06084165a966
[gaim-migrate @ 4853]
Christian Hammond <chipx86@chipx86.com>
parents:
4571
diff
changeset
|
3515 if (conv_type == GAIM_CONV_CHAT) g_free(gtkconv->u.chat); |
06084165a966
[gaim-migrate @ 4853]
Christian Hammond <chipx86@chipx86.com>
parents:
4571
diff
changeset
|
3516 else if (conv_type == GAIM_CONV_IM) g_free(gtkconv->u.im); |
4359 | 3517 |
3518 g_free(gtkconv); | |
3519 conv->ui_data = NULL; | |
3520 | |
3521 return; | |
3522 } | |
3523 | |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3524 /* Setup drag-and-drop */ |
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3525 gtk_drag_dest_set(pane, |
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3526 GTK_DEST_DEFAULT_MOTION | |
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3527 GTK_DEST_DEFAULT_DROP, |
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3528 te, sizeof(te) / sizeof(GtkTargetEntry), |
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3529 GDK_ACTION_COPY); |
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3530 gtk_drag_dest_set(gtkconv->imhtml, |
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3531 GTK_DEST_DEFAULT_MOTION | |
4702 | 3532 GTK_DEST_DEFAULT_DROP, |
4689
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3533 te, sizeof(te) / sizeof(GtkTargetEntry), |
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3534 GDK_ACTION_DEFAULT | GDK_ACTION_COPY | GDK_ACTION_MOVE); |
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3535 gtk_drag_dest_set(gtkconv->entry, |
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3536 GTK_DEST_DEFAULT_MOTION | |
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3537 GTK_DEST_DEFAULT_DROP, |
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3538 te, sizeof(te) / sizeof(GtkTargetEntry), |
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3539 GDK_ACTION_COPY); |
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3540 |
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3541 g_signal_connect(G_OBJECT(pane), "drag_data_received", |
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3542 G_CALLBACK(conv_dnd_recv), conv); |
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3543 g_signal_connect(G_OBJECT(gtkconv->imhtml), "drag_data_received", |
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3544 G_CALLBACK(conv_dnd_recv), conv); |
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3545 #if 0 |
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3546 g_signal_connect(G_OBJECT(gtkconv->entry), "drag_data_received", |
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3547 G_CALLBACK(conv_dnd_recv), conv); |
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3548 #endif |
69b19e132df0
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3549 |
4383
f7a84034f97f
[gaim-migrate @ 4649]
Christian Hammond <chipx86@chipx86.com>
parents:
4382
diff
changeset
|
3550 /* |
f7a84034f97f
[gaim-migrate @ 4649]
Christian Hammond <chipx86@chipx86.com>
parents:
4382
diff
changeset
|
3551 * Write the New Conversation log string. |
f7a84034f97f
[gaim-migrate @ 4649]
Christian Hammond <chipx86@chipx86.com>
parents:
4382
diff
changeset
|
3552 * |
f7a84034f97f
[gaim-migrate @ 4649]
Christian Hammond <chipx86@chipx86.com>
parents:
4382
diff
changeset
|
3553 * This should probably be elsewhere, but then, logging should |
f7a84034f97f
[gaim-migrate @ 4649]
Christian Hammond <chipx86@chipx86.com>
parents:
4382
diff
changeset
|
3554 * be moved out in some way, either via plugin or via a new API. |
f7a84034f97f
[gaim-migrate @ 4649]
Christian Hammond <chipx86@chipx86.com>
parents:
4382
diff
changeset
|
3555 */ |
f7a84034f97f
[gaim-migrate @ 4649]
Christian Hammond <chipx86@chipx86.com>
parents:
4382
diff
changeset
|
3556 if (gaim_conversation_is_logging(conv) && |
f7a84034f97f
[gaim-migrate @ 4649]
Christian Hammond <chipx86@chipx86.com>
parents:
4382
diff
changeset
|
3557 conv_type != GAIM_CONV_MISC) { |
f7a84034f97f
[gaim-migrate @ 4649]
Christian Hammond <chipx86@chipx86.com>
parents:
4382
diff
changeset
|
3558 |
f7a84034f97f
[gaim-migrate @ 4649]
Christian Hammond <chipx86@chipx86.com>
parents:
4382
diff
changeset
|
3559 FILE *fd; |
f7a84034f97f
[gaim-migrate @ 4649]
Christian Hammond <chipx86@chipx86.com>
parents:
4382
diff
changeset
|
3560 char filename[256]; |
f7a84034f97f
[gaim-migrate @ 4649]
Christian Hammond <chipx86@chipx86.com>
parents:
4382
diff
changeset
|
3561 |
f7a84034f97f
[gaim-migrate @ 4649]
Christian Hammond <chipx86@chipx86.com>
parents:
4382
diff
changeset
|
3562 g_snprintf(filename, sizeof(filename), "%s%s", name, |
f7a84034f97f
[gaim-migrate @ 4649]
Christian Hammond <chipx86@chipx86.com>
parents:
4382
diff
changeset
|
3563 (conv_type == GAIM_CONV_CHAT ? ".chat" : "")); |
f7a84034f97f
[gaim-migrate @ 4649]
Christian Hammond <chipx86@chipx86.com>
parents:
4382
diff
changeset
|
3564 |
f7a84034f97f
[gaim-migrate @ 4649]
Christian Hammond <chipx86@chipx86.com>
parents:
4382
diff
changeset
|
3565 fd = open_log_file(filename, (conv_type == GAIM_CONV_CHAT)); |
f7a84034f97f
[gaim-migrate @ 4649]
Christian Hammond <chipx86@chipx86.com>
parents:
4382
diff
changeset
|
3566 |
f7a84034f97f
[gaim-migrate @ 4649]
Christian Hammond <chipx86@chipx86.com>
parents:
4382
diff
changeset
|
3567 if (fd) { |
f7a84034f97f
[gaim-migrate @ 4649]
Christian Hammond <chipx86@chipx86.com>
parents:
4382
diff
changeset
|
3568 if (!(logging_options & OPT_LOG_STRIP_HTML)) |
f7a84034f97f
[gaim-migrate @ 4649]
Christian Hammond <chipx86@chipx86.com>
parents:
4382
diff
changeset
|
3569 fprintf(fd, |
f7a84034f97f
[gaim-migrate @ 4649]
Christian Hammond <chipx86@chipx86.com>
parents:
4382
diff
changeset
|
3570 "<HR><BR><H3 Align=Center> " |
f7a84034f97f
[gaim-migrate @ 4649]
Christian Hammond <chipx86@chipx86.com>
parents:
4382
diff
changeset
|
3571 "---- New Conversation @ %s ----</H3><BR>\n", |
f7a84034f97f
[gaim-migrate @ 4649]
Christian Hammond <chipx86@chipx86.com>
parents:
4382
diff
changeset
|
3572 full_date()); |
f7a84034f97f
[gaim-migrate @ 4649]
Christian Hammond <chipx86@chipx86.com>
parents:
4382
diff
changeset
|
3573 else |
f7a84034f97f
[gaim-migrate @ 4649]
Christian Hammond <chipx86@chipx86.com>
parents:
4382
diff
changeset
|
3574 fprintf(fd, "---- New Conversation @ %s ----\n", |
f7a84034f97f
[gaim-migrate @ 4649]
Christian Hammond <chipx86@chipx86.com>
parents:
4382
diff
changeset
|
3575 full_date()); |
f7a84034f97f
[gaim-migrate @ 4649]
Christian Hammond <chipx86@chipx86.com>
parents:
4382
diff
changeset
|
3576 |
f7a84034f97f
[gaim-migrate @ 4649]
Christian Hammond <chipx86@chipx86.com>
parents:
4382
diff
changeset
|
3577 fclose(fd); |
f7a84034f97f
[gaim-migrate @ 4649]
Christian Hammond <chipx86@chipx86.com>
parents:
4382
diff
changeset
|
3578 } |
f7a84034f97f
[gaim-migrate @ 4649]
Christian Hammond <chipx86@chipx86.com>
parents:
4382
diff
changeset
|
3579 } |
f7a84034f97f
[gaim-migrate @ 4649]
Christian Hammond <chipx86@chipx86.com>
parents:
4382
diff
changeset
|
3580 |
4359 | 3581 /* Setup the container for the tab. */ |
3582 gtkconv->tab_cont = tab_cont = gtk_vbox_new(FALSE, 5); | |
3583 gtk_container_set_border_width(GTK_CONTAINER(tab_cont), 5); | |
3584 gtk_container_add(GTK_CONTAINER(tab_cont), pane); | |
3585 gtk_widget_show(pane); | |
3586 | |
3587 new_ui = TRUE; | |
4636 | 3588 |
4359 | 3589 gtkconv->make_sound = TRUE; |
3590 } | |
3591 | |
4939
4d50e125b0fa
[gaim-migrate @ 5273]
Christian Hammond <chipx86@chipx86.com>
parents:
4931
diff
changeset
|
3592 g_signal_connect_swapped(G_OBJECT(pane), "focus", |
4d50e125b0fa
[gaim-migrate @ 5273]
Christian Hammond <chipx86@chipx86.com>
parents:
4931
diff
changeset
|
3593 G_CALLBACK(gtk_widget_grab_focus), gtkconv->entry); |
4d50e125b0fa
[gaim-migrate @ 5273]
Christian Hammond <chipx86@chipx86.com>
parents:
4931
diff
changeset
|
3594 |
4359 | 3595 gtkconv->tabby = tabby = gtk_hbox_new(FALSE, 5); |
3596 | |
3597 /* Close button. */ | |
3598 gtkconv->close = gtk_button_new(); | |
3599 gtk_widget_set_size_request(GTK_WIDGET(gtkconv->close), 16, 16); | |
3600 gtk_container_add(GTK_CONTAINER(gtkconv->close), | |
4445 | 3601 gtk_image_new_from_stock(GTK_STOCK_CLOSE, |
3602 GTK_ICON_SIZE_MENU)); | |
4359 | 3603 gtk_button_set_relief(GTK_BUTTON(gtkconv->close), GTK_RELIEF_NONE); |
3604 gtk_tooltips_set_tip(gtkconv->tooltips, gtkconv->close, | |
4572
06084165a966
[gaim-migrate @ 4853]
Christian Hammond <chipx86@chipx86.com>
parents:
4571
diff
changeset
|
3605 _("Close conversation"), NULL); |
4359 | 3606 |
3607 g_signal_connect(G_OBJECT(gtkconv->close), "clicked", | |
4571
51e988d015ed
[gaim-migrate @ 4852]
Christian Hammond <chipx86@chipx86.com>
parents:
4561
diff
changeset
|
3608 G_CALLBACK(close_conv_cb), conv); |
4359 | 3609 |
3610 /* Tab label. */ | |
3611 gtkconv->tab_label = gtk_label_new(gaim_conversation_get_title(conv)); | |
3612 #if 0 | |
3613 gtk_misc_set_alignment(GTK_MISC(gtkconv->tab_label), 0.00, 0.5); | |
3614 gtk_misc_set_padding(GTK_MISC(gtkconv->tab_label), 4, 0); | |
3615 #endif | |
3616 | |
4939
4d50e125b0fa
[gaim-migrate @ 5273]
Christian Hammond <chipx86@chipx86.com>
parents:
4931
diff
changeset
|
3617 |
4359 | 3618 /* Pack it all together. */ |
3619 gtk_box_pack_start(GTK_BOX(tabby), gtkconv->tab_label, TRUE, TRUE, 0); | |
4445 | 3620 gtk_widget_show(gtkconv->tab_label); |
3621 gtk_box_pack_start(GTK_BOX(tabby), gtkconv->close, FALSE, FALSE, 0); | |
3622 if (!(convo_options & OPT_CONVO_NO_X_ON_TAB)) | |
3623 gtk_widget_show_all(gtkconv->close); | |
3624 gtk_widget_show(tabby); | |
4359 | 3625 |
3626 | |
3627 /* Add this pane to the conversations notebook. */ | |
3628 gtk_notebook_append_page(GTK_NOTEBOOK(gtkwin->notebook), tab_cont, tabby); | |
3629 gtk_notebook_set_menu_label_text(GTK_NOTEBOOK(gtkwin->notebook), tab_cont, | |
3630 gaim_conversation_get_title(conv)); | |
3631 | |
3632 gtk_widget_show(tab_cont); | |
3633 | |
4818 | 3634 if (gaim_window_get_conversation_count(win) == 1) { |
3635 /* Er, bug in notebooks? Switch to the page manually. */ | |
4359 | 3636 gtk_notebook_set_current_page(GTK_NOTEBOOK(gtkwin->notebook), 0); |
4851 | 3637 |
3638 if(conv_type == GAIM_CONV_IM) { | |
3639 gtk_notebook_set_show_tabs(GTK_NOTEBOOK(gtkwin->notebook), | |
3640 (im_options & OPT_IM_ONE_WINDOW)); | |
3641 } else if(conv_type == GAIM_CONV_CHAT) { | |
3642 gtk_notebook_set_show_tabs(GTK_NOTEBOOK(gtkwin->notebook), | |
3643 (chat_options & OPT_CHAT_ONE_WINDOW)); | |
3644 } | |
4818 | 3645 } else { |
3646 gtk_notebook_set_show_tabs(GTK_NOTEBOOK(gtkwin->notebook), TRUE); | |
3647 } | |
4359 | 3648 |
3649 if ((gtk_notebook_get_current_page(GTK_NOTEBOOK(gtkwin->notebook)) == 0) || | |
3650 (conv == g_list_nth_data(gaim_window_get_conversations(win), 0))) { | |
3651 | |
3652 gtk_widget_grab_focus(gtkconv->entry); | |
3653 } | |
3654 | |
3655 gaim_gtkconv_update_buddy_icon(conv); | |
3656 | |
3657 if (!new_ui) | |
3658 g_object_unref(gtkconv->tab_cont); | |
3659 | |
3660 if (gaim_window_get_conversation_count(win) == 1) | |
4685 | 3661 g_timeout_add(0, (GSourceFunc)update_send_as_selection, win); |
4359 | 3662 } |
3663 | |
3664 static void | |
3665 gaim_gtk_remove_conversation(struct gaim_window *win, | |
3666 struct gaim_conversation *conv) | |
3667 { | |
3668 struct gaim_gtk_window *gtkwin; | |
3669 struct gaim_gtk_conversation *gtkconv; | |
3670 unsigned int index; | |
4818 | 3671 GaimConversationType conv_type; |
3672 | |
3673 conv_type = gaim_conversation_get_type(conv); | |
4359 | 3674 index = gaim_conversation_get_index(conv); |
3675 | |
3676 gtkwin = GAIM_GTK_WINDOW(win); | |
3677 gtkconv = GAIM_GTK_CONVERSATION(conv); | |
3678 | |
3679 g_object_ref(gtkconv->tab_cont); | |
3680 gtk_object_sink(GTK_OBJECT(gtkconv->tab_cont)); | |
3681 | |
3682 gtk_notebook_remove_page(GTK_NOTEBOOK(gtkwin->notebook), index); | |
3683 | |
4818 | 3684 /* go back to tabless if need be */ |
3685 if (gaim_window_get_conversation_count(win) <= 2) { | |
3686 gtk_notebook_set_show_tabs(GTK_NOTEBOOK(gtkwin->notebook), | |
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 |