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