Commit c2c76c6c authored by Felix Paul Kühne's avatar Felix Paul Kühne

macosx: fixed the messages panel by updating the code to the current API

parent 0f7aa11e
...@@ -3,15 +3,15 @@ ...@@ -3,15 +3,15 @@
<plist version="1.0"> <plist version="1.0">
<dict> <dict>
<key>IBDocumentLocation</key> <key>IBDocumentLocation</key>
<string>69 71 356 240 0 0 1280 778 </string> <string>402 63 356 240 0 0 1280 778 </string>
<key>IBEditorPositions</key> <key>IBEditorPositions</key>
<dict> <dict>
<key>29</key> <key>29</key>
<string>68 316 438 44 0 0 1280 778 </string> <string>69 318 438 44 0 0 1280 778 </string>
<key>3568</key> <key>3568</key>
<string>476 535 328 85 0 0 1280 778 </string> <string>476 535 328 85 0 0 1280 778 </string>
<key>915</key> <key>915</key>
<string>69 316 187 331 0 0 1280 778 </string> <string>69 318 187 331 0 0 1280 778 </string>
</dict> </dict>
<key>IBFramework Version</key> <key>IBFramework Version</key>
<string>489.0</string> <string>489.0</string>
...@@ -22,10 +22,11 @@ ...@@ -22,10 +22,11 @@
<key>IBOpenObjects</key> <key>IBOpenObjects</key>
<array> <array>
<integer>3706</integer> <integer>3706</integer>
<integer>21</integer> <integer>29</integer>
<integer>915</integer> <integer>915</integer>
<integer>3568</integer> <integer>3568</integer>
<integer>29</integer> <integer>21</integer>
<integer>282</integer>
</array> </array>
<key>IBSystem Version</key> <key>IBSystem Version</key>
<string>9G55</string> <string>9G55</string>
......
...@@ -83,6 +83,8 @@ struct intf_sys_t ...@@ -83,6 +83,8 @@ struct intf_sys_t
msg_subscription_t * p_sub; msg_subscription_t * p_sub;
}; };
static void MsgCallback( msg_cb_data_t *, msg_item_t *, unsigned );
/***************************************************************************** /*****************************************************************************
* VLCMain interface * VLCMain interface
*****************************************************************************/ *****************************************************************************/
...@@ -152,10 +154,11 @@ struct intf_sys_t ...@@ -152,10 +154,11 @@ struct intf_sys_t
IBOutlet VLCControls * o_controls; /* VLCControls */ IBOutlet VLCControls * o_controls; /* VLCControls */
IBOutlet VLCPlaylist * o_playlist; /* VLCPlaylist */ IBOutlet VLCPlaylist * o_playlist; /* VLCPlaylist */
IBOutlet id o_messages; /* messages tv */ IBOutlet NSTextView * o_messages; /* messages tv */
IBOutlet id o_msgs_panel; /* messages panel */ IBOutlet NSWindow * o_msgs_panel; /* messages panel */
NSMutableArray * o_msg_arr; /* messages array */ NSMutableArray * o_msg_arr; /* messages array */
NSLock * o_msg_lock; /* messages lock */ NSLock * o_msg_lock; /* messages lock */
BOOL b_msg_arr_changed; /* did the array change? */
IBOutlet NSButton * o_msgs_btn_crashlog; /* messages open crashlog */ IBOutlet NSButton * o_msgs_btn_crashlog; /* messages open crashlog */
/* CrashReporter panel */ /* CrashReporter panel */
...@@ -368,7 +371,7 @@ struct intf_sys_t ...@@ -368,7 +371,7 @@ struct intf_sys_t
- (void)setScrollField:(NSString *)o_string stopAfter:(int )timeout; - (void)setScrollField:(NSString *)o_string stopAfter:(int )timeout;
- (void)resetScrollField; - (void)resetScrollField;
- (void)updateMessageArray; - (void)updateMessageDisplay;
- (void)playStatusUpdated:(int) i_status; - (void)playStatusUpdated:(int) i_status;
- (void)setSubmenusEnabled:(BOOL)b_enabled; - (void)setSubmenusEnabled:(BOOL)b_enabled;
- (void)manageVolumeSlider; - (void)manageVolumeSlider;
......
/***************************************************************************** /*****************************************************************************
* intf.m: MacOS X interface module * intf.m: MacOS X interface module
***************************************************************************** *****************************************************************************
* Copyright (C) 2002-2008 the VideoLAN team * Copyright (C) 2002-2009 the VideoLAN team
* $Id$ * $Id$
* *
* Authors: Jon Lech Johansen <jon-vl@nanocrew.net> * Authors: Jon Lech Johansen <jon-vl@nanocrew.net>
...@@ -91,7 +91,8 @@ int OpenIntf ( vlc_object_t *p_this ) ...@@ -91,7 +91,8 @@ int OpenIntf ( vlc_object_t *p_this )
p_intf->p_sys->o_pool = [[NSAutoreleasePool alloc] init]; 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->pf_run = Run;
p_intf->b_should_run_on_first_thread = true; p_intf->b_should_run_on_first_thread = true;
...@@ -105,13 +106,32 @@ void CloseIntf ( vlc_object_t *p_this ) ...@@ -105,13 +106,32 @@ void CloseIntf ( vlc_object_t *p_this )
{ {
intf_thread_t *p_intf = (intf_thread_t*) p_this; 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]; [p_intf->p_sys->o_pool release];
free( p_intf->p_sys ); 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 * Run: main loop
*****************************************************************************/ *****************************************************************************/
...@@ -245,6 +265,11 @@ static VLCMain *_o_sharedMainInstance = nil; ...@@ -245,6 +265,11 @@ static VLCMain *_o_sharedMainInstance = nil;
else else
_o_sharedMainInstance = [super init]; _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_about = [[VLAboutBox alloc] init];
o_prefs = nil; o_prefs = nil;
o_open = [[VLCOpen alloc] init]; o_open = [[VLCOpen alloc] init];
...@@ -434,9 +459,6 @@ static VLCMain *_o_sharedMainInstance = nil; ...@@ -434,9 +459,6 @@ static VLCMain *_o_sharedMainInstance = nil;
- (void)applicationWillFinishLaunching:(NSNotification *)o_notification - (void)applicationWillFinishLaunching:(NSNotification *)o_notification
{ {
o_msg_lock = [[NSLock alloc] init];
o_msg_arr = [[NSMutableArray arrayWithCapacity: 200] retain];
/* FIXME: don't poll */ /* FIXME: don't poll */
interfaceTimer = [[NSTimer scheduledTimerWithTimeInterval: 0.5 interfaceTimer = [[NSTimer scheduledTimerWithTimeInterval: 0.5
target: self selector: @selector(manageIntf:) target: self selector: @selector(manageIntf:)
...@@ -737,6 +759,9 @@ static VLCMain *_o_sharedMainInstance = nil; ...@@ -737,6 +759,9 @@ static VLCMain *_o_sharedMainInstance = nil;
[o_img_pause release]; [o_img_pause release];
[o_img_play 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 removeAllObjects];
[o_msg_arr release]; [o_msg_arr release];
...@@ -1674,7 +1699,7 @@ static void * manage_cleanup( void * args ) ...@@ -1674,7 +1699,7 @@ static void * manage_cleanup( void * args )
} }
end: end:
[self updateMessageArray]; [self updateMessageDisplay];
if( ((i_end_scroll != -1) && (mdate() > i_end_scroll)) || !p_input ) if( ((i_end_scroll != -1) && (mdate() > i_end_scroll)) || !p_input )
[self resetScrollField]; [self resetScrollField];
...@@ -2347,6 +2372,12 @@ end: ...@@ -2347,6 +2372,12 @@ end:
- (void)windowDidBecomeKey:(NSNotification *)o_notification - (void)windowDidBecomeKey:(NSNotification *)o_notification
{ {
if( [o_notification object] == o_msgs_panel ) if( [o_notification object] == o_msgs_panel )
[self updateMessageDisplay];
}
- (void)updateMessageDisplay
{
if( [o_msgs_panel isVisible] && b_msg_arr_changed )
{ {
id o_msg; id o_msg;
NSEnumerator * o_enum; NSEnumerator * o_enum;
...@@ -2362,20 +2393,13 @@ end: ...@@ -2362,20 +2393,13 @@ end:
[o_messages insertText: o_msg]; [o_messages insertText: o_msg];
} }
b_msg_arr_changed = NO;
[o_msg_lock unlock]; [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 );
if( p_intf->p_sys->p_sub->i_start != i_stop )
{
NSColor *o_white = [NSColor whiteColor]; NSColor *o_white = [NSColor whiteColor];
NSColor *o_red = [NSColor redColor]; NSColor *o_red = [NSColor redColor];
NSColor *o_yellow = [NSColor yellowColor]; NSColor *o_yellow = [NSColor yellowColor];
...@@ -2385,15 +2409,11 @@ end: ...@@ -2385,15 +2409,11 @@ end:
static const char * ppsz_type[4] = { ": ", " error: ", static const char * ppsz_type[4] = { ": ", " error: ",
" warning: ", " debug: " }; " warning: ", " debug: " };
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; NSString *o_msg;
NSDictionary *o_attr; NSDictionary *o_attr;
NSAttributedString *o_msg_color; NSAttributedString *o_msg_color;
int i_type = p_intf->p_sys->p_sub->p_msg[i_start].i_type; int i_type = [[[o_notification userInfo] objectForKey: @"Type"] intValue];
[o_msg_lock lock]; [o_msg_lock lock];
...@@ -2406,8 +2426,8 @@ end: ...@@ -2406,8 +2426,8 @@ end:
o_attr = [NSDictionary dictionaryWithObject: o_gray o_attr = [NSDictionary dictionaryWithObject: o_gray
forKey: NSForegroundColorAttributeName]; forKey: NSForegroundColorAttributeName];
o_msg = [NSString stringWithFormat: @"%s%s", o_msg = [NSString stringWithFormat: @"%@%s",
p_intf->p_sys->p_sub->p_msg[i_start].psz_module, [[o_notification userInfo] objectForKey: @"Module"],
ppsz_type[i_type]]; ppsz_type[i_type]];
o_msg_color = [[NSAttributedString alloc] o_msg_color = [[NSAttributedString alloc]
initWithString: o_msg attributes: o_attr]; initWithString: o_msg attributes: o_attr];
...@@ -2415,21 +2435,16 @@ end: ...@@ -2415,21 +2435,16 @@ end:
o_attr = [NSDictionary dictionaryWithObject: pp_color[i_type] o_attr = [NSDictionary dictionaryWithObject: pp_color[i_type]
forKey: NSForegroundColorAttributeName]; forKey: NSForegroundColorAttributeName];
o_msg = [[NSString stringWithUTF8String: p_intf->p_sys->p_sub->p_msg[i_start].psz_msg] stringByAppendingString: @"\n"]; o_msg = [[[o_notification userInfo] objectForKey: @"Message"] stringByAppendingString: @"\n"];
o_msg_color = [[NSAttributedString alloc] o_msg_color = [[NSAttributedString alloc]
initWithString: o_msg attributes: o_attr]; initWithString: o_msg attributes: o_attr];
[o_msg_arr addObject: [o_msg_color autorelease]]; [o_msg_arr addObject: [o_msg_color autorelease]];
b_msg_arr_changed = YES;
[o_msg_lock unlock]; [o_msg_lock unlock];
}
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
} }
#pragma mark - #pragma mark -
#pragma mark Playlist toggling #pragma mark Playlist toggling
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment