-
-
Notifications
You must be signed in to change notification settings - Fork 82
Conversation
Don't merge this just yet, so we can tweak the details if need be. |
The only other thing I am wondering is how well this can cope with the other events. The code itself seems to be fine to me. |
We should try to find the most unusual events I guess and see if they'll have any problems.
The I don't think macros would allow us to manually specify the conversion for the return value but I may just be too tired. |
For me it seems fine. I would need an example to have a better view of where it leads us, otherwise nothing to say. |
There're two signals defined here and the basic example uses the new |
I'm gonna buy a drink because "cake is a lie" |
And what do you know, I did mess up the
|
Going with The |
Is it good to merge now ? |
Not yet. Some more stuff has come up. |
Another thing is that the declaration system has to support different unrelated classes of widgets having similar signals (both |
Maybe the way to go is not putting all signals into a single module but tying them to their corresponding traits. I've just found an existing attempt at this approach - |
Pushed a new version with a different approach: signal classes were replaced with traits that let you connect signals to various widgets: pub trait WidgetSignals: FFIWidget {
fn connect_notify<F: Fn(Widget, &ParamSpec)>(&self, f: F) -> u64;
fn connect_button_press_event<F: Fn(Widget, &EventButton) -> Inhibit>(&self, f: F) -> u64;
fn connect_button_release_event<F: Fn(Widget, &EventButton) -> Inhibit>(&self, f: F) -> u64;
fn connect_delete_event<F: Fn(Widget, &EventAny) -> Inhibit>(&self, f: F) -> u64;
fn connect_draw<F: Fn(Widget, Context) -> Inhibit>(&self, f: F) -> u64;
fn connect_key_press_event<F: Fn(Widget, &EventKey) -> Inhibit>(&self, f: F) -> u64;
fn connect_key_release_event<F: Fn(Widget, &EventKey) -> Inhibit>(&self, f: F) -> u64;
fn connect_popup_menu<F: Fn(Widget) -> bool>(&self, f: F) -> u64;
}
pub trait ButtonSignals: FFIWidget {
fn connect_activate<F: Fn(Button)>(&self, f: F) -> u64;
fn connect_clicked<F: Fn(Button)>(&self, f: F) -> u64;
}
pub trait ToolButtonSignals: FFIWidget {
fn connect_clicked<F: Fn(ToolButton)>(&self, f: F) -> u64;
} There are no clashes between different signals with the same name now. |
It's becoming nicer and nicer. =) I can't wait to test it ! |
If there're no objections to this style (maybe we should wait a day for someone else's input), this might be ready for merging, so other signals can be added gradually. We just need to decide, where best to put these trait declarations - in this module or near the |
That's fine by me. If there's an issue, we'll be back on it. For now, nice job ! |
New signals infrastructure
Wow, Github is really smart: this PR contained a commit from #37 and not only didn't it get confused but also marked that one as merged. Cool. |
Oh ? You didn't know ? Welcome on github =D |
This PR depends on gtk-rs/glib#10