Reputation: 612
I saw that rekonq's got a toolbar item named preferences like Chromium,which you click and a drop down menu appears!
How can i do something like that on my app? i presume its a gtk_toolbar_item with a gtk_menu placed when its clicked but how?
Upvotes: 1
Views: 2897
Reputation: 57880
In C, you can do this:
GtkToolItem *menubutton = gtk_menu_tool_button_new(NULL, NULL);
gtk_toolbar_insert(GTK_TOOLBAR(toolbar), menubutton, 1);
GtkWidget *menu = gtk_menu_new();
gtk_menu_tool_button_set_menu(GTK_MENU_TOOL_BUTTON(menubutton), menu);
GtkAction *action = gtk_action_new("dropdown-menu", "Dropdown", "Click me", GTK_STOCK_PREFERENCES);
gtk_action_connect_proxy(action, GTK_WIDGET(menubutton));
g_signal_connect(action, "activate", G_CALLBACK(popup_menu), menu);
...
void
popup_menu(GtkAction *action, GtkMenu *menu)
{
gtk_menu_popup(menu, NULL, NULL, NULL, NULL, 1, gtk_get_current_event_time());
}
Upvotes: 2