diff --git a/screen_file.c b/screen_file.c
index bd60872e60e438a0060800dc93eb1c9b8adfab10..69ec858085665aae35dbd6273d88fdce7f873926 100644 (file)
--- a/screen_file.c
+++ b/screen_file.c
-/*
- * $Id: screen_file.c,v 1.9 2004/03/18 09:33:07 kalle Exp $
- *
- */
-
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include "mpc.h"
#include "command.h"
#include "screen.h"
+#include "screen_utils.h"
#include "screen_file.h"
+#define BUFSIZE 1024
static char *
list_callback(int index, int *highlight, void *data)
{
+ static char buf[BUFSIZE];
mpd_client_t *c = (mpd_client_t *) data;
filelist_entry_t *entry;
mpd_InfoEntity *entity;
}
if( entity->type==MPD_INFO_ENTITY_TYPE_DIRECTORY )
{
-
mpd_Directory *dir = entity->info.directory;
+ char *dirname = utf8_to_locale(basename(dir->path));
- return utf8(basename(dir->path));
+ snprintf(buf, BUFSIZE, "[%s]", dirname);
+ free(dirname);
+ return buf;
}
else if( entity->type==MPD_INFO_ENTITY_TYPE_SONG )
{
mpd_Song *song = entity->info.song;
return mpc_get_song_name(song);
}
-
- return NULL;
+ else if( entity->type==MPD_INFO_ENTITY_TYPE_PLAYLISTFILE )
+ {
+ mpd_PlaylistFile *plf = entity->info.playlistFile;
+ char *filename = utf8_to_locale(basename(plf->path));
+
+ snprintf(buf, BUFSIZE, "%s*", filename);
+ free(filename);
+ return buf;
+ }
+ return "Error: Unknow entry!";
}
static void
mpd_InfoEntity *entity;
GList *subdir_list = NULL;
GList *list = NULL;
- char buf[80];
+ char *dirname;
- snprintf(buf, 80, "Adding directory %s...\n", dir);
- screen_status_message(c, buf);
+ dirname = utf8_to_locale(dir);
+ screen_status_printf("Adding directory %s...\n", dirname);
+ free(dirname);
+ dirname = NULL;
mpd_sendLsInfoCommand(c->connection, dir);
mpd_sendCommandListBegin(c->connection);
{
if( entry->entity->type==MPD_INFO_ENTITY_TYPE_SONG )
{
- char buf[80];
mpd_Song *song = entry->entity->info.song;
mpd_sendAddCommand(c->connection, song->file);
mpd_finishCommand(c->connection);
- snprintf(buf, 80,
- "Adding \'%s\' to playlist\n",
- mpc_get_song_name(song));
- screen_status_message(c, buf);
+ screen_status_printf("Adding \'%s\' to playlist\n",
+ mpc_get_song_name(song));
}
}
else
if( entry->entity->type==MPD_INFO_ENTITY_TYPE_SONG )
{
int i;
- char buf[80];
mpd_Song *song = entry->entity->info.song;
i = mpc_playlist_get_song_index(c, song->file);
{
mpd_sendDeleteCommand(c->connection, i);
mpd_finishCommand(c->connection);
- snprintf(buf, 80,
- "Removed \'%s\' from playlist\n",
- mpc_get_song_name(song));
- screen_status_message(c, buf);
+ screen_status_printf("Removed \'%s\' from playlist\n",
+ mpc_get_song_name(song));
+
}
}
}
file_get_header(mpd_client_t *c)
{
static char buf[64];
+ char *tmp;
+ tmp = utf8_to_locale(basename(c->cwd));
snprintf(buf, 64,
TOP_HEADER_FILE ": %s ",
- basename(c->cwd)
+ tmp
);
+ free(tmp);
return buf;
}
{
case CMD_PLAY:
change_directory(screen, c);
- break;
- case CMD_LIST_PREVIOUS:
- list_window_previous(screen->filelist);
- screen->filelist->repaint=1;
- break;
+ return 1;
case CMD_SELECT:
select_entry(screen, c);
/* continue and select next item... */
- case CMD_LIST_NEXT:
- list_window_next(screen->filelist, c->filelist_length);
- screen->filelist->repaint=1;
- break;
- case CMD_LIST_FIRST:
- list_window_first(screen->filelist);
- screen->filelist->repaint = 1;
- break;
- case CMD_LIST_LAST:
- list_window_last(screen->filelist, c->filelist_length);
- screen->filelist->repaint = 1;
- break;
- case CMD_LIST_NEXT_PAGE:
- list_window_next_page(screen->filelist, c->filelist_length);
- screen->filelist->repaint = 1;
- break;
- case CMD_LIST_PREVIOUS_PAGE:
- list_window_previous_page(screen->filelist);
- screen->filelist->repaint = 1;
+ cmd = CMD_LIST_NEXT;
break;
+ case CMD_LIST_FIND:
+ if( screen->findbuf )
+ {
+ free(screen->findbuf);
+ screen->findbuf=NULL;
+ }
+ /* continue... */
+ case CMD_LIST_FIND_NEXT:
+ if( !screen->findbuf )
+ screen->findbuf=screen_readln(screen->status_window.w, "/");
+ if( list_window_find(screen->filelist,
+ list_callback,
+ c,
+ screen->findbuf) == 0 )
+ {
+ screen->filelist->repaint = 1;
+ }
+ else
+ {
+ screen_status_printf("Unable to find \'%s\'", screen->findbuf);
+ beep();
+ }
+ return 1;
default:
- return 0;
+ break;
}
- return 1;
+ return list_window_cmd(screen->filelist, c->filelist_length, cmd);
}