Code

screen: method cmd() returns bool
authorMax Kellermann <max@duempel.org>
Tue, 18 Nov 2008 21:09:23 +0000 (22:09 +0100)
committerMax Kellermann <max@duempel.org>
Tue, 18 Nov 2008 21:09:23 +0000 (22:09 +0100)
Return true/false instead of 1/0.

src/screen.h
src/screen_artist.c
src/screen_file.c
src/screen_help.c
src/screen_keydef.c
src/screen_lyrics.c
src/screen_play.c
src/screen_search.c

index 5eb6cba207b98929db3ad8d5f5b92f7349fcbc74..5d7737973d2d0649c994cf328f9edd4dde5d2967 100644 (file)
@@ -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;
 
index 74fd96c1aed9a755543d07d7f2fb6b27d89d5855..01fbc9c1fbc35184f6d0ff5200446ff19bbfb711 100644 (file)
@@ -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 = {
index a934ef2763ffa79c271be662cf05154045d3ef5e..d7742879131a150bfeacdd0bc589e8b0411c0993 100644 (file)
@@ -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 = {
index e462ddc907897d86dfdd109e72f121015ba0c41e..423e85f59932cb843a67b6ab3ce23c7becc1881f 100644 (file)
@@ -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 = {
index 4e42b386f2975d5002dddfa603572876a480c554..509a44fc5e929110619e0d186826af579e8215ad 100644 (file)
@@ -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 = {
index 30a89a163973ddaf8f29143bf2bd5c88fdea20f1..9cffd57770e1d0d19feede84b6c8f7778e60c59b 100644 (file)
@@ -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 = {
index 1e0dcaa280759c05d74fd02246f1ac1ab592c895..4b50f7459916481650c5735c6732f2ce6b055c39 100644 (file)
@@ -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 = {
index e5239b0c74b97ce24c033fc5b887f642ec013174..277a9e2775c82f4b6151b27703c85a8e9fd4c7a8 100644 (file)
@@ -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 = {