-
Notifications
You must be signed in to change notification settings - Fork 1
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
the trait bound gdk::EventWindowState: glib::value::FromValueOptional<'_>
is not satisfied
#2
Comments
OK - so apparently unlike most of the parameters passed in the signals,
I lean toward the second option. While the third option is more flexible, I is much more verbose and much less elegant and I'm not sure we need that flexibility. Another thing I noticed is that #[signal(return = false)]
WindowState(gtk::Window, #[signal(event)] gdk::EventWindowState), |
I don't fully understand the inheritance relationship. Why should a subclass not be of a superclass? Also, do I assume correctly that the first solution would work without further code changes if it weren't for the return type? Regarding the return type: I've looked at my existing code (I want to migrate) and I found the following return types: The obvious problem with dynamic return values is that the current "match on event enum" approach does not type. Maybe we need something function-based, like suggested in gtk-rs/gtk3-rs#128 ? I think maybe what I need right now is a "less beautiful but more powerful" solution to bridge my callbacks into Actix, that even works on actions defined outside of any UI file. It must be powerful to cover all use cases, and then we can try to keep the common patterns fast with specialized solutions like |
I've pushed a commit that fixes this. Can you check if it works for you? You'll have to tell Cargo to get it from GitHub because I'm not doing a release yet - I prefer to do a few more iterations with you and catch other edge cases before I do 0.2. The syntax is: #[signal(ret = false)]
WindowState(gtk::Window, #[signal(event)] gdk::EventWindowState), I used
Because they are not really "subclasses". Maybe they are in GTK, but not it Rust.
Yes, but I've already pushed a commit that fixes both the return type issue and the second casting issue, so you can use the second solution.
Actually, no. All the signals handlers are returning But it isn't. The actual problem is that I need to return the result before the Maybe we can work something out with cells... |
I copied your code, it panics with
I've asked around and this seems to be a bindings-specific issue. We could implement
I see. I've looked at my code and the part that determines the return value is independent of the current state most of the time. If we had a way of sending new signals from code within a signal handler, this would solve the problem. |
Can you show me the code? Because a similar signal works in the new example I've added: https://github.com/idanarye/woab/blob/master/examples/example_events.rs#L49
Can you give an example for such a signal? And how would you expect the syntax to look like?
That's for gtk-rs - I can't implement a foreign trait for a foreign type...
You lost me. You mean sending a GTK signal from the |
I'll try to debug and minimize it first.
Sure. Generally, all signals that are part of input handling have events that bubble up and down the UI tree. At each stage, handlers can inhibit further propagation. Examples:
Well yes, that change must be made upstream (or on a local copy for now)
Yeah, sorry. Let me try again. For example, I have a callback like this, where carousel.connect_key_press_event(
clone!(@weak next, @weak previous => @default-panic, move |_carousel, event| {
use gdk::keys::constants;
match event.get_keyval() {
constants::Right | constants::KP_Right | constants::space | constants::KP_Space => {
next.activate(None);
gtk::Inhibit(true)
},
constants::Left | constants::KP_Left | constants::BackSpace => {
previous.activate(None);
gtk::Inhibit(true)
}
_ => gtk::Inhibit(false)
}
}),
); In this case, the return value is dependent on the input but not on the current state. I can't use WoAB for handling this signal, but I can move as much as possible of it into another signal that has no return value and thus can be bridged by WoAB. I then need a mechanism to trigger that signal from within my |
I think Had Regarding the dynamic return value - I was stuck on this problem because I was convincing myself that the syntax should be part of the signal enum and factories.app.build().signals_inhibit(|signal| {
match signal {
AppSignal::KeyPressEvent(_, event) => {
if custom_code_that_decide_if_should_inhibit(event) {
Some(gtk::Inhibit(true)) // yea yea I know old meme
} else {
Some(gtk::Inhibit(false))
}
}
_ => None // for most signals that don't need dynamic return types
}
}).actor(|_, widgets| AppActor {
widgets,
})?; Of course, we'd still keep The benefit of this style is that if we need some state we can pass a |
The crash happens in combination with my workaround for #3, so it can safely be ignored. Works as intended 🎉 |
Now that I think of it: would it be possible to add the inhibitor as a new method on the |
I'm trying to connect to the
window_state_event
, but I can't addgdk::EventWindowState
to my enum variant because it doesn't implementglib::value::FromValueOptional
. The error originates within thewoab::BuilderSignal
macro.The text was updated successfully, but these errors were encountered: