Wire and use the new Header struct instead.

This commit is contained in:
Jordan Petridis 2017-12-01 01:20:49 +02:00
parent dd0034327b
commit 5414dbdb37
No known key found for this signature in database
GPG Key ID: CEABAD9F5683B9A6
3 changed files with 18 additions and 6 deletions

View File

@ -44,8 +44,7 @@ impl Content {
podcasts: pop,
};
content.setup_stack();
content.podcasts.init(&content.stack);
content.init();
content
}
@ -57,4 +56,9 @@ impl Content {
self.stack.add_named(&self.podcasts.container, "fb_parent"); // Rename into "podcasts"
self.stack.add_named(&self.empty.container, "empty"); // Rename into "empty"
}
fn init(&self) {
self.setup_stack();
self.podcasts.init(&self.stack);
}
}

View File

@ -9,14 +9,14 @@ use utils;
#[derive(Debug)]
pub struct Header {
container: gtk::HeaderBar,
pub container: gtk::HeaderBar,
home: gtk::Button,
refresh: gtk::Button,
add_toggle: gtk::MenuButton,
}
impl Header {
fn new() -> Header {
pub fn new() -> Header {
let builder = gtk::Builder::new_from_resource("/org/gnome/hammond/gtk/headerbar.ui");
let header: gtk::HeaderBar = builder.get_object("headerbar1").unwrap();
@ -32,6 +32,12 @@ impl Header {
}
}
pub fn new_initialized(stack: &gtk::Stack) -> Header {
let header = Header::new();
header.init(stack);
header
}
fn init(&self, stack: &gtk::Stack) {
let builder = gtk::Builder::new_from_resource("/org/gnome/hammond/gtk/headerbar.ui");

View File

@ -101,8 +101,10 @@ fn build_ui(app: &gtk::Application) {
});
// Get the headerbar
let header = headerbar::get_headerbar(&stack);
window.set_titlebar(&header);
// let header = headerbar::get_headerbar(&stack);
// window.set_titlebar(&header);
let header = headerbar::Header::new_initialized(&stack);
window.set_titlebar(&header.container);
window.show_all();
window.activate();