Commit 4a6f45c9 authored by Alexander Mikhaylenko's avatar Alexander Mikhaylenko

gamepad-view: Use a property for setting configuration

parent 60112687
......@@ -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;
}
}
......
......@@ -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;
}
}
......
......@@ -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 () {
......
......@@ -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;
}
}
......
......@@ -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;
}
}
......
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