#include <vlc_vout_window.h>
#include <unistd.h> /* execl() */
+#import "CompatibilityFixes.h"
#import "intf.h"
#import "MainMenu.h"
-#import "MainWindow.h"
#import "vout.h"
#import "prefs.h"
#import "playlist.h"
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 * );
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;
* 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,
break;
case INPUT_EVENT_TITLE:
case INPUT_EVENT_CHAPTER:
+ [[VLCMain sharedInstance] updateMainMenu];
break;
case INPUT_EVENT_CACHE:
[[VLCMain sharedInstance] updateMainWindow];
case INPUT_EVENT_ES:
break;
case INPUT_EVENT_TELETEXT:
- NSLog( @"teletext" );
break;
case INPUT_EVENT_AOUT:
break;
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;
break;
case INPUT_EVENT_ABORT:
+ [[VLCMain sharedInstance] updateName];
+ [[VLCMain sharedInstance] updatePlaybackPosition];
break;
default:
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];
[o_remote setDelegate: _o_sharedMainInstance];
/* yeah, we are done */
+ b_nativeFullscreenMode = config_GetInt( p_intf, "macosx-nativefullscreenmode" );
nib_main_loaded = TRUE;
}
[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];
#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
[o_playlist updateRowSelection];
[o_mainwindow updateWindow];
- [o_mainwindow updateName];
+ [self updateMainMenu];
+}
+
+- (void)updateMainMenu
+{
[o_mainmenu setupMenus];
[o_mainmenu updatePlaybackRate];
}
[self playbackStatusUpdated];
[o_playlist playlistUpdated];
[o_mainwindow updateWindow];
+ [o_mainwindow updateName];
+}
+
+- (void)updateRecordState: (BOOL)b_value
+{
+ [o_mainmenu updateRecordState:b_value];
}
- (void)updateInfoandMetaPanel
}
}
-- (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];
NSDictionary *o_attr;
NSAttributedString *o_msg_color;
- int i_type = item->i_type;
-
[o_msg_lock lock];
if( [o_msg_arr count] + 2 > 600 )
[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;