The main function is starting to get bigger, so we'll refactor our code a little to make it easier to update in the upcoming sections and chapters.
First, we'll create a new module called toolbar. As a reminder, here's how to do so:
- Create a new file:Â src/toolbar.rs.
- Add a statement, mod toolbar;, at the top of the file main.rs.
This new module toolbar will start with the import statement and the const declaration:
use gtk::{ ContainerExt, SeparatorToolItem, Toolbar, ToolButton, }; const PLAY_STOCK: &str = "gtk-media-play";
We'll then create a new structure holding all the widgets that compose the toolbar:
pub struct MusicToolbar { open_button: ToolButton, next_button: ToolButton, play_button: ToolButton, previous_button: ToolButton, quit_button: ToolButton...