[gnome-games] ui: Introduce CollectionIconView



commit a42c7c1a5806b2bdd7005dfee2945c7f2fd3bbd7
Author: Neville <nevilleantony98 gmail com>
Date:   Thu Jun 18 21:12:43 2020 +0530

    ui: Introduce CollectionIconView
    
    This is will be used to display Collection in a CollectionsPage.
    Similar to a GameIconView it has a title and and a thumbnail.
    
    The thumbnail used here is a temporary GtkImage placeholder which will be
    replaced later on.

 data/org.gnome.Games.gresource.xml |  1 +
 data/ui/collection-icon-view.ui    | 37 +++++++++++++++++++++++++++++++++++++
 src/meson.build                    |  1 +
 src/ui/collection-icon-view.vala   | 22 ++++++++++++++++++++++
 4 files changed, 61 insertions(+)
---
diff --git a/data/org.gnome.Games.gresource.xml b/data/org.gnome.Games.gresource.xml
index c8d68589..4d96e95e 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/collection-icon-view.ui</file>
     <file preprocess="xml-stripblanks">ui/collection-view.ui</file>
     <file preprocess="xml-stripblanks">ui/display-view.ui</file>
     <file preprocess="xml-stripblanks">ui/empty-collection.ui</file>
diff --git a/data/ui/collection-icon-view.ui b/data/ui/collection-icon-view.ui
new file mode 100644
index 00000000..e62a1120
--- /dev/null
+++ b/data/ui/collection-icon-view.ui
@@ -0,0 +1,37 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+  <requires lib="gtk+" version="3.24"/>
+  <template class="GamesCollectionIconView" parent="GtkFlowBoxChild">
+    <property name="visible">True</property>
+      <child>
+        <object class="GtkBox">
+          <property name="visible">True</property>
+          <property name="orientation">vertical</property>
+          <property name="spacing">6</property>
+          <child>
+            <object class="GtkImage">
+              <property name="visible">True</property>
+              <property name="icon-name">starred-symbolic</property>
+              <property name="halign">center</property>
+              <property name="valign">center</property>
+              <property name="pixel-size">64</property>
+              <style>
+                <class name="favorite-placeholder"/>
+              </style>
+            </object>
+          </child>
+          <child>
+            <object class="GtkLabel" id="title">
+              <property name="visible">True</property>
+              <property name="ellipsize">middle</property>
+              <property name="justify">center</property>
+              <property name="lines">2</property>
+              <property name="max-width-chars">0</property>
+              <property name="wrap">True</property>
+              <property name="wrap-mode">word-char</property>
+            </object>
+          </child>
+        </object>
+      </child>
+  </template>
+</interface>
diff --git a/src/meson.build b/src/meson.build
index a650d167..598827f8 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -109,6 +109,7 @@ vala_sources = [
   'ui/application.vala',
   'ui/application-window.vala',
   'ui/checkmark-item.vala',
+  'ui/collection-icon-view.vala',
   'ui/collection-view.vala',
   'ui/display-bin.vala',
   'ui/display-view.vala',
diff --git a/src/ui/collection-icon-view.vala b/src/ui/collection-icon-view.vala
new file mode 100644
index 00000000..900352ef
--- /dev/null
+++ b/src/ui/collection-icon-view.vala
@@ -0,0 +1,22 @@
+// This file is part of GNOME Games. License: GPL-3.0+.
+
+[GtkTemplate (ui = "/org/gnome/Games/ui/collection-icon-view.ui")]
+private class Games.CollectionIconView : Gtk.FlowBoxChild {
+       [GtkChild]
+       private Gtk.Label title;
+
+       private Collection _collection;
+       public Collection collection {
+               get { return _collection; }
+               construct set {
+                       _collection = value;
+
+                       title.label = collection.get_title ();
+                       thumbnail.collection = collection;
+               }
+       }
+
+       public CollectionIconView (Collection collection) {
+               Object (collection: collection);
+       }
+}


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