Real Software Forums
http://forums.realsoftware.com/

Carbon + Sanbox + Open and Save dialogs
http://forums.realsoftware.com/viewtopic.php?f=7&t=44162
Page 2 of 2

Author:  rowlands [ Mon Jun 11, 2012 9:48 pm ]
Post subject:  Re: Carbon + Sanbox + Open and Save dialogs

I'm thinking to write a guide on Sandboxing RS applications to make it easier for people. Just gotta find the time to do so.

Author:  Bob Keeney [ Wed Jun 13, 2012 4:45 pm ]
Post subject:  Re: Carbon + Sanbox + Open and Save dialogs

One immediate question that's come out of playing around with the code. How do deal with custom file types? If I had a UTI for a say com.bkeeney.briefs (named changed to protect the guilty), just passing in the UTI doesn't seem to work since I am unable to select anything of those types of files.

Or am I doing something wrong?

Author:  tempel [ Wed Jun 13, 2012 4:58 pm ]
Post subject:  Re: Carbon + Sanbox + Open and Save dialogs

Bob, I believe Sam mention earlier that you have to use old style file types instead of UTIs. It's AppleScript, after all :)

Author:  Bob Keeney [ Wed Jun 13, 2012 5:42 pm ]
Post subject:  Re: Carbon + Sanbox + Open and Save dialogs

Ug. Sorry. Indeed he did. The relevant quote is:

Quote:
You need to use either the 4 character type or the UTI.


Now that I've reread the post :oops: using FileTypes isn't too different but you do have to supply the Creator Code from the FileType. So you have to do this:

//OLD WAY which works cross platform
f = GetOpenFolderItem( MyFileTypes.FileTypeObjectName)

//NEW WAY only works on Mac 10.6? and above
Dim osa as new OSAFileDialog
osa.Types = MyFileTypes.FileTypeObjectName.MacType

Dim f as folderitem = osa.openFile


It's not ideal nor pretty. I'll probably create a generic cross-platform equivalent just to keep my sanity (what little is left).

Author:  rowlands [ Fri Jun 15, 2012 8:18 pm ]
Post subject:  Re: Carbon + Sanbox + Open and Save dialogs

tempel wrote:
Bob, I believe Sam mention earlier that you have to use old style file types instead of UTIs. It's AppleScript, after all :)


UTIs work, for instance to open all images, use "public.image".

Sadly this solution isn't perfect, it's a dirty hack, but it's the only way I could find that works. Hopefully someone else can come up with a better solution.

Author:  rowlands [ Wed Mar 06, 2013 7:35 am ]
Post subject:  Re: Carbon + Sanbox + Open and Save dialogs

Bob Keeney wrote:
One immediate question that's come out of playing around with the code. How do deal with custom file types? If I had a UTI for a say com.bkeeney.briefs (named changed to protect the guilty), just passing in the UTI doesn't seem to work since I am unable to select anything of those types of files.

Or am I doing something wrong?

Just noticed this after so long - but I think the problem maybe that RS doesn't include the full UTI spec in the plist file. Once you've added the UTI within RS, use something like App Wrapper to add the descriptive information to the info.plist ( on the docs & utis page).

Author:  baquiano [ Fri May 03, 2013 12:21 pm ]
Post subject:  Re: Carbon + Sanbox + Open and Save dialogs

rowlands wrote:
I'm thinking to write a guide on Sandboxing RS applications to make it easier for people. Just gotta find the time to do so.
Just the time you've spent creating AppWrapper and supporting Open/Save for Carbon is good enough. Thanks!

Edit: Downloaded the MBS plugin from http://www.monkeybreadsoftware.de/realbasic/plugin-cocoa.shtml and it worked like a charm! Now, I'll test it in my project. Thanks again.

Edit: Grabbed the OSADialog class and copied it to my project. Added the following code:
#if TargetMacOS then
Dim major, minor, bug As Integer

If System.Gestalt("sys1", major) Then
If System.Gestalt("sys2", minor) Then
If System.Gestalt("sys3", bug) Then

End If
End If
End If
if major = 10 and minor >= 7 then
Dim osa as new OSAFileDialog
osa.DefaultName = "Untitled.xml"
f = osa.SaveFile
else
f = getSAveFolderItem("Package","Untitled.xml")
end if
#else
f = getSAveFolderItem("Package","Untitled.xml")
#endif


and my Carbon project worked just fine. The first part was copied from the Language Reference: uses System.Gestalt to check whether the OS is Snow Leopard or Lion and above. If Snow Leopard (or Windows), it uses the standard Save dialog. If OSX 10.7 and above (which is the Sandboxed app I'll submit to the MAS), will use the custom class. Next step is to replace all the Open/Save dialog code and submit the app.

Author:  Akiland [ Fri May 03, 2013 12:59 pm ]
Post subject:  Re: Carbon + Sanbox + Open and Save dialogs

rowlands wrote:
I'm thinking to write a guide on Sandboxing RS applications to make it easier for people. Just gotta find the time to do so.

That would be really sweet!
Let me know if you do :)

Page 2 of 2 All times are UTC - 5 hours
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/