Commit 7d5b21c4 authored by Jean-Paul Saman's avatar Jean-Paul Saman
Browse files

PDA Interface:

- Cleanup code
- Cleanup interface
- Adding items to playlist widgets from File, Camera, Transcode tabs.
parent bec4516d
......@@ -2,7 +2,7 @@
* pda.c : PDA Gtk2 plugin for vlc
*****************************************************************************
* Copyright (C) 2002 VideoLAN
* $Id: pda.c,v 1.8 2003/11/07 13:01:51 jpsaman Exp $
* $Id: pda.c,v 1.9 2003/11/18 20:36:40 jpsaman Exp $
*
* Authors: Jean-Paul Saman <jpsaman@wxs.nl>
* Marc Ariberti <marcari@videolan.org>
......@@ -148,6 +148,7 @@ static void Run( intf_thread_t *p_intf )
GtkCellRenderer *renderer = NULL;
GtkTreeViewColumn *column = NULL;
GtkListStore *filelist = NULL;
GtkListStore *playlist = NULL;
#ifndef NEED_GTK2_MAIN
gtk_set_locale ();
......@@ -252,7 +253,7 @@ static void Run( intf_thread_t *p_intf )
G_TYPE_UINT64, /* File size */
G_TYPE_STRING, /* Owner */
G_TYPE_STRING);/* Group */
ReadDirectory(filelist, ".");
ReadDirectory(p_intf, 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(filelist));
g_object_unref(filelist); /* Model will be released by GtkTreeView */
......@@ -267,8 +268,7 @@ static void Run( intf_thread_t *p_intf )
/* BEGIN OF PLAYLIST GTK_TREE_VIEW */
msg_Dbg(p_intf, "Getting GtkTreeView PlayList" );
p_intf->p_sys->p_tvplaylist = NULL;
p_intf->p_sys->p_tvplaylist = (GtkTreeView *) lookup_widget( p_intf->p_sys->p_window,
"tvPlaylist");
p_intf->p_sys->p_tvplaylist = (GtkTreeView *) lookup_widget( p_intf->p_sys->p_window, "tvPlaylist");
if (NULL == p_intf->p_sys->p_tvplaylist)
msg_Err(p_intf, "Error obtaining pointer to Play List");
......@@ -287,13 +287,13 @@ static void Run( intf_thread_t *p_intf )
/* update the playlist */
msg_Dbg(p_intf, "Populating GtkTreeView Playlist" );
p_intf->p_sys->p_playlist = gtk_list_store_new (2,
G_TYPE_STRING, /* Filename */
G_TYPE_STRING);/* Time */
PlaylistRebuildListStore( p_intf->p_sys->p_playlist, vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE ));
playlist = gtk_list_store_new (2,
G_TYPE_STRING, /* Filename */
G_TYPE_STRING);/* Time */
PlaylistRebuildListStore( playlist, vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE ));
msg_Dbg(p_intf, "Showing GtkTreeView 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_view_set_model(GTK_TREE_VIEW(p_intf->p_sys->p_tvplaylist), GTK_TREE_MODEL(playlist));
g_object_unref(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 */
......@@ -302,10 +302,6 @@ static void Run( intf_thread_t *p_intf )
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(
GTK_OBJECT( p_intf->p_sys->p_window ), "mrl_entry" ) );
/* 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),
......
......@@ -157,7 +157,7 @@
<packing>
<property name="padding">4</property>
<property name="expand">False</property>
<property name="fill">False</property>
<property name="fill">True</property>
</packing>
</child>
......@@ -209,7 +209,6 @@
<property name="reorderable">False</property>
<property name="enable_search">True</property>
<signal name="row_activated" handler="onFileListRow" last_modification_time="Fri, 26 Sep 2003 13:30:40 GMT"/>
<signal name="select_cursor_row" handler="onFileListRowSelected" last_modification_time="Fri, 26 Sep 2003 13:31:20 GMT"/>
</widget>
</child>
</widget>
......@@ -331,7 +330,6 @@
<property name="case_sensitive">False</property>
<property name="enable_arrow_keys">True</property>
<property name="enable_arrows_always">False</property>
<signal name="add" handler="onNetworkMRLAdd" last_modification_time="Fri, 07 Nov 2003 14:35:58 GMT"/>
<child internal-child="entry">
<widget class="GtkEntry" id="entryMRL">
......@@ -505,7 +503,7 @@
<property name="update_policy">GTK_UPDATE_ALWAYS</property>
<property name="snap_to_ticks">False</property>
<property name="wrap">False</property>
<property name="adjustment">1233 0 65535 1 10 10</property>
<property name="adjustment">1234 0 65535 1 10 10</property>
<signal name="changed" handler="NetworkBuildMRL" last_modification_time="Sat, 08 Nov 2003 13:34:10 GMT"/>
</widget>
<packing>
......@@ -573,7 +571,7 @@
<property name="editable">True</property>
<property name="visibility">True</property>
<property name="max_length">0</property>
<property name="text" translatable="yes">unicast</property>
<property name="text" translatable="yes"></property>
<property name="has_frame">True</property>
<property name="invisible_char" translatable="yes">*</property>
<property name="activates_default">True</property>
......@@ -653,7 +651,7 @@
<property name="editable">True</property>
<property name="visibility">True</property>
<property name="max_length">0</property>
<property name="text" translatable="yes">udp</property>
<property name="text" translatable="yes"></property>
<property name="has_frame">True</property>
<property name="invisible_char" translatable="yes">*</property>
<property name="activates_default">False</property>
......@@ -1167,7 +1165,7 @@
<property name="editable">True</property>
<property name="visibility">True</property>
<property name="max_length">0</property>
<property name="text" translatable="yes">/dev/video</property>
<property name="text" translatable="yes"></property>
<property name="has_frame">True</property>
<property name="invisible_char" translatable="yes">*</property>
<property name="activates_default">True</property>
......@@ -1231,7 +1229,7 @@
<property name="editable">True</property>
<property name="visibility">True</property>
<property name="max_length">0</property>
<property name="text" translatable="yes">/dev/dsp</property>
<property name="text" translatable="yes"></property>
<property name="has_frame">True</property>
<property name="invisible_char" translatable="yes">*</property>
<property name="activates_default">True</property>
......@@ -1325,7 +1323,7 @@
<property name="editable">True</property>
<property name="visibility">True</property>
<property name="max_length">0</property>
<property name="text" translatable="yes">pal</property>
<property name="text" translatable="yes"></property>
<property name="has_frame">True</property>
<property name="invisible_char" translatable="yes">*</property>
<property name="activates_default">True</property>
......@@ -1397,7 +1395,7 @@
<property name="editable">True</property>
<property name="visibility">True</property>
<property name="max_length">0</property>
<property name="text" translatable="yes">240x192</property>
<property name="text" translatable="yes"></property>
<property name="has_frame">True</property>
<property name="invisible_char" translatable="yes">*</property>
<property name="activates_default">True</property>
......@@ -1561,7 +1559,7 @@
<property name="editable">True</property>
<property name="visibility">True</property>
<property name="max_length">0</property>
<property name="text" translatable="yes">mono</property>
<property name="text" translatable="yes"></property>
<property name="has_frame">True</property>
<property name="invisible_char" translatable="yes">*</property>
<property name="activates_default">True</property>
......@@ -1808,7 +1806,7 @@
<property name="editable">True</property>
<property name="visibility">True</property>
<property name="max_length">0</property>
<property name="text" translatable="yes">huffyuv</property>
<property name="text" translatable="yes"></property>
<property name="has_frame">True</property>
<property name="invisible_char" translatable="yes">*</property>
<property name="activates_default">True</property>
......@@ -2181,7 +2179,7 @@
<property name="editable">True</property>
<property name="visibility">True</property>
<property name="max_length">0</property>
<property name="text" translatable="yes">127.0.0.1</property>
<property name="text" translatable="yes"></property>
<property name="has_frame">True</property>
<property name="invisible_char" translatable="yes">*</property>
<property name="activates_default">True</property>
......@@ -2252,7 +2250,7 @@
<property name="editable">True</property>
<property name="visibility">True</property>
<property name="max_length">0</property>
<property name="text" translatable="yes">udp</property>
<property name="text" translatable="yes"></property>
<property name="has_frame">True</property>
<property name="invisible_char" translatable="yes">*</property>
<property name="activates_default">True</property>
......@@ -2299,7 +2297,7 @@
<property name="editable">True</property>
<property name="visibility">True</property>
<property name="max_length">0</property>
<property name="text" translatable="yes">ts</property>
<property name="text" translatable="yes"></property>
<property name="has_frame">True</property>
<property name="invisible_char" translatable="yes">*</property>
<property name="activates_default">True</property>
......@@ -2376,7 +2374,7 @@
<property name="editable">True</property>
<property name="visibility">True</property>
<property name="max_length">0</property>
<property name="text" translatable="yes">alaw</property>
<property name="text" translatable="yes"></property>
<property name="has_frame">True</property>
<property name="invisible_char" translatable="yes">*</property>
<property name="activates_default">True</property>
......@@ -2743,7 +2741,30 @@
<property name="spacing">0</property>
<child>
<placeholder/>
<widget class="GtkScrolledWindow" id="scrolledwindowPreference">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="hscrollbar_policy">GTK_POLICY_ALWAYS</property>
<property name="vscrollbar_policy">GTK_POLICY_ALWAYS</property>
<property name="shadow_type">GTK_SHADOW_NONE</property>
<property name="window_placement">GTK_CORNER_TOP_LEFT</property>
<child>
<widget class="GtkTreeView" id="tvPreferences">
<property name="visible">True</property>
<property name="can_focus">True</property>
<property name="headers_visible">False</property>
<property name="rules_hint">False</property>
<property name="reorderable">False</property>
<property name="enable_search">True</property>
</widget>
</child>
</widget>
<packing>
<property name="padding">0</property>
<property name="expand">True</property>
<property name="fill">True</property>
</packing>
</child>
<child>
......@@ -2917,15 +2938,15 @@
</child>
<child>
<widget class="GtkLabel" id="labelProgramName">
<property name="width_request">152</property>
<widget class="GtkLabel" id="labelCopyright">
<property name="width_request">208</property>
<property name="height_request">16</property>
<property name="visible">True</property>
<property name="label" translatable="yes">VLC media player</property>
<property name="label" translatable="yes">(C) 1996-2003 the VideoLAN team</property>
<property name="use_underline">False</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_CENTER</property>
<property name="wrap">True</property>
<property name="wrap">False</property>
<property name="selectable">False</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
......@@ -2933,21 +2954,21 @@
<property name="ypad">0</property>
</widget>
<packing>
<property name="x">48</property>
<property name="y">16</property>
<property name="x">16</property>
<property name="y">48</property>
</packing>
</child>
<child>
<widget class="GtkLabel" id="labelCopyright">
<property name="width_request">208</property>
<widget class="GtkLabel" id="labelProgramName">
<property name="width_request">152</property>
<property name="height_request">16</property>
<property name="visible">True</property>
<property name="label" translatable="yes">(C) 1996-2003 the VideoLAN team</property>
<property name="label" translatable="yes">VLC media player</property>
<property name="use_underline">False</property>
<property name="use_markup">False</property>
<property name="justify">GTK_JUSTIFY_CENTER</property>
<property name="wrap">False</property>
<property name="wrap">True</property>
<property name="selectable">False</property>
<property name="xalign">0.5</property>
<property name="yalign">0.5</property>
......@@ -2955,8 +2976,8 @@
<property name="ypad">0</property>
</widget>
<packing>
<property name="x">16</property>
<property name="y">48</property>
<property name="x">48</property>
<property name="y">16</property>
</packing>
</child>
</widget>
......
......@@ -2,7 +2,7 @@
* pda.h: private Gtk+ interface description
*****************************************************************************
* Copyright (C) 1999, 2000 VideoLAN
* $Id: pda.h,v 1.4 2003/11/07 13:01:51 jpsaman Exp $
* $Id: pda.h,v 1.5 2003/11/18 20:36:40 jpsaman Exp $
*
* Authors: Jean-Paul Saman <jpsaman@wxs.nl>
*
......@@ -33,12 +33,10 @@ struct intf_sys_t
/* windows and widgets */
GtkWidget *p_window; /* main window */
GtkEntry *p_mrlentry;
GtkNotebook *p_notebook;
GtkHScale *p_slider;
GtkTreeView *p_tvfile;
GtkTreeView *p_tvplaylist;
GtkListStore *p_playlist; /* Playlist widget */
/* slider */
GtkLabel * p_slider_label;
......
......@@ -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.13 2003/11/09 21:29:52 jpsaman Exp $
* $Id: pda_callbacks.c,v 1.14 2003/11/18 20:36:40 jpsaman Exp $
*
* Authors: Jean-Paul Saman <jpsaman@wxs.nl>
*
......@@ -35,6 +35,8 @@
#include <dirent.h>
#include <sys/stat.h>
#include <unistd.h>
#include <pwd.h>
#include <grp.h>
#ifdef HAVE_CONFIG_H
# include <config.h>
......@@ -49,7 +51,7 @@
#define VLC_MAX_MRL 256
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, off_t *size);
/*****************************************************************************
* Useful function to retrieve p_intf
......@@ -85,7 +87,7 @@ void * E_(__GtkGetIntf)( GtkWidget * widget )
return p_data;
}
void PlaylistAddItem( GtkWidget *widget, gchar *name)
void PlaylistAddItem(GtkWidget *widget, gchar *name)
{
GtkTreeView *p_tvplaylist = NULL;
......@@ -139,7 +141,6 @@ void MediaURLOpenChanged( GtkWidget *widget, gchar *psz_url )
{
intf_thread_t *p_intf = GtkGetIntf( widget );
playlist_t *p_playlist;
GtkTreeView *p_tvplaylist;
p_playlist = (playlist_t *)
vlc_object_find( p_intf, VLC_OBJECT_PLAYLIST, FIND_ANYWHERE );
......@@ -163,13 +164,7 @@ void MediaURLOpenChanged( GtkWidget *widget, gchar *psz_url )
}
vlc_object_release( p_playlist );
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);
}
PlaylistAddItem(GTK_WIDGET(widget), psz_url);
}
}
#endif
......@@ -177,18 +172,18 @@ void MediaURLOpenChanged( GtkWidget *widget, gchar *psz_url )
/*****************************************************************
* Read directory helper function.
****************************************************************/
void ReadDirectory(GtkListStore *p_list, char *psz_dir )
void ReadDirectory(intf_thread_t *p_intf, GtkListStore *p_list, char *psz_dir )
{
GtkTreeIter iter;
struct dirent **namelist;
int n=-1, status=-1;
g_print("changing to dir %s\n", psz_dir);
msg_Dbg(p_intf, "Changing to dir %s", psz_dir);
if (psz_dir)
{
status = chdir(psz_dir);
if (status<0)
g_print( "permision denied\n" );
msg_Dbg(p_intf, "permision denied" );
}
n = scandir(".", &namelist, 0, alphasort);
......@@ -197,17 +192,14 @@ void ReadDirectory(GtkListStore *p_list, char *psz_dir )
else
{
int i;
uint32_t uid;
uint32_t gid;
off_t size;
gchar *ppsz_text[5];
gchar *ppsz_text[4];
/* XXX : kludge temporaire pour yopy */
ppsz_text[0]="..";
ppsz_text[1] = get_file_stat("..", &uid, &gid, &size);
ppsz_text[2] = "";
ppsz_text[3] = "";
ppsz_text[4] = "";
ppsz_text[0] = "..";
ppsz_text[1] = get_file_stat("..", &size);
ppsz_text[2] = "?";
ppsz_text[3] = "?";
/* Add a new row to the model */
gtk_list_store_append (p_list, &iter);
......@@ -215,8 +207,8 @@ void ReadDirectory(GtkListStore *p_list, char *psz_dir )
0, ppsz_text[0],
1, ppsz_text[1],
2, size,
3, ppsz_text[3],
4, ppsz_text[4],
3, ppsz_text[2],
4, ppsz_text[3],
-1);
if (ppsz_text[1]) free(ppsz_text[1]);
......@@ -228,20 +220,19 @@ void ReadDirectory(GtkListStore *p_list, char *psz_dir )
{
/* This is a list of strings. */
ppsz_text[0] = namelist[i]->d_name;
ppsz_text[1] = get_file_stat(namelist[i]->d_name, &uid, &gid, &size);
ppsz_text[2] = "";
ppsz_text[3] = "";
ppsz_text[4] = "";
#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 );
ppsz_text[1] = get_file_stat(namelist[i]->d_name, &size);
ppsz_text[2] = "?";
ppsz_text[3] = "?";
#if 1
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 );
#endif
gtk_list_store_append (p_list, &iter);
gtk_list_store_set (p_list, &iter,
0, ppsz_text[0],
1, ppsz_text[1],
2, size,
3, ppsz_text[3],
4, ppsz_text[4],
3, ppsz_text[2],
4, ppsz_text[3],
-1);
if (ppsz_text[1]) free(ppsz_text[1]);
......@@ -251,19 +242,18 @@ void ReadDirectory(GtkListStore *p_list, char *psz_dir )
}
}
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, off_t *size)
{
struct stat st;
char *perm;
struct passwd *pw = NULL;
struct group *grp = NULL;
struct stat st;
char *perm;
int ret = -1;
perm = (char *) malloc(sizeof(char)*10);
strncpy( perm, "----------", sizeof("----------"));
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))
perm[0]= 'l';
......@@ -325,6 +315,24 @@ static char* get_file_stat(const char *path, uid_t *uid, gid_t *gid, off_t *size
}
else if (st.st_mode &S_ISVTX)
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;
}
......@@ -481,7 +489,6 @@ void addSelectedToPlaylist(GtkTreeModel *model,
gtk_tree_model_get(model, iter, 0, &filename, -1);
/* Add to playlist object. */
PlaylistAddItem(GTK_WIDGET(userdata), filename);
}
......@@ -491,11 +498,12 @@ onFileListRow (GtkTreeView *treeview,
GtkTreeViewColumn *column,
gpointer user_data)
{
intf_thread_t *p_intf = GtkGetIntf( GTK_WIDGET(treeview) );
GtkTreeSelection *selection = gtk_tree_view_get_selection(treeview);
if (gtk_tree_selection_count_selected_rows(selection) == 1)
{
struct stat st;
struct stat st;
GtkTreeModel *model;
GtkTreeIter iter;
gchar *filename;
......@@ -503,37 +511,57 @@ onFileListRow (GtkTreeView *treeview,
/* 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" );
msg_Err(p_intf, "PDA: Filelist model contains a NULL pointer\n" );
gtk_tree_model_get(model, &iter, 0, &filename, -1);
if (stat((char*)filename, &st)==0)
if (path == NULL )
{
if (S_ISDIR(st.st_mode))
#if 0
GList* list;
list = gtk_tree_selection_get_selected_rows(selection,model);
if (g_list_length(list) == 1)
{
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 (p_model)
{
ReadDirectory(p_model, filename);
/* Update TreeView with new model */
gtk_tree_view_set_model(treeview, (GtkTreeModel*) p_model);
g_object_unref(p_model);
}
filename = (gchar *) g_list_nth_data(list,0);
msg_Dbg(p_intf, "PDA: filename = %s", (gchar*) filename );
PlaylistAddItem(GTK_WIDGET(treeview), filename);
}
else
g_list_foreach (list, gtk_tree_path_free, NULL);
g_list_free (list);
#endif
}
else
{
if (!gtk_tree_model_get_iter(model, &iter, path))
msg_Err( p_intf, "PDA: Could not get iter from model" );
gtk_tree_model_get(model, &iter, 0, &filename, -1);
if (stat((char*)filename, &st)==0)
{
gtk_tree_selection_selected_foreach(selection, (GtkTreeSelectionForeachFunc) &addSelectedToPlaylist, (gpointer) treeview);
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 (p_model)
{
ReadDirectory(p_intf, 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);
}
}
}
}
......@@ -543,25 +571,6 @@ onFileListRow (GtkTreeView *treeview,
}
}
void
onFileListColumns (GtkTreeView *treeview,
gpointer user_data)
{
g_print("onFileListColumn\n");
}
gboolean