1 /*****************************************************************************
2 * prefs_widgets.m: Preferences controls
3 *****************************************************************************
4 * Copyright (C) 2002-2007 the VideoLAN team
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>
39 #include "prefs_widgets.h"
41 #define PREFS_WRAP 300
42 #define OFFSET_RIGHT 20
43 #define OFFSET_BETWEEN 2
45 #define UPWARDS_WHITE_ARROW "\xE2\x87\xA7"
46 #define OPTION_KEY "\xE2\x8C\xA5"
47 #define UP_ARROWHEAD "\xE2\x8C\x83"
48 #define PLACE_OF_INTEREST_SIGN "\xE2\x8C\x98"
50 #define POPULATE_A_KEY( o_menu, string, value ) \
54 o_mi = [[NSMenuItem alloc] initWithTitle:string \
55 action:nil keyEquivalent:@""]; \
56 [o_mi setKeyEquivalentModifierMask: \
58 [o_mi setAlternate: NO]; \
61 [o_menu addItem: o_mi]; \
63 o_mi = [[NSMenuItem alloc] initWithTitle: \
64 [[NSString stringWithUTF8String: \
66 ] stringByAppendingString: string] \
67 action:nil keyEquivalent:@""]; \
68 [o_mi setKeyEquivalentModifierMask: \
70 [o_mi setAlternate: YES]; \
72 KEY_MODIFIER_CTRL | ( value )]; \
73 [o_menu addItem: o_mi]; \
75 o_mi = [[NSMenuItem alloc] initWithTitle: \
76 [[NSString stringWithUTF8String: \
77 UP_ARROWHEAD OPTION_KEY \
78 ] stringByAppendingString: string] \
79 action:nil keyEquivalent:@""]; \
80 [o_mi setKeyEquivalentModifierMask: \
81 NSControlKeyMask | NSAlternateKeyMask]; \
82 [o_mi setAlternate: YES]; \
84 (KEY_MODIFIER_CTRL | KEY_MODIFIER_ALT) | ( value )]; \
85 [o_menu addItem: o_mi]; \
87 o_mi = [[NSMenuItem alloc] initWithTitle: \
88 [[NSString stringWithUTF8String: \
89 UP_ARROWHEAD UPWARDS_WHITE_ARROW \
90 ] stringByAppendingString: string] \
91 action:nil keyEquivalent:@""]; \
92 [o_mi setKeyEquivalentModifierMask: \
93 NSControlKeyMask | NSShiftKeyMask]; \
94 [o_mi setAlternate: YES]; \
96 (KEY_MODIFIER_CTRL | KEY_MODIFIER_SHIFT) | ( value )]; \
97 [o_menu addItem: o_mi]; \
99 o_mi = [[NSMenuItem alloc] initWithTitle: \
100 [[NSString stringWithUTF8String: \
101 UP_ARROWHEAD PLACE_OF_INTEREST_SIGN \
102 ] stringByAppendingString: string] \
103 action:nil keyEquivalent:@""]; \
104 [o_mi setKeyEquivalentModifierMask: \
105 NSControlKeyMask | NSCommandKeyMask]; \
106 [o_mi setAlternate: YES]; \
108 (KEY_MODIFIER_CTRL | KEY_MODIFIER_COMMAND) | ( value )]; \
109 [o_menu addItem: o_mi]; \
110 /* Ctrl+Alt+Shift */ \
111 o_mi = [[NSMenuItem alloc] initWithTitle: \
112 [[NSString stringWithUTF8String: \
113 UP_ARROWHEAD OPTION_KEY UPWARDS_WHITE_ARROW \
114 ] stringByAppendingString: string] \
115 action:nil keyEquivalent:@""]; \
116 [o_mi setKeyEquivalentModifierMask: \
117 NSControlKeyMask | NSAlternateKeyMask | NSShiftKeyMask]; \
118 [o_mi setAlternate: YES]; \
120 (KEY_MODIFIER_CTRL | KEY_MODIFIER_ALT | KEY_MODIFIER_SHIFT) | \
122 [o_menu addItem: o_mi]; \
123 /* Ctrl+Alt+Apple */ \
124 o_mi = [[NSMenuItem alloc] initWithTitle: \
125 [[NSString stringWithUTF8String: \
126 UP_ARROWHEAD OPTION_KEY PLACE_OF_INTEREST_SIGN \
127 ] stringByAppendingString: string] \
128 action:nil keyEquivalent:@""]; \
129 [o_mi setKeyEquivalentModifierMask: \
130 NSControlKeyMask | NSAlternateKeyMask | NSCommandKeyMask]; \
131 [o_mi setAlternate: YES]; \
133 (KEY_MODIFIER_CTRL | KEY_MODIFIER_ALT | KEY_MODIFIER_COMMAND) | \
135 [o_menu addItem: o_mi]; \
136 /* Ctrl+Shift+Apple */ \
137 o_mi = [[NSMenuItem alloc] initWithTitle: \
138 [[NSString stringWithUTF8String: \
139 UP_ARROWHEAD UPWARDS_WHITE_ARROW PLACE_OF_INTEREST_SIGN \
140 ] stringByAppendingString: string] \
141 action:nil keyEquivalent:@""]; \
142 [o_mi setKeyEquivalentModifierMask: \
143 NSControlKeyMask | NSShiftKeyMask | NSCommandKeyMask]; \
144 [o_mi setAlternate: YES]; \
146 (KEY_MODIFIER_CTRL | KEY_MODIFIER_SHIFT | KEY_MODIFIER_COMMAND) | \
148 [o_menu addItem: o_mi]; \
149 /* Ctrl+Alt+Shift+Apple */ \
150 o_mi = [[NSMenuItem alloc] initWithTitle: \
151 [[NSString stringWithUTF8String: \
152 UP_ARROWHEAD OPTION_KEY UPWARDS_WHITE_ARROW \
153 PLACE_OF_INTEREST_SIGN \
154 ] stringByAppendingString: string] \
155 action:nil keyEquivalent:@""]; \
156 [o_mi setKeyEquivalentModifierMask: \
157 NSControlKeyMask | NSAlternateKeyMask | NSShiftKeyMask | \
159 [o_mi setAlternate: YES]; \
161 (KEY_MODIFIER_CTRL | KEY_MODIFIER_ALT | KEY_MODIFIER_SHIFT | \
162 KEY_MODIFIER_COMMAND) | ( value )]; \
163 [o_menu addItem: o_mi]; \
165 o_mi = [[NSMenuItem alloc] initWithTitle: \
166 [[NSString stringWithUTF8String: \
168 ] stringByAppendingString: string] \
169 action:nil keyEquivalent:@""]; \
170 [o_mi setKeyEquivalentModifierMask: \
171 NSAlternateKeyMask]; \
172 [o_mi setAlternate: YES]; \
174 KEY_MODIFIER_ALT | ( value )]; \
175 [o_menu addItem: o_mi]; \
177 o_mi = [[NSMenuItem alloc] initWithTitle: \
178 [[NSString stringWithUTF8String: \
179 OPTION_KEY UPWARDS_WHITE_ARROW \
180 ] stringByAppendingString: string] \
181 action:nil keyEquivalent:@""]; \
182 [o_mi setKeyEquivalentModifierMask: \
183 NSAlternateKeyMask | NSShiftKeyMask]; \
184 [o_mi setAlternate: YES]; \
186 (KEY_MODIFIER_ALT | KEY_MODIFIER_SHIFT) | ( value )]; \
187 [o_menu addItem: o_mi]; \
189 o_mi = [[NSMenuItem alloc] initWithTitle: \
190 [[NSString stringWithUTF8String: \
191 OPTION_KEY PLACE_OF_INTEREST_SIGN \
192 ] stringByAppendingString: string] \
193 action:nil keyEquivalent:@""]; \
194 [o_mi setKeyEquivalentModifierMask: \
195 NSAlternateKeyMask | NSCommandKeyMask]; \
196 [o_mi setAlternate: YES]; \
198 (KEY_MODIFIER_ALT | KEY_MODIFIER_COMMAND) | ( value )]; \
199 [o_menu addItem: o_mi]; \
200 /* Alt+Shift+Apple */ \
201 o_mi = [[NSMenuItem alloc] initWithTitle: \
202 [[NSString stringWithUTF8String: \
203 OPTION_KEY UPWARDS_WHITE_ARROW PLACE_OF_INTEREST_SIGN \
204 ] stringByAppendingString: string] \
205 action:nil keyEquivalent:@""]; \
206 [o_mi setKeyEquivalentModifierMask: \
207 NSAlternateKeyMask | NSShiftKeyMask | NSCommandKeyMask]; \
208 [o_mi setAlternate: YES]; \
210 (KEY_MODIFIER_ALT | KEY_MODIFIER_SHIFT | KEY_MODIFIER_COMMAND) | \
212 [o_menu addItem: o_mi]; \
214 o_mi = [[NSMenuItem alloc] initWithTitle: \
215 [[NSString stringWithUTF8String: \
216 UPWARDS_WHITE_ARROW \
217 ] stringByAppendingString: string] \
218 action:nil keyEquivalent:@""]; \
219 [o_mi setKeyEquivalentModifierMask: \
221 [o_mi setAlternate: YES]; \
223 KEY_MODIFIER_SHIFT | ( value )]; \
224 [o_menu addItem: o_mi]; \
226 o_mi = [[NSMenuItem alloc] initWithTitle: \
227 [[NSString stringWithUTF8String: \
228 UPWARDS_WHITE_ARROW PLACE_OF_INTEREST_SIGN \
229 ] stringByAppendingString: string] \
230 action:nil keyEquivalent:@""]; \
231 [o_mi setKeyEquivalentModifierMask: \
232 NSShiftKeyMask | NSCommandKeyMask]; \
233 [o_mi setAlternate: YES]; \
235 (KEY_MODIFIER_SHIFT | KEY_MODIFIER_COMMAND) | ( value )]; \
236 [o_menu addItem: o_mi]; \
238 o_mi = [[NSMenuItem alloc] initWithTitle: \
239 [[NSString stringWithUTF8String: \
240 PLACE_OF_INTEREST_SIGN \
241 ] stringByAppendingString: string] \
242 action:nil keyEquivalent:@""]; \
243 [o_mi setKeyEquivalentModifierMask: \
245 [o_mi setAlternate: YES]; \
247 KEY_MODIFIER_COMMAND | ( value )]; \
248 [o_menu addItem: o_mi]; \
251 #define ADD_LABEL( o_label, superFrame, x_offset, my_y_offset, label, \
254 NSRect s_rc = superFrame; \
255 s_rc.size.height = 17; \
256 s_rc.origin.x = x_offset - 3; \
257 s_rc.origin.y = superFrame.size.height - 17 + my_y_offset; \
258 o_label = [[[NSTextField alloc] initWithFrame: s_rc] retain]; \
259 [o_label setDrawsBackground: NO]; \
260 [o_label setBordered: NO]; \
261 [o_label setEditable: NO]; \
262 [o_label setSelectable: NO]; \
263 [o_label setStringValue: label]; \
264 [o_label setToolTip: tooltip]; \
265 [o_label setFont:[NSFont systemFontOfSize:0]]; \
266 [o_label sizeToFit]; \
269 #define ADD_TEXTFIELD( o_textfield, superFrame, x_offset, my_y_offset, \
270 my_width, tooltip, init_value ) \
272 NSRect s_rc = superFrame; \
273 s_rc.origin.x = x_offset; \
274 s_rc.origin.y = my_y_offset; \
275 s_rc.size.height = 22; \
276 s_rc.size.width = my_width; \
277 o_textfield = [[[NSTextField alloc] initWithFrame: s_rc] retain]; \
278 [o_textfield setFont:[NSFont systemFontOfSize:0]]; \
279 [o_textfield setToolTip: tooltip]; \
280 [o_textfield setStringValue: init_value]; \
283 #define ADD_SECURETEXTFIELD( o_textfield, superFrame, x_offset, my_y_offset, \
284 my_width, tooltip, init_value ) \
286 NSRect s_rc = superFrame; \
287 s_rc.origin.x = x_offset; \
288 s_rc.origin.y = my_y_offset; \
289 s_rc.size.height = 22; \
290 s_rc.size.width = my_width; \
291 o_textfield = [[[NSSecureTextField alloc] initWithFrame: s_rc] retain]; \
292 [o_textfield setFont:[NSFont systemFontOfSize:0]]; \
293 [o_textfield setToolTip: tooltip]; \
294 [o_textfield setStringValue: init_value]; \
297 #define ADD_COMBO( o_combo, superFrame, x_offset, my_y_offset, x2_offset, \
300 NSRect s_rc = superFrame; \
301 s_rc.origin.x = x_offset + 2; \
302 s_rc.origin.y = my_y_offset; \
303 s_rc.size.height = 26; \
304 s_rc.size.width = superFrame.size.width + 2 - s_rc.origin.x - \
306 o_combo = [[[NSComboBox alloc] initWithFrame: s_rc] retain]; \
307 [o_combo setFont:[NSFont systemFontOfSize:0]]; \
308 [o_combo setToolTip: tooltip]; \
309 [o_combo setUsesDataSource:TRUE]; \
310 [o_combo setDataSource:self]; \
311 [o_combo setNumberOfVisibleItems:10]; \
312 [o_combo setCompletes:YES]; \
315 #define ADD_RIGHT_BUTTON( o_button, superFrame, x_offset, my_y_offset, \
318 NSRect s_rc = superFrame; \
319 o_button = [[[NSButton alloc] initWithFrame: s_rc] retain]; \
320 [o_button setButtonType: NSMomentaryPushInButton]; \
321 [o_button setBezelStyle: NSRoundedBezelStyle]; \
322 [o_button setTitle: title]; \
323 [o_button setFont:[NSFont systemFontOfSize:0]]; \
324 [o_button sizeToFit]; \
325 s_rc = [o_button frame]; \
326 s_rc.origin.x = superFrame.size.width - [o_button frame].size.width - 6;\
327 s_rc.origin.y = my_y_offset - 6; \
328 s_rc.size.width += 12; \
329 [o_button setFrame: s_rc]; \
330 [o_button setToolTip: tooltip]; \
331 [o_button setTarget: self]; \
332 [o_button setAction: @selector(openFileDialog:)]; \
335 #define ADD_POPUP( o_popup, superFrame, x_offset, my_y_offset, x2_offset, \
338 NSRect s_rc = superFrame; \
339 s_rc.origin.x = x_offset - 1; \
340 s_rc.origin.y = my_y_offset; \
341 s_rc.size.height = 26; \
342 s_rc.size.width = superFrame.size.width + 2 - s_rc.origin.x - \
344 o_popup = [[[NSPopUpButton alloc] initWithFrame: s_rc] retain]; \
345 [o_popup setFont:[NSFont systemFontOfSize:0]]; \
346 [o_popup setToolTip: tooltip]; \
349 #define ADD_STEPPER( o_stepper, superFrame, x_offset, my_y_offset, tooltip, \
352 NSRect s_rc = superFrame; \
353 s_rc.origin.x = x_offset; \
354 s_rc.origin.y = my_y_offset; \
355 s_rc.size.height = 23; \
356 s_rc.size.width = 23; \
357 o_stepper = [[[NSStepper alloc] initWithFrame: s_rc] retain]; \
358 [o_stepper setFont:[NSFont systemFontOfSize:0]]; \
359 [o_stepper setToolTip: tooltip]; \
360 [o_stepper setMaxValue: higher]; \
361 [o_stepper setMinValue: lower]; \
362 [o_stepper setTarget: self]; \
363 [o_stepper setAction: @selector(stepperChanged:)]; \
364 [o_stepper sendActionOn:NSLeftMouseUpMask | NSLeftMouseDownMask | \
365 NSLeftMouseDraggedMask]; \
368 #define ADD_SLIDER( o_slider, superFrame, x_offset, my_y_offset, my_width, \
369 tooltip, lower, higher ) \
371 NSRect s_rc = superFrame; \
372 s_rc.origin.x = x_offset; \
373 s_rc.origin.y = my_y_offset; \
374 s_rc.size.height = 21; \
375 s_rc.size.width = my_width; \
376 o_slider = [[[NSSlider alloc] initWithFrame: s_rc] retain]; \
377 [o_slider setFont:[NSFont systemFontOfSize:0]]; \
378 [o_slider setToolTip: tooltip]; \
379 [o_slider setMaxValue: higher]; \
380 [o_slider setMinValue: lower]; \
383 #define ADD_CHECKBOX( o_checkbox, superFrame, x_offset, my_y_offset, label, \
384 tooltip, init_value, position ) \
386 NSRect s_rc = superFrame; \
387 s_rc.size.height = 18; \
388 s_rc.origin.x = x_offset - 2; \
389 s_rc.origin.y = superFrame.size.height - 18 + my_y_offset; \
390 o_checkbox = [[[NSButton alloc] initWithFrame: s_rc] retain]; \
391 [o_checkbox setFont:[NSFont systemFontOfSize:0]]; \
392 [o_checkbox setButtonType: NSSwitchButton]; \
393 [o_checkbox setImagePosition: position]; \
394 [o_checkbox setIntValue: init_value]; \
395 [o_checkbox setTitle: label]; \
396 [o_checkbox setToolTip: tooltip]; \
397 [o_checkbox sizeToFit]; \
400 @implementation VLCConfigControl
401 - (id)initWithFrame: (NSRect)frame
403 return [self initWithFrame: frame
407 - (id)initWithFrame: (NSRect)frame
408 item: (module_config_t *)_p_item
410 self = [super initWithFrame: frame];
415 psz_name = p_item->psz_name;
417 i_type = p_item->i_type;
419 b_advanced = p_item->b_advanced;
420 [self setAutoresizingMask:NSViewWidthSizable | NSViewMinYMargin ];
425 - (void)setYPos:(int)i_yPos
427 NSRect frame = [self frame];
428 frame.origin.y = i_yPos;
429 [self setFrame:frame];
434 if( o_label ) [o_label release];
439 + (int)calcVerticalMargin: (int)i_curItem lastItem: (int)i_lastItem
444 case CONFIG_ITEM_STRING:
445 case CONFIG_ITEM_PASSWORD:
448 case CONFIG_ITEM_STRING:
449 case CONFIG_ITEM_PASSWORD:
452 case CONFIG_ITEM_STRING_LIST:
455 case CONFIG_ITEM_FILE:
458 case CONFIG_ITEM_MODULE:
461 case CONFIG_ITEM_INTEGER:
464 case CONFIG_ITEM_RANGED_INTEGER:
467 case CONFIG_ITEM_BOOL:
470 case CONFIG_ITEM_KEY_AFTER_10_3:
473 case CONFIG_ITEM_MODULE_LIST:
481 case CONFIG_ITEM_STRING_LIST:
484 case CONFIG_ITEM_STRING:
485 case CONFIG_ITEM_PASSWORD:
488 case CONFIG_ITEM_STRING_LIST:
491 case CONFIG_ITEM_FILE:
494 case CONFIG_ITEM_MODULE:
497 case CONFIG_ITEM_INTEGER:
500 case CONFIG_ITEM_RANGED_INTEGER:
503 case CONFIG_ITEM_BOOL:
506 case CONFIG_ITEM_KEY_AFTER_10_3:
509 case CONFIG_ITEM_MODULE_LIST:
517 case CONFIG_ITEM_FILE:
520 case CONFIG_ITEM_STRING:
521 case CONFIG_ITEM_PASSWORD:
524 case CONFIG_ITEM_STRING_LIST:
527 case CONFIG_ITEM_FILE:
530 case CONFIG_ITEM_MODULE:
533 case CONFIG_ITEM_INTEGER:
536 case CONFIG_ITEM_RANGED_INTEGER:
539 case CONFIG_ITEM_BOOL:
542 case CONFIG_ITEM_KEY_AFTER_10_3:
545 case CONFIG_ITEM_MODULE_LIST:
553 case CONFIG_ITEM_MODULE:
556 case CONFIG_ITEM_STRING:
557 case CONFIG_ITEM_PASSWORD:
560 case CONFIG_ITEM_STRING_LIST:
563 case CONFIG_ITEM_FILE:
566 case CONFIG_ITEM_MODULE:
569 case CONFIG_ITEM_INTEGER:
572 case CONFIG_ITEM_RANGED_INTEGER:
575 case CONFIG_ITEM_BOOL:
578 case CONFIG_ITEM_KEY_AFTER_10_3:
581 case CONFIG_ITEM_MODULE_LIST:
589 case CONFIG_ITEM_INTEGER:
592 case CONFIG_ITEM_STRING:
593 case CONFIG_ITEM_PASSWORD:
596 case CONFIG_ITEM_STRING_LIST:
599 case CONFIG_ITEM_FILE:
602 case CONFIG_ITEM_MODULE:
605 case CONFIG_ITEM_INTEGER:
608 case CONFIG_ITEM_RANGED_INTEGER:
611 case CONFIG_ITEM_BOOL:
614 case CONFIG_ITEM_KEY_AFTER_10_3:
617 case CONFIG_ITEM_MODULE_LIST:
625 case CONFIG_ITEM_RANGED_INTEGER:
628 case CONFIG_ITEM_STRING:
629 case CONFIG_ITEM_PASSWORD:
632 case CONFIG_ITEM_STRING_LIST:
635 case CONFIG_ITEM_FILE:
638 case CONFIG_ITEM_MODULE:
641 case CONFIG_ITEM_INTEGER:
644 case CONFIG_ITEM_RANGED_INTEGER:
647 case CONFIG_ITEM_BOOL:
650 case CONFIG_ITEM_KEY_AFTER_10_3:
653 case CONFIG_ITEM_MODULE_LIST:
661 case CONFIG_ITEM_BOOL:
664 case CONFIG_ITEM_STRING:
665 case CONFIG_ITEM_PASSWORD:
668 case CONFIG_ITEM_STRING_LIST:
671 case CONFIG_ITEM_FILE:
674 case CONFIG_ITEM_MODULE:
677 case CONFIG_ITEM_INTEGER:
680 case CONFIG_ITEM_RANGED_INTEGER:
683 case CONFIG_ITEM_BOOL:
686 case CONFIG_ITEM_KEY_AFTER_10_3:
689 case CONFIG_ITEM_MODULE_LIST:
697 case CONFIG_ITEM_KEY_AFTER_10_3:
700 case CONFIG_ITEM_STRING:
701 case CONFIG_ITEM_PASSWORD:
704 case CONFIG_ITEM_STRING_LIST:
707 case CONFIG_ITEM_FILE:
710 case CONFIG_ITEM_MODULE:
713 case CONFIG_ITEM_INTEGER:
716 case CONFIG_ITEM_RANGED_INTEGER:
719 case CONFIG_ITEM_BOOL:
722 case CONFIG_ITEM_KEY_AFTER_10_3:
725 case CONFIG_ITEM_MODULE_LIST:
733 case CONFIG_ITEM_MODULE_LIST:
736 case CONFIG_ITEM_STRING:
737 case CONFIG_ITEM_PASSWORD:
740 case CONFIG_ITEM_STRING_LIST:
743 case CONFIG_ITEM_FILE:
746 case CONFIG_ITEM_MODULE:
749 case CONFIG_ITEM_INTEGER:
752 case CONFIG_ITEM_RANGED_INTEGER:
755 case CONFIG_ITEM_BOOL:
758 case CONFIG_ITEM_KEY_AFTER_10_3:
761 case CONFIG_ITEM_MODULE_LIST:
776 + (VLCConfigControl *)newControl: (module_config_t *)_p_item
777 withView: (NSView *)o_parent_view
779 VLCConfigControl *p_control = NULL;
781 switch( _p_item->i_type )
783 case CONFIG_ITEM_STRING:
784 case CONFIG_ITEM_PASSWORD:
785 if( !_p_item->i_list )
787 p_control = [[StringConfigControl alloc]
788 initWithItem: _p_item
789 withView: o_parent_view];
793 p_control = [[StringListConfigControl alloc]
794 initWithItem: _p_item
795 withView: o_parent_view];
798 case CONFIG_ITEM_FILE:
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->i_list )
813 p_control = [[IntegerListConfigControl alloc]
814 initWithItem: _p_item
815 withView: o_parent_view];
817 else if( _p_item->min.i != 0 || _p_item->max.i != 0 )
819 p_control = [[RangedIntegerConfigControl alloc]
820 initWithItem: _p_item
821 withView: o_parent_view];
825 p_control = [[IntegerConfigControl alloc]
826 initWithItem: _p_item
827 withView: o_parent_view];
830 case CONFIG_ITEM_BOOL:
831 p_control = [[BoolConfigControl alloc]
832 initWithItem: _p_item
833 withView: o_parent_view];
835 case CONFIG_ITEM_FLOAT:
836 if( _p_item->min.f != 0 || _p_item->max.f != 0 )
838 p_control = [[RangedFloatConfigControl alloc]
839 initWithItem: _p_item
840 withView: o_parent_view];
844 p_control = [[FloatConfigControl alloc]
845 initWithItem: _p_item
846 withView: o_parent_view];
849 case CONFIG_ITEM_KEY:
850 p_control = [[KeyConfigControl alloc]
851 initWithItem: _p_item
852 withView: o_parent_view];
854 case CONFIG_ITEM_MODULE_LIST:
855 case CONFIG_ITEM_MODULE_LIST_CAT:
856 p_control = [[ModuleListConfigControl alloc]
857 initWithItem: _p_item
858 withView: o_parent_view];
866 - (NSString *)getName
868 return [[VLCMain sharedInstance] localizedString: psz_name];
896 - (char *)stringValue
904 switch( p_item->i_type )
906 case CONFIG_ITEM_STRING:
907 case CONFIG_ITEM_PASSWORD:
908 case CONFIG_ITEM_FILE:
909 case CONFIG_ITEM_DIRECTORY:
910 case CONFIG_ITEM_MODULE:
911 case CONFIG_ITEM_MODULE_LIST:
912 case CONFIG_ITEM_MODULE_LIST_CAT:
913 config_PutPsz( VLCIntf, psz_name, [self stringValue] );
915 case CONFIG_ITEM_KEY:
916 /* So you don't need to restart to have the changes take effect */
917 val.i_int = [self intValue];
918 var_Set( VLCIntf->p_libvlc, psz_name, val );
919 case CONFIG_ITEM_INTEGER:
920 case CONFIG_ITEM_BOOL:
921 config_PutInt( VLCIntf, psz_name, [self intValue] );
923 case CONFIG_ITEM_FLOAT:
924 config_PutFloat( VLCIntf, psz_name, [self floatValue] );
931 return [o_label frame].size.width;
934 - (void) alignWithXPosition:(int)i_xPos;
936 /* FIXME: not implemented atm, but created to shut up the warning
937 * about "method definition not found" -- FK @ 7/24/05 */
941 @implementation StringConfigControl
942 - (id) initWithItem: (module_config_t *)_p_item
943 withView: (NSView *)o_parent_view
945 NSRect mainFrame = [o_parent_view frame];
946 NSString *o_labelString, *o_textfieldString, *o_textfieldTooltip;
947 mainFrame.size.height = 22;
948 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN;
949 mainFrame.origin.x = LEFTMARGIN;
950 mainFrame.origin.y = 0;
952 if( [super initWithFrame: mainFrame item: _p_item] != nil )
954 if( p_item->i_type == CONFIG_ITEM_PASSWORD )
955 i_view_type = CONFIG_ITEM_PASSWORD;
957 i_view_type = CONFIG_ITEM_STRING;
959 o_textfieldTooltip = [[VLCMain sharedInstance] wrapString:
960 [[VLCMain sharedInstance] localizedString: (char *)p_item->psz_longtext]
961 toWidth: PREFS_WRAP];
964 if( p_item->psz_text )
965 o_labelString = [[VLCMain sharedInstance]
966 localizedString: (char *)p_item->psz_text];
968 o_labelString = [NSString stringWithString:@""];
969 ADD_LABEL( o_label, mainFrame, 0, -3, o_labelString, o_textfieldTooltip )
970 [o_label setAutoresizingMask:NSViewNotSizable ];
971 [self addSubview: o_label];
973 /* build the textfield */
974 if( p_item->value.psz )
975 o_textfieldString = [[VLCMain sharedInstance]
976 localizedString: (char *)p_item->value.psz];
978 o_textfieldString = [NSString stringWithString: @""];
979 if( p_item->i_type == CONFIG_ITEM_PASSWORD )
981 ADD_SECURETEXTFIELD( o_textfield, mainFrame, [o_label frame].size.width + 2,
982 0, mainFrame.size.width - [o_label frame].size.width -
983 2, o_textfieldTooltip, o_textfieldString )
987 ADD_TEXTFIELD( o_textfield, mainFrame, [o_label frame].size.width + 2,
988 0, mainFrame.size.width - [o_label frame].size.width -
989 2, o_textfieldTooltip, o_textfieldString )
991 [o_textfield setAutoresizingMask:NSViewWidthSizable ];
993 [self addSubview: o_textfield];
998 - (void) alignWithXPosition:(int)i_xPos
1001 NSRect superFrame = [self frame];
1002 frame = [o_label frame];
1003 frame.origin.x = i_xPos - frame.size.width - 3;
1004 [o_label setFrame:frame];
1006 frame = [o_textfield frame];
1007 frame.origin.x = i_xPos + 2;
1008 frame.size.width = superFrame.size.width - frame.origin.x - 1;
1009 [o_textfield setFrame:frame];
1014 [o_textfield release];
1018 - (char *)stringValue
1020 return strdup( [[VLCMain sharedInstance] delocalizeString:
1021 [o_textfield stringValue]] );
1025 @implementation StringListConfigControl
1026 - (id) initWithItem: (module_config_t *)_p_item
1027 withView: (NSView *)o_parent_view
1029 NSRect mainFrame = [o_parent_view frame];
1030 NSString *o_labelString, *o_textfieldTooltip;
1031 mainFrame.size.height = 22;
1032 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN + 1;
1033 mainFrame.origin.x = LEFTMARGIN;
1034 mainFrame.origin.y = 0;
1036 if( [super initWithFrame: mainFrame item: _p_item] != nil )
1039 i_view_type = CONFIG_ITEM_STRING_LIST;
1041 o_textfieldTooltip = [[VLCMain sharedInstance] wrapString:
1042 [[VLCMain sharedInstance]
1043 localizedString: (char *)p_item->psz_longtext ] toWidth: PREFS_WRAP];
1046 if( p_item->psz_text )
1047 o_labelString = [[VLCMain sharedInstance]
1048 localizedString: (char *)p_item->psz_text];
1050 o_labelString = [NSString stringWithString:@""];
1051 ADD_LABEL( o_label, mainFrame, 0, -3, o_labelString, o_textfieldTooltip )
1052 [o_label setAutoresizingMask:NSViewNotSizable ];
1053 [self addSubview: o_label];
1055 /* build the textfield */
1056 ADD_COMBO( o_combo, mainFrame, [o_label frame].size.width,
1057 -2, 0, o_textfieldTooltip )
1058 [o_combo setAutoresizingMask:NSViewWidthSizable ];
1059 for( i_index = 0; i_index < p_item->i_list; i_index++ )
1060 if( p_item->value.psz &&
1061 !strcmp( p_item->value.psz, p_item->ppsz_list[i_index] ) )
1062 [o_combo selectItemAtIndex: i_index];
1063 [self addSubview: o_combo];
1068 - (void) alignWithXPosition:(int)i_xPos
1071 NSRect superFrame = [self frame];
1072 frame = [o_label frame];
1073 frame.origin.x = i_xPos - frame.size.width - 3;
1074 [o_label setFrame:frame];
1076 frame = [o_combo frame];
1077 frame.origin.x = i_xPos + 2;
1078 frame.size.width = superFrame.size.width - frame.origin.x + 2;
1079 [o_combo setFrame:frame];
1088 - (char *)stringValue
1090 if( [o_combo indexOfSelectedItem] >= 0 )
1091 return strdup( p_item->ppsz_list[[o_combo indexOfSelectedItem]] );
1093 return strdup( [[VLCMain sharedInstance]
1094 delocalizeString: [o_combo stringValue]] );
1098 @implementation StringListConfigControl (NSComboBoxDataSource)
1099 - (NSInteger)numberOfItemsInComboBox:(NSComboBox *)aComboBox
1101 return p_item->i_list;
1104 - (id)comboBox:(NSComboBox *)aComboBox objectValueForItemAtIndex:(NSInteger)i_index
1106 if( p_item->ppsz_list_text && p_item->ppsz_list_text[i_index] )
1108 return [[VLCMain sharedInstance]
1109 localizedString: (char *)p_item->ppsz_list_text[i_index]];
1110 } else return [[VLCMain sharedInstance]
1111 localizedString: (char *)p_item->ppsz_list[i_index]];
1115 @implementation FileConfigControl
1116 - (id) initWithItem: (module_config_t *)_p_item
1117 withView: (NSView *)o_parent_view
1119 NSRect mainFrame = [o_parent_view frame];
1120 NSString *o_labelString, *o_itemTooltip, *o_textfieldString;
1121 mainFrame.size.height = 46;
1122 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN;
1123 mainFrame.origin.x = LEFTMARGIN;
1124 mainFrame.origin.y = 0;
1126 if( [super initWithFrame: mainFrame item: _p_item] != nil )
1128 i_view_type = CONFIG_ITEM_FILE;
1130 o_itemTooltip = [[VLCMain sharedInstance]
1131 wrapString: [[VLCMain sharedInstance]
1132 localizedString: (char *)p_item->psz_longtext ] toWidth: PREFS_WRAP];
1134 /* is it a directory */
1135 b_directory = ( [self getType] == CONFIG_ITEM_DIRECTORY ) ? YES : NO;
1138 if( p_item->psz_text )
1139 o_labelString = [[VLCMain sharedInstance]
1140 localizedString: (char *)p_item->psz_text];
1142 o_labelString = [NSString stringWithString:@""];
1143 ADD_LABEL( o_label, mainFrame, 0, 3, o_labelString, o_itemTooltip )
1144 [o_label setAutoresizingMask:NSViewNotSizable ];
1145 [self addSubview: o_label];
1147 /* build the button */
1148 ADD_RIGHT_BUTTON( o_button, mainFrame, 0, 0, o_itemTooltip,
1150 [o_button setAutoresizingMask:NSViewMinXMargin ];
1151 [self addSubview: o_button];
1153 /* build the textfield */
1154 if( p_item->value.psz )
1155 o_textfieldString = [NSString stringWithFormat: @"%s", (char *)p_item->value.psz];
1157 o_textfieldString = [NSString stringWithString: @""];
1158 ADD_TEXTFIELD( o_textfield, mainFrame, 12, 2, mainFrame.size.width -
1159 8 - [o_button frame].size.width,
1160 o_itemTooltip, o_textfieldString )
1161 [o_textfield setAutoresizingMask:NSViewWidthSizable ];
1162 [self addSubview: o_textfield];
1167 - (void) alignWithXPosition:(int)i_xPos
1174 [o_textfield release];
1179 - (IBAction)openFileDialog: (id)sender
1181 NSOpenPanel *o_open_panel = [NSOpenPanel openPanel];
1183 [o_open_panel setTitle: (b_directory)?
1184 _NS("Select a directory"):_NS("Select a file")];
1185 [o_open_panel setPrompt: _NS("Select")];
1186 [o_open_panel setAllowsMultipleSelection: NO];
1187 [o_open_panel setCanChooseFiles: !b_directory];
1188 [o_open_panel setCanChooseDirectories: b_directory];
1189 [o_open_panel beginSheetForDirectory:nil
1192 modalForWindow:[sender window]
1194 didEndSelector: @selector(pathChosenInPanel:
1200 - (void)pathChosenInPanel:(NSOpenPanel *)o_sheet
1201 withReturn:(int)i_return_code contextInfo:(void *)o_context_info
1203 if( i_return_code == NSOKButton )
1205 NSString *o_path = [[o_sheet filenames] objectAtIndex: 0];
1206 [o_textfield setStringValue: o_path];
1210 - (char *)stringValue
1212 if( [[o_textfield stringValue] length] != 0)
1213 return strdup( [[o_textfield stringValue] fileSystemRepresentation] );
1219 @implementation ModuleConfigControl
1220 - (id) initWithItem: (module_config_t *)_p_item
1221 withView: (NSView *)o_parent_view
1223 NSRect mainFrame = [o_parent_view frame];
1224 NSString *o_labelString, *o_popupTooltip;
1225 mainFrame.size.height = 22;
1226 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN + 1;
1227 mainFrame.origin.x = LEFTMARGIN;
1228 mainFrame.origin.y = 0;
1230 if( [super initWithFrame: mainFrame item: _p_item] != nil )
1233 module_t *p_parser, **p_list;
1234 i_view_type = CONFIG_ITEM_MODULE;
1236 o_popupTooltip = [[VLCMain sharedInstance] wrapString:
1237 [[VLCMain sharedInstance]
1238 localizedString: (char *)p_item->psz_longtext ] toWidth: PREFS_WRAP];
1241 if( p_item->psz_text )
1242 o_labelString = [[VLCMain sharedInstance]
1243 localizedString: (char *)p_item->psz_text];
1245 o_labelString = [NSString stringWithString:@""];
1246 ADD_LABEL( o_label, mainFrame, 0, -1, o_labelString, o_popupTooltip )
1247 [o_label setAutoresizingMask:NSViewNotSizable ];
1248 [self addSubview: o_label];
1250 /* build the popup */
1251 ADD_POPUP( o_popup, mainFrame, [o_label frame].size.width,
1252 -2, 0, o_popupTooltip )
1253 [o_popup setAutoresizingMask:NSViewWidthSizable ];
1254 [o_popup addItemWithTitle: _NS("Default")];
1255 [[o_popup lastItem] setTag: -1];
1256 [o_popup selectItem: [o_popup lastItem]];
1258 /* build a list of available modules */
1259 p_list = module_list_get( NULL );
1260 for( i_index = 0; p_list[i_index]; i_index++ )
1262 p_parser = p_list[i_index];
1264 if( p_item->i_type == CONFIG_ITEM_MODULE )
1266 if( module_provides( p_parser, p_item->psz_type ) )
1268 NSString *o_description = [[VLCMain sharedInstance]
1269 localizedString: module_GetLongName( p_parser )];
1270 [o_popup addItemWithTitle: o_description];
1272 if( p_item->value.psz &&
1273 !strcmp( p_item->value.psz, module_get_object( p_parser ) ) )
1274 [o_popup selectItem:[o_popup lastItem]];
1281 if( module_is_main( p_parser ) )
1283 unsigned int confsize;
1284 unsigned int unused;
1285 module_config_get( p_parser, &confsize );
1286 for ( i = 0; i < confsize; i++ )
1288 module_config_t *p_config = module_config_get( p_parser, &unused ) + i;
1289 /* Hack: required subcategory is stored in i_min */
1290 if( p_config->i_type == CONFIG_SUBCATEGORY &&
1291 p_config->value.i == p_item->min.i )
1293 NSString *o_description = [[VLCMain sharedInstance]
1294 localizedString: module_GetLongName( p_parser )];
1295 [o_popup addItemWithTitle: o_description];
1297 if( p_item->value.psz && !strcmp(p_item->value.psz,
1298 module_get_object( p_parser )) )
1299 [o_popup selectItem:[o_popup lastItem]];
1304 module_list_free( p_list );
1305 [self addSubview: o_popup];
1310 - (void) alignWithXPosition:(int)i_xPos
1313 NSRect superFrame = [self frame];
1314 frame = [o_label frame];
1315 frame.origin.x = i_xPos - frame.size.width - 3;
1316 [o_label setFrame:frame];
1318 frame = [o_popup frame];
1319 frame.origin.x = i_xPos - 1;
1320 frame.size.width = superFrame.size.width - frame.origin.x + 2;
1321 [o_popup setFrame:frame];
1330 - (char *)stringValue
1332 NSString *newval = [o_popup titleOfSelectedItem];
1333 char *returnval = NULL;
1334 size_t i_module_index;
1335 module_t *p_parser, **p_list;
1337 p_list = module_list_get( NULL );
1338 for( i_module_index = 0; p_list[i_module_index]; i_module_index++ )
1340 p_parser = p_list[i_module_index];
1342 if( p_item->i_type == CONFIG_ITEM_MODULE )
1344 if( module_provides( p_parser, p_item->psz_type ) )
1346 NSString *o_description = [[VLCMain sharedInstance]
1347 localizedString: module_GetLongName( p_parser )];
1348 if( [newval isEqualToString: o_description] )
1350 returnval = strdup( module_get_object( p_parser ));
1359 if( module_is_main( p_parser) )
1361 unsigned int confsize, unused;
1362 module_config_get( p_parser, &confsize );
1363 for ( i = 0; i < confsize; i++ )
1365 module_config_t *p_config = module_config_get( p_parser, &unused ) + i;
1366 /* Hack: required subcategory is stored in i_min */
1367 if( p_config->i_type == CONFIG_SUBCATEGORY &&
1368 p_config->value.i == p_item->min.i )
1370 NSString *o_description = [[VLCMain sharedInstance]
1371 localizedString: module_GetLongName( p_parser )];
1372 if( [newval isEqualToString: o_description] )
1374 returnval = strdup(module_get_object( p_parser ));
1381 module_list_free( p_list );
1386 @implementation IntegerConfigControl
1387 - (id) initWithItem: (module_config_t *)_p_item
1388 withView: (NSView *)o_parent_view
1390 NSRect mainFrame = [o_parent_view frame];
1391 NSString *o_labelString, *o_tooltip;
1392 mainFrame.size.height = 23;
1393 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN + 1;
1394 mainFrame.origin.x = LEFTMARGIN;
1395 mainFrame.origin.y = 0;
1397 if( [super initWithFrame: mainFrame item: _p_item] != nil )
1399 i_view_type = CONFIG_ITEM_INTEGER;
1401 o_tooltip = [[VLCMain sharedInstance] wrapString:
1402 [[VLCMain sharedInstance]
1403 localizedString: (char *)p_item->psz_longtext ] toWidth: PREFS_WRAP];
1406 if( p_item->psz_text )
1407 o_labelString = [[VLCMain sharedInstance]
1408 localizedString: (char *)p_item->psz_text];
1410 o_labelString = [NSString stringWithString:@""];
1411 ADD_LABEL( o_label, mainFrame, 0, -3, o_labelString, o_tooltip )
1412 [o_label setAutoresizingMask:NSViewNotSizable ];
1413 [self addSubview: o_label];
1415 /* build the stepper */
1416 ADD_STEPPER( o_stepper, mainFrame, mainFrame.size.width - 19,
1417 0, o_tooltip, -100000, 100000)
1418 [o_stepper setIntValue: p_item->value.i];
1419 [o_stepper setAutoresizingMask:NSViewMaxXMargin ];
1420 [self addSubview: o_stepper];
1422 ADD_TEXTFIELD( o_textfield, mainFrame, mainFrame.size.width - 19 - 52,
1423 1, 49, o_tooltip, @"" )
1424 [o_textfield setIntValue: p_item->value.i];
1425 [o_textfield setDelegate: self];
1426 [[NSNotificationCenter defaultCenter] addObserver: self
1427 selector: @selector(textfieldChanged:)
1428 name: NSControlTextDidChangeNotification
1429 object: o_textfield];
1430 [o_textfield setAutoresizingMask:NSViewMaxXMargin ];
1431 [self addSubview: o_textfield];
1436 - (void) alignWithXPosition:(int)i_xPos
1439 frame = [o_label frame];
1440 frame.origin.x = i_xPos - frame.size.width - 3;
1441 [o_label setFrame:frame];
1443 frame = [o_textfield frame];
1444 frame.origin.x = i_xPos + 2;
1445 [o_textfield setFrame:frame];
1447 frame = [o_stepper frame];
1448 frame.origin.x = i_xPos + [o_textfield frame].size.width + 5;
1449 [o_stepper setFrame:frame];
1454 [o_stepper release];
1455 [o_textfield release];
1459 - (IBAction)stepperChanged:(id)sender
1461 [o_textfield setIntValue: [o_stepper intValue]];
1464 - (void)textfieldChanged:(NSNotification *)o_notification
1466 [o_stepper setIntValue: [o_textfield intValue]];
1471 return [o_textfield intValue];
1476 @implementation IntegerListConfigControl
1478 - (id) initWithItem: (module_config_t *)_p_item
1479 withView: (NSView *)o_parent_view
1481 NSRect mainFrame = [o_parent_view frame];
1482 NSString *o_labelString, *o_textfieldTooltip;
1483 mainFrame.size.height = 22;
1484 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN + 1;
1485 mainFrame.origin.x = LEFTMARGIN;
1486 mainFrame.origin.y = 0;
1488 if( [super initWithFrame: mainFrame item: _p_item] != nil )
1491 i_view_type = CONFIG_ITEM_STRING_LIST;
1493 o_textfieldTooltip = [[VLCMain sharedInstance] wrapString:
1494 [[VLCMain sharedInstance]
1495 localizedString: (char *)p_item->psz_longtext ] toWidth: PREFS_WRAP];
1498 if( p_item->psz_text )
1499 o_labelString = [[VLCMain sharedInstance]
1500 localizedString: (char *)p_item->psz_text];
1502 o_labelString = [NSString stringWithString:@""];
1503 ADD_LABEL( o_label, mainFrame, 0, -3, o_labelString, o_textfieldTooltip )
1504 [o_label setAutoresizingMask:NSViewNotSizable ];
1505 [self addSubview: o_label];
1507 /* build the textfield */
1508 ADD_COMBO( o_combo, mainFrame, [o_label frame].size.width,
1509 -2, 0, o_textfieldTooltip )
1510 [o_combo setAutoresizingMask:NSViewWidthSizable ];
1511 for( i_index = 0; i_index < p_item->i_list; i_index++ )
1513 if( p_item->value.i == p_item->pi_list[i_index] )
1515 [o_combo selectItemAtIndex: i_index];
1518 [self addSubview: o_combo];
1523 - (void) alignWithXPosition:(int)i_xPos
1526 NSRect superFrame = [self frame];
1527 frame = [o_label frame];
1528 frame.origin.x = i_xPos - frame.size.width - 3;
1529 [o_label setFrame:frame];
1531 frame = [o_combo frame];
1532 frame.origin.x = i_xPos + 2;
1533 frame.size.width = superFrame.size.width - frame.origin.x + 2;
1534 [o_combo setFrame:frame];
1545 if( [o_combo indexOfSelectedItem] >= 0 )
1546 return p_item->pi_list[[o_combo indexOfSelectedItem]];
1548 return [o_combo intValue];
1552 @implementation IntegerListConfigControl (NSComboBoxDataSource)
1553 - (NSInteger)numberOfItemsInComboBox:(NSComboBox *)aComboBox
1555 return p_item->i_list;
1558 - (id)comboBox:(NSComboBox *)aComboBox objectValueForItemAtIndex:(NSInteger)i_index
1560 if( p_item->ppsz_list_text && p_item->ppsz_list_text[i_index] )
1561 return [[VLCMain sharedInstance]
1562 localizedString: (char *)p_item->ppsz_list_text[i_index]];
1564 return [NSString stringWithFormat: @"%i", p_item->pi_list[i_index]];
1568 @implementation RangedIntegerConfigControl
1569 - (id) initWithItem: (module_config_t *)_p_item
1570 withView: (NSView *)o_parent_view
1572 NSRect mainFrame = [o_parent_view frame];
1573 NSString *o_labelString, *o_tooltip;
1574 mainFrame.size.height = 50;
1575 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN;
1576 mainFrame.origin.x = LEFTMARGIN;
1577 mainFrame.origin.y = 0;
1579 if( [super initWithFrame: mainFrame item: _p_item] != nil )
1581 i_view_type = CONFIG_ITEM_RANGED_INTEGER;
1583 o_tooltip = [[VLCMain sharedInstance] wrapString:
1584 [[VLCMain sharedInstance]
1585 localizedString: (char *)p_item->psz_longtext ] toWidth: PREFS_WRAP];
1588 if( p_item->psz_text )
1589 o_labelString = [[VLCMain sharedInstance]
1590 localizedString: (char *)p_item->psz_text];
1592 o_labelString = [NSString stringWithString:@""];
1593 ADD_LABEL( o_label, mainFrame, 0, -3, o_labelString, o_tooltip )
1594 [o_label setAutoresizingMask:NSViewNotSizable ];
1595 [self addSubview: o_label];
1597 /* build the textfield */
1598 ADD_TEXTFIELD( o_textfield, mainFrame, [o_label frame].size.width + 2,
1599 28, 49, o_tooltip, @"" )
1600 [o_textfield setIntValue: p_item->value.i];
1601 [o_textfield setAutoresizingMask:NSViewMaxXMargin ];
1602 [o_textfield setDelegate: self];
1603 [[NSNotificationCenter defaultCenter] addObserver: self
1604 selector: @selector(textfieldChanged:)
1605 name: NSControlTextDidChangeNotification
1606 object: o_textfield];
1607 [self addSubview: o_textfield];
1609 /* build the mintextfield */
1610 ADD_LABEL( o_textfield_min, mainFrame, 12, -30, @"-8888", @"" )
1611 [o_textfield_min setIntValue: p_item->min.i];
1612 [o_textfield_min setAutoresizingMask:NSViewMaxXMargin ];
1613 [o_textfield_min setAlignment:NSRightTextAlignment];
1614 [self addSubview: o_textfield_min];
1616 /* build the maxtextfield */
1617 ADD_LABEL( o_textfield_max, mainFrame,
1618 mainFrame.size.width - 31, -30, @"8888", @"" )
1619 [o_textfield_max setIntValue: p_item->max.i];
1620 [o_textfield_max setAutoresizingMask:NSViewMinXMargin ];
1621 [self addSubview: o_textfield_max];
1623 /* build the slider */
1624 ADD_SLIDER( o_slider, mainFrame, [o_textfield_min frame].origin.x +
1625 [o_textfield_min frame].size.width + 6, -1, mainFrame.size.width -
1626 [o_textfield_max frame].size.width -
1627 [o_textfield_max frame].size.width - 14 -
1628 [o_textfield_min frame].origin.x, o_tooltip,
1629 p_item->min.i, p_item->max.i )
1630 [o_slider setIntValue: p_item->value.i];
1631 [o_slider setAutoresizingMask:NSViewWidthSizable ];
1632 [o_slider setTarget: self];
1633 [o_slider setAction: @selector(sliderChanged:)];
1634 [o_slider sendActionOn:NSLeftMouseUpMask | NSLeftMouseDownMask |
1635 NSLeftMouseDraggedMask];
1636 [self addSubview: o_slider];
1642 - (void) alignWithXPosition:(int)i_xPos
1645 frame = [o_label frame];
1646 frame.origin.x = i_xPos - frame.size.width - 3;
1647 [o_label setFrame:frame];
1649 frame = [o_textfield frame];
1650 frame.origin.x = i_xPos + 2;
1651 [o_textfield setFrame:frame];
1656 [o_textfield release];
1657 [o_textfield_min release];
1658 [o_textfield_max release];
1663 - (IBAction)sliderChanged:(id)sender
1665 [o_textfield setIntValue: [o_slider intValue]];
1668 - (void)textfieldChanged:(NSNotification *)o_notification
1670 [o_slider setIntValue: [o_textfield intValue]];
1675 return [o_slider intValue];
1679 @implementation FloatConfigControl
1680 - (id) initWithItem: (module_config_t *)_p_item
1681 withView: (NSView *)o_parent_view
1683 NSRect mainFrame = [o_parent_view frame];
1684 NSString *o_labelString, *o_tooltip;
1685 mainFrame.size.height = 23;
1686 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN + 1;
1687 mainFrame.origin.x = LEFTMARGIN;
1688 mainFrame.origin.y = 0;
1690 if( [super initWithFrame: mainFrame item: _p_item] != nil )
1692 i_view_type = CONFIG_ITEM_INTEGER;
1694 o_tooltip = [[VLCMain sharedInstance] wrapString:
1695 [[VLCMain sharedInstance]
1696 localizedString: (char *)p_item->psz_longtext ] toWidth: PREFS_WRAP];
1699 if( p_item->psz_text )
1700 o_labelString = [[VLCMain sharedInstance]
1701 localizedString: (char *)p_item->psz_text];
1703 o_labelString = [NSString stringWithString:@""];
1704 ADD_LABEL( o_label, mainFrame, 0, -2, o_labelString, o_tooltip )
1705 [o_label setAutoresizingMask:NSViewNotSizable ];
1706 [self addSubview: o_label];
1708 /* build the stepper */
1709 ADD_STEPPER( o_stepper, mainFrame, mainFrame.size.width - 19,
1710 0, o_tooltip, -100000, 100000)
1711 [o_stepper setFloatValue: p_item->value.f];
1712 [o_stepper setAutoresizingMask:NSViewMaxXMargin ];
1713 [self addSubview: o_stepper];
1715 /* build the textfield */
1716 ADD_TEXTFIELD( o_textfield, mainFrame, mainFrame.size.width - 19 - 52,
1717 1, 49, o_tooltip, @"" )
1718 [o_textfield setFloatValue: p_item->value.f];
1719 [o_textfield setDelegate: self];
1720 [[NSNotificationCenter defaultCenter] addObserver: self
1721 selector: @selector(textfieldChanged:)
1722 name: NSControlTextDidChangeNotification
1723 object: o_textfield];
1724 [o_textfield setAutoresizingMask:NSViewMaxXMargin ];
1725 [self addSubview: o_textfield];
1730 - (void) alignWithXPosition:(int)i_xPos
1733 frame = [o_label frame];
1734 frame.origin.x = i_xPos - frame.size.width - 3;
1735 [o_label setFrame:frame];
1737 frame = [o_textfield frame];
1738 frame.origin.x = i_xPos + 2;
1739 [o_textfield setFrame:frame];
1741 frame = [o_stepper frame];
1742 frame.origin.x = i_xPos + [o_textfield frame].size.width + 5;
1743 [o_stepper setFrame:frame];
1748 [o_stepper release];
1749 [o_textfield release];
1753 - (IBAction)stepperChanged:(id)sender
1755 [o_textfield setFloatValue: [o_stepper floatValue]];
1758 - (void)textfieldChanged:(NSNotification *)o_notification
1760 [o_stepper setFloatValue: [o_textfield floatValue]];
1765 return [o_stepper floatValue];
1769 @implementation RangedFloatConfigControl
1770 - (id) initWithItem: (module_config_t *)_p_item
1771 withView: (NSView *)o_parent_view
1773 NSRect mainFrame = [o_parent_view frame];
1774 NSString *o_labelString, *o_tooltip;
1775 mainFrame.size.height = 50;
1776 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN;
1777 mainFrame.origin.x = LEFTMARGIN;
1778 mainFrame.origin.y = 0;
1780 if( [super initWithFrame: mainFrame item: _p_item] != nil )
1782 i_view_type = CONFIG_ITEM_RANGED_INTEGER;
1784 o_tooltip = [[VLCMain sharedInstance] wrapString:
1785 [[VLCMain sharedInstance]
1786 localizedString: (char *)p_item->psz_longtext ] toWidth: PREFS_WRAP];
1789 if( p_item->psz_text )
1790 o_labelString = [[VLCMain sharedInstance]
1791 localizedString: (char *)p_item->psz_text];
1793 o_labelString = [NSString stringWithString:@""];
1794 ADD_LABEL( o_label, mainFrame, 0, -3, o_labelString, o_tooltip )
1795 [o_label setAutoresizingMask:NSViewNotSizable ];
1796 [self addSubview: o_label];
1798 /* build the textfield */
1799 ADD_TEXTFIELD( o_textfield, mainFrame, [o_label frame].size.width + 2,
1800 28, 49, o_tooltip, @"" )
1801 [o_textfield setFloatValue: p_item->value.f];
1802 [o_textfield setAutoresizingMask:NSViewMaxXMargin ];
1803 [o_textfield setDelegate: self];
1804 [[NSNotificationCenter defaultCenter] addObserver: self
1805 selector: @selector(textfieldChanged:)
1806 name: NSControlTextDidChangeNotification
1807 object: o_textfield];
1808 [self addSubview: o_textfield];
1810 /* build the mintextfield */
1811 ADD_LABEL( o_textfield_min, mainFrame, 12, -30, @"-8888", @"" )
1812 [o_textfield_min setFloatValue: p_item->min.f];
1813 [o_textfield_min setAutoresizingMask:NSViewMaxXMargin ];
1814 [o_textfield_min setAlignment:NSRightTextAlignment];
1815 [self addSubview: o_textfield_min];
1817 /* build the maxtextfield */
1818 ADD_LABEL( o_textfield_max, mainFrame, mainFrame.size.width - 31,
1820 [o_textfield_max setFloatValue: p_item->max.f];
1821 [o_textfield_max setAutoresizingMask:NSViewMinXMargin ];
1822 [self addSubview: o_textfield_max];
1824 /* build the slider */
1825 ADD_SLIDER( o_slider, mainFrame, [o_textfield_min frame].origin.x +
1826 [o_textfield_min frame].size.width + 6, -1, mainFrame.size.width -
1827 [o_textfield_max frame].size.width -
1828 [o_textfield_max frame].size.width - 14 -
1829 [o_textfield_min frame].origin.x, o_tooltip, p_item->min.f,
1831 [o_slider setFloatValue: p_item->value.f];
1832 [o_slider setAutoresizingMask:NSViewWidthSizable ];
1833 [o_slider setTarget: self];
1834 [o_slider setAction: @selector(sliderChanged:)];
1835 [o_slider sendActionOn:NSLeftMouseUpMask | NSLeftMouseDownMask |
1836 NSLeftMouseDraggedMask];
1837 [self addSubview: o_slider];
1843 - (void) alignWithXPosition:(int)i_xPos
1846 frame = [o_label frame];
1847 frame.origin.x = i_xPos - frame.size.width - 3;
1848 [o_label setFrame:frame];
1850 frame = [o_textfield frame];
1851 frame.origin.x = i_xPos + 2;
1852 [o_textfield setFrame:frame];
1857 [o_textfield release];
1858 [o_textfield_min release];
1859 [o_textfield_max release];
1864 - (IBAction)sliderChanged:(id)sender
1866 [o_textfield setFloatValue: [o_slider floatValue]];
1869 - (void)textfieldChanged:(NSNotification *)o_notification
1871 [o_slider setFloatValue: [o_textfield floatValue]];
1876 return [o_slider floatValue];
1881 @implementation BoolConfigControl
1883 - (id) initWithItem: (module_config_t *)_p_item
1884 withView: (NSView *)o_parent_view
1886 NSRect mainFrame = [o_parent_view frame];
1887 NSString *o_labelString, *o_tooltip;
1888 mainFrame.size.height = 17;
1889 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN;
1890 mainFrame.origin.x = LEFTMARGIN;
1891 mainFrame.origin.y = 0;
1893 if( [super initWithFrame: mainFrame item: _p_item] != nil )
1895 i_view_type = CONFIG_ITEM_BOOL;
1897 /* add the checkbox */
1898 o_tooltip = [[VLCMain sharedInstance]
1899 wrapString: [[VLCMain sharedInstance]
1900 localizedString: (char *)p_item->psz_longtext ] toWidth: PREFS_WRAP];
1901 ADD_CHECKBOX( o_checkbox, mainFrame, 0,
1902 0, @"", o_tooltip, p_item->value.i, NSImageLeft)
1903 [o_checkbox setAutoresizingMask:NSViewNotSizable ];
1904 [self addSubview: o_checkbox];
1906 if( p_item->psz_text )
1907 o_labelString = [[VLCMain sharedInstance]
1908 localizedString: (char *)p_item->psz_text];
1910 o_labelString = [NSString stringWithString:@""];
1911 ADD_LABEL( o_label, mainFrame, [o_checkbox frame].size.width, 0, o_labelString, o_tooltip )
1912 [o_label setAutoresizingMask:NSViewNotSizable ];
1913 [self addSubview: o_label];
1920 [o_checkbox release];
1926 return [o_checkbox intValue];
1931 @implementation KeyConfigControl
1932 - (id) initWithItem: (module_config_t *)_p_item
1933 withView: (NSView *)o_parent_view
1935 NSRect mainFrame = [o_parent_view frame];
1936 NSString *o_labelString, *o_tooltip;
1937 mainFrame.size.height = 22;
1938 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN + 1;
1939 mainFrame.origin.x = LEFTMARGIN;
1940 mainFrame.origin.y = 0;
1942 if( [super initWithFrame: mainFrame item: _p_item] != nil )
1944 i_view_type = CONFIG_ITEM_KEY_AFTER_10_3;
1946 o_tooltip = [[VLCMain sharedInstance] wrapString:
1947 [[VLCMain sharedInstance]
1948 localizedString: (char *)p_item->psz_longtext ] toWidth: PREFS_WRAP];
1951 if( p_item->psz_text )
1952 o_labelString = [[VLCMain sharedInstance]
1953 localizedString: (char *)p_item->psz_text];
1955 o_labelString = [NSString stringWithString:@""];
1956 ADD_LABEL( o_label, mainFrame, 0, -1, o_labelString, o_tooltip )
1957 [o_label setAutoresizingMask:NSViewNotSizable ];
1958 [self addSubview: o_label];
1960 /* build the popup */
1961 ADD_POPUP( o_popup, mainFrame, [o_label frame].origin.x +
1962 [o_label frame].size.width + 3,
1964 [o_popup setAutoresizingMask:NSViewWidthSizable ];
1966 if( o_keys_menu == nil )
1969 o_keys_menu = [[NSMenu alloc] initWithTitle: @"Keys Menu"];
1970 for ( i = 0; i < sizeof(vlc_keys) / sizeof(key_descriptor_t); i++)
1971 if( vlc_keys[i].psz_key_string )
1972 POPULATE_A_KEY( o_keys_menu,
1973 [NSString stringWithUTF8String:vlc_keys[i].psz_key_string]
1974 , vlc_keys[i].i_key_code)
1976 [o_popup setMenu:[o_keys_menu copyWithZone:nil]];
1977 [o_popup selectItem:[[o_popup menu] itemWithTag:p_item->value.i]];
1978 [self addSubview: o_popup];
1984 - (void) alignWithXPosition:(int)i_xPos
1987 NSRect superFrame = [self frame];
1988 frame = [o_label frame];
1989 frame.origin.x = i_xPos - frame.size.width - 3;
1990 [o_label setFrame:frame];
1992 frame = [o_popup frame];
1993 frame.origin.x = i_xPos - 1;
1994 frame.size.width = superFrame.size.width - frame.origin.x + 2;
1995 [o_popup setFrame:frame];
2006 return [o_popup selectedTag];
2010 @implementation ModuleListConfigControl
2011 - (id) initWithItem: (module_config_t *)_p_item
2012 withView: (NSView *)o_parent_view
2014 if( _p_item->i_type == CONFIG_ITEM_MODULE_LIST )
2018 //Fill our array to know how may items we have...
2019 module_t *p_parser, **p_list;
2020 size_t i_module_index;
2021 NSRect mainFrame = [o_parent_view frame];
2022 NSString *o_labelString, *o_textfieldString, *o_tooltip;
2024 o_modulearray = [[NSMutableArray alloc] initWithCapacity:10];
2025 /* build a list of available modules */
2026 p_list = module_list_get( NULL );
2027 for( i_module_index = 0; p_list[i_module_index]; i_module_index++ )
2030 p_parser = p_list[i_module_index];
2032 if( module_is_main( p_parser ) )
2035 unsigned int confsize;
2036 module_config_get( p_parser, &confsize );
2038 for ( i = 0; i < confsize; i++ )
2040 unsigned int unused;
2041 module_config_t *p_config = module_config_get( p_parser, &unused ) + i;
2042 NSString *o_modulelongname, *o_modulename;
2043 NSNumber *o_moduleenabled = nil;
2045 /* Hack: required subcategory is stored in i_min */
2046 if( p_config->i_type == CONFIG_SUBCATEGORY &&
2047 p_config->value.i == _p_item->min.i )
2049 o_modulelongname = [NSString stringWithUTF8String:
2050 module_GetLongName( p_parser )];
2051 o_modulename = [NSString stringWithUTF8String:
2052 module_get_object( p_parser )];
2054 if( _p_item->value.psz &&
2055 strstr( _p_item->value.psz, module_get_object( p_parser ) ) )
2056 o_moduleenabled = [NSNumber numberWithBool:YES];
2058 o_moduleenabled = [NSNumber numberWithBool:NO];
2060 [o_modulearray addObject:[NSMutableArray
2061 arrayWithObjects: o_modulename, o_modulelongname,
2062 o_moduleenabled, nil]];
2066 module_list_free( p_list );
2068 mainFrame.size.height = 30 + 18 * [o_modulearray count];
2069 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN;
2070 mainFrame.origin.x = LEFTMARGIN;
2071 mainFrame.origin.y = 0;
2072 if( [super initWithFrame: mainFrame item: _p_item] != nil )
2074 i_view_type = CONFIG_ITEM_MODULE_LIST;
2076 o_tooltip = [[VLCMain sharedInstance] wrapString:
2077 [[VLCMain sharedInstance]
2078 localizedString: (char *)p_item->psz_longtext ] toWidth: PREFS_WRAP];
2081 if( p_item->psz_text )
2082 o_labelString = [[VLCMain sharedInstance]
2083 localizedString: (char *)p_item->psz_text];
2085 o_labelString = [NSString stringWithString:@""];
2086 ADD_LABEL( o_label, mainFrame, 0, -3, o_labelString, o_tooltip )
2087 [o_label setAutoresizingMask:NSViewNotSizable ];
2088 [self addSubview: o_label];
2090 /* build the textfield */
2091 if( p_item->value.psz )
2092 o_textfieldString = [[VLCMain sharedInstance]
2093 localizedString: (char *)p_item->value.psz];
2095 o_textfieldString = [NSString stringWithString: @""];
2096 ADD_TEXTFIELD( o_textfield, mainFrame, [o_label frame].size.width + 2,
2097 mainFrame.size.height - 22, mainFrame.size.width -
2098 [o_label frame].size.width - 2, o_tooltip, o_textfieldString )
2099 [o_textfield setAutoresizingMask:NSViewWidthSizable ];
2100 [self addSubview: o_textfield];
2104 NSRect s_rc = mainFrame;
2105 s_rc.size.height = mainFrame.size.height - 30;
2106 s_rc.size.width = mainFrame.size.width - 12;
2109 o_scrollview = [[[NSScrollView alloc] initWithFrame: s_rc] retain];
2110 [o_scrollview setDrawsBackground: NO];
2111 [o_scrollview setBorderType: NSBezelBorder];
2112 [o_scrollview setAutohidesScrollers:YES];
2114 NSTableView *o_tableview;
2115 o_tableview = [[NSTableView alloc] initWithFrame : s_rc];
2116 [o_tableview setUsesAlternatingRowBackgroundColors:YES];
2117 [o_tableview setHeaderView:nil];
2118 /* TODO: find a good way to fix the row height and text size*/
2119 /* FIXME: support for multiple selection... */
2120 // [o_tableview setAllowsMultipleSelection:YES];
2122 NSCell *o_headerCell = [[NSCell alloc] initTextCell:@"Enabled"];
2123 NSCell *o_dataCell = [[NSButtonCell alloc] init];
2124 [(NSButtonCell*)o_dataCell setButtonType:NSSwitchButton];
2125 [o_dataCell setTitle:@""];
2126 [o_dataCell setFont:[NSFont systemFontOfSize:0]];
2127 NSTableColumn *o_tableColumn = [[NSTableColumn alloc]
2128 initWithIdentifier:@"Enabled"];
2129 [o_tableColumn setHeaderCell: o_headerCell];
2130 [o_tableColumn setDataCell: o_dataCell];
2131 [o_tableColumn setWidth:17];
2132 [o_tableview addTableColumn: o_tableColumn];
2134 o_headerCell = [[NSCell alloc] initTextCell:@"Module Name"];
2135 o_dataCell = [[NSTextFieldCell alloc] init];
2136 [o_dataCell setFont:[NSFont systemFontOfSize:12]];
2137 o_tableColumn = [[NSTableColumn alloc]
2138 initWithIdentifier:@"Module"];
2139 [o_tableColumn setHeaderCell: o_headerCell];
2140 [o_tableColumn setDataCell: o_dataCell];
2141 [o_tableColumn setWidth:388 - 17];
2142 [o_tableview addTableColumn: o_tableColumn];
2143 [o_tableview registerForDraggedTypes:[NSArray arrayWithObjects:
2144 @"VLC media player module", nil]];
2146 [o_tableview setDataSource:self];
2147 [o_tableview setTarget: self];
2148 [o_tableview setAction: @selector(tableChanged:)];
2149 [o_tableview sendActionOn:NSLeftMouseUpMask | NSLeftMouseDownMask |
2150 NSLeftMouseDraggedMask];
2151 [o_scrollview setDocumentView: o_tableview];
2153 [o_scrollview setAutoresizingMask:NSViewWidthSizable ];
2154 [self addSubview: o_scrollview];
2161 - (void) alignWithXPosition:(int)i_xPos
2166 - (IBAction)tableChanged:(id)sender
2168 NSString *o_newstring = @"";
2170 for( i = 0 ; i < [o_modulearray count] ; i++ )
2171 if( [[[o_modulearray objectAtIndex:i] objectAtIndex:2]
2174 o_newstring = [o_newstring stringByAppendingString:
2175 [[o_modulearray objectAtIndex:i] objectAtIndex:0]];
2176 o_newstring = [o_newstring stringByAppendingString:@":"];
2179 [o_textfield setStringValue: [o_newstring
2180 substringToIndex: ([o_newstring length])?[o_newstring length] - 1:0]];
2185 [o_scrollview release];
2190 - (char *)stringValue
2192 return strdup( [[o_textfield stringValue] UTF8String] );
2197 @implementation ModuleListConfigControl (NSTableDataSource)
2199 - (BOOL)tableView:(NSTableView*)table writeRows:(NSArray*)rows
2200 toPasteboard:(NSPasteboard*)pb
2202 // We only want to allow dragging of selected rows.
2203 NSEnumerator *iter = [rows objectEnumerator];
2205 while ((row = [iter nextObject]) != nil)
2207 if (![table isRowSelected:[row intValue]])
2211 [pb declareTypes:[NSArray
2212 arrayWithObject:@"VLC media player module"] owner:nil];
2213 [pb setPropertyList:rows forType:@"VLC media player module"];
2217 - (NSDragOperation)tableView:(NSTableView*)table
2218 validateDrop:(id <NSDraggingInfo>)info proposedRow:(NSInteger)row
2219 proposedDropOperation:(NSTableViewDropOperation)op
2221 // Make drops at the end of the table go to the end.
2224 row = [table numberOfRows];
2225 op = NSTableViewDropAbove;
2226 [table setDropRow:row dropOperation:op];
2229 // We don't ever want to drop onto a row, only between rows.
2230 if (op == NSTableViewDropOn)
2231 [table setDropRow:(row+1) dropOperation:NSTableViewDropAbove];
2232 return NSTableViewDropAbove;
2235 - (BOOL)tableView:(NSTableView*)table acceptDrop:(id <NSDraggingInfo>)info
2236 row:(NSInteger)dropRow dropOperation:(NSTableViewDropOperation)op;
2238 NSPasteboard *pb = [info draggingPasteboard];
2239 NSDragOperation srcMask = [info draggingSourceOperationMask];
2246 // Intra-table drag - data is the array of rows.
2247 if (!accepted && (array =
2248 [pb propertyListForType:@"VLC media player module"]) != NULL)
2250 NSEnumerator *iter = nil;
2252 BOOL isCopy = (srcMask & NSDragOperationMove) ? NO:YES;
2254 iter = [array objectEnumerator];
2255 while ((val = [iter nextObject]) != NULL)
2257 NSArray *o_tmp = [[o_modulearray objectAtIndex:
2258 [val intValue]] mutableCopyWithZone:nil];
2259 [o_modulearray removeObject:o_tmp];
2260 [o_modulearray insertObject:o_tmp
2261 atIndex:(dropRow>[val intValue]) ? dropRow - 1 : dropRow];
2265 // Select the newly-dragged items.
2266 iter = [array objectEnumerator];
2268 [table deselectAll:self];
2270 [self tableChanged:self];
2271 [table setNeedsDisplay:YES];
2272 // Indicate that we finished the drag.
2276 [table setNeedsDisplay:YES];
2280 // An exception occurred. Uh-oh. Update the track table so that
2281 // it stays consistent, and re-raise the exception.
2283 [localException raise];
2284 [table setNeedsDisplay:YES];
2290 - (NSInteger)numberOfRowsInTableView:(NSTableView *)aTableView
2292 return [o_modulearray count];
2295 - (id)tableView:(NSTableView *)aTableView
2296 objectValueForTableColumn:(NSTableColumn *)aTableColumn row:(NSInteger)rowIndex
2298 if( [[aTableColumn identifier] isEqualToString: @"Enabled"] )
2299 return [[o_modulearray objectAtIndex:rowIndex] objectAtIndex:2];
2300 if( [[aTableColumn identifier] isEqualToString: @"Module"] )
2301 return [[o_modulearray objectAtIndex:rowIndex] objectAtIndex:1];
2306 - (void)tableView:(NSTableView *)aTableView setObjectValue:(id)anObject
2307 forTableColumn:(NSTableColumn *)aTableColumn row:(NSInteger)rowIndex
2309 [[o_modulearray objectAtIndex:rowIndex] replaceObjectAtIndex:2
2310 withObject: anObject];