[gnome-games/wip/exalm/savestates: 4/5] ui: Remove SavestatesListState
- From: Alexander Mikhaylenko <alexm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-games/wip/exalm/savestates: 4/5] ui: Remove SavestatesListState
- Date: Sun, 26 Jan 2020 19:23:50 +0000 (UTC)
commit e83a0dfd9fec35b690233c99ec208ac5a16314bc
Author: Alexander Mikhaylenko <alexm gnome org>
Date: Sun Jan 26 23:38:30 2020 +0500
ui: Remove SavestatesListState
Replace the remaining property with an is-showing-snapshots property
synced between DisplayView, DisplayBox, DisplayHeaderBar and
SavestatesListState.
data/ui/display-box.ui | 5 ++++-
data/ui/display-header-bar.ui | 1 +
data/ui/savestates-list.ui | 5 +++--
src/meson.build | 1 -
src/ui/display-box.vala | 24 +++---------------------
src/ui/display-header-bar.vala | 23 +++++------------------
src/ui/display-view.vala | 31 +++++++++++++++++--------------
src/ui/savestates-list-state.vala | 3 ---
src/ui/savestates-list.vala | 25 ++++---------------------
9 files changed, 37 insertions(+), 81 deletions(-)
---
diff --git a/data/ui/display-box.ui b/data/ui/display-box.ui
index 106c7d30..c7d11d8c 100644
--- a/data/ui/display-box.ui
+++ b/data/ui/display-box.ui
@@ -4,13 +4,15 @@
<template class="GamesDisplayBox" parent="GtkBin">
<property name="visible">True</property>
<child>
- <object class="GamesFullscreenBox" id="fullscreen_box">
+ <object class="GamesFullscreenBox">
<property name="visible">True</property>
+ <property name="autohide" bind-source="GamesDisplayBox" bind-property="is-showing-snapshots"
bind-flags="bidirectional|sync-create|invert-boolean"/>
<property name="is-fullscreen" bind-source="GamesDisplayBox" bind-property="is-fullscreen"
bind-flags="bidirectional"/>
<child type="titlebar">
<object class="GamesDisplayHeaderBar" id="fullscreen_header_bar">
<property name="visible">True</property>
<property name="show-title-buttons">False</property>
+ <property name="is-showing-snapshots" bind-source="GamesDisplayBox"
bind-property="is-showing-snapshots" bind-flags="bidirectional"/>
<signal name="back" handler="on_fullscreen_header_bar_back"/>
<signal name="size-allocate" handler="on_fullscreen_header_bar_size_allocated"/>
</object>
@@ -45,6 +47,7 @@
<object class="GamesSavestatesList" id="savestates_list">
<property name="visible">True</property>
<property name="halign">end</property>
+ <property name="is-revealed" bind-source="GamesDisplayBox"
bind-property="is-showing-snapshots" bind-flags="bidirectional"/>
<signal name="size-allocate" handler="on_savestates_list_size_allocate"/>
<signal name="hidden" handler="on_snapshots_hidden"/>
</object>
diff --git a/data/ui/display-header-bar.ui b/data/ui/display-header-bar.ui
index 91551d76..4f379967 100644
--- a/data/ui/display-header-bar.ui
+++ b/data/ui/display-header-bar.ui
@@ -5,6 +5,7 @@
<property name="visible">True</property>
<signal name="notify::is-fullscreen" handler="on_fullscreen_changed"/>
<signal name="notify::can-fullscreen" handler="on_fullscreen_changed"/>
+ <signal name="notify::is-showing-snapshots" handler="on_showing_snapshots_changed"/>
<child>
<object class="GtkStack" id="stack">
<property name="visible">True</property>
diff --git a/data/ui/savestates-list.ui b/data/ui/savestates-list.ui
index 7a5db8c2..6d488241 100644
--- a/data/ui/savestates-list.ui
+++ b/data/ui/savestates-list.ui
@@ -2,14 +2,15 @@
<interface>
<requires lib="gtk+" version="3.24"/>
<template class="GamesSavestatesList" parent="GtkBox">
+ <signal name="notify::is-revealed" handler="on_revealed_changed"/>
<style>
<class name="background"/>
</style>
<child>
- <object class="GtkRevealer" id="revealer">
+ <object class="GtkRevealer">
<property name="visible">True</property>
- <property name="reveal-child">False</property>
<property name="transition-type">slide-left</property>
+ <property name="reveal-child" bind-source="GamesSavestatesList" bind-property="is-revealed"
bind-flags="sync-create|bidirectional"/>
<signal name="notify::child-revealed" handler="on_revealer_transition_end"/>
<child>
<object class="GtkBox">
diff --git a/src/meson.build b/src/meson.build
index 99ef120a..e6132ef4 100644
--- a/src/meson.build
+++ b/src/meson.build
@@ -151,7 +151,6 @@ vala_sources = [
'ui/resume-failed-dialog.vala',
'ui/savestate-listbox-row.vala',
'ui/savestates-list.vala',
- 'ui/savestates-list-state.vala',
'ui/search-bar.vala',
'ui/shortcuts-window.vala',
'ui/ui-view.vala',
diff --git a/src/ui/display-box.vala b/src/ui/display-box.vala
index 37c71e24..6f3ff94a 100644
--- a/src/ui/display-box.vala
+++ b/src/ui/display-box.vala
@@ -17,20 +17,12 @@ private class Games.DisplayBox : Gtk.Bin {
}
}
+ public bool is_showing_snapshots { get; set; }
+
public DisplayHeaderBar header_bar {
get { return fullscreen_header_bar; }
}
- public SavestatesListState savestates_list_state {
- get { return savestates_list.state; }
- set {
- value.notify["is-revealed"].connect (on_savestates_list_revealed_changed);
-
- savestates_list.state = value;
- fullscreen_header_bar.savestates_list_state = value;
- }
- }
-
private Runner _runner;
public Runner runner {
get { return _runner; }
@@ -56,8 +48,6 @@ private class Games.DisplayBox : Gtk.Bin {
}
}
- [GtkChild]
- private FullscreenBox fullscreen_box;
[GtkChild]
private Gtk.Stack stack;
[GtkChild]
@@ -75,10 +65,6 @@ private class Games.DisplayBox : Gtk.Bin {
private int fullscreen_header_bar_height;
- public DisplayBox (SavestatesListState savestates_list_state) {
- Object (savestates_list_state: savestates_list_state);
- }
-
public void display_running_game_failed (Game game, string error_message) {
stack.visible_child = error_display;
error_display.running_game_failed (game, error_message);
@@ -108,7 +94,7 @@ private class Games.DisplayBox : Gtk.Bin {
if (runner == null)
return false;
- if (savestates_list_state.is_revealed)
+ if (is_showing_snapshots)
return savestates_list.on_key_press_event (keyval, state);
return runner.key_press_event (keyval, state);
@@ -128,10 +114,6 @@ private class Games.DisplayBox : Gtk.Bin {
return runner.gamepad_button_press_event (button);
}
- public void on_savestates_list_revealed_changed () {
- fullscreen_box.autohide = !savestates_list.state.is_revealed;
- }
-
[GtkCallback]
private void on_fullscreen_header_bar_size_allocated (Gtk.Allocation allocation) {
fullscreen_header_bar_height = allocation.height;
diff --git a/src/ui/display-header-bar.vala b/src/ui/display-header-bar.vala
index e735a392..4ef34f08 100644
--- a/src/ui/display-header-bar.vala
+++ b/src/ui/display-header-bar.vala
@@ -7,17 +7,6 @@ private class Games.DisplayHeaderBar : Gtk.Bin {
[GtkChild]
private MediaMenuButton media_button;
- private SavestatesListState _savestates_list_state;
- public SavestatesListState savestates_list_state {
- get { return _savestates_list_state; }
- set {
- _savestates_list_state = value;
-
- if (value != null)
- value.notify["is-revealed"].connect (on_savestates_list_revealed_changed);
- }
- }
-
public string game_title {
set {
ingame_header_bar.title = value;
@@ -31,6 +20,7 @@ private class Games.DisplayHeaderBar : Gtk.Bin {
public bool can_fullscreen { get; set; }
public bool is_fullscreen { get; set; }
+ public bool is_showing_snapshots { get; set; }
public MediaSet? media_set {
set { media_button.media_set = value; }
@@ -88,10 +78,6 @@ private class Games.DisplayHeaderBar : Gtk.Bin {
private Settings settings;
- public DisplayHeaderBar (SavestatesListState savestates_list_state) {
- Object (savestates_list_state: savestates_list_state);
- }
-
construct {
settings = new Settings ("org.gnome.Games");
}
@@ -125,11 +111,12 @@ private class Games.DisplayHeaderBar : Gtk.Bin {
[GtkCallback]
private void on_secondary_menu_savestates_clicked () {
- savestates_list_state.is_revealed = true;
+ is_showing_snapshots = true;
}
- private void on_savestates_list_revealed_changed () {
- if (savestates_list_state.is_revealed)
+ [GtkCallback]
+ private void on_showing_snapshots_changed () {
+ if (is_showing_snapshots)
stack.visible_child = savestates_header_bar;
else
stack.visible_child = ingame_header_bar;
diff --git a/src/ui/display-view.vala b/src/ui/display-view.vala
index 33fc4e44..60823f80 100644
--- a/src/ui/display-view.vala
+++ b/src/ui/display-view.vala
@@ -39,6 +39,7 @@ private class Games.DisplayView : Object, UiView {
public Gtk.Window window { get; construct; }
public bool is_fullscreen { get; set; }
+ public bool is_showing_snapshots { get; set; }
private Settings settings;
@@ -49,8 +50,6 @@ private class Games.DisplayView : Object, UiView {
private ResumeFailedDialog resume_failed_dialog;
private QuitDialog quit_dialog;
- private SavestatesListState savestates_list_state;
-
private long focus_out_timeout_id;
private const ActionEntry[] action_entries = {
@@ -62,9 +61,8 @@ private class Games.DisplayView : Object, UiView {
}
construct {
- savestates_list_state = new SavestatesListState ();
- box = new DisplayBox (savestates_list_state);
- header_bar = new DisplayHeaderBar (savestates_list_state);
+ box = new DisplayBox ();
+ header_bar = new DisplayHeaderBar ();
box.back.connect (on_display_back);
header_bar.back.connect (on_display_back);
@@ -78,6 +76,11 @@ private class Games.DisplayView : Object, UiView {
bind_property ("is-fullscreen", header_bar,
"is-fullscreen", BindingFlags.BIDIRECTIONAL);
+ bind_property ("is-showing-snapshots", box,
+ "is-showing-snapshots", BindingFlags.BIDIRECTIONAL);
+ bind_property ("is-showing-snapshots", header_bar,
+ "is-showing-snapshots", BindingFlags.BIDIRECTIONAL);
+
focus_out_timeout_id = -1;
var action_group = new SimpleActionGroup ();
@@ -108,7 +111,7 @@ private class Games.DisplayView : Object, UiView {
return true;
if ((keyval == Gdk.Key.f || keyval == Gdk.Key.F) && ctrl_pressed &&
- header_bar.can_fullscreen && !savestates_list_state.is_revealed) {
+ header_bar.can_fullscreen && !is_showing_snapshots) {
is_fullscreen = !is_fullscreen;
settings.set_boolean ("fullscreen", is_fullscreen);
@@ -116,7 +119,7 @@ private class Games.DisplayView : Object, UiView {
}
if (keyval == Gdk.Key.F11 && header_bar.can_fullscreen &&
- !savestates_list_state.is_revealed) {
+ !is_showing_snapshots) {
is_fullscreen = !is_fullscreen;
settings.set_boolean ("fullscreen", is_fullscreen);
@@ -141,12 +144,12 @@ private class Games.DisplayView : Object, UiView {
if (!box.runner.supports_savestates)
return false;
- if (savestates_list_state.is_revealed)
+ if (is_showing_snapshots)
return false;
if (((keyval == Gdk.Key.a || keyval == Gdk.Key.A) && ctrl_pressed) ||
(keyval == Gdk.Key.F4)) {
- savestates_list_state.is_revealed = true;
+ is_showing_snapshots = true;
return true;
}
@@ -169,7 +172,7 @@ private class Games.DisplayView : Object, UiView {
}
private void on_escape_key_pressed () {
- if (savestates_list_state.is_revealed)
+ if (is_showing_snapshots)
on_display_back (); // Hide Savestates menu
else if (header_bar.can_fullscreen) {
is_fullscreen = false;
@@ -243,9 +246,9 @@ private class Games.DisplayView : Object, UiView {
}
private void on_display_back () {
- if (savestates_list_state.is_revealed) {
+ if (is_showing_snapshots) {
box.runner.preview_current_state ();
- savestates_list_state.is_revealed = false;
+ is_showing_snapshots = false;
return;
}
@@ -507,7 +510,7 @@ private class Games.DisplayView : Object, UiView {
return;
if (window.is_active) {
- if (!savestates_list_state.is_revealed)
+ if (!is_showing_snapshots)
box.runner.resume ();
}
else if (with_delay)
@@ -549,6 +552,6 @@ private class Games.DisplayView : Object, UiView {
critical ("Failed to load snapshot: %s", e.message);
}
- savestates_list_state.is_revealed = false;
+ is_showing_snapshots = false;
}
}
diff --git a/src/ui/savestates-list.vala b/src/ui/savestates-list.vala
index 3d448bf2..15e2371e 100644
--- a/src/ui/savestates-list.vala
+++ b/src/ui/savestates-list.vala
@@ -4,8 +4,6 @@
private class Games.SavestatesList : Gtk.Box {
public signal void hidden ();
- [GtkChild]
- private Gtk.Revealer revealer;
[GtkChild]
private Gtk.ListBox list_box;
[GtkChild]
@@ -28,20 +26,7 @@ private class Games.SavestatesList : Gtk.Box {
private Savestate selected_savestate;
- private SavestatesListState _state;
- public SavestatesListState state {
- get { return _state; }
- set {
- if (_state != null)
- _state.notify["is-revealed"].disconnect (on_revealed_changed);
-
- _state = value;
-
- if (value != null)
- value.notify["is-revealed"].connect (on_revealed_changed);
- }
- }
-
+ public bool is_revealed { get; set; }
public Runner runner { get; set; }
construct {
@@ -109,20 +94,18 @@ private class Games.SavestatesList : Gtk.Box {
}
}
+ [GtkCallback]
private void on_revealed_changed () {
- revealer.reveal_child = state.is_revealed;
-
- if (state.is_revealed) {
+ if (is_revealed) {
runner.pause ();
populate_list_box ();
select_savestate_row (null);
}
- // Runner isn't resumed here but after the revealer finishes the transition
}
[GtkCallback]
private void on_revealer_transition_end () {
- if (!state.is_revealed)
+ if (!is_revealed)
hidden ();
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]