Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 11 additions & 3 deletions Table Tool/Base.lproj/MainMenu.xib
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="9060" systemVersion="14F1808" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="14460.31" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
<dependencies>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="9060"/>
<deployment identifier="macosx"/>
<plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="14460.31"/>
</dependencies>
<objects>
<customObject id="-2" userLabel="File's Owner" customClass="NSApplication">
Expand Down Expand Up @@ -653,6 +654,13 @@ CA
<action selector="arrangeInFront:" target="-1" id="DRN-fu-gQh"/>
</connections>
</menuItem>
<menuItem isSeparatorItem="YES" id="m6Z-XH-La9"/>
<menuItem title="Quit application on last window close" tag="1" id="kl0-ob-XcT">
<modifierMask key="keyEquivalentModifierMask"/>
<connections>
<action selector="quitApplicationOnLastWindowClose:" target="-1" id="3rE-LE-IvR"/>
</connections>
</menuItem>
</items>
</menu>
</menuItem>
Expand Down
1 change: 1 addition & 0 deletions Table Tool/Constants.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@
#pragma mark Pasteboard Types

extern NSString *TTRowInternalPboardType;
extern NSString *TTQuitOnLastWindowClose;
1 change: 1 addition & 0 deletions Table Tool/Constants.m
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,4 @@
#pragma mark Initializing Globals for Pasteboard Types

NSString *TTRowInternalPboardType = @"Table Tool Row Internal PasteBoard Type";
NSString *TTQuitOnLastWindowClose = @"TTQuitOnLastWindowClose";
47 changes: 46 additions & 1 deletion Table Tool/Document.m
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ @interface Document () {
BOOL ignoreColumnDidMoveNotifications;
BOOL newFile;
BOOL enableEditing;

BOOL quitOnLastWindowClose;

NSArray *validPBoardTypes;

TTErrorViewController *errorController;
Expand All @@ -48,6 +49,26 @@ - (instancetype)init {
newFile = YES;
errorCode5 = @"Your are not allowed to save while the input format has an error. Configure the format manually, until no error occurs.";
_didSave = NO;
quitOnLastWindowClose = NO;

NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
quitOnLastWindowClose = [userDefaults boolForKey:TTQuitOnLastWindowClose];

if (quitOnLastWindowClose == YES){

NSMenu *mainMenu = [[NSApplication sharedApplication] mainMenu];
NSMenu *appMenu = [[mainMenu itemAtIndex:5] submenu];

for (NSMenuItem *item in [appMenu itemArray]) {

NSInteger tag = [item tag];

if (tag == 1){
[item setState:YES];
}
}

}

[self initValidPBoardTypes];

Expand All @@ -64,6 +85,7 @@ -(void)dealloc {

- (void)windowControllerDidLoadNib:(NSWindowController *)aController {
[super windowControllerDidLoadNib:aController];

dataCell = [self.tableView.tableColumns.firstObject dataCell];
[self updateTableColumns];

Expand Down Expand Up @@ -98,6 +120,11 @@ - (void)windowControllerDidLoadNib:(NSWindowController *)aController {

- (void)close {
[super close];

if (([self.windowControllers count] == 0) && (quitOnLastWindowClose == YES)){
[NSApp terminate:self];
}

}


Expand Down Expand Up @@ -1152,4 +1179,22 @@ -(IBAction)exportFile:(id)sender {
-(IBAction)openReadme:(id)sender {
[[NSWorkspace sharedWorkspace] openURL:[NSURL URLWithString:@"https://github.com/jakob/TableTool/blob/master/README.md"]];
}

-(IBAction)quitApplicationOnLastWindowClose:(id)sender {

quitOnLastWindowClose = !quitOnLastWindowClose;

NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
[userDefaults setBool:quitOnLastWindowClose forKey:TTQuitOnLastWindowClose];
[userDefaults synchronize];

if (quitOnLastWindowClose == YES){
[sender setState:NSControlStateValueOn];
}else{
[sender setState:NSControlStateValueOff];
}

}


@end