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



commit 2283743992570ee36feb1110e6f1380f4c4369b8
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 2691ba7e..fe735478 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 c04ac402..f2499e65 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -131,6 +131,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]