macosx: implemented on-the-fly activation of the Media Key support
authorFelix Paul Kühne <fkuehne@videolan.org>
Thu, 16 Jul 2009 14:49:46 +0000 (16:49 +0200)
committerFelix Paul Kühne <fkuehne@videolan.org>
Thu, 16 Jul 2009 14:49:46 +0000 (16:49 +0200)
modules/gui/macosx/intf.h
modules/gui/macosx/intf.m
modules/gui/macosx/simple_prefs.m

index e974688..d5ca3d9 100644 (file)
@@ -433,7 +433,7 @@ struct intf_sys_t
        BOOL b_mediaKeySupport;
 }
 
-- (void)enableMediaKeySupport:(BOOL)b_value;
+- (void)coreChangedMediaKeySupportSetting: (NSNotification *)o_notification;
 - (void)sendEvent: (NSEvent*)event;
 - (void)resetJump;
 
index 6f489ea..25494bd 100644 (file)
@@ -2863,11 +2863,18 @@ end:
 - (void)awakeFromNib
 {
        b_mediaKeySupport = config_GetInt( VLCIntf, "macosx-mediakeys" );
+    [[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(coreChangedMediaKeySupportSetting:) name: @"VLCMediaKeySupportSettingChanged" object: nil];
 }
 
-- (void)enableMediaKeySupport:(BOOL)b_value
+- (void)dealloc
 {
-       b_mediaKeySupport = b_value;
+    [[NSNotificationCenter defaultCenter] removeObserver: self];
+    [super dealloc];
+}
+
+- (void)coreChangedMediaKeySupportSetting: (NSNotification *)o_notification
+{
+       b_mediaKeySupport = config_GetInt( VLCIntf, "macosx-mediakeys" );
 }
 
 - (void)sendEvent: (NSEvent*)event
index 35a482d..701a4cd 100644 (file)
@@ -748,6 +748,9 @@ static inline void save_module_list( intf_thread_t * p_intf, id object, const ch
                        [[[VLCMain sharedInstance] appleRemoteController] startListening: [VLCMain sharedInstance]];
                else
                        [[[VLCMain sharedInstance] appleRemoteController] stopListening: [VLCMain sharedInstance]];
+        [[NSNotificationCenter defaultCenter] postNotificationName: @"VLCMediaKeySupportSettingChanged" 
+                                                            object: nil 
+                                                          userInfo: nil];
 
         /* okay, let's save our changes to vlcrc */
         i = config_SaveConfigFile( p_intf, "main" );