Skip to content

Commit

Permalink
fixed error on windows that lead filechooser to not filter root direc…
Browse files Browse the repository at this point in the history
…tory and .sys files
  • Loading branch information
qlrd committed Oct 17, 2024
1 parent f53416b commit 2ce3a25
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 2 deletions.
1 change: 1 addition & 0 deletions .ci/create-spec.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@
# to keep `sys` module enabled (necessary for Kboot)
BUILDER_ARGS.append("--onefile")
BUILDER_ARGS.append("--console")
BUILDER_ARGS.append("--hidden-import=win32timezone")
BUILDER_ARGS.append("--hide-console=minimize-early")

elif SYSTEM == "Darwin":
Expand Down
19 changes: 18 additions & 1 deletion src/app/screens/airgap_update_screen.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
main_screen.py
"""
import os
import sys
import shutil
from functools import partial
from kivy.clock import Clock
Expand Down Expand Up @@ -76,14 +77,30 @@ def on_load(path):

setattr(AirgapUpdateScreen, "on_load", on_load)

self.make_grid(wid=f"{self.id}_grid", rows=1)
def on_filter_sys(directory, filename):
if sys.platform == "win32":
return not directory == "C:\\" and not filename.endswith(".sys")
return True

def on_filter_dumpstack(directory, filename):
if sys.platform == "win32":
return not directory == "C:\\" and not filename.endswith(
"DumpStack.log.tmp"
)
return True

setattr(
AirgapUpdateScreen, "on_filters_list", [on_filter_sys, on_filter_dumpstack]
)

self.make_grid(wid=f"{self.id}_grid", rows=1)
self.make_file_chooser(
wid=f"{self.id}_select",
root_widget=f"{self.id}_grid",
view_mode="icon",
font_factor=44,
on_load=getattr(AirgapUpdateScreen, "on_load"),
on_filters_list=getattr(AirgapUpdateScreen, "on_filters_list"),
)

fn = partial(self.update, name=self.name, key="canvas")
Expand Down
3 changes: 2 additions & 1 deletion src/app/screens/base_screen.py
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,7 @@ def make_file_chooser(
view_mode: str,
font_factor: int,
on_load: typing.Callable,
on_filters_list: typing.Callable,
):
"""Build a file chooser for airgap screen"""
box = BoxLayout(orientation="vertical")
Expand Down Expand Up @@ -298,7 +299,7 @@ def on_size(instance, value):
self.ids[btn.id] = WeakProxy(btn)

# File chooser
file_chooser = FileChooserIconView()
file_chooser = FileChooserIconView(filters=on_filters_list)
file_chooser.id = f"{wid}_chooser"
file_chooser.dirselect = True

Expand Down

0 comments on commit 2ce3a25

Please sign in to comment.