Source

vinstall-gambas / src / FMain.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 $aPrev AS NEW Object[]
PUBLIC $oCurrent AS Object
PUBLIC bConfMode AS Boolean
PUBLIC Cont AS String
PUBLIC bClear AS Boolean

PUBLIC SUB _new()

END

PUBLIC SUB Form_Open()

ClsGlobal.fRunningMainForm = ME

ME.Maximized = TRUE
IF Application.Args[1] <> "-C" THEN 
  'System.Language = Trim(Application.Args[1])
  $oCurrent = NEW Step0(pnlStack)
ELSE IF Application.Args[1] = "-C" THEN 
  bConfMode = TRUE
  $oCurrent = NEW Step1(pnlStack)

ELSE 
'$oCurrent = NEW Step0(pnlStack)
' Changed because of missing locales in pre-test initrd
$oCurrent = NEW Step0(pnlStack)
END IF
btBack.Enabled = FALSE
ME.auto_setup_for_resolution()
MdlStartUp.LAYOUT_NAVIGATION_VISUALS()
  IF Application.Args[1] THEN 
    ClsGlobal.fRunningMainForm.ListView1["Step0"].picture = MdlStartUp.pDone
    ClsGlobal.fRunningMainForm.ListView1["Step1"].picture = MdlStartUp.pNow
  END IF
  ME.PictureBox1.BackColor = Color.Transparent
  'ME.Maximized = FALSE
  'ME.Resize(1024, 600)
  MdlMain.Resize_Object(ME.btBack)
  MdlMain.Resize_Object(ME.btNext)
  MdlMain.Resize_Object(ME.btQuit)
  MdlMain.Resize_Object(ME.btHelp)
  'ME.Center
  ME.Maximized = TRUE
  
END

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



PUBLIC SUB btQuit_Click()

  FMain.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 "Conf1"
      ClsGlobal.fRunningMainForm.btNext.enabled = TRUE
    CASE "Conf2"
      ClsGlobal.fRunningMainForm.btNext.enabled = FALSE
    CASE "Conf0"
      $oCurrent.Revert_Form()
  END SELECT 

END

PUBLIC SUB ConfNav()
  DIM o AS Object
  DIM sTmp AS String
  DIM bExist AS Boolean
  
  $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




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 NOT bExist THEN
  
  $oCurrent = Object.New(sTmp, [pnlStack])
    'IF ERROR THEN Message(Error.where & gb.NewLine & Error.Text)
   $oCurrent.Visible = TRUE
    $oCurrent.width = pnlStack.Width
    $oCurrent.Height = pnlStack.Height

ELSE
  $OCurrent = o
ENDIF
  
  $oCurrent.Raise()

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


PUBLIC SUB btNext_Click()

  DIM o AS Object
  DIM sTmp AS String
  DIM bExist AS Boolean
  

  IF bConfMode = TRUE THEN 
    ConfNav()
    RETURN 
    STOP EVENT 
  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
  
  
'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
IF (cont) THEN 
sTmp = Cont
ELSE 
  sTmp = $oCurrent.GetNext()
'END IF

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


END IF

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 
  System.Language = ClsGlobal.sysLang
    FMain0.Show
    FMain.Close
    RETURN 
  END IF
  
END IF


IF NOT bExist THEN
  
  $oCurrent = Object.New(sTmp, [pnlStack])
    'IF ERROR THEN Message(Error.where & gb.NewLine & Error.Text)
   $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
IF Cont = "Conf0" THEN $oCurrent = Object.New("Conf0", [pnlStack])

 $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", "Conf3"
    LAST.enabled = TRUE
    ClsGlobal.fRunningMainForm.ListView1.Refresh()
  CASE "Conf1", "Conf3"
    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)
  'Message.Info(MdlHelpSystem.TRIGGER_HELP($oCurrent))
  'Message.Info(ClsGlobal.fRunningMainForm.name)
  FrmHelp.Show
  

END

PUBLIC SUB ListView1_Click()

  

END

PUBLIC SUB Timer1_Timer()

  ClsGlobal.fRunningMainForm.appstatus.text = ""

END
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.