[gnome-games] ui: Add DisplayBox
- From: Adrien Plazas <aplazas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-games] ui: Add DisplayBox
- Date: Mon, 25 Jul 2016 17:57:49 +0000 (UTC)
commit 2387adc2f5f1f5407cd5c79ecb20ed27cf94c3d2
Author: Adrien Plazas <kekun plazas laposte net>
Date: Sun Jul 24 12:55:50 2016 +0200
ui: Add DisplayBox
This will be used in a subsequent commit to replace ContentBox.
This is needed to better distribute the concerns of the different parts
of the UI.
data/org.gnome.Games.gresource.xml | 1 +
data/ui/display-box.ui | 7 +++++++
src/Makefile.am | 1 +
src/ui/display-box.vala | 33 +++++++++++++++++++++++++++++++++
4 files changed, 42 insertions(+), 0 deletions(-)
---
diff --git a/data/org.gnome.Games.gresource.xml b/data/org.gnome.Games.gresource.xml
index d48423e..62bd5d1 100644
--- a/data/org.gnome.Games.gresource.xml
+++ b/data/org.gnome.Games.gresource.xml
@@ -9,6 +9,7 @@
<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/content-box.ui</file>
+ <file preprocess="xml-stripblanks">ui/display-box.ui</file>
<file preprocess="xml-stripblanks">ui/display-header-bar.ui</file>
<file preprocess="xml-stripblanks">ui/dummy-display.ui</file>
<file preprocess="xml-stripblanks">ui/empty-collection.ui</file>
diff --git a/data/ui/display-box.ui b/data/ui/display-box.ui
new file mode 100644
index 0000000..41a0754
--- /dev/null
+++ b/data/ui/display-box.ui
@@ -0,0 +1,7 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<interface>
+ <requires lib="gtk+" version="3.16"/>
+ <template class="GamesDisplayBox" parent="GtkEventBox">
+ <property name="visible">True</property>
+ </template>
+</interface>
diff --git a/src/Makefile.am b/src/Makefile.am
index 8c614eb..9d0c1d7 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -88,6 +88,7 @@ gnome_games_SOURCES = \
ui/collection-icon-view.vala \
ui/collection-header-bar.vala \
ui/content-box.vala \
+ ui/display-box.vala \
ui/display-header-bar.vala \
ui/dummy-display.vala \
ui/empty-collection.vala \
diff --git a/src/ui/display-box.vala b/src/ui/display-box.vala
new file mode 100644
index 0000000..83eaaee
--- /dev/null
+++ b/src/ui/display-box.vala
@@ -0,0 +1,33 @@
+// This file is part of GNOME Games. License: GPLv3
+
+[GtkTemplate (ui = "/org/gnome/Games/ui/display-box.ui")]
+private class Games.DisplayBox : Gtk.EventBox {
+ public signal void game_activated (Game game);
+
+ private Runner _runner;
+ public Runner runner {
+ set {
+ _runner = value;
+ remove_display ();
+
+ if (runner == null)
+ return;
+
+ var display = runner.get_display ();
+ set_display (display);
+ }
+ get { return _runner; }
+ }
+
+ private void set_display (Gtk.Widget display) {
+ remove_display ();
+ add (display);
+ display.visible = true;
+ }
+
+ private void remove_display () {
+ var child = get_child ();
+ if (child != null)
+ remove (get_child ());
+ }
+}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]