Commit c15864db authored by Sam Hocevar's avatar Sam Hocevar

  * Added HTTP url drop (from a WWW browser) to the gtk/gnome interface.
parent 882422ab
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* gtk_playlist.c : Interface for the playlist dialog * gtk_playlist.c : Interface for the playlist dialog
***************************************************************************** *****************************************************************************
* Copyright (C) 2001 VideoLAN * Copyright (C) 2001 VideoLAN
* $Id: gtk_playlist.c,v 1.18 2001/07/25 03:12:33 sam Exp $ * $Id: gtk_playlist.c,v 1.19 2001/10/04 00:50:24 sam Exp $
* *
* Authors: Pierre Baillet <oct@zoy.org> * Authors: Pierre Baillet <oct@zoy.org>
* Stphane Borel <stef@via.ecp.fr> * Stphane Borel <stef@via.ecp.fr>
...@@ -80,26 +80,6 @@ gboolean GtkPlaylistShow( GtkWidget *widget, ...@@ -80,26 +80,6 @@ gboolean GtkPlaylistShow( GtkWidget *widget,
{ {
intf_thread_t *p_intf = GetIntf( GTK_WIDGET(widget), (char*)user_data ); 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 ) ) if( GTK_WIDGET_VISIBLE( p_intf->p_sys->p_playlist ) )
{ {
gtk_widget_hide( p_intf->p_sys->p_playlist ); gtk_widget_hide( p_intf->p_sys->p_playlist );
...@@ -425,6 +405,7 @@ void GtkDropDataReceived( intf_thread_t * p_intf, ...@@ -425,6 +405,7 @@ void GtkDropDataReceived( intf_thread_t * p_intf,
/* first we'll have to split against all the '\n' we have */ /* first we'll have to split against all the '\n' we have */
gchar * p_protocol; gchar * p_protocol;
gchar * p_temp; gchar * p_temp;
gchar * p_next;
gchar * p_string = p_data->data ; gchar * p_string = p_data->data ;
GList * p_files = NULL; GList * p_files = NULL;
GtkCList * p_clist; GtkCList * p_clist;
...@@ -448,34 +429,36 @@ void GtkDropDataReceived( intf_thread_t * p_intf, ...@@ -448,34 +429,36 @@ void GtkDropDataReceived( intf_thread_t * p_intf,
/* this code was borrowed from xmms, thx guys :) */ /* this code was borrowed from xmms, thx guys :) */
while( *p_string) while( *p_string)
{ {
p_temp = strchr( p_string, '\n' ); p_next = strchr( p_string, '\n' );
if( p_temp ) 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 ? */ /* do we have a protocol or something ? */
p_protocol = strstr( p_string, ":/" ); p_temp = strstr( p_string, ":" );
if( p_protocol != NULL ) if( p_temp != NULL && p_temp[0] != '\0' )
{ {
p_protocol = calloc( p_protocol - p_string + 2, sizeof(char) ); char i_save;
p_protocol = strncpy( p_protocol, p_string,
strstr( p_string, ":/" ) + 1 - p_string ); i_save = p_temp[0];
p_temp[0] = '\0';
intf_WarnMsg( 4, "Protocol dropped is %s", p_protocol ); p_protocol = strdup( p_string );
p_string += strlen( p_protocol ); p_temp[0] = i_save;
p_temp++;
/* Allowed things are proto: or proto:// */ /* Allowed things are proto: or proto:// */
if( p_string[0] == '/' && p_string[1] == '/') if( p_temp[0] == '/' && p_temp[1] == '/')
{ {
/* eat one '/' */ /* eat two '/'s */
p_string++; p_temp += 2;
} }
intf_WarnMsg( 4, " Dropped %s", p_string ); intf_WarnMsg( 4, "playlist: protocol '%s', target '%s'",
p_protocol, p_temp );
} }
else else
{ {
...@@ -491,14 +474,20 @@ void GtkDropDataReceived( intf_thread_t * p_intf, ...@@ -491,14 +474,20 @@ void GtkDropDataReceived( intf_thread_t * p_intf,
{ {
p_files = g_list_concat( p_files, GtkReadFiles( p_string ) ); 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 the malloc and go on... */
free( p_protocol ); free( p_protocol );
if( !p_temp )
if( p_next == NULL )
{ {
break; break;
} }
p_string = p_temp + 1; p_string = p_next + 1;
} }
/* At this point, we have a nice big list maybe NULL */ /* At this point, we have a nice big list maybe NULL */
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* intf_gnome.c: Gnome interface * intf_gnome.c: Gnome interface
***************************************************************************** *****************************************************************************
* Copyright (C) 1999, 2000 VideoLAN * Copyright (C) 1999, 2000 VideoLAN
* $Id: intf_gnome.c,v 1.3 2001/05/30 23:02:04 stef Exp $ * $Id: intf_gnome.c,v 1.4 2001/10/04 00:50:24 sam Exp $
* *
* Authors: Samuel Hocevar <sam@zoy.org> * Authors: Samuel Hocevar <sam@zoy.org>
* Stphane Borel <stef@via.ecp.fr> * Stphane Borel <stef@via.ecp.fr>
...@@ -185,6 +185,7 @@ static void intf_Run( intf_thread_t *p_intf ) ...@@ -185,6 +185,7 @@ static void intf_Run( intf_thread_t *p_intf )
/* The data types we are allowed to receive */ /* The data types we are allowed to receive */
static GtkTargetEntry target_table[] = static GtkTargetEntry target_table[] =
{ {
{ "STRING", 0, DROP_ACCEPT_STRING },
{ "text/uri-list", 0, DROP_ACCEPT_TEXT_URI_LIST }, { "text/uri-list", 0, DROP_ACCEPT_TEXT_URI_LIST },
{ "text/plain", 0, DROP_ACCEPT_TEXT_PLAIN } { "text/plain", 0, DROP_ACCEPT_TEXT_PLAIN }
}; };
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* intf_gtk.c: Gtk+ interface * intf_gtk.c: Gtk+ interface
***************************************************************************** *****************************************************************************
* Copyright (C) 1999, 2000 VideoLAN * Copyright (C) 1999, 2000 VideoLAN
* $Id: intf_gtk.c,v 1.25 2001/05/31 12:45:39 sam Exp $ * $Id: intf_gtk.c,v 1.26 2001/10/04 00:50:24 sam Exp $
* *
* Authors: Samuel Hocevar <sam@zoy.org> * Authors: Samuel Hocevar <sam@zoy.org>
* Stphane Borel <stef@via.ecp.fr> * Stphane Borel <stef@via.ecp.fr>
...@@ -187,6 +187,7 @@ static void intf_Run( intf_thread_t *p_intf ) ...@@ -187,6 +187,7 @@ static void intf_Run( intf_thread_t *p_intf )
/* The data types we are allowed to receive */ /* The data types we are allowed to receive */
static GtkTargetEntry target_table[] = static GtkTargetEntry target_table[] =
{ {
{ "STRING", 0, DROP_ACCEPT_STRING },
{ "text/uri-list", 0, DROP_ACCEPT_TEXT_URI_LIST }, { "text/uri-list", 0, DROP_ACCEPT_TEXT_URI_LIST },
{ "text/plain", 0, DROP_ACCEPT_TEXT_PLAIN } { "text/plain", 0, DROP_ACCEPT_TEXT_PLAIN }
}; };
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* intf_gtk.h: private Gtk+ interface description * intf_gtk.h: private Gtk+ interface description
***************************************************************************** *****************************************************************************
* Copyright (C) 1999, 2000 VideoLAN * Copyright (C) 1999, 2000 VideoLAN
* $Id: intf_gtk.h,v 1.7 2001/06/14 01:49:44 sam Exp $ * $Id: intf_gtk.h,v 1.8 2001/10/04 00:50:24 sam Exp $
* *
* Authors: Samuel Hocevar <sam@zoy.org> * Authors: Samuel Hocevar <sam@zoy.org>
* *
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
*****************************************************************************/ *****************************************************************************/
#define DROP_ACCEPT_TEXT_URI_LIST 0 #define DROP_ACCEPT_TEXT_URI_LIST 0
#define DROP_ACCEPT_TEXT_PLAIN 1 #define DROP_ACCEPT_TEXT_PLAIN 1
#define DROP_ACCEPT_STRING 2
/***************************************************************************** /*****************************************************************************
* Useful inline function * Useful inline function
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment