[gnome-games] nintendo-ds: Make the layout switcher prettier



commit 8dba8923f36210943afb81470c6b983ef4fd2ae9
Author: Adrien Plazas <kekun plazas lapsote net>
Date:   Wed Sep 30 08:44:10 2020 +0200

    nintendo-ds: Make the layout switcher prettier

 .../nintendo-ds/data/ui/nintendo-ds-layout-item.ui | 46 ++++++++++++----------
 .../data/ui/nintendo-ds-layout-switcher.ui         | 15 +++----
 .../nintendo-ds/src/nintendo-ds-layout-item.vala   | 16 ++++----
 .../src/nintendo-ds-layout-switcher.vala           |  3 ++
 plugins/nintendo-ds/src/nintendo-ds-layout.vala    | 37 ++++-------------
 5 files changed, 52 insertions(+), 65 deletions(-)
---
diff --git a/plugins/nintendo-ds/data/ui/nintendo-ds-layout-item.ui 
b/plugins/nintendo-ds/data/ui/nintendo-ds-layout-item.ui
index 81b78ae0..fb393826 100644
--- a/plugins/nintendo-ds/data/ui/nintendo-ds-layout-item.ui
+++ b/plugins/nintendo-ds/data/ui/nintendo-ds-layout-item.ui
@@ -5,40 +5,46 @@
     <property name="visible">True</property>
     <child>
       <object class="GtkBox">
-        <property name="visible">True</property>
-        <property name="margin">6</property>
+        <property name="halign">start</property>
         <property name="spacing">6</property>
-        <child>
-          <object class="GtkImage" id="icon">
-            <property name="visible">True</property>
-            <property name="pixel-size">32</property>
-            <style>
-              <class name="list-icon"/>
-            </style>
-          </object>
-        </child>
+        <property name="valign">center</property>
+        <property name="visible">True</property>
         <child>
           <object class="GtkBox">
-            <property name="visible">True</property>
-            <property name="orientation">vertical</property>
+            <property name="halign">start</property>
+            <property name="spacing">12</property>
             <property name="valign">center</property>
+            <property name="visible">True</property>
             <child>
-              <object class="GtkLabel" id="title">
+              <object class="GtkImage" id="icon">
                 <property name="visible">True</property>
-                <property name="halign">start</property>
+                <style>
+                  <class name="list-icon"/>
+                </style>
               </object>
             </child>
             <child>
-              <object class="GtkLabel" id="subtitle">
-                <property name="visible">False</property>
+              <object class="GtkLabel" id="title">
                 <property name="halign">start</property>
-                <style>
-                  <class name="dim-label"/>
-                </style>
+                <property name="valign">center</property>
+                <property name="visible">True</property>
+                <property name="xalign">0</property>
               </object>
             </child>
           </object>
         </child>
+        <child>
+          <object class="GtkImage" id="checkmark">
+            <property name="visible">True</property>
+            <property name="valign">center</property>
+            <property name="halign">start</property>
+            <property name="opacity">0</property>
+            <property name="icon-name">emblem-ok-symbolic</property>
+            <style>
+              <class name="checkmark"/>
+            </style>
+          </object>
+        </child>
       </object>
     </child>
   </template>
diff --git a/plugins/nintendo-ds/data/ui/nintendo-ds-layout-switcher.ui 
b/plugins/nintendo-ds/data/ui/nintendo-ds-layout-switcher.ui
index 47aec5ff..b65680ad 100644
--- a/plugins/nintendo-ds/data/ui/nintendo-ds-layout-switcher.ui
+++ b/plugins/nintendo-ds/data/ui/nintendo-ds-layout-switcher.ui
@@ -63,17 +63,14 @@
     <property name="visible">False</property>
     <signal name="show" handler="update_ui"/>
     <child>
-      <object class="GtkFrame">
+      <object class="GtkListBox" id="list_box">
         <property name="visible">True</property>
-        <property name="margin">6</property>
-        <property name="shadow-type">in</property>
-        <child>
-          <object class="GtkListBox" id="list_box">
-            <property name="visible">True</property>
-            <signal name="row-activated" handler="on_row_activated"/>
-          </object>
-        </child>
+        <property name="selection-mode">none</property>
+        <signal name="row-activated" handler="on_row_activated"/>
       </object>
     </child>
+    <style>
+      <class name="combo"/>
+    </style>
   </object>
 </interface>
diff --git a/plugins/nintendo-ds/src/nintendo-ds-layout-item.vala 
b/plugins/nintendo-ds/src/nintendo-ds-layout-item.vala
index 359e123d..49595d4d 100644
--- a/plugins/nintendo-ds/src/nintendo-ds-layout-item.vala
+++ b/plugins/nintendo-ds/src/nintendo-ds-layout-item.vala
@@ -7,24 +7,26 @@ private class Games.NintendoDsLayoutItem : Gtk.ListBoxRow {
        [GtkChild]
        private Gtk.Label title;
        [GtkChild]
-       private Gtk.Label subtitle;
+       private Gtk.Image checkmark;
 
        public NintendoDsLayout layout { get; construct; }
 
+       public bool selected { get; set; default = false; }
+
        public NintendoDsLayoutItem (NintendoDsLayout layout) {
                Object (layout: layout);
        }
 
+       construct {
+               notify["selected"].connect (() => {
+                       checkmark.opacity = selected ? 1 : 0;
+               });
+       }
+
        public override void constructed () {
                icon.icon_name = layout.get_icon ();
                title.label = layout.get_title ();
 
-               var subtitle_str = layout.get_subtitle ();
-               if (subtitle_str != null) {
-                       subtitle.label = subtitle_str;
-                       subtitle.show ();
-               }
-
                base.constructed ();
        }
 }
diff --git a/plugins/nintendo-ds/src/nintendo-ds-layout-switcher.vala 
b/plugins/nintendo-ds/src/nintendo-ds-layout-switcher.vala
index 9974cc64..0f15d6b7 100644
--- a/plugins/nintendo-ds/src/nintendo-ds-layout-switcher.vala
+++ b/plugins/nintendo-ds/src/nintendo-ds-layout-switcher.vala
@@ -63,6 +63,9 @@ private class Games.NintendoDsLayoutSwitcher : Gtk.Box, HeaderBarWidget {
 
                layout_image.icon_name = layout.get_icon ();
 
+               foreach (var item in items.get_values ())
+                       item.selected = item.layout == layout;
+
                var item = items[layout];
                list_box.select_row (item);
 
diff --git a/plugins/nintendo-ds/src/nintendo-ds-layout.vala b/plugins/nintendo-ds/src/nintendo-ds-layout.vala
index a63f9356..0bb1f147 100644
--- a/plugins/nintendo-ds/src/nintendo-ds-layout.vala
+++ b/plugins/nintendo-ds/src/nintendo-ds-layout.vala
@@ -55,14 +55,18 @@ public enum Games.NintendoDsLayout {
                case LEFT_RIGHT:
                        /* Translators: This describes the layout for the Nintendo DS
                         * emulator. This setting means the two screens are displayed side
-                        * by side */
-                       return _("Side by 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 */
-                       return _("Side by 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
@@ -75,31 +79,6 @@ public enum Games.NintendoDsLayout {
                }
        }
 
-       public string? get_subtitle () {
-               switch (this) {
-               case LEFT_RIGHT:
-                       /* Translators: This describes the layout for the Nintendo DS
-                        * emulator when the two screens are displayed side by side and not
-                        * one on top of the other. The bottom screen is displayed to the
-                        * right of the top screen. */
-                       return _("Bottom to the right");
-
-               case RIGHT_LEFT:
-                       /* Translators: This describes the layout for the Nintendo DS
-                        * emulator when the two screens are displayed side by side and not
-                        * one on top of the other. The bottom screen is displayed to the
-                        * left of the top screen. */
-                       return _("Bottom to the left");
-
-               case TOP_BOTTOM:
-               case QUICK_SWITCH:
-                       return null;
-
-               default:
-                       assert_not_reached ();
-               }
-       }
-
        public static NintendoDsLayout[] get_layouts () {
                return { TOP_BOTTOM, LEFT_RIGHT, RIGHT_LEFT, QUICK_SWITCH };
        }


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