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