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 POPULATE_A_KEY( o_menu, string, value ) \
53 o_mi = [[NSMenuItem alloc] initWithTitle:string \
54 action:nil keyEquivalent:@""]; \
55 [o_mi setKeyEquivalentModifierMask: \
57 [o_mi setAlternate: NO]; \
60 [o_menu addItem: o_mi]; \
61 if( MACOS_VERSION >= 10.3 ) \
64 o_mi = [[NSMenuItem alloc] initWithTitle: \
65 [[NSString stringWithUTF8String: \
67 ] stringByAppendingString: string] \
68 action:nil keyEquivalent:@""]; \
69 [o_mi setKeyEquivalentModifierMask: \
71 [o_mi setAlternate: YES]; \
73 KEY_MODIFIER_CTRL | ( value )]; \
74 [o_menu addItem: o_mi]; \
76 o_mi = [[NSMenuItem alloc] initWithTitle: \
77 [[NSString stringWithUTF8String: \
78 UP_ARROWHEAD OPTION_KEY \
79 ] stringByAppendingString: string] \
80 action:nil keyEquivalent:@""]; \
81 [o_mi setKeyEquivalentModifierMask: \
82 NSControlKeyMask | NSAlternateKeyMask]; \
83 [o_mi setAlternate: YES]; \
85 (KEY_MODIFIER_CTRL | KEY_MODIFIER_ALT) | ( value )]; \
86 [o_menu addItem: o_mi]; \
88 o_mi = [[NSMenuItem alloc] initWithTitle: \
89 [[NSString stringWithUTF8String: \
90 UP_ARROWHEAD UPWARDS_WHITE_ARROW \
91 ] stringByAppendingString: string] \
92 action:nil keyEquivalent:@""]; \
93 [o_mi setKeyEquivalentModifierMask: \
94 NSControlKeyMask | NSShiftKeyMask]; \
95 [o_mi setAlternate: YES]; \
97 (KEY_MODIFIER_CTRL | KEY_MODIFIER_SHIFT) | ( value )]; \
98 [o_menu addItem: o_mi]; \
100 o_mi = [[NSMenuItem alloc] initWithTitle: \
101 [[NSString stringWithUTF8String: \
102 UP_ARROWHEAD PLACE_OF_INTEREST_SIGN \
103 ] stringByAppendingString: string] \
104 action:nil keyEquivalent:@""]; \
105 [o_mi setKeyEquivalentModifierMask: \
106 NSControlKeyMask | NSCommandKeyMask]; \
107 [o_mi setAlternate: YES]; \
109 (KEY_MODIFIER_CTRL | KEY_MODIFIER_COMMAND) | ( value )]; \
110 [o_menu addItem: o_mi]; \
111 /* Ctrl+Alt+Shift */ \
112 o_mi = [[NSMenuItem alloc] initWithTitle: \
113 [[NSString stringWithUTF8String: \
114 UP_ARROWHEAD OPTION_KEY UPWARDS_WHITE_ARROW \
115 ] stringByAppendingString: string] \
116 action:nil keyEquivalent:@""]; \
117 [o_mi setKeyEquivalentModifierMask: \
118 NSControlKeyMask | NSAlternateKeyMask | NSShiftKeyMask]; \
119 [o_mi setAlternate: YES]; \
121 (KEY_MODIFIER_CTRL | KEY_MODIFIER_ALT | KEY_MODIFIER_SHIFT) | \
123 [o_menu addItem: o_mi]; \
124 /* Ctrl+Alt+Apple */ \
125 o_mi = [[NSMenuItem alloc] initWithTitle: \
126 [[NSString stringWithUTF8String: \
127 UP_ARROWHEAD OPTION_KEY PLACE_OF_INTEREST_SIGN \
128 ] stringByAppendingString: string] \
129 action:nil keyEquivalent:@""]; \
130 [o_mi setKeyEquivalentModifierMask: \
131 NSControlKeyMask | NSAlternateKeyMask | NSCommandKeyMask]; \
132 [o_mi setAlternate: YES]; \
134 (KEY_MODIFIER_CTRL | KEY_MODIFIER_ALT | KEY_MODIFIER_COMMAND) | \
136 [o_menu addItem: o_mi]; \
137 /* Ctrl+Shift+Apple */ \
138 o_mi = [[NSMenuItem alloc] initWithTitle: \
139 [[NSString stringWithUTF8String: \
140 UP_ARROWHEAD UPWARDS_WHITE_ARROW PLACE_OF_INTEREST_SIGN \
141 ] stringByAppendingString: string] \
142 action:nil keyEquivalent:@""]; \
143 [o_mi setKeyEquivalentModifierMask: \
144 NSControlKeyMask | NSShiftKeyMask | NSCommandKeyMask]; \
145 [o_mi setAlternate: YES]; \
147 (KEY_MODIFIER_CTRL | KEY_MODIFIER_SHIFT | KEY_MODIFIER_COMMAND) | \
149 [o_menu addItem: o_mi]; \
150 /* Ctrl+Alt+Shift+Apple */ \
151 o_mi = [[NSMenuItem alloc] initWithTitle: \
152 [[NSString stringWithUTF8String: \
153 UP_ARROWHEAD OPTION_KEY UPWARDS_WHITE_ARROW \
154 PLACE_OF_INTEREST_SIGN \
155 ] stringByAppendingString: string] \
156 action:nil keyEquivalent:@""]; \
157 [o_mi setKeyEquivalentModifierMask: \
158 NSControlKeyMask | NSAlternateKeyMask | NSShiftKeyMask | \
160 [o_mi setAlternate: YES]; \
162 (KEY_MODIFIER_CTRL | KEY_MODIFIER_ALT | KEY_MODIFIER_SHIFT | \
163 KEY_MODIFIER_COMMAND) | ( value )]; \
164 [o_menu addItem: o_mi]; \
166 o_mi = [[NSMenuItem alloc] initWithTitle: \
167 [[NSString stringWithUTF8String: \
169 ] stringByAppendingString: string] \
170 action:nil keyEquivalent:@""]; \
171 [o_mi setKeyEquivalentModifierMask: \
172 NSAlternateKeyMask]; \
173 [o_mi setAlternate: YES]; \
175 KEY_MODIFIER_ALT | ( value )]; \
176 [o_menu addItem: o_mi]; \
178 o_mi = [[NSMenuItem alloc] initWithTitle: \
179 [[NSString stringWithUTF8String: \
180 OPTION_KEY UPWARDS_WHITE_ARROW \
181 ] stringByAppendingString: string] \
182 action:nil keyEquivalent:@""]; \
183 [o_mi setKeyEquivalentModifierMask: \
184 NSAlternateKeyMask | NSShiftKeyMask]; \
185 [o_mi setAlternate: YES]; \
187 (KEY_MODIFIER_ALT | KEY_MODIFIER_SHIFT) | ( value )]; \
188 [o_menu addItem: o_mi]; \
190 o_mi = [[NSMenuItem alloc] initWithTitle: \
191 [[NSString stringWithUTF8String: \
192 OPTION_KEY PLACE_OF_INTEREST_SIGN \
193 ] stringByAppendingString: string] \
194 action:nil keyEquivalent:@""]; \
195 [o_mi setKeyEquivalentModifierMask: \
196 NSAlternateKeyMask | NSCommandKeyMask]; \
197 [o_mi setAlternate: YES]; \
199 (KEY_MODIFIER_ALT | KEY_MODIFIER_COMMAND) | ( value )]; \
200 [o_menu addItem: o_mi]; \
201 /* Alt+Shift+Apple */ \
202 o_mi = [[NSMenuItem alloc] initWithTitle: \
203 [[NSString stringWithUTF8String: \
204 OPTION_KEY UPWARDS_WHITE_ARROW PLACE_OF_INTEREST_SIGN \
205 ] stringByAppendingString: string] \
206 action:nil keyEquivalent:@""]; \
207 [o_mi setKeyEquivalentModifierMask: \
208 NSAlternateKeyMask | NSShiftKeyMask | NSCommandKeyMask]; \
209 [o_mi setAlternate: YES]; \
211 (KEY_MODIFIER_ALT | KEY_MODIFIER_SHIFT | KEY_MODIFIER_COMMAND) | \
213 [o_menu addItem: o_mi]; \
215 o_mi = [[NSMenuItem alloc] initWithTitle: \
216 [[NSString stringWithUTF8String: \
217 UPWARDS_WHITE_ARROW \
218 ] stringByAppendingString: string] \
219 action:nil keyEquivalent:@""]; \
220 [o_mi setKeyEquivalentModifierMask: \
222 [o_mi setAlternate: YES]; \
224 KEY_MODIFIER_SHIFT | ( value )]; \
225 [o_menu addItem: o_mi]; \
227 o_mi = [[NSMenuItem alloc] initWithTitle: \
228 [[NSString stringWithUTF8String: \
229 UPWARDS_WHITE_ARROW PLACE_OF_INTEREST_SIGN \
230 ] stringByAppendingString: string] \
231 action:nil keyEquivalent:@""]; \
232 [o_mi setKeyEquivalentModifierMask: \
233 NSShiftKeyMask | NSCommandKeyMask]; \
234 [o_mi setAlternate: YES]; \
236 (KEY_MODIFIER_SHIFT | KEY_MODIFIER_COMMAND) | ( value )]; \
237 [o_menu addItem: o_mi]; \
239 o_mi = [[NSMenuItem alloc] initWithTitle: \
240 [[NSString stringWithUTF8String: \
241 PLACE_OF_INTEREST_SIGN \
242 ] stringByAppendingString: string] \
243 action:nil keyEquivalent:@""]; \
244 [o_mi setKeyEquivalentModifierMask: \
246 [o_mi setAlternate: YES]; \
248 KEY_MODIFIER_COMMAND | ( value )]; \
249 [o_menu addItem: o_mi]; \
253 #define ADD_LABEL( o_label, superFrame, x_offset, my_y_offset, label ) \
255 NSRect s_rc = superFrame; \
256 s_rc.size.height = 17; \
257 s_rc.origin.x = x_offset - 3; \
258 s_rc.origin.y = superFrame.size.height - 17 + my_y_offset; \
259 o_label = [[[NSTextField alloc] initWithFrame: s_rc] retain]; \
260 [o_label setDrawsBackground: NO]; \
261 [o_label setBordered: NO]; \
262 [o_label setEditable: NO]; \
263 [o_label setSelectable: NO]; \
264 [o_label setStringValue: label]; \
265 [o_label 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_COMBO( o_combo, superFrame, x_offset, my_y_offset, x2_offset, \
286 NSRect s_rc = superFrame; \
287 s_rc.origin.x = x_offset + 2; \
288 s_rc.origin.y = my_y_offset; \
289 s_rc.size.height = 26; \
290 s_rc.size.width = superFrame.size.width + 2 - s_rc.origin.x - \
292 o_combo = [[[NSComboBox alloc] initWithFrame: s_rc] retain]; \
293 [o_combo setFont:[NSFont systemFontOfSize:0]]; \
294 [o_combo setToolTip: tooltip]; \
295 [o_combo setUsesDataSource:TRUE]; \
296 [o_combo setDataSource:self]; \
297 [o_combo setNumberOfVisibleItems:10]; \
298 [o_combo setCompletes:YES]; \
301 #define ADD_RIGHT_BUTTON( o_button, superFrame, x_offset, my_y_offset, \
304 NSRect s_rc = superFrame; \
305 o_button = [[[NSButton alloc] initWithFrame: s_rc] retain]; \
306 [o_button setButtonType: NSMomentaryPushInButton]; \
307 [o_button setBezelStyle: NSRoundedBezelStyle]; \
308 [o_button setTitle: title]; \
309 [o_button setFont:[NSFont systemFontOfSize:0]]; \
310 [o_button sizeToFit]; \
311 s_rc = [o_button frame]; \
312 s_rc.origin.x = superFrame.size.width - [o_button frame].size.width - 6;\
313 s_rc.origin.y = my_y_offset - 6; \
314 s_rc.size.width += 12; \
315 [o_button setFrame: s_rc]; \
316 [o_button setToolTip: tooltip]; \
317 [o_button setTarget: self]; \
318 [o_button setAction: @selector(openFileDialog:)]; \
321 #define ADD_POPUP( o_popup, superFrame, x_offset, my_y_offset, x2_offset, \
324 NSRect s_rc = superFrame; \
325 s_rc.origin.x = x_offset - 1; \
326 s_rc.origin.y = my_y_offset; \
327 s_rc.size.height = 26; \
328 s_rc.size.width = superFrame.size.width + 2 - s_rc.origin.x - \
330 o_popup = [[[NSPopUpButton alloc] initWithFrame: s_rc] retain]; \
331 [o_popup setFont:[NSFont systemFontOfSize:0]]; \
332 [o_popup setToolTip: tooltip]; \
335 #define ADD_STEPPER( o_stepper, superFrame, x_offset, my_y_offset, tooltip, \
338 NSRect s_rc = superFrame; \
339 s_rc.origin.x = x_offset; \
340 s_rc.origin.y = my_y_offset; \
341 s_rc.size.height = 23; \
342 s_rc.size.width = 23; \
343 o_stepper = [[[NSStepper alloc] initWithFrame: s_rc] retain]; \
344 [o_stepper setFont:[NSFont systemFontOfSize:0]]; \
345 [o_stepper setToolTip: tooltip]; \
346 [o_stepper setMaxValue: higher]; \
347 [o_stepper setMinValue: lower]; \
348 [o_stepper setTarget: self]; \
349 [o_stepper setAction: @selector(stepperChanged:)]; \
350 [o_stepper sendActionOn:NSLeftMouseUpMask | NSLeftMouseDownMask | \
351 NSLeftMouseDraggedMask]; \
354 #define ADD_SLIDER( o_slider, superFrame, x_offset, my_y_offset, my_width, \
355 tooltip, lower, higher ) \
357 NSRect s_rc = superFrame; \
358 s_rc.origin.x = x_offset; \
359 s_rc.origin.y = my_y_offset; \
360 s_rc.size.height = 21; \
361 s_rc.size.width = my_width; \
362 o_slider = [[[NSSlider alloc] initWithFrame: s_rc] retain]; \
363 [o_slider setFont:[NSFont systemFontOfSize:0]]; \
364 [o_slider setToolTip: tooltip]; \
365 [o_slider setMaxValue: higher]; \
366 [o_slider setMinValue: lower]; \
369 #define ADD_CHECKBOX( o_checkbox, superFrame, x_offset, my_y_offset, label, \
370 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 #define ADD_CHECKBOX( o_checkbox, superFrame, x_offset, my_y_offset, label, \
387 tooltip, init_value, position ) \
389 NSRect s_rc = superFrame; \
390 s_rc.size.height = 18; \
391 s_rc.origin.x = x_offset - 2; \
392 s_rc.origin.y = superFrame.size.height - 18 + my_y_offset; \
393 o_checkbox = [[[NSButton alloc] initWithFrame: s_rc] retain]; \
394 [o_checkbox setFont:[NSFont systemFontOfSize:0]]; \
395 [o_checkbox setButtonType: NSSwitchButton]; \
396 [o_checkbox setImagePosition: position]; \
397 [o_checkbox setIntValue: init_value]; \
398 [o_checkbox setTitle: label]; \
399 [o_checkbox setToolTip: tooltip]; \
400 [o_checkbox sizeToFit]; \
403 @implementation VLCConfigControl
404 - (id)initWithFrame: (NSRect)frame
406 return [self initWithFrame: frame
410 - (id)initWithFrame: (NSRect)frame
411 item: (module_config_t *)_p_item
413 self = [super initWithFrame: frame];
418 psz_name = strdup( p_item->psz_name );
420 i_type = p_item->i_type;
422 b_advanced = p_item->b_advanced;
423 [self setAutoresizingMask:NSViewWidthSizable | NSViewMinYMargin ];
428 - (void)setYPos:(int)i_yPos
430 NSRect frame = [self frame];
431 frame.origin.y = i_yPos;
432 [self setFrame:frame];
437 if( o_label ) [o_label release];
438 if( psz_name ) free( psz_name );
442 + (int)calcVerticalMargin: (int)i_curItem lastItem: (int)i_lastItem
447 case CONFIG_ITEM_STRING:
450 case CONFIG_ITEM_STRING:
453 case CONFIG_ITEM_STRING_LIST:
456 case CONFIG_ITEM_FILE:
459 case CONFIG_ITEM_MODULE:
462 case CONFIG_ITEM_INTEGER:
465 case CONFIG_ITEM_RANGED_INTEGER:
468 case CONFIG_ITEM_BOOL:
471 case CONFIG_ITEM_KEY_BEFORE_10_3:
474 case CONFIG_ITEM_KEY_AFTER_10_3:
477 case CONFIG_ITEM_MODULE_LIST:
485 case CONFIG_ITEM_STRING_LIST:
488 case CONFIG_ITEM_STRING:
491 case CONFIG_ITEM_STRING_LIST:
494 case CONFIG_ITEM_FILE:
497 case CONFIG_ITEM_MODULE:
500 case CONFIG_ITEM_INTEGER:
503 case CONFIG_ITEM_RANGED_INTEGER:
506 case CONFIG_ITEM_BOOL:
509 case CONFIG_ITEM_KEY_BEFORE_10_3:
512 case CONFIG_ITEM_KEY_AFTER_10_3:
515 case CONFIG_ITEM_MODULE_LIST:
523 case CONFIG_ITEM_FILE:
526 case CONFIG_ITEM_STRING:
529 case CONFIG_ITEM_STRING_LIST:
532 case CONFIG_ITEM_FILE:
535 case CONFIG_ITEM_MODULE:
538 case CONFIG_ITEM_INTEGER:
541 case CONFIG_ITEM_RANGED_INTEGER:
544 case CONFIG_ITEM_BOOL:
547 case CONFIG_ITEM_KEY_BEFORE_10_3:
550 case CONFIG_ITEM_KEY_AFTER_10_3:
553 case CONFIG_ITEM_MODULE_LIST:
561 case CONFIG_ITEM_MODULE:
564 case CONFIG_ITEM_STRING:
567 case CONFIG_ITEM_STRING_LIST:
570 case CONFIG_ITEM_FILE:
573 case CONFIG_ITEM_MODULE:
576 case CONFIG_ITEM_INTEGER:
579 case CONFIG_ITEM_RANGED_INTEGER:
582 case CONFIG_ITEM_BOOL:
585 case CONFIG_ITEM_KEY_BEFORE_10_3:
588 case CONFIG_ITEM_KEY_AFTER_10_3:
591 case CONFIG_ITEM_MODULE_LIST:
599 case CONFIG_ITEM_INTEGER:
602 case CONFIG_ITEM_STRING:
605 case CONFIG_ITEM_STRING_LIST:
608 case CONFIG_ITEM_FILE:
611 case CONFIG_ITEM_MODULE:
614 case CONFIG_ITEM_INTEGER:
617 case CONFIG_ITEM_RANGED_INTEGER:
620 case CONFIG_ITEM_BOOL:
623 case CONFIG_ITEM_KEY_BEFORE_10_3:
626 case CONFIG_ITEM_KEY_AFTER_10_3:
629 case CONFIG_ITEM_MODULE_LIST:
637 case CONFIG_ITEM_RANGED_INTEGER:
640 case CONFIG_ITEM_STRING:
643 case CONFIG_ITEM_STRING_LIST:
646 case CONFIG_ITEM_FILE:
649 case CONFIG_ITEM_MODULE:
652 case CONFIG_ITEM_INTEGER:
655 case CONFIG_ITEM_RANGED_INTEGER:
658 case CONFIG_ITEM_BOOL:
661 case CONFIG_ITEM_KEY_BEFORE_10_3:
664 case CONFIG_ITEM_KEY_AFTER_10_3:
667 case CONFIG_ITEM_MODULE_LIST:
675 case CONFIG_ITEM_BOOL:
678 case CONFIG_ITEM_STRING:
681 case CONFIG_ITEM_STRING_LIST:
684 case CONFIG_ITEM_FILE:
687 case CONFIG_ITEM_MODULE:
690 case CONFIG_ITEM_INTEGER:
693 case CONFIG_ITEM_RANGED_INTEGER:
696 case CONFIG_ITEM_BOOL:
699 case CONFIG_ITEM_KEY_BEFORE_10_3:
702 case CONFIG_ITEM_KEY_AFTER_10_3:
705 case CONFIG_ITEM_MODULE_LIST:
713 case CONFIG_ITEM_KEY_BEFORE_10_3:
716 case CONFIG_ITEM_STRING:
719 case CONFIG_ITEM_STRING_LIST:
722 case CONFIG_ITEM_FILE:
725 case CONFIG_ITEM_MODULE:
728 case CONFIG_ITEM_INTEGER:
731 case CONFIG_ITEM_RANGED_INTEGER:
734 case CONFIG_ITEM_BOOL:
737 case CONFIG_ITEM_KEY_BEFORE_10_3:
740 case CONFIG_ITEM_KEY_AFTER_10_3:
743 case CONFIG_ITEM_MODULE_LIST:
751 case CONFIG_ITEM_KEY_AFTER_10_3:
754 case CONFIG_ITEM_STRING:
757 case CONFIG_ITEM_STRING_LIST:
760 case CONFIG_ITEM_FILE:
763 case CONFIG_ITEM_MODULE:
766 case CONFIG_ITEM_INTEGER:
769 case CONFIG_ITEM_RANGED_INTEGER:
772 case CONFIG_ITEM_BOOL:
775 case CONFIG_ITEM_KEY_BEFORE_10_3:
778 case CONFIG_ITEM_KEY_AFTER_10_3:
781 case CONFIG_ITEM_MODULE_LIST:
789 case CONFIG_ITEM_MODULE_LIST:
792 case CONFIG_ITEM_STRING:
795 case CONFIG_ITEM_STRING_LIST:
798 case CONFIG_ITEM_FILE:
801 case CONFIG_ITEM_MODULE:
804 case CONFIG_ITEM_INTEGER:
807 case CONFIG_ITEM_RANGED_INTEGER:
810 case CONFIG_ITEM_BOOL:
813 case CONFIG_ITEM_KEY_BEFORE_10_3:
816 case CONFIG_ITEM_KEY_AFTER_10_3:
819 case CONFIG_ITEM_MODULE_LIST:
834 + (VLCConfigControl *)newControl: (module_config_t *)_p_item
835 withView: (NSView *)o_parent_view
837 VLCConfigControl *p_control = NULL;
838 switch( _p_item->i_type )
840 case CONFIG_ITEM_STRING:
841 if( !_p_item->i_list )
843 p_control = [[StringConfigControl alloc]
844 initWithItem: _p_item
845 withView: o_parent_view];
849 p_control = [[StringListConfigControl alloc]
850 initWithItem: _p_item
851 withView: o_parent_view];
854 case CONFIG_ITEM_FILE:
855 case CONFIG_ITEM_DIRECTORY:
856 p_control = [[FileConfigControl alloc]
857 initWithItem: _p_item
858 withView: o_parent_view];
860 case CONFIG_ITEM_MODULE:
861 case CONFIG_ITEM_MODULE_CAT:
862 p_control = [[ModuleConfigControl alloc]
863 initWithItem: _p_item
864 withView: o_parent_view];
866 case CONFIG_ITEM_INTEGER:
867 if( _p_item->i_list )
869 p_control = [[IntegerListConfigControl alloc]
870 initWithItem: _p_item
871 withView: o_parent_view];
873 else if( _p_item->i_min != 0 || _p_item->i_max != 0 )
875 p_control = [[RangedIntegerConfigControl alloc]
876 initWithItem: _p_item
877 withView: o_parent_view];
881 p_control = [[IntegerConfigControl alloc]
882 initWithItem: _p_item
883 withView: o_parent_view];
886 case CONFIG_ITEM_BOOL:
887 p_control = [[BoolConfigControl alloc]
888 initWithItem: _p_item
889 withView: o_parent_view];
891 case CONFIG_ITEM_FLOAT:
892 if( _p_item->f_min != 0 || _p_item->f_max != 0 )
894 p_control = [[RangedFloatConfigControl alloc]
895 initWithItem: _p_item
896 withView: o_parent_view];
900 p_control = [[FloatConfigControl alloc]
901 initWithItem: _p_item
902 withView: o_parent_view];
905 case CONFIG_ITEM_KEY:
906 if( MACOS_VERSION < 10.3 )
908 p_control = [[KeyConfigControlBefore103 alloc]
909 initWithItem: _p_item
910 withView: o_parent_view];
914 p_control = [[KeyConfigControlAfter103 alloc]
915 initWithItem: _p_item
916 withView: o_parent_view];
919 case CONFIG_ITEM_MODULE_LIST:
920 case CONFIG_ITEM_MODULE_LIST_CAT:
921 p_control = [[ModuleListConfigControl alloc]
922 initWithItem: _p_item
923 withView: o_parent_view];
931 - (NSString *)getName
933 return [[VLCMain sharedInstance] localizedString: psz_name];
961 - (char *)stringValue
969 switch( p_item->i_type )
971 case CONFIG_ITEM_STRING:
972 case CONFIG_ITEM_FILE:
973 case CONFIG_ITEM_DIRECTORY:
974 case CONFIG_ITEM_MODULE:
975 case CONFIG_ITEM_MODULE_LIST:
976 case CONFIG_ITEM_MODULE_LIST_CAT:
977 fprintf( stderr, "Applying %s to %s\n" , [self stringValue], psz_name );
978 config_PutPsz( VLCIntf, psz_name, [self stringValue] );
980 case CONFIG_ITEM_KEY:
981 /* So you don't need to restart to have the changes take effect */
982 fprintf( stderr, "Applying %d to %s\n" , [self intValue], psz_name );
983 val.i_int = [self intValue];
984 var_Set( VLCIntf->p_vlc, psz_name, val );
985 case CONFIG_ITEM_INTEGER:
986 case CONFIG_ITEM_BOOL:
987 fprintf( stderr, "Applying %d to %s\n" , [self intValue], psz_name );
988 config_PutInt( VLCIntf, psz_name, [self intValue] );
990 case CONFIG_ITEM_FLOAT:
991 fprintf( stderr, "Applying %f to %s\n" , [self floatValue], psz_name );
992 config_PutFloat( VLCIntf, psz_name, [self floatValue] );
998 @implementation StringConfigControl
999 - (id) initWithItem: (module_config_t *)_p_item
1000 withView: (NSView *)o_parent_view
1002 NSRect mainFrame = [o_parent_view frame];
1003 NSString *o_labelString, *o_textfieldString, *o_textfieldTooltip;
1004 mainFrame.size.height = 22;
1005 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN;
1006 mainFrame.origin.x = LEFTMARGIN;
1007 mainFrame.origin.y = 0;
1009 if( [super initWithFrame: mainFrame item: _p_item] != nil )
1011 i_view_type = CONFIG_ITEM_STRING;
1013 if( p_item->psz_text )
1014 o_labelString = [[VLCMain sharedInstance]
1015 localizedString: p_item->psz_text];
1017 o_labelString = [NSString stringWithString:@""];
1018 ADD_LABEL( o_label, mainFrame, 0, -3, o_labelString )
1019 [o_label setAutoresizingMask:NSViewNotSizable ];
1020 [self addSubview: o_label];
1022 /* build the textfield */
1023 o_textfieldTooltip = [[VLCMain sharedInstance] wrapString:
1024 [[VLCMain sharedInstance] localizedString: p_item->psz_longtext]
1025 toWidth: PREFS_WRAP];
1026 if( p_item->psz_value )
1027 o_textfieldString = [[VLCMain sharedInstance]
1028 localizedString: p_item->psz_value];
1030 o_textfieldString = [NSString stringWithString: @""];
1031 ADD_TEXTFIELD( o_textfield, mainFrame, [o_label frame].size.width + 2,
1032 0, mainFrame.size.width - [o_label frame].size.width -
1033 2, o_textfieldTooltip, o_textfieldString )
1034 [o_textfield setAutoresizingMask:NSViewWidthSizable ];
1035 [self addSubview: o_textfield];
1043 [o_textfield release];
1047 - (char *)stringValue
1049 return strdup( [[VLCMain sharedInstance] delocalizeString:
1050 [o_textfield stringValue]] );
1054 @implementation StringListConfigControl
1055 - (id) initWithItem: (module_config_t *)_p_item
1056 withView: (NSView *)o_parent_view
1058 NSRect mainFrame = [o_parent_view frame];
1059 NSString *o_labelString, *o_textfieldTooltip;
1060 mainFrame.size.height = 22;
1061 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN + 1;
1062 mainFrame.origin.x = LEFTMARGIN;
1063 mainFrame.origin.y = 0;
1065 if( [super initWithFrame: mainFrame item: _p_item] != nil )
1068 i_view_type = CONFIG_ITEM_STRING_LIST;
1070 if( p_item->psz_text )
1071 o_labelString = [[VLCMain sharedInstance]
1072 localizedString: p_item->psz_text];
1074 o_labelString = [NSString stringWithString:@""];
1075 ADD_LABEL( o_label, mainFrame, 0, -3, o_labelString )
1076 [o_label setAutoresizingMask:NSViewNotSizable ];
1077 [self addSubview: o_label];
1079 /* build the textfield */
1080 o_textfieldTooltip = [[VLCMain sharedInstance] wrapString:
1081 [[VLCMain sharedInstance]
1082 localizedString: p_item->psz_longtext ] toWidth: PREFS_WRAP];
1083 ADD_COMBO( o_combo, mainFrame, [o_label frame].size.width,
1084 -2, 0, o_textfieldTooltip )
1085 [o_combo setAutoresizingMask:NSViewWidthSizable ];
1086 for( i_index = 0; i_index < p_item->i_list; i_index++ )
1087 if( p_item->psz_value &&
1088 !strcmp( p_item->psz_value, p_item->ppsz_list[i_index] ) )
1089 [o_combo selectItemAtIndex: i_index];
1090 [self addSubview: o_combo];
1101 - (char *)stringValue
1103 if( [o_combo indexOfSelectedItem] >= 0 )
1104 return strdup( p_item->ppsz_list[[o_combo indexOfSelectedItem]] );
1106 return strdup( [[VLCMain sharedInstance]
1107 delocalizeString: [o_combo stringValue]] );
1111 @implementation StringListConfigControl (NSComboBoxDataSource)
1112 - (int)numberOfItemsInComboBox:(NSComboBox *)aComboBox
1114 return p_item->i_list;
1117 - (id)comboBox:(NSComboBox *)aComboBox objectValueForItemAtIndex:(int)i_index
1119 if( p_item->ppsz_list_text && p_item->ppsz_list_text[i_index] )
1121 return [[VLCMain sharedInstance]
1122 localizedString: p_item->ppsz_list_text[i_index]];
1123 } else return [[VLCMain sharedInstance]
1124 localizedString: p_item->ppsz_list[i_index]];
1128 @implementation FileConfigControl
1129 - (id) initWithItem: (module_config_t *)_p_item
1130 withView: (NSView *)o_parent_view
1132 NSRect mainFrame = [o_parent_view frame];
1133 NSString *o_labelString, *o_buttonTooltip, *o_textfieldString;
1134 NSString *o_textfieldTooltip;
1135 mainFrame.size.height = 46;
1136 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN;
1137 mainFrame.origin.x = LEFTMARGIN;
1138 mainFrame.origin.y = 0;
1140 if( [super initWithFrame: mainFrame item: _p_item] != nil )
1142 i_view_type = CONFIG_ITEM_FILE;
1144 /* is it a directory */
1145 b_directory = ( [self getType] == CONFIG_ITEM_DIRECTORY ) ? YES : NO;
1148 if( p_item->psz_text )
1149 o_labelString = [[VLCMain sharedInstance]
1150 localizedString: p_item->psz_text];
1152 o_labelString = [NSString stringWithString:@""];
1153 ADD_LABEL( o_label, mainFrame, 0, 3, o_labelString )
1154 [o_label setAutoresizingMask:NSViewNotSizable ];
1155 [self addSubview: o_label];
1157 /* build the button */
1158 o_buttonTooltip = [[VLCMain sharedInstance]
1159 wrapString: [[VLCMain sharedInstance]
1160 localizedString: p_item->psz_longtext ] toWidth: PREFS_WRAP];
1161 ADD_RIGHT_BUTTON( o_button, mainFrame, 0, 0, o_buttonTooltip,
1163 [o_button setAutoresizingMask:NSViewMinXMargin ];
1164 [self addSubview: o_button];
1166 /* build the textfield */
1167 o_textfieldTooltip = [[VLCMain sharedInstance] wrapString:
1168 [[VLCMain sharedInstance]
1169 localizedString: p_item->psz_longtext ] toWidth: PREFS_WRAP];
1170 if( p_item->psz_value )
1171 o_textfieldString = [[VLCMain sharedInstance]
1172 localizedString: p_item->psz_value];
1174 o_textfieldString = [NSString stringWithString: @""];
1175 ADD_TEXTFIELD( o_textfield, mainFrame, 12, 2, mainFrame.size.width -
1176 8 - [o_button frame].size.width,
1177 o_textfieldTooltip, o_textfieldString )
1178 [o_textfield setAutoresizingMask:NSViewWidthSizable ];
1179 [self addSubview: o_textfield];
1186 [o_textfield release];
1191 - (IBAction)openFileDialog: (id)sender
1193 NSOpenPanel *o_open_panel = [NSOpenPanel openPanel];
1195 [o_open_panel setTitle: (b_directory)?
1196 _NS("Select a directory"):_NS("Select a file")];
1197 [o_open_panel setPrompt: _NS("Select")];
1198 [o_open_panel setAllowsMultipleSelection: NO];
1199 [o_open_panel setCanChooseFiles: !b_directory];
1200 [o_open_panel setCanChooseDirectories: b_directory];
1201 [o_open_panel beginSheetForDirectory:nil
1204 modalForWindow:[sender window]
1206 didEndSelector: @selector(pathChosenInPanel:
1212 - (void)pathChosenInPanel:(NSOpenPanel *)o_sheet
1213 withReturn:(int)i_return_code contextInfo:(void *)o_context_info
1215 if( i_return_code == NSOKButton )
1217 NSString *o_path = [[o_sheet filenames] objectAtIndex: 0];
1218 [o_textfield setStringValue: o_path];
1222 - (char *)stringValue
1224 if( [[o_textfield stringValue] length] != 0)
1225 return strdup( [[o_textfield stringValue] fileSystemRepresentation] );
1231 @implementation ModuleConfigControl
1232 - (id) initWithItem: (module_config_t *)_p_item
1233 withView: (NSView *)o_parent_view
1235 NSRect mainFrame = [o_parent_view frame];
1236 NSString *o_labelString, *o_popupTooltip;
1237 mainFrame.size.height = 22;
1238 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN + 1;
1239 mainFrame.origin.x = LEFTMARGIN;
1240 mainFrame.origin.y = 0;
1242 if( [super initWithFrame: mainFrame item: _p_item] != nil )
1247 i_view_type = CONFIG_ITEM_MODULE;
1250 if( p_item->psz_text )
1251 o_labelString = [[VLCMain sharedInstance]
1252 localizedString: p_item->psz_text];
1254 o_labelString = [NSString stringWithString:@""];
1255 ADD_LABEL( o_label, mainFrame, 0, -1, o_labelString )
1256 [o_label setAutoresizingMask:NSViewNotSizable ];
1257 [self addSubview: o_label];
1259 /* build the popup */
1260 o_popupTooltip = [[VLCMain sharedInstance] wrapString:
1261 [[VLCMain sharedInstance]
1262 localizedString: p_item->psz_longtext ] toWidth: PREFS_WRAP];
1263 ADD_POPUP( o_popup, mainFrame, [o_label frame].size.width,
1264 -2, 0, o_popupTooltip )
1265 [o_popup setAutoresizingMask:NSViewWidthSizable ];
1266 [o_popup addItemWithTitle: _NS("Default")];
1267 [[o_popup lastItem] setTag: -1];
1268 [o_popup selectItem: [o_popup lastItem]];
1270 /* build a list of available modules */
1271 p_list = vlc_list_find( VLCIntf, VLC_OBJECT_MODULE, FIND_ANYWHERE );
1272 for( i_index = 0; i_index < p_list->i_count; i_index++ )
1274 p_parser = (module_t *)p_list->p_values[i_index].p_object ;
1275 if( p_item->i_type == CONFIG_ITEM_MODULE )
1277 if( !strcmp( p_parser->psz_capability,
1278 p_item->psz_type ) )
1280 NSString *o_description = [[VLCMain sharedInstance]
1281 localizedString: p_parser->psz_longname];
1282 [o_popup addItemWithTitle: o_description];
1284 if( p_item->psz_value &&
1285 !strcmp( p_item->psz_value, p_parser->psz_object_name ) )
1286 [o_popup selectItem:[o_popup lastItem]];
1291 module_config_t *p_config;
1292 if( !strcmp( p_parser->psz_object_name, "main" ) )
1295 p_config = p_parser->p_config;
1298 /* Hack: required subcategory is stored in i_min */
1299 if( p_config->i_type == CONFIG_SUBCATEGORY &&
1300 p_config->i_value == p_item->i_min )
1302 NSString *o_description = [[VLCMain sharedInstance]
1303 localizedString: p_parser->psz_longname];
1304 [o_popup addItemWithTitle: o_description];
1306 if( p_item->psz_value && !strcmp(p_item->psz_value,
1307 p_parser->psz_object_name) )
1308 [o_popup selectItem:[o_popup lastItem]];
1310 } while( p_config->i_type != CONFIG_HINT_END && p_config++ );
1313 vlc_list_release( p_list );
1314 [self addSubview: o_popup];
1325 - (char *)stringValue
1327 NSString *newval = [o_popup titleOfSelectedItem];
1328 char *returnval = NULL;
1333 p_list = vlc_list_find( VLCIntf, VLC_OBJECT_MODULE, FIND_ANYWHERE );
1334 for( i_index = 0; i_index < p_list->i_count; i_index++ )
1336 p_parser = (module_t *)p_list->p_values[i_index].p_object ;
1337 if( p_item->i_type == CONFIG_ITEM_MODULE )
1339 if( !strcmp( p_parser->psz_capability,
1340 p_item->psz_type ) )
1342 NSString *o_description = [[VLCMain sharedInstance]
1343 localizedString: p_parser->psz_longname];
1344 if( [newval isEqualToString: o_description] )
1346 returnval = strdup(p_parser->psz_object_name);
1353 module_config_t *p_config;
1354 if( !strcmp( p_parser->psz_object_name, "main" ) )
1357 p_config = p_parser->p_config;
1360 /* Hack: required subcategory is stored in i_min */
1361 if( p_config->i_type == CONFIG_SUBCATEGORY &&
1362 p_config->i_value == p_item->i_min )
1364 NSString *o_description = [[VLCMain sharedInstance]
1365 localizedString: p_parser->psz_longname];
1366 if( [newval isEqualToString: o_description] )
1368 returnval = strdup(p_parser->psz_object_name);
1372 } while( p_config->i_type != CONFIG_HINT_END && p_config++ );
1375 vlc_list_release( p_list );
1380 @implementation IntegerConfigControl
1381 - (id) initWithItem: (module_config_t *)_p_item
1382 withView: (NSView *)o_parent_view
1384 NSRect mainFrame = [o_parent_view frame];
1385 NSString *o_labelString, *o_tooltip, *o_textfieldString;
1386 mainFrame.size.height = 23;
1387 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN + 1;
1388 mainFrame.origin.x = LEFTMARGIN;
1389 mainFrame.origin.y = 0;
1391 if( [super initWithFrame: mainFrame item: _p_item] != nil )
1393 i_view_type = CONFIG_ITEM_INTEGER;
1395 o_tooltip = [[VLCMain sharedInstance] wrapString:
1396 [[VLCMain sharedInstance]
1397 localizedString: p_item->psz_longtext ] toWidth: PREFS_WRAP];
1400 if( p_item->psz_text )
1401 o_labelString = [[VLCMain sharedInstance]
1402 localizedString: p_item->psz_text];
1404 o_labelString = [NSString stringWithString:@""];
1405 ADD_LABEL( o_label, mainFrame, 0, -2, o_labelString )
1406 [o_label setAutoresizingMask:NSViewNotSizable ];
1407 [self addSubview: o_label];
1409 /* build the stepper */
1410 ADD_STEPPER( o_stepper, mainFrame, mainFrame.size.width - 19,
1411 0, o_tooltip, -1600, 1600)
1412 [o_stepper setIntValue: p_item->i_value];
1413 [o_stepper setAutoresizingMask:NSViewMinXMargin ];
1414 [self addSubview: o_stepper];
1416 /* build the textfield */
1417 if( p_item->psz_value )
1418 o_textfieldString = [[VLCMain sharedInstance]
1419 localizedString: p_item->psz_value];
1421 o_textfieldString = [NSString stringWithString: @""];
1422 ADD_TEXTFIELD( o_textfield, mainFrame, mainFrame.size.width - 19 - 52,
1423 1, 49, o_tooltip, @"" )
1424 [o_textfield setIntValue: p_item->i_value];
1425 [o_textfield setDelegate: self];
1426 [[NSNotificationCenter defaultCenter] addObserver: self
1427 selector: @selector(textfieldChanged:)
1428 name: NSControlTextDidChangeNotification
1429 object: o_textfield];
1430 [o_textfield setAutoresizingMask:NSViewMinXMargin ];
1431 [self addSubview: o_textfield];
1438 [o_stepper release];
1439 [o_textfield release];
1443 - (IBAction)stepperChanged:(id)sender
1445 [o_textfield setIntValue: [o_stepper intValue]];
1448 - (void)textfieldChanged:(NSNotification *)o_notification
1450 [o_stepper setIntValue: [o_textfield intValue]];
1455 return [o_textfield intValue];
1460 @implementation IntegerListConfigControl
1462 - (id) initWithItem: (module_config_t *)_p_item
1463 withView: (NSView *)o_parent_view
1465 NSRect mainFrame = [o_parent_view frame];
1466 NSString *o_labelString, *o_textfieldTooltip;
1467 mainFrame.size.height = 22;
1468 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN + 1;
1469 mainFrame.origin.x = LEFTMARGIN;
1470 mainFrame.origin.y = 0;
1472 if( [super initWithFrame: mainFrame item: _p_item] != nil )
1475 i_view_type = CONFIG_ITEM_STRING_LIST;
1478 if( p_item->psz_text )
1479 o_labelString = [[VLCMain sharedInstance]
1480 localizedString: p_item->psz_text];
1482 o_labelString = [NSString stringWithString:@""];
1483 ADD_LABEL( o_label, mainFrame, 0, -3, o_labelString )
1484 [o_label setAutoresizingMask:NSViewNotSizable ];
1485 [self addSubview: o_label];
1487 /* build the textfield */
1488 o_textfieldTooltip = [[VLCMain sharedInstance] wrapString:
1489 [[VLCMain sharedInstance]
1490 localizedString: p_item->psz_longtext ] toWidth: PREFS_WRAP];
1491 ADD_COMBO( o_combo, mainFrame, [o_label frame].size.width,
1492 -2, 0, o_textfieldTooltip )
1493 [o_combo setAutoresizingMask:NSViewWidthSizable ];
1494 for( i_index = 0; i_index < p_item->i_list; i_index++ )
1496 if( p_item->i_value == p_item->pi_list[i_index] )
1498 [o_combo selectItemAtIndex: i_index];
1501 [self addSubview: o_combo];
1514 if( [o_combo indexOfSelectedItem] >= 0 )
1515 return p_item->pi_list[[o_combo indexOfSelectedItem]];
1517 return [o_combo intValue];
1521 @implementation IntegerListConfigControl (NSComboBoxDataSource)
1522 - (int)numberOfItemsInComboBox:(NSComboBox *)aComboBox
1524 return p_item->i_list;
1527 - (id)comboBox:(NSComboBox *)aComboBox objectValueForItemAtIndex:(int)i_index
1529 if( p_item->ppsz_list_text && p_item->ppsz_list_text[i_index] )
1530 return [[VLCMain sharedInstance]
1531 localizedString: p_item->ppsz_list_text[i_index]];
1533 return [NSString stringWithFormat: @"%i", p_item->pi_list[i_index]];
1537 @implementation RangedIntegerConfigControl
1538 - (id) initWithItem: (module_config_t *)_p_item
1539 withView: (NSView *)o_parent_view
1541 NSRect mainFrame = [o_parent_view frame];
1542 NSString *o_labelString, *o_tooltip;
1543 mainFrame.size.height = 50;
1544 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN;
1545 mainFrame.origin.x = LEFTMARGIN;
1546 mainFrame.origin.y = 0;
1548 if( [super initWithFrame: mainFrame item: _p_item] != nil )
1550 i_view_type = CONFIG_ITEM_RANGED_INTEGER;
1553 if( p_item->psz_text )
1554 o_labelString = [[VLCMain sharedInstance]
1555 localizedString: p_item->psz_text];
1557 o_labelString = [NSString stringWithString:@""];
1558 ADD_LABEL( o_label, mainFrame, 0, -3, o_labelString )
1559 [o_label setAutoresizingMask:NSViewNotSizable ];
1560 [self addSubview: o_label];
1562 /* build the textfield */
1563 o_tooltip = [[VLCMain sharedInstance] wrapString:
1564 [[VLCMain sharedInstance]
1565 localizedString: p_item->psz_longtext ] toWidth: PREFS_WRAP];
1566 ADD_TEXTFIELD( o_textfield, mainFrame, [o_label frame].size.width + 2,
1567 28, 49, o_tooltip, @"" )
1568 [o_textfield setIntValue: p_item->i_value];
1569 [o_textfield setAutoresizingMask:NSViewMaxXMargin ];
1570 [o_textfield setDelegate: self];
1571 [[NSNotificationCenter defaultCenter] addObserver: self
1572 selector: @selector(textfieldChanged:)
1573 name: NSControlTextDidChangeNotification
1574 object: o_textfield];
1575 [self addSubview: o_textfield];
1577 /* build the mintextfield */
1578 ADD_LABEL( o_textfield_min, mainFrame, 12, -30, @"-8888" )
1579 [o_textfield_min setIntValue: p_item->i_min];
1580 [o_textfield_min setAutoresizingMask:NSViewMaxXMargin ];
1581 [self addSubview: o_textfield_min];
1583 /* build the maxtextfield */
1584 ADD_LABEL( o_textfield_max, mainFrame,
1585 mainFrame.size.width - 31, -30, @"8888" )
1586 [o_textfield_max setIntValue: p_item->i_max];
1587 [o_textfield_max setAutoresizingMask:NSViewMinXMargin ];
1588 [self addSubview: o_textfield_max];
1590 /* build the slider */
1591 ADD_SLIDER( o_slider, mainFrame, [o_textfield_min frame].origin.x +
1592 [o_textfield_min frame].size.width + 6, -1, mainFrame.size.width -
1593 [o_textfield_max frame].size.width -
1594 [o_textfield_max frame].size.width - 14 -
1595 [o_textfield_min frame].origin.x, o_tooltip,
1596 p_item->i_min, p_item->i_max )
1597 [o_slider setIntValue: p_item->i_value];
1598 [o_slider setAutoresizingMask:NSViewWidthSizable ];
1599 [o_slider setTarget: self];
1600 [o_slider setAction: @selector(sliderChanged:)];
1601 [o_slider sendActionOn:NSLeftMouseUpMask | NSLeftMouseDownMask |
1602 NSLeftMouseDraggedMask];
1603 [self addSubview: o_slider];
1611 [o_textfield release];
1612 [o_textfield_min release];
1613 [o_textfield_max release];
1618 - (IBAction)sliderChanged:(id)sender
1620 [o_textfield setIntValue: [o_slider intValue]];
1623 - (void)textfieldChanged:(NSNotification *)o_notification
1625 [o_slider setIntValue: [o_textfield intValue]];
1630 return [o_slider intValue];
1634 @implementation FloatConfigControl
1635 - (id) initWithItem: (module_config_t *)_p_item
1636 withView: (NSView *)o_parent_view
1638 NSRect mainFrame = [o_parent_view frame];
1639 NSString *o_labelString, *o_tooltip, *o_textfieldString;
1640 mainFrame.size.height = 23;
1641 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN + 1;
1642 mainFrame.origin.x = LEFTMARGIN;
1643 mainFrame.origin.y = 0;
1645 if( [super initWithFrame: mainFrame item: _p_item] != nil )
1647 i_view_type = CONFIG_ITEM_INTEGER;
1649 o_tooltip = [[VLCMain sharedInstance] wrapString:
1650 [[VLCMain sharedInstance]
1651 localizedString: p_item->psz_longtext ] toWidth: PREFS_WRAP];
1654 if( p_item->psz_text )
1655 o_labelString = [[VLCMain sharedInstance]
1656 localizedString: p_item->psz_text];
1658 o_labelString = [NSString stringWithString:@""];
1659 ADD_LABEL( o_label, mainFrame, 0, -2, o_labelString )
1660 [o_label setAutoresizingMask:NSViewNotSizable ];
1661 [self addSubview: o_label];
1663 /* build the stepper */
1664 ADD_STEPPER( o_stepper, mainFrame, mainFrame.size.width - 19,
1665 0, o_tooltip, -1600, 1600)
1666 [o_stepper setFloatValue: p_item->f_value];
1667 [o_stepper setAutoresizingMask:NSViewMinXMargin ];
1668 [self addSubview: o_stepper];
1670 /* build the textfield */
1671 if( p_item->psz_value )
1672 o_textfieldString = [[VLCMain sharedInstance]
1673 localizedString: p_item->psz_value];
1675 o_textfieldString = [NSString stringWithString: @""];
1676 ADD_TEXTFIELD( o_textfield, mainFrame, mainFrame.size.width - 19 - 52,
1677 1, 49, o_tooltip, @"" )
1678 [o_textfield setFloatValue: p_item->f_value];
1679 [o_textfield setDelegate: self];
1680 [[NSNotificationCenter defaultCenter] addObserver: self
1681 selector: @selector(textfieldChanged:)
1682 name: NSControlTextDidChangeNotification
1683 object: o_textfield];
1684 [o_textfield setAutoresizingMask:NSViewMinXMargin ];
1685 [self addSubview: o_textfield];
1692 [o_stepper release];
1693 [o_textfield release];
1697 - (IBAction)stepperChanged:(id)sender
1699 [o_textfield setFloatValue: [o_stepper floatValue]];
1702 - (void)textfieldChanged:(NSNotification *)o_notification
1704 [o_stepper setFloatValue: [o_textfield floatValue]];
1709 return [o_stepper floatValue];
1713 @implementation RangedFloatConfigControl
1714 - (id) initWithItem: (module_config_t *)_p_item
1715 withView: (NSView *)o_parent_view
1717 NSRect mainFrame = [o_parent_view frame];
1718 NSString *o_labelString, *o_tooltip;
1719 mainFrame.size.height = 50;
1720 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN;
1721 mainFrame.origin.x = LEFTMARGIN;
1722 mainFrame.origin.y = 0;
1724 if( [super initWithFrame: mainFrame item: _p_item] != nil )
1726 i_view_type = CONFIG_ITEM_RANGED_INTEGER;
1729 if( p_item->psz_text )
1730 o_labelString = [[VLCMain sharedInstance]
1731 localizedString: p_item->psz_text];
1733 o_labelString = [NSString stringWithString:@""];
1734 ADD_LABEL( o_label, mainFrame, 0, -3, o_labelString )
1735 [o_label setAutoresizingMask:NSViewNotSizable ];
1736 [self addSubview: o_label];
1738 /* build the textfield */
1739 o_tooltip = [[VLCMain sharedInstance] wrapString:
1740 [[VLCMain sharedInstance]
1741 localizedString: p_item->psz_longtext ] toWidth: PREFS_WRAP];
1742 ADD_TEXTFIELD( o_textfield, mainFrame, [o_label frame].size.width + 2,
1743 28, 49, o_tooltip, @"" )
1744 [o_textfield setFloatValue: p_item->f_value];
1745 [o_textfield setAutoresizingMask:NSViewMaxXMargin ];
1746 [o_textfield setDelegate: self];
1747 [[NSNotificationCenter defaultCenter] addObserver: self
1748 selector: @selector(textfieldChanged:)
1749 name: NSControlTextDidChangeNotification
1750 object: o_textfield];
1751 [self addSubview: o_textfield];
1753 /* build the mintextfield */
1754 ADD_LABEL( o_textfield_min, mainFrame, 12, -30, @"-8888" )
1755 [o_textfield_min setFloatValue: p_item->f_min];
1756 [o_textfield_min setAutoresizingMask:NSViewMaxXMargin ];
1757 [self addSubview: o_textfield_min];
1759 /* build the maxtextfield */
1760 ADD_LABEL( o_textfield_max, mainFrame, mainFrame.size.width - 31,
1762 [o_textfield_max setFloatValue: p_item->f_max];
1763 [o_textfield_max setAutoresizingMask:NSViewMinXMargin ];
1764 [self addSubview: o_textfield_max];
1766 /* build the slider */
1767 ADD_SLIDER( o_slider, mainFrame, [o_textfield_min frame].origin.x +
1768 [o_textfield_min frame].size.width + 6, -1, mainFrame.size.width -
1769 [o_textfield_max frame].size.width -
1770 [o_textfield_max frame].size.width - 14 -
1771 [o_textfield_min frame].origin.x, o_tooltip, p_item->f_min,
1773 [o_slider setFloatValue: p_item->f_value];
1774 [o_slider setAutoresizingMask:NSViewWidthSizable ];
1775 [o_slider setTarget: self];
1776 [o_slider setAction: @selector(sliderChanged:)];
1777 [o_slider sendActionOn:NSLeftMouseUpMask | NSLeftMouseDownMask |
1778 NSLeftMouseDraggedMask];
1779 [self addSubview: o_slider];
1787 [o_textfield release];
1788 [o_textfield_min release];
1789 [o_textfield_max release];
1794 - (IBAction)sliderChanged:(id)sender
1796 [o_textfield setFloatValue: [o_slider floatValue]];
1799 - (void)textfieldChanged:(NSNotification *)o_notification
1801 [o_slider setFloatValue: [o_textfield floatValue]];
1806 return [o_slider floatValue];
1811 @implementation BoolConfigControl
1813 - (id) initWithItem: (module_config_t *)_p_item
1814 withView: (NSView *)o_parent_view
1816 NSRect mainFrame = [o_parent_view frame];
1817 NSString *o_labelString, *o_tooltip;
1818 mainFrame.size.height = 17;
1819 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN;
1820 mainFrame.origin.x = LEFTMARGIN;
1821 mainFrame.origin.y = 0;
1823 if( [super initWithFrame: mainFrame item: _p_item] != nil )
1825 i_view_type = CONFIG_ITEM_BOOL;
1827 /* add the checkbox */
1828 if( p_item->psz_text )
1829 o_labelString = [[VLCMain sharedInstance]
1830 localizedString: p_item->psz_text];
1832 o_labelString = [NSString stringWithString:@""];
1833 o_tooltip = [[VLCMain sharedInstance]
1834 wrapString: [[VLCMain sharedInstance]
1835 localizedString: p_item->psz_longtext ] toWidth: PREFS_WRAP];
1836 ADD_CHECKBOX( o_checkbox, mainFrame, 0, 0, o_labelString,
1837 o_tooltip, p_item->i_value, NSImageRight)
1838 [o_checkbox setAutoresizingMask:NSViewNotSizable ];
1839 [self addSubview: o_checkbox];
1846 [o_checkbox release];
1852 return [o_checkbox intValue];
1857 @implementation KeyConfigControlBefore103
1859 - (id) initWithItem: (module_config_t *)_p_item
1860 withView: (NSView *)o_parent_view
1862 NSRect mainFrame = [o_parent_view frame];
1863 NSString *o_labelString, *o_tooltip;
1864 mainFrame.size.height = 37;
1865 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN + 1;
1866 mainFrame.origin.x = LEFTMARGIN;
1867 mainFrame.origin.y = 0;
1869 if( [super initWithFrame: mainFrame item: _p_item] != nil )
1871 i_view_type = CONFIG_ITEM_KEY_BEFORE_10_3;
1874 if( p_item->psz_text )
1875 o_labelString = [[VLCMain sharedInstance]
1876 localizedString: p_item->psz_text];
1878 o_labelString = [NSString stringWithString:@""];
1879 ADD_LABEL( o_label, mainFrame, 0, -10, o_labelString )
1880 [o_label setAutoresizingMask:NSViewNotSizable ];
1881 [self addSubview: o_label];
1883 /* add the checkboxes */
1884 o_tooltip = [[VLCMain sharedInstance] wrapString:
1885 [[VLCMain sharedInstance]
1886 localizedString: p_item->psz_longtext ] toWidth: PREFS_WRAP];
1887 ADD_CHECKBOX( o_cmd_checkbox, mainFrame,
1888 [o_label frame].size.width + 2, 0,
1889 [NSString stringWithUTF8String:PLACE_OF_INTEREST_SIGN], o_tooltip,
1890 ((((unsigned int)p_item->i_value) & KEY_MODIFIER_COMMAND)?YES:NO),
1892 [o_cmd_checkbox setState: p_item->i_value & KEY_MODIFIER_COMMAND];
1893 ADD_CHECKBOX( o_ctrl_checkbox, mainFrame,
1894 [o_cmd_checkbox frame].size.width +
1895 [o_cmd_checkbox frame].origin.x + 6, 0,
1896 [NSString stringWithUTF8String:UP_ARROWHEAD], o_tooltip,
1897 ((((unsigned int)p_item->i_value) & KEY_MODIFIER_CTRL)?YES:NO),
1899 [o_ctrl_checkbox setState: p_item->i_value & KEY_MODIFIER_CTRL];
1900 ADD_CHECKBOX( o_alt_checkbox, mainFrame, [o_label frame].size.width +
1901 2, -2 - [o_cmd_checkbox frame].size.height,
1902 [NSString stringWithUTF8String:OPTION_KEY], o_tooltip,
1903 ((((unsigned int)p_item->i_value) & KEY_MODIFIER_ALT)?YES:NO),
1905 [o_alt_checkbox setState: p_item->i_value & KEY_MODIFIER_ALT];
1906 ADD_CHECKBOX( o_shift_checkbox, mainFrame,
1907 [o_cmd_checkbox frame].size.width +
1908 [o_cmd_checkbox frame].origin.x + 6, -2 -
1909 [o_cmd_checkbox frame].size.height,
1910 [NSString stringWithUTF8String:UPWARDS_WHITE_ARROW], o_tooltip,
1911 ((((unsigned int)p_item->i_value) & KEY_MODIFIER_SHIFT)?YES:NO),
1913 [o_shift_checkbox setState: p_item->i_value & KEY_MODIFIER_SHIFT];
1914 [self addSubview: o_cmd_checkbox];
1915 [self addSubview: o_ctrl_checkbox];
1916 [self addSubview: o_alt_checkbox];
1917 [self addSubview: o_shift_checkbox];
1919 /* build the popup */
1920 ADD_POPUP( o_popup, mainFrame, [o_shift_checkbox frame].origin.x +
1921 [o_shift_checkbox frame].size.width + 4,
1923 [o_popup setAutoresizingMask:NSViewWidthSizable ];
1925 if( o_keys_menu == nil )
1928 o_keys_menu = [[NSMenu alloc] initWithTitle: @"Keys Menu"];
1929 for ( i = 0; i < sizeof(vlc_keys) / sizeof(key_descriptor_t); i++)
1930 if( vlc_keys[i].psz_key_string && *vlc_keys[i].psz_key_string )
1931 POPULATE_A_KEY( o_keys_menu,
1932 [NSString stringWithCString:vlc_keys[i].psz_key_string]
1933 , vlc_keys[i].i_key_code)
1935 [o_popup setMenu:[o_keys_menu copyWithZone:nil]];
1936 [o_popup selectItemWithTitle: [[VLCMain sharedInstance]
1937 localizedString:KeyToString(
1938 (((unsigned int)p_item->i_value) & ~KEY_MODIFIER ))]];
1939 [self addSubview: o_popup];
1946 [o_cmd_checkbox release];
1947 [o_ctrl_checkbox release];
1948 [o_alt_checkbox release];
1949 [o_shift_checkbox release];
1956 unsigned int i_new_key = 0;
1958 i_new_key |= ([o_cmd_checkbox state] == NSOnState) ?
1959 KEY_MODIFIER_COMMAND : 0;
1960 i_new_key |= ([o_ctrl_checkbox state] == NSOnState) ?
1961 KEY_MODIFIER_CTRL : 0;
1962 i_new_key |= ([o_alt_checkbox state] == NSOnState) ?
1963 KEY_MODIFIER_ALT : 0;
1964 i_new_key |= ([o_shift_checkbox state] == NSOnState) ?
1965 KEY_MODIFIER_SHIFT : 0;
1967 i_new_key |= StringToKey([[[o_popup selectedItem] title] cString]);
1972 @implementation KeyConfigControlAfter103
1973 - (id) initWithItem: (module_config_t *)_p_item
1974 withView: (NSView *)o_parent_view
1976 NSRect mainFrame = [o_parent_view frame];
1977 NSString *o_labelString, *o_tooltip;
1978 mainFrame.size.height = 22;
1979 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN + 1;
1980 mainFrame.origin.x = LEFTMARGIN;
1981 mainFrame.origin.y = 0;
1983 if( [super initWithFrame: mainFrame item: _p_item] != nil )
1985 i_view_type = CONFIG_ITEM_KEY_AFTER_10_3;
1988 if( p_item->psz_text )
1989 o_labelString = [[VLCMain sharedInstance]
1990 localizedString: p_item->psz_text];
1992 o_labelString = [NSString stringWithString:@""];
1993 ADD_LABEL( o_label, mainFrame, 0, -1, o_labelString )
1994 [o_label setAutoresizingMask:NSViewNotSizable ];
1995 [self addSubview: o_label];
1997 /* build the popup */
1998 o_tooltip = [[VLCMain sharedInstance] wrapString:
1999 [[VLCMain sharedInstance]
2000 localizedString: p_item->psz_longtext ] toWidth: PREFS_WRAP];
2001 ADD_POPUP( o_popup, mainFrame, [o_label frame].origin.x +
2002 [o_label frame].size.width + 3,
2004 [o_popup setAutoresizingMask:NSViewWidthSizable ];
2006 if( o_keys_menu == nil )
2009 o_keys_menu = [[NSMenu alloc] initWithTitle: @"Keys Menu"];
2010 for ( i = 0; i < sizeof(vlc_keys) / sizeof(key_descriptor_t); i++)
2011 if( vlc_keys[i].psz_key_string && *vlc_keys[i].psz_key_string )
2012 POPULATE_A_KEY( o_keys_menu,
2013 [NSString stringWithCString:vlc_keys[i].psz_key_string]
2014 , vlc_keys[i].i_key_code)
2016 [o_popup setMenu:[o_keys_menu copyWithZone:nil]];
2017 [o_popup selectItemWithTag: p_item->i_value];
2018 [self addSubview: o_popup];
2032 return [o_popup selectedTag];
2036 @implementation ModuleListConfigControl
2037 - (id) initWithItem: (module_config_t *)_p_item
2038 withView: (NSView *)o_parent_view
2040 if( _p_item->i_type == CONFIG_ITEM_MODULE_LIST )
2044 //Fill our array to know how may items we have...
2048 NSRect mainFrame = [o_parent_view frame];
2049 NSString *o_labelString, *o_textfieldString, *o_tooltip;
2051 o_modulearray = [[NSMutableArray alloc] initWithCapacity:10];
2052 /* build a list of available modules */
2053 p_list = vlc_list_find( VLCIntf, VLC_OBJECT_MODULE, FIND_ANYWHERE );
2054 for( i_index = 0; i_index < p_list->i_count; i_index++ )
2056 p_parser = (module_t *)p_list->p_values[i_index].p_object ;
2058 if( !strcmp( p_parser->psz_object_name, "main" ) )
2061 module_config_t *p_config = p_parser->p_config;
2064 NSString *o_modulelongname, *o_modulename;
2065 NSNumber *o_moduleenabled = nil;
2066 /* Hack: required subcategory is stored in i_min */
2067 if( p_config->i_type == CONFIG_SUBCATEGORY &&
2068 p_config->i_value == _p_item->i_min )
2070 o_modulelongname = [NSString stringWithCString:
2071 p_parser->psz_longname];
2072 o_modulename = [NSString stringWithCString:
2073 p_parser->psz_object_name];
2075 if( _p_item->psz_value &&
2076 strstr( _p_item->psz_value, p_parser->psz_object_name ) )
2077 o_moduleenabled = [NSNumber numberWithBool:YES];
2079 o_moduleenabled = [NSNumber numberWithBool:NO];
2081 [o_modulearray addObject:[NSMutableArray
2082 arrayWithObjects: o_modulename, o_modulelongname,
2083 o_moduleenabled, nil]];
2085 } while( p_config->i_type != CONFIG_HINT_END && p_config++ );
2087 vlc_list_release( p_list );
2089 mainFrame.size.height = 30 + 18 * [o_modulearray count];
2090 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN;
2091 mainFrame.origin.x = LEFTMARGIN;
2092 mainFrame.origin.y = 0;
2093 if( [super initWithFrame: mainFrame item: _p_item] != nil )
2095 i_view_type = CONFIG_ITEM_MODULE_LIST;
2098 if( p_item->psz_text )
2099 o_labelString = [[VLCMain sharedInstance]
2100 localizedString: p_item->psz_text];
2102 o_labelString = [NSString stringWithString:@""];
2103 ADD_LABEL( o_label, mainFrame, 0, -3, o_labelString )
2104 [o_label setAutoresizingMask:NSViewNotSizable ];
2105 [self addSubview: o_label];
2107 /* build the textfield */
2108 o_tooltip = [[VLCMain sharedInstance] wrapString:
2109 [[VLCMain sharedInstance]
2110 localizedString: p_item->psz_longtext ] toWidth: PREFS_WRAP];
2111 if( p_item->psz_value )
2112 o_textfieldString = [[VLCMain sharedInstance]
2113 localizedString: p_item->psz_value];
2115 o_textfieldString = [NSString stringWithString: @""];
2116 ADD_TEXTFIELD( o_textfield, mainFrame, [o_label frame].size.width + 2,
2117 mainFrame.size.height - 22, mainFrame.size.width -
2118 [o_label frame].size.width - 2, o_tooltip, o_textfieldString )
2119 [o_textfield setAutoresizingMask:NSViewWidthSizable ];
2120 [self addSubview: o_textfield];
2124 NSRect s_rc = mainFrame;
2125 s_rc.size.height = mainFrame.size.height - 30;
2126 s_rc.size.width = mainFrame.size.width - 12;
2129 o_scrollview = [[[NSScrollView alloc] initWithFrame: s_rc] retain];
2130 [o_scrollview setDrawsBackground: NO];
2131 [o_scrollview setBorderType: NSBezelBorder];
2132 [o_scrollview setAutohidesScrollers:YES];
2134 NSTableView *o_tableview;
2135 o_tableview = [[NSTableView alloc] initWithFrame : s_rc];
2136 [o_tableview setUsesAlternatingRowBackgroundColors:YES];
2137 [o_tableview setHeaderView:nil];
2138 /* TODO: find a good way to fix the row height and text size*/
2139 /* FIXME: support for multiple selection... */
2140 // [o_tableview setAllowsMultipleSelection:YES];
2142 NSCell *o_headerCell = [[NSCell alloc] initTextCell:@"Enabled"];
2143 NSCell *o_dataCell = [[NSButtonCell alloc] init];
2144 [(NSButtonCell*)o_dataCell setButtonType:NSSwitchButton];
2145 [o_dataCell setTitle:@""];
2146 [o_dataCell setFont:[NSFont systemFontOfSize:0]];
2147 NSTableColumn *o_tableColumn = [[NSTableColumn alloc]
2148 initWithIdentifier:[NSString stringWithCString: "Enabled"]];
2149 [o_tableColumn setHeaderCell: o_headerCell];
2150 [o_tableColumn setDataCell: o_dataCell];
2151 [o_tableColumn setWidth:17];
2152 [o_tableview addTableColumn: o_tableColumn];
2154 o_headerCell = [[NSCell alloc] initTextCell:@"Module Name"];
2155 o_dataCell = [[NSTextFieldCell alloc] init];
2156 [o_dataCell setFont:[NSFont systemFontOfSize:12]];
2157 o_tableColumn = [[NSTableColumn alloc]
2158 initWithIdentifier:[NSString stringWithCString: "Module"]];
2159 [o_tableColumn setHeaderCell: o_headerCell];
2160 [o_tableColumn setDataCell: o_dataCell];
2161 [o_tableColumn setWidth:388 - 17];
2162 [o_tableview addTableColumn: o_tableColumn];
2163 [o_tableview registerForDraggedTypes:[NSArray arrayWithObjects:
2164 @"VLC media player module", nil]];
2166 [o_tableview setDataSource:self];
2167 [o_tableview setTarget: self];
2168 [o_tableview setAction: @selector(tableChanged:)];
2169 [o_tableview sendActionOn:NSLeftMouseUpMask | NSLeftMouseDownMask |
2170 NSLeftMouseDraggedMask];
2171 [o_scrollview setDocumentView: o_tableview];
2173 [o_scrollview setAutoresizingMask:NSViewWidthSizable ];
2174 [self addSubview: o_scrollview];
2181 - (IBAction)tableChanged:(id)sender
2183 NSString *o_newstring = @"";
2185 for( i = 0 ; i < [o_modulearray count] ; i++ )
2186 if( [[[o_modulearray objectAtIndex:i] objectAtIndex:2]
2189 o_newstring = [o_newstring stringByAppendingString:
2190 [[o_modulearray objectAtIndex:i] objectAtIndex:0]];
2191 o_newstring = [o_newstring stringByAppendingString:@","];
2194 [o_textfield setStringValue: [o_newstring
2195 substringToIndex: ([o_newstring length])?[o_newstring length] - 1:0]];
2200 [o_scrollview release];
2205 - (char *)stringValue
2207 return strdup( [[o_textfield stringValue] cString] );
2212 @implementation ModuleListConfigControl (NSTableDataSource)
2214 - (BOOL)tableView:(NSTableView*)table writeRows:(NSArray*)rows
2215 toPasteboard:(NSPasteboard*)pb
2217 // We only want to allow dragging of selected rows.
2218 NSEnumerator *iter = [rows objectEnumerator];
2220 while ((row = [iter nextObject]) != nil)
2222 if (![table isRowSelected:[row intValue]])
2226 [pb declareTypes:[NSArray
2227 arrayWithObject:@"VLC media player module"] owner:nil];
2228 [pb setPropertyList:rows forType:@"VLC media player module"];
2232 - (NSDragOperation)tableView:(NSTableView*)table
2233 validateDrop:(id <NSDraggingInfo>)info proposedRow:(int)row
2234 proposedDropOperation:(NSTableViewDropOperation)op
2236 // Make drops at the end of the table go to the end.
2239 row = [table numberOfRows];
2240 op = NSTableViewDropAbove;
2241 [table setDropRow:row dropOperation:op];
2244 // We don't ever want to drop onto a row, only between rows.
2245 if (op == NSTableViewDropOn)
2246 [table setDropRow:(row+1) dropOperation:NSTableViewDropAbove];
2247 return NSTableViewDropAbove;
2250 - (BOOL)tableView:(NSTableView*)table acceptDrop:(id <NSDraggingInfo>)info
2251 row:(int)dropRow dropOperation:(NSTableViewDropOperation)op;
2253 NSPasteboard *pb = [info draggingPasteboard];
2254 NSDragOperation srcMask = [info draggingSourceOperationMask];
2261 // Intra-table drag - data is the array of rows.
2262 if (!accepted && (array =
2263 [pb propertyListForType:@"VLC media player module"]) != NULL)
2265 NSEnumerator *iter = nil;
2267 BOOL isCopy = (srcMask & NSDragOperationMove) ? NO:YES;
2269 iter = [array objectEnumerator];
2270 while ((val = [iter nextObject]) != NULL)
2272 NSArray *o_tmp = [[o_modulearray objectAtIndex:
2273 [val intValue]] mutableCopyWithZone:nil];
2274 [o_modulearray removeObject:o_tmp];
2275 [o_modulearray insertObject:o_tmp
2276 atIndex:(dropRow>[val intValue]) ? dropRow - 1 : dropRow];
2280 // Select the newly-dragged items.
2281 iter = [array objectEnumerator];
2283 [table deselectAll:self];
2285 [self tableChanged:self];
2286 [table setNeedsDisplay:YES];
2287 // Indicate that we finished the drag.
2291 [table setNeedsDisplay:YES];
2295 // An exception occurred. Uh-oh. Update the track table so that
2296 // it stays consistent, and re-raise the exception.
2298 [localException raise];
2299 [table setNeedsDisplay:YES];
2305 - (int)numberOfRowsInTableView:(NSTableView *)aTableView
2307 return [o_modulearray count];
2310 - (id)tableView:(NSTableView *)aTableView
2311 objectValueForTableColumn:(NSTableColumn *)aTableColumn row:(int)rowIndex
2313 if( [[aTableColumn identifier] isEqualToString:
2314 [NSString stringWithCString:"Enabled"]] )
2315 return [[o_modulearray objectAtIndex:rowIndex] objectAtIndex:2];
2316 if( [[aTableColumn identifier] isEqualToString:
2317 [NSString stringWithCString:"Module"]] )
2318 return [[o_modulearray objectAtIndex:rowIndex] objectAtIndex:1];
2323 - (void)tableView:(NSTableView *)aTableView setObjectValue:(id)anObject
2324 forTableColumn:(NSTableColumn *)aTableColumn row:(int)rowIndex
2326 [[o_modulearray objectAtIndex:rowIndex] replaceObjectAtIndex:2
2327 withObject: anObject];