Commit ef6a3f69 authored by Jérome Decoodt's avatar Jérome Decoodt

- added macosx version detection at runtime with...

- added macosx version detection at runtime with /System/Library/CoreServices/SystemVersion.plist file
- wrapped code
parent a0ff74f7
...@@ -107,9 +107,6 @@ static VLCPrefs *_o_sharedMainInstance = nil; ...@@ -107,9 +107,6 @@ static VLCPrefs *_o_sharedMainInstance = nil;
/* load our nib (if not already loaded) */ /* load our nib (if not already loaded) */
[NSBundle loadNibNamed:@"Preferences" owner:self]; [NSBundle loadNibNamed:@"Preferences" owner:self];
/* Show View for the currently select treeitem */
/* [self showViewForID: [[o_tree itemAtRow:[o_tree selectedRow]] getObjectID]
andName: [[o_tree itemAtRow:[o_tree selectedRow]] getName]]; */
[o_prefs_window center]; [o_prefs_window center];
[o_prefs_window makeKeyAndOrderFront:self]; [o_prefs_window makeKeyAndOrderFront:self];
} }
...@@ -138,19 +135,22 @@ static VLCPrefs *_o_sharedMainInstance = nil; ...@@ -138,19 +135,22 @@ static VLCPrefs *_o_sharedMainInstance = nil;
- (IBAction)resetAll: (id)sender - (IBAction)resetAll: (id)sender
{ {
NSBeginInformationalAlertSheet(_NS("Reset Preferences"), _NS("Cancel"), _NS("Continue"), NSBeginInformationalAlertSheet(_NS("Reset Preferences"), _NS("Cancel"),
nil, o_prefs_window, self, @selector(sheetDidEnd: returnCode: contextInfo:), NULL, nil, _NS("Continue"), nil, o_prefs_window, self,
@selector(sheetDidEnd: returnCode: contextInfo:), NULL, nil,
_NS("Beware this will reset your VLC media player preferences.\n" _NS("Beware this will reset your VLC media player preferences.\n"
"Are you sure you want to continue?") ); "Are you sure you want to continue?") );
} }
- (void)sheetDidEnd:(NSWindow *)o_sheet returnCode:(int)i_return contextInfo:(void *)o_context - (void)sheetDidEnd:(NSWindow *)o_sheet returnCode:(int)i_return
contextInfo:(void *)o_context
{ {
if( i_return == NSAlertAlternateReturn ) if( i_return == NSAlertAlternateReturn )
{ {
config_ResetAll( p_intf ); config_ResetAll( p_intf );
[[o_tree itemAtRow:[o_tree selectedRow]] showView:o_prefs_view advancedView: [[o_tree itemAtRow:[o_tree selectedRow]]
([o_advanced_ckb state] == NSOnState)?VLC_TRUE:VLC_FALSE]; showView:o_prefs_view advancedView:
( [o_advanced_ckb state] == NSOnState ) ? VLC_TRUE : VLC_FALSE];
} }
} }
...@@ -160,7 +160,7 @@ static VLCPrefs *_o_sharedMainInstance = nil; ...@@ -160,7 +160,7 @@ static VLCPrefs *_o_sharedMainInstance = nil;
[o_advanced_ckb setState: b_advanced]; [o_advanced_ckb setState: b_advanced];
/* refresh the view of the current treeitem */ /* refresh the view of the current treeitem */
[[o_tree itemAtRow:[o_tree selectedRow]] showView:o_prefs_view advancedView: [[o_tree itemAtRow:[o_tree selectedRow]] showView:o_prefs_view advancedView:
([o_advanced_ckb state] == NSOnState)?VLC_TRUE:VLC_FALSE]; ( [o_advanced_ckb state] == NSOnState ) ? VLC_TRUE : VLC_FALSE];
} }
- (void)loadConfigTree - (void)loadConfigTree
...@@ -174,8 +174,9 @@ static VLCPrefs *_o_sharedMainInstance = nil; ...@@ -174,8 +174,9 @@ static VLCPrefs *_o_sharedMainInstance = nil;
/* update the document view to the view of the selected tree item */ /* update the document view to the view of the selected tree item */
- (void)outlineViewSelectionDidChange:(NSNotification *)o_notification - (void)outlineViewSelectionDidChange:(NSNotification *)o_notification
{ {
[[o_tree itemAtRow:[o_tree selectedRow]] showView: o_prefs_view advancedView: [[o_tree itemAtRow:[o_tree selectedRow]] showView: o_prefs_view
([o_advanced_ckb state] == NSOnState)?VLC_TRUE:VLC_FALSE]; advancedView:( [o_advanced_ckb state] == NSOnState ) ?
VLC_TRUE : VLC_FALSE];
} }
@end @end
...@@ -183,18 +184,24 @@ static VLCPrefs *_o_sharedMainInstance = nil; ...@@ -183,18 +184,24 @@ static VLCPrefs *_o_sharedMainInstance = nil;
@implementation VLCPrefs (NSTableDataSource) @implementation VLCPrefs (NSTableDataSource)
- (int)outlineView:(NSOutlineView *)outlineView numberOfChildrenOfItem:(id)item { - (int)outlineView:(NSOutlineView *)outlineView numberOfChildrenOfItem:(id)item {
return (item == nil) ? [[VLCTreeItem rootItem] numberOfChildren] : [item numberOfChildren]; return (item == nil) ? [[VLCTreeItem rootItem] numberOfChildren] :
[item numberOfChildren];
} }
- (BOOL)outlineView:(NSOutlineView *)outlineView isItemExpandable:(id)item { - (BOOL)outlineView:(NSOutlineView *)outlineView isItemExpandable:(id)item
return (item == nil) ? YES : (([item numberOfChildren] != -1) && ([item numberOfChildren] != 0)); {
return (item == nil) ? YES : ( ([item numberOfChildren] != -1) &&
([item numberOfChildren] != 0));
} }
- (id)outlineView:(NSOutlineView *)outlineView child:(int)index ofItem:(id)item { - (id)outlineView:(NSOutlineView *)outlineView child:(int)index ofItem:(id)item {
return (item == nil) ? [[VLCTreeItem rootItem] childAtIndex:index] : [item childAtIndex:index]; return (item == nil) ? [[VLCTreeItem rootItem] childAtIndex:index] :
[item childAtIndex:index];
} }
- (id)outlineView:(NSOutlineView *)outlineView objectValueForTableColumn:(NSTableColumn *)tableColumn byItem:(id)item { - (id)outlineView:(NSOutlineView *)outlineView
objectValueForTableColumn:(NSTableColumn *)tableColumn byItem:(id)item
{
return (item == nil) ? @"" : (id)[item getName]; return (item == nil) ? @"" : (id)[item getName];
} }
...@@ -206,7 +213,10 @@ static VLCTreeItem *o_root_item = nil; ...@@ -206,7 +213,10 @@ static VLCTreeItem *o_root_item = nil;
#define IsALeafNode ((id)-1) #define IsALeafNode ((id)-1)
- (id)initWithName: (NSString *)o_item_name ID: (int)i_id parent:(VLCTreeItem *)o_parent_item children:(NSMutableArray *)o_children_array whithCategory: (int) i_category - (id)initWithName: (NSString *)o_item_name ID: (int)i_id
parent:(VLCTreeItem *)o_parent_item
children:(NSMutableArray *)o_children_array
whithCategory: (int) i_category
{ {
self = [super init]; self = [super init];
...@@ -222,8 +232,12 @@ static VLCTreeItem *o_root_item = nil; ...@@ -222,8 +232,12 @@ static VLCTreeItem *o_root_item = nil;
return( self ); return( self );
} }
+ (VLCTreeItem *)rootItem { + (VLCTreeItem *)rootItem
if (o_root_item == nil) o_root_item = [[VLCTreeItem alloc] initWithName:@"main" ID: 0 parent:nil children:[[NSMutableArray alloc] initWithCapacity:10] whithCategory: -1]; {
if (o_root_item == nil)
o_root_item = [[VLCTreeItem alloc] initWithName:@"main" ID:0
parent:nil children:[[NSMutableArray alloc] initWithCapacity:10]
whithCategory: -1];
return o_root_item; return o_root_item;
} }
...@@ -265,7 +279,8 @@ static VLCTreeItem *o_root_item = nil; ...@@ -265,7 +279,8 @@ static VLCTreeItem *o_root_item = nil;
} }
if( p_module == NULL ) if( p_module == NULL )
{ {
msg_Err( p_intf, "could not find the main module in our preferences" ); msg_Err( p_intf,
"could not find the main module in our preferences" );
return nil; return nil;
} }
if( i_index < p_list->i_count ) if( i_index < p_list->i_count )
...@@ -282,17 +297,30 @@ static VLCTreeItem *o_root_item = nil; ...@@ -282,17 +297,30 @@ static VLCTreeItem *o_root_item = nil;
switch( p_item->i_type ) switch( p_item->i_type )
{ {
case CONFIG_CATEGORY: case CONFIG_CATEGORY:
o_child_name = [[VLCMain sharedInstance] localizedString: config_CategoryNameGet(p_item->i_value ) ]; o_child_name = [[VLCMain sharedInstance]
localizedString: config_CategoryNameGet(p_item->i_value ) ];
p_last_category = [VLCTreeItem alloc]; p_last_category = [VLCTreeItem alloc];
[o_children addObject:[p_last_category initWithName: o_child_name [o_children addObject:[p_last_category
ID: p_item->i_value parent:self children:[[NSMutableArray alloc] initWithCapacity:10] whithCategory: p_item - p_module->p_config]]; initWithName: o_child_name
ID: p_item->i_value
parent:self
children:[[NSMutableArray alloc]
initWithCapacity:10]
whithCategory: p_item - p_module->p_config]];
break; break;
case CONFIG_SUBCATEGORY: case CONFIG_SUBCATEGORY:
o_child_name = [[VLCMain sharedInstance] localizedString: config_CategoryNameGet(p_item->i_value ) ]; o_child_name = [[VLCMain sharedInstance]
localizedString: config_CategoryNameGet(p_item->i_value ) ];
if( p_item->i_value != SUBCAT_VIDEO_GENERAL && if( p_item->i_value != SUBCAT_VIDEO_GENERAL &&
p_item->i_value != SUBCAT_AUDIO_GENERAL ) p_item->i_value != SUBCAT_AUDIO_GENERAL )
[p_last_category->o_children addObject:[[VLCTreeItem alloc] initWithName: o_child_name [p_last_category->o_children
ID: p_item->i_value parent:p_last_category children:[[NSMutableArray alloc] initWithCapacity:10] whithCategory: p_item - p_module->p_config]]; addObject:[[VLCTreeItem alloc]
initWithName: o_child_name
ID: p_item->i_value
parent:p_last_category
children:[[NSMutableArray alloc]
initWithCapacity:10]
whithCategory: p_item - p_module->p_config]];
break; break;
default: default:
break; break;
...@@ -310,8 +338,8 @@ static VLCTreeItem *o_root_item = nil; ...@@ -310,8 +338,8 @@ static VLCTreeItem *o_root_item = nil;
if( !strcmp( p_module->psz_object_name, "main" ) ) if( !strcmp( p_module->psz_object_name, "main" ) )
continue; continue;
/* Exclude empty plugins (submodules don't have config options, they /* Exclude empty plugins (submodules don't have config */
* are stored in the parent module) */ /* options, they are stored in the parent module) */
if( p_module->b_submodule ) if( p_module->b_submodule )
continue; continue;
else else
...@@ -324,19 +352,14 @@ static VLCTreeItem *o_root_item = nil; ...@@ -324,19 +352,14 @@ static VLCTreeItem *o_root_item = nil;
do do
{ {
if( p_item->i_type == CONFIG_CATEGORY ) if( p_item->i_type == CONFIG_CATEGORY )
{
i_category = p_item->i_value; i_category = p_item->i_value;
}
else if( p_item->i_type == CONFIG_SUBCATEGORY ) else if( p_item->i_type == CONFIG_SUBCATEGORY )
{
i_subcategory = p_item->i_value; i_subcategory = p_item->i_value;
}
if( p_item->i_type & CONFIG_ITEM ) if( p_item->i_type & CONFIG_ITEM )
i_options ++; i_options ++;
if( i_options > 0 && i_category >= 0 && i_subcategory >= 0 ) if( i_options > 0 && i_category >= 0 && i_subcategory >= 0 )
{
break; break;
}
} while( p_item->i_type != CONFIG_HINT_END && p_item++ ); } while( p_item->i_type != CONFIG_HINT_END && p_item++ );
if( !i_options ) continue; if( !i_options ) continue;
...@@ -362,7 +385,8 @@ static VLCTreeItem *o_root_item = nil; ...@@ -362,7 +385,8 @@ static VLCTreeItem *o_root_item = nil;
cookie = -1; cookie = -1;
for (i = 0 ; i < [p_category_item->o_children count] ; i++) for (i = 0 ; i < [p_category_item->o_children count] ; i++)
{ {
p_subcategory_item = [p_category_item->o_children objectAtIndex: i]; p_subcategory_item = [p_category_item->o_children
objectAtIndex: i];
if( p_subcategory_item->i_object_id == i_subcategory ) if( p_subcategory_item->i_object_id == i_subcategory )
{ {
b_found = VLC_TRUE; b_found = VLC_TRUE;
...@@ -372,10 +396,13 @@ static VLCTreeItem *o_root_item = nil; ...@@ -372,10 +396,13 @@ static VLCTreeItem *o_root_item = nil;
if( !b_found ) if( !b_found )
p_subcategory_item = p_category_item; p_subcategory_item = p_category_item;
[p_subcategory_item->o_children addObject:[[VLCTreeItem alloc] initWithName: [p_subcategory_item->o_children addObject:[[VLCTreeItem alloc]
[[VLCMain sharedInstance] localizedString: p_module->psz_object_name ] initWithName:[[VLCMain sharedInstance]
ID: p_module->i_object_id parent:p_subcategory_item children:IsALeafNode whithCategory: -1]]; localizedString: p_module->psz_object_name ]
ID: p_module->i_object_id
parent:p_subcategory_item
children:IsALeafNode
whithCategory: -1]];
} }
} }
vlc_list_release( p_list ); vlc_list_release( p_list );
...@@ -393,7 +420,8 @@ static VLCTreeItem *o_root_item = nil; ...@@ -393,7 +420,8 @@ static VLCTreeItem *o_root_item = nil;
return o_name; return o_name;
} }
- (VLCTreeItem *)childAtIndex:(int)i_index { - (VLCTreeItem *)childAtIndex:(int)i_index
{
return [[self children] objectAtIndex:i_index]; return [[self children] objectAtIndex:i_index];
} }
...@@ -432,7 +460,8 @@ static VLCTreeItem *o_root_item = nil; ...@@ -432,7 +460,8 @@ static VLCTreeItem *o_root_item = nil;
return( NO ); return( NO );
} }
- (NSView *)showView:(NSScrollView *)o_prefs_view advancedView:(vlc_bool_t) b_advanced - (NSView *)showView:(NSScrollView *)o_prefs_view
advancedView:(vlc_bool_t) b_advanced
{ {
fprintf( stderr, "[%s] showView\n", [o_name UTF8String] ); fprintf( stderr, "[%s] showView\n", [o_name UTF8String] );
if( o_view == nil ) if( o_view == nil )
...@@ -467,7 +496,7 @@ fprintf( stderr, "[%s] showView\n", [o_name UTF8String] ); ...@@ -467,7 +496,7 @@ fprintf( stderr, "[%s] showView\n", [o_name UTF8String] );
{ {
if( !p_item ) if( !p_item )
{ {
fprintf( stderr, "Something is going very bad... skipping null item\n" ); msg_Err( "null item found" );
break; break;
} }
switch(p_item->i_type) switch(p_item->i_type)
...@@ -535,8 +564,7 @@ fprintf( stderr, "CONFIG_ITEM_BOOL" ); ...@@ -535,8 +564,7 @@ fprintf( stderr, "CONFIG_ITEM_BOOL" );
break; break;
case CONFIG_ITEM_KEY: case CONFIG_ITEM_KEY:
fprintf( stderr, "CONFIG_ITEM_KEY" ); fprintf( stderr, "CONFIG_ITEM_KEY" );
#define MACOS_VERSION 4 if( MACOS_VERSION < 10.3 )
if( MACOS_VERSION < 3 )
i_widget = CONFIG_ITEM_KEY_BEFORE_10_3; i_widget = CONFIG_ITEM_KEY_BEFORE_10_3;
else else
i_widget = CONFIG_ITEM_KEY_AFTER_10_3; i_widget = CONFIG_ITEM_KEY_AFTER_10_3;
...@@ -551,7 +579,8 @@ fprintf( stderr, "***UNKNOWN***" ); ...@@ -551,7 +579,8 @@ fprintf( stderr, "***UNKNOWN***" );
} }
if( i_widget != 0 ) if( i_widget != 0 )
{ {
i_yPos += [VLCConfigControl calcVerticalMargin:i_widget lastItem:i_lastItem]; i_yPos += [VLCConfigControl
calcVerticalMargin:i_widget lastItem:i_lastItem];
o_control = [VLCConfigControl newControl:p_item o_control = [VLCConfigControl newControl:p_item
withView:o_view withView:o_view
yOffset: i_yPos yOffset: i_yPos
...@@ -560,7 +589,8 @@ fprintf( stderr, "***UNKNOWN***" ); ...@@ -560,7 +589,8 @@ fprintf( stderr, "***UNKNOWN***" );
{ {
i_yPos += [o_control frame].size.height; i_yPos += [o_control frame].size.height;
i_lastItem = i_widget; i_lastItem = i_widget;
[o_control setAutoresizingMask: NSViewMaxYMargin | NSViewWidthSizable]; [o_control setAutoresizingMask: NSViewMaxYMargin |
NSViewWidthSizable];
[o_view addSubview: o_control]; [o_view addSubview: o_control];
} }
} }
...@@ -574,6 +604,9 @@ fprintf( stderr, "\n" ); ...@@ -574,6 +604,9 @@ fprintf( stderr, "\n" );
} }
else else
{ {
int i = 0;
int i_yPos = -2;
int i_lastItem = 0;
int i_index; int i_index;
p_list = vlc_list_find( p_intf, VLC_OBJECT_MODULE, FIND_ANYWHERE ); p_list = vlc_list_find( p_intf, VLC_OBJECT_MODULE, FIND_ANYWHERE );
if( !p_list ) return o_view; if( !p_list ) return o_view;
...@@ -589,24 +622,22 @@ fprintf( stderr, "\n" ); ...@@ -589,24 +622,22 @@ fprintf( stderr, "\n" );
} }
if( p_parser == NULL ) if( p_parser == NULL )
{ {
msg_Err( p_intf, "could not find the main module in our preferences" ); msg_Err( p_intf, "could not find the main module in our "
"preferences" );
return o_view; return o_view;
} }
p_item = (p_parser->p_config + i_object_category); p_item = (p_parser->p_config + i_object_category);
if( ( p_item->i_type == CONFIG_CATEGORY ) && if( ( p_item->i_type == CONFIG_CATEGORY ) &&
( ( p_item->i_value == CAT_AUDIO ) || ( p_item->i_value == CAT_VIDEO ) ) ) ( ( p_item->i_value == CAT_AUDIO ) ||
( p_item->i_value == CAT_VIDEO ) ) )
p_item++; p_item++;
int i = 0;
int i_yPos = -2;
int i_lastItem = 0;
do do
{ {
p_item++; p_item++;
if( !p_item ) if( !p_item )
{ {
fprintf( stderr, "Something is going very bad... skipping null item\n" ); msg_Err( "null item found" );
break; break;
} }
switch(p_item->i_type) switch(p_item->i_type)
...@@ -672,8 +703,7 @@ fprintf( stderr, "CONFIG_ITEM_BOOL" ); ...@@ -672,8 +703,7 @@ fprintf( stderr, "CONFIG_ITEM_BOOL" );
break; break;
case CONFIG_ITEM_KEY: case CONFIG_ITEM_KEY:
fprintf( stderr, "CONFIG_ITEM_KEY" ); fprintf( stderr, "CONFIG_ITEM_KEY" );
#define MACOS_VERSION 4 if( MACOS_VERSION < 10.3 )
if( MACOS_VERSION < 3 )
i_widget = CONFIG_ITEM_KEY_BEFORE_10_3; i_widget = CONFIG_ITEM_KEY_BEFORE_10_3;
else else
i_widget = CONFIG_ITEM_KEY_AFTER_10_3; i_widget = CONFIG_ITEM_KEY_AFTER_10_3;
...@@ -688,7 +718,8 @@ fprintf( stderr, "***UNKNOWN***" ); ...@@ -688,7 +718,8 @@ fprintf( stderr, "***UNKNOWN***" );
} }
if( i_widget != 0 ) if( i_widget != 0 )
{ {
i_yPos += [VLCConfigControl calcVerticalMargin:i_widget lastItem:i_lastItem]; i_yPos += [VLCConfigControl
calcVerticalMargin:i_widget lastItem:i_lastItem];
o_control = [VLCConfigControl newControl:p_item o_control = [VLCConfigControl newControl:p_item
withView:o_view withView:o_view
yOffset: i_yPos yOffset: i_yPos
...@@ -697,7 +728,8 @@ fprintf( stderr, "***UNKNOWN***" ); ...@@ -697,7 +728,8 @@ fprintf( stderr, "***UNKNOWN***" );
{ {
i_yPos += [o_control frame].size.height; i_yPos += [o_control frame].size.height;
i_lastItem = i_widget; i_lastItem = i_widget;
[o_control setAutoresizingMask: NSViewMaxYMargin | NSViewWidthSizable]; [o_control setAutoresizingMask: NSViewMaxYMargin |
NSViewWidthSizable];
[o_view addSubview: o_control]; [o_view addSubview: o_control];
} }
} }
...@@ -705,7 +737,8 @@ fprintf( stderr, "\n" ); ...@@ -705,7 +737,8 @@ fprintf( stderr, "\n" );
break; break;
} }
} }
} while ( ( p_item->i_type != CONFIG_HINT_END ) && ( p_item->i_type != CONFIG_SUBCATEGORY ) ); } while ( ( p_item->i_type != CONFIG_HINT_END ) &&
( p_item->i_type != CONFIG_SUBCATEGORY ) );
vlc_object_release( p_parser ); vlc_object_release( p_parser );
vlc_list_release( p_list ); vlc_list_release( p_list );
......
...@@ -25,6 +25,9 @@ ...@@ -25,6 +25,9 @@
#define CONFIG_ITEM_RANGED_INTEGER (CONFIG_ITEM_INTEGER + 1) #define CONFIG_ITEM_RANGED_INTEGER (CONFIG_ITEM_INTEGER + 1)
#define CONFIG_ITEM_KEY_BEFORE_10_3 (CONFIG_ITEM_KEY + 1) #define CONFIG_ITEM_KEY_BEFORE_10_3 (CONFIG_ITEM_KEY + 1)
#define CONFIG_ITEM_KEY_AFTER_10_3 (CONFIG_ITEM_KEY + 2) #define CONFIG_ITEM_KEY_AFTER_10_3 (CONFIG_ITEM_KEY + 2)
#define MACOS_VERSION [[[NSDictionary dictionaryWithContentsOfFile: \
@"/System/Library/CoreServices/SystemVersion.plist"] \
objectForKey: @"ProductVersion"] floatValue]
@interface VLCConfigControl : NSView @interface VLCConfigControl : NSView
{ {
......
...@@ -46,20 +46,19 @@ ...@@ -46,20 +46,19 @@
#define UP_ARROWHEAD "\xE2\x8C\x83" #define UP_ARROWHEAD "\xE2\x8C\x83"
#define PLACE_OF_INTEREST_SIGN "\xE2\x8C\x98" #define PLACE_OF_INTEREST_SIGN "\xE2\x8C\x98"
#define MACOS_VERSION 3
#define POPULATE_A_KEY( o_menu, string, value ) \ #define POPULATE_A_KEY( o_menu, string, value ) \
{ \ { \
NSMenuItem *o_mi; \ NSMenuItem *o_mi; \
/* Normal */ \ /* Normal */ \
o_mi = [[NSMenuItem alloc] initWithTitle:string action:nil keyEquivalent:@""]; \ o_mi = [[NSMenuItem alloc] initWithTitle:string \
action:nil keyEquivalent:@""]; \
[o_mi setKeyEquivalentModifierMask: \ [o_mi setKeyEquivalentModifierMask: \
0]; \ 0]; \
[o_mi setAlternate: NO]; \ [o_mi setAlternate: NO]; \
[o_mi setTag: \ [o_mi setTag: \
( value )]; \ ( value )]; \
[o_menu addItem: o_mi]; \ [o_menu addItem: o_mi]; \
if( MACOS_VERSION >= 3 ) \ if( MACOS_VERSION >= 10.3 ) \
{ \ { \
/* Ctrl */ \ /* Ctrl */ \
o_mi = [[NSMenuItem alloc] initWithTitle: \ o_mi = [[NSMenuItem alloc] initWithTitle: \
...@@ -119,7 +118,8 @@ if( MACOS_VERSION >= 3 ) \ ...@@ -119,7 +118,8 @@ if( MACOS_VERSION >= 3 ) \
NSControlKeyMask | NSAlternateKeyMask | NSShiftKeyMask]; \ NSControlKeyMask | NSAlternateKeyMask | NSShiftKeyMask]; \
[o_mi setAlternate: YES]; \ [o_mi setAlternate: YES]; \
[o_mi setTag: \ [o_mi setTag: \
(KEY_MODIFIER_CTRL | KEY_MODIFIER_ALT | KEY_MODIFIER_SHIFT) | ( value )]; \ (KEY_MODIFIER_CTRL | KEY_MODIFIER_ALT | KEY_MODIFIER_SHIFT) | \
( value )]; \
[o_menu addItem: o_mi]; \ [o_menu addItem: o_mi]; \
/* Ctrl+Alt+Apple */ \ /* Ctrl+Alt+Apple */ \
o_mi = [[NSMenuItem alloc] initWithTitle: \ o_mi = [[NSMenuItem alloc] initWithTitle: \
...@@ -131,7 +131,8 @@ if( MACOS_VERSION >= 3 ) \ ...@@ -131,7 +131,8 @@ if( MACOS_VERSION >= 3 ) \
NSControlKeyMask | NSAlternateKeyMask | NSCommandKeyMask]; \ NSControlKeyMask | NSAlternateKeyMask | NSCommandKeyMask]; \
[o_mi setAlternate: YES]; \ [o_mi setAlternate: YES]; \
[o_mi setTag: \ [o_mi setTag: \
(KEY_MODIFIER_CTRL | KEY_MODIFIER_ALT | KEY_MODIFIER_COMMAND) | ( value )]; \ (KEY_MODIFIER_CTRL | KEY_MODIFIER_ALT | KEY_MODIFIER_COMMAND) | \
( value )]; \
[o_menu addItem: o_mi]; \ [o_menu addItem: o_mi]; \
/* Ctrl+Shift+Apple */ \ /* Ctrl+Shift+Apple */ \
o_mi = [[NSMenuItem alloc] initWithTitle: \ o_mi = [[NSMenuItem alloc] initWithTitle: \
...@@ -143,19 +144,23 @@ if( MACOS_VERSION >= 3 ) \ ...@@ -143,19 +144,23 @@ if( MACOS_VERSION >= 3 ) \
NSControlKeyMask | NSShiftKeyMask | NSCommandKeyMask]; \ NSControlKeyMask | NSShiftKeyMask | NSCommandKeyMask]; \
[o_mi setAlternate: YES]; \ [o_mi setAlternate: YES]; \
[o_mi setTag: \ [o_mi setTag: \
(KEY_MODIFIER_CTRL | KEY_MODIFIER_SHIFT | KEY_MODIFIER_COMMAND) | ( value )]; \ (KEY_MODIFIER_CTRL | KEY_MODIFIER_SHIFT | KEY_MODIFIER_COMMAND) | \
( value )]; \
[o_menu addItem: o_mi]; \ [o_menu addItem: o_mi]; \
/* Ctrl+Alt+Shift+Apple */ \ /* Ctrl+Alt+Shift+Apple */ \
o_mi = [[NSMenuItem alloc] initWithTitle: \ o_mi = [[NSMenuItem alloc] initWithTitle: \
[[NSString stringWithUTF8String: \ [[NSString stringWithUTF8String: \
UP_ARROWHEAD OPTION_KEY UPWARDS_WHITE_ARROW PLACE_OF_INTEREST_SIGN \ UP_ARROWHEAD OPTION_KEY UPWARDS_WHITE_ARROW \
PLACE_OF_INTEREST_SIGN \
] stringByAppendingString: string] \ ] stringByAppendingString: string] \
action:nil keyEquivalent:@""]; \ action:nil keyEquivalent:@""]; \
[o_mi setKeyEquivalentModifierMask: \ [o_mi setKeyEquivalentModifierMask: \
NSControlKeyMask | NSAlternateKeyMask | NSShiftKeyMask | NSCommandKeyMask]; \ NSControlKeyMask | NSAlternateKeyMask | NSShiftKeyMask | \
NSCommandKeyMask]; \
[o_mi setAlternate: YES]; \ [o_mi setAlternate: YES]; \
[o_mi setTag: \ [o_mi setTag: \
(KEY_MODIFIER_CTRL | KEY_MODIFIER_ALT | KEY_MODIFIER_SHIFT | KEY_MODIFIER_COMMAND) | ( value )]; \ (KEY_MODIFIER_CTRL | KEY_MODIFIER_ALT | KEY_MODIFIER_SHIFT | \
KEY_MODIFIER_COMMAND) | ( value )]; \
[o_menu addItem: o_mi]; \ [o_menu addItem: o_mi]; \
/* Alt */ \ /* Alt */ \
o_mi = [[NSMenuItem alloc] initWithTitle: \ o_mi = [[NSMenuItem alloc] initWithTitle: \
...@@ -203,7 +208,8 @@ if( MACOS_VERSION >= 3 ) \ ...@@ -203,7 +208,8 @@ if( MACOS_VERSION >= 3 ) \
NSAlternateKeyMask | NSShiftKeyMask | NSCommandKeyMask]; \ NSAlternateKeyMask | NSShiftKeyMask | NSCommandKeyMask]; \
[o_mi setAlternate: YES]; \ [o_mi setAlternate: YES]; \
[o_mi setTag: \ [o_mi setTag: \
(KEY_MODIFIER_ALT | KEY_MODIFIER_SHIFT | KEY_MODIFIER_COMMAND) | ( value )]; \ (KEY_MODIFIER_ALT | KEY_MODIFIER_SHIFT | KEY_MODIFIER_COMMAND) | \
( value )]; \
[o_menu addItem: o_mi]; \ [o_menu addItem: o_mi]; \
/* Shift */ \ /* Shift */ \
o_mi = [[NSMenuItem alloc] initWithTitle: \ o_mi = [[NSMenuItem alloc] initWithTitle: \
...@@ -260,7 +266,8 @@ if( MACOS_VERSION >= 3 ) \ ...@@ -260,7 +266,8 @@ if( MACOS_VERSION >= 3 ) \
[o_label sizeToFit]; \ [o_label sizeToFit]; \
} }
#define ADD_TEXTFIELD( o_textfield, superFrame, x_offset, my_y_offset, my_width, tooltip, init_value ) \ #define ADD_TEXTFIELD( o_textfield, superFrame, x_offset, my_y_offset, \
my_width, tooltip, init_value ) \
{ \ { \
NSRect s_rc = superFrame; \ NSRect s_rc = superFrame; \
s_rc.origin.x = x_offset; \ s_rc.origin.x = x_offset; \
...@@ -273,13 +280,15 @@ if( MACOS_VERSION >= 3 ) \ ...@@ -273,13 +280,15 @@ if( MACOS_VERSION >= 3 ) \
[o_textfield setStringValue: init_value]; \ [o_textfield setStringValue: init_value]; \
} }
#define ADD_COMBO( o_combo, superFrame, x_offset, my_y_offset, x2_offset, tooltip ) \ #define ADD_COMBO( o_combo, superFrame, x_offset, my_y_offset, x2_offset, \
tooltip ) \
{ \ { \
NSRect s_rc = superFrame; \ NSRect s_rc = superFrame; \
s_rc.origin.x = x_offset + 2; \ s_rc.origin.x = x_offset + 2; \
s_rc.origin.y = my_y_offset; \ s_rc.origin.y = my_y_offset; \
s_rc.size.height = 26; \ s_rc.size.height = 26; \
s_rc.size.width = superFrame.size.width + 2 - s_rc.origin.x - (x2_offset); \ s_rc.size.width = superFrame.size.width + 2 - s_rc.origin.x - \
(x2_offset); \
o_combo = [[[NSComboBox alloc] initWithFrame: s_rc] retain]; \ o_combo = [[[NSComboBox alloc] initWithFrame: s_rc] retain]; \
[o_combo setFont:[NSFont systemFontOfSize:0]]; \ [o_combo setFont:[NSFont systemFontOfSize:0]]; \
[o_combo setToolTip: tooltip]; \ [o_combo setToolTip: tooltip]; \
...@@ -289,7 +298,8 @@ if( MACOS_VERSION >= 3 ) \ ...@@ -289,7 +298,8 @@ if( MACOS_VERSION >= 3 ) \
[o_combo setCompletes:YES]; \ [o_combo setCompletes:YES]; \
} }
#define ADD_RIGHT_BUTTON( o_button, superFrame, x_offset, my_y_offset, tooltip, title ) \ #define ADD_RIGHT_BUTTON( o_button, superFrame, x_offset, my_y_offset, \
tooltip, title ) \
{ \ { \
NSRect s_rc = superFrame; \ NSRect s_rc = superFrame; \
o_button = [[[NSButton alloc] initWithFrame: s_rc] retain]; \ o_button = [[[NSButton alloc] initWithFrame: s_rc] retain]; \
...@@ -299,7 +309,7 @@ if( MACOS_VERSION >= 3 ) \ ...@@ -299,7 +309,7 @@ if( MACOS_VERSION >= 3 ) \
[o_button setFont:[NSFont systemFontOfSize:0]]; \ [o_button setFont:[NSFont systemFontOfSize:0]]; \
[o_button sizeToFit]; \ [o_button sizeToFit]; \
s_rc = [o_button frame]; \ s_rc = [o_button frame]; \
s_rc.origin.x = superFrame.size.width - [o_button frame].size.width - 6; \ s_rc.origin.x = superFrame.size.width - [o_button frame].size.width - 6;\
s_rc.origin.y = my_y_offset - 6; \ s_rc.origin.y = my_y_offset - 6; \
s_rc.size.width += 12; \ s_rc.size.width += 12; \
[o_button setFrame: s_rc]; \ [o_button setFrame: s_rc]; \
...@@ -308,19 +318,22 @@ if( MACOS_VERSION >= 3 ) \ ...@@ -308,19 +318,22 @@ if( MACOS_VERSION >= 3 ) \
[o_button setAction: @selector(openFileDialog:)]; \ [o_button setAction: @selector(openFileDialog:)]; \
} }
#define ADD_POPUP( o_popup, superFrame, x_offset, my_y_offset, x2_offset, tooltip ) \ #define ADD_POPUP( o_popup, superFrame, x_offset, my_y_offset, x2_offset, \
tooltip ) \
{ \ { \
NSRect s_rc = superFrame; \ NSRect s_rc = superFrame; \
s_rc.origin.x = x_offset - 1; \ s_rc.origin.x = x_offset - 1; \
s_rc.origin.y = my_y_offset; \ s_rc.origin.y = my_y_offset; \
s_rc.size.height = 26; \ s_rc.size.height = 26; \
s_rc.size.width = superFrame.size.width + 2 - s_rc.origin.x - (x2_offset); \ s_rc.size.width = superFrame.size.width + 2 - s_rc.origin.x - \
(x2_offset); \
o_popup = [[[NSPopUpButton alloc] initWithFrame: s_rc] retain]; \ o_popup = [[[NSPopUpButton alloc] initWithFrame: s_rc] retain]; \
[o_popup setFont:[NSFont systemFontOfSize:0]]; \ [o_popup setFont:[NSFont systemFontOfSize:0]]; \
[o_popup setToolTip: tooltip]; \ [o_popup setToolTip: tooltip]; \
} }
#define ADD_STEPPER( o_stepper, superFrame, x_offset, my_y_offset, tooltip, lower, higher ) \ #define ADD_STEPPER( o_stepper, superFrame, x_offset, my_y_offset, tooltip, \
lower, higher ) \
{ \ { \
NSRect s_rc = superFrame; \ NSRect s_rc = superFrame; \
s_rc.origin.x = x_offset; \ s_rc.origin.x = x_offset; \
...@@ -334,10 +347,12 @@ if( MACOS_VERSION >= 3 ) \ ...@@ -334,10 +347,12 @@ if( MACOS_VERSION >= 3 ) \
[o_stepper setMinValue: lower]; \ [o_stepper setMinValue: lower]; \
[o_stepper setTarget: self]; \ [o_stepper setTarget: self]; \
[o_stepper setAction: @selector(stepperChanged:)]; \ [o_stepper setAction: @selector(stepperChanged:)]; \
[o_stepper sendActionOn:NSLeftMouseUpMask|NSLeftMouseDownMask|NSLeftMouseDraggedMask]; \ [o_stepper sendActionOn:NSLeftMouseUpMask | NSLeftMouseDownMask | \
NSLeftMouseDraggedMask]; \
} }
#define ADD_SLIDER( o_slider, superFrame, x_offset, my_y_offset, my_width, tooltip, lower, higher ) \ #define ADD_SLIDER( o_slider, superFrame, x_offset, my_y_offset, my_width, \
tooltip, lower, higher ) \
{ \ { \
NSRect s_rc = superFrame; \ NSRect s_rc = superFrame; \
s_rc.origin.x = x_offset; \ s_rc.origin.x = x_offset; \
...@@ -351,7 +366,8 @@ if( MACOS_VERSION >= 3 ) \ ...@@ -351,7 +366,8 @@ if( MACOS_VERSION >= 3 ) \
[o_slider setMinValue: lower]; \ [o_slider setMinValue: lower]; \
} }
#define ADD_CHECKBOX( o_checkbox, superFrame, x_offset, my_y_offset, label, tooltip, init_value, position ) \ #define ADD_CHECKBOX( o_checkbox, superFrame, x_offset, my_y_offset, label, \
tooltip, init_value, position ) \
{ \ { \
NSRect s_rc = superFrame; \ NSRect s_rc = superFrame; \
s_rc.size.height = 18; \ s_rc.size.height = 18; \
...@@ -367,7 +383,8 @@ if( MACOS_VERSION >= 3 ) \ ...@@ -367,7 +383,8 @@ if( MACOS_VERSION >= 3 ) \
[o_checkbox sizeToFit]; \ [o_checkbox sizeToFit]; \
} }
#define ADD_CHECKBOX( o_checkbox, superFrame, x_offset, my_y_offset, label, tooltip, init_value, position ) \ #define ADD_CHECKBOX( o_checkbox, superFrame, x_offset, my_y_offset, label, \
tooltip, init_value, position ) \
{ \ { \
NSRect s_rc = superFrame; \ NSRect s_rc = superFrame; \
s_rc.size.height = 18; \ s_rc.size.height = 18; \
...@@ -384,7 +401,6 @@ if( MACOS_VERSION >= 3 ) \ ...@@ -384,7 +401,6 @@ if( MACOS_VERSION >= 3 ) \
} }
@implementation VLCConfigControl @implementation VLCConfigControl
- (id)initWithFrame: (NSRect)frame - (id)initWithFrame: (NSRect)frame
{ {
return [self initWithFrame: frame return [self initWithFrame: frame
...@@ -818,14 +834,16 @@ if( MACOS_VERSION >= 3 ) \ ...@@ -818,14 +834,16 @@ if( MACOS_VERSION >= 3 ) \
case CONFIG_ITEM_STRING: case CONFIG_ITEM_STRING:
if( !_p_item->i_list ) if( !_p_item->i_list )
{ {
p_control = [[StringConfigControl alloc] initWithItem: _p_item p_control = [[StringConfigControl alloc]
initWithItem: _p_item
withView: o_parent_view withView: o_parent_view
withVerticalOffset: i_yPos withVerticalOffset: i_yPos
withLastItem: i_lastItem]; withLastItem: i_lastItem];
} }
else else
{ {
p_control = [[StringListConfigControl alloc] initWithItem: _p_item p_control = [[StringListConfigControl alloc]
initWithItem: _p_item
withView: o_parent_view withView: o_parent_view
withVerticalOffset: i_yPos withVerticalOffset: i_yPos
withLastItem: i_lastItem]; withLastItem: i_lastItem];
...@@ -833,14 +851,16 @@ if( MACOS_VERSION >= 3 ) \ ...@@ -833,14 +851,16 @@ if( MACOS_VERSION >= 3 ) \
break; break;
case CONFIG_ITEM_FILE: case CONFIG_ITEM_FILE:
case CONFIG_ITEM_DIRECTORY: case CONFIG_ITEM_DIRECTORY:
p_control = [[FileConfigControl alloc] initWithItem: _p_item p_control = [[FileConfigControl alloc]
initWithItem: _p_item
withView: o_parent_view withView: o_parent_view
withVerticalOffset: i_yPos withVerticalOffset: i_yPos
withLastItem: i_lastItem]; withLastItem: i_lastItem];
break; break;
case CONFIG_ITEM_MODULE: case CONFIG_ITEM_MODULE:
case CONFIG_ITEM_MODULE_CAT: case CONFIG_ITEM_MODULE_CAT:
p_control = [[ModuleConfigControl alloc] initWithItem: _p_item p_control = [[ModuleConfigControl alloc]
initWithItem: _p_item
withView: o_parent_view withView: o_parent_view
withVerticalOffset: i_yPos withVerticalOffset: i_yPos
withLastItem: i_lastItem]; withLastItem: i_lastItem];
...@@ -848,28 +868,32 @@ if( MACOS_VERSION >= 3 ) \ ...@@ -848,28 +868,32 @@ if( MACOS_VERSION >= 3 ) \
case CONFIG_ITEM_INTEGER: case CONFIG_ITEM_INTEGER:
if( _p_item->i_list ) if( _p_item->i_list )
{ {
p_control = [[IntegerListConfigControl alloc] initWithItem: _p_item p_control = [[IntegerListConfigControl alloc]
initWithItem: _p_item
withView: o_parent_view withView: o_parent_view
withVerticalOffset: i_yPos withVerticalOffset: i_yPos
withLastItem: i_lastItem]; withLastItem: i_lastItem];
} }
else if( _p_item->i_min != 0 || _p_item->i_max != 0 ) else if( _p_item->i_min != 0 || _p_item->i_max != 0 )
{ {
p_control = [[RangedIntegerConfigControl alloc] initWithItem: _p_item p_control = [[RangedIntegerConfigControl alloc]
initWithItem: _p_item
withView: o_parent_view withView: o_parent_view
withVerticalOffset: i_yPos withVerticalOffset: i_yPos
withLastItem: i_lastItem]; withLastItem: i_lastItem];
} }
else else
{ {
p_control = [[IntegerConfigControl alloc] initWithItem: _p_item p_control = [[IntegerConfigControl alloc]
initWithItem: _p_item
withView: o_parent_view withView: o_parent_view
withVerticalOffset: i_yPos withVerticalOffset: i_yPos
withLastItem: i_lastItem]; withLastItem: i_lastItem];
} }
break; break;
case CONFIG_ITEM_BOOL: case CONFIG_ITEM_BOOL:
p_control = [[BoolConfigControl alloc] initWithItem: _p_item p_control = [[BoolConfigControl alloc]
initWithItem: _p_item
withView: o_parent_view withView: o_parent_view
withVerticalOffset: i_yPos withVerticalOffset: i_yPos
withLastItem: i_lastItem]; withLastItem: i_lastItem];
...@@ -877,30 +901,34 @@ if( MACOS_VERSION >= 3 ) \ ...@@ -877,30 +901,34 @@ if( MACOS_VERSION >= 3 ) \
case CONFIG_ITEM_FLOAT: case CONFIG_ITEM_FLOAT:
if( _p_item->f_min != 0 || _p_item->f_max != 0 ) if( _p_item->f_min != 0 || _p_item->f_max != 0 )
{ {
p_control = [[RangedFloatConfigControl alloc] initWithItem: _p_item p_control = [[RangedFloatConfigControl alloc]
initWithItem: _p_item
withView: o_parent_view withView: o_parent_view
withVerticalOffset: i_yPos withVerticalOffset: i_yPos
withLastItem: i_lastItem]; withLastItem: i_lastItem];
} }
else else
{ {
p_control = [[FloatConfigControl alloc] initWithItem: _p_item p_control = [[FloatConfigControl alloc]
initWithItem: _p_item
withView: o_parent_view withView: o_parent_view
withVerticalOffset: i_yPos withVerticalOffset: i_yPos
withLastItem: i_lastItem]; withLastItem: i_lastItem];
} }
break; break;
case CONFIG_ITEM_KEY: case CONFIG_ITEM_KEY:
if( MACOS_VERSION < 3 ) if( MACOS_VERSION < 10.3 )
{ {
p_control = [[KeyConfigControlBefore103 alloc] initWithItem: _p_item p_control = [[KeyConfigControlBefore103 alloc]
initWithItem: _p_item
withView: o_parent_view withView: o_parent_view
withVerticalOffset: i_yPos withVerticalOffset: i_yPos
withLastItem: i_lastItem]; withLastItem: i_lastItem];
} }
else else
{ {
p_control = [[KeyConfigControlAfter103 alloc] initWithItem: _p_item p_control = [[KeyConfigControlAfter103 alloc]
initWithItem: _p_item
withView: o_parent_view withView: o_parent_view
withVerticalOffset: i_yPos withVerticalOffset: i_yPos
withLastItem: i_lastItem]; withLastItem: i_lastItem];
...@@ -908,7 +936,8 @@ if( MACOS_VERSION >= 3 ) \ ...@@ -908,7 +936,8 @@ if( MACOS_VERSION >= 3 ) \
break; break;
case CONFIG_ITEM_MODULE_LIST: case CONFIG_ITEM_MODULE_LIST:
case CONFIG_ITEM_MODULE_LIST_CAT: case CONFIG_ITEM_MODULE_LIST_CAT:
p_control = [[ModuleListConfigControl alloc] initWithItem: _p_item p_control = [[ModuleListConfigControl alloc]
initWithItem: _p_item
withView: o_parent_view withView: o_parent_view
withVerticalOffset: i_yPos withVerticalOffset: i_yPos
withLastItem: i_lastItem]; withLastItem: i_lastItem];
...@@ -979,12 +1008,9 @@ fprintf( stderr, "Applying %f to %s\n" , [self floatValue], psz_name ); ...@@ -979,12 +1008,9 @@ fprintf( stderr, "Applying %f to %s\n" , [self floatValue], psz_name );
break; break;
} }
} }
@end @end
@implementation StringConfigControl @implementation StringConfigControl
- (id) initWithItem: (module_config_t *)_p_item - (id) initWithItem: (module_config_t *)_p_item
withView: (NSView *)o_parent_view withView: (NSView *)o_parent_view
withVerticalOffset: (int)i_yPos withVerticalOffset: (int)i_yPos
...@@ -1001,7 +1027,8 @@ fprintf( stderr, "Applying %f to %s\n" , [self floatValue], psz_name ); ...@@ -1001,7 +1027,8 @@ fprintf( stderr, "Applying %f to %s\n" , [self floatValue], psz_name );
{ {
/* add the label */ /* add the label */
if( p_item->psz_text ) if( p_item->psz_text )
o_labelString = [[VLCMain sharedInstance] localizedString: p_item->psz_text]; o_labelString = [[VLCMain sharedInstance]
localizedString: p_item->psz_text];
else else
o_labelString = [NSString stringWithString:@""]; o_labelString = [NSString stringWithString:@""];
ADD_LABEL( o_label, mainFrame, 0, -3, o_labelString ) ADD_LABEL( o_label, mainFrame, 0, -3, o_labelString )
...@@ -1010,14 +1037,16 @@ fprintf( stderr, "Applying %f to %s\n" , [self floatValue], psz_name ); ...@@ -1010,14 +1037,16 @@ fprintf( stderr, "Applying %f to %s\n" , [self floatValue], psz_name );
/* build the textfield */ /* build the textfield */
o_textfieldTooltip = [[VLCMain sharedInstance] wrapString: o_textfieldTooltip = [[VLCMain sharedInstance] wrapString:
[[VLCMain sharedInstance] localizedString: p_item->psz_longtext ] toWidth: PREFS_WRAP]; [[VLCMain sharedInstance] localizedString: p_item->psz_longtext]
toWidth: PREFS_WRAP];
if( p_item->psz_value ) if( p_item->psz_value )
o_textfieldString = [[VLCMain sharedInstance] localizedString: p_item->psz_value]; o_textfieldString = [[VLCMain sharedInstance]
localizedString: p_item->psz_value];
else else
o_textfieldString = [NSString stringWithString: @""]; o_textfieldString = [NSString stringWithString: @""];
ADD_TEXTFIELD( o_textfield, mainFrame, [o_label frame].size.width + 2, ADD_TEXTFIELD( o_textfield, mainFrame, [o_label frame].size.width + 2,
0, mainFrame.size.width - [o_label frame].size.width - 2, 0, mainFrame.size.width - [o_label frame].size.width -
o_textfieldTooltip, o_textfieldString ) 2, o_textfieldTooltip, o_textfieldString )
[o_textfield setAutoresizingMask:NSViewWidthSizable ]; [o_textfield setAutoresizingMask:NSViewWidthSizable ];
[self addSubview: o_textfield]; [self addSubview: o_textfield];
} }
...@@ -1033,13 +1062,12 @@ fprintf( stderr, "Applying %f to %s\n" , [self floatValue], psz_name ); ...@@ -1033,13 +1062,12 @@ fprintf( stderr, "Applying %f to %s\n" , [self floatValue], psz_name );
- (char *)stringValue - (char *)stringValue
{ {
return strdup( [[VLCMain sharedInstance] delocalizeString:[o_textfield stringValue]] ); return strdup( [[VLCMain sharedInstance] delocalizeString:
[o_textfield stringValue]] );
} }
@end @end
@implementation StringListConfigControl @implementation StringListConfigControl
- (id) initWithItem: (module_config_t *)_p_item - (id) initWithItem: (module_config_t *)_p_item
withView: (NSView *)o_parent_view withView: (NSView *)o_parent_view
withVerticalOffset: (int)i_yPos withVerticalOffset: (int)i_yPos
...@@ -1057,7 +1085,8 @@ fprintf( stderr, "Applying %f to %s\n" , [self floatValue], psz_name ); ...@@ -1057,7 +1085,8 @@ fprintf( stderr, "Applying %f to %s\n" , [self floatValue], psz_name );
int i_index; int i_index;
/* add the label */ /* add the label */
if( p_item->psz_text ) if( p_item->psz_text )
o_labelString = [[VLCMain sharedInstance] localizedString: p_item->psz_text]; o_labelString = [[VLCMain sharedInstance]
localizedString: p_item->psz_text];
else else
o_labelString = [NSString stringWithString:@""]; o_labelString = [NSString stringWithString:@""];
ADD_LABEL( o_label, mainFrame, 0, -3, o_labelString ) ADD_LABEL( o_label, mainFrame, 0, -3, o_labelString )
...@@ -1066,17 +1095,15 @@ fprintf( stderr, "Applying %f to %s\n" , [self floatValue], psz_name ); ...@@ -1066,17 +1095,15 @@ fprintf( stderr, "Applying %f to %s\n" , [self floatValue], psz_name );
/* build the textfield */ /* build the textfield */
o_textfieldTooltip = [[VLCMain sharedInstance] wrapString: o_textfieldTooltip = [[VLCMain sharedInstance] wrapString:
[[VLCMain sharedInstance] localizedString: p_item->psz_longtext ] toWidth: PREFS_WRAP]; [[VLCMain sharedInstance]
localizedString: p_item->psz_longtext ] toWidth: PREFS_WRAP];
ADD_COMBO( o_combo, mainFrame, [o_label frame].size.width, ADD_COMBO( o_combo, mainFrame, [o_label frame].size.width,
-2, 0, o_textfieldTooltip ) -2, 0, o_textfieldTooltip )
[o_combo setAutoresizingMask:NSViewWidthSizable ]; [o_combo setAutoresizingMask:NSViewWidthSizable ];
for( i_index = 0; i_index < p_item->i_list; i_index++ ) for( i_index = 0; i_index < p_item->i_list; i_index++ )
{ if( p_item->psz_value &&
if( p_item->psz_value && !strcmp( p_item->psz_value, p_item->ppsz_list[i_index] ) ) !strcmp( p_item->psz_value, p_item->ppsz_list[i_index] ) )
{
[o_combo selectItemAtIndex: i_index]; [o_combo selectItemAtIndex: i_index];
}
}
[self addSubview: o_combo]; [self addSubview: o_combo];
} }
return self; return self;
...@@ -1093,13 +1120,12 @@ fprintf( stderr, "Applying %f to %s\n" , [self floatValue], psz_name ); ...@@ -1093,13 +1120,12 @@ fprintf( stderr, "Applying %f to %s\n" , [self floatValue], psz_name );
if( [o_combo indexOfSelectedItem] >= 0 ) if( [o_combo indexOfSelectedItem] >= 0 )
return strdup( p_item->ppsz_list[[o_combo indexOfSelectedItem]] ); return strdup( p_item->ppsz_list[[o_combo indexOfSelectedItem]] );
else else
return strdup( [[VLCMain sharedInstance] delocalizeString: [o_combo stringValue]] ); return strdup( [[VLCMain sharedInstance]
delocalizeString: [o_combo stringValue]] );
} }
@end @end
@implementation StringListConfigControl (NSComboBoxDataSource) @implementation StringListConfigControl (NSComboBoxDataSource)
- (int)numberOfItemsInComboBox:(NSComboBox *)aComboBox - (int)numberOfItemsInComboBox:(NSComboBox *)aComboBox
{ {
return p_item->i_list; return p_item->i_list;
...@@ -1109,21 +1135,22 @@ fprintf( stderr, "Applying %f to %s\n" , [self floatValue], psz_name ); ...@@ -1109,21 +1135,22 @@ fprintf( stderr, "Applying %f to %s\n" , [self floatValue], psz_name );
{ {
if( p_item->ppsz_list_text && p_item->ppsz_list_text[i_index] ) if( p_item->ppsz_list_text && p_item->ppsz_list_text[i_index] )
{ {
return [[VLCMain sharedInstance] localizedString: p_item->ppsz_list_text[i_index]]; return [[VLCMain sharedInstance]
} else return [[VLCMain sharedInstance] localizedString: p_item->ppsz_list[i_index]]; localizedString: p_item->ppsz_list_text[i_index]];
} else return [[VLCMain sharedInstance]
localizedString: p_item->ppsz_list[i_index]];
} }
@end @end
@implementation FileConfigControl @implementation FileConfigControl
- (id) initWithItem: (module_config_t *)_p_item - (id) initWithItem: (module_config_t *)_p_item
withView: (NSView *)o_parent_view withView: (NSView *)o_parent_view
withVerticalOffset: (int)i_yPos withVerticalOffset: (int)i_yPos
withLastItem: (int)i_lastItem withLastItem: (int)i_lastItem
{ {
NSRect mainFrame = [o_parent_view frame]; NSRect mainFrame = [o_parent_view frame];
NSString *o_labelString, *o_buttonTooltip, *o_textfieldString, *o_textfieldTooltip; NSString *o_labelString, *o_buttonTooltip, *o_textfieldString;
NSString *o_textfieldTooltip;
mainFrame.size.height = 46; mainFrame.size.height = 46;
mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN; mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN;
mainFrame.origin.x = LEFTMARGIN; mainFrame.origin.x = LEFTMARGIN;
...@@ -1136,7 +1163,8 @@ fprintf( stderr, "Applying %f to %s\n" , [self floatValue], psz_name ); ...@@ -1136,7 +1163,8 @@ fprintf( stderr, "Applying %f to %s\n" , [self floatValue], psz_name );
/* add the label */ /* add the label */
if( p_item->psz_text ) if( p_item->psz_text )
o_labelString = [[VLCMain sharedInstance] localizedString: p_item->psz_text]; o_labelString = [[VLCMain sharedInstance]
localizedString: p_item->psz_text];
else else
o_labelString = [NSString stringWithString:@""]; o_labelString = [NSString stringWithString:@""];
ADD_LABEL( o_label, mainFrame, 0, 3, o_labelString ) ADD_LABEL( o_label, mainFrame, 0, 3, o_labelString )
...@@ -1144,21 +1172,25 @@ fprintf( stderr, "Applying %f to %s\n" , [self floatValue], psz_name ); ...@@ -1144,21 +1172,25 @@ fprintf( stderr, "Applying %f to %s\n" , [self floatValue], psz_name );
[self addSubview: o_label]; [self addSubview: o_label];
/* build the button */ /* build the button */
o_buttonTooltip = [[VLCMain sharedInstance] wrapString: o_buttonTooltip = [[VLCMain sharedInstance]
[[VLCMain sharedInstance] localizedString: p_item->psz_longtext ] toWidth: PREFS_WRAP]; wrapString: [[VLCMain sharedInstance]
ADD_RIGHT_BUTTON( o_button, mainFrame, 0, 0, o_buttonTooltip, _NS("Browse...") ) localizedString: p_item->psz_longtext ] toWidth: PREFS_WRAP];
ADD_RIGHT_BUTTON( o_button, mainFrame, 0, 0, o_buttonTooltip,
_NS("Browse...") )
[o_button setAutoresizingMask:NSViewMinXMargin ]; [o_button setAutoresizingMask:NSViewMinXMargin ];
[self addSubview: o_button]; [self addSubview: o_button];
/* build the textfield */ /* build the textfield */
o_textfieldTooltip = [[VLCMain sharedInstance] wrapString: o_textfieldTooltip = [[VLCMain sharedInstance] wrapString:
[[VLCMain sharedInstance] localizedString: p_item->psz_longtext ] toWidth: PREFS_WRAP]; [[VLCMain sharedInstance]
localizedString: p_item->psz_longtext ] toWidth: PREFS_WRAP];
if( p_item->psz_value ) if( p_item->psz_value )
o_textfieldString = [[VLCMain sharedInstance] localizedString: p_item->psz_value]; o_textfieldString = [[VLCMain sharedInstance]
localizedString: p_item->psz_value];
else else
o_textfieldString = [NSString stringWithString: @""]; o_textfieldString = [NSString stringWithString: @""];
ADD_TEXTFIELD( o_textfield, mainFrame, 12, ADD_TEXTFIELD( o_textfield, mainFrame, 12, 2, mainFrame.size.width -
2, mainFrame.size.width - 8 - [o_button frame].size.width, 8 - [o_button frame].size.width,
o_textfieldTooltip, o_textfieldString ) o_textfieldTooltip, o_textfieldString )
[o_textfield setAutoresizingMask:NSViewWidthSizable ]; [o_textfield setAutoresizingMask:NSViewWidthSizable ];
[self addSubview: o_textfield]; [self addSubview: o_textfield];
...@@ -1177,7 +1209,8 @@ fprintf( stderr, "Applying %f to %s\n" , [self floatValue], psz_name ); ...@@ -1177,7 +1209,8 @@ fprintf( stderr, "Applying %f to %s\n" , [self floatValue], psz_name );
{ {
NSOpenPanel *o_open_panel = [NSOpenPanel openPanel]; NSOpenPanel *o_open_panel = [NSOpenPanel openPanel];
[o_open_panel setTitle: (b_directory)?_NS("Select a directory"):_NS("Select a file")]; [o_open_panel setTitle: (b_directory)?
_NS("Select a directory"):_NS("Select a file")];
[o_open_panel setPrompt: _NS("Select")]; [o_open_panel setPrompt: _NS("Select")];
[o_open_panel setAllowsMultipleSelection: NO]; [o_open_panel setAllowsMultipleSelection: NO];
[o_open_panel setCanChooseFiles: !b_directory]; [o_open_panel setCanChooseFiles: !b_directory];
...@@ -1193,7 +1226,8 @@ fprintf( stderr, "Applying %f to %s\n" , [self floatValue], psz_name ); ...@@ -1193,7 +1226,8 @@ fprintf( stderr, "Applying %f to %s\n" , [self floatValue], psz_name );
contextInfo: nil]; contextInfo: nil];
} }
- (void)pathChosenInPanel:(NSOpenPanel *)o_sheet withReturn:(int)i_return_code contextInfo:(void *)o_context_info - (void)pathChosenInPanel:(NSOpenPanel *)o_sheet
withReturn:(int)i_return_code contextInfo:(void *)o_context_info
{ {
if( i_return_code == NSOKButton ) if( i_return_code == NSOKButton )
{ {
...@@ -1209,11 +1243,9 @@ fprintf( stderr, "Applying %f to %s\n" , [self floatValue], psz_name ); ...@@ -1209,11 +1243,9 @@ fprintf( stderr, "Applying %f to %s\n" , [self floatValue], psz_name );
else else
return NULL; return NULL;
} }
@end @end
@implementation ModuleConfigControl @implementation ModuleConfigControl
- (id) initWithItem: (module_config_t *)_p_item - (id) initWithItem: (module_config_t *)_p_item
withView: (NSView *)o_parent_view withView: (NSView *)o_parent_view
withVerticalOffset: (int)i_yPos withVerticalOffset: (int)i_yPos
...@@ -1233,7 +1265,8 @@ fprintf( stderr, "Applying %f to %s\n" , [self floatValue], psz_name ); ...@@ -1233,7 +1265,8 @@ fprintf( stderr, "Applying %f to %s\n" , [self floatValue], psz_name );
module_t *p_parser; module_t *p_parser;
/* add the label */ /* add the label */
if( p_item->psz_text ) if( p_item->psz_text )
o_labelString = [[VLCMain sharedInstance] localizedString: p_item->psz_text]; o_labelString = [[VLCMain sharedInstance]
localizedString: p_item->psz_text];
else else
o_labelString = [NSString stringWithString:@""]; o_labelString = [NSString stringWithString:@""];
ADD_LABEL( o_label, mainFrame, 0, -1, o_labelString ) ADD_LABEL( o_label, mainFrame, 0, -1, o_labelString )
...@@ -1242,7 +1275,8 @@ fprintf( stderr, "Applying %f to %s\n" , [self floatValue], psz_name ); ...@@ -1242,7 +1275,8 @@ fprintf( stderr, "Applying %f to %s\n" , [self floatValue], psz_name );
/* build the popup */ /* build the popup */
o_popupTooltip = [[VLCMain sharedInstance] wrapString: o_popupTooltip = [[VLCMain sharedInstance] wrapString:
[[VLCMain sharedInstance] localizedString: p_item->psz_longtext ] toWidth: PREFS_WRAP]; [[VLCMain sharedInstance]
localizedString: p_item->psz_longtext ] toWidth: PREFS_WRAP];
ADD_POPUP( o_popup, mainFrame, [o_label frame].size.width, ADD_POPUP( o_popup, mainFrame, [o_label frame].size.width,
-2, 0, o_popupTooltip ) -2, 0, o_popupTooltip )
[o_popup setAutoresizingMask:NSViewWidthSizable ]; [o_popup setAutoresizingMask:NSViewWidthSizable ];
...@@ -1266,11 +1300,9 @@ fprintf( stderr, "Applying %f to %s\n" , [self floatValue], psz_name ); ...@@ -1266,11 +1300,9 @@ fprintf( stderr, "Applying %f to %s\n" , [self floatValue], psz_name );
if( p_item->psz_value && if( p_item->psz_value &&
!strcmp( p_item->psz_value, p_parser->psz_object_name ) ) !strcmp( p_item->psz_value, p_parser->psz_object_name ) )
{
[o_popup selectItem:[o_popup lastItem]]; [o_popup selectItem:[o_popup lastItem]];
} }
} }
}
else else
{ {
module_config_t *p_config; module_config_t *p_config;
...@@ -1360,11 +1392,9 @@ fprintf( stderr, "Applying %f to %s\n" , [self floatValue], psz_name ); ...@@ -1360,11 +1392,9 @@ fprintf( stderr, "Applying %f to %s\n" , [self floatValue], psz_name );
vlc_list_release( p_list ); vlc_list_release( p_list );
return returnval; return returnval;
} }
@end @end
@implementation IntegerConfigControl @implementation IntegerConfigControl
- (id) initWithItem: (module_config_t *)_p_item - (id) initWithItem: (module_config_t *)_p_item
withView: (NSView *)o_parent_view withView: (NSView *)o_parent_view
withVerticalOffset: (int)i_yPos withVerticalOffset: (int)i_yPos
...@@ -1380,11 +1410,13 @@ fprintf( stderr, "Applying %f to %s\n" , [self floatValue], psz_name ); ...@@ -1380,11 +1410,13 @@ fprintf( stderr, "Applying %f to %s\n" , [self floatValue], psz_name );
if( [super initWithFrame: mainFrame item: _p_item] != nil ) if( [super initWithFrame: mainFrame item: _p_item] != nil )
{ {
o_tooltip = [[VLCMain sharedInstance] wrapString: o_tooltip = [[VLCMain sharedInstance] wrapString:
[[VLCMain sharedInstance] localizedString: p_item->psz_longtext ] toWidth: PREFS_WRAP]; [[VLCMain sharedInstance]
localizedString: p_item->psz_longtext ] toWidth: PREFS_WRAP];
/* add the label */ /* add the label */
if( p_item->psz_text ) if( p_item->psz_text )
o_labelString = [[VLCMain sharedInstance] localizedString: p_item->psz_text]; o_labelString = [[VLCMain sharedInstance]
localizedString: p_item->psz_text];
else else
o_labelString = [NSString stringWithString:@""]; o_labelString = [NSString stringWithString:@""];
ADD_LABEL( o_label, mainFrame, 0, -2, o_labelString ) ADD_LABEL( o_label, mainFrame, 0, -2, o_labelString )
...@@ -1400,7 +1432,8 @@ fprintf( stderr, "Applying %f to %s\n" , [self floatValue], psz_name ); ...@@ -1400,7 +1432,8 @@ fprintf( stderr, "Applying %f to %s\n" , [self floatValue], psz_name );
/* build the textfield */ /* build the textfield */
if( p_item->psz_value ) if( p_item->psz_value )
o_textfieldString = [[VLCMain sharedInstance] localizedString: p_item->psz_value]; o_textfieldString = [[VLCMain sharedInstance]
localizedString: p_item->psz_value];
else else
o_textfieldString = [NSString stringWithString: @""]; o_textfieldString = [NSString stringWithString: @""];
ADD_TEXTFIELD( o_textfield, mainFrame, mainFrame.size.width - 19 - 52, ADD_TEXTFIELD( o_textfield, mainFrame, mainFrame.size.width - 19 - 52,
...@@ -1460,7 +1493,8 @@ fprintf( stderr, "Applying %f to %s\n" , [self floatValue], psz_name ); ...@@ -1460,7 +1493,8 @@ fprintf( stderr, "Applying %f to %s\n" , [self floatValue], psz_name );
int i_index; int i_index;
/* add the label */ /* add the label */
if( p_item->psz_text ) if( p_item->psz_text )
o_labelString = [[VLCMain sharedInstance] localizedString: p_item->psz_text]; o_labelString = [[VLCMain sharedInstance]
localizedString: p_item->psz_text];
else else
o_labelString = [NSString stringWithString:@""]; o_labelString = [NSString stringWithString:@""];
ADD_LABEL( o_label, mainFrame, 0, -3, o_labelString ) ADD_LABEL( o_label, mainFrame, 0, -3, o_labelString )
...@@ -1469,7 +1503,8 @@ fprintf( stderr, "Applying %f to %s\n" , [self floatValue], psz_name ); ...@@ -1469,7 +1503,8 @@ fprintf( stderr, "Applying %f to %s\n" , [self floatValue], psz_name );
/* build the textfield */ /* build the textfield */
o_textfieldTooltip = [[VLCMain sharedInstance] wrapString: o_textfieldTooltip = [[VLCMain sharedInstance] wrapString:
[[VLCMain sharedInstance] localizedString: p_item->psz_longtext ] toWidth: PREFS_WRAP]; [[VLCMain sharedInstance]
localizedString: p_item->psz_longtext ] toWidth: PREFS_WRAP];
ADD_COMBO( o_combo, mainFrame, [o_label frame].size.width, ADD_COMBO( o_combo, mainFrame, [o_label frame].size.width,
-2, 0, o_textfieldTooltip ) -2, 0, o_textfieldTooltip )
[o_combo setAutoresizingMask:NSViewWidthSizable ]; [o_combo setAutoresizingMask:NSViewWidthSizable ];
...@@ -1498,11 +1533,9 @@ fprintf( stderr, "Applying %f to %s\n" , [self floatValue], psz_name ); ...@@ -1498,11 +1533,9 @@ fprintf( stderr, "Applying %f to %s\n" , [self floatValue], psz_name );
else else
return [o_combo intValue]; return [o_combo intValue];
} }
@end @end
@implementation IntegerListConfigControl (NSComboBoxDataSource) @implementation IntegerListConfigControl (NSComboBoxDataSource)
- (int)numberOfItemsInComboBox:(NSComboBox *)aComboBox - (int)numberOfItemsInComboBox:(NSComboBox *)aComboBox
{ {
return p_item->i_list; return p_item->i_list;
...@@ -1511,15 +1544,14 @@ fprintf( stderr, "Applying %f to %s\n" , [self floatValue], psz_name ); ...@@ -1511,15 +1544,14 @@ fprintf( stderr, "Applying %f to %s\n" , [self floatValue], psz_name );
- (id)comboBox:(NSComboBox *)aComboBox objectValueForItemAtIndex:(int)i_index - (id)comboBox:(NSComboBox *)aComboBox objectValueForItemAtIndex:(int)i_index
{ {
if( p_item->ppsz_list_text && p_item->ppsz_list_text[i_index] ) if( p_item->ppsz_list_text && p_item->ppsz_list_text[i_index] )
{ return [[VLCMain sharedInstance]
return [[VLCMain sharedInstance] localizedString: p_item->ppsz_list_text[i_index]]; localizedString: p_item->ppsz_list_text[i_index]];
} else return [NSString stringWithFormat: @"%i", p_item->pi_list[i_index]]; else
return [NSString stringWithFormat: @"%i", p_item->pi_list[i_index]];
} }
@end @end
@implementation RangedIntegerConfigControl @implementation RangedIntegerConfigControl
- (id) initWithItem: (module_config_t *)_p_item - (id) initWithItem: (module_config_t *)_p_item
withView: (NSView *)o_parent_view withView: (NSView *)o_parent_view
withVerticalOffset: (int)i_yPos withVerticalOffset: (int)i_yPos
...@@ -1536,7 +1568,8 @@ fprintf( stderr, "Applying %f to %s\n" , [self floatValue], psz_name ); ...@@ -1536,7 +1568,8 @@ fprintf( stderr, "Applying %f to %s\n" , [self floatValue], psz_name );
{ {
/* add the label */ /* add the label */
if( p_item->psz_text ) if( p_item->psz_text )
o_labelString = [[VLCMain sharedInstance] localizedString: p_item->psz_text]; o_labelString = [[VLCMain sharedInstance]
localizedString: p_item->psz_text];
else else
o_labelString = [NSString stringWithString:@""]; o_labelString = [NSString stringWithString:@""];
ADD_LABEL( o_label, mainFrame, 0, -3, o_labelString ) ADD_LABEL( o_label, mainFrame, 0, -3, o_labelString )
...@@ -1545,7 +1578,8 @@ fprintf( stderr, "Applying %f to %s\n" , [self floatValue], psz_name ); ...@@ -1545,7 +1578,8 @@ fprintf( stderr, "Applying %f to %s\n" , [self floatValue], psz_name );
/* build the textfield */ /* build the textfield */
o_tooltip = [[VLCMain sharedInstance] wrapString: o_tooltip = [[VLCMain sharedInstance] wrapString:
[[VLCMain sharedInstance] localizedString: p_item->psz_longtext ] toWidth: PREFS_WRAP]; [[VLCMain sharedInstance]
localizedString: p_item->psz_longtext ] toWidth: PREFS_WRAP];
ADD_TEXTFIELD( o_textfield, mainFrame, [o_label frame].size.width + 2, ADD_TEXTFIELD( o_textfield, mainFrame, [o_label frame].size.width + 2,
28, 49, o_tooltip, @"" ) 28, 49, o_tooltip, @"" )
[o_textfield setIntValue: p_item->i_value]; [o_textfield setIntValue: p_item->i_value];
...@@ -1564,20 +1598,25 @@ fprintf( stderr, "Applying %f to %s\n" , [self floatValue], psz_name ); ...@@ -1564,20 +1598,25 @@ fprintf( stderr, "Applying %f to %s\n" , [self floatValue], psz_name );
[self addSubview: o_textfield_min]; [self addSubview: o_textfield_min];
/* build the maxtextfield */ /* build the maxtextfield */
ADD_LABEL( o_textfield_max, mainFrame, mainFrame.size.width - 31, -30, @"8888" ) ADD_LABEL( o_textfield_max, mainFrame,
mainFrame.size.width - 31, -30, @"8888" )
[o_textfield_max setIntValue: p_item->i_max]; [o_textfield_max setIntValue: p_item->i_max];
[o_textfield_max setAutoresizingMask:NSViewMinXMargin ]; [o_textfield_max setAutoresizingMask:NSViewMinXMargin ];
[self addSubview: o_textfield_max]; [self addSubview: o_textfield_max];
/* build the slider */ /* build the slider */
ADD_SLIDER( o_slider, mainFrame, [o_textfield_min frame].origin.x + [o_textfield_min frame].size.width + 6, ADD_SLIDER( o_slider, mainFrame, [o_textfield_min frame].origin.x +
-1, mainFrame.size.width - [o_textfield_max frame].size.width - [o_textfield_max frame].size.width - 14 [o_textfield_min frame].size.width + 6, -1, mainFrame.size.width -
- [o_textfield_min frame].origin.x, o_tooltip, p_item->i_min, p_item->i_max ) [o_textfield_max frame].size.width -
[o_textfield_max frame].size.width - 14 -
[o_textfield_min frame].origin.x, o_tooltip,
p_item->i_min, p_item->i_max )
[o_slider setIntValue: p_item->i_value]; [o_slider setIntValue: p_item->i_value];
[o_slider setAutoresizingMask:NSViewWidthSizable ]; [o_slider setAutoresizingMask:NSViewWidthSizable ];
[o_slider setTarget: self]; [o_slider setTarget: self];
[o_slider setAction: @selector(sliderChanged:)]; [o_slider setAction: @selector(sliderChanged:)];
[o_slider sendActionOn:NSLeftMouseUpMask|NSLeftMouseDownMask|NSLeftMouseDraggedMask]; [o_slider sendActionOn:NSLeftMouseUpMask | NSLeftMouseDownMask |
NSLeftMouseDraggedMask];
[self addSubview: o_slider]; [self addSubview: o_slider];
} }
...@@ -1607,11 +1646,9 @@ fprintf( stderr, "Applying %f to %s\n" , [self floatValue], psz_name ); ...@@ -1607,11 +1646,9 @@ fprintf( stderr, "Applying %f to %s\n" , [self floatValue], psz_name );
{ {
return [o_slider intValue]; return [o_slider intValue];
} }
@end @end
@implementation FloatConfigControl @implementation FloatConfigControl
- (id) initWithItem: (module_config_t *)_p_item - (id) initWithItem: (module_config_t *)_p_item
withView: (NSView *)o_parent_view withView: (NSView *)o_parent_view
withVerticalOffset: (int)i_yPos withVerticalOffset: (int)i_yPos
...@@ -1627,11 +1664,13 @@ fprintf( stderr, "Applying %f to %s\n" , [self floatValue], psz_name ); ...@@ -1627,11 +1664,13 @@ fprintf( stderr, "Applying %f to %s\n" , [self floatValue], psz_name );
if( [super initWithFrame: mainFrame item: _p_item] != nil ) if( [super initWithFrame: mainFrame item: _p_item] != nil )
{ {
o_tooltip = [[VLCMain sharedInstance] wrapString: o_tooltip = [[VLCMain sharedInstance] wrapString:
[[VLCMain sharedInstance] localizedString: p_item->psz_longtext ] toWidth: PREFS_WRAP]; [[VLCMain sharedInstance]
localizedString: p_item->psz_longtext ] toWidth: PREFS_WRAP];
/* add the label */ /* add the label */
if( p_item->psz_text ) if( p_item->psz_text )
o_labelString = [[VLCMain sharedInstance] localizedString: p_item->psz_text]; o_labelString = [[VLCMain sharedInstance]
localizedString: p_item->psz_text];
else else
o_labelString = [NSString stringWithString:@""]; o_labelString = [NSString stringWithString:@""];
ADD_LABEL( o_label, mainFrame, 0, -2, o_labelString ) ADD_LABEL( o_label, mainFrame, 0, -2, o_labelString )
...@@ -1647,7 +1686,8 @@ fprintf( stderr, "Applying %f to %s\n" , [self floatValue], psz_name ); ...@@ -1647,7 +1686,8 @@ fprintf( stderr, "Applying %f to %s\n" , [self floatValue], psz_name );
/* build the textfield */ /* build the textfield */
if( p_item->psz_value ) if( p_item->psz_value )
o_textfieldString = [[VLCMain sharedInstance] localizedString: p_item->psz_value]; o_textfieldString = [[VLCMain sharedInstance]
localizedString: p_item->psz_value];
else else
o_textfieldString = [NSString stringWithString: @""]; o_textfieldString = [NSString stringWithString: @""];
ADD_TEXTFIELD( o_textfield, mainFrame, mainFrame.size.width - 19 - 52, ADD_TEXTFIELD( o_textfield, mainFrame, mainFrame.size.width - 19 - 52,
...@@ -1685,11 +1725,9 @@ fprintf( stderr, "Applying %f to %s\n" , [self floatValue], psz_name ); ...@@ -1685,11 +1725,9 @@ fprintf( stderr, "Applying %f to %s\n" , [self floatValue], psz_name );
{ {
return [o_stepper floatValue]; return [o_stepper floatValue];
} }
@end @end
@implementation RangedFloatConfigControl @implementation RangedFloatConfigControl
- (id) initWithItem: (module_config_t *)_p_item - (id) initWithItem: (module_config_t *)_p_item
withView: (NSView *)o_parent_view withView: (NSView *)o_parent_view
withVerticalOffset: (int)i_yPos withVerticalOffset: (int)i_yPos
...@@ -1706,7 +1744,8 @@ fprintf( stderr, "Applying %f to %s\n" , [self floatValue], psz_name ); ...@@ -1706,7 +1744,8 @@ fprintf( stderr, "Applying %f to %s\n" , [self floatValue], psz_name );
{ {
/* add the label */ /* add the label */
if( p_item->psz_text ) if( p_item->psz_text )
o_labelString = [[VLCMain sharedInstance] localizedString: p_item->psz_text]; o_labelString = [[VLCMain sharedInstance]
localizedString: p_item->psz_text];
else else
o_labelString = [NSString stringWithString:@""]; o_labelString = [NSString stringWithString:@""];
ADD_LABEL( o_label, mainFrame, 0, -3, o_labelString ) ADD_LABEL( o_label, mainFrame, 0, -3, o_labelString )
...@@ -1715,7 +1754,8 @@ fprintf( stderr, "Applying %f to %s\n" , [self floatValue], psz_name ); ...@@ -1715,7 +1754,8 @@ fprintf( stderr, "Applying %f to %s\n" , [self floatValue], psz_name );
/* build the textfield */ /* build the textfield */
o_tooltip = [[VLCMain sharedInstance] wrapString: o_tooltip = [[VLCMain sharedInstance] wrapString:
[[VLCMain sharedInstance] localizedString: p_item->psz_longtext ] toWidth: PREFS_WRAP]; [[VLCMain sharedInstance]
localizedString: p_item->psz_longtext ] toWidth: PREFS_WRAP];
ADD_TEXTFIELD( o_textfield, mainFrame, [o_label frame].size.width + 2, ADD_TEXTFIELD( o_textfield, mainFrame, [o_label frame].size.width + 2,
28, 49, o_tooltip, @"" ) 28, 49, o_tooltip, @"" )
[o_textfield setFloatValue: p_item->f_value]; [o_textfield setFloatValue: p_item->f_value];
...@@ -1734,20 +1774,25 @@ fprintf( stderr, "Applying %f to %s\n" , [self floatValue], psz_name ); ...@@ -1734,20 +1774,25 @@ fprintf( stderr, "Applying %f to %s\n" , [self floatValue], psz_name );
[self addSubview: o_textfield_min]; [self addSubview: o_textfield_min];
/* build the maxtextfield */ /* build the maxtextfield */
ADD_LABEL( o_textfield_max, mainFrame, mainFrame.size.width - 31, -30, @"8888" ) ADD_LABEL( o_textfield_max, mainFrame, mainFrame.size.width - 31,
-30, @"8888" )
[o_textfield_max setFloatValue: p_item->f_max]; [o_textfield_max setFloatValue: p_item->f_max];
[o_textfield_max setAutoresizingMask:NSViewMinXMargin ]; [o_textfield_max setAutoresizingMask:NSViewMinXMargin ];
[self addSubview: o_textfield_max]; [self addSubview: o_textfield_max];
/* build the slider */ /* build the slider */
ADD_SLIDER( o_slider, mainFrame, [o_textfield_min frame].origin.x + [o_textfield_min frame].size.width + 6, ADD_SLIDER( o_slider, mainFrame, [o_textfield_min frame].origin.x +
-1, mainFrame.size.width - [o_textfield_max frame].size.width - [o_textfield_max frame].size.width - 14 [o_textfield_min frame].size.width + 6, -1, mainFrame.size.width -
- [o_textfield_min frame].origin.x, o_tooltip, p_item->f_min, p_item->f_max ) [o_textfield_max frame].size.width -
[o_textfield_max frame].size.width - 14 -
[o_textfield_min frame].origin.x, o_tooltip, p_item->f_min,
p_item->f_max )
[o_slider setFloatValue: p_item->f_value]; [o_slider setFloatValue: p_item->f_value];
[o_slider setAutoresizingMask:NSViewWidthSizable ]; [o_slider setAutoresizingMask:NSViewWidthSizable ];
[o_slider setTarget: self]; [o_slider setTarget: self];
[o_slider setAction: @selector(sliderChanged:)]; [o_slider setAction: @selector(sliderChanged:)];
[o_slider sendActionOn:NSLeftMouseUpMask|NSLeftMouseDownMask|NSLeftMouseDraggedMask]; [o_slider sendActionOn:NSLeftMouseUpMask | NSLeftMouseDownMask |
NSLeftMouseDraggedMask];
[self addSubview: o_slider]; [self addSubview: o_slider];
} }
...@@ -1798,12 +1843,15 @@ fprintf( stderr, "Applying %f to %s\n" , [self floatValue], psz_name ); ...@@ -1798,12 +1843,15 @@ fprintf( stderr, "Applying %f to %s\n" , [self floatValue], psz_name );
{ {
/* add the checkbox */ /* add the checkbox */
if( p_item->psz_text ) if( p_item->psz_text )
o_labelString = [[VLCMain sharedInstance] localizedString: p_item->psz_text]; o_labelString = [[VLCMain sharedInstance]
localizedString: p_item->psz_text];
else else
o_labelString = [NSString stringWithString:@""]; o_labelString = [NSString stringWithString:@""];
o_tooltip = [[VLCMain sharedInstance] wrapString: o_tooltip = [[VLCMain sharedInstance]
[[VLCMain sharedInstance] localizedString: p_item->psz_longtext ] toWidth: PREFS_WRAP]; wrapString: [[VLCMain sharedInstance]
ADD_CHECKBOX( o_checkbox, mainFrame, 0, 0, o_labelString, o_tooltip, p_item->i_value, NSImageRight) localizedString: p_item->psz_longtext ] toWidth: PREFS_WRAP];
ADD_CHECKBOX( o_checkbox, mainFrame, 0, 0, o_labelString,
o_tooltip, p_item->i_value, NSImageRight)
[o_checkbox setAutoresizingMask:NSViewNotSizable ]; [o_checkbox setAutoresizingMask:NSViewNotSizable ];
[self addSubview: o_checkbox]; [self addSubview: o_checkbox];
} }
...@@ -1841,7 +1889,8 @@ fprintf( stderr, "Applying %f to %s\n" , [self floatValue], psz_name ); ...@@ -1841,7 +1889,8 @@ fprintf( stderr, "Applying %f to %s\n" , [self floatValue], psz_name );
{ {
/* add the label */ /* add the label */
if( p_item->psz_text ) if( p_item->psz_text )
o_labelString = [[VLCMain sharedInstance] localizedString: p_item->psz_text]; o_labelString = [[VLCMain sharedInstance]
localizedString: p_item->psz_text];
else else
o_labelString = [NSString stringWithString:@""]; o_labelString = [NSString stringWithString:@""];
ADD_LABEL( o_label, mainFrame, 0, -10, o_labelString ) ADD_LABEL( o_label, mainFrame, 0, -10, o_labelString )
...@@ -1850,27 +1899,34 @@ fprintf( stderr, "Applying %f to %s\n" , [self floatValue], psz_name ); ...@@ -1850,27 +1899,34 @@ fprintf( stderr, "Applying %f to %s\n" , [self floatValue], psz_name );
/* add the checkboxes */ /* add the checkboxes */
o_tooltip = [[VLCMain sharedInstance] wrapString: o_tooltip = [[VLCMain sharedInstance] wrapString:
[[VLCMain sharedInstance] localizedString: p_item->psz_longtext ] toWidth: PREFS_WRAP]; [[VLCMain sharedInstance]
localizedString: p_item->psz_longtext ] toWidth: PREFS_WRAP];
ADD_CHECKBOX( o_cmd_checkbox, mainFrame, ADD_CHECKBOX( o_cmd_checkbox, mainFrame,
[o_label frame].size.width + 2, 0, [o_label frame].size.width + 2, 0,
[NSString stringWithUTF8String:PLACE_OF_INTEREST_SIGN], [NSString stringWithUTF8String:PLACE_OF_INTEREST_SIGN], o_tooltip,
o_tooltip, ((((unsigned int)p_item->i_value) & KEY_MODIFIER_COMMAND)?YES:NO), NSImageLeft ) ((((unsigned int)p_item->i_value) & KEY_MODIFIER_COMMAND)?YES:NO),
NSImageLeft )
[o_cmd_checkbox setState: p_item->i_value & KEY_MODIFIER_COMMAND]; [o_cmd_checkbox setState: p_item->i_value & KEY_MODIFIER_COMMAND];
ADD_CHECKBOX( o_ctrl_checkbox, mainFrame, ADD_CHECKBOX( o_ctrl_checkbox, mainFrame,
[o_cmd_checkbox frame].size.width + [o_cmd_checkbox frame].origin.x + 6, 0, [o_cmd_checkbox frame].size.width +
[NSString stringWithUTF8String:UP_ARROWHEAD], [o_cmd_checkbox frame].origin.x + 6, 0,
o_tooltip, ((((unsigned int)p_item->i_value) & KEY_MODIFIER_CTRL)?YES:NO), NSImageLeft ) [NSString stringWithUTF8String:UP_ARROWHEAD], o_tooltip,
((((unsigned int)p_item->i_value) & KEY_MODIFIER_CTRL)?YES:NO),
NSImageLeft )
[o_ctrl_checkbox setState: p_item->i_value & KEY_MODIFIER_CTRL]; [o_ctrl_checkbox setState: p_item->i_value & KEY_MODIFIER_CTRL];
ADD_CHECKBOX( o_alt_checkbox, mainFrame, ADD_CHECKBOX( o_alt_checkbox, mainFrame, [o_label frame].size.width +
[o_label frame].size.width + 2, -2 - [o_cmd_checkbox frame].size.height, 2, -2 - [o_cmd_checkbox frame].size.height,
[NSString stringWithUTF8String:OPTION_KEY], [NSString stringWithUTF8String:OPTION_KEY], o_tooltip,
o_tooltip, ((((unsigned int)p_item->i_value) & KEY_MODIFIER_ALT)?YES:NO), NSImageLeft ) ((((unsigned int)p_item->i_value) & KEY_MODIFIER_ALT)?YES:NO),
NSImageLeft )
[o_alt_checkbox setState: p_item->i_value & KEY_MODIFIER_ALT]; [o_alt_checkbox setState: p_item->i_value & KEY_MODIFIER_ALT];
ADD_CHECKBOX( o_shift_checkbox, mainFrame, ADD_CHECKBOX( o_shift_checkbox, mainFrame,
[o_cmd_checkbox frame].size.width + [o_cmd_checkbox frame].origin.x + 6, [o_cmd_checkbox frame].size.width +
-2 - [o_cmd_checkbox frame].size.height, [o_cmd_checkbox frame].origin.x + 6, -2 -
[NSString stringWithUTF8String:UPWARDS_WHITE_ARROW], [o_cmd_checkbox frame].size.height,
o_tooltip, ((((unsigned int)p_item->i_value) & KEY_MODIFIER_SHIFT)?YES:NO), NSImageLeft ) [NSString stringWithUTF8String:UPWARDS_WHITE_ARROW], o_tooltip,
((((unsigned int)p_item->i_value) & KEY_MODIFIER_SHIFT)?YES:NO),
NSImageLeft )
[o_shift_checkbox setState: p_item->i_value & KEY_MODIFIER_SHIFT]; [o_shift_checkbox setState: p_item->i_value & KEY_MODIFIER_SHIFT];
[self addSubview: o_cmd_checkbox]; [self addSubview: o_cmd_checkbox];
[self addSubview: o_ctrl_checkbox]; [self addSubview: o_ctrl_checkbox];
...@@ -1878,7 +1934,8 @@ fprintf( stderr, "Applying %f to %s\n" , [self floatValue], psz_name ); ...@@ -1878,7 +1934,8 @@ fprintf( stderr, "Applying %f to %s\n" , [self floatValue], psz_name );
[self addSubview: o_shift_checkbox]; [self addSubview: o_shift_checkbox];
/* build the popup */ /* build the popup */
ADD_POPUP( o_popup, mainFrame, [o_shift_checkbox frame].origin.x + [o_shift_checkbox frame].size.width + 4, ADD_POPUP( o_popup, mainFrame, [o_shift_checkbox frame].origin.x +
[o_shift_checkbox frame].size.width + 4,
4, 0, o_tooltip ) 4, 0, o_tooltip )
[o_popup setAutoresizingMask:NSViewWidthSizable ]; [o_popup setAutoresizingMask:NSViewWidthSizable ];
...@@ -1888,13 +1945,15 @@ fprintf( stderr, "Applying %f to %s\n" , [self floatValue], psz_name ); ...@@ -1888,13 +1945,15 @@ fprintf( stderr, "Applying %f to %s\n" , [self floatValue], psz_name );
o_keys_menu = [[NSMenu alloc] initWithTitle: @"Keys Menu"]; o_keys_menu = [[NSMenu alloc] initWithTitle: @"Keys Menu"];
for ( i = 0; i < sizeof(vlc_keys) / sizeof(key_descriptor_t); i++) for ( i = 0; i < sizeof(vlc_keys) / sizeof(key_descriptor_t); i++)
if( vlc_keys[i].psz_key_string && *vlc_keys[i].psz_key_string ) if( vlc_keys[i].psz_key_string && *vlc_keys[i].psz_key_string )
POPULATE_A_KEY( o_keys_menu, [NSString stringWithCString:vlc_keys[i].psz_key_string] POPULATE_A_KEY( o_keys_menu,
[NSString stringWithCString:vlc_keys[i].psz_key_string]
, vlc_keys[i].i_key_code) , vlc_keys[i].i_key_code)
} }
[o_popup setMenu:[o_keys_menu copyWithZone:nil]]; [o_popup setMenu:[o_keys_menu copyWithZone:nil]];
[o_popup selectItemWithTitle: [[VLCMain sharedInstance] localizedString:KeyToString(( ((unsigned int)p_item->i_value) & ~KEY_MODIFIER ))]]; [o_popup selectItemWithTitle: [[VLCMain sharedInstance]
localizedString:KeyToString(
(((unsigned int)p_item->i_value) & ~KEY_MODIFIER ))]];
[self addSubview: o_popup]; [self addSubview: o_popup];
} }
return self; return self;
} }
...@@ -1913,19 +1972,21 @@ fprintf( stderr, "Applying %f to %s\n" , [self floatValue], psz_name ); ...@@ -1913,19 +1972,21 @@ fprintf( stderr, "Applying %f to %s\n" , [self floatValue], psz_name );
{ {
unsigned int i_new_key = 0; unsigned int i_new_key = 0;
i_new_key |= ([o_cmd_checkbox state] == NSOnState) ? KEY_MODIFIER_COMMAND : 0; i_new_key |= ([o_cmd_checkbox state] == NSOnState) ?
i_new_key |= ([o_ctrl_checkbox state] == NSOnState) ? KEY_MODIFIER_CTRL : 0; KEY_MODIFIER_COMMAND : 0;
i_new_key |= ([o_alt_checkbox state] == NSOnState) ? KEY_MODIFIER_ALT : 0; i_new_key |= ([o_ctrl_checkbox state] == NSOnState) ?
i_new_key |= ([o_shift_checkbox state] == NSOnState) ? KEY_MODIFIER_SHIFT : 0; KEY_MODIFIER_CTRL : 0;
i_new_key |= ([o_alt_checkbox state] == NSOnState) ?
KEY_MODIFIER_ALT : 0;
i_new_key |= ([o_shift_checkbox state] == NSOnState) ?
KEY_MODIFIER_SHIFT : 0;
i_new_key |= StringToKey([[[o_popup selectedItem] title] cString]); i_new_key |= StringToKey([[[o_popup selectedItem] title] cString]);
return i_new_key; return i_new_key;
} }
@end @end
@implementation KeyConfigControlAfter103 @implementation KeyConfigControlAfter103
- (id) initWithItem: (module_config_t *)_p_item - (id) initWithItem: (module_config_t *)_p_item
withView: (NSView *)o_parent_view withView: (NSView *)o_parent_view
withVerticalOffset: (int)i_yPos withVerticalOffset: (int)i_yPos
...@@ -1942,7 +2003,8 @@ fprintf( stderr, "Applying %f to %s\n" , [self floatValue], psz_name ); ...@@ -1942,7 +2003,8 @@ fprintf( stderr, "Applying %f to %s\n" , [self floatValue], psz_name );
{ {
/* add the label */ /* add the label */
if( p_item->psz_text ) if( p_item->psz_text )
o_labelString = [[VLCMain sharedInstance] localizedString: p_item->psz_text]; o_labelString = [[VLCMain sharedInstance]
localizedString: p_item->psz_text];
else else
o_labelString = [NSString stringWithString:@""]; o_labelString = [NSString stringWithString:@""];
ADD_LABEL( o_label, mainFrame, 0, -1, o_labelString ) ADD_LABEL( o_label, mainFrame, 0, -1, o_labelString )
...@@ -1951,8 +2013,10 @@ fprintf( stderr, "Applying %f to %s\n" , [self floatValue], psz_name ); ...@@ -1951,8 +2013,10 @@ fprintf( stderr, "Applying %f to %s\n" , [self floatValue], psz_name );
/* build the popup */ /* build the popup */
o_tooltip = [[VLCMain sharedInstance] wrapString: o_tooltip = [[VLCMain sharedInstance] wrapString:
[[VLCMain sharedInstance] localizedString: p_item->psz_longtext ] toWidth: PREFS_WRAP]; [[VLCMain sharedInstance]
ADD_POPUP( o_popup, mainFrame, [o_label frame].origin.x + [o_label frame].size.width + 3, localizedString: p_item->psz_longtext ] toWidth: PREFS_WRAP];
ADD_POPUP( o_popup, mainFrame, [o_label frame].origin.x +
[o_label frame].size.width + 3,
-2, 0, o_tooltip ) -2, 0, o_tooltip )
[o_popup setAutoresizingMask:NSViewWidthSizable ]; [o_popup setAutoresizingMask:NSViewWidthSizable ];
...@@ -1962,7 +2026,8 @@ fprintf( stderr, "Applying %f to %s\n" , [self floatValue], psz_name ); ...@@ -1962,7 +2026,8 @@ fprintf( stderr, "Applying %f to %s\n" , [self floatValue], psz_name );
o_keys_menu = [[NSMenu alloc] initWithTitle: @"Keys Menu"]; o_keys_menu = [[NSMenu alloc] initWithTitle: @"Keys Menu"];
for ( i = 0; i < sizeof(vlc_keys) / sizeof(key_descriptor_t); i++) for ( i = 0; i < sizeof(vlc_keys) / sizeof(key_descriptor_t); i++)
if( vlc_keys[i].psz_key_string && *vlc_keys[i].psz_key_string ) if( vlc_keys[i].psz_key_string && *vlc_keys[i].psz_key_string )
POPULATE_A_KEY( o_keys_menu, [NSString stringWithCString:vlc_keys[i].psz_key_string] POPULATE_A_KEY( o_keys_menu,
[NSString stringWithCString:vlc_keys[i].psz_key_string]
, vlc_keys[i].i_key_code) , vlc_keys[i].i_key_code)
} }
[o_popup setMenu:[o_keys_menu copyWithZone:nil]]; [o_popup setMenu:[o_keys_menu copyWithZone:nil]];
...@@ -1983,11 +2048,9 @@ fprintf( stderr, "Applying %f to %s\n" , [self floatValue], psz_name ); ...@@ -1983,11 +2048,9 @@ fprintf( stderr, "Applying %f to %s\n" , [self floatValue], psz_name );
{ {
return [o_popup selectedTag]; return [o_popup selectedTag];
} }
@end @end
@implementation ModuleListConfigControl @implementation ModuleListConfigControl
- (id) initWithItem: (module_config_t *)_p_item - (id) initWithItem: (module_config_t *)_p_item
withView: (NSView *)o_parent_view withView: (NSView *)o_parent_view
withVerticalOffset: (int)i_yPos withVerticalOffset: (int)i_yPos
...@@ -2023,8 +2086,10 @@ if( _p_item->i_type == CONFIG_ITEM_MODULE_LIST ) ...@@ -2023,8 +2086,10 @@ if( _p_item->i_type == CONFIG_ITEM_MODULE_LIST )
if( p_config->i_type == CONFIG_SUBCATEGORY && if( p_config->i_type == CONFIG_SUBCATEGORY &&
p_config->i_value == _p_item->i_min ) p_config->i_value == _p_item->i_min )
{ {
o_modulelongname = [NSString stringWithCString:p_parser->psz_longname]; o_modulelongname = [NSString stringWithCString:
o_modulename = [NSString stringWithCString:p_parser->psz_object_name]; p_parser->psz_longname];
o_modulename = [NSString stringWithCString:
p_parser->psz_object_name];
if( _p_item->psz_value && if( _p_item->psz_value &&
strstr( _p_item->psz_value, p_parser->psz_object_name ) ) strstr( _p_item->psz_value, p_parser->psz_object_name ) )
...@@ -2032,7 +2097,9 @@ if( _p_item->i_type == CONFIG_ITEM_MODULE_LIST ) ...@@ -2032,7 +2097,9 @@ if( _p_item->i_type == CONFIG_ITEM_MODULE_LIST )
else else
o_moduleenabled = [NSNumber numberWithBool:NO]; o_moduleenabled = [NSNumber numberWithBool:NO];
[o_modulearray addObject:[NSMutableArray arrayWithObjects: o_modulename, o_modulelongname, o_moduleenabled, nil]]; [o_modulearray addObject:[NSMutableArray
arrayWithObjects: o_modulename, o_modulelongname,
o_moduleenabled, nil]];
} }
} while( p_config->i_type != CONFIG_HINT_END && p_config++ ); } while( p_config->i_type != CONFIG_HINT_END && p_config++ );
} }
...@@ -2046,7 +2113,8 @@ if( _p_item->i_type == CONFIG_ITEM_MODULE_LIST ) ...@@ -2046,7 +2113,8 @@ if( _p_item->i_type == CONFIG_ITEM_MODULE_LIST )
{ {
/* add the label */ /* add the label */
if( p_item->psz_text ) if( p_item->psz_text )
o_labelString = [[VLCMain sharedInstance] localizedString: p_item->psz_text]; o_labelString = [[VLCMain sharedInstance]
localizedString: p_item->psz_text];
else else
o_labelString = [NSString stringWithString:@""]; o_labelString = [NSString stringWithString:@""];
ADD_LABEL( o_label, mainFrame, 0, -3, o_labelString ) ADD_LABEL( o_label, mainFrame, 0, -3, o_labelString )
...@@ -2055,14 +2123,16 @@ if( _p_item->i_type == CONFIG_ITEM_MODULE_LIST ) ...@@ -2055,14 +2123,16 @@ if( _p_item->i_type == CONFIG_ITEM_MODULE_LIST )
/* build the textfield */ /* build the textfield */
o_tooltip = [[VLCMain sharedInstance] wrapString: o_tooltip = [[VLCMain sharedInstance] wrapString:
[[VLCMain sharedInstance] localizedString: p_item->psz_longtext ] toWidth: PREFS_WRAP]; [[VLCMain sharedInstance]
localizedString: p_item->psz_longtext ] toWidth: PREFS_WRAP];
if( p_item->psz_value ) if( p_item->psz_value )
o_textfieldString = [[VLCMain sharedInstance] localizedString: p_item->psz_value]; o_textfieldString = [[VLCMain sharedInstance]
localizedString: p_item->psz_value];
else else
o_textfieldString = [NSString stringWithString: @""]; o_textfieldString = [NSString stringWithString: @""];
ADD_TEXTFIELD( o_textfield, mainFrame, [o_label frame].size.width + 2, ADD_TEXTFIELD( o_textfield, mainFrame, [o_label frame].size.width + 2,
mainFrame.size.height - 22, mainFrame.size.width - [o_label frame].size.width - 2, mainFrame.size.height - 22, mainFrame.size.width -
o_tooltip, o_textfieldString ) [o_label frame].size.width - 2, o_tooltip, o_textfieldString )
[o_textfield setAutoresizingMask:NSViewWidthSizable ]; [o_textfield setAutoresizingMask:NSViewWidthSizable ];
[self addSubview: o_textfield]; [self addSubview: o_textfield];
...@@ -2091,7 +2161,8 @@ if( _p_item->i_type == CONFIG_ITEM_MODULE_LIST ) ...@@ -2091,7 +2161,8 @@ if( _p_item->i_type == CONFIG_ITEM_MODULE_LIST )
[(NSButtonCell*)o_dataCell setButtonType:NSSwitchButton]; [(NSButtonCell*)o_dataCell setButtonType:NSSwitchButton];
[o_dataCell setTitle:@""]; [o_dataCell setTitle:@""];
[o_dataCell setFont:[NSFont systemFontOfSize:0]]; [o_dataCell setFont:[NSFont systemFontOfSize:0]];
NSTableColumn *o_tableColumn = [[NSTableColumn alloc]initWithIdentifier:[NSString stringWithCString: "Enabled"]]; NSTableColumn *o_tableColumn = [[NSTableColumn alloc]
initWithIdentifier:[NSString stringWithCString: "Enabled"]];
[o_tableColumn setHeaderCell: o_headerCell]; [o_tableColumn setHeaderCell: o_headerCell];
[o_tableColumn setDataCell: o_dataCell]; [o_tableColumn setDataCell: o_dataCell];
[o_tableColumn setWidth:17]; [o_tableColumn setWidth:17];
...@@ -2100,7 +2171,8 @@ if( _p_item->i_type == CONFIG_ITEM_MODULE_LIST ) ...@@ -2100,7 +2171,8 @@ if( _p_item->i_type == CONFIG_ITEM_MODULE_LIST )
o_headerCell = [[NSCell alloc] initTextCell:@"Module Name"]; o_headerCell = [[NSCell alloc] initTextCell:@"Module Name"];
o_dataCell = [[NSTextFieldCell alloc] init]; o_dataCell = [[NSTextFieldCell alloc] init];
[o_dataCell setFont:[NSFont systemFontOfSize:12]]; [o_dataCell setFont:[NSFont systemFontOfSize:12]];
o_tableColumn = [[NSTableColumn alloc]initWithIdentifier:[NSString stringWithCString: "Module"]]; o_tableColumn = [[NSTableColumn alloc]
initWithIdentifier:[NSString stringWithCString: "Module"]];
[o_tableColumn setHeaderCell: o_headerCell]; [o_tableColumn setHeaderCell: o_headerCell];
[o_tableColumn setDataCell: o_dataCell]; [o_tableColumn setDataCell: o_dataCell];
[o_tableColumn setWidth:388 - 17]; [o_tableColumn setWidth:388 - 17];
...@@ -2111,7 +2183,8 @@ if( _p_item->i_type == CONFIG_ITEM_MODULE_LIST ) ...@@ -2111,7 +2183,8 @@ if( _p_item->i_type == CONFIG_ITEM_MODULE_LIST )
[o_tableview setDataSource:self]; [o_tableview setDataSource:self];
[o_tableview setTarget: self]; [o_tableview setTarget: self];
[o_tableview setAction: @selector(tableChanged:)]; [o_tableview setAction: @selector(tableChanged:)];
[o_tableview sendActionOn:NSLeftMouseUpMask|NSLeftMouseDownMask|NSLeftMouseDraggedMask]; [o_tableview sendActionOn:NSLeftMouseUpMask | NSLeftMouseDownMask |
NSLeftMouseDraggedMask];
[o_scrollview setDocumentView: o_tableview]; [o_scrollview setDocumentView: o_tableview];
} }
[o_scrollview setAutoresizingMask:NSViewWidthSizable ]; [o_scrollview setAutoresizingMask:NSViewWidthSizable ];
...@@ -2127,13 +2200,16 @@ if( _p_item->i_type == CONFIG_ITEM_MODULE_LIST ) ...@@ -2127,13 +2200,16 @@ if( _p_item->i_type == CONFIG_ITEM_MODULE_LIST )
NSString *o_newstring = @""; NSString *o_newstring = @"";
unsigned int i; unsigned int i;
for( i = 0 ; i < [o_modulearray count] ; i++ ) for( i = 0 ; i < [o_modulearray count] ; i++ )
if( [[[o_modulearray objectAtIndex:i] objectAtIndex:2] boolValue] != NO ) if( [[[o_modulearray objectAtIndex:i] objectAtIndex:2]
boolValue] != NO )
{ {
o_newstring = [o_newstring stringByAppendingString:[[o_modulearray objectAtIndex:i] objectAtIndex:0]]; o_newstring = [o_newstring stringByAppendingString:
[[o_modulearray objectAtIndex:i] objectAtIndex:0]];
o_newstring = [o_newstring stringByAppendingString:@","]; o_newstring = [o_newstring stringByAppendingString:@","];
} }
[o_textfield setStringValue: [o_newstring substringToIndex: ([o_newstring length])?[o_newstring length] - 1:0]]; [o_textfield setStringValue: [o_newstring
substringToIndex: ([o_newstring length])?[o_newstring length] - 1:0]];
} }
- (void)dealloc - (void)dealloc
...@@ -2152,7 +2228,8 @@ if( _p_item->i_type == CONFIG_ITEM_MODULE_LIST ) ...@@ -2152,7 +2228,8 @@ if( _p_item->i_type == CONFIG_ITEM_MODULE_LIST )
@implementation ModuleListConfigControl (NSTableDataSource) @implementation ModuleListConfigControl (NSTableDataSource)
- (BOOL)tableView:(NSTableView*)table writeRows:(NSArray*)rows toPasteboard:(NSPasteboard*)pb - (BOOL)tableView:(NSTableView*)table writeRows:(NSArray*)rows
toPasteboard:(NSPasteboard*)pb
{ {
// We only want to allow dragging of selected rows. // We only want to allow dragging of selected rows.
NSEnumerator *iter = [rows objectEnumerator]; NSEnumerator *iter = [rows objectEnumerator];
...@@ -2163,13 +2240,15 @@ if( _p_item->i_type == CONFIG_ITEM_MODULE_LIST ) ...@@ -2163,13 +2240,15 @@ if( _p_item->i_type == CONFIG_ITEM_MODULE_LIST )
return NO; return NO;
} }
[pb declareTypes:[NSArray arrayWithObject:@"VLC media player module"] owner:nil]; [pb declareTypes:[NSArray
arrayWithObject:@"VLC media player module"] owner:nil];
[pb setPropertyList:rows forType:@"VLC media player module"]; [pb setPropertyList:rows forType:@"VLC media player module"];
return YES; return YES;
} }
- (NSDragOperation)tableView:(NSTableView*)table validateDrop:(id <NSDraggingInfo>)info proposedRow:(int)row proposedDropOperation:(NSTableViewDropOperation)op - (NSDragOperation)tableView:(NSTableView*)table
validateDrop:(id <NSDraggingInfo>)info proposedRow:(int)row
proposedDropOperation:(NSTableViewDropOperation)op
{ {
// Make drops at the end of the table go to the end. // Make drops at the end of the table go to the end.
if (row == -1) if (row == -1)
...@@ -2185,7 +2264,8 @@ if( _p_item->i_type == CONFIG_ITEM_MODULE_LIST ) ...@@ -2185,7 +2264,8 @@ if( _p_item->i_type == CONFIG_ITEM_MODULE_LIST )
return NSTableViewDropAbove; return NSTableViewDropAbove;
} }
- (BOOL)tableView:(NSTableView*)table acceptDrop:(id <NSDraggingInfo>)info row:(int)dropRow dropOperation:(NSTableViewDropOperation)op; - (BOOL)tableView:(NSTableView*)table acceptDrop:(id <NSDraggingInfo>)info
row:(int)dropRow dropOperation:(NSTableViewDropOperation)op;
{ {
NSPasteboard *pb = [info draggingPasteboard]; NSPasteboard *pb = [info draggingPasteboard];
NSDragOperation srcMask = [info draggingSourceOperationMask]; NSDragOperation srcMask = [info draggingSourceOperationMask];
...@@ -2196,18 +2276,21 @@ if( _p_item->i_type == CONFIG_ITEM_MODULE_LIST ) ...@@ -2196,18 +2276,21 @@ if( _p_item->i_type == CONFIG_ITEM_MODULE_LIST )
NSArray *array; NSArray *array;
// Intra-table drag - data is the array of rows. // Intra-table drag - data is the array of rows.
if (!accepted && (array = [pb propertyListForType:@"VLC media player module"]) != NULL) if (!accepted && (array =
[pb propertyListForType:@"VLC media player module"]) != NULL)
{ {
NSEnumerator * iter = nil; NSEnumerator *iter = nil;
id val; id val;
BOOL isCopy = (srcMask & NSDragOperationMove) ? NO:YES; BOOL isCopy = (srcMask & NSDragOperationMove) ? NO:YES;
// Move the modules // Move the modules
iter = [array objectEnumerator]; iter = [array objectEnumerator];
while ((val = [iter nextObject]) != NULL) while ((val = [iter nextObject]) != NULL)
{ {
NSArray *o_tmp = [[o_modulearray objectAtIndex:[val intValue]] mutableCopyWithZone:nil]; NSArray *o_tmp = [[o_modulearray objectAtIndex:
[val intValue]] mutableCopyWithZone:nil];
[o_modulearray removeObject:o_tmp]; [o_modulearray removeObject:o_tmp];
[o_modulearray insertObject:o_tmp atIndex:(dropRow>[val intValue]) ? dropRow - 1 : dropRow]; [o_modulearray insertObject:o_tmp
atIndex:(dropRow>[val intValue]) ? dropRow - 1 : dropRow];
dropRow++; dropRow++;
} }
...@@ -2241,18 +2324,23 @@ if( _p_item->i_type == CONFIG_ITEM_MODULE_LIST ) ...@@ -2241,18 +2324,23 @@ if( _p_item->i_type == CONFIG_ITEM_MODULE_LIST )
return [o_modulearray count]; return [o_modulearray count];
} }
- (id)tableView:(NSTableView *)aTableView objectValueForTableColumn:(NSTableColumn *)aTableColumn row:(int)rowIndex - (id)tableView:(NSTableView *)aTableView
objectValueForTableColumn:(NSTableColumn *)aTableColumn row:(int)rowIndex
{ {
if( [[aTableColumn identifier] isEqualToString:[NSString stringWithCString:"Enabled"]] ) if( [[aTableColumn identifier] isEqualToString:
[NSString stringWithCString:"Enabled"]] )
return [[o_modulearray objectAtIndex:rowIndex] objectAtIndex:2]; return [[o_modulearray objectAtIndex:rowIndex] objectAtIndex:2];
if( [[aTableColumn identifier] isEqualToString:[NSString stringWithCString:"Module"]] ) if( [[aTableColumn identifier] isEqualToString:
[NSString stringWithCString:"Module"]] )
return [[o_modulearray objectAtIndex:rowIndex] objectAtIndex:1]; return [[o_modulearray objectAtIndex:rowIndex] objectAtIndex:1];
return nil; return nil;
} }
- (void)tableView:(NSTableView *)aTableView setObjectValue:(id)anObject forTableColumn:(NSTableColumn *)aTableColumn row:(int)rowIndex - (void)tableView:(NSTableView *)aTableView setObjectValue:(id)anObject
forTableColumn:(NSTableColumn *)aTableColumn row:(int)rowIndex
{ {
[[o_modulearray objectAtIndex:rowIndex] replaceObjectAtIndex:2 withObject: anObject]; [[o_modulearray objectAtIndex:rowIndex] replaceObjectAtIndex:2
withObject: anObject];
} }
@end @end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment