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