1 /*****************************************************************************
2 * prefs_widgets.m: Preferences controls
3 *****************************************************************************
4 * Copyright (C) 2002-2012 VLC authors and VideoLAN
7 * Authors: Derk-Jan Hartman <hartman at videolan.org>
8 * Jérôme Decoodt <djc at videolan.org>
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
23 *****************************************************************************/
25 /*****************************************************************************
27 *****************************************************************************/
28 #include <stdlib.h> /* malloc(), free() */
35 #include <vlc_common.h>
36 #include <vlc_modules.h>
37 #include <vlc_plugin.h>
41 #include "prefs_widgets.h"
43 #define PREFS_WRAP 300
44 #define OFFSET_RIGHT 20
45 #define OFFSET_BETWEEN 2
47 #define UPWARDS_WHITE_ARROW "\xE2\x87\xA7"
48 #define OPTION_KEY "\xE2\x8C\xA5"
49 #define UP_ARROWHEAD "\xE2\x8C\x83"
50 #define PLACE_OF_INTEREST_SIGN "\xE2\x8C\x98"
52 #define POPULATE_A_KEY(o_menu, string, value) \
56 o_mi = [[NSMenuItem alloc] initWithTitle:string \
57 action:nil keyEquivalent:@""]; \
58 [o_mi setKeyEquivalentModifierMask: \
60 [o_mi setAlternate: NO]; \
63 [o_menu addItem: o_mi]; \
65 o_mi = [[NSMenuItem alloc] initWithTitle: \
66 [[NSString stringWithUTF8String: \
68 ] stringByAppendingString: string] \
69 action:nil keyEquivalent:@""]; \
70 [o_mi setKeyEquivalentModifierMask: \
72 [o_mi setAlternate: YES]; \
74 KEY_MODIFIER_CTRL | (value)]; \
75 [o_menu addItem: o_mi]; \
77 o_mi = [[NSMenuItem alloc] initWithTitle: \
78 [[NSString stringWithUTF8String: \
79 UP_ARROWHEAD OPTION_KEY \
80 ] stringByAppendingString: string] \
81 action:nil keyEquivalent:@""]; \
82 [o_mi setKeyEquivalentModifierMask: \
83 NSControlKeyMask | NSAlternateKeyMask]; \
84 [o_mi setAlternate: YES]; \
86 (KEY_MODIFIER_CTRL | KEY_MODIFIER_ALT) | (value)]; \
87 [o_menu addItem: o_mi]; \
89 o_mi = [[NSMenuItem alloc] initWithTitle: \
90 [[NSString stringWithUTF8String: \
91 UP_ARROWHEAD UPWARDS_WHITE_ARROW \
92 ] stringByAppendingString: string] \
93 action:nil keyEquivalent:@""]; \
94 [o_mi setKeyEquivalentModifierMask: \
95 NSControlKeyMask | NSShiftKeyMask]; \
96 [o_mi setAlternate: YES]; \
98 (KEY_MODIFIER_CTRL | KEY_MODIFIER_SHIFT) | (value)]; \
99 [o_menu addItem: o_mi]; \
101 o_mi = [[NSMenuItem alloc] initWithTitle: \
102 [[NSString stringWithUTF8String: \
103 UP_ARROWHEAD PLACE_OF_INTEREST_SIGN \
104 ] stringByAppendingString: string] \
105 action:nil keyEquivalent:@""]; \
106 [o_mi setKeyEquivalentModifierMask: \
107 NSControlKeyMask | NSCommandKeyMask]; \
108 [o_mi setAlternate: YES]; \
110 (KEY_MODIFIER_CTRL | KEY_MODIFIER_COMMAND) | (value)]; \
111 [o_menu addItem: o_mi]; \
112 /* Ctrl+Alt+Shift */ \
113 o_mi = [[NSMenuItem alloc] initWithTitle: \
114 [[NSString stringWithUTF8String: \
115 UP_ARROWHEAD OPTION_KEY UPWARDS_WHITE_ARROW \
116 ] stringByAppendingString: string] \
117 action:nil keyEquivalent:@""]; \
118 [o_mi setKeyEquivalentModifierMask: \
119 NSControlKeyMask | NSAlternateKeyMask | NSShiftKeyMask]; \
120 [o_mi setAlternate: YES]; \
122 (KEY_MODIFIER_CTRL | KEY_MODIFIER_ALT | KEY_MODIFIER_SHIFT) | \
124 [o_menu addItem: o_mi]; \
125 /* Ctrl+Alt+Apple */ \
126 o_mi = [[NSMenuItem alloc] initWithTitle: \
127 [[NSString stringWithUTF8String: \
128 UP_ARROWHEAD OPTION_KEY PLACE_OF_INTEREST_SIGN \
129 ] stringByAppendingString: string] \
130 action:nil keyEquivalent:@""]; \
131 [o_mi setKeyEquivalentModifierMask: \
132 NSControlKeyMask | NSAlternateKeyMask | NSCommandKeyMask]; \
133 [o_mi setAlternate: YES]; \
135 (KEY_MODIFIER_CTRL | KEY_MODIFIER_ALT | KEY_MODIFIER_COMMAND) | \
137 [o_menu addItem: o_mi]; \
138 /* Ctrl+Shift+Apple */ \
139 o_mi = [[NSMenuItem alloc] initWithTitle: \
140 [[NSString stringWithUTF8String: \
141 UP_ARROWHEAD UPWARDS_WHITE_ARROW PLACE_OF_INTEREST_SIGN \
142 ] stringByAppendingString: string] \
143 action:nil keyEquivalent:@""]; \
144 [o_mi setKeyEquivalentModifierMask: \
145 NSControlKeyMask | NSShiftKeyMask | NSCommandKeyMask]; \
146 [o_mi setAlternate: YES]; \
148 (KEY_MODIFIER_CTRL | KEY_MODIFIER_SHIFT | KEY_MODIFIER_COMMAND) | \
150 [o_menu addItem: o_mi]; \
151 /* Ctrl+Alt+Shift+Apple */ \
152 o_mi = [[NSMenuItem alloc] initWithTitle: \
153 [[NSString stringWithUTF8String: \
154 UP_ARROWHEAD OPTION_KEY UPWARDS_WHITE_ARROW \
155 PLACE_OF_INTEREST_SIGN \
156 ] stringByAppendingString: string] \
157 action:nil keyEquivalent:@""]; \
158 [o_mi setKeyEquivalentModifierMask: \
159 NSControlKeyMask | NSAlternateKeyMask | NSShiftKeyMask | \
161 [o_mi setAlternate: YES]; \
163 (KEY_MODIFIER_CTRL | KEY_MODIFIER_ALT | KEY_MODIFIER_SHIFT | \
164 KEY_MODIFIER_COMMAND) | (value)]; \
165 [o_menu addItem: o_mi]; \
167 o_mi = [[NSMenuItem alloc] initWithTitle: \
168 [[NSString stringWithUTF8String: \
170 ] stringByAppendingString: string] \
171 action:nil keyEquivalent:@""]; \
172 [o_mi setKeyEquivalentModifierMask: \
173 NSAlternateKeyMask]; \
174 [o_mi setAlternate: YES]; \
176 KEY_MODIFIER_ALT | (value)]; \
177 [o_menu addItem: o_mi]; \
179 o_mi = [[NSMenuItem alloc] initWithTitle: \
180 [[NSString stringWithUTF8String: \
181 OPTION_KEY UPWARDS_WHITE_ARROW \
182 ] stringByAppendingString: string] \
183 action:nil keyEquivalent:@""]; \
184 [o_mi setKeyEquivalentModifierMask: \
185 NSAlternateKeyMask | NSShiftKeyMask]; \
186 [o_mi setAlternate: YES]; \
188 (KEY_MODIFIER_ALT | KEY_MODIFIER_SHIFT) | (value)]; \
189 [o_menu addItem: o_mi]; \
191 o_mi = [[NSMenuItem alloc] initWithTitle: \
192 [[NSString stringWithUTF8String: \
193 OPTION_KEY PLACE_OF_INTEREST_SIGN \
194 ] stringByAppendingString: string] \
195 action:nil keyEquivalent:@""]; \
196 [o_mi setKeyEquivalentModifierMask: \
197 NSAlternateKeyMask | NSCommandKeyMask]; \
198 [o_mi setAlternate: YES]; \
200 (KEY_MODIFIER_ALT | KEY_MODIFIER_COMMAND) | (value)]; \
201 [o_menu addItem: o_mi]; \
202 /* Alt+Shift+Apple */ \
203 o_mi = [[NSMenuItem alloc] initWithTitle: \
204 [[NSString stringWithUTF8String: \
205 OPTION_KEY UPWARDS_WHITE_ARROW PLACE_OF_INTEREST_SIGN \
206 ] stringByAppendingString: string] \
207 action:nil keyEquivalent:@""]; \
208 [o_mi setKeyEquivalentModifierMask: \
209 NSAlternateKeyMask | NSShiftKeyMask | NSCommandKeyMask]; \
210 [o_mi setAlternate: YES]; \
212 (KEY_MODIFIER_ALT | KEY_MODIFIER_SHIFT | KEY_MODIFIER_COMMAND) | \
214 [o_menu addItem: o_mi]; \
216 o_mi = [[NSMenuItem alloc] initWithTitle: \
217 [[NSString stringWithUTF8String: \
218 UPWARDS_WHITE_ARROW \
219 ] stringByAppendingString: string] \
220 action:nil keyEquivalent:@""]; \
221 [o_mi setKeyEquivalentModifierMask: \
223 [o_mi setAlternate: YES]; \
225 KEY_MODIFIER_SHIFT | (value)]; \
226 [o_menu addItem: o_mi]; \
228 o_mi = [[NSMenuItem alloc] initWithTitle: \
229 [[NSString stringWithUTF8String: \
230 UPWARDS_WHITE_ARROW PLACE_OF_INTEREST_SIGN \
231 ] stringByAppendingString: string] \
232 action:nil keyEquivalent:@""]; \
233 [o_mi setKeyEquivalentModifierMask: \
234 NSShiftKeyMask | NSCommandKeyMask]; \
235 [o_mi setAlternate: YES]; \
237 (KEY_MODIFIER_SHIFT | KEY_MODIFIER_COMMAND) | (value)]; \
238 [o_menu addItem: o_mi]; \
240 o_mi = [[NSMenuItem alloc] initWithTitle: \
241 [[NSString stringWithUTF8String: \
242 PLACE_OF_INTEREST_SIGN \
243 ] stringByAppendingString: string] \
244 action:nil keyEquivalent:@""]; \
245 [o_mi setKeyEquivalentModifierMask: \
247 [o_mi setAlternate: YES]; \
249 KEY_MODIFIER_COMMAND | (value)]; \
250 [o_menu addItem: o_mi]; \
253 #define ADD_LABEL(o_label, superFrame, x_offset, my_y_offset, label, \
256 NSRect s_rc = superFrame; \
257 s_rc.size.height = 17; \
258 s_rc.origin.x = x_offset - 3; \
259 s_rc.origin.y = superFrame.size.height - 17 + my_y_offset; \
260 o_label = [[[NSTextField alloc] initWithFrame: s_rc] retain]; \
261 [o_label setDrawsBackground: NO]; \
262 [o_label setBordered: NO]; \
263 [o_label setEditable: NO]; \
264 [o_label setSelectable: NO]; \
265 [o_label setStringValue: label]; \
266 [o_label setToolTip: tooltip]; \
267 [o_label setFont:[NSFont systemFontOfSize:0]]; \
268 [o_label sizeToFit]; \
271 #define ADD_TEXTFIELD(o_textfield, superFrame, x_offset, my_y_offset, \
272 my_width, tooltip, init_value) \
274 NSRect s_rc = superFrame; \
275 s_rc.origin.x = x_offset; \
276 s_rc.origin.y = my_y_offset; \
277 s_rc.size.height = 22; \
278 s_rc.size.width = my_width; \
279 o_textfield = [[[NSTextField alloc] initWithFrame: s_rc] retain]; \
280 [o_textfield setFont:[NSFont systemFontOfSize:0]]; \
281 [o_textfield setToolTip: tooltip]; \
282 [o_textfield setStringValue: init_value]; \
285 #define ADD_SECURETEXTFIELD(o_textfield, superFrame, x_offset, my_y_offset, \
286 my_width, tooltip, init_value) \
288 NSRect s_rc = superFrame; \
289 s_rc.origin.x = x_offset; \
290 s_rc.origin.y = my_y_offset; \
291 s_rc.size.height = 22; \
292 s_rc.size.width = my_width; \
293 o_textfield = [[[NSSecureTextField alloc] initWithFrame: s_rc] retain]; \
294 [o_textfield setFont:[NSFont systemFontOfSize:0]]; \
295 [o_textfield setToolTip: tooltip]; \
296 [o_textfield setStringValue: init_value]; \
299 #define ADD_COMBO(o_combo, superFrame, x_offset, my_y_offset, x2_offset, \
302 NSRect s_rc = superFrame; \
303 s_rc.origin.x = x_offset + 2; \
304 s_rc.origin.y = my_y_offset; \
305 s_rc.size.height = 26; \
306 s_rc.size.width = superFrame.size.width + 2 - s_rc.origin.x - \
308 o_combo = [[[NSComboBox alloc] initWithFrame: s_rc] retain]; \
309 [o_combo setFont:[NSFont systemFontOfSize:0]]; \
310 [o_combo setToolTip: tooltip]; \
311 [o_combo setUsesDataSource:TRUE]; \
312 [o_combo setDataSource:self]; \
313 [o_combo setNumberOfVisibleItems:10]; \
314 [o_combo setCompletes:YES]; \
317 #define ADD_RIGHT_BUTTON(o_button, superFrame, x_offset, my_y_offset, \
320 NSRect s_rc = superFrame; \
321 o_button = [[[NSButton alloc] initWithFrame: s_rc] retain]; \
322 [o_button setButtonType: NSMomentaryPushInButton]; \
323 [o_button setBezelStyle: NSRoundedBezelStyle]; \
324 [o_button setTitle: title]; \
325 [o_button setFont:[NSFont systemFontOfSize:0]]; \
326 [o_button sizeToFit]; \
327 s_rc = [o_button frame]; \
328 s_rc.origin.x = superFrame.size.width - [o_button frame].size.width - 6;\
329 s_rc.origin.y = my_y_offset - 6; \
330 s_rc.size.width += 12; \
331 [o_button setFrame: s_rc]; \
332 [o_button setToolTip: tooltip]; \
333 [o_button setTarget: self]; \
334 [o_button setAction: @selector(openFileDialog:)]; \
337 #define ADD_POPUP(o_popup, superFrame, x_offset, my_y_offset, x2_offset, \
340 NSRect s_rc = superFrame; \
341 s_rc.origin.x = x_offset - 1; \
342 s_rc.origin.y = my_y_offset; \
343 s_rc.size.height = 26; \
344 s_rc.size.width = superFrame.size.width + 2 - s_rc.origin.x - \
346 o_popup = [[[NSPopUpButton alloc] initWithFrame: s_rc] retain]; \
347 [o_popup setFont:[NSFont systemFontOfSize:0]]; \
348 [o_popup setToolTip: tooltip]; \
351 #define ADD_STEPPER(o_stepper, superFrame, x_offset, my_y_offset, tooltip, \
354 NSRect s_rc = superFrame; \
355 s_rc.origin.x = x_offset; \
356 s_rc.origin.y = my_y_offset; \
357 s_rc.size.height = 23; \
358 s_rc.size.width = 23; \
359 o_stepper = [[[NSStepper alloc] initWithFrame: s_rc] retain]; \
360 [o_stepper setFont:[NSFont systemFontOfSize:0]]; \
361 [o_stepper setToolTip: tooltip]; \
362 [o_stepper setMaxValue: higher]; \
363 [o_stepper setMinValue: lower]; \
364 [o_stepper setTarget: self]; \
365 [o_stepper setAction: @selector(stepperChanged:)]; \
366 [o_stepper sendActionOn:NSLeftMouseUpMask | NSLeftMouseDownMask | \
367 NSLeftMouseDraggedMask]; \
370 #define ADD_SLIDER(o_slider, superFrame, x_offset, my_y_offset, my_width, \
371 tooltip, lower, higher) \
373 NSRect s_rc = superFrame; \
374 s_rc.origin.x = x_offset; \
375 s_rc.origin.y = my_y_offset; \
376 s_rc.size.height = 21; \
377 s_rc.size.width = my_width; \
378 o_slider = [[[NSSlider alloc] initWithFrame: s_rc] retain]; \
379 [o_slider setFont:[NSFont systemFontOfSize:0]]; \
380 [o_slider setToolTip: tooltip]; \
381 [o_slider setMaxValue: higher]; \
382 [o_slider setMinValue: lower]; \
385 #define ADD_CHECKBOX(o_checkbox, superFrame, x_offset, my_y_offset, label, \
386 tooltip, init_value, position) \
388 NSRect s_rc = superFrame; \
389 s_rc.size.height = 18; \
390 s_rc.origin.x = x_offset - 2; \
391 s_rc.origin.y = superFrame.size.height - 18 + my_y_offset; \
392 o_checkbox = [[[NSButton alloc] initWithFrame: s_rc] retain]; \
393 [o_checkbox setFont:[NSFont systemFontOfSize:0]]; \
394 [o_checkbox setButtonType: NSSwitchButton]; \
395 [o_checkbox setImagePosition: position]; \
396 [o_checkbox setIntValue: init_value]; \
397 [o_checkbox setTitle: label]; \
398 [o_checkbox setToolTip: tooltip]; \
399 [o_checkbox sizeToFit]; \
402 @implementation VLCConfigControl
403 @synthesize type = i_type, viewType = i_view_type, advanced = b_advanced;
405 - (id)initWithFrame: (NSRect)frame
407 return [self initWithFrame: frame
411 - (id)initWithFrame: (NSRect)frame
412 item: (module_config_t *)_p_item
414 self = [super initWithFrame: frame];
418 psz_name = p_item->psz_name;
420 i_type = p_item->i_type;
422 b_advanced = p_item->b_advanced;
423 [self setAutoresizingMask:NSViewWidthSizable | NSViewMinYMargin ];
428 - (void)setYPos:(int)i_yPos
430 NSRect frame = [self frame];
431 frame.origin.y = i_yPos;
432 [self setFrame:frame];
437 if (o_label) [o_label release];
442 + (int)calcVerticalMargin: (int)i_curItem lastItem: (int)i_lastItem
446 case CONFIG_ITEM_STRING:
447 case CONFIG_ITEM_PASSWORD:
449 case CONFIG_ITEM_STRING:
450 case CONFIG_ITEM_PASSWORD:
453 case CONFIG_ITEM_STRING_LIST:
456 case CONFIG_ITEM_LOADFILE:
457 case CONFIG_ITEM_SAVEFILE:
460 case CONFIG_ITEM_MODULE:
463 case CONFIG_ITEM_INTEGER:
466 case CONFIG_ITEM_RANGED_INTEGER:
469 case CONFIG_ITEM_BOOL:
472 case CONFIG_ITEM_KEY:
475 case CONFIG_ITEM_MODULE_LIST:
483 case CONFIG_ITEM_STRING_LIST:
485 case CONFIG_ITEM_STRING:
486 case CONFIG_ITEM_PASSWORD:
489 case CONFIG_ITEM_STRING_LIST:
492 case CONFIG_ITEM_LOADFILE:
493 case CONFIG_ITEM_SAVEFILE:
496 case CONFIG_ITEM_MODULE:
499 case CONFIG_ITEM_INTEGER:
502 case CONFIG_ITEM_RANGED_INTEGER:
505 case CONFIG_ITEM_BOOL:
508 case CONFIG_ITEM_KEY:
511 case CONFIG_ITEM_MODULE_LIST:
519 case CONFIG_ITEM_LOADFILE:
520 case CONFIG_ITEM_SAVEFILE:
522 case CONFIG_ITEM_STRING:
523 case CONFIG_ITEM_PASSWORD:
526 case CONFIG_ITEM_STRING_LIST:
529 case CONFIG_ITEM_LOADFILE:
530 case CONFIG_ITEM_SAVEFILE:
533 case CONFIG_ITEM_MODULE:
536 case CONFIG_ITEM_INTEGER:
539 case CONFIG_ITEM_RANGED_INTEGER:
542 case CONFIG_ITEM_BOOL:
545 case CONFIG_ITEM_KEY:
548 case CONFIG_ITEM_MODULE_LIST:
556 case CONFIG_ITEM_MODULE:
558 case CONFIG_ITEM_STRING:
559 case CONFIG_ITEM_PASSWORD:
562 case CONFIG_ITEM_STRING_LIST:
565 case CONFIG_ITEM_LOADFILE:
566 case CONFIG_ITEM_SAVEFILE:
569 case CONFIG_ITEM_MODULE:
572 case CONFIG_ITEM_INTEGER:
575 case CONFIG_ITEM_RANGED_INTEGER:
578 case CONFIG_ITEM_BOOL:
581 case CONFIG_ITEM_KEY:
584 case CONFIG_ITEM_MODULE_LIST:
592 case CONFIG_ITEM_INTEGER:
594 case CONFIG_ITEM_STRING:
595 case CONFIG_ITEM_PASSWORD:
598 case CONFIG_ITEM_STRING_LIST:
601 case CONFIG_ITEM_LOADFILE:
602 case CONFIG_ITEM_SAVEFILE:
605 case CONFIG_ITEM_MODULE:
608 case CONFIG_ITEM_INTEGER:
611 case CONFIG_ITEM_RANGED_INTEGER:
614 case CONFIG_ITEM_BOOL:
617 case CONFIG_ITEM_KEY:
620 case CONFIG_ITEM_MODULE_LIST:
628 case CONFIG_ITEM_RANGED_INTEGER:
630 case CONFIG_ITEM_STRING:
631 case CONFIG_ITEM_PASSWORD:
634 case CONFIG_ITEM_STRING_LIST:
637 case CONFIG_ITEM_LOADFILE:
638 case CONFIG_ITEM_SAVEFILE:
641 case CONFIG_ITEM_MODULE:
644 case CONFIG_ITEM_INTEGER:
647 case CONFIG_ITEM_RANGED_INTEGER:
650 case CONFIG_ITEM_BOOL:
653 case CONFIG_ITEM_KEY:
656 case CONFIG_ITEM_MODULE_LIST:
664 case CONFIG_ITEM_BOOL:
666 case CONFIG_ITEM_STRING:
667 case CONFIG_ITEM_PASSWORD:
670 case CONFIG_ITEM_STRING_LIST:
673 case CONFIG_ITEM_LOADFILE:
674 case CONFIG_ITEM_SAVEFILE:
677 case CONFIG_ITEM_MODULE:
680 case CONFIG_ITEM_INTEGER:
683 case CONFIG_ITEM_RANGED_INTEGER:
686 case CONFIG_ITEM_BOOL:
689 case CONFIG_ITEM_KEY:
692 case CONFIG_ITEM_MODULE_LIST:
700 case CONFIG_ITEM_KEY:
702 case CONFIG_ITEM_STRING:
703 case CONFIG_ITEM_PASSWORD:
706 case CONFIG_ITEM_STRING_LIST:
709 case CONFIG_ITEM_LOADFILE:
710 case CONFIG_ITEM_SAVEFILE:
713 case CONFIG_ITEM_MODULE:
716 case CONFIG_ITEM_INTEGER:
719 case CONFIG_ITEM_RANGED_INTEGER:
722 case CONFIG_ITEM_BOOL:
725 case CONFIG_ITEM_KEY:
728 case CONFIG_ITEM_MODULE_LIST:
736 case CONFIG_ITEM_MODULE_LIST:
738 case CONFIG_ITEM_STRING:
739 case CONFIG_ITEM_PASSWORD:
742 case CONFIG_ITEM_STRING_LIST:
745 case CONFIG_ITEM_LOADFILE:
746 case CONFIG_ITEM_SAVEFILE:
749 case CONFIG_ITEM_MODULE:
752 case CONFIG_ITEM_INTEGER:
755 case CONFIG_ITEM_RANGED_INTEGER:
758 case CONFIG_ITEM_BOOL:
761 case CONFIG_ITEM_KEY:
764 case CONFIG_ITEM_MODULE_LIST:
779 + (VLCConfigControl *)newControl: (module_config_t *)_p_item
780 withView: (NSView *)o_parent_view
782 VLCConfigControl *p_control = NULL;
784 switch(_p_item->i_type) {
785 case CONFIG_ITEM_STRING:
786 case CONFIG_ITEM_PASSWORD:
787 if (!_p_item->list_count) {
788 p_control = [[StringConfigControl alloc]
789 initWithItem: _p_item
790 withView: o_parent_view];
792 p_control = [[StringListConfigControl alloc]
793 initWithItem: _p_item
794 withView: o_parent_view];
797 case CONFIG_ITEM_LOADFILE:
798 case CONFIG_ITEM_SAVEFILE:
799 case CONFIG_ITEM_DIRECTORY:
800 p_control = [[FileConfigControl alloc]
801 initWithItem: _p_item
802 withView: o_parent_view];
804 case CONFIG_ITEM_MODULE:
805 case CONFIG_ITEM_MODULE_CAT:
806 p_control = [[ModuleConfigControl alloc]
807 initWithItem: _p_item
808 withView: o_parent_view];
810 case CONFIG_ITEM_INTEGER:
811 if (_p_item->list_count)
812 p_control = [[IntegerListConfigControl alloc] initWithItem: _p_item withView: o_parent_view];
813 else if ((_p_item->min.i != 0 || _p_item->max.i != 0) && (_p_item->min.i != INT_MIN || _p_item->max.i != INT_MAX))
814 p_control = [[RangedIntegerConfigControl alloc] initWithItem: _p_item withView: o_parent_view];
816 p_control = [[IntegerConfigControl alloc] initWithItem: _p_item withView: o_parent_view];
818 case CONFIG_ITEM_BOOL:
819 p_control = [[BoolConfigControl alloc]
820 initWithItem: _p_item
821 withView: o_parent_view];
823 case CONFIG_ITEM_FLOAT:
824 if ((_p_item->min.i != 0 || _p_item->max.i != 0) && (_p_item->min.i != INT_MIN || _p_item->max.i != INT_MAX))
825 p_control = [[RangedFloatConfigControl alloc] initWithItem: _p_item withView: o_parent_view];
827 p_control = [[FloatConfigControl alloc] initWithItem: _p_item withView: o_parent_view];
829 /* don't display keys in the advanced settings, since the current controls
830 are broken by design. The user is required to change hotkeys in the sprefs
831 and can only change really advanced stuff here..
832 case CONFIG_ITEM_KEY:
833 p_control = [[KeyConfigControl alloc]
834 initWithItem: _p_item
835 withView: o_parent_view];
837 case CONFIG_ITEM_MODULE_LIST:
838 case CONFIG_ITEM_MODULE_LIST_CAT:
839 p_control = [[ModuleListConfigControl alloc] initWithItem: _p_item withView: o_parent_view];
842 p_control = [[SectionControl alloc] initWithItem: _p_item withView: o_parent_view];
852 return _NS(psz_name);
865 - (char *)stringValue
873 switch(p_item->i_type) {
874 case CONFIG_ITEM_STRING:
875 case CONFIG_ITEM_PASSWORD:
876 case CONFIG_ITEM_LOADFILE:
877 case CONFIG_ITEM_SAVEFILE:
878 case CONFIG_ITEM_DIRECTORY:
879 case CONFIG_ITEM_MODULE:
880 case CONFIG_ITEM_MODULE_LIST:
881 case CONFIG_ITEM_MODULE_LIST_CAT:
882 config_PutPsz(VLCIntf, psz_name, [self stringValue]);
884 case CONFIG_ITEM_KEY:
885 /* So you don't need to restart to have the changes take effect */
886 val.i_int = [self intValue];
887 var_Set(VLCIntf->p_libvlc, psz_name, val);
888 case CONFIG_ITEM_INTEGER:
889 case CONFIG_ITEM_BOOL:
890 config_PutInt(VLCIntf, psz_name, [self intValue]);
892 case CONFIG_ITEM_FLOAT:
893 config_PutFloat(VLCIntf, psz_name, [self floatValue]);
904 return [o_label frame].size.width;
907 - (void) alignWithXPosition:(int)i_xPos;
909 /* FIXME: not implemented atm, but created to shut up the warning
910 * about "method definition not found" -- FK @ 7/24/05 */
914 @implementation StringConfigControl
915 - (id) initWithItem: (module_config_t *)_p_item
916 withView: (NSView *)o_parent_view
918 NSRect mainFrame = [o_parent_view frame];
919 NSString *o_labelString, *o_textfieldString, *o_textfieldTooltip;
920 mainFrame.size.height = 22;
921 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN;
922 mainFrame.origin.x = LEFTMARGIN;
923 mainFrame.origin.y = 0;
925 if ([super initWithFrame: mainFrame item: _p_item] != nil) {
926 if (p_item->i_type == CONFIG_ITEM_PASSWORD)
927 i_view_type = CONFIG_ITEM_PASSWORD;
929 i_view_type = CONFIG_ITEM_STRING;
931 o_textfieldTooltip = [[VLCStringUtility sharedInstance] wrapString: _NS((char *)p_item->psz_longtext) toWidth: PREFS_WRAP];
934 if (p_item->psz_text)
935 o_labelString = _NS((char *)p_item->psz_text);
938 ADD_LABEL(o_label, mainFrame, 0, -3, o_labelString, o_textfieldTooltip)
939 [o_label setAutoresizingMask:NSViewNotSizable ];
940 [self addSubview: o_label];
942 /* build the textfield */
943 if (p_item->value.psz)
944 o_textfieldString = [NSString stringWithCString:p_item->value.psz encoding:NSUTF8StringEncoding];
946 o_textfieldString = @"";
947 if (p_item->i_type == CONFIG_ITEM_PASSWORD) {
948 ADD_SECURETEXTFIELD(o_textfield, mainFrame, [o_label frame].size.width + 2,
949 0, mainFrame.size.width - [o_label frame].size.width -
950 2, o_textfieldTooltip, o_textfieldString)
952 ADD_TEXTFIELD(o_textfield, mainFrame, [o_label frame].size.width + 2,
953 0, mainFrame.size.width - [o_label frame].size.width -
954 2, o_textfieldTooltip, o_textfieldString)
956 [o_textfield setAutoresizingMask:NSViewWidthSizable ];
958 [self addSubview: o_textfield];
963 - (void) alignWithXPosition:(int)i_xPos
966 NSRect superFrame = [self frame];
967 frame = [o_label frame];
968 frame.origin.x = i_xPos - frame.size.width - 3;
969 [o_label setFrame:frame];
971 frame = [o_textfield frame];
972 frame.origin.x = i_xPos + 2;
973 frame.size.width = superFrame.size.width - frame.origin.x - 1;
974 [o_textfield setFrame:frame];
979 [o_textfield release];
983 - (char *)stringValue
985 return strdup([[o_textfield stringValue] UTF8String]);
990 NSString *o_textfieldString;
991 char *psz_value = config_GetPsz(VLCIntf, p_item->psz_name);
993 o_textfieldString = _NS(psz_value);
995 o_textfieldString = @"";
1001 @implementation StringListConfigControl
1002 - (id) initWithItem: (module_config_t *)_p_item
1003 withView: (NSView *)o_parent_view
1005 NSRect mainFrame = [o_parent_view frame];
1006 NSString *o_labelString, *o_textfieldTooltip;
1007 mainFrame.size.height = 22;
1008 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN + 1;
1009 mainFrame.origin.x = LEFTMARGIN;
1010 mainFrame.origin.y = 0;
1012 if ([super initWithFrame: mainFrame item: _p_item] != nil) {
1013 i_view_type = CONFIG_ITEM_STRING_LIST;
1015 o_textfieldTooltip = [[VLCStringUtility sharedInstance] wrapString: _NS(p_item->psz_longtext) toWidth: PREFS_WRAP];
1018 if (p_item->psz_text)
1019 o_labelString = _NS((char *)p_item->psz_text);
1021 o_labelString = @"";
1022 ADD_LABEL(o_label, mainFrame, 0, -3, o_labelString, o_textfieldTooltip)
1023 [o_label setAutoresizingMask:NSViewNotSizable ];
1024 [self addSubview: o_label];
1026 /* build the textfield */
1027 ADD_POPUP(o_popup, mainFrame, [o_label frame].size.width,
1028 -2, 0, o_textfieldTooltip)
1029 [o_popup setAutoresizingMask:NSViewWidthSizable];
1032 for (int i_index = 0; i_index < p_item->list_count; i_index++) {
1034 if (p_item->list_text && p_item->list_text[i_index])
1035 o_text = _NS((char *)p_item->list_text[i_index]);
1037 o_text = _NS((char *)p_item->list.psz[i_index]);
1038 [o_popup addItemWithTitle: o_text];
1040 /* select default item */
1041 if (!p_item->value.psz && !p_item->list.psz[i_index])
1042 [o_popup selectItemAtIndex: i_index];
1043 else if (p_item->value.psz && p_item->list.psz[i_index] &&
1044 !strcmp(p_item->value.psz, p_item->list.psz[i_index]))
1045 [o_popup selectItemAtIndex: i_index];
1048 [self addSubview: o_popup];
1053 - (void) alignWithXPosition:(int)i_xPos
1056 NSRect superFrame = [self frame];
1057 frame = [o_label frame];
1058 frame.origin.x = i_xPos - frame.size.width - 3;
1059 [o_label setFrame:frame];
1061 frame = [o_popup frame];
1062 frame.origin.x = i_xPos + 2;
1063 frame.size.width = superFrame.size.width - frame.origin.x + 2;
1064 [o_popup setFrame:frame];
1073 - (char *)stringValue
1075 if ([o_popup indexOfSelectedItem] >= 0) {
1076 if (p_item->list.psz[[o_popup indexOfSelectedItem]] != NULL)
1077 return strdup(p_item->list.psz[[o_popup indexOfSelectedItem]]);
1085 char *psz_value = config_GetPsz(VLCIntf, p_item->psz_name);
1087 for (int i_index = 0; i_index < p_item->list_count; i_index++) {
1088 if (!psz_value && !p_item->list.psz[i_index])
1089 [o_popup selectItemAtIndex: i_index];
1090 else if (psz_value && p_item->list.psz[i_index] &&
1091 !strcmp(psz_value, p_item->list.psz[i_index]))
1092 [o_popup selectItemAtIndex: i_index];
1096 [super resetValues];
1100 @implementation FileConfigControl
1101 - (id) initWithItem: (module_config_t *)_p_item
1102 withView: (NSView *)o_parent_view
1104 NSRect mainFrame = [o_parent_view frame];
1105 NSString *o_labelString, *o_itemTooltip, *o_textfieldString;
1106 mainFrame.size.height = 46;
1107 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN;
1108 mainFrame.origin.x = LEFTMARGIN;
1109 mainFrame.origin.y = 0;
1111 if ([super initWithFrame: mainFrame item: _p_item] != nil) {
1112 i_view_type = CONFIG_ITEM_LOADFILE;
1114 o_itemTooltip = [[VLCStringUtility sharedInstance] wrapString: _NS((char *)p_item->psz_longtext) toWidth: PREFS_WRAP];
1116 /* is it a directory */
1117 b_directory = ([self type] == CONFIG_ITEM_DIRECTORY) ? YES : NO;
1120 if (p_item->psz_text)
1121 o_labelString = _NS((char *)p_item->psz_text);
1123 o_labelString = @"";
1124 ADD_LABEL(o_label, mainFrame, 0, 3, o_labelString, o_itemTooltip)
1125 [o_label setAutoresizingMask:NSViewNotSizable ];
1126 [self addSubview: o_label];
1128 /* build the button */
1129 ADD_RIGHT_BUTTON(o_button, mainFrame, 0, 0, o_itemTooltip,
1131 [o_button setAutoresizingMask:NSViewMinXMargin ];
1132 [self addSubview: o_button];
1134 /* build the textfield */
1135 if (p_item->value.psz)
1136 o_textfieldString = [NSString stringWithFormat: @"%s", (char *)p_item->value.psz];
1138 o_textfieldString = @"";
1139 ADD_TEXTFIELD(o_textfield, mainFrame, 12, 2, mainFrame.size.width -
1140 8 - [o_button frame].size.width,
1141 o_itemTooltip, o_textfieldString)
1142 [o_textfield setAutoresizingMask:NSViewWidthSizable ];
1143 [self addSubview: o_textfield];
1148 - (void) alignWithXPosition:(int)i_xPos
1155 [o_textfield release];
1160 - (IBAction)openFileDialog: (id)sender
1162 NSOpenPanel *o_open_panel = [NSOpenPanel openPanel];
1164 [o_open_panel setTitle: (b_directory)?
1165 _NS("Select a directory"):_NS("Select a file")];
1166 [o_open_panel setPrompt: _NS("Select")];
1167 [o_open_panel setAllowsMultipleSelection: NO];
1168 [o_open_panel setCanChooseFiles: !b_directory];
1169 [o_open_panel setCanChooseDirectories: b_directory];
1170 [o_open_panel beginSheetModalForWindow:[sender window] completionHandler:^(NSInteger returnCode) {
1171 if (returnCode == NSOKButton) {
1172 NSString *o_path = [[[o_open_panel URLs] objectAtIndex: 0] path];
1173 [o_textfield setStringValue: o_path];
1178 - (char *)stringValue
1180 if ([[o_textfield stringValue] length] != 0)
1181 return strdup([[o_textfield stringValue] fileSystemRepresentation]);
1188 NSString *o_textfieldString;
1189 char *psz_value = config_GetPsz(VLCIntf, p_item->psz_name);
1191 o_textfieldString = [NSString stringWithFormat: @"%s", psz_value];
1193 o_textfieldString = @"";
1196 [super resetValues];
1200 @implementation ModuleConfigControl
1201 - (id) initWithItem: (module_config_t *)_p_item
1202 withView: (NSView *)o_parent_view
1204 NSRect mainFrame = [o_parent_view frame];
1205 NSString *o_labelString, *o_popupTooltip;
1206 mainFrame.size.height = 22;
1207 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN + 1;
1208 mainFrame.origin.x = LEFTMARGIN;
1209 mainFrame.origin.y = 0;
1211 if ([super initWithFrame: mainFrame item: _p_item] != nil) {
1212 i_view_type = CONFIG_ITEM_MODULE;
1214 o_popupTooltip = [[VLCStringUtility sharedInstance] wrapString: _NS((char *)p_item->psz_longtext) toWidth: PREFS_WRAP];
1217 if (p_item->psz_text)
1218 o_labelString = _NS((char *)p_item->psz_text);
1220 o_labelString = @"";
1222 ADD_LABEL(o_label, mainFrame, 0, -1, o_labelString, o_popupTooltip)
1223 [o_label setAutoresizingMask:NSViewNotSizable ];
1224 [self addSubview: o_label];
1226 /* build the popup */
1227 ADD_POPUP(o_popup, mainFrame, [o_label frame].size.width,
1228 -2, 0, o_popupTooltip)
1229 [o_popup setAutoresizingMask:NSViewWidthSizable ];
1230 [o_popup addItemWithTitle: _NS("Default")];
1231 [[o_popup lastItem] setTag: -1];
1232 [o_popup selectItem: [o_popup lastItem]];
1235 [self addSubview: o_popup];
1240 - (void) alignWithXPosition:(int)i_xPos
1243 NSRect superFrame = [self frame];
1244 frame = [o_label frame];
1245 frame.origin.x = i_xPos - frame.size.width - 3;
1246 [o_label setFrame:frame];
1248 frame = [o_popup frame];
1249 frame.origin.x = i_xPos - 1;
1250 frame.size.width = superFrame.size.width - frame.origin.x + 2;
1251 [o_popup setFrame:frame];
1260 - (char *)stringValue
1262 NSString *newval = [o_popup titleOfSelectedItem];
1263 char *returnval = NULL;
1264 size_t i_module_index;
1265 module_t *p_parser, **p_list;
1268 p_list = module_list_get(&count);
1269 for (i_module_index = 0; i_module_index < count; i_module_index++) {
1270 p_parser = p_list[i_module_index];
1272 if (p_item->i_type == CONFIG_ITEM_MODULE) {
1273 if (module_provides(p_parser, p_item->psz_type)) {
1274 NSString *o_description = _NS(module_get_name(p_parser, TRUE));
1275 if ([newval isEqualToString: o_description]) {
1276 returnval = strdup(module_get_object(p_parser));
1281 if (module_is_main(p_parser))
1284 unsigned int confsize;
1285 module_config_t *p_config = module_config_get(p_parser, &confsize);
1286 for (size_t i = 0; i < confsize; i++) {
1287 module_config_t *p_cfg = p_config + i;
1288 /* Hack: required subcategory is stored in i_min */
1289 if (p_cfg->i_type == CONFIG_SUBCATEGORY &&
1290 p_cfg->value.i == p_cfg->min.i) {
1291 NSString *o_description = _NS(module_get_name(p_parser, TRUE));
1292 if ([newval isEqualToString: o_description]) {
1293 returnval = strdup(module_get_object(p_parser));
1298 module_config_free(p_config);
1301 module_list_free(p_list);
1307 /* build a list of available modules */
1308 module_t *p_parser, **p_list;
1311 p_list = module_list_get(&count);
1312 for (size_t i_index = 0; i_index < count; i_index++) {
1313 p_parser = p_list[i_index];
1315 if (p_item->i_type == CONFIG_ITEM_MODULE) {
1316 if (module_provides(p_parser, p_item->psz_type)) {
1317 NSString *o_description = _NS(module_get_name(p_parser, TRUE));
1318 [o_popup addItemWithTitle: o_description];
1319 char *psz_value = config_GetPsz(VLCIntf, p_item->psz_name);
1322 !strcmp(psz_value, module_get_object(p_parser)))
1323 [o_popup selectItem:[o_popup lastItem]];
1328 if (module_is_main(p_parser))
1330 unsigned int confsize;
1332 module_config_t *p_configlist = module_config_get(p_parser, &confsize);
1333 for (size_t i = 0; i < confsize; i++) {
1334 module_config_t *p_config = &p_configlist[i];
1335 /* Hack: required subcategory is stored in i_min */
1336 if (p_config->i_type == CONFIG_SUBCATEGORY &&
1337 p_config->value.i == p_item->min.i) {
1338 NSString *o_description = _NS(module_get_name(p_parser, TRUE));
1339 [o_popup addItemWithTitle: o_description];
1341 if (p_item->value.psz && !strcmp(p_item->value.psz,
1342 module_get_object(p_parser)))
1343 [o_popup selectItem:[o_popup lastItem]];
1346 module_config_free(p_configlist);
1349 module_list_free(p_list);
1350 [super resetValues];
1354 @implementation IntegerConfigControl
1355 - (id) initWithItem: (module_config_t *)_p_item
1356 withView: (NSView *)o_parent_view
1358 NSRect mainFrame = [o_parent_view frame];
1359 NSString *o_labelString, *o_tooltip;
1360 mainFrame.size.height = 23;
1361 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN + 1;
1362 mainFrame.origin.x = LEFTMARGIN;
1363 mainFrame.origin.y = 0;
1365 if ([super initWithFrame: mainFrame item: _p_item] != nil) {
1366 i_view_type = CONFIG_ITEM_INTEGER;
1368 o_tooltip = [[VLCStringUtility sharedInstance] wrapString: _NS((char *)p_item->psz_longtext) toWidth: PREFS_WRAP];
1371 if (p_item->psz_text)
1372 o_labelString = _NS((char *)p_item->psz_text);
1374 o_labelString = @"";
1375 ADD_LABEL(o_label, mainFrame, 0, -3, o_labelString, o_tooltip)
1376 [o_label setAutoresizingMask:NSViewNotSizable ];
1377 [self addSubview: o_label];
1379 /* build the stepper */
1380 ADD_STEPPER(o_stepper, mainFrame, mainFrame.size.width - 19,
1381 0, o_tooltip, -100000, 100000)
1382 [o_stepper setIntValue: p_item->value.i];
1383 [o_stepper setAutoresizingMask:NSViewMaxXMargin ];
1384 [self addSubview: o_stepper];
1386 ADD_TEXTFIELD(o_textfield, mainFrame, mainFrame.size.width - 19 - 52,
1387 1, 49, o_tooltip, @"")
1388 [o_textfield setIntValue: p_item->value.i];
1389 [o_textfield setDelegate: self];
1390 [[NSNotificationCenter defaultCenter] addObserver: self
1391 selector: @selector(textfieldChanged:)
1392 name: NSControlTextDidChangeNotification
1393 object: o_textfield];
1394 [o_textfield setAutoresizingMask:NSViewMaxXMargin ];
1395 [self addSubview: o_textfield];
1400 - (void) alignWithXPosition:(int)i_xPos
1403 frame = [o_label frame];
1404 frame.origin.x = i_xPos - frame.size.width - 3;
1405 [o_label setFrame:frame];
1407 frame = [o_textfield frame];
1408 frame.origin.x = i_xPos + 2;
1409 [o_textfield setFrame:frame];
1411 frame = [o_stepper frame];
1412 frame.origin.x = i_xPos + [o_textfield frame].size.width + 5;
1413 [o_stepper setFrame:frame];
1418 [o_stepper release];
1419 [o_textfield release];
1423 - (IBAction)stepperChanged:(id)sender
1425 [o_textfield setIntValue: [o_stepper intValue]];
1428 - (void)textfieldChanged:(NSNotification *)o_notification
1430 [o_stepper setIntValue: [o_textfield intValue]];
1435 return [o_textfield intValue];
1440 [o_textfield setIntValue: config_GetInt(VLCIntf, p_item->psz_name)];
1441 [super resetValues];
1446 @implementation IntegerListConfigControl
1448 - (id) initWithItem: (module_config_t *)_p_item
1449 withView: (NSView *)o_parent_view
1451 NSRect mainFrame = [o_parent_view frame];
1452 NSString *o_labelString, *o_textfieldTooltip;
1453 mainFrame.size.height = 22;
1454 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN + 1;
1455 mainFrame.origin.x = LEFTMARGIN;
1456 mainFrame.origin.y = 0;
1458 if ([super initWithFrame: mainFrame item: _p_item] != nil) {
1459 i_view_type = CONFIG_ITEM_STRING_LIST;
1461 o_textfieldTooltip = [[VLCStringUtility sharedInstance] wrapString: _NS((char *)p_item->psz_longtext) toWidth: PREFS_WRAP];
1464 if (p_item->psz_text)
1465 o_labelString = _NS((char *)p_item->psz_text);
1467 o_labelString = @"";
1468 ADD_LABEL(o_label, mainFrame, 0, -3, o_labelString, o_textfieldTooltip)
1469 [o_label setAutoresizingMask:NSViewNotSizable ];
1470 [self addSubview: o_label];
1472 /* build the textfield */
1473 ADD_POPUP(o_popup, mainFrame, [o_label frame].size.width,
1474 -2, 0, o_textfieldTooltip)
1475 [o_popup setAutoresizingMask:NSViewWidthSizable ];
1478 for (int i_index = 0; i_index < p_item->list_count; i_index++) {
1480 if (p_item->list_text && p_item->list_text[i_index])
1481 o_text = _NS((char *)p_item->list_text[i_index]);
1483 o_text = [NSString stringWithFormat: @"%i", p_item->list.i[i_index]];
1484 [o_popup addItemWithTitle: o_text];
1486 if (p_item->value.i == p_item->list.i[i_index])
1487 [o_popup selectItemAtIndex: i_index];
1490 [self addSubview: o_popup];
1495 - (void) alignWithXPosition:(int)i_xPos
1498 NSRect superFrame = [self frame];
1499 frame = [o_label frame];
1500 frame.origin.x = i_xPos - frame.size.width - 3;
1501 [o_label setFrame:frame];
1503 frame = [o_popup frame];
1504 frame.origin.x = i_xPos + 2;
1505 frame.size.width = superFrame.size.width - frame.origin.x + 2;
1506 [o_popup setFrame:frame];
1517 if ([o_popup indexOfSelectedItem] >= 0)
1518 return p_item->list.i[[o_popup indexOfSelectedItem]];
1520 return [o_popup intValue];
1525 for (int i_index = 0; i_index < p_item->list_count; i_index++) {
1526 if (config_GetInt(VLCIntf, p_item->psz_name) == p_item->list.i[i_index])
1527 [o_popup selectItemAtIndex: i_index];
1533 @implementation RangedIntegerConfigControl
1534 - (id) initWithItem: (module_config_t *)_p_item
1535 withView: (NSView *)o_parent_view
1537 NSRect mainFrame = [o_parent_view frame];
1538 NSString *o_labelString, *o_tooltip;
1539 mainFrame.size.height = 50;
1540 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN;
1541 mainFrame.origin.x = LEFTMARGIN;
1542 mainFrame.origin.y = 0;
1544 if ([super initWithFrame: mainFrame item: _p_item] != nil) {
1545 i_view_type = CONFIG_ITEM_RANGED_INTEGER;
1547 o_tooltip = [[VLCStringUtility sharedInstance] wrapString: _NS((char *)p_item->psz_longtext) toWidth: PREFS_WRAP];
1550 if (p_item->psz_text)
1551 o_labelString = _NS((char *)p_item->psz_text);
1553 o_labelString = @"";
1554 ADD_LABEL(o_label, mainFrame, 0, -3, o_labelString, o_tooltip)
1555 [o_label setAutoresizingMask:NSViewNotSizable ];
1556 [self addSubview: o_label];
1558 /* build the textfield */
1559 ADD_TEXTFIELD(o_textfield, mainFrame, [o_label frame].size.width + 2,
1560 28, 49, o_tooltip, @"")
1561 [o_textfield setIntValue: p_item->value.i];
1562 [o_textfield setAutoresizingMask:NSViewMaxXMargin ];
1563 [o_textfield setDelegate: self];
1564 [[NSNotificationCenter defaultCenter] addObserver: self
1565 selector: @selector(textfieldChanged:)
1566 name: NSControlTextDidChangeNotification
1567 object: o_textfield];
1568 [self addSubview: o_textfield];
1570 /* build the mintextfield */
1571 ADD_LABEL(o_textfield_min, mainFrame, 12, -30, @"-8888", @"")
1572 [o_textfield_min setIntValue: p_item->min.i];
1573 [o_textfield_min setAutoresizingMask:NSViewMaxXMargin ];
1574 [o_textfield_min setAlignment:NSRightTextAlignment];
1575 [self addSubview: o_textfield_min];
1577 /* build the maxtextfield */
1578 ADD_LABEL(o_textfield_max, mainFrame,
1579 mainFrame.size.width - 31, -30, @"8888", @"")
1580 [o_textfield_max setIntValue: p_item->max.i];
1581 [o_textfield_max setAutoresizingMask:NSViewMinXMargin ];
1582 [self addSubview: o_textfield_max];
1584 /* build the slider */
1585 ADD_SLIDER(o_slider, mainFrame, [o_textfield_min frame].origin.x +
1586 [o_textfield_min frame].size.width + 6, -1, mainFrame.size.width -
1587 [o_textfield_max frame].size.width -
1588 [o_textfield_max frame].size.width - 14 -
1589 [o_textfield_min frame].origin.x, o_tooltip,
1590 p_item->min.i, p_item->max.i)
1591 [o_slider setIntValue: p_item->value.i];
1592 [o_slider setAutoresizingMask:NSViewWidthSizable ];
1593 [o_slider setTarget: self];
1594 [o_slider setAction: @selector(sliderChanged:)];
1595 [o_slider sendActionOn:NSLeftMouseUpMask | NSLeftMouseDownMask |
1596 NSLeftMouseDraggedMask];
1597 [self addSubview: o_slider];
1603 - (void) alignWithXPosition:(int)i_xPos
1606 frame = [o_label frame];
1607 frame.origin.x = i_xPos - frame.size.width - 3;
1608 [o_label setFrame:frame];
1610 frame = [o_textfield frame];
1611 frame.origin.x = i_xPos + 2;
1612 [o_textfield setFrame:frame];
1617 [o_textfield release];
1618 [o_textfield_min release];
1619 [o_textfield_max release];
1624 - (IBAction)sliderChanged:(id)sender
1626 [o_textfield setIntValue: [o_slider intValue]];
1629 - (void)textfieldChanged:(NSNotification *)o_notification
1631 [o_slider setIntValue: [o_textfield intValue]];
1636 return [o_slider intValue];
1641 int value = config_GetInt(VLCIntf, p_item->psz_name);
1642 [o_textfield setIntValue:value];
1643 [o_slider setIntValue:value];
1644 [super resetValues];
1648 @implementation FloatConfigControl
1649 - (id) initWithItem: (module_config_t *)_p_item
1650 withView: (NSView *)o_parent_view
1652 NSRect mainFrame = [o_parent_view frame];
1653 NSString *o_labelString, *o_tooltip;
1654 mainFrame.size.height = 23;
1655 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN + 1;
1656 mainFrame.origin.x = LEFTMARGIN;
1657 mainFrame.origin.y = 0;
1659 if ([super initWithFrame: mainFrame item: _p_item] != nil) {
1660 i_view_type = CONFIG_ITEM_INTEGER;
1662 o_tooltip = [[VLCStringUtility sharedInstance] wrapString: _NS((char *)p_item->psz_longtext) toWidth: PREFS_WRAP];
1665 if (p_item->psz_text)
1666 o_labelString = _NS((char *)p_item->psz_text);
1668 o_labelString = @"";
1669 ADD_LABEL(o_label, mainFrame, 0, -2, o_labelString, o_tooltip)
1670 [o_label setAutoresizingMask:NSViewNotSizable ];
1671 [self addSubview: o_label];
1673 /* build the stepper */
1674 ADD_STEPPER(o_stepper, mainFrame, mainFrame.size.width - 19,
1675 0, o_tooltip, -100000, 100000)
1676 [o_stepper setFloatValue: p_item->value.f];
1677 [o_stepper setAutoresizingMask:NSViewMaxXMargin ];
1678 [self addSubview: o_stepper];
1680 /* build the textfield */
1681 ADD_TEXTFIELD(o_textfield, mainFrame, mainFrame.size.width - 19 - 52,
1682 1, 49, o_tooltip, @"")
1683 [o_textfield setFloatValue: p_item->value.f];
1684 [o_textfield setDelegate: self];
1685 [[NSNotificationCenter defaultCenter] addObserver: self
1686 selector: @selector(textfieldChanged:)
1687 name: NSControlTextDidChangeNotification
1688 object: o_textfield];
1689 [o_textfield setAutoresizingMask:NSViewMaxXMargin ];
1690 [self addSubview: o_textfield];
1695 - (void) alignWithXPosition:(int)i_xPos
1698 frame = [o_label frame];
1699 frame.origin.x = i_xPos - frame.size.width - 3;
1700 [o_label setFrame:frame];
1702 frame = [o_textfield frame];
1703 frame.origin.x = i_xPos + 2;
1704 [o_textfield setFrame:frame];
1706 frame = [o_stepper frame];
1707 frame.origin.x = i_xPos + [o_textfield frame].size.width + 5;
1708 [o_stepper setFrame:frame];
1713 [o_stepper release];
1714 [o_textfield release];
1718 - (IBAction)stepperChanged:(id)sender
1720 [o_textfield setFloatValue: [o_stepper floatValue]];
1723 - (void)textfieldChanged:(NSNotification *)o_notification
1725 [o_stepper setFloatValue: [o_textfield floatValue]];
1730 return [o_stepper floatValue];
1735 [o_textfield setFloatValue: config_GetFloat(VLCIntf, p_item->psz_name)];
1736 [super resetValues];
1740 @implementation RangedFloatConfigControl
1741 - (id) initWithItem: (module_config_t *)_p_item
1742 withView: (NSView *)o_parent_view
1744 NSRect mainFrame = [o_parent_view frame];
1745 NSString *o_labelString, *o_tooltip;
1746 mainFrame.size.height = 50;
1747 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN;
1748 mainFrame.origin.x = LEFTMARGIN;
1749 mainFrame.origin.y = 0;
1751 if ([super initWithFrame: mainFrame item: _p_item] != nil) {
1752 i_view_type = CONFIG_ITEM_RANGED_INTEGER;
1754 o_tooltip = [[VLCStringUtility sharedInstance] wrapString: _NS((char *)p_item->psz_longtext) toWidth: PREFS_WRAP];
1757 if (p_item->psz_text)
1758 o_labelString = _NS((char *)p_item->psz_text);
1760 o_labelString = @"";
1761 ADD_LABEL(o_label, mainFrame, 0, -3, o_labelString, o_tooltip)
1762 [o_label setAutoresizingMask:NSViewNotSizable ];
1763 [self addSubview: o_label];
1765 /* build the textfield */
1766 ADD_TEXTFIELD(o_textfield, mainFrame, [o_label frame].size.width + 2,
1767 28, 49, o_tooltip, @"")
1768 [o_textfield setFloatValue: p_item->value.f];
1769 [o_textfield setAutoresizingMask:NSViewMaxXMargin ];
1770 [o_textfield setDelegate: self];
1771 [[NSNotificationCenter defaultCenter] addObserver: self
1772 selector: @selector(textfieldChanged:)
1773 name: NSControlTextDidChangeNotification
1774 object: o_textfield];
1775 [self addSubview: o_textfield];
1777 /* build the mintextfield */
1778 ADD_LABEL(o_textfield_min, mainFrame, 12, -30, @"-8888", @"")
1779 [o_textfield_min setFloatValue: p_item->min.f];
1780 [o_textfield_min setAutoresizingMask:NSViewMaxXMargin ];
1781 [o_textfield_min setAlignment:NSRightTextAlignment];
1782 [self addSubview: o_textfield_min];
1784 /* build the maxtextfield */
1785 ADD_LABEL(o_textfield_max, mainFrame, mainFrame.size.width - 31,
1787 [o_textfield_max setFloatValue: p_item->max.f];
1788 [o_textfield_max setAutoresizingMask:NSViewMinXMargin ];
1789 [self addSubview: o_textfield_max];
1791 /* build the slider */
1792 ADD_SLIDER(o_slider, mainFrame, [o_textfield_min frame].origin.x +
1793 [o_textfield_min frame].size.width + 6, -1, mainFrame.size.width -
1794 [o_textfield_max frame].size.width -
1795 [o_textfield_max frame].size.width - 14 -
1796 [o_textfield_min frame].origin.x, o_tooltip, p_item->min.f,
1798 [o_slider setFloatValue: p_item->value.f];
1799 [o_slider setAutoresizingMask:NSViewWidthSizable ];
1800 [o_slider setTarget: self];
1801 [o_slider setAction: @selector(sliderChanged:)];
1802 [o_slider sendActionOn:NSLeftMouseUpMask | NSLeftMouseDownMask |
1803 NSLeftMouseDraggedMask];
1804 [self addSubview: o_slider];
1810 - (void) alignWithXPosition:(int)i_xPos
1813 frame = [o_label frame];
1814 frame.origin.x = i_xPos - frame.size.width - 3;
1815 [o_label setFrame:frame];
1817 frame = [o_textfield frame];
1818 frame.origin.x = i_xPos + 2;
1819 [o_textfield setFrame:frame];
1824 [o_textfield release];
1825 [o_textfield_min release];
1826 [o_textfield_max release];
1831 - (IBAction)sliderChanged:(id)sender
1833 [o_textfield setFloatValue: [o_slider floatValue]];
1836 - (void)textfieldChanged:(NSNotification *)o_notification
1838 [o_slider setFloatValue: [o_textfield floatValue]];
1843 return [o_slider floatValue];
1848 [o_textfield setFloatValue: config_GetFloat(VLCIntf, p_item->psz_name)];
1849 [o_slider setFloatValue: config_GetFloat(VLCIntf, p_item->psz_name)];
1850 [super resetValues];
1854 @implementation BoolConfigControl
1856 - (id) initWithItem: (module_config_t *)_p_item
1857 withView: (NSView *)o_parent_view
1859 NSRect mainFrame = [o_parent_view frame];
1860 NSString *o_labelString, *o_tooltip;
1861 mainFrame.size.height = 17;
1862 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN;
1863 mainFrame.origin.x = LEFTMARGIN;
1864 mainFrame.origin.y = 0;
1866 if ([super initWithFrame: mainFrame item: _p_item] != nil) {
1867 i_view_type = CONFIG_ITEM_BOOL;
1869 if (p_item->psz_text)
1870 o_labelString = _NS((char *)p_item->psz_text);
1872 o_labelString = @"";
1874 o_tooltip = [[VLCStringUtility sharedInstance] wrapString: _NS((char *)p_item->psz_longtext) toWidth: PREFS_WRAP];
1876 /* add the checkbox */
1877 ADD_CHECKBOX(o_checkbox, mainFrame, 0,
1878 0, o_labelString, o_tooltip, p_item->value.i, NSImageLeft)
1879 [o_checkbox setAutoresizingMask:NSViewNotSizable ];
1880 [self addSubview: o_checkbox];
1887 [o_checkbox release];
1893 return [o_checkbox intValue];
1898 [o_checkbox setState: config_GetInt(VLCIntf, p_item->psz_name)];
1899 [super resetValues];
1903 @implementation KeyConfigControl
1904 - (id) initWithItem: (module_config_t *)_p_item
1905 withView: (NSView *)o_parent_view
1907 NSRect mainFrame = [o_parent_view frame];
1908 NSString *o_labelString, *o_tooltip;
1909 mainFrame.size.height = 22;
1910 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN + 1;
1911 mainFrame.origin.x = LEFTMARGIN;
1912 mainFrame.origin.y = 0;
1914 if ([super initWithFrame: mainFrame item: _p_item] != nil) {
1915 i_view_type = CONFIG_ITEM_KEY;
1917 o_tooltip = [[VLCStringUtility sharedInstance] wrapString: _NS((char *)p_item->psz_longtext) toWidth: PREFS_WRAP];
1920 if (p_item->psz_text)
1921 o_labelString = _NS((char *)p_item->psz_text);
1923 o_labelString = @"";
1924 ADD_LABEL(o_label, mainFrame, 0, -1, o_labelString, o_tooltip)
1925 [o_label setAutoresizingMask:NSViewNotSizable ];
1926 [self addSubview: o_label];
1928 /* build the popup */
1929 ADD_POPUP(o_popup, mainFrame, [o_label frame].origin.x +
1930 [o_label frame].size.width + 3,
1932 [o_popup setAutoresizingMask:NSViewWidthSizable ];
1934 if (o_keys_menu == nil) {
1936 o_keys_menu = [[NSMenu alloc] initWithTitle: @"Keys Menu"];
1937 #warning This does not work anymore. FIXME.
1939 for (i = 0; i < sizeof(vlc_key) / sizeof(key_descriptor_t); i++)
1940 if (vlc_key[i].psz_key_string)
1941 POPULATE_A_KEY(o_keys_menu,
1942 [NSString stringWithUTF8String:vlc_key[i].psz_key_string]
1943 , vlc_key[i].i_key_code)
1946 [o_popup setMenu:[o_keys_menu copyWithZone:nil]];
1947 [o_popup selectItem:[[o_popup menu] itemWithTag:p_item->value.i]];
1948 [self addSubview: o_popup];
1954 - (void) alignWithXPosition:(int)i_xPos
1957 NSRect superFrame = [self frame];
1958 frame = [o_label frame];
1959 frame.origin.x = i_xPos - frame.size.width - 3;
1960 [o_label setFrame:frame];
1962 frame = [o_popup frame];
1963 frame.origin.x = i_xPos - 1;
1964 frame.size.width = superFrame.size.width - frame.origin.x + 2;
1965 [o_popup setFrame:frame];
1976 return [o_popup selectedTag];
1981 [o_popup selectItem:[[o_popup menu] itemWithTag:config_GetInt(VLCIntf, p_item->psz_name)]];
1982 [super resetValues];
1986 @implementation ModuleListConfigControl
1987 - (id) initWithItem: (module_config_t *)_p_item
1988 withView: (NSView *)o_parent_view
1990 if (_p_item->i_type == CONFIG_ITEM_MODULE_LIST)
1994 //Fill our array to know how may items we have...
1995 module_t *p_parser, **p_list;
1996 size_t i_module_index;
1997 NSRect mainFrame = [o_parent_view frame];
1998 NSString *o_labelString, *o_textfieldString, *o_tooltip;
2000 o_modulearray = [[NSMutableArray alloc] initWithCapacity:10];
2001 /* build a list of available modules */
2003 p_list = module_list_get(&count);
2004 for (i_module_index = 0; i_module_index < count; i_module_index++) {
2006 p_parser = p_list[i_module_index];
2008 if (module_is_main(p_parser))
2011 unsigned int confsize;
2012 module_config_t *p_configlist = module_config_get(p_parser, &confsize);
2014 for (i = 0; i < confsize; i++) {
2015 unsigned int unused;
2016 module_config_t *p_config = &p_configlist[i];
2017 NSString *o_modulelongname, *o_modulename;
2018 NSNumber *o_moduleenabled = nil;
2020 /* Hack: required subcategory is stored in i_min */
2021 if (p_config->i_type == CONFIG_SUBCATEGORY &&
2022 p_config->value.i == _p_item->min.i) {
2023 o_modulelongname = [NSString stringWithUTF8String:
2024 module_get_name(p_parser, TRUE)];
2025 o_modulename = [NSString stringWithUTF8String:
2026 module_get_object(p_parser)];
2028 if (_p_item->value.psz &&
2029 strstr(_p_item->value.psz, module_get_object(p_parser)))
2030 o_moduleenabled = [NSNumber numberWithBool:YES];
2032 o_moduleenabled = [NSNumber numberWithBool:NO];
2034 [o_modulearray addObject:[NSMutableArray
2035 arrayWithObjects: o_modulename, o_modulelongname,
2036 o_moduleenabled, nil]];
2039 /* Parental Advisory HACK:
2040 * Selecting HTTP, RC and Telnet interfaces is difficult now
2041 * since they are just the lua interface module */
2042 if (p_config->i_type == CONFIG_SUBCATEGORY &&
2043 !strcmp(module_get_object(p_parser), "lua") &&
2044 !strcmp(_p_item->psz_name, "extraintf") &&
2045 p_config->value.i == _p_item->min.i) {
2047 #define addLuaIntf(shortname, longname) \
2048 if (_p_item->value.psz && strstr(_p_item->value.psz, shortname))\
2049 o_moduleenabled = [NSNumber numberWithBool:YES];\
2051 o_moduleenabled = [NSNumber numberWithBool:NO];\
2052 [o_modulearray addObject:[NSMutableArray arrayWithObjects: @shortname, _NS(longname), o_moduleenabled, nil]]
2054 addLuaIntf("http", "Web");
2055 addLuaIntf("telnet", "Telnet");
2056 addLuaIntf("cli", "Console");
2061 module_config_free(p_configlist);
2063 module_list_free(p_list);
2065 mainFrame.size.height = 30 + 20 * [o_modulearray count];
2066 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN;
2067 mainFrame.origin.x = LEFTMARGIN;
2068 mainFrame.origin.y = 0;
2069 if ([super initWithFrame: mainFrame item: _p_item] != nil) {
2070 i_view_type = CONFIG_ITEM_MODULE_LIST;
2072 o_tooltip = [[VLCStringUtility sharedInstance] wrapString: _NS((char *)p_item->psz_longtext) toWidth: PREFS_WRAP];
2075 if (p_item->psz_text)
2076 o_labelString = _NS((char *)p_item->psz_text);
2078 o_labelString = @"";
2079 ADD_LABEL(o_label, mainFrame, 0, -3, o_labelString, o_tooltip)
2080 [o_label setAutoresizingMask:NSViewNotSizable ];
2081 [self addSubview: o_label];
2083 /* build the textfield */
2084 if (p_item->value.psz)
2085 o_textfieldString = _NS((char *)p_item->value.psz);
2087 o_textfieldString = @"";
2088 ADD_TEXTFIELD(o_textfield, mainFrame, [o_label frame].size.width + 2,
2089 mainFrame.size.height - 22, mainFrame.size.width -
2090 [o_label frame].size.width - 2, o_tooltip, o_textfieldString)
2091 [o_textfield setAutoresizingMask:NSViewWidthSizable ];
2092 [self addSubview: o_textfield];
2096 NSRect s_rc = mainFrame;
2097 s_rc.size.height = mainFrame.size.height - 30;
2098 s_rc.size.width = mainFrame.size.width - 12;
2101 o_scrollview = [[[NSScrollView alloc] initWithFrame: s_rc] retain];
2102 [o_scrollview setDrawsBackground: NO];
2103 [o_scrollview setBorderType: NSBezelBorder];
2104 [o_scrollview setAutohidesScrollers:YES];
2106 NSTableView *o_tableview;
2107 o_tableview = [[NSTableView alloc] initWithFrame : s_rc];
2108 [o_tableview setUsesAlternatingRowBackgroundColors:YES];
2109 [o_tableview setHeaderView:nil];
2110 /* TODO: find a good way to fix the row height and text size*/
2111 /* FIXME: support for multiple selection... */
2112 // [o_tableview setAllowsMultipleSelection:YES];
2114 NSCell *o_headerCell = [[NSCell alloc] initTextCell:@"Enabled"];
2115 NSCell *o_dataCell = [[NSButtonCell alloc] init];
2116 [(NSButtonCell*)o_dataCell setButtonType:NSSwitchButton];
2117 [o_dataCell setTitle:@""];
2118 [o_dataCell setFont:[NSFont systemFontOfSize:0]];
2119 NSTableColumn *o_tableColumn = [[NSTableColumn alloc]
2120 initWithIdentifier:@"Enabled"];
2121 [o_tableColumn setHeaderCell: o_headerCell];
2122 [o_tableColumn setDataCell: o_dataCell];
2123 [o_tableColumn setWidth:17];
2124 [o_tableview addTableColumn: o_tableColumn];
2126 o_headerCell = [[NSCell alloc] initTextCell:@"Module Name"];
2127 o_dataCell = [[NSTextFieldCell alloc] init];
2128 [o_dataCell setFont:[NSFont systemFontOfSize:12]];
2129 o_tableColumn = [[NSTableColumn alloc]
2130 initWithIdentifier:@"Module"];
2131 [o_tableColumn setHeaderCell: o_headerCell];
2132 [o_tableColumn setDataCell: o_dataCell];
2133 [o_tableColumn setWidth:s_rc.size.width - 34];
2134 [o_tableview addTableColumn: o_tableColumn];
2135 [o_tableview registerForDraggedTypes:@[@"VLC media player module"]];
2137 [o_tableview setDataSource:self];
2138 [o_tableview setTarget: self];
2139 [o_tableview setAction: @selector(tableChanged:)];
2140 [o_tableview sendActionOn:NSLeftMouseUpMask | NSLeftMouseDownMask |
2141 NSLeftMouseDraggedMask];
2142 [o_scrollview setDocumentView: o_tableview];
2144 [o_scrollview setAutoresizingMask:NSViewWidthSizable ];
2145 [o_scrollview setAutohidesScrollers:YES];
2146 [self addSubview: o_scrollview];
2152 - (void) alignWithXPosition:(int)i_xPos
2157 - (IBAction)tableChanged:(id)sender
2159 NSString *o_newstring = @"";
2160 NSUInteger count = [o_modulearray count];
2161 for (NSUInteger i = 0 ; i < count ; i++)
2162 if ([[[o_modulearray objectAtIndex:i] objectAtIndex:2]
2164 o_newstring = [o_newstring stringByAppendingString:
2165 [[o_modulearray objectAtIndex:i] objectAtIndex:0]];
2166 o_newstring = [o_newstring stringByAppendingString:@":"];
2169 [o_textfield setStringValue: [o_newstring
2170 substringToIndex: ([o_newstring length])?[o_newstring length] - 1:0]];
2175 [o_scrollview release];
2180 - (char *)stringValue
2182 return strdup([[o_textfield stringValue] UTF8String]);
2187 #warning Reset prefs of the module selector is broken atm.
2188 msg_Err(VLCIntf, "don't forget about modulelistconfig");
2189 [super resetValues];
2194 @implementation ModuleListConfigControl (NSTableDataSource)
2196 - (BOOL)tableView:(NSTableView*)table writeRows:(NSArray*)rows
2197 toPasteboard:(NSPasteboard*)pb
2199 // We only want to allow dragging of selected rows.
2200 NSEnumerator *iter = [rows objectEnumerator];
2202 while ((row = [iter nextObject]) != nil) {
2203 if (![table isRowSelected:[row intValue]])
2207 [pb declareTypes:@[@"VLC media player module"] owner:nil];
2208 [pb setPropertyList:rows forType:@"VLC media player module"];
2212 - (NSDragOperation)tableView:(NSTableView*)table
2213 validateDrop:(id <NSDraggingInfo>)info proposedRow:(NSInteger)row
2214 proposedDropOperation:(NSTableViewDropOperation)op
2216 // Make drops at the end of the table go to the end.
2218 row = [table numberOfRows];
2219 op = NSTableViewDropAbove;
2220 [table setDropRow:row dropOperation:op];
2223 // We don't ever want to drop onto a row, only between rows.
2224 if (op == NSTableViewDropOn)
2225 [table setDropRow:(row+1) dropOperation:NSTableViewDropAbove];
2226 return NSTableViewDropAbove;
2229 - (BOOL)tableView:(NSTableView*)table acceptDrop:(id <NSDraggingInfo>)info
2230 row:(NSInteger)dropRow dropOperation:(NSTableViewDropOperation)op;
2232 NSPasteboard *pb = [info draggingPasteboard];
2233 NSDragOperation srcMask = [info draggingSourceOperationMask];
2240 // Intra-table drag - data is the array of rows.
2241 if (!accepted && (array =
2242 [pb propertyListForType:@"VLC media player module"]) != NULL) {
2243 NSEnumerator *iter = nil;
2245 BOOL isCopy = (srcMask & NSDragOperationMove) ? NO:YES;
2247 iter = [array objectEnumerator];
2248 while ((val = [iter nextObject]) != NULL) {
2249 NSArray *o_tmp = [[o_modulearray objectAtIndex:
2250 [val intValue]] mutableCopyWithZone:nil];
2251 [o_modulearray removeObject:o_tmp];
2252 [o_modulearray insertObject:o_tmp
2253 atIndex:(dropRow>[val intValue]) ? dropRow - 1 : dropRow];
2257 // Select the newly-dragged items.
2258 iter = [array objectEnumerator];
2260 [table deselectAll:self];
2262 [self tableChanged:self];
2263 [table setNeedsDisplay:YES];
2264 // Indicate that we finished the drag.
2268 [table setNeedsDisplay:YES];
2272 // An exception occurred. Uh-oh. Update the track table so that
2273 // it stays consistent, and re-raise the exception.
2275 [localException raise];
2276 [table setNeedsDisplay:YES];
2282 - (NSInteger)numberOfRowsInTableView:(NSTableView *)aTableView
2284 return [o_modulearray count];
2287 - (id)tableView:(NSTableView *)aTableView
2288 objectValueForTableColumn:(NSTableColumn *)aTableColumn row:(NSInteger)rowIndex
2290 if ([[aTableColumn identifier] isEqualToString: @"Enabled"])
2291 return [[o_modulearray objectAtIndex:rowIndex] objectAtIndex:2];
2292 if ([[aTableColumn identifier] isEqualToString: @"Module"])
2293 return [[o_modulearray objectAtIndex:rowIndex] objectAtIndex:1];
2298 - (void)tableView:(NSTableView *)aTableView setObjectValue:(id)anObject
2299 forTableColumn:(NSTableColumn *)aTableColumn row:(NSInteger)rowIndex
2301 [[o_modulearray objectAtIndex:rowIndex] replaceObjectAtIndex:2
2302 withObject: anObject];
2306 @implementation SectionControl
2308 - (id) initWithItem: (module_config_t *)_p_item
2309 withView: (NSView *)o_parent_view
2311 NSRect mainFrame = [o_parent_view frame];
2312 NSString *o_labelString, *o_tooltip;
2313 mainFrame.size.height = 17;
2314 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN;
2315 mainFrame.origin.x = LEFTMARGIN;
2316 mainFrame.origin.y = 0;
2318 if ([super initWithFrame: mainFrame item: _p_item] != nil) {
2321 if (p_item->psz_text)
2322 o_labelString = _NS((char *)p_item->psz_text);
2324 o_labelString = @"";
2326 NSDictionary *boldAttributes = [NSDictionary dictionaryWithObjectsAndKeys:
2327 [NSFont boldSystemFontOfSize:[NSFont systemFontSize]],
2328 NSFontAttributeName,
2330 NSAttributedString *o_bold_string = [[NSAttributedString alloc] initWithString: o_labelString attributes: boldAttributes];
2332 ADD_LABEL(o_label, mainFrame, 1, 0, @"", @"")
2333 [o_label setAttributedStringValue: o_bold_string];
2334 [o_label sizeToFit];
2336 [o_bold_string release];
2338 [o_label setAutoresizingMask:NSViewNotSizable];
2339 [self addSubview: o_label];