Add tabs to Notebook at runtime, loaded from .glade file?
- From: Adam Nielsen <a nielsen shikadi net>
- To: gtkmm-list gnome org
- Subject: Add tabs to Notebook at runtime, loaded from .glade file?
- Date: Sat, 3 Jan 2015 09:00:08 +1000
Hi all,
I'm trying to create a tabbed interface (works a bit like a web
browser) but I want to design the content of each tab using Glade.
I have worked out that I need to store each tab in a different .glade
file so that I can load and parse that file each time I want to create a
new tab, otherwise I only get one set of widgets created whereas I want
independent instances of the widgets for each new tab.
However I am a bit stuck figuring out the correct way to add the newly
created widgets to the Gtk::Notebook instance.
If I tell Gtk::Builder::get_widget() to retrieve the root Gtk::Window
from the .glade file and add that as the new tab, it won't compile
because I have to pass a Gtk::Widget to Gtk::Notebook::append_page()
and I only have a Gtk::Window.
If I pick the top-most widget in the window instead (a Gtk::Box), then I
get a bunch of runtime errors:
Can't set a parent on widget which has a parent
gtkcontainer.c:858: container class `gtkmm__GtkWindow' has no child
property named `tab-expand'
gtkcontainer.c:858: container class `gtkmm__GtkWindow' has no child
property named `tab-fill'
gtkcontainer.c:858: container class `gtkmm__GtkWindow' has no child
property named `tab-label'
gtkcontainer.c:858: container class `gtkmm__GtkWindow' has no child
property named `menu-label'
gtkcontainer.c:858: container class `gtkmm__GtkWindow' has no child
property named `position'
Gtk:ERROR:gtkcontainer.c:3541:gtk_container_propagate_draw: assertion
failed: (gtk_widget_get_parent (child) == GTK_WIDGET (container))
Aborted (core dumped)
If I take the top-most widget and instead call reparent() on it, and
pass the Gtk::Notebook as the new parent then the new tab does show up
correctly, but then I can't control the tab's title.
Can someone please give me some hints about the correct way to
dynamically add tabs at runtime that have been loaded from .glade files?
Many thanks,
Adam.
[Date Prev][
Date Next] [Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]