Code

command.c: put curly braces around a single large statement
[ncmpc.git] / src / screen_file.c
index d9faa69ac66430032a736b971de0211b9a8db7dc..515937750980757325ab5aedeb6dd18dfd3e101c 100644 (file)
@@ -1,5 +1,5 @@
 /* ncmpc (Ncurses MPD Client)
- * (c) 2004-2009 The Music Player Daemon Project
+ * (c) 2004-2010 The Music Player Daemon Project
  * Project homepage: http://musicpd.org
 
  * This program is free software; you can redistribute it and/or modify
@@ -56,18 +56,15 @@ screen_file_load_list(struct mpdclient *c, struct filelist *filelist)
 {
        struct mpd_connection *connection;
 
-       if (!mpdclient_is_connected(c))
-               return;
-
        connection = mpdclient_get_connection(c);
+       if (connection == NULL)
+               return;
 
        mpd_send_list_meta(connection, current_path);
        filelist_recv(filelist, connection);
 
-       if (mpd_response_finish(connection))
+       if (mpdclient_finish_command(c))
                filelist_sort_dir_play(filelist, compare_filelist_entry_path);
-       else
-               mpdclient_handle_error(c);
 }
 
 static void
@@ -98,9 +95,7 @@ change_directory(struct mpdclient *c, const char *new_path)
 
        screen_file_reload(c);
 
-#ifndef NCMPC_MINI
        screen_browser_sync_highlights(browser.filelist, &c->playlist);
-#endif
 
        list_window_reset(browser.lw);
 
@@ -209,6 +204,9 @@ handle_delete(struct mpdclient *c)
        char *str, *buf;
        int key;
 
+       if (connection == NULL)
+               return;
+
        list_window_get_range(browser.lw, &range);
        for (unsigned i = range.start; i < range.end; ++i) {
                struct filelist_entry *entry =
@@ -280,6 +278,7 @@ static void
 screen_file_open(struct mpdclient *c)
 {
        screen_file_reload(c);
+       screen_browser_sync_highlights(browser.filelist, &c->playlist);
 }
 
 static const char *
@@ -320,18 +319,14 @@ screen_file_update(struct mpdclient *c)
                screen_file_reload(c);
        }
 
-#ifndef NCMPC_MINI
-       if (c->events & (MPD_IDLE_DATABASE | MPD_IDLE_STORED_PLAYLIST |
-                        MPD_IDLE_PLAYLIST))
-               screen_browser_sync_highlights(browser.filelist, &c->playlist);
-#endif
-
        if (c->events & (MPD_IDLE_DATABASE | MPD_IDLE_STORED_PLAYLIST
 #ifndef NCMPC_MINI
-                        | MPD_IDLE_PLAYLIST
+                        | MPD_IDLE_QUEUE
 #endif
-                        ))
+                        )) {
+               screen_browser_sync_highlights(browser.filelist, &c->playlist);
                screen_file_repaint();
+       }
 }
 
 static bool
@@ -363,9 +358,7 @@ screen_file_cmd(struct mpdclient *c, command_t cmd)
 
        case CMD_SCREEN_UPDATE:
                screen_file_reload(c);
-#ifndef NCMPC_MINI
                screen_browser_sync_highlights(browser.filelist, &c->playlist);
-#endif
                screen_file_repaint();
                return false;