]> git.sesse.net Git - vlc/blobdiff - modules/gui/macosx/intf.m
macosx: removed 'erase logo' from the video effects panel and moved 'add logo' to...
[vlc] / modules / gui / macosx / intf.m
index 47a93ff8717241339df32f1e328a8f929f74cf67..64265cb3d547c5796a55c1a0cd8b4cfef073ebcf 100644 (file)
 #include <vlc_vout_window.h>
 #include <unistd.h> /* execl() */
 
+#import "CompatibilityFixes.h"
 #import "intf.h"
 #import "MainMenu.h"
-#import "MainWindow.h"
-#import "fspanel.h"
 #import "vout.h"
 #import "prefs.h"
 #import "playlist.h"
@@ -71,7 +70,7 @@ static void updateProgressPanel (void *, const char *, float);
 static bool checkProgressPanel (void *);
 static void destroyProgressPanel (void *);
 
-static void MsgCallback( msg_cb_data_t *, const msg_item_t * );
+static void MsgCallback( void *data, int type, const msg_item_t *item, const char *format, va_list ap );
 
 static int InputEvent( vlc_object_t *, const char *,
                       vlc_value_t, vlc_value_t, void * );
@@ -103,7 +102,7 @@ int OpenIntf ( vlc_object_t *p_this )
     memset( p_intf->p_sys, 0, sizeof( *p_intf->p_sys ) );
 
     /* subscribe to LibVLCCore's messages */
-    p_intf->p_sys->p_sub = msg_Subscribe( p_intf->p_libvlc, MsgCallback, NULL );
+    p_intf->p_sys->p_sub = vlc_Subscribe( MsgCallback, NULL );
     p_intf->pf_run = Run;
     p_intf->b_should_run_on_first_thread = true;
 
@@ -220,19 +219,23 @@ static void Run( intf_thread_t *p_intf )
  * ready to be displayed. We store everything in a NSArray in our Cocoa part
  * of this file.
  *****************************************************************************/
-static void MsgCallback( msg_cb_data_t *data, const msg_item_t *item )
+static void MsgCallback( void *data, int type, const msg_item_t *item, const char *format, va_list ap )
 {
     int canc = vlc_savecancel();
+    char *str;
 
-    /* this may happen from time to time, let's bail out as info would be useless anyway */
-    if( !item->psz_module || !item->psz_msg )
+    if (vasprintf( &str, format, ap ) == -1)
+    {
+        vlc_restorecancel( canc );
         return;
+    }
 
     NSAutoreleasePool *o_pool = [[NSAutoreleasePool alloc] init];
-    [[VLCMain sharedInstance] processReceivedlibvlcMessage: item];
+    [[VLCMain sharedInstance] processReceivedlibvlcMessage: item ofType: type withStr: str];
     [o_pool release];
 
     vlc_restorecancel( canc );
+    free( str );
 }
 
 static int InputEvent( vlc_object_t *p_this, const char *psz_var,
@@ -251,6 +254,7 @@ static int InputEvent( vlc_object_t *p_this, const char *psz_var,
             break;
         case INPUT_EVENT_TITLE:
         case INPUT_EVENT_CHAPTER:
+            [[VLCMain sharedInstance] updateMainMenu];
             break;
         case INPUT_EVENT_CACHE:
             [[VLCMain sharedInstance] updateMainWindow];
@@ -261,7 +265,6 @@ static int InputEvent( vlc_object_t *p_this, const char *psz_var,
         case INPUT_EVENT_ES:
             break;
         case INPUT_EVENT_TELETEXT:
-            NSLog( @"teletext" );
             break;
         case INPUT_EVENT_AOUT:
             break;
@@ -269,14 +272,17 @@ static int InputEvent( vlc_object_t *p_this, const char *psz_var,
             break;
         case INPUT_EVENT_ITEM_META:
         case INPUT_EVENT_ITEM_INFO:
+            [[VLCMain sharedInstance] updateMainMenu];
             [[VLCMain sharedInstance] updateName];
             [[VLCMain sharedInstance] updateInfoandMetaPanel];
             break;
         case INPUT_EVENT_BOOKMARK:
             break;
         case INPUT_EVENT_RECORD:
+            [[VLCMain sharedInstance] updateRecordState: var_GetBool( p_this, "record" )];
             break;
         case INPUT_EVENT_PROGRAM:
+            [[VLCMain sharedInstance] updateMainMenu];
             break;
         case INPUT_EVENT_ITEM_EPG:
             break;
@@ -299,7 +305,8 @@ static int InputEvent( vlc_object_t *p_this, const char *psz_var,
             break;
 
         case INPUT_EVENT_ABORT:
-            //NSLog( @"input stopped by user" );
+            [[VLCMain sharedInstance] updateName];
+            [[VLCMain sharedInstance] updatePlaybackPosition];
             break;
 
         default:
@@ -362,7 +369,7 @@ static int ShowController( vlc_object_t *p_this, const char *psz_variable,
     intf_thread_t * p_intf = VLCIntf;
     if( p_intf && p_intf->p_sys )
     {
-        NSLog( @"fixme! we should implement ShowController here" );
+//        [[[VLCMain sharedInstance] fspanel] makeKeyAndOrderFront: nil];
     }
     return VLC_SUCCESS;
 }
@@ -507,8 +514,6 @@ static VLCMain *_o_sharedMainInstance = nil;
 
     o_msg_lock = [[NSLock alloc] init];
     o_msg_arr = [[NSMutableArray arrayWithCapacity: 600] retain];
-    /* subscribe to LibVLC's debug messages as early as possible (for us) */
-    [[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(libvlcMessageReceived:) name: @"VLCCoreMessageReceived" object: nil];
 
     o_open = [[VLCOpen alloc] init];
     //o_embedded_list = [[VLCEmbeddedList alloc] init];
@@ -567,6 +572,9 @@ static VLCMain *_o_sharedMainInstance = nil;
     var_AddCallback(p_playlist, "volume", VolumeUpdated, self);
     var_AddCallback(p_playlist, "mute", VolumeUpdated, self);
 
+    if ([NSApp currentSystemPresentationOptions] == NSApplicationPresentationFullScreen)
+        var_SetBool( p_playlist, "fullscreen", YES );
+
     /* load our Core Dialogs nib */
     nib_coredialogs_loaded = [NSBundle loadNibNamed:@"CoreDialogs" owner: NSApp];
 
@@ -591,6 +599,7 @@ static VLCMain *_o_sharedMainInstance = nil;
     [o_remote setDelegate: _o_sharedMainInstance];
 
     /* yeah, we are done */
+    b_nativeFullscreenMode = config_GetInt( p_intf, "macosx-nativefullscreenmode" );
     nib_main_loaded = TRUE;
 }
 
@@ -612,6 +621,9 @@ static VLCMain *_o_sharedMainInstance = nil;
 
     [self _removeOldPreferences];
 
+    [o_mainwindow updateWindow];
+    [o_mainwindow updateTimeSlider];
+    [o_mainwindow updateVolumeSlider];
     [o_mainwindow makeKeyAndOrderFront: self];
 
     /* Handle sleep notification */
@@ -716,7 +728,7 @@ static VLCMain *_o_sharedMainInstance = nil;
     [o_mainwindow release];
 
     /* unsubscribe from libvlc's debug messages */
-    msg_Unsubscribe( p_intf->p_sys->p_sub );
+    vlc_Unsubscribe( p_intf->p_sys->p_sub );
 
     [o_msg_arr removeAllObjects];
     [o_msg_arr release];
@@ -747,10 +759,6 @@ static VLCMain *_o_sharedMainInstance = nil;
     [NSApp activateIgnoringOtherApps:YES];
     [o_remote stopListening: self];
     var_SetInteger( p_intf->p_libvlc, "key-action", ACTIONID_STOP );
-
-    /* Close the window directly, because we do know that there
-     * won't be anymore video. It's currently waiting a bit. */
-    [[[o_coreinteraction voutView] window] orderOut:self];
 }
 
 #pragma mark -
@@ -1227,7 +1235,6 @@ unsigned int CocoaKeyToVLC( unichar i_key )
         }
     }
     module_config_free (p_config);
-    module_release (p_main);
     o_usedHotkeys = [[NSArray alloc] initWithArray: o_usedHotkeys copyItems: YES];
 }
 
@@ -1235,10 +1242,30 @@ unsigned int CocoaKeyToVLC( unichar i_key )
 #pragma mark Interface updaters
 - (void)fullscreenChanged
 {
-    if(! [o_mainwindow isFullscreen] )
-        [o_mainwindow performSelectorOnMainThread:@selector(enterFullscreen) withObject:nil waitUntilDone:NO];
+    playlist_t * p_playlist = pl_Get( VLCIntf );
+    BOOL b_fullscreen = var_GetBool( p_playlist, "fullscreen" );
+
+    if (OSX_LION && b_nativeFullscreenMode)
+    {
+        [o_mainwindow toggleFullScreen: self];
+        if(b_fullscreen)
+            [NSApp setPresentationOptions:(NSApplicationPresentationFullScreen)];
+        else
+            [NSApp setPresentationOptions:(NSApplicationPresentationDefault)];
+    }
     else
-        [o_mainwindow performSelectorOnMainThread:@selector(leaveFullscreen) withObject:nil waitUntilDone:NO];
+    {
+        input_thread_t * p_input = pl_CurrentInput( VLCIntf );
+
+        if( p_input != NULL )
+        {
+            if(b_fullscreen)
+                [o_mainwindow performSelectorOnMainThread:@selector(enterFullscreen) withObject:nil waitUntilDone:NO];
+            else
+                [o_mainwindow performSelectorOnMainThread:@selector(leaveFullscreen) withObject:nil waitUntilDone:NO];
+            vlc_object_release( p_input );
+        }
+    }
 }
 
 - (void)PlaylistItemChanged
@@ -1257,6 +1284,11 @@ unsigned int CocoaKeyToVLC( unichar i_key )
 
     [o_playlist updateRowSelection];
     [o_mainwindow updateWindow];
+    [self updateMainMenu];
+}
+
+- (void)updateMainMenu
+{
     [o_mainmenu setupMenus];
     [o_mainmenu updatePlaybackRate];
 }
@@ -1266,6 +1298,11 @@ unsigned int CocoaKeyToVLC( unichar i_key )
     [o_mainwindow updateWindow];
 }
 
+- (void)showFullscreenController
+{
+    [o_mainwindow showFullscreenController];
+}
+
 - (void)updateDelays
 {
     [[VLCTrackSynchronization sharedInstance] performSelectorOnMainThread: @selector(updateValues) withObject: nil waitUntilDone:NO];
@@ -1279,6 +1316,15 @@ unsigned int CocoaKeyToVLC( unichar i_key )
 - (void)updatePlaybackPosition
 {
     [o_mainwindow updateTimeSlider];
+
+    input_thread_t * p_input;
+    p_input = pl_CurrentInput( p_intf );
+    if( p_input )
+    {
+        if( var_GetInteger( p_input, "state" ) == PLAYING_S )
+            UpdateSystemActivity( UsrActivity );
+        vlc_object_release( p_input );
+    }
 }
 
 - (void)updateVolume
@@ -1291,6 +1337,12 @@ unsigned int CocoaKeyToVLC( unichar i_key )
     [self playbackStatusUpdated];
     [o_playlist playlistUpdated];
     [o_mainwindow updateWindow];
+    [o_mainwindow updateName];
+}
+
+- (void)updateRecordState: (BOOL)b_value
+{
+    [o_mainmenu updateRecordState:b_value];
 }
 
 - (void)updateInfoandMetaPanel
@@ -1308,7 +1360,6 @@ unsigned int CocoaKeyToVLC( unichar i_key )
         int state = var_GetInteger( p_input, "state" );
         if( state == PLAYING_S )
         {
-            [[[self controls] fspanel] setPause];
             [[self mainMenu] setPause];
             [o_mainwindow setPause];
         }
@@ -1316,7 +1367,6 @@ unsigned int CocoaKeyToVLC( unichar i_key )
         {
             if (state == END_S)
                 [o_mainmenu setSubmenusEnabled: FALSE];
-            [[[self controls] fspanel] setPlay];
             [[self mainMenu] setPlay];
             [o_mainwindow setPlay];
         }
@@ -1727,7 +1777,7 @@ unsigned int CocoaKeyToVLC( unichar i_key )
     }
 }
 
-- (void)processReceivedlibvlcMessage:(const msg_item_t *)item
+- (void)processReceivedlibvlcMessage:(const msg_item_t *) item ofType: (int)i_type withStr: (char *)str
 {
     NSColor *o_white = [NSColor whiteColor];
     NSColor *o_red = [NSColor redColor];
@@ -1740,8 +1790,6 @@ unsigned int CocoaKeyToVLC( unichar i_key )
     NSDictionary *o_attr;
     NSAttributedString *o_msg_color;
 
-    int i_type = item->i_type;
-
     [o_msg_lock lock];
 
     if( [o_msg_arr count] + 2 > 600 )
@@ -1755,7 +1803,7 @@ unsigned int CocoaKeyToVLC( unichar i_key )
     [o_msg_arr addObject: [o_msg_color autorelease]];
 
     o_attr = [NSDictionary dictionaryWithObject: pp_color[i_type] forKey: NSForegroundColorAttributeName];
-    o_msg_color = [[NSAttributedString alloc] initWithString: [NSString stringWithFormat: @"%s\n", item->psz_msg] attributes: o_attr];
+    o_msg_color = [[NSAttributedString alloc] initWithString: [NSString stringWithFormat: @"%s\n", str] attributes: o_attr];
     [o_msg_arr addObject: [o_msg_color autorelease]];
 
     b_msg_arr_changed = YES;