1 /*****************************************************************************
2 * prefs_widgets.m: Preferences controls
3 *****************************************************************************
4 * Copyright (C) 2002-2011 the VideoLAN team
7 * Authors: Derk-Jan Hartman <hartman at videolan.org>
8 * Jérôme Decoodt <djc at videolan.org>
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
23 *****************************************************************************/
25 /*****************************************************************************
27 *****************************************************************************/
28 #include <stdlib.h> /* malloc(), free() */
35 #include <vlc_common.h>
36 #include <vlc_modules.h>
40 #include "prefs_widgets.h"
42 #define PREFS_WRAP 300
43 #define OFFSET_RIGHT 20
44 #define OFFSET_BETWEEN 2
46 #define UPWARDS_WHITE_ARROW "\xE2\x87\xA7"
47 #define OPTION_KEY "\xE2\x8C\xA5"
48 #define UP_ARROWHEAD "\xE2\x8C\x83"
49 #define PLACE_OF_INTEREST_SIGN "\xE2\x8C\x98"
51 #define POPULATE_A_KEY( o_menu, string, value ) \
55 o_mi = [[NSMenuItem alloc] initWithTitle:string \
56 action:nil keyEquivalent:@""]; \
57 [o_mi setKeyEquivalentModifierMask: \
59 [o_mi setAlternate: NO]; \
62 [o_menu addItem: o_mi]; \
64 o_mi = [[NSMenuItem alloc] initWithTitle: \
65 [[NSString stringWithUTF8String: \
67 ] stringByAppendingString: string] \
68 action:nil keyEquivalent:@""]; \
69 [o_mi setKeyEquivalentModifierMask: \
71 [o_mi setAlternate: YES]; \
73 KEY_MODIFIER_CTRL | ( value )]; \
74 [o_menu addItem: o_mi]; \
76 o_mi = [[NSMenuItem alloc] initWithTitle: \
77 [[NSString stringWithUTF8String: \
78 UP_ARROWHEAD OPTION_KEY \
79 ] stringByAppendingString: string] \
80 action:nil keyEquivalent:@""]; \
81 [o_mi setKeyEquivalentModifierMask: \
82 NSControlKeyMask | NSAlternateKeyMask]; \
83 [o_mi setAlternate: YES]; \
85 (KEY_MODIFIER_CTRL | KEY_MODIFIER_ALT) | ( value )]; \
86 [o_menu addItem: o_mi]; \
88 o_mi = [[NSMenuItem alloc] initWithTitle: \
89 [[NSString stringWithUTF8String: \
90 UP_ARROWHEAD UPWARDS_WHITE_ARROW \
91 ] stringByAppendingString: string] \
92 action:nil keyEquivalent:@""]; \
93 [o_mi setKeyEquivalentModifierMask: \
94 NSControlKeyMask | NSShiftKeyMask]; \
95 [o_mi setAlternate: YES]; \
97 (KEY_MODIFIER_CTRL | KEY_MODIFIER_SHIFT) | ( value )]; \
98 [o_menu addItem: o_mi]; \
100 o_mi = [[NSMenuItem alloc] initWithTitle: \
101 [[NSString stringWithUTF8String: \
102 UP_ARROWHEAD PLACE_OF_INTEREST_SIGN \
103 ] stringByAppendingString: string] \
104 action:nil keyEquivalent:@""]; \
105 [o_mi setKeyEquivalentModifierMask: \
106 NSControlKeyMask | NSCommandKeyMask]; \
107 [o_mi setAlternate: YES]; \
109 (KEY_MODIFIER_CTRL | KEY_MODIFIER_COMMAND) | ( value )]; \
110 [o_menu addItem: o_mi]; \
111 /* Ctrl+Alt+Shift */ \
112 o_mi = [[NSMenuItem alloc] initWithTitle: \
113 [[NSString stringWithUTF8String: \
114 UP_ARROWHEAD OPTION_KEY UPWARDS_WHITE_ARROW \
115 ] stringByAppendingString: string] \
116 action:nil keyEquivalent:@""]; \
117 [o_mi setKeyEquivalentModifierMask: \
118 NSControlKeyMask | NSAlternateKeyMask | NSShiftKeyMask]; \
119 [o_mi setAlternate: YES]; \
121 (KEY_MODIFIER_CTRL | KEY_MODIFIER_ALT | KEY_MODIFIER_SHIFT) | \
123 [o_menu addItem: o_mi]; \
124 /* Ctrl+Alt+Apple */ \
125 o_mi = [[NSMenuItem alloc] initWithTitle: \
126 [[NSString stringWithUTF8String: \
127 UP_ARROWHEAD OPTION_KEY PLACE_OF_INTEREST_SIGN \
128 ] stringByAppendingString: string] \
129 action:nil keyEquivalent:@""]; \
130 [o_mi setKeyEquivalentModifierMask: \
131 NSControlKeyMask | NSAlternateKeyMask | NSCommandKeyMask]; \
132 [o_mi setAlternate: YES]; \
134 (KEY_MODIFIER_CTRL | KEY_MODIFIER_ALT | KEY_MODIFIER_COMMAND) | \
136 [o_menu addItem: o_mi]; \
137 /* Ctrl+Shift+Apple */ \
138 o_mi = [[NSMenuItem alloc] initWithTitle: \
139 [[NSString stringWithUTF8String: \
140 UP_ARROWHEAD UPWARDS_WHITE_ARROW PLACE_OF_INTEREST_SIGN \
141 ] stringByAppendingString: string] \
142 action:nil keyEquivalent:@""]; \
143 [o_mi setKeyEquivalentModifierMask: \
144 NSControlKeyMask | NSShiftKeyMask | NSCommandKeyMask]; \
145 [o_mi setAlternate: YES]; \
147 (KEY_MODIFIER_CTRL | KEY_MODIFIER_SHIFT | KEY_MODIFIER_COMMAND) | \
149 [o_menu addItem: o_mi]; \
150 /* Ctrl+Alt+Shift+Apple */ \
151 o_mi = [[NSMenuItem alloc] initWithTitle: \
152 [[NSString stringWithUTF8String: \
153 UP_ARROWHEAD OPTION_KEY UPWARDS_WHITE_ARROW \
154 PLACE_OF_INTEREST_SIGN \
155 ] stringByAppendingString: string] \
156 action:nil keyEquivalent:@""]; \
157 [o_mi setKeyEquivalentModifierMask: \
158 NSControlKeyMask | NSAlternateKeyMask | NSShiftKeyMask | \
160 [o_mi setAlternate: YES]; \
162 (KEY_MODIFIER_CTRL | KEY_MODIFIER_ALT | KEY_MODIFIER_SHIFT | \
163 KEY_MODIFIER_COMMAND) | ( value )]; \
164 [o_menu addItem: o_mi]; \
166 o_mi = [[NSMenuItem alloc] initWithTitle: \
167 [[NSString stringWithUTF8String: \
169 ] stringByAppendingString: string] \
170 action:nil keyEquivalent:@""]; \
171 [o_mi setKeyEquivalentModifierMask: \
172 NSAlternateKeyMask]; \
173 [o_mi setAlternate: YES]; \
175 KEY_MODIFIER_ALT | ( value )]; \
176 [o_menu addItem: o_mi]; \
178 o_mi = [[NSMenuItem alloc] initWithTitle: \
179 [[NSString stringWithUTF8String: \
180 OPTION_KEY UPWARDS_WHITE_ARROW \
181 ] stringByAppendingString: string] \
182 action:nil keyEquivalent:@""]; \
183 [o_mi setKeyEquivalentModifierMask: \
184 NSAlternateKeyMask | NSShiftKeyMask]; \
185 [o_mi setAlternate: YES]; \
187 (KEY_MODIFIER_ALT | KEY_MODIFIER_SHIFT) | ( value )]; \
188 [o_menu addItem: o_mi]; \
190 o_mi = [[NSMenuItem alloc] initWithTitle: \
191 [[NSString stringWithUTF8String: \
192 OPTION_KEY PLACE_OF_INTEREST_SIGN \
193 ] stringByAppendingString: string] \
194 action:nil keyEquivalent:@""]; \
195 [o_mi setKeyEquivalentModifierMask: \
196 NSAlternateKeyMask | NSCommandKeyMask]; \
197 [o_mi setAlternate: YES]; \
199 (KEY_MODIFIER_ALT | KEY_MODIFIER_COMMAND) | ( value )]; \
200 [o_menu addItem: o_mi]; \
201 /* Alt+Shift+Apple */ \
202 o_mi = [[NSMenuItem alloc] initWithTitle: \
203 [[NSString stringWithUTF8String: \
204 OPTION_KEY UPWARDS_WHITE_ARROW PLACE_OF_INTEREST_SIGN \
205 ] stringByAppendingString: string] \
206 action:nil keyEquivalent:@""]; \
207 [o_mi setKeyEquivalentModifierMask: \
208 NSAlternateKeyMask | NSShiftKeyMask | NSCommandKeyMask]; \
209 [o_mi setAlternate: YES]; \
211 (KEY_MODIFIER_ALT | KEY_MODIFIER_SHIFT | KEY_MODIFIER_COMMAND) | \
213 [o_menu addItem: o_mi]; \
215 o_mi = [[NSMenuItem alloc] initWithTitle: \
216 [[NSString stringWithUTF8String: \
217 UPWARDS_WHITE_ARROW \
218 ] stringByAppendingString: string] \
219 action:nil keyEquivalent:@""]; \
220 [o_mi setKeyEquivalentModifierMask: \
222 [o_mi setAlternate: YES]; \
224 KEY_MODIFIER_SHIFT | ( value )]; \
225 [o_menu addItem: o_mi]; \
227 o_mi = [[NSMenuItem alloc] initWithTitle: \
228 [[NSString stringWithUTF8String: \
229 UPWARDS_WHITE_ARROW PLACE_OF_INTEREST_SIGN \
230 ] stringByAppendingString: string] \
231 action:nil keyEquivalent:@""]; \
232 [o_mi setKeyEquivalentModifierMask: \
233 NSShiftKeyMask | NSCommandKeyMask]; \
234 [o_mi setAlternate: YES]; \
236 (KEY_MODIFIER_SHIFT | KEY_MODIFIER_COMMAND) | ( value )]; \
237 [o_menu addItem: o_mi]; \
239 o_mi = [[NSMenuItem alloc] initWithTitle: \
240 [[NSString stringWithUTF8String: \
241 PLACE_OF_INTEREST_SIGN \
242 ] stringByAppendingString: string] \
243 action:nil keyEquivalent:@""]; \
244 [o_mi setKeyEquivalentModifierMask: \
246 [o_mi setAlternate: YES]; \
248 KEY_MODIFIER_COMMAND | ( value )]; \
249 [o_menu addItem: o_mi]; \
252 #define ADD_LABEL( o_label, superFrame, x_offset, my_y_offset, label, \
255 NSRect s_rc = superFrame; \
256 s_rc.size.height = 17; \
257 s_rc.origin.x = x_offset - 3; \
258 s_rc.origin.y = superFrame.size.height - 17 + my_y_offset; \
259 o_label = [[[NSTextField alloc] initWithFrame: s_rc] retain]; \
260 [o_label setDrawsBackground: NO]; \
261 [o_label setBordered: NO]; \
262 [o_label setEditable: NO]; \
263 [o_label setSelectable: NO]; \
264 [o_label setStringValue: label]; \
265 [o_label setToolTip: tooltip]; \
266 [o_label setFont:[NSFont systemFontOfSize:0]]; \
267 [o_label sizeToFit]; \
270 #define ADD_TEXTFIELD( o_textfield, superFrame, x_offset, my_y_offset, \
271 my_width, tooltip, init_value ) \
273 NSRect s_rc = superFrame; \
274 s_rc.origin.x = x_offset; \
275 s_rc.origin.y = my_y_offset; \
276 s_rc.size.height = 22; \
277 s_rc.size.width = my_width; \
278 o_textfield = [[[NSTextField alloc] initWithFrame: s_rc] retain]; \
279 [o_textfield setFont:[NSFont systemFontOfSize:0]]; \
280 [o_textfield setToolTip: tooltip]; \
281 [o_textfield setStringValue: init_value]; \
284 #define ADD_SECURETEXTFIELD( o_textfield, superFrame, x_offset, my_y_offset, \
285 my_width, tooltip, init_value ) \
287 NSRect s_rc = superFrame; \
288 s_rc.origin.x = x_offset; \
289 s_rc.origin.y = my_y_offset; \
290 s_rc.size.height = 22; \
291 s_rc.size.width = my_width; \
292 o_textfield = [[[NSSecureTextField alloc] initWithFrame: s_rc] retain]; \
293 [o_textfield setFont:[NSFont systemFontOfSize:0]]; \
294 [o_textfield setToolTip: tooltip]; \
295 [o_textfield setStringValue: init_value]; \
298 #define ADD_COMBO( o_combo, superFrame, x_offset, my_y_offset, x2_offset, \
301 NSRect s_rc = superFrame; \
302 s_rc.origin.x = x_offset + 2; \
303 s_rc.origin.y = my_y_offset; \
304 s_rc.size.height = 26; \
305 s_rc.size.width = superFrame.size.width + 2 - s_rc.origin.x - \
307 o_combo = [[[NSComboBox alloc] initWithFrame: s_rc] retain]; \
308 [o_combo setFont:[NSFont systemFontOfSize:0]]; \
309 [o_combo setToolTip: tooltip]; \
310 [o_combo setUsesDataSource:TRUE]; \
311 [o_combo setDataSource:self]; \
312 [o_combo setNumberOfVisibleItems:10]; \
313 [o_combo setCompletes:YES]; \
316 #define ADD_RIGHT_BUTTON( o_button, superFrame, x_offset, my_y_offset, \
319 NSRect s_rc = superFrame; \
320 o_button = [[[NSButton alloc] initWithFrame: s_rc] retain]; \
321 [o_button setButtonType: NSMomentaryPushInButton]; \
322 [o_button setBezelStyle: NSRoundedBezelStyle]; \
323 [o_button setTitle: title]; \
324 [o_button setFont:[NSFont systemFontOfSize:0]]; \
325 [o_button sizeToFit]; \
326 s_rc = [o_button frame]; \
327 s_rc.origin.x = superFrame.size.width - [o_button frame].size.width - 6;\
328 s_rc.origin.y = my_y_offset - 6; \
329 s_rc.size.width += 12; \
330 [o_button setFrame: s_rc]; \
331 [o_button setToolTip: tooltip]; \
332 [o_button setTarget: self]; \
333 [o_button setAction: @selector(openFileDialog:)]; \
336 #define ADD_POPUP( o_popup, superFrame, x_offset, my_y_offset, x2_offset, \
339 NSRect s_rc = superFrame; \
340 s_rc.origin.x = x_offset - 1; \
341 s_rc.origin.y = my_y_offset; \
342 s_rc.size.height = 26; \
343 s_rc.size.width = superFrame.size.width + 2 - s_rc.origin.x - \
345 o_popup = [[[NSPopUpButton alloc] initWithFrame: s_rc] retain]; \
346 [o_popup setFont:[NSFont systemFontOfSize:0]]; \
347 [o_popup setToolTip: tooltip]; \
350 #define ADD_STEPPER( o_stepper, superFrame, x_offset, my_y_offset, tooltip, \
353 NSRect s_rc = superFrame; \
354 s_rc.origin.x = x_offset; \
355 s_rc.origin.y = my_y_offset; \
356 s_rc.size.height = 23; \
357 s_rc.size.width = 23; \
358 o_stepper = [[[NSStepper alloc] initWithFrame: s_rc] retain]; \
359 [o_stepper setFont:[NSFont systemFontOfSize:0]]; \
360 [o_stepper setToolTip: tooltip]; \
361 [o_stepper setMaxValue: higher]; \
362 [o_stepper setMinValue: lower]; \
363 [o_stepper setTarget: self]; \
364 [o_stepper setAction: @selector(stepperChanged:)]; \
365 [o_stepper sendActionOn:NSLeftMouseUpMask | NSLeftMouseDownMask | \
366 NSLeftMouseDraggedMask]; \
369 #define ADD_SLIDER( o_slider, superFrame, x_offset, my_y_offset, my_width, \
370 tooltip, lower, higher ) \
372 NSRect s_rc = superFrame; \
373 s_rc.origin.x = x_offset; \
374 s_rc.origin.y = my_y_offset; \
375 s_rc.size.height = 21; \
376 s_rc.size.width = my_width; \
377 o_slider = [[[NSSlider alloc] initWithFrame: s_rc] retain]; \
378 [o_slider setFont:[NSFont systemFontOfSize:0]]; \
379 [o_slider setToolTip: tooltip]; \
380 [o_slider setMaxValue: higher]; \
381 [o_slider setMinValue: lower]; \
384 #define ADD_CHECKBOX( o_checkbox, superFrame, x_offset, my_y_offset, label, \
385 tooltip, init_value, position ) \
387 NSRect s_rc = superFrame; \
388 s_rc.size.height = 18; \
389 s_rc.origin.x = x_offset - 2; \
390 s_rc.origin.y = superFrame.size.height - 18 + my_y_offset; \
391 o_checkbox = [[[NSButton alloc] initWithFrame: s_rc] retain]; \
392 [o_checkbox setFont:[NSFont systemFontOfSize:0]]; \
393 [o_checkbox setButtonType: NSSwitchButton]; \
394 [o_checkbox setImagePosition: position]; \
395 [o_checkbox setIntValue: init_value]; \
396 [o_checkbox setTitle: label]; \
397 [o_checkbox setToolTip: tooltip]; \
398 [o_checkbox sizeToFit]; \
401 @implementation VLCConfigControl
402 - (id)initWithFrame: (NSRect)frame
404 return [self initWithFrame: frame
408 - (id)initWithFrame: (NSRect)frame
409 item: (module_config_t *)_p_item
411 self = [super initWithFrame: frame];
416 psz_name = p_item->psz_name;
418 i_type = p_item->i_type;
420 b_advanced = p_item->b_advanced;
421 [self setAutoresizingMask:NSViewWidthSizable | NSViewMinYMargin ];
426 - (void)setYPos:(int)i_yPos
428 NSRect frame = [self frame];
429 frame.origin.y = i_yPos;
430 [self setFrame:frame];
435 if( o_label ) [o_label release];
440 + (int)calcVerticalMargin: (int)i_curItem lastItem: (int)i_lastItem
445 case CONFIG_ITEM_STRING:
446 case CONFIG_ITEM_PASSWORD:
449 case CONFIG_ITEM_STRING:
450 case CONFIG_ITEM_PASSWORD:
453 case CONFIG_ITEM_STRING_LIST:
456 case CONFIG_ITEM_LOADFILE:
457 case CONFIG_ITEM_SAVEFILE:
460 case CONFIG_ITEM_MODULE:
463 case CONFIG_ITEM_INTEGER:
466 case CONFIG_ITEM_RANGED_INTEGER:
469 case CONFIG_ITEM_BOOL:
472 case CONFIG_ITEM_KEY_AFTER_10_3:
475 case CONFIG_ITEM_MODULE_LIST:
483 case CONFIG_ITEM_STRING_LIST:
486 case CONFIG_ITEM_STRING:
487 case CONFIG_ITEM_PASSWORD:
490 case CONFIG_ITEM_STRING_LIST:
493 case CONFIG_ITEM_LOADFILE:
494 case CONFIG_ITEM_SAVEFILE:
497 case CONFIG_ITEM_MODULE:
500 case CONFIG_ITEM_INTEGER:
503 case CONFIG_ITEM_RANGED_INTEGER:
506 case CONFIG_ITEM_BOOL:
509 case CONFIG_ITEM_KEY_AFTER_10_3:
512 case CONFIG_ITEM_MODULE_LIST:
520 case CONFIG_ITEM_LOADFILE:
521 case CONFIG_ITEM_SAVEFILE:
524 case CONFIG_ITEM_STRING:
525 case CONFIG_ITEM_PASSWORD:
528 case CONFIG_ITEM_STRING_LIST:
531 case CONFIG_ITEM_LOADFILE:
532 case CONFIG_ITEM_SAVEFILE:
535 case CONFIG_ITEM_MODULE:
538 case CONFIG_ITEM_INTEGER:
541 case CONFIG_ITEM_RANGED_INTEGER:
544 case CONFIG_ITEM_BOOL:
547 case CONFIG_ITEM_KEY_AFTER_10_3:
550 case CONFIG_ITEM_MODULE_LIST:
558 case CONFIG_ITEM_MODULE:
561 case CONFIG_ITEM_STRING:
562 case CONFIG_ITEM_PASSWORD:
565 case CONFIG_ITEM_STRING_LIST:
568 case CONFIG_ITEM_LOADFILE:
569 case CONFIG_ITEM_SAVEFILE:
572 case CONFIG_ITEM_MODULE:
575 case CONFIG_ITEM_INTEGER:
578 case CONFIG_ITEM_RANGED_INTEGER:
581 case CONFIG_ITEM_BOOL:
584 case CONFIG_ITEM_KEY_AFTER_10_3:
587 case CONFIG_ITEM_MODULE_LIST:
595 case CONFIG_ITEM_INTEGER:
598 case CONFIG_ITEM_STRING:
599 case CONFIG_ITEM_PASSWORD:
602 case CONFIG_ITEM_STRING_LIST:
605 case CONFIG_ITEM_LOADFILE:
606 case CONFIG_ITEM_SAVEFILE:
609 case CONFIG_ITEM_MODULE:
612 case CONFIG_ITEM_INTEGER:
615 case CONFIG_ITEM_RANGED_INTEGER:
618 case CONFIG_ITEM_BOOL:
621 case CONFIG_ITEM_KEY_AFTER_10_3:
624 case CONFIG_ITEM_MODULE_LIST:
632 case CONFIG_ITEM_RANGED_INTEGER:
635 case CONFIG_ITEM_STRING:
636 case CONFIG_ITEM_PASSWORD:
639 case CONFIG_ITEM_STRING_LIST:
642 case CONFIG_ITEM_LOADFILE:
643 case CONFIG_ITEM_SAVEFILE:
646 case CONFIG_ITEM_MODULE:
649 case CONFIG_ITEM_INTEGER:
652 case CONFIG_ITEM_RANGED_INTEGER:
655 case CONFIG_ITEM_BOOL:
658 case CONFIG_ITEM_KEY_AFTER_10_3:
661 case CONFIG_ITEM_MODULE_LIST:
669 case CONFIG_ITEM_BOOL:
672 case CONFIG_ITEM_STRING:
673 case CONFIG_ITEM_PASSWORD:
676 case CONFIG_ITEM_STRING_LIST:
679 case CONFIG_ITEM_LOADFILE:
680 case CONFIG_ITEM_SAVEFILE:
683 case CONFIG_ITEM_MODULE:
686 case CONFIG_ITEM_INTEGER:
689 case CONFIG_ITEM_RANGED_INTEGER:
692 case CONFIG_ITEM_BOOL:
695 case CONFIG_ITEM_KEY_AFTER_10_3:
698 case CONFIG_ITEM_MODULE_LIST:
706 case CONFIG_ITEM_KEY_AFTER_10_3:
709 case CONFIG_ITEM_STRING:
710 case CONFIG_ITEM_PASSWORD:
713 case CONFIG_ITEM_STRING_LIST:
716 case CONFIG_ITEM_LOADFILE:
717 case CONFIG_ITEM_SAVEFILE:
720 case CONFIG_ITEM_MODULE:
723 case CONFIG_ITEM_INTEGER:
726 case CONFIG_ITEM_RANGED_INTEGER:
729 case CONFIG_ITEM_BOOL:
732 case CONFIG_ITEM_KEY_AFTER_10_3:
735 case CONFIG_ITEM_MODULE_LIST:
743 case CONFIG_ITEM_MODULE_LIST:
746 case CONFIG_ITEM_STRING:
747 case CONFIG_ITEM_PASSWORD:
750 case CONFIG_ITEM_STRING_LIST:
753 case CONFIG_ITEM_LOADFILE:
754 case CONFIG_ITEM_SAVEFILE:
757 case CONFIG_ITEM_MODULE:
760 case CONFIG_ITEM_INTEGER:
763 case CONFIG_ITEM_RANGED_INTEGER:
766 case CONFIG_ITEM_BOOL:
769 case CONFIG_ITEM_KEY_AFTER_10_3:
772 case CONFIG_ITEM_MODULE_LIST:
787 + (VLCConfigControl *)newControl: (module_config_t *)_p_item
788 withView: (NSView *)o_parent_view
790 VLCConfigControl *p_control = NULL;
792 switch( _p_item->i_type )
794 case CONFIG_ITEM_STRING:
795 case CONFIG_ITEM_PASSWORD:
796 if( !_p_item->i_list )
798 p_control = [[StringConfigControl alloc]
799 initWithItem: _p_item
800 withView: o_parent_view];
804 p_control = [[StringListConfigControl alloc]
805 initWithItem: _p_item
806 withView: o_parent_view];
809 case CONFIG_ITEM_LOADFILE:
810 case CONFIG_ITEM_SAVEFILE:
811 case CONFIG_ITEM_DIRECTORY:
812 p_control = [[FileConfigControl alloc]
813 initWithItem: _p_item
814 withView: o_parent_view];
816 case CONFIG_ITEM_MODULE:
817 case CONFIG_ITEM_MODULE_CAT:
818 p_control = [[ModuleConfigControl alloc]
819 initWithItem: _p_item
820 withView: o_parent_view];
822 case CONFIG_ITEM_INTEGER:
823 if( _p_item->i_list )
825 p_control = [[IntegerListConfigControl alloc]
826 initWithItem: _p_item
827 withView: o_parent_view];
829 else if( _p_item->min.i != 0 || _p_item->max.i != 0 )
831 p_control = [[RangedIntegerConfigControl alloc]
832 initWithItem: _p_item
833 withView: o_parent_view];
837 p_control = [[IntegerConfigControl alloc]
838 initWithItem: _p_item
839 withView: o_parent_view];
842 case CONFIG_ITEM_BOOL:
843 p_control = [[BoolConfigControl alloc]
844 initWithItem: _p_item
845 withView: o_parent_view];
847 case CONFIG_ITEM_FLOAT:
848 if( _p_item->min.f != 0 || _p_item->max.f != 0 )
850 p_control = [[RangedFloatConfigControl alloc]
851 initWithItem: _p_item
852 withView: o_parent_view];
856 p_control = [[FloatConfigControl alloc]
857 initWithItem: _p_item
858 withView: o_parent_view];
861 case CONFIG_ITEM_KEY:
862 p_control = [[KeyConfigControl alloc]
863 initWithItem: _p_item
864 withView: o_parent_view];
866 case CONFIG_ITEM_MODULE_LIST:
867 case CONFIG_ITEM_MODULE_LIST_CAT:
868 p_control = [[ModuleListConfigControl alloc]
869 initWithItem: _p_item
870 withView: o_parent_view];
880 return [[VLCMain sharedInstance] localizedString: psz_name];
908 - (char *)stringValue
916 switch( p_item->i_type )
918 case CONFIG_ITEM_STRING:
919 case CONFIG_ITEM_PASSWORD:
920 case CONFIG_ITEM_LOADFILE:
921 case CONFIG_ITEM_SAVEFILE:
922 case CONFIG_ITEM_DIRECTORY:
923 case CONFIG_ITEM_MODULE:
924 case CONFIG_ITEM_MODULE_LIST:
925 case CONFIG_ITEM_MODULE_LIST_CAT:
926 config_PutPsz( VLCIntf, psz_name, [self stringValue] );
928 case CONFIG_ITEM_KEY:
929 /* So you don't need to restart to have the changes take effect */
930 val.i_int = [self intValue];
931 var_Set( VLCIntf->p_libvlc, psz_name, val );
932 case CONFIG_ITEM_INTEGER:
933 case CONFIG_ITEM_BOOL:
934 config_PutInt( VLCIntf, psz_name, [self intValue] );
936 case CONFIG_ITEM_FLOAT:
937 config_PutFloat( VLCIntf, psz_name, [self floatValue] );
948 return [o_label frame].size.width;
951 - (void) alignWithXPosition:(int)i_xPos;
953 /* FIXME: not implemented atm, but created to shut up the warning
954 * about "method definition not found" -- FK @ 7/24/05 */
958 @implementation StringConfigControl
959 - (id) initWithItem: (module_config_t *)_p_item
960 withView: (NSView *)o_parent_view
962 NSRect mainFrame = [o_parent_view frame];
963 NSString *o_labelString, *o_textfieldString, *o_textfieldTooltip;
964 mainFrame.size.height = 22;
965 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN;
966 mainFrame.origin.x = LEFTMARGIN;
967 mainFrame.origin.y = 0;
969 if( [super initWithFrame: mainFrame item: _p_item] != nil )
971 if( p_item->i_type == CONFIG_ITEM_PASSWORD )
972 i_view_type = CONFIG_ITEM_PASSWORD;
974 i_view_type = CONFIG_ITEM_STRING;
976 o_textfieldTooltip = [[VLCMain sharedInstance] wrapString:
977 [[VLCMain sharedInstance] localizedString: (char *)p_item->psz_longtext]
978 toWidth: PREFS_WRAP];
981 if( p_item->psz_text )
982 o_labelString = [[VLCMain sharedInstance]
983 localizedString: (char *)p_item->psz_text];
985 o_labelString = [NSString stringWithString:@""];
986 ADD_LABEL( o_label, mainFrame, 0, -3, o_labelString, o_textfieldTooltip )
987 [o_label setAutoresizingMask:NSViewNotSizable ];
988 [self addSubview: o_label];
990 /* build the textfield */
991 if( p_item->value.psz )
992 o_textfieldString = [[VLCMain sharedInstance]
993 localizedString: (char *)p_item->value.psz];
995 o_textfieldString = [NSString stringWithString: @""];
996 if( p_item->i_type == CONFIG_ITEM_PASSWORD )
998 ADD_SECURETEXTFIELD( o_textfield, mainFrame, [o_label frame].size.width + 2,
999 0, mainFrame.size.width - [o_label frame].size.width -
1000 2, o_textfieldTooltip, o_textfieldString )
1004 ADD_TEXTFIELD( o_textfield, mainFrame, [o_label frame].size.width + 2,
1005 0, mainFrame.size.width - [o_label frame].size.width -
1006 2, o_textfieldTooltip, o_textfieldString )
1008 [o_textfield setAutoresizingMask:NSViewWidthSizable ];
1010 [self addSubview: o_textfield];
1015 - (void) alignWithXPosition:(int)i_xPos
1018 NSRect superFrame = [self frame];
1019 frame = [o_label frame];
1020 frame.origin.x = i_xPos - frame.size.width - 3;
1021 [o_label setFrame:frame];
1023 frame = [o_textfield frame];
1024 frame.origin.x = i_xPos + 2;
1025 frame.size.width = superFrame.size.width - frame.origin.x - 1;
1026 [o_textfield setFrame:frame];
1031 [o_textfield release];
1035 - (char *)stringValue
1037 return [[VLCMain sharedInstance] delocalizeString:
1038 [o_textfield stringValue]];
1043 NSString *o_textfieldString;
1044 char *psz_value = config_GetPsz( VLCIntf, p_item->psz_name );
1046 o_textfieldString = [[VLCMain sharedInstance]
1047 localizedString: psz_value];
1049 o_textfieldString = [NSString stringWithString: @""];
1051 [super resetValues];
1055 @implementation StringListConfigControl
1056 - (id) initWithItem: (module_config_t *)_p_item
1057 withView: (NSView *)o_parent_view
1059 NSRect mainFrame = [o_parent_view frame];
1060 NSString *o_labelString, *o_textfieldTooltip;
1061 mainFrame.size.height = 22;
1062 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN + 1;
1063 mainFrame.origin.x = LEFTMARGIN;
1064 mainFrame.origin.y = 0;
1066 if( [super initWithFrame: mainFrame item: _p_item] != nil )
1069 i_view_type = CONFIG_ITEM_STRING_LIST;
1071 o_textfieldTooltip = [[VLCMain sharedInstance] wrapString:
1072 [[VLCMain sharedInstance]
1073 localizedString: (char *)p_item->psz_longtext ] toWidth: PREFS_WRAP];
1076 if( p_item->psz_text )
1077 o_labelString = [[VLCMain sharedInstance]
1078 localizedString: (char *)p_item->psz_text];
1080 o_labelString = [NSString stringWithString:@""];
1081 ADD_LABEL( o_label, mainFrame, 0, -3, o_labelString, o_textfieldTooltip )
1082 [o_label setAutoresizingMask:NSViewNotSizable ];
1083 [self addSubview: o_label];
1085 /* build the textfield */
1086 ADD_COMBO( o_combo, mainFrame, [o_label frame].size.width,
1087 -2, 0, o_textfieldTooltip )
1088 [o_combo setAutoresizingMask:NSViewWidthSizable ];
1089 for( i_index = 0; i_index < p_item->i_list; i_index++ )
1091 if( !p_item->value.psz && !p_item->ppsz_list[i_index] )
1092 [o_combo selectItemAtIndex: i_index];
1093 else if( p_item->value.psz && p_item->ppsz_list[i_index] &&
1094 !strcmp( p_item->value.psz, p_item->ppsz_list[i_index] ) )
1095 [o_combo selectItemAtIndex: i_index];
1097 [self addSubview: o_combo];
1102 - (void) alignWithXPosition:(int)i_xPos
1105 NSRect superFrame = [self frame];
1106 frame = [o_label frame];
1107 frame.origin.x = i_xPos - frame.size.width - 3;
1108 [o_label setFrame:frame];
1110 frame = [o_combo frame];
1111 frame.origin.x = i_xPos + 2;
1112 frame.size.width = superFrame.size.width - frame.origin.x + 2;
1113 [o_combo setFrame:frame];
1122 - (char *)stringValue
1124 if( [o_combo indexOfSelectedItem] >= 0 )
1125 return strdup( p_item->ppsz_list[[o_combo indexOfSelectedItem]] );
1127 return strdup( [[VLCMain sharedInstance]
1128 delocalizeString: [o_combo stringValue]] );
1134 [o_combo reloadData];
1135 char *psz_value = config_GetPsz( VLCIntf, p_item->psz_name );
1137 for( i_index = 0; i_index < p_item->i_list; i_index++ )
1139 if( !psz_value && !p_item->ppsz_list[i_index] )
1140 [o_combo selectItemAtIndex: i_index];
1141 else if( psz_value && p_item->ppsz_list[i_index] &&
1142 !strcmp( psz_value, p_item->ppsz_list[i_index] ) )
1143 [o_combo selectItemAtIndex: i_index];
1147 [super resetValues];
1151 @implementation StringListConfigControl (NSComboBoxDataSource)
1152 - (NSInteger)numberOfItemsInComboBox:(NSComboBox *)aComboBox
1154 return p_item->i_list;
1157 - (id)comboBox:(NSComboBox *)aComboBox objectValueForItemAtIndex:(NSInteger)i_index
1159 if( p_item->ppsz_list_text && p_item->ppsz_list_text[i_index] )
1161 return [[VLCMain sharedInstance]
1162 localizedString: (char *)p_item->ppsz_list_text[i_index]];
1163 } else return [[VLCMain sharedInstance]
1164 localizedString: (char *)p_item->ppsz_list[i_index]];
1168 @implementation FileConfigControl
1169 - (id) initWithItem: (module_config_t *)_p_item
1170 withView: (NSView *)o_parent_view
1172 NSRect mainFrame = [o_parent_view frame];
1173 NSString *o_labelString, *o_itemTooltip, *o_textfieldString;
1174 mainFrame.size.height = 46;
1175 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN;
1176 mainFrame.origin.x = LEFTMARGIN;
1177 mainFrame.origin.y = 0;
1179 if( [super initWithFrame: mainFrame item: _p_item] != nil )
1181 i_view_type = CONFIG_ITEM_LOADFILE;
1183 o_itemTooltip = [[VLCMain sharedInstance]
1184 wrapString: [[VLCMain sharedInstance]
1185 localizedString: (char *)p_item->psz_longtext ] toWidth: PREFS_WRAP];
1187 /* is it a directory */
1188 b_directory = ( [self type] == CONFIG_ITEM_DIRECTORY ) ? YES : NO;
1191 if( p_item->psz_text )
1192 o_labelString = [[VLCMain sharedInstance]
1193 localizedString: (char *)p_item->psz_text];
1195 o_labelString = [NSString stringWithString:@""];
1196 ADD_LABEL( o_label, mainFrame, 0, 3, o_labelString, o_itemTooltip )
1197 [o_label setAutoresizingMask:NSViewNotSizable ];
1198 [self addSubview: o_label];
1200 /* build the button */
1201 ADD_RIGHT_BUTTON( o_button, mainFrame, 0, 0, o_itemTooltip,
1203 [o_button setAutoresizingMask:NSViewMinXMargin ];
1204 [self addSubview: o_button];
1206 /* build the textfield */
1207 if( p_item->value.psz )
1208 o_textfieldString = [NSString stringWithFormat: @"%s", (char *)p_item->value.psz];
1210 o_textfieldString = [NSString stringWithString: @""];
1211 ADD_TEXTFIELD( o_textfield, mainFrame, 12, 2, mainFrame.size.width -
1212 8 - [o_button frame].size.width,
1213 o_itemTooltip, o_textfieldString )
1214 [o_textfield setAutoresizingMask:NSViewWidthSizable ];
1215 [self addSubview: o_textfield];
1220 - (void) alignWithXPosition:(int)i_xPos
1227 [o_textfield release];
1232 - (IBAction)openFileDialog: (id)sender
1234 NSOpenPanel *o_open_panel = [NSOpenPanel openPanel];
1236 [o_open_panel setTitle: (b_directory)?
1237 _NS("Select a directory"):_NS("Select a file")];
1238 [o_open_panel setPrompt: _NS("Select")];
1239 [o_open_panel setAllowsMultipleSelection: NO];
1240 [o_open_panel setCanChooseFiles: !b_directory];
1241 [o_open_panel setCanChooseDirectories: b_directory];
1242 [o_open_panel beginSheetForDirectory:nil
1245 modalForWindow:[sender window]
1247 didEndSelector: @selector(pathChosenInPanel:
1253 - (void)pathChosenInPanel:(NSOpenPanel *)o_sheet
1254 withReturn:(int)i_return_code contextInfo:(void *)o_context_info
1256 if( i_return_code == NSOKButton )
1258 NSString *o_path = [[[o_sheet URLs] objectAtIndex: 0] path];
1259 [o_textfield setStringValue: o_path];
1263 - (char *)stringValue
1265 if( [[o_textfield stringValue] length] != 0)
1266 return strdup( [[o_textfield stringValue] fileSystemRepresentation] );
1273 NSString *o_textfieldString;
1274 char *psz_value = config_GetPsz( VLCIntf, p_item->psz_name );
1276 o_textfieldString = [NSString stringWithFormat: @"%s", psz_value];
1278 o_textfieldString = [NSString stringWithString: @""];
1281 [super resetValues];
1285 @implementation ModuleConfigControl
1286 - (id) initWithItem: (module_config_t *)_p_item
1287 withView: (NSView *)o_parent_view
1289 NSRect mainFrame = [o_parent_view frame];
1290 NSString *o_labelString, *o_popupTooltip;
1291 mainFrame.size.height = 22;
1292 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN + 1;
1293 mainFrame.origin.x = LEFTMARGIN;
1294 mainFrame.origin.y = 0;
1296 if( [super initWithFrame: mainFrame item: _p_item] != nil )
1298 i_view_type = CONFIG_ITEM_MODULE;
1300 o_popupTooltip = [[VLCMain sharedInstance] wrapString:
1301 [[VLCMain sharedInstance]
1302 localizedString: (char *)p_item->psz_longtext ] toWidth: PREFS_WRAP];
1305 if( p_item->psz_text )
1306 o_labelString = [[VLCMain sharedInstance]
1307 localizedString: (char *)p_item->psz_text];
1309 o_labelString = [NSString stringWithString:@""];
1310 ADD_LABEL( o_label, mainFrame, 0, -1, o_labelString, o_popupTooltip )
1311 [o_label setAutoresizingMask:NSViewNotSizable ];
1312 [self addSubview: o_label];
1314 /* build the popup */
1315 ADD_POPUP( o_popup, mainFrame, [o_label frame].size.width,
1316 -2, 0, o_popupTooltip )
1317 [o_popup setAutoresizingMask:NSViewWidthSizable ];
1318 [o_popup addItemWithTitle: _NS("Default")];
1319 [[o_popup lastItem] setTag: -1];
1320 [o_popup selectItem: [o_popup lastItem]];
1323 [self addSubview: o_popup];
1328 - (void) alignWithXPosition:(int)i_xPos
1331 NSRect superFrame = [self frame];
1332 frame = [o_label frame];
1333 frame.origin.x = i_xPos - frame.size.width - 3;
1334 [o_label setFrame:frame];
1336 frame = [o_popup frame];
1337 frame.origin.x = i_xPos - 1;
1338 frame.size.width = superFrame.size.width - frame.origin.x + 2;
1339 [o_popup setFrame:frame];
1348 - (char *)stringValue
1350 NSString *newval = [o_popup titleOfSelectedItem];
1351 char *returnval = NULL;
1352 size_t i_module_index;
1353 module_t *p_parser, **p_list;
1355 p_list = module_list_get( NULL );
1356 for( i_module_index = 0; p_list[i_module_index]; i_module_index++ )
1358 p_parser = p_list[i_module_index];
1360 if( p_item->i_type == CONFIG_ITEM_MODULE )
1362 if( module_provides( p_parser, p_item->psz_type ) )
1364 NSString *o_description = [[VLCMain sharedInstance]
1365 localizedString: module_get_name( p_parser, TRUE )];
1366 if( [newval isEqualToString: o_description] )
1368 returnval = strdup( module_get_object( p_parser ));
1377 if( module_is_main( p_parser) )
1379 unsigned int confsize, unused;
1380 module_config_t *p_config = module_config_get( p_parser, &confsize );
1381 for ( i = 0; i < confsize; i++ )
1383 module_config_t *p_item = p_config + i;
1384 /* Hack: required subcategory is stored in i_min */
1385 if( p_item->i_type == CONFIG_SUBCATEGORY &&
1386 p_item->value.i == p_item->min.i )
1388 NSString *o_description = [[VLCMain sharedInstance]
1389 localizedString: module_get_name( p_parser, TRUE )];
1390 if( [newval isEqualToString: o_description] )
1392 returnval = strdup(module_get_object( p_parser ));
1397 module_config_free( p_config );
1400 module_list_free( p_list );
1406 /* build a list of available modules */
1408 module_t *p_parser, **p_list;
1410 p_list = module_list_get( NULL );
1411 for( i_index = 0; p_list[i_index]; i_index++ )
1413 p_parser = p_list[i_index];
1415 if( p_item->i_type == CONFIG_ITEM_MODULE )
1417 if( module_provides( p_parser, p_item->psz_type ) )
1419 NSString *o_description = [[VLCMain sharedInstance]
1420 localizedString: module_get_name( p_parser, TRUE )];
1421 [o_popup addItemWithTitle: o_description];
1422 char *psz_value = config_GetPsz( VLCIntf, p_item->psz_name );
1425 !strcmp( psz_value, module_get_object( p_parser ) ) )
1426 [o_popup selectItem:[o_popup lastItem]];
1435 if( module_is_main( p_parser ) )
1437 unsigned int confsize;
1438 unsigned int unused;
1439 module_config_t *p_configlist = module_config_get( p_parser, &confsize );
1440 for ( i = 0; i < confsize; i++ )
1442 module_config_t *p_config = &p_configlist[i];
1443 /* Hack: required subcategory is stored in i_min */
1444 if( p_config->i_type == CONFIG_SUBCATEGORY &&
1445 config_GetInt( VLCIntf, p_item->psz_name) == p_item->min.i )
1447 NSString *o_description = [[VLCMain sharedInstance]
1448 localizedString: module_get_name( p_parser, TRUE )];
1449 [o_popup addItemWithTitle: o_description];
1450 char *psz_value = config_GetPsz( VLCIntf, p_item->psz_name );
1452 if( psz_value && !strcmp(psz_value,
1453 module_get_object( p_parser )) )
1454 [o_popup selectItem:[o_popup lastItem]];
1459 module_config_free( p_configlist );
1462 module_list_free( p_list );
1463 [super resetValues];
1467 @implementation IntegerConfigControl
1468 - (id) initWithItem: (module_config_t *)_p_item
1469 withView: (NSView *)o_parent_view
1471 NSRect mainFrame = [o_parent_view frame];
1472 NSString *o_labelString, *o_tooltip;
1473 mainFrame.size.height = 23;
1474 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN + 1;
1475 mainFrame.origin.x = LEFTMARGIN;
1476 mainFrame.origin.y = 0;
1478 if( [super initWithFrame: mainFrame item: _p_item] != nil )
1480 i_view_type = CONFIG_ITEM_INTEGER;
1482 o_tooltip = [[VLCMain sharedInstance] wrapString:
1483 [[VLCMain sharedInstance]
1484 localizedString: (char *)p_item->psz_longtext ] toWidth: PREFS_WRAP];
1487 if( p_item->psz_text )
1488 o_labelString = [[VLCMain sharedInstance]
1489 localizedString: (char *)p_item->psz_text];
1491 o_labelString = [NSString stringWithString:@""];
1492 ADD_LABEL( o_label, mainFrame, 0, -3, o_labelString, o_tooltip )
1493 [o_label setAutoresizingMask:NSViewNotSizable ];
1494 [self addSubview: o_label];
1496 /* build the stepper */
1497 ADD_STEPPER( o_stepper, mainFrame, mainFrame.size.width - 19,
1498 0, o_tooltip, -100000, 100000)
1499 [o_stepper setIntValue: p_item->value.i];
1500 [o_stepper setAutoresizingMask:NSViewMaxXMargin ];
1501 [self addSubview: o_stepper];
1503 ADD_TEXTFIELD( o_textfield, mainFrame, mainFrame.size.width - 19 - 52,
1504 1, 49, o_tooltip, @"" )
1505 [o_textfield setIntValue: p_item->value.i];
1506 [o_textfield setDelegate: self];
1507 [[NSNotificationCenter defaultCenter] addObserver: self
1508 selector: @selector(textfieldChanged:)
1509 name: NSControlTextDidChangeNotification
1510 object: o_textfield];
1511 [o_textfield setAutoresizingMask:NSViewMaxXMargin ];
1512 [self addSubview: o_textfield];
1517 - (void) alignWithXPosition:(int)i_xPos
1520 frame = [o_label frame];
1521 frame.origin.x = i_xPos - frame.size.width - 3;
1522 [o_label setFrame:frame];
1524 frame = [o_textfield frame];
1525 frame.origin.x = i_xPos + 2;
1526 [o_textfield setFrame:frame];
1528 frame = [o_stepper frame];
1529 frame.origin.x = i_xPos + [o_textfield frame].size.width + 5;
1530 [o_stepper setFrame:frame];
1535 [o_stepper release];
1536 [o_textfield release];
1540 - (IBAction)stepperChanged:(id)sender
1542 [o_textfield setIntValue: [o_stepper intValue]];
1545 - (void)textfieldChanged:(NSNotification *)o_notification
1547 [o_stepper setIntValue: [o_textfield intValue]];
1552 return [o_textfield intValue];
1557 [o_textfield setIntValue: config_GetInt(VLCIntf, p_item->psz_name)];
1558 [super resetValues];
1563 @implementation IntegerListConfigControl
1565 - (id) initWithItem: (module_config_t *)_p_item
1566 withView: (NSView *)o_parent_view
1568 NSRect mainFrame = [o_parent_view frame];
1569 NSString *o_labelString, *o_textfieldTooltip;
1570 mainFrame.size.height = 22;
1571 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN + 1;
1572 mainFrame.origin.x = LEFTMARGIN;
1573 mainFrame.origin.y = 0;
1575 if( [super initWithFrame: mainFrame item: _p_item] != nil )
1578 i_view_type = CONFIG_ITEM_STRING_LIST;
1580 o_textfieldTooltip = [[VLCMain sharedInstance] wrapString:
1581 [[VLCMain sharedInstance]
1582 localizedString: (char *)p_item->psz_longtext ] toWidth: PREFS_WRAP];
1585 if( p_item->psz_text )
1586 o_labelString = [[VLCMain sharedInstance]
1587 localizedString: (char *)p_item->psz_text];
1589 o_labelString = [NSString stringWithString:@""];
1590 ADD_LABEL( o_label, mainFrame, 0, -3, o_labelString, o_textfieldTooltip )
1591 [o_label setAutoresizingMask:NSViewNotSizable ];
1592 [self addSubview: o_label];
1594 /* build the textfield */
1595 ADD_COMBO( o_combo, mainFrame, [o_label frame].size.width,
1596 -2, 0, o_textfieldTooltip )
1597 [o_combo setAutoresizingMask:NSViewWidthSizable ];
1598 for( i_index = 0; i_index < p_item->i_list; i_index++ )
1600 if( p_item->value.i == p_item->pi_list[i_index] )
1602 [o_combo selectItemAtIndex: i_index];
1605 [self addSubview: o_combo];
1610 - (void) alignWithXPosition:(int)i_xPos
1613 NSRect superFrame = [self frame];
1614 frame = [o_label frame];
1615 frame.origin.x = i_xPos - frame.size.width - 3;
1616 [o_label setFrame:frame];
1618 frame = [o_combo frame];
1619 frame.origin.x = i_xPos + 2;
1620 frame.size.width = superFrame.size.width - frame.origin.x + 2;
1621 [o_combo setFrame:frame];
1632 if( [o_combo indexOfSelectedItem] >= 0 )
1633 return p_item->pi_list[[o_combo indexOfSelectedItem]];
1635 return [o_combo intValue];
1641 [o_combo reloadData];
1642 for( i_index = 0; i_index < p_item->i_list; i_index++ )
1644 if( config_GetInt( VLCIntf, p_item->psz_name) == p_item->pi_list[i_index] )
1646 [o_combo selectItemAtIndex: i_index];
1653 @implementation IntegerListConfigControl (NSComboBoxDataSource)
1654 - (NSInteger)numberOfItemsInComboBox:(NSComboBox *)aComboBox
1656 return p_item->i_list;
1659 - (id)comboBox:(NSComboBox *)aComboBox objectValueForItemAtIndex:(NSInteger)i_index
1661 if( p_item->ppsz_list_text && p_item->ppsz_list_text[i_index] )
1662 return [[VLCMain sharedInstance]
1663 localizedString: (char *)p_item->ppsz_list_text[i_index]];
1665 return [NSString stringWithFormat: @"%i", p_item->pi_list[i_index]];
1669 @implementation RangedIntegerConfigControl
1670 - (id) initWithItem: (module_config_t *)_p_item
1671 withView: (NSView *)o_parent_view
1673 NSRect mainFrame = [o_parent_view frame];
1674 NSString *o_labelString, *o_tooltip;
1675 mainFrame.size.height = 50;
1676 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN;
1677 mainFrame.origin.x = LEFTMARGIN;
1678 mainFrame.origin.y = 0;
1680 if( [super initWithFrame: mainFrame item: _p_item] != nil )
1682 i_view_type = CONFIG_ITEM_RANGED_INTEGER;
1684 o_tooltip = [[VLCMain sharedInstance] wrapString:
1685 [[VLCMain sharedInstance]
1686 localizedString: (char *)p_item->psz_longtext ] toWidth: PREFS_WRAP];
1689 if( p_item->psz_text )
1690 o_labelString = [[VLCMain sharedInstance]
1691 localizedString: (char *)p_item->psz_text];
1693 o_labelString = [NSString stringWithString:@""];
1694 ADD_LABEL( o_label, mainFrame, 0, -3, o_labelString, o_tooltip )
1695 [o_label setAutoresizingMask:NSViewNotSizable ];
1696 [self addSubview: o_label];
1698 /* build the textfield */
1699 ADD_TEXTFIELD( o_textfield, mainFrame, [o_label frame].size.width + 2,
1700 28, 49, o_tooltip, @"" )
1701 [o_textfield setIntValue: p_item->value.i];
1702 [o_textfield setAutoresizingMask:NSViewMaxXMargin ];
1703 [o_textfield setDelegate: self];
1704 [[NSNotificationCenter defaultCenter] addObserver: self
1705 selector: @selector(textfieldChanged:)
1706 name: NSControlTextDidChangeNotification
1707 object: o_textfield];
1708 [self addSubview: o_textfield];
1710 /* build the mintextfield */
1711 ADD_LABEL( o_textfield_min, mainFrame, 12, -30, @"-8888", @"" )
1712 [o_textfield_min setIntValue: p_item->min.i];
1713 [o_textfield_min setAutoresizingMask:NSViewMaxXMargin ];
1714 [o_textfield_min setAlignment:NSRightTextAlignment];
1715 [self addSubview: o_textfield_min];
1717 /* build the maxtextfield */
1718 ADD_LABEL( o_textfield_max, mainFrame,
1719 mainFrame.size.width - 31, -30, @"8888", @"" )
1720 [o_textfield_max setIntValue: p_item->max.i];
1721 [o_textfield_max setAutoresizingMask:NSViewMinXMargin ];
1722 [self addSubview: o_textfield_max];
1724 /* build the slider */
1725 ADD_SLIDER( o_slider, mainFrame, [o_textfield_min frame].origin.x +
1726 [o_textfield_min frame].size.width + 6, -1, mainFrame.size.width -
1727 [o_textfield_max frame].size.width -
1728 [o_textfield_max frame].size.width - 14 -
1729 [o_textfield_min frame].origin.x, o_tooltip,
1730 p_item->min.i, p_item->max.i )
1731 [o_slider setIntValue: p_item->value.i];
1732 [o_slider setAutoresizingMask:NSViewWidthSizable ];
1733 [o_slider setTarget: self];
1734 [o_slider setAction: @selector(sliderChanged:)];
1735 [o_slider sendActionOn:NSLeftMouseUpMask | NSLeftMouseDownMask |
1736 NSLeftMouseDraggedMask];
1737 [self addSubview: o_slider];
1743 - (void) alignWithXPosition:(int)i_xPos
1746 frame = [o_label frame];
1747 frame.origin.x = i_xPos - frame.size.width - 3;
1748 [o_label setFrame:frame];
1750 frame = [o_textfield frame];
1751 frame.origin.x = i_xPos + 2;
1752 [o_textfield setFrame:frame];
1757 [o_textfield release];
1758 [o_textfield_min release];
1759 [o_textfield_max release];
1764 - (IBAction)sliderChanged:(id)sender
1766 [o_textfield setIntValue: [o_slider intValue]];
1769 - (void)textfieldChanged:(NSNotification *)o_notification
1771 [o_slider setIntValue: [o_textfield intValue]];
1776 return [o_slider intValue];
1781 int value = config_GetInt( VLCIntf, p_item->psz_name );
1782 [o_textfield setIntValue:value];
1783 [o_slider setIntValue:value];
1784 [super resetValues];
1788 @implementation FloatConfigControl
1789 - (id) initWithItem: (module_config_t *)_p_item
1790 withView: (NSView *)o_parent_view
1792 NSRect mainFrame = [o_parent_view frame];
1793 NSString *o_labelString, *o_tooltip;
1794 mainFrame.size.height = 23;
1795 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN + 1;
1796 mainFrame.origin.x = LEFTMARGIN;
1797 mainFrame.origin.y = 0;
1799 if( [super initWithFrame: mainFrame item: _p_item] != nil )
1801 i_view_type = CONFIG_ITEM_INTEGER;
1803 o_tooltip = [[VLCMain sharedInstance] wrapString:
1804 [[VLCMain sharedInstance]
1805 localizedString: (char *)p_item->psz_longtext ] toWidth: PREFS_WRAP];
1808 if( p_item->psz_text )
1809 o_labelString = [[VLCMain sharedInstance]
1810 localizedString: (char *)p_item->psz_text];
1812 o_labelString = [NSString stringWithString:@""];
1813 ADD_LABEL( o_label, mainFrame, 0, -2, o_labelString, o_tooltip )
1814 [o_label setAutoresizingMask:NSViewNotSizable ];
1815 [self addSubview: o_label];
1817 /* build the stepper */
1818 ADD_STEPPER( o_stepper, mainFrame, mainFrame.size.width - 19,
1819 0, o_tooltip, -100000, 100000)
1820 [o_stepper setFloatValue: p_item->value.f];
1821 [o_stepper setAutoresizingMask:NSViewMaxXMargin ];
1822 [self addSubview: o_stepper];
1824 /* build the textfield */
1825 ADD_TEXTFIELD( o_textfield, mainFrame, mainFrame.size.width - 19 - 52,
1826 1, 49, o_tooltip, @"" )
1827 [o_textfield setFloatValue: p_item->value.f];
1828 [o_textfield setDelegate: self];
1829 [[NSNotificationCenter defaultCenter] addObserver: self
1830 selector: @selector(textfieldChanged:)
1831 name: NSControlTextDidChangeNotification
1832 object: o_textfield];
1833 [o_textfield setAutoresizingMask:NSViewMaxXMargin ];
1834 [self addSubview: o_textfield];
1839 - (void) alignWithXPosition:(int)i_xPos
1842 frame = [o_label frame];
1843 frame.origin.x = i_xPos - frame.size.width - 3;
1844 [o_label setFrame:frame];
1846 frame = [o_textfield frame];
1847 frame.origin.x = i_xPos + 2;
1848 [o_textfield setFrame:frame];
1850 frame = [o_stepper frame];
1851 frame.origin.x = i_xPos + [o_textfield frame].size.width + 5;
1852 [o_stepper setFrame:frame];
1857 [o_stepper release];
1858 [o_textfield release];
1862 - (IBAction)stepperChanged:(id)sender
1864 [o_textfield setFloatValue: [o_stepper floatValue]];
1867 - (void)textfieldChanged:(NSNotification *)o_notification
1869 [o_stepper setFloatValue: [o_textfield floatValue]];
1874 return [o_stepper floatValue];
1879 [o_textfield setFloatValue: config_GetFloat( VLCIntf, p_item->psz_name)];
1880 [super resetValues];
1884 @implementation RangedFloatConfigControl
1885 - (id) initWithItem: (module_config_t *)_p_item
1886 withView: (NSView *)o_parent_view
1888 NSRect mainFrame = [o_parent_view frame];
1889 NSString *o_labelString, *o_tooltip;
1890 mainFrame.size.height = 50;
1891 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN;
1892 mainFrame.origin.x = LEFTMARGIN;
1893 mainFrame.origin.y = 0;
1895 if( [super initWithFrame: mainFrame item: _p_item] != nil )
1897 i_view_type = CONFIG_ITEM_RANGED_INTEGER;
1899 o_tooltip = [[VLCMain sharedInstance] wrapString:
1900 [[VLCMain sharedInstance]
1901 localizedString: (char *)p_item->psz_longtext ] toWidth: PREFS_WRAP];
1904 if( p_item->psz_text )
1905 o_labelString = [[VLCMain sharedInstance]
1906 localizedString: (char *)p_item->psz_text];
1908 o_labelString = [NSString stringWithString:@""];
1909 ADD_LABEL( o_label, mainFrame, 0, -3, o_labelString, o_tooltip )
1910 [o_label setAutoresizingMask:NSViewNotSizable ];
1911 [self addSubview: o_label];
1913 /* build the textfield */
1914 ADD_TEXTFIELD( o_textfield, mainFrame, [o_label frame].size.width + 2,
1915 28, 49, o_tooltip, @"" )
1916 [o_textfield setFloatValue: p_item->value.f];
1917 [o_textfield setAutoresizingMask:NSViewMaxXMargin ];
1918 [o_textfield setDelegate: self];
1919 [[NSNotificationCenter defaultCenter] addObserver: self
1920 selector: @selector(textfieldChanged:)
1921 name: NSControlTextDidChangeNotification
1922 object: o_textfield];
1923 [self addSubview: o_textfield];
1925 /* build the mintextfield */
1926 ADD_LABEL( o_textfield_min, mainFrame, 12, -30, @"-8888", @"" )
1927 [o_textfield_min setFloatValue: p_item->min.f];
1928 [o_textfield_min setAutoresizingMask:NSViewMaxXMargin ];
1929 [o_textfield_min setAlignment:NSRightTextAlignment];
1930 [self addSubview: o_textfield_min];
1932 /* build the maxtextfield */
1933 ADD_LABEL( o_textfield_max, mainFrame, mainFrame.size.width - 31,
1935 [o_textfield_max setFloatValue: p_item->max.f];
1936 [o_textfield_max setAutoresizingMask:NSViewMinXMargin ];
1937 [self addSubview: o_textfield_max];
1939 /* build the slider */
1940 ADD_SLIDER( o_slider, mainFrame, [o_textfield_min frame].origin.x +
1941 [o_textfield_min frame].size.width + 6, -1, mainFrame.size.width -
1942 [o_textfield_max frame].size.width -
1943 [o_textfield_max frame].size.width - 14 -
1944 [o_textfield_min frame].origin.x, o_tooltip, p_item->min.f,
1946 [o_slider setFloatValue: p_item->value.f];
1947 [o_slider setAutoresizingMask:NSViewWidthSizable ];
1948 [o_slider setTarget: self];
1949 [o_slider setAction: @selector(sliderChanged:)];
1950 [o_slider sendActionOn:NSLeftMouseUpMask | NSLeftMouseDownMask |
1951 NSLeftMouseDraggedMask];
1952 [self addSubview: o_slider];
1958 - (void) alignWithXPosition:(int)i_xPos
1961 frame = [o_label frame];
1962 frame.origin.x = i_xPos - frame.size.width - 3;
1963 [o_label setFrame:frame];
1965 frame = [o_textfield frame];
1966 frame.origin.x = i_xPos + 2;
1967 [o_textfield setFrame:frame];
1972 [o_textfield release];
1973 [o_textfield_min release];
1974 [o_textfield_max release];
1979 - (IBAction)sliderChanged:(id)sender
1981 [o_textfield setFloatValue: [o_slider floatValue]];
1984 - (void)textfieldChanged:(NSNotification *)o_notification
1986 [o_slider setFloatValue: [o_textfield floatValue]];
1991 return [o_slider floatValue];
1996 [o_textfield setFloatValue: config_GetFloat(VLCIntf, p_item->psz_name)];
1997 [o_slider setFloatValue: config_GetFloat(VLCIntf, p_item->psz_name)];
1998 [super resetValues];
2002 @implementation BoolConfigControl
2004 - (id) initWithItem: (module_config_t *)_p_item
2005 withView: (NSView *)o_parent_view
2007 NSRect mainFrame = [o_parent_view frame];
2008 NSString *o_labelString, *o_tooltip;
2009 mainFrame.size.height = 17;
2010 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN;
2011 mainFrame.origin.x = LEFTMARGIN;
2012 mainFrame.origin.y = 0;
2014 if( [super initWithFrame: mainFrame item: _p_item] != nil )
2016 i_view_type = CONFIG_ITEM_BOOL;
2018 /* add the checkbox */
2019 o_tooltip = [[VLCMain sharedInstance]
2020 wrapString: [[VLCMain sharedInstance]
2021 localizedString: (char *)p_item->psz_longtext ] toWidth: PREFS_WRAP];
2022 ADD_CHECKBOX( o_checkbox, mainFrame, 0,
2023 0, @"", o_tooltip, p_item->value.i, NSImageLeft)
2024 [o_checkbox setAutoresizingMask:NSViewNotSizable ];
2025 [self addSubview: o_checkbox];
2027 if( p_item->psz_text )
2028 o_labelString = [[VLCMain sharedInstance]
2029 localizedString: (char *)p_item->psz_text];
2031 o_labelString = [NSString stringWithString:@""];
2032 ADD_LABEL( o_label, mainFrame, [o_checkbox frame].size.width, 0, o_labelString, o_tooltip )
2033 [o_label setAutoresizingMask:NSViewNotSizable ];
2034 [self addSubview: o_label];
2041 [o_checkbox release];
2047 return [o_checkbox intValue];
2052 [o_checkbox setState: config_GetInt( VLCIntf, p_item->psz_name)];
2053 [super resetValues];
2057 @implementation KeyConfigControl
2058 - (id) initWithItem: (module_config_t *)_p_item
2059 withView: (NSView *)o_parent_view
2061 NSRect mainFrame = [o_parent_view frame];
2062 NSString *o_labelString, *o_tooltip;
2063 mainFrame.size.height = 22;
2064 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN + 1;
2065 mainFrame.origin.x = LEFTMARGIN;
2066 mainFrame.origin.y = 0;
2068 if( [super initWithFrame: mainFrame item: _p_item] != nil )
2070 i_view_type = CONFIG_ITEM_KEY_AFTER_10_3;
2072 o_tooltip = [[VLCMain sharedInstance] wrapString:
2073 [[VLCMain sharedInstance]
2074 localizedString: (char *)p_item->psz_longtext ] toWidth: PREFS_WRAP];
2077 if( p_item->psz_text )
2078 o_labelString = [[VLCMain sharedInstance]
2079 localizedString: (char *)p_item->psz_text];
2081 o_labelString = [NSString stringWithString:@""];
2082 ADD_LABEL( o_label, mainFrame, 0, -1, o_labelString, o_tooltip )
2083 [o_label setAutoresizingMask:NSViewNotSizable ];
2084 [self addSubview: o_label];
2086 /* build the popup */
2087 ADD_POPUP( o_popup, mainFrame, [o_label frame].origin.x +
2088 [o_label frame].size.width + 3,
2090 [o_popup setAutoresizingMask:NSViewWidthSizable ];
2092 if( o_keys_menu == nil )
2095 o_keys_menu = [[NSMenu alloc] initWithTitle: @"Keys Menu"];
2096 #warning This does not work anymore. FIXME.
2098 for ( i = 0; i < sizeof(vlc_key) / sizeof(key_descriptor_t); i++)
2099 if( vlc_key[i].psz_key_string )
2100 POPULATE_A_KEY( o_keys_menu,
2101 [NSString stringWithUTF8String:vlc_key[i].psz_key_string]
2102 , vlc_key[i].i_key_code)
2105 [o_popup setMenu:[o_keys_menu copyWithZone:nil]];
2106 [o_popup selectItem:[[o_popup menu] itemWithTag:p_item->value.i]];
2107 [self addSubview: o_popup];
2113 - (void) alignWithXPosition:(int)i_xPos
2116 NSRect superFrame = [self frame];
2117 frame = [o_label frame];
2118 frame.origin.x = i_xPos - frame.size.width - 3;
2119 [o_label setFrame:frame];
2121 frame = [o_popup frame];
2122 frame.origin.x = i_xPos - 1;
2123 frame.size.width = superFrame.size.width - frame.origin.x + 2;
2124 [o_popup setFrame:frame];
2135 return [o_popup selectedTag];
2140 [o_popup selectItem:[[o_popup menu] itemWithTag:config_GetInt( VLCIntf, p_item->psz_name )]];
2141 [super resetValues];
2145 @implementation ModuleListConfigControl
2146 - (id) initWithItem: (module_config_t *)_p_item
2147 withView: (NSView *)o_parent_view
2149 if( _p_item->i_type == CONFIG_ITEM_MODULE_LIST )
2153 //Fill our array to know how may items we have...
2154 module_t *p_parser, **p_list;
2155 size_t i_module_index;
2156 NSRect mainFrame = [o_parent_view frame];
2157 NSString *o_labelString, *o_textfieldString, *o_tooltip;
2159 o_modulearray = [[NSMutableArray alloc] initWithCapacity:10];
2160 /* build a list of available modules */
2161 p_list = module_list_get( NULL );
2162 for( i_module_index = 0; p_list[i_module_index]; i_module_index++ )
2165 p_parser = p_list[i_module_index];
2167 if( module_is_main( p_parser ) )
2170 unsigned int confsize;
2171 module_config_t *p_configlist = module_config_get( p_parser, &confsize );
2173 for ( i = 0; i < confsize; i++ )
2175 unsigned int unused;
2176 module_config_t *p_config = &p_configlist[i];
2177 NSString *o_modulelongname, *o_modulename;
2178 NSNumber *o_moduleenabled = nil;
2180 /* Hack: required subcategory is stored in i_min */
2181 if( p_config->i_type == CONFIG_SUBCATEGORY &&
2182 p_config->value.i == _p_item->min.i )
2184 o_modulelongname = [NSString stringWithUTF8String:
2185 module_get_name( p_parser, TRUE )];
2186 o_modulename = [NSString stringWithUTF8String:
2187 module_get_object( p_parser )];
2189 if( _p_item->value.psz &&
2190 strstr( _p_item->value.psz, module_get_object( p_parser ) ) )
2191 o_moduleenabled = [NSNumber numberWithBool:YES];
2193 o_moduleenabled = [NSNumber numberWithBool:NO];
2195 [o_modulearray addObject:[NSMutableArray
2196 arrayWithObjects: o_modulename, o_modulelongname,
2197 o_moduleenabled, nil]];
2200 module_config_free( p_configlist );
2202 module_list_free( p_list );
2204 mainFrame.size.height = 30 + 20 * [o_modulearray count];
2205 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN;
2206 mainFrame.origin.x = LEFTMARGIN;
2207 mainFrame.origin.y = 0;
2208 if( [super initWithFrame: mainFrame item: _p_item] != nil )
2210 i_view_type = CONFIG_ITEM_MODULE_LIST;
2212 o_tooltip = [[VLCMain sharedInstance] wrapString:
2213 [[VLCMain sharedInstance]
2214 localizedString: (char *)p_item->psz_longtext ] toWidth: PREFS_WRAP];
2217 if( p_item->psz_text )
2218 o_labelString = [[VLCMain sharedInstance]
2219 localizedString: (char *)p_item->psz_text];
2221 o_labelString = [NSString stringWithString:@""];
2222 ADD_LABEL( o_label, mainFrame, 0, -3, o_labelString, o_tooltip )
2223 [o_label setAutoresizingMask:NSViewNotSizable ];
2224 [self addSubview: o_label];
2226 /* build the textfield */
2227 if( p_item->value.psz )
2228 o_textfieldString = [[VLCMain sharedInstance]
2229 localizedString: (char *)p_item->value.psz];
2231 o_textfieldString = [NSString stringWithString: @""];
2232 ADD_TEXTFIELD( o_textfield, mainFrame, [o_label frame].size.width + 2,
2233 mainFrame.size.height - 22, mainFrame.size.width -
2234 [o_label frame].size.width - 2, o_tooltip, o_textfieldString )
2235 [o_textfield setAutoresizingMask:NSViewWidthSizable ];
2236 [self addSubview: o_textfield];
2240 NSRect s_rc = mainFrame;
2241 s_rc.size.height = mainFrame.size.height - 30;
2242 s_rc.size.width = mainFrame.size.width - 12;
2245 o_scrollview = [[[NSScrollView alloc] initWithFrame: s_rc] retain];
2246 [o_scrollview setDrawsBackground: NO];
2247 [o_scrollview setBorderType: NSBezelBorder];
2248 [o_scrollview setAutohidesScrollers:YES];
2250 NSTableView *o_tableview;
2251 o_tableview = [[NSTableView alloc] initWithFrame : s_rc];
2252 [o_tableview setUsesAlternatingRowBackgroundColors:YES];
2253 [o_tableview setHeaderView:nil];
2254 /* TODO: find a good way to fix the row height and text size*/
2255 /* FIXME: support for multiple selection... */
2256 // [o_tableview setAllowsMultipleSelection:YES];
2258 NSCell *o_headerCell = [[NSCell alloc] initTextCell:@"Enabled"];
2259 NSCell *o_dataCell = [[NSButtonCell alloc] init];
2260 [(NSButtonCell*)o_dataCell setButtonType:NSSwitchButton];
2261 [o_dataCell setTitle:@""];
2262 [o_dataCell setFont:[NSFont systemFontOfSize:0]];
2263 NSTableColumn *o_tableColumn = [[NSTableColumn alloc]
2264 initWithIdentifier:@"Enabled"];
2265 [o_tableColumn setHeaderCell: o_headerCell];
2266 [o_tableColumn setDataCell: o_dataCell];
2267 [o_tableColumn setWidth:17];
2268 [o_tableview addTableColumn: o_tableColumn];
2270 o_headerCell = [[NSCell alloc] initTextCell:@"Module Name"];
2271 o_dataCell = [[NSTextFieldCell alloc] init];
2272 [o_dataCell setFont:[NSFont systemFontOfSize:12]];
2273 o_tableColumn = [[NSTableColumn alloc]
2274 initWithIdentifier:@"Module"];
2275 [o_tableColumn setHeaderCell: o_headerCell];
2276 [o_tableColumn setDataCell: o_dataCell];
2277 [o_tableColumn setWidth:s_rc.size.width - 34];
2278 [o_tableview addTableColumn: o_tableColumn];
2279 [o_tableview registerForDraggedTypes:[NSArray arrayWithObjects:
2280 @"VLC media player module", nil]];
2282 [o_tableview setDataSource:self];
2283 [o_tableview setTarget: self];
2284 [o_tableview setAction: @selector(tableChanged:)];
2285 [o_tableview sendActionOn:NSLeftMouseUpMask | NSLeftMouseDownMask |
2286 NSLeftMouseDraggedMask];
2287 [o_scrollview setDocumentView: o_tableview];
2289 [o_scrollview setAutoresizingMask:NSViewWidthSizable ];
2290 [o_scrollview setAutohidesScrollers:YES];
2291 [self addSubview: o_scrollview];
2297 - (void) alignWithXPosition:(int)i_xPos
2302 - (IBAction)tableChanged:(id)sender
2304 NSString *o_newstring = @"";
2306 for( i = 0 ; i < [o_modulearray count] ; i++ )
2307 if( [[[o_modulearray objectAtIndex:i] objectAtIndex:2]
2310 o_newstring = [o_newstring stringByAppendingString:
2311 [[o_modulearray objectAtIndex:i] objectAtIndex:0]];
2312 o_newstring = [o_newstring stringByAppendingString:@":"];
2315 [o_textfield setStringValue: [o_newstring
2316 substringToIndex: ([o_newstring length])?[o_newstring length] - 1:0]];
2321 [o_scrollview release];
2326 - (char *)stringValue
2328 return strdup( [[o_textfield stringValue] UTF8String] );
2333 #warning Reset prefs of the module selector is broken atm.
2334 NSLog( @"don't forget about modulelistconfig" );
2335 [super resetValues];
2340 @implementation ModuleListConfigControl (NSTableDataSource)
2342 - (BOOL)tableView:(NSTableView*)table writeRows:(NSArray*)rows
2343 toPasteboard:(NSPasteboard*)pb
2345 // We only want to allow dragging of selected rows.
2346 NSEnumerator *iter = [rows objectEnumerator];
2348 while ((row = [iter nextObject]) != nil)
2350 if (![table isRowSelected:[row intValue]])
2354 [pb declareTypes:[NSArray
2355 arrayWithObject:@"VLC media player module"] owner:nil];
2356 [pb setPropertyList:rows forType:@"VLC media player module"];
2360 - (NSDragOperation)tableView:(NSTableView*)table
2361 validateDrop:(id <NSDraggingInfo>)info proposedRow:(NSInteger)row
2362 proposedDropOperation:(NSTableViewDropOperation)op
2364 // Make drops at the end of the table go to the end.
2367 row = [table numberOfRows];
2368 op = NSTableViewDropAbove;
2369 [table setDropRow:row dropOperation:op];
2372 // We don't ever want to drop onto a row, only between rows.
2373 if (op == NSTableViewDropOn)
2374 [table setDropRow:(row+1) dropOperation:NSTableViewDropAbove];
2375 return NSTableViewDropAbove;
2378 - (BOOL)tableView:(NSTableView*)table acceptDrop:(id <NSDraggingInfo>)info
2379 row:(NSInteger)dropRow dropOperation:(NSTableViewDropOperation)op;
2381 NSPasteboard *pb = [info draggingPasteboard];
2382 NSDragOperation srcMask = [info draggingSourceOperationMask];
2389 // Intra-table drag - data is the array of rows.
2390 if (!accepted && (array =
2391 [pb propertyListForType:@"VLC media player module"]) != NULL)
2393 NSEnumerator *iter = nil;
2395 BOOL isCopy = (srcMask & NSDragOperationMove) ? NO:YES;
2397 iter = [array objectEnumerator];
2398 while ((val = [iter nextObject]) != NULL)
2400 NSArray *o_tmp = [[o_modulearray objectAtIndex:
2401 [val intValue]] mutableCopyWithZone:nil];
2402 [o_modulearray removeObject:o_tmp];
2403 [o_modulearray insertObject:o_tmp
2404 atIndex:(dropRow>[val intValue]) ? dropRow - 1 : dropRow];
2408 // Select the newly-dragged items.
2409 iter = [array objectEnumerator];
2411 [table deselectAll:self];
2413 [self tableChanged:self];
2414 [table setNeedsDisplay:YES];
2415 // Indicate that we finished the drag.
2419 [table setNeedsDisplay:YES];
2423 // An exception occurred. Uh-oh. Update the track table so that
2424 // it stays consistent, and re-raise the exception.
2426 [localException raise];
2427 [table setNeedsDisplay:YES];
2433 - (NSInteger)numberOfRowsInTableView:(NSTableView *)aTableView
2435 return [o_modulearray count];
2438 - (id)tableView:(NSTableView *)aTableView
2439 objectValueForTableColumn:(NSTableColumn *)aTableColumn row:(NSInteger)rowIndex
2441 if( [[aTableColumn identifier] isEqualToString: @"Enabled"] )
2442 return [[o_modulearray objectAtIndex:rowIndex] objectAtIndex:2];
2443 if( [[aTableColumn identifier] isEqualToString: @"Module"] )
2444 return [[o_modulearray objectAtIndex:rowIndex] objectAtIndex:1];
2449 - (void)tableView:(NSTableView *)aTableView setObjectValue:(id)anObject
2450 forTableColumn:(NSTableColumn *)aTableColumn row:(NSInteger)rowIndex
2452 [[o_modulearray objectAtIndex:rowIndex] replaceObjectAtIndex:2
2453 withObject: anObject];