ALL: the next and previous buttons first work through the chapters. Only
authorDerk-Jan Hartman <hartman@videolan.org>
Tue, 28 Jan 2003 01:50:52 +0000 (01:50 +0000)
committerDerk-Jan Hartman <hartman@videolan.org>
Tue, 28 Jan 2003 01:50:52 +0000 (01:50 +0000)
     then they turn to the playlist.

modules/gui/macosx/controls.m
modules/gui/macosx/intf.m

index 358f419..1b6d452 100644 (file)
@@ -2,7 +2,7 @@
  * controls.m: MacOS X interface plugin
  *****************************************************************************
  * Copyright (C) 2002 VideoLAN
- * $Id: controls.m,v 1.14 2003/01/24 16:19:15 hartman Exp $
+ * $Id: controls.m,v 1.15 2003/01/28 01:50:52 hartman Exp $
  *
  * Authors: Jon Lech Johansen <jon-vl@nanocrew.net>
  *          Christophe Massiot <massiot@via.ecp.fr>
 - (IBAction)prev:(id)sender
 {
     intf_thread_t * p_intf = [NSApp getIntf];
+    input_area_t *  p_area;
     playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
                                                        FIND_ANYWHERE );
-    if( p_playlist == NULL )
+
+    vlc_mutex_lock( &p_intf->p_sys->p_input->stream.stream_lock );
+    p_area = p_intf->p_sys->p_input->stream.p_selected_area;
+
+    /* check if this is the first chapter and whether there are any chapters at all */
+    if( p_area->i_part > 1 && p_area->i_part_nb > 1 )
     {
-        return;
-    }
+        p_area->i_part--;
+        vlc_mutex_unlock( &p_intf->p_sys->p_input->stream.stream_lock );
 
-    playlist_Prev( p_playlist );
-    vlc_object_release( p_playlist );
+        input_ChangeArea( p_intf->p_sys->p_input, p_area );
+
+        p_intf->p_sys->b_chapter_update = VLC_TRUE;
+    }
+    else if( p_playlist != NULL )
+    {
+        vlc_mutex_unlock( &p_intf->p_sys->p_input->stream.stream_lock );
+        playlist_Prev( p_playlist );
+    }
+    else
+    {
+        vlc_mutex_unlock( &p_intf->p_sys->p_input->stream.stream_lock );
+    }
+    
+    if ( p_playlist != NULL )
+        vlc_object_release( p_playlist );
 }
 
 - (IBAction)next:(id)sender
 {
     intf_thread_t * p_intf = [NSApp getIntf];
+    input_area_t *  p_area;
     playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
                                                        FIND_ANYWHERE );
-    if( p_playlist == NULL )
+
+    vlc_mutex_lock( &p_intf->p_sys->p_input->stream.stream_lock );
+    p_area = p_intf->p_sys->p_input->stream.p_selected_area;
+
+    /* check if this is the last chapter and whether there are any chapters at all */
+    if( p_area->i_part_nb > 1 && p_area->i_part < p_area->i_part_nb )
     {
-        return;
-    }
+        p_area->i_part++;
+        vlc_mutex_unlock( &p_intf->p_sys->p_input->stream.stream_lock );
 
-    playlist_Next( p_playlist );
-    vlc_object_release( p_playlist );
+        input_ChangeArea( p_intf->p_sys->p_input, p_area );
+
+        p_intf->p_sys->b_chapter_update = VLC_TRUE;
+    }
+    else if( p_playlist != NULL )
+    {
+        vlc_mutex_unlock( &p_intf->p_sys->p_input->stream.stream_lock );
+        playlist_Next( p_playlist );
+    }
+    else
+    {
+        vlc_mutex_unlock( &p_intf->p_sys->p_input->stream.stream_lock );
+    }
+    
+    if ( p_playlist != NULL )
+        vlc_object_release( p_playlist );
 }
 
 - (IBAction)loop:(id)sender
index 2a46154..c2d7d93 100644 (file)
@@ -2,7 +2,7 @@
  * intf.m: MacOS X interface plugin
  *****************************************************************************
  * Copyright (C) 2002-2003 VideoLAN
- * $Id: intf.m,v 1.36 2003/01/27 00:08:31 jlj Exp $
+ * $Id: intf.m,v 1.37 2003/01/28 01:50:52 hartman Exp $
  *
  * Authors: Jon Lech Johansen <jon-vl@nanocrew.net>
  *          Christophe Massiot <massiot@via.ecp.fr>
@@ -627,8 +627,10 @@ static void Run( intf_thread_t *p_intf )
 - (void)setControlItems {
     intf_thread_t * p_intf = [NSApp getIntf];
     vlc_bool_t b_input;
-    vlc_bool_t b_plmul = 0;
-    vlc_bool_t b_control = 0;
+    vlc_bool_t b_plmul = NO;
+    vlc_bool_t b_control = NO;
+    vlc_bool_t b_chapters = NO;
+    input_area_t *  p_area;
     playlist_t * p_playlist = NULL;
     NSImage *playImage = [NSImage imageNamed:@"play"];
     NSImage *pauseImage = [NSImage imageNamed:@"pause"];
@@ -643,18 +645,21 @@ static void Run( intf_thread_t *p_intf )
         vlc_object_release( p_playlist );
     }
     
-    if( ( b_input = ( p_intf->p_sys->p_input != NULL ) ) )
+    if ( b_input = ( p_intf->p_sys->p_input != NULL ) )
     {
         /* control buttons for free pace streams */
         b_control = p_intf->p_sys->p_input->stream.b_pace_control;
+        p_area = p_intf->p_sys->p_input->stream.p_selected_area;
+        if ( p_area->i_part_nb > 1 )
+            b_chapters = YES;
     }
     
     /* set control items */
     [o_btn_stop setEnabled: b_input];
     [o_btn_fastforward setEnabled: b_control];
     [o_btn_slowmotion setEnabled: b_control];
-    [o_btn_prev setEnabled: b_plmul];
-    [o_btn_next setEnabled: b_plmul];
+    [o_btn_prev setEnabled: (b_plmul || b_chapters) ];
+    [o_btn_next setEnabled: (b_plmul || b_chapters) ];
     [o_controls setVolumeSlider];
     [o_timeslider setEnabled: b_input];