1 /*****************************************************************************
2 * HelpWindowController.m
3 *****************************************************************************
4 * Copyright (C) 2017 VLC authors and VideoLAN
7 * Authors: Derk-Jan Hartman <thedj@users.sourceforge.net>
8 * Felix Paul Kühne <fkuehne -at- videolan.org>
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
23 *****************************************************************************/
25 #import "VLCErrorWindowController.h"
27 #import "VLCStringUtility.h"
30 @interface VLCErrorWindowController()
32 NSMutableArray *_errors;
33 NSMutableArray *_icons;
38 @implementation VLCErrorWindowController
42 self = [super initWithWindowNibName:@"ErrorPanel"];
44 /* init data sources */
45 _errors = [[NSMutableArray alloc] init];
46 _icons = [[NSMutableArray alloc] init];
55 [self.window setTitle: _NS("Errors and Warnings")];
56 [self.cleanupButton setTitle: _NS("Clean up")];
58 if ([[NSApplication sharedApplication] userInterfaceLayoutDirection] == NSUserInterfaceLayoutDirectionRightToLeft) {
59 [self.errorTable moveColumn:0 toColumn:1];
63 - (void)addError:(NSString *)title withMsg:(NSString *)message;
65 /* format our string as desired */
66 NSMutableAttributedString * ourError;
67 ourError = [[NSMutableAttributedString alloc] initWithString:
68 [NSString stringWithFormat:@"%@\n%@", title, message]
70 [NSDictionary dictionaryWithObject: [NSFont systemFontOfSize:11] forKey: NSFontAttributeName]];
72 addAttribute: NSFontAttributeName
73 value: [NSFont boldSystemFontOfSize:11]
74 range: NSMakeRange(0, [title length])];
75 [_errors addObject: ourError];
77 [_icons addObject: [[NSWorkspace sharedWorkspace] iconForFileType:NSFileTypeForHFSTypeCode(kAlertStopIcon)]];
79 [self.errorTable reloadData];
82 -(IBAction)cleanupTable:(id)sender
84 [_errors removeAllObjects];
85 [_icons removeAllObjects];
86 [self.errorTable reloadData];
89 /*----------------------------------------------------------------------------
91 *---------------------------------------------------------------------------*/
92 - (NSInteger)numberOfRowsInTableView:(NSTableView *)theDataTable
94 return [_errors count];
97 - (id)tableView:(NSTableView *)theDataTable objectValueForTableColumn:
98 (NSTableColumn *)theTableColumn row: (NSInteger)row
100 if ([[theTableColumn identifier] isEqualToString: @"error_msg"])
101 return [_errors objectAtIndex:row];
103 if ([[theTableColumn identifier] isEqualToString: @"icon"])
104 return [_icons objectAtIndex:row];