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