hai I have a problem with textview. I want to replace the characters in a gtktextview after checking some condition. ie when i press "A" the displayed character will be H. But in the case of textview i enter the all code to rplace the character, but it will print both characters "AH" ie the actual one and the mapped one. I place the code bellow. any replay will very thankful to you. I want to build an editor in regional language. I think some problem in iteration. It will not correctly initialize. With Regards Manoj ######################################### #include <gtk/gtk.h> PangoFontDescription *font_kar; GtkTextView *textview1; GtkTextBuffer *Buf; GtkTextIter IterCur, IterSel, IterEnd; GtkTextMark *MarkCur, *MarkSel; static gboolean delete_event( GtkWidget *widget, GdkEvent *event, gpointer data ) { gtk_main_quit (); return FALSE; } gboolean on_textview1_realize (GtkWidget *widget, GdkEventKey *event, gpointer user_data) { font_kar = pango_font_description_from_string("Sans 16"); textview1=GTK_TEXT_VIEW(widget); gtk_widget_modify_font(GTK_WIDGET(textview1),font_kar); Buf = gtk_text_view_get_buffer (GTK_TEXT_VIEW(textview1)) ; gtk_widget_grab_focus(GTK_WIDGET(textview1)); MarkCur = gtk_text_buffer_get_mark ( Buf, "insert" ) ; gtk_text_buffer_get_iter_at_mark ( Buf, &IterCur, MarkCur ) ; } gboolean on_textview1_key_press_event (GtkWidget *widget, GdkEventKey *event, gpointer user_data) { int Pos,SelPos; gchar *fchar; Buf = gtk_text_view_get_buffer( GTK_TEXT_VIEW( widget)) ; MarkCur = gtk_text_buffer_get_insert(Buf); gtk_text_buffer_get_iter_at_mark ( Buf, &IterCur,MarkCur ) ; gtk_text_buffer_get_iter_at_offset(Buf,&IterEnd,-1); switch (event->keyval) { case 65: // 'A' gtk_text_buffer_insert( Buf,&IterCur,"H",-1); // gtk_text_buffer_insert( Buf,&IterCur,"m",-1); gtk_text_buffer_get_iter_at_offset(Buf,&IterEnd,gtk_text_iter_get_offset(&IterCur)-1); //gtk_text_buffer_delete(Buf,&IterCur,&IterEnd); break; } return FALSE; } int main( int argc, char *argv[] ) { gtk_init (&argc, &argv); GtkWidget *window1; GtkWidget *scrolledwindow1; GtkWidget *textview1; window1 = gtk_window_new (GTK_WINDOW_TOPLEVEL); gtk_widget_set_name (window1, "window1"); gtk_window_set_title (GTK_WINDOW (window1), ("window1")); scrolledwindow1 = gtk_scrolled_window_new (NULL, NULL); gtk_widget_set_name (scrolledwindow1, "scrolledwindow1"); gtk_widget_show (scrolledwindow1); gtk_container_add (GTK_CONTAINER (window1), scrolledwindow1); textview1 = gtk_text_view_new (); gtk_widget_set_name (textview1, "textview1"); gtk_widget_show (textview1); gtk_container_add (GTK_CONTAINER (scrolledwindow1), textview1); gtk_widget_set_size_request (textview1, 300, 400); g_signal_connect ((gpointer) textview1, "realize", G_CALLBACK (on_textview1_realize), NULL); g_signal_connect ((gpointer) textview1, "key_press_event", G_CALLBACK (on_textview1_key_press_event), NULL); g_signal_connect ((gpointer) window1, "delete_event", G_CALLBACK (delete_event), NULL); /* Rest in gtk_main and wait for the fun to begin! */ gtk_widget_show (window1); gtk_main (); return 0; } -- ______________________________________________ Check out the latest SMS services @ http://www.linuxmail.org This allows you to send and receive SMS through your mailbox. Powered by Outblaze _______________________________________________ gtk-list@xxxxxxxxx http://mail.gnome.org/mailman/listinfo/gtk-list