Commit 553f1be2 authored by Jon Lech Johansen's avatar Jon Lech Johansen

* ./modules/gui/macosx/intf.[mh]: Fixed message panel memory leak. Textview

                                    is now updated on panel BecomeKey.
  * ./modules/gui/macosx/prefs.m: Decreased width of prefs panel.
parent 3bcc216c
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* intf.h: MacOS X interface plugin * intf.h: MacOS X interface plugin
***************************************************************************** *****************************************************************************
* Copyright (C) 2002 VideoLAN * Copyright (C) 2002 VideoLAN
* $Id: intf.h,v 1.17 2003/01/25 18:42:17 hartman Exp $ * $Id: intf.h,v 1.18 2003/01/27 00:08:31 jlj Exp $
* *
* Authors: Jon Lech Johansen <jon-vl@nanocrew.net> * Authors: Jon Lech Johansen <jon-vl@nanocrew.net>
* Christophe Massiot <massiot@via.ecp.fr> * Christophe Massiot <massiot@via.ecp.fr>
...@@ -110,6 +110,8 @@ struct intf_sys_t ...@@ -110,6 +110,8 @@ struct intf_sys_t
IBOutlet id o_messages; /* messages tv */ IBOutlet id o_messages; /* messages tv */
IBOutlet id o_msgs_panel; /* messages panel */ IBOutlet id o_msgs_panel; /* messages panel */
IBOutlet id o_msgs_btn_ok; /* messages btn */ IBOutlet id o_msgs_btn_ok; /* messages btn */
NSMutableArray * o_msg_arr; /* messages array */
NSLock * o_msg_lock; /* messages lock */
IBOutlet id o_error; /* error panel */ IBOutlet id o_error; /* error panel */
IBOutlet id o_err_msg; /* NSTextView */ IBOutlet id o_err_msg; /* NSTextView */
...@@ -218,6 +220,8 @@ struct intf_sys_t ...@@ -218,6 +220,8 @@ struct intf_sys_t
- (IBAction)openWebsite:(id)sender; - (IBAction)openWebsite:(id)sender;
- (IBAction)openLicense:(id)sender; - (IBAction)openLicense:(id)sender;
- (void)windowDidBecomeKey:(NSNotification *)o_notification;
@end @end
@interface VLCMain (Internal) @interface VLCMain (Internal)
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* intf.m: MacOS X interface plugin * intf.m: MacOS X interface plugin
***************************************************************************** *****************************************************************************
* Copyright (C) 2002-2003 VideoLAN * Copyright (C) 2002-2003 VideoLAN
* $Id: intf.m,v 1.35 2003/01/25 21:34:45 hartman Exp $ * $Id: intf.m,v 1.36 2003/01/27 00:08:31 jlj Exp $
* *
* Authors: Jon Lech Johansen <jon-vl@nanocrew.net> * Authors: Jon Lech Johansen <jon-vl@nanocrew.net>
* Christophe Massiot <massiot@via.ecp.fr> * Christophe Massiot <massiot@via.ecp.fr>
...@@ -187,10 +187,7 @@ static void Run( intf_thread_t *p_intf ) ...@@ -187,10 +187,7 @@ static void Run( intf_thread_t *p_intf )
- (void)awakeFromNib - (void)awakeFromNib
{ {
NSString * pTitle; [o_window setTitle: _NS("VLC - Controller")];
pTitle = _NS("VLC - Controller");
[o_window setTitle: pTitle];
[o_window setExcludedFromWindowsMenu: TRUE]; [o_window setExcludedFromWindowsMenu: TRUE];
/* button controls */ /* button controls */
...@@ -207,6 +204,7 @@ static void Run( intf_thread_t *p_intf ) ...@@ -207,6 +204,7 @@ static void Run( intf_thread_t *p_intf )
[o_timeslider setToolTip: _NS("Position")]; [o_timeslider setToolTip: _NS("Position")];
/* messages panel */ /* messages panel */
[o_msgs_panel setDelegate: self];
[o_msgs_panel setTitle: _NS("Messages")]; [o_msgs_panel setTitle: _NS("Messages")];
[o_msgs_panel setExcludedFromWindowsMenu: TRUE]; [o_msgs_panel setExcludedFromWindowsMenu: TRUE];
[o_msgs_btn_ok setTitle: _NS("Close")]; [o_msgs_btn_ok setTitle: _NS("Close")];
...@@ -295,6 +293,9 @@ static void Run( intf_thread_t *p_intf ) ...@@ -295,6 +293,9 @@ static void Run( intf_thread_t *p_intf )
f_slider_old = f_slider = 0.0; f_slider_old = f_slider = 0.0;
o_msg_lock = [[NSLock alloc] init];
o_msg_arr = [[NSMutableArray arrayWithCapacity: 200] retain];
[NSThread detachNewThreadSelector: @selector(manage) [NSThread detachNewThreadSelector: @selector(manage)
toTarget: self withObject: nil]; toTarget: self withObject: nil];
...@@ -433,35 +434,34 @@ static void Run( intf_thread_t *p_intf ) ...@@ -433,35 +434,34 @@ static void Run( intf_thread_t *p_intf )
if( p_intf->p_sys->p_sub->i_start != i_stop ) if( p_intf->p_sys->p_sub->i_start != i_stop )
{ {
#if 0
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];
NSColor *o_gray = [NSColor grayColor]; NSColor *o_gray = [NSColor grayColor];
unsigned int ui_length = [[o_messages string] length];
NSColor * pp_color[4] = { o_white, o_red, o_yellow, o_gray }; NSColor * pp_color[4] = { o_white, o_red, o_yellow, o_gray };
static const char * ppsz_type[4] = { ": ", " error: ", static const char * ppsz_type[4] = { ": ", " error: ",
" warning: ", " debug: " }; " warning: ", " debug: " };
[o_messages setEditable: YES];
[o_messages setSelectedRange: NSMakeRange( ui_length, 0 )];
[o_messages scrollRangeToVisible: NSMakeRange( ui_length, 0 )];
#endif
for( i_start = p_intf->p_sys->p_sub->i_start; for( i_start = p_intf->p_sys->p_sub->i_start;
i_start != i_stop; i_start != i_stop;
i_start = (i_start+1) % VLC_MSG_QSIZE ) i_start = (i_start+1) % VLC_MSG_QSIZE )
{ {
#if 0
NSString *o_msg; NSString *o_msg;
NSDictionary *o_attr; NSDictionary *o_attr;
NSAttributedString *o_msg_color; NSAttributedString *o_msg_color;
#endif
int i_type = p_intf->p_sys->p_sub->p_msg[i_start].i_type; int i_type = p_intf->p_sys->p_sub->p_msg[i_start].i_type;
#if 0 [o_msg_lock lock];
if( [o_msg_arr count] + 2 > 200 )
{
unsigned rid[] = { 0, 1 };
[o_msg_arr removeObjectsFromIndices: (unsigned *)&rid
numIndices: sizeof(rid)/sizeof(rid[0])];
}
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%s",
...@@ -469,18 +469,17 @@ static void Run( intf_thread_t *p_intf ) ...@@ -469,18 +469,17 @@ static void Run( intf_thread_t *p_intf )
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];
[o_messages insertText: o_msg_color]; [o_msg_arr addObject: [o_msg_color autorelease]];
o_attr = [NSDictionary dictionaryWithObject: pp_color[i_type] o_attr = [NSDictionary dictionaryWithObject: pp_color[i_type]
forKey: NSForegroundColorAttributeName]; forKey: NSForegroundColorAttributeName];
o_msg = [NSString stringWithCString: o_msg = [NSString stringWithFormat: @"%s\n",
p_intf->p_sys->p_sub->p_msg[i_start].psz_msg]; p_intf->p_sys->p_sub->p_msg[i_start].psz_msg];
o_msg_color = [[NSAttributedString alloc] o_msg_color = [[NSAttributedString alloc]
initWithString: o_msg attributes: o_attr]; initWithString: o_msg attributes: o_attr];
[o_messages insertText: o_msg_color]; [o_msg_arr addObject: [o_msg_color autorelease]];
[o_messages insertText: @"\n"]; [o_msg_lock unlock];
#endif
if ( i_type == 1 ) if ( i_type == 1 )
{ {
...@@ -500,10 +499,6 @@ static void Run( intf_thread_t *p_intf ) ...@@ -500,10 +499,6 @@ static void Run( intf_thread_t *p_intf )
} }
} }
#if 0
[o_messages setEditable: NO];
#endif
vlc_mutex_lock( p_intf->p_sys->p_sub->p_lock ); vlc_mutex_lock( p_intf->p_sys->p_sub->p_lock );
p_intf->p_sys->p_sub->i_start = i_start; p_intf->p_sys->p_sub->i_start = i_start;
vlc_mutex_unlock( p_intf->p_sys->p_sub->p_lock ); vlc_mutex_unlock( p_intf->p_sys->p_sub->p_lock );
...@@ -534,12 +529,6 @@ static void Run( intf_thread_t *p_intf ) ...@@ -534,12 +529,6 @@ static void Run( intf_thread_t *p_intf )
p_intf->p_sys->p_input = NULL; p_intf->p_sys->p_input = NULL;
} }
if( o_prefs != nil )
{
[o_prefs release];
o_prefs = nil;
}
/* /*
* Free playlists * Free playlists
*/ */
...@@ -564,6 +553,19 @@ static void Run( intf_thread_t *p_intf ) ...@@ -564,6 +553,19 @@ static void Run( intf_thread_t *p_intf )
vout_Destroy( p_vout ); vout_Destroy( p_vout );
} }
if( o_msg_arr != nil )
{
[o_msg_arr removeAllObjects];
[o_msg_arr release];
o_msg_arr = nil;
}
if( o_msg_lock != nil )
{
[o_msg_lock release];
o_msg_lock = nil;
}
if( o_prefs != nil ) if( o_prefs != nil )
{ {
[o_prefs release]; [o_prefs release];
...@@ -1173,44 +1175,63 @@ static void Run( intf_thread_t *p_intf ) ...@@ -1173,44 +1175,63 @@ static void Run( intf_thread_t *p_intf )
- (IBAction)closeError:(id)sender - (IBAction)closeError:(id)sender
{ {
/* Error panel */ /* Error panel */
[o_err_msg setEditable: YES]; [o_err_msg setString: @""];
[o_err_msg setSelectedRange:
NSMakeRange( 0, [[o_err_msg string] length] )];
[o_err_msg insertText: @""];
[o_err_msg setEditable: NO];
[o_error performClose: self]; [o_error performClose: self];
} }
- (IBAction)openReadMe:(id)sender - (IBAction)openReadMe:(id)sender
{ {
NSString *readmeFile = [[NSBundle mainBundle] pathForResource:@"README.MacOSX" NSString * o_path = [[NSBundle mainBundle]
ofType:@"rtf"]; pathForResource: @"README.MacOSX" ofType: @"rtf"];
[[NSWorkspace sharedWorkspace] openFile: readmeFile [[NSWorkspace sharedWorkspace] openFile: o_path
withApplication:@"TextEdit"]; withApplication: @"TextEdit"];
} }
- (IBAction)reportABug:(id)sender - (IBAction)reportABug:(id)sender
{ {
NSURL *bugURL = [NSURL URLWithString:@"http://www.videolan.org/support/bug-reporting.html"]; NSURL * o_url = [NSURL URLWithString:
@"http://www.videolan.org/support/bug-reporting.html"];
[[NSWorkspace sharedWorkspace] openURL: bugURL]; [[NSWorkspace sharedWorkspace] openURL: o_url];
} }
- (IBAction)openWebsite:(id)sender - (IBAction)openWebsite:(id)sender
{ {
NSURL *websiteURL = [NSURL URLWithString:@"http://www.videolan.org/"]; NSURL * o_url = [NSURL URLWithString: @"http://www.videolan.org"];
[[NSWorkspace sharedWorkspace] openURL: websiteURL]; [[NSWorkspace sharedWorkspace] openURL: o_url];
} }
- (IBAction)openLicense:(id)sender - (IBAction)openLicense:(id)sender
{ {
NSString *licenseFile = [[NSBundle mainBundle] pathForResource:@"COPYING" NSString * o_path = [[NSBundle mainBundle]
ofType:nil]; pathForResource: @"COPYING" ofType: nil];
[[NSWorkspace sharedWorkspace] openFile: licenseFile [[NSWorkspace sharedWorkspace] openFile: o_path
withApplication:@"TextEdit"]; withApplication: @"TextEdit"];
}
- (void)windowDidBecomeKey:(NSNotification *)o_notification
{
if( [o_notification object] == o_msgs_panel )
{
id o_msg;
NSEnumerator * o_enum;
[o_messages setString: @""];
[o_msg_lock lock];
o_enum = [o_msg_arr objectEnumerator];
while( ( o_msg = [o_enum nextObject] ) != nil )
{
[o_messages insertText: o_msg];
}
[o_msg_lock unlock];
}
} }
@end @end
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* prefs.m: MacOS X plugin for vlc * prefs.m: MacOS X plugin for vlc
***************************************************************************** *****************************************************************************
* Copyright (C) 2002 VideoLAN * Copyright (C) 2002 VideoLAN
* $Id: prefs.m,v 1.7 2003/01/16 23:00:47 massiot Exp $ * $Id: prefs.m,v 1.8 2003/01/27 00:08:31 jlj Exp $
* *
* Authors: Jon Lech Johansen <jon-vl@nanocrew.net> * Authors: Jon Lech Johansen <jon-vl@nanocrew.net>
* *
...@@ -186,7 +186,7 @@ ...@@ -186,7 +186,7 @@
/* We found it, now we can start building its configuration interface */ /* We found it, now we can start building its configuration interface */
s_panel_rc = NSMakeRect( 0, 0, 550, 450 ); s_panel_rc = NSMakeRect( 0, 0, 450, 450 );
o_panel = [[NSPanel alloc] initWithContentRect: s_panel_rc o_panel = [[NSPanel alloc] initWithContentRect: s_panel_rc
styleMask: NSTitledWindowMask styleMask: NSTitledWindowMask
backing: NSBackingStoreBuffered backing: NSBackingStoreBuffered
......
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