* ALL: there were reports of crashes in the menucode. i think it was that
authorDerk-Jan Hartman <hartman@videolan.org>
Tue, 6 May 2003 20:12:28 +0000 (20:12 +0000)
committerDerk-Jan Hartman <hartman@videolan.org>
Tue, 6 May 2003 20:12:28 +0000 (20:12 +0000)
  the VLCWindow could suddenly disappear (the vout closed) and therefore we
  could no longer reference it. This should fix that. Also made this code
  more generic to avoid code duplication.

extras/MacOSX/Resources/English.lproj/MainMenu.nib/classes.nib
extras/MacOSX/Resources/English.lproj/MainMenu.nib/objects.nib
modules/gui/macosx/controls.h
modules/gui/macosx/controls.m
modules/gui/macosx/intf.m

index 2ae839d..1dcaa68 100644 (file)
             ACTIONS = {
                 backward = id; 
                 deinterlace = id; 
-                doubleWindow = id; 
                 faster = id; 
-                floatOnTop = id; 
                 forward = id; 
-                fullscreen = id; 
-                halfWindow = id; 
                 loop = id; 
                 mute = id; 
                 next = id; 
-                normalWindow = id; 
                 pause = id; 
                 play = id; 
                 prev = id; 
@@ -44,6 +39,7 @@
                 volumeDown = id; 
                 volumeSliderUpdated = id; 
                 volumeUp = id; 
+                windowAction = id; 
             }; 
             CLASS = VLCControls; 
             LANGUAGE = ObjC; 
index 0ddfd00..9b5231a 100644 (file)
Binary files a/extras/MacOSX/Resources/English.lproj/MainMenu.nib/objects.nib and b/extras/MacOSX/Resources/English.lproj/MainMenu.nib/objects.nib differ
index ae77743..9d34374 100644 (file)
@@ -2,7 +2,7 @@
  * controls.h: MacOS X interface plugin
  *****************************************************************************
  * Copyright (C) 2002-2003 VideoLAN
- * $Id: controls.h,v 1.2 2003/05/01 01:11:17 hartman Exp $
+ * $Id: controls.h,v 1.3 2003/05/06 20:12:28 hartman Exp $
  *
  * Authors: Jon Lech Johansen <jon-vl@nanocrew.net>
  *          Christophe Massiot <massiot@via.ecp.fr>
 - (IBAction)volumeSliderUpdated:(id)sender;
 - (void)updateVolumeSlider;
 
-- (IBAction)halfWindow:(id)sender;
-- (IBAction)normalWindow:(id)sender;
-- (IBAction)doubleWindow:(id)sender;
-- (IBAction)fullscreen:(id)sender;
-- (IBAction)floatOnTop:(id)sender;
+- (IBAction)windowAction:(id)sender;
 - (IBAction)deinterlace:(id)sender;
 
 - (IBAction)toggleProgram:(id)sender;
index 9b52acb..51cc396 100644 (file)
@@ -2,7 +2,7 @@
  * controls.m: MacOS X interface plugin
  *****************************************************************************
  * Copyright (C) 2002-2003 VideoLAN
- * $Id: controls.m,v 1.35 2003/05/05 22:04:11 hartman Exp $
+ * $Id: controls.m,v 1.36 2003/05/06 20:12:28 hartman Exp $
  *
  * Authors: Jon Lech Johansen <jon-vl@nanocrew.net>
  *          Christophe Massiot <massiot@via.ecp.fr>
     [o_volumeslider setFloatValue: (float)(i_volume / AOUT_VOLUME_STEP)]; 
 }
 
-- (IBAction)halfWindow:(id)sender
+- (IBAction)windowAction:(id)sender
 {
     id o_window = [NSApp keyWindow];
+    NSString *o_title = [sender title];
     NSArray *o_windows = [NSApp windows];
     NSEnumerator *o_enumerator = [o_windows objectEnumerator];
-    
-    while ((o_window = [o_enumerator nextObject]))
-    {
-        if( [[o_window className] isEqualToString: @"VLCWindow"] )
-        {
-            [o_window scaleWindowWithFactor: 0.5];
-        }
-    }
-}
-
-- (IBAction)normalWindow:(id)sender
-{
-    id o_window = [NSApp keyWindow];
-    NSArray *o_windows = [NSApp windows];
-    NSEnumerator *o_enumerator = [o_windows objectEnumerator];
-    
-    while ((o_window = [o_enumerator nextObject]))
-    {
-        if( [[o_window className] isEqualToString: @"VLCWindow"] )
-        {
-            [o_window scaleWindowWithFactor: 1];
-        }
-    }
-}
-
-- (IBAction)doubleWindow:(id)sender
-{
-    id o_window = [NSApp keyWindow];
-    NSArray *o_windows = [NSApp windows];
-    NSEnumerator *o_enumerator = [o_windows objectEnumerator];
-    
-    while ((o_window = [o_enumerator nextObject]))
-    {
-        if( [[o_window className] isEqualToString: @"VLCWindow"] )
-        {
-            [o_window scaleWindowWithFactor: 2];
-        }
-    }
-}
-
+    vout_thread_t   *p_vout = vlc_object_find( [NSApp getIntf], VLC_OBJECT_VOUT,
+                                              FIND_ANYWHERE );
 
-- (IBAction)fullscreen:(id)sender
-{
-    id o_window = [NSApp keyWindow];
-    NSArray *o_windows = [NSApp windows];
-    NSEnumerator *o_enumerator = [o_windows objectEnumerator];
-    
-    while ((o_window = [o_enumerator nextObject]))
+    if( p_vout != NULL )
     {
-        if( [[o_window className] isEqualToString: @"VLCWindow"] )
-        {
-            [o_window toggleFullscreen];
-        }
-    }
-}
-
-- (IBAction)floatOnTop:(id)sender
-{
-    id o_window = [NSApp keyWindow];
-    NSArray *o_windows = [NSApp windows];
-    NSEnumerator *o_enumerator = [o_windows objectEnumerator];
-    
-    while ((o_window = [o_enumerator nextObject]))
-    {
-        if( [[o_window className] isEqualToString: @"VLCWindow"] )
+        while ((o_window = [o_enumerator nextObject]))
         {
-            [o_window toggleFloatOnTop];
+            if( [[o_window className] isEqualToString: @"VLCWindow"] )
+            {
+                if( [o_title isEqualToString: _NS("Fullscreen") ] )
+                    [o_window toggleFullscreen];
+                else if( [o_title isEqualToString: _NS("Half Size") ] )
+                    [o_window scaleWindowWithFactor: 0.5];
+                else if( [o_title isEqualToString: _NS("Normal Size") ] )
+                    [o_window scaleWindowWithFactor: 1.0];
+                else if( [o_title isEqualToString: _NS("Double Size") ] )
+                    [o_window scaleWindowWithFactor: 2.0];
+                else if( [o_title isEqualToString: _NS("Float On Top") ] )
+                    [o_window toggleFloatOnTop];
+            }
         }
+        vlc_object_release( (vlc_object_t *)p_vout );
     }
 }
 
             [o_mi setState: i_state];
         }
         
-        while ((o_window = [o_enumerator nextObject]))
+        vout_thread_t   *p_vout = vlc_object_find( p_intf, VLC_OBJECT_VOUT,
+                                              FIND_ANYWHERE );
+        if( p_vout != NULL )
         {
-            if( [[o_window className] isEqualToString: @"VLCWindow"] )
+            while ((o_window = [o_enumerator nextObject]))
             {
-                bEnabled = TRUE;
-                break;
+                if( [[o_window className] isEqualToString: @"VLCWindow"] )
+                {
+                    bEnabled = TRUE;
+                    break;
+                }
             }
+            vlc_object_release( (vlc_object_t *)p_vout );
         }
     }
     else if( [[o_mi title] isEqualToString: _NS("Float On Top")] )
index f64393d..c5d9e4e 100644 (file)
@@ -2,7 +2,7 @@
  * intf.m: MacOS X interface plugin
  *****************************************************************************
  * Copyright (C) 2002-2003 VideoLAN
- * $Id: intf.m,v 1.74 2003/05/05 22:23:39 gbazin Exp $
+ * $Id: intf.m,v 1.75 2003/05/06 20:12:28 hartman Exp $
  *
  * Authors: Jon Lech Johansen <jon-vl@nanocrew.net>
  *          Christophe Massiot <massiot@via.ecp.fr>
@@ -636,18 +636,22 @@ int ExecuteOnMainThread( id target, SEL sel, void * p_arg )
 
     if( p_intf->p_sys->b_current_title_update )
     {
-        id o_vout_wnd;
-
-        NSEnumerator * o_enum = [[NSApp windows] objectEnumerator];
-        
-        while( ( o_vout_wnd = [o_enum nextObject] ) )
+        vout_thread_t   *p_vout = vlc_object_find( p_intf, VLC_OBJECT_VOUT,
+                                              FIND_ANYWHERE );
+        if( p_vout != NULL )
         {
-            if( [[o_vout_wnd className] isEqualToString: @"VLCWindow"] )
+            id o_vout_wnd;
+            NSEnumerator * o_enum = [[NSApp windows] objectEnumerator];
+            
+            while( ( o_vout_wnd = [o_enum nextObject] ) )
             {
-                [o_vout_wnd updateTitle];
+                if( [[o_vout_wnd className] isEqualToString: @"VLCWindow"] )
+                {
+                    [o_vout_wnd updateTitle];
+                }
             }
+            vlc_object_release( (vlc_object_t *)p_vout );
         }
-
         [o_playlist updateRowSelection];
         [o_info updateInfo];