There are several methods to create menu button:
- Connect the "clicked" or "toggled" signal of a button or toggle button to a callback that pops up a menu. For this method, we need to create a custom positioning function, which is to me a tedious work.
- Customize the GtkMenuToolButton by getting it's child and remove the button part as well as replacing the GtkArrow with another widget.
- Using GtkMenuBar.
Convert GtkMenuBar into Menu Button
This is the simplest way to create a menu button. Before this, I used the second method to come up with a menu button until I updated my Gnome installation to version 3.4 and found out Epiphany 3.4['s] way of implementing this. I don't know why am I so stupid to come up with that method? :(What the developer did, is just changing the style class of the GtkMenuBar into button style. That's all. As easy as that! >.<
Code (in python)
menub = Gtk.MenuBar()
onlyitem = Gtk.MenuItem()
onlyitem_child = Gtk.Button(label = "Menu")
onlyitem.add(onlyitem_child)
onlyitem_child = Gtk.Button(label = "Menu")
onlyitem.add(onlyitem_child)
menu = Gtk.Menu()
mitem1 = Gtk.MenuItem(label = "Item 1")
mitem2 = Gtk.MenuItem(label = "Item 2")
menu.insert(mitem1, 0)
menu.insert(mitem2, 1)
onlyitem.set_submenu(menu)
menub.insert(onlyitem, 0)
**UPDATE**
Since Gtk+ 3.6, a native menu button widget, GtkMenuButton has been added.