Real Software Forums

The forum for Real Studio and other Real Software products.
[ REAL Software Website | Board Index ]
It is currently Fri Dec 15, 2017 1:30 am
xojo

All times are UTC - 5 hours




Post new topic Reply to topic  [ 23 posts ]  Go to page Previous  1, 2
Author Message
 Post subject: Re: Carbon + Sanbox + Open and Save dialogs
PostPosted: Mon Jun 11, 2012 9:48 pm 
Offline
User avatar

Joined: Fri Sep 30, 2005 11:00 am
Posts: 583
Location: Beautiful Taiwan
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.

_________________
Sam Rowlands
rMBP 15" @ 10.8 & '08 MBA 13" @ 10.6 + 10.7, RB2012
http://www.ohanaware.com/
AppWrapper - Prepare Apps for Mac App Store & OS X 10.8 - http://www.ohanaware.com/appwrapper/


Top
 Profile  
Reply with quote  
 Post subject: Re: Carbon + Sanbox + Open and Save dialogs
PostPosted: Wed Jun 13, 2012 4:45 pm 
Offline
User avatar

Joined: Fri Sep 30, 2005 11:48 am
Posts: 3554
Location: Lenexa, KS
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?

_________________
Bob K.

A blog about being a Real Studio/Xojo developer at http://www.bkeeneybriefs.com


Top
 Profile  
Reply with quote  
 Post subject: Re: Carbon + Sanbox + Open and Save dialogs
PostPosted: Wed Jun 13, 2012 4:58 pm 
Offline

Joined: Fri Sep 30, 2005 10:01 am
Posts: 283
Location: Germany, Munich
Bob, I believe Sam mention earlier that you have to use old style file types instead of UTIs. It's AppleScript, after all :)

_________________
User of RB since first version. Provider of many free and outdated plugins.
Code for sharing: http://www.tempel.org/RB/Resources
Arbed, a unique tool for editing projects: http://www.tempel.org/Arbed
Zip compression classes: http://www.tempel.org/RB/ZipPackage


Top
 Profile  
Reply with quote  
 Post subject: Re: Carbon + Sanbox + Open and Save dialogs
PostPosted: Wed Jun 13, 2012 5:42 pm 
Offline
User avatar

Joined: Fri Sep 30, 2005 11:48 am
Posts: 3554
Location: Lenexa, KS
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).

_________________
Bob K.

A blog about being a Real Studio/Xojo developer at http://www.bkeeneybriefs.com


Top
 Profile  
Reply with quote  
 Post subject: Re: Carbon + Sanbox + Open and Save dialogs
PostPosted: Fri Jun 15, 2012 8:18 pm 
Offline
User avatar

Joined: Fri Sep 30, 2005 11:00 am
Posts: 583
Location: Beautiful Taiwan
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.

_________________
Sam Rowlands
rMBP 15" @ 10.8 & '08 MBA 13" @ 10.6 + 10.7, RB2012
http://www.ohanaware.com/
AppWrapper - Prepare Apps for Mac App Store & OS X 10.8 - http://www.ohanaware.com/appwrapper/


Top
 Profile  
Reply with quote  
 Post subject: Re: Carbon + Sanbox + Open and Save dialogs
PostPosted: Wed Mar 06, 2013 7:35 am 
Offline
User avatar

Joined: Fri Sep 30, 2005 11:00 am
Posts: 583
Location: Beautiful Taiwan
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).

_________________
Sam Rowlands
rMBP 15" @ 10.8 & '08 MBA 13" @ 10.6 + 10.7, RB2012
http://www.ohanaware.com/
AppWrapper - Prepare Apps for Mac App Store & OS X 10.8 - http://www.ohanaware.com/appwrapper/


Top
 Profile  
Reply with quote  
 Post subject: Re: Carbon + Sanbox + Open and Save dialogs
PostPosted: Fri May 03, 2013 12:21 pm 
Offline

Joined: Tue Nov 08, 2005 5:52 pm
Posts: 111
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.


Last edited by baquiano on Fri May 03, 2013 3:33 pm, edited 1 time in total.

Top
 Profile  
Reply with quote  
 Post subject: Re: Carbon + Sanbox + Open and Save dialogs
PostPosted: Fri May 03, 2013 12:59 pm 
Offline
User avatar

Joined: Tue Jan 04, 2011 3:02 am
Posts: 1236
Location: Jönköping, Sweden
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 :)

_________________
Image http://www.linkedin.com/in/albinkiland
Dev. iMac 27" + 2x22" LG (2.8GHz Intel Core i7, 12GB RAM, 120GB SSD) OS X 10.8
Xojo Pro 2013r1


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 23 posts ]  Go to page Previous  1, 2

All times are UTC - 5 hours


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group