]> git.sesse.net Git - vlc/blob - modules/gui/macosx/sfilters.m
* removed instability warning, which was introduced for the 0.8.5 betas
[vlc] / modules / gui / macosx / sfilters.m
1 /*****************************************************************************
2  * sfilter.m: MacOS X Subpicture filters dialogue
3  *****************************************************************************
4  * Copyright (C) 2005-2006 the VideoLAN team
5  * $Id$
6  *
7  * Authors: Felix Kühne <fkuehne@users.sf.net>
8  *
9  * This program is free software; you can redistribute it and/or modify
10  * it under the terms of the GNU General Public License as published by
11  * the Free Software Foundation; either version 2 of the License, or
12  * (at your option) any later version.
13  *
14  * This program is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17  * GNU General Public License for more details.
18  *
19  * You should have received a copy of the GNU General Public License
20  * along with this program; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
22  *****************************************************************************/
23
24
25 /*****************************************************************************
26  * Note: 
27  * the code used to bind with VLC's core is partially based upon the 
28  * RC-interface, written by Antoine Cellerier and Mark F. Moriarty  
29  * (members of the VideoLAN team) 
30  *****************************************************************************/
31
32 #import "sfilters.h"
33 #import "intf.h"
34 #import <vlc/vout.h>
35
36 /* TODO:
37     - check for memory leaks
38     - save the preferences, if requested
39 */
40
41 @implementation VLCsFilters
42
43 static VLCsFilters *_o_sharedInstance = nil;
44
45 + (VLCsFilters *)sharedInstance
46 {
47     return _o_sharedInstance ? _o_sharedInstance : [[self alloc] init];
48 }
49
50 - (id)init
51 {
52     if (_o_sharedInstance) {
53         [self dealloc];
54     } else {
55         _o_sharedInstance = [super init];
56     }
57
58     return _o_sharedInstance;
59 }
60
61 - (void)dealloc
62 {
63     [o_colors release];
64
65     [super dealloc];
66 }
67
68 - (void)initStrings
69 {
70     [o_sfilter_win setTitle: _NS("Subpicture Filters")];
71     [[o_sfilter_tabView tabViewItemAtIndex: 0] setLabel: _NS("Logo")];
72     [[o_sfilter_tabView tabViewItemAtIndex: 1] setLabel: _NS("Time")];
73     [[o_sfilter_tabView tabViewItemAtIndex: 2] setLabel: _NS("Marquee")];
74     [o_sfilter_saveSettings_ckb setTitle: _NS("Save settings")];
75     [o_logo_image_btn setTitle: _NS("Browse...")];
76     [o_logo_enabled_ckb setTitle: _NS("Enabled")];
77     [o_logo_image_lbl setStringValue: [_NS("Image") \
78         stringByAppendingString: @":"]];
79     [o_logo_pos_lbl setStringValue: [_NS("Position") \
80         stringByAppendingString: @":"]];
81     [o_logo_opaque_lbl setStringValue: [_NS("Opaqueness") \
82         stringByAppendingString: @":"]];
83     [o_time_enabled_ckb setTitle: _NS("Enabled")];
84     [o_time_stamp_lbl setStringValue: [_NS("Timestamp") \
85         stringByAppendingString: @":"]];
86     [o_time_size_lbl setStringValue: [_NS("Size") \
87         stringByAppendingString: @":"]];
88     [o_time_color_lbl setStringValue: [_NS("Color") \
89         stringByAppendingString: @":"]];
90     [o_time_opaque_lbl setStringValue: [_NS("Opaqueness") \
91         stringByAppendingString: @":"]];
92     [o_time_pos_lbl setStringValue: [_NS("Position") \
93         stringByAppendingString: @":"]];
94     [o_time_size_inPx_lbl setStringValue: _NS("(in pixels)")];
95     [o_marq_enabled_ckb setTitle: _NS("Enabled")];
96     [o_marq_color_lbl setStringValue: [_NS("Color") \
97         stringByAppendingString: @":"]];
98     [o_marq_marq_lbl setStringValue: [_NS("Marquee") \
99         stringByAppendingString: @":"]];
100     [o_marq_opaque_lbl setStringValue: [_NS("Opaqueness") \
101         stringByAppendingString: @":"]];
102     [o_marq_tmOut_lbl setStringValue: [_NS("Timeout") \
103         stringByAppendingString: @":"]];
104     [o_marq_tmOut_ms_lbl setStringValue: _NS("ms")];
105     [o_marq_pos_lbl setStringValue: [_NS("Position") \
106         stringByAppendingString: @":"]];
107     [o_marq_size_lbl setStringValue: [_NS("Size") \
108         stringByAppendingString: @":"]];
109     [o_time_color_lbl setStringValue: _NS("(in pixels)")];
110 }
111
112 - (void)awakeFromNib
113 {
114     /* colors as implemented at the beginning of marq.c and time.c
115      * feel free to add more colors, but remember to add them to these files 
116      * as well to keep a certain level of consistency across the interfaces */
117     NSArray * o_default;
118     NSArray * o_black;
119     NSArray * o_gray;
120     NSArray * o_silver;
121     NSArray * o_white;
122     NSArray * o_maroon;
123     NSArray * o_red;
124     NSArray * o_fuchsia;
125     NSArray * o_yellow;
126     NSArray * o_olive;
127     NSArray * o_green;
128     NSArray * o_teal;
129     NSArray * o_lime;
130     NSArray * o_purple;
131     NSArray * o_navy;
132     NSArray * o_blue;
133     NSArray * o_aqua;
134     o_default = [NSArray arrayWithObjects: _NS("Default"), @"-1", nil];
135     o_black = [NSArray arrayWithObjects: _NS("Black"), @"0x000000", nil];
136     o_gray = [NSArray arrayWithObjects: _NS("Gray"), @"0x808080", nil];
137     o_silver = [NSArray arrayWithObjects: _NS("Silver"), @"0xC0C0C0", nil];
138     o_white = [NSArray arrayWithObjects: _NS("White"), @"0xFFFFFF", nil];
139     o_maroon = [NSArray arrayWithObjects: _NS("Maroon"), @"0x800000", nil];
140     o_red = [NSArray arrayWithObjects: _NS("Red"), @"0xFF0000", nil];
141     o_fuchsia = [NSArray arrayWithObjects: _NS("Fuchsia"), @"0xFF00FF", nil];
142     o_yellow = [NSArray arrayWithObjects: _NS("Yellow"), @"0xFFFF00", nil];
143     o_olive = [NSArray arrayWithObjects: _NS("Olive"), @"0x808000", nil];
144     o_green = [NSArray arrayWithObjects: _NS("Green"), @"0x008000", nil];
145     o_teal = [NSArray arrayWithObjects: _NS("Teal"), @"0x008080", nil];
146     o_lime = [NSArray arrayWithObjects: _NS("Lime"), @"0x00FF00", nil];
147     o_purple = [NSArray arrayWithObjects: _NS("Purple"), @"0x800080", nil];
148     o_navy = [NSArray arrayWithObjects: _NS("Navy"), @"0x000080", nil];
149     o_blue = [NSArray arrayWithObjects: _NS("Blue"), @"0x0000FF", nil];
150     o_aqua = [NSArray arrayWithObjects: _NS("Aqua"), @"0x00FFFF", nil];
151     o_colors = [[NSArray alloc] initWithObjects: o_default, o_black, o_gray, \
152         o_silver, o_white, o_maroon, o_red, o_fuchsia, o_yellow, o_olive, \
153         o_green, o_teal, o_lime, o_purple, o_navy, o_blue, o_aqua, nil];
154
155     unsigned int x = 0;
156     [o_marq_color_pop removeAllItems];
157     [o_time_color_pop removeAllItems];
158     
159     /* we are adding tags to the items, so we can easily identify them even if 
160      * the menu was sorted */
161     while (x != [o_colors count])
162     {
163         [o_marq_color_pop addItemWithTitle: [[o_colors objectAtIndex:x] \
164             objectAtIndex:0]];
165         [[o_marq_color_pop lastItem] setTag: x];
166         
167         [o_time_color_pop addItemWithTitle: [[o_colors objectAtIndex:x] \
168             objectAtIndex:0]];
169         [[o_time_color_pop lastItem] setTag: x];
170         
171         x = (x + 1);
172     }
173
174     [o_marq_color_pop selectItemAtIndex:0];
175     [o_time_color_pop selectItemAtIndex:0];
176
177     /* define the relative positions and copy them to the menues
178      * we can destroy the array afterwards, because we are saving the ints 
179      * as tags to the menu-items */
180     NSArray * o_cnt_cnt;
181     NSArray * o_lft_cnt;
182     NSArray * o_rht_cnt;
183     NSArray * o_cnt_top;
184     NSArray * o_lft_top;
185     NSArray * o_rht_top;
186     NSArray * o_cnt_btm;
187     NSArray * o_lft_btm;
188     NSArray * o_rht_btm;
189     NSArray * o_positions;
190     o_cnt_cnt = [NSArray arrayWithObjects: _NS("Center-Center"), @"0", nil];
191     o_lft_cnt = [NSArray arrayWithObjects: _NS("Left-Center"), @"1", nil];
192     o_rht_cnt = [NSArray arrayWithObjects: _NS("Right-Center"), @"2", nil];
193     o_cnt_top = [NSArray arrayWithObjects: _NS("Center-Top"), @"4", nil];
194     o_lft_top = [NSArray arrayWithObjects: _NS("Left-Top"), @"5", nil];
195     o_rht_top = [NSArray arrayWithObjects: _NS("Right-Top"), @"6", nil];
196     o_cnt_btm = [NSArray arrayWithObjects: _NS("Center-Bottom"), @"8", nil];
197     o_lft_btm = [NSArray arrayWithObjects: _NS("Left-Bottom"), @"9", nil];
198     o_rht_btm = [NSArray arrayWithObjects: _NS("Right-Bottom"), @"10", nil];
199     o_positions = [[NSArray alloc] initWithObjects: o_cnt_cnt, o_lft_cnt, \
200         o_rht_cnt, o_cnt_top, o_lft_top, o_rht_top, o_cnt_btm, o_lft_btm, \
201         o_rht_btm, nil];
202         
203     x = 0;
204     [o_time_pos_rel_pop removeAllItems];
205     [o_marq_pos_rel_pop removeAllItems];
206     [o_logo_pos_rel_pop removeAllItems];
207     
208     /* we are adding a tag here, so we can easily select an item later on */
209     while ( x != [o_positions count] )
210     {
211         [o_time_pos_rel_pop addItemWithTitle: [[o_positions objectAtIndex:x] \
212             objectAtIndex:0]];
213         [[o_time_pos_rel_pop lastItem] setTag: [[[o_positions objectAtIndex:x] \
214             objectAtIndex:1] intValue]];
215         [o_marq_pos_rel_pop addItemWithTitle: [[o_positions objectAtIndex:x] \
216             objectAtIndex:0]];
217         [[o_marq_pos_rel_pop lastItem] setTag: [[[o_positions objectAtIndex:x] \
218             objectAtIndex:1] intValue]];
219         [o_logo_pos_rel_pop addItemWithTitle: [[o_positions objectAtIndex:x] \
220             objectAtIndex:0]];
221         [[o_logo_pos_rel_pop lastItem] setTag: [[[o_positions objectAtIndex:x] \
222             objectAtIndex:1] intValue]];
223
224         x = (x + 1);
225     }
226     [o_positions release];
227
228     NSArray * o_sizes;
229     o_sizes = [[NSArray alloc] initWithObjects: @"6", @"8", @"10", @"11", @"12",\
230         @"14", @"13", @"16", @"18", @"24", @"36", @"48", @"64", @"72", @"96", \
231         @"144", @"288", nil];
232     [o_marq_size_pop removeAllItems];
233     [o_marq_size_pop addItemsWithTitles: o_sizes];
234     [o_time_size_pop removeAllItems];
235     [o_time_size_pop addItemsWithTitles: o_sizes];
236     [o_sizes release];
237 }
238
239 - (void)showAsPanel
240 {
241     /* called from intf.m */
242     [o_sfilter_win displayIfNeeded];
243     [o_sfilter_win makeKeyAndOrderFront:nil];
244
245     intf_thread_t * p_intf = VLCIntf;
246
247     /* retrieve the marquee settings */
248     int x = 0;
249     int tempInt = config_GetInt( p_intf, "marq-color" );
250     while( strtol([[[o_colors objectAtIndex:x] objectAtIndex:1] UTF8String], \
251         NULL, 0) != tempInt )
252     {
253         x = (x + 1);
254         
255         if( x >= [o_marq_color_pop numberOfItems] )
256         {
257             x = 0;
258             return;
259         }
260     }
261     [o_marq_color_pop selectItemAtIndex: x];
262     [o_marq_marq_fld setStringValue: [NSString stringWithUTF8String: \
263         config_GetPsz( p_intf, "marq-marquee" )]];
264     [o_marq_opaque_sld setIntValue: config_GetInt( p_intf, "marq-opacity")];
265     x = 0;
266     tempInt = config_GetInt( p_intf, "marq-position" );
267     while( tempInt != [[o_marq_pos_rel_pop itemAtIndex:x] tag] )
268     {
269         x = (x + 1);
270         
271         if( x >= [o_marq_pos_rel_pop numberOfItems] )
272         {
273             x = 0;
274             return;
275         }
276     }
277     [o_marq_pos_rel_pop selectItemAtIndex:x];
278     x = 0;
279     tempInt = config_GetInt( p_intf, "marq-size" );
280     while( [[[o_marq_size_pop itemAtIndex: x] title] intValue] != tempInt )
281         x = (x + 1);
282         
283         if( x >= [o_marq_size_pop numberOfItems] )
284         {
285             x = 0;
286             return;
287         }
288     [o_marq_size_pop selectItemAtIndex: x];
289     [o_marq_tmOut_fld setStringValue: [[NSNumber numberWithInt: \
290         config_GetInt( p_intf, "marq-timeout" )] stringValue]];
291     
292     /* retrieve the time settings */
293     x = 0;
294     tempInt = config_GetInt( p_intf, "time-color" );
295     while( strtol([[[o_colors objectAtIndex:x] objectAtIndex:1] UTF8String], \
296         NULL, 0) != tempInt )
297     {
298         x = (x + 1);
299         
300         if( x >= [o_time_color_pop numberOfItems] )
301         {
302             x = 0;
303             return;
304         }
305     }
306     [o_time_color_pop selectItemAtIndex: x];
307     [o_time_stamp_fld setStringValue: [NSString stringWithUTF8String: \
308         config_GetPsz( p_intf, "time-format" )]];
309     [o_time_opaque_sld setIntValue: config_GetInt( p_intf, "time-opacity")];
310     x = 0;
311     tempInt = config_GetInt( p_intf, "time-size" );
312     while( [[[o_time_size_pop itemAtIndex: x] title] intValue] != tempInt )
313         x = (x + 1);
314         
315         if( x >= [o_time_size_pop numberOfItems] )
316         {
317             x = 0;
318             return;
319         }
320     [o_time_size_pop selectItemAtIndex: x];
321     x = 0;
322     tempInt = config_GetInt( p_intf, "time-position" );
323     while( tempInt != [[o_time_pos_rel_pop itemAtIndex:x] tag] )
324     {
325         x = (x + 1);
326         
327         if( x >= [o_time_pos_rel_pop numberOfItems] )
328         {
329             x = 0;
330             return;
331         }
332     }
333     
334     /* retrieve the logo settings */
335     [o_logo_opaque_sld setIntValue: config_GetInt( p_intf, "logo-transparency")];
336     /* in case that no path has been saved yet */
337     NSString * tempString = [[NSString alloc] initWithUTF8String: \
338         config_GetPsz( p_intf, "logo-file" )];
339     if( [tempString length] == 0 )
340     {
341         [o_logo_image_fld setStringValue: @""];
342     }
343     else
344     {
345         [o_logo_image_fld setStringValue: tempString ];
346     }
347     [tempString release];
348     x = 0;
349     tempInt = config_GetInt( p_intf, "logo-position" );
350     while( tempInt != [[o_logo_pos_rel_pop itemAtIndex:x] tag] )
351     {
352         x = (x + 1);
353         
354         if( x >= [o_logo_pos_rel_pop numberOfItems] )
355         {
356             x = 0;
357             return;
358         }
359     }
360     
361     /* enable the wanted filters */
362     char * psz_subfilters;
363     psz_subfilters = config_GetPsz( p_intf, "sub-filter" );
364     if( psz_subfilters )
365     {
366         [o_marq_enabled_ckb setState: (int)strstr( psz_subfilters, "marq")];
367         [o_logo_enabled_ckb setState: (int)strstr( psz_subfilters, "logo")];
368         [o_time_enabled_ckb setState: (int)strstr( psz_subfilters, "time")];
369         [self enableMarq];
370         [self enableLogo];
371         [self enableTime];
372     }
373 }
374
375 - (IBAction)logo_selectFile:(id)sender
376 {
377     NSOpenPanel * openPanel = [NSOpenPanel openPanel];
378     SEL sel = @selector(logo_getFile:returnCode:contextInfo:);
379     [openPanel beginSheetForDirectory:nil file:nil types: [NSArray \
380         arrayWithObjects: @"png", @"PNG", @"'PNGf'", nil] modalForWindow: \
381         o_sfilter_win modalDelegate:self didEndSelector:sel contextInfo:nil];
382 }
383
384 - (void)logo_getFile: (NSOpenPanel *)sheet returnCode: \
385     (int)returnCode contextInfo: (void *)contextInfo
386 {
387     if (returnCode == NSOKButton)
388     {
389         [o_logo_image_fld setStringValue: [sheet filename]];
390     }
391 }
392
393 - (IBAction)propertyChanged:(id)sender
394 {
395     intf_thread_t * p_intf = VLCIntf;
396     input_thread_t * p_input = (input_thread_t *)vlc_object_find( p_intf, \
397         VLC_OBJECT_INPUT, FIND_ANYWHERE );
398
399     vlc_value_t val;
400
401     /* general properties */
402     if( sender == o_sfilter_saveSettings_ckb)
403     {
404         o_save_settings = [o_sfilter_saveSettings_ckb state]; 
405     }
406
407     /* marquee */
408     else if( sender == o_marq_marq_fld )
409     {
410         if( [[o_marq_marq_fld stringValue] length] == 0 )
411         {
412             val.psz_string = "";
413         }
414         else
415         {
416             val.psz_string = (char *)[[o_marq_marq_fld stringValue] UTF8String];
417         }
418
419         if( p_input )
420             var_Set( p_input->p_libvlc, "marq-marquee", val );
421
422         config_PutPsz( p_intf, "marq-marquee", val.psz_string );
423     }
424     
425     else if( sender == o_marq_pos_rel_pop )
426     {
427         val.i_int = [[o_marq_pos_rel_pop selectedItem] tag];
428
429         if( p_input )
430             var_Set( p_input->p_libvlc, "marq-position", val );
431
432         config_PutInt( p_intf, "marq-position", val.i_int );
433     }
434     
435     else if( sender == o_marq_color_pop )
436     {
437         val.i_int = strtol( [[[o_colors objectAtIndex: [o_marq_color_pop \
438             indexOfSelectedItem]] objectAtIndex: 1] UTF8String], NULL, 0 );
439
440         if( p_input )
441             var_Set( p_input->p_libvlc, "marq-color", val );
442
443         config_PutInt( p_intf, "marq-color", val.i_int );
444     }
445     
446     else if( sender == o_marq_opaque_sld )
447     {
448         val.i_int = [o_marq_opaque_sld intValue];
449
450         if( p_input )
451             var_Set( p_input->p_libvlc, "marq-opacity", val );
452
453         config_PutInt( p_intf, "marq-opacity", val.i_int );
454     }
455     
456     else if( sender == o_marq_size_pop )
457     {
458         val.i_int = [[o_marq_size_pop titleOfSelectedItem] intValue];
459
460         if( p_input )
461             var_Set( p_input->p_libvlc, "marq-size", val );
462
463         config_PutInt( p_intf, "marq-size", val.i_int );
464     }
465     
466     else if( sender == o_marq_tmOut_fld && [[sender stringValue] length] > 0 )
467     {
468         val.i_int = [o_marq_tmOut_fld intValue];
469
470         if( p_input )
471             var_Set( p_input->p_libvlc, "marq-timeout", val );
472
473         config_PutInt( p_intf, "marq-timeout", val.i_int );
474     }
475     
476     /* time */
477     
478     else if( sender == o_time_stamp_fld )
479     {
480         if( [[o_time_stamp_fld stringValue] length] == 0 )
481         {
482             val.psz_string = "";
483         }
484         else
485         {
486             val.psz_string = (char *)[[o_time_stamp_fld stringValue] UTF8String];
487         }
488
489         if( p_input )
490             var_Set( p_input->p_libvlc, "time-format", val );
491
492         config_PutPsz( p_intf, "time-format", val.psz_string );
493     }
494
495     else if( sender == o_time_pos_rel_pop )
496     {
497         val.i_int = [[o_time_pos_rel_pop selectedItem] tag];
498
499         if( p_input )
500             var_Set( p_input->p_libvlc, "time-position", val );
501
502         config_PutInt( p_intf, "time-position", val.i_int );
503     }
504     
505     else if( sender == o_time_color_pop )
506     {
507         val.i_int = strtol( [[[o_colors objectAtIndex: [o_time_color_pop \
508             indexOfSelectedItem]] objectAtIndex: 1] UTF8String], NULL, 0 );
509
510         if( p_input )
511             var_Set( p_input->p_libvlc, "time-color", val );
512
513         config_PutInt( p_intf, "time-color", val.i_int );
514     }
515     
516     else if( sender == o_time_opaque_sld )
517     {
518         val.i_int = [o_time_opaque_sld intValue];
519
520         if( p_input )
521             var_Set( p_input->p_libvlc, "time-opacity", val );
522
523         config_PutInt( p_intf, "time-opacity", val.i_int );
524     }
525     
526     else if( sender == o_time_size_pop )
527     {
528         val.i_int = [[o_time_size_pop titleOfSelectedItem] intValue];
529
530         if( p_input )
531             var_Set( p_input->p_libvlc, "time-size", val );
532
533         config_PutInt( p_intf, "time-size", val.i_int );
534     }
535
536     /* logo */
537     else if( sender == o_logo_opaque_sld )
538     {
539         val.i_int = [o_logo_opaque_sld intValue];
540
541         if( p_input )
542             var_Set( p_input->p_libvlc, "logo-transparency", val );
543
544         config_PutInt( p_intf, "logo-transparency", val.i_int );
545     }
546     
547     else if( sender == o_logo_pos_rel_pop )
548     {
549         val.i_int = [[o_logo_pos_rel_pop selectedItem] tag];
550
551         if( p_input )
552             var_Set( p_input->p_libvlc, "logo-position", val );
553
554         config_PutInt( p_intf, "logo-position", val.i_int );
555     }
556
557     /* clean up */
558     if ( p_input )
559     {
560         o_config_changed = YES;
561         vlc_object_release( p_input );
562     }
563 }
564
565 - (IBAction)enableFilter:(id)sender
566 {
567     if( sender == o_marq_enabled_ckb )
568     {
569         if( [o_marq_enabled_ckb state] == NSOnState )
570         {
571             [self changeFiltersString:"marq" onOrOff:VLC_TRUE];
572         }
573         else
574         {
575             [self changeFiltersString:"marq" onOrOff:VLC_FALSE];
576         }
577         [self enableMarq];
578     }
579     if( sender == o_logo_enabled_ckb )
580     {
581         if( [o_logo_enabled_ckb state] == NSOnState )
582         {
583             [self changeFiltersString:"logo" onOrOff:VLC_TRUE];
584         }
585         else
586         {
587             [self changeFiltersString:"logo" onOrOff:VLC_FALSE];
588         }
589         [self enableLogo];
590     }
591     if( sender == o_time_enabled_ckb )
592     {
593         if( [o_time_enabled_ckb state] == NSOnState )
594         {
595             [self changeFiltersString:"time" onOrOff:VLC_TRUE];
596         }
597         else
598         {
599             [self changeFiltersString:"time" onOrOff:VLC_FALSE];
600         }
601         [self enableTime];
602     }    
603 }
604
605 - (void)enableMarq
606 {
607     [o_marq_color_pop setEnabled: [o_marq_enabled_ckb state]];
608     [o_marq_marq_fld setEnabled: [o_marq_enabled_ckb state]];
609     [o_marq_opaque_sld setEnabled: [o_marq_enabled_ckb state]];
610     [o_marq_size_pop setEnabled: [o_marq_enabled_ckb state]];
611     [o_marq_tmOut_fld setEnabled: [o_marq_enabled_ckb state]];
612     [o_marq_pos_rel_pop setEnabled: [o_marq_enabled_ckb state]];
613 }
614
615 - (void)enableTime
616 {
617     [o_time_color_pop setEnabled: [o_time_enabled_ckb state]];
618     [o_time_stamp_fld setEnabled: [o_time_enabled_ckb state]];
619     [o_time_opaque_sld setEnabled: [o_time_enabled_ckb state]];
620     [o_time_size_pop setEnabled: [o_time_enabled_ckb state]];
621     [o_time_pos_rel_pop setEnabled: [o_time_enabled_ckb state]];
622 }
623
624 - (void)enableLogo
625 {
626     [o_logo_image_btn setEnabled: [o_logo_enabled_ckb state]];
627     [o_logo_image_fld setEnabled: [o_logo_enabled_ckb state]];
628     [o_logo_opaque_sld setEnabled: [o_logo_enabled_ckb state]];
629     [o_logo_pos_rel_pop setEnabled: [o_logo_enabled_ckb state]];
630 }
631
632 - (void)changeFiltersString:(char *)psz_name onOrOff:(vlc_bool_t )b_add
633 {
634     /* copied from ../wxwidgets/extrapanel.cpp
635      * renamed to conform with Cocoa's rules
636      * and slightly modified to suit our needs */
637
638     intf_thread_t * p_intf = VLCIntf;
639     
640     char *psz_parser, *psz_string;
641     psz_string = config_GetPsz( p_intf, "sub-filter" );
642     
643     if( !psz_string ) psz_string = strdup("");
644
645     psz_parser = strstr( psz_string, psz_name );
646
647     if( b_add )
648     {
649         if( !psz_parser )
650         {
651             psz_parser = psz_string;
652             asprintf( &psz_string, (*psz_string) ? "%s:%s" : "%s%s",
653                             psz_string, psz_name );
654             free( psz_parser );
655         }
656         else
657         {
658             return;
659         }
660     }
661     else
662     {
663         if( psz_parser )
664         {
665             memmove( psz_parser, psz_parser + strlen(psz_name) +
666                             (*(psz_parser + strlen(psz_name)) == ':' ? 1 : 0 ),
667                             strlen(psz_parser + strlen(psz_name)) + 1 );
668
669             /* Remove trailing : : */
670             if( *(psz_string+strlen(psz_string ) -1 ) == ':' )
671             {
672                 *(psz_string+strlen(psz_string ) -1 ) = '\0';
673             }
674          }
675          else
676          {
677              free( psz_string );
678              return;
679          }
680     }
681     
682     config_PutPsz( p_intf, "sub-filter", psz_string );
683     
684     /* Try to set on the fly */
685     /* FIXME: enable this once we support on-the-fly addition of this kind of
686      * filters...
687     vout_thread_t *p_vout;
688     p_vout = (vout_thread_t *)vlc_object_find( p_intf, VLC_OBJECT_VOUT,
689                                               FIND_ANYWHERE );
690     if( p_vout )
691     {
692         var_SetString( p_vout, "sub-filter", psz_string );
693         vlc_object_release( p_vout );
694     }*/
695
696     free( psz_string );
697
698     vlc_object_release( p_intf );
699
700     o_config_changed = YES;
701 }
702 @end