Re: Problem with Gtk.SpinButton.new_with_range

Giovanni Campagna <[email protected]>
Newsgroups gmane.comp.gnome.shell,gmane.comp.gnome.love
Message-ID <CABkLShFD=g0EQ+QJzcxLTvjXWJHAffJi7a2fAxLwAQCQtiMDJQ@mail.gmail.com>
2013/4/28 Thiago Bellini Ribeiro <[email protected]>:
> Hi!
>
> 2 people send me error reports about this problem [1] when opening the
> preferences dialog of my extension [2] on 3.8. One of them said he is
> using Arch Linux with the latest updates.
>
> The error says new_with_range is not a constructor.. But I'm confused.
> That code worked fine (with totally no errors) from 3.4 to 3.6. Also,
> when I was testing the extension on a virtual machine with a daily
> build of fedora (to test 3.8), the preferences window worked (so, that
> problem didn't exist there).
>
> Also, I took a look at the 3.8's GtkSpinButton [3] documentation and
> new_with_range is still a constructor.

new_with_range has never been a constructor, in the JS sense. It's a
regular function that returns a Gtk.SpinButton.

> So, my question is: What is happening there? Does the js binding
> changed? Should I change the syntax I'm using
> (Gtk.SpinButton.new_with_range)? And why did the problem happened for
> those guys and not for me (on my tests) and other people (I suppose I
> would have received many more error reports if that was affecting
> everyone)?

You're calling "new (Gtk.SpinButton.new_with_range)(...)" (parentheses
mine), i.e. creating an object whose class is
Gtk.SpinButton.new_with_range. That evaluates to:
- create an object
- invoke Gtk.SpinButton.new_with_range(...) with that object as this
  the call ignores the this object because it's not a method
- the return value is not undefined, discard the original object and
return the new one.

This is valid JS, after all, but it's obviously wrong: what you want
there is either
new Gtk.SpinButton({ adjustment: new Gtk.Adjustment(...) });
or
Gtk.SpinButton.new_with_range(...)
(without new)

Giovanni
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.