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 @@
* callbacks.c : Callbacks for the pda Linux Gtk+ plugin.
*****************************************************************************
* 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>
*
......
......@@ -2,7 +2,7 @@
* pda.c : PDA Gtk2 plugin for vlc
*****************************************************************************
* 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>
* Marc Ariberti <marcari@videolan.org>
......@@ -147,14 +147,15 @@ static void Run( intf_thread_t *p_intf )
#endif
GtkCellRenderer *renderer = NULL;
GtkTreeViewColumn *column = NULL;
GtkListStore *filelist = NULL;
gtk_set_locale ();
#ifndef NEED_GTK2_MAIN
gtk_set_locale ();
msg_Dbg( p_intf, "Starting pda GTK2+ interface" );
gtk_init( &i_args, &pp_args );
#else
/* Initialize Gtk+ */
msg_Dbg( p_intf, "Starting pda GTK+ interface thread" );
msg_Dbg( p_intf, "Starting pda GTK2+ interface thread" );
gdk_threads_enter();
#endif
......@@ -182,8 +183,6 @@ static void Run( intf_thread_t *p_intf )
/* Get the notebook object */
p_intf->p_sys->p_notebook = GTK_NOTEBOOK( gtk_object_get_data(
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 */
p_intf->p_sys->p_slider = GTK_HSCALE( gtk_object_get_data(
......@@ -247,16 +246,16 @@ static void Run( intf_thread_t *p_intf )
/* Get new directory listing */
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, /* permissions */
G_TYPE_UINT64, /* File size */
G_TYPE_STRING, /* Owner */
G_TYPE_STRING);/* Group */
ReadDirectory(p_intf, p_intf->p_sys->p_filelist, ".");
ReadDirectory(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));
g_object_unref(p_intf->p_sys->p_filelist); /* Model will be released by GtkTreeView */
gtk_tree_view_set_model(GTK_TREE_VIEW(p_intf->p_sys->p_tvfile), GTK_TREE_MODEL(filelist));
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);
/* Column properties */
......@@ -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);
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_set_sort_column_id(column, 0);
/* Column 2 */
renderer = gtk_cell_renderer_text_new ();
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 );
gtk_tree_view_column_add_attribute(column, renderer, "text", 1 );
gtk_tree_view_column_set_sort_column_id(column, 1);
/* update the playlist */
msg_Dbg(p_intf, "Populating GtkTreeView Playlist" );
......@@ -305,15 +306,11 @@ static void Run( intf_thread_t *p_intf )
p_intf->p_sys->p_mrlentry = GTK_ENTRY( gtk_object_get_data(
GTK_OBJECT( p_intf->p_sys->p_window ), "mrl_entry" ) );
#if 0
/* Store p_intf to keep an eye on it */
msg_Dbg( p_intf, "trying to store p_intf pointer ... " );
gtk_object_set_data( GTK_OBJECT(p_intf->p_sys->p_window),
"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" );
#endif
/* Show the control window */
gtk_widget_show( p_intf->p_sys->p_window );
......
......@@ -31,45 +31,6 @@
<property name="toolbar_style">GTK_TOOLBAR_ICONS</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>
<widget class="button" id="tbRewind">
<property name="width_request">22</property>
......@@ -157,7 +118,7 @@
<child>
<widget class="GtkLabel" id="timeLabel">
<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_markup">False</property>
<property name="justify">GTK_JUSTIFY_CENTER</property>
......
......@@ -2,7 +2,7 @@
* pda.h: private Gtk+ interface description
*****************************************************************************
* 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>
*
......@@ -35,11 +35,9 @@ struct intf_sys_t
GtkWidget *p_window; /* main window */
GtkEntry *p_mrlentry;
GtkNotebook *p_notebook;
GtkNotebook *p_mediabook;
GtkHScale *p_slider;
GtkTreeView *p_tvfile;
GtkTreeView *p_tvplaylist;
GtkListStore *p_filelist; /* File list widget */
GtkListStore *p_playlist; /* Playlist widget */
/* slider */
......
......@@ -2,7 +2,7 @@
* pda_callbacks.c : Callbacks for the pda Linux Gtk+ plugin.
*****************************************************************************
* 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>
*
......@@ -103,7 +103,6 @@ void PlaylistRebuildListStore( GtkListStore * p_list, playlist_t * p_playlist )
0, ppsz_text[0],
1, ppsz_text[1],
-1);
}
vlc_mutex_unlock( &p_playlist->object_lock );
}
......@@ -115,9 +114,8 @@ void MediaURLOpenChanged( GtkWidget *widget, gchar *psz_url )
{
intf_thread_t *p_intf = GtkGetIntf( widget );
playlist_t *p_playlist;
GtkListStore *p_liststore;
GtkTreeView *p_tvplaylist;
// Add p_url to playlist .... but how ?
p_playlist = (playlist_t *)
vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
......@@ -139,32 +137,32 @@ void MediaURLOpenChanged( GtkWidget *widget, gchar *psz_url )
PLAYLIST_APPEND, PLAYLIST_END );
}
vlc_object_release( p_playlist );
msg_Dbg(p_intf, "MediaURLOpenChange: Populating GtkTreeView Playlist" );
p_liststore = gtk_list_store_new (2,
G_TYPE_STRING,
G_TYPE_STRING);
p_tvplaylist = (GtkTreeView*) lookup_widget( GTK_WIDGET(widget), "tvPlaylist" );
if (p_tvplaylist)
{
GtkListStore *p_liststore;
p_liststore = (GtkListStore *) gtk_tree_view_get_model(p_tvplaylist);
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.
****************************************************************/
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;
struct dirent **namelist;
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)
{
status = chdir(psz_dir);
if (status<0)
msg_Err( p_intf, "permision denied" );
g_print( "permision denied\n" );
}
n = scandir(".", &namelist, 0, alphasort);
......@@ -178,8 +176,6 @@ void ReadDirectory( intf_thread_t *p_intf, GtkListStore *p_list, char *psz_dir )
off_t size;
gchar *ppsz_text[5];
msg_Dbg( p_intf, "updating interface" );
/* XXX : kludge temporaire pour yopy */
ppsz_text[0]="..";
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 )
ppsz_text[2] = "";
ppsz_text[3] = "";
ppsz_text[4] = "";
// 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 );
#if 0
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_set (p_list, &iter,
0, ppsz_text[0],
......@@ -226,13 +223,6 @@ void ReadDirectory( intf_thread_t *p_intf, GtkListStore *p_list, char *psz_dir )
}
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)
......@@ -338,35 +328,29 @@ void
onFileOpen (GtkButton *button,
gpointer user_data)
{
intf_thread_t *p_intf = GtkGetIntf( GTK_WIDGET( button ) );
GtkListStore *list;
intf_thread_t *p_intf = GtkGetIntf( button );
GtkListStore *p_list;
if (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);
}
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 );
if (p_intf->p_sys->p_tvfile)
{
/* 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_ULONG,
G_TYPE_UINT64,
G_TYPE_STRING,
G_TYPE_STRING);
ReadDirectory(p_intf, list, ".");
ReadDirectory(p_list, ".");
/* Update TreeView */
gtk_tree_view_set_model(p_intf->p_sys->p_tvfile, (GtkTreeModel*) list);
g_object_unref(list);
gtk_tree_selection_set_mode(gtk_tree_view_get_selection(GTK_TREE_VIEW(p_intf->p_sys->p_tvfile)),GTK_SELECTION_NONE);
gtk_tree_view_set_model(p_intf->p_sys->p_tvfile, (GtkTreeModel*) p_list);
g_object_unref(p_list);
}
}
......@@ -534,33 +518,33 @@ SliderPress (GtkWidget *widget,
return TRUE;
}
gboolean addSelectedToPlaylist(GtkTreeModel *model,
void addSelectedToPlaylist(GtkTreeModel *model,
GtkTreePath *path,
GtkTreeIter *iter,
gpointer *userdata)
{
GtkTreeView *tvplaylist = NULL;
GtkTreeModel *play_model;
GtkTreeIter play_iter;
GtkTreeView *p_tvplaylist = NULL;
gchar *filename;
gtk_tree_model_get(model, iter, 0, &filename, -1);
g_print("selected %s\n", filename);
tvplaylist = (GtkTreeView *) lookup_widget( GTK_WIDGET(userdata), "tvPlaylist");
if (NULL != tvplaylist)
/* Add to playlist object. */
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 */
gtk_list_store_append (play_model, &play_iter);
gtk_list_store_set (play_model, &play_iter,
gtk_list_store_append (GTK_LIST_STORE(p_play_model), &p_play_iter);
gtk_list_store_set (GTK_LIST_STORE(p_play_model), &p_play_iter,
0, filename, /* Add path to it !!! */
1, "00:00:00",
-1 );
/* do we need to unref ?? */
}
else
// msg_Err(p_intf, "Error obtaining pointer to Play List");
g_print("Error obtaining pointer to Play List");
}
......@@ -571,8 +555,54 @@ onFileListRow (GtkTreeView *treeview,
gpointer user_data)
{
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,
{
GtkTreeView *treeview = NULL;
g_print("onAddFileToPlaylist\n");
treeview = (GtkTreeView *) lookup_widget( GTK_WIDGET(button), "tvFileList");
if (treeview)
{
......@@ -731,18 +760,18 @@ onAddNetworkPlaylist (GtkButton *button,
p_mrl = (GtkEntry*) lookup_widget(GTK_WIDGET(button),"" );
if (NULL != p_mrl)
{
GtkTreeView *tvplaylist = NULL;
GtkTreeModel *play_model;
GtkTreeIter play_iter;
GtkTreeView *p_tvplaylist = NULL;
GtkTreeModel *p_play_model;
GtkTreeIter p_play_iter;
gchar *name;
tvplaylist = (GtkTreeView *) lookup_widget( GTK_WIDGET(button), "tvPlaylist");
if (NULL != tvplaylist)
p_tvplaylist = (GtkTreeView *) lookup_widget( GTK_WIDGET(button), "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 */
gtk_list_store_append (play_model, &play_iter);
gtk_list_store_set (play_model, &play_iter,
gtk_list_store_append (p_play_model, &p_play_iter);
gtk_list_store_set (p_play_model, &p_play_iter,
0, name, /* Add path to it !!! */
1, "00:00:00",
-1 );
......
......@@ -2,7 +2,7 @@
* callbacks.h : pda plugin for vlc
*****************************************************************************
* 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>
*
......@@ -26,7 +26,7 @@
#include <vlc/vlc.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 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