[gnome-games/wip/abhinavsingh/gamepad-config2: 19/20] ui: Add preferences page for inputs
- From: Abhinav Singh <abhinavsingh src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-games/wip/abhinavsingh/gamepad-config2: 19/20] ui: Add preferences page for inputs
- Date: Mon, 17 Jul 2017 09:36:13 +0000 (UTC)
commit d7c5395e9ccbe258636dfe2877d3ca397c7737e7
Author: theawless <theawless gmail com>
Date: Tue May 23 20:13:26 2017 +0530
ui: Add preferences page for inputs
This screen will allow the users to edit the settings related to inputs
like gamepads and keyboard.
data/Makefile.am | 1 +
data/org.gnome.Games.gresource.xml | 1 +
data/ui/preferences-page-input.ui | 67 +++++++++++++++++++++++++++++++
data/ui/preferences-window.ui | 9 ++++
src/Makefile.am | 1 +
src/ui/preferences-page-input.vala | 77 ++++++++++++++++++++++++++++++++++++
6 files changed, 156 insertions(+), 0 deletions(-)
---
diff --git a/data/Makefile.am b/data/Makefile.am
index 5f3d675..ec03a0d 100644
--- a/data/Makefile.am
+++ b/data/Makefile.am
@@ -41,6 +41,7 @@ EXTRA_DIST = \
ui/game-icon-view.ui \
ui/media-menu-button.ui \
ui/media-selector.ui \
+ ui/preferences-page-input.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 49a7af4..b4926d3 100644
--- a/data/org.gnome.Games.gresource.xml
+++ b/data/org.gnome.Games.gresource.xml
@@ -20,6 +20,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-input.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-input.ui b/data/ui/preferences-page-input.ui
new file mode 100644
index 0000000..9ce4607
--- /dev/null
+++ b/data/ui/preferences-page-input.ui
@@ -0,0 +1,67 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+ <template class="GamesPreferencesPageInput" parent="GtkStack">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ <property name="visible-child">main_stack_child_holder</property>
+ <property name="transition-type">GTK_STACK_TRANSITION_TYPE_SLIDE_LEFT_RIGHT</property>
+ <child>
+ <object class="GtkBox" id="extra_stack_child_holder">
+ <property name="visible">True</property>
+ <property name="can_focus">False</property>
+ </object>
+ <packing>
+ <property name="name">extra_stack_child</property>
+ </packing>
+ </child>
+ <child>
+ <object class="GtkScrolledWindow" id="main_stack_child_holder">
+ <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>
+ <packing>
+ <property name="name">main_stack_child</property>
+ </packing>
+ </child>
+ </template>
+</interface>
diff --git a/data/ui/preferences-window.ui b/data/ui/preferences-window.ui
index 36026a6..97f14d2 100644
--- a/data/ui/preferences-window.ui
+++ b/data/ui/preferences-window.ui
@@ -95,6 +95,15 @@
</packing>
</child>
<child>
+ <object class="GamesPreferencesPageInput" id="input_page">
+ <property name="visible">True</property>
+ </object>
+ <packing>
+ <property name="name">input</property>
+ <property name="title" translatable="yes">Input</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 43cf66b..98f6923 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -136,6 +136,7 @@ gnome_games_SOURCES = \
ui/media-selector.vala \
ui/media-menu-button.vala \
ui/preferences-page.vala \
+ ui/preferences-page-input.vala \
ui/preferences-page-plugins.vala \
ui/preferences-page-plugins-item.vala \
ui/preferences-page-video.vala \
diff --git a/src/ui/preferences-page-input.vala b/src/ui/preferences-page-input.vala
new file mode 100644
index 0000000..8182d28
--- /dev/null
+++ b/src/ui/preferences-page-input.vala
@@ -0,0 +1,77 @@
+// This file is part of GNOME Games. License: GPL-3.0+.
+
+[GtkTemplate (ui = "/org/gnome/Games/ui/preferences-page-input.ui")]
+private class Games.PreferencesPageInput: Gtk.Stack, PreferencesPage {
+ private Gtk.Widget _header_content;
+ public Gtk.Widget header_content {
+ get { return _header_content; }
+ protected set { _header_content = value; }
+ }
+
+ [GtkChild]
+ private Gtk.ListBox gamepads_list_box;
+ [GtkChild]
+ private Gtk.Box extra_stack_child_holder;
+ private GamepadMonitor gamepad_monitor;
+ private Gtk.Label default_label;
+
+ construct {
+ default_label = new Gtk.Label (_("Input"));
+ header_content = default_label;
+ header_content.visible = true;
+
+ gamepad_monitor = GamepadMonitor.get_instance ();
+
+ gamepad_monitor.gamepad_unplugged.connect (rebuild_gamepad_list);
+ gamepad_monitor.gamepad_plugged.connect (rebuild_gamepad_list);
+ build_gamepad_list ();
+ }
+
+ private void rebuild_gamepad_list () {
+ clear_gamepad_list ();
+ build_gamepad_list ();
+ }
+
+ private void build_gamepad_list () {
+ 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);
+ });
+ }
+
+ private void clear_gamepad_list () {
+ gamepads_list_box.foreach ((child) => child.destroy ());
+ }
+
+ [GtkCallback]
+ private void gamepads_list_box_row_activated (Gtk.ListBoxRow row_item) {
+ Gamepad? gamepad = null;
+ var i = 0;
+ gamepad_monitor.foreach_gamepad ((gamepad_) => {
+ if (i == row_item.get_index ())
+ gamepad = gamepad_;
+ i++;
+ });
+
+ if (gamepad == null)
+ return;
+ var mapper = new GamepadMapper(gamepad);
+ mapper.back.connect (on_mapper_back);
+ header_content = mapper.header_content;
+ extra_stack_child_holder.pack_start (mapper);
+ set_visible_child_name ("extra_stack_child");
+ mapper.start ();
+ }
+
+ private void on_mapper_back () {
+ header_content = default_label;
+ set_visible_child_name ("main_stack_child");
+ extra_stack_child_holder.foreach ((child) => child.destroy ());
+ }
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]