1 /*****************************************************************************
2 * prefs_widgets.m: Preferences controls
3 *****************************************************************************
4 * Copyright (C) 2002-2003 VideoLAN
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., 59 Temple Place - Suite 330, Boston, MA 02111, USA.
23 *****************************************************************************/
25 /*****************************************************************************
27 *****************************************************************************/
28 #include <stdlib.h> /* malloc(), free() */
35 #include "prefs_widgets.h"
37 #define PREFS_WRAP 300
38 #define OFFSET_RIGHT 20
39 #define OFFSET_BETWEEN 2
42 #define RIGHTMARGIN 18
44 #define UPWARDS_WHITE_ARROW "\xE2\x87\xA7"
45 #define OPTION_KEY "\xE2\x8C\xA5"
46 #define UP_ARROWHEAD "\xE2\x8C\x83"
47 #define PLACE_OF_INTEREST_SIGN "\xE2\x8C\x98"
49 #define MACOS_VERSION 3
51 #define POPULATE_A_KEY( o_menu, string, value ) \
55 o_mi = [[NSMenuItem alloc] initWithTitle:string action:nil keyEquivalent:@""]; \
56 [o_mi setKeyEquivalentModifierMask: \
58 [o_mi setAlternate: NO]; \
61 [o_menu addItem: o_mi]; \
62 if( MACOS_VERSION >= 3 ) \
65 o_mi = [[NSMenuItem alloc] initWithTitle: \
66 [[NSString stringWithUTF8String: \
68 ] stringByAppendingString: string] \
69 action:nil keyEquivalent:@""]; \
70 [o_mi setKeyEquivalentModifierMask: \
72 [o_mi setAlternate: YES]; \
74 KEY_MODIFIER_CTRL | ( value )]; \
75 [o_menu addItem: o_mi]; \
77 o_mi = [[NSMenuItem alloc] initWithTitle: \
78 [[NSString stringWithUTF8String: \
79 UP_ARROWHEAD OPTION_KEY \
80 ] stringByAppendingString: string] \
81 action:nil keyEquivalent:@""]; \
82 [o_mi setKeyEquivalentModifierMask: \
83 NSControlKeyMask | NSAlternateKeyMask]; \
84 [o_mi setAlternate: YES]; \
86 (KEY_MODIFIER_CTRL | KEY_MODIFIER_ALT) | ( value )]; \
87 [o_menu addItem: o_mi]; \
89 o_mi = [[NSMenuItem alloc] initWithTitle: \
90 [[NSString stringWithUTF8String: \
91 UP_ARROWHEAD UPWARDS_WHITE_ARROW \
92 ] stringByAppendingString: string] \
93 action:nil keyEquivalent:@""]; \
94 [o_mi setKeyEquivalentModifierMask: \
95 NSControlKeyMask | NSShiftKeyMask]; \
96 [o_mi setAlternate: YES]; \
98 (KEY_MODIFIER_CTRL | KEY_MODIFIER_SHIFT) | ( value )]; \
99 [o_menu addItem: o_mi]; \
101 o_mi = [[NSMenuItem alloc] initWithTitle: \
102 [[NSString stringWithUTF8String: \
103 UP_ARROWHEAD PLACE_OF_INTEREST_SIGN \
104 ] stringByAppendingString: string] \
105 action:nil keyEquivalent:@""]; \
106 [o_mi setKeyEquivalentModifierMask: \
107 NSControlKeyMask | NSCommandKeyMask]; \
108 [o_mi setAlternate: YES]; \
110 (KEY_MODIFIER_CTRL | KEY_MODIFIER_COMMAND) | ( value )]; \
111 [o_menu addItem: o_mi]; \
112 /* Ctrl+Alt+Shift */ \
113 o_mi = [[NSMenuItem alloc] initWithTitle: \
114 [[NSString stringWithUTF8String: \
115 UP_ARROWHEAD OPTION_KEY UPWARDS_WHITE_ARROW \
116 ] stringByAppendingString: string] \
117 action:nil keyEquivalent:@""]; \
118 [o_mi setKeyEquivalentModifierMask: \
119 NSControlKeyMask | NSAlternateKeyMask | NSShiftKeyMask]; \
120 [o_mi setAlternate: YES]; \
122 (KEY_MODIFIER_CTRL | KEY_MODIFIER_ALT | KEY_MODIFIER_SHIFT) | ( value )]; \
123 [o_menu addItem: o_mi]; \
124 /* Ctrl+Alt+Apple */ \
125 o_mi = [[NSMenuItem alloc] initWithTitle: \
126 [[NSString stringWithUTF8String: \
127 UP_ARROWHEAD OPTION_KEY PLACE_OF_INTEREST_SIGN \
128 ] stringByAppendingString: string] \
129 action:nil keyEquivalent:@""]; \
130 [o_mi setKeyEquivalentModifierMask: \
131 NSControlKeyMask | NSAlternateKeyMask | NSCommandKeyMask]; \
132 [o_mi setAlternate: YES]; \
134 (KEY_MODIFIER_CTRL | KEY_MODIFIER_ALT | KEY_MODIFIER_COMMAND) | ( value )]; \
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) | ( value )]; \
147 [o_menu addItem: o_mi]; \
148 /* Ctrl+Alt+Shift+Apple */ \
149 o_mi = [[NSMenuItem alloc] initWithTitle: \
150 [[NSString stringWithUTF8String: \
151 UP_ARROWHEAD OPTION_KEY UPWARDS_WHITE_ARROW PLACE_OF_INTEREST_SIGN \
152 ] stringByAppendingString: string] \
153 action:nil keyEquivalent:@""]; \
154 [o_mi setKeyEquivalentModifierMask: \
155 NSControlKeyMask | NSAlternateKeyMask | NSShiftKeyMask | NSCommandKeyMask]; \
156 [o_mi setAlternate: YES]; \
158 (KEY_MODIFIER_CTRL | KEY_MODIFIER_ALT | KEY_MODIFIER_SHIFT | KEY_MODIFIER_COMMAND) | ( value )]; \
159 [o_menu addItem: o_mi]; \
161 o_mi = [[NSMenuItem alloc] initWithTitle: \
162 [[NSString stringWithUTF8String: \
164 ] stringByAppendingString: string] \
165 action:nil keyEquivalent:@""]; \
166 [o_mi setKeyEquivalentModifierMask: \
167 NSAlternateKeyMask]; \
168 [o_mi setAlternate: YES]; \
170 KEY_MODIFIER_ALT | ( value )]; \
171 [o_menu addItem: o_mi]; \
173 o_mi = [[NSMenuItem alloc] initWithTitle: \
174 [[NSString stringWithUTF8String: \
175 OPTION_KEY UPWARDS_WHITE_ARROW \
176 ] stringByAppendingString: string] \
177 action:nil keyEquivalent:@""]; \
178 [o_mi setKeyEquivalentModifierMask: \
179 NSAlternateKeyMask | NSShiftKeyMask]; \
180 [o_mi setAlternate: YES]; \
182 (KEY_MODIFIER_ALT | KEY_MODIFIER_SHIFT) | ( value )]; \
183 [o_menu addItem: o_mi]; \
185 o_mi = [[NSMenuItem alloc] initWithTitle: \
186 [[NSString stringWithUTF8String: \
187 OPTION_KEY PLACE_OF_INTEREST_SIGN \
188 ] stringByAppendingString: string] \
189 action:nil keyEquivalent:@""]; \
190 [o_mi setKeyEquivalentModifierMask: \
191 NSAlternateKeyMask | NSCommandKeyMask]; \
192 [o_mi setAlternate: YES]; \
194 (KEY_MODIFIER_ALT | KEY_MODIFIER_COMMAND) | ( value )]; \
195 [o_menu addItem: o_mi]; \
196 /* Alt+Shift+Apple */ \
197 o_mi = [[NSMenuItem alloc] initWithTitle: \
198 [[NSString stringWithUTF8String: \
199 OPTION_KEY UPWARDS_WHITE_ARROW PLACE_OF_INTEREST_SIGN \
200 ] stringByAppendingString: string] \
201 action:nil keyEquivalent:@""]; \
202 [o_mi setKeyEquivalentModifierMask: \
203 NSAlternateKeyMask | NSShiftKeyMask | NSCommandKeyMask]; \
204 [o_mi setAlternate: YES]; \
206 (KEY_MODIFIER_ALT | KEY_MODIFIER_SHIFT | KEY_MODIFIER_COMMAND) | ( value )]; \
207 [o_menu addItem: o_mi]; \
209 o_mi = [[NSMenuItem alloc] initWithTitle: \
210 [[NSString stringWithUTF8String: \
211 UPWARDS_WHITE_ARROW \
212 ] stringByAppendingString: string] \
213 action:nil keyEquivalent:@""]; \
214 [o_mi setKeyEquivalentModifierMask: \
216 [o_mi setAlternate: YES]; \
218 KEY_MODIFIER_SHIFT | ( value )]; \
219 [o_menu addItem: o_mi]; \
221 o_mi = [[NSMenuItem alloc] initWithTitle: \
222 [[NSString stringWithUTF8String: \
223 UPWARDS_WHITE_ARROW PLACE_OF_INTEREST_SIGN \
224 ] stringByAppendingString: string] \
225 action:nil keyEquivalent:@""]; \
226 [o_mi setKeyEquivalentModifierMask: \
227 NSShiftKeyMask | NSCommandKeyMask]; \
228 [o_mi setAlternate: YES]; \
230 (KEY_MODIFIER_SHIFT | KEY_MODIFIER_COMMAND) | ( value )]; \
231 [o_menu addItem: o_mi]; \
233 o_mi = [[NSMenuItem alloc] initWithTitle: \
234 [[NSString stringWithUTF8String: \
235 PLACE_OF_INTEREST_SIGN \
236 ] stringByAppendingString: string] \
237 action:nil keyEquivalent:@""]; \
238 [o_mi setKeyEquivalentModifierMask: \
240 [o_mi setAlternate: YES]; \
242 KEY_MODIFIER_COMMAND | ( value )]; \
243 [o_menu addItem: o_mi]; \
247 #define ADD_LABEL( o_label, superFrame, x_offset, my_y_offset, label ) \
249 NSRect s_rc = superFrame; \
250 s_rc.size.height = 17; \
251 s_rc.origin.x = x_offset - 3; \
252 s_rc.origin.y = superFrame.size.height - 17 + my_y_offset; \
253 o_label = [[[NSTextField alloc] initWithFrame: s_rc] retain]; \
254 [o_label setDrawsBackground: NO]; \
255 [o_label setBordered: NO]; \
256 [o_label setEditable: NO]; \
257 [o_label setSelectable: NO]; \
258 [o_label setStringValue: label]; \
259 [o_label setFont:[NSFont systemFontOfSize:0]]; \
260 [o_label sizeToFit]; \
263 #define ADD_TEXTFIELD( o_textfield, superFrame, x_offset, my_y_offset, my_width, tooltip, init_value ) \
265 NSRect s_rc = superFrame; \
266 s_rc.origin.x = x_offset; \
267 s_rc.origin.y = my_y_offset; \
268 s_rc.size.height = 22; \
269 s_rc.size.width = my_width; \
270 o_textfield = [[[NSTextField alloc] initWithFrame: s_rc] retain]; \
271 [o_textfield setFont:[NSFont systemFontOfSize:0]]; \
272 [o_textfield setToolTip: tooltip]; \
273 [o_textfield setStringValue: init_value]; \
276 #define ADD_COMBO( o_combo, superFrame, x_offset, my_y_offset, x2_offset, tooltip ) \
278 NSRect s_rc = superFrame; \
279 s_rc.origin.x = x_offset + 2; \
280 s_rc.origin.y = my_y_offset; \
281 s_rc.size.height = 26; \
282 s_rc.size.width = superFrame.size.width + 2 - s_rc.origin.x - (x2_offset); \
283 o_combo = [[[NSComboBox alloc] initWithFrame: s_rc] retain]; \
284 [o_combo setFont:[NSFont systemFontOfSize:0]]; \
285 [o_combo setToolTip: tooltip]; \
286 [o_combo setUsesDataSource:TRUE]; \
287 [o_combo setDataSource:self]; \
288 [o_combo setNumberOfVisibleItems:10]; \
289 [o_combo setCompletes:YES]; \
292 #define ADD_RIGHT_BUTTON( o_button, superFrame, x_offset, my_y_offset, tooltip, title ) \
294 NSRect s_rc = superFrame; \
295 o_button = [[[NSButton alloc] initWithFrame: s_rc] retain]; \
296 [o_button setButtonType: NSMomentaryPushInButton]; \
297 [o_button setBezelStyle: NSRoundedBezelStyle]; \
298 [o_button setTitle: title]; \
299 [o_button setFont:[NSFont systemFontOfSize:0]]; \
300 [o_button sizeToFit]; \
301 s_rc = [o_button frame]; \
302 s_rc.origin.x = superFrame.size.width - [o_button frame].size.width - 6; \
303 s_rc.origin.y = my_y_offset - 6; \
304 s_rc.size.width += 12; \
305 [o_button setFrame: s_rc]; \
306 [o_button setToolTip: tooltip]; \
307 [o_button setTarget: self]; \
308 [o_button setAction: @selector(openFileDialog:)]; \
311 #define ADD_POPUP( o_popup, superFrame, x_offset, my_y_offset, x2_offset, tooltip ) \
313 NSRect s_rc = superFrame; \
314 s_rc.origin.x = x_offset - 1; \
315 s_rc.origin.y = my_y_offset; \
316 s_rc.size.height = 26; \
317 s_rc.size.width = superFrame.size.width + 2 - s_rc.origin.x - (x2_offset); \
318 o_popup = [[[NSPopUpButton alloc] initWithFrame: s_rc] retain]; \
319 [o_popup setFont:[NSFont systemFontOfSize:0]]; \
320 [o_popup setToolTip: tooltip]; \
323 #define ADD_STEPPER( o_stepper, superFrame, x_offset, my_y_offset, tooltip, lower, higher ) \
325 NSRect s_rc = superFrame; \
326 s_rc.origin.x = x_offset; \
327 s_rc.origin.y = my_y_offset; \
328 s_rc.size.height = 23; \
329 s_rc.size.width = 23; \
330 o_stepper = [[[NSStepper alloc] initWithFrame: s_rc] retain]; \
331 [o_stepper setFont:[NSFont systemFontOfSize:0]]; \
332 [o_stepper setToolTip: tooltip]; \
333 [o_stepper setMaxValue: higher]; \
334 [o_stepper setMinValue: lower]; \
335 [o_stepper setTarget: self]; \
336 [o_stepper setAction: @selector(stepperChanged:)]; \
337 [o_stepper sendActionOn:NSLeftMouseUpMask|NSLeftMouseDownMask|NSLeftMouseDraggedMask]; \
340 #define ADD_SLIDER( o_slider, superFrame, x_offset, my_y_offset, my_width, tooltip, lower, higher ) \
342 NSRect s_rc = superFrame; \
343 s_rc.origin.x = x_offset; \
344 s_rc.origin.y = my_y_offset; \
345 s_rc.size.height = 21; \
346 s_rc.size.width = my_width; \
347 o_slider = [[[NSSlider alloc] initWithFrame: s_rc] retain]; \
348 [o_slider setFont:[NSFont systemFontOfSize:0]]; \
349 [o_slider setToolTip: tooltip]; \
350 [o_slider setMaxValue: higher]; \
351 [o_slider setMinValue: lower]; \
354 #define ADD_CHECKBOX( o_checkbox, superFrame, x_offset, my_y_offset, label, tooltip, init_value, position ) \
356 NSRect s_rc = superFrame; \
357 s_rc.size.height = 18; \
358 s_rc.origin.x = x_offset - 2; \
359 s_rc.origin.y = superFrame.size.height - 18 + my_y_offset; \
360 o_checkbox = [[[NSButton alloc] initWithFrame: s_rc] retain]; \
361 [o_checkbox setFont:[NSFont systemFontOfSize:0]]; \
362 [o_checkbox setButtonType: NSSwitchButton]; \
363 [o_checkbox setImagePosition: position]; \
364 [o_checkbox setIntValue: init_value]; \
365 [o_checkbox setTitle: label]; \
366 [o_checkbox setToolTip: tooltip]; \
367 [o_checkbox sizeToFit]; \
370 #define ADD_CHECKBOX( o_checkbox, superFrame, x_offset, my_y_offset, label, tooltip, init_value, position ) \
372 NSRect s_rc = superFrame; \
373 s_rc.size.height = 18; \
374 s_rc.origin.x = x_offset - 2; \
375 s_rc.origin.y = superFrame.size.height - 18 + my_y_offset; \
376 o_checkbox = [[[NSButton alloc] initWithFrame: s_rc] retain]; \
377 [o_checkbox setFont:[NSFont systemFontOfSize:0]]; \
378 [o_checkbox setButtonType: NSSwitchButton]; \
379 [o_checkbox setImagePosition: position]; \
380 [o_checkbox setIntValue: init_value]; \
381 [o_checkbox setTitle: label]; \
382 [o_checkbox setToolTip: tooltip]; \
383 [o_checkbox sizeToFit]; \
386 @implementation VLCConfigControl
388 - (id)initWithFrame: (NSRect)frame
390 return [self initWithFrame: frame
394 - (id)initWithFrame: (NSRect)frame
395 item: (module_config_t *)_p_item
397 self = [super initWithFrame: frame];
402 psz_name = strdup( p_item->psz_name );
404 i_type = p_item->i_type;
405 b_advanced = p_item->b_advanced;
406 [self setAutoresizingMask:NSViewWidthSizable | NSViewMinYMargin ];
413 if( o_label ) [o_label release];
414 if( psz_name ) free( psz_name );
418 + (int)calcVerticalMargin: (int)i_curItem lastItem: (int)i_lastItem
423 case CONFIG_ITEM_STRING:
426 case CONFIG_ITEM_STRING:
429 case CONFIG_ITEM_STRING_LIST:
432 case CONFIG_ITEM_FILE:
435 case CONFIG_ITEM_MODULE:
438 case CONFIG_ITEM_INTEGER:
441 case CONFIG_ITEM_RANGED_INTEGER:
444 case CONFIG_ITEM_BOOL:
447 case CONFIG_ITEM_KEY_BEFORE_10_3:
450 case CONFIG_ITEM_KEY_AFTER_10_3:
453 case CONFIG_ITEM_MODULE_LIST:
461 case CONFIG_ITEM_STRING_LIST:
464 case CONFIG_ITEM_STRING:
467 case CONFIG_ITEM_STRING_LIST:
470 case CONFIG_ITEM_FILE:
473 case CONFIG_ITEM_MODULE:
476 case CONFIG_ITEM_INTEGER:
479 case CONFIG_ITEM_RANGED_INTEGER:
482 case CONFIG_ITEM_BOOL:
485 case CONFIG_ITEM_KEY_BEFORE_10_3:
488 case CONFIG_ITEM_KEY_AFTER_10_3:
491 case CONFIG_ITEM_MODULE_LIST:
499 case CONFIG_ITEM_FILE:
502 case CONFIG_ITEM_STRING:
505 case CONFIG_ITEM_STRING_LIST:
508 case CONFIG_ITEM_FILE:
511 case CONFIG_ITEM_MODULE:
514 case CONFIG_ITEM_INTEGER:
517 case CONFIG_ITEM_RANGED_INTEGER:
520 case CONFIG_ITEM_BOOL:
523 case CONFIG_ITEM_KEY_BEFORE_10_3:
526 case CONFIG_ITEM_KEY_AFTER_10_3:
529 case CONFIG_ITEM_MODULE_LIST:
537 case CONFIG_ITEM_MODULE:
540 case CONFIG_ITEM_STRING:
543 case CONFIG_ITEM_STRING_LIST:
546 case CONFIG_ITEM_FILE:
549 case CONFIG_ITEM_MODULE:
552 case CONFIG_ITEM_INTEGER:
555 case CONFIG_ITEM_RANGED_INTEGER:
558 case CONFIG_ITEM_BOOL:
561 case CONFIG_ITEM_KEY_BEFORE_10_3:
564 case CONFIG_ITEM_KEY_AFTER_10_3:
567 case CONFIG_ITEM_MODULE_LIST:
575 case CONFIG_ITEM_INTEGER:
578 case CONFIG_ITEM_STRING:
581 case CONFIG_ITEM_STRING_LIST:
584 case CONFIG_ITEM_FILE:
587 case CONFIG_ITEM_MODULE:
590 case CONFIG_ITEM_INTEGER:
593 case CONFIG_ITEM_RANGED_INTEGER:
596 case CONFIG_ITEM_BOOL:
599 case CONFIG_ITEM_KEY_BEFORE_10_3:
602 case CONFIG_ITEM_KEY_AFTER_10_3:
605 case CONFIG_ITEM_MODULE_LIST:
613 case CONFIG_ITEM_RANGED_INTEGER:
616 case CONFIG_ITEM_STRING:
619 case CONFIG_ITEM_STRING_LIST:
622 case CONFIG_ITEM_FILE:
625 case CONFIG_ITEM_MODULE:
628 case CONFIG_ITEM_INTEGER:
631 case CONFIG_ITEM_RANGED_INTEGER:
634 case CONFIG_ITEM_BOOL:
637 case CONFIG_ITEM_KEY_BEFORE_10_3:
640 case CONFIG_ITEM_KEY_AFTER_10_3:
643 case CONFIG_ITEM_MODULE_LIST:
651 case CONFIG_ITEM_BOOL:
654 case CONFIG_ITEM_STRING:
657 case CONFIG_ITEM_STRING_LIST:
660 case CONFIG_ITEM_FILE:
663 case CONFIG_ITEM_MODULE:
666 case CONFIG_ITEM_INTEGER:
669 case CONFIG_ITEM_RANGED_INTEGER:
672 case CONFIG_ITEM_BOOL:
675 case CONFIG_ITEM_KEY_BEFORE_10_3:
678 case CONFIG_ITEM_KEY_AFTER_10_3:
681 case CONFIG_ITEM_MODULE_LIST:
689 case CONFIG_ITEM_KEY_BEFORE_10_3:
692 case CONFIG_ITEM_STRING:
695 case CONFIG_ITEM_STRING_LIST:
698 case CONFIG_ITEM_FILE:
701 case CONFIG_ITEM_MODULE:
704 case CONFIG_ITEM_INTEGER:
707 case CONFIG_ITEM_RANGED_INTEGER:
710 case CONFIG_ITEM_BOOL:
713 case CONFIG_ITEM_KEY_BEFORE_10_3:
716 case CONFIG_ITEM_KEY_AFTER_10_3:
719 case CONFIG_ITEM_MODULE_LIST:
727 case CONFIG_ITEM_KEY_AFTER_10_3:
730 case CONFIG_ITEM_STRING:
733 case CONFIG_ITEM_STRING_LIST:
736 case CONFIG_ITEM_FILE:
739 case CONFIG_ITEM_MODULE:
742 case CONFIG_ITEM_INTEGER:
745 case CONFIG_ITEM_RANGED_INTEGER:
748 case CONFIG_ITEM_BOOL:
751 case CONFIG_ITEM_KEY_BEFORE_10_3:
754 case CONFIG_ITEM_KEY_AFTER_10_3:
757 case CONFIG_ITEM_MODULE_LIST:
765 case CONFIG_ITEM_MODULE_LIST:
768 case CONFIG_ITEM_STRING:
771 case CONFIG_ITEM_STRING_LIST:
774 case CONFIG_ITEM_FILE:
777 case CONFIG_ITEM_MODULE:
780 case CONFIG_ITEM_INTEGER:
783 case CONFIG_ITEM_RANGED_INTEGER:
786 case CONFIG_ITEM_BOOL:
789 case CONFIG_ITEM_KEY_BEFORE_10_3:
792 case CONFIG_ITEM_KEY_AFTER_10_3:
795 case CONFIG_ITEM_MODULE_LIST:
810 + (VLCConfigControl *)newControl: (module_config_t *)_p_item
811 withView: (NSView *)o_parent_view
813 lastItem: (int) i_lastItem
815 VLCConfigControl *p_control = NULL;
816 switch( _p_item->i_type )
818 case CONFIG_ITEM_STRING:
819 if( !_p_item->i_list )
821 p_control = [[StringConfigControl alloc] initWithItem: _p_item
822 withView: o_parent_view
823 withVerticalOffset: i_yPos
824 withLastItem: i_lastItem];
828 p_control = [[StringListConfigControl alloc] initWithItem: _p_item
829 withView: o_parent_view
830 withVerticalOffset: i_yPos
831 withLastItem: i_lastItem];
834 case CONFIG_ITEM_FILE:
835 case CONFIG_ITEM_DIRECTORY:
836 p_control = [[FileConfigControl alloc] initWithItem: _p_item
837 withView: o_parent_view
838 withVerticalOffset: i_yPos
839 withLastItem: i_lastItem];
841 case CONFIG_ITEM_MODULE:
842 case CONFIG_ITEM_MODULE_CAT:
843 p_control = [[ModuleConfigControl alloc] initWithItem: _p_item
844 withView: o_parent_view
845 withVerticalOffset: i_yPos
846 withLastItem: i_lastItem];
848 case CONFIG_ITEM_INTEGER:
849 if( _p_item->i_list )
851 p_control = [[IntegerListConfigControl alloc] initWithItem: _p_item
852 withView: o_parent_view
853 withVerticalOffset: i_yPos
854 withLastItem: i_lastItem];
856 else if( _p_item->i_min != 0 || _p_item->i_max != 0 )
858 p_control = [[RangedIntegerConfigControl alloc] initWithItem: _p_item
859 withView: o_parent_view
860 withVerticalOffset: i_yPos
861 withLastItem: i_lastItem];
865 p_control = [[IntegerConfigControl alloc] initWithItem: _p_item
866 withView: o_parent_view
867 withVerticalOffset: i_yPos
868 withLastItem: i_lastItem];
871 case CONFIG_ITEM_BOOL:
872 p_control = [[BoolConfigControl alloc] initWithItem: _p_item
873 withView: o_parent_view
874 withVerticalOffset: i_yPos
875 withLastItem: i_lastItem];
877 case CONFIG_ITEM_FLOAT:
878 if( _p_item->f_min != 0 || _p_item->f_max != 0 )
880 p_control = [[RangedFloatConfigControl alloc] initWithItem: _p_item
881 withView: o_parent_view
882 withVerticalOffset: i_yPos
883 withLastItem: i_lastItem];
887 p_control = [[FloatConfigControl alloc] initWithItem: _p_item
888 withView: o_parent_view
889 withVerticalOffset: i_yPos
890 withLastItem: i_lastItem];
893 case CONFIG_ITEM_KEY:
894 if( MACOS_VERSION < 3 )
896 p_control = [[KeyConfigControlBefore103 alloc] initWithItem: _p_item
897 withView: o_parent_view
898 withVerticalOffset: i_yPos
899 withLastItem: i_lastItem];
903 p_control = [[KeyConfigControlAfter103 alloc] initWithItem: _p_item
904 withView: o_parent_view
905 withVerticalOffset: i_yPos
906 withLastItem: i_lastItem];
909 case CONFIG_ITEM_MODULE_LIST:
910 case CONFIG_ITEM_MODULE_LIST_CAT:
911 p_control = [[ModuleListConfigControl alloc] initWithItem: _p_item
912 withView: o_parent_view
913 withVerticalOffset: i_yPos
914 withLastItem: i_lastItem];
922 - (NSString *)getName
924 return [[VLCMain sharedInstance] localizedString: psz_name];
947 - (char *)stringValue
955 switch( p_item->i_type )
957 case CONFIG_ITEM_STRING:
958 case CONFIG_ITEM_FILE:
959 case CONFIG_ITEM_DIRECTORY:
960 case CONFIG_ITEM_MODULE:
961 case CONFIG_ITEM_MODULE_LIST:
962 case CONFIG_ITEM_MODULE_LIST_CAT:
963 fprintf( stderr, "Applying %s to %s\n" , [self stringValue], psz_name );
964 config_PutPsz( VLCIntf, psz_name, [self stringValue] );
966 case CONFIG_ITEM_KEY:
967 /* So you don't need to restart to have the changes take effect */
968 fprintf( stderr, "Applying %d to %s\n" , [self intValue], psz_name );
969 val.i_int = [self intValue];
970 var_Set( VLCIntf->p_vlc, psz_name, val );
971 case CONFIG_ITEM_INTEGER:
972 case CONFIG_ITEM_BOOL:
973 fprintf( stderr, "Applying %d to %s\n" , [self intValue], psz_name );
974 config_PutInt( VLCIntf, psz_name, [self intValue] );
976 case CONFIG_ITEM_FLOAT:
977 fprintf( stderr, "Applying %f to %s\n" , [self floatValue], psz_name );
978 config_PutFloat( VLCIntf, psz_name, [self floatValue] );
986 @implementation StringConfigControl
988 - (id) initWithItem: (module_config_t *)_p_item
989 withView: (NSView *)o_parent_view
990 withVerticalOffset: (int)i_yPos
991 withLastItem: (int)i_lastItem
993 NSRect mainFrame = [o_parent_view frame];
994 NSString *o_labelString, *o_textfieldString, *o_textfieldTooltip;
995 mainFrame.size.height = 22;
996 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN;
997 mainFrame.origin.x = LEFTMARGIN;
998 mainFrame.origin.y = i_yPos;
1000 if( [super initWithFrame: mainFrame item: _p_item] != nil )
1003 if( p_item->psz_text )
1004 o_labelString = [[VLCMain sharedInstance] localizedString: p_item->psz_text];
1006 o_labelString = [NSString stringWithString:@""];
1007 ADD_LABEL( o_label, mainFrame, 0, -3, o_labelString )
1008 [o_label setAutoresizingMask:NSViewNotSizable ];
1009 [self addSubview: o_label];
1011 /* build the textfield */
1012 o_textfieldTooltip = [[VLCMain sharedInstance] wrapString:
1013 [[VLCMain sharedInstance] localizedString: p_item->psz_longtext ] toWidth: PREFS_WRAP];
1014 if( p_item->psz_value )
1015 o_textfieldString = [[VLCMain sharedInstance] localizedString: p_item->psz_value];
1017 o_textfieldString = [NSString stringWithString: @""];
1018 ADD_TEXTFIELD( o_textfield, mainFrame, [o_label frame].size.width + 2,
1019 0, mainFrame.size.width - [o_label frame].size.width - 2,
1020 o_textfieldTooltip, o_textfieldString )
1021 [o_textfield setAutoresizingMask:NSViewWidthSizable ];
1022 [self addSubview: o_textfield];
1030 [o_textfield release];
1034 - (char *)stringValue
1036 return strdup( [[VLCMain sharedInstance] delocalizeString:[o_textfield stringValue]] );
1041 @implementation StringListConfigControl
1043 - (id) initWithItem: (module_config_t *)_p_item
1044 withView: (NSView *)o_parent_view
1045 withVerticalOffset: (int)i_yPos
1046 withLastItem: (int)i_lastItem
1048 NSRect mainFrame = [o_parent_view frame];
1049 NSString *o_labelString, *o_textfieldTooltip;
1050 mainFrame.size.height = 22;
1051 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN + 1;
1052 mainFrame.origin.x = LEFTMARGIN;
1053 mainFrame.origin.y = i_yPos;
1055 if( [super initWithFrame: mainFrame item: _p_item] != nil )
1059 if( p_item->psz_text )
1060 o_labelString = [[VLCMain sharedInstance] localizedString: p_item->psz_text];
1062 o_labelString = [NSString stringWithString:@""];
1063 ADD_LABEL( o_label, mainFrame, 0, -3, o_labelString )
1064 [o_label setAutoresizingMask:NSViewNotSizable ];
1065 [self addSubview: o_label];
1067 /* build the textfield */
1068 o_textfieldTooltip = [[VLCMain sharedInstance] wrapString:
1069 [[VLCMain sharedInstance] localizedString: p_item->psz_longtext ] toWidth: PREFS_WRAP];
1070 ADD_COMBO( o_combo, mainFrame, [o_label frame].size.width,
1071 -2, 0, o_textfieldTooltip )
1072 [o_combo setAutoresizingMask:NSViewWidthSizable ];
1073 for( i_index = 0; i_index < p_item->i_list; i_index++ )
1075 if( p_item->psz_value && !strcmp( p_item->psz_value, p_item->ppsz_list[i_index] ) )
1077 [o_combo selectItemAtIndex: i_index];
1080 [self addSubview: o_combo];
1091 - (char *)stringValue
1093 if( [o_combo indexOfSelectedItem] >= 0 )
1094 return strdup( p_item->ppsz_list[[o_combo indexOfSelectedItem]] );
1096 return strdup( [[VLCMain sharedInstance] delocalizeString: [o_combo stringValue]] );
1101 @implementation StringListConfigControl (NSComboBoxDataSource)
1103 - (int)numberOfItemsInComboBox:(NSComboBox *)aComboBox
1105 return p_item->i_list;
1108 - (id)comboBox:(NSComboBox *)aComboBox objectValueForItemAtIndex:(int)i_index
1110 if( p_item->ppsz_list_text && p_item->ppsz_list_text[i_index] )
1112 return [[VLCMain sharedInstance] localizedString: p_item->ppsz_list_text[i_index]];
1113 } else return [[VLCMain sharedInstance] localizedString: p_item->ppsz_list[i_index]];
1118 @implementation FileConfigControl
1120 - (id) initWithItem: (module_config_t *)_p_item
1121 withView: (NSView *)o_parent_view
1122 withVerticalOffset: (int)i_yPos
1123 withLastItem: (int)i_lastItem
1125 NSRect mainFrame = [o_parent_view frame];
1126 NSString *o_labelString, *o_buttonTooltip, *o_textfieldString, *o_textfieldTooltip;
1127 mainFrame.size.height = 46;
1128 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN;
1129 mainFrame.origin.x = LEFTMARGIN;
1130 mainFrame.origin.y = i_yPos;
1132 if( [super initWithFrame: mainFrame item: _p_item] != nil )
1134 /* is it a directory */
1135 b_directory = ( [self getType] == CONFIG_ITEM_DIRECTORY ) ? YES : NO;
1138 if( p_item->psz_text )
1139 o_labelString = [[VLCMain sharedInstance] localizedString: p_item->psz_text];
1141 o_labelString = [NSString stringWithString:@""];
1142 ADD_LABEL( o_label, mainFrame, 0, 3, o_labelString )
1143 [o_label setAutoresizingMask:NSViewNotSizable ];
1144 [self addSubview: o_label];
1146 /* build the button */
1147 o_buttonTooltip = [[VLCMain sharedInstance] wrapString:
1148 [[VLCMain sharedInstance] localizedString: p_item->psz_longtext ] toWidth: PREFS_WRAP];
1149 ADD_RIGHT_BUTTON( o_button, mainFrame, 0, 0, o_buttonTooltip, _NS("Browse...") )
1150 [o_button setAutoresizingMask:NSViewMinXMargin ];
1151 [self addSubview: o_button];
1153 /* build the textfield */
1154 o_textfieldTooltip = [[VLCMain sharedInstance] wrapString:
1155 [[VLCMain sharedInstance] localizedString: p_item->psz_longtext ] toWidth: PREFS_WRAP];
1156 if( p_item->psz_value )
1157 o_textfieldString = [[VLCMain sharedInstance] localizedString: p_item->psz_value];
1159 o_textfieldString = [NSString stringWithString: @""];
1160 ADD_TEXTFIELD( o_textfield, mainFrame, 12,
1161 2, mainFrame.size.width - 8 - [o_button frame].size.width,
1162 o_textfieldTooltip, o_textfieldString )
1163 [o_textfield setAutoresizingMask:NSViewWidthSizable ];
1164 [self addSubview: o_textfield];
1171 [o_textfield release];
1176 - (IBAction)openFileDialog: (id)sender
1178 NSOpenPanel *o_open_panel = [NSOpenPanel openPanel];
1180 [o_open_panel setTitle: (b_directory)?_NS("Select a directory"):_NS("Select a file")];
1181 [o_open_panel setPrompt: _NS("Select")];
1182 [o_open_panel setAllowsMultipleSelection: NO];
1183 [o_open_panel setCanChooseFiles: !b_directory];
1184 [o_open_panel setCanChooseDirectories: b_directory];
1185 [o_open_panel beginSheetForDirectory:nil
1188 modalForWindow:[sender window]
1190 didEndSelector: @selector(pathChosenInPanel:
1196 - (void)pathChosenInPanel:(NSOpenPanel *)o_sheet withReturn:(int)i_return_code contextInfo:(void *)o_context_info
1198 if( i_return_code == NSOKButton )
1200 NSString *o_path = [[o_sheet filenames] objectAtIndex: 0];
1201 [o_textfield setStringValue: o_path];
1205 - (char *)stringValue
1207 if( [[o_textfield stringValue] length] != 0)
1208 return strdup( [[o_textfield stringValue] fileSystemRepresentation] );
1215 @implementation ModuleConfigControl
1217 - (id) initWithItem: (module_config_t *)_p_item
1218 withView: (NSView *)o_parent_view
1219 withVerticalOffset: (int)i_yPos
1220 withLastItem: (int)i_lastItem
1222 NSRect mainFrame = [o_parent_view frame];
1223 NSString *o_labelString, *o_popupTooltip;
1224 mainFrame.size.height = 22;
1225 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN + 1;
1226 mainFrame.origin.x = LEFTMARGIN;
1227 mainFrame.origin.y = i_yPos;
1229 if( [super initWithFrame: mainFrame item: _p_item] != nil )
1235 if( p_item->psz_text )
1236 o_labelString = [[VLCMain sharedInstance] localizedString: p_item->psz_text];
1238 o_labelString = [NSString stringWithString:@""];
1239 ADD_LABEL( o_label, mainFrame, 0, -1, o_labelString )
1240 [o_label setAutoresizingMask:NSViewNotSizable ];
1241 [self addSubview: o_label];
1243 /* build the popup */
1244 o_popupTooltip = [[VLCMain sharedInstance] wrapString:
1245 [[VLCMain sharedInstance] localizedString: p_item->psz_longtext ] toWidth: PREFS_WRAP];
1246 ADD_POPUP( o_popup, mainFrame, [o_label frame].size.width,
1247 -2, 0, o_popupTooltip )
1248 [o_popup setAutoresizingMask:NSViewWidthSizable ];
1249 [o_popup addItemWithTitle: _NS("Default")];
1250 [[o_popup lastItem] setTag: -1];
1251 [o_popup selectItem: [o_popup lastItem]];
1253 /* build a list of available modules */
1254 p_list = vlc_list_find( VLCIntf, VLC_OBJECT_MODULE, FIND_ANYWHERE );
1255 for( i_index = 0; i_index < p_list->i_count; i_index++ )
1257 p_parser = (module_t *)p_list->p_values[i_index].p_object ;
1258 if( p_item->i_type == CONFIG_ITEM_MODULE )
1260 if( !strcmp( p_parser->psz_capability,
1261 p_item->psz_type ) )
1263 NSString *o_description = [[VLCMain sharedInstance]
1264 localizedString: p_parser->psz_longname];
1265 [o_popup addItemWithTitle: o_description];
1267 if( p_item->psz_value &&
1268 !strcmp( p_item->psz_value, p_parser->psz_object_name ) )
1270 [o_popup selectItem:[o_popup lastItem]];
1276 module_config_t *p_config;
1277 if( !strcmp( p_parser->psz_object_name, "main" ) )
1280 p_config = p_parser->p_config;
1283 /* Hack: required subcategory is stored in i_min */
1284 if( p_config->i_type == CONFIG_SUBCATEGORY &&
1285 p_config->i_value == p_item->i_min )
1287 NSString *o_description = [[VLCMain sharedInstance]
1288 localizedString: p_parser->psz_longname];
1289 [o_popup addItemWithTitle: o_description];
1291 if( p_item->psz_value && !strcmp(p_item->psz_value,
1292 p_parser->psz_object_name) )
1293 [o_popup selectItem:[o_popup lastItem]];
1295 } while( p_config->i_type != CONFIG_HINT_END && p_config++ );
1298 vlc_list_release( p_list );
1299 [self addSubview: o_popup];
1310 - (char *)stringValue
1312 NSString *newval = [o_popup titleOfSelectedItem];
1313 char *returnval = NULL;
1318 p_list = vlc_list_find( VLCIntf, VLC_OBJECT_MODULE, FIND_ANYWHERE );
1319 for( i_index = 0; i_index < p_list->i_count; i_index++ )
1321 p_parser = (module_t *)p_list->p_values[i_index].p_object ;
1322 if( p_item->i_type == CONFIG_ITEM_MODULE )
1324 if( !strcmp( p_parser->psz_capability,
1325 p_item->psz_type ) )
1327 NSString *o_description = [[VLCMain sharedInstance]
1328 localizedString: p_parser->psz_longname];
1329 if( [newval isEqualToString: o_description] )
1331 returnval = strdup(p_parser->psz_object_name);
1338 module_config_t *p_config;
1339 if( !strcmp( p_parser->psz_object_name, "main" ) )
1342 p_config = p_parser->p_config;
1345 /* Hack: required subcategory is stored in i_min */
1346 if( p_config->i_type == CONFIG_SUBCATEGORY &&
1347 p_config->i_value == p_item->i_min )
1349 NSString *o_description = [[VLCMain sharedInstance]
1350 localizedString: p_parser->psz_longname];
1351 if( [newval isEqualToString: o_description] )
1353 returnval = strdup(p_parser->psz_object_name);
1357 } while( p_config->i_type != CONFIG_HINT_END && p_config++ );
1360 vlc_list_release( p_list );
1366 @implementation IntegerConfigControl
1368 - (id) initWithItem: (module_config_t *)_p_item
1369 withView: (NSView *)o_parent_view
1370 withVerticalOffset: (int)i_yPos
1371 withLastItem: (int)i_lastItem
1373 NSRect mainFrame = [o_parent_view frame];
1374 NSString *o_labelString, *o_tooltip, *o_textfieldString;
1375 mainFrame.size.height = 23;
1376 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN + 1;
1377 mainFrame.origin.x = LEFTMARGIN;
1378 mainFrame.origin.y = i_yPos;
1380 if( [super initWithFrame: mainFrame item: _p_item] != nil )
1382 o_tooltip = [[VLCMain sharedInstance] wrapString:
1383 [[VLCMain sharedInstance] localizedString: p_item->psz_longtext ] toWidth: PREFS_WRAP];
1386 if( p_item->psz_text )
1387 o_labelString = [[VLCMain sharedInstance] localizedString: p_item->psz_text];
1389 o_labelString = [NSString stringWithString:@""];
1390 ADD_LABEL( o_label, mainFrame, 0, -2, o_labelString )
1391 [o_label setAutoresizingMask:NSViewNotSizable ];
1392 [self addSubview: o_label];
1394 /* build the stepper */
1395 ADD_STEPPER( o_stepper, mainFrame, mainFrame.size.width - 19,
1396 0, o_tooltip, -1600, 1600)
1397 [o_stepper setIntValue: p_item->i_value];
1398 [o_stepper setAutoresizingMask:NSViewMinXMargin ];
1399 [self addSubview: o_stepper];
1401 /* build the textfield */
1402 if( p_item->psz_value )
1403 o_textfieldString = [[VLCMain sharedInstance] localizedString: p_item->psz_value];
1405 o_textfieldString = [NSString stringWithString: @""];
1406 ADD_TEXTFIELD( o_textfield, mainFrame, mainFrame.size.width - 19 - 52,
1407 1, 49, o_tooltip, @"" )
1408 [o_textfield setIntValue: p_item->i_value];
1409 [o_textfield setDelegate: self];
1410 [[NSNotificationCenter defaultCenter] addObserver: self
1411 selector: @selector(textfieldChanged:)
1412 name: NSControlTextDidChangeNotification
1413 object: o_textfield];
1414 [o_textfield setAutoresizingMask:NSViewMinXMargin ];
1415 [self addSubview: o_textfield];
1422 [o_stepper release];
1423 [o_textfield release];
1427 - (IBAction)stepperChanged:(id)sender
1429 [o_textfield setIntValue: [o_stepper intValue]];
1432 - (void)textfieldChanged:(NSNotification *)o_notification
1434 [o_stepper setIntValue: [o_textfield intValue]];
1439 return [o_textfield intValue];
1444 @implementation IntegerListConfigControl
1446 - (id) initWithItem: (module_config_t *)_p_item
1447 withView: (NSView *)o_parent_view
1448 withVerticalOffset: (int)i_yPos
1449 withLastItem: (int)i_lastItem
1451 NSRect mainFrame = [o_parent_view frame];
1452 NSString *o_labelString, *o_textfieldTooltip;
1453 mainFrame.size.height = 22;
1454 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN + 1;
1455 mainFrame.origin.x = LEFTMARGIN;
1456 mainFrame.origin.y = i_yPos;
1458 if( [super initWithFrame: mainFrame item: _p_item] != nil )
1462 if( p_item->psz_text )
1463 o_labelString = [[VLCMain sharedInstance] localizedString: p_item->psz_text];
1465 o_labelString = [NSString stringWithString:@""];
1466 ADD_LABEL( o_label, mainFrame, 0, -3, o_labelString )
1467 [o_label setAutoresizingMask:NSViewNotSizable ];
1468 [self addSubview: o_label];
1470 /* build the textfield */
1471 o_textfieldTooltip = [[VLCMain sharedInstance] wrapString:
1472 [[VLCMain sharedInstance] localizedString: p_item->psz_longtext ] toWidth: PREFS_WRAP];
1473 ADD_COMBO( o_combo, mainFrame, [o_label frame].size.width,
1474 -2, 0, o_textfieldTooltip )
1475 [o_combo setAutoresizingMask:NSViewWidthSizable ];
1476 for( i_index = 0; i_index < p_item->i_list; i_index++ )
1478 if( p_item->i_value == p_item->pi_list[i_index] )
1480 [o_combo selectItemAtIndex: i_index];
1483 [self addSubview: o_combo];
1496 if( [o_combo indexOfSelectedItem] >= 0 )
1497 return p_item->pi_list[[o_combo indexOfSelectedItem]];
1499 return [o_combo intValue];
1504 @implementation IntegerListConfigControl (NSComboBoxDataSource)
1506 - (int)numberOfItemsInComboBox:(NSComboBox *)aComboBox
1508 return p_item->i_list;
1511 - (id)comboBox:(NSComboBox *)aComboBox objectValueForItemAtIndex:(int)i_index
1513 if( p_item->ppsz_list_text && p_item->ppsz_list_text[i_index] )
1515 return [[VLCMain sharedInstance] localizedString: p_item->ppsz_list_text[i_index]];
1516 } else return [NSString stringWithFormat: @"%i", p_item->pi_list[i_index]];
1521 @implementation RangedIntegerConfigControl
1523 - (id) initWithItem: (module_config_t *)_p_item
1524 withView: (NSView *)o_parent_view
1525 withVerticalOffset: (int)i_yPos
1526 withLastItem: (int)i_lastItem
1528 NSRect mainFrame = [o_parent_view frame];
1529 NSString *o_labelString, *o_tooltip;
1530 mainFrame.size.height = 50;
1531 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN;
1532 mainFrame.origin.x = LEFTMARGIN;
1533 mainFrame.origin.y = i_yPos;
1535 if( [super initWithFrame: mainFrame item: _p_item] != nil )
1538 if( p_item->psz_text )
1539 o_labelString = [[VLCMain sharedInstance] localizedString: p_item->psz_text];
1541 o_labelString = [NSString stringWithString:@""];
1542 ADD_LABEL( o_label, mainFrame, 0, -3, o_labelString )
1543 [o_label setAutoresizingMask:NSViewNotSizable ];
1544 [self addSubview: o_label];
1546 /* build the textfield */
1547 o_tooltip = [[VLCMain sharedInstance] wrapString:
1548 [[VLCMain sharedInstance] localizedString: p_item->psz_longtext ] toWidth: PREFS_WRAP];
1549 ADD_TEXTFIELD( o_textfield, mainFrame, [o_label frame].size.width + 2,
1550 28, 49, o_tooltip, @"" )
1551 [o_textfield setIntValue: p_item->i_value];
1552 [o_textfield setAutoresizingMask:NSViewMaxXMargin ];
1553 [o_textfield setDelegate: self];
1554 [[NSNotificationCenter defaultCenter] addObserver: self
1555 selector: @selector(textfieldChanged:)
1556 name: NSControlTextDidChangeNotification
1557 object: o_textfield];
1558 [self addSubview: o_textfield];
1560 /* build the mintextfield */
1561 ADD_LABEL( o_textfield_min, mainFrame, 12, -30, @"-8888" )
1562 [o_textfield_min setIntValue: p_item->i_min];
1563 [o_textfield_min setAutoresizingMask:NSViewMaxXMargin ];
1564 [self addSubview: o_textfield_min];
1566 /* build the maxtextfield */
1567 ADD_LABEL( o_textfield_max, mainFrame, mainFrame.size.width - 31, -30, @"8888" )
1568 [o_textfield_max setIntValue: p_item->i_max];
1569 [o_textfield_max setAutoresizingMask:NSViewMinXMargin ];
1570 [self addSubview: o_textfield_max];
1572 /* build the slider */
1573 ADD_SLIDER( o_slider, mainFrame, [o_textfield_min frame].origin.x + [o_textfield_min frame].size.width + 6,
1574 -1, mainFrame.size.width - [o_textfield_max frame].size.width - [o_textfield_max frame].size.width - 14
1575 - [o_textfield_min frame].origin.x, o_tooltip, p_item->i_min, p_item->i_max )
1576 [o_slider setIntValue: p_item->i_value];
1577 [o_slider setAutoresizingMask:NSViewWidthSizable ];
1578 [o_slider setTarget: self];
1579 [o_slider setAction: @selector(sliderChanged:)];
1580 [o_slider sendActionOn:NSLeftMouseUpMask|NSLeftMouseDownMask|NSLeftMouseDraggedMask];
1581 [self addSubview: o_slider];
1589 [o_textfield release];
1590 [o_textfield_min release];
1591 [o_textfield_max release];
1596 - (IBAction)sliderChanged:(id)sender
1598 [o_textfield setIntValue: [o_slider intValue]];
1601 - (void)textfieldChanged:(NSNotification *)o_notification
1603 [o_slider setIntValue: [o_textfield intValue]];
1608 return [o_slider intValue];
1613 @implementation FloatConfigControl
1615 - (id) initWithItem: (module_config_t *)_p_item
1616 withView: (NSView *)o_parent_view
1617 withVerticalOffset: (int)i_yPos
1618 withLastItem: (int)i_lastItem
1620 NSRect mainFrame = [o_parent_view frame];
1621 NSString *o_labelString, *o_tooltip, *o_textfieldString;
1622 mainFrame.size.height = 23;
1623 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN + 1;
1624 mainFrame.origin.x = LEFTMARGIN;
1625 mainFrame.origin.y = i_yPos;
1627 if( [super initWithFrame: mainFrame item: _p_item] != nil )
1629 o_tooltip = [[VLCMain sharedInstance] wrapString:
1630 [[VLCMain sharedInstance] localizedString: p_item->psz_longtext ] toWidth: PREFS_WRAP];
1633 if( p_item->psz_text )
1634 o_labelString = [[VLCMain sharedInstance] localizedString: p_item->psz_text];
1636 o_labelString = [NSString stringWithString:@""];
1637 ADD_LABEL( o_label, mainFrame, 0, -2, o_labelString )
1638 [o_label setAutoresizingMask:NSViewNotSizable ];
1639 [self addSubview: o_label];
1641 /* build the stepper */
1642 ADD_STEPPER( o_stepper, mainFrame, mainFrame.size.width - 19,
1643 0, o_tooltip, -1600, 1600)
1644 [o_stepper setFloatValue: p_item->f_value];
1645 [o_stepper setAutoresizingMask:NSViewMinXMargin ];
1646 [self addSubview: o_stepper];
1648 /* build the textfield */
1649 if( p_item->psz_value )
1650 o_textfieldString = [[VLCMain sharedInstance] localizedString: p_item->psz_value];
1652 o_textfieldString = [NSString stringWithString: @""];
1653 ADD_TEXTFIELD( o_textfield, mainFrame, mainFrame.size.width - 19 - 52,
1654 1, 49, o_tooltip, @"" )
1655 [o_textfield setFloatValue: p_item->f_value];
1656 [o_textfield setDelegate: self];
1657 [[NSNotificationCenter defaultCenter] addObserver: self
1658 selector: @selector(textfieldChanged:)
1659 name: NSControlTextDidChangeNotification
1660 object: o_textfield];
1661 [o_textfield setAutoresizingMask:NSViewMinXMargin ];
1662 [self addSubview: o_textfield];
1669 [o_stepper release];
1670 [o_textfield release];
1674 - (IBAction)stepperChanged:(id)sender
1676 [o_textfield setFloatValue: [o_stepper floatValue]];
1679 - (void)textfieldChanged:(NSNotification *)o_notification
1681 [o_stepper setFloatValue: [o_textfield floatValue]];
1686 return [o_stepper floatValue];
1691 @implementation RangedFloatConfigControl
1693 - (id) initWithItem: (module_config_t *)_p_item
1694 withView: (NSView *)o_parent_view
1695 withVerticalOffset: (int)i_yPos
1696 withLastItem: (int)i_lastItem
1698 NSRect mainFrame = [o_parent_view frame];
1699 NSString *o_labelString, *o_tooltip;
1700 mainFrame.size.height = 50;
1701 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN;
1702 mainFrame.origin.x = LEFTMARGIN;
1703 mainFrame.origin.y = i_yPos;
1705 if( [super initWithFrame: mainFrame item: _p_item] != nil )
1708 if( p_item->psz_text )
1709 o_labelString = [[VLCMain sharedInstance] localizedString: p_item->psz_text];
1711 o_labelString = [NSString stringWithString:@""];
1712 ADD_LABEL( o_label, mainFrame, 0, -3, o_labelString )
1713 [o_label setAutoresizingMask:NSViewNotSizable ];
1714 [self addSubview: o_label];
1716 /* build the textfield */
1717 o_tooltip = [[VLCMain sharedInstance] wrapString:
1718 [[VLCMain sharedInstance] localizedString: p_item->psz_longtext ] toWidth: PREFS_WRAP];
1719 ADD_TEXTFIELD( o_textfield, mainFrame, [o_label frame].size.width + 2,
1720 28, 49, o_tooltip, @"" )
1721 [o_textfield setFloatValue: p_item->f_value];
1722 [o_textfield setAutoresizingMask:NSViewMaxXMargin ];
1723 [o_textfield setDelegate: self];
1724 [[NSNotificationCenter defaultCenter] addObserver: self
1725 selector: @selector(textfieldChanged:)
1726 name: NSControlTextDidChangeNotification
1727 object: o_textfield];
1728 [self addSubview: o_textfield];
1730 /* build the mintextfield */
1731 ADD_LABEL( o_textfield_min, mainFrame, 12, -30, @"-8888" )
1732 [o_textfield_min setFloatValue: p_item->f_min];
1733 [o_textfield_min setAutoresizingMask:NSViewMaxXMargin ];
1734 [self addSubview: o_textfield_min];
1736 /* build the maxtextfield */
1737 ADD_LABEL( o_textfield_max, mainFrame, mainFrame.size.width - 31, -30, @"8888" )
1738 [o_textfield_max setFloatValue: p_item->f_max];
1739 [o_textfield_max setAutoresizingMask:NSViewMinXMargin ];
1740 [self addSubview: o_textfield_max];
1742 /* build the slider */
1743 ADD_SLIDER( o_slider, mainFrame, [o_textfield_min frame].origin.x + [o_textfield_min frame].size.width + 6,
1744 -1, mainFrame.size.width - [o_textfield_max frame].size.width - [o_textfield_max frame].size.width - 14
1745 - [o_textfield_min frame].origin.x, o_tooltip, p_item->f_min, p_item->f_max )
1746 [o_slider setFloatValue: p_item->f_value];
1747 [o_slider setAutoresizingMask:NSViewWidthSizable ];
1748 [o_slider setTarget: self];
1749 [o_slider setAction: @selector(sliderChanged:)];
1750 [o_slider sendActionOn:NSLeftMouseUpMask|NSLeftMouseDownMask|NSLeftMouseDraggedMask];
1751 [self addSubview: o_slider];
1759 [o_textfield release];
1760 [o_textfield_min release];
1761 [o_textfield_max release];
1766 - (IBAction)sliderChanged:(id)sender
1768 [o_textfield setFloatValue: [o_slider floatValue]];
1771 - (void)textfieldChanged:(NSNotification *)o_notification
1773 [o_slider setFloatValue: [o_textfield floatValue]];
1778 return [o_slider floatValue];
1783 @implementation BoolConfigControl
1785 - (id) initWithItem: (module_config_t *)_p_item
1786 withView: (NSView *)o_parent_view
1787 withVerticalOffset: (int)i_yPos
1788 withLastItem: (int)i_lastItem
1790 NSRect mainFrame = [o_parent_view frame];
1791 NSString *o_labelString, *o_tooltip;
1792 mainFrame.size.height = 17;
1793 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN;
1794 mainFrame.origin.x = LEFTMARGIN;
1795 mainFrame.origin.y = i_yPos;
1797 if( [super initWithFrame: mainFrame item: _p_item] != nil )
1799 /* add the checkbox */
1800 if( p_item->psz_text )
1801 o_labelString = [[VLCMain sharedInstance] localizedString: p_item->psz_text];
1803 o_labelString = [NSString stringWithString:@""];
1804 o_tooltip = [[VLCMain sharedInstance] wrapString:
1805 [[VLCMain sharedInstance] localizedString: p_item->psz_longtext ] toWidth: PREFS_WRAP];
1806 ADD_CHECKBOX( o_checkbox, mainFrame, 0, 0, o_labelString, o_tooltip, p_item->i_value, NSImageRight)
1807 [o_checkbox setAutoresizingMask:NSViewNotSizable ];
1808 [self addSubview: o_checkbox];
1815 [o_checkbox release];
1821 return [o_checkbox intValue];
1826 @implementation KeyConfigControlBefore103
1828 - (id) initWithItem: (module_config_t *)_p_item
1829 withView: (NSView *)o_parent_view
1830 withVerticalOffset: (int)i_yPos
1831 withLastItem: (int)i_lastItem
1833 NSRect mainFrame = [o_parent_view frame];
1834 NSString *o_labelString, *o_tooltip;
1835 mainFrame.size.height = 37;
1836 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN + 1;
1837 mainFrame.origin.x = LEFTMARGIN;
1838 mainFrame.origin.y = i_yPos;
1840 if( [super initWithFrame: mainFrame item: _p_item] != nil )
1843 if( p_item->psz_text )
1844 o_labelString = [[VLCMain sharedInstance] localizedString: p_item->psz_text];
1846 o_labelString = [NSString stringWithString:@""];
1847 ADD_LABEL( o_label, mainFrame, 0, -10, o_labelString )
1848 [o_label setAutoresizingMask:NSViewNotSizable ];
1849 [self addSubview: o_label];
1851 /* add the checkboxes */
1852 o_tooltip = [[VLCMain sharedInstance] wrapString:
1853 [[VLCMain sharedInstance] localizedString: p_item->psz_longtext ] toWidth: PREFS_WRAP];
1854 ADD_CHECKBOX( o_cmd_checkbox, mainFrame,
1855 [o_label frame].size.width + 2, 0,
1856 [NSString stringWithUTF8String:PLACE_OF_INTEREST_SIGN],
1857 o_tooltip, ((((unsigned int)p_item->i_value) & KEY_MODIFIER_COMMAND)?YES:NO), NSImageLeft )
1858 [o_cmd_checkbox setState: p_item->i_value & KEY_MODIFIER_COMMAND];
1859 ADD_CHECKBOX( o_ctrl_checkbox, mainFrame,
1860 [o_cmd_checkbox frame].size.width + [o_cmd_checkbox frame].origin.x + 6, 0,
1861 [NSString stringWithUTF8String:UP_ARROWHEAD],
1862 o_tooltip, ((((unsigned int)p_item->i_value) & KEY_MODIFIER_CTRL)?YES:NO), NSImageLeft )
1863 [o_ctrl_checkbox setState: p_item->i_value & KEY_MODIFIER_CTRL];
1864 ADD_CHECKBOX( o_alt_checkbox, mainFrame,
1865 [o_label frame].size.width + 2, -2 - [o_cmd_checkbox frame].size.height,
1866 [NSString stringWithUTF8String:OPTION_KEY],
1867 o_tooltip, ((((unsigned int)p_item->i_value) & KEY_MODIFIER_ALT)?YES:NO), NSImageLeft )
1868 [o_alt_checkbox setState: p_item->i_value & KEY_MODIFIER_ALT];
1869 ADD_CHECKBOX( o_shift_checkbox, mainFrame,
1870 [o_cmd_checkbox frame].size.width + [o_cmd_checkbox frame].origin.x + 6,
1871 -2 - [o_cmd_checkbox frame].size.height,
1872 [NSString stringWithUTF8String:UPWARDS_WHITE_ARROW],
1873 o_tooltip, ((((unsigned int)p_item->i_value) & KEY_MODIFIER_SHIFT)?YES:NO), NSImageLeft )
1874 [o_shift_checkbox setState: p_item->i_value & KEY_MODIFIER_SHIFT];
1875 [self addSubview: o_cmd_checkbox];
1876 [self addSubview: o_ctrl_checkbox];
1877 [self addSubview: o_alt_checkbox];
1878 [self addSubview: o_shift_checkbox];
1880 /* build the popup */
1881 ADD_POPUP( o_popup, mainFrame, [o_shift_checkbox frame].origin.x + [o_shift_checkbox frame].size.width + 4,
1883 [o_popup setAutoresizingMask:NSViewWidthSizable ];
1885 if( o_keys_menu == nil )
1888 o_keys_menu = [[NSMenu alloc] initWithTitle: @"Keys Menu"];
1889 for ( i = 0; i < sizeof(vlc_keys) / sizeof(key_descriptor_t); i++)
1890 if( vlc_keys[i].psz_key_string && *vlc_keys[i].psz_key_string )
1891 POPULATE_A_KEY( o_keys_menu, [NSString stringWithCString:vlc_keys[i].psz_key_string]
1892 , vlc_keys[i].i_key_code)
1894 [o_popup setMenu:[o_keys_menu copyWithZone:nil]];
1895 [o_popup selectItemWithTitle: [[VLCMain sharedInstance] localizedString:KeyToString(( ((unsigned int)p_item->i_value) & ~KEY_MODIFIER ))]];
1896 [self addSubview: o_popup];
1904 [o_cmd_checkbox release];
1905 [o_ctrl_checkbox release];
1906 [o_alt_checkbox release];
1907 [o_shift_checkbox release];
1914 unsigned int i_new_key = 0;
1916 i_new_key |= ([o_cmd_checkbox state] == NSOnState) ? KEY_MODIFIER_COMMAND : 0;
1917 i_new_key |= ([o_ctrl_checkbox state] == NSOnState) ? KEY_MODIFIER_CTRL : 0;
1918 i_new_key |= ([o_alt_checkbox state] == NSOnState) ? KEY_MODIFIER_ALT : 0;
1919 i_new_key |= ([o_shift_checkbox state] == NSOnState) ? KEY_MODIFIER_SHIFT : 0;
1921 i_new_key |= StringToKey([[[o_popup selectedItem] title] cString]);
1927 @implementation KeyConfigControlAfter103
1929 - (id) initWithItem: (module_config_t *)_p_item
1930 withView: (NSView *)o_parent_view
1931 withVerticalOffset: (int)i_yPos
1932 withLastItem: (int)i_lastItem
1934 NSRect mainFrame = [o_parent_view frame];
1935 NSString *o_labelString, *o_tooltip;
1936 mainFrame.size.height = 22;
1937 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN + 1;
1938 mainFrame.origin.x = LEFTMARGIN;
1939 mainFrame.origin.y = i_yPos;
1941 if( [super initWithFrame: mainFrame item: _p_item] != nil )
1944 if( p_item->psz_text )
1945 o_labelString = [[VLCMain sharedInstance] localizedString: p_item->psz_text];
1947 o_labelString = [NSString stringWithString:@""];
1948 ADD_LABEL( o_label, mainFrame, 0, -1, o_labelString )
1949 [o_label setAutoresizingMask:NSViewNotSizable ];
1950 [self addSubview: o_label];
1952 /* build the popup */
1953 o_tooltip = [[VLCMain sharedInstance] wrapString:
1954 [[VLCMain sharedInstance] localizedString: p_item->psz_longtext ] toWidth: PREFS_WRAP];
1955 ADD_POPUP( o_popup, mainFrame, [o_label frame].origin.x + [o_label frame].size.width + 3,
1957 [o_popup setAutoresizingMask:NSViewWidthSizable ];
1959 if( o_keys_menu == nil )
1962 o_keys_menu = [[NSMenu alloc] initWithTitle: @"Keys Menu"];
1963 for ( i = 0; i < sizeof(vlc_keys) / sizeof(key_descriptor_t); i++)
1964 if( vlc_keys[i].psz_key_string && *vlc_keys[i].psz_key_string )
1965 POPULATE_A_KEY( o_keys_menu, [NSString stringWithCString:vlc_keys[i].psz_key_string]
1966 , vlc_keys[i].i_key_code)
1968 [o_popup setMenu:[o_keys_menu copyWithZone:nil]];
1969 [o_popup selectItemWithTag: p_item->i_value];
1970 [self addSubview: o_popup];
1984 return [o_popup selectedTag];
1989 @implementation ModuleListConfigControl
1991 - (id) initWithItem: (module_config_t *)_p_item
1992 withView: (NSView *)o_parent_view
1993 withVerticalOffset: (int)i_yPos
1994 withLastItem: (int)i_lastItem
1996 if( _p_item->i_type == CONFIG_ITEM_MODULE_LIST )
2000 //Fill our array to know how may items we have...
2004 NSRect mainFrame = [o_parent_view frame];
2005 NSString *o_labelString, *o_textfieldString, *o_tooltip;
2007 o_modulearray = [[NSMutableArray alloc] initWithCapacity:10];
2008 /* build a list of available modules */
2009 p_list = vlc_list_find( VLCIntf, VLC_OBJECT_MODULE, FIND_ANYWHERE );
2010 for( i_index = 0; i_index < p_list->i_count; i_index++ )
2012 p_parser = (module_t *)p_list->p_values[i_index].p_object ;
2014 if( !strcmp( p_parser->psz_object_name, "main" ) )
2017 module_config_t *p_config = p_parser->p_config;
2020 NSString *o_modulelongname, *o_modulename;
2021 NSNumber *o_moduleenabled = nil;
2022 /* Hack: required subcategory is stored in i_min */
2023 if( p_config->i_type == CONFIG_SUBCATEGORY &&
2024 p_config->i_value == _p_item->i_min )
2026 o_modulelongname = [NSString stringWithCString:p_parser->psz_longname];
2027 o_modulename = [NSString stringWithCString:p_parser->psz_object_name];
2029 if( _p_item->psz_value &&
2030 strstr( _p_item->psz_value, p_parser->psz_object_name ) )
2031 o_moduleenabled = [NSNumber numberWithBool:YES];
2033 o_moduleenabled = [NSNumber numberWithBool:NO];
2035 [o_modulearray addObject:[NSMutableArray arrayWithObjects: o_modulename, o_modulelongname, o_moduleenabled, nil]];
2037 } while( p_config->i_type != CONFIG_HINT_END && p_config++ );
2039 vlc_list_release( p_list );
2041 mainFrame.size.height = 30 + 18 * [o_modulearray count];
2042 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN;
2043 mainFrame.origin.x = LEFTMARGIN;
2044 mainFrame.origin.y = i_yPos;
2045 if( [super initWithFrame: mainFrame item: _p_item] != nil )
2048 if( p_item->psz_text )
2049 o_labelString = [[VLCMain sharedInstance] localizedString: p_item->psz_text];
2051 o_labelString = [NSString stringWithString:@""];
2052 ADD_LABEL( o_label, mainFrame, 0, -3, o_labelString )
2053 [o_label setAutoresizingMask:NSViewNotSizable ];
2054 [self addSubview: o_label];
2056 /* build the textfield */
2057 o_tooltip = [[VLCMain sharedInstance] wrapString:
2058 [[VLCMain sharedInstance] localizedString: p_item->psz_longtext ] toWidth: PREFS_WRAP];
2059 if( p_item->psz_value )
2060 o_textfieldString = [[VLCMain sharedInstance] localizedString: p_item->psz_value];
2062 o_textfieldString = [NSString stringWithString: @""];
2063 ADD_TEXTFIELD( o_textfield, mainFrame, [o_label frame].size.width + 2,
2064 mainFrame.size.height - 22, mainFrame.size.width - [o_label frame].size.width - 2,
2065 o_tooltip, o_textfieldString )
2066 [o_textfield setAutoresizingMask:NSViewWidthSizable ];
2067 [self addSubview: o_textfield];
2071 NSRect s_rc = mainFrame;
2072 s_rc.size.height = mainFrame.size.height - 30;
2073 s_rc.size.width = mainFrame.size.width - 12;
2076 o_scrollview = [[[NSScrollView alloc] initWithFrame: s_rc] retain];
2077 [o_scrollview setDrawsBackground: NO];
2078 [o_scrollview setBorderType: NSBezelBorder];
2079 [o_scrollview setAutohidesScrollers:YES];
2081 NSTableView *o_tableview;
2082 o_tableview = [[NSTableView alloc] initWithFrame : s_rc];
2083 [o_tableview setUsesAlternatingRowBackgroundColors:YES];
2084 [o_tableview setHeaderView:nil];
2085 /* TODO: find a good way to fix the row height and text size*/
2086 /* FIXME: support for multiple selection... */
2087 // [o_tableview setAllowsMultipleSelection:YES];
2089 NSCell *o_headerCell = [[NSCell alloc] initTextCell:@"Enabled"];
2090 NSCell *o_dataCell = [[NSButtonCell alloc] init];
2091 [(NSButtonCell*)o_dataCell setButtonType:NSSwitchButton];
2092 [o_dataCell setTitle:@""];
2093 [o_dataCell setFont:[NSFont systemFontOfSize:0]];
2094 NSTableColumn *o_tableColumn = [[NSTableColumn alloc]initWithIdentifier:[NSString stringWithCString: "Enabled"]];
2095 [o_tableColumn setHeaderCell: o_headerCell];
2096 [o_tableColumn setDataCell: o_dataCell];
2097 [o_tableColumn setWidth:17];
2098 [o_tableview addTableColumn: o_tableColumn];
2100 o_headerCell = [[NSCell alloc] initTextCell:@"Module Name"];
2101 o_dataCell = [[NSTextFieldCell alloc] init];
2102 [o_dataCell setFont:[NSFont systemFontOfSize:12]];
2103 o_tableColumn = [[NSTableColumn alloc]initWithIdentifier:[NSString stringWithCString: "Module"]];
2104 [o_tableColumn setHeaderCell: o_headerCell];
2105 [o_tableColumn setDataCell: o_dataCell];
2106 [o_tableColumn setWidth:388 - 17];
2107 [o_tableview addTableColumn: o_tableColumn];
2108 [o_tableview registerForDraggedTypes:[NSArray arrayWithObjects:
2109 @"VLC media player module", nil]];
2111 [o_tableview setDataSource:self];
2112 [o_tableview setTarget: self];
2113 [o_tableview setAction: @selector(tableChanged:)];
2114 [o_tableview sendActionOn:NSLeftMouseUpMask|NSLeftMouseDownMask|NSLeftMouseDraggedMask];
2115 [o_scrollview setDocumentView: o_tableview];
2117 [o_scrollview setAutoresizingMask:NSViewWidthSizable ];
2118 [self addSubview: o_scrollview];
2125 - (IBAction)tableChanged:(id)sender
2127 NSString *o_newstring = @"";
2129 for( i = 0 ; i < [o_modulearray count] ; i++ )
2130 if( [[[o_modulearray objectAtIndex:i] objectAtIndex:2] boolValue] != NO )
2132 o_newstring = [o_newstring stringByAppendingString:[[o_modulearray objectAtIndex:i] objectAtIndex:0]];
2133 o_newstring = [o_newstring stringByAppendingString:@","];
2136 [o_textfield setStringValue: [o_newstring substringToIndex: ([o_newstring length])?[o_newstring length] - 1:0]];
2141 [o_scrollview release];
2146 - (char *)stringValue
2148 return strdup( [[o_textfield stringValue] cString] );
2153 @implementation ModuleListConfigControl (NSTableDataSource)
2155 - (BOOL)tableView:(NSTableView*)table writeRows:(NSArray*)rows toPasteboard:(NSPasteboard*)pb
2157 // We only want to allow dragging of selected rows.
2158 NSEnumerator *iter = [rows objectEnumerator];
2160 while ((row = [iter nextObject]) != nil)
2162 if (![table isRowSelected:[row intValue]])
2166 [pb declareTypes:[NSArray arrayWithObject:@"VLC media player module"] owner:nil];
2167 [pb setPropertyList:rows forType:@"VLC media player module"];
2172 - (NSDragOperation)tableView:(NSTableView*)table validateDrop:(id <NSDraggingInfo>)info proposedRow:(int)row proposedDropOperation:(NSTableViewDropOperation)op
2174 // Make drops at the end of the table go to the end.
2177 row = [table numberOfRows];
2178 op = NSTableViewDropAbove;
2179 [table setDropRow:row dropOperation:op];
2182 // We don't ever want to drop onto a row, only between rows.
2183 if (op == NSTableViewDropOn)
2184 [table setDropRow:(row+1) dropOperation:NSTableViewDropAbove];
2185 return NSTableViewDropAbove;
2188 - (BOOL)tableView:(NSTableView*)table acceptDrop:(id <NSDraggingInfo>)info row:(int)dropRow dropOperation:(NSTableViewDropOperation)op;
2190 NSPasteboard *pb = [info draggingPasteboard];
2191 NSDragOperation srcMask = [info draggingSourceOperationMask];
2198 // Intra-table drag - data is the array of rows.
2199 if (!accepted && (array = [pb propertyListForType:@"VLC media player module"]) != NULL)
2201 NSEnumerator * iter = nil;
2203 BOOL isCopy = (srcMask & NSDragOperationMove) ? NO:YES;
2205 iter = [array objectEnumerator];
2206 while ((val = [iter nextObject]) != NULL)
2208 NSArray *o_tmp = [[o_modulearray objectAtIndex:[val intValue]] mutableCopyWithZone:nil];
2209 [o_modulearray removeObject:o_tmp];
2210 [o_modulearray insertObject:o_tmp atIndex:(dropRow>[val intValue]) ? dropRow - 1 : dropRow];
2214 // Select the newly-dragged items.
2215 iter = [array objectEnumerator];
2217 [table deselectAll:self];
2219 [self tableChanged:self];
2220 [table setNeedsDisplay:YES];
2221 // Indicate that we finished the drag.
2225 [table setNeedsDisplay:YES];
2229 // An exception occurred. Uh-oh. Update the track table so that
2230 // it stays consistent, and re-raise the exception.
2232 [localException raise];
2233 [table setNeedsDisplay:YES];
2239 - (int)numberOfRowsInTableView:(NSTableView *)aTableView
2241 return [o_modulearray count];
2244 - (id)tableView:(NSTableView *)aTableView objectValueForTableColumn:(NSTableColumn *)aTableColumn row:(int)rowIndex
2246 if( [[aTableColumn identifier] isEqualToString:[NSString stringWithCString:"Enabled"]] )
2247 return [[o_modulearray objectAtIndex:rowIndex] objectAtIndex:2];
2248 if( [[aTableColumn identifier] isEqualToString:[NSString stringWithCString:"Module"]] )
2249 return [[o_modulearray objectAtIndex:rowIndex] objectAtIndex:1];
2254 - (void)tableView:(NSTableView *)aTableView setObjectValue:(id)anObject forTableColumn:(NSTableColumn *)aTableColumn row:(int)rowIndex
2256 [[o_modulearray objectAtIndex:rowIndex] replaceObjectAtIndex:2 withObject: anObject];