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