Commit ddb643bf authored by David Fuhrmann's avatar David Fuhrmann

macosx: simple prefs: use config_GetIntChoices for int list

parent 4e6bc174
...@@ -503,20 +503,23 @@ static inline char * __config_GetLabel(vlc_object_t *p_this, const char *psz_nam ...@@ -503,20 +503,23 @@ static inline char * __config_GetLabel(vlc_object_t *p_this, const char *psz_nam
/* serious problem, if no item found */ /* serious problem, if no item found */
assert(p_item); assert(p_item);
for (int i = 0; i < p_item->list_count; i++) { int64_t *values;
NSMenuItem *mi; char **texts;
if (p_item->list_text != NULL) ssize_t count = config_GetIntChoices(VLC_OBJECT(VLCIntf), name, &values, &texts);
mi = [[NSMenuItem alloc] initWithTitle: _NS(p_item->list_text[i]) action:NULL keyEquivalent: @""]; for (ssize_t i = 0; i < count; i++) {
else if (p_item->list.i[i]) NSMenuItem *mi = [[NSMenuItem alloc] initWithTitle: toNSStr(texts[i]) action: NULL keyEquivalent: @""];
mi = [[NSMenuItem alloc] initWithTitle: [NSString stringWithFormat: @"%d", p_item->list.i[i]] action:NULL keyEquivalent: @""]; [mi setRepresentedObject:[NSNumber numberWithInt:values[i]]];
else
msg_Err(p_intf, "item %d of pref %s failed to be created", i, name);
[mi setRepresentedObject:[NSNumber numberWithInt:p_item->list.i[i]]];
[[object menu] addItem: [mi autorelease]]; [[object menu] addItem: [mi autorelease]];
if (p_item->value.i == p_item->list.i[i])
if (p_item->value.i == values[i])
[object selectItem:[object lastItem]]; [object selectItem:[object lastItem]];
free(texts[i]);
} }
[object setToolTip: _NS(p_item->psz_longtext)]; free(texts);
if (p_item->psz_longtext)
[object setToolTip: _NS(p_item->psz_longtext)];
} }
- (void)setupButton: (NSButton *)object forBoolValue: (const char *)name - (void)setupButton: (NSButton *)object forBoolValue: (const char *)name
...@@ -869,8 +872,6 @@ static inline char * __config_GetLabel(vlc_object_t *p_this, const char *psz_nam ...@@ -869,8 +872,6 @@ static inline char * __config_GetLabel(vlc_object_t *p_this, const char *psz_nam
static inline void save_int_list(intf_thread_t * p_intf, id object, const char * name) static inline void save_int_list(intf_thread_t * p_intf, id object, const char * name)
{ {
NSNumber *p_valueobject; NSNumber *p_valueobject;
module_config_t *p_item;
p_item = config_FindConfig(VLC_OBJECT(p_intf), name);
p_valueobject = (NSNumber *)[[object selectedItem] representedObject]; p_valueobject = (NSNumber *)[[object selectedItem] representedObject];
assert([p_valueobject isKindOfClass:[NSNumber class]]); assert([p_valueobject isKindOfClass:[NSNumber class]]);
if (p_valueobject) config_PutInt(p_intf, name, [p_valueobject intValue]); if (p_valueobject) config_PutInt(p_intf, name, [p_valueobject intValue]);
......
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