[GB.DESKTOP]

* NEW: New Function that return the comment for a given mimetype in the current country setting. 
  If true is set in parameter the common language is returned.


git-svn-id: svn://localhost/gambas/trunk@5294 867c0c6c-44f3-4631-809d-bfa615b0a4ec
This commit is contained in:
Fabien Bodard 2012-11-03 16:03:57 +00:00
parent 6ec8947f88
commit 413147d1ce
3 changed files with 43 additions and 19 deletions

View file

@ -223,6 +223,10 @@ _exit
M
GetComment
m
s
[(Common)b]
#DesktopWatcher
C

View file

@ -1,7 +1,7 @@
# Gambas Project File 3.0
# Compiled with Gambas 3.3.90
Title=Desktop-neutral routines from Portland project
Startup=Main
Startup=MMimeTest
Version=3.3.90
VersionFile=1
Component=gb.image

View file

@ -188,8 +188,8 @@ Static Private Sub LoadMimeDatabase()
Catch
Refresh
Error "gb.desktop: unable to read mime database"
Refresh
Error "gb.desktop: unable to read mime database"
End
@ -325,8 +325,12 @@ Static Public Function _next() As DesktopMime
If Not $aCurMimes Then $aCurMimes = $aMimesSuffix
If Not Enum.Index Then Enum.Index = 0
Enum.Index += 1
If Enum.Index = $aCurMimes.count + 1 Then Enum.Stop
Try Return $aCurMimes[Enum.Index - 1]
If Enum.Index = $aCurMimes.count + 1 Then
Enum.Stop
$aCurMimes = Null
Return
Endif
Return $aCurMimes[Enum.Index - 1]
End
@ -403,18 +407,34 @@ Static Private Sub PreciseSearch_Write(Value As Boolean)
End
Public Function GetComment(Optional Common As Boolean) As String
Dim sPath As String
Dim s As String
Dim sLine As String
Dim sLang As String = Left(System.Language, 2)
Dim sRet As String
'Dim sTypePath As String = Type & ".xml"
For Each s In GetDataDir()
sPath = s &/ "mime" &/ _$sType & ".xml"
If Exist(sPath) Then
For Each sLine In Split(File.Load(sPath), "\n")
If Not common Then
If InStr(sline, "<comment xml:lang=\"" & sLang & "\">") Then
Return Scan(sLine, "*>*<*")[1]
Break
Endif
Endif
If InStr(sLine, "comment>") Then
sRet = Scan(sLine, "*>*<*")[1]
If sRet And If common Then Return sRet
Endif
Next
If sRet Then Return sRet
Endif
Next
' Public Function GetDescription(Optional Common As Boolean) As String
'
' Dim sPath As String
' Dim s As String
' 'Dim sTypePath As String = Type & ".xml"
' For Each s In GetDataDir()
'
' 'If Exist(s &/ "mime" &/
'
' Next
'
'
'
' End
End