macosx: Convert VLCBookmarks to NSWindowController subclass
authorDavid Fuhrmann <dfuhrmann@videolan.org>
Sun, 2 Aug 2015 09:21:02 +0000 (11:21 +0200)
committerDavid Fuhrmann <dfuhrmann@videolan.org>
Sun, 2 Aug 2015 11:26:18 +0000 (13:26 +0200)
extras/package/macosx/Resources/English.lproj/Bookmarks.xib
modules/gui/macosx/bookmarks.h
modules/gui/macosx/bookmarks.m
modules/gui/macosx/intf.m

index 23097f5..0cf7407 100644 (file)
@@ -2,7 +2,7 @@
 <archive type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="8.00">
        <data>
                <int key="IBDocument.SystemTarget">1060</int>
-               <string key="IBDocument.SystemVersion">14E46</string>
+               <string key="IBDocument.SystemVersion">14F19a</string>
                <string key="IBDocument.InterfaceBuilderVersion">7706</string>
                <string key="IBDocument.AppKitVersion">1348.17</string>
                <string key="IBDocument.HIToolboxVersion">758.70</string>
                                                                                        <string key="NSFrameSize">{392, 257}</string>
                                                                                        <reference key="NSSuperview" ref="536774820"/>
                                                                                        <reference key="NSWindow"/>
-                                                                                       <reference key="NSNextKeyView" ref="829105237"/>
+                                                                                       <reference key="NSNextKeyView" ref="529141156"/>
                                                                                        <string key="NSReuseIdentifierKey">_NS:447</string>
                                                                                        <bool key="NSEnabled">YES</bool>
                                                                                        <bool key="NSAllowsLogicalLayoutDirection">NO</bool>
                                                                        <string key="NSFrame">{{1, 260}, {377, 15}}</string>
                                                                        <reference key="NSSuperview" ref="384668170"/>
                                                                        <reference key="NSWindow"/>
-                                                                       <reference key="NSNextKeyView"/>
                                                                        <bool key="NSAllowsLogicalLayoutDirection">NO</bool>
                                                                        <string key="NSControlAction">_doScroller:</string>
                                                                        <reference key="NSControlTarget" ref="384668170"/>
                                                        <string key="NSFrame">{{126, 20}, {394, 276}}</string>
                                                        <reference key="NSSuperview" ref="638255441"/>
                                                        <reference key="NSWindow"/>
-                                                       <reference key="NSNextKeyView" ref="529141156"/>
+                                                       <reference key="NSNextKeyView" ref="536774820"/>
                                                        <string key="NSReuseIdentifierKey">_NS:443</string>
                                                        <int key="NSsFlags">133681</int>
                                                        <reference key="NSVScroller" ref="829105237"/>
                                        </object>
                                        <int key="connectionID">163</int>
                                </object>
-                               <object class="IBConnectionRecord">
-                                       <object class="IBOutletConnection" key="connection">
-                                               <string key="label">bookmarksWindow</string>
-                                               <reference key="source" ref="33654090"/>
-                                               <reference key="destination" ref="483319126"/>
-                                       </object>
-                                       <int key="connectionID">164</int>
-                               </object>
                                <object class="IBConnectionRecord">
                                        <object class="IBOutletConnection" key="connection">
                                                <string key="label">clearButton</string>
                                        </object>
                                        <int key="connectionID">183</int>
                                </object>
+                               <object class="IBConnectionRecord">
+                                       <object class="IBOutletConnection" key="connection">
+                                               <string key="label">window</string>
+                                               <reference key="source" ref="33654090"/>
+                                               <reference key="destination" ref="483319126"/>
+                                       </object>
+                                       <int key="connectionID">184</int>
+                               </object>
                        </array>
                        <object class="IBMutableOrderedSet" key="objectRecords">
                                <array key="orderedObjects">
                        <nil key="activeLocalization"/>
                        <dictionary class="NSMutableDictionary" key="localizations"/>
                        <nil key="sourceID"/>
-                       <int key="maxID">183</int>
+                       <int key="maxID">184</int>
                </object>
                <object class="IBClassDescriber" key="IBDocument.Classes">
                        <array class="NSMutableArray" key="referencedPartialClassDescriptions">
                                <object class="IBPartialClassDescription">
                                        <string key="className">VLCBookmarks</string>
-                                       <string key="superclassName">NSObject</string>
+                                       <string key="superclassName">NSWindowController</string>
                                        <dictionary class="NSMutableDictionary" key="actions">
                                                <string key="add:">id</string>
                                                <string key="clear:">id</string>
                                        </dictionary>
                                        <dictionary class="NSMutableDictionary" key="outlets">
                                                <string key="addButton">NSButton</string>
-                                               <string key="bookmarksWindow">NSWindow</string>
                                                <string key="clearButton">NSButton</string>
                                                <string key="dataTable">NSTableView</string>
                                                <string key="editBookmarksWindow">NSWindow</string>
                                                        <string key="name">addButton</string>
                                                        <string key="candidateClassName">NSButton</string>
                                                </object>
-                                               <object class="IBToOneOutletInfo" key="bookmarksWindow">
-                                                       <string key="name">bookmarksWindow</string>
-                                                       <string key="candidateClassName">NSWindow</string>
-                                               </object>
                                                <object class="IBToOneOutletInfo" key="clearButton">
                                                        <string key="name">clearButton</string>
                                                        <string key="candidateClassName">NSButton</string>
                                </object>
                        </array>
                        <array class="NSMutableArray" key="referencedPartialClassDescriptionsV3.2+">
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">BGHUDButtonCell</string>
+                                       <string key="superclassName">NSButtonCell</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">BGHUDAppKit.framework/Headers/BGHUDButtonCell.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">BGHUDLabel</string>
+                                       <string key="superclassName">NSTextField</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">BGHUDAppKit.framework/Headers/BGHUDLabel.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">BGHUDScrollView</string>
+                                       <string key="superclassName">NSScrollView</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">BGHUDAppKit.framework/Headers/BGHUDScrollView.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">BGHUDScroller</string>
+                                       <string key="superclassName">NSScroller</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">BGHUDAppKit.framework/Headers/BGHUDScroller.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">BGHUDTableView</string>
+                                       <string key="superclassName">NSTableView</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">BGHUDAppKit.framework/Headers/BGHUDTableView.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">BGHUDTextFieldCell</string>
+                                       <string key="superclassName">NSTextFieldCell</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">BGHUDAppKit.framework/Headers/BGHUDTextFieldCell.h</string>
+                                       </object>
+                               </object>
                                <object class="IBPartialClassDescription">
                                        <string key="className">NSActionCell</string>
                                        <string key="superclassName">NSCell</string>
                                                <string key="minorKey">AppKit.framework/Headers/NSButton.h</string>
                                        </object>
                                </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSButtonCell</string>
+                                       <string key="superclassName">NSActionCell</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">AppKit.framework/Headers/NSButtonCell.h</string>
+                                       </object>
+                               </object>
                                <object class="IBPartialClassDescription">
                                        <string key="className">NSCell</string>
                                        <string key="superclassName">NSObject</string>
                                                <string key="minorKey">AppKit.framework/Headers/NSResponder.h</string>
                                        </object>
                                </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSScrollView</string>
+                                       <string key="superclassName">NSView</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">AppKit.framework/Headers/NSScrollView.h</string>
+                                       </object>
+                               </object>
+                               <object class="IBPartialClassDescription">
+                                       <string key="className">NSScroller</string>
+                                       <string key="superclassName">NSControl</string>
+                                       <object class="IBClassDescriptionSource" key="sourceIdentifier">
+                                               <string key="majorKey">IBFrameworkSource</string>
+                                               <string key="minorKey">AppKit.framework/Headers/NSScroller.h</string>
+                                       </object>
+                               </object>
                                <object class="IBPartialClassDescription">
                                        <string key="className">NSTableColumn</string>
                                        <string key="superclassName">NSObject</string>
                                                <string key="minorKey">AppKit.framework/Headers/NSWindow.h</string>
                                        </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>
                </object>
                <int key="IBDocument.localizationMode">0</int>
index a38170c..78c24b3 100644 (file)
 #import "intf.h"
 #import <vlc_common.h>
 
-@interface VLCBookmarks : NSObject
+@interface VLCBookmarks : NSWindowController
 
 /* main window */
-@property (readwrite, weak) IBOutlet NSWindow *bookmarksWindow;
 @property (readwrite, weak) IBOutlet NSButton *addButton;
 @property (readwrite, weak) IBOutlet NSButton *clearButton;
 @property (readwrite, weak) IBOutlet NSButton *editButton;
index 309657d..6dc3c92 100644 (file)
  * GUI methods
  *****************************************************************************/
 
-- (void)awakeFromNib
+- (id)init
 {
-    [_bookmarksWindow setCollectionBehavior: NSWindowCollectionBehaviorFullScreenAuxiliary];
+    self = [super initWithWindowNibName:@"Bookmarks"];
+
+    return self;
+}
+
+- (void)dealloc
+{
+    if (p_old_input)
+        vlc_object_release(p_old_input);
+
+    [[NSNotificationCenter defaultCenter] removeObserver:self];
+}
+
+- (void)windowDidLoad
+{
+    [self.window setCollectionBehavior: NSWindowCollectionBehaviorFullScreenAuxiliary];
 
     _dataTable.dataSource = self;
     _dataTable.delegate = self;
@@ -59,7 +74,7 @@
     _dataTable.target = self;
 
     /* main window */
-    [_bookmarksWindow setTitle: _NS("Bookmarks")];
+    [self.window setTitle: _NS("Bookmarks")];
     [_addButton setTitle: _NS("Add")];
     [_clearButton setTitle: _NS("Clear")];
     [_editButton setTitle: _NS("Edit")];
                                                object:nil];
 }
 
-- (void)dealloc
-{
-    if (p_old_input)
-        vlc_object_release(p_old_input);
-
-    [[NSNotificationCenter defaultCenter] removeObserver:self];
-}
-
 - (void)updateCocoaWindowLevel:(NSInteger)i_level
 {
-    if (_bookmarksWindow && [_bookmarksWindow isVisible] && [_bookmarksWindow level] != i_level)
-        [_bookmarksWindow setLevel: i_level];
+    if (self.window && [self.window isVisible] && [self.window level] != i_level)
+        [self.window setLevel: i_level];
 }
 
 - (void)showBookmarks
 {
     /* show the window, called from intf.m */
-    [_bookmarksWindow displayIfNeeded];
-    [_bookmarksWindow setLevel: [[[VLCMain sharedInstance] voutController] currentStatusWindowLevel]];
-    [_bookmarksWindow makeKeyAndOrderFront:nil];
+    [self.window displayIfNeeded];
+    [self.window setLevel: [[[VLCMain sharedInstance] voutController] currentStatusWindowLevel]];
+    [self.window makeKeyAndOrderFront:nil];
 }
 
 -(void)inputChangedEvent:(NSNotification *)o_notification
     p_old_input = p_input;
     vlc_object_release(p_input);
 
-    [NSApp beginSheet: _editBookmarksWindow modalForWindow: _bookmarksWindow modalDelegate: _editBookmarksWindow didEndSelector: nil contextInfo: nil];
+    [NSApp beginSheet: _editBookmarksWindow modalForWindow: self.window modalDelegate: _editBookmarksWindow didEndSelector: nil contextInfo: nil];
 
     // Clear the bookmark list
     for (int i = 0; i < i_bookmarks; i++)
     input_thread_t * p_input = pl_CurrentInput(VLCIntf);
 
     if (!p_input) {
-        NSBeginCriticalAlertSheet(_NS("No input"), _NS("OK"), @"", @"", _bookmarksWindow, nil, nil, nil, nil, @"%@",_NS("No input found. A stream must be playing or paused for bookmarks to work."));
+        NSBeginCriticalAlertSheet(_NS("No input"), _NS("OK"), @"", @"", self.window, nil, nil, nil, nil, @"%@",_NS("No input found. A stream must be playing or paused for bookmarks to work."));
         return;
     }
     if (p_old_input != p_input) {
-        NSBeginCriticalAlertSheet(_NS("Input has changed"), _NS("OK"), @"", @"", _bookmarksWindow, nil, nil, nil, nil, @"%@",_NS("Input has changed, unable to save bookmark. Suspending playback with \"Pause\" while editing bookmarks to ensure to keep the same input."));
+        NSBeginCriticalAlertSheet(_NS("Input has changed"), _NS("OK"), @"", @"", self.window, nil, nil, nil, nil, @"%@",_NS("Input has changed, unable to save bookmark. Suspending playback with \"Pause\" while editing bookmarks to ensure to keep the same input."));
         vlc_object_release(p_input);
         return;
     }
@@ -260,12 +267,12 @@ clear:
 #warning this does not work anymore
 #if 0
     if ([_dataTable numberOfSelectedRows] < 2) {
-        NSBeginAlertSheet(_NS("Invalid selection"), _NS("OK"), @"", @"", _bookmarksWindow, nil, nil, nil, nil, @"%@",_NS("Two bookmarks have to be selected."));
+        NSBeginAlertSheet(_NS("Invalid selection"), _NS("OK"), @"", @"", self.window, nil, nil, nil, nil, @"%@",_NS("Two bookmarks have to be selected."));
         return;
     }
     input_thread_t * p_input = pl_CurrentInput(VLCIntf);
     if (!p_input) {
-        NSBeginCriticalAlertSheet(_NS("No input found"), _NS("OK"), @"", @"", _bookmarksWindow, nil, nil, nil, nil, @"%@",_NS("The stream must be playing or paused for bookmarks to work."));
+        NSBeginCriticalAlertSheet(_NS("No input found"), _NS("OK"), @"", @"", self.window, nil, nil, nil, nil, @"%@",_NS("The stream must be playing or paused for bookmarks to work."));
         return;
     }
 
index 06ac5a7..df5ef4d 100644 (file)
@@ -145,7 +145,6 @@ static int ShowController(vlc_object_t *p_this, const char *psz_variable,
     BOOL nib_prefs_loaded;      /* preferences xibfile */
     BOOL nib_sprefs_loaded;      /* simple preferences xibfile */
     BOOL nib_coredialogs_loaded; /* CoreDialogs nibfile */
-    BOOL nib_bookmarks_loaded;   /* Bookmarks nibfile */
     BOOL b_active_videoplayback;
 
     VLCMainMenu *_mainmenu;
@@ -536,9 +535,6 @@ static int ShowController(vlc_object_t *p_this, const char *psz_variable,
     if (!_bookmarks)
         _bookmarks = [[VLCBookmarks alloc] init];
 
-    if (!nib_bookmarks_loaded)
-        nib_bookmarks_loaded = [NSBundle loadNibNamed:@"Bookmarks" owner:_bookmarks];
-
     return _bookmarks;
 }