From 0325901984b759c8a5781ca3fb078f13807c91eb Mon Sep 17 00:00:00 2001 From: Pino Toscano Date: Wed, 22 Jul 2020 14:35:03 +0200 Subject: [PATCH] Create single strings for the window title Currently there is a strings with four placeholders that represents optional bits: the "press to release", a whitespace (!), the subtitle, and the application title. This is suboptimal, because it hides the way the title is composed, and makes it hard to properly translate. Instead of this string puzzle, create separate strings for each case (there are only four of them, and one is only the application title). Each of the string has all the static text availale, with a proper comment explaining the layout. Signed-off-by: Pino Toscano --- src/virt-viewer-window.c | 41 +++++++++++++++++++++++++--------------- 1 file changed, 26 insertions(+), 15 deletions(-) diff --git a/src/virt-viewer-window.c b/src/virt-viewer-window.c index 9203762..2441820 100644 --- a/src/virt-viewer-window.c +++ b/src/virt-viewer-window.c @@ -1390,7 +1390,6 @@ virt_viewer_window_update_title(VirtViewerWindow *self) { VirtViewerWindowPrivate *priv = self->priv; char *title; - gchar *ungrab = NULL; if (priv->grabbed) { gchar *label; @@ -1406,29 +1405,41 @@ virt_viewer_window_update_title(VirtViewerWindow *self) label = g_strdup(_("Ctrl_L+Alt_L")); } - ungrab = g_strdup_printf(_("(Press %s to release pointer)"), label); - g_free(label); - } + if (priv->subtitle) { + /* translators: + * This is " - " + * Such as: "(Press Ctrl+Alt to release pointer) BigCorpTycoon MOTD - Virt Viewer" + */ + title = g_strdup_printf(_("(Press %s to release pointer) %s - %s"), + label, + priv->subtitle, + g_get_application_name()); + } else { + /* translators: + * This is " - " + * Such as: "(Press Ctrl+Alt to release pointer) - Virt Viewer" + */ + title = g_strdup_printf(_("(Press %s to release pointer) - %s"), + label, + g_get_application_name()); + } - if (!ungrab && !priv->subtitle) - title = g_strdup(g_get_application_name()); - else + g_free(label); + } else if (priv->subtitle) { /* translators: - * This is " - " - * Such as: "(Press Ctrl+Alt to release pointer) BigCorpTycoon MOTD - Virt Viewer" + * This is " - " + * Such as: "BigCorpTycoon MOTD - Virt Viewer" */ - title = g_strdup_printf(_("%s%s%s - %s"), - /* translators: */ - ungrab ? ungrab : "", - /* translators: */ - ungrab && priv->subtitle ? _(" ") : "", + title = g_strdup_printf(_("%s - %s"), priv->subtitle, g_get_application_name()); + } else { + title = g_strdup(g_get_application_name()); + } gtk_window_set_title(GTK_WINDOW(priv->window), title); g_free(title); - g_free(ungrab); } void