Adding child widgets
We saw the basics of how to create a widget with relm. Now, let's continue the creation of our user interface. We'll start by adding the toolbar. Besides specifying properties and signals in the view!
macro, we can also nest widgets in order to add a child to a container. So, to add gtk::Box
as a child of our window, we simply need to nest the former inside the latter:
view! { gtk::Window { title: "Rusic", delete_event(_, _) => (Quit, Inhibit(false)), gtk::Box { }, } }
And to add a toolbar to the gtk::Box
, we create a new level of nesting:
view! { gtk::Window { title: "Rusic", delete_event(_, _) => (Quit, Inhibit(false)), gtk::Box { orientation: Vertical, #[name="toolbar"] gtk::Toolbar { }, }, } }
Here, we can see that there's an attribute: the #[name]
attribute gives a name to a widget which will allow us to access this widget by the specified...