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