Initial stackswitcher addition into the headerbar.
This commit is contained in:
parent
851be1fcfb
commit
e127941d8a
@ -112,7 +112,6 @@
|
||||
<object class="GtkHeaderBar" id="headerbar1">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="title">Hammond</property>
|
||||
<property name="has_subtitle">False</property>
|
||||
<property name="show_close_button">True</property>
|
||||
<child>
|
||||
@ -131,6 +130,15 @@
|
||||
</object>
|
||||
</child>
|
||||
</object>
|
||||
</child>
|
||||
<child>
|
||||
<object class="GtkStackSwitcher" id="switch">
|
||||
<property name="visible">True</property>
|
||||
<property name="can_focus">False</property>
|
||||
<property name="halign">center</property>
|
||||
<property name="hexpand">True</property>
|
||||
<property name="vexpand">True</property>
|
||||
</object>
|
||||
<packing>
|
||||
<property name="position">3</property>
|
||||
</packing>
|
||||
|
||||
@ -24,8 +24,8 @@ impl Content {
|
||||
let podcasts = PopulatedView::new();
|
||||
let empty = EmptyView::new();
|
||||
|
||||
stack.add_named(&widget.container, "widget");
|
||||
stack.add_named(&podcasts.container, "podcasts");
|
||||
stack.add_titled(&widget.container, "widget", "Episodes");
|
||||
stack.add_titled(&podcasts.container, "podcasts", "Shows");
|
||||
stack.add_named(&empty.container, "empty");
|
||||
|
||||
Content {
|
||||
@ -58,7 +58,8 @@ impl Content {
|
||||
self.stack.remove(&old);
|
||||
|
||||
self.widget = pdw;
|
||||
self.stack.add_named(&self.widget.container, "widget");
|
||||
self.stack
|
||||
.add_titled(&self.widget.container, "widget", "Episodes");
|
||||
self.stack.set_visible_child_name(&vis);
|
||||
old.destroy();
|
||||
}
|
||||
@ -69,7 +70,8 @@ impl Content {
|
||||
self.stack.remove(&old);
|
||||
|
||||
self.podcasts = pop;
|
||||
self.stack.add_named(&self.podcasts.container, "podcasts");
|
||||
self.stack
|
||||
.add_titled(&self.podcasts.container, "podcasts", "Shows");
|
||||
self.stack.set_visible_child_name(&vis);
|
||||
old.destroy();
|
||||
}
|
||||
@ -200,14 +202,14 @@ impl ContentState<PodcastsView> {
|
||||
fn replace_widget(stack: >k::Stack, pdw: &PodcastWidget) {
|
||||
let old = stack.get_child_by_name("widget").unwrap();
|
||||
stack.remove(&old);
|
||||
stack.add_named(&pdw.container, "widget");
|
||||
stack.add_titled(&pdw.container, "widget", "Episode");
|
||||
old.destroy();
|
||||
}
|
||||
|
||||
fn replace_podcasts(stack: >k::Stack, pop: &PopulatedView) {
|
||||
let old = stack.get_child_by_name("podcasts").unwrap();
|
||||
stack.remove(&old);
|
||||
stack.add_named(&pop.container, "podcasts");
|
||||
stack.add_titled(&pop.container, "podcasts", "Shows");
|
||||
old.destroy();
|
||||
}
|
||||
|
||||
|
||||
@ -13,6 +13,7 @@ pub struct Header {
|
||||
home: gtk::Button,
|
||||
refresh: gtk::Button,
|
||||
add_toggle: gtk::MenuButton,
|
||||
switch: gtk::StackSwitcher,
|
||||
}
|
||||
|
||||
impl Header {
|
||||
@ -23,12 +24,16 @@ impl Header {
|
||||
let home: gtk::Button = builder.get_object("homebutton").unwrap();
|
||||
let refresh: gtk::Button = builder.get_object("refbutton").unwrap();
|
||||
let add_toggle: gtk::MenuButton = builder.get_object("add-toggle-button").unwrap();
|
||||
let switch: gtk::StackSwitcher = builder.get_object("switch").unwrap();
|
||||
switch.set_halign(gtk::Align::Center);
|
||||
switch.show();
|
||||
|
||||
Header {
|
||||
container: header,
|
||||
home,
|
||||
refresh,
|
||||
add_toggle,
|
||||
switch,
|
||||
}
|
||||
}
|
||||
|
||||
@ -44,6 +49,7 @@ impl Header {
|
||||
let add_popover: gtk::Popover = builder.get_object("add-popover").unwrap();
|
||||
let new_url: gtk::Entry = builder.get_object("new-url").unwrap();
|
||||
let add_button: gtk::Button = builder.get_object("add-button").unwrap();
|
||||
self.switch.set_stack(stack);
|
||||
|
||||
new_url.connect_changed(move |url| {
|
||||
println!("{:?}", url.get_text());
|
||||
|
||||
Loading…
Reference in New Issue
Block a user