Opened 4 years ago

Closed 4 years ago

Last modified 4 years ago

#60646 closed enhancement (wontfix)

app portgroup -- accept drag-and-dropped files from the Finder

Reported by: kencu (Ken) Owned by:
Priority: Normal Milestone:
Component: ports Version:
Keywords: Cc:
Port:

Description

The app PortGroup might be beneficially enhanced to allow files to be drag-and-dropped on the application icon and opened in the normal mac fashion.

This Info.plist would need to be enhanced to allow the proper entries for the accepted file types.

The launch script would need to be enhanced to pass the documents to be opened to the application. -psn would need to be managed possibly, depending on the OS version.

Change History (7)

comment:1 Changed 4 years ago by ryandesign (Ryan Carsten Schmidt)

Is there a specific program that you have in mind where this feature would actually work?

I had expected that any program wanting to support macOS to such an extent would be providing their own app bundle.

The portgroup was originally created to make it easy to wrap libSDL games, which do behave like proper Mac apps but have no need to support opening files.

comment:2 Changed 4 years ago by kencu (Ken)

It may not be possible, but I think that with the proper entry in the Info.plist, if you drag and drop a file onto the app icon, it would be passed on to the shell script as an argument. Then, after screening out the -psn if needed, you would do something like this:

exec /opt/local/bin/gedit "${@}"

and gedit would open the file. Hopefully.

In an ideal world, gedit might come up as an option for opening the file when you right-or-control click on it too.

Gedit is pretty excellent -- in fact, remarkable excellent. I currently use bbedit mostly, but my current version won't work on Catalina as it's apparently somehow still i386.

comment:3 Changed 4 years ago by kencu (Ken)

Ah, it's been a while since I did this.

something like this in the plist file gives Gedit the ability to respond to files dropped on it:

    <key>CFBundleDocumentTypes</key>
  	<array>
  		<dict>
  			<key>CFBundleTypeExtensions</key>
  			<array>
  				<string>*</string>
  			</array>
  			<key>CFBundleTypeIconFile</key>
  			<string></string>
  			<key>CFBundleTypeName</key>
  			<string>Text Document</string>
  			<key>CFBundleTypeRole</key>
  			<string>Editor</string>
  			<key>CFBundleTypeOSTypes</key>
  			<array>
  				<string>****</string>
  			</array>
  		</dict>
  	</array>

but then I just get this when I try to drop something on the app

Jun 13 14:05:12 MacBook-Pro com.apple.xpc.launchd[1] (com.apple.xpc.launchd.domain.pid.gedit.2248): Failed to bootstrap path: path = /opt/local/bin/gedit, error = 2: No such file or directory

and the on-screen message is "gedit cannot open files in the "text" format.

Which is either me (probably) or GateKeeper (says the Internet ..).

Last edited 4 years ago by kencu (Ken) (previous) (diff)

comment:4 Changed 4 years ago by kencu (Ken)

Maybe I should try using PlatyPus to make a few simple examples first and get it working that way. Then once it works like that, try to move it into the app PG.

Last edited 4 years ago by kencu (Ken) (previous) (diff)

comment:5 Changed 4 years ago by ryandesign (Ryan Carsten Schmidt)

Dragging a file onto an app does not cause macOS to pass that file to the app executable as a command line argument. Instead, the app must implement the application:openFile: and application:openFiles: methods of the NSApplicationDelegate class; NSApplication will call those delegate methods with information about the files. It seems beyond the scope of a portgroup to potentially implement an entire NSApplication-based wrapper for the program to provide this functionality.

comment:6 Changed 4 years ago by kencu (Ken)

Resolution: wontfix
Status: newclosed

ok, no point then

comment:7 Changed 4 years ago by kencu (Ken)

However, I think if some clever person actually wanted to implement this idea someday, py2app might actually be a scriptable general solution. <https://py2app.readthedocs.io/en/latest/tutorial.html>

Note: See TracTickets for help on using tickets.