Commit 4e6bc174 authored by David Fuhrmann's avatar David Fuhrmann

macosx: advanced prefs: use config_GetIntChoices for int list

parent b76584c1
...@@ -1446,17 +1446,7 @@ o_textfield = [[[NSSecureTextField alloc] initWithFrame: s_rc] retain]; \ ...@@ -1446,17 +1446,7 @@ o_textfield = [[[NSSecureTextField alloc] initWithFrame: s_rc] retain]; \
[o_popup setAutoresizingMask:NSViewWidthSizable ]; [o_popup setAutoresizingMask:NSViewWidthSizable ];
/* add items */ /* add items */
for (int i_index = 0; i_index < p_item->list_count; i_index++) { [self resetValues];
NSString *o_text;
if (p_item->list_text && p_item->list_text[i_index])
o_text = _NS((char *)p_item->list_text[i_index]);
else
o_text = [NSString stringWithFormat: @"%i", p_item->list.i[i_index]];
[o_popup addItemWithTitle: o_text];
if (p_item->value.i == p_item->list.i[i_index])
[o_popup selectItemAtIndex: i_index];
}
[self addSubview: o_popup]; [self addSubview: o_popup];
} }
...@@ -1485,19 +1475,33 @@ o_textfield = [[[NSSecureTextField alloc] initWithFrame: s_rc] retain]; \ ...@@ -1485,19 +1475,33 @@ o_textfield = [[[NSSecureTextField alloc] initWithFrame: s_rc] retain]; \
- (int)intValue - (int)intValue
{ {
if ([o_popup indexOfSelectedItem] >= 0) NSNumber *p_valueobject = (NSNumber *)[[o_popup selectedItem] representedObject];
return p_item->list.i[[o_popup indexOfSelectedItem]]; if (p_valueobject) {
else assert([p_valueobject isKindOfClass:[NSNumber class]]);
return [o_popup intValue]; return [p_valueobject intValue];
} else
return 0;
} }
-(void)resetValues -(void)resetValues
{ {
for (int i_index = 0; i_index < p_item->list_count; i_index++) { [o_popup removeAllItems];
if (config_GetInt(VLCIntf, p_item->psz_name) == p_item->list.i[i_index])
[o_popup selectItemAtIndex: i_index]; int i_current_selection = config_GetInt(VLCIntf, p_item->psz_name);
} int64_t *values;
char **texts;
ssize_t count = config_GetIntChoices(VLC_OBJECT(VLCIntf), p_item->psz_name, &values, &texts);
for (ssize_t i = 0; i < count; i++) {
NSMenuItem *mi = [[NSMenuItem alloc] initWithTitle: toNSStr(texts[i]) action: NULL keyEquivalent: @""];
[mi setRepresentedObject:[NSNumber numberWithInt:values[i]]];
[[o_popup menu] addItem: [mi autorelease]];
if (i_current_selection == values[i])
[o_popup selectItem:[o_popup lastItem]];
free(texts[i]);
}
free(texts);
} }
@end @end
......
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