diff options
author | Přemysl Eric Janouch <p@janouch.name> | 2022-02-13 13:18:16 +0100 |
---|---|---|
committer | Přemysl Eric Janouch <p@janouch.name> | 2022-02-13 13:18:36 +0100 |
commit | 0857a04a3a1bf6fe7cf328abff46299b66a4ad6a (patch) | |
tree | d0c584fb4f20dc709c724834bf6af2e87836dd14 | |
parent | 4302ec71f2ba8fcc7ede7b403aa41eef4529e97f (diff) | |
download | fiv-0857a04a3a1bf6fe7cf328abff46299b66a4ad6a.tar.gz fiv-0857a04a3a1bf6fe7cf328abff46299b66a4ad6a.tar.xz fiv-0857a04a3a1bf6fe7cf328abff46299b66a4ad6a.zip |
Scroll to selection when returning from the viewer
-rw-r--r-- | fiv-browser.c | 17 |
1 files 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. } |