Commit b8a59e7f authored by Sam Hocevar's avatar Sam Hocevar
Browse files

* ./plugins/gtk/*: the Gnome/Gtk+ interfaces have all their features back.

  * ./src/playlist/playlist.c: fixed an off-by-one loop error.
parent bd0a8b89
......@@ -2,7 +2,7 @@
* vlc_playlist.h : Playlist functions
*****************************************************************************
* Copyright (C) 1999, 2000, 2001, 2002 VideoLAN
* $Id: playlist.h,v 1.6 2002/06/07 14:30:40 sam Exp $
* $Id: playlist.h,v 1.7 2002/06/07 19:54:37 sam Exp $
*
* Authors: Samuel Hocevar <sam@zoy.org>
*
......@@ -57,7 +57,7 @@ struct playlist_s
#define PLAYLIST_APPEND 0x0004
#define PLAYLIST_GO 0x0008
#define PLAYLIST_END -1
#define PLAYLIST_END -666
/* Playlist parsing mode */
#define PLAYLIST_REPEAT_CURRENT 0 /* Keep playing current item */
......
......@@ -2554,7 +2554,7 @@ http://www.videolan.org/
</signal>
<columns>2</columns>
<column_widths>287,70</column_widths>
<selection_mode>GTK_SELECTION_SINGLE</selection_mode>
<selection_mode>GTK_SELECTION_EXTENDED</selection_mode>
<show_titles>True</show_titles>
<shadow_type>GTK_SHADOW_IN</shadow_type>
......@@ -2652,7 +2652,7 @@ http://www.videolan.org/
<name>playlist_add_url</name>
<signal>
<name>activate</name>
<handler>GtkPlaylistAddUrl</handler>
<handler>GtkPlaylistAddUrl_GLADE_SUX_intf_playlist</handler>
<data>&quot;intf_playlist&quot;</data>
<last_modification_time>Sat, 19 May 2001 16:24:27 GMT</last_modification_time>
</signal>
......@@ -2677,7 +2677,7 @@ http://www.videolan.org/
<name>playlist_delete_all</name>
<signal>
<name>activate</name>
<handler>GtkPlaylistDeleteAll</handler>
<handler>GtkPlaylistDeleteAll_GLADE_SUX_intf_playlist</handler>
<data>&quot;intf_playlist&quot;</data>
<last_modification_time>Sat, 19 May 2001 03:08:11 GMT</last_modification_time>
</signal>
......@@ -2690,7 +2690,7 @@ http://www.videolan.org/
<name>playlist_delete_item</name>
<signal>
<name>activate</name>
<handler>GtkPlaylistDeleteSelected</handler>
<handler>GtkPlaylistDeleteSelected_GLADE_SUX_intf_playlist</handler>
<data>&quot;intf_playlist&quot;</data>
<last_modification_time>Sat, 19 May 2001 03:08:05 GMT</last_modification_time>
</signal>
......@@ -2715,7 +2715,7 @@ http://www.videolan.org/
<name>playlist_selection_crop</name>
<signal>
<name>activate</name>
<handler>GtkPlaylistCrop</handler>
<handler>GtkPlaylistCrop_GLADE_SUX_intf_playlist</handler>
<data>&quot;intf_playlist&quot;</data>
<last_modification_time>Sat, 19 May 2001 03:07:56 GMT</last_modification_time>
</signal>
......@@ -2728,7 +2728,7 @@ http://www.videolan.org/
<name>playlist_selection_invert</name>
<signal>
<name>activate</name>
<handler>GtkPlaylistInvert</handler>
<handler>GtkPlaylistInvert_GLADE_SUX_intf_playlist</handler>
<data>&quot;intf_playlist&quot;</data>
<last_modification_time>Sat, 19 May 2001 03:07:51 GMT</last_modification_time>
</signal>
......@@ -2741,7 +2741,7 @@ http://www.videolan.org/
<name>playlist_selection_select</name>
<signal>
<name>activate</name>
<handler>GtkPlaylistSelect</handler>
<handler>GtkPlaylistSelect_GLADE_SUX_intf_playlist</handler>
<data>&quot;intf_playlist&quot;</data>
<last_modification_time>Sat, 19 May 2001 03:07:45 GMT</last_modification_time>
</signal>
......
......@@ -1727,7 +1727,7 @@ static GnomeUIInfo playlist_add_menu_uiinfo[] =
{
GNOME_APP_UI_ITEM, N_("Url"),
NULL,
(gpointer) GtkPlaylistAddUrl, NULL, NULL,
(gpointer) GtkPlaylistAddUrl, "intf_playlist", NULL,
GNOME_APP_PIXMAP_NONE, NULL,
0, (GdkModifierType) 0, NULL
},
......@@ -1739,14 +1739,14 @@ static GnomeUIInfo playlist_delete_menu_uiinfo[] =
{
GNOME_APP_UI_ITEM, N_("All"),
NULL,
(gpointer) GtkPlaylistDeleteAll, NULL, NULL,
(gpointer) GtkPlaylistDeleteAll, "intf_playlist", NULL,
GNOME_APP_PIXMAP_NONE, NULL,
0, (GdkModifierType) 0, NULL
},
{
GNOME_APP_UI_ITEM, N_("Item"),
NULL,
(gpointer) GtkPlaylistDeleteSelected, NULL, NULL,
(gpointer) GtkPlaylistDeleteSelected, "intf_playlist", NULL,
GNOME_APP_PIXMAP_NONE, NULL,
0, (GdkModifierType) 0, NULL
},
......@@ -1758,21 +1758,21 @@ static GnomeUIInfo playlist_selection_menu_uiinfo[] =
{
GNOME_APP_UI_ITEM, N_("Crop"),
NULL,
(gpointer) GtkPlaylistCrop, NULL, NULL,
(gpointer) GtkPlaylistCrop, "intf_playlist", NULL,
GNOME_APP_PIXMAP_NONE, NULL,
0, (GdkModifierType) 0, NULL
},
{
GNOME_APP_UI_ITEM, N_("Invert"),
NULL,
(gpointer) GtkPlaylistInvert, NULL, NULL,
(gpointer) GtkPlaylistInvert, "intf_playlist", NULL,
GNOME_APP_PIXMAP_NONE, NULL,
0, (GdkModifierType) 0, NULL
},
{
GNOME_APP_UI_ITEM, N_("Select"),
NULL,
(gpointer) GtkPlaylistSelect, NULL, NULL,
(gpointer) GtkPlaylistSelect, "intf_playlist", NULL,
GNOME_APP_PIXMAP_NONE, NULL,
0, (GdkModifierType) 0, NULL
},
......@@ -1862,6 +1862,7 @@ create_intf_playlist (void)
gtk_container_add (GTK_CONTAINER (playlist_frame), playlist_clist);
gtk_clist_set_column_width (GTK_CLIST (playlist_clist), 0, 287);
gtk_clist_set_column_width (GTK_CLIST (playlist_clist), 1, 70);
gtk_clist_set_selection_mode (GTK_CLIST (playlist_clist), GTK_SELECTION_EXTENDED);
gtk_clist_column_titles_show (GTK_CLIST (playlist_clist));
playlist_label_url = gtk_label_new (_("Url"));
......
......@@ -2,7 +2,7 @@
* gtk_callbacks.c : Callbacks for the Gtk+ plugin.
*****************************************************************************
* Copyright (C) 2000, 2001 VideoLAN
* $Id: gtk_callbacks.c,v 1.44 2002/06/07 14:30:40 sam Exp $
* $Id: gtk_callbacks.c,v 1.45 2002/06/07 19:54:37 sam Exp $
*
* Authors: Samuel Hocevar <sam@zoy.org>
* Stphane Borel <stef@via.ecp.fr>
......@@ -384,12 +384,20 @@ void GtkJumpCancel( GtkButton *button,
****************************************************************************/
gboolean GtkDiscEject ( GtkWidget *widget, gpointer user_data )
{
#if 0 /* PLAYLIST TARASS */
intf_thread_t *p_intf = GetIntf( GTK_WIDGET(widget), (char*)user_data );
char *psz_device = NULL;
char *psz_parser;
char *psz_current = p_intf->p_vlc->p_playlist->current.psz_name;
char *psz_current;
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 )
{
return FALSE;
}
vlc_mutex_lock( &p_playlist->object_lock );
psz_current = p_playlist->pp_items[ p_playlist->i_index ]->psz_name;
/*
* Get the active input
......@@ -437,6 +445,9 @@ gboolean GtkDiscEject ( GtkWidget *widget, gpointer user_data )
}
}
vlc_mutex_unlock( &p_playlist->object_lock );
vlc_object_release( p_playlist );
if( psz_device == NULL )
{
return TRUE;
......@@ -462,7 +473,7 @@ gboolean GtkDiscEject ( GtkWidget *widget, gpointer user_data )
}
free(psz_device);
#endif
return TRUE;
}
......
......@@ -2,16 +2,16 @@
* gtk_playlist.c : Interface for the playlist dialog
*****************************************************************************
* Copyright (C) 2001 VideoLAN
* $Id: gtk_playlist.c,v 1.34 2002/06/07 16:06:09 sam Exp $
* $Id: gtk_playlist.c,v 1.35 2002/06/07 19:54:37 sam Exp $
*
* Authors: Pierre Baillet <oct@zoy.org>
* Stphane 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
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
......@@ -56,7 +56,8 @@
/****************************************************************************
* Local prototypes
****************************************************************************/
static void UrlDecode( char *encoded_path );
static void UrlDecode ( char * );
static GList * GtkReadFiles ( intf_thread_t *, gchar * );
/****************************************************************************
* Playlist window management
......@@ -75,9 +76,9 @@ gboolean GtkPlaylistShow( GtkWidget *widget,
if( GTK_WIDGET_VISIBLE( p_intf->p_sys->p_playwin ) )
{
gtk_widget_hide( p_intf->p_sys->p_playwin );
}
else
{
}
else
{
GtkCList * p_clist;
p_clist = GTK_CLIST( gtk_object_get_data(
......@@ -158,39 +159,40 @@ void GtkPlaylistDeleteAll( GtkMenuItem * menuitem, gpointer user_data )
void GtkPlaylistDeleteSelected( GtkMenuItem * menuitem, gpointer user_data )
{
#if 0 /* PLAYLIST TARASS */
/* 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(menuitem), /*(char*)user_data*/"intf_playlist" );
p_playlist = p_intf->p_vlc->p_playlist;
intf_thread_t * p_intf = GetIntf( GTK_WIDGET(menuitem), user_data );
playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
FIND_ANYWHERE );
if( p_playlist == NULL )
{
return;
}
/* lock the struct */
vlc_mutex_lock( &p_intf->change_lock );
p_clist = GTK_CLIST( gtk_object_get_data( GTK_OBJECT(
p_intf->p_sys->p_playwin ), "playlist_clist" ) );
/* I use UNDOCUMENTED features to retrieve the selection... */
p_selection = p_clist->selection;
if( g_list_length( p_selection ) > 0 )
if( g_list_length( p_selection ) )
{
/* 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 );
g_list_foreach( p_selection, GtkDeleteGListItem, p_playlist );
/* rebuild the CList */
GtkRebuildCList( p_clist, p_playlist );
}
vlc_mutex_unlock( &p_intf->change_lock );
#endif
vlc_object_release( p_playlist );
}
void GtkPlaylistCrop( GtkMenuItem * menuitem, gpointer user_data )
......@@ -203,51 +205,47 @@ void GtkPlaylistCrop( GtkMenuItem * menuitem, gpointer user_data )
void GtkPlaylistInvert( GtkMenuItem * menuitem, gpointer user_data )
{
#if 0 /* PLAYLIST TARASS */
playlist_t *p_playlist;
GtkCList * p_clist;
int * pi_selected;
int i_sel_l;
int i_length;
int i_dummy;
/* catch the thread back */
intf_thread_t *p_intf = GetIntf( GTK_WIDGET(menuitem), (char*)user_data );
p_playlist = p_intf->p_vlc->p_playlist;
/* lock the struct */
vlc_mutex_lock( &p_intf->change_lock );
p_clist = GTK_CLIST( gtk_object_get_data( GTK_OBJECT(
p_intf->p_sys->p_playwin ), "playlist_clist" ) );
gtk_clist_freeze( p_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 :( */
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++)
i_length = g_list_length( p_clist->selection );
pi_selected = malloc( sizeof(int) * i_length );
for( i_dummy = 0 ; i_dummy < i_length ; i_dummy++ )
{
pi_selected[i_dummy] = (long)g_list_nth_data( p_clist->selection,
i_dummy );
pi_selected[i_dummy] =
GPOINTER_TO_UINT( 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++)
for( i_dummy = 0; i_dummy < i_length; 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 );
#endif
free( pi_selected );
}
void GtkPlaylistSelect( GtkMenuItem * menuitem, gpointer user_data)
......@@ -275,8 +273,8 @@ gboolean GtkPlaylistEvent( GtkWidget * widget,
p_clist = GTK_CLIST( gtk_object_get_data( GTK_OBJECT(
p_intf->p_sys->p_playwin ), "playlist_clist" ) );
if( gtk_clist_get_selection_info( p_clist, (event->button).x,
if( gtk_clist_get_selection_info( p_clist, (event->button).x,
(event->button).y, &i_row, &i_col ) == 1 )
{
playlist_Goto( p_playlist, i_row );
......@@ -299,29 +297,24 @@ void GtkPlaylistDragData( GtkWidget *widget,
guint time,
gpointer user_data )
{
#if 0 /* PLAYLIST TARASS */
intf_thread_t * p_intf = GetIntf( GTK_WIDGET(widget), (char*)user_data );
GtkCList * p_clist;
gint i_row;
gint i_col;
int i_end = p_intf->p_vlc->p_playlist->i_size;
p_clist = GTK_CLIST( gtk_object_get_data( GTK_OBJECT(
p_intf->p_sys->p_playwin ), "playlist_clist" ) );
if( gtk_clist_get_selection_info( p_clist, x, y, &i_row, &i_col ) == 1 )
{
/* we are dropping somewhere into the clist items */
GtkDropDataReceived( p_intf, data, info, i_row );
}
else
GtkDropDataReceived( p_intf, data, info, i_row - 1 );
}
else
{
/* else, put that at the end of the playlist */
/* otherwise, put that at the end of the playlist */
GtkDropDataReceived( p_intf, data, info, PLAYLIST_END );
}
intf_PlaylistJumpto( p_intf->p_vlc->p_playlist, i_end - 1 );
#endif
}
......@@ -332,15 +325,19 @@ gboolean GtkPlaylistDragMotion( GtkWidget *widget,
guint time,
gpointer user_data )
{
#if 0 /* PLAYLIST TARASS */
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 );
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 )
{
return FALSE;
}
p_clist = GTK_CLIST( gtk_object_get_data( GTK_OBJECT(
p_intf->p_sys->p_playwin ), "playlist_clist" ) );
......@@ -355,37 +352,41 @@ gboolean GtkPlaylistDragMotion( GtkWidget *widget,
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);
gtk_clist_set_background( p_clist, i_dummy , &color );
}
color.red = 0;
color.blue = 0xf000;
color.green = 0x9000;
if( gtk_clist_get_selection_info( p_clist, x, y, &i_row, &i_col ) == 1 )
{
gtk_clist_set_background ( p_clist, i_row - 1, &color );
gtk_clist_set_background ( p_clist, i_row, &color );
}
else
{
gtk_clist_set_background ( p_clist, p_clist->rows - 1, &color );
}
color.red = 0xffff;
color.blue = 0;
color.green = 0;
i_row = p_intf->p_vlc->p_playlist->i_index;
gtk_clist_set_background( p_clist, i_row, &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);
}
vlc_mutex_lock( &p_playlist->object_lock );
gtk_clist_set_background( p_clist, p_playlist->i_index, &color );
vlc_mutex_unlock( &p_playlist->object_lock );
vlc_object_release( p_playlist );
gtk_clist_thaw( p_clist );
#endif
return TRUE;
}
void GtkDropDataReceived( intf_thread_t * p_intf,
GtkSelectionData * p_data, guint i_info, int i_position)
{
#if 0 /* PLAYLIST TARASS */
/* first we'll have to split against all the '\n' we have */
gchar * p_protocol;
gchar * p_temp;
......@@ -394,21 +395,23 @@ void GtkDropDataReceived( intf_thread_t * p_intf,
GList * p_files = NULL;
GtkCList * p_clist;
/* catch the playlist back */
playlist_t * p_playlist = p_intf->p_vlc->p_playlist;
playlist_t * p_playlist = vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST,
FIND_ANYWHERE );
if( p_playlist == NULL )
{
return;
}
/* if this has been URLencoded, decode it
*
*
* Is it a good thing to do it in place ?
* probably not...
* probably not...
*/
if( i_info == DROP_ACCEPT_TEXT_URI_LIST )
{
UrlDecode( p_string );
}
/* this cuts string into single file drops */
/* this code was borrowed from xmms, thx guys :) */
while( *p_string)
......@@ -443,27 +446,28 @@ void GtkDropDataReceived( intf_thread_t * p_intf,
}
msg_Dbg( p_intf, "playlist protocol '%s', target '%s'",
p_protocol, p_temp );
}
else
}
else
{
p_protocol = strdup( "" );
}
/* if it uses the file protocol we can do something, else, sorry :(
/* if it uses the file protocol we can do something, else, sorry :(
* I think this is a good choice for now, as we don't have any
* ability to read http:// or ftp:// files
* what about adding dvd:// to the list of authorized proto ? */
if( strcmp( p_protocol, "file:" ) == 0 )
{
p_files = g_list_concat( p_files, GtkReadFiles( p_string ) );
p_files = g_list_concat( p_files,
GtkReadFiles( p_intf, 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 );
......@@ -473,51 +477,35 @@ void GtkDropDataReceived( intf_thread_t * p_intf,
}
p_string = p_next + 1;
}
/* At this point, we have a nice big list maybe NULL */
if( p_files != NULL )
{
/* lock the interface */
vlc_mutex_lock( &p_intf->change_lock );
msg_Dbg( p_intf, "list has %d elements", g_list_length( p_files ) );
msg_Dbg( p_intf, "adding %d elements", g_list_length( p_files ) );
GtkAppendList( p_playlist, i_position, p_files );
/* get the CList and rebuild it. */
p_clist = GTK_CLIST( lookup_widget( p_intf->p_sys->p_playwin,
"playlist_clist" ) );
"playlist_clist" ) );
GtkRebuildCList( p_clist , p_playlist );
/* unlock the interface */
vlc_mutex_unlock( &p_intf->change_lock );
}
#endif
vlc_object_release( p_playlist );
}
void GtkDeleteGListItem( gpointer data, gpointer param )
{
#if 0 /* PLAYLIST TARASS */
int i_cur_row = (long)data;
intf_thread_t * p_intf = param;
intf_PlaylistDelete( p_intf->p_vlc->p_playlist, i_cur_row );
playlist_t * p_playlist = param;
/* are we deleting the current played stream */
if( p_intf->p_sys->i_playing == i_cur_row )
{
/* next ! */
p_intf->p_sys->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_intf->p_vlc->p_playlist->change_lock );
p_intf->p_vlc->p_playlist->i_index-- ;
vlc_mutex_unlock( &p_intf->p_vlc->p_playlist->change_lock );
}
#endif
playlist_Delete( p_playlist, i_cur_row );
}
......@@ -549,37 +537,37 @@ int GtkHasValidExtension( gchar * psz_filename )
/* recursive function: descend into folders and build a list of
* valid filenames */
GList * GtkReadFiles( gchar * psz_fsname )
static GList * GtkReadFiles( intf_thread_t * p_intf, gchar * psz_fsname )
{
struct stat statbuf;
GList * p_current = NULL;
/* get the attributes of this file */
stat( psz_fsname, &statbuf );
/* is it a regular file ? */
if( S_ISREG( statbuf.st_mode ) )
{
if( GtkHasValidExtension( psz_fsname ) )
{
//X msg_Warn( "%s is a valid file. Stacking on the playlist",
//X psz_fsname );
msg_Dbg( p_intf, "%s is a valid file, stacking on the playlist",
psz_fsname );
return g_list_append( NULL, g_strdup( psz_fsname ) );
}
}
else
{
return NULL;
}
}
}
/* is it a directory (should we check for symlinks ?) */
else if( S_ISDIR( statbuf.st_mode ) )