On Tue, Nov 13, 2018 at 11:35 AM Tony Houghton <h...@realh.co.uk> wrote:

> On Tue, 13 Nov 2018 at 16:01, <makep...@firemail.cc> wrote:
>
>> Please consider sending a pull request to ts-for-gjs with definitions
>> and tests for registerClass, if you have time before I can write them.
>> It's a relatively new thing, haven't needed it yet. So far the focus has
>> been on GObject introspection. Definitions for other built-ins, such as
>> package, signals and system, would be helpful too.
>>
>
> Unfortunately I'm a complete newbie with both gjs and typescript, so I
> wouldn't really know how to make such definitions, or even know for sure if
> registerClass is (still) officially supported.
>

registerClass is currently the only supported way to inherit from GObject
classes. There is Lang.Class which still works, and I will take PRs to fix
bugs in it, but it is considered legacy.

(By the way, it's written so that it *should* work fine as a decorator in
typescript. If you add a definition for it, it might make sense to document
it as a decorator. My plan is to make the decorator the main supported way
to inherit, once decorators are supported in the main javascript standard.)

Wouldn't say that has-a relationships and signals are an old way, just
>> one of the ways and quite useful at that.
>>
>
> Yes, it does the job, but it seems a shame that I can't take advantage of
> all the facilities that should be available by using GObject with an OO
> language. I suppose a good way to proceed for now would be to compromise by
> deriving Typescript classes from GObject classes but assume that I can't
> override native virtual functions this way and use signals instead.
>

You can override the virtual functions, but they all start with vfunc_. You
can find them in the documentation, for example Gtk.Widget's virtual
functions start here:
http://devdocs.baznga.org/gtk30~3.22.12/gtk.widget#vfunc-adjust_baseline_allocation

Regards,
Philip C
_______________________________________________
javascript-list mailing list
javascript-list@gnome.org
https://mail.gnome.org/mailman/listinfo/javascript-list

Reply via email to