[gnome-games/wip/abhinavsingh/gamepad-config: 4/14] ui: Add basic preference screen for gamepads



commit 4102b689733a1fca3bf6e8b0841457b8f640cac5
Author: theawless <theawless gmail com>
Date:   Tue May 23 20:13:26 2017 +0530

    ui: Add basic preference screen for gamepads
    
    Currently it only shows the gamepad names and their orders.

 data/Makefile.am                      |    1 +
 data/org.gnome.Games.gresource.xml    |    1 +
 data/ui/preferences-page-gamepads.ui  |   53 +++++++++++++++++++++++++++++++++
 data/ui/preferences-window.ui         |    9 +++++
 src/Makefile.am                       |    1 +
 src/ui/preferences-page-gamepads.vala |   30 ++++++++++++++++++
 6 files changed, 95 insertions(+), 0 deletions(-)
---
diff --git a/data/Makefile.am b/data/Makefile.am
index 87b56b8..30b594b 100644
--- a/data/Makefile.am
+++ b/data/Makefile.am
@@ -39,6 +39,7 @@ EXTRA_DIST = \
        ui/game-icon-view.ui \
        ui/media-menu-button.ui \
        ui/media-selector.ui \
+       ui/preferences-page-gamepads.ui \
        ui/preferences-page-plugins-item.ui \
        ui/preferences-page-plugins.ui \
        ui/preferences-page-video.ui \
diff --git a/data/org.gnome.Games.gresource.xml b/data/org.gnome.Games.gresource.xml
index e66ccca..a66adac 100644
--- a/data/org.gnome.Games.gresource.xml
+++ b/data/org.gnome.Games.gresource.xml
@@ -18,6 +18,7 @@
     <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>
+    <file preprocess="xml-stripblanks">ui/preferences-page-gamepads.ui</file>
     <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>
diff --git a/data/ui/preferences-page-gamepads.ui b/data/ui/preferences-page-gamepads.ui
new file mode 100644
index 0000000..d652219
--- /dev/null
+++ b/data/ui/preferences-page-gamepads.ui
@@ -0,0 +1,53 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+  <template class="GamesPreferencesPageGamepads" parent="GtkBin">
+    <property name="visible">True</property>
+    <property name="can_focus">False</property>
+    <child>
+      <object class="GtkScrolledWindow">
+        <property name="visible">True</property>
+        <property name="can_focus">True</property>
+        <child>
+          <object class="GtkViewport">
+            <property name="can_focus">False</property>
+            <property name="visible">True</property>
+            <child>
+              <object class="GtkFrame">
+                <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>
+                <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="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>
+          </object>
+        </child>
+      </object>
+    </child>
+  </template>
+</interface>
diff --git a/data/ui/preferences-window.ui b/data/ui/preferences-window.ui
index 36026a6..063a459 100644
--- a/data/ui/preferences-window.ui
+++ b/data/ui/preferences-window.ui
@@ -95,6 +95,15 @@
               </packing>
             </child>
             <child>
+              <object class="GamesPreferencesPageGamepads" id="gamepads_page">
+                <property name="visible">True</property>
+              </object>
+              <packing>
+                <property name="name">gamepads</property>
+                <property name="title" translatable="yes">Gamepads</property>
+              </packing>
+            </child>
+            <child>
               <object class="GamesPreferencesPagePlugins" id="plugins_page">
                 <property name="visible">True</property>
               </object>
diff --git a/src/Makefile.am b/src/Makefile.am
index dfbf6a3..bf507df 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -129,6 +129,7 @@ gnome_games_SOURCES = \
        ui/media-selector.vala \
        ui/media-menu-button.vala \
        ui/preferences-page.vala \
+       ui/preferences-page-gamepads.vala \
        ui/preferences-page-plugins.vala \
        ui/preferences-page-plugins-item.vala \
        ui/preferences-page-video.vala \
diff --git a/src/ui/preferences-page-gamepads.vala b/src/ui/preferences-page-gamepads.vala
new file mode 100644
index 0000000..fe5da53
--- /dev/null
+++ b/src/ui/preferences-page-gamepads.vala
@@ -0,0 +1,30 @@
+// This file is part of GNOME Games. License: GPL-3.0+.
+
+[GtkTemplate (ui = "/org/gnome/Games/ui/preferences-page-gamepads.ui")]
+private class Games.PreferencesPageGamepads: Gtk.Bin, PreferencesPage {
+       public string title {
+               get { return _("Gamepads"); }
+       }
+
+       [GtkChild]
+       private Gtk.ListBox gamepads_list_box;
+
+       construct {
+               var gamepad_monitor = GamepadMonitor.get_instance ();
+               var i = 0;
+               gamepad_monitor.foreach_gamepad ((gamepad) => {
+                       i += 1;
+                       var box = new Gtk.Box (Gtk.Orientation.HORIZONTAL, 0);
+                       box.pack_start (new Gtk.Label (gamepad.name), false, false);
+                       box.pack_end (new Gtk.Label (i.to_string ()), false, false);
+                       box.margin = 6;
+                       box.show_all ();
+                       gamepads_list_box.add (box);
+               });
+       }
+
+       [GtkCallback]
+       private void gamepads_list_box_row_activated (Gtk.ListBoxRow row_item) {
+               // open the gamepad configurer here
+       }
+}


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