]> git.sesse.net Git - vlc/blobdiff - plugins/gtk/gtk_control.c
* ./src/playlist/playlist.c: lots of playlist behaviour enhancements.
[vlc] / plugins / gtk / gtk_control.c
index e3372d87fb792e1bdc411e1779720afd442941dc..2ef7fbe90ea05ac15f539e361c59dcc13a7d0924 100644 (file)
@@ -2,7 +2,7 @@
  * gtk_control.c : functions to handle stream control buttons.
  *****************************************************************************
  * Copyright (C) 2000, 2001 VideoLAN
- * $Id: gtk_control.c,v 1.11 2002/06/02 09:03:54 sam Exp $
+ * $Id: gtk_control.c,v 1.12 2002/06/07 14:30:41 sam Exp $
  *
  * Authors: Samuel Hocevar <sam@zoy.org>
  *          Stéphane Borel <stef@via.ecp.fr>
@@ -52,7 +52,6 @@
  * by other callbacks
  ****************************************************************************/
 gboolean GtkControlBack( GtkWidget       *widget,
-                         GdkEventButton  *event,
                          gpointer         user_data )
 {
     return FALSE;
@@ -60,162 +59,98 @@ gboolean GtkControlBack( GtkWidget       *widget,
 
 
 gboolean GtkControlStop( GtkWidget       *widget,
-                         GdkEventButton  *event,
                          gpointer         user_data )
 {
-    intf_thread_t *p_intf = GetIntf( GTK_WIDGET(widget), (char*)user_data );
-    playlist_t *p_playlist;
-
-    p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
-
-    if( p_playlist )
+    intf_thread_t *  p_intf = GetIntf( GTK_WIDGET(widget), (char*)user_data );
+    playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
+                                                       FIND_ANYWHERE );
+    if( p_playlist == NULL )
     {
-        playlist_Stop( p_playlist );
-        vlc_object_release( p_playlist );
+        return FALSE;
     }
 
+    playlist_Stop( p_playlist );
+    vlc_object_release( p_playlist );
+
     return TRUE;
 }
 
 
 gboolean GtkControlPlay( GtkWidget       *widget,
-                         GdkEventButton  *event,
                          gpointer         user_data )
 {
-    intf_thread_t *p_intf = GetIntf( GTK_WIDGET(widget), (char*)user_data );
-    playlist_t *p_playlist;
-
-    p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
+    intf_thread_t *  p_intf = GetIntf( GTK_WIDGET(widget), (char*)user_data );
+    playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
+                                                       FIND_ANYWHERE );
+    if( p_playlist == NULL )
+    {
+        GtkFileOpenShow( widget, user_data );
+        return TRUE;
+    }
 
-    if( p_playlist )
+    /* If the playlist is empty, open a file requester instead */
+    vlc_mutex_lock( &p_playlist->object_lock );
+    if( p_playlist->i_size )
     {
+        vlc_mutex_unlock( &p_playlist->object_lock );
         playlist_Play( p_playlist );
         vlc_object_release( p_playlist );
     }
-
-#if 0 /* FIXME: deal with this */
+    else
     {
-        vlc_mutex_unlock( &p_intf->p_vlc->p_playlist->change_lock );
-        GtkFileOpenShow( widget, event, user_data );
+        vlc_mutex_unlock( &p_playlist->object_lock );
+        vlc_object_release( p_playlist );
+        GtkFileOpenShow( widget, user_data );
     }
-#endif
 
     return TRUE;
 }
 
 
 gboolean GtkControlPause( GtkWidget       *widget,
-                          GdkEventButton  *event,
                           gpointer         user_data )
 {
-    intf_thread_t *p_intf = GetIntf( GTK_WIDGET(widget), (char*)user_data );
-    playlist_t *p_playlist;
-
-    p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
+    intf_thread_t *  p_intf = GetIntf( GTK_WIDGET(widget), (char*)user_data );
 
-    if( p_playlist )
+    if( p_intf->p_sys->p_input == NULL )
     {
-        playlist_Pause( p_playlist );
-        vlc_object_release( p_playlist );
+        return FALSE;
     }
 
+    input_SetStatus( p_intf->p_sys->p_input, INPUT_STATUS_PAUSE );
+
     return TRUE;
 }
 
 
 gboolean GtkControlSlow( GtkWidget       *widget,
-                         GdkEventButton  *event,
                          gpointer         user_data )
 {
-    intf_thread_t *p_intf = GetIntf( GTK_WIDGET(widget), (char*)user_data );
-    playlist_t *p_playlist;
-
-    p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
+    intf_thread_t *  p_intf = GetIntf( GTK_WIDGET(widget), (char*)user_data );
 
-#if 0
-    if( p_playlist )
+    if( p_intf->p_sys->p_input == NULL )
     {
-        playlist_Slow( p_playlist );
-        vlc_object_release( p_playlist );
+        return FALSE;
     }
-#endif
+
+    input_SetStatus( p_intf->p_sys->p_input, INPUT_STATUS_SLOWER );
 
     return TRUE;
 }
 
 
 gboolean GtkControlFast( GtkWidget       *widget,
-                         GdkEventButton  *event,
                          gpointer         user_data )
 {
-    intf_thread_t *p_intf = GetIntf( GTK_WIDGET(widget), (char*)user_data );
-    playlist_t *p_playlist;
-
-    p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
+    intf_thread_t *  p_intf = GetIntf( GTK_WIDGET(widget), (char*)user_data );
 
-#if 0
-    if( p_playlist )
+    if( p_intf->p_sys->p_input == NULL )
     {
-        playlist_Fast( p_playlist );
-        vlc_object_release( p_playlist );
+        return FALSE;
     }
-#endif
-
-    return TRUE;
-}
 
+    input_SetStatus( p_intf->p_sys->p_input, INPUT_STATUS_FASTER );
 
-/****************************************************************************
- * Control callbacks for menuitems
- ****************************************************************************
- * We have different callaback for menuitem since we must use the
- * activate signal toi popdown the menu automatically
- ****************************************************************************/
-void GtkPlayActivate( GtkMenuItem * menuitem, gpointer user_data )
-{
-    GtkControlPlay( GTK_WIDGET( menuitem ), NULL, user_data );
-}
-
-
-void GtkPauseActivate( GtkMenuItem * menuitem, gpointer user_data )
-{
-    GtkControlPause( GTK_WIDGET( menuitem ), NULL, user_data );
-
-}
-
-
-void
-GtKStopActivate                        (GtkMenuItem     *menuitem,
-                                        gpointer         user_data)
-{
-    GtkControlStop( GTK_WIDGET( menuitem ), NULL, user_data );
-
-}
-
-
-void
-GtkBackActivate                        (GtkMenuItem     *menuitem,
-                                        gpointer         user_data)
-{
-    GtkControlBack( GTK_WIDGET( menuitem ), NULL, user_data );
-
-}
-
-
-void
-GtkSlowActivate                        (GtkMenuItem     *menuitem,
-                                        gpointer         user_data)
-{
-    GtkControlSlow( GTK_WIDGET( menuitem ), NULL, user_data );
-
-}
-
-
-void
-GtkFastActivate                        (GtkMenuItem     *menuitem,
-                                        gpointer         user_data)
-{
-    GtkControlFast( GTK_WIDGET( menuitem ), NULL, user_data );
+    return TRUE;
 }
 
-