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



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.

Here is a sample code in C:

static void
tool_menu_action_class_init (ToolMenuActionClass *klass)
{
    GtkActionClass *action_class = GTK_ACTION_CLASS (klass);
    action_class->toolbar_item_type = GTK_TYPE_MENU_TOOL_BUTTON;
}

See here <http://www.gtkforums.com/viewtopic.php?t=4215> for a full
implementation in C.

In Vala I've tried this:

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

Any idea?


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