gtk-rs / gtk3-rs

Rust bindings for GTK 3
https://gtk-rs.org
MIT License
508 stars 90 forks source link

GtkWidget Subclassing: virtual methods #85

Open BrainBlasted opened 5 years ago

BrainBlasted commented 5 years ago

This issue is to provide a list of vfuncs of GtkWidget, to be crossed of as they are implemented. The first batch is covered in gtk-rs/gtk#861.

sdroege commented 5 years ago

Note that we don't need all of them (or not even most of them) for writing meaningful widgets. Check existing widget implementations, only a very small subset of the virtual methods is usually needed.

I think the main important missing one is draw at this point, that should really be added rather sooner than later :)

BrainBlasted commented 5 years ago

Currently we use expect if no parent implementation for a vfunc exists. There are a few vfuncs in GtkWidget that default to NULL - what's the right way to handle this? Is it okay to leave these as panics if the user makes a call to a non-existent parent implementation?

sdroege commented 5 years ago

On 10 August 2019 09:35:12 EEST, Chris notifications@github.com wrote:

Currently we use expect if no parent implementation for a vfunc exists. There are a few vfuncs in GtkWidget that default to NULL - what's the right way to handle this? Is it okay to leave these as panics if the user makes a call to a non-existent parent implementation?

It depends. If it's mandatory to implement the virtual method then yes, and you would put no default impl into the Impl trait.

If it's optional then you would instead return a default value here. Whatever the base class would do anyway if it was left at NULL.

See the various cases in gstreamer-rs, they all appear there.

-- Sent from my Android device with K-9 Mail. Please excuse my brevity.

hfiguiere commented 4 years ago

A few of the vfunc have been added, I don't have the permissions to check them in the list.

BrainBlasted commented 4 years ago

Which ones?

hfiguiere commented 4 years ago

The ones in commit ccc855a for example. No?

sdroege commented 4 years ago

@GuillaumeGomez your job :)