]> git.sesse.net Git - vlc/blobdiff - plugins/gtk/gtk_playlist.c
* Fixed the BeOS compile typo.
[vlc] / plugins / gtk / gtk_playlist.c
index e87c4e30ab89af4cdf28b3e805588fab2119a458..d6201ddfa42acb340c1237c75e197ea52840ef93 100644 (file)
@@ -2,9 +2,10 @@
  * gtk_playlist.c : Interface for the playlist dialog
  *****************************************************************************
  * Copyright (C) 2001 VideoLAN
- * $Id: gtk_playlist.c,v 1.10 2001/04/28 03:36:25 sam Exp $
+ * $Id: gtk_playlist.c,v 1.15 2001/05/30 17:03:12 sam Exp $
  *
  * Authors: Pierre Baillet <oct@zoy.org>
+ *          Stéphane Borel <stef@via.ecp.fr>
  *      
  * This program is free software; you can redistribute it and/or modify
  * it under the terms of the GNU General Public License as published by
@@ -21,9 +22,6 @@
  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111, USA.
  *****************************************************************************/
 
-#define MODULE_NAME gtk
-#include "modules_inner.h"
-
 /*****************************************************************************
  * Preamble
  *****************************************************************************/
@@ -51,7 +49,6 @@
 #include "interface.h"
 #include "intf_playlist.h"
 #include "intf_msg.h"
-#include "intf_urldecode.h"
 
 #include "gtk_callbacks.h"
 #include "gtk_interface.h"
 #include "gtk_playlist.h"
 #include "intf_gtk.h"
 
-
 #include "main.h"
 
-void
-on_menubar_playlist_activate           (GtkMenuItem     *menuitem,
-                                        gpointer         user_data)
-{
-
-    intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), "intf_window" );
-    playlist_t * p_playlist ;
-    GtkCList * list;
-    
-    if( !GTK_IS_WIDGET( p_intf->p_sys->p_playlist ) )
-    {
-        /* this shoud never happen */
-        intf_ErrMsgImm("intf_playlist is not a widget !");
-        p_intf->p_sys->p_playlist = create_intf_playlist();
-        gtk_object_set_data( GTK_OBJECT( p_intf->p_sys->p_playlist ),
-                             "p_intf", p_intf );
-    }
-    
-    vlc_mutex_lock( &p_main->p_playlist->change_lock );
-    if(p_main->p_playlist->i_size > 0 )
-    {
-        p_playlist = p_main->p_playlist;
-        list = GTK_CLIST(lookup_widget( p_intf->p_sys->p_playlist, "playlist_clist" )) ;
-        rebuildCList( list, p_playlist );
-    }
-    vlc_mutex_unlock( &p_main->p_playlist->change_lock );
-    
-    gtk_widget_show( p_intf->p_sys->p_playlist );
-    gdk_window_raise( p_intf->p_sys->p_playlist->window );
-}
-
+#include "modules_export.h"
 
-void
-on_toolbar_playlist_clicked            (GtkButton       *button,
-                                        gpointer         user_data)
+/****************************************************************************
+ * Playlist window management
+ ****************************************************************************/
+gboolean GtkPlaylistShow( GtkWidget       *widget,
+                          GdkEventButton  *event,
+                          gpointer         user_data )
 {
-    intf_thread_t *p_intf = GetIntf( GTK_WIDGET(button), "intf_window" );
+    intf_thread_t *p_intf = GetIntf( GTK_WIDGET(widget), (char*)user_data );
 
     if( !GTK_IS_WIDGET( p_intf->p_sys->p_playlist ) )
     {
-        /* this should never happen */
-        intf_ErrMsgImm("intf_playlist is not a widget !");
+        /* The data types we are allowed to receive */
+        static GtkTargetEntry target_table[] =
+        {
+            { "text/uri-list", 0, DROP_ACCEPT_TEXT_URI_LIST },
+            { "text/plain", 0, DROP_ACCEPT_TEXT_PLAIN }
+        };
 
         p_intf->p_sys->p_playlist = create_intf_playlist();
         gtk_object_set_data( GTK_OBJECT( p_intf->p_sys->p_playlist ),
                              "p_intf", p_intf );
+
+        /* Accept file drops on the playlist window */
+        gtk_drag_dest_set( GTK_WIDGET( lookup_widget( p_intf->p_sys->p_playlist,
+                                       "playlist_clist") ),
+                           GTK_DEST_DEFAULT_ALL, target_table,
+                           1, GDK_ACTION_COPY );
     }
-    if( GTK_WIDGET_VISIBLE(p_intf->p_sys->p_playlist) ) {
-        gtk_widget_hide( p_intf->p_sys->p_playlist);
+
+    if( GTK_WIDGET_VISIBLE( p_intf->p_sys->p_playlist ) )
+    {
+        gtk_widget_hide( p_intf->p_sys->p_playlist );
     } 
     else 
     {        
-        GtkCList * clist;
+        GtkCList * p_clist;
+
+        p_clist = GTK_CLIST( gtk_object_get_data(
+            GTK_OBJECT( p_intf->p_sys->p_playlist ), "playlist_clist" ) );
+        GtkRebuildCList( p_clist , p_main->p_playlist );
         gtk_widget_show( p_intf->p_sys->p_playlist );
-        clist = GTK_CLIST(lookup_widget( p_intf->p_sys->p_playlist,"playlist_clist" ));
         gdk_window_raise( p_intf->p_sys->p_playlist->window );
-        rebuildCList( clist , p_main->p_playlist );
     }
+
+    return TRUE;
 }
 
-void
-on_playlist_ok_clicked                 (GtkButton       *button,
-                                        gpointer         user_data)
+
+void GtkPlaylistOk( GtkButton * button, gpointer user_data )
 {
-    intf_thread_t *p_intf = GetIntf( GTK_WIDGET(button), "intf_playlist" );
-    gtk_widget_hide( p_intf->p_sys->p_playlist );
+     gtk_widget_hide( gtk_widget_get_toplevel( GTK_WIDGET (button) ) );
 }
 
-void  deleteGListItem(gpointer data, gpointer param)
+
+void GtkPlaylistCancel( GtkButton * button, gpointer user_data )
 {
-    int curRow = ( int )data;
-    intf_thread_t * p_intf = param;    
-    
-    intf_PlaylistDelete( p_main->p_playlist, curRow );
+     gtk_widget_hide( gtk_widget_get_toplevel( GTK_WIDGET (button) ) );
+}
 
-    /* are we deleting the current played stream */
-    if( p_intf->p_sys->i_playing == curRow )
+
+
+gboolean GtkPlaylistPrev( GtkWidget       *widget,
+                          GdkEventButton  *event,
+                          gpointer         user_data )
+{
+    intf_thread_t *p_intf = GetIntf( GTK_WIDGET(widget), (char*)user_data );
+
+    if( p_intf->p_input != NULL )
     {
-        /* next ! */
+        /* FIXME: temporary hack */
+        intf_PlaylistPrev( p_main->p_playlist );
+        intf_PlaylistPrev( p_main->p_playlist );
         p_intf->p_input->b_eof = 1;
-        /* this has to set the slider to 0 */
-        
-        /* step minus one */
-        p_intf->p_sys->i_playing-- ;
-        p_main->p_playlist->i_index-- ;
     }
-}
-gint compareItems(gconstpointer a, gconstpointer b)
-{
-    return b - a;
+
+    return TRUE;
 }
 
-void 
-rebuildCList(GtkCList * clist, playlist_t * playlist_p)
+
+gboolean GtkPlaylistNext( GtkWidget       *widget,
+                          GdkEventButton  *event,
+                          gpointer         user_data)
 {
-    int dummy;
-    gchar * text[2];
-    GdkColor red;
-    red.red = 65535;
-    red.green = 0;
-    red.blue = 0;
+    intf_thread_t *p_intf = GetIntf( GTK_WIDGET(widget), (char*)user_data );
 
-    
-    gtk_clist_freeze( clist );
-    gtk_clist_clear( clist );
-   
-    for( dummy=0; dummy < playlist_p->i_size; dummy++ )
+    if( p_intf->p_input != NULL )
     {
-#ifdef WIN32 /* WIN32 HACK */
-        text[0] = g_strdup( "" );
-#else
-        text[0] = g_strdup( rindex( (char *)(playlist_p->p_item[playlist_p->i_size -1 - dummy].psz_name ), '/' ) + 1 );
-#endif
-        text[1] = g_strdup( "no info");
-        
-        gtk_clist_insert( clist, 0, text );
-        
-        free(text[0]);
-        free(text[1]);
+        /* FIXME: temporary hack */
+        p_intf->p_input->b_eof = 1;
     }
-    gtk_clist_set_background (
-      clist, 
-      playlist_p->i_index, 
-      &red);
-    gtk_clist_thaw( clist );
+
+    return TRUE;
 }
 
-void
-on_invertselection_clicked (GtkMenuItem *item, gpointer user_data)
+/****************************************************************************
+ * Menu callbacks for playlist functions
+ ****************************************************************************/
+void GtkPlaylistActivate( GtkMenuItem * menuitem, gpointer user_data )
+{
+    GtkPlaylistShow( GTK_WIDGET( menuitem ), NULL, user_data );
+}
+
+
+void GtkNextActivate( GtkMenuItem * menuitem, gpointer user_data )
 {
-    int * selected, sel_l;
-    GtkCList    * clist;
-    playlist_t * playlist_p;
-    int dummy;
+    GtkPlaylistNext( GTK_WIDGET( menuitem ), NULL, user_data );
+}
+
+
+void GtkPrevActivate( GtkMenuItem * menuitem, gpointer user_data )
+{
+    GtkPlaylistPrev( GTK_WIDGET( menuitem ), NULL, user_data );
+}
+
+
+/****************************************************************************
+ * Playlist core functions
+ ****************************************************************************/
+void GtkPlaylistAddUrl( GtkMenuItem * menuitem, gpointer user_data )
+{
+
+}
+
+
+void GtkPlaylistDeleteAll( GtkMenuItem * menuitem, gpointer user_data )
+{
+
+}
+
+
+void GtkPlaylistDeleteSelected( GtkMenuItem * menuitem, gpointer user_data )
+{
+    /* user wants to delete a file in the queue */
+    GList *     p_selection;
+    GtkCList *  p_clist;
+    playlist_t *p_playlist;
     
     /* catch the thread back */
-    intf_thread_t *p_intf = GetIntf( GTK_WIDGET(item), "intf_playlist" );
-    playlist_p = p_main->p_playlist;
+    intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), (char*)user_data );
+
+    p_playlist = p_main->p_playlist;
     
     /* lock the struct */
     vlc_mutex_lock( &p_intf->change_lock );
-    clist = GTK_CLIST( lookup_widget(p_intf->p_sys->p_playlist,"playlist_clist") );
+
+    p_clist = GTK_CLIST( gtk_object_get_data( GTK_OBJECT(
+        p_intf->p_sys->p_playlist ), "playlist_clist" ) );
     
-    /* have to copy the selection to an int *
-       I wasn't able to copy the g_list to another g_list
-       glib only does pointer copies, not real copies :( */
+    /* I use UNDOCUMENTED features to retrieve the selection... */
+    p_selection = p_clist->selection;
     
-    selected = malloc(sizeof(int)* g_list_length(clist->selection));
-    sel_l = g_list_length(clist->selection);
-    for(dummy=0; dummy < sel_l; dummy++)
+    if( g_list_length( p_selection ) > 0 )
     {
-        selected[dummy] = (int)g_list_nth_data(clist->selection,dummy);
+        /* reverse-sort so that we can delete from the furthest
+         * to the closest item to delete...
+         */
+        p_selection = g_list_sort( p_selection, GtkCompareItems );
+        g_list_foreach( p_selection, GtkDeleteGListItem, p_intf );
+        /* rebuild the CList */
+        GtkRebuildCList( p_clist, p_playlist );
     }
     
-    gtk_clist_freeze( clist );
-    gtk_clist_select_all( clist );
-    for(dummy=0; dummy < sel_l; dummy++)
-    {
-        gtk_clist_unselect_row( clist, selected[dummy],0);
-        gtk_clist_unselect_row( clist, selected[dummy],1);
-    }
-    free( selected );
-    gtk_clist_thaw( clist );
     vlc_mutex_unlock( &p_intf->change_lock );
-}    
+}
 
-void
-on_crop_activate                       (GtkMenuItem     *menuitem,
-                                       gpointer         user_data)
+void GtkPlaylistCrop( GtkMenuItem * menuitem, gpointer user_data )
 {
     /* Ok, this is a really small thing, but, hey, it works and
        might be useful, who knows ? */
-    
-    on_invertselection_clicked (menuitem, user_data);
-    on_delete_clicked(menuitem, user_data);
+    GtkPlaylistInvert( menuitem, user_data );
+    GtkPlaylistDeleteSelected( menuitem, user_data );
 }
 
-
-void
-on_delete_clicked                      (GtkMenuItem       *item,
-                                        gpointer         user_data)
+void GtkPlaylistInvert( GtkMenuItem * menuitem, gpointer user_data )
 {
-    /* user wants to delete a file in the queue */
-    GList * selection;
-    GtkCList    * clist;
-    playlist_t * playlist_p;
+    playlist_t *p_playlist;
+    GtkCList *  p_clist;
+    int *       pi_selected;
+    int         i_sel_l;
+    int         i_dummy;
     
     /* catch the thread back */
-    intf_thread_t *p_intf = GetIntf( GTK_WIDGET(item), "intf_playlist" );
-    playlist_p = p_main->p_playlist;
+    intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), (char*)user_data );
+
+    p_playlist = p_main->p_playlist;
     
     /* lock the struct */
     vlc_mutex_lock( &p_intf->change_lock );
-    clist = GTK_CLIST( lookup_widget(p_intf->p_sys->p_playlist,"playlist_clist") );
+
+    p_clist = GTK_CLIST( gtk_object_get_data( GTK_OBJECT(
+        p_intf->p_sys->p_playlist ), "playlist_clist" ) );
     
-    /* I use UNDOCUMENTED features to retrieve the selection... */
-    selection = clist->selection; 
+    /* have to copy the selection to an int *
+       I wasn't able to copy the g_list to another g_list
+       glib only does pointer copies, not real copies :( */
     
-    if( g_list_length(selection)>0 )
+    pi_selected = malloc( sizeof(int) *g_list_length( p_clist->selection ) );
+    i_sel_l = g_list_length( p_clist->selection );
+
+    for( i_dummy = 0 ; i_dummy < i_sel_l ; i_dummy++)
     {
-        /* reverse-sort so that we can delete from the furthest to the 
-           closest item to delete...
-          */
-        selection = g_list_sort( selection, compareItems );
-        g_list_foreach( selection,
-                        deleteGListItem, 
-                        p_intf );
-        /* rebuild the CList */
-        rebuildCList( clist, playlist_p );
+        pi_selected[i_dummy] = (int)g_list_nth_data( p_clist->selection,
+                                                     i_dummy );
     }
     
+    gtk_clist_freeze( p_clist );
+    gtk_clist_select_all( p_clist );
+
+    for( i_dummy = 0; i_dummy < i_sel_l; i_dummy++)
+    {
+        gtk_clist_unselect_row( p_clist, pi_selected[i_dummy], 0 );
+        gtk_clist_unselect_row( p_clist, pi_selected[i_dummy], 1 );
+    }
+
+    free( pi_selected );
+    gtk_clist_thaw( p_clist );
+
     vlc_mutex_unlock( &p_intf->change_lock );
 }
 
-gboolean
-on_intf_playlist_destroy_event         (GtkWidget       *widget,
-                                        GdkEvent        *event,
-                                        gpointer         user_data)
+void GtkPlaylistSelect( GtkMenuItem * menuitem, gpointer user_data)
 {
-    /* hide ! */
-    gtk_widget_hide(widget);
-    return TRUE;
+
 }
 
-void
-on_intf_playlist_drag_data_received    (GtkWidget       *widget,
-    GdkDragContext  *drag_context,
-    gint             x,
-    gint             y,
-    GtkSelectionData *data,
-    guint            info,
-    guint            time,
-    gpointer         user_data)
+gboolean GtkPlaylistEvent( GtkWidget * widget,
+                           GdkEvent  * event,
+                           gpointer    user_data)
 {
+    intf_thread_t *p_intf = GetIntf( GTK_WIDGET(widget), (char*)user_data );
+
+    if( ( event->button ).type == GDK_2BUTTON_PRESS )
+    {
+        GtkCList *  p_clist;
+        gint        i_row;
+        gint        i_col;
+
+        p_clist = GTK_CLIST( gtk_object_get_data( GTK_OBJECT(
+            p_intf->p_sys->p_playlist ), "playlist_clist" ) );
+        
+        if( gtk_clist_get_selection_info( p_clist, (event->button).x, 
+                    (event->button).y, &i_row, &i_col ) == 1 )
+        {
+            /* clicked is in range. */
+            if( p_intf->p_input != NULL )
+            {
+                /* FIXME: temporary hack */
+                p_intf->p_input->b_eof = 1;
+            }
+
+            intf_PlaylistJumpto( p_main->p_playlist, i_row - 1 );
+        }
+        return TRUE;
+    }
+
+    return FALSE;
+}
+
+void GtkPlaylistDragData( GtkWidget       *widget,
+                          GdkDragContext  *drag_context,
+                          gint             x,
+                          gint             y,
+                          GtkSelectionData *data,
+                          guint            info,
+                          guint            time,
+                          gpointer         user_data )
+{
+    intf_thread_t * p_intf;
+    GtkCList *      p_clist;
+    gint            i_row;
+    gint            i_col;
+    int             i_end = p_main->p_playlist->i_size;
+
     /* catch the interface back */
-    intf_thread_t * p_intf =  GetIntf( GTK_WIDGET(widget), "intf_playlist" );
-    GtkCList *  clist;
-    gint row, col;
+    p_intf = GetIntf( GTK_WIDGET(widget), (char*)user_data );
 
-    clist = GTK_CLIST(lookup_widget( p_intf->p_sys->p_playlist,"playlist_clist" ));
+    p_clist = GTK_CLIST( gtk_object_get_data( GTK_OBJECT(
+        p_intf->p_sys->p_playlist ), "playlist_clist" ) );
    
-    /* are we dropping somewhere into the clist items ? */
-    if( gtk_clist_get_selection_info( clist, 
-                x, 
-                y, 
-                &row, 
-                &col )== 1)
+    if( gtk_clist_get_selection_info( p_clist, x, y, &i_row, &i_col ) == 1 )
     {
-        on_generic_drop_data_received( p_intf, data, info, row );
+        /* we are dropping somewhere into the clist items */
+        GtkDropDataReceived( p_intf, data, info, i_row );
     } 
-    /* else, put that at the end of the playlist */
     else 
     {
-        on_generic_drop_data_received( p_intf, data, info, PLAYLIST_END);
+        /* else, put that at the end of the playlist */
+        GtkDropDataReceived( p_intf, data, info, PLAYLIST_END );
     }
+
+    intf_PlaylistJumpto( p_main->p_playlist, i_end - 1 );
 }
+
+
+gboolean GtkPlaylistDragMotion( GtkWidget       *widget,
+                                GdkDragContext  *drag_context,
+                                gint             x,
+                                gint             y,
+                                guint            time,
+                                gpointer         user_data )
+{
+    intf_thread_t *p_intf;
+    GtkCList *  p_clist;
+    gint        i_row;
+    gint        i_col;
+    int         i_dummy;
+    GdkColor    color;
+
+    p_intf = GetIntf( GTK_WIDGET(widget), (char*)user_data );
+
+    p_clist = GTK_CLIST( gtk_object_get_data( GTK_OBJECT(
+        p_intf->p_sys->p_playlist ), "playlist_clist" ) );
+
+    if( !GTK_WIDGET_TOPLEVEL(widget) )
+    {
+        gdk_window_raise( p_intf->p_sys->p_playlist->window );
+    }
+
+    color.red =   0xffff;
+    color.blue =  0xffff;
+    color.green = 0xffff;
+
+    gtk_clist_freeze( p_clist );
+    
+    for( i_dummy = 0; i_dummy < p_clist->rows; i_dummy++)
+    {
+       gtk_clist_set_background ( p_clist, i_dummy , &color);
+    }
+
+    color.red = 0xffff;
+    color.blue = 0;
+    color.green = 0;
+    gtk_clist_set_background( p_clist, p_main->p_playlist->i_index , &color );
+        
+    if( gtk_clist_get_selection_info( p_clist, x, y, &i_row, &i_col ) == 1)
+    {
+        color.red = 0;
+        color.blue = 0xf000;
+        color.green = 0x9000;
+        gtk_clist_set_background ( p_clist, i_row - 1, &color);
+        gtk_clist_set_background ( p_clist, i_row, &color);
+    }
+
+    gtk_clist_thaw( p_clist );
     
-void on_generic_drop_data_received( intf_thread_t * p_intf,
-        GtkSelectionData *data, guint info, int position)
+    return TRUE;
+}
+
+void GtkDropDataReceived( intf_thread_t * p_intf,
+        GtkSelectionData * p_data, guint i_info, int i_position)
 {
     /* first we'll have to split against all the '\n' we have */
-    gchar * protocol;
-    gchar * temp;
-    gchar * string = data->data ;
-    GList * files = NULL;
-    GtkCList * clist;
+    gchar *     p_protocol;
+    gchar *     p_temp;
+    gchar *     p_string = p_data->data ;
+    GList *     p_files = NULL;
+    GtkCList *  p_clist;
 
     
     /* catch the playlist back */
-    playlist_t * p_playlist = p_main->p_playlist ;
+    playlist_t * p_playlist = p_main->p_playlist;
    
 
     /* if this has been URLencoded, decode it
@@ -339,47 +428,47 @@ void on_generic_drop_data_received( intf_thread_t * p_intf,
      * Is it a good thing to do it in place ?
      * probably not... 
      */
-    if(info == DROP_ACCEPT_TEXT_URI_LIST)
+    if( i_info == DROP_ACCEPT_TEXT_URI_LIST )
     {
-        urldecode_path( string );
+        intf_UrlDecode( p_string );
     }
     
     /* this cuts string into single file drops */
     /* this code was borrowed from xmms, thx guys :) */
-    while(*string)
+    while( *p_string)
     {
-        temp = strchr(string, '\n');
-        if(temp)
+        p_temp = strchr( p_string, '\n' );
+        if( p_temp )
         {
-            if (*(temp - 1) == '\r')
-                *(temp - 1) = '\0';
-            *temp = '\0';
+            if( *( p_temp - 1 ) == '\r' )
+            {
+                *( p_temp - 1) = '\0';
+            }
+            *p_temp = '\0';
         }
-       
-        
+
         /* do we have a protocol or something ? */
-        protocol = strstr( string, ":/" );
-        if( protocol != NULL )
+        p_protocol = strstr( p_string, ":/" );
+        if( p_protocol != NULL )
         {
-            protocol = calloc( protocol - string + 2 , 
-                            sizeof(char));
-            protocol = strncpy( protocol, string, strstr( string, ":/") + 1 - string );
+            p_protocol = calloc( p_protocol - p_string + 2, sizeof(char) );
+            p_protocol = strncpy( p_protocol, p_string,
+                                  strstr( p_string, ":/" ) + 1 - p_string );
 
-            intf_WarnMsg(1,"Protocol dropped is %s",protocol);
-            string += strlen(protocol) ;
+            intf_WarnMsg( 4, "Protocol dropped is %s", p_protocol );
+            p_string += strlen( p_protocol );
 
             /* Allowed things are proto: or proto:// */
-            if(string[0]=='/' && string[1]=='/')
+            if( p_string[0] == '/' && p_string[1] == '/')
             {
                 /* eat one '/' */
-                string++;
+                p_string++;
             }
-            intf_WarnMsg(1,"Dropped %s",string);
-
+            intf_WarnMsg( 4, " Dropped %s", p_string );
         } 
         else 
         {
-            protocol = strdup("");
+            p_protocol = strdup( "" );
         }
          
         /* if it uses the file protocol we can do something, else, sorry :( 
@@ -387,70 +476,108 @@ void on_generic_drop_data_received( intf_thread_t * p_intf,
          * ability to read http:// or ftp:// files
          * what about adding dvd:// to the list of authorized proto ? */
         
-        if( strcmp(protocol,"file:")==0 )
+        if( strcmp( p_protocol, "file:" ) == 0 )
         {
-            files = g_list_concat( files, intf_readFiles( string ) ); 
+            p_files = g_list_concat( p_files, GtkReadFiles( p_string ) ); 
         }
        
         /* free the malloc and go on... */
-        free( protocol );
-        if (!temp)
+        free( p_protocol );
+        if( !p_temp )
+        {
             break;
-        string = temp + 1;
+        }
+        p_string = p_temp + 1;
     }
    
     /* At this point, we have a nice big list maybe NULL */
-    if(files != NULL)
+    if( p_files != NULL )
     {
         /* lock the interface */
         vlc_mutex_lock( &p_intf->change_lock );
-        intf_WarnMsg( 1, "List has %d elements",g_list_length( files ) ); 
-        intf_AppendList( p_playlist, position, files );
+
+        intf_WarnMsg( 4, "List has %d elements", g_list_length( p_files ) ); 
+        GtkAppendList( p_playlist, i_position, p_files );
 
         /* get the CList  and rebuild it. */
-        clist = GTK_CLIST(
-                lookup_widget( p_intf->p_sys->p_playlist,
-                               "playlist_clist" ) ); 
-        rebuildCList( clist , p_playlist );
+        p_clist = GTK_CLIST( lookup_widget( p_intf->p_sys->p_playlist,
+                                            "playlist_clist" ) ); 
+        GtkRebuildCList( p_clist , p_playlist );
         
         /* unlock the interface */
         vlc_mutex_unlock( &p_intf->change_lock );
     }
 }
 
+
+void GtkDeleteGListItem( gpointer data, gpointer param )
+{
+    int i_cur_row = ( int )data;
+    intf_thread_t * p_intf = param;    
+    
+    intf_PlaylistDelete( p_main->p_playlist, i_cur_row );
+
+    /* are we deleting the current played stream */
+    if( p_intf->p_sys->i_playing == i_cur_row )
+    {
+        /* next ! */
+        p_intf->p_input->b_eof = 1;
+        /* this has to set the slider to 0 */
+        
+        /* step minus one */
+        p_intf->p_sys->i_playing-- ;
+
+        vlc_mutex_lock( &p_main->p_playlist->change_lock );
+        p_main->p_playlist->i_index-- ;
+        vlc_mutex_unlock( &p_main->p_playlist->change_lock );
+    }
+}
+
+
+gint GtkCompareItems( gconstpointer a, gconstpointer b )
+{
+    return b - a;
+}
+
+
 /* check a file (string) against supposed valid extension */
-int 
-hasValidExtension( gchar * filename )
+int GtkHasValidExtension( gchar * psz_filename )
 {
-    char * ext[6] = {"mpg","mpeg","vob","mp2","ts","ps"};
+    char * ppsz_ext[6] = { "mpg", "mpeg", "vob", "mp2", "ts", "ps" };
     int  i_ext = 6;
-    int dummy;
-    gchar * p_filename = strrchr( filename, '.' ) + sizeof( char );
-    for( dummy=0; dummy<i_ext;dummy++ )
+    int  i_dummy;
+
+    gchar * psz_ext = strrchr( psz_filename, '.' ) + sizeof( char );
+
+    for( i_dummy = 0 ; i_dummy < i_ext ; i_dummy++ )
     {
-        if( strcmp( p_filename,ext[dummy] )==0 )
+        if( strcmp( psz_ext, ppsz_ext[i_dummy] ) == 0 )
+        {
             return 1;
+        }
     }
+
     return 0;
 }
 
-/* recursive function: descend into folders and build a list of valid filenames */
-GList * 
-intf_readFiles( gchar * fsname )
+/* recursive function: descend into folders and build a list of
+ * valid filenames */
+GList * GtkReadFiles( gchar * psz_fsname )
 {
     struct stat statbuf;
-    GList  * current = NULL;
+    GList  *    p_current = NULL;
 
     /* get the attributes of this file */
-    stat(fsname, &statbuf);
+    stat( psz_fsname, &statbuf );
     
     /* is it a regular file ? */
     if( S_ISREG( statbuf.st_mode ) )
     {
-        if( hasValidExtension(fsname) )
+        if( GtkHasValidExtension( psz_fsname ) )
         {
-            intf_WarnMsg( 3, "%s is a valid file. Stacking on the playlist", fsname );
-            return g_list_append( NULL, g_strdup(fsname) );
+            intf_WarnMsg( 2, "%s is a valid file. Stacking on the playlist",
+                          psz_fsname );
+            return g_list_append( NULL, g_strdup( psz_fsname ) );
         } 
         else
         {
@@ -461,140 +588,140 @@ intf_readFiles( gchar * fsname )
     else if( S_ISDIR( statbuf.st_mode ) ) 
     {
         /* have to cd into this dir */
-        DIR * currentDir = opendir( fsname );
-        struct dirent * dirContent; 
+        DIR *           p_current_dir = opendir( psz_fsname );
+        struct dirent * p_dir_content; 
         
-        intf_WarnMsg( 3, "%s is a folder.", fsname );
+        intf_WarnMsg( 2, "%s is a folder.", psz_fsname );
         
-        if( currentDir == NULL )
+        if( p_current_dir == NULL )
         {
             /* something went bad, get out of here ! */
-            return current;
+            return p_current;
         }
-        dirContent = readdir( currentDir );
+        p_dir_content = readdir( p_current_dir );
 
         /* while we still have entries in the directory */
-        while( dirContent != NULL )
+        while( p_dir_content != NULL )
         {
             /* if it is "." or "..", forget it */
-            if(strcmp(dirContent->d_name,".") != 0
-                    && strcmp(dirContent->d_name,"..") != 0)
+            if( ( strcmp( p_dir_content->d_name, "." ) != 0 ) &&
+                ( strcmp( p_dir_content->d_name, ".." ) != 0 ) )
             {
                 /* else build the new directory by adding
                    fsname "/" and the current entry name 
                    (kludgy :()
                   */
-                char * newfs = malloc ( 2 + 
-                        strlen( fsname ) + 
-                        strlen( dirContent->d_name ) * sizeof( char ) );
-                strcpy( newfs, fsname );
-                strcpy( newfs + strlen( fsname )+1, dirContent->d_name);
-                newfs[strlen( fsname )] = '/';
+                char *  psz_newfs = malloc ( 2 + strlen( psz_fsname ) +
+                            strlen( p_dir_content->d_name ) * sizeof(char) );
+                strcpy( psz_newfs, psz_fsname );
+                strcpy( psz_newfs + strlen( psz_fsname ) + 1,
+                        p_dir_content->d_name );
+                psz_newfs[strlen( psz_fsname )] = '/';
                 
-                current = g_list_concat( current, intf_readFiles( newfs ) );
+                p_current = g_list_concat( p_current,
+                                           GtkReadFiles( psz_newfs ) );
                     
-                g_free( newfs );
+                g_free( psz_newfs );
             }
-            dirContent = readdir( currentDir );
+            p_dir_content = readdir( p_current_dir );
         }
-        return current;
+        return p_current;
     }
     return NULL;
 }
 
 /* add items in a playlist 
-  when i_pos==-1 add to the end of the list... 
* when i_pos==-1 add to the end of the list... 
  */
-int intf_AppendList( playlist_t * p_playlist, int i_pos, GList * list )
+int GtkAppendList( playlist_t * p_playlist, int i_pos, GList * p_list )
 {
-    guint length, dummy;
-    length = g_list_length( list );
-    for( dummy=0; dummy<length; dummy++ )
+    guint i_dummy;
+    guint i_length;
+
+    i_length = g_list_length( p_list );
+
+    for( i_dummy = 0; i_dummy < i_length ; i_dummy++ )
     {
         intf_PlaylistAdd( p_playlist, 
                 /* ok; this is a really nasty trick to insert
                    the item where they are suppose to go but, hey
                    this works :P (btw, you are really nasty too) */
-                i_pos==PLAYLIST_END?PLAYLIST_END:( i_pos + dummy ), 
-                g_list_nth_data(list, dummy));
+                i_pos==PLAYLIST_END?PLAYLIST_END:( i_pos + i_dummy ), 
+                g_list_nth_data( p_list, i_dummy ) );
     }
     return 0;
 }
-gboolean
-on_playlist_clist_event (GtkWidget       *widget,
-                            GdkEvent        *event,
-                            gpointer         user_data)
-{
-    intf_thread_t * p_intf =  GetIntf( GTK_WIDGET( widget ), "intf_playlist" );
-
-    if( ( event->button ).type == GDK_2BUTTON_PRESS )
-    {
-        GtkCList *  clist;
-        gint row, col;
-
-        clist = GTK_CLIST( 
-                    lookup_widget( 
-                        p_intf->p_sys->p_playlist,
-                        "playlist_clist" ) );
-        
-        if( gtk_clist_get_selection_info( clist, 
-                    (event->button).x, 
-                    (event->button).y, 
-                    &row, 
-                    &col )== 1 )
-        {
-
-            /* clicked is in range. */
-            if( p_intf->p_input != NULL )
-            {
-                /* FIXME: temporary hack */
-                p_intf->p_input->b_eof = 1;
-            }
-            intf_PlaylistJumpto( p_main->p_playlist, row-1 );
-        }
-        return TRUE;
-    }
-    return FALSE;
-}
 
 /* statis timeouted function */
-void GtkPlayListManage( gpointer p_data )
+void GtkPlayListManage( intf_thread_t * p_intf )
 {
     /* this thing really sucks for now :( */
 
     /* TODO speak more with interface/intf_playlist.c */
 
-    intf_thread_t *p_intf = (void *)p_data;
-    playlist_t * p_playlist = p_main->p_playlist ;
-
-    vlc_mutex_lock( &p_intf->change_lock );
+    playlist_t *    p_playlist = p_main->p_playlist ;
+    GtkCList *      p_clist;
 
-    if( p_intf->p_sys->i_playing != p_playlist->i_index )
+    if( GTK_IS_WIDGET( p_intf->p_sys->p_playlist ) )
     {
-        GdkColor color;
-
-        color.red = 0xffff;
-        color.green = 0;
-        color.blue = 0;
-
-        gtk_clist_set_background ( GTK_CLIST(
-                    lookup_widget( p_intf->p_sys->p_playlist, 
-                                   "playlist_clist" ) ),
-                    p_playlist->i_index,
-                    &color );
-
-        if( p_intf->p_sys->i_playing != -1 )
+        p_clist = GTK_CLIST( gtk_object_get_data( GTK_OBJECT(
+                       p_intf->p_sys->p_playlist ), "playlist_clist" ) );
+    
+        vlc_mutex_lock( &p_playlist->change_lock );
+    
+        if( p_intf->p_sys->i_playing != p_playlist->i_index )
         {
+            GdkColor color;
+    
             color.red = 0xffff;
-            color.green = 0xffff;
-            color.blue = 0xffff;
-            gtk_clist_set_background (
-            GTK_CLIST(lookup_widget( p_intf->p_sys->p_playlist, "playlist_clist" ) ),
-            p_intf->p_sys->i_playing,
-            &color);
+            color.blue = 0;
+            color.green = 0;
+    
+            gtk_clist_set_background( p_clist, p_playlist->i_index, &color );
+    
+            if( p_intf->p_sys->i_playing != -1 )
+            {
+                color.red = 0xffff;
+                color.blue = 0xffff;
+                color.green = 0xffff;
+                gtk_clist_set_background( p_clist, p_intf->p_sys->i_playing,
+                                          &color);
+            }
+            p_intf->p_sys->i_playing = p_playlist->i_index;
         }
-        p_intf->p_sys->i_playing = p_playlist->i_index;
+    
+        vlc_mutex_unlock( &p_playlist->change_lock );
     }
-    vlc_mutex_unlock( &p_intf->change_lock );
+}
+
+void GtkRebuildCList( GtkCList * p_clist, playlist_t * p_playlist )
+{
+    int         i_dummy;
+    gchar *     ppsz_text[2];
+    GdkColor    red;
+    red.red     = 65535;
+    red.blue    = 0;
+    red.green   = 0;
+    
+    gtk_clist_freeze( p_clist );
+    gtk_clist_clear( p_clist );
+   
+    for( i_dummy = 0; i_dummy < p_playlist->i_size ; i_dummy++ )
+    {
+#ifdef WIN32 /* WIN32 HACK */
+        ppsz_text[0] = g_strdup( "" );
+#else
+        ppsz_text[0] = g_strdup( rindex( (char *)(p_playlist->p_item[
+                p_playlist->i_size - 1 - i_dummy].psz_name ), '/' ) + 1 );
+#endif
+        ppsz_text[1] = g_strdup( "no info");
+        
+        gtk_clist_insert( p_clist, 0, ppsz_text );
+        
+        free( ppsz_text[0] );
+        free( ppsz_text[1] );
+    }
+    gtk_clist_set_background( p_clist, p_playlist->i_index, &red);
+    gtk_clist_thaw( p_clist );
 }