Commit d377635a authored by Jean-Paul Saman's avatar Jean-Paul Saman

- File and directory listing show unix permissions.

parent a444052d
......@@ -2,7 +2,7 @@
* callbacks.c : Callbacks for the Familiar Linux Gtk+ plugin.
*****************************************************************************
* Copyright (C) 2000, 2001 VideoLAN
* $Id: callbacks.c,v 1.5 2002/08/17 13:33:00 jpsaman Exp $
* $Id: callbacks.c,v 1.6 2002/08/18 20:36:04 jpsaman Exp $
*
* Authors: Jean-Paul Saman <jpsaman@wxs.nl>
*
......@@ -51,8 +51,7 @@
/*#include "netutils.h"*/
static void MediaURLOpenChanged( GtkWidget *widget, gchar *psz_url );
static void PreferencesURLOpenChanged( GtkEditable *editable, gpointer user_data );
static char* get_file_type(const char *path);
static char* get_file_perm(const char *path);
/*****************************************************************************
* Useful function to retrieve p_intf
......@@ -112,26 +111,17 @@ static void MediaURLOpenChanged( GtkWidget *widget, gchar *psz_url )
}
}
static void PreferencesURLOpenChanged( GtkEditable *editable, gpointer user_data )
{
gchar * p_url;
p_url = gtk_entry_get_text(GTK_ENTRY(editable) );
g_print( "%s\n",p_url );
}
/*****************************************************************
* Read directory helper function.
****************************************************************/
void ReadDirectory( GtkCList *clist, char *psz_dir)
void ReadDirectory( GtkCList *clist, char *psz_dir )
{
intf_thread_t *p_intf = GtkGetIntf( clist );
struct dirent **namelist;
int n,i;
if (psz_dir)
n = scandir(psz_dir, &namelist, 0, NULL);
else
chdir(psz_dir);
n = scandir(".", &namelist, 0, NULL);
if (n<0)
......@@ -147,7 +137,7 @@ void ReadDirectory( GtkCList *clist, char *psz_dir)
{
/* This is a list of strings. */
ppsz_text[0] = namelist[i]->d_name;
ppsz_text[1] = get_file_type(namelist[i]->d_name);
ppsz_text[1] = get_file_perm(namelist[i]->d_name);
if (strcmp(ppsz_text[1],"") == 0)
msg_Err( p_intf->p_sys->p_input, "File system error unknown filetype encountered.");
gtk_clist_insert( clist, i, ppsz_text );
......@@ -158,30 +148,77 @@ void ReadDirectory( GtkCList *clist, char *psz_dir)
}
}
static char* get_file_type(const char *path)
static char* get_file_perm(const char *path)
{
struct stat st;
char *perm;
perm = (char *) malloc(sizeof(char)*10);
strncpy( perm, "----------", sizeof("----------"));
if (lstat(path, &st)==0)
{
if (S_ISLNK(st.st_mode))
return "link";
perm[0]= 'l';
else if (S_ISDIR(st.st_mode))
return "dir";
perm[0]= 'd';
else if (S_ISCHR(st.st_mode))
return "char device";
perm[0]= 'c';
else if (S_ISBLK(st.st_mode))
return "block device";
perm[0]= 'b';
else if (S_ISFIFO(st.st_mode))
return "fifo";
perm[0]= 'f';
else if (S_ISSOCK(st.st_mode))
return "socket";
perm[0]= 's';
else if (S_ISREG(st.st_mode))
return "file";
perm[0]= '-';
else /* Unknown type is an error */
return "";
perm[0]= '?';
/* Get file permissions */
/* User */
if (st.st_mode & S_IRUSR)
perm[1]= 'r';
if (st.st_mode & S_IWUSR)
perm[2]= 'w';
if (st.st_mode & S_IXUSR)
{
if (st.st_mode & S_ISUID)
perm[3] = 's';
else
perm[3]= 'x';
}
return "";
else if (st.st_mode & S_ISUID)
perm[3] = 'S';
/* Group */
if (st.st_mode & S_IRGRP)
perm[4]= 'r';
if (st.st_mode & S_IWGRP)
perm[5]= 'w';
if (st.st_mode & S_IXGRP)
{
if (st.st_mode & S_ISGID)
perm[6] = 's';
else
perm[6]= 'x';
}
else if (st.st_mode & S_ISGID)
perm[6] = 'S';
/* Other */
if (st.st_mode & S_IROTH)
perm[7]= 'r';
if (st.st_mode & S_IWOTH)
perm[8]= 'w';
if (st.st_mode & S_IXOTH)
{
// 'sticky' bit
if (st.st_mode &S_ISVTX)
perm[9] = 't';
else
perm[9]= 'x';
}
else if (st.st_mode &S_ISVTX)
perm[9]= 'T';
}
return perm;
}
/*
......@@ -370,26 +407,15 @@ on_comboURL_entry_changed (GtkEditable *editable,
gchar * psz_url;
if (p_intf)
{
if (p_intf->p_sys->b_autoplayfile == 1)
{
psz_url = gtk_entry_get_text(GTK_ENTRY(editable));
MediaURLOpenChanged( GTK_WIDGET(editable), psz_url );
}
}
void
on_comboPrefs_entry_changed (GtkEditable *editable,
gpointer user_data)
{
intf_thread_t * p_intf = GtkGetIntf( editable );
if (p_intf)
{
PreferencesURLOpenChanged( editable, NULL );
}
}
void
on_clistmedia_click_column (GtkCList *clist,
gint column,
......@@ -397,6 +423,7 @@ on_clistmedia_click_column (GtkCList *clist,
{
static GtkSortType sort_type = GTK_SORT_ASCENDING;
// Should sort on column
switch(sort_type)
{
case GTK_SORT_ASCENDING:
......@@ -422,35 +449,34 @@ on_clistmedia_select_row (GtkCList *clist,
{
gchar *text[2];
gint ret;
struct stat st;
ret = gtk_clist_get_text (clist, row, 0, text);
if (ret)
{
MediaURLOpenChanged( GTK_WIDGET(clist), text[0] );
// /* DO NOT TRY THIS CODE IT SEGFAULTS */
// g_print( "dir\n");
// /* should be a gchar compare function */
// if (strlen(text[1])>0)
// {
// g_print( "checking dir\n");
// /* should be a gchar compare function */
// if (strncmp(text[1],"dir",3)==0)
// {
// g_print( "dir: %s\n", text[0]);
// ReadDirectory(clist, text[0]);
// }
// else
// {
// g_print( "playing file\n");
// MediaURLOpenChanged( GTK_WIDGET(clist), text[0] );
// }
// }
// else
// {
// g_print( "playing filer\n");
// MediaURLOpenChanged( GTK_WIDGET(clist), text[0] );
// }
if (lstat((char*)text[0], &st)==0)
{
if (S_ISDIR(st.st_mode))
ReadDirectory(clist, text[0]);
else
MediaURLOpenChanged(GTK_WIDGET(clist), text[0]);
}
}
}
void
on_cbautoplay_toggled (GtkToggleButton *togglebutton,
gpointer user_data)
{
intf_thread_t * p_intf = GtkGetIntf( togglebutton );
if (p_intf)
{
if (p_intf->p_sys->b_autoplayfile == 1)
p_intf->p_sys->b_autoplayfile = 0;
else
p_intf->p_sys->b_autoplayfile = 1;
}
}
......@@ -2,7 +2,7 @@
* callbacks.h : familiar plugin for vlc
*****************************************************************************
* Copyright (C) 2002 VideoLAN
* $Id: callbacks.h,v 1.4 2002/08/14 21:50:01 jpsaman Exp $
* $Id: callbacks.h,v 1.5 2002/08/18 20:36:04 jpsaman Exp $
*
* Authors: Jean-Paul Saman <jpsaman@wxs.nl>
*
......@@ -68,10 +68,6 @@ void
on_comboURL_entry_changed (GtkEditable *editable,
gpointer user_data);
void
on_comboPrefs_entry_changed (GtkEditable *editable,
gpointer user_data);
void
on_clistmedia_click_column (GtkCList *clist,
......@@ -84,3 +80,8 @@ on_clistmedia_select_row (GtkCList *clist,
gint column,
GdkEvent *event,
gpointer user_data);
void
on_cbautoplay_toggled (GtkToggleButton *togglebutton,
gpointer user_data);
......@@ -2,7 +2,7 @@
* familiar.c : familiar plugin for vlc
*****************************************************************************
* Copyright (C) 2002 VideoLAN
* $Id: familiar.c,v 1.3 2002/08/14 21:50:01 jpsaman Exp $
* $Id: familiar.c,v 1.4 2002/08/18 20:36:04 jpsaman Exp $
*
* Authors: Jean-Paul Saman <jpsaman@wxs.nl>
*
......@@ -122,6 +122,8 @@ static int Open( vlc_object_t *p_this )
/* Initialize Gtk+ thread */
p_intf->p_sys->p_input = NULL;
p_intf->p_sys->b_autoplayfile = 1;
p_intf->pf_run = Run;
return( 0 );
......@@ -183,11 +185,17 @@ static void Run( intf_thread_t *p_intf )
gtk_window_set_title( GTK_WINDOW(p_intf->p_sys->p_window),
VOUT_TITLE " (Familiar Linux interface)");
/* Get the slider object */
p_intf->p_sys->p_notebook = GTK_NOTEBOOK( gtk_object_get_data(
GTK_OBJECT( p_intf->p_sys->p_window ), "notebook" ) );
// gtk_widget_hide( GTK_WIDGET(p_intf->p_sys->p_notebook) );
p_intf->p_sys->p_clist = GTK_CLIST( gtk_object_get_data(
GTK_OBJECT( p_intf->p_sys->p_window ), "clistmedia" ) );
gtk_clist_set_column_visibility (GTK_CLIST (p_intf->p_sys->p_clist), 2, FALSE);
gtk_clist_set_column_visibility (GTK_CLIST (p_intf->p_sys->p_clist), 3, FALSE);
gtk_clist_set_column_visibility (GTK_CLIST (p_intf->p_sys->p_clist), 4, FALSE);
gtk_clist_column_titles_show (GTK_CLIST (p_intf->p_sys->p_clist));
/* Store p_intf to keep an eye on it */
gtk_object_set_data( GTK_OBJECT(p_intf->p_sys->p_window),
"p_intf", p_intf );
......
......@@ -237,6 +237,42 @@
<ypad>0</ypad>
</widget>
<widget>
<class>GtkCombo</class>
<name>comboURL</name>
<x>40</x>
<y>4</y>
<width>185</width>
<height>24</height>
<value_in_list>False</value_in_list>
<ok_if_empty>True</ok_if_empty>
<case_sensitive>False</case_sensitive>
<use_arrows>True</use_arrows>
<use_arrows_always>False</use_arrows_always>
<items>file://
ftp://
http://
udp://:1234
udpstream://@:1234
</items>
<widget>
<class>GtkEntry</class>
<child_name>GtkCombo:entry</child_name>
<name>comboURL-entry</name>
<can_focus>True</can_focus>
<signal>
<name>changed</name>
<handler>on_comboURL-entry_changed</handler>
<last_modification_time>Thu, 01 Aug 2002 19:37:06 GMT</last_modification_time>
</signal>
<editable>True</editable>
<text_visible>True</text_visible>
<text_max_length>0</text_max_length>
<text>file://</text>
</widget>
</widget>
<widget>
<class>GtkScrolledWindow</class>
<name>scrolledwindow1</name>
......@@ -252,22 +288,19 @@
<widget>
<class>GtkCList</class>
<name>clistmedia</name>
<width>216</width>
<height>208</height>
<tooltip>Select files to play</tooltip>
<can_focus>True</can_focus>
<signal>
<name>click_column</name>
<handler>on_clistmedia_click_column</handler>
<last_modification_time>Wed, 14 Aug 2002 20:26:18 GMT</last_modification_time>
</signal>
<signal>
<name>select_row</name>
<handler>on_clistmedia_select_row</handler>
<last_modification_time>Wed, 14 Aug 2002 20:30:36 GMT</last_modification_time>
<last_modification_time>Sun, 18 Aug 2002 19:40:44 GMT</last_modification_time>
</signal>
<signal>
<name>click_column</name>
<handler>on_clistmedia_click_column</handler>
<last_modification_time>Sun, 18 Aug 2002 19:41:06 GMT</last_modification_time>
</signal>
<columns>2</columns>
<column_widths>145,54</column_widths>
<columns>5</columns>
<column_widths>123,80,80,80,80</column_widths>
<selection_mode>GTK_SELECTION_SINGLE</selection_mode>
<show_titles>True</show_titles>
<shadow_type>GTK_SHADOW_IN</shadow_type>
......@@ -277,7 +310,7 @@
<child_name>CList:title</child_name>
<name>labelname</name>
<label>Name</label>
<justify>GTK_JUSTIFY_LEFT</justify>
<justify>GTK_JUSTIFY_CENTER</justify>
<wrap>False</wrap>
<xalign>0.5</xalign>
<yalign>0.5</yalign>
......@@ -290,49 +323,52 @@
<child_name>CList:title</child_name>
<name>labeltype</name>
<label>Type</label>
<justify>GTK_JUSTIFY_LEFT</justify>
<justify>GTK_JUSTIFY_CENTER</justify>
<wrap>False</wrap>
<xalign>0.5</xalign>
<yalign>0.5</yalign>
<xpad>0</xpad>
<ypad>0</ypad>
</widget>
</widget>
<widget>
<class>GtkLabel</class>
<child_name>CList:title</child_name>
<name>labelsize</name>
<label>Size</label>
<justify>GTK_JUSTIFY_CENTER</justify>
<wrap>False</wrap>
<xalign>0.5</xalign>
<yalign>0.5</yalign>
<xpad>0</xpad>
<ypad>0</ypad>
</widget>
<widget>
<class>GtkCombo</class>
<name>comboURL</name>
<x>40</x>
<y>4</y>
<width>185</width>
<height>24</height>
<value_in_list>False</value_in_list>
<ok_if_empty>True</ok_if_empty>
<case_sensitive>False</case_sensitive>
<use_arrows>True</use_arrows>
<use_arrows_always>False</use_arrows_always>
<items>file://
ftp://
http://
udp://:1234
udpstream://@:1234
</items>
<class>GtkLabel</class>
<child_name>CList:title</child_name>
<name>labeluid</name>
<label>User</label>
<justify>GTK_JUSTIFY_CENTER</justify>
<wrap>False</wrap>
<xalign>0.5</xalign>
<yalign>0.5</yalign>
<xpad>0</xpad>
<ypad>0</ypad>
</widget>
<widget>
<class>GtkEntry</class>
<child_name>GtkCombo:entry</child_name>
<name>comboURL-entry</name>
<can_focus>True</can_focus>
<signal>
<name>changed</name>
<handler>on_comboURL-entry_changed</handler>
<last_modification_time>Thu, 01 Aug 2002 19:37:06 GMT</last_modification_time>
</signal>
<editable>True</editable>
<text_visible>True</text_visible>
<text_max_length>0</text_max_length>
<text>file://</text>
<class>GtkLabel</class>
<child_name>CList:title</child_name>
<name>labelgid</name>
<label>Group</label>
<justify>GTK_JUSTIFY_CENTER</justify>
<wrap>False</wrap>
<xalign>0.5</xalign>
<yalign>0.5</yalign>
<xpad>0</xpad>
<ypad>0</ypad>
</widget>
</widget>
</widget>
</widget>
......@@ -391,100 +427,22 @@ udpstream://@:1234
</widget>
<widget>
<class>GtkFrame</class>
<name>frameDefaultURL</name>
<x>8</x>
<y>8</y>
<width>220</width>
<height>60</height>
<label>Default URL:</label>
<label_xalign>0</label_xalign>
<shadow_type>GTK_SHADOW_ETCHED_IN</shadow_type>
<widget>
<class>GtkFixed</class>
<name>fixed3</name>
<widget>
<class>GtkCombo</class>
<name>comboDefaultURL</name>
<class>GtkCheckButton</class>
<name>cbautoplay</name>
<x>8</x>
<y>8</y>
<width>200</width>
<width>216</width>
<height>24</height>
<value_in_list>False</value_in_list>
<ok_if_empty>True</ok_if_empty>
<case_sensitive>False</case_sensitive>
<use_arrows>True</use_arrows>
<use_arrows_always>False</use_arrows_always>
<items>file://
ftp://
http://
udpstream://@:1234
udp://:1234
</items>
<widget>
<class>GtkEntry</class>
<child_name>GtkCombo:entry</child_name>
<name>comboPrefs-entry</name>
<can_focus>True</can_focus>
<signal>
<name>changed</name>
<handler>on_comboPrefs-entry_changed</handler>
<last_modification_time>Thu, 01 Aug 2002 20:11:46 GMT</last_modification_time>
<name>toggled</name>
<handler>on_cbautoplay_toggled</handler>
<last_modification_time>Sun, 18 Aug 2002 20:00:52 GMT</last_modification_time>
</signal>
<editable>True</editable>
<text_visible>True</text_visible>
<text_max_length>0</text_max_length>
<text>file://</text>
</widget>
</widget>
</widget>
</widget>
<widget>
<class>GtkFrame</class>
<name>frameIP</name>
<x>8</x>
<y>72</y>
<width>220</width>
<height>60</height>
<label>IP version:</label>
<label_xalign>0</label_xalign>
<shadow_type>GTK_SHADOW_ETCHED_IN</shadow_type>
<widget>
<class>GtkFixed</class>
<name>fixed2</name>
<widget>
<class>GtkRadioButton</class>
<name>rbIPv4</name>
<x>8</x>
<y>8</y>
<width>104</width>
<height>26</height>
<can_focus>True</can_focus>
<label>IPv4</label>
<label>Automatically play file.</label>
<active>True</active>
<draw_indicator>True</draw_indicator>
</widget>
<widget>
<class>GtkRadioButton</class>
<name>rbIPv6</name>
<x>112</x>
<y>8</y>
<width>104</width>
<height>26</height>
<can_focus>True</can_focus>
<label>IPv6</label>
<active>False</active>
<draw_indicator>True</draw_indicator>
</widget>
</widget>
</widget>
</widget>
<widget>
......
......@@ -2,7 +2,7 @@
* familiar.h: private Gtk+ interface description
*****************************************************************************
* Copyright (C) 1999, 2000 VideoLAN
* $Id: familiar.h,v 1.3 2002/08/14 21:50:01 jpsaman Exp $
* $Id: familiar.h,v 1.4 2002/08/18 20:36:04 jpsaman Exp $
*
* Authors: Jean-Paul Saman <jpsaman@wxs.nl>
*
......@@ -34,7 +34,9 @@ struct intf_sys_t
// GtkWidget * p_notebook_about;
// GtkWidget * p_notebook_open;
// GtkWidget * p_notebook_preferences;
GtkCList * p_clist;
vlc_bool_t b_autoplayfile;
/* The input thread */
input_thread_t * p_input;
......
This diff is collapsed.
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