EpisodesView: Added glade files and initial yak shaving.

This commit is contained in:
Jordan Petridis 2017-12-18 18:20:40 +02:00
parent 945600b20d
commit 32cd24fc7b
No known key found for this signature in database
GPG Key ID: CEABAD9F5683B9A6
9 changed files with 190 additions and 34 deletions

View File

@ -15,6 +15,7 @@
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="valign">center</property>
<property name="orientation">vertical</property>
<property name="spacing">5</property>
<child>
@ -261,8 +262,8 @@
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="expand">True</property>
<property name="fill">False</property>
<property name="padding">5</property>
<property name="position">0</property>
</packing>
@ -275,6 +276,7 @@
<property name="expand">False</property>
<property name="fill">True</property>
<property name="padding">5</property>
<property name="pack_type">end</property>
<property name="position">1</property>
</packing>
</child>

View File

@ -0,0 +1,82 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.20.2 -->
<interface>
<requires lib="gtk+" version="3.20"/>
<object class="GtkBox" id="container">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkScrolledWindow">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="shadow_type">in</property>
<child>
<object class="GtkViewport">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">center</property>
<child>
<object class="GtkBox">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<child>
<placeholder/>
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkBox" id="frame_parent">
<property name="width_request">600</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">center</property>
<property name="orientation">vertical</property>
<child>
<placeholder/>
</child>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<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>
<child>
<placeholder/>
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">False</property>
<property name="position">2</property>
</packing>
</child>
</object>
</child>
</object>
</child>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
</object>
</interface>

View File

@ -0,0 +1,25 @@
<?xml version="1.0" encoding="UTF-8"?>
<!-- Generated with glade 3.20.2 -->
<interface>
<requires lib="gtk+" version="3.20"/>
<object class="GtkBox" id="container">
<property name="visible">True</property>
<property name="can_focus">False</property>
<child>
<object class="GtkImage" id="cover">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="pixel_size">102</property>
<property name="icon_name">image-x-generic-symbolic</property>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="position">0</property>
</packing>
</child>
<child>
<placeholder/>
</child>
</object>
</interface>

View File

@ -78,6 +78,26 @@
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<property name="spacing">10</property>
<child type="center">
<object class="GtkLabel" id="description">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">start</property>
<property name="valign">end</property>
<property name="label" translatable="yes">Show description</property>
<property name="wrap">True</property>
<property name="max_width_chars">57</property>
<attributes>
<attribute name="weight" value="medium"/>
</attributes>
</object>
<packing>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="pack_type">end</property>
<property name="position">1</property>
</packing>
</child>
<child>
<object class="GtkBox">
<property name="visible">True</property>
@ -128,6 +148,9 @@
<property name="receives_default">True</property>
<property name="halign">center</property>
<property name="valign">center</property>
<style>
<class name="destructive-action"/>
</style>
</object>
<packing>
<property name="expand">False</property>
@ -145,27 +168,6 @@
<property name="position">0</property>
</packing>
</child>
<child>
<object class="GtkLabel" id="description">
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="halign">start</property>
<property name="valign">center</property>
<property name="label" translatable="yes">Show description</property>
<property name="wrap">True</property>
<property name="wrap_mode">word-char</property>
<property name="max_width_chars">55</property>
<attributes>
<attribute name="weight" value="medium"/>
</attributes>
</object>
<packing>
<property name="expand">True</property>
<property name="fill">True</property>
<property name="pack_type">end</property>
<property name="position">1</property>
</packing>
</child>
</object>
<packing>
<property name="expand">True</property>
@ -176,7 +178,7 @@
</object>
<packing>
<property name="expand">False</property>
<property name="fill">True</property>
<property name="fill">False</property>
<property name="position">0</property>
</packing>
</child>

View File

@ -4,6 +4,8 @@
<file preprocess="xml-stripblanks">gtk/episode_widget.ui</file>
<file preprocess="xml-stripblanks">gtk/show_widget.ui</file>
<file preprocess="xml-stripblanks">gtk/empty_view.ui</file>
<file preprocess="xml-stripblanks">gtk/episodes_view.ui</file>
<file preprocess="xml-stripblanks">gtk/episodes_view_widget.ui</file>
<file preprocess="xml-stripblanks">gtk/shows_view.ui</file>
<file preprocess="xml-stripblanks">gtk/shows_child.ui</file>
<file preprocess="xml-stripblanks">gtk/headerbar.ui</file>

View File

@ -6,6 +6,7 @@ use hammond_data::dbqueries;
use views::shows::ShowsPopulated;
use views::empty::EmptyView;
use views::episodes::EpisodesView;
use widgets::show::ShowWidget;
use headerbar::Header;
@ -155,14 +156,14 @@ struct EpisodeStack {
impl EpisodeStack {
fn new() -> Rc<EpisodeStack> {
let _pop = RecentEpisodes {};
let episodes = EpisodesView::default();
let empty = EmptyView::new();
let stack = gtk::Stack::new();
// stack.add_named(&pop.container, "populated");
stack.add_named(&episodes.container, "episodes");
stack.add_named(&empty.container, "empty");
// FIXME:
stack.set_visible_child_name("empty");
stack.set_visible_child_name("episodes");
Rc::new(EpisodeStack {
// empty,

View File

@ -1 +1,47 @@
use gtk;
use gtk::prelude::*;
use widgets::episode::EpisodeWidget;
#[derive(Debug, Clone)]
pub struct EpisodesView {
pub container: gtk::Box,
frame_parent: gtk::Box,
}
impl Default for EpisodesView {
fn default() -> Self {
let builder = gtk::Builder::new_from_resource("/org/gnome/hammond/gtk/episodes_view.ui");
let container: gtk::Box = builder.get_object("container").unwrap();
let frame_parent: gtk::Box = builder.get_object("frame_parent").unwrap();
EpisodesView {
container,
frame_parent,
}
}
}
#[derive(Debug, Clone)]
struct EpisodesViewWidget {
container: gtk::Box,
image: gtk::Image,
episode: gtk::Box,
}
impl Default for EpisodesViewWidget {
fn default() -> Self {
let builder =
gtk::Builder::new_from_resource("/org/gnome/hammond/gtk/episodes_view_widget.ui");
let container: gtk::Box = builder.get_object("container").unwrap();
let image: gtk::Image = builder.get_object("cover").unwrap();
let ep = EpisodeWidget::default();
container.add(&ep.container);
EpisodesViewWidget {
container,
image,
episode: ep.container,
}
}
}

View File

@ -32,9 +32,9 @@ type Foo = RefCell<
thread_local!(static GLOBAL: Foo = RefCell::new(None));
#[derive(Debug)]
struct EpisodeWidget {
container: gtk::Box,
#[derive(Debug, Clone)]
pub struct EpisodeWidget {
pub container: gtk::Box,
play: gtk::Button,
delete: gtk::Button,
download: gtk::Button,

View File

@ -40,10 +40,6 @@ impl Default for ShowWidget {
let link: gtk::Button = builder.get_object("link_button").unwrap();
let settings: gtk::MenuButton = builder.get_object("settings_button").unwrap();
unsub
.get_style_context()
.map(|c| c.add_class("destructive-action"));
ShowWidget {
container,
cover,