Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to disable/inactive some of the GtkMenu Items

Tags:

gtk

glade

I am trying to disable/inactive some of menu items under GTK+. I have created Menu In GTK+Glade under C, and on some external event I need to disable some of the menu options.

How can I do this?

like image 501
User7723337 Avatar asked Nov 10 '09 11:11

User7723337


4 Answers

You can use gtk_widget_set_sensitive(menuitem, true/false) to disable or enable the menu item widget.

Alternatively, if you used GtkUiManager and GtkAction to build the menu, use gtk_action_set_sensitive() instead.

like image 145
axel_c Avatar answered Dec 29 '22 18:12

axel_c


Using:

gtk_widget_set_sensitive (menuitem,FALSE); // to gray-out
gtk_widget_set_sensitive (menuitem,TRUE); //to enable
like image 43
spilver Avatar answered Dec 29 '22 18:12

spilver


Use with Vala + Gtk:

Gtk.Button play = new Gtk.Button.with_mnemonic("Play");
play.set_sensitive(false); // to gray-out
like image 44
anlijudavid Avatar answered Dec 29 '22 18:12

anlijudavid


There is also a checkbox inside Glade to disable the menu item:

Select your menu item --> Common --> Widget Flags --> Uncheck "Sensitive"

enter image description here

like image 21
manµ Avatar answered Dec 29 '22 20:12

manµ