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