Commit 03c6d5b8 authored by Felix Paul Kühne's avatar Felix Paul Kühne

macosx: implement CONFIG_ITEM_PASSWORD (closes #2118)

Thanks for not waiting for this announced, easy-to-backport commit.
parent c4f35e50
...@@ -280,6 +280,20 @@ ...@@ -280,6 +280,20 @@
[o_textfield setStringValue: init_value]; \ [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, \ #define ADD_COMBO( o_combo, superFrame, x_offset, my_y_offset, x2_offset, \
tooltip ) \ tooltip ) \
{ \ { \
...@@ -428,9 +442,49 @@ ...@@ -428,9 +442,49 @@
switch( i_curItem ) switch( i_curItem )
{ {
case CONFIG_ITEM_STRING: case CONFIG_ITEM_STRING:
case CONFIG_ITEM_PASSWORD:
switch( i_lastItem ) switch( i_lastItem )
{ {
case CONFIG_ITEM_STRING: 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_BEFORE_10_3:
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;
switch( i_lastItem )
{
case CONFIG_ITEM_STRING:
case CONFIG_ITEM_PASSWORD:
i_margin = 8; i_margin = 8;
break; break;
case CONFIG_ITEM_STRING_LIST: case CONFIG_ITEM_STRING_LIST:
...@@ -469,6 +523,7 @@ ...@@ -469,6 +523,7 @@
switch( i_lastItem ) switch( i_lastItem )
{ {
case CONFIG_ITEM_STRING: case CONFIG_ITEM_STRING:
case CONFIG_ITEM_PASSWORD:
i_margin = 8; i_margin = 8;
break; break;
case CONFIG_ITEM_STRING_LIST: case CONFIG_ITEM_STRING_LIST:
...@@ -507,6 +562,7 @@ ...@@ -507,6 +562,7 @@
switch( i_lastItem ) switch( i_lastItem )
{ {
case CONFIG_ITEM_STRING: case CONFIG_ITEM_STRING:
case CONFIG_ITEM_PASSWORD:
i_margin = 13; i_margin = 13;
break; break;
case CONFIG_ITEM_STRING_LIST: case CONFIG_ITEM_STRING_LIST:
...@@ -545,6 +601,7 @@ ...@@ -545,6 +601,7 @@
switch( i_lastItem ) switch( i_lastItem )
{ {
case CONFIG_ITEM_STRING: case CONFIG_ITEM_STRING:
case CONFIG_ITEM_PASSWORD:
i_margin = 8; i_margin = 8;
break; break;
case CONFIG_ITEM_STRING_LIST: case CONFIG_ITEM_STRING_LIST:
...@@ -583,6 +640,7 @@ ...@@ -583,6 +640,7 @@
switch( i_lastItem ) switch( i_lastItem )
{ {
case CONFIG_ITEM_STRING: case CONFIG_ITEM_STRING:
case CONFIG_ITEM_PASSWORD:
i_margin = 8; i_margin = 8;
break; break;
case CONFIG_ITEM_STRING_LIST: case CONFIG_ITEM_STRING_LIST:
...@@ -621,6 +679,7 @@ ...@@ -621,6 +679,7 @@
switch( i_lastItem ) switch( i_lastItem )
{ {
case CONFIG_ITEM_STRING: case CONFIG_ITEM_STRING:
case CONFIG_ITEM_PASSWORD:
i_margin = 8; i_margin = 8;
break; break;
case CONFIG_ITEM_STRING_LIST: case CONFIG_ITEM_STRING_LIST:
...@@ -659,6 +718,7 @@ ...@@ -659,6 +718,7 @@
switch( i_lastItem ) switch( i_lastItem )
{ {
case CONFIG_ITEM_STRING: case CONFIG_ITEM_STRING:
case CONFIG_ITEM_PASSWORD:
i_margin = 10; i_margin = 10;
break; break;
case CONFIG_ITEM_STRING_LIST: case CONFIG_ITEM_STRING_LIST:
...@@ -697,6 +757,7 @@ ...@@ -697,6 +757,7 @@
switch( i_lastItem ) switch( i_lastItem )
{ {
case CONFIG_ITEM_STRING: case CONFIG_ITEM_STRING:
case CONFIG_ITEM_PASSWORD:
i_margin = 6; i_margin = 6;
break; break;
case CONFIG_ITEM_STRING_LIST: case CONFIG_ITEM_STRING_LIST:
...@@ -735,6 +796,7 @@ ...@@ -735,6 +796,7 @@
switch( i_lastItem ) switch( i_lastItem )
{ {
case CONFIG_ITEM_STRING: case CONFIG_ITEM_STRING:
case CONFIG_ITEM_PASSWORD:
i_margin = 8; i_margin = 8;
break; break;
case CONFIG_ITEM_STRING_LIST: case CONFIG_ITEM_STRING_LIST:
...@@ -773,6 +835,7 @@ ...@@ -773,6 +835,7 @@
switch( i_lastItem ) switch( i_lastItem )
{ {
case CONFIG_ITEM_STRING: case CONFIG_ITEM_STRING:
case CONFIG_ITEM_PASSWORD:
i_margin = 10; i_margin = 10;
break; break;
case CONFIG_ITEM_STRING_LIST: case CONFIG_ITEM_STRING_LIST:
...@@ -822,6 +885,7 @@ ...@@ -822,6 +885,7 @@
switch( _p_item->i_type ) switch( _p_item->i_type )
{ {
case CONFIG_ITEM_STRING: case CONFIG_ITEM_STRING:
case CONFIG_ITEM_PASSWORD:
if( !_p_item->i_list ) if( !_p_item->i_list )
{ {
p_control = [[StringConfigControl alloc] p_control = [[StringConfigControl alloc]
...@@ -944,6 +1008,7 @@ ...@@ -944,6 +1008,7 @@
switch( p_item->i_type ) switch( p_item->i_type )
{ {
case CONFIG_ITEM_STRING: case CONFIG_ITEM_STRING:
case CONFIG_ITEM_PASSWORD:
case CONFIG_ITEM_FILE: case CONFIG_ITEM_FILE:
case CONFIG_ITEM_DIRECTORY: case CONFIG_ITEM_DIRECTORY:
case CONFIG_ITEM_MODULE: case CONFIG_ITEM_MODULE:
...@@ -990,7 +1055,11 @@ ...@@ -990,7 +1055,11 @@
if( [super initWithFrame: mainFrame item: _p_item] != nil ) 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: o_textfieldTooltip = [[VLCMain sharedInstance] wrapString:
[[VLCMain sharedInstance] localizedString: (char *)p_item->psz_longtext] [[VLCMain sharedInstance] localizedString: (char *)p_item->psz_longtext]
toWidth: PREFS_WRAP]; toWidth: PREFS_WRAP];
...@@ -1011,10 +1080,20 @@ ...@@ -1011,10 +1080,20 @@
localizedString: (char *)p_item->value.psz]; localizedString: (char *)p_item->value.psz];
else else
o_textfieldString = [NSString stringWithString: @""]; o_textfieldString = [NSString stringWithString: @""];
ADD_TEXTFIELD( o_textfield, mainFrame, [o_label frame].size.width + 2, if( p_item->i_type == CONFIG_ITEM_PASSWORD )
0, mainFrame.size.width - [o_label frame].size.width - {
2, o_textfieldTooltip, o_textfieldString ) 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 ]; [o_textfield setAutoresizingMask:NSViewWidthSizable ];
[self addSubview: o_textfield]; [self addSubview: o_textfield];
} }
return self; return self;
......
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