Code

screen: moved struct window to window.h
[ncmpc.git] / src / screen.h
1 /* ncmpc (Ncurses MPD Client)
2  * (c) 2004-2009 The Music Player Daemon Project
3  * Project homepage: http://musicpd.org
4  
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
15  * You should have received a copy of the GNU General Public License along
16  * with this program; if not, write to the Free Software Foundation, Inc.,
17  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 */
20 #ifndef SCREEN_H
21 #define SCREEN_H
23 #include "config.h"
24 #include "command.h"
25 #include "window.h"
27 #include <mpd/client.h>
29 #include <glib.h>
31 #ifdef HAVE_NCURSESW_NCURSES_H
32 #include <ncursesw/ncurses.h>
33 #else
34 #include <ncurses.h>
35 #endif
37 #define IS_PLAYING(s) (s==MPD_STATE_PLAY)
38 #define IS_PAUSED(s) (s==MPD_STATE_PAUSE)
39 #define IS_STOPPED(s) (!(IS_PLAYING(s) | IS_PAUSED(s)))
41 #define MAX_SONGNAME_LENGTH   512
43 struct mpdclient;
45 struct screen {
46         struct window top_window;
47         struct window main_window;
48         struct window progress_window;
49         struct window status_window;
51         /* GTime is equivalent to time_t */
52         GTime start_timestamp;
53         GTime status_timestamp;
55         unsigned cols, rows;
57         char *buf;
58         size_t buf_size;
60         char *findbuf;
61         GList *find_history;
62 };
64 extern struct screen screen;
66 extern const struct screen_functions screen_playlist;
67 extern const struct screen_functions screen_browse;
68 #ifdef ENABLE_ARTIST_SCREEN
69 extern const struct screen_functions screen_artist;
70 #endif
71 extern const struct screen_functions screen_help;
72 #ifdef ENABLE_SEARCH_SCREEN
73 extern const struct screen_functions screen_search;
74 #endif
75 #ifdef ENABLE_SONG_SCREEN
76 extern const struct screen_functions screen_song;
77 #endif
78 #ifdef ENABLE_KEYDEF_SCREEN
79 extern const struct screen_functions screen_keydef;
80 #endif
81 #ifdef ENABLE_LYRICS_SCREEN
82 extern const struct screen_functions screen_lyrics;
83 #endif
84 #ifdef ENABLE_OUTPUTS_SCREEN
85 extern const struct screen_functions screen_outputs;
86 #endif
89 typedef struct screen_functions {
90         void (*init)(WINDOW *w, int cols, int rows);
91         void (*exit)(void);
92         void (*open)(struct mpdclient *c);
93         void (*close)(void);
94         void (*resize)(int cols, int rows);
95         void (*paint)(void);
96         void (*update)(struct mpdclient *c);
97         bool (*cmd)(struct mpdclient *c, command_t cmd);
98         const char *(*get_title)(char *s, size_t size);
99 } screen_functions_t;
101 void screen_init(struct mpdclient *c);
102 void screen_exit(void);
103 void screen_resize(struct mpdclient *c);
104 void screen_status_message(const char *msg);
105 void screen_status_printf(const char *format, ...);
106 char *screen_error(void);
107 void screen_paint(struct mpdclient *c);
108 void screen_update(struct mpdclient *c);
109 void screen_cmd(struct mpdclient *c, command_t cmd);
110 gint screen_get_id(const char *name);
112 void
113 screen_switch(const struct screen_functions *sf, struct mpdclient *c);
114 void 
115 screen_swap(struct mpdclient *c, const struct mpd_song *song);
117 gboolean
118 screen_is_visible(const struct screen_functions *sf);
120 int
121 screen_get_mouse_event(struct mpdclient *c, unsigned long *bstate, int *row);
123 bool
124 screen_file_goto_song(struct mpdclient *c, const struct mpd_song *song);
126 #ifdef ENABLE_SONG_SCREEN
127 void
128 screen_song_switch(struct mpdclient *c, const struct mpd_song *song);
129 #endif
131 #ifdef ENABLE_LYRICS_SCREEN
132 void
133 screen_lyrics_switch(struct mpdclient *c, const struct mpd_song *song, bool follow);
134 #endif
136 #endif