Do not pass some things by value when not needed.

This commit is contained in:
Jordan Petridis 2018-04-29 19:27:40 +03:00
parent 8951a6e237
commit 00d9019f29
No known key found for this signature in database
GPG Key ID: CEABAD9F5683B9A6
3 changed files with 5 additions and 5 deletions

View File

@ -104,7 +104,7 @@ where
// Kudos to Julian Sparber
// https://blogs.gnome.org/jsparber/2018/04/29/animate-a-scrolledwindow/
pub fn smooth_scroll_to(view: gtk::ScrolledWindow, target: gtk::Adjustment) {
pub fn smooth_scroll_to(view: &gtk::ScrolledWindow, target: &gtk::Adjustment) {
if let Some(adj) = view.get_vadjustment() {
if let Some(clock) = view.get_frame_clock() {
let duration = 200;
@ -119,10 +119,10 @@ pub fn smooth_scroll_to(view: gtk::ScrolledWindow, target: gtk::Adjustment) {
let mut t = (now - start_time) as f64 / (end_time - start_time) as f64;
t = ease_out_cubic(t);
adj.set_value(start + t * (end - start));
return glib::Continue(true);
glib::Continue(true)
} else {
adj.set_value(end);
return glib::Continue(false);
glib::Continue(false)
}
});
}

View File

@ -132,7 +132,7 @@ impl HomeView {
// Copy the vertical scrollbar adjustment from the old view into the new one.
sendcell
.try_get()
.map(|x| utils::smooth_scroll_to(self.scrolled_window.clone(), x.clone()));
.map(|x| utils::smooth_scroll_to(&self.scrolled_window, &x));
}
Ok(())

View File

@ -165,7 +165,7 @@ impl ShowWidget {
// Copy the vertical scrollbar adjustment from the old view into the new one.
sendcell
.try_get()
.map(|x| utils::smooth_scroll_to(self.scrolled_window.clone(), x.clone()));
.map(|x| utils::smooth_scroll_to(&self.scrolled_window, &x));
}
Ok(())