diff options
Diffstat (limited to '')
-rw-r--r-- | src/screen.c | 8 | ||||
-rw-r--r-- | src/screen.h | 10 | ||||
-rw-r--r-- | src/screen_artist.c | 16 | ||||
-rw-r--r-- | src/screen_browser.c | 5 | ||||
-rw-r--r-- | src/screen_browser.h | 2 | ||||
-rw-r--r-- | src/screen_file.c | 18 | ||||
-rw-r--r-- | src/screen_help.c | 5 | ||||
-rw-r--r-- | src/screen_keydef.c | 9 | ||||
-rw-r--r-- | src/screen_lyrics.c | 7 | ||||
-rw-r--r-- | src/screen_play.c | 36 | ||||
-rw-r--r-- | src/screen_play.h | 2 | ||||
-rw-r--r-- | src/screen_search.c | 20 | ||||
-rw-r--r-- | src/screen_utils.c | 40 | ||||
-rw-r--r-- | src/screen_utils.h | 6 |
14 files changed, 85 insertions, 99 deletions
diff --git a/src/screen.c b/src/screen.c index 5345f49ef..ea6d5d4ba 100644 --- a/src/screen.c +++ b/src/screen.c @@ -51,7 +51,7 @@ static const int SCREEN_MIN_ROWS = 5; /* screens */ static gboolean welcome = TRUE; -static struct screen screen; +struct screen screen; static const struct screen_functions *mode_fn = &screen_playlist; static int seek_id = -1; static int seek_target_time = 0; @@ -79,7 +79,7 @@ screen_switch(const struct screen_functions *sf, struct mpdclient *c) /* open the new mode */ if (mode_fn->open != NULL) - mode_fn->open(&screen, c); + mode_fn->open(c); screen_paint(c); } @@ -522,7 +522,7 @@ screen_init(mpdclient_t *c) screen.main_window.cols, screen.main_window.rows); if (mode_fn->open != NULL) - mode_fn->open(&screen, c); + mode_fn->open(c); /* initialize wreadln */ wrln_wgetch = my_wgetch; @@ -764,7 +764,7 @@ screen_cmd(mpdclient_t *c, command_t cmd) screen.last_cmd = cmd; welcome = FALSE; - if (mode_fn->cmd != NULL && mode_fn->cmd(&screen, c, cmd)) + if (mode_fn->cmd != NULL && mode_fn->cmd(c, cmd)) return; if (screen_client_cmd(c, cmd)) diff --git a/src/screen.h b/src/screen.h index 976c75c90..ef7940a31 100644 --- a/src/screen.h +++ b/src/screen.h @@ -19,7 +19,7 @@ struct window { unsigned rows, cols; }; -typedef struct screen { +struct screen { struct window top_window; struct window main_window; struct window progress_window; @@ -38,7 +38,9 @@ typedef struct screen { char *findbuf; GList *find_history; -} screen_t; +}; + +extern struct screen screen; extern const struct screen_functions screen_playlist; extern const struct screen_functions screen_browse; @@ -59,12 +61,12 @@ extern const struct screen_functions screen_lyrics; typedef struct screen_functions { void (*init)(WINDOW *w, int cols, int rows); void (*exit)(void); - void (*open)(struct screen *screen, mpdclient_t *c); + void (*open)(mpdclient_t *c); void (*close)(void); void (*resize)(int cols, int rows); void (*paint)(void); void (*update)(mpdclient_t *c); - int (*cmd)(struct screen *scr, mpdclient_t *c, command_t cmd); + int (*cmd)(mpdclient_t *c, command_t cmd); const char *(*get_title)(char *s, size_t size); } screen_functions_t; diff --git a/src/screen_artist.c b/src/screen_artist.c index 52b7eeee8..846902e0a 100644 --- a/src/screen_artist.c +++ b/src/screen_artist.c @@ -331,7 +331,7 @@ quit(void) } static void -open(mpd_unused screen_t *screen, mpdclient_t *c) +open(mpdclient_t *c) { static gboolean callback_installed = FALSE; @@ -434,7 +434,7 @@ metalist_length(void) } static int -artist_lw_cmd(struct screen *screen, struct mpdclient *c, command_t cmd) +artist_lw_cmd(struct mpdclient *c, command_t cmd) { switch (mode) { case LIST_ARTISTS: @@ -442,7 +442,7 @@ artist_lw_cmd(struct screen *screen, struct mpdclient *c, command_t cmd) return list_window_cmd(browser.lw, metalist_length(), cmd); case LIST_SONGS: - return browser_cmd(&browser, screen, c, cmd); + return browser_cmd(&browser, c, cmd); } assert(0); @@ -463,7 +463,7 @@ string_array_find(GPtrArray *array, const char *value) } static int -artist_cmd(screen_t *screen, mpdclient_t *c, command_t cmd) +artist_cmd(mpdclient_t *c, command_t cmd) { char *selected; char *old; @@ -641,15 +641,13 @@ artist_cmd(screen_t *screen, mpdclient_t *c, command_t cmd) case CMD_LIST_RFIND_NEXT: switch (mode) { case LIST_ARTISTS: - screen_find(screen, - browser.lw, artist_list->len, + screen_find(browser.lw, artist_list->len, cmd, artist_lw_callback, artist_list); artist_repaint(); return 1; case LIST_ALBUMS: - screen_find(screen, - browser.lw, album_list->len + 2, + screen_find(browser.lw, album_list->len + 2, cmd, artist_lw_callback, album_list); artist_repaint(); return 1; @@ -665,7 +663,7 @@ artist_cmd(screen_t *screen, mpdclient_t *c, command_t cmd) break; } - if (artist_lw_cmd(screen, c, cmd)) { + if (artist_lw_cmd(c, cmd)) { artist_repaint(); return 1; } diff --git a/src/screen_browser.c b/src/screen_browser.c index e68e70285..00965edb0 100644 --- a/src/screen_browser.c +++ b/src/screen_browser.c @@ -453,7 +453,7 @@ browser_handle_mouse_event(struct screen_browser *browser, mpdclient_t *c) #endif bool -browser_cmd(struct screen_browser *browser, struct screen *screen, +browser_cmd(struct screen_browser *browser, struct mpdclient *c, command_t cmd) { struct filelist_entry *entry; @@ -487,8 +487,7 @@ browser_cmd(struct screen_browser *browser, struct screen *screen, case CMD_LIST_RFIND: case CMD_LIST_FIND_NEXT: case CMD_LIST_RFIND_NEXT: - screen_find(screen, - browser->lw, filelist_length(browser->filelist), + screen_find(browser->lw, filelist_length(browser->filelist), cmd, browser_lw_callback, browser->filelist); return true; diff --git a/src/screen_browser.h b/src/screen_browser.h index 17e41f6ec..802886aa0 100644 --- a/src/screen_browser.h +++ b/src/screen_browser.h @@ -49,7 +49,7 @@ browser_change_directory(struct screen_browser *browser, mpdclient_t *c, filelist_entry_t *entry, const char *new_path); bool -browser_cmd(struct screen_browser *browser, struct screen *screen, +browser_cmd(struct screen_browser *browser, struct mpdclient *c, command_t cmd); #endif diff --git a/src/screen_file.c b/src/screen_file.c index 9dfe4ac68..bef155f59 100644 --- a/src/screen_file.c +++ b/src/screen_file.c @@ -75,7 +75,7 @@ playlist_changed_callback(mpdclient_t *c, int event, gpointer data) } static int -handle_save(screen_t *screen, mpdclient_t *c) +handle_save(mpdclient_t *c) { filelist_entry_t *entry; char *defaultname = NULL; @@ -92,11 +92,11 @@ handle_save(screen_t *screen, mpdclient_t *c) } } - return playlist_save(screen, c, NULL, defaultname); + return playlist_save(c, NULL, defaultname); } static int -handle_delete(screen_t *screen, mpdclient_t *c) +handle_delete(mpdclient_t *c) { filelist_entry_t *entry; mpd_InfoEntity *entity; @@ -123,7 +123,7 @@ handle_delete(screen_t *screen, mpdclient_t *c) str = utf8_to_locale(g_basename(plf->path)); buf = g_strdup_printf(_("Delete playlist %s [%s/%s] ? "), str, YES, NO); g_free(str); - key = tolower(screen_getch(screen->status_window.w, buf)); + key = tolower(screen_getch(screen.status_window.w, buf)); g_free(buf); if( key != YES[0] ) { screen_status_printf(_("Aborted!")); @@ -159,7 +159,7 @@ browse_exit(void) } static void -browse_open(mpd_unused screen_t *screen, mpd_unused mpdclient_t *c) +browse_open(mpd_unused mpdclient_t *c) { if (browser.filelist == NULL) { browser.filelist = mpdclient_filelist_get(c, ""); @@ -196,7 +196,7 @@ browse_paint(void) } static int -browse_cmd(screen_t *screen, mpdclient_t *c, command_t cmd) +browse_cmd(mpdclient_t *c, command_t cmd) { switch(cmd) { case CMD_GO_ROOT_DIRECTORY: @@ -209,11 +209,11 @@ browse_cmd(screen_t *screen, mpdclient_t *c, command_t cmd) return 1; case CMD_DELETE: - handle_delete(screen, c); + handle_delete(c); file_repaint(); break; case CMD_SAVE_PLAYLIST: - handle_save(screen, c); + handle_save(c); break; case CMD_SCREEN_UPDATE: browser.filelist = mpdclient_filelist_update(c, browser.filelist); @@ -249,7 +249,7 @@ browse_cmd(screen_t *screen, mpdclient_t *c, command_t cmd) break; } - if (browser_cmd(&browser, screen, c, cmd)) { + if (browser_cmd(&browser, c, cmd)) { file_repaint(); return 1; } diff --git a/src/screen_help.c b/src/screen_help.c index fbcbf2b82..3b66403d7 100644 --- a/src/screen_help.c +++ b/src/screen_help.c @@ -213,7 +213,7 @@ help_paint(void) } static int -help_cmd(screen_t *screen, mpd_unused mpdclient_t *c, command_t cmd) +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); @@ -222,8 +222,7 @@ help_cmd(screen_t *screen, mpd_unused mpdclient_t *c, command_t cmd) } lw->selected = lw->start+lw->rows; - if (screen_find(screen, - lw, help_text_rows, + if (screen_find(lw, help_text_rows, cmd, list_callback, NULL)) { /* center the row */ list_window_center(lw, help_text_rows, lw->selected); diff --git a/src/screen_keydef.c b/src/screen_keydef.c index b84289d5b..86faabaf4 100644 --- a/src/screen_keydef.c +++ b/src/screen_keydef.c @@ -246,7 +246,7 @@ keydef_exit(void) } static void -keydef_open(mpd_unused screen_t *screen, mpd_unused mpdclient_t *c) +keydef_open(mpd_unused mpdclient_t *c) { if (cmds == NULL) { command_definition_t *current_cmds = get_command_definitions(); @@ -294,7 +294,7 @@ keydef_paint(void) } static int -keydef_cmd(screen_t *screen, mpd_unused mpdclient_t *c, command_t cmd) +keydef_cmd(mpd_unused mpdclient_t *c, command_t cmd) { int length = LIST_LENGTH(); @@ -328,7 +328,7 @@ keydef_cmd(screen_t *screen, mpd_unused mpdclient_t *c, command_t cmd) keydef_repaint(); } else - assign_new_key(screen->status_window.w, + assign_new_key(screen.status_window.w, subcmd, lw->selected - STATIC_SUB_ITEMS); } @@ -346,8 +346,7 @@ keydef_cmd(screen_t *screen, mpd_unused mpdclient_t *c, command_t cmd) case CMD_LIST_RFIND: case CMD_LIST_FIND_NEXT: case CMD_LIST_RFIND_NEXT: - screen_find(screen, - lw, length, + screen_find(lw, length, cmd, list_callback, NULL); keydef_repaint(); return 1; diff --git a/src/screen_lyrics.c b/src/screen_lyrics.c index be99e6b75..2a8e10b67 100644 --- a/src/screen_lyrics.c +++ b/src/screen_lyrics.c @@ -264,7 +264,7 @@ lyrics_exit(void) } static void -lyrics_open(mpd_unused screen_t *screen, mpdclient_t *c) +lyrics_open(mpdclient_t *c) { if (next_song == NULL) next_song = c->song; @@ -297,7 +297,7 @@ lyrics_paint(void) } static int -lyrics_cmd(screen_t *screen, mpdclient_t *c, command_t cmd) +lyrics_cmd(mpdclient_t *c, command_t cmd) { if (list_window_scroll_cmd(lw, current.lines->len, cmd)) { lyrics_repaint(); @@ -327,8 +327,7 @@ lyrics_cmd(screen_t *screen, mpdclient_t *c, command_t cmd) } lw->selected = lw->start+lw->rows; - if (screen_find(screen, - lw, current.lines->len, + if (screen_find(lw, current.lines->len, cmd, list_callback, NULL)) { /* center the row */ list_window_center(lw, current.lines->len, lw->selected); diff --git a/src/screen_play.c b/src/screen_play.c index 4b285c533..37705c559 100644 --- a/src/screen_play.c +++ b/src/screen_play.c @@ -44,7 +44,6 @@ typedef struct { GList **list; GList **dir_list; - screen_t *screen; mpdclient_t *c; } completion_callback_data_t; @@ -145,17 +144,14 @@ save_pre_completion_cb(GCompletion *gcmp, mpd_unused gchar *line, void *data) static void save_post_completion_cb(mpd_unused GCompletion *gcmp, mpd_unused gchar *line, - GList *items, void *data) + GList *items, mpd_unused void *data) { - completion_callback_data_t *tmp = (completion_callback_data_t *)data; - screen_t *screen = tmp->screen; - if (g_list_length(items) >= 1) - screen_display_completion_list(screen, items); + screen_display_completion_list(items); } int -playlist_save(screen_t *screen, mpdclient_t *c, char *name, char *defaultname) +playlist_save(mpdclient_t *c, char *name, char *defaultname) { gchar *filename; gint error; @@ -169,7 +165,6 @@ playlist_save(screen_t *screen, mpdclient_t *c, char *name, char *defaultname) g_completion_set_compare(gcmp, strncmp); data.list = &list; data.dir_list = NULL; - data.screen = screen; data.c = c; wrln_completion_callback_data = &data; wrln_pre_completion_callback = save_pre_completion_cb; @@ -177,7 +172,7 @@ playlist_save(screen_t *screen, mpdclient_t *c, char *name, char *defaultname) /* query the user for a filename */ - filename = screen_readln(screen->status_window.w, + filename = screen_readln(screen.status_window.w, _("Save playlist as: "), defaultname, NULL, @@ -207,7 +202,7 @@ playlist_save(screen_t *screen, mpdclient_t *c, char *name, char *defaultname) buf = g_strdup_printf(_("Replace %s [%s/%s] ? "), filename, YES, NO); - key = tolower(screen_getch(screen->status_window.w, + key = tolower(screen_getch(screen.status_window.w, buf)); g_free(buf); @@ -217,7 +212,7 @@ playlist_save(screen_t *screen, mpdclient_t *c, char *name, char *defaultname) return -1; } - error = playlist_save(screen, c, filename, NULL); + error = playlist_save(c, filename, NULL); g_free(filename); return error; } @@ -270,10 +265,9 @@ static void add_post_completion_cb(GCompletion *gcmp, gchar *line, GList **dir_list = tmp->dir_list; GList **list = tmp->list; mpdclient_t *c = tmp->c; - screen_t *screen = tmp->screen; if (g_list_length(items) >= 1) - screen_display_completion_list(screen, items); + screen_display_completion_list(items); if (line && line[0] && line[strlen(line) - 1] == '/' && string_list_find(*dir_list, line) == NULL) { @@ -283,7 +277,7 @@ static void add_post_completion_cb(GCompletion *gcmp, gchar *line, } static int -handle_add_to_playlist(screen_t *screen, mpdclient_t *c) +handle_add_to_playlist(mpdclient_t *c) { gchar *path; GCompletion *gcmp; @@ -296,14 +290,13 @@ handle_add_to_playlist(screen_t *screen, mpdclient_t *c) g_completion_set_compare(gcmp, strncmp); data.list = &list; data.dir_list = &dir_list; - data.screen = screen; data.c = c; wrln_completion_callback_data = &data; wrln_pre_completion_callback = add_pre_completion_cb; wrln_post_completion_callback = add_post_completion_cb; /* get path */ - path = screen_readln(screen->status_window.w, + path = screen_readln(screen.status_window.w, _("Add: "), NULL, NULL, @@ -353,7 +346,7 @@ timer_hide_cursor(gpointer data) } static void -play_open(mpd_unused screen_t *screen, mpdclient_t *c) +play_open(mpdclient_t *c) { static gboolean install_cb = TRUE; @@ -471,7 +464,7 @@ handle_mouse_event(struct mpdclient *c) #endif static int -play_cmd(screen_t *screen, mpdclient_t *c, command_t cmd) +play_cmd(mpdclient_t *c, command_t cmd) { lw->flags &= ~LW_HIDE_CURSOR; @@ -495,10 +488,10 @@ play_cmd(screen_t *screen, mpdclient_t *c, command_t cmd) mpdclient_cmd_delete(c, lw->selected); return 1; case CMD_SAVE_PLAYLIST: - playlist_save(screen, c, NULL, NULL); + playlist_save(c, NULL, NULL); return 1; case CMD_ADD: - handle_add_to_playlist(screen, c); + handle_add_to_playlist(c); return 1; case CMD_SCREEN_UPDATE: center_playing_item(c); @@ -515,8 +508,7 @@ play_cmd(screen_t *screen, mpdclient_t *c, command_t cmd) case CMD_LIST_RFIND: case CMD_LIST_FIND_NEXT: case CMD_LIST_RFIND_NEXT: - screen_find(screen, - lw, playlist_length(&c->playlist), + screen_find(lw, playlist_length(&c->playlist), cmd, list_callback, NULL); playlist_repaint(); return 1; diff --git a/src/screen_play.h b/src/screen_play.h index 36d57a2fa..3ff3cb02a 100644 --- a/src/screen_play.h +++ b/src/screen_play.h @@ -1,2 +1,2 @@ -int playlist_save(screen_t *screen, mpdclient_t *c, char *name, char *defaultname); +int playlist_save(mpdclient_t *c, char *name, char *defaultname); diff --git a/src/screen_search.c b/src/screen_search.c index bf9278b53..4e2f922ec 100644 --- a/src/screen_search.c +++ b/src/screen_search.c @@ -161,7 +161,7 @@ search_check_mode(void) } static void -search_clear(mpd_unused screen_t *screen, mpdclient_t *c, +search_clear(mpdclient_t *c, gboolean clear_pattern) { if (browser.filelist) { @@ -300,11 +300,11 @@ search_advanced_query(char *query, mpdclient_t *c) } static void -search_new(screen_t *screen, mpdclient_t *c) +search_new(mpdclient_t *c) { - search_clear(screen, c, TRUE); + search_clear(c, TRUE); - pattern = screen_readln(screen->status_window.w, + pattern = screen_readln(screen.status_window.w, _("Search: "), NULL, &search_history, @@ -360,7 +360,7 @@ quit(void) } static void -open(mpd_unused screen_t *screen, mpd_unused mpdclient_t *c) +open(mpd_unused mpdclient_t *c) { // if( pattern==NULL ) // search_new(screen, c); @@ -408,7 +408,7 @@ get_title(char *str, size_t size) } static int -search_cmd(screen_t *screen, mpdclient_t *c, command_t cmd) +search_cmd(mpdclient_t *c, command_t cmd) { switch (cmd) { case CMD_SEARCH_MODE: @@ -420,7 +420,7 @@ search_cmd(screen_t *screen, mpdclient_t *c, command_t cmd) /* continue and update... */ case CMD_SCREEN_UPDATE: if (pattern) { - search_clear(screen, c, FALSE); + search_clear(c, FALSE); browser.filelist = filelist_search(c, FALSE, mode[options.search_mode].table, @@ -431,12 +431,12 @@ search_cmd(screen_t *screen, mpdclient_t *c, command_t cmd) return 1; case CMD_SCREEN_SEARCH: - search_new(screen, c); + search_new(c); search_repaint(); return 1; case CMD_CLEAR: - search_clear(screen, c, TRUE); + search_clear(c, TRUE); list_window_reset(browser.lw); search_repaint(); return 1; @@ -446,7 +446,7 @@ search_cmd(screen_t *screen, mpdclient_t *c, command_t cmd) } if (browser.filelist != NULL && - browser_cmd(&browser, screen, c, cmd)) { + browser_cmd(&browser, c, cmd)) { search_repaint(); return 1; } diff --git a/src/screen_utils.c b/src/screen_utils.c index d83015503..513475616 100644 --- a/src/screen_utils.c +++ b/src/screen_utils.c @@ -143,8 +143,7 @@ screen_auth(struct mpdclient *c) /* query user for a string and find it in a list window */ int -screen_find(screen_t *screen, - list_window_t *lw, +screen_find(list_window_t *lw, int rows, command_t findcmd, list_window_callback_fn_t callback_fn, @@ -163,40 +162,41 @@ screen_find(screen_t *screen, switch (findcmd) { case CMD_LIST_FIND: case CMD_LIST_RFIND: - if (screen->findbuf) { - g_free(screen->findbuf); - screen->findbuf=NULL; + if (screen.findbuf) { + g_free(screen.findbuf); + screen.findbuf=NULL; } /* continue... */ case CMD_LIST_FIND_NEXT: case CMD_LIST_RFIND_NEXT: - if (!screen->findbuf) - screen->findbuf=screen_readln(screen->status_window.w, - prompt, - value, - &screen->find_history, - NULL); - - if (!screen->findbuf || !screen->findbuf[0]) + if (!screen.findbuf) + screen.findbuf=screen_readln(screen.status_window.w, + prompt, + value, + &screen.find_history, + NULL); + + if (!screen.findbuf || !screen.findbuf[0]) return 1; if (reversed) retval = list_window_rfind(lw, callback_fn, callback_data, - screen->findbuf, + screen.findbuf, options.find_wrap, rows); else retval = list_window_find(lw, callback_fn, callback_data, - screen->findbuf, + screen.findbuf, options.find_wrap); if (retval != 0) { - screen_status_printf(_("Unable to find \'%s\'"), screen->findbuf); + screen_status_printf(_("Unable to find \'%s\'"), + screen.findbuf); screen_bell(); } return 1; @@ -207,17 +207,17 @@ screen_find(screen_t *screen, } void -screen_display_completion_list(screen_t *screen, GList *list) +screen_display_completion_list(GList *list) { static GList *prev_list = NULL; static guint prev_length = 0; static guint offset = 0; - WINDOW *w = screen->main_window.w; + WINDOW *w = screen.main_window.w; guint length, y=0; length = g_list_length(list); if (list == prev_list && length == prev_length) { - offset += screen->main_window.rows; + offset += screen.main_window.rows; if (offset >= length) offset = 0; } else { @@ -227,7 +227,7 @@ screen_display_completion_list(screen_t *screen, GList *list) } colors_use(w, COLOR_STATUS_ALERT); - while (y < screen->main_window.rows) { + while (y < screen.main_window.rows) { GList *item = g_list_nth(list, y+offset); wmove(w, y++, 0); diff --git a/src/screen_utils.h b/src/screen_utils.h index 74ca7d012..a550f1742 100644 --- a/src/screen_utils.h +++ b/src/screen_utils.h @@ -6,7 +6,6 @@ #include <ncurses.h> -struct screen; struct mpdclient; /* sound an audible and/or visible bell */ @@ -22,8 +21,7 @@ char *screen_readln(WINDOW *w, const char *prompt, const char *value, char *screen_readln_masked(WINDOW *w, const char *prompt); char *screen_read_pasword(WINDOW *w, const char *prompt); /* query user for a string and find it in a list window */ -int screen_find(struct screen *screen, - struct list_window *lw, +int screen_find(struct list_window *lw, int rows, command_t findcmd, list_window_callback_fn_t callback_fn, @@ -31,7 +29,7 @@ int screen_find(struct screen *screen, gint screen_auth(struct mpdclient *c); -void screen_display_completion_list(struct screen *screen, GList *list); +void screen_display_completion_list(GList *list); void set_xterm_title(const char *format, ...); |