diff --git a/FlashlightApp/EasySIMBL/AppDelegate.m b/FlashlightApp/EasySIMBL/AppDelegate.m index 24ef457a..872390ff 100755 --- a/FlashlightApp/EasySIMBL/AppDelegate.m +++ b/FlashlightApp/EasySIMBL/AppDelegate.m @@ -20,6 +20,8 @@ @interface AppDelegate () @property (nonatomic,weak) IBOutlet NSMenuItem *createNewAutomatorPluginMenuItem; @property (nonatomic,weak) IBOutlet NSTextField *versionLabel, *searchAnything; @property (nonatomic,weak) IBOutlet NSButton *openGithub, *requestPlugin, *leaveFeedback; +@property (nonatomic,weak) IBOutlet NSWindow *aboutWindow; +@property (nonatomic,weak) IBOutlet NSButton *menuBarItemPreferenceButton; @end @@ -47,7 +49,7 @@ - (void)applicationWillFinishLaunching:(NSNotification *)aNotification [self checkSpotlightVersion]; - [self setupURLHandling]; + [self setupDefaults]; self.versionLabel.stringValue = [[NSBundle mainBundle] infoDictionary][@"CFBundleShortVersionString"]; @@ -116,8 +118,13 @@ - (void)applicationWillFinishLaunching:(NSNotification *)aNotification self.openGithub.stringValue = NSLocalizedString(@"Contribute on GitHub", @""); self.requestPlugin.stringValue = NSLocalizedString(@"Request a Plugin", @""); self.searchAnything.stringValue = NSLocalizedString(@"Search anything.", @""); + self.menuBarItemPreferenceButton.stringValue = NSLocalizedString(@"Show menu bar item", @""); + [self.menuBarItemPreferenceButton sizeToFit]; + self.menuBarItemPreferenceButton.frame = NSMakeRect(self.menuBarItemPreferenceButton.superview.bounds.size.width/2 - self.menuBarItemPreferenceButton.frame.size.width/2, self.menuBarItemPreferenceButton.frame.origin.y, self.menuBarItemPreferenceButton.frame.size.width, self.menuBarItemPreferenceButton.frame.size.height); [UpdateChecker shared]; // begin fetch + + [self setupURLHandling]; } - (void)applicationDidFinishLaunching:(NSNotification *)notification { @@ -300,7 +307,34 @@ - (void)handleURLEvent:(NSAppleEventDescriptor *)event withReplyEvent:(NSAppleEv [self.pluginListController showCategory:parts[1]]; } else if (parts.count == 1 && [parts[0] isEqualToString:@"search"]) { [self.pluginListController showSearch:query[@"q"]]; + } else if (parts.count >= 1 && [parts[0] isEqualToString:@"preferences"]) { + if (parts.count == 2 && [parts[1] isEqualToString:@"menuBarItem"]) { + [self.aboutWindow makeKeyAndOrderFront:nil]; + dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0.1 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ + // in case we're mid-launch — we don't want the main window to be made key above this window + [self.aboutWindow makeKeyAndOrderFront:nil]; + }); + } } } } +#pragma mark Preferences +- (void)setupDefaults { + NSDictionary *defaults = @{ + @"ShowMenuItem": @YES + }; + for (NSString *key in defaults) { + if (![[NSUserDefaults standardUserDefaults] valueForKey:key]) { + [[NSUserDefaults standardUserDefaults] setValue:defaults[key] forKey:key]; + } + } +} + +- (IBAction)showMenuBarItemPressed:(id)sender { + dispatch_after(dispatch_time(DISPATCH_TIME_NOW, (int64_t)(0 * NSEC_PER_SEC)), dispatch_get_main_queue(), ^{ + [[NSUserDefaults standardUserDefaults] synchronize]; + [[NSDistributedNotificationCenter defaultCenter] postNotificationName:@"com.nateparrott.Flashlight.DefaultsChanged" object:@"com.nateparrott.Flashlight" userInfo:nil options:NSNotificationPostToAllSessions | NSNotificationDeliverImmediately]; + }); +} + @end diff --git a/FlashlightApp/EasySIMBL/Base.lproj/MainMenu.xib b/FlashlightApp/EasySIMBL/Base.lproj/MainMenu.xib index f4c50b89..b615b546 100755 --- a/FlashlightApp/EasySIMBL/Base.lproj/MainMenu.xib +++ b/FlashlightApp/EasySIMBL/Base.lproj/MainMenu.xib @@ -348,7 +348,9 @@ + + @@ -591,23 +593,23 @@ - + - + - + - + - + @@ -616,7 +618,7 @@ - + @@ -647,7 +649,7 @@ - + @@ -656,7 +658,7 @@ + - + diff --git a/FlashlightApp/EasySIMBL/Flashlight-Info.plist b/FlashlightApp/EasySIMBL/Flashlight-Info.plist index 517f0295..dbee78b6 100755 --- a/FlashlightApp/EasySIMBL/Flashlight-Info.plist +++ b/FlashlightApp/EasySIMBL/Flashlight-Info.plist @@ -38,7 +38,7 @@ CFBundlePackageType APPL CFBundleShortVersionString - 0.97.0 + 0.97.1 CFBundleSignature ???? CFBundleURLTypes @@ -65,7 +65,7 @@ CFBundleVersion - 41 + 42 LSApplicationCategoryType public.app-category.utilities LSMinimumSystemVersion diff --git a/FlashlightApp/SIMBL Agent/Base.lproj/MainMenu.xib b/FlashlightApp/SIMBL Agent/Base.lproj/MainMenu.xib index d32b65bb..88151233 100755 --- a/FlashlightApp/SIMBL Agent/Base.lproj/MainMenu.xib +++ b/FlashlightApp/SIMBL Agent/Base.lproj/MainMenu.xib @@ -1163,12 +1163,30 @@ submenuAction: - + + + + YES + YES + + + 2147483647 + + + + + + Hide this menu... + + 2147483647 + + + @@ -1702,6 +1720,14 @@ 475 + + + hideThisMenu: + + + + 480 + delegate @@ -2568,6 +2594,8 @@ + + @@ -2610,6 +2638,16 @@ + + 478 + + + + + 479 + + + @@ -2732,6 +2770,8 @@ com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin @@ -2753,7 +2793,7 @@ - 477 + 480 @@ -2777,6 +2817,7 @@ UIManager id + id id @@ -2784,6 +2825,10 @@ getNewPlugins: id + + hideThisMenu: + id + managePlugins: id diff --git a/FlashlightApp/SIMBL Agent/UIManager.m b/FlashlightApp/SIMBL Agent/UIManager.m index 45d6fe1c..150ee49a 100644 --- a/FlashlightApp/SIMBL Agent/UIManager.m +++ b/FlashlightApp/SIMBL Agent/UIManager.m @@ -15,6 +15,7 @@ @interface UIManager () @property (nonatomic) NSStatusItem *statusItem; @property (nonatomic) IBOutlet NSMenu *statusMenu; @property (nonatomic) IBOutlet NSMenu *pluginExamples; +@property (nonatomic) BOOL statusItemShown; @end @@ -23,12 +24,33 @@ @implementation UIManager - (void)awakeFromNib { [super awakeFromNib]; - self.statusItem = [[NSStatusBar systemStatusBar] statusItemWithLength:NSSquareStatusItemLength]; - [self.statusItem setHighlightMode:YES]; - NSImage *image = [NSImage imageNamed:@"StatusItemOn"]; - [image setTemplate:YES]; - self.statusItem.image = image; - self.statusItem.menu = self.statusMenu; + [[NSDistributedNotificationCenter defaultCenter] addObserver:self selector:@selector(settingsChanged:) name:@"com.nateparrott.Flashlight.DefaultsChanged" object:@"com.nateparrott.Flashlight"]; + [self settingsChanged:nil]; +} + +- (void)settingsChanged:(id)notif { + NSLog(@"SETTINGS CHANGED"); + CFPreferencesAppSynchronize(CFSTR("com.nateparrott.Flashlight")); + Boolean exists; + Boolean showMenuItem = CFPreferencesGetAppBooleanValue(CFSTR("ShowMenuItem"), CFSTR("com.nateparrott.Flashlight"), &exists); + self.statusItemShown = showMenuItem || !exists; +} + +- (void)setStatusItemShown:(BOOL)statusItemShown { + if (statusItemShown != _statusItemShown) { + _statusItemShown = statusItemShown; + if (statusItemShown) { + self.statusItem = [[NSStatusBar systemStatusBar] statusItemWithLength:NSSquareStatusItemLength]; + [self.statusItem setHighlightMode:YES]; + NSImage *image = [NSImage imageNamed:@"StatusItemOn"]; + [image setTemplate:YES]; + self.statusItem.image = image; + self.statusItem.menu = self.statusMenu; + } else { + [[NSStatusBar systemStatusBar] removeStatusItem:self.statusItem]; + self.statusItem = nil; + } + } } - (IBAction)managePlugins:(id)sender { @@ -79,4 +101,8 @@ - (void)openExample:(NSMenuItem *)sender { } +- (IBAction)hideThisMenu:(id)sender { + [[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:@"flashlight://preferences/menuBarItem"]]; +} + @end diff --git a/FlashlightApp/SIMBL.xcodeproj/project.pbxproj b/FlashlightApp/SIMBL.xcodeproj/project.pbxproj index 040b1e81..7c3ecd42 100755 --- a/FlashlightApp/SIMBL.xcodeproj/project.pbxproj +++ b/FlashlightApp/SIMBL.xcodeproj/project.pbxproj @@ -411,7 +411,7 @@ INSTALL_PATH = ""; MACOSX_DEPLOYMENT_TARGET = 10.10; PRODUCT_NAME = "$(TARGET_NAME)"; - PRODUCT_VERSION = 9; + PRODUCT_VERSION = 10; }; name = Debug; }; @@ -425,7 +425,7 @@ INSTALL_PATH = ""; MACOSX_DEPLOYMENT_TARGET = 10.10; PRODUCT_NAME = "$(TARGET_NAME)"; - PRODUCT_VERSION = 9; + PRODUCT_VERSION = 10; }; name = Release; }; diff --git a/FlashlightApp/SpotlightSIMBL/SpotlightSIMBL/Info.plist b/FlashlightApp/SpotlightSIMBL/SpotlightSIMBL/Info.plist index 8aea4c59..242c142b 100644 --- a/FlashlightApp/SpotlightSIMBL/SpotlightSIMBL/Info.plist +++ b/FlashlightApp/SpotlightSIMBL/SpotlightSIMBL/Info.plist @@ -19,7 +19,7 @@ CFBundleSignature ???? CFBundleVersion - 12 + 13 NSHumanReadableCopyright Copyright © 2014 Nate Parrott. All rights reserved. NSPrincipalClass diff --git a/flashlightplugins/static/images/Icon-Large.png b/flashlightplugins/static/images/Icon-Large.png new file mode 100644 index 00000000..134975e2 Binary files /dev/null and b/flashlightplugins/static/images/Icon-Large.png differ diff --git a/flashlightplugins/static/images/favicon.png b/flashlightplugins/static/images/favicon.png index eeebe045..c2abacc6 100644 Binary files a/flashlightplugins/static/images/favicon.png and b/flashlightplugins/static/images/favicon.png differ