Commit d7657086 authored by David Fuhrmann's avatar David Fuhrmann

macosx: Transform AddonsManager to NSWindowController subclass

Removes singleton, fixes initialization and deletion. Renames to
AddonsWindowController.
parent 39d906ef
...@@ -347,8 +347,8 @@ ...@@ -347,8 +347,8 @@
1CCB5F521A62A724004C3E90 /* about.m in Sources */ = {isa = PBXBuildFile; fileRef = 8EE1AFA0044465080059A3A7 /* about.m */; }; 1CCB5F521A62A724004C3E90 /* about.m in Sources */ = {isa = PBXBuildFile; fileRef = 8EE1AFA0044465080059A3A7 /* about.m */; };
1CCB5F531A62A724004C3E90 /* AddonListDataSource.h in Sources */ = {isa = PBXBuildFile; fileRef = 7DF0435E1972E26A0022B534 /* AddonListDataSource.h */; }; 1CCB5F531A62A724004C3E90 /* AddonListDataSource.h in Sources */ = {isa = PBXBuildFile; fileRef = 7DF0435E1972E26A0022B534 /* AddonListDataSource.h */; };
1CCB5F541A62A724004C3E90 /* AddonListDataSource.m in Sources */ = {isa = PBXBuildFile; fileRef = 7DF0435F1972E26A0022B534 /* AddonListDataSource.m */; }; 1CCB5F541A62A724004C3E90 /* AddonListDataSource.m in Sources */ = {isa = PBXBuildFile; fileRef = 7DF0435F1972E26A0022B534 /* AddonListDataSource.m */; };
1CCB5F551A62A724004C3E90 /* AddonManager.h in Sources */ = {isa = PBXBuildFile; fileRef = 7DB65D5218ABD6380053B874 /* AddonManager.h */; }; 1CCB5F551A62A724004C3E90 /* AddonsWindowController.h in Sources */ = {isa = PBXBuildFile; fileRef = 7DB65D5218ABD6380053B874 /* AddonsWindowController.h */; };
1CCB5F561A62A724004C3E90 /* AddonManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 7DB65D5318ABD6380053B874 /* AddonManager.m */; }; 1CCB5F561A62A724004C3E90 /* AddonsWindowController.m in Sources */ = {isa = PBXBuildFile; fileRef = 7DB65D5318ABD6380053B874 /* AddonsWindowController.m */; };
1CCB5F571A62A724004C3E90 /* applescript.h in Sources */ = {isa = PBXBuildFile; fileRef = 8E6BC6F6041643860059A3A7 /* applescript.h */; }; 1CCB5F571A62A724004C3E90 /* applescript.h in Sources */ = {isa = PBXBuildFile; fileRef = 8E6BC6F6041643860059A3A7 /* applescript.h */; };
1CCB5F581A62A724004C3E90 /* applescript.m in Sources */ = {isa = PBXBuildFile; fileRef = 8E6BC6F7041643860059A3A7 /* applescript.m */; }; 1CCB5F581A62A724004C3E90 /* applescript.m in Sources */ = {isa = PBXBuildFile; fileRef = 8E6BC6F7041643860059A3A7 /* applescript.m */; };
1CCB5F591A62A724004C3E90 /* AudioEffects.h in Sources */ = {isa = PBXBuildFile; fileRef = CC5560231365CDC700D54038 /* AudioEffects.h */; }; 1CCB5F591A62A724004C3E90 /* AudioEffects.h in Sources */ = {isa = PBXBuildFile; fileRef = CC5560231365CDC700D54038 /* AudioEffects.h */; };
...@@ -1232,8 +1232,8 @@ ...@@ -1232,8 +1232,8 @@
7D8BB0B61830311300FAE9B7 /* English */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = English; path = Resources/English.lproj/DebugMessageVisualizer.xib; sourceTree = "<group>"; }; 7D8BB0B61830311300FAE9B7 /* English */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = English; path = Resources/English.lproj/DebugMessageVisualizer.xib; sourceTree = "<group>"; };
7D8BB0B91830367200FAE9B7 /* English */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = English; path = Resources/English.lproj/PlaylistMenu.xib; sourceTree = "<group>"; }; 7D8BB0B91830367200FAE9B7 /* English */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = English; path = Resources/English.lproj/PlaylistMenu.xib; sourceTree = "<group>"; };
7D8BB0BF1830393300FAE9B7 /* English */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = English; path = Resources/English.lproj/MainWindow.xib; sourceTree = "<group>"; }; 7D8BB0BF1830393300FAE9B7 /* English */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = English; path = Resources/English.lproj/MainWindow.xib; sourceTree = "<group>"; };
7DB65D5218ABD6380053B874 /* AddonManager.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = AddonManager.h; path = ../../../modules/gui/macosx/AddonManager.h; sourceTree = SOURCE_ROOT; }; 7DB65D5218ABD6380053B874 /* AddonsWindowController.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = AddonsWindowController.h; path = ../../../modules/gui/macosx/AddonsWindowController.h; sourceTree = SOURCE_ROOT; };
7DB65D5318ABD6380053B874 /* AddonManager.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; name = AddonManager.m; path = ../../../modules/gui/macosx/AddonManager.m; sourceTree = SOURCE_ROOT; }; 7DB65D5318ABD6380053B874 /* AddonsWindowController.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; name = AddonsWindowController.m; path = ../../../modules/gui/macosx/AddonsWindowController.m; sourceTree = SOURCE_ROOT; };
7DB65D5518ABD6490053B874 /* English */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = English; path = Resources/English.lproj/AddonManager.xib; sourceTree = "<group>"; }; 7DB65D5518ABD6490053B874 /* English */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = English; path = Resources/English.lproj/AddonManager.xib; sourceTree = "<group>"; };
7DE88F291831396A00CD9DA2 /* English */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = English; path = Resources/English.lproj/PlaylistAccessoryView.xib; sourceTree = "<group>"; }; 7DE88F291831396A00CD9DA2 /* English */ = {isa = PBXFileReference; lastKnownFileType = file.xib; name = English; path = Resources/English.lproj/PlaylistAccessoryView.xib; sourceTree = "<group>"; };
7DF0435E1972E26A0022B534 /* AddonListDataSource.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = AddonListDataSource.h; path = ../../../modules/gui/macosx/AddonListDataSource.h; sourceTree = SOURCE_ROOT; }; 7DF0435E1972E26A0022B534 /* AddonListDataSource.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = AddonListDataSource.h; path = ../../../modules/gui/macosx/AddonListDataSource.h; sourceTree = SOURCE_ROOT; };
...@@ -1811,8 +1811,8 @@ ...@@ -1811,8 +1811,8 @@
8EE1AFA0044465080059A3A7 /* about.m */, 8EE1AFA0044465080059A3A7 /* about.m */,
7DF0435E1972E26A0022B534 /* AddonListDataSource.h */, 7DF0435E1972E26A0022B534 /* AddonListDataSource.h */,
7DF0435F1972E26A0022B534 /* AddonListDataSource.m */, 7DF0435F1972E26A0022B534 /* AddonListDataSource.m */,
7DB65D5218ABD6380053B874 /* AddonManager.h */, 7DB65D5218ABD6380053B874 /* AddonsWindowController.h */,
7DB65D5318ABD6380053B874 /* AddonManager.m */, 7DB65D5318ABD6380053B874 /* AddonsWindowController.m */,
8E6BC6F6041643860059A3A7 /* applescript.h */, 8E6BC6F6041643860059A3A7 /* applescript.h */,
8E6BC6F7041643860059A3A7 /* applescript.m */, 8E6BC6F7041643860059A3A7 /* applescript.m */,
CC5560231365CDC700D54038 /* AudioEffects.h */, CC5560231365CDC700D54038 /* AudioEffects.h */,
...@@ -3745,8 +3745,8 @@ ...@@ -3745,8 +3745,8 @@
1CCB5F521A62A724004C3E90 /* about.m in Sources */, 1CCB5F521A62A724004C3E90 /* about.m in Sources */,
1CCB5F531A62A724004C3E90 /* AddonListDataSource.h in Sources */, 1CCB5F531A62A724004C3E90 /* AddonListDataSource.h in Sources */,
1CCB5F541A62A724004C3E90 /* AddonListDataSource.m in Sources */, 1CCB5F541A62A724004C3E90 /* AddonListDataSource.m in Sources */,
1CCB5F551A62A724004C3E90 /* AddonManager.h in Sources */, 1CCB5F551A62A724004C3E90 /* AddonsWindowController.h in Sources */,
1CCB5F561A62A724004C3E90 /* AddonManager.m in Sources */, 1CCB5F561A62A724004C3E90 /* AddonsWindowController.m in Sources */,
1CCB5F571A62A724004C3E90 /* applescript.h in Sources */, 1CCB5F571A62A724004C3E90 /* applescript.h in Sources */,
1CCB5F581A62A724004C3E90 /* applescript.m in Sources */, 1CCB5F581A62A724004C3E90 /* applescript.m in Sources */,
1CCB5F591A62A724004C3E90 /* AudioEffects.h in Sources */, 1CCB5F591A62A724004C3E90 /* AudioEffects.h in Sources */,
......
...@@ -21,9 +21,8 @@ ...@@ -21,9 +21,8 @@
#import <Cocoa/Cocoa.h> #import <Cocoa/Cocoa.h>
@interface VLCAddonManager : NSObject <NSTableViewDataSource, NSTableViewDelegate> @interface AddonsWindowController : NSWindowController <NSTableViewDataSource, NSTableViewDelegate>
{ {
IBOutlet NSWindow *_window;
IBOutlet NSPopUpButton *_typeSwitcher; IBOutlet NSPopUpButton *_typeSwitcher;
IBOutlet NSButton *_localAddonsOnlyCheckbox; IBOutlet NSButton *_localAddonsOnlyCheckbox;
IBOutlet NSButton *_downloadCatalogButton; IBOutlet NSButton *_downloadCatalogButton;
...@@ -37,9 +36,7 @@ ...@@ -37,9 +36,7 @@
IBOutlet NSButton *_installButton; IBOutlet NSButton *_installButton;
} }
+ (VLCAddonManager *)sharedInstance;
- (void)showWindow;
- (IBAction)switchType:(id)sender; - (IBAction)switchType:(id)sender;
- (IBAction)toggleLocalCheckbox:(id)sender; - (IBAction)toggleLocalCheckbox:(id)sender;
- (IBAction)downloadCatalog:(id)sender; - (IBAction)downloadCatalog:(id)sender;
......
...@@ -23,12 +23,12 @@ ...@@ -23,12 +23,12 @@
#import <vlc_events.h> #import <vlc_events.h>
#import <vlc_addons.h> #import <vlc_addons.h>
#import "AddonManager.h" #import "AddonsWindowController.h"
#import "intf.h" #import "intf.h"
#import "MainWindow.h" #import "MainWindow.h"
#import "AddonListDataSource.h" #import "AddonListDataSource.h"
@interface VLCAddonManager () @interface AddonsWindowController()
{ {
addons_manager_t *_manager; addons_manager_t *_manager;
NSMutableArray *_addons; NSMutableArray *_addons;
...@@ -39,55 +39,50 @@ ...@@ -39,55 +39,50 @@
- (void)addAddon:(NSValue *)o_value; - (void)addAddon:(NSValue *)o_value;
- (void)discoveryEnded; - (void)discoveryEnded;
- (void)addonChanged:(NSValue *)o_value; - (void)addonChanged:(NSValue *)o_value;
@end @end
static void addonsEventsCallback( const vlc_event_t *event, void *data ) static void addonsEventsCallback( const vlc_event_t *event, void *data )
{ {
AddonsWindowController *controller = data;
@autoreleasepool { @autoreleasepool {
if (event->type == vlc_AddonFound) if (event->type == vlc_AddonFound)
[[VLCAddonManager sharedInstance] performSelectorOnMainThread:@selector(addAddon:) withObject:[NSValue valueWithPointer:event->u.addon_generic_event.p_entry] waitUntilDone:NO]; [controller performSelectorOnMainThread:@selector(addAddon:) withObject:[NSValue valueWithPointer:event->u.addon_generic_event.p_entry] waitUntilDone:NO];
else if (event->type == vlc_AddonsDiscoveryEnded) else if (event->type == vlc_AddonsDiscoveryEnded)
[[VLCAddonManager sharedInstance] performSelectorOnMainThread:@selector(discoveryEnded) withObject:nil waitUntilDone:NO]; [controller performSelectorOnMainThread:@selector(discoveryEnded) withObject:nil waitUntilDone:NO];
else if (event->type == vlc_AddonChanged) else if (event->type == vlc_AddonChanged)
[[VLCAddonManager sharedInstance] performSelectorOnMainThread:@selector(addonChanged:) withObject:[NSValue valueWithPointer:event->u.addon_generic_event.p_entry] waitUntilDone:NO]; [controller performSelectorOnMainThread:@selector(addonChanged:) withObject:[NSValue valueWithPointer:event->u.addon_generic_event.p_entry] waitUntilDone:NO];
} }
} }
@implementation VLCAddonManager @implementation AddonsWindowController
static VLCAddonManager *_o_sharedInstance = nil;
+ (VLCAddonManager *)sharedInstance
{
return _o_sharedInstance ? _o_sharedInstance : [[self alloc] init];
}
#pragma mark - object handling #pragma mark - object handling
- (id)init - (id)init
{ {
if (_o_sharedInstance) self = [super initWithWindowNibName:@"AddonManager"];
[self dealloc]; if (self) {
else { [self setWindowFrameAutosaveName:@"addons"];
_o_sharedInstance = [super init];
_addons = [[NSMutableArray alloc] init]; _addons = [[NSMutableArray alloc] init];
} }
return _o_sharedInstance; return self;
} }
- (void)dealloc - (void)dealloc
{ {
[_addons release]; [_addons release];
[_displayedAddons release]; [_displayedAddons release];
if ( _manager ) if (_manager)
addons_manager_Delete(_manager); addons_manager_Delete(_manager);
[super dealloc]; [super dealloc];
} }
#pragma mark - UI handling #pragma mark - UI handling
- (void)awakeFromNib - (void)windowDidLoad
{ {
[_typeSwitcher removeAllItems]; [_typeSwitcher removeAllItems];
[_typeSwitcher addItemWithTitle:_NS("All")]; [_typeSwitcher addItemWithTitle:_NS("All")];
...@@ -118,8 +113,7 @@ static VLCAddonManager *_o_sharedInstance = nil; ...@@ -118,8 +113,7 @@ static VLCAddonManager *_o_sharedInstance = nil;
[_author setStringValue:@""]; [_author setStringValue:@""];
[_version setStringValue:@""]; [_version setStringValue:@""];
[_description setString:@""]; [_description setString:@""];
[_window setTitle:_NS("Addons Manager")]; [[self window] setTitle:_NS("Addons Manager")];
[_window setReleasedWhenClosed:NO];
[[[_addonsTable tableColumnWithIdentifier:@"installed"] headerCell] setStringValue:_NS("Installed")]; [[[_addonsTable tableColumnWithIdentifier:@"installed"] headerCell] setStringValue:_NS("Installed")];
[[[_addonsTable tableColumnWithIdentifier:@"name"] headerCell] setStringValue:_NS("Name")]; [[[_addonsTable tableColumnWithIdentifier:@"name"] headerCell] setStringValue:_NS("Name")];
...@@ -138,11 +132,6 @@ static VLCAddonManager *_o_sharedInstance = nil; ...@@ -138,11 +132,6 @@ static VLCAddonManager *_o_sharedInstance = nil;
[self _findInstalled]; [self _findInstalled];
} }
- (void)showWindow
{
[_window makeKeyAndOrderFront:nil];
}
- (IBAction)switchType:(id)sender - (IBAction)switchType:(id)sender
{ {
[self _refactorDataModel]; [self _refactorDataModel];
......
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
#import <vlc_interface.h> #import <vlc_interface.h>
@class AboutWindowController; @class AboutWindowController;
@class AddonsWindowController;
@class HelpWindowController; @class HelpWindowController;
@interface VLCMainMenu : NSObject @interface VLCMainMenu : NSObject
...@@ -37,7 +38,6 @@ ...@@ -37,7 +38,6 @@
BOOL b_nib_tracksynchro_loaded; BOOL b_nib_tracksynchro_loaded;
BOOL b_nib_bookmarks_loaded; BOOL b_nib_bookmarks_loaded;
BOOL b_nib_convertandsave_loaded; BOOL b_nib_convertandsave_loaded;
BOOL b_nib_addonmanager_loaded;
AboutWindowController *o_about; AboutWindowController *o_about;
HelpWindowController *o_helpWin; HelpWindowController *o_helpWin;
...@@ -46,7 +46,7 @@ ...@@ -46,7 +46,7 @@
id o_trackSynchronization; /* VLCTrackSynchronization */ id o_trackSynchronization; /* VLCTrackSynchronization */
id o_bookmarks; /* VLCBookmarks */ id o_bookmarks; /* VLCBookmarks */
id o_convertandsave; /* VLCConvertAndSave */ id o_convertandsave; /* VLCConvertAndSave */
id o_addonManager; /* VLCAddonManager */ AddonsWindowController *o_addonsController;
id o_extMgr; /* Extensions Manager */ id o_extMgr; /* Extensions Manager */
......
...@@ -47,7 +47,7 @@ ...@@ -47,7 +47,7 @@
#import "ExtensionsManager.h" #import "ExtensionsManager.h"
#import "ConvertAndSave.h" #import "ConvertAndSave.h"
#import "DebugMessageVisualizer.h" #import "DebugMessageVisualizer.h"
#import "AddonManager.h" #import "AddonsWindowController.h"
@implementation VLCMainMenu @implementation VLCMainMenu
static VLCMainMenu *_o_sharedInstance = nil; static VLCMainMenu *_o_sharedInstance = nil;
...@@ -97,6 +97,8 @@ static VLCMainMenu *_o_sharedInstance = nil; ...@@ -97,6 +97,8 @@ static VLCMainMenu *_o_sharedInstance = nil;
[o_about release]; [o_about release];
[o_helpWin release]; [o_helpWin release];
[o_addonsController release];
if (b_nib_videoeffects_loaded) if (b_nib_videoeffects_loaded)
[o_videoeffects release]; [o_videoeffects release];
...@@ -1172,13 +1174,10 @@ static VLCMainMenu *_o_sharedInstance = nil; ...@@ -1172,13 +1174,10 @@ static VLCMainMenu *_o_sharedInstance = nil;
- (IBAction)openAddonManager:(id)sender - (IBAction)openAddonManager:(id)sender
{ {
if (!o_addonManager) if (!o_addonsController)
o_addonManager = [[VLCAddonManager alloc] init]; o_addonsController = [[AddonsWindowController alloc] init];
if (!b_nib_addonmanager_loaded)
b_nib_addonmanager_loaded = [NSBundle loadNibNamed:@"AddonManager" owner:NSApp];
[o_addonManager showWindow]; [o_addonsController showWindow:self];
} }
- (IBAction)showMessagesPanel:(id)showMessagesPanel - (IBAction)showMessagesPanel:(id)showMessagesPanel
......
...@@ -20,8 +20,8 @@ SOURCES_macosx = \ ...@@ -20,8 +20,8 @@ SOURCES_macosx = \
ExtensionsManager.m \ ExtensionsManager.m \
ExtensionsDialogProvider.h \ ExtensionsDialogProvider.h \
ExtensionsDialogProvider.m \ ExtensionsDialogProvider.m \
AddonManager.h \ AddonsWindowController.h \
AddonManager.m \ AddonsWindowController.m \
AddonListDataSource.h \ AddonListDataSource.h \
AddonListDataSource.m \ AddonListDataSource.m \
VLCUIWidgets.h \ VLCUIWidgets.h \
......
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