diff --git a/src/screen.c b/src/screen.c
index e89e4ebf815eb6e433d8c6653539cca3955484b6..ea21a1af8fae1a5679b9815126df2b60cad72e1c 100644 (file)
--- a/src/screen.c
+++ b/src/screen.c
/* screens */
-extern screen_functions_t *get_screen_playlist(void);
-extern screen_functions_t *get_screen_browse(void);
-extern screen_functions_t *get_screen_help(void);
-extern screen_functions_t *get_screen_search(void);
-extern screen_functions_t *get_screen_artist(void);
-extern screen_functions_t *get_screen_keydef(void);
-extern screen_functions_t *get_screen_clock(void);
-extern screen_functions_t *get_screen_lyrics(void);
-
-typedef screen_functions_t * (*screen_get_mode_functions_fn_t) (void);
-
-typedef struct
+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_KEYDEF_SCREEN
+extern const struct screen_functions screen_keydef;
+#endif
+#ifdef ENABLE_CLOCK_SCREEN
+extern const struct screen_functions screen_clock;
+#endif
+extern const struct screen_functions screen_lyrics;
+
+typedef struct screen_functions * (*screen_get_mode_functions_fn_t) (void);
+
+static const struct
{
gint id;
const gchar *name;
- screen_get_mode_functions_fn_t get_mode_functions;
-} screen_mode_info_t;
-
-
-static screen_mode_info_t screens[] = {
- { SCREEN_PLAYLIST_ID, "playlist", get_screen_playlist },
- { SCREEN_BROWSE_ID, "browse", get_screen_browse },
+ const struct screen_functions *functions;
+} screens[] = {
+ { SCREEN_PLAYLIST_ID, "playlist", &screen_playlist },
+ { SCREEN_BROWSE_ID, "browse", &screen_browse },
#ifdef ENABLE_ARTIST_SCREEN
- { SCREEN_ARTIST_ID, "artist", get_screen_artist },
+ { SCREEN_ARTIST_ID, "artist", &screen_artist },
#endif
- { SCREEN_HELP_ID, "help", get_screen_help },
+ { SCREEN_HELP_ID, "help", &screen_help },
#ifdef ENABLE_SEARCH_SCREEN
- { SCREEN_SEARCH_ID, "search", get_screen_search },
+ { SCREEN_SEARCH_ID, "search", &screen_search },
#endif
#ifdef ENABLE_KEYDEF_SCREEN
- { SCREEN_KEYDEF_ID, "keydef", get_screen_keydef },
+ { SCREEN_KEYDEF_ID, "keydef", &screen_keydef },
#endif
#ifdef ENABLE_CLOCK_SCREEN
- { SCREEN_CLOCK_ID, "clock", get_screen_clock },
+ { SCREEN_CLOCK_ID, "clock", &screen_clock },
#endif
#ifdef ENABLE_LYRICS_SCREEN
- { SCREEN_LYRICS_ID, "lyrics", get_screen_lyrics },
+ { SCREEN_LYRICS_ID, "lyrics", &screen_lyrics },
#endif
- { G_MAXINT, NULL, NULL }
+ { G_MAXINT, NULL, NULL }
};
static gboolean welcome = TRUE;
static screen_t *screen = NULL;
-static screen_functions_t *mode_fn = NULL;
+static const struct screen_functions *mode_fn = NULL;
static int seek_id = -1;
static int seek_target_time = 0;
/* get functions for the new mode */
new_mode = lookup_mode(id);
- if (new_mode>=0 && screens[new_mode].get_mode_functions) {
+ if (new_mode >= 0 && screens[new_mode].functions) {
D("switch_screen(%s)\n", screens[new_mode].name );
- mode_fn = screens[new_mode].get_mode_functions();
+ mode_fn = screens[new_mode].functions;
screen->mode = new_mode;
}
/* close and exit all screens (playlist,browse,help...) */
i=0;
- while (screens[i].get_mode_functions) {
- screen_functions_t *sf = screens[i].get_mode_functions();
+ while (screens[i].functions) {
+ const struct screen_functions *sf = screens[i].functions;
- if (sf && sf->close)
+ if (sf->close)
sf->close();
- if (sf && sf->exit)
+ if (sf->exit)
sf->exit();
i++;
/* close and exit all screens (playlist,browse,help...) */
i=0;
- while (screens[i].get_mode_functions) {
- screen_functions_t *sf = screens[i].get_mode_functions();
+ while (screens[i].functions) {
+ const struct screen_functions *sf = screens[i].functions;
- if (sf && sf->resize)
+ if (sf->resize)
sf->resize(screen->main_window.cols, screen->main_window.rows);
i++;
wbkgd(screen->status_window.w, COLOR_PAIR(COLOR_STATUS));
colors_use(screen->progress_window.w, COLOR_PROGRESSBAR);
}
+
+ refresh();
}
int
/* initialize screens */
i=0;
- while( screens[i].get_mode_functions )
- {
- screen_functions_t *fn = screens[i].get_mode_functions();
+ while (screens[i].functions) {
+ const struct screen_functions *fn = screens[i].functions;
- if( fn && fn->init )
- fn->init(screen->main_window.w,
- screen->main_window.cols,
- screen->main_window.rows);
+ if (fn->init)
+ fn->init(screen->main_window.w,
+ screen->main_window.cols,
+ screen->main_window.rows);
- i++;
- }
+ i++;
+ }
#if 0
/* broken */
mode_fn = NULL;
switch_screen_mode(screen_get_id(options.screen_list[0]), c);
#else
- mode_fn = get_screen_playlist();
+ mode_fn = &screen_playlist;
#endif
if( mode_fn && mode_fn->open )