Commit 9b889a6a authored by Jean-Paul Saman's avatar Jean-Paul Saman

PDA Interface:

- Code cleanup and fixes for file view widget.
parent ca9786f7
...@@ -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.9 2003/11/18 20:36:40 jpsaman Exp $ * $Id: pda.c,v 1.10 2003/11/21 09:23:49 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>
...@@ -177,6 +177,12 @@ static void Run( intf_thread_t *p_intf ) ...@@ -177,6 +177,12 @@ static void Run( intf_thread_t *p_intf )
msg_Err( p_intf, "unable to create pda interface" ); msg_Err( p_intf, "unable to create pda interface" );
} }
/* 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 );
msg_Dbg( p_intf, "trying to store p_intf pointer ... done" );
/* Set the title of the main window */ /* Set the title of the main window */
gtk_window_set_title( GTK_WINDOW(p_intf->p_sys->p_window), gtk_window_set_title( GTK_WINDOW(p_intf->p_sys->p_window),
VOUT_TITLE " (PDA Linux interface)"); VOUT_TITLE " (PDA Linux interface)");
...@@ -302,12 +308,6 @@ static void Run( intf_thread_t *p_intf ) ...@@ -302,12 +308,6 @@ static void Run( intf_thread_t *p_intf )
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 */ /* END OF PLAYLIST GTK_TREE_VIEW */
/* 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 );
msg_Dbg( p_intf, "trying to store p_intf pointer ... done" );
/* 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 );
......
...@@ -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.14 2003/11/18 20:36:40 jpsaman Exp $ * $Id: pda_callbacks.c,v 1.15 2003/11/21 09:23:49 jpsaman Exp $
* *
* Authors: Jean-Paul Saman <jpsaman@wxs.nl> * Authors: Jean-Paul Saman <jpsaman@wxs.nl>
* *
...@@ -51,7 +51,7 @@ ...@@ -51,7 +51,7 @@
#define VLC_MAX_MRL 256 #define VLC_MAX_MRL 256
static char *get_file_stat(const char *path, off_t *size); static char *get_file_perms(struct stat st);
/***************************************************************************** /*****************************************************************************
* Useful function to retrieve p_intf * Useful function to retrieve p_intf
...@@ -176,6 +176,9 @@ void ReadDirectory(intf_thread_t *p_intf, GtkListStore *p_list, char *psz_dir ) ...@@ -176,6 +176,9 @@ void ReadDirectory(intf_thread_t *p_intf, GtkListStore *p_list, char *psz_dir )
{ {
GtkTreeIter iter; GtkTreeIter iter;
struct dirent **namelist; struct dirent **namelist;
struct passwd *pw;
struct group *grp;
struct stat st;
int n=-1, status=-1; int n=-1, status=-1;
msg_Dbg(p_intf, "Changing to dir %s", psz_dir); msg_Dbg(p_intf, "Changing to dir %s", psz_dir);
...@@ -192,45 +195,55 @@ void ReadDirectory(intf_thread_t *p_intf, GtkListStore *p_list, char *psz_dir ) ...@@ -192,45 +195,55 @@ void ReadDirectory(intf_thread_t *p_intf, GtkListStore *p_list, char *psz_dir )
else else
{ {
int i; int i;
off_t size;
gchar *ppsz_text[4]; gchar *ppsz_text[4];
if (lstat("..", &st)==0)
{
/* user, group */
pw = getpwuid(st.st_uid);
grp = getgrgid(st.st_gid);
/* XXX : kludge temporaire pour yopy */ /* XXX : kludge temporaire pour yopy */
ppsz_text[0] = ".."; ppsz_text[0] = "..";
ppsz_text[1] = get_file_stat("..", &size); ppsz_text[1] = get_file_perms(st);
ppsz_text[2] = "?"; ppsz_text[2] = pw->pw_name;
ppsz_text[3] = "?"; ppsz_text[3] = grp->gr_name;
/* Add a new row to the model */ /* Add a new row to the model */
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, size, 2, st.st_size,
3, ppsz_text[2], 3, ppsz_text[2],
4, ppsz_text[3], 4, ppsz_text[3],
-1); -1);
if (ppsz_text[1]) free(ppsz_text[1]); if (ppsz_text[1]) free(ppsz_text[1]);
}
/* kludge */ /* kludge */
for (i=0; i<n; i++) for (i=0; i<n; i++)
{ {
if (namelist[i]->d_name[0] != '.') if ((namelist[i]->d_name[0] != '.') &&
(lstat(namelist[i]->d_name, &st)==0))
{ {
/* user, group */
pw = getpwuid(st.st_uid);
grp = getgrgid(st.st_gid);
/* 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_stat(namelist[i]->d_name, &size); ppsz_text[1] = get_file_perms(st);
ppsz_text[2] = "?"; ppsz_text[2] = pw->pw_name;
ppsz_text[3] = "?"; ppsz_text[3] = grp->gr_name;
#if 1 #if 0
msg_Dbg(p_intf, "(%d) file: %s permission: %s user: %s group: %s size: %ull", i, ppsz_text[0], ppsz_text[1], ppsz_text[2], ppsz_text[3], (unsigned long long) size ); msg_Dbg(p_intf, "(%d) file: %s permission: %s user: %s group: %s", i, ppsz_text[0], ppsz_text[1], ppsz_text[2], ppsz_text[3] );
#endif #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],
1, ppsz_text[1], 1, ppsz_text[1],
2, size, 2, st.st_size,
3, ppsz_text[2], 3, ppsz_text[2],
4, ppsz_text[3], 4, ppsz_text[3],
-1); -1);
...@@ -242,18 +255,13 @@ void ReadDirectory(intf_thread_t *p_intf, GtkListStore *p_list, char *psz_dir ) ...@@ -242,18 +255,13 @@ void ReadDirectory(intf_thread_t *p_intf, GtkListStore *p_list, char *psz_dir )
} }
} }
static char *get_file_stat(const char *path, off_t *size) static char *get_file_perms(const struct stat st)
{ {
struct passwd *pw = NULL;
struct group *grp = NULL;
struct stat st;
char *perm; char *perm;
int ret = -1;
perm = (char *) malloc(sizeof(char)*10); perm = (char *) malloc(sizeof(char)*10);
strncpy( perm, "----------", sizeof("----------")); strncpy( perm, "----------", sizeof("----------"));
if (lstat(path, &st)==0)
{
/* determine permission modes */ /* determine permission modes */
if (S_ISLNK(st.st_mode)) if (S_ISLNK(st.st_mode))
perm[0]= 'l'; perm[0]= 'l';
...@@ -316,24 +324,6 @@ static char *get_file_stat(const char *path, off_t *size) ...@@ -316,24 +324,6 @@ static char *get_file_stat(const char *path, off_t *size)
else if (st.st_mode &S_ISVTX) else if (st.st_mode &S_ISVTX)
perm[9]= 'T'; perm[9]= 'T';
#if 0
*permission = perm;
/* user, group, filesize */
pw = getpwuid(st.st_uid);
grp = getgrgid(st.st_gid);
if (NULL == pw)
return -1;
*uid = (char*) malloc( sizeof(char) * strlen(pw->pw_name) );
strcpy(path[2],pw->pw_name);
if (NULL == grp)
return -1;
*gid = (char*) malloc( sizeof(char) * strlen(grp->gr_name) );
strcpy(path[3], grp->gr_name);
#endif
*size = st.st_size;
ret = 0;
}
return perm; return perm;
} }
......
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