bug in gtk_entry / gtk_editable
- From: "Zvi Sebrow" <zvi sebrow verizon net>
- To: <gtk-app-devel-list gnome org>
- Subject: bug in gtk_entry / gtk_editable
- Date: Mon, 18 Oct 2004 08:36:15 -0400
Hi,
I have the following test program that I believe illustrates a bug in gtk_entry/gtk_editable,
at least on Windows XP (I dont currently have access to X11, so I dont know if it is the same).
When the user types in "ABC" the BC should then be selected, but they arent! When the user
then types a "D" and then backspaces, deleting the "D", the "BC" are selected. But as the output
from the program shows, gtk_editable_select_region() is called both times, but only functions the
second time.
gtk_editable_select_region() seems to only work when it is called in the changed_text hanlder
only after a character deletion, but not after an insertion. Am I doing something wrong, or is
this a bonafide bug?
Thanks,
Zvi
----------------------------------------------------------------------------
#include <gtk/gtk.h>
void changed_text_handler(GtkEditable *editable, gpointer data)
{
gchar *text;
gint s, e;
gboolean b;
text = gtk_editable_get_chars(editable, 0, -1);
g_print("changed_text_handler() - etext = \"%s\"\n", text);
if (!strcmp(text, "ABC"))
{
gtk_editable_select_region(editable, 1, 3);
b = gtk_editable_get_selection_bounds(editable, &s, &e);
g_print("gtk_editable_get_selection_bounds() = %d, s=%d, e=%d\n",
b, s, e);
}
g_free(text);
}
int main(int argc, char **argv)
{
GtkWidget *frm_main, *entry;
gtk_init(&argc, &argv);
frm_main = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_window_set_title(GTK_WINDOW(frm_main),"ENTRY test");
g_signal_connect (G_OBJECT(frm_main), "destroy",
G_CALLBACK (gtk_widget_destroyed), NULL);
entry = gtk_entry_new();
g_signal_connect(G_OBJECT(entry), "changed",
G_CALLBACK(changed_text_handler), NULL);
gtk_container_add(GTK_CONTAINER(frm_main), entry);
gtk_widget_show_all(frm_main);
gtk_main();
return 0;
}
--------------------------------------------------------------------------------------------------------------
OUTPUT FROM g_print():
changed_text_handler() - etext = "A"
changed_text_handler() - etext = "AB"
changed_text_handler() - etext = "ABC"
gtk_editable_get_selection_bounds() = 1, s=1, e=3
changed_text_handler() - etext = "ABCD"
changed_text_handler() - etext = "ABC"
gtk_editable_get_selection_bounds() = 1, s=1, e=3
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]