[gnome-games/wip/exalm/platform-preferences: 20/26] ui: Add PreferencesPageRetroPlatform



commit 798162327042d5782585bf54f4987be167a0eeab
Author: Alexander Mikhaylenko <exalm7659 gmail com>
Date:   Tue Sep 25 23:08:16 2018 +0500

    ui: Add PreferencesPageRetroPlatform

 data/org.gnome.Games.gresource.xml          |  1 +
 data/ui/preferences-page-retro-platform.ui  | 46 ++++++++++++++++++++
 po/POTFILES.in                              |  1 +
 src/meson.build                             |  1 +
 src/ui/preferences-page-retro-platform.vala | 66 +++++++++++++++++++++++++++++
 5 files changed, 115 insertions(+)
---
diff --git a/data/org.gnome.Games.gresource.xml b/data/org.gnome.Games.gresource.xml
index fe735478..c22af35e 100644
--- a/data/org.gnome.Games.gresource.xml
+++ b/data/org.gnome.Games.gresource.xml
@@ -35,6 +35,7 @@
     <file preprocess="xml-stripblanks">ui/preferences-page-dummy-platform.ui</file>
     <file preprocess="xml-stripblanks">ui/preferences-page-plugins.ui</file>
     <file preprocess="xml-stripblanks">ui/preferences-page-plugins-item.ui</file>
+    <file preprocess="xml-stripblanks">ui/preferences-page-retro-platform.ui</file>
     <file preprocess="xml-stripblanks">ui/preferences-page-video.ui</file>
     <file preprocess="xml-stripblanks">ui/preferences-sidebar.ui</file>
     <file preprocess="xml-stripblanks">ui/preferences-sidebar-item.ui</file>
diff --git a/data/ui/preferences-page-retro-platform.ui b/data/ui/preferences-page-retro-platform.ui
new file mode 100644
index 00000000..ae6c9a78
--- /dev/null
+++ b/data/ui/preferences-page-retro-platform.ui
@@ -0,0 +1,46 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+  <!-- interface-requires gtk+ 3.16 -->
+  <template class="GamesPreferencesPageRetroPlatform" parent="GtkBin">
+    <property name="visible">True</property>
+    <child>
+      <object class="GtkScrolledWindow">
+        <property name="visible">true</property>
+        <property name="hscrollbar-policy">never</property>
+        <child>
+          <object class="GtkViewport">
+            <property name="visible">true</property>
+            <child>
+              <object class="HdyColumn">
+                <property name="visible">True</property>
+                <property name="expand">True</property>
+                <property name="maximum_width">600</property>
+                <property name="linear-growth-width">300</property>
+                <child>
+                  <object class="GtkBox">
+                    <property name="visible">True</property>
+                    <property name="orientation">vertical</property>
+                    <property name="margin">12</property>
+                    <property name="spacing">12</property>
+                    <child>
+                      <object class="GtkFrame">
+                        <property name="visible">true</property>
+                        <property name="shadow-type">in</property>
+                        <child>
+                          <object class="GtkListBox" id="core_list_box">
+                            <property name="selection-mode">none</property>
+                            <property name="visible">true</property>
+                          </object>
+                        </child>
+                      </object>
+                    </child>
+                  </object>
+                </child>
+              </object>
+            </child>
+          </object>
+        </child>
+      </object>
+    </child>
+  </template>
+</interface>
diff --git a/po/POTFILES.in b/po/POTFILES.in
index c4aa492b..6140e3ec 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -14,6 +14,7 @@ data/ui/media-menu-button.ui
 data/ui/preferences-page-controllers.ui
 data/ui/preferences-page-dummy-platform.ui
 data/ui/preferences-page-plugins.ui
+data/ui/preferences-page-retro-platform.ui
 data/ui/preferences-page-video.ui
 data/ui/preferences-subpage-gamepad.ui
 data/ui/preferences-subpage-keyboard.ui
diff --git a/src/meson.build b/src/meson.build
index f2499e65..29887433 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -161,6 +161,7 @@ vala_sources = [
   'ui/preferences-page-dummy-platform.vala',
   'ui/preferences-page-plugins.vala',
   'ui/preferences-page-plugins-item.vala',
+  'ui/preferences-page-retro-platform.vala',
   'ui/preferences-page-video.vala',
   'ui/preferences-sidebar.vala',
   'ui/preferences-sidebar-item.vala',
diff --git a/src/ui/preferences-page-retro-platform.vala b/src/ui/preferences-page-retro-platform.vala
new file mode 100644
index 00000000..192e00e9
--- /dev/null
+++ b/src/ui/preferences-page-retro-platform.vala
@@ -0,0 +1,66 @@
+// This file is part of GNOME Games. License: GPL-3.0+.
+
+[GtkTemplate (ui = "/org/gnome/Games/ui/preferences-page-retro-platform.ui")]
+private class Games.PreferencesPageRetroPlatform: Gtk.Bin, PreferencesPage {
+       public RetroPlatform platform { get; construct set; }
+
+       public PreferencesSubpage subpage { get; protected set; }
+
+       private string _title;
+       public string title {
+               get { return _title; }
+       }
+
+       public PreferencesPageCategory category {
+               get { return PreferencesPageCategory.PLATFORMS; }
+       }
+
+       [GtkChild]
+       private Gtk.ListBox core_list_box;
+
+       public PreferencesPageRetroPlatform (RetroPlatform platform) {
+               this.platform = platform;
+               _title = platform.get_name ();
+
+               build_core_list ();
+       }
+
+       private void build_core_list () {
+               var modules = new Retro.ModuleQuery (true);
+               foreach (var core_descriptor in modules) {
+                       try {
+                               var platform_id = platform.get_id ();
+                               var mime_types = platform.get_mime_types ();
+
+                               if (!core_descriptor.get_is_emulator ())
+                                       continue;
+
+                               if (!core_descriptor.has_platform (platform_id))
+                                       continue;
+
+                               if (!core_descriptor.get_platform_supports_mime_types (platform_id, 
mime_types))
+                                       continue;
+
+                               if (core_descriptor.get_module_file () == null)
+                                       continue;
+
+                               add_core_descriptor (core_descriptor);
+                       }
+                       catch (Error e) {
+                               debug (e.message);
+                       }
+               }
+       }
+
+       private void add_core_descriptor (Retro.CoreDescriptor core_descriptor) throws Error {
+               var name = core_descriptor.get_name ();
+
+               var item = new CheckmarkItem (name);
+               var row = new Gtk.ListBoxRow ();
+               row.add (item);
+               core_list_box.add (row);
+
+               item.show ();
+               row.show ();
+       }
+}


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