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