Commit 50cd0bcc authored by Felix Paul Kühne's avatar Felix Paul Kühne Committed by Jean-Baptiste Kempf

macosx: fixed enabling/disabling SDs through the sidebar

note that the playlist table remains to be fixed to show the current selection only
(cherry picked from commit 4c0f16871304032f95f0d56737d438c17621d51d)
Signed-off-by: default avatarJean-Baptiste Kempf <jb@videolan.org>
parent 862de86b
...@@ -328,7 +328,6 @@ static VLCMainWindow *_o_sharedInstance = nil; ...@@ -328,7 +328,6 @@ static VLCMainWindow *_o_sharedInstance = nil;
for (; *ppsz_name; ppsz_name++, ppsz_longname++, p_category++) for (; *ppsz_name; ppsz_name++, ppsz_longname++, p_category++)
{ {
o_identifier = [NSString stringWithCString: *ppsz_name encoding: NSUTF8StringEncoding]; o_identifier = [NSString stringWithCString: *ppsz_name encoding: NSUTF8StringEncoding];
o_identifier = [[o_identifier componentsSeparatedByString:@"{"] objectAtIndex:0];
switch (*p_category) { switch (*p_category) {
case SD_CAT_INTERNET: case SD_CAT_INTERNET:
{ {
...@@ -337,18 +336,21 @@ static VLCMainWindow *_o_sharedInstance = nil; ...@@ -337,18 +336,21 @@ static VLCMainWindow *_o_sharedInstance = nil;
[[internetItems lastObject] setIcon: [NSImage imageNamed:@"sidebar-podcast"]]; [[internetItems lastObject] setIcon: [NSImage imageNamed:@"sidebar-podcast"]];
else else
[[internetItems lastObject] setIcon: [NSImage imageNamed:@"NSApplicationIcon"]]; [[internetItems lastObject] setIcon: [NSImage imageNamed:@"NSApplicationIcon"]];
[[internetItems lastObject] setSdtype: SD_CAT_INTERNET];
} }
break; break;
case SD_CAT_DEVICES: case SD_CAT_DEVICES:
{ {
[devicesItems addObject: [SideBarItem itemWithTitle: [NSString stringWithCString: *ppsz_longname encoding: NSUTF8StringEncoding] identifier: o_identifier]]; [devicesItems addObject: [SideBarItem itemWithTitle: [NSString stringWithCString: *ppsz_longname encoding: NSUTF8StringEncoding] identifier: o_identifier]];
[[devicesItems lastObject] setIcon: [NSImage imageNamed:@"NSApplicationIcon"]]; [[devicesItems lastObject] setIcon: [NSImage imageNamed:@"NSApplicationIcon"]];
[[devicesItems lastObject] setSdtype: SD_CAT_DEVICES];
} }
break; break;
case SD_CAT_LAN: case SD_CAT_LAN:
{ {
[lanItems addObject: [SideBarItem itemWithTitle: [NSString stringWithCString: *ppsz_longname encoding: NSUTF8StringEncoding] identifier: o_identifier]]; [lanItems addObject: [SideBarItem itemWithTitle: [NSString stringWithCString: *ppsz_longname encoding: NSUTF8StringEncoding] identifier: o_identifier]];
[[lanItems lastObject] setIcon: [NSImage imageNamed:@"sidebar-local"]]; [[lanItems lastObject] setIcon: [NSImage imageNamed:@"sidebar-local"]];
[[lanItems lastObject] setSdtype: SD_CAT_LAN];
} }
break; break;
case SD_CAT_MYCOMPUTER: case SD_CAT_MYCOMPUTER:
...@@ -362,6 +364,7 @@ static VLCMainWindow *_o_sharedInstance = nil; ...@@ -362,6 +364,7 @@ static VLCMainWindow *_o_sharedInstance = nil;
[[mycompItems lastObject] setIcon: [NSImage imageNamed:@"sidebar-pictures"]]; [[mycompItems lastObject] setIcon: [NSImage imageNamed:@"sidebar-pictures"]];
else else
[[mycompItems lastObject] setIcon: [NSImage imageNamed:@"NSApplicationIcon"]]; [[mycompItems lastObject] setIcon: [NSImage imageNamed:@"NSApplicationIcon"]];
[[mycompItems lastObject] setSdtype: SD_CAT_MYCOMPUTER];
} }
break; break;
default: default:
...@@ -1063,7 +1066,7 @@ static VLCMainWindow *_o_sharedInstance = nil; ...@@ -1063,7 +1066,7 @@ static VLCMainWindow *_o_sharedInstance = nil;
[o_fspanel setSeekable: b_seekable]; [o_fspanel setSeekable: b_seekable];
PL_LOCK; PL_LOCK;
if (playlist_CurrentSize( p_playlist ) >= 1) if (p_playlist->items.i_size >= 1)
[self hideDropZone]; [self hideDropZone];
else else
[self showDropZone]; [self showDropZone];
...@@ -1895,14 +1898,41 @@ static VLCMainWindow *_o_sharedInstance = nil; ...@@ -1895,14 +1898,41 @@ static VLCMainWindow *_o_sharedInstance = nil;
- (NSMenu*)sourceList:(PXSourceList*)aSourceList menuForEvent:(NSEvent*)theEvent item:(id)item - (NSMenu*)sourceList:(PXSourceList*)aSourceList menuForEvent:(NSEvent*)theEvent item:(id)item
{ {
if ([theEvent type] == NSRightMouseDown || ([theEvent type] == NSLeftMouseDown && ([theEvent modifierFlags] & NSControlKeyMask) == NSControlKeyMask)) { if ([theEvent type] == NSRightMouseDown || ([theEvent type] == NSLeftMouseDown && ([theEvent modifierFlags] & NSControlKeyMask) == NSControlKeyMask)) {
NSMenu * m = [[NSMenu alloc] init];
if (item != nil) if (item != nil)
[m addItemWithTitle:[item title] action:nil keyEquivalent:@""]; {
NSMenu * m;
if ([item sdtype] > 0)
{
m = [[NSMenu alloc] init];
playlist_t * p_playlist = pl_Get( VLCIntf );
BOOL sd_loaded = playlist_IsServicesDiscoveryLoaded( p_playlist, [[item identifier] UTF8String] );
if (!sd_loaded)
[m addItemWithTitle:_NS("Enable") action:@selector(sdmenuhandler:) keyEquivalent:@""];
else
[m addItemWithTitle:_NS("Disable") action:@selector(sdmenuhandler:) keyEquivalent:@""];
[[m itemAtIndex:0] setRepresentedObject: [item identifier]];
}
return [m autorelease]; return [m autorelease];
} }
}
return nil; return nil;
} }
- (IBAction)sdmenuhandler:(id)sender
{
NSString * identifier = [sender representedObject];
if ([identifier length] > 0 && ![identifier isEqualToString:@"lua{sd='freebox',longname='Freebox TV'}"])
{
playlist_t * p_playlist = pl_Get( VLCIntf );
BOOL sd_loaded = playlist_IsServicesDiscoveryLoaded( p_playlist, [identifier UTF8String] );
if (!sd_loaded)
playlist_ServicesDiscoveryAdd( p_playlist, [identifier UTF8String] );
else
playlist_ServicesDiscoveryRemove( p_playlist, [identifier UTF8String] );
}
}
#pragma mark - #pragma mark -
#pragma mark Side Bar Delegate Methods #pragma mark Side Bar Delegate Methods
/* taken under BSD-new from the PXSourceList sample project, adapted for VLC */ /* taken under BSD-new from the PXSourceList sample project, adapted for VLC */
...@@ -1917,9 +1947,18 @@ static VLCMainWindow *_o_sharedInstance = nil; ...@@ -1917,9 +1947,18 @@ static VLCMainWindow *_o_sharedInstance = nil;
//Set the label text to represent the new selection //Set the label text to represent the new selection
if([selectedIndexes count]==1) { if([selectedIndexes count]==1) {
NSString *title = [[o_sidebar_view itemAtRow:[selectedIndexes firstIndex]] title]; id item = [o_sidebar_view itemAtRow:[selectedIndexes firstIndex]];
if ([item sdtype] > -1)
{
playlist_t * p_playlist = pl_Get( VLCIntf );
BOOL sd_loaded = playlist_IsServicesDiscoveryLoaded( p_playlist, [[item identifier] UTF8String] );
if (!sd_loaded)
{
playlist_ServicesDiscoveryAdd( p_playlist, [[item identifier] UTF8String] );
}
}
[o_chosen_category_lbl setStringValue:title]; [o_chosen_category_lbl setStringValue:[item title]];
} }
else { else {
[o_chosen_category_lbl setStringValue:@"(none)"]; [o_chosen_category_lbl setStringValue:@"(none)"];
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
// //
#import "PXSourceList.h" #import "PXSourceList.h"
#import "SideBarItem.h"
//Layout constants //Layout constants
#define MIN_BADGE_WIDTH 22.0 //The minimum badge width for each item (default 22.0) #define MIN_BADGE_WIDTH 22.0 //The minimum badge width for each item (default 22.0)
...@@ -610,7 +611,10 @@ NSString * const PXSLDeleteKeyPressedOnRowsNotification = @"PXSourceListDeleteKe ...@@ -610,7 +611,10 @@ NSString * const PXSLDeleteKeyPressedOnRowsNotification = @"PXSourceListDeleteKe
NSPoint clickPoint = [self convertPoint:[theEvent locationInWindow] fromView:nil]; NSPoint clickPoint = [self convertPoint:[theEvent locationInWindow] fromView:nil];
NSInteger row = [self rowAtPoint:clickPoint]; NSInteger row = [self rowAtPoint:clickPoint];
id clickedItem = [self itemAtRow:row]; id clickedItem = [self itemAtRow:row];
if ([clickedItem sdtype] > 0)
m = [_secondaryDelegate sourceList:self menuForEvent:theEvent item:clickedItem]; m = [_secondaryDelegate sourceList:self menuForEvent:theEvent item:clickedItem];
else
m = [super menuForEvent:theEvent];
} }
if (m == nil) { if (m == nil) {
m = [super menuForEvent:theEvent]; m = [super menuForEvent:theEvent];
......
...@@ -32,6 +32,7 @@ ...@@ -32,6 +32,7 @@
NSString *identifier; NSString *identifier;
NSImage *icon; NSImage *icon;
NSInteger badgeValue; NSInteger badgeValue;
NSInteger sdtype;
NSArray *children; NSArray *children;
} }
...@@ -40,6 +41,7 @@ ...@@ -40,6 +41,7 @@
@property (nonatomic, copy) NSString *identifier; @property (nonatomic, copy) NSString *identifier;
@property (nonatomic, retain) NSImage *icon; @property (nonatomic, retain) NSImage *icon;
@property NSInteger badgeValue; @property NSInteger badgeValue;
@property NSInteger sdtype;
@property (nonatomic, copy) NSArray *children; @property (nonatomic, copy) NSArray *children;
......
...@@ -20,6 +20,7 @@ ...@@ -20,6 +20,7 @@
@synthesize icon; @synthesize icon;
@synthesize badgeValue; @synthesize badgeValue;
@synthesize children; @synthesize children;
@synthesize sdtype;
#pragma mark - #pragma mark -
#pragma mark Init/Dealloc/Finalize #pragma mark Init/Dealloc/Finalize
...@@ -29,6 +30,7 @@ ...@@ -29,6 +30,7 @@
if(self=[super init]) if(self=[super init])
{ {
badgeValue = -1; //We don't want a badge value by default badgeValue = -1; //We don't want a badge value by default
sdtype = -1; //no sd type set
} }
return self; return self;
......
...@@ -520,6 +520,7 @@ ...@@ -520,6 +520,7 @@
[[[[VLCMain sharedInstance] bookmarks] dataTable] reloadData]; [[[[VLCMain sharedInstance] bookmarks] dataTable] reloadData];
[self outlineViewSelectionDidChange: nil]; [self outlineViewSelectionDidChange: nil];
[[VLCMain sharedInstance] updateMainWindow];
} }
- (void)outlineViewSelectionDidChange:(NSNotification *)notification - (void)outlineViewSelectionDidChange:(NSNotification *)notification
......
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