mirror of
https://github.com/morgan9e/warehouse
synced 2026-04-14 00:04:08 +09:00
Add support for .flatpakref file handling
This commit is contained in:
36
src/main.py
36
src/main.py
@@ -44,7 +44,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)
|
||||
@@ -188,6 +188,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(
|
||||
|
||||
Reference in New Issue
Block a user