[fractal/up-dependencies: 3/3] Log error on settings update



commit c611529a0ff935b3d4a7aff4ae12a9170680ed1c
Author: Daniel GarcĂ­a Moreno <dani danigm net>
Date:   Wed Mar 4 09:54:30 2020 +0100

    Log error on settings update

 fractal-gtk/src/app/mod.rs         |  6 +++++-
 fractal-gtk/src/app/windowstate.rs | 17 +++++++++++------
 fractal-gtk/src/util.rs            |  6 +++++-
 3 files changed, 21 insertions(+), 8 deletions(-)
---
diff --git a/fractal-gtk/src/app/mod.rs b/fractal-gtk/src/app/mod.rs
index c6dab27f..1ae25aa1 100644
--- a/fractal-gtk/src/app/mod.rs
+++ b/fractal-gtk/src/app/mod.rs
@@ -9,6 +9,8 @@ use std::sync::mpsc::channel;
 use std::sync::mpsc::{Receiver, Sender};
 use std::sync::{Arc, Mutex, Weak};
 
+use log::error;
+
 use crate::appop::AppOp;
 use crate::backend::BKResponse;
 use crate::backend::Backend;
@@ -211,7 +213,9 @@ impl App {
         app.main_window.connect_delete_event(move |window, _| {
             let settings: gio::Settings = gio::Settings::new("org.gnome.Fractal");
             let window_state = WindowState::from_window(window);
-            window_state.save_in_gsettings(&settings);
+            if let Err(err) = window_state.save_in_gsettings(&settings) {
+                error!("Can't save the window settings: {:?}", err);
+            }
             Inhibit(false)
         });
 
diff --git a/fractal-gtk/src/app/windowstate.rs b/fractal-gtk/src/app/windowstate.rs
index 11bb84bb..7f417746 100644
--- a/fractal-gtk/src/app/windowstate.rs
+++ b/fractal-gtk/src/app/windowstate.rs
@@ -45,11 +45,16 @@ impl WindowState {
         }
     }
 
-    pub fn save_in_gsettings(&self, settings: &gio::Settings) {
-        let _ = settings.set_int("main-window-state-x", self.x);
-        let _ = settings.set_int("main-window-state-y", self.y);
-        let _ = settings.set_int("main-window-state-width", self.width);
-        let _ = settings.set_int("main-window-state-height", self.height);
-        let _ = settings.set_boolean("main-window-state-maximized", self.is_maximized);
+    pub fn save_in_gsettings(
+        &self,
+        settings: &gio::Settings,
+    ) -> Result<(), glib::error::BoolError> {
+        settings.set_int("main-window-state-x", self.x)?;
+        settings.set_int("main-window-state-y", self.y)?;
+        settings.set_int("main-window-state-width", self.width)?;
+        settings.set_int("main-window-state-height", self.height)?;
+        settings.set_boolean("main-window-state-maximized", self.is_maximized)?;
+
+        Ok(())
     }
 }
diff --git a/fractal-gtk/src/util.rs b/fractal-gtk/src/util.rs
index 29777497..a509ae89 100644
--- a/fractal-gtk/src/util.rs
+++ b/fractal-gtk/src/util.rs
@@ -5,6 +5,8 @@ use gdk::prelude::*;
 use gdk_pixbuf::Pixbuf;
 use gio::{Settings, SettingsExt, SettingsSchemaSource};
 
+use log::error;
+
 use html2pango::{html_escape, markup_links};
 
 pub mod glib_thread_prelude {
@@ -70,7 +72,9 @@ pub fn set_markdown_schema(md: bool) {
         .and_then(|s| s.lookup("org.gnome.Fractal", true))
         .map(|_| {
             let settings: Settings = Settings::new("org.gnome.Fractal");
-            let _ = settings.set_boolean("markdown-active", md);
+            if let Err(err) = settings.set_boolean("markdown-active", md) {
+                error!("Can't save markdown active state: {:?}", err);
+            }
         });
 }
 


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