[gnome-tour: 1/2] Remove anyhow and adapt paginator




commit b876e4e46e5b51f2d716522bdb7902b97f43a8d6
Author: Julian Hofer <julianhofer gnome org>
Date:   Sun Oct 4 00:41:58 2020 +0200

    Remove anyhow and adapt paginator
    
    Anyhow was only used for paginator and
    Option makes arguably more sense here than Result

 Cargo.lock               |  1 -
 Cargo.toml               |  1 -
 src/application.rs       |  4 ++--
 src/widgets/paginator.rs | 13 ++++++-------
 4 files changed, 8 insertions(+), 11 deletions(-)
---
diff --git a/Cargo.lock b/Cargo.lock
index 487465c..927c82d 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -382,7 +382,6 @@ dependencies = [
 name = "gnome-tour"
 version = "3.38.0"
 dependencies = [
- "anyhow",
  "gdk",
  "gettext-rs",
  "gio",
diff --git a/Cargo.toml b/Cargo.toml
index 33b0d59..a7073c5 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -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"
diff --git a/src/application.rs b/src/application.rs
index ee6cec7..a95b00a 100644
--- a/src/application.rs
+++ b/src/application.rs
@@ -61,7 +61,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();
                     }
                 }
@@ -73,7 +73,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();
                     }
                 }
diff --git a/src/widgets/paginator.rs b/src/widgets/paginator.rs
index 20f25fb..7fc070a 100644
--- a/src/widgets/paginator.rs
+++ b/src/widgets/paginator.rs
@@ -1,4 +1,3 @@
-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) {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]