summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 96ba600)
raw | patch | inline | side by side (parent: 96ba600)
author | Kalle Wallin <kaw@linux.se> | |
Sat, 19 Jun 2004 19:33:46 +0000 (19:33 +0000) | ||
committer | Kalle Wallin <kaw@linux.se> | |
Sat, 19 Jun 2004 19:33:46 +0000 (19:33 +0000) |
ChangeLog | patch | blob | history | |
src/screen_play.c | patch | blob | history | |
src/utils.c | patch | blob | history | |
src/utils.h | patch | blob | history |
diff --git a/ChangeLog b/ChangeLog
index 75d9fd09ee5d4982f560dac34a4c6b3c75a788da..6bacbc91d24ba9ced2e0ec50992385b5c8f02413 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
+2004-06-17 Kalle Wallin <kaw@linux.se>
+ * screen_utils.c: fixed the display of completion lists
+ * wreadln.c: try to complete even if the line is empty
+ * utils.c: added type argument to gcmp_list_from_path()
+ * screen_play.c: added completion support to handle_save_playlist()
+ * command.[c|h]: check_key_bindings() can now write an error messages
+ to a buffer instead of stderr
+ * main.c: display errors without exiting when key bindings are broken
+
+2004-06-17 Kalle Wallin <kaw@linux.se>
+ * Added a add command, used to add urls or files to the playlist, with
+ file completion.
+
+
+2004-06-16 Kalle Wallin <kaw@linux.se>
+ * mpdclient.c: enabled plchanges, make shure the playlist length is
+ updated when removing songs
+
2004-06-16 Kalle Wallin <kaw@linux.se>
* libmpdclient updated (r1507)
* mpdclient: add path to mpdclient_cmd_db_update()
* conf.c: Added support for cusomized format strings with
list-format and status-format
* options.c: Added status_format, list_format fields
- * mpdclient.c: Sort playlist if needed after plchanges,
+ * mpdclient.c: disable plchanges (needs more work),
update the song position fields in mpdclient_cmd_move,
use song id's by default (define ENABLE_SONG_ID), disable plchanges
* screen_play.c: Offer to overwrite when saving playlists
diff --git a/src/screen_play.c b/src/screen_play.c
index 3bb16ee638d49fa20e3a7102960468c25d981dce..fc130b9861cc61845dd33cd8e4b5e04eac170f82 100644 (file)
--- a/src/screen_play.c
+++ b/src/screen_play.c
{
gchar *filename;
gint error;
+ GCompletion *gcmp;
+ GList *list = NULL;
+
+ void pre_completion_cb(GCompletion *gcmp, gchar *line)
+ {
+ if( list == NULL )
+ {
+ /* create completion list */
+ list = gcmp_list_from_path(c, "", NULL, GCMP_TYPE_PLAYLIST);
+ g_completion_add_items(gcmp, list);
+ }
+ }
+
+ void post_completion_cb(GCompletion *gcmp, gchar *line, GList *items)
+ {
+ if( g_list_length(items)>=1 )
+ screen_display_completion_list(screen, items);
+ }
if( name==NULL )
{
+ /* initialize completion support */
+ gcmp = g_completion_new(NULL);
+ g_completion_set_compare(gcmp, strncmp);
+ wrln_pre_completion_callback = pre_completion_cb;
+ wrln_post_completion_callback = post_completion_cb;
+
/* query the user for a filename */
- filename=screen_getstr(screen->status_window.w, _("Save playlist as: "));
+ filename = screen_readln(screen->status_window.w,
+ _("Save playlist as: "),
+ NULL,
+ NULL,
+ gcmp);
filename=trim(filename);
+
+ /* destroy completion support */
+ wrln_pre_completion_callback = NULL;
+ wrln_post_completion_callback = NULL;
+ g_completion_free(gcmp);
+ list = string_list_free(list);
}
else
{
{
g_completion_remove_items(gcmp, list);
list = string_list_remove(list, dir);
- list = gcmp_list_from_path(c, dir, list);
+ 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));
}
void pre_completion_cb(GCompletion *gcmp, gchar *line)
{
+ D("pre_completion()...\n");
if( list == NULL )
{
/* create initial list */
- list = gcmp_list_from_path(c, "", NULL);
+ 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]=='/' &&
void post_completion_cb(GCompletion *gcmp, gchar *line, GList *items)
{
+ D("post_completion()...\n");
if( g_list_length(items)>1 )
screen_display_completion_list(screen, items);
}
}
-
+ /* initialize completion support */
gcmp = g_completion_new(NULL);
g_completion_set_compare(gcmp, strncmp);
-
wrln_pre_completion_callback = pre_completion_cb;
wrln_post_completion_callback = post_completion_cb;
+ /* get path */
path = screen_readln(screen->status_window.w,
_("Add: "),
NULL,
NULL,
gcmp);
+
+ /* destroy completion data */
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);
+ lw->clear = 1;
+ lw->repaint = 1;
+
return 0;
}
diff --git a/src/utils.c b/src/utils.c
index 49841a350c1baffd57aee9d208492f0860d1eb3f..58340c42ece27d90c977dc9f9a8172e722e46d2b 100644 (file)
--- a/src/utils.c
+++ b/src/utils.c
/* create a list suiteble for GCompletion from path */
GList *
-gcmp_list_from_path(mpdclient_t *c, gchar *path, GList *list)
+gcmp_list_from_path(mpdclient_t *c, gchar *path, GList *list, gint types)
{
GList *flist = NULL;
mpdclient_filelist_t *filelist;
mpd_InfoEntity *entity = entry ? entry->entity : NULL;
char *name = NULL;
- if( entity && entity->type==MPD_INFO_ENTITY_TYPE_DIRECTORY )
+ if( entity && entity->type==MPD_INFO_ENTITY_TYPE_DIRECTORY &&
+ types & GCMP_TYPE_DIR)
{
mpd_Directory *dir = entity->info.directory;
gchar *tmp = utf8_to_locale(dir->path);
strcat(name, "/");
g_free(tmp);
}
- else if( entity && entity->type==MPD_INFO_ENTITY_TYPE_SONG )
+ else if( entity && entity->type==MPD_INFO_ENTITY_TYPE_SONG &&
+ types & GCMP_TYPE_FILE )
{
mpd_Song *song = entity->info.song;
name = utf8_to_locale(song->file);
}
+ else if( entity && entity->type==MPD_INFO_ENTITY_TYPE_PLAYLISTFILE &&
+ types & GCMP_TYPE_PLAYLIST )
+ {
+ mpd_PlaylistFile *plf = entity->info.playlistFile;
+ name = utf8_to_locale(plf->path);
+ }
+
if( name )
list = g_list_append(list, name);
diff --git a/src/utils.h b/src/utils.h
index 998a0decead8893abd24834b8a1f4be640d6495d..4446d1cd705fa28c69dbc292c899af4b071a03c1 100644 (file)
--- a/src/utils.h
+++ b/src/utils.h
#ifndef UTILS_H
#define UTILS_H
+
/* functions for lists containing strings */
GList *string_list_free(GList *string_list);
GList *string_list_find(GList *string_list, gchar *str);
GList *string_list_remove(GList *string_list, gchar *str);
/* create a string list from path - used for completion */
-GList *gcmp_list_from_path(mpdclient_t *c, gchar *path, GList *list);
+#define GCMP_TYPE_DIR (0x01 << 0)
+#define GCMP_TYPE_FILE (0x01 << 1)
+#define GCMP_TYPE_PLAYLIST (0x01 << 2)
+#define GCMP_TYPE_RFILE (GCMP_TYPE_DIR | GCMP_TYPE_FILE)
+#define GCMP_TYPE_RPLAYLIST (GCMP_TYPE_DIR | GCMP_TYPE_PLAYLIST)
+
+GList *gcmp_list_from_path(mpdclient_t *c,
+ gchar *path,
+ GList *list,
+ gint types);
#endif