* gtk_playlist.c : Interface for the playlist dialog
*****************************************************************************
* Copyright (C) 2001 VideoLAN
- * $Id: gtk_playlist.c,v 1.14 2001/05/23 23:08:20 stef Exp $
+ * $Id: gtk_playlist.c,v 1.24 2001/12/30 07:09:55 sam Exp $
*
* Authors: Pierre Baillet <oct@zoy.org>
* Stéphane Borel <stef@via.ecp.fr>
/*****************************************************************************
* Preamble
*****************************************************************************/
-#include "defs.h"
-
#include <stdlib.h>
-
-#include <gtk/gtk.h>
-
#include <string.h>
+#include <videolan/vlc.h>
+
#include <sys/types.h> /* for readdir and stat stuff */
-#include <dirent.h>
+
+#ifndef WIN32
+# include <dirent.h>
+#endif
+
#include <sys/stat.h>
#include <unistd.h>
-#include "config.h"
-#include "common.h"
-#include "threads.h"
-#include "mtime.h"
+#ifdef MODULE_NAME_IS_gnome
+# include <gnome.h>
+#else
+# include <gtk/gtk.h>
+#endif
#include "stream_control.h"
#include "input_ext-intf.h"
#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_support.h"
#include "gtk_playlist.h"
-#include "intf_gtk.h"
-
-
-#include "main.h"
+#include "gtk_common.h"
/****************************************************************************
* Playlist window management
{
intf_thread_t *p_intf = GetIntf( GTK_WIDGET(widget), (char*)user_data );
- if( !GTK_IS_WIDGET( p_intf->p_sys->p_playlist ) )
- {
- /* 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 );
playlist_t *p_playlist;
/* catch the thread back */
- intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), (char*)user_data );
+ intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), /*(char*)user_data*/"intf_playlist" );
p_playlist = p_main->p_playlist;
for( i_dummy = 0 ; i_dummy < i_sel_l ; i_dummy++)
{
- pi_selected[i_dummy] = (int)g_list_nth_data( p_clist->selection,
- i_dummy );
+ pi_selected[i_dummy] = (long)g_list_nth_data( p_clist->selection,
+ i_dummy );
}
gtk_clist_freeze( p_clist );
/* first we'll have to split against all the '\n' we have */
gchar * p_protocol;
gchar * p_temp;
+ gchar * p_next;
gchar * p_string = p_data->data ;
GList * p_files = NULL;
GtkCList * p_clist;
*/
if( i_info == DROP_ACCEPT_TEXT_URI_LIST )
{
- urldecode_path( p_string );
+ intf_UrlDecode( p_string );
}
/* this cuts string into single file drops */
/* this code was borrowed from xmms, thx guys :) */
while( *p_string)
{
- p_temp = strchr( p_string, '\n' );
- if( p_temp )
+ p_next = strchr( p_string, '\n' );
+ if( p_next )
{
- if( *( p_temp - 1 ) == '\r' )
+ if( *( p_next - 1 ) == '\r' )
{
- *( p_temp - 1) = '\0';
+ *( p_next - 1) = '\0';
}
- *p_temp = '\0';
+ *p_next = '\0';
}
/* do we have a protocol or something ? */
- p_protocol = strstr( p_string, ":/" );
- if( p_protocol != NULL )
+ p_temp = strstr( p_string, ":" );
+ if( p_temp != NULL && p_temp[0] != '\0' )
{
- 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( 4, "Protocol dropped is %s", p_protocol );
- p_string += strlen( p_protocol );
-
+ char i_save;
+
+ i_save = p_temp[0];
+ p_temp[0] = '\0';
+ p_protocol = strdup( p_string );
+ p_temp[0] = i_save;
+ p_temp++;
+
/* Allowed things are proto: or proto:// */
- if( p_string[0] == '/' && p_string[1] == '/')
+ if( p_temp[0] == '/' && p_temp[1] == '/')
{
- /* eat one '/' */
- p_string++;
+ /* eat two '/'s */
+ p_temp += 2;
}
- intf_WarnMsg( 4, " Dropped %s", p_string );
+ intf_WarnMsg( 4, "playlist: protocol '%s', target '%s'",
+ p_protocol, p_temp );
}
else
{
{
p_files = g_list_concat( p_files, GtkReadFiles( p_string ) );
}
+ else
+ {
+ p_files = g_list_concat( p_files,
+ g_list_append( NULL, g_strdup( p_string ) ) );
+ }
/* free the malloc and go on... */
free( p_protocol );
- if( !p_temp )
+
+ if( p_next == NULL )
{
break;
}
- p_string = p_temp + 1;
+ p_string = p_next + 1;
}
/* At this point, we have a nice big list maybe NULL */
void GtkDeleteGListItem( gpointer data, gpointer param )
{
- int i_cur_row = ( int )data;
+ int i_cur_row = (long)data;
intf_thread_t * p_intf = param;
intf_PlaylistDelete( p_main->p_playlist, i_cur_row );
for( i_dummy = 0; i_dummy < p_playlist->i_size ; i_dummy++ )
{
#ifdef WIN32 /* WIN32 HACK */
- ppsz_text[0] = g_strdup( "" );
+ ppsz_text[0] = "";
#else
- ppsz_text[0] = g_strdup( rindex( (char *)(p_playlist->p_item[
- p_playlist->i_size - 1 - i_dummy].psz_name ), '/' ) + 1 );
+ ppsz_text[0] = rindex( p_playlist->p_item[
+ p_playlist->i_size - 1 - i_dummy].psz_name, '/' );
+ if ( ppsz_text[0] == NULL )
+ {
+ ppsz_text[0] =
+ p_playlist->p_item[ p_playlist->i_size - 1 - i_dummy ].psz_name;
+ }
+ else
+ {
+ /* Skip leading '/' */
+ ppsz_text[0]++;
+ }
#endif
- ppsz_text[1] = g_strdup( "no info");
+ ppsz_text[1] = "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 );