Source

vlocity-vinstall-gambas / Vlocity / Step0.class

' Gambas class file
'    This file is part of vinstall-ng

'    vinstall-ng is free software: you can redistribute it and/or modify
'    it under the terms of the GNU General Public License as published by
'    the Free Software Foundation, either version 2 of the License, or
'    (at your option) any later version.

'    vinstall-ng  is distributed in the hope that it will be useful,
'    but WITHOUT ANY WARRANTY; without even the implied warranty of
'    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
'    GNU General Public License for more details.

'    You should have received a copy of the GNU General Public License
'    along with vinstall-ng.  If not, see <http://www.gnu.org/licenses/>.

PUBLIC SUB Form_Open()

  WITH ME
    .tlbanner.Text = "<h2>" & ("Localization Settings") & "</h2>"
  END WITH 
ME.LIST_LANG_CHOICES()
ME.LIST_KEYBOARD_LAYOUTS()
ME.LIST_KEYBOARD_MODELS()
ME.PRE_SELECT_US_SETTINGS()



'ClsGlobal.fRunningMainForm.btnext.enabled = Main.InstallMedia.Count > 0

END

PUBLIC SUB onExit()
  
  'Message(ME.name & Space(1) & "parting")
  'System.Language = ME.cvLangList.Current.Key
  
END



PUBLIC SUB PRE_SELECT_US_SETTINGS()

  IF ME.cvkbdlayout.Exist("us") THEN ME.cvkbdlayout["us"].Selected = TRUE
  IF ME.cvKbdMod.Exist("pc104") THEN ME.cvKbdMod["pc104"].Selected = TRUE
  IF ME.cvLangList.Exist("en_US") THEN ME.cvLangList["en_US"].Selected = TRUE
  
END



PUBLIC SUB LIST_KEYBOARD_LAYOUTS()
  
  DIM sListFile AS String[]
  DIM sListFilePath AS String = "/etc/X11/xkb/rules/xorg.lst"
  DIM sSymbolsList AS String = "/usr/share/X11/xkb/symbols"
  DIM sSymbol, sdump, sFileIn, sLine, sDesc AS String
  DIM sXorgConf AS String[]
  DIM sXorgConfPath AS String = "/etc/X11/xorg.conf"
  DIM sXorgVesaPath AS String = "/etc/X11/xorg.conf-vesa"
  DIM sKeyMapPath AS String = "/etc/rc.d/rc.keymap"
  DIM i, iAdd AS Integer
  
   iAdd = 1 ' we will add 1 by default
   
  'these are the variables we will be setting
  ' KEY_MODEL = ""
  ' KEY_LAYOUT = ""
  
  ' PREPARE A TEMP FILE WITH A LIST OF THE LAYOUT DESCRIPTIONS ONLY
  SHELL "cat " & sListFilePath & " | tr -s \' \'\"\" > /tmp/keylist" WAIT 
    sFileIn = File.Load("/tmp/keylist")   
    sListFile = Split(sFileIn, "\n")
      FOR i = 0 TO sListFile.count - 1
        sLine = Trim(sListFile[i])
          IF sLine LIKE "! layout" THEN 
            REPEAT 
            sSymbol = Left(Trim(sListFile[i + iadd]), InStr(Trim(sListFile[i + iadd]), " "))
            'Message(sSymbol)
            sDesc = Right(Trim(sListFile[i + iadd]), Len(Trim(sListFile[i + iadd])) - Len(sSymbol) + 1)
            TRY cvkbdlayout.Add(Trim(sSymbol), sDesc)
              'TRY FMain.ListView1.Add(sSymbol, sDesc)
            '  FMain.ListView1.Add(Left(sListFile[i + iAdd], InStr(sListFile[i + iadd], " ")), sListFile[i + iadd])
              INC iadd
            UNTIL sListFile[i + iadd] LIKE "! variant"
          END IF

        
      NEXT 

  
END


PUBLIC SUB LIST_KEYBOARD_MODELS()
  
 DIM sFilePath AS String = "/tmp/keylist"
  DIM sdump, sFile, sLine, skey, sdesc AS String
  DIM i, iadd AS Integer
  DIM sFileIn AS String[]
  
  iadd = 1
  sdump = File.Load("/tmp/keylist")
    sFileIn = Split(sdump, "\n")
      FOR i = 0 TO sFileIn.Count - 1
        IF Trim(sFileIn[i]) LIKE "! model" THEN 
          REPEAT 
            sLine = Trim(sFileIn[i + iadd])
              skey = Left(sLine, InStr(sLine, " "))
              sdesc = Right(sLine, Len(sLine) - Len(skey) + 1)
                'TRY FMain.lvkbdmod.Add(skey, sdesc)
                TRY cvkbdmod.Add(Trim(skey), sDesc)
          INC iadd
          UNTIL sFileIn[i + iadd] LIKE "" OR sFileIn[i + iadd] LIKE "! layout"
        END IF
      NEXT 
  
END


PUBLIC SUB LIST_LANG_CHOICES()
  
  DIM sLang, sKey, sFile AS String
    FOR EACH sFile IN Dir(".lang", "*.mo")
      SELECT CASE File.BaseName(Application.dir &/ ".lang" &/ sfile)
        CASE "es"
          'sKey = "es_ES.utf8" ' This stopped working ????? WTH????
          sKey = "es_ES"
          sLang = ("Spanish")
        CASE "en", "en_US"
          sKey = "en_US"
          sLang = ("English (US)")
        CASE ELSE 
          sKey = File.BaseName(Application.Dir &/ ".lang" &/ sfile)
          sLang = sKey
          
        END SELECT 
        cvlanglist.Add(skey, slang)
      'ME.cvLangList.Add(File.BaseName(Application.Dir &/ ".lang" &/ sFile), sLang)
      'Message(sFile)
    NEXT 
  
  
END



PUBLIC FUNCTION GetNext() AS String
  
   
  ClsGlobal.fRunningMainForm.Listview1["Step0"].picture = MdlStartUp.pDone
  ClsGlobal.fRunningMainForm.Listview1["Step1"].picture = MdlStartUp.pNow
  
  IF System.Language = "en_US" THEN 
    RETURN "Step1"
  ELSE 
   FMain.Close
   FMain0.Show
  END IF
 
  
END

PUBLIC SUB TextBox1_MouseDown()

  TextBox1.Clear
  

END

PUBLIC SUB cvLangList_Click()

  'Message(LAST.current.key)
  IF System.Language <> Trim(LAST.current.key) THEN System.language = Trim(LAST.current.Key)
  ClsGlobal.sysLang = Trim(LAST.current.key)
  System.Language = Trim(LAST.current.key)



END

PUBLIC SUB cvKbdMod_Select()

  'Message(LAST.key)
  EXEC ["setxkbmap", "-model", Trim(LAST.current.key)] WAIT 
  ClsGlobal.sysKbModel = Trim(LAST.current.key)

END

PUBLIC SUB cvkbdlayout_Select()

  EXEC ["setxkbmap", "-layout", Trim(LAST.current.key)] WAIT 
  ClsGlobal.sysKbLayout = Trim(LAST.current.key)
  'Message(LAST.current.key)

END


PUBLIC SUB cvLangList_menu()

  MdlMain.Set_App_Status(("Select Language here"))
  

END