diff --git a/hammond-gtk/resources/gtk/player_toolbar.ui b/hammond-gtk/resources/gtk/player_toolbar.ui index 94e0493..57c623c 100644 --- a/hammond-gtk/resources/gtk/player_toolbar.ui +++ b/hammond-gtk/resources/gtk/player_toolbar.ui @@ -31,241 +31,219 @@ media-seek-backward-symbolic 1 - - True + False - slide-up + True + end - + True False - 0.5 - 0 - in + center - + + 42 + True + False + True + True + Previous + previous_image + True + + + False + False + 0 + + + + + 60 + False + True + True + Play + play_image + True + + + False + False + 1 + + + + + 60 + True + False + True + True + Play + pause_image + True + + + False + False + 2 + + + + + 42 + True + False + True + True + Next + ff_image + True + + + False + False + 3 + + + + + + 0 + + + + + True + False + 6 + + True False - end + 42 + image-x-generic-symbolic + + + False + True + 0 + + + + + True + False + vertical - + True False - center - - - 42 - True - False - True - True - Previous - previous_image - True - - - False - False - 0 - - - - - 60 - True - False - True - True - Play - play_image - True - - - False - False - 1 - - - - - 60 - True - False - True - True - Play - pause_image - True - - - False - False - 2 - - - - - 42 - True - False - True - True - Next - ff_image - True - - - False - False - 3 - - - + Show Title + False + True 0 - + True False - 6 - - - True - False - 42 - image-x-generic-symbolic - - - False - True - 0 - - - - - True - False - vertical - - - True - False - Show Title - - - False - True - 0 - - - - - True - False - Episode Title - - - False - True - 1 - - - - - False - True - 1 - - + Episode Title + False + True 1 - - - 0 - True - True - end - True - True - False - -1 - 0 - False - False - right - - - 3 - - - - - True - False - start - center - 6 - - - True - False - start - center - 0:00 - - - False - False - 0 - - - - - True - False - start - center - / - - - False - False - 1 - - - - - True - False - start - center - 0:00 - - - False - False - 2 - - - - - 4 - - - - - + + False + True + 1 + + + 1 + + + + + True + True + True + True + False + -1 + 0 + False + False + right + + + 3 + + + + + True + False + start + center + 6 + + + True + False + start + center + 0:00 + + + False + False + 0 + + + + + True + False + start + center + / + + + False + False + 1 + + + + + True + False + start + center + 0:00 + + + False + False + 2 + + + + + 4 + diff --git a/hammond-gtk/resources/resources.xml b/hammond-gtk/resources/resources.xml index 6f0dd7f..4925609 100644 --- a/hammond-gtk/resources/resources.xml +++ b/hammond-gtk/resources/resources.xml @@ -13,7 +13,7 @@ gtk/inapp_notif.ui gtk/menus.ui gtk/help-overlay.ui - gtk/playback.ui + gtk/player_toolbar.ui gtk/style.css diff --git a/hammond-gtk/src/app.rs b/hammond-gtk/src/app.rs index ada84ba..7d041f0 100644 --- a/hammond-gtk/src/app.rs +++ b/hammond-gtk/src/app.rs @@ -5,8 +5,6 @@ use gio::{ SimpleAction, SimpleActionExt, }; use glib; -use gstreamer_player as gst; -use gstreamer::ClockTime; use gtk; use gtk::prelude::*; use gtk::SettingsExt as GtkSettingsExt; @@ -19,7 +17,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, Playback}; +use widgets::{about_dialog, mark_all_notif, remove_show_notif, PlayerWidget}; use std::rc::Rc; use std::sync::Arc; @@ -56,9 +54,6 @@ pub enum Action { RemoveShow(Arc), ErrorNotification(String), PlayEpisode(String), - PlayerStateChanged(gst::PlayerState), - PlayerMediaChanged(Option, ClockTime), - PlayerPositionChanged(ClockTime), } #[derive(Debug)] @@ -103,8 +98,6 @@ impl App { Inhibit(false) })); - let wrap = gtk::Box::new(gtk::Orientation::Vertical, 0); - window.add(&wrap); // Create a content instance let content = @@ -122,11 +115,17 @@ impl App { let overlay = gtk::Overlay::new(); overlay.add(&content.get_stack()); - // Add the overlay to the main window + let wrap = gtk::Box::new(gtk::Orientation::Vertical, 0); + // Add the overlay to the main Box wrap.add(&overlay); - let playback = Rc::new(Playback::new()); - wrap.add(playback.get_widget()); + // FIXME: this should have a ::new() method instead. + let player = PlayerWidget::default(); + // Add the player to the main Box + wrap.add(&player.action_bar); + // player.reveal(); + + window.add(&wrap); WindowGeometry::from_settings(&settings).apply(&window); @@ -135,23 +134,22 @@ impl App { window.show_all(); window.activate(); - let player = gst::Player::new(None, None); - player.connect_error(clone!(sender => move |_,err| { + // player.connect_error(clone!(sender => move |_,err| { // Not the most user friendly... - sender.send(Action::ErrorNotification(format!("Playback: {}", err))).ok(); - })); + // sender.send(Action::ErrorNotification(format!("Playback: {}", err))).ok(); + // })); - player.connect_state_changed(clone!(sender => move |_,state| { - sender.send(Action::PlayerStateChanged(state)).ok(); - })); + // player.connect_state_changed(clone!(sender => move |_,state| { + // sender.send(Action::PlayerStateChanged(state)).ok(); + // })); - player.connect_media_info_updated(clone!(sender => move |_,info| { - sender.send(Action::PlayerMediaChanged(info.get_title(), info.get_duration())).ok(); - })); + // player.connect_media_info_updated(clone!(sender => move |_,info| { + // sender.send(Action::PlayerMediaChanged(info.get_title(), info.get_duration())).ok(); + // })); - player.connect_property_position_notify(clone!(sender => move |p| { - sender.send(Action::PlayerPositionChanged(p.get_position())).ok(); - })); + // player.connect_property_position_notify(clone!(sender => move |p| { + // sender.send(Action::PlayerPositionChanged(p.get_position())).ok(); + // })); gtk::timeout_add(50, clone!(sender, receiver => move || { // Uses receiver, content, header, sender, overlay, playback @@ -210,14 +208,7 @@ impl App { || {}, UndoState::Hidden); notif.show(&overlay); }, - Ok(Action::PlayEpisode(uri)) => { - // This must be a 'real' (file://) uri not a path - player.set_uri(&uri); - player.play(); - }, - Ok(Action::PlayerStateChanged(state)) => playback.state_changed(state), - Ok(Action::PlayerMediaChanged(t, l)) => playback.media_changed(t, l), - Ok(Action::PlayerPositionChanged(t)) => playback.position_changed(t), + Ok(Action::PlayEpisode(_uri)) => (), Err(_) => (), } diff --git a/hammond-gtk/src/widgets/mod.rs b/hammond-gtk/src/widgets/mod.rs index 946bb6d..32992c1 100644 --- a/hammond-gtk/src/widgets/mod.rs +++ b/hammond-gtk/src/widgets/mod.rs @@ -5,7 +5,6 @@ mod episode; mod home_view; mod show; mod shows_view; -mod playback; mod player; pub use self::aboutdialog::about_dialog; @@ -15,4 +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; +pub use self::player::PlayerWidget; diff --git a/hammond-gtk/src/widgets/playback.rs b/hammond-gtk/src/widgets/playback.rs deleted file mode 100644 index becef5b..0000000 --- a/hammond-gtk/src/widgets/playback.rs +++ /dev/null @@ -1,94 +0,0 @@ -use gstreamer::ClockTime; -use gstreamer_player as gst; -use gtk; -use gtk::prelude::*; - -#[derive(Debug, Clone)] -pub struct Playback { - reveal: gtk::Revealer, - container: gtk::Grid, - play: gtk::Button, - seek: gtk::Scale, - title: gtk::Label, - time: gtk::Label, -} - -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(); - let play = builder.get_object("play").unwrap(); - let seek = builder.get_object("seek").unwrap(); - let title = builder.get_object("title").unwrap(); - let time = builder.get_object("time").unwrap(); - - let reveal = gtk::Revealer::new(); - reveal.set_no_show_all(true); - reveal.add(&container); - - Playback { reveal, container, play, seek, title, time } - } -} - -impl Playback { - pub fn new() -> Playback { - Playback::default() - } - - pub fn set_icon(&self, icon: &str) { - let image = gtk::Image::new_from_icon_name(icon, gtk::IconSize::Button.into()); - self.play.set_image(Some(&image)); - } - - pub fn get_widget(&self) -> >k::Revealer { - &self.reveal - } - - pub fn state_changed(&self, state: gst::PlayerState) { - // Once the playback controls are shown they don't go - // away again so show them unconditionally - self.reveal.show(); - self.reveal.set_reveal_child(true); - match state { - gst::PlayerState::Buffering => { - println!("Buffering!!!!!!!"); - }, - gst::PlayerState::Stopped | gst::PlayerState::Paused => { - println!("Stopped/Paused"); - self.set_icon("media-playback-start-symbolic"); - }, - gst::PlayerState::Playing => { - println!("Playing"); - self.set_icon("media-playback-pause-symbolic"); - }, - _ => { - println!("Weird stuff"); - } - } - } - - pub fn media_changed(&self, title: Option, length: ClockTime) { - self.reveal.show(); - self.reveal.set_reveal_child(true); - if let Some(title) = title { - self.title.set_label(&title); - } else { - self.title.set_label(""); - } - if let Some(s) = length.seconds() { - let hours = s / 3600; - let s = s - (hours * 3600); - let mins = s / 60; - let s = s - (mins * 60); - // This is a little nasty - let t = format!("{}:{}:{}", hours, mins, s); - self.time.set_label(&t); - } else { - self.time.set_label(""); - } - } - - pub fn position_changed(&self, _pos: ClockTime) { - println!("Tada!"); - } -} diff --git a/hammond-gtk/src/widgets/player.rs b/hammond-gtk/src/widgets/player.rs index cf519e8..cff2f83 100644 --- a/hammond-gtk/src/widgets/player.rs +++ b/hammond-gtk/src/widgets/player.rs @@ -25,6 +25,12 @@ struct PlayerInfo { cover: gtk::Image, } +impl PlayerInfo { + fn init(&self) -> Result<(), Error> { + unimplemented!() + } +} + #[derive(Debug, Clone)] struct PlayerTimes { container: gtk::Box, @@ -54,9 +60,8 @@ struct PlayerControls { #[derive(Debug, Clone)] pub struct PlayerWidget { + pub action_bar: gtk::ActionBar, player: gst::Player, - revealer: gtk::Revealer, - action_bar: gtk::ActionBar, controls: PlayerControls, timer: PlayerTimes, info: PlayerInfo, @@ -66,7 +71,6 @@ impl Default for PlayerWidget { fn default() -> Self { let builder = gtk::Builder::new_from_resource("/org/gnome/Hammond/gtk/player_toolbar.ui"); let player = gst::Player::new(None, None); - let revealer = builder.get_object("revealer").unwrap(); let action_bar = builder.get_object("action_bar").unwrap(); let buttons = builder.get_object("buttons").unwrap(); @@ -86,7 +90,7 @@ impl Default for PlayerWidget { let timer_container = builder.get_object("timer").unwrap(); let progressed = builder.get_object("progress_time_label").unwrap(); - let duration = builder.get_object("total_duration").unwrap(); + let duration = builder.get_object("total_duration_label").unwrap(); let separator = builder.get_object("separator").unwrap(); let scalebar = builder.get_object("seek").unwrap(); let timer = PlayerTimes { @@ -110,7 +114,6 @@ impl Default for PlayerWidget { PlayerWidget { player, - revealer, action_bar, controls, timer, @@ -121,8 +124,7 @@ impl Default for PlayerWidget { impl PlayerWidget { fn reveal(&self) { - self.revealer.show(); - self.revealer.set_reveal_child(true); + self.action_bar.show(); } }