1. Veg Head
  2. headstak

Commits

Veg Head  committed fe01c39

Rename StakViewController

  • Participants
  • Parent commits cd9609b
  • Branches master

Comments (0)

Files changed (10)

File StakController.h

View file
  • Ignore whitespace
-/**
- headstak - a stack for your head
- 
- Copyright (C) 2012 dreadtech.com
- 
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
- 
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- GNU General Public License for more details.
- 
- You should have received a copy of the GNU General Public License
- along with this program.  If not, see <http://www.gnu.org/licenses/>.
- 
- **/
 //
-//  HSController.h
+//  StakController.h
 //  headstak
 //
-//  Created by Veghead on 7/24/11.
-
-#import <Foundation/Foundation.h>
-
-@class StakWindowController;
-@class StakDB;
-@class StakItem;
-@class StakPrefController;
-
-@interface StakController : NSViewController {
-
-}
-
-@property (strong, nonatomic) StakWindowController *swc;
-@property (strong, nonatomic) StakPrefController *spc;
+//  Created by Veghead on 7/6/13.
+//  Copyright (c) 2013 dreadtech.com. All rights reserved.
+//
 
-@property (strong, nonatomic) StakDB *db;
-@property (nonatomic, strong) NSMutableArray *stakHolder;
+#import <Cocoa/Cocoa.h>
 
-- (void)setStak:(NSMutableArray *)stak;
-- (void)layoutItemViews;
-- (StakItem *)pushNewItemOfType:(NSUInteger)itemType;
-- (StakItem *)popItem;
-- (void)clearStakWarning;
-- (void)exportStakSheet;
+@interface StakController : NSArrayController
 
 @end

File StakController.m

View file
  • Ignore whitespace
-/**
- headstak - a stack for your head
- 
- Copyright (C) 2012 dreadtech.com
- 
- This program is free software: you can redistribute it and/or modify
- it under the terms of the GNU General Public License as published by
- the Free Software Foundation, either version 3 of the License, or
- (at your option) any later version.
- 
- This program is distributed in the hope that it will be useful,
- but WITHOUT ANY WARRANTY; without even the implied warranty of
- MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- GNU General Public License for more details.
- 
- You should have received a copy of the GNU General Public License
- along with this program.  If not, see <http://www.gnu.org/licenses/>.
- 
- **/
 //
-//  HSController.m
+//  StakController.m
 //  headstak
 //
-//  Created by Veghead on 7/24/11.
-
+//  Created by Veghead on 7/6/13.
+//  Copyright (c) 2013 dreadtech.com. All rights reserved.
+//
 
 #import "StakController.h"
-#import "StakWindowController.h"
-#import "StakDB.h"
-#import "StakItem.h"
-#import "StakView.h"
-#import "StakItemView.h"
-#import "StakPrefController.h"
-
-NSObject *_stakLock;
 
 @implementation StakController
 
-- (id)init
-{
-    self = [super init];
-    if (self) {
-        _swc = [[StakWindowController alloc] init];
-        [_swc setController:self];
-        _db = [StakDB stackDB];
-        [_db setTraceExecution:YES];
-        [_db setLogsErrors:YES];
-        [_db open];
-        _stakHolder = [[NSMutableArray alloc] init];        
-        [_db loadStakIntoHolder:_stakHolder];
-        _stakLock = [[NSObject alloc] init];
-    }
-    return self;
-}
-
-
-- (void)flagsChanged:(NSEvent *)theEvent {
-    NSLog(@"flags changed");
-}
-
-
-- (StakItem *)pushNewItemOfType:(NSUInteger)itemType {
-    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;
-    @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 {
-    @synchronized(_stakLock) {
-        [self setStakHolder:stak];
-    }
-}
-
-- (void)layoutItemViews {
-    NSRect r = [[[self swc] stakView] frame];
-    NSInteger yoffset = 0;
-    NSMakeRect(r.origin.x, [[self stakHolder] count] * 40, r.size.width, r.size.height);
-    for (StakItem *item in [self stakHolder]) {
-        NSRect theFrame = [[item view] frame];
-        theFrame.origin.y = yoffset;
-        [[item view] setFrame:theFrame];
-        yoffset += theFrame.size.height + 5;
-    }
-    [[[self swc]stakView] setNeedsDisplay:YES];
-    return;
-}
-
-- (StakPrefController *)spc {
-    if (!_spc) {
-        _spc = [[StakPrefController alloc] initWithWindowNibName:@"StakPref"];
-    }
-    return _spc;
-}
-
-- (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

File StakViewController.h

View file
  • Ignore whitespace
+/**
+ headstak - a stack for your head
+ 
+ Copyright (C) 2012 dreadtech.com
+ 
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+ 
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ GNU General Public License for more details.
+ 
+ You should have received a copy of the GNU General Public License
+ along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ 
+ **/
+//
+//  HSController.h
+//  headstak
+//
+//  Created by Veghead on 7/24/11.
+
+#import <Foundation/Foundation.h>
+
+@class StakWindowController;
+@class StakDB;
+@class StakItem;
+@class StakPrefController;
+
+@interface StakViewController : NSViewController {
+
+}
+
+@property (strong, nonatomic) StakWindowController *swc;
+@property (strong, nonatomic) StakPrefController *spc;
+
+@property (strong, nonatomic) StakDB *db;
+@property (nonatomic, strong) NSMutableArray *stakHolder;
+
+- (void)setStak:(NSMutableArray *)stak;
+- (void)layoutItemViews;
+- (StakItem *)pushNewItemOfType:(NSUInteger)itemType;
+- (StakItem *)popItem;
+- (void)clearStakWarning;
+- (void)exportStakSheet;
+
+@end

File StakViewController.m

View file
  • Ignore whitespace
+/**
+ headstak - a stack for your head
+ 
+ Copyright (C) 2012 dreadtech.com
+ 
+ This program is free software: you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation, either version 3 of the License, or
+ (at your option) any later version.
+ 
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ GNU General Public License for more details.
+ 
+ You should have received a copy of the GNU General Public License
+ along with this program.  If not, see <http://www.gnu.org/licenses/>.
+ 
+ **/
+//
+//  HSController.m
+//  headstak
+//
+//  Created by Veghead on 7/24/11.
+
+
+#import "StakViewController.h"
+#import "StakWindowController.h"
+#import "StakDB.h"
+#import "StakItem.h"
+#import "StakView.h"
+#import "StakItemView.h"
+#import "StakPrefController.h"
+
+NSObject *_stakLock;
+
+@implementation StakViewController
+
+- (id)init
+{
+    self = [super init];
+    if (self) {
+        _swc = [[StakWindowController alloc] init];
+        [_swc setController:self];
+        _db = [StakDB stackDB];
+        [_db setTraceExecution:YES];
+        [_db setLogsErrors:YES];
+        [_db open];
+        _stakHolder = [[NSMutableArray alloc] init];        
+        [_db loadStakIntoHolder:_stakHolder];
+        _stakLock = [[NSObject alloc] init];
+    }
+    return self;
+}
+
+
+- (void)flagsChanged:(NSEvent *)theEvent {
+    NSLog(@"flags changed");
+}
+
+
+- (StakItem *)pushNewItemOfType:(NSUInteger)itemType {
+    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;
+    @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 {
+    @synchronized(_stakLock) {
+        [self setStakHolder:stak];
+    }
+}
+
+- (void)layoutItemViews {
+    NSRect r = [[[self swc] stakView] frame];
+    NSInteger yoffset = 0;
+    NSMakeRect(r.origin.x, [[self stakHolder] count] * 40, r.size.width, r.size.height);
+    for (StakItem *item in [self stakHolder]) {
+        NSRect theFrame = [[item view] frame];
+        theFrame.origin.y = yoffset;
+        [[item view] setFrame:theFrame];
+        yoffset += theFrame.size.height + 5;
+    }
+    [[[self swc]stakView] setNeedsDisplay:YES];
+    return;
+}
+
+- (StakPrefController *)spc {
+    if (!_spc) {
+        _spc = [[StakPrefController alloc] initWithWindowNibName:@"StakPref"];
+    }
+    return _spc;
+}
+
+- (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

File StakWindowController.h

View file
  • Ignore whitespace
 
 @class StakView;
 @class StakItem;
-@class StakController;
+@class StakViewController;
 
 @interface StakWindowController : NSWindowController {
-    StakController *_controller;
+    StakViewController *_controller;
     IBOutlet StakView *_stakView;
     IBOutlet NSTextField *_caption;
 }
 
-@property (strong, nonatomic) StakController *controller;
+@property (strong, nonatomic) StakViewController *controller;
 @property (strong, nonatomic) StakView *stakView;
 @property (strong, nonatomic) NSTextField *caption;
 

File StakWindowController.m

View file
  • Ignore whitespace
 #import "StakView.h"
 #import "StakItem.h"
 #import "StakItemView.h"
-#import "StakController.h"
+#import "StakViewController.h"
 
 enum {
     keycodeUp = 126,

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

  • Ignore whitespace
Binary file modified.

File headstak.xcodeproj/project.pbxproj

View file
  • Ignore whitespace
 		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 */; };
+		8D2626F71788B369004D76B8 /* StakController.m in Sources */ = {isa = PBXBuildFile; fileRef = 8D2626F61788B369004D76B8 /* StakController.m */; };
 		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 */; };
 		8E26D0BD13C0EDFD00155117 /* rockicon.icns in Resources */ = {isa = PBXBuildFile; fileRef = 8E26D0BC13C0EDFD00155117 /* rockicon.icns */; };
 		8E7F537813F87F5D00891382 /* StakView.m in Sources */ = {isa = PBXBuildFile; fileRef = 8E7F537713F87F5D00891382 /* StakView.m */; };
 		8E7F537A13F891A100891382 /* stakicon.png in Resources */ = {isa = PBXBuildFile; fileRef = 8E7F537913F891A100891382 /* stakicon.png */; };
-		8EDDA76913DCACC300C60BD3 /* StakController.m in Sources */ = {isa = PBXBuildFile; fileRef = 8EDDA76813DCACC300C60BD3 /* StakController.m */; };
+		8EDDA76913DCACC300C60BD3 /* StakViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 8EDDA76813DCACC300C60BD3 /* StakViewController.m */; };
 		8EDDA76C13DCCE4D00C60BD3 /* StakApplication.m in Sources */ = {isa = PBXBuildFile; fileRef = 8EDDA76B13DCCE4D00C60BD3 /* StakApplication.m */; };
 /* End PBXBuildFile section */
 
 		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>"; };
+		8D2626F51788B369004D76B8 /* StakController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StakController.h; sourceTree = "<group>"; };
+		8D2626F61788B369004D76B8 /* StakController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = StakController.m; 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>"; };
 		8E7F537613F87F5D00891382 /* StakView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StakView.h; sourceTree = "<group>"; };
 		8E7F537713F87F5D00891382 /* StakView.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = StakView.m; sourceTree = "<group>"; };
 		8E7F537913F891A100891382 /* stakicon.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; path = stakicon.png; sourceTree = "<group>"; };
-		8EDDA76713DCACC300C60BD3 /* StakController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StakController.h; sourceTree = "<group>"; };
-		8EDDA76813DCACC300C60BD3 /* StakController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = StakController.m; sourceTree = "<group>"; };
+		8EDDA76713DCACC300C60BD3 /* StakViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StakViewController.h; sourceTree = "<group>"; };
+		8EDDA76813DCACC300C60BD3 /* StakViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = StakViewController.m; sourceTree = "<group>"; };
 		8EDDA76A13DCCE4D00C60BD3 /* StakApplication.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StakApplication.h; sourceTree = "<group>"; };
 		8EDDA76B13DCCE4D00C60BD3 /* StakApplication.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = StakApplication.m; sourceTree = "<group>"; };
 /* End PBXFileReference section */
 				8D4BAC471528DECE00C0843F /* fmdb */,
 				77C8280B06725ACE000B614F /* headstak_AppDelegate.h */,
 				77C8280C06725ACE000B614F /* headstak_AppDelegate.m */,
+				8D2626F51788B369004D76B8 /* StakController.h */,
+				8D2626F61788B369004D76B8 /* StakController.m */,
 				8EDDA76A13DCCE4D00C60BD3 /* StakApplication.h */,
 				8EDDA76B13DCCE4D00C60BD3 /* StakApplication.m */,
-				8EDDA76713DCACC300C60BD3 /* StakController.h */,
-				8EDDA76813DCACC300C60BD3 /* StakController.m */,
+				8EDDA76713DCACC300C60BD3 /* StakViewController.h */,
+				8EDDA76813DCACC300C60BD3 /* StakViewController.m */,
 				8E1E6E9413EDDA1D000AADA8 /* StakWindowController.h */,
 				8E1E6E9513EDDA1D000AADA8 /* StakWindowController.m */,
 				8E7F537613F87F5D00891382 /* StakView.h */,
 			files = (
 				8D11072D0486CEB800E47090 /* main.m in Sources */,
 				77C8280E06725ACE000B614F /* headstak_AppDelegate.m in Sources */,
-				8EDDA76913DCACC300C60BD3 /* StakController.m in Sources */,
+				8EDDA76913DCACC300C60BD3 /* StakViewController.m in Sources */,
 				8EDDA76C13DCCE4D00C60BD3 /* StakApplication.m in Sources */,
 				8E1E6E9613EDDA1D000AADA8 /* StakWindowController.m in Sources */,
 				8E7F537813F87F5D00891382 /* StakView.m in Sources */,
 				8D4BAC4A15290AF600C0843F /* StakDB.m in Sources */,
 				8D1582A9153CE5F800216E4E /* StakWindow.m in Sources */,
 				8D5F9D721581700E009411D5 /* StakPrefController.m in Sources */,
+				8D2626F71788B369004D76B8 /* StakController.m in Sources */,
 			);
 			runOnlyForDeploymentPostprocessing = 0;
 		};

File headstak_AppDelegate.h

View file
  • Ignore whitespace
 //  Created by Veghead on 25/06/2011.
 
 #import <Cocoa/Cocoa.h>
-@class StakController;
+@class StakViewController;
 
 @interface headstak_AppDelegate : NSObject 
 {
 };
 
 @property (nonatomic, strong) IBOutlet NSWindow *window;
-@property (nonatomic, strong) StakController *hscontroller;
+@property (nonatomic, strong) StakViewController *hscontroller;
 @property (strong, nonatomic) NSMenu *stakMenu;
 
 - (IBAction)menuHandler:(id)sender;

File headstak_AppDelegate.m

View file
  • Ignore whitespace
 
 #import "headstak_AppDelegate.h"
 #import <Carbon/Carbon.h>
-#import "StakController.h"
+#import "StakViewController.h"
 #import "StakItem.h"
 #import "StakView.h"
 #import "StakWindowController.h"
 @implementation headstak_AppDelegate
 
 -(void)awakeFromNib {
-    self.hscontroller = [[StakController alloc] init];
+    self.hscontroller = [[StakViewController alloc] init];
     EventHotKeyRef hotKeyRef;
     EventHotKeyID hotKeyID;
     EventTypeSpec eventType;