[gnome-games/wip/exalm/platform-preferences: 34/36] ui: Add PreferencesPageRetroPlatform
- From: Alexander Mikhaylenko <alexm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-games/wip/exalm/platform-preferences: 34/36] ui: Add PreferencesPageRetroPlatform
- Date: Mon, 7 Jan 2019 15:37:31 +0000 (UTC)
commit 4b85d84c1437893a53850d90b4d1e29f91290806
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 | 20 +++++++++
po/POTFILES.in | 1 +
src/meson.build | 1 +
src/ui/preferences-page-retro-platform.vala | 64 +++++++++++++++++++++++++++++
5 files changed, 87 insertions(+)
---
diff --git a/data/org.gnome.Games.gresource.xml b/data/org.gnome.Games.gresource.xml
index 33405834..cb1865b2 100644
--- a/data/org.gnome.Games.gresource.xml
+++ b/data/org.gnome.Games.gresource.xml
@@ -38,6 +38,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..b943261d
--- /dev/null
+++ b/data/ui/preferences-page-retro-platform.ui
@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+ <!-- interface-requires gtk+ 3.16 -->
+ <template class="GamesPreferencesPageRetroPlatform" parent="GamesPreferencesPage">
+ <property name="visible">True</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>
+ <signal name="row-activated" handler="core_list_box_row_activated"/>
+ </object>
+ </child>
+ </object>
+ </child>
+ </template>
+</interface>
diff --git a/po/POTFILES.in b/po/POTFILES.in
index 5c605716..a56284e2 100644
--- a/po/POTFILES.in
+++ b/po/POTFILES.in
@@ -15,6 +15,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 9f4d114e..3333a33a 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -166,6 +166,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..43d2929d
--- /dev/null
+++ b/src/ui/preferences-page-retro-platform.vala
@@ -0,0 +1,64 @@
+// 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: PreferencesPage {
+ public RetroPlatform platform { get; construct set; }
+
+ [GtkChild]
+ private Gtk.ListBox core_list_box;
+
+ private Settings settings;
+
+ private string _current_core;
+ public string current_core {
+ get { return _current_core; }
+ set {
+ _current_core = value;
+
+ update_core_list ();
+ }
+ }
+
+ public PreferencesPageRetroPlatform (RetroPlatform platform) {
+ this.platform = platform;
+ title = platform.get_name ();
+ category = PreferencesPageCategory.PLATFORMS;
+
+ build_core_list ();
+
+ var path = "/org/gnome/Games/platforms/%s/".printf (platform.get_id ());
+ settings = new Settings.with_path ("org.gnome.Games.platforms", path);
+
+ settings.bind ("libretro-core", this, "current-core",
+ SettingsBindFlags.DEFAULT);
+ }
+
+ private void build_core_list () {
+ var core_manager = new RetroCoreManager ();
+ var core_descriptors = core_manager.get_cores_for_platform (platform);
+
+ foreach (var core_descriptor in core_descriptors) {
+ var item = new CoreItem (core_descriptor);
+ core_list_box.add (item);
+ }
+ }
+
+ private void update_core_list () {
+ core_list_box.foreach ((item) => {
+ var core_item = item as CoreItem;
+ var core_descriptor = core_item.core_descriptor;
+ var core_id = core_descriptor.get_id ();
+
+ core_item.checkmark_visible = (core_id == current_core);
+ });
+ }
+
+ [GtkCallback]
+ private void core_list_box_row_activated (Gtk.ListBoxRow row_item) {
+ var core_item = row_item as CoreItem;
+
+ var core_descriptor = core_item.core_descriptor;
+
+ current_core = core_descriptor.get_id ();
+ }
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]