Commit d3d496a7 authored by Benjamin Pracht's avatar Benjamin Pracht

*all :

- Add "Add group" and "delete group" buttons in the playlistinfo window
- When several items of the playlist are selected, and we change the group, change it for all selected items...
parent 791c8192
...@@ -373,6 +373,8 @@ ...@@ -373,6 +373,8 @@
}, },
{ {
ACTIONS = { ACTIONS = {
createOutlineGroup = id;
deleteOutlineGroup = id;
handleGroup = id; handleGroup = id;
infoCancel = id; infoCancel = id;
infoOk = id; infoOk = id;
...@@ -383,7 +385,9 @@ ...@@ -383,7 +385,9 @@
OUTLETS = { OUTLETS = {
"o_author_lbl" = id; "o_author_lbl" = id;
"o_author_txt" = id; "o_author_txt" = id;
"o_btn_add_group" = id;
"o_btn_cancel" = id; "o_btn_cancel" = id;
"o_btn_delete_group" = id;
"o_btn_ok" = id; "o_btn_ok" = id;
"o_group_cbx" = id; "o_group_cbx" = id;
"o_group_color" = id; "o_group_color" = id;
......
...@@ -106,6 +106,8 @@ ...@@ -106,6 +106,8 @@
/*For playlist info window*/ /*For playlist info window*/
- (int)selectedPlaylistItem; - (int)selectedPlaylistItem;
- (void)deleteGroup:(int)i_id;
- (NSMutableArray *)selectedPlaylistItemsList;
- (NSColor *)getColor:(int)i_group; - (NSColor *)getColor:(int)i_group;
@end @end
......
...@@ -717,6 +717,65 @@ belongs to an Apple hidden private API, and then can "disapear" at any time*/ ...@@ -717,6 +717,65 @@ belongs to an Apple hidden private API, and then can "disapear" at any time*/
return [o_table_view selectedRow]; return [o_table_view selectedRow];
} }
- (NSMutableArray *)selectedPlaylistItemsList
{
return [NSMutableArray arrayWithArray:[[o_table_view
selectedRowEnumerator] allObjects]];
}
- (void)deleteGroup:(int)i_id
{
intf_thread_t * p_intf = [NSApp getIntf];
playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
FIND_ANYWHERE );
int i;
int i_newgroup = 0;
if (p_playlist)
{
/*first, change the group of all the items that belong to the group to
delete. Change it to the group with the smallest id.*/
/*search for the group with the smallest id*/
if(p_playlist->i_groups == 1)
{
msg_Warn(p_playlist,"Trying to delete last group, cancelling");
vlc_object_release(p_playlist);
return;
}
for (i = 0 ; i<p_playlist->i_groups ; i++)
{
if((i_newgroup == 0 || i_newgroup > p_playlist->pp_groups[i]->i_id)
&& p_playlist->pp_groups[i]->i_id != i_id)
{
i_newgroup = p_playlist->pp_groups[i]->i_id;
}
}
vlc_mutex_lock( &p_playlist->object_lock );
for (i = 0; i < p_playlist->i_size;i++)
{
if (p_playlist->pp_items[i]->i_group == i_id)
{
vlc_mutex_lock(&p_playlist->pp_items[i]->input.lock);
p_playlist->pp_items[i]->i_group = i_newgroup;
vlc_mutex_unlock(&p_playlist->pp_items[i]->input.lock);
}
}
vlc_mutex_unlock( &p_playlist->object_lock );
playlist_DeleteGroup( p_playlist, i_id );
vlc_object_release(p_playlist);
[self playlistUpdated];
}
}
- (NSColor *)getColor:(int)i_group - (NSColor *)getColor:(int)i_group
{ {
NSColor * o_color = nil; NSColor * o_color = nil;
...@@ -860,7 +919,10 @@ belongs to an Apple hidden private API, and then can "disapear" at any time*/ ...@@ -860,7 +919,10 @@ belongs to an Apple hidden private API, and then can "disapear" at any time*/
[o_cell setDrawsBackground: VLC_TRUE]; [o_cell setDrawsBackground: VLC_TRUE];
[o_cell setBackgroundColor: [o_cell setBackgroundColor:
[self getColor:p_playlist->pp_items[i_rows]->i_group]]; [self getColor:p_playlist->pp_items[i_rows]->i_group]];
}
else
{
[o_cell setDrawsBackground: VLC_FALSE];
} }
if (!p_playlist->pp_items[i_rows]->b_enabled) if (!p_playlist->pp_items[i_rows]->b_enabled)
......
...@@ -37,6 +37,8 @@ ...@@ -37,6 +37,8 @@
IBOutlet id o_author_txt; IBOutlet id o_author_txt;
IBOutlet id o_btn_info_ok; IBOutlet id o_btn_info_ok;
IBOutlet id o_btn_info_cancel; IBOutlet id o_btn_info_cancel;
IBOutlet id o_btn_delete_group;
IBOutlet id o_btn_add_group;
IBOutlet id o_outline_view; IBOutlet id o_outline_view;
IBOutlet id o_vlc_playlist; IBOutlet id o_vlc_playlist;
IBOutlet id o_group_lbl; IBOutlet id o_group_lbl;
...@@ -48,6 +50,9 @@ ...@@ -48,6 +50,9 @@
- (IBAction)infoCancel:(id)sender; - (IBAction)infoCancel:(id)sender;
- (IBAction)infoOk:(id)sender; - (IBAction)infoOk:(id)sender;
- (IBAction)handleGroup:(id)sender; - (IBAction)handleGroup:(id)sender;
- (IBAction)deleteOutlineGroup:(id)sender;
- (IBAction)createOutlineGroup:(id)sender;
- (void)createComboBox;
@end @end
......
...@@ -45,6 +45,8 @@ ...@@ -45,6 +45,8 @@
[o_author_lbl setStringValue: _NS("Author")]; [o_author_lbl setStringValue: _NS("Author")];
[o_btn_info_ok setTitle: _NS("OK")]; [o_btn_info_ok setTitle: _NS("OK")];
[o_btn_info_cancel setTitle: _NS("Cancel")]; [o_btn_info_cancel setTitle: _NS("Cancel")];
[o_btn_delete_group setTitle: _NS("Delete Group")];
[o_btn_add_group setTitle: _NS("Add Group")];
[o_group_lbl setStringValue: _NS("Group")]; [o_group_lbl setStringValue: _NS("Group")];
} }
...@@ -65,7 +67,6 @@ ...@@ -65,7 +67,6 @@
if (p_playlist) if (p_playlist)
{ {
/*fill uri / title / author info */ /*fill uri / title / author info */
int i;
int i_item = [o_vlc_playlist selectedPlaylistItem]; int i_item = [o_vlc_playlist selectedPlaylistItem];
[o_uri_txt setStringValue: [o_uri_txt setStringValue:
([NSString stringWithUTF8String:p_playlist-> ([NSString stringWithUTF8String:p_playlist->
...@@ -90,20 +91,7 @@ ...@@ -90,20 +91,7 @@
[[VLCInfoTreeItem rootItem] refresh]; [[VLCInfoTreeItem rootItem] refresh];
[o_outline_view reloadData]; [o_outline_view reloadData];
[o_group_cbx removeAllItems]; [self createComboBox];
for (i = 0; i < p_playlist->i_groups ; i++)
{
[o_group_cbx addItemWithObjectValue:
[NSString stringWithUTF8String:
p_playlist->pp_groups[i]->psz_name]];
if (p_playlist->pp_items[i_item]->i_group == p_playlist
->pp_groups[i]->i_id)
{
[o_group_cbx selectItemAtIndex:i];
}
}
[self handleGroup:self]; [self handleGroup:self];
vlc_object_release( p_playlist ); vlc_object_release( p_playlist );
...@@ -120,11 +108,15 @@ ...@@ -120,11 +108,15 @@
- (IBAction)infoOk:(id)sender - (IBAction)infoOk:(id)sender
{ {
int i,i_row,c;
int i_item = [o_vlc_playlist selectedPlaylistItem]; int i_item = [o_vlc_playlist selectedPlaylistItem];
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 );
vlc_value_t val; vlc_value_t val;
NSMutableArray * o_selected = [o_vlc_playlist selectedPlaylistItemsList];
NSNumber * o_number;
if (p_playlist) if (p_playlist)
{ {
...@@ -136,17 +128,34 @@ ...@@ -136,17 +128,34 @@
strdup([[o_title_txt stringValue] cString]); strdup([[o_title_txt stringValue] cString]);
playlist_ItemAddInfo(p_playlist->pp_items[i_item],_("General"),_("Author"), [[o_author_txt stringValue] cString]); playlist_ItemAddInfo(p_playlist->pp_items[i_item],_("General"),_("Author"), [[o_author_txt stringValue] cString]);
c = (int)[o_selected count];
if ([[o_group_cbx stringValue] isEqual: if ([[o_group_cbx stringValue] isEqual:
[o_group_cbx objectValueOfSelectedItem]]) [o_group_cbx objectValueOfSelectedItem]])
{ {
p_playlist->pp_items[i_item]->i_group = p_playlist-> for (i = 0 ; i < c ; i++)
{
o_number = [o_selected lastObject];
i_row = [o_number intValue];
p_playlist->pp_items[i_row]->i_group = p_playlist->
pp_groups[[o_group_cbx indexOfSelectedItem]]->i_id; pp_groups[[o_group_cbx indexOfSelectedItem]]->i_id;
[o_selected removeObject: o_number];
}
} }
else else
{ {
playlist_group_t * p_group = playlist_CreateGroup( p_playlist, playlist_group_t * p_group = playlist_CreateGroup( p_playlist,
strdup([[o_group_cbx stringValue] cString])); strdup([[o_group_cbx stringValue] cString]));
p_playlist->pp_items[i_item]->i_group = p_group->i_id; if (p_group)
{
for (i = 0 ; i < c ; i++)
{
o_number = [o_selected lastObject];
i_row = [o_number intValue];
p_playlist->pp_items[i_row]->i_group = p_group->i_id;
[o_selected removeObject: o_number];
}
}
} }
...@@ -183,8 +192,77 @@ ...@@ -183,8 +192,77 @@
} }
} }
- (IBAction)deleteOutlineGroup:(id)sender
{
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 ([[o_group_cbx stringValue] isEqual:
[o_group_cbx objectValueOfSelectedItem]])
{
[o_vlc_playlist deleteGroup:p_playlist->pp_groups[
[o_group_cbx indexOfSelectedItem]]->i_id];
[self createComboBox];
[self handleGroup:self];
[o_group_cbx reloadData];
}
else
{
msg_Warn(p_playlist,"Group doesn't exist, cannot delete");
}
vlc_object_release(p_playlist);
}
}
- (IBAction)createOutlineGroup:(id)sender;
{
intf_thread_t * p_intf = [NSApp getIntf];
playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
FIND_ANYWHERE );
if(p_playlist)
{
playlist_CreateGroup( p_playlist,
strdup([[o_group_cbx stringValue] cString]));
[self createComboBox];
[o_group_cbx reloadData];
[o_vlc_playlist playlistUpdated];
vlc_object_release(p_playlist);
}
}
-(void)createComboBox
{
intf_thread_t * p_intf = [NSApp getIntf];
playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
FIND_ANYWHERE );
int i;
int i_item = [o_vlc_playlist selectedPlaylistItem];
[o_group_cbx removeAllItems];
if (p_playlist)
{
for (i = 0; i < p_playlist->i_groups ; i++)
{
[o_group_cbx addItemWithObjectValue:
[NSString stringWithUTF8String:
p_playlist->pp_groups[i]->psz_name]];
if (p_playlist->pp_items[i_item]->i_group == p_playlist
->pp_groups[i]->i_id)
{
[o_group_cbx selectItemAtIndex:i];
}
}
vlc_object_release(p_playlist);
}
}
@end @end
@implementation VLCPlaylistInfo (NSTableDataSource) @implementation VLCPlaylistInfo (NSTableDataSource)
- (int)outlineView:(NSOutlineView *)outlineView numberOfChildrenOfItem:(id)item - (int)outlineView:(NSOutlineView *)outlineView numberOfChildrenOfItem:(id)item
......
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