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