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