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: \
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 [@(UP_ARROWHEAD OPTION_KEY) \
78 stringByAppendingString: string] \
79 action:nil keyEquivalent:@""]; \
80 [o_mi setKeyEquivalentModifierMask: \
81 NSControlKeyMask | NSAlternateKeyMask]; \
82 [o_mi setAlternate: YES]; \
84 (KEY_MODIFIER_CTRL | KEY_MODIFIER_ALT) | (value)]; \
85 [o_menu addItem: o_mi]; \
87 o_mi = [[NSMenuItem alloc] initWithTitle: \
88 [@(UP_ARROWHEAD UPWARDS_WHITE_ARROW) \
89 stringByAppendingString: string] \
90 action:nil keyEquivalent:@""]; \
91 [o_mi setKeyEquivalentModifierMask: \
92 NSControlKeyMask | NSShiftKeyMask]; \
93 [o_mi setAlternate: YES]; \
95 (KEY_MODIFIER_CTRL | KEY_MODIFIER_SHIFT) | (value)]; \
96 [o_menu addItem: o_mi]; \
98 o_mi = [[NSMenuItem alloc] initWithTitle: \
99 [@(UP_ARROWHEAD PLACE_OF_INTEREST_SIGN) \
100 stringByAppendingString: string] \
101 action:nil keyEquivalent:@""]; \
102 [o_mi setKeyEquivalentModifierMask: \
103 NSControlKeyMask | NSCommandKeyMask]; \
104 [o_mi setAlternate: YES]; \
106 (KEY_MODIFIER_CTRL | KEY_MODIFIER_COMMAND) | (value)]; \
107 [o_menu addItem: o_mi]; \
108 /* Ctrl+Alt+Shift */ \
109 o_mi = [[NSMenuItem alloc] initWithTitle: \
110 [@(UP_ARROWHEAD OPTION_KEY UPWARDS_WHITE_ARROW) \
111 stringByAppendingString: string] \
112 action:nil keyEquivalent:@""]; \
113 [o_mi setKeyEquivalentModifierMask: \
114 NSControlKeyMask | NSAlternateKeyMask | NSShiftKeyMask]; \
115 [o_mi setAlternate: YES]; \
117 (KEY_MODIFIER_CTRL | KEY_MODIFIER_ALT | KEY_MODIFIER_SHIFT) | \
119 [o_menu addItem: o_mi]; \
120 /* Ctrl+Alt+Apple */ \
121 o_mi = [[NSMenuItem alloc] initWithTitle: \
122 [@(UP_ARROWHEAD OPTION_KEY PLACE_OF_INTEREST_SIGN) \
123 stringByAppendingString: string] \
124 action:nil keyEquivalent:@""]; \
125 [o_mi setKeyEquivalentModifierMask: \
126 NSControlKeyMask | NSAlternateKeyMask | NSCommandKeyMask]; \
127 [o_mi setAlternate: YES]; \
129 (KEY_MODIFIER_CTRL | KEY_MODIFIER_ALT | KEY_MODIFIER_COMMAND) | \
131 [o_menu addItem: o_mi]; \
132 /* Ctrl+Shift+Apple */ \
133 o_mi = [[NSMenuItem alloc] initWithTitle: \
134 [@(UP_ARROWHEAD UPWARDS_WHITE_ARROW PLACE_OF_INTEREST_SIGN) \
135 stringByAppendingString: string] \
136 action:nil keyEquivalent:@""]; \
137 [o_mi setKeyEquivalentModifierMask: \
138 NSControlKeyMask | NSShiftKeyMask | NSCommandKeyMask]; \
139 [o_mi setAlternate: YES]; \
141 (KEY_MODIFIER_CTRL | KEY_MODIFIER_SHIFT | KEY_MODIFIER_COMMAND) | \
143 [o_menu addItem: o_mi]; \
144 /* Ctrl+Alt+Shift+Apple */ \
145 o_mi = [[NSMenuItem alloc] initWithTitle: \
146 [@(UP_ARROWHEAD OPTION_KEY UPWARDS_WHITE_ARROW PLACE_OF_INTEREST_SIGN ) \
147 stringByAppendingString: string] \
148 action:nil keyEquivalent:@""]; \
149 [o_mi setKeyEquivalentModifierMask: \
150 NSControlKeyMask | NSAlternateKeyMask | NSShiftKeyMask | \
152 [o_mi setAlternate: YES]; \
154 (KEY_MODIFIER_CTRL | KEY_MODIFIER_ALT | KEY_MODIFIER_SHIFT | \
155 KEY_MODIFIER_COMMAND) | (value)]; \
156 [o_menu addItem: o_mi]; \
158 o_mi = [[NSMenuItem alloc] initWithTitle: \
159 [@(OPTION_KEY) stringByAppendingString: string] \
160 action:nil keyEquivalent:@""]; \
161 [o_mi setKeyEquivalentModifierMask: \
162 NSAlternateKeyMask]; \
163 [o_mi setAlternate: YES]; \
165 KEY_MODIFIER_ALT | (value)]; \
166 [o_menu addItem: o_mi]; \
168 o_mi = [[NSMenuItem alloc] initWithTitle: \
169 [@(OPTION_KEY UPWARDS_WHITE_ARROW) stringByAppendingString: string] \
170 action:nil keyEquivalent:@""]; \
171 [o_mi setKeyEquivalentModifierMask: \
172 NSAlternateKeyMask | NSShiftKeyMask]; \
173 [o_mi setAlternate: YES]; \
175 (KEY_MODIFIER_ALT | KEY_MODIFIER_SHIFT) | (value)]; \
176 [o_menu addItem: o_mi]; \
178 o_mi = [[NSMenuItem alloc] initWithTitle: \
179 [@(OPTION_KEY PLACE_OF_INTEREST_SIGN) \
180 stringByAppendingString: string] action:nil keyEquivalent:@""]; \
181 [o_mi setKeyEquivalentModifierMask: \
182 NSAlternateKeyMask | NSCommandKeyMask]; \
183 [o_mi setAlternate: YES]; \
185 (KEY_MODIFIER_ALT | KEY_MODIFIER_COMMAND) | (value)]; \
186 [o_menu addItem: o_mi]; \
187 /* Alt+Shift+Apple */ \
188 o_mi = [[NSMenuItem alloc] initWithTitle: \
189 [@(OPTION_KEY UPWARDS_WHITE_ARROW PLACE_OF_INTEREST_SIGN) \
190 stringByAppendingString: string] \
191 action:nil keyEquivalent:@""]; \
192 [o_mi setKeyEquivalentModifierMask: \
193 NSAlternateKeyMask | NSShiftKeyMask | NSCommandKeyMask]; \
194 [o_mi setAlternate: YES]; \
196 (KEY_MODIFIER_ALT | KEY_MODIFIER_SHIFT | KEY_MODIFIER_COMMAND) | \
198 [o_menu addItem: o_mi]; \
200 o_mi = [[NSMenuItem alloc] initWithTitle: \
201 [@(UPWARDS_WHITE_ARROW) \
202 stringByAppendingString: string] \
203 action:nil keyEquivalent:@""]; \
204 [o_mi setKeyEquivalentModifierMask: \
206 [o_mi setAlternate: YES]; \
208 KEY_MODIFIER_SHIFT | (value)]; \
209 [o_menu addItem: o_mi]; \
211 o_mi = [[NSMenuItem alloc] initWithTitle: \
212 [@(UPWARDS_WHITE_ARROW PLACE_OF_INTEREST_SIGN) \
213 stringByAppendingString: string] \
214 action:nil keyEquivalent:@""]; \
215 [o_mi setKeyEquivalentModifierMask: \
216 NSShiftKeyMask | NSCommandKeyMask]; \
217 [o_mi setAlternate: YES]; \
219 (KEY_MODIFIER_SHIFT | KEY_MODIFIER_COMMAND) | (value)]; \
220 [o_menu addItem: o_mi]; \
222 o_mi = [[NSMenuItem alloc] initWithTitle: \
223 [@(PLACE_OF_INTEREST_SIGN) \
224 stringByAppendingString: string] \
225 action:nil keyEquivalent:@""]; \
226 [o_mi setKeyEquivalentModifierMask: \
228 [o_mi setAlternate: YES]; \
230 KEY_MODIFIER_COMMAND | (value)]; \
231 [o_menu addItem: o_mi]; \
234 #define ADD_LABEL(o_label, superFrame, x_offset, my_y_offset, label, \
237 NSRect s_rc = superFrame; \
238 s_rc.size.height = 17; \
239 s_rc.origin.x = x_offset - 3; \
240 s_rc.origin.y = superFrame.size.height - 17 + my_y_offset; \
241 o_label = [[[NSTextField alloc] initWithFrame: s_rc] retain]; \
242 [o_label setDrawsBackground: NO]; \
243 [o_label setBordered: NO]; \
244 [o_label setEditable: NO]; \
245 [o_label setSelectable: NO]; \
246 [o_label setStringValue: label]; \
247 [o_label setToolTip: tooltip]; \
248 [o_label setFont:[NSFont systemFontOfSize:0]]; \
249 [o_label sizeToFit]; \
252 #define ADD_TEXTFIELD(o_textfield, superFrame, x_offset, my_y_offset, \
253 my_width, tooltip, init_value) \
255 NSRect s_rc = superFrame; \
256 s_rc.origin.x = x_offset; \
257 s_rc.origin.y = my_y_offset; \
258 s_rc.size.height = 22; \
259 s_rc.size.width = my_width; \
260 o_textfield = [[[NSTextField alloc] initWithFrame: s_rc] retain]; \
261 [o_textfield setFont:[NSFont systemFontOfSize:0]]; \
262 [o_textfield setToolTip: tooltip]; \
263 [o_textfield setStringValue: init_value]; \
266 #define ADD_SECURETEXTFIELD(o_textfield, superFrame, x_offset, my_y_offset, \
267 my_width, tooltip, init_value) \
269 NSRect s_rc = superFrame; \
270 s_rc.origin.x = x_offset; \
271 s_rc.origin.y = my_y_offset; \
272 s_rc.size.height = 22; \
273 s_rc.size.width = my_width; \
274 o_textfield = [[[NSSecureTextField alloc] initWithFrame: s_rc] retain]; \
275 [o_textfield setFont:[NSFont systemFontOfSize:0]]; \
276 [o_textfield setToolTip: tooltip]; \
277 [o_textfield setStringValue: init_value]; \
280 #define ADD_COMBO(o_combo, superFrame, x_offset, my_y_offset, x2_offset, \
283 NSRect s_rc = superFrame; \
284 s_rc.origin.x = x_offset + 2; \
285 s_rc.origin.y = my_y_offset; \
286 s_rc.size.height = 26; \
287 s_rc.size.width = superFrame.size.width + 2 - s_rc.origin.x - \
289 o_combo = [[[NSComboBox alloc] initWithFrame: s_rc] retain]; \
290 [o_combo setFont:[NSFont systemFontOfSize:0]]; \
291 [o_combo setToolTip: tooltip]; \
292 [o_combo setUsesDataSource:TRUE]; \
293 [o_combo setDataSource:self]; \
294 [o_combo setNumberOfVisibleItems:10]; \
295 [o_combo setCompletes:YES]; \
298 #define ADD_RIGHT_BUTTON(o_button, superFrame, x_offset, my_y_offset, \
301 NSRect s_rc = superFrame; \
302 o_button = [[[NSButton alloc] initWithFrame: s_rc] retain]; \
303 [o_button setButtonType: NSMomentaryPushInButton]; \
304 [o_button setBezelStyle: NSRoundedBezelStyle]; \
305 [o_button setTitle: title]; \
306 [o_button setFont:[NSFont systemFontOfSize:0]]; \
307 [o_button sizeToFit]; \
308 s_rc = [o_button frame]; \
309 s_rc.origin.x = superFrame.size.width - [o_button frame].size.width - 6;\
310 s_rc.origin.y = my_y_offset - 6; \
311 s_rc.size.width += 12; \
312 [o_button setFrame: s_rc]; \
313 [o_button setToolTip: tooltip]; \
314 [o_button setTarget: self]; \
315 [o_button setAction: @selector(openFileDialog:)]; \
318 #define ADD_POPUP(o_popup, superFrame, x_offset, my_y_offset, x2_offset, \
321 NSRect s_rc = superFrame; \
322 s_rc.origin.x = x_offset - 1; \
323 s_rc.origin.y = my_y_offset; \
324 s_rc.size.height = 26; \
325 s_rc.size.width = superFrame.size.width + 2 - s_rc.origin.x - \
327 o_popup = [[[NSPopUpButton alloc] initWithFrame: s_rc] retain]; \
328 [o_popup setFont:[NSFont systemFontOfSize:0]]; \
329 [o_popup setToolTip: tooltip]; \
332 #define ADD_STEPPER(o_stepper, superFrame, x_offset, my_y_offset, tooltip, \
335 NSRect s_rc = superFrame; \
336 s_rc.origin.x = x_offset; \
337 s_rc.origin.y = my_y_offset; \
338 s_rc.size.height = 23; \
339 s_rc.size.width = 23; \
340 o_stepper = [[[NSStepper alloc] initWithFrame: s_rc] retain]; \
341 [o_stepper setFont:[NSFont systemFontOfSize:0]]; \
342 [o_stepper setToolTip: tooltip]; \
343 [o_stepper setMaxValue: higher]; \
344 [o_stepper setMinValue: lower]; \
345 [o_stepper setTarget: self]; \
346 [o_stepper setAction: @selector(stepperChanged:)]; \
347 [o_stepper sendActionOn:NSLeftMouseUpMask | NSLeftMouseDownMask | \
348 NSLeftMouseDraggedMask]; \
351 #define ADD_SLIDER(o_slider, superFrame, x_offset, my_y_offset, my_width, \
352 tooltip, lower, higher) \
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 = 21; \
358 s_rc.size.width = my_width; \
359 o_slider = [[[NSSlider alloc] initWithFrame: s_rc] retain]; \
360 [o_slider setFont:[NSFont systemFontOfSize:0]]; \
361 [o_slider setToolTip: tooltip]; \
362 [o_slider setMaxValue: higher]; \
363 [o_slider setMinValue: lower]; \
366 #define ADD_CHECKBOX(o_checkbox, superFrame, x_offset, my_y_offset, label, \
367 tooltip, init_value, position) \
369 NSRect s_rc = superFrame; \
370 s_rc.size.height = 18; \
371 s_rc.origin.x = x_offset - 2; \
372 s_rc.origin.y = superFrame.size.height - 18 + my_y_offset; \
373 o_checkbox = [[[NSButton alloc] initWithFrame: s_rc] retain]; \
374 [o_checkbox setFont:[NSFont systemFontOfSize:0]]; \
375 [o_checkbox setButtonType: NSSwitchButton]; \
376 [o_checkbox setImagePosition: position]; \
377 [o_checkbox setIntValue: init_value]; \
378 [o_checkbox setTitle: label]; \
379 [o_checkbox setToolTip: tooltip]; \
380 [o_checkbox sizeToFit]; \
383 @implementation VLCConfigControl
384 @synthesize type = i_type, viewType = i_view_type, advanced = b_advanced;
386 - (id)initWithFrame: (NSRect)frame
388 return [self initWithFrame: frame
392 - (id)initWithFrame: (NSRect)frame
393 item: (module_config_t *)_p_item
395 self = [super initWithFrame: frame];
399 psz_name = p_item->psz_name;
401 i_type = p_item->i_type;
403 b_advanced = p_item->b_advanced;
404 [self setAutoresizingMask:NSViewWidthSizable | NSViewMinYMargin ];
409 - (void)setYPos:(int)i_yPos
411 NSRect frame = [self frame];
412 frame.origin.y = i_yPos;
413 [self setFrame:frame];
418 if (o_label) [o_label release];
423 + (int)calcVerticalMargin: (int)i_curItem lastItem: (int)i_lastItem
427 case CONFIG_ITEM_STRING:
428 case CONFIG_ITEM_PASSWORD:
430 case CONFIG_ITEM_STRING:
431 case CONFIG_ITEM_PASSWORD:
434 case CONFIG_ITEM_STRING_LIST:
437 case CONFIG_ITEM_LOADFILE:
438 case CONFIG_ITEM_SAVEFILE:
441 case CONFIG_ITEM_MODULE:
444 case CONFIG_ITEM_INTEGER:
447 case CONFIG_ITEM_RANGED_INTEGER:
450 case CONFIG_ITEM_BOOL:
453 case CONFIG_ITEM_KEY:
456 case CONFIG_ITEM_MODULE_LIST:
464 case CONFIG_ITEM_STRING_LIST:
466 case CONFIG_ITEM_STRING:
467 case CONFIG_ITEM_PASSWORD:
470 case CONFIG_ITEM_STRING_LIST:
473 case CONFIG_ITEM_LOADFILE:
474 case CONFIG_ITEM_SAVEFILE:
477 case CONFIG_ITEM_MODULE:
480 case CONFIG_ITEM_INTEGER:
483 case CONFIG_ITEM_RANGED_INTEGER:
486 case CONFIG_ITEM_BOOL:
489 case CONFIG_ITEM_KEY:
492 case CONFIG_ITEM_MODULE_LIST:
500 case CONFIG_ITEM_LOADFILE:
501 case CONFIG_ITEM_SAVEFILE:
503 case CONFIG_ITEM_STRING:
504 case CONFIG_ITEM_PASSWORD:
507 case CONFIG_ITEM_STRING_LIST:
510 case CONFIG_ITEM_LOADFILE:
511 case CONFIG_ITEM_SAVEFILE:
514 case CONFIG_ITEM_MODULE:
517 case CONFIG_ITEM_INTEGER:
520 case CONFIG_ITEM_RANGED_INTEGER:
523 case CONFIG_ITEM_BOOL:
526 case CONFIG_ITEM_KEY:
529 case CONFIG_ITEM_MODULE_LIST:
537 case CONFIG_ITEM_MODULE:
539 case CONFIG_ITEM_STRING:
540 case CONFIG_ITEM_PASSWORD:
543 case CONFIG_ITEM_STRING_LIST:
546 case CONFIG_ITEM_LOADFILE:
547 case CONFIG_ITEM_SAVEFILE:
550 case CONFIG_ITEM_MODULE:
553 case CONFIG_ITEM_INTEGER:
556 case CONFIG_ITEM_RANGED_INTEGER:
559 case CONFIG_ITEM_BOOL:
562 case CONFIG_ITEM_KEY:
565 case CONFIG_ITEM_MODULE_LIST:
573 case CONFIG_ITEM_INTEGER:
575 case CONFIG_ITEM_STRING:
576 case CONFIG_ITEM_PASSWORD:
579 case CONFIG_ITEM_STRING_LIST:
582 case CONFIG_ITEM_LOADFILE:
583 case CONFIG_ITEM_SAVEFILE:
586 case CONFIG_ITEM_MODULE:
589 case CONFIG_ITEM_INTEGER:
592 case CONFIG_ITEM_RANGED_INTEGER:
595 case CONFIG_ITEM_BOOL:
598 case CONFIG_ITEM_KEY:
601 case CONFIG_ITEM_MODULE_LIST:
609 case CONFIG_ITEM_RANGED_INTEGER:
611 case CONFIG_ITEM_STRING:
612 case CONFIG_ITEM_PASSWORD:
615 case CONFIG_ITEM_STRING_LIST:
618 case CONFIG_ITEM_LOADFILE:
619 case CONFIG_ITEM_SAVEFILE:
622 case CONFIG_ITEM_MODULE:
625 case CONFIG_ITEM_INTEGER:
628 case CONFIG_ITEM_RANGED_INTEGER:
631 case CONFIG_ITEM_BOOL:
634 case CONFIG_ITEM_KEY:
637 case CONFIG_ITEM_MODULE_LIST:
645 case CONFIG_ITEM_BOOL:
647 case CONFIG_ITEM_STRING:
648 case CONFIG_ITEM_PASSWORD:
651 case CONFIG_ITEM_STRING_LIST:
654 case CONFIG_ITEM_LOADFILE:
655 case CONFIG_ITEM_SAVEFILE:
658 case CONFIG_ITEM_MODULE:
661 case CONFIG_ITEM_INTEGER:
664 case CONFIG_ITEM_RANGED_INTEGER:
667 case CONFIG_ITEM_BOOL:
670 case CONFIG_ITEM_KEY:
673 case CONFIG_ITEM_MODULE_LIST:
681 case CONFIG_ITEM_KEY:
683 case CONFIG_ITEM_STRING:
684 case CONFIG_ITEM_PASSWORD:
687 case CONFIG_ITEM_STRING_LIST:
690 case CONFIG_ITEM_LOADFILE:
691 case CONFIG_ITEM_SAVEFILE:
694 case CONFIG_ITEM_MODULE:
697 case CONFIG_ITEM_INTEGER:
700 case CONFIG_ITEM_RANGED_INTEGER:
703 case CONFIG_ITEM_BOOL:
706 case CONFIG_ITEM_KEY:
709 case CONFIG_ITEM_MODULE_LIST:
717 case CONFIG_ITEM_MODULE_LIST:
719 case CONFIG_ITEM_STRING:
720 case CONFIG_ITEM_PASSWORD:
723 case CONFIG_ITEM_STRING_LIST:
726 case CONFIG_ITEM_LOADFILE:
727 case CONFIG_ITEM_SAVEFILE:
730 case CONFIG_ITEM_MODULE:
733 case CONFIG_ITEM_INTEGER:
736 case CONFIG_ITEM_RANGED_INTEGER:
739 case CONFIG_ITEM_BOOL:
742 case CONFIG_ITEM_KEY:
745 case CONFIG_ITEM_MODULE_LIST:
760 + (VLCConfigControl *)newControl: (module_config_t *)_p_item
761 withView: (NSView *)o_parent_view
763 VLCConfigControl *p_control = NULL;
765 switch(_p_item->i_type) {
766 case CONFIG_ITEM_STRING:
767 case CONFIG_ITEM_PASSWORD:
768 if (!_p_item->list_count) {
769 p_control = [[StringConfigControl alloc]
770 initWithItem: _p_item
771 withView: o_parent_view];
773 p_control = [[StringListConfigControl alloc]
774 initWithItem: _p_item
775 withView: o_parent_view];
778 case CONFIG_ITEM_LOADFILE:
779 case CONFIG_ITEM_SAVEFILE:
780 case CONFIG_ITEM_DIRECTORY:
781 p_control = [[FileConfigControl alloc]
782 initWithItem: _p_item
783 withView: o_parent_view];
785 case CONFIG_ITEM_MODULE:
786 case CONFIG_ITEM_MODULE_CAT:
787 p_control = [[ModuleConfigControl alloc]
788 initWithItem: _p_item
789 withView: o_parent_view];
791 case CONFIG_ITEM_INTEGER:
792 if (_p_item->list_count)
793 p_control = [[IntegerListConfigControl alloc] initWithItem: _p_item withView: o_parent_view];
794 else if ((_p_item->min.i != 0 || _p_item->max.i != 0) && (_p_item->min.i != INT_MIN || _p_item->max.i != INT_MAX))
795 p_control = [[RangedIntegerConfigControl alloc] initWithItem: _p_item withView: o_parent_view];
797 p_control = [[IntegerConfigControl alloc] initWithItem: _p_item withView: o_parent_view];
799 case CONFIG_ITEM_BOOL:
800 p_control = [[BoolConfigControl alloc]
801 initWithItem: _p_item
802 withView: o_parent_view];
804 case CONFIG_ITEM_FLOAT:
805 if ((_p_item->min.i != 0 || _p_item->max.i != 0) && (_p_item->min.i != INT_MIN || _p_item->max.i != INT_MAX))
806 p_control = [[RangedFloatConfigControl alloc] initWithItem: _p_item withView: o_parent_view];
808 p_control = [[FloatConfigControl alloc] initWithItem: _p_item withView: o_parent_view];
810 /* don't display keys in the advanced settings, since the current controls
811 are broken by design. The user is required to change hotkeys in the sprefs
812 and can only change really advanced stuff here..
813 case CONFIG_ITEM_KEY:
814 p_control = [[KeyConfigControl alloc]
815 initWithItem: _p_item
816 withView: o_parent_view];
818 case CONFIG_ITEM_MODULE_LIST:
819 case CONFIG_ITEM_MODULE_LIST_CAT:
820 p_control = [[ModuleListConfigControl alloc] initWithItem: _p_item withView: o_parent_view];
823 p_control = [[SectionControl alloc] initWithItem: _p_item withView: o_parent_view];
833 return _NS(psz_name);
846 - (char *)stringValue
854 switch(p_item->i_type) {
855 case CONFIG_ITEM_STRING:
856 case CONFIG_ITEM_PASSWORD:
857 case CONFIG_ITEM_LOADFILE:
858 case CONFIG_ITEM_SAVEFILE:
859 case CONFIG_ITEM_DIRECTORY:
860 case CONFIG_ITEM_MODULE:
861 case CONFIG_ITEM_MODULE_LIST:
862 case CONFIG_ITEM_MODULE_LIST_CAT:
863 config_PutPsz(VLCIntf, psz_name, [self stringValue]);
865 case CONFIG_ITEM_KEY:
866 /* So you don't need to restart to have the changes take effect */
867 val.i_int = [self intValue];
868 var_Set(VLCIntf->p_libvlc, psz_name, val);
869 case CONFIG_ITEM_INTEGER:
870 case CONFIG_ITEM_BOOL:
871 config_PutInt(VLCIntf, psz_name, [self intValue]);
873 case CONFIG_ITEM_FLOAT:
874 config_PutFloat(VLCIntf, psz_name, [self floatValue]);
885 return [o_label frame].size.width;
888 - (void) alignWithXPosition:(int)i_xPos;
890 /* FIXME: not implemented atm, but created to shut up the warning
891 * about "method definition not found" -- FK @ 7/24/05 */
895 @implementation StringConfigControl
896 - (id) initWithItem: (module_config_t *)_p_item
897 withView: (NSView *)o_parent_view
899 NSRect mainFrame = [o_parent_view frame];
900 NSString *o_labelString, *o_textfieldString, *o_textfieldTooltip;
901 mainFrame.size.height = 22;
902 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN;
903 mainFrame.origin.x = LEFTMARGIN;
904 mainFrame.origin.y = 0;
906 if ([super initWithFrame: mainFrame item: _p_item] != nil) {
907 if (p_item->i_type == CONFIG_ITEM_PASSWORD)
908 i_view_type = CONFIG_ITEM_PASSWORD;
910 i_view_type = CONFIG_ITEM_STRING;
912 o_textfieldTooltip = [[VLCStringUtility sharedInstance] wrapString: _NS((char *)p_item->psz_longtext) toWidth: PREFS_WRAP];
915 if (p_item->psz_text)
916 o_labelString = _NS((char *)p_item->psz_text);
919 ADD_LABEL(o_label, mainFrame, 0, -3, o_labelString, o_textfieldTooltip)
920 [o_label setAutoresizingMask:NSViewNotSizable ];
921 [self addSubview: o_label];
923 /* build the textfield */
924 if (p_item->value.psz)
925 o_textfieldString = [NSString stringWithCString:p_item->value.psz encoding:NSUTF8StringEncoding];
927 o_textfieldString = @"";
928 if (p_item->i_type == CONFIG_ITEM_PASSWORD) {
929 ADD_SECURETEXTFIELD(o_textfield, mainFrame, [o_label frame].size.width + 2,
930 0, mainFrame.size.width - [o_label frame].size.width -
931 2, o_textfieldTooltip, o_textfieldString)
933 ADD_TEXTFIELD(o_textfield, mainFrame, [o_label frame].size.width + 2,
934 0, mainFrame.size.width - [o_label frame].size.width -
935 2, o_textfieldTooltip, o_textfieldString)
937 [o_textfield setAutoresizingMask:NSViewWidthSizable ];
939 [self addSubview: o_textfield];
944 - (void) alignWithXPosition:(int)i_xPos
947 NSRect superFrame = [self frame];
948 frame = [o_label frame];
949 frame.origin.x = i_xPos - frame.size.width - 3;
950 [o_label setFrame:frame];
952 frame = [o_textfield frame];
953 frame.origin.x = i_xPos + 2;
954 frame.size.width = superFrame.size.width - frame.origin.x - 1;
955 [o_textfield setFrame:frame];
960 [o_textfield release];
964 - (char *)stringValue
966 return strdup([[o_textfield stringValue] UTF8String]);
971 NSString *o_textfieldString;
972 char *psz_value = config_GetPsz(VLCIntf, p_item->psz_name);
974 o_textfieldString = _NS(psz_value);
976 o_textfieldString = @"";
982 @implementation StringListConfigControl
983 - (id) initWithItem: (module_config_t *)_p_item
984 withView: (NSView *)o_parent_view
986 NSRect mainFrame = [o_parent_view frame];
987 NSString *o_labelString, *o_textfieldTooltip;
988 mainFrame.size.height = 22;
989 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN + 1;
990 mainFrame.origin.x = LEFTMARGIN;
991 mainFrame.origin.y = 0;
993 if ([super initWithFrame: mainFrame item: _p_item] != nil) {
994 i_view_type = CONFIG_ITEM_STRING_LIST;
996 o_textfieldTooltip = [[VLCStringUtility sharedInstance] wrapString: _NS(p_item->psz_longtext) toWidth: PREFS_WRAP];
999 if (p_item->psz_text)
1000 o_labelString = _NS((char *)p_item->psz_text);
1002 o_labelString = @"";
1003 ADD_LABEL(o_label, mainFrame, 0, -3, o_labelString, o_textfieldTooltip)
1004 [o_label setAutoresizingMask:NSViewNotSizable ];
1005 [self addSubview: o_label];
1007 /* build the textfield */
1008 ADD_POPUP(o_popup, mainFrame, [o_label frame].size.width,
1009 -2, 0, o_textfieldTooltip)
1010 [o_popup setAutoresizingMask:NSViewWidthSizable];
1013 for (int i_index = 0; i_index < p_item->list_count; i_index++) {
1015 if (p_item->list_text && p_item->list_text[i_index])
1016 o_text = _NS((char *)p_item->list_text[i_index]);
1018 o_text = _NS((char *)p_item->list.psz[i_index]);
1019 [o_popup addItemWithTitle: o_text];
1021 /* select default item */
1022 if (!p_item->value.psz && !p_item->list.psz[i_index])
1023 [o_popup selectItemAtIndex: i_index];
1024 else if (p_item->value.psz && p_item->list.psz[i_index] &&
1025 !strcmp(p_item->value.psz, p_item->list.psz[i_index]))
1026 [o_popup selectItemAtIndex: i_index];
1029 [self addSubview: o_popup];
1034 - (void) alignWithXPosition:(int)i_xPos
1037 NSRect superFrame = [self frame];
1038 frame = [o_label frame];
1039 frame.origin.x = i_xPos - frame.size.width - 3;
1040 [o_label setFrame:frame];
1042 frame = [o_popup frame];
1043 frame.origin.x = i_xPos + 2;
1044 frame.size.width = superFrame.size.width - frame.origin.x + 2;
1045 [o_popup setFrame:frame];
1054 - (char *)stringValue
1056 if ([o_popup indexOfSelectedItem] >= 0) {
1057 if (p_item->list.psz[[o_popup indexOfSelectedItem]] != NULL)
1058 return strdup(p_item->list.psz[[o_popup indexOfSelectedItem]]);
1066 char *psz_value = config_GetPsz(VLCIntf, p_item->psz_name);
1068 for (int i_index = 0; i_index < p_item->list_count; i_index++) {
1069 if (!psz_value && !p_item->list.psz[i_index])
1070 [o_popup selectItemAtIndex: i_index];
1071 else if (psz_value && p_item->list.psz[i_index] &&
1072 !strcmp(psz_value, p_item->list.psz[i_index]))
1073 [o_popup selectItemAtIndex: i_index];
1077 [super resetValues];
1081 @implementation FileConfigControl
1082 - (id) initWithItem: (module_config_t *)_p_item
1083 withView: (NSView *)o_parent_view
1085 NSRect mainFrame = [o_parent_view frame];
1086 NSString *o_labelString, *o_itemTooltip, *o_textfieldString;
1087 mainFrame.size.height = 46;
1088 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN;
1089 mainFrame.origin.x = LEFTMARGIN;
1090 mainFrame.origin.y = 0;
1092 if ([super initWithFrame: mainFrame item: _p_item] != nil) {
1093 i_view_type = CONFIG_ITEM_LOADFILE;
1095 o_itemTooltip = [[VLCStringUtility sharedInstance] wrapString: _NS((char *)p_item->psz_longtext) toWidth: PREFS_WRAP];
1097 /* is it a directory */
1098 b_directory = ([self type] == CONFIG_ITEM_DIRECTORY) ? YES : NO;
1101 if (p_item->psz_text)
1102 o_labelString = _NS((char *)p_item->psz_text);
1104 o_labelString = @"";
1105 ADD_LABEL(o_label, mainFrame, 0, 3, o_labelString, o_itemTooltip)
1106 [o_label setAutoresizingMask:NSViewNotSizable ];
1107 [self addSubview: o_label];
1109 /* build the button */
1110 ADD_RIGHT_BUTTON(o_button, mainFrame, 0, 0, o_itemTooltip,
1112 [o_button setAutoresizingMask:NSViewMinXMargin ];
1113 [self addSubview: o_button];
1115 /* build the textfield */
1116 if (p_item->value.psz)
1117 o_textfieldString = [NSString stringWithFormat: @"%s", (char *)p_item->value.psz];
1119 o_textfieldString = @"";
1120 ADD_TEXTFIELD(o_textfield, mainFrame, 12, 2, mainFrame.size.width -
1121 8 - [o_button frame].size.width,
1122 o_itemTooltip, o_textfieldString)
1123 [o_textfield setAutoresizingMask:NSViewWidthSizable ];
1124 [self addSubview: o_textfield];
1129 - (void) alignWithXPosition:(int)i_xPos
1136 [o_textfield release];
1141 - (IBAction)openFileDialog: (id)sender
1143 NSOpenPanel *o_open_panel = [NSOpenPanel openPanel];
1145 [o_open_panel setTitle: (b_directory)?
1146 _NS("Select a directory"):_NS("Select a file")];
1147 [o_open_panel setPrompt: _NS("Select")];
1148 [o_open_panel setAllowsMultipleSelection: NO];
1149 [o_open_panel setCanChooseFiles: !b_directory];
1150 [o_open_panel setCanChooseDirectories: b_directory];
1151 [o_open_panel beginSheetModalForWindow:[sender window] completionHandler:^(NSInteger returnCode) {
1152 if (returnCode == NSOKButton) {
1153 NSString *o_path = [[[o_open_panel URLs] objectAtIndex:0] path];
1154 [o_textfield setStringValue: o_path];
1159 - (char *)stringValue
1161 if ([[o_textfield stringValue] length] != 0)
1162 return strdup([[o_textfield stringValue] fileSystemRepresentation]);
1169 NSString *o_textfieldString;
1170 char *psz_value = config_GetPsz(VLCIntf, p_item->psz_name);
1172 o_textfieldString = [NSString stringWithFormat: @"%s", psz_value];
1174 o_textfieldString = @"";
1177 [super resetValues];
1181 @implementation ModuleConfigControl
1182 - (id) initWithItem: (module_config_t *)_p_item
1183 withView: (NSView *)o_parent_view
1185 NSRect mainFrame = [o_parent_view frame];
1186 NSString *o_labelString, *o_popupTooltip;
1187 mainFrame.size.height = 22;
1188 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN + 1;
1189 mainFrame.origin.x = LEFTMARGIN;
1190 mainFrame.origin.y = 0;
1192 if ([super initWithFrame: mainFrame item: _p_item] != nil) {
1193 i_view_type = CONFIG_ITEM_MODULE;
1195 o_popupTooltip = [[VLCStringUtility sharedInstance] wrapString: _NS((char *)p_item->psz_longtext) toWidth: PREFS_WRAP];
1198 if (p_item->psz_text)
1199 o_labelString = _NS((char *)p_item->psz_text);
1201 o_labelString = @"";
1203 ADD_LABEL(o_label, mainFrame, 0, -1, o_labelString, o_popupTooltip)
1204 [o_label setAutoresizingMask:NSViewNotSizable ];
1205 [self addSubview: o_label];
1207 /* build the popup */
1208 ADD_POPUP(o_popup, mainFrame, [o_label frame].size.width,
1209 -2, 0, o_popupTooltip)
1210 [o_popup setAutoresizingMask:NSViewWidthSizable ];
1211 [o_popup addItemWithTitle: _NS("Default")];
1212 [[o_popup lastItem] setTag: -1];
1213 [o_popup selectItem: [o_popup lastItem]];
1216 [self addSubview: o_popup];
1221 - (void) alignWithXPosition:(int)i_xPos
1224 NSRect superFrame = [self frame];
1225 frame = [o_label frame];
1226 frame.origin.x = i_xPos - frame.size.width - 3;
1227 [o_label setFrame:frame];
1229 frame = [o_popup frame];
1230 frame.origin.x = i_xPos - 1;
1231 frame.size.width = superFrame.size.width - frame.origin.x + 2;
1232 [o_popup setFrame:frame];
1241 - (char *)stringValue
1243 NSString *newval = [o_popup titleOfSelectedItem];
1244 char *returnval = NULL;
1245 size_t i_module_index;
1246 module_t *p_parser, **p_list;
1249 p_list = module_list_get(&count);
1250 for (i_module_index = 0; i_module_index < count; i_module_index++) {
1251 p_parser = p_list[i_module_index];
1253 if (p_item->i_type == CONFIG_ITEM_MODULE) {
1254 if (module_provides(p_parser, p_item->psz_type)) {
1255 NSString *o_description = _NS(module_get_name(p_parser, TRUE));
1256 if ([newval isEqualToString: o_description]) {
1257 returnval = strdup(module_get_object(p_parser));
1262 if (module_is_main(p_parser))
1265 unsigned int confsize;
1266 module_config_t *p_config = module_config_get(p_parser, &confsize);
1267 for (size_t i = 0; i < confsize; i++) {
1268 module_config_t *p_cfg = p_config + i;
1269 /* Hack: required subcategory is stored in i_min */
1270 if (p_cfg->i_type == CONFIG_SUBCATEGORY &&
1271 p_cfg->value.i == p_cfg->min.i) {
1272 NSString *o_description = _NS(module_get_name(p_parser, TRUE));
1273 if ([newval isEqualToString: o_description]) {
1274 returnval = strdup(module_get_object(p_parser));
1279 module_config_free(p_config);
1282 module_list_free(p_list);
1288 /* build a list of available modules */
1289 module_t *p_parser, **p_list;
1292 p_list = module_list_get(&count);
1293 for (size_t i_index = 0; i_index < count; i_index++) {
1294 p_parser = p_list[i_index];
1296 if (p_item->i_type == CONFIG_ITEM_MODULE) {
1297 if (module_provides(p_parser, p_item->psz_type)) {
1298 NSString *o_description = _NS(module_get_name(p_parser, TRUE));
1299 [o_popup addItemWithTitle: o_description];
1300 char *psz_value = config_GetPsz(VLCIntf, p_item->psz_name);
1303 !strcmp(psz_value, module_get_object(p_parser)))
1304 [o_popup selectItem:[o_popup lastItem]];
1309 if (module_is_main(p_parser))
1311 unsigned int confsize;
1313 module_config_t *p_configlist = module_config_get(p_parser, &confsize);
1314 for (size_t i = 0; i < confsize; i++) {
1315 module_config_t *p_config = &p_configlist[i];
1316 /* Hack: required subcategory is stored in i_min */
1317 if (p_config->i_type == CONFIG_SUBCATEGORY &&
1318 p_config->value.i == p_item->min.i) {
1319 NSString *o_description = _NS(module_get_name(p_parser, TRUE));
1320 [o_popup addItemWithTitle: o_description];
1322 if (p_item->value.psz && !strcmp(p_item->value.psz,
1323 module_get_object(p_parser)))
1324 [o_popup selectItem:[o_popup lastItem]];
1327 module_config_free(p_configlist);
1330 module_list_free(p_list);
1331 [super resetValues];
1335 @implementation IntegerConfigControl
1336 - (id) initWithItem: (module_config_t *)_p_item
1337 withView: (NSView *)o_parent_view
1339 NSRect mainFrame = [o_parent_view frame];
1340 NSString *o_labelString, *o_tooltip;
1341 mainFrame.size.height = 23;
1342 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN + 1;
1343 mainFrame.origin.x = LEFTMARGIN;
1344 mainFrame.origin.y = 0;
1346 if ([super initWithFrame: mainFrame item: _p_item] != nil) {
1347 i_view_type = CONFIG_ITEM_INTEGER;
1349 o_tooltip = [[VLCStringUtility sharedInstance] wrapString: _NS((char *)p_item->psz_longtext) toWidth: PREFS_WRAP];
1352 if (p_item->psz_text)
1353 o_labelString = _NS((char *)p_item->psz_text);
1355 o_labelString = @"";
1356 ADD_LABEL(o_label, mainFrame, 0, -3, o_labelString, o_tooltip)
1357 [o_label setAutoresizingMask:NSViewNotSizable ];
1358 [self addSubview: o_label];
1360 /* build the stepper */
1361 ADD_STEPPER(o_stepper, mainFrame, mainFrame.size.width - 19,
1362 0, o_tooltip, -100000, 100000)
1363 [o_stepper setIntValue: p_item->value.i];
1364 [o_stepper setAutoresizingMask:NSViewMaxXMargin ];
1365 [self addSubview: o_stepper];
1367 ADD_TEXTFIELD(o_textfield, mainFrame, mainFrame.size.width - 19 - 52,
1368 1, 49, o_tooltip, @"")
1369 [o_textfield setIntValue: p_item->value.i];
1370 [o_textfield setDelegate: self];
1371 [[NSNotificationCenter defaultCenter] addObserver: self
1372 selector: @selector(textfieldChanged:)
1373 name: NSControlTextDidChangeNotification
1374 object: o_textfield];
1375 [o_textfield setAutoresizingMask:NSViewMaxXMargin ];
1376 [self addSubview: o_textfield];
1381 - (void) alignWithXPosition:(int)i_xPos
1384 frame = [o_label frame];
1385 frame.origin.x = i_xPos - frame.size.width - 3;
1386 [o_label setFrame:frame];
1388 frame = [o_textfield frame];
1389 frame.origin.x = i_xPos + 2;
1390 [o_textfield setFrame:frame];
1392 frame = [o_stepper frame];
1393 frame.origin.x = i_xPos + [o_textfield frame].size.width + 5;
1394 [o_stepper setFrame:frame];
1399 [o_stepper release];
1400 [o_textfield release];
1404 - (IBAction)stepperChanged:(id)sender
1406 [o_textfield setIntValue: [o_stepper intValue]];
1409 - (void)textfieldChanged:(NSNotification *)o_notification
1411 [o_stepper setIntValue: [o_textfield intValue]];
1416 return [o_textfield intValue];
1421 [o_textfield setIntValue: config_GetInt(VLCIntf, p_item->psz_name)];
1422 [super resetValues];
1427 @implementation IntegerListConfigControl
1429 - (id) initWithItem: (module_config_t *)_p_item
1430 withView: (NSView *)o_parent_view
1432 NSRect mainFrame = [o_parent_view frame];
1433 NSString *o_labelString, *o_textfieldTooltip;
1434 mainFrame.size.height = 22;
1435 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN + 1;
1436 mainFrame.origin.x = LEFTMARGIN;
1437 mainFrame.origin.y = 0;
1439 if ([super initWithFrame: mainFrame item: _p_item] != nil) {
1440 i_view_type = CONFIG_ITEM_STRING_LIST;
1442 o_textfieldTooltip = [[VLCStringUtility sharedInstance] wrapString: _NS((char *)p_item->psz_longtext) toWidth: PREFS_WRAP];
1445 if (p_item->psz_text)
1446 o_labelString = _NS((char *)p_item->psz_text);
1448 o_labelString = @"";
1449 ADD_LABEL(o_label, mainFrame, 0, -3, o_labelString, o_textfieldTooltip)
1450 [o_label setAutoresizingMask:NSViewNotSizable ];
1451 [self addSubview: o_label];
1453 /* build the textfield */
1454 ADD_POPUP(o_popup, mainFrame, [o_label frame].size.width,
1455 -2, 0, o_textfieldTooltip)
1456 [o_popup setAutoresizingMask:NSViewWidthSizable ];
1459 for (int i_index = 0; i_index < p_item->list_count; i_index++) {
1461 if (p_item->list_text && p_item->list_text[i_index])
1462 o_text = _NS((char *)p_item->list_text[i_index]);
1464 o_text = [NSString stringWithFormat: @"%i", p_item->list.i[i_index]];
1465 [o_popup addItemWithTitle: o_text];
1467 if (p_item->value.i == p_item->list.i[i_index])
1468 [o_popup selectItemAtIndex: i_index];
1471 [self addSubview: o_popup];
1476 - (void) alignWithXPosition:(int)i_xPos
1479 NSRect superFrame = [self frame];
1480 frame = [o_label frame];
1481 frame.origin.x = i_xPos - frame.size.width - 3;
1482 [o_label setFrame:frame];
1484 frame = [o_popup frame];
1485 frame.origin.x = i_xPos + 2;
1486 frame.size.width = superFrame.size.width - frame.origin.x + 2;
1487 [o_popup setFrame:frame];
1498 if ([o_popup indexOfSelectedItem] >= 0)
1499 return p_item->list.i[[o_popup indexOfSelectedItem]];
1501 return [o_popup intValue];
1506 for (int i_index = 0; i_index < p_item->list_count; i_index++) {
1507 if (config_GetInt(VLCIntf, p_item->psz_name) == p_item->list.i[i_index])
1508 [o_popup selectItemAtIndex: i_index];
1514 @implementation RangedIntegerConfigControl
1515 - (id) initWithItem: (module_config_t *)_p_item
1516 withView: (NSView *)o_parent_view
1518 NSRect mainFrame = [o_parent_view frame];
1519 NSString *o_labelString, *o_tooltip;
1520 mainFrame.size.height = 50;
1521 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN;
1522 mainFrame.origin.x = LEFTMARGIN;
1523 mainFrame.origin.y = 0;
1525 if ([super initWithFrame: mainFrame item: _p_item] != nil) {
1526 i_view_type = CONFIG_ITEM_RANGED_INTEGER;
1528 o_tooltip = [[VLCStringUtility sharedInstance] wrapString: _NS((char *)p_item->psz_longtext) toWidth: PREFS_WRAP];
1531 if (p_item->psz_text)
1532 o_labelString = _NS((char *)p_item->psz_text);
1534 o_labelString = @"";
1535 ADD_LABEL(o_label, mainFrame, 0, -3, o_labelString, o_tooltip)
1536 [o_label setAutoresizingMask:NSViewNotSizable ];
1537 [self addSubview: o_label];
1539 /* build the textfield */
1540 ADD_TEXTFIELD(o_textfield, mainFrame, [o_label frame].size.width + 2,
1541 28, 49, o_tooltip, @"")
1542 [o_textfield setIntValue: p_item->value.i];
1543 [o_textfield setAutoresizingMask:NSViewMaxXMargin ];
1544 [o_textfield setDelegate: self];
1545 [[NSNotificationCenter defaultCenter] addObserver: self
1546 selector: @selector(textfieldChanged:)
1547 name: NSControlTextDidChangeNotification
1548 object: o_textfield];
1549 [self addSubview: o_textfield];
1551 /* build the mintextfield */
1552 ADD_LABEL(o_textfield_min, mainFrame, 12, -30, @"-8888", @"")
1553 [o_textfield_min setIntValue: p_item->min.i];
1554 [o_textfield_min setAutoresizingMask:NSViewMaxXMargin ];
1555 [o_textfield_min setAlignment:NSRightTextAlignment];
1556 [self addSubview: o_textfield_min];
1558 /* build the maxtextfield */
1559 ADD_LABEL(o_textfield_max, mainFrame,
1560 mainFrame.size.width - 31, -30, @"8888", @"")
1561 [o_textfield_max setIntValue: p_item->max.i];
1562 [o_textfield_max setAutoresizingMask:NSViewMinXMargin ];
1563 [self addSubview: o_textfield_max];
1565 /* build the slider */
1566 ADD_SLIDER(o_slider, mainFrame, [o_textfield_min frame].origin.x +
1567 [o_textfield_min frame].size.width + 6, -1, mainFrame.size.width -
1568 [o_textfield_max frame].size.width -
1569 [o_textfield_max frame].size.width - 14 -
1570 [o_textfield_min frame].origin.x, o_tooltip,
1571 p_item->min.i, p_item->max.i)
1572 [o_slider setIntValue: p_item->value.i];
1573 [o_slider setAutoresizingMask:NSViewWidthSizable ];
1574 [o_slider setTarget: self];
1575 [o_slider setAction: @selector(sliderChanged:)];
1576 [o_slider sendActionOn:NSLeftMouseUpMask | NSLeftMouseDownMask |
1577 NSLeftMouseDraggedMask];
1578 [self addSubview: o_slider];
1584 - (void) alignWithXPosition:(int)i_xPos
1587 frame = [o_label frame];
1588 frame.origin.x = i_xPos - frame.size.width - 3;
1589 [o_label setFrame:frame];
1591 frame = [o_textfield frame];
1592 frame.origin.x = i_xPos + 2;
1593 [o_textfield setFrame:frame];
1598 [o_textfield release];
1599 [o_textfield_min release];
1600 [o_textfield_max release];
1605 - (IBAction)sliderChanged:(id)sender
1607 [o_textfield setIntValue: [o_slider intValue]];
1610 - (void)textfieldChanged:(NSNotification *)o_notification
1612 [o_slider setIntValue: [o_textfield intValue]];
1617 return [o_slider intValue];
1622 int value = config_GetInt(VLCIntf, p_item->psz_name);
1623 [o_textfield setIntValue:value];
1624 [o_slider setIntValue:value];
1625 [super resetValues];
1629 @implementation FloatConfigControl
1630 - (id) initWithItem: (module_config_t *)_p_item
1631 withView: (NSView *)o_parent_view
1633 NSRect mainFrame = [o_parent_view frame];
1634 NSString *o_labelString, *o_tooltip;
1635 mainFrame.size.height = 23;
1636 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN + 1;
1637 mainFrame.origin.x = LEFTMARGIN;
1638 mainFrame.origin.y = 0;
1640 if ([super initWithFrame: mainFrame item: _p_item] != nil) {
1641 i_view_type = CONFIG_ITEM_INTEGER;
1643 o_tooltip = [[VLCStringUtility sharedInstance] wrapString: _NS((char *)p_item->psz_longtext) toWidth: PREFS_WRAP];
1646 if (p_item->psz_text)
1647 o_labelString = _NS((char *)p_item->psz_text);
1649 o_labelString = @"";
1650 ADD_LABEL(o_label, mainFrame, 0, -2, o_labelString, o_tooltip)
1651 [o_label setAutoresizingMask:NSViewNotSizable ];
1652 [self addSubview: o_label];
1654 /* build the stepper */
1655 ADD_STEPPER(o_stepper, mainFrame, mainFrame.size.width - 19,
1656 0, o_tooltip, -100000, 100000)
1657 [o_stepper setFloatValue: p_item->value.f];
1658 [o_stepper setAutoresizingMask:NSViewMaxXMargin ];
1659 [self addSubview: o_stepper];
1661 /* build the textfield */
1662 ADD_TEXTFIELD(o_textfield, mainFrame, mainFrame.size.width - 19 - 52,
1663 1, 49, o_tooltip, @"")
1664 [o_textfield setFloatValue: p_item->value.f];
1665 [o_textfield setDelegate: self];
1666 [[NSNotificationCenter defaultCenter] addObserver: self
1667 selector: @selector(textfieldChanged:)
1668 name: NSControlTextDidChangeNotification
1669 object: o_textfield];
1670 [o_textfield setAutoresizingMask:NSViewMaxXMargin ];
1671 [self addSubview: o_textfield];
1676 - (void) alignWithXPosition:(int)i_xPos
1679 frame = [o_label frame];
1680 frame.origin.x = i_xPos - frame.size.width - 3;
1681 [o_label setFrame:frame];
1683 frame = [o_textfield frame];
1684 frame.origin.x = i_xPos + 2;
1685 [o_textfield setFrame:frame];
1687 frame = [o_stepper frame];
1688 frame.origin.x = i_xPos + [o_textfield frame].size.width + 5;
1689 [o_stepper setFrame:frame];
1694 [o_stepper release];
1695 [o_textfield release];
1699 - (IBAction)stepperChanged:(id)sender
1701 [o_textfield setFloatValue: [o_stepper floatValue]];
1704 - (void)textfieldChanged:(NSNotification *)o_notification
1706 [o_stepper setFloatValue: [o_textfield floatValue]];
1711 return [o_stepper floatValue];
1716 [o_textfield setFloatValue: config_GetFloat(VLCIntf, p_item->psz_name)];
1717 [super resetValues];
1721 @implementation RangedFloatConfigControl
1722 - (id) initWithItem: (module_config_t *)_p_item
1723 withView: (NSView *)o_parent_view
1725 NSRect mainFrame = [o_parent_view frame];
1726 NSString *o_labelString, *o_tooltip;
1727 mainFrame.size.height = 50;
1728 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN;
1729 mainFrame.origin.x = LEFTMARGIN;
1730 mainFrame.origin.y = 0;
1732 if ([super initWithFrame: mainFrame item: _p_item] != nil) {
1733 i_view_type = CONFIG_ITEM_RANGED_INTEGER;
1735 o_tooltip = [[VLCStringUtility sharedInstance] wrapString: _NS((char *)p_item->psz_longtext) toWidth: PREFS_WRAP];
1738 if (p_item->psz_text)
1739 o_labelString = _NS((char *)p_item->psz_text);
1741 o_labelString = @"";
1742 ADD_LABEL(o_label, mainFrame, 0, -3, o_labelString, o_tooltip)
1743 [o_label setAutoresizingMask:NSViewNotSizable ];
1744 [self addSubview: o_label];
1746 /* build the textfield */
1747 ADD_TEXTFIELD(o_textfield, mainFrame, [o_label frame].size.width + 2,
1748 28, 49, o_tooltip, @"")
1749 [o_textfield setFloatValue: p_item->value.f];
1750 [o_textfield setAutoresizingMask:NSViewMaxXMargin ];
1751 [o_textfield setDelegate: self];
1752 [[NSNotificationCenter defaultCenter] addObserver: self
1753 selector: @selector(textfieldChanged:)
1754 name: NSControlTextDidChangeNotification
1755 object: o_textfield];
1756 [self addSubview: o_textfield];
1758 /* build the mintextfield */
1759 ADD_LABEL(o_textfield_min, mainFrame, 12, -30, @"-8888", @"")
1760 [o_textfield_min setFloatValue: p_item->min.f];
1761 [o_textfield_min setAutoresizingMask:NSViewMaxXMargin ];
1762 [o_textfield_min setAlignment:NSRightTextAlignment];
1763 [self addSubview: o_textfield_min];
1765 /* build the maxtextfield */
1766 ADD_LABEL(o_textfield_max, mainFrame, mainFrame.size.width - 31,
1768 [o_textfield_max setFloatValue: p_item->max.f];
1769 [o_textfield_max setAutoresizingMask:NSViewMinXMargin ];
1770 [self addSubview: o_textfield_max];
1772 /* build the slider */
1773 ADD_SLIDER(o_slider, mainFrame, [o_textfield_min frame].origin.x +
1774 [o_textfield_min frame].size.width + 6, -1, mainFrame.size.width -
1775 [o_textfield_max frame].size.width -
1776 [o_textfield_max frame].size.width - 14 -
1777 [o_textfield_min frame].origin.x, o_tooltip, p_item->min.f,
1779 [o_slider setFloatValue: p_item->value.f];
1780 [o_slider setAutoresizingMask:NSViewWidthSizable ];
1781 [o_slider setTarget: self];
1782 [o_slider setAction: @selector(sliderChanged:)];
1783 [o_slider sendActionOn:NSLeftMouseUpMask | NSLeftMouseDownMask |
1784 NSLeftMouseDraggedMask];
1785 [self addSubview: o_slider];
1791 - (void) alignWithXPosition:(int)i_xPos
1794 frame = [o_label frame];
1795 frame.origin.x = i_xPos - frame.size.width - 3;
1796 [o_label setFrame:frame];
1798 frame = [o_textfield frame];
1799 frame.origin.x = i_xPos + 2;
1800 [o_textfield setFrame:frame];
1805 [o_textfield release];
1806 [o_textfield_min release];
1807 [o_textfield_max release];
1812 - (IBAction)sliderChanged:(id)sender
1814 [o_textfield setFloatValue: [o_slider floatValue]];
1817 - (void)textfieldChanged:(NSNotification *)o_notification
1819 [o_slider setFloatValue: [o_textfield floatValue]];
1824 return [o_slider floatValue];
1829 [o_textfield setFloatValue: config_GetFloat(VLCIntf, p_item->psz_name)];
1830 [o_slider setFloatValue: config_GetFloat(VLCIntf, p_item->psz_name)];
1831 [super resetValues];
1835 @implementation BoolConfigControl
1837 - (id) initWithItem: (module_config_t *)_p_item
1838 withView: (NSView *)o_parent_view
1840 NSRect mainFrame = [o_parent_view frame];
1841 NSString *o_labelString, *o_tooltip;
1842 mainFrame.size.height = 17;
1843 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN;
1844 mainFrame.origin.x = LEFTMARGIN;
1845 mainFrame.origin.y = 0;
1847 if ([super initWithFrame: mainFrame item: _p_item] != nil) {
1848 i_view_type = CONFIG_ITEM_BOOL;
1850 if (p_item->psz_text)
1851 o_labelString = _NS((char *)p_item->psz_text);
1853 o_labelString = @"";
1855 o_tooltip = [[VLCStringUtility sharedInstance] wrapString: _NS((char *)p_item->psz_longtext) toWidth: PREFS_WRAP];
1857 /* add the checkbox */
1858 ADD_CHECKBOX(o_checkbox, mainFrame, 0,
1859 0, o_labelString, o_tooltip, p_item->value.i, NSImageLeft)
1860 [o_checkbox setAutoresizingMask:NSViewNotSizable ];
1861 [self addSubview: o_checkbox];
1868 [o_checkbox release];
1874 return [o_checkbox intValue];
1879 [o_checkbox setState: config_GetInt(VLCIntf, p_item->psz_name)];
1880 [super resetValues];
1884 @implementation KeyConfigControl
1885 - (id) initWithItem: (module_config_t *)_p_item
1886 withView: (NSView *)o_parent_view
1888 NSRect mainFrame = [o_parent_view frame];
1889 NSString *o_labelString, *o_tooltip;
1890 mainFrame.size.height = 22;
1891 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN + 1;
1892 mainFrame.origin.x = LEFTMARGIN;
1893 mainFrame.origin.y = 0;
1895 if ([super initWithFrame: mainFrame item: _p_item] != nil) {
1896 i_view_type = CONFIG_ITEM_KEY;
1898 o_tooltip = [[VLCStringUtility sharedInstance] wrapString: _NS((char *)p_item->psz_longtext) toWidth: PREFS_WRAP];
1901 if (p_item->psz_text)
1902 o_labelString = _NS((char *)p_item->psz_text);
1904 o_labelString = @"";
1905 ADD_LABEL(o_label, mainFrame, 0, -1, o_labelString, o_tooltip)
1906 [o_label setAutoresizingMask:NSViewNotSizable ];
1907 [self addSubview: o_label];
1909 /* build the popup */
1910 ADD_POPUP(o_popup, mainFrame, [o_label frame].origin.x +
1911 [o_label frame].size.width + 3,
1913 [o_popup setAutoresizingMask:NSViewWidthSizable ];
1915 if (o_keys_menu == nil) {
1917 o_keys_menu = [[NSMenu alloc] initWithTitle: @"Keys Menu"];
1918 #warning This does not work anymore. FIXME.
1920 for (i = 0; i < sizeof(vlc_key) / sizeof(key_descriptor_t); i++)
1921 if (vlc_key[i].psz_key_string)
1922 POPULATE_A_KEY(o_keys_menu,
1923 @(vlc_key[i].psz_key_string),
1924 vlc_key[i].i_key_code)
1927 [o_popup setMenu:[o_keys_menu copyWithZone:nil]];
1928 [o_popup selectItem:[[o_popup menu] itemWithTag:p_item->value.i]];
1929 [self addSubview: o_popup];
1935 - (void) alignWithXPosition:(int)i_xPos
1938 NSRect superFrame = [self frame];
1939 frame = [o_label frame];
1940 frame.origin.x = i_xPos - frame.size.width - 3;
1941 [o_label setFrame:frame];
1943 frame = [o_popup frame];
1944 frame.origin.x = i_xPos - 1;
1945 frame.size.width = superFrame.size.width - frame.origin.x + 2;
1946 [o_popup setFrame:frame];
1957 return [o_popup selectedTag];
1962 [o_popup selectItem:[[o_popup menu] itemWithTag:config_GetInt(VLCIntf, p_item->psz_name)]];
1963 [super resetValues];
1967 @implementation ModuleListConfigControl
1968 - (id) initWithItem: (module_config_t *)_p_item
1969 withView: (NSView *)o_parent_view
1971 if (_p_item->i_type == CONFIG_ITEM_MODULE_LIST)
1975 //Fill our array to know how may items we have...
1976 module_t *p_parser, **p_list;
1977 size_t i_module_index;
1978 NSRect mainFrame = [o_parent_view frame];
1979 NSString *o_labelString, *o_textfieldString, *o_tooltip;
1981 o_modulearray = [[NSMutableArray alloc] initWithCapacity:10];
1982 /* build a list of available modules */
1984 p_list = module_list_get(&count);
1985 for (i_module_index = 0; i_module_index < count; i_module_index++) {
1987 p_parser = p_list[i_module_index];
1989 if (module_is_main(p_parser))
1992 unsigned int confsize;
1993 module_config_t *p_configlist = module_config_get(p_parser, &confsize);
1995 for (i = 0; i < confsize; i++) {
1996 unsigned int unused;
1997 module_config_t *p_config = &p_configlist[i];
1998 NSString *o_modulelongname, *o_modulename;
1999 NSNumber *o_moduleenabled = nil;
2001 /* Hack: required subcategory is stored in i_min */
2002 if (p_config->i_type == CONFIG_SUBCATEGORY &&
2003 p_config->value.i == _p_item->min.i) {
2004 o_modulelongname = @(module_get_name(p_parser, TRUE));
2005 o_modulename = @(module_get_object(p_parser));
2007 if (_p_item->value.psz &&
2008 strstr(_p_item->value.psz, module_get_object(p_parser)))
2009 o_moduleenabled = @YES;
2011 o_moduleenabled = @NO;
2013 [o_modulearray addObject:[NSMutableArray
2014 arrayWithObjects: o_modulename, o_modulelongname,
2015 o_moduleenabled, nil]];
2018 /* Parental Advisory HACK:
2019 * Selecting HTTP, RC and Telnet interfaces is difficult now
2020 * since they are just the lua interface module */
2021 if (p_config->i_type == CONFIG_SUBCATEGORY &&
2022 !strcmp(module_get_object(p_parser), "lua") &&
2023 !strcmp(_p_item->psz_name, "extraintf") &&
2024 p_config->value.i == _p_item->min.i) {
2026 #define addLuaIntf(shortname, longname) \
2027 if (_p_item->value.psz && strstr(_p_item->value.psz, shortname))\
2028 o_moduleenabled = @YES;\
2030 o_moduleenabled = @NO;\
2031 [o_modulearray addObject:[NSMutableArray arrayWithObjects: @shortname, _NS(longname), o_moduleenabled, nil]]
2033 addLuaIntf("http", "Web");
2034 addLuaIntf("telnet", "Telnet");
2035 addLuaIntf("cli", "Console");
2040 module_config_free(p_configlist);
2042 module_list_free(p_list);
2044 mainFrame.size.height = 30 + 20 * [o_modulearray count];
2045 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN;
2046 mainFrame.origin.x = LEFTMARGIN;
2047 mainFrame.origin.y = 0;
2048 if ([super initWithFrame: mainFrame item: _p_item] != nil) {
2049 i_view_type = CONFIG_ITEM_MODULE_LIST;
2051 o_tooltip = [[VLCStringUtility sharedInstance] wrapString: _NS((char *)p_item->psz_longtext) toWidth: PREFS_WRAP];
2054 if (p_item->psz_text)
2055 o_labelString = _NS((char *)p_item->psz_text);
2057 o_labelString = @"";
2058 ADD_LABEL(o_label, mainFrame, 0, -3, o_labelString, o_tooltip)
2059 [o_label setAutoresizingMask:NSViewNotSizable ];
2060 [self addSubview: o_label];
2062 /* build the textfield */
2063 if (p_item->value.psz)
2064 o_textfieldString = _NS((char *)p_item->value.psz);
2066 o_textfieldString = @"";
2067 ADD_TEXTFIELD(o_textfield, mainFrame, [o_label frame].size.width + 2,
2068 mainFrame.size.height - 22, mainFrame.size.width -
2069 [o_label frame].size.width - 2, o_tooltip, o_textfieldString)
2070 [o_textfield setAutoresizingMask:NSViewWidthSizable ];
2071 [self addSubview: o_textfield];
2075 NSRect s_rc = mainFrame;
2076 s_rc.size.height = mainFrame.size.height - 30;
2077 s_rc.size.width = mainFrame.size.width - 12;
2080 o_scrollview = [[[NSScrollView alloc] initWithFrame: s_rc] retain];
2081 [o_scrollview setDrawsBackground: NO];
2082 [o_scrollview setBorderType: NSBezelBorder];
2083 [o_scrollview setAutohidesScrollers:YES];
2085 NSTableView *o_tableview;
2086 o_tableview = [[NSTableView alloc] initWithFrame : s_rc];
2087 [o_tableview setUsesAlternatingRowBackgroundColors:YES];
2088 [o_tableview setHeaderView:nil];
2089 /* TODO: find a good way to fix the row height and text size*/
2090 /* FIXME: support for multiple selection... */
2091 // [o_tableview setAllowsMultipleSelection:YES];
2093 NSCell *o_headerCell = [[NSCell alloc] initTextCell:@"Enabled"];
2094 NSCell *o_dataCell = [[NSButtonCell alloc] init];
2095 [(NSButtonCell*)o_dataCell setButtonType:NSSwitchButton];
2096 [o_dataCell setTitle:@""];
2097 [o_dataCell setFont:[NSFont systemFontOfSize:0]];
2098 NSTableColumn *o_tableColumn = [[NSTableColumn alloc]
2099 initWithIdentifier:@"Enabled"];
2100 [o_tableColumn setHeaderCell: o_headerCell];
2101 [o_tableColumn setDataCell: o_dataCell];
2102 [o_tableColumn setWidth:17];
2103 [o_tableview addTableColumn: o_tableColumn];
2105 o_headerCell = [[NSCell alloc] initTextCell:@"Module Name"];
2106 o_dataCell = [[NSTextFieldCell alloc] init];
2107 [o_dataCell setFont:[NSFont systemFontOfSize:12]];
2108 o_tableColumn = [[NSTableColumn alloc]
2109 initWithIdentifier:@"Module"];
2110 [o_tableColumn setHeaderCell: o_headerCell];
2111 [o_tableColumn setDataCell: o_dataCell];
2112 [o_tableColumn setWidth:s_rc.size.width - 34];
2113 [o_tableview addTableColumn: o_tableColumn];
2114 [o_tableview registerForDraggedTypes:@[@"VLC media player module"]];
2116 [o_tableview setDataSource:self];
2117 [o_tableview setTarget: self];
2118 [o_tableview setAction: @selector(tableChanged:)];
2119 [o_tableview sendActionOn:NSLeftMouseUpMask | NSLeftMouseDownMask |
2120 NSLeftMouseDraggedMask];
2121 [o_scrollview setDocumentView: o_tableview];
2123 [o_scrollview setAutoresizingMask:NSViewWidthSizable ];
2124 [o_scrollview setAutohidesScrollers:YES];
2125 [self addSubview: o_scrollview];
2131 - (void) alignWithXPosition:(int)i_xPos
2136 - (IBAction)tableChanged:(id)sender
2138 NSString *o_newstring = @"";
2139 NSUInteger count = [o_modulearray count];
2140 for (NSUInteger i = 0 ; i < count ; i++)
2141 if ([[[o_modulearray objectAtIndex:i] objectAtIndex:2]
2143 o_newstring = [o_newstring stringByAppendingString:
2144 [[o_modulearray objectAtIndex:i] objectAtIndex:0]];
2145 o_newstring = [o_newstring stringByAppendingString:@":"];
2148 [o_textfield setStringValue: [o_newstring
2149 substringToIndex: ([o_newstring length])?[o_newstring length] - 1:0]];
2154 [o_scrollview release];
2159 - (char *)stringValue
2161 return strdup([[o_textfield stringValue] UTF8String]);
2166 #warning Reset prefs of the module selector is broken atm.
2167 msg_Err(VLCIntf, "don't forget about modulelistconfig");
2168 [super resetValues];
2173 @implementation ModuleListConfigControl (NSTableDataSource)
2175 - (BOOL)tableView:(NSTableView*)table writeRows:(NSArray*)rows
2176 toPasteboard:(NSPasteboard*)pb
2178 // We only want to allow dragging of selected rows.
2179 NSEnumerator *iter = [rows objectEnumerator];
2181 while ((row = [iter nextObject]) != nil) {
2182 if (![table isRowSelected:[row intValue]])
2186 [pb declareTypes:@[@"VLC media player module"] owner:nil];
2187 [pb setPropertyList:rows forType:@"VLC media player module"];
2191 - (NSDragOperation)tableView:(NSTableView*)table
2192 validateDrop:(id <NSDraggingInfo>)info proposedRow:(NSInteger)row
2193 proposedDropOperation:(NSTableViewDropOperation)op
2195 // Make drops at the end of the table go to the end.
2197 row = [table numberOfRows];
2198 op = NSTableViewDropAbove;
2199 [table setDropRow:row dropOperation:op];
2202 // We don't ever want to drop onto a row, only between rows.
2203 if (op == NSTableViewDropOn)
2204 [table setDropRow:(row+1) dropOperation:NSTableViewDropAbove];
2205 return NSTableViewDropAbove;
2208 - (BOOL)tableView:(NSTableView*)table acceptDrop:(id <NSDraggingInfo>)info
2209 row:(NSInteger)dropRow dropOperation:(NSTableViewDropOperation)op;
2211 NSPasteboard *pb = [info draggingPasteboard];
2212 NSDragOperation srcMask = [info draggingSourceOperationMask];
2219 // Intra-table drag - data is the array of rows.
2220 if (!accepted && (array =
2221 [pb propertyListForType:@"VLC media player module"]) != NULL) {
2222 NSEnumerator *iter = nil;
2224 BOOL isCopy = (srcMask & NSDragOperationMove) ? NO:YES;
2226 iter = [array objectEnumerator];
2227 while ((val = [iter nextObject]) != NULL) {
2228 NSArray *o_tmp = [[o_modulearray objectAtIndex:
2229 [val intValue]] mutableCopyWithZone:nil];
2230 [o_modulearray removeObject:o_tmp];
2231 [o_modulearray insertObject:o_tmp
2232 atIndex:(dropRow>[val intValue]) ? dropRow - 1 : dropRow];
2236 // Select the newly-dragged items.
2237 iter = [array objectEnumerator];
2239 [table deselectAll:self];
2241 [self tableChanged:self];
2242 [table setNeedsDisplay:YES];
2243 // Indicate that we finished the drag.
2247 [table setNeedsDisplay:YES];
2251 // An exception occurred. Uh-oh. Update the track table so that
2252 // it stays consistent, and re-raise the exception.
2254 [localException raise];
2255 [table setNeedsDisplay:YES];
2261 - (NSInteger)numberOfRowsInTableView:(NSTableView *)aTableView
2263 return [o_modulearray count];
2266 - (id)tableView:(NSTableView *)aTableView
2267 objectValueForTableColumn:(NSTableColumn *)aTableColumn row:(NSInteger)rowIndex
2269 if ([[aTableColumn identifier] isEqualToString: @"Enabled"])
2270 return [[o_modulearray objectAtIndex:rowIndex] objectAtIndex:2];
2271 if ([[aTableColumn identifier] isEqualToString: @"Module"])
2272 return [[o_modulearray objectAtIndex:rowIndex] objectAtIndex:1];
2277 - (void)tableView:(NSTableView *)aTableView setObjectValue:(id)anObject
2278 forTableColumn:(NSTableColumn *)aTableColumn row:(NSInteger)rowIndex
2280 [[o_modulearray objectAtIndex:rowIndex] replaceObjectAtIndex:2
2281 withObject: anObject];
2285 @implementation SectionControl
2287 - (id) initWithItem: (module_config_t *)_p_item
2288 withView: (NSView *)o_parent_view
2290 NSRect mainFrame = [o_parent_view frame];
2291 NSString *o_labelString, *o_tooltip;
2292 mainFrame.size.height = 17;
2293 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN;
2294 mainFrame.origin.x = LEFTMARGIN;
2295 mainFrame.origin.y = 0;
2297 if ([super initWithFrame: mainFrame item: _p_item] != nil) {
2300 if (p_item->psz_text)
2301 o_labelString = _NS((char *)p_item->psz_text);
2303 o_labelString = @"";
2305 NSDictionary *boldAttributes = [NSDictionary dictionaryWithObjectsAndKeys:
2306 [NSFont boldSystemFontOfSize:[NSFont systemFontSize]],
2307 NSFontAttributeName,
2309 NSAttributedString *o_bold_string = [[NSAttributedString alloc] initWithString: o_labelString attributes: boldAttributes];
2311 ADD_LABEL(o_label, mainFrame, 1, 0, @"", @"")
2312 [o_label setAttributedStringValue: o_bold_string];
2313 [o_label sizeToFit];
2315 [o_bold_string release];
2317 [o_label setAutoresizingMask:NSViewNotSizable];
2318 [self addSubview: o_label];