From: Max Kellermann Date: Fri, 8 Nov 2013 17:04:36 +0000 (+0100) Subject: status_bar: export _clear_message() X-Git-Tag: v0.22~22 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=bd2b1fb43c5d83a0fceafbf79f2db73bef959b15;p=ncmpc.git status_bar: export _clear_message() --- diff --git a/src/screen_status.c b/src/screen_status.c index 36f8753..ca61fee 100644 --- a/src/screen_status.c +++ b/src/screen_status.c @@ -22,6 +22,12 @@ #include +void +screen_status_clear_message(void) +{ + status_bar_clear_message(&screen.status_bar); +} + void screen_status_message(const char *msg) { diff --git a/src/screen_status.h b/src/screen_status.h index d951290..60959eb 100644 --- a/src/screen_status.h +++ b/src/screen_status.h @@ -20,6 +20,9 @@ #ifndef NCMPC_SCREEN_STATUS_H #define NCMPC_SCREEN_STATUS_H +void +screen_status_clear_message(void); + void screen_status_message(const char *msg); diff --git a/src/status_bar.c b/src/status_bar.c index c6357f4..b1b301f 100644 --- a/src/status_bar.c +++ b/src/status_bar.c @@ -61,22 +61,21 @@ status_bar_deinit(struct status_bar *p) #endif } -static gboolean -status_bar_clear_message(gpointer data) +void +status_bar_clear_message(struct status_bar *p) { - struct status_bar *p = data; - WINDOW *w = p->window.w; - assert(p != NULL); - assert(p->message_source_id != 0); - p->message_source_id = 0; + if (p->message_source_id != 0) { + g_source_remove(p->message_source_id); + p->message_source_id = 0; + } + + WINDOW *w = p->window.w; wmove(w, 0, 0); wclrtoeol(w); wrefresh(w); - - return false; } #ifndef NCMPC_MINI @@ -242,6 +241,17 @@ status_bar_resize(struct status_bar *p, unsigned width, int y, int x) mvwin(p->window.w, y, x); } +static gboolean +status_bar_clear_message_cb(gpointer data) +{ + struct status_bar *p = data; + assert(p->message_source_id != 0); + p->message_source_id = 0; + + status_bar_clear_message(p); + return false; +} + void status_bar_message(struct status_bar *p, const char *msg) { @@ -261,5 +271,5 @@ status_bar_message(struct status_bar *p, const char *msg) 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); + status_bar_clear_message_cb, p); } diff --git a/src/status_bar.h b/src/status_bar.h index 71298e0..9c8f4a9 100644 --- a/src/status_bar.h +++ b/src/status_bar.h @@ -60,4 +60,7 @@ status_bar_resize(struct status_bar *p, unsigned width, int y, int x); void status_bar_message(struct status_bar *p, const char *msg); +void +status_bar_clear_message(struct status_bar *p); + #endif