Commit 9d9db1a4 authored by AndreiLisita's avatar AndreiLisita 🎮

savestates-list: Ensure selected row is visible on rename and delete

Ensures the rename popover appears on screen
Fixes #225
parent df4c48e9
Pipeline #104978 passed with stages
in 13 minutes and 48 seconds
......@@ -142,6 +142,7 @@ private class Games.SavestatesList : Gtk.Box {
var savestate_row = selected_row as SavestateListBoxRow;
var savestate = savestate_row.savestate;
ensure_row_is_visible (selected_row);
runner.delete_savestate (savestate);
savestate_row.remove_animated ();
......@@ -172,11 +173,26 @@ private class Games.SavestatesList : Gtk.Box {
private void on_rename_clicked () {
var selected_row = list_box.get_selected_row ();
ensure_row_is_visible (selected_row);
rename_entry.text = state.selected_savestate.get_name ();
rename_popover.relative_to = selected_row;
rename_popover.popup ();
}
// Adapted from gtklistbox.c, ensure_row_visible()
private void ensure_row_is_visible (Gtk.ListBoxRow row) {
Gtk.Allocation allocation;
row.get_allocation (out allocation);
var y = allocation.y;
var height = allocation.height;
scrolled_window.kinetic_scrolling = false;
scrolled_window.vadjustment.clamp_page (y, y + height);
scrolled_window.kinetic_scrolling = true;
}
[GtkCallback]
private void on_rename_entry_activated () {
if (check_rename_is_valid ())
......
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