summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 9d62836)
raw | patch | inline | side by side (parent: 9d62836)
author | Max Kellermann <max@duempel.org> | |
Wed, 30 Sep 2009 22:13:30 +0000 (00:13 +0200) | ||
committer | Max Kellermann <max@duempel.org> | |
Wed, 30 Sep 2009 22:13:30 +0000 (00:13 +0200) |
src/status_bar.c | patch | blob | history | |
src/status_bar.h | patch | blob | history |
diff --git a/src/status_bar.c b/src/status_bar.c
index 3c167313d7f6674d0234336a4be950ee25abd160..5aaf04bc6d3c2463e852ab241cf50123010684c3 100644 (file)
--- a/src/status_bar.c
+++ b/src/status_bar.c
#include <mpd/client.h>
+#include <assert.h>
#include <string.h>
+static gboolean
+status_bar_clear_message(gpointer data)
+{
+ struct status_bar *p = data;
+ WINDOW *w = p->window.w;
+
+ assert(p != NULL);
+ assert(p->message_source_id != 0);
+
+ p->message_source_id = 0;
+
+ wmove(w, 0, 0);
+ wclrtoeol(w);
+ wrefresh(w);
+
+ return false;
+}
+
void
status_bar_paint(const struct status_bar *p, const struct mpd_status *status,
const struct mpd_song *song)
int x = 0;
char buffer[p->window.cols * 4 + 1];
- if (time(NULL) - p->message_timestamp <= options.status_message_time)
+ if (p->message_source_id != 0)
return;
wmove(w, 0, 0);
waddstr(w, msg);
wnoutrefresh(w);
- p->message_timestamp = time(NULL);
+ if (p->message_source_id != 0)
+ g_source_remove(p->message_source_id);
+ p->message_source_id = g_timeout_add(options.status_message_time * 1000,
+ status_bar_clear_message, p);
}
diff --git a/src/status_bar.h b/src/status_bar.h
index 78b367c1f710ed61eaa6dca7d9408f2dac3dea6f..902ed1a22829824a9f20ba79e0a38af4ca851ac1 100644 (file)
--- a/src/status_bar.h
+++ b/src/status_bar.h
struct status_bar {
struct window window;
- GTime message_timestamp;
+ guint message_source_id;
};
static inline void
leaveok(p->window.w, false);
keypad(p->window.w, true);
- p->message_timestamp = 0;
+ p->message_source_id = 0;
}
static inline void
status_bar_deinit(struct status_bar *p)
{
delwin(p->window.w);
+
+ if (p->message_source_id != 0)
+ g_source_remove(p->message_source_id);
}
void