path.split( '/' ).last.split( '.' ).first
> item= self.template_menu.addItemWithTitle( title,
> action:"open_engine_template:", keyEquivalent:"" )
> item.setTarget( self )
> end
>
> examples= bundle.pathsForResourcesOfType( "cnc",
> inDirectory:"Examples" )
> examples.each do | path |
> title = path.split( '/' ).last.split( '.' ).first
> item= self.example_menu.addItemWithTitle( title,
> action:"open_document_template:", keyEquivalent:"" )
> item.setTarget( self )
> end
> end
>
> def makeNewMachine( sender )
> makeNewDocument( "Machine" )
> end
>
> def makeNewEngine( sender )
> makeNewDocument( "Engine" )
> end
>
> def makeNewDocument( type )
> ErrorLog.instance.warn( "makeNewDocument #{ type }" )
>
> nserror = Pointer.new( :object )
> controller = NSDocumentController.sharedDocumentController
> document= controller.makeUntitledDocumentOfType( type,
> error:nserror )
> if document
> controller.addDocument( document )
> document.makeWindowControllers
> document.showWindows
>
> else
> ErrorLog.instance.error( "Error creating new #{ type }
> Document" )
> end
>
> document
> end
>
> def open_engine_template( sender )
> open_file( NSBundle.mainBundle.pathForResource( sender.title,
> ofType:"engine", inDirectory:"Templates" ) )
> end
>
> def open_machine_template( sender )
> open_file( NSBundle.mainBundle.pathForResource( sender.title,
> ofType:"machine", inDirectory:"Templates" ) )
> end
>
> def open_document_template( sender )
> open_file( NSBundle.mainBundle.pathForResource( sender.title,
> ofType:"cnc", inDirectory:"Examples" ) )
> end
>
> def open_file( path )
> url = NSURL.fileURLWithPath( path )
> nserror = Pointer.new( :object )
>
> NSDocumentController.sharedDocumentController.openDocumentWithContentsOfURL(
> url,
> display:true, error:nserror )
> end
>
> end
>
>
>
> -- next part --
> An HTML attachment was scrubbed...
> URL:
> <http://lists.macosforge.org/pipermail/macruby-devel/attachments/20131110/7846250a/attachment.html>
>
> --
>
> ___
> MacRuby-devel mailing list
> [email protected]
> https://lists.macosforge.org/mailman/listinfo/macruby-devel
>
>
> End of MacRuby-devel Digest, Vol 66, Issue 12
> *
___
MacRuby-devel mailing list
[email protected]
https://lists.macosforge.org/mailman/listinfo/macruby-devel