Commit 52b25baa authored by Jean-Paul Saman's avatar Jean-Paul Saman

PDA interface update:

* File tab is beginning to work
* Adding file to Playlist begins to work

Note: not very usefull yet.
parent fe3f88ca
...@@ -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.4 2003/10/03 18:04:58 jpsaman Exp $ * $Id: pda.c,v 1.5 2003/10/27 22:42:02 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>
...@@ -150,6 +150,7 @@ static void Run( intf_thread_t *p_intf ) ...@@ -150,6 +150,7 @@ static void Run( intf_thread_t *p_intf )
int i_dummy; int i_dummy;
#endif #endif
GtkCellRenderer *renderer = NULL; GtkCellRenderer *renderer = NULL;
GtkTreeViewColumn *column = NULL;
#ifdef HAVE_GPE_INIT_H #ifdef HAVE_GPE_INIT_H
/* Initialize GPE interface */ /* Initialize GPE interface */
...@@ -223,52 +224,79 @@ static void Run( intf_thread_t *p_intf ) ...@@ -223,52 +224,79 @@ static void Run( intf_thread_t *p_intf )
msg_Dbg( p_intf, "setting slider adjustment ... done" ); msg_Dbg( p_intf, "setting slider adjustment ... done" );
#endif #endif
/* Get the GtkTreeView filelist object */ /* BEGIN OF FILEVIEW GTK_TREE_VIEW */
msg_Dbg(p_intf, "Getting GtkTreeView FileList" ); msg_Dbg(p_intf, "Getting GtkTreeView FileList" );
p_intf->p_sys->p_tvfile = NULL; p_intf->p_sys->p_tvfile = NULL;
p_intf->p_sys->p_tvfile = (GtkTreeView *) lookup_widget( p_intf->p_sys->p_window, p_intf->p_sys->p_tvfile = (GtkTreeView *) lookup_widget( p_intf->p_sys->p_window,
"tvFileList"); "tvFileList");
if (NULL == p_intf->p_sys->p_tvfile) if (NULL == p_intf->p_sys->p_tvfile)
msg_Err(p_intf, "Error obtaining pointer to File List"); msg_Err(p_intf, "Error obtaining pointer to File List");
/* Get new directory listing */
msg_Dbg(p_intf, "Populating GtkTreeView FileList" ); /* Insert columns 0 */
p_intf->p_sys->p_filelist = gtk_list_store_new (5,
G_TYPE_STRING, /* Filename */
G_TYPE_STRING, /* permissions */
G_TYPE_STRING, /* File size */
G_TYPE_STRING, /* Owner */
G_TYPE_STRING);/* Group */
ReadDirectory(p_intf, p_intf->p_sys->p_filelist, ".");
msg_Dbg(p_intf, "Showing GtkTreeView FileList" );
gtk_tree_view_set_model(p_intf->p_sys->p_tvfile, GTK_TREE_MODEL(p_intf->p_sys->p_filelist));
/* Insert columns */
renderer = gtk_cell_renderer_text_new (); renderer = gtk_cell_renderer_text_new ();
gtk_tree_view_insert_column_with_attributes(p_intf->p_sys->p_tvfile, 0, _("Filename"), renderer, NULL); gtk_tree_view_insert_column_with_attributes(p_intf->p_sys->p_tvfile, 0, _("Filename"), renderer, NULL);
column = gtk_tree_view_get_column(p_intf->p_sys->p_tvfile, 0 );
gtk_tree_view_column_add_attribute(column, renderer, "text", 0 );
/* Insert columns 1 */
renderer = gtk_cell_renderer_text_new (); renderer = gtk_cell_renderer_text_new ();
gtk_tree_view_insert_column_with_attributes(p_intf->p_sys->p_tvfile, 1, _("Permissions"), renderer, NULL); gtk_tree_view_insert_column_with_attributes(p_intf->p_sys->p_tvfile, 1, _("Permissions"), renderer, NULL);
column = gtk_tree_view_get_column(p_intf->p_sys->p_tvfile, 1 );
gtk_tree_view_column_add_attribute(column, renderer, "text", 1 );
/* Insert columns 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_tvfile, 2, _("Size"), renderer, NULL); gtk_tree_view_insert_column_with_attributes(p_intf->p_sys->p_tvfile, 2, _("Size"), renderer, NULL);
column = gtk_tree_view_get_column(p_intf->p_sys->p_tvfile, 2 );
gtk_tree_view_column_add_attribute(column, renderer, "text", 2 );
/* Insert columns 3 */
renderer = gtk_cell_renderer_text_new (); renderer = gtk_cell_renderer_text_new ();
gtk_tree_view_insert_column_with_attributes(p_intf->p_sys->p_tvfile, 3, _("Owner"), renderer, NULL); gtk_tree_view_insert_column_with_attributes(p_intf->p_sys->p_tvfile, 3, _("Owner"), renderer, NULL);
column = gtk_tree_view_get_column(p_intf->p_sys->p_tvfile, 3 );
gtk_tree_view_column_add_attribute(column, renderer, "text", 3 );
/* Insert columns 4 */
renderer = gtk_cell_renderer_text_new (); renderer = gtk_cell_renderer_text_new ();
gtk_tree_view_insert_column_with_attributes(p_intf->p_sys->p_tvfile, 4, _("Group"), renderer, NULL); gtk_tree_view_insert_column_with_attributes(p_intf->p_sys->p_tvfile, 4, _("Group"), renderer, NULL);
column = gtk_tree_view_get_column(p_intf->p_sys->p_tvfile, 4 );
gtk_tree_view_column_add_attribute(column, renderer, "text", 4 );
/* Get new directory listing */
msg_Dbg(p_intf, "Populating GtkTreeView FileList" );
p_intf->p_sys->p_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, ".");
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_selection_set_mode(gtk_tree_view_get_selection(GTK_TREE_VIEW(p_intf->p_sys->p_tvfile)),GTK_SELECTION_MULTIPLE);
/* Column properties */ /* Column properties */
gtk_tree_view_set_headers_visible(p_intf->p_sys->p_tvfile, TRUE); gtk_tree_view_set_headers_visible(p_intf->p_sys->p_tvfile, TRUE);
gtk_tree_view_columns_autosize(p_intf->p_sys->p_tvfile); gtk_tree_view_columns_autosize(p_intf->p_sys->p_tvfile);
gtk_tree_view_set_headers_clickable(p_intf->p_sys->p_tvfile,TRUE); gtk_tree_view_set_headers_clickable(GTK_TREE_VIEW(p_intf->p_sys->p_tvfile),TRUE);
/* END OF FILEVIEW GTK_TREE_VIEW */
/* Get the GtkTreeView playlist object */ /* BEGIN OF PLAYLIST GTK_TREE_VIEW */
msg_Dbg(p_intf, "Getting GtkTreeView PlayList" ); msg_Dbg(p_intf, "Getting GtkTreeView PlayList" );
p_intf->p_sys->p_tvplaylist = NULL; p_intf->p_sys->p_tvplaylist = NULL;
p_intf->p_sys->p_tvplaylist = (GtkTreeView *) lookup_widget( p_intf->p_sys->p_window, p_intf->p_sys->p_tvplaylist = (GtkTreeView *) lookup_widget( p_intf->p_sys->p_window,
"tvPlaylist"); "tvPlaylist");
if (NULL == p_intf->p_sys->p_tvplaylist) if (NULL == p_intf->p_sys->p_tvplaylist)
msg_Err(p_intf, "Error obtaining pointer to Play List"); msg_Err(p_intf, "Error obtaining pointer to Play List");
/* Insert columns */
/* Columns 1 */
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, 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 );
gtk_tree_view_column_add_attribute(column, renderer, "text", 0 );
/* 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 );
gtk_tree_view_column_add_attribute(column, renderer, "text", 1 );
/* update the playlist */ /* update the playlist */
msg_Dbg(p_intf, "Populating GtkTreeView Playlist" ); msg_Dbg(p_intf, "Populating GtkTreeView Playlist" );
p_intf->p_sys->p_playlist = gtk_list_store_new (2, p_intf->p_sys->p_playlist = gtk_list_store_new (2,
...@@ -276,12 +304,17 @@ static void Run( intf_thread_t *p_intf ) ...@@ -276,12 +304,17 @@ static void Run( intf_thread_t *p_intf )
G_TYPE_STRING);/* Time */ G_TYPE_STRING);/* Time */
PlaylistRebuildListStore( p_intf->p_sys->p_playlist, vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE )); PlaylistRebuildListStore( p_intf->p_sys->p_playlist, vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE ));
msg_Dbg(p_intf, "Showing GtkTreeView Playlist" ); msg_Dbg(p_intf, "Showing GtkTreeView Playlist" );
gtk_tree_view_set_model(p_intf->p_sys->p_tvplaylist, GTK_TREE_MODEL(p_intf->p_sys->p_playlist)); gtk_tree_view_set_model(GTK_TREE_VIEW(p_intf->p_sys->p_tvplaylist), GTK_TREE_MODEL(p_intf->p_sys->p_playlist));
g_object_unref(p_intf->p_sys->p_playlist);
gtk_tree_selection_set_mode(gtk_tree_view_get_selection(GTK_TREE_VIEW(p_intf->p_sys->p_tvplaylist)),GTK_SELECTION_MULTIPLE);
/* Column properties */ /* Column properties */
gtk_tree_view_set_headers_visible(p_intf->p_sys->p_tvplaylist, TRUE); gtk_tree_view_set_headers_visible(p_intf->p_sys->p_tvplaylist, TRUE);
gtk_tree_view_columns_autosize(p_intf->p_sys->p_tvplaylist); gtk_tree_view_columns_autosize(p_intf->p_sys->p_tvplaylist);
gtk_tree_view_set_headers_clickable(p_intf->p_sys->p_tvplaylist, TRUE); gtk_tree_view_set_headers_clickable(p_intf->p_sys->p_tvplaylist, TRUE);
/* END OF PLAYLIST GTK_TREE_VIEW */
/* Save MRL entry object */
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" ) );
......
...@@ -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.1 2003/10/01 20:58:45 jpsaman Exp $ * $Id: pda_callbacks.c,v 1.2 2003/10/27 22:42:02 jpsaman Exp $
* *
* Authors: Jean-Paul Saman <jpsaman@wxs.nl> * Authors: Jean-Paul Saman <jpsaman@wxs.nl>
* *
...@@ -47,7 +47,7 @@ ...@@ -47,7 +47,7 @@
#include "pda_support.h" #include "pda_support.h"
#include "pda.h" #include "pda.h"
static char* get_file_perm(const char *path); static char* get_file_stat(const char *path, uid_t *uid, gid_t *gid, off_t *size);
/***************************************************************************** /*****************************************************************************
* Useful function to retrieve p_intf * Useful function to retrieve p_intf
...@@ -173,13 +173,16 @@ void ReadDirectory( intf_thread_t *p_intf, GtkListStore *p_list, char *psz_dir ) ...@@ -173,13 +173,16 @@ void ReadDirectory( intf_thread_t *p_intf, GtkListStore *p_list, char *psz_dir )
else else
{ {
int i; int i;
uint32_t uid;
uint32_t gid;
off_t size;
gchar *ppsz_text[5]; gchar *ppsz_text[5];
msg_Dbg( p_intf, "updating interface" ); 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_perm(".."); ppsz_text[1] = get_file_stat("..", &uid, &gid, &size);
ppsz_text[2] = ""; ppsz_text[2] = "";
ppsz_text[3] = ""; ppsz_text[3] = "";
ppsz_text[4] = ""; ppsz_text[4] = "";
...@@ -189,11 +192,13 @@ void ReadDirectory( intf_thread_t *p_intf, GtkListStore *p_list, char *psz_dir ) ...@@ -189,11 +192,13 @@ void ReadDirectory( intf_thread_t *p_intf, GtkListStore *p_list, char *psz_dir )
gtk_list_store_set (p_list, &iter, gtk_list_store_set (p_list, &iter,
0, ppsz_text[0], 0, ppsz_text[0],
1, ppsz_text[1], 1, ppsz_text[1],
2, ppsz_text[2], 2, size,
3, ppsz_text[3], 3, ppsz_text[3],
4, ppsz_text[4], 4, ppsz_text[4],
-1); -1);
if (ppsz_text[1]) free(ppsz_text[1]);
/* kludge */ /* kludge */
for (i=0; i<n; i++) for (i=0; i<n; i++)
{ {
...@@ -201,20 +206,22 @@ void ReadDirectory( intf_thread_t *p_intf, GtkListStore *p_list, char *psz_dir ) ...@@ -201,20 +206,22 @@ void ReadDirectory( intf_thread_t *p_intf, GtkListStore *p_list, char *psz_dir )
{ {
/* This is a list of strings. */ /* This is a list of strings. */
ppsz_text[0] = namelist[i]->d_name; ppsz_text[0] = namelist[i]->d_name;
ppsz_text[1] = get_file_perm(namelist[i]->d_name); ppsz_text[1] = get_file_stat(namelist[i]->d_name, &uid, &gid, &size);
ppsz_text[2] = ""; ppsz_text[2] = "";
ppsz_text[3] = ""; ppsz_text[3] = "";
ppsz_text[4] = ""; ppsz_text[4] = "";
msg_Dbg(p_intf, "(%d) file: %s permission: %s", i, ppsz_text[0], ppsz_text[1] ); // 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 );
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],
1, ppsz_text[1], 1, ppsz_text[1],
2, ppsz_text[2], 2, size,
3, ppsz_text[3], 3, ppsz_text[3],
4, ppsz_text[4], 4, ppsz_text[4],
-1); -1);
if (ppsz_text[1]) free(ppsz_text[1]);
} }
} }
free(namelist); free(namelist);
...@@ -228,7 +235,7 @@ void ReadDirectory( intf_thread_t *p_intf, GtkListStore *p_list, char *psz_dir ) ...@@ -228,7 +235,7 @@ void ReadDirectory( intf_thread_t *p_intf, GtkListStore *p_list, char *psz_dir )
} }
} }
static char* get_file_perm(const char *path) static char* get_file_stat(const char *path, uid_t *uid, gid_t *gid, off_t *size)
{ {
struct stat st; struct stat st;
char *perm; char *perm;
...@@ -237,6 +244,11 @@ static char* get_file_perm(const char *path) ...@@ -237,6 +244,11 @@ static char* get_file_perm(const char *path)
strncpy( perm, "----------", sizeof("----------")); strncpy( perm, "----------", sizeof("----------"));
if (lstat(path, &st)==0) if (lstat(path, &st)==0)
{ {
/* user, group, filesize */
*uid = st.st_uid;
*gid = st.st_gid;
*size = st.st_size;
/* determine permission modes */
if (S_ISLNK(st.st_mode)) if (S_ISLNK(st.st_mode))
perm[0]= 'l'; perm[0]= 'l';
else if (S_ISDIR(st.st_mode)) else if (S_ISDIR(st.st_mode))
...@@ -312,9 +324,11 @@ onPDADeleteEvent (GtkWidget *widget, ...@@ -312,9 +324,11 @@ onPDADeleteEvent (GtkWidget *widget,
{ {
intf_thread_t *p_intf = GtkGetIntf( widget ); intf_thread_t *p_intf = GtkGetIntf( widget );
msg_Dbg( p_intf, "about to exit vlc ... " );
vlc_mutex_lock( &p_intf->change_lock ); vlc_mutex_lock( &p_intf->change_lock );
p_intf->p_vlc->b_die = VLC_TRUE; p_intf->p_vlc->b_die = VLC_TRUE;
vlc_mutex_unlock( &p_intf->change_lock ); vlc_mutex_unlock( &p_intf->change_lock );
msg_Dbg( p_intf, "about to exit vlc ... signalled" );
return TRUE; return TRUE;
} }
...@@ -344,13 +358,15 @@ onFileOpen (GtkButton *button, ...@@ -344,13 +358,15 @@ onFileOpen (GtkButton *button,
list = gtk_list_store_new (5, list = gtk_list_store_new (5,
G_TYPE_STRING, G_TYPE_STRING,
G_TYPE_STRING, G_TYPE_STRING,
G_TYPE_STRING, G_TYPE_ULONG,
G_TYPE_STRING, G_TYPE_STRING,
G_TYPE_STRING); G_TYPE_STRING);
ReadDirectory(p_intf, list, "."); ReadDirectory(p_intf, 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*) 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);
} }
} }
...@@ -518,6 +534,37 @@ SliderPress (GtkWidget *widget, ...@@ -518,6 +534,37 @@ SliderPress (GtkWidget *widget,
return TRUE; return TRUE;
} }
gboolean addSelectedToPlaylist(GtkTreeModel *model,
GtkTreePath *path,
GtkTreeIter *iter,
gpointer *userdata)
{
GtkTreeView *tvplaylist = NULL;
GtkTreeModel *play_model;
GtkTreeIter play_iter;
gchar *filename;
gtk_tree_model_get(model, iter, 0, &filename, -1);
g_print("selected %s\n", filename);
#if 1
tvplaylist = (GtkTreeView *) lookup_widget( GTK_WIDGET(userdata), "tvPlaylist");
if (NULL != tvplaylist)
{
play_model = gtk_tree_view_get_model(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,
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");
#endif
}
void void
onFileListRow (GtkTreeView *treeview, onFileListRow (GtkTreeView *treeview,
...@@ -525,7 +572,9 @@ onFileListRow (GtkTreeView *treeview, ...@@ -525,7 +572,9 @@ onFileListRow (GtkTreeView *treeview,
GtkTreeViewColumn *column, GtkTreeViewColumn *column,
gpointer user_data) gpointer user_data)
{ {
GtkTreeSelection *selection = gtk_tree_view_get_selection(treeview);
g_print("onFileListRow\n"); g_print("onFileListRow\n");
gtk_tree_selection_selected_foreach(selection, addSelectedToPlaylist, (gpointer) treeview);
} }
......
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