[squeak-dev] Double click on an data file

Edgar J. De Cleene edgardec2001 at yahoo.com.ar
Mon Jul 14 20:06:01 UTC 2008




El 7/14/08 2:14 PM, "Javier Reyes" <jreyes at gmail.com> escribió:

> Hello !
> 
> I have created a Mac Application which stores certain information in files.
> These files are saved using Reference Stream. I have obviously provided a
> mechanism to read them back, but my problem comes if a user double clicks on
> the file icon at the Mac Osx operating system level. When that happens, the
> application opens with it's last image and the file is read as a text in a
> SystemWindow (Lots of fancy binary simbols!).  Is there a way I can control
> which method takes responsability of that process ?
> 
> All the best,
>                             Javier

Use services.
You could made any exterrnal file was processed using your logic.
I add two examples of my own use, one for read objects saved to  disk the
other for my own "SqueakBooks"

Edgar

-------------- next part --------------
'From SqueakLight|II of 31 May 2008 [latest update: #7195] on 14 July 2008 at 5:02:38 pm'!


!Object class methodsFor: '*services-extras' stamp: 'edc 2/14/2008 08:24'!
fileReaderServicesForFile: fullName suffix: suffix
	| services |
	services _ OrderedCollection new.
	
	(fullName asLowercase endsWith: '.obj')
		ifTrue: [ services add: self serviceLoadObject ].
	^services! !

!Object class methodsFor: '*services-extras' stamp: 'edc 2/14/2008 08:26'!
serviceLoadObject
"Answer a service for opening a saved Object"

	^ (SimpleServiceEntry 
		provider: self 
		label: 'saved Object'
		selector: #readAndInspect:
		description: 'open a Object'
		buttonLabel: 'object')
		argumentGetter: [:fileList | fileList readOnlyStream]! !
-------------- next part --------------

!MiStack class methodsFor: '*services-extras' stamp: 'edc 10/25/2006 17:45'!
registeredServices
	^ { 
	Service new
		label: 'Open saved SqueakBook';
		shortLabel: 'SqueakBook'; 
		description: 'load back saved notes ';
		action: [:stream | self unzip: (FileStream oldFileOrNoneNamed:stream name)];
		shortcut: nil;
		categories: Service worldServiceCat.} ! !

!MiStack class methodsFor: '*services-extras' stamp: 'edc 9/7/2006 10:58'!
fileReaderServicesForFile: fullName suffix: suffix
	| services |
	services _ OrderedCollection new.
	
	(fullName asLowercase endsWith: '.shc')
		ifTrue: [ services add: self serviceLoadSqueakBook ].
	^services! !

!MiStack class methodsFor: '*services-extras' stamp: 'edc 10/25/2006 17:43'!
serviceLoadSqueakBook
"Answer a service for opening a saved SqueakBook"

	^ (SimpleServiceEntry 
		provider: self 
		label: 'saved SqueakBook'
		selector: #unzip:
		description: 'open a SqueakBook'
		buttonLabel: 'SqueakBook')
		argumentGetter: [:fileList | fileList readOnlyStream]! !


More information about the Squeak-dev mailing list