- AbstractDesktop
added:
#desktopDirectory
#documentsDirectory
#reinitialize
- GNOMEDesktop
added:
#desktopDirectory
#documentsDirectory
#isAvailable
- UnixDesktop
added:
#desktopDirectory
#documentsDirectory
- stx_libbasic
changed:
#classNamesAndAttributes
#extensionMethodNames
#preRequisites
- UnixOperatingSystem
added:
#getDesktopDirectory
#getDocumentsDirectory
- XDGDesktop
class definition
added:5 methods
changed: #isAvailable
category of:
"
COPYRIGHT (c) 2006 by eXept Software AG
All Rights Reserved
This software is furnished under a license and may be used
only in accordance with the terms of that license and with the
inclusion of the above copyright notice. This software may not
be provided or otherwise made available to, or used by, any
other person. No title to or ownership of the software is
hereby transferred.
"
"{ Package: 'stx:libbasic' }"
UnixDesktop subclass:#XDGDesktop
instanceVariableNames:''
classVariableNames:'XDG_USERCONFIG_DIR XDG_DESKTOP_DIR XDG_DOWNLOAD_DIR
XDG_TEMPLATES_DIR XDG_PUBLICSHARE_DIR XDG_DOCUMENTS_DIR
XDG_MUSIC_DIR XDG_PICTURES_DIR XDG_VIDEOS_DIR'
poolDictionaries:''
category:'System-Desktop'
!
!XDGDesktop class methodsFor:'documentation'!
copyright
"
COPYRIGHT (c) 2006 by eXept Software AG
All Rights Reserved
This software is furnished under a license and may be used
only in accordance with the terms of that license and with the
inclusion of the above copyright notice. This software may not
be provided or otherwise made available to, or used by, any
other person. No title to or ownership of the software is
hereby transferred.
"
! !
!XDGDesktop class methodsFor:'initialization'!
initialize
self initializeDirectories
"Created: / 09-05-2012 / 11:11:24 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
initializeDirectories
"Read XDG config file, if exist"
| cfg |
XDG_USERCONFIG_DIR := Filename homeDirectory / '.config'.
cfg := XDG_USERCONFIG_DIR / 'user-dirs.dirs'.
cfg exists ifFalse:[ ^ self ].
cfg readingFileDo:[:s|
[ s atEnd ] whileFalse:[
| l i name value eqpos q1pos q2pos |
l := s nextLine.
(i := l indexOfNonSeparator) ~~ 0 ifTrue:[
(l at: i) ~~ $# ifTrue:[
((eqpos := l indexOf: $= startingAt: i) ~~ 0
and:[(q1pos := l indexOf: $" startingAt: eqpos + 1) ~~ 0
and:[(q2pos := l indexOf: $" startingAt: q1pos + 1) ~~ 0]]) ifTrue:[
name := l copyFrom: i to: eqpos - 1.
value := l copyFrom: q1pos + 1 to: q2pos - 1.
(value startsWith: '$HOME/') ifTrue:[
value := Filename homeDirectory pathName , (value copyFrom:6).
].
self classVarAt: name asSymbol put: value asFilename.
]
]
]
]
]
"Created: / 09-05-2012 / 11:11:42 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
reinitialize
self initialize
"Created: / 09-05-2012 / 11:11:42 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!XDGDesktop class methodsFor:'accessing'!
priority
^30
"Created: / 11-08-2009 / 16:41:45 / Jan Vrany <vranyj1@fel.cvut.cz>"
! !
!XDGDesktop class methodsFor:'accessing - defaults'!
defaultEditorCommand
^ 'xdg-open %F'
"Created: / 11-08-2009 / 16:54:29 / Jan Vrany <vranyj1@fel.cvut.cz>"
! !
!XDGDesktop class methodsFor:'testing'!
isAvailable
^ super isAvailable and: [
(OperatingSystem getEnvironment: 'XDG_CONFIG_DIRS') notNil
or:[(OperatingSystem getEnvironment: 'XDG_SESSION_PATH') notNil
]
]
"
XDGDesktop isAvailable
"
"Created: / 11-08-2009 / 16:44:34 / Jan Vrany <vranyj1@fel.cvut.cz>"
"Modified: / 09-05-2012 / 11:44:07 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!XDGDesktop methodsFor:'accessing-directories'!
desktopDirectory
^XDG_DESKTOP_DIR isNil ifTrue:[Filename homeDirectory]
"Created: / 09-05-2012 / 11:53:43 / Jan Vrany <jan.vrany@fit.cvut.cz>"
!
documentsDirectory
^XDG_DOCUMENTS_DIR isNil ifTrue:[Filename homeDirectory]
"Created: / 09-05-2012 / 11:52:02 / Jan Vrany <jan.vrany@fit.cvut.cz>"
! !
!XDGDesktop class methodsFor:'documentation'!
version
^'$Id: XDGDesktop.st 10808 2012-05-09 15:04:12Z vranyj1 $'
!
version_SVN
^ '$Id: XDGDesktop.st 10808 2012-05-09 15:04:12Z vranyj1 $'
! !
XDGDesktop initialize!