Skip to content

Commit

Permalink
Stores window position (fixes issue 21)
Browse files Browse the repository at this point in the history
  • Loading branch information
jtuley committed Feb 11, 2010
1 parent f0695e7 commit 918b87d
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 1 deletion.
1 change: 1 addition & 0 deletions Classes/NiceController.m
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ -(int)runModalOpenPanel:(NSOpenPanel *)openPanel forTypes:(NSArray *)openableFil
forTypes:[[NPPluginReader pluginReader] allowedExtensions]];
}


/**
* Takes an array of NSString files, converts them to NSURLs and opens them, adding subsequent files to the
* playlist.
Expand Down
8 changes: 7 additions & 1 deletion Classes/NiceDocument.m
Original file line number Diff line number Diff line change
Expand Up @@ -403,6 +403,12 @@ -(void)updateAfterLoad

- (void)repositionAfterLoad{

NSString* tPosition =[[Preferences mainPrefs] windowPosition];
if([[NSApp movieWindows] count] == 1 && tPosition != nil){
[[self window] setFrameOrigin:NSPointFromString(tPosition)];
return;
}

int tScreenPref = -1;

NSScreen* tScreen = [NSScreen mainScreen];
Expand Down Expand Up @@ -814,7 +820,7 @@ -(IBAction)toggleRandomMode:(id)sender
[self resetRandom];
}

[[NSNotificationCenter defaultCenter] postNotificationName:@"RebuildAllMenus" object:nil];
[[NSNotificationCenter defaultCenter] postNotificationName:@"RebuildAllMenus" object:nil];

}

Expand Down
6 changes: 6 additions & 0 deletions Classes/NiceWindow/NiceWindow.m
Original file line number Diff line number Diff line change
Expand Up @@ -223,12 +223,18 @@ -(void)resignMainWindow
-(void)setFrame:(NSRect)frameRect display:(BOOL)displayFlag
{
[super setFrame:frameRect display:displayFlag];
[[Preferences mainPrefs] setWindowPosition:[self frame].origin];
[self setOverlayControllerWindowLocation];
[self setOverlayTitleLocation];
[self setOverLayVolumeLocation];
[self setOverLaySubtitleLocation];
}

-(void)setFrameOrigin:(NSPoint)orign{
[[Preferences mainPrefs] setWindowPosition:orign];
[super setFrameOrigin:orign];
}

-(BOOL)canBecomeMainWindow
{
return YES;
Expand Down
2 changes: 2 additions & 0 deletions Classes/Preferences/Preferences.h
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,8 @@ enum defaultOpenModeValues { OPEN_PLAYLIST, OPEN_WINDOWS };
-(void)setDisableShowingOverlaysOnKeyPress:(BOOL)aBool;
-(float)opacityWhenWindowIsTransparent;
-(void)setOpacityWhenWindowIsTransparent:(float)aFloat;
-(NSString*)windowPosition;
-(void)setWindowPosition:(NSPoint) aPoint;

-(void)integrateViewerPluginPrefs;
-(NSMutableArray *)viewerPluginPrefs;
Expand Down
10 changes: 10 additions & 0 deletions Classes/Preferences/Preferences.m
Original file line number Diff line number Diff line change
Expand Up @@ -194,6 +194,16 @@ -(void)setScrollResizePin:(enum scrollResizePinValues)anInt
[[NSUserDefaults standardUserDefaults] setInteger:anInt forKey:@"scrollResizePin"];
}

-(void)setWindowPosition:(NSPoint) aPoint
{
[[NSUserDefaults standardUserDefaults] setObject:NSStringFromPoint(aPoint) forKey:@"windowOrigin"];
}

-(NSString*)windowPosition
{
return [[NSUserDefaults standardUserDefaults] valueForKey:@"windowOrigin"];
}

-(enum defaultTimeDisplayValues)defaultTimeDisplay
{
return defaultTimeDisplay;
Expand Down

0 comments on commit 918b87d

Please sign in to comment.