ShowStack: Copy the scrollbar position only if both widget represent the same podcast.
This commit is contained in:
parent
e961d5f8b0
commit
4a6a9517f1
@ -161,6 +161,15 @@ impl ShowStack {
|
|||||||
.unwrap();
|
.unwrap();
|
||||||
debug!("Name: {:?}", WidgetExt::get_name(&old));
|
debug!("Name: {:?}", WidgetExt::get_name(&old));
|
||||||
|
|
||||||
|
let new = ShowWidget::new(Arc::new(self.clone()), pd, self.sender.clone());
|
||||||
|
// Each composite ShowWidget is a gtkBox with the Podcast.id encoded in the gtk::Widget
|
||||||
|
// name. It's a hack since we can't yet subclass GObject easily.
|
||||||
|
let oldid = WidgetExt::get_name(&old);
|
||||||
|
let newid = WidgetExt::get_name(&new.container);
|
||||||
|
debug!("Old widget Name: {:?}\nNew widget Name: {:?}", oldid, newid);
|
||||||
|
|
||||||
|
// Only copy the old scrollbar if both widget's represent the same podcast.
|
||||||
|
if newid == oldid {
|
||||||
let scrolled_window = old.get_children()
|
let scrolled_window = old.get_children()
|
||||||
.first()
|
.first()
|
||||||
// This is guaranted to exist based on the show_widget.ui file.
|
// This is guaranted to exist based on the show_widget.ui file.
|
||||||
@ -171,11 +180,11 @@ impl ShowStack {
|
|||||||
.unwrap();
|
.unwrap();
|
||||||
debug!("Name: {:?}", WidgetExt::get_name(&scrolled_window));
|
debug!("Name: {:?}", WidgetExt::get_name(&scrolled_window));
|
||||||
|
|
||||||
let new = ShowWidget::new(Arc::new(self.clone()), pd, self.sender.clone());
|
|
||||||
// Copy the vertical scrollbar adjustment from the old view into the new one.
|
// Copy the vertical scrollbar adjustment from the old view into the new one.
|
||||||
scrolled_window
|
scrolled_window
|
||||||
.get_vadjustment()
|
.get_vadjustment()
|
||||||
.map(|x| new.set_vadjustment(&x));
|
.map(|x| new.set_vadjustment(&x));
|
||||||
|
}
|
||||||
|
|
||||||
self.stack.remove(&old);
|
self.stack.remove(&old);
|
||||||
self.stack.add_named(&new.container, "widget");
|
self.stack.add_named(&new.container, "widget");
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user