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