OptionMenu and sensitivity puzzle
- From: "Karl H. Beckers" <karl h beckers gmx net>
- To: gtk-app-devel-list gnome org
- Subject: OptionMenu and sensitivity puzzle
- Date: Thu, 15 Jul 2004 18:13:53 +0200
Hi all,
I have this puzzling problem with an option menu, and though I've found a
vaguely related thread from 1998 the issue at the time was different enough
to make the workaround not applicable for me
(http://mail.gnome.org/archives/gtk-devel-list/1998-November/msg00131.html)
Alright, let's say I have three widgets (1) a text entry field, (2) a
check button, and
(3) an option menu. If (2) is unchecked the user can pick a value from
(3). If (2)
is checked, the value for (3) is set to a default value calculated on
the base of
whatever is entered in (1).
In other words: I have an event handler connected to the changed signal
of (1)
which updates (3) if (2) is checked and the text entered in (1)
indicates (3) should
be set to smth. different.
This far everything works well.
Now, if I check (2), (3) gets set insensitive. If I enter some text in
(1) now, triggering
some changes to the insensitive (3), then uncheck (2) which makes (3)
sensitive
again, and open the optionmenu, all the items of (3) that had been
selected while
(3) was insensitive are still grayed out except for the last, i.e. the
current one.
Apparently, due to the reparenting mechanism with which the optionmenu
displays
the label of the menuitem, all the menuitems which were selected while
the optionmenu
was insensitive were made insensitive, too. However, only the currently
parented label
gets set sensitive again. (Note that I can actually select all the
menuitems, they are
just painted grayed out.)
I would be more than willing to work around this, but can't seem to be
able. I tried:
// event handler connected to the toggled signal of (2)
static void
on_sf_format_auto_check_toggled (GtkToggleButton *togglebutton, gpointer
user_data) {
if ( gtk_toggle_button_get_active ( togglebutton ) ) {
GtkWidget *menu =
gtk_option_menu_get_menu(GTK_OPTION_MENU(sf_format_optionmenu));
GList *list = GTK_MENU_SHELL(menu)->children;
gtk_widget_set_sensitive ( sf_format_optionmenu, FALSE );
} else {
GtkWidget *menu =
gtk_option_menu_get_menu(GTK_OPTION_MENU(sf_format_optionmenu));
GtkMenuItem *item;
GtkObject *label;
GList *list = GTK_MENU_SHELL(menu)->children;
int i;
gtk_widget_set_sensitive ( sf_format_optionmenu, TRUE );
for ( i = 0; i < g_list_length(list); i++ ) {
item = GTK_MENU_ITEM(g_list_nth_data(list, i));
gtk_menu_item_activate(item);
gtk_widget_set_sensitive( GTK_WIDGET(item), TRUE );
label = GTK_OBJECT(gtk_bin_get_child(GTK_BIN(item)));
printf("label: %s - pointer: %p\n",
gtk_label_get_label(GTK_LABEL(label)), label);
if ( label != NULL ) {
printf("setting label active\n");
gtk_widget_set_sensitive ( label, TRUE );
}
}
}
This doesn't have any discernible effect, though.
Any insights would be much appreciated.
Karl.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]