diff --git a/src/status_bar.c b/src/status_bar.c
index c6357f43e6b5f1caab63032d27a96bb30176ab3c..fc63d20e49e0d4fa4b50df1e5ac9b63e9da523db 100644 (file)
--- a/src/status_bar.c
+++ b/src/status_bar.c
/* ncmpc (Ncurses MPD Client)
- * (c) 2004-2010 The Music Player Daemon Project
+ * (c) 2004-2017 The Music Player Daemon Project
* Project homepage: http://musicpd.org
*
* This program is free software; you can redistribute it and/or modify
#include "charset.h"
#include "strfsong.h"
#include "player_command.h"
-#include "utils.h"
+#include "time_format.h"
#include <mpd/client.h>
#endif
}
-static gboolean
-status_bar_clear_message(gpointer data)
+void
+status_bar_clear_message(struct status_bar *p)
{
- struct status_bar *p = data;
- WINDOW *w = p->window.w;
-
assert(p != NULL);
- assert(p->message_source_id != 0);
- p->message_source_id = 0;
+ if (p->message_source_id != 0) {
+ g_source_remove(p->message_source_id);
+ p->message_source_id = 0;
+ }
+
+ WINDOW *w = p->window.w;
wmove(w, 0, 0);
wclrtoeol(w);
wrefresh(w);
-
- return false;
}
#ifndef NCMPC_MINI
const struct mpd_song *song)
{
WINDOW *w = p->window.w;
- enum mpd_state state;
- const char *str = NULL;
- int x = 0;
char buffer[p->window.cols * 4 + 1];
#ifndef NCMPC_MINI
wclrtoeol(w);
colors_use(w, COLOR_STATUS_BOLD);
- state = status == NULL ? MPD_STATE_UNKNOWN
+ enum mpd_state state = status == NULL ? MPD_STATE_UNKNOWN
: mpd_status_get_state(status);
+ const char *str = NULL;
switch (state) {
case MPD_STATE_PLAY:
str = _("Playing:");
break;
}
+ int x = 0;
if (str) {
waddstr(w, str);
x += utf8_width(str) + 1;
#endif
}
} else {
-#ifndef NCMPC_MINI
- if (options.display_time) {
- time_t timep;
-
- time(&timep);
- strftime(buffer, sizeof(buffer), "%X ",localtime(&timep));
- } else
-#endif
- buffer[0] = 0;
+ buffer[0] = 0;
}
/* display song */
mvwin(p->window.w, y, x);
}
+static gboolean
+status_bar_clear_message_cb(gpointer data)
+{
+ struct status_bar *p = data;
+ assert(p->message_source_id != 0);
+ p->message_source_id = 0;
+
+ status_bar_clear_message(p);
+ return false;
+}
+
void
status_bar_message(struct status_bar *p, const char *msg)
{
if (p->message_source_id != 0)
g_source_remove(p->message_source_id);
- p->message_source_id = g_timeout_add(options.status_message_time * 1000,
- status_bar_clear_message, p);
+ p->message_source_id = g_timeout_add_seconds(options.status_message_time,
+ status_bar_clear_message_cb, p);
}