[gnome-games/wip/abhinavsingh/gamepad-config] Temp patch



commit 0f11fd7b6d95482dde928eb691a79019576e0967
Author: theawless <theawless gmail com>
Date:   Thu Jul 20 04:14:22 2017 +0530

    Temp patch

 data/Makefile.am                          |    2 +
 data/org.gnome.Games.gresource.xml        |    2 +
 data/ui/gamepad-configurer.ui             |  107 +++++++++++++++++
 data/ui/gamepad-mapper.ui                 |   65 -----------
 data/ui/gamepad-tester.ui                 |   19 +++
 data/ui/preferences-page-inputs.ui        |    4 +
 data/ui/preferences-page-plugins.ui       |    4 +
 data/ui/preferences-page-video.ui         |    4 +
 data/ui/preferences-window.ui             |   14 +--
 src/Makefile.am                           |    4 +-
 src/ui/gamepad-configurer.vala            |  177 ++++++++++++++++++++++++++++
 src/ui/gamepad-mapper.vala                |  180 ++++-------------------------
 src/ui/gamepad-mapping-configuration.vala |   16 +++
 src/ui/gamepad-tester.vala                |   69 +++++++++++
 src/ui/gamepad-view-configuration.c       |  168 +++++++++++++++++++++++++++
 src/ui/gamepad-view-configuration.vala    |   11 --
 src/ui/gamepad-view.vala                  |   37 ++++---
 src/ui/preferences-page-inputs.vala       |   34 ++----
 src/ui/preferences-page-plugins.vala      |   16 +--
 src/ui/preferences-page-video.vala        |   16 +--
 src/ui/preferences-page.vala              |    4 +-
 src/ui/preferences-window.vala            |   46 ++------
 22 files changed, 652 insertions(+), 347 deletions(-)
---
diff --git a/data/Makefile.am b/data/Makefile.am
index dd8eb44..5c9bdc1 100644
--- a/data/Makefile.am
+++ b/data/Makefile.am
@@ -37,7 +37,9 @@ EXTRA_DIST = \
        ui/empty-collection.ui \
        ui/error-display.ui \
        ui/error-info-bar.ui \
+       ui/gamepad-configurer.ui \
        ui/gamepad-mapper.ui \
+       ui/gamepad-tester.ui \
        ui/game-icon-view.ui \
        ui/media-menu-button.ui \
        ui/media-selector.ui \
diff --git a/data/org.gnome.Games.gresource.xml b/data/org.gnome.Games.gresource.xml
index 9e628d9..4053a61 100644
--- a/data/org.gnome.Games.gresource.xml
+++ b/data/org.gnome.Games.gresource.xml
@@ -16,7 +16,9 @@
     <file preprocess="xml-stripblanks">ui/empty-collection.ui</file>
     <file preprocess="xml-stripblanks">ui/error-display.ui</file>
     <file preprocess="xml-stripblanks">ui/error-info-bar.ui</file>
+    <file preprocess="xml-stripblanks">ui/gamepad-configurer.ui</file>
     <file preprocess="xml-stripblanks">ui/gamepad-mapper.ui</file>
+    <file preprocess="xml-stripblanks">ui/gamepad-tester.ui</file>
     <file preprocess="xml-stripblanks">ui/game-icon-view.ui</file>
     <file preprocess="xml-stripblanks">ui/media-menu-button.ui</file>
     <file preprocess="xml-stripblanks">ui/media-selector.ui</file>
diff --git a/data/ui/gamepad-configurer.ui b/data/ui/gamepad-configurer.ui
new file mode 100644
index 0000000..a2f11c6
--- /dev/null
+++ b/data/ui/gamepad-configurer.ui
@@ -0,0 +1,107 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+  <template class="GamesGamepadConfigurer" parent="GtkBox">
+    <property name="visible">True</property>
+    <property name="can_focus">False</property>
+    <property name="orientation">vertical</property>
+    <property name="spacing">6</property>
+    <child>
+      <object class="GtkStack" id="stack">
+        <property name="visible">True</property>
+        <property name="halign">fill</property>
+        <property name="valign">fill</property>
+        <property name="hexpand">True</property>
+        <property name="vexpand">True</property>
+        <child>
+          <object class="GtkBox" id="gamepad_mapper_holder">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+          </object>
+          <packing>
+            <property name="name">gamepad_mapper</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkBox" id="gamepad_tester_holder">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+          </object>
+          <packing>
+            <property name="name">gamepad_tester</property>
+          </packing>
+        </child>
+      </object>
+    </child>
+    <child>
+      <object class="GtkActionBar" id="action_bar">
+        <property name="visible">True</property>
+        <child>
+          <object class="GtkButton" id="reset_button">
+            <property name="visible">True</property>
+            <property name="label" translatable="yes">Reset</property>
+            <signal name="clicked" handler="on_reset_clicked"/>
+            <style>
+              <class name="destructive-action"/>
+            </style>
+          </object>
+          <packing>
+            <property name="pack-type">end</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkButton" id="configure_button">
+            <property name="visible">True</property>
+            <property name="label" translatable="yes">Configure</property>
+            <signal name="clicked" handler="on_configure_clicked"/>
+            <style>
+              <class name="suggested-action"/>
+            </style>
+          </object>
+          <packing>
+            <property name="pack-type">start</property>
+          </packing>
+        </child>
+      </object>
+    </child>
+  </template>
+  <object class="GtkHeaderBar" id="header_bar">
+    <property name="visible">True</property>
+    <child>
+      <object class="GtkButton" id="back_button">
+        <property name="visible">True</property>
+        <signal name="clicked" handler="on_back_clicked"/>
+        <style>
+          <class name="image-button"/>
+        </style>
+        <child internal-child="accessible">
+          <object class="AtkObject" id="a11y-back">
+            <property name="accessible-name" translatable="yes">Back</property>
+          </object>
+        </child>
+        <child>
+          <object class="GtkImage" id="back_image">
+            <property name="visible">True</property>
+            <property name="icon-name">go-previous-symbolic</property>
+            <property name="icon-size">1</property>
+          </object>
+        </child>
+      </object>
+      <packing>
+        <property name="pack-type">start</property>
+      </packing>
+    </child>
+    <child>
+      <object class="GtkButton" id="cancel_button">
+        <property name="visible">True</property>
+        <property name="label" translatable="yes">Cancel</property>
+        <signal name="clicked" handler="on_cancel_clicked"/>
+        <style>
+          <class name="destructive-action"/>
+        </style>
+      </object>
+      <packing>
+        <property name="pack-type">end</property>
+      </packing>
+    </child>
+  </object>
+</interface>
diff --git a/data/ui/gamepad-mapper.ui b/data/ui/gamepad-mapper.ui
index 7b04b28..1ab3dae 100644
--- a/data/ui/gamepad-mapper.ui
+++ b/data/ui/gamepad-mapper.ui
@@ -18,33 +18,6 @@
       <object class="GtkActionBar" id="action_bar">
         <property name="visible">True</property>
         <child>
-          <object class="GtkButton" id="apply_button">
-            <property name="visible">True</property>
-            <property name="can-default">True</property>
-            <property name="label" translatable="yes">Apply</property>
-            <signal name="clicked" handler="on_apply_clicked"/>
-            <style>
-              <class name="suggested-action"/>
-            </style>
-          </object>
-          <packing>
-            <property name="pack-type">start</property>
-          </packing>
-        </child>
-        <child>
-          <object class="GtkButton" id="reset_button">
-            <property name="visible">True</property>
-            <property name="label" translatable="yes">Reset</property>
-            <signal name="clicked" handler="on_reset_clicked"/>
-            <style>
-              <class name="destructive-action"/>
-            </style>
-          </object>
-          <packing>
-            <property name="pack-type">end</property>
-          </packing>
-        </child>
-        <child>
           <object class="GtkButton" id="skip_button">
             <property name="visible">True</property>
             <property name="label" translatable="yes">Skip</property>
@@ -62,42 +35,4 @@
       </object>
     </child>
   </template>
-  <object class="GtkBox" id="header_content">
-    <property name="orientation">horizontal</property>
-    <property name="visible">True</property>
-    <property name="spacing">2</property>
-    <property name="hexpand">True</property>
-    <child>
-      <object class="GtkButton" id="back_button">
-        <property name="visible">True</property>
-        <signal name="clicked" handler="on_back_clicked"/>
-        <style>
-          <class name="image-button"/>
-        </style>
-        <child internal-child="accessible">
-          <object class="AtkObject" id="a11y-back">
-            <property name="accessible-name" translatable="yes">Back</property>
-          </object>
-        </child>
-        <child>
-          <object class="GtkImage" id="back_image">
-            <property name="visible">True</property>
-            <property name="icon-name">go-previous-symbolic</property>
-            <property name="icon-size">1</property>
-          </object>
-        </child>
-      </object>
-      <packing>
-        <property name="pack-type">start</property>
-      </packing>
-    </child>
-    <child type="center">
-      <object class="GtkLabel" id="title">
-        <property name="visible">True</property>
-        <style>
-          <class name="title"/>
-        </style>
-      </object>
-    </child>
-  </object>
 </interface>
diff --git a/data/ui/gamepad-tester.ui b/data/ui/gamepad-tester.ui
new file mode 100644
index 0000000..7ec2239
--- /dev/null
+++ b/data/ui/gamepad-tester.ui
@@ -0,0 +1,19 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+  <template class="GamesGamepadTester" parent="GtkBox">
+    <property name="visible">True</property>
+    <property name="can_focus">False</property>
+    <property name="orientation">vertical</property>
+    <property name="spacing">6</property>
+    <child>
+      <object class="GtkBox" id="gamepad_view_holder">
+        <property name="visible">True</property>
+        <property name="can_focus">False</property>
+        <property name="halign">fill</property>
+        <property name="valign">fill</property>
+        <property name="hexpand">True</property>
+        <property name="vexpand">True</property>
+      </object>
+    </child>
+  </template>
+</interface>
diff --git a/data/ui/preferences-page-inputs.ui b/data/ui/preferences-page-inputs.ui
index 6df11f0..6cfc237 100644
--- a/data/ui/preferences-page-inputs.ui
+++ b/data/ui/preferences-page-inputs.ui
@@ -64,4 +64,8 @@
       </packing>
     </child>
   </template>
+  <object class="GtkHeaderBar" id="default_header_bar">
+    <property name="visible">True</property>
+    <property name="title" translatable="yes">Inputs</property>
+  </object>
 </interface>
diff --git a/data/ui/preferences-page-plugins.ui b/data/ui/preferences-page-plugins.ui
index 75a7615..4b47370 100644
--- a/data/ui/preferences-page-plugins.ui
+++ b/data/ui/preferences-page-plugins.ui
@@ -45,4 +45,8 @@
       </object>
     </child>
   </template>
+  <object class="GtkHeaderBar" id="header_bar">
+    <property name="visible">True</property>
+    <property name="title" translatable="yes">Extensions</property>
+  </object>
 </interface>
diff --git a/data/ui/preferences-page-video.ui b/data/ui/preferences-page-video.ui
index 50b473e..e900d7f 100644
--- a/data/ui/preferences-page-video.ui
+++ b/data/ui/preferences-page-video.ui
@@ -50,4 +50,8 @@
       </object>
     </child>
   </template>
+  <object class="GtkHeaderBar" id="header_bar">
+    <property name="visible">True</property>
+    <property name="title" translatable="yes">Video</property>
+  </object>
 </interface>
diff --git a/data/ui/preferences-window.ui b/data/ui/preferences-window.ui
index 2e54d0b..78b0a4c 100644
--- a/data/ui/preferences-window.ui
+++ b/data/ui/preferences-window.ui
@@ -29,21 +29,9 @@
           </object>
         </child>
         <child>
-          <object class="GtkHeaderBar" id="right_header_bar">
-            <property name="name">right_header_bar</property>
+          <object class="GtkBox" id="right_header_bar_holder">
             <property name="visible">True</property>
             <property name="expand">True</property>
-            <property name="show-close-button">True</property>
-            <property name="decoration_layout">:close</property>
-            <child>
-              <object class="GtkStack" id="controls_stack">
-                <property name="homogeneous">false</property>
-                <property name="visible">true</property>
-              </object>
-              <packing>
-                <property name="pack-type">start</property>
-              </packing>
-            </child>
           </object>
         </child>
       </object>
diff --git a/src/Makefile.am b/src/Makefile.am
index 158caad..3b2e667 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -133,11 +133,13 @@ gnome_games_SOURCES = \
        ui/empty-collection.vala \
        ui/error-display.vala \
        ui/error-info-bar.vala \
+       ui/gamepad-configurer.vala \
        ui/gamepad-mapper.vala \
+       ui/gamepad-tester.vala \
        ui/gamepad-view.vala \
        ui/game-icon-view.vala \
        ui/game-thumbnail.vala \
-       ui/gamepad-view-configuration.vala \
+       ui/gamepad-mapping-configuration.vala \
        ui/media-selector.vala \
        ui/media-menu-button.vala \
        ui/preferences-page.vala \
diff --git a/src/ui/gamepad-configurer.vala b/src/ui/gamepad-configurer.vala
new file mode 100644
index 0000000..d5a3282
--- /dev/null
+++ b/src/ui/gamepad-configurer.vala
@@ -0,0 +1,177 @@
+// This file is part of GNOME Games. License: GPL-3.0+.
+
+[GtkTemplate (ui = "/org/gnome/Games/ui/gamepad-configurer.ui")]
+private class Games.GamepadConfigurer : Gtk.Box {
+
+       private const GamepadInput[] STANDARD_GAMEPAD_INPUTS = {
+               { EventCode.EV_KEY, EventCode.BTN_A },
+               { EventCode.EV_KEY, EventCode.BTN_B },
+               { EventCode.EV_KEY, EventCode.BTN_X },
+               { EventCode.EV_KEY, EventCode.BTN_Y },
+               { EventCode.EV_KEY, EventCode.BTN_THUMBL },
+               { EventCode.EV_KEY, EventCode.BTN_THUMBR },
+               { EventCode.EV_KEY, EventCode.BTN_TL },
+               { EventCode.EV_KEY, EventCode.BTN_TR },
+               { EventCode.EV_KEY, EventCode.BTN_TL2 },
+               { EventCode.EV_KEY, EventCode.BTN_TR2 },
+               { EventCode.EV_KEY, EventCode.BTN_DPAD_UP },
+               { EventCode.EV_KEY, EventCode.BTN_DPAD_LEFT },
+               { EventCode.EV_KEY, EventCode.BTN_DPAD_DOWN },
+               { EventCode.EV_KEY, EventCode.BTN_DPAD_RIGHT },
+               { EventCode.EV_KEY, EventCode.BTN_SELECT },
+               { EventCode.EV_KEY, EventCode.BTN_MODE },
+               { EventCode.EV_KEY, EventCode.BTN_START },
+               { EventCode.EV_ABS, EventCode.ABS_X },
+               { EventCode.EV_ABS, EventCode.ABS_RX },
+               { EventCode.EV_ABS, EventCode.ABS_Y },
+               { EventCode.EV_ABS, EventCode.ABS_RY },
+       };
+
+       private const GamepadInputPath[] STANDARD_GAMEPAD_INPUT_PATHS = {
+               { { EventCode.EV_ABS, EventCode.ABS_X }, "leftx" },
+               { { EventCode.EV_ABS, EventCode.ABS_Y }, "lefty" },
+               { { EventCode.EV_ABS, EventCode.ABS_RX }, "rightx" },
+               { { EventCode.EV_ABS, EventCode.ABS_RY }, "righty" },
+               { { EventCode.EV_KEY, EventCode.BTN_A }, "a" },
+               { { EventCode.EV_KEY, EventCode.BTN_B }, "b" },
+               { { EventCode.EV_KEY, EventCode.BTN_DPAD_DOWN }, "dpdown" },
+               { { EventCode.EV_KEY, EventCode.BTN_DPAD_LEFT }, "dpleft" },
+               { { EventCode.EV_KEY, EventCode.BTN_DPAD_RIGHT }, "dpright" },
+               { { EventCode.EV_KEY, EventCode.BTN_DPAD_UP }, "dpup" },
+               { { EventCode.EV_KEY, EventCode.BTN_MODE }, "guide" },
+               { { EventCode.EV_KEY, EventCode.BTN_SELECT }, "back" },
+               { { EventCode.EV_KEY, EventCode.BTN_TL }, "leftshoulder" },
+               { { EventCode.EV_KEY, EventCode.BTN_TR }, "rightshoulder" },
+               { { EventCode.EV_KEY, EventCode.BTN_START }, "start" },
+               { { EventCode.EV_KEY, EventCode.BTN_THUMBL }, "leftstick" },
+               { { EventCode.EV_KEY, EventCode.BTN_THUMBR }, "rightstick" },
+               { { EventCode.EV_KEY, EventCode.BTN_TL2 }, "lefttrigger" },
+               { { EventCode.EV_KEY, EventCode.BTN_TR2 }, "righttrigger" },
+               { { EventCode.EV_KEY, EventCode.BTN_Y }, "x" },
+               { { EventCode.EV_KEY, EventCode.BTN_X }, "y" },
+       };
+
+       private const GamepadViewConfiguration STANDARD_GAMEPAD_VIEW_CONFIGURATION = {
+               "resource:///org/gnome/Games/gamepads/standard-gamepad.svg", STANDARD_GAMEPAD_INPUT_PATHS
+       };
+
+       public signal void back ();
+
+       private enum State {
+               TEST,
+               CONFIGURE,
+       }
+
+       private State? _state;
+       private State? state {
+               set {
+                       _state = value;
+
+                       switch (value) {
+                       case State.TEST:
+                               stack.set_visible_child_name ("gamepad_tester");
+                               header_bar.title = _("Testing ") + gamepad.name;
+                               action_bar.show ();
+                               back_button.show ();
+                               cancel_button.hide ();
+                               header_bar.get_style_context ().remove_class ("selection-mode");
+
+                               tester.start ();
+                               mapper.stop ();
+                               mapper.finished.disconnect (save_sdl_string);
+
+                               break;
+                       case State.CONFIGURE:
+                               stack.set_visible_child_name ("gamepad_mapper");
+                               header_bar.title = _("Configuring ") + gamepad.name;
+                               action_bar.hide ();
+                               back_button.hide ();
+                               cancel_button.show ();
+                               header_bar.get_style_context ().add_class ("selection-mode");
+
+                               tester.stop ();
+                               mapper.start ();
+                               mapper.finished.connect (save_sdl_string);
+
+                               break;
+                       }
+               }
+               get { return _state; }
+       }
+
+       [GtkChild]
+       public Gtk.Stack stack;
+       [GtkChild]
+       public Gtk.Box gamepad_mapper_holder;
+       [GtkChild]
+       public Gtk.Box gamepad_tester_holder;
+       [GtkChild]
+       public Gtk.ActionBar action_bar;
+       [GtkChild]
+       private Gtk.Button reset_button;
+       [GtkChild]
+       private Gtk.Button configure_button;
+       [GtkChild]
+       public Gtk.HeaderBar header_bar;
+       [GtkChild]
+       private Gtk.Button back_button;
+       [GtkChild]
+       private Gtk.Button cancel_button;
+
+       private Gamepad gamepad;
+       private GamepadMapper mapper;
+       private GamepadTester tester;
+
+       public GamepadConfigurer (Gamepad gamepad) {
+               this.gamepad = gamepad;
+               mapper = new GamepadMapper (gamepad, STANDARD_GAMEPAD_VIEW_CONFIGURATION, 
STANDARD_GAMEPAD_INPUTS);
+               gamepad_mapper_holder.pack_start (mapper);
+               tester = new GamepadTester (gamepad, STANDARD_GAMEPAD_VIEW_CONFIGURATION);
+               gamepad_tester_holder.pack_start (tester);
+
+               state = State.TEST;
+       }
+
+       [GtkCallback]
+       private void on_reset_clicked () {
+               reset_mapping ();
+       }
+
+       [GtkCallback]
+       private void on_configure_clicked () {
+               state = State.CONFIGURE;
+       }
+
+       [GtkCallback]
+       private void on_back_clicked () {
+               back ();
+       }
+
+       [GtkCallback]
+       private void on_cancel_clicked () {
+               state = State.TEST;
+       }
+
+       private void on_mapper_finished (string sdl_string) {
+               state = State.TEST;
+               save_sdl_string (sdl_string);
+       }
+
+       private void reset_mapping () {
+               var mappings_manager = GamepadMappingsManager.get_instance ();
+               var sdl_string =  mappings_manager.get_default_mapping (gamepad.guid);
+               save_sdl_string (sdl_string);
+       }
+
+       private void save_sdl_string (string sdl_string) {
+               var mappings_manager = GamepadMappingsManager.get_instance ();
+               try {
+                       var mapping = new GamepadMapping.from_sdl_string (sdl_string);
+                       gamepad.set_mapping (mapping);
+                       mappings_manager.save_mapping (gamepad.guid, gamepad.name, sdl_string);
+               }
+               catch (Error e) {
+                       warning (e.message);
+               }
+       }
+}
diff --git a/src/ui/gamepad-mapper.vala b/src/ui/gamepad-mapper.vala
index 5983e81..5c6d07b 100644
--- a/src/ui/gamepad-mapper.vala
+++ b/src/ui/gamepad-mapper.vala
@@ -2,53 +2,12 @@
 
 [GtkTemplate (ui = "/org/gnome/Games/ui/gamepad-mapper.ui")]
 private class Games.GamepadMapper : Gtk.Box {
-       public signal void back ();
-
-       private enum State {
-               BEGIN,
-               CONFIGURE,
-               FINISH,
-       }
-
-       private State? _state;
-       private State? state {
-               set {
-                       switch (value) {
-                       case State.BEGIN:
-                               apply_button.set_sensitive (false);
-                               title.label = _("Configuring ") + gamepad.name;
-                               connect_to_gamepad ();
-
-                               break;
-                       case State.CONFIGURE:
-                               gamepad_view.reset ();
-                               gamepad_view.highlight (input, true);
-
-                               break;
-                       case State.FINISH:
-                               gamepad_view.reset ();
-                               skip_button.set_sensitive (false);
-                               apply_button.set_sensitive (true);
-                               title.label = _("Finished configuration");
-                               disconnect_from_gamepad ();
-
-                               break;
-                       }
-
-                       _state = value;
-               }
-               get { return _state; }
-       }
+       public signal void finished (string sdl_string);
 
        private GamepadInput? _input;
        private GamepadInput? input {
                set {
                        _input = value;
-                       if (_input == null) {
-                               info_message.label = "";
-
-                               return;
-                       }
 
                        switch (input.type) {
                        case EventCode.EV_KEY:
@@ -70,95 +29,37 @@ private class Games.GamepadMapper : Gtk.Box {
        }
 
        [GtkChild]
-       public Gtk.Box header_content;
-       [GtkChild]
-       private Gtk.Button apply_button;
-       [GtkChild]
-       private Gtk.Button skip_button;
-       [GtkChild]
        private Gtk.Box gamepad_view_holder;
        [GtkChild]
-       private Gtk.Label title;
-       [GtkChild]
        private Gtk.Label info_message;
 
-       private const GamepadInput[] STANDARD_GAMEPAD_INPUTS = {
-               { EventCode.EV_KEY, EventCode.BTN_A },
-               { EventCode.EV_KEY, EventCode.BTN_B },
-               { EventCode.EV_KEY, EventCode.BTN_X },
-               { EventCode.EV_KEY, EventCode.BTN_Y },
-               { EventCode.EV_KEY, EventCode.BTN_THUMBL },
-               { EventCode.EV_KEY, EventCode.BTN_THUMBR },
-               { EventCode.EV_KEY, EventCode.BTN_TL },
-               { EventCode.EV_KEY, EventCode.BTN_TR },
-               { EventCode.EV_KEY, EventCode.BTN_TL2 },
-               { EventCode.EV_KEY, EventCode.BTN_TR2 },
-               { EventCode.EV_KEY, EventCode.BTN_DPAD_UP },
-               { EventCode.EV_KEY, EventCode.BTN_DPAD_LEFT },
-               { EventCode.EV_KEY, EventCode.BTN_DPAD_DOWN },
-               { EventCode.EV_KEY, EventCode.BTN_DPAD_RIGHT },
-               { EventCode.EV_KEY, EventCode.BTN_SELECT },
-               { EventCode.EV_KEY, EventCode.BTN_MODE },
-               { EventCode.EV_KEY, EventCode.BTN_START },
-               { EventCode.EV_ABS, EventCode.ABS_X },
-               { EventCode.EV_ABS, EventCode.ABS_RX },
-               { EventCode.EV_ABS, EventCode.ABS_Y },
-               { EventCode.EV_ABS, EventCode.ABS_RY },
-       };
-
-       private const GamepadInputPath[] STANDARD_GAMEPAD_INPUT_PATHS = {
-               { { EventCode.EV_ABS, EventCode.ABS_X }, "leftx" },
-               { { EventCode.EV_ABS, EventCode.ABS_Y }, "lefty" },
-               { { EventCode.EV_ABS, EventCode.ABS_RX }, "rightx" },
-               { { EventCode.EV_ABS, EventCode.ABS_RY }, "righty" },
-               { { EventCode.EV_KEY, EventCode.BTN_A }, "a" },
-               { { EventCode.EV_KEY, EventCode.BTN_B }, "b" },
-               { { EventCode.EV_KEY, EventCode.BTN_DPAD_DOWN }, "dpdown" },
-               { { EventCode.EV_KEY, EventCode.BTN_DPAD_LEFT }, "dpleft" },
-               { { EventCode.EV_KEY, EventCode.BTN_DPAD_RIGHT }, "dpright" },
-               { { EventCode.EV_KEY, EventCode.BTN_DPAD_UP }, "dpup" },
-               { { EventCode.EV_KEY, EventCode.BTN_MODE }, "guide" },
-               { { EventCode.EV_KEY, EventCode.BTN_SELECT }, "back" },
-               { { EventCode.EV_KEY, EventCode.BTN_TL }, "leftshoulder" },
-               { { EventCode.EV_KEY, EventCode.BTN_TR }, "rightshoulder" },
-               { { EventCode.EV_KEY, EventCode.BTN_START }, "start" },
-               { { EventCode.EV_KEY, EventCode.BTN_THUMBL }, "leftstick" },
-               { { EventCode.EV_KEY, EventCode.BTN_THUMBR }, "rightstick" },
-               { { EventCode.EV_KEY, EventCode.BTN_TL2 }, "lefttrigger" },
-               { { EventCode.EV_KEY, EventCode.BTN_TR2 }, "righttrigger" },
-               { { EventCode.EV_KEY, EventCode.BTN_Y }, "x" },
-               { { EventCode.EV_KEY, EventCode.BTN_X }, "y" },
-       };
-
-       private const GamepadViewConfiguration STANDARD_GAMEPAD_VIEW_CONFIGURATION = {
-               "resource:///org/gnome/Games/gamepads/standard-gamepad.svg", STANDARD_GAMEPAD_INPUT_PATHS
-       };
-
        private Gamepad gamepad;
        private GamepadView gamepad_view;
        private GamepadMappingBuilder mapping_builder;
-       private ulong gamepad_event_handler_id;
+       private GamepadInput[] mapping_inputs;
        private uint current_input_index;
 
-       public GamepadMapper (Gamepad gamepad) {
+       private ulong gamepad_event_handler_id;
+
+       public GamepadMapper (Gamepad gamepad, GamepadViewConfiguration configuration, GamepadInput[] 
mapping_inputs) {
                this.gamepad = gamepad;
-               mapping_builder = new GamepadMappingBuilder ();
-               state = State.BEGIN;
-               current_input_index = 0;
+               this.mapping_inputs = mapping_inputs;
 
-               gamepad_view = new GamepadView (STANDARD_GAMEPAD_VIEW_CONFIGURATION);
+               gamepad_view = new GamepadView (configuration);
                gamepad_view_holder.pack_start (gamepad_view);
                gamepad_view.show ();
        }
 
        public void start () {
+               mapping_builder = new GamepadMappingBuilder ();
+               current_input_index = 0;
+               connect_to_gamepad ();
+
                next_input ();
        }
 
-       [GtkCallback]
-       private void on_apply_clicked () {
-               save_mapping ();
-               back ();
+       public void stop () {
+               disconnect_from_gamepad ();
        }
 
        [GtkCallback]
@@ -166,19 +67,8 @@ private class Games.GamepadMapper : Gtk.Box {
                next_input ();
        }
 
-       [GtkCallback]
-       private void on_reset_clicked () {
-               reset_mapping ();
-               back ();
-       }
-
-       [GtkCallback]
-       private void on_back_clicked () {
-               back ();
-       }
-
        private void connect_to_gamepad () {
-               gamepad_event_handler_id = this.gamepad.event.connect ((event) => {
+               gamepad_event_handler_id = gamepad.event.connect ((event) => {
                        switch (event.type) {
                        case EventType.EVENT_GAMEPAD_BUTTON_RELEASE:
                                on_button_event (event.gamepad_button);
@@ -199,7 +89,8 @@ private class Games.GamepadMapper : Gtk.Box {
        }
 
        private void disconnect_from_gamepad () {
-               gamepad.disconnect (gamepad_event_handler_id);
+               if (gamepad_event_handler_id > 0)
+                       gamepad.disconnect (gamepad_event_handler_id);
        }
 
        private void on_button_event (EventGamepadButton event) {
@@ -244,39 +135,16 @@ private class Games.GamepadMapper : Gtk.Box {
        }
 
        private void next_input () {
-               if (state == State.FINISH)
-                       return;
-               if (current_input_index >= STANDARD_GAMEPAD_INPUTS.length) {
-                       input = null;
-                       state = State.FINISH;
-
-                       return;
-               }
+               gamepad_view.reset ();
+               input = mapping_inputs[current_input_index++];
+               gamepad_view.highlight (input, true);
 
-               input = STANDARD_GAMEPAD_INPUTS[current_input_index++];
-               state = State.CONFIGURE;
-       }
+               if (current_input_index == mapping_inputs.length) {
+                       var sdl_string = mapping_builder.build_sdl_string ();
+                       finished (sdl_string);
+                       stop ();
 
-       private void save_mapping () {
-               var sdl_string = mapping_builder.build_sdl_string ();
-               save_sdl_string (sdl_string);
-       }
-
-       private void reset_mapping () {
-               var mappings_manager = GamepadMappingsManager.get_instance ();
-               var sdl_string =  mappings_manager.get_default_mapping (gamepad.guid);
-               save_sdl_string (sdl_string);
-       }
-
-       private void save_sdl_string (string sdl_string) {
-               var mappings_manager = GamepadMappingsManager.get_instance ();
-               try {
-                       var mapping = new GamepadMapping.from_sdl_string (sdl_string);
-                       gamepad.set_mapping (mapping);
-                       mappings_manager.save_mapping (gamepad.guid, gamepad.name, sdl_string);
-               }
-               catch (Error e) {
-                       warning (e.message);
+                       return;
                }
        }
 }
diff --git a/src/ui/gamepad-mapping-configuration.vala b/src/ui/gamepad-mapping-configuration.vala
new file mode 100644
index 0000000..f4f3e24
--- /dev/null
+++ b/src/ui/gamepad-mapping-configuration.vala
@@ -0,0 +1,16 @@
+// This file is part of GNOME Games. License: GPL-3.0+.
+
+private struct Games.GamepadInputPath {
+       GamepadInput input;
+       string path;
+}
+
+private struct Games.GamepadViewConfiguration {
+       string svg_path;
+       GamepadInputPath[] input_paths;
+}
+
+private struct Games.GamepadMappingConfiguration {
+       GamepadViewConfiguration view_configuration;
+       GamepadInput[] mapping_inputs;
+}
diff --git a/src/ui/gamepad-tester.vala b/src/ui/gamepad-tester.vala
new file mode 100644
index 0000000..8413bc7
--- /dev/null
+++ b/src/ui/gamepad-tester.vala
@@ -0,0 +1,69 @@
+// This file is part of GNOME Games. License: GPL-3.0+.
+
+[GtkTemplate (ui = "/org/gnome/Games/ui/gamepad-tester.ui")]
+private class Games.GamepadTester : Gtk.Box {
+       [GtkChild]
+       private Gtk.Box gamepad_view_holder;
+
+       private Gamepad gamepad;
+       private GamepadView gamepad_view;
+       private GamepadInput current_input; 
+
+       private ulong gamepad_button_event_handler_id;
+       private ulong gamepad_axis_event_handler_id;
+       private ulong gamepad_hat_event_handler_id;
+       private uint gamepad_view_unhighlight_id;
+
+       public GamepadTester (Gamepad gamepad, GamepadViewConfiguration configuration) {
+               this.gamepad = gamepad;
+
+               gamepad_view = new GamepadView (configuration);
+               gamepad_view_holder.pack_start (gamepad_view);
+               gamepad_view.show ();
+       }
+
+       public void start () {
+               connect_to_gamepad ();
+       }
+
+       public void stop () {
+               disconnect_from_gamepad ();
+       }
+
+       private void connect_to_gamepad () {
+               gamepad_button_event_handler_id = gamepad.button_press_event.connect ((event) => {
+                       highlight_input (EventCode.EV_KEY, event.gamepad_button.button);
+               });
+               gamepad_axis_event_handler_id = gamepad.axis_event.connect ((event) => {
+                       if (!(-0.8 < event.gamepad_axis.value && event.gamepad_axis.value < 0.8))
+                               highlight_input (EventCode.EV_ABS, event.gamepad_axis.axis);
+               });
+               gamepad_button_event_handler_id = gamepad.hat_event.connect ((event) => {
+                       if (event.gamepad_hat.value != 0)
+                               highlight_input (EventCode.EV_ABS, event.gamepad_hat.axis);
+               });
+       }
+
+       private void disconnect_from_gamepad () {
+               if (gamepad_button_event_handler_id > 0)
+                       gamepad.disconnect (gamepad_button_event_handler_id);
+               if (gamepad_axis_event_handler_id > 0)
+                       gamepad.disconnect (gamepad_axis_event_handler_id);
+               if (gamepad_hat_event_handler_id > 0)
+                       gamepad.disconnect (gamepad_hat_event_handler_id);
+       }
+
+       private void highlight_input (uint16 type, uint16 code) {
+               if (gamepad_button_event_handler_id != 0)
+                       gamepad_view.highlight (current_input, false);
+
+               current_input = {type, code};
+               gamepad_view.highlight (current_input, true);
+               gamepad_view_unhighlight_id = Timeout.add (200, () => {
+                       gamepad_view.highlight (current_input, false);
+                       gamepad_axis_event_handler_id = 0;
+
+                       return false;
+               });
+       }
+}
diff --git a/src/ui/gamepad-view-configuration.c b/src/ui/gamepad-view-configuration.c
new file mode 100644
index 0000000..befd2ad
--- /dev/null
+++ b/src/ui/gamepad-view-configuration.c
@@ -0,0 +1,168 @@
+/* gamepad-view-configuration.c generated by valac 0.37.1.6-1eaec, the Vala compiler
+ * generated from gamepad-view-configuration.vala, do not modify */
+
+/* This file is part of GNOME Games. License: GPL-3.0+.*/
+
+#include <glib.h>
+#include <glib-object.h>
+#include <gamepad-input.h>
+#include <stdlib.h>
+#include <string.h>
+
+
+#define GAMES_TYPE_GAMEPAD_INPUT_PATH (games_gamepad_input_path_get_type ())
+typedef struct _GamesGamepadInputPath GamesGamepadInputPath;
+#define _g_free0(var) (var = (g_free (var), NULL))
+
+#define GAMES_TYPE_GAMEPAD_VIEW_CONFIGURATION (games_gamepad_view_configuration_get_type ())
+typedef struct _GamesGamepadViewConfiguration GamesGamepadViewConfiguration;
+
+struct _GamesGamepadInputPath {
+       GamesGamepadInput input;
+       gchar* path;
+};
+
+struct _GamesGamepadViewConfiguration {
+       gchar* svg_path;
+       GamesGamepadInputPath* input_paths;
+       gint input_paths_length1;
+       gint _input_paths_size_;
+};
+
+
+
+GType games_gamepad_input_path_get_type (void) G_GNUC_CONST;
+GamesGamepadInputPath* games_gamepad_input_path_dup (const GamesGamepadInputPath* self);
+void games_gamepad_input_path_free (GamesGamepadInputPath* self);
+void games_gamepad_input_path_copy (const GamesGamepadInputPath* self, GamesGamepadInputPath* dest);
+void games_gamepad_input_path_destroy (GamesGamepadInputPath* self);
+GType games_gamepad_view_configuration_get_type (void) G_GNUC_CONST;
+GamesGamepadViewConfiguration* games_gamepad_view_configuration_dup (const GamesGamepadViewConfiguration* 
self);
+void games_gamepad_view_configuration_free (GamesGamepadViewConfiguration* self);
+void games_gamepad_view_configuration_copy (const GamesGamepadViewConfiguration* self, 
GamesGamepadViewConfiguration* dest);
+void games_gamepad_view_configuration_destroy (GamesGamepadViewConfiguration* self);
+static void _vala_GamesGamepadInputPath_array_free (GamesGamepadInputPath * array, gint array_length);
+static GamesGamepadInputPath* _vala_array_dup9 (GamesGamepadInputPath* self, int length);
+
+
+void games_gamepad_input_path_copy (const GamesGamepadInputPath* self, GamesGamepadInputPath* dest) {
+       GamesGamepadInput _tmp0_;
+       const gchar* _tmp1_;
+       gchar* _tmp2_;
+       _tmp0_ = (*self).input;
+       (*dest).input = _tmp0_;
+       _tmp1_ = (*self).path;
+       _tmp2_ = g_strdup (_tmp1_);
+       _g_free0 ((*dest).path);
+       (*dest).path = _tmp2_;
+}
+
+
+void games_gamepad_input_path_destroy (GamesGamepadInputPath* self) {
+       _g_free0 ((*self).path);
+}
+
+
+GamesGamepadInputPath* games_gamepad_input_path_dup (const GamesGamepadInputPath* self) {
+       GamesGamepadInputPath* dup;
+       dup = g_new0 (GamesGamepadInputPath, 1);
+       games_gamepad_input_path_copy (self, dup);
+       return dup;
+}
+
+
+void games_gamepad_input_path_free (GamesGamepadInputPath* self) {
+       games_gamepad_input_path_destroy (self);
+       g_free (self);
+}
+
+
+GType games_gamepad_input_path_get_type (void) {
+       static volatile gsize games_gamepad_input_path_type_id__volatile = 0;
+       if (g_once_init_enter (&games_gamepad_input_path_type_id__volatile)) {
+               GType games_gamepad_input_path_type_id;
+               games_gamepad_input_path_type_id = g_boxed_type_register_static ("GamesGamepadInputPath", 
(GBoxedCopyFunc) games_gamepad_input_path_dup, (GBoxedFreeFunc) games_gamepad_input_path_free);
+               g_once_init_leave (&games_gamepad_input_path_type_id__volatile, 
games_gamepad_input_path_type_id);
+       }
+       return games_gamepad_input_path_type_id__volatile;
+}
+
+
+static void _vala_GamesGamepadInputPath_array_free (GamesGamepadInputPath * array, gint array_length) {
+       if (array != NULL) {
+               int i;
+               for (i = 0; i < array_length; i = i + 1) {
+                       games_gamepad_input_path_destroy (&array[i]);
+               }
+       }
+       g_free (array);
+}
+
+
+static GamesGamepadInputPath* _vala_array_dup9 (GamesGamepadInputPath* self, int length) {
+       GamesGamepadInputPath* result;
+       int i;
+       result = g_new0 (GamesGamepadInputPath, length);
+       for (i = 0; i < length; i++) {
+               GamesGamepadInputPath _tmp0_ = {0};
+               games_gamepad_input_path_copy (&self[i], &_tmp0_);
+               result[i] = _tmp0_;
+       }
+       return result;
+}
+
+
+void games_gamepad_view_configuration_copy (const GamesGamepadViewConfiguration* self, 
GamesGamepadViewConfiguration* dest) {
+       const gchar* _tmp0_;
+       gchar* _tmp1_;
+       GamesGamepadInputPath* _tmp2_;
+       gint _tmp2__length1;
+       GamesGamepadInputPath* _tmp3_;
+       gint _tmp3__length1;
+       _tmp0_ = (*self).svg_path;
+       _tmp1_ = g_strdup (_tmp0_);
+       _g_free0 ((*dest).svg_path);
+       (*dest).svg_path = _tmp1_;
+       _tmp2_ = (*self).input_paths;
+       _tmp2__length1 = (*self).input_paths_length1;
+       _tmp3_ = (_tmp2_ != NULL) ? _vala_array_dup9 (_tmp2_, _tmp2__length1) : ((gpointer) _tmp2_);
+       _tmp3__length1 = _tmp2__length1;
+       (*dest).input_paths = (_vala_GamesGamepadInputPath_array_free ((*dest).input_paths, 
(*dest).input_paths_length1), NULL);
+       (*dest).input_paths = _tmp3_;
+       (*dest).input_paths_length1 = _tmp3__length1;
+       (*dest)._input_paths_size_ = (*dest).input_paths_length1;
+}
+
+
+void games_gamepad_view_configuration_destroy (GamesGamepadViewConfiguration* self) {
+       _g_free0 ((*self).svg_path);
+       (*self).input_paths = (_vala_GamesGamepadInputPath_array_free ((*self).input_paths, 
(*self).input_paths_length1), NULL);
+}
+
+
+GamesGamepadViewConfiguration* games_gamepad_view_configuration_dup (const GamesGamepadViewConfiguration* 
self) {
+       GamesGamepadViewConfiguration* dup;
+       dup = g_new0 (GamesGamepadViewConfiguration, 1);
+       games_gamepad_view_configuration_copy (self, dup);
+       return dup;
+}
+
+
+void games_gamepad_view_configuration_free (GamesGamepadViewConfiguration* self) {
+       games_gamepad_view_configuration_destroy (self);
+       g_free (self);
+}
+
+
+GType games_gamepad_view_configuration_get_type (void) {
+       static volatile gsize games_gamepad_view_configuration_type_id__volatile = 0;
+       if (g_once_init_enter (&games_gamepad_view_configuration_type_id__volatile)) {
+               GType games_gamepad_view_configuration_type_id;
+               games_gamepad_view_configuration_type_id = g_boxed_type_register_static 
("GamesGamepadViewConfiguration", (GBoxedCopyFunc) games_gamepad_view_configuration_dup, (GBoxedFreeFunc) 
games_gamepad_view_configuration_free);
+               g_once_init_leave (&games_gamepad_view_configuration_type_id__volatile, 
games_gamepad_view_configuration_type_id);
+       }
+       return games_gamepad_view_configuration_type_id__volatile;
+}
+
+
+
diff --git a/src/ui/gamepad-view.vala b/src/ui/gamepad-view.vala
index 1399186..fb71505 100644
--- a/src/ui/gamepad-view.vala
+++ b/src/ui/gamepad-view.vala
@@ -27,29 +27,33 @@ private class Games.GamepadView : Gtk.DrawingArea {
                queue_draw ();
        }
 
-       public void highlight (GamepadInput input, bool highlight) {
-               for (var i = 0; i < configuration.input_paths.length; ++i)
-                       if (configuration.input_paths[i].input == input)
+       public bool highlight (GamepadInput input, bool highlight) {
+               for (var i = 0; i < configuration.input_paths.length; ++i) {
+                       if (configuration.input_paths[i].input == input) {
                                input_highlights[i] = highlight;
+                               queue_draw ();
 
-               queue_draw ();
+                               return true;
+                       }
+               }
+
+               return false;
        }
 
        public override bool draw (Cairo.Context context) {
                double x, y, scale;
                calculate_image_dimensions (out x, out y, out scale);
 
-               color_gamepad (context, x, y, scale);
-               highlight_gamepad (context, x, y, scale);
+               var color_context = create_similar_context (context, x, y, scale);
+               color_gamepad (context, color_context);
+               var highlight_context = create_similar_context (context, x, y, scale);
+               highlight_gamepad (context, highlight_context);
 
                return false;
        }
 
-       private void color_gamepad (Cairo.Context gamepad_context, double x, double y, double scale) {
-               var color_context = create_similar_context (gamepad_context);
+       private void color_gamepad (Cairo.Context gamepad_context, Cairo.Context color_context) {
                var color_suface = color_context.get_target ();
-               color_context.translate (x, y);
-               color_context.scale (scale, scale);
 
                handle.render_cairo (color_context);
 
@@ -58,11 +62,8 @@ private class Games.GamepadView : Gtk.DrawingArea {
                gamepad_context.mask_surface (color_suface, 0, 0);
        }
 
-       private void highlight_gamepad (Cairo.Context gamepad_context, double x, double y, double scale) {
-               var highlight_context = create_similar_context (gamepad_context);
+       private void highlight_gamepad (Cairo.Context gamepad_context, Cairo.Context highlight_context) {
                var highlight_suface = highlight_context.get_target ();
-               highlight_context.translate (x, y);
-               highlight_context.scale (scale, scale);
                
                for (var i = 0; i < configuration.input_paths.length; ++i)
                        if (input_highlights[i])
@@ -73,12 +74,16 @@ private class Games.GamepadView : Gtk.DrawingArea {
                gamepad_context.mask_surface (highlight_suface, 0, 0);
        }
 
-       private Cairo.Context create_similar_context (Cairo.Context context) {
+       private Cairo.Context create_similar_context (Cairo.Context context, double x, double y, double 
scale) {
                var w = get_allocated_width ();
                var h = get_allocated_height ();
                var surface = context.get_target ();
                var similar_suface = new Cairo.Surface.similar (surface, Cairo.Content.COLOR_ALPHA, w, h);
-               return new Cairo.Context (similar_suface);
+               var similar_context = new Cairo.Context (similar_suface);
+               similar_context.translate (x, y);
+               similar_context.scale (scale, scale);
+
+               return similar_context;
        }
 
        private void calculate_image_dimensions (out double x, out double y, out double scale) {
diff --git a/src/ui/preferences-page-inputs.vala b/src/ui/preferences-page-inputs.vala
index 59b925a..643b97a 100644
--- a/src/ui/preferences-page-inputs.vala
+++ b/src/ui/preferences-page-inputs.vala
@@ -2,32 +2,21 @@
 
 [GtkTemplate (ui = "/org/gnome/Games/ui/preferences-page-inputs.ui")]
 private class Games.PreferencesPageInputs: Gtk.Stack, PreferencesPage {
-       private Gtk.Widget? _custom_title;
-       public Gtk.Widget? custom_title {
-               get { return _custom_title; }
-               protected set { _custom_title = value; }
+       private Gtk.HeaderBar _header_bar;
+       public Gtk.HeaderBar header_bar {
+               get { return _header_bar; }
+               protected set { _header_bar = value; }
        }
-       
-       public string? subtitle {
-               get { return null; }
-               protected set {}
-       }
-
-       private string? _title;
-       public string? title {
-               get { return _title; }
-               protected set { _title = value; }
-       }
 
        [GtkChild]
        private Gtk.ListBox gamepads_list_box;
        [GtkChild]
        private Gtk.Box extra_stack_child_holder;
+       [GtkChild]
+       private Gtk.HeaderBar default_header_bar;
        private GamepadMonitor gamepad_monitor;
-       private Gtk.Label default_label;
 
        construct {
-               title = _("Inputs");
                gamepad_monitor = GamepadMonitor.get_instance ();
 
                gamepad_monitor.gamepad_unplugged.connect (rebuild_gamepad_list);
@@ -72,16 +61,15 @@ private class Games.PreferencesPageInputs: Gtk.Stack, PreferencesPage {
 
                if (gamepad == null)
                        return;
-               var mapper = new GamepadMapper(gamepad);
-               mapper.back.connect (on_mapper_back);
-               custom_title = mapper.header_content;
-               extra_stack_child_holder.pack_start (mapper);
+               var configurer = new GamepadConfigurer(gamepad);
+               configurer.back.connect (on_mapper_back);
+               header_bar = configurer.header_bar;
+               extra_stack_child_holder.pack_start (configurer);
                set_visible_child_name ("extra_stack_child");
-               mapper.start ();
        }
 
        private void on_mapper_back () {
-               custom_title = null;
+               header_bar = default_header_bar;
                set_visible_child_name ("main_stack_child");
                extra_stack_child_holder.foreach ((child) => child.destroy ());
        }
diff --git a/src/ui/preferences-page-plugins.vala b/src/ui/preferences-page-plugins.vala
index ab85970..0d27f6f 100644
--- a/src/ui/preferences-page-plugins.vala
+++ b/src/ui/preferences-page-plugins.vala
@@ -2,18 +2,10 @@
 
 [GtkTemplate (ui = "/org/gnome/Games/ui/preferences-page-plugins.ui")]
 private class Games.PreferencesPagePlugins: Gtk.Bin, PreferencesPage {
-       public Gtk.Widget? custom_title {
-               get { return null; }
-               protected set {}
-       }
-       
-       public string? subtitle {
-               get { return null; }
-               protected set {}
-       }
-       
-       public string? title {
-               get { return _("Extensions"); }
+       [GtkChild (name = "header_bar")]
+       private Gtk.HeaderBar _header_bar;
+       public Gtk.HeaderBar header_bar {
+               get { return _header_bar; }
                protected set {}
        }
 
diff --git a/src/ui/preferences-page-video.vala b/src/ui/preferences-page-video.vala
index 0829031..d9a628d 100644
--- a/src/ui/preferences-page-video.vala
+++ b/src/ui/preferences-page-video.vala
@@ -2,21 +2,13 @@
 
 [GtkTemplate (ui = "/org/gnome/Games/ui/preferences-page-video.ui")]
 private class Games.PreferencesPageVideo: Gtk.Bin, PreferencesPage {
-       public Gtk.Widget? custom_title {
-               get { return null; }
+       [GtkChild (name = "header_bar")]
+       private Gtk.HeaderBar _header_bar;
+       public Gtk.HeaderBar header_bar {
+               get { return _header_bar; }
                protected set {}
        }
        
-       public string? subtitle {
-               get { return null; }
-               protected set {}
-       }
-       
-       public string? title {
-               get { return _("Video"); }
-               protected set {}
-       }
-
        private string _filter_active;
        public string filter_active {
                set {
diff --git a/src/ui/preferences-page.vala b/src/ui/preferences-page.vala
index b3d8445..0690e27 100644
--- a/src/ui/preferences-page.vala
+++ b/src/ui/preferences-page.vala
@@ -1,8 +1,6 @@
 // This file is part of GNOME Games. License: GPL-3.0+.
 
 private interface Games.PreferencesPage: Gtk.Widget {
-       public abstract Gtk.Widget? custom_title { set; protected get; }
-       public abstract string? subtitle { set; protected get; }
-       public abstract string? title { set; protected get; }
+       public abstract Gtk.HeaderBar header_bar { get; protected set; }
        public virtual void visible_page_changed () {}
 }
diff --git a/src/ui/preferences-window.vala b/src/ui/preferences-window.vala
index 2ee0aa8..aff9d99 100644
--- a/src/ui/preferences-window.vala
+++ b/src/ui/preferences-window.vala
@@ -3,54 +3,30 @@
 [GtkTemplate (ui = "/org/gnome/Games/ui/preferences-window.ui")]
 private class Games.PreferencesWindow : Gtk.Window {
        [GtkChild]
-       private Gtk.HeaderBar right_header_bar;
+       private Gtk.Box right_header_bar_holder;
        [GtkChild]
        private Gtk.Stack stack;
 
-       Binding right_header_bar_custom_title_binding;
-       Binding right_header_bar_subtitle_binding;
-       Binding right_header_bar_title_binding;
-
        public PreferencesWindow () {
                stack.foreach ((child) => {
                        var page = (PreferencesPage) child;
                        stack.notify["visible-child-name"].connect (page.visible_page_changed);
+                       page.notify["header-bar"].connect (set_right_header);
                });
-               stack.notify["visible-child-name"].connect (update_right_header);
-               update_right_header ();
+               stack.notify["visible-child-name"].connect (set_right_header);
+               set_right_header ();
        }
 
-       private void update_right_header () {
-               reset_right_header_bindings ();
-
+       private void set_right_header () {
+               clear_right_header ();
                var page = (PreferencesPage) stack.get_visible_child ();
-               if (page == null) {
-                       right_header_bar.custom_title = null;
-                       right_header_bar.subtitle = null;
-                       right_header_bar.title = null;
-
+               if (page == null)
                        return;
-               }
-               right_header_bar_custom_title_binding = page.bind_property ("custom-title", right_header_bar, 
"custom-title",
-                                                                           BindingFlags.SYNC_CREATE);
-               right_header_bar_subtitle_binding = page.bind_property ("subtitle", right_header_bar, 
"subtitle",
-                                                                       BindingFlags.SYNC_CREATE);
-               right_header_bar_title_binding = page.bind_property ("title", right_header_bar, "title",
-                                                                    BindingFlags.SYNC_CREATE);
+
+               right_header_bar_holder.pack_start (page.header_bar);
        }
 
-       private void reset_right_header_bindings () {
-               if (right_header_bar_custom_title_binding != null) {
-                       right_header_bar_custom_title_binding.unbind ();
-                       right_header_bar_custom_title_binding = null;
-               }
-               if (right_header_bar_subtitle_binding != null) {
-                       right_header_bar_subtitle_binding.unbind ();
-                       right_header_bar_subtitle_binding = null;
-               }
-               if (right_header_bar_title_binding != null) {
-                       right_header_bar_title_binding.unbind ();
-                       right_header_bar_title_binding = null;
-               }
+       private void clear_right_header () {
+               right_header_bar_holder.foreach ((child) => right_header_bar_holder.remove (child));
        }
 }



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