From 4afdc54914ab43d483dd3aaf4e6b30ba217c49f7 Mon Sep 17 00:00:00 2001 From: Zander Brown Date: Tue, 29 May 2018 19:09:54 +0100 Subject: [PATCH] Initial playback control area (not plumbed in) --- hammond-gtk/resources/gtk/playback.ui | 103 ++++++++++++++++++++++++++ hammond-gtk/resources/gtk/style.css | 4 + hammond-gtk/resources/resources.xml | 1 + hammond-gtk/src/app.rs | 22 ++++-- hammond-gtk/src/widgets/mod.rs | 2 + hammond-gtk/src/widgets/playback.rs | 21 ++++++ 6 files changed, 147 insertions(+), 6 deletions(-) create mode 100644 hammond-gtk/resources/gtk/playback.ui create mode 100644 hammond-gtk/src/widgets/playback.rs diff --git a/hammond-gtk/resources/gtk/playback.ui b/hammond-gtk/resources/gtk/playback.ui new file mode 100644 index 0000000..0457d68 --- /dev/null +++ b/hammond-gtk/resources/gtk/playback.ui @@ -0,0 +1,103 @@ + + + + + + True + False + media-playback-start-symbolic + + + True + False + center + True + True + + + True + False + center + center + 5 + 5 + 5 + 5 + 64 + image-x-generic-symbolic + 6 + + + 3 + 0 + 2 + + + + + True + True + start + True + True + False + False + False + right + + + 1 + 1 + 2 + + + + + True + True + True + center + center + 5 + 5 + 5 + 5 + image1 + + + 0 + 0 + 2 + + + + + True + False + start + end + label + + + 1 + 0 + + + + + True + False + end + end + label + + + 2 + 0 + + + + + diff --git a/hammond-gtk/resources/gtk/style.css b/hammond-gtk/resources/gtk/style.css index b97847e..cfb0ecd 100644 --- a/hammond-gtk/resources/gtk/style.css +++ b/hammond-gtk/resources/gtk/style.css @@ -9,3 +9,7 @@ row:last-child { list, border { border-radius: 4px; } + +.playback { + border-top: 1px solid @borders; +} diff --git a/hammond-gtk/resources/resources.xml b/hammond-gtk/resources/resources.xml index 67b98ae..6f0dd7f 100644 --- a/hammond-gtk/resources/resources.xml +++ b/hammond-gtk/resources/resources.xml @@ -13,6 +13,7 @@ gtk/inapp_notif.ui gtk/menus.ui gtk/help-overlay.ui + gtk/playback.ui gtk/style.css diff --git a/hammond-gtk/src/app.rs b/hammond-gtk/src/app.rs index 711c004..3dd14cc 100644 --- a/hammond-gtk/src/app.rs +++ b/hammond-gtk/src/app.rs @@ -18,7 +18,7 @@ use settings::{self, WindowGeometry}; use stacks::{Content, PopulatedState}; use utils; use widgets::appnotif::{InAppNotification, UndoState}; -use widgets::{about_dialog, mark_all_notif, remove_show_notif}; +use widgets::{about_dialog, mark_all_notif, remove_show_notif, Playback}; use std::rc::Rc; use std::sync::Arc; @@ -69,10 +69,6 @@ impl App { let application = gtk::Application::new("org.gnome.Hammond", ApplicationFlags::empty()) .expect("Application Initialization failed..."); - // Weird magic I copy-pasted that sets the Application Name in the Shell. - glib::set_application_name("Hammond"); - glib::set_prgname(Some("Hammond")); - let cleanup_date = settings::get_cleanup_date(&settings); utils::cleanup(cleanup_date); @@ -103,6 +99,9 @@ impl App { Inhibit(false) })); + let wrap = gtk::Box::new(gtk::Orientation::Vertical, 0); + window.add(&wrap); + // Create a content instance let content = Rc::new(Content::new(sender.clone()).expect( @@ -120,7 +119,13 @@ impl App { overlay.add(&content.get_stack()); // Add the overlay to the main window - window.add(&overlay); + wrap.add(&overlay); + + let playback = Playback::new(); + + let reveal = gtk::Revealer::new(); + reveal.add(&playback.container); + wrap.add(&reveal); WindowGeometry::from_settings(&settings).apply(&window); @@ -301,6 +306,11 @@ impl App { } pub fn run(self) { + // Weird magic I copy-pasted that sets the Application Name in the Shell. + glib::set_application_name("Hammond"); + glib::set_prgname(Some("Hammond")); + // We need out own org.gnome.Hammon icon + gtk::Window::set_default_icon_name("multimedia-player"); ApplicationExtManual::run(&self.app_instance, &[]); } } diff --git a/hammond-gtk/src/widgets/mod.rs b/hammond-gtk/src/widgets/mod.rs index df7361d..6360040 100644 --- a/hammond-gtk/src/widgets/mod.rs +++ b/hammond-gtk/src/widgets/mod.rs @@ -5,6 +5,7 @@ mod episode; mod home_view; mod show; mod shows_view; +mod playback; pub use self::aboutdialog::about_dialog; pub use self::empty::EmptyView; @@ -13,3 +14,4 @@ pub use self::home_view::HomeView; pub use self::show::ShowWidget; pub use self::show::{mark_all_notif, remove_show_notif}; pub use self::shows_view::ShowsView; +pub use self::playback::Playback; diff --git a/hammond-gtk/src/widgets/playback.rs b/hammond-gtk/src/widgets/playback.rs new file mode 100644 index 0000000..7ec6d4e --- /dev/null +++ b/hammond-gtk/src/widgets/playback.rs @@ -0,0 +1,21 @@ +use gtk; + +#[derive(Debug, Clone)] +pub struct Playback { + pub container: gtk::Grid, +} + +impl Default for Playback { + fn default() -> Self { + let builder = gtk::Builder::new_from_resource("/org/gnome/Hammond/gtk/playback.ui"); + let container = builder.get_object("wrapper").unwrap(); + + Playback { container } + } +} + +impl Playback { + pub fn new() -> Playback { + Playback::default() + } +}