--- a/AbstractFileBrowser.st Tue Feb 17 12:08:22 2004 +0100
+++ b/AbstractFileBrowser.st Tue Feb 17 13:08:05 2004 +0100
@@ -1269,6 +1269,113 @@
^ ToolbarIconLibrary shell20x20Icon
! !
+!AbstractFileBrowser class methodsFor:'interface specs'!
+
+encodingDialogSpec
+ "This resource specification was automatically generated
+ by the UIPainter of ST/X."
+
+ "Do not manually edit this!! If it is corrupted,
+ the UIPainter may not be able to read the specification."
+
+ "
+ UIPainter new openOnClass:AbstractFileBrowser andSelector:#encodingDialogSpec
+ AbstractFileBrowser new openInterface:#encodingDialogSpec
+ "
+
+ <resource: #canvas>
+
+ ^
+ #(FullSpec
+ name: encodingDialogSpec
+ window:
+ (WindowSpec
+ label: 'File Encoding'
+ name: 'File Encoding'
+ min: (Point 10 10)
+ bounds: (Rectangle 0 0 367 568)
+ )
+ component:
+ (SpecCollection
+ collection: (
+ (LabelSpec
+ label: 'Label'
+ name: 'Select the Character Encoding'
+ layout: (LayoutFrame 0 0 0 0 0 1 30 0)
+ translateLabel: true
+ adjust: left
+ )
+ (DataSetSpec
+ name: 'Table1'
+ layout: (LayoutFrame 0 0 30 0 0 1 -30 1)
+ model: selectedEncoding
+ hasHorizontalScrollBar: true
+ hasVerticalScrollBar: true
+ dataList: encodingList
+ has3Dsepartors: true
+ has3Dseparators: true
+ doubleClickSelector: accept
+ columns:
+ (OrderedCollection
+
+ (DataSetColumnSpec
+ label: 'Encoding'
+ translateLabel: true
+ labelButtonType: Button
+ model: at:
+ canSelect: false
+ isResizeable: false
+ showRowSeparator: false
+ showColSeparator: false
+ )
+ (DataSetColumnSpec
+ label: 'Description'
+ translateLabel: true
+ labelButtonType: Button
+ model: at:
+ canSelect: false
+ isResizeable: false
+ showRowSeparator: false
+ showColSeparator: false
+ )
+ )
+ )
+ (HorizontalPanelViewSpec
+ name: 'HorizontalPanel1'
+ layout: (LayoutFrame 0 0 -30 1 0 1 0 1)
+ horizontalLayout: fitSpace
+ verticalLayout: center
+ horizontalSpace: 3
+ verticalSpace: 3
+ reverseOrderIfOKAtLeft: true
+ component:
+ (SpecCollection
+ collection: (
+ (ActionButtonSpec
+ label: 'Cancel'
+ name: 'Button2'
+ translateLabel: true
+ model: cancel
+ extent: (Point 171 22)
+ )
+ (ActionButtonSpec
+ label: 'OK'
+ name: 'Button1'
+ translateLabel: true
+ model: accept
+ isDefault: true
+ extent: (Point 171 22)
+ )
+ )
+
+ )
+ )
+ )
+
+ )
+ )
+! !
+
!AbstractFileBrowser class methodsFor:'menu specs'!
baseBookmarksMenuSpec
@@ -1360,6 +1467,11 @@
translateLabel: true
)
(MenuItem
+ label: 'Encoding...'
+ itemValue: fileEncodingDialog
+ translateLabel: true
+ )
+ (MenuItem
label: '-'
)
(MenuItem
@@ -2496,6 +2608,34 @@
self fileGetInfo:true
!
+fileEncodingDialog
+ "open a dialog to allow change of the files character encoding.
+ Files are converted to internal encoding when read, and converted back
+ to this encoding when saved.
+ The default encoding is nil, which means that files are already in
+ the internal encoding (which is iso8859).
+ Notice: currently, not too many encodings are supported by the system."
+
+ |bindings encodings encodingDescr idx selectedEncoding|
+
+ encodingDescr := CharacterEncoder supportedExternalEncodings.
+ encodings := encodingDescr collect:[:d | d isNil ifTrue:[nil] ifFalse:[d first]].
+
+ bindings := IdentityDictionary new.
+ bindings at:#encodingList put:encodingDescr.
+ bindings at:#selectedEncoding put:(encodings indexOf:self fileEncoding ifAbsent:1) asValue.
+ (self openDialogInterface:#encodingDialogSpec withBindings:bindings)
+ ifTrue:[
+ idx := (bindings at:#selectedEncoding) value.
+ selectedEncoding := encodings at:idx.
+ selectedEncoding notNil ifTrue:[
+ self fileEncoding:selectedEncoding.
+ ].
+ ].
+
+ "Modified: 30.6.1997 / 14:41:12 / cg"
+!
+
fileGetInfo:longInfo
"get info on selected file - show it in a box"
@@ -2794,6 +2934,10 @@
]
!
+defaultFileEncoding
+ ^ #'iso8859-1' "/ #'utf-8'
+!
+
enableDirectoryUp
^ self aspectFor:#enableDirectoryUp ifAbsent:[false asValue]
@@ -2814,6 +2958,14 @@
^ self aspectFor:#enableViewNoteBookApplication ifAbsent:[false asValue]
!
+fileEncoding
+ ^ self fileEncodingHolder value
+!
+
+fileEncoding:newEncoding
+ self fileEncodingHolder value:newEncoding
+!
+
hasFileSelection
^ self aspectFor:#hasFileSelection ifAbsent:[ false asValue ].
@@ -6455,5 +6607,5 @@
!AbstractFileBrowser class methodsFor:'documentation'!
version
- ^ '$Header: /cvs/stx/stx/libtool/AbstractFileBrowser.st,v 1.202 2004-02-06 18:02:42 stefan Exp $'
+ ^ '$Header: /cvs/stx/stx/libtool/AbstractFileBrowser.st,v 1.203 2004-02-17 12:08:00 cg Exp $'
! !