summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 9f8c904)
raw | patch | inline | side by side (parent: 9f8c904)
author | Max Kellermann <max@duempel.org> | |
Thu, 25 Sep 2008 15:44:57 +0000 (17:44 +0200) | ||
committer | Max Kellermann <max@duempel.org> | |
Thu, 25 Sep 2008 15:44:57 +0000 (17:44 +0200) |
Repaint the file screen on demand. No need for the update() method
anymore.
anymore.
src/screen_file.c | patch | blob | history |
diff --git a/src/screen_file.c b/src/screen_file.c
index efea4db6000ad8f2bea63de4125a63e5683a7baf..05e8ad29924441607e0ffe2935353373262a4955 100644 (file)
--- a/src/screen_file.c
+++ b/src/screen_file.c
static struct screen_browser browser;
+static void
+browse_paint(mpdclient_t *c);
+
+static void
+file_repaint(void)
+{
+ browse_paint(NULL);
+ wrefresh(browser.lw->w);
+}
+
+static void
+file_repaint_if_active(void)
+{
+ if (get_cur_mode_id() == 1) /* XXX don't use the literal number */
+ file_repaint();
+}
+
/* the db have changed -> update the filelist */
static void
file_changed_callback(mpdclient_t *c, mpd_unused int event,
browser.filelist = mpdclient_filelist_update(c, browser.filelist);
sync_highlights(c, browser.filelist);
list_window_check_selected(browser.lw, filelist_length(browser.filelist));
+
+ file_repaint_if_active();
}
/* the playlist have been updated -> fix highlights */
playlist_changed_callback(mpdclient_t *c, int event, gpointer data)
{
browser_playlist_changed(&browser, c, event, data);
+
+ file_repaint_if_active();
}
static int
list_window_paint(browser.lw, browser_lw_callback, browser.filelist);
}
-static void
-browse_update(mpd_unused screen_t *screen, mpdclient_t *c)
-{
- if (browser.filelist->updated) {
- browse_paint(c);
- browser.filelist->updated = FALSE;
- return;
- }
-
- list_window_paint(browser.lw, browser_lw_callback, browser.filelist);
-}
-
static int
browse_cmd(screen_t *screen, mpdclient_t *c, command_t cmd)
{
switch(cmd) {
case CMD_PLAY:
browser_handle_enter(&browser, c);
+ file_repaint();
return 1;
case CMD_GO_ROOT_DIRECTORY:
- return browser_change_directory(&browser, c, NULL, "");
- break;
+ browser_change_directory(&browser, c, NULL, "");
+ file_repaint();
+ return 1;
case CMD_GO_PARENT_DIRECTORY:
- return browser_change_directory(&browser, c, NULL, "..");
- break;
+ browser_change_directory(&browser, c, NULL, "..");
+ file_repaint();
+ return 1;
case CMD_SELECT:
if (browser_handle_select(&browser, c) == 0) {
/* continue and select next item... */
break;
case CMD_DELETE:
handle_delete(screen, c);
+ file_repaint();
break;
case CMD_SAVE_PLAYLIST:
handle_save(screen, c);
browser.filelist = mpdclient_filelist_update(c, browser.filelist);
list_window_check_selected(browser.lw,
filelist_length(browser.filelist));
+ file_repaint();
+
screen_status_printf(_("Screen updated!"));
return 0;
case CMD_LIST_RFIND:
case CMD_LIST_FIND_NEXT:
case CMD_LIST_RFIND_NEXT:
- return screen_find(screen,
- browser.lw, filelist_length(browser.filelist),
- cmd, browser_lw_callback,
- browser.filelist);
+ screen_find(screen,
+ browser.lw, filelist_length(browser.filelist),
+ cmd, browser_lw_callback,
+ browser.filelist);
+ file_repaint();
+ return 1;
+
case CMD_MOUSE_EVENT:
- return browser_handle_mouse_event(&browser, c);
+ if (browser_handle_mouse_event(&browser, c))
+ file_repaint();
+
+ return 1;
+
default:
break;
}
- return list_window_cmd(browser.lw, filelist_length(browser.filelist), cmd);
+ if (list_window_cmd(browser.lw, filelist_length(browser.filelist),
+ cmd)) {
+ file_repaint();
+ return 1;
+ }
+
+ return 0;
}
const struct screen_functions screen_browse = {
.open = browse_open,
.resize = browse_resize,
.paint = browse_paint,
- .update = browse_update,
.cmd = browse_cmd,
.get_title = browse_title,
};