aboutsummaryrefslogtreecommitdiffstats
path: root/src/screen_browser.c
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2008-09-19 16:24:37 +0200
committerMax Kellermann <max@duempel.org>2008-09-19 16:24:37 +0200
commit6bf491217a2543365118839d616933ba43879dda (patch)
tree2f693e6f74cc11d6cb6f1ebf32de0e2000cebb33 /src/screen_browser.c
parent1982b42e73af9e6272c9e7fe803be3739847dcbe (diff)
downloadmpd-6bf491217a2543365118839d616933ba43879dda.tar.gz
mpd-6bf491217a2543365118839d616933ba43879dda.tar.xz
mpd-6bf491217a2543365118839d616933ba43879dda.zip
browser: added function browser_get_selected()
browser_get_selected() checks if there is a file list and a valid selection, and returns the selected entry.
Diffstat (limited to '')
-rw-r--r--src/screen_browser.c20
1 files changed, 11 insertions, 9 deletions
diff --git a/src/screen_browser.c b/src/screen_browser.c
index 40c639980..b01e70c7a 100644
--- a/src/screen_browser.c
+++ b/src/screen_browser.c
@@ -247,16 +247,21 @@ enqueue_and_play(mpdclient_t *c, filelist_entry_t *entry)
return 0;
}
+static struct filelist_entry *
+browser_get_selected(const struct screen_browser *browser)
+{
+ if (browser->filelist == NULL)
+ return NULL;
+
+ return filelist_get(browser->filelist, browser->lw->selected);
+}
+
int
browser_handle_enter(struct screen_browser *browser, mpdclient_t *c)
{
- filelist_entry_t *entry;
+ struct filelist_entry *entry = browser_get_selected(browser);
mpd_InfoEntity *entity;
- if (browser->filelist == NULL)
- return -1;
-
- entry = filelist_get(browser->filelist, browser->lw->selected);
if( entry==NULL )
return -1;
@@ -379,11 +384,8 @@ browser_select_entry(mpdclient_t *c, filelist_entry_t *entry,
int
browser_handle_select(struct screen_browser *browser, mpdclient_t *c)
{
- filelist_entry_t *entry;
+ struct filelist_entry *entry = browser_get_selected(browser);
- if (browser->filelist == NULL)
- return -1;
- entry = filelist_get(browser->filelist, browser->lw->selected);
if (entry == NULL || entry->entity == NULL)
return -1;