Hi All,

Two related questions.

(1) Managing the default application for documents from a "file manager" type 
of appication.
(2) An "Open With..." menu.

-----------

(1) (Background: MacHg is a "browser" or "file manager" type of application 
(its a GUI for the DVCS mercurial) so its role is to manage files and sometimes 
if the user wants then open these files in the appropriate application.) Its 
quite likely that developers will want to open these documents in an 
application which is not the default. Eg if they are working with .html files 
from within MacHg they will likely be "developing" with / on them and so will 
want these files to open in bbedit, or coda, or DreamWeaver etc, rather than 
Safari, Firefox, or Chrome.

So what is the best way to manage this mapping in MacHg? Have some sort of 
table in the preferences which does this mapping from extensions to 
applications? I don't want to reinvent wheels so if there is already some code 
with is publicly viewable that does this sort of thing I would interested in 
references so I could look it over...

2.
Some users have asked for an "open with" menu to be added to MacHg. I have a 
menu delegate that captures when the contextual menu is firing and I can insert 
a "Open With..." menu at the right place and time in my 'menuNeedsUpdate' call. 
My question is does anyone have any prototype code already written that nicely 
constructs and manages the creation of this "Open With..." menu.

I would of course imagine that the results would be generated from 
LSCopyApplicationURLsForURL, but for me LSCopyApplicationURLsForURL with 
kLSRolesEditor for a file /Users/jason/Documents/myfile.txt file returns the 
following list:

<NSCFArray 0x1228010>(
file://localhost/Developer/Applications/Xcode.app/,
file://localhost/Applications/Microsoft%20Office%202008/Microsoft%20Excel.app/,
file://localhost/Volumes/QuickSilver/Applications%20local/Write/BBEdit.app/,
file://localhost/Volumes/QuickSilver/Applications/TextEdit.app/,
file://localhost/Applications/TextWrangler.app/,
file://localhost/Volumes/QuickSilver/Developer/Applications/Dashcode.app/,
file://localhost/Volumes/TSL/Applications/TextEdit.app/,
file://localhost/Volumes/QuickSilver/Applications%20local/Write/Word%20Processing/Nisus%20Writer%20Express.app/,
file://localhost/Applications%20local/Utilities/File/HexEdit/HexEdit.app/,
file://localhost/Applications/Microsoft%20Office%202008/Microsoft%20Word.app/,
file://localhost/Developer/Applications/AD%20Viewer.app/,
file://localhost/Volumes/TSL/Applications/TextEdit.app/,
file://localhost/Developer/Applications/Dashcode.app/,
file://localhost/Volumes/QuickSilver/Applications%20local/Graphics/Adobe%20Dreamweaver%20CS4/Adobe%20Dreamweaver%20CS4.app/,
file://localhost/Volumes/QuickSilver/Applications%20local/Graphics/Adobe%20Illustrator%20CS4/Adobe%20Illustrator.app/,
file://localhost/Applications%20local/Write/BBEdit.app/,
file://localhost/Applications/TextEdit.app/,
file://localhost/Applications%20local/Graphics/Coda.app/,
file://localhost/Applications%20local/Utilities/iPhone/Stanza.app/
)

Which of course needs a bit of cleanup. Ie remove duplicate applications and 
choose those on the main drive first. If this list is empty or "too" small then 
the application should fall back on kLSRolesViewer.  Ordering preference should 
likely be given to the applications that are currently open. If its easy and 
possible then maybe ordering in the menu should be given by the last time an 
application was run? Then I can imagine if the user actually choose a 
particular application for opening the given file /document then maybe MacHg 
should order that application preferentially in the future higher in the list?  
It should definitely be the first choice in the list for the same file in the 
future. I can imagine other complications / subtleties around this topic. Thus, 
is there some source code somewhere that someone could point out with the 
recommended best practices in this sort of case?

Thanks in advance!
  Jason_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to