[gnome-games/wip/abhinavsingh/keyboard-config: 6/6] ui: Show keyboard in PreferencePageControllers



commit f4628159878e199ee72d9f79e79ff40103f79c5f
Author: theawless <theawless gmail com>
Date:   Mon Aug 28 04:41:02 2017 +0530

    ui: Show keyboard in PreferencePageControllers
    
    This will allow the user to edit the settings related to keyboard.

 data/ui/preferences-page-controllers.ui  |   73 +++++++++++++++++++++++------
 src/ui/preferences-page-controllers.vala |   23 +++++++++
 2 files changed, 81 insertions(+), 15 deletions(-)
---
diff --git a/data/ui/preferences-page-controllers.ui b/data/ui/preferences-page-controllers.ui
index 09bd294..14f3a14 100644
--- a/data/ui/preferences-page-controllers.ui
+++ b/data/ui/preferences-page-controllers.ui
@@ -23,35 +23,78 @@
             <property name="can_focus">False</property>
             <property name="visible">True</property>
             <child>
-              <object class="GtkFrame">
+              <object class="GtkBox">
                 <property name="visible">True</property>
                 <property name="can_focus">False</property>
-                <property name="border_width">12</property>
-                <property name="valign">start</property>
-                <property name="shadow_type">none</property>
+                <property name="orientation">vertical</property>
                 <child>
-                  <object class="GtkAlignment">
+                  <object class="GtkFrame">
                     <property name="visible">True</property>
                     <property name="can_focus">False</property>
-                    <property name="top_padding">12</property>
+                    <property name="border_width">12</property>
+                    <property name="valign">start</property>
+                    <property name="hexpand">True</property>
+                    <property name="shadow_type">none</property>
                     <child>
-                      <object class="GtkListBox" id="gamepads_list_box">
+                      <object class="GtkAlignment">
                         <property name="visible">True</property>
                         <property name="can_focus">False</property>
-                        <property name="selection_mode">none</property>
-                        <signal name="row-activated" handler="gamepads_list_box_row_activated"/>
+                        <property name="top_padding">12</property>
+                        <child>
+                          <object class="GtkListBox" id="gamepads_list_box">
+                            <property name="visible">True</property>
+                            <property name="can_focus">False</property>
+                            <property name="selection_mode">none</property>
+                            <signal name="row-activated" handler="gamepads_list_box_row_activated"/>
+                          </object>
+                        </child>
+                      </object>
+                    </child>
+                    <child type="label">
+                      <object class="GtkLabel">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="label" translatable="yes">Gamepads</property>
+                        <attributes>
+                          <attribute name="weight" value="bold"/>
+                        </attributes>
                       </object>
                     </child>
                   </object>
                 </child>
-                <child type="label">
-                  <object class="GtkLabel">
+                <child>
+                  <object class="GtkFrame">
                     <property name="visible">True</property>
                     <property name="can_focus">False</property>
-                    <property name="label" translatable="yes">Gamepads</property>
-                    <attributes>
-                      <attribute name="weight" value="bold"/>
-                    </attributes>
+                    <property name="border_width">12</property>
+                    <property name="valign">start</property>
+                    <property name="hexpand">True</property>
+                    <property name="shadow_type">none</property>
+                    <child>
+                      <object class="GtkAlignment">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="top_padding">12</property>
+                        <child>
+                          <object class="GtkListBox" id="keyboard_list_box">
+                            <property name="visible">True</property>
+                            <property name="can_focus">False</property>
+                            <property name="selection_mode">none</property>
+                            <signal name="row-activated" handler="keyboard_list_box_row_activated"/>
+                          </object>
+                        </child>
+                      </object>
+                    </child>
+                    <child type="label">
+                      <object class="GtkLabel">
+                        <property name="visible">True</property>
+                        <property name="can_focus">False</property>
+                        <property name="label" translatable="yes">Keyboard</property>
+                        <attributes>
+                          <attribute name="weight" value="bold"/>
+                        </attributes>
+                      </object>
+                    </child>
                   </object>
                 </child>
               </object>
diff --git a/src/ui/preferences-page-controllers.vala b/src/ui/preferences-page-controllers.vala
index 4f619a9..4afb4d0 100644
--- a/src/ui/preferences-page-controllers.vala
+++ b/src/ui/preferences-page-controllers.vala
@@ -8,6 +8,8 @@ private class Games.PreferencesPageControllers: Gtk.Stack, PreferencesPage {
        [GtkChild]
        private Gtk.ListBox gamepads_list_box;
        [GtkChild]
+       private Gtk.ListBox keyboard_list_box;
+       [GtkChild]
        private Gtk.Box extra_stack_child_holder;
        [GtkChild]
        private Gtk.HeaderBar default_header_bar;
@@ -26,6 +28,7 @@ private class Games.PreferencesPageControllers: Gtk.Stack, PreferencesPage {
                gamepad_monitor.gamepad_unplugged.connect (rebuild_gamepad_list);
                gamepad_monitor.gamepad_plugged.connect (rebuild_gamepad_list);
                build_gamepad_list ();
+               build_keyboard_list ();
        }
 
        public void visible_page_changed () {
@@ -75,6 +78,26 @@ private class Games.PreferencesPageControllers: Gtk.Stack, PreferencesPage {
                set_visible_child_name ("extra_stack_child");
        }
 
+       private void build_keyboard_list () {
+               var box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 0);
+               box.pack_start (new Gtk.Label ("Keyboard"), false, false);
+               box.margin = 6;
+               box.show_all ();
+               keyboard_list_box.add (box);
+       }
+
+       [GtkCallback]
+       private void keyboard_list_box_row_activated (Gtk.ListBoxRow row_item) {
+               var configurer = new KeyboardConfigurer();
+               back_handler_id = configurer.back.connect (on_back);
+               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");
+       }
+
        private void on_back (Object? emitter) {
                header_bar_binding = null;
                immersive_mode_binding = null;


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