Commit 1461ae95 authored by Andrei Lisita's avatar Andrei Lisita 🎮

savestates-list: Re-populate the list box everytime the menu is opened

parent 3c5b4f56
...@@ -30,31 +30,7 @@ private class Games.SavestatesList : Gtk.Box { ...@@ -30,31 +30,7 @@ private class Games.SavestatesList : Gtk.Box {
} }
} }
private Runner _runner; public Runner runner { get; set; }
public Runner runner {
get { return _runner; }
set {
_runner = value;
// Remove current savestate rows
var list_rows = list_box.get_children ();
foreach (var row in list_rows) {
if (row != new_savestate_row)
list_box.remove (row);
}
if (value == null)
return;
// value != null
var savestates = _runner.get_savestates ();
foreach (var savestate in savestates) {
var list_row = new SavestateListBoxRow (savestate);
list_box.add (list_row);
}
}
}
construct { construct {
list_box.set_header_func (update_header); list_box.set_header_func (update_header);
...@@ -87,6 +63,25 @@ private class Games.SavestatesList : Gtk.Box { ...@@ -87,6 +63,25 @@ private class Games.SavestatesList : Gtk.Box {
select_savestate_row (activated_row); select_savestate_row (activated_row);
} }
private void populate_list_box () {
// Remove current savestate rows
var list_rows = list_box.get_children ();
foreach (var row in list_rows) {
if (row != new_savestate_row)
list_box.remove (row);
}
if (runner == null)
return;
var savestates = _runner.get_savestates ();
foreach (var savestate in savestates) {
var list_row = new SavestateListBoxRow (savestate);
list_box.add (list_row);
}
}
private void on_load_clicked () { private void on_load_clicked () {
if (!try_runner_load_previewed_savestate ()) { if (!try_runner_load_previewed_savestate ()) {
// TODO: Here we could show a dialog with one button like // TODO: Here we could show a dialog with one button like
...@@ -115,6 +110,7 @@ private class Games.SavestatesList : Gtk.Box { ...@@ -115,6 +110,7 @@ private class Games.SavestatesList : Gtk.Box {
if (state.is_revealed) { if (state.is_revealed) {
runner.pause (); runner.pause ();
populate_list_box ();
select_savestate_row (null); select_savestate_row (null);
} }
// Runner isn't resumed here but after the revealer finishes the transition // Runner isn't resumed here but after the revealer finishes the transition
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment