#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"
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;
return VLC_EGENERIC;
}
- msg_Dbg( p_wnd, "looking for video view" );
int i_x = cfg->x;
int i_y = cfg->y;
unsigned i_width = cfg->width;
return VLC_EGENERIC;
}
+ [[VLCMain sharedInstance] setNativeVideoSize:NSMakeSize( cfg->width, cfg->height )];
[[VLCMain sharedInstance] setActiveVideoPlayback: YES];
p_wnd->control = WindowControl;
p_wnd->sys = (vout_window_sys_t *)VLCIntf;
if( i_query == VOUT_WINDOW_SET_STATE )
NSLog( @"WindowControl:VOUT_WINDOW_SET_STATE" );
else if( i_query == VOUT_WINDOW_SET_SIZE )
+ {
NSLog( @"WindowControl:VOUT_WINDOW_SET_SIZE" );
+ unsigned int i_width = va_arg( args, unsigned int );
+ unsigned int i_height = va_arg( args, unsigned int );
+ [[VLCMain sharedInstance] setNativeVideoSize:NSMakeSize( i_width, i_height )];
+ }
else if( i_query == VOUT_WINDOW_SET_FULLSCREEN )
NSLog( @"WindowControl:VOUT_WINDOW_SET_FULLSCREEN" );
else
* 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:
- //NSLog( @"input stopped by user" );
+ [[VLCMain sharedInstance] updateName];
+ [[VLCMain sharedInstance] updatePlaybackPosition];
break;
default:
vlc_value_t oldval, vlc_value_t new_val, void *param )
{
NSAutoreleasePool * o_pool = [[NSAutoreleasePool alloc] init];
- [[VLCMain sharedInstance] updateVolume];
+ [[VLCMain sharedInstance] performSelectorOnMainThread:@selector(updateVolume) withObject:nil waitUntilDone:NO];
[o_pool release];
return VLC_SUCCESS;
intf_thread_t * p_intf = VLCIntf;
if( p_intf && p_intf->p_sys )
{
- NSAutoreleasePool *o_pool = [[NSAutoreleasePool alloc] init];
- if( [[[VLCCoreInteraction sharedInstance] voutView] isFullscreen] && config_GetInt( VLCIntf, "macosx-fspanel" ) )
- [[[[VLCMain sharedInstance] controls] fspanel] fadeIn];
- else
- [[VLCMainWindow sharedInstance] makeKeyAndOrderFront: nil];
- [o_pool release];
+// [[[VLCMain sharedInstance] fspanel] makeKeyAndOrderFront: nil];
}
return VLC_SUCCESS;
}
vlc_value_t old_val, vlc_value_t new_val, void *param )
{
intf_thread_t * p_intf = VLCIntf;
- if( p_intf && p_intf->p_sys )
- NSLog( @"we should update fullscreen state" ); //FIXME
+ if (p_intf)
+ {
+ NSAutoreleasePool *o_pool = [[NSAutoreleasePool alloc] init];
+ [[VLCMain sharedInstance] fullscreenChanged];
+ [o_pool release];
+ }
return VLC_SUCCESS;
}
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];
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;
}
[self _removeOldPreferences];
+ [o_mainwindow updateWindow];
+ [o_mainwindow updateTimeSlider];
+ [o_mainwindow updateVolumeSlider];
[o_mainwindow makeKeyAndOrderFront: self];
/* Handle sleep notification */
[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];
[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 -
}
}
module_config_free (p_config);
- module_release (p_main);
o_usedHotkeys = [[NSArray alloc] initWithArray: o_usedHotkeys copyItems: YES];
}
#pragma mark -
#pragma mark Interface updaters
+- (void)fullscreenChanged
+{
+ 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
+ {
+ 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
{
input_thread_t * p_input;
[o_mainmenu setRateControlsEnabled: YES];
vlc_object_release( p_input );
}
- else[o_mainmenu setRateControlsEnabled: NO];
+ else
+ [o_mainmenu setRateControlsEnabled: NO];
[o_playlist updateRowSelection];
[o_mainwindow updateWindow];
+ [self updateMainMenu];
+}
+
+- (void)updateMainMenu
+{
[o_mainmenu setupMenus];
[o_mainmenu updatePlaybackRate];
}
[o_mainwindow updateWindow];
}
+- (void)showFullscreenController
+{
+ [o_mainwindow showFullscreenController];
+}
+
- (void)updateDelays
{
[[VLCTrackSynchronization sharedInstance] performSelectorOnMainThread: @selector(updateValues) withObject: nil waitUntilDone:NO];
- (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
{
[self playbackStatusUpdated];
[o_playlist playlistUpdated];
+ [o_mainwindow updateWindow];
+ [o_mainwindow updateName];
+}
+
+- (void)updateRecordState: (BOOL)b_value
+{
+ [o_mainmenu updateRecordState:b_value];
}
- (void)updateInfoandMetaPanel
int state = var_GetInteger( p_input, "state" );
if( state == PLAYING_S )
{
- [[[self controls] fspanel] setPause];
[[self mainMenu] setPause];
[o_mainwindow setPause];
}
{
if (state == END_S)
[o_mainmenu setSubmenusEnabled: FALSE];
- [[[self controls] fspanel] setPlay];
[[self mainMenu] setPlay];
[o_mainwindow setPlay];
}
return videoView;
}
+- (void)setNativeVideoSize:(NSSize)size
+{
+ [o_mainwindow setNativeVideoSize:size];
+}
+
- (id)embeddedList
{
if( o_embedded_list )
}
}
-- (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;
- (IBAction)saveDebugLog:(id)sender
{
- NSOpenPanel * saveFolderPanel = [[NSSavePanel alloc] init];
+ NSSavePanel * saveFolderPanel = [[NSSavePanel alloc] init];
- [saveFolderPanel setCanChooseDirectories: NO];
- [saveFolderPanel setCanChooseFiles: YES];
[saveFolderPanel setCanSelectHiddenExtension: NO];
[saveFolderPanel setCanCreateDirectories: YES];
[saveFolderPanel setAllowedFileTypes: [NSArray arrayWithObject:@"rtfd"]];