]> git.sesse.net Git - vlc/commitdiff
MacOS X port:
authorJon Lech Johansen <jlj@videolan.org>
Sun, 5 Jan 2003 03:21:50 +0000 (03:21 +0000)
committerJon Lech Johansen <jlj@videolan.org>
Sun, 5 Jan 2003 03:21:50 +0000 (03:21 +0000)
  * replaced playlist panel with drawer.
  * implemented context menu for playlist tableview.

extras/MacOSX/Resources/English.lproj/MainMenu.nib/classes.nib
extras/MacOSX/Resources/English.lproj/MainMenu.nib/info.nib
extras/MacOSX/Resources/English.lproj/MainMenu.nib/objects.nib
modules/gui/macosx/playlist.h
modules/gui/macosx/playlist.m

index 9ed4d79e1900fd5fcb454e6784f0b9f5ee148869..9dc841a3fafb981c60f2218c214fad7fc026aa3e 100644 (file)
             SUPERCLASS = NSObject; 
         }, 
         {
+            ACTIONS = {deleteItems = id; playItem = id; selectAll = id; }; 
             CLASS = VLCPlaylist; 
             LANGUAGE = ObjC; 
-            OUTLETS = {"o_btn_close" = id; "o_panel" = id; "o_table_view" = id; }; 
+            OUTLETS = {
+                "o_ctx_menu" = id; 
+                "o_mi_delete" = id; 
+                "o_mi_play" = id; 
+                "o_mi_selectall" = id; 
+                "o_table_view" = id; 
+            }; 
             SUPERCLASS = NSObject; 
         }, 
         {CLASS = VLCPlaylistView; LANGUAGE = ObjC; SUPERCLASS = NSTableView; }
index 564d95a4f54e2f21bd275ad2c39866f0ed407712..51d0179ea35c10abb13a2b41569346f5c7bfa4dc 100644 (file)
@@ -3,22 +3,20 @@
 <plist version="1.0">
 <dict>
        <key>IBDocumentLocation</key>
-       <string>61 306 428 434 0 0 1152 746 </string>
+       <string>95 526 428 434 0 0 1600 1178 </string>
        <key>IBEditorPositions</key>
        <dict>
                <key>29</key>
-               <string>266 466 308 44 0 0 1152 746 </string>
+               <string>407 753 308 44 0 0 1600 1178 </string>
                <key>303</key>
                <string>93 566 72 114 0 0 1600 1178 </string>
+               <key>909</key>
+               <string>761 663 440 172 0 0 1600 1178 </string>
+               <key>915</key>
+               <string>594 532 93 96 0 0 1600 1178 </string>
        </dict>
        <key>IBFramework Version</key>
        <string>291.0</string>
-       <key>IBOpenObjects</key>
-       <array>
-               <integer>21</integer>
-               <integer>29</integer>
-               <integer>636</integer>
-       </array>
        <key>IBSystem Version</key>
        <string>6G30</string>
 </dict>
index 606e5e45e8709bbd48662f7d07d49f158d1d6862..198b50f62208253fdab2e6c5f92ebd87ec602717 100644 (file)
Binary files a/extras/MacOSX/Resources/English.lproj/MainMenu.nib/objects.nib and b/extras/MacOSX/Resources/English.lproj/MainMenu.nib/objects.nib differ
index adbf1f222af8ffc957d9ff62d82ed30d3a4c79e3..8b8f768225cb273aac74299322695c24ba37f079 100644 (file)
@@ -2,7 +2,7 @@
  * playlist.h: MacOS X interface plugin
  *****************************************************************************
  * Copyright (C) 2002 VideoLAN
- * $Id: playlist.h,v 1.1 2002/08/04 17:23:43 sam Exp $
+ * $Id: playlist.h,v 1.2 2003/01/05 03:21:50 jlj Exp $
  *
  * Authors: Jon Lech Johansen <jon-vl@nanocrew.net>
  *
  *****************************************************************************/
 @interface VLCPlaylist : NSObject
 {
-    IBOutlet id o_panel; 
-    IBOutlet id o_btn_close;
     IBOutlet id o_table_view;
+
+    IBOutlet id o_ctx_menu;
+
+    IBOutlet id o_mi_play;
+    IBOutlet id o_mi_delete;
+    IBOutlet id o_mi_selectall;
 }
 
+- (NSMenu *)menuForEvent:(NSEvent *)o_event;
+
+- (IBAction)playItem:(id)sender;
+- (IBAction)deleteItems:(id)sender;
+- (IBAction)selectAll:(id)sender;
+
 - (void)appendArray:(NSArray*)o_array atPos:(int)i_pos;
+- (void)playlistUpdated;
 
 @end
-
index c94fa56b3d0f5a06b0267c79d4f79029b6a57261..9e8b360f73227f33270399823b64a8c9773f9b30 100644 (file)
@@ -2,7 +2,7 @@
  * playlist.m: MacOS X interface plugin
  *****************************************************************************
  * Copyright (C) 2002 VideoLAN
- * $Id: playlist.m,v 1.2 2002/09/23 23:05:58 massiot Exp $
+ * $Id: playlist.m,v 1.3 2003/01/05 03:21:50 jlj Exp $
  *
  * Authors: Jon Lech Johansen <jon-vl@nanocrew.net>
  *
@@ -43,9 +43,7 @@
 
 - (NSMenu *)menuForEvent:(NSEvent *)o_event
 {
-    /* TODO */
-
-    return( nil );
+    return( [[self delegate] menuForEvent: o_event] );
 }
 
 @end
     [o_table_view setDelegate: self];
     [o_table_view setDataSource: self];
 
-    [o_table_view setDoubleAction: @selector(doubleClick:)];
+    [o_table_view setDoubleAction: @selector(playItem:)];
 
     [o_table_view registerForDraggedTypes: 
         [NSArray arrayWithObjects: NSFilenamesPboardType, nil]];
 
-    [o_panel setTitle: _NS("Playlist")];
-    [o_btn_close setTitle: _NS("Close")];
+    [o_mi_play setTitle: _NS("Play")];
+    [o_mi_delete setTitle: _NS("Delete")];
+    [o_mi_selectall setTitle: _NS("Select All")];
 }
 
 - (BOOL)tableView:(NSTableView *)o_tv 
 
         [self appendArray: o_values atPos: i_row];
 
-        if( i_row != -1 )
-        {
-            [o_table_view reloadData];
-        }
-        
         return( YES );
     }
 
 - (void)tableView:(NSTableView *)o_tv willDisplayCell:(id)o_cell
                   forTableColumn:(NSTableColumn *)o_tc row:(int)i_row
 {
+    NSColor * o_color;
+
     [o_cell setDrawsBackground: YES];
 
     if( i_row % 2 )
     {
-        [o_cell setBackgroundColor: 
-            [NSColor colorWithDeviceRed: 0.937255 
-                                  green: 0.968627
-                                   blue: 1.0
-                                  alpha: 1.0]];
+        o_color = [[NSColor alternateSelectedControlColor]
+                            highlightWithLevel: 0.90];
     }
     else
     {
-        [o_cell setBackgroundColor: [NSColor whiteColor]];
+        o_color = [o_tv backgroundColor]; 
     }
+
+    [o_cell setBackgroundColor: o_color];
 }
 
-- (IBAction)doubleClick:(id)sender
+- (NSMenu *)menuForEvent:(NSEvent *)o_event
+{
+    NSPoint pt;
+    vlc_bool_t b_rows;
+    vlc_bool_t b_item_sel;
+
+    pt = [o_table_view convertPoint: [o_event locationInWindow] 
+                                                 fromView: nil];
+    b_item_sel = ( [o_table_view rowAtPoint: pt] != -1 &&
+                   [o_table_view selectedRow] != -1 );
+    b_rows = [o_table_view numberOfRows] != 0;
+
+    [o_mi_play setEnabled: b_item_sel];
+    [o_mi_delete setEnabled: b_item_sel];
+    [o_mi_selectall setEnabled: b_rows];
+
+    return( o_ctx_menu );
+}
+
+- (IBAction)playItem:(id)sender
 {
-    NSTableView * o_tv = sender;
     intf_thread_t * p_intf = [NSApp getIntf];
     playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
                                                        FIND_ANYWHERE );
         return;
     }
 
-    playlist_Goto( p_playlist, [o_tv clickedRow] );
+    playlist_Goto( p_playlist, [o_table_view selectedRow] );
 
     vlc_object_release( p_playlist );
 }
 
+- (IBAction)deleteItems:(id)sender
+{
+    int i_row;
+
+    intf_thread_t * p_intf = [NSApp getIntf];
+    playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
+                                                       FIND_ANYWHERE );
+
+    if( p_playlist == NULL )
+    {
+        return;
+    }
+
+    while( ( i_row = [o_table_view selectedRow] ) != -1 )
+    {
+        if( p_playlist->i_index == i_row && p_playlist->i_status )
+        {
+            playlist_Stop( p_playlist );
+        }
+
+        playlist_Delete( p_playlist, i_row ); 
+
+        [o_table_view deselectRow: i_row];
+    }
+
+    vlc_object_release( p_playlist );
+
+    [self playlistUpdated];
+}
+
+- (IBAction)selectAll:(id)sender
+{
+    [o_table_view selectAll: nil];
+}
+
 - (void)appendArray:(NSArray*)o_array atPos:(int)i_pos
 {
     int i_items;
     }
 
     vlc_object_release( p_playlist );
+
+    [self playlistUpdated];
+}
+
+- (void)playlistUpdated
+{
+    [o_table_view reloadData];
 }
 
 @end