Search code examples
c++gtkgtkmm

How to collapse Gtkmm notebook tabs?


So I am making a Gtkmm application using a Gtk::notebook and during run-time I'm adding new tabs to the notebook. But when I add more tabs than there is space on my screen it just keeps going moving out of the screen.

Now I know most Gtk widgets have a lot of properties that can be configured, so I'am wondering is there such a property for notebook that automatically collapses tabs or scales them in some way to make it fit inside the widget/screen.

If not it would be great if you could give me some pointers to how to implement this functionality myself.


Solution

  • set_scrollable() is your best bet. It will add scrolling arrows on the sides of the tab labels at the top when there isn't enough room to show them all.

    Note that GtkNotebook will always ask for enough space to show the contents of all tabs, not just the one that's currently visible. If one of your tab pages is really big (say, contains a 10x10 grid of 100x100 buttons), you won't be able to resize the GtkNotebook smaller than that tab page (in that case, 1000x1000 + the height of the label area), even if the current tab page is just an empty container. All set_scrollable() will do is let you resize smaller than the width needed to show all tab labels at the top.