Skip to content

Commit

Permalink
Add quick open by making background UI element daemon.
Browse files Browse the repository at this point in the history
  • Loading branch information
aleffert committed Dec 21, 2011
1 parent 1f26c51 commit 56324c2
Show file tree
Hide file tree
Showing 32 changed files with 2,572 additions and 129 deletions.
16 changes: 16 additions & 0 deletions Julep-UIElement/ADLUIElementDelegate.h
@@ -0,0 +1,16 @@
//
// ADLUIElementDelegate.h
// Julep-UIElement
//
// Created by Akiva Leffert on 12/21/11.
// Copyright (c) 2011 __MyCompanyName__. All rights reserved.
//

#import <Cocoa/Cocoa.h>

#import "ADLNewItemController.h"
#import "ADLUIElementServer.h"

@interface ADLUIElementDelegate : NSObject <NSApplicationDelegate, ADLUIElementServerDelegate, ADLNewItemControllerDelegate>

@end
68 changes: 68 additions & 0 deletions Julep-UIElement/ADLUIElementDelegate.m
@@ -0,0 +1,68 @@
//
// ADLUIElementDelegate.m
// Julep-UIElement
//
// Created by Akiva Leffert on 12/21/11.
// Copyright (c) 2011 __MyCompanyName__. All rights reserved.
//

#import "ADLUIElementDelegate.h"

#import "ADLAppServer.h"
#import "ADLNewItemController.h"

@interface ADLUIElementDelegate ()

@property (retain, nonatomic) ADLUIElementServer* server;
@property (retain, nonatomic) ADLNewItemController* quickCreateController;

@end

@implementation ADLUIElementDelegate

@synthesize quickCreateController = mQuickCreateController;
@synthesize server = mServer;

- (void)dealloc
{
self.quickCreateController = nil;
self.server = nil;
[super dealloc];
}

- (void)applicationDidFinishLaunching:(NSNotification *)aNotification
{
[[NSWorkspace sharedWorkspace] addObserver:self forKeyPath:@"runningApplications" options:NSKeyValueObservingOptionNew context:NULL];
self.server = [[[ADLUIElementServer alloc] init] autorelease];
self.server.delegate = self;
[self.server start];
}

- (void)observeValueForKeyPath:(NSString *)keyPath ofObject:(id)object change:(NSDictionary *)change context:(void *)context {
NSAssert([keyPath isEqual:@"runningApplications"], @"unexpected key path");
NSArray* items = [NSRunningApplication runningApplicationsWithBundleIdentifier:@"com.ognid.julep"];
if(items.count == 0) {
[[NSApplication sharedApplication] terminate:self];
}
}

- (void)showQuickCreateWithListIDs:(NSArray*)listIDs named:(NSArray*)names {
if(self.quickCreateController == nil) {
self.quickCreateController = [[[ADLNewItemController alloc] init] autorelease];
self.quickCreateController.delegate = self;
}
self.quickCreateController.listNames = names;
self.quickCreateController.listIDs = listIDs;
[self.quickCreateController showWindow:self];
}

- (void)addItemWithTitle:(NSString *)name toList:(NSURL *)listID {
id <ADLAppServer> appServer = (id <ADLAppServer>)[NSConnection rootProxyForConnectionWithRegisteredName:kADLAppServerName host:nil];
[appServer addItemWithTitle:name toList:listID];
}

- (void)applicationWillResignActive:(NSNotification *)notification {
[self.quickCreateController.window orderOut:self];
}

@end
34 changes: 34 additions & 0 deletions Julep-UIElement/ADLUIElementServer.h
@@ -0,0 +1,34 @@
//
// ADLUIElementServer.h
// julep
//
// Created by Akiva Leffert on 12/21/11.
// Copyright (c) 2011 __MyCompanyName__. All rights reserved.
//

#import <Foundation/Foundation.h>

@protocol ADLUIElementServerDelegate;

@protocol ADLUIElementServer <NSObject>

- (void)showQuickCreateWithListIDs:(NSArray*)listIDs named:(NSArray*)names;

@end

@interface ADLUIElementServer : NSObject <ADLUIElementServer>

@property (assign, nonatomic) id <ADLUIElementServerDelegate> delegate;

- (void)start;

@end


@protocol ADLUIElementServerDelegate <NSObject>

- (void)showQuickCreateWithListIDs:(NSArray*)listIDs named:(NSArray*)names;

@end

extern NSString* kADLUIServerName;
42 changes: 42 additions & 0 deletions Julep-UIElement/ADLUIElementServer.m
@@ -0,0 +1,42 @@
//
// ADLUIElementServer.m
// julep
//
// Created by Akiva Leffert on 12/21/11.
// Copyright (c) 2011 __MyCompanyName__. All rights reserved.
//

#import "ADLUIElementServer.h"

NSString* kADLUIServerName = @"com.ognid.julep-ui-server";

@interface ADLUIElementServer ()

@property (retain, nonatomic) NSConnection* connection;

@end

@implementation ADLUIElementServer

@synthesize connection = mConnection;
@synthesize delegate = mDelegate;

- (void)dealloc {
[self.connection invalidate];
self.connection = nil;
[super dealloc];
}

- (void)start {
self.connection = [[[NSConnection alloc] init] autorelease];
self.connection.rootObject = self;
if([self.connection registerName:kADLUIServerName] == NO) {
NSLog(@"failed to start ui element server");
};
}

- (void)showQuickCreateWithListIDs:(NSArray*)listIDs named:(NSArray*)names {
[self.delegate showQuickCreateWithListIDs:listIDs named:names];
}

@end
36 changes: 36 additions & 0 deletions Julep-UIElement/Julep-UIElement-Info.plist
@@ -0,0 +1,36 @@
<?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>en</string>
<key>CFBundleExecutable</key>
<string>${EXECUTABLE_NAME}</string>
<key>CFBundleIconFile</key>
<string></string>
<key>CFBundleIdentifier</key>
<string>com.ognid.${PRODUCT_NAME:rfc1034identifier}</string>
<key>CFBundleInfoDictionaryVersion</key>
<string>6.0</string>
<key>CFBundleName</key>
<string>${PRODUCT_NAME}</string>
<key>CFBundlePackageType</key>
<string>APPL</string>
<key>CFBundleShortVersionString</key>
<string>1.0</string>
<key>CFBundleSignature</key>
<string>????</string>
<key>CFBundleVersion</key>
<string>1</string>
<key>LSMinimumSystemVersion</key>
<string>${MACOSX_DEPLOYMENT_TARGET}</string>
<key>LSUIElement</key>
<true/>
<key>NSHumanReadableCopyright</key>
<string>Copyright © 2011 __MyCompanyName__. All rights reserved.</string>
<key>NSMainNibFile</key>
<string>ADLLUIElementMain</string>
<key>NSPrincipalClass</key>
<string>NSApplication</string>
</dict>
</plist>
7 changes: 7 additions & 0 deletions Julep-UIElement/Julep-UIElement-Prefix.pch
@@ -0,0 +1,7 @@
//
// Prefix header for all source files of the 'Julep-UIElement' target in the 'Julep-UIElement' project
//

#ifdef __OBJC__
#import <Cocoa/Cocoa.h>
#endif
119 changes: 119 additions & 0 deletions Julep-UIElement/en.lproj/ADLLUIElementMain.xib
@@ -0,0 +1,119 @@
<?xml version="1.0" encoding="UTF-8"?>
<archive type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="8.00">
<data>
<int key="IBDocument.SystemTarget">1070</int>
<string key="IBDocument.SystemVersion">11C74</string>
<string key="IBDocument.InterfaceBuilderVersion">1938</string>
<string key="IBDocument.AppKitVersion">1138.23</string>
<string key="IBDocument.HIToolboxVersion">567.00</string>
<object class="NSMutableDictionary" key="IBDocument.PluginVersions">
<string key="NS.key.0">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="NS.object.0">1938</string>
</object>
<array key="IBDocument.IntegratedClassDependencies">
<string>NSCustomObject</string>
</array>
<array key="IBDocument.PluginDependencies">
<string>com.apple.InterfaceBuilder.CocoaPlugin</string>
</array>
<object class="NSMutableDictionary" key="IBDocument.Metadata">
<string key="NS.key.0">PluginDependencyRecalculationVersion</string>
<integer value="1" key="NS.object.0"/>
</object>
<array class="NSMutableArray" key="IBDocument.RootObjects" id="1048">
<object class="NSCustomObject" id="1021">
<string key="NSClassName">NSApplication</string>
</object>
<object class="NSCustomObject" id="1014">
<string key="NSClassName">FirstResponder</string>
</object>
<object class="NSCustomObject" id="1050">
<string key="NSClassName">NSApplication</string>
</object>
<object class="NSCustomObject" id="976324537">
<string key="NSClassName">ADLUIElementDelegate</string>
</object>
<object class="NSCustomObject" id="755631768">
<string key="NSClassName">NSFontManager</string>
</object>
</array>
<object class="IBObjectContainer" key="IBDocument.Objects">
<array class="NSMutableArray" key="connectionRecords">
<object class="IBConnectionRecord">
<object class="IBOutletConnection" key="connection">
<string key="label">delegate</string>
<reference key="source" ref="1021"/>
<reference key="destination" ref="976324537"/>
</object>
<int key="connectionID">495</int>
</object>
</array>
<object class="IBMutableOrderedSet" key="objectRecords">
<array key="orderedObjects">
<object class="IBObjectRecord">
<int key="objectID">0</int>
<array key="object" id="0"/>
<reference key="children" ref="1048"/>
<nil key="parent"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">-2</int>
<reference key="object" ref="1021"/>
<reference key="parent" ref="0"/>
<string key="objectName">File's Owner</string>
</object>
<object class="IBObjectRecord">
<int key="objectID">-1</int>
<reference key="object" ref="1014"/>
<reference key="parent" ref="0"/>
<string key="objectName">First Responder</string>
</object>
<object class="IBObjectRecord">
<int key="objectID">-3</int>
<reference key="object" ref="1050"/>
<reference key="parent" ref="0"/>
<string key="objectName">Application</string>
</object>
<object class="IBObjectRecord">
<int key="objectID">420</int>
<reference key="object" ref="755631768"/>
<reference key="parent" ref="0"/>
</object>
<object class="IBObjectRecord">
<int key="objectID">494</int>
<reference key="object" ref="976324537"/>
<reference key="parent" ref="0"/>
</object>
</array>
</object>
<dictionary class="NSMutableDictionary" key="flattenedProperties">
<string key="-1.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="-2.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="-3.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="420.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="494.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">535</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<array class="NSMutableArray" key="referencedPartialClassDescriptions">
<object class="IBPartialClassDescription">
<string key="className">ADLUIElementDelegate</string>
<string key="superclassName">NSObject</string>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBProjectSource</string>
<string key="minorKey">./Classes/ADLUIElementDelegate.h</string>
</object>
</object>
</array>
</object>
<int key="IBDocument.localizationMode">0</int>
<string key="IBDocument.TargetRuntimeIdentifier">IBCocoaFramework</string>
<bool key="IBDocument.PluginDeclaredDependenciesTrackSystemTargetVersion">YES</bool>
<int key="IBDocument.defaultPropertyAccessControl">3</int>
</data>
</archive>
29 changes: 29 additions & 0 deletions Julep-UIElement/en.lproj/Credits.rtf
@@ -0,0 +1,29 @@
{\rtf0\ansi{\fonttbl\f0\fswiss Helvetica;}
{\colortbl;\red255\green255\blue255;}
\paperw9840\paperh8400
\pard\tx560\tx1120\tx1680\tx2240\tx2800\tx3360\tx3920\tx4480\tx5040\tx5600\tx6160\tx6720\ql\qnatural

\f0\b\fs24 \cf0 Engineering:
\b0 \
Some people\
\

\b Human Interface Design:
\b0 \
Some other people\
\

\b Testing:
\b0 \
Hopefully not nobody\
\

\b Documentation:
\b0 \
Whoever\
\

\b With special thanks to:
\b0 \
Mom\
}
2 changes: 2 additions & 0 deletions Julep-UIElement/en.lproj/InfoPlist.strings
@@ -0,0 +1,2 @@
/* Localized versions of Info.plist keys */

14 changes: 14 additions & 0 deletions Julep-UIElement/main.m
@@ -0,0 +1,14 @@
//
// main.m
// Julep-UIElement
//
// Created by Akiva Leffert on 12/21/11.
// Copyright (c) 2011 __MyCompanyName__. All rights reserved.
//

#import <Cocoa/Cocoa.h>

int main(int argc, char *argv[])
{
return NSApplicationMain(argc, (const char **)argv);
}
3 changes: 3 additions & 0 deletions README
@@ -1,3 +1,6 @@
Julep is a todo list app for MacOSX optimized for me.
It syncs to the calendar store.
Right now it is extremely basic.


Credit for shortcut recorder to http://shortcutrecorder.googlecode.com
1 change: 1 addition & 0 deletions Shared/ADLList.h
Expand Up @@ -16,6 +16,7 @@
@property (nonatomic, retain) NSString * uid;
@property (nonatomic, retain) NSOrderedSet *items;
@property (nonatomic, retain) ADLListCollection *list;
@property (nonatomic, assign) BOOL showsCountInBadge;
@end

@interface ADLList (CoreDataGeneratedAccessors)
Expand Down

0 comments on commit 56324c2

Please sign in to comment.