Commit 697f59f3 authored by Felix Paul Kühne's avatar Felix Paul Kühne

macosx: split debug messages handling from VLCMain and the Main Menu nib

parent 04cb7d2a
This source diff could not be displayed because it is too large. You can view the blob instead.
......@@ -8,6 +8,7 @@
/* Begin PBXBuildFile section */
7D8BB0B21830244B00FAE9B7 /* CrashReporter.xib in Resources */ = {isa = PBXBuildFile; fileRef = 7D8BB0B01830244B00FAE9B7 /* CrashReporter.xib */; };
7D8BB0B71830311300FAE9B7 /* DebugMessageVisualizer.xib in Resources */ = {isa = PBXBuildFile; fileRef = 7D8BB0B51830311300FAE9B7 /* DebugMessageVisualizer.xib */; };
7DFFA16C16124F38001AF89F /* effects-one-button-pressed-dark.png in Resources */ = {isa = PBXBuildFile; fileRef = 7DFFA16A16124F38001AF89F /* effects-one-button-pressed-dark.png */; };
7DFFA16D16124F38001AF89F /* effects-one-button-pressed-dark@2x.png in Resources */ = {isa = PBXBuildFile; fileRef = 7DFFA16B16124F38001AF89F /* effects-one-button-pressed-dark@2x.png */; };
CC04323D13B246DF00D7D52E /* effects-double-buttons_dark.png in Resources */ = {isa = PBXBuildFile; fileRef = CC04321313B246DF00D7D52E /* effects-double-buttons_dark.png */; };
......@@ -470,6 +471,9 @@
7D5B7B20182FDA0300DB4869 /* CrashReporter.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; name = CrashReporter.m; path = ../../../modules/gui/macosx/CrashReporter.m; sourceTree = "<group>"; };
7D7DC2CA182E86D9008C9E3E /* darwinvlc.c */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.c; name = darwinvlc.c; path = ../../../bin/darwinvlc.c; sourceTree = "<group>"; };
7D8BB0B11830244B00FAE9B7 /* English */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = English; path = Resources/English.lproj/CrashReporter.xib; sourceTree = "<group>"; };
7D8BB0B318302AC000FAE9B7 /* DebugMessageVisualizer.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = DebugMessageVisualizer.h; path = ../../../modules/gui/macosx/DebugMessageVisualizer.h; sourceTree = "<group>"; };
7D8BB0B418302AC000FAE9B7 /* DebugMessageVisualizer.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; name = DebugMessageVisualizer.m; path = ../../../modules/gui/macosx/DebugMessageVisualizer.m; sourceTree = "<group>"; };
7D8BB0B61830311300FAE9B7 /* English */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = English; path = Resources/English.lproj/DebugMessageVisualizer.xib; sourceTree = "<group>"; };
7DFFA16A16124F38001AF89F /* effects-one-button-pressed-dark.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "effects-one-button-pressed-dark.png"; path = "Resources/mainwindow_dark/effects-one-button-pressed-dark.png"; sourceTree = "<group>"; };
7DFFA16B16124F38001AF89F /* effects-one-button-pressed-dark@2x.png */ = {isa = PBXFileReference; lastKnownFileType = image.png; name = "effects-one-button-pressed-dark@2x.png"; path = "Resources/mainwindow_dark/effects-one-button-pressed-dark@2x.png"; sourceTree = "<group>"; };
8E49720006417F6800370C9F /* playlistinfo.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = playlistinfo.h; path = ../../../modules/gui/macosx/playlistinfo.h; sourceTree = SOURCE_ROOT; };
......@@ -1065,6 +1069,8 @@
8ED6C27E03E2EB1C0059A3A7 /* macosx.m */,
8ED6C27C03E2EB1C0059A3A7 /* intf.h */,
8ED6C27D03E2EB1C0059A3A7 /* intf.m */,
7D8BB0B318302AC000FAE9B7 /* DebugMessageVisualizer.h */,
7D8BB0B418302AC000FAE9B7 /* DebugMessageVisualizer.m */,
7D5B7B1F182FDA0300DB4869 /* CrashReporter.h */,
7D5B7B20182FDA0300DB4869 /* CrashReporter.m */,
CC448A5A13B61D49009F72E0 /* MainMenu.h */,
......@@ -1783,6 +1789,7 @@
CC0663371566CD5A003A411C /* ConvertAndSave.xib */,
CC461F73160084A10022423C /* SharedDialogs.xib */,
7D8BB0B01830244B00FAE9B7 /* CrashReporter.xib */,
7D8BB0B51830311300FAE9B7 /* DebugMessageVisualizer.xib */,
);
name = xibs;
sourceTree = "<group>";
......@@ -1937,6 +1944,7 @@
CC04337D13B28B8200D7D52E /* progression-fill-right.png in Resources */,
CC04337E13B28B8200D7D52E /* progression-knob.png in Resources */,
CC04337F13B28B8200D7D52E /* progression-track-wrapper-left.png in Resources */,
7D8BB0B71830311300FAE9B7 /* DebugMessageVisualizer.xib in Resources */,
CC04338013B28B8200D7D52E /* progression-track-wrapper-middle.png in Resources */,
CC04338113B28B8200D7D52E /* progression-track-wrapper-right.png in Resources */,
CC04338213B28B8200D7D52E /* repeat-all-pressed.png in Resources */,
......@@ -2273,6 +2281,14 @@
name = CrashReporter.xib;
sourceTree = "<group>";
};
7D8BB0B51830311300FAE9B7 /* DebugMessageVisualizer.xib */ = {
isa = PBXVariantGroup;
children = (
7D8BB0B61830311300FAE9B7 /* English */,
);
name = DebugMessageVisualizer.xib;
sourceTree = "<group>";
};
CC0663371566CD5A003A411C /* ConvertAndSave.xib */ = {
isa = PBXVariantGroup;
children = (
......
/*****************************************************************************
* DebugMessageVisualizer.h: Mac OS X interface crash reporter
*****************************************************************************
* Copyright (C) 2004-2013 VLC authors and VideoLAN
* $Id$
*
* Authors: Felix Paul Kühne <fkuehne at videolan dot org>
* Pierre d'Herbemont <pdherbemont # videolan org>
* Derk-Jan Hartman <hartman at videolan.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#import <Cocoa/Cocoa.h>
@interface VLCDebugMessageVisualizer : NSObject
{
IBOutlet NSWindow * _msgs_panel;
IBOutlet NSButton * _msgs_save_btn;
IBOutlet NSButton * _msgs_refresh_btn;
IBOutlet id _msgs_table;
}
+ (VLCDebugMessageVisualizer *)sharedInstance;
- (void)showPanel;
- (IBAction)updateMessagesPanel:(id)sender;
- (IBAction)saveDebugLog:(id)sender;
@end
/*****************************************************************************
* DebugMessageVisualizer.m: Mac OS X interface crash reporter
*****************************************************************************
* Copyright (C) 2004-2013 VLC authors and VideoLAN
* $Id$
*
* Authors: Felix Paul Kühne <fkuehne at videolan dot org>
* Pierre d'Herbemont <pdherbemont # videolan org>
* Derk-Jan Hartman <hartman at videolan.org>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#import "DebugMessageVisualizer.h"
#import "intf.h"
#import <vlc_common.h>
static void MsgCallback(void *data, int type, const vlc_log_t *item, const char *format, va_list ap);
/*****************************************************************************
* MsgCallback: Callback triggered by the core once a new debug message is
* ready to be displayed. We store everything in a NSArray in our Cocoa part
* of this file.
*****************************************************************************/
@interface VLCDebugMessageVisualizer () <NSWindowDelegate>
{
NSMutableArray * _msg_arr;
NSLock * _msg_lock;
}
- (void)processReceivedlibvlcMessage:(const vlc_log_t *) item ofType: (int)i_type withStr: (char *)str;
@end
static void MsgCallback(void *data, int type, const vlc_log_t *item, const char *format, va_list ap)
{
int canc = vlc_savecancel();
char *str;
if (vasprintf(&str, format, ap) == -1) {
vlc_restorecancel(canc);
return;
}
NSAutoreleasePool *_pool = [[NSAutoreleasePool alloc] init];
[[VLCDebugMessageVisualizer sharedInstance] processReceivedlibvlcMessage: item ofType: type withStr: str];
[_pool release];
vlc_restorecancel(canc);
free(str);
}
@implementation VLCDebugMessageVisualizer
static VLCDebugMessageVisualizer *_sharedMainInstance = nil;
+ (VLCDebugMessageVisualizer *)sharedInstance
{
return _sharedMainInstance ? _sharedMainInstance : [[self alloc] init];
}
- (id)init
{
if (_sharedMainInstance)
[self dealloc];
else {
_sharedMainInstance = [super init];
_msg_lock = [[NSLock alloc] init];
_msg_arr = [[NSMutableArray arrayWithCapacity:600] retain];
BOOL loaded = [NSBundle loadNibNamed:@"DebugMessageVisualizer" owner:self];
}
return _sharedMainInstance;
}
- (void)awakeFromNib
{
[_msgs_panel setExcludedFromWindowsMenu: YES];
[_msgs_panel setDelegate: self];
[_msgs_panel setTitle: _NS("Messages")];
[_msgs_save_btn setTitle: _NS("Save this Log...")];
[_msgs_refresh_btn setImage: [NSImage imageNamed: NSImageNameRefreshTemplate]];
}
- (void)dealloc
{
[_msg_arr removeAllObjects];
[_msg_arr release];
_msg_arr = NULL;
[_msg_lock release];
[super dealloc];
}
#pragma mark - UI interaction
- (void)showPanel
{
/* subscribe to LibVLCCore's messages */
vlc_LogSet(VLCIntf->p_libvlc, MsgCallback, NULL);
/* show panel */
[_msgs_panel makeKeyAndOrderFront:nil];
}
- (IBAction)updateMessagesPanel:(id)sender
{
[self windowDidBecomeKey:nil];
}
- (void)windowDidBecomeKey:(NSNotification *)notification
{
[_msgs_table reloadData];
[_msgs_table scrollRowToVisible: [_msg_arr count] - 1];
}
- (void)windowWillClose:(NSNotification *)notification
{
/* unsubscribe from LibVLCCore's messages */
vlc_LogSet( VLCIntf->p_libvlc, NULL, NULL );
}
- (IBAction)saveDebugLog:(id)sender
{
NSSavePanel * saveFolderPanel = [[NSSavePanel alloc] init];
[saveFolderPanel setCanSelectHiddenExtension: NO];
[saveFolderPanel setCanCreateDirectories: YES];
[saveFolderPanel setAllowedFileTypes: [NSArray arrayWithObject:@"rtf"]];
[saveFolderPanel setNameFieldStringValue:[NSString stringWithFormat: _NS("VLC Debug Log (%s).rtf"), VERSION_MESSAGE]];
[saveFolderPanel beginSheetModalForWindow: _msgs_panel completionHandler:^(NSInteger returnCode) {
if (returnCode == NSOKButton) {
NSUInteger count = [_msg_arr count];
NSMutableAttributedString * string = [[NSMutableAttributedString alloc] init];
for (NSUInteger i = 0; i < count; i++)
[string appendAttributedString: [_msg_arr objectAtIndex:i]];
NSData *data = [string RTFFromRange:NSMakeRange(0, [string length])
documentAttributes:[NSDictionary dictionaryWithObject: NSRTFTextDocumentType forKey: NSDocumentTypeDocumentAttribute]];
if ([data writeToFile: [[saveFolderPanel URL] path] atomically: YES] == NO)
msg_Warn(VLCIntf, "Error while saving the debug log");
[string release];
}
}];
[saveFolderPanel release];
}
#pragma mark - data handling
- (NSInteger)numberOfRowsInTableView:(NSTableView *)aTableView
{
if (aTableView == _msgs_table)
return [_msg_arr count];
return 0;
}
- (id)tableView:(NSTableView *)aTableView objectValueForTableColumn:(NSTableColumn *)aTableColumn row:(NSInteger)rowIndex
{
NSMutableAttributedString *result = NULL;
[_msg_lock lock];
if (rowIndex < [_msg_arr count])
result = [_msg_arr objectAtIndex:rowIndex];
[_msg_lock unlock];
if (result != NULL)
return result;
else
return @"";
}
- (void)processReceivedlibvlcMessage:(const vlc_log_t *) item ofType: (int)i_type withStr: (char *)str
{
if (_msg_arr) {
NSColor *_white = [NSColor whiteColor];
NSColor *_red = [NSColor redColor];
NSColor *_yellow = [NSColor yellowColor];
NSColor *_gray = [NSColor grayColor];
NSString * firstString, * secondString;
NSColor * pp_color[4] = { _white, _red, _yellow, _gray };
static const char * ppsz_type[4] = { ": ", " error: ", " warning: ", " debug: " };
NSDictionary *_attr;
NSMutableAttributedString *_msg_color;
[_msg_lock lock];
if ([_msg_arr count] > 600) {
[_msg_arr removeObjectAtIndex: 0];
[_msg_arr removeObjectAtIndex: 1];
}
if (!item->psz_module)
return;
if (!str)
return;
firstString = [NSString stringWithFormat:@"%s%s", item->psz_module, ppsz_type[i_type]];
secondString = [NSString stringWithFormat:@"%@%s\n", firstString, str];
_attr = [NSDictionary dictionaryWithObject: pp_color[i_type] forKey: NSForegroundColorAttributeName];
_msg_color = [[NSMutableAttributedString alloc] initWithString: secondString attributes: _attr];
_attr = [NSDictionary dictionaryWithObject: pp_color[3] forKey: NSForegroundColorAttributeName];
[_msg_color setAttributes: _attr range: NSMakeRange(0, [firstString length])];
[_msg_arr addObject: [_msg_color autorelease]];
[_msg_lock unlock];
}
}
@end
......@@ -287,6 +287,7 @@
- (IBAction)openForum:(id)sender;
- (IBAction)openDonate:(id)sender;
- (IBAction)viewErrorsAndWarnings:(id)sender;
- (IBAction)showMessagesPanel:(id)showMessagesPanel;
- (void)setPlay;
- (void)setPause;
......
......@@ -44,6 +44,7 @@
#import "ControlsBar.h"
#import "ExtensionsManager.h"
#import "ConvertAndSave.h"
#import "DebugMessageVisualizer.h"
@implementation VLCMainMenu
static VLCMainMenu *_o_sharedInstance = nil;
......@@ -1104,6 +1105,11 @@ static VLCMainMenu *_o_sharedInstance = nil;
[[[VLCMain sharedInstance] simplePreferences] showSimplePrefsWithLevel:i_level];
}
- (IBAction)showMessagesPanel:(id)showMessagesPanel
{
[[VLCDebugMessageVisualizer sharedInstance] showPanel];
}
#pragma mark -
#pragma mark Help and Docs
......
......@@ -85,5 +85,7 @@ SOURCES_macosx = \
VLCVoutWindowController.h \
CrashReporter.m \
CrashReporter.h \
DebugMessageVisualizer.m \
DebugMessageVisualizer.h \
iTunes.h \
$(NULL)
......@@ -110,15 +110,6 @@ struct intf_sys_t
IBOutlet VLCControls * o_controls; /* VLCControls */
IBOutlet VLCPlaylist * o_playlist; /* VLCPlaylist */
/* messages panel */
IBOutlet NSWindow * o_msgs_panel; /* messages panel */
NSMutableArray * o_msg_arr; /* messages array */
NSLock * o_msg_lock; /* messages lock */
BOOL b_msg_arr_changed; /* did the array change? */
IBOutlet NSButton * o_msgs_save_btn; /* save the log as rtf */
IBOutlet NSButton * o_msgs_refresh_btn; /* update the panel */
IBOutlet id o_msgs_table;
AppleRemote * o_remote;
BOOL b_remote_button_hold; /* true as long as the user holds the left,right,plus or minus on the remote control */
......@@ -187,10 +178,6 @@ struct intf_sys_t
- (void)updateDelays;
- (void)initStrings;
- (IBAction)saveDebugLog:(id)sender;
- (IBAction)showMessagesPanel:(id)sender;
- (IBAction)updateMessagesPanel:(id)sender;
- (void)processReceivedlibvlcMessage:(const vlc_log_t *) item ofType: (int)type withStr: (char *)str;
- (void)updateTogglePlaylistState;
......
......@@ -82,8 +82,6 @@ static void updateProgressPanel (void *, const char *, float);
static bool checkProgressPanel (void *);
static void destroyProgressPanel (void *);
static void MsgCallback(void *data, int type, const vlc_log_t *item, const char *format, va_list ap);
static int InputEvent(vlc_object_t *, const char *,
vlc_value_t, vlc_value_t, void *);
static int PLItemChanged(vlc_object_t *, const char *,
......@@ -318,29 +316,6 @@ static void Run(intf_thread_t *p_intf)
#pragma mark -
#pragma mark Variables Callback
/*****************************************************************************
* MsgCallback: Callback triggered by the core once a new debug message is
* ready to be displayed. We store everything in a NSArray in our Cocoa part
* of this file.
*****************************************************************************/
static void MsgCallback(void *data, int type, const vlc_log_t *item, const char *format, va_list ap)
{
int canc = vlc_savecancel();
char *str;
if (vasprintf(&str, format, ap) == -1) {
vlc_restorecancel(canc);
return;
}
NSAutoreleasePool *o_pool = [[NSAutoreleasePool alloc] init];
[[VLCMain sharedInstance] processReceivedlibvlcMessage: item ofType: type withStr: str];
[o_pool release];
vlc_restorecancel(canc);
free(str);
}
static int InputEvent(vlc_object_t *p_this, const char *psz_var,
vlc_value_t oldval, vlc_value_t new_val, void *param)
{
......@@ -413,7 +388,6 @@ static int InputEvent(vlc_object_t *p_this, const char *psz_var,
break;
default:
//msg_Warn(p_this, "unhandled input event (%lld)", new_val.i_int);
break;
}
......@@ -658,9 +632,6 @@ static VLCMain *_o_sharedMainInstance = nil;
p_intf = NULL;
p_current_input = p_input_changed = NULL;
o_msg_lock = [[NSLock alloc] init];
o_msg_arr = [[NSMutableArray arrayWithCapacity: 600] retain];
o_open = [[VLCOpen alloc] init];
o_coredialogs = [[VLCCoreDialogProvider alloc] init];
o_info = [[VLCInfo alloc] init];
......@@ -706,9 +677,6 @@ static VLCMain *_o_sharedMainInstance = nil;
if (nib_main_loaded)
return;
[o_msgs_panel setExcludedFromWindowsMenu: YES];
[o_msgs_panel setDelegate: self];
p_playlist = pl_Get(p_intf);
val.b_bool = false;
......@@ -754,8 +722,6 @@ static VLCMain *_o_sharedMainInstance = nil;
[o_remote setClickCountEnabledButtons: kRemoteButtonPlay];
[o_remote setDelegate: _o_sharedMainInstance];
[o_msgs_refresh_btn setImage: [NSImage imageNamed: NSImageNameRefreshTemplate]];
/* yeah, we are done */
b_nativeFullscreenMode = NO;
#ifdef MAC_OS_X_VERSION_10_7
......@@ -777,8 +743,6 @@ static VLCMain *_o_sharedMainInstance = nil;
[[VLCApplication sharedApplication] setApplicationIconImage: [NSImage imageNamed:@"vlc-xmas"]];
}
[self initStrings];
nib_main_loaded = TRUE;
}
......@@ -833,16 +797,6 @@ static VLCMain *_o_sharedMainInstance = nil;
[[self playlist] playItem:nil];
}
- (void)initStrings
{
if (!p_intf)
return;
/* messages panel */
[o_msgs_panel setTitle: _NS("Messages")];
[o_msgs_save_btn setTitle: _NS("Save this Log...")];
}
#pragma mark -
#pragma mark Termination
......@@ -944,20 +898,14 @@ static VLCMain *_o_sharedMainInstance = nil;
/* unsubscribe from libvlc's debug messages */
vlc_LogSet(p_intf->p_libvlc, NULL, NULL);
[o_msg_arr removeAllObjects];
[o_msg_arr release];
o_msg_arr = NULL;
[o_usedHotkeys release];
o_usedHotkeys = NULL;
[o_mediaKeyController release];
[o_msg_lock release];
/* write cached user defaults to disk */
[[NSUserDefaults standardUserDefaults] synchronize];
[o_mainmenu release];
libvlc_Quit(p_intf->p_libvlc);
......@@ -1801,123 +1749,6 @@ static VLCMain *_o_sharedMainInstance = nil;
execl(path, path, NULL);
}
#pragma mark -
#pragma mark Errors, warnings and messages
- (IBAction)updateMessagesPanel:(id)sender
{
[self windowDidBecomeKey:nil];
}
- (IBAction)showMessagesPanel:(id)sender
{
/* subscribe to LibVLCCore's messages */
vlc_LogSet(p_intf->p_libvlc, MsgCallback, NULL);
/* show panel */
[o_msgs_panel makeKeyAndOrderFront: sender];
}
- (void)windowDidBecomeKey:(NSNotification *)o_notification
{
[o_msgs_table reloadData];
[o_msgs_table scrollRowToVisible: [o_msg_arr count] - 1];
}
- (void)windowWillClose:(NSNotification *)o_notification
{
/* unsubscribe from LibVLCCore's messages */
vlc_LogSet( p_intf->p_libvlc, NULL, NULL );
}
- (NSInteger)numberOfRowsInTableView:(NSTableView *)aTableView
{
if (aTableView == o_msgs_table)
return [o_msg_arr count];
return 0;
}
- (id)tableView:(NSTableView *)aTableView objectValueForTableColumn:(NSTableColumn *)aTableColumn row:(NSInteger)rowIndex
{
NSMutableAttributedString *result = NULL;
[o_msg_lock lock];
if (rowIndex < [o_msg_arr count])
result = [o_msg_arr objectAtIndex:rowIndex];
[o_msg_lock unlock];
if (result != NULL)
return result;
else
return @"";
}
- (void)processReceivedlibvlcMessage:(const vlc_log_t *) item ofType: (int)i_type withStr: (char *)str
{
if (o_msg_arr) {
NSColor *o_white = [NSColor whiteColor];
NSColor *o_red = [NSColor redColor];
NSColor *o_yellow = [NSColor yellowColor];
NSColor *o_gray = [NSColor grayColor];
NSString * firstString, * secondString;
NSColor * pp_color[4] = { o_white, o_red, o_yellow, o_gray };
static const char * ppsz_type[4] = { ": ", " error: ", " warning: ", " debug: " };
NSDictionary *o_attr;
NSMutableAttributedString *o_msg_color;
[o_msg_lock lock];
if ([o_msg_arr count] > 600) {
[o_msg_arr removeObjectAtIndex: 0];
[o_msg_arr removeObjectAtIndex: 1];
}
if (!item->psz_module)
return;
if (!str)
return;
firstString = [NSString stringWithFormat:@"%s%s", item->psz_module, ppsz_type[i_type]];
secondString = [NSString stringWithFormat:@"%@%s\n", firstString, str];
o_attr = [NSDictionary dictionaryWithObject: pp_color[i_type] forKey: NSForegroundColorAttributeName];
o_msg_color = [[NSMutableAttributedString alloc] initWithString: secondString attributes: o_attr];
o_attr = [NSDictionary dictionaryWithObject: pp_color[3] forKey: NSForegroundColorAttributeName];
[o_msg_color setAttributes: o_attr range: NSMakeRange(0, [firstString length])];
[o_msg_arr addObject: [o_msg_color autorelease]];
b_msg_arr_changed = YES;
[o_msg_lock unlock];
}
}
- (IBAction)saveDebugLog:(id)sender
{
NSSavePanel * saveFolderPanel = [[NSSavePanel alloc] init];
[saveFolderPanel setCanSelectHiddenExtension: NO];
[saveFolderPanel setCanCreateDirectories: YES];
[saveFolderPanel setAllowedFileTypes: [NSArray arrayWithObject:@"rtf"]];
[saveFolderPanel setNameFieldStringValue:[NSString stringWithFormat: _NS("VLC Debug Log (%s).rtf"), VERSION_MESSAGE]];
[saveFolderPanel beginSheetModalForWindow: o_msgs_panel completionHandler:^(NSInteger returnCode) {
if (returnCode == NSOKButton) {
NSUInteger count = [o_msg_arr count];
NSMutableAttributedString * string = [[NSMutableAttributedString alloc] init];
for (NSUInteger i = 0; i < count; i++)
[string appendAttributedString: [o_msg_arr objectAtIndex:i]];
NSData *data = [string RTFFromRange:NSMakeRange(0, [string length])
documentAttributes:[NSDictionary dictionaryWithObject: NSRTFTextDocumentType forKey: NSDocumentTypeDocumentAttribute]];
if ([data writeToFile: [[saveFolderPanel URL] path] atomically: YES] == NO)
msg_Warn(p_intf, "Error while saving the debug log");
[string release];
}
}];
[saveFolderPanel release];
}
#pragma mark -
#pragma mark Playlist toggling
......
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