|
From: creedon <icr...@us...> - 2005-06-14 01:08:26
|
Update of /cvsroot/frontierkernel/odbs/frontierRoot/system/verbs/builtins/app In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27928 Modified Files: startWithDocument Log Message: added mac os x app may be folders to fileIsApp handler, file.creator check Index: startWithDocument =================================================================== RCS file: /cvsroot/frontierkernel/odbs/frontierRoot/system/verbs/builtins/app/startWithDocument,v retrieving revision 1.1.1.1 retrieving revision 1.2 diff -C2 -d -r1.1.1.1 -r1.2 *** startWithDocument 26 Mar 2005 19:42:35 -0000 1.1.1.1 --- startWithDocument 14 Jun 2005 01:08:16 -0000 1.2 *************** *** 1,3 **** FrontierVcsFile:1:scpt:system.verbs.builtins.app.startWithDocument ! on startWithDocument (appTable, docPath) { Çstart talking with the application, might launch it Çadr is the address of an application's glue table, usually in system.verbs.apps Çif the application isn't running, try to launch it Çif the path isn't the program, use file.getFileDialog Çkeep the path updated Çreturns true if the application is launched and ready to talk Çv2.0 dmb: added document support Çv3.0 dmb: handle difference between nil and the empty string for docPath Çzero means normal launch w/out a specific document Ç"" means inhibit default document or open file dialog ÇChanges: Ç1/7/02; 11:44:10 PM by PBS ÇOn OS X apps may be folders. If so, then the path to the app is okay, don't prompt for it again. appTable = address (appTable); bundle { Çbody of app.start local (infoTable); Çthe application's appInfo table local (name, id, path, app1Supported, sharedMenus); on copyFromInfoTable () { Çcopy infoTable values into this script's locals name = infoTable^.name; id = infoTable^.id; path = infoTable^.path; app1Supported = infoTable^.app1Supported; sharedMenus = infoTable^.sharedMenus}; on appRunning () { Çreturn true if the application is running if defined (app.idnetworkapp) { Çregistration already taken care of id = app.idnetworkapp; return (true)}; if sys.appIsRunning (id) { if string.length (infoTable^.path) == 0 { Çhasn't been set yet infoTable^.path = sys.getAppPath (id)}; return (true)}; return (false)}; on fileIsApp () { Çreturn true if the path points to our application if sizeof (path) == 0 { return (false)}; if not file.exists (path) { return (false)}; if file.type (path) != 'APPL' { if not (system.environment.isCarbon and file.isFolder (path)) { //PBS 01/07/02: OS X apps may be folders return (false)}}; if file.creator (path) != id { return (false)}; return (true)}; on searchForApp () { Çreturns empty string if we failed, full path if we won local (folder); folder = file.folderFromPath (Frontier.getFilePath ()) + "UserLand Utilities:"; if file.exists (folder) { local (f); fileloop (f in folder, infinity) { if (file.type (f) == 'APPL') and (file.creator (f) == id) { return (f)}}}; return ("")}; on promptForPath () { Çget the application's path from the user local (newpath); newpath = searchForApp (); if newpath == "" { Çour very limited search strategy failed Frontier.bringToFront (); Çbe sure Frontier is the frontmost app newpath = file.findApplication (infoTable^.id); if not file.getFileDialog ("Where is " + name + "?", @newpath, 'APPL') { return (false)}}; infoTable^.path = newpath; infoTable^.id = file.creator (newpath); if sizeof (infoTable^.name) == 0 { Çhasn't been set yet infoTable^.name = file.fileFromPath (path)}; copyFromInfoTable (); return (true)}; on launchApp () { Çreturn true if we're able to launch the application msg ("Launching " + name + "..."); if typeof (docPath) == unknowntype { if not launch.application (path) { return (false)}} else { if not launch.appWithDocument (path, docPath) { return (false)}}; docPath = ""; Çclear path so we'll know not to open it again return (true)}; bundle { Çbe sure the app's appInfo table is set up properly if not defined (appTable^) { Çpassing in a bogus address scriptError ("The application doesn't have a Frontier \"glue\" table.")}; infoTable = @appTable^.appInfo; if not defined (infoTable^) { Çno appInfo table, create one with initial values new (tableType, infoTable); infoTable^.name = nameOf (appTable^); infoTable^.id = '????'; infoTable^.path = ""; infoTable^.app1Supported = false; infoTable^.sharedMenus = false}; copyFromInfoTable (); appTable^.id = id}; Çside-effect -- makes life easier for glue scripts while (not appRunning ()) { if not fileIsApp () { if not promptForPath () { Çuser clicked on Cancel return (false)}}; if launchApp () { break}; path = ""}; Çnext time try for a different file bundle { Çset up the app table in the object database for this application app.id = id; Çall app verbs are sent to this application appTable^.id = id; Çmake life easy for the app's glue scripts app.adrAppTable = appTable; Çthe app verbs can refer to current app's info table Çbundle Çfuss with the paths table Çlocal (adr = @system.misc.paths.app1path) Çif app1Supported Çapp verbs are global Çadr^ = @system.verbs.builtins.app Çelse Çapp verbs are undefined, or require a full path Çif defined (adr^) Çdelete (adr)}; if docPath != "" { Çtell app to open the document required.openDocument (id, docPath)}; msg (""); Çrelease message area return (true)}} \ No newline at end of file --- 1,3 ---- FrontierVcsFile:1:scpt:system.verbs.builtins.app.startWithDocument ! on startWithDocument (appTable, docPath) { Çstart talking with the application, might launch it ÇChanges Ç4/30/05; 9:15:10 AM by TAC Çadded mac os x app may be folders to fileIsApp handler, file.creator check Ç1/7/02; 11:44:10 PM by PBS ÇOn OS X apps may be folders. If so, then the path to the app is okay, don't prompt for it again. Çv3.0 dmb Çhandle difference between nil and the empty string for docPath Çzero means normal launch w/out a specific document Ç"" means inhibit default document or open file dialog Çv2.0 dmb Çadded document support Çadr is the address of an application's glue table, usually in system.verbs.apps Çif the application isn't running, try to launch it Çif the path isn't the program, use file.getFileDialog Çkeep the path updated Çreturns true if the application is launched and ready to talk appTable = address (appTable); bundle { Çbody of app.start local (infoTable); Çthe application's appInfo table local (name, id, path, app1Supported, sharedMenus); on copyFromInfoTable () { Çcopy infoTable values into this script's locals name = infoTable^.name; id = infoTable^.id; path = infoTable^.path; app1Supported = infoTable^.app1Supported; sharedMenus = infoTable^.sharedMenus}; on appRunning () { Çreturn true if the application is running if defined (app.idnetworkapp) { Çregistration already taken care of id = app.idnetworkapp; return (true)}; if sys.appIsRunning (id) { if string.length (infoTable^.path) == 0 { Çhasn't been set yet infoTable^.path = sys.getAppPath (id)}; return (true)}; return (false)}; on fileIsApp () { Çreturn true if the path points to our application if sizeof (path) == 0 { return (false)}; if not file.exists (path) { return (false)}; if file.type (path) != 'APPL' { if not (system.environment.isCarbon and file.isFolder (path)) { //PBS 01/07/02: OS X apps may be folders return (false)}}; if file.creator (path) != id { if not (system.environment.isCarbon and file.isFolder (path)) { // 4/30/05; 9:15:10 AM by TAC - os x apps may be folders return (false)}}; return (true)}; on searchForApp () { Çreturns empty string if we failed, full path if we won local (folder); folder = file.folderFromPath (Frontier.getFilePath ()) + "UserLand Utilities:"; if file.exists (folder) { local (f); fileloop (f in folder, infinity) { if (file.type (f) == 'APPL') and (file.creator (f) == id) { return (f)}}}; return ("")}; on promptForPath () { Çget the application's path from the user local (newpath); newpath = searchForApp (); if newpath == "" { Çour very limited search strategy failed Frontier.bringToFront (); Çbe sure Frontier is the frontmost app newpath = file.findApplication (infoTable^.id); if not file.getFileDialog ("Where is " + name + "?", @newpath, 'APPL') { return (false)}}; infoTable^.path = newpath; infoTable^.id = file.creator (newpath); if sizeof (infoTable^.name) == 0 { Çhasn't been set yet infoTable^.name = file.fileFromPath (path)}; copyFromInfoTable (); return (true)}; on launchApp () { Çreturn true if we're able to launch the application msg ("Launching " + name + "..."); if typeof (docPath) == unknowntype { if not launch.application (path) { return (false)}} else { if not launch.appWithDocument (path, docPath) { return (false)}}; docPath = ""; Çclear path so we'll know not to open it again return (true)}; bundle { Çbe sure the app's appInfo table is set up properly if not defined (appTable^) { Çpassing in a bogus address scriptError ("The application doesn't have a Frontier \"glue\" table.")}; infoTable = @appTable^.appInfo; if not defined (infoTable^) { Çno appInfo table, create one with initial values new (tableType, infoTable); infoTable^.name = nameOf (appTable^); infoTable^.id = '????'; infoTable^.path = ""; infoTable^.app1Supported = false; infoTable^.sharedMenus = false}; copyFromInfoTable (); appTable^.id = id}; Çside-effect -- makes life easier for glue scripts while (not appRunning ()) { if not fileIsApp () { if not promptForPath () { Çuser clicked on Cancel return (false)}}; if launchApp () { break}; path = ""}; Çnext time try for a different file bundle { Çset up the app table in the object database for this application app.id = id; Çall app verbs are sent to this application appTable^.id = id; Çmake life easy for the app's glue scripts app.adrAppTable = appTable; Çthe app verbs can refer to current app's info table Çbundle Çfuss with the paths table Çlocal (adr = @system.misc.paths.app1path) Çif app1Supported Çapp verbs are global Çadr^ = @system.verbs.builtins.app Çelse Çapp verbs are undefined, or require a full path Çif defined (adr^) Çdelete (adr)}; if docPath != "" { Çtell app to open the document required.openDocument (id, docPath)}; msg (""); Çrelease message area return (true)}}; Çbundle // test ÇstartWithDocument ("Safari", nil) \ No newline at end of file |