Commit 4343919e authored by Jean-Paul Saman's avatar Jean-Paul Saman

PDA interface:

* Directory browsing works
* Coredump is solved
* Adding files or entire directories to the playlist GUI control works.
parent 1b18a015
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* callbacks.c : Callbacks for the pda Linux Gtk+ plugin. * callbacks.c : Callbacks for the pda Linux Gtk+ plugin.
***************************************************************************** *****************************************************************************
* Copyright (C) 2000, 2001 VideoLAN * Copyright (C) 2000, 2001 VideoLAN
* $Id: callbacks.c,v 1.1 2003/07/23 22:02:56 jpsaman Exp $ * $Id: callbacks.c,v 1.2 2003/11/07 13:01:51 jpsaman Exp $
* *
* Authors: Jean-Paul Saman <jpsaman@wxs.nl> * Authors: Jean-Paul Saman <jpsaman@wxs.nl>
* *
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* pda.c : PDA Gtk2 plugin for vlc * pda.c : PDA Gtk2 plugin for vlc
***************************************************************************** *****************************************************************************
* Copyright (C) 2002 VideoLAN * Copyright (C) 2002 VideoLAN
* $Id: pda.c,v 1.7 2003/11/07 09:24:58 jpsaman Exp $ * $Id: pda.c,v 1.8 2003/11/07 13:01:51 jpsaman Exp $
* *
* Authors: Jean-Paul Saman <jpsaman@wxs.nl> * Authors: Jean-Paul Saman <jpsaman@wxs.nl>
* Marc Ariberti <marcari@videolan.org> * Marc Ariberti <marcari@videolan.org>
...@@ -147,14 +147,15 @@ static void Run( intf_thread_t *p_intf ) ...@@ -147,14 +147,15 @@ static void Run( intf_thread_t *p_intf )
#endif #endif
GtkCellRenderer *renderer = NULL; GtkCellRenderer *renderer = NULL;
GtkTreeViewColumn *column = NULL; GtkTreeViewColumn *column = NULL;
GtkListStore *filelist = NULL;
gtk_set_locale ();
#ifndef NEED_GTK2_MAIN #ifndef NEED_GTK2_MAIN
gtk_set_locale ();
msg_Dbg( p_intf, "Starting pda GTK2+ interface" ); msg_Dbg( p_intf, "Starting pda GTK2+ interface" );
gtk_init( &i_args, &pp_args ); gtk_init( &i_args, &pp_args );
#else #else
/* Initialize Gtk+ */ /* Initialize Gtk+ */
msg_Dbg( p_intf, "Starting pda GTK+ interface thread" ); msg_Dbg( p_intf, "Starting pda GTK2+ interface thread" );
gdk_threads_enter(); gdk_threads_enter();
#endif #endif
...@@ -182,8 +183,6 @@ static void Run( intf_thread_t *p_intf ) ...@@ -182,8 +183,6 @@ static void Run( intf_thread_t *p_intf )
/* Get the notebook object */ /* Get the notebook object */
p_intf->p_sys->p_notebook = GTK_NOTEBOOK( gtk_object_get_data( p_intf->p_sys->p_notebook = GTK_NOTEBOOK( gtk_object_get_data(
GTK_OBJECT( p_intf->p_sys->p_window ), "notebook" ) ); GTK_OBJECT( p_intf->p_sys->p_window ), "notebook" ) );
p_intf->p_sys->p_mediabook = GTK_NOTEBOOK( gtk_object_get_data(
GTK_OBJECT( p_intf->p_sys->p_window ), "mediabook" ) );
/* Get the slider object */ /* Get the slider object */
p_intf->p_sys->p_slider = GTK_HSCALE( gtk_object_get_data( p_intf->p_sys->p_slider = GTK_HSCALE( gtk_object_get_data(
...@@ -247,16 +246,16 @@ static void Run( intf_thread_t *p_intf ) ...@@ -247,16 +246,16 @@ static void Run( intf_thread_t *p_intf )
/* Get new directory listing */ /* Get new directory listing */
msg_Dbg(p_intf, "Populating GtkTreeView FileList" ); msg_Dbg(p_intf, "Populating GtkTreeView FileList" );
p_intf->p_sys->p_filelist = gtk_list_store_new (5, filelist = gtk_list_store_new (5,
G_TYPE_STRING, /* Filename */ G_TYPE_STRING, /* Filename */
G_TYPE_STRING, /* permissions */ G_TYPE_STRING, /* permissions */
G_TYPE_UINT64, /* File size */ G_TYPE_UINT64, /* File size */
G_TYPE_STRING, /* Owner */ G_TYPE_STRING, /* Owner */
G_TYPE_STRING);/* Group */ G_TYPE_STRING);/* Group */
ReadDirectory(p_intf, p_intf->p_sys->p_filelist, "."); ReadDirectory(filelist, ".");
msg_Dbg(p_intf, "Showing GtkTreeView FileList" ); msg_Dbg(p_intf, "Showing GtkTreeView FileList" );
gtk_tree_view_set_model(GTK_TREE_VIEW(p_intf->p_sys->p_tvfile), GTK_TREE_MODEL(p_intf->p_sys->p_filelist)); gtk_tree_view_set_model(GTK_TREE_VIEW(p_intf->p_sys->p_tvfile), GTK_TREE_MODEL(filelist));
g_object_unref(p_intf->p_sys->p_filelist); /* Model will be released by GtkTreeView */ g_object_unref(filelist); /* Model will be released by GtkTreeView */
gtk_tree_selection_set_mode(gtk_tree_view_get_selection(GTK_TREE_VIEW(p_intf->p_sys->p_tvfile)),GTK_SELECTION_MULTIPLE); gtk_tree_selection_set_mode(gtk_tree_view_get_selection(GTK_TREE_VIEW(p_intf->p_sys->p_tvfile)),GTK_SELECTION_MULTIPLE);
/* Column properties */ /* Column properties */
...@@ -278,11 +277,13 @@ static void Run( intf_thread_t *p_intf ) ...@@ -278,11 +277,13 @@ static void Run( intf_thread_t *p_intf )
gtk_tree_view_insert_column_with_attributes(p_intf->p_sys->p_tvplaylist, 0, _("Filename"), renderer, NULL); gtk_tree_view_insert_column_with_attributes(p_intf->p_sys->p_tvplaylist, 0, _("Filename"), renderer, NULL);
column = gtk_tree_view_get_column(p_intf->p_sys->p_tvplaylist, 0 ); column = gtk_tree_view_get_column(p_intf->p_sys->p_tvplaylist, 0 );
gtk_tree_view_column_add_attribute(column, renderer, "text", 0 ); gtk_tree_view_column_add_attribute(column, renderer, "text", 0 );
gtk_tree_view_column_set_sort_column_id(column, 0);
/* Column 2 */ /* Column 2 */
renderer = gtk_cell_renderer_text_new (); renderer = gtk_cell_renderer_text_new ();
gtk_tree_view_insert_column_with_attributes(p_intf->p_sys->p_tvplaylist, 1, _("Time"), renderer, NULL); gtk_tree_view_insert_column_with_attributes(p_intf->p_sys->p_tvplaylist, 1, _("Time"), renderer, NULL);
column = gtk_tree_view_get_column(p_intf->p_sys->p_tvplaylist, 1 ); column = gtk_tree_view_get_column(p_intf->p_sys->p_tvplaylist, 1 );
gtk_tree_view_column_add_attribute(column, renderer, "text", 1 ); gtk_tree_view_column_add_attribute(column, renderer, "text", 1 );
gtk_tree_view_column_set_sort_column_id(column, 1);
/* update the playlist */ /* update the playlist */
msg_Dbg(p_intf, "Populating GtkTreeView Playlist" ); msg_Dbg(p_intf, "Populating GtkTreeView Playlist" );
...@@ -305,15 +306,11 @@ static void Run( intf_thread_t *p_intf ) ...@@ -305,15 +306,11 @@ static void Run( intf_thread_t *p_intf )
p_intf->p_sys->p_mrlentry = GTK_ENTRY( gtk_object_get_data( p_intf->p_sys->p_mrlentry = GTK_ENTRY( gtk_object_get_data(
GTK_OBJECT( p_intf->p_sys->p_window ), "mrl_entry" ) ); GTK_OBJECT( p_intf->p_sys->p_window ), "mrl_entry" ) );
#if 0
/* Store p_intf to keep an eye on it */ /* Store p_intf to keep an eye on it */
msg_Dbg( p_intf, "trying to store p_intf pointer ... " ); msg_Dbg( p_intf, "trying to store p_intf pointer ... " );
gtk_object_set_data( GTK_OBJECT(p_intf->p_sys->p_window), gtk_object_set_data( GTK_OBJECT(p_intf->p_sys->p_window),
"p_intf", p_intf ); "p_intf", p_intf );
gtk_object_set_data( GTK_OBJECT(p_intf->p_sys->p_adj),
"p_intf", p_intf );
msg_Dbg( p_intf, "trying to store p_intf pointer ... done" ); msg_Dbg( p_intf, "trying to store p_intf pointer ... done" );
#endif
/* Show the control window */ /* Show the control window */
gtk_widget_show( p_intf->p_sys->p_window ); gtk_widget_show( p_intf->p_sys->p_window );
......
...@@ -31,45 +31,6 @@ ...@@ -31,45 +31,6 @@
<property name="toolbar_style">GTK_TOOLBAR_ICONS</property> <property name="toolbar_style">GTK_TOOLBAR_ICONS</property>
<property name="tooltips">True</property> <property name="tooltips">True</property>
<child>
<widget class="button" id="tbOpen">
<property name="width_request">22</property>
<property name="height_request">22</property>
<property name="visible">True</property>
<property name="tooltip" translatable="yes">File</property>
<property name="label" translatable="yes">Open</property>
<property name="use_underline">True</property>
<property name="icon">pda-openb16x16.xpm</property>
<signal name="clicked" handler="onFileOpen" last_modification_time="Fri, 26 Sep 2003 12:26:11 GMT"/>
</widget>
</child>
<child>
<widget class="button" id="tbPlaylist">
<property name="width_request">22</property>
<property name="height_request">22</property>
<property name="visible">True</property>
<property name="tooltip" translatable="yes">Playlist</property>
<property name="label" translatable="yes">Playlist</property>
<property name="use_underline">True</property>
<property name="icon">pda-playlistb16x16.xpm</property>
<signal name="clicked" handler="onPlaylist" last_modification_time="Fri, 26 Sep 2003 12:26:23 GMT"/>
</widget>
</child>
<child>
<widget class="button" id="tbPreferences">
<property name="width_request">22</property>
<property name="height_request">22</property>
<property name="visible">True</property>
<property name="tooltip" translatable="yes">Preferences</property>
<property name="label" translatable="yes">Preferences</property>
<property name="use_underline">True</property>
<property name="icon">pda-preferencesb16x16.xpm</property>
<signal name="clicked" handler="onPreferences" last_modification_time="Fri, 26 Sep 2003 12:26:36 GMT"/>
</widget>
</child>
<child> <child>
<widget class="button" id="tbRewind"> <widget class="button" id="tbRewind">
<property name="width_request">22</property> <property name="width_request">22</property>
...@@ -157,7 +118,7 @@ ...@@ -157,7 +118,7 @@
<child> <child>
<widget class="GtkLabel" id="timeLabel"> <widget class="GtkLabel" id="timeLabel">
<property name="visible">True</property> <property name="visible">True</property>
<property name="label" translatable="yes">0:00:00</property> <property name="label" translatable="yes">00:00:00</property>
<property name="use_underline">False</property> <property name="use_underline">False</property>
<property name="use_markup">False</property> <property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_CENTER</property> <property name="justify">GTK_JUSTIFY_CENTER</property>
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* pda.h: private Gtk+ interface description * pda.h: private Gtk+ interface description
***************************************************************************** *****************************************************************************
* Copyright (C) 1999, 2000 VideoLAN * Copyright (C) 1999, 2000 VideoLAN
* $Id: pda.h,v 1.3 2003/10/03 18:04:58 jpsaman Exp $ * $Id: pda.h,v 1.4 2003/11/07 13:01:51 jpsaman Exp $
* *
* Authors: Jean-Paul Saman <jpsaman@wxs.nl> * Authors: Jean-Paul Saman <jpsaman@wxs.nl>
* *
...@@ -35,11 +35,9 @@ struct intf_sys_t ...@@ -35,11 +35,9 @@ struct intf_sys_t
GtkWidget *p_window; /* main window */ GtkWidget *p_window; /* main window */
GtkEntry *p_mrlentry; GtkEntry *p_mrlentry;
GtkNotebook *p_notebook; GtkNotebook *p_notebook;
GtkNotebook *p_mediabook;
GtkHScale *p_slider; GtkHScale *p_slider;
GtkTreeView *p_tvfile; GtkTreeView *p_tvfile;
GtkTreeView *p_tvplaylist; GtkTreeView *p_tvplaylist;
GtkListStore *p_filelist; /* File list widget */
GtkListStore *p_playlist; /* Playlist widget */ GtkListStore *p_playlist; /* Playlist widget */
/* slider */ /* slider */
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* pda_callbacks.c : Callbacks for the pda Linux Gtk+ plugin. * pda_callbacks.c : Callbacks for the pda Linux Gtk+ plugin.
***************************************************************************** *****************************************************************************
* Copyright (C) 2000, 2001 VideoLAN * Copyright (C) 2000, 2001 VideoLAN
* $Id: pda_callbacks.c,v 1.4 2003/11/07 09:24:58 jpsaman Exp $ * $Id: pda_callbacks.c,v 1.5 2003/11/07 13:01:51 jpsaman Exp $
* *
* Authors: Jean-Paul Saman <jpsaman@wxs.nl> * Authors: Jean-Paul Saman <jpsaman@wxs.nl>
* *
...@@ -103,7 +103,6 @@ void PlaylistRebuildListStore( GtkListStore * p_list, playlist_t * p_playlist ) ...@@ -103,7 +103,6 @@ void PlaylistRebuildListStore( GtkListStore * p_list, playlist_t * p_playlist )
0, ppsz_text[0], 0, ppsz_text[0],
1, ppsz_text[1], 1, ppsz_text[1],
-1); -1);
} }
vlc_mutex_unlock( &p_playlist->object_lock ); vlc_mutex_unlock( &p_playlist->object_lock );
} }
...@@ -115,9 +114,8 @@ void MediaURLOpenChanged( GtkWidget *widget, gchar *psz_url ) ...@@ -115,9 +114,8 @@ void MediaURLOpenChanged( GtkWidget *widget, gchar *psz_url )
{ {
intf_thread_t *p_intf = GtkGetIntf( widget ); intf_thread_t *p_intf = GtkGetIntf( widget );
playlist_t *p_playlist; playlist_t *p_playlist;
GtkListStore *p_liststore; GtkTreeView *p_tvplaylist;
// Add p_url to playlist .... but how ?
p_playlist = (playlist_t *) p_playlist = (playlist_t *)
vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE ); vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
...@@ -139,32 +137,32 @@ void MediaURLOpenChanged( GtkWidget *widget, gchar *psz_url ) ...@@ -139,32 +137,32 @@ void MediaURLOpenChanged( GtkWidget *widget, gchar *psz_url )
PLAYLIST_APPEND, PLAYLIST_END ); PLAYLIST_APPEND, PLAYLIST_END );
} }
vlc_object_release( p_playlist ); vlc_object_release( p_playlist );
msg_Dbg(p_intf, "MediaURLOpenChange: Populating GtkTreeView Playlist" );
p_liststore = gtk_list_store_new (2, p_tvplaylist = (GtkTreeView*) lookup_widget( GTK_WIDGET(widget), "tvPlaylist" );
G_TYPE_STRING, if (p_tvplaylist)
G_TYPE_STRING); {
GtkListStore *p_liststore;
p_liststore = (GtkListStore *) gtk_tree_view_get_model(p_tvplaylist);
PlaylistRebuildListStore(p_liststore, p_playlist); PlaylistRebuildListStore(p_liststore, p_playlist);
msg_Dbg(p_intf, "MediaURLOpenChange: Updating GtkTreeView Playlist" ); }
gtk_tree_view_set_model(p_intf->p_sys->p_tvplaylist, (GtkTreeModel*) p_liststore);
} }
} }
/***************************************************************** /*****************************************************************
* Read directory helper function. * Read directory helper function.
****************************************************************/ ****************************************************************/
void ReadDirectory( intf_thread_t *p_intf, GtkListStore *p_list, char *psz_dir ) void ReadDirectory(GtkListStore *p_list, char *psz_dir )
{ {
// intf_thread_t *p_intf = GtkGetIntf( GTK_WIDGET(p_list) );
GtkTreeIter iter; GtkTreeIter iter;
struct dirent **namelist; struct dirent **namelist;
int n=-1, status=-1; int n=-1, status=-1;
msg_Dbg(p_intf, "changing to dir %s", psz_dir); g_print("changing to dir %s\n", psz_dir);
if (psz_dir) if (psz_dir)
{ {
status = chdir(psz_dir); status = chdir(psz_dir);
if (status<0) if (status<0)
msg_Err( p_intf, "permision denied" ); g_print( "permision denied\n" );
} }
n = scandir(".", &namelist, 0, alphasort); n = scandir(".", &namelist, 0, alphasort);
...@@ -178,8 +176,6 @@ void ReadDirectory( intf_thread_t *p_intf, GtkListStore *p_list, char *psz_dir ) ...@@ -178,8 +176,6 @@ void ReadDirectory( intf_thread_t *p_intf, GtkListStore *p_list, char *psz_dir )
off_t size; off_t size;
gchar *ppsz_text[5]; gchar *ppsz_text[5];
msg_Dbg( p_intf, "updating interface" );
/* XXX : kludge temporaire pour yopy */ /* XXX : kludge temporaire pour yopy */
ppsz_text[0]=".."; ppsz_text[0]="..";
ppsz_text[1] = get_file_stat("..", &uid, &gid, &size); ppsz_text[1] = get_file_stat("..", &uid, &gid, &size);
...@@ -210,8 +206,9 @@ void ReadDirectory( intf_thread_t *p_intf, GtkListStore *p_list, char *psz_dir ) ...@@ -210,8 +206,9 @@ void ReadDirectory( intf_thread_t *p_intf, GtkListStore *p_list, char *psz_dir )
ppsz_text[2] = ""; ppsz_text[2] = "";
ppsz_text[3] = ""; ppsz_text[3] = "";
ppsz_text[4] = ""; ppsz_text[4] = "";
#if 0
// msg_Dbg(p_intf, "(%d) file: %s permission: %s user: %ull group: %ull size: %ull", i, ppsz_text[0], ppsz_text[1], uid, gid, size ); g_print( "(%d) file: %s permission: %s user: %ull group: %ull size: %ull\n", i, ppsz_text[0], ppsz_text[1], uid, gid, size );
#endif
gtk_list_store_append (p_list, &iter); gtk_list_store_append (p_list, &iter);
gtk_list_store_set (p_list, &iter, gtk_list_store_set (p_list, &iter,
0, ppsz_text[0], 0, ppsz_text[0],
...@@ -226,13 +223,6 @@ void ReadDirectory( intf_thread_t *p_intf, GtkListStore *p_list, char *psz_dir ) ...@@ -226,13 +223,6 @@ void ReadDirectory( intf_thread_t *p_intf, GtkListStore *p_list, char *psz_dir )
} }
free(namelist); free(namelist);
} }
/* now switch to the "file" tab */
if (p_intf->p_sys->p_mediabook)
{
gtk_widget_show( GTK_WIDGET(p_intf->p_sys->p_mediabook) );
gtk_notebook_set_page(p_intf->p_sys->p_mediabook,0);
}
} }
static char* get_file_stat(const char *path, uid_t *uid, gid_t *gid, off_t *size) static char* get_file_stat(const char *path, uid_t *uid, gid_t *gid, off_t *size)
...@@ -338,35 +328,29 @@ void ...@@ -338,35 +328,29 @@ void
onFileOpen (GtkButton *button, onFileOpen (GtkButton *button,
gpointer user_data) gpointer user_data)
{ {
intf_thread_t *p_intf = GtkGetIntf( GTK_WIDGET( button ) ); intf_thread_t *p_intf = GtkGetIntf( button );
GtkListStore *list; GtkListStore *p_list;
if (p_intf->p_sys->p_notebook) if (p_intf->p_sys->p_notebook)
{ {
gtk_widget_show( GTK_WIDGET(p_intf->p_sys->p_notebook) ); gtk_widget_show( GTK_WIDGET(p_intf->p_sys->p_notebook) );
gtk_notebook_set_page(p_intf->p_sys->p_notebook,0); gtk_notebook_set_page(p_intf->p_sys->p_notebook,0);
} }
if (p_intf->p_sys->p_mediabook)
{
gtk_widget_show( GTK_WIDGET(p_intf->p_sys->p_mediabook) );
gtk_notebook_set_page(p_intf->p_sys->p_mediabook,0);
}
gdk_window_raise( p_intf->p_sys->p_window->window ); gdk_window_raise( p_intf->p_sys->p_window->window );
if (p_intf->p_sys->p_tvfile) if (p_intf->p_sys->p_tvfile)
{ {
/* Get new directory listing */ /* Get new directory listing */
list = gtk_list_store_new (5, p_list = gtk_list_store_new (5,
G_TYPE_STRING, G_TYPE_STRING,
G_TYPE_STRING, G_TYPE_STRING,
G_TYPE_ULONG, G_TYPE_UINT64,
G_TYPE_STRING, G_TYPE_STRING,
G_TYPE_STRING); G_TYPE_STRING);
ReadDirectory(p_intf, list, "."); ReadDirectory(p_list, ".");
/* Update TreeView */ /* Update TreeView */
gtk_tree_view_set_model(p_intf->p_sys->p_tvfile, (GtkTreeModel*) list); gtk_tree_view_set_model(p_intf->p_sys->p_tvfile, (GtkTreeModel*) p_list);
g_object_unref(list); g_object_unref(p_list);
gtk_tree_selection_set_mode(gtk_tree_view_get_selection(GTK_TREE_VIEW(p_intf->p_sys->p_tvfile)),GTK_SELECTION_NONE);
} }
} }
...@@ -534,33 +518,33 @@ SliderPress (GtkWidget *widget, ...@@ -534,33 +518,33 @@ SliderPress (GtkWidget *widget,
return TRUE; return TRUE;
} }
gboolean addSelectedToPlaylist(GtkTreeModel *model, void addSelectedToPlaylist(GtkTreeModel *model,
GtkTreePath *path, GtkTreePath *path,
GtkTreeIter *iter, GtkTreeIter *iter,
gpointer *userdata) gpointer *userdata)
{ {
GtkTreeView *tvplaylist = NULL; GtkTreeView *p_tvplaylist = NULL;
GtkTreeModel *play_model;
GtkTreeIter play_iter;
gchar *filename; gchar *filename;
gtk_tree_model_get(model, iter, 0, &filename, -1); gtk_tree_model_get(model, iter, 0, &filename, -1);
g_print("selected %s\n", filename);
tvplaylist = (GtkTreeView *) lookup_widget( GTK_WIDGET(userdata), "tvPlaylist"); /* Add to playlist object. */
if (NULL != tvplaylist) p_tvplaylist = (GtkTreeView *) lookup_widget( GTK_WIDGET(userdata), "tvPlaylist");
if (p_tvplaylist)
{ {
play_model = gtk_tree_view_get_model(tvplaylist); GtkTreeModel *p_play_model;
GtkTreeIter p_play_iter;
p_play_model = gtk_tree_view_get_model(p_tvplaylist);
/* Add a new row to the playlist treeview model */ /* Add a new row to the playlist treeview model */
gtk_list_store_append (play_model, &play_iter); gtk_list_store_append (GTK_LIST_STORE(p_play_model), &p_play_iter);
gtk_list_store_set (play_model, &play_iter, gtk_list_store_set (GTK_LIST_STORE(p_play_model), &p_play_iter,
0, filename, /* Add path to it !!! */ 0, filename, /* Add path to it !!! */
1, "00:00:00", 1, "00:00:00",
-1 ); -1 );
/* do we need to unref ?? */ /* do we need to unref ?? */
} }
else else
// msg_Err(p_intf, "Error obtaining pointer to Play List");
g_print("Error obtaining pointer to Play List"); g_print("Error obtaining pointer to Play List");
} }
...@@ -571,8 +555,54 @@ onFileListRow (GtkTreeView *treeview, ...@@ -571,8 +555,54 @@ onFileListRow (GtkTreeView *treeview,
gpointer user_data) gpointer user_data)
{ {
GtkTreeSelection *selection = gtk_tree_view_get_selection(treeview); GtkTreeSelection *selection = gtk_tree_view_get_selection(treeview);
g_print("onFileListRow\n");
gtk_tree_selection_selected_foreach(selection, addSelectedToPlaylist, (gpointer) treeview); if (gtk_tree_selection_count_selected_rows(selection) == 1)
{
struct stat st;
GtkTreeModel *model;
GtkTreeIter iter;
gchar *filename;
/* This might be a directory selection */
model = gtk_tree_view_get_model(treeview);
if (!model)
g_print( "Error: model is a null pointer\n" );
if (!gtk_tree_model_get_iter(model, &iter, path))
g_print( "Error: could not get iter from model\n" );
gtk_tree_model_get(model, &iter, 0, &filename, -1);
if (stat((char*)filename, &st)==0)
{
if (S_ISDIR(st.st_mode))
{
GtkListStore *p_model = NULL;
/* Get new directory listing */
p_model = gtk_list_store_new (5,
G_TYPE_STRING,
G_TYPE_STRING,
G_TYPE_UINT64,
G_TYPE_STRING,
G_TYPE_STRING);
if (NULL == p_model)
g_print( "ERROR: model has a NULL pointer\n" );
ReadDirectory(p_model, filename);
/* Update TreeView with new model */
gtk_tree_view_set_model(treeview, (GtkTreeModel*) p_model);
g_object_unref(p_model);
}
else
{
gtk_tree_selection_selected_foreach(selection, (GtkTreeSelectionForeachFunc) &addSelectedToPlaylist, (gpointer) treeview);
}
}
}
else
{
gtk_tree_selection_selected_foreach(selection, (GtkTreeSelectionForeachFunc) &addSelectedToPlaylist, (gpointer) treeview);
}
} }
...@@ -600,7 +630,6 @@ onAddFileToPlaylist (GtkButton *button, ...@@ -600,7 +630,6 @@ onAddFileToPlaylist (GtkButton *button,
{ {
GtkTreeView *treeview = NULL; GtkTreeView *treeview = NULL;
g_print("onAddFileToPlaylist\n");
treeview = (GtkTreeView *) lookup_widget( GTK_WIDGET(button), "tvFileList"); treeview = (GtkTreeView *) lookup_widget( GTK_WIDGET(button), "tvFileList");
if (treeview) if (treeview)
{ {
...@@ -731,18 +760,18 @@ onAddNetworkPlaylist (GtkButton *button, ...@@ -731,18 +760,18 @@ onAddNetworkPlaylist (GtkButton *button,
p_mrl = (GtkEntry*) lookup_widget(GTK_WIDGET(button),"" ); p_mrl = (GtkEntry*) lookup_widget(GTK_WIDGET(button),"" );
if (NULL != p_mrl) if (NULL != p_mrl)
{ {
GtkTreeView *tvplaylist = NULL; GtkTreeView *p_tvplaylist = NULL;
GtkTreeModel *play_model; GtkTreeModel *p_play_model;
GtkTreeIter play_iter; GtkTreeIter p_play_iter;
gchar *name; gchar *name;
tvplaylist = (GtkTreeView *) lookup_widget( GTK_WIDGET(button), "tvPlaylist"); p_tvplaylist = (GtkTreeView *) lookup_widget( GTK_WIDGET(button), "tvPlaylist");
if (NULL != tvplaylist) if (p_tvplaylist)
{ {
play_model = gtk_tree_view_get_model(tvplaylist); p_play_model = gtk_tree_view_get_model(p_tvplaylist);
/* Add a new row to the playlist treeview model */ /* Add a new row to the playlist treeview model */
gtk_list_store_append (play_model, &play_iter); gtk_list_store_append (p_play_model, &p_play_iter);
gtk_list_store_set (play_model, &play_iter, gtk_list_store_set (p_play_model, &p_play_iter,
0, name, /* Add path to it !!! */ 0, name, /* Add path to it !!! */
1, "00:00:00", 1, "00:00:00",
-1 ); -1 );
......
...@@ -2,7 +2,7 @@ ...@@ -2,7 +2,7 @@
* callbacks.h : pda plugin for vlc * callbacks.h : pda plugin for vlc
***************************************************************************** *****************************************************************************
* Copyright (C) 2003 VideoLAN * Copyright (C) 2003 VideoLAN
* $Id: pda_callbacks.h,v 1.2 2003/11/07 09:24:58 jpsaman Exp $ * $Id: pda_callbacks.h,v 1.3 2003/11/07 13:01:51 jpsaman Exp $
* *
* Authors: Jean-Paul Saman <jpsaman@wxs.nl> * Authors: Jean-Paul Saman <jpsaman@wxs.nl>
* *
...@@ -26,7 +26,7 @@ ...@@ -26,7 +26,7 @@
#include <vlc/vlc.h> #include <vlc/vlc.h>
#include <vlc/intf.h> #include <vlc/intf.h>
void ReadDirectory( intf_thread_t *p_intf, GtkListStore *p_list, char *psz_dir ); void ReadDirectory( GtkListStore *p_list, char *psz_dir );
void MediaURLOpenChanged( GtkWidget *widget, gchar *psz_url ); void MediaURLOpenChanged( GtkWidget *widget, gchar *psz_url );
void PlaylistRebuildListStore( GtkListStore *p_list, playlist_t * p_playlist ); void PlaylistRebuildListStore( GtkListStore *p_list, playlist_t * p_playlist );
......
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