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