From 2223680504a47af66d340fbc4a531beac44b5c96 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?P=C5=99emysl=20Janouch?=
Date: Mon, 5 Jun 2017 00:18:53 +0200
Subject: [PATCH] Add interface for database updates
---
nncmpp.c | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)
diff --git a/nncmpp.c b/nncmpp.c
index 758c25d..70fda7e 100644
--- a/nncmpp.c
+++ b/nncmpp.c
@@ -1275,7 +1275,9 @@ app_write_mpd_status (struct row_buffer *buf)
// TODO: "N hours N minutes" ("stats" -> "playtime" or count in code)
char *stats;
- if (g.playlist.len == 1)
+ if (str_map_find (map, "updating_db"))
+ stats = xstrdup ("Updating database...");
+ else if (g.playlist.len == 1)
stats = xstrdup_printf ("%zu song", g.playlist.len);
else
stats = xstrdup_printf ("%zu songs", g.playlist.len);
@@ -1314,7 +1316,6 @@ app_draw_statusbar (void)
struct row_buffer buf;
row_buffer_init (&buf);
- // TODO: task status such as "Updating database..."
if (g.message)
row_buffer_append (&buf, g.message, APP_ATTR (HIGHLIGHT));
else if (g.client.state == MPD_CONNECTED)
@@ -1459,6 +1460,7 @@ app_goto_tab (int tab_index)
\
XX( MPD_ADD, "Add song to playlist" ) \
XX( MPD_REPLACE, "Replace playlist with song" ) \
+ XX( MPD_UPDATE_DB, "Update MPD database" ) \
\
XX( CHOOSE, "Choose item" ) \
XX( DELETE, "Delete item" ) \
@@ -1569,6 +1571,12 @@ app_process_action (enum action action)
app_switch_tab (g.help_tab);
break;
+// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
+
+ case ACTION_MPD_UPDATE_DB:
+ MPD_SIMPLE ("update");
+ break;
+
// - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
case ACTION_MPD_PREVIOUS:
@@ -1791,6 +1799,7 @@ g_default_bindings[] =
{ "Backspace", ACTION_UP, {}},
{ "a", ACTION_MPD_ADD, {}},
{ "r", ACTION_MPD_REPLACE, {}},
+ { "u", ACTION_MPD_UPDATE_DB, {}},
{ "Left", ACTION_MPD_PREVIOUS, {}},
{ "Right", ACTION_MPD_NEXT, {}},
@@ -2827,7 +2836,7 @@ mpd_on_events (unsigned subsystems, void *user_data)
library_tab_reload (NULL);
if (subsystems & (MPD_SUBSYSTEM_PLAYER | MPD_SUBSYSTEM_OPTIONS
- | MPD_SUBSYSTEM_PLAYLIST | MPD_SUBSYSTEM_MIXER))
+ | MPD_SUBSYSTEM_PLAYLIST | MPD_SUBSYSTEM_MIXER | MPD_SUBSYSTEM_UPDATE))
mpd_request_info ();
else
mpd_client_idle (c, 0);