Source

vlocity-vinstall-gambas / src / Step7c.class

Full commit
' 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/>.

PRIVATE PicYes AS Picture
PRIVATE PicNo AS Picture

PUBLIC SUB List_LANGUAGE_PACKS()
  
  DIM sLang, LangDesc AS String
  DIM Raw, LangLine AS String[]
  DIM i, irow AS Integer
  
  IF Exist(Main.Install.SrcMnt &/ "veclinux" &/ "CD2" &/ "LANG") = FALSE THEN RETURN ' no LANG bulk provided.
    FOR i = 0 TO gvOptions.Rows.Count - 1
      IF gvOptions[i, 1].Text THEN INC irow
    NEXT 
    
    INC gvOptions.Rows.Count
    Raw = Split(Trim(File.Load(Main.Install.SrcMnt &/ "veclinux" &/ "CD2" &/ "LANG")), gb.NewLine)
      FOR i = 1 TO Raw.Max ' IGNORE LINE 1, it only contains a description.
        LangLine = Split(Trim(Raw[i]), "-")
        sLang = Trim(LangLine[LangLine.Max])
        LangDesc = Describe_Lang_Pack(sLang)
        gvOptions[irow, 1].Text = Trim(Raw[i])
        gvOptions[irow, 2].Text = LangDesc & Space(1) & ("translation for the KDE desktop environment")
        gvOptions[irow, 0].Picture = PicNo
        gvOptions[irow, 0].Alignment = Align.Center
        INC irow
        INC gvOptions.Rows.Count
      NEXT 
      
    
    
END

PUBLIC FUNCTION Describe_Lang_Pack(sLang AS String) AS String
  
  DIM sret AS String
    SELECT CASE sLang
      CASE "es", "ES", "es_ES"
        sret = ("Spanish")
      CASE "en_GB"
        sret = ("English (UK)")
      CASE "it"
        sret = ("Italian")
      CASE "fr" 
        sret = ("French")
      CASE "ar"
        sret = ("Arabic")
      CASE "bg"
        sret = ("Bulgarian")
      CASE "bn_IN"
        sret = ("Bengali")
      CASE "ca"
        sret = ("Catalan")
      CASE "cs"
        sret = ("Czech")
      CASE "csb"
        sret = ("Kashubian")
      CASE "da"
        sret = ("Danish")
      CASE "de"
        sret = ("German")
      CASE "el"
        sret = ("Greek")
      CASE "eo"
        sret = ("Esperanto")
      CASE "et"
        sret = ("Estonian")
      CASE "eu"
        sret = ("Basque")
      CASE "fi"
        sret = ("Finnish")
      CASE "fy"
        sret = ("Abkhasysk")
      CASE "ga"
        sret = ("Irish")
      CASE "gl"
        sret = ("Galician")
      CASE "gu"
        sret = ("Gujarati")
      CASE "he"
        sret = ("Hebrew")
      CASE "hi"
        sret = ("Hindi")
      CASE "hu"
        sret = ("Hungarian")
      CASE "is"
        sret = ("Icelandic")
      CASE "ja"
        sret = ("Japanese")
      CASE "kk"
        sret = ("Kazakh")
      CASE "km"
        sret = ("Khmer")
      CASE "kn"
        sret = ("Kannada")
      CASE "ko"
        sret = ("Korean")
      CASE "ku"
        sret = ("Kurdish")
      CASE "lt"
        sret = ("Lithuanian")
      CASE "lv"
        sret = ("Latvian")
      CASE "mai"
        sret = ("Maithili")
      CASE "mk"
        sret = ("Macedonian")
      CASE "ml"
        sret = ("Malayalam")
      CASE "mr"
        sret = ("Marathi")
      CASE "nb"
        sret = ("Norwegian (Bokmaal)")
      CASE "nds"
        sret = ("Low Saxon")
      CASE "nl"
        sret = ("Dutch")
      CASE "nn" 
        sret = ("Norwegian (Nynorsk)")
      CASE "pa"
        sret = ("Punjabi")
      CASE "pl"
        sret = ("Polish")
      CASE "pt"
        sret = ("Portuguese")
      CASE "pt_BR"
        sret = ("Brazilian Portuguese")
      CASE "ro"
        sret = ("Romanian")
      CASE "ru"
        sret = ("Russian")
      CASE "sk"
        sret = ("Slovak")
      CASE "sl"
        sret = ("Slovenian")
      CASE "sr"
        sret = ("Serbian")
      CASE "sv"
        sret = ("Swedish")
      CASE "ta"
        sret = ("Tamil")
      CASE "tg"
        sret = ("Tajik")
      CASE "th"
        sret = ("Thai")
      CASE "tr"
        sret = ("Turkish")
      CASE "uk"
        sret = ("Ukrainian")
      CASE "wa"
        sret = ("Walloon")
      CASE "zh_ZN"
        sret = ("Simplified Chinese")
      CASE "zh_TW"
        sret = ("Chinese")
      CASE ELSE 
        sret = sLang
    END SELECT 
    
    RETURN sret       
  
END


PUBLIC SUB Form_Open()

  ME.tlbanner.Text = "<h2>" & ("Additional Included Software") & "</h2>"
  ME.btTglSel.Width = MdlObjSizer.get_object_width(ME.btTglSel.Text) + 48
  
    ME.gvOptions.Rows.count = 1
    ME.gvOptions.Columns.count = 3
    gvOptions.Columns[0].Width = 48
    gvOptions.Columns[1].Text = ("Package Name")
    gvOptions.Columns[2].Text = ("Description")    
    ME.Resize(ClsGlobal.fRunningMainForm.pnlstack.Width, ClsGlobal.fRunningMainForm.pnlstack.height)
    picYes = Picture.Load("images/16px-check.png")
    picNo = Picture.Load("images/16px-Nocheck.png")
    ME.MovieBox1.Path = "images/throbber.gif"
    
    'WAIT 1
    ME.LIST_OPTIONAL_PACKAGES()  
    ME.List_LANGUAGE_PACKS()
    'ME.Cleanup_PkgOptions()
    HPanel2.Visible = FALSE
    Panel1.Visible = TRUE
    Panel1.Height = ME.ClientH - Panel1.Top - (HBox5.Height * 1.5)
    REPEAT 
      IF gvOptions[gvOptions.Rows.Count - 1, 1].Text = "" THEN DEC gvOptions.Rows.Count
    UNTIL gvOptions[gvOptions.Rows.Count - 1, 1].Text <> ""
  

END



PUBLIC SUB LIST_OPTIONAL_PACKAGES()
  
  DIM irow, i AS Integer
  DIM sDescDump, sFile, sLine, sPkg, sDesc, sShortDesc AS String
  DIM sArr, sDescArr AS String[]
  
  'ME.Panel1.Visible = FALSE
  ME.tlWinExp.Text = ("Reading software catalog... Please wait a moment")
  ME.Panel1.Visible = FALSE
  ME.HPanel2.Visible = TRUE
  ME.HBox3.Visible = FALSE
  ME.HBox5.Visible = TRUE
  ME.MovieBox1.Playing = TRUE
  WAIT 0.1
  'irow = 2
       
    'IF Exist("/mnt/source/veclinux/OPTIONAL") = FALSE THEN RETURN 
    'sArr = Split(File.Load("/mnt/source/veclinux/OPTIONAL"), "\n")
      FOR EACH sPkg IN Dir("/mnt/source/veclinux/CD2")
      IF sPkg = "LANG" THEN CONTINUE ' DO NOT READ THIS BULK... THIS WILL BE READ INDIVIDUALLY, ON A SEPARATE FUNCTION
        IF sPkg THEN 
                SHELL "head -n 1 " & "/mnt/source/veclinux/CD2" &/ sPkg TO sShortDesc
        IF Len(Trim(sShortDesc)) <= 0 THEN sShortDesc = LCase(sPkg) & Space(1) & ("Bundle")
        'sShortDesc = sPkg & Space(1) & ("Bundle")

        gvOptions[irow, 0].Picture = PicYes
        gvOptions[irow, 0].Alignment = Align.Center
        gvOptions[irow, 1].Text = sPkg
        gvOptions[irow, 2].Text = Trim(sShortDesc)
        'gvOptions[irow, 3].Text = Trim(sDesc)
        'gvOptions[irow, 4].Text = "yes"
        INC irow
        INC gvOptions.Rows.Count
      END IF
      NEXT 
          
    ME.MovieBox1.Playing = FALSE
    ME.HPanel2.Visible = FALSE
    ME.Panel1.Visible = TRUE
    ME.HBox3.Visible = TRUE
    ME.HBox5.Visible = FALSE
    ME.tlWinExp.Text = ("The following software packages are available for installation from a second install media. If you choose to install these, you will be prompted to provide the second install CD or Image during the installation process.")

  
END




PUBLIC SUB OnExit()
  
  ME.Read_Optional_Pkg_Selection()
  Read_LANGUAGE_PACK_SELECTION() 
  
  'Message(ClsGlobal.sPkgListToInstall)
  
END
PUBLIC SUB StartUp()
  
  ME.Resize(ClsGlobal.fRunningMainForm.pnlstack.Width, ClsGlobal.fRunningMainForm.pnlstack.height)
  
END
PUBLIC FUNCTION GetNext() AS String
  
  RETURN "Step8"
  
END

PUBLIC SUB Form_Resize()
  ' 
  ' 'gvBulkSel.Columns[2].Width = gvBulkSel.Width - (gvBulkSel.ColumnAt(gvBulkSel[0, 2].Left) + gvBulkSel.Columns[1].Width + gvBulkSel.Columns[0].width + 4)
  ' gvOptions.Columns[2].Width = gvOptions.Width - (gvOptions.ColumnAt(gvOptions[0, 3].Left) + (gvOptions.Columns[0].Width + gvOptions.Columns[1].Width)) - gvOptions.Columns[0].Width + 4 ' + gvOptions.Columns[1].Width + gvOptions.Columns[0].width)
  ' gvOptions.Columns[3].Width = 0
  ' ME.Panel1.Height = ME.ClientH - ME.Panel1.Top - HBox3.Height - 12

END

PUBLIC SUB TOGGLE_SELECTION(BsELECTaLL AS Boolean)
  
  DIM irow AS Integer
  IF BsELECTaLL = TRUE THEN 
    Main.LangPacks.Clear
    FOR irow = 0 TO gvOptions.Rows.Count - 1
      gvOptions[irow, 0].Picture = PicYes
        IF gvOptions[irow, 1].Text LIKE "l10n" THEN Main.LangPacks.Push(Trim(gvOptions[irow, 1].text))
      'gvOptions[irow, 4].Text = "yes"
    NEXT 
  ELSE 
    Main.LangPacks.Clear()
    FOR irow = 0 TO gvOptions.Rows.Count - 1
      gvOptions[irow, 0].Picture = PicNo
      'gvOptions[irow, 4].Text = "no"
    NEXT 
  END IF
  
END


PUBLIC SUB gvOptions_Click()

'IF gvOptions[LAST.row, 1].Text = "" THEN RETURN 
IF InStr(gvOptions[LAST.row, 1].Text, "l10n") THEN 
  IF gvOptions[LAST.row, 0].Picture = PicYes THEN 
    gvOptions[LAST.row, 0].Picture = PicNo
    'IF Main.LangPakcs.Find(gvOptions[LAST.row, 1].Text) > -1 THEN Main.LangPakcs.Remove(Main.LangPakcs.Find(gvOptions[LAST.row, 1].text))
  ELSE 
    gvOptions[LAST.row, 0].Picture = PicYes
      Main.LangPacks.Add(gvOptions[LAST.row, 1].Text)
  END IF
ELSE 
' IF LAST.column = 0 OR LAST.column = 1 THEN 
  IF gvOptions[LAST.row, 0].Picture = PicYes THEN 
    gvOptions[LAST.row, 0].Picture = PicNo
  ELSE 
    gvOptions[LAST.row, 0].Picture = PicYes
  END IF
' ELSE 
'   RETURN 
'   STOP EVENT 
' END IF

END IF
gvOptions.Refresh
END

PUBLIC SUB btTglSel_Click()

  IF LAST.text = ("Un-Select All") THEN 
    ME.TOGGLE_SELECTION(FALSE)
    ME.btTglSel.Text = ("Select All")
  ELSE 
    ME.TOGGLE_SELECTION(TRUE)
    ME.btTglSel.Text = ("Un-Select All")
  END IF
  gvOptions.Refresh
LAST.Width = MdlObjSizer.get_object_width(LAST.text) + 48
END

PUBLIC SUB Read_Optional_Pkg_Selection()
  
  DIM IROW AS Integer
  DIM sList AS String
  
  'Main.Install.Packages.Clear()
  Main.Install.CD2Bulks.Clear()
  FOR irow = 0 TO gvOptions.Rows.count - 1
    IF InStr(gvOptions[irow, 1].Text, "l10n-") THEN CONTINUE 
    IF gvOptions[irow, 0].picture = PicYes THEN Main.Install.CD2Bulks.Add(gvOptions[irow, 1].Text)
    
  NEXT 
  
      
  
END

PRIVATE SUB Read_LANGUAGE_PACK_SELECTION()
  
  DIM irow AS Integer
  DIM i AS Integer
  Main.LangPacks.Clear()
  FOR irow = 0 TO gvOptions.Rows.Count - 1
    IF InStr(gvOptions[irow, 1].Text, "l10n-") = FALSE THEN CONTINUE 
    IF gvOptions[irow, 0].Picture = PicYes THEN Main.LangPacks.Add(gvOptions[irow, 1].Text)
  NEXT 
  
END