[gnome-games/wip/exalm/ds: 36/37] nintendo-ds: Add NintendoDsLayoutSwitcher



commit 56f0e74c43f31e55d97cd542adc823ab1a0975fa
Author: Alexander Mikhaylenko <exalm7659 gmail com>
Date:   Sun Jan 6 20:47:41 2019 +0500

    nintendo-ds: Add NintendoDsLayoutSwitcher
    
    Provides a popover to switch between available screen modes and a separate
    button to swap screens in quick switch mode.

 data/gtk-style.css                                 |   3 +
 .../icons/screen-layout-left-right-symbolic.svg    |  70 ++++++++++++
 .../icons/screen-layout-quick-switch-symbolic.svg  |  66 +++++++++++
 .../icons/screen-layout-right-left-symbolic.svg    |  71 ++++++++++++
 .../icons/screen-layout-top-bottom-symbolic.svg    |  71 ++++++++++++
 .../data/icons/view-bottom-screen-symbolic.svg     |  66 +++++++++++
 .../data/icons/view-top-screen-symbolic.svg        |  66 +++++++++++
 plugins/nintendo-ds/data/meson.build               |   6 +
 plugins/nintendo-ds/data/nintendo-ds.gresource.xml |  13 +++
 .../nintendo-ds/data/ui/nintendo-ds-layout-item.ui |  45 ++++++++
 .../data/ui/nintendo-ds-layout-switcher.ui         |  76 +++++++++++++
 plugins/nintendo-ds/src/meson.build                |   4 +-
 .../nintendo-ds/src/nintendo-ds-layout-item.vala   |  29 +++++
 .../src/nintendo-ds-layout-switcher.vala           | 126 +++++++++++++++++++++
 14 files changed, 711 insertions(+), 1 deletion(-)
---
diff --git a/data/gtk-style.css b/data/gtk-style.css
index 7203e785..1d136531 100644
--- a/data/gtk-style.css
+++ b/data/gtk-style.css
@@ -30,3 +30,6 @@ stacksidebar list {
        border-right-width: 0px;
 }
 
+.list-icon {
+       opacity: 0.7;
+}
diff --git a/plugins/nintendo-ds/data/icons/screen-layout-left-right-symbolic.svg 
b/plugins/nintendo-ds/data/icons/screen-layout-left-right-symbolic.svg
new file mode 100644
index 00000000..66c963f4
--- /dev/null
+++ b/plugins/nintendo-ds/data/icons/screen-layout-left-right-symbolic.svg
@@ -0,0 +1,70 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<svg
+   xmlns:dc="http://purl.org/dc/elements/1.1/";
+   xmlns:cc="http://creativecommons.org/ns#";
+   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#";
+   xmlns:svg="http://www.w3.org/2000/svg";
+   xmlns="http://www.w3.org/2000/svg";
+   xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd";
+   xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape";
+   width="16"
+   height="16"
+   version="1.1"
+   id="svg8"
+   sodipodi:docname="ds-touchscreen-right.svg"
+   inkscape:version="0.92.2 2405546, 2018-03-11">
+  <metadata
+     id="metadata14">
+    <rdf:RDF>
+      <cc:Work
+         rdf:about="">
+        <dc:format>image/svg+xml</dc:format>
+        <dc:type
+           rdf:resource="http://purl.org/dc/dcmitype/StillImage"; />
+        <dc:title></dc:title>
+      </cc:Work>
+    </rdf:RDF>
+  </metadata>
+  <defs
+     id="defs12" />
+  <sodipodi:namedview
+     pagecolor="#ffffff"
+     bordercolor="#666666"
+     borderopacity="1"
+     objecttolerance="10"
+     gridtolerance="10"
+     guidetolerance="10"
+     inkscape:pageopacity="0"
+     inkscape:pageshadow="2"
+     inkscape:window-width="2560"
+     inkscape:window-height="1376"
+     id="namedview10"
+     showgrid="true"
+     inkscape:zoom="64"
+     inkscape:cx="3.6767386"
+     inkscape:cy="8.1664307"
+     inkscape:window-x="0"
+     inkscape:window-y="27"
+     inkscape:window-maximized="1"
+     inkscape:current-layer="svg8">
+    <inkscape:grid
+       type="xygrid"
+       id="grid4526" />
+  </sodipodi:namedview>
+  <g
+     id="g873">
+    <rect
+       y="5.5"
+       x="7.5"
+       height="6"
+       width="6"
+       id="rect869"
+       
style="opacity:0.5;fill:#474747;fill-opacity:1;stroke:none;stroke-width:1.2544198;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
 />
+    <path
+       sodipodi:nodetypes="ssssssssscccccccccc"
+       inkscape:connector-curvature="0"
+       id="path4659-5"
+       d="M 15,6 C 15,5.057191 13.942809,4 13,4 H 2 C 1.057191,4 0,5.057191 0,6 v 5 c 0,0.942809 1.057191,2 
2,2 h 11 c 0.942809,0 2,-1.057191 2,-2 z m -2,0 v 5 H 8 V 6 Z M 7,6 v 5 H 2 V 6 Z"
+       
style="fill:#474747;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
 />
+  </g>
+</svg>
diff --git a/plugins/nintendo-ds/data/icons/screen-layout-quick-switch-symbolic.svg 
b/plugins/nintendo-ds/data/icons/screen-layout-quick-switch-symbolic.svg
new file mode 100644
index 00000000..f2b61d32
--- /dev/null
+++ b/plugins/nintendo-ds/data/icons/screen-layout-quick-switch-symbolic.svg
@@ -0,0 +1,66 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<svg
+   xmlns:dc="http://purl.org/dc/elements/1.1/";
+   xmlns:cc="http://creativecommons.org/ns#";
+   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#";
+   xmlns:svg="http://www.w3.org/2000/svg";
+   xmlns="http://www.w3.org/2000/svg";
+   xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd";
+   xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape";
+   width="16"
+   height="16"
+   version="1.1"
+   id="svg8"
+   sodipodi:docname="screen-layout-quick-switch-symbolic.svg"
+   inkscape:version="0.92.4 5da689c313, 2019-01-14">
+  <metadata
+     id="metadata14">
+    <rdf:RDF>
+      <cc:Work
+         rdf:about="">
+        <dc:format>image/svg+xml</dc:format>
+        <dc:type
+           rdf:resource="http://purl.org/dc/dcmitype/StillImage"; />
+        <dc:title />
+      </cc:Work>
+    </rdf:RDF>
+  </metadata>
+  <defs
+     id="defs12" />
+  <sodipodi:namedview
+     pagecolor="#ffffff"
+     bordercolor="#666666"
+     borderopacity="1"
+     objecttolerance="10"
+     gridtolerance="10"
+     guidetolerance="10"
+     inkscape:pageopacity="0"
+     inkscape:pageshadow="2"
+     inkscape:window-width="1920"
+     inkscape:window-height="1016"
+     id="namedview10"
+     showgrid="true"
+     inkscape:zoom="32"
+     inkscape:cx="8.3953872"
+     inkscape:cy="9.5898251"
+     inkscape:window-x="0"
+     inkscape:window-y="27"
+     inkscape:window-maximized="1"
+     inkscape:current-layer="svg8">
+    <inkscape:grid
+       type="xygrid"
+       id="grid4526" />
+  </sodipodi:namedview>
+  <path
+     
style="opacity:0.5;fill:#474747;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+     d="m 9,1 c 0.942809,0 1.999979,1.057191 2,2 V 4 H 9 V 3 H 3 v 6 h 1 v 2 H 3 C 2.057191,11 
1.000021,9.942809 1,9 V 3 C 0.999979,2.057191 2.057191,1 3,1 Z"
+     id="path872"
+     inkscape:connector-curvature="0"
+     sodipodi:nodetypes="sccccccccsccss" />
+  <path
+     sodipodi:nodetypes="sccssccssccccc"
+     inkscape:connector-curvature="0"
+     id="path817"
+     d="m 13,5 c 0.942809,0 1.999979,1.057191 2,2 v 6 c 2.1e-5,0.942809 -1.057191,2 -2,2 H 7 C 6.057191,15 
5.000021,13.942809 5,13 V 7 C 4.999979,6.057191 6.057191,5 7,5 Z m 0,2 H 7 v 6 h 6 z"
+     
style="fill:#474747;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
 />
+</svg>
diff --git a/plugins/nintendo-ds/data/icons/screen-layout-right-left-symbolic.svg 
b/plugins/nintendo-ds/data/icons/screen-layout-right-left-symbolic.svg
new file mode 100644
index 00000000..0219572b
--- /dev/null
+++ b/plugins/nintendo-ds/data/icons/screen-layout-right-left-symbolic.svg
@@ -0,0 +1,71 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<svg
+   xmlns:dc="http://purl.org/dc/elements/1.1/";
+   xmlns:cc="http://creativecommons.org/ns#";
+   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#";
+   xmlns:svg="http://www.w3.org/2000/svg";
+   xmlns="http://www.w3.org/2000/svg";
+   xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd";
+   xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape";
+   width="16"
+   height="16"
+   version="1.1"
+   id="svg8"
+   sodipodi:docname="ds-touchscreen-left.svg"
+   inkscape:version="0.92.2 2405546, 2018-03-11">
+  <metadata
+     id="metadata14">
+    <rdf:RDF>
+      <cc:Work
+         rdf:about="">
+        <dc:format>image/svg+xml</dc:format>
+        <dc:type
+           rdf:resource="http://purl.org/dc/dcmitype/StillImage"; />
+        <dc:title></dc:title>
+      </cc:Work>
+    </rdf:RDF>
+  </metadata>
+  <defs
+     id="defs12" />
+  <sodipodi:namedview
+     pagecolor="#ffffff"
+     bordercolor="#666666"
+     borderopacity="1"
+     objecttolerance="10"
+     gridtolerance="10"
+     guidetolerance="10"
+     inkscape:pageopacity="0"
+     inkscape:pageshadow="2"
+     inkscape:window-width="2560"
+     inkscape:window-height="1376"
+     id="namedview10"
+     showgrid="true"
+     inkscape:zoom="64"
+     inkscape:cx="3.6767386"
+     inkscape:cy="8.1664307"
+     inkscape:window-x="0"
+     inkscape:window-y="27"
+     inkscape:window-maximized="1"
+     inkscape:current-layer="svg8">
+    <inkscape:grid
+       type="xygrid"
+       id="grid4526" />
+  </sodipodi:namedview>
+  <g
+     id="g873"
+     transform="matrix(-1,0,0,1,15,0)">
+    <rect
+       y="5.5"
+       x="7.5"
+       height="6"
+       width="6"
+       id="rect869"
+       
style="opacity:0.5;fill:#474747;fill-opacity:1;stroke:none;stroke-width:1.2544198;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
 />
+    <path
+       sodipodi:nodetypes="ssssssssscccccccccc"
+       inkscape:connector-curvature="0"
+       id="path4659-5"
+       d="M 15,6 C 15,5.057191 13.942809,4 13,4 H 2 C 1.057191,4 0,5.057191 0,6 v 5 c 0,0.942809 1.057191,2 
2,2 h 11 c 0.942809,0 2,-1.057191 2,-2 z m -2,0 v 5 H 8 V 6 Z M 7,6 v 5 H 2 V 6 Z"
+       
style="fill:#474747;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
 />
+  </g>
+</svg>
diff --git a/plugins/nintendo-ds/data/icons/screen-layout-top-bottom-symbolic.svg 
b/plugins/nintendo-ds/data/icons/screen-layout-top-bottom-symbolic.svg
new file mode 100644
index 00000000..5f633d76
--- /dev/null
+++ b/plugins/nintendo-ds/data/icons/screen-layout-top-bottom-symbolic.svg
@@ -0,0 +1,71 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<svg
+   xmlns:dc="http://purl.org/dc/elements/1.1/";
+   xmlns:cc="http://creativecommons.org/ns#";
+   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#";
+   xmlns:svg="http://www.w3.org/2000/svg";
+   xmlns="http://www.w3.org/2000/svg";
+   xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd";
+   xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape";
+   width="16"
+   height="16"
+   version="1.1"
+   id="svg8"
+   sodipodi:docname="ds-touchscreen-bottom.svg"
+   inkscape:version="0.92.2 2405546, 2018-03-11">
+  <metadata
+     id="metadata14">
+    <rdf:RDF>
+      <cc:Work
+         rdf:about="">
+        <dc:format>image/svg+xml</dc:format>
+        <dc:type
+           rdf:resource="http://purl.org/dc/dcmitype/StillImage"; />
+        <dc:title></dc:title>
+      </cc:Work>
+    </rdf:RDF>
+  </metadata>
+  <defs
+     id="defs12" />
+  <sodipodi:namedview
+     pagecolor="#ffffff"
+     bordercolor="#666666"
+     borderopacity="1"
+     objecttolerance="10"
+     gridtolerance="10"
+     guidetolerance="10"
+     inkscape:pageopacity="0"
+     inkscape:pageshadow="2"
+     inkscape:window-width="2560"
+     inkscape:window-height="1376"
+     id="namedview10"
+     showgrid="true"
+     inkscape:zoom="64"
+     inkscape:cx="3.6767386"
+     inkscape:cy="8.1664307"
+     inkscape:window-x="0"
+     inkscape:window-y="27"
+     inkscape:window-maximized="1"
+     inkscape:current-layer="svg8">
+    <inkscape:grid
+       type="xygrid"
+       id="grid4526" />
+  </sodipodi:namedview>
+  <g
+     id="g873"
+     transform="matrix(0,1,1,0,-1,0)">
+    <rect
+       y="5.5"
+       x="7.5"
+       height="6"
+       width="6"
+       id="rect869"
+       
style="opacity:0.5;fill:#474747;fill-opacity:1;stroke:none;stroke-width:1.2544198;stroke-miterlimit:4;stroke-dasharray:none;stroke-opacity:1"
 />
+    <path
+       sodipodi:nodetypes="ssssssssscccccccccc"
+       inkscape:connector-curvature="0"
+       id="path4659-5"
+       d="M 15,6 C 15,5.057191 13.942809,4 13,4 H 2 C 1.057191,4 0,5.057191 0,6 v 5 c 0,0.942809 1.057191,2 
2,2 h 11 c 0.942809,0 2,-1.057191 2,-2 z m -2,0 v 5 H 8 V 6 Z M 7,6 v 5 H 2 V 6 Z"
+       
style="fill:#474747;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
 />
+  </g>
+</svg>
diff --git a/plugins/nintendo-ds/data/icons/view-bottom-screen-symbolic.svg 
b/plugins/nintendo-ds/data/icons/view-bottom-screen-symbolic.svg
new file mode 100644
index 00000000..fda93dbb
--- /dev/null
+++ b/plugins/nintendo-ds/data/icons/view-bottom-screen-symbolic.svg
@@ -0,0 +1,66 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<svg
+   xmlns:dc="http://purl.org/dc/elements/1.1/";
+   xmlns:cc="http://creativecommons.org/ns#";
+   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#";
+   xmlns:svg="http://www.w3.org/2000/svg";
+   xmlns="http://www.w3.org/2000/svg";
+   xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd";
+   xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape";
+   width="16"
+   height="16"
+   version="1.1"
+   id="svg8"
+   sodipodi:docname="6-bottom.svg"
+   inkscape:version="0.92.4 5da689c313, 2019-01-14">
+  <metadata
+     id="metadata14">
+    <rdf:RDF>
+      <cc:Work
+         rdf:about="">
+        <dc:format>image/svg+xml</dc:format>
+        <dc:type
+           rdf:resource="http://purl.org/dc/dcmitype/StillImage"; />
+        <dc:title></dc:title>
+      </cc:Work>
+    </rdf:RDF>
+  </metadata>
+  <defs
+     id="defs12" />
+  <sodipodi:namedview
+     pagecolor="#ffffff"
+     bordercolor="#666666"
+     borderopacity="1"
+     objecttolerance="10"
+     gridtolerance="10"
+     guidetolerance="10"
+     inkscape:pageopacity="0"
+     inkscape:pageshadow="2"
+     inkscape:window-width="1920"
+     inkscape:window-height="1016"
+     id="namedview10"
+     showgrid="true"
+     inkscape:zoom="32"
+     inkscape:cx="1.5549575"
+     inkscape:cy="8.7612104"
+     inkscape:window-x="0"
+     inkscape:window-y="27"
+     inkscape:window-maximized="1"
+     inkscape:current-layer="svg8">
+    <inkscape:grid
+       type="xygrid"
+       id="grid4526" />
+  </sodipodi:namedview>
+  <path
+     sodipodi:nodetypes="sccssccssscscccscscccs"
+     inkscape:connector-curvature="0"
+     id="path858"
+     d="m 9,1 c 0.942809,0 1.999979,1.057191 2,2 v 6 c 2.1e-5,0.942809 -1.057191,2 -2,2 H 3 C 2.057191,11 
1.000021,9.942809 1,9 V 3 C 0.999979,2.057191 2.057191,1 3,1 Z M 4,4 H 3 V 5 C 3,5.31 3.09025,5.552 
3.28125,5.75 L 6,8.4082031 8.71875,5.751953 C 8.90875,5.553953 9,5.311953 9,5.001953 v -1 H 8 c -0.257,0 
-0.52775,0.1295 -0.71875,0.3125 L 6,5.59375 4.71875,4.314453 C 4.52875,4.131453 4.257,4 4,4 Z"
+     
style="fill:#474747;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
 />
+  <path
+     inkscape:connector-curvature="0"
+     id="path818"
+     d="M 7,15 C 6.057191,15 5.000021,13.942809 5,13 v -1 h 2 v 1 h 6 V 7 H 12 V 5 h 1 c 0.942809,0 
1.999979,1.057191 2,2 v 6 c 2.1e-5,0.942809 -1.057191,2 -2,2 z"
+     
style="opacity:0.5;fill:#474747;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+     sodipodi:nodetypes="sccccccccsccss" />
+</svg>
diff --git a/plugins/nintendo-ds/data/icons/view-top-screen-symbolic.svg 
b/plugins/nintendo-ds/data/icons/view-top-screen-symbolic.svg
new file mode 100644
index 00000000..d9a3b696
--- /dev/null
+++ b/plugins/nintendo-ds/data/icons/view-top-screen-symbolic.svg
@@ -0,0 +1,66 @@
+<?xml version="1.0" encoding="UTF-8" standalone="no"?>
+<svg
+   xmlns:dc="http://purl.org/dc/elements/1.1/";
+   xmlns:cc="http://creativecommons.org/ns#";
+   xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#";
+   xmlns:svg="http://www.w3.org/2000/svg";
+   xmlns="http://www.w3.org/2000/svg";
+   xmlns:sodipodi="http://sodipodi.sourceforge.net/DTD/sodipodi-0.dtd";
+   xmlns:inkscape="http://www.inkscape.org/namespaces/inkscape";
+   width="16"
+   height="16"
+   version="1.1"
+   id="svg8"
+   sodipodi:docname="6-top.svg"
+   inkscape:version="0.92.4 5da689c313, 2019-01-14">
+  <metadata
+     id="metadata14">
+    <rdf:RDF>
+      <cc:Work
+         rdf:about="">
+        <dc:format>image/svg+xml</dc:format>
+        <dc:type
+           rdf:resource="http://purl.org/dc/dcmitype/StillImage"; />
+        <dc:title></dc:title>
+      </cc:Work>
+    </rdf:RDF>
+  </metadata>
+  <defs
+     id="defs12" />
+  <sodipodi:namedview
+     pagecolor="#ffffff"
+     bordercolor="#666666"
+     borderopacity="1"
+     objecttolerance="10"
+     gridtolerance="10"
+     guidetolerance="10"
+     inkscape:pageopacity="0"
+     inkscape:pageshadow="2"
+     inkscape:window-width="1920"
+     inkscape:window-height="1016"
+     id="namedview10"
+     showgrid="true"
+     inkscape:zoom="32"
+     inkscape:cx="1.5549575"
+     inkscape:cy="8.7612104"
+     inkscape:window-x="0"
+     inkscape:window-y="27"
+     inkscape:window-maximized="1"
+     inkscape:current-layer="svg8">
+    <inkscape:grid
+       type="xygrid"
+       id="grid4526" />
+  </sodipodi:namedview>
+  <path
+     sodipodi:nodetypes="sccssccssscscccscscccs"
+     inkscape:connector-curvature="0"
+     id="path858"
+     d="M 7,15 C 6.057191,15 5.000021,13.942809 5,13 V 7 C 4.999979,6.057191 6.057191,4.9999999 7,4.9999999 
h 6 c 0.942809,0 1.999979,1.0571911 2,2.0000001 v 6 c 2.1e-5,0.942809 -1.057191,2 -2,2 z m 5,-3 h 1 v -1 c 
0,-0.31 -0.09025,-0.552 -0.28125,-0.75 L 10,7.5917969 7.28125,10.248047 c -0.19,0.198 -0.28125,0.44 
-0.28125,0.75 v 1 h 1 c 0.257,0 0.52775,-0.1295 0.71875,-0.3125 L 10,10.40625 11.28125,11.685547 C 
11.47125,11.868547 11.743,12 12,12 Z"
+     
style="fill:#474747;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
 />
+  <path
+     inkscape:connector-curvature="0"
+     id="path818"
+     d="m 9,1 c 0.942809,0 1.999979,1.057191 2,2 V 4 H 9 V 3 H 3 v 6 h 1 v 2 H 3 C 2.057191,11 
1.000021,9.942809 1,9 V 3 C 0.999979,2.057191 2.057191,1 3,1 Z"
+     
style="opacity:0.5;fill:#474747;fill-opacity:1;stroke:none;stroke-width:1px;stroke-linecap:butt;stroke-linejoin:miter;stroke-opacity:1"
+     sodipodi:nodetypes="sccccccccsccss" />
+</svg>
diff --git a/plugins/nintendo-ds/data/meson.build b/plugins/nintendo-ds/data/meson.build
index 007c8981..0100e094 100644
--- a/plugins/nintendo-ds/data/meson.build
+++ b/plugins/nintendo-ds/data/meson.build
@@ -1,5 +1,11 @@
 install_data (plugin_name + '.plugin', install_dir: plugins_dir)
 
+nintendo_ds_resources = gnome.compile_resources (
+  'nintendo-ds',
+  'nintendo-ds.gresource.xml',
+  c_name: 'resources'
+)
+
 configure_file (
   input: 'org.gnome.Games.plugins.nintendo-ds.gschema.xml',
   output: 'org.gnome.Games.plugins.nintendo-ds.gschema.xml',
diff --git a/plugins/nintendo-ds/data/nintendo-ds.gresource.xml 
b/plugins/nintendo-ds/data/nintendo-ds.gresource.xml
new file mode 100644
index 00000000..135d986e
--- /dev/null
+++ b/plugins/nintendo-ds/data/nintendo-ds.gresource.xml
@@ -0,0 +1,13 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<gresources>
+  <gresource prefix="/org/gnome/Games/plugins/nintendo-ds">
+    <file>ui/nintendo-ds-layout-item.ui</file>
+    <file>ui/nintendo-ds-layout-switcher.ui</file>
+    <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>
+  </gresource>
+</gresources>
diff --git a/plugins/nintendo-ds/data/ui/nintendo-ds-layout-item.ui 
b/plugins/nintendo-ds/data/ui/nintendo-ds-layout-item.ui
new file mode 100644
index 00000000..8c622571
--- /dev/null
+++ b/plugins/nintendo-ds/data/ui/nintendo-ds-layout-item.ui
@@ -0,0 +1,45 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+  <requires lib="gtk+" version="3.16"/>
+  <template class="GamesNintendoDsLayoutItem" parent="GtkListBoxRow">
+    <property name="visible">True</property>
+    <child>
+      <object class="GtkBox">
+        <property name="visible">True</property>
+        <property name="margin">6</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>
+        <child>
+          <object class="GtkBox">
+            <property name="visible">True</property>
+            <property name="orientation">vertical</property>
+            <property name="valign">center</property>
+            <child>
+              <object class="GtkLabel" id="title">
+                <property name="visible">True</property>
+                <property name="halign">start</property>
+              </object>
+            </child>
+            <child>
+              <object class="GtkLabel" id="subtitle">
+                <property name="visible">False</property>
+                <property name="halign">start</property>
+                <style>
+                  <class name="dim-label"/>
+                </style>
+              </object>
+            </child>
+          </object>
+        </child>
+      </object>
+    </child>
+  </template>
+</interface>
diff --git a/plugins/nintendo-ds/data/ui/nintendo-ds-layout-switcher.ui 
b/plugins/nintendo-ds/data/ui/nintendo-ds-layout-switcher.ui
new file mode 100644
index 00000000..9c256351
--- /dev/null
+++ b/plugins/nintendo-ds/data/ui/nintendo-ds-layout-switcher.ui
@@ -0,0 +1,76 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+  <requires lib="gtk+" version="3.16"/>
+  <template class="GamesNintendoDsLayoutSwitcher" parent="GtkBox">
+    <property name="visible">True</property>
+
+    <child>
+      <object class="GtkRevealer" id="change_screen_revealer">
+        <property name="visible">True</property>
+        <property name="transition-type">slide-left</property>
+        <child>
+          <object class="GtkButton">
+            <property name="visible">True</property>
+            <property name="can-focus">False</property>
+            <property name="margin-right">6</property>
+            <signal name="clicked" handler="on_screen_changed"/>
+            <child internal-child="accessible">
+              <object class="AtkObject">
+                <property name="accessible-name" translatable="yes">Change Screen</property>
+              </object>
+            </child>
+            <child>
+              <object class="GtkImage" id="change_screen_image">
+                <property name="visible">True</property>
+              </object>
+            </child>
+           </object>
+        </child>
+      </object>
+    </child>
+    <child>
+      <object class="GtkMenuButton">
+        <property name="visible">True</property>
+        <property name="can-focus">False</property>
+        <property name="popover">layout_popover</property>
+          <child internal-child="accessible">
+          <object class="AtkObject" id="a11y-display-discs">
+            <property name="accessible-name" translatable="yes">Screen Layout</property>
+          </object>
+        </child>
+        <child>
+          <object class="GtkBox">
+            <property name="visible">True</property>
+            <property name="spacing">6</property>
+            <child>
+              <object class="GtkImage" id="layout_image">
+                <property name="visible">True</property>
+              </object>
+            </child>
+            <child>
+              <object class="GtkImage">
+                <property name="visible">True</property>
+                <property name="icon-name">pan-down-symbolic</property>
+              </object>
+            </child>
+          </object>
+        </child>
+      </object>
+    </child>
+  </template>
+  <object class="GtkPopover" id="layout_popover">
+    <property name="visible">False</property>
+    <child>
+      <object class="GtkFrame">
+        <property name="visible">True</property>
+        <property name="margin">6</property>
+        <child>
+          <object class="GtkListBox" id="list_box">
+            <property name="visible">True</property>
+            <signal name="row-activated" handler="on_row_activated"/>
+          </object>
+        </child>
+      </object>
+    </child>
+  </object>
+</interface>
diff --git a/plugins/nintendo-ds/src/meson.build b/plugins/nintendo-ds/src/meson.build
index 0313ac92..a8713655 100644
--- a/plugins/nintendo-ds/src/meson.build
+++ b/plugins/nintendo-ds/src/meson.build
@@ -1,5 +1,7 @@
 vala_sources = [
   'nintendo-ds-icon.vala',
+  'nintendo-ds-layout-item.vala',
+  'nintendo-ds-layout-switcher.vala',
   'nintendo-ds-plugin.vala',
 ]
 
@@ -13,7 +15,7 @@ c_args = [
 
 shared_module (
   'games-' + plugin_name + '-plugin',
-  vala_sources + c_sources,
+  vala_sources + c_sources + nintendo_ds_resources,
   dependencies: gnome_games_dep,
   c_args: c_args,
   install: true,
diff --git a/plugins/nintendo-ds/src/nintendo-ds-layout-item.vala 
b/plugins/nintendo-ds/src/nintendo-ds-layout-item.vala
new file mode 100644
index 00000000..34837291
--- /dev/null
+++ b/plugins/nintendo-ds/src/nintendo-ds-layout-item.vala
@@ -0,0 +1,29 @@
+// This file is part of GNOME Games. License: GPL-3.0+.
+
+[GtkTemplate (ui = "/org/gnome/Games/plugins/nintendo-ds/ui/nintendo-ds-layout-item.ui")]
+private class Games.NintendoDsLayoutItem : Gtk.ListBoxRow {
+       [GtkChild]
+       private Gtk.Image icon;
+       [GtkChild]
+       private Gtk.Label title;
+       [GtkChild]
+       private Gtk.Label subtitle;
+
+       private string layout;
+
+       public NintendoDsLayoutItem (string layout, string title, string? subtitle, string icon) {
+               this.layout = layout;
+
+               this.icon.icon_name = icon;
+               this.title.label = title;
+
+               if (subtitle != null) {
+                       this.subtitle.label = subtitle;
+                       this.subtitle.show ();
+               }
+       }
+
+       public string get_layout () {
+               return layout;
+       }
+}
diff --git a/plugins/nintendo-ds/src/nintendo-ds-layout-switcher.vala 
b/plugins/nintendo-ds/src/nintendo-ds-layout-switcher.vala
new file mode 100644
index 00000000..aa313279
--- /dev/null
+++ b/plugins/nintendo-ds/src/nintendo-ds-layout-switcher.vala
@@ -0,0 +1,126 @@
+// This file is part of GNOME Games. License: GPL-3.0+.
+
+[GtkTemplate (ui = "/org/gnome/Games/plugins/nintendo-ds/ui/nintendo-ds-layout-switcher.ui")]
+private class Games.NintendoDsLayoutSwitcher : Gtk.Box {
+       [GtkChild]
+       private Gtk.Revealer change_screen_revealer;
+       [GtkChild]
+       private Gtk.Image change_screen_image;
+       [GtkChild]
+       private Gtk.Image layout_image;
+       [GtkChild]
+       private Gtk.Popover layout_popover;
+       [GtkChild]
+       private Gtk.ListBox list_box;
+
+       private Settings settings;
+       private HashTable<string, NintendoDsLayoutItem> items;
+
+       private string[] LAYOUTS = {
+               "top/bottom",
+               "left/right",
+               "right/left",
+               "quick switch",
+       };
+
+       static construct {
+               var icon_theme = Gtk.IconTheme.get_default ();
+               icon_theme.add_resource_path ("/org/gnome/Games/plugins/nintendo-ds/icons");
+       }
+
+       construct {
+               items = new HashTable<string, NintendoDsLayoutItem> (str_hash, str_equal);
+               foreach (string layout in LAYOUTS) {
+                       string icon = get_layout_icon (layout);
+                       string title = get_layout_title (layout);
+                       string subtitle = get_layout_subtitle (layout);
+
+                       var item = new NintendoDsLayoutItem (layout, title, subtitle, icon);
+                       items[layout] = item;
+
+                       list_box.add (item);
+               }
+
+               settings = new Settings ("org.gnome.Games.plugins.nintendo-ds");
+               settings.changed.connect (update_ui);
+
+               layout_popover.show.connect (update_ui);
+
+               update_ui ();
+       }
+
+       private void update_ui () {
+               var layout = settings.get_string ("screen-layout");
+               var view_bottom = settings.get_boolean ("view-bottom-screen");
+
+               layout_image.icon_name = get_layout_icon (layout);
+
+               var item = items[layout];
+               list_box.select_row (item);
+
+               change_screen_revealer.reveal_child = (layout == "quick switch");
+               change_screen_image.icon_name = view_bottom ? "view-top-screen-symbolic" : 
"view-bottom-screen-symbolic-symbolic";
+       }
+
+       [GtkCallback]
+       private void on_screen_changed (Gtk.Button button) {
+               var view_bottom = settings.get_boolean ("view-bottom-screen");
+
+               settings.set_boolean ("view-bottom-screen", !view_bottom);
+       }
+
+       [GtkCallback]
+       private void on_row_activated (Gtk.ListBoxRow row) {
+               var layout_item = row as NintendoDsLayoutItem;
+
+               var layout = layout_item.get_layout ();
+
+               settings.set_string ("screen-layout", layout);
+       }
+
+       private string get_layout_icon (string layout) {
+               switch (layout) {
+               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";
+               }
+
+               return "video-display-symbolic";
+       }
+
+       private string get_layout_title (string layout) {
+               switch (layout) {
+               case "top/bottom":
+                       return _("Vertical");
+
+               case "left/right":
+               case "right/left":
+                       return _("Side by side");
+
+               case "quick switch":
+                       return _("Single screen");
+               }
+
+               return _("Unknown");
+       }
+
+       private string? get_layout_subtitle (string layout) {
+               switch (layout) {
+               case "left/right":
+                       return _("Bottom to the right");
+
+               case "right/left":
+                       return _("Bottom to the left");
+               }
+
+               return null;
+       }
+}


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