aboutsummaryrefslogtreecommitdiffstats
path: root/src/screen.c
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2008-09-25 21:21:00 +0200
committerMax Kellermann <max@duempel.org>2008-09-25 21:21:00 +0200
commit9791d3094719f1ed6c3c8ecf9c006b81d0de5370 (patch)
treea69a352e00ffa1abdfc7d26c01a724dedb5a5af9 /src/screen.c
parent3809e2f13bb6642d3a874c24df7d854aa0aea8b5 (diff)
downloadmpd-9791d3094719f1ed6c3c8ecf9c006b81d0de5370.tar.gz
mpd-9791d3094719f1ed6c3c8ecf9c006b81d0de5370.tar.xz
mpd-9791d3094719f1ed6c3c8ecf9c006b81d0de5370.zip
screen: pass screen_functions pointer to switch_screen_mode()
Trying to get rid of the screen ids. A pointer to screen_functions is better for identifying a screen.
Diffstat (limited to '')
-rw-r--r--src/screen.c32
1 files changed, 20 insertions, 12 deletions
diff --git a/src/screen.c b/src/screen.c
index 02df03b52..2124a2b74 100644
--- a/src/screen.c
+++ b/src/screen.c
@@ -54,14 +54,14 @@ screen_is_visible(const struct screen_functions *sf)
}
static void
-switch_screen_mode(gint id, mpdclient_t *c)
+switch_screen_mode(const struct screen_functions *sf, mpdclient_t *c)
{
gint new_mode;
- if (id == screen_get_id_by_index(screen.mode))
+ if (sf == mode_fn)
return;
- new_mode = lookup_mode(id);
+ new_mode = lookup_mode(sf);
if (new_mode < 0)
return;
@@ -70,7 +70,7 @@ switch_screen_mode(gint id, mpdclient_t *c)
mode_fn->close();
/* get functions for the new mode */
- mode_fn = screen_get_functions(new_mode);
+ mode_fn = sf;
screen.mode = new_mode;
screen.painted = 0;
@@ -106,7 +106,7 @@ screen_next_mode(mpdclient_t *c, int offset)
next = 0;
D("current mode: %d:%d next:%d\n", current, max, next);
- switch_screen_mode(screen_get_id(options.screen_list[next]), c);
+ switch_screen_mode(screen_lookup_name(options.screen_list[next]), c);
}
static void
@@ -792,26 +792,34 @@ screen_cmd(mpdclient_t *c, command_t cmd)
screen_next_mode(c, 1);
break;
case CMD_SCREEN_PLAY:
- switch_screen_mode(SCREEN_PLAYLIST_ID, c);
+ switch_screen_mode(&screen_playlist, c);
break;
case CMD_SCREEN_FILE:
- switch_screen_mode(SCREEN_BROWSE_ID, c);
+ switch_screen_mode(&screen_browse, c);
break;
case CMD_SCREEN_HELP:
- switch_screen_mode(SCREEN_HELP_ID, c);
+ switch_screen_mode(&screen_help, c);
break;
+#ifdef ENABLE_SEARCH_SCREEN
case CMD_SCREEN_SEARCH:
- switch_screen_mode(SCREEN_SEARCH_ID, c);
+ switch_screen_mode(&screen_search, c);
break;
+#endif
+#ifdef ENABLE_ARTIST_SCREEN
case CMD_SCREEN_ARTIST:
- switch_screen_mode(SCREEN_ARTIST_ID, c);
+ switch_screen_mode(&screen_artist, c);
break;
+#endif
+#ifdef ENABLE_KEYDEF_SCREEN
case CMD_SCREEN_KEYDEF:
- switch_screen_mode(SCREEN_KEYDEF_ID, c);
+ switch_screen_mode(&screen_keydef, c);
break;
+#endif
+#ifdef ENABLE_LYRICS_SCREEN
case CMD_SCREEN_LYRICS:
- switch_screen_mode(SCREEN_LYRICS_ID, c);
+ switch_screen_mode(&screen_lyrics, c);
break;
+#endif
default:
break;
}