file_model: Add file() function

Adds a function to get the file at a given index directly,
instead of going through GListModel::item().
This commit is contained in:
Christopher Davis 2022-06-29 16:51:16 -04:00
parent e13ecb4df4
commit 70054971d9
2 changed files with 9 additions and 11 deletions

View file

@ -119,6 +119,11 @@ impl LpFileModel {
self.imp().directory.get().cloned()
}
pub fn file(&self, index: u32) -> Option<gio::File> {
let vec = self.imp().inner.borrow();
vec.get(index as usize).cloned()
}
pub fn index_of(&self, file: &gio::File) -> Option<usize> {
let imp = self.imp();
let vec = imp.inner.borrow();