]> git.sesse.net Git - vlc/blobdiff - modules/gui/macosx/prefs_widgets.m
Qt: fix video widget size
[vlc] / modules / gui / macosx / prefs_widgets.m
index 01ee64ecce4e006a3f62faf7824cbbfbe248d087..90c187f6f88c6260610dadb424ff6824b95a1e9b 100644 (file)
     [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 )                                                               \
 {                                                                           \
     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:
         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;
         switch( i_lastItem )
         {
         case CONFIG_ITEM_STRING:
+        case CONFIG_ITEM_PASSWORD:
             i_margin = 8;
             break;
         case CONFIG_ITEM_STRING_LIST:
         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;
         switch( i_lastItem )
         {
         case CONFIG_ITEM_STRING:
+        case CONFIG_ITEM_PASSWORD:
             i_margin = 13;
             break;
         case CONFIG_ITEM_STRING_LIST:
         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;
         switch( i_lastItem )
         {
         case CONFIG_ITEM_STRING:
+        case CONFIG_ITEM_PASSWORD:
             i_margin = 8;
             break;
         case CONFIG_ITEM_STRING_LIST:
         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;
         switch( i_lastItem )
         {
         case CONFIG_ITEM_STRING:
+        case CONFIG_ITEM_PASSWORD:
             i_margin = 8;
             break;
         case CONFIG_ITEM_STRING_LIST:
         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;
         switch( i_lastItem )
         {
         case CONFIG_ITEM_STRING:
+        case CONFIG_ITEM_PASSWORD:
             i_margin = 8;
             break;
         case CONFIG_ITEM_STRING_LIST:
         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;
         switch( i_lastItem )
         {
         case CONFIG_ITEM_STRING:
+        case CONFIG_ITEM_PASSWORD:
             i_margin = 10;
             break;
         case CONFIG_ITEM_STRING_LIST:
         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;
             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:
         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;
         switch( i_lastItem )
         {
         case CONFIG_ITEM_STRING:
+        case CONFIG_ITEM_PASSWORD:
             i_margin = 10;
             break;
         case CONFIG_ITEM_STRING_LIST:
         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;
     switch( _p_item->i_type )
     {
     case CONFIG_ITEM_STRING:
+    case CONFIG_ITEM_PASSWORD:
         if( !_p_item->i_list )
         {
             p_control = [[StringConfigControl alloc]
     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:
 
     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];
                                     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;
 
     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:
         [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]];
                 }
             }
             {
                 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 )
                         [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;
 {
     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;
                 }
             }
         {
             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 )
                         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;