5 ms·
Ah yeah if you're coming from using GObject in C, it probably makes much more sense. Still, I would highly prefer macros that made it much quicker to subclass.
by jms55 5y ago
Ah yeah if you're coming from using GObject in C, it probably makes much more sense. Still, I would highly prefer macros that made it much quicker to subclass. Things like:
* Automatically figuring out which parent objects the class you're subclassing derives from, instead of having to import and then list out all of them individually. This is for the glib::wrapper!() macro.
* Automatically filling out ObjectSubclass, and WidgetImpl, etc.
* Helpers for properties and signals
* A flat list of methods, instead of the public/imp split
The bigger issue that Relm solves imo, is state management. I feel like I had a difficult time figuring out how to share state between widgets. You end up with lots of OnceCell, Rc, and RefCell, and it quickly becomes confusing, especially when you start subclassing GObject and making your own objects.
As soon as I think of a good project to work on, I'm going to try out Relm4 and see if it is better than gtk4-rs.
- md8z 5y ago"Automatically figuring out which parent objects the class you're subclassing derives from" AFAIK this is a language limitation, there is no way in a Rust macro to take a type and get all the traits that are implemented for that type. It would need some kind of reflection API. Maybe someone could try it with this crate? https://crates.io/crates/reflect https://crates.io/crates/reflect "Helpers for properties and signals" There are some open issues for this: https://github.com/gtk-rs/gtk-rs-core/issues/27 https://github.com/gtk-rs/gtk-rs-core/issues/27 https://github.com/gtk-rs/gtk-rs-core/issues/214 https://github.com/gtk-rs/gtk-rs-core/issues/214 "A flat list of methods, instead of the public/imp split" You can already do this in your code and use "pub fn" and "fn" like normal. "I feel like I had a difficult time figuring out how to share state between widgets. You end up with lots of OnceCell, Rc, and RefCell, and it quickly becomes confusing," I think you are supposed to use bind_property and the gtk::Expression objects to do data binding, though that part is not so convenient to use from C or Rust either.