[gnome-games/wip/exalm/3ds: 9/17] nintendo-ds: Move layout switcher to core




commit 1d44da19229afe8fcec1409ccb3cb897b2c7a9ba
Author: Alexander Mikhaylenko <alexm gnome org>
Date:   Fri Dec 11 00:26:43 2020 +0500

    nintendo-ds: Move layout switcher to core
    
    The switcher will be shared with 3DS in future. Generify it a bit and move
    to src/screen-layout/.

 plugins/nintendo-ds/src/meson.build                |  2 -
 .../src/nintendo-ds-layout-switcher.vala           | 91 ----------------------
 plugins/nintendo-ds/src/nintendo-ds-layout.vala    | 73 +----------------
 plugins/nintendo-ds/src/nintendo-ds-runner.vala    | 37 +++++----
 plugins/nintendo-ds/src/nintendo-ds-snapshot.vala  |  4 +-
 plugins/nintendo-ds/src/nintendo-ds.gresource.xml  |  8 --
 .../icons/screen-layout-left-right-symbolic.svg    |  0
 .../icons/screen-layout-quick-switch-symbolic.svg  |  0
 .../icons/screen-layout-right-left-symbolic.svg    |  0
 .../icons/screen-layout-top-bottom-symbolic.svg    |  0
 .../icons/view-bottom-screen-symbolic.svg          |  0
 .../src => src}/icons/view-top-screen-symbolic.svg |  0
 src/meson.build                                    |  4 +
 src/org.gnome.Games.gresource.xml                  | 10 +++
 .../screen-layout/screen-layout-item.ui            |  2 +-
 .../screen-layout/screen-layout-item.vala          |  8 +-
 .../screen-layout/screen-layout-switcher.ui        |  2 +-
 src/screen-layout/screen-layout-switcher.vala      | 80 +++++++++++++++++++
 src/screen-layout/screen-layout.vala               | 66 ++++++++++++++++
 src/ui/application.vala                            |  1 +
 20 files changed, 195 insertions(+), 193 deletions(-)
---
diff --git a/plugins/nintendo-ds/src/meson.build b/plugins/nintendo-ds/src/meson.build
index 87c18a95..91d70d26 100644
--- a/plugins/nintendo-ds/src/meson.build
+++ b/plugins/nintendo-ds/src/meson.build
@@ -1,8 +1,6 @@
 vala_sources = [
   'nintendo-ds-icon.vala',
   'nintendo-ds-layout.vala',
-  'nintendo-ds-layout-item.vala',
-  'nintendo-ds-layout-switcher.vala',
   'nintendo-ds-platform.vala',
   'nintendo-ds-plugin.vala',
   'nintendo-ds-runner.vala',
diff --git a/plugins/nintendo-ds/src/nintendo-ds-layout.vala b/plugins/nintendo-ds/src/nintendo-ds-layout.vala
index 0bb1f147..7691447f 100644
--- a/plugins/nintendo-ds/src/nintendo-ds-layout.vala
+++ b/plugins/nintendo-ds/src/nintendo-ds-layout.vala
@@ -1,13 +1,6 @@
-// This file is part of GNOME Games. License: GPL-3.0+.
-
-public enum Games.NintendoDsLayout {
-       TOP_BOTTOM,
-       LEFT_RIGHT,
-       RIGHT_LEFT,
-       QUICK_SWITCH;
-
-       public string get_value () {
-               switch (this) {
+namespace Games.NintendoDsLayout {
+       private string get_value (ScreenLayout layout) {
+               switch (layout) {
                case TOP_BOTTOM:
                        return "top/bottom";
 
@@ -25,65 +18,7 @@ public enum Games.NintendoDsLayout {
                }
        }
 
-       public string get_icon () {
-               switch (this) {
-               case TOP_BOTTOM:
-                       return "screen-layout-top-bottom-symbolic";
-
-               case LEFT_RIGHT:
-                       return "screen-layout-left-right-symbolic";
-
-               case RIGHT_LEFT:
-                       return "screen-layout-right-left-symbolic";
-
-               case QUICK_SWITCH:
-                       return "screen-layout-quick-switch-symbolic";
-
-               default:
-                       assert_not_reached ();
-               }
-       }
-
-       public string get_title () {
-               switch (this) {
-               case TOP_BOTTOM:
-                       /* Translators: This describes the layout for the Nintendo DS
-                        * emulator. This setting means the two screens are stacked one on
-                        * top of the other */
-                       return _("Vertical");
-
-               case LEFT_RIGHT:
-                       /* Translators: This describes the layout for the Nintendo DS
-                        * emulator. This setting means the two screens are displayed side
-                        * by side and not one on top of the other. The bottom screen
-                        * (which is the touch screen) is displayed to the right of the top
-                        * screen, making it comfortable for right-handed persons. */
-                       return _("Side by side, right-handed");
-
-               case RIGHT_LEFT:
-                       /* Translators: This describes the layout for the Nintendo DS
-                        * emulator. This setting means the two screens are displayed side
-                        * by side and not one on top of the other. The bottom screen
-                        * (which is the touch screen) is displayed to the left of the top
-                        * screen, making it comfortable for left-handed persons. */
-                       return _("Side by side, left-handed");
-
-               case QUICK_SWITCH:
-                       /* Translators: This describes the layout for the Nintendo DS
-                        * emulator. This setting means only one screen is displayed at
-                        * once. The screen displayed can then be changed in-game. */
-                       return _("Single screen");
-
-               default:
-                       assert_not_reached ();
-               }
-       }
-
-       public static NintendoDsLayout[] get_layouts () {
-               return { TOP_BOTTOM, LEFT_RIGHT, RIGHT_LEFT, QUICK_SWITCH };
-       }
-
-       public static NintendoDsLayout? from_value (string value) {
+       private static ScreenLayout? from_value (string value) {
                switch (value) {
                case "top/bottom":
                        return TOP_BOTTOM;
diff --git a/plugins/nintendo-ds/src/nintendo-ds-runner.vala b/plugins/nintendo-ds/src/nintendo-ds-runner.vala
index 6463adeb..400f3658 100644
--- a/plugins/nintendo-ds/src/nintendo-ds-runner.vala
+++ b/plugins/nintendo-ds/src/nintendo-ds-runner.vala
@@ -2,7 +2,7 @@
 
 private class Games.NintendoDsRunner : RetroRunner {
        // Map the 1,2,3,4 key values to the 4 screen layouts of the Nintendo DS
-       private static HashTable<uint, NintendoDsLayout?> layouts;
+       private static HashTable<uint, ScreenLayout?> layouts;
        private static HashTable<string, string> gap_overrides;
 
        private const string SCREENS_LAYOUT_OPTION = "desmume_screens_layout";
@@ -13,8 +13,8 @@ private class Games.NintendoDsRunner : RetroRunner {
        private const size_t HEADER_GAME_CODE_OFFSET = 12;
        private const size_t HEADER_GAME_CODE_SIZE = 3;
 
-       private NintendoDsLayout _screen_layout;
-       public NintendoDsLayout screen_layout {
+       private ScreenLayout _screen_layout;
+       public ScreenLayout screen_layout {
                get { return _screen_layout; }
                set {
                        _screen_layout = value;
@@ -32,12 +32,12 @@ private class Games.NintendoDsRunner : RetroRunner {
        }
 
        static construct {
-               layouts = new HashTable<uint, NintendoDsLayout?> (direct_hash, direct_equal);
+               layouts = new HashTable<uint, ScreenLayout?> (direct_hash, direct_equal);
 
-               layouts[Gdk.Key.@1] = NintendoDsLayout.TOP_BOTTOM;
-               layouts[Gdk.Key.@2] = NintendoDsLayout.LEFT_RIGHT;
-               layouts[Gdk.Key.@3] = NintendoDsLayout.RIGHT_LEFT;
-               layouts[Gdk.Key.@4] = NintendoDsLayout.QUICK_SWITCH;
+               layouts[Gdk.Key.@1] = ScreenLayout.TOP_BOTTOM;
+               layouts[Gdk.Key.@2] = ScreenLayout.LEFT_RIGHT;
+               layouts[Gdk.Key.@3] = ScreenLayout.RIGHT_LEFT;
+               layouts[Gdk.Key.@4] = ScreenLayout.QUICK_SWITCH;
 
                gap_overrides = new HashTable<string, string> (str_hash, str_equal);
 
@@ -99,13 +99,13 @@ private class Games.NintendoDsRunner : RetroRunner {
                var core = get_core ();
 
                var screens_layout_option = core.get_option (SCREENS_LAYOUT_OPTION);
-               var screens_layout_option_value = screen_layout.get_value ();
-               if (screen_layout == NintendoDsLayout.QUICK_SWITCH)
+               var screens_layout_option_value = NintendoDsLayout.get_value (screen_layout);
+               if (screen_layout == ScreenLayout.QUICK_SWITCH)
                        screens_layout_option_value = view_bottom_screen ? "bottom only" : "top only";
 
                var screens_gap_option = core.get_option (SCREENS_GAP_OPTION);
                string screens_gap;
-               if (screen_layout == NintendoDsLayout.TOP_BOTTOM)
+               if (screen_layout == ScreenLayout.TOP_BOTTOM)
                        screens_gap = get_screen_gap_width ();
                else
                        screens_gap = SCREENS_GAP_NONE;
@@ -123,7 +123,14 @@ private class Games.NintendoDsRunner : RetroRunner {
                if (!core_supports_layouts ())
                        return null;
 
-               return new NintendoDsLayoutSwitcher (this);
+               var switcher = new ScreenLayoutSwitcher ();
+
+               bind_property ("screen-layout", switcher, "screen-layout",
+                              BindingFlags.SYNC_CREATE | BindingFlags.BIDIRECTIONAL);
+               bind_property ("view-bottom-screen", switcher, "view-bottom-screen",
+                              BindingFlags.SYNC_CREATE | BindingFlags.BIDIRECTIONAL);
+
+               return switcher;
        }
 
        public override bool key_press_event (uint keyval, Gdk.ModifierType state) {
@@ -137,7 +144,7 @@ private class Games.NintendoDsRunner : RetroRunner {
                        }
                }
 
-               if (screen_layout != NintendoDsLayout.QUICK_SWITCH)
+               if (screen_layout != ScreenLayout.QUICK_SWITCH)
                        return false;
 
                var switch_keyval = view_bottom_screen ? Gdk.Key.Page_Up : Gdk.Key.Page_Down;
@@ -155,7 +162,7 @@ private class Games.NintendoDsRunner : RetroRunner {
        }
 
        private bool swap_screens () {
-               if (screen_layout != NintendoDsLayout.QUICK_SWITCH)
+               if (screen_layout != ScreenLayout.QUICK_SWITCH)
                        return false;
 
                view_bottom_screen = !view_bottom_screen;
@@ -186,7 +193,7 @@ private class Games.NintendoDsRunner : RetroRunner {
        protected override void reset_with_snapshot (Snapshot? last_snapshot) throws Error {
                base.reset_with_snapshot (last_snapshot);
 
-               screen_layout = NintendoDsLayout.TOP_BOTTOM;
+               screen_layout = ScreenLayout.TOP_BOTTOM;
                view_bottom_screen = false;
        }
 }
diff --git a/plugins/nintendo-ds/src/nintendo-ds-snapshot.vala 
b/plugins/nintendo-ds/src/nintendo-ds-snapshot.vala
index acf25c11..3254b3db 100644
--- a/plugins/nintendo-ds/src/nintendo-ds-snapshot.vala
+++ b/plugins/nintendo-ds/src/nintendo-ds-snapshot.vala
@@ -1,7 +1,7 @@
 // This file is part of GNOME Games. License: GPL-3.0+.
 
 public class Games.NintendoDsSnapshot : Snapshot {
-       public NintendoDsLayout screen_layout { get; set; }
+       public ScreenLayout screen_layout { get; set; }
        public bool view_bottom_screen { get; set; }
 
        protected override void load_metadata (KeyFile keyfile) throws KeyFileError {
@@ -16,7 +16,7 @@ public class Games.NintendoDsSnapshot : Snapshot {
        protected override void save_metadata (KeyFile keyfile) {
                base.save_metadata (keyfile);
 
-               keyfile.set_string ("Nintendo DS", "Screen Layout", screen_layout.get_value ());
+               keyfile.set_string ("Nintendo DS", "Screen Layout", NintendoDsLayout.get_value 
(screen_layout));
                keyfile.set_boolean ("Nintendo DS", "View Bottom Screen", view_bottom_screen);
        }
 }
diff --git a/plugins/nintendo-ds/src/nintendo-ds.gresource.xml 
b/plugins/nintendo-ds/src/nintendo-ds.gresource.xml
index c69f4a8b..e9ee7c04 100644
--- a/plugins/nintendo-ds/src/nintendo-ds.gresource.xml
+++ b/plugins/nintendo-ds/src/nintendo-ds.gresource.xml
@@ -1,14 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <gresources>
   <gresource prefix="/org/gnome/Games/plugins/nintendo-ds">
-    <file>icons/screen-layout-left-right-symbolic.svg</file>
-    <file>icons/screen-layout-quick-switch-symbolic.svg</file>
-    <file>icons/screen-layout-right-left-symbolic.svg</file>
-    <file>icons/screen-layout-top-bottom-symbolic.svg</file>
-    <file>icons/view-bottom-screen-symbolic.svg</file>
-    <file>icons/view-top-screen-symbolic.svg</file>
     <file>layout-overrides</file>
-    <file>nintendo-ds-layout-item.ui</file>
-    <file>nintendo-ds-layout-switcher.ui</file>
   </gresource>
 </gresources>
diff --git a/plugins/nintendo-ds/src/icons/screen-layout-left-right-symbolic.svg 
b/src/icons/screen-layout-left-right-symbolic.svg
similarity index 100%
rename from plugins/nintendo-ds/src/icons/screen-layout-left-right-symbolic.svg
rename to src/icons/screen-layout-left-right-symbolic.svg
diff --git a/plugins/nintendo-ds/src/icons/screen-layout-quick-switch-symbolic.svg 
b/src/icons/screen-layout-quick-switch-symbolic.svg
similarity index 100%
rename from plugins/nintendo-ds/src/icons/screen-layout-quick-switch-symbolic.svg
rename to src/icons/screen-layout-quick-switch-symbolic.svg
diff --git a/plugins/nintendo-ds/src/icons/screen-layout-right-left-symbolic.svg 
b/src/icons/screen-layout-right-left-symbolic.svg
similarity index 100%
rename from plugins/nintendo-ds/src/icons/screen-layout-right-left-symbolic.svg
rename to src/icons/screen-layout-right-left-symbolic.svg
diff --git a/plugins/nintendo-ds/src/icons/screen-layout-top-bottom-symbolic.svg 
b/src/icons/screen-layout-top-bottom-symbolic.svg
similarity index 100%
rename from plugins/nintendo-ds/src/icons/screen-layout-top-bottom-symbolic.svg
rename to src/icons/screen-layout-top-bottom-symbolic.svg
diff --git a/plugins/nintendo-ds/src/icons/view-bottom-screen-symbolic.svg 
b/src/icons/view-bottom-screen-symbolic.svg
similarity index 100%
rename from plugins/nintendo-ds/src/icons/view-bottom-screen-symbolic.svg
rename to src/icons/view-bottom-screen-symbolic.svg
diff --git a/plugins/nintendo-ds/src/icons/view-top-screen-symbolic.svg 
b/src/icons/view-top-screen-symbolic.svg
similarity index 100%
rename from plugins/nintendo-ds/src/icons/view-top-screen-symbolic.svg
rename to src/icons/view-top-screen-symbolic.svg
diff --git a/src/meson.build b/src/meson.build
index 2548533c..8d833ce0 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -119,6 +119,10 @@ vala_sources = [
   'retro/retro-simple-type.vala',
   'retro/retro-simple-types.vala',
 
+  'screen-layout/screen-layout.vala',
+  'screen-layout/screen-layout-item.vala',
+  'screen-layout/screen-layout-switcher.vala',
+
   'tracker/mime-type-tracker-uri-query.vala',
   'tracker/tracker-error.vala',
   'tracker/tracker-uri-iterator.vala',
diff --git a/src/org.gnome.Games.gresource.xml b/src/org.gnome.Games.gresource.xml
index 58b1031c..6b91e83f 100644
--- a/src/org.gnome.Games.gresource.xml
+++ b/src/org.gnome.Games.gresource.xml
@@ -7,6 +7,13 @@
     <file preprocess="xml-stripblanks">gamepad/gamepad-mapper.ui</file>
     <file preprocess="xml-stripblanks">gamepad/gamepad-tester.ui</file>
 
+    <file preprocess="xml-stripblanks">icons/screen-layout-left-right-symbolic.svg</file>
+    <file preprocess="xml-stripblanks">icons/screen-layout-quick-switch-symbolic.svg</file>
+    <file preprocess="xml-stripblanks">icons/screen-layout-right-left-symbolic.svg</file>
+    <file preprocess="xml-stripblanks">icons/screen-layout-top-bottom-symbolic.svg</file>
+    <file preprocess="xml-stripblanks">icons/view-bottom-screen-symbolic.svg</file>
+    <file preprocess="xml-stripblanks">icons/view-top-screen-symbolic.svg</file>
+
     <file preprocess="xml-stripblanks">gesture/button-east-symbolic.svg</file>
     <file preprocess="xml-stripblanks">gesture/button-home-symbolic.svg</file>
     <file preprocess="xml-stripblanks">gesture/button-south-symbolic.svg</file>
@@ -27,6 +34,9 @@
     <file preprocess="xml-stripblanks">preferences/preferences-subpage-keyboard.ui</file>
     <file preprocess="xml-stripblanks">preferences/preferences-window.ui</file>
 
+    <file preprocess="xml-stripblanks">screen-layout/screen-layout-item.ui</file>
+    <file preprocess="xml-stripblanks">screen-layout/screen-layout-switcher.ui</file>
+
     <file preprocess="xml-stripblanks">ui/application-window.ui</file>
     <file preprocess="xml-stripblanks">ui/checkmark-item.ui</file>
     <file preprocess="xml-stripblanks">ui/collection-action-window.ui</file>
diff --git a/plugins/nintendo-ds/src/nintendo-ds-layout-item.ui b/src/screen-layout/screen-layout-item.ui
similarity index 96%
rename from plugins/nintendo-ds/src/nintendo-ds-layout-item.ui
rename to src/screen-layout/screen-layout-item.ui
index fb393826..14f365a2 100644
--- a/plugins/nintendo-ds/src/nintendo-ds-layout-item.ui
+++ b/src/screen-layout/screen-layout-item.ui
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <interface>
   <requires lib="gtk+" version="3.24"/>
-  <template class="GamesNintendoDsLayoutItem" parent="GtkListBoxRow">
+  <template class="GamesScreenLayoutItem" parent="GtkListBoxRow">
     <property name="visible">True</property>
     <child>
       <object class="GtkBox">
diff --git a/plugins/nintendo-ds/src/nintendo-ds-layout-item.vala b/src/screen-layout/screen-layout-item.vala
similarity index 66%
rename from plugins/nintendo-ds/src/nintendo-ds-layout-item.vala
rename to src/screen-layout/screen-layout-item.vala
index 1de1c591..7007783a 100644
--- a/plugins/nintendo-ds/src/nintendo-ds-layout-item.vala
+++ b/src/screen-layout/screen-layout-item.vala
@@ -1,7 +1,7 @@
 // This file is part of GNOME Games. License: GPL-3.0+.
 
-[GtkTemplate (ui = "/org/gnome/Games/plugins/nintendo-ds/nintendo-ds-layout-item.ui")]
-private class Games.NintendoDsLayoutItem : Gtk.ListBoxRow {
+[GtkTemplate (ui = "/org/gnome/Games/screen-layout/screen-layout-item.ui")]
+private class Games.ScreenLayoutItem : Gtk.ListBoxRow {
        [GtkChild]
        private Gtk.Image icon;
        [GtkChild]
@@ -9,11 +9,11 @@ private class Games.NintendoDsLayoutItem : Gtk.ListBoxRow {
        [GtkChild]
        private Gtk.Image checkmark;
 
-       public NintendoDsLayout layout { get; construct; }
+       public ScreenLayout layout { get; construct; }
 
        public bool selected { get; set; default = false; }
 
-       public NintendoDsLayoutItem (NintendoDsLayout layout) {
+       public ScreenLayoutItem (ScreenLayout layout) {
                Object (layout: layout);
        }
 
diff --git a/plugins/nintendo-ds/src/nintendo-ds-layout-switcher.ui 
b/src/screen-layout/screen-layout-switcher.ui
similarity index 97%
rename from plugins/nintendo-ds/src/nintendo-ds-layout-switcher.ui
rename to src/screen-layout/screen-layout-switcher.ui
index b65680ad..c0c6878a 100644
--- a/plugins/nintendo-ds/src/nintendo-ds-layout-switcher.ui
+++ b/src/screen-layout/screen-layout-switcher.ui
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <interface>
   <requires lib="gtk+" version="3.24"/>
-  <template class="GamesNintendoDsLayoutSwitcher" parent="GtkBox">
+  <template class="GamesScreenLayoutSwitcher" parent="GtkBox">
     <property name="visible">True</property>
 
     <child>
diff --git a/src/screen-layout/screen-layout-switcher.vala b/src/screen-layout/screen-layout-switcher.vala
new file mode 100644
index 00000000..bd0b824f
--- /dev/null
+++ b/src/screen-layout/screen-layout-switcher.vala
@@ -0,0 +1,80 @@
+// This file is part of GNOME Games. License: GPL-3.0+.
+
+[GtkTemplate (ui = "/org/gnome/Games/screen-layout/screen-layout-switcher.ui")]
+public class Games.ScreenLayoutSwitcher : Gtk.Box, HeaderBarWidget {
+       [GtkChild]
+       private Gtk.Revealer change_screen_revealer;
+       [GtkChild]
+       private Gtk.Image change_screen_image;
+       [GtkChild]
+       private Gtk.MenuButton layout_button;
+       [GtkChild]
+       private Gtk.Image layout_image;
+       [GtkChild]
+       private Gtk.Popover layout_popover;
+       [GtkChild]
+       private Gtk.ListBox list_box;
+
+       private HashTable<ScreenLayout, ScreenLayoutItem> items;
+
+       public ScreenLayout screen_layout { get; set; }
+       public bool view_bottom_screen { get; set; }
+
+       private bool is_menu_open;
+       public bool block_autohide {
+               get { return is_menu_open; }
+       }
+
+       public override void constructed () {
+               items = new HashTable<ScreenLayout, ScreenLayoutItem> (direct_hash, direct_equal);
+               foreach (var layout in ScreenLayout.get_layouts ()) {
+                       var item = new ScreenLayoutItem (layout);
+
+                       items[layout] = item;
+                       list_box.add (item);
+               }
+
+               update_ui ();
+
+               notify["screen-layout"].connect (update_ui);
+               notify["view-bottom-screen"].connect (update_ui);
+
+               base.constructed ();
+       }
+
+       [GtkCallback]
+       private void on_menu_state_changed () {
+               is_menu_open = layout_button.active;
+               notify_property ("block-autohide");
+       }
+
+       [GtkCallback]
+       private void update_ui () {
+               layout_image.icon_name = screen_layout.get_icon ();
+
+               foreach (var item in items.get_values ())
+                       item.selected = item.layout == screen_layout;
+
+               var item = items[screen_layout];
+               list_box.select_row (item);
+
+               change_screen_revealer.reveal_child = (screen_layout == ScreenLayout.QUICK_SWITCH);
+               change_screen_image.icon_name = view_bottom_screen ?
+                                               "view-top-screen-symbolic" :
+                                               "view-bottom-screen-symbolic";
+       }
+
+       [GtkCallback]
+       private void on_screen_changed () {
+               view_bottom_screen = !view_bottom_screen;
+       }
+
+       [GtkCallback]
+       private void on_row_activated (Gtk.ListBoxRow row) {
+               var layout_item = row as ScreenLayoutItem;
+
+               screen_layout = layout_item.layout;
+
+               layout_popover.popdown ();
+       }
+}
diff --git a/src/screen-layout/screen-layout.vala b/src/screen-layout/screen-layout.vala
new file mode 100644
index 00000000..2d146385
--- /dev/null
+++ b/src/screen-layout/screen-layout.vala
@@ -0,0 +1,66 @@
+// This file is part of GNOME Games. License: GPL-3.0+.
+
+public enum Games.ScreenLayout {
+       TOP_BOTTOM,
+       LEFT_RIGHT,
+       RIGHT_LEFT,
+       QUICK_SWITCH;
+
+       public string get_icon () {
+               switch (this) {
+               case TOP_BOTTOM:
+                       return "screen-layout-top-bottom-symbolic";
+
+               case LEFT_RIGHT:
+                       return "screen-layout-left-right-symbolic";
+
+               case RIGHT_LEFT:
+                       return "screen-layout-right-left-symbolic";
+
+               case QUICK_SWITCH:
+                       return "screen-layout-quick-switch-symbolic";
+
+               default:
+                       assert_not_reached ();
+               }
+       }
+
+       public string get_title () {
+               switch (this) {
+               case TOP_BOTTOM:
+                       /* Translators: This describes the layout for the Nintendo DS and
+                        * 3DS emulators. This setting means the two screens are stacked one
+                        * on top of the other */
+                       return _("Vertical");
+
+               case LEFT_RIGHT:
+                       /* Translators: This describes the layout for the Nintendo DS and
+                        * 3DS emulators. This setting means the two screens are displaye
+                        * side by side and not one on top of the other. The bottom screen
+                        * (which is the touch screen) is displayed to the right of the top
+                        * screen, making it comfortable for right-handed persons. */
+                       return _("Side by side, right-handed");
+
+               case RIGHT_LEFT:
+                       /* Translators: This describes the layout for the Nintendo DS and
+                        * 3DS emulators. This setting means the two screens are displayed
+                        * side by side and not one on top of the other. The bottom screen
+                        * (which is the touch screen) is displayed to the left of the top
+                        * screen, making it comfortable for left-handed persons. */
+                       return _("Side by side, left-handed");
+
+               case QUICK_SWITCH:
+                       /* Translators: This describes the layout for the Nintendo DS and
+                        * 3DS emulators. This setting means only one screen is displayed at
+                        * once. The screen displayed can then be changed in-game. */
+                       return _("Single screen");
+
+               default:
+                       assert_not_reached ();
+               }
+       }
+
+       public static ScreenLayout[] get_layouts () {
+               return { TOP_BOTTOM, LEFT_RIGHT, RIGHT_LEFT, QUICK_SWITCH };
+       }
+}
diff --git a/src/ui/application.vala b/src/ui/application.vala
index 9c58e40f..8ff9e7b6 100644
--- a/src/ui/application.vala
+++ b/src/ui/application.vala
@@ -234,6 +234,7 @@ public class Games.Application : Gtk.Application {
                Gtk.Settings.get_default ().gtk_application_prefer_dark_theme = true;
 
                var icon_theme = Gtk.IconTheme.get_default ();
+               icon_theme.add_resource_path ("/org/gnome/Games/icons/");
                icon_theme.add_resource_path ("/org/gnome/Games/gesture");
        }
 


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