Commit 68642411 authored by Bilal Elmoussaoui's avatar Bilal Elmoussaoui

Merge branch 'anyhow' into 'master'

Remove anyhow and adapt paginator See merge request GNOME/gnome-tour!25
parents 7f3c2334 b876e4e4
......@@ -382,7 +382,6 @@ dependencies = [
name = "gnome-tour"
version = "3.38.0"
dependencies = [
"anyhow",
"gdk",
"gettext-rs",
"gio",
......
......@@ -16,7 +16,6 @@ log = "0.4"
gettext-rs = { version = "0.4", features = ["gettext-system"] }
libhandy = "0.7"
pretty_env_logger = "0.4"
anyhow = "1.0"
[dependencies.gst_player]
version = "0.16"
......
......@@ -62,7 +62,7 @@ impl Application {
"next-page",
clone!(@strong application => move |_, _| {
if let Some(window) = &*application.window.borrow().clone() {
if window.paginator.borrow_mut().next().is_err() {
if window.paginator.borrow_mut().try_next().is_none() {
window.widget.close();
}
}
......@@ -74,7 +74,7 @@ impl Application {
"previous-page",
clone!(@strong application => move |_, _| {
if let Some(window) = &*application.window.borrow().clone() {
if window.paginator.borrow_mut().previous().is_err() {
if window.paginator.borrow_mut().try_previous().is_none() {
window.reset_tour();
}
}
......
use anyhow::Result;
use gettextrs::gettext;
use glib::clone;
use gtk::prelude::*;
......@@ -38,22 +37,22 @@ impl PaginatorWidget {
paginator
}
pub fn next(&self) -> Result<()> {
pub fn try_next(&self) -> Option<()> {
let p = *self.current_page.borrow() + 1;
if p == self.carousel.get_n_pages() {
anyhow::bail!("Already at the latest page");
return None;
}
self.set_page(p);
Ok(())
Some(())
}
pub fn previous(&self) -> Result<()> {
pub fn try_previous(&self) -> Option<()> {
let p = *self.current_page.borrow();
if p == 0 {
anyhow::bail!("Already at the first page");
return None;
}
self.set_page(p - 1);
Ok(())
Some(())
}
pub fn add_page(&self, page: gtk::Widget) {
......
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