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