Fri, 14 Mar 2003 11:38:21 +0000
[gaim-migrate @ 5088]
I want to go to sleep. This is drag-n-drop moving of buddies in the list.
I think it works, but I didn't actually test it... I really should have though;
I can't imagine it working fine as-is. ;)
I'm holding off on the rest of my Edit Buddy List stuff for tomorrow... I love
last minute things, don't I?
Note: I created gaim_blist_members and gaim_blist_groups to reproduce the
effects of the old groups GSList and the members GSList of the group struct
that I removed. This is really sub-optimal and should be replaced to iterate
the Buddy List directly. If someone wants to do that, please do. Even if you
don't want to do that, just review the changes I made and make sure I didn't
do anything stupid. It is past 6am and I'm a bit tired and prone to mistake
making.
Thanks.
| 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 | ||
| 4685 | 319 | conv = gaim_window_get_active_conversation(win); |
| 320 | ||
| 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 | ||
| 802 | if (!g_strcasecmp(buddy, "")) { | |
| 803 | g_free(info); | |
| 804 | ||
| 805 | return; | |
| 806 | } | |
| 807 | ||
| 808 | serv_chat_invite(gaim_conversation_get_gc(info->conv), | |
| 809 | gaim_chat_get_id(GAIM_CHAT(info->conv)), | |
| 810 | message, buddy); | |
| 811 | } | |
| 812 | ||
| 813 | gtk_widget_destroy(invite_dialog); | |
| 814 | invite_dialog = NULL; | |
| 815 | ||
| 816 | g_free(info); | |
| 817 | } | |
| 818 | ||
| 819 | static void | |
| 820 | invite_cb(GtkWidget *widget, struct gaim_conversation *conv) | |
| 821 | { | |
| 822 | struct InviteBuddyInfo *info = NULL; | |
| 823 | ||
| 824 | if (invite_dialog == NULL) { | |
| 825 | struct gaim_connection *gc; | |
| 826 | struct gaim_window *win; | |
| 827 | struct gaim_gtk_window *gtkwin; | |
| 828 | char *filename; | |
| 829 | GtkWidget *label; | |
| 830 | GtkWidget *vbox, *hbox; | |
| 831 | GtkWidget *table; | |
| 832 | GtkWidget *img; | |
| 833 | ||
| 834 | filename = g_build_filename(DATADIR, "pixmaps", "gaim", "dialogs", | |
| 835 | "gaim_question.png", NULL); | |
| 836 | ||
| 837 | img = gtk_image_new_from_file(filename); | |
| 838 | ||
| 839 | g_free(filename); | |
| 840 | ||
| 841 | ||
| 842 | info = g_new0(struct InviteBuddyInfo, 1); | |
| 843 | info->conv = conv; | |
| 844 | ||
| 845 | gc = gaim_conversation_get_gc(conv); | |
| 846 | win = gaim_conversation_get_window(conv); | |
| 847 | gtkwin = GAIM_GTK_WINDOW(win); | |
| 848 | ||
| 849 | /* Create the new dialog. */ | |
| 850 | invite_dialog = gtk_dialog_new_with_buttons( | |
| 851 | _("Gaim - Invite Buddy Into Chat Room"), | |
| 852 | GTK_WINDOW(gtkwin->window), | |
| 853 | GTK_DIALOG_MODAL, GTK_STOCK_CANCEL, GTK_RESPONSE_CANCEL, | |
| 854 | GTK_STOCK_OK, GTK_RESPONSE_OK, NULL); | |
| 855 | ||
| 856 | gtk_dialog_set_default_response(GTK_DIALOG(invite_dialog), | |
| 857 | GTK_RESPONSE_OK); | |
| 858 | gtk_container_set_border_width(GTK_CONTAINER(invite_dialog), 6); | |
| 859 | gtk_window_set_resizable(GTK_WINDOW(invite_dialog), FALSE); | |
| 860 | gtk_dialog_set_has_separator(GTK_DIALOG(invite_dialog), FALSE); | |
| 861 | ||
| 862 | /* Setup the outside spacing. */ | |
| 863 | vbox = GTK_DIALOG(invite_dialog)->vbox; | |
| 864 | ||
| 865 | gtk_box_set_spacing(GTK_BOX(vbox), 12); | |
| 866 | gtk_container_set_border_width(GTK_CONTAINER(vbox), 6); | |
| 867 | ||
| 868 | /* Setup the inner hbox and put the dialog's icon in it. */ | |
| 869 | hbox = gtk_hbox_new(FALSE, 12); | |
| 870 | gtk_container_add(GTK_CONTAINER(vbox), hbox); | |
| 871 | gtk_box_pack_start(GTK_BOX(hbox), img, FALSE, FALSE, 0); | |
| 872 | gtk_misc_set_alignment(GTK_MISC(img), 0, 0); | |
| 873 | ||
| 874 | /* Setup the right vbox. */ | |
| 875 | vbox = gtk_vbox_new(FALSE, 0); | |
| 876 | gtk_container_add(GTK_CONTAINER(hbox), vbox); | |
| 877 | ||
| 878 | /* Put our happy label in it. */ | |
| 879 | label = gtk_label_new(_("Please enter the name of the user you wish " | |
| 880 | "to invite, along with an optional invite " | |
| 881 | "message.")); | |
| 882 | gtk_widget_set_size_request(label, 350, -1); | |
| 883 | gtk_label_set_line_wrap(GTK_LABEL(label), TRUE); | |
| 884 | gtk_misc_set_alignment(GTK_MISC(label), 0, 0); | |
| 885 | gtk_box_pack_start(GTK_BOX(vbox), label, FALSE, FALSE, 0); | |
| 886 | ||
| 887 | /* hbox for the table, and to give it some spacing on the left. */ | |
| 888 | hbox = gtk_hbox_new(FALSE, 6); | |
| 889 | gtk_container_add(GTK_CONTAINER(vbox), hbox); | |
| 890 | ||
| 891 | /* Setup the table we're going to use to lay stuff out. */ | |
| 892 | table = gtk_table_new(2, 2, FALSE); | |
| 893 | gtk_table_set_row_spacings(GTK_TABLE(table), 6); | |
| 894 | gtk_table_set_col_spacings(GTK_TABLE(table), 6); | |
| 895 | gtk_container_set_border_width(GTK_CONTAINER(table), 12); | |
| 896 | gtk_box_pack_start(GTK_BOX(vbox), table, FALSE, FALSE, 0); | |
| 897 | ||
| 898 | /* Now the Buddy label */ | |
| 899 | label = gtk_label_new(NULL); | |
| 900 | gtk_label_set_markup_with_mnemonic(GTK_LABEL(label), _("_Buddy:")); | |
| 901 | gtk_misc_set_alignment(GTK_MISC(label), 0, 0); | |
| 902 | gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 0, 1); | |
| 903 | ||
| 904 | /* Now the Buddy drop-down entry field. */ | |
| 905 | info->entry = gtk_combo_new(); | |
| 906 | gtk_combo_set_case_sensitive(GTK_COMBO(info->entry), FALSE); | |
| 907 | gtk_entry_set_activates_default( | |
| 908 | GTK_ENTRY(GTK_COMBO(info->entry)->entry), TRUE); | |
| 909 | ||
| 910 | gtk_table_attach_defaults(GTK_TABLE(table), info->entry, 1, 2, 0, 1); | |
| 911 | gtk_label_set_mnemonic_widget(GTK_LABEL(label), info->entry); | |
| 912 | ||
| 913 | /* Fill in the names. */ | |
| 914 | gtk_combo_set_popdown_strings(GTK_COMBO(info->entry), | |
| 915 | generate_invite_user_names(gc)); | |
| 916 | ||
| 917 | ||
| 918 | /* Now the label for "Message" */ | |
| 919 | label = gtk_label_new(NULL); | |
| 920 | gtk_label_set_markup_with_mnemonic(GTK_LABEL(label), _("_Message:")); | |
| 921 | gtk_misc_set_alignment(GTK_MISC(label), 0, 0); | |
| 922 | gtk_table_attach_defaults(GTK_TABLE(table), label, 0, 1, 1, 2); | |
| 923 | ||
| 924 | ||
| 925 | /* And finally, the Message entry field. */ | |
| 926 | info->message = gtk_entry_new(); | |
| 927 | gtk_entry_set_activates_default(GTK_ENTRY(info->message), TRUE); | |
| 928 | ||
| 929 | gtk_table_attach_defaults(GTK_TABLE(table), info->message, 1, 2, 1, 2); | |
| 930 | gtk_label_set_mnemonic_widget(GTK_LABEL(label), info->message); | |
| 931 | ||
| 932 | /* Connect the signals. */ | |
| 933 | g_signal_connect(G_OBJECT(invite_dialog), "response", | |
| 934 | G_CALLBACK(do_invite), info); | |
| 935 | } | |
| 936 | ||
| 937 | gtk_widget_show_all(invite_dialog); | |
| 938 | ||
| 939 | if (info != NULL) | |
| 940 | gtk_widget_grab_focus(GTK_COMBO(info->entry)->entry); | |
| 941 | } | |
| 942 | ||
| 943 | static gboolean | |
| 944 | entry_key_pressed_cb_2(GtkWidget *entry, GdkEventKey *event, gpointer data) | |
| 945 | { | |
| 946 | struct gaim_window *win; | |
| 947 | struct gaim_conversation *conv; | |
| 948 | struct gaim_gtk_conversation *gtkconv; | |
| 4362 | 949 | struct gaim_gtk_window *gtkwin; |
| 4359 | 950 | |
| 951 | conv = (struct gaim_conversation *)data; | |
| 952 | gtkconv = GAIM_GTK_CONVERSATION(conv); | |
| 953 | win = gaim_conversation_get_window(conv); | |
| 4362 | 954 | gtkwin = GAIM_GTK_WINDOW(win); |
| 4359 | 955 | |
| 956 | if (event->keyval == GDK_Escape) { | |
| 957 | if (convo_options & OPT_CONVO_ESC_CAN_CLOSE) { | |
| 958 | g_signal_stop_emission_by_name(G_OBJECT(entry), "key_press_event"); | |
| 959 | gaim_conversation_destroy(conv); | |
| 960 | } | |
| 961 | } | |
| 962 | else if (event->keyval == GDK_Page_Up) { | |
| 963 | g_signal_stop_emission_by_name(G_OBJECT(entry), "key_press_event"); | |
| 964 | ||
| 965 | if (!(event->state & GDK_CONTROL_MASK)) | |
| 966 | gtk_imhtml_page_up(GTK_IMHTML(gtkconv->imhtml)); | |
| 967 | } | |
| 968 | else if (event->keyval == GDK_Page_Down) { | |
| 969 | g_signal_stop_emission_by_name(G_OBJECT(entry), "key_press_event"); | |
| 970 | ||
| 971 | if (!(event->state & GDK_CONTROL_MASK)) | |
| 972 | gtk_imhtml_page_down(GTK_IMHTML(gtkconv->imhtml)); | |
| 973 | } | |
| 974 | else if ((event->keyval == GDK_F2) && | |
| 975 | (convo_options & OPT_CONVO_F2_TOGGLES)) { | |
| 976 | gtk_imhtml_show_comments(GTK_IMHTML(gtkconv->imhtml), | |
| 977 | !GTK_IMHTML(gtkconv->imhtml)->comments); | |
| 978 | } | |
| 979 | else if (event->keyval == GDK_Return || event->keyval == GDK_KP_Enter) { | |
| 980 | if ((event->state & GDK_CONTROL_MASK) && | |
| 981 | (convo_options & OPT_CONVO_CTL_ENTER)) { | |
| 982 | ||
| 983 | send_cb(NULL, conv); | |
| 984 | g_signal_stop_emission_by_name(G_OBJECT(entry), "key_press_event"); | |
| 985 | ||
| 986 | return TRUE; | |
| 987 | } | |
| 988 | else if (!(event->state & (GDK_SHIFT_MASK | GDK_CONTROL_MASK)) && | |
| 989 | (convo_options & OPT_CONVO_ENTER_SENDS)) { | |
| 990 | ||
| 991 | send_cb(NULL, conv); | |
| 992 | g_signal_stop_emission_by_name(G_OBJECT(entry), "key_press_event"); | |
| 993 | ||
| 994 | return TRUE; | |
| 995 | } | |
| 996 | ||
| 997 | return FALSE; | |
| 998 | } | |
| 999 | else if ((event->state & GDK_CONTROL_MASK) && (event->keyval == 'm')) { | |
| 1000 | g_signal_stop_emission_by_name(G_OBJECT(entry), "key_press_event"); | |
| 1001 | gtk_text_buffer_insert_at_cursor(gtkconv->entry_buffer, "\n", 1); | |
| 1002 | } | |
| 1003 | else if (event->state & GDK_CONTROL_MASK) { | |
| 1004 | switch (event->keyval) { | |
| 1005 | case GDK_Up: | |
| 1006 | if (!conv->send_history) | |
| 1007 | break; | |
| 1008 | ||
| 1009 | if (!conv->send_history->prev) { | |
| 1010 | GtkTextIter start, end; | |
| 1011 | ||
| 1012 | if (conv->send_history->data) | |
| 1013 | g_free(conv->send_history->data); | |
| 1014 | ||
| 1015 | gtk_text_buffer_get_start_iter(gtkconv->entry_buffer, | |
| 1016 | &start); | |
| 1017 | gtk_text_buffer_get_end_iter(gtkconv->entry_buffer, &end); | |
| 1018 | ||
| 1019 | conv->send_history->data = | |
| 1020 | gtk_text_buffer_get_text(gtkconv->entry_buffer, | |
| 1021 | &start, &end, FALSE); | |
| 1022 | } | |
| 1023 | ||
| 1024 | if (conv->send_history->next && | |
| 1025 | conv->send_history->next->data) { | |
| 1026 | ||
| 1027 | conv->send_history = conv->send_history->next; | |
| 1028 | gtk_text_buffer_set_text(gtkconv->entry_buffer, | |
| 1029 | conv->send_history->data, -1); | |
| 1030 | } | |
| 1031 | ||
| 1032 | break; | |
| 1033 | ||
| 1034 | case GDK_Down: | |
| 1035 | if (!conv->send_history) | |
| 1036 | break; | |
| 1037 | ||
| 1038 | if (conv->send_history->prev) { | |
| 1039 | conv->send_history = conv->send_history->prev; | |
| 1040 | ||
| 1041 | if (conv->send_history->data) | |
| 1042 | gtk_text_buffer_set_text(gtkconv->entry_buffer, | |
| 1043 | conv->send_history->data, -1); | |
| 1044 | } | |
| 1045 | ||
| 1046 | break; | |
| 1047 | } | |
| 1048 | ||
| 1049 | if (convo_options & OPT_CONVO_CTL_CHARS) { | |
| 1050 | switch (event->keyval) { | |
| 1051 | case 'i': | |
| 1052 | case 'I': | |
| 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); | |
| 1316 | gdk_pointer_grab(gtkwin->notebook->window, FALSE, | |
| 1317 | GDK_BUTTON1_MOTION_MASK | GDK_BUTTON_RELEASE_MASK, | |
| 1318 | NULL, cursor, GDK_CURRENT_TIME); | |
| 1319 | } | |
| 1320 | ||
| 1321 | static gboolean | |
| 1322 | notebook_motion_cb(GtkWidget *widget, GdkEventButton *e, | |
| 1323 | struct gaim_window *win) | |
| 1324 | { | |
| 1325 | struct gaim_gtk_window *gtkwin; | |
| 1326 | ||
| 1327 | gtkwin = GAIM_GTK_WINDOW(win); | |
| 1328 | ||
| 1329 | /* | |
| 1330 | * Make sure the user moved the mouse far enough for the | |
| 1331 | * drag to be initiated. | |
| 1332 | */ | |
| 1333 | if (gtkwin->in_predrag) { | |
| 1334 | if (e->x_root < gtkwin->drag_min_x || | |
| 1335 | e->x_root >= gtkwin->drag_max_x || | |
| 1336 | e->y_root < gtkwin->drag_min_y || | |
| 1337 | e->y_root >= gtkwin->drag_max_y) { | |
| 1338 | ||
| 1339 | gtkwin->in_predrag = FALSE; | |
| 1340 | notebook_init_grab(gtkwin, widget); | |
| 1341 | } | |
| 1342 | } | |
| 1343 | else { /* Otherwise, draw the arrows. */ | |
| 1344 | struct gaim_window *dest_win; | |
| 1345 | struct gaim_gtk_window *dest_gtkwin; | |
| 1346 | GtkNotebook *dest_notebook; | |
| 1347 | GtkWidget *tab, *last_vis_tab = NULL; | |
| 1348 | gint nb_x, nb_y, page_num, i, last_vis_tab_loc = -1; | |
| 1349 | gint arrow1_x, arrow1_y, arrow2_x, arrow2_y; | |
| 1350 | gboolean horiz_tabs = FALSE, tab_found = FALSE; | |
| 1351 | GList *l; | |
| 1352 | ||
| 1353 | /* Get the window that the cursor is over. */ | |
| 1354 | dest_win = gaim_gtkwin_get_at_xy(e->x_root, e->y_root); | |
| 1355 | ||
| 1356 | if (dest_win == NULL) { | |
| 1357 | dnd_hints_hide_all(); | |
| 1358 | ||
| 1359 | return TRUE; | |
| 1360 | } | |
| 1361 | ||
| 1362 | dest_gtkwin = GAIM_GTK_WINDOW(dest_win); | |
| 1363 | ||
| 1364 | dest_notebook = GTK_NOTEBOOK(dest_gtkwin->notebook); | |
| 1365 | ||
| 1366 | gdk_window_get_origin(GTK_WIDGET(dest_notebook)->window, &nb_x, &nb_y); | |
| 1367 | ||
| 1368 | arrow1_x = arrow2_x = nb_x; | |
| 1369 | arrow1_y = arrow2_y = nb_y; | |
| 1370 | ||
| 1371 | page_num = gaim_gtkconv_get_dest_tab_at_xy(dest_win, | |
| 1372 | e->x_root, e->y_root); | |
| 1373 | ||
| 1374 | if (gtk_notebook_get_tab_pos(dest_notebook) == GTK_POS_TOP || | |
| 1375 | gtk_notebook_get_tab_pos(dest_notebook) == GTK_POS_BOTTOM) { | |
| 1376 | ||
| 1377 | horiz_tabs = TRUE; | |
| 1378 | } | |
| 1379 | ||
| 1380 | /* Find out where to put the arrows. */ | |
| 1381 | for (l = gaim_window_get_conversations(dest_win), i = 0; | |
| 1382 | l != NULL; | |
| 1383 | l = l->next, i++) { | |
| 1384 | ||
| 1385 | struct gaim_conversation *conv = l->data; | |
| 1386 | ||
| 1387 | tab = GAIM_GTK_CONVERSATION(conv)->tabby; | |
| 1388 | ||
| 1389 | /* | |
| 1390 | * If this is the correct tab, record the positions | |
| 1391 | * for the arrows. | |
| 1392 | */ | |
| 1393 | if (i == page_num) { | |
| 1394 | if (horiz_tabs) { | |
| 1395 | arrow1_x = arrow2_x = nb_x + tab->allocation.x; | |
| 1396 | arrow1_y = nb_y + tab->allocation.y; | |
| 1397 | arrow2_y = nb_y + tab->allocation.y + | |
| 1398 | tab->allocation.height; | |
| 1399 | } | |
| 1400 | else { | |
| 1401 | arrow1_x = nb_x + tab->allocation.x; | |
| 1402 | arrow2_x = nb_x + tab->allocation.x + | |
| 1403 | tab->allocation.width; | |
| 1404 | arrow1_y = arrow2_y = nb_y + tab->allocation.y; | |
| 1405 | } | |
| 1406 | ||
| 1407 | tab_found = TRUE; | |
| 1408 | break; | |
| 1409 | } | |
| 1410 | else { /* Keep track of the right-most tab that we see. */ | |
| 1411 | if (horiz_tabs && tab->allocation.x > last_vis_tab_loc) { | |
| 1412 | last_vis_tab = tab; | |
| 1413 | last_vis_tab_loc = tab->allocation.x; | |
| 1414 | } | |
| 1415 | else if (!horiz_tabs && tab->allocation.y > last_vis_tab_loc) { | |
| 1416 | last_vis_tab = tab; | |
| 1417 | last_vis_tab_loc = tab->allocation.y; | |
| 1418 | } | |
| 1419 | } | |
| 1420 | } | |
| 1421 | ||
| 1422 | /* | |
| 1423 | * If we didn't find the tab, then we'll just place the | |
| 1424 | * arrows to the right/bottom of the last visible tab. | |
| 1425 | */ | |
| 1426 | if (!tab_found && last_vis_tab) { | |
| 1427 | if (horiz_tabs) { | |
| 1428 | arrow1_x = arrow2_x = nb_x + last_vis_tab->allocation.x + | |
| 1429 | last_vis_tab->allocation.width; | |
| 1430 | arrow1_y = nb_y + last_vis_tab->allocation.y; | |
| 1431 | arrow2_y = nb_y + last_vis_tab->allocation.y + | |
| 1432 | last_vis_tab->allocation.height; | |
| 1433 | } | |
| 1434 | else { | |
| 1435 | arrow1_x = nb_x + last_vis_tab->allocation.x; | |
| 1436 | arrow2_x = nb_x + last_vis_tab->allocation.x + | |
| 1437 | last_vis_tab->allocation.width; | |
| 1438 | arrow1_y = arrow2_y = nb_y + last_vis_tab->allocation.y + | |
| 1439 | last_vis_tab->allocation.height; | |
| 1440 | } | |
| 1441 | } | |
| 1442 | ||
| 1443 | if (horiz_tabs) { | |
| 1444 | dnd_hints_show(HINT_ARROW_DOWN, arrow1_x, arrow1_y); | |
| 1445 | dnd_hints_show(HINT_ARROW_UP, arrow2_x, arrow2_y); | |
| 1446 | } | |
| 1447 | else { | |
| 1448 | dnd_hints_show(HINT_ARROW_RIGHT, arrow1_x, arrow1_y); | |
| 1449 | dnd_hints_show(HINT_ARROW_LEFT, arrow2_x, arrow2_y); | |
| 1450 | } | |
| 1451 | } | |
| 1452 | ||
| 1453 | return TRUE; | |
| 1454 | } | |
| 1455 | ||
| 1456 | static gboolean | |
| 1457 | notebook_leave_cb(GtkWidget *widget, GdkEventCrossing *e, | |
| 1458 | struct gaim_window *win) | |
| 1459 | { | |
| 1460 | struct gaim_gtk_window *gtkwin; | |
| 1461 | ||
| 1462 | gtkwin = GAIM_GTK_WINDOW(win); | |
| 1463 | ||
| 1464 | if (gtkwin->in_drag) | |
| 1465 | return FALSE; | |
| 1466 | ||
| 1467 | if (e->x_root < gtkwin->drag_min_x || | |
| 1468 | e->x_root >= gtkwin->drag_max_x || | |
| 1469 | e->y_root < gtkwin->drag_min_y || | |
| 1470 | e->y_root >= gtkwin->drag_max_y) { | |
| 1471 | ||
| 1472 | gtkwin->in_predrag = FALSE; | |
| 1473 | notebook_init_grab(gtkwin, widget); | |
| 1474 | } | |
| 1475 | ||
| 1476 | return TRUE; | |
| 1477 | } | |
| 1478 | ||
| 1479 | /* | |
| 1480 | * THANK YOU GALEON! | |
| 1481 | */ | |
| 1482 | static gboolean | |
| 1483 | notebook_press_cb(GtkWidget *widget, GdkEventButton *e, | |
| 1484 | struct gaim_window *win) | |
| 1485 | { | |
| 1486 | struct gaim_gtk_window *gtkwin; | |
| 1487 | gint nb_x, nb_y, x_rel, y_rel; | |
| 1488 | GList *l; | |
| 1489 | int tab_clicked; | |
| 1490 | ||
| 1491 | if (e->button != 1 || e->type != GDK_BUTTON_PRESS) | |
| 1492 | return FALSE; | |
| 1493 | ||
| 1494 | gtkwin = GAIM_GTK_WINDOW(win); | |
| 1495 | ||
| 1496 | if (gtkwin->in_drag) { | |
| 1497 | debug_printf("Already in the middle of a window " | |
| 4685 | 1498 | "drag at tab_press_cb\n"); |
| 4359 | 1499 | return FALSE; |
| 1500 | } | |
| 1501 | ||
| 1502 | /* | |
| 1503 | * Make sure a tab was actually clicked. The arrow buttons | |
| 1504 | * mess things up. | |
| 1505 | */ | |
| 1506 | tab_clicked = gaim_gtkconv_get_tab_at_xy(win, e->x_root, e->y_root); | |
| 1507 | ||
| 1508 | if (tab_clicked == -1) | |
| 1509 | return FALSE; | |
| 1510 | ||
| 1511 | /* | |
| 1512 | * Get the relative position of the press event, with regards to | |
| 1513 | * the position of the notebook. | |
| 1514 | */ | |
| 1515 | gdk_window_get_origin(gtkwin->notebook->window, &nb_x, &nb_y); | |
| 1516 | ||
| 1517 | x_rel = e->x_root - nb_x; | |
| 1518 | y_rel = e->y_root - nb_y; | |
| 1519 | ||
| 1520 | /* Reset the min/max x/y */ | |
| 1521 | gtkwin->drag_min_x = 0; | |
| 1522 | gtkwin->drag_min_y = 0; | |
| 1523 | gtkwin->drag_max_x = 0; | |
| 1524 | gtkwin->drag_max_y = 0; | |
| 1525 | ||
| 1526 | /* Find out which tab was dragged. */ | |
| 1527 | for (l = gaim_window_get_conversations(win); l != NULL; l = l->next) { | |
| 1528 | struct gaim_conversation *conv = l->data; | |
| 1529 | GtkWidget *tab = GAIM_GTK_CONVERSATION(conv)->tabby; | |
| 1530 | ||
| 1531 | if (!GTK_WIDGET_VISIBLE(tab)) | |
| 1532 | continue; | |
| 1533 | ||
| 1534 | if (tab->allocation.x > x_rel || tab->allocation.y > y_rel) | |
| 1535 | break; | |
| 1536 | ||
| 1537 | /* Save the borders of the tab. */ | |
| 1538 | gtkwin->drag_min_x = tab->allocation.x + nb_x; | |
| 1539 | gtkwin->drag_min_y = tab->allocation.y + nb_y; | |
| 1540 | gtkwin->drag_max_x = tab->allocation.width + gtkwin->drag_min_x; | |
| 1541 | gtkwin->drag_max_y = tab->allocation.height + gtkwin->drag_min_y; | |
| 1542 | } | |
| 1543 | ||
| 1544 | /* Make sure the click occurred in the tab. */ | |
| 1545 | if (e->x_root < gtkwin->drag_min_x || | |
| 1546 | e->x_root >= gtkwin->drag_max_x || | |
| 1547 | e->y_root < gtkwin->drag_min_y || | |
| 1548 | e->y_root >= gtkwin->drag_max_y) { | |
| 1549 | ||
| 1550 | return FALSE; | |
| 1551 | } | |
| 1552 | ||
| 1553 | gtkwin->in_predrag = TRUE; | |
| 1554 | ||
| 1555 | /* Connect the new motion signals. */ | |
| 1556 | gtkwin->drag_motion_signal = | |
| 1557 | g_signal_connect(G_OBJECT(widget), "motion_notify_event", | |
| 1558 | G_CALLBACK(notebook_motion_cb), win); | |
| 1559 | ||
| 1560 | gtkwin->drag_leave_signal = | |
| 1561 | g_signal_connect(G_OBJECT(widget), "leave_notify_event", | |
| 1562 | G_CALLBACK(notebook_leave_cb), win); | |
| 1563 | ||
| 1564 | return FALSE; | |
| 1565 | } | |
| 1566 | ||
| 1567 | static gboolean | |
| 1568 | notebook_release_cb(GtkWidget *widget, GdkEventButton *e, | |
| 1569 | struct gaim_window *win) | |
| 1570 | { | |
| 1571 | struct gaim_window *dest_win; | |
| 1572 | struct gaim_gtk_window *gtkwin; | |
| 1573 | struct gaim_gtk_window *dest_gtkwin; | |
| 1574 | struct gaim_conversation *conv; | |
| 1575 | GtkNotebook *dest_notebook; | |
| 1576 | gint dest_page_num; | |
| 1577 | ||
| 1578 | /* | |
| 1579 | * Don't check to make sure that the event's window matches the | |
| 1580 | * widget's, because we may be getting an event passed on from the | |
| 1581 | * close button. | |
| 1582 | */ | |
| 1583 | if (e->button != 1 && e->type != GDK_BUTTON_RELEASE) | |
| 1584 | return FALSE; | |
| 1585 | ||
| 1586 | if (gdk_pointer_is_grabbed()) { | |
| 1587 | gdk_pointer_ungrab(GDK_CURRENT_TIME); | |
| 1588 | gtk_grab_remove(widget); | |
| 1589 | } | |
| 1590 | ||
| 1591 | gtkwin = GAIM_GTK_WINDOW(win); | |
| 1592 | ||
| 1593 | if (!gtkwin->in_predrag && !gtkwin->in_drag) { | |
| 1594 | return TRUE; | |
| 1595 | } | |
| 1596 | ||
| 1597 | /* Disconnect the motion signal. */ | |
| 1598 | if (gtkwin->drag_motion_signal) { | |
| 1599 | g_signal_handler_disconnect(G_OBJECT(widget), | |
| 1600 | gtkwin->drag_motion_signal); | |
| 1601 | ||
| 1602 | gtkwin->drag_motion_signal = 0; | |
| 1603 | } | |
| 1604 | ||
| 1605 | /* | |
| 1606 | * If we're in a pre-drag, we'll also need to disconnect the leave | |
| 1607 | * signal. | |
| 1608 | */ | |
| 1609 | if (gtkwin->in_predrag) { | |
| 1610 | gtkwin->in_predrag = FALSE; | |
| 1611 | ||
| 1612 | if (gtkwin->drag_leave_signal) { | |
| 1613 | g_signal_handler_disconnect(G_OBJECT(widget), | |
| 1614 | gtkwin->drag_leave_signal); | |
| 1615 | ||
| 1616 | gtkwin->drag_leave_signal = 0; | |
| 1617 | } | |
| 1618 | } | |
| 1619 | ||
| 1620 | /* If we're not in drag... */ | |
| 1621 | /* We're perfectly normal people! */ | |
| 1622 | if (!gtkwin->in_drag) { | |
| 1623 | return FALSE; | |
| 1624 | } | |
| 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 | ||
| 1966 | if (conv == NULL) | |
| 4685 | 1967 | return FALSE; |
| 4359 | 1968 | |
| 4491 | 1969 | account = gaim_conversation_get_account(conv); |
| 4359 | 1970 | gtkwin = GAIM_GTK_WINDOW(win); |
| 1971 | ||
| 4491 | 1972 | if (account == NULL) |
| 4685 | 1973 | return FALSE; |
|
4466
57833e49c0ac
[gaim-migrate @ 4741]
Christian Hammond <chipx86@chipx86.com>
parents:
4465
diff
changeset
|
1974 | |
|
4364
b5e95f7f08c9
[gaim-migrate @ 4630]
Christian Hammond <chipx86@chipx86.com>
parents:
4363
diff
changeset
|
1975 | if (gtkwin->menu.send_as == NULL) |
| 4685 | 1976 | return FALSE; |
|
4364
b5e95f7f08c9
[gaim-migrate @ 4630]
Christian Hammond <chipx86@chipx86.com>
parents:
4363
diff
changeset
|
1977 | |
| 4359 | 1978 | gtk_widget_show(gtkwin->menu.send_as); |
| 1979 | ||
| 1980 | menu = gtk_menu_item_get_submenu( | |
| 1981 | GTK_MENU_ITEM(gtkwin->menu.send_as)); | |
| 1982 | ||
| 1983 | for (child = gtk_container_get_children(GTK_CONTAINER(menu)); | |
| 1984 | child != NULL; | |
| 1985 | child = child->next) { | |
| 1986 | ||
| 1987 | GtkWidget *item = child->data; | |
| 4673 | 1988 | struct gaim_account *item_account = g_object_get_data(G_OBJECT(item), |
| 1989 | "gaim_account"); | |
| 1990 | ||
| 1991 | if (account == item_account) { | |
| 4359 | 1992 | gtk_check_menu_item_set_active(GTK_CHECK_MENU_ITEM(item), TRUE); |
| 1993 | break; | |
| 1994 | } | |
| 1995 | } | |
| 4685 | 1996 | return FALSE; |
| 4359 | 1997 | } |
| 1998 | ||
| 1999 | static void | |
|
4360
28aa945b7c16
[gaim-migrate @ 4626]
Christian Hammond <chipx86@chipx86.com>
parents:
4359
diff
changeset
|
2000 | generate_send_as_items(struct gaim_window *win, |
|
28aa945b7c16
[gaim-migrate @ 4626]
Christian Hammond <chipx86@chipx86.com>
parents:
4359
diff
changeset
|
2001 | struct gaim_conversation *deleted_conv) |
| 4359 | 2002 | { |
| 2003 | struct gaim_gtk_window *gtkwin; | |
| 2004 | GtkWidget *menu; | |
| 2005 | GtkWidget *menuitem; | |
| 2006 | GSList *gcs; | |
| 2007 | GList *convs; | |
| 2008 | GSList *group = NULL; | |
| 2009 | gboolean first_offline = TRUE; | |
| 2010 | gboolean found_online = FALSE; | |
|
4669
879e30ac4cf3
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2011 | GtkSizeGroup *sg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL); |
| 4359 | 2012 | |
| 2013 | gtkwin = GAIM_GTK_WINDOW(win); | |
| 2014 | ||
| 2015 | if (gtkwin->menu.send_as != NULL) | |
| 2016 | gtk_widget_destroy(gtkwin->menu.send_as); | |
| 2017 | ||
| 2018 | /* See if we have > 1 connection active. */ | |
| 2019 | if (g_slist_length(connections) < 2) { | |
| 2020 | /* Now make sure we don't have any Offline entries. */ | |
| 2021 | gboolean found_offline = FALSE; | |
| 2022 | ||
| 2023 | for (convs = gaim_get_conversations(); | |
| 2024 | convs != NULL; | |
| 2025 | convs = convs->next) { | |
| 2026 | ||
| 2027 | struct gaim_conversation *conv; | |
| 4491 | 2028 | struct gaim_account *account; |
| 2029 | ||
| 4359 | 2030 | conv = (struct gaim_conversation *)convs->data; |
| 4491 | 2031 | account = gaim_conversation_get_account(conv); |
| 2032 | ||
| 2033 | if (account->gc == NULL) { | |
| 4359 | 2034 | found_offline = TRUE; |
| 2035 | break; | |
| 2036 | } | |
| 2037 | } | |
| 2038 | ||
| 2039 | if (!found_offline) { | |
| 2040 | gtkwin->menu.send_as = NULL; | |
| 2041 | return; | |
| 2042 | } | |
| 2043 | } | |
| 2044 | ||
| 2045 | /* Build the Send As menu */ | |
| 2046 | gtkwin->menu.send_as = gtk_menu_item_new_with_mnemonic(_("_Send As")); | |
| 2047 | gtk_widget_show(gtkwin->menu.send_as); | |
| 2048 | ||
| 2049 | menu = gtk_menu_new(); | |
| 2050 | ||
| 2051 | gtk_menu_shell_append(GTK_MENU_SHELL(gtkwin->menu.menubar), | |
| 2052 | gtkwin->menu.send_as); | |
| 2053 | gtk_menu_item_set_submenu(GTK_MENU_ITEM(gtkwin->menu.send_as), menu); | |
| 2054 | ||
| 2055 | gtk_widget_show(menu); | |
| 2056 | ||
| 2057 | /* Fill it with entries. */ | |
| 2058 | for (gcs = connections; gcs != NULL; gcs = gcs->next) { | |
|
4668
94a5dfabaecb
[gaim-migrate @ 4979]
Christian Hammond <chipx86@chipx86.com>
parents:
4640
diff
changeset
|
2059 | |
| 4359 | 2060 | struct gaim_connection *gc; |
|
4669
879e30ac4cf3
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2061 | GtkWidget *box; |
|
879e30ac4cf3
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2062 | GtkWidget *label; |
|
879e30ac4cf3
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2063 | GtkWidget *image; |
|
4689
524a0357d05b
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
2064 | GdkPixbuf *pixbuf, *scale; |
| 4359 | 2065 | |
| 2066 | found_online = TRUE; | |
| 2067 | ||
| 2068 | gc = (struct gaim_connection *)gcs->data; | |
| 2069 | ||
|
4669
879e30ac4cf3
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2070 | /* Create a pixmap for the protocol icon. */ |
|
4689
524a0357d05b
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
2071 | pixbuf = create_prpl_icon(gc->account); |
|
524a0357d05b
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
2072 | 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
|
2073 | |
|
879e30ac4cf3
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2074 | /* Now convert it to GtkImage */ |
|
4689
524a0357d05b
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
2075 | if (pixbuf == NULL) |
|
4669
879e30ac4cf3
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2076 | image = gtk_image_new(); |
|
879e30ac4cf3
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2077 | else |
|
4689
524a0357d05b
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
2078 | image = gtk_image_new_from_pixbuf(scale); |
|
4669
879e30ac4cf3
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2079 | |
|
879e30ac4cf3
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2080 | gtk_size_group_add_widget(sg, image); |
|
879e30ac4cf3
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2081 | |
|
4689
524a0357d05b
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
2082 | g_object_unref(G_OBJECT(scale)); |
|
524a0357d05b
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
2083 | g_object_unref(G_OBJECT(pixbuf)); |
|
4669
879e30ac4cf3
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2084 | |
|
879e30ac4cf3
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2085 | /* Make our menu item */ |
|
879e30ac4cf3
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2086 | menuitem = gtk_radio_menu_item_new_with_label(group, gc->username); |
| 4359 | 2087 | group = gtk_radio_menu_item_group(GTK_RADIO_MENU_ITEM(menuitem)); |
| 2088 | ||
|
4669
879e30ac4cf3
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2089 | /* Do some evil, see some evil, speak some evil. */ |
|
879e30ac4cf3
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2090 | box = gtk_hbox_new(FALSE, 0); |
|
879e30ac4cf3
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2091 | |
|
879e30ac4cf3
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2092 | label = gtk_bin_get_child(GTK_BIN(menuitem)); |
|
879e30ac4cf3
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2093 | g_object_ref(label); |
|
879e30ac4cf3
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2094 | gtk_container_remove(GTK_CONTAINER(menuitem), label); |
|
879e30ac4cf3
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2095 | |
|
879e30ac4cf3
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2096 | gtk_box_pack_start(GTK_BOX(box), image, FALSE, FALSE, 0); |
|
879e30ac4cf3
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2097 | gtk_box_pack_start(GTK_BOX(box), label, TRUE, TRUE, 4); |
|
879e30ac4cf3
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2098 | |
|
879e30ac4cf3
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2099 | g_object_unref(label); |
|
879e30ac4cf3
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2100 | |
|
879e30ac4cf3
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2101 | gtk_container_add(GTK_CONTAINER(menuitem), box); |
|
879e30ac4cf3
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2102 | |
|
879e30ac4cf3
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2103 | gtk_widget_show(label); |
|
879e30ac4cf3
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2104 | gtk_widget_show(image); |
|
879e30ac4cf3
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2105 | gtk_widget_show(box); |
|
879e30ac4cf3
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2106 | |
|
879e30ac4cf3
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2107 | /* Set our data and callbacks. */ |
| 4359 | 2108 | g_object_set_data(G_OBJECT(menuitem), "user_data", win); |
| 4673 | 2109 | g_object_set_data(G_OBJECT(menuitem), "gaim_account", gc->account); |
| 4359 | 2110 | |
| 4685 | 2111 | g_signal_connect_after(G_OBJECT(menuitem), "activate", |
| 4673 | 2112 | G_CALLBACK(menu_conv_sel_send_cb), NULL); |
| 4359 | 2113 | |
| 2114 | gtk_widget_show(menuitem); | |
| 2115 | gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem); | |
| 2116 | } | |
| 2117 | ||
| 2118 | /* | |
| 2119 | * Fill it with any accounts that still has an open (yet disabled) window | |
| 2120 | * (signed off accounts with a window open). | |
| 2121 | */ | |
| 2122 | for (convs = gaim_get_conversations(); | |
| 2123 | convs != NULL; | |
| 2124 | convs = convs->next) { | |
| 2125 | ||
| 2126 | struct gaim_conversation *conv; | |
| 4491 | 2127 | struct gaim_account *account; |
|
4669
879e30ac4cf3
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2128 | GtkWidget *box; |
|
879e30ac4cf3
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2129 | GtkWidget *label; |
|
879e30ac4cf3
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2130 | GtkWidget *image; |
|
4689
524a0357d05b
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
2131 | GdkPixbuf *pixbuf, *scale; |
| 4359 | 2132 | |
| 2133 | conv = (struct gaim_conversation *)convs->data; | |
|
4360
28aa945b7c16
[gaim-migrate @ 4626]
Christian Hammond <chipx86@chipx86.com>
parents:
4359
diff
changeset
|
2134 | |
|
28aa945b7c16
[gaim-migrate @ 4626]
Christian Hammond <chipx86@chipx86.com>
parents:
4359
diff
changeset
|
2135 | if (conv == deleted_conv) |
|
28aa945b7c16
[gaim-migrate @ 4626]
Christian Hammond <chipx86@chipx86.com>
parents:
4359
diff
changeset
|
2136 | continue; |
|
28aa945b7c16
[gaim-migrate @ 4626]
Christian Hammond <chipx86@chipx86.com>
parents:
4359
diff
changeset
|
2137 | |
| 4491 | 2138 | account = gaim_conversation_get_account(conv); |
| 2139 | ||
| 2140 | if (account->gc == NULL) { | |
| 4359 | 2141 | if (first_offline && found_online) { |
| 2142 | menuitem = gtk_separator_menu_item_new(); | |
| 2143 | gtk_widget_show(menuitem); | |
| 2144 | gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem); | |
| 2145 | ||
| 2146 | first_offline = FALSE; | |
| 2147 | } | |
| 2148 | ||
|
4669
879e30ac4cf3
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2149 | /* Create a pixmap for the protocol icon. */ |
|
4689
524a0357d05b
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
2150 | pixbuf = create_prpl_icon(account); |
|
524a0357d05b
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
2151 | scale = gdk_pixbuf_scale_simple(pixbuf, 16, 16, |
|
524a0357d05b
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
2152 | GDK_INTERP_BILINEAR); |
|
4669
879e30ac4cf3
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2153 | |
|
879e30ac4cf3
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2154 | /* Now convert it to GtkImage */ |
|
4689
524a0357d05b
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
2155 | if (pixbuf == NULL) |
|
4669
879e30ac4cf3
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2156 | image = gtk_image_new(); |
|
879e30ac4cf3
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2157 | else |
|
4689
524a0357d05b
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
2158 | image = gtk_image_new_from_pixbuf(scale); |
|
4669
879e30ac4cf3
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2159 | |
|
879e30ac4cf3
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2160 | gtk_size_group_add_widget(sg, image); |
|
879e30ac4cf3
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2161 | |
|
4689
524a0357d05b
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
2162 | if (scale != NULL) g_object_unref(scale); |
|
524a0357d05b
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
2163 | if (pixbuf != NULL) g_object_unref(pixbuf); |
|
4669
879e30ac4cf3
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2164 | |
|
879e30ac4cf3
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2165 | /* Make our menu item */ |
| 4359 | 2166 | menuitem = gtk_radio_menu_item_new_with_label(group, |
| 4491 | 2167 | account->username); |
| 4359 | 2168 | group = gtk_radio_menu_item_group(GTK_RADIO_MENU_ITEM(menuitem)); |
| 2169 | ||
|
4669
879e30ac4cf3
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2170 | /* Do some evil, see some evil, speak some evil. */ |
|
879e30ac4cf3
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2171 | box = gtk_hbox_new(FALSE, 0); |
|
879e30ac4cf3
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2172 | |
|
879e30ac4cf3
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2173 | label = gtk_bin_get_child(GTK_BIN(menuitem)); |
|
879e30ac4cf3
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2174 | g_object_ref(label); |
|
879e30ac4cf3
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2175 | gtk_container_remove(GTK_CONTAINER(menuitem), label); |
|
879e30ac4cf3
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2176 | |
|
879e30ac4cf3
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2177 | gtk_box_pack_start(GTK_BOX(box), image, FALSE, FALSE, 0); |
|
879e30ac4cf3
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2178 | gtk_box_pack_start(GTK_BOX(box), label, TRUE, TRUE, 4); |
|
879e30ac4cf3
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2179 | |
|
879e30ac4cf3
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2180 | g_object_unref(label); |
|
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 | gtk_container_add(GTK_CONTAINER(menuitem), box); |
|
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_widget_show(label); |
|
879e30ac4cf3
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2185 | gtk_widget_show(image); |
|
879e30ac4cf3
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2186 | gtk_widget_show(box); |
|
879e30ac4cf3
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2187 | |
| 4359 | 2188 | gtk_widget_set_sensitive(menuitem, FALSE); |
| 4674 | 2189 | g_object_set_data(G_OBJECT(menuitem), "gaim_account", account); |
| 4359 | 2190 | |
| 2191 | gtk_widget_show(menuitem); | |
| 2192 | gtk_menu_shell_append(GTK_MENU_SHELL(menu), menuitem); | |
| 2193 | } | |
| 2194 | } | |
| 2195 | ||
|
4669
879e30ac4cf3
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2196 | g_object_unref(sg); |
|
879e30ac4cf3
[gaim-migrate @ 4980]
Christian Hammond <chipx86@chipx86.com>
parents:
4668
diff
changeset
|
2197 | |
| 4359 | 2198 | gtk_widget_show(gtkwin->menu.send_as); |
| 2199 | update_send_as_selection(win); | |
| 2200 | } | |
| 2201 | ||
| 2202 | static GList * | |
| 2203 | generate_invite_user_names(struct gaim_connection *gc) | |
| 2204 | { | |
| 4770 | 2205 | GSList *grp = gaim_blist_groups(), *grp1; |
| 2206 | GSList *bl, *bl1; | |
| 4359 | 2207 | struct group *g; |
| 2208 | struct buddy *buddy; | |
| 2209 | static GList *tmp = NULL; | |
| 2210 | ||
| 2211 | if (tmp) | |
| 2212 | g_list_free(tmp); | |
| 2213 | ||
| 2214 | tmp = g_list_append(NULL, ""); | |
| 2215 | ||
| 2216 | if (gc != NULL) { | |
| 4770 | 2217 | for (grp1 = grp; grp1 != NULL; grp1 = grp1->next) { |
| 2218 | g = (struct group *)grp1->data; | |
| 2219 | bl = gaim_blist_members(g); | |
| 2220 | for (bl1 = bl; bl1 != NULL; bl1 = bl1->next) { | |
| 2221 | buddy = (struct buddy *)bl1->data; | |
| 4359 | 2222 | |
| 2223 | if (buddy->present) | |
| 2224 | tmp = g_list_append(tmp, buddy->name); | |
| 2225 | } | |
| 4770 | 2226 | g_slist_free(bl); |
| 4359 | 2227 | } |
| 4770 | 2228 | g_slist_free(grp); |
| 4359 | 2229 | } |
| 2230 | ||
| 2231 | return tmp; | |
| 2232 | } | |
| 2233 | ||
| 2234 | static void | |
| 2235 | add_chat_buddy_common(struct gaim_conversation *conv, const char *name, | |
| 2236 | int pos) | |
| 2237 | { | |
| 2238 | struct gaim_gtk_conversation *gtkconv; | |
| 2239 | struct gaim_gtk_chat_pane *gtkchat; | |
| 2240 | struct gaim_chat *chat; | |
| 2241 | GtkTreeIter iter; | |
| 2242 | GtkListStore *ls; | |
| 2243 | ||
| 2244 | chat = GAIM_CHAT(conv); | |
| 2245 | gtkconv = GAIM_GTK_CONVERSATION(conv); | |
| 2246 | gtkchat = gtkconv->u.chat; | |
| 2247 | ||
| 2248 | ls = GTK_LIST_STORE(gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list))); | |
| 2249 | ||
| 2250 | gtk_list_store_append(ls, &iter); | |
| 2251 | gtk_list_store_set(ls, &iter, 0, | |
| 2252 | (gaim_chat_is_user_ignored(chat, name) ? "X" : " "), | |
| 2253 | 1, name, -1); | |
| 2254 | gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(ls), 1, | |
| 2255 | GTK_SORT_ASCENDING); | |
| 2256 | } | |
| 2257 | ||
| 2258 | static void | |
| 2259 | tab_complete(struct gaim_conversation *conv) | |
| 2260 | { | |
| 2261 | struct gaim_gtk_conversation *gtkconv; | |
| 2262 | struct gaim_chat *chat; | |
| 2263 | GtkTextIter cursor, word_start, start_buffer; | |
| 2264 | int start; | |
| 2265 | int most_matched = -1; | |
| 2266 | char *entered, *partial = NULL; | |
| 2267 | char *text; | |
| 2268 | GList *matches = NULL; | |
| 2269 | GList *nicks = NULL; | |
| 2270 | ||
| 2271 | gtkconv = GAIM_GTK_CONVERSATION(conv); | |
| 2272 | chat = GAIM_CHAT(conv); | |
| 2273 | ||
| 2274 | gtk_text_buffer_get_start_iter(gtkconv->entry_buffer, &start_buffer); | |
| 2275 | gtk_text_buffer_get_iter_at_mark(gtkconv->entry_buffer, &cursor, | |
| 2276 | gtk_text_buffer_get_insert(gtkconv->entry_buffer)); | |
| 2277 | ||
| 2278 | word_start = cursor; | |
| 2279 | ||
| 2280 | /* if there's nothing there just return */ | |
| 2281 | if (!gtk_text_iter_compare(&cursor, &start_buffer)) | |
| 2282 | return; | |
| 2283 | ||
| 2284 | text = gtk_text_buffer_get_text(gtkconv->entry_buffer, &start_buffer, | |
| 2285 | &cursor, FALSE); | |
| 2286 | ||
| 2287 | /* if we're at the end of ": " we need to move back 2 spaces */ | |
| 2288 | start = strlen(text) - 1; | |
| 2289 | ||
| 2290 | if (strlen(text) >= 2 && !strncmp(&text[start-1], ": ", 2)) | |
| 2291 | gtk_text_iter_backward_chars(&word_start, 2); | |
| 2292 | ||
| 2293 | /* find the start of the word that we're tabbing */ | |
| 2294 | while (start >= 0 && text[start] != ' ') { | |
| 2295 | gtk_text_iter_backward_char(&word_start); | |
| 2296 | start--; | |
| 2297 | } | |
| 2298 | ||
| 2299 | g_free(text); | |
| 2300 | ||
| 2301 | entered = gtk_text_buffer_get_text(gtkconv->entry_buffer, &word_start, | |
| 2302 | &cursor, FALSE); | |
| 2303 | ||
| 2304 | if (chat_options & OPT_CHAT_OLD_STYLE_TAB) { | |
| 2305 | if (strlen(entered) >= 2 && | |
| 2306 | !strncmp(": ", entered + strlen(entered) - 2, 2)) { | |
| 2307 | ||
| 2308 | entered[strlen(entered) - 2] = 0; | |
| 2309 | } | |
| 2310 | } | |
| 2311 | ||
| 2312 | if (!strlen(entered)) { | |
| 2313 | g_free(entered); | |
| 2314 | return; | |
| 2315 | } | |
| 2316 | ||
| 2317 | for (nicks = gaim_chat_get_users(chat); | |
| 2318 | nicks != NULL; | |
| 2319 | nicks = nicks->next) { | |
| 2320 | ||
| 2321 | char *nick = nicks->data; | |
| 2322 | /* this checks to see if the current nick could be a completion */ | |
| 2323 | if (g_strncasecmp(nick, entered, strlen(entered))) { | |
|
4621
c1d2f34bf634
[gaim-migrate @ 4912]
Christian Hammond <chipx86@chipx86.com>
parents:
4608
diff
changeset
|
2324 | if (*nick != '+' && *nick != '@' && *nick != '%') |
| 4359 | 2325 | continue; |
| 2326 | ||
| 2327 | if (g_strncasecmp(nick + 1, entered, strlen(entered))) { | |
| 2328 | if (nick[0] != '@' || nick[1] != '+') | |
| 2329 | continue; | |
| 2330 | ||
| 2331 | if (g_strncasecmp(nick + 2, entered, strlen(entered))) | |
| 2332 | continue; | |
| 2333 | else | |
| 2334 | nick += 2; | |
| 2335 | } | |
| 2336 | else | |
| 2337 | nick++; | |
| 2338 | } | |
| 2339 | ||
| 2340 | /* if we're here, it's a possible completion */ | |
| 2341 | ||
| 2342 | /* if we're doing old-style, just fill in the completion */ | |
| 2343 | if (chat_options & OPT_CHAT_OLD_STYLE_TAB) { | |
| 2344 | gtk_text_buffer_delete(gtkconv->entry_buffer, | |
| 2345 | &word_start, &cursor); | |
| 2346 | ||
| 2347 | if (strlen(nick) == strlen(entered)) { | |
| 2348 | nicks = (nicks->next | |
| 2349 | ? nicks->next | |
| 2350 | : gaim_chat_get_users(chat)); | |
| 2351 | ||
| 2352 | nick = nicks->data; | |
| 2353 | ||
| 2354 | if (*nick == '@') nick++; | |
|
4621
c1d2f34bf634
[gaim-migrate @ 4912]
Christian Hammond <chipx86@chipx86.com>
parents:
4608
diff
changeset
|
2355 | if (*nick == '%') nick++; |
| 4359 | 2356 | if (*nick == '+') nick++; |
| 2357 | } | |
| 2358 | ||
| 2359 | gtk_text_buffer_get_start_iter(gtkconv->entry_buffer, | |
| 2360 | &start_buffer); | |
| 2361 | gtk_text_buffer_get_iter_at_mark(gtkconv->entry_buffer, &cursor, | |
| 2362 | gtk_text_buffer_get_insert(gtkconv->entry_buffer)); | |
| 2363 | ||
| 2364 | if (!gtk_text_iter_compare(&cursor, &start_buffer)) { | |
| 2365 | char *tmp = g_strdup_printf("%s: ", nick); | |
| 2366 | gtk_text_buffer_insert_at_cursor(gtkconv->entry_buffer, | |
| 2367 | tmp, -1); | |
| 2368 | g_free(tmp); | |
| 2369 | } | |
| 2370 | else | |
| 2371 | gtk_text_buffer_insert_at_cursor(gtkconv->entry_buffer, | |
| 2372 | nick, -1); | |
| 2373 | ||
| 2374 | g_free(entered); | |
| 2375 | ||
| 2376 | return; | |
| 2377 | } | |
| 2378 | ||
| 2379 | /* we're only here if we're doing new style */ | |
| 2380 | if (most_matched == -1) { | |
| 2381 | /* | |
| 2382 | * this will only get called once, since from now | |
| 2383 | * on most_matched is >= 0 | |
| 2384 | */ | |
| 2385 | most_matched = strlen(nick); | |
| 2386 | partial = g_strdup(nick); | |
| 2387 | } | |
| 2388 | else if (most_matched) { | |
| 2389 | while (g_strncasecmp(nick, partial, most_matched)) | |
| 2390 | most_matched--; | |
| 2391 | ||
| 2392 | partial[most_matched] = 0; | |
| 2393 | } | |
| 2394 | ||
| 2395 | matches = g_list_append(matches, nick); | |
| 2396 | } | |
| 2397 | ||
| 2398 | /* we're only here if we're doing new style */ | |
| 2399 | ||
| 2400 | /* if there weren't any matches, return */ | |
| 2401 | if (!matches) { | |
| 2402 | /* if matches isn't set partials won't be either */ | |
| 2403 | g_free(entered); | |
| 2404 | return; | |
| 2405 | } | |
| 2406 | ||
| 2407 | gtk_text_buffer_delete(gtkconv->entry_buffer, &word_start, &cursor); | |
| 2408 | ||
| 2409 | if (!matches->next) { | |
| 2410 | /* there was only one match. fill it in. */ | |
| 2411 | gtk_text_buffer_get_start_iter(gtkconv->entry_buffer, &start_buffer); | |
| 2412 | gtk_text_buffer_get_iter_at_mark(gtkconv->entry_buffer, &cursor, | |
| 2413 | gtk_text_buffer_get_insert(gtkconv->entry_buffer)); | |
| 2414 | ||
| 2415 | if (!gtk_text_iter_compare(&cursor, &start_buffer)) { | |
| 2416 | char *tmp = g_strdup_printf("%s: ", (char *)matches->data); | |
| 2417 | gtk_text_buffer_insert_at_cursor(gtkconv->entry_buffer, tmp, -1); | |
| 2418 | g_free(tmp); | |
| 2419 | } | |
| 2420 | else | |
| 2421 | gtk_text_buffer_insert_at_cursor(gtkconv->entry_buffer, | |
| 2422 | matches->data, -1); | |
| 2423 | ||
| 2424 | matches = g_list_remove(matches, matches->data); | |
| 2425 | } | |
| 2426 | else { | |
| 2427 | /* | |
| 2428 | * there were lots of matches, fill in as much as possible | |
| 2429 | * and display all of them | |
| 2430 | */ | |
| 2431 | char *addthis = g_malloc0(1); | |
| 2432 | ||
| 2433 | while (matches) { | |
| 2434 | char *tmp = addthis; | |
| 2435 | addthis = g_strconcat(tmp, matches->data, " ", NULL); | |
| 2436 | g_free(tmp); | |
| 2437 | matches = g_list_remove(matches, matches->data); | |
| 2438 | } | |
| 2439 | ||
| 2440 | gaim_conversation_write(conv, NULL, addthis, -1, WFLAG_NOLOG, | |
| 2441 | time(NULL)); | |
| 2442 | gtk_text_buffer_insert_at_cursor(gtkconv->entry_buffer, partial, -1); | |
| 2443 | g_free(addthis); | |
| 2444 | } | |
| 2445 | ||
| 2446 | g_free(entered); | |
| 2447 | g_free(partial); | |
| 2448 | } | |
| 2449 | ||
| 2450 | static gboolean | |
| 2451 | meify(char *message, size_t len) | |
| 2452 | { | |
| 2453 | /* | |
| 2454 | * Read /me-ify: If the message (post-HTML) starts with /me, | |
| 2455 | * remove the "/me " part of it (including that space) and return TRUE. | |
| 2456 | */ | |
| 2457 | char *c; | |
| 2458 | gboolean inside_html = 0; | |
| 2459 | ||
| 2460 | if (message == NULL) | |
| 2461 | return FALSE; /* Umm.. this would be very bad if this happens. */ | |
| 2462 | ||
| 2463 | if (len == -1) | |
| 2464 | len = strlen(message); | |
| 2465 | ||
| 2466 | for (c = message; *c != '\0'; c++, len--) { | |
| 2467 | if (inside_html) { | |
| 2468 | if (*c == '>') | |
| 2469 | inside_html = FALSE; | |
| 2470 | } | |
| 2471 | else { | |
| 2472 | if (*c == '<') | |
| 2473 | inside_html = TRUE; | |
| 2474 | else | |
| 2475 | break; | |
| 2476 | } | |
| 2477 | } | |
| 2478 | ||
| 2479 | if (*c != '\0' && !g_strncasecmp(c, "/me ", 4)) { | |
| 2480 | memmove(c, c + 4, len - 3); | |
| 2481 | ||
| 2482 | return TRUE; | |
| 2483 | } | |
| 2484 | ||
| 2485 | return FALSE; | |
| 2486 | } | |
| 2487 | ||
| 2488 | static GtkItemFactoryEntry menu_items[] = | |
| 2489 | { | |
| 2490 | /* Conversation menu */ | |
|
4596
64e72bf4ece4
[gaim-migrate @ 4881]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
4578
diff
changeset
|
2491 | { N_("/_Conversation"), NULL, NULL, 0, "<Branch>" }, |
|
64e72bf4ece4
[gaim-migrate @ 4881]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
4578
diff
changeset
|
2492 | { N_("/Conversation/_Save As..."), NULL, menu_save_as_cb, 0, |
| 4359 | 2493 | "<StockItem>", GTK_STOCK_SAVE_AS }, |
|
4596
64e72bf4ece4
[gaim-migrate @ 4881]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
4578
diff
changeset
|
2494 | { N_("/Conversation/View _History..."), NULL, menu_view_history_cb, 0, NULL }, |
| 4359 | 2495 | { "/Conversation/sep1", NULL, NULL, 0, "<Separator>" }, |
|
4596
64e72bf4ece4
[gaim-migrate @ 4881]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
4578
diff
changeset
|
2496 | { N_("/Conversation/Insert _URL..."), NULL, menu_insert_link_cb, 0, |
| 4359 | 2497 | "<StockItem>", GAIM_STOCK_LINK }, |
|
4596
64e72bf4ece4
[gaim-migrate @ 4881]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
4578
diff
changeset
|
2498 | { N_("/Conversation/Insert _Image..."), NULL, menu_insert_image_cb, 0, |
| 4359 | 2499 | "<StockItem>", GAIM_STOCK_IMAGE }, |
| 2500 | { "/Conversation/sep2", NULL, NULL, 0, "<Separator>" }, | |
|
4596
64e72bf4ece4
[gaim-migrate @ 4881]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
4578
diff
changeset
|
2501 | { N_("/Conversation/_Close"), NULL, menu_close_conv_cb, 0, |
| 4359 | 2502 | "<StockItem>", GTK_STOCK_CLOSE }, |
| 2503 | ||
| 2504 | /* Options */ | |
|
4596
64e72bf4ece4
[gaim-migrate @ 4881]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
4578
diff
changeset
|
2505 | { N_("/_Options"), NULL, NULL, 0, "<Branch>" }, |
|
64e72bf4ece4
[gaim-migrate @ 4881]
Björn Voigt <bjoern@cs.tu-berlin.de>
parents:
4578
diff
changeset
|
2506 | { 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
|
2507 | { N_("/Options/Enable _Sounds"), NULL, menu_sounds_cb, 0, "<CheckItem>" }, |
| 4359 | 2508 | }; |
| 2509 | ||
|
4602
a030b07555d2
[gaim-migrate @ 4889]
Christian Hammond <chipx86@chipx86.com>
parents:
4598
diff
changeset
|
2510 | static const int menu_item_count = |
| 4359 | 2511 | sizeof(menu_items) / sizeof(*menu_items); |
| 2512 | ||
|
4602
a030b07555d2
[gaim-migrate @ 4889]
Christian Hammond <chipx86@chipx86.com>
parents:
4598
diff
changeset
|
2513 | static char * |
|
a030b07555d2
[gaim-migrate @ 4889]
Christian Hammond <chipx86@chipx86.com>
parents:
4598
diff
changeset
|
2514 | item_factory_translate_func (const char *path, gpointer func_data) |
|
a030b07555d2
[gaim-migrate @ 4889]
Christian Hammond <chipx86@chipx86.com>
parents:
4598
diff
changeset
|
2515 | { |
|
a030b07555d2
[gaim-migrate @ 4889]
Christian Hammond <chipx86@chipx86.com>
parents:
4598
diff
changeset
|
2516 | return _(path); |
|
a030b07555d2
[gaim-migrate @ 4889]
Christian Hammond <chipx86@chipx86.com>
parents:
4598
diff
changeset
|
2517 | } |
|
a030b07555d2
[gaim-migrate @ 4889]
Christian Hammond <chipx86@chipx86.com>
parents:
4598
diff
changeset
|
2518 | |
| 4359 | 2519 | static GtkWidget * |
| 2520 | setup_menubar(struct gaim_window *win) | |
| 2521 | { | |
| 2522 | struct gaim_gtk_window *gtkwin; | |
| 2523 | GtkWidget *hb; | |
| 2524 | ||
| 2525 | gtkwin = GAIM_GTK_WINDOW(win); | |
| 2526 | ||
| 2527 | /* Create the handle box. */ | |
| 2528 | hb = gtk_handle_box_new(); | |
| 2529 | ||
| 4630 | 2530 | gtkwin->menu.item_factory = gtk_item_factory_new(GTK_TYPE_MENU_BAR, |
| 2531 | "<main>", NULL); | |
| 2532 | ||
| 2533 | gtk_item_factory_set_translate_func (gtkwin->menu.item_factory, | |
|
4602
a030b07555d2
[gaim-migrate @ 4889]
Christian Hammond <chipx86@chipx86.com>
parents:
4598
diff
changeset
|
2534 | item_factory_translate_func, |
|
a030b07555d2
[gaim-migrate @ 4889]
Christian Hammond <chipx86@chipx86.com>
parents:
4598
diff
changeset
|
2535 | NULL, NULL); |
| 4630 | 2536 | |
| 2537 | gtk_item_factory_create_items(gtkwin->menu.item_factory, menu_item_count, | |
| 4359 | 2538 | menu_items, win); |
| 2539 | ||
| 4630 | 2540 | gtkwin->menu.menubar = gtk_item_factory_get_widget(gtkwin->menu.item_factory, |
| 2541 | "<main>"); | |
| 2542 | gtkwin->menu.view_history = gtk_item_factory_get_widget(gtkwin->menu.item_factory, | |
| 4359 | 2543 | "/Conversation/View History..."); |
| 4630 | 2544 | gtkwin->menu.insert_link = gtk_item_factory_get_widget(gtkwin->menu.item_factory, |
| 4359 | 2545 | "/Conversation/Insert URL..."); |
| 4630 | 2546 | gtkwin->menu.insert_image = gtk_item_factory_get_widget(gtkwin->menu.item_factory, |
| 4359 | 2547 | "/Conversation/Insert Image..."); |
| 4630 | 2548 | gtkwin->menu.logging = gtk_item_factory_get_widget(gtkwin->menu.item_factory, |
| 4359 | 2549 | "/Options/Enable Logging"); |
| 4630 | 2550 | gtkwin->menu.sounds = gtk_item_factory_get_widget(gtkwin->menu.item_factory, |
| 4359 | 2551 | "/Options/Enable Sounds"); |
| 2552 | ||
|
4360
28aa945b7c16
[gaim-migrate @ 4626]
Christian Hammond <chipx86@chipx86.com>
parents:
4359
diff
changeset
|
2553 | generate_send_as_items(win, NULL); |
| 4359 | 2554 | |
| 2555 | gtk_container_add(GTK_CONTAINER(hb), gtkwin->menu.menubar); | |
| 2556 | ||
| 2557 | gtk_widget_show(gtkwin->menu.menubar); | |
| 2558 | gtk_widget_show(hb); | |
| 2559 | ||
| 2560 | return hb; | |
| 2561 | } | |
| 2562 | ||
| 2563 | static void | |
| 2564 | setup_im_buttons(struct gaim_conversation *conv, GtkWidget *parent) | |
| 2565 | { | |
| 2566 | struct gaim_connection *gc; | |
| 2567 | struct gaim_gtk_conversation *gtkconv; | |
| 2568 | struct gaim_gtk_im_pane *gtkim; | |
| 2569 | GaimConversationType type = GAIM_CONV_IM; | |
| 2570 | ||
| 2571 | gtkconv = GAIM_GTK_CONVERSATION(conv); | |
| 2572 | gtkim = gtkconv->u.im; | |
| 2573 | gc = gaim_conversation_get_gc(conv); | |
| 2574 | ||
| 2575 | /* From right to left... */ | |
| 2576 | ||
| 2577 | /* Send button */ | |
| 2578 | gtkconv->send = gaim_gtk_change_text(_("Send"), gtkconv->send, | |
| 2579 | GAIM_STOCK_SEND, type); | |
| 2580 | gtk_tooltips_set_tip(gtkconv->tooltips, gtkconv->send, _("Send"), NULL); | |
| 2581 | ||
| 2582 | gtk_box_pack_end(GTK_BOX(parent), gtkconv->send, FALSE, FALSE, 0); | |
| 2583 | ||
| 2584 | /* Separator */ | |
| 2585 | if (gtkim->sep2 != NULL) | |
| 2586 | gtk_widget_destroy(gtkim->sep2); | |
| 2587 | ||
| 2588 | gtkim->sep2 = gtk_vseparator_new(); | |
| 2589 | gtk_box_pack_end(GTK_BOX(parent), gtkim->sep2, FALSE, TRUE, 0); | |
| 2590 | gtk_widget_show(gtkim->sep2); | |
| 2591 | ||
| 2592 | /* Now, um, just kind of all over the place. Huh? */ | |
| 2593 | ||
| 2594 | /* Add button */ | |
|
4689
524a0357d05b
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
2595 | if (gaim_find_buddy(gaim_conversation_get_account(conv), |
|
524a0357d05b
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
2596 | gaim_conversation_get_name(conv)) == NULL) { |
|
524a0357d05b
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
2597 | |
| 4359 | 2598 | gtkim->add = gaim_gtk_change_text(_("Add"), gtkim->add, |
| 2599 | GTK_STOCK_ADD, type); | |
| 2600 | gtk_tooltips_set_tip(gtkconv->tooltips, gtkim->add, | |
|
4370
8a804f16341c
[gaim-migrate @ 4636]
Christian Hammond <chipx86@chipx86.com>
parents:
4369
diff
changeset
|
2601 | _("Add the user to your buddy list"), NULL); |
| 4359 | 2602 | } |
| 2603 | else { | |
| 2604 | gtkim->add = gaim_gtk_change_text(_("Remove"), gtkim->add, | |
| 2605 | GTK_STOCK_REMOVE, 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 | _("Remove the user from your buddy list"), NULL); |
| 4359 | 2608 | } |
| 2609 | ||
| 2610 | gtk_box_pack_start(GTK_BOX(parent), gtkim->add, | |
| 2611 | FALSE, FALSE, 0); | |
| 2612 | ||
| 2613 | /* Warn button */ | |
| 2614 | gtkim->warn = gaim_gtk_change_text(_("Warn"), gtkim->warn, | |
| 2615 | GAIM_STOCK_WARN, type); | |
| 2616 | 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
|
2617 | gtk_tooltips_set_tip(gtkconv->tooltips, gtkim->warn, |
|
8a804f16341c
[gaim-migrate @ 4636]
Christian Hammond <chipx86@chipx86.com>
parents:
4369
diff
changeset
|
2618 | _("Warn the user"), NULL); |
| 4359 | 2619 | |
| 2620 | /* Info button */ | |
| 2621 | gtkconv->info = gaim_gtk_change_text(_("Info"), gtkconv->info, | |
| 2622 | GAIM_STOCK_INFO, type); | |
| 2623 | gtk_box_pack_start(GTK_BOX(parent), gtkconv->info, FALSE, FALSE, 0); | |
| 2624 | gtk_tooltips_set_tip(gtkconv->tooltips, gtkconv->info, | |
|
4370
8a804f16341c
[gaim-migrate @ 4636]
Christian Hammond <chipx86@chipx86.com>
parents:
4369
diff
changeset
|
2625 | _("Get the user's information"), NULL); |
| 4359 | 2626 | |
| 2627 | /* Block button */ | |
| 2628 | gtkim->block = gaim_gtk_change_text(_("Block"), gtkim->block, | |
| 2629 | GAIM_STOCK_BLOCK, type); | |
| 2630 | gtk_box_pack_start(GTK_BOX(parent), gtkim->block, FALSE, FALSE, 0); | |
| 2631 | gtk_tooltips_set_tip(gtkconv->tooltips, gtkim->block, | |
|
4370
8a804f16341c
[gaim-migrate @ 4636]
Christian Hammond <chipx86@chipx86.com>
parents:
4369
diff
changeset
|
2632 | _("Block the user"), NULL); |
| 4359 | 2633 | |
| 2634 | gtk_button_set_relief(GTK_BUTTON(gtkconv->info), GTK_RELIEF_NONE); | |
| 2635 | gtk_button_set_relief(GTK_BUTTON(gtkim->add), GTK_RELIEF_NONE); | |
| 2636 | gtk_button_set_relief(GTK_BUTTON(gtkim->warn), GTK_RELIEF_NONE); | |
| 2637 | gtk_button_set_relief(GTK_BUTTON(gtkconv->send), GTK_RELIEF_NONE); | |
| 2638 | gtk_button_set_relief(GTK_BUTTON(gtkim->block), GTK_RELIEF_NONE); | |
| 2639 | ||
| 2640 | gtk_size_group_add_widget(gtkconv->sg, gtkconv->info); | |
| 2641 | gtk_size_group_add_widget(gtkconv->sg, gtkim->add); | |
| 2642 | gtk_size_group_add_widget(gtkconv->sg, gtkim->warn); | |
| 2643 | gtk_size_group_add_widget(gtkconv->sg, gtkconv->send); | |
| 2644 | gtk_size_group_add_widget(gtkconv->sg, gtkim->block); | |
| 2645 | ||
| 2646 | gtk_box_reorder_child(GTK_BOX(parent), gtkim->warn, 1); | |
| 2647 | gtk_box_reorder_child(GTK_BOX(parent), gtkim->block, 2); | |
|
4370
8a804f16341c
[gaim-migrate @ 4636]
Christian Hammond <chipx86@chipx86.com>
parents:
4369
diff
changeset
|
2648 | gtk_box_reorder_child(GTK_BOX(parent), gtkim->add, 3); |
| 4359 | 2649 | gtk_box_reorder_child(GTK_BOX(parent), gtkconv->info, 4); |
| 2650 | ||
| 2651 | gaim_gtkconv_update_buttons_by_protocol(conv); | |
| 2652 | ||
| 2653 | g_signal_connect(G_OBJECT(gtkconv->send), "clicked", | |
| 2654 | G_CALLBACK(send_cb), conv); | |
| 2655 | g_signal_connect(G_OBJECT(gtkconv->info), "clicked", | |
| 2656 | G_CALLBACK(info_cb), conv); | |
| 2657 | g_signal_connect(G_OBJECT(gtkim->warn), "clicked", | |
| 2658 | G_CALLBACK(warn_cb), conv); | |
| 2659 | g_signal_connect(G_OBJECT(gtkim->block), "clicked", | |
| 2660 | G_CALLBACK(block_cb), conv); | |
| 2661 | } | |
| 2662 | ||
| 2663 | static void | |
| 2664 | setup_chat_buttons(struct gaim_conversation *conv, GtkWidget *parent) | |
| 2665 | { | |
| 2666 | struct gaim_connection *gc; | |
| 2667 | struct gaim_gtk_conversation *gtkconv; | |
| 2668 | struct gaim_gtk_chat_pane *gtkchat; | |
| 2669 | struct gaim_gtk_window *gtkwin; | |
| 2670 | GtkWidget *sep; | |
| 2671 | ||
| 2672 | gtkconv = GAIM_GTK_CONVERSATION(conv); | |
| 2673 | gtkchat = gtkconv->u.chat; | |
| 2674 | gtkwin = GAIM_GTK_WINDOW(gaim_conversation_get_window(conv)); | |
| 2675 | gc = gaim_conversation_get_gc(conv); | |
| 2676 | ||
| 2677 | /* Send button */ | |
| 2678 | gtkconv->send = gaim_gtk_change_text(_("Send"), gtkconv->send, | |
| 2679 | GAIM_STOCK_SEND, GAIM_CONV_CHAT); | |
| 2680 | gtk_tooltips_set_tip(gtkconv->tooltips, gtkconv->send, _("Send"), NULL); | |
| 2681 | ||
| 2682 | gtk_box_pack_end(GTK_BOX(parent), gtkconv->send, FALSE, FALSE, 0); | |
| 2683 | ||
| 2684 | /* Separator */ | |
| 2685 | sep = gtk_vseparator_new(); | |
| 2686 | gtk_box_pack_end(GTK_BOX(parent), sep, FALSE, TRUE, 0); | |
| 2687 | gtk_widget_show(sep); | |
| 2688 | ||
| 2689 | /* Invite */ | |
| 2690 | gtkchat->invite = gaim_gtk_change_text(_("Invite"), gtkchat->invite, | |
| 2691 | GAIM_STOCK_INVITE, GAIM_CONV_CHAT); | |
| 2692 | gtk_tooltips_set_tip(gtkconv->tooltips, gtkchat->invite, | |
| 2693 | _("Invite a user"), NULL); | |
| 2694 | gtk_box_pack_end(GTK_BOX(parent), gtkchat->invite, FALSE, FALSE, 0); | |
| 2695 | ||
| 2696 | /* Set the relief on these. */ | |
| 2697 | gtk_button_set_relief(GTK_BUTTON(gtkchat->invite), GTK_RELIEF_NONE); | |
| 2698 | gtk_button_set_relief(GTK_BUTTON(gtkconv->send), GTK_RELIEF_NONE); | |
| 2699 | ||
| 2700 | /* Callbacks */ | |
| 2701 | g_signal_connect(G_OBJECT(gtkconv->send), "clicked", | |
| 2702 | G_CALLBACK(send_cb), conv); | |
| 2703 | g_signal_connect(G_OBJECT(gtkchat->invite), "clicked", | |
| 2704 | G_CALLBACK(invite_cb), conv); | |
| 2705 | } | |
| 2706 | ||
| 2707 | static GtkWidget * | |
| 2708 | build_conv_toolbar(struct gaim_conversation *conv) | |
| 2709 | { | |
| 2710 | struct gaim_gtk_conversation *gtkconv; | |
| 2711 | GtkWidget *vbox; | |
| 2712 | GtkWidget *hbox; | |
| 2713 | GtkWidget *button; | |
| 2714 | GtkWidget *sep; | |
| 2715 | GtkSizeGroup *sg; | |
| 2716 | ||
| 2717 | gtkconv = GAIM_GTK_CONVERSATION(conv); | |
| 2718 | ||
| 2719 | sg = gtk_size_group_new(GTK_SIZE_GROUP_BOTH); | |
| 2720 | ||
| 2721 | vbox = gtk_vbox_new(FALSE, 0); | |
| 2722 | sep = gtk_hseparator_new(); | |
| 2723 | gtk_box_pack_start(GTK_BOX(vbox), sep, FALSE, FALSE, 0); | |
| 2724 | ||
| 2725 | hbox = gtk_hbox_new(FALSE, 5); | |
| 2726 | gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 0); | |
| 2727 | ||
| 2728 | /* Bold */ | |
| 2729 | button = gaim_pixbuf_toolbar_button_from_stock(GTK_STOCK_BOLD); | |
| 2730 | gtk_size_group_add_widget(sg, button); | |
| 2731 | gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0); | |
| 2732 | gtk_tooltips_set_tip(gtkconv->tooltips, button, _("Bold"), NULL); | |
| 2733 | ||
| 2734 | g_signal_connect(G_OBJECT(button), "clicked", | |
| 2735 | G_CALLBACK(do_bold), gtkconv); | |
| 2736 | ||
| 2737 | gtkconv->toolbar.bold = button; | |
| 2738 | ||
| 2739 | /* Italic */ | |
| 2740 | button = gaim_pixbuf_toolbar_button_from_stock(GTK_STOCK_ITALIC); | |
| 2741 | gtk_size_group_add_widget(sg, button); | |
| 2742 | gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0); | |
| 2743 | gtk_tooltips_set_tip(gtkconv->tooltips, button, _("Italic"), NULL); | |
| 2744 | ||
| 2745 | g_signal_connect(G_OBJECT(button), "clicked", | |
| 2746 | G_CALLBACK(do_italic), gtkconv); | |
| 2747 | ||
| 2748 | gtkconv->toolbar.italic = button; | |
| 2749 | ||
| 2750 | /* Underline */ | |
| 2751 | button = gaim_pixbuf_toolbar_button_from_stock(GTK_STOCK_UNDERLINE); | |
| 2752 | gtk_size_group_add_widget(sg, button); | |
| 2753 | gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0); | |
| 2754 | gtk_tooltips_set_tip(gtkconv->tooltips, button, _("Underline"), NULL); | |
| 2755 | ||
| 2756 | g_signal_connect(G_OBJECT(button), "clicked", | |
| 2757 | G_CALLBACK(do_underline), gtkconv); | |
| 2758 | ||
| 2759 | gtkconv->toolbar.underline = button; | |
| 2760 | ||
| 2761 | /* Sep */ | |
| 2762 | sep = gtk_vseparator_new(); | |
| 2763 | gtk_box_pack_start(GTK_BOX(hbox), sep, FALSE, FALSE, 0); | |
| 2764 | ||
| 2765 | /* Increase font size */ | |
| 2766 | button = gaim_pixbuf_toolbar_button_from_stock(GAIM_STOCK_TEXT_BIGGER); | |
| 2767 | gtk_size_group_add_widget(sg, button); | |
| 2768 | gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0); | |
| 2769 | gtk_tooltips_set_tip(gtkconv->tooltips, button, | |
| 2770 | _("Larger font size"), NULL); | |
| 2771 | ||
| 2772 | g_signal_connect(G_OBJECT(button), "clicked", | |
| 2773 | G_CALLBACK(do_big), gtkconv); | |
| 2774 | ||
| 2775 | /* Normal font size */ | |
| 2776 | button = gaim_pixbuf_toolbar_button_from_stock(GAIM_STOCK_TEXT_NORMAL); | |
| 2777 | gtk_size_group_add_widget(sg, button); | |
| 2778 | gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0); | |
| 2779 | gtk_tooltips_set_tip(gtkconv->tooltips, button, | |
| 2780 | _("Normal font size"), NULL); | |
| 2781 | ||
| 2782 | g_signal_connect(G_OBJECT(button), "clicked", | |
| 2783 | G_CALLBACK(do_normal), gtkconv); | |
| 2784 | ||
| 2785 | gtkconv->toolbar.normal_size = button; | |
| 2786 | ||
| 2787 | /* Decrease font size */ | |
| 2788 | button = gaim_pixbuf_toolbar_button_from_stock(GAIM_STOCK_TEXT_SMALLER); | |
| 2789 | gtk_size_group_add_widget(sg, button); | |
| 2790 | gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0); | |
| 2791 | gtk_tooltips_set_tip(gtkconv->tooltips, button, | |
| 2792 | _("Smaller font size"), NULL); | |
| 2793 | ||
| 2794 | g_signal_connect(G_OBJECT(button), "clicked", | |
| 2795 | G_CALLBACK(do_small), gtkconv); | |
| 2796 | ||
| 2797 | /* Sep */ | |
| 2798 | sep = gtk_vseparator_new(); | |
| 2799 | gtk_box_pack_start(GTK_BOX(hbox), sep, FALSE, FALSE, 0); | |
| 2800 | ||
| 4685 | 2801 | /* Font Face */ |
| 2802 | ||
| 2803 | button = gaim_pixbuf_toolbar_button_from_stock(GTK_STOCK_SELECT_FONT); | |
| 2804 | gtk_size_group_add_widget(sg, button); | |
| 2805 | gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0); | |
| 2806 | gtk_tooltips_set_tip(gtkconv->tooltips, button, | |
| 2807 | _("Font Face"), NULL); | |
| 2808 | ||
| 2809 | g_signal_connect(G_OBJECT(button), "clicked", | |
| 2810 | G_CALLBACK(toggle_font), conv); | |
| 2811 | ||
| 2812 | gtkconv->toolbar.font = button; | |
| 2813 | ||
| 4359 | 2814 | /* Foreground Color */ |
| 2815 | button = gaim_pixbuf_toolbar_button_from_stock(GAIM_STOCK_FGCOLOR); | |
| 2816 | gtk_size_group_add_widget(sg, button); | |
| 2817 | gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0); | |
| 2818 | gtk_tooltips_set_tip(gtkconv->tooltips, button, | |
| 2819 | _("Foreground font color"), NULL); | |
| 2820 | ||
| 2821 | g_signal_connect(G_OBJECT(button), "clicked", | |
| 2822 | G_CALLBACK(toggle_fg_color), conv); | |
| 2823 | ||
| 2824 | gtkconv->toolbar.fgcolor = button; | |
| 2825 | ||
| 2826 | /* Background Color */ | |
| 2827 | button = gaim_pixbuf_toolbar_button_from_stock(GAIM_STOCK_BGCOLOR); | |
| 2828 | gtk_size_group_add_widget(sg, button); | |
| 2829 | gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0); | |
| 2830 | gtk_tooltips_set_tip(gtkconv->tooltips, button, | |
| 2831 | _("Background color"), NULL); | |
| 2832 | ||
| 2833 | g_signal_connect(G_OBJECT(button), "clicked", | |
| 2834 | G_CALLBACK(toggle_bg_color), conv); | |
| 2835 | ||
| 2836 | gtkconv->toolbar.bgcolor = button; | |
| 2837 | ||
| 2838 | /* Sep */ | |
| 2839 | sep = gtk_vseparator_new(); | |
| 2840 | gtk_box_pack_start(GTK_BOX(hbox), sep, FALSE, FALSE, 0); | |
| 2841 | ||
| 2842 | /* Insert IM Image */ | |
| 2843 | button = gaim_pixbuf_toolbar_button_from_stock(GAIM_STOCK_IMAGE); | |
| 2844 | gtk_size_group_add_widget(sg, button); | |
| 2845 | gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0); | |
| 2846 | gtk_tooltips_set_tip(gtkconv->tooltips, button, _("Insert image"), NULL); | |
| 2847 | ||
| 2848 | g_signal_connect(G_OBJECT(button), "clicked", | |
| 2849 | G_CALLBACK(insert_image_cb), conv); | |
| 2850 | ||
| 2851 | gtkconv->toolbar.image = button; | |
| 2852 | ||
| 2853 | /* Insert Link */ | |
| 2854 | button = gaim_pixbuf_toolbar_button_from_stock(GAIM_STOCK_LINK); | |
| 2855 | gtk_size_group_add_widget(sg, button); | |
| 2856 | gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0); | |
| 2857 | gtk_tooltips_set_tip(gtkconv->tooltips, button, _("Insert link"), NULL); | |
| 2858 | ||
| 2859 | g_signal_connect(G_OBJECT(button), "clicked", | |
| 2860 | G_CALLBACK(insert_link_cb), conv); | |
| 2861 | ||
| 2862 | gtkconv->toolbar.link = button; | |
| 2863 | ||
| 2864 | /* Insert Smiley */ | |
| 2865 | button = gaim_pixbuf_toolbar_button_from_stock(GAIM_STOCK_SMILEY); | |
| 2866 | gtk_size_group_add_widget(sg, button); | |
| 2867 | gtk_box_pack_start(GTK_BOX(hbox), button, FALSE, FALSE, 0); | |
| 2868 | gtk_tooltips_set_tip(gtkconv->tooltips, button, _("Insert smiley"), NULL); | |
| 2869 | ||
| 2870 | g_signal_connect(G_OBJECT(button), "clicked", | |
| 2871 | G_CALLBACK(insert_smiley_cb), conv); | |
| 2872 | ||
| 2873 | gtkconv->toolbar.smiley = button; | |
| 2874 | ||
| 2875 | ||
| 2876 | sep = gtk_hseparator_new(); | |
| 2877 | gtk_box_pack_start(GTK_BOX(vbox), sep, FALSE, FALSE, 0); | |
| 2878 | ||
| 2879 | gtk_widget_show_all(vbox); | |
| 2880 | ||
| 2881 | return vbox; | |
| 2882 | } | |
| 2883 | ||
| 2884 | static GtkWidget * | |
| 2885 | setup_chat_pane(struct gaim_conversation *conv) | |
| 2886 | { | |
| 2887 | struct gaim_gtk_conversation *gtkconv; | |
| 2888 | struct gaim_gtk_chat_pane *gtkchat; | |
| 2889 | struct gaim_connection *gc; | |
| 2890 | GtkWidget *vpaned, *hpaned; | |
| 2891 | GtkWidget *vbox, *hbox; | |
| 2892 | GtkWidget *lbox, *bbox; | |
| 2893 | GtkWidget *label; | |
| 2894 | GtkWidget *sw2; | |
| 2895 | GtkWidget *list; | |
| 2896 | GtkWidget *button; | |
| 2897 | GtkWidget *frame; | |
| 2898 | GtkListStore *ls; | |
| 2899 | GtkCellRenderer *rend; | |
| 2900 | GtkTreeViewColumn *col; | |
| 2901 | ||
| 2902 | gtkconv = GAIM_GTK_CONVERSATION(conv); | |
| 2903 | gtkchat = gtkconv->u.chat; | |
| 2904 | gc = gaim_conversation_get_gc(conv); | |
| 2905 | ||
| 2906 | /* Setup the outer pane. */ | |
| 2907 | vpaned = gtk_vpaned_new(); | |
| 2908 | gtk_widget_show(vpaned); | |
| 2909 | ||
| 2910 | /* Setup the top part of the pane. */ | |
| 2911 | vbox = gtk_vbox_new(FALSE, 5); | |
| 2912 | gtk_paned_pack1(GTK_PANED(vpaned), vbox, TRUE, FALSE); | |
| 2913 | gtk_widget_show(vbox); | |
| 2914 | ||
| 2915 | if (gc->prpl->options & OPT_PROTO_CHAT_TOPIC) | |
| 2916 | { | |
| 2917 | hbox = gtk_hbox_new(FALSE, 0); | |
| 2918 | gtk_box_pack_start(GTK_BOX(vbox), hbox, FALSE, FALSE, 5); | |
| 2919 | gtk_widget_show(hbox); | |
| 2920 | ||
| 2921 | label = gtk_label_new(_("Topic:")); | |
| 2922 | gtk_box_pack_start(GTK_BOX(hbox), label, FALSE, FALSE, 5); | |
| 2923 | gtk_widget_show(label); | |
| 2924 | ||
| 2925 | gtkchat->topic_text = gtk_entry_new(); | |
| 4635 | 2926 | gtk_editable_set_editable(GTK_EDITABLE(gtkchat->topic_text), FALSE); |
| 4359 | 2927 | gtk_box_pack_start(GTK_BOX(hbox), gtkchat->topic_text, TRUE, TRUE, 5); |
| 2928 | gtk_widget_show(gtkchat->topic_text); | |
| 2929 | } | |
| 2930 | ||
| 2931 | /* Setup the horizontal pane. */ | |
| 2932 | hpaned = gtk_hpaned_new(); | |
| 2933 | gtk_box_pack_start(GTK_BOX(vbox), hpaned, TRUE, TRUE, 5); | |
| 2934 | gtk_widget_show(hpaned); | |
| 2935 | ||
| 2936 | /* Setup the scrolled window to put gtkimhtml in. */ | |
| 2937 | gtkconv->sw = gtk_scrolled_window_new(NULL, NULL); | |
| 2938 | gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(gtkconv->sw), | |
| 2939 | GTK_POLICY_NEVER, GTK_POLICY_ALWAYS); | |
| 2940 | gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(gtkconv->sw), | |
| 2941 | GTK_SHADOW_IN); | |
| 2942 | gtk_paned_pack1(GTK_PANED(hpaned), gtkconv->sw, TRUE, TRUE); | |
| 2943 | ||
| 2944 | gtk_widget_set_size_request(gtkconv->sw, | |
| 2945 | buddy_chat_size.width, buddy_chat_size.height); | |
| 2946 | gtk_widget_show(gtkconv->sw); | |
| 2947 | ||
| 2948 | /* Setup gtkihmtml. */ | |
| 2949 | gtkconv->imhtml = gtk_imhtml_new(NULL, NULL); | |
| 2950 | gtk_container_add(GTK_CONTAINER(gtkconv->sw), gtkconv->imhtml); | |
| 2951 | ||
| 2952 | gtk_imhtml_show_comments(GTK_IMHTML(gtkconv->imhtml), | |
| 2953 | (convo_options & OPT_CONVO_SHOW_TIME)); | |
| 2954 | ||
| 2955 | g_signal_connect_after(G_OBJECT(gtkconv->imhtml), "button_press_event", | |
| 2956 | G_CALLBACK(entry_stop_rclick_cb), NULL); | |
| 2957 | ||
| 2958 | gaim_setup_imhtml(gtkconv->imhtml); | |
| 2959 | ||
| 2960 | gtk_widget_show(gtkconv->imhtml); | |
| 2961 | ||
| 2962 | /* Build the right pane. */ | |
| 2963 | lbox = gtk_vbox_new(FALSE, 5); | |
|
4409
a2526adf0f4b
[gaim-migrate @ 4682]
Christian Hammond <chipx86@chipx86.com>
parents:
4398
diff
changeset
|
2964 | gtk_paned_pack2(GTK_PANED(hpaned), lbox, FALSE, TRUE); |
| 4359 | 2965 | gtk_widget_show(lbox); |
| 2966 | ||
| 2967 | /* Setup the label telling how many people are in the room. */ | |
| 2968 | gtkchat->count = gtk_label_new(_("0 people in room")); | |
| 2969 | gtk_box_pack_start(GTK_BOX(lbox), gtkchat->count, FALSE, FALSE, 0); | |
| 2970 | gtk_widget_show(gtkchat->count); | |
| 2971 | ||
| 2972 | /* Setup the list of users. */ | |
| 2973 | sw2 = gtk_scrolled_window_new(NULL, NULL); | |
| 2974 | gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(sw2), | |
| 2975 | GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC); | |
| 2976 | gtk_box_pack_start(GTK_BOX(lbox), sw2, TRUE, TRUE, 0); | |
| 2977 | gtk_widget_show(sw2); | |
| 2978 | ||
| 2979 | ls = gtk_list_store_new(2, G_TYPE_STRING, G_TYPE_STRING); | |
| 2980 | gtk_tree_sortable_set_sort_column_id(GTK_TREE_SORTABLE(ls), 1, | |
| 2981 | GTK_SORT_ASCENDING); | |
| 2982 | ||
| 2983 | list = gtk_tree_view_new_with_model(GTK_TREE_MODEL(ls)); | |
| 2984 | ||
| 2985 | rend = gtk_cell_renderer_text_new(); | |
| 2986 | col = gtk_tree_view_column_new_with_attributes(NULL, rend, | |
| 2987 | "text", 0, NULL); | |
| 2988 | gtk_tree_view_column_set_clickable(GTK_TREE_VIEW_COLUMN(col), TRUE); | |
| 2989 | ||
| 2990 | g_signal_connect(G_OBJECT(list), "button_press_event", | |
| 2991 | G_CALLBACK(right_click_chat_cb), conv); | |
| 2992 | ||
| 2993 | gtk_tree_view_append_column(GTK_TREE_VIEW(list), col); | |
| 2994 | ||
| 2995 | col = gtk_tree_view_column_new_with_attributes(NULL, rend, | |
| 2996 | "text", 1, NULL); | |
| 2997 | gtk_tree_view_column_set_clickable(GTK_TREE_VIEW_COLUMN(col), TRUE); | |
| 2998 | ||
| 2999 | #if 0 | |
| 3000 | g_signal_connect(G_OBJECT(list), "button_press_event", | |
| 3001 | G_CALLBACK(right_click_chat), conv); | |
| 3002 | #endif | |
| 3003 | ||
| 3004 | gtk_tree_view_append_column(GTK_TREE_VIEW(list), col); | |
| 3005 | ||
| 3006 | gtk_widget_set_size_request(list, 150, -1); | |
| 3007 | ||
| 3008 | gtk_tree_view_set_headers_visible(GTK_TREE_VIEW(list), FALSE); | |
| 3009 | gtk_widget_show(list); | |
| 3010 | ||
| 3011 | gtkchat->list = list; | |
| 3012 | ||
| 3013 | gtk_scrolled_window_add_with_viewport(GTK_SCROLLED_WINDOW(sw2), list); | |
| 3014 | ||
| 3015 | /* Setup the user list toolbar. */ | |
| 3016 | bbox = gtk_hbox_new(TRUE, 5); | |
| 3017 | gtk_box_pack_start(GTK_BOX(lbox), bbox, FALSE, FALSE, 0); | |
| 3018 | gtk_widget_show(bbox); | |
| 3019 | ||
| 3020 | /* IM */ | |
| 3021 | button = gaim_pixbuf_button_from_stock(NULL, GTK_STOCK_REDO, | |
| 3022 | GAIM_BUTTON_VERTICAL); | |
| 3023 | gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE); | |
| 3024 | 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
|
3025 | gtk_tooltips_set_tip(gtkconv->tooltips, button, _("IM the user"), NULL); |
| 4359 | 3026 | g_signal_connect(G_OBJECT(button), "clicked", |
| 3027 | G_CALLBACK(im_cb), conv); | |
| 3028 | ||
| 3029 | gtk_widget_show(button); | |
| 3030 | ||
| 3031 | /* Ignore */ | |
| 3032 | button = gaim_pixbuf_button_from_stock(NULL, GAIM_STOCK_IGNORE, | |
| 3033 | GAIM_BUTTON_VERTICAL); | |
| 3034 | gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE); | |
| 3035 | 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
|
3036 | gtk_tooltips_set_tip(gtkconv->tooltips, button, |
|
8a804f16341c
[gaim-migrate @ 4636]
Christian Hammond <chipx86@chipx86.com>
parents:
4369
diff
changeset
|
3037 | _("Ignore the user"), NULL); |
| 4359 | 3038 | g_signal_connect(G_OBJECT(button), "clicked", |
| 3039 | G_CALLBACK(ignore_cb), conv); | |
| 3040 | gtk_widget_show(button); | |
| 3041 | ||
| 3042 | /* Info */ | |
| 3043 | button = gaim_pixbuf_button_from_stock(NULL, GAIM_STOCK_INFO, | |
| 3044 | GAIM_BUTTON_VERTICAL); | |
| 3045 | gtk_button_set_relief(GTK_BUTTON(button), GTK_RELIEF_NONE); | |
| 3046 | gtk_box_pack_start(GTK_BOX(bbox), button, FALSE, FALSE, 0); | |
| 3047 | gtk_tooltips_set_tip(gtkconv->tooltips, button, | |
|
4370
8a804f16341c
[gaim-migrate @ 4636]
Christian Hammond <chipx86@chipx86.com>
parents:
4369
diff
changeset
|
3048 | _("Get the user's information"), NULL); |
| 4359 | 3049 | g_signal_connect(G_OBJECT(button), "clicked", |
| 3050 | G_CALLBACK(info_cb), conv); | |
| 3051 | ||
| 3052 | gtk_widget_show(button); | |
| 3053 | ||
| 3054 | gtkconv->info = button; | |
| 3055 | ||
| 3056 | /* Build the toolbar. */ | |
| 3057 | vbox = gtk_vbox_new(FALSE, 5); | |
|
4409
a2526adf0f4b
[gaim-migrate @ 4682]
Christian Hammond <chipx86@chipx86.com>
parents:
4398
diff
changeset
|
3058 | gtk_paned_pack2(GTK_PANED(vpaned), vbox, FALSE, FALSE); |
| 4359 | 3059 | gtk_widget_show(vbox); |
| 3060 | ||
| 3061 | gtkconv->toolbar.toolbar = build_conv_toolbar(conv); | |
| 3062 | gtk_box_pack_start(GTK_BOX(vbox), gtkconv->toolbar.toolbar, | |
| 3063 | FALSE, FALSE, 0); | |
| 3064 | ||
| 3065 | /* Setup the entry widget. */ | |
| 3066 | frame = gtk_frame_new(NULL); | |
| 3067 | gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_IN); | |
| 3068 | gtk_box_pack_start(GTK_BOX(vbox), frame, TRUE, TRUE, 0); | |
| 3069 | gtk_widget_show(frame); | |
| 3070 | ||
| 3071 | gtkconv->entry_buffer = gtk_text_buffer_new(NULL); | |
| 3072 | g_object_set_data(G_OBJECT(gtkconv->entry_buffer), "user_data", conv); | |
| 3073 | gtkconv->entry = gtk_text_view_new_with_buffer(gtkconv->entry_buffer); | |
| 3074 | ||
| 3075 | gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(gtkconv->entry), GTK_WRAP_WORD); | |
| 3076 | gtk_widget_set_size_request(gtkconv->entry, buddy_chat_size.width, | |
| 3077 | MAX(buddy_chat_size.entry_height, 25)); | |
| 3078 | ||
| 3079 | /* Connect the signal handlers. */ | |
| 3080 | g_signal_connect_swapped(G_OBJECT(gtkconv->entry), "key_press_event", | |
| 3081 | G_CALLBACK(entry_key_pressed_cb_1), | |
| 3082 | gtkconv->entry_buffer); | |
| 3083 | g_signal_connect_after(G_OBJECT(gtkconv->entry), "button_press_event", | |
| 3084 | G_CALLBACK(entry_stop_rclick_cb), NULL); | |
| 3085 | g_signal_connect(G_OBJECT(gtkconv->entry), "key_press_event", | |
| 3086 | G_CALLBACK(entry_key_pressed_cb_2), conv); | |
| 3087 | ||
| 3088 | #ifdef USE_GTKSPELL | |
| 3089 | if (convo_options & OPT_CONVO_CHECK_SPELLING) | |
| 3090 | gtkspell_new_attach(GTK_TEXT_VIEW(gtkconv->entry), NULL, NULL); | |
| 3091 | #endif | |
| 3092 | ||
| 3093 | gtk_container_add(GTK_CONTAINER(frame), GTK_WIDGET(gtkconv->entry)); | |
| 3094 | gtk_widget_show(gtkconv->entry); | |
| 3095 | ||
| 3096 | /* Setup the bottom button box. */ | |
| 3097 | gtkconv->bbox = gtk_hbox_new(FALSE, 5); | |
| 3098 | gtk_box_pack_start(GTK_BOX(vbox), gtkconv->bbox, FALSE, FALSE, 0); | |
| 3099 | gtk_widget_show(gtkconv->bbox); | |
| 3100 | ||
| 3101 | setup_chat_buttons(conv, gtkconv->bbox); | |
| 3102 | ||
| 3103 | return vpaned; | |
| 3104 | } | |
| 3105 | ||
| 3106 | static GtkWidget * | |
| 3107 | setup_im_pane(struct gaim_conversation *conv) | |
| 3108 | { | |
| 3109 | struct gaim_gtk_conversation *gtkconv; | |
| 3110 | struct gaim_gtk_im_pane *gtkim; | |
| 3111 | GtkWidget *paned; | |
| 3112 | GtkWidget *vbox; | |
| 3113 | GtkWidget *vbox2; | |
| 3114 | GtkWidget *frame; | |
| 3115 | ||
| 3116 | gtkconv = GAIM_GTK_CONVERSATION(conv); | |
| 3117 | gtkim = gtkconv->u.im; | |
| 3118 | ||
| 3119 | /* Setup the outer pane. */ | |
| 3120 | paned = gtk_vpaned_new(); | |
| 3121 | gtk_widget_show(paned); | |
| 3122 | ||
| 3123 | /* Setup the top part of the pane. */ | |
| 3124 | vbox = gtk_vbox_new(FALSE, 5); | |
|
4409
a2526adf0f4b
[gaim-migrate @ 4682]
Christian Hammond <chipx86@chipx86.com>
parents:
4398
diff
changeset
|
3125 | gtk_paned_pack1(GTK_PANED(paned), vbox, TRUE, TRUE); |
| 4359 | 3126 | gtk_widget_show(vbox); |
| 3127 | ||
| 3128 | /* Setup the gtkimhtml widget. */ | |
| 3129 | gtkconv->sw = gtk_scrolled_window_new(NULL, NULL); | |
| 3130 | gtk_scrolled_window_set_policy(GTK_SCROLLED_WINDOW(gtkconv->sw), | |
| 3131 | GTK_POLICY_NEVER, GTK_POLICY_ALWAYS); | |
| 3132 | gtk_scrolled_window_set_shadow_type(GTK_SCROLLED_WINDOW(gtkconv->sw), | |
| 3133 | GTK_SHADOW_IN); | |
| 3134 | gtk_box_pack_start(GTK_BOX(vbox), gtkconv->sw, TRUE, TRUE, 0); | |
| 3135 | gtk_widget_set_size_request(gtkconv->sw, conv_size.width, conv_size.height); | |
| 3136 | gtk_widget_show(gtkconv->sw); | |
| 3137 | ||
| 3138 | gtkconv->imhtml = gtk_imhtml_new(NULL, NULL); | |
| 3139 | gtk_container_add(GTK_CONTAINER(gtkconv->sw), gtkconv->imhtml); | |
| 3140 | ||
| 3141 | g_signal_connect_after(G_OBJECT(gtkconv->imhtml), "button_press_event", | |
| 3142 | G_CALLBACK(entry_stop_rclick_cb), NULL); | |
| 3143 | ||
| 3144 | gtk_imhtml_show_comments(GTK_IMHTML(gtkconv->imhtml), | |
| 3145 | (convo_options & OPT_CONVO_SHOW_TIME)); | |
| 3146 | ||
| 3147 | gaim_setup_imhtml(gtkconv->imhtml); | |
| 3148 | ||
| 3149 | gtk_widget_show(gtkconv->imhtml); | |
| 3150 | ||
| 3151 | vbox2 = gtk_vbox_new(FALSE, 5); | |
| 3152 | gtk_paned_pack2(GTK_PANED(paned), vbox2, FALSE, FALSE); | |
| 3153 | gtk_widget_show(vbox2); | |
| 3154 | ||
| 3155 | /* Build the toolbar. */ | |
| 3156 | gtkconv->toolbar.toolbar = build_conv_toolbar(conv); | |
| 3157 | gtk_box_pack_start(GTK_BOX(vbox2), gtkconv->toolbar.toolbar, | |
| 3158 | FALSE, FALSE, 0); | |
| 3159 | ||
| 3160 | /* Setup the entry widget. */ | |
| 3161 | frame = gtk_frame_new(NULL); | |
| 3162 | gtk_frame_set_shadow_type(GTK_FRAME(frame), GTK_SHADOW_IN); | |
| 3163 | gtk_box_pack_start(GTK_BOX(vbox2), frame, TRUE, TRUE, 0); | |
| 3164 | gtk_widget_show(frame); | |
| 3165 | ||
| 3166 | gtkconv->entry_buffer = gtk_text_buffer_new(NULL); | |
| 3167 | g_object_set_data(G_OBJECT(gtkconv->entry_buffer), "user_data", conv); | |
| 3168 | gtkconv->entry = gtk_text_view_new_with_buffer(gtkconv->entry_buffer); | |
| 3169 | ||
| 3170 | gtk_text_view_set_wrap_mode(GTK_TEXT_VIEW(gtkconv->entry), GTK_WRAP_WORD); | |
| 3171 | gtk_widget_set_size_request(gtkconv->entry, conv_size.width - 20, | |
| 3172 | MAX(conv_size.entry_height, 25)); | |
| 3173 | ||
| 3174 | /* Connect the signal handlers. */ | |
| 3175 | g_signal_connect_swapped(G_OBJECT(gtkconv->entry), "key_press_event", | |
| 3176 | G_CALLBACK(entry_key_pressed_cb_1), | |
| 3177 | gtkconv->entry_buffer); | |
| 3178 | g_signal_connect(G_OBJECT(gtkconv->entry), "key_press_event", | |
| 3179 | G_CALLBACK(entry_key_pressed_cb_2), conv); | |
| 3180 | g_signal_connect_after(G_OBJECT(gtkconv->entry), "button_press_event", | |
| 3181 | G_CALLBACK(entry_stop_rclick_cb), NULL); | |
| 3182 | ||
| 3183 | g_signal_connect(G_OBJECT(gtkconv->entry_buffer), "insert_text", | |
| 3184 | G_CALLBACK(insert_text_cb), conv); | |
| 3185 | g_signal_connect(G_OBJECT(gtkconv->entry_buffer), "delete_range", | |
| 3186 | G_CALLBACK(delete_text_cb), conv); | |
| 3187 | ||
| 3188 | #ifdef USE_GTKSPELL | |
| 3189 | if (convo_options & OPT_CONVO_CHECK_SPELLING) | |
| 3190 | gtkspell_new_attach(GTK_TEXT_VIEW(gtkconv->entry), NULL, NULL); | |
| 3191 | #endif | |
| 3192 | ||
| 3193 | gtk_container_add(GTK_CONTAINER(frame), GTK_WIDGET(gtkconv->entry)); | |
| 3194 | gtk_widget_show(gtkconv->entry); | |
| 3195 | ||
| 3196 | gtkconv->bbox = gtk_hbox_new(FALSE, 5); | |
| 3197 | gtk_box_pack_start(GTK_BOX(vbox2), gtkconv->bbox, FALSE, FALSE, 0); | |
| 3198 | gtk_widget_show(gtkconv->bbox); | |
| 3199 | ||
| 3200 | setup_im_buttons(conv, gtkconv->bbox); | |
| 3201 | ||
| 3202 | return paned; | |
| 3203 | } | |
| 3204 | ||
| 3205 | static void | |
| 3206 | move_next_tab(struct gaim_conversation *conv) | |
| 3207 | { | |
| 3208 | struct gaim_conversation *next_conv = NULL; | |
| 3209 | struct gaim_window *win; | |
| 3210 | GList *l; | |
| 3211 | int index, i; | |
| 3212 | ||
| 3213 | win = gaim_conversation_get_window(conv); | |
| 3214 | index = gaim_conversation_get_index(conv); | |
| 3215 | ||
| 3216 | /* First check the tabs after this position. */ | |
| 3217 | for (l = g_list_nth(gaim_window_get_conversations(win), index); | |
| 3218 | l != NULL; | |
| 3219 | l = l->next) { | |
| 3220 | ||
| 3221 | next_conv = (struct gaim_conversation *)l->data; | |
| 3222 | ||
| 3223 | if (gaim_conversation_get_unseen(next_conv) > 0) | |
| 3224 | break; | |
| 3225 | ||
| 3226 | next_conv = NULL; | |
| 3227 | } | |
| 3228 | ||
| 3229 | if (next_conv == NULL) { | |
| 3230 | ||
| 3231 | /* Now check before this position. */ | |
| 3232 | for (l = gaim_window_get_conversations(win), i = 0; | |
| 3233 | l != NULL && i < index; | |
| 3234 | l = l->next) { | |
| 3235 | ||
| 3236 | next_conv = (struct gaim_conversation *)l->data; | |
| 3237 | ||
| 3238 | if (gaim_conversation_get_unseen(next_conv) > 0) | |
| 3239 | break; | |
| 3240 | ||
| 3241 | next_conv = NULL; | |
| 3242 | } | |
| 3243 | ||
| 3244 | if (next_conv == NULL) { | |
| 3245 | /* Okay, just grab the next conversation tab. */ | |
| 3246 | if (index == gaim_window_get_conversation_count(win) - 1) | |
| 3247 | next_conv = gaim_window_get_conversation_at(win, 0); | |
| 3248 | else | |
| 3249 | next_conv = gaim_window_get_conversation_at(win, index + 1); | |
| 3250 | } | |
| 3251 | } | |
| 3252 | ||
| 3253 | if (next_conv != NULL && next_conv != conv) { | |
| 3254 | gaim_window_switch_conversation(win, | |
| 3255 | gaim_conversation_get_index(next_conv)); | |
| 3256 | } | |
| 3257 | } | |
| 3258 | ||
|
4689
524a0357d05b
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3259 | static void |
|
524a0357d05b
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3260 | conv_dnd_recv(GtkWidget *widget, GdkDragContext *dc, guint x, guint y, |
| 4702 | 3261 | GtkSelectionData *sd, guint info, guint t) |
|
4689
524a0357d05b
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3262 | { |
| 4702 | 3263 | if (sd->target == gdk_atom_intern("GAIM_BUDDY", FALSE)) { |
| 3264 | struct buddy *b = NULL; | |
| 3265 | memcpy(&b, sd->data, sizeof(b)); | |
| 3266 | gaim_conversation_new(GAIM_CONV_IM, b->account, b->name); | |
| 3267 | } | |
| 3268 | ||
| 3269 | /* do_error_dialog("MWAHAHAHA! I AM A TROLL! I AM GOING TO EAT YOU!", | |
| 3270 | NULL, GAIM_WARNING); */ | |
|
4689
524a0357d05b
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3271 | } |
| 4359 | 3272 | |
| 3273 | /************************************************************************** | |
| 3274 | * GTK+ window ops | |
| 3275 | **************************************************************************/ | |
|
4465
43184ae252ed
[gaim-migrate @ 4740]
Christian Hammond <chipx86@chipx86.com>
parents:
4454
diff
changeset
|
3276 | static struct gaim_conversation_ui_ops * |
|
43184ae252ed
[gaim-migrate @ 4740]
Christian Hammond <chipx86@chipx86.com>
parents:
4454
diff
changeset
|
3277 | gaim_gtk_get_conversation_ui_ops(void) |
| 4359 | 3278 | { |
|
4465
43184ae252ed
[gaim-migrate @ 4740]
Christian Hammond <chipx86@chipx86.com>
parents:
4454
diff
changeset
|
3279 | return gaim_get_gtk_conversation_ui_ops(); |
| 4359 | 3280 | } |
| 3281 | ||
| 3282 | static void | |
| 3283 | gaim_gtk_new_window(struct gaim_window *win) | |
| 3284 | { | |
| 3285 | struct gaim_gtk_window *gtkwin; | |
| 3286 | GtkPositionType pos; | |
| 3287 | GtkWidget *testidea; | |
| 3288 | GtkWidget *menubar; | |
| 3289 | ||
| 3290 | gtkwin = g_malloc0(sizeof(struct gaim_gtk_window)); | |
| 3291 | ||
| 3292 | win->ui_data = gtkwin; | |
| 3293 | ||
| 3294 | /* Create the window. */ | |
| 3295 | gtkwin->window = gtk_window_new(GTK_WINDOW_TOPLEVEL); | |
| 3296 | gtk_window_set_role(GTK_WINDOW(gtkwin->window), "conversation"); | |
| 4635 | 3297 | gtk_window_set_resizable(GTK_WINDOW(gtkwin->window), TRUE); |
|
4510
deb241b1189c
[gaim-migrate @ 4786]
Christian Hammond <chipx86@chipx86.com>
parents:
4505
diff
changeset
|
3298 | gtk_container_set_border_width(GTK_CONTAINER(gtkwin->window), 0); |
| 4359 | 3299 | gtk_widget_realize(gtkwin->window); |
| 3300 | ||
| 3301 | g_signal_connect(G_OBJECT(gtkwin->window), "delete_event", | |
| 3302 | G_CALLBACK(close_win_cb), win); | |
| 3303 | ||
| 3304 | /* Create the notebook. */ | |
| 3305 | gtkwin->notebook = gtk_notebook_new(); | |
| 3306 | ||
| 3307 | pos = ((im_options & OPT_IM_SIDE_TAB) | |
| 3308 | ? ((im_options & OPT_IM_BR_TAB) ? GTK_POS_RIGHT : GTK_POS_LEFT) | |
| 3309 | : ((im_options & OPT_IM_BR_TAB) ? GTK_POS_BOTTOM : GTK_POS_TOP)); | |
| 3310 | ||
| 3311 | #if 0 | |
| 3312 | gtk_notebook_set_tab_hborder(GTK_NOTEBOOK(gtkwin->notebook), 0); | |
| 3313 | gtk_notebook_set_tab_vborder(GTK_NOTEBOOK(gtkwin->notebook), 0); | |
| 3314 | #endif | |
| 3315 | gtk_notebook_set_tab_pos(GTK_NOTEBOOK(gtkwin->notebook), pos); | |
| 3316 | gtk_notebook_set_scrollable(GTK_NOTEBOOK(gtkwin->notebook), TRUE); | |
| 3317 | gtk_notebook_popup_enable(GTK_NOTEBOOK(gtkwin->notebook)); | |
| 3318 | gtk_widget_show(gtkwin->notebook); | |
| 3319 | ||
| 3320 | g_signal_connect_after(G_OBJECT(gtkwin->notebook), "switch_page", | |
| 3321 | G_CALLBACK(switch_conv_cb), win); | |
| 3322 | ||
| 3323 | /* Setup the tab drag and drop signals. */ | |
| 4486 | 3324 | gtk_widget_add_events(gtkwin->notebook, |
| 3325 | GDK_BUTTON1_MOTION_MASK | GDK_LEAVE_NOTIFY_MASK); | |
| 3326 | g_signal_connect(G_OBJECT(gtkwin->notebook), "button_press_event", | |
|
4572
c6dfc8e14233
[gaim-migrate @ 4853]
Christian Hammond <chipx86@chipx86.com>
parents:
4571
diff
changeset
|
3327 | G_CALLBACK(notebook_press_cb), win); |
| 4486 | 3328 | g_signal_connect(G_OBJECT(gtkwin->notebook), "button_release_event", |
|
4572
c6dfc8e14233
[gaim-migrate @ 4853]
Christian Hammond <chipx86@chipx86.com>
parents:
4571
diff
changeset
|
3329 | G_CALLBACK(notebook_release_cb), win); |
|
c6dfc8e14233
[gaim-migrate @ 4853]
Christian Hammond <chipx86@chipx86.com>
parents:
4571
diff
changeset
|
3330 | |
| 4359 | 3331 | testidea = gtk_vbox_new(FALSE, 0); |
|
4572
c6dfc8e14233
[gaim-migrate @ 4853]
Christian Hammond <chipx86@chipx86.com>
parents:
4571
diff
changeset
|
3332 | |
| 4359 | 3333 | /* Setup the menubar. */ |
| 3334 | menubar = setup_menubar(win); | |
| 3335 | gtk_box_pack_start(GTK_BOX(testidea), menubar, FALSE, TRUE, 0); | |
| 3336 | ||
| 3337 | gtk_box_pack_start(GTK_BOX(testidea), gtkwin->notebook, TRUE, TRUE, 0); | |
| 3338 | ||
| 3339 | gtk_container_add(GTK_CONTAINER(gtkwin->window), testidea); | |
| 3340 | ||
| 3341 | gtk_widget_show(testidea); | |
| 3342 | } | |
| 3343 | ||
| 3344 | static void | |
| 3345 | gaim_gtk_destroy_window(struct gaim_window *win) | |
| 3346 | { | |
| 3347 | struct gaim_gtk_window *gtkwin = GAIM_GTK_WINDOW(win); | |
| 3348 | ||
| 3349 | gtk_widget_destroy(gtkwin->window); | |
| 3350 | ||
| 4630 | 3351 | g_object_unref(G_OBJECT(gtkwin->menu.item_factory)); |
| 3352 | ||
| 4359 | 3353 | g_free(gtkwin); |
| 3354 | win->ui_data = NULL; | |
| 3355 | } | |
| 3356 | ||
| 3357 | static void | |
| 3358 | gaim_gtk_show(struct gaim_window *win) | |
| 3359 | { | |
| 3360 | struct gaim_gtk_window *gtkwin = GAIM_GTK_WINDOW(win); | |
| 3361 | ||
| 3362 | gtk_widget_show(gtkwin->window); | |
| 3363 | } | |
| 3364 | ||
| 3365 | static void | |
| 3366 | gaim_gtk_hide(struct gaim_window *win) | |
| 3367 | { | |
| 3368 | struct gaim_gtk_window *gtkwin = GAIM_GTK_WINDOW(win); | |
| 3369 | ||
| 3370 | gtk_widget_hide(gtkwin->window); | |
| 3371 | } | |
| 3372 | ||
| 3373 | static void | |
| 3374 | gaim_gtk_raise(struct gaim_window *win) | |
| 3375 | { | |
| 3376 | struct gaim_gtk_window *gtkwin = GAIM_GTK_WINDOW(win); | |
| 3377 | ||
| 4526 | 3378 | gdk_window_raise(gtkwin->window->window); |
| 4359 | 3379 | } |
| 3380 | ||
| 3381 | static void | |
| 3382 | gaim_gtk_flash(struct gaim_window *win) | |
| 3383 | { | |
| 3384 | #ifdef _WIN32 | |
| 3385 | struct gaim_gtk_window *gtkwin = GAIM_GTK_WINDOW(win); | |
| 3386 | ||
| 3387 | wgaim_im_blink(gtkwin->window); | |
| 3388 | #endif | |
| 3389 | } | |
| 3390 | ||
| 3391 | static void | |
| 3392 | gaim_gtk_switch_conversation(struct gaim_window *win, unsigned int index) | |
| 3393 | { | |
| 3394 | struct gaim_gtk_window *gtkwin; | |
| 3395 | ||
| 3396 | gtkwin = GAIM_GTK_WINDOW(win); | |
| 3397 | ||
| 3398 | gtk_notebook_set_current_page(GTK_NOTEBOOK(gtkwin->notebook), index); | |
| 3399 | } | |
| 3400 | ||
|
4689
524a0357d05b
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3401 | static const GtkTargetEntry te[] = |
|
524a0357d05b
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3402 | { |
|
524a0357d05b
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3403 | {"text/plain", 0, 0}, |
| 4702 | 3404 | {"text/uri-list", 0, 1}, |
| 3405 | {"GAIM_BUDDY", 0, 2}, | |
| 3406 | {"STRING", 0, 3} | |
|
4689
524a0357d05b
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3407 | }; |
|
524a0357d05b
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3408 | |
| 4359 | 3409 | static void |
| 3410 | gaim_gtk_add_conversation(struct gaim_window *win, | |
| 3411 | struct gaim_conversation *conv) | |
| 3412 | { | |
| 3413 | struct gaim_gtk_window *gtkwin; | |
| 3414 | struct gaim_gtk_conversation *gtkconv; | |
| 3415 | GtkWidget *pane = NULL; | |
| 3416 | GtkWidget *tab_cont; | |
| 3417 | GtkWidget *tabby; | |
| 3418 | gboolean new_ui; | |
|
4383
92d3152f22f3
[gaim-migrate @ 4649]
Christian Hammond <chipx86@chipx86.com>
parents:
4382
diff
changeset
|
3419 | GaimConversationType conv_type; |
|
92d3152f22f3
[gaim-migrate @ 4649]
Christian Hammond <chipx86@chipx86.com>
parents:
4382
diff
changeset
|
3420 | const char *name; |
|
92d3152f22f3
[gaim-migrate @ 4649]
Christian Hammond <chipx86@chipx86.com>
parents:
4382
diff
changeset
|
3421 | |
|
92d3152f22f3
[gaim-migrate @ 4649]
Christian Hammond <chipx86@chipx86.com>
parents:
4382
diff
changeset
|
3422 | name = gaim_conversation_get_name(conv); |
|
92d3152f22f3
[gaim-migrate @ 4649]
Christian Hammond <chipx86@chipx86.com>
parents:
4382
diff
changeset
|
3423 | conv_type = gaim_conversation_get_type(conv); |
|
92d3152f22f3
[gaim-migrate @ 4649]
Christian Hammond <chipx86@chipx86.com>
parents:
4382
diff
changeset
|
3424 | gtkwin = GAIM_GTK_WINDOW(win); |
| 4359 | 3425 | |
| 3426 | if (conv->ui_data != NULL) { | |
| 3427 | gtkconv = (struct gaim_gtk_conversation *)conv->ui_data; | |
| 3428 | ||
| 3429 | tab_cont = gtkconv->tab_cont; | |
| 3430 | ||
| 3431 | new_ui = FALSE; | |
| 3432 | } | |
| 3433 | else { | |
| 3434 | gtkconv = g_malloc0(sizeof(struct gaim_gtk_conversation)); | |
| 3435 | conv->ui_data = gtkconv; | |
| 3436 | ||
| 3437 | /* Setup some initial variables. */ | |
| 3438 | gtkconv->sg = gtk_size_group_new(GTK_SIZE_GROUP_HORIZONTAL); | |
| 3439 | gtkconv->tooltips = gtk_tooltips_new(); | |
| 3440 | ||
| 4421 | 3441 | /* Setup the foreground and background colors */ |
| 3442 | gaim_gtkconv_update_font_colors(conv); | |
| 3443 | ||
|
4438
9beaf48335fc
[gaim-migrate @ 4713]
Christian Hammond <chipx86@chipx86.com>
parents:
4421
diff
changeset
|
3444 | /* Setup the font face */ |
|
9beaf48335fc
[gaim-migrate @ 4713]
Christian Hammond <chipx86@chipx86.com>
parents:
4421
diff
changeset
|
3445 | gaim_gtkconv_update_font_face(conv); |
|
9beaf48335fc
[gaim-migrate @ 4713]
Christian Hammond <chipx86@chipx86.com>
parents:
4421
diff
changeset
|
3446 | |
|
4383
92d3152f22f3
[gaim-migrate @ 4649]
Christian Hammond <chipx86@chipx86.com>
parents:
4382
diff
changeset
|
3447 | if (conv_type == GAIM_CONV_CHAT) { |
| 4359 | 3448 | gtkconv->u.chat = g_malloc0(sizeof(struct gaim_gtk_chat_pane)); |
| 3449 | ||
| 3450 | pane = setup_chat_pane(conv); | |
| 3451 | } | |
|
4383
92d3152f22f3
[gaim-migrate @ 4649]
Christian Hammond <chipx86@chipx86.com>
parents:
4382
diff
changeset
|
3452 | else if (conv_type == GAIM_CONV_IM) { |
| 4359 | 3453 | gtkconv->u.im = g_malloc0(sizeof(struct gaim_gtk_im_pane)); |
| 3454 | gtkconv->u.im->a_virgin = TRUE; | |
| 3455 | ||
| 3456 | pane = setup_im_pane(conv); | |
| 3457 | } | |
| 3458 | ||
| 3459 | if (pane == NULL) { | |
|
4572
c6dfc8e14233
[gaim-migrate @ 4853]
Christian Hammond <chipx86@chipx86.com>
parents:
4571
diff
changeset
|
3460 | if (conv_type == GAIM_CONV_CHAT) g_free(gtkconv->u.chat); |
|
c6dfc8e14233
[gaim-migrate @ 4853]
Christian Hammond <chipx86@chipx86.com>
parents:
4571
diff
changeset
|
3461 | else if (conv_type == GAIM_CONV_IM) g_free(gtkconv->u.im); |
| 4359 | 3462 | |
| 3463 | g_free(gtkconv); | |
| 3464 | conv->ui_data = NULL; | |
| 3465 | ||
| 3466 | return; | |
| 3467 | } | |
| 3468 | ||
|
4689
524a0357d05b
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3469 | /* Setup drag-and-drop */ |
|
524a0357d05b
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3470 | gtk_drag_dest_set(pane, |
|
524a0357d05b
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3471 | GTK_DEST_DEFAULT_MOTION | |
|
524a0357d05b
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3472 | GTK_DEST_DEFAULT_DROP, |
|
524a0357d05b
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3473 | te, sizeof(te) / sizeof(GtkTargetEntry), |
|
524a0357d05b
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3474 | GDK_ACTION_COPY); |
|
524a0357d05b
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3475 | gtk_drag_dest_set(gtkconv->imhtml, |
|
524a0357d05b
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3476 | GTK_DEST_DEFAULT_MOTION | |
| 4702 | 3477 | GTK_DEST_DEFAULT_DROP, |
|
4689
524a0357d05b
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3478 | te, sizeof(te) / sizeof(GtkTargetEntry), |
|
524a0357d05b
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3479 | GDK_ACTION_DEFAULT | GDK_ACTION_COPY | GDK_ACTION_MOVE); |
|
524a0357d05b
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3480 | gtk_drag_dest_set(gtkconv->entry, |
|
524a0357d05b
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3481 | GTK_DEST_DEFAULT_MOTION | |
|
524a0357d05b
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3482 | GTK_DEST_DEFAULT_DROP, |
|
524a0357d05b
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3483 | te, sizeof(te) / sizeof(GtkTargetEntry), |
|
524a0357d05b
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3484 | GDK_ACTION_COPY); |
|
524a0357d05b
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3485 | |
|
524a0357d05b
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3486 | g_signal_connect(G_OBJECT(pane), "drag_data_received", |
|
524a0357d05b
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3487 | G_CALLBACK(conv_dnd_recv), conv); |
|
524a0357d05b
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3488 | g_signal_connect(G_OBJECT(gtkconv->imhtml), "drag_data_received", |
|
524a0357d05b
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3489 | G_CALLBACK(conv_dnd_recv), conv); |
|
524a0357d05b
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3490 | #if 0 |
|
524a0357d05b
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3491 | g_signal_connect(G_OBJECT(gtkconv->entry), "drag_data_received", |
|
524a0357d05b
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3492 | G_CALLBACK(conv_dnd_recv), conv); |
|
524a0357d05b
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3493 | #endif |
|
524a0357d05b
[gaim-migrate @ 5000]
Christian Hammond <chipx86@chipx86.com>
parents:
4687
diff
changeset
|
3494 | |
|
4383
92d3152f22f3
[gaim-migrate @ 4649]
Christian Hammond <chipx86@chipx86.com>
parents:
4382
diff
changeset
|
3495 | /* |
|
92d3152f22f3
[gaim-migrate @ 4649]
Christian Hammond <chipx86@chipx86.com>
parents:
4382
diff
changeset
|
3496 | * Write the New Conversation log string. |
|
92d3152f22f3
[gaim-migrate @ 4649]
Christian Hammond <chipx86@chipx86.com>
parents:
4382
diff
changeset
|
3497 | * |
|
92d3152f22f3
[gaim-migrate @ 4649]
Christian Hammond <chipx86@chipx86.com>
parents:
4382
diff
changeset
|
3498 | * This should probably be elsewhere, but then, logging should |
|
92d3152f22f3
[gaim-migrate @ 4649]
Christian Hammond <chipx86@chipx86.com>
parents:
4382
diff
changeset
|
3499 | * 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
|
3500 | */ |
|
92d3152f22f3
[gaim-migrate @ 4649]
Christian Hammond <chipx86@chipx86.com>
parents:
4382
diff
changeset
|
3501 | if (gaim_conversation_is_logging(conv) && |
|
92d3152f22f3
[gaim-migrate @ 4649]
Christian Hammond <chipx86@chipx86.com>
parents:
4382
diff
changeset
|
3502 | conv_type != GAIM_CONV_MISC) { |
|
92d3152f22f3
[gaim-migrate @ 4649]
Christian Hammond <chipx86@chipx86.com>
parents:
4382
diff
changeset
|
3503 | |
|
92d3152f22f3
[gaim-migrate @ 4649]
Christian Hammond <chipx86@chipx86.com>
parents:
4382
diff
changeset
|
3504 | FILE *fd; |
|
92d3152f22f3
[gaim-migrate @ 4649]
Christian Hammond <chipx86@chipx86.com>
parents:
4382
diff
changeset
|
3505 | char filename[256]; |
|
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 | g_snprintf(filename, sizeof(filename), "%s%s", name, |
|
92d3152f22f3
[gaim-migrate @ 4649]
Christian Hammond <chipx86@chipx86.com>
parents:
4382
diff
changeset
|
3508 | (conv_type == GAIM_CONV_CHAT ? ".chat" : "")); |
|
92d3152f22f3
[gaim-migrate @ 4649]
Christian Hammond <chipx86@chipx86.com>
parents:
4382
diff
changeset
|
3509 | |
|
92d3152f22f3
[gaim-migrate @ 4649]
Christian Hammond <chipx86@chipx86.com>
parents:
4382
diff
changeset
|
3510 | fd = open_log_file(filename, (conv_type == GAIM_CONV_CHAT)); |
|
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 (fd) { |
|
92d3152f22f3
[gaim-migrate @ 4649]
Christian Hammond <chipx86@chipx86.com>
parents:
4382
diff
changeset
|
3513 | if (!(logging_options & OPT_LOG_STRIP_HTML)) |
|
92d3152f22f3
[gaim-migrate @ 4649]
Christian Hammond <chipx86@chipx86.com>
parents:
4382
diff
changeset
|
3514 | fprintf(fd, |
|
92d3152f22f3
[gaim-migrate @ 4649]
Christian Hammond <chipx86@chipx86.com>
parents:
4382
diff
changeset
|
3515 | "<HR><BR><H3 Align=Center> " |
|
92d3152f22f3
[gaim-migrate @ 4649]
Christian Hammond <chipx86@chipx86.com>
parents:
4382
diff
changeset
|
3516 | "---- New Conversation @ %s ----</H3><BR>\n", |
|
92d3152f22f3
[gaim-migrate @ 4649]
Christian Hammond <chipx86@chipx86.com>
parents:
4382
diff
changeset
|
3517 | full_date()); |
|
92d3152f22f3
[gaim-migrate @ 4649]
Christian Hammond <chipx86@chipx86.com>
parents:
4382
diff
changeset
|
3518 | else |
|
92d3152f22f3
[gaim-migrate @ 4649]
Christian Hammond <chipx86@chipx86.com>
parents:
4382
diff
changeset
|
3519 | fprintf(fd, "---- New Conversation @ %s ----\n", |
|
92d3152f22f3
[gaim-migrate @ 4649]
Christian Hammond <chipx86@chipx86.com>
parents:
4382
diff
changeset
|
3520 | full_date()); |
|
92d3152f22f3
[gaim-migrate @ 4649]
Christian Hammond <chipx86@chipx86.com>
parents:
4382
diff
changeset
|
3521 | |
|
92d3152f22f3
[gaim-migrate @ 4649]
Christian Hammond <chipx86@chipx86.com>
parents:
4382
diff
changeset
|
3522 | fclose(fd); |
|
92d3152f22f3
[gaim-migrate @ 4649]
Christian Hammond <chipx86@chipx86.com>
parents:
4382
diff
changeset
|
3523 | } |
|
92d3152f22f3
[gaim-migrate @ 4649]
Christian Hammond <chipx86@chipx86.com>
parents:
4382
diff
changeset
|
3524 | } |
|
92d3152f22f3
[gaim-migrate @ 4649]
Christian Hammond <chipx86@chipx86.com>
parents:
4382
diff
changeset
|
3525 | |
| 4359 | 3526 | /* Setup the container for the tab. */ |
| 3527 | gtkconv->tab_cont = tab_cont = gtk_vbox_new(FALSE, 5); | |
| 3528 | gtk_container_set_border_width(GTK_CONTAINER(tab_cont), 5); | |
| 3529 | gtk_container_add(GTK_CONTAINER(tab_cont), pane); | |
| 3530 | gtk_widget_show(pane); | |
| 3531 | ||
| 3532 | new_ui = TRUE; | |
| 4636 | 3533 | |
| 3534 | gtk_widget_grab_focus(pane); | |
| 3535 | ||
| 4359 | 3536 | gtkconv->make_sound = TRUE; |
| 3537 | } | |
| 3538 | ||
| 3539 | gtkconv->tabby = tabby = gtk_hbox_new(FALSE, 5); | |
| 3540 | ||
| 3541 | /* Close button. */ | |
| 3542 | gtkconv->close = gtk_button_new(); | |
| 3543 | gtk_widget_set_size_request(GTK_WIDGET(gtkconv->close), 16, 16); | |
| 3544 | gtk_container_add(GTK_CONTAINER(gtkconv->close), | |
| 4445 | 3545 | gtk_image_new_from_stock(GTK_STOCK_CLOSE, |
| 3546 | GTK_ICON_SIZE_MENU)); | |
| 4359 | 3547 | gtk_button_set_relief(GTK_BUTTON(gtkconv->close), GTK_RELIEF_NONE); |
| 3548 | gtk_tooltips_set_tip(gtkconv->tooltips, gtkconv->close, | |
|
4572
c6dfc8e14233
[gaim-migrate @ 4853]
Christian Hammond <chipx86@chipx86.com>
parents:
4571
diff
changeset
|
3549 | _("Close conversation"), NULL); |
| 4359 | 3550 | |
| 3551 | g_signal_connect(G_OBJECT(gtkconv->close), "clicked", | |
|
4571
57ca8feb5fd3
[gaim-migrate @ 4852]
Christian Hammond <chipx86@chipx86.com>
parents:
4561
diff
changeset
|
3552 | G_CALLBACK(close_conv_cb), conv); |
| 4359 | 3553 | |
| 3554 | /* Tab label. */ | |
| 3555 | gtkconv->tab_label = gtk_label_new(gaim_conversation_get_title(conv)); | |
| 3556 | #if 0 | |
| 3557 | gtk_misc_set_alignment(GTK_MISC(gtkconv->tab_label), 0.00, 0.5); | |
| 3558 | gtk_misc_set_padding(GTK_MISC(gtkconv->tab_label), 4, 0); | |
| 3559 | #endif | |
| 3560 | ||
| 3561 | /* Pack it all together. */ | |
| 3562 | gtk_box_pack_start(GTK_BOX(tabby), gtkconv->tab_label, TRUE, TRUE, 0); | |
| 4445 | 3563 | gtk_widget_show(gtkconv->tab_label); |
| 3564 | gtk_box_pack_start(GTK_BOX(tabby), gtkconv->close, FALSE, FALSE, 0); | |
| 3565 | if (!(convo_options & OPT_CONVO_NO_X_ON_TAB)) | |
| 3566 | gtk_widget_show_all(gtkconv->close); | |
| 3567 | gtk_widget_show(tabby); | |
| 4359 | 3568 | |
| 3569 | ||
| 3570 | /* Add this pane to the conversations notebook. */ | |
| 3571 | gtk_notebook_append_page(GTK_NOTEBOOK(gtkwin->notebook), tab_cont, tabby); | |
| 3572 | gtk_notebook_set_menu_label_text(GTK_NOTEBOOK(gtkwin->notebook), tab_cont, | |
| 3573 | gaim_conversation_get_title(conv)); | |
| 3574 | ||
| 3575 | gtk_widget_show(tab_cont); | |
| 3576 | ||
| 3577 | /* Er, bug in notebooks? Switch to the page manually. */ | |
| 3578 | if (gaim_window_get_conversation_count(win) == 1) | |
| 3579 | gtk_notebook_set_current_page(GTK_NOTEBOOK(gtkwin->notebook), 0); | |
| 3580 | ||
| 3581 | if ((gtk_notebook_get_current_page(GTK_NOTEBOOK(gtkwin->notebook)) == 0) || | |
| 3582 | (conv == g_list_nth_data(gaim_window_get_conversations(win), 0))) { | |
| 3583 | ||
| 3584 | gtk_widget_grab_focus(gtkconv->entry); | |
| 3585 | } | |
| 3586 | ||
| 3587 | gaim_gtkconv_update_buddy_icon(conv); | |
| 3588 | ||
| 3589 | if (!new_ui) | |
| 3590 | g_object_unref(gtkconv->tab_cont); | |
| 3591 | ||
| 3592 | if (gaim_window_get_conversation_count(win) == 1) | |
| 4685 | 3593 | g_timeout_add(0, (GSourceFunc)update_send_as_selection, win); |
| 4359 | 3594 | } |
| 3595 | ||
| 3596 | static void | |
| 3597 | gaim_gtk_remove_conversation(struct gaim_window *win, | |
| 3598 | struct gaim_conversation *conv) | |
| 3599 | { | |
| 3600 | struct gaim_gtk_window *gtkwin; | |
| 3601 | struct gaim_gtk_conversation *gtkconv; | |
| 3602 | unsigned int index; | |
| 3603 | ||
| 3604 | index = gaim_conversation_get_index(conv); | |
| 3605 | ||
| 3606 | gtkwin = GAIM_GTK_WINDOW(win); | |
| 3607 | gtkconv = GAIM_GTK_CONVERSATION(conv); | |
| 3608 | ||
| 3609 | g_object_ref(gtkconv->tab_cont); | |
| 3610 | gtk_object_sink(GTK_OBJECT(gtkconv->tab_cont)); | |
| 3611 | ||
| 3612 | gtk_notebook_remove_page(GTK_NOTEBOOK(gtkwin->notebook), index); | |
| 3613 | ||
| 3614 | /* If this window is setup with an inactive gc, regenerate the menu. */ | |
| 3615 | if (gaim_conversation_get_type(conv) == GAIM_CONV_IM && | |
| 3616 | gaim_conversation_get_gc(conv) == NULL) { | |
| 3617 | ||
|
4360
28aa945b7c16
[gaim-migrate @ 4626]
Christian Hammond <chipx86@chipx86.com>
parents:
4359
diff
changeset
|
3618 | generate_send_as_items(win, conv); |
| 4359 | 3619 | } |
| 3620 | } | |
| 3621 | ||
| 3622 | static void | |
| 3623 | gaim_gtk_move_conversation(struct gaim_window *win, | |
| 3624 | struct gaim_conversation *conv, | |
| 3625 | unsigned int new_index) | |
| 3626 | { | |
| 3627 | struct gaim_gtk_window *gtkwin; | |
| 3628 | struct gaim_gtk_conversation *gtkconv; | |
| 3629 | ||
| 3630 | gtkwin = GAIM_GTK_WINDOW(win); | |
| 3631 | gtkconv = GAIM_GTK_CONVERSATION(conv); | |
| 3632 | ||
|
4415
eca21938871e
[gaim-migrate @ 4688]
Christian Hammond <chipx86@chipx86.com>
parents:
4409
diff
changeset
|
3633 | if (new_index > gaim_conversation_get_index(conv)) |
|
eca21938871e
[gaim-migrate @ 4688]
Christian Hammond <chipx86@chipx86.com>
parents:
4409
diff
changeset
|
3634 | new_index--; |
|
eca21938871e
[gaim-migrate @ 4688]
Christian Hammond <chipx86@chipx86.com>
parents:
4409
diff
changeset
|
3635 | |
| 4359 | 3636 | gtk_notebook_reorder_child(GTK_NOTEBOOK(gtkwin->notebook), |
| 3637 | gtkconv->tab_cont, new_index); | |
| 3638 | } | |
| 3639 | ||
| 3640 | static int | |
| 3641 | gaim_gtk_get_active_index(const struct gaim_window *win) | |
| 3642 | { | |
| 3643 | struct gaim_gtk_window *gtkwin; | |
| 3644 | ||
| 3645 | gtkwin = GAIM_GTK_WINDOW(win); | |
| 3646 | ||
| 3647 | return gtk_notebook_get_current_page(GTK_NOTEBOOK(gtkwin->notebook)); | |
| 3648 | } | |
| 3649 | ||
|
4465
43184ae252ed
[gaim-migrate @ 4740]
Christian Hammond <chipx86@chipx86.com>
parents:
4454
diff
changeset
|
3650 | static struct gaim_window_ui_ops window_ui_ops = |
| 4359 | 3651 | { |
|
4465
43184ae252ed
[gaim-migrate @ 4740]
Christian Hammond <chipx86@chipx86.com>
parents:
4454
diff
changeset
|
3652 | gaim_gtk_get_conversation_ui_ops, |
| 4359 | 3653 | gaim_gtk_new_window, |
| 3654 | gaim_gtk_destroy_window, | |
| 3655 | gaim_gtk_show, | |
| 3656 | gaim_gtk_hide, | |
| 3657 | gaim_gtk_raise, | |
| 3658 | gaim_gtk_flash, | |
| 3659 | gaim_gtk_switch_conversation, | |
| 3660 | gaim_gtk_add_conversation, | |
| 3661 | gaim_gtk_remove_conversation, | |
| 3662 | gaim_gtk_move_conversation, | |
| 3663 | gaim_gtk_get_active_index | |
| 3664 | }; | |
| 3665 | ||
| 3666 | static void | |
| 3667 | update_convo_add_button(struct gaim_conversation *conv) | |
| 3668 | { | |
| 3669 | struct gaim_gtk_conversation *gtkconv; | |
| 3670 | struct gaim_connection *gc; | |
| 3671 | GaimConversationType type; | |
| 3672 | GtkWidget *parent; | |
| 3673 | ||
| 3674 | type = gaim_conversation_get_type(conv); | |
| 3675 | gc = gaim_conversation_get_gc(conv); | |
| 3676 | gtkconv = GAIM_GTK_CONVERSATION(conv); | |
| 3677 | parent = gtk_widget_get_parent(gtkconv->u.im->add); | |
| 3678 | ||
| 4687 | 3679 | if (gaim_find_buddy(gc->account, gaim_conversation_get_name(conv))) { |
| 4397 | 3680 | gtkconv->u.im->add = |
| 3681 | gaim_gtk_change_text(_("Remove"), gtkconv->u.im->add, | |
| 3682 | GTK_STOCK_REMOVE, type); | |
| 3683 | gtk_tooltips_set_tip(gtkconv->tooltips, gtkconv->u.im->add, | |
| 3684 | _("Remove the user from your buddy list"), NULL); | |
| 3685 | ||
| 4359 | 3686 | gtk_widget_set_sensitive(gtkconv->u.im->add, |
| 3687 | (gc != NULL && gc->prpl->remove_buddy != NULL)); | |
| 3688 | } else { | |
| 4397 | 3689 | gtkconv->u.im->add = |
| 3690 | gaim_gtk_change_text(_("Add"), gtkconv->u.im->add, | |
| 3691 | GTK_STOCK_ADD, type); | |
| 3692 | gtk_tooltips_set_tip(gtkconv->tooltips, gtkconv->u.im->add, | |
| 3693 | _("Add the user to your buddy list"), NULL); | |
| 4359 | 3694 | |
| 3695 | gtk_widget_set_sensitive(gtkconv->u.im->add, | |
| 3696 | (gc != NULL && gc->prpl->add_buddy != NULL)); | |
| 3697 | } | |
| 3698 | ||
| 4397 | 3699 | g_signal_connect(G_OBJECT(gtkconv->u.im->add), "clicked", |
| 3700 | G_CALLBACK(add_cb), conv); | |
| 3701 | ||
| 3702 | gtk_box_pack_start(GTK_BOX(parent), gtkconv->u.im->add, | |
| 3703 | FALSE, FALSE, 0); | |
| 3704 | gtk_box_reorder_child(GTK_BOX(parent), gtkconv->u.im->add, 3); | |
| 3705 | gtk_button_set_relief(GTK_BUTTON(gtkconv->u.im->add), GTK_RELIEF_NONE); | |
| 3706 | gtk_size_group_add_widget(gtkconv->sg, gtkconv->u.im->add); | |
| 4359 | 3707 | } |
| 3708 | ||
|
4465
43184ae252ed
[gaim-migrate @ 4740]
Christian Hammond <chipx86@chipx86.com>
parents:
4454
diff
changeset
|
3709 | struct gaim_window_ui_ops * |
|
43184ae252ed
[gaim-migrate @ 4740]
Christian Hammond <chipx86@chipx86.com>
parents:
4454
diff
changeset
|
3710 | gaim_get_gtk_window_ui_ops(void) |
| 4359 | 3711 | { |
|
4465
43184ae252ed
[gaim-migrate @ 4740]
Christian Hammond <chipx86@chipx86.com>
parents:
4454
diff
changeset
|
3712 | return &window_ui_ops; |
| 4359 | 3713 | } |
| 3714 | ||
| 3715 | /************************************************************************** | |
|
4465
43184ae252ed
[gaim-migrate @ 4740]
Christian Hammond <chipx86@chipx86.com>
parents:
4454
diff
changeset
|
3716 | * Conversation UI operations |
| 4359 | 3717 | **************************************************************************/ |
| 3718 | static void | |
| 3719 | gaim_gtkconv_destroy(struct gaim_conversation *conv) | |
| 3720 | { | |
| 3721 | struct gaim_gtk_conversation *gtkconv = GAIM_GTK_CONVERSATION(conv); | |
| 3722 | ||
| 3723 | if (gtkconv->dialogs.fg_color != NULL) | |
| 3724 | gtk_widget_destroy(gtkconv->dialogs.fg_color); | |
| 3725 | ||
| 3726 | if (gtkconv->dialogs.bg_color != NULL) | |
| 3727 | gtk_widget_destroy(gtkconv->dialogs.bg_color); | |
| 3728 | ||
| 3729 | if (gtkconv->dialogs.font != NULL) | |
| 3730 | gtk_widget_destroy(gtkconv->dialogs.font); | |
| 3731 | ||
| 3732 | if (gtkconv->dialogs.smiley != NULL) | |
| 3733 | gtk_widget_destroy(gtkconv->dialogs.smiley); | |
| 3734 | ||
| 3735 | if (gtkconv->dialogs.link != NULL) | |
| 3736 | gtk_widget_destroy(gtkconv->dialogs.link); | |
| 3737 | ||
| 3738 | if (gtkconv->dialogs.log != NULL) | |
| 3739 | gtk_widget_destroy(gtkconv->dialogs.log); | |
| 3740 | ||
|
4571
57ca8feb5fd3
[gaim-migrate @ 4852]
Christian Hammond <chipx86@chipx86.com>
parents:
4561
diff
changeset
|
3741 | gtk_widget_destroy(gtkconv->tab_cont); |
|
57ca8feb5fd3
[gaim-migrate @ 4852]
Christian Hammond <chipx86@chipx86.com>
parents:
4561
diff
changeset
|
3742 | |
| 4359 | 3743 | if (gaim_conversation_get_type(conv) == GAIM_CONV_IM) { |
|
4755
64ee7fb9cdba
[gaim-migrate @ 5072]
Mark Doliner <markdoliner@pidgin.im>
parents:
4748
diff
changeset
|
3744 | if (gtkconv->u.im->icon_timer != 0) |
|
64ee7fb9cdba
[gaim-migrate @ 5072]
Mark Doliner <markdoliner@pidgin.im>
parents:
4748
diff
changeset
|
3745 | g_source_remove(gtkconv->u.im->icon_timer); |
|
64ee7fb9cdba
[gaim-migrate @ 5072]
Mark Doliner <markdoliner@pidgin.im>
parents:
4748
diff
changeset
|
3746 | |
| 4359 | 3747 | if (gtkconv->u.im->save_icon != NULL) |
| 3748 | gtk_widget_destroy(gtkconv->u.im->save_icon); | |
| 3749 | ||
| 3750 | if (gtkconv->u.im->anim != NULL) | |
| 3751 | gdk_pixbuf_animation_unref(gtkconv->u.im->anim); | |
| 3752 | ||
| 3753 | g_free(gtkconv->u.im); | |
| 3754 | } | |
| 3755 | else if (gaim_conversation_get_type(conv) == GAIM_CONV_CHAT) { | |
| 3756 | g_free(gtkconv->u.chat); | |
| 3757 | } | |
| 3758 | ||
| 4633 | 3759 | gtk_object_sink(GTK_OBJECT(gtkconv->tooltips)); |
| 3760 | ||
| 4359 | 3761 | g_free(gtkconv); |
| 3762 | } | |
| 3763 | ||
| 3764 | static void | |
| 3765 | gaim_gtkconv_write_im(struct gaim_conversation *conv, const char *who, | |
| 3766 | const char *message, size_t len, int flags, time_t mtime) | |
| 3767 | { | |
| 3768 | struct gaim_gtk_conversation *gtkconv; | |
| 3769 | ||
| 3770 | gtkconv = GAIM_GTK_CONVERSATION(conv); | |
| 3771 | ||
|
4382
fd60cabf2bae
[gaim-migrate @ 4648]
Christian Hammond <chipx86@chipx86.com>
parents:
4378
diff
changeset
|
3772 | /* Play a sound, if specified in prefs. */ |
| 4359 | 3773 | if (gtkconv->make_sound) { |
| 3774 | if (flags & WFLAG_RECV) { | |
| 3775 | if (gtkconv->u.im->a_virgin && | |
| 3776 | (sound_options & OPT_SOUND_FIRST_RCV)) { | |
| 3777 | ||
| 4561 | 3778 | gaim_sound_play_event(GAIM_SOUND_FIRST_RECEIVE); |
| 4359 | 3779 | } |
| 3780 | else | |
| 4561 | 3781 | gaim_sound_play_event(GAIM_SOUND_RECEIVE); |
| 4359 | 3782 | } |
| 3783 | else { | |
| 4561 | 3784 | gaim_sound_play_event(GAIM_SOUND_SEND); |
| 4359 | 3785 | } |
| 3786 | } | |
| 3787 | ||
| 3788 | gtkconv->u.im->a_virgin = FALSE; | |
| 3789 | ||
| 3790 | gaim_conversation_write(conv, who, message, len, flags, mtime); | |
| 3791 | } | |
| 3792 | ||
| 3793 | static void | |
| 3794 | gaim_gtkconv_write_chat(struct gaim_conversation *conv, const char *who, | |
| 3795 | const char *message, int flags, time_t mtime) | |
| 3796 | { | |
| 3797 | struct gaim_gtk_conversation *gtkconv; | |
| 3798 | ||
| 3799 | gtkconv = GAIM_GTK_CONVERSATION(conv); | |
| 3800 | ||
|
4382
fd60cabf2bae
[gaim-migrate @ 4648]
Christian Hammond <chipx86@chipx86.com>
parents:
4378
diff
changeset
|
3801 | /* Play a sound, if specified in prefs. */ |
| 4359 | 3802 | if (gtkconv->make_sound) { |
| 3803 | if (!(flags & WFLAG_WHISPER) && (flags & WFLAG_SEND)) | |
| 4561 | 3804 | gaim_sound_play_event(GAIM_SOUND_CHAT_YOU_SAY); |
| 4359 | 3805 | else if (flags & WFLAG_RECV) { |
| 3806 | if ((flags & WFLAG_NICK) && (sound_options & OPT_SOUND_CHAT_NICK)) | |
| 4561 | 3807 | gaim_sound_play_event(GAIM_SOUND_CHAT_NICK); |
| 4359 | 3808 | else |
| 4561 | 3809 | gaim_sound_play_event(GAIM_SOUND_CHAT_SAY); |
| 4359 | 3810 | } |
| 3811 | } | |
| 3812 | ||
| 3813 | if (chat_options & OPT_CHAT_COLORIZE) | |
| 3814 | flags |= WFLAG_COLORIZE; | |
| 3815 | ||
| 3816 | gaim_conversation_write(conv, who, message, -1, flags, mtime); | |
| 3817 | } | |
| 3818 | ||
| 3819 | static void | |
| 3820 | gaim_gtkconv_write_conv(struct gaim_conversation *conv, const char *who, | |
| 3821 | const char *message, size_t length, int flags, | |
| 3822 | time_t mtime) | |
| 3823 | { | |
| 3824 | struct gaim_gtk_conversation *gtkconv; | |
| 3825 | struct gaim_connection *gc; | |
| 3826 | int gtk_font_options = 0; | |
| 3827 | GString *log_str; | |
| 3828 | FILE *fd; | |
| 3829 | char buf[BUF_LONG]; | |
| 3830 | char buf2[BUF_LONG]; | |
| 3831 | char mdate[64]; | |
| 3832 | char color[10]; | |
| 3833 | char *str; | |
| 3834 | char *with_font_tag; | |
| 3835 | ||
| 3836 | gtkconv = GAIM_GTK_CONVERSATION(conv); | |
| 3837 | gc = gaim_conversation_get_gc(conv); | |
| 3838 | ||
| 3839 | strftime(mdate, sizeof(mdate), "%H:%M:%S", localtime(&mtime)); | |
| 3840 | ||
| 3841 | gtk_font_options ^= GTK_IMHTML_NO_COMMENTS; | |
| 3842 | ||
| 3843 | if (convo_options & OPT_CONVO_IGNORE_COLOUR) | |
| 3844 | gtk_font_options ^= GTK_IMHTML_NO_COLOURS; | |
| 3845 | ||
| 3846 | if (convo_options & OPT_CONVO_IGNORE_FONTS) | |
| 3847 | gtk_font_options ^= GTK_IMHTML_NO_FONTS; | |
| 3848 | ||
| 3849 | if (convo_options & OPT_CONVO_IGNORE_SIZES) | |
| 3850 | gtk_font_options ^= GTK_IMHTML_NO_SIZES; | |
| 3851 | ||
| 3852 | if (!(logging_options & OPT_LOG_STRIP_HTML)) | |
| 3853 | gtk_font_options ^= GTK_IMHTML_RETURN_LOG; | |
| 3854 | ||
| 3855 | if (flags & WFLAG_SYSTEM) { | |
| 3856 | if (convo_options & OPT_CONVO_SHOW_TIME) | |
| 3857 | g_snprintf(buf, BUF_LONG, "<FONT SIZE=\"2\">(%s) </FONT><B>%s</B>", | |
| 3858 | mdate, message); | |
| 3859 | else | |
| 3860 | g_snprintf(buf, BUF_LONG, "<B>%s</B>", message); | |
| 3861 | ||
| 3862 | g_snprintf(buf2, sizeof(buf2), | |
| 3863 | "<FONT SIZE=\"2\"><!--(%s) --></FONT><B>%s</B><BR>", | |
| 3864 | mdate, message); | |
| 3865 | ||
| 3866 | gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), buf2, -1, 0); | |
| 3867 | ||
| 3868 | if (logging_options & OPT_LOG_STRIP_HTML) { | |
| 3869 | char *t1 = strip_html(buf); | |
| 3870 | ||
| 3871 | conv->history = g_string_append(conv->history, t1); | |
| 3872 | conv->history = g_string_append(conv->history, "\n"); | |
| 3873 | ||
| 3874 | g_free(t1); | |
| 3875 | } | |
| 3876 | else { | |
| 3877 | conv->history = g_string_append(conv->history, buf); | |
| 3878 | conv->history = g_string_append(conv->history, "<BR>\n"); | |
| 3879 | } | |
| 3880 | ||
| 3881 | if (!(flags & WFLAG_NOLOG) && gaim_conversation_is_logging(conv)) { | |
| 3882 | ||
| 3883 | char *t1; | |
| 3884 | char nm[256]; | |
| 3885 | ||
| 3886 | if (logging_options & OPT_LOG_STRIP_HTML) | |
| 3887 | t1 = strip_html(buf); | |
| 3888 | else | |
| 3889 | t1 = buf; | |
| 3890 | ||
| 3891 | if (gaim_conversation_get_type(conv) == GAIM_CONV_CHAT) | |
| 3892 | g_snprintf(nm, sizeof(nm), "%s.chat", | |
| 3893 | gaim_conversation_get_name(conv)); | |
| 3894 | else | |
| 3895 | strncpy(nm, gaim_conversation_get_name(conv), sizeof(nm)); | |
| 3896 | ||
| 3897 | fd = open_log_file(nm, | |
| 3898 | (gaim_conversation_get_type(conv) == GAIM_CONV_CHAT)); | |
| 3899 | ||
| 3900 | if (fd) { | |
| 3901 | if (logging_options & OPT_LOG_STRIP_HTML) | |
| 3902 | fprintf(fd, "%s\n", t1); | |
| 3903 | else | |
| 3904 | fprintf(fd, "%s<BR>\n", t1); | |
| 3905 | ||
| 3906 | fclose(fd); | |
| 3907 | } | |
| 3908 | ||
| 3909 | if (logging_options & OPT_LOG_STRIP_HTML) | |
| 3910 | g_free(t1); | |
| 3911 | } | |
| 3912 | } | |
| 3913 | else if (flags & WFLAG_NOLOG) { | |
| 3914 | g_snprintf(buf, BUF_LONG, | |
| 3915 | "<B><FONT COLOR=\"#777777\">%s</FONT></B><BR>", | |
| 3916 | message); | |
| 3917 | ||
| 3918 | gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), buf, -1, 0); | |
| 3919 | } | |
| 3920 | else { | |
| 3921 | char *new_message = g_strdup(message); | |
| 3922 | ||
| 3923 | if (flags & WFLAG_WHISPER) { | |
| 3924 | str = g_malloc(1024); | |
| 3925 | ||
| 3926 | /* If we're whispering, it's not an autoresponse. */ | |
| 3927 | if (meify(new_message, length)) { | |
| 3928 | g_snprintf(str, 1024, "***%s", who); | |
| 3929 | strcpy(color, "#6C2585"); | |
| 3930 | } | |
| 3931 | else { | |
| 3932 | g_snprintf(str, 1024, "*%s*:", who); | |
| 3933 | strcpy(color, "#00FF00"); | |
| 3934 | } | |
| 3935 | } | |
| 3936 | else { | |
| 3937 | if (meify(new_message, length)) { | |
| 3938 | str = g_malloc(1024); | |
| 3939 | ||
| 3940 | if (flags & WFLAG_AUTO) | |
| 3941 | g_snprintf(str, 1024, "%s ***%s", AUTO_RESPONSE, who); | |
| 3942 | else | |
| 3943 | g_snprintf(str, 1024, "***%s", who); | |
| 3944 | ||
| 3945 | if (flags & WFLAG_NICK) | |
| 3946 | strcpy(color, "#AF7F00"); | |
| 3947 | else | |
| 3948 | strcpy(color, "#062585"); | |
| 3949 | } | |
| 3950 | else { | |
| 3951 | str = g_malloc(1024); | |
| 3952 | ||
| 3953 | if (flags & WFLAG_AUTO) | |
| 3954 | g_snprintf(str, 1024, "%s %s", who, AUTO_RESPONSE); | |
| 3955 | else | |
| 3956 | g_snprintf(str, 1024, "%s:", who); | |
| 3957 | ||
| 3958 | if (flags & WFLAG_NICK) | |
| 3959 | strcpy(color, "#AF7F00"); | |
| 3960 | else if (flags & WFLAG_RECV) { | |
| 3961 | if (flags & WFLAG_COLORIZE) { | |
| 3962 | const char *u; | |
| 3963 | int m = 0; | |
| 3964 | ||
| 3965 | for (u = who; *u != '\0'; u++) | |
| 3966 | m += *u; | |
| 3967 | ||
| 3968 | m = m % NUM_NICK_COLORS; | |
| 3969 | ||
| 3970 | strcpy(color, nick_colors[m]); | |
| 3971 | } | |
| 3972 | else | |
| 3973 | strcpy(color, "#A82F2F"); | |
| 3974 | } | |
| 3975 | else if (flags & WFLAG_SEND) | |
| 3976 | strcpy(color, "#16569E"); | |
| 3977 | } | |
| 3978 | } | |
| 3979 | ||
| 3980 | if (convo_options & OPT_CONVO_SHOW_TIME) | |
| 3981 | g_snprintf(buf, BUF_LONG, | |
| 3982 | "<FONT COLOR=\"%s\"><FONT SIZE=\"2\">(%s) </FONT>" | |
| 3983 | "<B>%s</B></FONT> ", color, mdate, str); | |
| 3984 | else | |
| 3985 | g_snprintf(buf, BUF_LONG, | |
| 3986 | "<FONT COLOR=\"%s\"><B>%s</B></FONT> ", color, str); | |
| 3987 | ||
| 3988 | g_snprintf(buf2, BUF_LONG, | |
| 3989 | "<FONT COLOR=\"%s\"><FONT SIZE=\"2\"><!--(%s) --></FONT>" | |
| 3990 | "<B>%s</B></FONT> ", | |
| 3991 | color, mdate, str); | |
| 3992 | ||
| 3993 | g_free(str); | |
| 3994 | ||
| 3995 | gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), buf2, -1, 0); | |
| 3996 | ||
| 4608 | 3997 | if(gc) |
| 3998 | with_font_tag = g_strdup_printf("<font sml=\"%s\">%s</font>", | |
| 4359 | 3999 | gc->prpl->name, new_message); |
| 4608 | 4000 | else |
| 4001 | with_font_tag = g_strdup(new_message); | |
| 4359 | 4002 | |
| 4003 | log_str = gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), | |
| 4004 | with_font_tag, length, | |
| 4005 | gtk_font_options); | |
| 4006 | ||
| 4007 | gtk_imhtml_append_text(GTK_IMHTML(gtkconv->imhtml), "<BR>", -1, 0); | |
| 4008 | ||
| 4009 | /* XXX This needs to be updated for the new length argument. */ | |
| 4010 | if (logging_options & OPT_LOG_STRIP_HTML) { | |
| 4011 | char *t1, *t2; | |
| 4012 | ||
| 4013 | t1 = strip_html(buf); | |
| 4014 | t2 = strip_html(new_message); | |
| 4015 | ||
| 4016 | conv->history = g_string_append(conv->history, t1); | |
| 4017 | conv->history = g_string_append(conv->history, t2); | |
| 4018 | conv->history = g_string_append(conv->history, "\n"); | |
| 4019 | ||
| 4020 | g_free(t1); | |
| 4021 | g_free(t2); | |
| 4022 | } | |
| 4023 | else { | |
| 4024 | char *t1, *t2; | |
| 4025 | ||
| 4026 | t1 = html_logize(buf); | |
| 4027 | t2 = html_logize(new_message); | |
| 4028 | ||
| 4029 | conv->history = g_string_append(conv->history, t1); | |
| 4030 | conv->history = g_string_append(conv->history, t2); | |
| 4031 | conv->history = g_string_append(conv->history, "\n"); | |
| 4032 | conv->history = g_string_append(conv->history, log_str->str); | |
| 4033 | conv->history = g_string_append(conv->history, "<BR>\n"); | |
| 4034 | ||
| 4035 | g_free(t1); | |
| 4036 | g_free(t2); | |
| 4037 | } | |
| 4038 | ||
| 4039 | /* XXX This needs to be updated for the new length argument. */ | |
| 4040 | if (gaim_conversation_is_logging(conv)) { | |
| 4041 | char *t1, *t2; | |
| 4042 | char nm[256]; | |
| 4043 | ||
| 4044 | if (gaim_conversation_get_type(conv) == GAIM_CONV_CHAT) | |
| 4045 | g_snprintf(nm, sizeof(nm), "%s.chat", | |
| 4046 | gaim_conversation_get_name(conv)); | |
| 4047 | else | |
| 4048 | strncpy(nm, gaim_conversation_get_name(conv), sizeof(nm)); | |
| 4049 | ||
| 4050 | if (logging_options & OPT_LOG_STRIP_HTML) { | |
| 4051 | t1 = strip_html(buf); | |
| 4052 | t2 = strip_html(with_font_tag); | |
| 4053 | } | |
| 4054 | else { | |
| 4055 | t1 = html_logize(buf); | |
| 4056 | t2 = html_logize(with_font_tag); | |
| 4057 | } | |
| 4058 | ||
| 4059 | fd = open_log_file(nm, | |
| 4060 | (gaim_conversation_get_type(conv) == GAIM_CONV_CHAT)); | |
| 4061 | ||
| 4062 | if (fd) { | |
| 4063 | if (logging_options & OPT_LOG_STRIP_HTML) | |
| 4064 | fprintf(fd, "%s%s\n", t1, t2); | |
| 4065 | else { | |
| 4066 | fprintf(fd, "%s%s%s<BR>\n", t1, t2, log_str->str); | |
| 4067 | g_string_free(log_str, TRUE); | |
| 4068 | } | |
| 4069 | ||
| 4070 | fclose(fd); | |
| 4071 | } | |
| 4072 | ||
| 4073 | g_free(t1); | |
| 4074 | g_free(t2); | |
| 4075 | } | |
| 4076 | ||
| 4077 | g_free(with_font_tag); | |
| 4078 | g_free(new_message); | |
| 4079 | } | |
| 4080 | } | |
| 4081 | ||
| 4082 | static void | |
| 4083 | gaim_gtkconv_chat_add_user(struct gaim_conversation *conv, const char *user) | |
| 4084 | { | |
| 4085 | struct gaim_chat *chat; | |
| 4086 | struct gaim_gtk_conversation *gtkconv; | |
| 4087 | struct gaim_gtk_chat_pane *gtkchat; | |
| 4088 | char tmp[BUF_LONG]; | |
| 4089 | int num_users; | |
| 4090 | int pos; | |
| 4091 | ||
| 4092 | chat = GAIM_CHAT(conv); | |
| 4093 | gtkconv = GAIM_GTK_CONVERSATION(conv); | |
| 4094 | gtkchat = gtkconv->u.chat; | |
| 4095 | ||
| 4096 | num_users = g_list_length(gaim_chat_get_users(chat)); | |
| 4097 | ||
| 4098 | g_snprintf(tmp, sizeof(tmp), | |
| 4099 | ngettext("%d person in room", "%d people in room", | |
| 4100 | num_users), | |
| 4101 | num_users); | |
| 4102 | ||
| 4103 | gtk_label_set_text(GTK_LABEL(gtkchat->count), tmp); | |
| 4104 | ||
| 4105 | if (gtkconv->make_sound) | |
| 4561 | 4106 | gaim_sound_play_event(GAIM_SOUND_CHAT_JOIN); |
| 4359 | 4107 | |
| 4108 | pos = g_list_index(gaim_chat_get_users(chat), user); | |
| 4109 | ||
| 4110 | add_chat_buddy_common(conv, user, pos); | |
| 4111 | } | |
| 4112 | ||
| 4113 | static void | |
| 4114 | gaim_gtkconv_chat_rename_user(struct gaim_conversation *conv, | |
| 4115 | const char *old_name, const char *new_name) | |
| 4116 | { | |
| 4117 | struct gaim_chat *chat; | |
| 4118 | struct gaim_gtk_conversation *gtkconv; | |
| 4119 | struct gaim_gtk_chat_pane *gtkchat; | |
| 4120 | GtkTreeIter iter; | |
| 4121 | GtkTreeModel *model; | |
| 4122 | GList *names; | |
| 4123 | int pos; | |
| 4124 | int f = 1; | |
| 4125 | ||
| 4126 | chat = GAIM_CHAT(conv); | |
| 4127 | gtkconv = GAIM_GTK_CONVERSATION(conv); | |
| 4128 | gtkchat = gtkconv->u.chat; | |
| 4129 | ||
| 4130 | for (names = gaim_chat_get_users(chat); | |
| 4131 | names != NULL; | |
| 4132 | names = names->next) { | |
| 4133 | ||
| 4134 | char *u = (char *)names->data; | |
| 4135 | ||
| 4136 | if (!g_strcasecmp(u, old_name)) { | |
| 4137 | model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); | |
| 4138 | ||
| 4139 | if (!gtk_tree_model_get_iter_first(GTK_TREE_MODEL(model), &iter)) | |
| 4140 | break; | |
| 4141 | ||
| 4142 | while (f != 0) { | |
| 4143 | char *val; | |
| 4144 | ||
| 4145 | gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, 1, &val, -1); | |
| 4146 | ||
| 4640 | 4147 | if (!g_strcasecmp(old_name, val)) { |
| 4359 | 4148 | gtk_list_store_remove(GTK_LIST_STORE(model), &iter); |
| 4640 | 4149 | break; |
| 4150 | } | |
| 4359 | 4151 | |
| 4152 | f = gtk_tree_model_iter_next(GTK_TREE_MODEL(model), &iter); | |
| 4153 | ||
| 4154 | g_free(val); | |
| 4155 | } | |
| 4156 | ||
| 4157 | break; | |
| 4158 | } | |
| 4159 | } | |
| 4160 | ||
| 4161 | if (!names) | |
| 4162 | return; | |
| 4163 | ||
| 4164 | pos = g_list_index(gaim_chat_get_users(chat), new_name); | |
| 4165 | ||
| 4166 | add_chat_buddy_common(conv, new_name, pos); | |
| 4167 | } | |
| 4168 | ||
| 4169 | static void | |
| 4170 | gaim_gtkconv_chat_remove_user(struct gaim_conversation *conv, const char *user) | |
| 4171 | { | |
| 4172 | struct gaim_chat *chat; | |
| 4173 | struct gaim_gtk_conversation *gtkconv; | |
| 4174 | struct gaim_gtk_chat_pane *gtkchat; | |
| 4175 | GtkTreeIter iter; | |
| 4176 | GtkTreeModel *model; | |
| 4177 | GList *names; | |
| 4178 | char tmp[BUF_LONG]; | |
| 4179 | int num_users; | |
| 4180 | int f = 1; | |
| 4181 | ||
| 4182 | chat = GAIM_CHAT(conv); | |
| 4183 | gtkconv = GAIM_GTK_CONVERSATION(conv); | |
| 4184 | gtkchat = gtkconv->u.chat; | |
| 4185 | ||
| 4186 | num_users = g_list_length(gaim_chat_get_users(chat)) - 1; | |
| 4187 | ||
| 4188 | for (names = gaim_chat_get_users(chat); | |
| 4189 | names != NULL; | |
| 4190 | names = names->next) { | |
| 4191 | ||
| 4192 | char *u = (char *)names->data; | |
| 4193 | ||
| 4194 | if (!g_strcasecmp(u, user)) { | |
| 4195 | model = gtk_tree_view_get_model(GTK_TREE_VIEW(gtkchat->list)); | |
| 4196 | ||
| 4197 | if (!gtk_tree_model_get_iter_first(GTK_TREE_MODEL(model), &iter)) | |
| 4198 | break; | |
| 4199 | ||
| 4200 | while (f != 0) { | |
| 4201 | char *val; | |
| 4202 | ||
| 4203 | gtk_tree_model_get(GTK_TREE_MODEL(model), &iter, 1, &val, -1); | |
| 4204 | ||
| 4205 | if (!g_strcasecmp(user, val)) | |
| 4206 | gtk_list_store_remove(GTK_LIST_STORE(model), &iter); | |
| 4207 | ||
| 4208 | f = gtk_tree_model_iter_next(GTK_TREE_MODEL(model), &iter); | |
| 4209 | ||
| 4210 | g_free(val); | |
| 4211 | } | |
| 4212 | ||
| 4213 | break; | |
| 4214 | } | |
| 4215 | } | |
| 4216 | ||
| 4217 | if (names == NULL) | |
| 4218 | return; | |
| 4219 | ||
| 4220 | g_snprintf(tmp, sizeof(tmp), | |
| 4221 | ngettext("%d person in room", "%d people in room", | |
| 4222 | num_users), num_users); | |
| 4223 | ||
| 4224 | gtk_label_set_text(GTK_LABEL(gtkchat->count), tmp); | |
| 4225 | ||
| 4226 | if (gtkconv->make_sound) | |
| 4561 | 4227 | gaim_sound_play_event(GAIM_SOUND_CHAT_LEAVE); |
| 4359 | 4228 | } |
| 4229 | ||
| 4230 | static void | |
| 4231 | gaim_gtkconv_set_title(struct gaim_conversation *conv, const char *title) | |
| 4232 | { | |
| 4233 | struct gaim_gtk_conversation *gtkconv; | |
| 4681 | 4234 | struct gaim_window *win; |
| 4235 | struct gaim_gtk_window *gtkwin; | |
| 4236 | ||
| 4237 | win = gaim_conversation_get_window(conv); | |
| 4238 | gtkwin = GAIM_GTK_WINDOW(win); | |
| 4359 | 4239 | gtkconv = GAIM_GTK_CONVERSATION(conv); |
| 4240 | ||
| 4241 | gtk_label_set_text(GTK_LABEL(gtkconv->tab_label), title); | |
| 4681 | 4242 | |
| 4243 | if(conv == gaim_window_get_active_conversation(win)) | |
| 4244 | gtk_window_set_title(GTK_WINDOW(gtkwin->window), title); | |
| 4359 | 4245 | } |
| 4246 | ||
| 4247 | static void | |
| 4248 | gaim_gtkconv_updated(struct gaim_conversation *conv, GaimConvUpdateType type) | |
| 4249 | { | |
| 4250 | struct gaim_window *win; | |
| 4736 | 4251 | struct gaim_gtk_window *gtkwin; |
| 4359 | 4252 | struct gaim_gtk_conversation *gtkconv; |
| 4253 | struct gaim_gtk_chat_pane *gtkchat; | |
| 4254 | struct gaim_chat *chat; | |
| 4255 | ||
| 4256 | win = gaim_conversation_get_window(conv); | |
| 4736 | 4257 | gtkwin = GAIM_GTK_WINDOW(win); |
| 4359 | 4258 | gtkconv = GAIM_GTK_CONVERSATION(conv); |
| 4259 | ||
| 4491 | 4260 | if (type == GAIM_CONV_UPDATE_ACCOUNT) { |
| 4359 | 4261 | gaim_conversation_autoset_title(conv); |
| 4262 | gaim_gtkconv_update_buddy_icon(conv); | |
| 4263 | gaim_gtkconv_update_buttons_by_protocol(conv); | |
| 4264 | ||
| 4685 | 4265 | g_timeout_add(0, (GSourceFunc)update_send_as_selection, win); |
| 4359 | 4266 | |
| 4267 | smiley_themeize(gtkconv->imhtml); | |
| 4268 | } | |
| 4269 | else if (type == GAIM_CONV_UPDATE_TYPING || | |
| 4270 | type == GAIM_CONV_UPDATE_UNSEEN) { | |
| 4271 | GtkStyle *style; | |
| 4272 | struct gaim_im *im = NULL; | |
| 4273 | ||
| 4736 | 4274 | |
| 4359 | 4275 | if (gaim_conversation_get_type(conv) == GAIM_CONV_IM) |
| 4276 | im = GAIM_IM(conv); | |
| 4277 | ||
| 4278 | style = gtk_style_new(); | |
| 4279 | ||
| 4280 | if (!GTK_WIDGET_REALIZED(gtkconv->tab_label)) | |
| 4281 | gtk_widget_realize(gtkconv->tab_label); | |
| 4282 | ||
| 4757 | 4283 | pango_font_description_free(style->font_desc); |
| 4635 | 4284 | style->font_desc = pango_font_description_copy( |
| 4285 | gtk_widget_get_style(gtkconv->tab_label)->font_desc); | |
| 4359 | 4286 | |
| 4287 | if (im != NULL && gaim_im_get_typing_state(im) == TYPING) { | |
| 4577 | 4288 | style->fg[GTK_STATE_NORMAL].red = 0x4646; |
| 4289 | style->fg[GTK_STATE_NORMAL].green = 0xA0A0; | |
| 4290 | style->fg[GTK_STATE_NORMAL].blue = 0x4646; | |
| 4291 | style->fg[GTK_STATE_ACTIVE] = style->fg[GTK_STATE_NORMAL]; | |
| 4359 | 4292 | } |
| 4293 | else if (im != NULL && gaim_im_get_typing_state(im) == TYPED) { | |
| 4577 | 4294 | style->fg[GTK_STATE_NORMAL].red = 0xD1D1; |
| 4295 | style->fg[GTK_STATE_NORMAL].green = 0x9494; | |
| 4296 | style->fg[GTK_STATE_NORMAL].blue = 0x0C0C; | |
| 4297 | style->fg[GTK_STATE_ACTIVE] = style->fg[GTK_STATE_NORMAL]; | |
| 4359 | 4298 | } |
| 4299 | else if (gaim_conversation_get_unseen(conv) == GAIM_UNSEEN_NICK) { | |
| 4577 | 4300 | style->fg[GTK_STATE_ACTIVE].red = 0x3131; |
| 4301 | style->fg[GTK_STATE_ACTIVE].green = 0x4E4E; | |
| 4302 | style->fg[GTK_STATE_ACTIVE].blue = 0x6C6C; | |
| 4578 | 4303 | style->fg[GTK_STATE_NORMAL] = style->fg[GTK_STATE_ACTIVE]; |
| 4359 | 4304 | } |
| 4305 | else if (gaim_conversation_get_unseen(conv) == GAIM_UNSEEN_TEXT) { | |
| 4577 | 4306 | style->fg[GTK_STATE_ACTIVE].red = 0xDFDF; |
| 4307 | style->fg[GTK_STATE_ACTIVE].green = 0x4242; | |
| 4308 | style->fg[GTK_STATE_ACTIVE].blue = 0x1E1E; | |
| 4578 | 4309 | style->fg[GTK_STATE_NORMAL] = style->fg[GTK_STATE_ACTIVE]; |
| 4359 | 4310 | } |
| 4311 | ||
| 4312 | gtk_widget_set_style(gtkconv->tab_label, style); | |
| 4635 | 4313 | g_object_unref(G_OBJECT(style)); |
| 4736 | 4314 | |
| 4315 | if(type == GAIM_CONV_UPDATE_TYPING && | |
| 4316 | conv == gaim_window_get_active_conversation(win)) { | |
| 4317 | update_typing_icon(conv); | |
| 4318 | } | |
| 4319 | ||
| 4359 | 4320 | } |
| 4321 | else if (type == GAIM_CONV_UPDATE_TOPIC) { | |
| 4322 | chat = GAIM_CHAT(conv); | |
| 4323 | gtkchat = gtkconv->u.chat; | |
| 4324 | ||
| 4325 | gtk_entry_set_text(GTK_ENTRY(gtkchat->topic_text), | |
| 4326 | gaim_chat_get_topic(chat)); | |
| 4327 | } | |
| 4328 | else if (type == GAIM_CONV_ACCOUNT_ONLINE || | |
| 4329 | type == GAIM_CONV_ACCOUNT_OFFLINE) { | |
| 4330 | ||
|
4360
28aa945b7c16
[gaim-migrate @ 4626]
Christian Hammond <chipx86@chipx86.com>
parents:
4359
diff
changeset
|
4331 | generate_send_as_items(win, NULL); |
| 4359 | 4332 | } |
| 4397 | 4333 | else if(type == GAIM_CONV_UPDATE_ADD || |
| 4334 | type == GAIM_CONV_UPDATE_REMOVE) { | |
| 4736 | 4335 | |
| 4397 | 4336 | update_convo_add_button(conv); |
| 4337 | } | |
| 4359 | 4338 | } |
| 4339 | ||
|
4465
43184ae252ed
[gaim-migrate @ 4740]
Christian Hammond <chipx86@chipx86.com>
parents:
4454
diff
changeset
|
4340 | static struct gaim_conversation_ui_ops conversation_ui_ops = |
| 4359 | 4341 | { |
| 4342 | gaim_gtkconv_destroy, /* destroy_conversation */ | |
| 4343 | gaim_gtkconv_write_chat, /* write_chat */ | |
| 4344 | gaim_gtkconv_write_im, /* write_im */ | |
| 4345 | gaim_gtkconv_write_conv, /* write_conv */ | |
| 4346 | gaim_gtkconv_chat_add_user, /* chat_add_user */ | |
| 4347 | gaim_gtkconv_chat_rename_user, /* chat_rename_user */ | |
| 4348 | gaim_gtkconv_chat_remove_user, /* chat_remove_user */ | |
| 4349 | gaim_gtkconv_set_title, /* set_title */ | |
| 4350 | NULL, /* update_progress */ | |
| 4351 | gaim_gtkconv_updated /* updated */ | |
| 4352 | }; | |
| 4353 | ||
|
4465
43184ae252ed
[gaim-migrate @ 4740]
Christian Hammond <chipx86@chipx86.com>
parents:
4454
diff
changeset
|
4354 | struct gaim_conversation_ui_ops * |
|
43184ae252ed
[gaim-migrate @ 4740]
Christian Hammond <chipx86@chipx86.com>
parents:
4454
diff
changeset
|
4355 | gaim_get_gtk_conversation_ui_ops(void) |
| 4359 | 4356 | { |
|
4465
43184ae252ed
[gaim-migrate @ 4740]
Christian Hammond <chipx86@chipx86.com>
parents:
4454
diff
changeset
|
4357 | return &conversation_ui_ops; |
| 4359 | 4358 | } |
| 4359 | ||
| 4360 | /************************************************************************** | |
| 4361 | * Public conversation utility functions | |
| 4362 | **************************************************************************/ | |
| 4363 | void | |
| 4364 | gaim_gtkconv_toggle_smileys(void) | |
| 4365 | { | |
| 4366 | GList *cl; | |
| 4367 | struct gaim_conversation *conv; | |
| 4368 | struct gaim_gtk_conversation *gtkconv; | |
| 4369 | ||
| 4370 | for (cl = gaim_get_conversations(); cl != NULL; cl = cl->next) { | |
| 4371 | ||
| 4372 | conv = (struct gaim_conversation *)cl->data; | |
| 4373 | ||
|
4398
ba901bb913e5
[gaim-migrate @ 4667]
Christian Hammond <chipx86@chipx86.com>
parents:
4397
diff
changeset
|
4374 | if (!GAIM_IS_GTK_CONVERSATION(conv)) |
| 4359 | 4375 | continue; |
| 4376 | ||
| 4377 | gtkconv = GAIM_GTK_CONVERSATION(conv); | |
| 4378 | ||
| 4379 | gtk_imhtml_show_smileys(GTK_IMHTML(gtkconv->imhtml), | |
| 4380 | (convo_options & OPT_CONVO_SHOW_SMILEY)); | |
| 4381 | } | |
| 4382 | } | |
| 4383 | ||
| 4384 | void | |
| 4385 | gaim_gtkconv_toggle_timestamps(void) | |
| 4386 | { | |
| 4387 | GList *cl; | |
| 4388 | struct gaim_conversation *conv; | |
| 4389 | struct gaim_gtk_conversation *gtkconv; | |
| 4390 | ||
| 4391 | for (cl = gaim_get_conversations(); cl != NULL; cl = cl->next) { | |
| 4392 | ||
| 4393 | conv = (struct gaim_conversation *)cl->data; | |
| 4394 | ||
|
4398
ba901bb913e5
[gaim-migrate @ 4667]
Christian Hammond <chipx86@chipx86.com>
parents:
4397
diff
changeset
|
4395 | if (!GAIM_IS_GTK_CONVERSATION(conv)) |
| 4359 | 4396 | continue; |
| 4397 | ||
| 4398 | gtkconv = GAIM_GTK_CONVERSATION(conv); | |
| 4399 | ||
| 4400 | gtk_imhtml_show_comments(GTK_IMHTML(gtkconv->imhtml), | |
| 4401 | (convo_options & OPT_CONVO_SHOW_TIME)); | |
| 4402 | } | |
| 4403 | } | |
| 4404 | ||
| 4405 | void | |
| 4406 | gaim_gtkconv_toggle_spellchk(void) | |
| 4407 | { | |
| 4408 | #ifdef USE_GTKSPELL | |
| 4409 | GList *cl; | |
| 4410 | struct gaim_conversation *conv; | |
| 4411 | struct gaim_gtk_conversation *gtkconv; | |
| 4412 | GtkSpell *spell; | |
| 4413 | ||
| 4414 | for (cl = gaim_get_conversations(); cl != NULL; cl = cl->next) { | |
| 4415 | ||
| 4416 | conv = (struct gaim_conversation *)cl->data; | |
| 4417 | ||
|
4398
ba901bb913e5
[gaim-migrate @ 4667]
Christian Hammond <chipx86@chipx86.com>
parents:
4397
diff
changeset
|
4418 | if (!GAIM_IS_GTK_CONVERSATION(conv)) |
| 4359 | 4419 | continue; |
| 4420 | ||
| 4421 | gtkconv = GAIM_GTK_CONVERSATION(conv); | |
| 4422 | ||
| 4423 | if (convo_options & OPT_CONVO_CHECK_SPELLING) | |
| 4424 | gtkspell_new_attach(GTK_TEXT_VIEW(gtkconv->entry), NULL, NULL); | |
| 4425 | else { | |
| 4426 | spell = gtkspell_get_from_text_view(GTK_TEXT_VIEW(gtkconv->entry)); | |
| 4427 | gtkspell_detach(spell); | |
| 4428 | } | |
| 4429 | } | |
| 4430 | #endif | |
| 4431 | } | |
| 4432 | ||
| 4445 | 4433 | void |
| 4434 | gaim_gtkconv_toggle_close_buttons(void) | |
| 4435 | { | |
| 4436 | GList *cl; | |
| 4437 | struct gaim_conversation *conv; | |
| 4438 | struct gaim_gtk_conversation *gtkconv; | |
| 4439 | ||
| 4440 | for (cl = gaim_get_conversations(); cl != NULL; cl = cl->next) { | |
| 4441 | conv = (struct gaim_conversation *)cl->data; | |
| 4442 | if (!GAIM_IS_GTK_CONVERSATION(conv)) | |
| 4443 | continue; | |
| 4444 | ||
| 4445 | gtkconv = GAIM_GTK_CONVERSATION(conv); | |
| 4446 | ||
| 4447 | if (convo_options & OPT_CONVO_NO_X_ON_TAB) | |
| 4448 | gtk_widget_hide(gtkconv->close); | |
| 4449 | else | |
| 4450 | gtk_widget_show_all(gtkconv->close); | |
| 4451 | } | |
| 4452 | } | |
| 4453 | ||
| 4359 | 4454 | static void |
| 4455 | remove_icon(struct gaim_gtk_conversation *gtkconv) | |
| 4456 | { | |
| 4457 | if (gtkconv == NULL) | |
| 4458 | return; | |
| 4459 | ||
| 4460 | if (gtkconv->u.im->icon != NULL) | |
| 4461 | gtk_container_remove(GTK_CONTAINER(gtkconv->bbox), | |
| 4462 | gtkconv->u.im->icon->parent->parent); | |
| 4463 | ||
| 4464 | if (gtkconv->u.im->anim != NULL) | |
| 4465 | gdk_pixbuf_animation_unref(gtkconv->u.im->anim); | |
| 4466 | ||
| 4467 | if (gtkconv->u.im->icon_timer != 0) | |
| 4468 | g_source_remove(gtkconv->u.im->icon_timer); | |
| 4469 | ||
| 4470 | if (gtkconv->u.im->iter != NULL) | |
| 4471 | g_object_unref(G_OBJECT(gtkconv->u.im->iter)); | |
| 4472 | ||
| 4473 | gtkconv->u.im->icon_timer = 0; | |
| 4474 | gtkconv->u.im->icon = NULL; | |
| 4475 | gtkconv->u.im->anim = NULL; | |
| 4476 | gtkconv->u.im->iter = NULL; | |
| 4477 | } | |
| 4478 | ||
| 4479 | static gboolean | |
| 4480 | redraw_icon(gpointer data) | |
| 4481 | { | |
| 4482 | struct gaim_conversation *conv = (struct gaim_conversation *)data; | |
| 4483 | struct gaim_gtk_conversation *gtkconv; | |
| 4484 | ||
| 4485 | GdkPixbuf *buf; | |
| 4486 | GdkPixbuf *scale; | |
| 4487 | GdkPixmap *pm; | |
| 4488 | GdkBitmap *bm; | |
| 4489 | gint delay; | |
| 4490 | ||
| 4491 | if (!g_list_find(gaim_get_ims(), conv)) { | |
| 4492 | debug_printf("I think this is a bug.\n"); | |
| 4493 | return FALSE; | |
| 4494 | } | |
| 4495 | ||
| 4496 | gtkconv = GAIM_GTK_CONVERSATION(conv); | |
| 4497 | ||
| 4498 | gdk_pixbuf_animation_iter_advance(gtkconv->u.im->iter, NULL); | |
| 4499 | buf = gdk_pixbuf_animation_iter_get_pixbuf(gtkconv->u.im->iter); | |
| 4500 | ||
| 4501 | scale = gdk_pixbuf_scale_simple(buf, | |
| 4502 | MAX(gdk_pixbuf_get_width(buf) * SCALE(gtkconv->u.im->anim) / | |
| 4503 | gdk_pixbuf_animation_get_width(gtkconv->u.im->anim), 1), | |
| 4504 | MAX(gdk_pixbuf_get_height(buf) * SCALE(gtkconv->u.im->anim) / | |
| 4505 | gdk_pixbuf_animation_get_height(gtkconv->u.im->anim), 1), | |
| 4506 | GDK_INTERP_NEAREST); | |
| 4507 | ||
| 4508 | gdk_pixbuf_render_pixmap_and_mask(scale, &pm, &bm, 100); | |
| 4509 | gdk_pixbuf_unref(scale); | |
| 4635 | 4510 | gtk_image_set_from_pixmap(GTK_IMAGE(gtkconv->u.im->icon), pm, bm); |
| 4359 | 4511 | gdk_pixmap_unref(pm); |
| 4512 | gtk_widget_queue_draw(gtkconv->u.im->icon); | |
| 4513 | ||
| 4514 | if (bm) | |
| 4515 | gdk_bitmap_unref(bm); | |
| 4516 | ||
| 4517 | delay = gdk_pixbuf_animation_iter_get_delay_time(gtkconv->u.im->iter) / 10; | |
| 4518 | ||
| 4519 | gtkconv->u.im->icon_timer = g_timeout_add(delay * 10, redraw_icon, conv); | |
| 4520 | ||
| 4521 | return FALSE; | |
| 4522 | } | |
| 4523 | ||
| 4524 | static void | |
| 4525 | start_anim(GtkObject *obj, struct gaim_conversation *conv) | |
| 4526 | { | |
| 4527 | struct gaim_gtk_conversation *gtkconv; | |
| 4528 | int delay; | |
| 4529 | ||
|
4398
ba901bb913e5
[gaim-migrate @ 4667]
Christian Hammond <chipx86@chipx86.com>
parents:
4397
diff
changeset
|
4530 | if (!GAIM_IS_GTK_CONVERSATION(conv)) |
| 4359 | 4531 | return; |
| 4532 | ||
| 4533 | gtkconv = GAIM_GTK_CONVERSATION(conv); | |
| 4534 | ||
| 4535 | delay = gdk_pixbuf_animation_iter_get_delay_time(gtkconv->u.im->iter) / 10; | |
| 4536 | ||
| 4537 | if (gtkconv->u.im->anim) | |
| 4538 | gtkconv->u.im->icon_timer = g_timeout_add(delay * 10, redraw_icon, | |
| 4539 | conv); | |
| 4540 | } | |
| 4541 | ||
| 4542 | static void | |
| 4543 | stop_anim(GtkObject *obj, struct gaim_conversation *conv) | |
| 4544 | { | |
| 4545 | struct gaim_gtk_conversation *gtkconv; | |
| 4546 | ||
|
4398
ba901bb913e5
[gaim-migrate @ 4667]
Christian Hammond <chipx86@chipx86.com>
parents:
4397
diff
changeset
|
4547 | if (!GAIM_IS_GTK_CONVERSATION(conv)) |
| 4359 | 4548 | return; |
| 4549 | ||
| 4550 | gtkconv = GAIM_GTK_CONVERSATION(conv); | |
| 4551 | ||
| 4552 | if (gtkconv->u.im->icon_timer != 0) | |
| 4553 | g_source_remove(gtkconv->u.im->icon_timer); | |
| 4554 | ||
| 4555 | gtkconv->u.im->icon_timer = 0; | |
| 4556 | } | |
| 4557 | ||
| 4558 | static gboolean | |
| 4559 | icon_menu(GtkObject *obj, GdkEventButton *e, struct gaim_conversation *conv) | |
| 4560 | { | |
| 4561 | struct gaim_gtk_conversation *gtkconv; | |
| 4562 | static GtkWidget *menu = NULL; | |
| 4563 | GtkWidget *button; | |
| 4564 | ||
| 4565 | if (e->button != 3 || e->type != GDK_BUTTON_PRESS) | |
| 4566 | return FALSE; | |
| 4567 | ||
| 4568 | gtkconv = GAIM_GTK_CONVERSATION(conv); | |
| 4569 | ||
| 4570 | /* | |
| 4571 | * If a menu already exists, destroy it before creating a new one, | |
| 4572 | * thus freeing-up the memory it occupied. | |
| 4573 | */ | |
| 4574 | if (menu != NULL) | |
| 4575 | gtk_widget_destroy(menu); | |
| 4576 | ||
| 4577 | menu = gtk_menu_new(); | |
| 4578 | ||
| 4579 | if (gtkconv->u.im->icon_timer) { | |
| 4580 | button = gtk_menu_item_new_with_label(_("Disable Animation")); | |
| 4581 | g_signal_connect(GTK_OBJECT(button), "activate", | |
| 4582 | G_CALLBACK(stop_anim), conv); | |
| 4583 | gtk_menu_shell_append(GTK_MENU_SHELL(menu), button); | |
| 4584 | gtk_widget_show(button); | |
| 4585 | } | |
| 4586 | else if (gtkconv->u.im->anim && | |
| 4587 | !(gdk_pixbuf_animation_is_static_image(gtkconv->u.im->anim))) | |
| 4588 | { | |
| 4589 | button = gtk_menu_item_new_with_label(_("Enable Animation")); | |
| 4590 | g_signal_connect(GTK_OBJECT(button), "activate", | |
| 4591 | G_CALLBACK(start_anim), conv); | |
| 4592 | gtk_menu_shell_append(GTK_MENU_SHELL(menu), button); | |
| 4593 | gtk_widget_show(button); | |
| 4594 | } | |
| 4595 | ||
| 4596 | button = gtk_menu_item_new_with_label(_("Hide Icon")); | |
| 4597 | g_signal_connect_swapped(GTK_OBJECT(button), "activate", | |
|
4515
646a4904ad32
[gaim-migrate @ 4793]
Christian Hammond <chipx86@chipx86.com>
parents:
4513
diff
changeset
|
4598 | G_CALLBACK(remove_icon), gtkconv); |
| 4359 | 4599 | gtk_menu_shell_append(GTK_MENU_SHELL(menu), button); |
| 4600 | gtk_widget_show(button); | |
| 4601 | ||
| 4602 | button = gtk_menu_item_new_with_label(_("Save Icon As...")); | |
| 4603 | g_signal_connect(GTK_OBJECT(button), "activate", | |
| 4604 | G_CALLBACK(gaim_gtk_save_icon_dialog), conv); | |
| 4605 | gtk_menu_shell_append(GTK_MENU_SHELL(menu), button); | |
| 4606 | gtk_widget_show(button); | |
| 4607 | ||
| 4608 | gtk_menu_popup(GTK_MENU(menu), NULL, NULL, NULL, NULL, e->button, e->time); | |
| 4609 | ||
| 4610 | return TRUE; | |
| 4611 | } | |
| 4612 | ||
| 4613 | void | |
| 4614 | gaim_gtkconv_update_buddy_icon(struct gaim_conversation *conv) | |
| 4615 | { | |
| 4616 | struct gaim_gtk_conversation *gtkconv; | |
| 4617 | ||
| 4618 | char filename[256]; | |
| 4619 | FILE *file; | |
| 4620 | GError *err = NULL; | |
| 4621 | ||
| 4757 | 4622 | struct buddy *buddy; |
| 4623 | ||
| 4359 | 4624 | void *data; |
| 4625 | int len, delay; | |
| 4626 | ||
| 4627 | GdkPixbuf *buf; | |
| 4628 | ||
| 4629 | GtkWidget *event; | |
| 4630 | GtkWidget *frame; | |
| 4631 | GdkPixbuf *scale; | |
| 4632 | GdkPixmap *pm; | |
| 4633 | GdkBitmap *bm; | |
| 4634 | int sf = 0; | |
| 4635 | ||
|
4398
ba901bb913e5
[gaim-migrate @ 4667]
Christian Hammond <chipx86@chipx86.com>
parents:
4397
diff
changeset
|
4636 | if (conv == NULL || !GAIM_IS_GTK_CONVERSATION(conv) || |
| 4359 | 4637 | gaim_conversation_get_type(conv) != GAIM_CONV_IM) { |
| 4638 | ||
| 4639 | return; | |
| 4640 | } | |
| 4641 | ||
| 4642 | gtkconv = GAIM_GTK_CONVERSATION(conv); | |
| 4643 | ||
| 4644 | remove_icon(gtkconv); | |
| 4645 | ||
| 4646 | if (im_options & OPT_IM_HIDE_ICONS) | |
| 4647 | return; | |
| 4648 | ||
| 4649 | if (gaim_conversation_get_gc(conv) == NULL) | |
| 4650 | return; | |
| 4651 | ||
| 4757 | 4652 | if((buddy = gaim_find_buddy(gaim_conversation_get_account(conv), |
| 4653 | gaim_conversation_get_name(conv))) != NULL) { | |
| 4654 | char *file = gaim_buddy_get_setting(buddy, "buddy_icon"); | |
| 4655 | if(file) { | |
| 4656 | gtkconv->u.im->anim = gdk_pixbuf_animation_new_from_file(file, &err); | |
| 4657 | g_free(file); | |
| 4658 | } | |
| 4659 | } else { | |
| 4660 | data = get_icon_data(gaim_conversation_get_gc(conv), | |
| 4661 | normalize(gaim_conversation_get_name(conv)), | |
| 4662 | &len); | |
| 4663 | ||
| 4664 | if (!data) | |
| 4665 | return; | |
| 4666 | ||
| 4667 | /* this is such an evil hack, i don't know why i'm even considering it. | |
| 4668 | * we'll do it differently when gdk-pixbuf-loader isn't leaky anymore. */ | |
| 4669 | g_snprintf(filename, sizeof(filename), | |
| 4670 | "%s" G_DIR_SEPARATOR_S "gaimicon-%s.%d", | |
| 4671 | g_get_tmp_dir(), gaim_conversation_get_name(conv), getpid()); | |
| 4672 | ||
| 4673 | if (!(file = fopen(filename, "wb"))) | |
| 4674 | return; | |
| 4675 | ||
| 4676 | fwrite(data, 1, len, file); | |
| 4677 | fclose(file); | |
| 4678 | ||
| 4679 | gtkconv->u.im->anim = gdk_pixbuf_animation_new_from_file(filename, &err); | |
| 4680 | /* make sure we remove the file as soon as possible */ | |
| 4681 | unlink(filename); | |
| 4682 | } | |
| 4359 | 4683 | |
| 4684 | if (err) { | |
| 4685 | debug_printf("Buddy icon error: %s\n", err->message); | |
| 4686 | g_error_free(err); | |
| 4687 | } | |
| 4688 | ||
| 4689 | ||
| 4690 | if (!gtkconv->u.im->anim) | |
| 4691 | return; | |
| 4692 | ||
| 4693 | if (gdk_pixbuf_animation_is_static_image(gtkconv->u.im->anim)) { | |
| 4694 | gtkconv->u.im->iter = NULL; | |
| 4695 | delay = 0; | |
| 4696 | buf = gdk_pixbuf_animation_get_static_image(gtkconv->u.im->anim); | |
| 4697 | } else { | |
| 4698 | gtkconv->u.im->iter = | |
| 4699 | gdk_pixbuf_animation_get_iter(gtkconv->u.im->anim, NULL); | |
| 4700 | buf = gdk_pixbuf_animation_iter_get_pixbuf(gtkconv->u.im->iter); | |
| 4701 | delay = gdk_pixbuf_animation_iter_get_delay_time(gtkconv->u.im->iter); | |
| 4702 | delay = delay / 10; | |
| 4703 | } | |
| 4704 | ||
| 4705 | sf = SCALE(gtkconv->u.im->anim); | |
| 4706 | scale = gdk_pixbuf_scale_simple(buf, | |
| 4707 | MAX(gdk_pixbuf_get_width(buf) * sf / | |
| 4708 | gdk_pixbuf_animation_get_width(gtkconv->u.im->anim), 1), | |
| 4709 | MAX(gdk_pixbuf_get_height(buf) * sf / | |
| 4710 | gdk_pixbuf_animation_get_height(gtkconv->u.im->anim), 1), | |
| 4711 | GDK_INTERP_NEAREST); | |
| 4712 | ||
| 4713 | if (delay) | |
| 4714 | gtkconv->u.im->icon_timer = g_timeout_add(delay * 10, redraw_icon, | |
| 4715 | conv); | |
| 4716 | ||
| 4717 | gdk_pixbuf_render_pixmap_and_mask(scale, &pm, &bm, 100); | |
| 4718 | gdk_pixbuf_unref(scale); | |
| 4719 | ||
| 4720 | frame = gtk_frame_new(NULL); | |
| 4721 | gtk_frame_set_shadow_type(GTK_FRAME(frame), | |
| 4722 | (bm ? GTK_SHADOW_NONE : GTK_SHADOW_IN)); | |
| 4723 | gtk_box_pack_start(GTK_BOX(gtkconv->bbox), frame, FALSE, FALSE, 5); | |
| 4724 | gtk_box_reorder_child(GTK_BOX(gtkconv->bbox), frame, 0); | |
| 4725 | gtk_widget_show(frame); | |
| 4726 | ||
| 4727 | event = gtk_event_box_new(); | |
| 4728 | gtk_container_add(GTK_CONTAINER(frame), event); | |
| 4729 | g_signal_connect(GTK_OBJECT(event), "button-press-event", | |
| 4730 | G_CALLBACK(icon_menu), conv); | |
| 4731 | gtk_widget_show(event); | |
| 4732 | ||
| 4635 | 4733 | gtkconv->u.im->icon = gtk_image_new_from_pixmap(pm, bm); |
| 4359 | 4734 | gtk_widget_set_size_request(gtkconv->u.im->icon, sf, sf); |
| 4735 | gtk_container_add(GTK_CONTAINER(event), gtkconv->u.im->icon); | |
| 4736 | gtk_widget_show(gtkconv->u.im->icon); | |
| 4737 | ||
| 4738 | if(im_options & OPT_IM_NO_ANIMATION) | |
| 4739 | stop_anim(NULL, conv); | |
| 4740 | ||
| 4741 | gdk_pixmap_unref(pm); | |
| 4742 | ||
| 4743 | if (bm) | |
| 4744 | gdk_bitmap_unref(bm); | |
| 4745 | } | |
| 4746 | ||
| 4747 | void | |
| 4748 | gaim_gtkconv_hide_buddy_icons(void) | |
| 4749 | { | |
| 4750 | gaim_conversation_foreach(gaim_gtkconv_update_buddy_icon); | |
| 4751 | } | |
| 4752 | ||
| 4753 | void | |
| 4754 | gaim_gtkconv_set_anim(void) | |
| 4755 | { | |
| 4756 | GList *l; | |
| 4757 | ||
| 4758 | if (im_options & OPT_IM_HIDE_ICONS) | |
| 4759 | return; | |
| 4760 | ||
| 4761 | if (im_options & OPT_IM_NO_ANIMATION) { | |
| 4762 | for (l = gaim_get_ims(); l != NULL; l = l->next) | |
| 4763 | stop_anim(NULL, (struct gaim_conversation *)l->data); | |
| 4764 | } else { | |
| 4765 | for (l = gaim_get_ims(); l != NULL; l = l->next) | |
| 4766 | start_anim(NULL, (struct gaim_conversation *)l->data); | |
| 4767 | } | |
| 4768 | } | |
| 4769 | ||
| 4770 | void | |
| 4771 | gaim_gtkconv_update_font_buttons(void) | |
| 4772 | { | |
| 4773 | GList *l; | |
| 4774 | struct gaim_conversation *conv; | |
| 4775 | struct gaim_gtk_conversation *gtkconv; | |
| 4776 | ||
| 4777 | for (l = gaim_get_ims(); l != NULL; l = l->next) { | |
| 4778 | conv = (struct gaim_conversation *)l->data; | |
| 4779 | ||
|
4398
ba901bb913e5
[gaim-migrate @ 4667]
Christian Hammond <chipx86@chipx86.com>
parents:
4397
diff
changeset
|
4780 | if (!GAIM_IS_GTK_CONVERSATION(conv)) |
| 4359 | 4781 | continue; |
| 4782 | ||
| 4783 | gtkconv = GAIM_GTK_CONVERSATION(conv); | |
| 4784 | ||
| 4785 | if (gtkconv->toolbar.bold != NULL) | |
| 4786 | gtk_widget_set_sensitive(gtkconv->toolbar.bold, | |
| 4787 | (!(font_options & OPT_FONT_BOLD))); | |
| 4788 | ||
| 4789 | if (gtkconv->toolbar.italic != NULL) | |
| 4790 | gtk_widget_set_sensitive(gtkconv->toolbar.italic, | |
| 4791 | (!(font_options & OPT_FONT_ITALIC))); | |
| 4792 | ||
| 4793 | if (gtkconv->toolbar.underline != NULL) | |
| 4794 | gtk_widget_set_sensitive(gtkconv->toolbar.underline, | |
| 4795 | (!(font_options & OPT_FONT_UNDERLINE))); | |
| 4796 | } | |
| 4797 | } | |
| 4798 | ||
| 4799 | void | |
| 4421 | 4800 | gaim_gtkconv_update_font_colors(struct gaim_conversation *conv) |
| 4801 | { | |
|
4438
9beaf48335fc
[gaim-migrate @ 4713]
Christian Hammond <chipx86@chipx86.com>
parents:
4421
diff
changeset
|
4802 | struct gaim_gtk_conversation *gtkconv; |
|
9beaf48335fc
[gaim-migrate @ 4713]
Christian Hammond <chipx86@chipx86.com>
parents:
4421
diff
changeset
|
4803 | |
|
9beaf48335fc
[gaim-migrate @ 4713]
Christian Hammond <chipx86@chipx86.com>
parents:
4421
diff
changeset
|
4804 | if (!GAIM_IS_GTK_CONVERSATION(conv)) |
|
9beaf48335fc
[gaim-migrate @ 4713]
Christian Hammond <chipx86@chipx86.com>
parents:
4421
diff
changeset
|
4805 | return; |
|
9beaf48335fc
[gaim-migrate @ 4713]
Christian Hammond <chipx86@chipx86.com>
parents:
4421
diff
changeset
|
4806 | |
|
9beaf48335fc
[gaim-migrate @ 4713]
Christian Hammond <chipx86@chipx86.com>
parents:
4421
diff
changeset
|
4807 | gtkconv = GAIM_GTK_CONVERSATION(conv); |
| 4421 | 4808 | |
|
4438
9beaf48335fc
[gaim-migrate @ 4713]
Christian Hammond <chipx86@chipx86.com>
parents:
4421
diff
changeset
|
4809 | gtkconv->fg_color.red = fgcolor.red; |
|
9beaf48335fc
[gaim-migrate @ 4713]
Christian Hammond <chipx86@chipx86.com>
parents:
4421
diff
changeset
|
4810 | gtkconv->fg_color.blue = fgcolor.blue; |
|
9beaf48335fc
[gaim-migrate @ 4713]
Christian Hammond <chipx86@chipx86.com>
parents:
4421
diff
changeset
|
4811 | gtkconv->fg_color.green = fgcolor.green; |
|
9beaf48335fc
[gaim-migrate @ 4713]
Christian Hammond <chipx86@chipx86.com>
parents:
4421
diff
changeset
|
4812 | |
|
9beaf48335fc
[gaim-migrate @ 4713]
Christian Hammond <chipx86@chipx86.com>
parents:
4421
diff
changeset
|
4813 | gtkconv->bg_color.red = bgcolor.red; |
|
9beaf48335fc
[gaim-migrate @ 4713]
Christian Hammond <chipx86@chipx86.com>
parents:
4421
diff
changeset
|
4814 | gtkconv->bg_color.blue = bgcolor.blue; |
|
9beaf48335fc
[gaim-migrate @ 4713]
Christian Hammond <chipx86@chipx86.com>
parents:
4421
diff
changeset
|
4815 | gtkconv->bg_color.green = bgcolor.green; |
|
9beaf48335fc
[gaim-migrate @ 4713]
Christian Hammond <chipx86@chipx86.com>
parents:
4421
diff
changeset
|
4816 | } |
|
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 | void |
|
9beaf48335fc
[gaim-migrate @ 4713]
Christian Hammond <chipx86@chipx86.com>
parents:
4421
diff
changeset
|
4819 | gaim_gtkconv_update_font_face(struct gaim_conversation *conv) |
|
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 | struct gaim_gtk_conversation *gtkconv; |
|
9beaf48335fc
[gaim-migrate @ 4713]
Christian Hammond <chipx86@chipx86.com>
parents:
4421
diff
changeset
|
4822 | |
|
9beaf48335fc
[gaim-migrate @ 4713]
Christian Hammond <chipx86@chipx86.com>
parents:
4421
diff
changeset
|
4823 | if (!GAIM_IS_GTK_CONVERSATION(conv)) |
|
9beaf48335fc
[gaim-migrate @ 4713]
Christian Hammond <chipx86@chipx86.com>
parents:
4421
diff
changeset
|
4824 | return; |
|
9beaf48335fc
[gaim-migrate @ 4713]
Christian Hammond <chipx86@chipx86.com>
parents:
4421
diff
changeset
|
4825 | |
|
9beaf48335fc
[gaim-migrate @ 4713]
Christian Hammond <chipx86@chipx86.com>
parents:
4421
diff
changeset
|
4826 | gtkconv = GAIM_GTK_CONVERSATION(conv); |
|
9beaf48335fc
[gaim-migrate @ 4713]
Christian Hammond <chipx86@chipx86.com>
parents:
4421
diff
changeset
|
4827 | |
|
9beaf48335fc
[gaim-migrate @ 4713]
Christian Hammond <chipx86@chipx86.com>
parents:
4421
diff
changeset
|
4828 | strncpy(gtkconv->fontface, fontface, 128); |
| 4421 | 4829 | } |
| 4830 | ||
| 4831 | void | |
| 4359 | 4832 | gaim_gtkconv_update_tabs(void) |
| 4833 | { | |
| 4834 | GList *l; | |
| 4835 | GtkPositionType pos; | |
| 4836 | struct gaim_window *win; | |
| 4837 | struct gaim_gtk_window *gtkwin; | |
| 4838 | ||
| 4839 | pos = ((im_options & OPT_IM_SIDE_TAB) | |
| 4840 | ? ((im_options & OPT_IM_BR_TAB) ? GTK_POS_RIGHT : GTK_POS_LEFT) | |
| 4841 | : ((im_options & OPT_IM_BR_TAB) ? GTK_POS_BOTTOM : GTK_POS_TOP)); | |
| 4842 | ||
| 4843 | for (l = gaim_get_windows(); l != NULL; l = l->next) { | |
| 4844 | win = (struct gaim_window *)l->data; | |
| 4845 | ||
|
4398
ba901bb913e5
[gaim-migrate @ 4667]
Christian Hammond <chipx86@chipx86.com>
parents:
4397
diff
changeset
|
4846 | if (!GAIM_IS_GTK_WINDOW(win)) |
| 4359 | 4847 | continue; |
| 4848 | ||
| 4849 | gtkwin = GAIM_GTK_WINDOW(win); | |
| 4850 | ||
| 4851 | gtk_notebook_set_tab_pos(GTK_NOTEBOOK(gtkwin->notebook), pos); | |
| 4852 | } | |
| 4853 | } | |
| 4854 | ||
| 4855 | void | |
| 4856 | gaim_gtkconv_update_chat_button_style() | |
| 4857 | { | |
| 4858 | GSList *l; | |
| 4859 | struct gaim_connection *g; | |
| 4860 | GtkWidget *parent; | |
| 4861 | GaimConversationType type = GAIM_CONV_CHAT; | |
| 4862 | ||
| 4863 | for (l = connections; l != NULL; l = l->next) { | |
| 4864 | GSList *bcs; | |
| 4865 | struct gaim_conversation *conv; | |
| 4866 | struct gaim_gtk_conversation *gtkconv; | |
| 4867 | struct gaim_gtk_window *gtkwin; | |
| 4868 | ||
| 4869 | g = (struct gaim_connection *)l->data; | |
| 4870 | ||
| 4871 | for (bcs = g->buddy_chats; bcs != NULL; bcs = bcs->next) { | |
| 4872 | conv = (struct gaim_conversation *)bcs->data; | |
| 4873 | ||
| 4874 | if (gaim_conversation_get_type(conv) != GAIM_CONV_CHAT) | |
| 4875 | continue; | |
| 4876 | ||
|
4398
ba901bb913e5
[gaim-migrate @ 4667]
Christian Hammond <chipx86@chipx86.com>
parents:
4397
diff
changeset
|
4877 | if (!GAIM_IS_GTK_CONVERSATION(conv)) |
| 4359 | 4878 | continue; |
| 4879 | ||
| 4880 | gtkconv = GAIM_GTK_CONVERSATION(conv); | |
| 4881 | gtkwin = GAIM_GTK_WINDOW(gaim_conversation_get_window(conv)); | |
| 4882 | parent = gtk_widget_get_parent(gtkconv->send); | |
| 4883 | ||
| 4884 | gtkconv->send = | |
| 4885 | gaim_gtk_change_text(_("Send"), | |
| 4886 | gtkconv->send, GAIM_STOCK_SEND, type); | |
| 4887 | gtkconv->u.chat->invite = | |
| 4888 | gaim_gtk_change_text(_("Invite"), | |
| 4889 | gtkconv->u.chat->invite, | |
| 4890 | GAIM_STOCK_INVITE, type); | |
| 4891 | ||
| 4892 | gtk_box_pack_end(GTK_BOX(parent), gtkconv->send, FALSE, FALSE, | |
| 4893 | type); | |
| 4894 | gtk_box_pack_end(GTK_BOX(parent), gtkconv->u.chat->invite, | |
| 4895 | FALSE, FALSE, 0); | |
| 4896 | ||
| 4897 | g_signal_connect(G_OBJECT(gtkconv->send), "clicked", | |
| 4898 | G_CALLBACK(send_cb), conv); | |
| 4899 | g_signal_connect(G_OBJECT(gtkconv->u.chat->invite), "clicked", | |
| 4900 | G_CALLBACK(invite_cb), conv); | |
| 4901 | ||
| 4902 | gtk_button_set_relief(GTK_BUTTON(gtkconv->send), | |
| 4903 | GTK_RELIEF_NONE); | |
| 4904 | gtk_button_set_relief(GTK_BUTTON(gtkconv->u.chat->invite), | |
| 4905 | GTK_RELIEF_NONE); | |
| 4906 | ||
| 4907 | gaim_gtkconv_update_buttons_by_protocol(conv); | |
| 4908 | } | |
| 4909 | } | |
| 4910 | } | |
| 4911 | ||
| 4912 | void | |
| 4913 | gaim_gtkconv_update_im_button_style() | |
| 4914 | { | |
| 4915 | GList *l; | |
| 4916 | struct gaim_conversation *conv; | |
| 4917 | struct gaim_gtk_conversation *gtkconv; | |
| 4918 | ||
| 4919 | for (l = gaim_get_ims(); l != NULL; l = l->next) { | |
| 4920 | conv = (struct gaim_conversation *)l->data; | |
| 4921 | gtkconv = GAIM_GTK_CONVERSATION(conv); | |
| 4922 | ||
| 4923 | setup_im_buttons(conv, gtk_widget_get_parent(gtkconv->send)); | |
| 4924 | } | |
| 4925 | } | |
| 4926 | ||
| 4927 | void | |
| 4928 | gaim_gtkconv_update_buttons_by_protocol(struct gaim_conversation *conv) | |
| 4929 | { | |
| 4930 | struct gaim_window *win; | |
| 4931 | struct gaim_gtk_window *gtkwin = NULL; | |
| 4932 | struct gaim_gtk_conversation *gtkconv; | |
| 4933 | struct gaim_connection *gc; | |
| 4934 | ||
|
4398
ba901bb913e5
[gaim-migrate @ 4667]
Christian Hammond <chipx86@chipx86.com>
parents:
4397
diff
changeset
|
4935 | if (!GAIM_IS_GTK_CONVERSATION(conv)) |
| 4359 | 4936 | return; |
| 4937 | ||
| 4938 | gc = gaim_conversation_get_gc(conv); | |
| 4939 | win = gaim_conversation_get_window(conv); | |
| 4940 | gtkconv = GAIM_GTK_CONVERSATION(conv); | |
| 4941 | ||
| 4942 | if (win != NULL) | |
| 4943 | gtkwin = GAIM_GTK_WINDOW(win); | |
| 4944 | ||
| 4945 | if (gc == NULL) { | |
| 4946 | gtk_widget_set_sensitive(gtkconv->send, FALSE); | |
| 4947 | ||
|
4365
3c55b884edef
[gaim-migrate @ 4631]
Christian Hammond <chipx86@chipx86.com>
parents:
4364
diff
changeset
|
4948 | if (win != NULL && gaim_window_get_active_conversation(win) == conv) { |
| 4359 | 4949 | gtk_widget_set_sensitive(gtkwin->menu.insert_link, FALSE); |
| 4950 | } | |
| 4951 | } | |
|
4364
b5e95f7f08c9
[gaim-migrate @ 4630]
Christian Hammond <chipx86@chipx86.com>
parents:
4363
diff
changeset
|
4952 | else { |
| 4674 | 4953 | gtk_widget_set_sensitive(gtkconv->send, TRUE); |
|
4365
3c55b884edef
[gaim-migrate @ 4631]
Christian Hammond <chipx86@chipx86.com>
parents:
4364
diff
changeset
|
4954 | if (win != NULL) { |
|
3c55b884edef
[gaim-migrate @ 4631]
Christian Hammond <chipx86@chipx86.com>
parents:
4364
diff
changeset
|
4955 | gtk_widget_set_sensitive(gtkwin->menu.insert_link, TRUE); |
|
3c55b884edef
[gaim-migrate @ 4631]
Christian Hammond <chipx86@chipx86.com>
parents:
4364
diff
changeset
|
4956 | } |
|
4364
b5e95f7f08c9
[gaim-migrate @ 4630]
Christian Hammond <chipx86@chipx86.com>
parents:
4363
diff
changeset
|
4957 | } |
| 4359 | 4958 | |
| 4959 | if (gaim_conversation_get_type(conv) == GAIM_CONV_IM) { | |
| 4960 | if (gc == NULL) { | |
| 4961 | gtk_widget_set_sensitive(gtkconv->info, FALSE); | |
| 4962 | gtk_widget_set_sensitive(gtkconv->u.im->warn, FALSE); | |
| 4963 | gtk_widget_set_sensitive(gtkconv->u.im->block, FALSE); | |
| 4964 | gtk_widget_set_sensitive(gtkconv->u.im->add, FALSE); | |
| 4965 | ||
| 4966 | if (win != NULL && | |
| 4967 | gaim_window_get_active_conversation(win) == conv) { | |
| 4968 | ||
| 4969 | gtk_widget_set_sensitive(gtkwin->menu.insert_image, FALSE); | |
| 4970 | } | |
| 4971 | ||
| 4972 | return; | |
| 4973 | } | |
| 4974 | ||
| 4975 | gtk_widget_set_sensitive(gtkconv->info, | |
| 4976 | (gc->prpl->get_info != NULL)); | |
| 4977 | ||
| 4978 | gtk_widget_set_sensitive(gtkconv->toolbar.image, | |
| 4979 | (gc->prpl->options & OPT_PROTO_IM_IMAGE)); | |
| 4980 | ||
| 4981 | if (win != NULL && gaim_window_get_active_conversation(win) == conv) { | |
| 4982 | gtk_widget_set_sensitive(gtkwin->menu.insert_image, | |
| 4983 | (gc->prpl->options & OPT_PROTO_IM_IMAGE)); | |
| 4984 | } | |
| 4985 | ||
| 4986 | gtk_widget_set_sensitive(gtkconv->u.im->warn, | |
| 4987 | (gc->prpl->warn != NULL)); | |
| 4988 | ||
| 4989 | gtk_widget_set_sensitive(gtkconv->u.im->block, | |
| 4990 | (gc->prpl->add_permit != NULL)); | |
| 4991 | ||
| 4992 | update_convo_add_button(conv); | |
| 4993 | } | |
| 4994 | else if (gaim_conversation_get_type(conv) == GAIM_CONV_CHAT) { | |
| 4995 | if (gc == NULL) { | |
| 4996 | gtk_widget_set_sensitive(gtkconv->u.chat->whisper, FALSE); | |
| 4997 | gtk_widget_set_sensitive(gtkconv->u.chat->invite, FALSE); | |
| 4998 | ||
| 4999 | return; | |
| 5000 | } | |
| 5001 | ||
| 5002 | gtk_widget_set_sensitive(gtkconv->send, (gc->prpl->chat_send != NULL)); | |
| 5003 | ||
| 5004 | gtk_widget_set_sensitive(gtkconv->toolbar.image, FALSE); | |
| 5005 | /* gtk_widget_set_sensitive(gtkwin->menu.insert_image, FALSE); */ | |
| 5006 | ||
| 5007 | gtk_widget_set_sensitive(gtkconv->u.chat->whisper, | |
| 5008 | (gc->prpl->chat_whisper != NULL)); | |
| 5009 | ||
| 5010 | gtk_widget_set_sensitive(gtkconv->u.chat->invite, | |
| 5011 | (gc->prpl->chat_invite != NULL)); | |
| 5012 | } | |
| 5013 | } | |
| 5014 | ||
| 5015 | struct gaim_window * | |
| 5016 | gaim_gtkwin_get_at_xy(int x, int y) | |
| 5017 | { | |
| 5018 | struct gaim_window *win = NULL; | |
| 5019 | struct gaim_gtk_window *gtkwin; | |
| 5020 | GdkWindow *gdkwin; | |
| 5021 | GList *l; | |
| 5022 | ||
| 5023 | gdkwin = gdk_window_at_pointer(&x, &y); | |
| 5024 | ||
| 5025 | if (gdkwin) | |
| 5026 | gdkwin = gdk_window_get_toplevel(gdkwin); | |
| 5027 | ||
| 5028 | for (l = gaim_get_windows(); l != NULL; l = l->next) { | |
| 5029 | win = (struct gaim_window *)l->data; | |
| 5030 | ||
|
4398
ba901bb913e5
[gaim-migrate @ 4667]
Christian Hammond <chipx86@chipx86.com>
parents:
4397
diff
changeset
|
5031 | if (!GAIM_IS_GTK_WINDOW(win)) |
| 4359 | 5032 | continue; |
| 5033 | ||
| 5034 | gtkwin = GAIM_GTK_WINDOW(win); | |
| 5035 | ||
| 5036 | if (gdkwin == gtkwin->window->window) | |
| 5037 | return win; | |
| 5038 | } | |
| 5039 | ||
| 5040 | return NULL; | |
| 5041 | } | |
| 5042 | ||
| 5043 | int | |
| 5044 | gaim_gtkconv_get_tab_at_xy(struct gaim_window *win, int x, int y) | |
| 5045 | { | |
| 5046 | struct gaim_gtk_window *gtkwin; | |
| 5047 | GList *l; | |
| 5048 | gint nb_x, nb_y, x_rel, y_rel; | |
| 5049 | GtkNotebook *notebook; | |
| 5050 | GtkWidget *tab; | |
| 5051 | gint i, page_num = 0; | |
| 5052 | gboolean first_visible = TRUE; | |
| 5053 | ||
|
4398
ba901bb913e5
[gaim-migrate @ 4667]
Christian Hammond <chipx86@chipx86.com>
parents:
4397
diff
changeset
|
5054 | if (!GAIM_IS_GTK_WINDOW(win)) |
| 4359 | 5055 | return -1; |
| 5056 | ||
| 5057 | gtkwin = GAIM_GTK_WINDOW(win); | |
| 5058 | notebook = GTK_NOTEBOOK(gtkwin->notebook); | |
| 5059 | ||
| 5060 | gdk_window_get_origin(gtkwin->notebook->window, &nb_x, &nb_y); | |
| 5061 | x_rel = x - nb_x; | |
| 5062 | y_rel = y - nb_y; | |
| 5063 | ||
| 5064 | for (l = gaim_window_get_conversations(win), i = 0; | |
| 5065 | l != NULL; | |
| 5066 | l = l->next, i++) { | |
| 5067 | ||
| 5068 | struct gaim_conversation *conv = l->data; | |
| 5069 | tab = GAIM_GTK_CONVERSATION(conv)->tab_label; | |
| 5070 | ||
| 5071 | if (!GTK_WIDGET_MAPPED(tab)) | |
| 5072 | continue; | |
| 5073 | ||
| 5074 | if (first_visible) { | |
| 5075 | first_visible = FALSE; | |
| 5076 | ||
| 5077 | if (x_rel < tab->allocation.x) x_rel = tab->allocation.x; | |
| 5078 | if (y_rel < tab->allocation.y) y_rel = tab->allocation.y; | |
| 5079 | } | |
| 5080 | ||
| 5081 | if (gtk_notebook_get_tab_pos(notebook) == GTK_POS_TOP || | |
| 5082 | gtk_notebook_get_tab_pos(notebook) == GTK_POS_BOTTOM) { | |
| 5083 | ||
| 5084 | if (tab->allocation.x <= x_rel) { | |
| 5085 | if (tab->allocation.x + tab->allocation.width <= x_rel) | |
| 5086 | page_num = i + 1; | |
| 5087 | else | |
| 5088 | page_num = i; | |
| 5089 | } | |
| 5090 | else | |
| 5091 | break; | |
| 5092 | } | |
| 5093 | else { | |
| 5094 | if (tab->allocation.y <= y_rel) { | |
| 5095 | if (tab->allocation.y + tab->allocation.height <= y_rel) | |
| 5096 | page_num = i + 1; | |
| 5097 | else | |
| 5098 | page_num = i; | |
| 5099 | } | |
| 5100 | else | |
| 5101 | break; | |
| 5102 | } | |
| 5103 | } | |
| 5104 | ||
| 5105 | if (i == gaim_window_get_conversation_count(win) + 1) | |
| 5106 | return -1; | |
| 5107 | ||
| 5108 | return page_num; | |
| 5109 | } | |
| 5110 | ||
| 5111 | int | |
| 5112 | gaim_gtkconv_get_dest_tab_at_xy(struct gaim_window *win, int x, int y) | |
| 5113 | { | |
| 5114 | struct gaim_gtk_window *gtkwin; | |
| 5115 | GList *l; | |
| 5116 | gint nb_x, nb_y, x_rel, y_rel; | |
| 5117 | GtkNotebook *notebook; | |
| 5118 | GtkWidget *tab; | |
| 5119 | gint i, page_num = 0; | |
| 5120 | ||
|
4398
ba901bb913e5
[gaim-migrate @ 4667]
Christian Hammond <chipx86@chipx86.com>
parents:
4397
diff
changeset
|
5121 | if (!GAIM_IS_GTK_WINDOW(win)) |
| 4359 | 5122 | return -1; |
| 5123 | ||
| 5124 | gtkwin = GAIM_GTK_WINDOW(win); | |
| 5125 | notebook = GTK_NOTEBOOK(gtkwin->notebook); | |
| 5126 | ||
| 5127 | gdk_window_get_origin(gtkwin->notebook->window, &nb_x, &nb_y); | |
| 5128 | x_rel = x - nb_x; | |
| 5129 | y_rel = y - nb_y; | |
| 5130 | ||
| 5131 | for (l = gaim_window_get_conversations(win), i = 0; | |
| 5132 | l != NULL; | |
| 5133 | l = l->next, i++) { | |
| 5134 | ||
| 5135 | struct gaim_conversation *conv = l->data; | |
| 5136 | tab = GAIM_GTK_CONVERSATION(conv)->tab_label; | |
| 5137 | ||
| 5138 | if (!GTK_WIDGET_MAPPED(tab)) | |
| 5139 | continue; | |
| 5140 | ||
| 5141 | if (gtk_notebook_get_tab_pos(notebook) == GTK_POS_TOP || | |
| 5142 | gtk_notebook_get_tab_pos(notebook) == GTK_POS_BOTTOM) { | |
| 5143 | ||
| 5144 | if (tab->allocation.x <= x_rel) { | |
| 5145 | if (tab->allocation.x + (tab->allocation.width / 2) <= x_rel) | |
| 5146 | page_num = i + 1; | |
| 5147 | else | |
| 5148 | page_num = i; | |
| 5149 | } | |
| 5150 | else | |
| 5151 | break; | |
| 5152 | } | |
| 5153 | else { | |
| 5154 | if (tab->allocation.y <= y_rel) { | |
| 5155 | if (tab->allocation.y + (tab->allocation.height / 2) <= y_rel) | |
| 5156 | page_num = i + 1; | |
| 5157 | else | |
| 5158 | page_num = i; | |
| 5159 | } | |
| 5160 | else | |
| 5161 | break; | |
| 5162 | } | |
| 5163 | } | |
| 5164 | ||
| 5165 | if (i == gaim_window_get_conversation_count(win) + 1) | |
| 5166 | return -1; | |
| 5167 | ||
| 5168 | return page_num; | |
| 5169 | } |