Gray out a menu item Edit/copy etc

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Gray out a menu item Edit/copy etc

Ian Chapman

Hi, I have some GtkMenuItem in my .glade file and I removed the tick in Sensitive flag.  The item is grayed out, good.  Now I need to turn it on/off so that I can use/disable it.  Looking at the Gtk3 manual I am not able to find any reference to sensitive.

A search on the internet gave

menuOpen->set_sensitive(false);

To re-enable the menu item:

menuOpen->set_sensitive();

but I am not able to determine what this is about or if it is up-to-date or how to apply it.  Any ideas there?

Also GtkImageMenuItem is still in glade-3-18-3 but Gtk tell me that it has been depreciated since 3.10.  I got it from the Edit/Hierarchy.  But it looks okay.  Should I change it to GtkMenuItem?  Regards Ian.


_______________________________________________
gtk-list mailing list
[hidden email]
https://mail.gnome.org/mailman/listinfo/gtk-list
Reply | Threaded
Open this post in threaded view
|

Re: Gray out a menu item Edit/copy etc

Stefan Salewski-2
On Thu, 2017-04-06 at 19:52 -0400, Ian Chapman wrote:
> Now I need to turn it on/off so that I can use/disable it.

For GTK3 we have

https://developer.gnome.org/gtk3/stable/GtkWidget.html#gtk-widget-set-sensitive

So there should be a similar function available for your programming
language.

Of course you need a reference to your menu item to pass to that
function. Is that your real problem, the missing reference because your
use of glade?
_______________________________________________
gtk-list mailing list
[hidden email]
https://mail.gnome.org/mailman/listinfo/gtk-list
Reply | Threaded
Open this post in threaded view
|

Re: Gray out a menu item Edit/copy etc

Ian Chapman
In reply to this post by Ian Chapman
On 04/07/17 03:25, Stefan Salewski wrote:

> On Thu, 2017-04-06 at 19:52 -0400, Ian Chapman wrote:
>> Now I need to turn it on/off so that I can use/disable it.
> For GTK3 we have
>
> https://developer.gnome.org/gtk3/stable/GtkWidget.html#gtk-widget-set-sensitive
>
> So there should be a similar function available for your programming
> language.
>
> Of course you need a reference to your menu item to pass to that
> function. Is that your real problem, the missing reference because your
> use of glade?
>
Thanks Stefan,  I've got it now.  I should be looking at widgets and I
guess all the widget stuff applies to all and sundry that is derived
from widget.

// Variable declarations

     GtkWidget    *name; //name refs File/Open or Edit/copy etc

// In builder stuff added

     name = GTK_WIDGET (gtk_builder_get_object (builder, "Open")); // if
called Open in Glade.

// In program (the part that's actually executed).

     gtk_widget_set_sensitive(name, FALSE); // or TRUE as needed

Thanks a million, it's working great. Regards Ian.

_______________________________________________
gtk-list mailing list
[hidden email]
https://mail.gnome.org/mailman/listinfo/gtk-list