From 0857a04a3a1bf6fe7cf328abff46299b66a4ad6a Mon Sep 17 00:00:00 2001 From: Přemysl Eric Janouch
Date: Sun, 13 Feb 2022 13:18:16 +0100 Subject: Scroll to selection when returning from the viewer --- fiv-browser.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/fiv-browser.c b/fiv-browser.c index 0f05e84..aaf955f 100644 --- a/fiv-browser.c +++ b/fiv-browser.c @@ -1603,6 +1603,20 @@ fiv_browser_new(FivIoModel *model) return GTK_WIDGET(self); } +static void +scroll_to_selection(FivBrowser *self) +{ + for (gsize y = 0; y < self->layouted_rows->len; y++) { + const Row *row = &g_array_index(self->layouted_rows, Row, y); + for (gsize x = 0; x < row->len; x++) { + if (row->items[x].entry == self->selected) { + scroll_to_row(self, row); + return; + } + } + } +} + void fiv_browser_select(FivBrowser *self, const char *uri) { @@ -1617,9 +1631,8 @@ fiv_browser_select(FivBrowser *self, const char *uri) const Entry *entry = &g_array_index(self->entries, Entry, i); if (!g_strcmp0(entry->uri, uri)) { self->selected = entry; + scroll_to_selection(self); break; } } - - // TODO(p): Scroll to selection. } -- cgit v1.2.3-70-g09d2