Re: [Vala] I found a major bug



Thank you very much for the very detailed responses are helpful.

Long time no do anything in C or Java, since I discovered python not write
in another language. vala seems excellent among other things because I can
run my python application to vala practically without changes.

Hence come my difficulties with these functions.

In python get_toplevel () always returns the main Gtk.Window of apicación.
Get the value of any property is made by GET_PROPERTY ("property_name"),
etc. . .

These details are important for code clarity for those who got to vala from
python.

2014-12-20 2:36 GMT-02:00 Evan Nemerson <evan coeus-group com>:

On Sat, 2014-12-20 at 00:51 -0200, Flavio Danesse wrote:
Another thing that does not work as expected is:

this.get_toplevel ()

This should return the main application window, or one Gtk.Window, but
returns a Gtk.Widget

Because that's what the C function does.  The documentation describes
when the return value will *not* be a Gtk.Window.  See

https://developer.gnome.org/gtk3/stable/GtkWidget.html#gtk-widget-get-toplevel

2014-12-20 0:32 GMT-02:00 Flavio Danesse <fdanesse gmail com>:

I understand, but it is logical that a get back what is asked, things
like
that are not logical fol:

error: invocation of void method not allowed as expression
this.get_property("type");

Not sure where you're getting that error from—trying to call
GLib.Object.get_property like that here results in:

        error: 1 missing arguments for `void GLib.Object.get_property
        (string property_name, ref GLib.Value value)'

As for why it returns void instead of GLib.Value, look at the C
function:

https://developer.gnome.org/gobject/stable/gobject-The-Base-Object-Type.html#g-object-get-property


In the initial example:
this.get_allocation()
does not work, though:
this.get_allocated_width()
if it works.

This is a more interesting example, but again it's a reflection of the C
API:


https://developer.gnome.org/gtk3/stable/GtkWidget.html#gtk-widget-get-allocation

https://developer.gnome.org/gtk3/stable/GtkWidget.html#gtk-widget-get-allocated-width

For this function it would actually be possible to alter the bindings to

        public Gtk.Allocation get_allocation ();

Actually, these days it is generated like that by default, but we have a
line in our metadata file to change it back to avoid breaking backwards
compatibility.

Also, we have to be careful changing out params to return values like
that since in the future the C API may change to include a return value
(which isn't an API break for the C API).  That happened recently in
GtkSourceview and it broke several Vala programs.  See
https://bugzilla.gnome.org/show_bug.cgi?id=738896





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