From 94a8c60f3df33e42df79cd33822bfe5074b56afa Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Thu, 1 Oct 2009 19:40:49 +0200 Subject: [PATCH] screen: moved screen_interface externs to each screen header Make a header for each screen implementation. --- Makefile.am | 9 ++++++++- src/screen.c | 9 +++++++++ src/screen.h | 33 +-------------------------------- src/screen_artist.c | 10 +++------- src/screen_artist.h | 29 +++++++++++++++++++++++++++++ src/screen_browser.c | 2 ++ src/screen_file.c | 4 +--- src/screen_file.h | 2 ++ src/screen_help.c | 5 +---- src/screen_help.h | 29 +++++++++++++++++++++++++++++ src/screen_keydef.c | 5 +---- src/screen_keydef.h | 29 +++++++++++++++++++++++++++++ src/screen_list.c | 9 +++++++++ src/screen_list.h | 23 +---------------------- src/screen_lyrics.c | 4 +++- src/screen_lyrics.h | 40 ++++++++++++++++++++++++++++++++++++++++ src/screen_outputs.c | 1 + src/screen_outputs.h | 29 +++++++++++++++++++++++++++++ src/screen_play.c | 9 ++++----- src/screen_play.h | 17 +++++++++++++---- src/screen_search.c | 4 +--- src/screen_search.h | 29 +++++++++++++++++++++++++++++ src/screen_song.c | 2 ++ src/screen_song.h | 37 +++++++++++++++++++++++++++++++++++++ 24 files changed, 284 insertions(+), 86 deletions(-) create mode 100644 src/screen_artist.h create mode 100644 src/screen_help.h create mode 100644 src/screen_keydef.h create mode 100644 src/screen_lyrics.h create mode 100644 src/screen_outputs.h create mode 100644 src/screen_search.h create mode 100644 src/screen_song.h diff --git a/Makefile.am b/Makefile.am index 91c83b2..65620e3 100644 --- a/Makefile.am +++ b/Makefile.am @@ -28,7 +28,6 @@ ncmpc_headers = \ src/screen.h \ src/screen_interface.h \ src/screen_list.h \ - src/screen_play.h \ src/screen_utils.h \ src/screen_client.h \ src/list_window.h \ @@ -42,8 +41,16 @@ ncmpc_headers = \ src/ncmpc.h \ src/defaults.h \ src/i18n.h \ + src/screen_help.h \ + src/screen_play.h \ src/screen_file.h \ + src/screen_artist.h \ src/screen_browser.h \ + src/screen_search.h \ + src/screen_song.h \ + src/screen_keydef.h \ + src/screen_lyrics.h \ + src/screen_outputs.h \ src/screen_text.h \ src/plugin.h \ src/lyrics.h \ diff --git a/src/screen.c b/src/screen.c index 34330ff..cf99538 100644 --- a/src/screen.c +++ b/src/screen.c @@ -29,6 +29,15 @@ #include "options.h" #include "colors.h" #include "player_command.h" +#include "screen_help.h" +#include "screen_play.h" +#include "screen_file.h" +#include "screen_artist.h" +#include "screen_search.h" +#include "screen_song.h" +#include "screen_keydef.h" +#include "screen_lyrics.h" +#include "screen_outputs.h" #include diff --git a/src/screen.h b/src/screen.h index b20a6c9..a78ae51 100644 --- a/src/screen.h +++ b/src/screen.h @@ -44,6 +44,7 @@ #define MAX_SONGNAME_LENGTH 512 struct mpdclient; +struct screen_functions; struct screen { struct title_bar title_bar; @@ -65,28 +66,6 @@ struct screen { extern struct screen screen; -extern const struct screen_functions screen_playlist; -extern const struct screen_functions screen_browse; -#ifdef ENABLE_ARTIST_SCREEN -extern const struct screen_functions screen_artist; -#endif -extern const struct screen_functions screen_help; -#ifdef ENABLE_SEARCH_SCREEN -extern const struct screen_functions screen_search; -#endif -#ifdef ENABLE_SONG_SCREEN -extern const struct screen_functions screen_song; -#endif -#ifdef ENABLE_KEYDEF_SCREEN -extern const struct screen_functions screen_keydef; -#endif -#ifdef ENABLE_LYRICS_SCREEN -extern const struct screen_functions screen_lyrics; -#endif -#ifdef ENABLE_OUTPUTS_SCREEN -extern const struct screen_functions screen_outputs; -#endif - void screen_init(struct mpdclient *c); void screen_exit(void); void screen_resize(struct mpdclient *c); @@ -109,14 +88,4 @@ screen_is_visible(const struct screen_functions *sf); int screen_get_mouse_event(struct mpdclient *c, unsigned long *bstate, int *row); -#ifdef ENABLE_SONG_SCREEN -void -screen_song_switch(struct mpdclient *c, const struct mpd_song *song); -#endif - -#ifdef ENABLE_LYRICS_SCREEN -void -screen_lyrics_switch(struct mpdclient *c, const struct mpd_song *song, bool follow); -#endif - #endif diff --git a/src/screen_artist.c b/src/screen_artist.c index d3c1822..eb1e449 100644 --- a/src/screen_artist.c +++ b/src/screen_artist.c @@ -17,20 +17,16 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ +#include "screen_artist.h" +#include "screen_interface.h" #include "i18n.h" -#include "options.h" #include "charset.h" #include "mpdclient.h" -#include "utils.h" -#include "strfsong.h" -#include "command.h" -#include "screen_interface.h" #include "screen_utils.h" #include "screen_browser.h" #include "filelist.h" -#include -#include +#include #include #include diff --git a/src/screen_artist.h b/src/screen_artist.h new file mode 100644 index 0000000..60ebd9b --- /dev/null +++ b/src/screen_artist.h @@ -0,0 +1,29 @@ +/* ncmpc (Ncurses MPD Client) + * (c) 2004-2009 The Music Player Daemon Project + * Project homepage: http://musicpd.org + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#ifndef NCMPC_SCREEN_ARTIST_H +#define NCMPC_SCREEN_ARTIST_H + +#include "config.h" + +#ifdef ENABLE_ARTIST_SCREEN +extern const struct screen_functions screen_artist; +#endif + +#endif diff --git a/src/screen_browser.c b/src/screen_browser.c index 65fefbd..9577123 100644 --- a/src/screen_browser.c +++ b/src/screen_browser.c @@ -19,6 +19,8 @@ #include "screen_browser.h" #include "screen_file.h" +#include "screen_song.h" +#include "screen_lyrics.h" #include "i18n.h" #include "options.h" #include "charset.h" diff --git a/src/screen_file.c b/src/screen_file.c index 53997a5..47efc9b 100644 --- a/src/screen_file.c +++ b/src/screen_file.c @@ -18,16 +18,14 @@ */ #include "screen_file.h" +#include "screen_browser.h" #include "screen_interface.h" #include "config.h" #include "i18n.h" -#include "options.h" #include "charset.h" #include "mpdclient.h" #include "filelist.h" -#include "command.h" #include "screen_utils.h" -#include "screen_browser.h" #include "screen_play.h" #include "screen_client.h" diff --git a/src/screen_file.h b/src/screen_file.h index 775bc61..c2e640c 100644 --- a/src/screen_file.h +++ b/src/screen_file.h @@ -25,6 +25,8 @@ struct mpdclient; struct mpd_song; +extern const struct screen_functions screen_browse; + bool screen_file_goto_song(struct mpdclient *c, const struct mpd_song *song); diff --git a/src/screen_help.c b/src/screen_help.c index 5aa579f..042478a 100644 --- a/src/screen_help.c +++ b/src/screen_help.c @@ -17,15 +17,12 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ +#include "screen_help.h" #include "screen_interface.h" #include "config.h" #include "i18n.h" -#include "mpdclient.h" -#include "command.h" #include "screen_utils.h" -#include -#include #include typedef struct { diff --git a/src/screen_help.h b/src/screen_help.h new file mode 100644 index 0000000..6323e33 --- /dev/null +++ b/src/screen_help.h @@ -0,0 +1,29 @@ +/* ncmpc (Ncurses MPD Client) + * (c) 2004-2009 The Music Player Daemon Project + * Project homepage: http://musicpd.org + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#ifndef NCMPC_SCREEN_HELP_H +#define NCMPC_SCREEN_HELP_H + +#include "config.h" + +#ifdef ENABLE_HELP_SCREEN +extern const struct screen_functions screen_help; +#endif + +#endif diff --git a/src/screen_keydef.c b/src/screen_keydef.c index 5809cd2..30f85ac 100644 --- a/src/screen_keydef.c +++ b/src/screen_keydef.c @@ -17,17 +17,14 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ +#include "screen_keydef.h" #include "screen_interface.h" #include "i18n.h" -#include "mpdclient.h" -#include "options.h" #include "conf.h" -#include "command.h" #include "screen.h" #include "screen_utils.h" #include -#include #include #include diff --git a/src/screen_keydef.h b/src/screen_keydef.h new file mode 100644 index 0000000..2eb2444 --- /dev/null +++ b/src/screen_keydef.h @@ -0,0 +1,29 @@ +/* ncmpc (Ncurses MPD Client) + * (c) 2004-2009 The Music Player Daemon Project + * Project homepage: http://musicpd.org + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#ifndef NCMPC_SCREEN_KEYDEF_H +#define NCMPC_SCREEN_KEYDEF_H + +#include "config.h" + +#ifdef ENABLE_KEYDEF_SCREEN +extern const struct screen_functions screen_keydef; +#endif /* ENABLE_KEYDEF_SCREEN */ + +#endif diff --git a/src/screen_list.c b/src/screen_list.c index 49f6037..8f218a1 100644 --- a/src/screen_list.c +++ b/src/screen_list.c @@ -20,6 +20,15 @@ #include "screen_list.h" #include "screen_interface.h" #include "screen.h" +#include "screen_help.h" +#include "screen_play.h" +#include "screen_file.h" +#include "screen_artist.h" +#include "screen_search.h" +#include "screen_song.h" +#include "screen_keydef.h" +#include "screen_lyrics.h" +#include "screen_outputs.h" #include diff --git a/src/screen_list.h b/src/screen_list.h index 2f9cffd..9f6c926 100644 --- a/src/screen_list.h +++ b/src/screen_list.h @@ -28,28 +28,7 @@ #include #endif -extern const struct screen_functions screen_playlist; -extern const struct screen_functions screen_browse; -#ifdef ENABLE_ARTIST_SCREEN -extern const struct screen_functions screen_artist; -#endif -extern const struct screen_functions screen_help; -#ifdef ENABLE_SEARCH_SCREEN -extern const struct screen_functions screen_search; -#endif -#ifdef ENABLE_SONG_SCREEN -extern const struct screen_functions screen_song; -#endif -#ifdef ENABLE_KEYDEF_SCREEN -extern const struct screen_functions screen_keydef; -#endif -#ifdef ENABLE_LYRICS_SCREEN -extern const struct screen_functions screen_lyrics; -#endif -#ifdef ENABLE_OUTPUTS_SCREEN -extern const struct screen_functions screen_outputs; -#endif - +struct screen_functions; void screen_list_init(WINDOW *w, unsigned cols, unsigned rows); diff --git a/src/screen_lyrics.c b/src/screen_lyrics.c index 054ac62..928a42e 100644 --- a/src/screen_lyrics.c +++ b/src/screen_lyrics.c @@ -17,16 +17,18 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ +#include "screen_lyrics.h" #include "screen_interface.h" #include "screen_file.h" +#include "screen_song.h" #include "i18n.h" #include "options.h" #include "mpdclient.h" -#include "command.h" #include "screen.h" #include "lyrics.h" #include "screen_text.h" +#include #include #include #include diff --git a/src/screen_lyrics.h b/src/screen_lyrics.h new file mode 100644 index 0000000..4975165 --- /dev/null +++ b/src/screen_lyrics.h @@ -0,0 +1,40 @@ +/* ncmpc (Ncurses MPD Client) + * (c) 2004-2009 The Music Player Daemon Project + * Project homepage: http://musicpd.org + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#ifndef NCMPC_SCREEN_LYRICS_H +#define NCMPC_SCREEN_LYRICS_H + +#include "config.h" + +#ifdef ENABLE_LYRICS_SCREEN + +#include + +struct mpdclient; +struct mpd_song; + +extern const struct screen_functions screen_lyrics; + +void +screen_lyrics_switch(struct mpdclient *c, const struct mpd_song *song, + bool follow); + +#endif /* ENABLE_LYRICS_SCREEN */ + +#endif diff --git a/src/screen_outputs.c b/src/screen_outputs.c index 75b9790..7f64bd0 100644 --- a/src/screen_outputs.c +++ b/src/screen_outputs.c @@ -17,6 +17,7 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ +#include "screen_outputs.h" #include "screen_interface.h" #include "i18n.h" #include "screen.h" diff --git a/src/screen_outputs.h b/src/screen_outputs.h new file mode 100644 index 0000000..36a0332 --- /dev/null +++ b/src/screen_outputs.h @@ -0,0 +1,29 @@ +/* ncmpc (Ncurses MPD Client) + * (c) 2004-2009 The Music Player Daemon Project + * Project homepage: http://musicpd.org + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#ifndef NCMPC_SCREEN_OUTPUTS_H +#define NCMPC_SCREEN_OUTPUTS_H + +#include "config.h" + +#ifdef ENABLE_OUTPUTS_SCREEN +extern const struct screen_functions screen_outputs; +#endif /* ENABLE_OUTPUTS_SCREEN */ + +#endif diff --git a/src/screen_play.c b/src/screen_play.c index bd830ba..ceb1361 100644 --- a/src/screen_play.c +++ b/src/screen_play.c @@ -17,8 +17,9 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ -#include "screen_file.h" +#include "screen_play.h" #include "screen_interface.h" +#include "screen_file.h" #include "config.h" #include "i18n.h" #include "charset.h" @@ -27,11 +28,11 @@ #include "utils.h" #include "strfsong.h" #include "wreadln.h" -#include "command.h" #include "colors.h" #include "screen.h" #include "screen_utils.h" -#include "screen_play.h" +#include "screen_song.h" +#include "screen_lyrics.h" #ifndef NCMPC_MINI #include "hscroll.h" @@ -40,9 +41,7 @@ #include #include -#include #include -#include #include #define MAX_SONG_LENGTH 512 diff --git a/src/screen_play.h b/src/screen_play.h index 3cccfb8..9c77677 100644 --- a/src/screen_play.h +++ b/src/screen_play.h @@ -1,21 +1,30 @@ /* ncmpc (Ncurses MPD Client) * (c) 2004-2009 The Music Player Daemon Project * Project homepage: http://musicpd.org - + * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. - + * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. - + * * You should have received a copy of the GNU General Public License along * with this program; if not, write to the Free Software Foundation, Inc., * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. -*/ + */ + +#ifndef NCMPC_SCREEN_PLAY_H +#define NCMPC_SCREEN_PLAY_H + +struct mpdclient; + +extern const struct screen_functions screen_playlist; int playlist_save(struct mpdclient *c, char *name, char *defaultname); + +#endif diff --git a/src/screen_search.c b/src/screen_search.c index 66b05b5..d7e49aa 100644 --- a/src/screen_search.c +++ b/src/screen_search.c @@ -17,20 +17,18 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ +#include "screen_search.h" #include "screen_interface.h" #include "i18n.h" #include "options.h" #include "charset.h" #include "mpdclient.h" #include "strfsong.h" -#include "command.h" #include "utils.h" #include "screen_utils.h" #include "screen_browser.h" #include "filelist.h" -#include -#include #include #include diff --git a/src/screen_search.h b/src/screen_search.h new file mode 100644 index 0000000..3c807ed --- /dev/null +++ b/src/screen_search.h @@ -0,0 +1,29 @@ +/* ncmpc (Ncurses MPD Client) + * (c) 2004-2009 The Music Player Daemon Project + * Project homepage: http://musicpd.org + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#ifndef NCMPC_SCREEN_SEARCH_H +#define NCMPC_SCREEN_SEARCH_H + +#include "config.h" + +#ifdef ENABLE_SEARCH_SCREEN +extern const struct screen_functions screen_search; +#endif + +#endif diff --git a/src/screen_song.c b/src/screen_song.c index 7b6ec6f..eeb2f11 100644 --- a/src/screen_song.c +++ b/src/screen_song.c @@ -17,8 +17,10 @@ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ +#include "screen_song.h" #include "screen_interface.h" #include "screen_file.h" +#include "screen_lyrics.h" #include "i18n.h" #include "screen.h" #include "screen_utils.h" diff --git a/src/screen_song.h b/src/screen_song.h new file mode 100644 index 0000000..ac229af --- /dev/null +++ b/src/screen_song.h @@ -0,0 +1,37 @@ +/* ncmpc (Ncurses MPD Client) + * (c) 2004-2009 The Music Player Daemon Project + * Project homepage: http://musicpd.org + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License along + * with this program; if not, write to the Free Software Foundation, Inc., + * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + */ + +#ifndef NCMPC_SCREEN_SONG_H +#define NCMPC_SCREEN_SONG_H + +#include "config.h" + +#ifdef ENABLE_SONG_SCREEN + +struct mpdclient; +struct mpd_song; + +extern const struct screen_functions screen_song; + +void +screen_song_switch(struct mpdclient *c, const struct mpd_song *song); + +#endif /* ENABLE_SONG_SCREEN */ + +#endif -- 2.30.2