This commit is contained in:
Přemysl Eric Janouch 2017-06-03 23:42:18 +02:00
parent 5721074b48
commit 86b87bee74
Signed by: p
GPG Key ID: B715679E3A361BE6
1 changed files with 22 additions and 25 deletions

View File

@ -1953,6 +1953,19 @@ library_tab_compare (char **a, char **b)
return app_casecmp ((uint8_t *) xa.path, (uint8_t *) xb.path); return app_casecmp ((uint8_t *) xa.path, (uint8_t *) xb.path);
} }
static char *
library_tab_above (void)
{
struct str *path = &g_library_tab.path;
if (!path->len)
return NULL;
char *last_slash;
if ((last_slash = strrchr (path->str, '/')))
return xstrndup (path->str, last_slash - path->str);
return xstrdup ("");
}
static void static void
library_tab_on_data (const struct mpd_response *response, library_tab_on_data (const struct mpd_response *response,
const struct strv *data, void *user_data) const struct strv *data, void *user_data)
@ -1963,20 +1976,12 @@ library_tab_on_data (const struct mpd_response *response,
strv_reset (&g_library_tab.items); strv_reset (&g_library_tab.items);
struct str *path = &g_library_tab.path; char *above = library_tab_above ();
if (path->len) if (above)
{ {
library_tab_add (LIBRARY_ROOT, "", ""); library_tab_add (LIBRARY_ROOT, "", "");
library_tab_add (LIBRARY_UP, "", above);
char *last_slash; free (above);
if ((last_slash = strrchr (path->str, '/')))
{
char *up = xstrndup (path->str, last_slash - path->str);
library_tab_add (LIBRARY_UP, "", up);
free (up);
}
else
library_tab_add (LIBRARY_UP, "", "");
} }
struct str_map map; struct str_map map;
@ -2052,21 +2057,13 @@ library_tab_on_action (enum action action)
return true; return true;
case ACTION_UP: case ACTION_UP:
{ {
// TODO: probably put this in a special function char *above = library_tab_above ();
char *path = g_library_tab.path.str; if (above)
if (!*path)
return false;
char *last_slash;
if ((last_slash = strrchr (path, '/')))
{ {
char *up = xstrndup (path, last_slash - path); library_tab_reload (above);
library_tab_reload (up); free (above);
free (up);
} }
else return above != NULL;
library_tab_reload ("");
return true;
} }
case ACTION_MPD_REPLACE: case ACTION_MPD_REPLACE:
// FIXME: we also need to play it if we've been playing things already // FIXME: we also need to play it if we've been playing things already