Commit e34a1cb1 authored by David Fuhrmann's avatar David Fuhrmann

macosx: convert debug message visualizer to NSWindowController

... and get rid of another singleton.
parent cb8e4a6d
......@@ -2,13 +2,13 @@
<archive type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="8.00">
<data>
<int key="IBDocument.SystemTarget">1060</int>
<string key="IBDocument.SystemVersion">14B25</string>
<string key="IBDocument.InterfaceBuilderVersion">6254</string>
<string key="IBDocument.AppKitVersion">1343.16</string>
<string key="IBDocument.HIToolboxVersion">755.00</string>
<string key="IBDocument.SystemVersion">14F6a</string>
<string key="IBDocument.InterfaceBuilderVersion">7706</string>
<string key="IBDocument.AppKitVersion">1348.17</string>
<string key="IBDocument.HIToolboxVersion">758.70</string>
<object class="NSMutableDictionary" key="IBDocument.PluginVersions">
<string key="NS.key.0">com.apple.InterfaceBuilder.CocoaPlugin</string>
<string key="NS.object.0">6254</string>
<string key="NS.object.0">7706</string>
</object>
<array key="IBDocument.IntegratedClassDependencies">
<string>NSButton</string>
......@@ -317,11 +317,11 @@
</object>
<object class="IBConnectionRecord">
<object class="IBOutletConnection" key="connection">
<string key="label">_msgs_panel</string>
<string key="label">window</string>
<reference key="source" ref="1001"/>
<reference key="destination" ref="401114513"/>
</object>
<int key="connectionID">23</int>
<int key="connectionID">24</int>
</object>
<object class="IBConnectionRecord">
<object class="IBOutletConnection" key="connection">
......@@ -476,13 +476,13 @@
<nil key="activeLocalization"/>
<dictionary class="NSMutableDictionary" key="localizations"/>
<nil key="sourceID"/>
<int key="maxID">23</int>
<int key="maxID">24</int>
</object>
<object class="IBClassDescriber" key="IBDocument.Classes">
<array class="NSMutableArray" key="referencedPartialClassDescriptions">
<object class="IBPartialClassDescription">
<string key="className">VLCDebugMessageVisualizer</string>
<string key="superclassName">NSObject</string>
<string key="superclassName">NSWindowController</string>
<dictionary class="NSMutableDictionary" key="actions">
<string key="saveDebugLog:">id</string>
<string key="updateMessagesPanel:">id</string>
......@@ -498,16 +498,11 @@
</object>
</dictionary>
<dictionary class="NSMutableDictionary" key="outlets">
<string key="_msgs_panel">NSWindow</string>
<string key="_msgs_refresh_btn">NSButton</string>
<string key="_msgs_save_btn">NSButton</string>
<string key="_msgs_table">id</string>
</dictionary>
<dictionary class="NSMutableDictionary" key="toOneOutletInfosByName">
<object class="IBToOneOutletInfo" key="_msgs_panel">
<string key="name">_msgs_panel</string>
<string key="candidateClassName">NSWindow</string>
</object>
<object class="IBToOneOutletInfo" key="_msgs_refresh_btn">
<string key="name">_msgs_refresh_btn</string>
<string key="candidateClassName">NSButton</string>
......@@ -685,6 +680,25 @@
<string key="minorKey">AppKit.framework/Headers/NSWindow.h</string>
</object>
</object>
<object class="IBPartialClassDescription">
<string key="className">NSWindowController</string>
<string key="superclassName">NSResponder</string>
<object class="NSMutableDictionary" key="actions">
<string key="NS.key.0">showWindow:</string>
<string key="NS.object.0">id</string>
</object>
<object class="NSMutableDictionary" key="actionInfosByName">
<string key="NS.key.0">showWindow:</string>
<object class="IBActionInfo" key="NS.object.0">
<string key="name">showWindow:</string>
<string key="candidateClassName">id</string>
</object>
</object>
<object class="IBClassDescriptionSource" key="sourceIdentifier">
<string key="majorKey">IBFrameworkSource</string>
<string key="minorKey">AppKit.framework/Headers/NSWindowController.h</string>
</object>
</object>
</array>
</object>
<int key="IBDocument.localizationMode">0</int>
......
......@@ -25,16 +25,15 @@
#import <Cocoa/Cocoa.h>
@interface VLCDebugMessageVisualizer : NSObject
@interface VLCDebugMessageVisualizer : NSWindowController
{
IBOutlet NSWindow * _msgs_panel;
IBOutlet NSButton * _msgs_save_btn;
IBOutlet NSButton * _msgs_refresh_btn;
IBOutlet id _msgs_table;
}
+ (VLCDebugMessageVisualizer *)sharedInstance;
- (void)showPanel;
- (void)showWindow:(id)sender;
- (IBAction)updateMessagesPanel:(id)sender;
- (IBAction)saveDebugLog:(id)sender;
......
......@@ -47,6 +47,9 @@ static void MsgCallback(void *data, int type, const vlc_log_t *item, const char
static void MsgCallback(void *data, int type, const vlc_log_t *item, const char *format, va_list ap)
{
@autoreleasepool {
VLCDebugMessageVisualizer *visualizer = (__bridge VLCDebugMessageVisualizer*)data;
int canc = vlc_savecancel();
char *str;
......@@ -55,7 +58,7 @@ static void MsgCallback(void *data, int type, const vlc_log_t *item, const char
return;
}
[[VLCDebugMessageVisualizer sharedInstance] processReceivedlibvlcMessage: item ofType: type withStr: str];
[visualizer processReceivedlibvlcMessage: item ofType: type withStr: str];
vlc_restorecancel(canc);
free(str);
......@@ -78,33 +81,31 @@ static void MsgCallback(void *data, int type, const vlc_log_t *item, const char
- (id)init
{
self = [super init];
self = [super initWithWindowNibName:@"DebugMessageVisualizer"];
if (self) {
_msg_lock = [[NSLock alloc] init];
_msg_arr = [NSMutableArray arrayWithCapacity:600];
BOOL loaded = [NSBundle loadNibNamed:@"DebugMessageVisualizer" owner:self];
}
return self;
}
- (void)awakeFromNib
- (void)windowDidLoad
{
[_msgs_panel setExcludedFromWindowsMenu: YES];
[_msgs_panel setDelegate: self];
[_msgs_panel setTitle: _NS("Messages")];
[self.window setExcludedFromWindowsMenu: YES];
[self.window setDelegate: self];
[self.window setTitle: _NS("Messages")];
[_msgs_save_btn setTitle: _NS("Save this Log...")];
[_msgs_refresh_btn setImage: [NSImage imageNamed: NSImageNameRefreshTemplate]];
}
#pragma mark - UI interaction
- (void)showPanel
- (void)showWindow:(id)sender
{
/* subscribe to LibVLCCore's messages */
vlc_LogSet(VLCIntf->p_libvlc, MsgCallback, NULL);
vlc_LogSet(VLCIntf->p_libvlc, MsgCallback, (__bridge void*)self);
/* show panel */
[_msgs_panel makeKeyAndOrderFront:nil];
[super showWindow:sender];
}
- (IBAction)updateMessagesPanel:(id)sender
......@@ -132,7 +133,7 @@ static void MsgCallback(void *data, int type, const vlc_log_t *item, const char
[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) {
[saveFolderPanel beginSheetModalForWindow: self.window completionHandler:^(NSInteger returnCode) {
if (returnCode == NSOKButton) {
NSUInteger count = [_msg_arr count];
NSMutableAttributedString * string = [[NSMutableAttributedString alloc] init];
......
......@@ -1335,7 +1335,7 @@
- (IBAction)showMessagesPanel:(id)showMessagesPanel
{
[[VLCDebugMessageVisualizer sharedInstance] showPanel];
[[[VLCMain sharedInstance] debugMsgPanel] showWindow:self];
}
- (IBAction)showMainWindow:(id)sender
......
......@@ -64,6 +64,7 @@ static NSString * VLCInputChangedNotification = @"VLCInputChangedNotification";
@class VLCCoreDialogProvider;
@class VLCBookmarks;
@class VLCOpen;
@class VLCDebugMessageVisualizer;
@interface VLCMain : NSObject <NSWindowDelegate, NSApplicationDelegate>
{
......@@ -88,6 +89,8 @@ static NSString * VLCInputChangedNotification = @"VLCInputChangedNotification";
- (VLCCoreDialogProvider *)coreDialogProvider;
- (ResumeDialogController *)resumeDialog;
- (VLCInputManager *)inputManager;
- (VLCDebugMessageVisualizer *)debugMsgPanel;
- (void)setActiveVideoPlayback:(BOOL)b_value;
- (BOOL)activeVideoPlayback;
- (void)applicationWillTerminate:(NSNotification *)notification;
......
......@@ -58,6 +58,7 @@
#import "ExtensionsManager.h"
#import "BWQuincyManager.h"
#import "ResumeDialogController.h"
#import "DebugMessageVisualizer.h"
#import "VideoEffects.h"
#import "AudioEffects.h"
......@@ -157,6 +158,7 @@ static int ShowController(vlc_object_t *p_this, const char *psz_variable,
ResumeDialogController *_resume_dialog;
VLCInputManager *_input_manager;
VLCPlaylist *_playlist;
VLCDebugMessageVisualizer *_messagePanelController;
bool b_intf_terminating; /* Makes sure applicationWillTerminate will be called only once */
}
......@@ -521,6 +523,14 @@ static int ShowController(vlc_object_t *p_this, const char *psz_variable,
return _input_manager;
}
- (VLCDebugMessageVisualizer *)debugMsgPanel
{
if (!_messagePanelController)
_messagePanelController = [[VLCDebugMessageVisualizer alloc] init];
return _messagePanelController;
}
- (VLCBookmarks *)bookmarks
{
if (!_bookmarks)
......
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