[Vala] Gtk.TextBuffer text/set_text



Gtk.TextBuffer has a property:

    public weak string text { set; get; }

This should mean you can either use:

    my_text_buffer.text = "foo";

Or:

    my_text_buffer.set_text ("foo");

Right? However, the set_text() method in this case is different:

    public void set_text (string text, int len)

So, this works:

    my_text_buffer.set_text ("foo", 3);

But this doesn't:

    my_text_buffer.text = "foo";

The problem is, valac compiles that last line, but gcc gives an error saying gtk_text_buffer_set_text() isn't 
getting enough arguments. So I'm guessing this constitutes as a bug in Vala.

BTW, I would have just submitted a bug report on bugzilla, but the whole philosophy behind the { set; get; } 
way of working is still a bit unclear to me. Is it meant to be double, as in: you can always use both 
"object.x = something" and "object.set_x(something)"? Why wasn't there chosen for one way? Maybe I'm just 
fussing too hard over this, but I keep wondering which is the preferred way of the two.


      



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