mirror of
https://github.com/johrpan/musicus.git
synced 2025-10-26 11:47:25 +01:00
Add mechanism to show playlist page
This commit is contained in:
parent
5fd958644e
commit
d0cf77888c
8 changed files with 135 additions and 8 deletions
|
|
@ -4,6 +4,7 @@ gnome = import('gnome')
|
|||
blueprints = custom_target('blueprints',
|
||||
input: files(
|
||||
'home_page.blp',
|
||||
'playlist_page.blp',
|
||||
'tile.blp',
|
||||
'welcome_page.blp',
|
||||
'window.blp'
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
<gresource prefix="/de/johrpan/musicus">
|
||||
<file preprocess="xml-stripblanks">icons/scalable/actions/playlist-symbolic.svg</file>
|
||||
<file preprocess="xml-stripblanks">home_page.ui</file>
|
||||
<file preprocess="xml-stripblanks">playlist_page.ui</file>
|
||||
<file preprocess="xml-stripblanks">tile.ui</file>
|
||||
<file preprocess="xml-stripblanks">welcome_page.ui</file>
|
||||
<file preprocess="xml-stripblanks">window.ui</file>
|
||||
|
|
|
|||
28
data/res/playlist_page.blp
Normal file
28
data/res/playlist_page.blp
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
using Gtk 4.0;
|
||||
using Adw 1;
|
||||
|
||||
template $MusicusPlaylistPage : Adw.Bin {
|
||||
Adw.ToolbarView {
|
||||
[top]
|
||||
Adw.HeaderBar {
|
||||
title-widget: Adw.WindowTitle {
|
||||
title: _("Playlist");
|
||||
};
|
||||
|
||||
[start]
|
||||
Gtk.Button close_button {
|
||||
icon-name: "go-down-symbolic";
|
||||
clicked => $close() swapped;
|
||||
}
|
||||
}
|
||||
|
||||
Gtk.ScrolledWindow {
|
||||
hscrollbar-policy: never;
|
||||
|
||||
Adw.Clamp {
|
||||
maximum-size: 1000;
|
||||
tightening-threshold: 600;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -5,17 +5,31 @@ template $MusicusWindow : Adw.ApplicationWindow {
|
|||
title: _("Musicus");
|
||||
|
||||
Adw.ToolbarView {
|
||||
Adw.NavigationView navigation_view {
|
||||
$MusicusWelcomePage {
|
||||
folder-selected => $set_library_folder() swapped;
|
||||
Gtk.Stack stack {
|
||||
transition-type: over_up_down;
|
||||
|
||||
Gtk.StackPage {
|
||||
name: "navigation";
|
||||
child: Adw.NavigationView navigation_view {
|
||||
$MusicusWelcomePage {
|
||||
folder-selected => $set_library_folder() swapped;
|
||||
}
|
||||
|
||||
$MusicusHomePage {}
|
||||
};
|
||||
}
|
||||
|
||||
$MusicusHomePage {}
|
||||
Gtk.StackPage {
|
||||
name: "playlist";
|
||||
child: $MusicusPlaylistPage {
|
||||
close => $hide_playlist() swapped;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
[bottom]
|
||||
Gtk.Revealer player_bar_revealer {
|
||||
reveal-child: false;
|
||||
reveal-child: true;
|
||||
transition-type: slide_up;
|
||||
|
||||
Gtk.Box {
|
||||
|
|
@ -55,10 +69,11 @@ template $MusicusWindow : Adw.ApplicationWindow {
|
|||
label: "00:00 / 01:00";
|
||||
}
|
||||
|
||||
Gtk.Button {
|
||||
Gtk.ToggleButton playlist_button {
|
||||
styles ["flat"]
|
||||
valign: center;
|
||||
icon-name: "playlist-symbolic";
|
||||
toggled => $show_playlist() swapped;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,4 +1,5 @@
|
|||
data/res/home_page.blp
|
||||
data/res/playlist_page.blp
|
||||
data/res/tile.blp
|
||||
data/res/welcome_page.blp
|
||||
data/res/window.blp
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
mod application;
|
||||
mod config;
|
||||
mod home_page;
|
||||
mod playlist_page;
|
||||
mod tile;
|
||||
mod welcome_page;
|
||||
mod window;
|
||||
|
|
|
|||
56
src/playlist_page.rs
Normal file
56
src/playlist_page.rs
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
use adw::subclass::prelude::*;
|
||||
use gtk::{glib, glib::subclass::Signal, prelude::*};
|
||||
use once_cell::sync::Lazy;
|
||||
|
||||
mod imp {
|
||||
use super::*;
|
||||
|
||||
#[derive(Debug, Default, gtk::CompositeTemplate)]
|
||||
#[template(resource = "/de/johrpan/musicus/playlist_page.ui")]
|
||||
pub struct MusicusPlaylistPage {}
|
||||
|
||||
#[glib::object_subclass]
|
||||
impl ObjectSubclass for MusicusPlaylistPage {
|
||||
const NAME: &'static str = "MusicusPlaylistPage";
|
||||
type Type = super::MusicusPlaylistPage;
|
||||
type ParentType = adw::Bin;
|
||||
|
||||
fn class_init(klass: &mut Self::Class) {
|
||||
klass.bind_template();
|
||||
klass.bind_template_instance_callbacks();
|
||||
}
|
||||
|
||||
fn instance_init(obj: &glib::subclass::InitializingObject<Self>) {
|
||||
obj.init_template();
|
||||
}
|
||||
}
|
||||
|
||||
impl ObjectImpl for MusicusPlaylistPage {
|
||||
fn signals() -> &'static [Signal] {
|
||||
static SIGNALS: Lazy<Vec<Signal>> =
|
||||
Lazy::new(|| vec![Signal::builder("close").build()]);
|
||||
|
||||
SIGNALS.as_ref()
|
||||
}
|
||||
}
|
||||
|
||||
impl WidgetImpl for MusicusPlaylistPage {}
|
||||
impl BinImpl for MusicusPlaylistPage {}
|
||||
}
|
||||
|
||||
glib::wrapper! {
|
||||
pub struct MusicusPlaylistPage(ObjectSubclass<imp::MusicusPlaylistPage>)
|
||||
@extends gtk::Widget, adw::Bin;
|
||||
}
|
||||
|
||||
#[gtk::template_callbacks]
|
||||
impl MusicusPlaylistPage {
|
||||
pub fn new() -> Self {
|
||||
glib::Object::new()
|
||||
}
|
||||
|
||||
#[template_callback]
|
||||
fn close(&self, _: >k::Button) {
|
||||
self.emit_by_name::<()>("close", &[]);
|
||||
}
|
||||
}
|
||||
|
|
@ -1,4 +1,7 @@
|
|||
use crate::{home_page::MusicusHomePage, welcome_page::MusicusWelcomePage};
|
||||
use crate::{
|
||||
home_page::MusicusHomePage, playlist_page::MusicusPlaylistPage,
|
||||
welcome_page::MusicusWelcomePage,
|
||||
};
|
||||
|
||||
use adw::subclass::prelude::*;
|
||||
use gtk::{gio, glib, prelude::*};
|
||||
|
|
@ -9,10 +12,14 @@ mod imp {
|
|||
#[derive(Debug, Default, gtk::CompositeTemplate)]
|
||||
#[template(resource = "/de/johrpan/musicus/window.ui")]
|
||||
pub struct MusicusWindow {
|
||||
#[template_child]
|
||||
pub stack: TemplateChild<gtk::Stack>,
|
||||
#[template_child]
|
||||
pub navigation_view: TemplateChild<adw::NavigationView>,
|
||||
#[template_child]
|
||||
pub player_bar_revealer: TemplateChild<gtk::Revealer>,
|
||||
#[template_child]
|
||||
pub playlist_button: TemplateChild<gtk::ToggleButton>,
|
||||
}
|
||||
|
||||
#[glib::object_subclass]
|
||||
|
|
@ -23,6 +30,7 @@ mod imp {
|
|||
|
||||
fn class_init(klass: &mut Self::Class) {
|
||||
MusicusHomePage::static_type();
|
||||
MusicusPlaylistPage::static_type();
|
||||
MusicusWelcomePage::static_type();
|
||||
klass.bind_template();
|
||||
klass.bind_template_instance_callbacks();
|
||||
|
|
@ -93,4 +101,20 @@ impl MusicusWindow {
|
|||
log::info!("{path:?}");
|
||||
self.imp().navigation_view.replace_with_tags(&["home"]);
|
||||
}
|
||||
|
||||
#[template_callback]
|
||||
fn show_playlist(&self, button: >k::ToggleButton) {
|
||||
self.imp()
|
||||
.stack
|
||||
.set_visible_child_name(if button.is_active() {
|
||||
"playlist"
|
||||
} else {
|
||||
"navigation"
|
||||
});
|
||||
}
|
||||
|
||||
#[template_callback]
|
||||
fn hide_playlist(&self, _: &MusicusPlaylistPage) {
|
||||
self.imp().playlist_button.set_active(false);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue