Hi Mike,
Looking at the appendPage() function, I get the impression that a Notebook tab can be pretty much any Widget. This seems to be borne out by a few discussions and examples I've read:
C# Gtk Notebook Tab Label with Close Button
PyGtk Notebook with Closeable Tabs
And a few others.
In these examples/discussions, a tab can be populated with a Box which, in turn, contains a Label and a Button.
But when I tried this in GtkD, even though everything looks right, tab switching is disabled. Any idea why?
// Description of example
import std.stdio;
import std.math;
import gtk.MainWindow;
import gtk.Main;
import gtk.Box;
import gtk.Widget;
import gtk.Notebook;
import gtk.Button;
import gtk.TextView;
import gtk.TextBuffer;
import cairo.Context;
import gtk.DrawingArea;
void main(string[] args)
{
TestRigWindow testRigWindow;
Main.init(args);
testRigWindow = new TestRigWindow();
Main.run();
} // main()
class TestRigWindow : MainWindow
{
string title = "Notebook Demo - Simple";
AppBox appBox;
this()
{
super(title);
addOnDestroy(&quitApp);
appBox = new AppBox();
add(appBox);
showAll();
} // this()
void quitApp(Widget widget)
{
string exitMessage = "Bye.";
writeln(exitMessage);
Main.quit();
} // quitApp()
} // class TestRigWindow
class AppBox : Box
{
bool expand = false, fill = false;
uint globalPadding = 10, localPadding = 5;
MyNotebook myNotebook;
this()
{
super(Orientation.VERTICAL, globalPadding);
myNotebook = new MyNotebook();
packStart(myNotebook, expand, fill, localPadding); // LEFT justify
} // this()
} // class AppBox
class MyNotebook : Notebook
{
PositionType tabPosition = PositionType.TOP;
string tabButtonOne = "Tab One", tabButtonTwo = "Tab Two", tabButtonThree = "Tab Three";
Button myTabButtonOne, myTabButtonTwo, myTabButtonThree;
int tabIndex;
MyTextView myTextViewOne, myTextViewTwo, myTextViewThree;
this()
{
super();
setTabPos(tabPosition);
myTabButtonOne = new Button(tabButtonOne);
myTextViewOne = new MyTextView("Now is the witness of our discontinent.");
tabIndex = appendPage(myTextViewOne, myTabButtonOne);
myTabButtonTwo = new Button(tabButtonTwo);
myTextViewTwo = new MyTextView("Four stores and seven pounds ago...");
tabIndex = appendPage(myTextViewTwo, myTabButtonTwo);
myTabButtonThree = new Button(tabButtonThree);
myTextViewThree = new MyTextView("Help me open yon cantelope.");
tabIndex = appendPage(myTextViewThree, myTabButtonThree);
} // this()
} // class MyNotebook
class MyTextView : TextView
{
TextBuffer textBuffer;
int width = 400, height = 350;
this(string content)
{
super();
setSizeRequest(width, height);
textBuffer = getBuffer();
textBuffer.setText(content);
} // this()
} // class MyTextView