X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=modules%2Fgui%2Fmacosx%2Fprefs_widgets.m;h=90c187f6f88c6260610dadb424ff6824b95a1e9b;hb=828d8c8a67910e1df772832da0004748de040279;hp=01ee64ecce4e006a3f62faf7824cbbfbe248d087;hpb=a1bd8b94477962ef495117ea161246172ce83859;p=vlc diff --git a/modules/gui/macosx/prefs_widgets.m b/modules/gui/macosx/prefs_widgets.m index 01ee64ecce..90c187f6f8 100644 --- a/modules/gui/macosx/prefs_widgets.m +++ b/modules/gui/macosx/prefs_widgets.m @@ -280,6 +280,20 @@ [o_textfield setStringValue: init_value]; \ } +#define ADD_SECURETEXTFIELD( o_textfield, superFrame, x_offset, my_y_offset, \ +my_width, tooltip, init_value ) \ +{ \ +NSRect s_rc = superFrame; \ +s_rc.origin.x = x_offset; \ +s_rc.origin.y = my_y_offset; \ +s_rc.size.height = 22; \ +s_rc.size.width = my_width; \ +o_textfield = [[[NSSecureTextField alloc] initWithFrame: s_rc] retain]; \ +[o_textfield setFont:[NSFont systemFontOfSize:0]]; \ +[o_textfield setToolTip: tooltip]; \ +[o_textfield setStringValue: init_value]; \ +} + #define ADD_COMBO( o_combo, superFrame, x_offset, my_y_offset, x2_offset, \ tooltip ) \ { \ @@ -428,9 +442,11 @@ switch( i_curItem ) { case CONFIG_ITEM_STRING: + case CONFIG_ITEM_PASSWORD: switch( i_lastItem ) { case CONFIG_ITEM_STRING: + case CONFIG_ITEM_PASSWORD: i_margin = 8; break; case CONFIG_ITEM_STRING_LIST: @@ -451,9 +467,6 @@ case CONFIG_ITEM_BOOL: i_margin = 7; break; - case CONFIG_ITEM_KEY_BEFORE_10_3: - i_margin = 7; - break; case CONFIG_ITEM_KEY_AFTER_10_3: i_margin = 6; break; @@ -469,6 +482,7 @@ switch( i_lastItem ) { case CONFIG_ITEM_STRING: + case CONFIG_ITEM_PASSWORD: i_margin = 8; break; case CONFIG_ITEM_STRING_LIST: @@ -489,9 +503,6 @@ case CONFIG_ITEM_BOOL: i_margin = 7; break; - case CONFIG_ITEM_KEY_BEFORE_10_3: - i_margin = 7; - break; case CONFIG_ITEM_KEY_AFTER_10_3: i_margin = 6; break; @@ -507,6 +518,7 @@ switch( i_lastItem ) { case CONFIG_ITEM_STRING: + case CONFIG_ITEM_PASSWORD: i_margin = 13; break; case CONFIG_ITEM_STRING_LIST: @@ -527,9 +539,6 @@ case CONFIG_ITEM_BOOL: i_margin = 10; break; - case CONFIG_ITEM_KEY_BEFORE_10_3: - i_margin = 10; - break; case CONFIG_ITEM_KEY_AFTER_10_3: i_margin = 9; break; @@ -545,6 +554,7 @@ switch( i_lastItem ) { case CONFIG_ITEM_STRING: + case CONFIG_ITEM_PASSWORD: i_margin = 8; break; case CONFIG_ITEM_STRING_LIST: @@ -565,9 +575,6 @@ case CONFIG_ITEM_BOOL: i_margin = 8; break; - case CONFIG_ITEM_KEY_BEFORE_10_3: - i_margin = 8; - break; case CONFIG_ITEM_KEY_AFTER_10_3: i_margin = 7; break; @@ -583,6 +590,7 @@ switch( i_lastItem ) { case CONFIG_ITEM_STRING: + case CONFIG_ITEM_PASSWORD: i_margin = 8; break; case CONFIG_ITEM_STRING_LIST: @@ -603,9 +611,6 @@ case CONFIG_ITEM_BOOL: i_margin = 7; break; - case CONFIG_ITEM_KEY_BEFORE_10_3: - i_margin = 7; - break; case CONFIG_ITEM_KEY_AFTER_10_3: i_margin = 6; break; @@ -621,6 +626,7 @@ switch( i_lastItem ) { case CONFIG_ITEM_STRING: + case CONFIG_ITEM_PASSWORD: i_margin = 8; break; case CONFIG_ITEM_STRING_LIST: @@ -641,9 +647,6 @@ case CONFIG_ITEM_BOOL: i_margin = 7; break; - case CONFIG_ITEM_KEY_BEFORE_10_3: - i_margin = 7; - break; case CONFIG_ITEM_KEY_AFTER_10_3: i_margin = 6; break; @@ -659,6 +662,7 @@ switch( i_lastItem ) { case CONFIG_ITEM_STRING: + case CONFIG_ITEM_PASSWORD: i_margin = 10; break; case CONFIG_ITEM_STRING_LIST: @@ -679,9 +683,6 @@ case CONFIG_ITEM_BOOL: i_margin = 7; break; - case CONFIG_ITEM_KEY_BEFORE_10_3: - i_margin = 7; - break; case CONFIG_ITEM_KEY_AFTER_10_3: i_margin = 5; break; @@ -693,48 +694,11 @@ break; } break; - case CONFIG_ITEM_KEY_BEFORE_10_3: - switch( i_lastItem ) - { - case CONFIG_ITEM_STRING: - i_margin = 6; - break; - case CONFIG_ITEM_STRING_LIST: - i_margin = 5; - break; - case CONFIG_ITEM_FILE: - i_margin = 4; - break; - case CONFIG_ITEM_MODULE: - i_margin = 2; - break; - case CONFIG_ITEM_INTEGER: - i_margin = 5; - break; - case CONFIG_ITEM_RANGED_INTEGER: - i_margin = 3; - break; - case CONFIG_ITEM_BOOL: - i_margin = 3; - break; - case CONFIG_ITEM_KEY_BEFORE_10_3: - i_margin = 10; - break; - case CONFIG_ITEM_KEY_AFTER_10_3: - i_margin = 6; - break; - case CONFIG_ITEM_MODULE_LIST: - i_margin = 6; - break; - default: - i_margin = 18; - break; - } - break; case CONFIG_ITEM_KEY_AFTER_10_3: switch( i_lastItem ) { case CONFIG_ITEM_STRING: + case CONFIG_ITEM_PASSWORD: i_margin = 8; break; case CONFIG_ITEM_STRING_LIST: @@ -755,9 +719,6 @@ case CONFIG_ITEM_BOOL: i_margin = 7; break; - case CONFIG_ITEM_KEY_BEFORE_10_3: - i_margin = 7; - break; case CONFIG_ITEM_KEY_AFTER_10_3: i_margin = 8; break; @@ -773,6 +734,7 @@ switch( i_lastItem ) { case CONFIG_ITEM_STRING: + case CONFIG_ITEM_PASSWORD: i_margin = 10; break; case CONFIG_ITEM_STRING_LIST: @@ -793,9 +755,6 @@ case CONFIG_ITEM_BOOL: i_margin = 7; break; - case CONFIG_ITEM_KEY_BEFORE_10_3: - i_margin = 7; - break; case CONFIG_ITEM_KEY_AFTER_10_3: i_margin = 5; break; @@ -822,6 +781,7 @@ switch( _p_item->i_type ) { case CONFIG_ITEM_STRING: + case CONFIG_ITEM_PASSWORD: if( !_p_item->i_list ) { p_control = [[StringConfigControl alloc] @@ -944,6 +904,7 @@ switch( p_item->i_type ) { case CONFIG_ITEM_STRING: + case CONFIG_ITEM_PASSWORD: case CONFIG_ITEM_FILE: case CONFIG_ITEM_DIRECTORY: case CONFIG_ITEM_MODULE: @@ -990,7 +951,11 @@ if( [super initWithFrame: mainFrame item: _p_item] != nil ) { - i_view_type = CONFIG_ITEM_STRING; + if( p_item->i_type == CONFIG_ITEM_PASSWORD ) + i_view_type = CONFIG_ITEM_PASSWORD; + else + i_view_type = CONFIG_ITEM_STRING; + o_textfieldTooltip = [[VLCMain sharedInstance] wrapString: [[VLCMain sharedInstance] localizedString: (char *)p_item->psz_longtext] toWidth: PREFS_WRAP]; @@ -1011,10 +976,20 @@ localizedString: (char *)p_item->value.psz]; else o_textfieldString = [NSString stringWithString: @""]; - ADD_TEXTFIELD( o_textfield, mainFrame, [o_label frame].size.width + 2, - 0, mainFrame.size.width - [o_label frame].size.width - - 2, o_textfieldTooltip, o_textfieldString ) + if( p_item->i_type == CONFIG_ITEM_PASSWORD ) + { + ADD_SECURETEXTFIELD( o_textfield, mainFrame, [o_label frame].size.width + 2, + 0, mainFrame.size.width - [o_label frame].size.width - + 2, o_textfieldTooltip, o_textfieldString ) + } + else + { + ADD_TEXTFIELD( o_textfield, mainFrame, [o_label frame].size.width + 2, + 0, mainFrame.size.width - [o_label frame].size.width - + 2, o_textfieldTooltip, o_textfieldString ) + } [o_textfield setAutoresizingMask:NSViewWidthSizable ]; + [self addSubview: o_textfield]; } return self; @@ -1254,9 +1229,8 @@ if( [super initWithFrame: mainFrame item: _p_item] != nil ) { - int i_index; - vlc_list_t *p_list; - module_t *p_parser; + size_t i_index; + module_t *p_parser, **p_list; i_view_type = CONFIG_ITEM_MODULE; o_popupTooltip = [[VLCMain sharedInstance] wrapString: @@ -1282,21 +1256,21 @@ [o_popup selectItem: [o_popup lastItem]]; /* build a list of available modules */ - p_list = vlc_list_find( VLCIntf, VLC_OBJECT_MODULE, FIND_ANYWHERE ); - for( i_index = 0; i_index < p_list->i_count; i_index++ ) + p_list = module_list_get( NULL ); + for( i_index = 0; p_list[i_index]; i_index++ ) { - p_parser = (module_t *)p_list->p_values[i_index].p_object; + p_parser = p_list[i_index]; if( p_item->i_type == CONFIG_ITEM_MODULE ) { - if( module_IsCapable( p_parser, p_item->psz_type ) ) + 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_GetObjName( p_parser ) ) ) + !strcmp( p_item->value.psz, module_get_object( p_parser ) ) ) [o_popup selectItem:[o_popup lastItem]]; } } @@ -1304,14 +1278,14 @@ { int i; - if( !strcmp( module_GetObjName( p_parser ), "main" ) ) + if( module_is_main( p_parser ) ) continue; unsigned int confsize; unsigned int unused; - module_GetConfig( p_parser, &confsize ); + module_config_get( p_parser, &confsize ); for ( i = 0; i < confsize; i++ ) { - module_config_t *p_config = module_GetConfig( p_parser, &unused ) + 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 ) @@ -1321,13 +1295,13 @@ [o_popup addItemWithTitle: o_description]; if( p_item->value.psz && !strcmp(p_item->value.psz, - module_GetObjName( p_parser )) ) + module_get_object( p_parser )) ) [o_popup selectItem:[o_popup lastItem]]; } } } } - vlc_list_release( p_list ); + module_list_free( p_list ); [self addSubview: o_popup]; } return self; @@ -1357,24 +1331,23 @@ { NSString *newval = [o_popup titleOfSelectedItem]; char *returnval = NULL; - int i_module_index; - vlc_list_t *p_list; - module_t *p_parser; + size_t i_module_index; + module_t *p_parser, **p_list; - p_list = vlc_list_find( VLCIntf, VLC_OBJECT_MODULE, FIND_ANYWHERE ); - for( i_module_index = 0; i_module_index < p_list->i_count; i_module_index++ ) + p_list = module_list_get( NULL ); + for( i_module_index = 0; p_list[i_module_index]; i_module_index++ ) { - p_parser = (module_t *)p_list->p_values[i_module_index].p_object; + p_parser = p_list[i_module_index]; if( p_item->i_type == CONFIG_ITEM_MODULE ) { - if( module_IsCapable( p_parser, p_item->psz_type ) ) + if( module_provides( p_parser, p_item->psz_type ) ) { NSString *o_description = [[VLCMain sharedInstance] localizedString: module_GetLongName( p_parser )]; if( [newval isEqualToString: o_description] ) { - returnval = strdup( module_GetObjName( p_parser )); + returnval = strdup( module_get_object( p_parser )); break; } } @@ -1383,13 +1356,13 @@ { int i; - if( !strcmp( module_GetObjName( p_parser ), "main" ) ) + if( module_is_main( p_parser) ) continue; unsigned int confsize, unused; - module_GetConfig( p_parser, &confsize ); + module_config_get( p_parser, &confsize ); for ( i = 0; i < confsize; i++ ) { - module_config_t *p_config = module_GetConfig( p_parser, &unused ) + 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 ) @@ -1398,14 +1371,14 @@ localizedString: module_GetLongName( p_parser )]; if( [newval isEqualToString: o_description] ) { - returnval = strdup(module_GetObjName( p_parser )); + returnval = strdup(module_get_object( p_parser )); break; } } } } } - vlc_list_release( p_list ); + module_list_free( p_list ); return returnval; } @end @@ -2043,30 +2016,29 @@ if( _p_item->i_type == CONFIG_ITEM_MODULE_LIST ) return nil; //Fill our array to know how may items we have... - vlc_list_t *p_list; - module_t *p_parser; - int i_module_index; + module_t *p_parser, **p_list; + size_t i_module_index; NSRect mainFrame = [o_parent_view frame]; NSString *o_labelString, *o_textfieldString, *o_tooltip; o_modulearray = [[NSMutableArray alloc] initWithCapacity:10]; /* build a list of available modules */ - p_list = vlc_list_find( VLCIntf, VLC_OBJECT_MODULE, FIND_ANYWHERE ); - for( i_module_index = 0; i_module_index < p_list->i_count; i_module_index++ ) + p_list = module_list_get( NULL ); + for( i_module_index = 0; p_list[i_module_index]; i_module_index++ ) { int i; - p_parser = (module_t *)p_list->p_values[i_module_index].p_object; + p_parser = p_list[i_module_index]; - if( !strcmp( module_GetObjName( p_parser ), "main" ) ) + if( module_is_main( p_parser ) ) continue; unsigned int confsize; - module_GetConfig( p_parser, &confsize ); + module_config_get( p_parser, &confsize ); for ( i = 0; i < confsize; i++ ) { unsigned int unused; - module_config_t *p_config = module_GetConfig( p_parser, &unused ) + i; + module_config_t *p_config = module_config_get( p_parser, &unused ) + i; NSString *o_modulelongname, *o_modulename; NSNumber *o_moduleenabled = nil; @@ -2077,10 +2049,10 @@ if( _p_item->i_type == CONFIG_ITEM_MODULE_LIST ) o_modulelongname = [NSString stringWithUTF8String: module_GetLongName( p_parser )]; o_modulename = [NSString stringWithUTF8String: - module_GetObjName( p_parser )]; + module_get_object( p_parser )]; if( _p_item->value.psz && - strstr( _p_item->value.psz, module_GetObjName( p_parser ) ) ) + strstr( _p_item->value.psz, module_get_object( p_parser ) ) ) o_moduleenabled = [NSNumber numberWithBool:YES]; else o_moduleenabled = [NSNumber numberWithBool:NO]; @@ -2091,7 +2063,7 @@ if( _p_item->i_type == CONFIG_ITEM_MODULE_LIST ) } } } - vlc_list_release( p_list ); + module_list_free( p_list ); mainFrame.size.height = 30 + 18 * [o_modulearray count]; mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN;