(maybe a)Bug in GtkOptionMenu & GtkMenu & GtkMenuItem



-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hi,

i'm having trouble with gtkoptionmenu while gathering "string" contents
of a MenuItem.

My string gatherer func is simple:
char *get_option_menu_string(GtkWidget *option)
{
~    gchar *string;
~    GtkWidget *menu = gtk_option_menu_get_menu(GTK_OPTION_MENU(option));
~    GtkWidget *item = gtk_menu_get_active(GTK_MENU(menu));
~    GtkWidget *child = GTK_BIN(item)->child;
~    gtk_label_get(GTK_LABEL(child), &string);
~    return string;

}

and the func that creates option menu with items is :

- ------Cut--------
GtkWidget *option, *menu, *item;
int selected = 1;
gchar *service[] = { "item1", "item2" , "item3" };

gtk_option_menu_remove_menu(GTK_OPTION_MENU(option));
menu = gtk_menu_new ();
gtk_option_menu_set_menu (GTK_OPTION_MENU (option), menu);

for (i=0;i<MAX_ITEM; i++) {
item = gtk_menu_item_new_with_label(service);
gtk_menu_shell_append(GTK_MENU_SHELL (menu), item);
gtk_widget_show (item);
}

if (selected > 0) {
~    //gtk_option_menu_set_history(GTK_OPTION_MENU(option), selected);
~    //gtk_menu_set_active(GTK_MENU(menu), selected);
}

//gtk_option_menu_set_menu (GTK_OPTION_MENU (option), menu);
- ------Cut--------


Problem description:

After i set the history via gtk_option_menu_set_history() or
menu_set_active(), i
try to get the label of the item. But, GtkWidget *child =
GTK_BIN(item)->child;
return NULL. When i debug it, i saw that item->child is 0x0 mean NULL.

If i do not set the history/active item, my label gatherer func returns
me correctly
the *first* item's string. Moreover, when i manually changed the active
item,
item->child is set to 0x0 again.

I think there is bug in these funcs but i dunno in which. It is maybe
related to
bug no:66969 but i'm not sure.

I've also tried to set menu after setting the menu history(menu_set_active)
but nothing changed.

As far as i know, this was working in gtk+1.2.

Using Gtk 2.2.1 btw.

Thnx.
Evrim.
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.1 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iD8DBQE+mQL86+aEfy4lqIARAnazAKC3eoEunsUycjt/XWAYWzLfabAX9QCeP4lF
lyiVY5KI3V8AmrQGKVkU5bk=
=cpv/
-----END PGP SIGNATURE-----




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