[gnome-games/wip/exalm/views: 2/17] ui: Add CollectionView



commit 817f99cb6abc03c6b334f02114e8916c76466a76
Author: Alexander Mikhaylenko <exalm7659 gmail com>
Date:   Thu Oct 4 13:49:35 2018 +0500

    ui: Add CollectionView
    
    This will be used in the subsequent commits to move collection logic out
    of ApplicationWindow.
    
    Make 'box' and '_header_bar' public temporarily, until their references in
    ApplicationWindow are removed.

 data/org.gnome.Games.gresource.xml |  1 +
 data/ui/collection-view.ui         | 18 ++++++++++
 src/meson.build                    |  1 +
 src/ui/collection-view.vala        | 70 ++++++++++++++++++++++++++++++++++++++
 4 files changed, 90 insertions(+)
---
diff --git a/data/org.gnome.Games.gresource.xml b/data/org.gnome.Games.gresource.xml
index b9f080cb..cf9c30a3 100644
--- a/data/org.gnome.Games.gresource.xml
+++ b/data/org.gnome.Games.gresource.xml
@@ -15,6 +15,7 @@
     <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>
+    <file preprocess="xml-stripblanks">ui/collection-view.ui</file>
     <file preprocess="xml-stripblanks">ui/developer-list-item.ui</file>
     <file preprocess="xml-stripblanks">ui/display-box.ui</file>
     <file preprocess="xml-stripblanks">ui/display-header-bar.ui</file>
diff --git a/data/ui/collection-view.ui b/data/ui/collection-view.ui
new file mode 100644
index 00000000..14810906
--- /dev/null
+++ b/data/ui/collection-view.ui
@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!-- Generated with glade 3.18.1 -->
+<interface>
+  <requires lib="gtk+" version="3.16"/>
+  <template class="GamesCollectionView" parent="GtkBin">
+    <property name="visible">True</property>
+    <child>
+      <object class="GamesCollectionBox" id="box">
+        <property name="visible">True</property>
+        <signal name="game-activated" handler="on_game_activated"/>
+      </object>
+    </child>
+  </template>
+  <object class="GamesCollectionHeaderBar" id="header_bar">
+    <property name="visible">True</property>
+    <property name="show_close_button">True</property>
+  </object>
+</interface>
diff --git a/src/meson.build b/src/meson.build
index 7e5cc74b..85af716e 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -130,6 +130,7 @@ vala_sources = [
   'ui/collection-box.vala',
   'ui/collection-icon-view.vala',
   'ui/collection-header-bar.vala',
+  'ui/collection-view.vala',
   'ui/developer-list-item.vala',
   'ui/developers-view.vala',
   'ui/display-box.vala',
diff --git a/src/ui/collection-view.vala b/src/ui/collection-view.vala
new file mode 100644
index 00000000..d3e51da3
--- /dev/null
+++ b/src/ui/collection-view.vala
@@ -0,0 +1,70 @@
+// This file is part of GNOME Games. License: GPL-3.0+.
+
+[GtkTemplate (ui = "/org/gnome/Games/ui/collection-view.ui")]
+private class Games.CollectionView: Gtk.Bin, ApplicationView {
+       public signal void game_activated (Game game);
+
+       [GtkChild]
+       public CollectionBox box;
+       [GtkChild]
+       public CollectionHeaderBar header_bar;
+
+       public Gtk.Widget titlebar {
+               get { return header_bar; }
+       }
+
+       private bool _is_view_active;
+       public bool is_view_active {
+               get { return _is_view_active; }
+               set {
+                       if (is_view_active == value)
+                               return;
+
+                       _is_view_active = value;
+               }
+       }
+
+       public ApplicationWindow window { get; construct set; }
+
+       private ListModel _collection;
+       public ListModel collection {
+               get { return _collection; }
+               construct set {
+                       _collection = value;
+                       box.collection = _collection;
+               }
+       }
+
+       construct {
+               header_bar.viewstack = box.viewstack;
+       }
+
+       public CollectionView (ListModel collection) {
+               box.collection = collection;
+       }
+
+       public bool on_button_pressed (Gdk.EventButton event) {
+               return false;
+       }
+
+       public bool on_key_pressed (Gdk.EventKey event) {
+               return false;
+       }
+
+       public bool gamepad_button_press_event (Manette.Event event) {
+               return false;
+       }
+
+       public bool gamepad_button_release_event (Manette.Event event) {
+               return false;
+       }
+
+       public bool gamepad_absolute_axis_event (Manette.Event event) {
+               return false;
+       }
+
+       [GtkCallback]
+       private void on_game_activated (Game game) {
+               game_activated (game);
+       }
+}


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