Skip to content

Commit

Permalink
Use new list view "scroll to" API in GTK 4.12
Browse files Browse the repository at this point in the history
  • Loading branch information
johnfactotum committed Sep 21, 2023
1 parent c8e6408 commit be52155
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/search.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ GObject.registerClass({
})
utils.addPropertyActions(this.settings, this.settings.keys, this.actionGroup)
this.model.connect('selection-changed', sel => {
utils.scrollListView(this, sel.selected)
this.scroll_to(sel.selected, Gtk.ListScrollFlags.NONE, null)
const { cfi } = sel.selected_item?.item ?? {}
if (cfi) this.emit('show-cfi', cfi)
})
Expand Down
3 changes: 1 addition & 2 deletions src/toc.js
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,7 @@ GObject.registerClass({
}
}
this.#shouldGoToTocItem = false
model.set_selected(index)
utils.scrollListView(this, index)
this.scroll_to(index, Gtk.ListScrollFlags.SELECT, null)
this.#shouldGoToTocItem = true
}
})
4 changes: 0 additions & 4 deletions src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -310,10 +310,6 @@ export const tree = (arr, item, autoexpand = true) => {
return Gtk.TreeListModel.new(root, false, autoexpand, item => item.subitems ?? null)
}

// see https://gitlab.gnome.org/GNOME/gtk/-/issues/4237
export const scrollListView = (listView, pos) =>
listView.activate_action('list.scroll-to-item', new GLib.Variant('u', pos))

// go through all child widgets
export const walk = (widget, callback) => {
const f = widget => {
Expand Down

0 comments on commit be52155

Please sign in to comment.