]> git.sesse.net Git - vlc/commitdiff
macosx: added menu item and advanced option to hide the main window's sidebar
authorFelix Paul Kühne <fkuehne@videolan.org>
Wed, 26 Dec 2012 17:35:46 +0000 (18:35 +0100)
committerFelix Paul Kühne <fkuehne@videolan.org>
Wed, 26 Dec 2012 17:36:09 +0000 (18:36 +0100)
extras/package/macosx/Resources/English.lproj/MainMenu.xib
modules/gui/macosx/MainMenu.h
modules/gui/macosx/MainMenu.m
modules/gui/macosx/MainWindow.h
modules/gui/macosx/MainWindow.m
modules/gui/macosx/macosx.m

index 3a4805a630848c3af46ad212790c31c830991cdd..8172d60bf43cade1c471505e37924e38ddc525fe 100644 (file)
     </object>
     <object class="NSMutableArray" key="IBDocument.EditedObjectIDs">
       <bool key="EncodedWithXMLCoder">YES</bool>
-      <integer value="5132"/>
-      <integer value="5260"/>
       <integer value="2730"/>
       <integer value="4850"/>
+      <integer value="5238"/>
+      <integer value="5260"/>
+      <integer value="2"/>
     </object>
     <object class="NSArray" key="IBDocument.PluginDependencies">
       <bool key="EncodedWithXMLCoder">YES</bool>
@@ -57,7 +58,7 @@
         <nil key="NSUserInterfaceItemIdentifier"/>
         <string key="NSWindowContentMaxSize">{1.7976931348623157e+308, 1.7976931348623157e+308}</string>
         <object class="NSView" key="NSWindowView" id="429932428">
-          <nil key="NSNextResponder"/>
+          <reference key="NSNextResponder"/>
           <int key="NSvFlags">256</int>
           <object class="NSMutableArray" key="NSSubviews">
             <bool key="EncodedWithXMLCoder">YES</bool>
                           </object>
                           <string key="NSFrame">{{1, 1}, {199, 272}}</string>
                           <reference key="NSSuperview" ref="979766179"/>
+                          <reference key="NSNextKeyView" ref="1064884668"/>
                           <reference key="NSDocView" ref="1064884668"/>
                           <reference key="NSBGColor" ref="885475112"/>
                           <int key="NScvFlags">4</int>
                       </object>
                       <string key="NSFrameSize">{201, 274}</string>
                       <reference key="NSSuperview" ref="824340487"/>
+                      <reference key="NSNextKeyView" ref="18556274"/>
                       <int key="NSsFlags">133650</int>
                       <reference key="NSVScroller" ref="252983915"/>
                       <reference key="NSHScroller" ref="11557666"/>
                           </object>
                           <string key="NSFrame">{{1, 17}, {402, 236}}</string>
                           <reference key="NSSuperview" ref="915491793"/>
+                          <reference key="NSNextKeyView" ref="23448837"/>
                           <reference key="NSDocView" ref="23448837"/>
                           <reference key="NSBGColor" ref="885475112"/>
                           <int key="NScvFlags">4</int>
                           </object>
                           <string key="NSFrame">{{1, 0}, {402, 17}}</string>
                           <reference key="NSSuperview" ref="915491793"/>
+                          <reference key="NSNextKeyView" ref="823165105"/>
                           <reference key="NSDocView" ref="823165105"/>
                           <reference key="NSBGColor" ref="885475112"/>
                           <int key="NScvFlags">4</int>
                       </object>
                       <string key="NSFrameSize">{404, 254}</string>
                       <reference key="NSSuperview" ref="440594360"/>
+                      <reference key="NSNextKeyView" ref="343242432"/>
                       <int key="NSsFlags">133682</int>
                       <reference key="NSVScroller" ref="573737110"/>
                       <reference key="NSHScroller" ref="297523533"/>
             </object>
           </object>
           <string key="NSFrameSize">{604, 310}</string>
+          <reference key="NSSuperview"/>
         </object>
         <string key="NSScreenRect">{{0, 0}, {1280, 778}}</string>
         <string key="NSMaxSize">{1.7976931348623157e+308, 1.7976931348623157e+308}</string>
                   <reference key="NSOnImage" ref="447396056"/>
                   <reference key="NSMixedImage" ref="100133332"/>
                 </object>
+                <object class="NSMenuItem" id="35710136">
+                  <reference key="NSMenu" ref="815243229"/>
+                  <string key="NSTitle">Show Sidebar</string>
+                  <string key="NSKeyEquiv"/>
+                  <int key="NSMnemonicLoc">2147483647</int>
+                  <reference key="NSOnImage" ref="447396056"/>
+                  <reference key="NSMixedImage" ref="100133332"/>
+                </object>
                 <object class="NSMenuItem" id="710935977">
                   <reference key="NSMenu" ref="815243229"/>
                   <bool key="NSIsDisabled">YES</bool>
@@ -7938,6 +7953,22 @@ LCAuLi4</string>
           </object>
           <int key="connectionID">5412</int>
         </object>
+        <object class="IBConnectionRecord">
+          <object class="IBOutletConnection" key="connection">
+            <string key="label">o_mi_toggleSidebar</string>
+            <reference key="source" ref="651263286"/>
+            <reference key="destination" ref="35710136"/>
+          </object>
+          <int key="connectionID">5415</int>
+        </object>
+        <object class="IBConnectionRecord">
+          <object class="IBActionConnection" key="connection">
+            <string key="label">toggleSidebar:</string>
+            <reference key="source" ref="651263286"/>
+            <reference key="destination" ref="35710136"/>
+          </object>
+          <int key="connectionID">5416</int>
+        </object>
       </object>
       <object class="IBMutableOrderedSet" key="objectRecords">
         <object class="NSArray" key="orderedObjects">
@@ -10682,6 +10713,7 @@ LCAuLi4</string>
               <reference ref="709859089"/>
               <reference ref="710935977"/>
               <reference ref="338106467"/>
+              <reference ref="35710136"/>
             </object>
             <reference key="parent" ref="939296045"/>
           </object>
@@ -11041,6 +11073,11 @@ LCAuLi4</string>
             <reference key="object" ref="634067619"/>
             <reference key="parent" ref="1056513052"/>
           </object>
+          <object class="IBObjectRecord">
+            <int key="objectID">5413</int>
+            <reference key="object" ref="35710136"/>
+            <reference key="parent" ref="815243229"/>
+          </object>
         </object>
       </object>
       <object class="NSMutableDictionary" key="flattenedProperties">
@@ -11856,6 +11893,7 @@ LCAuLi4</string>
           <string>5335.IBViewBoundsToFrameTransform</string>
           <string>5339.IBPluginDependency</string>
           <string>5409.IBPluginDependency</string>
+          <string>5413.IBPluginDependency</string>
           <string>56.IBPluginDependency</string>
           <string>56.ImportedFromIB2</string>
           <string>57.IBEditorWindowLastContentRect</string>
@@ -12249,7 +12287,7 @@ LCAuLi4</string>
           <boolean value="YES"/>
           <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
           <boolean value="YES"/>
-          <string>{{762, 736}, {518, 20}}</string>
+          <string>{{487, 663}, {518, 20}}</string>
           <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
           <boolean value="YES"/>
           <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
@@ -12714,7 +12752,7 @@ LCAuLi4</string>
           <boolean value="YES"/>
           <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
           <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
-          <string>{{616, 901}, {260, 73}}</string>
+          <string>{{631, 570}, {260, 93}}</string>
           <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
           <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
           <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
@@ -12828,6 +12866,7 @@ LCAuLi4</string>
           <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
           <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
           <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
+          <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
           <boolean value="YES"/>
           <string>{{329, 186}, {267, 263}}</string>
           <string>com.apple.InterfaceBuilder.CocoaPlugin</string>
@@ -12884,7 +12923,7 @@ LCAuLi4</string>
         </object>
       </object>
       <nil key="sourceID"/>
-      <int key="maxID">5412</int>
+      <int key="maxID">5416</int>
     </object>
     <object class="IBClassDescriber" key="IBDocument.Classes">
       <object class="NSMutableArray" key="referencedPartialClassDescriptions">
@@ -15970,6 +16009,7 @@ LCAuLi4</string>
               <string>togglePlaylistColumnTable:</string>
               <string>togglePlaymodeButtons:</string>
               <string>toggleRecord:</string>
+              <string>toggleSidebar:</string>
               <string>toggleVar:</string>
               <string>viewAbout:</string>
               <string>viewErrorsAndWarnings:</string>
@@ -16012,6 +16052,7 @@ LCAuLi4</string>
               <string>id</string>
               <string>id</string>
               <string>id</string>
+              <string>id</string>
             </object>
           </object>
           <object class="NSMutableDictionary" key="actionInfosByName">
@@ -16047,6 +16088,7 @@ LCAuLi4</string>
               <string>togglePlaylistColumnTable:</string>
               <string>togglePlaymodeButtons:</string>
               <string>toggleRecord:</string>
+              <string>toggleSidebar:</string>
               <string>toggleVar:</string>
               <string>viewAbout:</string>
               <string>viewErrorsAndWarnings:</string>
@@ -16171,6 +16213,10 @@ LCAuLi4</string>
                 <string key="name">toggleRecord:</string>
                 <string key="candidateClassName">id</string>
               </object>
+              <object class="IBActionInfo">
+                <string key="name">toggleSidebar:</string>
+                <string key="candidateClassName">id</string>
+              </object>
               <object class="IBActionInfo">
                 <string key="name">toggleVar:</string>
                 <string key="candidateClassName">id</string>
@@ -16299,6 +16345,7 @@ LCAuLi4</string>
               <string>o_mi_title</string>
               <string>o_mi_toggleJumpButtons</string>
               <string>o_mi_togglePlaymodeButtons</string>
+              <string>o_mi_toggleSidebar</string>
               <string>o_mi_trackSynchronization</string>
               <string>o_mi_videoeffects</string>
               <string>o_mi_videotrack</string>
@@ -16456,6 +16503,7 @@ LCAuLi4</string>
               <string>NSMenuItem</string>
               <string>NSMenuItem</string>
               <string>NSMenuItem</string>
+              <string>NSMenuItem</string>
               <string>NSMenu</string>
               <string>NSMenu</string>
               <string>NSMenu</string>
@@ -16602,6 +16650,7 @@ LCAuLi4</string>
               <string>o_mi_title</string>
               <string>o_mi_toggleJumpButtons</string>
               <string>o_mi_togglePlaymodeButtons</string>
+              <string>o_mi_toggleSidebar</string>
               <string>o_mi_trackSynchronization</string>
               <string>o_mi_videoeffects</string>
               <string>o_mi_videotrack</string>
@@ -17058,6 +17107,10 @@ LCAuLi4</string>
                 <string key="name">o_mi_togglePlaymodeButtons</string>
                 <string key="candidateClassName">NSMenuItem</string>
               </object>
+              <object class="IBToOneOutletInfo">
+                <string key="name">o_mi_toggleSidebar</string>
+                <string key="candidateClassName">NSMenuItem</string>
+              </object>
               <object class="IBToOneOutletInfo">
                 <string key="name">o_mi_trackSynchronization</string>
                 <string key="candidateClassName">NSMenuItem</string>
index ace9c0fd3ef8410e81c4e8edad84e2a978b1edc8..6f8e80520c41dae73500a45e93f5e9645a106d95 100644 (file)
@@ -80,6 +80,7 @@
     IBOutlet NSMenu * o_mu_view;
     IBOutlet NSMenuItem * o_mi_toggleJumpButtons;
     IBOutlet NSMenuItem * o_mi_togglePlaymodeButtons;
+    IBOutlet NSMenuItem * o_mi_toggleSidebar;
     IBOutlet NSMenu * o_mu_playlistTableColumns;
     NSMenu * o_mu_playlistTableColumnsContextMenu;
 
 - (void)setSubmenusEnabled:(BOOL)b_enabled;
 - (void)setRateControlsEnabled:(BOOL)b_enabled;
 - (void)setupExtensionsMenu;
+- (void)updateSidebarMenuItem;
 
 - (IBAction)intfOpenFile:(id)sender;
 - (IBAction)intfOpenFileGeneric:(id)sender;
 
 - (IBAction)toggleJumpButtons:(id)sender;
 - (IBAction)togglePlaymodeButtons:(id)sender;
+- (IBAction)toggleSidebar:(id)sender;
 - (IBAction)togglePlaylistColumnTable:(id)sender;
 - (void)setPlaylistColumnTableState:(NSInteger)i_state forColumn:(NSString *)o_column;
 - (NSMenu *)setupPlaylistTableColumnsMenu;
index df3a74fe910f4c027cb2f3b737ccac999348d672..401ad1ff64a165ad41d53306e3f58dde752622e9 100644 (file)
@@ -302,6 +302,8 @@ static VLCMainMenu *_o_sharedInstance = nil;
     [o_mi_toggleJumpButtons setState: config_GetInt(VLCIntf, "macosx-show-playback-buttons")];
     [o_mi_togglePlaymodeButtons setTitle: _NS("Show Shuffle & Repeat Buttons")];
     [o_mi_togglePlaymodeButtons setState: config_GetInt(VLCIntf, "macosx-show-playmode-buttons")];
+    [o_mi_toggleSidebar setTitle: _NS("Show Sidebar")];
+    [o_mi_toggleSidebar setState: config_GetInt(VLCIntf, "macosx-show-sidebar")];
     [o_mu_playlistTableColumns setTitle: _NS("Playlist Table Columns")];
 
     [o_mu_controls setTitle: _NS("Playback")];
@@ -647,6 +649,19 @@ static VLCMainMenu *_o_sharedInstance = nil;
     [o_mi_togglePlaymodeButtons setState: b_value];
 }
 
+- (IBAction)toggleSidebar:(id)sender
+{
+    BOOL b_value = !config_GetInt(VLCIntf, "macosx-show-sidebar");
+    config_PutInt(VLCIntf, "macosx-show-sidebar", b_value);
+    [[[VLCMain sharedInstance] mainWindow] toggleLeftSubSplitView];
+    [o_mi_toggleSidebar setState: b_value];
+}
+
+- (void)updateSidebarMenuItem
+{
+    [o_mi_toggleSidebar setState: config_GetInt(VLCIntf, "macosx-show-sidebar")];
+}
+
 - (IBAction)togglePlaylistColumnTable:(id)sender
 {
     NSInteger i_new_state = ![sender state];
index c0043345b6ee689c5efae4c54c2fede4affea308..a5192c93fdeb8ee422711f7348542229fef51dbb 100644 (file)
@@ -44,7 +44,7 @@
 @interface VLCMainWindow : VLCVideoWindowCommon <PXSourceListDataSource, PXSourceListDelegate, NSWindowDelegate, NSAnimationDelegate, NSSplitViewDelegate> {
 
     IBOutlet id o_search_fld;
-    
+
     IBOutlet id o_playlist_table;
     IBOutlet id o_split_view;
     IBOutlet id o_left_split_view;
@@ -82,7 +82,8 @@
     BOOL b_splitview_removed;
     BOOL b_minimized_view;
 
-    int i_lastSplitViewHeight;
+    NSUInteger i_lastSplitViewHeight;
+    NSUInteger i_lastLeftSplitViewWidth;
 
     NSMutableArray *o_sidebaritems;
 
 
 - (void)windowResizedOrMoved:(NSNotification *)notification;
 
+- (void)toggleLeftSubSplitView;
 - (void)showDropZone;
 - (void)hideDropZone;
 - (void)showSplitView;
     VLCColorView * o_color_backdrop;
 }
 
-@end
\ No newline at end of file
+@end
index d7b6075f70b4a12c2f9d397b3f440c5051473aa3..3550610a5a9e878733d409309b180b7f99ebb827 100644 (file)
@@ -370,8 +370,8 @@ static VLCMainWindow *_o_sharedInstance = nil;
     [[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(someWindowWillClose:) name: NSWindowWillCloseNotification object: nil];
     [[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(someWindowWillMiniaturize:) name: NSWindowWillMiniaturizeNotification object:nil];
     [[NSNotificationCenter defaultCenter] addObserver: self selector: @selector(applicationWillTerminate:) name: NSApplicationWillTerminateNotification object: nil];
+    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(mainSplitViewWillResizeSubviews:) name:NSSplitViewWillResizeSubviewsNotification object:o_split_view];
 
-    [o_split_view setAutosaveName:@"10thanniversary-splitview"];
     if (b_splitviewShouldBeHidden) {
         [self hideSplitView];
         i_lastSplitViewHeight = 300;
@@ -385,13 +385,19 @@ static VLCMainWindow *_o_sharedInstance = nil;
         [self resizeWindow];
     }
 
-    // update fs button to reflect state for next startup
-    if (var_InheritBool(pl_Get(VLCIntf), "fullscreen")) {
+    /* update fs button to reflect state for next startup */
+    if (var_InheritBool(pl_Get(VLCIntf), "fullscreen"))
         [o_controls_bar setFullscreenState:YES];
-    }
+
+    /* restore split view */
+    i_lastLeftSplitViewWidth = 200;
+    /* trick NSSplitView implementation, which pretends to know better than us */
+    if (!config_GetInt(VLCIntf, "macosx-show-sidebar"))
+        [self performSelector:@selector(toggleLeftSubSplitView) withObject:nil afterDelay:0.05];
 }
 
 #pragma mark -
+#pragma mark appearance management
 
 - (VLCMainWindowControlsBar *)controlsBar;
 {
@@ -518,6 +524,8 @@ static VLCMainWindow *_o_sharedInstance = nil;
 
 - (void)applicationWillTerminate:(NSNotification *)notification
 {
+    config_PutInt(VLCIntf, "macosx-show-sidebar", ![o_split_view isSubviewCollapsed:o_left_split_view]);
+
     [self saveFrameUsingName: [self frameAutosaveName]];
 }
 
@@ -959,6 +967,22 @@ static VLCMainWindow *_o_sharedInstance = nil;
     return YES;
 }
 
+- (void)mainSplitViewWillResizeSubviews:(id)object
+{
+    i_lastLeftSplitViewWidth = [o_left_split_view frame].size.width;
+    config_PutInt(VLCIntf, "macosx-show-sidebar", ![o_split_view isSubviewCollapsed:o_left_split_view]);
+    [[[VLCMain sharedInstance] mainMenu] updateSidebarMenuItem];
+}
+
+- (void)toggleLeftSubSplitView
+{
+    [o_split_view adjustSubviews];
+    if ([o_split_view isSubviewCollapsed:o_left_split_view])
+        [o_split_view setPosition:i_lastLeftSplitViewWidth ofDividerAtIndex:0];
+    else
+        [o_split_view setPosition:[o_split_view minPossiblePositionOfDividerAtIndex:0] ofDividerAtIndex:0];
+}
+
 #pragma mark -
 #pragma mark Side Bar Data handling
 /* taken under BSD-new from the PXSourceList sample project, adapted for VLC */
index da66e60c6aefe17503a80ab0f88bf0aee2b8c2e7..b4472444163922b8e47217586adef1da7f80b760 100644 (file)
@@ -116,6 +116,9 @@ void WindowClose  (vout_window_t *);
 #define PLAYMODEBUTTONS_TEXT N_("Show play mode control buttons")
 #define PLAYMODEBUTTONS_LONGTEXT N_("Shows the shuffle and repeat buttons in the main window")
 
+#define SIDEBAR_TEXT N_("Show sidebar")
+#define SIDEBAR_LONGTEXT N_("Shows a sidebar in the main window listing media sources")
+
 vlc_module_begin ()
     set_description(N_("Mac OS X interface"))
     set_capability("interface", 200)
@@ -141,6 +144,7 @@ vlc_module_begin ()
     add_bool("macosx-icon-change", true, ICONCHANGE_TEXT, ICONCHANGE_LONGTEXT, true)
     add_bool("macosx-show-playback-buttons", false, JUMPBUTTONS_TEXT, JUMPBUTTONS_LONGTEXT, false)
     add_bool("macosx-show-playmode-buttons", true, PLAYMODEBUTTONS_TEXT, PLAYMODEBUTTONS_LONGTEXT, false)
+    add_bool("macosx-show-sidebar", true, SIDEBAR_TEXT, SIDEBAR_LONGTEXT, false)
 
     add_submodule ()
         set_description("Mac OS X Video Output Provider")