X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=modules%2Fgui%2Fmacosx%2Fprefs_widgets.m;h=d444d176fdb29af7604d2e01dac18f87c3ca34b4;hb=ef61df309612786ed316534908978a2a9340e154;hp=90c187f6f88c6260610dadb424ff6824b95a1e9b;hpb=5af8cc2e44cfa73e385ef5d5b2d25c7d25499c63;p=vlc diff --git a/modules/gui/macosx/prefs_widgets.m b/modules/gui/macosx/prefs_widgets.m index 90c187f6f8..d444d176fd 100644 --- a/modules/gui/macosx/prefs_widgets.m +++ b/modules/gui/macosx/prefs_widgets.m @@ -33,7 +33,7 @@ #endif #include -#include "vlc_keys.h" +#include #include "intf.h" #include "prefs_widgets.h" @@ -863,17 +863,17 @@ o_textfield = [[[NSSecureTextField alloc] initWithFrame: s_rc] retain]; \ 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; } @@ -926,7 +926,11 @@ o_textfield = [[[NSSecureTextField alloc] initWithFrame: s_rc] retain]; \ } } -- (int)getLabelSize +- (void)resetValues +{ +} + +- (int)labelSize { return [o_label frame].size.width; } @@ -1017,8 +1021,21 @@ o_textfield = [[[NSSecureTextField alloc] initWithFrame: s_rc] retain]; \ - (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 @@ -1057,9 +1074,13 @@ o_textfield = [[[NSSecureTextField alloc] initWithFrame: s_rc] retain]; \ -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; @@ -1093,15 +1114,34 @@ o_textfield = [[[NSSecureTextField alloc] initWithFrame: s_rc] retain]; \ 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] ) { @@ -1132,7 +1172,7 @@ o_textfield = [[[NSSecureTextField alloc] initWithFrame: s_rc] retain]; \ 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 ) @@ -1214,6 +1254,19 @@ o_textfield = [[[NSSecureTextField alloc] initWithFrame: s_rc] retain]; \ 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 @@ -1229,8 +1282,6 @@ o_textfield = [[[NSSecureTextField alloc] initWithFrame: s_rc] retain]; \ 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: @@ -1255,53 +1306,7 @@ o_textfield = [[[NSSecureTextField alloc] initWithFrame: s_rc] retain]; \ [[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; @@ -1381,6 +1386,68 @@ o_textfield = [[[NSSecureTextField alloc] initWithFrame: s_rc] retain]; \ 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 @@ -1471,6 +1538,12 @@ o_textfield = [[[NSSecureTextField alloc] initWithFrame: s_rc] retain]; \ return [o_textfield intValue]; } +-(void)resetValues +{ + [o_textfield setIntValue: config_GetInt(VLCIntf, p_item->psz_name)]; + [super resetValues]; +} + @end @implementation IntegerListConfigControl @@ -1547,15 +1620,29 @@ o_textfield = [[[NSSecureTextField alloc] initWithFrame: s_rc] retain]; \ 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] @@ -1674,6 +1761,14 @@ o_textfield = [[[NSSecureTextField alloc] initWithFrame: s_rc] retain]; \ { 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 @@ -1764,6 +1859,12 @@ o_textfield = [[[NSSecureTextField alloc] initWithFrame: s_rc] retain]; \ { return [o_stepper floatValue]; } + +- (void)resetValues +{ + [o_textfield setFloatValue: config_GetFloat( VLCIntf, p_item->psz_name)]; + [super resetValues]; +} @end @implementation RangedFloatConfigControl @@ -1876,6 +1977,12 @@ o_textfield = [[[NSSecureTextField alloc] initWithFrame: s_rc] retain]; \ 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 @@ -1926,6 +2033,11 @@ o_textfield = [[[NSSecureTextField alloc] initWithFrame: s_rc] retain]; \ return [o_checkbox intValue]; } +- (void)resetValues +{ + [o_checkbox setState: config_GetInt( VLCIntf, p_item->psz_name)]; + [super resetValues]; +} @end @implementation KeyConfigControl @@ -1967,11 +2079,14 @@ o_textfield = [[[NSSecureTextField alloc] initWithFrame: s_rc] retain]; \ { 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]]; @@ -2005,13 +2120,19 @@ o_textfield = [[[NSSecureTextField alloc] initWithFrame: s_rc] retain]; \ { 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; @@ -2033,12 +2154,12 @@ if( _p_item->i_type == CONFIG_ITEM_MODULE_LIST ) 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; @@ -2062,6 +2183,7 @@ if( _p_item->i_type == CONFIG_ITEM_MODULE_LIST ) o_moduleenabled, nil]]; } } + module_config_free( p_configlist ); } module_list_free( p_list ); @@ -2192,6 +2314,13 @@ if( _p_item->i_type == CONFIG_ITEM_MODULE_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) @@ -2215,7 +2344,7 @@ if( _p_item->i_type == CONFIG_ITEM_MODULE_LIST ) } - (NSDragOperation)tableView:(NSTableView*)table - validateDrop:(id )info proposedRow:(int)row + validateDrop:(id )info proposedRow:(NSInteger)row proposedDropOperation:(NSTableViewDropOperation)op { // Make drops at the end of the table go to the end. @@ -2233,7 +2362,7 @@ if( _p_item->i_type == CONFIG_ITEM_MODULE_LIST ) } - (BOOL)tableView:(NSTableView*)table acceptDrop:(id )info - row:(int)dropRow dropOperation:(NSTableViewDropOperation)op; + row:(NSInteger)dropRow dropOperation:(NSTableViewDropOperation)op; { NSPasteboard *pb = [info draggingPasteboard]; NSDragOperation srcMask = [info draggingSourceOperationMask]; @@ -2287,13 +2416,13 @@ if( _p_item->i_type == CONFIG_ITEM_MODULE_LIST ) 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]; @@ -2304,7 +2433,7 @@ if( _p_item->i_type == CONFIG_ITEM_MODULE_LIST ) } - (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];