summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 7c9aa09)
raw | patch | inline | side by side (parent: 7c9aa09)
author | Kalle Wallin <kaw@linux.se> | |
Wed, 15 Jun 2005 13:04:22 +0000 (13:04 +0000) | ||
committer | Kalle Wallin <kaw@linux.se> | |
Wed, 15 Jun 2005 13:04:22 +0000 (13:04 +0000) |
ChangeLog | patch | blob | history | |
doc/config.sample | patch | blob | history | |
src/conf.c | patch | blob | history | |
src/ncmpc.h | patch | blob | history | |
src/options.c | patch | blob | history | |
src/options.h | patch | blob | history | |
src/screen.c | patch | blob | history |
diff --git a/ChangeLog b/ChangeLog
index 393bb68094325e890a9eb1395ef5cb7097a6c25d..ed3e6127aea4b8cd9964a50436bb74b18896d746 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
+2005-06-15: Kalle Wallin <kaw@linux.se>
+ * Added configuraton option screen-list
+
2005-06-14: Kalle Wallin <kaw@linux.se>
* Moved list window state code to list_window.c
+ * mpdclient.c: added exact_match parameter to
+ mpdclient_filelist_search()
+ * screen_artist.c: support adding of artists and albums (all songs)
2005-06-11: Kalle Wallin <kaw@linux.se>
* configure.ac: support wide-char ncurses library (--with-ncursesw)
diff --git a/doc/config.sample b/doc/config.sample
index f3bcab541af3bd872a56735145d5af32f6ef89a5..7be4181c68ccd7054a1725b6eb64f459e1da09ac 100644 (file)
--- a/doc/config.sample
+++ b/doc/config.sample
## Configuration file for ncmpc (~/.ncmpc/config)
##
+## screen list - used when navigating with next-screen (tab) and
+## previous-screen (shift+tab)
+## names: playlist browse help artist clock
+#screen-list = playlist artist
+
## auto center (center the playing track in the playlist)
#auto-center = no
diff --git a/src/conf.c b/src/conf.c
index 7e4b4e1aea86da786d83ad57db409c591c3b9f55..73135b8f64ce8875c9e407a9673fc8dbef054bb7 100644 (file)
--- a/src/conf.c
+++ b/src/conf.c
#define CONF_SEARCH_MODE "search-mode"
#define CONF_HIDE_CURSOR "hide-cursor"
#define CONF_SEEK_TIME "seek-time"
+#define CONF_SCREEN_LIST "screen-list"
typedef enum {
KEY_PARSER_UNKNOWN,
KEY_PARSER_DONE
} key_parser_state_t;
+
+extern gint screen_get_id(char *name);
+
+
static gboolean
str2bool(char *str)
{
return g_strdup(str);
}
+static char **
+check_screen_list(char *value)
+{
+ char **tmp = g_strsplit_set(value, " \t,", 100);
+ char **screen = NULL;
+ int i,j;
+
+ i=0;
+ j=0;
+ while( tmp && tmp[i] )
+ {
+ tmp[i] = lowerstr(tmp[i]);
+ if( screen_get_id(tmp[i]) == -1 )
+ fprintf(stderr,
+ _("Error: Unsupported screen \"%s\"\n"),
+ tmp[i]);
+ else
+ {
+ screen = g_realloc(screen, (j+2)*sizeof(char *));
+ screen[j++] = g_strdup(tmp[i]);
+ screen[j] = NULL;
+ }
+ i++;
+ }
+ g_strfreev(tmp);
+ if( screen == NULL )
+ return g_strsplit_set(DEFAULT_SCREEN_LIST, " ", 0);
+
+ return screen;
+}
static int
read_rc_file(char *filename, options_t *options)
{
options->seek_time = atoi(value);
}
+ else if( !strcasecmp(CONF_SCREEN_LIST, name) )
+ {
+ g_strfreev(options->screen_list);
+ options->screen_list = check_screen_list(value);
+
+#ifdef DEBUG
+ D("screen-list:");
+ j=0;
+ while(options->screen_list[j])
+ D(" %s", options->screen_list[j++]);
+ D("\n");
+#endif
+ }
else
{
match_found = 0;
}
-
if( !match_found )
fprintf(stderr,
diff --git a/src/ncmpc.h b/src/ncmpc.h
index 194d7ac5cf0f684d72bf13eb4d6c726c91725fcf..4d3b840a524e89df6066c4caeba8e3235c70d021 100644 (file)
--- a/src/ncmpc.h
+++ b/src/ncmpc.h
/* welcome message time [s] */
#define SCREEN_WELCOME_TIME 10
+/* screen list */
+#define DEFAULT_SCREEN_LIST "playlist browse"
+
/* status message time [s] */
#define SCREEN_STATUS_MESSAGE_TIME 3
diff --git a/src/options.c b/src/options.c
index e1ed99e632be2a7ccf77248cb48f3fa60fb3b571..dd31203b63bb1210ee77436a4e3d66545f3a45e4 100644 (file)
--- a/src/options.c
+++ b/src/options.c
options.audible_bell = TRUE;
options.crossfade_time = DEFAULT_CROSSFADE_TIME;
options.seek_time = 1;
+ options.screen_list = g_strsplit_set(DEFAULT_SCREEN_LIST, " ", 0);
return &options;
}
diff --git a/src/options.h b/src/options.h
index 3f203b09c1793d9dc3046cb03efef8964dbbc644..6acf88b0902ccc03a9754d33fdab619abb61be5e 100644 (file)
--- a/src/options.h
+++ b/src/options.h
char *list_format;
char *status_format;
char *xterm_title_format;
+ char **screen_list;
int port;
int crossfade_time;
int search_mode;
diff --git a/src/screen.c b/src/screen.c
index b5a1d473a4645f303abf67c156c0bf6871d46b0d..b947190011aac6beaf6c1dd71f0390dca3ef5214 100644 (file)
--- a/src/screen.c
+++ b/src/screen.c
static screen_mode_info_t screens[] = {
{ SCREEN_PLAYLIST_ID, "playlist", get_screen_playlist },
{ SCREEN_BROWSE_ID, "browse", get_screen_browse },
- { SCREEN_HELP_ID, "help", get_screen_help },
#ifdef ENABLE_ARTIST_SCREEN
{ SCREEN_ARTIST_ID, "artist", get_screen_artist },
#endif
+ { SCREEN_HELP_ID, "help", get_screen_help },
#ifdef ENABLE_SEARCH_SCREEN
{ SCREEN_SEARCH_ID, "search", get_screen_search },
#endif
static int seek_id = -1;
static int seek_target_time = 0;
+gint
+screen_get_id(char *name)
+{
+ gint i=0;
+
+ while( screens[i].name )
+ {
+ if( strcmp(name, screens[i].name) == 0 )
+ return screens[i].id;
+ i++;
+ }
+ return -1;
+}
+
static gint
lookup_mode(gint id)
{
}
+static void
+screen_next_mode(mpdclient_t *c, int offset)
+{
+ int max = g_strv_length(options.screen_list);
+ int current, next;
+ int i;
+
+ /* find current screen */
+ current = -1;
+ i = 0;
+ while( options.screen_list[i] )
+ {
+ if( strcmp(options.screen_list[i], screens[screen->mode].name) == 0 )
+ current = i;
+ i++;
+ }
+ next = current + offset;
+ if( next<0 )
+ next = max-1;
+ else if( next>=max )
+ next = 0;
+
+ D("current mode: %d:%d next:%d\n", current, max, next);
+ switch_screen_mode(screen_get_id(options.screen_list[next]), c);
+}
+
static void
paint_top_window(char *header, mpdclient_t *c, int clear)
{
i++;
}
+#if 0
+ /* broken */
+ mode_fn = NULL;
+ switch_screen_mode(screen_get_id(options.screen_list[0]), c);
+#else
mode_fn = get_screen_playlist();
+#endif
+
if( mode_fn && mode_fn->open )
mode_fn->open(screen, c);
screen->painted = 0;
break;
case CMD_SCREEN_PREVIOUS:
- if( screen->mode > 0 )
- switch_screen_mode(screens[screen->mode-1].id, c);
- else
- switch_screen_mode(lookup_mode(SCREEN_HELP_ID)-1, c);
+ screen_next_mode(c, -1);
break;
case CMD_SCREEN_NEXT:
- if( screens[screen->mode+1].id < SCREEN_HELP_ID )
- switch_screen_mode(screens[screen->mode+1].id, c);
- else
- switch_screen_mode(screens[0].id, c);
+ screen_next_mode(c, 1);
break;
case CMD_SCREEN_PLAY:
switch_screen_mode(SCREEN_PLAYLIST_ID, c);