1 /*****************************************************************************
2 * prefs_widgets.m: Preferences controls
3 *****************************************************************************
4 * Copyright (C) 2002-2007 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>
39 #include "prefs_widgets.h"
41 #define PREFS_WRAP 300
42 #define OFFSET_RIGHT 20
43 #define OFFSET_BETWEEN 2
45 #define UPWARDS_WHITE_ARROW "\xE2\x87\xA7"
46 #define OPTION_KEY "\xE2\x8C\xA5"
47 #define UP_ARROWHEAD "\xE2\x8C\x83"
48 #define PLACE_OF_INTEREST_SIGN "\xE2\x8C\x98"
50 #define POPULATE_A_KEY( o_menu, string, value ) \
54 o_mi = [[NSMenuItem alloc] initWithTitle:string \
55 action:nil keyEquivalent:@""]; \
56 [o_mi setKeyEquivalentModifierMask: \
58 [o_mi setAlternate: NO]; \
61 [o_menu addItem: o_mi]; \
63 o_mi = [[NSMenuItem alloc] initWithTitle: \
64 [[NSString stringWithUTF8String: \
66 ] stringByAppendingString: string] \
67 action:nil keyEquivalent:@""]; \
68 [o_mi setKeyEquivalentModifierMask: \
70 [o_mi setAlternate: YES]; \
72 KEY_MODIFIER_CTRL | ( value )]; \
73 [o_menu addItem: o_mi]; \
75 o_mi = [[NSMenuItem alloc] initWithTitle: \
76 [[NSString stringWithUTF8String: \
77 UP_ARROWHEAD OPTION_KEY \
78 ] stringByAppendingString: string] \
79 action:nil keyEquivalent:@""]; \
80 [o_mi setKeyEquivalentModifierMask: \
81 NSControlKeyMask | NSAlternateKeyMask]; \
82 [o_mi setAlternate: YES]; \
84 (KEY_MODIFIER_CTRL | KEY_MODIFIER_ALT) | ( value )]; \
85 [o_menu addItem: o_mi]; \
87 o_mi = [[NSMenuItem alloc] initWithTitle: \
88 [[NSString stringWithUTF8String: \
89 UP_ARROWHEAD UPWARDS_WHITE_ARROW \
90 ] stringByAppendingString: string] \
91 action:nil keyEquivalent:@""]; \
92 [o_mi setKeyEquivalentModifierMask: \
93 NSControlKeyMask | NSShiftKeyMask]; \
94 [o_mi setAlternate: YES]; \
96 (KEY_MODIFIER_CTRL | KEY_MODIFIER_SHIFT) | ( value )]; \
97 [o_menu addItem: o_mi]; \
99 o_mi = [[NSMenuItem alloc] initWithTitle: \
100 [[NSString stringWithUTF8String: \
101 UP_ARROWHEAD PLACE_OF_INTEREST_SIGN \
102 ] stringByAppendingString: string] \
103 action:nil keyEquivalent:@""]; \
104 [o_mi setKeyEquivalentModifierMask: \
105 NSControlKeyMask | NSCommandKeyMask]; \
106 [o_mi setAlternate: YES]; \
108 (KEY_MODIFIER_CTRL | KEY_MODIFIER_COMMAND) | ( value )]; \
109 [o_menu addItem: o_mi]; \
110 /* Ctrl+Alt+Shift */ \
111 o_mi = [[NSMenuItem alloc] initWithTitle: \
112 [[NSString stringWithUTF8String: \
113 UP_ARROWHEAD OPTION_KEY UPWARDS_WHITE_ARROW \
114 ] stringByAppendingString: string] \
115 action:nil keyEquivalent:@""]; \
116 [o_mi setKeyEquivalentModifierMask: \
117 NSControlKeyMask | NSAlternateKeyMask | NSShiftKeyMask]; \
118 [o_mi setAlternate: YES]; \
120 (KEY_MODIFIER_CTRL | KEY_MODIFIER_ALT | KEY_MODIFIER_SHIFT) | \
122 [o_menu addItem: o_mi]; \
123 /* Ctrl+Alt+Apple */ \
124 o_mi = [[NSMenuItem alloc] initWithTitle: \
125 [[NSString stringWithUTF8String: \
126 UP_ARROWHEAD OPTION_KEY PLACE_OF_INTEREST_SIGN \
127 ] stringByAppendingString: string] \
128 action:nil keyEquivalent:@""]; \
129 [o_mi setKeyEquivalentModifierMask: \
130 NSControlKeyMask | NSAlternateKeyMask | NSCommandKeyMask]; \
131 [o_mi setAlternate: YES]; \
133 (KEY_MODIFIER_CTRL | KEY_MODIFIER_ALT | KEY_MODIFIER_COMMAND) | \
135 [o_menu addItem: o_mi]; \
136 /* Ctrl+Shift+Apple */ \
137 o_mi = [[NSMenuItem alloc] initWithTitle: \
138 [[NSString stringWithUTF8String: \
139 UP_ARROWHEAD UPWARDS_WHITE_ARROW PLACE_OF_INTEREST_SIGN \
140 ] stringByAppendingString: string] \
141 action:nil keyEquivalent:@""]; \
142 [o_mi setKeyEquivalentModifierMask: \
143 NSControlKeyMask | NSShiftKeyMask | NSCommandKeyMask]; \
144 [o_mi setAlternate: YES]; \
146 (KEY_MODIFIER_CTRL | KEY_MODIFIER_SHIFT | KEY_MODIFIER_COMMAND) | \
148 [o_menu addItem: o_mi]; \
149 /* Ctrl+Alt+Shift+Apple */ \
150 o_mi = [[NSMenuItem alloc] initWithTitle: \
151 [[NSString stringWithUTF8String: \
152 UP_ARROWHEAD OPTION_KEY UPWARDS_WHITE_ARROW \
153 PLACE_OF_INTEREST_SIGN \
154 ] stringByAppendingString: string] \
155 action:nil keyEquivalent:@""]; \
156 [o_mi setKeyEquivalentModifierMask: \
157 NSControlKeyMask | NSAlternateKeyMask | NSShiftKeyMask | \
159 [o_mi setAlternate: YES]; \
161 (KEY_MODIFIER_CTRL | KEY_MODIFIER_ALT | KEY_MODIFIER_SHIFT | \
162 KEY_MODIFIER_COMMAND) | ( value )]; \
163 [o_menu addItem: o_mi]; \
165 o_mi = [[NSMenuItem alloc] initWithTitle: \
166 [[NSString stringWithUTF8String: \
168 ] stringByAppendingString: string] \
169 action:nil keyEquivalent:@""]; \
170 [o_mi setKeyEquivalentModifierMask: \
171 NSAlternateKeyMask]; \
172 [o_mi setAlternate: YES]; \
174 KEY_MODIFIER_ALT | ( value )]; \
175 [o_menu addItem: o_mi]; \
177 o_mi = [[NSMenuItem alloc] initWithTitle: \
178 [[NSString stringWithUTF8String: \
179 OPTION_KEY UPWARDS_WHITE_ARROW \
180 ] stringByAppendingString: string] \
181 action:nil keyEquivalent:@""]; \
182 [o_mi setKeyEquivalentModifierMask: \
183 NSAlternateKeyMask | NSShiftKeyMask]; \
184 [o_mi setAlternate: YES]; \
186 (KEY_MODIFIER_ALT | KEY_MODIFIER_SHIFT) | ( value )]; \
187 [o_menu addItem: o_mi]; \
189 o_mi = [[NSMenuItem alloc] initWithTitle: \
190 [[NSString stringWithUTF8String: \
191 OPTION_KEY PLACE_OF_INTEREST_SIGN \
192 ] stringByAppendingString: string] \
193 action:nil keyEquivalent:@""]; \
194 [o_mi setKeyEquivalentModifierMask: \
195 NSAlternateKeyMask | NSCommandKeyMask]; \
196 [o_mi setAlternate: YES]; \
198 (KEY_MODIFIER_ALT | KEY_MODIFIER_COMMAND) | ( value )]; \
199 [o_menu addItem: o_mi]; \
200 /* Alt+Shift+Apple */ \
201 o_mi = [[NSMenuItem alloc] initWithTitle: \
202 [[NSString stringWithUTF8String: \
203 OPTION_KEY UPWARDS_WHITE_ARROW PLACE_OF_INTEREST_SIGN \
204 ] stringByAppendingString: string] \
205 action:nil keyEquivalent:@""]; \
206 [o_mi setKeyEquivalentModifierMask: \
207 NSAlternateKeyMask | NSShiftKeyMask | NSCommandKeyMask]; \
208 [o_mi setAlternate: YES]; \
210 (KEY_MODIFIER_ALT | KEY_MODIFIER_SHIFT | KEY_MODIFIER_COMMAND) | \
212 [o_menu addItem: o_mi]; \
214 o_mi = [[NSMenuItem alloc] initWithTitle: \
215 [[NSString stringWithUTF8String: \
216 UPWARDS_WHITE_ARROW \
217 ] stringByAppendingString: string] \
218 action:nil keyEquivalent:@""]; \
219 [o_mi setKeyEquivalentModifierMask: \
221 [o_mi setAlternate: YES]; \
223 KEY_MODIFIER_SHIFT | ( value )]; \
224 [o_menu addItem: o_mi]; \
226 o_mi = [[NSMenuItem alloc] initWithTitle: \
227 [[NSString stringWithUTF8String: \
228 UPWARDS_WHITE_ARROW PLACE_OF_INTEREST_SIGN \
229 ] stringByAppendingString: string] \
230 action:nil keyEquivalent:@""]; \
231 [o_mi setKeyEquivalentModifierMask: \
232 NSShiftKeyMask | NSCommandKeyMask]; \
233 [o_mi setAlternate: YES]; \
235 (KEY_MODIFIER_SHIFT | KEY_MODIFIER_COMMAND) | ( value )]; \
236 [o_menu addItem: o_mi]; \
238 o_mi = [[NSMenuItem alloc] initWithTitle: \
239 [[NSString stringWithUTF8String: \
240 PLACE_OF_INTEREST_SIGN \
241 ] stringByAppendingString: string] \
242 action:nil keyEquivalent:@""]; \
243 [o_mi setKeyEquivalentModifierMask: \
245 [o_mi setAlternate: YES]; \
247 KEY_MODIFIER_COMMAND | ( value )]; \
248 [o_menu addItem: o_mi]; \
251 #define ADD_LABEL( o_label, superFrame, x_offset, my_y_offset, label, \
254 NSRect s_rc = superFrame; \
255 s_rc.size.height = 17; \
256 s_rc.origin.x = x_offset - 3; \
257 s_rc.origin.y = superFrame.size.height - 17 + my_y_offset; \
258 o_label = [[[NSTextField alloc] initWithFrame: s_rc] retain]; \
259 [o_label setDrawsBackground: NO]; \
260 [o_label setBordered: NO]; \
261 [o_label setEditable: NO]; \
262 [o_label setSelectable: NO]; \
263 [o_label setStringValue: label]; \
264 [o_label setToolTip: tooltip]; \
265 [o_label setFont:[NSFont systemFontOfSize:0]]; \
266 [o_label sizeToFit]; \
269 #define ADD_TEXTFIELD( o_textfield, superFrame, x_offset, my_y_offset, \
270 my_width, tooltip, init_value ) \
272 NSRect s_rc = superFrame; \
273 s_rc.origin.x = x_offset; \
274 s_rc.origin.y = my_y_offset; \
275 s_rc.size.height = 22; \
276 s_rc.size.width = my_width; \
277 o_textfield = [[[NSTextField alloc] initWithFrame: s_rc] retain]; \
278 [o_textfield setFont:[NSFont systemFontOfSize:0]]; \
279 [o_textfield setToolTip: tooltip]; \
280 [o_textfield setStringValue: init_value]; \
283 #define ADD_SECURETEXTFIELD( o_textfield, superFrame, x_offset, my_y_offset, \
284 my_width, tooltip, init_value ) \
286 NSRect s_rc = superFrame; \
287 s_rc.origin.x = x_offset; \
288 s_rc.origin.y = my_y_offset; \
289 s_rc.size.height = 22; \
290 s_rc.size.width = my_width; \
291 o_textfield = [[[NSSecureTextField alloc] initWithFrame: s_rc] retain]; \
292 [o_textfield setFont:[NSFont systemFontOfSize:0]]; \
293 [o_textfield setToolTip: tooltip]; \
294 [o_textfield setStringValue: init_value]; \
297 #define ADD_COMBO( o_combo, superFrame, x_offset, my_y_offset, x2_offset, \
300 NSRect s_rc = superFrame; \
301 s_rc.origin.x = x_offset + 2; \
302 s_rc.origin.y = my_y_offset; \
303 s_rc.size.height = 26; \
304 s_rc.size.width = superFrame.size.width + 2 - s_rc.origin.x - \
306 o_combo = [[[NSComboBox alloc] initWithFrame: s_rc] retain]; \
307 [o_combo setFont:[NSFont systemFontOfSize:0]]; \
308 [o_combo setToolTip: tooltip]; \
309 [o_combo setUsesDataSource:TRUE]; \
310 [o_combo setDataSource:self]; \
311 [o_combo setNumberOfVisibleItems:10]; \
312 [o_combo setCompletes:YES]; \
315 #define ADD_RIGHT_BUTTON( o_button, superFrame, x_offset, my_y_offset, \
318 NSRect s_rc = superFrame; \
319 o_button = [[[NSButton alloc] initWithFrame: s_rc] retain]; \
320 [o_button setButtonType: NSMomentaryPushInButton]; \
321 [o_button setBezelStyle: NSRoundedBezelStyle]; \
322 [o_button setTitle: title]; \
323 [o_button setFont:[NSFont systemFontOfSize:0]]; \
324 [o_button sizeToFit]; \
325 s_rc = [o_button frame]; \
326 s_rc.origin.x = superFrame.size.width - [o_button frame].size.width - 6;\
327 s_rc.origin.y = my_y_offset - 6; \
328 s_rc.size.width += 12; \
329 [o_button setFrame: s_rc]; \
330 [o_button setToolTip: tooltip]; \
331 [o_button setTarget: self]; \
332 [o_button setAction: @selector(openFileDialog:)]; \
335 #define ADD_POPUP( o_popup, superFrame, x_offset, my_y_offset, x2_offset, \
338 NSRect s_rc = superFrame; \
339 s_rc.origin.x = x_offset - 1; \
340 s_rc.origin.y = my_y_offset; \
341 s_rc.size.height = 26; \
342 s_rc.size.width = superFrame.size.width + 2 - s_rc.origin.x - \
344 o_popup = [[[NSPopUpButton alloc] initWithFrame: s_rc] retain]; \
345 [o_popup setFont:[NSFont systemFontOfSize:0]]; \
346 [o_popup setToolTip: tooltip]; \
349 #define ADD_STEPPER( o_stepper, superFrame, x_offset, my_y_offset, tooltip, \
352 NSRect s_rc = superFrame; \
353 s_rc.origin.x = x_offset; \
354 s_rc.origin.y = my_y_offset; \
355 s_rc.size.height = 23; \
356 s_rc.size.width = 23; \
357 o_stepper = [[[NSStepper alloc] initWithFrame: s_rc] retain]; \
358 [o_stepper setFont:[NSFont systemFontOfSize:0]]; \
359 [o_stepper setToolTip: tooltip]; \
360 [o_stepper setMaxValue: higher]; \
361 [o_stepper setMinValue: lower]; \
362 [o_stepper setTarget: self]; \
363 [o_stepper setAction: @selector(stepperChanged:)]; \
364 [o_stepper sendActionOn:NSLeftMouseUpMask | NSLeftMouseDownMask | \
365 NSLeftMouseDraggedMask]; \
368 #define ADD_SLIDER( o_slider, superFrame, x_offset, my_y_offset, my_width, \
369 tooltip, lower, higher ) \
371 NSRect s_rc = superFrame; \
372 s_rc.origin.x = x_offset; \
373 s_rc.origin.y = my_y_offset; \
374 s_rc.size.height = 21; \
375 s_rc.size.width = my_width; \
376 o_slider = [[[NSSlider alloc] initWithFrame: s_rc] retain]; \
377 [o_slider setFont:[NSFont systemFontOfSize:0]]; \
378 [o_slider setToolTip: tooltip]; \
379 [o_slider setMaxValue: higher]; \
380 [o_slider setMinValue: lower]; \
383 #define ADD_CHECKBOX( o_checkbox, superFrame, x_offset, my_y_offset, label, \
384 tooltip, init_value, position ) \
386 NSRect s_rc = superFrame; \
387 s_rc.size.height = 18; \
388 s_rc.origin.x = x_offset - 2; \
389 s_rc.origin.y = superFrame.size.height - 18 + my_y_offset; \
390 o_checkbox = [[[NSButton alloc] initWithFrame: s_rc] retain]; \
391 [o_checkbox setFont:[NSFont systemFontOfSize:0]]; \
392 [o_checkbox setButtonType: NSSwitchButton]; \
393 [o_checkbox setImagePosition: position]; \
394 [o_checkbox setIntValue: init_value]; \
395 [o_checkbox setTitle: label]; \
396 [o_checkbox setToolTip: tooltip]; \
397 [o_checkbox sizeToFit]; \
400 @implementation VLCConfigControl
401 - (id)initWithFrame: (NSRect)frame
403 return [self initWithFrame: frame
407 - (id)initWithFrame: (NSRect)frame
408 item: (module_config_t *)_p_item
410 self = [super initWithFrame: frame];
415 psz_name = p_item->psz_name;
417 i_type = p_item->i_type;
419 b_advanced = p_item->b_advanced;
420 [self setAutoresizingMask:NSViewWidthSizable | NSViewMinYMargin ];
425 - (void)setYPos:(int)i_yPos
427 NSRect frame = [self frame];
428 frame.origin.y = i_yPos;
429 [self setFrame:frame];
434 if( o_label ) [o_label release];
439 + (int)calcVerticalMargin: (int)i_curItem lastItem: (int)i_lastItem
444 case CONFIG_ITEM_STRING:
445 case CONFIG_ITEM_PASSWORD:
448 case CONFIG_ITEM_STRING:
449 case CONFIG_ITEM_PASSWORD:
452 case CONFIG_ITEM_STRING_LIST:
455 case CONFIG_ITEM_FILE:
458 case CONFIG_ITEM_MODULE:
461 case CONFIG_ITEM_INTEGER:
464 case CONFIG_ITEM_RANGED_INTEGER:
467 case CONFIG_ITEM_BOOL:
470 case CONFIG_ITEM_KEY_AFTER_10_3:
473 case CONFIG_ITEM_MODULE_LIST:
481 case CONFIG_ITEM_STRING_LIST:
484 case CONFIG_ITEM_STRING:
485 case CONFIG_ITEM_PASSWORD:
488 case CONFIG_ITEM_STRING_LIST:
491 case CONFIG_ITEM_FILE:
494 case CONFIG_ITEM_MODULE:
497 case CONFIG_ITEM_INTEGER:
500 case CONFIG_ITEM_RANGED_INTEGER:
503 case CONFIG_ITEM_BOOL:
506 case CONFIG_ITEM_KEY_AFTER_10_3:
509 case CONFIG_ITEM_MODULE_LIST:
517 case CONFIG_ITEM_FILE:
520 case CONFIG_ITEM_STRING:
521 case CONFIG_ITEM_PASSWORD:
524 case CONFIG_ITEM_STRING_LIST:
527 case CONFIG_ITEM_FILE:
530 case CONFIG_ITEM_MODULE:
533 case CONFIG_ITEM_INTEGER:
536 case CONFIG_ITEM_RANGED_INTEGER:
539 case CONFIG_ITEM_BOOL:
542 case CONFIG_ITEM_KEY_AFTER_10_3:
545 case CONFIG_ITEM_MODULE_LIST:
553 case CONFIG_ITEM_MODULE:
556 case CONFIG_ITEM_STRING:
557 case CONFIG_ITEM_PASSWORD:
560 case CONFIG_ITEM_STRING_LIST:
563 case CONFIG_ITEM_FILE:
566 case CONFIG_ITEM_MODULE:
569 case CONFIG_ITEM_INTEGER:
572 case CONFIG_ITEM_RANGED_INTEGER:
575 case CONFIG_ITEM_BOOL:
578 case CONFIG_ITEM_KEY_AFTER_10_3:
581 case CONFIG_ITEM_MODULE_LIST:
589 case CONFIG_ITEM_INTEGER:
592 case CONFIG_ITEM_STRING:
593 case CONFIG_ITEM_PASSWORD:
596 case CONFIG_ITEM_STRING_LIST:
599 case CONFIG_ITEM_FILE:
602 case CONFIG_ITEM_MODULE:
605 case CONFIG_ITEM_INTEGER:
608 case CONFIG_ITEM_RANGED_INTEGER:
611 case CONFIG_ITEM_BOOL:
614 case CONFIG_ITEM_KEY_AFTER_10_3:
617 case CONFIG_ITEM_MODULE_LIST:
625 case CONFIG_ITEM_RANGED_INTEGER:
628 case CONFIG_ITEM_STRING:
629 case CONFIG_ITEM_PASSWORD:
632 case CONFIG_ITEM_STRING_LIST:
635 case CONFIG_ITEM_FILE:
638 case CONFIG_ITEM_MODULE:
641 case CONFIG_ITEM_INTEGER:
644 case CONFIG_ITEM_RANGED_INTEGER:
647 case CONFIG_ITEM_BOOL:
650 case CONFIG_ITEM_KEY_AFTER_10_3:
653 case CONFIG_ITEM_MODULE_LIST:
661 case CONFIG_ITEM_BOOL:
664 case CONFIG_ITEM_STRING:
665 case CONFIG_ITEM_PASSWORD:
668 case CONFIG_ITEM_STRING_LIST:
671 case CONFIG_ITEM_FILE:
674 case CONFIG_ITEM_MODULE:
677 case CONFIG_ITEM_INTEGER:
680 case CONFIG_ITEM_RANGED_INTEGER:
683 case CONFIG_ITEM_BOOL:
686 case CONFIG_ITEM_KEY_AFTER_10_3:
689 case CONFIG_ITEM_MODULE_LIST:
697 case CONFIG_ITEM_KEY_AFTER_10_3:
700 case CONFIG_ITEM_STRING:
701 case CONFIG_ITEM_PASSWORD:
704 case CONFIG_ITEM_STRING_LIST:
707 case CONFIG_ITEM_FILE:
710 case CONFIG_ITEM_MODULE:
713 case CONFIG_ITEM_INTEGER:
716 case CONFIG_ITEM_RANGED_INTEGER:
719 case CONFIG_ITEM_BOOL:
722 case CONFIG_ITEM_KEY_AFTER_10_3:
725 case CONFIG_ITEM_MODULE_LIST:
733 case CONFIG_ITEM_MODULE_LIST:
736 case CONFIG_ITEM_STRING:
737 case CONFIG_ITEM_PASSWORD:
740 case CONFIG_ITEM_STRING_LIST:
743 case CONFIG_ITEM_FILE:
746 case CONFIG_ITEM_MODULE:
749 case CONFIG_ITEM_INTEGER:
752 case CONFIG_ITEM_RANGED_INTEGER:
755 case CONFIG_ITEM_BOOL:
758 case CONFIG_ITEM_KEY_AFTER_10_3:
761 case CONFIG_ITEM_MODULE_LIST:
776 + (VLCConfigControl *)newControl: (module_config_t *)_p_item
777 withView: (NSView *)o_parent_view
779 VLCConfigControl *p_control = NULL;
781 switch( _p_item->i_type )
783 case CONFIG_ITEM_STRING:
784 case CONFIG_ITEM_PASSWORD:
785 if( !_p_item->i_list )
787 p_control = [[StringConfigControl alloc]
788 initWithItem: _p_item
789 withView: o_parent_view];
793 p_control = [[StringListConfigControl alloc]
794 initWithItem: _p_item
795 withView: o_parent_view];
798 case CONFIG_ITEM_FILE:
799 case CONFIG_ITEM_DIRECTORY:
800 p_control = [[FileConfigControl alloc]
801 initWithItem: _p_item
802 withView: o_parent_view];
804 case CONFIG_ITEM_MODULE:
805 case CONFIG_ITEM_MODULE_CAT:
806 p_control = [[ModuleConfigControl alloc]
807 initWithItem: _p_item
808 withView: o_parent_view];
810 case CONFIG_ITEM_INTEGER:
811 if( _p_item->i_list )
813 p_control = [[IntegerListConfigControl alloc]
814 initWithItem: _p_item
815 withView: o_parent_view];
817 else if( _p_item->min.i != 0 || _p_item->max.i != 0 )
819 p_control = [[RangedIntegerConfigControl alloc]
820 initWithItem: _p_item
821 withView: o_parent_view];
825 p_control = [[IntegerConfigControl alloc]
826 initWithItem: _p_item
827 withView: o_parent_view];
830 case CONFIG_ITEM_BOOL:
831 p_control = [[BoolConfigControl alloc]
832 initWithItem: _p_item
833 withView: o_parent_view];
835 case CONFIG_ITEM_FLOAT:
836 if( _p_item->min.f != 0 || _p_item->max.f != 0 )
838 p_control = [[RangedFloatConfigControl alloc]
839 initWithItem: _p_item
840 withView: o_parent_view];
844 p_control = [[FloatConfigControl alloc]
845 initWithItem: _p_item
846 withView: o_parent_view];
849 case CONFIG_ITEM_KEY:
850 p_control = [[KeyConfigControl alloc]
851 initWithItem: _p_item
852 withView: o_parent_view];
854 case CONFIG_ITEM_MODULE_LIST:
855 case CONFIG_ITEM_MODULE_LIST_CAT:
856 p_control = [[ModuleListConfigControl alloc]
857 initWithItem: _p_item
858 withView: o_parent_view];
868 return [[VLCMain sharedInstance] localizedString: psz_name];
896 - (char *)stringValue
904 switch( p_item->i_type )
906 case CONFIG_ITEM_STRING:
907 case CONFIG_ITEM_PASSWORD:
908 case CONFIG_ITEM_FILE:
909 case CONFIG_ITEM_DIRECTORY:
910 case CONFIG_ITEM_MODULE:
911 case CONFIG_ITEM_MODULE_LIST:
912 case CONFIG_ITEM_MODULE_LIST_CAT:
913 config_PutPsz( VLCIntf, psz_name, [self stringValue] );
915 case CONFIG_ITEM_KEY:
916 /* So you don't need to restart to have the changes take effect */
917 val.i_int = [self intValue];
918 var_Set( VLCIntf->p_libvlc, psz_name, val );
919 case CONFIG_ITEM_INTEGER:
920 case CONFIG_ITEM_BOOL:
921 config_PutInt( VLCIntf, psz_name, [self intValue] );
923 case CONFIG_ITEM_FLOAT:
924 config_PutFloat( VLCIntf, psz_name, [self floatValue] );
935 return [o_label frame].size.width;
938 - (void) alignWithXPosition:(int)i_xPos;
940 /* FIXME: not implemented atm, but created to shut up the warning
941 * about "method definition not found" -- FK @ 7/24/05 */
945 @implementation StringConfigControl
946 - (id) initWithItem: (module_config_t *)_p_item
947 withView: (NSView *)o_parent_view
949 NSRect mainFrame = [o_parent_view frame];
950 NSString *o_labelString, *o_textfieldString, *o_textfieldTooltip;
951 mainFrame.size.height = 22;
952 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN;
953 mainFrame.origin.x = LEFTMARGIN;
954 mainFrame.origin.y = 0;
956 if( [super initWithFrame: mainFrame item: _p_item] != nil )
958 if( p_item->i_type == CONFIG_ITEM_PASSWORD )
959 i_view_type = CONFIG_ITEM_PASSWORD;
961 i_view_type = CONFIG_ITEM_STRING;
963 o_textfieldTooltip = [[VLCMain sharedInstance] wrapString:
964 [[VLCMain sharedInstance] localizedString: (char *)p_item->psz_longtext]
965 toWidth: PREFS_WRAP];
968 if( p_item->psz_text )
969 o_labelString = [[VLCMain sharedInstance]
970 localizedString: (char *)p_item->psz_text];
972 o_labelString = [NSString stringWithString:@""];
973 ADD_LABEL( o_label, mainFrame, 0, -3, o_labelString, o_textfieldTooltip )
974 [o_label setAutoresizingMask:NSViewNotSizable ];
975 [self addSubview: o_label];
977 /* build the textfield */
978 if( p_item->value.psz )
979 o_textfieldString = [[VLCMain sharedInstance]
980 localizedString: (char *)p_item->value.psz];
982 o_textfieldString = [NSString stringWithString: @""];
983 if( p_item->i_type == CONFIG_ITEM_PASSWORD )
985 ADD_SECURETEXTFIELD( o_textfield, mainFrame, [o_label frame].size.width + 2,
986 0, mainFrame.size.width - [o_label frame].size.width -
987 2, o_textfieldTooltip, o_textfieldString )
991 ADD_TEXTFIELD( o_textfield, mainFrame, [o_label frame].size.width + 2,
992 0, mainFrame.size.width - [o_label frame].size.width -
993 2, o_textfieldTooltip, o_textfieldString )
995 [o_textfield setAutoresizingMask:NSViewWidthSizable ];
997 [self addSubview: o_textfield];
1002 - (void) alignWithXPosition:(int)i_xPos
1005 NSRect superFrame = [self frame];
1006 frame = [o_label frame];
1007 frame.origin.x = i_xPos - frame.size.width - 3;
1008 [o_label setFrame:frame];
1010 frame = [o_textfield frame];
1011 frame.origin.x = i_xPos + 2;
1012 frame.size.width = superFrame.size.width - frame.origin.x - 1;
1013 [o_textfield setFrame:frame];
1018 [o_textfield release];
1022 - (char *)stringValue
1024 return [[VLCMain sharedInstance] delocalizeString:
1025 [o_textfield stringValue]];
1030 NSString *o_textfieldString;
1031 char *psz_value = config_GetPsz( VLCIntf, p_item->psz_name );
1033 o_textfieldString = [[VLCMain sharedInstance]
1034 localizedString: psz_value];
1036 o_textfieldString = [NSString stringWithString: @""];
1038 [super resetValues];
1042 @implementation StringListConfigControl
1043 - (id) initWithItem: (module_config_t *)_p_item
1044 withView: (NSView *)o_parent_view
1046 NSRect mainFrame = [o_parent_view frame];
1047 NSString *o_labelString, *o_textfieldTooltip;
1048 mainFrame.size.height = 22;
1049 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN + 1;
1050 mainFrame.origin.x = LEFTMARGIN;
1051 mainFrame.origin.y = 0;
1053 if( [super initWithFrame: mainFrame item: _p_item] != nil )
1056 i_view_type = CONFIG_ITEM_STRING_LIST;
1058 o_textfieldTooltip = [[VLCMain sharedInstance] wrapString:
1059 [[VLCMain sharedInstance]
1060 localizedString: (char *)p_item->psz_longtext ] toWidth: PREFS_WRAP];
1063 if( p_item->psz_text )
1064 o_labelString = [[VLCMain sharedInstance]
1065 localizedString: (char *)p_item->psz_text];
1067 o_labelString = [NSString stringWithString:@""];
1068 ADD_LABEL( o_label, mainFrame, 0, -3, o_labelString, o_textfieldTooltip )
1069 [o_label setAutoresizingMask:NSViewNotSizable ];
1070 [self addSubview: o_label];
1072 /* build the textfield */
1073 ADD_COMBO( o_combo, mainFrame, [o_label frame].size.width,
1074 -2, 0, o_textfieldTooltip )
1075 [o_combo setAutoresizingMask:NSViewWidthSizable ];
1076 for( i_index = 0; i_index < p_item->i_list; i_index++ )
1078 if( !p_item->value.psz && !p_item->ppsz_list[i_index] )
1079 [o_combo selectItemAtIndex: i_index];
1080 else if( p_item->value.psz && p_item->ppsz_list[i_index] &&
1081 !strcmp( p_item->value.psz, p_item->ppsz_list[i_index] ) )
1082 [o_combo selectItemAtIndex: i_index];
1084 [self addSubview: o_combo];
1089 - (void) alignWithXPosition:(int)i_xPos
1092 NSRect superFrame = [self frame];
1093 frame = [o_label frame];
1094 frame.origin.x = i_xPos - frame.size.width - 3;
1095 [o_label setFrame:frame];
1097 frame = [o_combo frame];
1098 frame.origin.x = i_xPos + 2;
1099 frame.size.width = superFrame.size.width - frame.origin.x + 2;
1100 [o_combo setFrame:frame];
1109 - (char *)stringValue
1111 if( [o_combo indexOfSelectedItem] >= 0 )
1112 return strdup( p_item->ppsz_list[[o_combo indexOfSelectedItem]] );
1114 return strdup( [[VLCMain sharedInstance]
1115 delocalizeString: [o_combo stringValue]] );
1121 [o_combo reloadData];
1122 char *psz_value = config_GetPsz( VLCIntf, p_item->psz_name );
1124 for( i_index = 0; i_index < p_item->i_list; i_index++ )
1126 if( !psz_value && !p_item->ppsz_list[i_index] )
1127 [o_combo selectItemAtIndex: i_index];
1128 else if( psz_value && p_item->ppsz_list[i_index] &&
1129 !strcmp( psz_value, p_item->ppsz_list[i_index] ) )
1130 [o_combo selectItemAtIndex: i_index];
1134 [super resetValues];
1138 @implementation StringListConfigControl (NSComboBoxDataSource)
1139 - (NSInteger)numberOfItemsInComboBox:(NSComboBox *)aComboBox
1141 return p_item->i_list;
1144 - (id)comboBox:(NSComboBox *)aComboBox objectValueForItemAtIndex:(NSInteger)i_index
1146 if( p_item->ppsz_list_text && p_item->ppsz_list_text[i_index] )
1148 return [[VLCMain sharedInstance]
1149 localizedString: (char *)p_item->ppsz_list_text[i_index]];
1150 } else return [[VLCMain sharedInstance]
1151 localizedString: (char *)p_item->ppsz_list[i_index]];
1155 @implementation FileConfigControl
1156 - (id) initWithItem: (module_config_t *)_p_item
1157 withView: (NSView *)o_parent_view
1159 NSRect mainFrame = [o_parent_view frame];
1160 NSString *o_labelString, *o_itemTooltip, *o_textfieldString;
1161 mainFrame.size.height = 46;
1162 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN;
1163 mainFrame.origin.x = LEFTMARGIN;
1164 mainFrame.origin.y = 0;
1166 if( [super initWithFrame: mainFrame item: _p_item] != nil )
1168 i_view_type = CONFIG_ITEM_FILE;
1170 o_itemTooltip = [[VLCMain sharedInstance]
1171 wrapString: [[VLCMain sharedInstance]
1172 localizedString: (char *)p_item->psz_longtext ] toWidth: PREFS_WRAP];
1174 /* is it a directory */
1175 b_directory = ( [self type] == CONFIG_ITEM_DIRECTORY ) ? YES : NO;
1178 if( p_item->psz_text )
1179 o_labelString = [[VLCMain sharedInstance]
1180 localizedString: (char *)p_item->psz_text];
1182 o_labelString = [NSString stringWithString:@""];
1183 ADD_LABEL( o_label, mainFrame, 0, 3, o_labelString, o_itemTooltip )
1184 [o_label setAutoresizingMask:NSViewNotSizable ];
1185 [self addSubview: o_label];
1187 /* build the button */
1188 ADD_RIGHT_BUTTON( o_button, mainFrame, 0, 0, o_itemTooltip,
1190 [o_button setAutoresizingMask:NSViewMinXMargin ];
1191 [self addSubview: o_button];
1193 /* build the textfield */
1194 if( p_item->value.psz )
1195 o_textfieldString = [NSString stringWithFormat: @"%s", (char *)p_item->value.psz];
1197 o_textfieldString = [NSString stringWithString: @""];
1198 ADD_TEXTFIELD( o_textfield, mainFrame, 12, 2, mainFrame.size.width -
1199 8 - [o_button frame].size.width,
1200 o_itemTooltip, o_textfieldString )
1201 [o_textfield setAutoresizingMask:NSViewWidthSizable ];
1202 [self addSubview: o_textfield];
1207 - (void) alignWithXPosition:(int)i_xPos
1214 [o_textfield release];
1219 - (IBAction)openFileDialog: (id)sender
1221 NSOpenPanel *o_open_panel = [NSOpenPanel openPanel];
1223 [o_open_panel setTitle: (b_directory)?
1224 _NS("Select a directory"):_NS("Select a file")];
1225 [o_open_panel setPrompt: _NS("Select")];
1226 [o_open_panel setAllowsMultipleSelection: NO];
1227 [o_open_panel setCanChooseFiles: !b_directory];
1228 [o_open_panel setCanChooseDirectories: b_directory];
1229 [o_open_panel beginSheetForDirectory:nil
1232 modalForWindow:[sender window]
1234 didEndSelector: @selector(pathChosenInPanel:
1240 - (void)pathChosenInPanel:(NSOpenPanel *)o_sheet
1241 withReturn:(int)i_return_code contextInfo:(void *)o_context_info
1243 if( i_return_code == NSOKButton )
1245 NSString *o_path = [[o_sheet filenames] objectAtIndex: 0];
1246 [o_textfield setStringValue: o_path];
1250 - (char *)stringValue
1252 if( [[o_textfield stringValue] length] != 0)
1253 return strdup( [[o_textfield stringValue] fileSystemRepresentation] );
1260 NSString *o_textfieldString;
1261 char *psz_value = config_GetPsz( VLCIntf, p_item->psz_name );
1263 o_textfieldString = [NSString stringWithFormat: @"%s", psz_value];
1265 o_textfieldString = [NSString stringWithString: @""];
1268 [super resetValues];
1272 @implementation ModuleConfigControl
1273 - (id) initWithItem: (module_config_t *)_p_item
1274 withView: (NSView *)o_parent_view
1276 NSRect mainFrame = [o_parent_view frame];
1277 NSString *o_labelString, *o_popupTooltip;
1278 mainFrame.size.height = 22;
1279 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN + 1;
1280 mainFrame.origin.x = LEFTMARGIN;
1281 mainFrame.origin.y = 0;
1283 if( [super initWithFrame: mainFrame item: _p_item] != nil )
1285 i_view_type = CONFIG_ITEM_MODULE;
1287 o_popupTooltip = [[VLCMain sharedInstance] wrapString:
1288 [[VLCMain sharedInstance]
1289 localizedString: (char *)p_item->psz_longtext ] toWidth: PREFS_WRAP];
1292 if( p_item->psz_text )
1293 o_labelString = [[VLCMain sharedInstance]
1294 localizedString: (char *)p_item->psz_text];
1296 o_labelString = [NSString stringWithString:@""];
1297 ADD_LABEL( o_label, mainFrame, 0, -1, o_labelString, o_popupTooltip )
1298 [o_label setAutoresizingMask:NSViewNotSizable ];
1299 [self addSubview: o_label];
1301 /* build the popup */
1302 ADD_POPUP( o_popup, mainFrame, [o_label frame].size.width,
1303 -2, 0, o_popupTooltip )
1304 [o_popup setAutoresizingMask:NSViewWidthSizable ];
1305 [o_popup addItemWithTitle: _NS("Default")];
1306 [[o_popup lastItem] setTag: -1];
1307 [o_popup selectItem: [o_popup lastItem]];
1310 [self addSubview: o_popup];
1315 - (void) alignWithXPosition:(int)i_xPos
1318 NSRect superFrame = [self frame];
1319 frame = [o_label frame];
1320 frame.origin.x = i_xPos - frame.size.width - 3;
1321 [o_label setFrame:frame];
1323 frame = [o_popup frame];
1324 frame.origin.x = i_xPos - 1;
1325 frame.size.width = superFrame.size.width - frame.origin.x + 2;
1326 [o_popup setFrame:frame];
1335 - (char *)stringValue
1337 NSString *newval = [o_popup titleOfSelectedItem];
1338 char *returnval = NULL;
1339 size_t i_module_index;
1340 module_t *p_parser, **p_list;
1342 p_list = module_list_get( NULL );
1343 for( i_module_index = 0; p_list[i_module_index]; i_module_index++ )
1345 p_parser = p_list[i_module_index];
1347 if( p_item->i_type == CONFIG_ITEM_MODULE )
1349 if( module_provides( p_parser, p_item->psz_type ) )
1351 NSString *o_description = [[VLCMain sharedInstance]
1352 localizedString: module_GetLongName( p_parser )];
1353 if( [newval isEqualToString: o_description] )
1355 returnval = strdup( module_get_object( p_parser ));
1364 if( module_is_main( p_parser) )
1366 unsigned int confsize, unused;
1367 module_config_get( p_parser, &confsize );
1368 for ( i = 0; i < confsize; i++ )
1370 module_config_t *p_config = module_config_get( p_parser, &unused ) + i;
1371 /* Hack: required subcategory is stored in i_min */
1372 if( p_config->i_type == CONFIG_SUBCATEGORY &&
1373 p_config->value.i == p_item->min.i )
1375 NSString *o_description = [[VLCMain sharedInstance]
1376 localizedString: module_GetLongName( p_parser )];
1377 if( [newval isEqualToString: o_description] )
1379 returnval = strdup(module_get_object( p_parser ));
1386 module_list_free( p_list );
1392 /* build a list of available modules */
1394 module_t *p_parser, **p_list;
1396 p_list = module_list_get( NULL );
1397 for( i_index = 0; p_list[i_index]; i_index++ )
1399 p_parser = p_list[i_index];
1401 if( p_item->i_type == CONFIG_ITEM_MODULE )
1403 if( module_provides( p_parser, p_item->psz_type ) )
1405 NSString *o_description = [[VLCMain sharedInstance]
1406 localizedString: module_GetLongName( p_parser )];
1407 [o_popup addItemWithTitle: o_description];
1408 char *psz_value = config_GetPsz( VLCIntf, p_item->psz_name );
1411 !strcmp( psz_value, module_get_object( p_parser ) ) )
1412 [o_popup selectItem:[o_popup lastItem]];
1421 if( module_is_main( p_parser ) )
1423 unsigned int confsize;
1424 unsigned int unused;
1425 module_config_t *p_configlist = module_config_get( p_parser, &confsize );
1426 for ( i = 0; i < confsize; i++ )
1428 module_config_t *p_config = &p_configlist[i];
1429 /* Hack: required subcategory is stored in i_min */
1430 if( p_config->i_type == CONFIG_SUBCATEGORY &&
1431 config_GetInt( VLCIntf, p_item->psz_name) == p_item->min.i )
1433 NSString *o_description = [[VLCMain sharedInstance]
1434 localizedString: module_GetLongName( p_parser )];
1435 [o_popup addItemWithTitle: o_description];
1436 char *psz_value = config_GetPsz( VLCIntf, p_item->psz_name );
1438 if( psz_value && !strcmp(psz_value,
1439 module_get_object( p_parser )) )
1440 [o_popup selectItem:[o_popup lastItem]];
1445 module_config_free( p_configlist );
1448 module_list_free( p_list );
1449 [super resetValues];
1453 @implementation IntegerConfigControl
1454 - (id) initWithItem: (module_config_t *)_p_item
1455 withView: (NSView *)o_parent_view
1457 NSRect mainFrame = [o_parent_view frame];
1458 NSString *o_labelString, *o_tooltip;
1459 mainFrame.size.height = 23;
1460 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN + 1;
1461 mainFrame.origin.x = LEFTMARGIN;
1462 mainFrame.origin.y = 0;
1464 if( [super initWithFrame: mainFrame item: _p_item] != nil )
1466 i_view_type = CONFIG_ITEM_INTEGER;
1468 o_tooltip = [[VLCMain sharedInstance] wrapString:
1469 [[VLCMain sharedInstance]
1470 localizedString: (char *)p_item->psz_longtext ] toWidth: PREFS_WRAP];
1473 if( p_item->psz_text )
1474 o_labelString = [[VLCMain sharedInstance]
1475 localizedString: (char *)p_item->psz_text];
1477 o_labelString = [NSString stringWithString:@""];
1478 ADD_LABEL( o_label, mainFrame, 0, -3, o_labelString, o_tooltip )
1479 [o_label setAutoresizingMask:NSViewNotSizable ];
1480 [self addSubview: o_label];
1482 /* build the stepper */
1483 ADD_STEPPER( o_stepper, mainFrame, mainFrame.size.width - 19,
1484 0, o_tooltip, -100000, 100000)
1485 [o_stepper setIntValue: p_item->value.i];
1486 [o_stepper setAutoresizingMask:NSViewMaxXMargin ];
1487 [self addSubview: o_stepper];
1489 ADD_TEXTFIELD( o_textfield, mainFrame, mainFrame.size.width - 19 - 52,
1490 1, 49, o_tooltip, @"" )
1491 [o_textfield setIntValue: p_item->value.i];
1492 [o_textfield setDelegate: self];
1493 [[NSNotificationCenter defaultCenter] addObserver: self
1494 selector: @selector(textfieldChanged:)
1495 name: NSControlTextDidChangeNotification
1496 object: o_textfield];
1497 [o_textfield setAutoresizingMask:NSViewMaxXMargin ];
1498 [self addSubview: o_textfield];
1503 - (void) alignWithXPosition:(int)i_xPos
1506 frame = [o_label frame];
1507 frame.origin.x = i_xPos - frame.size.width - 3;
1508 [o_label setFrame:frame];
1510 frame = [o_textfield frame];
1511 frame.origin.x = i_xPos + 2;
1512 [o_textfield setFrame:frame];
1514 frame = [o_stepper frame];
1515 frame.origin.x = i_xPos + [o_textfield frame].size.width + 5;
1516 [o_stepper setFrame:frame];
1521 [o_stepper release];
1522 [o_textfield release];
1526 - (IBAction)stepperChanged:(id)sender
1528 [o_textfield setIntValue: [o_stepper intValue]];
1531 - (void)textfieldChanged:(NSNotification *)o_notification
1533 [o_stepper setIntValue: [o_textfield intValue]];
1538 return [o_textfield intValue];
1543 [o_textfield setIntValue: config_GetInt(VLCIntf, p_item->psz_name)];
1544 [super resetValues];
1549 @implementation IntegerListConfigControl
1551 - (id) initWithItem: (module_config_t *)_p_item
1552 withView: (NSView *)o_parent_view
1554 NSRect mainFrame = [o_parent_view frame];
1555 NSString *o_labelString, *o_textfieldTooltip;
1556 mainFrame.size.height = 22;
1557 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN + 1;
1558 mainFrame.origin.x = LEFTMARGIN;
1559 mainFrame.origin.y = 0;
1561 if( [super initWithFrame: mainFrame item: _p_item] != nil )
1564 i_view_type = CONFIG_ITEM_STRING_LIST;
1566 o_textfieldTooltip = [[VLCMain sharedInstance] wrapString:
1567 [[VLCMain sharedInstance]
1568 localizedString: (char *)p_item->psz_longtext ] toWidth: PREFS_WRAP];
1571 if( p_item->psz_text )
1572 o_labelString = [[VLCMain sharedInstance]
1573 localizedString: (char *)p_item->psz_text];
1575 o_labelString = [NSString stringWithString:@""];
1576 ADD_LABEL( o_label, mainFrame, 0, -3, o_labelString, o_textfieldTooltip )
1577 [o_label setAutoresizingMask:NSViewNotSizable ];
1578 [self addSubview: o_label];
1580 /* build the textfield */
1581 ADD_COMBO( o_combo, mainFrame, [o_label frame].size.width,
1582 -2, 0, o_textfieldTooltip )
1583 [o_combo setAutoresizingMask:NSViewWidthSizable ];
1584 for( i_index = 0; i_index < p_item->i_list; i_index++ )
1586 if( p_item->value.i == p_item->pi_list[i_index] )
1588 [o_combo selectItemAtIndex: i_index];
1591 [self addSubview: o_combo];
1596 - (void) alignWithXPosition:(int)i_xPos
1599 NSRect superFrame = [self frame];
1600 frame = [o_label frame];
1601 frame.origin.x = i_xPos - frame.size.width - 3;
1602 [o_label setFrame:frame];
1604 frame = [o_combo frame];
1605 frame.origin.x = i_xPos + 2;
1606 frame.size.width = superFrame.size.width - frame.origin.x + 2;
1607 [o_combo setFrame:frame];
1618 if( [o_combo indexOfSelectedItem] >= 0 )
1619 return p_item->pi_list[[o_combo indexOfSelectedItem]];
1621 return [o_combo intValue];
1627 [o_combo reloadData];
1628 for( i_index = 0; i_index < p_item->i_list; i_index++ )
1630 if( config_GetInt( VLCIntf, p_item->psz_name) == p_item->pi_list[i_index] )
1632 [o_combo selectItemAtIndex: i_index];
1639 @implementation IntegerListConfigControl (NSComboBoxDataSource)
1640 - (NSInteger)numberOfItemsInComboBox:(NSComboBox *)aComboBox
1642 return p_item->i_list;
1645 - (id)comboBox:(NSComboBox *)aComboBox objectValueForItemAtIndex:(NSInteger)i_index
1647 if( p_item->ppsz_list_text && p_item->ppsz_list_text[i_index] )
1648 return [[VLCMain sharedInstance]
1649 localizedString: (char *)p_item->ppsz_list_text[i_index]];
1651 return [NSString stringWithFormat: @"%i", p_item->pi_list[i_index]];
1655 @implementation RangedIntegerConfigControl
1656 - (id) initWithItem: (module_config_t *)_p_item
1657 withView: (NSView *)o_parent_view
1659 NSRect mainFrame = [o_parent_view frame];
1660 NSString *o_labelString, *o_tooltip;
1661 mainFrame.size.height = 50;
1662 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN;
1663 mainFrame.origin.x = LEFTMARGIN;
1664 mainFrame.origin.y = 0;
1666 if( [super initWithFrame: mainFrame item: _p_item] != nil )
1668 i_view_type = CONFIG_ITEM_RANGED_INTEGER;
1670 o_tooltip = [[VLCMain sharedInstance] wrapString:
1671 [[VLCMain sharedInstance]
1672 localizedString: (char *)p_item->psz_longtext ] toWidth: PREFS_WRAP];
1675 if( p_item->psz_text )
1676 o_labelString = [[VLCMain sharedInstance]
1677 localizedString: (char *)p_item->psz_text];
1679 o_labelString = [NSString stringWithString:@""];
1680 ADD_LABEL( o_label, mainFrame, 0, -3, o_labelString, o_tooltip )
1681 [o_label setAutoresizingMask:NSViewNotSizable ];
1682 [self addSubview: o_label];
1684 /* build the textfield */
1685 ADD_TEXTFIELD( o_textfield, mainFrame, [o_label frame].size.width + 2,
1686 28, 49, o_tooltip, @"" )
1687 [o_textfield setIntValue: p_item->value.i];
1688 [o_textfield setAutoresizingMask:NSViewMaxXMargin ];
1689 [o_textfield setDelegate: self];
1690 [[NSNotificationCenter defaultCenter] addObserver: self
1691 selector: @selector(textfieldChanged:)
1692 name: NSControlTextDidChangeNotification
1693 object: o_textfield];
1694 [self addSubview: o_textfield];
1696 /* build the mintextfield */
1697 ADD_LABEL( o_textfield_min, mainFrame, 12, -30, @"-8888", @"" )
1698 [o_textfield_min setIntValue: p_item->min.i];
1699 [o_textfield_min setAutoresizingMask:NSViewMaxXMargin ];
1700 [o_textfield_min setAlignment:NSRightTextAlignment];
1701 [self addSubview: o_textfield_min];
1703 /* build the maxtextfield */
1704 ADD_LABEL( o_textfield_max, mainFrame,
1705 mainFrame.size.width - 31, -30, @"8888", @"" )
1706 [o_textfield_max setIntValue: p_item->max.i];
1707 [o_textfield_max setAutoresizingMask:NSViewMinXMargin ];
1708 [self addSubview: o_textfield_max];
1710 /* build the slider */
1711 ADD_SLIDER( o_slider, mainFrame, [o_textfield_min frame].origin.x +
1712 [o_textfield_min frame].size.width + 6, -1, mainFrame.size.width -
1713 [o_textfield_max frame].size.width -
1714 [o_textfield_max frame].size.width - 14 -
1715 [o_textfield_min frame].origin.x, o_tooltip,
1716 p_item->min.i, p_item->max.i )
1717 [o_slider setIntValue: p_item->value.i];
1718 [o_slider setAutoresizingMask:NSViewWidthSizable ];
1719 [o_slider setTarget: self];
1720 [o_slider setAction: @selector(sliderChanged:)];
1721 [o_slider sendActionOn:NSLeftMouseUpMask | NSLeftMouseDownMask |
1722 NSLeftMouseDraggedMask];
1723 [self addSubview: o_slider];
1729 - (void) alignWithXPosition:(int)i_xPos
1732 frame = [o_label frame];
1733 frame.origin.x = i_xPos - frame.size.width - 3;
1734 [o_label setFrame:frame];
1736 frame = [o_textfield frame];
1737 frame.origin.x = i_xPos + 2;
1738 [o_textfield setFrame:frame];
1743 [o_textfield release];
1744 [o_textfield_min release];
1745 [o_textfield_max release];
1750 - (IBAction)sliderChanged:(id)sender
1752 [o_textfield setIntValue: [o_slider intValue]];
1755 - (void)textfieldChanged:(NSNotification *)o_notification
1757 [o_slider setIntValue: [o_textfield intValue]];
1762 return [o_slider intValue];
1767 int value = config_GetInt( VLCIntf, p_item->psz_name );
1768 [o_textfield setIntValue:value];
1769 [o_slider setIntValue:value];
1770 [super resetValues];
1774 @implementation FloatConfigControl
1775 - (id) initWithItem: (module_config_t *)_p_item
1776 withView: (NSView *)o_parent_view
1778 NSRect mainFrame = [o_parent_view frame];
1779 NSString *o_labelString, *o_tooltip;
1780 mainFrame.size.height = 23;
1781 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN + 1;
1782 mainFrame.origin.x = LEFTMARGIN;
1783 mainFrame.origin.y = 0;
1785 if( [super initWithFrame: mainFrame item: _p_item] != nil )
1787 i_view_type = CONFIG_ITEM_INTEGER;
1789 o_tooltip = [[VLCMain sharedInstance] wrapString:
1790 [[VLCMain sharedInstance]
1791 localizedString: (char *)p_item->psz_longtext ] toWidth: PREFS_WRAP];
1794 if( p_item->psz_text )
1795 o_labelString = [[VLCMain sharedInstance]
1796 localizedString: (char *)p_item->psz_text];
1798 o_labelString = [NSString stringWithString:@""];
1799 ADD_LABEL( o_label, mainFrame, 0, -2, o_labelString, o_tooltip )
1800 [o_label setAutoresizingMask:NSViewNotSizable ];
1801 [self addSubview: o_label];
1803 /* build the stepper */
1804 ADD_STEPPER( o_stepper, mainFrame, mainFrame.size.width - 19,
1805 0, o_tooltip, -100000, 100000)
1806 [o_stepper setFloatValue: p_item->value.f];
1807 [o_stepper setAutoresizingMask:NSViewMaxXMargin ];
1808 [self addSubview: o_stepper];
1810 /* build the textfield */
1811 ADD_TEXTFIELD( o_textfield, mainFrame, mainFrame.size.width - 19 - 52,
1812 1, 49, o_tooltip, @"" )
1813 [o_textfield setFloatValue: p_item->value.f];
1814 [o_textfield setDelegate: self];
1815 [[NSNotificationCenter defaultCenter] addObserver: self
1816 selector: @selector(textfieldChanged:)
1817 name: NSControlTextDidChangeNotification
1818 object: o_textfield];
1819 [o_textfield setAutoresizingMask:NSViewMaxXMargin ];
1820 [self addSubview: o_textfield];
1825 - (void) alignWithXPosition:(int)i_xPos
1828 frame = [o_label frame];
1829 frame.origin.x = i_xPos - frame.size.width - 3;
1830 [o_label setFrame:frame];
1832 frame = [o_textfield frame];
1833 frame.origin.x = i_xPos + 2;
1834 [o_textfield setFrame:frame];
1836 frame = [o_stepper frame];
1837 frame.origin.x = i_xPos + [o_textfield frame].size.width + 5;
1838 [o_stepper setFrame:frame];
1843 [o_stepper release];
1844 [o_textfield release];
1848 - (IBAction)stepperChanged:(id)sender
1850 [o_textfield setFloatValue: [o_stepper floatValue]];
1853 - (void)textfieldChanged:(NSNotification *)o_notification
1855 [o_stepper setFloatValue: [o_textfield floatValue]];
1860 return [o_stepper floatValue];
1865 [o_textfield setFloatValue: config_GetFloat( VLCIntf, p_item->psz_name)];
1866 [super resetValues];
1870 @implementation RangedFloatConfigControl
1871 - (id) initWithItem: (module_config_t *)_p_item
1872 withView: (NSView *)o_parent_view
1874 NSRect mainFrame = [o_parent_view frame];
1875 NSString *o_labelString, *o_tooltip;
1876 mainFrame.size.height = 50;
1877 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN;
1878 mainFrame.origin.x = LEFTMARGIN;
1879 mainFrame.origin.y = 0;
1881 if( [super initWithFrame: mainFrame item: _p_item] != nil )
1883 i_view_type = CONFIG_ITEM_RANGED_INTEGER;
1885 o_tooltip = [[VLCMain sharedInstance] wrapString:
1886 [[VLCMain sharedInstance]
1887 localizedString: (char *)p_item->psz_longtext ] toWidth: PREFS_WRAP];
1890 if( p_item->psz_text )
1891 o_labelString = [[VLCMain sharedInstance]
1892 localizedString: (char *)p_item->psz_text];
1894 o_labelString = [NSString stringWithString:@""];
1895 ADD_LABEL( o_label, mainFrame, 0, -3, o_labelString, o_tooltip )
1896 [o_label setAutoresizingMask:NSViewNotSizable ];
1897 [self addSubview: o_label];
1899 /* build the textfield */
1900 ADD_TEXTFIELD( o_textfield, mainFrame, [o_label frame].size.width + 2,
1901 28, 49, o_tooltip, @"" )
1902 [o_textfield setFloatValue: p_item->value.f];
1903 [o_textfield setAutoresizingMask:NSViewMaxXMargin ];
1904 [o_textfield setDelegate: self];
1905 [[NSNotificationCenter defaultCenter] addObserver: self
1906 selector: @selector(textfieldChanged:)
1907 name: NSControlTextDidChangeNotification
1908 object: o_textfield];
1909 [self addSubview: o_textfield];
1911 /* build the mintextfield */
1912 ADD_LABEL( o_textfield_min, mainFrame, 12, -30, @"-8888", @"" )
1913 [o_textfield_min setFloatValue: p_item->min.f];
1914 [o_textfield_min setAutoresizingMask:NSViewMaxXMargin ];
1915 [o_textfield_min setAlignment:NSRightTextAlignment];
1916 [self addSubview: o_textfield_min];
1918 /* build the maxtextfield */
1919 ADD_LABEL( o_textfield_max, mainFrame, mainFrame.size.width - 31,
1921 [o_textfield_max setFloatValue: p_item->max.f];
1922 [o_textfield_max setAutoresizingMask:NSViewMinXMargin ];
1923 [self addSubview: o_textfield_max];
1925 /* build the slider */
1926 ADD_SLIDER( o_slider, mainFrame, [o_textfield_min frame].origin.x +
1927 [o_textfield_min frame].size.width + 6, -1, mainFrame.size.width -
1928 [o_textfield_max frame].size.width -
1929 [o_textfield_max frame].size.width - 14 -
1930 [o_textfield_min frame].origin.x, o_tooltip, p_item->min.f,
1932 [o_slider setFloatValue: p_item->value.f];
1933 [o_slider setAutoresizingMask:NSViewWidthSizable ];
1934 [o_slider setTarget: self];
1935 [o_slider setAction: @selector(sliderChanged:)];
1936 [o_slider sendActionOn:NSLeftMouseUpMask | NSLeftMouseDownMask |
1937 NSLeftMouseDraggedMask];
1938 [self addSubview: o_slider];
1944 - (void) alignWithXPosition:(int)i_xPos
1947 frame = [o_label frame];
1948 frame.origin.x = i_xPos - frame.size.width - 3;
1949 [o_label setFrame:frame];
1951 frame = [o_textfield frame];
1952 frame.origin.x = i_xPos + 2;
1953 [o_textfield setFrame:frame];
1958 [o_textfield release];
1959 [o_textfield_min release];
1960 [o_textfield_max release];
1965 - (IBAction)sliderChanged:(id)sender
1967 [o_textfield setFloatValue: [o_slider floatValue]];
1970 - (void)textfieldChanged:(NSNotification *)o_notification
1972 [o_slider setFloatValue: [o_textfield floatValue]];
1977 return [o_slider floatValue];
1982 [o_textfield setFloatValue: config_GetFloat(VLCIntf, p_item->psz_name)];
1983 [o_slider setFloatValue: config_GetFloat(VLCIntf, p_item->psz_name)];
1984 [super resetValues];
1988 @implementation BoolConfigControl
1990 - (id) initWithItem: (module_config_t *)_p_item
1991 withView: (NSView *)o_parent_view
1993 NSRect mainFrame = [o_parent_view frame];
1994 NSString *o_labelString, *o_tooltip;
1995 mainFrame.size.height = 17;
1996 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN;
1997 mainFrame.origin.x = LEFTMARGIN;
1998 mainFrame.origin.y = 0;
2000 if( [super initWithFrame: mainFrame item: _p_item] != nil )
2002 i_view_type = CONFIG_ITEM_BOOL;
2004 /* add the checkbox */
2005 o_tooltip = [[VLCMain sharedInstance]
2006 wrapString: [[VLCMain sharedInstance]
2007 localizedString: (char *)p_item->psz_longtext ] toWidth: PREFS_WRAP];
2008 ADD_CHECKBOX( o_checkbox, mainFrame, 0,
2009 0, @"", o_tooltip, p_item->value.i, NSImageLeft)
2010 [o_checkbox setAutoresizingMask:NSViewNotSizable ];
2011 [self addSubview: o_checkbox];
2013 if( p_item->psz_text )
2014 o_labelString = [[VLCMain sharedInstance]
2015 localizedString: (char *)p_item->psz_text];
2017 o_labelString = [NSString stringWithString:@""];
2018 ADD_LABEL( o_label, mainFrame, [o_checkbox frame].size.width, 0, o_labelString, o_tooltip )
2019 [o_label setAutoresizingMask:NSViewNotSizable ];
2020 [self addSubview: o_label];
2027 [o_checkbox release];
2033 return [o_checkbox intValue];
2038 [o_checkbox setState: config_GetInt( VLCIntf, p_item->psz_name)];
2039 [super resetValues];
2043 @implementation KeyConfigControl
2044 - (id) initWithItem: (module_config_t *)_p_item
2045 withView: (NSView *)o_parent_view
2047 NSRect mainFrame = [o_parent_view frame];
2048 NSString *o_labelString, *o_tooltip;
2049 mainFrame.size.height = 22;
2050 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN + 1;
2051 mainFrame.origin.x = LEFTMARGIN;
2052 mainFrame.origin.y = 0;
2054 if( [super initWithFrame: mainFrame item: _p_item] != nil )
2056 i_view_type = CONFIG_ITEM_KEY_AFTER_10_3;
2058 o_tooltip = [[VLCMain sharedInstance] wrapString:
2059 [[VLCMain sharedInstance]
2060 localizedString: (char *)p_item->psz_longtext ] toWidth: PREFS_WRAP];
2063 if( p_item->psz_text )
2064 o_labelString = [[VLCMain sharedInstance]
2065 localizedString: (char *)p_item->psz_text];
2067 o_labelString = [NSString stringWithString:@""];
2068 ADD_LABEL( o_label, mainFrame, 0, -1, o_labelString, o_tooltip )
2069 [o_label setAutoresizingMask:NSViewNotSizable ];
2070 [self addSubview: o_label];
2072 /* build the popup */
2073 ADD_POPUP( o_popup, mainFrame, [o_label frame].origin.x +
2074 [o_label frame].size.width + 3,
2076 [o_popup setAutoresizingMask:NSViewWidthSizable ];
2078 if( o_keys_menu == nil )
2081 o_keys_menu = [[NSMenu alloc] initWithTitle: @"Keys Menu"];
2082 #warning This does not work anymore. FIXME.
2084 for ( i = 0; i < sizeof(vlc_keys) / sizeof(key_descriptor_t); i++)
2085 if( vlc_keys[i].psz_key_string )
2086 POPULATE_A_KEY( o_keys_menu,
2087 [NSString stringWithUTF8String:vlc_keys[i].psz_key_string]
2088 , vlc_keys[i].i_key_code)
2091 [o_popup setMenu:[o_keys_menu copyWithZone:nil]];
2092 [o_popup selectItem:[[o_popup menu] itemWithTag:p_item->value.i]];
2093 [self addSubview: o_popup];
2099 - (void) alignWithXPosition:(int)i_xPos
2102 NSRect superFrame = [self frame];
2103 frame = [o_label frame];
2104 frame.origin.x = i_xPos - frame.size.width - 3;
2105 [o_label setFrame:frame];
2107 frame = [o_popup frame];
2108 frame.origin.x = i_xPos - 1;
2109 frame.size.width = superFrame.size.width - frame.origin.x + 2;
2110 [o_popup setFrame:frame];
2121 return [o_popup selectedTag];
2126 [o_popup selectItem:[[o_popup menu] itemWithTag:config_GetInt( VLCIntf, p_item->psz_name )]];
2127 [super resetValues];
2131 @implementation ModuleListConfigControl
2132 - (id) initWithItem: (module_config_t *)_p_item
2133 withView: (NSView *)o_parent_view
2135 if( _p_item->i_type == CONFIG_ITEM_MODULE_LIST )
2139 //Fill our array to know how may items we have...
2140 module_t *p_parser, **p_list;
2141 size_t i_module_index;
2142 NSRect mainFrame = [o_parent_view frame];
2143 NSString *o_labelString, *o_textfieldString, *o_tooltip;
2145 o_modulearray = [[NSMutableArray alloc] initWithCapacity:10];
2146 /* build a list of available modules */
2147 p_list = module_list_get( NULL );
2148 for( i_module_index = 0; p_list[i_module_index]; i_module_index++ )
2151 p_parser = p_list[i_module_index];
2153 if( module_is_main( p_parser ) )
2156 unsigned int confsize;
2157 module_config_t *p_configlist = module_config_get( p_parser, &confsize );
2159 for ( i = 0; i < confsize; i++ )
2161 unsigned int unused;
2162 module_config_t *p_config = &p_configlist[i];
2163 NSString *o_modulelongname, *o_modulename;
2164 NSNumber *o_moduleenabled = nil;
2166 /* Hack: required subcategory is stored in i_min */
2167 if( p_config->i_type == CONFIG_SUBCATEGORY &&
2168 p_config->value.i == _p_item->min.i )
2170 o_modulelongname = [NSString stringWithUTF8String:
2171 module_GetLongName( p_parser )];
2172 o_modulename = [NSString stringWithUTF8String:
2173 module_get_object( p_parser )];
2175 if( _p_item->value.psz &&
2176 strstr( _p_item->value.psz, module_get_object( p_parser ) ) )
2177 o_moduleenabled = [NSNumber numberWithBool:YES];
2179 o_moduleenabled = [NSNumber numberWithBool:NO];
2181 [o_modulearray addObject:[NSMutableArray
2182 arrayWithObjects: o_modulename, o_modulelongname,
2183 o_moduleenabled, nil]];
2186 module_config_free( p_configlist );
2188 module_list_free( p_list );
2190 mainFrame.size.height = 30 + 18 * [o_modulearray count];
2191 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN;
2192 mainFrame.origin.x = LEFTMARGIN;
2193 mainFrame.origin.y = 0;
2194 if( [super initWithFrame: mainFrame item: _p_item] != nil )
2196 i_view_type = CONFIG_ITEM_MODULE_LIST;
2198 o_tooltip = [[VLCMain sharedInstance] wrapString:
2199 [[VLCMain sharedInstance]
2200 localizedString: (char *)p_item->psz_longtext ] toWidth: PREFS_WRAP];
2203 if( p_item->psz_text )
2204 o_labelString = [[VLCMain sharedInstance]
2205 localizedString: (char *)p_item->psz_text];
2207 o_labelString = [NSString stringWithString:@""];
2208 ADD_LABEL( o_label, mainFrame, 0, -3, o_labelString, o_tooltip )
2209 [o_label setAutoresizingMask:NSViewNotSizable ];
2210 [self addSubview: o_label];
2212 /* build the textfield */
2213 if( p_item->value.psz )
2214 o_textfieldString = [[VLCMain sharedInstance]
2215 localizedString: (char *)p_item->value.psz];
2217 o_textfieldString = [NSString stringWithString: @""];
2218 ADD_TEXTFIELD( o_textfield, mainFrame, [o_label frame].size.width + 2,
2219 mainFrame.size.height - 22, mainFrame.size.width -
2220 [o_label frame].size.width - 2, o_tooltip, o_textfieldString )
2221 [o_textfield setAutoresizingMask:NSViewWidthSizable ];
2222 [self addSubview: o_textfield];
2226 NSRect s_rc = mainFrame;
2227 s_rc.size.height = mainFrame.size.height - 30;
2228 s_rc.size.width = mainFrame.size.width - 12;
2231 o_scrollview = [[[NSScrollView alloc] initWithFrame: s_rc] retain];
2232 [o_scrollview setDrawsBackground: NO];
2233 [o_scrollview setBorderType: NSBezelBorder];
2234 [o_scrollview setAutohidesScrollers:YES];
2236 NSTableView *o_tableview;
2237 o_tableview = [[NSTableView alloc] initWithFrame : s_rc];
2238 [o_tableview setUsesAlternatingRowBackgroundColors:YES];
2239 [o_tableview setHeaderView:nil];
2240 /* TODO: find a good way to fix the row height and text size*/
2241 /* FIXME: support for multiple selection... */
2242 // [o_tableview setAllowsMultipleSelection:YES];
2244 NSCell *o_headerCell = [[NSCell alloc] initTextCell:@"Enabled"];
2245 NSCell *o_dataCell = [[NSButtonCell alloc] init];
2246 [(NSButtonCell*)o_dataCell setButtonType:NSSwitchButton];
2247 [o_dataCell setTitle:@""];
2248 [o_dataCell setFont:[NSFont systemFontOfSize:0]];
2249 NSTableColumn *o_tableColumn = [[NSTableColumn alloc]
2250 initWithIdentifier:@"Enabled"];
2251 [o_tableColumn setHeaderCell: o_headerCell];
2252 [o_tableColumn setDataCell: o_dataCell];
2253 [o_tableColumn setWidth:17];
2254 [o_tableview addTableColumn: o_tableColumn];
2256 o_headerCell = [[NSCell alloc] initTextCell:@"Module Name"];
2257 o_dataCell = [[NSTextFieldCell alloc] init];
2258 [o_dataCell setFont:[NSFont systemFontOfSize:12]];
2259 o_tableColumn = [[NSTableColumn alloc]
2260 initWithIdentifier:@"Module"];
2261 [o_tableColumn setHeaderCell: o_headerCell];
2262 [o_tableColumn setDataCell: o_dataCell];
2263 [o_tableColumn setWidth:388 - 17];
2264 [o_tableview addTableColumn: o_tableColumn];
2265 [o_tableview registerForDraggedTypes:[NSArray arrayWithObjects:
2266 @"VLC media player module", nil]];
2268 [o_tableview setDataSource:self];
2269 [o_tableview setTarget: self];
2270 [o_tableview setAction: @selector(tableChanged:)];
2271 [o_tableview sendActionOn:NSLeftMouseUpMask | NSLeftMouseDownMask |
2272 NSLeftMouseDraggedMask];
2273 [o_scrollview setDocumentView: o_tableview];
2275 [o_scrollview setAutoresizingMask:NSViewWidthSizable ];
2276 [self addSubview: o_scrollview];
2283 - (void) alignWithXPosition:(int)i_xPos
2288 - (IBAction)tableChanged:(id)sender
2290 NSString *o_newstring = @"";
2292 for( i = 0 ; i < [o_modulearray count] ; i++ )
2293 if( [[[o_modulearray objectAtIndex:i] objectAtIndex:2]
2296 o_newstring = [o_newstring stringByAppendingString:
2297 [[o_modulearray objectAtIndex:i] objectAtIndex:0]];
2298 o_newstring = [o_newstring stringByAppendingString:@":"];
2301 [o_textfield setStringValue: [o_newstring
2302 substringToIndex: ([o_newstring length])?[o_newstring length] - 1:0]];
2307 [o_scrollview release];
2312 - (char *)stringValue
2314 return strdup( [[o_textfield stringValue] UTF8String] );
2319 #warning Reset prefs of the module selector is broken atm.
2320 NSLog( @"don't forget about modulelistconfig" );
2321 [super resetValues];
2326 @implementation ModuleListConfigControl (NSTableDataSource)
2328 - (BOOL)tableView:(NSTableView*)table writeRows:(NSArray*)rows
2329 toPasteboard:(NSPasteboard*)pb
2331 // We only want to allow dragging of selected rows.
2332 NSEnumerator *iter = [rows objectEnumerator];
2334 while ((row = [iter nextObject]) != nil)
2336 if (![table isRowSelected:[row intValue]])
2340 [pb declareTypes:[NSArray
2341 arrayWithObject:@"VLC media player module"] owner:nil];
2342 [pb setPropertyList:rows forType:@"VLC media player module"];
2346 - (NSDragOperation)tableView:(NSTableView*)table
2347 validateDrop:(id <NSDraggingInfo>)info proposedRow:(NSInteger)row
2348 proposedDropOperation:(NSTableViewDropOperation)op
2350 // Make drops at the end of the table go to the end.
2353 row = [table numberOfRows];
2354 op = NSTableViewDropAbove;
2355 [table setDropRow:row dropOperation:op];
2358 // We don't ever want to drop onto a row, only between rows.
2359 if (op == NSTableViewDropOn)
2360 [table setDropRow:(row+1) dropOperation:NSTableViewDropAbove];
2361 return NSTableViewDropAbove;
2364 - (BOOL)tableView:(NSTableView*)table acceptDrop:(id <NSDraggingInfo>)info
2365 row:(NSInteger)dropRow dropOperation:(NSTableViewDropOperation)op;
2367 NSPasteboard *pb = [info draggingPasteboard];
2368 NSDragOperation srcMask = [info draggingSourceOperationMask];
2375 // Intra-table drag - data is the array of rows.
2376 if (!accepted && (array =
2377 [pb propertyListForType:@"VLC media player module"]) != NULL)
2379 NSEnumerator *iter = nil;
2381 BOOL isCopy = (srcMask & NSDragOperationMove) ? NO:YES;
2383 iter = [array objectEnumerator];
2384 while ((val = [iter nextObject]) != NULL)
2386 NSArray *o_tmp = [[o_modulearray objectAtIndex:
2387 [val intValue]] mutableCopyWithZone:nil];
2388 [o_modulearray removeObject:o_tmp];
2389 [o_modulearray insertObject:o_tmp
2390 atIndex:(dropRow>[val intValue]) ? dropRow - 1 : dropRow];
2394 // Select the newly-dragged items.
2395 iter = [array objectEnumerator];
2397 [table deselectAll:self];
2399 [self tableChanged:self];
2400 [table setNeedsDisplay:YES];
2401 // Indicate that we finished the drag.
2405 [table setNeedsDisplay:YES];
2409 // An exception occurred. Uh-oh. Update the track table so that
2410 // it stays consistent, and re-raise the exception.
2412 [localException raise];
2413 [table setNeedsDisplay:YES];
2419 - (NSInteger)numberOfRowsInTableView:(NSTableView *)aTableView
2421 return [o_modulearray count];
2424 - (id)tableView:(NSTableView *)aTableView
2425 objectValueForTableColumn:(NSTableColumn *)aTableColumn row:(NSInteger)rowIndex
2427 if( [[aTableColumn identifier] isEqualToString: @"Enabled"] )
2428 return [[o_modulearray objectAtIndex:rowIndex] objectAtIndex:2];
2429 if( [[aTableColumn identifier] isEqualToString: @"Module"] )
2430 return [[o_modulearray objectAtIndex:rowIndex] objectAtIndex:1];
2435 - (void)tableView:(NSTableView *)aTableView setObjectValue:(id)anObject
2436 forTableColumn:(NSTableColumn *)aTableColumn row:(NSInteger)rowIndex
2438 [[o_modulearray objectAtIndex:rowIndex] replaceObjectAtIndex:2
2439 withObject: anObject];