summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 7086156)
raw | patch | inline | side by side (parent: 7086156)
author | Max Kellermann <max@duempel.org> | |
Tue, 18 Nov 2008 20:50:11 +0000 (21:50 +0100) | ||
committer | Max Kellermann <max@duempel.org> | |
Tue, 18 Nov 2008 20:50:11 +0000 (21:50 +0100) |
Return true/false instead of 0/-1.
src/screen_browser.c | patch | blob | history | |
src/screen_browser.h | patch | blob | history |
diff --git a/src/screen_browser.c b/src/screen_browser.c
index dfae309e3af6195a57064fd05fb38ea76f33564f..a9ed379913edf8b5c31a382be2255f4ed4960057 100644 (file)
--- a/src/screen_browser.c
+++ b/src/screen_browser.c
}
/* chdir */
-int
+bool
browser_change_directory(struct screen_browser *browser, mpdclient_t *c,
filelist_entry_t *entry, const char *new_path)
{
if( entry!=NULL )
entity = entry->entity;
else if( new_path==NULL )
- return -1;
+ return false;
if( entity==NULL ) {
if( entry || 0==strcmp(new_path, "..") ) {
mpd_Directory *dir = entity->info.directory;
path = g_strdup(dir->path);
} else
- return -1;
+ return false;
old_path = g_strdup(browser->filelist->path);
}
g_free(path);
- return 0;
+ return true;
}
-static int
+static bool
load_playlist(mpdclient_t *c, filelist_entry_t *entry)
{
mpd_InfoEntity *entity = entry->entity;
screen_status_printf(_("Loading playlist %s..."),
g_basename(filename));
g_free(filename);
- return 0;
+ return true;
}
-static int
+static bool
enqueue_and_play(mpdclient_t *c, filelist_entry_t *entry)
{
int idx;
screen_status_printf(_("Adding \'%s\' to playlist\n"), buf);
mpdclient_update(c); /* get song id */
} else
- return -1;
+ return false;
#ifndef NCMPC_MINI
}
#endif
idx = playlist_get_index_from_file(c, song->file);
mpdclient_cmd_play(c, idx);
- return 0;
+ return true;
}
static struct filelist_entry *
return filelist_get(browser->filelist, browser->lw->selected);
}
-static int
+static bool
browser_handle_enter(struct screen_browser *browser, mpdclient_t *c)
{
struct filelist_entry *entry = browser_get_selected(browser);
mpd_InfoEntity *entity;
if( entry==NULL )
- return -1;
+ return false;
entity = entry->entity;
if (entity == NULL || entity->type == MPD_INFO_ENTITY_TYPE_DIRECTORY)
return load_playlist(c, entry);
else if (entity->type == MPD_INFO_ENTITY_TYPE_SONG)
return enqueue_and_play(c, entry);
- return -1;
+ return false;
}
}
#endif
-static int
+static bool
browser_select_entry(mpdclient_t *c, filelist_entry_t *entry,
mpd_unused gboolean toggle)
{
g_free(tmp);
}
#endif
- return 0;
+ return true;
}
if (entry->entity->type != MPD_INFO_ENTITY_TYPE_SONG)
- return -1;
+ return false;
assert(entry->entity->info.song != NULL);
#endif
}
- return 0;
+ return true;
}
-static int
+static bool
browser_handle_select(struct screen_browser *browser, mpdclient_t *c)
{
struct filelist_entry *entry = browser_get_selected(browser);
if (entry == NULL || entry->entity == NULL)
- return -1;
+ return false;
return browser_select_entry(c, entry, TRUE);
}
-static int
+static bool
browser_handle_add(struct screen_browser *browser, mpdclient_t *c)
{
struct filelist_entry *entry = browser_get_selected(browser);
if (entry == NULL || entry->entity == NULL)
- return -1;
+ return false;
return browser_select_entry(c, entry, FALSE);
}
return true;
case CMD_SELECT:
- if (browser_handle_select(browser, c) == 0)
+ if (browser_handle_select(browser, c))
/* continue and select next item... */
cmd = CMD_LIST_NEXT;
break;
case CMD_ADD:
- if (browser_handle_add(browser, c) == 0)
+ if (browser_handle_add(browser, c))
/* continue and select next item... */
cmd = CMD_LIST_NEXT;
diff --git a/src/screen_browser.h b/src/screen_browser.h
index 57564f1c948e956f112f91963fd66a0cb996ccf5..6ea17cc18edae90a4def5e3766d6159192a0c34d 100644 (file)
--- a/src/screen_browser.h
+++ b/src/screen_browser.h
const char *browser_lw_callback(unsigned index, int *highlight, void *filelist);
-int
+bool
browser_change_directory(struct screen_browser *browser, mpdclient_t *c,
filelist_entry_t *entry, const char *new_path);