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