vlocity-vinstall-gambas / src / Step5.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()

  ME.tlbanner.Text = "<h2>" & ("Resize partitions using Gparted") & "</h2>"
  MdlMain.Resize_Object(ME.btRestart)
  WAIT 1
  ME.EMBED_GPARTED()
  ClsGlobal.fRunningMainForm.btnext.enabled = FALSE
END

PUBLIC SUB OnExit()
  
  
  
END


PUBLIC SUB StartUp()
  ' WAIT 1
  ' ME.Resize(ClsGlobal.fRunningMainForm.Pnlstack.Width, ClsGlobal.fRunningMainForm.PnlStack.Height)
  ' ME.tlEmbDone.Visible = FALSE
  ' ME.tlEmbDone.Parent.Visible = FALSE
  ' ME.Embedder1.Visible = TRUE
  ' ME.EMBED_GPARTED()
  ' ClsGlobal.fRunningMainForm.refresh
  ' ClsGlobal.fRunningMainForm.Pnlstack.refresh
  
END


PUBLIC FUNCTION GetNext() AS String
  
  RETURN "Step6"
  
END



PUBLIC SUB EMBED_GPARTED()
  
  
  DIM sTitle AS String
  DIM sTitle1, sTitle2 AS String
  DIM aHandle AS NEW Pointer[]
  DIM iHandle AS Integer
  DIM i AS Integer = 0
  DIM sDump AS String
  DIM sWins AS String = "gpartedbin,Gpartedbin" '" GParted, / dev / sda - GParted, / dev / hda - GParted ""
  DIM sWons AS String[] = Split(sWins, ",")
  DIM sType AS String
  DIM sTypes AS String[]
   
  ' The window can be found on the Desktop WM_CLASS property which can be seen via the xprop application
  ' We may need to implement this method here instead of the win window title method.
  
     
    IF Exist("/usr/sbin/gpartedbin") = FALSE AND IF Exist("/sbin/gpartedbin") = FALSE AND IF Exist("/usr/bin/gpartedbin") = FALSE THEN 
      Message.Error(("Gparted was not found on this system. Please install gparted and try again"))
      ME.tlEmbDone.Text = "<b>" & ("Unable to launch partitioning tool.") & "</b>" & "<br><br>" &
      ("The gparted program was not found on this system. Please install gparted or choose another partitioning method.")
      ClsGlobal.fRunningMainForm.btnext.Enabled = FALSE
      Embedder1.Visible = FALSE
      tlEmbDone.Parent.Visible = TRUE
      tlEmbDone.Visible = TRUE
      
      
      RETURN 
    END IF
  
'  FrmDiskPart.tlBanner.Text = "<h3>" & ("Loading gparted ... Please wait") & "</h3>"
  ME.tlEmbDone.Text = "<h3><i>" & ("Loading partitioning utility...Please Wait") & "</i></h3>"
  ME.tlEmbDone.Visible = TRUE
  SHELL "gpartedbin"
  WAIT 1

  REPEAT 
    WAIT 1
    INC i
      aHandle = Desktop.Find("", "*parted*", "")
  UNTIL aHandle.Count = 1 OR i = 5
  
   IF aHandle.Count > 0 THEN iHandle = aHandle[0]

  
  IF iHandle THEN 
    ME.tlEmbDone.Text = ""
    ME.tlEmbDone.Visible = FALSE
    TRY Embedder1.Embed(iHandle)
      CATCH 
        Message.Error(Error.Text & gb.NewLine & Error.Where)
  ELSE 
    Message.Warning(("The") & Space(1) & ClsGlobal.sDistroName & Space(1) & ("installer is unable to embed the gparted partitioning utility.") & gb.NewLine &
    ("Please consider using the automatic partition option, or use other means of") & gb.NewLine &
    ("partitioning your hard drives."))
  END IF

  

  
END




PUBLIC SUB Embedder1_Embed()

  ME.HBox1.Visible = FALSE
  ME.tlEmbDone.Visible = FALSE

    Message.Warning(main.Install.Name & Space(1) & ("has launched the GParted partitioning tool. Use this utility to") & gb.NewLine &
    ("move, resize, delete or create partitions.") & "<b>" & gb.NewLine & gb.NewLine & 
    ("When you are finished, you will need to exit the utility from the") & Space(1) & ("GParted") & Space(1) & ("menu") & "</b>")
    WITH ClsGlobal.fRunningMainForm
      .btnext.Enabled = FALSE
      .btBack.Enabled = FALSE
      .btQuit.enabled = FALSE
    END WITH 
    Embedder1.Raise
    Embedder1.Visible = TRUE
    HBox2.Visible = FALSE
    ClsGlobal.fRunningMainForm.btnext.enabled = FALSE
    
END

PUBLIC FUNCTION CHECK_IF_REBOOT_NEEDED() AS Boolean
 
 ' KNOWN BUG:
 ' This will make the user restart if there are FAT* partitions anywhere on the box
 ' even if that drive was not modified
 ' END OF BUG -- FIX SOON
 
 DIM sWinPartList AS String
 
 'SHELL "probepart | grep -e \"^/dev.*FAT32$\" | sed \'s/\\*/ /\' | grep -e \"/dev\"" TO sFAT32List
 'SHELL "probepart | grep -e \"^/dev.*FAT$\" | sed \'s/\\*/ /\'|grep -e \" /dev\"" TO sFATList
 
 SHELL "probepart | grep \"^/dev\" | grep -i \"FAT*\" | tr -s \' \',\"\"" TO sWinPartList
 
 sWinPartList = Trim(sWinPartList)
 IF sWinPartList THEN RETURN TRUE
 RETURN FALSE

    
END



PUBLIC SUB Embedder1_Close()

  
  ME.HBox1.Visible = TRUE
  'ME.HBox2.Visible = TRUE
  ME.tlEmbDone.Visible = TRUE
  
  MdlMain.RECREATE_PARTITION_OBJECTS()
  IF ME.CHECK_IF_REBOOT_NEEDED() = TRUE THEN 
      ME.HBox2.Visible = TRUE
      ME.tlEmbDone.Text = "<h3>" & ("SYSTEM RESTART SUGGESTED") & "</H3>" & GB.NewLine &
      "\n" &
      ("Your system still contains some non-linux partitions. If you still have a Windows operating system installed, it is recomended ")&
      ("that you reboot your system at this time. ") & "<br><br>" &
      ("Click the") & Space(1) & "\"" & "<b>" & ME.btRestart.Text & "</b>" & "\"" & Space(1) & ("button to restart your computer now, or click") & Space(1) & "\n" &
      "\"" & "<b>" & ClsGlobal.fRunningMainForm.btNext.text & "</b>" & "\"" & Space(1) & ("to continue without restarting.")
      
    
  ELSE 
      ME.tlEmbDone.Text = "<h3>" & ("PARTITIONING DONE") & "</h3>" & gb.NewLine & gb.NewLine &
        ("Click") & Space(1) & ClsGlobal.fRunningMainForm.btnext.text & Space(1) & ("to continue")
  END IF
  
  
  ClsGlobal.fRunningMainForm.btnext.enabled = Embedder1.Client = 0
  ClsGlobal.fRunningMainForm.btBack.enabled = Embedder1.Client = 0
  ClsGlobal.fRunningMainForm.btQuit.enabled = Embedder1.Client = 0

END

PUBLIC SUB btRestart_Click()
    
FrmRestart.Show()

END

PUBLIC SUB Form_Resize()

  Embedder1.Resize(ME.ClientWidth - (ME.Embedder1.x * 2), ME.ClientHeight - (ME.Embedder1.Top + 12))

END

PUBLIC SUB Embedder1_Enter()

  ClsGlobal.fRunningMainForm.btnext.enabled = FALSE

END

PUBLIC SUB Form_Enter()

  ClsGlobal.fRunningMainForm.btnext.enabled = Embedder1.Client = 0

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.