Commits

Veg Head  committed cd9609b

Clear stak implemented

  • Participants
  • Parent commits 12116ed

Comments (0)

Files changed (16)

File Credits.html

         div {
             text-align: center;
             font-family: Lucida Grande, sans-serif;
-            text-shadow: 1px 1px;
             font-size: 2em;
         }
         div.lifo {

File English.lproj/localizable.strings

+/* 
+  localizable.strings
+  headstak
+
+  Created by Veghead on 7/1/13.
+  Copyright (c) 2013 dreadtech.com. All rights reserved.
+*/
+"All of your HeadStak history will be deleted. Are you sure?" = "All of your HeadStak history will be deleted. Are you sure?";
+"Are you sure?" = "Are you sure?";
+"No" = "No";
+"Yes" = "Yes";

File MainMenu.xib

 			<string>NSCustomObject</string>
 			<string>NSMenu</string>
 			<string>NSMenuItem</string>
+			<string>NSUserDefaultsController</string>
 		</object>
 		<object class="NSArray" key="IBDocument.PluginDependencies">
 			<bool key="EncodedWithXMLCoder">YES</bool>
 				<string key="NSClassName">FirstResponder</string>
 			</object>
 			<object class="NSCustomObject" id="1050">
-				<string key="NSClassName">NSApplication</string>
+				<string key="NSClassName">StakApplication</string>
 			</object>
 			<object class="NSCustomObject" id="903638069">
 				<string key="NSClassName">NSFontManager</string>
 						<reference key="NSOnImage" ref="229763992"/>
 						<reference key="NSMixedImage" ref="909111550"/>
 					</object>
-					<object class="NSMenuItem" id="161620825">
-						<reference key="NSMenu" ref="600672092"/>
-						<string key="NSTitle">Preferences</string>
-						<string key="NSKeyEquiv">p</string>
-						<int key="NSKeyEquivModMask">1048576</int>
-						<int key="NSMnemonicLoc">2147483647</int>
-						<reference key="NSOnImage" ref="229763992"/>
-						<reference key="NSMixedImage" ref="909111550"/>
-						<int key="NSTag">4</int>
-					</object>
 					<object class="NSMenuItem" id="1015243510">
 						<reference key="NSMenu" ref="600672092"/>
 						<string key="NSTitle">About headstak</string>
 					</object>
 				</object>
 			</object>
+			<object class="NSUserDefaultsController" id="808888551">
+				<bool key="NSSharedInstance">YES</bool>
+			</object>
 		</object>
 		<object class="IBObjectContainer" key="IBDocument.Objects">
 			<object class="NSMutableArray" key="connectionRecords">
 					<object class="IBActionConnection" key="connection">
 						<string key="label">menuHandler:</string>
 						<reference key="source" ref="905284910"/>
-						<reference key="destination" ref="161620825"/>
-					</object>
-					<int key="connectionID">812</int>
-				</object>
-				<object class="IBConnectionRecord">
-					<object class="IBActionConnection" key="connection">
-						<string key="label">menuHandler:</string>
-						<reference key="source" ref="905284910"/>
 						<reference key="destination" ref="985308477"/>
 					</object>
 					<int key="connectionID">813</int>
 							<reference ref="1015243510"/>
 							<reference ref="985308477"/>
 							<reference ref="1000606700"/>
-							<reference ref="161620825"/>
 							<reference ref="1001219518"/>
 							<reference ref="795130291"/>
 						</object>
 						<reference key="parent" ref="600672092"/>
 					</object>
 					<object class="IBObjectRecord">
-						<int key="objectID">810</int>
-						<reference key="object" ref="161620825"/>
-						<reference key="parent" ref="600672092"/>
-					</object>
-					<object class="IBObjectRecord">
 						<int key="objectID">814</int>
 						<reference key="object" ref="1001219518"/>
 						<reference key="parent" ref="600672092"/>
 						<reference key="object" ref="795130291"/>
 						<reference key="parent" ref="600672092"/>
 					</object>
+					<object class="IBObjectRecord">
+						<int key="objectID">817</int>
+						<reference key="object" ref="808888551"/>
+						<reference key="parent" ref="0"/>
+					</object>
 				</object>
 			</object>
 			<object class="NSMutableDictionary" key="flattenedProperties">
 					<string>807.IBPluginDependency</string>
 					<string>808.IBPluginDependency</string>
 					<string>81.IBPluginDependency</string>
-					<string>810.IBPluginDependency</string>
 					<string>814.IBPluginDependency</string>
 					<string>815.IBPluginDependency</string>
+					<string>817.IBPluginDependency</string>
 					<string>82.IBPluginDependency</string>
 					<string>83.IBPluginDependency</string>
 					<string>92.IBPluginDependency</string>
 				<reference key="dict.values" ref="0"/>
 			</object>
 			<nil key="sourceID"/>
-			<int key="maxID">816</int>
+			<int key="maxID">836</int>
+		</object>
+		<object class="IBClassDescriber" key="IBDocument.Classes">
+			<object class="NSMutableArray" key="referencedPartialClassDescriptions">
+				<bool key="EncodedWithXMLCoder">YES</bool>
+				<object class="IBPartialClassDescription">
+					<string key="className">StakApplication</string>
+					<string key="superclassName">NSApplication</string>
+					<object class="IBClassDescriptionSource" key="sourceIdentifier">
+						<string key="majorKey">IBProjectSource</string>
+						<string key="minorKey">./Classes/StakApplication.h</string>
+					</object>
+				</object>
+				<object class="IBPartialClassDescription">
+					<string key="className">headstak_AppDelegate</string>
+					<string key="superclassName">NSObject</string>
+					<object class="NSMutableDictionary" key="actions">
+						<string key="NS.key.0">menuHandler:</string>
+						<string key="NS.object.0">id</string>
+					</object>
+					<object class="NSMutableDictionary" key="actionInfosByName">
+						<string key="NS.key.0">menuHandler:</string>
+						<object class="IBActionInfo" key="NS.object.0">
+							<string key="name">menuHandler:</string>
+							<string key="candidateClassName">id</string>
+						</object>
+					</object>
+					<object class="NSMutableDictionary" key="outlets">
+						<bool key="EncodedWithXMLCoder">YES</bool>
+						<object class="NSArray" key="dict.sortedKeys">
+							<bool key="EncodedWithXMLCoder">YES</bool>
+							<string>_stakMenu</string>
+							<string>window</string>
+						</object>
+						<object class="NSArray" key="dict.values">
+							<bool key="EncodedWithXMLCoder">YES</bool>
+							<string>NSMenu</string>
+							<string>NSWindow</string>
+						</object>
+					</object>
+					<object class="NSMutableDictionary" key="toOneOutletInfosByName">
+						<bool key="EncodedWithXMLCoder">YES</bool>
+						<object class="NSArray" key="dict.sortedKeys">
+							<bool key="EncodedWithXMLCoder">YES</bool>
+							<string>_stakMenu</string>
+							<string>window</string>
+						</object>
+						<object class="NSArray" key="dict.values">
+							<bool key="EncodedWithXMLCoder">YES</bool>
+							<object class="IBToOneOutletInfo">
+								<string key="name">_stakMenu</string>
+								<string key="candidateClassName">NSMenu</string>
+							</object>
+							<object class="IBToOneOutletInfo">
+								<string key="name">window</string>
+								<string key="candidateClassName">NSWindow</string>
+							</object>
+						</object>
+					</object>
+					<object class="IBClassDescriptionSource" key="sourceIdentifier">
+						<string key="majorKey">IBProjectSource</string>
+						<string key="minorKey">./Classes/headstak_AppDelegate.h</string>
+					</object>
+				</object>
+			</object>
 		</object>
-		<object class="IBClassDescriber" key="IBDocument.Classes"/>
 		<int key="IBDocument.localizationMode">0</int>
 		<string key="IBDocument.TargetRuntimeIdentifier">IBCocoaFramework</string>
 		<object class="NSMutableDictionary" key="IBDocument.PluginDeclaredDevelopmentDependencies">

File StakApplication.h

 #define LogError( s, ... ) NSLog( @"<%p %@:(%d)> [Error] %@", self, [[NSString stringWithUTF8String:__FILE__] lastPathComponent], __LINE__, [NSString stringWithFormat:(s), ##__VA_ARGS__] )
 
 @interface StakApplication : NSApplication {
-@private
-    NSMutableArray *_theStak;
 }
 
 @property (strong, readwrite) NSMutableArray *theStak;

File StakApplication.m

 #import "StakItem.h"
 
 @implementation StakApplication
-@synthesize theStak = _theStak;
 
 
 - (id)init

File StakController.m

 #import "StakItemView.h"
 #import "StakPrefController.h"
 
+NSObject *_stakLock;
+
 @implementation StakController
 
 - (id)init
         [_db setLogsErrors:YES];
         [_db open];
         _stakHolder = [[NSMutableArray alloc] init];        
-        [_db loadStakIntoHolder:_stakHolder]; 
+        [_db loadStakIntoHolder:_stakHolder];
+        _stakLock = [[NSObject alloc] init];
     }
     return self;
 }
 
 
 - (StakItem *)pushNewItemOfType:(NSUInteger)itemType {
-    StakItem *item = [[StakItem alloc] initNewItemOfType:itemType InDb:[self db]];
-    [[self stakHolder] insertObject:item atIndex:0];
+    StakItem *item = [[StakItem alloc] initNewItemOfType:itemType inDb:[self db]];
+    @synchronized(_stakLock) {
+        [[self stakHolder] insertObject:item atIndex:0];
+    }
     [[[self swc] stakView] addSubview:[item viewInStakView:[[self swc] stakView]]];
     [self layoutItemViews];
     return item;
 
 - (StakItem *)popItem {
     StakItem *item = nil;
-    if ([[self stakHolder] count]) {
-        item = [[self stakHolder] objectAtIndex:0];
-        [item setPopTime:[NSDate date]];
-        [item save];
-        [[self stakHolder] removeObjectAtIndex:0];
-        [[item viewInStakView:[[self swc] stakView]] removeFromSuperview];
-        [self layoutItemViews];
+    @synchronized(_stakLock) {
+        if ([[self stakHolder] count]) {
+            item = [[self stakHolder] objectAtIndex:0];
+            [item setPopTime:[NSDate date]];
+            [item save];
+            [[self stakHolder] removeObjectAtIndex:0];
+            [[item viewInStakView:[[self swc] stakView]] removeFromSuperview];
+            [self layoutItemViews];
+        }
     }
     return item;
 }
 
 
 - (void)setStak:(NSMutableArray *)stak {
-    [self setStakHolder:stak];
+    @synchronized(_stakLock) {
+        [self setStakHolder:stak];
+    }
 }
 
 - (void)layoutItemViews {
 }
 
 - (void)clearStakWarning {
-    
+    NSAlert *alert = [NSAlert alertWithMessageText:NSLocalizedString(@"All of your HeadStak history will be deleted. Are you sure?", nil)
+                     defaultButton:NSLocalizedString(@"No", nil)
+                   alternateButton:NSLocalizedString(@"Yes",nil)
+                       otherButton:nil
+         informativeTextWithFormat:@""];
+    NSInteger result = [alert runModal];
+    switch (result) {
+        case NSAlertAlternateReturn:
+            [self clearStak];
+            break;
+        default:
+            break;
+    }
+}
+
+- (void)clearStak {
+    @synchronized(_stakLock) {
+        while ([[self stakHolder] count]) {
+            StakItem *item = [[self stakHolder] objectAtIndex:0];
+            [[self stakHolder] removeObjectAtIndex:0];
+            [[item viewInStakView:[[self swc] stakView]] removeFromSuperview];
+        }
+        [[self stakHolder] removeAllObjects];
+    }
+    [[self db] hardDeleteStak];
+    [self layoutItemViews];
 }
 
 - (void)exportStakSheet {
-    
 }
 
+
+
 @end
 - (void)buildFreshStak;
 - (NSString *)typeNameForId:(NSUInteger)typeId;
 - (void)loadStakIntoHolder:(NSMutableArray *)holder;
+- (void)hardDeleteStak;
 
 @end
 #define HSDBName    @"headstak.db"
 
 @implementation StakDB
-@synthesize itemTypes = _itemTypes;
 
 + (id)stackDB {
     // Look for Application Support directory
 }
 
 - (void)buildFreshStak {
-    NSArray *itypes = [NSArray arrayWithObjects:
-                       [NSArray arrayWithObjects:@"1",@"Task",@"#00ff99",@"t",nil],
-                       [NSArray arrayWithObjects:@"2",@"Distraction",@"#ffcc00",@"d",nil],
-                       [NSArray arrayWithObjects:@"3",@"Sidetracked",@"#0099ff",@"d",nil],
-                        nil];
+    NSArray *itypes = @[@[@"1",@"Task",@"#00ff99",@"t"],
+                       @[@"2",@"Distraction",@"#ffcc00",@"d"],
+                       @[@"3",@"Sidetracked",@"#0099ff",@"d"]];
     
     if (![self executeUpdate:@"CREATE TABLE IF NOT EXISTS itemtypes \
      (id INTEGER PRIMARY KEY NOT NULL,\
         [holder addObject:item];
     }
 }
+
+- (void)hardDeleteStak {
+    [self executeUpdate:
+     @"DELETE FROM STAKITEMS",nil];
+    
+}
 @end
 
 - (StakItemView *)viewInStakView:(StakView *)stakView;
 - (id)initWithDictionary:(NSDictionary *)dict inDb:(StakDB *)db;
-- (id)initNewItemOfType:(NSUInteger)type InDb:(StakDB *)db;
+- (id)initNewItemOfType:(NSUInteger)type inDb:(StakDB *)db;
 - (void)save;
 - (NSColor *)colour;
 @end
 #import "StakApplication.h"
 
 @implementation StakItem
-@synthesize view = _view,
-            description = _description,
-            pushTime = _pushTime,
-            popTime = _popTime,
-            itemType = _itemType,
-            db = _db,
-            itemId = _itemId;
 
-- (id)initNewItemOfType:(NSUInteger)type InDb:(StakDB *)db {
+
+- (id)initNewItemOfType:(NSUInteger)type inDb:(StakDB *)db {
     self = [super init];
     if (self) {
         _db = db;
 #import "StakWindowController.h"
 
 @implementation StakView
-@synthesize box = _box;
-@synthesize scroller = _scroller;
 
 - (id)initWithCoder:(NSCoder *)aDecoder
 {

File StakWindowController.m

 };
 
 @implementation StakWindowController
-@synthesize stakView = _stakView,
-    controller = _controller,
-    caption = _caption;
+
 
 - (id)init {
     self = [super initWithWindowNibName:@"MainStak"];

File Untitled.xcworkspace/xcuserdata/veg.xcuserdatad/UserInterfaceState.xcuserstate

Binary file modified.

File headstak.xcodeproj/project.pbxproj

 		8D1582A4153B496400216E4E /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 8D1582A3153B496400216E4E /* MainMenu.xib */; };
 		8D1582A6153B770F00216E4E /* Credits.html in Resources */ = {isa = PBXBuildFile; fileRef = 8D1582A5153B770F00216E4E /* Credits.html */; };
 		8D1582A9153CE5F800216E4E /* StakWindow.m in Sources */ = {isa = PBXBuildFile; fileRef = 8D1582A8153CE5F800216E4E /* StakWindow.m */; };
+		8D2626F11782365B004D76B8 /* AppKit.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 8D2626F01782365B004D76B8 /* AppKit.framework */; };
+		8D2626F417823874004D76B8 /* localizable.strings in Resources */ = {isa = PBXBuildFile; fileRef = 8D2626F217823874004D76B8 /* localizable.strings */; };
 		8D2D3D4E154463B900B440A4 /* taskbg.png in Resources */ = {isa = PBXBuildFile; fileRef = 8D2D3D4D154463B900B440A4 /* taskbg.png */; };
 		8D491D44150D4A4600FA3170 /* StakItemView.m in Sources */ = {isa = PBXBuildFile; fileRef = 8D491D43150D4A4600FA3170 /* StakItemView.m */; };
 		8D491D4B150D67E300FA3170 /* StakItem.m in Sources */ = {isa = PBXBuildFile; fileRef = 8D491D4A150D67E300FA3170 /* StakItem.m */; };
 		8D1582A5153B770F00216E4E /* Credits.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = Credits.html; sourceTree = "<group>"; };
 		8D1582A7153CE5F800216E4E /* StakWindow.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StakWindow.h; sourceTree = "<group>"; };
 		8D1582A8153CE5F800216E4E /* StakWindow.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = StakWindow.m; sourceTree = "<group>"; };
+		8D2626F01782365B004D76B8 /* AppKit.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = AppKit.framework; path = System/Library/Frameworks/AppKit.framework; sourceTree = SDKROOT; };
+		8D2626F317823874004D76B8 /* English */ = {isa = PBXFileReference; lastKnownFileType = text.plist.strings; name = English; path = English.lproj/localizable.strings; sourceTree = "<group>"; };
 		8D2D3D4D154463B900B440A4 /* taskbg.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = taskbg.png; sourceTree = "<group>"; };
 		8D491D42150D4A4600FA3170 /* StakItemView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StakItemView.h; sourceTree = "<group>"; };
 		8D491D43150D4A4600FA3170 /* StakItemView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = StakItemView.m; sourceTree = "<group>"; };
 			isa = PBXFrameworksBuildPhase;
 			buildActionMask = 2147483647;
 			files = (
+				8D2626F11782365B004D76B8 /* AppKit.framework in Frameworks */,
 				8D4BAC461528DAFC00C0843F /* libsqlite3.dylib in Frameworks */,
 				8DDFE1B714A2A87500947DED /* Carbon.framework in Frameworks */,
 				8D11072F0486CEB800E47090 /* Cocoa.framework in Frameworks */,
 		29B97314FDCFA39411CA2CEA /* headstak */ = {
 			isa = PBXGroup;
 			children = (
+				8D2626F01782365B004D76B8 /* AppKit.framework */,
 				080E96DDFE201D6D7F000001 /* Classes */,
 				29B97315FDCFA39411CA2CEA /* Other Sources */,
 				29B97317FDCFA39411CA2CEA /* Resources */,
 				8D1582A3153B496400216E4E /* MainMenu.xib */,
 				8D1582A5153B770F00216E4E /* Credits.html */,
 				8D93F0561558966400E65DC8 /* StakPref.xib */,
+				8D2626F217823874004D76B8 /* localizable.strings */,
 			);
 			name = Resources;
 			sourceTree = "<group>";
 				8D2D3D4E154463B900B440A4 /* taskbg.png in Resources */,
 				8D93F054154F5A8B00E65DC8 /* COPYING in Resources */,
 				8D93F0571558966400E65DC8 /* StakPref.xib in Resources */,
+				8D2626F417823874004D76B8 /* localizable.strings in Resources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};
 			name = InfoPlist.strings;
 			sourceTree = "<group>";
 		};
+		8D2626F217823874004D76B8 /* localizable.strings */ = {
+			isa = PBXVariantGroup;
+			children = (
+				8D2626F317823874004D76B8 /* English */,
+			);
+			name = localizable.strings;
+			sourceTree = "<group>";
+		};
 		8D93F038154C896800E65DC8 /* InfoPlist.strings */ = {
 			isa = PBXVariantGroup;
 			children = (

File headstak_AppDelegate.h

 
 @interface headstak_AppDelegate : NSObject 
 {
-    NSWindow *window;
     NSStatusItem *statusItem;
     IBOutlet NSMenu *_stakMenu;
 }

File headstak_AppDelegate.m

 
 @implementation headstak_AppDelegate
 
-@synthesize window, hscontroller, stakMenu = _stakMenu;
-
-
 -(void)awakeFromNib {
     self.hscontroller = [[StakController alloc] init];
     EventHotKeyRef hotKeyRef;