[gnome-games] savestates-list: Fix row deletion with animations disabled
- From: Alexander Mikhaylenko <alexm src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-games] savestates-list: Fix row deletion with animations disabled
- Date: Thu, 15 Aug 2019 21:57:29 +0000 (UTC)
commit de9c97f277ed20434607a484d6651680fca4faa0
Author: Alexander Mikhaylenko <exalm7659 gmail com>
Date: Fri Aug 16 02:55:11 2019 +0500
savestates-list: Fix row deletion with animations disabled
Since the animation ends instantly in this case, connect to the signal
before starting it and not after. Since in this case get_row_at_index()
will immediately return a different row, select the next row before
removing, and not after.
Also simply the code a bit.
src/ui/savestate-listbox-row.vala | 2 +-
src/ui/savestates-list.vala | 25 +++++++------------------
2 files changed, 8 insertions(+), 19 deletions(-)
---
diff --git a/src/ui/savestate-listbox-row.vala b/src/ui/savestate-listbox-row.vala
index 08e1b1dd..e7f546ca 100644
--- a/src/ui/savestate-listbox-row.vala
+++ b/src/ui/savestate-listbox-row.vala
@@ -87,10 +87,10 @@ private class Games.SavestateListBoxRow : Gtk.ListBoxRow {
}
public void remove_animated () {
- revealer.reveal_child = false;
revealer.notify["child-revealed"].connect(() => {
get_parent ().remove (this);
});
+ revealer.reveal_child = false;
}
}
diff --git a/src/ui/savestates-list.vala b/src/ui/savestates-list.vala
index 828f44c2..75da8050 100644
--- a/src/ui/savestates-list.vala
+++ b/src/ui/savestates-list.vala
@@ -144,29 +144,18 @@ private class Games.SavestatesList : Gtk.Box {
ensure_row_is_visible (selected_row);
runner.delete_savestate (savestate);
- savestate_row.remove_animated ();
// Select and preview a new row
var next_row = list_box.get_row_at_index (selected_row_index + 1);
- if (next_row == null) { // The last row in the list has been deleted
- var nr_rows = list_box.get_children ().length ();
-
- if (nr_rows == 1) {
- // The only remaining row in the list is the create savestate one
- select_savestate_row (null);
- }
- else {
- // The last row of the list has been deleted but there are still
- // rows remaining in the list
- var last_row = list_box.get_row_at_index (selected_row_index - 1);
- select_savestate_row (last_row);
- }
-
- return;
+ if (next_row == null && list_box.get_children ().length () >= 1) {
+ // The last row of the list has been deleted but there are still
+ // rows remaining in the list
+ next_row = list_box.get_row_at_index (selected_row_index - 1);
}
select_savestate_row (next_row);
+ savestate_row.remove_animated ();
}
[GtkCallback]
@@ -258,8 +247,9 @@ private class Games.SavestatesList : Gtk.Box {
}
private void select_savestate_row (Gtk.ListBoxRow? row) {
+ list_box.select_row (row);
+
if (row == null) {
- list_box.select_row (null);
runner.preview_current_state ();
state.selected_savestate = null;
}
@@ -267,7 +257,6 @@ private class Games.SavestatesList : Gtk.Box {
var savestate_row = row as SavestateListBoxRow;
var savestate = savestate_row.savestate;
- list_box.select_row (row);
runner.preview_savestate (savestate);
state.selected_savestate = savestate;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]