Re: [Vala] Access the "klass" parameter of a class_init() function in vala with "static construct"



Hi,
I see you've found a solution. But see my comments below about the
"right thing".
                في س، 31-07-2010 عند 17:59 +0200 ، كتب Sébastien Wilmet:
Hello!

What I want to do is to implement a GtkAction derived class which sets
GtkActionClass:toolbar_item_type to GTK_TYPE_MENU_TOOL_BUTTON in its
class_init function.

public class MenuToolAction : Action
{
    static construct
    {
        toolbar_item_type = typeof (MenuToolButton);
    }

    public MenuToolAction (string name, string? label, string? tooltip,
string? stock_id)
    {
        GLib.Object (name: name, label: label, tooltip: tooltip, stock_id:
stock_id);
    }
}

But I have this error:
error: The name `toolbar_item_type' does not exist in the context of
`MenuToolAction'

Indeed, toolbar_item_type is not present in gtk+-2.0.vapi.

How do I add toolbar_item_type in gtk+-2.0.vapi? I've put this inside the
"public class Action" block:
protected GLib.Type toolbar_item_type;

But I have this error (same with public instead of protected):
error: Access to instance member `Gtk.Action.toolbar_item_type' denied

It should be a *class* variable, not an instance variable. So try
something like
        protected class GLib.Type toolbar_item_type;
and you won't be able to access it from static construct AFAIK, you need
to use class construct.

Regards,
Abderrahim




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