Possible bug in GtkText..



  There seems to be a bug in the "gtk_text_set_point" routine for the
GtkText widget. I hope this is not a known "feature" or a FAQ (the
mailing list archive is difficult to browse without a search
engine)...
  I use the just released libgtk+-1.0.0. What I want to do is word
autocompletion with the TAB key, but when I want to put the edition
point just after the inserted word, it does not move.

  There is a small program highlighting the bug...

#include <gtk/gtk.h>

GtkWidget *text;

void test(GtkWidget *widget, gpointer data)
{
  g_print("%d - ", gtk_text_get_point(GTK_TEXT(text)));
  gtk_text_set_point(GTK_TEXT(text), 0);
  g_print("%d\n", gtk_text_get_point(GTK_TEXT(text)));
}

int main (int argc, char *argv[])
{
  GtkWidget *window, *button, *vbox;

  gtk_init (&argc, &argv);
  window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  vbox = gtk_vbox_new(FALSE, 0);
  text = gtk_text_new (NULL, NULL);
  gtk_text_set_editable (GTK_TEXT(text), TRUE);
  gtk_signal_connect (GTK_OBJECT (text), "changed",
		      GTK_SIGNAL_FUNC (test), NULL);
  gtk_box_pack_start (GTK_BOX(vbox), text, TRUE, TRUE, 0);
  button = gtk_button_new_with_label("Foo");
  gtk_signal_connect (GTK_OBJECT (button), "clicked",
		      GTK_SIGNAL_FUNC (test), NULL);
  gtk_box_pack_start (GTK_BOX(vbox), button, TRUE, TRUE, 0);
  gtk_container_add (GTK_CONTAINER (window), vbox);
  gtk_widget_show (text);
  gtk_widget_show (button);
  gtk_widget_show (vbox);
  gtk_widget_show (window);
  gtk_main ();
  
  return 0;
}

--
		 Lionel ULMER  -  ulmer@email.enst.fr
		 Now Reading : Slan (A. E. Van Vogt)
       My books : http://www.stud.enst.fr/~ulmer/gen_pages.cgi



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]