'From Squeak3.2alpha of 3 October 2001 [latest update: #4450] on 26 October 2001 at 2:40:49 am'! "Change Set: dropGz-sw Date: 26 October 2001 Author: Scott Wallace When you drop a .gz file onto the icon of a running Squeak application, the contents of it will now be displayed in decompressed form. A more general and modular mechanism is needed to open the right kind of tool upon a drop, but in the interim this provides the convenience that we can quickly see the decompressed contents of .gz files that come flying into our lives via email through direct dNd from the OS, or indeed right from a dNd-friendly email client such as Eudora"! !FileList methodsFor: 'file list menu' stamp: 'sw 10/26/2001 02:36'! viewGZipContents "View the contents of a gzipped file" (directory readOnlyFileNamed: self fullName) viewGZipContents! ! !FileStream methodsFor: 'editing' stamp: 'sw 10/26/2001 02:35'! viewGZipContents "View the contents of a gzipped file" | stringContents | self binary. stringContents _ self contentsOfEntireFile. Cursor wait showWhile: [stringContents _ (GZipReadStream on: stringContents) upToEnd]. stringContents _ stringContents asString withSqueakLineEndings. StringHolder new contents: stringContents; openLabel: 'Decompressed contents of: ', self localName! ! !PasteUpMorph methodsFor: 'dropping/grabbing' stamp: 'sw 10/26/2001 02:25'! dropFiles: anEvent "Handle a number of dropped files from the OS. TODO: - use a more general mechanism for figuring out what to do with the file (perhaps even offering a choice from a menu) - remember the resource location or (when in browser) even the actual file handle " | numFiles stream sketch type image | numFiles _ anEvent contents. 1 to: numFiles do: [:i | stream _ FileStream requestDropStream: i. type _ stream mimeTypes. type ifNotNil: [type _ type first]. "for now just use the first one" "only image files will be handled for now" (type notNil and: [type beginsWith: 'image/']) ifTrue: [stream binary. image _ Form fromBinaryStream: stream. Project current resourceManager addResource: image url: (FileDirectory urlForFileNamed: stream name) asString. sketch _ SketchMorph withForm: image. self addMorph: sketch centeredNear: anEvent position] ifFalse: [(stream name endsWith: '.gz') ifTrue: [stream viewGZipContents] ifFalse: ["just get us a text editor" stream edit]]].! !