From 0aacd7f393607f95710f608549213fe5c6b879d0 Mon Sep 17 00:00:00 2001 From: Vivia Nikolaidou Date: Tue, 9 Jun 2015 21:24:07 +0300 Subject: [PATCH] tools: gst-play: don't print 64 whitespaces next to the time indication Printing 64 whitespaces to erase the "Paused" message (after \r) would make it wrap to the next line on shorter terminals. Instead we only print the amount of spaces needed. Also mark the "Paused" string for translation while we're at it. --- tools/gst-play.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/tools/gst-play.c b/tools/gst-play.c index 52f6d71..c9b6e73 100644 --- a/tools/gst-play.c +++ b/tools/gst-play.c @@ -458,7 +458,8 @@ play_timeout (gpointer user_data) { GstPlay *play = user_data; gint64 pos = -1, dur = -1; - gchar status[64] = { 0, }; + const gchar *paused = _("Paused"); + gchar *status; if (play->buffering) return TRUE; @@ -466,10 +467,14 @@ play_timeout (gpointer user_data) gst_element_query_position (play->playbin, GST_FORMAT_TIME, &pos); gst_element_query_duration (play->playbin, GST_FORMAT_TIME, &dur); - if (play->desired_state == GST_STATE_PAUSED) - g_snprintf (status, sizeof (status), "Paused"); - else - memset (status, ' ', sizeof (status) - 1); + if (play->desired_state == GST_STATE_PAUSED) { + status = (gchar *) paused; + } else { + gint len = g_utf8_strlen (paused, -1); + status = g_newa (gchar, len + 1); + memset (status, ' ', len); + status[len] = '\0'; + } if (pos >= 0 && dur > 0) { gchar dstr[32], pstr[32]; -- 2.7.4