msg_Dbg( p_access, "plugin notified" );
- close(p_sys->eyetvSock);
+
+close(p_sys->eyetvSock);
msg_Dbg( p_access, "msg port closed and freed" );
*pi_64 =
INT64_C(1000) * var_InheritInteger( p_access, "live-caching" );
break;
-
+
case ACCESS_SET_PAUSE_STATE:
case ACCESS_GET_TITLE_INFO:
case ACCESS_SET_TITLE:
{
CVImageBufferRef imageBuffer;
mtime_t pts;
- void * pixels;
+
+void * pixels;
if(!currentImageBuffer || currentPts == previousPts )
return 0;
memcpy( buffer, pixels, CVPixelBufferGetBytesPerRow(imageBuffer) * CVPixelBufferGetHeight(imageBuffer));
CVPixelBufferUnlockBaseAddress(imageBuffer, 0);
}
-
+
}
CVBufferRelease(imageBuffer);
- if(pixels)
- return currentPts;
- else
- return 0;
+ if(pixels)
+ return currentPts;
+ else
+ return 0;
}
@end
kRemoteControl_Switched =1<<11,
kRemoteButtonVolume_Plus_Hold =1<<12,
kRemoteButtonVolume_Minus_Hold =1<<13,
- k2009RemoteButtonPlay =1<<14,
- k2009RemoteButtonFullscreen =1<<15
+ k2009RemoteButtonPlay
+
+ =1<<14,
+ k2009RemoteButtonFullscreen
+ =1<<15
};
typedef enum AppleRemoteEventIdentifier AppleRemoteEventIdentifier;
[cookieToButtonMapping setObject:[NSNumber numberWithInt:kRemoteButtonPlay_Sleep] forKey:@"37_33_21_20_2_37_33_21_20_2_"];
[cookieToButtonMapping setObject:[NSNumber numberWithInt:kRemoteControl_Switched] forKey:@"42_33_23_21_20_2_33_23_21_20_2_"];
[cookieToButtonMapping setObject:[NSNumber numberWithInt:k2009RemoteButtonPlay] forKey:@"33_21_20_8_2_33_21_20_8_2_"];
- [cookieToButtonMapping setObject:[NSNumber numberWithInt:k2009RemoteButtonFullscreen] forKey:@"33_21_20_3_2_33_21_20_3_2_"];
+ [cookieToButtonMapping setObject:[NSNumber numberWithInt:k2009RemoteButtonFullscreen] forKey:@"33_21_20_3_2_33_21_20_3_2_"];
}
else
{
cookieString = [previousRemainingCookieString stringByAppendingString: cookieString];
NSLog(@"New cookie string is %@", cookieString);
[previousRemainingCookieString release], previousRemainingCookieString=nil;
- }*/
+ }*/
if (cookieString == nil || [cookieString length] == 0) return;
NSNumber* buttonId = [[self cookieToButtonMapping] objectForKey: cookieString];
if (buttonId != nil) {
IBOutlet id o_comp_band7_sld;
IBOutlet id o_comp_band7_fld;
IBOutlet id o_comp_band7_lbl;
-
+
/* Spatializer */
IBOutlet id o_spat_enable_ckb;
IBOutlet id o_spat_reset_btn;
p_intf = VLCIntf;
_o_sharedInstance = [super init];
}
-
+
return _o_sharedInstance;
}
[o_comp_band5_lbl setStringValue:_NS("Ratio")];
[o_comp_band6_lbl setStringValue:_NS("Knee radius")];
[o_comp_band7_lbl setStringValue:_NS("Makeup gain")];
-
+
/* Spatializer */
[o_spat_enable_ckb setTitle:_NS("Enable Spatializer")];
[o_spat_reset_btn setTitle:_NS("Reset")];
[o_spat_band3_lbl setStringValue:_NS("Wet")];
[o_spat_band4_lbl setStringValue:_NS("Dry")];
[o_spat_band5_lbl setStringValue:_NS("Dump")];
-
+
/* Filter */
[o_filter_headPhone_ckb setTitle:_NS("Headphone virtualization")];
[o_filter_normLevel_ckb setTitle:_NS("Volume normalization")];
[o_filter_normLevel_lbl setStringValue:_NS("Maximum level")];
-
+
/* generic */
[[o_tableView tabViewItemAtIndex:[o_tableView indexOfTabViewItemWithIdentifier:@"equalizer"]] setLabel:_NS("Equalizer")];
[[o_tableView tabViewItemAtIndex:[o_tableView indexOfTabViewItemWithIdentifier:@"compressor"]] setLabel:_NS("Compressor")];
if( p_aout )
psz_tmp = var_GetNonEmptyString( p_aout, "audio-filter" );
else
- psz_tmp = config_GetPsz( p_intf, "audio-filter" );
-
+ psz_tmp = config_GetPsz( p_intf, "audio-filter" );
+
if( b_on )
{
if(! psz_tmp)
vlc_object_t *p_object = VLC_OBJECT(getAout());
if( p_object == NULL )
p_object = vlc_object_hold(pl_Get( p_custom_intf ));
-
+
psz_string = config_GetPsz( p_custom_intf, "audio-filter" );
-
+
if(! psz_string )
psz_string = var_GetNonEmptyString( p_object, "audio-filter" );
-
+
vlc_object_release( p_object );
-
+
if( !psz_string ) return false;
-
+
psz_parser = strstr( psz_string, psz_name );
-
+
free( psz_string );
-
+
if ( psz_parser )
return true;
else
eqz_preset_10b[i].f_amp[7],
eqz_preset_10b[i].f_amp[8],
eqz_preset_10b[i].f_amp[9] );
-
+
var_Create( p_object, "equalizer-preamp", VLC_VAR_FLOAT | VLC_VAR_DOINHERIT );
var_Create( p_object, "equalizer-bands", VLC_VAR_STRING | VLC_VAR_DOINHERIT );
var_SetFloat( p_object, "equalizer-preamp", eqz_preset_10b[i].f_preamp );
bool b_2p;
bool b_enabled = GetEqualizerStatus( p_intf, (char *)"equalizer" );
vlc_object_t *p_object = VLC_OBJECT(getAout());
-
+
if( p_object == NULL )
p_object = vlc_object_hold(pl_Get( p_intf ));
-
+
var_Create( p_object, "equalizer-preamp", VLC_VAR_FLOAT |
VLC_VAR_DOINHERIT );
var_Create( p_object, "equalizer-bands", VLC_VAR_STRING |
VLC_VAR_DOINHERIT );
-
+
psz_bands = var_GetNonEmptyString( p_object, "equalizer-bands" );
-
+
if( psz_bands == NULL )
psz_bands = strdup( "0 0 0 0 0 0 0 0 0 0" );
f_preamp = config_GetFloat( p_object, "equalizer-preamp" );
vlc_object_release( p_object );
-
+
/* Set the preamp slider */
[o_eq_preamp_sld setFloatValue: f_preamp];
/* Set the bands slider */
psz_bands_init = psz_bands;
-
+
for( int i = 0; i < 10; i++ )
{
/* Read dB -20/20 */
f_band[i] = strtof( psz_bands, &p_next );
if( !p_next || p_next == psz_bands ) break; /* strtof() failed */
-
+
if( !*psz_bands ) break; /* end of line */
psz_bands = p_next+1;
}
free( psz_bands_init );
[self setBandSlidersValues:f_band];
-
+
/* Set the the checkboxes */
[o_eq_enable_ckb setState: b_enabled];
[o_eq_twopass_ckb setState: b_2p];
- (void)setValue:(float)value forSlider:(int)index
{
id slider = [self sliderByIndex:index];
-
+
if (slider != nil)
[slider setFloatValue:value];
}
- (IBAction)eq_bandSliderUpdated:(id)sender
{
vlc_object_t *p_object = VLC_OBJECT(getAout());
-
+
if( p_object == NULL )
p_object = vlc_object_hold(pl_Get( p_intf ));
-
+
const char *psz_values;
NSString *preset = [NSString stringWithFormat:@"%.1f ", [o_eq_band1_sld floatValue] ];
preset = [preset stringByAppendingFormat:@"%.1f ", [o_eq_band2_sld floatValue] ];
}
else
[o_spat_enable_ckb setState: NSOffState];
-
+
[o_spat_band1_sld setFloatValue: config_GetFloat( p_intf, "spatializer-roomsize" )];
[o_spat_band1_fld setStringValue:[NSString localizedStringWithFormat:@"%1.1f", [o_spat_band1_sld floatValue]]];
[o_spat_band2_sld setFloatValue: config_GetFloat( p_intf, "spatializer-width" )];
- (IBAction)spat_enable:(id)sender
{
- [self setAudioFilter:"spatializer" on:[sender state]];
+ [self setAudioFilter:"spatializer" on:[sender state]];
}
- (IBAction)spat_sliderUpdated:(id)sender
value = "spatializer-dry";
else if( sender == o_spat_band5_sld )
value = "spatializer-damp";
-
+
if( p_aout ) {
var_SetFloat( p_aout, value, [sender floatValue] );
vlc_object_release( p_aout );
}
config_PutFloat( p_intf, value, [sender floatValue] );
-
+
if( sender == o_spat_band1_sld )
[o_spat_band1_fld setStringValue:[NSString localizedStringWithFormat:@"%1.1f", [sender floatValue]]];
else if( sender == o_spat_band2_sld )
- (IBAction)filter_enableVolumeNorm:(id)sender
{
- [self setAudioFilter: "normvol" on:[sender state]];
+ [self setAudioFilter: "normvol" on:[sender state]];
}
- (IBAction)filter_volNormSliderUpdated:(id)sender
_o_sharedInstance = [super init];
b_lockAspectRatio = YES;
}
-
+
return _o_sharedInstance;
}
{
playlist_t * p_playlist = pl_Get( VLCIntf );
bool empty;
-
+
PL_LOCK;
empty = playlist_IsEmpty( p_playlist );
PL_UNLOCK;
-
+
if( empty )
[[[VLCMain sharedInstance] open] openFileGeneric];
-
+
var_SetInteger( VLCIntf->p_libvlc, "key-action", ACTIONID_PLAY_PAUSE );
}
- (void)dealloc
{
[[NSNotificationCenter defaultCenter] removeObserver: self];
-
+
if (b_nib_about_loaded)
[o_about release];
- (void)releaseRepresentedObjects:(NSMenu *)the_menu
{
if( !p_intf ) return;
-
+
NSArray *menuitems_array = [the_menu itemArray];
NSUInteger menuItemCount = [menuitems_array count];
for( NSUInteger i=0; i < menuItemCount; i++ )
bool b_value;
playlist_t *p_playlist = pl_Get( VLCIntf );
b_value = var_GetBool( p_playlist, "random" );
- [o_mi_random setState: b_value];
+
+ [o_mi_random setState: b_value];
}
#pragma mark -
if( i_type & VLC_VAR_HASCHOICE )
{
NSMenu *o_menu = [o_mi submenu];
-
+
[self setupVarMenu: o_menu forMenuItem: o_mi target:p_object
var:psz_variable selector:pf_callback];
-
+
free( text.psz_string );
return;
}
if( [o_title isEqualToString: _NS("Normal Size")] )
{
NSMenuItem *item = [[o_mi menu] itemWithTitle:_NS("Teletext")];
- bool b_telx = p_input && var_GetInteger( p_input, "teletext-es" ) >= 0;
+
+
+bool b_telx = p_input && var_GetInteger( p_input, "teletext-es" ) >= 0;
[[item submenu] setAutoenablesItems:NO];
for( int k=0; k < [[item submenu] numberOfItems]; k++ )
else
{
[o_effects_btn setImage: [NSImage imageNamed:@"effects-double-buttons_dark"]];
- [o_effects_btn setAlternateImage: [NSImage imageNamed:@"effects-double-buttons-pressed_dark"]];
+ [o_effects_btn setAlternateImage: [NSImage imageNamed:@"effects-double-buttons-pressed_dark"]];
}
[o_fullscreen_btn setImage: [NSImage imageNamed:@"fullscreen-double-buttons_dark"]];
[o_fullscreen_btn setAlternateImage: [NSImage imageNamed:@"fullscreen-double-buttons-pressed_dark"]];
bool b_value;
playlist_t *p_playlist = pl_Get( VLCIntf );
b_value = var_GetBool( p_playlist, "random" );
- if(b_value) {
+
+ if(b_value) {
[o_shuffle_btn setImage: o_shuffle_on_img];
[o_shuffle_btn setAlternateImage: o_shuffle_on_pressed_img];
}
- (BOOL)validateMenuItem:(NSMenuItem *)menuItem
{
- SEL s_menuAction = [menuItem action];
- if ((s_menuAction == @selector(performClose:)) || (s_menuAction == @selector(performMiniaturize:)) || (s_menuAction == @selector(performZoom:)))
- return YES;
+ SEL s_menuAction = [menuItem action];
- return [super validateMenuItem:menuItem];
+ if ((s_menuAction == @selector(performClose:)) || (s_menuAction == @selector(performMiniaturize:)) || (s_menuAction == @selector(performZoom:)))
+ return YES;
+
+ return [super validateMenuItem:menuItem];
}
- (BOOL)isMainWindow
{
- return YES;
+
+return YES;
}
- (void)setTitle:(NSString *)title
[o_nonembedded_window orderOut: self];
else
[super orderOut: self];
-
+
[self unlockFullscreenAnimation];
return;
}
NSRect winrect;
CGFloat f_titleBarHeight = [o_titlebar_view frame].size.height;
winrect = [self frame];
-
+
[o_titlebar_view setFrame: NSMakeRect( 0, winrect.size.height - f_titleBarHeight,
winrect.size.width, f_titleBarHeight )];
[[self contentView] addSubview: o_titlebar_view];
-
+
winrect.size.height = winrect.size.height + f_titleBarHeight;
[self setFrame: winrect display:NO animate:NO];
winrect = [o_split_view frame];
/* 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];
- }
+ //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];
- }
+ if(item==nil)
+ return [o_sidebaritems objectAtIndex:index];
+ else
+ return [[item children] objectAtIndex:index];
}
- (id)sourceList:(PXSourceList*)aSourceList objectValueForItem:(id)item
{
- return [item title];
+ return [item title];
}
- (void)sourceList:(PXSourceList*)aSourceList setObjectValue:(id)object forItem:(id)item
{
- [item setTitle:object];
+ [item setTitle:object];
}
- (BOOL)sourceList:(PXSourceList*)aSourceList isItemExpandable:(id)item
{
- return [item hasChildren];
+ return [item hasChildren];
}
if ([[item identifier] isEqualToString: @"playlist"] || [[item identifier] isEqualToString: @"medialibrary"])
return YES;
- return [item hasBadge];
+ return [item hasBadge];
}
return i_playlist_size;
}
- return [item badgeValue];
+
+ return [item badgeValue];
}
- (BOOL)sourceList:(PXSourceList*)aSourceList itemHasIcon:(id)item
{
- return [item hasIcon];
+ return [item hasIcon];
}
- (NSImage*)sourceList:(PXSourceList*)aSourceList iconForItem:(id)item
{
- return [item icon];
+ return [item icon];
}
- (NSMenu*)sourceList:(PXSourceList*)aSourceList menuForEvent:(NSEvent*)theEvent item:(id)item
{
- if ([theEvent type] == NSRightMouseDown || ([theEvent type] == NSLeftMouseDown && ([theEvent modifierFlags] & NSControlKeyMask) == NSControlKeyMask)) {
- if (item != nil)
+ if ([theEvent type] == NSRightMouseDown || ([theEvent type] == NSLeftMouseDown && ([theEvent modifierFlags] & NSControlKeyMask) == NSControlKeyMask))
+ {
+ if (item != nil)
{
NSMenu * m;
if ([item sdtype] > 0)
}
return [m autorelease];
}
- }
- return nil;
+ }
+
+ return nil;
}
- (IBAction)sdmenuhandler:(id)sender
- (void)sourceListSelectionDidChange:(NSNotification *)notification
{
playlist_t * p_playlist = pl_Get( VLCIntf );
- NSIndexSet *selectedIndexes = [o_sidebar_view selectedRowIndexes];
+
+ NSIndexSet *selectedIndexes = [o_sidebar_view selectedRowIndexes];
id item = [o_sidebar_view itemAtRow:[selectedIndexes firstIndex]];
- //Set the label text to represent the new selection
+
+ //Set the label text to represent the new selection
if ([item sdtype] > -1 && [[item identifier] length] > 0)
{
BOOL sd_loaded = playlist_IsServicesDiscoveryLoaded( p_playlist, [[item identifier] UTF8String] );
o_yellow_on_img = [[NSImage imageNamed:@"lion-window-minimize-on-graphite"] retain];
o_green_img = [[NSImage imageNamed:@"lion-window-zoom-graphite"] retain];
o_green_over_img = [[NSImage imageNamed:@"lion-window-zoom-over-graphite"] retain];
- o_green_on_img = [[NSImage imageNamed:@"lion-window-zoom-on-graphite"] retain];
+ o_green_on_img = [[NSImage imageNamed:@"lion-window-zoom-on-graphite"] retain];
}
} else {
if( [NSColor currentControlTint] == NSBlueControlTint )
o_yellow_on_img = [[NSImage imageNamed:@"snowleo-window-minimize-on-graphite"] retain];
o_green_img = [[NSImage imageNamed:@"snowleo-window-zoom-graphite"] retain];
o_green_over_img = [[NSImage imageNamed:@"snowleo-window-zoom-over-graphite"] retain];
- o_green_on_img = [[NSImage imageNamed:@"snowleo-window-zoom-on-graphite"] retain];
+ o_green_on_img = [[NSImage imageNamed:@"snowleo-window-zoom-on-graphite"] retain];
}
}
}
- (NSArray*)accessibilityAttributeNames {
NSArray *theAttributeNames = [super accessibilityAttributeNames];
id theControlView = [self controlView];
- return ([theControlView respondsToSelector: @selector(extendedAccessibilityAttributeNames:)] ? [theControlView extendedAccessibilityAttributeNames: theAttributeNames] : theAttributeNames); // ask the cell's control view (i.e., the button) for additional attribute values
+ return ([theControlView respondsToSelector: @selector(extendedAccessibilityAttributeNames:)] ? [theControlView extendedAccessibilityAttributeNames: theAttributeNames] : theAttributeNames); // ask the cell's control view (i.e., the button) for additional attribute values
}
- (id)accessibilityAttributeValue: (NSString*)theAttributeName {
if ([theControlView respondsToSelector: @selector(extendedAccessibilityAttributeValue:)]) {
id theValue = [theControlView extendedAccessibilityAttributeValue: theAttributeName];
if (theValue) {
- return theValue; // if this is an extended attribute value we added, return that -- otherwise, fall back to super's implementation
+ return theValue; // if this is an extended attribute value we added, return that -- otherwise, fall back to super's implementation
}
}
return [super accessibilityAttributeValue: theAttributeName];
if ([theControlView respondsToSelector: @selector(extendedAccessibilityIsAttributeSettable:)]) {
NSNumber *theValue = [theControlView extendedAccessibilityIsAttributeSettable: theAttributeName];
if (theValue) {
- return [theValue boolValue]; // same basic strategy we use in -accessibilityAttributeValue:
+ return [theValue boolValue]; // same basic strategy we use in -accessibilityAttributeValue:
}
}
return [super accessibilityIsAttributeSettable: theAttributeName];
}
- (NSArray*)extendedAccessibilityAttributeNames: (NSArray*)theAttributeNames {
- return ([theAttributeNames containsObject: NSAccessibilitySubroleAttribute] ? theAttributeNames : [theAttributeNames arrayByAddingObject: NSAccessibilitySubroleAttribute]); // run-of-the-mill button cells don't usually have a Subrole attribute, so we add that attribute
+ return ([theAttributeNames containsObject: NSAccessibilitySubroleAttribute] ? theAttributeNames : [theAttributeNames arrayByAddingObject: NSAccessibilitySubroleAttribute]); // run-of-the-mill button cells don't usually have a Subrole attribute, so we add that attribute
}
- (id)extendedAccessibilityAttributeValue: (NSString*)theAttributeName {
}
- (NSNumber*)extendedAccessibilityIsAttributeSettable: (NSString*)theAttributeName {
- return ([theAttributeName isEqualToString: NSAccessibilitySubroleAttribute] ? [NSNumber numberWithBool: NO] : nil); // make the Subrole attribute we added non-settable
+ return ([theAttributeName isEqualToString: NSAccessibilitySubroleAttribute] ? [NSNumber numberWithBool: NO] : nil); // make the Subrole attribute we added non-settable
}
- (void)accessibilityPerformAction: (NSString*)theActionName {
@interface PXSourceList: NSOutlineView <NSOutlineViewDelegate, NSOutlineViewDataSource>
{
- id <PXSourceListDelegate> _secondaryDelegate; //Used to store the publicly visible delegate
- id <PXSourceListDataSource> _secondaryDataSource; //Used to store the publicly visible data source
-
- NSSize _iconSize; //The size of icons in the Source List. Defaults to 16x16
+ id <PXSourceListDelegate> _secondaryDelegate; //Used to store the publicly visible delegate
+ id <PXSourceListDataSource> _secondaryDataSource; //Used to store the publicly visible data source
+
+ NSSize _iconSize; //The size of icons in the Source List. Defaults to 16x16
}
-
+
@property (nonatomic) NSSize iconSize;
-
+
@property (assign) id<PXSourceListDataSource> dataSource;
@property (assign) id<PXSourceListDelegate> delegate;
-- (NSUInteger)numberOfGroups; //Returns the number of groups in the Source List
-- (BOOL)isGroupItem:(id)item; //Returns whether `item` is a group
-- (BOOL)isGroupAlwaysExpanded:(id)group; //Returns whether `group` is displayed as always expanded
+- (NSUInteger)numberOfGroups; //Returns the number of groups in the Source List
+- (BOOL)isGroupItem:(id)item; //Returns whether `item` is a group
+- (BOOL)isGroupAlwaysExpanded:(id)group; //Returns whether `group` is displayed as always expanded
-- (BOOL)itemHasBadge:(id)item; //Returns whether `item` has a badge
-- (NSInteger)badgeValueForItem:(id)item; //Returns the badge value for `item`
+- (BOOL)itemHasBadge:(id)item; //Returns whether `item` has a badge
+- (NSInteger)badgeValueForItem:(id)item; //Returns the badge value for `item`
@end
#import "SideBarItem.h"
//Layout constants
-#define MIN_BADGE_WIDTH 22.0 //The minimum badge width for each item (default 22.0)
-#define BADGE_HEIGHT 14.0 //The badge height for each item (default 14.0)
-#define BADGE_MARGIN 5.0 //The spacing between the badge and the cell for that row
-#define ROW_RIGHT_MARGIN 5.0 //The spacing between the right edge of the badge and the edge of the table column
-#define ICON_SPACING 2.0 //The spacing between the icon and it's adjacent cell
-#define DISCLOSURE_TRIANGLE_SPACE 18.0 //The indentation reserved for disclosure triangles for non-group items
+#define MIN_BADGE_WIDTH 22.0 //The minimum badge width for each item (default 22.0)
+#define BADGE_HEIGHT 14.0 //The badge height for each item (default 14.0)
+#define BADGE_MARGIN 5.0 //The spacing between the badge and the cell for that row
+#define ROW_RIGHT_MARGIN 5.0 //The spacing between the right edge of the badge and the edge of the table column
+#define ICON_SPACING 2.0 //The spacing between the icon and it's adjacent cell
+#define DISCLOSURE_TRIANGLE_SPACE 18.0 //The indentation reserved for disclosure triangles for non-group items
//Drawing constants
-#define BADGE_BACKGROUND_COLOR [NSColor colorWithCalibratedRed:(152/255.0) green:(168/255.0) blue:(202/255.0) alpha:1]
-#define BADGE_HIDDEN_BACKGROUND_COLOR [NSColor colorWithDeviceWhite:(180/255.0) alpha:1]
-#define BADGE_SELECTED_TEXT_COLOR [NSColor keyboardFocusIndicatorColor]
-#define BADGE_SELECTED_UNFOCUSED_TEXT_COLOR [NSColor colorWithCalibratedRed:(153/255.0) green:(169/255.0) blue:(203/255.0) alpha:1]
-#define BADGE_SELECTED_HIDDEN_TEXT_COLOR [NSColor colorWithCalibratedWhite:(170/255.0) alpha:1]
-#define BADGE_FONT [NSFont boldSystemFontOfSize:11]
+#define BADGE_BACKGROUND_COLOR [NSColor colorWithCalibratedRed:(152/255.0) green:(168/255.0) blue:(202/255.0) alpha:1]
+#define BADGE_HIDDEN_BACKGROUND_COLOR [NSColor colorWithDeviceWhite:(180/255.0) alpha:1]
+#define BADGE_SELECTED_TEXT_COLOR [NSColor keyboardFocusIndicatorColor]
+#define BADGE_SELECTED_UNFOCUSED_TEXT_COLOR [NSColor colorWithCalibratedRed:(153/255.0) green:(169/255.0) blue:(203/255.0) alpha:1]
+#define BADGE_SELECTED_HIDDEN_TEXT_COLOR [NSColor colorWithCalibratedWhite:(170/255.0) alpha:1]
+#define BADGE_FONT [NSFont boldSystemFontOfSize:11]
//Delegate notification constants
NSString * const PXSLSelectionIsChangingNotification = @"PXSourceListSelectionIsChanging";
#pragma mark Init/Dealloc/Finalize
- (id)initWithCoder:(NSCoder*)decoder
-{
- if(self=[super initWithCoder:decoder])
- {
- [self setDelegate:(id<PXSourceListDelegate>)[super delegate]];
- [super setDelegate:self];
-
- [self setDataSource:(id<PXSourceListDataSource>)[super dataSource]];
- [super setDataSource:self];
-
- _iconSize = NSMakeSize(16,16);
- }
-
- return self;
+{
+ if(self=[super initWithCoder:decoder])
+ {
+ [self setDelegate:(id<PXSourceListDelegate>)[super delegate]];
+ [super setDelegate:self];
+ [self setDataSource:(id<PXSourceListDataSource>)[super dataSource]];
+ [super setDataSource:self];
+
+ _iconSize = NSMakeSize(16,16);
+ }
+
+ return self;
}
- (void)dealloc
{
- //Remove ourselves as the delegate and data source to be safe
- [super setDataSource:nil];
- [super setDelegate:nil];
-
- //Unregister the delegate from receiving notifications
- [[NSNotificationCenter defaultCenter] removeObserver:_secondaryDelegate name:nil object:self];
-
- [super dealloc];
+ //Remove ourselves as the delegate and data source to be safe
+ [super setDataSource:nil];
+ [super setDelegate:nil];
+
+ //Unregister the delegate from receiving notifications
+ [[NSNotificationCenter defaultCenter] removeObserver:_secondaryDelegate name:nil object:self];
+
+ [super dealloc];
}
- (void)finalize
{
- //Remove ourselves as the delegate and data source to be safe
- [super setDataSource:nil];
- [super setDelegate:nil];
-
- //Unregister the delegate from receiving notifications
- [[NSNotificationCenter defaultCenter] removeObserver:_secondaryDelegate name:nil object:self];
-
- [super finalize];
+ //Remove ourselves as the delegate and data source to be safe
+ [super setDataSource:nil];
+ [super setDelegate:nil];
+
+ //Unregister the delegate from receiving notifications
+ [[NSNotificationCenter defaultCenter] removeObserver:_secondaryDelegate name:nil object:self];
+
+ [super finalize];
}
#pragma mark -
- (void)setDelegate:(id<PXSourceListDelegate>)aDelegate
{
- //Unregister the old delegate from receiving notifications
- [[NSNotificationCenter defaultCenter] removeObserver:_secondaryDelegate name:nil object:self];
-
- _secondaryDelegate = aDelegate;
-
- //Register the new delegate to receive notifications
- [self registerDelegateToReceiveNotification:PXSLSelectionIsChangingNotification
- withSelector:@selector(sourceListSelectionIsChanging:)];
- [self registerDelegateToReceiveNotification:PXSLSelectionDidChangeNotification
- withSelector:@selector(sourceListSelectionDidChange:)];
- [self registerDelegateToReceiveNotification:PXSLItemWillExpandNotification
- withSelector:@selector(sourceListItemWillExpand:)];
- [self registerDelegateToReceiveNotification:PXSLItemDidExpandNotification
- withSelector:@selector(sourceListItemDidExpand:)];
- [self registerDelegateToReceiveNotification:PXSLItemWillCollapseNotification
- withSelector:@selector(sourceListItemWillCollapse:)];
- [self registerDelegateToReceiveNotification:PXSLItemDidCollapseNotification
- withSelector:@selector(sourceListItemDidCollapse:)];
- [self registerDelegateToReceiveNotification:PXSLDeleteKeyPressedOnRowsNotification
- withSelector:@selector(sourceListDeleteKeyPressedOnRows:)];
+ //Unregister the old delegate from receiving notifications
+ [[NSNotificationCenter defaultCenter] removeObserver:_secondaryDelegate name:nil object:self];
+
+ _secondaryDelegate = aDelegate;
+ //Register the new delegate to receive notifications
+ [self registerDelegateToReceiveNotification:PXSLSelectionIsChangingNotification withSelector:@selector(sourceListSelectionIsChanging:)];
+ [self registerDelegateToReceiveNotification:PXSLSelectionDidChangeNotification withSelector:@selector(sourceListSelectionDidChange:)];
+ [self registerDelegateToReceiveNotification:PXSLItemWillExpandNotification withSelector:@selector(sourceListItemWillExpand:)];
+ [self registerDelegateToReceiveNotification:PXSLItemDidExpandNotification withSelector:@selector(sourceListItemDidExpand:)];
+ [self registerDelegateToReceiveNotification:PXSLItemWillCollapseNotification withSelector:@selector(sourceListItemWillCollapse:)];
+ [self registerDelegateToReceiveNotification:PXSLItemDidCollapseNotification withSelector:@selector(sourceListItemDidCollapse:)];
+ [self registerDelegateToReceiveNotification:PXSLDeleteKeyPressedOnRowsNotification withSelector:@selector(sourceListDeleteKeyPressedOnRows:)];
}
- (void)setDataSource:(id<PXSourceListDataSource>)aDataSource
{
- _secondaryDataSource = aDataSource;
-
- [self reloadData];
+ _secondaryDataSource = aDataSource;
+
+ [self reloadData];
}
- (void)setIconSize:(NSSize)newIconSize
{
- _iconSize = newIconSize;
-
- CGFloat rowHeight = [self rowHeight];
-
- //Make sure icon height does not exceed row height; if so constrain, keeping width and height in proportion
- if(_iconSize.height>rowHeight)
- {
- _iconSize.width = _iconSize.width * (rowHeight/_iconSize.height);
- _iconSize.height = rowHeight;
- }
+ _iconSize = newIconSize;
+ CGFloat rowHeight = [self rowHeight];
+
+ //Make sure icon height does not exceed row height; if so constrain, keeping width and height in proportion
+ if(_iconSize.height>rowHeight)
+ {
+ _iconSize.width = _iconSize.width * (rowHeight/_iconSize.height);
+ _iconSize.height = rowHeight;
+ }
}
#pragma mark -
- (void)reloadData
{
- [super reloadData];
-
- //Expand items that are displayed as always expanded
- if([_secondaryDataSource conformsToProtocol:@protocol(PXSourceListDataSource)] &&
- [_secondaryDelegate respondsToSelector:@selector(sourceList:isGroupAlwaysExpanded:)])
- {
- for(NSUInteger i=0;i<[self numberOfGroups];i++)
- {
- id item = [_secondaryDataSource sourceList:self child:i ofItem:nil];
-
- if([self isGroupAlwaysExpanded:item]) {
- [self expandItem:item expandChildren:NO];
- }
- }
-
- }
-
- //If there are selected rows and the item hierarchy has changed, make sure a Group row isn't
- //selected
- if([self numberOfSelectedRows]>0) {
- NSIndexSet *selectedIndexes = [self selectedRowIndexes];
- NSUInteger firstSelectedRow = [selectedIndexes firstIndex];
-
- //Is a group item selected?
- if([self isGroupItem:[self itemAtRow:firstSelectedRow]]) {
- //Work backwards to find the first non-group row
- BOOL foundRow = NO;
- for(NSUInteger i=firstSelectedRow;i>0;i--)
- {
- if(![self isGroupItem:[self itemAtRow:i]]) {
- [self selectRowIndexes:[NSIndexSet indexSetWithIndex:i] byExtendingSelection:NO];
- foundRow = YES;
- break;
- }
- }
-
- //If there is no non-group row preceding the currently selected group item, remove the selection
- //from the Source List
- if(!foundRow) {
- [self deselectAll:self];
- }
- }
- }
- else if(![self allowsEmptySelection]&&[self numberOfSelectedRows]==0)
- {
- //Select the first non-group row if no rows are selected, and empty selection is disallowed
- for(NSUInteger i=0;i<[self numberOfRows];i++)
- {
- if(![self isGroupItem:[self itemAtRow:i]]) {
- [self selectRowIndexes:[NSIndexSet indexSetWithIndex:i] byExtendingSelection:NO];
- break;
- }
- }
- }
+ [super reloadData];
+
+ //Expand items that are displayed as always expanded
+ if([_secondaryDataSource conformsToProtocol:@protocol(PXSourceListDataSource)] &&
+ [_secondaryDelegate respondsToSelector:@selector(sourceList:isGroupAlwaysExpanded:)])
+ {
+ for(NSUInteger i=0;i<[self numberOfGroups];i++)
+ {
+ id item = [_secondaryDataSource sourceList:self child:i ofItem:nil];
+
+ if([self isGroupAlwaysExpanded:item]) {
+ [self expandItem:item expandChildren:NO];
+ }
+ }
+ }
+
+ //If there are selected rows and the item hierarchy has changed, make sure a Group row isn't
+ //selected
+ if([self numberOfSelectedRows]>0) {
+ NSIndexSet *selectedIndexes = [self selectedRowIndexes];
+ NSUInteger firstSelectedRow = [selectedIndexes firstIndex];
+
+ //Is a group item selected?
+ if([self isGroupItem:[self itemAtRow:firstSelectedRow]]) {
+ //Work backwards to find the first non-group row
+ BOOL foundRow = NO;
+ for(NSUInteger i=firstSelectedRow;i>0;i--)
+ {
+ if(![self isGroupItem:[self itemAtRow:i]]) {
+ [self selectRowIndexes:[NSIndexSet indexSetWithIndex:i] byExtendingSelection:NO];
+ foundRow = YES;
+ break;
+ }
+ }
+
+ //If there is no non-group row preceding the currently selected group item, remove the selection
+ //from the Source List
+ if(!foundRow) {
+ [self deselectAll:self];
+ }
+ }
+ }
+ else if(![self allowsEmptySelection]&&[self numberOfSelectedRows]==0)
+ {
+ //Select the first non-group row if no rows are selected, and empty selection is disallowed
+ for(NSUInteger i=0;i<[self numberOfRows];i++)
+ {
+ if(![self isGroupItem:[self itemAtRow:i]]) {
+ [self selectRowIndexes:[NSIndexSet indexSetWithIndex:i] byExtendingSelection:NO];
+ break;
+ }
+ }
+ }
}
- (NSUInteger)numberOfGroups
-{
- if([_secondaryDataSource respondsToSelector:@selector(sourceList:numberOfChildrenOfItem:)]) {
- return [_secondaryDataSource sourceList:self numberOfChildrenOfItem:nil];
- }
-
- return 0;
+{
+ if([_secondaryDataSource respondsToSelector:@selector(sourceList:numberOfChildrenOfItem:)]) {
+ return [_secondaryDataSource sourceList:self numberOfChildrenOfItem:nil];
+ }
+ return 0;
}
- (BOOL)isGroupItem:(id)item
{
- //Groups are defined as root items (at level 0)
- return 0==[self levelForItem:item];
+ //Groups are defined as root items (at level 0)
+ return 0==[self levelForItem:item];
}
- (BOOL)isGroupAlwaysExpanded:(id)group
{
- //Make sure that the item IS a group to prevent unwanted queries sent to the data source
- if([self isGroupItem:group]) {
- //Query the data source
- if([_secondaryDelegate respondsToSelector:@selector(sourceList:isGroupAlwaysExpanded:)]) {
- return [_secondaryDelegate sourceList:self isGroupAlwaysExpanded:group];
- }
- }
-
- return NO;
+ //Make sure that the item IS a group to prevent unwanted queries sent to the data source
+ if([self isGroupItem:group]) {
+ //Query the data source
+ if([_secondaryDelegate respondsToSelector:@selector(sourceList:isGroupAlwaysExpanded:)]) {
+ return [_secondaryDelegate sourceList:self isGroupAlwaysExpanded:group];
+ }
+ }
+
+ return NO;
}
- (BOOL)itemHasBadge:(id)item
{
- if([_secondaryDataSource respondsToSelector:@selector(sourceList:itemHasBadge:)]) {
- return [_secondaryDataSource sourceList:self itemHasBadge:item];
- }
-
- return NO;
+ if([_secondaryDataSource respondsToSelector:@selector(sourceList:itemHasBadge:)]) {
+ return [_secondaryDataSource sourceList:self itemHasBadge:item];
+ }
+
+ return NO;
}
- (NSInteger)badgeValueForItem:(id)item
-{
- //Make sure that the item has a badge
- if(![self itemHasBadge:item]) {
- return NSNotFound;
- }
-
- if([_secondaryDataSource respondsToSelector:@selector(sourceList:badgeValueForItem:)]) {
- return [_secondaryDataSource sourceList:self badgeValueForItem:item];
- }
-
- return NSNotFound;
+{
+ //Make sure that the item has a badge
+ if(![self itemHasBadge:item]) {
+ return NSNotFound;
+ }
+
+ if([_secondaryDataSource respondsToSelector:@selector(sourceList:badgeValueForItem:)]) {
+ return [_secondaryDataSource sourceList:self badgeValueForItem:item];
+ }
+
+ return NSNotFound;
}
#pragma mark -
- (void)selectRowIndexes:(NSIndexSet*)indexes byExtendingSelection:(BOOL)extend
{
- NSUInteger numberOfIndexes = [indexes count];
-
- //Prevent empty selection if we don't want it
- if(![self allowsEmptySelection]&&0==numberOfIndexes) {
- return;
- }
-
- //Would use blocks but we're also targeting 10.5...
- //Get the selected indexes
- NSUInteger *selectedIndexes = malloc(sizeof(NSUInteger)*numberOfIndexes);
- [indexes getIndexes:selectedIndexes maxCount:numberOfIndexes inIndexRange:nil];
-
- //Loop through the indexes and only add non-group row indexes
- //Allows selection across groups without selecting the group rows
- NSMutableIndexSet *newSelectionIndexes = [NSMutableIndexSet indexSet];
- for(NSInteger i=0;i<numberOfIndexes;i++)
- {
- if(![self isGroupItem:[self itemAtRow:selectedIndexes[i]]]) {
- [newSelectionIndexes addIndex:selectedIndexes[i]];
- }
- }
-
- //If there are any non-group rows selected
- if([newSelectionIndexes count]>0) {
- [super selectRowIndexes:newSelectionIndexes byExtendingSelection:extend];
- }
-
- //C memory management... *sigh*
- free(selectedIndexes);
+ NSUInteger numberOfIndexes = [indexes count];
+
+ //Prevent empty selection if we don't want it
+ if(![self allowsEmptySelection]&&0==numberOfIndexes) {
+ return;
+ }
+
+ //Would use blocks but we're also targeting 10.5...
+ //Get the selected indexes
+ NSUInteger *selectedIndexes = malloc(sizeof(NSUInteger)*numberOfIndexes);
+ [indexes getIndexes:selectedIndexes maxCount:numberOfIndexes inIndexRange:nil];
+
+ //Loop through the indexes and only add non-group row indexes
+ //Allows selection across groups without selecting the group rows
+ NSMutableIndexSet *newSelectionIndexes = [NSMutableIndexSet indexSet];
+ for(NSInteger i=0;i<numberOfIndexes;i++)
+ {
+ if(![self isGroupItem:[self itemAtRow:selectedIndexes[i]]]) {
+ [newSelectionIndexes addIndex:selectedIndexes[i]];
+ }
+ }
+
+ //If there are any non-group rows selected
+ if([newSelectionIndexes count]>0) {
+ [super selectRowIndexes:newSelectionIndexes byExtendingSelection:extend];
+ }
+
+ //C memory management... *sigh*
+ free(selectedIndexes);
}
#pragma mark -
#pragma mark Layout
- (NSRect)frameOfOutlineCellAtRow:(NSInteger)row
-{
- //Return a zero-rect if the item is always expanded (a disclosure triangle will not be drawn)
- if([self isGroupAlwaysExpanded:[self itemAtRow:row]]) {
- return NSZeroRect;
- }
-
- return [super frameOfOutlineCellAtRow:row];
+{
+ //Return a zero-rect if the item is always expanded (a disclosure triangle will not be drawn)
+ if([self isGroupAlwaysExpanded:[self itemAtRow:row]]) {
+ return NSZeroRect;
+ }
+
+ return [super frameOfOutlineCellAtRow:row];
}
- (NSRect)frameOfCellAtColumn:(NSInteger)column row:(NSInteger)row
{
- id item = [self itemAtRow:row];
-
- NSCell *cell = [self preparedCellAtColumn:column row:row];
- NSSize cellSize = [cell cellSize];
- if (!([cell type] == NSImageCellType) && !([cell type] == NSTextCellType))
- cellSize = [cell cellSizeForBounds:[super frameOfCellAtColumn:column row:row]];
- NSRect cellFrame = [super frameOfCellAtColumn:column row:row];
-
- NSRect rowRect = [self rectOfRow:row];
-
- if([self isGroupItem:item])
- {
- CGFloat minX = NSMinX(cellFrame);
-
- //Set the origin x-coord; if there are no children of the group at current, there will still be a
- //margin to the left of the cell (in cellFrame), which we don't want
- if([self isGroupAlwaysExpanded:[self itemAtRow:row]]) {
- minX = 7;
- }
-
- return NSMakeRect(minX,
- NSMidY(cellFrame)-(cellSize.height/2.0),
- NSWidth(rowRect)-minX,
- cellSize.height);
- }
- else
- {
- CGFloat leftIndent = ([self levelForRow:row] -1)*[self indentationPerLevel]+DISCLOSURE_TRIANGLE_SPACE;
-
- //Calculate space left for a badge if need be
- CGFloat rightIndent = [self sizeOfBadgeAtRow:row].width+ROW_RIGHT_MARGIN;
-
- //Allow space for an icon if need be
- if(![self isGroupItem:item]&&[_secondaryDataSource respondsToSelector:@selector(sourceList:itemHasIcon:)])
- {
- if([_secondaryDataSource sourceList:self itemHasIcon:item]) {
- leftIndent += [self iconSize].width+(ICON_SPACING*2);
- }
- }
-
- return NSMakeRect(leftIndent,
- NSMidY(rowRect)-(cellSize.height/2.0),
- NSWidth(rowRect)-rightIndent-leftIndent,
- cellSize.height);
- }
+ id item = [self itemAtRow:row];
+
+ NSCell *cell = [self preparedCellAtColumn:column row:row];
+ NSSize cellSize = [cell cellSize];
+ if (!([cell type] == NSImageCellType) && !([cell type] == NSTextCellType))
+ cellSize = [cell cellSizeForBounds:[super frameOfCellAtColumn:column row:row]];
+
+ NSRect cellFrame = [super frameOfCellAtColumn:column row:row];
+ NSRect rowRect = [self rectOfRow:row];
+
+ if([self isGroupItem:item])
+ {
+ CGFloat minX = NSMinX(cellFrame);
+
+ //Set the origin x-coord; if there are no children of the group at current, there will still be a
+ //margin to the left of the cell (in cellFrame), which we don't want
+ if([self isGroupAlwaysExpanded:[self itemAtRow:row]]) {
+ minX = 7;
+ }
+
+ return NSMakeRect(minX, NSMidY(cellFrame)-(cellSize.height/2.0), NSWidth(rowRect)-minX, cellSize.height);
+ }
+ else
+ {
+ CGFloat leftIndent = ([self levelForRow:row] -1)*[self indentationPerLevel]+DISCLOSURE_TRIANGLE_SPACE;
+
+ //Calculate space left for a badge if need be
+ CGFloat rightIndent = [self sizeOfBadgeAtRow:row].width+ROW_RIGHT_MARGIN;
+
+ //Allow space for an icon if need be
+ if(![self isGroupItem:item]&&[_secondaryDataSource respondsToSelector:@selector(sourceList:itemHasIcon:)])
+ {
+ if([_secondaryDataSource sourceList:self itemHasIcon:item]) {
+ leftIndent += [self iconSize].width+(ICON_SPACING*2);
+ }
+ }
+ return NSMakeRect(leftIndent, NSMidY(rowRect)-(cellSize.height/2.0), NSWidth(rowRect)-rightIndent-leftIndent, cellSize.height);
+ }
}
//row for the row index passed to the method does not have a badge, then NSZeroSize is returned.
- (NSSize)sizeOfBadgeAtRow:(NSInteger)rowIndex
{
- id rowItem = [self itemAtRow:rowIndex];
-
- //Make sure that the item has a badge
- if(![self itemHasBadge:rowItem]) {
- return NSZeroSize;
- }
-
- NSAttributedString *badgeAttrString = [[NSAttributedString alloc] initWithString:[NSString stringWithFormat:@"%d", [self badgeValueForItem:rowItem]]
- attributes:[NSDictionary dictionaryWithObjectsAndKeys:BADGE_FONT, NSFontAttributeName, nil]];
-
- NSSize stringSize = [badgeAttrString size];
-
- //Calculate the width needed to display the text or the minimum width if it's smaller
- CGFloat width = stringSize.width+(2*BADGE_MARGIN);
-
- if(width<MIN_BADGE_WIDTH) {
- width = MIN_BADGE_WIDTH;
- }
-
- [badgeAttrString release];
-
- return NSMakeSize(width, BADGE_HEIGHT);
+ id rowItem = [self itemAtRow:rowIndex];
+
+ //Make sure that the item has a badge
+ if(![self itemHasBadge:rowItem]) {
+ return NSZeroSize;
+ }
+
+ NSAttributedString *badgeAttrString = [[NSAttributedString alloc] initWithString:[NSString stringWithFormat:@"%d", [self badgeValueForItem:rowItem]] attributes:[NSDictionary dictionaryWithObjectsAndKeys:BADGE_FONT, NSFontAttributeName, nil]];
+ NSSize stringSize = [badgeAttrString size];
+
+ //Calculate the width needed to display the text or the minimum width if it's smaller
+ CGFloat width = stringSize.width+(2*BADGE_MARGIN);
+
+ if(width<MIN_BADGE_WIDTH) {
+ width = MIN_BADGE_WIDTH;
+ }
+
+ [badgeAttrString release];
+
+ return NSMakeSize(width, BADGE_HEIGHT);
}
#pragma mark Drawing
- (void)drawRow:(NSInteger)rowIndex clipRect:(NSRect)clipRect
-{
- [super drawRow:rowIndex clipRect:clipRect];
-
- id item = [self itemAtRow:rowIndex];
-
- //Draw an icon if the item has one
- if(![self isGroupItem:item]&&[_secondaryDataSource respondsToSelector:@selector(sourceList:itemHasIcon:)])
- {
- if([_secondaryDataSource sourceList:self itemHasIcon:item])
- {
- NSRect cellFrame = [self frameOfCellAtColumn:0 row:rowIndex];
- NSSize iconSize = [self iconSize];
- NSRect iconRect = NSMakeRect(NSMinX(cellFrame)-iconSize.width-ICON_SPACING,
- NSMidY(cellFrame)-(iconSize.width/2.0f),
- iconSize.width,
- iconSize.height);
-
- if([_secondaryDataSource respondsToSelector:@selector(sourceList:iconForItem:)])
- {
- NSImage *icon = [_secondaryDataSource sourceList:self iconForItem:item];
-
- if(icon!=nil)
- {
- NSSize actualIconSize = [icon size];
-
- //If the icon is *smaller* than the size retrieved from the -iconSize property, make sure we
- //reduce the size of the rectangle to draw the icon in, so that it is not stretched.
- if((actualIconSize.width<iconSize.width)||(actualIconSize.height<iconSize.height))
- {
- iconRect = NSMakeRect(NSMidX(iconRect)-(actualIconSize.width/2.0f),
- NSMidY(iconRect)-(actualIconSize.height/2.0f),
- actualIconSize.width,
- actualIconSize.height);
- }
-
+{
+ [super drawRow:rowIndex clipRect:clipRect];
+ id item = [self itemAtRow:rowIndex];
+
+ //Draw an icon if the item has one
+ if(![self isGroupItem:item]&&[_secondaryDataSource respondsToSelector:@selector(sourceList:itemHasIcon:)])
+ {
+ if([_secondaryDataSource sourceList:self itemHasIcon:item])
+ {
+ NSRect cellFrame = [self frameOfCellAtColumn:0 row:rowIndex];
+ NSSize iconSize = [self iconSize];
+ NSRect iconRect = NSMakeRect(NSMinX(cellFrame)-iconSize.width-ICON_SPACING, NSMidY(cellFrame)-(iconSize.width/2.0f), iconSize.width, iconSize.height);
+
+ if([_secondaryDataSource respondsToSelector:@selector(sourceList:iconForItem:)])
+ {
+ NSImage *icon = [_secondaryDataSource sourceList:self iconForItem:item];
+ if(icon!=nil)
+ {
+ NSSize actualIconSize = [icon size];
+ //If the icon is *smaller* than the size retrieved from the -iconSize property, make sure we
+ //reduce the size of the rectangle to draw the icon in, so that it is not stretched.
+ if((actualIconSize.width<iconSize.width)||(actualIconSize.height<iconSize.height))
+ {
+ iconRect = NSMakeRect(NSMidX(iconRect)-(actualIconSize.width/2.0f), NSMidY(iconRect)-(actualIconSize.height/2.0f), actualIconSize.width, actualIconSize.height);
+ }
+
//Use 10.6 NSImage drawing if we can
if([icon respondsToSelector:@selector(drawInRect:fromRect:operation:fraction:respectFlipped:hints:)]) {
[icon drawInRect:iconRect
operation:NSCompositeSourceOver
fraction:1];
}
- }
- }
- }
- }
-
- //Draw the badge if the item has one
- if([self itemHasBadge:item])
- {
- NSRect rowRect = [self rectOfRow:rowIndex];
- NSSize badgeSize = [self sizeOfBadgeAtRow:rowIndex];
-
- NSRect badgeFrame = NSMakeRect(NSMaxX(rowRect)-badgeSize.width-ROW_RIGHT_MARGIN,
- NSMidY(rowRect)-(badgeSize.height/2.0),
- badgeSize.width,
- badgeSize.height);
-
- [self drawBadgeForRow:rowIndex inRect:badgeFrame];
- }
+ }
+ }
+ }
+ }
+
+ //Draw the badge if the item has one
+ if([self itemHasBadge:item])
+ {
+ NSRect rowRect = [self rectOfRow:rowIndex];
+ NSSize badgeSize = [self sizeOfBadgeAtRow:rowIndex];
+
+ NSRect badgeFrame = NSMakeRect(NSMaxX(rowRect)-badgeSize.width-ROW_RIGHT_MARGIN,
+ NSMidY(rowRect)-(badgeSize.height/2.0),
+ badgeSize.width,
+ badgeSize.height);
+ [self drawBadgeForRow:rowIndex inRect:badgeFrame];
+ }
}
- (void)drawBadgeForRow:(NSInteger)rowIndex inRect:(NSRect)badgeFrame
{
- id rowItem = [self itemAtRow:rowIndex];
-
- NSBezierPath *badgePath = [NSBezierPath bezierPathWithRoundedRect:badgeFrame
- xRadius:(BADGE_HEIGHT/2.0)
- yRadius:(BADGE_HEIGHT/2.0)];
-
- //Get window and control state to determine colours used
- BOOL isVisible = [[NSApp mainWindow] isVisible];
- BOOL isFocused = [[[self window] firstResponder] isEqual:self];
- NSInteger rowBeingEdited = [self editedRow];
-
- //Set the attributes based on the row state
- NSDictionary *attributes;
- NSColor *backgroundColor;
-
- if([[self selectedRowIndexes] containsIndex:rowIndex])
- {
- backgroundColor = [NSColor whiteColor];
-
- //Set the text color based on window and control state
- NSColor *textColor;
-
- if(isVisible && (isFocused || rowBeingEdited==rowIndex)) {
- textColor = BADGE_SELECTED_TEXT_COLOR;
- }
- else if(isVisible && !isFocused) {
- textColor = BADGE_SELECTED_UNFOCUSED_TEXT_COLOR;
- }
- else {
- textColor = BADGE_SELECTED_HIDDEN_TEXT_COLOR;
- }
-
- attributes = [[NSDictionary alloc] initWithObjectsAndKeys:BADGE_FONT, NSFontAttributeName,
- textColor, NSForegroundColorAttributeName, nil];
- }
- else
- {
- //Set the text colour based on window and control state
- NSColor *badgeColor = [NSColor whiteColor];
-
- if(isVisible) {
- //If the data source returns a custom colour..
- if([_secondaryDataSource respondsToSelector:@selector(sourceList:badgeBackgroundColorForItem:)]) {
- backgroundColor = [_secondaryDataSource sourceList:self badgeBackgroundColorForItem:rowItem];
-
- if(backgroundColor==nil)
- backgroundColor = BADGE_BACKGROUND_COLOR;
- }
- else { //Otherwise use the default (purple-blue colour)
- backgroundColor = BADGE_BACKGROUND_COLOR;
- }
-
- //If the delegate wants a custom badge text colour..
- if([_secondaryDataSource respondsToSelector:@selector(sourceList:badgeTextColorForItem:)]) {
- badgeColor = [_secondaryDataSource sourceList:self badgeTextColorForItem:rowItem];
-
- if(badgeColor==nil)
- badgeColor = [NSColor whiteColor];
- }
- }
- else { //Gray colour
- backgroundColor = BADGE_HIDDEN_BACKGROUND_COLOR;
- }
-
- attributes = [[NSDictionary alloc] initWithObjectsAndKeys:BADGE_FONT, NSFontAttributeName,
- badgeColor, NSForegroundColorAttributeName, nil];
- }
-
- [backgroundColor set];
- [badgePath fill];
-
- //Draw the badge text
- NSAttributedString *badgeAttrString = [[NSAttributedString alloc] initWithString:[NSString stringWithFormat:@"%d", [self badgeValueForItem:rowItem]]
- attributes:attributes];
- NSSize stringSize = [badgeAttrString size];
- NSPoint badgeTextPoint = NSMakePoint(NSMidX(badgeFrame)-(stringSize.width/2.0), //Center in the badge frame
- NSMidY(badgeFrame)-(stringSize.height/2.0)); //Center in the badge frame
- [badgeAttrString drawAtPoint:badgeTextPoint];
-
- [attributes release];
- [badgeAttrString release];
+ id rowItem = [self itemAtRow:rowIndex];
+ NSBezierPath *badgePath = [NSBezierPath bezierPathWithRoundedRect:badgeFrame
+ xRadius:(BADGE_HEIGHT/2.0)
+ yRadius:(BADGE_HEIGHT/2.0)];
+
+ //Get window and control state to determine colours used
+ BOOL isVisible = [[NSApp mainWindow] isVisible];
+ BOOL isFocused = [[[self window] firstResponder] isEqual:self];
+ NSInteger rowBeingEdited = [self editedRow];
+
+ //Set the attributes based on the row state
+ NSDictionary *attributes;
+ NSColor *backgroundColor;
+
+ if([[self selectedRowIndexes] containsIndex:rowIndex])
+ {
+ backgroundColor = [NSColor whiteColor];
+ //Set the text color based on window and control state
+ NSColor *textColor;
+ if(isVisible && (isFocused || rowBeingEdited==rowIndex)) {
+ textColor = BADGE_SELECTED_TEXT_COLOR;
+ }
+ else if(isVisible && !isFocused) {
+ textColor = BADGE_SELECTED_UNFOCUSED_TEXT_COLOR;
+ }
+ else {
+ textColor = BADGE_SELECTED_HIDDEN_TEXT_COLOR;
+ }
+
+ attributes = [[NSDictionary alloc] initWithObjectsAndKeys:BADGE_FONT, NSFontAttributeName, textColor, NSForegroundColorAttributeName, nil];
+ }
+ else
+ {
+ //Set the text colour based on window and control state
+ NSColor *badgeColor = [NSColor whiteColor];
+
+ if(isVisible) {
+ //If the data source returns a custom colour..
+ if([_secondaryDataSource respondsToSelector:@selector(sourceList:badgeBackgroundColorForItem:)]) {
+ backgroundColor = [_secondaryDataSource sourceList:self badgeBackgroundColorForItem:rowItem];
+
+ if(backgroundColor==nil)
+ backgroundColor = BADGE_BACKGROUND_COLOR;
+ }
+ else { //Otherwise use the default (purple-blue colour)
+ backgroundColor = BADGE_BACKGROUND_COLOR;
+ }
+
+ //If the delegate wants a custom badge text colour..
+ if([_secondaryDataSource respondsToSelector:@selector(sourceList:badgeTextColorForItem:)]) {
+ badgeColor = [_secondaryDataSource sourceList:self badgeTextColorForItem:rowItem];
+
+ if(badgeColor==nil)
+ badgeColor = [NSColor whiteColor];
+ }
+ }
+ else { //Gray colour
+ backgroundColor = BADGE_HIDDEN_BACKGROUND_COLOR;
+ }
+ attributes = [[NSDictionary alloc] initWithObjectsAndKeys:BADGE_FONT, NSFontAttributeName, badgeColor, NSForegroundColorAttributeName, nil];
+ }
+
+ [backgroundColor set];
+ [badgePath fill];
+
+ //Draw the badge text
+ NSAttributedString *badgeAttrString = [[NSAttributedString alloc] initWithString:[NSString stringWithFormat:@"%d", [self badgeValueForItem:rowItem]] attributes:attributes];
+
+ NSSize stringSize = [badgeAttrString size];
+ NSPoint badgeTextPoint = NSMakePoint(NSMidX(badgeFrame)-(stringSize.width/2.0), //Center in the badge frame
+ NSMidY(badgeFrame)-(stringSize.height/2.0)); //Center in the badge frame
+ [badgeAttrString drawAtPoint:badgeTextPoint];
+ [attributes release];
+ [badgeAttrString release];
}
#pragma mark -
- (void)keyDown:(NSEvent *)theEvent
{
- NSIndexSet *selectedIndexes = [self selectedRowIndexes];
-
- NSString *keyCharacters = [theEvent characters];
-
- //Make sure we have a selection
- if([selectedIndexes count]>0)
- {
- if([keyCharacters length]>0)
- {
- unichar firstKey = [keyCharacters characterAtIndex:0];
-
- if(firstKey==NSUpArrowFunctionKey||firstKey==NSDownArrowFunctionKey)
- {
- //Handle keyboard navigation across groups
- if([selectedIndexes count]==1&&!([theEvent modifierFlags] & NSShiftKeyMask))
- {
- int delta = firstKey==NSDownArrowFunctionKey?1:-1; //Search "backwards" if up arrow, "forwards" if down
- NSInteger newRow = [selectedIndexes firstIndex];
-
- //Keep incrementing/decrementing the row until a non-header row is reached
- do {
- newRow+=delta;
-
- //If out of bounds of the number of rows..
- if(newRow<0||newRow==[self numberOfRows])
- break;
- } while([self isGroupItem:[self itemAtRow:newRow]]);
-
-
- [self selectRowIndexes:[NSIndexSet indexSetWithIndex:newRow] byExtendingSelection:NO];
- return;
- }
- }
- else if(firstKey==NSDeleteCharacter||firstKey==NSBackspaceCharacter)
- {
- //Post the notification
- [[NSNotificationCenter defaultCenter] postNotificationName:PXSLDeleteKeyPressedOnRowsNotification
- object:self
- userInfo:[NSDictionary dictionaryWithObject:selectedIndexes forKey:@"rows"]];
-
- return;
- }
- }
- }
-
- //We don't care about it
- [super keyDown:theEvent];
+ NSIndexSet *selectedIndexes = [self selectedRowIndexes];
+ NSString *keyCharacters = [theEvent characters];
+
+ //Make sure we have a selection
+ if([selectedIndexes count]>0)
+ {
+ if([keyCharacters length]>0)
+ {
+ unichar firstKey = [keyCharacters characterAtIndex:0];
+ if(firstKey==NSUpArrowFunctionKey||firstKey==NSDownArrowFunctionKey)
+ {
+ //Handle keyboard navigation across groups
+ if([selectedIndexes count]==1&&!([theEvent modifierFlags] & NSShiftKeyMask))
+ {
+ int delta = firstKey==NSDownArrowFunctionKey?1:-1;
+ //Search "backwards" if up arrow, "forwards" if down
+
+ NSInteger newRow = [selectedIndexes firstIndex];
+ //Keep incrementing/decrementing the row until a non-header row is reached
+ do {
+ newRow+=delta;
+
+ //If out of bounds of the number of rows..
+ if(newRow<0||newRow==[self numberOfRows])
+ break;
+ } while([self isGroupItem:[self itemAtRow:newRow]]);
+
+ [self selectRowIndexes:[NSIndexSet indexSetWithIndex:newRow] byExtendingSelection:NO];
+
+ return;
+ }
+ }
+ else if(firstKey==NSDeleteCharacter||firstKey==NSBackspaceCharacter)
+ {
+ //Post the notification
+ [[NSNotificationCenter defaultCenter] postNotificationName:PXSLDeleteKeyPressedOnRowsNotification object:self userInfo:[NSDictionary dictionaryWithObject:selectedIndexes forKey:@"rows"]];
+
+ return;
+
+ }
+
+ }
+
+ }
+
+ //We don't care about it
+ [super keyDown:theEvent];
}
#pragma mark -
- (NSMenu *)menuForEvent:(NSEvent *)theEvent
{
- NSMenu * m = nil;
- if([_secondaryDelegate respondsToSelector:@selector(sourceList:menuForEvent:item:)]) {
- NSPoint clickPoint = [self convertPoint:[theEvent locationInWindow] fromView:nil];
- NSInteger row = [self rowAtPoint:clickPoint];
- id clickedItem = [self itemAtRow:row];
+ NSMenu * m = nil;
+
+ if([_secondaryDelegate respondsToSelector:@selector(sourceList:menuForEvent:item:)]) {
+ NSPoint clickPoint = [self convertPoint:[theEvent locationInWindow] fromView:nil];
+ NSInteger row = [self rowAtPoint:clickPoint];
+ id clickedItem = [self itemAtRow:row];
+
if ([clickedItem sdtype] > 0)
m = [_secondaryDelegate sourceList:self menuForEvent:theEvent item:clickedItem];
else
m = [super menuForEvent:theEvent];
- }
- if (m == nil) {
- m = [super menuForEvent:theEvent];
- }
- return m;
+ }
+
+ if (m == nil) {
+ m = [super menuForEvent:theEvent];
+ }
+
+ return m;
}
#pragma mark -
#pragma mark NSOutlineView Data Source methods
- (NSInteger)outlineView:(NSOutlineView *)outlineView numberOfChildrenOfItem:(id)item
-{
- if([_secondaryDataSource conformsToProtocol:@protocol(PXSourceListDataSource)]) {
- return [_secondaryDataSource sourceList:self numberOfChildrenOfItem:item];
- }
-
- return 0;
+{
+ if([_secondaryDataSource conformsToProtocol:@protocol(PXSourceListDataSource)]) {
+ return [_secondaryDataSource sourceList:self numberOfChildrenOfItem:item];
+ }
+
+ return 0;
}
- (id)outlineView:(NSOutlineView *)outlineView child:(NSInteger)index ofItem:(id)item
-{
- if([_secondaryDataSource conformsToProtocol:@protocol(PXSourceListDataSource)]) {
- return [_secondaryDataSource sourceList:self child:index ofItem:item];
- }
-
- return nil;
+{
+ if([_secondaryDataSource conformsToProtocol:@protocol(PXSourceListDataSource)]) {
+ return [_secondaryDataSource sourceList:self child:index ofItem:item];
+ }
+
+ return nil;
}
- (BOOL)outlineView:(NSOutlineView *)outlineView isItemExpandable:(id)item
-{
- if([_secondaryDataSource conformsToProtocol:@protocol(PXSourceListDataSource)]) {
- return [_secondaryDataSource sourceList:self isItemExpandable:item];
- }
-
- return NO;
+{
+ if([_secondaryDataSource conformsToProtocol:@protocol(PXSourceListDataSource)]) {
+ return [_secondaryDataSource sourceList:self isItemExpandable:item];
+ }
+
+ return NO;
}
- (id)outlineView:(NSOutlineView *)outlineView objectValueForTableColumn:(NSTableColumn *)tableColumn byItem:(id)item
{
- if([_secondaryDataSource conformsToProtocol:@protocol(PXSourceListDataSource)]) {
- return [_secondaryDataSource sourceList:self objectValueForItem:item];
- }
-
- return nil;
+ if([_secondaryDataSource conformsToProtocol:@protocol(PXSourceListDataSource)]) {
+ return [_secondaryDataSource sourceList:self objectValueForItem:item];
+ }
+
+ return nil;
}
- (void)outlineView:(NSOutlineView *)outlineView setObjectValue:(id)object forTableColumn:(NSTableColumn *)tableColumn byItem:(id)item
-{
- if([_secondaryDataSource conformsToProtocol:@protocol(PXSourceListDataSource)]) {
- [_secondaryDataSource sourceList:self setObjectValue:object forItem:item];
- }
+{
+ if([_secondaryDataSource conformsToProtocol:@protocol(PXSourceListDataSource)]) {
+ [_secondaryDataSource sourceList:self setObjectValue:object forItem:item];
+ }
}
- (id)outlineView:(NSOutlineView *)outlineView itemForPersistentObject:(id)object
{
- if([_secondaryDataSource respondsToSelector:@selector(sourceList:itemForPersistentObject:)]) {
- return [_secondaryDataSource sourceList:self itemForPersistentObject:object];
- }
-
- return nil;
+ if([_secondaryDataSource respondsToSelector:@selector(sourceList:itemForPersistentObject:)]) {
+ return [_secondaryDataSource sourceList:self itemForPersistentObject:object];
+ }
+
+ return nil;
}
- (id)outlineView:(NSOutlineView *)outlineView persistentObjectForItem:(id)item
{
- if([_secondaryDataSource respondsToSelector:@selector(sourceList:persistentObjectForItem:)]) {
- return [_secondaryDataSource sourceList:self persistentObjectForItem:item];
- }
-
- return nil;
+ if([_secondaryDataSource respondsToSelector:@selector(sourceList:persistentObjectForItem:)]) {
+ return [_secondaryDataSource sourceList:self persistentObjectForItem:item];
+ }
+
+ return nil;
}
- (BOOL)outlineView:(NSOutlineView *)outlineView writeItems:(NSArray *)items toPasteboard:(NSPasteboard *)pasteboard
{
- if([_secondaryDataSource respondsToSelector:@selector(sourceList:writeItems:toPasteboard:)]) {
- return [_secondaryDataSource sourceList:self writeItems:items toPasteboard:pasteboard];
- }
-
- return NO;
+ if([_secondaryDataSource respondsToSelector:@selector(sourceList:writeItems:toPasteboard:)]) {
+ return [_secondaryDataSource sourceList:self writeItems:items toPasteboard:pasteboard];
+ }
+
+ return NO;
}
- (NSDragOperation)outlineView:(NSOutlineView *)outlineView validateDrop:(id <NSDraggingInfo>)info proposedItem:(id)item proposedChildIndex:(NSInteger)index
{
- if([_secondaryDataSource respondsToSelector:@selector(sourceList:validateDrop:proposedItem:proposedChildIndex:)]) {
- return [_secondaryDataSource sourceList:self validateDrop:info proposedItem:item proposedChildIndex:index];
- }
-
- return NSDragOperationNone;
+ if([_secondaryDataSource respondsToSelector:@selector(sourceList:validateDrop:proposedItem:proposedChildIndex:)]) {
+ return [_secondaryDataSource sourceList:self validateDrop:info proposedItem:item proposedChildIndex:index];
+ }
+
+ return NSDragOperationNone;
}
- (BOOL)outlineView:(NSOutlineView *)outlineView acceptDrop:(id <NSDraggingInfo>)info item:(id)item childIndex:(NSInteger)index
{
- if([_secondaryDataSource respondsToSelector:@selector(sourceList:acceptDrop:item:childIndex:)]) {
- return [_secondaryDataSource sourceList:self acceptDrop:info item:item childIndex:index];
- }
-
- return NO;
+ if([_secondaryDataSource respondsToSelector:@selector(sourceList:acceptDrop:item:childIndex:)]) {
+ return [_secondaryDataSource sourceList:self acceptDrop:info item:item childIndex:index];
+ }
+
+ return NO;
}
- (NSArray *)outlineView:(NSOutlineView *)outlineView namesOfPromisedFilesDroppedAtDestination:(NSURL *)dropDestination forDraggedItems:(NSArray *)items
{
- if([_secondaryDataSource respondsToSelector:@selector(sourceList:namesOfPromisedFilesDroppedAtDestination:forDraggedItems:)]) {
- return [_secondaryDataSource sourceList:self namesOfPromisedFilesDroppedAtDestination:dropDestination forDraggedItems:items];
- }
-
- return nil;
+ if([_secondaryDataSource respondsToSelector:@selector(sourceList:namesOfPromisedFilesDroppedAtDestination:forDraggedItems:)]) {
+ return [_secondaryDataSource sourceList:self namesOfPromisedFilesDroppedAtDestination:dropDestination forDraggedItems:items];
+ }
+
+ return nil;
}
- (BOOL)outlineView:(NSOutlineView *)outlineView shouldExpandItem:(id)item
{
- if([_secondaryDelegate respondsToSelector:@selector(sourceList:shouldExpandItem:)]) {
- return [_secondaryDelegate sourceList:self shouldExpandItem:item];
- }
-
- return YES;
+ if([_secondaryDelegate respondsToSelector:@selector(sourceList:shouldExpandItem:)]) {
+ return [_secondaryDelegate sourceList:self shouldExpandItem:item];
+ }
+
+ return YES;
}
- (BOOL)outlineView:(NSOutlineView *)outlineView shouldCollapseItem:(id)item
{
- //Make sure the item isn't displayed as always expanded
- if([self isGroupItem:item])
- {
- if([self isGroupAlwaysExpanded:item]) {
- return NO;
- }
- }
-
- if([_secondaryDelegate respondsToSelector:@selector(sourceList:shouldCollapseItem:)]) {
- return [_secondaryDelegate sourceList:self shouldCollapseItem:item];
- }
-
- return YES;
+ //Make sure the item isn't displayed as always expanded
+ if([self isGroupItem:item])
+ {
+ if([self isGroupAlwaysExpanded:item]) {
+ return NO;
+ }
+ }
+
+ if([_secondaryDelegate respondsToSelector:@selector(sourceList:shouldCollapseItem:)]) {
+ return [_secondaryDelegate sourceList:self shouldCollapseItem:item];
+ }
+
+ return YES;
}
- (NSCell *)outlineView:(NSOutlineView *)outlineView dataCellForTableColumn:(NSTableColumn *)tableColumn item:(id)item
{
- if([_secondaryDelegate respondsToSelector:@selector(sourceList:dataCellForItem:)]) {
- return [_secondaryDelegate sourceList:self dataCellForItem:item];
- }
-
- NSInteger row = [self rowForItem:item];
-
- //Return the default table column
- return [[[self tableColumns] objectAtIndex:0] dataCellForRow:row];
+ if([_secondaryDelegate respondsToSelector:@selector(sourceList:dataCellForItem:)]) {
+ return [_secondaryDelegate sourceList:self dataCellForItem:item];
+ }
+
+ NSInteger row = [self rowForItem:item];
+
+ //Return the default table column
+ return [[[self tableColumns] objectAtIndex:0] dataCellForRow:row];
}
- (void)outlineView:(NSOutlineView *)outlineView willDisplayCell:(id)cell forTableColumn:(NSTableColumn *)tableColumn item:(id)item
{
- if([_secondaryDelegate respondsToSelector:@selector(sourceList:willDisplayCell:forItem:)]) {
- [_secondaryDelegate sourceList:self willDisplayCell:cell forItem:item];
- }
+ if([_secondaryDelegate respondsToSelector:@selector(sourceList:willDisplayCell:forItem:)]) {
+ [_secondaryDelegate sourceList:self willDisplayCell:cell forItem:item];
+ }
}
- (BOOL)outlineView:(NSOutlineView *)outlineView shouldSelectItem:(id)item
-{
- //Make sure that the item isn't a group as they can't be selected
- if(![self isGroupItem:item]) {
- if([_secondaryDelegate respondsToSelector:@selector(sourceList:shouldSelectItem:)]) {
- return [_secondaryDelegate sourceList:self shouldSelectItem:item];
- }
- }
- else {
- return NO;
- }
-
- return YES;
+{
+ //Make sure that the item isn't a group as they can't be selected
+ if(![self isGroupItem:item]) {
+ if([_secondaryDelegate respondsToSelector:@selector(sourceList:shouldSelectItem:)]) {
+ return [_secondaryDelegate sourceList:self shouldSelectItem:item];
+ }
+ }
+ else {
+ return NO;
+ }
+
+ return YES;
}
- (NSIndexSet *)outlineView:(NSOutlineView *)outlineView selectionIndexesForProposedSelection:(NSIndexSet *)proposedSelectionIndexes
-{
- //The outline view will try to select the first row if -[allowsEmptySelection:] is set to NO – if this is a group row
- //stop it from doing so and leave it to our implementation of-[reloadData] which will select the first non-group row
- //for us.
- if([self numberOfSelectedRows]==0) {
- if([self isGroupItem:[self itemAtRow:[proposedSelectionIndexes firstIndex]]]) {
- return [NSIndexSet indexSet];
- }
- }
-
- if([_secondaryDelegate respondsToSelector:@selector(sourceList:selectionIndexesForProposedSelection:)]) {
- return [_secondaryDelegate sourceList:self selectionIndexesForProposedSelection:proposedSelectionIndexes];
- }
-
- //Since we implement this method, something must be returned to the outline view
- return proposedSelectionIndexes;
+{
+ //The outline view will try to select the first row if -[allowsEmptySelection:] is set to NO – if this is a group row
+ //stop it from doing so and leave it to our implementation of-[reloadData] which will select the first non-group row
+ //for us.
+ if([self numberOfSelectedRows]==0) {
+ if([self isGroupItem:[self itemAtRow:[proposedSelectionIndexes firstIndex]]]) {
+ return [NSIndexSet indexSet];
+ }
+ }
+
+ if([_secondaryDelegate respondsToSelector:@selector(sourceList:selectionIndexesForProposedSelection:)]) {
+ return [_secondaryDelegate sourceList:self selectionIndexesForProposedSelection:proposedSelectionIndexes];
+ }
+
+ //Since we implement this method, something must be returned to the outline view
+ return proposedSelectionIndexes;
}
- (BOOL)outlineView:(NSOutlineView *)outlineView shouldEditTableColumn:(NSTableColumn *)tableColumn item:(id)item
{
- //Group titles can't be edited
- if([self isGroupItem:item])
- return NO;
-
- if([_secondaryDelegate respondsToSelector:@selector(sourceList:shouldEditItem:)]) {
- return [_secondaryDelegate sourceList:self shouldEditItem:item];
- }
-
- return YES;
+ //Group titles can't be edited
+ if([self isGroupItem:item])
+ return NO;
+
+ if([_secondaryDelegate respondsToSelector:@selector(sourceList:shouldEditItem:)]) {
+ return [_secondaryDelegate sourceList:self shouldEditItem:item];
+ }
+
+ return YES;
}
- (BOOL)outlineView:(NSOutlineView *)outlineView shouldTrackCell:(NSCell *)cell forTableColumn:(NSTableColumn *)tableColumn item:(id)item
-{
- if([_secondaryDelegate respondsToSelector:@selector(sourceList:shouldTrackCell:forItem:)]) {
- return [_secondaryDelegate sourceList:self shouldTrackCell:cell forItem:item];
- }
-
- return NO;
+{
+ if([_secondaryDelegate respondsToSelector:@selector(sourceList:shouldTrackCell:forItem:)]) {
+ return [_secondaryDelegate sourceList:self shouldTrackCell:cell forItem:item];
+ }
+
+ return NO;
}
- (CGFloat)outlineView:(NSOutlineView *)outlineView heightOfRowByItem:(id)item
{
- if([_secondaryDelegate respondsToSelector:@selector(sourceList:heightOfRowByItem:)]) {
- return [_secondaryDelegate sourceList:self heightOfRowByItem:item];
- }
-
- return [self rowHeight];
+ if([_secondaryDelegate respondsToSelector:@selector(sourceList:heightOfRowByItem:)]) {
+ return [_secondaryDelegate sourceList:self heightOfRowByItem:item];
+ }
+
+ return [self rowHeight];
}
- (BOOL)outlineView:(NSOutlineView *)outlineView isGroupItem:(id)item
{
- return [self isGroupItem:item];
+ return [self isGroupItem:item];
}
#pragma mark -
/* Notification wrappers */
- (void)outlineViewSelectionIsChanging:(NSNotification *)notification
{
- [[NSNotificationCenter defaultCenter] postNotificationName:PXSLSelectionIsChangingNotification object:self];
+ [[NSNotificationCenter defaultCenter] postNotificationName:PXSLSelectionIsChangingNotification object:self];
}
- (void)outlineViewSelectionDidChange:(NSNotification *)notification
{
- [[NSNotificationCenter defaultCenter] postNotificationName:PXSLSelectionDidChangeNotification object:self];
+ [[NSNotificationCenter defaultCenter] postNotificationName:PXSLSelectionDidChangeNotification object:self];
}
- (void)outlineViewItemWillExpand:(NSNotification *)notification
{
- [[NSNotificationCenter defaultCenter] postNotificationName:PXSLItemWillExpandNotification
- object:self
- userInfo:[notification userInfo]];
+ [[NSNotificationCenter defaultCenter] postNotificationName:PXSLItemWillExpandNotification object:self userInfo:[notification userInfo]];
}
- (void)outlineViewItemDidExpand:(NSNotification *)notification
{
- [[NSNotificationCenter defaultCenter] postNotificationName:PXSLItemDidExpandNotification
- object:self
- userInfo:[notification userInfo]];
+ [[NSNotificationCenter defaultCenter] postNotificationName:PXSLItemDidExpandNotification object:self userInfo:[notification userInfo]];
}
- (void)outlineViewItemWillCollapse:(NSNotification *)notification
{
- [[NSNotificationCenter defaultCenter] postNotificationName:PXSLItemWillCollapseNotification
- object:self
- userInfo:[notification userInfo]];
+ [[NSNotificationCenter defaultCenter] postNotificationName:PXSLItemWillCollapseNotification object:self userInfo:[notification userInfo]];
}
- (void)outlineViewItemDidCollapse:(NSNotification *)notification
{
- [[NSNotificationCenter defaultCenter] postNotificationName:PXSLItemDidCollapseNotification
- object:self
- userInfo:[notification userInfo]];
+ [[NSNotificationCenter defaultCenter] postNotificationName:PXSLItemDidCollapseNotification object:self userInfo:[notification userInfo]];
}
- (void)registerDelegateToReceiveNotification:(NSString*)notification withSelector:(SEL)selector
{
- NSNotificationCenter *defaultCenter = [NSNotificationCenter defaultCenter];
-
- //Set the delegate as a receiver of the notification if it implements the notification method
- if([_secondaryDelegate respondsToSelector:selector]) {
- [defaultCenter addObserver:_secondaryDelegate
- selector:selector
- name:notification
- object:self];
- }
+ NSNotificationCenter *defaultCenter = [NSNotificationCenter defaultCenter];
+
+ //Set the delegate as a receiver of the notification if it implements the notification method
+ if([_secondaryDelegate respondsToSelector:selector]) {
+ [defaultCenter addObserver:_secondaryDelegate selector:selector name:notification object:self];
+ }
}
@end
@implementation SPInvocationGrabber
- (id)initWithObject:(id)obj;
{
- return [self initWithObject:obj stacktraceSaving:YES];
+ return [self initWithObject:obj stacktraceSaving:YES];
}
-(id)initWithObject:(id)obj stacktraceSaving:(BOOL)saveStack;
{
- self.object = obj;
+ self.object = obj;
+ if(saveStack)
+ [self saveBacktrace];
- if(saveStack)
- [self saveBacktrace];
-
- return self;
+ return self;
}
+
-(void)dealloc;
{
- free(frameStrings);
- self.object = nil;
- self.invocation = nil;
- [super dealloc];
+ free(frameStrings);
+ self.object = nil;
+ self.invocation = nil;
+
+ [super dealloc];
}
@synthesize invocation = _invocation, object = _object;
@synthesize backgroundAfterForward, onMainAfterForward, waitUntilDone;
- (void)runInBackground;
{
- NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
- @try {
- [self invoke];
- }
- @finally {
- [pool drain];
- }
+ NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
+ @try {
+ [self invoke];
+ }
+ @finally {
+ [pool drain];
+ }
}
- (void)forwardInvocation:(NSInvocation *)anInvocation {
- [anInvocation retainArguments];
- anInvocation.target = _object;
- self.invocation = anInvocation;
-
- if(backgroundAfterForward)
- [NSThread detachNewThreadSelector:@selector(runInBackground) toTarget:self withObject:nil];
- else if(onMainAfterForward)
+ [anInvocation retainArguments];
+ anInvocation.target = _object;
+ self.invocation = anInvocation;
+
+ if(backgroundAfterForward)
+ [NSThread detachNewThreadSelector:@selector(runInBackground) toTarget:self withObject:nil];
+ else if(onMainAfterForward)
[self performSelectorOnMainThread:@selector(invoke) withObject:nil waitUntilDone:waitUntilDone];
}
+
- (NSMethodSignature *)methodSignatureForSelector:(SEL)inSelector {
- NSMethodSignature *signature = [super methodSignatureForSelector:inSelector];
- if (signature == NULL)
- signature = [_object methodSignatureForSelector:inSelector];
-
- return signature;
+ NSMethodSignature *signature = [super methodSignatureForSelector:inSelector];
+ if (signature == NULL)
+ signature = [_object methodSignatureForSelector:inSelector];
+
+ return signature;
}
- (void)invoke;
{
-
- @try {
- [_invocation invoke];
- }
- @catch (NSException * e) {
- NSLog(@"SPInvocationGrabber's target raised %@:\n\t%@\nInvocation was originally scheduled at:", e.name, e);
- [self printBacktrace];
- printf("\n");
- [e raise];
- }
-
- self.invocation = nil;
- self.object = nil;
+ @try {
+ [_invocation invoke];
+ }
+
+ @catch (NSException * e) {
+ NSLog(@"SPInvocationGrabber's target raised %@:\n\t%@\nInvocation was originally scheduled at:", e.name, e);
+ [self printBacktrace];
+ printf("\n");
+ [e raise];
+ }
+
+ self.invocation = nil;
+ self.object = nil;
}
-(void)saveBacktrace;
{
- void *backtraceFrames[128];
- frameCount = backtrace(&backtraceFrames[0], 128);
- frameStrings = backtrace_symbols(&backtraceFrames[0], frameCount);
+ void *backtraceFrames[128];
+ frameCount = backtrace(&backtraceFrames[0], 128);
+ frameStrings = backtrace_symbols(&backtraceFrames[0], frameCount);
}
+
-(void)printBacktrace;
{
- for(int x = 3; x < frameCount; x++) {
- if(frameStrings[x] == NULL) { break; }
- printf("%s\n", frameStrings[x]);
- }
+ for(int x = 3; x < frameCount; x++) {
+ if(frameStrings[x] == NULL) { break; }
+ printf("%s\n", frameStrings[x]);
+ }
}
@end
@implementation NSObject (SPInvocationGrabbing)
-(id)grab;
{
- return [[[SPInvocationGrabber alloc] initWithObject:self] autorelease];
+ return [[[SPInvocationGrabber alloc] initWithObject:self] autorelease];
}
+
-(id)invokeAfter:(NSTimeInterval)delta;
{
- id grabber = [self grab];
- [NSTimer scheduledTimerWithTimeInterval:delta target:grabber selector:@selector(invoke) userInfo:nil repeats:NO];
- return grabber;
+ id grabber = [self grab];
+ [NSTimer scheduledTimerWithTimeInterval:delta target:grabber selector:@selector(invoke) userInfo:nil repeats:NO];
+ return grabber;
}
+
- (id)nextRunloop;
{
- return [self invokeAfter:0];
+ return [self invokeAfter:0];
}
+
-(id)inBackground;
{
SPInvocationGrabber *grabber = [self grab];
- grabber.backgroundAfterForward = YES;
- return grabber;
+ grabber.backgroundAfterForward = YES;
+ return grabber;
}
+
-(id)onMainAsync:(BOOL)async;
{
SPInvocationGrabber *grabber = [self grab];
- grabber.onMainAfterForward = YES;
+ grabber.onMainAfterForward = YES;
grabber.waitUntilDone = !async;
- return grabber;
+ return grabber;
}
@end
#define SPSystemDefinedEventMediaKeys 8
@interface SPMediaKeyTap : NSObject {
- EventHandlerRef _app_switching_ref;
- EventHandlerRef _app_terminating_ref;
- CFMachPortRef _eventPort;
- CFRunLoopSourceRef _eventPortSource;
- CFRunLoopRef _tapThreadRL;
- BOOL _shouldInterceptMediaKeyEvents;
- id _delegate;
- // The app that is frontmost in this list owns media keys
- NSMutableArray *_mediaKeyAppList;
+
+EventHandlerRef _app_switching_ref;
+
+EventHandlerRef _app_terminating_ref;
+
+CFMachPortRef _eventPort;
+
+CFRunLoopSourceRef _eventPortSource;
+
+CFRunLoopRef _tapThreadRL;
+
+BOOL _shouldInterceptMediaKeyEvents;
+
+id _delegate;
+
+// The app that is frontmost in this list owns media keys
+
+NSMutableArray *_mediaKeyAppList;
}
+ (NSArray*)defaultMediaKeyUserBundleIdentifiers;
#pragma mark Setup and teardown
-(id)initWithDelegate:(id)delegate;
{
- _delegate = delegate;
- [self startWatchingAppSwitching];
- singleton = self;
- _mediaKeyAppList = [NSMutableArray new];
- return self;
+ _delegate = delegate;
+ [self startWatchingAppSwitching];
+ singleton = self;
+ _mediaKeyAppList = [NSMutableArray new];
+ return self;
}
-(void)dealloc;
{
- [self stopWatchingMediaKeys];
- [self stopWatchingAppSwitching];
- [_mediaKeyAppList release];
- [super dealloc];
+ [self stopWatchingMediaKeys];
+ [self stopWatchingAppSwitching];
+ [_mediaKeyAppList release];
+ [super dealloc];
}
-(void)startWatchingAppSwitching;
{
- // Listen to "app switched" event, so that we don't intercept media keys if we
- // weren't the last "media key listening" app to be active
- EventTypeSpec eventType = { kEventClassApplication, kEventAppFrontSwitched };
+ // Listen to "app switched" event, so that we don't intercept media keys if we
+ // weren't the last "media key listening" app to be active
+ EventTypeSpec eventType = { kEventClassApplication, kEventAppFrontSwitched };
OSStatus err = InstallApplicationEventHandler(NewEventHandlerUPP(appSwitched), 1, &eventType, self, &_app_switching_ref);
- assert(err == noErr);
-
- eventType.eventKind = kEventAppTerminated;
+ assert(err == noErr);
+
+ eventType.eventKind = kEventAppTerminated;
err = InstallApplicationEventHandler(NewEventHandlerUPP(appTerminated), 1, &eventType, self, &_app_terminating_ref);
- assert(err == noErr);
+ assert(err == noErr);
}
-(void)stopWatchingAppSwitching;
{
- if(!_app_switching_ref) return;
- RemoveEventHandler(_app_switching_ref);
- _app_switching_ref = NULL;
+ if(!_app_switching_ref) return;
+ RemoveEventHandler(_app_switching_ref);
+ _app_switching_ref = NULL;
}
-(void)startWatchingMediaKeys;{
- [self setShouldInterceptMediaKeyEvents:YES];
-
- // Add an event tap to intercept the system defined media key events
- _eventPort = CGEventTapCreate(kCGSessionEventTap,
- kCGHeadInsertEventTap,
- kCGEventTapOptionDefault,
- CGEventMaskBit(NX_SYSDEFINED),
- tapEventCallback,
- self);
- assert(_eventPort != NULL);
-
+ [self setShouldInterceptMediaKeyEvents:YES];
+
+ // Add an event tap to intercept the system defined media key events
+ _eventPort = CGEventTapCreate(kCGSessionEventTap,
+ kCGHeadInsertEventTap,
+ kCGEventTapOptionDefault,
+ CGEventMaskBit(NX_SYSDEFINED),
+ tapEventCallback,
+ self);
+ assert(_eventPort != NULL);
+
_eventPortSource = CFMachPortCreateRunLoopSource(kCFAllocatorSystemDefault, _eventPort, 0);
- assert(_eventPortSource != NULL);
-
- // Let's do this in a separate thread so that a slow app doesn't lag the event tap
- [NSThread detachNewThreadSelector:@selector(eventTapThread) toTarget:self withObject:nil];
+ assert(_eventPortSource != NULL);
+
+ // Let's do this in a separate thread so that a slow app doesn't lag the event tap
+ [NSThread detachNewThreadSelector:@selector(eventTapThread) toTarget:self withObject:nil];
}
-(void)stopWatchingMediaKeys;
{
- // TODO<nevyn>: Shut down thread, remove event tap port and source
+ // TODO<nevyn>: Shut down thread, remove event tap port and source
}
#pragma mark -
+(BOOL)usesGlobalMediaKeyTap
{
- return YES;
+ return YES;
#ifdef _DEBUG
- return NO;
+ return NO;
#else
- // XXX(nevyn): MediaKey event tap doesn't work on 10.4, feel free to figure out why if you have the energy.
- return floor(NSAppKitVersionNumber) >= 949/*NSAppKitVersionNumber10_5*/;
+ // XXX(nevyn): MediaKey event tap doesn't work on 10.4, feel free to figure out why if you have the energy.
+ return floor(NSAppKitVersionNumber) >= 949/*NSAppKitVersionNumber10_5*/;
#endif
}
+ (NSArray*)defaultMediaKeyUserBundleIdentifiers;
{
- return [NSArray arrayWithObjects:
- @"com.spotify.client",
- @"com.apple.iTunes",
- @"com.apple.QuickTimePlayerX",
- @"com.apple.quicktimeplayer",
- @"com.apple.iWork.Keynote",
- @"com.apple.iPhoto",
- @"org.videolan.vlc",
- @"com.apple.Aperture",
- @"com.plexsquared.Plex",
- @"com.soundcloud.desktop",
- @"com.macromedia.fireworks", // the tap messes up their mouse input
- nil
- ];
+ return [NSArray arrayWithObjects:
+ @"com.spotify.client",
+ @"com.apple.iTunes",
+ @"com.apple.QuickTimePlayerX",
+ @"com.apple.quicktimeplayer",
+ @"com.apple.iWork.Keynote",
+ @"com.apple.iPhoto",
+ @"org.videolan.vlc",
+ @"com.apple.Aperture",
+ @"com.plexsquared.Plex",
+ @"com.soundcloud.desktop",
+ @"com.macromedia.fireworks", // the tap messes up their mouse input
+ nil
+ ];
}
-(BOOL)shouldInterceptMediaKeyEvents;
{
- BOOL shouldIntercept = NO;
- @synchronized(self) {
- shouldIntercept = _shouldInterceptMediaKeyEvents;
- }
- return shouldIntercept;
+ BOOL shouldIntercept = NO;
+ @synchronized(self) {
+ shouldIntercept = _shouldInterceptMediaKeyEvents;
+ }
+ return shouldIntercept;
}
-(void)pauseTapOnTapThread:(BOOL)yeahno;
{
- CGEventTapEnable(self->_eventPort, yeahno);
+ CGEventTapEnable(self->_eventPort, yeahno);
}
-(void)setShouldInterceptMediaKeyEvents:(BOOL)newSetting;
{
- BOOL oldSetting;
- @synchronized(self) {
- oldSetting = _shouldInterceptMediaKeyEvents;
- _shouldInterceptMediaKeyEvents = newSetting;
- }
- if(_tapThreadRL && oldSetting != newSetting) {
- id grab = [self grab];
- [grab pauseTapOnTapThread:newSetting];
- NSTimer *timer = [NSTimer timerWithTimeInterval:0 invocation:[grab invocation] repeats:NO];
- CFRunLoopAddTimer(_tapThreadRL, (CFRunLoopTimerRef)timer, kCFRunLoopCommonModes);
- }
+ BOOL oldSetting;
+ @synchronized(self) {
+ oldSetting = _shouldInterceptMediaKeyEvents;
+ _shouldInterceptMediaKeyEvents = newSetting;
+ }
+ if(_tapThreadRL && oldSetting != newSetting) {
+ id grab = [self grab];
+ [grab pauseTapOnTapThread:newSetting];
+ NSTimer *timer = [NSTimer timerWithTimeInterval:0 invocation:[grab invocation] repeats:NO];
+ CFRunLoopAddTimer(_tapThreadRL, (CFRunLoopTimerRef)timer, kCFRunLoopCommonModes);
+ }
}
#pragma mark
static CGEventRef tapEventCallback2(CGEventTapProxy proxy, CGEventType type, CGEventRef event, void *refcon)
{
- SPMediaKeyTap *self = refcon;
+ SPMediaKeyTap *self = refcon;
if(type == kCGEventTapDisabledByTimeout) {
- NSLog(@"Media key event tap was disabled by timeout");
- CGEventTapEnable(self->_eventPort, TRUE);
- return event;
- } else if(type == kCGEventTapDisabledByUserInput) {
- // Was disabled manually by -[pauseTapOnTapThread]
- return event;
- }
- NSEvent *nsEvent = nil;
- @try {
- nsEvent = [NSEvent eventWithCGEvent:event];
- }
- @catch (NSException * e) {
- NSLog(@"Strange CGEventType: %d: %@", type, e);
- assert(0);
- return event;
- }
-
- if (type != NX_SYSDEFINED || [nsEvent subtype] != SPSystemDefinedEventMediaKeys)
- return event;
-
- int keyCode = (([nsEvent data1] & 0xFFFF0000) >> 16);
- if (keyCode != NX_KEYTYPE_PLAY && keyCode != NX_KEYTYPE_FAST && keyCode != NX_KEYTYPE_REWIND)
- return event;
-
- if (![self shouldInterceptMediaKeyEvents])
- return event;
-
- [nsEvent retain]; // matched in handleAndReleaseMediaKeyEvent:
- [self performSelectorOnMainThread:@selector(handleAndReleaseMediaKeyEvent:) withObject:nsEvent waitUntilDone:NO];
-
- return NULL;
+ NSLog(@"Media key event tap was disabled by timeout");
+ CGEventTapEnable(self->_eventPort, TRUE);
+ return event;
+ } else if(type == kCGEventTapDisabledByUserInput) {
+ // Was disabled manually by -[pauseTapOnTapThread]
+ return event;
+ }
+ NSEvent *nsEvent = nil;
+ @try {
+ nsEvent = [NSEvent eventWithCGEvent:event];
+ }
+ @catch (NSException * e) {
+ NSLog(@"Strange CGEventType: %d: %@", type, e);
+ assert(0);
+ return event;
+ }
+
+ if (type != NX_SYSDEFINED || [nsEvent subtype] != SPSystemDefinedEventMediaKeys)
+ return event;
+
+ int keyCode = (([nsEvent data1] & 0xFFFF0000) >> 16);
+ if (keyCode != NX_KEYTYPE_PLAY && keyCode != NX_KEYTYPE_FAST && keyCode != NX_KEYTYPE_REWIND)
+ return event;
+
+ if (![self shouldInterceptMediaKeyEvents])
+ return event;
+
+ [nsEvent retain]; // matched in handleAndReleaseMediaKeyEvent:
+ [self performSelectorOnMainThread:@selector(handleAndReleaseMediaKeyEvent:) withObject:nsEvent waitUntilDone:NO];
+
+ return NULL;
}
static CGEventRef tapEventCallback(CGEventTapProxy proxy, CGEventType type, CGEventRef event, void *refcon)
{
- NSAutoreleasePool *pool = [NSAutoreleasePool new];
- CGEventRef ret = tapEventCallback2(proxy, type, event, refcon);
- [pool drain];
- return ret;
+ NSAutoreleasePool *pool = [NSAutoreleasePool new];
+ CGEventRef ret = tapEventCallback2(proxy, type, event, refcon);
+ [pool drain];
+ return ret;
}
// event will have been retained in the other thread
-(void)handleAndReleaseMediaKeyEvent:(NSEvent *)event {
- [event autorelease];
-
- [_delegate mediaKeyTap:self receivedMediaKeyEvent:event];
+ [event autorelease];
+
+ [_delegate mediaKeyTap:self receivedMediaKeyEvent:event];
}
-(void)eventTapThread;
{
- _tapThreadRL = CFRunLoopGetCurrent();
- CFRunLoopAddSource(_tapThreadRL, _eventPortSource, kCFRunLoopCommonModes);
- CFRunLoopRun();
+ _tapThreadRL = CFRunLoopGetCurrent();
+ CFRunLoopAddSource(_tapThreadRL, _eventPortSource, kCFRunLoopCommonModes);
+ CFRunLoopRun();
}
#pragma mark Task switching callbacks
-(void)mediaKeyAppListChanged;
{
- if([_mediaKeyAppList count] == 0) return;
-
- /*NSLog(@"--");
- int i = 0;
- for (NSValue *psnv in _mediaKeyAppList) {
- ProcessSerialNumber psn; [psnv getValue:&psn];
- NSDictionary *processInfo = [(id)ProcessInformationCopyDictionary(
- &psn,
- kProcessDictionaryIncludeAllInformationMask
- ) autorelease];
- NSString *bundleIdentifier = [processInfo objectForKey:(id)kCFBundleIdentifierKey];
- NSLog(@"%d: %@", i++, bundleIdentifier);
- }*/
-
+ if([_mediaKeyAppList count] == 0) return;
+
+ /*NSLog(@"--");
+ int i = 0;
+ for (NSValue *psnv in _mediaKeyAppList) {
+ ProcessSerialNumber psn; [psnv getValue:&psn];
+ NSDictionary *processInfo = [(id)ProcessInformationCopyDictionary(
+ &psn,
+ kProcessDictionaryIncludeAllInformationMask
+ ) autorelease];
+ NSString *bundleIdentifier = [processInfo objectForKey:(id)kCFBundleIdentifierKey];
+ NSLog(@"%d: %@", i++, bundleIdentifier);
+ }*/
+
ProcessSerialNumber mySerial, topSerial;
- GetCurrentProcess(&mySerial);
- [[_mediaKeyAppList objectAtIndex:0] getValue:&topSerial];
+ GetCurrentProcess(&mySerial);
+ [[_mediaKeyAppList objectAtIndex:0] getValue:&topSerial];
- Boolean same;
- OSErr err = SameProcess(&mySerial, &topSerial, &same);
- [self setShouldInterceptMediaKeyEvents:(err == noErr && same)];
+ Boolean same;
+ OSErr err = SameProcess(&mySerial, &topSerial, &same);
+ [self setShouldInterceptMediaKeyEvents:(err == noErr && same)];
}
-(void)appIsNowFrontmost:(ProcessSerialNumber)psn;
{
- NSValue *psnv = [NSValue valueWithBytes:&psn objCType:@encode(ProcessSerialNumber)];
-
- NSDictionary *processInfo = [(id)ProcessInformationCopyDictionary(
- &psn,
- kProcessDictionaryIncludeAllInformationMask
- ) autorelease];
- NSString *bundleIdentifier = [processInfo objectForKey:(id)kCFBundleIdentifierKey];
-
- NSArray *whitelistIdentifiers = [[NSUserDefaults standardUserDefaults] arrayForKey:kMediaKeyUsingBundleIdentifiersDefaultsKey];
- if(![whitelistIdentifiers containsObject:bundleIdentifier]) return;
-
- [_mediaKeyAppList removeObject:psnv];
- [_mediaKeyAppList insertObject:psnv atIndex:0];
- [self mediaKeyAppListChanged];
+ NSValue *psnv = [NSValue valueWithBytes:&psn objCType:@encode(ProcessSerialNumber)];
+
+ NSDictionary *processInfo = [(id)ProcessInformationCopyDictionary(
+ &psn,
+ kProcessDictionaryIncludeAllInformationMask
+ ) autorelease];
+ NSString *bundleIdentifier = [processInfo objectForKey:(id)kCFBundleIdentifierKey];
+
+ NSArray *whitelistIdentifiers = [[NSUserDefaults standardUserDefaults] arrayForKey:kMediaKeyUsingBundleIdentifiersDefaultsKey];
+ if(![whitelistIdentifiers containsObject:bundleIdentifier]) return;
+
+ [_mediaKeyAppList removeObject:psnv];
+ [_mediaKeyAppList insertObject:psnv atIndex:0];
+ [self mediaKeyAppListChanged];
}
-(void)appTerminated:(ProcessSerialNumber)psn;
{
- NSValue *psnv = [NSValue valueWithBytes:&psn objCType:@encode(ProcessSerialNumber)];
- [_mediaKeyAppList removeObject:psnv];
- [self mediaKeyAppListChanged];
+ NSValue *psnv = [NSValue valueWithBytes:&psn objCType:@encode(ProcessSerialNumber)];
+ [_mediaKeyAppList removeObject:psnv];
+ [self mediaKeyAppListChanged];
}
static pascal OSStatus appSwitched (EventHandlerCallRef nextHandler, EventRef evt, void* userData)
{
- SPMediaKeyTap *self = (id)userData;
+ SPMediaKeyTap *self = (id)userData;
ProcessSerialNumber newSerial;
GetFrontProcess(&newSerial);
-
- [self appIsNowFrontmost:newSerial];
-
+
+ [self appIsNowFrontmost:newSerial];
+
return CallNextEventHandler(nextHandler, evt);
}
static pascal OSStatus appTerminated (EventHandlerCallRef nextHandler, EventRef evt, void* userData)
{
- SPMediaKeyTap *self = (id)userData;
-
- ProcessSerialNumber deadPSN;
-
- GetEventParameter(
- evt,
- kEventParamProcessID,
- typeProcessSerialNumber,
- NULL,
- sizeof(deadPSN),
- NULL,
- &deadPSN
- );
-
-
- [self appTerminated:deadPSN];
+ SPMediaKeyTap *self = (id)userData;
+
+ ProcessSerialNumber deadPSN;
+
+ GetEventParameter(
+ evt,
+ kEventParamProcessID,
+ typeProcessSerialNumber,
+ NULL,
+ sizeof(deadPSN),
+ NULL,
+ &deadPSN
+ );
+
+
+ [self appTerminated:deadPSN];
return CallNextEventHandler(nextHandler, evt);
}
- SourceListItem *child1;
- SourceListItem *child2;
- SourceListItem *childOfChild2;
- - SourceListItem *anotherChildOfChild2;
+
+ - SourceListItem *anotherChildOfChild2;
- SourceListItem *child3;
*/
@interface SideBarItem : NSObject {
- NSString *title;
- NSString *identifier;
+
+NSString *title;
+
+NSString *identifier;
NSString *untranslatedTitle;
- NSImage *icon;
- NSInteger badgeValue;
+
+NSImage *icon;
+
+NSInteger badgeValue;
NSInteger sdtype;
- NSArray *children;
+
+NSArray *children;
}
@property (nonatomic, copy) NSString *title;
- (id)init
{
- if(self=[super init])
- {
- badgeValue = -1; //We don't want a badge value by default
+ if(self=[super init])
+ {
+ badgeValue = -1; //We don't want a badge value by default
sdtype = -1; //no sd type set
- }
+ }
- return self;
+ return self;
}
+ (id)itemWithTitle:(NSString*)aTitle identifier:(NSString*)anIdentifier
{
- SideBarItem *item = [SideBarItem itemWithTitle:aTitle identifier:anIdentifier icon:nil];
+ SideBarItem *item = [SideBarItem itemWithTitle:aTitle identifier:anIdentifier icon:nil];
- return item;
+ 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];
+ SideBarItem *item = [[[SideBarItem alloc] init] autorelease];
- return item;
+ [item setTitle:aTitle];
+ [item setIdentifier:anIdentifier];
+ [item setIcon:anIcon];
+
+ return item;
}
- (void)dealloc
{
- [title release];
- [identifier release];
- [icon release];
- [children release];
+ [title release];
+ [identifier release];
+ [icon release];
+ [children release];
- [super dealloc];
+ [super dealloc];
}
- (void)finalize
{
- title = nil;
- identifier = nil;
- icon = nil;
- children = nil;
+ title = nil;
+ identifier = nil;
+ icon = nil;
+ children = nil;
- [super finalize];
+ [super finalize];
}
#pragma mark -
- (BOOL)hasBadge
{
- return badgeValue!=-1;
+ return badgeValue!=-1;
}
- (BOOL)hasChildren
{
- return [children count]>0;
+ return [children count]>0;
}
- (BOOL)hasIcon
{
- return icon!=nil;
+ return icon!=nil;
}
@end
p_intf = VLCIntf;
_o_sharedInstance = [super init];
}
-
+
return _o_sharedInstance;
}
NSTimeInterval i_start;
BOOL b_restart;
BOOL b_isSetUp;
-
+
/* generic help window */
IBOutlet id o_help_window;
IBOutlet WebView *o_help_web_view; //we may _not_ use id here because of method name collisions
/* Setup the nameversion field */
[o_name_version_field setStringValue: [NSString stringWithFormat:@"Version %s (%s)", VERSION_MESSAGE, PLATFORM]];
-
+
NSMutableArray *tmpArray = [NSMutableArray arrayWithArray: [[NSString stringWithUTF8String: psz_authors]componentsSeparatedByString:@"\n\n"]];
NSUInteger count = [tmpArray count];
for( NSUInteger i = 0; i < count; i++ )
{
[o_gpl_window setTitle: _NS("License")];
[o_gpl_field setString: [NSString stringWithUTF8String: psz_license]];
-
+
[o_gpl_window center];
[o_gpl_window makeKeyAndOrderFront: sender];
}
[o_help_home_btn setToolTip: _NS("Index")];
[o_help_window makeKeyAndOrderFront: self];
-
+
[[o_help_web_view mainFrame] loadHTMLString: _NS(I_LONGHELP)
baseURL: [NSURL URLWithString:@"http://videolan.org"]];
}
*****************************************************************************/
@implementation NSApplication(ScriptSupport)
-- (BOOL) scriptFullscreenMode {
+- (BOOL) scriptFullscreenMode {
vout_thread_t * p_vout = getVout();
if( !p_vout )
return NO;
seekpoint_t bookmark;
if( !input_Control( p_input, INPUT_GET_BOOKMARK, &bookmark ) )
- {
- bookmark.psz_name = _("Untitled");
- input_Control( p_input, INPUT_ADD_BOOKMARK, &bookmark );
- }
+ {
+ bookmark.psz_name = _("Untitled");
+ input_Control( p_input, INPUT_ADD_BOOKMARK, &bookmark );
+ }
vlc_object_release( p_input );
IBOutlet id o_cleanup_button;
IBOutlet id o_error_table;
IBOutlet id o_messages_btn;
-
+
NSMutableArray * o_errors;
NSMutableArray * o_icons;
-
+
BOOL b_nib_loaded;
}
- (IBAction)cleanupTable:(id)sender;
o_error_panel = [[VLCErrorPanel alloc] init];
b_progress_cancelled = NO;
}
-
+
return _o_sharedInstance;
}
NSAlert *o_alert;
NSString *o_yes, *o_no, *o_cancel;
NSInteger i_returnValue = 0;
-
+
if( p_dialog->yes != NULL )
o_yes = [NSString stringWithUTF8String: p_dialog->yes];
if( p_dialog->no != NULL )
object: @"VLCEyeTVSupport"
suspensionBehavior: NSNotificationSuspensionBehaviorDeliverImmediately];
}
-
+
return _o_sharedInstance;
}
"end tell"];
NSLog( @"telling eyetv to switch 1 channel down" );
}
-
+
descriptor = [script executeAndReturnError:&errorDict];
if( nil == descriptor )
{
[self mouseExited:NULL];
[self center];
-
+
/* get a notification if VLC isn't the active app anymore */
[[NSNotificationCenter defaultCenter]
addObserver: self
selector: @selector(setNonActive:)
name: NSApplicationDidResignActiveNotification
object: NSApp];
-
+
/* get a notification if VLC is the active app again */
[[NSNotificationCenter defaultCenter]
addObserver: self
NSRect theScreensFrame;
NSRect theWindowsFrame;
NSScreen *screen;
-
+
/* user-defined screen */
screen = [NSScreen screenWithDisplayID: (CGDirectDisplayID)i_device];
-
+
if (!screen)
{
/* invalid preferences or none specified, using main screen */
theScreensFrame = [screen frame];
theWindowsFrame = [self frame];
-
+
if( theScreensFrame.size.width >= 1920 ) // 17" MBP, 24"/27" iMacs, external displays
b_usingBigScreen = YES;
{
b_nonActive = YES;
[self orderOut: self];
-
+
/* here's fadeOut, just without visibly fading */
b_displayed = NO;
[self setAlphaValue:0.0];
return;
[self orderFront: nil];
-
+
if( [self alphaValue] < 1.0 || b_displayed != YES )
{
if (![self fadeTimer])
{
/* this will tell the timer to start over again or to start at all */
b_keptVisible = YES;
-
+
/* get us a valid timer */
if(! b_alreadyCounting )
{
[o_fs_volumeSlider setTarget: self];
[o_fs_volumeSlider setAction: @selector(fsVolumeSliderUpdate:)];
[self addSubview: o_fs_volumeSlider];
-
+
/* time counter and stream title output fields */
s_rc = [self frame];
s_rc.origin.x = 98;
NSRectClip(NSZeroRect);
[super drawRect:rect];
[[NSGraphicsContext currentContext] restoreGraphicsState];
-
+
NSRect knobRect = [[self cell] knobRectFlipped:NO];
knobRect.origin.y+=7.5;
[[[NSColor blackColor] colorWithAlphaComponent:0.6] set];
NSRectClip(NSZeroRect);
[super drawRect:rect];
[[NSGraphicsContext currentContext] restoreGraphicsState];
-
+
NSRect knobRect = [[self cell] knobRectFlipped:NO];
knobRect.origin.y+=6;
[[[NSColor blackColor] colorWithAlphaComponent:0.6] set];
- (CGDirectDisplayID)displayID
{
- return (CGDirectDisplayID)[[[self deviceDescription] objectForKey: @"NSScreenNumber"] intValue];
+ return (CGDirectDisplayID)[[[self deviceDescription] objectForKey: @"NSScreenNumber"] intValue];
}
- (void)blackoutOtherScreens
[o_capture_mode_pop removeAllItems];
[o_capture_mode_pop addItemWithTitle: _NS("Capture Device")];
- // our screen capture module isn't Lion-compatible, so let's hide it from the user if needed (trac #4799)
- if( NSAppKitVersionNumber < 1115.2 )
- [o_capture_mode_pop addItemWithTitle: _NS("Screen")];
+
+ // our screen capture module isn't Lion-compatible, so let's hide it from the user if needed (trac #4799)
+ if( NSAppKitVersionNumber < 1115.2 )
+ [o_capture_mode_pop addItemWithTitle: _NS("Screen")];
+
[o_capture_mode_pop addItemWithTitle: @"EyeTV"];
[o_screen_long_lbl setStringValue: _NS("This input allows you to save, stream or display your current screen contents.")];
[o_screen_fps_lbl setStringValue: _NS("Frames per Second:")];
[self qtkvideoDevices];
[o_qtk_device_pop removeAllItems];
msg_Dbg( VLCIntf, "Found %lu capture devices", [qtkvideoDevices count] );
- if([qtkvideoDevices count] >= 1)
- {
+
+ if([qtkvideoDevices count] >= 1)
+ {
if (!qtk_currdevice_uid) {
qtk_currdevice_uid = [[[QTCaptureDevice defaultInputDeviceWithMediaType: QTMediaTypeVideo] uniqueID]
stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
}
}
}
- else
- {
- [o_qtk_device_pop addItemWithTitle: _NS("None")];
+ else
+ {
+ [o_qtk_device_pop addItemWithTitle: _NS("None")];
[qtk_currdevice_uid release];
- }
-
+ }
[self setSubPanel];
o_specialMediaFolders = [[NSMutableArray alloc] init];
o_opticalDevices = [[NSMutableArray alloc] init];
NSWorkspace *sharedWorkspace = [NSWorkspace sharedWorkspace];
- [[sharedWorkspace notificationCenter] addObserver:self selector:@selector(scanOpticalMedia:) name:NSWorkspaceDidMountNotification object:nil];
- [[sharedWorkspace notificationCenter] addObserver:self selector:@selector(scanOpticalMedia:) name:NSWorkspaceDidUnmountNotification object:nil];
+
+ [[sharedWorkspace notificationCenter] addObserver:self selector:@selector(scanOpticalMedia:) name:NSWorkspaceDidMountNotification object:nil];
+ [[sharedWorkspace notificationCenter] addObserver:self selector:@selector(scanOpticalMedia:) name:NSWorkspaceDidUnmountNotification object:nil];
[self performSelector:@selector(scanOpticalMedia:) withObject:nil afterDelay:2.0];
[self performSelector:@selector(qtkChanged:) withObject:nil afterDelay:2.5];
- (IBAction)qtkChanged:(id)sender
{
- NSInteger i_selectedDevice = [o_qtk_device_pop indexOfSelectedItem];
- if (i_selectedDevice >= ([qtkvideoDevices count] - 1))
- {
- NSValue *sizes = [[[[qtkvideoDevices objectAtIndex:i_selectedDevice] formatDescriptions] objectAtIndex: 0] attributeForKey: QTFormatDescriptionVideoEncodedPixelsSizeAttribute];
-
- [o_capture_width_fld setIntValue: [sizes sizeValue].width];
- [o_capture_height_fld setIntValue: [sizes sizeValue].height];
- [o_capture_width_stp setIntValue: [o_capture_width_fld intValue]];
- [o_capture_height_stp setIntValue: [o_capture_height_fld intValue]];
- qtk_currdevice_uid = [[(QTCaptureDevice *)[qtkvideoDevices objectAtIndex:i_selectedDevice] uniqueID]
- stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
- [self setMRL:[NSString stringWithFormat:@"qtcapture://%@", qtk_currdevice_uid]];
- }
+ NSInteger i_selectedDevice = [o_qtk_device_pop indexOfSelectedItem];
+
+ if (i_selectedDevice >= ([qtkvideoDevices count] - 1))
+ {
+ NSValue *sizes = [[[[qtkvideoDevices objectAtIndex:i_selectedDevice] formatDescriptions] objectAtIndex: 0] attributeForKey: QTFormatDescriptionVideoEncodedPixelsSizeAttribute];
+ [o_capture_width_fld setIntValue: [sizes sizeValue].width];
+ [o_capture_height_fld setIntValue: [sizes sizeValue].height];
+ [o_capture_width_stp setIntValue: [o_capture_width_fld intValue]];
+ [o_capture_height_stp setIntValue: [o_capture_height_fld intValue]];
+ qtk_currdevice_uid = [[(QTCaptureDevice *)[qtkvideoDevices objectAtIndex:i_selectedDevice] uniqueID] stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]];
+
+ [self setMRL:[NSString stringWithFormat:@"qtcapture://%@", qtk_currdevice_uid]];
+ }
}
- (void)tabView:(NSTabView *)o_tv didSelectTabViewItem:(NSTabViewItem *)o_tvi
GetVolParmsInfoBuffer volumeParms;
err = FSGetVolumeParms( actualVolume, &volumeParms, sizeof(volumeParms) );
- CFMutableDictionaryRef matchingDict;
- io_service_t service;
+ CFMutableDictionaryRef matchingDict;
+ io_service_t service;
matchingDict = IOBSDNameMatching(kIOMasterPortDefault, 0, volumeParms.vMDeviceID);
service = IOServiceGetMatchingService(kIOMasterPortDefault, matchingDict);
return;
unsigned int index = [n_index intValue];
- id o_currentOpticalDevice = [o_opticalDevices objectAtIndex: index];
+
+id o_currentOpticalDevice = [o_opticalDevices objectAtIndex: index];
char *diskType = [self getVolumeTypeFromMountPath:o_currentOpticalDevice];
if (diskType == kVLCMediaDVD || diskType == kVLCMediaVideoTSFolder)
if( [[[o_net_mode selectedCell] title] isEqualToString: _NS("Unicast")] )
{
int i_port = [o_net_udp_port intValue];
-
+
if( [[o_net_udp_protocol_mat selectedCell] tag] == 0 )
o_mrl_string = [NSString stringWithString: @"udp://"];
else
{
NSString *o_addr = [o_net_udpm_addr stringValue];
int i_port = [o_net_udpm_port intValue];
-
+
if( [[o_net_udp_protocol_mat selectedCell] tag] == 0 )
o_mrl_string = [NSString stringWithFormat: @"udp://@%@", o_addr];
else
[NSApp endSheet: o_net_udp_panel];
}
}
-
+
- (void)openFile
{
NSOpenPanel *o_open_panel = [NSOpenPanel openPanel];
msg_Dbg( VLCIntf, "eyetv was launched, no device yet" );
setEyeTVUnconnected;
}
-}
+}
/* little helper method, since this code needs to be run by multiple objects */
- (void)setupChannelInfo
[o_file_sub_sheet orderOut:sender];
[NSApp endSheet: o_file_sub_sheet];
}
-
+
- (IBAction)subFileBrowse:(id)sender
{
NSOpenPanel *o_open_panel = [NSOpenPanel openPanel];
[o_outline_view setAllowsEmptySelection: NO];
[o_outline_view expandItem: [o_outline_view itemAtRow:0]];
- [o_outline_view_other setTarget: self];
+ [o_outline_view_other setTarget: self];
[o_outline_view_other setDelegate: self];
[o_outline_view_other setDataSource: self];
[o_outline_view_other setAllowsEmptySelection: NO];
[[o_tc_author headerCell] setStringValue:_NS("Author")];
[[o_tc_duration headerCell] setStringValue:_NS("Duration")];
- [[o_tc_name_other headerCell] setStringValue:_NS("Name")];
+ [[o_tc_name_other headerCell] setStringValue:_NS("Name")];
[[o_tc_author_other headerCell] setStringValue:_NS("Author")];
[[o_tc_duration_other headerCell] setStringValue:_NS("Duration")];
}
- (void)swapPlaylists:(id)newList
{
- if(newList != o_outline_view)
- {
- id o_outline_view_temp = o_outline_view;
- id o_tc_author_temp = o_tc_author;
- id o_tc_duration_temp = o_tc_duration;
- id o_tc_name_temp = o_tc_name;
- o_outline_view = o_outline_view_other;
- o_tc_author = o_tc_author_other;
- o_tc_duration = o_tc_duration_other;
- o_tc_name = o_tc_name_other;
- o_outline_view_other = o_outline_view_temp;
- o_tc_author_other = o_tc_author_temp;
- o_tc_duration_other = o_tc_duration_temp;
- o_tc_name_other = o_tc_name_temp;
- }
+ if(newList != o_outline_view)
+ {
+ id o_outline_view_temp = o_outline_view;
+ id o_tc_author_temp = o_tc_author;
+ id o_tc_duration_temp = o_tc_duration;
+ id o_tc_name_temp = o_tc_name;
+ o_outline_view = o_outline_view_other;
+ o_tc_author = o_tc_author_other;
+ o_tc_duration = o_tc_duration_other;
+ o_tc_name = o_tc_name_other;
+ o_outline_view_other = o_outline_view_temp;
+ o_tc_author_other = o_tc_author_temp;
+ o_tc_duration_other = o_tc_duration_temp;
+ o_tc_name_other = o_tc_name_temp;
+ }
}
- (NSOutlineView *)outlineView
- (void)swapPlaylists:(id)newList
{
- if(newList != o_outline_view)
- {
- id o_search_field_temp = o_search_field;
- o_search_field = o_search_field_other;
- o_search_field_other = o_search_field_temp;
- [super swapPlaylists:newList];
- [self playlistUpdated];
- }
+ if(newList != o_outline_view)
+ {
+ id o_search_field_temp = o_search_field;
+ o_search_field = o_search_field_other;
+ o_search_field_other = o_search_field_temp;
+ [super swapPlaylists:newList];
+ [self playlistUpdated];
+ }
}
- (void)playlistUpdated
}
if( i_row > -1 )
{
- [o_outline_view selectRowIndexes:[NSIndexSet indexSetWithIndex:i_row] byExtendingSelection:NO];
+ [o_outline_view selectRowIndexes:[NSIndexSet indexSetWithIndex:i_row] byExtendingSelection:NO];
[o_outline_view scrollRowToVisible: i_row];
}
}
else
{
_o_sharedInstance = [super init];
-
+
if( _o_sharedInstance != nil )
{
p_item = NULL;
[o_input_bitrate_txt setStringValue: [NSString stringWithFormat:@"%6.0f kb/s", (float)0]];
[o_demux_bytes_txt setStringValue: [NSString stringWithFormat:@"%8.0f KiB", (float)0]];
[o_demux_bitrate_txt setStringValue: [NSString stringWithFormat:@"%6.0f kb/s", (float)0]];
-
+
//Initializing Video Variables
[o_video_decoded_txt setIntValue:0];
[o_displayed_txt setIntValue:0];
[o_prefs_view setHasVerticalScroller: YES];
[o_prefs_view setDrawsBackground: NO];
[o_prefs_view setDocumentView: o_empty_view];
- [o_tree selectRowIndexes: [NSIndexSet indexSetWithIndex: 0] byExtendingSelection: NO];
+ [o_tree selectRowIndexes: [NSIndexSet indexSetWithIndex: 0] byExtendingSelection: NO];
}
- (void)setTitle: (NSString *) o_title_name
}
}
}
-
+
if( module_is_main( p_module) && CONFIG_ITEM(configType) )
{
if( categoryItem && [self isSubCategoryGeneral:lastsubcat] )
}
assert(view);
-
+
int i_lastItem = 0;
int i_yPos = -2;
int i_max_label = 0;
int i_index;
i_view_type = CONFIG_ITEM_STRING_LIST;
- o_textfieldTooltip = [[VLCMain sharedInstance] wrapString: _NS((char *)p_item->psz_longtext) toWidth: PREFS_WRAP];
+ o_textfieldTooltip = [[VLCMain sharedInstance] wrapString: _NS((char *)p_item->psz_longtext) toWidth: PREFS_WRAP];
/* add the label */
if( p_item->psz_text )
{
i_view_type = CONFIG_ITEM_RANGED_INTEGER;
- o_tooltip = [[VLCMain sharedInstance] wrapString: _NS((char *)p_item->psz_longtext) toWidth: PREFS_WRAP];
+ o_tooltip = [[VLCMain sharedInstance] wrapString: _NS((char *)p_item->psz_longtext) toWidth: PREFS_WRAP];
/* add the label */
if( p_item->psz_text )
if( _p_item->i_type == CONFIG_ITEM_MODULE_LIST )
//TODO....
return nil;
-
+
//Fill our array to know how may items we have...
module_t *p_parser, **p_list;
size_t i_module_index;
NSRect mainFrame = [o_parent_view frame];
NSString *o_labelString, *o_textfieldString, *o_tooltip;
-
+
o_modulearray = [[NSMutableArray alloc] initWithCapacity:10];
/* build a list of available modules */
p_list = module_list_get( NULL );
{
int i;
p_parser = p_list[i_module_index];
-
+
if( module_is_main( p_parser ) )
continue;
-
+
unsigned int confsize;
module_config_t *p_configlist = module_config_get( p_parser, &confsize );
-
+
for ( i = 0; i < confsize; i++ )
{
unsigned int unused;
module_config_t *p_config = &p_configlist[i];
NSString *o_modulelongname, *o_modulename;
NSNumber *o_moduleenabled = nil;
-
+
/* Hack: required subcategory is stored in i_min */
if( p_config->i_type == CONFIG_SUBCATEGORY &&
p_config->value.i == _p_item->min.i )
module_get_name( p_parser, TRUE )];
o_modulename = [NSString stringWithUTF8String:
module_get_object( p_parser )];
-
+
if( _p_item->value.psz &&
strstr( _p_item->value.psz, module_get_object( p_parser ) ) )
o_moduleenabled = [NSNumber numberWithBool:YES];
else
o_moduleenabled = [NSNumber numberWithBool:NO];
-
+
[o_modulearray addObject:[NSMutableArray
arrayWithObjects: o_modulename, o_modulelongname,
o_moduleenabled, nil]];
module_config_free( p_configlist );
}
module_list_free( p_list );
-
+
mainFrame.size.height = 30 + 20 * [o_modulearray count];
mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN;
mainFrame.origin.x = LEFTMARGIN;
if( [super initWithFrame: mainFrame item: _p_item] != nil )
{
i_view_type = CONFIG_ITEM_MODULE_LIST;
-
+
o_tooltip = [[VLCMain sharedInstance] wrapString: _NS((char *)p_item->psz_longtext) toWidth: PREFS_WRAP];
-
+
/* add the label */
if( p_item->psz_text )
o_labelString = _NS((char *)p_item->psz_text);
ADD_LABEL( o_label, mainFrame, 0, -3, o_labelString, o_tooltip )
[o_label setAutoresizingMask:NSViewNotSizable ];
[self addSubview: o_label];
-
+
/* build the textfield */
if( p_item->value.psz )
o_textfieldString = _NS((char *)p_item->value.psz);
[o_label frame].size.width - 2, o_tooltip, o_textfieldString )
[o_textfield setAutoresizingMask:NSViewWidthSizable ];
[self addSubview: o_textfield];
-
-
+
+
{
NSRect s_rc = mainFrame;
s_rc.size.height = mainFrame.size.height - 30;
[o_scrollview setDrawsBackground: NO];
[o_scrollview setBorderType: NSBezelBorder];
[o_scrollview setAutohidesScrollers:YES];
-
+
NSTableView *o_tableview;
o_tableview = [[NSTableView alloc] initWithFrame : s_rc];
[o_tableview setUsesAlternatingRowBackgroundColors:YES];
/* TODO: find a good way to fix the row height and text size*/
/* FIXME: support for multiple selection... */
// [o_tableview setAllowsMultipleSelection:YES];
-
+
NSCell *o_headerCell = [[NSCell alloc] initTextCell:@"Enabled"];
NSCell *o_dataCell = [[NSButtonCell alloc] init];
[(NSButtonCell*)o_dataCell setButtonType:NSSwitchButton];
[o_tableColumn setDataCell: o_dataCell];
[o_tableColumn setWidth:17];
[o_tableview addTableColumn: o_tableColumn];
-
+
o_headerCell = [[NSCell alloc] initTextCell:@"Module Name"];
o_dataCell = [[NSTextFieldCell alloc] init];
[o_dataCell setFont:[NSFont systemFontOfSize:12]];
[o_tableview addTableColumn: o_tableColumn];
[o_tableview registerForDraggedTypes:[NSArray arrayWithObjects:
@"VLC media player module", nil]];
-
+
[o_tableview setDataSource:self];
[o_tableview setTarget: self];
[o_tableview setAction: @selector(tableChanged:)];
IBOutlet id o_intf_art_txt;
IBOutlet id o_intf_embedded_ckb;
IBOutlet id o_intf_fspanel_ckb;
- IBOutlet id o_intf_appleremote_ckb;
- IBOutlet id o_intf_mediakeys_ckb;
+
+IBOutlet id o_intf_appleremote_ckb;
+
+IBOutlet id o_intf_mediakeys_ckb;
IBOutlet id o_intf_lang_pop;
IBOutlet id o_intf_lang_txt;
IBOutlet id o_intf_network_box;
[o_intf_fspanel_ckb setTitle: _NS("Show Fullscreen Controller")];
[o_intf_lang_txt setStringValue: _NS("Language")];
[o_intf_network_box setTitle: _NS("Privacy / Network Interaction")];
- [o_intf_appleremote_ckb setTitle: _NS("Control playback with the Apple Remote")];
- [o_intf_mediakeys_ckb setTitle: _NS("Control playback with media keys")];
+
+ [o_intf_appleremote_ckb setTitle: _NS("Control playback with the Apple Remote")];
+
+ [o_intf_mediakeys_ckb setTitle: _NS("Control playback with media keys")];
[o_intf_update_ckb setTitle: _NS("Automatically check for updates")];
[o_intf_last_update_lbl setStringValue: @""];
[o_intf_enableGrowl_ckb setTitle: _NS("Enable Growl notifications (on playlist item change)")];
[self setupButton: o_intf_fspanel_ckb forBoolValue: "macosx-fspanel"];
[self setupButton: o_intf_nativefullscreen_ckb forBoolValue: "macosx-nativefullscreenmode"];
[self setupButton: o_intf_embedded_ckb forBoolValue: "embedded-video"];
- [self setupButton: o_intf_appleremote_ckb forBoolValue: "macosx-appleremote"];
- [self setupButton: o_intf_mediakeys_ckb forBoolValue: "macosx-mediakeys"];
+
+[self setupButton: o_intf_appleremote_ckb forBoolValue: "macosx-appleremote"];
+
+[self setupButton: o_intf_mediakeys_ckb forBoolValue: "macosx-mediakeys"];
if( [[SUUpdater sharedUpdater] lastUpdateCheckDate] != NULL )
[o_intf_last_update_lbl setStringValue: [NSString stringWithFormat: _NS("Last check on: %@"), [[[SUUpdater sharedUpdater] lastUpdateCheckDate] descriptionWithLocale: [[NSUserDefaults standardUserDefaults] dictionaryRepresentation]]]];
else
assert( p_main );
unsigned confsize;
module_config_t *p_config;
-
+
p_config = module_config_get (p_main, &confsize);
-
+
for (size_t i = 0; i < confsize; i++)
{
module_config_t *p_item = p_config + i;
config_PutInt( p_intf, "macosx-fspanel", [o_intf_fspanel_ckb state] );
config_PutInt( p_intf, "embedded-video", [o_intf_embedded_ckb state] );
- config_PutInt( p_intf, "macosx-appleremote", [o_intf_appleremote_ckb state] );
+
+ config_PutInt( p_intf, "macosx-appleremote", [o_intf_appleremote_ckb state] );
config_PutInt( p_intf, "macosx-mediakeys", [o_intf_mediakeys_ckb state] );
config_PutInt( p_intf, "macosx-interfacestyle", [o_intf_style_dark_bcell state] );
config_PutInt( p_intf, "macosx-nativefullscreenmode", [o_intf_nativefullscreen_ckb state] );
}
}
- /* activate stuff without restart */
- if( [o_intf_appleremote_ckb state] == YES )
- [[[VLCMain sharedInstance] appleRemoteController] startListening: [VLCMain sharedInstance]];
- else
- [[[VLCMain sharedInstance] appleRemoteController] stopListening: [VLCMain sharedInstance]];
+ /* activate stuff without restart */
+ if( [o_intf_appleremote_ckb state] == YES )
+ [[[VLCMain sharedInstance] appleRemoteController] startListening: [VLCMain sharedInstance]];
+ else
+ [[[VLCMain sharedInstance] appleRemoteController] stopListening: [VLCMain sharedInstance]];
b_intfSettingChanged = NO;
}
[o_hotkeys_change_taken_lbl setStringValue: [NSString stringWithFormat:
_NS("This combination is already taken by \"%@\"."),
[o_hotkeyDescriptions objectAtIndex: i_returnValue2]]];
-
else
[o_hotkeys_change_taken_lbl setStringValue: @""];
{
NSMutableString *tempString = [[[NSMutableString alloc] init] autorelease];
NSString *keyString = [o_theEvent characters];
- unichar key = [keyString characterAtIndex:0];
+
+ unichar key = [keyString characterAtIndex:0];
/* modifiers */
if( [o_theEvent modifierFlags] & NSControlKeyMask )
[_okayButton setAction:@selector(buttonAction:)];
[_okayButton setKeyEquivalent:@"\r"] ; // enter key
[ourContentView addSubview:_okayButton];
-
+
s_rc.origin.x = 94;
s_rc.origin.y = 170;
s_rc.size.height = 14;
[_passwordField setEditable:YES];
[_passwordField setImportsGraphics:NO];
[ourContentView addSubview:_passwordField];
-
+
s_rc.origin.x = 94;
s_rc.origin.y = 238;
s_rc.size.height = 17;
p_vout->pf_unlock = cocoaglvoutviewUnlock;
}
#else
- /* Let's use the VLCOpenGLVoutView.m class */
- p_vout->pf_init = cocoaglvoutviewInit;
- p_vout->pf_end = cocoaglvoutviewEnd;
- p_vout->pf_manage = cocoaglvoutviewManage;
- p_vout->pf_control= cocoaglvoutviewControl;
- p_vout->pf_swap = cocoaglvoutviewSwap;
- p_vout->pf_lock = cocoaglvoutviewLock;
- p_vout->pf_unlock = cocoaglvoutviewUnlock;
+ /* Let's use the VLCOpenGLVoutView.m class */
+ p_vout->pf_init = cocoaglvoutviewInit;
+ p_vout->pf_end = cocoaglvoutviewEnd;
+ p_vout->pf_manage = cocoaglvoutviewManage;
+ p_vout->pf_control= cocoaglvoutviewControl;
+ p_vout->pf_swap = cocoaglvoutviewSwap;
+ p_vout->pf_lock = cocoaglvoutviewLock;
+ p_vout->pf_unlock = cocoaglvoutviewUnlock;
#endif
p_vout->p_sys->b_got_frame = false;
const vlc_fourcc_t *subpicture_chromas;
video_format_t fmt = vd->fmt;
- sys->vgl = vout_display_opengl_New(&vd->fmt, &subpicture_chromas, &sys->gl);
- if (!sys->vgl)
+ sys->vgl = vout_display_opengl_New(&vd->fmt, &subpicture_chromas, &sys->gl);
+ if (!sys->vgl)
{
sys->gl.sys = NULL;
goto error;
[sys->glView setVoutFlushing:NO];
picture_Release (pic);
sys->has_first_frame = true;
- (void)subpicture;
+
+ (void)subpicture;
}
static int Control (vout_display_t *vd, int query, va_list ap)
NSWindow *window = [self window];
// Remove flashes with splitter view.
- if ([window respondsToSelector:@selector(disableScreenUpdatesUntilFlush)])
- [window disableScreenUpdatesUntilFlush];
+ if ([window respondsToSelector:@selector(disableScreenUpdatesUntilFlush)])
+ [window disableScreenUpdatesUntilFlush];
[super renewGState];
}