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

[Request] non-void signals #134

Open
GeopJr opened this issue Nov 22, 2023 · 2 comments
Open

[Request] non-void signals #134

GeopJr opened this issue Nov 22, 2023 · 2 comments
Labels
gap Missing needed feature

Comments

@GeopJr
Copy link
Contributor

GeopJr commented Nov 22, 2023

Could the signal macro support non-void signals?

Use case:
I'm emitting a singal from a child widget to call another function from the parent and want it to return a bool if it succeeded or not

(exact use case: A widget has a button and a clicked signal. The parent connects to the signal that provides the hash function to copy in string (e.g. "MD5"), the parent then copies it to clipboard and should return a bool to the widget if it succeeded or not so the button displays the correct feedback icon (:heavy_check_mark: or :x:))

@hugopl
Copy link
Owner

hugopl commented Nov 23, 2023

You mean: Support signal return values?

Meanwhile it doesn't support, but yes, it's possible to have this.

First step is to let the signal macro register a signal with a return value, so we can inform to GObject the right GType used for the return type at:

https://github.com/hugopl/gi-crystal/blob/main/src/bindings/g_object/object.cr#L596

Then we also need to register a GObject::SignalAcumulator callback.

I never used (or remember to had used) signals with return values, so I would need to do some experiments in libtest to first see it working in C, to later change the macro to let it work in Crystal.

@GeopJr
Copy link
Contributor Author

GeopJr commented Nov 24, 2023

You mean: Support signal return values?

Yes!

I never used (or remember to had used) signals with return values

FWIW, there's quite a few in GTK, here's some: Gtk::ComboBox::PopdownSignal, Gdk::Surface::EventSignal, Gtk::SpinButton::InputSignal

@hugopl hugopl added the gap Missing needed feature label Nov 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
gap Missing needed feature
Projects
None yet
Development

No branches or pull requests

2 participants