Commit 112b61d3 authored by Jordan Petridis's avatar Jordan Petridis 🌱

EpisodesView: Retain vertical scrolling adjustment upon view refresh.

parent 9d82b0ed
Pipeline #1822 passed with stages
......@@ -3,11 +3,13 @@
<interface>
<requires lib="gtk+" version="3.20"/>
<object class="GtkBox" id="container">
<property name="name">container</property>
<property name="visible">True</property>
<property name="can_focus">False</property>
<property name="orientation">vertical</property>
<child>
<object class="GtkScrolledWindow">
<object class="GtkScrolledWindow" id="scrolled_window">
<property name="name">scrolled_window</property>
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="shadow_type">in</property>
......
......@@ -134,12 +134,8 @@ impl App {
utils::refresh_feed(headerbar.clone(), Some(vec![s]), sender.clone())
}
}
Ok(Action::RefreshViews) => {
content.update();
}
Ok(Action::RefreshEpisodesViewBGR) => {
content.update_episode_view_if_baground();
}
Ok(Action::RefreshViews) => content.update(),
Ok(Action::RefreshEpisodesViewBGR) => content.update_episode_view_if_baground(),
Ok(Action::HeaderBarShowTile(title)) => headerbar.switch_to_back(&title),
Ok(Action::HeaderBarNormal) => headerbar.switch_to_normal(),
Ok(Action::HeaderBarHideUpdateIndicator) => headerbar.hide_update_notification(),
......
......@@ -193,8 +193,27 @@ impl EpisodeStack {
}
pub fn update(&self) {
let old = self.stack.get_child_by_name("episodes").unwrap();
use gtk::Cast;
let old = self.stack
.get_child_by_name("episodes")
.unwrap()
.downcast::<gtk::Box>()
.unwrap();
info!("Name: {:?}", WidgetExt::get_name(&old));
let scrolled_window = old.get_children()
.first()
.unwrap()
.clone()
.downcast::<gtk::ScrolledWindow>()
.unwrap();
info!("Name: {:?}", WidgetExt::get_name(&scrolled_window));
let eps = EpisodesView::new(self.sender.clone());
scrolled_window
.get_vadjustment()
.map(|x| eps.set_vadjustment(&x));
self.stack.remove(&old);
self.stack.add_named(&eps.container, "episodes");
......
......@@ -24,6 +24,7 @@ enum ListSplit {
#[derive(Debug, Clone)]
pub struct EpisodesView {
pub container: gtk::Box,
scrolled_window: gtk::ScrolledWindow,
frame_parent: gtk::Box,
today_box: gtk::Box,
yday_box: gtk::Box,
......@@ -41,6 +42,7 @@ 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 scrolled_window: gtk::ScrolledWindow = builder.get_object("scrolled_window").unwrap();
let frame_parent: gtk::Box = builder.get_object("frame_parent").unwrap();
let today_box: gtk::Box = builder.get_object("today_box").unwrap();
let yday_box: gtk::Box = builder.get_object("yday_box").unwrap();
......@@ -55,6 +57,7 @@ impl Default for EpisodesView {
EpisodesView {
container,
scrolled_window,
frame_parent,
today_box,
yday_box,
......@@ -147,6 +150,10 @@ impl EpisodesView {
true
}
pub fn set_vadjustment(&self, vadjustment: &gtk::Adjustment) {
self.scrolled_window.set_vadjustment(vadjustment)
}
}
fn split(now: &DateTime<Utc>, epoch: i64) -> ListSplit {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment