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 @@
* intf.h: MacOS X interface plugin
*****************************************************************************
* 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>
* Christophe Massiot <massiot@via.ecp.fr>
......@@ -110,6 +110,8 @@ struct intf_sys_t
IBOutlet id o_messages; /* messages tv */
IBOutlet id o_msgs_panel; /* messages panel */
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_err_msg; /* NSTextView */
......@@ -218,6 +220,8 @@ struct intf_sys_t
- (IBAction)openWebsite:(id)sender;
- (IBAction)openLicense:(id)sender;
- (void)windowDidBecomeKey:(NSNotification *)o_notification;
@end
@interface VLCMain (Internal)
......
......@@ -2,7 +2,7 @@
* intf.m: MacOS X interface plugin
*****************************************************************************
* 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>
* Christophe Massiot <massiot@via.ecp.fr>
......@@ -187,10 +187,7 @@ static void Run( intf_thread_t *p_intf )
- (void)awakeFromNib
{
NSString * pTitle;
pTitle = _NS("VLC - Controller");
[o_window setTitle: pTitle];
[o_window setTitle: _NS("VLC - Controller")];
[o_window setExcludedFromWindowsMenu: TRUE];
/* button controls */
......@@ -207,6 +204,7 @@ static void Run( intf_thread_t *p_intf )
[o_timeslider setToolTip: _NS("Position")];
/* messages panel */
[o_msgs_panel setDelegate: self];
[o_msgs_panel setTitle: _NS("Messages")];
[o_msgs_panel setExcludedFromWindowsMenu: TRUE];
[o_msgs_btn_ok setTitle: _NS("Close")];
......@@ -295,6 +293,9 @@ static void Run( intf_thread_t *p_intf )
f_slider_old = f_slider = 0.0;
o_msg_lock = [[NSLock alloc] init];
o_msg_arr = [[NSMutableArray arrayWithCapacity: 200] retain];
[NSThread detachNewThreadSelector: @selector(manage)
toTarget: self withObject: nil];
......@@ -433,35 +434,34 @@ static void Run( intf_thread_t *p_intf )
if( p_intf->p_sys->p_sub->i_start != i_stop )
{
#if 0
NSColor *o_white = [NSColor whiteColor];
NSColor *o_red = [NSColor redColor];
NSColor *o_yellow = [NSColor yellowColor];
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 };
static const char * ppsz_type[4] = { ": ", " error: ",
" 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;
i_start != i_stop;
i_start = (i_start+1) % VLC_MSG_QSIZE )
{
#if 0
NSString *o_msg;
NSDictionary *o_attr;
NSAttributedString *o_msg_color;
#endif
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
forKey: NSForegroundColorAttributeName];
o_msg = [NSString stringWithFormat: @"%s%s",
......@@ -469,18 +469,17 @@ static void Run( intf_thread_t *p_intf )
ppsz_type[i_type]];
o_msg_color = [[NSAttributedString alloc]
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]
forKey: NSForegroundColorAttributeName];
o_msg = [NSString stringWithCString:
o_msg = [NSString stringWithFormat: @"%s\n",
p_intf->p_sys->p_sub->p_msg[i_start].psz_msg];
o_msg_color = [[NSAttributedString alloc]
initWithString: o_msg attributes: o_attr];
[o_messages insertText: o_msg_color];
[o_msg_arr addObject: [o_msg_color autorelease]];
[o_messages insertText: @"\n"];
#endif
[o_msg_lock unlock];
if ( i_type == 1 )
{
......@@ -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 );
p_intf->p_sys->p_sub->i_start = i_start;
vlc_mutex_unlock( p_intf->p_sys->p_sub->p_lock );
......@@ -534,12 +529,6 @@ static void Run( intf_thread_t *p_intf )
p_intf->p_sys->p_input = NULL;
}
if( o_prefs != nil )
{
[o_prefs release];
o_prefs = nil;
}
/*
* Free playlists
*/
......@@ -564,6 +553,19 @@ static void Run( intf_thread_t *p_intf )
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 )
{
[o_prefs release];
......@@ -1173,44 +1175,63 @@ static void Run( intf_thread_t *p_intf )
- (IBAction)closeError:(id)sender
{
/* Error panel */
[o_err_msg setEditable: YES];
[o_err_msg setSelectedRange:
NSMakeRange( 0, [[o_err_msg string] length] )];
[o_err_msg insertText: @""];
[o_err_msg setEditable: NO];
[o_err_msg setString: @""];
[o_error performClose: self];
}
- (IBAction)openReadMe:(id)sender
{
NSString *readmeFile = [[NSBundle mainBundle] pathForResource:@"README.MacOSX"
ofType:@"rtf"];
NSString * o_path = [[NSBundle mainBundle]
pathForResource: @"README.MacOSX" ofType: @"rtf"];
[[NSWorkspace sharedWorkspace] openFile: readmeFile
withApplication:@"TextEdit"];
[[NSWorkspace sharedWorkspace] openFile: o_path
withApplication: @"TextEdit"];
}
- (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
{
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
{
NSString *licenseFile = [[NSBundle mainBundle] pathForResource:@"COPYING"
ofType:nil];
NSString * o_path = [[NSBundle mainBundle]
pathForResource: @"COPYING" ofType: nil];
[[NSWorkspace sharedWorkspace] openFile: licenseFile
withApplication:@"TextEdit"];
[[NSWorkspace sharedWorkspace] openFile: o_path
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
......
......@@ -2,7 +2,7 @@
* prefs.m: MacOS X plugin for vlc
*****************************************************************************
* 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>
*
......@@ -186,7 +186,7 @@
/* 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
styleMask: NSTitledWindowMask
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