mirror of
https://github.com/nicoverbruggen/phpmon.git
synced 2025-08-07 20:10:08 +02:00
👌 Fix launching apps with spaces in name, add window position (#68)
This commit is contained in:
@ -777,7 +777,7 @@
|
||||
CODE_SIGN_IDENTITY = "Apple Development";
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
COMBINE_HIDPI_IMAGES = YES;
|
||||
CURRENT_PROJECT_VERSION = 110;
|
||||
CURRENT_PROJECT_VERSION = 120;
|
||||
DEVELOPMENT_TEAM = 8M54J5J787;
|
||||
ENABLE_HARDENED_RUNTIME = YES;
|
||||
INFOPLIST_FILE = phpmon/Info.plist;
|
||||
@ -786,7 +786,7 @@
|
||||
"@executable_path/../Frameworks",
|
||||
);
|
||||
MACOSX_DEPLOYMENT_TARGET = 11.0;
|
||||
MARKETING_VERSION = "4.1-beta5";
|
||||
MARKETING_VERSION = "4.1-rc1";
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.nicoverbruggen.phpmon;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
PROVISIONING_PROFILE_SPECIFIER = "";
|
||||
@ -802,7 +802,7 @@
|
||||
CODE_SIGN_IDENTITY = "Apple Development";
|
||||
CODE_SIGN_STYLE = Automatic;
|
||||
COMBINE_HIDPI_IMAGES = YES;
|
||||
CURRENT_PROJECT_VERSION = 110;
|
||||
CURRENT_PROJECT_VERSION = 120;
|
||||
DEVELOPMENT_TEAM = 8M54J5J787;
|
||||
ENABLE_HARDENED_RUNTIME = YES;
|
||||
INFOPLIST_FILE = phpmon/Info.plist;
|
||||
@ -811,7 +811,7 @@
|
||||
"@executable_path/../Frameworks",
|
||||
);
|
||||
MACOSX_DEPLOYMENT_TARGET = 11.0;
|
||||
MARKETING_VERSION = "4.1-beta5";
|
||||
MARKETING_VERSION = "4.1-rc1";
|
||||
PRODUCT_BUNDLE_IDENTIFIER = com.nicoverbruggen.phpmon;
|
||||
PRODUCT_NAME = "$(TARGET_NAME)";
|
||||
PROVISIONING_PROFILE_SPECIFIER = "";
|
||||
|
@ -15,7 +15,7 @@ import Foundation
|
||||
class Application {
|
||||
|
||||
enum AppType {
|
||||
case editor, browser, gitgui, terminal
|
||||
case editor, browser, git_gui, terminal
|
||||
}
|
||||
|
||||
/// Name of the app. Used for display purposes and to determine `name.app` exists.
|
||||
@ -24,25 +24,25 @@ class Application {
|
||||
/// Application type. Depending on the type, a different action might occur.
|
||||
let type: AppType
|
||||
|
||||
/// Initializer.
|
||||
/// Initializer. Used to detect a specific app of a specific type.
|
||||
init(_ name: String, _ type: AppType) {
|
||||
self.name = name
|
||||
self.type = type
|
||||
}
|
||||
|
||||
/**
|
||||
Attempt to open a specific directory in the editor of choice.
|
||||
This will open the editor if it isn't open yet.
|
||||
Attempt to open a specific directory in the app of choice.
|
||||
(This will open the app if it isn't open yet.)
|
||||
*/
|
||||
@objc public func openDirectory(file: String) {
|
||||
return Shell.run("/usr/bin/open -a \(self.name) \(file)")
|
||||
return Shell.run("/usr/bin/open -a \"\(name)\" \(file)")
|
||||
}
|
||||
|
||||
/** Checks if the app is installed. */
|
||||
func isInstalled() -> Bool {
|
||||
// If this script does not complain, the app exists!
|
||||
return Shell.user.execute(
|
||||
"/usr/bin/open -Ra \"\(self.name)\"",
|
||||
"/usr/bin/open -Ra \"\(name)\"",
|
||||
requiresPath: false,
|
||||
waitUntilExit: true
|
||||
).task.terminationStatus == 0
|
||||
@ -56,7 +56,7 @@ class Application {
|
||||
Application("PhpStorm", .editor),
|
||||
Application("Visual Studio Code", .editor),
|
||||
Application("Sublime Text", .editor),
|
||||
Application("Sublime Merge", .gitgui),
|
||||
Application("Sublime Merge", .git_gui),
|
||||
Application("iTerm", .terminal)
|
||||
].filter {
|
||||
return $0.isInstalled()
|
||||
|
@ -25,6 +25,18 @@ class PMWindowController: NSWindowController, NSWindowDelegate {
|
||||
App.shared.register(window: windowName)
|
||||
}
|
||||
|
||||
public func positionWindowInTopLeftCorner() {
|
||||
guard let frame = NSScreen.main?.frame else { return }
|
||||
guard let window = self.window else { return }
|
||||
|
||||
window.setFrame(NSRect(
|
||||
x: frame.size.width - window.frame.size.width - 20,
|
||||
y: frame.size.height - window.frame.size.height - 40,
|
||||
width: window.frame.width,
|
||||
height: window.frame.height
|
||||
), display: true)
|
||||
}
|
||||
|
||||
func windowWillClose(_ notification: Notification) {
|
||||
App.shared.remove(window: windowName)
|
||||
}
|
||||
|
@ -57,6 +57,7 @@ class PrefsVC: NSViewController {
|
||||
windowController.window!.delegate = delegate
|
||||
windowController.window!.styleMask = [.titled, .closable, .miniaturizable]
|
||||
windowController.window!.delegate = windowController
|
||||
windowController.positionWindowInTopLeftCorner()
|
||||
|
||||
App.shared.preferencesWindowController = windowController
|
||||
}
|
||||
|
@ -56,6 +56,7 @@ class SiteListVC: NSViewController, NSTableViewDelegate, NSTableViewDataSource {
|
||||
]
|
||||
windowController.window!.minSize = NSSize(width: 550, height: 200)
|
||||
windowController.window!.delegate = windowController
|
||||
windowController.positionWindowInTopLeftCorner()
|
||||
|
||||
App.shared.siteListWindowController = windowController
|
||||
}
|
||||
|
Reference in New Issue
Block a user