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.
This commit is contained in:
Vivia Nikolaidou 2015-06-09 21:24:07 +03:00 committed by Tim-Philipp Müller
parent 199d81088f
commit 0aacd7f393

View file

@ -458,7 +458,8 @@ play_timeout (gpointer user_data)
{ {
GstPlay *play = user_data; GstPlay *play = user_data;
gint64 pos = -1, dur = -1; gint64 pos = -1, dur = -1;
gchar status[64] = { 0, }; const gchar *paused = _("Paused");
gchar *status;
if (play->buffering) if (play->buffering)
return TRUE; return TRUE;
@ -466,10 +467,14 @@ play_timeout (gpointer user_data)
gst_element_query_position (play->playbin, GST_FORMAT_TIME, &pos); gst_element_query_position (play->playbin, GST_FORMAT_TIME, &pos);
gst_element_query_duration (play->playbin, GST_FORMAT_TIME, &dur); gst_element_query_duration (play->playbin, GST_FORMAT_TIME, &dur);
if (play->desired_state == GST_STATE_PAUSED) if (play->desired_state == GST_STATE_PAUSED) {
g_snprintf (status, sizeof (status), "Paused"); status = (gchar *) paused;
else } else {
memset (status, ' ', sizeof (status) - 1); gint len = g_utf8_strlen (paused, -1);
status = g_newa (gchar, len + 1);
memset (status, ' ', len);
status[len] = '\0';
}
if (pos >= 0 && dur > 0) { if (pos >= 0 && dur > 0) {
gchar dstr[32], pstr[32]; gchar dstr[32], pstr[32];