PDA

View Full Version : [vala/gtk] Button with menu



Sublime Porte
February 23rd, 2010, 06:52 AM
Howdy,

Does anyone know if there's a button widget with a drop down menu available in gtk? Something like the QToolButton from Qt (with default behaviour, not the arrow). I am using genie/vala which I assume has all the standard gtk widgets available. Can't seem to find one in the documentation.

nowic
September 16th, 2010, 11:21 PM
Better late than never... ;-)

The widget is called Gtk.ComboBox:

http://valadoc.org/gtk+-2.0/Gtk.ComboBox.html



var chooser = new ComboBox.text ();
chooser.append_text ("First option");
chooser.append_text ("Second option");
chooser.changed.connect ((widget) => {
if (widget.get_active () == 0) {
// Do option 1
} else {
// Do option 2
}
});

SledgeHammer_999
September 17th, 2010, 12:32 PM
I think you're looking for GtkMenuToolButton (http://library.gnome.org/devel/gtk/stable/GtkMenuToolButton.html)