[Gtk-sharp-list] Custom (subclassed) widget fails to show up in
Glade based application
Sebastian
scut at nb.in-berlin.de
Sat Oct 15 06:49:53 EDT 2005
Hello everybody,
I use a .glade file to load all main parts of the GUI, including a few
tabs. As I need the same TreeView in some of the tabs, I manually wrote
a subclass, looking like this:
public class
MyListView : Gtk.ScrolledWindow
{
private TreeView tv;
public MyListView ()
: base ()
{
tv = new TreeView ();
// ... do TreeView initialization, populate treeview, etc.
tv.WidthRequest = 240;
WidthRequest = 250;
Child = tv;
}
}
In Glade, I have constructed a HPaned in one tab and a VBox in another
tab. In the VBox I just put one label, and the HPaned I left empty on
the left side.
The main program initialization is this:
private void Init ()
{
Glade.XML gxml = new Glade.XML ("myprogram.glade",
"MainWindow", null);
gxml.Autoconnect (this);
/* Setup the view tree
*/
MyListView mlv = new MyListView ();
tab1Pane.Pack1 (mlv, true, false);
tab2VBox.PackEnd (mlv);
// **A
}
Using this starts up the GUI but leaves the HPaned empty and the VBox
with just the label. I tried inserting a "mlv.Show ()" and "mlv.Realize
()" at the **A marked place, but it failed, giving the error message:
(<unknown>:6496): Gtk-CRITICAL **: gtk_widget_realize: assertion
`GTK_WIDGET_ANCHORED (widget) || GTK_IS_INVISIBLE (widget)' failed
I am at loss about Gtk internals and did not find a single example of
how to properly setup a subclassed custom widget with a glade-based
application (I have used manual subclassing in non-glade gtk# apps
successfully).
What do I miss?
Thanks,
Sebastian
More information about the Gtk-sharp-list
mailing list