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++ )
1077 if( p_item->value.psz &&
1078 !strcmp( p_item->value.psz, p_item->ppsz_list[i_index] ) )
1079 [o_combo selectItemAtIndex: i_index];
1080 [self addSubview: o_combo];
1085 - (void) alignWithXPosition:(int)i_xPos
1088 NSRect superFrame = [self frame];
1089 frame = [o_label frame];
1090 frame.origin.x = i_xPos - frame.size.width - 3;
1091 [o_label setFrame:frame];
1093 frame = [o_combo frame];
1094 frame.origin.x = i_xPos + 2;
1095 frame.size.width = superFrame.size.width - frame.origin.x + 2;
1096 [o_combo setFrame:frame];
1105 - (char *)stringValue
1107 if( [o_combo indexOfSelectedItem] >= 0 )
1108 return strdup( p_item->ppsz_list[[o_combo indexOfSelectedItem]] );
1110 return strdup( [[VLCMain sharedInstance]
1111 delocalizeString: [o_combo stringValue]] );
1117 [o_combo reloadData];
1118 char *psz_value = config_GetPsz( VLCIntf, p_item->psz_name );
1120 for( i_index = 0; i_index < p_item->i_list; i_index++ )
1122 !strcmp( psz_value, p_item->ppsz_list[i_index] ) )
1123 [o_combo selectItemAtIndex: i_index];
1126 [super resetValues];
1130 @implementation StringListConfigControl (NSComboBoxDataSource)
1131 - (NSInteger)numberOfItemsInComboBox:(NSComboBox *)aComboBox
1133 return p_item->i_list;
1136 - (id)comboBox:(NSComboBox *)aComboBox objectValueForItemAtIndex:(NSInteger)i_index
1138 if( p_item->ppsz_list_text && p_item->ppsz_list_text[i_index] )
1140 return [[VLCMain sharedInstance]
1141 localizedString: (char *)p_item->ppsz_list_text[i_index]];
1142 } else return [[VLCMain sharedInstance]
1143 localizedString: (char *)p_item->ppsz_list[i_index]];
1147 @implementation FileConfigControl
1148 - (id) initWithItem: (module_config_t *)_p_item
1149 withView: (NSView *)o_parent_view
1151 NSRect mainFrame = [o_parent_view frame];
1152 NSString *o_labelString, *o_itemTooltip, *o_textfieldString;
1153 mainFrame.size.height = 46;
1154 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN;
1155 mainFrame.origin.x = LEFTMARGIN;
1156 mainFrame.origin.y = 0;
1158 if( [super initWithFrame: mainFrame item: _p_item] != nil )
1160 i_view_type = CONFIG_ITEM_FILE;
1162 o_itemTooltip = [[VLCMain sharedInstance]
1163 wrapString: [[VLCMain sharedInstance]
1164 localizedString: (char *)p_item->psz_longtext ] toWidth: PREFS_WRAP];
1166 /* is it a directory */
1167 b_directory = ( [self type] == CONFIG_ITEM_DIRECTORY ) ? YES : NO;
1170 if( p_item->psz_text )
1171 o_labelString = [[VLCMain sharedInstance]
1172 localizedString: (char *)p_item->psz_text];
1174 o_labelString = [NSString stringWithString:@""];
1175 ADD_LABEL( o_label, mainFrame, 0, 3, o_labelString, o_itemTooltip )
1176 [o_label setAutoresizingMask:NSViewNotSizable ];
1177 [self addSubview: o_label];
1179 /* build the button */
1180 ADD_RIGHT_BUTTON( o_button, mainFrame, 0, 0, o_itemTooltip,
1182 [o_button setAutoresizingMask:NSViewMinXMargin ];
1183 [self addSubview: o_button];
1185 /* build the textfield */
1186 if( p_item->value.psz )
1187 o_textfieldString = [NSString stringWithFormat: @"%s", (char *)p_item->value.psz];
1189 o_textfieldString = [NSString stringWithString: @""];
1190 ADD_TEXTFIELD( o_textfield, mainFrame, 12, 2, mainFrame.size.width -
1191 8 - [o_button frame].size.width,
1192 o_itemTooltip, o_textfieldString )
1193 [o_textfield setAutoresizingMask:NSViewWidthSizable ];
1194 [self addSubview: o_textfield];
1199 - (void) alignWithXPosition:(int)i_xPos
1206 [o_textfield release];
1211 - (IBAction)openFileDialog: (id)sender
1213 NSOpenPanel *o_open_panel = [NSOpenPanel openPanel];
1215 [o_open_panel setTitle: (b_directory)?
1216 _NS("Select a directory"):_NS("Select a file")];
1217 [o_open_panel setPrompt: _NS("Select")];
1218 [o_open_panel setAllowsMultipleSelection: NO];
1219 [o_open_panel setCanChooseFiles: !b_directory];
1220 [o_open_panel setCanChooseDirectories: b_directory];
1221 [o_open_panel beginSheetForDirectory:nil
1224 modalForWindow:[sender window]
1226 didEndSelector: @selector(pathChosenInPanel:
1232 - (void)pathChosenInPanel:(NSOpenPanel *)o_sheet
1233 withReturn:(int)i_return_code contextInfo:(void *)o_context_info
1235 if( i_return_code == NSOKButton )
1237 NSString *o_path = [[o_sheet filenames] objectAtIndex: 0];
1238 [o_textfield setStringValue: o_path];
1242 - (char *)stringValue
1244 if( [[o_textfield stringValue] length] != 0)
1245 return strdup( [[o_textfield stringValue] fileSystemRepresentation] );
1252 NSString *o_textfieldString;
1253 char *psz_value = config_GetPsz( VLCIntf, p_item->psz_name );
1255 o_textfieldString = [NSString stringWithFormat: @"%s", psz_value];
1257 o_textfieldString = [NSString stringWithString: @""];
1260 [super resetValues];
1264 @implementation ModuleConfigControl
1265 - (id) initWithItem: (module_config_t *)_p_item
1266 withView: (NSView *)o_parent_view
1268 NSRect mainFrame = [o_parent_view frame];
1269 NSString *o_labelString, *o_popupTooltip;
1270 mainFrame.size.height = 22;
1271 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN + 1;
1272 mainFrame.origin.x = LEFTMARGIN;
1273 mainFrame.origin.y = 0;
1275 if( [super initWithFrame: mainFrame item: _p_item] != nil )
1277 i_view_type = CONFIG_ITEM_MODULE;
1279 o_popupTooltip = [[VLCMain sharedInstance] wrapString:
1280 [[VLCMain sharedInstance]
1281 localizedString: (char *)p_item->psz_longtext ] toWidth: PREFS_WRAP];
1284 if( p_item->psz_text )
1285 o_labelString = [[VLCMain sharedInstance]
1286 localizedString: (char *)p_item->psz_text];
1288 o_labelString = [NSString stringWithString:@""];
1289 ADD_LABEL( o_label, mainFrame, 0, -1, o_labelString, o_popupTooltip )
1290 [o_label setAutoresizingMask:NSViewNotSizable ];
1291 [self addSubview: o_label];
1293 /* build the popup */
1294 ADD_POPUP( o_popup, mainFrame, [o_label frame].size.width,
1295 -2, 0, o_popupTooltip )
1296 [o_popup setAutoresizingMask:NSViewWidthSizable ];
1297 [o_popup addItemWithTitle: _NS("Default")];
1298 [[o_popup lastItem] setTag: -1];
1299 [o_popup selectItem: [o_popup lastItem]];
1302 [self addSubview: o_popup];
1307 - (void) alignWithXPosition:(int)i_xPos
1310 NSRect superFrame = [self frame];
1311 frame = [o_label frame];
1312 frame.origin.x = i_xPos - frame.size.width - 3;
1313 [o_label setFrame:frame];
1315 frame = [o_popup frame];
1316 frame.origin.x = i_xPos - 1;
1317 frame.size.width = superFrame.size.width - frame.origin.x + 2;
1318 [o_popup setFrame:frame];
1327 - (char *)stringValue
1329 NSString *newval = [o_popup titleOfSelectedItem];
1330 char *returnval = NULL;
1331 size_t i_module_index;
1332 module_t *p_parser, **p_list;
1334 p_list = module_list_get( NULL );
1335 for( i_module_index = 0; p_list[i_module_index]; i_module_index++ )
1337 p_parser = p_list[i_module_index];
1339 if( p_item->i_type == CONFIG_ITEM_MODULE )
1341 if( module_provides( p_parser, p_item->psz_type ) )
1343 NSString *o_description = [[VLCMain sharedInstance]
1344 localizedString: module_GetLongName( p_parser )];
1345 if( [newval isEqualToString: o_description] )
1347 returnval = strdup( module_get_object( p_parser ));
1356 if( module_is_main( p_parser) )
1358 unsigned int confsize, unused;
1359 module_config_get( p_parser, &confsize );
1360 for ( i = 0; i < confsize; i++ )
1362 module_config_t *p_config = module_config_get( p_parser, &unused ) + i;
1363 /* Hack: required subcategory is stored in i_min */
1364 if( p_config->i_type == CONFIG_SUBCATEGORY &&
1365 p_config->value.i == p_item->min.i )
1367 NSString *o_description = [[VLCMain sharedInstance]
1368 localizedString: module_GetLongName( p_parser )];
1369 if( [newval isEqualToString: o_description] )
1371 returnval = strdup(module_get_object( p_parser ));
1378 module_list_free( p_list );
1384 /* build a list of available modules */
1386 module_t *p_parser, **p_list;
1388 p_list = module_list_get( NULL );
1389 for( i_index = 0; p_list[i_index]; i_index++ )
1391 p_parser = p_list[i_index];
1393 if( p_item->i_type == CONFIG_ITEM_MODULE )
1395 if( module_provides( p_parser, p_item->psz_type ) )
1397 NSString *o_description = [[VLCMain sharedInstance]
1398 localizedString: module_GetLongName( p_parser )];
1399 [o_popup addItemWithTitle: o_description];
1400 char *psz_value = config_GetPsz( VLCIntf, p_item->psz_name );
1403 !strcmp( psz_value, module_get_object( p_parser ) ) )
1404 [o_popup selectItem:[o_popup lastItem]];
1413 if( module_is_main( p_parser ) )
1415 unsigned int confsize;
1416 unsigned int unused;
1417 module_config_t *p_configlist = module_config_get( p_parser, &confsize );
1418 for ( i = 0; i < confsize; i++ )
1420 module_config_t *p_config = &p_configlist[i];
1421 /* Hack: required subcategory is stored in i_min */
1422 if( p_config->i_type == CONFIG_SUBCATEGORY &&
1423 config_GetInt( VLCIntf, p_item->psz_name) == p_item->min.i )
1425 NSString *o_description = [[VLCMain sharedInstance]
1426 localizedString: module_GetLongName( p_parser )];
1427 [o_popup addItemWithTitle: o_description];
1428 char *psz_value = config_GetPsz( VLCIntf, p_item->psz_name );
1430 if( psz_value && !strcmp(psz_value,
1431 module_get_object( p_parser )) )
1432 [o_popup selectItem:[o_popup lastItem]];
1437 module_config_free( p_configlist );
1440 module_list_free( p_list );
1441 [super resetValues];
1445 @implementation IntegerConfigControl
1446 - (id) initWithItem: (module_config_t *)_p_item
1447 withView: (NSView *)o_parent_view
1449 NSRect mainFrame = [o_parent_view frame];
1450 NSString *o_labelString, *o_tooltip;
1451 mainFrame.size.height = 23;
1452 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN + 1;
1453 mainFrame.origin.x = LEFTMARGIN;
1454 mainFrame.origin.y = 0;
1456 if( [super initWithFrame: mainFrame item: _p_item] != nil )
1458 i_view_type = CONFIG_ITEM_INTEGER;
1460 o_tooltip = [[VLCMain sharedInstance] wrapString:
1461 [[VLCMain sharedInstance]
1462 localizedString: (char *)p_item->psz_longtext ] toWidth: PREFS_WRAP];
1465 if( p_item->psz_text )
1466 o_labelString = [[VLCMain sharedInstance]
1467 localizedString: (char *)p_item->psz_text];
1469 o_labelString = [NSString stringWithString:@""];
1470 ADD_LABEL( o_label, mainFrame, 0, -3, o_labelString, o_tooltip )
1471 [o_label setAutoresizingMask:NSViewNotSizable ];
1472 [self addSubview: o_label];
1474 /* build the stepper */
1475 ADD_STEPPER( o_stepper, mainFrame, mainFrame.size.width - 19,
1476 0, o_tooltip, -100000, 100000)
1477 [o_stepper setIntValue: p_item->value.i];
1478 [o_stepper setAutoresizingMask:NSViewMaxXMargin ];
1479 [self addSubview: o_stepper];
1481 ADD_TEXTFIELD( o_textfield, mainFrame, mainFrame.size.width - 19 - 52,
1482 1, 49, o_tooltip, @"" )
1483 [o_textfield setIntValue: p_item->value.i];
1484 [o_textfield setDelegate: self];
1485 [[NSNotificationCenter defaultCenter] addObserver: self
1486 selector: @selector(textfieldChanged:)
1487 name: NSControlTextDidChangeNotification
1488 object: o_textfield];
1489 [o_textfield setAutoresizingMask:NSViewMaxXMargin ];
1490 [self addSubview: o_textfield];
1495 - (void) alignWithXPosition:(int)i_xPos
1498 frame = [o_label frame];
1499 frame.origin.x = i_xPos - frame.size.width - 3;
1500 [o_label setFrame:frame];
1502 frame = [o_textfield frame];
1503 frame.origin.x = i_xPos + 2;
1504 [o_textfield setFrame:frame];
1506 frame = [o_stepper frame];
1507 frame.origin.x = i_xPos + [o_textfield frame].size.width + 5;
1508 [o_stepper setFrame:frame];
1513 [o_stepper release];
1514 [o_textfield release];
1518 - (IBAction)stepperChanged:(id)sender
1520 [o_textfield setIntValue: [o_stepper intValue]];
1523 - (void)textfieldChanged:(NSNotification *)o_notification
1525 [o_stepper setIntValue: [o_textfield intValue]];
1530 return [o_textfield intValue];
1535 [o_textfield setIntValue: config_GetInt(VLCIntf, p_item->psz_name)];
1536 [super resetValues];
1541 @implementation IntegerListConfigControl
1543 - (id) initWithItem: (module_config_t *)_p_item
1544 withView: (NSView *)o_parent_view
1546 NSRect mainFrame = [o_parent_view frame];
1547 NSString *o_labelString, *o_textfieldTooltip;
1548 mainFrame.size.height = 22;
1549 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN + 1;
1550 mainFrame.origin.x = LEFTMARGIN;
1551 mainFrame.origin.y = 0;
1553 if( [super initWithFrame: mainFrame item: _p_item] != nil )
1556 i_view_type = CONFIG_ITEM_STRING_LIST;
1558 o_textfieldTooltip = [[VLCMain sharedInstance] wrapString:
1559 [[VLCMain sharedInstance]
1560 localizedString: (char *)p_item->psz_longtext ] toWidth: PREFS_WRAP];
1563 if( p_item->psz_text )
1564 o_labelString = [[VLCMain sharedInstance]
1565 localizedString: (char *)p_item->psz_text];
1567 o_labelString = [NSString stringWithString:@""];
1568 ADD_LABEL( o_label, mainFrame, 0, -3, o_labelString, o_textfieldTooltip )
1569 [o_label setAutoresizingMask:NSViewNotSizable ];
1570 [self addSubview: o_label];
1572 /* build the textfield */
1573 ADD_COMBO( o_combo, mainFrame, [o_label frame].size.width,
1574 -2, 0, o_textfieldTooltip )
1575 [o_combo setAutoresizingMask:NSViewWidthSizable ];
1576 for( i_index = 0; i_index < p_item->i_list; i_index++ )
1578 if( p_item->value.i == p_item->pi_list[i_index] )
1580 [o_combo selectItemAtIndex: i_index];
1583 [self addSubview: o_combo];
1588 - (void) alignWithXPosition:(int)i_xPos
1591 NSRect superFrame = [self frame];
1592 frame = [o_label frame];
1593 frame.origin.x = i_xPos - frame.size.width - 3;
1594 [o_label setFrame:frame];
1596 frame = [o_combo frame];
1597 frame.origin.x = i_xPos + 2;
1598 frame.size.width = superFrame.size.width - frame.origin.x + 2;
1599 [o_combo setFrame:frame];
1610 if( [o_combo indexOfSelectedItem] >= 0 )
1611 return p_item->pi_list[[o_combo indexOfSelectedItem]];
1613 return [o_combo intValue];
1619 [o_combo reloadData];
1620 for( i_index = 0; i_index < p_item->i_list; i_index++ )
1622 if( config_GetInt( VLCIntf, p_item->psz_name) == p_item->pi_list[i_index] )
1624 [o_combo selectItemAtIndex: i_index];
1631 @implementation IntegerListConfigControl (NSComboBoxDataSource)
1632 - (NSInteger)numberOfItemsInComboBox:(NSComboBox *)aComboBox
1634 return p_item->i_list;
1637 - (id)comboBox:(NSComboBox *)aComboBox objectValueForItemAtIndex:(NSInteger)i_index
1639 if( p_item->ppsz_list_text && p_item->ppsz_list_text[i_index] )
1640 return [[VLCMain sharedInstance]
1641 localizedString: (char *)p_item->ppsz_list_text[i_index]];
1643 return [NSString stringWithFormat: @"%i", p_item->pi_list[i_index]];
1647 @implementation RangedIntegerConfigControl
1648 - (id) initWithItem: (module_config_t *)_p_item
1649 withView: (NSView *)o_parent_view
1651 NSRect mainFrame = [o_parent_view frame];
1652 NSString *o_labelString, *o_tooltip;
1653 mainFrame.size.height = 50;
1654 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN;
1655 mainFrame.origin.x = LEFTMARGIN;
1656 mainFrame.origin.y = 0;
1658 if( [super initWithFrame: mainFrame item: _p_item] != nil )
1660 i_view_type = CONFIG_ITEM_RANGED_INTEGER;
1662 o_tooltip = [[VLCMain sharedInstance] wrapString:
1663 [[VLCMain sharedInstance]
1664 localizedString: (char *)p_item->psz_longtext ] toWidth: PREFS_WRAP];
1667 if( p_item->psz_text )
1668 o_labelString = [[VLCMain sharedInstance]
1669 localizedString: (char *)p_item->psz_text];
1671 o_labelString = [NSString stringWithString:@""];
1672 ADD_LABEL( o_label, mainFrame, 0, -3, o_labelString, o_tooltip )
1673 [o_label setAutoresizingMask:NSViewNotSizable ];
1674 [self addSubview: o_label];
1676 /* build the textfield */
1677 ADD_TEXTFIELD( o_textfield, mainFrame, [o_label frame].size.width + 2,
1678 28, 49, o_tooltip, @"" )
1679 [o_textfield setIntValue: p_item->value.i];
1680 [o_textfield setAutoresizingMask:NSViewMaxXMargin ];
1681 [o_textfield setDelegate: self];
1682 [[NSNotificationCenter defaultCenter] addObserver: self
1683 selector: @selector(textfieldChanged:)
1684 name: NSControlTextDidChangeNotification
1685 object: o_textfield];
1686 [self addSubview: o_textfield];
1688 /* build the mintextfield */
1689 ADD_LABEL( o_textfield_min, mainFrame, 12, -30, @"-8888", @"" )
1690 [o_textfield_min setIntValue: p_item->min.i];
1691 [o_textfield_min setAutoresizingMask:NSViewMaxXMargin ];
1692 [o_textfield_min setAlignment:NSRightTextAlignment];
1693 [self addSubview: o_textfield_min];
1695 /* build the maxtextfield */
1696 ADD_LABEL( o_textfield_max, mainFrame,
1697 mainFrame.size.width - 31, -30, @"8888", @"" )
1698 [o_textfield_max setIntValue: p_item->max.i];
1699 [o_textfield_max setAutoresizingMask:NSViewMinXMargin ];
1700 [self addSubview: o_textfield_max];
1702 /* build the slider */
1703 ADD_SLIDER( o_slider, mainFrame, [o_textfield_min frame].origin.x +
1704 [o_textfield_min frame].size.width + 6, -1, mainFrame.size.width -
1705 [o_textfield_max frame].size.width -
1706 [o_textfield_max frame].size.width - 14 -
1707 [o_textfield_min frame].origin.x, o_tooltip,
1708 p_item->min.i, p_item->max.i )
1709 [o_slider setIntValue: p_item->value.i];
1710 [o_slider setAutoresizingMask:NSViewWidthSizable ];
1711 [o_slider setTarget: self];
1712 [o_slider setAction: @selector(sliderChanged:)];
1713 [o_slider sendActionOn:NSLeftMouseUpMask | NSLeftMouseDownMask |
1714 NSLeftMouseDraggedMask];
1715 [self addSubview: o_slider];
1721 - (void) alignWithXPosition:(int)i_xPos
1724 frame = [o_label frame];
1725 frame.origin.x = i_xPos - frame.size.width - 3;
1726 [o_label setFrame:frame];
1728 frame = [o_textfield frame];
1729 frame.origin.x = i_xPos + 2;
1730 [o_textfield setFrame:frame];
1735 [o_textfield release];
1736 [o_textfield_min release];
1737 [o_textfield_max release];
1742 - (IBAction)sliderChanged:(id)sender
1744 [o_textfield setIntValue: [o_slider intValue]];
1747 - (void)textfieldChanged:(NSNotification *)o_notification
1749 [o_slider setIntValue: [o_textfield intValue]];
1754 return [o_slider intValue];
1759 int value = config_GetInt( VLCIntf, p_item->psz_name );
1760 [o_textfield setIntValue:value];
1761 [o_slider setIntValue:value];
1762 [super resetValues];
1766 @implementation FloatConfigControl
1767 - (id) initWithItem: (module_config_t *)_p_item
1768 withView: (NSView *)o_parent_view
1770 NSRect mainFrame = [o_parent_view frame];
1771 NSString *o_labelString, *o_tooltip;
1772 mainFrame.size.height = 23;
1773 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN + 1;
1774 mainFrame.origin.x = LEFTMARGIN;
1775 mainFrame.origin.y = 0;
1777 if( [super initWithFrame: mainFrame item: _p_item] != nil )
1779 i_view_type = CONFIG_ITEM_INTEGER;
1781 o_tooltip = [[VLCMain sharedInstance] wrapString:
1782 [[VLCMain sharedInstance]
1783 localizedString: (char *)p_item->psz_longtext ] toWidth: PREFS_WRAP];
1786 if( p_item->psz_text )
1787 o_labelString = [[VLCMain sharedInstance]
1788 localizedString: (char *)p_item->psz_text];
1790 o_labelString = [NSString stringWithString:@""];
1791 ADD_LABEL( o_label, mainFrame, 0, -2, o_labelString, o_tooltip )
1792 [o_label setAutoresizingMask:NSViewNotSizable ];
1793 [self addSubview: o_label];
1795 /* build the stepper */
1796 ADD_STEPPER( o_stepper, mainFrame, mainFrame.size.width - 19,
1797 0, o_tooltip, -100000, 100000)
1798 [o_stepper setFloatValue: p_item->value.f];
1799 [o_stepper setAutoresizingMask:NSViewMaxXMargin ];
1800 [self addSubview: o_stepper];
1802 /* build the textfield */
1803 ADD_TEXTFIELD( o_textfield, mainFrame, mainFrame.size.width - 19 - 52,
1804 1, 49, o_tooltip, @"" )
1805 [o_textfield setFloatValue: p_item->value.f];
1806 [o_textfield setDelegate: self];
1807 [[NSNotificationCenter defaultCenter] addObserver: self
1808 selector: @selector(textfieldChanged:)
1809 name: NSControlTextDidChangeNotification
1810 object: o_textfield];
1811 [o_textfield setAutoresizingMask:NSViewMaxXMargin ];
1812 [self addSubview: o_textfield];
1817 - (void) alignWithXPosition:(int)i_xPos
1820 frame = [o_label frame];
1821 frame.origin.x = i_xPos - frame.size.width - 3;
1822 [o_label setFrame:frame];
1824 frame = [o_textfield frame];
1825 frame.origin.x = i_xPos + 2;
1826 [o_textfield setFrame:frame];
1828 frame = [o_stepper frame];
1829 frame.origin.x = i_xPos + [o_textfield frame].size.width + 5;
1830 [o_stepper setFrame:frame];
1835 [o_stepper release];
1836 [o_textfield release];
1840 - (IBAction)stepperChanged:(id)sender
1842 [o_textfield setFloatValue: [o_stepper floatValue]];
1845 - (void)textfieldChanged:(NSNotification *)o_notification
1847 [o_stepper setFloatValue: [o_textfield floatValue]];
1852 return [o_stepper floatValue];
1857 [o_textfield setFloatValue: config_GetFloat( VLCIntf, p_item->psz_name)];
1858 [super resetValues];
1862 @implementation RangedFloatConfigControl
1863 - (id) initWithItem: (module_config_t *)_p_item
1864 withView: (NSView *)o_parent_view
1866 NSRect mainFrame = [o_parent_view frame];
1867 NSString *o_labelString, *o_tooltip;
1868 mainFrame.size.height = 50;
1869 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN;
1870 mainFrame.origin.x = LEFTMARGIN;
1871 mainFrame.origin.y = 0;
1873 if( [super initWithFrame: mainFrame item: _p_item] != nil )
1875 i_view_type = CONFIG_ITEM_RANGED_INTEGER;
1877 o_tooltip = [[VLCMain sharedInstance] wrapString:
1878 [[VLCMain sharedInstance]
1879 localizedString: (char *)p_item->psz_longtext ] toWidth: PREFS_WRAP];
1882 if( p_item->psz_text )
1883 o_labelString = [[VLCMain sharedInstance]
1884 localizedString: (char *)p_item->psz_text];
1886 o_labelString = [NSString stringWithString:@""];
1887 ADD_LABEL( o_label, mainFrame, 0, -3, o_labelString, o_tooltip )
1888 [o_label setAutoresizingMask:NSViewNotSizable ];
1889 [self addSubview: o_label];
1891 /* build the textfield */
1892 ADD_TEXTFIELD( o_textfield, mainFrame, [o_label frame].size.width + 2,
1893 28, 49, o_tooltip, @"" )
1894 [o_textfield setFloatValue: p_item->value.f];
1895 [o_textfield setAutoresizingMask:NSViewMaxXMargin ];
1896 [o_textfield setDelegate: self];
1897 [[NSNotificationCenter defaultCenter] addObserver: self
1898 selector: @selector(textfieldChanged:)
1899 name: NSControlTextDidChangeNotification
1900 object: o_textfield];
1901 [self addSubview: o_textfield];
1903 /* build the mintextfield */
1904 ADD_LABEL( o_textfield_min, mainFrame, 12, -30, @"-8888", @"" )
1905 [o_textfield_min setFloatValue: p_item->min.f];
1906 [o_textfield_min setAutoresizingMask:NSViewMaxXMargin ];
1907 [o_textfield_min setAlignment:NSRightTextAlignment];
1908 [self addSubview: o_textfield_min];
1910 /* build the maxtextfield */
1911 ADD_LABEL( o_textfield_max, mainFrame, mainFrame.size.width - 31,
1913 [o_textfield_max setFloatValue: p_item->max.f];
1914 [o_textfield_max setAutoresizingMask:NSViewMinXMargin ];
1915 [self addSubview: o_textfield_max];
1917 /* build the slider */
1918 ADD_SLIDER( o_slider, mainFrame, [o_textfield_min frame].origin.x +
1919 [o_textfield_min frame].size.width + 6, -1, mainFrame.size.width -
1920 [o_textfield_max frame].size.width -
1921 [o_textfield_max frame].size.width - 14 -
1922 [o_textfield_min frame].origin.x, o_tooltip, p_item->min.f,
1924 [o_slider setFloatValue: p_item->value.f];
1925 [o_slider setAutoresizingMask:NSViewWidthSizable ];
1926 [o_slider setTarget: self];
1927 [o_slider setAction: @selector(sliderChanged:)];
1928 [o_slider sendActionOn:NSLeftMouseUpMask | NSLeftMouseDownMask |
1929 NSLeftMouseDraggedMask];
1930 [self addSubview: o_slider];
1936 - (void) alignWithXPosition:(int)i_xPos
1939 frame = [o_label frame];
1940 frame.origin.x = i_xPos - frame.size.width - 3;
1941 [o_label setFrame:frame];
1943 frame = [o_textfield frame];
1944 frame.origin.x = i_xPos + 2;
1945 [o_textfield setFrame:frame];
1950 [o_textfield release];
1951 [o_textfield_min release];
1952 [o_textfield_max release];
1957 - (IBAction)sliderChanged:(id)sender
1959 [o_textfield setFloatValue: [o_slider floatValue]];
1962 - (void)textfieldChanged:(NSNotification *)o_notification
1964 [o_slider setFloatValue: [o_textfield floatValue]];
1969 return [o_slider floatValue];
1974 [o_textfield setFloatValue: config_GetFloat(VLCIntf, p_item->psz_name)];
1975 [o_slider setFloatValue: config_GetFloat(VLCIntf, p_item->psz_name)];
1976 [super resetValues];
1980 @implementation BoolConfigControl
1982 - (id) initWithItem: (module_config_t *)_p_item
1983 withView: (NSView *)o_parent_view
1985 NSRect mainFrame = [o_parent_view frame];
1986 NSString *o_labelString, *o_tooltip;
1987 mainFrame.size.height = 17;
1988 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN;
1989 mainFrame.origin.x = LEFTMARGIN;
1990 mainFrame.origin.y = 0;
1992 if( [super initWithFrame: mainFrame item: _p_item] != nil )
1994 i_view_type = CONFIG_ITEM_BOOL;
1996 /* add the checkbox */
1997 o_tooltip = [[VLCMain sharedInstance]
1998 wrapString: [[VLCMain sharedInstance]
1999 localizedString: (char *)p_item->psz_longtext ] toWidth: PREFS_WRAP];
2000 ADD_CHECKBOX( o_checkbox, mainFrame, 0,
2001 0, @"", o_tooltip, p_item->value.i, NSImageLeft)
2002 [o_checkbox setAutoresizingMask:NSViewNotSizable ];
2003 [self addSubview: o_checkbox];
2005 if( p_item->psz_text )
2006 o_labelString = [[VLCMain sharedInstance]
2007 localizedString: (char *)p_item->psz_text];
2009 o_labelString = [NSString stringWithString:@""];
2010 ADD_LABEL( o_label, mainFrame, [o_checkbox frame].size.width, 0, o_labelString, o_tooltip )
2011 [o_label setAutoresizingMask:NSViewNotSizable ];
2012 [self addSubview: o_label];
2019 [o_checkbox release];
2025 return [o_checkbox intValue];
2030 [o_checkbox setState: config_GetInt( VLCIntf, p_item->psz_name)];
2031 [super resetValues];
2035 @implementation KeyConfigControl
2036 - (id) initWithItem: (module_config_t *)_p_item
2037 withView: (NSView *)o_parent_view
2039 NSRect mainFrame = [o_parent_view frame];
2040 NSString *o_labelString, *o_tooltip;
2041 mainFrame.size.height = 22;
2042 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN + 1;
2043 mainFrame.origin.x = LEFTMARGIN;
2044 mainFrame.origin.y = 0;
2046 if( [super initWithFrame: mainFrame item: _p_item] != nil )
2048 i_view_type = CONFIG_ITEM_KEY_AFTER_10_3;
2050 o_tooltip = [[VLCMain sharedInstance] wrapString:
2051 [[VLCMain sharedInstance]
2052 localizedString: (char *)p_item->psz_longtext ] toWidth: PREFS_WRAP];
2055 if( p_item->psz_text )
2056 o_labelString = [[VLCMain sharedInstance]
2057 localizedString: (char *)p_item->psz_text];
2059 o_labelString = [NSString stringWithString:@""];
2060 ADD_LABEL( o_label, mainFrame, 0, -1, o_labelString, o_tooltip )
2061 [o_label setAutoresizingMask:NSViewNotSizable ];
2062 [self addSubview: o_label];
2064 /* build the popup */
2065 ADD_POPUP( o_popup, mainFrame, [o_label frame].origin.x +
2066 [o_label frame].size.width + 3,
2068 [o_popup setAutoresizingMask:NSViewWidthSizable ];
2070 if( o_keys_menu == nil )
2073 o_keys_menu = [[NSMenu alloc] initWithTitle: @"Keys Menu"];
2074 for ( i = 0; i < sizeof(vlc_keys) / sizeof(key_descriptor_t); i++)
2075 if( vlc_keys[i].psz_key_string )
2076 POPULATE_A_KEY( o_keys_menu,
2077 [NSString stringWithUTF8String:vlc_keys[i].psz_key_string]
2078 , vlc_keys[i].i_key_code)
2080 [o_popup setMenu:[o_keys_menu copyWithZone:nil]];
2081 [o_popup selectItem:[[o_popup menu] itemWithTag:p_item->value.i]];
2082 [self addSubview: o_popup];
2088 - (void) alignWithXPosition:(int)i_xPos
2091 NSRect superFrame = [self frame];
2092 frame = [o_label frame];
2093 frame.origin.x = i_xPos - frame.size.width - 3;
2094 [o_label setFrame:frame];
2096 frame = [o_popup frame];
2097 frame.origin.x = i_xPos - 1;
2098 frame.size.width = superFrame.size.width - frame.origin.x + 2;
2099 [o_popup setFrame:frame];
2110 return [o_popup selectedTag];
2115 [o_popup selectItem:[[o_popup menu] itemWithTag:config_GetInt( VLCIntf, p_item->psz_name )]];
2116 [super resetValues];
2120 @implementation ModuleListConfigControl
2121 - (id) initWithItem: (module_config_t *)_p_item
2122 withView: (NSView *)o_parent_view
2124 if( _p_item->i_type == CONFIG_ITEM_MODULE_LIST )
2128 //Fill our array to know how may items we have...
2129 module_t *p_parser, **p_list;
2130 size_t i_module_index;
2131 NSRect mainFrame = [o_parent_view frame];
2132 NSString *o_labelString, *o_textfieldString, *o_tooltip;
2134 o_modulearray = [[NSMutableArray alloc] initWithCapacity:10];
2135 /* build a list of available modules */
2136 p_list = module_list_get( NULL );
2137 for( i_module_index = 0; p_list[i_module_index]; i_module_index++ )
2140 p_parser = p_list[i_module_index];
2142 if( module_is_main( p_parser ) )
2145 unsigned int confsize;
2146 module_config_t *p_configlist = module_config_get( p_parser, &confsize );
2148 for ( i = 0; i < confsize; i++ )
2150 unsigned int unused;
2151 module_config_t *p_config = &p_configlist[i];
2152 NSString *o_modulelongname, *o_modulename;
2153 NSNumber *o_moduleenabled = nil;
2155 /* Hack: required subcategory is stored in i_min */
2156 if( p_config->i_type == CONFIG_SUBCATEGORY &&
2157 p_config->value.i == _p_item->min.i )
2159 o_modulelongname = [NSString stringWithUTF8String:
2160 module_GetLongName( p_parser )];
2161 o_modulename = [NSString stringWithUTF8String:
2162 module_get_object( p_parser )];
2164 if( _p_item->value.psz &&
2165 strstr( _p_item->value.psz, module_get_object( p_parser ) ) )
2166 o_moduleenabled = [NSNumber numberWithBool:YES];
2168 o_moduleenabled = [NSNumber numberWithBool:NO];
2170 [o_modulearray addObject:[NSMutableArray
2171 arrayWithObjects: o_modulename, o_modulelongname,
2172 o_moduleenabled, nil]];
2175 module_config_free( p_configlist );
2177 module_list_free( p_list );
2179 mainFrame.size.height = 30 + 18 * [o_modulearray count];
2180 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN;
2181 mainFrame.origin.x = LEFTMARGIN;
2182 mainFrame.origin.y = 0;
2183 if( [super initWithFrame: mainFrame item: _p_item] != nil )
2185 i_view_type = CONFIG_ITEM_MODULE_LIST;
2187 o_tooltip = [[VLCMain sharedInstance] wrapString:
2188 [[VLCMain sharedInstance]
2189 localizedString: (char *)p_item->psz_longtext ] toWidth: PREFS_WRAP];
2192 if( p_item->psz_text )
2193 o_labelString = [[VLCMain sharedInstance]
2194 localizedString: (char *)p_item->psz_text];
2196 o_labelString = [NSString stringWithString:@""];
2197 ADD_LABEL( o_label, mainFrame, 0, -3, o_labelString, o_tooltip )
2198 [o_label setAutoresizingMask:NSViewNotSizable ];
2199 [self addSubview: o_label];
2201 /* build the textfield */
2202 if( p_item->value.psz )
2203 o_textfieldString = [[VLCMain sharedInstance]
2204 localizedString: (char *)p_item->value.psz];
2206 o_textfieldString = [NSString stringWithString: @""];
2207 ADD_TEXTFIELD( o_textfield, mainFrame, [o_label frame].size.width + 2,
2208 mainFrame.size.height - 22, mainFrame.size.width -
2209 [o_label frame].size.width - 2, o_tooltip, o_textfieldString )
2210 [o_textfield setAutoresizingMask:NSViewWidthSizable ];
2211 [self addSubview: o_textfield];
2215 NSRect s_rc = mainFrame;
2216 s_rc.size.height = mainFrame.size.height - 30;
2217 s_rc.size.width = mainFrame.size.width - 12;
2220 o_scrollview = [[[NSScrollView alloc] initWithFrame: s_rc] retain];
2221 [o_scrollview setDrawsBackground: NO];
2222 [o_scrollview setBorderType: NSBezelBorder];
2223 [o_scrollview setAutohidesScrollers:YES];
2225 NSTableView *o_tableview;
2226 o_tableview = [[NSTableView alloc] initWithFrame : s_rc];
2227 [o_tableview setUsesAlternatingRowBackgroundColors:YES];
2228 [o_tableview setHeaderView:nil];
2229 /* TODO: find a good way to fix the row height and text size*/
2230 /* FIXME: support for multiple selection... */
2231 // [o_tableview setAllowsMultipleSelection:YES];
2233 NSCell *o_headerCell = [[NSCell alloc] initTextCell:@"Enabled"];
2234 NSCell *o_dataCell = [[NSButtonCell alloc] init];
2235 [(NSButtonCell*)o_dataCell setButtonType:NSSwitchButton];
2236 [o_dataCell setTitle:@""];
2237 [o_dataCell setFont:[NSFont systemFontOfSize:0]];
2238 NSTableColumn *o_tableColumn = [[NSTableColumn alloc]
2239 initWithIdentifier:@"Enabled"];
2240 [o_tableColumn setHeaderCell: o_headerCell];
2241 [o_tableColumn setDataCell: o_dataCell];
2242 [o_tableColumn setWidth:17];
2243 [o_tableview addTableColumn: o_tableColumn];
2245 o_headerCell = [[NSCell alloc] initTextCell:@"Module Name"];
2246 o_dataCell = [[NSTextFieldCell alloc] init];
2247 [o_dataCell setFont:[NSFont systemFontOfSize:12]];
2248 o_tableColumn = [[NSTableColumn alloc]
2249 initWithIdentifier:@"Module"];
2250 [o_tableColumn setHeaderCell: o_headerCell];
2251 [o_tableColumn setDataCell: o_dataCell];
2252 [o_tableColumn setWidth:388 - 17];
2253 [o_tableview addTableColumn: o_tableColumn];
2254 [o_tableview registerForDraggedTypes:[NSArray arrayWithObjects:
2255 @"VLC media player module", nil]];
2257 [o_tableview setDataSource:self];
2258 [o_tableview setTarget: self];
2259 [o_tableview setAction: @selector(tableChanged:)];
2260 [o_tableview sendActionOn:NSLeftMouseUpMask | NSLeftMouseDownMask |
2261 NSLeftMouseDraggedMask];
2262 [o_scrollview setDocumentView: o_tableview];
2264 [o_scrollview setAutoresizingMask:NSViewWidthSizable ];
2265 [self addSubview: o_scrollview];
2272 - (void) alignWithXPosition:(int)i_xPos
2277 - (IBAction)tableChanged:(id)sender
2279 NSString *o_newstring = @"";
2281 for( i = 0 ; i < [o_modulearray count] ; i++ )
2282 if( [[[o_modulearray objectAtIndex:i] objectAtIndex:2]
2285 o_newstring = [o_newstring stringByAppendingString:
2286 [[o_modulearray objectAtIndex:i] objectAtIndex:0]];
2287 o_newstring = [o_newstring stringByAppendingString:@":"];
2290 [o_textfield setStringValue: [o_newstring
2291 substringToIndex: ([o_newstring length])?[o_newstring length] - 1:0]];
2296 [o_scrollview release];
2301 - (char *)stringValue
2303 return strdup( [[o_textfield stringValue] UTF8String] );
2308 #warning Reset prefs of the module selector is broken atm.
2309 NSLog( @"don't forget about modulelistconfig" );
2310 [super resetValues];
2315 @implementation ModuleListConfigControl (NSTableDataSource)
2317 - (BOOL)tableView:(NSTableView*)table writeRows:(NSArray*)rows
2318 toPasteboard:(NSPasteboard*)pb
2320 // We only want to allow dragging of selected rows.
2321 NSEnumerator *iter = [rows objectEnumerator];
2323 while ((row = [iter nextObject]) != nil)
2325 if (![table isRowSelected:[row intValue]])
2329 [pb declareTypes:[NSArray
2330 arrayWithObject:@"VLC media player module"] owner:nil];
2331 [pb setPropertyList:rows forType:@"VLC media player module"];
2335 - (NSDragOperation)tableView:(NSTableView*)table
2336 validateDrop:(id <NSDraggingInfo>)info proposedRow:(NSInteger)row
2337 proposedDropOperation:(NSTableViewDropOperation)op
2339 // Make drops at the end of the table go to the end.
2342 row = [table numberOfRows];
2343 op = NSTableViewDropAbove;
2344 [table setDropRow:row dropOperation:op];
2347 // We don't ever want to drop onto a row, only between rows.
2348 if (op == NSTableViewDropOn)
2349 [table setDropRow:(row+1) dropOperation:NSTableViewDropAbove];
2350 return NSTableViewDropAbove;
2353 - (BOOL)tableView:(NSTableView*)table acceptDrop:(id <NSDraggingInfo>)info
2354 row:(NSInteger)dropRow dropOperation:(NSTableViewDropOperation)op;
2356 NSPasteboard *pb = [info draggingPasteboard];
2357 NSDragOperation srcMask = [info draggingSourceOperationMask];
2364 // Intra-table drag - data is the array of rows.
2365 if (!accepted && (array =
2366 [pb propertyListForType:@"VLC media player module"]) != NULL)
2368 NSEnumerator *iter = nil;
2370 BOOL isCopy = (srcMask & NSDragOperationMove) ? NO:YES;
2372 iter = [array objectEnumerator];
2373 while ((val = [iter nextObject]) != NULL)
2375 NSArray *o_tmp = [[o_modulearray objectAtIndex:
2376 [val intValue]] mutableCopyWithZone:nil];
2377 [o_modulearray removeObject:o_tmp];
2378 [o_modulearray insertObject:o_tmp
2379 atIndex:(dropRow>[val intValue]) ? dropRow - 1 : dropRow];
2383 // Select the newly-dragged items.
2384 iter = [array objectEnumerator];
2386 [table deselectAll:self];
2388 [self tableChanged:self];
2389 [table setNeedsDisplay:YES];
2390 // Indicate that we finished the drag.
2394 [table setNeedsDisplay:YES];
2398 // An exception occurred. Uh-oh. Update the track table so that
2399 // it stays consistent, and re-raise the exception.
2401 [localException raise];
2402 [table setNeedsDisplay:YES];
2408 - (NSInteger)numberOfRowsInTableView:(NSTableView *)aTableView
2410 return [o_modulearray count];
2413 - (id)tableView:(NSTableView *)aTableView
2414 objectValueForTableColumn:(NSTableColumn *)aTableColumn row:(NSInteger)rowIndex
2416 if( [[aTableColumn identifier] isEqualToString: @"Enabled"] )
2417 return [[o_modulearray objectAtIndex:rowIndex] objectAtIndex:2];
2418 if( [[aTableColumn identifier] isEqualToString: @"Module"] )
2419 return [[o_modulearray objectAtIndex:rowIndex] objectAtIndex:1];
2424 - (void)tableView:(NSTableView *)aTableView setObjectValue:(id)anObject
2425 forTableColumn:(NSTableColumn *)aTableColumn row:(NSInteger)rowIndex
2427 [[o_modulearray objectAtIndex:rowIndex] replaceObjectAtIndex:2
2428 withObject: anObject];