Commit 6f31dda7 authored by David Fuhrmann's avatar David Fuhrmann

macosx: messages panel: create outlets in the new style

parent 80f24bf7
......@@ -7,10 +7,10 @@
<objects>
<customObject id="-2" userLabel="File's Owner" customClass="VLCDebugMessageVisualizer">
<connections>
<outlet property="_clearButton" destination="RCj-GY-IGn" id="chJ-sn-o6c"/>
<outlet property="_msgs_refresh_btn" destination="4" id="17"/>
<outlet property="_msgs_save_btn" destination="3" id="19"/>
<outlet property="_msgs_table" destination="6" id="20"/>
<outlet property="clearButton" destination="RCj-GY-IGn" id="bi1-74-dyp"/>
<outlet property="messageTable" destination="6" id="BzW-Qh-PMq"/>
<outlet property="refreshButton" destination="4" id="bdj-c0-rau"/>
<outlet property="saveButton" destination="3" id="WDG-KN-R01"/>
<outlet property="window" destination="1" id="24"/>
</connections>
</customObject>
......
......@@ -26,12 +26,11 @@
#import <Cocoa/Cocoa.h>
@interface VLCDebugMessageVisualizer : NSWindowController
{
IBOutlet NSButton *_clearButton;
IBOutlet NSButton * _msgs_save_btn;
IBOutlet NSButton * _msgs_refresh_btn;
IBOutlet id _msgs_table;
}
@property (assign) IBOutlet NSTableView *messageTable;
@property (assign) IBOutlet NSButton *saveButton;
@property (assign) IBOutlet NSButton *clearButton;
@property (assign) IBOutlet NSButton *refreshButton;
- (void)showWindow:(id)sender;
......
......@@ -37,7 +37,7 @@ static void MsgCallback(void *data, int type, const vlc_log_t *item, const char
@interface VLCDebugMessageVisualizer () <NSWindowDelegate>
{
NSMutableArray * _msg_arr;
NSMutableArray * _messageArray;
}
- (void)appendMessage:(NSMutableAttributedString *) message;
......@@ -91,7 +91,7 @@ static void MsgCallback(void *data, int type, const vlc_log_t *item, const char
{
self = [super initWithWindowNibName:@"DebugMessageVisualizer"];
if (self) {
_msg_arr = [NSMutableArray arrayWithCapacity:600];
_messageArray = [NSMutableArray arrayWithCapacity:600];
}
return self;
}
......@@ -106,9 +106,9 @@ static void MsgCallback(void *data, int type, const vlc_log_t *item, const char
[self.window setExcludedFromWindowsMenu: YES];
[self.window setDelegate: self];
[self.window setTitle: _NS("Messages")];
[_msgs_save_btn setTitle: _NS("Save this Log...")];
[_saveButton setTitle: _NS("Save this Log...")];
[_clearButton setTitle:_NS("Clear")];
[_msgs_refresh_btn setImage: [NSImage imageNamed: NSImageNameRefreshTemplate]];
[_refreshButton setImage: [NSImage imageNamed: NSImageNameRefreshTemplate]];
}
#pragma mark - UI interaction
......@@ -128,8 +128,8 @@ static void MsgCallback(void *data, int type, const vlc_log_t *item, const char
- (void)windowDidBecomeKey:(NSNotification *)notification
{
[_msgs_table reloadData];
[_msgs_table scrollRowToVisible: [_msg_arr count] - 1];
[_messageTable reloadData];
[_messageTable scrollRowToVisible: [_messageArray count] - 1];
}
- (void)windowWillClose:(NSNotification *)notification
......@@ -148,10 +148,10 @@ static void MsgCallback(void *data, int type, const vlc_log_t *item, const char
[saveFolderPanel setNameFieldStringValue:[NSString stringWithFormat: _NS("VLC Debug Log (%s).rtf"), VERSION_MESSAGE]];
[saveFolderPanel beginSheetModalForWindow: self.window completionHandler:^(NSInteger returnCode) {
if (returnCode == NSOKButton) {
NSUInteger count = [_msg_arr count];
NSUInteger count = [_messageArray count];
NSMutableAttributedString * string = [[NSMutableAttributedString alloc] init];
for (NSUInteger i = 0; i < count; i++)
[string appendAttributedString: [_msg_arr objectAtIndex:i]];
[string appendAttributedString: [_messageArray objectAtIndex:i]];
NSData *data = [string RTFFromRange:NSMakeRange(0, [string length])
documentAttributes:[NSDictionary dictionaryWithObject: NSRTFTextDocumentType forKey: NSDocumentTypeDocumentAttribute]];
......@@ -164,35 +164,35 @@ static void MsgCallback(void *data, int type, const vlc_log_t *item, const char
- (IBAction)clearLog:(id)sender
{
[_msg_arr removeAllObjects];
[_messageArray removeAllObjects];
// Reregister handler, to write new header to log
vlc_LogSet(VLCIntf->p_libvlc, NULL, NULL);
vlc_LogSet(VLCIntf->p_libvlc, MsgCallback, (__bridge void*)self);
[_msgs_table reloadData];
[_messageTable reloadData];
}
#pragma mark - data handling
- (NSInteger)numberOfRowsInTableView:(NSTableView *)aTableView
{
return [_msg_arr count];
return [_messageArray count];
}
- (id)tableView:(NSTableView *)aTableView objectValueForTableColumn:(NSTableColumn *)aTableColumn row:(NSInteger)rowIndex
{
return [_msg_arr objectAtIndex:rowIndex];
return [_messageArray objectAtIndex:rowIndex];
}
- (void)appendMessage:(NSMutableAttributedString *) message
{
if ([_msg_arr count] > 1000000) {
[_msg_arr removeObjectAtIndex: 0];
[_msg_arr removeObjectAtIndex: 1];
if ([_messageArray count] > 1000000) {
[_messageArray removeObjectAtIndex: 0];
[_messageArray removeObjectAtIndex: 1];
}
[_msg_arr addObject:message];
[_messageArray addObject:message];
}
@end
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