]> git.sesse.net Git - vlc/blobdiff - modules/gui/macosx/intf.m
* fix minor resize-bug when closing the playlist (closes #210)
[vlc] / modules / gui / macosx / intf.m
index e2ac383708bcd91c88d826080eabf93a37f5e5cb..851e2f8d197b80d94ec4534d25394c0e2fdcd954 100644 (file)
@@ -179,6 +179,7 @@ int PlaylistChanged( vlc_object_t *p_this, const char *psz_variable,
     intf_thread_t * p_intf = VLCIntf;
     p_intf->p_sys->b_playlist_update = TRUE;
     p_intf->p_sys->b_intf_update = TRUE;
+    p_intf->p_sys->b_playmode_update = TRUE;
     return VLC_SUCCESS;
 }
 
@@ -293,9 +294,10 @@ static VLCMain *_o_sharedMainInstance = nil;
     }
     
     o_about = [[VLAboutBox alloc] init];
-    o_prefs = [[VLCPrefs alloc] init];
+    o_prefs = nil;
     o_open = [[VLCOpen alloc] init];
-    
+
+    i_lastShownVolume = -1;
     return _o_sharedMainInstance;
 }
 
@@ -712,6 +714,13 @@ static VLCMain *_o_sharedMainInstance = nil;
         case NSDeleteCharFunctionKey:
         case NSBackspaceCharacter:
             return YES;
+        case NSUpArrowFunctionKey:
+        case NSDownArrowFunctionKey:
+        case NSRightArrowFunctionKey:
+        case NSLeftArrowFunctionKey:
+        case NSEnterCharacter:
+        case NSCarriageReturnCharacter:
+            return NO;
     }
 
     val.i_int |= CocoaKeyToVLC( key );
@@ -772,6 +781,8 @@ static VLCMain *_o_sharedMainInstance = nil;
     {
         var_AddCallback( p_playlist, "intf-change", PlaylistChanged, self );
         var_AddCallback( p_playlist, "item-change", PlaylistChanged, self );
+        var_AddCallback( p_playlist, "item-append", PlaylistChanged, self );
+        var_AddCallback( p_playlist, "item-deleted", PlaylistChanged, self );
         var_AddCallback( p_playlist, "playlist-current", PlaylistChanged, self );
 
         vlc_object_release( p_playlist );
@@ -806,6 +817,9 @@ static VLCMain *_o_sharedMainInstance = nil;
         }
 #undef p_input
 
+        /* Manage volume status */
+        [self manageVolumeSlider];
+
         vlc_mutex_unlock( &p_intf->change_lock );
 
         o_sleep_date = [NSDate dateWithTimeIntervalSinceNow: .1];
@@ -874,7 +888,12 @@ static VLCMain *_o_sharedMainInstance = nil;
         p_intf->p_sys->b_intf_update = VLC_FALSE;
     }
 
-    if ( p_intf->p_sys->b_playlist_update )
+    if( p_intf->p_sys->b_playmode_update )
+    {
+        [o_playlist playModeUpdated];
+        p_intf->p_sys->b_playmode_update = VLC_FALSE;
+    }
+    if( p_intf->p_sys->b_playlist_update )
     {
         [o_playlist playlistUpdated];
         p_intf->p_sys->b_playlist_update = VLC_FALSE;
@@ -884,9 +903,8 @@ static VLCMain *_o_sharedMainInstance = nil;
     {
         playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
                                                    FIND_ANYWHERE );
-
-        [o_btn_fullscreen setState: ( var_Get( p_playlist, "fullscreen", &val )>=0 && val.b_bool ) ];
-
+        var_Get( p_playlist, "fullscreen", &val );
+        [o_btn_fullscreen setState: val.b_bool];
         vlc_object_release( p_playlist );
 
         p_intf->p_sys->b_fullscreen_update = VLC_FALSE;
@@ -903,7 +921,7 @@ static VLCMain *_o_sharedMainInstance = nil;
             playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
                                                        FIND_ANYWHERE );
 
-            if( p_playlist == NULL )
+            if( p_playlist == NULL || p_playlist->status.p_item == NULL )
             {
                 return;
             }
@@ -925,7 +943,7 @@ static VLCMain *_o_sharedMainInstance = nil;
                 {
                     if( [[o_vout_wnd className] isEqualToString: @"VLCWindow"] )
                     {
-                        ;[o_vout_wnd updateTitle];
+                        [o_vout_wnd updateTitle];
                     }
                 }
                 vlc_object_release( (vlc_object_t *)p_vout );
@@ -957,9 +975,19 @@ static VLCMain *_o_sharedMainInstance = nil;
                             (int) (i_seconds % 60)];
             [o_timefield setStringValue: o_time];
         }
-
-        /* Manage volume status */
-        [self manageVolumeSlider];
+        
+        if( p_intf->p_sys->b_volume_update )
+        {
+            NSString *o_text;
+            o_text = [NSString stringWithFormat: _NS("Volume: %d"), i_lastShownVolume * 200 / AOUT_VOLUME_MAX];
+            if( i_lastShownVolume != -1 )
+            [self setScrollField:o_text stopAfter:1000000];
+
+            [o_volumeslider setFloatValue: (float)i_lastShownVolume / AOUT_VOLUME_STEP];
+            [o_volumeslider setEnabled: TRUE];
+            p_intf->p_sys->b_mute = ( i_lastShownVolume == 0 );
+            p_intf->p_sys->b_volume_update = FALSE;
+        }
 
         /* Manage Playing status */
         var_Get( p_input, "state", &val );
@@ -984,6 +1012,7 @@ static VLCMain *_o_sharedMainInstance = nil;
     if( (i_end_scroll != -1) && (mdate() > i_end_scroll) )
         [self resetScrollField];
 
+
     [NSTimer scheduledTimerWithTimeInterval: 0.3
         target: self selector: @selector(manageIntf:)
         userInfo: nil repeats: FALSE];
@@ -1214,13 +1243,13 @@ static VLCMain *_o_sharedMainInstance = nil;
 - (void)manageVolumeSlider
 {
     audio_volume_t i_volume;
-
     aout_VolumeGet( p_intf, &i_volume );
 
-    [o_volumeslider setFloatValue: (float)i_volume / AOUT_VOLUME_STEP];
-    [o_volumeslider setEnabled: TRUE];
-
-    p_intf->p_sys->b_mute = ( i_volume == 0 );
+    if( i_volume != i_lastShownVolume )
+    {
+        i_lastShownVolume = i_volume;
+        p_intf->p_sys->b_volume_update = TRUE;
+    }
 }
 
 - (IBAction)timesliderUpdate:(id)sender
@@ -1399,6 +1428,9 @@ static VLCMain *_o_sharedMainInstance = nil;
 
 - (IBAction)viewPreferences:(id)sender
 {
+/* GRUIIIIIIIK */
+    if( o_prefs == nil )
+        o_prefs = [[VLCPrefs alloc] init];
     [o_prefs showPrefs];
 }
 
@@ -1525,12 +1557,13 @@ static VLCMain *_o_sharedMainInstance = nil;
         else
         {
             o_rect.size.height = 500;
-            if ( o_rect.size.width == [o_window minSize].width )
-            {
-                o_rect.size.width = 500;
-            }
-
         }
+        
+        if ( o_rect.size.width == [o_window minSize].width )
+        {
+            o_rect.size.width = 500;
+        }
+        
         o_rect.size.height = (o_size_with_playlist.height > 200) ?
             o_size_with_playlist.height : 500;
         o_rect.origin.x = [o_window frame].origin.x;
@@ -1542,11 +1575,13 @@ static VLCMain *_o_sharedMainInstance = nil;
     {
         /* make small */
         o_rect.size.height = [o_window minSize].height;
+        o_rect.size.width = [o_window minSize].width;
         o_rect.origin.x = [o_window frame].origin.x;
         /* Calculate the position of the lower right corner after resize */
         o_rect.origin.y = [o_window frame].origin.y +
             [o_window frame].size.height - [o_window minSize].height;
 
+        
         [o_playlist_view setAutoresizesSubviews: NO];
         [o_playlist_view removeFromSuperview];
         [o_btn_playlist setState: NO];