Re: MENU !



Anita Dixit wrote:
> I need to enable or disable the menu items depending upon the variable
> values present in the application.
> 
> Now is there anything similar to UPDATE_COMMAND_UI (MFC mechanism)
> present in gtk or some  similar method of keeping track of variables and
> making the menu items active?

Hi Anita, there are lots of ways of doing this, it depends how 
complicated your needs are.

The easy technique is to make a function to set the variable, and add 
stuff to the function to change the menu state. Eg.

static void
set_speed( int speed )
{
   GtkWidget *item =
     gtk_item_factory_get_widget( menu_bar, "/Edit/Warp" );

   global_speed = speed;

   if( global_speed < 10 )
     gtk_widget_set_sensitive( item, TRUE );
   else
     gtk_widget_set_sensitive( item, FALSE );
}

Now every time you want to set the variable, call set_speed() instead.

For more complicated things, you should probably use some sort of 
model-view structure.

HTH, J







========================================================== 
Fabric of Vision 
Dress and Drapery in Painting 

19 June - 8 September 2002 

For information and tickets: 
http://www.nationalgallery.org.uk/exhibitions/fabric/



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