[Cuis-dev] Towards a Scalable Desktop

ken.dickey at whidbey.com ken.dickey at whidbey.com
Sun Apr 4 14:47:32 PDT 2021


Hi Juan,

Did a quick pass at import of SVG icons into a ContentPack.

Might be of use.

I used

    https://freecode.com/projects/svg-icons/

but you may have your own favorites.

vvv===vvv
SVGIconsPk := (ContentPack new
	loadContentFrom: '/home/kend/Downloads/SVG-Icons' asDirectoryEntry).
(SVGIconsPk at: 'window_new') openInWorld.
(SVGIconsPk at: 'folder-blue') openInWorld.
^^^===^^^

One step closer ..

Cheers,
-KenD
-------------- next part --------------
'From Cuis 5.0 [latest update: #4552] on 4 April 2021 at 2:26:31 pm'!

!String methodsFor: 'converting' stamp: 'KenD 4/4/2021 14:09:57'!
withoutDotSuffix
"
	'foo.svg' withoutDotSuffix.  	--> 'foo' 
	'barzot' withoutDotSuffix . 	--> 'barzot' 
	'foo.bar.baz' withoutDotSuffix. --> 'foo.bar' 
"
	^(self prefixAndSuffix: $. )
		ifNotNil: [ :pair  | pair first ]
		ifNil: [self ]! !


!ContentPack methodsFor: 'importing' stamp: 'KenD 4/4/2021 14:10:39'!
loadContentFrom: aDirectoryEntry
	"Load content in us, from files.
	Start with an empty instance!!"

	(self supportedFilesIn: aDirectoryEntry) do: [ :filename |			
		self flag: #todo. "Add hook for other media types here. Also consider renaming this method. --cbr"
		self at: filename name withoutDotSuffix
			put: (Form fromFileEntry: filename)
	].

	aDirectoryEntry directoryNames do: [ :i |
		self at: i put: (ContentPack new loadContentFrom: aDirectoryEntry / i)
	]! !


!ContentPack class methodsFor: 'configuration' stamp: 'KenD 4/4/2021 10:41:47'!
mapping

	^ {
		ColorForm -> #bmp .
		Form -> #png .
		SVGMainMorph -> #svg .
	}! !

-------------- next part --------------
'From Cuis 5.0 [latest update: #4552] on 4 April 2021 at 1:43:05 pm'!
!classDefinition: #SVGReadWriter category: 'SVG-Elements'!
ImageReadWriter subclass: #SVGReadWriter
	instanceVariableNames: ''
	classVariableNames: ''
	poolDictionaries: ''
	category: 'SVG-Elements'!
!SVGReadWriter commentStamp: '<historical>' prior: 0!
I read SVG files and yield SVGMainMorph's.!


!SVGReadWriter methodsFor: 'testing' stamp: 'KenD 4/4/2021 11:11:58'!
understandsImageFormat
	"Answer true if the image stream format is understood by this decoder."
	"@@@FIXME: totally bogus!!!! @@@"
	^ true! !


!SVGReadWriter methodsFor: 'accessing' stamp: 'KenD 4/4/2021 13:41:08'!
nextImage
	| xmlDocument |
	xmlDocument := 
		[  [ XMLDOMParser parseDocumentFrom: stream useCharacters. ]
			on: SVGWarning 
			do: [ :warning | "warning print." warning resume ] 
		] on: PathCommandError do: [ :error | error print. error return ].

	^ [SVGMainMorph fromXml: xmlDocument elements first] 
			on: SVGWarning 
			do: [ :warning | "warning print."  warning resume ] ! !

"-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- "!

!classDefinition: 'SVGReadWriter class' category: 'SVG-Elements'!
SVGReadWriter class
	instanceVariableNames: ''!

!SVGReadWriter class methodsFor: 'accessing' stamp: 'KenD 4/4/2021 10:54:14'!
typicalFileExtensions
	"Answer a collection of file extensions (lowercase) which files that I can read might commonly have"
	^#('SVG' 'svg')! !


!SVGReadWriter class methodsFor: 'instance creation' stamp: 'KenD 4/4/2021 13:07:26'!
onBinaryStream: aStream
	"Answer a SVGMainMorph"
	
	^ self new binaryStream: aStream ! !
-------------- next part --------------
A non-text attachment was scrubbed...
Name: SVGIcon-Import.png
Type: image/png
Size: 45090 bytes
Desc: not available
URL: <http://lists.cuis.st/mailman/archives/cuis-dev/attachments/20210404/175f1c92/attachment-0001.png>


More information about the Cuis-dev mailing list