[gnome-games/wip/exalm/platform-preferences: 71/76] preferences-page-retro-platform: List cores
- From: Alexander Mikhaylenko <alexm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-games/wip/exalm/platform-preferences: 71/76] preferences-page-retro-platform: List cores
- Date: Tue, 1 Jan 2019 18:16:51 +0000 (UTC)
commit 4d301d013e1f95045ef78eb4208c09a12fffeaa5
Author: Alexander Mikhaylenko <exalm7659 gmail com>
Date: Thu Sep 27 15:49:47 2018 +0500
preferences-page-retro-platform: List cores
data/ui/preferences-page-retro-platform.ui | 1 +
src/ui/preferences-page-retro-platform.vala | 46 ++++++++++++++++++++++++-----
2 files changed, 39 insertions(+), 8 deletions(-)
---
diff --git a/data/ui/preferences-page-retro-platform.ui b/data/ui/preferences-page-retro-platform.ui
index 83841200..b943261d 100644
--- a/data/ui/preferences-page-retro-platform.ui
+++ b/data/ui/preferences-page-retro-platform.ui
@@ -11,6 +11,7 @@
<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>
diff --git a/src/ui/preferences-page-retro-platform.vala b/src/ui/preferences-page-retro-platform.vala
index e2ee08b4..d20afe82 100644
--- a/src/ui/preferences-page-retro-platform.vala
+++ b/src/ui/preferences-page-retro-platform.vala
@@ -7,6 +7,18 @@ private class Games.PreferencesPageRetroPlatform: PreferencesPage {
[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 ();
+ }
+ }
+
private static Retro.CoreDescriptor[] core_descriptors;
static construct {
@@ -22,6 +34,12 @@ private class Games.PreferencesPageRetroPlatform: PreferencesPage {
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 () {
@@ -50,15 +68,27 @@ private class Games.PreferencesPageRetroPlatform: PreferencesPage {
}
}
- private void add_core_descriptor (Retro.CoreDescriptor core_descriptor) throws Error {
- var name = core_descriptor.get_name ();
+ 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);
+ });
+ }
+
+ private void add_core_descriptor (Retro.CoreDescriptor core_descriptor) {
+ var item = new CoreItem (core_descriptor);
+ core_list_box.add (item);
+ }
+
+ [GtkCallback]
+ private void core_list_box_row_activated (Gtk.ListBoxRow row_item) {
+ var core_item = row_item as CoreItem;
- var item = new CheckmarkItem (name);
- var row = new Gtk.ListBoxRow ();
- row.add (item);
- core_list_box.add (row);
+ var core_descriptor = core_item.core_descriptor;
- item.show ();
- row.show ();
+ current_core = core_descriptor.get_id ();
}
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]