Commit 8db0ca58 authored by David Fuhrmann's avatar David Fuhrmann

macosx: Change VLCInfo to NSWindowController subclass

Uses NSWindowController to load the information panel. Get rid of
the singleton. VLCMain will now hold one instance, which is aimed
to display information about the currently playing media.
parent 8c5a7eee
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -74,7 +74,7 @@ static int InputEvent(vlc_object_t *p_this, const char *psz_var, ...@@ -74,7 +74,7 @@ static int InputEvent(vlc_object_t *p_this, const char *psz_var,
break; break;
case INPUT_EVENT_STATISTICS: case INPUT_EVENT_STATISTICS:
dispatch_async(dispatch_get_main_queue(), ^{ dispatch_async(dispatch_get_main_queue(), ^{
[[VLCInfo sharedInstance] updateStatistics]; [[[VLCMain sharedInstance] currentMediaInfoPanel] updateStatistics];
}); });
break; break;
case INPUT_EVENT_ES: case INPUT_EVENT_ES:
...@@ -397,14 +397,14 @@ static int InputEvent(vlc_object_t *p_this, const char *psz_var, ...@@ -397,14 +397,14 @@ static int InputEvent(vlc_object_t *p_this, const char *psz_var,
- (void)updateMetaAndInfo - (void)updateMetaAndInfo
{ {
if (!p_current_input) { if (!p_current_input) {
[[VLCInfo sharedInstance] updatePanelWithItem:nil]; [[[VLCMain sharedInstance] currentMediaInfoPanel] updatePanelWithItem:nil];
return; return;
} }
input_item_t *p_input_item = input_GetItem(p_current_input); input_item_t *p_input_item = input_GetItem(p_current_input);
[[[o_main playlist] model] updateItem:p_input_item]; [[[o_main playlist] model] updateItem:p_input_item];
[[VLCInfo sharedInstance] updatePanelWithItem:p_input_item]; [[[VLCMain sharedInstance] currentMediaInfoPanel] updatePanelWithItem:p_input_item];
} }
- (void)updateMainWindow - (void)updateMainWindow
......
...@@ -1357,7 +1357,7 @@ ...@@ -1357,7 +1357,7 @@
- (IBAction)showInformationPanel:(id)sender - (IBAction)showInformationPanel:(id)sender
{ {
[[VLCInfo sharedInstance] initPanel]; [[[VLCMain sharedInstance] currentMediaInfoPanel] showPanel];
} }
#pragma mark - convinience stuff for other objects #pragma mark - convinience stuff for other objects
......
...@@ -299,7 +299,7 @@ static int VolumeUpdated(vlc_object_t *p_this, const char *psz_var, ...@@ -299,7 +299,7 @@ static int VolumeUpdated(vlc_object_t *p_this, const char *psz_var,
VLCMain *instance = [VLCMain sharedInstance]; VLCMain *instance = [VLCMain sharedInstance];
[[instance mainWindow] updateName]; [[instance mainWindow] updateName];
[[VLCInfo sharedInstance] updateMetadata]; [[instance currentMediaInfoPanel] updateMetadata];
} }
- (void)addItem:(int)i_item withParentNode:(int)i_node - (void)addItem:(int)i_item withParentNode:(int)i_node
......
...@@ -394,7 +394,7 @@ ...@@ -394,7 +394,7 @@
- (IBAction)showInfoPanel:(id)sender - (IBAction)showInfoPanel:(id)sender
{ {
[[VLCInfo sharedInstance] initPanel]; [[[VLCMain sharedInstance] currentMediaInfoPanel] showPanel];
} }
- (IBAction)deleteItem:(id)sender - (IBAction)deleteItem:(id)sender
......
...@@ -28,11 +28,10 @@ ...@@ -28,11 +28,10 @@
@class VLCInfoTreeItem; @class VLCInfoTreeItem;
@interface VLCInfo : NSObject @interface VLCInfo : NSWindowController
@property (readonly) input_item_t *item; @property (readonly) input_item_t *item;
@property (readwrite, weak) IBOutlet NSPanel *infoPanel;
@property (readwrite, weak) IBOutlet NSOutlineView *outlineView; @property (readwrite, weak) IBOutlet NSOutlineView *outlineView;
@property (readwrite, weak) IBOutlet NSTabView *tabView; @property (readwrite, weak) IBOutlet NSTabView *tabView;
...@@ -97,7 +96,7 @@ ...@@ -97,7 +96,7 @@
@property (readwrite, weak) IBOutlet NSTextField *videoDecodedTextField; @property (readwrite, weak) IBOutlet NSTextField *videoDecodedTextField;
- (void)updateCocoaWindowLevel:(NSInteger)i_level; - (void)updateCocoaWindowLevel:(NSInteger)i_level;
- (void)initPanel; - (void)showPanel;
- (IBAction)metaFieldChanged:(id)sender; - (IBAction)metaFieldChanged:(id)sender;
- (IBAction)saveMetaData:(id)sender; - (IBAction)saveMetaData:(id)sender;
...@@ -108,7 +107,6 @@ ...@@ -108,7 +107,6 @@
- (void)updateMetadata; - (void)updateMetadata;
- (void)updateStatistics; - (void)updateStatistics;
+ (VLCInfo *)sharedInstance;
@end @end
@interface VLCInfoTreeItem : NSObject @interface VLCInfoTreeItem : NSObject
...@@ -117,7 +115,9 @@ ...@@ -117,7 +115,9 @@
@property (readonly) NSString *name; @property (readonly) NSString *name;
@property (readonly) NSString *value; @property (readonly) NSString *value;
- (id)initWithInputItem:(input_item_t *)inputItem;
- (VLCInfoTreeItem *)childAtIndex:(NSUInteger)i_index; - (VLCInfoTreeItem *)childAtIndex:(NSUInteger)i_index;
- (void)refresh; - (void)refreshWithItem:(input_item_t *)inputItem;
@end @end
...@@ -34,7 +34,6 @@ ...@@ -34,7 +34,6 @@
input_item_t *p_item; input_item_t *p_item;
BOOL b_nibLoaded;
BOOL b_awakeFromNib; BOOL b_awakeFromNib;
BOOL b_stats; BOOL b_stats;
} }
...@@ -42,24 +41,22 @@ ...@@ -42,24 +41,22 @@
@implementation VLCInfo @implementation VLCInfo
+ (VLCInfo *)sharedInstance - (id)init
{ {
static VLCInfo *sharedInstance = nil; self = [super initWithWindowNibName:@"MediaInfo"];
static dispatch_once_t pred; if (self) {
dispatch_once(&pred, ^{ }
sharedInstance = [VLCInfo new];
});
return sharedInstance; return self;
} }
- (void)awakeFromNib - (void)windowDidLoad
{ {
[_infoPanel setExcludedFromWindowsMenu: YES]; [self.window setExcludedFromWindowsMenu: YES];
[_infoPanel setCollectionBehavior: NSWindowCollectionBehaviorFullScreenAuxiliary]; [self.window setCollectionBehavior: NSWindowCollectionBehaviorFullScreenAuxiliary];
[_infoPanel setTitle: _NS("Media Information")]; [self.window setTitle: _NS("Media Information")];
_outlineView.dataSource = self; _outlineView.dataSource = self;
_outlineView.delegate = self; _outlineView.delegate = self;
...@@ -108,10 +105,19 @@ ...@@ -108,10 +105,19 @@
[_playedAudioBuffersLabel setStringValue: _NS("Played buffers")]; [_playedAudioBuffersLabel setStringValue: _NS("Played buffers")];
[_lostAudioBuffersLabel setStringValue: _NS("Lost buffers")]; [_lostAudioBuffersLabel setStringValue: _NS("Lost buffers")];
[_infoPanel setInitialFirstResponder: _uriLabel]; [self.window setInitialFirstResponder: _uriLabel];
b_awakeFromNib = YES; b_awakeFromNib = YES;
b_stats = var_InheritBool(VLCIntf, "stats");
if (!b_stats) {
if ([_tabView numberOfTabViewItems] > 2)
[_tabView removeTabViewItem: [_tabView tabViewItemAtIndex: 2]];
}
else
[self initMediaPanelStats];
/* We may be awoken from nib way after initialisation /* We may be awoken from nib way after initialisation
*Update ourselves */ *Update ourselves */
[self updatePanelWithItem:p_item]; [self updatePanelWithItem:p_item];
...@@ -126,26 +132,15 @@ ...@@ -126,26 +132,15 @@
- (void)updateCocoaWindowLevel:(NSInteger)i_level - (void)updateCocoaWindowLevel:(NSInteger)i_level
{ {
if (_infoPanel && [_infoPanel isVisible] && [_infoPanel level] != i_level) if (self.window && [self.window isVisible] && [self.window level] != i_level)
[_infoPanel setLevel: i_level]; [self.window setLevel: i_level];
} }
- (void)initPanel - (void)showPanel
{ {
if (!b_nibLoaded)
b_nibLoaded = [NSBundle loadNibNamed:@"MediaInfo" owner: self];
b_stats = var_InheritBool(VLCIntf, "stats");
if (!b_stats) {
if ([_tabView numberOfTabViewItems] > 2)
[_tabView removeTabViewItem: [_tabView tabViewItemAtIndex: 2]];
}
else
[self initMediaPanelStats];
NSInteger i_level = [[[VLCMain sharedInstance] voutController] currentStatusWindowLevel]; NSInteger i_level = [[[VLCMain sharedInstance] voutController] currentStatusWindowLevel];
[_infoPanel setLevel: i_level]; [self.window setLevel: i_level];
[_infoPanel makeKeyAndOrderFront:nil]; [self.window makeKeyAndOrderFront:nil];
} }
- (void)initMediaPanelStats - (void)initMediaPanelStats
...@@ -183,7 +178,6 @@ ...@@ -183,7 +178,6 @@
- (void)updatePanelWithItem:(input_item_t *)_p_item; - (void)updatePanelWithItem:(input_item_t *)_p_item;
{ {
@autoreleasepool { @autoreleasepool {
rootItem = [[VLCInfoTreeItem alloc] init];
if (_p_item != p_item) { if (_p_item != p_item) {
if (p_item) if (p_item)
...@@ -194,6 +188,8 @@ ...@@ -194,6 +188,8 @@
p_item = _p_item; p_item = _p_item;
} }
rootItem = [[VLCInfoTreeItem alloc] initWithInputItem:p_item];
if (!p_item) { if (!p_item) {
/* Erase */ /* Erase */
#define SET( foo ) \ #define SET( foo ) \
...@@ -263,7 +259,7 @@ ...@@ -263,7 +259,7 @@
} }
/* reload the advanced table */ /* reload the advanced table */
[rootItem refresh]; [rootItem refreshWithItem:p_item];
[_outlineView reloadData]; [_outlineView reloadData];
[_outlineView expandItem:nil expandChildren:YES]; [_outlineView expandItem:nil expandChildren:YES];
...@@ -285,7 +281,7 @@ ...@@ -285,7 +281,7 @@
if (!b_awakeFromNib || !b_stats) if (!b_awakeFromNib || !b_stats)
return; return;
if ([_infoPanel isVisible]) { if ([self.window isVisible]) {
if (!p_item || !p_item->p_stats) { if (!p_item || !p_item->p_stats) {
[self initMediaPanelStats]; [self initMediaPanelStats];
return; return;
...@@ -434,6 +430,7 @@ error: ...@@ -434,6 +430,7 @@ error:
value:(NSString *)item_value value:(NSString *)item_value
ID:(int)i_id ID:(int)i_id
parent:(VLCInfoTreeItem *)parent_item parent:(VLCInfoTreeItem *)parent_item
inputItem:(input_item_t*)inputItem
{ {
self = [super init]; self = [super init];
...@@ -442,20 +439,22 @@ error: ...@@ -442,20 +439,22 @@ error:
_value = [item_value copy]; _value = [item_value copy];
i_object_id = i_id; i_object_id = i_id;
_parent = parent_item; _parent = parent_item;
p_item = [[VLCInfo sharedInstance] item]; p_item = inputItem;
if (p_item)
input_item_Hold(p_item);
} }
return self; return self;
} }
- (id)init - (id)initWithInputItem:(input_item_t *)inputItem
{ {
return [self initWithName:@"main" value:@"" ID:-1 parent:nil]; return [self initWithName:@"main" value:@"" ID:-1 parent:nil inputItem:inputItem];
} }
- (void)dealloc - (void)dealloc
{ {
if (p_item) if (p_item)
vlc_gc_decref(p_item); input_item_Release(p_item);
} }
/* Creates and returns the array of children /* Creates and returns the array of children
...@@ -477,7 +476,8 @@ error: ...@@ -477,7 +476,8 @@ error:
initWithName:name initWithName:name
value:@"" value:@""
ID:i ID:i
parent:self]; parent:self
inputItem:p_item];
[_children addObject:item]; [_children addObject:item];
} }
vlc_mutex_unlock(&p_item->lock); vlc_mutex_unlock(&p_item->lock);
...@@ -493,7 +493,8 @@ error: ...@@ -493,7 +493,8 @@ error:
initWithName:name initWithName:name
value:value value:value
ID:i ID:i
parent:self]; parent:self
inputItem:p_item];
[_children addObject:item]; [_children addObject:item];
} }
vlc_mutex_unlock(&p_item->lock); vlc_mutex_unlock(&p_item->lock);
...@@ -503,12 +504,14 @@ error: ...@@ -503,12 +504,14 @@ error:
_isALeafNode = YES; _isALeafNode = YES;
} }
- (void)refresh - (void)refreshWithItem:(input_item_t *)inputItem;
{ {
if (p_item) if (p_item)
vlc_gc_decref(p_item); input_item_Release(p_item);
p_item = [[VLCInfo sharedInstance] item]; p_item = inputItem;
if (p_item)
input_item_Hold(p_item);
_children = nil; _children = nil;
} }
......
...@@ -592,7 +592,7 @@ void WindowClose(vout_window_t *p_wnd) ...@@ -592,7 +592,7 @@ void WindowClose(vout_window_t *p_wnd)
[[[VLCMain sharedInstance] mainWindow] setWindowLevel:i_level]; [[[VLCMain sharedInstance] mainWindow] setWindowLevel:i_level];
[[main videoEffectsPanel] updateCocoaWindowLevel:currentStatusWindowLevel]; [[main videoEffectsPanel] updateCocoaWindowLevel:currentStatusWindowLevel];
[[main audioEffectsPanel] updateCocoaWindowLevel:currentStatusWindowLevel]; [[main audioEffectsPanel] updateCocoaWindowLevel:currentStatusWindowLevel];
[[VLCInfo sharedInstance] updateCocoaWindowLevel:currentStatusWindowLevel]; [[main currentMediaInfoPanel] updateCocoaWindowLevel:currentStatusWindowLevel];
[[main bookmarks] updateCocoaWindowLevel:currentStatusWindowLevel]; [[main bookmarks] updateCocoaWindowLevel:currentStatusWindowLevel];
[[main trackSyncPanel] updateCocoaWindowLevel:currentStatusWindowLevel]; [[main trackSyncPanel] updateCocoaWindowLevel:currentStatusWindowLevel];
[[main resumeDialog] updateCocoaWindowLevel:currentStatusWindowLevel]; [[main resumeDialog] updateCocoaWindowLevel:currentStatusWindowLevel];
......
...@@ -74,6 +74,7 @@ static NSString * VLCInputChangedNotification = @"VLCInputChangedNotification"; ...@@ -74,6 +74,7 @@ static NSString * VLCInputChangedNotification = @"VLCInputChangedNotification";
@class VLCVideoEffects; @class VLCVideoEffects;
@class VLCConvertAndSave; @class VLCConvertAndSave;
@class ExtensionsManager; @class ExtensionsManager;
@class VLCInfo;
@interface VLCMain : NSObject <NSWindowDelegate, NSApplicationDelegate> @interface VLCMain : NSObject <NSWindowDelegate, NSApplicationDelegate>
...@@ -102,6 +103,9 @@ static NSString * VLCInputChangedNotification = @"VLCInputChangedNotification"; ...@@ -102,6 +103,9 @@ static NSString * VLCInputChangedNotification = @"VLCInputChangedNotification";
- (VLCAudioEffects *)audioEffectsPanel; - (VLCAudioEffects *)audioEffectsPanel;
- (VLCVideoEffects *)videoEffectsPanel; - (VLCVideoEffects *)videoEffectsPanel;
- (VLCInfo *)currentMediaInfoPanel;
- (VLCConvertAndSave *)convertAndSaveWindow; - (VLCConvertAndSave *)convertAndSaveWindow;
- (void)setActiveVideoPlayback:(BOOL)b_value; - (void)setActiveVideoPlayback:(BOOL)b_value;
......
...@@ -49,6 +49,7 @@ ...@@ -49,6 +49,7 @@
#import "prefs.h" #import "prefs.h"
#import "VLCPlaylist.h" #import "VLCPlaylist.h"
#import "VLCPlaylistInfo.h" #import "VLCPlaylistInfo.h"
#import "VLCPlaylistInfo.h"
#import "open.h" #import "open.h"
#import "bookmarks.h" #import "bookmarks.h"
#import "coredialogs.h" #import "coredialogs.h"
...@@ -171,6 +172,7 @@ static int ShowController(vlc_object_t *p_this, const char *psz_variable, ...@@ -171,6 +172,7 @@ static int ShowController(vlc_object_t *p_this, const char *psz_variable,
VLCVideoEffects *_videoEffectsPanel; VLCVideoEffects *_videoEffectsPanel;
VLCConvertAndSave *_convertAndSaveWindow; VLCConvertAndSave *_convertAndSaveWindow;
ExtensionsManager *_extensionsManager; ExtensionsManager *_extensionsManager;
VLCInfo *_currentMediaInfoPanel;
bool b_intf_terminating; /* Makes sure applicationWillTerminate will be called only once */ bool b_intf_terminating; /* Makes sure applicationWillTerminate will be called only once */
} }
...@@ -546,6 +548,14 @@ static VLCMain *sharedInstance = nil; ...@@ -546,6 +548,14 @@ static VLCMain *sharedInstance = nil;
return _videoEffectsPanel; return _videoEffectsPanel;
} }
- (VLCInfo *)currentMediaInfoPanel;
{
if (!_currentMediaInfoPanel)
_currentMediaInfoPanel = [[VLCInfo alloc] init];
return _currentMediaInfoPanel;
}
- (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