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:UP_ARROWHEAD] \
67 stringByAppendingString: string] \
68 action:nil keyEquivalent:@""]; \
69 [o_mi setKeyEquivalentModifierMask: \
71 [o_mi setAlternate: YES]; \
73 KEY_MODIFIER_CTRL | (value)]; \
74 [o_menu addItem: o_mi]; \
76 o_mi = [[NSMenuItem alloc] initWithTitle: \
77 [[NSString stringWithUTF8String:UP_ARROWHEAD OPTION_KEY] \
78 stringByAppendingString: string] \
79 action:nil keyEquivalent:@""]; \
80 [o_mi setKeyEquivalentModifierMask: \
81 NSControlKeyMask | NSAlternateKeyMask]; \
82 [o_mi setAlternate: YES]; \
84 (KEY_MODIFIER_CTRL | KEY_MODIFIER_ALT) | (value)]; \
85 [o_menu addItem: o_mi]; \
87 o_mi = [[NSMenuItem alloc] initWithTitle: \
88 [[NSString stringWithUTF8String: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 [[NSString stringWithUTF8String: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 [[NSString stringWithUTF8String: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 [[NSString stringWithUTF8String: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 [[NSString stringWithUTF8String: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 [[NSString stringWithUTF8String: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 [[NSString stringWithUTF8String: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 [[NSString stringWithUTF8String: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 [[NSString stringWithUTF8String: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 [[NSString stringWithUTF8String: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 [[NSString stringWithUTF8String: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 [[NSString stringWithUTF8String: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 [[NSString stringWithUTF8String: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 p_control = [[StringListConfigControl alloc]
787 initWithItem: _p_item
788 withView: o_parent_view];
790 case CONFIG_ITEM_MODULE_CAT:
791 p_control = [[ModuleConfigControl alloc]
792 initWithItem: _p_item
793 withView: o_parent_view];
795 case CONFIG_ITEM_INTEGER:
796 if (_p_item->list_count)
797 p_control = [[IntegerListConfigControl alloc] initWithItem: _p_item withView: o_parent_view];
798 else if ((_p_item->min.i != 0 || _p_item->max.i != 0) && (_p_item->min.i != INT_MIN || _p_item->max.i != INT_MAX))
799 p_control = [[RangedIntegerConfigControl alloc] initWithItem: _p_item withView: o_parent_view];
801 p_control = [[IntegerConfigControl alloc] initWithItem: _p_item withView: o_parent_view];
803 case CONFIG_ITEM_BOOL:
804 p_control = [[BoolConfigControl alloc]
805 initWithItem: _p_item
806 withView: o_parent_view];
808 case CONFIG_ITEM_FLOAT:
809 if ((_p_item->min.i != 0 || _p_item->max.i != 0) && (_p_item->min.i != INT_MIN || _p_item->max.i != INT_MAX))
810 p_control = [[RangedFloatConfigControl alloc] initWithItem: _p_item withView: o_parent_view];
812 p_control = [[FloatConfigControl alloc] initWithItem: _p_item withView: o_parent_view];
814 /* don't display keys in the advanced settings, since the current controls
815 are broken by design. The user is required to change hotkeys in the sprefs
816 and can only change really advanced stuff here..
817 case CONFIG_ITEM_KEY:
818 p_control = [[KeyConfigControl alloc]
819 initWithItem: _p_item
820 withView: o_parent_view];
822 case CONFIG_ITEM_MODULE_LIST:
823 case CONFIG_ITEM_MODULE_LIST_CAT:
824 p_control = [[ModuleListConfigControl alloc] initWithItem: _p_item withView: o_parent_view];
827 p_control = [[SectionControl alloc] initWithItem: _p_item withView: o_parent_view];
837 return _NS(psz_name);
850 - (char *)stringValue
858 switch(p_item->i_type) {
859 case CONFIG_ITEM_STRING:
860 case CONFIG_ITEM_PASSWORD:
861 case CONFIG_ITEM_LOADFILE:
862 case CONFIG_ITEM_SAVEFILE:
863 case CONFIG_ITEM_DIRECTORY:
864 case CONFIG_ITEM_MODULE:
865 case CONFIG_ITEM_MODULE_LIST:
866 case CONFIG_ITEM_MODULE_LIST_CAT: {
867 char *psz_val = [self stringValue];
868 config_PutPsz(VLCIntf, psz_name, psz_val);
872 case CONFIG_ITEM_KEY:
873 /* So you don't need to restart to have the changes take effect */
874 val.i_int = [self intValue];
875 var_Set(VLCIntf->p_libvlc, psz_name, val);
876 case CONFIG_ITEM_INTEGER:
877 case CONFIG_ITEM_BOOL:
878 config_PutInt(VLCIntf, psz_name, [self intValue]);
880 case CONFIG_ITEM_FLOAT:
881 config_PutFloat(VLCIntf, psz_name, [self floatValue]);
892 return [o_label frame].size.width;
895 - (void) alignWithXPosition:(int)i_xPos;
897 /* FIXME: not implemented atm, but created to shut up the warning
898 * about "method definition not found" -- FK @ 7/24/05 */
902 @implementation StringConfigControl
903 - (id) initWithItem: (module_config_t *)_p_item
904 withView: (NSView *)o_parent_view
906 NSRect mainFrame = [o_parent_view frame];
907 NSString *o_labelString, *o_textfieldString, *o_textfieldTooltip;
908 mainFrame.size.height = 22;
909 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN;
910 mainFrame.origin.x = LEFTMARGIN;
911 mainFrame.origin.y = 0;
913 if ([super initWithFrame: mainFrame item: _p_item] != nil) {
914 if (p_item->i_type == CONFIG_ITEM_PASSWORD)
915 i_view_type = CONFIG_ITEM_PASSWORD;
917 i_view_type = CONFIG_ITEM_STRING;
919 o_textfieldTooltip = [[VLCStringUtility sharedInstance] wrapString: _NS((char *)p_item->psz_longtext) toWidth: PREFS_WRAP];
922 if (p_item->psz_text)
923 o_labelString = _NS((char *)p_item->psz_text);
926 ADD_LABEL(o_label, mainFrame, 0, -3, o_labelString, o_textfieldTooltip)
927 [o_label setAutoresizingMask:NSViewNotSizable ];
928 [self addSubview: o_label];
930 /* build the textfield */
931 if (p_item->value.psz)
932 o_textfieldString = [NSString stringWithCString:p_item->value.psz encoding:NSUTF8StringEncoding];
934 o_textfieldString = @"";
935 if (p_item->i_type == CONFIG_ITEM_PASSWORD) {
936 ADD_SECURETEXTFIELD(o_textfield, mainFrame, [o_label frame].size.width + 2,
937 0, mainFrame.size.width - [o_label frame].size.width -
938 2, o_textfieldTooltip, o_textfieldString)
940 ADD_TEXTFIELD(o_textfield, mainFrame, [o_label frame].size.width + 2,
941 0, mainFrame.size.width - [o_label frame].size.width -
942 2, o_textfieldTooltip, o_textfieldString)
944 [o_textfield setAutoresizingMask:NSViewWidthSizable ];
946 [self addSubview: o_textfield];
951 - (void) alignWithXPosition:(int)i_xPos
954 NSRect superFrame = [self frame];
955 frame = [o_label frame];
956 frame.origin.x = i_xPos - frame.size.width - 3;
957 [o_label setFrame:frame];
959 frame = [o_textfield frame];
960 frame.origin.x = i_xPos + 2;
961 frame.size.width = superFrame.size.width - frame.origin.x - 1;
962 [o_textfield setFrame:frame];
967 [o_textfield release];
971 - (char *)stringValue
973 return strdup([[o_textfield stringValue] UTF8String]);
978 NSString *o_textfieldString;
979 char *psz_value = config_GetPsz(VLCIntf, p_item->psz_name);
981 o_textfieldString = _NS(psz_value);
983 o_textfieldString = @"";
989 @implementation StringListConfigControl
990 - (id) initWithItem: (module_config_t *)_p_item
991 withView: (NSView *)o_parent_view
993 NSRect mainFrame = [o_parent_view frame];
994 NSString *o_labelString, *o_textfieldTooltip;
995 mainFrame.size.height = 22;
996 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN + 1;
997 mainFrame.origin.x = LEFTMARGIN;
998 mainFrame.origin.y = 0;
1000 if ([super initWithFrame: mainFrame item: _p_item] != nil) {
1001 if (p_item->i_type == CONFIG_ITEM_STRING)
1002 i_view_type = CONFIG_ITEM_STRING_LIST;
1004 i_view_type = CONFIG_ITEM_MODULE;
1006 o_textfieldTooltip = [[VLCStringUtility sharedInstance] wrapString: _NS(p_item->psz_longtext) toWidth: PREFS_WRAP];
1009 if (p_item->psz_text)
1010 o_labelString = _NS((char *)p_item->psz_text);
1012 o_labelString = @"";
1013 ADD_LABEL(o_label, mainFrame, 0, -3, o_labelString, o_textfieldTooltip)
1014 [o_label setAutoresizingMask:NSViewNotSizable ];
1015 [self addSubview: o_label];
1017 /* build the textfield */
1018 ADD_POPUP(o_popup, mainFrame, [o_label frame].size.width,
1019 -2, 0, o_textfieldTooltip)
1020 [o_popup setAutoresizingMask:NSViewWidthSizable];
1025 [self addSubview: o_popup];
1030 - (void) alignWithXPosition:(int)i_xPos
1033 NSRect superFrame = [self frame];
1034 frame = [o_label frame];
1035 frame.origin.x = i_xPos - frame.size.width - 3;
1036 [o_label setFrame:frame];
1038 frame = [o_popup frame];
1039 frame.origin.x = i_xPos + 2;
1040 frame.size.width = superFrame.size.width - frame.origin.x + 2;
1041 [o_popup setFrame:frame];
1050 - (char *)stringValue
1052 if ([o_popup indexOfSelectedItem] < 0)
1055 NSString *o_data = [[o_popup selectedItem] representedObject];
1056 return strdup([o_data UTF8String]);
1061 [o_popup removeAllItems];
1063 char *psz_value = config_GetPsz(VLCIntf, p_item->psz_name);
1065 char **values, **texts;
1066 ssize_t count = config_GetPszChoices(VLC_OBJECT(VLCIntf), p_item->psz_name,
1068 for (ssize_t i = 0; i < count && texts; i++) {
1069 if (texts[i] == NULL || values[i] == NULL)
1072 [o_popup addItemWithTitle: toNSStr(texts[i])];
1073 NSMenuItem *lastItem = [o_popup lastItem];
1074 [lastItem setRepresentedObject: toNSStr(values[i])];
1076 if (!strcmp(psz_value ? psz_value : "", values[i]))
1077 [o_popup selectItem: [o_popup lastItem]];
1087 [super resetValues];
1091 @implementation FileConfigControl
1092 - (id) initWithItem: (module_config_t *)_p_item
1093 withView: (NSView *)o_parent_view
1095 NSRect mainFrame = [o_parent_view frame];
1096 NSString *o_labelString, *o_itemTooltip, *o_textfieldString;
1097 mainFrame.size.height = 46;
1098 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN;
1099 mainFrame.origin.x = LEFTMARGIN;
1100 mainFrame.origin.y = 0;
1102 if ([super initWithFrame: mainFrame item: _p_item] != nil) {
1103 i_view_type = CONFIG_ITEM_LOADFILE;
1105 o_itemTooltip = [[VLCStringUtility sharedInstance] wrapString: _NS((char *)p_item->psz_longtext) toWidth: PREFS_WRAP];
1107 /* is it a directory */
1108 b_directory = ([self type] == CONFIG_ITEM_DIRECTORY) ? YES : NO;
1111 if (p_item->psz_text)
1112 o_labelString = _NS((char *)p_item->psz_text);
1114 o_labelString = @"";
1115 ADD_LABEL(o_label, mainFrame, 0, 3, o_labelString, o_itemTooltip)
1116 [o_label setAutoresizingMask:NSViewNotSizable ];
1117 [self addSubview: o_label];
1119 /* build the button */
1120 ADD_RIGHT_BUTTON(o_button, mainFrame, 0, 0, o_itemTooltip,
1122 [o_button setAutoresizingMask:NSViewMinXMargin ];
1123 [self addSubview: o_button];
1125 /* build the textfield */
1126 if (p_item->value.psz)
1127 o_textfieldString = [NSString stringWithFormat: @"%s", (char *)p_item->value.psz];
1129 o_textfieldString = @"";
1130 ADD_TEXTFIELD(o_textfield, mainFrame, 12, 2, mainFrame.size.width -
1131 8 - [o_button frame].size.width,
1132 o_itemTooltip, o_textfieldString)
1133 [o_textfield setAutoresizingMask:NSViewWidthSizable ];
1134 [self addSubview: o_textfield];
1139 - (void) alignWithXPosition:(int)i_xPos
1146 [o_textfield release];
1151 - (IBAction)openFileDialog: (id)sender
1153 NSOpenPanel *o_open_panel = [NSOpenPanel openPanel];
1155 [o_open_panel setTitle: (b_directory)?
1156 _NS("Select a directory"):_NS("Select a file")];
1157 [o_open_panel setPrompt: _NS("Select")];
1158 [o_open_panel setAllowsMultipleSelection: NO];
1159 [o_open_panel setCanChooseFiles: !b_directory];
1160 [o_open_panel setCanChooseDirectories: b_directory];
1161 [o_open_panel beginSheetModalForWindow:[sender window] completionHandler:^(NSInteger returnCode) {
1162 if (returnCode == NSOKButton) {
1163 NSString *o_path = [[[o_open_panel URLs] objectAtIndex:0] path];
1164 [o_textfield setStringValue: o_path];
1169 - (char *)stringValue
1171 if ([[o_textfield stringValue] length] != 0)
1172 return strdup([[o_textfield stringValue] fileSystemRepresentation]);
1179 NSString *o_textfieldString;
1180 char *psz_value = config_GetPsz(VLCIntf, p_item->psz_name);
1182 o_textfieldString = [NSString stringWithFormat: @"%s", psz_value];
1184 o_textfieldString = @"";
1187 [super resetValues];
1191 @implementation ModuleConfigControl
1192 - (id) initWithItem: (module_config_t *)_p_item
1193 withView: (NSView *)o_parent_view
1195 NSRect mainFrame = [o_parent_view frame];
1196 NSString *o_labelString, *o_popupTooltip;
1197 mainFrame.size.height = 22;
1198 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN + 1;
1199 mainFrame.origin.x = LEFTMARGIN;
1200 mainFrame.origin.y = 0;
1202 if ([super initWithFrame: mainFrame item: _p_item] != nil) {
1203 i_view_type = CONFIG_ITEM_MODULE;
1205 o_popupTooltip = [[VLCStringUtility sharedInstance] wrapString: _NS((char *)p_item->psz_longtext) toWidth: PREFS_WRAP];
1208 if (p_item->psz_text)
1209 o_labelString = _NS((char *)p_item->psz_text);
1211 o_labelString = @"";
1213 ADD_LABEL(o_label, mainFrame, 0, -1, o_labelString, o_popupTooltip)
1214 [o_label setAutoresizingMask:NSViewNotSizable ];
1215 [self addSubview: o_label];
1217 /* build the popup */
1218 ADD_POPUP(o_popup, mainFrame, [o_label frame].size.width,
1219 -2, 0, o_popupTooltip)
1220 [o_popup setAutoresizingMask:NSViewWidthSizable ];
1221 [o_popup addItemWithTitle: _NS("Default")];
1222 [[o_popup lastItem] setTag: -1];
1223 [o_popup selectItem: [o_popup lastItem]];
1226 [self addSubview: o_popup];
1231 - (void) alignWithXPosition:(int)i_xPos
1234 NSRect superFrame = [self frame];
1235 frame = [o_label frame];
1236 frame.origin.x = i_xPos - frame.size.width - 3;
1237 [o_label setFrame:frame];
1239 frame = [o_popup frame];
1240 frame.origin.x = i_xPos - 1;
1241 frame.size.width = superFrame.size.width - frame.origin.x + 2;
1242 [o_popup setFrame:frame];
1251 - (char *)stringValue
1253 NSString *newval = [o_popup titleOfSelectedItem];
1254 char *returnval = NULL;
1255 size_t i_module_index;
1256 module_t *p_parser, **p_list;
1259 p_list = module_list_get(&count);
1260 for (i_module_index = 0; i_module_index < count; i_module_index++) {
1261 p_parser = p_list[i_module_index];
1263 if (module_is_main(p_parser))
1266 unsigned int confsize;
1267 module_config_t *p_config = module_config_get(p_parser, &confsize);
1268 for (size_t i = 0; i < confsize; i++) {
1269 module_config_t *p_cfg = p_config + i;
1270 /* Hack: required subcategory is stored in i_min */
1271 if (p_cfg->i_type == CONFIG_SUBCATEGORY &&
1272 p_cfg->value.i == p_cfg->min.i) {
1273 NSString *o_description = _NS(module_get_name(p_parser, TRUE));
1274 if ([newval isEqualToString: o_description]) {
1275 returnval = strdup(module_get_object(p_parser));
1279 module_config_free(p_config);
1282 module_list_free(p_list);
1284 if(returnval == NULL && [newval isEqualToString: _NS("Default")] && p_item->orig.psz != NULL) {
1285 returnval = strdup(p_item->orig.psz);
1292 /* build a list of available modules */
1293 module_t *p_parser, **p_list;
1296 p_list = module_list_get(&count);
1297 for (size_t i_index = 0; i_index < count; i_index++) {
1298 p_parser = p_list[i_index];
1300 if (module_is_main(p_parser))
1302 unsigned int confsize;
1304 module_config_t *p_configlist = module_config_get(p_parser, &confsize);
1305 for (size_t i = 0; i < confsize; i++) {
1306 module_config_t *p_config = &p_configlist[i];
1307 /* Hack: required subcategory is stored in i_min */
1308 if (p_config->i_type == CONFIG_SUBCATEGORY &&
1309 p_config->value.i == p_item->min.i) {
1310 NSString *o_description = _NS(module_get_name(p_parser, TRUE));
1311 [o_popup addItemWithTitle: o_description];
1313 if (p_item->value.psz && !strcmp(p_item->value.psz,
1314 module_get_object(p_parser)))
1315 [o_popup selectItem:[o_popup lastItem]];
1318 module_config_free(p_configlist);
1320 module_list_free(p_list);
1321 [super resetValues];
1325 @implementation IntegerConfigControl
1326 - (id) initWithItem: (module_config_t *)_p_item
1327 withView: (NSView *)o_parent_view
1329 NSRect mainFrame = [o_parent_view frame];
1330 NSString *o_labelString, *o_tooltip;
1331 mainFrame.size.height = 23;
1332 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN + 1;
1333 mainFrame.origin.x = LEFTMARGIN;
1334 mainFrame.origin.y = 0;
1336 if ([super initWithFrame: mainFrame item: _p_item] != nil) {
1337 i_view_type = CONFIG_ITEM_INTEGER;
1339 o_tooltip = [[VLCStringUtility sharedInstance] wrapString: _NS((char *)p_item->psz_longtext) toWidth: PREFS_WRAP];
1342 if (p_item->psz_text)
1343 o_labelString = _NS((char *)p_item->psz_text);
1345 o_labelString = @"";
1346 ADD_LABEL(o_label, mainFrame, 0, -3, o_labelString, o_tooltip)
1347 [o_label setAutoresizingMask:NSViewNotSizable ];
1348 [self addSubview: o_label];
1350 /* build the stepper */
1351 ADD_STEPPER(o_stepper, mainFrame, mainFrame.size.width - 19,
1352 0, o_tooltip, -100000, 100000)
1353 [o_stepper setIntValue: p_item->value.i];
1354 [o_stepper setAutoresizingMask:NSViewMaxXMargin ];
1355 [self addSubview: o_stepper];
1357 ADD_TEXTFIELD(o_textfield, mainFrame, mainFrame.size.width - 19 - 52,
1358 1, 49, o_tooltip, @"")
1359 [o_textfield setIntValue: p_item->value.i];
1360 [o_textfield setDelegate: self];
1361 [[NSNotificationCenter defaultCenter] addObserver: self
1362 selector: @selector(textfieldChanged:)
1363 name: NSControlTextDidChangeNotification
1364 object: o_textfield];
1365 [o_textfield setAutoresizingMask:NSViewMaxXMargin ];
1366 [self addSubview: o_textfield];
1371 - (void) alignWithXPosition:(int)i_xPos
1374 frame = [o_label frame];
1375 frame.origin.x = i_xPos - frame.size.width - 3;
1376 [o_label setFrame:frame];
1378 frame = [o_textfield frame];
1379 frame.origin.x = i_xPos + 2;
1380 [o_textfield setFrame:frame];
1382 frame = [o_stepper frame];
1383 frame.origin.x = i_xPos + [o_textfield frame].size.width + 5;
1384 [o_stepper setFrame:frame];
1389 [o_stepper release];
1390 [o_textfield release];
1394 - (IBAction)stepperChanged:(id)sender
1396 [o_textfield setIntValue: [o_stepper intValue]];
1399 - (void)textfieldChanged:(NSNotification *)o_notification
1401 [o_stepper setIntValue: [o_textfield intValue]];
1406 return [o_textfield intValue];
1411 [o_textfield setIntValue: config_GetInt(VLCIntf, p_item->psz_name)];
1412 [super resetValues];
1417 @implementation IntegerListConfigControl
1419 - (id) initWithItem: (module_config_t *)_p_item
1420 withView: (NSView *)o_parent_view
1422 NSRect mainFrame = [o_parent_view frame];
1423 NSString *o_labelString, *o_textfieldTooltip;
1424 mainFrame.size.height = 22;
1425 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN + 1;
1426 mainFrame.origin.x = LEFTMARGIN;
1427 mainFrame.origin.y = 0;
1429 if ([super initWithFrame: mainFrame item: _p_item] != nil) {
1430 i_view_type = CONFIG_ITEM_STRING_LIST;
1432 o_textfieldTooltip = [[VLCStringUtility sharedInstance] wrapString: _NS((char *)p_item->psz_longtext) toWidth: PREFS_WRAP];
1435 if (p_item->psz_text)
1436 o_labelString = _NS((char *)p_item->psz_text);
1438 o_labelString = @"";
1439 ADD_LABEL(o_label, mainFrame, 0, -3, o_labelString, o_textfieldTooltip)
1440 [o_label setAutoresizingMask:NSViewNotSizable ];
1441 [self addSubview: o_label];
1443 /* build the textfield */
1444 ADD_POPUP(o_popup, mainFrame, [o_label frame].size.width,
1445 -2, 0, o_textfieldTooltip)
1446 [o_popup setAutoresizingMask:NSViewWidthSizable ];
1451 [self addSubview: o_popup];
1456 - (void) alignWithXPosition:(int)i_xPos
1459 NSRect superFrame = [self frame];
1460 frame = [o_label frame];
1461 frame.origin.x = i_xPos - frame.size.width - 3;
1462 [o_label setFrame:frame];
1464 frame = [o_popup frame];
1465 frame.origin.x = i_xPos + 2;
1466 frame.size.width = superFrame.size.width - frame.origin.x + 2;
1467 [o_popup setFrame:frame];
1478 NSNumber *p_valueobject = (NSNumber *)[[o_popup selectedItem] representedObject];
1479 if (p_valueobject) {
1480 assert([p_valueobject isKindOfClass:[NSNumber class]]);
1481 return [p_valueobject intValue];
1488 [o_popup removeAllItems];
1490 int i_current_selection = config_GetInt(VLCIntf, p_item->psz_name);
1493 ssize_t count = config_GetIntChoices(VLC_OBJECT(VLCIntf), p_item->psz_name, &values, &texts);
1494 for (ssize_t i = 0; i < count; i++) {
1495 NSMenuItem *mi = [[NSMenuItem alloc] initWithTitle: toNSStr(texts[i]) action: NULL keyEquivalent: @""];
1496 [mi setRepresentedObject:[NSNumber numberWithInt:values[i]]];
1497 [[o_popup menu] addItem: [mi autorelease]];
1499 if (i_current_selection == values[i])
1500 [o_popup selectItem:[o_popup lastItem]];
1508 @implementation RangedIntegerConfigControl
1509 - (id) initWithItem: (module_config_t *)_p_item
1510 withView: (NSView *)o_parent_view
1512 NSRect mainFrame = [o_parent_view frame];
1513 NSString *o_labelString, *o_tooltip;
1514 mainFrame.size.height = 50;
1515 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN;
1516 mainFrame.origin.x = LEFTMARGIN;
1517 mainFrame.origin.y = 0;
1519 if ([super initWithFrame: mainFrame item: _p_item] != nil) {
1520 i_view_type = CONFIG_ITEM_RANGED_INTEGER;
1522 o_tooltip = [[VLCStringUtility sharedInstance] wrapString: _NS((char *)p_item->psz_longtext) toWidth: PREFS_WRAP];
1525 if (p_item->psz_text)
1526 o_labelString = _NS((char *)p_item->psz_text);
1528 o_labelString = @"";
1529 ADD_LABEL(o_label, mainFrame, 0, -3, o_labelString, o_tooltip)
1530 [o_label setAutoresizingMask:NSViewNotSizable ];
1531 [self addSubview: o_label];
1533 /* build the textfield */
1534 ADD_TEXTFIELD(o_textfield, mainFrame, [o_label frame].size.width + 2,
1535 28, 49, o_tooltip, @"")
1536 [o_textfield setIntValue: p_item->value.i];
1537 [o_textfield setAutoresizingMask:NSViewMaxXMargin ];
1538 [o_textfield setDelegate: self];
1539 [[NSNotificationCenter defaultCenter] addObserver: self
1540 selector: @selector(textfieldChanged:)
1541 name: NSControlTextDidChangeNotification
1542 object: o_textfield];
1543 [self addSubview: o_textfield];
1545 /* build the mintextfield */
1546 ADD_LABEL(o_textfield_min, mainFrame, 12, -30, @"-8888", @"")
1547 [o_textfield_min setIntValue: p_item->min.i];
1548 [o_textfield_min setAutoresizingMask:NSViewMaxXMargin ];
1549 [o_textfield_min setAlignment:NSRightTextAlignment];
1550 [self addSubview: o_textfield_min];
1552 /* build the maxtextfield */
1553 ADD_LABEL(o_textfield_max, mainFrame,
1554 mainFrame.size.width - 31, -30, @"8888", @"")
1555 [o_textfield_max setIntValue: p_item->max.i];
1556 [o_textfield_max setAutoresizingMask:NSViewMinXMargin ];
1557 [self addSubview: o_textfield_max];
1559 /* build the slider */
1560 ADD_SLIDER(o_slider, mainFrame, [o_textfield_min frame].origin.x +
1561 [o_textfield_min frame].size.width + 6, -1, mainFrame.size.width -
1562 [o_textfield_max frame].size.width -
1563 [o_textfield_max frame].size.width - 14 -
1564 [o_textfield_min frame].origin.x, o_tooltip,
1565 p_item->min.i, p_item->max.i)
1566 [o_slider setIntValue: p_item->value.i];
1567 [o_slider setAutoresizingMask:NSViewWidthSizable ];
1568 [o_slider setTarget: self];
1569 [o_slider setAction: @selector(sliderChanged:)];
1570 [o_slider sendActionOn:NSLeftMouseUpMask | NSLeftMouseDownMask |
1571 NSLeftMouseDraggedMask];
1572 [self addSubview: o_slider];
1578 - (void) alignWithXPosition:(int)i_xPos
1581 frame = [o_label frame];
1582 frame.origin.x = i_xPos - frame.size.width - 3;
1583 [o_label setFrame:frame];
1585 frame = [o_textfield frame];
1586 frame.origin.x = i_xPos + 2;
1587 [o_textfield setFrame:frame];
1592 [o_textfield release];
1593 [o_textfield_min release];
1594 [o_textfield_max release];
1599 - (IBAction)sliderChanged:(id)sender
1601 [o_textfield setIntValue: [o_slider intValue]];
1604 - (void)textfieldChanged:(NSNotification *)o_notification
1606 [o_slider setIntValue: [o_textfield intValue]];
1611 return [o_slider intValue];
1616 int value = config_GetInt(VLCIntf, p_item->psz_name);
1617 [o_textfield setIntValue:value];
1618 [o_slider setIntValue:value];
1619 [super resetValues];
1623 @implementation FloatConfigControl
1624 - (id) initWithItem: (module_config_t *)_p_item
1625 withView: (NSView *)o_parent_view
1627 NSRect mainFrame = [o_parent_view frame];
1628 NSString *o_labelString, *o_tooltip;
1629 mainFrame.size.height = 23;
1630 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN + 1;
1631 mainFrame.origin.x = LEFTMARGIN;
1632 mainFrame.origin.y = 0;
1634 if ([super initWithFrame: mainFrame item: _p_item] != nil) {
1635 i_view_type = CONFIG_ITEM_INTEGER;
1637 o_tooltip = [[VLCStringUtility sharedInstance] wrapString: _NS((char *)p_item->psz_longtext) toWidth: PREFS_WRAP];
1640 if (p_item->psz_text)
1641 o_labelString = _NS((char *)p_item->psz_text);
1643 o_labelString = @"";
1644 ADD_LABEL(o_label, mainFrame, 0, -2, o_labelString, o_tooltip)
1645 [o_label setAutoresizingMask:NSViewNotSizable ];
1646 [self addSubview: o_label];
1648 /* build the stepper */
1649 ADD_STEPPER(o_stepper, mainFrame, mainFrame.size.width - 19,
1650 0, o_tooltip, -100000, 100000)
1651 [o_stepper setFloatValue: p_item->value.f];
1652 [o_stepper setAutoresizingMask:NSViewMaxXMargin ];
1653 [self addSubview: o_stepper];
1655 /* build the textfield */
1656 ADD_TEXTFIELD(o_textfield, mainFrame, mainFrame.size.width - 19 - 52,
1657 1, 49, o_tooltip, @"")
1658 [o_textfield setFloatValue: p_item->value.f];
1659 [o_textfield setDelegate: self];
1660 [[NSNotificationCenter defaultCenter] addObserver: self
1661 selector: @selector(textfieldChanged:)
1662 name: NSControlTextDidChangeNotification
1663 object: o_textfield];
1664 [o_textfield setAutoresizingMask:NSViewMaxXMargin ];
1665 [self addSubview: o_textfield];
1670 - (void) alignWithXPosition:(int)i_xPos
1673 frame = [o_label frame];
1674 frame.origin.x = i_xPos - frame.size.width - 3;
1675 [o_label setFrame:frame];
1677 frame = [o_textfield frame];
1678 frame.origin.x = i_xPos + 2;
1679 [o_textfield setFrame:frame];
1681 frame = [o_stepper frame];
1682 frame.origin.x = i_xPos + [o_textfield frame].size.width + 5;
1683 [o_stepper setFrame:frame];
1688 [o_stepper release];
1689 [o_textfield release];
1693 - (IBAction)stepperChanged:(id)sender
1695 [o_textfield setFloatValue: [o_stepper floatValue]];
1698 - (void)textfieldChanged:(NSNotification *)o_notification
1700 [o_stepper setFloatValue: [o_textfield floatValue]];
1705 return [o_stepper floatValue];
1710 [o_textfield setFloatValue: config_GetFloat(VLCIntf, p_item->psz_name)];
1711 [super resetValues];
1715 @implementation RangedFloatConfigControl
1716 - (id) initWithItem: (module_config_t *)_p_item
1717 withView: (NSView *)o_parent_view
1719 NSRect mainFrame = [o_parent_view frame];
1720 NSString *o_labelString, *o_tooltip;
1721 mainFrame.size.height = 50;
1722 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN;
1723 mainFrame.origin.x = LEFTMARGIN;
1724 mainFrame.origin.y = 0;
1726 if ([super initWithFrame: mainFrame item: _p_item] != nil) {
1727 i_view_type = CONFIG_ITEM_RANGED_INTEGER;
1729 o_tooltip = [[VLCStringUtility sharedInstance] wrapString: _NS((char *)p_item->psz_longtext) toWidth: PREFS_WRAP];
1732 if (p_item->psz_text)
1733 o_labelString = _NS((char *)p_item->psz_text);
1735 o_labelString = @"";
1736 ADD_LABEL(o_label, mainFrame, 0, -3, o_labelString, o_tooltip)
1737 [o_label setAutoresizingMask:NSViewNotSizable ];
1738 [self addSubview: o_label];
1740 /* build the textfield */
1741 ADD_TEXTFIELD(o_textfield, mainFrame, [o_label frame].size.width + 2,
1742 28, 49, o_tooltip, @"")
1743 [o_textfield setFloatValue: p_item->value.f];
1744 [o_textfield setAutoresizingMask:NSViewMaxXMargin ];
1745 [o_textfield setDelegate: self];
1746 [[NSNotificationCenter defaultCenter] addObserver: self
1747 selector: @selector(textfieldChanged:)
1748 name: NSControlTextDidChangeNotification
1749 object: o_textfield];
1750 [self addSubview: o_textfield];
1752 /* build the mintextfield */
1753 ADD_LABEL(o_textfield_min, mainFrame, 12, -30, @"-8888", @"")
1754 [o_textfield_min setFloatValue: p_item->min.f];
1755 [o_textfield_min setAutoresizingMask:NSViewMaxXMargin ];
1756 [o_textfield_min setAlignment:NSRightTextAlignment];
1757 [self addSubview: o_textfield_min];
1759 /* build the maxtextfield */
1760 ADD_LABEL(o_textfield_max, mainFrame, mainFrame.size.width - 31,
1762 [o_textfield_max setFloatValue: p_item->max.f];
1763 [o_textfield_max setAutoresizingMask:NSViewMinXMargin ];
1764 [self addSubview: o_textfield_max];
1766 /* build the slider */
1767 ADD_SLIDER(o_slider, mainFrame, [o_textfield_min frame].origin.x +
1768 [o_textfield_min frame].size.width + 6, -1, mainFrame.size.width -
1769 [o_textfield_max frame].size.width -
1770 [o_textfield_max frame].size.width - 14 -
1771 [o_textfield_min frame].origin.x, o_tooltip, p_item->min.f,
1773 [o_slider setFloatValue: p_item->value.f];
1774 [o_slider setAutoresizingMask:NSViewWidthSizable ];
1775 [o_slider setTarget: self];
1776 [o_slider setAction: @selector(sliderChanged:)];
1777 [o_slider sendActionOn:NSLeftMouseUpMask | NSLeftMouseDownMask |
1778 NSLeftMouseDraggedMask];
1779 [self addSubview: o_slider];
1785 - (void) alignWithXPosition:(int)i_xPos
1788 frame = [o_label frame];
1789 frame.origin.x = i_xPos - frame.size.width - 3;
1790 [o_label setFrame:frame];
1792 frame = [o_textfield frame];
1793 frame.origin.x = i_xPos + 2;
1794 [o_textfield setFrame:frame];
1799 [o_textfield release];
1800 [o_textfield_min release];
1801 [o_textfield_max release];
1806 - (IBAction)sliderChanged:(id)sender
1808 [o_textfield setFloatValue: [o_slider floatValue]];
1811 - (void)textfieldChanged:(NSNotification *)o_notification
1813 [o_slider setFloatValue: [o_textfield floatValue]];
1818 return [o_slider floatValue];
1823 [o_textfield setFloatValue: config_GetFloat(VLCIntf, p_item->psz_name)];
1824 [o_slider setFloatValue: config_GetFloat(VLCIntf, p_item->psz_name)];
1825 [super resetValues];
1829 @implementation BoolConfigControl
1831 - (id) initWithItem: (module_config_t *)_p_item
1832 withView: (NSView *)o_parent_view
1834 NSRect mainFrame = [o_parent_view frame];
1835 NSString *o_labelString, *o_tooltip;
1836 mainFrame.size.height = 17;
1837 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN;
1838 mainFrame.origin.x = LEFTMARGIN;
1839 mainFrame.origin.y = 0;
1841 if ([super initWithFrame: mainFrame item: _p_item] != nil) {
1842 i_view_type = CONFIG_ITEM_BOOL;
1844 if (p_item->psz_text)
1845 o_labelString = _NS((char *)p_item->psz_text);
1847 o_labelString = @"";
1849 o_tooltip = [[VLCStringUtility sharedInstance] wrapString: _NS((char *)p_item->psz_longtext) toWidth: PREFS_WRAP];
1851 /* add the checkbox */
1852 ADD_CHECKBOX(o_checkbox, mainFrame, 0,
1853 0, o_labelString, o_tooltip, p_item->value.i, NSImageLeft)
1854 [o_checkbox setAutoresizingMask:NSViewNotSizable ];
1855 [self addSubview: o_checkbox];
1862 [o_checkbox release];
1868 return [o_checkbox intValue];
1873 [o_checkbox setState: config_GetInt(VLCIntf, p_item->psz_name)];
1874 [super resetValues];
1878 @implementation KeyConfigControl
1879 - (id) initWithItem: (module_config_t *)_p_item
1880 withView: (NSView *)o_parent_view
1882 NSRect mainFrame = [o_parent_view frame];
1883 NSString *o_labelString, *o_tooltip;
1884 mainFrame.size.height = 22;
1885 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN + 1;
1886 mainFrame.origin.x = LEFTMARGIN;
1887 mainFrame.origin.y = 0;
1889 if ([super initWithFrame: mainFrame item: _p_item] != nil) {
1890 i_view_type = CONFIG_ITEM_KEY;
1892 o_tooltip = [[VLCStringUtility sharedInstance] wrapString: _NS((char *)p_item->psz_longtext) toWidth: PREFS_WRAP];
1895 if (p_item->psz_text)
1896 o_labelString = _NS((char *)p_item->psz_text);
1898 o_labelString = @"";
1899 ADD_LABEL(o_label, mainFrame, 0, -1, o_labelString, o_tooltip)
1900 [o_label setAutoresizingMask:NSViewNotSizable ];
1901 [self addSubview: o_label];
1903 /* build the popup */
1904 ADD_POPUP(o_popup, mainFrame, [o_label frame].origin.x +
1905 [o_label frame].size.width + 3,
1907 [o_popup setAutoresizingMask:NSViewWidthSizable ];
1909 if (o_keys_menu == nil) {
1911 o_keys_menu = [[NSMenu alloc] initWithTitle: @"Keys Menu"];
1912 #warning This does not work anymore. FIXME.
1914 for (i = 0; i < sizeof(vlc_key) / sizeof(key_descriptor_t); i++)
1915 if (vlc_key[i].psz_key_string)
1916 POPULATE_A_KEY(o_keys_menu,
1917 [NSString stringWithUTF8String:vlc_key[i].psz_key_string],
1918 vlc_key[i].i_key_code)
1921 [o_popup setMenu:[o_keys_menu copyWithZone:nil]];
1922 [o_popup selectItem:[[o_popup menu] itemWithTag:p_item->value.i]];
1923 [self addSubview: o_popup];
1929 - (void) alignWithXPosition:(int)i_xPos
1932 NSRect superFrame = [self frame];
1933 frame = [o_label frame];
1934 frame.origin.x = i_xPos - frame.size.width - 3;
1935 [o_label setFrame:frame];
1937 frame = [o_popup frame];
1938 frame.origin.x = i_xPos - 1;
1939 frame.size.width = superFrame.size.width - frame.origin.x + 2;
1940 [o_popup setFrame:frame];
1951 return [o_popup selectedTag];
1956 [o_popup selectItem:[[o_popup menu] itemWithTag:config_GetInt(VLCIntf, p_item->psz_name)]];
1957 [super resetValues];
1961 @implementation ModuleListConfigControl
1962 - (id) initWithItem: (module_config_t *)_p_item
1963 withView: (NSView *)o_parent_view
1965 BOOL b_by_cat = _p_item->i_type == CONFIG_ITEM_MODULE_LIST_CAT;
1967 //Fill our array to know how may items we have...
1968 module_t *p_parser, **p_list;
1969 size_t i_module_index;
1970 NSRect mainFrame = [o_parent_view frame];
1971 NSString *o_labelString, *o_textfieldString, *o_tooltip;
1973 o_modulearray = [[NSMutableArray alloc] initWithCapacity:10];
1974 /* build a list of available modules */
1976 p_list = module_list_get(&count);
1977 for (i_module_index = 0; i_module_index < count; i_module_index++) {
1979 p_parser = p_list[i_module_index];
1981 if (module_is_main(p_parser))
1985 unsigned int confsize;
1986 module_config_t *p_configlist = module_config_get(p_parser, &confsize);
1988 for (i = 0; i < confsize; i++) {
1989 unsigned int unused;
1990 module_config_t *p_config = &p_configlist[i];
1991 NSString *o_modulelongname, *o_modulename;
1992 NSNumber *o_moduleenabled = nil;
1994 /* Hack: required subcategory is stored in i_min */
1995 if (p_config->i_type == CONFIG_SUBCATEGORY &&
1996 p_config->value.i == _p_item->min.i) {
1998 o_modulelongname = [NSString stringWithUTF8String:module_get_name(p_parser, TRUE)];
1999 o_modulename = [NSString stringWithUTF8String:module_get_object(p_parser)];
2001 if (_p_item->value.psz &&
2002 strstr(_p_item->value.psz, module_get_object(p_parser)))
2003 o_moduleenabled = [NSNumber numberWithBool:YES];
2005 o_moduleenabled = [NSNumber numberWithBool:NO];
2007 [o_modulearray addObject:[NSMutableArray
2008 arrayWithObjects: o_modulename, o_modulelongname,
2009 o_moduleenabled, nil]];
2012 /* Parental Advisory HACK:
2013 * Selecting HTTP, RC and Telnet interfaces is difficult now
2014 * since they are just the lua interface module */
2015 if (p_config->i_type == CONFIG_SUBCATEGORY &&
2016 !strcmp(module_get_object(p_parser), "lua") &&
2017 !strcmp(_p_item->psz_name, "extraintf") &&
2018 p_config->value.i == _p_item->min.i) {
2020 #define addLuaIntf(shortname, longname) \
2021 if (_p_item->value.psz && strstr(_p_item->value.psz, shortname))\
2022 o_moduleenabled = [NSNumber numberWithBool:YES];\
2024 o_moduleenabled = [NSNumber numberWithBool:NO];\
2025 [o_modulearray addObject:[NSMutableArray arrayWithObjects: @shortname, _NS(longname), o_moduleenabled, nil]]
2027 addLuaIntf("http", "Web");
2028 addLuaIntf("telnet", "Telnet");
2029 addLuaIntf("cli", "Console");
2034 module_config_free(p_configlist);
2037 } else if (module_provides(p_parser, _p_item->psz_type)) {
2039 NSString *o_modulelongname = toNSStr(module_get_name(p_parser, TRUE));
2040 NSString *o_modulename = toNSStr(module_get_object(p_parser));
2042 NSNumber *o_moduleenabled = nil;
2043 if (_p_item->value.psz &&
2044 strstr(_p_item->value.psz, module_get_object(p_parser)))
2045 o_moduleenabled = [NSNumber numberWithBool:YES];
2047 o_moduleenabled = [NSNumber numberWithBool:NO];
2049 [o_modulearray addObject:[NSMutableArray
2050 arrayWithObjects: o_modulename, o_modulelongname,
2051 o_moduleenabled, nil]];
2054 } /* FOR i_module_index */
2055 module_list_free(p_list);
2057 // First, initialize and draw the table view to get its height
2058 // width is increased a little to fix horizontal auto-sizing
2059 NSRect s_rc = NSMakeRect(12, 10, mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN + 18, 50);
2060 // height is automatically increased as needed
2061 o_tableview = [[NSTableView alloc] initWithFrame : s_rc];
2062 [o_tableview setUsesAlternatingRowBackgroundColors:YES];
2063 [o_tableview setHeaderView:nil];
2064 /* FIXME: support for multiple selection... */
2065 // [o_tableview setAllowsMultipleSelection:YES];
2067 NSCell *o_headerCell = [[NSCell alloc] initTextCell:@"Enabled"];
2068 NSCell *o_dataCell = [[NSButtonCell alloc] init];
2069 [(NSButtonCell*)o_dataCell setButtonType:NSSwitchButton];
2070 [o_dataCell setTitle:@""];
2071 [o_dataCell setFont:[NSFont systemFontOfSize:0]];
2072 NSTableColumn *o_tableColumn = [[NSTableColumn alloc]
2073 initWithIdentifier:@"Enabled"];
2074 [o_tableColumn setHeaderCell: o_headerCell];
2075 [o_tableColumn setDataCell: o_dataCell];
2076 [o_tableColumn setWidth:17];
2077 [o_tableview addTableColumn: o_tableColumn];
2079 o_headerCell = [[NSCell alloc] initTextCell:@"Module Name"];
2080 o_dataCell = [[NSTextFieldCell alloc] init];
2081 [o_dataCell setFont:[NSFont systemFontOfSize:12]];
2082 o_tableColumn = [[NSTableColumn alloc]
2083 initWithIdentifier:@"Module"];
2084 [o_tableColumn setHeaderCell: o_headerCell];
2085 [o_tableColumn setDataCell: o_dataCell];
2086 [o_tableColumn setWidth:s_rc.size.width - 34];
2087 [o_tableview addTableColumn: o_tableColumn];
2088 [o_tableview registerForDraggedTypes:[NSArray arrayWithObject:@"VLC media player module"]];
2090 [o_tableview setDataSource:self];
2091 [o_tableview setTarget: self];
2092 [o_tableview setAction: @selector(tableChanged:)];
2093 [o_tableview sendActionOn:NSLeftMouseUpMask | NSLeftMouseDownMask |
2094 NSLeftMouseDraggedMask];
2096 [o_tableview reloadData];
2097 [o_tableview setAutoresizingMask: NSViewWidthSizable];
2099 CGFloat tableview_height = [o_tableview frame].size.height;
2101 mainFrame.size.height = 40 + tableview_height;
2102 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN;
2103 mainFrame.origin.x = LEFTMARGIN;
2104 mainFrame.origin.y = 0;
2105 if ([super initWithFrame: mainFrame item: _p_item] != nil) {
2106 i_view_type = CONFIG_ITEM_MODULE_LIST;
2108 o_tooltip = [[VLCStringUtility sharedInstance] wrapString: _NS((char *)p_item->psz_longtext) toWidth: PREFS_WRAP];
2111 if (p_item->psz_text)
2112 o_labelString = _NS((char *)p_item->psz_text);
2114 o_labelString = @"";
2115 ADD_LABEL(o_label, mainFrame, 0, -3, o_labelString, o_tooltip)
2116 [o_label setAutoresizingMask:NSViewNotSizable ];
2117 [self addSubview: o_label];
2119 /* build the textfield */
2120 if (p_item->value.psz)
2121 o_textfieldString = _NS((char *)p_item->value.psz);
2123 o_textfieldString = @"";
2124 ADD_TEXTFIELD(o_textfield, mainFrame, [o_label frame].size.width + 2,
2125 mainFrame.size.height - 22, mainFrame.size.width -
2126 [o_label frame].size.width - 2, o_tooltip, o_textfieldString)
2127 [o_textfield setAutoresizingMask:NSViewWidthSizable ];
2128 [self addSubview: o_textfield];
2130 [self addSubview: o_tableview];
2135 - (void) alignWithXPosition:(int)i_xPos
2140 - (IBAction)tableChanged:(id)sender
2142 NSString *o_newstring = @"";
2143 NSUInteger count = [o_modulearray count];
2144 for (NSUInteger i = 0 ; i < count ; i++)
2145 if ([[[o_modulearray objectAtIndex:i] objectAtIndex:2]
2147 o_newstring = [o_newstring stringByAppendingString:
2148 [[o_modulearray objectAtIndex:i] objectAtIndex:0]];
2149 o_newstring = [o_newstring stringByAppendingString:@":"];
2152 [o_textfield setStringValue: [o_newstring
2153 substringToIndex: ([o_newstring length])?[o_newstring length] - 1:0]];
2158 [o_tableview release];
2163 - (char *)stringValue
2165 return strdup([[o_textfield stringValue] UTF8String]);
2170 #warning Reset prefs of the module selector is broken atm.
2171 msg_Err(VLCIntf, "don't forget about modulelistconfig");
2172 [super resetValues];
2177 @implementation ModuleListConfigControl (NSTableDataSource)
2179 - (BOOL)tableView:(NSTableView*)table writeRows:(NSArray*)rows
2180 toPasteboard:(NSPasteboard*)pb
2182 // We only want to allow dragging of selected rows.
2183 NSEnumerator *iter = [rows objectEnumerator];
2185 while ((row = [iter nextObject]) != nil) {
2186 if (![table isRowSelected:[row intValue]])
2190 [pb declareTypes:[NSArray arrayWithObject:@"VLC media player module"] owner:nil];
2191 [pb setPropertyList:rows forType:@"VLC media player module"];
2195 - (NSDragOperation)tableView:(NSTableView*)table
2196 validateDrop:(id <NSDraggingInfo>)info proposedRow:(NSInteger)row
2197 proposedDropOperation:(NSTableViewDropOperation)op
2199 // Make drops at the end of the table go to the end.
2201 row = [table numberOfRows];
2202 op = NSTableViewDropAbove;
2203 [table setDropRow:row dropOperation:op];
2206 // We don't ever want to drop onto a row, only between rows.
2207 if (op == NSTableViewDropOn)
2208 [table setDropRow:(row+1) dropOperation:NSTableViewDropAbove];
2209 return NSTableViewDropAbove;
2212 - (BOOL)tableView:(NSTableView*)table acceptDrop:(id <NSDraggingInfo>)info
2213 row:(NSInteger)dropRow dropOperation:(NSTableViewDropOperation)op;
2215 NSPasteboard *pb = [info draggingPasteboard];
2216 NSDragOperation srcMask = [info draggingSourceOperationMask];
2223 // Intra-table drag - data is the array of rows.
2224 if (!accepted && (array =
2225 [pb propertyListForType:@"VLC media player module"]) != NULL) {
2226 NSEnumerator *iter = nil;
2228 BOOL isCopy = (srcMask & NSDragOperationMove) ? NO:YES;
2230 iter = [array objectEnumerator];
2231 while ((val = [iter nextObject]) != NULL) {
2232 NSArray *o_tmp = [[o_modulearray objectAtIndex:
2233 [val intValue]] mutableCopyWithZone:nil];
2234 [o_modulearray removeObject:o_tmp];
2235 [o_modulearray insertObject:o_tmp
2236 atIndex:(dropRow>[val intValue]) ? dropRow - 1 : dropRow];
2240 // Select the newly-dragged items.
2241 iter = [array objectEnumerator];
2243 [table deselectAll:self];
2245 [self tableChanged:self];
2246 [table setNeedsDisplay:YES];
2247 // Indicate that we finished the drag.
2251 [table setNeedsDisplay:YES];
2255 // An exception occurred. Uh-oh. Update the track table so that
2256 // it stays consistent, and re-raise the exception.
2258 [localException raise];
2259 [table setNeedsDisplay:YES];
2265 - (NSInteger)numberOfRowsInTableView:(NSTableView *)aTableView
2267 return [o_modulearray count];
2270 - (id)tableView:(NSTableView *)aTableView
2271 objectValueForTableColumn:(NSTableColumn *)aTableColumn row:(NSInteger)rowIndex
2273 if ([[aTableColumn identifier] isEqualToString: @"Enabled"])
2274 return [[o_modulearray objectAtIndex:rowIndex] objectAtIndex:2];
2275 if ([[aTableColumn identifier] isEqualToString: @"Module"])
2276 return [[o_modulearray objectAtIndex:rowIndex] objectAtIndex:1];
2281 - (void)tableView:(NSTableView *)aTableView setObjectValue:(id)anObject
2282 forTableColumn:(NSTableColumn *)aTableColumn row:(NSInteger)rowIndex
2284 [[o_modulearray objectAtIndex:rowIndex] replaceObjectAtIndex:2
2285 withObject: anObject];
2289 @implementation SectionControl
2291 - (id) initWithItem: (module_config_t *)_p_item
2292 withView: (NSView *)o_parent_view
2294 NSRect mainFrame = [o_parent_view frame];
2295 NSString *o_labelString, *o_tooltip;
2296 mainFrame.size.height = 17;
2297 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN;
2298 mainFrame.origin.x = LEFTMARGIN;
2299 mainFrame.origin.y = 0;
2301 if ([super initWithFrame: mainFrame item: _p_item] != nil) {
2304 if (p_item->psz_text)
2305 o_labelString = _NS((char *)p_item->psz_text);
2307 o_labelString = @"";
2309 NSDictionary *boldAttributes = [NSDictionary dictionaryWithObjectsAndKeys:
2310 [NSFont boldSystemFontOfSize:[NSFont systemFontSize]],
2311 NSFontAttributeName,
2313 NSAttributedString *o_bold_string = [[NSAttributedString alloc] initWithString: o_labelString attributes: boldAttributes];
2315 ADD_LABEL(o_label, mainFrame, 1, 0, @"", @"")
2316 [o_label setAttributedStringValue: o_bold_string];
2317 [o_label sizeToFit];
2319 [o_bold_string release];
2321 [o_label setAutoresizingMask:NSViewNotSizable];
2322 [self addSubview: o_label];