Javier Reyes | 14 Jul 19:12

Double click on an data file

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


Edgar J. De Cleene | 14 Jul 22:06

Re: Double click on an data file


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

'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]! !

!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]! !

Javier Reyes | 15 Jul 00:48

Re: Double click on an data file

Thanks very much Edgar,

That's exactly what I was looking for.

Best regards,
                            Javier

On Mon, Jul 14, 2008 at 10:06 PM, Edgar J. De Cleene <edgardec2001 <at> yahoo.com.ar> wrote:



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







Gmane