Re: [Vala] Help with struct array



Dmitrijs Ledkovs wrote:
Hello all

I'm beginning to learn Vala & Gtk. I've manage through Vala/Tutorial
upto the end of OOP chapter and couldn't handle the rest =)

Anywho I'm trying to port Webkit html5 based WYSIWYG editor[0] to
Vala. Sounds easy and fun.

I've hit a small problem. I'm failing to create a valid Array of ActionEntries.

public void add_actions (ActionEntry[] entries, void* user_data);

I'm my code I'm trying something like this:

    ActionEntry[] entries = new ActionEntry[3];
    entries =
            {name="menuFile", label="_File"},
            {name="menuEdit", label="_Edit"},
            {name="menuInsert", label="_Insert"};

    var actions = new ActionGroup("Actions");
    actions.add_entries(entries, 3);

And I'm getting an error saying that ";" is expected in the line where
I define entries for the first time.

Hi,

it's

        ActionEntry[] entries = new ActionEntry[3];
        entries = {
                ActionEntry() { name = "menuFile", label = "_File" },
                ActionEntry() { name = "menuEdit", label = "_Edit" },
                ActionEntry() { name = "menuInsert", label = "_Insert" }
        };

or

        ActionEntry[] entries = {
                ActionEntry() { name = "menuFile", label = "_File" },
                ActionEntry() { name = "menuEdit", label = "_Edit" },
                ActionEntry() { name = "menuInsert", label = "_Insert" }
        };

or, if it's a constant array (currently not allowed in method scope):

        const ActionEntry[] entries3 = {
                { "menuFile", "_File" },
                { "menuEdit", "_Edit" },
                { "menuInsert", "_Insert" }
        };


Best regards,

Frederik



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