'Desktop.Type', 'Desktop.Types', and 'Desktop.Is()' are now implemented in 'gb.gui.base'.

[GB.GUI.BASE]
* NEW: 'Desktop.Type', 'Desktop.Types', and 'Desktop.Is()' are now implemented here.
This commit is contained in:
gambas 2021-08-18 21:49:58 +02:00
parent 835884698e
commit 333985260e

View file

@ -0,0 +1,74 @@
' Gambas class file
Export
Static Property Read Type As String
Static Property Read Types As String[]
Static Private $sDesktop As String
Static Private $aDesktopType As String[]
Static Private Sub GetDesktop() As String
If $sDesktop Then Return $sDesktop
If Not $aDesktopType Then
$aDesktopType = Split(Application.Env["XDG_CURRENT_DESKTOP"], ":")
$aDesktopType.ReadOnly = True
Endif
If $aDesktopType.Count = 0 Then
If Application.Env["KDE_FULL_SESSION"] Then
If Application.Env["KDE_SESSION_VERSION"] = "4" Then
$aDesktopType.Add("KDE4")
Else If Application.Env["KDE_SESSION_VERSION"] = "5" Then
$aDesktopType.Add("KDE5")
Endif
$aDesktopType.Add("KDE")
Else If Application.Env["GNOME_DESKTOP_SESSION_ID"] Then
$aDesktopType.Add("GNOME")
Else If Application.Env["MATE_DESKTOP_SESSION_ID"] Or If Application.Env["MATECORBA_SOCKETDIR"] Then
$aDesktopType.Add("MATE")
Else If Application.Env["E_BIN_DIR"] And If Application.Env["E_LIB_DIR"] Then
$aDesktopType.Add("ENLIGHTENMENT")
Else If Application.Env["WMAKER_BIN_NAME"] Then
$aDesktopType.Add("WINDOWMAKER")
Else If Application.Env["DESKTOP_SESSION"] = "LXDE" Then
$aDesktopType.Add("LXDE")
Else If UCase(Env["DESKTOP_SESSION"]) = "XCFE" Then
$aDesktopType.Add("XFCE")
Else If UCase(Env["XDG_MENU_PREFIX"]) Begins "XCFE" Then
$aDesktopType.Add("XFCE")
Else If InStr(Env["XDG_DATA_DIR"], "/xfce") Then
$aDesktopType.Add("XFCE")
Endif
Endif
$sDesktop = $aDesktopType[0]
If $sDesktop Begins "X-" Then $sDesktop = Mid$($sDesktop, 3)
Return $sDesktop
End
Static Private Function Type_Read() As String
Return GetDesktop()
End
Static Private Function Types_Read() As String[]
GetDesktop()
Return $aDesktopType
End
Static Public Sub Is(Type As String) As Boolean
Return Types_Read().Exist(Type, gb.IgnoreCase)
End