Commit d2270bdb authored by Benjamin Pracht's avatar Benjamin Pracht

Adds "Enable/disable item" menu item in playlist contextual menu.

parent 3cad60ce
...@@ -339,6 +339,7 @@ ...@@ -339,6 +339,7 @@
savePlaylist = id; savePlaylist = id;
searchItem = id; searchItem = id;
selectAll = id; selectAll = id;
toggleItemsEnabled = id;
toggleWindow = id; toggleWindow = id;
}; };
CLASS = VLCPlaylist; CLASS = VLCPlaylist;
...@@ -352,6 +353,7 @@ ...@@ -352,6 +353,7 @@
"o_mi_play" = id; "o_mi_play" = id;
"o_mi_save_playlist" = id; "o_mi_save_playlist" = id;
"o_mi_selectall" = id; "o_mi_selectall" = id;
"o_mi_toggleItemsEnabled" = id;
"o_random_ckb" = id; "o_random_ckb" = id;
"o_search_button" = id; "o_search_button" = id;
"o_search_keyword" = id; "o_search_keyword" = id;
......
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
<key>29</key> <key>29</key>
<string>544 598 419 44 0 0 1024 746 </string> <string>544 598 419 44 0 0 1024 746 </string>
<key>915</key> <key>915</key>
<string>160 353 103 130 0 0 800 578 </string> <string>54 452 118 149 0 0 1024 746 </string>
</dict> </dict>
<key>IBFramework Version</key> <key>IBFramework Version</key>
<string>349.0</string> <string>349.0</string>
...@@ -20,7 +20,6 @@ ...@@ -20,7 +20,6 @@
<key>IBOpenObjects</key> <key>IBOpenObjects</key>
<array> <array>
<integer>21</integer> <integer>21</integer>
<integer>1789</integer>
</array> </array>
<key>IBSystem Version</key> <key>IBSystem Version</key>
<string>7F44</string> <string>7F44</string>
......
...@@ -276,6 +276,7 @@ ...@@ -276,6 +276,7 @@
} }
} }
- (IBAction)volumeUp:(id)sender - (IBAction)volumeUp:(id)sender
{ {
intf_thread_t * p_intf = [NSApp getIntf]; intf_thread_t * p_intf = [NSApp getIntf];
......
...@@ -56,6 +56,7 @@ ...@@ -56,6 +56,7 @@
IBOutlet id o_mi_play; IBOutlet id o_mi_play;
IBOutlet id o_mi_delete; IBOutlet id o_mi_delete;
IBOutlet id o_mi_selectall; IBOutlet id o_mi_selectall;
IBOutlet id o_mi_toggleItemsEnabled;
IBOutlet id o_random_ckb; IBOutlet id o_random_ckb;
...@@ -88,6 +89,7 @@ ...@@ -88,6 +89,7 @@
- (IBAction)savePlaylist:(id)sender; - (IBAction)savePlaylist:(id)sender;
- (IBAction)playItem:(id)sender; - (IBAction)playItem:(id)sender;
- (IBAction)deleteItems:(id)sender; - (IBAction)deleteItems:(id)sender;
- (IBAction)toggleItemsEnabled:(id)sender;
- (IBAction)selectAll:(id)sender; - (IBAction)selectAll:(id)sender;
- (IBAction)searchItem:(id)sender; - (IBAction)searchItem:(id)sender;
- (IBAction)handlePopUp:(id)sender; - (IBAction)handlePopUp:(id)sender;
......
...@@ -137,6 +137,8 @@ ...@@ -137,6 +137,8 @@
[o_table_view setIntercellSpacing: NSMakeSize (0.0, 1.0)]; [o_table_view setIntercellSpacing: NSMakeSize (0.0, 1.0)];
[o_window setExcludedFromWindowsMenu: TRUE]; [o_window setExcludedFromWindowsMenu: TRUE];
[o_mi_toggleItemsEnabled setTarget:self];
// [o_tbv_info setDataSource: [VLCInfoDataSource init]]; // [o_tbv_info setDataSource: [VLCInfoDataSource init]];
/* We need to check whether _defaultTableHeaderSortImage exists, since it /* 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*/ ...@@ -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_play setTitle: _NS("Play")];
[o_mi_delete setTitle: _NS("Delete")]; [o_mi_delete setTitle: _NS("Delete")];
[o_mi_selectall setTitle: _NS("Select All")]; [o_mi_selectall setTitle: _NS("Select All")];
[o_mi_toggleItemsEnabled setTitle: _NS("Item Enabled")];
[o_mi_info setTitle: _NS("Properties")]; [o_mi_info setTitle: _NS("Properties")];
[[o_tc_name headerCell] setStringValue:_NS("Name")]; [[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*/ ...@@ -260,6 +263,12 @@ belongs to an Apple hidden private API, and then can "disapear" at any time*/
- (NSMenu *)menuForEvent:(NSEvent *)o_event - (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; NSPoint pt;
vlc_bool_t b_rows; vlc_bool_t b_rows;
vlc_bool_t b_item_sel; vlc_bool_t b_item_sel;
...@@ -274,6 +283,17 @@ belongs to an Apple hidden private API, and then can "disapear" at any time*/ ...@@ -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_delete setEnabled: b_item_sel];
[o_mi_selectall setEnabled: b_rows]; [o_mi_selectall setEnabled: b_rows];
[o_mi_info setEnabled: b_item_sel]; [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 ); return( o_ctx_menu );
} }
...@@ -364,6 +384,52 @@ belongs to an Apple hidden private API, and then can "disapear" at any time*/ ...@@ -364,6 +384,52 @@ belongs to an Apple hidden private API, and then can "disapear" at any time*/
[self updateRowSelection]; [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 - (IBAction)selectAll:(id)sender
{ {
[o_table_view selectAll: nil]; [o_table_view selectAll: nil];
...@@ -623,51 +689,52 @@ belongs to an Apple hidden private API, and then can "disapear" at any time*/ ...@@ -623,51 +689,52 @@ belongs to an Apple hidden private API, and then can "disapear" at any time*/
- (NSColor *)getColor:(int)i_group - (NSColor *)getColor:(int)i_group
{ {
NSColor * o_color = nil;
switch ( i_group % 8 ) switch ( i_group % 8 )
{ {
case 1: case 1:
/*white*/ /*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; break;
case 2: case 2:
/*red*/ /*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; break;
case 3: case 3:
/*dark blue*/ /*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; break;
case 4: case 4:
/*orange*/ /*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; break;
case 5: case 5:
/*purple*/ /*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; break;
case 6: case 6:
/*green*/ /*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; break;
case 7: case 7:
/*light blue*/ /*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; break;
case 0: case 0:
/*yellow*/ /*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; break;
} }
return o_color;
} }
@end @end
@implementation VLCPlaylist (NSTableDataSource) @implementation VLCPlaylist (NSTableDataSource)
...@@ -751,20 +818,31 @@ belongs to an Apple hidden private API, and then can "disapear" at any time*/ ...@@ -751,20 +818,31 @@ belongs to an Apple hidden private API, and then can "disapear" at any time*/
- (void)tableView:(NSTableView *)o_tv - (void)tableView:(NSTableView *)o_tv
willDisplayCell:(id)o_cell willDisplayCell:(id)o_cell
forTableColumn:(NSTableColumn *)o_tc forTableColumn:(NSTableColumn *)o_tc
row:(int)o_rows row:(int)i_rows
{ {
intf_thread_t * p_intf = [NSApp getIntf]; intf_thread_t * p_intf = [NSApp getIntf];
playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
FIND_ANYWHERE ); FIND_ANYWHERE );
if ((p_playlist->i_groups) > 1 ) if (p_playlist)
{ {
[o_cell setDrawsBackground: VLC_TRUE]; if ((p_playlist->i_groups) > 1 )
[o_cell setBackgroundColor: {
[self getColor:p_playlist->pp_items[o_rows]->i_group]]; [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 - (BOOL)tableView:(NSTableView *)o_tv
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment