Source

vinstall-gambas / src / Step7a.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/>.

PUBLIC objBulks AS Object[]
PUBLIC picYes AS Picture
PUBLIC picNo AS Picture

PUBLIC SUB Form_Open()

picYes = Picture.Load("images/16px-check.png")
picNo = Picture.Load("images/16px-Nocheck.png")
'btTglSel.Value = FALSE
ME.btTglSel.Width = MdlObjSizer.get_object_width(ME.btTglSel.Text) + 48

  ME.tlbanner.Text = "<h2>" & ("Customize Your") & Space(1) & ClsGlobal.sDistroName & Space(1) & ("Installation") & "</h2>"
  WITH ME.gvBulkSel
    .Columns.count = 3
    .Rows.Count = 2
    .Columns[0].Width = 48
  END WITH 

  gvBulkSel.Columns[1].Text = ("Component")
  gvBulkSel.Columns[2].Text = ("Description")

  ME.LIST_OPTIONAL_BULKS
END

PUBLIC FUNCTION GetNext() AS String
  
  IF Exist(main.Install.SrcMnt &/ "veclinux" &/ "OPTIONAL") THEN
    RETURN "Step7b"
  ELSE 
    IF main.SelectedSrc.MultiDisk = TRUE THEN 
      RETURN "Step7c"
    END IF
    RETURN "Step8"
  END IF
    
  
END

PUBLIC SUB LIST_OPTIONAL_BULKS()
  
  DIM sLine, sFile AS String '= File.Load("/mnt/source/veclinux/SETUP.CONF")
  DIM sArr, sLineArr AS String[]
  DIM i, irow AS Integer
  DIM sName, sDesc, sDump AS String
  DIM BulkList AS NEW String[]
  

   IF Exist(Main.Install.SrcMnt &/ "veclinux" &/ "VINSTALL.INI") THEN

      FOR EACH sLine IN main.Install.Config.Keys["bulks/optional"]
        sDesc = Main.Install.Config["bulks/optional" &/ Trim(sLine)]
        INC gvBulkSel.Rows.Count
        gvBulkSel[irow, 1].Text = sLine
        gvBulkSel[irow, 0].Picture = picyes
        gvBulkSel[irow, 0].Alignment = Align.Center
        gvBulkSel[irow, 2].Text = sDesc
        INC irow
      NEXT 
  ELSE 
    SHELL "cat " & Main.Install.SrcMnt &/ "veclinux" &/ "VINSTALL.CONF | grep ^BULK | grep OPT | cut -f2 -d\\'" TO sDump
      IF Len(Trim(sDump)) <= 0 THEN RETURN 
  sArr = Split(Trim(sDump), gb.NewLine)
    FOR i = 0 TO sArr.Max
      sLineArr = Split(sArr[i], ":")
        sName = sLineArr[1]
        sDesc = sLineArr[3]
        INC gvBulkSel.Rows.Count
          gvBulkSel[irow, 1].Text = sName
          gvBulkSel[irow, 0].Picture = picyes
          gvBulkSel[irow, 0].Alignment = Align.Center
          gvBulkSel[irow, 2].Text = sDesc
          'gvBulkSel[irow, 3].Text = "yes"
          INC irow
    NEXT 
  END IF
  REPEAT 
  IF gvBulkSel[gvBulkSel.Rows.Count - 1, 1].Text = "" THEN DEC gvBulkSel.Rows.Count
  'IF gvBulkSel[gvBulkSel.Rows.Count - 1, 1].Text = "" THEN DEC gvBulkSel.Rows.Count
  UNTIL gvBulkSel[gvBulkSel.Rows.Count - 1, 1].Text <> ""

  
END


PUBLIC SUB StartUp()
  
  
  
END

PUBLIC SUB Get_Bulk_Selection()
  
  DIM irow AS Integer
  DIM sList AS String
  DIM blklst AS NEW Object[]
  DIM blk AS Bulk
  DIM arr AS String[]
  DIM i AS Integer
  Main.install.Bulks.Clear
  ClsGlobal.sBulkListToInstall = ""
    FOR irow = 0 TO gvBulkSel.Rows.count - 1
      'IF gvBulkSel[irow, 3].Text LIKE "yes" THEN 
      IF gvBulkSel[irow, 0].Picture = picyes THEN 
        sList = sList & Trim(gvBulkSel[irow, 1].Text) & ","
        Main.install.Bulks.Add(gvBulkSel[irow, 1].text)
        blk = NEW Bulk
        blk.Name = Trim(gvBulkSel[irow, 1].Text)
        blk.Description = main.Install.Config["bulks/optional" &/ blk.Name]
        'blk.Description = Trim(gvBulkSel[irow, 2].Text)
        blk.Required = FALSE
        blklst.Add(blk)
    END IF
    NEXT 
  ClsGlobal.sBulkListToInstall = Trim(slist)

END


PUBLIC SUB OnExit()
  
  ME.Get_Bulk_Selection()
  
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)
  'gvBulkSel.Columns[2].Width = gvBulkSel.Width - (gvBulkSel.Columns[0].Width + gvBulkSel.Columns[2].Width - gvBulkSel.Columns[3].Width)

END

PUBLIC SUB gvBulkSel_Click()

  'IF LAST.column > 0 THEN RETURN 
  'IF LAST.row < 2 THEN RETURN 
  'IF LAST.column = 0 OR LAST.column = 1 AND LAST.row > 1 THEN 
    IF gvBulkSel[LAST.row, 0].Picture = picYes THEN 
        IF gvBulkSel[LAST.row, 1].text LIKE "x11" THEN 
          SELECT CASE Message.Warning("<b>" & ("WARNING:") & "</b>" & Space(1) & ("This component is a dependancy to any graphical user interface progam on the system") & "<br>" &
          ("Choosing not to install this may result in a command-line (text mode) installation only") & "<br>" &
          ("Are you sure you want to disable this component anyway?"), ("Yes"), ("No"))
            CASE 2
              RETURN 
              STOP EVENT 
          END SELECT 
        END IF
      gvBulkSel[LAST.row, 0].Picture = picNo
      'gvBulkSel[LAST.row, 3].Text = "no"
    ELSE 
      gvBulkSel[LAST.row, 0].Picture = picYes
      'gvBulkSel[LAST.row, 3].Text = "yes"
    END IF
  ' ELSE IF LAST.column = 2 THEN 
  '   'Balloon(gvBulkSel[LAST.row, 2].Text, gvBulkSel, gvBulkSel[LAST.row, 0].picture, gvBulkSel[LAST.row, LAST.column].left + 4, gvBulkSel[LAST.row, LAST.column].y + 12)
  ' END IF
        
  gvBulkSel.Refresh
  

END

PUBLIC SUB btTglSel_Click()
  
    DIM irow AS Integer

  'IF LAST.value THEN 
  IF LAST.text = ("Select All") THEN 
      'irow = 0
        FOR irow = 0 TO gvBulkSel.Rows.count - 1
          gvBulkSel[irow, 0].Picture = picyes
          'gvBulkSel[irow, 3].Text = "yes"
        NEXT         
    
    LAST.text = ("Un-Select All")
  ELSE 
    'irow = 0
      FOR irow = 0 TO gvBulkSel.Rows.count - 1
        gvBulkSel[irow, 0].Picture = picno
        'gvBulkSel[irow, 3].Text = "no"
      NEXT 
      Message.Warning("<b>" & ("WARNING:") & "</b>" & Space(1) & ("The X11 component has been disabled. This is a vital part of the system.") & "<br>" &
          ("Choosing not to install this may result in a command-line (text mode) installation only"))          
    LAST.text = ("Select All")
  END IF
gvBulkSel.Refresh
LAST.Width = MdlObjSizer.get_object_width(LAST.text) + 48
END