[virt-tools-list] [PATCH 14/22] app: set subtitle using VTE name

marcandre.lureau at redhat.com marcandre.lureau at redhat.com
Tue Jul 31 13:41:17 UTC 2018


From: Marc-André Lureau <marcandre.lureau at redhat.com>

Currently, subtitle indicate the monitor number, ex: "Fedora (1)".

Custom subtitle use %d to place the monitor number.

Let's make this placeholder more generic to place the name of the
console, ex: "Fedora (Serial)".

Signed-off-by: Marc-André Lureau <marcandre.lureau at redhat.com>
---
 src/virt-viewer-app.c | 22 +++++++++++++++++-----
 1 file changed, 17 insertions(+), 5 deletions(-)

diff --git a/src/virt-viewer-app.c b/src/virt-viewer-app.c
index 62dbf19..a14c92d 100644
--- a/src/virt-viewer-app.c
+++ b/src/virt-viewer-app.c
@@ -62,6 +62,8 @@
 #include "virt-viewer-session-spice.h"
 #endif
 
+#include "virt-viewer-display-vte.h"
+
 gboolean doDebug = FALSE;
 
 /* Signal handlers for about dialog */
@@ -699,15 +701,25 @@ virt_viewer_app_set_window_subtitle(VirtViewerApp *app,
 {
     gchar *subtitle = NULL;
     const gchar *title = virt_viewer_app_get_title(app);
+    VirtViewerDisplay *display = virt_viewer_window_get_display(window);
 
     if (title != NULL) {
         gchar *d = strstr(title, "%d");
+        gchar *desc = NULL;
+
+        if (display && VIRT_VIEWER_IS_DISPLAY_VTE(display)) {
+            g_object_get(display, "name", &desc, NULL);
+        } else  {
+            desc = g_strdup_printf("%d", nth + 1);
+        }
+
         if (d != NULL) {
             *d = '\0';
-            subtitle = g_strdup_printf("%s%d%s", title, nth + 1, d + 2);
+            subtitle = g_strdup_printf("%s%s%s", title, desc, d + 2);
             *d = '%';
         } else
-            subtitle = g_strdup_printf("%s (%d)", title, nth + 1);
+            subtitle = g_strdup_printf("%s (%s)", title, desc);
+        g_free(desc);
     }
 
     g_object_set(window, "subtitle", subtitle, NULL);
@@ -715,8 +727,8 @@ virt_viewer_app_set_window_subtitle(VirtViewerApp *app,
 }
 
 static void
-set_title(gpointer value,
-          gpointer user_data)
+set_subtitle(gpointer value,
+             gpointer user_data)
 {
     VirtViewerApp *app = user_data;
     VirtViewerWindow *window = value;
@@ -732,7 +744,7 @@ set_title(gpointer value,
 static void
 virt_viewer_app_set_all_window_subtitles(VirtViewerApp *app)
 {
-    g_list_foreach(app->priv->windows, set_title, app);
+    g_list_foreach(app->priv->windows, set_subtitle, app);
 }
 
 static void update_title(gpointer value,
-- 
2.18.0.321.gffc6fa0e39




More information about the virt-tools-list mailing list