[squeak-dev] The Inbox: Tools-hmm.236.mcz
Hannes Hirzel
hannes.hirzel at gmail.com
Thu Apr 29 03:42:38 UTC 2010
Hello
I loaded Tools-hmm.236.mcz into a pristine 4.1 image updated to the
last trunk 10025.
It displays PNG and JPG pictures (tested) and probably others (not
tested) nicely.
The graphic is loaded through
form := Form fromFileNamed: self fullName.
I vote for inclusion into the trunk
Thank you Hans-Martin for this very nice and needed contribution.
--Hannes
On Tue, 27 Apr 2010 18:47:13.803 0000, commits at source.squeak.org
<commits at source.squeak.org> wrote:
> A new version of Tools was added to project The Inbox:
> http://source.squeak.org/inbox/Tools-hmm.236.mcz
>
> ==================== Summary ====================
>
> Name: Tools-hmm.236
> Author: hmm
> Time: 27 April 2010, 8:46:59.789 pm
> UUID: 283b99fb-15fd-45b6-81f0-49a6bb6bea15
> Ancestors: Tools-ar.235
>
> Display image files (graphics) in FileList
>
> =============== Diff against Tools-ar.235 ===============
>
> Item was added:
> + ----- Method: FileList>>stepTimeIn: (in category 'private') -----
> + stepTimeIn: aWindow
> + ^500!
>
> Item was added:
> + ----- Method: FileList>>readGraphicContents (in category 'private') -----
> + readGraphicContents
> + | form maxExtent ext |
> + form := Form fromFileNamed: self fullName.
> + maxExtent := lastGraphicsExtent := self availableGraphicsExtent.
> + ext := form extent.
> + (maxExtent notNil and: [form extent <= maxExtent]) ifFalse: [
> + form := form magnify: form boundingBox by: (maxExtent x / form width
> min: maxExtent y / form height) asPoint smoothing: 3].
> + contents := ('Image extent: ', ext printString) asText,
> + (String with: Character cr),
> + (Text string: ' '
> + attribute: (TextFontReference toFont:
> + (FormSetFont new
> + fromFormArray: (Array with: form)
> + asciiStart: Character space asInteger
> + ascent: form height))).
> + brevityState := #graphic.
> + ^contents!
>
> Item was added:
> + ----- Method: FileList>>step (in category 'private') -----
> + step
> + | ext |
> + brevityState = #graphic ifTrue: [
> + ext := self availableGraphicsExtent.
> + ext = lastGraphicsExtent ifFalse: [
> + lastGraphicsExtent := ext.
> + brevityState := #needToGetGraphic.
> + self changed: #contents]]!
>
> Item was added:
> + ----- Method: FileList>>availableGraphicsExtent (in category 'private')
> -----
> + availableGraphicsExtent
> + self dependents do: [:each |
> + ((each isKindOf: PluggableTextMorph) and: [each getTextSelector ==
> #contents]) ifTrue: [^each innerBounds extent - (6 at 22)]].
> + ^nil!
>
> Item was added:
> + ----- Method: FileList>>isGraphicsFileSelected (in category 'private')
> -----
> + isGraphicsFileSelected
> + ^fileName notNil and: [((self itemsForFile: self fullName) detect: [:each
> | each provider == Form and: [each selector == #importImage:]] ifNone: [])
> notNil]!
>
> Item was changed:
> ----- Method: FileList>>fileListIndex: (in category 'file list') -----
> fileListIndex: anInteger
> "Select the file name having the given index, and display its contents."
>
> | item name |
> self okToChange ifFalse: [^ self].
> listIndex := anInteger.
> listIndex = 0
> ifTrue: [fileName := nil]
> ifFalse:
> [item := self fileNameFromFormattedItem: (list at: anInteger).
> (item endsWith: self folderString)
> ifTrue:
> ["remove [...] folder string and open the folder"
> name := item copyFrom: 1 to: item size - self folderString size.
> listIndex := 0.
> brevityState := #FileList.
> self addPath: name.
> name first = $^
> ifTrue: [self directory: (ServerDirectory serverNamed: name
> allButFirst)]
> ifFalse: [volListIndex = 1 ifTrue: [name := name, directory slash].
> self directory: (directory directoryNamed: name)]]
> ifFalse: [fileName := item]]. "open the file selected"
>
> + brevityState := self isGraphicsFileSelected
> + ifTrue: [#needToGetGraphic]
> + ifFalse: [#needToGetBrief]..
> - brevityState := #needToGetBrief.
> self changed: #fileListIndex.
> self changed: #contents.
> self updateButtonRow!
>
> Item was changed:
> ----- Method: FileList>>contents (in category 'private') -----
> contents
> "Answer the contents of the file, reading it first if needed."
> "Possible brevityState values:
> FileList,
> fullFile, briefFile, needToGetFull, needToGetBrief,
> fullHex, briefHex, needToGetFullHex, needToGetBriefHex"
>
> (listIndex = 0) | (brevityState == #FileList) ifTrue: [^ self
> defaultContents]. "no file selected"
> brevityState == #fullFile ifTrue: [^ contents].
> brevityState == #fullHex ifTrue: [^ contents].
> brevityState == #briefFile ifTrue: [^ contents].
> brevityState == #briefHex ifTrue: [^ contents].
> + brevityState == #graphic ifTrue: [^ contents].
>
> + brevityState == #needToGetGraphic ifTrue: [^self readGraphicContents].
> +
> brevityState == #needToGetFullHex ifTrue: [^ self readContentsHex:
> false].
> brevityState == #needToGetBriefHex ifTrue: [^ self readContentsHex:
> true].
>
> brevityState == #needToGetFull ifTrue: [^ self readContentsBrief: false].
> brevityState == #needToGetBrief ifTrue: [^ self readContentsBrief: true].
> "default"
>
> (TextConverter allEncodingNames includes: brevityState)
> ifTrue: [ ^self readContentsAsEncoding: brevityState].
>
> self halt: 'unknown state ' , brevityState printString!
>
> Item was changed:
> StringHolder subclass: #FileList
> + instanceVariableNames: 'fileName directory volList volListIndex list
> listIndex pattern sortMode brevityState directoryCache lastGraphicsExtent'
> - instanceVariableNames: 'fileName directory volList volListIndex list
> listIndex pattern sortMode brevityState directoryCache'
> classVariableNames: 'FileReaderRegistry RecentDirs'
> poolDictionaries: ''
> category: 'Tools-FileList'!
>
> !FileList commentStamp: 'nk 11/26/2002 11:52' prior: 0!
> I am model that can be used to navigate the host file system. By omitting
> the volume list, file list, and template panes from the view, I can also be
> used as the model for an editor on an individual file.
>
> The FileList now provides a registration mechanism to which any tools the
> filelist uses ***MUST*** register. This way it is possible to dynamically
> load or unload a new tool and have the FileList automatically updated. This
> change supports a decomposition of Squeak and removes a problem with dead
> reference to classes after a major shrink.
>
> Tools should implement the following methods (look for implementors in the
> image):
>
> #fileReaderServicesForFile:suffix: (appropriate services for given file,
> takes a file name and a lowercased suffix)
>
> #services (all provided services, to be displayed in full list)
>
> These methods both return a collection of SimpleServiceEntry instances.
> These contain a class, a menu label and a method selector having one
> argument. They may also provide separate button labels and description.
>
> The argument to the specified method will be a string representing the
> full name of a file when one is selected or the file list itself when there
> is no selected file.
>
> Tools must register with the FileList calling the class method
> #registerFileReader: when they load. They also must call
> #unregisterFileReader: when they unload.
>
> There is a testSuite called FileListTest that presents some examples.
>
> Stef (I do not like really this distinction passing always a file list
> could be better)
>
>
> Old Comments:
>
>
> FileLists can now see FTP servers anywhere on the net. In the volume list
> menu:
> fill in server info... Gives you a form to register a new ftp server you
> want to use.
> open server... Choose a server to connect to.
> local disk Go back to looking at your local volume.
>
>
> Still undone (you can contribute code):
> [ ] Using a Proxy server to get out through a firewall. What is the
> convention for proxy servers with FTP?
> [ ] Fill in the date and size info in the list of remote files. Allow
> sorting by it. New smarts needed in (ServerDirectory
> fileNameFormattedFrom:sizePad:sortMode:).
> [ ] Currently the FileList has no way to delete a directory. Since you
> can't select a directory without going into it, it would have to be deleting
> the current directory. Which would usually be empty.!
>
> Item was added:
> + ----- Method: FileList>>wantsSteps (in category 'private') -----
> + wantsSteps
> + ^true!
>
>
>
More information about the Squeak-dev
mailing list
|