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