1 /*****************************************************************************
2 * prefs_widgets.m: Preferences controls
3 *****************************************************************************
4 * Copyright (C) 2002-2012 VLC authors and 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., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
23 *****************************************************************************/
25 /*****************************************************************************
27 *****************************************************************************/
28 #include <stdlib.h> /* malloc(), free() */
35 #include <vlc_common.h>
36 #include <vlc_modules.h>
37 #include <vlc_plugin.h>
41 #include "prefs_widgets.h"
43 #define PREFS_WRAP 300
44 #define OFFSET_RIGHT 20
45 #define OFFSET_BETWEEN 2
47 #define UPWARDS_WHITE_ARROW "\xE2\x87\xA7"
48 #define OPTION_KEY "\xE2\x8C\xA5"
49 #define UP_ARROWHEAD "\xE2\x8C\x83"
50 #define PLACE_OF_INTEREST_SIGN "\xE2\x8C\x98"
52 #define POPULATE_A_KEY(o_menu, string, value) \
56 o_mi = [[NSMenuItem alloc] initWithTitle:string \
57 action:nil keyEquivalent:@""]; \
58 [o_mi setKeyEquivalentModifierMask: \
60 [o_mi setAlternate: NO]; \
63 [o_menu addItem: o_mi]; \
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) | \
124 [o_menu addItem: o_mi]; \
125 /* Ctrl+Alt+Apple */ \
126 o_mi = [[NSMenuItem alloc] initWithTitle: \
127 [[NSString stringWithUTF8String: \
128 UP_ARROWHEAD OPTION_KEY PLACE_OF_INTEREST_SIGN \
129 ] stringByAppendingString: string] \
130 action:nil keyEquivalent:@""]; \
131 [o_mi setKeyEquivalentModifierMask: \
132 NSControlKeyMask | NSAlternateKeyMask | NSCommandKeyMask]; \
133 [o_mi setAlternate: YES]; \
135 (KEY_MODIFIER_CTRL | KEY_MODIFIER_ALT | KEY_MODIFIER_COMMAND) | \
137 [o_menu addItem: o_mi]; \
138 /* Ctrl+Shift+Apple */ \
139 o_mi = [[NSMenuItem alloc] initWithTitle: \
140 [[NSString stringWithUTF8String: \
141 UP_ARROWHEAD UPWARDS_WHITE_ARROW PLACE_OF_INTEREST_SIGN \
142 ] stringByAppendingString: string] \
143 action:nil keyEquivalent:@""]; \
144 [o_mi setKeyEquivalentModifierMask: \
145 NSControlKeyMask | NSShiftKeyMask | NSCommandKeyMask]; \
146 [o_mi setAlternate: YES]; \
148 (KEY_MODIFIER_CTRL | KEY_MODIFIER_SHIFT | KEY_MODIFIER_COMMAND) | \
150 [o_menu addItem: o_mi]; \
151 /* Ctrl+Alt+Shift+Apple */ \
152 o_mi = [[NSMenuItem alloc] initWithTitle: \
153 [[NSString stringWithUTF8String: \
154 UP_ARROWHEAD OPTION_KEY UPWARDS_WHITE_ARROW \
155 PLACE_OF_INTEREST_SIGN \
156 ] stringByAppendingString: string] \
157 action:nil keyEquivalent:@""]; \
158 [o_mi setKeyEquivalentModifierMask: \
159 NSControlKeyMask | NSAlternateKeyMask | NSShiftKeyMask | \
161 [o_mi setAlternate: YES]; \
163 (KEY_MODIFIER_CTRL | KEY_MODIFIER_ALT | KEY_MODIFIER_SHIFT | \
164 KEY_MODIFIER_COMMAND) | (value)]; \
165 [o_menu addItem: o_mi]; \
167 o_mi = [[NSMenuItem alloc] initWithTitle: \
168 [[NSString stringWithUTF8String: \
170 ] stringByAppendingString: string] \
171 action:nil keyEquivalent:@""]; \
172 [o_mi setKeyEquivalentModifierMask: \
173 NSAlternateKeyMask]; \
174 [o_mi setAlternate: YES]; \
176 KEY_MODIFIER_ALT | (value)]; \
177 [o_menu addItem: o_mi]; \
179 o_mi = [[NSMenuItem alloc] initWithTitle: \
180 [[NSString stringWithUTF8String: \
181 OPTION_KEY UPWARDS_WHITE_ARROW \
182 ] stringByAppendingString: string] \
183 action:nil keyEquivalent:@""]; \
184 [o_mi setKeyEquivalentModifierMask: \
185 NSAlternateKeyMask | NSShiftKeyMask]; \
186 [o_mi setAlternate: YES]; \
188 (KEY_MODIFIER_ALT | KEY_MODIFIER_SHIFT) | (value)]; \
189 [o_menu addItem: o_mi]; \
191 o_mi = [[NSMenuItem alloc] initWithTitle: \
192 [[NSString stringWithUTF8String: \
193 OPTION_KEY PLACE_OF_INTEREST_SIGN \
194 ] stringByAppendingString: string] \
195 action:nil keyEquivalent:@""]; \
196 [o_mi setKeyEquivalentModifierMask: \
197 NSAlternateKeyMask | NSCommandKeyMask]; \
198 [o_mi setAlternate: YES]; \
200 (KEY_MODIFIER_ALT | KEY_MODIFIER_COMMAND) | (value)]; \
201 [o_menu addItem: o_mi]; \
202 /* Alt+Shift+Apple */ \
203 o_mi = [[NSMenuItem alloc] initWithTitle: \
204 [[NSString stringWithUTF8String: \
205 OPTION_KEY UPWARDS_WHITE_ARROW PLACE_OF_INTEREST_SIGN \
206 ] stringByAppendingString: string] \
207 action:nil keyEquivalent:@""]; \
208 [o_mi setKeyEquivalentModifierMask: \
209 NSAlternateKeyMask | NSShiftKeyMask | NSCommandKeyMask]; \
210 [o_mi setAlternate: YES]; \
212 (KEY_MODIFIER_ALT | KEY_MODIFIER_SHIFT | KEY_MODIFIER_COMMAND) | \
214 [o_menu addItem: o_mi]; \
216 o_mi = [[NSMenuItem alloc] initWithTitle: \
217 [[NSString stringWithUTF8String: \
218 UPWARDS_WHITE_ARROW \
219 ] stringByAppendingString: string] \
220 action:nil keyEquivalent:@""]; \
221 [o_mi setKeyEquivalentModifierMask: \
223 [o_mi setAlternate: YES]; \
225 KEY_MODIFIER_SHIFT | (value)]; \
226 [o_menu addItem: o_mi]; \
228 o_mi = [[NSMenuItem alloc] initWithTitle: \
229 [[NSString stringWithUTF8String: \
230 UPWARDS_WHITE_ARROW PLACE_OF_INTEREST_SIGN \
231 ] stringByAppendingString: string] \
232 action:nil keyEquivalent:@""]; \
233 [o_mi setKeyEquivalentModifierMask: \
234 NSShiftKeyMask | NSCommandKeyMask]; \
235 [o_mi setAlternate: YES]; \
237 (KEY_MODIFIER_SHIFT | KEY_MODIFIER_COMMAND) | (value)]; \
238 [o_menu addItem: o_mi]; \
240 o_mi = [[NSMenuItem alloc] initWithTitle: \
241 [[NSString stringWithUTF8String: \
242 PLACE_OF_INTEREST_SIGN \
243 ] stringByAppendingString: string] \
244 action:nil keyEquivalent:@""]; \
245 [o_mi setKeyEquivalentModifierMask: \
247 [o_mi setAlternate: YES]; \
249 KEY_MODIFIER_COMMAND | (value)]; \
250 [o_menu addItem: o_mi]; \
253 #define ADD_LABEL(o_label, superFrame, x_offset, my_y_offset, label, \
256 NSRect s_rc = superFrame; \
257 s_rc.size.height = 17; \
258 s_rc.origin.x = x_offset - 3; \
259 s_rc.origin.y = superFrame.size.height - 17 + my_y_offset; \
260 o_label = [[[NSTextField alloc] initWithFrame: s_rc] retain]; \
261 [o_label setDrawsBackground: NO]; \
262 [o_label setBordered: NO]; \
263 [o_label setEditable: NO]; \
264 [o_label setSelectable: NO]; \
265 [o_label setStringValue: label]; \
266 [o_label setToolTip: tooltip]; \
267 [o_label setFont:[NSFont systemFontOfSize:0]]; \
268 [o_label sizeToFit]; \
271 #define ADD_TEXTFIELD(o_textfield, superFrame, x_offset, my_y_offset, \
272 my_width, tooltip, init_value) \
274 NSRect s_rc = superFrame; \
275 s_rc.origin.x = x_offset; \
276 s_rc.origin.y = my_y_offset; \
277 s_rc.size.height = 22; \
278 s_rc.size.width = my_width; \
279 o_textfield = [[[NSTextField alloc] initWithFrame: s_rc] retain]; \
280 [o_textfield setFont:[NSFont systemFontOfSize:0]]; \
281 [o_textfield setToolTip: tooltip]; \
282 [o_textfield setStringValue: init_value]; \
285 #define ADD_SECURETEXTFIELD(o_textfield, superFrame, x_offset, my_y_offset, \
286 my_width, tooltip, init_value) \
288 NSRect s_rc = superFrame; \
289 s_rc.origin.x = x_offset; \
290 s_rc.origin.y = my_y_offset; \
291 s_rc.size.height = 22; \
292 s_rc.size.width = my_width; \
293 o_textfield = [[[NSSecureTextField alloc] initWithFrame: s_rc] retain]; \
294 [o_textfield setFont:[NSFont systemFontOfSize:0]]; \
295 [o_textfield setToolTip: tooltip]; \
296 [o_textfield setStringValue: init_value]; \
299 #define ADD_COMBO(o_combo, superFrame, x_offset, my_y_offset, x2_offset, \
302 NSRect s_rc = superFrame; \
303 s_rc.origin.x = x_offset + 2; \
304 s_rc.origin.y = my_y_offset; \
305 s_rc.size.height = 26; \
306 s_rc.size.width = superFrame.size.width + 2 - s_rc.origin.x - \
308 o_combo = [[[NSComboBox alloc] initWithFrame: s_rc] retain]; \
309 [o_combo setFont:[NSFont systemFontOfSize:0]]; \
310 [o_combo setToolTip: tooltip]; \
311 [o_combo setUsesDataSource:TRUE]; \
312 [o_combo setDataSource:self]; \
313 [o_combo setNumberOfVisibleItems:10]; \
314 [o_combo setCompletes:YES]; \
317 #define ADD_RIGHT_BUTTON(o_button, superFrame, x_offset, my_y_offset, \
320 NSRect s_rc = superFrame; \
321 o_button = [[[NSButton alloc] initWithFrame: s_rc] retain]; \
322 [o_button setButtonType: NSMomentaryPushInButton]; \
323 [o_button setBezelStyle: NSRoundedBezelStyle]; \
324 [o_button setTitle: title]; \
325 [o_button setFont:[NSFont systemFontOfSize:0]]; \
326 [o_button sizeToFit]; \
327 s_rc = [o_button frame]; \
328 s_rc.origin.x = superFrame.size.width - [o_button frame].size.width - 6;\
329 s_rc.origin.y = my_y_offset - 6; \
330 s_rc.size.width += 12; \
331 [o_button setFrame: s_rc]; \
332 [o_button setToolTip: tooltip]; \
333 [o_button setTarget: self]; \
334 [o_button setAction: @selector(openFileDialog:)]; \
337 #define ADD_POPUP(o_popup, superFrame, x_offset, my_y_offset, x2_offset, \
340 NSRect s_rc = superFrame; \
341 s_rc.origin.x = x_offset - 1; \
342 s_rc.origin.y = my_y_offset; \
343 s_rc.size.height = 26; \
344 s_rc.size.width = superFrame.size.width + 2 - s_rc.origin.x - \
346 o_popup = [[[NSPopUpButton alloc] initWithFrame: s_rc] retain]; \
347 [o_popup setFont:[NSFont systemFontOfSize:0]]; \
348 [o_popup setToolTip: tooltip]; \
351 #define ADD_STEPPER(o_stepper, superFrame, x_offset, my_y_offset, tooltip, \
354 NSRect s_rc = superFrame; \
355 s_rc.origin.x = x_offset; \
356 s_rc.origin.y = my_y_offset; \
357 s_rc.size.height = 23; \
358 s_rc.size.width = 23; \
359 o_stepper = [[[NSStepper alloc] initWithFrame: s_rc] retain]; \
360 [o_stepper setFont:[NSFont systemFontOfSize:0]]; \
361 [o_stepper setToolTip: tooltip]; \
362 [o_stepper setMaxValue: higher]; \
363 [o_stepper setMinValue: lower]; \
364 [o_stepper setTarget: self]; \
365 [o_stepper setAction: @selector(stepperChanged:)]; \
366 [o_stepper sendActionOn:NSLeftMouseUpMask | NSLeftMouseDownMask | \
367 NSLeftMouseDraggedMask]; \
370 #define ADD_SLIDER(o_slider, superFrame, x_offset, my_y_offset, my_width, \
371 tooltip, lower, higher) \
373 NSRect s_rc = superFrame; \
374 s_rc.origin.x = x_offset; \
375 s_rc.origin.y = my_y_offset; \
376 s_rc.size.height = 21; \
377 s_rc.size.width = my_width; \
378 o_slider = [[[NSSlider alloc] initWithFrame: s_rc] retain]; \
379 [o_slider setFont:[NSFont systemFontOfSize:0]]; \
380 [o_slider setToolTip: tooltip]; \
381 [o_slider setMaxValue: higher]; \
382 [o_slider setMinValue: lower]; \
385 #define ADD_CHECKBOX(o_checkbox, superFrame, x_offset, my_y_offset, label, \
386 tooltip, init_value, position) \
388 NSRect s_rc = superFrame; \
389 s_rc.size.height = 18; \
390 s_rc.origin.x = x_offset - 2; \
391 s_rc.origin.y = superFrame.size.height - 18 + my_y_offset; \
392 o_checkbox = [[[NSButton alloc] initWithFrame: s_rc] retain]; \
393 [o_checkbox setFont:[NSFont systemFontOfSize:0]]; \
394 [o_checkbox setButtonType: NSSwitchButton]; \
395 [o_checkbox setImagePosition: position]; \
396 [o_checkbox setIntValue: init_value]; \
397 [o_checkbox setTitle: label]; \
398 [o_checkbox setToolTip: tooltip]; \
399 [o_checkbox sizeToFit]; \
402 @implementation VLCConfigControl
403 @synthesize type = i_type, viewType = i_view_type, advanced = b_advanced;
405 - (id)initWithFrame: (NSRect)frame
407 return [self initWithFrame: frame
411 - (id)initWithFrame: (NSRect)frame
412 item: (module_config_t *)_p_item
414 self = [super initWithFrame: frame];
418 psz_name = 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];
442 + (int)calcVerticalMargin: (int)i_curItem lastItem: (int)i_lastItem
446 case CONFIG_ITEM_STRING:
447 case CONFIG_ITEM_PASSWORD:
449 case CONFIG_ITEM_STRING:
450 case CONFIG_ITEM_PASSWORD:
453 case CONFIG_ITEM_STRING_LIST:
456 case CONFIG_ITEM_LOADFILE:
457 case CONFIG_ITEM_SAVEFILE:
460 case CONFIG_ITEM_MODULE:
463 case CONFIG_ITEM_INTEGER:
466 case CONFIG_ITEM_RANGED_INTEGER:
469 case CONFIG_ITEM_BOOL:
472 case CONFIG_ITEM_KEY:
475 case CONFIG_ITEM_MODULE_LIST:
483 case CONFIG_ITEM_STRING_LIST:
485 case CONFIG_ITEM_STRING:
486 case CONFIG_ITEM_PASSWORD:
489 case CONFIG_ITEM_STRING_LIST:
492 case CONFIG_ITEM_LOADFILE:
493 case CONFIG_ITEM_SAVEFILE:
496 case CONFIG_ITEM_MODULE:
499 case CONFIG_ITEM_INTEGER:
502 case CONFIG_ITEM_RANGED_INTEGER:
505 case CONFIG_ITEM_BOOL:
508 case CONFIG_ITEM_KEY:
511 case CONFIG_ITEM_MODULE_LIST:
519 case CONFIG_ITEM_LOADFILE:
520 case CONFIG_ITEM_SAVEFILE:
522 case CONFIG_ITEM_STRING:
523 case CONFIG_ITEM_PASSWORD:
526 case CONFIG_ITEM_STRING_LIST:
529 case CONFIG_ITEM_LOADFILE:
530 case CONFIG_ITEM_SAVEFILE:
533 case CONFIG_ITEM_MODULE:
536 case CONFIG_ITEM_INTEGER:
539 case CONFIG_ITEM_RANGED_INTEGER:
542 case CONFIG_ITEM_BOOL:
545 case CONFIG_ITEM_KEY:
548 case CONFIG_ITEM_MODULE_LIST:
556 case CONFIG_ITEM_MODULE:
558 case CONFIG_ITEM_STRING:
559 case CONFIG_ITEM_PASSWORD:
562 case CONFIG_ITEM_STRING_LIST:
565 case CONFIG_ITEM_LOADFILE:
566 case CONFIG_ITEM_SAVEFILE:
569 case CONFIG_ITEM_MODULE:
572 case CONFIG_ITEM_INTEGER:
575 case CONFIG_ITEM_RANGED_INTEGER:
578 case CONFIG_ITEM_BOOL:
581 case CONFIG_ITEM_KEY:
584 case CONFIG_ITEM_MODULE_LIST:
592 case CONFIG_ITEM_INTEGER:
594 case CONFIG_ITEM_STRING:
595 case CONFIG_ITEM_PASSWORD:
598 case CONFIG_ITEM_STRING_LIST:
601 case CONFIG_ITEM_LOADFILE:
602 case CONFIG_ITEM_SAVEFILE:
605 case CONFIG_ITEM_MODULE:
608 case CONFIG_ITEM_INTEGER:
611 case CONFIG_ITEM_RANGED_INTEGER:
614 case CONFIG_ITEM_BOOL:
617 case CONFIG_ITEM_KEY:
620 case CONFIG_ITEM_MODULE_LIST:
628 case CONFIG_ITEM_RANGED_INTEGER:
630 case CONFIG_ITEM_STRING:
631 case CONFIG_ITEM_PASSWORD:
634 case CONFIG_ITEM_STRING_LIST:
637 case CONFIG_ITEM_LOADFILE:
638 case CONFIG_ITEM_SAVEFILE:
641 case CONFIG_ITEM_MODULE:
644 case CONFIG_ITEM_INTEGER:
647 case CONFIG_ITEM_RANGED_INTEGER:
650 case CONFIG_ITEM_BOOL:
653 case CONFIG_ITEM_KEY:
656 case CONFIG_ITEM_MODULE_LIST:
664 case CONFIG_ITEM_BOOL:
666 case CONFIG_ITEM_STRING:
667 case CONFIG_ITEM_PASSWORD:
670 case CONFIG_ITEM_STRING_LIST:
673 case CONFIG_ITEM_LOADFILE:
674 case CONFIG_ITEM_SAVEFILE:
677 case CONFIG_ITEM_MODULE:
680 case CONFIG_ITEM_INTEGER:
683 case CONFIG_ITEM_RANGED_INTEGER:
686 case CONFIG_ITEM_BOOL:
689 case CONFIG_ITEM_KEY:
692 case CONFIG_ITEM_MODULE_LIST:
700 case CONFIG_ITEM_KEY:
702 case CONFIG_ITEM_STRING:
703 case CONFIG_ITEM_PASSWORD:
706 case CONFIG_ITEM_STRING_LIST:
709 case CONFIG_ITEM_LOADFILE:
710 case CONFIG_ITEM_SAVEFILE:
713 case CONFIG_ITEM_MODULE:
716 case CONFIG_ITEM_INTEGER:
719 case CONFIG_ITEM_RANGED_INTEGER:
722 case CONFIG_ITEM_BOOL:
725 case CONFIG_ITEM_KEY:
728 case CONFIG_ITEM_MODULE_LIST:
736 case CONFIG_ITEM_MODULE_LIST:
738 case CONFIG_ITEM_STRING:
739 case CONFIG_ITEM_PASSWORD:
742 case CONFIG_ITEM_STRING_LIST:
745 case CONFIG_ITEM_LOADFILE:
746 case CONFIG_ITEM_SAVEFILE:
749 case CONFIG_ITEM_MODULE:
752 case CONFIG_ITEM_INTEGER:
755 case CONFIG_ITEM_RANGED_INTEGER:
758 case CONFIG_ITEM_BOOL:
761 case CONFIG_ITEM_KEY:
764 case CONFIG_ITEM_MODULE_LIST:
779 + (VLCConfigControl *)newControl: (module_config_t *)_p_item
780 withView: (NSView *)o_parent_view
782 VLCConfigControl *p_control = NULL;
784 switch(_p_item->i_type) {
785 case CONFIG_ITEM_STRING:
786 case CONFIG_ITEM_PASSWORD:
787 if (!_p_item->list_count) {
788 p_control = [[StringConfigControl alloc]
789 initWithItem: _p_item
790 withView: o_parent_view];
792 p_control = [[StringListConfigControl alloc]
793 initWithItem: _p_item
794 withView: o_parent_view];
797 case CONFIG_ITEM_LOADFILE:
798 case CONFIG_ITEM_SAVEFILE:
799 case CONFIG_ITEM_DIRECTORY:
800 p_control = [[FileConfigControl alloc]
801 initWithItem: _p_item
802 withView: o_parent_view];
804 case CONFIG_ITEM_MODULE:
805 case CONFIG_ITEM_MODULE_CAT:
806 p_control = [[ModuleConfigControl alloc]
807 initWithItem: _p_item
808 withView: o_parent_view];
810 case CONFIG_ITEM_INTEGER:
811 if (_p_item->list_count)
812 p_control = [[IntegerListConfigControl alloc] initWithItem: _p_item withView: o_parent_view];
813 else if ((_p_item->min.i != 0 || _p_item->max.i != 0) && (_p_item->min.i != INT_MIN || _p_item->max.i != INT_MAX))
814 p_control = [[RangedIntegerConfigControl alloc] initWithItem: _p_item withView: o_parent_view];
816 p_control = [[IntegerConfigControl alloc] initWithItem: _p_item withView: o_parent_view];
818 case CONFIG_ITEM_BOOL:
819 p_control = [[BoolConfigControl alloc]
820 initWithItem: _p_item
821 withView: o_parent_view];
823 case CONFIG_ITEM_FLOAT:
824 if ((_p_item->min.i != 0 || _p_item->max.i != 0) && (_p_item->min.i != INT_MIN || _p_item->max.i != INT_MAX))
825 p_control = [[RangedFloatConfigControl alloc] initWithItem: _p_item withView: o_parent_view];
827 p_control = [[FloatConfigControl alloc] initWithItem: _p_item withView: o_parent_view];
829 /* don't display keys in the advanced settings, since the current controls
830 are broken by design. The user is required to change hotkeys in the sprefs
831 and can only change really advanced stuff here..
832 case CONFIG_ITEM_KEY:
833 p_control = [[KeyConfigControl alloc]
834 initWithItem: _p_item
835 withView: o_parent_view];
837 case CONFIG_ITEM_MODULE_LIST:
838 case CONFIG_ITEM_MODULE_LIST_CAT:
839 p_control = [[ModuleListConfigControl alloc] initWithItem: _p_item withView: o_parent_view];
849 return _NS(psz_name);
862 - (char *)stringValue
870 switch(p_item->i_type) {
871 case CONFIG_ITEM_STRING:
872 case CONFIG_ITEM_PASSWORD:
873 case CONFIG_ITEM_LOADFILE:
874 case CONFIG_ITEM_SAVEFILE:
875 case CONFIG_ITEM_DIRECTORY:
876 case CONFIG_ITEM_MODULE:
877 case CONFIG_ITEM_MODULE_LIST:
878 case CONFIG_ITEM_MODULE_LIST_CAT:
879 config_PutPsz(VLCIntf, psz_name, [self stringValue]);
881 case CONFIG_ITEM_KEY:
882 /* So you don't need to restart to have the changes take effect */
883 val.i_int = [self intValue];
884 var_Set(VLCIntf->p_libvlc, psz_name, val);
885 case CONFIG_ITEM_INTEGER:
886 case CONFIG_ITEM_BOOL:
887 config_PutInt(VLCIntf, psz_name, [self intValue]);
889 case CONFIG_ITEM_FLOAT:
890 config_PutFloat(VLCIntf, psz_name, [self floatValue]);
901 return [o_label frame].size.width;
904 - (void) alignWithXPosition:(int)i_xPos;
906 /* FIXME: not implemented atm, but created to shut up the warning
907 * about "method definition not found" -- FK @ 7/24/05 */
911 @implementation StringConfigControl
912 - (id) initWithItem: (module_config_t *)_p_item
913 withView: (NSView *)o_parent_view
915 NSRect mainFrame = [o_parent_view frame];
916 NSString *o_labelString, *o_textfieldString, *o_textfieldTooltip;
917 mainFrame.size.height = 22;
918 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN;
919 mainFrame.origin.x = LEFTMARGIN;
920 mainFrame.origin.y = 0;
922 if ([super initWithFrame: mainFrame item: _p_item] != nil) {
923 if (p_item->i_type == CONFIG_ITEM_PASSWORD)
924 i_view_type = CONFIG_ITEM_PASSWORD;
926 i_view_type = CONFIG_ITEM_STRING;
928 o_textfieldTooltip = [[VLCStringUtility sharedInstance] wrapString: _NS((char *)p_item->psz_longtext) toWidth: PREFS_WRAP];
931 if (p_item->psz_text)
932 o_labelString = _NS((char *)p_item->psz_text);
935 ADD_LABEL(o_label, mainFrame, 0, -3, o_labelString, o_textfieldTooltip)
936 [o_label setAutoresizingMask:NSViewNotSizable ];
937 [self addSubview: o_label];
939 /* build the textfield */
940 if (p_item->value.psz)
941 o_textfieldString = _NS((char *)p_item->value.psz);
943 o_textfieldString = @"";
944 if (p_item->i_type == CONFIG_ITEM_PASSWORD) {
945 ADD_SECURETEXTFIELD(o_textfield, mainFrame, [o_label frame].size.width + 2,
946 0, mainFrame.size.width - [o_label frame].size.width -
947 2, o_textfieldTooltip, o_textfieldString)
949 ADD_TEXTFIELD(o_textfield, mainFrame, [o_label frame].size.width + 2,
950 0, mainFrame.size.width - [o_label frame].size.width -
951 2, o_textfieldTooltip, o_textfieldString)
953 [o_textfield setAutoresizingMask:NSViewWidthSizable ];
955 [self addSubview: o_textfield];
960 - (void) alignWithXPosition:(int)i_xPos
963 NSRect superFrame = [self frame];
964 frame = [o_label frame];
965 frame.origin.x = i_xPos - frame.size.width - 3;
966 [o_label setFrame:frame];
968 frame = [o_textfield frame];
969 frame.origin.x = i_xPos + 2;
970 frame.size.width = superFrame.size.width - frame.origin.x - 1;
971 [o_textfield setFrame:frame];
976 [o_textfield release];
980 - (char *)stringValue
982 return [[VLCStringUtility sharedInstance] delocalizeString:
983 [o_textfield stringValue]];
988 NSString *o_textfieldString;
989 char *psz_value = config_GetPsz(VLCIntf, p_item->psz_name);
991 o_textfieldString = _NS(psz_value);
993 o_textfieldString = @"";
999 @implementation StringListConfigControl
1000 - (id) initWithItem: (module_config_t *)_p_item
1001 withView: (NSView *)o_parent_view
1003 NSRect mainFrame = [o_parent_view frame];
1004 NSString *o_labelString, *o_textfieldTooltip;
1005 mainFrame.size.height = 22;
1006 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN + 1;
1007 mainFrame.origin.x = LEFTMARGIN;
1008 mainFrame.origin.y = 0;
1010 if ([super initWithFrame: mainFrame item: _p_item] != nil) {
1011 i_view_type = CONFIG_ITEM_STRING_LIST;
1013 o_textfieldTooltip = [[VLCStringUtility sharedInstance] wrapString: _NS(p_item->psz_longtext) toWidth: PREFS_WRAP];
1016 if (p_item->psz_text)
1017 o_labelString = _NS((char *)p_item->psz_text);
1019 o_labelString = @"";
1020 ADD_LABEL(o_label, mainFrame, 0, -3, o_labelString, o_textfieldTooltip)
1021 [o_label setAutoresizingMask:NSViewNotSizable ];
1022 [self addSubview: o_label];
1024 /* build the textfield */
1025 ADD_COMBO(o_combo, mainFrame, [o_label frame].size.width,
1026 -2, 0, o_textfieldTooltip)
1027 [o_combo setAutoresizingMask:NSViewWidthSizable ];
1028 for (int i_index = 0; i_index < p_item->list_count; i_index++) {
1029 if (!p_item->value.psz && !p_item->list.psz[i_index])
1030 [o_combo selectItemAtIndex: i_index];
1031 else if (p_item->value.psz && p_item->list.psz[i_index] &&
1032 !strcmp(p_item->value.psz, p_item->list.psz[i_index]))
1033 [o_combo selectItemAtIndex: i_index];
1035 [self addSubview: o_combo];
1040 - (void) alignWithXPosition:(int)i_xPos
1043 NSRect superFrame = [self frame];
1044 frame = [o_label frame];
1045 frame.origin.x = i_xPos - frame.size.width - 3;
1046 [o_label setFrame:frame];
1048 frame = [o_combo frame];
1049 frame.origin.x = i_xPos + 2;
1050 frame.size.width = superFrame.size.width - frame.origin.x + 2;
1051 [o_combo setFrame:frame];
1060 - (char *)stringValue
1062 if ([o_combo indexOfSelectedItem] >= 0) {
1063 if (p_item->list.psz[[o_combo indexOfSelectedItem]] != NULL)
1064 return strdup(p_item->list.psz[[o_combo indexOfSelectedItem]]);
1066 if ([[VLCStringUtility sharedInstance] delocalizeString: [o_combo stringValue]] != NULL)
1067 return strdup([[VLCStringUtility sharedInstance] delocalizeString: [o_combo stringValue]]);
1074 [o_combo reloadData];
1075 char *psz_value = config_GetPsz(VLCIntf, p_item->psz_name);
1077 for (int i_index = 0; i_index < p_item->list_count; i_index++) {
1078 if (!psz_value && !p_item->list.psz[i_index])
1079 [o_combo selectItemAtIndex: i_index];
1080 else if (psz_value && p_item->list.psz[i_index] &&
1081 !strcmp(psz_value, p_item->list.psz[i_index]))
1082 [o_combo selectItemAtIndex: i_index];
1086 [super resetValues];
1090 @implementation StringListConfigControl (NSComboBoxDataSource)
1091 - (NSInteger)numberOfItemsInComboBox:(NSComboBox *)aComboBox
1093 return p_item->list_count;
1096 - (id)comboBox:(NSComboBox *)aComboBox objectValueForItemAtIndex:(NSInteger)i_index
1098 if (p_item->list_text && p_item->list_text[i_index]) {
1099 return _NS((char *)p_item->list_text[i_index]);
1101 return _NS((char *)p_item->list.psz[i_index]);
1105 @implementation FileConfigControl
1106 - (id) initWithItem: (module_config_t *)_p_item
1107 withView: (NSView *)o_parent_view
1109 NSRect mainFrame = [o_parent_view frame];
1110 NSString *o_labelString, *o_itemTooltip, *o_textfieldString;
1111 mainFrame.size.height = 46;
1112 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN;
1113 mainFrame.origin.x = LEFTMARGIN;
1114 mainFrame.origin.y = 0;
1116 if ([super initWithFrame: mainFrame item: _p_item] != nil) {
1117 i_view_type = CONFIG_ITEM_LOADFILE;
1119 o_itemTooltip = [[VLCStringUtility sharedInstance] wrapString: _NS((char *)p_item->psz_longtext) toWidth: PREFS_WRAP];
1121 /* is it a directory */
1122 b_directory = ([self type] == CONFIG_ITEM_DIRECTORY) ? YES : NO;
1125 if (p_item->psz_text)
1126 o_labelString = _NS((char *)p_item->psz_text);
1128 o_labelString = @"";
1129 ADD_LABEL(o_label, mainFrame, 0, 3, o_labelString, o_itemTooltip)
1130 [o_label setAutoresizingMask:NSViewNotSizable ];
1131 [self addSubview: o_label];
1133 /* build the button */
1134 ADD_RIGHT_BUTTON(o_button, mainFrame, 0, 0, o_itemTooltip,
1136 [o_button setAutoresizingMask:NSViewMinXMargin ];
1137 [self addSubview: o_button];
1139 /* build the textfield */
1140 if (p_item->value.psz)
1141 o_textfieldString = [NSString stringWithFormat: @"%s", (char *)p_item->value.psz];
1143 o_textfieldString = @"";
1144 ADD_TEXTFIELD(o_textfield, mainFrame, 12, 2, mainFrame.size.width -
1145 8 - [o_button frame].size.width,
1146 o_itemTooltip, o_textfieldString)
1147 [o_textfield setAutoresizingMask:NSViewWidthSizable ];
1148 [self addSubview: o_textfield];
1153 - (void) alignWithXPosition:(int)i_xPos
1160 [o_textfield release];
1165 - (IBAction)openFileDialog: (id)sender
1167 NSOpenPanel *o_open_panel = [NSOpenPanel openPanel];
1169 [o_open_panel setTitle: (b_directory)?
1170 _NS("Select a directory"):_NS("Select a file")];
1171 [o_open_panel setPrompt: _NS("Select")];
1172 [o_open_panel setAllowsMultipleSelection: NO];
1173 [o_open_panel setCanChooseFiles: !b_directory];
1174 [o_open_panel setCanChooseDirectories: b_directory];
1175 [o_open_panel beginSheetModalForWindow:[sender window] completionHandler:^(NSInteger returnCode) {
1176 if (returnCode == NSOKButton) {
1177 NSString *o_path = [[[o_open_panel URLs] objectAtIndex: 0] path];
1178 [o_textfield setStringValue: o_path];
1183 - (char *)stringValue
1185 if ([[o_textfield stringValue] length] != 0)
1186 return strdup([[o_textfield stringValue] fileSystemRepresentation]);
1193 NSString *o_textfieldString;
1194 char *psz_value = config_GetPsz(VLCIntf, p_item->psz_name);
1196 o_textfieldString = [NSString stringWithFormat: @"%s", psz_value];
1198 o_textfieldString = @"";
1201 [super resetValues];
1205 @implementation ModuleConfigControl
1206 - (id) initWithItem: (module_config_t *)_p_item
1207 withView: (NSView *)o_parent_view
1209 NSRect mainFrame = [o_parent_view frame];
1210 NSString *o_labelString, *o_popupTooltip;
1211 mainFrame.size.height = 22;
1212 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN + 1;
1213 mainFrame.origin.x = LEFTMARGIN;
1214 mainFrame.origin.y = 0;
1216 if ([super initWithFrame: mainFrame item: _p_item] != nil) {
1217 i_view_type = CONFIG_ITEM_MODULE;
1219 o_popupTooltip = [[VLCStringUtility sharedInstance] wrapString: _NS((char *)p_item->psz_longtext) toWidth: PREFS_WRAP];
1222 if (p_item->psz_text)
1223 o_labelString = _NS((char *)p_item->psz_text);
1225 o_labelString = @"";
1227 ADD_LABEL(o_label, mainFrame, 0, -1, o_labelString, o_popupTooltip)
1228 [o_label setAutoresizingMask:NSViewNotSizable ];
1229 [self addSubview: o_label];
1231 /* build the popup */
1232 ADD_POPUP(o_popup, mainFrame, [o_label frame].size.width,
1233 -2, 0, o_popupTooltip)
1234 [o_popup setAutoresizingMask:NSViewWidthSizable ];
1235 [o_popup addItemWithTitle: _NS("Default")];
1236 [[o_popup lastItem] setTag: -1];
1237 [o_popup selectItem: [o_popup lastItem]];
1240 [self addSubview: o_popup];
1245 - (void) alignWithXPosition:(int)i_xPos
1248 NSRect superFrame = [self frame];
1249 frame = [o_label frame];
1250 frame.origin.x = i_xPos - frame.size.width - 3;
1251 [o_label setFrame:frame];
1253 frame = [o_popup frame];
1254 frame.origin.x = i_xPos - 1;
1255 frame.size.width = superFrame.size.width - frame.origin.x + 2;
1256 [o_popup setFrame:frame];
1265 - (char *)stringValue
1267 NSString *newval = [o_popup titleOfSelectedItem];
1268 char *returnval = NULL;
1269 size_t i_module_index;
1270 module_t *p_parser, **p_list;
1273 p_list = module_list_get(&count);
1274 for (i_module_index = 0; i_module_index < count; i_module_index++) {
1275 p_parser = p_list[i_module_index];
1277 if (p_item->i_type == CONFIG_ITEM_MODULE) {
1278 if (module_provides(p_parser, p_item->psz_type)) {
1279 NSString *o_description = _NS(module_get_name(p_parser, TRUE));
1280 if ([newval isEqualToString: o_description]) {
1281 returnval = strdup(module_get_object(p_parser));
1286 if (module_is_main(p_parser))
1289 unsigned int confsize;
1290 module_config_t *p_config = module_config_get(p_parser, &confsize);
1291 for (size_t i = 0; i < confsize; i++) {
1292 module_config_t *p_cfg = p_config + i;
1293 /* Hack: required subcategory is stored in i_min */
1294 if (p_cfg->i_type == CONFIG_SUBCATEGORY &&
1295 p_cfg->value.i == p_cfg->min.i) {
1296 NSString *o_description = _NS(module_get_name(p_parser, TRUE));
1297 if ([newval isEqualToString: o_description]) {
1298 returnval = strdup(module_get_object(p_parser));
1303 module_config_free(p_config);
1306 module_list_free(p_list);
1312 /* build a list of available modules */
1313 module_t *p_parser, **p_list;
1316 p_list = module_list_get(&count);
1317 for (size_t i_index = 0; i_index < count; i_index++) {
1318 p_parser = p_list[i_index];
1320 if (p_item->i_type == CONFIG_ITEM_MODULE) {
1321 if (module_provides(p_parser, p_item->psz_type)) {
1322 NSString *o_description = _NS(module_get_name(p_parser, TRUE));
1323 [o_popup addItemWithTitle: o_description];
1324 char *psz_value = config_GetPsz(VLCIntf, p_item->psz_name);
1327 !strcmp(psz_value, module_get_object(p_parser)))
1328 [o_popup selectItem:[o_popup lastItem]];
1333 if (module_is_main(p_parser))
1335 unsigned int confsize;
1337 module_config_t *p_configlist = module_config_get(p_parser, &confsize);
1338 for (size_t i = 0; i < confsize; i++) {
1339 module_config_t *p_config = &p_configlist[i];
1340 /* Hack: required subcategory is stored in i_min */
1341 if (p_config->i_type == CONFIG_SUBCATEGORY &&
1342 p_config->value.i == p_item->min.i) {
1343 NSString *o_description = _NS(module_get_name(p_parser, TRUE));
1344 [o_popup addItemWithTitle: o_description];
1346 if (p_item->value.psz && !strcmp(p_item->value.psz,
1347 module_get_object(p_parser)))
1348 [o_popup selectItem:[o_popup lastItem]];
1351 module_config_free(p_configlist);
1354 module_list_free(p_list);
1355 [super resetValues];
1359 @implementation IntegerConfigControl
1360 - (id) initWithItem: (module_config_t *)_p_item
1361 withView: (NSView *)o_parent_view
1363 NSRect mainFrame = [o_parent_view frame];
1364 NSString *o_labelString, *o_tooltip;
1365 mainFrame.size.height = 23;
1366 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN + 1;
1367 mainFrame.origin.x = LEFTMARGIN;
1368 mainFrame.origin.y = 0;
1370 if ([super initWithFrame: mainFrame item: _p_item] != nil) {
1371 i_view_type = CONFIG_ITEM_INTEGER;
1373 o_tooltip = [[VLCStringUtility sharedInstance] wrapString: _NS((char *)p_item->psz_longtext) toWidth: PREFS_WRAP];
1376 if (p_item->psz_text)
1377 o_labelString = _NS((char *)p_item->psz_text);
1379 o_labelString = @"";
1380 ADD_LABEL(o_label, mainFrame, 0, -3, o_labelString, o_tooltip)
1381 [o_label setAutoresizingMask:NSViewNotSizable ];
1382 [self addSubview: o_label];
1384 /* build the stepper */
1385 ADD_STEPPER(o_stepper, mainFrame, mainFrame.size.width - 19,
1386 0, o_tooltip, -100000, 100000)
1387 [o_stepper setIntValue: p_item->value.i];
1388 [o_stepper setAutoresizingMask:NSViewMaxXMargin ];
1389 [self addSubview: o_stepper];
1391 ADD_TEXTFIELD(o_textfield, mainFrame, mainFrame.size.width - 19 - 52,
1392 1, 49, o_tooltip, @"")
1393 [o_textfield setIntValue: p_item->value.i];
1394 [o_textfield setDelegate: self];
1395 [[NSNotificationCenter defaultCenter] addObserver: self
1396 selector: @selector(textfieldChanged:)
1397 name: NSControlTextDidChangeNotification
1398 object: o_textfield];
1399 [o_textfield setAutoresizingMask:NSViewMaxXMargin ];
1400 [self addSubview: o_textfield];
1405 - (void) alignWithXPosition:(int)i_xPos
1408 frame = [o_label frame];
1409 frame.origin.x = i_xPos - frame.size.width - 3;
1410 [o_label setFrame:frame];
1412 frame = [o_textfield frame];
1413 frame.origin.x = i_xPos + 2;
1414 [o_textfield setFrame:frame];
1416 frame = [o_stepper frame];
1417 frame.origin.x = i_xPos + [o_textfield frame].size.width + 5;
1418 [o_stepper setFrame:frame];
1423 [o_stepper release];
1424 [o_textfield release];
1428 - (IBAction)stepperChanged:(id)sender
1430 [o_textfield setIntValue: [o_stepper intValue]];
1433 - (void)textfieldChanged:(NSNotification *)o_notification
1435 [o_stepper setIntValue: [o_textfield intValue]];
1440 return [o_textfield intValue];
1445 [o_textfield setIntValue: config_GetInt(VLCIntf, p_item->psz_name)];
1446 [super resetValues];
1451 @implementation IntegerListConfigControl
1453 - (id) initWithItem: (module_config_t *)_p_item
1454 withView: (NSView *)o_parent_view
1456 NSRect mainFrame = [o_parent_view frame];
1457 NSString *o_labelString, *o_textfieldTooltip;
1458 mainFrame.size.height = 22;
1459 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN + 1;
1460 mainFrame.origin.x = LEFTMARGIN;
1461 mainFrame.origin.y = 0;
1463 if ([super initWithFrame: mainFrame item: _p_item] != nil) {
1464 i_view_type = CONFIG_ITEM_STRING_LIST;
1466 o_textfieldTooltip = [[VLCStringUtility sharedInstance] wrapString: _NS((char *)p_item->psz_longtext) toWidth: PREFS_WRAP];
1469 if (p_item->psz_text)
1470 o_labelString = _NS((char *)p_item->psz_text);
1472 o_labelString = @"";
1473 ADD_LABEL(o_label, mainFrame, 0, -3, o_labelString, o_textfieldTooltip)
1474 [o_label setAutoresizingMask:NSViewNotSizable ];
1475 [self addSubview: o_label];
1477 /* build the textfield */
1478 ADD_COMBO(o_combo, mainFrame, [o_label frame].size.width,
1479 -2, 0, o_textfieldTooltip)
1480 [o_combo setAutoresizingMask:NSViewWidthSizable ];
1481 for (int i_index = 0; i_index < p_item->list_count; i_index++) {
1482 if (p_item->value.i == p_item->list.i[i_index])
1483 [o_combo selectItemAtIndex: i_index];
1485 [self addSubview: o_combo];
1490 - (void) alignWithXPosition:(int)i_xPos
1493 NSRect superFrame = [self frame];
1494 frame = [o_label frame];
1495 frame.origin.x = i_xPos - frame.size.width - 3;
1496 [o_label setFrame:frame];
1498 frame = [o_combo frame];
1499 frame.origin.x = i_xPos + 2;
1500 frame.size.width = superFrame.size.width - frame.origin.x + 2;
1501 [o_combo setFrame:frame];
1512 if ([o_combo indexOfSelectedItem] >= 0)
1513 return p_item->list.i[[o_combo indexOfSelectedItem]];
1515 return [o_combo intValue];
1520 [o_combo reloadData];
1521 for (int i_index = 0; i_index < p_item->list_count; i_index++) {
1522 if (config_GetInt(VLCIntf, p_item->psz_name) == p_item->list.i[i_index])
1523 [o_combo selectItemAtIndex: i_index];
1529 @implementation IntegerListConfigControl (NSComboBoxDataSource)
1530 - (NSInteger)numberOfItemsInComboBox:(NSComboBox *)aComboBox
1532 return p_item->list_count;
1535 - (id)comboBox:(NSComboBox *)aComboBox objectValueForItemAtIndex:(NSInteger)i_index
1537 if (p_item->list_text && p_item->list_text[i_index])
1538 return _NS((char *)p_item->list_text[i_index]);
1540 return [NSString stringWithFormat: @"%i", p_item->list.i[i_index]];
1544 @implementation RangedIntegerConfigControl
1545 - (id) initWithItem: (module_config_t *)_p_item
1546 withView: (NSView *)o_parent_view
1548 NSRect mainFrame = [o_parent_view frame];
1549 NSString *o_labelString, *o_tooltip;
1550 mainFrame.size.height = 50;
1551 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN;
1552 mainFrame.origin.x = LEFTMARGIN;
1553 mainFrame.origin.y = 0;
1555 if ([super initWithFrame: mainFrame item: _p_item] != nil) {
1556 i_view_type = CONFIG_ITEM_RANGED_INTEGER;
1558 o_tooltip = [[VLCStringUtility sharedInstance] wrapString: _NS((char *)p_item->psz_longtext) toWidth: PREFS_WRAP];
1561 if (p_item->psz_text)
1562 o_labelString = _NS((char *)p_item->psz_text);
1564 o_labelString = @"";
1565 ADD_LABEL(o_label, mainFrame, 0, -3, o_labelString, o_tooltip)
1566 [o_label setAutoresizingMask:NSViewNotSizable ];
1567 [self addSubview: o_label];
1569 /* build the textfield */
1570 ADD_TEXTFIELD(o_textfield, mainFrame, [o_label frame].size.width + 2,
1571 28, 49, o_tooltip, @"")
1572 [o_textfield setIntValue: p_item->value.i];
1573 [o_textfield setAutoresizingMask:NSViewMaxXMargin ];
1574 [o_textfield setDelegate: self];
1575 [[NSNotificationCenter defaultCenter] addObserver: self
1576 selector: @selector(textfieldChanged:)
1577 name: NSControlTextDidChangeNotification
1578 object: o_textfield];
1579 [self addSubview: o_textfield];
1581 /* build the mintextfield */
1582 ADD_LABEL(o_textfield_min, mainFrame, 12, -30, @"-8888", @"")
1583 [o_textfield_min setIntValue: p_item->min.i];
1584 [o_textfield_min setAutoresizingMask:NSViewMaxXMargin ];
1585 [o_textfield_min setAlignment:NSRightTextAlignment];
1586 [self addSubview: o_textfield_min];
1588 /* build the maxtextfield */
1589 ADD_LABEL(o_textfield_max, mainFrame,
1590 mainFrame.size.width - 31, -30, @"8888", @"")
1591 [o_textfield_max setIntValue: p_item->max.i];
1592 [o_textfield_max setAutoresizingMask:NSViewMinXMargin ];
1593 [self addSubview: o_textfield_max];
1595 /* build the slider */
1596 ADD_SLIDER(o_slider, mainFrame, [o_textfield_min frame].origin.x +
1597 [o_textfield_min frame].size.width + 6, -1, mainFrame.size.width -
1598 [o_textfield_max frame].size.width -
1599 [o_textfield_max frame].size.width - 14 -
1600 [o_textfield_min frame].origin.x, o_tooltip,
1601 p_item->min.i, p_item->max.i)
1602 [o_slider setIntValue: p_item->value.i];
1603 [o_slider setAutoresizingMask:NSViewWidthSizable ];
1604 [o_slider setTarget: self];
1605 [o_slider setAction: @selector(sliderChanged:)];
1606 [o_slider sendActionOn:NSLeftMouseUpMask | NSLeftMouseDownMask |
1607 NSLeftMouseDraggedMask];
1608 [self addSubview: o_slider];
1614 - (void) alignWithXPosition:(int)i_xPos
1617 frame = [o_label frame];
1618 frame.origin.x = i_xPos - frame.size.width - 3;
1619 [o_label setFrame:frame];
1621 frame = [o_textfield frame];
1622 frame.origin.x = i_xPos + 2;
1623 [o_textfield setFrame:frame];
1628 [o_textfield release];
1629 [o_textfield_min release];
1630 [o_textfield_max release];
1635 - (IBAction)sliderChanged:(id)sender
1637 [o_textfield setIntValue: [o_slider intValue]];
1640 - (void)textfieldChanged:(NSNotification *)o_notification
1642 [o_slider setIntValue: [o_textfield intValue]];
1647 return [o_slider intValue];
1652 int value = config_GetInt(VLCIntf, p_item->psz_name);
1653 [o_textfield setIntValue:value];
1654 [o_slider setIntValue:value];
1655 [super resetValues];
1659 @implementation FloatConfigControl
1660 - (id) initWithItem: (module_config_t *)_p_item
1661 withView: (NSView *)o_parent_view
1663 NSRect mainFrame = [o_parent_view frame];
1664 NSString *o_labelString, *o_tooltip;
1665 mainFrame.size.height = 23;
1666 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN + 1;
1667 mainFrame.origin.x = LEFTMARGIN;
1668 mainFrame.origin.y = 0;
1670 if ([super initWithFrame: mainFrame item: _p_item] != nil) {
1671 i_view_type = CONFIG_ITEM_INTEGER;
1673 o_tooltip = [[VLCStringUtility sharedInstance] wrapString: _NS((char *)p_item->psz_longtext) toWidth: PREFS_WRAP];
1676 if (p_item->psz_text)
1677 o_labelString = _NS((char *)p_item->psz_text);
1679 o_labelString = @"";
1680 ADD_LABEL(o_label, mainFrame, 0, -2, o_labelString, o_tooltip)
1681 [o_label setAutoresizingMask:NSViewNotSizable ];
1682 [self addSubview: o_label];
1684 /* build the stepper */
1685 ADD_STEPPER(o_stepper, mainFrame, mainFrame.size.width - 19,
1686 0, o_tooltip, -100000, 100000)
1687 [o_stepper setFloatValue: p_item->value.f];
1688 [o_stepper setAutoresizingMask:NSViewMaxXMargin ];
1689 [self addSubview: o_stepper];
1691 /* build the textfield */
1692 ADD_TEXTFIELD(o_textfield, mainFrame, mainFrame.size.width - 19 - 52,
1693 1, 49, o_tooltip, @"")
1694 [o_textfield setFloatValue: p_item->value.f];
1695 [o_textfield setDelegate: self];
1696 [[NSNotificationCenter defaultCenter] addObserver: self
1697 selector: @selector(textfieldChanged:)
1698 name: NSControlTextDidChangeNotification
1699 object: o_textfield];
1700 [o_textfield setAutoresizingMask:NSViewMaxXMargin ];
1701 [self addSubview: o_textfield];
1706 - (void) alignWithXPosition:(int)i_xPos
1709 frame = [o_label frame];
1710 frame.origin.x = i_xPos - frame.size.width - 3;
1711 [o_label setFrame:frame];
1713 frame = [o_textfield frame];
1714 frame.origin.x = i_xPos + 2;
1715 [o_textfield setFrame:frame];
1717 frame = [o_stepper frame];
1718 frame.origin.x = i_xPos + [o_textfield frame].size.width + 5;
1719 [o_stepper setFrame:frame];
1724 [o_stepper release];
1725 [o_textfield release];
1729 - (IBAction)stepperChanged:(id)sender
1731 [o_textfield setFloatValue: [o_stepper floatValue]];
1734 - (void)textfieldChanged:(NSNotification *)o_notification
1736 [o_stepper setFloatValue: [o_textfield floatValue]];
1741 return [o_stepper floatValue];
1746 [o_textfield setFloatValue: config_GetFloat(VLCIntf, p_item->psz_name)];
1747 [super resetValues];
1751 @implementation RangedFloatConfigControl
1752 - (id) initWithItem: (module_config_t *)_p_item
1753 withView: (NSView *)o_parent_view
1755 NSRect mainFrame = [o_parent_view frame];
1756 NSString *o_labelString, *o_tooltip;
1757 mainFrame.size.height = 50;
1758 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN;
1759 mainFrame.origin.x = LEFTMARGIN;
1760 mainFrame.origin.y = 0;
1762 if ([super initWithFrame: mainFrame item: _p_item] != nil) {
1763 i_view_type = CONFIG_ITEM_RANGED_INTEGER;
1765 o_tooltip = [[VLCStringUtility sharedInstance] wrapString: _NS((char *)p_item->psz_longtext) toWidth: PREFS_WRAP];
1768 if (p_item->psz_text)
1769 o_labelString = _NS((char *)p_item->psz_text);
1771 o_labelString = @"";
1772 ADD_LABEL(o_label, mainFrame, 0, -3, o_labelString, o_tooltip)
1773 [o_label setAutoresizingMask:NSViewNotSizable ];
1774 [self addSubview: o_label];
1776 /* build the textfield */
1777 ADD_TEXTFIELD(o_textfield, mainFrame, [o_label frame].size.width + 2,
1778 28, 49, o_tooltip, @"")
1779 [o_textfield setFloatValue: p_item->value.f];
1780 [o_textfield setAutoresizingMask:NSViewMaxXMargin ];
1781 [o_textfield setDelegate: self];
1782 [[NSNotificationCenter defaultCenter] addObserver: self
1783 selector: @selector(textfieldChanged:)
1784 name: NSControlTextDidChangeNotification
1785 object: o_textfield];
1786 [self addSubview: o_textfield];
1788 /* build the mintextfield */
1789 ADD_LABEL(o_textfield_min, mainFrame, 12, -30, @"-8888", @"")
1790 [o_textfield_min setFloatValue: p_item->min.f];
1791 [o_textfield_min setAutoresizingMask:NSViewMaxXMargin ];
1792 [o_textfield_min setAlignment:NSRightTextAlignment];
1793 [self addSubview: o_textfield_min];
1795 /* build the maxtextfield */
1796 ADD_LABEL(o_textfield_max, mainFrame, mainFrame.size.width - 31,
1798 [o_textfield_max setFloatValue: p_item->max.f];
1799 [o_textfield_max setAutoresizingMask:NSViewMinXMargin ];
1800 [self addSubview: o_textfield_max];
1802 /* build the slider */
1803 ADD_SLIDER(o_slider, mainFrame, [o_textfield_min frame].origin.x +
1804 [o_textfield_min frame].size.width + 6, -1, mainFrame.size.width -
1805 [o_textfield_max frame].size.width -
1806 [o_textfield_max frame].size.width - 14 -
1807 [o_textfield_min frame].origin.x, o_tooltip, p_item->min.f,
1809 [o_slider setFloatValue: p_item->value.f];
1810 [o_slider setAutoresizingMask:NSViewWidthSizable ];
1811 [o_slider setTarget: self];
1812 [o_slider setAction: @selector(sliderChanged:)];
1813 [o_slider sendActionOn:NSLeftMouseUpMask | NSLeftMouseDownMask |
1814 NSLeftMouseDraggedMask];
1815 [self addSubview: o_slider];
1821 - (void) alignWithXPosition:(int)i_xPos
1824 frame = [o_label frame];
1825 frame.origin.x = i_xPos - frame.size.width - 3;
1826 [o_label setFrame:frame];
1828 frame = [o_textfield frame];
1829 frame.origin.x = i_xPos + 2;
1830 [o_textfield setFrame:frame];
1835 [o_textfield release];
1836 [o_textfield_min release];
1837 [o_textfield_max release];
1842 - (IBAction)sliderChanged:(id)sender
1844 [o_textfield setFloatValue: [o_slider floatValue]];
1847 - (void)textfieldChanged:(NSNotification *)o_notification
1849 [o_slider setFloatValue: [o_textfield floatValue]];
1854 return [o_slider floatValue];
1859 [o_textfield setFloatValue: config_GetFloat(VLCIntf, p_item->psz_name)];
1860 [o_slider setFloatValue: config_GetFloat(VLCIntf, p_item->psz_name)];
1861 [super resetValues];
1865 @implementation BoolConfigControl
1867 - (id) initWithItem: (module_config_t *)_p_item
1868 withView: (NSView *)o_parent_view
1870 NSRect mainFrame = [o_parent_view frame];
1871 NSString *o_labelString, *o_tooltip;
1872 mainFrame.size.height = 17;
1873 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN;
1874 mainFrame.origin.x = LEFTMARGIN;
1875 mainFrame.origin.y = 0;
1877 if ([super initWithFrame: mainFrame item: _p_item] != nil) {
1878 i_view_type = CONFIG_ITEM_BOOL;
1880 /* add the checkbox */
1881 o_tooltip = [[VLCStringUtility sharedInstance] wrapString: _NS((char *)p_item->psz_longtext) toWidth: PREFS_WRAP];
1882 ADD_CHECKBOX(o_checkbox, mainFrame, 0,
1883 0, @"", o_tooltip, p_item->value.i, NSImageLeft)
1884 [o_checkbox setAutoresizingMask:NSViewNotSizable ];
1885 [self addSubview: o_checkbox];
1887 if (p_item->psz_text)
1888 o_labelString = _NS((char *)p_item->psz_text);
1890 o_labelString = @"";
1891 ADD_LABEL(o_label, mainFrame, [o_checkbox frame].size.width, 0, o_labelString, o_tooltip)
1892 [o_label setAutoresizingMask:NSViewNotSizable ];
1893 [self addSubview: o_label];
1900 [o_checkbox release];
1906 return [o_checkbox intValue];
1911 [o_checkbox setState: config_GetInt(VLCIntf, p_item->psz_name)];
1912 [super resetValues];
1916 @implementation KeyConfigControl
1917 - (id) initWithItem: (module_config_t *)_p_item
1918 withView: (NSView *)o_parent_view
1920 NSRect mainFrame = [o_parent_view frame];
1921 NSString *o_labelString, *o_tooltip;
1922 mainFrame.size.height = 22;
1923 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN + 1;
1924 mainFrame.origin.x = LEFTMARGIN;
1925 mainFrame.origin.y = 0;
1927 if ([super initWithFrame: mainFrame item: _p_item] != nil) {
1928 i_view_type = CONFIG_ITEM_KEY;
1930 o_tooltip = [[VLCStringUtility sharedInstance] wrapString: _NS((char *)p_item->psz_longtext) toWidth: PREFS_WRAP];
1933 if (p_item->psz_text)
1934 o_labelString = _NS((char *)p_item->psz_text);
1936 o_labelString = @"";
1937 ADD_LABEL(o_label, mainFrame, 0, -1, o_labelString, o_tooltip)
1938 [o_label setAutoresizingMask:NSViewNotSizable ];
1939 [self addSubview: o_label];
1941 /* build the popup */
1942 ADD_POPUP(o_popup, mainFrame, [o_label frame].origin.x +
1943 [o_label frame].size.width + 3,
1945 [o_popup setAutoresizingMask:NSViewWidthSizable ];
1947 if (o_keys_menu == nil) {
1949 o_keys_menu = [[NSMenu alloc] initWithTitle: @"Keys Menu"];
1950 #warning This does not work anymore. FIXME.
1952 for (i = 0; i < sizeof(vlc_key) / sizeof(key_descriptor_t); i++)
1953 if (vlc_key[i].psz_key_string)
1954 POPULATE_A_KEY(o_keys_menu,
1955 [NSString stringWithUTF8String:vlc_key[i].psz_key_string]
1956 , vlc_key[i].i_key_code)
1959 [o_popup setMenu:[o_keys_menu copyWithZone:nil]];
1960 [o_popup selectItem:[[o_popup menu] itemWithTag:p_item->value.i]];
1961 [self addSubview: o_popup];
1967 - (void) alignWithXPosition:(int)i_xPos
1970 NSRect superFrame = [self frame];
1971 frame = [o_label frame];
1972 frame.origin.x = i_xPos - frame.size.width - 3;
1973 [o_label setFrame:frame];
1975 frame = [o_popup frame];
1976 frame.origin.x = i_xPos - 1;
1977 frame.size.width = superFrame.size.width - frame.origin.x + 2;
1978 [o_popup setFrame:frame];
1989 return [o_popup selectedTag];
1994 [o_popup selectItem:[[o_popup menu] itemWithTag:config_GetInt(VLCIntf, p_item->psz_name)]];
1995 [super resetValues];
1999 @implementation ModuleListConfigControl
2000 - (id) initWithItem: (module_config_t *)_p_item
2001 withView: (NSView *)o_parent_view
2003 if (_p_item->i_type == CONFIG_ITEM_MODULE_LIST)
2007 //Fill our array to know how may items we have...
2008 module_t *p_parser, **p_list;
2009 size_t i_module_index;
2010 NSRect mainFrame = [o_parent_view frame];
2011 NSString *o_labelString, *o_textfieldString, *o_tooltip;
2013 o_modulearray = [[NSMutableArray alloc] initWithCapacity:10];
2014 /* build a list of available modules */
2016 p_list = module_list_get(&count);
2017 for (i_module_index = 0; i_module_index < count; i_module_index++) {
2019 p_parser = p_list[i_module_index];
2021 if (module_is_main(p_parser))
2024 unsigned int confsize;
2025 module_config_t *p_configlist = module_config_get(p_parser, &confsize);
2027 for (i = 0; i < confsize; i++) {
2028 unsigned int unused;
2029 module_config_t *p_config = &p_configlist[i];
2030 NSString *o_modulelongname, *o_modulename;
2031 NSNumber *o_moduleenabled = nil;
2033 /* Hack: required subcategory is stored in i_min */
2034 if (p_config->i_type == CONFIG_SUBCATEGORY &&
2035 p_config->value.i == _p_item->min.i) {
2036 o_modulelongname = [NSString stringWithUTF8String:
2037 module_get_name(p_parser, TRUE)];
2038 o_modulename = [NSString stringWithUTF8String:
2039 module_get_object(p_parser)];
2041 if (_p_item->value.psz &&
2042 strstr(_p_item->value.psz, module_get_object(p_parser)))
2043 o_moduleenabled = [NSNumber numberWithBool:YES];
2045 o_moduleenabled = [NSNumber numberWithBool:NO];
2047 [o_modulearray addObject:[NSMutableArray
2048 arrayWithObjects: o_modulename, o_modulelongname,
2049 o_moduleenabled, nil]];
2052 module_config_free(p_configlist);
2054 module_list_free(p_list);
2056 mainFrame.size.height = 30 + 20 * [o_modulearray count];
2057 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN;
2058 mainFrame.origin.x = LEFTMARGIN;
2059 mainFrame.origin.y = 0;
2060 if ([super initWithFrame: mainFrame item: _p_item] != nil) {
2061 i_view_type = CONFIG_ITEM_MODULE_LIST;
2063 o_tooltip = [[VLCStringUtility sharedInstance] wrapString: _NS((char *)p_item->psz_longtext) toWidth: PREFS_WRAP];
2066 if (p_item->psz_text)
2067 o_labelString = _NS((char *)p_item->psz_text);
2069 o_labelString = @"";
2070 ADD_LABEL(o_label, mainFrame, 0, -3, o_labelString, o_tooltip)
2071 [o_label setAutoresizingMask:NSViewNotSizable ];
2072 [self addSubview: o_label];
2074 /* build the textfield */
2075 if (p_item->value.psz)
2076 o_textfieldString = _NS((char *)p_item->value.psz);
2078 o_textfieldString = @"";
2079 ADD_TEXTFIELD(o_textfield, mainFrame, [o_label frame].size.width + 2,
2080 mainFrame.size.height - 22, mainFrame.size.width -
2081 [o_label frame].size.width - 2, o_tooltip, o_textfieldString)
2082 [o_textfield setAutoresizingMask:NSViewWidthSizable ];
2083 [self addSubview: o_textfield];
2087 NSRect s_rc = mainFrame;
2088 s_rc.size.height = mainFrame.size.height - 30;
2089 s_rc.size.width = mainFrame.size.width - 12;
2092 o_scrollview = [[[NSScrollView alloc] initWithFrame: s_rc] retain];
2093 [o_scrollview setDrawsBackground: NO];
2094 [o_scrollview setBorderType: NSBezelBorder];
2095 [o_scrollview setAutohidesScrollers:YES];
2097 NSTableView *o_tableview;
2098 o_tableview = [[NSTableView alloc] initWithFrame : s_rc];
2099 [o_tableview setUsesAlternatingRowBackgroundColors:YES];
2100 [o_tableview setHeaderView:nil];
2101 /* TODO: find a good way to fix the row height and text size*/
2102 /* FIXME: support for multiple selection... */
2103 // [o_tableview setAllowsMultipleSelection:YES];
2105 NSCell *o_headerCell = [[NSCell alloc] initTextCell:@"Enabled"];
2106 NSCell *o_dataCell = [[NSButtonCell alloc] init];
2107 [(NSButtonCell*)o_dataCell setButtonType:NSSwitchButton];
2108 [o_dataCell setTitle:@""];
2109 [o_dataCell setFont:[NSFont systemFontOfSize:0]];
2110 NSTableColumn *o_tableColumn = [[NSTableColumn alloc]
2111 initWithIdentifier:@"Enabled"];
2112 [o_tableColumn setHeaderCell: o_headerCell];
2113 [o_tableColumn setDataCell: o_dataCell];
2114 [o_tableColumn setWidth:17];
2115 [o_tableview addTableColumn: o_tableColumn];
2117 o_headerCell = [[NSCell alloc] initTextCell:@"Module Name"];
2118 o_dataCell = [[NSTextFieldCell alloc] init];
2119 [o_dataCell setFont:[NSFont systemFontOfSize:12]];
2120 o_tableColumn = [[NSTableColumn alloc]
2121 initWithIdentifier:@"Module"];
2122 [o_tableColumn setHeaderCell: o_headerCell];
2123 [o_tableColumn setDataCell: o_dataCell];
2124 [o_tableColumn setWidth:s_rc.size.width - 34];
2125 [o_tableview addTableColumn: o_tableColumn];
2126 [o_tableview registerForDraggedTypes:[NSArray arrayWithObjects:
2127 @"VLC media player module", nil]];
2129 [o_tableview setDataSource:self];
2130 [o_tableview setTarget: self];
2131 [o_tableview setAction: @selector(tableChanged:)];
2132 [o_tableview sendActionOn:NSLeftMouseUpMask | NSLeftMouseDownMask |
2133 NSLeftMouseDraggedMask];
2134 [o_scrollview setDocumentView: o_tableview];
2136 [o_scrollview setAutoresizingMask:NSViewWidthSizable ];
2137 [o_scrollview setAutohidesScrollers:YES];
2138 [self addSubview: o_scrollview];
2144 - (void) alignWithXPosition:(int)i_xPos
2149 - (IBAction)tableChanged:(id)sender
2151 NSString *o_newstring = @"";
2152 NSUInteger count = [o_modulearray count];
2153 for (NSUInteger i = 0 ; i < count ; i++)
2154 if ([[[o_modulearray objectAtIndex:i] objectAtIndex:2]
2156 o_newstring = [o_newstring stringByAppendingString:
2157 [[o_modulearray objectAtIndex:i] objectAtIndex:0]];
2158 o_newstring = [o_newstring stringByAppendingString:@":"];
2161 [o_textfield setStringValue: [o_newstring
2162 substringToIndex: ([o_newstring length])?[o_newstring length] - 1:0]];
2167 [o_scrollview release];
2172 - (char *)stringValue
2174 return strdup([[o_textfield stringValue] UTF8String]);
2179 #warning Reset prefs of the module selector is broken atm.
2180 msg_Err(VLCIntf, "don't forget about modulelistconfig");
2181 [super resetValues];
2186 @implementation ModuleListConfigControl (NSTableDataSource)
2188 - (BOOL)tableView:(NSTableView*)table writeRows:(NSArray*)rows
2189 toPasteboard:(NSPasteboard*)pb
2191 // We only want to allow dragging of selected rows.
2192 NSEnumerator *iter = [rows objectEnumerator];
2194 while ((row = [iter nextObject]) != nil) {
2195 if (![table isRowSelected:[row intValue]])
2199 [pb declareTypes:[NSArray
2200 arrayWithObject:@"VLC media player module"] owner:nil];
2201 [pb setPropertyList:rows forType:@"VLC media player module"];
2205 - (NSDragOperation)tableView:(NSTableView*)table
2206 validateDrop:(id <NSDraggingInfo>)info proposedRow:(NSInteger)row
2207 proposedDropOperation:(NSTableViewDropOperation)op
2209 // Make drops at the end of the table go to the end.
2211 row = [table numberOfRows];
2212 op = NSTableViewDropAbove;
2213 [table setDropRow:row dropOperation:op];
2216 // We don't ever want to drop onto a row, only between rows.
2217 if (op == NSTableViewDropOn)
2218 [table setDropRow:(row+1) dropOperation:NSTableViewDropAbove];
2219 return NSTableViewDropAbove;
2222 - (BOOL)tableView:(NSTableView*)table acceptDrop:(id <NSDraggingInfo>)info
2223 row:(NSInteger)dropRow dropOperation:(NSTableViewDropOperation)op;
2225 NSPasteboard *pb = [info draggingPasteboard];
2226 NSDragOperation srcMask = [info draggingSourceOperationMask];
2233 // Intra-table drag - data is the array of rows.
2234 if (!accepted && (array =
2235 [pb propertyListForType:@"VLC media player module"]) != NULL) {
2236 NSEnumerator *iter = nil;
2238 BOOL isCopy = (srcMask & NSDragOperationMove) ? NO:YES;
2240 iter = [array objectEnumerator];
2241 while ((val = [iter nextObject]) != NULL) {
2242 NSArray *o_tmp = [[o_modulearray objectAtIndex:
2243 [val intValue]] mutableCopyWithZone:nil];
2244 [o_modulearray removeObject:o_tmp];
2245 [o_modulearray insertObject:o_tmp
2246 atIndex:(dropRow>[val intValue]) ? dropRow - 1 : dropRow];
2250 // Select the newly-dragged items.
2251 iter = [array objectEnumerator];
2253 [table deselectAll:self];
2255 [self tableChanged:self];
2256 [table setNeedsDisplay:YES];
2257 // Indicate that we finished the drag.
2261 [table setNeedsDisplay:YES];
2265 // An exception occurred. Uh-oh. Update the track table so that
2266 // it stays consistent, and re-raise the exception.
2268 [localException raise];
2269 [table setNeedsDisplay:YES];
2275 - (NSInteger)numberOfRowsInTableView:(NSTableView *)aTableView
2277 return [o_modulearray count];
2280 - (id)tableView:(NSTableView *)aTableView
2281 objectValueForTableColumn:(NSTableColumn *)aTableColumn row:(NSInteger)rowIndex
2283 if ([[aTableColumn identifier] isEqualToString: @"Enabled"])
2284 return [[o_modulearray objectAtIndex:rowIndex] objectAtIndex:2];
2285 if ([[aTableColumn identifier] isEqualToString: @"Module"])
2286 return [[o_modulearray objectAtIndex:rowIndex] objectAtIndex:1];
2291 - (void)tableView:(NSTableView *)aTableView setObjectValue:(id)anObject
2292 forTableColumn:(NSTableColumn *)aTableColumn row:(NSInteger)rowIndex
2294 [[o_modulearray objectAtIndex:rowIndex] replaceObjectAtIndex:2
2295 withObject: anObject];