Skip to content

Commit

Permalink
Fix thumbnail textures incorrectly showing up
Browse files Browse the repository at this point in the history
  • Loading branch information
kra-mo committed Dec 22, 2023
1 parent 6d18a6b commit bd951f1
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions hyperplane/item.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,13 +172,12 @@ def bind(self) -> None:

def unbind(self) -> None:
"""Cleanup after the object has been unbound from its item."""
return

def __dir_children_cb(self, gfile: Gio.File, result: Gio.Task) -> None:
try:
files = gfile.enumerate_children_finish(result)
except GLib.Error:
self.__thumbnail_cb(shared.closed_folder_texture)
self.__thumbnail_cb()
return

def done(index) -> None:
Expand All @@ -188,9 +187,7 @@ def done(index) -> None:
index + 1 >= thumbnail_index,
)

self.__thumbnail_cb(
shared.open_folder_texture if index else shared.closed_folder_texture
)
self.__thumbnail_cb(open_folder=bool(index))

def next_files_cb(
enumerator: Gio.FileEnumerator, result: Gio.Task, index: int
Expand Down Expand Up @@ -294,7 +291,9 @@ def __dir_thumbnail_cb(

idle_add(picture.set_paintable, texture)

def __thumbnail_cb(self, texture: Optional[Gdk.Texture] = None) -> None:
def __thumbnail_cb(
self, texture: Optional[Gdk.Texture] = None, open_folder: bool = False
) -> None:
idle_add(
self.play_button.set_visible,
texture
Expand All @@ -305,6 +304,13 @@ def __thumbnail_cb(self, texture: Optional[Gdk.Texture] = None) -> None:
),
)

if self.is_dir:
texture = (
shared.open_folder_texture
if open_folder
else shared.closed_folder_texture
)

idle_add(self.picture.set_visible, bool(texture))
if not self.is_dir:
for thumbnail in (
Expand Down

0 comments on commit bd951f1

Please sign in to comment.