Skip to content

Commit

Permalink
Version 3.0 BETA 4 final commit
Browse files Browse the repository at this point in the history
- Code imprrovements and polish
- Improvved plist edit open menu in EFI partition mounter
- Implemented translations for the most important ui dialogs
- Improoved icon detection for disk drives
- improoved diagnosrtics mode code
- added support for touch id on EFI partition mounter
- remooved unused libraries calls
  • Loading branch information
ITzTravelInTime committed Oct 12, 2020
1 parent d5df23c commit 4104b31
Show file tree
Hide file tree
Showing 25 changed files with 653 additions and 505 deletions.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -17,36 +17,28 @@ public class EFIPartitionToolInterface{

public let id: String = "EFIPartitionItem"

public let tileHeight: CGFloat = 60

let titleLabel = NSTextField()
let placeHolderLabel = NSTextField()

let mountButton = NSButton()
let unmountButton = NSButton()

let editOtherConfigButton = NSButton()
public let titleLabel = NSTextField()

var configOpenMenu: NSMenu = NSMenu()
private let placeHolderLabel = NSTextField()
private let mountButton = NSButton()
private let unmountButton = NSButton()
private let editOtherConfigButton = NSButton()
private var configOpenMenu: NSMenu = NSMenu()
private let showInFinderButton = NSButton()
private let ejectButton = NSButton()
private let coverView = NSView()
private let spinner = NSProgressIndicator()

let showInFinderButton = NSButton()
let ejectButton = NSButton()
let coverView = NSView()

let spinner = NSProgressIndicator()
var isMounted = false

var configType: EFIPartitionToolTypes.ConfigLocations! = .cloverConfigLocation

var isEjectable = false

var bsdid: String = ""

var partitions: [PartitionItem] = []

var isBar = false

var alreadyDrwn = false
public let tileHeight: CGFloat = 60

private var alreadyDrwn = false

public override func draw(_ dirtyRect: NSRect) {
super.draw(dirtyRect)
Expand Down Expand Up @@ -137,23 +129,30 @@ public class EFIPartitionToolInterface{
editOtherConfigButton.font = NSFont.systemFont(ofSize: 13)
editOtherConfigButton.isContinuous = true
editOtherConfigButton.target = self
//editOtherConfigButton.action = #selector(EFIPartitionItem.editConfigOther(_:))

editOtherConfigButton.action = #selector(EFIPartitionItem.openConfigMenu(_:))

self.addSubview(editOtherConfigButton)

configOpenMenu = NSMenu()//(title: EFIPMTextManager.getViewString(context: self, stringID: "configMenuTitle"))
configOpenMenu = NSMenu()

for c in 0..<appMenu.list.count{
let itm = NSMenuItem()//NSMenuItem(title: appMenu.list[c].name, action: #selector(editConfigGeneric(_:)), keyEquivalent: "")
itm.title = appMenu.list[c].name
itm.tag = c
itm.isEnabled = true
itm.isHidden = false
itm.target = self
itm.action = #selector(editConfigGeneric(_:))
let name = appMenu.list[c].name

var itm: NSMenuItem = NSMenuItem()

if name == "Separator"{
itm = NSMenuItem.separator()
itm.isEnabled = false
}else{
itm.title = name
itm.tag = c
itm.isEnabled = true
itm.isHidden = false
itm.target = self
itm.action = #selector(editConfigGeneric(_:))
}

configOpenMenu.insertItem(itm, at: c)
}

Expand Down Expand Up @@ -229,11 +228,6 @@ public class EFIPartitionToolInterface{

distance = 0

/*
if partCount < 3{
distance = (tileWidth + margin) / CGFloat(partCount)
}*/

for partition in partitions{
partition.frame.size = CGSize(width: tileWidth, height: tileHeight)

Expand All @@ -255,17 +249,6 @@ public class EFIPartitionToolInterface{

}

/*
for c in self.subviews{
if let l = c as? NSTextField{
l.drawsBackground = true
(l as NSView).backgroundColor = (l.superview! as NSView).backgroundColor
}

//c.backgroundColor = .red
}*/


alreadyDrwn.toggle()

checkMounted()
Expand Down Expand Up @@ -329,43 +312,21 @@ public class EFIPartitionToolInterface{

#if !macOnlyMode

@objc private func editConfigOther(_ sender: Any){
@objc private func openConfigMenu(_ sender: Any){

if configType == nil{
return
}


DispatchQueue.global(qos: .background).async{
guard let mountPoint = dm.getMountPointFromPartitionBSDID(self.bsdid) else { return }

var configLocation = mountPoint

for loc in EFIPartitionToolTypes.ConfigLocations.allCases{
if !FileManager.default.fileExists(atPath: mountPoint + loc.rawValue){ continue }

configLocation += loc.rawValue
break
}

DispatchQueue.main.sync{

if NSWorkspace.shared().openFile(configLocation){ return }

//msgBoxWarning("Impossible to open \"config.plist\"!", "Impossible to find an app to open the \"config.plist\" file!")

msgboxWithManagerGeneric(EFIPMTextManager, self, name: "impossible", parseList: nil, style: .warning, icon: IconsManager.shared.warningIcon)
}
}

}

@objc private func openConfigMenu(_ sender: Any){
configOpenMenu.popUp(positioning: nil, at: editOtherConfigButton.frame.origin, in: self)
}

@objc private func editConfigGeneric(_ sender: Any){

if configType == nil{
return
}

guard let sen = sender as? NSMenuItem else { return }
let target = sen.tag

Expand All @@ -380,21 +341,23 @@ public class EFIPartitionToolInterface{

DispatchQueue.main.sync{

if item.installedAppName.isEmpty{
switch item.installedAppName{
case "":
if NSWorkspace.shared().openFile(configLocation){ return }

msgboxWithManagerGeneric(EFIPMTextManager, self, name: "impossible", parseList: nil, style: .warning, icon: IconsManager.shared.warningIcon)

}else{

break
case "{openLink}" :
NSWorkspace.shared().open(URL(string: item.download)!)
break
default:
if NSWorkspace.shared().openFile(configLocation, withApplication: item.installedAppName){ return }

let list = ["{appName}" : item.name]
let list = ["{appName}" : item.installedAppName]
if dialogWithManagerGeneric(EFIPMTextManager as TextManagerGet, self, name: "download", parseList: list){
NSWorkspace.shared().open(URL(string: item.download)!)
}

break
}

}
Expand Down
10 changes: 5 additions & 5 deletions TINU.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@
/* End PBXFrameworksBuildPhase section */

/* Begin PBXGroup section */
C600803C251A910800FE35E2 /* Json */ = {
C600803C251A910800FE35E2 /* JSON */ = {
isa = PBXGroup;
children = (
C6188D972513828E00BCBC51 /* AppDownloadsEn.json */,
Expand All @@ -273,7 +273,7 @@
C68C79F12505205A00BBDA37 /* TextAssetsIt.json */,
C63F035D24E1091400F950B4 /* ProgressBarSettings.json */,
);
name = Json;
name = JSON;
sourceTree = "<group>";
};
C60C40C520CCAD9C00258574 /* Managers */ = {
Expand Down Expand Up @@ -373,14 +373,14 @@
C649CC90211A4EE100A6B47B /* EFIPartitionMounterTool */ = {
isa = PBXGroup;
children = (
C660D19A2529BB3B0027FCA0 /* JSON */,
C647B3AD211D18950024B9A1 /* EFIPartitionMounterTool.storyboard */,
C647B399211CF2C40024B9A1 /* EFIPartitionMounterModel.swift */,
C660D19D2529F0A70027FCA0 /* EFIPartitionMounterTextManager.swift */,
C647B395211CF2C40024B9A1 /* EFIPartitionMounterTypes.swift */,
C647B39A211CF2C40024B9A1 /* EFIPartitionMounterUIClasses.swift */,
C647B396211CF2C40024B9A1 /* EFIPartitionMounterViewController.swift */,
C647B397211CF2C40024B9A1 /* EFIPartitionMounterWindowController.swift */,
C660D19A2529BB3B0027FCA0 /* JSON */,
);
name = EFIPartitionMounterTool;
sourceTree = "<group>";
Expand Down Expand Up @@ -463,13 +463,13 @@
C6DE523A247EB6EA00FBD2E1 /* TINU.entitlements */,
C6DF046E1F4F33C500D200B1 /* Info.plist */,
C691BFED1F6DEEA800589EF8 /* Assets.xcassets */,
C600803C251A910800FE35E2 /* JSON */,
C6553A941F5F83DC0048965D /* Resources */,
C6DF046B1F4F33C500D200B1 /* Main.storyboard */,
C698B47D204CDAE5007B3CD8 /* MacrosReference.swift */,
C6DF04651F4F33C500D200B1 /* AppDelegate.swift */,
C60A461423A8571E009ADF4D /* ToDo.swift */,
C649CC8F211A4ECF00A6B47B /* Tools */,
C600803C251A910800FE35E2 /* Json */,
C6553A941F5F83DC0048965D /* Resources */,
C60D39B51F5EB48000D94834 /* WindowsControllers */,
C60D39B71F5EB4C800D94834 /* ViewControllers */,
C60D39B61F5EB4A000D94834 /* OtherCode */,
Expand Down
Binary file modified TINU/.DS_Store
Binary file not shown.
2 changes: 1 addition & 1 deletion TINU/AllertFunctionsWithTextManager.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// Copyright © 2020 Pietro Caruso. All rights reserved.
//

import AppKit
import Cocoa

public func msgboxWithManagerGeneric(_ manager: TextManagerGet, _ handle: ViewID, name: String, parseList: [String: String]! = nil, style: NSAlertStyle = NSAlertStyle.warning, icon: NSImage? = IconsManager.shared.warningIcon){
var title = manager.getViewString(context: handle, stringID: name + "Title")
Expand Down
2 changes: 1 addition & 1 deletion TINU/ChooseSideViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ class ChooseSideViewController: GenericViewController, ViewID {
//ui setup

//print(TextManager!)
print(CodableCreation<TINUTextsManagerStruct>.getEncoded(TextManager!)!)
//print(CodableCreation<TINUTextsManagerStruct>.getEncoded(TextManager!)!)

createUSBButton.upperImage.image = IconsManager.shared.removableDiskIcon //NSImage(named: "Removable")
createUSBButton.upperTitle.stringValue = TextManager.getViewString(context: self, stringID: "openInstaller")//"Create a bootable\nmacOS installer"
Expand Down
10 changes: 8 additions & 2 deletions TINU/ChoseAppViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -146,12 +146,18 @@ class ChoseAppViewController: GenericViewController, ViewID {
}

if open.urls.isEmpty{
msgBoxWarning("Error while opening the file", "No files choosen")
//msgBoxWarning("Error: no files chosen!", "No files seems to have been chosen , proably this is an internal error")

msgboxWithManager(self, name: "errorOpening")

continue
}

guard var path = open.urls.first?.path else {
msgBoxWarning("Error while opening the file", "Impossible to obtain the file's location")
//msgBoxWarning("Error while opening the file's path", "Impossible to obtain the file's location for some reason")

msgboxWithManager(self, name: "errorPath")

continue
}

Expand Down
25 changes: 24 additions & 1 deletion TINU/ChoseDriveViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -153,11 +153,28 @@ class ChoseDriveViewController: ShadowViewController, ViewID {
prt.size = d.Size

log(" Item display name is: \(drivei.volume.stringValue)")

drivei.image.image = nil

if !prt.isDrive{
if item!.isMounted(){
drivei.image.image = NSWorkspace.shared().icon(forFile: item.MountPoint!)
}
}else{
var property = "Ejectable"

if #available(OSX 10.12, *){
property = "RemovableMediaOrExternalDevice"
}

if let i = dm.getDevicePropertyInfoBoolNew(prt.bsdName, propertyName: property) {
if !i{
drivei.image.image = IconsManager.shared.internalDiskIcon
}
}
}

if drivei.image.image == nil{
drivei.image.image = IconsManager.shared.removableDiskIcon
}

Expand Down Expand Up @@ -212,6 +229,7 @@ class ChoseDriveViewController: ShadowViewController, ViewID {
//just need to know which is the boot volume, to not allow the user to choose it
let boot = dm.getDeviceBSDIDFromMountPoint("/")!
var boot_drive = [dm.getDriveBSDIDFromVolumeBSDID(volumeID: boot)]
let execp = Bundle.main.executablePath!

print("Boot volume BSDID: \(boot)")

Expand All @@ -234,7 +252,7 @@ class ChoseDriveViewController: ShadowViewController, ViewID {
print("The boot drive devices are: ")
print(boot_drive)

for d in data.AllDisksAndPartitions{
alldiskFor: for d in data.AllDisksAndPartitions{
log(" Drive: \(d.DeviceIdentifier)")

if boot_drive.contains(d.DeviceIdentifier){
Expand Down Expand Up @@ -266,6 +284,11 @@ class ChoseDriveViewController: ShadowViewController, ViewID {
continue
}

if execp.contains(p.MountPoint!) {
log(" TINU is running from this partition, skipping to the next drive")
continue alldiskFor
}

log(" Partition meets all the requirements, it will be added to the dectected partitions list")

self.makeAndDisplayItem(p, &drives)
Expand Down
2 changes: 1 addition & 1 deletion TINU/ClassExtensions.swift
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// Copyright © 2017 Pietro Caruso. All rights reserved.
//

import AppKit
import Cocoa

//this file just contains some usefoul extensions and methods for system classes

Expand Down
24 changes: 22 additions & 2 deletions TINU/ConfigMenuAppsEn.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"installedAppName" : "Clover Configurator"
},
{
"name" : "OpenCore Configurator",
"name" : "OpenCore Configurator (May break your config.plist)",
"download" : "https://mackie100projects.altervista.org/download-opencore-configurator/",
"installedAppName" : "OpenCore Configurator"
},
Expand All @@ -16,10 +16,30 @@
"installedAppName" : "Xcode"
},
{
"name" : "BBEdit",
"name" : "BBEdit (Contains in-app purchases)",
"download" : "macappstores:\/\/itunes.apple.com/app/bbedit/id404009241?mt=12",
"installedAppName" : "BBEdit"
},
{
"name" : "PlistEdit Pro (May require a paid license)",
"download" : "https://www.fatcatsoftware.com/plisteditpro/",
"installedAppName" : "PlistEdit Pro"
},
{
"name" : "Separator",
"download" : "",
"installedAppName" : ""
},
{
"name" : "Get ProperTree",
"download" : "https://github.com/corpnewt/propertree",
"installedAppName" : "{openLink}"
},
{
"name" : "Separator",
"download" : "",
"installedAppName" : ""
},
{
"name" : "Other app ...",
"download" : "",
Expand Down
Loading

0 comments on commit 4104b31

Please sign in to comment.