Skip to content

Commit 85751a0

Browse files
committed
32ビット対応のみかどうか表示する機能実装
1 parent 3dc1bfa commit 85751a0

2 files changed

Lines changed: 51 additions & 8 deletions

File tree

SwitchMenu/AppDelegate.m

Lines changed: 39 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,11 +35,13 @@ @interface AppDelegate ()
3535
@property (weak) IBOutlet NSMenuItem *miOrderAppName;
3636
@property (weak) IBOutlet NSMenuItem *miOrderLaunchTime;
3737
@property (weak) IBOutlet NSMenuItem *miShowNumberOfWindows;
38+
@property (weak) IBOutlet NSMenuItem *miShow32BitOnly;
3839

3940
@property (assign) NSInteger iMenuTitle;
4041
@property (assign) NSInteger iIconSmall;
4142
@property (assign) NSInteger iOrder;
4243
@property (assign) NSInteger iShowNumberOfWindows;
44+
@property (assign) NSInteger iShow32BitOnly;
4345

4446
@property (strong, retain) NSStatusItem *sbItem;
4547
@property (strong, retain) NSMutableArray *apps;
@@ -97,7 +99,7 @@ - (void)changeMenuTitle
9799

98100
switch (self.iMenuTitle) {
99101
case 0: {
100-
self.sbItem.title = app.localizedName;
102+
self.sbItem.title = [self appName:app];
101103
self.sbItem.image = nil;
102104
break;
103105
}
@@ -114,13 +116,13 @@ - (void)changeMenuTitle
114116
break;
115117
}
116118
case 3: {
117-
self.sbItem.title = app.localizedName;
119+
self.sbItem.title = [self appName:app];
118120
self.sbItem.image = [AppDelegate resizeImage:app.icon small:YES
119121
monochrome:NO translucent:NO];
120122
break;
121123
}
122124
case 4: {
123-
self.sbItem.title = app.localizedName;
125+
self.sbItem.title = [self appName:app];
124126
self.sbItem.image = [AppDelegate resizeImage:app.icon small:YES
125127
monochrome:YES translucent:NO];
126128
break;
@@ -290,7 +292,7 @@ - (void)createSubmenuOfSwitchMenu {
290292
}
291293
}
292294

293-
NSString *title = app.localizedName;
295+
NSString *title = [self appName:app];
294296
NSMutableArray *windows = [[NSMutableArray alloc] init];
295297

296298
NSInteger numWindows = 0;
@@ -361,6 +363,18 @@ - (void)createSubmenuOfSwitchMenu {
361363

362364
NSMutableString *tooltip = [[NSMutableString alloc] init];
363365
[tooltip appendFormat:@"Full Path:\n%@\n",[app.bundleURL path]];
366+
NSString *arch;
367+
switch (app.executableArchitecture) {
368+
case NSBundleExecutableArchitectureI386:
369+
arch = @"i386";
370+
break;
371+
case NSBundleExecutableArchitectureX86_64:
372+
arch = @"x86_64";
373+
break;
374+
default:
375+
arch = @"N/A";
376+
}
377+
[tooltip appendFormat:@"\nExecutable Architecture:\n%@\n", arch];
364378
// [tooltip appendFormat:@"\nBundle Identifier:\n%@\n",app.bundleIdentifier];
365379
if (app.launchDate) {
366380
[tooltip appendFormat:@"\nLaunch Date/Time:\n%@\n",app.launchDate];
@@ -514,26 +528,37 @@ - (NSImage *)makeAllAppsImageMonochrome:(BOOL)monochrome {
514528
return tmpImage;
515529
}
516530

531+
- (NSString *)appName:(NSRunningApplication *)app {
532+
if (self.iShow32BitOnly && [app executableArchitecture] == NSBundleExecutableArchitectureI386) {
533+
return [app.localizedName stringByAppendingString:@" (32-bit)"];
534+
} else {
535+
return app.localizedName;
536+
}
537+
}
538+
517539
#pragma mark - User Defaults
518540

519541
#define UD [NSUserDefaults standardUserDefaults]
520542
#define UDMenuTitle @"MenuTitle"
521543
#define UDIconSmall @"IconSmall"
522544
#define UDOrder @"Order"
523545
#define UDShowNumberOfWindows @"ShowNumberOfWindows"
546+
#define UDShow32BitOnly @"Show32BitOnly"
524547

525548
- (void)loadUserDefaults {
526549
self.iMenuTitle = [UD integerForKey:UDMenuTitle];
527550
self.iIconSmall = [UD integerForKey:UDIconSmall];
528551
self.iOrder = [UD integerForKey:UDOrder];
529552
self.iShowNumberOfWindows = [UD integerForKey:UDShowNumberOfWindows];
553+
self.iShow32BitOnly = [UD integerForKey:UDShowNumberOfWindows];
530554
}
531555

532556
- (void)saveUserDefaults {
533557
[UD setInteger:self.iMenuTitle forKey:UDMenuTitle];
534558
[UD setInteger:self.iIconSmall forKey:UDIconSmall];
535559
[UD setInteger:self.iOrder forKey:UDOrder];
536560
[UD setInteger:self.iShowNumberOfWindows forKey:UDShowNumberOfWindows];
561+
[UD setInteger:self.iShow32BitOnly forKey:UDShow32BitOnly];
537562
}
538563

539564
- (void)recheckMenuItems {
@@ -553,6 +578,7 @@ - (void)recheckMenuItems {
553578
self.miOrderLaunchTime.state = self.iOrder == 1 ? NSOnState : NSOffState;
554579

555580
self.miShowNumberOfWindows.state = self.iShowNumberOfWindows > 0 ? NSOnState : NSOffState;
581+
self.miShow32BitOnly.state = self.iShow32BitOnly > 0 ? NSOnState : NSOffState;
556582
}
557583

558584

@@ -594,6 +620,15 @@ - (IBAction)setShowNumberOfWindows:(NSMenuItem *)sender {
594620
[self saveUserDefaults];
595621
}
596622

623+
- (IBAction)setShow32BitOnly:(NSMenuItem *)sender {
624+
self.iShow32BitOnly = sender.state == NSOnState ? 0 : 1;
625+
626+
[self changeMenuTitle];
627+
[self recheckMenuItems];
628+
[self createSubmenuOfSwitchMenu];
629+
[self saveUserDefaults];
630+
}
631+
597632

598633
- (IBAction)actionHideApp:(id)sender {
599634
for (NSRunningApplication *app in self.apps) {

SwitchMenu/Base.lproj/MainMenu.xib

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<?xml version="1.0" encoding="UTF-8"?>
2-
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="14460.31" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
2+
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="15705" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
33
<dependencies>
44
<deployment identifier="macosx"/>
5-
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="14460.31"/>
5+
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="15705"/>
66
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
77
</dependencies>
88
<objects>
@@ -32,6 +32,7 @@
3232
<outlet property="miOrderAppName" destination="knp-7g-65a" id="vMb-k8-gzK"/>
3333
<outlet property="miOrderLaunchTime" destination="xes-we-Zde" id="pYL-nE-UQq"/>
3434
<outlet property="miQuitApp" destination="UY7-mP-BSk" id="tjq-ph-oPn"/>
35+
<outlet property="miShow32BitOnly" destination="l9s-PZ-kzX" id="mDk-zS-Nbq"/>
3536
<outlet property="miShowAll" destination="0pC-wN-3TZ" id="Lw1-JK-rfa"/>
3637
<outlet property="miShowNumberOfWindows" destination="6So-3B-tbA" id="MSX-ep-PR9"/>
3738
<outlet property="switchMenu" destination="yLx-0K-94h" id="RUF-J0-XcN"/>
@@ -687,12 +688,13 @@
687688
</menu>
688689
</menuItem>
689690
</items>
691+
<point key="canvasLocation" x="139" y="154"/>
690692
</menu>
691693
<window title="SwitchMenu" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" releasedWhenClosed="NO" visibleAtLaunch="NO" animationBehavior="default" id="QvC-M9-y7g">
692694
<windowStyleMask key="styleMask" titled="YES" closable="YES" miniaturizable="YES" resizable="YES"/>
693695
<windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/>
694696
<rect key="contentRect" x="335" y="390" width="480" height="360"/>
695-
<rect key="screenRect" x="0.0" y="0.0" width="1920" height="1057"/>
697+
<rect key="screenRect" x="0.0" y="0.0" width="1440" height="877"/>
696698
<view key="contentView" id="EiT-Mj-1SZ">
697699
<rect key="frame" x="0.0" y="0.0" width="480" height="360"/>
698700
<autoresizingMask key="autoresizingMask"/>
@@ -826,6 +828,12 @@
826828
<action selector="setShowNumberOfWindows:" target="Voe-Tx-rLC" id="VXa-wa-I7u"/>
827829
</connections>
828830
</menuItem>
831+
<menuItem title="Show If the App Supports 32-bit Only" id="l9s-PZ-kzX">
832+
<modifierMask key="keyEquivalentModifierMask"/>
833+
<connections>
834+
<action selector="setShow32BitOnly:" target="Voe-Tx-rLC" id="kAb-gu-dQo"/>
835+
</connections>
836+
</menuItem>
829837
<menuItem isSeparatorItem="YES" id="lQM-iE-qGD"/>
830838
<menuItem title="Open SwitchMenu Items Folder" id="hbg-Rb-mfS">
831839
<modifierMask key="keyEquivalentModifierMask"/>
@@ -847,7 +855,7 @@
847855
<connections>
848856
<outlet property="delegate" destination="-2" id="Db0-MA-GtS"/>
849857
</connections>
850-
<point key="canvasLocation" x="370" y="642"/>
858+
<point key="canvasLocation" x="250" y="502"/>
851859
</menu>
852860
<userDefaultsController representsSharedInstance="YES" id="9su-vE-kwj"/>
853861
</objects>

0 commit comments

Comments
 (0)