diff --git a/data/io.github.flattool.Warehouse.desktop.in b/data/io.github.flattool.Warehouse.desktop.in
index 9bb8a8d..71fd638 100644
--- a/data/io.github.flattool.Warehouse.desktop.in
+++ b/data/io.github.flattool.Warehouse.desktop.in
@@ -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;
diff --git a/data/io.github.flattool.Warehouse.metainfo.xml.in b/data/io.github.flattool.Warehouse.metainfo.xml.in
index 8676c1d..c4f029a 100644
--- a/data/io.github.flattool.Warehouse.metainfo.xml.in
+++ b/data/io.github.flattool.Warehouse.metainfo.xml.in
@@ -30,6 +30,8 @@
keyboard
pointing
touch
+ application/vnd.flatpak.ref
+ application/vnd.flatpak
330
diff --git a/src/main.py b/src/main.py
index 0974c11..dd84c96 100644
--- a/src/main.py
+++ b/src/main.py
@@ -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(