[Vala] How to subclass a Gtk.Label?



Hi,

I tried to subclass a Label, but the program will crash:

---------------------------------------------------------
using Gtk;

public class MyLabel : Label {

        public MyLabel () {
                this.text = "Subclassed Label";
        }
}

static int main (string[] args) {
        Gtk.init (ref args);
        var window = new Window (WindowType.TOPLEVEL);
        var label = new MyLabel ();
        window.add (label);
        window.show_all ();
        Gtk.main ();
        return 0;
}
---------------------------------------------------------

It also doesn't work if I use 'construct { ... }' instead.
In the vapi file the Label is annotated with

  [CCode (type = "GtkWidget*", has_construct_function = false)]

Strangely, the program crashes on adding the widget.
Is there any way to subclass a Label at all?


Regards,

Frederik



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