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