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 "prefs_widgets.h"
37 #define PREFS_WRAP 300
38 #define OFFSET_RIGHT 20
39 #define OFFSET_BETWEEN 2
41 #define UPWARDS_WHITE_ARROW "\xE2\x87\xA7"
42 #define OPTION_KEY "\xE2\x8C\xA5"
43 #define UP_ARROWHEAD "\xE2\x8C\x83"
44 #define PLACE_OF_INTEREST_SIGN "\xE2\x8C\x98"
46 #define POPULATE_A_KEY( o_menu, string, value ) \
50 o_mi = [[NSMenuItem alloc] initWithTitle:string \
51 action:nil keyEquivalent:@""]; \
52 [o_mi setKeyEquivalentModifierMask: \
54 [o_mi setAlternate: NO]; \
57 [o_menu addItem: o_mi]; \
59 o_mi = [[NSMenuItem alloc] initWithTitle: \
60 [[NSString stringWithUTF8String: \
62 ] stringByAppendingString: string] \
63 action:nil keyEquivalent:@""]; \
64 [o_mi setKeyEquivalentModifierMask: \
66 [o_mi setAlternate: YES]; \
68 KEY_MODIFIER_CTRL | ( value )]; \
69 [o_menu addItem: o_mi]; \
71 o_mi = [[NSMenuItem alloc] initWithTitle: \
72 [[NSString stringWithUTF8String: \
73 UP_ARROWHEAD OPTION_KEY \
74 ] stringByAppendingString: string] \
75 action:nil keyEquivalent:@""]; \
76 [o_mi setKeyEquivalentModifierMask: \
77 NSControlKeyMask | NSAlternateKeyMask]; \
78 [o_mi setAlternate: YES]; \
80 (KEY_MODIFIER_CTRL | KEY_MODIFIER_ALT) | ( value )]; \
81 [o_menu addItem: o_mi]; \
83 o_mi = [[NSMenuItem alloc] initWithTitle: \
84 [[NSString stringWithUTF8String: \
85 UP_ARROWHEAD UPWARDS_WHITE_ARROW \
86 ] stringByAppendingString: string] \
87 action:nil keyEquivalent:@""]; \
88 [o_mi setKeyEquivalentModifierMask: \
89 NSControlKeyMask | NSShiftKeyMask]; \
90 [o_mi setAlternate: YES]; \
92 (KEY_MODIFIER_CTRL | KEY_MODIFIER_SHIFT) | ( value )]; \
93 [o_menu addItem: o_mi]; \
95 o_mi = [[NSMenuItem alloc] initWithTitle: \
96 [[NSString stringWithUTF8String: \
97 UP_ARROWHEAD PLACE_OF_INTEREST_SIGN \
98 ] stringByAppendingString: string] \
99 action:nil keyEquivalent:@""]; \
100 [o_mi setKeyEquivalentModifierMask: \
101 NSControlKeyMask | NSCommandKeyMask]; \
102 [o_mi setAlternate: YES]; \
104 (KEY_MODIFIER_CTRL | KEY_MODIFIER_COMMAND) | ( value )]; \
105 [o_menu addItem: o_mi]; \
106 /* Ctrl+Alt+Shift */ \
107 o_mi = [[NSMenuItem alloc] initWithTitle: \
108 [[NSString stringWithUTF8String: \
109 UP_ARROWHEAD OPTION_KEY UPWARDS_WHITE_ARROW \
110 ] stringByAppendingString: string] \
111 action:nil keyEquivalent:@""]; \
112 [o_mi setKeyEquivalentModifierMask: \
113 NSControlKeyMask | NSAlternateKeyMask | NSShiftKeyMask]; \
114 [o_mi setAlternate: YES]; \
116 (KEY_MODIFIER_CTRL | KEY_MODIFIER_ALT | KEY_MODIFIER_SHIFT) | \
118 [o_menu addItem: o_mi]; \
119 /* Ctrl+Alt+Apple */ \
120 o_mi = [[NSMenuItem alloc] initWithTitle: \
121 [[NSString stringWithUTF8String: \
122 UP_ARROWHEAD OPTION_KEY PLACE_OF_INTEREST_SIGN \
123 ] stringByAppendingString: string] \
124 action:nil keyEquivalent:@""]; \
125 [o_mi setKeyEquivalentModifierMask: \
126 NSControlKeyMask | NSAlternateKeyMask | NSCommandKeyMask]; \
127 [o_mi setAlternate: YES]; \
129 (KEY_MODIFIER_CTRL | KEY_MODIFIER_ALT | KEY_MODIFIER_COMMAND) | \
131 [o_menu addItem: o_mi]; \
132 /* Ctrl+Shift+Apple */ \
133 o_mi = [[NSMenuItem alloc] initWithTitle: \
134 [[NSString stringWithUTF8String: \
135 UP_ARROWHEAD UPWARDS_WHITE_ARROW PLACE_OF_INTEREST_SIGN \
136 ] stringByAppendingString: string] \
137 action:nil keyEquivalent:@""]; \
138 [o_mi setKeyEquivalentModifierMask: \
139 NSControlKeyMask | NSShiftKeyMask | NSCommandKeyMask]; \
140 [o_mi setAlternate: YES]; \
142 (KEY_MODIFIER_CTRL | KEY_MODIFIER_SHIFT | KEY_MODIFIER_COMMAND) | \
144 [o_menu addItem: o_mi]; \
145 /* Ctrl+Alt+Shift+Apple */ \
146 o_mi = [[NSMenuItem alloc] initWithTitle: \
147 [[NSString stringWithUTF8String: \
148 UP_ARROWHEAD OPTION_KEY UPWARDS_WHITE_ARROW \
149 PLACE_OF_INTEREST_SIGN \
150 ] stringByAppendingString: string] \
151 action:nil keyEquivalent:@""]; \
152 [o_mi setKeyEquivalentModifierMask: \
153 NSControlKeyMask | NSAlternateKeyMask | NSShiftKeyMask | \
155 [o_mi setAlternate: YES]; \
157 (KEY_MODIFIER_CTRL | KEY_MODIFIER_ALT | KEY_MODIFIER_SHIFT | \
158 KEY_MODIFIER_COMMAND) | ( value )]; \
159 [o_menu addItem: o_mi]; \
161 o_mi = [[NSMenuItem alloc] initWithTitle: \
162 [[NSString stringWithUTF8String: \
164 ] stringByAppendingString: string] \
165 action:nil keyEquivalent:@""]; \
166 [o_mi setKeyEquivalentModifierMask: \
167 NSAlternateKeyMask]; \
168 [o_mi setAlternate: YES]; \
170 KEY_MODIFIER_ALT | ( value )]; \
171 [o_menu addItem: o_mi]; \
173 o_mi = [[NSMenuItem alloc] initWithTitle: \
174 [[NSString stringWithUTF8String: \
175 OPTION_KEY UPWARDS_WHITE_ARROW \
176 ] stringByAppendingString: string] \
177 action:nil keyEquivalent:@""]; \
178 [o_mi setKeyEquivalentModifierMask: \
179 NSAlternateKeyMask | NSShiftKeyMask]; \
180 [o_mi setAlternate: YES]; \
182 (KEY_MODIFIER_ALT | KEY_MODIFIER_SHIFT) | ( value )]; \
183 [o_menu addItem: o_mi]; \
185 o_mi = [[NSMenuItem alloc] initWithTitle: \
186 [[NSString stringWithUTF8String: \
187 OPTION_KEY PLACE_OF_INTEREST_SIGN \
188 ] stringByAppendingString: string] \
189 action:nil keyEquivalent:@""]; \
190 [o_mi setKeyEquivalentModifierMask: \
191 NSAlternateKeyMask | NSCommandKeyMask]; \
192 [o_mi setAlternate: YES]; \
194 (KEY_MODIFIER_ALT | KEY_MODIFIER_COMMAND) | ( value )]; \
195 [o_menu addItem: o_mi]; \
196 /* Alt+Shift+Apple */ \
197 o_mi = [[NSMenuItem alloc] initWithTitle: \
198 [[NSString stringWithUTF8String: \
199 OPTION_KEY UPWARDS_WHITE_ARROW PLACE_OF_INTEREST_SIGN \
200 ] stringByAppendingString: string] \
201 action:nil keyEquivalent:@""]; \
202 [o_mi setKeyEquivalentModifierMask: \
203 NSAlternateKeyMask | NSShiftKeyMask | NSCommandKeyMask]; \
204 [o_mi setAlternate: YES]; \
206 (KEY_MODIFIER_ALT | KEY_MODIFIER_SHIFT | KEY_MODIFIER_COMMAND) | \
208 [o_menu addItem: o_mi]; \
210 o_mi = [[NSMenuItem alloc] initWithTitle: \
211 [[NSString stringWithUTF8String: \
212 UPWARDS_WHITE_ARROW \
213 ] stringByAppendingString: string] \
214 action:nil keyEquivalent:@""]; \
215 [o_mi setKeyEquivalentModifierMask: \
217 [o_mi setAlternate: YES]; \
219 KEY_MODIFIER_SHIFT | ( value )]; \
220 [o_menu addItem: o_mi]; \
222 o_mi = [[NSMenuItem alloc] initWithTitle: \
223 [[NSString stringWithUTF8String: \
224 UPWARDS_WHITE_ARROW PLACE_OF_INTEREST_SIGN \
225 ] stringByAppendingString: string] \
226 action:nil keyEquivalent:@""]; \
227 [o_mi setKeyEquivalentModifierMask: \
228 NSShiftKeyMask | NSCommandKeyMask]; \
229 [o_mi setAlternate: YES]; \
231 (KEY_MODIFIER_SHIFT | KEY_MODIFIER_COMMAND) | ( value )]; \
232 [o_menu addItem: o_mi]; \
234 o_mi = [[NSMenuItem alloc] initWithTitle: \
235 [[NSString stringWithUTF8String: \
236 PLACE_OF_INTEREST_SIGN \
237 ] stringByAppendingString: string] \
238 action:nil keyEquivalent:@""]; \
239 [o_mi setKeyEquivalentModifierMask: \
241 [o_mi setAlternate: YES]; \
243 KEY_MODIFIER_COMMAND | ( value )]; \
244 [o_menu addItem: o_mi]; \
247 #define ADD_LABEL( o_label, superFrame, x_offset, my_y_offset, label ) \
249 NSRect s_rc = superFrame; \
250 s_rc.size.height = 17; \
251 s_rc.origin.x = x_offset - 3; \
252 s_rc.origin.y = superFrame.size.height - 17 + my_y_offset; \
253 o_label = [[[NSTextField alloc] initWithFrame: s_rc] retain]; \
254 [o_label setDrawsBackground: NO]; \
255 [o_label setBordered: NO]; \
256 [o_label setEditable: NO]; \
257 [o_label setSelectable: NO]; \
258 [o_label setStringValue: label]; \
259 [o_label setFont:[NSFont systemFontOfSize:0]]; \
260 [o_label sizeToFit]; \
263 #define ADD_TEXTFIELD( o_textfield, superFrame, x_offset, my_y_offset, \
264 my_width, tooltip, init_value ) \
266 NSRect s_rc = superFrame; \
267 s_rc.origin.x = x_offset; \
268 s_rc.origin.y = my_y_offset; \
269 s_rc.size.height = 22; \
270 s_rc.size.width = my_width; \
271 o_textfield = [[[NSTextField alloc] initWithFrame: s_rc] retain]; \
272 [o_textfield setFont:[NSFont systemFontOfSize:0]]; \
273 [o_textfield setToolTip: tooltip]; \
274 [o_textfield setStringValue: init_value]; \
277 #define ADD_COMBO( o_combo, superFrame, x_offset, my_y_offset, x2_offset, \
280 NSRect s_rc = superFrame; \
281 s_rc.origin.x = x_offset + 2; \
282 s_rc.origin.y = my_y_offset; \
283 s_rc.size.height = 26; \
284 s_rc.size.width = superFrame.size.width + 2 - s_rc.origin.x - \
286 o_combo = [[[NSComboBox alloc] initWithFrame: s_rc] retain]; \
287 [o_combo setFont:[NSFont systemFontOfSize:0]]; \
288 [o_combo setToolTip: tooltip]; \
289 [o_combo setUsesDataSource:TRUE]; \
290 [o_combo setDataSource:self]; \
291 [o_combo setNumberOfVisibleItems:10]; \
292 [o_combo setCompletes:YES]; \
295 #define ADD_RIGHT_BUTTON( o_button, superFrame, x_offset, my_y_offset, \
298 NSRect s_rc = superFrame; \
299 o_button = [[[NSButton alloc] initWithFrame: s_rc] retain]; \
300 [o_button setButtonType: NSMomentaryPushInButton]; \
301 [o_button setBezelStyle: NSRoundedBezelStyle]; \
302 [o_button setTitle: title]; \
303 [o_button setFont:[NSFont systemFontOfSize:0]]; \
304 [o_button sizeToFit]; \
305 s_rc = [o_button frame]; \
306 s_rc.origin.x = superFrame.size.width - [o_button frame].size.width - 6;\
307 s_rc.origin.y = my_y_offset - 6; \
308 s_rc.size.width += 12; \
309 [o_button setFrame: s_rc]; \
310 [o_button setToolTip: tooltip]; \
311 [o_button setTarget: self]; \
312 [o_button setAction: @selector(openFileDialog:)]; \
315 #define ADD_POPUP( o_popup, superFrame, x_offset, my_y_offset, x2_offset, \
318 NSRect s_rc = superFrame; \
319 s_rc.origin.x = x_offset - 1; \
320 s_rc.origin.y = my_y_offset; \
321 s_rc.size.height = 26; \
322 s_rc.size.width = superFrame.size.width + 2 - s_rc.origin.x - \
324 o_popup = [[[NSPopUpButton alloc] initWithFrame: s_rc] retain]; \
325 [o_popup setFont:[NSFont systemFontOfSize:0]]; \
326 [o_popup setToolTip: tooltip]; \
329 #define ADD_STEPPER( o_stepper, superFrame, x_offset, my_y_offset, tooltip, \
332 NSRect s_rc = superFrame; \
333 s_rc.origin.x = x_offset; \
334 s_rc.origin.y = my_y_offset; \
335 s_rc.size.height = 23; \
336 s_rc.size.width = 23; \
337 o_stepper = [[[NSStepper alloc] initWithFrame: s_rc] retain]; \
338 [o_stepper setFont:[NSFont systemFontOfSize:0]]; \
339 [o_stepper setToolTip: tooltip]; \
340 [o_stepper setMaxValue: higher]; \
341 [o_stepper setMinValue: lower]; \
342 [o_stepper setTarget: self]; \
343 [o_stepper setAction: @selector(stepperChanged:)]; \
344 [o_stepper sendActionOn:NSLeftMouseUpMask | NSLeftMouseDownMask | \
345 NSLeftMouseDraggedMask]; \
348 #define ADD_SLIDER( o_slider, superFrame, x_offset, my_y_offset, my_width, \
349 tooltip, lower, higher ) \
351 NSRect s_rc = superFrame; \
352 s_rc.origin.x = x_offset; \
353 s_rc.origin.y = my_y_offset; \
354 s_rc.size.height = 21; \
355 s_rc.size.width = my_width; \
356 o_slider = [[[NSSlider alloc] initWithFrame: s_rc] retain]; \
357 [o_slider setFont:[NSFont systemFontOfSize:0]]; \
358 [o_slider setToolTip: tooltip]; \
359 [o_slider setMaxValue: higher]; \
360 [o_slider setMinValue: lower]; \
363 #define ADD_CHECKBOX( o_checkbox, superFrame, x_offset, my_y_offset, label, \
364 tooltip, init_value, position ) \
366 NSRect s_rc = superFrame; \
367 s_rc.size.height = 18; \
368 s_rc.origin.x = x_offset - 2; \
369 s_rc.origin.y = superFrame.size.height - 18 + my_y_offset; \
370 o_checkbox = [[[NSButton alloc] initWithFrame: s_rc] retain]; \
371 [o_checkbox setFont:[NSFont systemFontOfSize:0]]; \
372 [o_checkbox setButtonType: NSSwitchButton]; \
373 [o_checkbox setImagePosition: position]; \
374 [o_checkbox setIntValue: init_value]; \
375 [o_checkbox setTitle: label]; \
376 [o_checkbox setToolTip: tooltip]; \
377 [o_checkbox sizeToFit]; \
380 @implementation VLCConfigControl
381 - (id)initWithFrame: (NSRect)frame
383 return [self initWithFrame: frame
387 - (id)initWithFrame: (NSRect)frame
388 item: (module_config_t *)_p_item
390 self = [super initWithFrame: frame];
395 psz_name = strdup( p_item->psz_name );
397 i_type = p_item->i_type;
399 b_advanced = p_item->b_advanced;
400 [self setAutoresizingMask:NSViewWidthSizable | NSViewMinYMargin ];
405 - (void)setYPos:(int)i_yPos
407 NSRect frame = [self frame];
408 frame.origin.y = i_yPos;
409 [self setFrame:frame];
415 /* since dealloc isn't called on 10.5 if GC is enabled and since GC is
416 * Obj-C only, we need to do this: */
417 if( psz_name ) free( psz_name );
424 if( o_label ) [o_label release];
425 if( psz_name ) free( psz_name );
429 + (int)calcVerticalMargin: (int)i_curItem lastItem: (int)i_lastItem
434 case CONFIG_ITEM_STRING:
437 case CONFIG_ITEM_STRING:
440 case CONFIG_ITEM_STRING_LIST:
443 case CONFIG_ITEM_FILE:
446 case CONFIG_ITEM_MODULE:
449 case CONFIG_ITEM_INTEGER:
452 case CONFIG_ITEM_RANGED_INTEGER:
455 case CONFIG_ITEM_BOOL:
458 case CONFIG_ITEM_KEY_BEFORE_10_3:
461 case CONFIG_ITEM_KEY_AFTER_10_3:
464 case CONFIG_ITEM_MODULE_LIST:
472 case CONFIG_ITEM_STRING_LIST:
475 case CONFIG_ITEM_STRING:
478 case CONFIG_ITEM_STRING_LIST:
481 case CONFIG_ITEM_FILE:
484 case CONFIG_ITEM_MODULE:
487 case CONFIG_ITEM_INTEGER:
490 case CONFIG_ITEM_RANGED_INTEGER:
493 case CONFIG_ITEM_BOOL:
496 case CONFIG_ITEM_KEY_BEFORE_10_3:
499 case CONFIG_ITEM_KEY_AFTER_10_3:
502 case CONFIG_ITEM_MODULE_LIST:
510 case CONFIG_ITEM_FILE:
513 case CONFIG_ITEM_STRING:
516 case CONFIG_ITEM_STRING_LIST:
519 case CONFIG_ITEM_FILE:
522 case CONFIG_ITEM_MODULE:
525 case CONFIG_ITEM_INTEGER:
528 case CONFIG_ITEM_RANGED_INTEGER:
531 case CONFIG_ITEM_BOOL:
534 case CONFIG_ITEM_KEY_BEFORE_10_3:
537 case CONFIG_ITEM_KEY_AFTER_10_3:
540 case CONFIG_ITEM_MODULE_LIST:
548 case CONFIG_ITEM_MODULE:
551 case CONFIG_ITEM_STRING:
554 case CONFIG_ITEM_STRING_LIST:
557 case CONFIG_ITEM_FILE:
560 case CONFIG_ITEM_MODULE:
563 case CONFIG_ITEM_INTEGER:
566 case CONFIG_ITEM_RANGED_INTEGER:
569 case CONFIG_ITEM_BOOL:
572 case CONFIG_ITEM_KEY_BEFORE_10_3:
575 case CONFIG_ITEM_KEY_AFTER_10_3:
578 case CONFIG_ITEM_MODULE_LIST:
586 case CONFIG_ITEM_INTEGER:
589 case CONFIG_ITEM_STRING:
592 case CONFIG_ITEM_STRING_LIST:
595 case CONFIG_ITEM_FILE:
598 case CONFIG_ITEM_MODULE:
601 case CONFIG_ITEM_INTEGER:
604 case CONFIG_ITEM_RANGED_INTEGER:
607 case CONFIG_ITEM_BOOL:
610 case CONFIG_ITEM_KEY_BEFORE_10_3:
613 case CONFIG_ITEM_KEY_AFTER_10_3:
616 case CONFIG_ITEM_MODULE_LIST:
624 case CONFIG_ITEM_RANGED_INTEGER:
627 case CONFIG_ITEM_STRING:
630 case CONFIG_ITEM_STRING_LIST:
633 case CONFIG_ITEM_FILE:
636 case CONFIG_ITEM_MODULE:
639 case CONFIG_ITEM_INTEGER:
642 case CONFIG_ITEM_RANGED_INTEGER:
645 case CONFIG_ITEM_BOOL:
648 case CONFIG_ITEM_KEY_BEFORE_10_3:
651 case CONFIG_ITEM_KEY_AFTER_10_3:
654 case CONFIG_ITEM_MODULE_LIST:
662 case CONFIG_ITEM_BOOL:
665 case CONFIG_ITEM_STRING:
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_BEFORE_10_3:
689 case CONFIG_ITEM_KEY_AFTER_10_3:
692 case CONFIG_ITEM_MODULE_LIST:
700 case CONFIG_ITEM_KEY_BEFORE_10_3:
703 case CONFIG_ITEM_STRING:
706 case CONFIG_ITEM_STRING_LIST:
709 case CONFIG_ITEM_FILE:
712 case CONFIG_ITEM_MODULE:
715 case CONFIG_ITEM_INTEGER:
718 case CONFIG_ITEM_RANGED_INTEGER:
721 case CONFIG_ITEM_BOOL:
724 case CONFIG_ITEM_KEY_BEFORE_10_3:
727 case CONFIG_ITEM_KEY_AFTER_10_3:
730 case CONFIG_ITEM_MODULE_LIST:
738 case CONFIG_ITEM_KEY_AFTER_10_3:
741 case CONFIG_ITEM_STRING:
744 case CONFIG_ITEM_STRING_LIST:
747 case CONFIG_ITEM_FILE:
750 case CONFIG_ITEM_MODULE:
753 case CONFIG_ITEM_INTEGER:
756 case CONFIG_ITEM_RANGED_INTEGER:
759 case CONFIG_ITEM_BOOL:
762 case CONFIG_ITEM_KEY_BEFORE_10_3:
765 case CONFIG_ITEM_KEY_AFTER_10_3:
768 case CONFIG_ITEM_MODULE_LIST:
776 case CONFIG_ITEM_MODULE_LIST:
779 case CONFIG_ITEM_STRING:
782 case CONFIG_ITEM_STRING_LIST:
785 case CONFIG_ITEM_FILE:
788 case CONFIG_ITEM_MODULE:
791 case CONFIG_ITEM_INTEGER:
794 case CONFIG_ITEM_RANGED_INTEGER:
797 case CONFIG_ITEM_BOOL:
800 case CONFIG_ITEM_KEY_BEFORE_10_3:
803 case CONFIG_ITEM_KEY_AFTER_10_3:
806 case CONFIG_ITEM_MODULE_LIST:
821 + (VLCConfigControl *)newControl: (module_config_t *)_p_item
822 withView: (NSView *)o_parent_view
824 VLCConfigControl *p_control = NULL;
825 /* Skip depracated options */
826 if( _p_item->psz_current )
831 switch( _p_item->i_type )
833 case CONFIG_ITEM_STRING:
834 if( !_p_item->i_list )
836 p_control = [[StringConfigControl alloc]
837 initWithItem: _p_item
838 withView: o_parent_view];
842 p_control = [[StringListConfigControl alloc]
843 initWithItem: _p_item
844 withView: o_parent_view];
847 case CONFIG_ITEM_FILE:
848 case CONFIG_ITEM_DIRECTORY:
849 p_control = [[FileConfigControl alloc]
850 initWithItem: _p_item
851 withView: o_parent_view];
853 case CONFIG_ITEM_MODULE:
854 case CONFIG_ITEM_MODULE_CAT:
855 p_control = [[ModuleConfigControl alloc]
856 initWithItem: _p_item
857 withView: o_parent_view];
859 case CONFIG_ITEM_INTEGER:
860 if( _p_item->i_list )
862 p_control = [[IntegerListConfigControl alloc]
863 initWithItem: _p_item
864 withView: o_parent_view];
866 else if( _p_item->min.i != 0 || _p_item->max.i != 0 )
868 p_control = [[RangedIntegerConfigControl alloc]
869 initWithItem: _p_item
870 withView: o_parent_view];
874 p_control = [[IntegerConfigControl alloc]
875 initWithItem: _p_item
876 withView: o_parent_view];
879 case CONFIG_ITEM_BOOL:
880 p_control = [[BoolConfigControl alloc]
881 initWithItem: _p_item
882 withView: o_parent_view];
884 case CONFIG_ITEM_FLOAT:
885 if( _p_item->min.f != 0 || _p_item->max.f != 0 )
887 p_control = [[RangedFloatConfigControl alloc]
888 initWithItem: _p_item
889 withView: o_parent_view];
893 p_control = [[FloatConfigControl alloc]
894 initWithItem: _p_item
895 withView: o_parent_view];
898 case CONFIG_ITEM_KEY:
899 p_control = [[KeyConfigControl alloc]
900 initWithItem: _p_item
901 withView: o_parent_view];
903 case CONFIG_ITEM_MODULE_LIST:
904 case CONFIG_ITEM_MODULE_LIST_CAT:
905 p_control = [[ModuleListConfigControl alloc]
906 initWithItem: _p_item
907 withView: o_parent_view];
915 - (NSString *)getName
917 return [[VLCMain sharedInstance] localizedString: psz_name];
945 - (char *)stringValue
953 switch( p_item->i_type )
955 case CONFIG_ITEM_STRING:
956 case CONFIG_ITEM_FILE:
957 case CONFIG_ITEM_DIRECTORY:
958 case CONFIG_ITEM_MODULE:
959 case CONFIG_ITEM_MODULE_LIST:
960 case CONFIG_ITEM_MODULE_LIST_CAT:
961 config_PutPsz( VLCIntf, psz_name, [self stringValue] );
963 case CONFIG_ITEM_KEY:
964 /* So you don't need to restart to have the changes take effect */
965 val.i_int = [self intValue];
966 var_Set( VLCIntf->p_libvlc, psz_name, val );
967 case CONFIG_ITEM_INTEGER:
968 case CONFIG_ITEM_BOOL:
969 config_PutInt( VLCIntf, psz_name, [self intValue] );
971 case CONFIG_ITEM_FLOAT:
972 config_PutFloat( VLCIntf, psz_name, [self floatValue] );
979 return [o_label frame].size.width;
982 - (void) alignWithXPosition:(int)i_xPos;
984 /* FIXME: not implemented atm, but created to shut up the warning
985 * about "method definition not found" -- FK @ 7/24/05 */
989 @implementation StringConfigControl
990 - (id) initWithItem: (module_config_t *)_p_item
991 withView: (NSView *)o_parent_view
993 NSRect mainFrame = [o_parent_view frame];
994 NSString *o_labelString, *o_textfieldString, *o_textfieldTooltip;
995 mainFrame.size.height = 22;
996 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN;
997 mainFrame.origin.x = LEFTMARGIN;
998 mainFrame.origin.y = 0;
1000 if( [super initWithFrame: mainFrame item: _p_item] != nil )
1002 i_view_type = CONFIG_ITEM_STRING;
1004 if( p_item->psz_text )
1005 o_labelString = [[VLCMain sharedInstance]
1006 localizedString: (char *)p_item->psz_text];
1008 o_labelString = [NSString stringWithString:@""];
1009 ADD_LABEL( o_label, mainFrame, 0, -3, o_labelString )
1010 [o_label setAutoresizingMask:NSViewNotSizable ];
1011 [self addSubview: o_label];
1013 /* build the textfield */
1014 o_textfieldTooltip = [[VLCMain sharedInstance] wrapString:
1015 [[VLCMain sharedInstance] localizedString: (char *)p_item->psz_longtext]
1016 toWidth: PREFS_WRAP];
1017 if( p_item->value.psz )
1018 o_textfieldString = [[VLCMain sharedInstance]
1019 localizedString: (char *)p_item->value.psz];
1021 o_textfieldString = [NSString stringWithString: @""];
1022 ADD_TEXTFIELD( o_textfield, mainFrame, [o_label frame].size.width + 2,
1023 0, mainFrame.size.width - [o_label frame].size.width -
1024 2, o_textfieldTooltip, o_textfieldString )
1025 [o_textfield setAutoresizingMask:NSViewWidthSizable ];
1026 [self addSubview: o_textfield];
1031 - (void) alignWithXPosition:(int)i_xPos
1034 NSRect superFrame = [self frame];
1035 frame = [o_label frame];
1036 frame.origin.x = i_xPos - frame.size.width - 3;
1037 [o_label setFrame:frame];
1039 frame = [o_textfield frame];
1040 frame.origin.x = i_xPos + 2;
1041 frame.size.width = superFrame.size.width - frame.origin.x - 1;
1042 [o_textfield setFrame:frame];
1047 [o_textfield release];
1051 - (char *)stringValue
1053 return strdup( [[VLCMain sharedInstance] delocalizeString:
1054 [o_textfield stringValue]] );
1058 @implementation StringListConfigControl
1059 - (id) initWithItem: (module_config_t *)_p_item
1060 withView: (NSView *)o_parent_view
1062 NSRect mainFrame = [o_parent_view frame];
1063 NSString *o_labelString, *o_textfieldTooltip;
1064 mainFrame.size.height = 22;
1065 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN + 1;
1066 mainFrame.origin.x = LEFTMARGIN;
1067 mainFrame.origin.y = 0;
1069 if( [super initWithFrame: mainFrame item: _p_item] != nil )
1072 i_view_type = CONFIG_ITEM_STRING_LIST;
1074 if( p_item->psz_text )
1075 o_labelString = [[VLCMain sharedInstance]
1076 localizedString: (char *)p_item->psz_text];
1078 o_labelString = [NSString stringWithString:@""];
1079 ADD_LABEL( o_label, mainFrame, 0, -3, o_labelString )
1080 [o_label setAutoresizingMask:NSViewNotSizable ];
1081 [self addSubview: o_label];
1083 /* build the textfield */
1084 o_textfieldTooltip = [[VLCMain sharedInstance] wrapString:
1085 [[VLCMain sharedInstance]
1086 localizedString: (char *)p_item->psz_longtext ] toWidth: PREFS_WRAP];
1087 ADD_COMBO( o_combo, mainFrame, [o_label frame].size.width,
1088 -2, 0, o_textfieldTooltip )
1089 [o_combo setAutoresizingMask:NSViewWidthSizable ];
1090 for( i_index = 0; i_index < p_item->i_list; i_index++ )
1091 if( p_item->value.psz &&
1092 !strcmp( p_item->value.psz, p_item->ppsz_list[i_index] ) )
1093 [o_combo selectItemAtIndex: i_index];
1094 [self addSubview: o_combo];
1099 - (void) alignWithXPosition:(int)i_xPos
1102 NSRect superFrame = [self frame];
1103 frame = [o_label frame];
1104 frame.origin.x = i_xPos - frame.size.width - 3;
1105 [o_label setFrame:frame];
1107 frame = [o_combo frame];
1108 frame.origin.x = i_xPos + 2;
1109 frame.size.width = superFrame.size.width - frame.origin.x + 2;
1110 [o_combo setFrame:frame];
1119 - (char *)stringValue
1121 if( [o_combo indexOfSelectedItem] >= 0 )
1122 return strdup( p_item->ppsz_list[[o_combo indexOfSelectedItem]] );
1124 return strdup( [[VLCMain sharedInstance]
1125 delocalizeString: [o_combo stringValue]] );
1129 @implementation StringListConfigControl (NSComboBoxDataSource)
1130 - (int)numberOfItemsInComboBox:(NSComboBox *)aComboBox
1132 return p_item->i_list;
1135 - (id)comboBox:(NSComboBox *)aComboBox objectValueForItemAtIndex:(int)i_index
1137 if( p_item->ppsz_list_text && p_item->ppsz_list_text[i_index] )
1139 return [[VLCMain sharedInstance]
1140 localizedString: (char *)p_item->ppsz_list_text[i_index]];
1141 } else return [[VLCMain sharedInstance]
1142 localizedString: (char *)p_item->ppsz_list[i_index]];
1146 @implementation FileConfigControl
1147 - (id) initWithItem: (module_config_t *)_p_item
1148 withView: (NSView *)o_parent_view
1150 NSRect mainFrame = [o_parent_view frame];
1151 NSString *o_labelString, *o_buttonTooltip, *o_textfieldString;
1152 NSString *o_textfieldTooltip;
1153 mainFrame.size.height = 46;
1154 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN;
1155 mainFrame.origin.x = LEFTMARGIN;
1156 mainFrame.origin.y = 0;
1158 if( [super initWithFrame: mainFrame item: _p_item] != nil )
1160 i_view_type = CONFIG_ITEM_FILE;
1162 /* is it a directory */
1163 b_directory = ( [self getType] == CONFIG_ITEM_DIRECTORY ) ? YES : NO;
1166 if( p_item->psz_text )
1167 o_labelString = [[VLCMain sharedInstance]
1168 localizedString: (char *)p_item->psz_text];
1170 o_labelString = [NSString stringWithString:@""];
1171 ADD_LABEL( o_label, mainFrame, 0, 3, o_labelString )
1172 [o_label setAutoresizingMask:NSViewNotSizable ];
1173 [self addSubview: o_label];
1175 /* build the button */
1176 o_buttonTooltip = [[VLCMain sharedInstance]
1177 wrapString: [[VLCMain sharedInstance]
1178 localizedString: (char *)p_item->psz_longtext ] toWidth: PREFS_WRAP];
1179 ADD_RIGHT_BUTTON( o_button, mainFrame, 0, 0, o_buttonTooltip,
1181 [o_button setAutoresizingMask:NSViewMinXMargin ];
1182 [self addSubview: o_button];
1184 /* build the textfield */
1185 o_textfieldTooltip = [[VLCMain sharedInstance] wrapString:
1186 [[VLCMain sharedInstance]
1187 localizedString: (char *)p_item->psz_longtext ] toWidth: PREFS_WRAP];
1188 if( p_item->value.psz )
1189 o_textfieldString = [NSString stringWithFormat: @"%s", (char *)p_item->value.psz];
1191 o_textfieldString = [NSString stringWithString: @""];
1192 ADD_TEXTFIELD( o_textfield, mainFrame, 12, 2, mainFrame.size.width -
1193 8 - [o_button frame].size.width,
1194 o_textfieldTooltip, o_textfieldString )
1195 [o_textfield setAutoresizingMask:NSViewWidthSizable ];
1196 [self addSubview: o_textfield];
1201 - (void) alignWithXPosition:(int)i_xPos
1208 [o_textfield release];
1213 - (IBAction)openFileDialog: (id)sender
1215 NSOpenPanel *o_open_panel = [NSOpenPanel openPanel];
1217 [o_open_panel setTitle: (b_directory)?
1218 _NS("Select a directory"):_NS("Select a file")];
1219 [o_open_panel setPrompt: _NS("Select")];
1220 [o_open_panel setAllowsMultipleSelection: NO];
1221 [o_open_panel setCanChooseFiles: !b_directory];
1222 [o_open_panel setCanChooseDirectories: b_directory];
1223 [o_open_panel beginSheetForDirectory:nil
1226 modalForWindow:[sender window]
1228 didEndSelector: @selector(pathChosenInPanel:
1234 - (void)pathChosenInPanel:(NSOpenPanel *)o_sheet
1235 withReturn:(int)i_return_code contextInfo:(void *)o_context_info
1237 if( i_return_code == NSOKButton )
1239 NSString *o_path = [[o_sheet filenames] objectAtIndex: 0];
1240 [o_textfield setStringValue: o_path];
1244 - (char *)stringValue
1246 if( [[o_textfield stringValue] length] != 0)
1247 return strdup( [[o_textfield stringValue] fileSystemRepresentation] );
1253 @implementation ModuleConfigControl
1254 - (id) initWithItem: (module_config_t *)_p_item
1255 withView: (NSView *)o_parent_view
1257 NSRect mainFrame = [o_parent_view frame];
1258 NSString *o_labelString, *o_popupTooltip;
1259 mainFrame.size.height = 22;
1260 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN + 1;
1261 mainFrame.origin.x = LEFTMARGIN;
1262 mainFrame.origin.y = 0;
1264 if( [super initWithFrame: mainFrame item: _p_item] != nil )
1269 i_view_type = CONFIG_ITEM_MODULE;
1272 if( p_item->psz_text )
1273 o_labelString = [[VLCMain sharedInstance]
1274 localizedString: (char *)p_item->psz_text];
1276 o_labelString = [NSString stringWithString:@""];
1277 ADD_LABEL( o_label, mainFrame, 0, -1, o_labelString )
1278 [o_label setAutoresizingMask:NSViewNotSizable ];
1279 [self addSubview: o_label];
1281 /* build the popup */
1282 o_popupTooltip = [[VLCMain sharedInstance] wrapString:
1283 [[VLCMain sharedInstance]
1284 localizedString: (char *)p_item->psz_longtext ] toWidth: PREFS_WRAP];
1285 ADD_POPUP( o_popup, mainFrame, [o_label frame].size.width,
1286 -2, 0, o_popupTooltip )
1287 [o_popup setAutoresizingMask:NSViewWidthSizable ];
1288 [o_popup addItemWithTitle: _NS("Default")];
1289 [[o_popup lastItem] setTag: -1];
1290 [o_popup selectItem: [o_popup lastItem]];
1292 /* build a list of available modules */
1293 p_list = vlc_list_find( VLCIntf, VLC_OBJECT_MODULE, FIND_ANYWHERE );
1294 for( i_index = 0; i_index < p_list->i_count; i_index++ )
1296 p_parser = (module_t *)p_list->p_values[i_index].p_object;
1298 if( p_item->i_type == CONFIG_ITEM_MODULE )
1300 if( !strcmp( p_parser->psz_capability,
1301 p_item->psz_type ) )
1303 NSString *o_description = [[VLCMain sharedInstance]
1304 localizedString: (char *)p_parser->psz_longname];
1305 [o_popup addItemWithTitle: o_description];
1307 if( p_item->value.psz &&
1308 !strcmp( p_item->value.psz, p_parser->psz_object_name ) )
1309 [o_popup selectItem:[o_popup lastItem]];
1316 if( !strcmp( p_parser->psz_object_name, "main" ) )
1319 for ( i = 0; i < p_parser->confsize; i++ )
1321 module_config_t *p_config = p_parser->p_config + i;
1322 /* Hack: required subcategory is stored in i_min */
1323 if( p_config->i_type == CONFIG_SUBCATEGORY &&
1324 p_config->value.i == p_item->min.i )
1326 NSString *o_description = [[VLCMain sharedInstance]
1327 localizedString: (char *)p_parser->psz_longname];
1328 [o_popup addItemWithTitle: o_description];
1330 if( p_item->value.psz && !strcmp(p_item->value.psz,
1331 p_parser->psz_object_name) )
1332 [o_popup selectItem:[o_popup lastItem]];
1337 vlc_list_release( p_list );
1338 [self addSubview: o_popup];
1343 - (void) alignWithXPosition:(int)i_xPos
1346 NSRect superFrame = [self frame];
1347 frame = [o_label frame];
1348 frame.origin.x = i_xPos - frame.size.width - 3;
1349 [o_label setFrame:frame];
1351 frame = [o_popup frame];
1352 frame.origin.x = i_xPos - 1;
1353 frame.size.width = superFrame.size.width - frame.origin.x + 2;
1354 [o_popup setFrame:frame];
1363 - (char *)stringValue
1365 NSString *newval = [o_popup titleOfSelectedItem];
1366 char *returnval = NULL;
1371 p_list = vlc_list_find( VLCIntf, VLC_OBJECT_MODULE, FIND_ANYWHERE );
1372 for( i_module_index = 0; i_module_index < p_list->i_count; i_module_index++ )
1374 p_parser = (module_t *)p_list->p_values[i_module_index].p_object;
1376 if( p_item->i_type == CONFIG_ITEM_MODULE )
1378 if( !strcmp( p_parser->psz_capability,
1379 p_item->psz_type ) )
1381 NSString *o_description = [[VLCMain sharedInstance]
1382 localizedString: (char *)p_parser->psz_longname];
1383 if( [newval isEqualToString: o_description] )
1385 returnval = strdup(p_parser->psz_object_name);
1394 if( !strcmp( p_parser->psz_object_name, "main" ) )
1397 for ( i = 0; i < p_parser->confsize; i++ )
1399 module_config_t *p_config = p_parser->p_config + i;
1400 /* Hack: required subcategory is stored in i_min */
1401 if( p_config->i_type == CONFIG_SUBCATEGORY &&
1402 p_config->value.i == p_item->min.i )
1404 NSString *o_description = [[VLCMain sharedInstance]
1405 localizedString: (char *)p_parser->psz_longname];
1406 if( [newval isEqualToString: o_description] )
1408 returnval = strdup(p_parser->psz_object_name);
1415 vlc_list_release( p_list );
1420 @implementation IntegerConfigControl
1421 - (id) initWithItem: (module_config_t *)_p_item
1422 withView: (NSView *)o_parent_view
1424 NSRect mainFrame = [o_parent_view frame];
1425 NSString *o_labelString, *o_tooltip;
1426 mainFrame.size.height = 23;
1427 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN + 1;
1428 mainFrame.origin.x = LEFTMARGIN;
1429 mainFrame.origin.y = 0;
1431 if( [super initWithFrame: mainFrame item: _p_item] != nil )
1433 i_view_type = CONFIG_ITEM_INTEGER;
1435 o_tooltip = [[VLCMain sharedInstance] wrapString:
1436 [[VLCMain sharedInstance]
1437 localizedString: (char *)p_item->psz_longtext ] toWidth: PREFS_WRAP];
1440 if( p_item->psz_text )
1441 o_labelString = [[VLCMain sharedInstance]
1442 localizedString: (char *)p_item->psz_text];
1444 o_labelString = [NSString stringWithString:@""];
1445 ADD_LABEL( o_label, mainFrame, 0, -3, o_labelString )
1446 [o_label setAutoresizingMask:NSViewNotSizable ];
1447 [self addSubview: o_label];
1449 /* build the stepper */
1450 ADD_STEPPER( o_stepper, mainFrame, mainFrame.size.width - 19,
1451 0, o_tooltip, -1600, 1600)
1452 [o_stepper setIntValue: p_item->value.i];
1453 [o_stepper setAutoresizingMask:NSViewMaxXMargin ];
1454 [self addSubview: o_stepper];
1456 ADD_TEXTFIELD( o_textfield, mainFrame, mainFrame.size.width - 19 - 52,
1457 1, 49, o_tooltip, @"" )
1458 [o_textfield setIntValue: p_item->value.i];
1459 [o_textfield setDelegate: self];
1460 [[NSNotificationCenter defaultCenter] addObserver: self
1461 selector: @selector(textfieldChanged:)
1462 name: NSControlTextDidChangeNotification
1463 object: o_textfield];
1464 [o_textfield setAutoresizingMask:NSViewMaxXMargin ];
1465 [self addSubview: o_textfield];
1470 - (void) alignWithXPosition:(int)i_xPos
1473 frame = [o_label frame];
1474 frame.origin.x = i_xPos - frame.size.width - 3;
1475 [o_label setFrame:frame];
1477 frame = [o_textfield frame];
1478 frame.origin.x = i_xPos + 2;
1479 [o_textfield setFrame:frame];
1481 frame = [o_stepper frame];
1482 frame.origin.x = i_xPos + [o_textfield frame].size.width + 5;
1483 [o_stepper setFrame:frame];
1488 [o_stepper release];
1489 [o_textfield release];
1493 - (IBAction)stepperChanged:(id)sender
1495 [o_textfield setIntValue: [o_stepper intValue]];
1498 - (void)textfieldChanged:(NSNotification *)o_notification
1500 [o_stepper setIntValue: [o_textfield intValue]];
1505 return [o_textfield intValue];
1510 @implementation IntegerListConfigControl
1512 - (id) initWithItem: (module_config_t *)_p_item
1513 withView: (NSView *)o_parent_view
1515 NSRect mainFrame = [o_parent_view frame];
1516 NSString *o_labelString, *o_textfieldTooltip;
1517 mainFrame.size.height = 22;
1518 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN + 1;
1519 mainFrame.origin.x = LEFTMARGIN;
1520 mainFrame.origin.y = 0;
1522 if( [super initWithFrame: mainFrame item: _p_item] != nil )
1525 i_view_type = CONFIG_ITEM_STRING_LIST;
1528 if( p_item->psz_text )
1529 o_labelString = [[VLCMain sharedInstance]
1530 localizedString: (char *)p_item->psz_text];
1532 o_labelString = [NSString stringWithString:@""];
1533 ADD_LABEL( o_label, mainFrame, 0, -3, o_labelString )
1534 [o_label setAutoresizingMask:NSViewNotSizable ];
1535 [self addSubview: o_label];
1537 /* build the textfield */
1538 o_textfieldTooltip = [[VLCMain sharedInstance] wrapString:
1539 [[VLCMain sharedInstance]
1540 localizedString: (char *)p_item->psz_longtext ] toWidth: PREFS_WRAP];
1541 ADD_COMBO( o_combo, mainFrame, [o_label frame].size.width,
1542 -2, 0, o_textfieldTooltip )
1543 [o_combo setAutoresizingMask:NSViewWidthSizable ];
1544 for( i_index = 0; i_index < p_item->i_list; i_index++ )
1546 if( p_item->value.i == p_item->pi_list[i_index] )
1548 [o_combo selectItemAtIndex: i_index];
1551 [self addSubview: o_combo];
1556 - (void) alignWithXPosition:(int)i_xPos
1559 NSRect superFrame = [self frame];
1560 frame = [o_label frame];
1561 frame.origin.x = i_xPos - frame.size.width - 3;
1562 [o_label setFrame:frame];
1564 frame = [o_combo frame];
1565 frame.origin.x = i_xPos + 2;
1566 frame.size.width = superFrame.size.width - frame.origin.x + 2;
1567 [o_combo setFrame:frame];
1578 if( [o_combo indexOfSelectedItem] >= 0 )
1579 return p_item->pi_list[[o_combo indexOfSelectedItem]];
1581 return [o_combo intValue];
1585 @implementation IntegerListConfigControl (NSComboBoxDataSource)
1586 - (int)numberOfItemsInComboBox:(NSComboBox *)aComboBox
1588 return p_item->i_list;
1591 - (id)comboBox:(NSComboBox *)aComboBox objectValueForItemAtIndex:(int)i_index
1593 if( p_item->ppsz_list_text && p_item->ppsz_list_text[i_index] )
1594 return [[VLCMain sharedInstance]
1595 localizedString: (char *)p_item->ppsz_list_text[i_index]];
1597 return [NSString stringWithFormat: @"%i", p_item->pi_list[i_index]];
1601 @implementation RangedIntegerConfigControl
1602 - (id) initWithItem: (module_config_t *)_p_item
1603 withView: (NSView *)o_parent_view
1605 NSRect mainFrame = [o_parent_view frame];
1606 NSString *o_labelString, *o_tooltip;
1607 mainFrame.size.height = 50;
1608 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN;
1609 mainFrame.origin.x = LEFTMARGIN;
1610 mainFrame.origin.y = 0;
1612 if( [super initWithFrame: mainFrame item: _p_item] != nil )
1614 i_view_type = CONFIG_ITEM_RANGED_INTEGER;
1617 if( p_item->psz_text )
1618 o_labelString = [[VLCMain sharedInstance]
1619 localizedString: (char *)p_item->psz_text];
1621 o_labelString = [NSString stringWithString:@""];
1622 ADD_LABEL( o_label, mainFrame, 0, -3, o_labelString )
1623 [o_label setAutoresizingMask:NSViewNotSizable ];
1624 [self addSubview: o_label];
1626 /* build the textfield */
1627 o_tooltip = [[VLCMain sharedInstance] wrapString:
1628 [[VLCMain sharedInstance]
1629 localizedString: (char *)p_item->psz_longtext ] toWidth: PREFS_WRAP];
1630 ADD_TEXTFIELD( o_textfield, mainFrame, [o_label frame].size.width + 2,
1631 28, 49, o_tooltip, @"" )
1632 [o_textfield setIntValue: p_item->value.i];
1633 [o_textfield setAutoresizingMask:NSViewMaxXMargin ];
1634 [o_textfield setDelegate: self];
1635 [[NSNotificationCenter defaultCenter] addObserver: self
1636 selector: @selector(textfieldChanged:)
1637 name: NSControlTextDidChangeNotification
1638 object: o_textfield];
1639 [self addSubview: o_textfield];
1641 /* build the mintextfield */
1642 ADD_LABEL( o_textfield_min, mainFrame, 12, -30, @"-8888" )
1643 [o_textfield_min setIntValue: p_item->min.i];
1644 [o_textfield_min setAutoresizingMask:NSViewMaxXMargin ];
1645 [o_textfield_min setAlignment:NSRightTextAlignment];
1646 [self addSubview: o_textfield_min];
1648 /* build the maxtextfield */
1649 ADD_LABEL( o_textfield_max, mainFrame,
1650 mainFrame.size.width - 31, -30, @"8888" )
1651 [o_textfield_max setIntValue: p_item->max.i];
1652 [o_textfield_max setAutoresizingMask:NSViewMinXMargin ];
1653 [self addSubview: o_textfield_max];
1655 /* build the slider */
1656 ADD_SLIDER( o_slider, mainFrame, [o_textfield_min frame].origin.x +
1657 [o_textfield_min frame].size.width + 6, -1, mainFrame.size.width -
1658 [o_textfield_max frame].size.width -
1659 [o_textfield_max frame].size.width - 14 -
1660 [o_textfield_min frame].origin.x, o_tooltip,
1661 p_item->min.i, p_item->max.i )
1662 [o_slider setIntValue: p_item->value.i];
1663 [o_slider setAutoresizingMask:NSViewWidthSizable ];
1664 [o_slider setTarget: self];
1665 [o_slider setAction: @selector(sliderChanged:)];
1666 [o_slider sendActionOn:NSLeftMouseUpMask | NSLeftMouseDownMask |
1667 NSLeftMouseDraggedMask];
1668 [self addSubview: o_slider];
1674 - (void) alignWithXPosition:(int)i_xPos
1677 frame = [o_label frame];
1678 frame.origin.x = i_xPos - frame.size.width - 3;
1679 [o_label setFrame:frame];
1681 frame = [o_textfield frame];
1682 frame.origin.x = i_xPos + 2;
1683 [o_textfield setFrame:frame];
1688 [o_textfield release];
1689 [o_textfield_min release];
1690 [o_textfield_max release];
1695 - (IBAction)sliderChanged:(id)sender
1697 [o_textfield setIntValue: [o_slider intValue]];
1700 - (void)textfieldChanged:(NSNotification *)o_notification
1702 [o_slider setIntValue: [o_textfield intValue]];
1707 return [o_slider intValue];
1711 @implementation FloatConfigControl
1712 - (id) initWithItem: (module_config_t *)_p_item
1713 withView: (NSView *)o_parent_view
1715 NSRect mainFrame = [o_parent_view frame];
1716 NSString *o_labelString, *o_tooltip;
1717 mainFrame.size.height = 23;
1718 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN + 1;
1719 mainFrame.origin.x = LEFTMARGIN;
1720 mainFrame.origin.y = 0;
1722 if( [super initWithFrame: mainFrame item: _p_item] != nil )
1724 i_view_type = CONFIG_ITEM_INTEGER;
1726 o_tooltip = [[VLCMain sharedInstance] wrapString:
1727 [[VLCMain sharedInstance]
1728 localizedString: (char *)p_item->psz_longtext ] toWidth: PREFS_WRAP];
1731 if( p_item->psz_text )
1732 o_labelString = [[VLCMain sharedInstance]
1733 localizedString: (char *)p_item->psz_text];
1735 o_labelString = [NSString stringWithString:@""];
1736 ADD_LABEL( o_label, mainFrame, 0, -2, o_labelString )
1737 [o_label setAutoresizingMask:NSViewNotSizable ];
1738 [self addSubview: o_label];
1740 /* build the stepper */
1741 ADD_STEPPER( o_stepper, mainFrame, mainFrame.size.width - 19,
1742 0, o_tooltip, -1600, 1600)
1743 [o_stepper setFloatValue: p_item->value.f];
1744 [o_stepper setAutoresizingMask:NSViewMaxXMargin ];
1745 [self addSubview: o_stepper];
1747 /* build the textfield */
1748 ADD_TEXTFIELD( o_textfield, mainFrame, mainFrame.size.width - 19 - 52,
1749 1, 49, o_tooltip, @"" )
1750 [o_textfield setFloatValue: p_item->value.f];
1751 [o_textfield setDelegate: self];
1752 [[NSNotificationCenter defaultCenter] addObserver: self
1753 selector: @selector(textfieldChanged:)
1754 name: NSControlTextDidChangeNotification
1755 object: o_textfield];
1756 [o_textfield setAutoresizingMask:NSViewMaxXMargin ];
1757 [self addSubview: o_textfield];
1762 - (void) alignWithXPosition:(int)i_xPos
1765 frame = [o_label frame];
1766 frame.origin.x = i_xPos - frame.size.width - 3;
1767 [o_label setFrame:frame];
1769 frame = [o_textfield frame];
1770 frame.origin.x = i_xPos + 2;
1771 [o_textfield setFrame:frame];
1773 frame = [o_stepper frame];
1774 frame.origin.x = i_xPos + [o_textfield frame].size.width + 5;
1775 [o_stepper setFrame:frame];
1780 [o_stepper release];
1781 [o_textfield release];
1785 - (IBAction)stepperChanged:(id)sender
1787 [o_textfield setFloatValue: [o_stepper floatValue]];
1790 - (void)textfieldChanged:(NSNotification *)o_notification
1792 [o_stepper setFloatValue: [o_textfield floatValue]];
1797 return [o_stepper floatValue];
1801 @implementation RangedFloatConfigControl
1802 - (id) initWithItem: (module_config_t *)_p_item
1803 withView: (NSView *)o_parent_view
1805 NSRect mainFrame = [o_parent_view frame];
1806 NSString *o_labelString, *o_tooltip;
1807 mainFrame.size.height = 50;
1808 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN;
1809 mainFrame.origin.x = LEFTMARGIN;
1810 mainFrame.origin.y = 0;
1812 if( [super initWithFrame: mainFrame item: _p_item] != nil )
1814 i_view_type = CONFIG_ITEM_RANGED_INTEGER;
1817 if( p_item->psz_text )
1818 o_labelString = [[VLCMain sharedInstance]
1819 localizedString: (char *)p_item->psz_text];
1821 o_labelString = [NSString stringWithString:@""];
1822 ADD_LABEL( o_label, mainFrame, 0, -3, o_labelString )
1823 [o_label setAutoresizingMask:NSViewNotSizable ];
1824 [self addSubview: o_label];
1826 /* build the textfield */
1827 o_tooltip = [[VLCMain sharedInstance] wrapString:
1828 [[VLCMain sharedInstance]
1829 localizedString: (char *)p_item->psz_longtext ] toWidth: PREFS_WRAP];
1830 ADD_TEXTFIELD( o_textfield, mainFrame, [o_label frame].size.width + 2,
1831 28, 49, o_tooltip, @"" )
1832 [o_textfield setFloatValue: p_item->value.f];
1833 [o_textfield setAutoresizingMask:NSViewMaxXMargin ];
1834 [o_textfield setDelegate: self];
1835 [[NSNotificationCenter defaultCenter] addObserver: self
1836 selector: @selector(textfieldChanged:)
1837 name: NSControlTextDidChangeNotification
1838 object: o_textfield];
1839 [self addSubview: o_textfield];
1841 /* build the mintextfield */
1842 ADD_LABEL( o_textfield_min, mainFrame, 12, -30, @"-8888" )
1843 [o_textfield_min setFloatValue: p_item->min.f];
1844 [o_textfield_min setAutoresizingMask:NSViewMaxXMargin ];
1845 [o_textfield_min setAlignment:NSRightTextAlignment];
1846 [self addSubview: o_textfield_min];
1848 /* build the maxtextfield */
1849 ADD_LABEL( o_textfield_max, mainFrame, mainFrame.size.width - 31,
1851 [o_textfield_max setFloatValue: p_item->max.f];
1852 [o_textfield_max setAutoresizingMask:NSViewMinXMargin ];
1853 [self addSubview: o_textfield_max];
1855 /* build the slider */
1856 ADD_SLIDER( o_slider, mainFrame, [o_textfield_min frame].origin.x +
1857 [o_textfield_min frame].size.width + 6, -1, mainFrame.size.width -
1858 [o_textfield_max frame].size.width -
1859 [o_textfield_max frame].size.width - 14 -
1860 [o_textfield_min frame].origin.x, o_tooltip, p_item->min.f,
1862 [o_slider setFloatValue: p_item->value.f];
1863 [o_slider setAutoresizingMask:NSViewWidthSizable ];
1864 [o_slider setTarget: self];
1865 [o_slider setAction: @selector(sliderChanged:)];
1866 [o_slider sendActionOn:NSLeftMouseUpMask | NSLeftMouseDownMask |
1867 NSLeftMouseDraggedMask];
1868 [self addSubview: o_slider];
1874 - (void) alignWithXPosition:(int)i_xPos
1877 frame = [o_label frame];
1878 frame.origin.x = i_xPos - frame.size.width - 3;
1879 [o_label setFrame:frame];
1881 frame = [o_textfield frame];
1882 frame.origin.x = i_xPos + 2;
1883 [o_textfield setFrame:frame];
1888 [o_textfield release];
1889 [o_textfield_min release];
1890 [o_textfield_max release];
1895 - (IBAction)sliderChanged:(id)sender
1897 [o_textfield setFloatValue: [o_slider floatValue]];
1900 - (void)textfieldChanged:(NSNotification *)o_notification
1902 [o_slider setFloatValue: [o_textfield floatValue]];
1907 return [o_slider floatValue];
1912 @implementation BoolConfigControl
1914 - (id) initWithItem: (module_config_t *)_p_item
1915 withView: (NSView *)o_parent_view
1917 NSRect mainFrame = [o_parent_view frame];
1918 NSString *o_labelString, *o_tooltip;
1919 mainFrame.size.height = 17;
1920 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN;
1921 mainFrame.origin.x = LEFTMARGIN;
1922 mainFrame.origin.y = 0;
1924 if( [super initWithFrame: mainFrame item: _p_item] != nil )
1926 i_view_type = CONFIG_ITEM_BOOL;
1928 /* add the checkbox */
1929 o_tooltip = [[VLCMain sharedInstance]
1930 wrapString: [[VLCMain sharedInstance]
1931 localizedString: (char *)p_item->psz_longtext ] toWidth: PREFS_WRAP];
1932 ADD_CHECKBOX( o_checkbox, mainFrame, 0,
1933 0, @"", o_tooltip, p_item->value.i, NSImageLeft)
1934 [o_checkbox setAutoresizingMask:NSViewNotSizable ];
1935 [self addSubview: o_checkbox];
1937 if( p_item->psz_text )
1938 o_labelString = [[VLCMain sharedInstance]
1939 localizedString: (char *)p_item->psz_text];
1941 o_labelString = [NSString stringWithString:@""];
1942 ADD_LABEL( o_label, mainFrame, [o_checkbox frame].size.width, 0, o_labelString )
1943 [o_label setAutoresizingMask:NSViewNotSizable ];
1944 [self addSubview: o_label];
1951 [o_checkbox release];
1957 return [o_checkbox intValue];
1962 @implementation KeyConfigControl
1963 - (id) initWithItem: (module_config_t *)_p_item
1964 withView: (NSView *)o_parent_view
1966 NSRect mainFrame = [o_parent_view frame];
1967 NSString *o_labelString, *o_tooltip;
1968 mainFrame.size.height = 22;
1969 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN + 1;
1970 mainFrame.origin.x = LEFTMARGIN;
1971 mainFrame.origin.y = 0;
1973 if( [super initWithFrame: mainFrame item: _p_item] != nil )
1975 i_view_type = CONFIG_ITEM_KEY_AFTER_10_3;
1978 if( p_item->psz_text )
1979 o_labelString = [[VLCMain sharedInstance]
1980 localizedString: (char *)p_item->psz_text];
1982 o_labelString = [NSString stringWithString:@""];
1983 ADD_LABEL( o_label, mainFrame, 0, -1, o_labelString )
1984 [o_label setAutoresizingMask:NSViewNotSizable ];
1985 [self addSubview: o_label];
1987 /* build the popup */
1988 o_tooltip = [[VLCMain sharedInstance] wrapString:
1989 [[VLCMain sharedInstance]
1990 localizedString: (char *)p_item->psz_longtext ] toWidth: PREFS_WRAP];
1991 ADD_POPUP( o_popup, mainFrame, [o_label frame].origin.x +
1992 [o_label frame].size.width + 3,
1994 [o_popup setAutoresizingMask:NSViewWidthSizable ];
1996 if( o_keys_menu == nil )
1999 o_keys_menu = [[NSMenu alloc] initWithTitle: @"Keys Menu"];
2000 for ( i = 0; i < sizeof(vlc_keys) / sizeof(key_descriptor_t); i++)
2001 if( vlc_keys[i].psz_key_string && *vlc_keys[i].psz_key_string )
2002 POPULATE_A_KEY( o_keys_menu,
2003 [NSString stringWithCString:vlc_keys[i].psz_key_string]
2004 , vlc_keys[i].i_key_code)
2006 [o_popup setMenu:[o_keys_menu copyWithZone:nil]];
2007 [o_popup selectItem:[[o_popup menu] itemWithTag:p_item->value.i]];
2008 [self addSubview: o_popup];
2014 - (void) alignWithXPosition:(int)i_xPos
2017 NSRect superFrame = [self frame];
2018 frame = [o_label frame];
2019 frame.origin.x = i_xPos - frame.size.width - 3;
2020 [o_label setFrame:frame];
2022 frame = [o_popup frame];
2023 frame.origin.x = i_xPos - 1;
2024 frame.size.width = superFrame.size.width - frame.origin.x + 2;
2025 [o_popup setFrame:frame];
2036 return [o_popup selectedTag];
2040 @implementation ModuleListConfigControl
2041 - (id) initWithItem: (module_config_t *)_p_item
2042 withView: (NSView *)o_parent_view
2044 if( _p_item->i_type == CONFIG_ITEM_MODULE_LIST )
2048 //Fill our array to know how may items we have...
2052 NSRect mainFrame = [o_parent_view frame];
2053 NSString *o_labelString, *o_textfieldString, *o_tooltip;
2055 o_modulearray = [[NSMutableArray alloc] initWithCapacity:10];
2056 /* build a list of available modules */
2057 p_list = vlc_list_find( VLCIntf, VLC_OBJECT_MODULE, FIND_ANYWHERE );
2058 for( i_module_index = 0; i_module_index < p_list->i_count; i_module_index++ )
2061 p_parser = (module_t *)p_list->p_values[i_module_index].p_object;
2063 if( !strcmp( p_parser->psz_object_name, "main" ) )
2066 for ( i = 0; i < p_parser->confsize; i++ )
2068 module_config_t *p_config = p_parser->p_config + i;
2069 NSString *o_modulelongname, *o_modulename;
2070 NSNumber *o_moduleenabled = nil;
2072 /* Hack: required subcategory is stored in i_min */
2073 if( p_config->i_type == CONFIG_SUBCATEGORY &&
2074 p_config->value.i == _p_item->min.i )
2076 o_modulelongname = [NSString stringWithUTF8String:
2077 p_parser->psz_longname];
2078 o_modulename = [NSString stringWithUTF8String:
2079 p_parser->psz_object_name];
2081 if( _p_item->value.psz &&
2082 strstr( _p_item->value.psz, p_parser->psz_object_name ) )
2083 o_moduleenabled = [NSNumber numberWithBool:YES];
2085 o_moduleenabled = [NSNumber numberWithBool:NO];
2087 [o_modulearray addObject:[NSMutableArray
2088 arrayWithObjects: o_modulename, o_modulelongname,
2089 o_moduleenabled, nil]];
2093 vlc_list_release( p_list );
2095 mainFrame.size.height = 30 + 18 * [o_modulearray count];
2096 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN;
2097 mainFrame.origin.x = LEFTMARGIN;
2098 mainFrame.origin.y = 0;
2099 if( [super initWithFrame: mainFrame item: _p_item] != nil )
2101 i_view_type = CONFIG_ITEM_MODULE_LIST;
2104 if( p_item->psz_text )
2105 o_labelString = [[VLCMain sharedInstance]
2106 localizedString: (char *)p_item->psz_text];
2108 o_labelString = [NSString stringWithString:@""];
2109 ADD_LABEL( o_label, mainFrame, 0, -3, o_labelString )
2110 [o_label setAutoresizingMask:NSViewNotSizable ];
2111 [self addSubview: o_label];
2113 /* build the textfield */
2114 o_tooltip = [[VLCMain sharedInstance] wrapString:
2115 [[VLCMain sharedInstance]
2116 localizedString: (char *)p_item->psz_longtext ] toWidth: PREFS_WRAP];
2117 if( p_item->value.psz )
2118 o_textfieldString = [[VLCMain sharedInstance]
2119 localizedString: (char *)p_item->value.psz];
2121 o_textfieldString = [NSString stringWithString: @""];
2122 ADD_TEXTFIELD( o_textfield, mainFrame, [o_label frame].size.width + 2,
2123 mainFrame.size.height - 22, mainFrame.size.width -
2124 [o_label frame].size.width - 2, o_tooltip, o_textfieldString )
2125 [o_textfield setAutoresizingMask:NSViewWidthSizable ];
2126 [self addSubview: o_textfield];
2130 NSRect s_rc = mainFrame;
2131 s_rc.size.height = mainFrame.size.height - 30;
2132 s_rc.size.width = mainFrame.size.width - 12;
2135 o_scrollview = [[[NSScrollView alloc] initWithFrame: s_rc] retain];
2136 [o_scrollview setDrawsBackground: NO];
2137 [o_scrollview setBorderType: NSBezelBorder];
2138 [o_scrollview setAutohidesScrollers:YES];
2140 NSTableView *o_tableview;
2141 o_tableview = [[NSTableView alloc] initWithFrame : s_rc];
2142 [o_tableview setUsesAlternatingRowBackgroundColors:YES];
2143 [o_tableview setHeaderView:nil];
2144 /* TODO: find a good way to fix the row height and text size*/
2145 /* FIXME: support for multiple selection... */
2146 // [o_tableview setAllowsMultipleSelection:YES];
2148 NSCell *o_headerCell = [[NSCell alloc] initTextCell:@"Enabled"];
2149 NSCell *o_dataCell = [[NSButtonCell alloc] init];
2150 [(NSButtonCell*)o_dataCell setButtonType:NSSwitchButton];
2151 [o_dataCell setTitle:@""];
2152 [o_dataCell setFont:[NSFont systemFontOfSize:0]];
2153 NSTableColumn *o_tableColumn = [[NSTableColumn alloc]
2154 initWithIdentifier:[NSString stringWithCString: "Enabled"]];
2155 [o_tableColumn setHeaderCell: o_headerCell];
2156 [o_tableColumn setDataCell: o_dataCell];
2157 [o_tableColumn setWidth:17];
2158 [o_tableview addTableColumn: o_tableColumn];
2160 o_headerCell = [[NSCell alloc] initTextCell:@"Module Name"];
2161 o_dataCell = [[NSTextFieldCell alloc] init];
2162 [o_dataCell setFont:[NSFont systemFontOfSize:12]];
2163 o_tableColumn = [[NSTableColumn alloc]
2164 initWithIdentifier:[NSString stringWithCString: "Module"]];
2165 [o_tableColumn setHeaderCell: o_headerCell];
2166 [o_tableColumn setDataCell: o_dataCell];
2167 [o_tableColumn setWidth:388 - 17];
2168 [o_tableview addTableColumn: o_tableColumn];
2169 [o_tableview registerForDraggedTypes:[NSArray arrayWithObjects:
2170 @"VLC media player module", nil]];
2172 [o_tableview setDataSource:self];
2173 [o_tableview setTarget: self];
2174 [o_tableview setAction: @selector(tableChanged:)];
2175 [o_tableview sendActionOn:NSLeftMouseUpMask | NSLeftMouseDownMask |
2176 NSLeftMouseDraggedMask];
2177 [o_scrollview setDocumentView: o_tableview];
2179 [o_scrollview setAutoresizingMask:NSViewWidthSizable ];
2180 [self addSubview: o_scrollview];
2187 - (void) alignWithXPosition:(int)i_xPos
2192 - (IBAction)tableChanged:(id)sender
2194 NSString *o_newstring = @"";
2196 for( i = 0 ; i < [o_modulearray count] ; i++ )
2197 if( [[[o_modulearray objectAtIndex:i] objectAtIndex:2]
2200 o_newstring = [o_newstring stringByAppendingString:
2201 [[o_modulearray objectAtIndex:i] objectAtIndex:0]];
2202 o_newstring = [o_newstring stringByAppendingString:@":"];
2205 [o_textfield setStringValue: [o_newstring
2206 substringToIndex: ([o_newstring length])?[o_newstring length] - 1:0]];
2211 [o_scrollview release];
2216 - (char *)stringValue
2218 return strdup( [[o_textfield stringValue] UTF8String] );
2223 @implementation ModuleListConfigControl (NSTableDataSource)
2225 - (BOOL)tableView:(NSTableView*)table writeRows:(NSArray*)rows
2226 toPasteboard:(NSPasteboard*)pb
2228 // We only want to allow dragging of selected rows.
2229 NSEnumerator *iter = [rows objectEnumerator];
2231 while ((row = [iter nextObject]) != nil)
2233 if (![table isRowSelected:[row intValue]])
2237 [pb declareTypes:[NSArray
2238 arrayWithObject:@"VLC media player module"] owner:nil];
2239 [pb setPropertyList:rows forType:@"VLC media player module"];
2243 - (NSDragOperation)tableView:(NSTableView*)table
2244 validateDrop:(id <NSDraggingInfo>)info proposedRow:(int)row
2245 proposedDropOperation:(NSTableViewDropOperation)op
2247 // Make drops at the end of the table go to the end.
2250 row = [table numberOfRows];
2251 op = NSTableViewDropAbove;
2252 [table setDropRow:row dropOperation:op];
2255 // We don't ever want to drop onto a row, only between rows.
2256 if (op == NSTableViewDropOn)
2257 [table setDropRow:(row+1) dropOperation:NSTableViewDropAbove];
2258 return NSTableViewDropAbove;
2261 - (BOOL)tableView:(NSTableView*)table acceptDrop:(id <NSDraggingInfo>)info
2262 row:(int)dropRow dropOperation:(NSTableViewDropOperation)op;
2264 NSPasteboard *pb = [info draggingPasteboard];
2265 NSDragOperation srcMask = [info draggingSourceOperationMask];
2272 // Intra-table drag - data is the array of rows.
2273 if (!accepted && (array =
2274 [pb propertyListForType:@"VLC media player module"]) != NULL)
2276 NSEnumerator *iter = nil;
2278 BOOL isCopy = (srcMask & NSDragOperationMove) ? NO:YES;
2280 iter = [array objectEnumerator];
2281 while ((val = [iter nextObject]) != NULL)
2283 NSArray *o_tmp = [[o_modulearray objectAtIndex:
2284 [val intValue]] mutableCopyWithZone:nil];
2285 [o_modulearray removeObject:o_tmp];
2286 [o_modulearray insertObject:o_tmp
2287 atIndex:(dropRow>[val intValue]) ? dropRow - 1 : dropRow];
2291 // Select the newly-dragged items.
2292 iter = [array objectEnumerator];
2294 [table deselectAll:self];
2296 [self tableChanged:self];
2297 [table setNeedsDisplay:YES];
2298 // Indicate that we finished the drag.
2302 [table setNeedsDisplay:YES];
2306 // An exception occurred. Uh-oh. Update the track table so that
2307 // it stays consistent, and re-raise the exception.
2309 [localException raise];
2310 [table setNeedsDisplay:YES];
2316 - (int)numberOfRowsInTableView:(NSTableView *)aTableView
2318 return [o_modulearray count];
2321 - (id)tableView:(NSTableView *)aTableView
2322 objectValueForTableColumn:(NSTableColumn *)aTableColumn row:(int)rowIndex
2324 if( [[aTableColumn identifier] isEqualToString:
2325 [NSString stringWithCString:"Enabled"]] )
2326 return [[o_modulearray objectAtIndex:rowIndex] objectAtIndex:2];
2327 if( [[aTableColumn identifier] isEqualToString:
2328 [NSString stringWithCString:"Module"]] )
2329 return [[o_modulearray objectAtIndex:rowIndex] objectAtIndex:1];
2334 - (void)tableView:(NSTableView *)aTableView setObjectValue:(id)anObject
2335 forTableColumn:(NSTableColumn *)aTableColumn row:(int)rowIndex
2337 [[o_modulearray objectAtIndex:rowIndex] replaceObjectAtIndex:2
2338 withObject: anObject];