[gtkmm] Confused with TabElem



I am trying to implement a dynamic notebook (adding and removing tabs to
a notebook during runtime).  I'm using the 'Notebook_Helpers::TabElem()'
approach to this, since this seems to be the best way to go about it
(?).  However, I am having trouble understanding the logic and usage of
TabElem().  Here is what I have so far:

Gtk::TextView *textview = Gtk::manage(new class Gtk::TextView());
Gtk::ScrolledWindow *scrolledwindow = Gtk::manage(new class
	Gtk::ScrolledWindow());
Gtk::Label *label = Gtk::manage(new class Gtk::Label("Test"));
Gtk::Image *image = Gtk::manage(new class
	Gtk::Image(Gtk::StockID("gtk-close"), Gtk::IconSize(4)));
Gtk::Button *button = Gtk::manage(new class Gtk::Button());
Gtk::HBox *hbox = Gtk::manage(new class Gtk::HBox(false, 0));

... Do stuff to initialize the above widgets,including the following 3
lines:

button->add(*image);  // This is a small close button
hbox->pack_start(*label, Gtk::PACK_SHRINK, 10);
hbox->pack_start(*button, Gtk::PACK_SHRINK, 0);

notebook1->pages().push_back(Gtk::Notebook_Helpers::TabElem(*scrolledwindow, *hbox));
show_all_children();
notebook1->set_current_page(-1);
-------------------------------------------------------------------------
Obviously I am doing this wrong.  When I test this code, the tab gets
added during runtime as expected, but none of the widgets that are
supposed to be inside of the tab page are there (including the hbox
containing my label and close button).  My question is, how do I use
TabElem to add pages that contain widgets?  Additionally, how do I
access widgets inside of the page later on?  I searched the archives,
and there doesn't seem to be much info on this.  Does anyone know of a
tutorial that is more extensive than the Gtkmm.org tutorial?  Any help
would be very appreciated.  I am new to Gtkmm, but am having fun
learning this library.  Any tips on my code is appreciated too. :)

Thanks in advance,
Dan




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]