Re: MenuItem callback weirdness - partial answer
- From: Patrice St-Gelais <patrice st-gelais oricom ca>
- To: "gtk-app-devel-list gnome org" <gtk-app-devel-list gnome org>
- Subject: Re: MenuItem callback weirdness - partial answer
- Date: Wed, 11 Sep 2002 00:43:18 -0400
Hi all,
I finally solved the problem, at least in part: an option menu is a kind
of button to which a menu is linked. The active label is "borrowed" by the
option menu button from the menu item. So a callback function like this
does the job, connected to the "activate" signal of each menu item - the
option menu widget must be embedded in the data:
void omenu_callb(GtkWidget *wdg, gpointer data) {
gchar *label;
my_struct *str;
str = (my_struct *) data;
if (!GTK_IS_LABEL(GTK_BIN(str->omenu)->child))
// First call, after we have set the option menu with a given value,
already in str->some_allocated_string
return;
gtk_label_get(GTK_LABEL(GTK_BIN(str->omenu)->child), &label);
strcpy(str->some_allocated_string,label);
}
I wonder why we shouldn't be able to connect the function to the option
menu globally, but I was not able to find a working signal. Button signals
("clicked", "realeased"), in the option menu hierarchy, don't seem to work.
______________
Patrice St-Gelais a écrit :
Hi all,
I'm developping with Gtk 1.2.x. I connect a callback function to each
menu item of an option menu. The function extracts the label of the last
selected menu item.
The function looks like this:
void omenu_callb(GtkWidget *wdg, gpointer data) {
gchar *label;
my_struct *str;
str = (my_struct *) data;
if (!GTK_CHECK_MENU_ITEM(wdg)->active)
return;
gtk_label_get(GTK_LABEL(GTK_BIN(wdg)->child), &label);
strcpy(str->some_allocated_string,label);
}
It works the first time the callback is executed, when I set the default
option. But at each subsequent call, GTK_BIN(wdg)->child is NULL.
GTK_IS_MENU_ITEM(wdg) is always TRUE, though, and "wdg" is the right
MenuItem (the widget address is the same for the same choice).
....
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]