Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

subclass/widget: Implement default handling for parent events #921

Merged

Conversation

@alatiera
Copy link
Contributor

alatiera commented Dec 4, 2019

Close #916

.expect("No parent class impl for \"button_press_event\"");
let ev_glib = glib::translate::mut_override(event.to_glib_none().0);
Inhibit(from_glib(f(widget.to_glib_none().0, ev_glib)))
if let Some(f) = (*parent_class).button_press_event {

This comment has been minimized.

Copy link
@EPashkin

EPashkin Dec 4, 2019

Member

Can this part be macro?
call_parent!(button_press_event, f(widget.to_glib_none().0, ev_glib))

This comment has been minimized.

Copy link
@sdroege

sdroege Dec 4, 2019

Member

No because it looks different depending on what the parent class expects by default.

This comment has been minimized.

Copy link
@EPashkin
@sdroege

This comment has been minimized.

Copy link
Member

sdroege commented Dec 4, 2019

  • parent_child_notify() should do nothing instead of panicking
  • parent_compute_expand() is difficult. We need to replicate the behaviour the base class would do if it's not set here... basically we would need to set the two bools to the return values of gtk_widget_get_hexpand() and gtk_widget_get_vexpand().
  • Application, container, dialog, window need the same treatment (I think all of them are cases of "do-nothing-if-not-set")
@alatiera alatiera force-pushed the alatiera:alatiera/widget-parent-events branch from b89da17 to 1ee3dd2 Dec 6, 2019
@sdroege

This comment has been minimized.

Copy link
Member

sdroege commented Dec 6, 2019

Looks good, I think. Only container and widget's compute_expand() missing now :)

@alatiera alatiera force-pushed the alatiera:alatiera/widget-parent-events branch from 1ee3dd2 to 98e6ae9 Dec 6, 2019
@alatiera

This comment has been minimized.

Copy link
Contributor Author

alatiera commented Dec 6, 2019

Added compute expand now, though given how simple it looks I am not sure if that's what you had in mind?

@sdroege

This comment has been minimized.

Copy link
Member

sdroege commented Dec 6, 2019

Added compute expand now, though given how simple it looks I am not sure if that's what you had in mind?

Yes exactly that. Then only the GtkContainer virtual methods are missing and then we're good to go here :)

@alatiera alatiera force-pushed the alatiera:alatiera/widget-parent-events branch from 98e6ae9 to e2515bf Dec 6, 2019
@alatiera

This comment has been minimized.

Copy link
Contributor Author

alatiera commented Dec 6, 2019

oh whoops, forgot aobut container

@sdroege

This comment has been minimized.

Copy link
Member

sdroege commented Dec 6, 2019

👍

src/subclass/container.rs Outdated Show resolved Hide resolved
@alatiera alatiera force-pushed the alatiera:alatiera/widget-parent-events branch from e2515bf to ef5190b Dec 6, 2019
…default handling for parent events

Close #916
@alatiera alatiera force-pushed the alatiera:alatiera/widget-parent-events branch from ef5190b to ea45775 Dec 7, 2019
@alatiera

This comment has been minimized.

Copy link
Contributor Author

alatiera commented Dec 7, 2019

Should be good to go!

@sdroege

This comment has been minimized.

Copy link
Member

sdroege commented Dec 7, 2019

Should be good to go!

I agree :) Also your examples PR should be good to merge then?

@alatiera

This comment has been minimized.

Copy link
Contributor Author

alatiera commented Dec 7, 2019

Okay, that's the last of the panics I am hitting it seems \o/

@sdroege

This comment has been minimized.

Copy link
Member

sdroege commented Dec 7, 2019

Okay, that's the last of the panics I am hitting it seems \o/

🙌 Let's get this in then once the CI is green

@GuillaumeGomez

This comment has been minimized.

Copy link
Member

GuillaumeGomez commented Dec 7, 2019

Thanks!

@GuillaumeGomez GuillaumeGomez merged commit 2efce6e into gtk-rs:master Dec 7, 2019
2 checks passed
2 checks passed
continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
@alatiera alatiera deleted the alatiera:alatiera/widget-parent-events branch Dec 7, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
4 participants
You can’t perform that action at this time.