| 1 /* |
|
| 2 * gaim |
|
| 3 * |
|
| 4 * Copyright (C) 1998-1999, Mark Spencer <markster@marko.net> |
|
| 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 |
|
| 22 #include <string.h> |
|
| 23 #include <sys/time.h> |
|
| 24 #include <sys/types.h> |
|
| 25 #include <sys/stat.h> |
|
| 26 #include <unistd.h> |
|
| 27 #include <stdio.h> |
|
| 28 #include <stdlib.h> |
|
| 29 #include <gtk/gtk.h> |
|
| 30 #include "gaim.h" |
|
| 31 #include "gtkhtml.h" |
|
| 32 #include <gdk/gdkkeysyms.h> |
|
| 33 #include "pixmaps/underline.xpm" |
|
| 34 #include "pixmaps/bold.xpm" |
|
| 35 #include "pixmaps/italic.xpm" |
|
| 36 #include "pixmaps/small.xpm" |
|
| 37 #include "pixmaps/normal.xpm" |
|
| 38 #include "pixmaps/big.xpm" |
|
| 39 #include "pixmaps/speaker.xpm" |
|
| 40 #include "pixmaps/aimicon2.xpm" |
|
| 41 #include "pixmaps/wood.xpm" |
|
| 42 #include "pixmaps/palette.xpm" |
|
| 43 #include "pixmaps/link.xpm" |
|
| 44 #include "pixmaps/strike.xpm" |
|
| 45 |
|
| 46 int state_lock=0; |
|
| 47 |
|
| 48 GdkPixmap *dark_icon_pm = NULL; |
|
| 49 GdkBitmap *dark_icon_bm = NULL; |
|
| 50 |
|
| 51 |
|
| 52 void check_everything(GtkWidget *entry); |
|
| 53 gboolean user_keypress_callback(GtkWidget *entry, GdkEventKey *event, struct conversation *c); |
|
| 54 |
|
| 55 |
|
| 56 /*------------------------------------------------------------------------*/ |
|
| 57 /* Helpers */ |
|
| 58 /*------------------------------------------------------------------------*/ |
|
| 59 |
|
| 60 |
|
| 61 void quiet_set(GtkWidget *tb, int state) |
|
| 62 { |
|
| 63 state_lock=1; |
|
| 64 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(tb), state); |
|
| 65 state_lock=0; |
|
| 66 } |
|
| 67 |
|
| 68 |
|
| 69 void set_state_lock(int i) |
|
| 70 { |
|
| 71 state_lock = i; |
|
| 72 } |
|
| 73 |
|
| 74 |
|
| 75 struct conversation *new_conversation(char *name) |
|
| 76 { |
|
| 77 struct conversation *c; |
|
| 78 |
|
| 79 c = find_conversation(name); |
|
| 80 |
|
| 81 if (c != NULL) |
|
| 82 return c; |
|
| 83 |
|
| 84 c = (struct conversation *)g_new0(struct conversation, 1); |
|
| 85 g_snprintf(c->name, sizeof(c->name), "%s", name); |
|
| 86 |
|
| 87 if ((general_options & OPT_GEN_LOG_ALL) || find_log_info(c->name)) { |
|
| 88 FILE *fd; |
|
| 89 fd = open_log_file(c); |
|
| 90 if (!(general_options & OPT_GEN_STRIP_HTML)) |
|
| 91 fprintf(fd, "<HR><BR><H3 Align=Center> ---- New Conversation @ %s ----</H3><BR>\n", date()); |
|
| 92 else |
|
| 93 fprintf(fd, " ---- New Conversation @ %s ----\n", date()); |
|
| 94 fclose(fd); |
|
| 95 } |
|
| 96 |
|
| 97 show_conv(c); |
|
| 98 conversations = g_list_append(conversations, c); |
|
| 99 return c; |
|
| 100 } |
|
| 101 |
|
| 102 |
|
| 103 struct conversation *find_conversation(char *name) |
|
| 104 { |
|
| 105 char *cuser = g_malloc(64); |
|
| 106 struct conversation *c; |
|
| 107 GList *cnv = conversations; |
|
| 108 |
|
| 109 strcpy(cuser, normalize(name)); |
|
| 110 |
|
| 111 while(cnv) { |
|
| 112 c = (struct conversation *)cnv->data; |
|
| 113 if(!strcasecmp(cuser, normalize(c->name))) { |
|
| 114 g_free(cuser); |
|
| 115 return c; |
|
| 116 } |
|
| 117 cnv = cnv->next; |
|
| 118 } |
|
| 119 g_free(cuser); |
|
| 120 return NULL; |
|
| 121 } |
|
| 122 |
|
| 123 /* --------------------------------------------------- |
|
| 124 * Function to remove a log file entry |
|
| 125 * --------------------------------------------------- |
|
| 126 */ |
|
| 127 |
|
| 128 void rm_log(struct log_conversation *a) |
|
| 129 { |
|
| 130 struct conversation *cnv = find_conversation(a->name); |
|
| 131 char buf[128]; |
|
| 132 |
|
| 133 log_conversations = g_list_remove(log_conversations, a); |
|
| 134 |
|
| 135 save_prefs(); |
|
| 136 |
|
| 137 if (cnv) { |
|
| 138 if (!(general_options & OPT_GEN_LOG_ALL)) |
|
| 139 g_snprintf(buf, sizeof(buf), CONVERSATION_TITLE, cnv->name); |
|
| 140 else |
|
| 141 g_snprintf(buf, sizeof(buf), LOG_CONVERSATION_TITLE, cnv->name); |
|
| 142 gtk_window_set_title(GTK_WINDOW(cnv->window), buf); |
|
| 143 } |
|
| 144 } |
|
| 145 |
|
| 146 struct log_conversation *find_log_info(char *name) |
|
| 147 { |
|
| 148 char *pname = g_malloc(64); |
|
| 149 GList *lc = log_conversations; |
|
| 150 struct log_conversation *l; |
|
| 151 |
|
| 152 |
|
| 153 strcpy(pname, normalize(name)); |
|
| 154 |
|
| 155 while(lc) { |
|
| 156 l = (struct log_conversation *)lc->data; |
|
| 157 if (!strcasecmp(pname, normalize(l->name))) { |
|
| 158 g_free(pname); |
|
| 159 return l; |
|
| 160 } |
|
| 161 lc = lc->next; |
|
| 162 } |
|
| 163 g_free(pname); |
|
| 164 return NULL; |
|
| 165 } |
|
| 166 |
|
| 167 void delete_conversation(struct conversation *cnv) |
|
| 168 { |
|
| 169 conversations = g_list_remove(conversations, cnv); |
|
| 170 g_free(cnv); |
|
| 171 } |
|
| 172 |
|
| 173 void update_log_convs() |
|
| 174 { |
|
| 175 GList *cnv = conversations; |
|
| 176 struct conversation *c; |
|
| 177 |
|
| 178 while(cnv) { |
|
| 179 c = (struct conversation *)cnv->data; |
|
| 180 |
|
| 181 if (c->log_button) |
|
| 182 gtk_widget_set_sensitive(c->log_button, ((general_options & OPT_GEN_LOG_ALL)) ? FALSE : TRUE); |
|
| 183 |
|
| 184 cnv = cnv->next; |
|
| 185 } |
|
| 186 } |
|
| 187 |
|
| 188 void update_font_buttons() |
|
| 189 { |
|
| 190 GList *cnv = conversations; |
|
| 191 struct conversation *c; |
|
| 192 |
|
| 193 while (cnv) { |
|
| 194 c = (struct conversation *)cnv->data; |
|
| 195 |
|
| 196 if (c->bold) |
|
| 197 gtk_widget_set_sensitive(c->bold, ((font_options & OPT_FONT_BOLD)) ? FALSE : TRUE); |
|
| 198 |
|
| 199 if (c->italic) |
|
| 200 gtk_widget_set_sensitive(c->italic, ((font_options & OPT_FONT_ITALIC)) ? FALSE : TRUE); |
|
| 201 |
|
| 202 if (c->underline) |
|
| 203 gtk_widget_set_sensitive(c->underline, ((font_options & OPT_FONT_UNDERLINE)) ? FALSE : TRUE); |
|
| 204 |
|
| 205 if (c->strike) |
|
| 206 gtk_widget_set_sensitive(c->strike, ((font_options & OPT_FONT_STRIKE)) ? FALSE : TRUE); |
|
| 207 |
|
| 208 cnv = cnv->next; |
|
| 209 } |
|
| 210 } |
|
| 211 |
|
| 212 /* |
|
| 213 void update_transparency() |
|
| 214 { |
|
| 215 GList *cnv = conversations; |
|
| 216 struct conversation *c; |
|
| 217 |
|
| 218 This func should be uncalled! |
|
| 219 |
|
| 220 while(cnv) { |
|
| 221 c = (struct conversation *)cnv->data; |
|
| 222 |
|
| 223 if (c->text) |
|
| 224 gtk_html_set_transparent(GTK_HTML(c->text), |
|
| 225 (transparent) ? TRUE : FALSE); |
|
| 226 |
|
| 227 cnv = cnv->next; |
|
| 228 } |
|
| 229 } |
|
| 230 */ |
|
| 231 |
|
| 232 |
|
| 233 /*------------------------------------------------------------------------*/ |
|
| 234 /* Callbacks */ |
|
| 235 /*------------------------------------------------------------------------*/ |
|
| 236 |
|
| 237 void toggle_loggle(GtkWidget *w, struct conversation *p) |
|
| 238 { |
|
| 239 if (state_lock) |
|
| 240 return; |
|
| 241 |
|
| 242 if (find_log_info(p->name)) |
|
| 243 rm_log(find_log_info(p->name)); |
|
| 244 else |
|
| 245 show_log_dialog(p->name); |
|
| 246 } |
|
| 247 |
|
| 248 |
|
| 249 static int close_callback(GtkWidget *widget, struct conversation *c) |
|
| 250 { |
|
| 251 gtk_widget_destroy(c->window); |
|
| 252 delete_conversation(c); |
|
| 253 return TRUE; |
|
| 254 } |
|
| 255 |
|
| 256 static gint delete_event_convo(GtkWidget *w, GdkEventAny *e, struct conversation *c) |
|
| 257 { |
|
| 258 delete_conversation(c); |
|
| 259 return FALSE; |
|
| 260 } |
|
| 261 |
|
| 262 |
|
| 263 static void color_callback(GtkWidget *widget, struct conversation *c) |
|
| 264 { |
|
| 265 /* show_color_dialog(c); */ |
|
| 266 gtk_widget_grab_focus(c->entry); |
|
| 267 } |
|
| 268 |
|
| 269 static void add_callback(GtkWidget *widget, struct conversation *c) |
|
| 270 { |
|
| 271 if (find_buddy(c->name) != NULL) { |
|
| 272 sprintf(debug_buff,"Removing '%s' from buddylist.\n", c->name); |
|
| 273 debug_print(debug_buff); |
|
| 274 remove_buddy(find_group_by_buddy(c->name), find_buddy(c->name)); |
|
| 275 build_edit_tree(); |
|
| 276 gtk_label_set_text(GTK_LABEL(GTK_BIN(c->add_button)->child), "Add"); |
|
| 277 } |
|
| 278 else |
|
| 279 { |
|
| 280 show_add_buddy(c->name, NULL); |
|
| 281 } |
|
| 282 |
|
| 283 gtk_widget_grab_focus(c->entry); |
|
| 284 } |
|
| 285 |
|
| 286 |
|
| 287 static void block_callback(GtkWidget *widget, struct conversation *c) |
|
| 288 { |
|
| 289 show_add_perm(c->name); |
|
| 290 gtk_widget_grab_focus(c->entry); |
|
| 291 } |
|
| 292 |
|
| 293 static void warn_callback(GtkWidget *widget, struct conversation *c) |
|
| 294 { |
|
| 295 show_warn_dialog(c->name); |
|
| 296 gtk_widget_grab_focus(c->entry); |
|
| 297 } |
|
| 298 |
|
| 299 static void info_callback(GtkWidget *widget, struct conversation *c) |
|
| 300 { |
|
| 301 serv_get_info(c->name); |
|
| 302 gtk_widget_grab_focus(c->entry); |
|
| 303 } |
|
| 304 |
|
| 305 gboolean user_keypress_callback(GtkWidget *entry, GdkEventKey *event, struct conversation *c) |
|
| 306 { |
|
| 307 int pos; |
|
| 308 if(event->keyval==GDK_Return) { |
|
| 309 if(!(event->state & GDK_SHIFT_MASK)){ |
|
| 310 gtk_signal_emit_by_name(GTK_OBJECT(entry), "activate", c); |
|
| 311 //to stop the putting in of the enter character |
|
| 312 gtk_signal_emit_stop_by_name(GTK_OBJECT(entry), "key_press_event"); |
|
| 313 } else { |
|
| 314 gtk_signal_emit_stop_by_name(GTK_OBJECT(entry), "key_press_event"); |
|
| 315 pos=gtk_editable_get_position(GTK_EDITABLE(entry)); |
|
| 316 gtk_editable_insert_text(GTK_EDITABLE(entry), "\n", 1, &pos); |
|
| 317 } |
|
| 318 } |
|
| 319 |
|
| 320 return TRUE; |
|
| 321 |
|
| 322 } |
|
| 323 |
|
| 324 |
|
| 325 static void send_callback(GtkWidget *widget, struct conversation *c) |
|
| 326 { |
|
| 327 char buf[BUF_LONG]; |
|
| 328 char *buf2; |
|
| 329 char *buf3; |
|
| 330 gchar *buf4; |
|
| 331 int hdrlen; |
|
| 332 |
|
| 333 buf4 = gtk_editable_get_chars(GTK_EDITABLE(c->entry), 0, -1); |
|
| 334 g_snprintf(buf, BUF_LONG, "%s", buf4); |
|
| 335 g_free(buf4); |
|
| 336 |
|
| 337 if (!strlen(buf)) { |
|
| 338 return; |
|
| 339 } |
|
| 340 |
|
| 341 if (general_options & OPT_GEN_SEND_LINKS) { |
|
| 342 linkify_text(buf); |
|
| 343 } |
|
| 344 |
|
| 345 /* Let us determine how long the message CAN be. |
|
| 346 * toc_send_im is 11 chars long + 2 quotes. |
|
| 347 * + 2 spaces + 6 for the header + 2 for good |
|
| 348 * measure = 23 bytes + the length of normalize c->name */ |
|
| 349 |
|
| 350 buf2 = g_malloc(BUF_LONG); |
|
| 351 buf3 = g_malloc(BUF_LONG); |
|
| 352 |
|
| 353 hdrlen = 23 + strlen(normalize(c->name)); |
|
| 354 |
|
| 355 /* printf("%d %d %d\n", strlen(buf), hdrlen, BUF_LONG);*/ |
|
| 356 |
|
| 357 if (font_options & OPT_FONT_BOLD) { |
|
| 358 g_snprintf(buf2, BUF_LONG, "<B>%s</B>", buf); |
|
| 359 strcpy(buf, buf2); |
|
| 360 } |
|
| 361 |
|
| 362 if (font_options & OPT_FONT_ITALIC) { |
|
| 363 g_snprintf(buf2, BUF_LONG, "<I>%s</I>", buf); |
|
| 364 strcpy(buf, buf2); |
|
| 365 } |
|
| 366 |
|
| 367 if (font_options & OPT_FONT_UNDERLINE) { |
|
| 368 g_snprintf(buf2, BUF_LONG, "<U>%s</U>", buf); |
|
| 369 strcpy(buf, buf2); |
|
| 370 } |
|
| 371 |
|
| 372 if (font_options & OPT_FONT_STRIKE) { |
|
| 373 g_snprintf(buf2, BUF_LONG, "<STRIKE>%s</STRIKE>", buf); |
|
| 374 strcpy(buf, buf2); |
|
| 375 } |
|
| 376 |
|
| 377 write_to_conv(c, buf, WFLAG_SEND); |
|
| 378 |
|
| 379 gtk_editable_delete_text(GTK_EDITABLE(c->entry), 0, -1); |
|
| 380 |
|
| 381 escape_text(buf); |
|
| 382 if (escape_message(buf) > MSG_LEN - hdrlen) { |
|
| 383 do_error_dialog("Message too long, some data truncated.", "Error"); |
|
| 384 } |
|
| 385 |
|
| 386 serv_send_im(c->name, buf, 0); |
|
| 387 |
|
| 388 quiet_set(c->bold, FALSE); |
|
| 389 quiet_set(c->strike, FALSE); |
|
| 390 quiet_set(c->italic, FALSE); |
|
| 391 quiet_set(c->underline, FALSE); |
|
| 392 quiet_set(c->palette, FALSE); |
|
| 393 quiet_set(c->link, FALSE); |
|
| 394 |
|
| 395 if (c->makesound && (sound_options & OPT_SOUND_SEND)) |
|
| 396 play_sound(SEND); |
|
| 397 |
|
| 398 if (awaymessage != NULL) { |
|
| 399 do_im_back(); |
|
| 400 } |
|
| 401 |
|
| 402 |
|
| 403 gtk_widget_grab_focus(c->entry); |
|
| 404 |
|
| 405 g_free(buf2); |
|
| 406 g_free(buf3); |
|
| 407 |
|
| 408 } |
|
| 409 |
|
| 410 static int |
|
| 411 entry_key_pressed(GtkWidget *w, GtkWidget *entry) |
|
| 412 { |
|
| 413 check_everything(w); |
|
| 414 return TRUE; |
|
| 415 } |
|
| 416 |
|
| 417 /*------------------------------------------------------------------------*/ |
|
| 418 /* HTML-type stuff */ |
|
| 419 /*------------------------------------------------------------------------*/ |
|
| 420 |
|
| 421 int count_tag(GtkWidget *entry, char *s1, char *s2) |
|
| 422 { |
|
| 423 char *p1, *p2; |
|
| 424 int res=0; |
|
| 425 char *tmp, *tmpo, h; |
|
| 426 tmpo = gtk_editable_get_chars(GTK_EDITABLE(entry), 0, -1); |
|
| 427 h = tmpo[GTK_EDITABLE(entry)->current_pos]; |
|
| 428 tmpo[GTK_EDITABLE(entry)->current_pos]='\0'; |
|
| 429 tmp=tmpo; |
|
| 430 do { |
|
| 431 p1 = strstr(tmp, s1); |
|
| 432 p2 = strstr(tmp, s2); |
|
| 433 if (p1 && p2) { |
|
| 434 if (p1 < p2) { |
|
| 435 res=1; |
|
| 436 tmp = p1 +strlen(s1); |
|
| 437 } else if (p2 < p1) { |
|
| 438 res = 0; |
|
| 439 tmp = p2 + strlen(s2); |
|
| 440 } |
|
| 441 } else { |
|
| 442 if (p1) { |
|
| 443 res = 1; |
|
| 444 tmp = p1 + strlen(s1); |
|
| 445 } else if (p2) { |
|
| 446 res = 0; |
|
| 447 tmp = p2 + strlen(s2); |
|
| 448 } |
|
| 449 } |
|
| 450 } while (p1 || p2); |
|
| 451 tmpo[GTK_EDITABLE(entry)->current_pos]=h; |
|
| 452 g_free(tmpo); |
|
| 453 return res; |
|
| 454 } |
|
| 455 |
|
| 456 |
|
| 457 int invert_tags(GtkWidget *entry, char *s1, char *s2, int really) |
|
| 458 { |
|
| 459 int start = GTK_EDITABLE(entry)->selection_start_pos; |
|
| 460 int finish = GTK_EDITABLE(entry)->selection_end_pos; |
|
| 461 char *s; |
|
| 462 |
|
| 463 s = gtk_editable_get_chars(GTK_EDITABLE(entry), 0, -1); |
|
| 464 if (!strncasecmp(&s[start], s1, strlen(s1)) && |
|
| 465 !strncasecmp(&s[finish - strlen(s2)], s2, strlen(s2))) { |
|
| 466 if (really) { |
|
| 467 gtk_editable_delete_text(GTK_EDITABLE(entry), start, start + strlen(s1)); |
|
| 468 gtk_editable_delete_text(GTK_EDITABLE(entry), finish - strlen(s2) - strlen(s1), finish - strlen(s1)); |
|
| 469 } |
|
| 470 g_free(s); |
|
| 471 return 1; |
|
| 472 } |
|
| 473 g_free(s); |
|
| 474 return 0; |
|
| 475 } |
|
| 476 |
|
| 477 |
|
| 478 void remove_tags(GtkWidget *entry, char *tag) |
|
| 479 { |
|
| 480 char *s; |
|
| 481 char *t; |
|
| 482 int start = GTK_EDITABLE(entry)->selection_start_pos; |
|
| 483 int finish = GTK_EDITABLE(entry)->selection_end_pos; |
|
| 484 s = gtk_editable_get_chars(GTK_EDITABLE(entry), 0, -1); |
|
| 485 t = s; |
|
| 486 while((t = strstr(t, tag))) { |
|
| 487 if (((t-s) < finish) && ((t-s) >= start)) |
|
| 488 gtk_editable_delete_text(GTK_EDITABLE(entry), (t-s), (t-s) + strlen(tag)); |
|
| 489 else t++; |
|
| 490 } |
|
| 491 g_free(s); |
|
| 492 } |
|
| 493 |
|
| 494 void surround(GtkWidget *entry, char *pre, char *post) |
|
| 495 { |
|
| 496 int pos = GTK_EDITABLE(entry)->current_pos; |
|
| 497 int dummy; |
|
| 498 int start, finish; |
|
| 499 if (GTK_EDITABLE(entry)->has_selection) { |
|
| 500 remove_tags(entry, pre); |
|
| 501 remove_tags(entry, post); |
|
| 502 start = GTK_EDITABLE(entry)->selection_start_pos; |
|
| 503 finish = GTK_EDITABLE(entry)->selection_end_pos; |
|
| 504 if (start > finish) { |
|
| 505 dummy = finish; |
|
| 506 finish = start; |
|
| 507 start = dummy; |
|
| 508 } |
|
| 509 dummy = start; |
|
| 510 gtk_editable_insert_text(GTK_EDITABLE(entry), pre, strlen(pre), &dummy); |
|
| 511 dummy = finish + strlen(pre); |
|
| 512 gtk_editable_insert_text(GTK_EDITABLE(entry), post, strlen(post), &dummy); |
|
| 513 gtk_editable_select_region(GTK_EDITABLE(entry), start, finish + strlen(pre) + strlen(post)); |
|
| 514 } else { |
|
| 515 gtk_editable_insert_text(GTK_EDITABLE(entry), pre, strlen(pre), &pos); |
|
| 516 dummy = pos; |
|
| 517 gtk_editable_insert_text(GTK_EDITABLE(entry), post, strlen(post), &dummy); |
|
| 518 gtk_editable_set_position(GTK_EDITABLE(entry), pos); |
|
| 519 } |
|
| 520 gtk_widget_grab_focus(entry); |
|
| 521 } |
|
| 522 |
|
| 523 static void advance_past(GtkWidget *entry, char *pre, char *post) |
|
| 524 { |
|
| 525 char *s, *s2; |
|
| 526 int pos; |
|
| 527 if (invert_tags(entry, pre, post, 1)) |
|
| 528 return; |
|
| 529 s = gtk_editable_get_chars(GTK_EDITABLE(entry), 0, -1); |
|
| 530 pos = GTK_EDITABLE(entry)->current_pos; |
|
| 531 sprintf(debug_buff,"Currently at %d\n",pos); |
|
| 532 debug_print(debug_buff); |
|
| 533 s2= strstr(&s[pos], post); |
|
| 534 if (s2) |
|
| 535 pos = s2 - s + strlen(post); |
|
| 536 else |
|
| 537 pos=-1; |
|
| 538 sprintf(debug_buff,"Setting position to %d\n",pos); |
|
| 539 debug_print(debug_buff); |
|
| 540 gtk_editable_set_position(GTK_EDITABLE(entry), pos); |
|
| 541 gtk_widget_grab_focus(entry); |
|
| 542 } |
|
| 543 |
|
| 544 static void toggle_color(GtkWidget *color, GtkWidget *entry) |
|
| 545 { |
|
| 546 if (state_lock) |
|
| 547 return; |
|
| 548 if (GTK_TOGGLE_BUTTON(color)->active) |
|
| 549 show_color_dialog(entry, color); |
|
| 550 else |
|
| 551 advance_past(entry, "<FONT COLOR>", "</FONT>"); |
|
| 552 } |
|
| 553 |
|
| 554 static void do_link(GtkWidget *linky, GtkWidget *entry) |
|
| 555 { |
|
| 556 if (state_lock) |
|
| 557 return; |
|
| 558 if (GTK_TOGGLE_BUTTON(linky)->active) |
|
| 559 show_add_link(entry, linky); |
|
| 560 else |
|
| 561 advance_past(entry, "<A HREF>", "</A>" ); |
|
| 562 } |
|
| 563 |
|
| 564 static void do_strike(GtkWidget *strike, GtkWidget *entry) |
|
| 565 { |
|
| 566 if (state_lock) |
|
| 567 return; |
|
| 568 if (GTK_TOGGLE_BUTTON(strike)->active) |
|
| 569 surround(entry, "<STRIKE>","</STRIKE>"); |
|
| 570 else |
|
| 571 advance_past(entry, "<STRIKE>", "</STRIKE>"); |
|
| 572 } |
|
| 573 |
|
| 574 static void do_bold(GtkWidget *bold, GtkWidget *entry) |
|
| 575 { |
|
| 576 if (state_lock) |
|
| 577 return; |
|
| 578 if (GTK_TOGGLE_BUTTON(bold)->active) |
|
| 579 surround(entry, "<B>","</B>"); |
|
| 580 else |
|
| 581 advance_past(entry, "<B>", "</B>"); |
|
| 582 } |
|
| 583 |
|
| 584 static void do_underline(GtkWidget *underline, GtkWidget *entry) |
|
| 585 { |
|
| 586 if (state_lock) |
|
| 587 return; |
|
| 588 if (GTK_TOGGLE_BUTTON(underline)->active) |
|
| 589 surround(entry, "<U>","</U>"); |
|
| 590 else |
|
| 591 advance_past(entry, "<U>", "</U>"); |
|
| 592 } |
|
| 593 |
|
| 594 static void do_italic(GtkWidget *italic, GtkWidget *entry) |
|
| 595 { |
|
| 596 if (state_lock) |
|
| 597 return; |
|
| 598 if (GTK_TOGGLE_BUTTON(italic)->active) |
|
| 599 surround(entry, "<I>","</I>"); |
|
| 600 else |
|
| 601 advance_past(entry, "<I>", "</I>"); |
|
| 602 } |
|
| 603 |
|
| 604 static void do_small(GtkWidget *small, GtkWidget *entry) |
|
| 605 { |
|
| 606 if (state_lock) |
|
| 607 return; |
|
| 608 surround(entry, "<FONT SIZE=\"+1\">","</FONT>"); |
|
| 609 } |
|
| 610 |
|
| 611 static void do_normal(GtkWidget *normal, GtkWidget *entry) |
|
| 612 { |
|
| 613 if (state_lock) |
|
| 614 return; |
|
| 615 surround(entry, "<FONT SIZE=\"+3\">","</FONT>"); |
|
| 616 } |
|
| 617 |
|
| 618 static void do_big(GtkWidget *big, GtkWidget *entry) |
|
| 619 { |
|
| 620 if (state_lock) |
|
| 621 return; |
|
| 622 surround(entry, "<FONT SIZE=\"+5\">","</FONT>"); |
|
| 623 } |
|
| 624 |
|
| 625 void check_everything(GtkWidget *entry) |
|
| 626 { |
|
| 627 struct conversation *c; |
|
| 628 c = (struct conversation *)gtk_object_get_user_data(GTK_OBJECT(entry)); |
|
| 629 if (!c) return; |
|
| 630 if (invert_tags(entry, "<B>", "</B>", 0)) |
|
| 631 quiet_set(c->bold, TRUE); |
|
| 632 else if (count_tag(entry, "<B>", "</B>")) |
|
| 633 quiet_set(c->bold, TRUE); |
|
| 634 else |
|
| 635 quiet_set(c->bold,FALSE); |
|
| 636 if (invert_tags(entry, "<I>", "</I>", 0)) |
|
| 637 quiet_set(c->italic, TRUE); |
|
| 638 else if (count_tag(entry, "<I>", "</I>")) |
|
| 639 quiet_set(c->italic, TRUE); |
|
| 640 else |
|
| 641 quiet_set(c->italic, FALSE); |
|
| 642 |
|
| 643 if (invert_tags(entry, "<FONT COLOR", "</FONT>", 0)) |
|
| 644 quiet_set(c->palette, TRUE); |
|
| 645 else if (count_tag(entry, "<FONT COLOR", "</FONT>")) |
|
| 646 quiet_set(c->palette, TRUE); |
|
| 647 else |
|
| 648 quiet_set(c->palette, FALSE); |
|
| 649 |
|
| 650 if (invert_tags(entry, "<A HREF", "</A>", 0)) |
|
| 651 quiet_set(c->link, TRUE); |
|
| 652 else if (count_tag(entry, "<A HREF", "</A>")) |
|
| 653 quiet_set(c->link, TRUE); |
|
| 654 else |
|
| 655 quiet_set(c->link, FALSE); |
|
| 656 |
|
| 657 if (invert_tags(entry, "<U>", "</U>", 0)) |
|
| 658 quiet_set(c->underline, TRUE); |
|
| 659 else if (count_tag(entry, "<U>", "</U>")) |
|
| 660 quiet_set(c->underline, TRUE); |
|
| 661 else |
|
| 662 quiet_set(c->underline, FALSE); |
|
| 663 |
|
| 664 if (invert_tags(entry, "<STRIKE>", "</STRIKE>", 0)) |
|
| 665 quiet_set(c->strike, TRUE); |
|
| 666 else if (count_tag(entry, "<STRIKE>", "</STRIKE>")) |
|
| 667 quiet_set(c->strike, TRUE); |
|
| 668 else |
|
| 669 quiet_set(c->strike, FALSE); |
|
| 670 } |
|
| 671 |
|
| 672 |
|
| 673 /*------------------------------------------------------------------------*/ |
|
| 674 /* Takin care of the window.. */ |
|
| 675 /*------------------------------------------------------------------------*/ |
|
| 676 |
|
| 677 |
|
| 678 void write_to_conv(struct conversation *c, char *what, int flags) |
|
| 679 { |
|
| 680 char *buf = g_malloc(BUF_LONG); |
|
| 681 char *buf2 = g_malloc(BUF_LONG); |
|
| 682 char *who = NULL; |
|
| 683 FILE *fd; |
|
| 684 char colour[10]; |
|
| 685 |
|
| 686 if (flags & WFLAG_SYSTEM) { |
|
| 687 |
|
| 688 gtk_html_freeze(GTK_HTML(c->text)); |
|
| 689 |
|
| 690 gtk_html_append_text(GTK_HTML(c->text), what, 0); |
|
| 691 |
|
| 692 gtk_html_append_text(GTK_HTML(c->text), "<BR>", 0); |
|
| 693 |
|
| 694 gtk_html_thaw(GTK_HTML(c->text)); |
|
| 695 |
|
| 696 |
|
| 697 if ((general_options & OPT_GEN_LOG_ALL) || find_log_info(c->name)) { |
|
| 698 char *t1; |
|
| 699 |
|
| 700 if (general_options & OPT_GEN_STRIP_HTML) { |
|
| 701 t1 = strip_html(what); |
|
| 702 } else { |
|
| 703 t1 = what; |
|
| 704 } |
|
| 705 fd = open_log_file(c); |
|
| 706 fprintf(fd, "%s\n", t1); |
|
| 707 fclose(fd); |
|
| 708 if (general_options & OPT_GEN_STRIP_HTML) { |
|
| 709 g_free(t1); |
|
| 710 } |
|
| 711 } |
|
| 712 |
|
| 713 } else { |
|
| 714 |
|
| 715 if (flags & WFLAG_RECV) { |
|
| 716 strcpy(colour, "#ff0000"); |
|
| 717 who = c->name; |
|
| 718 } else if (flags & WFLAG_SEND) { |
|
| 719 strcpy(colour, "#0000ff"); |
|
| 720 who = current_user->username; |
|
| 721 } |
|
| 722 |
|
| 723 if (flags & WFLAG_AUTO && flags & WFLAG_SEND) |
|
| 724 sprintf(buf2, " %s", AUTO_RESPONSE); |
|
| 725 else |
|
| 726 buf2[0]=0; /* sprintf(buf2, ""); */ |
|
| 727 |
|
| 728 if (display_options & OPT_DISP_SHOW_TIME) |
|
| 729 g_snprintf(buf, BUF_LONG, "<FONT COLOR=\"%s\"><B>%s %s:%s</B></FONT> ", colour, date(), who, buf2); |
|
| 730 else |
|
| 731 g_snprintf(buf, BUF_LONG, "<FONT COLOR=\"%s\"><B>%s:%s</B></FONT> ", colour, who, buf2); |
|
| 732 |
|
| 733 gtk_html_freeze(GTK_HTML(c->text)); |
|
| 734 |
|
| 735 gtk_html_append_text(GTK_HTML(c->text), buf, 0); |
|
| 736 gtk_html_append_text(GTK_HTML(c->text), what, (display_options & OPT_DISP_IGNORE_COLOUR) ? HTML_OPTION_NO_COLOURS : 0); |
|
| 737 |
|
| 738 gtk_html_append_text(GTK_HTML(c->text), "<BR>", 0); |
|
| 739 |
|
| 740 |
|
| 741 gtk_html_thaw(GTK_HTML(c->text)); |
|
| 742 |
|
| 743 if ((general_options & OPT_GEN_LOG_ALL) || find_log_info(c->name)) { |
|
| 744 char *t1, *t2; |
|
| 745 |
|
| 746 if (general_options & OPT_GEN_STRIP_HTML) { |
|
| 747 t1 = strip_html(buf); |
|
| 748 t2 = strip_html(what); |
|
| 749 } else { |
|
| 750 t1 = buf; |
|
| 751 t2 = what; |
|
| 752 } |
|
| 753 fd = open_log_file(c); |
|
| 754 fprintf(fd, "%s%s\n", t1, t2); |
|
| 755 fclose(fd); |
|
| 756 if (general_options & OPT_GEN_STRIP_HTML) { |
|
| 757 g_free(t1); |
|
| 758 g_free(t2); |
|
| 759 } |
|
| 760 } |
|
| 761 } |
|
| 762 |
|
| 763 /* if (!GTK_WIDGET_MAPPED(c->window)) { |
|
| 764 |
|
| 765 if (dark_icon_pm == NULL) |
|
| 766 dark_icon_pm = gdk_pixmap_create_from_xpm_d(c->window->window, &dark_icon_bm, |
|
| 767 NULL, (gchar **)aimicon2_xpm); |
|
| 768 gdk_window_set_icon(c->window->window, NULL, dark_icon_pm, dark_icon_bm); |
|
| 769 } |
|
| 770 */ |
|
| 771 |
|
| 772 if (general_options & OPT_GEN_POPUP_WINDOWS) |
|
| 773 gdk_window_raise(c->window->window); |
|
| 774 |
|
| 775 |
|
| 776 g_free(buf); |
|
| 777 g_free(buf2); |
|
| 778 } |
|
| 779 |
|
| 780 |
|
| 781 |
|
| 782 |
|
| 783 |
|
| 784 void show_conv(struct conversation *c) |
|
| 785 { |
|
| 786 GtkWidget *win; |
|
| 787 char buf[256]; |
|
| 788 GtkWidget *text; |
|
| 789 GtkWidget *sw; |
|
| 790 GtkWidget *send; |
|
| 791 GtkWidget *info; |
|
| 792 GtkWidget *warn; |
|
| 793 GtkWidget *block; |
|
| 794 GtkWidget *color; |
|
| 795 GtkWidget *close; |
|
| 796 GtkWidget *entry; |
|
| 797 GtkWidget *toolbar; |
|
| 798 GtkWidget *bbox; |
|
| 799 GtkWidget *vbox; |
|
| 800 GtkWidget *add; |
|
| 801 GdkPixmap *strike_i, *small_i, *normal_i, *big_i, *bold_i, *italic_i, *underline_i, *speaker_i, *wood_i, *palette_i, *link_i; |
|
| 802 GtkWidget *strike_p, *small_p, *normal_p, *big_p, *bold_p, *italic_p, *underline_p, *speaker_p, *wood_p, *palette_p, *link_p; |
|
| 803 GtkWidget *strike, *small, *normal, *big, *bold, *italic, *underline, *speaker, *wood, *palette, *link; |
|
| 804 GdkBitmap *mask; |
|
| 805 |
|
| 806 win = gtk_window_new(GTK_WINDOW_TOPLEVEL); |
|
| 807 gtk_window_set_policy(GTK_WINDOW(win), TRUE, TRUE, TRUE); |
|
| 808 |
|
| 809 gtk_widget_realize(win); |
|
| 810 aol_icon(win->window); |
|
| 811 |
|
| 812 |
|
| 813 c->window = win; |
|
| 814 |
|
| 815 send = gtk_button_new_with_label("Send"); |
|
| 816 info = gtk_button_new_with_label("Info"); |
|
| 817 warn = gtk_button_new_with_label("Warn"); |
|
| 818 color = gtk_button_new_with_label("Color"); |
|
| 819 close = gtk_button_new_with_label("Close"); |
|
| 820 if (find_buddy(c->name) != NULL) { |
|
| 821 add = gtk_button_new_with_label("Remove"); |
|
| 822 } |
|
| 823 else { |
|
| 824 add = gtk_button_new_with_label("Add"); |
|
| 825 } |
|
| 826 block = gtk_button_new_with_label("Block"); |
|
| 827 |
|
| 828 |
|
| 829 bbox = gtk_hbox_new(TRUE, 0); |
|
| 830 vbox = gtk_vbox_new(FALSE, 0); |
|
| 831 |
|
| 832 entry = gtk_text_new(NULL, NULL); |
|
| 833 gtk_text_set_editable(GTK_TEXT(entry), TRUE); |
|
| 834 gtk_text_set_word_wrap(GTK_TEXT(entry), TRUE); |
|
| 835 |
|
| 836 /* Toolbar */ |
|
| 837 toolbar = gtk_toolbar_new(GTK_ORIENTATION_HORIZONTAL, GTK_TOOLBAR_ICONS); |
|
| 838 |
|
| 839 link_i = gdk_pixmap_create_from_xpm_d(win->window, &mask, |
|
| 840 &win->style->white, link_xpm ); |
|
| 841 link_p = gtk_pixmap_new(link_i, mask); |
|
| 842 gtk_widget_show(link_p); |
|
| 843 |
|
| 844 palette_i = gdk_pixmap_create_from_xpm_d (win->window, &mask, |
|
| 845 &win->style->white, palette_xpm ); |
|
| 846 palette_p = gtk_pixmap_new(palette_i, mask); |
|
| 847 gtk_widget_show(palette_p); |
|
| 848 |
|
| 849 wood_i = gdk_pixmap_create_from_xpm_d ( win->window, &mask, |
|
| 850 &win->style->white, wood_xpm ); |
|
| 851 wood_p = gtk_pixmap_new(wood_i, mask); |
|
| 852 gtk_widget_show(wood_p); |
|
| 853 speaker_i = gdk_pixmap_create_from_xpm_d ( win->window, &mask, |
|
| 854 &win->style->white, speaker_xpm ); |
|
| 855 speaker_p = gtk_pixmap_new(speaker_i, mask); |
|
| 856 gtk_widget_show(speaker_p); |
|
| 857 c->makesound=1; |
|
| 858 strike_i = gdk_pixmap_create_from_xpm_d ( win->window, &mask, |
|
| 859 &win->style->white, strike_xpm ); |
|
| 860 strike_p = gtk_pixmap_new(strike_i, mask); |
|
| 861 gtk_widget_show(strike_p); |
|
| 862 bold_i = gdk_pixmap_create_from_xpm_d ( win->window, &mask, |
|
| 863 &win->style->white, bold_xpm ); |
|
| 864 bold_p = gtk_pixmap_new(bold_i, mask); |
|
| 865 gtk_widget_show(bold_p); |
|
| 866 italic_i = gdk_pixmap_create_from_xpm_d ( win->window, &mask, |
|
| 867 &win->style->white, italic_xpm ); |
|
| 868 italic_p = gtk_pixmap_new(italic_i, mask); |
|
| 869 gtk_widget_show(italic_p); |
|
| 870 underline_i = gdk_pixmap_create_from_xpm_d ( win->window, &mask, |
|
| 871 &win->style->white, underline_xpm ); |
|
| 872 underline_p = gtk_pixmap_new(underline_i, mask); |
|
| 873 gtk_widget_show(underline_p); |
|
| 874 small_i = gdk_pixmap_create_from_xpm_d ( win->window, &mask, |
|
| 875 &win->style->white, small_xpm ); |
|
| 876 small_p = gtk_pixmap_new(small_i, mask); |
|
| 877 gtk_widget_show(small_p); |
|
| 878 normal_i = gdk_pixmap_create_from_xpm_d ( win->window, &mask, |
|
| 879 &win->style->white, normal_xpm ); |
|
| 880 normal_p = gtk_pixmap_new(normal_i, mask); |
|
| 881 gtk_widget_show(normal_p); |
|
| 882 big_i = gdk_pixmap_create_from_xpm_d ( win->window, &mask, |
|
| 883 &win->style->white, big_xpm ); |
|
| 884 big_p = gtk_pixmap_new(big_i, mask); |
|
| 885 gtk_widget_show(big_p); |
|
| 886 |
|
| 887 |
|
| 888 bold = gtk_toolbar_append_element(GTK_TOOLBAR(toolbar), |
|
| 889 GTK_TOOLBAR_CHILD_TOGGLEBUTTON, NULL, |
|
| 890 "Bold", "Bold Text", "Bold", bold_p, |
|
| 891 GTK_SIGNAL_FUNC(do_bold), entry); |
|
| 892 italic = gtk_toolbar_append_element(GTK_TOOLBAR(toolbar), |
|
| 893 GTK_TOOLBAR_CHILD_TOGGLEBUTTON, |
|
| 894 NULL, "Italics", "Italics Text", |
|
| 895 "Italics", italic_p, GTK_SIGNAL_FUNC(do_italic), entry); |
|
| 896 underline = gtk_toolbar_append_element(GTK_TOOLBAR(toolbar), |
|
| 897 GTK_TOOLBAR_CHILD_TOGGLEBUTTON, |
|
| 898 NULL, "Underline", "Underline Text", |
|
| 899 "Underline", underline_p, GTK_SIGNAL_FUNC(do_underline), entry); |
|
| 900 strike = gtk_toolbar_append_element(GTK_TOOLBAR(toolbar), |
|
| 901 GTK_TOOLBAR_CHILD_TOGGLEBUTTON, |
|
| 902 NULL, "Strike", "Strike through Text", |
|
| 903 "Strike", strike_p, GTK_SIGNAL_FUNC(do_strike), entry); |
|
| 904 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar)); |
|
| 905 small = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar), "Small", "Decrease font size", "Small", small_p, GTK_SIGNAL_FUNC(do_small), entry); |
|
| 906 normal = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar), "Normal", "Normal font size", "Normal", normal_p, GTK_SIGNAL_FUNC(do_normal), entry); |
|
| 907 big = gtk_toolbar_append_item(GTK_TOOLBAR(toolbar), "Big", "Increase font size", "Big", big_p, GTK_SIGNAL_FUNC(do_big), entry); |
|
| 908 gtk_toolbar_append_space(GTK_TOOLBAR(toolbar)); |
|
| 909 link = gtk_toolbar_append_element(GTK_TOOLBAR(toolbar), |
|
| 910 GTK_TOOLBAR_CHILD_TOGGLEBUTTON, NULL, "Link", "Insert Link", |
|
| 911 "Link", link_p, GTK_SIGNAL_FUNC(do_link), entry); |
|
| 912 palette = gtk_toolbar_append_element(GTK_TOOLBAR(toolbar), |
|
| 913 GTK_TOOLBAR_CHILD_TOGGLEBUTTON, |
|
| 914 NULL, "Color", "Text Color", |
|
| 915 "Color", palette_p, GTK_SIGNAL_FUNC(toggle_color), entry); |
|
| 916 wood = gtk_toolbar_append_element(GTK_TOOLBAR(toolbar), |
|
| 917 GTK_TOOLBAR_CHILD_TOGGLEBUTTON, |
|
| 918 NULL, "Logging", "Enable logging", |
|
| 919 "Logging", wood_p, GTK_SIGNAL_FUNC(toggle_loggle), c); |
|
| 920 speaker = gtk_toolbar_append_element(GTK_TOOLBAR(toolbar), |
|
| 921 GTK_TOOLBAR_CHILD_TOGGLEBUTTON, |
|
| 922 NULL, "Sound", "Enable sounds", |
|
| 923 "Sound", speaker_p, GTK_SIGNAL_FUNC(set_option), &c->makesound); |
|
| 924 c->makesound=0; |
|
| 925 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(speaker), TRUE); |
|
| 926 |
|
| 927 state_lock = 1; |
|
| 928 if (find_log_info(c->name)) |
|
| 929 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(wood), TRUE); |
|
| 930 else |
|
| 931 gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(wood), FALSE); |
|
| 932 state_lock = 0; |
|
| 933 |
|
| 934 gtk_widget_show(toolbar); |
|
| 935 |
|
| 936 c->entry = entry; |
|
| 937 c->bold = bold; |
|
| 938 c->strike = strike; |
|
| 939 c->italic = italic; |
|
| 940 c->underline = underline; |
|
| 941 c->log_button = wood; |
|
| 942 c->palette = palette; |
|
| 943 c->link = link; |
|
| 944 c->add_button = add; |
|
| 945 |
|
| 946 gtk_widget_set_sensitive(c->log_button, ((general_options & OPT_GEN_LOG_ALL)) ? FALSE : TRUE); |
|
| 947 |
|
| 948 gtk_widget_set_sensitive(c->bold, ((font_options & OPT_FONT_BOLD)) ? FALSE : TRUE); |
|
| 949 gtk_widget_set_sensitive(c->italic, ((font_options & OPT_FONT_ITALIC)) ? FALSE : TRUE); |
|
| 950 gtk_widget_set_sensitive(c->underline, ((font_options & OPT_FONT_UNDERLINE)) ? FALSE : TRUE); |
|
| 951 gtk_widget_set_sensitive(c->strike, ((font_options & OPT_FONT_STRIKE)) ? FALSE : TRUE); |
|
| 952 |
|
| 953 gtk_object_set_user_data(GTK_OBJECT(entry), c); |
|
| 954 |
|
| 955 |
|
| 956 |
|
| 957 gtk_signal_connect(GTK_OBJECT(entry), "activate", GTK_SIGNAL_FUNC(send_callback),c); |
|
| 958 |
|
| 959 /* Text box */ |
|
| 960 |
|
| 961 |
|
| 962 text = gtk_html_new(NULL, NULL); |
|
| 963 |
|
| 964 gtk_html_set_editable(GTK_HTML(text), FALSE); |
|
| 965 /* gtk_html_set_transparent(GTK_HTML(text), (transparent) ? TRUE : FALSE);*/ |
|
| 966 c->text = text; |
|
| 967 |
|
| 968 sw = gtk_scrolled_window_new (NULL, NULL); |
|
| 969 gtk_scrolled_window_set_policy (GTK_SCROLLED_WINDOW (sw), |
|
| 970 GTK_POLICY_NEVER, |
|
| 971 GTK_POLICY_ALWAYS); |
|
| 972 gtk_widget_show(sw); |
|
| 973 gtk_container_add(GTK_CONTAINER(sw), text); |
|
| 974 gtk_widget_show(text); |
|
| 975 |
|
| 976 |
|
| 977 |
|
| 978 |
|
| 979 GTK_HTML (text)->hadj->step_increment = 10.0; |
|
| 980 GTK_HTML (text)->vadj->step_increment = 10.0; |
|
| 981 gtk_widget_set_usize(sw, 320, 150); |
|
| 982 |
|
| 983 |
|
| 984 |
|
| 985 /* Ready and pack buttons */ |
|
| 986 gtk_object_set_user_data(GTK_OBJECT(win), c); |
|
| 987 gtk_object_set_user_data(GTK_OBJECT(close), c); |
|
| 988 gtk_signal_connect(GTK_OBJECT(close), "clicked", GTK_SIGNAL_FUNC(close_callback), c); |
|
| 989 gtk_signal_connect(GTK_OBJECT(send), "clicked", GTK_SIGNAL_FUNC(send_callback), c); |
|
| 990 gtk_signal_connect(GTK_OBJECT(add), "clicked", GTK_SIGNAL_FUNC(add_callback), c); |
|
| 991 gtk_signal_connect(GTK_OBJECT(info), "clicked", GTK_SIGNAL_FUNC(info_callback), c); |
|
| 992 gtk_signal_connect(GTK_OBJECT(warn), "clicked", GTK_SIGNAL_FUNC(warn_callback), c); |
|
| 993 gtk_signal_connect(GTK_OBJECT(block), "clicked", GTK_SIGNAL_FUNC(block_callback), c); |
|
| 994 gtk_signal_connect(GTK_OBJECT(color), "clicked", GTK_SIGNAL_FUNC(color_callback), c); |
|
| 995 |
|
| 996 gtk_signal_connect(GTK_OBJECT(entry), "key_press_event", GTK_SIGNAL_FUNC(user_keypress_callback), c); |
|
| 997 gtk_widget_set_usize(entry, 300, 70); |
|
| 998 |
|
| 999 gtk_box_pack_start(GTK_BOX(bbox), send, TRUE, TRUE, 5); |
|
| 1000 gtk_box_pack_start(GTK_BOX(bbox), info, TRUE, TRUE, 5); |
|
| 1001 gtk_box_pack_start(GTK_BOX(bbox), warn, TRUE, TRUE, 5); |
|
| 1002 gtk_box_pack_start(GTK_BOX(bbox), block, TRUE, TRUE, 5); |
|
| 1003 gtk_box_pack_start(GTK_BOX(bbox), color, TRUE, TRUE, 5); |
|
| 1004 gtk_box_pack_start(GTK_BOX(bbox), add, TRUE, TRUE, 5); |
|
| 1005 gtk_box_pack_start(GTK_BOX(bbox), close, TRUE, TRUE, 5); |
|
| 1006 |
|
| 1007 /* pack and fill the rest */ |
|
| 1008 |
|
| 1009 gtk_box_pack_start(GTK_BOX(vbox), sw, TRUE, TRUE, 5); |
|
| 1010 gtk_box_pack_start(GTK_BOX(vbox), toolbar, FALSE, FALSE, 5); |
|
| 1011 gtk_box_pack_start(GTK_BOX(vbox), entry, FALSE, FALSE, 5); |
|
| 1012 gtk_box_pack_start(GTK_BOX(vbox), bbox, FALSE, FALSE, 5); |
|
| 1013 |
|
| 1014 |
|
| 1015 |
|
| 1016 |
|
| 1017 gtk_widget_show(send); |
|
| 1018 gtk_widget_show(info); |
|
| 1019 gtk_widget_show(warn); |
|
| 1020 /* gtk_widget_show(color); */ |
|
| 1021 gtk_widget_show(close); |
|
| 1022 gtk_widget_show(add); |
|
| 1023 gtk_widget_show(block); |
|
| 1024 gtk_widget_show(bbox); |
|
| 1025 gtk_widget_show(vbox); |
|
| 1026 gtk_widget_show(entry); |
|
| 1027 gtk_widget_show(text); |
|
| 1028 |
|
| 1029 gtk_container_add(GTK_CONTAINER(win),vbox); |
|
| 1030 gtk_container_border_width(GTK_CONTAINER(win), 10); |
|
| 1031 |
|
| 1032 if ((find_log_info(c->name)) || ((general_options & OPT_GEN_LOG_ALL))) |
|
| 1033 g_snprintf(buf, sizeof(buf), LOG_CONVERSATION_TITLE, c->name); |
|
| 1034 else |
|
| 1035 g_snprintf(buf, sizeof(buf), CONVERSATION_TITLE, c->name); |
|
| 1036 gtk_window_set_title(GTK_WINDOW(win), buf); |
|
| 1037 gtk_window_set_focus(GTK_WINDOW(win),entry); |
|
| 1038 |
|
| 1039 gtk_signal_connect(GTK_OBJECT(win), "delete_event", GTK_SIGNAL_FUNC(delete_event_convo), c); |
|
| 1040 gtk_signal_connect(GTK_OBJECT(entry), "key_press_event", GTK_SIGNAL_FUNC(entry_key_pressed), entry); |
|
| 1041 |
|
| 1042 gtk_widget_show(win); |
|
| 1043 |
|
| 1044 } |
|
| 1045 |
|
| 1046 |
|