]> git.sesse.net Git - vlc/commitdiff
Adds "Enable/disable item" menu item in playlist contextual menu.
authorBenjamin Pracht <bigben@videolan.org>
Sun, 4 Apr 2004 00:30:11 +0000 (00:30 +0000)
committerBenjamin Pracht <bigben@videolan.org>
Sun, 4 Apr 2004 00:30:11 +0000 (00:30 +0000)
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/controls.m
modules/gui/macosx/playlist.h
modules/gui/macosx/playlist.m

index c313ed8b24e14cb89f6952e1fa5f22faee733786..eb113de325b82b0f9c72c035ba09b6357838b657 100644 (file)
                 savePlaylist = id; 
                 searchItem = id; 
                 selectAll = id; 
+                toggleItemsEnabled = id; 
                 toggleWindow = id; 
             }; 
             CLASS = VLCPlaylist; 
                 "o_mi_play" = id; 
                 "o_mi_save_playlist" = id; 
                 "o_mi_selectall" = id; 
+                "o_mi_toggleItemsEnabled" = id; 
                 "o_random_ckb" = id; 
                 "o_search_button" = id; 
                 "o_search_keyword" = id; 
index 4983e5c058c37bc0be73aebc4f730a8928153d9e..2856308604c68f58fbd3f98023c5ce7c192c4a5b 100644 (file)
@@ -11,7 +11,7 @@
                <key>29</key>
                <string>544 598 419 44 0 0 1024 746 </string>
                <key>915</key>
-               <string>160 353 103 130 0 0 800 578 </string>
+               <string>54 452 118 149 0 0 1024 746 </string>
        </dict>
        <key>IBFramework Version</key>
        <string>349.0</string>
@@ -20,7 +20,6 @@
        <key>IBOpenObjects</key>
        <array>
                <integer>21</integer>
-               <integer>1789</integer>
        </array>
        <key>IBSystem Version</key>
        <string>7F44</string>
index 0e781eac51136495945cc4602e810ab4bc474f8c..76ca5fc03ee2cb5343828be38a27938023d2c4a7 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 8cea69c58ebbb443e428221b98efedf42207f9de..05afc31f08a41c219e7311fcdbbb01c4b1ae858e 100644 (file)
     }
 }
 
+
 - (IBAction)volumeUp:(id)sender
 {
     intf_thread_t * p_intf = [NSApp getIntf];
index f2008dd5c5ee456b65e386ee300034bdf86c7509..db901544dab33a5785f70347b070f390404d2e98 100644 (file)
@@ -56,6 +56,7 @@
     IBOutlet id o_mi_play;
     IBOutlet id o_mi_delete;
     IBOutlet id o_mi_selectall;
+    IBOutlet id o_mi_toggleItemsEnabled;
 
     IBOutlet id o_random_ckb;
 
@@ -88,6 +89,7 @@
 - (IBAction)savePlaylist:(id)sender;
 - (IBAction)playItem:(id)sender;
 - (IBAction)deleteItems:(id)sender;
+- (IBAction)toggleItemsEnabled:(id)sender;
 - (IBAction)selectAll:(id)sender;
 - (IBAction)searchItem:(id)sender;
 - (IBAction)handlePopUp:(id)sender;
index bca93c08b73dedf8e7d5515ee7f2927f5a24c689..93611fd619a282f1c19ce090a9bde1d28cafe1de 100644 (file)
     [o_table_view setIntercellSpacing: NSMakeSize (0.0, 1.0)];
     [o_window setExcludedFromWindowsMenu: TRUE];
 
+    [o_mi_toggleItemsEnabled setTarget:self];
+
 //    [o_tbv_info setDataSource: [VLCInfoDataSource init]];
 
 /* We need to check whether _defaultTableHeaderSortImage exists, since it 
@@ -171,6 +173,7 @@ belongs to an Apple hidden private API, and then can "disapear" at any time*/
     [o_mi_play setTitle: _NS("Play")];
     [o_mi_delete setTitle: _NS("Delete")];
     [o_mi_selectall setTitle: _NS("Select All")];
+    [o_mi_toggleItemsEnabled setTitle: _NS("Item Enabled")];
     [o_mi_info setTitle: _NS("Properties")];
 
     [[o_tc_name headerCell] setStringValue:_NS("Name")];
@@ -260,6 +263,12 @@ belongs to an Apple hidden private API, and then can "disapear" at any time*/
 
 - (NSMenu *)menuForEvent:(NSEvent *)o_event
 {
+    intf_thread_t * p_intf = [NSApp getIntf];
+    playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
+                                            FIND_ANYWHERE );
+
+    bool b_state = FALSE;
+
     NSPoint pt;
     vlc_bool_t b_rows;
     vlc_bool_t b_item_sel;
@@ -274,6 +283,17 @@ belongs to an Apple hidden private API, and then can "disapear" at any time*/
     [o_mi_delete setEnabled: b_item_sel];
     [o_mi_selectall setEnabled: b_rows];
     [o_mi_info setEnabled: b_item_sel];
+    [o_mi_toggleItemsEnabled setEnabled: b_item_sel];
+
+
+    if (p_playlist)
+    {
+        b_state = ([o_table_view selectedRow] > -1) ?
+            p_playlist->pp_items[[o_table_view selectedRow]]->b_enabled : FALSE;
+        vlc_object_release(p_playlist);
+    }
+
+    [o_mi_toggleItemsEnabled setState: b_state];
 
     return( o_ctx_menu );
 }
@@ -364,6 +384,52 @@ belongs to an Apple hidden private API, and then can "disapear" at any time*/
     [self updateRowSelection];
 }
 
+- (IBAction)toggleItemsEnabled:(id)sender
+{
+    int i, c, i_row;
+    NSMutableArray *o_selected;
+    NSNumber *o_number;
+
+    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;
+    }
+
+    o_selected = [NSMutableArray arrayWithArray:[[o_table_view selectedRowEnumerator] allObjects]];
+    c = (int)[o_selected count];
+
+    if (p_playlist->pp_items[[o_table_view selectedRow]]->b_enabled)
+    {
+        for( i = 0; i < c; i++ )
+        {
+            o_number = [o_selected lastObject];
+            i_row = [o_number intValue];
+            if( p_playlist->i_index == i_row && p_playlist->i_status )
+            {
+                playlist_Stop( p_playlist );
+            }
+            [o_selected removeObject: o_number];
+            playlist_Disable( p_playlist, i_row );
+        }
+    }
+    else
+    {
+        for( i = 0; i < c; i++ )
+        {
+            o_number = [o_selected lastObject];
+            i_row = [o_number intValue];
+            [o_selected removeObject: o_number];
+            playlist_Enable( p_playlist, i_row );
+        }
+    }
+    vlc_object_release( p_playlist );
+    [self playlistUpdated];
+}
+
 - (IBAction)selectAll:(id)sender
 {
     [o_table_view selectAll: nil];
@@ -623,51 +689,52 @@ belongs to an Apple hidden private API, and then can "disapear" at any time*/
 
 - (NSColor *)getColor:(int)i_group
 {
+    NSColor * o_color = nil;
     switch ( i_group % 8 )
     {
         case 1:
             /*white*/
-            return [NSColor colorWithDeviceRed:1.0 green:1.0 blue:1.0 alpha:1.0];
+            o_color = [NSColor colorWithDeviceRed:1.0 green:1.0 blue:1.0 alpha:1.0];
         break;
 
         case 2:
             /*red*/
-           return [NSColor colorWithDeviceRed:1.0 green:0.76471 blue:0.76471 alpha:1.0];
+           o_color = [NSColor colorWithDeviceRed:1.0 green:0.76471 blue:0.76471 alpha:1.0];
         break;
 
            case 3:
               /*dark blue*/
-                  return [NSColor colorWithDeviceRed:0.76471 green:0.76471 blue:1.0 alpha:1.0];
+                  o_color = [NSColor colorWithDeviceRed:0.76471 green:0.76471 blue:1.0 alpha:1.0];
         break; 
 
         case 4:
                /*orange*/
-           return [NSColor colorWithDeviceRed:1.0 green:0.89804 blue:0.76471 alpha:1.0];
+           o_color = [NSColor colorWithDeviceRed:1.0 green:0.89804 blue:0.76471 alpha:1.0];
         break;
 
         case 5:
                /*purple*/
-           return [NSColor colorWithDeviceRed:1.0 green:0.76471 blue:1.0 alpha:1.0];
+           o_color = [NSColor colorWithDeviceRed:1.0 green:0.76471 blue:1.0 alpha:1.0];
         break;
  
         case 6:
               /*green*/
-           return [NSColor colorWithDeviceRed:0.76471 green:1.0 blue:0.76471 alpha:1.0];
+           o_color = [NSColor colorWithDeviceRed:0.76471 green:1.0 blue:0.76471 alpha:1.0];
         break; 
 
         case 7:
               /*light blue*/
-           return [NSColor colorWithDeviceRed:0.76471 green:1.0 blue:1.0 alpha:1.0];
+           o_color = [NSColor colorWithDeviceRed:0.76471 green:1.0 blue:1.0 alpha:1.0];
         break;
 
         case 0:
               /*yellow*/
-           return [NSColor colorWithDeviceRed:1.0 green:1.0 blue:0.76471 alpha:1.0];
+           o_color = [NSColor colorWithDeviceRed:1.0 green:1.0 blue:0.76471 alpha:1.0];
         break;
        }
+    return o_color;
 }
 
-
 @end
 
 @implementation VLCPlaylist (NSTableDataSource)
@@ -751,20 +818,31 @@ belongs to an Apple hidden private API, and then can "disapear" at any time*/
 - (void)tableView:(NSTableView *)o_tv
                    willDisplayCell:(id)o_cell
                    forTableColumn:(NSTableColumn *)o_tc
-                   row:(int)o_rows
+                   row:(int)i_rows
 {
     intf_thread_t * p_intf = [NSApp getIntf];
     playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
                                                FIND_ANYWHERE );
-    if ((p_playlist->i_groups) > 1 )
+    if (p_playlist)
     {
-       [o_cell setDrawsBackground: VLC_TRUE];
-       [o_cell setBackgroundColor:
-                [self getColor:p_playlist->pp_items[o_rows]->i_group]];
+        if ((p_playlist->i_groups) > 1 )
+        {
+            [o_cell setDrawsBackground: VLC_TRUE];
+            [o_cell setBackgroundColor:
+                [self getColor:p_playlist->pp_items[i_rows]->i_group]];
+       
+        }
 
-    
+        if (!p_playlist->pp_items[i_rows]->b_enabled)
+        {
+            [o_cell setTextColor: [NSColor colorWithDeviceRed:0.3686 green:0.3686 blue:0.3686 alpha:1.0]];
+        }
+        else
+        {
+            [o_cell setTextColor:[NSColor colorWithDeviceRed:0.0 green:0.0 blue:0.0 alpha:1.0]];
+        }
+    vlc_object_release( p_playlist );
     }
-vlc_object_release( p_playlist );
 }
 
 - (BOOL)tableView:(NSTableView *)o_tv