[vlc-devel] commit: macosx: implement CONFIG_ITEM_PASSWORD (closes #2118) ( Felix Paul Kühne )
git version control
git at videolan.org
Thu Sep 25 19:02:25 CEST 2008
vlc | branch: 0.9-bugfix | Felix Paul Kühne <fkuehne at videolan.org> | Thu Sep 25 16:27:49 2008 +0200| [670eb14b3e231a913f4a0ae5ecf81a93af02428a] | committer: Derk-Jan Hartman
macosx: implement CONFIG_ITEM_PASSWORD (closes #2118)
Thanks for not waiting for this announced, easy-to-backport commit.
(cherry picked from commit 03c6d5b8ae4f617cc809ab0b16c3aebff4c77523)
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=670eb14b3e231a913f4a0ae5ecf81a93af02428a
---
modules/gui/macosx/prefs_widgets.m | 87 ++++++++++++++++++++++++++++++++++--
1 files changed, 83 insertions(+), 4 deletions(-)
diff --git a/modules/gui/macosx/prefs_widgets.m b/modules/gui/macosx/prefs_widgets.m
index 01ee64e..6784fc6 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,49 @@
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:
+ 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;
break;
case CONFIG_ITEM_STRING_LIST:
@@ -469,6 +523,7 @@
switch( i_lastItem )
{
case CONFIG_ITEM_STRING:
+ case CONFIG_ITEM_PASSWORD:
i_margin = 8;
break;
case CONFIG_ITEM_STRING_LIST:
@@ -507,6 +562,7 @@
switch( i_lastItem )
{
case CONFIG_ITEM_STRING:
+ case CONFIG_ITEM_PASSWORD:
i_margin = 13;
break;
case CONFIG_ITEM_STRING_LIST:
@@ -545,6 +601,7 @@
switch( i_lastItem )
{
case CONFIG_ITEM_STRING:
+ case CONFIG_ITEM_PASSWORD:
i_margin = 8;
break;
case CONFIG_ITEM_STRING_LIST:
@@ -583,6 +640,7 @@
switch( i_lastItem )
{
case CONFIG_ITEM_STRING:
+ case CONFIG_ITEM_PASSWORD:
i_margin = 8;
break;
case CONFIG_ITEM_STRING_LIST:
@@ -621,6 +679,7 @@
switch( i_lastItem )
{
case CONFIG_ITEM_STRING:
+ case CONFIG_ITEM_PASSWORD:
i_margin = 8;
break;
case CONFIG_ITEM_STRING_LIST:
@@ -659,6 +718,7 @@
switch( i_lastItem )
{
case CONFIG_ITEM_STRING:
+ case CONFIG_ITEM_PASSWORD:
i_margin = 10;
break;
case CONFIG_ITEM_STRING_LIST:
@@ -697,6 +757,7 @@
switch( i_lastItem )
{
case CONFIG_ITEM_STRING:
+ case CONFIG_ITEM_PASSWORD:
i_margin = 6;
break;
case CONFIG_ITEM_STRING_LIST:
@@ -735,6 +796,7 @@
switch( i_lastItem )
{
case CONFIG_ITEM_STRING:
+ case CONFIG_ITEM_PASSWORD:
i_margin = 8;
break;
case CONFIG_ITEM_STRING_LIST:
@@ -773,6 +835,7 @@
switch( i_lastItem )
{
case CONFIG_ITEM_STRING:
+ case CONFIG_ITEM_PASSWORD:
i_margin = 10;
break;
case CONFIG_ITEM_STRING_LIST:
@@ -822,6 +885,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 +1008,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 +1055,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 +1080,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;
More information about the vlc-devel
mailing list