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_COMBO( o_combo, superFrame, x_offset, my_y_offset, x2_offset, \
286 NSRect s_rc = superFrame; \
287 s_rc.origin.x = x_offset + 2; \
288 s_rc.origin.y = my_y_offset; \
289 s_rc.size.height = 26; \
290 s_rc.size.width = superFrame.size.width + 2 - s_rc.origin.x - \
292 o_combo = [[[NSComboBox alloc] initWithFrame: s_rc] retain]; \
293 [o_combo setFont:[NSFont systemFontOfSize:0]]; \
294 [o_combo setToolTip: tooltip]; \
295 [o_combo setUsesDataSource:TRUE]; \
296 [o_combo setDataSource:self]; \
297 [o_combo setNumberOfVisibleItems:10]; \
298 [o_combo setCompletes:YES]; \
301 #define ADD_RIGHT_BUTTON( o_button, superFrame, x_offset, my_y_offset, \
304 NSRect s_rc = superFrame; \
305 o_button = [[[NSButton alloc] initWithFrame: s_rc] retain]; \
306 [o_button setButtonType: NSMomentaryPushInButton]; \
307 [o_button setBezelStyle: NSRoundedBezelStyle]; \
308 [o_button setTitle: title]; \
309 [o_button setFont:[NSFont systemFontOfSize:0]]; \
310 [o_button sizeToFit]; \
311 s_rc = [o_button frame]; \
312 s_rc.origin.x = superFrame.size.width - [o_button frame].size.width - 6;\
313 s_rc.origin.y = my_y_offset - 6; \
314 s_rc.size.width += 12; \
315 [o_button setFrame: s_rc]; \
316 [o_button setToolTip: tooltip]; \
317 [o_button setTarget: self]; \
318 [o_button setAction: @selector(openFileDialog:)]; \
321 #define ADD_POPUP( o_popup, superFrame, x_offset, my_y_offset, x2_offset, \
324 NSRect s_rc = superFrame; \
325 s_rc.origin.x = x_offset - 1; \
326 s_rc.origin.y = my_y_offset; \
327 s_rc.size.height = 26; \
328 s_rc.size.width = superFrame.size.width + 2 - s_rc.origin.x - \
330 o_popup = [[[NSPopUpButton alloc] initWithFrame: s_rc] retain]; \
331 [o_popup setFont:[NSFont systemFontOfSize:0]]; \
332 [o_popup setToolTip: tooltip]; \
335 #define ADD_STEPPER( o_stepper, superFrame, x_offset, my_y_offset, tooltip, \
338 NSRect s_rc = superFrame; \
339 s_rc.origin.x = x_offset; \
340 s_rc.origin.y = my_y_offset; \
341 s_rc.size.height = 23; \
342 s_rc.size.width = 23; \
343 o_stepper = [[[NSStepper alloc] initWithFrame: s_rc] retain]; \
344 [o_stepper setFont:[NSFont systemFontOfSize:0]]; \
345 [o_stepper setToolTip: tooltip]; \
346 [o_stepper setMaxValue: higher]; \
347 [o_stepper setMinValue: lower]; \
348 [o_stepper setTarget: self]; \
349 [o_stepper setAction: @selector(stepperChanged:)]; \
350 [o_stepper sendActionOn:NSLeftMouseUpMask | NSLeftMouseDownMask | \
351 NSLeftMouseDraggedMask]; \
354 #define ADD_SLIDER( o_slider, superFrame, x_offset, my_y_offset, my_width, \
355 tooltip, lower, higher ) \
357 NSRect s_rc = superFrame; \
358 s_rc.origin.x = x_offset; \
359 s_rc.origin.y = my_y_offset; \
360 s_rc.size.height = 21; \
361 s_rc.size.width = my_width; \
362 o_slider = [[[NSSlider alloc] initWithFrame: s_rc] retain]; \
363 [o_slider setFont:[NSFont systemFontOfSize:0]]; \
364 [o_slider setToolTip: tooltip]; \
365 [o_slider setMaxValue: higher]; \
366 [o_slider setMinValue: lower]; \
369 #define ADD_CHECKBOX( o_checkbox, superFrame, x_offset, my_y_offset, label, \
370 tooltip, init_value, position ) \
372 NSRect s_rc = superFrame; \
373 s_rc.size.height = 18; \
374 s_rc.origin.x = x_offset - 2; \
375 s_rc.origin.y = superFrame.size.height - 18 + my_y_offset; \
376 o_checkbox = [[[NSButton alloc] initWithFrame: s_rc] retain]; \
377 [o_checkbox setFont:[NSFont systemFontOfSize:0]]; \
378 [o_checkbox setButtonType: NSSwitchButton]; \
379 [o_checkbox setImagePosition: position]; \
380 [o_checkbox setIntValue: init_value]; \
381 [o_checkbox setTitle: label]; \
382 [o_checkbox setToolTip: tooltip]; \
383 [o_checkbox sizeToFit]; \
386 @implementation VLCConfigControl
387 - (id)initWithFrame: (NSRect)frame
389 return [self initWithFrame: frame
393 - (id)initWithFrame: (NSRect)frame
394 item: (module_config_t *)_p_item
396 self = [super initWithFrame: frame];
401 psz_name = p_item->psz_name;
403 i_type = p_item->i_type;
405 b_advanced = p_item->b_advanced;
406 [self setAutoresizingMask:NSViewWidthSizable | NSViewMinYMargin ];
411 - (void)setYPos:(int)i_yPos
413 NSRect frame = [self frame];
414 frame.origin.y = i_yPos;
415 [self setFrame:frame];
420 if( o_label ) [o_label release];
425 + (int)calcVerticalMargin: (int)i_curItem lastItem: (int)i_lastItem
430 case CONFIG_ITEM_STRING:
433 case CONFIG_ITEM_STRING:
436 case CONFIG_ITEM_STRING_LIST:
439 case CONFIG_ITEM_FILE:
442 case CONFIG_ITEM_MODULE:
445 case CONFIG_ITEM_INTEGER:
448 case CONFIG_ITEM_RANGED_INTEGER:
451 case CONFIG_ITEM_BOOL:
454 case CONFIG_ITEM_KEY_BEFORE_10_3:
457 case CONFIG_ITEM_KEY_AFTER_10_3:
460 case CONFIG_ITEM_MODULE_LIST:
468 case CONFIG_ITEM_STRING_LIST:
471 case CONFIG_ITEM_STRING:
474 case CONFIG_ITEM_STRING_LIST:
477 case CONFIG_ITEM_FILE:
480 case CONFIG_ITEM_MODULE:
483 case CONFIG_ITEM_INTEGER:
486 case CONFIG_ITEM_RANGED_INTEGER:
489 case CONFIG_ITEM_BOOL:
492 case CONFIG_ITEM_KEY_BEFORE_10_3:
495 case CONFIG_ITEM_KEY_AFTER_10_3:
498 case CONFIG_ITEM_MODULE_LIST:
506 case CONFIG_ITEM_FILE:
509 case CONFIG_ITEM_STRING:
512 case CONFIG_ITEM_STRING_LIST:
515 case CONFIG_ITEM_FILE:
518 case CONFIG_ITEM_MODULE:
521 case CONFIG_ITEM_INTEGER:
524 case CONFIG_ITEM_RANGED_INTEGER:
527 case CONFIG_ITEM_BOOL:
530 case CONFIG_ITEM_KEY_BEFORE_10_3:
533 case CONFIG_ITEM_KEY_AFTER_10_3:
536 case CONFIG_ITEM_MODULE_LIST:
544 case CONFIG_ITEM_MODULE:
547 case CONFIG_ITEM_STRING:
550 case CONFIG_ITEM_STRING_LIST:
553 case CONFIG_ITEM_FILE:
556 case CONFIG_ITEM_MODULE:
559 case CONFIG_ITEM_INTEGER:
562 case CONFIG_ITEM_RANGED_INTEGER:
565 case CONFIG_ITEM_BOOL:
568 case CONFIG_ITEM_KEY_BEFORE_10_3:
571 case CONFIG_ITEM_KEY_AFTER_10_3:
574 case CONFIG_ITEM_MODULE_LIST:
582 case CONFIG_ITEM_INTEGER:
585 case CONFIG_ITEM_STRING:
588 case CONFIG_ITEM_STRING_LIST:
591 case CONFIG_ITEM_FILE:
594 case CONFIG_ITEM_MODULE:
597 case CONFIG_ITEM_INTEGER:
600 case CONFIG_ITEM_RANGED_INTEGER:
603 case CONFIG_ITEM_BOOL:
606 case CONFIG_ITEM_KEY_BEFORE_10_3:
609 case CONFIG_ITEM_KEY_AFTER_10_3:
612 case CONFIG_ITEM_MODULE_LIST:
620 case CONFIG_ITEM_RANGED_INTEGER:
623 case CONFIG_ITEM_STRING:
626 case CONFIG_ITEM_STRING_LIST:
629 case CONFIG_ITEM_FILE:
632 case CONFIG_ITEM_MODULE:
635 case CONFIG_ITEM_INTEGER:
638 case CONFIG_ITEM_RANGED_INTEGER:
641 case CONFIG_ITEM_BOOL:
644 case CONFIG_ITEM_KEY_BEFORE_10_3:
647 case CONFIG_ITEM_KEY_AFTER_10_3:
650 case CONFIG_ITEM_MODULE_LIST:
658 case CONFIG_ITEM_BOOL:
661 case CONFIG_ITEM_STRING:
664 case CONFIG_ITEM_STRING_LIST:
667 case CONFIG_ITEM_FILE:
670 case CONFIG_ITEM_MODULE:
673 case CONFIG_ITEM_INTEGER:
676 case CONFIG_ITEM_RANGED_INTEGER:
679 case CONFIG_ITEM_BOOL:
682 case CONFIG_ITEM_KEY_BEFORE_10_3:
685 case CONFIG_ITEM_KEY_AFTER_10_3:
688 case CONFIG_ITEM_MODULE_LIST:
696 case CONFIG_ITEM_KEY_BEFORE_10_3:
699 case CONFIG_ITEM_STRING:
702 case CONFIG_ITEM_STRING_LIST:
705 case CONFIG_ITEM_FILE:
708 case CONFIG_ITEM_MODULE:
711 case CONFIG_ITEM_INTEGER:
714 case CONFIG_ITEM_RANGED_INTEGER:
717 case CONFIG_ITEM_BOOL:
720 case CONFIG_ITEM_KEY_BEFORE_10_3:
723 case CONFIG_ITEM_KEY_AFTER_10_3:
726 case CONFIG_ITEM_MODULE_LIST:
734 case CONFIG_ITEM_KEY_AFTER_10_3:
737 case CONFIG_ITEM_STRING:
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_BEFORE_10_3:
761 case CONFIG_ITEM_KEY_AFTER_10_3:
764 case CONFIG_ITEM_MODULE_LIST:
772 case CONFIG_ITEM_MODULE_LIST:
775 case CONFIG_ITEM_STRING:
778 case CONFIG_ITEM_STRING_LIST:
781 case CONFIG_ITEM_FILE:
784 case CONFIG_ITEM_MODULE:
787 case CONFIG_ITEM_INTEGER:
790 case CONFIG_ITEM_RANGED_INTEGER:
793 case CONFIG_ITEM_BOOL:
796 case CONFIG_ITEM_KEY_BEFORE_10_3:
799 case CONFIG_ITEM_KEY_AFTER_10_3:
802 case CONFIG_ITEM_MODULE_LIST:
817 + (VLCConfigControl *)newControl: (module_config_t *)_p_item
818 withView: (NSView *)o_parent_view
820 VLCConfigControl *p_control = NULL;
822 switch( _p_item->i_type )
824 case CONFIG_ITEM_STRING:
825 if( !_p_item->i_list )
827 p_control = [[StringConfigControl alloc]
828 initWithItem: _p_item
829 withView: o_parent_view];
833 p_control = [[StringListConfigControl alloc]
834 initWithItem: _p_item
835 withView: o_parent_view];
838 case CONFIG_ITEM_FILE:
839 case CONFIG_ITEM_DIRECTORY:
840 p_control = [[FileConfigControl alloc]
841 initWithItem: _p_item
842 withView: o_parent_view];
844 case CONFIG_ITEM_MODULE:
845 case CONFIG_ITEM_MODULE_CAT:
846 p_control = [[ModuleConfigControl alloc]
847 initWithItem: _p_item
848 withView: o_parent_view];
850 case CONFIG_ITEM_INTEGER:
851 if( _p_item->i_list )
853 p_control = [[IntegerListConfigControl alloc]
854 initWithItem: _p_item
855 withView: o_parent_view];
857 else if( _p_item->min.i != 0 || _p_item->max.i != 0 )
859 p_control = [[RangedIntegerConfigControl alloc]
860 initWithItem: _p_item
861 withView: o_parent_view];
865 p_control = [[IntegerConfigControl alloc]
866 initWithItem: _p_item
867 withView: o_parent_view];
870 case CONFIG_ITEM_BOOL:
871 p_control = [[BoolConfigControl alloc]
872 initWithItem: _p_item
873 withView: o_parent_view];
875 case CONFIG_ITEM_FLOAT:
876 if( _p_item->min.f != 0 || _p_item->max.f != 0 )
878 p_control = [[RangedFloatConfigControl alloc]
879 initWithItem: _p_item
880 withView: o_parent_view];
884 p_control = [[FloatConfigControl alloc]
885 initWithItem: _p_item
886 withView: o_parent_view];
889 case CONFIG_ITEM_KEY:
890 p_control = [[KeyConfigControl alloc]
891 initWithItem: _p_item
892 withView: o_parent_view];
894 case CONFIG_ITEM_MODULE_LIST:
895 case CONFIG_ITEM_MODULE_LIST_CAT:
896 p_control = [[ModuleListConfigControl alloc]
897 initWithItem: _p_item
898 withView: o_parent_view];
906 - (NSString *)getName
908 return [[VLCMain sharedInstance] localizedString: psz_name];
936 - (char *)stringValue
944 switch( p_item->i_type )
946 case CONFIG_ITEM_STRING:
947 case CONFIG_ITEM_FILE:
948 case CONFIG_ITEM_DIRECTORY:
949 case CONFIG_ITEM_MODULE:
950 case CONFIG_ITEM_MODULE_LIST:
951 case CONFIG_ITEM_MODULE_LIST_CAT:
952 config_PutPsz( VLCIntf, psz_name, [self stringValue] );
954 case CONFIG_ITEM_KEY:
955 /* So you don't need to restart to have the changes take effect */
956 val.i_int = [self intValue];
957 var_Set( VLCIntf->p_libvlc, psz_name, val );
958 case CONFIG_ITEM_INTEGER:
959 case CONFIG_ITEM_BOOL:
960 config_PutInt( VLCIntf, psz_name, [self intValue] );
962 case CONFIG_ITEM_FLOAT:
963 config_PutFloat( VLCIntf, psz_name, [self floatValue] );
970 return [o_label frame].size.width;
973 - (void) alignWithXPosition:(int)i_xPos;
975 /* FIXME: not implemented atm, but created to shut up the warning
976 * about "method definition not found" -- FK @ 7/24/05 */
980 @implementation StringConfigControl
981 - (id) initWithItem: (module_config_t *)_p_item
982 withView: (NSView *)o_parent_view
984 NSRect mainFrame = [o_parent_view frame];
985 NSString *o_labelString, *o_textfieldString, *o_textfieldTooltip;
986 mainFrame.size.height = 22;
987 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN;
988 mainFrame.origin.x = LEFTMARGIN;
989 mainFrame.origin.y = 0;
991 if( [super initWithFrame: mainFrame item: _p_item] != nil )
993 i_view_type = CONFIG_ITEM_STRING;
994 o_textfieldTooltip = [[VLCMain sharedInstance] wrapString:
995 [[VLCMain sharedInstance] localizedString: (char *)p_item->psz_longtext]
996 toWidth: PREFS_WRAP];
999 if( p_item->psz_text )
1000 o_labelString = [[VLCMain sharedInstance]
1001 localizedString: (char *)p_item->psz_text];
1003 o_labelString = [NSString stringWithString:@""];
1004 ADD_LABEL( o_label, mainFrame, 0, -3, o_labelString, o_textfieldTooltip )
1005 [o_label setAutoresizingMask:NSViewNotSizable ];
1006 [self addSubview: o_label];
1008 /* build the textfield */
1009 if( p_item->value.psz )
1010 o_textfieldString = [[VLCMain sharedInstance]
1011 localizedString: (char *)p_item->value.psz];
1013 o_textfieldString = [NSString stringWithString: @""];
1014 ADD_TEXTFIELD( o_textfield, mainFrame, [o_label frame].size.width + 2,
1015 0, mainFrame.size.width - [o_label frame].size.width -
1016 2, o_textfieldTooltip, o_textfieldString )
1017 [o_textfield setAutoresizingMask:NSViewWidthSizable ];
1018 [self addSubview: o_textfield];
1023 - (void) alignWithXPosition:(int)i_xPos
1026 NSRect superFrame = [self frame];
1027 frame = [o_label frame];
1028 frame.origin.x = i_xPos - frame.size.width - 3;
1029 [o_label setFrame:frame];
1031 frame = [o_textfield frame];
1032 frame.origin.x = i_xPos + 2;
1033 frame.size.width = superFrame.size.width - frame.origin.x - 1;
1034 [o_textfield setFrame:frame];
1039 [o_textfield release];
1043 - (char *)stringValue
1045 return strdup( [[VLCMain sharedInstance] delocalizeString:
1046 [o_textfield stringValue]] );
1050 @implementation StringListConfigControl
1051 - (id) initWithItem: (module_config_t *)_p_item
1052 withView: (NSView *)o_parent_view
1054 NSRect mainFrame = [o_parent_view frame];
1055 NSString *o_labelString, *o_textfieldTooltip;
1056 mainFrame.size.height = 22;
1057 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN + 1;
1058 mainFrame.origin.x = LEFTMARGIN;
1059 mainFrame.origin.y = 0;
1061 if( [super initWithFrame: mainFrame item: _p_item] != nil )
1064 i_view_type = CONFIG_ITEM_STRING_LIST;
1066 o_textfieldTooltip = [[VLCMain sharedInstance] wrapString:
1067 [[VLCMain sharedInstance]
1068 localizedString: (char *)p_item->psz_longtext ] toWidth: PREFS_WRAP];
1071 if( p_item->psz_text )
1072 o_labelString = [[VLCMain sharedInstance]
1073 localizedString: (char *)p_item->psz_text];
1075 o_labelString = [NSString stringWithString:@""];
1076 ADD_LABEL( o_label, mainFrame, 0, -3, o_labelString, o_textfieldTooltip )
1077 [o_label setAutoresizingMask:NSViewNotSizable ];
1078 [self addSubview: o_label];
1080 /* build the textfield */
1081 ADD_COMBO( o_combo, mainFrame, [o_label frame].size.width,
1082 -2, 0, o_textfieldTooltip )
1083 [o_combo setAutoresizingMask:NSViewWidthSizable ];
1084 for( i_index = 0; i_index < p_item->i_list; i_index++ )
1085 if( p_item->value.psz &&
1086 !strcmp( p_item->value.psz, p_item->ppsz_list[i_index] ) )
1087 [o_combo selectItemAtIndex: i_index];
1088 [self addSubview: o_combo];
1093 - (void) alignWithXPosition:(int)i_xPos
1096 NSRect superFrame = [self frame];
1097 frame = [o_label frame];
1098 frame.origin.x = i_xPos - frame.size.width - 3;
1099 [o_label setFrame:frame];
1101 frame = [o_combo frame];
1102 frame.origin.x = i_xPos + 2;
1103 frame.size.width = superFrame.size.width - frame.origin.x + 2;
1104 [o_combo setFrame:frame];
1113 - (char *)stringValue
1115 if( [o_combo indexOfSelectedItem] >= 0 )
1116 return strdup( p_item->ppsz_list[[o_combo indexOfSelectedItem]] );
1118 return strdup( [[VLCMain sharedInstance]
1119 delocalizeString: [o_combo stringValue]] );
1123 @implementation StringListConfigControl (NSComboBoxDataSource)
1124 - (int)numberOfItemsInComboBox:(NSComboBox *)aComboBox
1126 return p_item->i_list;
1129 - (id)comboBox:(NSComboBox *)aComboBox objectValueForItemAtIndex:(int)i_index
1131 if( p_item->ppsz_list_text && p_item->ppsz_list_text[i_index] )
1133 return [[VLCMain sharedInstance]
1134 localizedString: (char *)p_item->ppsz_list_text[i_index]];
1135 } else return [[VLCMain sharedInstance]
1136 localizedString: (char *)p_item->ppsz_list[i_index]];
1140 @implementation FileConfigControl
1141 - (id) initWithItem: (module_config_t *)_p_item
1142 withView: (NSView *)o_parent_view
1144 NSRect mainFrame = [o_parent_view frame];
1145 NSString *o_labelString, *o_itemTooltip, *o_textfieldString;
1146 mainFrame.size.height = 46;
1147 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN;
1148 mainFrame.origin.x = LEFTMARGIN;
1149 mainFrame.origin.y = 0;
1151 if( [super initWithFrame: mainFrame item: _p_item] != nil )
1153 i_view_type = CONFIG_ITEM_FILE;
1155 o_itemTooltip = [[VLCMain sharedInstance]
1156 wrapString: [[VLCMain sharedInstance]
1157 localizedString: (char *)p_item->psz_longtext ] toWidth: PREFS_WRAP];
1159 /* is it a directory */
1160 b_directory = ( [self getType] == CONFIG_ITEM_DIRECTORY ) ? YES : NO;
1163 if( p_item->psz_text )
1164 o_labelString = [[VLCMain sharedInstance]
1165 localizedString: (char *)p_item->psz_text];
1167 o_labelString = [NSString stringWithString:@""];
1168 ADD_LABEL( o_label, mainFrame, 0, 3, o_labelString, o_itemTooltip )
1169 [o_label setAutoresizingMask:NSViewNotSizable ];
1170 [self addSubview: o_label];
1172 /* build the button */
1173 ADD_RIGHT_BUTTON( o_button, mainFrame, 0, 0, o_itemTooltip,
1175 [o_button setAutoresizingMask:NSViewMinXMargin ];
1176 [self addSubview: o_button];
1178 /* build the textfield */
1179 if( p_item->value.psz )
1180 o_textfieldString = [NSString stringWithFormat: @"%s", (char *)p_item->value.psz];
1182 o_textfieldString = [NSString stringWithString: @""];
1183 ADD_TEXTFIELD( o_textfield, mainFrame, 12, 2, mainFrame.size.width -
1184 8 - [o_button frame].size.width,
1185 o_itemTooltip, o_textfieldString )
1186 [o_textfield setAutoresizingMask:NSViewWidthSizable ];
1187 [self addSubview: o_textfield];
1192 - (void) alignWithXPosition:(int)i_xPos
1199 [o_textfield release];
1204 - (IBAction)openFileDialog: (id)sender
1206 NSOpenPanel *o_open_panel = [NSOpenPanel openPanel];
1208 [o_open_panel setTitle: (b_directory)?
1209 _NS("Select a directory"):_NS("Select a file")];
1210 [o_open_panel setPrompt: _NS("Select")];
1211 [o_open_panel setAllowsMultipleSelection: NO];
1212 [o_open_panel setCanChooseFiles: !b_directory];
1213 [o_open_panel setCanChooseDirectories: b_directory];
1214 [o_open_panel beginSheetForDirectory:nil
1217 modalForWindow:[sender window]
1219 didEndSelector: @selector(pathChosenInPanel:
1225 - (void)pathChosenInPanel:(NSOpenPanel *)o_sheet
1226 withReturn:(int)i_return_code contextInfo:(void *)o_context_info
1228 if( i_return_code == NSOKButton )
1230 NSString *o_path = [[o_sheet filenames] objectAtIndex: 0];
1231 [o_textfield setStringValue: o_path];
1235 - (char *)stringValue
1237 if( [[o_textfield stringValue] length] != 0)
1238 return strdup( [[o_textfield stringValue] fileSystemRepresentation] );
1244 @implementation ModuleConfigControl
1245 - (id) initWithItem: (module_config_t *)_p_item
1246 withView: (NSView *)o_parent_view
1248 NSRect mainFrame = [o_parent_view frame];
1249 NSString *o_labelString, *o_popupTooltip;
1250 mainFrame.size.height = 22;
1251 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN + 1;
1252 mainFrame.origin.x = LEFTMARGIN;
1253 mainFrame.origin.y = 0;
1255 if( [super initWithFrame: mainFrame item: _p_item] != nil )
1260 i_view_type = CONFIG_ITEM_MODULE;
1262 o_popupTooltip = [[VLCMain sharedInstance] wrapString:
1263 [[VLCMain sharedInstance]
1264 localizedString: (char *)p_item->psz_longtext ] toWidth: PREFS_WRAP];
1267 if( p_item->psz_text )
1268 o_labelString = [[VLCMain sharedInstance]
1269 localizedString: (char *)p_item->psz_text];
1271 o_labelString = [NSString stringWithString:@""];
1272 ADD_LABEL( o_label, mainFrame, 0, -1, o_labelString, o_popupTooltip )
1273 [o_label setAutoresizingMask:NSViewNotSizable ];
1274 [self addSubview: o_label];
1276 /* build the popup */
1277 ADD_POPUP( o_popup, mainFrame, [o_label frame].size.width,
1278 -2, 0, o_popupTooltip )
1279 [o_popup setAutoresizingMask:NSViewWidthSizable ];
1280 [o_popup addItemWithTitle: _NS("Default")];
1281 [[o_popup lastItem] setTag: -1];
1282 [o_popup selectItem: [o_popup lastItem]];
1284 /* build a list of available modules */
1285 p_list = vlc_list_find( VLCIntf, VLC_OBJECT_MODULE, FIND_ANYWHERE );
1286 for( i_index = 0; i_index < p_list->i_count; i_index++ )
1288 p_parser = (module_t *)p_list->p_values[i_index].p_object;
1290 if( p_item->i_type == CONFIG_ITEM_MODULE )
1292 if( module_IsCapable( p_parser, p_item->psz_type ) )
1294 NSString *o_description = [[VLCMain sharedInstance]
1295 localizedString: module_GetLongName( p_parser )];
1296 [o_popup addItemWithTitle: o_description];
1298 if( p_item->value.psz &&
1299 !strcmp( p_item->value.psz, module_GetObjName( p_parser ) ) )
1300 [o_popup selectItem:[o_popup lastItem]];
1307 if( !strcmp( module_GetObjName( p_parser ), "main" ) )
1309 unsigned int confsize;
1310 unsigned int unused;
1311 module_GetConfig( p_parser, &confsize );
1312 for ( i = 0; i < confsize; i++ )
1314 module_config_t *p_config = module_GetConfig( p_parser, &unused ) + i;
1315 /* Hack: required subcategory is stored in i_min */
1316 if( p_config->i_type == CONFIG_SUBCATEGORY &&
1317 p_config->value.i == p_item->min.i )
1319 NSString *o_description = [[VLCMain sharedInstance]
1320 localizedString: module_GetLongName( p_parser )];
1321 [o_popup addItemWithTitle: o_description];
1323 if( p_item->value.psz && !strcmp(p_item->value.psz,
1324 module_GetObjName( p_parser )) )
1325 [o_popup selectItem:[o_popup lastItem]];
1330 vlc_list_release( p_list );
1331 [self addSubview: o_popup];
1336 - (void) alignWithXPosition:(int)i_xPos
1339 NSRect superFrame = [self frame];
1340 frame = [o_label frame];
1341 frame.origin.x = i_xPos - frame.size.width - 3;
1342 [o_label setFrame:frame];
1344 frame = [o_popup frame];
1345 frame.origin.x = i_xPos - 1;
1346 frame.size.width = superFrame.size.width - frame.origin.x + 2;
1347 [o_popup setFrame:frame];
1356 - (char *)stringValue
1358 NSString *newval = [o_popup titleOfSelectedItem];
1359 char *returnval = NULL;
1364 p_list = vlc_list_find( VLCIntf, VLC_OBJECT_MODULE, FIND_ANYWHERE );
1365 for( i_module_index = 0; i_module_index < p_list->i_count; i_module_index++ )
1367 p_parser = (module_t *)p_list->p_values[i_module_index].p_object;
1369 if( p_item->i_type == CONFIG_ITEM_MODULE )
1371 if( module_IsCapable( p_parser, p_item->psz_type ) )
1373 NSString *o_description = [[VLCMain sharedInstance]
1374 localizedString: module_GetLongName( p_parser )];
1375 if( [newval isEqualToString: o_description] )
1377 returnval = strdup( module_GetObjName( p_parser ));
1386 if( !strcmp( module_GetObjName( p_parser ), "main" ) )
1388 unsigned int confsize, unused;
1389 module_GetConfig( p_parser, &confsize );
1390 for ( i = 0; i < confsize; i++ )
1392 module_config_t *p_config = module_GetConfig( p_parser, &unused ) + i;
1393 /* Hack: required subcategory is stored in i_min */
1394 if( p_config->i_type == CONFIG_SUBCATEGORY &&
1395 p_config->value.i == p_item->min.i )
1397 NSString *o_description = [[VLCMain sharedInstance]
1398 localizedString: module_GetLongName( p_parser )];
1399 if( [newval isEqualToString: o_description] )
1401 returnval = strdup(module_GetObjName( p_parser ));
1408 vlc_list_release( p_list );
1413 @implementation IntegerConfigControl
1414 - (id) initWithItem: (module_config_t *)_p_item
1415 withView: (NSView *)o_parent_view
1417 NSRect mainFrame = [o_parent_view frame];
1418 NSString *o_labelString, *o_tooltip;
1419 mainFrame.size.height = 23;
1420 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN + 1;
1421 mainFrame.origin.x = LEFTMARGIN;
1422 mainFrame.origin.y = 0;
1424 if( [super initWithFrame: mainFrame item: _p_item] != nil )
1426 i_view_type = CONFIG_ITEM_INTEGER;
1428 o_tooltip = [[VLCMain sharedInstance] wrapString:
1429 [[VLCMain sharedInstance]
1430 localizedString: (char *)p_item->psz_longtext ] toWidth: PREFS_WRAP];
1433 if( p_item->psz_text )
1434 o_labelString = [[VLCMain sharedInstance]
1435 localizedString: (char *)p_item->psz_text];
1437 o_labelString = [NSString stringWithString:@""];
1438 ADD_LABEL( o_label, mainFrame, 0, -3, o_labelString, o_tooltip )
1439 [o_label setAutoresizingMask:NSViewNotSizable ];
1440 [self addSubview: o_label];
1442 /* build the stepper */
1443 ADD_STEPPER( o_stepper, mainFrame, mainFrame.size.width - 19,
1444 0, o_tooltip, -100000, 100000)
1445 [o_stepper setIntValue: p_item->value.i];
1446 [o_stepper setAutoresizingMask:NSViewMaxXMargin ];
1447 [self addSubview: o_stepper];
1449 ADD_TEXTFIELD( o_textfield, mainFrame, mainFrame.size.width - 19 - 52,
1450 1, 49, o_tooltip, @"" )
1451 [o_textfield setIntValue: p_item->value.i];
1452 [o_textfield setDelegate: self];
1453 [[NSNotificationCenter defaultCenter] addObserver: self
1454 selector: @selector(textfieldChanged:)
1455 name: NSControlTextDidChangeNotification
1456 object: o_textfield];
1457 [o_textfield setAutoresizingMask:NSViewMaxXMargin ];
1458 [self addSubview: o_textfield];
1463 - (void) alignWithXPosition:(int)i_xPos
1466 frame = [o_label frame];
1467 frame.origin.x = i_xPos - frame.size.width - 3;
1468 [o_label setFrame:frame];
1470 frame = [o_textfield frame];
1471 frame.origin.x = i_xPos + 2;
1472 [o_textfield setFrame:frame];
1474 frame = [o_stepper frame];
1475 frame.origin.x = i_xPos + [o_textfield frame].size.width + 5;
1476 [o_stepper setFrame:frame];
1481 [o_stepper release];
1482 [o_textfield release];
1486 - (IBAction)stepperChanged:(id)sender
1488 [o_textfield setIntValue: [o_stepper intValue]];
1491 - (void)textfieldChanged:(NSNotification *)o_notification
1493 [o_stepper setIntValue: [o_textfield intValue]];
1498 return [o_textfield intValue];
1503 @implementation IntegerListConfigControl
1505 - (id) initWithItem: (module_config_t *)_p_item
1506 withView: (NSView *)o_parent_view
1508 NSRect mainFrame = [o_parent_view frame];
1509 NSString *o_labelString, *o_textfieldTooltip;
1510 mainFrame.size.height = 22;
1511 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN + 1;
1512 mainFrame.origin.x = LEFTMARGIN;
1513 mainFrame.origin.y = 0;
1515 if( [super initWithFrame: mainFrame item: _p_item] != nil )
1518 i_view_type = CONFIG_ITEM_STRING_LIST;
1520 o_textfieldTooltip = [[VLCMain sharedInstance] wrapString:
1521 [[VLCMain sharedInstance]
1522 localizedString: (char *)p_item->psz_longtext ] toWidth: PREFS_WRAP];
1525 if( p_item->psz_text )
1526 o_labelString = [[VLCMain sharedInstance]
1527 localizedString: (char *)p_item->psz_text];
1529 o_labelString = [NSString stringWithString:@""];
1530 ADD_LABEL( o_label, mainFrame, 0, -3, o_labelString, o_textfieldTooltip )
1531 [o_label setAutoresizingMask:NSViewNotSizable ];
1532 [self addSubview: o_label];
1534 /* build the textfield */
1535 ADD_COMBO( o_combo, mainFrame, [o_label frame].size.width,
1536 -2, 0, o_textfieldTooltip )
1537 [o_combo setAutoresizingMask:NSViewWidthSizable ];
1538 for( i_index = 0; i_index < p_item->i_list; i_index++ )
1540 if( p_item->value.i == p_item->pi_list[i_index] )
1542 [o_combo selectItemAtIndex: i_index];
1545 [self addSubview: o_combo];
1550 - (void) alignWithXPosition:(int)i_xPos
1553 NSRect superFrame = [self frame];
1554 frame = [o_label frame];
1555 frame.origin.x = i_xPos - frame.size.width - 3;
1556 [o_label setFrame:frame];
1558 frame = [o_combo frame];
1559 frame.origin.x = i_xPos + 2;
1560 frame.size.width = superFrame.size.width - frame.origin.x + 2;
1561 [o_combo setFrame:frame];
1572 if( [o_combo indexOfSelectedItem] >= 0 )
1573 return p_item->pi_list[[o_combo indexOfSelectedItem]];
1575 return [o_combo intValue];
1579 @implementation IntegerListConfigControl (NSComboBoxDataSource)
1580 - (int)numberOfItemsInComboBox:(NSComboBox *)aComboBox
1582 return p_item->i_list;
1585 - (id)comboBox:(NSComboBox *)aComboBox objectValueForItemAtIndex:(int)i_index
1587 if( p_item->ppsz_list_text && p_item->ppsz_list_text[i_index] )
1588 return [[VLCMain sharedInstance]
1589 localizedString: (char *)p_item->ppsz_list_text[i_index]];
1591 return [NSString stringWithFormat: @"%i", p_item->pi_list[i_index]];
1595 @implementation RangedIntegerConfigControl
1596 - (id) initWithItem: (module_config_t *)_p_item
1597 withView: (NSView *)o_parent_view
1599 NSRect mainFrame = [o_parent_view frame];
1600 NSString *o_labelString, *o_tooltip;
1601 mainFrame.size.height = 50;
1602 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN;
1603 mainFrame.origin.x = LEFTMARGIN;
1604 mainFrame.origin.y = 0;
1606 if( [super initWithFrame: mainFrame item: _p_item] != nil )
1608 i_view_type = CONFIG_ITEM_RANGED_INTEGER;
1610 o_tooltip = [[VLCMain sharedInstance] wrapString:
1611 [[VLCMain sharedInstance]
1612 localizedString: (char *)p_item->psz_longtext ] toWidth: PREFS_WRAP];
1615 if( p_item->psz_text )
1616 o_labelString = [[VLCMain sharedInstance]
1617 localizedString: (char *)p_item->psz_text];
1619 o_labelString = [NSString stringWithString:@""];
1620 ADD_LABEL( o_label, mainFrame, 0, -3, o_labelString, o_tooltip )
1621 [o_label setAutoresizingMask:NSViewNotSizable ];
1622 [self addSubview: o_label];
1624 /* build the textfield */
1625 ADD_TEXTFIELD( o_textfield, mainFrame, [o_label frame].size.width + 2,
1626 28, 49, o_tooltip, @"" )
1627 [o_textfield setIntValue: p_item->value.i];
1628 [o_textfield setAutoresizingMask:NSViewMaxXMargin ];
1629 [o_textfield setDelegate: self];
1630 [[NSNotificationCenter defaultCenter] addObserver: self
1631 selector: @selector(textfieldChanged:)
1632 name: NSControlTextDidChangeNotification
1633 object: o_textfield];
1634 [self addSubview: o_textfield];
1636 /* build the mintextfield */
1637 ADD_LABEL( o_textfield_min, mainFrame, 12, -30, @"-8888", @"" )
1638 [o_textfield_min setIntValue: p_item->min.i];
1639 [o_textfield_min setAutoresizingMask:NSViewMaxXMargin ];
1640 [o_textfield_min setAlignment:NSRightTextAlignment];
1641 [self addSubview: o_textfield_min];
1643 /* build the maxtextfield */
1644 ADD_LABEL( o_textfield_max, mainFrame,
1645 mainFrame.size.width - 31, -30, @"8888", @"" )
1646 [o_textfield_max setIntValue: p_item->max.i];
1647 [o_textfield_max setAutoresizingMask:NSViewMinXMargin ];
1648 [self addSubview: o_textfield_max];
1650 /* build the slider */
1651 ADD_SLIDER( o_slider, mainFrame, [o_textfield_min frame].origin.x +
1652 [o_textfield_min frame].size.width + 6, -1, mainFrame.size.width -
1653 [o_textfield_max frame].size.width -
1654 [o_textfield_max frame].size.width - 14 -
1655 [o_textfield_min frame].origin.x, o_tooltip,
1656 p_item->min.i, p_item->max.i )
1657 [o_slider setIntValue: p_item->value.i];
1658 [o_slider setAutoresizingMask:NSViewWidthSizable ];
1659 [o_slider setTarget: self];
1660 [o_slider setAction: @selector(sliderChanged:)];
1661 [o_slider sendActionOn:NSLeftMouseUpMask | NSLeftMouseDownMask |
1662 NSLeftMouseDraggedMask];
1663 [self addSubview: o_slider];
1669 - (void) alignWithXPosition:(int)i_xPos
1672 frame = [o_label frame];
1673 frame.origin.x = i_xPos - frame.size.width - 3;
1674 [o_label setFrame:frame];
1676 frame = [o_textfield frame];
1677 frame.origin.x = i_xPos + 2;
1678 [o_textfield setFrame:frame];
1683 [o_textfield release];
1684 [o_textfield_min release];
1685 [o_textfield_max release];
1690 - (IBAction)sliderChanged:(id)sender
1692 [o_textfield setIntValue: [o_slider intValue]];
1695 - (void)textfieldChanged:(NSNotification *)o_notification
1697 [o_slider setIntValue: [o_textfield intValue]];
1702 return [o_slider intValue];
1706 @implementation FloatConfigControl
1707 - (id) initWithItem: (module_config_t *)_p_item
1708 withView: (NSView *)o_parent_view
1710 NSRect mainFrame = [o_parent_view frame];
1711 NSString *o_labelString, *o_tooltip;
1712 mainFrame.size.height = 23;
1713 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN + 1;
1714 mainFrame.origin.x = LEFTMARGIN;
1715 mainFrame.origin.y = 0;
1717 if( [super initWithFrame: mainFrame item: _p_item] != nil )
1719 i_view_type = CONFIG_ITEM_INTEGER;
1721 o_tooltip = [[VLCMain sharedInstance] wrapString:
1722 [[VLCMain sharedInstance]
1723 localizedString: (char *)p_item->psz_longtext ] toWidth: PREFS_WRAP];
1726 if( p_item->psz_text )
1727 o_labelString = [[VLCMain sharedInstance]
1728 localizedString: (char *)p_item->psz_text];
1730 o_labelString = [NSString stringWithString:@""];
1731 ADD_LABEL( o_label, mainFrame, 0, -2, o_labelString, o_tooltip )
1732 [o_label setAutoresizingMask:NSViewNotSizable ];
1733 [self addSubview: o_label];
1735 /* build the stepper */
1736 ADD_STEPPER( o_stepper, mainFrame, mainFrame.size.width - 19,
1737 0, o_tooltip, -100000, 100000)
1738 [o_stepper setFloatValue: p_item->value.f];
1739 [o_stepper setAutoresizingMask:NSViewMaxXMargin ];
1740 [self addSubview: o_stepper];
1742 /* build the textfield */
1743 ADD_TEXTFIELD( o_textfield, mainFrame, mainFrame.size.width - 19 - 52,
1744 1, 49, o_tooltip, @"" )
1745 [o_textfield setFloatValue: p_item->value.f];
1746 [o_textfield setDelegate: self];
1747 [[NSNotificationCenter defaultCenter] addObserver: self
1748 selector: @selector(textfieldChanged:)
1749 name: NSControlTextDidChangeNotification
1750 object: o_textfield];
1751 [o_textfield setAutoresizingMask:NSViewMaxXMargin ];
1752 [self addSubview: o_textfield];
1757 - (void) alignWithXPosition:(int)i_xPos
1760 frame = [o_label frame];
1761 frame.origin.x = i_xPos - frame.size.width - 3;
1762 [o_label setFrame:frame];
1764 frame = [o_textfield frame];
1765 frame.origin.x = i_xPos + 2;
1766 [o_textfield setFrame:frame];
1768 frame = [o_stepper frame];
1769 frame.origin.x = i_xPos + [o_textfield frame].size.width + 5;
1770 [o_stepper setFrame:frame];
1775 [o_stepper release];
1776 [o_textfield release];
1780 - (IBAction)stepperChanged:(id)sender
1782 [o_textfield setFloatValue: [o_stepper floatValue]];
1785 - (void)textfieldChanged:(NSNotification *)o_notification
1787 [o_stepper setFloatValue: [o_textfield floatValue]];
1792 return [o_stepper floatValue];
1796 @implementation RangedFloatConfigControl
1797 - (id) initWithItem: (module_config_t *)_p_item
1798 withView: (NSView *)o_parent_view
1800 NSRect mainFrame = [o_parent_view frame];
1801 NSString *o_labelString, *o_tooltip;
1802 mainFrame.size.height = 50;
1803 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN;
1804 mainFrame.origin.x = LEFTMARGIN;
1805 mainFrame.origin.y = 0;
1807 if( [super initWithFrame: mainFrame item: _p_item] != nil )
1809 i_view_type = CONFIG_ITEM_RANGED_INTEGER;
1811 o_tooltip = [[VLCMain sharedInstance] wrapString:
1812 [[VLCMain sharedInstance]
1813 localizedString: (char *)p_item->psz_longtext ] toWidth: PREFS_WRAP];
1816 if( p_item->psz_text )
1817 o_labelString = [[VLCMain sharedInstance]
1818 localizedString: (char *)p_item->psz_text];
1820 o_labelString = [NSString stringWithString:@""];
1821 ADD_LABEL( o_label, mainFrame, 0, -3, o_labelString, o_tooltip )
1822 [o_label setAutoresizingMask:NSViewNotSizable ];
1823 [self addSubview: o_label];
1825 /* build the textfield */
1826 ADD_TEXTFIELD( o_textfield, mainFrame, [o_label frame].size.width + 2,
1827 28, 49, o_tooltip, @"" )
1828 [o_textfield setFloatValue: p_item->value.f];
1829 [o_textfield setAutoresizingMask:NSViewMaxXMargin ];
1830 [o_textfield setDelegate: self];
1831 [[NSNotificationCenter defaultCenter] addObserver: self
1832 selector: @selector(textfieldChanged:)
1833 name: NSControlTextDidChangeNotification
1834 object: o_textfield];
1835 [self addSubview: o_textfield];
1837 /* build the mintextfield */
1838 ADD_LABEL( o_textfield_min, mainFrame, 12, -30, @"-8888", @"" )
1839 [o_textfield_min setFloatValue: p_item->min.f];
1840 [o_textfield_min setAutoresizingMask:NSViewMaxXMargin ];
1841 [o_textfield_min setAlignment:NSRightTextAlignment];
1842 [self addSubview: o_textfield_min];
1844 /* build the maxtextfield */
1845 ADD_LABEL( o_textfield_max, mainFrame, mainFrame.size.width - 31,
1847 [o_textfield_max setFloatValue: p_item->max.f];
1848 [o_textfield_max setAutoresizingMask:NSViewMinXMargin ];
1849 [self addSubview: o_textfield_max];
1851 /* build the slider */
1852 ADD_SLIDER( o_slider, mainFrame, [o_textfield_min frame].origin.x +
1853 [o_textfield_min frame].size.width + 6, -1, mainFrame.size.width -
1854 [o_textfield_max frame].size.width -
1855 [o_textfield_max frame].size.width - 14 -
1856 [o_textfield_min frame].origin.x, o_tooltip, p_item->min.f,
1858 [o_slider setFloatValue: p_item->value.f];
1859 [o_slider setAutoresizingMask:NSViewWidthSizable ];
1860 [o_slider setTarget: self];
1861 [o_slider setAction: @selector(sliderChanged:)];
1862 [o_slider sendActionOn:NSLeftMouseUpMask | NSLeftMouseDownMask |
1863 NSLeftMouseDraggedMask];
1864 [self addSubview: o_slider];
1870 - (void) alignWithXPosition:(int)i_xPos
1873 frame = [o_label frame];
1874 frame.origin.x = i_xPos - frame.size.width - 3;
1875 [o_label setFrame:frame];
1877 frame = [o_textfield frame];
1878 frame.origin.x = i_xPos + 2;
1879 [o_textfield setFrame:frame];
1884 [o_textfield release];
1885 [o_textfield_min release];
1886 [o_textfield_max release];
1891 - (IBAction)sliderChanged:(id)sender
1893 [o_textfield setFloatValue: [o_slider floatValue]];
1896 - (void)textfieldChanged:(NSNotification *)o_notification
1898 [o_slider setFloatValue: [o_textfield floatValue]];
1903 return [o_slider floatValue];
1908 @implementation BoolConfigControl
1910 - (id) initWithItem: (module_config_t *)_p_item
1911 withView: (NSView *)o_parent_view
1913 NSRect mainFrame = [o_parent_view frame];
1914 NSString *o_labelString, *o_tooltip;
1915 mainFrame.size.height = 17;
1916 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN;
1917 mainFrame.origin.x = LEFTMARGIN;
1918 mainFrame.origin.y = 0;
1920 if( [super initWithFrame: mainFrame item: _p_item] != nil )
1922 i_view_type = CONFIG_ITEM_BOOL;
1924 /* add the checkbox */
1925 o_tooltip = [[VLCMain sharedInstance]
1926 wrapString: [[VLCMain sharedInstance]
1927 localizedString: (char *)p_item->psz_longtext ] toWidth: PREFS_WRAP];
1928 ADD_CHECKBOX( o_checkbox, mainFrame, 0,
1929 0, @"", o_tooltip, p_item->value.i, NSImageLeft)
1930 [o_checkbox setAutoresizingMask:NSViewNotSizable ];
1931 [self addSubview: o_checkbox];
1933 if( p_item->psz_text )
1934 o_labelString = [[VLCMain sharedInstance]
1935 localizedString: (char *)p_item->psz_text];
1937 o_labelString = [NSString stringWithString:@""];
1938 ADD_LABEL( o_label, mainFrame, [o_checkbox frame].size.width, 0, o_labelString, o_tooltip )
1939 [o_label setAutoresizingMask:NSViewNotSizable ];
1940 [self addSubview: o_label];
1947 [o_checkbox release];
1953 return [o_checkbox intValue];
1958 @implementation KeyConfigControl
1959 - (id) initWithItem: (module_config_t *)_p_item
1960 withView: (NSView *)o_parent_view
1962 NSRect mainFrame = [o_parent_view frame];
1963 NSString *o_labelString, *o_tooltip;
1964 mainFrame.size.height = 22;
1965 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN + 1;
1966 mainFrame.origin.x = LEFTMARGIN;
1967 mainFrame.origin.y = 0;
1969 if( [super initWithFrame: mainFrame item: _p_item] != nil )
1971 i_view_type = CONFIG_ITEM_KEY_AFTER_10_3;
1973 o_tooltip = [[VLCMain sharedInstance] wrapString:
1974 [[VLCMain sharedInstance]
1975 localizedString: (char *)p_item->psz_longtext ] toWidth: PREFS_WRAP];
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, o_tooltip )
1984 [o_label setAutoresizingMask:NSViewNotSizable ];
1985 [self addSubview: o_label];
1987 /* build the popup */
1988 ADD_POPUP( o_popup, mainFrame, [o_label frame].origin.x +
1989 [o_label frame].size.width + 3,
1991 [o_popup setAutoresizingMask:NSViewWidthSizable ];
1993 if( o_keys_menu == nil )
1996 o_keys_menu = [[NSMenu alloc] initWithTitle: @"Keys Menu"];
1997 for ( i = 0; i < sizeof(vlc_keys) / sizeof(key_descriptor_t); i++)
1998 if( vlc_keys[i].psz_key_string )
1999 POPULATE_A_KEY( o_keys_menu,
2000 [NSString stringWithUTF8String:vlc_keys[i].psz_key_string]
2001 , vlc_keys[i].i_key_code)
2003 [o_popup setMenu:[o_keys_menu copyWithZone:nil]];
2004 [o_popup selectItem:[[o_popup menu] itemWithTag:p_item->value.i]];
2005 [self addSubview: o_popup];
2011 - (void) alignWithXPosition:(int)i_xPos
2014 NSRect superFrame = [self frame];
2015 frame = [o_label frame];
2016 frame.origin.x = i_xPos - frame.size.width - 3;
2017 [o_label setFrame:frame];
2019 frame = [o_popup frame];
2020 frame.origin.x = i_xPos - 1;
2021 frame.size.width = superFrame.size.width - frame.origin.x + 2;
2022 [o_popup setFrame:frame];
2033 return [o_popup selectedTag];
2037 @implementation ModuleListConfigControl
2038 - (id) initWithItem: (module_config_t *)_p_item
2039 withView: (NSView *)o_parent_view
2041 if( _p_item->i_type == CONFIG_ITEM_MODULE_LIST )
2045 //Fill our array to know how may items we have...
2049 NSRect mainFrame = [o_parent_view frame];
2050 NSString *o_labelString, *o_textfieldString, *o_tooltip;
2052 o_modulearray = [[NSMutableArray alloc] initWithCapacity:10];
2053 /* build a list of available modules */
2054 p_list = vlc_list_find( VLCIntf, VLC_OBJECT_MODULE, FIND_ANYWHERE );
2055 for( i_module_index = 0; i_module_index < p_list->i_count; i_module_index++ )
2058 p_parser = (module_t *)p_list->p_values[i_module_index].p_object;
2060 if( !strcmp( module_GetObjName( p_parser ), "main" ) )
2063 unsigned int confsize;
2064 module_GetConfig( p_parser, &confsize );
2066 for ( i = 0; i < confsize; i++ )
2068 unsigned int unused;
2069 module_config_t *p_config = module_GetConfig( p_parser, &unused ) + i;
2070 NSString *o_modulelongname, *o_modulename;
2071 NSNumber *o_moduleenabled = nil;
2073 /* Hack: required subcategory is stored in i_min */
2074 if( p_config->i_type == CONFIG_SUBCATEGORY &&
2075 p_config->value.i == _p_item->min.i )
2077 o_modulelongname = [NSString stringWithUTF8String:
2078 module_GetLongName( p_parser )];
2079 o_modulename = [NSString stringWithUTF8String:
2080 module_GetObjName( p_parser )];
2082 if( _p_item->value.psz &&
2083 strstr( _p_item->value.psz, module_GetObjName( p_parser ) ) )
2084 o_moduleenabled = [NSNumber numberWithBool:YES];
2086 o_moduleenabled = [NSNumber numberWithBool:NO];
2088 [o_modulearray addObject:[NSMutableArray
2089 arrayWithObjects: o_modulename, o_modulelongname,
2090 o_moduleenabled, nil]];
2094 vlc_list_release( p_list );
2096 mainFrame.size.height = 30 + 18 * [o_modulearray count];
2097 mainFrame.size.width = mainFrame.size.width - LEFTMARGIN - RIGHTMARGIN;
2098 mainFrame.origin.x = LEFTMARGIN;
2099 mainFrame.origin.y = 0;
2100 if( [super initWithFrame: mainFrame item: _p_item] != nil )
2102 i_view_type = CONFIG_ITEM_MODULE_LIST;
2104 o_tooltip = [[VLCMain sharedInstance] wrapString:
2105 [[VLCMain sharedInstance]
2106 localizedString: (char *)p_item->psz_longtext ] toWidth: PREFS_WRAP];
2109 if( p_item->psz_text )
2110 o_labelString = [[VLCMain sharedInstance]
2111 localizedString: (char *)p_item->psz_text];
2113 o_labelString = [NSString stringWithString:@""];
2114 ADD_LABEL( o_label, mainFrame, 0, -3, o_labelString, o_tooltip )
2115 [o_label setAutoresizingMask:NSViewNotSizable ];
2116 [self addSubview: o_label];
2118 /* build the textfield */
2119 if( p_item->value.psz )
2120 o_textfieldString = [[VLCMain sharedInstance]
2121 localizedString: (char *)p_item->value.psz];
2123 o_textfieldString = [NSString stringWithString: @""];
2124 ADD_TEXTFIELD( o_textfield, mainFrame, [o_label frame].size.width + 2,
2125 mainFrame.size.height - 22, mainFrame.size.width -
2126 [o_label frame].size.width - 2, o_tooltip, o_textfieldString )
2127 [o_textfield setAutoresizingMask:NSViewWidthSizable ];
2128 [self addSubview: o_textfield];
2132 NSRect s_rc = mainFrame;
2133 s_rc.size.height = mainFrame.size.height - 30;
2134 s_rc.size.width = mainFrame.size.width - 12;
2137 o_scrollview = [[[NSScrollView alloc] initWithFrame: s_rc] retain];
2138 [o_scrollview setDrawsBackground: NO];
2139 [o_scrollview setBorderType: NSBezelBorder];
2140 [o_scrollview setAutohidesScrollers:YES];
2142 NSTableView *o_tableview;
2143 o_tableview = [[NSTableView alloc] initWithFrame : s_rc];
2144 [o_tableview setUsesAlternatingRowBackgroundColors:YES];
2145 [o_tableview setHeaderView:nil];
2146 /* TODO: find a good way to fix the row height and text size*/
2147 /* FIXME: support for multiple selection... */
2148 // [o_tableview setAllowsMultipleSelection:YES];
2150 NSCell *o_headerCell = [[NSCell alloc] initTextCell:@"Enabled"];
2151 NSCell *o_dataCell = [[NSButtonCell alloc] init];
2152 [(NSButtonCell*)o_dataCell setButtonType:NSSwitchButton];
2153 [o_dataCell setTitle:@""];
2154 [o_dataCell setFont:[NSFont systemFontOfSize:0]];
2155 NSTableColumn *o_tableColumn = [[NSTableColumn alloc]
2156 initWithIdentifier:@"Enabled"];
2157 [o_tableColumn setHeaderCell: o_headerCell];
2158 [o_tableColumn setDataCell: o_dataCell];
2159 [o_tableColumn setWidth:17];
2160 [o_tableview addTableColumn: o_tableColumn];
2162 o_headerCell = [[NSCell alloc] initTextCell:@"Module Name"];
2163 o_dataCell = [[NSTextFieldCell alloc] init];
2164 [o_dataCell setFont:[NSFont systemFontOfSize:12]];
2165 o_tableColumn = [[NSTableColumn alloc]
2166 initWithIdentifier:@"Module"];
2167 [o_tableColumn setHeaderCell: o_headerCell];
2168 [o_tableColumn setDataCell: o_dataCell];
2169 [o_tableColumn setWidth:388 - 17];
2170 [o_tableview addTableColumn: o_tableColumn];
2171 [o_tableview registerForDraggedTypes:[NSArray arrayWithObjects:
2172 @"VLC media player module", nil]];
2174 [o_tableview setDataSource:self];
2175 [o_tableview setTarget: self];
2176 [o_tableview setAction: @selector(tableChanged:)];
2177 [o_tableview sendActionOn:NSLeftMouseUpMask | NSLeftMouseDownMask |
2178 NSLeftMouseDraggedMask];
2179 [o_scrollview setDocumentView: o_tableview];
2181 [o_scrollview setAutoresizingMask:NSViewWidthSizable ];
2182 [self addSubview: o_scrollview];
2189 - (void) alignWithXPosition:(int)i_xPos
2194 - (IBAction)tableChanged:(id)sender
2196 NSString *o_newstring = @"";
2198 for( i = 0 ; i < [o_modulearray count] ; i++ )
2199 if( [[[o_modulearray objectAtIndex:i] objectAtIndex:2]
2202 o_newstring = [o_newstring stringByAppendingString:
2203 [[o_modulearray objectAtIndex:i] objectAtIndex:0]];
2204 o_newstring = [o_newstring stringByAppendingString:@":"];
2207 [o_textfield setStringValue: [o_newstring
2208 substringToIndex: ([o_newstring length])?[o_newstring length] - 1:0]];
2213 [o_scrollview release];
2218 - (char *)stringValue
2220 return strdup( [[o_textfield stringValue] UTF8String] );
2225 @implementation ModuleListConfigControl (NSTableDataSource)
2227 - (BOOL)tableView:(NSTableView*)table writeRows:(NSArray*)rows
2228 toPasteboard:(NSPasteboard*)pb
2230 // We only want to allow dragging of selected rows.
2231 NSEnumerator *iter = [rows objectEnumerator];
2233 while ((row = [iter nextObject]) != nil)
2235 if (![table isRowSelected:[row intValue]])
2239 [pb declareTypes:[NSArray
2240 arrayWithObject:@"VLC media player module"] owner:nil];
2241 [pb setPropertyList:rows forType:@"VLC media player module"];
2245 - (NSDragOperation)tableView:(NSTableView*)table
2246 validateDrop:(id <NSDraggingInfo>)info proposedRow:(int)row
2247 proposedDropOperation:(NSTableViewDropOperation)op
2249 // Make drops at the end of the table go to the end.
2252 row = [table numberOfRows];
2253 op = NSTableViewDropAbove;
2254 [table setDropRow:row dropOperation:op];
2257 // We don't ever want to drop onto a row, only between rows.
2258 if (op == NSTableViewDropOn)
2259 [table setDropRow:(row+1) dropOperation:NSTableViewDropAbove];
2260 return NSTableViewDropAbove;
2263 - (BOOL)tableView:(NSTableView*)table acceptDrop:(id <NSDraggingInfo>)info
2264 row:(int)dropRow dropOperation:(NSTableViewDropOperation)op;
2266 NSPasteboard *pb = [info draggingPasteboard];
2267 NSDragOperation srcMask = [info draggingSourceOperationMask];
2274 // Intra-table drag - data is the array of rows.
2275 if (!accepted && (array =
2276 [pb propertyListForType:@"VLC media player module"]) != NULL)
2278 NSEnumerator *iter = nil;
2280 BOOL isCopy = (srcMask & NSDragOperationMove) ? NO:YES;
2282 iter = [array objectEnumerator];
2283 while ((val = [iter nextObject]) != NULL)
2285 NSArray *o_tmp = [[o_modulearray objectAtIndex:
2286 [val intValue]] mutableCopyWithZone:nil];
2287 [o_modulearray removeObject:o_tmp];
2288 [o_modulearray insertObject:o_tmp
2289 atIndex:(dropRow>[val intValue]) ? dropRow - 1 : dropRow];
2293 // Select the newly-dragged items.
2294 iter = [array objectEnumerator];
2296 [table deselectAll:self];
2298 [self tableChanged:self];
2299 [table setNeedsDisplay:YES];
2300 // Indicate that we finished the drag.
2304 [table setNeedsDisplay:YES];
2308 // An exception occurred. Uh-oh. Update the track table so that
2309 // it stays consistent, and re-raise the exception.
2311 [localException raise];
2312 [table setNeedsDisplay:YES];
2318 - (int)numberOfRowsInTableView:(NSTableView *)aTableView
2320 return [o_modulearray count];
2323 - (id)tableView:(NSTableView *)aTableView
2324 objectValueForTableColumn:(NSTableColumn *)aTableColumn row:(int)rowIndex
2326 if( [[aTableColumn identifier] isEqualToString: @"Enabled"] )
2327 return [[o_modulearray objectAtIndex:rowIndex] objectAtIndex:2];
2328 if( [[aTableColumn identifier] isEqualToString: @"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];