diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/interface.c | 9 | ||||
-rw-r--r-- | src/interface.h | 2 | ||||
-rw-r--r-- | src/pa-sink-ctl.c | 12 |
3 files changed, 12 insertions, 11 deletions
diff --git a/src/interface.c b/src/interface.c index 905ffa3..4af03c0 100644 --- a/src/interface.c +++ b/src/interface.c @@ -19,6 +19,7 @@ #include <unistd.h> #include <string.h> +#include <stdarg.h> #include <sys/ioctl.h> #include <glib.h> @@ -209,11 +210,15 @@ interface_clear(struct context *ctx) } void -interface_set_status(struct context *ctx, const gchar *msg) +interface_set_status(struct context *ctx, const gchar *msg, ...) { + va_list ap; + if (msg != NULL) { g_free(ctx->status); - ctx->status = g_strdup(msg); + va_start(ap, msg); + ctx->status = g_strdup_vprintf(msg, ap); + va_end(ap); } werase(ctx->msg_win); box(ctx->msg_win, 0, 0); diff --git a/src/interface.h b/src/interface.h index abd6341..d07f298 100644 --- a/src/interface.h +++ b/src/interface.h @@ -38,6 +38,6 @@ void interface_clear(struct context *ctx); void -interface_set_status(struct context *ctx, const gchar *); +interface_set_status(struct context *ctx, const gchar *, ...); #endif diff --git a/src/pa-sink-ctl.c b/src/pa-sink-ctl.c index 7dfe187..7ee00eb 100644 --- a/src/pa-sink-ctl.c +++ b/src/pa-sink-ctl.c @@ -348,10 +348,8 @@ main(int argc, char** argv) mainloop_api = pa_glib_mainloop_get_api(m); if (!(ctx.context = pa_context_new(mainloop_api, "pa-sink-ctl"))) { - char *s = g_strdup_printf("pa_context_new failed: %s\n", - pa_strerror(pa_context_errno(ctx.context))); - interface_set_status(&ctx, s); - g_free(s); + interface_set_status(&ctx, "pa_context_new failed: %s\n", + pa_strerror(pa_context_errno(ctx.context))); } // define callback for connection init @@ -359,10 +357,8 @@ main(int argc, char** argv) context_state_callback, &ctx); if (pa_context_connect(ctx.context, NULL, PA_CONTEXT_NOAUTOSPAWN, NULL)) { - char *s = g_strdup_printf("pa_context_connect failed: %s\n", - pa_strerror(pa_context_errno(ctx.context))); - interface_set_status(&ctx, s); - g_free(s); + interface_set_status(&ctx, "pa_context_connect failed: %s\n", + pa_strerror(pa_context_errno(ctx.context))); } ctx.return_value = 0; |