[gnome-games/wip/exalm/libhandy4: 11/19] ui: Convert GamepadConfigurer into a subpage



commit 4d1bfc1a7395521360aa1a2f4bd43b0fdb3e8531
Author: Alexander Mikhaylenko <exalm7659 gmail com>
Date:   Wed Sep 12 01:42:57 2018 +0500

    ui: Convert GamepadConfigurer into a subpage

 data/org.gnome.Games.gresource.xml                       |  2 +-
 ...epad-configurer.ui => preferences-subpage-gamepad.ui} |  2 +-
 src/meson.build                                          |  2 +-
 src/ui/preferences-page-controllers.vala                 | 16 ++++++++--------
 ...-configurer.vala => preferences-subpage-gamepad.vala} | 12 ++++++------
 5 files changed, 17 insertions(+), 17 deletions(-)
---
diff --git a/data/org.gnome.Games.gresource.xml b/data/org.gnome.Games.gresource.xml
index dc309b63..200140eb 100644
--- a/data/org.gnome.Games.gresource.xml
+++ b/data/org.gnome.Games.gresource.xml
@@ -22,7 +22,6 @@
     <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>
@@ -36,6 +35,7 @@
     <file preprocess="xml-stripblanks">ui/preferences-page-plugins.ui</file>
     <file preprocess="xml-stripblanks">ui/preferences-page-plugins-item.ui</file>
     <file preprocess="xml-stripblanks">ui/preferences-page-video.ui</file>
+    <file preprocess="xml-stripblanks">ui/preferences-subpage-gamepad.ui</file>
     <file preprocess="xml-stripblanks">ui/preferences-window.ui</file>
     <file preprocess="xml-stripblanks">ui/quit-dialog.ui</file>
     <file preprocess="xml-stripblanks">ui/remote-display.ui</file>
diff --git a/data/ui/gamepad-configurer.ui b/data/ui/preferences-subpage-gamepad.ui
similarity index 98%
rename from data/ui/gamepad-configurer.ui
rename to data/ui/preferences-subpage-gamepad.ui
index c02a8af2..78f93415 100644
--- a/data/ui/gamepad-configurer.ui
+++ b/data/ui/preferences-subpage-gamepad.ui
@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <interface>
-  <template class="GamesGamepadConfigurer" parent="GtkBox">
+  <template class="GamesPreferencesSubpageGamepad" parent="GtkBox">
     <property name="visible">True</property>
     <property name="orientation">vertical</property>
     <child>
diff --git a/src/meson.build b/src/meson.build
index 72607b05..33450837 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -138,7 +138,6 @@ vala_sources = [
   'ui/error-display.vala',
   'ui/error-info-bar.vala',
   'ui/gamepad-browse.vala',
-  'ui/gamepad-configurer.vala',
   'ui/gamepad-mapper.vala',
   'ui/gamepad-tester.vala',
   'ui/gamepad-view.vala',
@@ -160,6 +159,7 @@ vala_sources = [
   'ui/preferences-page-plugins-item.vala',
   'ui/preferences-page-video.vala',
   'ui/preferences-subpage.vala',
+  'ui/preferences-subpage-gamepad.vala',
   'ui/preferences-window.vala',
   'ui/quit-dialog.vala',
   'ui/remote-display.vala',
diff --git a/src/ui/preferences-page-controllers.vala b/src/ui/preferences-page-controllers.vala
index 656635c0..c0d8e520 100644
--- a/src/ui/preferences-page-controllers.vala
+++ b/src/ui/preferences-page-controllers.vala
@@ -81,14 +81,9 @@ private class Games.PreferencesPageControllers: Gtk.Stack, PreferencesPage {
                if (device == null)
                        return;
 
-               var configurer = new GamepadConfigurer (device);
-               back_handler_id = configurer.back.connect (on_back_clicked);
-               header_bar_binding = configurer.bind_property ("header-bar", this, "header-bar",
-                                                              BindingFlags.SYNC_CREATE);
-               immersive_mode_binding = configurer.bind_property ("immersive-mode", this, "immersive-mode",
-                                                                  BindingFlags.SYNC_CREATE);
-               extra_stack_child_holder.pack_start (configurer);
-               set_visible_child_name ("extra_stack_child");
+               var subpage_gamepad = new PreferencesSubpageGamepad (device);
+               back_handler_id = subpage_gamepad.back.connect (on_back);
+               subpage = subpage_gamepad;
        }
 
        private void build_keyboard_list () {
@@ -111,6 +106,11 @@ private class Games.PreferencesPageControllers: Gtk.Stack, PreferencesPage {
                visible_child_name = "extra_stack_child";
        }
 
+       private void on_back () {
+               subpage.disconnect (back_handler_id);
+               subpage = null;
+       }
+
        private void on_back_clicked (Object? emitter) {
                header_bar_binding = null;
                immersive_mode_binding = null;
diff --git a/src/ui/gamepad-configurer.vala b/src/ui/preferences-subpage-gamepad.vala
similarity index 93%
rename from src/ui/gamepad-configurer.vala
rename to src/ui/preferences-subpage-gamepad.vala
index 0fff223d..492fdf27 100644
--- a/src/ui/gamepad-configurer.vala
+++ b/src/ui/preferences-subpage-gamepad.vala
@@ -1,7 +1,7 @@
 // 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 {
+[GtkTemplate (ui = "/org/gnome/Games/ui/preferences-subpage-gamepad.ui")]
+private class Games.PreferencesSubpageGamepad: Gtk.Box, PreferencesSubpage {
        private const GamepadInput[] STANDARD_GAMEPAD_INPUTS = {
                { EventCode.EV_KEY, EventCode.BTN_A },
                { EventCode.EV_KEY, EventCode.BTN_B },
@@ -65,9 +65,10 @@ private class Games.GamepadConfigurer : Gtk.Box {
        private State state {
                set {
                        _state = value;
-                       immersive_mode = (state == State.CONFIGURE);
                        back_button.visible = (state == State.TEST);
                        cancel_button.visible = (state == State.CONFIGURE);
+                       header_bar.show_close_button = (state == State.TEST);
+                       request_selection_mode = (state == State.CONFIGURE);
 
                        switch (value) {
                        case State.TEST:
@@ -102,11 +103,10 @@ private class Games.GamepadConfigurer : Gtk.Box {
        [GtkChild (name = "header_bar")]
        private Gtk.HeaderBar _header_bar;
        public Gtk.HeaderBar header_bar {
-               private set {}
                get { return _header_bar; }
        }
 
-       public bool immersive_mode { private set; get; }
+       public bool request_selection_mode { get; set; }
 
        [GtkChild]
        private Gtk.Stack gamepad_view_stack;
@@ -131,7 +131,7 @@ private class Games.GamepadConfigurer : Gtk.Box {
 
        private Binding info_message_binding;
 
-       public GamepadConfigurer (Manette.Device device) {
+       public PreferencesSubpageGamepad (Manette.Device device) {
                this.device = device;
                mapper = new GamepadMapper (device, STANDARD_GAMEPAD_VIEW_CONFIGURATION, 
STANDARD_GAMEPAD_INPUTS);
                gamepad_view_stack.add (mapper);


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