h-gtk: Bind the new player widget to code.

This commit is contained in:
Jordan Petridis 2018-06-12 17:43:21 +03:00
parent 1142948945
commit 58f09ba150
3 changed files with 140 additions and 18 deletions

View File

@ -129,26 +129,16 @@
</packing>
</child>
<child>
<object class="GtkImage" id="show_cover">
<object class="GtkBox" id="info">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="pixel_size">36</property>
<property name="icon_name">image-x-generic-symbolic</property>
</object>
<packing>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<property name="spacing">6</property>
<child>
<object class="GtkLabel" id="show_label">
<object class="GtkImage" id="show_cover">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Show Title</property>
<property name="pixel_size">42</property>
<property name="icon_name">image-x-generic-symbolic</property>
</object>
<packing>
<property name="expand">False</property>
@ -157,10 +147,34 @@
</packing>
</child>
<child>
<object class="GtkLabel" id="episode_label">
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Episode Title</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkLabel" id="show_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Show Title</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="episode_label">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="label" translatable="yes">Episode Title</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">False</property>
@ -170,7 +184,7 @@
</child>
</object>
<packing>
<property name="position">2</property>
<property name="position">1</property>
</packing>
</child>
<child>

View File

@ -6,6 +6,7 @@ mod home_view;
mod show;
mod shows_view;
mod playback;
mod player;
pub use self::aboutdialog::about_dialog;
pub use self::empty::EmptyView;

View File

@ -0,0 +1,107 @@
#![allow(warnings)]
use gstreamer_player as gst;
use gtk;
use gtk::prelude::*;
#[derive(Debug, Clone)]
struct PlayerInfo {
container: gtk::Box,
show: gtk::Label,
episode: gtk::Label,
cover: gtk::Image,
}
#[derive(Debug, Clone)]
struct PlayerTimes {
container: gtk::Box,
progressed: gtk::Label,
duration: gtk::Label,
separator: gtk::Label,
scalebar: gtk::Scale,
}
#[derive(Debug, Clone)]
// FIXME: This is a mock till stuff get sorted out.
enum PlayerState {
Playing,
Paused,
Ready,
}
#[derive(Debug, Clone)]
struct PlayerControls {
container: gtk::Box,
play: gtk::Button,
pause: gtk::Button,
forward: gtk::Button,
rewind: gtk::Button,
state: PlayerState,
}
#[derive(Debug, Clone)]
pub struct PlayerWidget {
player: gst::Player,
revealer: gtk::Revealer,
action_bar: gtk::ActionBar,
controls: PlayerControls,
timer: PlayerTimes,
info: PlayerInfo,
}
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();
let play = builder.get_object("play_button").unwrap();
let pause = builder.get_object("pause_button").unwrap();
let forward = builder.get_object("ff_button").unwrap();
let rewind = builder.get_object("rewind_button").unwrap();
let controls = PlayerControls {
container: buttons,
play,
pause,
forward,
rewind,
state: PlayerState::Ready,
};
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 separator = builder.get_object("separator").unwrap();
let scalebar = builder.get_object("seek").unwrap();
let timer = PlayerTimes {
container: timer_container,
progressed,
duration,
separator,
scalebar,
};
let labels = builder.get_object("info").unwrap();
let show = builder.get_object("show_label").unwrap();
let episode = builder.get_object("episode_label").unwrap();
let cover = builder.get_object("show_cover").unwrap();
let info = PlayerInfo {
container: labels,
show,
episode,
cover,
};
PlayerWidget {
player,
revealer,
action_bar,
controls,
timer,
info,
}
}
}