aboutsummaryrefslogtreecommitdiffstats
path: root/src/screen_file.c
diff options
context:
space:
mode:
authorAndreas Obergrusberger <tradiaz@yahoo.de>2006-11-08 15:10:37 +0000
committerAndreas Obergrusberger <tradiaz@yahoo.de>2006-11-08 15:10:37 +0000
commitaee50deefe83ea3a79255cb64a252c58775f8a5b (patch)
treebb08dfc06dddde768f83c6929566181bf8335e66 /src/screen_file.c
parented358adb44de918bd253d2aa46aa85a58a77a144 (diff)
downloadmpd-aee50deefe83ea3a79255cb64a252c58775f8a5b.tar.gz
mpd-aee50deefe83ea3a79255cb64a252c58775f8a5b.tar.xz
mpd-aee50deefe83ea3a79255cb64a252c58775f8a5b.zip
go to root/parent dir key added
git-svn-id: https://svn.musicpd.org/ncmpc/branches/tradiaz@5034 09075e82-0dd4-0310-85a5-a0d7c8717e4f
Diffstat (limited to 'src/screen_file.c')
-rw-r--r--src/screen_file.c35
1 files changed, 27 insertions, 8 deletions
diff --git a/src/screen_file.c b/src/screen_file.c
index b2d320f0b..4a4bdf70c 100644
--- a/src/screen_file.c
+++ b/src/screen_file.c
@@ -207,20 +207,33 @@ browse_lw_callback(int index, int *highlight, void *data)
/* chdir */
static int
-change_directory(screen_t *screen, mpdclient_t *c, filelist_entry_t *entry)
+change_directory(screen_t *screen, mpdclient_t *c, filelist_entry_t *entry, char *new_path)
{
- mpd_InfoEntity *entity = entry->entity;
+ mpd_InfoEntity *entity = NULL;
gchar *path = NULL;
+ if( entry!=NULL )
+ entity = entry->entity;
+ else if( new_path==NULL )
+ return -1;
+
if( entity==NULL )
{
- /* return to parent */
- char *parent = g_path_get_dirname(filelist->path);
- if( strcmp(parent, ".") == 0 )
+ if( entry || 0==strcmp(new_path, "..") )
+ {
+ /* return to parent */
+ char *parent = g_path_get_dirname(filelist->path);
+ if( strcmp(parent, ".") == 0 )
+ {
+ parent[0] = '\0';
+ }
+ path = g_strdup(parent);
+ }
+ else
{
- parent[0] = '\0';
+ /* entry==NULL, then new_path ("" is root) */
+ path = g_strdup(new_path);
}
- path = g_strdup(parent);
list_window_reset(lw);
/* restore previous list window state */
list_window_pop_state(lw_state,lw);
@@ -366,7 +379,7 @@ browse_handle_enter(screen_t *screen,
entity = entry->entity;
if( entity==NULL || entity->type==MPD_INFO_ENTITY_TYPE_DIRECTORY )
- return change_directory(screen, c, entry);
+ return change_directory(screen, c, entry, NULL);
else if( entity->type==MPD_INFO_ENTITY_TYPE_PLAYLISTFILE )
return load_playlist(screen, c, entry);
else if( entity->type==MPD_INFO_ENTITY_TYPE_SONG )
@@ -635,6 +648,12 @@ browse_cmd(screen_t *screen, mpdclient_t *c, command_t cmd)
case CMD_PLAY:
browse_handle_enter(screen, c, lw, filelist);
return 1;
+ case CMD_GO_ROOT_DIRECTORY:
+ return change_directory(screen, c, NULL, "");
+ break;
+ case CMD_GO_PARENT_DIRECTORY:
+ return change_directory(screen, c, NULL, "..");
+ break;
case CMD_SELECT:
if( browse_handle_select(screen, c, lw, filelist) == 0 )
{