Re: [gtk-list] GtkMenuItem sensitivity and accelerator callbacks



On Wed, 17 Mar 1999, Alexander Larsson wrote:

> I have have some problems with menu item sensitivity and accelerator
> callbacks in my application Dia. I have most operations in a pull-down
> menu (like the Gimp). Some of the menu items in that menu are insensitive
> when you pull it down depending on the state of the diagram. Stuff like:
> Copy/Cut/Delete are only sensitive if some object is selected.
> 
> Now, these sensitivities are set by a call to
> display_set_menu_sensitivity() just before the menu is poped-up each time
> the right mouse button is pressed. This works great, until you try to use
> the keyboard accelerators in the menu. These are of course also made
> sensitive just like the menu items, but as the sensitivity is only changed
> when pulling down the menu they don't work well if the diagram state is
> changed and the menu hasn't been pulled down.
> 
> Anyone know of any solutions for this? (I'd rather not call
> display_set_menu_sensitivity() after each change of diagram state)

if the menu is not popped up, the corresponding gtk_widget_set_sensitive()
call is actually a pretty cheap one (i.e. it doesn't involve Xserver traffic),
it'll just set a new state and propagate that to the menu item's child.

the only other viable alternative is to block/unblock your signal handlers
if you know they shouldn't get called for a certain while.


> Is
> there some way to get a callback before each accelerator callback?

nope, because accelerators are not simple callbacks but merely trigger
certain signal emissions on the accel widget.

> 
> / Alex
> 

---
ciaoTJ



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