tags:

views:

310

answers:

2

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+?

A: 

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.

anthony
Thank you very much. Haven't done much with Gdk drawing stuff -- that's pretty nasty but it works.
c4757p
gdk drawing is the fun part!
anthony
A: 

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.
luiscubal
I already thought of that, but it's fugly.
c4757p