Add an hidden API to install the stock icons as system icon theme in '~/.local/share/icons'.
[GB.FORM.STOCK] * NEW: Add an hidden API to install the stock icons as system icon theme in '~/.local/share/icons'. * NEW: Add icon for special home folders. * NEW: Redraw the 'watch' icon.
167
comp/src/gb.form.stock/.src/MakeIconTheme.module
Normal file
|
@ -0,0 +1,167 @@
|
|||
' Gambas module file
|
||||
|
||||
Private Sub MakeDir(Path As String)
|
||||
|
||||
Dim sElt As String
|
||||
Dim sMake As String = "/"
|
||||
|
||||
If Path Begins "~/" Then Path = User.Home &/ Mid$(Path, 3)
|
||||
|
||||
For Each sElt In Split(Path, "/")
|
||||
sMake &/= sElt
|
||||
If IsDir(sMake) Then Continue
|
||||
Try Mkdir sMake
|
||||
Next
|
||||
|
||||
If Not Exist(Path) Or If Not IsDir(Path) Then Error.Raise("Cannot create directory")
|
||||
|
||||
End
|
||||
|
||||
Public Sub Run()
|
||||
|
||||
Dim sSize As String
|
||||
Dim hFile As File
|
||||
Dim sLine As String
|
||||
Dim iPos As Integer
|
||||
Dim sIcon As String
|
||||
Dim aTarget As String[]
|
||||
Dim sIconPath As String
|
||||
Dim sTarget As String
|
||||
Dim sTargetDir As String
|
||||
Dim cMime As New Collection
|
||||
Dim sTargetPath As String
|
||||
Dim sRoot As String
|
||||
Dim aDirectories As New String[]
|
||||
Dim sDir As String
|
||||
Dim sName As String
|
||||
Dim hImage As Image
|
||||
Dim sMakeLink As String
|
||||
Dim sLink As String
|
||||
|
||||
sRoot = "~/.local/share/icons/Gambas"
|
||||
|
||||
hFile = Open "links" For Input
|
||||
While Not Eof(hFile)
|
||||
|
||||
Line Input #hFile, sLine
|
||||
sLine = Trim(sLine)
|
||||
If Not sLine Then Continue
|
||||
|
||||
iPos = InStr(sLine, "->")
|
||||
If iPos = 0 Then Continue
|
||||
|
||||
sIcon = Trim(Mid(sLine, iPos + 2))
|
||||
sTarget = Trim(Left(sLine, iPos - 1))
|
||||
|
||||
aTarget = cMime[sIcon]
|
||||
If Not aTarget Then
|
||||
aTarget = New String[]
|
||||
cMime[sIcon] = aTarget
|
||||
Endif
|
||||
|
||||
aTarget.Add("$(mime)" &/ sTarget)
|
||||
|
||||
Wend
|
||||
|
||||
Close #hFile
|
||||
|
||||
hFile = Open "icon.map" For Input
|
||||
While Not Eof(hFile)
|
||||
|
||||
Line Input #hFile, sLine
|
||||
sLine = Trim(sLine)
|
||||
If Not sLine Then Continue
|
||||
|
||||
iPos = InStr(sLine, " ")
|
||||
If iPos = 0 Then Continue
|
||||
|
||||
sIcon = Left(sLine, iPos - 1)
|
||||
aTarget = Split(Trim(Mid(sLine, iPos + 1)), ";")
|
||||
If cMime.Exist(sIcon) Then aTarget.Insert(cMime[sIcon])
|
||||
|
||||
For Each sSize In ["16", "32", "128"]
|
||||
|
||||
If sSize = "16" Then
|
||||
sIconPath = "gambas/32" &/ sIcon & ".png"
|
||||
If Not Exist(sIconPath) Then sIconPath = "gambas/128" &/ sIcon & ".png"
|
||||
hImage = Image.Load(sIconPath).Stretch(16, 16)
|
||||
sIconPath = Temp$("image") & ".png"
|
||||
hImage.Save(sIconPath)
|
||||
Else
|
||||
sIconPath = "gambas" &/ sSize &/ sIcon & ".png"
|
||||
Endif
|
||||
|
||||
If Not Exist(sIconPath) Then Continue
|
||||
|
||||
sMakeLink = ""
|
||||
|
||||
For Each sTarget In aTarget
|
||||
If sTarget = "#" Then Continue
|
||||
|
||||
If sTarget Begins "[" Then
|
||||
iPos = InStr(sTarget, "]")
|
||||
sTarget = Mid(sTarget, iPos + 1)
|
||||
Endif
|
||||
|
||||
iPos = InStr(sTarget, "/")
|
||||
sTargetDir = Left(sTarget, iPos - 1)
|
||||
sTarget = Mid(sTarget, iPos + 1)
|
||||
|
||||
If sTargetDir = "$(mime)" Then sTargetDir = "mimetypes"
|
||||
|
||||
sTargetDir = sSize & "x" & sSize &/ sTargetDir
|
||||
If Not aDirectories.Exist(sTargetDir) Then aDirectories.Add(sTargetDir)
|
||||
sTargetPath = sRoot &/ sTargetDir &/ sTarget & ".png"
|
||||
Print sTargetPath
|
||||
|
||||
MakeDir(File.Dir(sTargetPath))
|
||||
Try Kill sTargetPath
|
||||
|
||||
If sMakeLink Then
|
||||
sLink = sMakeLink
|
||||
If sLink & "/" Begins sTargetDir & "/" Then
|
||||
sLink = File.Name(sLink)
|
||||
Else
|
||||
sLink = ".." &/ sMakeLink
|
||||
Endif
|
||||
Link sLink To sTargetPath
|
||||
Else
|
||||
Copy sIconPath To sTargetPath
|
||||
sMakeLink = Mid$(sTargetDir, InStr(sTargetDir, "/") + 1) &/ sTarget & ".png"
|
||||
Endif
|
||||
|
||||
Next
|
||||
|
||||
Next
|
||||
|
||||
Wend
|
||||
|
||||
Close #hFile
|
||||
|
||||
hFile = Open sRoot &/ "index.theme" For Output Create
|
||||
|
||||
Print #hFile, "[Icon Theme]"
|
||||
Print #hFile, "Name=Gambas"
|
||||
Print #hFile, "Comment=Gambas Icon Theme"
|
||||
Print #hFile, "Inherits=Papirus,breeze"
|
||||
Print #hFile, "Directories="; aDirectories.Sort(gb.Natural).Join(",")
|
||||
Print #hFile
|
||||
|
||||
For Each sDir In aDirectories
|
||||
Print #hFile, "["; sDir; "]"
|
||||
iPos = InStr(sDir, "x")
|
||||
Print #hFile, "Size="; Left(sDir, iPos - 1)
|
||||
Print #hFile, "Type=Fixed"
|
||||
sName = File.Name(sDir)
|
||||
Select Case sName
|
||||
Case "mimetypes"
|
||||
Print #hFile, "Context=MimeTypes"
|
||||
Case Else
|
||||
Print #hFile, "Context="; UCase(Left(sName)); Mid(sName, 2)
|
||||
End Select
|
||||
Print #hFile
|
||||
Next
|
||||
|
||||
Close #hFile
|
||||
|
||||
End
|
|
@ -110,3 +110,10 @@ Static Public Sub LoadSvgImage(sKey As String, Optional sStock As String) As Svg
|
|||
Return SvgImage.Load(sPath & ".svg")
|
||||
|
||||
End
|
||||
|
||||
Static Public Sub InstallIconTheme()
|
||||
|
||||
MakeIconTheme.Run()
|
||||
|
||||
End
|
||||
|
||||
|
|
Before Width: | Height: | Size: 357 B After Width: | Height: | Size: 374 B |
Before Width: | Height: | Size: 276 B After Width: | Height: | Size: 268 B |
Before Width: | Height: | Size: 345 B After Width: | Height: | Size: 412 B |
Before Width: | Height: | Size: 499 B After Width: | Height: | Size: 646 B |
BIN
comp/src/gb.form.stock/gambas/128/folder-document.png
Normal file
After Width: | Height: | Size: 251 B |
BIN
comp/src/gb.form.stock/gambas/128/folder-download.png
Normal file
After Width: | Height: | Size: 277 B |
BIN
comp/src/gb.form.stock/gambas/128/folder-image.png
Normal file
After Width: | Height: | Size: 337 B |
BIN
comp/src/gb.form.stock/gambas/128/folder-music.png
Normal file
After Width: | Height: | Size: 446 B |
BIN
comp/src/gb.form.stock/gambas/128/folder-video.png
Normal file
After Width: | Height: | Size: 398 B |
BIN
comp/src/gb.form.stock/gambas/128/multimedia.png
Normal file
After Width: | Height: | Size: 824 B |
Before Width: | Height: | Size: 353 B After Width: | Height: | Size: 353 B |
Before Width: | Height: | Size: 427 B After Width: | Height: | Size: 427 B |
Before Width: | Height: | Size: 297 B After Width: | Height: | Size: 268 B |
Before Width: | Height: | Size: 496 B After Width: | Height: | Size: 646 B |
1
comp/src/gb.form.stock/icon.map
Symbolic link
|
@ -0,0 +1 @@
|
|||
../gb.form/map/icon.map
|
|
@ -5,18 +5,21 @@ application-json -> json
|
|||
application-vnd.debian.binary-package -> package
|
||||
application-vnd.google-earth.kml+xml -> html
|
||||
application-vnd.ms-excel -> office-calc
|
||||
application-vns.ms-powerpoint -> office-presentation
|
||||
application-vnd.ms-powerpoint -> office-presentation
|
||||
application-vnd.ms-word -> office
|
||||
application-vnd.oasis.opendocument.graphics -> office-draw
|
||||
application-vnd.oasis.opendocument.presentation -> office-presentation
|
||||
application-vnd.oasis.opendocument.spreadsheet -> office-calc
|
||||
application-vnd.oasis.opendocument.text -> office
|
||||
application-vnd.openxmlformats-officedocument.presentationml.presentation -> office-presentation
|
||||
application-vnd.openxmlformats-officedocument.wordprocessingml.document -> office
|
||||
application-vnd.rar -> archive
|
||||
application-vnd.stardivision.calc -> office-calc
|
||||
application-vnd.stardivision.writer -> office
|
||||
application-vnd.sun.xml.calc -> office-calc
|
||||
application-vnd.sun.xml.writer -> office
|
||||
application-vnd.sun.xml.draw -> office-draw
|
||||
application-vnd.sun.xml.impress -> office-presentation
|
||||
application-x-bzip-compressed-tar -> archive
|
||||
application-x-cd-image -> cdrom
|
||||
application-x-compressed-tar -> archive
|
||||
|
@ -38,9 +41,17 @@ application-x-xz-compressed-tar -> archive
|
|||
application-xml -> xml
|
||||
application-zip -> archive
|
||||
audio-x-generic -> audio
|
||||
audio-mpeg -> audio
|
||||
audio-x-vorbis+ogg -> audio
|
||||
font-x-generic -> font
|
||||
font-ttf -> font
|
||||
image-svg+xml -> vector
|
||||
image-svg+xml-compressed -> vector
|
||||
image-x-generic -> image
|
||||
image-x-xcf -> image
|
||||
image-jpeg -> image
|
||||
image-png -> image
|
||||
inode-directory -> directory
|
||||
package-x-generic -> archive
|
||||
text-calendar -> calendar
|
||||
text-css -> css
|
||||
|
@ -54,4 +65,6 @@ text-x-csrc -> c
|
|||
text-x-generic -> text
|
||||
text-x-markdown -> md
|
||||
video-x-generic -> video
|
||||
font-x-generic -> font
|
||||
video-x-ms-wmv -> video
|
||||
video-mp4 -> video
|
||||
video-x-matroska -> video
|
||||
|
|