Re: Visual bug in gtk_widget_set_sensitive() / GtkOptionMenu




Dave Cole <dave@dccs.com.au> writes:

> I upgraded to gtk+-1.1.5 tonight and have noticed a bug in
> gtk_widget_set_sensitive() or GtkOptionMenu, I am not sure which.

[...]

> Now it seems that the way that GtkOptionMenu works is subverting the
> operation of gtk_widget_set_sensitive().  The last time I looked at
> the source, the option menu displayed the current selection by
> re-parenting the contents of the active menu item.  This means that
> setting the sensitivity of the currently selected menu item will not
> work as expected - its' contents are no longer there!
> 
> I worked around it in my application by doing this all of the time...
> 
>     gtk_widget_set_sensitive(GTK_BIN(elem_option)->child, TRUE);
> 
> I would suggest that this is sub-optimal.

Well, if you want to work on a patch, here's an approach that
I think will work. (Tim might be able to answer more authoritatively,
since he's worked on that code more recently than me)

 * When the current menu item is set, connect to "state_changed"
   on the menu item.

 * when "state_changed" is received, if the old state is
   not GTK_STATE_INSENSITIVE and the current state is
   GTK_STATE_INSENSITIVE, call gtk_widget_set_sensitive (widget, FALSE)

 * when "state_changed" is received, if the old state is
   GTK_STATE_INSENSITIVE and the current state not GTK_STATE_INSENSITIVE, 
   call gtk_widget_set_sensitive (widget, TRUE)

I'm however, not really sure it makes sense for an insensitive
item to be displayed as the current item of a sensitive
option menu... since insensitivity means "cannot be selected".

                                        Owen



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