Main Page | Modules | Class Hierarchy | Class List | Directories | File List | Class Members | File Members | Related Pages

controls.m

00001 /*****************************************************************************
00002  * controls.m: MacOS X interface module
00003  *****************************************************************************
00004  * Copyright (C) 2002-2005 the VideoLAN team
00005  * $Id: controls.m 12412 2005-08-27 16:40:23Z jpsaman $
00006  *
00007  * Authors: Jon Lech Johansen <[email protected]>
00008  *          Christophe Massiot <[email protected]>
00009  *          Derk-Jan Hartman <hartman at videolan dot org>
00010  *
00011  * This program is free software; you can redistribute it and/or modify
00012  * it under the terms of the GNU General Public License as published by
00013  * the Free Software Foundation; either version 2 of the License, or
00014  * (at your option) any later version.
00015  * 
00016  * This program is distributed in the hope that it will be useful,
00017  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00018  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00019  * GNU General Public License for more details.
00020  *
00021  * You should have received a copy of the GNU General Public License
00022  * along with this program; if not, write to the Free Software
00023  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
00024  *****************************************************************************/
00025 
00026 /*****************************************************************************
00027  * Preamble
00028  *****************************************************************************/
00029 #include <stdlib.h>                                      /* malloc(), free() */
00030 #include <sys/param.h>                                    /* for MAXPATHLEN */
00031 #include <string.h>
00032 
00033 #include "intf.h"
00034 #include "vout.h"
00035 #include "open.h"
00036 #include "controls.h"
00037 #include <vlc_osd.h>
00038 
00039 /*****************************************************************************
00040  * VLCControls implementation 
00041  *****************************************************************************/
00042 @implementation VLCControls
00043 
00044 - (IBAction)play:(id)sender
00045 {
00046     vlc_value_t val;
00047     intf_thread_t * p_intf = VLCIntf;
00048     playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
00049                                         FIND_ANYWHERE );
00050     if( p_playlist )
00051     {
00052         vlc_mutex_lock( &p_playlist->object_lock );
00053         if( p_playlist->i_size <= 0 )
00054         {
00055             vlc_mutex_unlock( &p_playlist->object_lock );
00056             vlc_object_release( p_playlist );
00057             [o_main intfOpenFileGeneric: (id)sender];
00058         }
00059         else
00060         {
00061             vlc_mutex_unlock( &p_playlist->object_lock );
00062             vlc_object_release( p_playlist );
00063         }
00064 
00065     }
00066     val.i_int = config_GetInt( p_intf, "key-play-pause" );
00067     var_Set( p_intf->p_vlc, "key-pressed", val );
00068 }
00069 
00070 - (IBAction)stop:(id)sender
00071 {
00072     vlc_value_t val;
00073     intf_thread_t * p_intf = VLCIntf;
00074     val.i_int = config_GetInt( p_intf, "key-stop" );
00075     var_Set( p_intf->p_vlc, "key-pressed", val );
00076 }
00077 
00078 - (IBAction)faster:(id)sender
00079 {
00080     vlc_value_t val;
00081     intf_thread_t * p_intf = VLCIntf;
00082     val.i_int = config_GetInt( p_intf, "key-faster" );
00083     var_Set( p_intf->p_vlc, "key-pressed", val );
00084 }
00085 
00086 - (IBAction)slower:(id)sender
00087 {
00088     vlc_value_t val;
00089     intf_thread_t * p_intf = VLCIntf;
00090     val.i_int = config_GetInt( p_intf, "key-slower" );
00091     var_Set( p_intf->p_vlc, "key-pressed", val );
00092 }
00093 
00094 - (IBAction)prev:(id)sender
00095 {
00096     vlc_value_t val;
00097     intf_thread_t * p_intf = VLCIntf;
00098     val.i_int = config_GetInt( p_intf, "key-prev" );
00099     var_Set( p_intf->p_vlc, "key-pressed", val );
00100 }
00101 
00102 - (IBAction)next:(id)sender
00103 {
00104     vlc_value_t val;
00105     intf_thread_t * p_intf = VLCIntf;
00106     val.i_int = config_GetInt( p_intf, "key-next" );
00107     var_Set( p_intf->p_vlc, "key-pressed", val );
00108 }
00109 
00110 - (IBAction)random:(id)sender
00111 {
00112     vlc_value_t val;
00113     intf_thread_t * p_intf = VLCIntf;
00114     playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
00115                                                        FIND_ANYWHERE );
00116     if( p_playlist == NULL )
00117     {
00118         return;
00119     }
00120 
00121     var_Get( p_playlist, "random", &val );
00122     val.b_bool = !val.b_bool;
00123     var_Set( p_playlist, "random", val );
00124     if( val.b_bool )
00125     {
00126         vout_OSDMessage( p_intf, DEFAULT_CHAN, _( "Random On" ) );
00127     }
00128     else
00129     {
00130         vout_OSDMessage( p_intf, DEFAULT_CHAN, _( "Random Off" ) );
00131     }
00132 
00133     p_intf->p_sys->b_playmode_update = VLC_TRUE;
00134     p_intf->p_sys->b_intf_update = VLC_TRUE;
00135     vlc_object_release( p_playlist );
00136 }
00137 
00138 - (IBAction)repeat:(id)sender
00139 {
00140     vlc_value_t val;
00141     intf_thread_t * p_intf = VLCIntf;
00142     playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
00143                                                        FIND_ANYWHERE );
00144     if( p_playlist == NULL )
00145     {
00146         return;
00147     }
00148 
00149     var_Get( p_playlist, "repeat", &val );
00150     if (!val.b_bool)
00151     {
00152         var_Set( p_playlist, "loop", val );
00153     }
00154     val.b_bool = !val.b_bool;
00155     var_Set( p_playlist, "repeat", val );
00156     if( val.b_bool )
00157     {
00158         vout_OSDMessage( p_intf, DEFAULT_CHAN, _( "Repeat One" ) );
00159     }
00160     else
00161     {
00162         vout_OSDMessage( p_intf, DEFAULT_CHAN, _( "Repeat Off" ) );
00163     }
00164 
00165     p_intf->p_sys->b_playmode_update = VLC_TRUE;
00166     p_intf->p_sys->b_intf_update = VLC_TRUE;
00167     vlc_object_release( p_playlist );
00168 }
00169 
00170 - (IBAction)loop:(id)sender
00171 {
00172     vlc_value_t val;
00173     intf_thread_t * p_intf = VLCIntf;
00174     playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
00175                                                        FIND_ANYWHERE );
00176     if( p_playlist == NULL )
00177     {
00178         return;
00179     }
00180 
00181     var_Get( p_playlist, "loop", &val );
00182     if (!val.b_bool)
00183     {
00184         var_Set( p_playlist, "repeat", val );
00185     }
00186     val.b_bool = !val.b_bool;
00187     var_Set( p_playlist, "loop", val );
00188     if( val.b_bool )
00189     {
00190         vout_OSDMessage( p_intf, DEFAULT_CHAN, _( "Repeat All" ) );
00191     }
00192     else
00193     {
00194         vout_OSDMessage( p_intf, DEFAULT_CHAN, _( "Repeat Off" ) );
00195     }
00196 
00197     p_intf->p_sys->b_playmode_update = VLC_TRUE;
00198     p_intf->p_sys->b_intf_update = VLC_TRUE;
00199     vlc_object_release( p_playlist );
00200 }
00201 
00202 - (IBAction)forward:(id)sender
00203 {
00204     vlc_value_t val;
00205     intf_thread_t * p_intf = VLCIntf;
00206     val.i_int = config_GetInt( p_intf, "key-jump+10sec" );
00207     var_Set( p_intf->p_vlc, "key-pressed", val );
00208 }
00209 
00210 - (IBAction)backward:(id)sender
00211 {
00212     vlc_value_t val;
00213     intf_thread_t * p_intf = VLCIntf;
00214     val.i_int = config_GetInt( p_intf, "key-jump-10sec" );
00215     var_Set( p_intf->p_vlc, "key-pressed", val );
00216 }
00217 
00218 
00219 - (IBAction)volumeUp:(id)sender
00220 {
00221     vlc_value_t val;
00222     intf_thread_t * p_intf = VLCIntf;
00223     val.i_int = config_GetInt( p_intf, "key-vol-up" );
00224     var_Set( p_intf->p_vlc, "key-pressed", val );
00225     /* Manage volume status */
00226     [o_main manageVolumeSlider];
00227 }
00228 
00229 - (IBAction)volumeDown:(id)sender
00230 {
00231     vlc_value_t val;
00232     intf_thread_t * p_intf = VLCIntf;
00233     val.i_int = config_GetInt( p_intf, "key-vol-down" );
00234     var_Set( p_intf->p_vlc, "key-pressed", val );
00235     /* Manage volume status */
00236     [o_main manageVolumeSlider];
00237 }
00238 
00239 - (IBAction)mute:(id)sender
00240 {
00241     vlc_value_t val;
00242     intf_thread_t * p_intf = VLCIntf;
00243     val.i_int = config_GetInt( p_intf, "key-vol-mute" );
00244     var_Set( p_intf->p_vlc, "key-pressed", val );
00245     /* Manage volume status */
00246     [o_main manageVolumeSlider];
00247 }
00248 
00249 - (IBAction)volumeSliderUpdated:(id)sender
00250 {
00251     intf_thread_t * p_intf = VLCIntf;
00252     audio_volume_t i_volume = (audio_volume_t)[sender intValue];
00253     int i_volume_step = 0;
00254     i_volume_step = config_GetInt( p_intf->p_vlc, "volume-step" );
00255     aout_VolumeSet( p_intf, i_volume * i_volume_step );
00256     /* Manage volume status */
00257     [o_main manageVolumeSlider];
00258 }
00259 
00260 - (IBAction)windowAction:(id)sender
00261 {
00262     id o_window = [NSApp keyWindow];
00263     NSString *o_title = [sender title];
00264     NSArray *o_windows = [NSApp orderedWindows];
00265     NSEnumerator *o_enumerator = [o_windows objectEnumerator];
00266     vout_thread_t *p_vout = vlc_object_find( VLCIntf, VLC_OBJECT_VOUT,
00267                                               FIND_ANYWHERE );
00268 
00269     if( p_vout != NULL )
00270     {
00271         while ((o_window = [o_enumerator nextObject]))
00272         {
00273             if( [[o_window className] isEqualToString: @"VLCWindow"] )
00274             {
00275                 if( [o_title isEqualToString: _NS("Half Size") ] )
00276                     [o_window scaleWindowWithFactor: 0.5];
00277                 else if( [o_title isEqualToString: _NS("Normal Size") ] )
00278                     [o_window scaleWindowWithFactor: 1.0];
00279                 else if( [o_title isEqualToString: _NS("Double Size") ] )
00280                     [o_window scaleWindowWithFactor: 2.0];
00281                 else if( [o_title isEqualToString: _NS("Float on Top") ] )
00282                     [o_window toggleFloatOnTop];
00283                 else if( [o_title isEqualToString: _NS("Fit to Screen") ] )
00284                 {
00285                     if( ![o_window isZoomed] )
00286                         [o_window performZoom:self];
00287                 }
00288                 else if( [o_title isEqualToString: _NS("Snapshot") ] )
00289                 {
00290                     [o_window snapshot];
00291                 }
00292                 else
00293                 {
00294                     [o_window toggleFullscreen];
00295                 }
00296                 break;
00297             }
00298         }
00299         vlc_object_release( (vlc_object_t *)p_vout );
00300     }
00301     else
00302     {
00303         playlist_t * p_playlist = vlc_object_find( VLCIntf, VLC_OBJECT_PLAYLIST,
00304                                               FIND_ANYWHERE );
00305 
00306         if( p_playlist && ( [o_title isEqualToString: _NS("Fullscreen")] ||
00307             [sender isKindOfClass:[NSButton class]] ) )
00308         {
00309             vlc_value_t val;
00310             var_Get( p_playlist, "fullscreen", &val );
00311             var_Set( p_playlist, "fullscreen", (vlc_value_t)!val.b_bool );
00312         }
00313         if( p_playlist ) vlc_object_release( (vlc_object_t *)p_playlist );
00314     }
00315 
00316 }
00317 
00318 - (void)setupVarMenuItem:(NSMenuItem *)o_mi
00319                     target:(vlc_object_t *)p_object
00320                     var:(const char *)psz_variable
00321                     selector:(SEL)pf_callback
00322 {
00323     vlc_value_t val, text;
00324     int i_type = var_Type( p_object, psz_variable );
00325 
00326     switch( i_type & VLC_VAR_TYPE )
00327     {
00328     case VLC_VAR_VOID:
00329     case VLC_VAR_BOOL:
00330     case VLC_VAR_VARIABLE:
00331     case VLC_VAR_STRING:
00332     case VLC_VAR_INTEGER:
00333         break;
00334     default:
00335         /* Variable doesn't exist or isn't handled */
00336         return;
00337     }
00338     
00339     /* Make sure we want to display the variable */
00340     if( i_type & VLC_VAR_HASCHOICE )
00341     {
00342         var_Change( p_object, psz_variable, VLC_VAR_CHOICESCOUNT, &val, NULL );
00343         if( val.i_int == 0 ) return;
00344         if( (i_type & VLC_VAR_TYPE) != VLC_VAR_VARIABLE && val.i_int == 1 )
00345             return;
00346     }
00347     
00348     /* Get the descriptive name of the variable */
00349     var_Change( p_object, psz_variable, VLC_VAR_GETTEXT, &text, NULL );
00350     [o_mi setTitle: [[VLCMain sharedInstance] localizedString: text.psz_string ?
00351                                         text.psz_string : strdup( psz_variable ) ]];
00352 
00353     var_Get( p_object, psz_variable, &val );
00354     if( i_type & VLC_VAR_HASCHOICE )
00355     {
00356         NSMenu *o_menu = [o_mi submenu];
00357 
00358         [self setupVarMenu: o_menu forMenuItem: o_mi target:p_object
00359                         var:psz_variable selector:pf_callback];
00360         
00361         if( text.psz_string ) free( text.psz_string );
00362         return;
00363     }
00364 
00365     VLCMenuExt *o_data;
00366     switch( i_type & VLC_VAR_TYPE )
00367     {
00368     case VLC_VAR_VOID:
00369         o_data = [[VLCMenuExt alloc] initWithVar: psz_variable Object: p_object->i_object_id
00370                 Value: val ofType: i_type];
00371         [o_mi setRepresentedObject: [NSValue valueWithPointer:[o_data retain]]];
00372         break;
00373 
00374     case VLC_VAR_BOOL:
00375         o_data = [[VLCMenuExt alloc] initWithVar: psz_variable Object: p_object->i_object_id
00376                 Value: val ofType: i_type];
00377         [o_mi setRepresentedObject: [NSValue valueWithPointer:[o_data retain]]];
00378         if( !( i_type & VLC_VAR_ISCOMMAND ) )
00379             [o_mi setState: val.b_bool ? TRUE : FALSE ];
00380         break;
00381 
00382     default:
00383         if( text.psz_string ) free( text.psz_string );
00384         return;
00385     }
00386 
00387     if( ( i_type & VLC_VAR_TYPE ) == VLC_VAR_STRING ) free( val.psz_string );
00388     if( text.psz_string ) free( text.psz_string );
00389 }
00390 
00391 
00392 - (void)setupVarMenu:(NSMenu *)o_menu
00393                     forMenuItem: (NSMenuItem *)o_parent
00394                     target:(vlc_object_t *)p_object
00395                     var:(const char *)psz_variable
00396                     selector:(SEL)pf_callback
00397 {
00398     vlc_value_t val, val_list, text_list;
00399     int i_type, i, i_nb_items;
00400 
00401     /* remove previous items */
00402     i_nb_items = [o_menu numberOfItems];
00403     for( i = 0; i < i_nb_items; i++ )
00404     {
00405         [o_menu removeItemAtIndex: 0];
00406     }
00407 
00408     /* Check the type of the object variable */
00409     i_type = var_Type( p_object, psz_variable );
00410 
00411     /* Make sure we want to display the variable */
00412     if( i_type & VLC_VAR_HASCHOICE )
00413     {
00414         var_Change( p_object, psz_variable, VLC_VAR_CHOICESCOUNT, &val, NULL );
00415         if( val.i_int == 0 ) return;
00416         if( (i_type & VLC_VAR_TYPE) != VLC_VAR_VARIABLE && val.i_int == 1 )
00417             return;
00418     }
00419     else
00420     {
00421         return;
00422     }
00423 
00424     switch( i_type & VLC_VAR_TYPE )
00425     {
00426     case VLC_VAR_VOID:
00427     case VLC_VAR_BOOL:
00428     case VLC_VAR_VARIABLE:
00429     case VLC_VAR_STRING:
00430     case VLC_VAR_INTEGER:
00431         break;
00432     default:
00433         /* Variable doesn't exist or isn't handled */
00434         return;
00435     }
00436 
00437     if( var_Get( p_object, psz_variable, &val ) < 0 )
00438     {
00439         return;
00440     }
00441 
00442     if( var_Change( p_object, psz_variable, VLC_VAR_GETLIST,
00443                     &val_list, &text_list ) < 0 )
00444     {
00445         if( (i_type & VLC_VAR_TYPE) == VLC_VAR_STRING ) free( val.psz_string );
00446         return;
00447     }
00448 
00449     /* make (un)sensitive */
00450     [o_parent setEnabled: ( val_list.p_list->i_count > 1 )];
00451 
00452     for( i = 0; i < val_list.p_list->i_count; i++ )
00453     {
00454         vlc_value_t another_val;
00455         NSMenuItem * o_lmi;
00456         NSString *o_title = @"";
00457         VLCMenuExt *o_data;
00458 
00459         switch( i_type & VLC_VAR_TYPE )
00460         {
00461         case VLC_VAR_STRING:
00462             another_val.psz_string =
00463                 strdup(val_list.p_list->p_values[i].psz_string);
00464 
00465             o_title = [[VLCMain sharedInstance] localizedString: text_list.p_list->p_values[i].psz_string ?
00466                 text_list.p_list->p_values[i].psz_string : val_list.p_list->p_values[i].psz_string ];
00467 
00468             o_lmi = [o_menu addItemWithTitle: o_title action: pf_callback keyEquivalent: @""];
00469             o_data = [[VLCMenuExt alloc] initWithVar: strdup(psz_variable) Object: p_object->i_object_id
00470                     Value: another_val ofType: i_type];
00471             [o_lmi setRepresentedObject: [NSValue valueWithPointer:[o_data retain]]];
00472             [o_lmi setTarget: self];
00473             
00474             if( !strcmp( val.psz_string, val_list.p_list->p_values[i].psz_string ) && !( i_type & VLC_VAR_ISCOMMAND ) )
00475                 [o_lmi setState: TRUE ];
00476 
00477             break;
00478 
00479         case VLC_VAR_INTEGER:
00480 
00481              o_title = text_list.p_list->p_values[i].psz_string ?
00482                                  [[VLCMain sharedInstance] localizedString: strdup( text_list.p_list->p_values[i].psz_string )] :
00483                                  [NSString stringWithFormat: @"%d",
00484                                  val_list.p_list->p_values[i].i_int];
00485 
00486             o_lmi = [[o_menu addItemWithTitle: o_title action: pf_callback keyEquivalent: @""] retain ];
00487             o_data = [[VLCMenuExt alloc] initWithVar: strdup(psz_variable) Object: p_object->i_object_id
00488                     Value: val_list.p_list->p_values[i] ofType: i_type];
00489             [o_lmi setRepresentedObject: [NSValue valueWithPointer:[ o_data retain]]];
00490             [o_lmi setTarget: self];
00491 
00492             if( val_list.p_list->p_values[i].i_int == val.i_int && !( i_type & VLC_VAR_ISCOMMAND ) )
00493                 [o_lmi setState: TRUE ];
00494             break;
00495 
00496         default:
00497           break;
00498         }
00499     }
00500     
00501     /* clean up everything */
00502     if( (i_type & VLC_VAR_TYPE) == VLC_VAR_STRING ) free( val.psz_string );
00503     var_Change( p_object, psz_variable, VLC_VAR_FREELIST, &val_list, &text_list );
00504 }
00505 
00506 - (IBAction)toggleVar:(id)sender
00507 {
00508     NSMenuItem *o_mi = (NSMenuItem *)sender;
00509     VLCMenuExt *o_data = [[o_mi representedObject] pointerValue];
00510     [NSThread detachNewThreadSelector: @selector(toggleVarThread:)
00511         toTarget: self withObject: o_data];
00512 
00513     return;
00514 }
00515 
00516 - (int)toggleVarThread: (id)_o_data
00517 {
00518     vlc_object_t *p_object;
00519     NSAutoreleasePool * o_pool = [[NSAutoreleasePool alloc] init];
00520     VLCMenuExt *o_data = (VLCMenuExt *)_o_data;
00521 
00522     vlc_thread_set_priority( VLCIntf , VLC_THREAD_PRIORITY_LOW );
00523 
00524     p_object = (vlc_object_t *)vlc_object_get( VLCIntf,
00525                                     [o_data objectID] );
00526 
00527     if( p_object != NULL )
00528     {
00529         var_Set( p_object, strdup([o_data name]), [o_data value] );
00530         vlc_object_release( p_object );
00531         [o_pool release];
00532         return VLC_TRUE;
00533     }
00534     [o_pool release];
00535     return VLC_EGENERIC;
00536 }
00537 
00538 @end
00539 
00540 @implementation VLCControls (NSMenuValidation)
00541  
00542 - (BOOL)validateMenuItem:(NSMenuItem *)o_mi
00543 {
00544     BOOL bEnabled = TRUE;
00545     vlc_value_t val;
00546     intf_thread_t * p_intf = VLCIntf;
00547     playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
00548                                                        FIND_ANYWHERE );
00549 
00550     if( p_playlist != NULL )
00551     {
00552         vlc_mutex_lock( &p_playlist->object_lock );
00553     }
00554     else return FALSE;
00555 
00556 #define p_input p_playlist->p_input
00557 
00558     if( [[o_mi title] isEqualToString: _NS("Faster")] ||
00559         [[o_mi title] isEqualToString: _NS("Slower")] )
00560     {
00561         if( p_input != NULL )
00562         {
00563             bEnabled = p_input->input.b_can_pace_control;
00564         }
00565         else
00566         {
00567             bEnabled = FALSE;
00568         }
00569     }
00570     else if( [[o_mi title] isEqualToString: _NS("Stop")] )
00571     {
00572         if( p_input == NULL )
00573         {
00574             bEnabled = FALSE;
00575         }
00576                 [o_main setupMenus]; /* Make sure input menu is up to date */
00577     }
00578     else if( [[o_mi title] isEqualToString: _NS("Previous")] ||
00579              [[o_mi title] isEqualToString: _NS("Next")] )
00580     {
00581             bEnabled = p_playlist->i_size > 1;
00582     }
00583     else if( [[o_mi title] isEqualToString: _NS("Random")] )
00584     {
00585         int i_state;
00586         var_Get( p_playlist, "random", &val );
00587         i_state = val.b_bool ? NSOnState : NSOffState;
00588         [o_mi setState: i_state];
00589     }
00590     else if( [[o_mi title] isEqualToString: _NS("Repeat One")] )
00591     {
00592         int i_state;
00593         var_Get( p_playlist, "repeat", &val );
00594         i_state = val.b_bool ? NSOnState : NSOffState;
00595         [o_mi setState: i_state];
00596     }
00597     else if( [[o_mi title] isEqualToString: _NS("Repeat All")] )
00598     {
00599         int i_state;
00600         var_Get( p_playlist, "loop", &val );
00601         i_state = val.b_bool ? NSOnState : NSOffState;
00602         [o_mi setState: i_state];
00603     }
00604     else if( [[o_mi title] isEqualToString: _NS("Step Forward")] ||
00605              [[o_mi title] isEqualToString: _NS("Step Backward")] )
00606     {
00607         if( p_input != NULL )
00608         {
00609             var_Get( p_input, "seekable", &val);
00610             bEnabled = val.b_bool;
00611         }
00612     }
00613     else if( [[o_mi title] isEqualToString: _NS("Mute")] ) 
00614     {
00615         [o_mi setState: p_intf->p_sys->b_mute ? NSOnState : NSOffState];
00616                 [o_main setupMenus]; /* Make sure audio menu is up to date */
00617     }
00618     else if( [[o_mi title] isEqualToString: _NS("Half Size")] ||
00619                 [[o_mi title] isEqualToString: _NS("Normal Size")] ||
00620                 [[o_mi title] isEqualToString: _NS("Double Size")] ||
00621                 [[o_mi title] isEqualToString: _NS("Fit to Screen")] ||
00622                 [[o_mi title] isEqualToString: _NS("Snapshot")] ||
00623                 [[o_mi title] isEqualToString: _NS("Fullscreen")] ||
00624                 [[o_mi title] isEqualToString: _NS("Float on Top")] )
00625     {
00626         id o_window;
00627         NSArray *o_windows = [NSApp orderedWindows];
00628         NSEnumerator *o_enumerator = [o_windows objectEnumerator];
00629         bEnabled = FALSE;
00630         
00631         vout_thread_t   *p_vout = vlc_object_find( p_intf, VLC_OBJECT_VOUT,
00632                                               FIND_ANYWHERE );
00633         if( p_vout != NULL )
00634         {
00635             if( [[o_mi title] isEqualToString: _NS("Float on Top")] )
00636             {
00637                 var_Get( p_vout, "video-on-top", &val );
00638                 [o_mi setState: val.b_bool ?  NSOnState : NSOffState];
00639             }
00640 
00641             while( (o_window = [o_enumerator nextObject]))
00642             {
00643                 if( [[o_window className] isEqualToString: @"VLCWindow"] )
00644                 {
00645                     bEnabled = TRUE;
00646                     break;
00647                 }
00648             }
00649             vlc_object_release( (vlc_object_t *)p_vout );
00650         }
00651         else if( [[o_mi title] isEqualToString: _NS("Fullscreen")] )
00652         {
00653             var_Get( p_playlist, "fullscreen", &val );
00654             [o_mi setState: val.b_bool];
00655             bEnabled = TRUE;
00656         }
00657                 [o_main setupMenus]; /* Make sure video menu is up to date */
00658     }
00659 
00660     vlc_mutex_unlock( &p_playlist->object_lock );
00661     vlc_object_release( p_playlist );
00662 
00663     return( bEnabled );
00664 }
00665 
00666 @end
00667 
00668 /*****************************************************************************
00669  * VLCMenuExt implementation 
00670  *****************************************************************************
00671  * Object connected to a playlistitem which remembers the data belonging to
00672  * the variable of the autogenerated menu
00673  *****************************************************************************/
00674 @implementation VLCMenuExt
00675 
00676 - (id)initWithVar: (const char *)_psz_name Object: (int)i_id
00677         Value: (vlc_value_t)val ofType: (int)_i_type
00678 {
00679     self = [super init];
00680 
00681     if( self != nil )
00682     {
00683         psz_name = strdup( _psz_name );
00684         i_object_id = i_id;
00685         value = val;
00686         i_type = _i_type;
00687     }
00688 
00689     return( self );
00690 }
00691 
00692 - (void)dealloc
00693 {
00694     free( psz_name );
00695     [super dealloc];
00696 }
00697 
00698 - (char *)name
00699 {
00700     return psz_name;
00701 }
00702 
00703 - (int)objectID
00704 {
00705     return i_object_id;
00706 }
00707 
00708 - (vlc_value_t)value
00709 {
00710     return value;
00711 }
00712 
00713 - (int)type
00714 {
00715     return i_type;
00716 }
00717 
00718 @end

Generated on Tue Dec 20 10:14:38 2005 for vlc-0.8.4a by  doxygen 1.4.2