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 @@
savePlaylist = id;
searchItem = id;
selectAll = id;
toggleItemsEnabled = id;
toggleWindow = id;
};
CLASS = VLCPlaylist;
......@@ -352,6 +353,7 @@
"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;
......
......@@ -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>
......
......@@ -276,6 +276,7 @@
}
}
- (IBAction)volumeUp:(id)sender
{
intf_thread_t * p_intf = [NSApp getIntf];
......
......@@ -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;
......
......@@ -137,6 +137,8 @@
[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)
{
if ((p_playlist->i_groups) > 1 )
{
[o_cell setDrawsBackground: VLC_TRUE];
[o_cell setBackgroundColor:
[self getColor:p_playlist->pp_items[o_rows]->i_group]];
[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
......
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