antoyo / relm

Idiomatic, GTK+-based, GUI library, inspired by Elm, written in Rust
MIT License
2.43k stars 78 forks source link

How to access to a relm::Widget? #193

Closed sanpii closed 4 years ago

sanpii commented 4 years ago

In relm 0.9, the method relm::Component::widget() returns the relm::Widget but since 0.10 it returns relm::Widget::Root. Is there another way to interact with relm::Widget in a parent widget?

antoyo commented 4 years ago

I'm not sure I understand your problem: Component::widget() is still there. There's also a Widget::root() method.

sanpii commented 4 years ago

Yes but in 0.9 it returns WIDGET and WIDGET::Root in 0.10: https://github.com/antoyo/relm/compare/0.9.0...0.10.0#diff-852c8250af37b95ed01ce8c7dc82e312L71-R67

-    /// Get the widget of this component.
-    pub fn widget(&self) -> &WIDGET {
-        &self.0.widget
+    /// Get the widget of the component.
+    pub fn widget(&self) -> &WIDGET::Root {
+        &self.widget
antoyo commented 4 years ago

Oh, that was unsound. In relm, there's only one owner to a widget. The way to "access" a child widget is through communication.

sanpii commented 4 years ago

Ok, I definitively need to rethink my application. Thank you.