#endif
#include <vlc_common.h>
-#include "vlc_keys.h"
+#include <vlc_keys.h>
#include "intf.h"
#include "prefs_widgets.h"
break;
}
break;
- switch( i_lastItem )
- {
- case CONFIG_ITEM_STRING:
- case CONFIG_ITEM_PASSWORD:
- i_margin = 8;
- break;
- case CONFIG_ITEM_STRING_LIST:
- i_margin = 7;
- break;
- case CONFIG_ITEM_FILE:
- i_margin = 8;
- break;
- case CONFIG_ITEM_MODULE:
- i_margin = 4;
- break;
- case CONFIG_ITEM_INTEGER:
- i_margin = 7;
- break;
- case CONFIG_ITEM_RANGED_INTEGER:
- i_margin = 5;
- break;
- case CONFIG_ITEM_BOOL:
- i_margin = 7;
- break;
- case CONFIG_ITEM_KEY_AFTER_10_3:
- i_margin = 6;
- break;
- case CONFIG_ITEM_MODULE_LIST:
- i_margin = 8;
- break;
- default:
- i_margin = 20;
- break;
- }
- break;
case CONFIG_ITEM_STRING_LIST:
switch( i_lastItem )
{
return p_control;
}
-- (NSString *)getName
+- (NSString *)name
{
return [[VLCMain sharedInstance] localizedString: psz_name];
}
-- (int)getType
+- (int)type
{
return i_type;
}
-- (int)getViewType
+- (int)viewType
{
return i_view_type;
}
}
}
-- (int)getLabelSize
+- (void)resetValues
+{
+}
+
+- (int)labelSize
{
return [o_label frame].size.width;
}
- (char *)stringValue
{
- return strdup( [[VLCMain sharedInstance] delocalizeString:
- [o_textfield stringValue]] );
+ return [[VLCMain sharedInstance] delocalizeString:
+ [o_textfield stringValue]];
+}
+
+- (void)resetValues
+{
+ NSString *o_textfieldString;
+ char *psz_value = config_GetPsz( VLCIntf, p_item->psz_name );
+ if( psz_value )
+ o_textfieldString = [[VLCMain sharedInstance]
+ localizedString: psz_value];
+ else
+ o_textfieldString = [NSString stringWithString: @""];
+ free( psz_value );
+ [super resetValues];
}
@end
-2, 0, o_textfieldTooltip )
[o_combo setAutoresizingMask:NSViewWidthSizable ];
for( i_index = 0; i_index < p_item->i_list; i_index++ )
- if( p_item->value.psz &&
+ {
+ if( !p_item->value.psz && !p_item->ppsz_list[i_index] )
+ [o_combo selectItemAtIndex: i_index];
+ else if( p_item->value.psz && p_item->ppsz_list[i_index] &&
!strcmp( p_item->value.psz, p_item->ppsz_list[i_index] ) )
[o_combo selectItemAtIndex: i_index];
+ }
[self addSubview: o_combo];
}
return self;
return strdup( [[VLCMain sharedInstance]
delocalizeString: [o_combo stringValue]] );
}
+
+- (void)resetValues
+{
+ int i_index;
+ [o_combo reloadData];
+ char *psz_value = config_GetPsz( VLCIntf, p_item->psz_name );
+
+ for( i_index = 0; i_index < p_item->i_list; i_index++ )
+ {
+ if( !psz_value && !p_item->ppsz_list[i_index] )
+ [o_combo selectItemAtIndex: i_index];
+ else if( psz_value && p_item->ppsz_list[i_index] &&
+ !strcmp( psz_value, p_item->ppsz_list[i_index] ) )
+ [o_combo selectItemAtIndex: i_index];
+ }
+
+ free( psz_value );
+ [super resetValues];
+}
@end
@implementation StringListConfigControl (NSComboBoxDataSource)
-- (int)numberOfItemsInComboBox:(NSComboBox *)aComboBox
+- (NSInteger)numberOfItemsInComboBox:(NSComboBox *)aComboBox
{
return p_item->i_list;
}
-- (id)comboBox:(NSComboBox *)aComboBox objectValueForItemAtIndex:(int)i_index
+- (id)comboBox:(NSComboBox *)aComboBox objectValueForItemAtIndex:(NSInteger)i_index
{
if( p_item->ppsz_list_text && p_item->ppsz_list_text[i_index] )
{
localizedString: (char *)p_item->psz_longtext ] toWidth: PREFS_WRAP];
/* is it a directory */
- b_directory = ( [self getType] == CONFIG_ITEM_DIRECTORY ) ? YES : NO;
+ b_directory = ( [self type] == CONFIG_ITEM_DIRECTORY ) ? YES : NO;
/* add the label */
if( p_item->psz_text )
else
return NULL;
}
+
+-(void)resetValues
+{
+ NSString *o_textfieldString;
+ char *psz_value = config_GetPsz( VLCIntf, p_item->psz_name );
+ if( psz_value )
+ o_textfieldString = [NSString stringWithFormat: @"%s", psz_value];
+ else
+ o_textfieldString = [NSString stringWithString: @""];
+
+ free(psz_value);
+ [super resetValues];
+}
@end
@implementation ModuleConfigControl
if( [super initWithFrame: mainFrame item: _p_item] != nil )
{
- size_t i_index;
- module_t *p_parser, **p_list;
i_view_type = CONFIG_ITEM_MODULE;
o_popupTooltip = [[VLCMain sharedInstance] wrapString:
[[o_popup lastItem] setTag: -1];
[o_popup selectItem: [o_popup lastItem]];
- /* build a list of available modules */
- p_list = module_list_get( NULL );
- for( i_index = 0; p_list[i_index]; i_index++ )
- {
- p_parser = p_list[i_index];
-
- if( p_item->i_type == CONFIG_ITEM_MODULE )
- {
- if( module_provides( p_parser, p_item->psz_type ) )
- {
- NSString *o_description = [[VLCMain sharedInstance]
- localizedString: module_GetLongName( p_parser )];
- [o_popup addItemWithTitle: o_description];
-
- if( p_item->value.psz &&
- !strcmp( p_item->value.psz, module_get_object( p_parser ) ) )
- [o_popup selectItem:[o_popup lastItem]];
- }
- }
- else
- {
- int i;
-
- if( module_is_main( p_parser ) )
- continue;
- unsigned int confsize;
- unsigned int unused;
- module_config_get( p_parser, &confsize );
- for ( i = 0; i < confsize; i++ )
- {
- module_config_t *p_config = module_config_get( p_parser, &unused ) + i;
- /* Hack: required subcategory is stored in i_min */
- if( p_config->i_type == CONFIG_SUBCATEGORY &&
- p_config->value.i == p_item->min.i )
- {
- NSString *o_description = [[VLCMain sharedInstance]
- localizedString: module_GetLongName( p_parser )];
- [o_popup addItemWithTitle: o_description];
-
- if( p_item->value.psz && !strcmp(p_item->value.psz,
- module_get_object( p_parser )) )
- [o_popup selectItem:[o_popup lastItem]];
- }
- }
- }
- }
- module_list_free( p_list );
+ [self resetValues];
[self addSubview: o_popup];
}
return self;
module_list_free( p_list );
return returnval;
}
+
+-(void)resetValues
+{
+ /* build a list of available modules */
+ size_t i_index;
+ module_t *p_parser, **p_list;
+
+ p_list = module_list_get( NULL );
+ for( i_index = 0; p_list[i_index]; i_index++ )
+ {
+ p_parser = p_list[i_index];
+
+ if( p_item->i_type == CONFIG_ITEM_MODULE )
+ {
+ if( module_provides( p_parser, p_item->psz_type ) )
+ {
+ NSString *o_description = [[VLCMain sharedInstance]
+ localizedString: module_GetLongName( p_parser )];
+ [o_popup addItemWithTitle: o_description];
+ char *psz_value = config_GetPsz( VLCIntf, p_item->psz_name );
+
+ if( psz_value &&
+ !strcmp( psz_value, module_get_object( p_parser ) ) )
+ [o_popup selectItem:[o_popup lastItem]];
+
+ free(psz_value);
+ }
+ }
+ else
+ {
+ int i;
+
+ if( module_is_main( p_parser ) )
+ continue;
+ unsigned int confsize;
+ unsigned int unused;
+ module_config_t *p_configlist = module_config_get( p_parser, &confsize );
+ for ( i = 0; i < confsize; i++ )
+ {
+ module_config_t *p_config = &p_configlist[i];
+ /* Hack: required subcategory is stored in i_min */
+ if( p_config->i_type == CONFIG_SUBCATEGORY &&
+ config_GetInt( VLCIntf, p_item->psz_name) == p_item->min.i )
+ {
+ NSString *o_description = [[VLCMain sharedInstance]
+ localizedString: module_GetLongName( p_parser )];
+ [o_popup addItemWithTitle: o_description];
+ char *psz_value = config_GetPsz( VLCIntf, p_item->psz_name );
+
+ if( psz_value && !strcmp(psz_value,
+ module_get_object( p_parser )) )
+ [o_popup selectItem:[o_popup lastItem]];
+
+ free( psz_value );
+ }
+ }
+ module_config_free( p_configlist );
+ }
+ }
+ module_list_free( p_list );
+ [super resetValues];
+}
@end
@implementation IntegerConfigControl
return [o_textfield intValue];
}
+-(void)resetValues
+{
+ [o_textfield setIntValue: config_GetInt(VLCIntf, p_item->psz_name)];
+ [super resetValues];
+}
+
@end
@implementation IntegerListConfigControl
else
return [o_combo intValue];
}
+
+-(void)resetValues
+{
+ int i_index;
+ [o_combo reloadData];
+ for( i_index = 0; i_index < p_item->i_list; i_index++ )
+ {
+ if( config_GetInt( VLCIntf, p_item->psz_name) == p_item->pi_list[i_index] )
+ {
+ [o_combo selectItemAtIndex: i_index];
+ }
+ }
+
+}
@end
@implementation IntegerListConfigControl (NSComboBoxDataSource)
-- (int)numberOfItemsInComboBox:(NSComboBox *)aComboBox
+- (NSInteger)numberOfItemsInComboBox:(NSComboBox *)aComboBox
{
return p_item->i_list;
}
-- (id)comboBox:(NSComboBox *)aComboBox objectValueForItemAtIndex:(int)i_index
+- (id)comboBox:(NSComboBox *)aComboBox objectValueForItemAtIndex:(NSInteger)i_index
{
if( p_item->ppsz_list_text && p_item->ppsz_list_text[i_index] )
return [[VLCMain sharedInstance]
{
return [o_slider intValue];
}
+
+- (void)resetValues
+{
+ int value = config_GetInt( VLCIntf, p_item->psz_name );
+ [o_textfield setIntValue:value];
+ [o_slider setIntValue:value];
+ [super resetValues];
+}
@end
@implementation FloatConfigControl
{
return [o_stepper floatValue];
}
+
+- (void)resetValues
+{
+ [o_textfield setFloatValue: config_GetFloat( VLCIntf, p_item->psz_name)];
+ [super resetValues];
+}
@end
@implementation RangedFloatConfigControl
return [o_slider floatValue];
}
+- (void)resetValues
+{
+ [o_textfield setFloatValue: config_GetFloat(VLCIntf, p_item->psz_name)];
+ [o_slider setFloatValue: config_GetFloat(VLCIntf, p_item->psz_name)];
+ [super resetValues];
+}
@end
@implementation BoolConfigControl
return [o_checkbox intValue];
}
+- (void)resetValues
+{
+ [o_checkbox setState: config_GetInt( VLCIntf, p_item->psz_name)];
+ [super resetValues];
+}
@end
@implementation KeyConfigControl
{
unsigned int i;
o_keys_menu = [[NSMenu alloc] initWithTitle: @"Keys Menu"];
+#warning This does not work anymore. FIXME.
+#if 0
for ( i = 0; i < sizeof(vlc_keys) / sizeof(key_descriptor_t); i++)
if( vlc_keys[i].psz_key_string )
POPULATE_A_KEY( o_keys_menu,
[NSString stringWithUTF8String:vlc_keys[i].psz_key_string]
, vlc_keys[i].i_key_code)
+#endif
}
[o_popup setMenu:[o_keys_menu copyWithZone:nil]];
[o_popup selectItem:[[o_popup menu] itemWithTag:p_item->value.i]];
{
return [o_popup selectedTag];
}
+
+- (void)resetValues
+{
+ [o_popup selectItem:[[o_popup menu] itemWithTag:config_GetInt( VLCIntf, p_item->psz_name )]];
+ [super resetValues];
+}
@end
@implementation ModuleListConfigControl
- (id) initWithItem: (module_config_t *)_p_item
withView: (NSView *)o_parent_view
{
-if( _p_item->i_type == CONFIG_ITEM_MODULE_LIST )
+ if( _p_item->i_type == CONFIG_ITEM_MODULE_LIST )
//TODO....
return nil;
continue;
unsigned int confsize;
- module_config_get( p_parser, &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 = module_config_get( p_parser, &unused ) + i;
+ module_config_t *p_config = &p_configlist[i];
NSString *o_modulelongname, *o_modulename;
NSNumber *o_moduleenabled = nil;
o_moduleenabled, nil]];
}
}
+ module_config_free( p_configlist );
}
module_list_free( p_list );
return strdup( [[o_textfield stringValue] UTF8String] );
}
+-(void)resetValues
+{
+#warning Reset prefs of the module selector is broken atm.
+ NSLog( @"don't forget about modulelistconfig" );
+ [super resetValues];
+}
+
@end
@implementation ModuleListConfigControl (NSTableDataSource)
}
- (NSDragOperation)tableView:(NSTableView*)table
- validateDrop:(id <NSDraggingInfo>)info proposedRow:(int)row
+ validateDrop:(id <NSDraggingInfo>)info proposedRow:(NSInteger)row
proposedDropOperation:(NSTableViewDropOperation)op
{
// Make drops at the end of the table go to the end.
}
- (BOOL)tableView:(NSTableView*)table acceptDrop:(id <NSDraggingInfo>)info
- row:(int)dropRow dropOperation:(NSTableViewDropOperation)op;
+ row:(NSInteger)dropRow dropOperation:(NSTableViewDropOperation)op;
{
NSPasteboard *pb = [info draggingPasteboard];
NSDragOperation srcMask = [info draggingSourceOperationMask];
return accepted;
}
-- (int)numberOfRowsInTableView:(NSTableView *)aTableView
+- (NSInteger)numberOfRowsInTableView:(NSTableView *)aTableView
{
return [o_modulearray count];
}
- (id)tableView:(NSTableView *)aTableView
- objectValueForTableColumn:(NSTableColumn *)aTableColumn row:(int)rowIndex
+ objectValueForTableColumn:(NSTableColumn *)aTableColumn row:(NSInteger)rowIndex
{
if( [[aTableColumn identifier] isEqualToString: @"Enabled"] )
return [[o_modulearray objectAtIndex:rowIndex] objectAtIndex:2];
}
- (void)tableView:(NSTableView *)aTableView setObjectValue:(id)anObject
- forTableColumn:(NSTableColumn *)aTableColumn row:(int)rowIndex
+ forTableColumn:(NSTableColumn *)aTableColumn row:(NSInteger)rowIndex
{
[[o_modulearray objectAtIndex:rowIndex] replaceObjectAtIndex:2
withObject: anObject];