Browse Source

update

master
boB Rudis 11 months ago
parent
commit
9d457eef71
No known key found for this signature in database GPG Key ID: 1D7529BE14E2BBA9
11 changed files with 186 additions and 34 deletions
  1. +41
    -16
      RSwitch.xcodeproj/project.pbxproj
  2. +78
    -0
      RSwitch.xcodeproj/xcshareddata/xcschemes/RSwitch.xcscheme
  3. +10
    -2
      RSwitch.xcodeproj/xcuserdata/hrbrmstr.xcuserdatad/xcschemes/xcschememanagement.plist
  4. BIN
      RSwitch.xcworkspace/xcuserdata/hrbrmstr.xcuserdatad/UserInterfaceState.xcuserstate
  5. +2
    -3
      RSwitch/Swift/AppDelegate.swift
  6. +1
    -0
      RSwitch/Swift/HandleRSwitch.swift
  7. +18
    -0
      RSwitch/Swift/Menu.swift
  8. +5
    -0
      RSwitch/Swift/Notify.swift
  9. +2
    -2
      RSwitch/Swift/Utils/Associations.swift
  10. +11
    -1
      RSwitch/Swift/Utils/Preferences.swift
  11. +18
    -10
      rswitch-cmd/Info.plist

+ 41
- 16
RSwitch.xcodeproj/project.pbxproj View File

@ -103,6 +103,7 @@
01A4F40923F3084E005B88C2 /* Reachable.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Reachable.swift; sourceTree = "<group>"; };
01A4F40B23F30DB4005B88C2 /* Associations.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Associations.swift; sourceTree = "<group>"; };
01B611EB232176A200432807 /* NewSessionViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NewSessionViewController.swift; sourceTree = "<group>"; };
01BDA1A5245482CD005DC733 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist; path = Info.plist; sourceTree = "<group>"; };
01D3E439232119DD00E3BC02 /* WebViewController.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WebViewController.swift; sourceTree = "<group>"; };
01D3E43B23211B4C00E3BC02 /* RStudioServerAction.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RStudioServerAction.swift; sourceTree = "<group>"; };
01D3E43E2321315900E3BC02 /* RStudioServerSession.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = RStudioServerSession.swift; sourceTree = "<group>"; };
@ -175,6 +176,7 @@
01575A35245443D7004A5715 /* rswitch-cmd */ = {
isa = PBXGroup;
children = (
01BDA1A5245482CD005DC733 /* Info.plist */,
01575A36245443D7004A5715 /* main.swift */,
);
path = "rswitch-cmd";
@ -313,11 +315,22 @@
};
/* End PBXGroup section */
/* Begin PBXHeadersBuildPhase section */
01BDA1A624548938005DC733 /* Headers */ = {
isa = PBXHeadersBuildPhase;
buildActionMask = 2147483647;
files = (
);
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXHeadersBuildPhase section */
/* Begin PBXNativeTarget section */
01575A33245443D7004A5715 /* rswitch-cmd */ = {
isa = PBXNativeTarget;
buildConfigurationList = 01575A38245443D7004A5715 /* Build configuration list for PBXNativeTarget "rswitch-cmd" */;
buildPhases = (
01BDA1A624548938005DC733 /* Headers */,
01575A30245443D7004A5715 /* Sources */,
01575A31245443D7004A5715 /* Frameworks */,
01575A32245443D7004A5715 /* CopyFiles */,
@ -526,17 +539,21 @@
01575A39245443D7004A5715 /* Debug */ = {
isa = XCBuildConfiguration;
buildSettings = {
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CODE_SIGN_IDENTITY = "Developer ID Application";
CODE_SIGN_STYLE = Manual;
COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_ASSET_PATHS = "";
DEVELOPMENT_TEAM = CBY22P58G8;
ENABLE_HARDENED_RUNTIME = YES;
INFOPLIST_FILE = "$(SRCROOT)/rswitch-cmd/Info.plist";
MACOSX_DEPLOYMENT_TARGET = 10.13;
MARKETING_VERSION = 1.0.0;
PRODUCT_BUNDLE_IDENTIFIER = "is.rud.rswitch-cmd";
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
STRIP_INSTALLED_PRODUCT = NO;
SKIP_INSTALL = YES;
STRIP_INSTALLED_PRODUCT = YES;
SWIFT_VERSION = 5.0;
};
name = Debug;
@ -544,17 +561,21 @@
01575A3A245443D7004A5715 /* Release */ = {
isa = XCBuildConfiguration;
buildSettings = {
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CODE_SIGN_IDENTITY = "Developer ID Application";
CODE_SIGN_STYLE = Manual;
COPY_PHASE_STRIP = NO;
CURRENT_PROJECT_VERSION = 1;
DEVELOPMENT_ASSET_PATHS = "";
DEVELOPMENT_TEAM = CBY22P58G8;
ENABLE_HARDENED_RUNTIME = YES;
INFOPLIST_FILE = "$(SRCROOT)/rswitch-cmd/Info.plist";
MACOSX_DEPLOYMENT_TARGET = 10.13;
MARKETING_VERSION = 1.0.0;
PRODUCT_BUNDLE_IDENTIFIER = "is.rud.rswitch-cmd";
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
STRIP_INSTALLED_PRODUCT = NO;
SKIP_INSTALL = YES;
STRIP_INSTALLED_PRODUCT = YES;
SWIFT_VERSION = 5.0;
};
name = Release;
@ -591,7 +612,7 @@
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = YES;
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = dwarf;
ENABLE_STRICT_OBJC_MSGSEND = YES;
ENABLE_TESTABILITY = YES;
@ -615,6 +636,7 @@
MTL_FAST_MATH = YES;
ONLY_ACTIVE_ARCH = YES;
SDKROOT = macosx;
STRIP_INSTALLED_PRODUCT = NO;
SWIFT_ACTIVE_COMPILATION_CONDITIONS = DEBUG;
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
};
@ -652,7 +674,7 @@
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
CLANG_WARN_UNREACHABLE_CODE = YES;
CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
COPY_PHASE_STRIP = YES;
COPY_PHASE_STRIP = NO;
DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
ENABLE_NS_ASSERTIONS = NO;
ENABLE_STRICT_OBJC_MSGSEND = YES;
@ -670,6 +692,7 @@
MTL_FAST_MATH = YES;
ONLY_ACTIVE_ARCH = NO;
SDKROOT = macosx;
STRIP_INSTALLED_PRODUCT = NO;
SWIFT_COMPILATION_MODE = wholemodule;
SWIFT_OPTIMIZATION_LEVEL = "-O";
};
@ -682,8 +705,8 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = RSwitch/RSwitch.entitlements;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CODE_SIGN_IDENTITY = "Developer ID Application";
CODE_SIGN_STYLE = Manual;
COMBINE_HIDPI_IMAGES = YES;
DEVELOPMENT_TEAM = CBY22P58G8;
ENABLE_HARDENED_RUNTIME = YES;
@ -701,8 +724,9 @@
MARKETING_VERSION = 1.7.0;
PRODUCT_BUNDLE_IDENTIFIER = is.rud.bob.RSwitch;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
STRIP_INSTALLED_PRODUCT = NO;
PROVISIONING_PROFILE_SPECIFIER = "rswitch-1+";
SKIP_INSTALL = NO;
STRIP_INSTALLED_PRODUCT = YES;
SWIFT_OBJC_BRIDGING_HEADER = "RSwitch/ObjC/RSwitch-Bridging-Header.h";
SWIFT_OPTIMIZATION_LEVEL = "-O";
SWIFT_VERSION = 5.0;
@ -716,8 +740,8 @@
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CLANG_ENABLE_MODULES = YES;
CODE_SIGN_ENTITLEMENTS = RSwitch/RSwitch.entitlements;
CODE_SIGN_IDENTITY = "Apple Development";
CODE_SIGN_STYLE = Automatic;
CODE_SIGN_IDENTITY = "Developer ID Application";
CODE_SIGN_STYLE = Manual;
COMBINE_HIDPI_IMAGES = YES;
DEVELOPMENT_TEAM = CBY22P58G8;
ENABLE_HARDENED_RUNTIME = YES;
@ -735,8 +759,9 @@
MARKETING_VERSION = 1.7.0;
PRODUCT_BUNDLE_IDENTIFIER = is.rud.bob.RSwitch;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
STRIP_INSTALLED_PRODUCT = NO;
PROVISIONING_PROFILE_SPECIFIER = "rswitch-1+";
SKIP_INSTALL = NO;
STRIP_INSTALLED_PRODUCT = YES;
SWIFT_OBJC_BRIDGING_HEADER = "RSwitch/ObjC/RSwitch-Bridging-Header.h";
SWIFT_OPTIMIZATION_LEVEL = "-O";
SWIFT_VERSION = 5.0;


+ 78
- 0
RSwitch.xcodeproj/xcshareddata/xcschemes/RSwitch.xcscheme View File

@ -0,0 +1,78 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1140"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "01F3EF07230E635300DF5DF9"
BuildableName = "RSwitch.app"
BlueprintName = "RSwitch"
ReferencedContainer = "container:RSwitch.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "01F3EF07230E635300DF5DF9"
BuildableName = "RSwitch.app"
BlueprintName = "RSwitch"
ReferencedContainer = "container:RSwitch.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "01F3EF07230E635300DF5DF9"
BuildableName = "RSwitch.app"
BlueprintName = "RSwitch"
ReferencedContainer = "container:RSwitch.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>

+ 10
- 2
RSwitch.xcodeproj/xcuserdata/hrbrmstr.xcuserdatad/xcschemes/xcschememanagement.plist View File

@ -7,12 +7,20 @@
<key>RSwitch.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>3</integer>
<integer>2</integer>
</dict>
<key>rswitch-cmd.xcscheme_^#shared#^_</key>
<dict>
<key>orderHint</key>
<integer>2</integer>
<integer>3</integer>
</dict>
</dict>
<key>SuppressBuildableAutocreation</key>
<dict>
<key>01F3EF07230E635300DF5DF9</key>
<dict>
<key>primary</key>
<true/>
</dict>
</dict>
</dict>


BIN
RSwitch.xcworkspace/xcuserdata/hrbrmstr.xcuserdatad/UserInterfaceState.xcuserstate View File


+ 2
- 3
RSwitch/Swift/AppDelegate.swift View File

@ -38,6 +38,7 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSToolbarDelegate {
@objc func performTimer(_ sender: Timer) {
if (Preferences.hourlyRStudioCheck) { performRStudioCheck(sender) }
if (Preferences.ensureFileHandlers) { FileAssociationUtils.setHandlers() }
}
var mainStoryboard: NSStoryboard!
@ -92,9 +93,7 @@ class AppDelegate: NSObject, NSApplicationDelegate, NSToolbarDelegate {
sess = RStudioServerSessionManager()
FileAssociationUtils.getHandlers();
FileAssociationUtils.setHandlers();
FileAssociationUtils.getHandlers();
if (Preferences.ensureFileHandlers) { FileAssociationUtils.setHandlers() }
timer = Timer.scheduledTimer(
timeInterval: 3600,


+ 1
- 0
RSwitch/Swift/HandleRSwitch.swift View File

@ -33,6 +33,7 @@ extension AppDelegate {
withDestinationURL: NSURL(fileURLWithPath: title_link) as URL
)
self.notifyUser(title: "Success", text: "Current R version switched to " + title!)
// self.notifyUserWithDL(title: "Success", subtitle: "Subtitle", text: "Current R version switched to " + title!)
} catch {
self.notifyUser(title: "Action failed", text: "Failed to create alias for " + title_link + " (\(error))")
}


+ 18
- 0
RSwitch/Swift/Menu.swift View File

@ -34,6 +34,18 @@ extension AppDelegate: NSMenuDelegate {
}
}
@objc func toggle_ensure_file_handlers(_ sender: NSMenuItem) {
Preferences.ensureFileHandlers = !Preferences.ensureFileHandlers
if (Preferences.ensureFileHandlers) { FileAssociationUtils.setHandlers() }
if let menu = statusItem.menu, let item = menu.item(withTag: 98) {
item.state = Preferences.ensureFileHandlers.stateValue
}
}
@objc func subscribeToMailingList(_ sender: NSMenuItem) {
NSWorkspace.shared.open(URL(string: "https://lists.sr.ht/~hrbrmstr/rswitch")!)
@ -115,6 +127,12 @@ extension AppDelegate: NSMenuDelegate {
rstudioCheckItem.state = Preferences.hourlyRStudioCheck.stateValue
prefSub.addItem(rstudioCheckItem)
let fileHandlersCheckItem = NSMenuItem(title: "Ensure RStudio opens R/Rmd files", action: #selector(toggle_ensure_file_handlers), keyEquivalent: "")
fileHandlersCheckItem.tag = 97
fileHandlersCheckItem.target = self
fileHandlersCheckItem.state = Preferences.ensureFileHandlers.stateValue
prefSub.addItem(fileHandlersCheckItem)
menu.addItem(NSMenuItem(title: "Check for update…", action: #selector(checkForUpdate), keyEquivalent: ""))
menu.addItem(NSMenuItem(title: "Subscribe to mailing list…", action: #selector(subscribeToMailingList), keyEquivalent: ""))
menu.addItem(NSMenuItem(title: "About RSwitch…", action: #selector(showAbout), keyEquivalent: ""))


+ 5
- 0
RSwitch/Swift/Notify.swift View File

@ -16,10 +16,12 @@ extension AppDelegate : NSUserNotificationCenterDelegate {
let notification = NSUserNotification()
// notification.identifier = "RSwitch"
notification.title = title
notification.subtitle = subtitle
notification.informativeText = text
notification.hasActionButton = true
notification.otherButtonTitle = "Dismiss"
notification.actionButtonTitle = "Download"
notification.soundName = NSUserNotificationDefaultSoundName
@ -34,6 +36,7 @@ extension AppDelegate : NSUserNotificationCenterDelegate {
let notification = NSUserNotification()
// notification.identifier = "RSwitch"
notification.title = title
notification.subtitle = subtitle
notification.informativeText = text
@ -46,10 +49,12 @@ extension AppDelegate : NSUserNotificationCenterDelegate {
}
func userNotificationCenter(_ center: NSUserNotificationCenter, shouldPresent notification: NSUserNotification) -> Bool {
print("should present")
return(true)
}
func userNotificationCenter(_ center: NSUserNotificationCenter, didActivate notification: NSUserNotification) {
print("did activate")
print(notification)
}


+ 2
- 2
RSwitch/Swift/Utils/Associations.swift View File

@ -45,12 +45,12 @@ class FileAssociationUtils {
public static func setHandlers() {
let setResR : String = UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension, "R" as CFString, nil)?.takeRetainedValue() as String? ?? "";
NSLog("UTI of .R extension: " + setResR);
//NSLog("UTI of .R extension: " + setResR);
LSSetDefaultRoleHandlerForContentType(setResR as CFString, LSRolesMask.all, "org.rstudio.RStudio" as CFString);
let setResRmd : String = UTTypeCreatePreferredIdentifierForTag(kUTTagClassFilenameExtension, "Rmd" as CFString, nil)?.takeRetainedValue() as String? ?? "";
NSLog("UTI of .Rmd extension: " + setResRmd);
//NSLog("UTI of .Rmd extension: " + setResRmd);
LSSetDefaultRoleHandlerForContentType(setResRmd as CFString, LSRolesMask.all, "org.rstudio.RStudio" as CFString);


+ 11
- 1
RSwitch/Swift/Utils/Preferences.swift View File

@ -21,6 +21,7 @@ extension UserDefaults {
enum Key: String {
case showDockIcon = "showDockIcon"
case hourlyRStudioCheck = "hourlyRStudioCheck"
case ensureFileHandlers = "ensureFileHandlers"
case firstRunGone = "firstRunGone"
case lastVersionNotified = ""
}
@ -86,10 +87,19 @@ struct Preferences {
defaults.synchronize()
}
}
static var ensureFileHandlers: Bool {
get { return(defaults.bool(forKey: .ensureFileHandlers)) }
set {
defaults.set(newValue, forKey: .ensureFileHandlers)
defaults.synchronize()
}
}
static func restore() {
Preferences.showDockIcon = false
Preferences.hourlyRStudioCheck = false
Preferences.ensureFileHandlers = false
Preferences.lastVersionNotified = ""
}


+ 18
- 10
rswitch-cmd/Info.plist View File

@ -1,14 +1,22 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleIdentifier</key>
<string>is.rud.rswitch-cmd</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>61.0</string>
<key>CFBundleName</key>
<string>rswitch-cmd</string>
<key>CFBundleVersion</key>
<string>1.0</string>
<key>CFBundleDevelopmentRegion</key>
<string>English</string>
<key>CFBundleExecutable</key>
<string></string>
<key>CFBundleIdentifier</key>
<string>is.rud.rswitch-cmd</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>rswitch-cmd</string>
<key>CFBundleShortVersionString</key>
<string>$(MARKETING_VERSION)</string>
<key>CFBundleVersion</key>
<string>$(CURRENT_PROJECT_VERSION)</string>
<key>NSHumanReadableCopyright</key>
<string>Copyright © 2020 Bob Rudis. All rights reserved. MIT Licensed</string>
</dict>
</plist>

Loading…
Cancel
Save