Commit 06e1cd04 authored by Felix Paul Kühne's avatar Felix Paul Kühne

macosx: fill the side bar with SDs, etc.

note: playlist view isn't connected to the side bar yet
parent 0084be7d
......@@ -472,6 +472,8 @@
CCC593790AB4A9FB0004FF52 /* embeddedwindow.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = embeddedwindow.m; path = ../../../modules/gui/macosx/embeddedwindow.m; sourceTree = SOURCE_ROOT; };
CCC895830D9A8A82005AE59C /* eyetv.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = eyetv.m; path = ../../../modules/access/eyetv.m; sourceTree = SOURCE_ROOT; };
CCC896B90D9AA9E8005AE59C /* English */ = {isa = PBXFileReference; lastKnownFileType = wrapper.nib; name = English; path = Resources/English.lproj/MediaInfo.nib; sourceTree = "<group>"; };
CCCDDEEF13E870BB00A35661 /* SideBarItem.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = SideBarItem.h; path = ../../../modules/gui/macosx/SideBarItem.h; sourceTree = "<group>"; };
CCCDDEF013E870BB00A35661 /* SideBarItem.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; name = SideBarItem.m; path = ../../../modules/gui/macosx/SideBarItem.m; sourceTree = "<group>"; };
CCCE366D13817E4500694F2A /* VideoEffects.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = VideoEffects.h; path = ../../../modules/gui/macosx/VideoEffects.h; sourceTree = "<group>"; };
CCCE366E13817E4500694F2A /* VideoEffects.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; name = VideoEffects.m; path = ../../../modules/gui/macosx/VideoEffects.m; sourceTree = "<group>"; };
CCD590F010E5B73200D39094 /* dialogProvider.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = dialogProvider.h; path = ../../../modules/gui/macosx_dialog_provider/dialogProvider.h; sourceTree = SOURCE_ROOT; };
......@@ -813,6 +815,8 @@
CC0CD0E413DE0EB500B0D90D /* PXSourceList */ = {
isa = PBXGroup;
children = (
CCCDDEEF13E870BB00A35661 /* SideBarItem.h */,
CCCDDEF013E870BB00A35661 /* SideBarItem.m */,
CC0CD0DF13DE0EAE00B0D90D /* PXSourceList.h */,
CC0CD0E013DE0EAE00B0D90D /* PXSourceList.m */,
CC0CD0E113DE0EAE00B0D90D /* PXSourceListDataSource.h */,
......
......@@ -25,9 +25,14 @@
*****************************************************************************/
#import <Cocoa/Cocoa.h>
#import "PXSourceList.h"
#import <vlc_input.h>
@interface VLCMainWindow : NSWindow {
#ifndef MAC_OS_X_VERSION_10_6
@protocol NSWindowDelegate <NSObject> @end
#endif
@interface VLCMainWindow : NSWindow <PXSourceListDataSource, PXSourceListDelegate, NSWindowDelegate> {
IBOutlet id o_play_btn;
IBOutlet id o_bwd_btn;
IBOutlet id o_fwd_btn;
......@@ -82,6 +87,7 @@
NSTimeInterval last_bwd_event;
BOOL just_triggered_next;
BOOL just_triggered_previous;
NSMutableArray *o_sidebaritems;
}
+ (VLCMainWindow *)sharedInstance;
......
......@@ -31,10 +31,12 @@
#import "MainMenu.h"
#import "misc.h"
#import "controls.h" // TODO: remove me
#import "SideBarItem.h"
#import <vlc_playlist.h>
#import <vlc_aout_intf.h>
#import <vlc_url.h>
#import <vlc_strings.h>
#import <vlc_services_discovery.h>
@implementation VLCMainWindow
static VLCMainWindow *_o_sharedInstance = nil;
......@@ -93,11 +95,13 @@ static VLCMainWindow *_o_sharedInstance = nil;
- (void)dealloc
{
config_PutInt( VLCIntf->p_libvlc, "volume", i_lastShownVolume );
[o_sidebaritems release];
[super dealloc];
}
- (void)awakeFromNib
{
/* setup the styled interface */
b_dark_interface = config_GetInt( VLCIntf, "macosx-interfacestyle" );
i_lastShownVolume = -1;
......@@ -195,10 +199,10 @@ static VLCMainWindow *_o_sharedInstance = nil;
[o_repeat_btn setAlternateImage: o_repeat_pressed_img];
[o_shuffle_btn setImage: o_shuffle_img];
[o_shuffle_btn setAlternateImage: o_shuffle_pressed_img];
[o_play_btn setImage: o_play_img];
[o_play_btn setAlternateImage: o_play_pressed_img];
/* interface builder action */
[o_video_view setFrame: [o_split_view frame]];
[self setDelegate: self];
[self setExcludedFromWindowsMenu: YES];
......@@ -207,8 +211,79 @@ static VLCMainWindow *_o_sharedInstance = nil;
[self setTitle: _NS("VLC media player")];
[o_playlist_btn setEnabled:NO];
/* reset the interface */
[self updateVolumeSlider];
[self updateTimeSlider];
/* create the sidebar */
o_sidebaritems = [[NSMutableArray alloc] init];
SideBarItem *libraryItem = [SideBarItem itemWithTitle:_NS("LIBRARY") identifier:@"library"];
SideBarItem *playlistItem = [SideBarItem itemWithTitle:_NS("Playlist") identifier:@"playlist"];
SideBarItem *mycompItem = [SideBarItem itemWithTitle:_NS("MY COMPUTER") identifier:@"mycomputer"];
SideBarItem *devicesItem = [SideBarItem itemWithTitle:_NS("DEVICES") identifier:@"devices"];
SideBarItem *lanItem = [SideBarItem itemWithTitle:_NS("LOCAL NETWORK") identifier:@"localnetwork"];
SideBarItem *internetItem = [SideBarItem itemWithTitle:_NS("INTERNET") identifier:@"internet"];
/* SD subnodes, inspired by the Qt4 intf */
char **ppsz_longnames;
int *p_categories;
char **ppsz_names = vlc_sd_GetNames( pl_Get( VLCIntf ), &ppsz_longnames, &p_categories );
if (!ppsz_names)
msg_Err( VLCIntf, "no sd item found" ); //TODO
char **ppsz_name = ppsz_names, **ppsz_longname = ppsz_longnames;
int *p_category = p_categories;
NSMutableArray *internetItems = [[NSMutableArray alloc] init];
NSMutableArray *devicesItems = [[NSMutableArray alloc] init];
NSMutableArray *lanItems = [[NSMutableArray alloc] init];
NSMutableArray *mycompItems = [[NSMutableArray alloc] init];
for (; *ppsz_name; ppsz_name++, ppsz_longname++, p_category++)
{
switch (*p_category) {
case SD_CAT_INTERNET:
[internetItems addObject: [SideBarItem itemWithTitle: [NSString stringWithCString: *ppsz_longname encoding: NSUTF8StringEncoding] identifier: [NSString stringWithCString: *ppsz_name encoding: NSUTF8StringEncoding]]];
break;
case SD_CAT_DEVICES:
[devicesItems addObject: [SideBarItem itemWithTitle: [NSString stringWithCString: *ppsz_longname encoding: NSUTF8StringEncoding] identifier: [NSString stringWithCString: *ppsz_name encoding: NSUTF8StringEncoding]]];
break;
case SD_CAT_LAN:
[lanItems addObject: [SideBarItem itemWithTitle: [NSString stringWithCString: *ppsz_longname encoding: NSUTF8StringEncoding] identifier: [NSString stringWithCString: *ppsz_name encoding: NSUTF8StringEncoding]]];
break;
case SD_CAT_MYCOMPUTER:
[mycompItems addObject: [SideBarItem itemWithTitle: [NSString stringWithCString: *ppsz_longname encoding: NSUTF8StringEncoding] identifier: [NSString stringWithCString: *ppsz_name encoding: NSUTF8StringEncoding]]];
break;
default:
msg_Warn( VLCIntf, "unknown SD type found, skipping (%s)", *ppsz_name );
break;
}
free( *ppsz_name );
free( *ppsz_longname );
}
[mycompItem setChildren: [NSArray arrayWithArray: mycompItems]];
[devicesItem setChildren: [NSArray arrayWithArray: devicesItems]];
[lanItem setChildren: [NSArray arrayWithArray: lanItems]];
[internetItem setChildren: [NSArray arrayWithArray: internetItems]];
[mycompItems release];
[devicesItems release];
[lanItems release];
[internetItems release];
free( ppsz_names );
free( ppsz_longnames );
free( p_categories );
[libraryItem setChildren: [NSArray arrayWithObject: playlistItem]];
[o_sidebaritems addObject: libraryItem];
if ([mycompItem hasChildren])
[o_sidebaritems addObject: mycompItem];
if ([devicesItem hasChildren])
[o_sidebaritems addObject: devicesItem];
if ([lanItem hasChildren])
[o_sidebaritems addObject: lanItem];
if ([internetItem hasChildren])
[o_sidebaritems addObject: internetItem];
msg_Dbg( VLCIntf, "side bar should contain %lu items", [o_sidebaritems count] );
[o_sidebar_view reloadData];
}
#pragma mark -
......@@ -682,6 +757,109 @@ static VLCMainWindow *_o_sharedInstance = nil;
[o_playlist_btn setEnabled: [[VLCMain sharedInstance] activeVideoPlayback]];
}
#pragma mark -
#pragma mark Side Bar Data handling
/* taken under BSD-new from the PXSourceList sample project, adapted for VLC */
- (NSUInteger)sourceList:(PXSourceList*)sourceList numberOfChildrenOfItem:(id)item
{
//Works the same way as the NSOutlineView data source: `nil` means a parent item
if(item==nil) {
return [o_sidebaritems count];
}
else {
return [[item children] count];
}
}
- (id)sourceList:(PXSourceList*)aSourceList child:(NSUInteger)index ofItem:(id)item
{
//Works the same way as the NSOutlineView data source: `nil` means a parent item
if(item==nil) {
return [o_sidebaritems objectAtIndex:index];
}
else {
return [[item children] objectAtIndex:index];
}
}
- (id)sourceList:(PXSourceList*)aSourceList objectValueForItem:(id)item
{
return [item title];
}
- (void)sourceList:(PXSourceList*)aSourceList setObjectValue:(id)object forItem:(id)item
{
[item setTitle:object];
}
- (BOOL)sourceList:(PXSourceList*)aSourceList isItemExpandable:(id)item
{
return [item hasChildren];
}
- (BOOL)sourceList:(PXSourceList*)aSourceList itemHasBadge:(id)item
{
return [item hasBadge];
}
- (NSInteger)sourceList:(PXSourceList*)aSourceList badgeValueForItem:(id)item
{
return [item badgeValue];
}
- (BOOL)sourceList:(PXSourceList*)aSourceList itemHasIcon:(id)item
{
return [item hasIcon];
}
- (NSImage*)sourceList:(PXSourceList*)aSourceList iconForItem:(id)item
{
return [item icon];
}
- (NSMenu*)sourceList:(PXSourceList*)aSourceList menuForEvent:(NSEvent*)theEvent item:(id)item
{
if ([theEvent type] == NSRightMouseDown || ([theEvent type] == NSLeftMouseDown && ([theEvent modifierFlags] & NSControlKeyMask) == NSControlKeyMask)) {
NSMenu * m = [[NSMenu alloc] init];
if (item != nil)
[m addItemWithTitle:[item title] action:nil keyEquivalent:@""];
return [m autorelease];
}
return nil;
}
#pragma mark -
#pragma mark Side Bar Delegate Methods
/* taken under BSD-new from the PXSourceList sample project, adapted for VLC */
- (BOOL)sourceList:(PXSourceList*)aSourceList isGroupAlwaysExpanded:(id)group
{
if([[group identifier] isEqualToString:@"library"])
return YES;
return NO;
}
- (void)sourceListSelectionDidChange:(NSNotification *)notification
{
NSIndexSet *selectedIndexes = [o_sidebar_view selectedRowIndexes];
//Set the label text to represent the new selection
if([selectedIndexes count]==1) {
NSString *title = [[o_sidebar_view itemAtRow:[selectedIndexes firstIndex]] title];
[o_chosen_category_lbl setStringValue:title];
}
else {
[o_chosen_category_lbl setStringValue:@"(none)"];
}
}
@end
@implementation VLCProgressBarGradientEffect
......
......@@ -59,6 +59,8 @@ SOURCES_macosx = \
PXSourceList.m \
PXSourceListDataSource.h \
PXSourceListDelegate.h \
SideBarItem.h \
SideBarItem.m \
fspanel.m \
fspanel.h \
eyetv.h \
......
//
// SourceListItem.h
// PXSourceList
//
// Created by Alex Rozanski on 08/01/2010.
// Copyright 2010 Alex Rozanski http://perspx.com
//
// Adapted to VLC media player by Felix Paul Kühne
//
#import <Cocoa/Cocoa.h>
/*An example of a class that could be used to represent a Source List Item
Provides a title, an identifier, and an icon to be shown, as well as a badge value and a property to determine
whether the current item has a badge or not (`badgeValue` is set to -1 if no badge is shown)
Used to form a hierarchical model of SourceListItem instances – similar to the Source List tree structure
and easily accessible by the data source with the "children" property
SourceListItem *parent
- SourceListItem *child1;
- SourceListItem *child2;
- SourceListItem *childOfChild2;
- SourceListItem *anotherChildOfChild2;
- SourceListItem *child3;
*/
@interface SideBarItem : NSObject {
NSString *title;
NSString *identifier;
NSImage *icon;
NSInteger badgeValue;
NSArray *children;
}
@property (nonatomic, copy) NSString *title;
@property (nonatomic, copy) NSString *identifier;
@property (nonatomic, retain) NSImage *icon;
@property NSInteger badgeValue;
@property (nonatomic, copy) NSArray *children;
//Convenience methods
+ (id)itemWithTitle:(NSString*)aTitle identifier:(NSString*)anIdentifier;
+ (id)itemWithTitle:(NSString*)aTitle identifier:(NSString*)anIdentifier icon:(NSImage*)anIcon;
- (BOOL)hasBadge;
- (BOOL)hasChildren;
- (BOOL)hasIcon;
@end
//
// SideBarItem.m
// PXSourceList
//
// Created by Alex Rozanski on 08/01/2010.
// Copyright 2010 Alex Rozanski http://perspx.com
//
// GC-enabled code revised by Stefan Vogt http://byteproject.net
//
// Adapted to VLC media player by Felix Paul Kühne
#import "SideBarItem.h"
@implementation SideBarItem
@synthesize title;
@synthesize identifier;
@synthesize icon;
@synthesize badgeValue;
@synthesize children;
#pragma mark -
#pragma mark Init/Dealloc/Finalize
- (id)init
{
if(self=[super init])
{
badgeValue = -1; //We don't want a badge value by default
}
return self;
}
+ (id)itemWithTitle:(NSString*)aTitle identifier:(NSString*)anIdentifier
{
SideBarItem *item = [SideBarItem itemWithTitle:aTitle identifier:anIdentifier icon:nil];
return item;
}
+ (id)itemWithTitle:(NSString*)aTitle identifier:(NSString*)anIdentifier icon:(NSImage*)anIcon
{
SideBarItem *item = [[[SideBarItem alloc] init] autorelease];
[item setTitle:aTitle];
[item setIdentifier:anIdentifier];
[item setIcon:anIcon];
return item;
}
- (void)dealloc
{
[title release];
[identifier release];
[icon release];
[children release];
[super dealloc];
}
- (void)finalize
{
title = nil;
identifier = nil;
icon = nil;
children = nil;
[super finalize];
}
#pragma mark -
#pragma mark Custom Accessors
- (BOOL)hasBadge
{
return badgeValue!=-1;
}
- (BOOL)hasChildren
{
return [children count]>0;
}
- (BOOL)hasIcon
{
return icon!=nil;
}
@end
......@@ -27,7 +27,11 @@
#import "misc.h"
@interface VLCEmbeddedWindow : NSWindow
#ifndef MAC_OS_X_VERSION_10_6
@protocol NSAnimationDelegate <NSObject> @end
#endif
@interface VLCEmbeddedWindow : NSWindow <NSWindowDelegate, NSAnimationDelegate>
{
IBOutlet id o_btn_backward;
IBOutlet id o_btn_forward;
......
......@@ -78,12 +78,15 @@ struct intf_sys_t
/*****************************************************************************
* VLCMain interface
*****************************************************************************/
#ifndef MAC_OS_X_VERSION_10_6
@protocol NSWindowDelegate <NSObject> @end
#endif
@class AppleRemote;
@class VLCInformation;
@class VLCEmbeddedWindow;
@class VLCControls;
@class VLCPlaylist;
@interface VLCMain : NSObject
@interface VLCMain : NSObject <NSWindowDelegate>
{
intf_thread_t *p_intf; /* The main intf object */
id o_mainmenu; /* VLCMainMenu */
......
......@@ -289,7 +289,8 @@ static int InputEvent( vlc_object_t *p_this, const char *psz_var,
break;
case INPUT_EVENT_DEAD:
//NSLog( @"dying input" );
[[VLCMain sharedInstance] updateName];
[[VLCMain sharedInstance] updateTimeSlider];
break;
case INPUT_EVENT_ABORT:
......
......@@ -25,6 +25,10 @@
#import <Cocoa/Cocoa.h>
#import <ApplicationServices/ApplicationServices.h>
#ifndef MAC_OS_X_VERSION_10_6
@protocol NSWindowDelegate <NSObject> @end
#endif
/*****************************************************************************
* NSAnimation (VLCAddition)
*****************************************************************************/
......@@ -56,7 +60,7 @@
* Missing extension to NSWindow
*****************************************************************************/
@interface VLCWindow : NSWindow
@interface VLCWindow : NSWindow <NSWindowDelegate>
{
BOOL b_canBecomeKeyWindow;
BOOL b_isset_canBecomeKeyWindow;
......
......@@ -34,17 +34,20 @@
/*****************************************************************************
* VLCPlaylistCommon interface
*****************************************************************************/
@interface VLCPlaylistCommon : NSObject
#ifndef MAC_OS_X_VERSION_10_6
@protocol NSOutlineViewDataSource <NSObject> @end
#endif
@interface VLCPlaylistCommon : NSObject <NSOutlineViewDataSource, NSOutlineViewDelegate>
{
IBOutlet id o_tc_name;
IBOutlet id o_tc_author;
IBOutlet id o_tc_duration;
IBOutlet id o_outline_view;
IBOutlet VLCPlaylistView* o_outline_view;
IBOutlet id o_tc_name_other;
IBOutlet id o_tc_author_other;
IBOutlet id o_tc_duration_other;
IBOutlet id o_outline_view_other;
IBOutlet VLCPlaylistView* o_outline_view_other;
NSMutableDictionary *o_outline_dict;
}
......
......@@ -26,6 +26,11 @@
#define LEFTMARGIN 18
#define RIGHTMARGIN 18
#ifndef MAC_OS_X_VERSION_10_6
@protocol NSComboBoxDataSource <NSObject> @end
@protocol NSTextFieldDelegate <NSObject> @end
#endif
static NSMenu *o_keys_menu = nil;
@interface VLCConfigControl : NSView
......@@ -68,7 +73,7 @@ static NSMenu *o_keys_menu = nil;
@end
@interface StringListConfigControl : VLCConfigControl
@interface StringListConfigControl : VLCConfigControl <NSComboBoxDataSource>
{
NSComboBox *o_combo;
}
......@@ -103,7 +108,7 @@ static NSMenu *o_keys_menu = nil;
@end
@interface IntegerConfigControl : VLCConfigControl
@interface IntegerConfigControl : VLCConfigControl <NSTextFieldDelegate>
{
NSTextField *o_textfield;
NSStepper *o_stepper;
......@@ -117,7 +122,7 @@ static NSMenu *o_keys_menu = nil;
@end
@interface IntegerListConfigControl : VLCConfigControl
@interface IntegerListConfigControl : VLCConfigControl <NSComboBoxDataSource>
{
NSComboBox *o_combo;
}
......@@ -127,7 +132,7 @@ static NSMenu *o_keys_menu = nil;
@end
@interface RangedIntegerConfigControl : VLCConfigControl
@interface RangedIntegerConfigControl : VLCConfigControl <NSTextFieldDelegate>
{
NSSlider *o_slider;
NSTextField *o_textfield;
......@@ -153,7 +158,7 @@ static NSMenu *o_keys_menu = nil;
@end
@interface FloatConfigControl : VLCConfigControl
@interface FloatConfigControl : VLCConfigControl <NSTextFieldDelegate>
{
NSTextField *o_textfield;
NSStepper *o_stepper;
......@@ -167,7 +172,7 @@ static NSMenu *o_keys_menu = nil;
@end
@interface RangedFloatConfigControl : VLCConfigControl
@interface RangedFloatConfigControl : VLCConfigControl <NSTextFieldDelegate>
{
NSSlider *o_slider;
NSTextField *o_textfield;
......@@ -193,7 +198,7 @@ static NSMenu *o_keys_menu = nil;
@end
@interface ModuleListConfigControl : VLCConfigControl
@interface ModuleListConfigControl : VLCConfigControl <NSTableViewDataSource>
{
NSTextField *o_textfield;
NSScrollView *o_scrollview;
......
......@@ -25,7 +25,11 @@
#import "intf.h"
#import <vlc_common.h>
@interface VLCSimplePrefs : NSObject
#ifndef MAC_OS_X_VERSION_10_6
@protocol NSToolbarDelegate <NSObject> @end
#endif
@interface VLCSimplePrefs : NSObject <NSToolbarDelegate>
{
IBOutlet id o_audio_dolby_pop;
IBOutlet id o_audio_dolby_txt;
......
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