[gnome-games/wip/exalm/cleanups: 6/10] gamepad-view: Handle error internally



commit 742e9461aed73fec6e62c7772c11daa38e4fcf4a
Author: Alexander Mikhaylenko <exalm7659 gmail com>
Date:   Mon Feb 25 15:41:28 2019 +0500

    gamepad-view: Handle error internally

 src/ui/gamepad-mapper.vala  |  7 +------
 src/ui/gamepad-tester.vala  |  7 +------
 src/ui/gamepad-view.vala    | 14 ++++++++++----
 src/ui/keyboard-mapper.vala |  7 +------
 src/ui/keyboard-tester.vala |  7 +------
 5 files changed, 14 insertions(+), 28 deletions(-)
---
diff --git a/src/ui/gamepad-mapper.vala b/src/ui/gamepad-mapper.vala
index 5182a2ce..c6f6ce33 100644
--- a/src/ui/gamepad-mapper.vala
+++ b/src/ui/gamepad-mapper.vala
@@ -23,12 +23,7 @@ private class Games.GamepadMapper : Gtk.Bin {
                get { return _configuration; }
                construct {
                        _configuration = value;
-                       try {
-                               gamepad_view.set_configuration (value);
-                       }
-                       catch (Error e) {
-                               critical ("Could not set up gamepad view: %s", e.message);
-                       }
+                       gamepad_view.set_configuration (value);
                }
        }
 
diff --git a/src/ui/gamepad-tester.vala b/src/ui/gamepad-tester.vala
index ff624235..0da0e2e6 100644
--- a/src/ui/gamepad-tester.vala
+++ b/src/ui/gamepad-tester.vala
@@ -16,12 +16,7 @@ private class Games.GamepadTester : Gtk.Bin {
                get { return _configuration; }
                construct {
                        _configuration = value;
-                       try {
-                               gamepad_view.set_configuration (value);
-                       }
-                       catch (Error e) {
-                               critical ("Could not set up gamepad view: %s", e.message);
-                       }
+                       gamepad_view.set_configuration (value);
                }
        }
 
diff --git a/src/ui/gamepad-view.vala b/src/ui/gamepad-view.vala
index 98a3817b..ee2e6789 100644
--- a/src/ui/gamepad-view.vala
+++ b/src/ui/gamepad-view.vala
@@ -11,11 +11,17 @@ private class Games.GamepadView : Gtk.DrawingArea {
                input_highlights = {};
        }
 
-       public void set_configuration (GamepadViewConfiguration configuration) throws Error {
-               var bytes = resources_lookup_data (configuration.svg_path, ResourceLookupFlags.NONE);
-               var data = bytes.get_data ();
+       public void set_configuration (GamepadViewConfiguration configuration) {
+               try {
+                       var bytes = resources_lookup_data (configuration.svg_path, ResourceLookupFlags.NONE);
+                       var data = bytes.get_data ();
+
+                       handle = new Rsvg.Handle.from_data (data);
+               }
+               catch (Error e) {
+                       critical ("Could not set up gamepad view: %s", e.message);
+               }
 
-               handle = new Rsvg.Handle.from_data (data);
                set_size_request (handle.width, handle.height);
                this.configuration = configuration;
                input_highlights = new bool[configuration.input_paths.length];
diff --git a/src/ui/keyboard-mapper.vala b/src/ui/keyboard-mapper.vala
index d447e067..519523fc 100644
--- a/src/ui/keyboard-mapper.vala
+++ b/src/ui/keyboard-mapper.vala
@@ -19,12 +19,7 @@ private class Games.KeyboardMapper : Gtk.Bin {
                get { return _configuration; }
                construct {
                        _configuration = value;
-                       try {
-                               gamepad_view.set_configuration (value);
-                       }
-                       catch (Error e) {
-                               critical ("Could not set up gamepad view: %s", e.message);
-                       }
+                       gamepad_view.set_configuration (value);
                }
        }
 
diff --git a/src/ui/keyboard-tester.vala b/src/ui/keyboard-tester.vala
index 84519b0a..bf3ec29b 100644
--- a/src/ui/keyboard-tester.vala
+++ b/src/ui/keyboard-tester.vala
@@ -12,12 +12,7 @@ private class Games.KeyboardTester : Gtk.Bin {
                get { return _configuration; }
                construct {
                        _configuration = value;
-                       try {
-                               gamepad_view.set_configuration (value);
-                       }
-                       catch (Error e) {
-                               critical ("Could not set up gamepad view: %s", e.message);
-                       }
+                       gamepad_view.set_configuration (value);
                }
        }
 


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