comparison src/conversation.c @ 3802:9bcb42faccc0

[gaim-migrate @ 3945] Rewrote show_im_dialog and show_info_dialog. Ported to gtkspell2. Gtkspell2 is a library available from gtkspell.sf.net. It requires the pspell library. If you want the "highlight misspelled words" feature to work, you must have this library installed. If installed, configure will detect it and link against it. committer: Tailor Script <tailor@pidgin.im>
author Sean Egan <seanegan@gmail.com>
date Sat, 26 Oct 2002 06:41:13 +0000
parents 8cc3d7526043
children e403c93110d0
comparison
equal deleted inserted replaced
3801:8cc3d7526043 3802:9bcb42faccc0
38 #include <stdio.h> 38 #include <stdio.h>
39 #include <stdlib.h> 39 #include <stdlib.h>
40 #include <errno.h> 40 #include <errno.h>
41 #include <ctype.h> 41 #include <ctype.h>
42 #include <gtk/gtk.h> 42 #include <gtk/gtk.h>
43 #ifdef USE_GTKSPELL
44 #include <gtkspell/gtkspell.h>
45 #endif
43 #include "gtkimhtml.h" 46 #include "gtkimhtml.h"
44 #include <gdk/gdkkeysyms.h> 47 #include <gdk/gdkkeysyms.h>
45 #include "convo.h" 48 #include "convo.h"
46 #include "gtkspell.h"
47 #include "prpl.h" 49 #include "prpl.h"
48 50
49 #ifdef _WIN32 51 #ifdef _WIN32
50 #include <process.h> /* fog getpid() */ 52 #include <process.h> /* fog getpid() */
51 #include <io.h> 53 #include <io.h>
509 gtk_widget_destroy(tmp); 511 gtk_widget_destroy(tmp);
510 return FALSE; 512 return FALSE;
511 } 513 }
512 514
513 debug_printf("conversation close callback\n"); 515 debug_printf("conversation close callback\n");
514
515 /* if (convo_options & OPT_CONVO_CHECK_SPELLING)
516 gtkspell_detach(GTK_TEXT(c->entry));*/
517 516
518 if (!c->is_chat) { 517 if (!c->is_chat) {
519 GSList *cn = connections; 518 GSList *cn = connections;
520 if (!(misc_options & OPT_MISC_STEALTH_TYPING)) 519 if (!(misc_options & OPT_MISC_STEALTH_TYPING))
521 serv_send_typing(c->gc, c->name, NOT_TYPING); 520 serv_send_typing(c->gc, c->name, NOT_TYPING);
1509 void surround(struct conversation *c, char *pre, char *post) 1508 void surround(struct conversation *c, char *pre, char *post)
1510 { 1509 {
1511 GtkTextIter start, end; 1510 GtkTextIter start, end;
1512 GtkTextMark *mark_start, *mark_end; 1511 GtkTextMark *mark_start, *mark_end;
1513 1512
1514 /* if (convo_options & OPT_CONVO_CHECK_SPELLING) {
1515 gtkspell_detach(GTK_TEXT(entry));
1516 }*/
1517
1518 if (gtk_text_buffer_get_selection_bounds(c->entry_buffer, &start, &end)) { 1513 if (gtk_text_buffer_get_selection_bounds(c->entry_buffer, &start, &end)) {
1519 remove_tags(c, pre); 1514 remove_tags(c, pre);
1520 remove_tags(c, post); 1515 remove_tags(c, post);
1521 1516
1522 mark_start = gtk_text_buffer_create_mark(c->entry_buffer, "m1", &start, TRUE); 1517 mark_start = gtk_text_buffer_create_mark(c->entry_buffer, "m1", &start, TRUE);
1532 mark_start = gtk_text_buffer_get_insert(c->entry_buffer); 1527 mark_start = gtk_text_buffer_get_insert(c->entry_buffer);
1533 gtk_text_buffer_get_iter_at_mark(c->entry_buffer, &start, mark_start); 1528 gtk_text_buffer_get_iter_at_mark(c->entry_buffer, &start, mark_start);
1534 gtk_text_iter_backward_chars(&start, strlen(post)); 1529 gtk_text_iter_backward_chars(&start, strlen(post));
1535 gtk_text_buffer_place_cursor(c->entry_buffer, &start); 1530 gtk_text_buffer_place_cursor(c->entry_buffer, &start);
1536 } 1531 }
1537
1538 /* if (convo_options & OPT_CONVO_CHECK_SPELLING) {
1539 gtkspell_attach(GTK_TEXT(entry));
1540 }*/
1541 1532
1542 gtk_widget_grab_focus(c->entry); 1533 gtk_widget_grab_focus(c->entry);
1543 } 1534 }
1544 1535
1545 void advance_past(struct conversation *c, char *pre, char *post) 1536 void advance_past(struct conversation *c, char *pre, char *post)
2900 g_signal_connect(G_OBJECT(c->entry_buffer), "insert_text", 2891 g_signal_connect(G_OBJECT(c->entry_buffer), "insert_text",
2901 G_CALLBACK(insert_text_callback), c); 2892 G_CALLBACK(insert_text_callback), c);
2902 g_signal_connect(G_OBJECT(c->entry_buffer), "delete_range", 2893 g_signal_connect(G_OBJECT(c->entry_buffer), "delete_range",
2903 G_CALLBACK(delete_text_callback), c); 2894 G_CALLBACK(delete_text_callback), c);
2904 2895
2905 /* if (convo_options & OPT_CONVO_CHECK_SPELLING) 2896 #ifdef USE_GTKSPELL
2906 gtkspell_attach(GTK_TEXT(c->entry));*/ 2897 if (convo_options & OPT_CONVO_CHECK_SPELLING)
2898 gtkspell_new_attach(GTK_TEXT_VIEW(c->entry), NULL, NULL);
2899 #endif
2900
2907 gtk_container_add(GTK_CONTAINER(frame), GTK_WIDGET(entry)); 2901 gtk_container_add(GTK_CONTAINER(frame), GTK_WIDGET(entry));
2908 gtk_widget_show(entry); 2902 gtk_widget_show(entry);
2909 2903
2910 c->bbox = bbox = gtk_hbox_new(FALSE, 5); 2904 c->bbox = bbox = gtk_hbox_new(FALSE, 5);
2911 gtk_box_pack_start(GTK_BOX(vbox2), bbox, FALSE, FALSE, 0); 2905 gtk_box_pack_start(GTK_BOX(vbox2), bbox, FALSE, FALSE, 0);
2999 } 2993 }
3000 2994
3001 2995
3002 void toggle_spellchk() 2996 void toggle_spellchk()
3003 { 2997 {
2998 #ifdef USE_GTKSPELL
3004 GList *cnv = conversations; 2999 GList *cnv = conversations;
3005 GSList *cht; 3000 GSList *cht;
3006 struct conversation *c; 3001 struct conversation *c;
3007 GSList *con = connections; 3002 GSList *con = connections;
3008 struct gaim_connection *gc; 3003 struct gaim_connection *gc;
3009 3004 GtkSpell *spell;
3010 if (convo_options & OPT_CONVO_CHECK_SPELLING){ 3005
3011 /*If ispell fails to start, start aspell. This is the way that
3012 Gabber does it. -- lorien420@myrealbox.com */
3013 if (gtkspell_start(NULL, ispell_cmd)<0){
3014 debug_printf("gtkspell failed to start when using ispell\n");
3015 if (gtkspell_start(NULL, aspell_cmd)<0){
3016 debug_printf("gtkspell failed to start when using aspell\n");
3017 } else
3018 debug_printf("gtkspell started with aspell\n");
3019 } else {
3020 debug_printf("gtkspell started with ispell\n");
3021 }
3022 }
3023
3024 while (cnv) { 3006 while (cnv) {
3025 c = (struct conversation *)cnv->data; 3007 c = (struct conversation *)cnv->data;
3026 /* if (convo_options & OPT_CONVO_CHECK_SPELLING) 3008 if (convo_options & OPT_CONVO_CHECK_SPELLING) {
3027 gtkspell_attach(GTK_TEXT(c->entry)); 3009 gtkspell_new_attach(GTK_TEXT_VIEW(c->entry), NULL, NULL);
3028 else 3010 } else {
3029 gtkspell_detach(GTK_TEXT(c->entry));*/ 3011 spell = gtkspell_get_from_text_view(GTK_TEXT_VIEW(c->entry));
3012 gtkspell_detach(spell);
3013 }
3030 cnv = cnv->next; 3014 cnv = cnv->next;
3031 } 3015 }
3032 3016
3033 while (con) { 3017 while (con) {
3034 gc = (struct gaim_connection *)con->data; 3018 gc = (struct gaim_connection *)con->data;
3035 cht = gc->buddy_chats; 3019 cht = gc->buddy_chats;
3036 while (cht) { 3020 while (cht) {
3037 c = (struct conversation *)cht->data; 3021 c = (struct conversation *)cht->data;
3038 /* if (convo_options & OPT_CONVO_CHECK_SPELLING) 3022 if (convo_options & OPT_CONVO_CHECK_SPELLING) {
3039 gtkspell_attach(GTK_TEXT(c->entry)); 3023 gtkspell_new_attach(GTK_TEXT_VIEW(c->entry), NULL, NULL);
3040 else 3024 } else {
3041 gtkspell_detach(GTK_TEXT(c->entry));*/ 3025 spell = gtkspell_get_from_text_view(GTK_TEXT_VIEW(c->entry));
3026 gtkspell_detach(spell);
3027 }
3042 cht = cht->next; 3028 cht = cht->next;
3043 } 3029 }
3044 con = con->next; 3030 con = con->next;
3045 } 3031 }
3046 3032 #endif
3047 if (!(convo_options & OPT_CONVO_CHECK_SPELLING))
3048 gtkspell_stop();
3049 } 3033 }
3050 3034
3051 void toggle_timestamps() 3035 void toggle_timestamps()
3052 { 3036 {
3053 GList *cnv = conversations; 3037 GList *cnv = conversations;