Re: [Vala] How to assign to construct-only property?



I have solved the problem.

My question have been derived from my ignorance of GObject.
Sorry my ignorance.

class MyClass : Object
{
    public bool construct_only_property { get; construct; default = false; }
    public void print_construct_only_property()
    { stdout.printf("%s\n", construct_only_property.to_string()); }
}


void main (string[] args)
{
    // set construct-only property
    var instance1 = (MyClass) GLib.Object.new (typeof(MyClass),
                                               construct_only_property:
true);

    instance1.print_construct_only_property(); // print true,  Correct,
Good.

    var instance2 = new MyClass();

    instance2.print_construct_only_property(); // print false, Correct,
Good.
}


---- gsf-decompress.vala ----

void main (string[] args)
{
    Gsf.InfileMSOle olefile;

    string filename = args[1];

    try   {
        var file = new Gsf.InputStdio (filename);
        olefile  = new Gsf.InfileMSOle (file);
    }
    catch {
        stderr.printf ("%s is not a OLE file\n", filename);
        return;
    }

    var input = olefile.child_by_name("DocInfo");

    Gsf.InputGZip stream;
    stream = (Gsf.InputGZip) GLib.Object.new (typeof(Gsf.InputGZip),
                                              raw:    true,
                                              source: input);
}

$ valac gsf-decompress.vala --pkg libgsf-1
gsf-decompress.vala.c: In function ‘_vala_main’:
gsf-decompress.vala.c:101:26: error: ‘GSF_TYPE_INPUT_GZIP’ undeclared
(first use in this function)
gsf-decompress.vala.c:101:26: note: each undeclared identifier is reported
only once for each function it appears in
error: cc exited with status 256
Compilation failed: 1 error(s), 0 warning(s)

I have reported a bug.
https://bugzilla.gnome.org/show_bug.cgi?id=688851

2012/11/22 Luca Bruno <lethalman88 gmail com>

On Wed, Nov 21, 2012 at 4:26 PM, Hodong Kim <cogniti gmail com> wrote:

class InflateGZip : Gsf.InputGZip
{
    public InflateGZip(Gsf.Input source)
    {
        //Object(raw: true);
        base(source);
    }
}


You can only use either Object() or base():
Object (raw: true, source: source);

--
www.debian.org - The Universal Operating System



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