Using inherited window with GtkBuilder



Hello!

I'm trying to use my custom GtkWindow class (call it MyWindow) with
GtkBuilder, but I'm not sure how to do that.

I want to get an object of class MyWindow from the GtkBuilder object.
So, I tried to set the "class" attribute to "MyWindow" in my XML file
and cast to MyWindow when I use the get_object method from GtkBuilder.

This example code (in Vala, witch is the programming language used for
my application) throw an exception with the message "Invalid object type
`MyWindow'".

try{
    var builder = new Builder();
    builder.add_from_file("mygui.ui");
    var window = builder.get_object("mainwindow") as MyWindow;
    window.start();

    Gtk.main();
} catch(Error e){
    stderr.printf(e.message);
}

Am I losing something?

Thanks in advance!


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