Recent

Author Topic: Register default application  (Read 3030 times)

Ove Halseth

  • Newbie
  • Posts: 6
Register default application
« on: April 19, 2017, 03:11:33 pm »
Hi,

Is it any way to programatically register a default application for a custom file-ending?

So that .wiskrypt files is opened by my application.

Found this page that describes how to do it manually:
http://www.bittbox.com/os-x/how-to-set-the-default-program-to-open-a-certain-type-of-file-in-mac-os-x

Ove B-)

Phil

  • Hero Member
  • *****
  • Posts: 2737
Re: Register default application
« Reply #1 on: April 19, 2017, 04:17:30 pm »
Is it any way to programatically register a default application for a custom file-ending?

You do that in your app's Info.plist file. Since Lazarus does not provide any way to edit that in the IDE, you'll need to edit the Info.plist with a text editor. See any app's Info.plist to see how they associate a file type with an app action (for example, see how Lazarus does it). See also Apple's docs on the subject.

You may also find this page helpful with other Mac related questions:

https://macpgmr.github.io/MacXPlatform/LazXProj.html

Hansaplast

  • Hero Member
  • *****
  • Posts: 674
  • Tweaking4All.com
    • Tweaking4All
Re: Register default application
« Reply #2 on: April 19, 2017, 04:19:51 pm »
Maybe these articles help:


Apple Dev document (written for iOS but seems applicable for macOS as well - reference):  Registering the File Types Your App Supports


I found at least 2 more related topics at StackExchange:
 - overriding Mac app file associations via CFBundleDocumentTypes in info.plist
 - How to set default application for specific file types in Mac OS X?
 - Mac OS X file association works, but file icon not changed


As far as I read, these all work based on the Info.plist file in your .app bundle.
plist example that I found in one of these topics:


Code: Pascal  [Select][+][-]
  1. <key>CFBundleDocumentTypes</key>
  2. <array>
  3.     <!-- Registered file accociation -->
  4.     <dict>
  5.         <key>CFBundleTypeRole</key>
  6.         <string>Editor</string>
  7.         <key>CFBundleTypeName</key>
  8.         <string>XYZ</string>
  9.         <key>CFBundleTypeExtensions</key>
  10.         <array>
  11.             <string>xyz</string>
  12.         </array>
  13.         <key>CFBundleTypeIconFile</key>
  14.         <string>XYZ</string>
  15.     </dict>
  16. <array>


I have not yet tested this myself. This seems the correct way of doing it.


Hope this helps ...

Hansaplast

  • Hero Member
  • *****
  • Posts: 674
  • Tweaking4All.com
    • Tweaking4All
Re: Register default application
« Reply #3 on: April 19, 2017, 04:21:02 pm »
Sorry Phil - I guess we posted at almost the same time   :D

 

TinyPortal © 2005-2018