diff options
author | Andreas Obergrusberger <tradiaz@yahoo.de> | 2006-11-08 15:10:37 +0000 |
---|---|---|
committer | Andreas Obergrusberger <tradiaz@yahoo.de> | 2006-11-08 15:10:37 +0000 |
commit | aee50deefe83ea3a79255cb64a252c58775f8a5b (patch) | |
tree | bb08dfc06dddde768f83c6929566181bf8335e66 /src | |
parent | ed358adb44de918bd253d2aa46aa85a58a77a144 (diff) | |
download | mpd-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')
-rw-r--r-- | src/command.c | 4 | ||||
-rw-r--r-- | src/command.h | 2 | ||||
-rw-r--r-- | src/screen_file.c | 35 | ||||
-rw-r--r-- | src/screen_help.c | 4 |
4 files changed, 36 insertions, 9 deletions
diff --git a/src/command.c b/src/command.c index 2f0ece1d9..3210f39d9 100644 --- a/src/command.c +++ b/src/command.c @@ -137,6 +137,10 @@ static command_definition_t cmds[] = { { 'a', 0, 0 }, 0, CMD_ADD, "add", N_("Add url/file to playlist") }, + { { '!', 0, 0 }, 0, CMD_GO_ROOT_DIRECTORY, "go-root-directory", + N_("Go to root directory") }, + { { '"', 0, 0 }, 0, CMD_GO_PARENT_DIRECTORY, "go-parent-directory", + N_("Go to parent directory") }, /* lists */ { { 11, 0, 0 }, 0, CMD_LIST_MOVE_UP, "move-up", diff --git a/src/command.h b/src/command.h index 86db34ce9..745b5283b 100644 --- a/src/command.h +++ b/src/command.h @@ -55,6 +55,8 @@ typedef enum CMD_SCREEN_LYRICS, CMD_LYRICS_UPDATE, CMD_INTERRUPT, + CMD_GO_ROOT_DIRECTORY, + CMD_GO_PARENT_DIRECTORY, CMD_QUIT } command_t; 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 ) { diff --git a/src/screen_help.c b/src/screen_help.c index 31a125a7f..6825e567b 100644 --- a/src/screen_help.c +++ b/src/screen_help.c @@ -98,7 +98,7 @@ static help_text_row_t help_text[] = { 0, CMD_PLAY, N_("Play") }, { 0, CMD_DELETE, NULL }, { 0, CMD_CLEAR, NULL }, - { 0, CMD_LIST_MOVE_UP, N_("Move song up") }, + { 1, CMD_LIST_MOVE_UP, N_("Move song up") }, { 0, CMD_LIST_MOVE_DOWN, N_("Move song down") }, { 0, CMD_ADD, NULL }, { 0, CMD_SAVE_PLAYLIST, NULL }, @@ -113,6 +113,8 @@ static help_text_row_t help_text[] = { 0, CMD_SELECT, NULL }, { 0, CMD_SAVE_PLAYLIST, NULL }, { 0, CMD_DELETE, N_("Delete playlist") }, + { 0, CMD_GO_PARENT_DIRECTORY, NULL }, + { 0, CMD_GO_ROOT_DIRECTORY, NULL }, { 0, CMD_SCREEN_UPDATE, NULL }, #ifdef ENABLE_SEARCH_SCREEN |