Skip to content

Commit

Permalink
Use Gio API for getting mtime
Browse files Browse the repository at this point in the history
  • Loading branch information
kra-mo committed Dec 16, 2023
1 parent a78a91f commit 31c5b8a
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 23 deletions.
12 changes: 8 additions & 4 deletions hyperplane/utils/thumbnail.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,6 @@

from gi.repository import Gdk, Gio, GLib, GnomeDesktop

from hyperplane.utils.files import get_gfile_path


def generate_thumbnail(
gfile: Gio.File, content_type: str, callback: Callable, *args: Any
Expand All @@ -40,8 +38,14 @@ def generate_thumbnail(
uri = gfile.get_uri()

try:
mtime = get_gfile_path(gfile).stat().st_mtime
except FileNotFoundError:
mtime = (
gfile.query_info(
Gio.FILE_ATTRIBUTE_TIME_MODIFIED, Gio.FileQueryInfoFlags.NONE
)
.get_modification_date_time()
.to_unix()
)
except AttributeError:
return

if not factory.can_thumbnail(uri, content_type, mtime):
Expand Down
19 changes: 0 additions & 19 deletions hyperplane/window.py
Original file line number Diff line number Diff line change
Expand Up @@ -255,25 +255,6 @@ def get_gfiles_from_positions(self, positions: list[int]) -> list[Gio.File]:

return paths

def get_paths_from_positions(self, positions: list[int]) -> list[Path]:
"""Get a list of file paths corresponding to positions in the ListModel."""
paths = []
multi_selection = self.get_visible_page().multi_selection

for position in positions:
try:
path = get_gfile_path(
multi_selection.get_item(position).get_attribute_object(
"standard::file"
)
)
except FileNotFoundError:
continue

paths.append(path)

return paths

def get_selected_items(self) -> list[int]:
"""Gets the list of positions for selected items in the grid view."""
bitset = self.get_visible_page().multi_selection.get_selection()
Expand Down

0 comments on commit 31c5b8a

Please sign in to comment.