Source

vinstall-gambas / src / FMain0.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 $aPrev AS NEW Object[]
PUBLIC $oCurrent AS Object

PUBLIC SUB _new()

END

PUBLIC SUB Form_Open()

ClsGlobal.fRunningMainForm = ME

ME.Maximized = TRUE
IF Application.Args[1] THEN 
  'System.Language = Trim(Application.Args[1])
  $oCurrent = NEW Step1(pnlStack)
ELSE
'$oCurrent = NEW Step0(pnlStack)
' Changed because of missing locales in pre-test initrd
$oCurrent = NEW Step1(pnlStack)
END IF
btBack.Enabled = FALSE
ME.auto_setup_for_resolution()
'ME.Resize(1024, 600)
MdlStartUp.LAYOUT_NAVIGATION_VISUALS()
  'IF Application.Args[1] THEN 
'MdlMain.ADVANCE_STATUS_TREE("Step0", "Step1")
  'END IF
  ME.PictureBox1.BackColor = Color.Transparent
  MdlMain.Resize_Object(ME.btBack)
  MdlMain.Resize_Object(ME.btNext)
  MdlMain.Resize_Object(ME.btQuit)
  MdlMain.Resize_Object(ME.btHelp)
  ME.Maximized = TRUE
  ME.Resize(Desktop.Width, Desktop.Height)
  
END

PUBLIC SUB auto_setup_for_resolution()
  
  SidePanel1.Visible = Desktop.Width >= 1024
  
  
END



PUBLIC SUB btQuit_Click()

  ClsGlobal.fRunningMainForm.CLOSE 

END

PUBLIC SUB btBack_Click()

  $oCurrent = $aPrev.Pop()
  btBack.Enabled = $aPrev.count > 0
  btNext.Enabled = TRUE
  $oCurrent.Raise()
  SELECT CASE $oCurrent.name
    CASE "Step1"
      ClsGlobal.fRunningMainForm.btBack.enabled = FALSE
    CASE "Step7"
      Main.Install.BulkObjects.Clear
      Main.Install.CD2BulkObjects.Clear
      Main.Install.CD2Bulks.Clear
      Main.LangPacks.Clear()
    CASE "Conf2"
      ClsGlobal.fRunningMainForm.btNext.enabled = FALSE
    CASE "Conf1"
      ClsGlobal.fRunningMainForm.btNext.enabled = TRUE
    CASE "Conf0"
      $oCurrent.Revert_Form()
  END SELECT 

END

PUBLIC SUB btNext_Click()

  DIM o AS Object
  DIM sTmp AS String
  DIM bExist AS Boolean
'Get the next One
LAST.Enabled = FALSE
IF LAST.text = ("Reboot") THEN 
  'DEBUG "Insert reboot command in this line here"
  'Message.Error("Reboot not yet allowed")
  'SHELL "shutdown -frn now" WAIT 
  FrmRestart.Show()
  RETURN 
END IF


$oCurrent.OnExit() ' execute any code that needs to be ran before moving to the next step
'  Message(Main.bClear)
 IF Main.bStopNav = TRUE THEN 
  IF $oCurrent.name = "Conf0" THEN 
    $oCurrent.Revert_Form()
  END IF
    RETURN 
    STOP EVENT 
  END IF

sTmp = $oCurrent.GetNext()
    
'$oCurrent.Form_Open()
'$oCurrent.Startup()
'Is this form already opened ?
'if true it may have no been closed to preserve entries

'$oCurrent.OnExit() ' execute any code that needs to be ran before moving to the next step


FOR EACH o IN pnlStack.Children

 IF Object.Type(o) = sTmp THEN 
  bExist = TRUE
  BREAK 
 ENDIF

NEXT


'strore the previous
 $aPrev.Push($oCurrent)
 btBack.Enabled = $aPrev.Count > 0

IF $oCurrent.name = "Step0" THEN 
  IF System.Language <> "en_US" THEN 
    FMain0.Show
    FMain.Close
    RETURN 
  END IF
  
END IF


IF NOT bExist THEN
   $oCurrent = Object.New(sTmp, [pnlStack])
   $oCurrent.Visible = TRUE
    $oCurrent.width = pnlStack.Width
    $oCurrent.Height = pnlStack.Height

ELSE
  $OCurrent = o
ENDIF
 
  IF $oCurrent.name = "FDone" THEN 
    Message.Info(("Installation complete. Need to reboot now to test the system."))
    ClsGlobal.fRunningMainForm.btNext.text = ("Reboot")   
    ClsGlobal.fRunningMainForm.btNext.width = MdlObjSizer.get_object_width(ClsGlobal.fRunningMainForm.btNext.text) + 48   
    RETURN  
  END IF
 IF IsNull($oCurrent.GetNext()) THEN btNext.Enabled = FALSE
'Push to the foreground

 $oCurrent.Raise()

 $oCurrent.Startup() ' Call each form's startup sub

ME.ListView1.Refresh 
SELECT CASE $oCurrent.name
  CASE "Step6", "Conf2"
    LAST.enabled = FALSE
  CASE "FDone"
    LAST.enabled = TRUE
    ClsGlobal.fRunningMainForm.ListView1.Refresh()
  CASE "Conf1"
    ClsGlobal.fRunningMainForm.btQuit.enabled = TRUE
  CASE ELSE 
    LAST.enabled = TRUE
END SELECT 

END

PUBLIC SUB Form_Resize()

  '$oCurrent.width = pnlStack.Width
  '$oCurrent.height = pnlStack.Height
  
  'ME.SidePanel1.Height = pnlStack.Height
  ME.pnlStack.Height = ME.panel2.Height - ME.HBox3.Height
  ME.HBox8.Width = ME.SidePanel1.Width / 2
  'ME.HBox3.Width = panel2.Width
  ME.panel1.Height = ME.ClientH - (ME.Panel1.top + ME.hbox7.Height + 36)
  ME.Panel2.Height = ME.Panel1.Height
  ME.pnlStack.Height = ME.Panel2.Height
  
  'PANEL1.Width = ME.ClientWidth - (panel1.left * 2)
  'panel1.Height = ME.ClientHeight - (panel1.top + 12)
  'PRINT ME.ClientWidth & "X" & ME.ClientHeight
END


PUBLIC SUB pnlStack_Enter()

  '$oCurrent.resize(pnlStack.Width, pnlStack.Height)

END

PUBLIC SUB SidePanel1_Show()

  $oCurrent.resize(pnlStack.Width, pnlStack.Height)

END

PUBLIC SUB SidePanel1_Resize()

  $oCurrent.resize(pnlStack.Width, pnlStack.Height)
  ME.HBox8.Width = LAST.width / 2

END

PUBLIC SUB Form_Close()

  'EXEC ["umount", "/mnt/source"] WAIT 
  SHELL "umount /mnt/source 2>/dev/null" WAIT 

END

PUBLIC SUB btHelp_Click()

  'MdlHelpSystem.TRIGGER_HELP($oCurrent)
  FrmHelp.Show()

END