[gnome-games/wip/abhinavsingh/gamepad-reassign: 12/12] ui: Display ControllerPopover in DisplayHeaderBar



commit f4170476dad9437173dd57d1c1ede26a4f4db074
Author: theawless <theawless gmail com>
Date:   Sat Aug 12 00:31:17 2017 +0530

    ui: Display ControllerPopover in DisplayHeaderBar

 data/ui/display-header-bar.ui  |   25 +++++++++++++++++++++++++
 src/ui/application-window.vala |    2 ++
 src/ui/display-header-bar.vala |   14 ++++++++++++++
 3 files changed, 41 insertions(+), 0 deletions(-)
---
diff --git a/data/ui/display-header-bar.ui b/data/ui/display-header-bar.ui
index aae8f8d..90547b6 100644
--- a/data/ui/display-header-bar.ui
+++ b/data/ui/display-header-bar.ui
@@ -92,5 +92,30 @@
         <property name="pack-type">end</property>
       </packing>
     </child>
+    <child>
+      <object class="GtkMenuButton" id="controller_button">
+        <property name="visible">True</property>
+        <property name="valign">center</property>
+        <property name="use-underline">True</property>
+        <style>
+          <class name="image-button"/>
+        </style>
+        <child internal-child="accessible">
+          <object class="AtkObject" id="a11y-controller">
+            <property name="accessible-name" translatable="yes">controller</property>
+          </object>
+        </child>
+        <child>
+          <object class="GtkImage" id="controller_image">
+            <property name="visible">True</property>
+            <property name="icon-name">input-gaming-symbolic</property>
+            <property name="icon-size">1</property>
+          </object>
+        </child>
+      </object>
+      <packing>
+        <property name="pack-type">end</property>
+      </packing>
+    </child>
   </template>
 </interface>
diff --git a/src/ui/application-window.vala b/src/ui/application-window.vala
index 4c157ef..bfaeb9e 100644
--- a/src/ui/application-window.vala
+++ b/src/ui/application-window.vala
@@ -254,6 +254,8 @@ private class Games.ApplicationWindow : Gtk.ApplicationWindow {
                display_box.runner = runner;
                display_header_bar.media_set = runner.media_set;
                display_box.header_bar.media_set = runner.media_set;
+               display_header_bar.controller_set = runner.controller_set;
+               display_box.header_bar.controller_set = runner.controller_set;
 
                is_fullscreen = settings.get_boolean ("fullscreen") && runner.can_fullscreen;
 
diff --git a/src/ui/display-header-bar.vala b/src/ui/display-header-bar.vala
index 5fa6749..8481480 100644
--- a/src/ui/display-header-bar.vala
+++ b/src/ui/display-header-bar.vala
@@ -6,6 +6,8 @@ private class Games.DisplayHeaderBar : Gtk.HeaderBar {
 
        [GtkChild]
        private MediaMenuButton media_button;
+       [GtkChild]
+       private Gtk.MenuButton controller_button;
 
        public string game_title {
                set { title = value; }
@@ -21,7 +23,15 @@ private class Games.DisplayHeaderBar : Gtk.HeaderBar {
                }
        }
 
+       public ControllerSet? controller_set {
+               set {
+                       controller_popover.controller_set = value;
+                       controller_button.visible = value != null;
+               }
+       }
+
        private MediaSelector media_selector;
+       private ControllerPopover controller_popover;
 
        [GtkChild]
        private Gtk.Button fullscreen;
@@ -34,6 +44,10 @@ private class Games.DisplayHeaderBar : Gtk.HeaderBar {
        construct {
                settings = new Settings ("org.gnome.Games");
 
+               controller_popover = new ControllerPopover ();
+               controller_popover.set_relative_to (controller_button);
+               controller_button.set_popover (controller_popover);
+
                media_selector = new MediaSelector ();
                media_selector.set_relative_to (media_button);
                media_button.set_popover (media_selector);


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