]> git.sesse.net Git - vlc/commitdiff
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 e9746882ddbc0738db0d3ba4f5e690aa46b47d75..d5ca3d970846de9f50eeb15dab77b76fd5592f4d 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 6f489ea5273a9461df666fb179e712526dc6d217..25494bd01dc6de85faceaeecb61a7b35161ba177 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 35a482dc59ea3f85575b1ad3bb8b166838a49c71..701a4cd9db42e04cc9945ed0437fb2d50d398365 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" );