Skip to content

Commit 8b69df5

Browse files
committed
gtk: update playlist details screen
1 parent 42c960f commit 8b69df5

File tree

4 files changed

+25
-1
lines changed

4 files changed

+25
-1
lines changed

gtk/src/ui/pages/playlist_details.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use crate::state::AppState;
22
use adw::subclass::prelude::*;
33
use glib::subclass;
44
use gtk::glib;
5-
use gtk::{Button, CompositeTemplate};
5+
use gtk::{Button, CompositeTemplate, ListBox};
66
use std::cell::RefCell;
77

88
mod imp {
@@ -12,6 +12,9 @@ mod imp {
1212
#[derive(Debug, Default, CompositeTemplate)]
1313
#[template(resource = "/io/github/tsirysndr/Rockbox/gtk/playlist_details.ui")]
1414
pub struct PlaylistDetails {
15+
#[template_child]
16+
pub tracks: TemplateChild<ListBox>,
17+
1518
pub main_stack: RefCell<Option<adw::ViewStack>>,
1619
pub go_back_button: RefCell<Option<Button>>,
1720
pub state: glib::WeakRef<AppState>,
@@ -52,4 +55,6 @@ impl PlaylistDetails {
5255
pub fn new() -> Self {
5356
glib::Object::new()
5457
}
58+
59+
pub fn load_tracks(&self) {}
5560
}

gtk/src/ui/pages/playlists.rs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ use crate::api::rockbox::v1alpha1::{
33
GetFoldersRequest, GetFoldersResponse, GetPlaylistsRequest, GetPlaylistsResponse,
44
};
55
use crate::state::AppState;
6+
use crate::ui::pages::playlist_details::PlaylistDetails;
67
use crate::ui::playlist::Playlist;
78
use crate::ui::playlist_folder::PlaylistFolder;
89
use adw::subclass::prelude::*;
@@ -28,6 +29,7 @@ mod imp {
2829
pub main_stack: RefCell<Option<adw::ViewStack>>,
2930
pub go_back_button: RefCell<Option<Button>>,
3031
pub state: glib::WeakRef<AppState>,
32+
pub playlist_details: RefCell<Option<PlaylistDetails>>,
3133
}
3234

3335
#[glib::object_subclass]
@@ -148,6 +150,10 @@ impl Playlists {
148150
let playlist = Playlist::new();
149151
playlist.imp().playlist_name.set_text(&entry.name);
150152
playlist.imp().state.set(Some(&state));
153+
playlist
154+
.imp()
155+
.playlist_details
156+
.replace(self.imp().playlist_details.borrow().clone());
151157
self.imp().playlists.append(&playlist);
152158
}
153159
}

gtk/src/ui/playlist.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use crate::state::AppState;
2+
use crate::ui::pages::playlist_details::PlaylistDetails;
23
use crate::ui::{delete_playlist::DeletePlaylistDialog, edit_playlist::EditPlaylistDialog};
34
use adw::prelude::*;
45
use adw::subclass::prelude::*;
@@ -8,6 +9,7 @@ use gtk::{Button, CompositeTemplate, Image, Label, MenuButton};
89
use std::cell::RefCell;
910

1011
mod imp {
12+
1113
use super::*;
1214

1315
#[derive(Debug, Default, CompositeTemplate)]
@@ -25,6 +27,7 @@ mod imp {
2527
pub main_stack: RefCell<Option<adw::ViewStack>>,
2628
pub go_back_button: RefCell<Option<Button>>,
2729
pub state: glib::WeakRef<AppState>,
30+
pub playlist_details: RefCell<Option<PlaylistDetails>>,
2831
}
2932

3033
#[glib::object_subclass]
@@ -115,6 +118,12 @@ mod imp {
115118
let click = gtk::GestureClick::new();
116119
click.connect_released(move |_, _, _, _| {
117120
if let Some(self_) = self_weak.upgrade() {
121+
let main_stack = self_.main_stack.borrow();
122+
let main_stack_ref = main_stack.as_ref().unwrap();
123+
main_stack_ref.set_visible_child_name("playlist-details-page");
124+
let state = self_.state.upgrade().unwrap();
125+
state.push_navigation("Playlist", "playlist-details-page");
126+
118127
let go_back_button = self_.go_back_button.borrow();
119128
if let Some(go_back_button) = go_back_button.as_ref() {
120129
go_back_button.set_visible(true);

gtk/src/ui/window.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1089,6 +1089,10 @@ impl RbApplicationWindow {
10891089
playlists
10901090
.imp()
10911091
.set_go_back_button(window.imp().go_back_button.get().clone());
1092+
playlists
1093+
.imp()
1094+
.playlist_details
1095+
.replace(Some(window.imp().playlist_details.get().clone()));
10921096

10931097
album_results.imp().set_main_stack(main_stack.clone());
10941098
album_results.imp().set_library_page(library_page.clone());

0 commit comments

Comments
 (0)