I am devoloping an app in gtkmm 2 and learning how to use tabs. Right now I have no idea whatsoever how to ad a frame or V_Box in the signature of the append-function that creates the actual tab.
m_Notebook.append_page(m_Label1, "First");
Here is an example of how to add a label, called m_label1. But what if I want to add a box that hold childitems such as entry-fields and other labels. How do I implement that?
ExampleWindow::ExampleWindow()
: m_Label1("Contents of tab 1"),
m_Label2("Contents of tab 2"),
m_Button_Quit("Quit")
{
set_title("Gtk::Notebook example");
set_border_width(10);
set_default_size(400, 200);
//MyButton myButton;
add(m_VBox);
//Add the Notebook, with the button underneath:
m_Notebook.set_border_width(10);
m_VBox.pack_start(m_Notebook);
m_VBox.pack_start(m_ButtonBox, Gtk::PACK_SHRINK);
m_ButtonBox.pack_start(m_Button_Quit, Gtk::PACK_SHRINK);
m_Button_Quit.signal_clicked().connect(sigc::mem_fun(*this,
&ExampleWindow::on_button_quit) );
//Add the Notebook pages:
//m_Notebook.append_page(m_Label1, "First");
m_Notebook.append_page(m_Label1, "First");
m_Notebook.append_page(m_Label2, "Second");
m_Notebook.signal_switch_page().connect(sigc::mem_fun(*this,
&ExampleWindow::on_notebook_switch_page) );
show_all_children();
}
ExampleWindow::~ExampleWindow()
{
}
void ExampleWindow::on_button_quit()
{
hide();
}
void ExampleWindow::on_notebook_switch_page(GtkNotebookPage* /* page */, guint page_num)
{
std::cout << "Switched to tab with index " << page_num << std::endl;
//You can also use m_Notebook.get_current_page() to get this index.
}
You just add the box instead of a label. For instance:
m_Notebook.append_page(first_box, "First");
And add the child widgets to that box.