Scroll to selection when returning from the viewer
This commit is contained in:
parent
4302ec71f2
commit
0857a04a3a
@ -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.
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user