[gnome-games/wip/exalm/platform-preferences: 19/30] ui: Add CoreItem



commit 23b10eb21df6b876bf846634ea2b53bc1100e3cd
Author: Alexander Mikhaylenko <exalm7659 gmail com>
Date:   Thu Sep 27 12:55:21 2018 +0500

    ui: Add CoreItem

 data/org.gnome.Games.gresource.xml |  1 +
 data/ui/core-item.ui               | 30 ++++++++++++++++++++++++++++++
 src/meson.build                    |  1 +
 src/ui/core-item.vala              | 29 +++++++++++++++++++++++++++++
 4 files changed, 61 insertions(+)
---
diff --git a/data/org.gnome.Games.gresource.xml b/data/org.gnome.Games.gresource.xml
index 7d3f8ecb..33405834 100644
--- a/data/org.gnome.Games.gresource.xml
+++ b/data/org.gnome.Games.gresource.xml
@@ -12,6 +12,7 @@
     <file preprocess="xml-stripblanks">gesture/stick-symbolic.svg</file>
     <file preprocess="xml-stripblanks">ui/application-window.ui</file>
     <file preprocess="xml-stripblanks">ui/checkmark-item.ui</file>
+    <file preprocess="xml-stripblanks">ui/core-item.ui</file>
     <file preprocess="xml-stripblanks">ui/collection-box.ui</file>
     <file preprocess="xml-stripblanks">ui/collection-header-bar.ui</file>
     <file preprocess="xml-stripblanks">ui/collection-icon-view.ui</file>
diff --git a/data/ui/core-item.ui b/data/ui/core-item.ui
new file mode 100644
index 00000000..ac5edef5
--- /dev/null
+++ b/data/ui/core-item.ui
@@ -0,0 +1,30 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+  <template class="GamesCoreItem" parent="GtkListBoxRow">
+    <property name="visible">true</property>
+    <child>
+      <object class="GtkBox">
+        <property name="visible">true</property>
+        <property name="margin">6</property>
+        <property name="spacing">12</property>
+        <child>
+          <object class="GtkLabel" id="title_label">
+            <property name="visible">true</property>
+            <property name="vexpand">true</property>
+            <property name="wrap">true</property>
+          </object>
+        </child>
+        <child>
+          <object class="GtkImage" id="checkmark_image">
+            <property name="visible">False</property>
+            <property name="icon-name">object-select-symbolic</property>
+            <property name="valign">center</property>
+          </object>
+          <packing>
+            <property name="pack-type">end</property>
+          </packing>
+        </child>
+      </object>
+    </child>
+  </template>
+</interface>
diff --git a/src/meson.build b/src/meson.build
index e34bf632..86005f68 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -132,6 +132,7 @@ vala_sources = [
   'ui/collection-box.vala',
   'ui/collection-icon-view.vala',
   'ui/collection-header-bar.vala',
+  'ui/core-item.vala',
   'ui/developer-list-item.vala',
   'ui/developers-view.vala',
   'ui/display-box.vala',
diff --git a/src/ui/core-item.vala b/src/ui/core-item.vala
new file mode 100644
index 00000000..d775df3e
--- /dev/null
+++ b/src/ui/core-item.vala
@@ -0,0 +1,29 @@
+// This file is part of GNOME Games. License: GPL-3.0+.
+
+[GtkTemplate (ui = "/org/gnome/Games/ui/core-item.ui")]
+private class Games.CoreItem: Gtk.ListBoxRow {
+       [GtkChild]
+       private Gtk.Label title_label;
+       [GtkChild]
+       private Gtk.Image checkmark_image;
+
+       public Retro.CoreDescriptor core_descriptor;
+
+       public bool checkmark_visible { get; set; }
+       private Binding checkmark_visible_binding;
+
+       public CoreItem (Retro.CoreDescriptor core_descriptor) {
+               this.core_descriptor = core_descriptor;
+               try {
+                       title_label.label = core_descriptor.get_name ();
+               }
+               catch (Error e) {
+                       critical ("Cannot get core name: %s", e.message);
+               }
+       }
+
+       construct {
+               checkmark_visible_binding = bind_property ("checkmark-visible", checkmark_image, "visible",
+                                                          BindingFlags.DEFAULT);
+       }
+}


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