vlc | branch: master | Felix Paul Kühne <[email protected]> | Sat Jul 18 18:29:45 2015 +0200| [41ed8b154711992f67bd9fc64d915c91cb362327] | committer: Felix Paul Kühne
macosx/full prefs: move from explicit singleton to a functional singleton > http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=41ed8b154711992f67bd9fc64d915c91cb362327 --- .../macosx/Resources/English.lproj/Preferences.xib | 10 ++++-- modules/gui/macosx/prefs.h | 2 -- modules/gui/macosx/prefs.m | 35 ++++++++------------ 3 files changed, 20 insertions(+), 27 deletions(-) diff --git a/extras/package/macosx/Resources/English.lproj/Preferences.xib b/extras/package/macosx/Resources/English.lproj/Preferences.xib index d7d4fa6..c9db124 100644 --- a/extras/package/macosx/Resources/English.lproj/Preferences.xib +++ b/extras/package/macosx/Resources/English.lproj/Preferences.xib @@ -10,7 +10,7 @@ <connections> <outlet property="cancelButton" destination="1543" id="xKX-e8-dhh"/> <outlet property="prefsView" destination="1537" id="Yv9-bn-gFQ"/> - <outlet property="prefsWindow" destination="1530" id="34m-Dr-em4"/> + <outlet property="prefsWindow" destination="1530" id="GrB-uU-B7B"/> <outlet property="resetButton" destination="1542" id="2QZ-tp-Blv"/> <outlet property="saveButton" destination="1541" id="Ng1-aE-PqI"/> <outlet property="showBasicButton" destination="3642" id="E0I-T2-hF5"/> @@ -19,7 +19,7 @@ </connections> </customObject> <customObject id="-1" userLabel="First Responder" customClass="FirstResponder"/> - <customObject id="-3" userLabel="Application"/> + <customObject id="-3" userLabel="Application" customClass="NSObject"/> <window title="Preferences" allowsToolTipsWhenApplicationIsInactive="NO" autorecalculatesKeyViewLoop="NO" releasedWhenClosed="NO" visibleAtLaunch="NO" frameAutosaveName="prefs" animationBehavior="default" id="1530" userLabel="Com. Preferences" customClass="NSPanel"> <windowStyleMask key="styleMask" titled="YES" resizable="YES"/> <windowPositionMask key="initialPositionMask" leftStrut="YES" rightStrut="YES" topStrut="YES" bottomStrut="YES"/> @@ -42,7 +42,7 @@ <autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/> <subviews> <outlineView verticalHuggingPriority="750" allowsExpansionToolTips="YES" columnReordering="NO" multipleSelection="NO" autosaveColumns="NO" indentationPerLevel="16" autoresizesOutlineColumn="YES" outlineTableColumn="1535" id="1534"> - <rect key="frame" x="0.0" y="0.0" width="188" height="392"/> + <rect key="frame" x="0.0" y="0.0" width="188" height="19"/> <autoresizingMask key="autoresizingMask"/> <animations/> <size key="intercellSpacing" width="3" height="2"/> @@ -63,6 +63,10 @@ <tableColumnResizingMask key="resizingMask" resizeWithTable="YES" userResizable="YES"/> </tableColumn> </tableColumns> + <connections> + <outlet property="dataSource" destination="-2" id="mjP-Y3-e81"/> + <outlet property="delegate" destination="-2" id="Wdi-xB-wsa"/> + </connections> </outlineView> </subviews> <animations/> diff --git a/modules/gui/macosx/prefs.h b/modules/gui/macosx/prefs.h index 8a4a8b6..6ee116e 100644 --- a/modules/gui/macosx/prefs.h +++ b/modules/gui/macosx/prefs.h @@ -29,8 +29,6 @@ *****************************************************************************/ @interface VLCPrefs : NSObject -+ (VLCPrefs *)sharedInstance; - @property (readwrite, weak) IBOutlet NSWindow *prefsWindow; @property (readwrite, weak) IBOutlet NSTextField *titleLabel; @property (readwrite, weak) IBOutlet NSOutlineView *tree; diff --git a/modules/gui/macosx/prefs.m b/modules/gui/macosx/prefs.m index 2880735..851b667 100644 --- a/modules/gui/macosx/prefs.m +++ b/modules/gui/macosx/prefs.m @@ -75,6 +75,7 @@ NSMutableArray *_options; NSMutableArray *_subviews; } +@property (readwrite, weak) VLCPrefs *prefsViewController; - (id)initWithName:(NSString*)name; @@ -84,7 +85,7 @@ - (NSString *)name; - (NSMutableArray *)children; - (NSMutableArray *)options; -- (void)showView:(NSScrollView *)prefsView; +- (void)showView; - (void)applyChanges; - (void)resetView; @@ -131,7 +132,6 @@ module_config_t * _configItem; } - (id)initWithConfigItem:(module_config_t *)configItem; - - (module_config_t *)configItem; @end @@ -147,7 +147,7 @@ @interface VLCPrefs() { - VLCTreeMainItem * _rootTreeItem; + VLCTreeMainItem *_rootTreeItem; NSView *o_emptyView; NSMutableDictionary *o_save_prefs; } @@ -155,18 +155,6 @@ @implementation VLCPrefs -+ (VLCPrefs *)sharedInstance -{ - static VLCPrefs *sharedInstance = nil; - static dispatch_once_t pred; - - dispatch_once(&pred, ^{ - sharedInstance = [VLCPrefs new]; - }); - - return sharedInstance; -} - - (void)awakeFromNib { o_emptyView = [[NSView alloc] init]; @@ -190,14 +178,14 @@ - (void)setTitle: (NSString *) o_title_name { - [_titleLabel setStringValue: o_title_name]; + [self.titleLabel setStringValue: o_title_name]; } - (void)showPrefsWithLevel:(NSInteger)iWindow_level { - [_prefsWindow setLevel: iWindow_level]; - [_prefsWindow center]; - [_prefsWindow makeKeyAndOrderFront:self]; + [self.prefsWindow setLevel: iWindow_level]; + [self.prefsWindow center]; + [self.prefsWindow makeKeyAndOrderFront:self]; [_rootTreeItem resetView]; } @@ -237,7 +225,9 @@ /* update the document view to the view of the selected tree item */ - (void)outlineViewSelectionDidChange:(NSNotification *)o_notification { - [[_tree itemAtRow:[_tree selectedRow]] showView: _prefsView]; + VLCTreeItem *treeItem = [_tree itemAtRow:[_tree selectedRow]]; + treeItem.prefsViewController = self; + [treeItem showView]; [_tree expandItem:[_tree itemAtRow:[_tree selectedRow]]]; } @@ -296,12 +286,13 @@ return _name; } -- (void)showView:(NSScrollView *)prefsView +- (void)showView { + NSScrollView *prefsView = self.prefsViewController.prefsView; NSRect s_vrc; NSView *view; - [[VLCPrefs sharedInstance] setTitle: [self name]]; + [self.prefsViewController setTitle: [self name]]; s_vrc = [[prefsView contentView] bounds]; s_vrc.size.height -= 4; view = [[NSView alloc] initWithFrame: s_vrc]; [view setAutoresizingMask: NSViewWidthSizable | NSViewMinYMargin | NSViewMaxYMargin]; _______________________________________________ vlc-commits mailing list [email protected] https://mailman.videolan.org/listinfo/vlc-commits
