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

[Feature Request] Expose methods to C, to be called from signals #168

Open
BigBoyBarney opened this issue Jan 1, 2025 · 1 comment
Open

Comments

@BigBoyBarney
Copy link
Contributor

BigBoyBarney commented Jan 1, 2025

Hi!

It's possible to bind a button, or any other property for that matter via expressions, to a function in C. Relevant blueprint documentation for signals and closure expressions.

Button {
  clicked => $on_button_clicked();
}

This would allow us to replace

button.clicked_signal.connect(->on_button_clicked)

and use closure expressions in blueprints (very useful)!

I have 0 idea whether this is feasible at all, but an annotation like for properties would be amazing

class Snorlax
  @[GObject::Property]
  property size : Int32

Cheers, and happy new year!

@hugopl
Copy link
Owner

hugopl commented Jan 2, 2025

I had a branch somewhere with some small fixes to be able to use Gtk expressions, I stop working on it because I noticed that I would not need GTK expressions for what I was doing.

IIRC I had to add a finalizer for GTK::Expression so gi-crystal calls the right destruction function and not crash.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants