Skip to content

Commit

Permalink
Merge branch 'rtoshiro-master'
Browse files Browse the repository at this point in the history
  • Loading branch information
savvycom-copilot committed Oct 29, 2014
2 parents 1b69045 + 1778d69 commit b431c92
Show file tree
Hide file tree
Showing 3 changed files with 95 additions and 27 deletions.
2 changes: 2 additions & 0 deletions SimulatorManager/AppDelegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
#import <Cocoa/Cocoa.h>
#import "LaunchAtLoginController.h"

#define RecentAppsOnKey @"RecentAppsOn"

@interface AppDelegate : NSObject <NSApplicationDelegate, NSMenuDelegate>{
IBOutlet NSMenu *menu;
IBOutlet NSArrayController *arrayController;
Expand Down
51 changes: 44 additions & 7 deletions SimulatorManager/AppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ @interface AppDelegate()<NSUserNotificationCenterDelegate>
@property (assign, nonatomic) BOOL recentAppUpdate;
@property (weak) IBOutlet NSMenuItem *eraseMenuItem;

@property (nonatomic, assign) BOOL recentAppDisabled;
@property (nonatomic, weak) IBOutlet NSMenuItem *recentAppMenuItem;

@end
@implementation AppDelegate
- (void)applicationDidFinishLaunching:(NSNotification *)notification {
Expand Down Expand Up @@ -46,7 +49,12 @@ - (void) awakeFromNib {

[statusItem setImage:image];
[statusItem setAlternateImage:alternateImage];


self.recentAppDisabled = [[NSUserDefaults standardUserDefaults] boolForKey:RecentAppsOnKey];
if (self.recentAppDisabled)
self.recentAppMenuItem.title = @"Enable Recent Apps";
else
self.recentAppMenuItem.title = @"Disable Recent Apps";

launchAtLoginController = [[LaunchAtLoginController alloc] init];
self.launchAtLoginMenuItem.state = launchAtLoginController.launchAtLogin ? NSOnState : NSOffState;
Expand Down Expand Up @@ -80,7 +88,7 @@ - (void)menuWillOpen:(NSMenu *)menu {
- (void) loadMenu {
// Clear out the hosts so we can start over
NSUInteger n = [[menu itemArray] count];
for (int i=0;i<n-6;i++) {
for (int i=0;i<n-7;i++) {
[menu removeItemAtIndex:0];
}

Expand All @@ -103,7 +111,9 @@ - (void) loadMenu {
[self buildMenuForSimulator:self.simulators addToMenu:menu];

//Load recent app
[self buildMenuForRecentsAddToMenu:menu];
BOOL recentAppDisabled = [[NSUserDefaults standardUserDefaults] boolForKey:RecentAppsOnKey];
if (!recentAppDisabled)
[self buildMenuForRecentsAddToMenu:menu];
}

- (void)buildMenuForSimulator:(NSArray *)simulatorArray addToMenu:(NSMenu *)m {
Expand All @@ -115,14 +125,25 @@ - (void)buildMenuForSimulator:(NSArray *)simulatorArray addToMenu:(NSMenu *)m {
[menuItem setTitle:[simulator.name stringByAppendingFormat:@" (%@)", simulator.runtimeVersion]];
[menuItem setSubmenu:subMenu];
menuItem.target = self;
menuItem.action = @selector(openSimulatorFolder:);
menuItem.action = nil;//@selector(openSimulatorFolder:);
[m insertItem:menuItem atIndex:menuIndex];
[self buildApplicationMenu:[simulator applications] addToMenu:subMenu simulator:simulator];
}
}
- (void)buildApplicationMenu:(NSArray *)apps addToMenu:(NSMenu *)m simulator:(Simulator *)simulator {
NSFileManager *fileManager = [NSFileManager defaultManager];


NSMenuItem* menuItem = [[NSMenuItem alloc] init];
[menuItem setTitle:@"Simulator Folder"];
[menuItem setRepresentedObject:simulator];
menuItem.target = self;
menuItem.action = @selector(openSimulatorFolder:);
[m addItem:menuItem];
NSString *rootPath = simulator.path;
if (![fileManager fileExistsAtPath:rootPath]) {
menuItem.image = [NSImage imageNamed:@"warning"];
}

{
NSMenuItem* menuItem = [[NSMenuItem alloc] init];
[menuItem setTitle:@"App Data Folder"];
Expand All @@ -134,7 +155,7 @@ - (void)buildApplicationMenu:(NSArray *)apps addToMenu:(NSMenu *)m simulator:(Si
[m addItem:separator];
NSString *dataPath = [simulator appDataPath:nil];
if (![fileManager fileExistsAtPath:dataPath]) {
menuItem.image = [NSImage imageNamed:@"Warning"];
menuItem.image = [NSImage imageNamed:@"warning"];
}
}

Expand All @@ -149,7 +170,7 @@ - (void)buildApplicationMenu:(NSArray *)apps addToMenu:(NSMenu *)m simulator:(Si
[m addItem:menuItem];
NSString *dataPath = [app dataPath];
if (![fileManager fileExistsAtPath:dataPath]) {
menuItem.image = [NSImage imageNamed:@"Warning"];
menuItem.image = [NSImage imageNamed:@"warning"];
}

}
Expand Down Expand Up @@ -253,6 +274,22 @@ - (void)performEraseSimulators {
});
}

- (IBAction)toggleRecentApps:(id)sender
{
NSMenuItem *menuItem = sender;
if ([menuItem.title rangeOfString:@"Disable"].length > 0)
menuItem.title = @"Enable Recent Apps";
else
menuItem.title = @"Disable Recent Apps";

self.recentAppDisabled = !self.recentAppDisabled;
[[NSUserDefaults standardUserDefaults] setBool:self.recentAppDisabled forKey:RecentAppsOnKey];
[[NSUserDefaults standardUserDefaults] synchronize];

[self loadMenu];

}

- (IBAction)launchAtLogin:(id)sender {
NSMenuItem *menuItem = sender;
if (menuItem.state == NSOffState) menuItem.state = NSOnState;
Expand Down
69 changes: 49 additions & 20 deletions SimulatorManager/en.lproj/MainMenu.xib
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
<archive type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="8.00">
<data>
<int key="IBDocument.SystemTarget">1080</int>
<string key="IBDocument.SystemVersion">14A388a</string>
<string key="IBDocument.InterfaceBuilderVersion">6245</string>
<string key="IBDocument.SystemVersion">14A389</string>
<string key="IBDocument.InterfaceBuilderVersion">6250</string>
<string key="IBDocument.AppKitVersion">1343.14</string>
<string key="IBDocument.HIToolboxVersion">755.00</string>
<object class="NSMutableDictionary" key="IBDocument.PluginVersions">
<string key="NS.key.0">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="NS.object.0">6245</string>
<string key="NS.object.0">6250</string>
</object>
<array key="IBDocument.IntegratedClassDependencies">
<string>NSArrayController</string>
Expand Down Expand Up @@ -128,6 +128,14 @@
<reference key="NSMixedImage" ref="502551668"/>
</object>
<object class="NSMenuItem" id="605965567">
<reference key="NSMenu" ref="862705665"/>
<string key="NSTitle">Disable Recent Apps</string>
<string key="NSKeyEquiv"/>
<int key="NSMnemonicLoc">2147483647</int>
<reference key="NSOnImage" ref="35465992"/>
<reference key="NSMixedImage" ref="502551668"/>
</object>
<object class="NSMenuItem" id="586187136">
<reference key="NSMenu" ref="862705665"/>
<string key="NSTitle">Launch At Login</string>
<string key="NSKeyEquiv"/>
Expand Down Expand Up @@ -207,21 +215,29 @@
</object>
<int key="connectionID">495</int>
</object>
<object class="IBConnectionRecord">
<object class="IBActionConnection" key="connection">
<string key="label">eraseAllSimulators:</string>
<reference key="source" ref="1014"/>
<reference key="destination" ref="547763140"/>
</object>
<int key="connectionID">663</int>
</object>
<object class="IBConnectionRecord">
<object class="IBActionConnection" key="connection">
<string key="label">launchAtLogin:</string>
<reference key="source" ref="1014"/>
<reference key="destination" ref="605965567"/>
<reference key="destination" ref="586187136"/>
</object>
<int key="connectionID">659</int>
<int key="connectionID">667</int>
</object>
<object class="IBConnectionRecord">
<object class="IBActionConnection" key="connection">
<string key="label">eraseAllSimulators:</string>
<string key="label">toggleRecentApps:</string>
<reference key="source" ref="1014"/>
<reference key="destination" ref="547763140"/>
<reference key="destination" ref="605965567"/>
</object>
<int key="connectionID">663</int>
<int key="connectionID">668</int>
</object>
<object class="IBConnectionRecord">
<object class="IBOutletConnection" key="connection">
Expand Down Expand Up @@ -265,19 +281,19 @@
</object>
<object class="IBConnectionRecord">
<object class="IBOutletConnection" key="connection">
<string key="label">launchAtLoginMenuItem</string>
<string key="label">eraseMenuItem</string>
<reference key="source" ref="976324537"/>
<reference key="destination" ref="605965567"/>
<reference key="destination" ref="547763140"/>
</object>
<int key="connectionID">660</int>
<int key="connectionID">664</int>
</object>
<object class="IBConnectionRecord">
<object class="IBOutletConnection" key="connection">
<string key="label">eraseMenuItem</string>
<string key="label">recentAppMenuItem</string>
<reference key="source" ref="976324537"/>
<reference key="destination" ref="547763140"/>
<reference key="destination" ref="605965567"/>
</object>
<int key="connectionID">664</int>
<int key="connectionID">669</int>
</object>
</array>
<object class="IBMutableOrderedSet" key="objectRecords">
Expand Down Expand Up @@ -367,6 +383,7 @@
<reference ref="605965567"/>
<reference ref="547763140"/>
<reference ref="158591610"/>
<reference ref="586187136"/>
</array>
<reference key="parent" ref="0"/>
</object>
Expand Down Expand Up @@ -404,7 +421,6 @@
<int key="objectID">658</int>
<reference key="object" ref="605965567"/>
<reference key="parent" ref="862705665"/>
<string key="objectName">Launch At Login</string>
</object>
<object class="IBObjectRecord">
<int key="objectID">661</int>
Expand All @@ -417,6 +433,12 @@
<reference key="object" ref="158591610"/>
<reference key="parent" ref="862705665"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">665</int>
<reference key="object" ref="586187136"/>
<reference key="parent" ref="862705665"/>
<string key="objectName">Launch At Login</string>
</object>
</array>
</object>
<dictionary class="NSMutableDictionary" key="flattenedProperties">
Expand All @@ -441,12 +463,13 @@
<string key="658.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="661.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="662.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="665.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
</dictionary>
<dictionary class="NSMutableDictionary" key="unlocalizedProperties"/>
<nil key="activeLocalization"/>
<dictionary class="NSMutableDictionary" key="localizations"/>
<nil key="sourceID"/>
<int key="maxID">664</int>
<int key="maxID">669</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<array class="NSMutableArray" key="referencedPartialClassDescriptions">
Expand Down Expand Up @@ -479,6 +502,7 @@
<string key="launchAtLogin:">id</string>
<string key="quit:">id</string>
<string key="showAbout:">id</string>
<string key="toggleRecentApps:">id</string>
</dictionary>
<dictionary class="NSMutableDictionary" key="actionInfosByName">
<object class="IBActionInfo" key="eraseAllSimulators:">
Expand All @@ -497,10 +521,15 @@
<string key="name">showAbout:</string>
<string key="candidateClassName">id</string>
</object>
<object class="IBActionInfo" key="toggleRecentApps:">
<string key="name">toggleRecentApps:</string>
<string key="candidateClassName">id</string>
</object>
</dictionary>
<dictionary class="NSMutableDictionary" key="outlets">
<string key="eraseMenuItem">NSMenuItem</string>
<string key="launchAtLoginMenuItem">NSMenuItem</string>
<string key="recentAppMenuItem">NSMenuItem</string>
</dictionary>
<dictionary class="NSMutableDictionary" key="toOneOutletInfosByName">
<object class="IBToOneOutletInfo" key="eraseMenuItem">
Expand All @@ -511,6 +540,10 @@
<string key="name">launchAtLoginMenuItem</string>
<string key="candidateClassName">NSMenuItem</string>
</object>
<object class="IBToOneOutletInfo" key="recentAppMenuItem">
<string key="name">recentAppMenuItem</string>
<string key="candidateClassName">NSMenuItem</string>
</object>
</dictionary>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBProjectSource</string>
Expand Down Expand Up @@ -604,10 +637,6 @@
<int key="IBDocument.localizationMode">0</int>
<string key="IBDocument.TargetRuntimeIdentifier">IBCocoaFramework</string>
<bool key="IBDocument.previouslyAttemptedUpgradeToXcode5">NO</bool>
<object class="NSMutableDictionary" key="IBDocument.PluginDeclaredDependencyDefaults">
<string key="NS.key.0">com.apple.InterfaceBuilder.CocoaPlugin.macosx</string>
<real value="1080" key="NS.object.0"/>
</object>
<object class="NSMutableDictionary" key="IBDocument.PluginDeclaredDevelopmentDependencies">
<string key="NS.key.0">com.apple.InterfaceBuilder.CocoaPlugin.InterfaceBuilder3</string>
<integer value="4600" key="NS.object.0"/>
Expand Down

0 comments on commit b431c92

Please sign in to comment.