A #GtkMenu is a #GtkMenuShell that implements a drop down menu
consisting of a list of #GtkMenuItem objects which can be navigated
and activated by the user to perform application functions.
A #GtkMenu is most commonly dropped down by activating a
#GtkMenuItem in a #GtkMenuBar or popped up by activating a
#GtkMenuItem in another #GtkMenu.
A #GtkMenu can also be popped up by activating a #GtkComboBox.
Other composite widgets such as the #GtkNotebook can pop up a
#GtkMenu as well.
Applications can display a #GtkMenu as a popup menu by calling the
gtk.menu.Menu.popup function. The example below shows how an application
can pop up a menu when the 3rd mouse button is pressed.
static gint
my_popup_handler (GtkWidget *widget, GdkEvent *event)
{
GtkMenu *menu;
GdkEventButton *event_button;
g_return_val_if_fail (widget != NULL, FALSE);
g_return_val_if_fail (GTK_IS_MENU (widget), FALSE);
g_return_val_if_fail (event != NULL, FALSE);
// The "widget" is the menu that was supplied when// g_signal_connect_swapped() was called.
menu = GTK_MENU (widget);
if (event->type == GDK_BUTTON_PRESS)
{
event_button = (GdkEventButton *) event;
if (event_button->button == GDK_BUTTON_SECONDARY)
{
gtk_menu_popup (menu, NULL, NULL, NULL, NULL,
event_button->button, event_button->time);
return TRUE;
}
}
return FALSE;
}
CSS nodes
menu
├── arrow.top
├── <child>
┊
├── <child>
╰── arrow.bottom
The main CSS node of GtkMenu has name menu, and there are two subnodes
with name arrow, for scrolling menu arrows. These subnodes get the
.top and .bottom style classes.
A #GtkMenu is a #GtkMenuShell that implements a drop down menu consisting of a list of #GtkMenuItem objects which can be navigated and activated by the user to perform application functions.
A #GtkMenu is most commonly dropped down by activating a #GtkMenuItem in a #GtkMenuBar or popped up by activating a #GtkMenuItem in another #GtkMenu.
A #GtkMenu can also be popped up by activating a #GtkComboBox. Other composite widgets such as the #GtkNotebook can pop up a #GtkMenu as well.
Applications can display a #GtkMenu as a popup menu by calling the gtk.menu.Menu.popup function. The example below shows how an application can pop up a menu when the 3rd mouse button is pressed.
Connecting the popup signal handler.
Signal handler which displays a popup menu.
CSS nodes
The main CSS node of GtkMenu has name menu, and there are two subnodes with name arrow, for scrolling menu arrows. These subnodes get the .top and .bottom style classes.