[gnome-games/wip/exalm/cleanups: 10/13] gamepad-view: Use a property for setting configuration
- From: Alexander Mikhaylenko <alexm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-games/wip/exalm/cleanups: 10/13] gamepad-view: Use a property for setting configuration
- Date: Mon, 25 Feb 2019 11:03:54 +0000 (UTC)
commit 4a6f45c921c16c80c127fd39866051dbe65a98c7
Author: Alexander Mikhaylenko <exalm7659 gmail com>
Date: Mon Feb 25 15:46:12 2019 +0500
gamepad-view: Use a property for setting configuration
src/ui/gamepad-mapper.vala | 2 +-
src/ui/gamepad-tester.vala | 2 +-
src/ui/gamepad-view.vala | 44 +++++++++++++++++++++++++-------------------
src/ui/keyboard-mapper.vala | 2 +-
src/ui/keyboard-tester.vala | 2 +-
5 files changed, 29 insertions(+), 23 deletions(-)
---
diff --git a/src/ui/gamepad-mapper.vala b/src/ui/gamepad-mapper.vala
index c6f6ce33..4b6bd099 100644
--- a/src/ui/gamepad-mapper.vala
+++ b/src/ui/gamepad-mapper.vala
@@ -23,7 +23,7 @@ private class Games.GamepadMapper : Gtk.Bin {
get { return _configuration; }
construct {
_configuration = value;
- gamepad_view.set_configuration (value);
+ gamepad_view.configuration = value;
}
}
diff --git a/src/ui/gamepad-tester.vala b/src/ui/gamepad-tester.vala
index 0da0e2e6..4c7bfc58 100644
--- a/src/ui/gamepad-tester.vala
+++ b/src/ui/gamepad-tester.vala
@@ -16,7 +16,7 @@ private class Games.GamepadTester : Gtk.Bin {
get { return _configuration; }
construct {
_configuration = value;
- gamepad_view.set_configuration (value);
+ gamepad_view.configuration = value;
}
}
diff --git a/src/ui/gamepad-view.vala b/src/ui/gamepad-view.vala
index ee2e6789..9cba3a50 100644
--- a/src/ui/gamepad-view.vala
+++ b/src/ui/gamepad-view.vala
@@ -2,31 +2,37 @@
private class Games.GamepadView : Gtk.DrawingArea {
private Rsvg.Handle handle;
- private GamepadViewConfiguration configuration;
private bool[] input_highlights;
- construct {
- handle = new Rsvg.Handle ();
- configuration = { "", new GamepadInputPath[0] };
- input_highlights = {};
- }
+ private GamepadViewConfiguration _configuration;
+ public GamepadViewConfiguration configuration {
+ get { return _configuration; }
+ set {
+ if (value == configuration)
+ return;
- public void set_configuration (GamepadViewConfiguration configuration) {
- try {
- var bytes = resources_lookup_data (configuration.svg_path, ResourceLookupFlags.NONE);
- var data = bytes.get_data ();
+ try {
+ var bytes = resources_lookup_data (value.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);
+ }
+ catch (Error e) {
+ critical ("Could not set up gamepad view: %s", e.message);
+ }
+
+ set_size_request (handle.width, handle.height);
+ _configuration = value;
+ input_highlights = new bool[value.input_paths.length];
- set_size_request (handle.width, handle.height);
- this.configuration = configuration;
- input_highlights = new bool[configuration.input_paths.length];
+ reset ();
+ }
+ }
- reset ();
+ construct {
+ handle = new Rsvg.Handle ();
+ configuration = { "", new GamepadInputPath[0] };
+ input_highlights = {};
}
public void reset () {
diff --git a/src/ui/keyboard-mapper.vala b/src/ui/keyboard-mapper.vala
index 519523fc..8606ef85 100644
--- a/src/ui/keyboard-mapper.vala
+++ b/src/ui/keyboard-mapper.vala
@@ -19,7 +19,7 @@ private class Games.KeyboardMapper : Gtk.Bin {
get { return _configuration; }
construct {
_configuration = value;
- gamepad_view.set_configuration (value);
+ gamepad_view.configuration = value;
}
}
diff --git a/src/ui/keyboard-tester.vala b/src/ui/keyboard-tester.vala
index bf3ec29b..43a8dc0c 100644
--- a/src/ui/keyboard-tester.vala
+++ b/src/ui/keyboard-tester.vala
@@ -12,7 +12,7 @@ private class Games.KeyboardTester : Gtk.Bin {
get { return _configuration; }
construct {
_configuration = value;
- gamepad_view.set_configuration (value);
+ gamepad_view.configuration = value;
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]