c4757p
c4757p

Reputation: 1808

GtkNotebook add-tab button

Is it possible in Gtk+ to have an add-tab button inline with the tabs in a notebook, ala Opera or Google Chrome? I do know that Opera uses Qt and Chrome uses custom tabs, but is it possible in pure Gtk+?

Upvotes: 1

Views: 1650

Answers (2)

luiscubal
luiscubal

Reputation: 25121

Well, if it is not possible, there is a simple workaround:

  • Create a tab with the title "New Tab" or "+" or whatever
  • Detect when the tab is selected and, when such happens, create a new tab. Focus on that new tab so that the "New tab" tab isn't ever selected.

Upvotes: 3

anthony
anthony

Reputation: 41098

Sure. Check out the class BrandedNotebook at line 1384 of this file.

Unfortunately Gtk+ doesn't give you a "nice" way to do this, but you should be able to determine the amount of space available, and use it as you wish. In the case of BrandedNotebook, a pixbuf is drawn in the space, and mouse clicks are handled within the coordinates of the pixbuf.

Upvotes: 2

Related Questions