Merge pull request #177 from brunos3d/feature/flatpakref-support

Add support for .flatpakref file handling
This commit is contained in:
Heliguy
2025-06-10 15:13:13 -04:00
committed by GitHub
3 changed files with 39 additions and 2 deletions

View File

@@ -1,7 +1,7 @@
[Desktop Entry]
# Translators: Do not translate the application name
Name=Warehouse
Exec=warehouse
Exec=warehouse %F
Icon=io.github.flattool.Warehouse
Terminal=false
Type=Application
@@ -10,3 +10,4 @@ StartupNotify=true
Keywords=flatpak;packages;apps;remotes;snapshots;
Comment=Manage all things Flatpak
X-Purism-FormFactor=Workstation;Mobile;
MimeType=application/vnd.flatpak.ref;application/vnd.flatpak;x-scheme-handler/flatpak;

View File

@@ -30,6 +30,8 @@
<control>keyboard</control>
<control>pointing</control>
<control>touch</control>
<mime>application/vnd.flatpak.ref</mime>
<mime>application/vnd.flatpak</mime>
</supports>
<requires>
<display_length compare="ge">330</display_length>

View File

@@ -41,7 +41,7 @@ class WarehouseApplication(Adw.Application):
def __init__(self):
super().__init__(
application_id="io.github.flattool.Warehouse",
flags=Gio.ApplicationFlags.DEFAULT_FLAGS,
flags=Gio.ApplicationFlags.HANDLES_COMMAND_LINE | Gio.ApplicationFlags.HANDLES_OPEN,
)
self.create_action("about", self.on_about_action)
self.create_action("preferences", self.on_preferences_action)
@@ -185,6 +185,40 @@ class WarehouseApplication(Adw.Application):
win = WarehouseWindow(application=self)
win.present()
def do_open(self, files, _n_files, _hint):
"""Handle files opened from file manager or command line"""
win = self.props.active_window
if not win:
win = WarehouseWindow(application=self)
win.present()
# Convert GFiles to file paths
file_list = []
for gfile in files:
file_list.append(gfile)
# Use existing file drop handler
win.on_file_drop(None, file_list, None, None)
def do_command_line(self, command_line):
"""Handle command line arguments"""
args = command_line.get_arguments()
if len(args) > 1: # First arg is program name
files = []
for path in args[1:]:
gfile = Gio.File.new_for_path(path)
if gfile.query_exists():
files.append(gfile)
if files:
self.open(files, "")
return 0
# No valid files, just activate normally
self.activate()
return 0
def on_about_action(self, widget, _a):
"""Callback for the app.about action."""
about = Adw.AboutDialog(