/*****************************************************************************
* intf.m: MacOS X interface module
*****************************************************************************
- * Copyright (C) 2002-2008 the VideoLAN team
+ * Copyright (C) 2002-2009 the VideoLAN team
* $Id$
*
* Authors: Jon Lech Johansen <jon-vl@nanocrew.net>
p_intf->p_sys->o_pool = [[NSAutoreleasePool alloc] init];
-// p_intf->p_sys->p_sub = msg_Subscribe( p_intf );
+ /* subscribe to LibVLCCore's messages */
+ p_intf->p_sys->p_sub = msg_Subscribe( p_intf->p_libvlc, MsgCallback, NULL );
p_intf->pf_run = Run;
p_intf->b_should_run_on_first_thread = true;
{
intf_thread_t *p_intf = (intf_thread_t*) p_this;
-// msg_Unsubscribe( p_intf, p_intf->p_sys->p_sub );
-
[p_intf->p_sys->o_pool release];
free( p_intf->p_sys );
}
+static void MsgCallback( msg_cb_data_t *data, msg_item_t *item, unsigned int i )
+{
+ int canc = vlc_savecancel();
+ NSAutoreleasePool * o_pool = [[NSAutoreleasePool alloc] init];
+
+ NSDictionary *o_dict = [NSDictionary dictionaryWithObjects:
+ [NSArray arrayWithObjects:
+ [NSString stringWithUTF8String: item->psz_module],
+ [NSString stringWithUTF8String: item->psz_msg],
+ [NSNumber numberWithInt: item->i_type], nil]
+ forKeys:
+ [NSArray arrayWithObjects: @"Module", @"Message", @"Type", nil]];
+
+ [[NSNotificationCenter defaultCenter] postNotificationName: @"VLCCoreMessageReceived"
+ object: nil
+ userInfo: o_dict];
+
+ [o_pool release];
+ vlc_restorecancel( canc );
+}
+
/*****************************************************************************
* Run: main loop
*****************************************************************************/
* see applicationWillTerminate: */
if(setjmp(jmpbuffer) == 0)
[NSApp run];
-
+
[o_pool release];
}
else
_o_sharedMainInstance = [super init];
+ o_msg_lock = [[NSLock alloc] init];
+ o_msg_arr = [[NSMutableArray arrayWithCapacity: 200] 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_about = [[VLAboutBox alloc] init];
o_prefs = nil;
o_open = [[VLCOpen alloc] init];
var_Create( p_intf, "interaction", VLC_VAR_ADDRESS );
var_AddCallback( p_intf, "interaction", InteractCallback, self );
- p_intf->b_interaction = true;
+ interaction_Register( p_intf );
/* update the playmode stuff */
p_intf->p_sys->b_playmode_update = true;
- (void)applicationWillFinishLaunching:(NSNotification *)o_notification
{
- o_msg_lock = [[NSLock alloc] init];
- o_msg_arr = [[NSMutableArray arrayWithCapacity: 200] retain];
-
/* FIXME: don't poll */
interfaceTimer = [[NSTimer scheduledTimerWithTimeInterval: 0.5
target: self selector: @selector(manageIntf:)
[o_mi_quit setTitle: _NS("Quit VLC")];
[o_mu_file setTitle: _ANS("1:File")];
- [o_mi_open_generic setTitle: _NS("Open File...")];
- [o_mi_open_file setTitle: _NS("Quick Open File...")];
+ [o_mi_open_generic setTitle: _NS("Advanced Open File...")];
+ [o_mi_open_file setTitle: _NS("Open File...")];
[o_mi_open_disc setTitle: _NS("Open Disc...")];
[o_mi_open_net setTitle: _NS("Open Network...")];
[o_mi_open_capture setTitle: _NS("Open Capture Device...")];
[o_extended savePrefs];
}
- p_intf->b_interaction = false;
+ interaction_Unregister( p_intf );
var_DelCallback( p_intf, "interaction", InteractCallback, self );
/* remove global observer watching for vout device changes correctly */
[o_img_pause release];
[o_img_play release];
+ /* unsubscribe from libvlc's debug messages */
+ msg_Unsubscribe( p_intf->p_sys->p_sub );
+
[o_msg_arr removeAllObjects];
[o_msg_arr release];
vlc_object_kill( p_playlist );
pl_Release( p_intf );
- vlc_object_kill( p_intf->p_libvlc );
+ libvlc_Quit( p_intf->p_libvlc );
[self setIntf:nil];
return nil;
}
+- (BOOL)isPlaylistCollapsed
+{
+ return ![o_btn_playlist state];
+}
+
- (id)getInfo
{
if( o_info )
id self = manage_cleanup_stack->self;
playlist_t * p_playlist = manage_cleanup_stack->p_playlist;
- var_AddCallback( p_playlist, "playlist-current", PlaylistChanged, self );
+ var_AddCallback( p_playlist, "item-current", PlaylistChanged, self );
var_AddCallback( p_playlist, "intf-change", PlaylistChanged, self );
var_AddCallback( p_playlist, "item-change", PlaylistChanged, self );
- var_AddCallback( p_playlist, "item-append", PlaylistChanged, self );
- var_AddCallback( p_playlist, "item-deleted", PlaylistChanged, self );
+ var_AddCallback( p_playlist, "playlist-item-append", PlaylistChanged, self );
+ var_AddCallback( p_playlist, "playlist-item-deleted", PlaylistChanged, self );
pl_Release( p_intf );
p_playlist = pl_Hold( p_intf );
- var_AddCallback( p_playlist, "playlist-current", PlaylistChanged, self );
+ var_AddCallback( p_playlist, "item-current", PlaylistChanged, self );
var_AddCallback( p_playlist, "intf-change", PlaylistChanged, self );
var_AddCallback( p_playlist, "item-change", PlaylistChanged, self );
- var_AddCallback( p_playlist, "item-append", PlaylistChanged, self );
- var_AddCallback( p_playlist, "item-deleted", PlaylistChanged, self );
+ var_AddCallback( p_playlist, "playlist-item-append", PlaylistChanged, self );
+ var_AddCallback( p_playlist, "playlist-item-deleted", PlaylistChanged, self );
struct manage_cleanup_stack stack = { p_intf, &p_input, p_playlist, self };
pthread_cleanup_push(manage_cleanup, &stack);
b_buffering = YES;
}
- /* update our info-panel to reflect the new item */
- [[[VLCMain sharedInstance] getInfo]
- updatePanelWithItem:
- playlist_CurrentPlayingItem( p_playlist )->p_input];
+ /* update our info-panel to reflect the new item, if we don't show
+ * the playlist or the selection is empty */
+ if( [self isPlaylistCollapsed] == YES )
+ [[self getInfo] updatePanelWithItem: playlist_CurrentPlayingItem( p_playlist )->p_input];
/* seekable streams */
b_seekable = var_GetBool( p_input, "can-seek" );
/* check whether slow/fast motion is possible */
- b_control = p_input->b_can_pace_control;
+ b_control = var_GetBool( p_input, "can-rate" );
/* chapters & titles */
//b_chapters = p_input->stream.i_area_nb > 1;
}
end:
- [self updateMessageArray];
+ [self updateMessageDisplay];
if( ((i_end_scroll != -1) && (mdate() > i_end_scroll)) || !p_input )
[self resetScrollField];
- (IBAction)crashReporterAction:(id)sender
{
if( sender == o_crashrep_send_btn )
- [self sendCrashLog:[NSString stringWithContentsOfFile: [self latestCrashLogPath]] withUserComment: [o_crashrep_fld string]];
+ [self sendCrashLog:[NSString stringWithContentsOfFile: [self latestCrashLogPath] encoding: NSUTF8StringEncoding error: NULL] withUserComment: [o_crashrep_fld string]];
[NSApp stopModal];
[o_crashrep_win orderOut: sender];
- (void)windowDidBecomeKey:(NSNotification *)o_notification
{
if( [o_notification object] == o_msgs_panel )
+ [self updateMessageDisplay];
+}
+
+- (void)updateMessageDisplay
+{
+ if( [o_msgs_panel isVisible] && b_msg_arr_changed )
{
id o_msg;
NSEnumerator * o_enum;
[o_messages insertText: o_msg];
}
+ b_msg_arr_changed = NO;
[o_msg_lock unlock];
}
}
-- (void)updateMessageArray
+- (void)libvlcMessageReceived: (NSNotification *)o_notification
{
- int i_start, i_stop;
-#if 0
- vlc_mutex_lock( p_intf->p_sys->p_sub->p_lock );
- i_stop = *p_intf->p_sys->p_sub->pi_stop;
- vlc_mutex_unlock( p_intf->p_sys->p_sub->p_lock );
+ NSColor *o_white = [NSColor whiteColor];
+ NSColor *o_red = [NSColor redColor];
+ NSColor *o_yellow = [NSColor yellowColor];
+ NSColor *o_gray = [NSColor grayColor];
- if( p_intf->p_sys->p_sub->i_start != i_stop )
- {
- NSColor *o_white = [NSColor whiteColor];
- NSColor *o_red = [NSColor redColor];
- NSColor *o_yellow = [NSColor yellowColor];
- NSColor *o_gray = [NSColor grayColor];
+ NSColor * pp_color[4] = { o_white, o_red, o_yellow, o_gray };
+ static const char * ppsz_type[4] = { ": ", " error: ",
+ " warning: ", " debug: " };
- NSColor * pp_color[4] = { o_white, o_red, o_yellow, o_gray };
- static const char * ppsz_type[4] = { ": ", " error: ",
- " warning: ", " debug: " };
+ NSString *o_msg;
+ NSDictionary *o_attr;
+ NSAttributedString *o_msg_color;
- for( i_start = p_intf->p_sys->p_sub->i_start;
- i_start != i_stop;
- i_start = (i_start+1) % VLC_MSG_QSIZE )
- {
- NSString *o_msg;
- NSDictionary *o_attr;
- NSAttributedString *o_msg_color;
+ int i_type = [[[o_notification userInfo] objectForKey: @"Type"] intValue];
- int i_type = p_intf->p_sys->p_sub->p_msg[i_start].i_type;
+ [o_msg_lock lock];
- [o_msg_lock lock];
+ if( [o_msg_arr count] + 2 > 400 )
+ {
+ unsigned rid[] = { 0, 1 };
+ [o_msg_arr removeObjectsFromIndices: (unsigned *)&rid
+ numIndices: sizeof(rid)/sizeof(rid[0])];
+ }
- if( [o_msg_arr count] + 2 > 400 )
- {
- unsigned rid[] = { 0, 1 };
- [o_msg_arr removeObjectsFromIndices: (unsigned *)&rid
- numIndices: sizeof(rid)/sizeof(rid[0])];
- }
+ o_attr = [NSDictionary dictionaryWithObject: o_gray
+ forKey: NSForegroundColorAttributeName];
+ o_msg = [NSString stringWithFormat: @"%@%s",
+ [[o_notification userInfo] objectForKey: @"Module"],
+ ppsz_type[i_type]];
+ o_msg_color = [[NSAttributedString alloc]
+ initWithString: o_msg attributes: o_attr];
+ [o_msg_arr addObject: [o_msg_color autorelease]];
- o_attr = [NSDictionary dictionaryWithObject: o_gray
- forKey: NSForegroundColorAttributeName];
- o_msg = [NSString stringWithFormat: @"%s%s",
- p_intf->p_sys->p_sub->p_msg[i_start].psz_module,
- ppsz_type[i_type]];
- o_msg_color = [[NSAttributedString alloc]
- initWithString: o_msg attributes: o_attr];
- [o_msg_arr addObject: [o_msg_color autorelease]];
-
- o_attr = [NSDictionary dictionaryWithObject: pp_color[i_type]
- forKey: NSForegroundColorAttributeName];
- o_msg = [[NSString stringWithUTF8String: p_intf->p_sys->p_sub->p_msg[i_start].psz_msg] stringByAppendingString: @"\n"];
- o_msg_color = [[NSAttributedString alloc]
- initWithString: o_msg attributes: o_attr];
- [o_msg_arr addObject: [o_msg_color autorelease]];
-
- [o_msg_lock unlock];
- }
+ o_attr = [NSDictionary dictionaryWithObject: pp_color[i_type]
+ forKey: NSForegroundColorAttributeName];
+ o_msg = [[[o_notification userInfo] objectForKey: @"Message"] stringByAppendingString: @"\n"];
+ o_msg_color = [[NSAttributedString alloc]
+ initWithString: o_msg attributes: o_attr];
+ [o_msg_arr addObject: [o_msg_color autorelease]];
- vlc_mutex_lock( p_intf->p_sys->p_sub->p_lock );
- p_intf->p_sys->p_sub->i_start = i_start;
- vlc_mutex_unlock( p_intf->p_sys->p_sub->p_lock );
- }
-#endif
+ b_msg_arr_changed = YES;
+ [o_msg_lock unlock];
}
+
#pragma mark -
#pragma mark Playlist toggling
- (void)updateTogglePlaylistState
{
if( [o_window contentRectForFrameRect:[o_window frame]].size.height <= 169. )
- {
[o_btn_playlist setState: NO];
- }
else
- {
[o_btn_playlist setState: YES];
- }
+
+ [[self getPlaylist] outlineViewSelectionDidChange: NULL];
}
- (NSSize)windowWillResize:(NSWindow *)sender toSize:(NSSize)proposedFrameSize