-
-
Notifications
You must be signed in to change notification settings - Fork 133
Description
When defining a GObject type in Rust, it is necessary to define a ObjectImpl::signals() function, and useful to define the emit_ and connect_ functions like the ones generated by gir.
Considering a few things, this seems like a reasonable API for it, which I think would work:
glib::wrapper! {
signals {
fn signal_without_params();
fn signal_with_params(i32, String);
fn signal_with_params_and_return(i32, String) -> bool;
}
pub struct FooObject(ObjectSubclass<FooObjectInner>);
}I guess it would be necessary for the caller to define ObjectImpl::signals() to call a function generated by the macro. Kind of similar to the boilerplate required with composite templates. I can't think of a way to avoid a slight complication like this.
Alternately to making this part of glib::wrapper!, it could be a separate macro, or an attribute macro on something. Given glib::wrapper! is necessary, it seems cleaner to add it here. It could also generate the connect_/emit_ functions for types other than ObjectSubclass (code currently generated in gir).
Properties should be handled in a similar way, but that's more complicated since it would be good for it to automatically store a value if there is no custom getter/setter, while also supporting custom getters and setters. And then there's a need to define nick, blurb, and default value.