Skip to content

Commit

Permalink
AppList: modified
Browse files Browse the repository at this point in the history
  • Loading branch information
authored and committed Apr 15, 2010
1 parent 62c1831 commit 7767ca2
Show file tree
Hide file tree
Showing 6 changed files with 79 additions and 40 deletions.
6 changes: 6 additions & 0 deletions AppList/AppList.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
1DDD58160DA1D0A300B32029 /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 1DDD58140DA1D0A300B32029 /* MainMenu.xib */; };
256AC3DA0F4B6AC300CF3369 /* AppListAppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 256AC3D90F4B6AC300CF3369 /* AppListAppDelegate.m */; };
4C19D0CC1173E5B0006A352C /* ApplicationEntry.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C19D0CB1173E5B0006A352C /* ApplicationEntry.m */; };
4C4A13CB11767CFE00016D81 /* ApplicationCell.m in Sources */ = {isa = PBXBuildFile; fileRef = 4C4A13CA11767CFE00016D81 /* ApplicationCell.m */; };
8D11072B0486CEB800E47090 /* InfoPlist.strings in Resources */ = {isa = PBXBuildFile; fileRef = 089C165CFE840E0CC02AAC07 /* InfoPlist.strings */; };
8D11072D0486CEB800E47090 /* main.m in Sources */ = {isa = PBXBuildFile; fileRef = 29B97316FDCFA39411CA2CEA /* main.m */; settings = {ATTRIBUTES = (); }; };
8D11072F0486CEB800E47090 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 1058C7A1FEA54F0111CA2CBB /* Cocoa.framework */; };
Expand All @@ -28,6 +29,8 @@
29B97325FDCFA39411CA2CEA /* Foundation.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = Foundation.framework; path = /System/Library/Frameworks/Foundation.framework; sourceTree = "<absolute>"; };
4C19D0CA1173E5B0006A352C /* ApplicationEntry.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ApplicationEntry.h; sourceTree = "<group>"; };
4C19D0CB1173E5B0006A352C /* ApplicationEntry.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ApplicationEntry.m; sourceTree = "<group>"; };
4C4A13C911767CFE00016D81 /* ApplicationCell.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ApplicationCell.h; sourceTree = "<group>"; };
4C4A13CA11767CFE00016D81 /* ApplicationCell.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ApplicationCell.m; sourceTree = "<group>"; };
8D1107310486CEB800E47090 /* AppList-Info.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; path = "AppList-Info.plist"; sourceTree = "<group>"; };
8D1107320486CEB800E47090 /* AppList.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = AppList.app; sourceTree = BUILT_PRODUCTS_DIR; };
/* End PBXFileReference section */
Expand All @@ -51,6 +54,8 @@
256AC3D90F4B6AC300CF3369 /* AppListAppDelegate.m */,
4C19D0CA1173E5B0006A352C /* ApplicationEntry.h */,
4C19D0CB1173E5B0006A352C /* ApplicationEntry.m */,
4C4A13C911767CFE00016D81 /* ApplicationCell.h */,
4C4A13CA11767CFE00016D81 /* ApplicationCell.m */,
);
name = Classes;
sourceTree = "<group>";
Expand Down Expand Up @@ -179,6 +184,7 @@
8D11072D0486CEB800E47090 /* main.m in Sources */,
256AC3DA0F4B6AC300CF3369 /* AppListAppDelegate.m in Sources */,
4C19D0CC1173E5B0006A352C /* ApplicationEntry.m in Sources */,
4C4A13CB11767CFE00016D81 /* ApplicationCell.m in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down
1 change: 1 addition & 0 deletions AppList/AppListAppDelegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@

IBOutlet NSTableView* tableView_;
IBOutlet NSArrayController* arrayController_;
IBOutlet NSTableColumn* tableColumn_;

NSMutableArray* appList_;
}
Expand Down
7 changes: 4 additions & 3 deletions AppList/AppListAppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
#import "AppListAppDelegate.h"

#import "ApplicationEntry.h"
#import "ApplicationCell.h"

@implementation AppListAppDelegate

Expand Down Expand Up @@ -54,6 +55,8 @@ - (void)applicationDidFinishLaunching:(NSNotification *)aNotification {

[tableView_ registerForDraggedTypes:
[NSArray arrayWithObjects:NSFilenamesPboardType, nil]];

[tableColumn_ setDataCell:[[[ApplicationCell alloc] init] autorelease]];
}

#pragma mark -
Expand Down Expand Up @@ -92,9 +95,7 @@ - (BOOL)tableView:(NSTableView *)aTableView acceptDrop:(id <NSDraggingInfo>)info
NSArray*filenames = [pboard propertyListForType:NSFilenamesPboardType];

for (NSString* filename in filenames) {
ApplicationEntry* entry = [[[ApplicationEntry alloc] init] autorelease];
entry.path = filename;
// entry.name = [filename lastPathComponent];
ApplicationEntry* entry = [[[ApplicationEntry alloc] initWithPath:filename] autorelease];
[arrayController_ insertObject:entry atArrangedObjectIndex:row];
}

Expand Down
2 changes: 2 additions & 0 deletions AppList/ApplicationEntry.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,6 @@
@property (copy) NSString* name;
@property (copy) NSString* path;
@property (retain) NSImage* icon;

-(id)initWithPath:(NSString*)aPath;
@end
46 changes: 38 additions & 8 deletions AppList/ApplicationEntry.m
Original file line number Diff line number Diff line change
Expand Up @@ -13,17 +13,47 @@ @implementation ApplicationEntry

@synthesize name, path, icon;

-(void)setPath:(NSString *)aPath
#pragma mark -
#pragma mark Initialization & Deallocation
-(id)initWithPath:(NSString*)aPath;
{
[aPath retain];
[path release];
path = aPath;
self = [super init];
if (self != nil) {
self.path = aPath;
NSString* appName;
LSCopyDisplayNameForURL((CFURLRef)[NSURL fileURLWithPath:path], (CFStringRef *)&appName);

if (!appName) {
appName = @"(not found)";
}
self.name = appName;

self.icon = [[NSWorkspace sharedWorkspace] iconForFile:path];
[icon setSize:NSMakeSize(16, 16)];
}
return self;
}

- (void) dealloc
{
self.path = nil;
self.name = nil;
self.icon = nil;
[super dealloc];
}

#pragma mark -
#pragma mark Accessors

- (id)copyWithZone:(NSZone *)zone
{
ApplicationEntry* entry = [[[self class] allocWithZone:zone] init];

LSCopyDisplayNameForURL((CFURLRef)[NSURL fileURLWithPath:path], (CFStringRef *)&name);
entry.path = [path copyWithZone:zone];
entry.name = [name copyWithZone:zone];
entry.icon = [icon copyWithZone:zone];

if (!name) {
name = @"(not found)";
}
return entry;
}

@end
57 changes: 28 additions & 29 deletions AppList/English.lproj/MainMenu.xib
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
</object>
<object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
<bool key="EncodedWithXMLCoder">YES</bool>
<integer value="536"/>
<integer value="29"/>
</object>
<object class="NSArray" key="IBDocument.PluginDependencies">
Expand Down Expand Up @@ -1314,9 +1315,6 @@
</object>
<string key="NSName">_NSMainMenu</string>
</object>
<object class="NSCustomObject" id="755631768">
<string key="NSClassName">NSFontManager</string>
</object>
<object class="NSWindowTemplate" id="972006081">
<int key="NSWindowStyleMask">15</int>
<int key="NSWindowBacking">2</int>
Expand Down Expand Up @@ -1346,22 +1344,19 @@
<int key="NSvFlags">256</int>
<string key="NSFrameSize">{367, 190}</string>
<reference key="NSSuperview" ref="70107259"/>
<reference key="NSWindow"/>
<bool key="NSEnabled">YES</bool>
<object class="NSTableHeaderView" key="NSHeaderView" id="84217362">
<reference key="NSNextResponder" ref="940491372"/>
<int key="NSvFlags">256</int>
<string key="NSFrameSize">{367, 17}</string>
<reference key="NSSuperview" ref="940491372"/>
<reference key="NSWindow"/>
<reference key="NSTableView" ref="118153432"/>
</object>
<object class="_NSCornerView" key="NSCornerView" id="1023461112">
<reference key="NSNextResponder" ref="738471903"/>
<int key="NSvFlags">-2147483392</int>
<string key="NSFrame">{{224, 0}, {16, 17}}</string>
<reference key="NSSuperview" ref="738471903"/>
<reference key="NSWindow"/>
</object>
<object class="NSMutableArray" key="NSTableColumns">
<bool key="EncodedWithXMLCoder">YES</bool>
Expand Down Expand Up @@ -1451,7 +1446,6 @@
</object>
<string key="NSFrame">{{1, 17}, {367, 190}}</string>
<reference key="NSSuperview" ref="738471903"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="118153432"/>
<reference key="NSDocView" ref="118153432"/>
<reference key="NSBGColor" ref="208638811"/>
Expand All @@ -1462,7 +1456,6 @@
<int key="NSvFlags">-2147483392</int>
<string key="NSFrame">{{224, 17}, {15, 102}}</string>
<reference key="NSSuperview" ref="738471903"/>
<reference key="NSWindow"/>
<reference key="NSTarget" ref="738471903"/>
<string key="NSAction">_doScroller:</string>
<double key="NSPercent">0.99476438760757446</double>
Expand All @@ -1472,7 +1465,6 @@
<int key="NSvFlags">-2147483392</int>
<string key="NSFrame">{{-100, -100}, {367, 15}}</string>
<reference key="NSSuperview" ref="738471903"/>
<reference key="NSWindow"/>
<int key="NSsFlags">1</int>
<reference key="NSTarget" ref="738471903"/>
<string key="NSAction">_doScroller:</string>
Expand All @@ -1487,7 +1479,6 @@
</object>
<string key="NSFrame">{{1, 0}, {367, 17}}</string>
<reference key="NSSuperview" ref="738471903"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="84217362"/>
<reference key="NSDocView" ref="84217362"/>
<reference key="NSBGColor" ref="208638811"/>
Expand All @@ -1497,7 +1488,6 @@
</object>
<string key="NSFrame">{{20, 48}, {369, 208}}</string>
<reference key="NSSuperview" ref="439893737"/>
<reference key="NSWindow"/>
<reference key="NSNextKeyView" ref="70107259"/>
<int key="NSsFlags">530</int>
<reference key="NSVScroller" ref="994067818"/>
Expand All @@ -1512,7 +1502,6 @@
<int key="NSvFlags">268</int>
<string key="NSFrame">{{17, 264}, {416, 17}}</string>
<reference key="NSSuperview" ref="439893737"/>
<reference key="NSWindow"/>
<bool key="NSEnabled">YES</bool>
<object class="NSTextFieldCell" key="NSCell" id="664973123">
<int key="NSCellFlags">68288064</int>
Expand All @@ -1534,7 +1523,6 @@
<int key="NSvFlags">260</int>
<string key="NSFrame">{{20, 19}, {23, 22}}</string>
<reference key="NSSuperview" ref="439893737"/>
<reference key="NSWindow"/>
<bool key="NSEnabled">YES</bool>
<object class="NSButtonCell" key="NSCell" id="594828877">
<int key="NSCellFlags">-2080244224</int>
Expand All @@ -1559,7 +1547,6 @@
<int key="NSvFlags">260</int>
<string key="NSFrame">{{42, 19}, {23, 22}}</string>
<reference key="NSSuperview" ref="439893737"/>
<reference key="NSWindow"/>
<bool key="NSEnabled">YES</bool>
<object class="NSButtonCell" key="NSCell" id="138229259">
<int key="NSCellFlags">-2080244224</int>
Expand All @@ -1582,11 +1569,13 @@
</object>
<string key="NSFrameSize">{409, 301}</string>
<reference key="NSSuperview"/>
<reference key="NSWindow"/>
</object>
<string key="NSScreenRect">{{0, 0}, {1920, 1178}}</string>
<string key="NSMaxSize">{3.40282e+38, 3.40282e+38}</string>
</object>
<object class="NSCustomObject" id="755631768">
<string key="NSClassName">NSFontManager</string>
</object>
<object class="NSCustomObject" id="976324537">
<string key="NSClassName">AppListAppDelegate</string>
</object>
Expand Down Expand Up @@ -2345,17 +2334,33 @@
</object>
<int key="connectionID">572</int>
</object>
<object class="IBConnectionRecord">
<object class="IBOutletConnection" key="connection">
<string key="label">arrayController_</string>
<reference key="source" ref="976324537"/>
<reference key="destination" ref="170240774"/>
</object>
<int key="connectionID">574</int>
</object>
<object class="IBConnectionRecord">
<object class="IBOutletConnection" key="connection">
<string key="label">tableColumn_</string>
<reference key="source" ref="976324537"/>
<reference key="destination" ref="427243853"/>
</object>
<int key="connectionID">575</int>
</object>
<object class="IBConnectionRecord">
<object class="IBBindingConnection" key="connection">
<string key="label">value: arrangedObjects.name</string>
<string key="label">value: arrangedObjects</string>
<reference key="source" ref="427243853"/>
<reference key="destination" ref="170240774"/>
<object class="NSNibBindingConnector" key="connector">
<reference key="NSSource" ref="427243853"/>
<reference key="NSDestination" ref="170240774"/>
<string key="NSLabel">value: arrangedObjects.name</string>
<string key="NSLabel">value: arrangedObjects</string>
<string key="NSBinding">value</string>
<string key="NSKeyPath">arrangedObjects.name</string>
<string key="NSKeyPath">arrangedObjects</string>
<object class="NSDictionary" key="NSOptions">
<bool key="EncodedWithXMLCoder">YES</bool>
<object class="NSArray" key="dict.sortedKeys">
Expand All @@ -2372,15 +2377,7 @@
<int key="NSNibBindingConnectorVersion">2</int>
</object>
</object>
<int key="connectionID">573</int>
</object>
<object class="IBConnectionRecord">
<object class="IBOutletConnection" key="connection">
<string key="label">arrayController_</string>
<reference key="source" ref="976324537"/>
<reference key="destination" ref="170240774"/>
</object>
<int key="connectionID">574</int>
<int key="connectionID">576</int>
</object>
</object>
<object class="IBMutableOrderedSet" key="objectRecords">
Expand Down Expand Up @@ -2938,9 +2935,9 @@
<object class="NSMutableArray" key="children">
<bool key="EncodedWithXMLCoder">YES</bool>
<reference ref="1015124532"/>
<reference ref="738471903"/>
<reference ref="12032461"/>
<reference ref="977962396"/>
<reference ref="738471903"/>
</object>
<reference key="parent" ref="972006081"/>
</object>
Expand Down Expand Up @@ -4082,7 +4079,7 @@
</object>
</object>
<nil key="sourceID"/>
<int key="maxID">574</int>
<int key="maxID">576</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<object class="NSMutableArray" key="referencedPartialClassDescriptions">
Expand All @@ -4108,12 +4105,14 @@
<object class="NSArray" key="dict.sortedKeys">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>arrayController_</string>
<string>tableColumn_</string>
<string>tableView_</string>
<string>window</string>
</object>
<object class="NSMutableArray" key="dict.values">
<bool key="EncodedWithXMLCoder">YES</bool>
<string>NSArrayController</string>
<string>NSTableColumn</string>
<string>NSTableView</string>
<string>NSWindow</string>
</object>
Expand Down

0 comments on commit 7767ca2

Please sign in to comment.