[gnome-games] ui: Make ApplicationWindow handle fullscreen
- From: Adrien Plazas <aplazas src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-games] ui: Make ApplicationWindow handle fullscreen
- Date: Sun, 31 Jul 2016 07:40:16 +0000 (UTC)
commit 4ccd77d5a9dd35a5cb124e7767adc0ebcb2e6a2b
Author: Adrien Plazas <kekun plazas laposte net>
Date: Sat Jul 30 18:19:24 2016 +0200
ui: Make ApplicationWindow handle fullscreen
This will be used in the next commit to implement fullscreen support.
https://bugzilla.gnome.org/show_bug.cgi?id=769329
data/ui/application-window.ui | 2 ++
src/ui/application-window.vala | 27 +++++++++++++++++++++++++++
2 files changed, 29 insertions(+), 0 deletions(-)
---
diff --git a/data/ui/application-window.ui b/data/ui/application-window.ui
index 1d57769..b6593ca 100644
--- a/data/ui/application-window.ui
+++ b/data/ui/application-window.ui
@@ -9,6 +9,7 @@
<property name="show_menubar">False</property>
<signal name="delete-event" after="yes" handler="on_delete_event"/>
<signal name="key-press-event" after="yes" handler="on_key_pressed"/>
+ <signal name="window-state-event" after="yes" handler="on_window_state_event"/>
<child>
<object class="GtkStack" id="content_box">
<property name="visible">True</property>
@@ -25,6 +26,7 @@
<child>
<object class="GamesDisplayBox" id="display_box">
<property name="visible">True</property>
+ <signal name="back" handler="on_display_back"/>
</object>
<packing>
<property name="name">display</property>
diff --git a/src/ui/application-window.vala b/src/ui/application-window.vala
index 3bd25be..138f044 100644
--- a/src/ui/application-window.vala
+++ b/src/ui/application-window.vala
@@ -15,6 +15,8 @@ private class Games.ApplicationWindow : Gtk.ApplicationWindow {
content_box.set_visible_child (collection_box);
header_bar.set_visible_child (collection_header_bar);
+ is_fullscreen = false;
+
if (display_box.runner != null) {
display_box.runner.pause ();
display_box.runner = null;
@@ -33,6 +35,19 @@ private class Games.ApplicationWindow : Gtk.ApplicationWindow {
get { return _ui_state; }
}
+ private bool _is_fullscreen;
+ public bool is_fullscreen {
+ set {
+ _is_fullscreen = value && (ui_state == UiState.DISPLAY);
+
+ if (_is_fullscreen)
+ fullscreen ();
+ else
+ unfullscreen ();
+ }
+ get { return _is_fullscreen; }
+ }
+
private bool _search_mode;
public bool search_mode {
set { _search_mode = value && (ui_state == UiState.COLLECTION); }
@@ -54,6 +69,7 @@ private class Games.ApplicationWindow : Gtk.ApplicationWindow {
private DisplayHeaderBar display_header_bar;
private Binding box_search_binding;
+ private Binding box_fullscreen_binding;
private Binding header_bar_search_binding;
private HashTable<Game, Runner> runners;
@@ -72,6 +88,9 @@ private class Games.ApplicationWindow : Gtk.ApplicationWindow {
BindingFlags.BIDIRECTIONAL);
header_bar_search_binding = bind_property ("search-mode", collection_header_bar,
"search-mode",
BindingFlags.BIDIRECTIONAL);
+
+ box_fullscreen_binding = bind_property ("is-fullscreen", display_box, "is-fullscreen",
+ BindingFlags.BIDIRECTIONAL);
}
public void run_game (Game game) {
@@ -134,6 +153,13 @@ private class Games.ApplicationWindow : Gtk.ApplicationWindow {
}
[GtkCallback]
+ public bool on_window_state_event (Gdk.EventWindowState event) {
+ is_fullscreen = (bool) (event.new_window_state & Gdk.WindowState.FULLSCREEN);
+
+ return false;
+ }
+
+ [GtkCallback]
private void on_game_activated (Game game) {
run_game (game);
}
@@ -157,6 +183,7 @@ private class Games.ApplicationWindow : Gtk.ApplicationWindow {
}
display_header_bar.game_title = game.name;
+ display_box.header_bar.game_title = game.name;
display_box.runner = runner;
ui_state = UiState.DISPLAY;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]