mirror of
https://github.com/johrpan/musicus.git
synced 2025-10-26 19:57:25 +01:00
main screen: Add button to start random playback
This commit is contained in:
parent
487fd0a048
commit
3350c6be95
5 changed files with 57 additions and 22 deletions
|
|
@ -7,7 +7,7 @@
|
|||
<child>
|
||||
<object class="AdwHeaderBar">
|
||||
<property name="title-widget">
|
||||
<object class="GtkLabel"/>
|
||||
<object class="GtkLabel" />
|
||||
</property>
|
||||
</object>
|
||||
</child>
|
||||
|
|
@ -17,6 +17,18 @@
|
|||
<property name="title" translatable="yes">Welcome to Musicus!</property>
|
||||
<property name="description" translatable="yes">Get startet by selecting something from the sidebar or adding new things to your library using the button in the top left corner.</property>
|
||||
<property name="vexpand">true</property>
|
||||
<child>
|
||||
<object class="GtkRevealer" id="play_button_revealer">
|
||||
<property name="reveal-child">true</property>
|
||||
<property name="transition-type">crossfade</property>
|
||||
<child>
|
||||
<object class="GtkButton" id="play_button">
|
||||
<property name="halign">center</property>
|
||||
<property name="label" translatable="yes">Play something</property>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
|
|
@ -40,7 +52,7 @@
|
|||
<object class="GtkLabel">
|
||||
<property name="label">Musicus</property>
|
||||
<style>
|
||||
<class name="title"/>
|
||||
<class name="title" />
|
||||
</style>
|
||||
</object>
|
||||
</property>
|
||||
|
|
@ -104,7 +116,7 @@
|
|||
<property name="child">
|
||||
<object class="GtkScrolledWindow" id="scroll">
|
||||
<child>
|
||||
<placeholder/>
|
||||
<placeholder />
|
||||
</child>
|
||||
</object>
|
||||
</property>
|
||||
|
|
|
|||
|
|
@ -32,6 +32,8 @@ impl Screen<(), ()> for MainScreen {
|
|||
|
||||
get_widget!(builder, gtk::Box, widget);
|
||||
get_widget!(builder, adw::Leaflet, leaflet);
|
||||
get_widget!(builder, gtk::Revealer, play_button_revealer);
|
||||
get_widget!(builder, gtk::Button, play_button);
|
||||
get_widget!(builder, gtk::Button, add_button);
|
||||
get_widget!(builder, gtk::SearchEntry, search_entry);
|
||||
get_widget!(builder, gtk::Stack, stack);
|
||||
|
|
@ -126,6 +128,14 @@ impl Screen<(), ()> for MainScreen {
|
|||
search.is_empty() || title.contains(&search)
|
||||
}));
|
||||
|
||||
this.handle.backend.pl().add_playlist_cb(clone!(@weak play_button_revealer => move |new_playlist| {
|
||||
play_button_revealer.set_reveal_child(new_playlist.is_empty());
|
||||
}));
|
||||
|
||||
play_button.connect_clicked(clone!(@weak this => move |_| {
|
||||
this.handle.backend.pl().play_pause().unwrap();
|
||||
}));
|
||||
|
||||
this.navigator.set_back_cb(clone!(@weak this => move || {
|
||||
this.leaflet.set_visible_child_name("sidebar");
|
||||
}));
|
||||
|
|
|
|||
|
|
@ -163,7 +163,7 @@ impl Screen<(), ()> for PlayerScreen {
|
|||
|
||||
this.play_button
|
||||
.connect_clicked(clone!(@weak this => move |_| {
|
||||
this.handle.backend.pl().play_pause();
|
||||
this.handle.backend.pl().play_pause().unwrap();
|
||||
}));
|
||||
|
||||
this.next_button
|
||||
|
|
|
|||
|
|
@ -47,7 +47,7 @@ impl PlayerBar {
|
|||
|
||||
play_button.connect_clicked(clone!(@strong player => move |_| {
|
||||
if let Some(player) = &*player.borrow() {
|
||||
player.play_pause();
|
||||
player.play_pause().unwrap();
|
||||
}
|
||||
}));
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue