Varad
Varad

Reputation: 145

GtkNotebook: Appending to the Default Popup Menu

Is there a way to append a menu item to the popup menu that appears by default on right-clicking a GtkNotebook's tab (the one that contains the names of all the open tabs)?

Upvotes: 3

Views: 206

Answers (2)

unwind
unwind

Reputation: 399793

As a somewhat gross hack, it might be possible to use gtk_notebook_get_menu_label() to get the GtkLabel in one of the tab's menu items on that menu, and then use parent-walking from there to find the menu.

Possibly this only works when the menu is being realized/shown, you could try adding event handlers on that label to detect that.

On the other hand, user4815162342's suggestion of re-implementing the menu is way easier.

Upvotes: 1

user4815162342
user4815162342

Reputation: 154886

Looking at the source code, it would appear that there is no way to append to the existing menu: the menu is kept in a private structure, and it is popped up directly on button-press event.

You can disable the default menu, connect to button-press event, and popup your own menu.

Upvotes: 1

Related Questions