Commit 6495e042 authored by Felix Paul Kühne's avatar Felix Paul Kühne

macosx: save playback modes on quit and recover more gracefully

(cherry picked from commit 20b891eb)
parent 75c9feea
...@@ -456,6 +456,7 @@ static VLCMainWindow *_o_sharedInstance = nil; ...@@ -456,6 +456,7 @@ static VLCMainWindow *_o_sharedInstance = nil;
[[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(someWindowWillClose:) name: NSWindowWillCloseNotification object: nil]; [[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(someWindowWillClose:) name: NSWindowWillCloseNotification object: nil];
[[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(someWindowWillMiniaturize:) name: NSWindowWillMiniaturizeNotification object:nil]; [[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(someWindowWillMiniaturize:) name: NSWindowWillMiniaturizeNotification object:nil];
[[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(applicationWillTerminate:) name: NSApplicationWillTerminateNotification object: nil]; [[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(applicationWillTerminate:) name: NSApplicationWillTerminateNotification object: nil];
[[VLCMain sharedInstance] playbackModeUpdated];
} }
#pragma mark - #pragma mark -
......
...@@ -614,8 +614,6 @@ static VLCMain *_o_sharedMainInstance = nil; ...@@ -614,8 +614,6 @@ static VLCMain *_o_sharedMainInstance = nil;
var_AddCallback( p_intf, "dialog-progress-bar", DialogCallback, self ); var_AddCallback( p_intf, "dialog-progress-bar", DialogCallback, self );
dialog_Register( p_intf ); dialog_Register( p_intf );
[self playbackModeUpdated];
/* init Apple Remote support */ /* init Apple Remote support */
o_remote = [[AppleRemote alloc] init]; o_remote = [[AppleRemote alloc] init];
[o_remote setClickCountEnabledButtons: kRemoteButtonPlay]; [o_remote setClickCountEnabledButtons: kRemoteButtonPlay];
...@@ -636,6 +634,11 @@ static VLCMain *_o_sharedMainInstance = nil; ...@@ -636,6 +634,11 @@ static VLCMain *_o_sharedMainInstance = nil;
{ {
if( !p_intf ) return; if( !p_intf ) return;
[o_mainwindow updateWindow];
[o_mainwindow updateTimeSlider];
[o_mainwindow updateVolumeSlider];
[o_mainwindow makeKeyAndOrderFront: self];
/* init media key support */ /* init media key support */
b_mediaKeySupport = config_GetInt( VLCIntf, "macosx-mediakeys" ); b_mediaKeySupport = config_GetInt( VLCIntf, "macosx-mediakeys" );
if( b_mediaKeySupport ) if( b_mediaKeySupport )
...@@ -650,11 +653,6 @@ static VLCMain *_o_sharedMainInstance = nil; ...@@ -650,11 +653,6 @@ static VLCMain *_o_sharedMainInstance = nil;
[self _removeOldPreferences]; [self _removeOldPreferences];
[o_mainwindow updateWindow];
[o_mainwindow updateTimeSlider];
[o_mainwindow updateVolumeSlider];
[o_mainwindow makeKeyAndOrderFront: self];
/* Handle sleep notification */ /* Handle sleep notification */
[[[NSWorkspace sharedWorkspace] notificationCenter] addObserver:self selector:@selector(computerWillSleep:) [[[NSWorkspace sharedWorkspace] notificationCenter] addObserver:self selector:@selector(computerWillSleep:)
name:NSWorkspaceWillSleepNotification object:nil]; name:NSWorkspaceWillSleepNotification object:nil];
...@@ -690,20 +688,11 @@ static VLCMain *_o_sharedMainInstance = nil; ...@@ -690,20 +688,11 @@ static VLCMain *_o_sharedMainInstance = nil;
- (void)applicationWillTerminate:(NSNotification *)notification - (void)applicationWillTerminate:(NSNotification *)notification
{ {
if (notification == nil)
[[NSNotificationCenter defaultCenter] postNotificationName: NSApplicationWillTerminateNotification object: nil];
playlist_t * p_playlist;
int returnedValue = 0;
if( !p_intf ) if( !p_intf )
return; return;
// save stuff /* don't allow a double termination call. If the user has
config_SaveConfigFile( p_intf ); * already invoked the quit then simply return this time. */
// don't allow a double termination call. If the user has
// already invoked the quit then simply return this time.
int isTerminating = false; int isTerminating = false;
[o_appLock lock]; [o_appLock lock];
...@@ -713,9 +702,21 @@ static VLCMain *_o_sharedMainInstance = nil; ...@@ -713,9 +702,21 @@ static VLCMain *_o_sharedMainInstance = nil;
if (isTerminating) if (isTerminating)
return; return;
msg_Dbg( p_intf, "Terminating" ); if (notification == nil)
[[NSNotificationCenter defaultCenter] postNotificationName: NSApplicationWillTerminateNotification object: nil];
p_playlist = pl_Get( p_intf ); playlist_t * p_playlist = pl_Get( p_intf );;
int returnedValue = 0;
/* Save some interface state in configuration, at module quit */
config_PutInt( p_intf, "random", var_GetBool( p_playlist, "random" ) );
config_PutInt( p_intf, "loop", var_GetBool( p_playlist, "loop" ) );
config_PutInt( p_intf, "repeat", var_GetBool( p_playlist, "repeat" ) );
// save stuff
config_SaveConfigFile( p_intf );
msg_Dbg( p_intf, "Terminating" );
/* unsubscribe from the interactive dialogues */ /* unsubscribe from the interactive dialogues */
dialog_Unregister( p_intf ); dialog_Unregister( p_intf );
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment