[gnome-games/wip/exalm/ds: 3/9] nintendo-ds: Add NintendoDsLayout
- From: Alexander Mikhaylenko <alexm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-games/wip/exalm/ds: 3/9] nintendo-ds: Add NintendoDsLayout
- Date: Tue, 13 Aug 2019 23:35:07 +0000 (UTC)
commit 1b0267d32a964de7def59d4870babdb63e460952
Author: Alexander Mikhaylenko <exalm7659 gmail com>
Date: Wed Aug 14 01:12:39 2019 +0500
nintendo-ds: Add NintendoDsLayout
This will be used for passing layouts around later when GSettings aren't
used anymore.
plugins/nintendo-ds/src/meson.build | 1 +
plugins/nintendo-ds/src/nintendo-ds-layout.vala | 106 ++++++++++++++++++++++++
2 files changed, 107 insertions(+)
---
diff --git a/plugins/nintendo-ds/src/meson.build b/plugins/nintendo-ds/src/meson.build
index ebf3cefe..b3c84613 100644
--- a/plugins/nintendo-ds/src/meson.build
+++ b/plugins/nintendo-ds/src/meson.build
@@ -1,5 +1,6 @@
vala_sources = [
'nintendo-ds-icon.vala',
+ 'nintendo-ds-layout.vala',
'nintendo-ds-layout-item.vala',
'nintendo-ds-layout-switcher.vala',
'nintendo-ds-plugin.vala',
diff --git a/plugins/nintendo-ds/src/nintendo-ds-layout.vala b/plugins/nintendo-ds/src/nintendo-ds-layout.vala
new file mode 100644
index 00000000..5dc902c8
--- /dev/null
+++ b/plugins/nintendo-ds/src/nintendo-ds-layout.vala
@@ -0,0 +1,106 @@
+// 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) {
+ case TOP_BOTTOM:
+ return "top/bottom";
+
+ case LEFT_RIGHT:
+ return "left/right";
+
+ case RIGHT_LEFT:
+ return "right/left";
+
+ case QUICK_SWITCH:
+ return "quick switch";
+
+ default:
+ assert_not_reached ();
+ }
+ }
+
+ 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:
+ return _("Vertical");
+
+ case LEFT_RIGHT:
+ return _("Side by side");
+
+ case RIGHT_LEFT:
+ return _("Side by side");
+
+ case QUICK_SWITCH:
+ return _("Single screen");
+
+ default:
+ assert_not_reached ();
+ }
+ }
+
+ public string? get_subtitle () {
+ switch (this) {
+ case LEFT_RIGHT:
+ return _("Bottom to the right");
+
+ case RIGHT_LEFT:
+ 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 };
+ }
+
+ public static NintendoDsLayout? from_value (string value) {
+ switch (value) {
+ case "top/bottom":
+ return TOP_BOTTOM;
+
+ case "left/right":
+ return LEFT_RIGHT;
+
+ case "right/left":
+ return RIGHT_LEFT;
+
+ case "quick switch":
+ return QUICK_SWITCH;
+
+ default:
+ warning ("Unknown screen layout: %s\n", value);
+ return null;
+ }
+ }
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]