diff options
author | Max Kellermann <max@duempel.org> | 2008-09-25 17:40:28 +0200 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2008-09-25 17:40:28 +0200 |
commit | 0fd4d0c99d31b69356c289d3bb1dcd791b898028 (patch) | |
tree | ce3893e184b03ec5c63859e1fc1ffe889eacc8e1 /src | |
parent | 6fabb44f8b5d9615fd316bac87133d4b5ce69a3b (diff) | |
download | mpd-0fd4d0c99d31b69356c289d3bb1dcd791b898028.tar.gz mpd-0fd4d0c99d31b69356c289d3bb1dcd791b898028.tar.xz mpd-0fd4d0c99d31b69356c289d3bb1dcd791b898028.zip |
code style, indent with tabs X
Follow the same code style als MPD itself.
Diffstat (limited to '')
-rw-r--r-- | src/list_window.c | 8 | ||||
-rw-r--r-- | src/screen_artist.c | 4 | ||||
-rw-r--r-- | src/screen_browser.c | 2 | ||||
-rw-r--r-- | src/screen_file.c | 4 | ||||
-rw-r--r-- | src/screen_help.c | 6 | ||||
-rw-r--r-- | src/screen_keydef.c | 308 | ||||
-rw-r--r-- | src/screen_play.c | 327 | ||||
-rw-r--r-- | src/screen_search.c | 4 | ||||
-rw-r--r-- | src/screen_utils.c | 4 |
9 files changed, 321 insertions, 346 deletions
diff --git a/src/list_window.c b/src/list_window.c index cce992d86..5a4ccf36d 100644 --- a/src/list_window.c +++ b/src/list_window.c @@ -196,20 +196,20 @@ list_window_paint(struct list_window *lw, int selected = lw->start + i == lw->selected; size_t len = my_strlen(label); - if( highlight ) + if (highlight) colors_use(lw->w, COLOR_LIST_BOLD); else colors_use(lw->w, COLOR_LIST); - if( show_cursor && selected ) + if (show_cursor && selected) wattron(lw->w, A_REVERSE); //waddnstr(lw->w, label, lw->cols); waddstr(lw->w, label); - if( fill && len<lw->cols ) + if (fill && len < lw->cols) whline(lw->w, ' ', lw->cols-len); - if( selected ) + if (selected) wattroff(lw->w, A_REVERSE); } } diff --git a/src/screen_artist.c b/src/screen_artist.c index dd7e0175a..4abd585c0 100644 --- a/src/screen_artist.c +++ b/src/screen_artist.c @@ -1,6 +1,4 @@ -/* - * $Id$ - * +/* * (c) 2005 by Kalle Wallin <kaw@linux.se> * * This program is free software; you can redistribute it and/or modify diff --git a/src/screen_browser.c b/src/screen_browser.c index bbf69c522..9ce6fedd8 100644 --- a/src/screen_browser.c +++ b/src/screen_browser.c @@ -1,6 +1,4 @@ /* - * $Id$ - * * (c) 2004 by Kalle Wallin <kaw@linux.se> * Copyright (C) 2008 Max Kellermann <max@duempel.org> * diff --git a/src/screen_file.c b/src/screen_file.c index 920525004..f2384ecb7 100644 --- a/src/screen_file.c +++ b/src/screen_file.c @@ -1,6 +1,4 @@ -/* - * $Id$ - * +/* * (c) 2004 by Kalle Wallin <kaw@linux.se> * * This program is free software; you can redistribute it and/or modify diff --git a/src/screen_help.c b/src/screen_help.c index 79b8fa722..e440672d2 100644 --- a/src/screen_help.c +++ b/src/screen_help.c @@ -1,6 +1,4 @@ -/* - * $Id$ - * +/* * (c) 2004 by Kalle Wallin <kaw@linux.se> * * This program is free software; you can redistribute it and/or modify @@ -38,7 +36,7 @@ typedef struct { const char *text; } help_text_row_t; -static help_text_row_t help_text[] = +static help_text_row_t help_text[] = { { 1, CMD_NONE, N_("Keys - Movement") }, { 2, CMD_NONE, NULL }, diff --git a/src/screen_keydef.c b/src/screen_keydef.c index 9d573976a..3dda0ec72 100644 --- a/src/screen_keydef.c +++ b/src/screen_keydef.c @@ -1,6 +1,4 @@ -/* - * $Id$ - * +/* * (c) 2004 by Kalle Wallin <kaw@linux.se> * * This program is free software; you can redistribute it and/or modify @@ -59,128 +57,126 @@ static unsigned subcmd_addpos = 0; static int keybindings_changed(void) { - command_definition_t *orginal_cmds = get_command_definitions(); - size_t size = command_list_length*sizeof(command_definition_t); - - return memcmp(orginal_cmds, cmds, size); + command_definition_t *orginal_cmds = get_command_definitions(); + size_t size = command_list_length * sizeof(command_definition_t); + + return memcmp(orginal_cmds, cmds, size); } static void apply_keys(void) { - if( keybindings_changed() ) - { - command_definition_t *orginal_cmds = get_command_definitions(); - size_t size = command_list_length*sizeof(command_definition_t); - - memcpy(orginal_cmds, cmds, size); - screen_status_printf(_("You have new key bindings!")); - } - else - screen_status_printf(_("Keybindings unchanged.")); + if (keybindings_changed()) { + command_definition_t *orginal_cmds = get_command_definitions(); + size_t size = command_list_length * sizeof(command_definition_t); + + memcpy(orginal_cmds, cmds, size); + screen_status_printf(_("You have new key bindings!")); + } else + screen_status_printf(_("Keybindings unchanged.")); } static int save_keys(void) { - FILE *f; - char *filename; - - if( check_user_conf_dir() ) - { - screen_status_printf(_("Error: Unable to create direcory ~/.ncmpc - %s"), - strerror(errno)); - screen_bell(); - return -1; - } - - filename = get_user_key_binding_filename(); - - if( (f=fopen(filename,"w")) == NULL ) - { - screen_status_printf(_("Error: %s - %s"), filename, strerror(errno)); - screen_bell(); - g_free(filename); - return -1; - } - if( write_key_bindings(f, KEYDEF_WRITE_HEADER) ) - screen_status_printf(_("Error: %s - %s"), filename, strerror(errno)); - else - screen_status_printf(_("Wrote %s"), filename); - - g_free(filename); - return fclose(f); + FILE *f; + char *filename; + + if (check_user_conf_dir()) { + screen_status_printf(_("Error: Unable to create direcory ~/.ncmpc - %s"), + strerror(errno)); + screen_bell(); + return -1; + } + + filename = get_user_key_binding_filename(); + + if ((f = fopen(filename,"w")) == NULL) { + screen_status_printf(_("Error: %s - %s"), filename, strerror(errno)); + screen_bell(); + g_free(filename); + return -1; + } + + if (write_key_bindings(f, KEYDEF_WRITE_HEADER)) + screen_status_printf(_("Error: %s - %s"), filename, strerror(errno)); + else + screen_status_printf(_("Wrote %s"), filename); + + g_free(filename); + return fclose(f); } static void check_subcmd_length(void) { - subcmd_length = 0; - while( subcmd_length<MAX_COMMAND_KEYS && cmds[subcmd].keys[subcmd_length]>0 ) - subcmd_length ++; - - if( subcmd_length<MAX_COMMAND_KEYS ) - { - subcmd_addpos = subcmd_length; - subcmd_length++; - } - else - subcmd_addpos = 0; - subcmd_length += STATIC_SUB_ITEMS; + subcmd_length = 0; + while (subcmd_length < MAX_COMMAND_KEYS && + cmds[subcmd].keys[subcmd_length] > 0) + ++subcmd_length; + + if (subcmd_length < MAX_COMMAND_KEYS) { + subcmd_addpos = subcmd_length; + subcmd_length++; + } else + subcmd_addpos = 0; + subcmd_length += STATIC_SUB_ITEMS; } static void delete_key(int cmd_index, int key_index) { - int i = key_index+1; - - screen_status_printf(_("Deleted")); - while( i<MAX_COMMAND_KEYS && cmds[cmd_index].keys[i] ) - cmds[cmd_index].keys[key_index++] = cmds[cmd_index].keys[i++]; - cmds[cmd_index].keys[key_index] = 0; - cmds[cmd_index].flags |= COMMAND_KEY_MODIFIED; - check_subcmd_length(); - lw->clear = 1; - lw->repaint = 1; - /* update key conflict flags */ - check_key_bindings(cmds, NULL, 0); + int i = key_index+1; + + screen_status_printf(_("Deleted")); + while (i < MAX_COMMAND_KEYS && cmds[cmd_index].keys[i]) + cmds[cmd_index].keys[key_index++] = cmds[cmd_index].keys[i++]; + cmds[cmd_index].keys[key_index] = 0; + cmds[cmd_index].flags |= COMMAND_KEY_MODIFIED; + check_subcmd_length(); + lw->clear = 1; + lw->repaint = 1; + /* update key conflict flags */ + check_key_bindings(cmds, NULL, 0); } static void assign_new_key(WINDOW *w, int cmd_index, int key_index) { - int key; - char *buf; - command_t cmd; - - buf = g_strdup_printf(_("Enter new key for %s: "), cmds[cmd_index].name); - key = screen_getch(w, buf); - g_free(buf); - if( key==KEY_RESIZE ) - screen_resize(); - if( key==ERR ) - { - screen_status_printf(_("Aborted!")); - return; - } - cmd = find_key_command(key, cmds); - if( cmd!=CMD_NONE && cmd!= cmds[cmd_index].command ) - { - screen_status_printf(_("Error: key %s is already used for %s"), - key2str(key), - get_key_command_name(cmd)); - screen_bell(); - return; - } - cmds[cmd_index].keys[key_index] = key; - cmds[cmd_index].flags |= COMMAND_KEY_MODIFIED; - - screen_status_printf(_("Assigned %s to %s"), - key2str(key),cmds[cmd_index].name); - check_subcmd_length(); - lw->repaint = 1; - /* update key conflict flags */ - check_key_bindings(cmds, NULL, 0); + int key; + char *buf; + command_t cmd; + + buf = g_strdup_printf(_("Enter new key for %s: "), cmds[cmd_index].name); + key = screen_getch(w, buf); + g_free(buf); + + if (key == KEY_RESIZE) + screen_resize(); + + if (key==ERR) { + screen_status_printf(_("Aborted!")); + return; + } + + cmd = find_key_command(key, cmds); + if (cmd != CMD_NONE && cmd != cmds[cmd_index].command) { + screen_status_printf(_("Error: key %s is already used for %s"), + key2str(key), + get_key_command_name(cmd)); + screen_bell(); + return; + } + + cmds[cmd_index].keys[key_index] = key; + cmds[cmd_index].flags |= COMMAND_KEY_MODIFIED; + + screen_status_printf(_("Assigned %s to %s"), + key2str(key),cmds[cmd_index].name); + check_subcmd_length(); + lw->repaint = 1; + /* update key conflict flags */ + check_key_bindings(cmds, NULL, 0); } static const char * @@ -217,91 +213,87 @@ list_callback(unsigned idx, int *highlight, mpd_unused void *data) return NULL; } -static void +static void keydef_init(WINDOW *w, int cols, int rows) { - lw = list_window_init(w, cols, rows); + lw = list_window_init(w, cols, rows); } static void keydef_resize(int cols, int rows) { - lw->cols = cols; - lw->rows = rows; + lw->cols = cols; + lw->rows = rows; } -static void +static void keydef_exit(void) { - list_window_free(lw); - if( cmds ) - g_free(cmds); - cmds = NULL; - lw = NULL; + list_window_free(lw); + if (cmds) + g_free(cmds); + cmds = NULL; + lw = NULL; } -static void +static void keydef_open(mpd_unused screen_t *screen, mpd_unused mpdclient_t *c) { - if( cmds == NULL ) - { - command_definition_t *current_cmds = get_command_definitions(); - size_t cmds_size; - - command_list_length = 0; - while( current_cmds[command_list_length].name ) - command_list_length++; - - cmds_size = (command_list_length+1)*sizeof(command_definition_t); - cmds = g_malloc0(cmds_size); - memcpy(cmds, current_cmds, cmds_size); - command_list_length += STATIC_ITEMS; - screen_status_printf(_("Welcome to the key editor!")); - } - - subcmd = -1; - list_window_check_selected(lw, LIST_LENGTH()); + if (cmds == NULL) { + command_definition_t *current_cmds = get_command_definitions(); + size_t cmds_size; + + command_list_length = 0; + while (current_cmds[command_list_length].name) + command_list_length++; + + cmds_size = (command_list_length+1) * sizeof(command_definition_t); + cmds = g_malloc0(cmds_size); + memcpy(cmds, current_cmds, cmds_size); + command_list_length += STATIC_ITEMS; + screen_status_printf(_("Welcome to the key editor!")); + } + + subcmd = -1; + list_window_check_selected(lw, LIST_LENGTH()); } -static void +static void keydef_close(void) { - if( cmds && !keybindings_changed() ) - { - g_free(cmds); - cmds = NULL; - } - else - screen_status_printf(_("Note: Did you forget to \'Apply\' your changes?")); + if (cmds && !keybindings_changed()) { + g_free(cmds); + cmds = NULL; + } else + screen_status_printf(_("Note: Did you forget to \'Apply\' your changes?")); } static const char * keydef_title(char *str, size_t size) { - if( subcmd<0 ) - return _("Edit key bindings"); - - g_snprintf(str, size, _("Edit keys for %s"), cmds[subcmd].name); - return str; + if (subcmd < 0) + return _("Edit key bindings"); + + g_snprintf(str, size, _("Edit keys for %s"), cmds[subcmd].name); + return str; } -static void +static void keydef_paint(mpd_unused screen_t *screen, mpd_unused mpdclient_t *c) { - lw->clear = 1; - list_window_paint(lw, list_callback, NULL); - wrefresh(lw->w); + lw->clear = 1; + list_window_paint(lw, list_callback, NULL); + wrefresh(lw->w); } -static void +static void keydef_update(mpd_unused screen_t *screen, mpd_unused mpdclient_t *c) -{ - if( lw->repaint ) - { - list_window_paint(lw, list_callback, NULL); - wrefresh(lw->w); - lw->repaint = 0; - } +{ + if (lw->repaint) { + list_window_paint(lw, list_callback, NULL); + wrefresh(lw->w); + lw->repaint = 0; + } } static int @@ -314,10 +306,10 @@ keydef_cmd(screen_t *screen, mpd_unused mpdclient_t *c, command_t cmd) switch(cmd) { case CMD_PLAY: - if( subcmd<0 ) { - if( lw->selected == LIST_ITEM_APPLY() ) + if (subcmd < 0) { + if (lw->selected == LIST_ITEM_APPLY()) apply_keys(); - else if( lw->selected == LIST_ITEM_SAVE() ) { + else if (lw->selected == LIST_ITEM_SAVE()) { apply_keys(); save_keys(); } else { @@ -332,7 +324,7 @@ keydef_cmd(screen_t *screen, mpd_unused mpdclient_t *c, command_t cmd) } else assign_new_key(screen->status_window.w, subcmd, - lw->selected-STATIC_SUB_ITEMS); + lw->selected - STATIC_SUB_ITEMS); } lw->repaint = 1; lw->clear = 1; diff --git a/src/screen_play.c b/src/screen_play.c index 265ca4d10..6df8c9f81 100644 --- a/src/screen_play.c +++ b/src/screen_play.c @@ -1,6 +1,4 @@ -/* - * $Id$ - * +/* * (c) 2004 by Kalle Wallin <kaw@linux.se> * * This program is free software; you can redistribute it and/or modify @@ -44,10 +42,10 @@ typedef struct { - GList **list; - GList **dir_list; - screen_t *screen; - mpdclient_t *c; + GList **list; + GList **dir_list; + screen_t *screen; + mpdclient_t *c; } completion_callback_data_t; static GTime input_timestamp; @@ -58,12 +56,12 @@ static void playlist_changed_callback(mpdclient_t *c, int event, gpointer data) { D("screen_play.c> playlist_callback() [%d]\n", event); - switch(event) { + switch (event) { case PLAYLIST_EVENT_DELETE: break; case PLAYLIST_EVENT_MOVE: lw->selected = *((int *) data); - if( lw->selected<lw->start ) + if (lw->selected < lw->start) lw->start--; break; default: @@ -141,7 +139,7 @@ save_post_completion_cb(mpd_unused GCompletion *gcmp, mpd_unused gchar *line, completion_callback_data_t *tmp = (completion_callback_data_t *)data; screen_t *screen = tmp->screen; - if( g_list_length(items)>=1 ) { + if (g_list_length(items) >= 1) { screen_display_completion_list(screen, items); lw->clear = 1; } @@ -150,179 +148,176 @@ save_post_completion_cb(mpd_unused GCompletion *gcmp, mpd_unused gchar *line, int playlist_save(screen_t *screen, mpdclient_t *c, char *name, char *defaultname) { - gchar *filename; - gint error; - GCompletion *gcmp; - GList *list = NULL; - completion_callback_data_t data; - - if( name==NULL ) - { - /* initialize completion support */ - gcmp = g_completion_new(NULL); - 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; - wrln_post_completion_callback = save_post_completion_cb; - - - /* query the user for a filename */ - filename = screen_readln(screen->status_window.w, - _("Save playlist as: "), - defaultname, - NULL, - gcmp); - - /* destroy completion support */ - wrln_completion_callback_data = NULL; - wrln_pre_completion_callback = NULL; - wrln_post_completion_callback = NULL; - g_completion_free(gcmp); - list = string_list_free(list); - if( filename ) - filename=g_strstrip(filename); - } - else - { - filename=g_strdup(name); - } - if( filename==NULL || filename[0]=='\0' ) - return -1; - /* send save command to mpd */ - D("Saving playlist as \'%s \'...\n", filename); - if( (error=mpdclient_cmd_save_playlist(c, filename)) ) - { - gint code = GET_ACK_ERROR_CODE(error); - - if( code == MPD_ACK_ERROR_EXIST ) - { - char *buf; - int key; - - buf=g_strdup_printf(_("Replace %s [%s/%s] ? "), filename, YES, NO); - key = tolower(screen_getch(screen->status_window.w, buf)); - g_free(buf); - if( key == YES[0] ) - { - if( mpdclient_cmd_delete_playlist(c, filename) ) - { - g_free(filename); - return -1; + gchar *filename; + gint error; + GCompletion *gcmp; + GList *list = NULL; + completion_callback_data_t data; + + if (name == NULL) { + /* initialize completion support */ + gcmp = g_completion_new(NULL); + 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; + wrln_post_completion_callback = save_post_completion_cb; + + + /* query the user for a filename */ + filename = screen_readln(screen->status_window.w, + _("Save playlist as: "), + defaultname, + NULL, + gcmp); + + /* destroy completion support */ + wrln_completion_callback_data = NULL; + wrln_pre_completion_callback = NULL; + wrln_post_completion_callback = NULL; + g_completion_free(gcmp); + list = string_list_free(list); + if( filename ) + filename=g_strstrip(filename); + } else + filename=g_strdup(name); + + if (filename == NULL || filename[0] == '\0') + return -1; + + /* send save command to mpd */ + D("Saving playlist as \'%s \'...\n", filename); + if ((error = mpdclient_cmd_save_playlist(c, filename))) { + gint code = GET_ACK_ERROR_CODE(error); + + if (code == MPD_ACK_ERROR_EXIST) { + char *buf; + int key; + + buf = g_strdup_printf(_("Replace %s [%s/%s] ? "), + filename, YES, NO); + key = tolower(screen_getch(screen->status_window.w, + buf)); + g_free(buf); + + if (key == YES[0]) { + if (mpdclient_cmd_delete_playlist(c, filename)) { + g_free(filename); + return -1; + } + + error = playlist_save(screen, c, filename, NULL); + g_free(filename); + return error; + } + + screen_status_printf(_("Aborted!")); } - error = playlist_save(screen, c, filename, NULL); - g_free(filename); - return error; - } - screen_status_printf(_("Aborted!")); + + g_free(filename); + return -1; } - g_free(filename); - return -1; - } - /* success */ - screen_status_printf(_("Saved %s"), filename); - g_free(filename); - return 0; + + /* success */ + screen_status_printf(_("Saved %s"), filename); + g_free(filename); + return 0; } static void add_dir(GCompletion *gcmp, gchar *dir, GList **dir_list, - GList **list, mpdclient_t *c) + GList **list, mpdclient_t *c) { - g_completion_remove_items(gcmp, *list); - *list = string_list_remove(*list, dir); - *list = gcmp_list_from_path(c, dir, *list, GCMP_TYPE_RFILE); - g_completion_add_items(gcmp, *list); - *dir_list = g_list_append(*dir_list, g_strdup(dir)); + g_completion_remove_items(gcmp, *list); + *list = string_list_remove(*list, dir); + *list = gcmp_list_from_path(c, dir, *list, GCMP_TYPE_RFILE); + g_completion_add_items(gcmp, *list); + *dir_list = g_list_append(*dir_list, g_strdup(dir)); } static void add_pre_completion_cb(GCompletion *gcmp, gchar *line, void *data) { - completion_callback_data_t *tmp = (completion_callback_data_t *)data; - GList **dir_list = tmp->dir_list; - GList **list = tmp->list; - mpdclient_t *c = tmp->c; - - D("pre_completion()...\n"); - if( *list == NULL ) - { - /* create initial list */ - *list = gcmp_list_from_path(c, "", NULL, GCMP_TYPE_RFILE); - g_completion_add_items(gcmp, *list); - } - else if( line && line[0] && line[strlen(line)-1]=='/' && - string_list_find(*dir_list, line) == NULL ) - { - /* add directory content to list */ - add_dir(gcmp, line, dir_list, list, c); - } + completion_callback_data_t *tmp = (completion_callback_data_t *)data; + GList **dir_list = tmp->dir_list; + GList **list = tmp->list; + mpdclient_t *c = tmp->c; + + D("pre_completion()...\n"); + if (*list == NULL) { + /* create initial list */ + *list = gcmp_list_from_path(c, "", NULL, GCMP_TYPE_RFILE); + g_completion_add_items(gcmp, *list); + } else if (line && line[0] && line[strlen(line)-1]=='/' && + string_list_find(*dir_list, line) == NULL) { + /* add directory content to list */ + add_dir(gcmp, line, dir_list, list, c); + } } static void add_post_completion_cb(GCompletion *gcmp, gchar *line, - GList *items, void *data) + GList *items, void *data) { - completion_callback_data_t *tmp = (completion_callback_data_t *)data; - GList **dir_list = tmp->dir_list; - GList **list = tmp->list; - mpdclient_t *c = tmp->c; - screen_t *screen = tmp->screen; - - D("post_completion()...\n"); - if( g_list_length(items)>=1 ) - { - screen_display_completion_list(screen, items); - lw->clear = 1; - } - - if( line && line[0] && line[strlen(line)-1]=='/' && - string_list_find(*dir_list, line) == NULL ) - { - /* add directory content to list */ - add_dir(gcmp, line, dir_list, list, c); - } + completion_callback_data_t *tmp = (completion_callback_data_t *)data; + GList **dir_list = tmp->dir_list; + GList **list = tmp->list; + mpdclient_t *c = tmp->c; + screen_t *screen = tmp->screen; + + D("post_completion()...\n"); + if (g_list_length(items) >= 1) { + screen_display_completion_list(screen, items); + lw->clear = 1; + } + + if (line && line[0] && line[strlen(line) - 1] == '/' && + string_list_find(*dir_list, line) == NULL) { + /* add directory content to list */ + add_dir(gcmp, line, dir_list, list, c); + } } static int handle_add_to_playlist(screen_t *screen, mpdclient_t *c) { - gchar *path; - GCompletion *gcmp; - GList *list = NULL; - GList *dir_list = NULL; - completion_callback_data_t data; - - /* initialize completion support */ - gcmp = g_completion_new(NULL); - 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, - _("Add: "), - NULL, - NULL, - gcmp); - - /* destroy completion data */ - wrln_completion_callback_data = NULL; - wrln_pre_completion_callback = NULL; - wrln_post_completion_callback = NULL; - g_completion_free(gcmp); - string_list_free(list); - string_list_free(dir_list); - - /* add the path to the playlist */ - if( path && path[0] ) - mpdclient_cmd_add_path(c, path); - - return 0; + gchar *path; + GCompletion *gcmp; + GList *list = NULL; + GList *dir_list = NULL; + completion_callback_data_t data; + + /* initialize completion support */ + gcmp = g_completion_new(NULL); + 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, + _("Add: "), + NULL, + NULL, + gcmp); + + /* destroy completion data */ + wrln_completion_callback_data = NULL; + wrln_pre_completion_callback = NULL; + wrln_post_completion_callback = NULL; + g_completion_free(gcmp); + string_list_free(list); + string_list_free(dir_list); + + /* add the path to the playlist */ + if (path && path[0]) + mpdclient_cmd_add_path(c, path); + + return 0; } static void @@ -390,10 +385,10 @@ play_update(screen_t *screen, mpdclient_t *c) } /* center the cursor */ - if( options.auto_center ) { + if (options.auto_center) { static int prev_song_id = 0; - if( c->song && prev_song_id != c->song->id ) { + if (c->song && prev_song_id != c->song->id) { center_playing_item(c); prev_song_id = c->song->id; } diff --git a/src/screen_search.c b/src/screen_search.c index 7dfc58d0f..8242f1350 100644 --- a/src/screen_search.c +++ b/src/screen_search.c @@ -1,6 +1,4 @@ -/* - * $Id$ - * +/* * (c) 2004 by Kalle Wallin <kaw@linux.se> * * This program is free software; you can redistribute it and/or modify diff --git a/src/screen_utils.c b/src/screen_utils.c index b6141216c..6ee1eba68 100644 --- a/src/screen_utils.c +++ b/src/screen_utils.c @@ -1,6 +1,4 @@ -/* - * $Id$ - * +/* * (c) 2004 by Kalle Wallin <kaw@linux.se> * * This program is free software; you can redistribute it and/or modify |