From 4eb970945e85a5f7c5ac768a44d5bca03c824b97 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Tue, 18 Nov 2008 22:09:23 +0100 Subject: [PATCH] screen: method cmd() returns bool Return true/false instead of 1/0. --- src/screen.h | 2 +- src/screen_artist.c | 12 ++++++------ src/screen_file.c | 16 ++++++++-------- src/screen_help.c | 8 ++++---- src/screen_keydef.c | 12 ++++++------ src/screen_lyrics.c | 14 +++++++------- src/screen_play.c | 32 ++++++++++++++++---------------- src/screen_search.c | 12 ++++++------ 8 files changed, 54 insertions(+), 54 deletions(-) diff --git a/src/screen.h b/src/screen.h index 5eb6cba..5d77379 100644 --- a/src/screen.h +++ b/src/screen.h @@ -71,7 +71,7 @@ typedef struct screen_functions { void (*resize)(int cols, int rows); void (*paint)(void); void (*update)(mpdclient_t *c); - int (*cmd)(mpdclient_t *c, command_t cmd); + bool (*cmd)(mpdclient_t *c, command_t cmd); const char *(*get_title)(char *s, size_t size); } screen_functions_t; diff --git a/src/screen_artist.c b/src/screen_artist.c index 74fd96c..01fbc9c 100644 --- a/src/screen_artist.c +++ b/src/screen_artist.c @@ -461,7 +461,7 @@ string_array_find(GPtrArray *array, const char *value) return -1; } -static int +static bool artist_cmd(mpdclient_t *c, command_t cmd) { char *selected; @@ -632,7 +632,7 @@ artist_cmd(mpdclient_t *c, command_t cmd) case CMD_SCREEN_UPDATE: reload_lists(c); screen_status_printf(_("Screen updated!")); - return 0; + return false; case CMD_LIST_FIND: case CMD_LIST_RFIND: @@ -643,13 +643,13 @@ artist_cmd(mpdclient_t *c, command_t cmd) screen_find(browser.lw, artist_list->len, cmd, artist_lw_callback, artist_list); artist_repaint(); - return 1; + return true; case LIST_ALBUMS: screen_find(browser.lw, album_list->len + 2, cmd, artist_lw_callback, album_list); artist_repaint(); - return 1; + return true; case LIST_SONGS: /* handled by browser_cmd() */ @@ -665,10 +665,10 @@ artist_cmd(mpdclient_t *c, command_t cmd) if (artist_lw_cmd(c, cmd)) { if (screen_is_visible(&screen_artist)) artist_repaint(); - return 1; + return true; } - return 0; + return false; } const struct screen_functions screen_artist = { diff --git a/src/screen_file.c b/src/screen_file.c index a934ef2..d774287 100644 --- a/src/screen_file.c +++ b/src/screen_file.c @@ -206,18 +206,18 @@ browse_paint(void) list_window_paint(browser.lw, browser_lw_callback, browser.filelist); } -static int +static bool browse_cmd(mpdclient_t *c, command_t cmd) { switch(cmd) { case CMD_GO_ROOT_DIRECTORY: browser_change_directory(&browser, c, NULL, ""); file_repaint(); - return 1; + return true; case CMD_GO_PARENT_DIRECTORY: browser_change_directory(&browser, c, NULL, ".."); file_repaint(); - return 1; + return true; case CMD_LOCATE: /* don't let browser_cmd() evaluate the locate command @@ -242,11 +242,11 @@ browse_cmd(mpdclient_t *c, command_t cmd) file_repaint(); screen_status_printf(_("Screen updated!")); - return 0; + return false; case CMD_DB_UPDATE: if (c->status == NULL) - return 1; + return true; if (!c->status->updatingDb) { if (mpdclient_cmd_db_update(c, browser.filelist->path) == 0) { @@ -265,7 +265,7 @@ browse_cmd(mpdclient_t *c, command_t cmd) } } else screen_status_printf(_("Database update running...")); - return 1; + return true; default: break; @@ -274,10 +274,10 @@ browse_cmd(mpdclient_t *c, command_t cmd) if (browser_cmd(&browser, c, cmd)) { if (screen_is_visible(&screen_browse)) file_repaint(); - return 1; + return true; } - return 0; + return false; } const struct screen_functions screen_browse = { diff --git a/src/screen_help.c b/src/screen_help.c index e462ddc..423e85f 100644 --- a/src/screen_help.c +++ b/src/screen_help.c @@ -212,13 +212,13 @@ help_paint(void) list_window_paint(lw, list_callback, NULL); } -static int +static bool help_cmd(mpd_unused mpdclient_t *c, command_t cmd) { if (list_window_scroll_cmd(lw, help_text_rows, cmd)) { list_window_paint(lw, list_callback, NULL); wrefresh(lw->w); - return 1; + return true; } lw->selected = lw->start+lw->rows; @@ -228,10 +228,10 @@ help_cmd(mpd_unused mpdclient_t *c, command_t cmd) list_window_center(lw, help_text_rows, lw->selected); list_window_paint(lw, list_callback, NULL); wrefresh(lw->w); - return 1; + return true; } - return 0; + return false; } const struct screen_functions screen_help = { diff --git a/src/screen_keydef.c b/src/screen_keydef.c index 4e42b38..509a44f 100644 --- a/src/screen_keydef.c +++ b/src/screen_keydef.c @@ -292,7 +292,7 @@ keydef_paint(void) list_window_paint(lw, list_callback, NULL); } -static int +static bool keydef_cmd(mpd_unused mpdclient_t *c, command_t cmd) { int length = LIST_LENGTH(); @@ -302,7 +302,7 @@ keydef_cmd(mpd_unused mpdclient_t *c, command_t cmd) if (list_window_cmd(lw, length, cmd)) { keydef_repaint(); - return 1; + return true; } switch(cmd) { @@ -331,11 +331,11 @@ keydef_cmd(mpd_unused mpdclient_t *c, command_t cmd) subcmd, lw->selected - STATIC_SUB_ITEMS); } - return 1; + return true; case CMD_DELETE: if (subcmd >= 0 && lw->selected >= STATIC_SUB_ITEMS) delete_key(subcmd, lw->selected - STATIC_SUB_ITEMS); - return 1; + return true; break; case CMD_SAVE_PLAYLIST: apply_keys(); @@ -348,13 +348,13 @@ keydef_cmd(mpd_unused mpdclient_t *c, command_t cmd) screen_find(lw, length, cmd, list_callback, NULL); keydef_repaint(); - return 1; + return true; default: break; } - return 0; + return false; } const struct screen_functions screen_keydef = { diff --git a/src/screen_lyrics.c b/src/screen_lyrics.c index 30a89a1..9cffd57 100644 --- a/src/screen_lyrics.c +++ b/src/screen_lyrics.c @@ -303,12 +303,12 @@ lyrics_paint(void) list_window_paint(lw, list_callback, NULL); } -static int +static bool lyrics_cmd(mpdclient_t *c, command_t cmd) { if (list_window_scroll_cmd(lw, current.lines->len, cmd)) { lyrics_repaint(); - return 1; + return true; } switch(cmd) { @@ -317,18 +317,18 @@ lyrics_cmd(mpdclient_t *c, command_t cmd) screen_lyrics_abort(); screen_lyrics_clear(); } - return 1; + return true; case CMD_ADD: if (current.loader == NULL && current.artist != NULL && current.title != NULL && store_lyr_hd() == 0) screen_status_message (_("Lyrics saved!")); - return 1; + return true; case CMD_LYRICS_UPDATE: if (c->song != NULL) { screen_lyrics_load(c->song); lyrics_repaint(); } - return 1; + return true; case CMD_LOCATE: if (current.song != NULL) { @@ -348,10 +348,10 @@ lyrics_cmd(mpdclient_t *c, command_t cmd) /* center the row */ list_window_center(lw, current.lines->len, lw->selected); lyrics_repaint(); - return 1; + return true; } - return 0; + return false; } const struct screen_functions screen_lyrics = { diff --git a/src/screen_play.c b/src/screen_play.c index 1e0dcaa..4b50f74 100644 --- a/src/screen_play.c +++ b/src/screen_play.c @@ -460,7 +460,7 @@ play_update(mpdclient_t *c) } #ifdef HAVE_GETMOUSE -static int +static bool handle_mouse_event(struct mpdclient *c) { int row; @@ -470,13 +470,13 @@ handle_mouse_event(struct mpdclient *c) if (screen_get_mouse_event(c, &bstate, &row) || list_window_mouse(lw, playlist_length(playlist), bstate, row)) { playlist_repaint(); - return 1; + return true; } if (bstate & BUTTON1_DOUBLE_CLICKED) { /* stop */ screen_cmd(c, CMD_STOP); - return 1; + return true; } selected = lw->start + row; @@ -495,11 +495,11 @@ handle_mouse_event(struct mpdclient *c) list_window_check_selected(lw, playlist_length(playlist)); playlist_repaint(); - return 1; + return true; } #endif -static int +static bool play_cmd(mpdclient_t *c, command_t cmd) { lw->flags &= ~LW_HIDE_CURSOR; @@ -513,33 +513,33 @@ play_cmd(mpdclient_t *c, command_t cmd) if (list_window_cmd(lw, playlist_length(&c->playlist), cmd)) { playlist_repaint(); - return 1; + return true; } switch(cmd) { case CMD_PLAY: mpdclient_cmd_play(c, lw->selected); - return 1; + return true; case CMD_DELETE: mpdclient_cmd_delete(c, lw->selected); - return 1; + return true; case CMD_SAVE_PLAYLIST: playlist_save(c, NULL, NULL); - return 1; + return true; case CMD_ADD: handle_add_to_playlist(c); - return 1; + return true; case CMD_SCREEN_UPDATE: center_playing_item(c); playlist_repaint(); - return 0; + return false; case CMD_LIST_MOVE_UP: mpdclient_cmd_move(c, lw->selected, lw->selected-1); - return 1; + return true; case CMD_LIST_MOVE_DOWN: mpdclient_cmd_move(c, lw->selected, lw->selected+1); - return 1; + return true; case CMD_LIST_FIND: case CMD_LIST_RFIND: case CMD_LIST_FIND_NEXT: @@ -547,7 +547,7 @@ play_cmd(mpdclient_t *c, command_t cmd) screen_find(lw, playlist_length(&c->playlist), cmd, list_callback, NULL); playlist_repaint(); - return 1; + return true; #ifdef HAVE_GETMOUSE case CMD_MOUSE_EVENT: @@ -566,7 +566,7 @@ play_cmd(mpdclient_t *c, command_t cmd) case CMD_SCREEN_LYRICS: if (lw->selected < playlist_length(&c->playlist)) { screen_lyrics_switch(c, playlist_get(&c->playlist, lw->selected)); - return 1; + return true; } break; @@ -576,7 +576,7 @@ play_cmd(mpdclient_t *c, command_t cmd) break; } - return 0; + return false; } const struct screen_functions screen_playlist = { diff --git a/src/screen_search.c b/src/screen_search.c index e5239b0..277a9e2 100644 --- a/src/screen_search.c +++ b/src/screen_search.c @@ -410,7 +410,7 @@ get_title(char *str, size_t size) return str; } -static int +static bool search_cmd(mpdclient_t *c, command_t cmd) { switch (cmd) { @@ -431,18 +431,18 @@ search_cmd(mpdclient_t *c, command_t cmd) sync_highlights(c, browser.filelist); } search_repaint(); - return 1; + return true; case CMD_SCREEN_SEARCH: search_new(c); search_repaint(); - return 1; + return true; case CMD_CLEAR: search_clear(c, TRUE); list_window_reset(browser.lw); search_repaint(); - return 1; + return true; default: break; @@ -452,10 +452,10 @@ search_cmd(mpdclient_t *c, command_t cmd) browser_cmd(&browser, c, cmd)) { if (screen_is_visible(&screen_search)) search_repaint(); - return 1; + return true; } - return 0; + return false; } const struct screen_functions screen_search = { -- 2.30.2