[gnome-games/wip/exalm/views: 97/109] application-window: Use DisplayBox
- From: Alexander Mikhaylenko <alexm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-games/wip/exalm/views: 97/109] application-window: Use DisplayBox
- Date: Sun, 24 Feb 2019 18:39:53 +0000 (UTC)
commit 8c5d93efa883e691beca376d0999e43a4f21c200
Author: Alexander Mikhaylenko <exalm7659 gmail com>
Date: Thu Oct 4 23:40:07 2018 +0500
application-window: Use DisplayBox
Use a DisplayView object instead of adding DisplayBox and DisplayHeaderBar
separately.
data/ui/application-window.ui | 15 +-------
src/ui/application-window.vala | 86 +++++++++++++++++++++---------------------
2 files changed, 45 insertions(+), 56 deletions(-)
---
diff --git a/data/ui/application-window.ui b/data/ui/application-window.ui
index 2a713d45..7dbf6d8e 100644
--- a/data/ui/application-window.ui
+++ b/data/ui/application-window.ui
@@ -21,13 +21,10 @@
</object>
</child>
<child>
- <object class="GamesDisplayBox" id="display_box">
+ <object class="GamesDisplayView" id="display_view">
<property name="visible">True</property>
<signal name="back" handler="on_display_back"/>
</object>
- <packing>
- <property name="name">display</property>
- </packing>
</child>
</object>
</child>
@@ -37,16 +34,6 @@
<child>
<object class="GtkStack" id="header_bar">
<property name="visible">True</property>
- <child>
- <object class="GamesDisplayHeaderBar" id="display_header_bar">
- <property name="visible">True</property>
- <property name="show-close-button">True</property>
- <signal name="back" handler="on_display_back"/>
- </object>
- <packing>
- <property name="name">display</property>
- </packing>
- </child>
</object>
</child>
</object>
diff --git a/src/ui/application-window.vala b/src/ui/application-window.vala
index c00c545a..c3e6187e 100644
--- a/src/ui/application-window.vala
+++ b/src/ui/application-window.vala
@@ -21,21 +21,23 @@ private class Games.ApplicationWindow : Gtk.ApplicationWindow {
content_box.visible_child = collection_view;
header_bar.visible_child = collection_view.titlebar;
+ display_view.is_view_active = false;
collection_view.is_view_active = true;
is_fullscreen = false;
- if (display_box.runner != null) {
- display_box.runner.stop ();
- display_box.runner = null;
+ if (display_view.box.runner != null) {
+ display_view.box.runner.stop ();
+ display_view.box.runner = null;
}
break;
case UiState.DISPLAY:
- content_box.visible_child = display_box;
- header_bar.visible_child = display_header_bar;
+ content_box.visible_child = display_view;
+ header_bar.visible_child = display_view.titlebar;
collection_view.is_view_active = false;
+ display_view.is_view_active = true;
search_mode = false;
@@ -77,12 +79,10 @@ private class Games.ApplicationWindow : Gtk.ApplicationWindow {
[GtkChild]
private CollectionView collection_view;
[GtkChild]
- private DisplayBox display_box;
+ private DisplayView display_view;
[GtkChild]
private Gtk.Stack header_bar;
- [GtkChild]
- private DisplayHeaderBar display_header_bar;
private Settings settings;
@@ -121,9 +121,11 @@ private class Games.ApplicationWindow : Gtk.ApplicationWindow {
construct {
header_bar.add (collection_view.titlebar);
+ header_bar.add (display_view.titlebar);
header_bar.visible_child = collection_view.titlebar;
collection_view.window = this;
+ display_view.window = this;
ui_state = UiState.COLLECTION;
@@ -148,9 +150,9 @@ private class Games.ApplicationWindow : Gtk.ApplicationWindow {
header_bar_search_binding = bind_property ("search-mode", collection_view.header_bar,
"search-mode",
BindingFlags.BIDIRECTIONAL);
- box_fullscreen_binding = bind_property ("is-fullscreen", display_box, "is-fullscreen",
+ box_fullscreen_binding = bind_property ("is-fullscreen", display_view.box, "is-fullscreen",
BindingFlags.BIDIRECTIONAL);
- header_bar_fullscreen_binding = bind_property ("is-fullscreen", display_header_bar,
"is-fullscreen",
+ header_bar_fullscreen_binding = bind_property ("is-fullscreen", display_view.header_bar,
"is-fullscreen",
BindingFlags.BIDIRECTIONAL);
box_empty_collection_binding = bind_property ("is-collection-empty", collection_view.box,
"is-collection-empty",
@@ -176,7 +178,7 @@ private class Games.ApplicationWindow : Gtk.ApplicationWindow {
public void run_game (Game game) {
// If there is a game already running we have to quit it first
- if (display_box.runner != null && !quit_game())
+ if (display_view.box.runner != null && !quit_game ())
return;
if (run_game_cancellable != null)
@@ -350,8 +352,8 @@ private class Games.ApplicationWindow : Gtk.ApplicationWindow {
}
private void run_game_with_cancellable (Game game, Cancellable cancellable) {
- display_header_bar.game_title = game.name;
- display_box.header_bar.game_title = game.name;
+ display_view.header_bar.game_title = game.name;
+ display_view.box.header_bar.game_title = game.name;
ui_state = UiState.DISPLAY;
// Reset the UI parts depending on the runner to avoid an
@@ -362,12 +364,12 @@ private class Games.ApplicationWindow : Gtk.ApplicationWindow {
if (runner == null)
return;
- display_header_bar.can_fullscreen = runner.can_fullscreen;
- display_box.header_bar.can_fullscreen = runner.can_fullscreen;
- display_header_bar.runner = runner;
- display_box.runner = runner;
- display_header_bar.media_set = runner.media_set;
- display_box.header_bar.media_set = runner.media_set;
+ display_view.header_bar.can_fullscreen = runner.can_fullscreen;
+ display_view.box.header_bar.can_fullscreen = runner.can_fullscreen;
+ display_view.header_bar.runner = runner;
+ display_view.box.runner = runner;
+ display_view.header_bar.media_set = runner.media_set;
+ display_view.box.header_bar.media_set = runner.media_set;
is_fullscreen = settings.get_boolean ("fullscreen") && runner.can_fullscreen;
@@ -396,14 +398,14 @@ private class Games.ApplicationWindow : Gtk.ApplicationWindow {
return runner;
reset_display_page ();
- display_box.display_running_game_failed (game, error_message);
+ display_view.box.display_running_game_failed (game, error_message);
return null;
}
catch (Error e) {
warning (e.message);
reset_display_page ();
- display_box.display_running_game_failed (game, _("An unexpected error occurred."));
+ display_view.box.display_running_game_failed (game, _("An unexpected error
occurred."));
return null;
}
@@ -436,7 +438,7 @@ private class Games.ApplicationWindow : Gtk.ApplicationWindow {
private bool try_run_with_cancellable (Runner runner, bool resume, Cancellable cancellable) {
try {
if (resume)
- display_box.runner.resume ();
+ display_view.box.runner.resume ();
else
runner.start ();
@@ -469,7 +471,7 @@ private class Games.ApplicationWindow : Gtk.ApplicationWindow {
response = Gtk.ResponseType.CANCEL;
if (response == Gtk.ResponseType.CANCEL) {
- display_box.runner = null;
+ display_view.box.runner = null;
ui_state = UiState.COLLECTION;
return;
@@ -484,13 +486,13 @@ private class Games.ApplicationWindow : Gtk.ApplicationWindow {
}
public bool quit_game_with_cancellable (Cancellable cancellable) {
- if (display_box.runner == null)
+ if (display_view.box.runner == null)
return true;
- display_box.runner.pause ();
+ display_view.box.runner.pause ();
- if (display_box.runner.can_quit_safely) {
- display_box.runner.stop();
+ if (display_view.box.runner.can_quit_safely) {
+ display_view.box.runner.stop ();
return true;
}
@@ -525,9 +527,9 @@ private class Games.ApplicationWindow : Gtk.ApplicationWindow {
}
private bool cancel_quitting_game () {
- if (display_box.runner != null)
+ if (display_view.box.runner != null)
try {
- display_box.runner.resume ();
+ display_view.box.runner.resume ();
}
catch (Error e) {
warning (e.message);
@@ -589,7 +591,7 @@ private class Games.ApplicationWindow : Gtk.ApplicationWindow {
if (is_active)
try {
- display_box.runner.resume ();
+ display_view.box.runner.resume ();
}
catch (Error e) {
warning (e.message);
@@ -597,7 +599,7 @@ private class Games.ApplicationWindow : Gtk.ApplicationWindow {
else if (with_delay)
focus_out_timeout_id = Timeout.add (FOCUS_OUT_DELAY_MILLISECONDS,
on_focus_out_delay_elapsed);
else
- display_box.runner.pause ();
+ display_view.box.runner.pause ();
}
private bool on_focus_out_delay_elapsed () {
@@ -607,7 +609,7 @@ private class Games.ApplicationWindow : Gtk.ApplicationWindow {
return false;
if (!is_active)
- display_box.runner.pause ();
+ display_view.box.runner.pause ();
return false;
}
@@ -616,7 +618,7 @@ private class Games.ApplicationWindow : Gtk.ApplicationWindow {
if (ui_state != UiState.DISPLAY)
return false;
- if (display_box.runner == null)
+ if (display_view.box.runner == null)
return false;
if (run_game_cancellable != null)
@@ -653,21 +655,21 @@ private class Games.ApplicationWindow : Gtk.ApplicationWindow {
if ((event.keyval == Gdk.Key.f || event.keyval == Gdk.Key.F) &&
(event.state & default_modifiers) == Gdk.ModifierType.CONTROL_MASK &&
- display_header_bar.can_fullscreen) {
+ display_view.header_bar.can_fullscreen) {
is_fullscreen = !is_fullscreen;
settings.set_boolean ("fullscreen", is_fullscreen);
return true;
}
- if (event.keyval == Gdk.Key.F11 && display_header_bar.can_fullscreen) {
+ if (event.keyval == Gdk.Key.F11 && display_view.header_bar.can_fullscreen) {
is_fullscreen = !is_fullscreen;
settings.set_boolean ("fullscreen", is_fullscreen);
return true;
}
- if (event.keyval == Gdk.Key.Escape && display_header_bar.can_fullscreen) {
+ if (event.keyval == Gdk.Key.Escape && display_view.header_bar.can_fullscreen) {
is_fullscreen = false;
settings.set_boolean ("fullscreen", false);
@@ -717,12 +719,12 @@ private class Games.ApplicationWindow : Gtk.ApplicationWindow {
}
private void reset_display_page () {
- display_header_bar.can_fullscreen = false;
- display_box.header_bar.can_fullscreen = false;
- display_header_bar.runner = null;
- display_box.runner = null;
- display_header_bar.media_set = null;
- display_box.header_bar.media_set = null;
+ display_view.header_bar.can_fullscreen = false;
+ display_view.box.header_bar.can_fullscreen = false;
+ display_view.header_bar.runner = null;
+ display_view.box.runner = null;
+ display_view.header_bar.media_set = null;
+ display_view.box.header_bar.media_set = null;
}
private void on_konami_code_performed () {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]