[virt-tools-list] [PATCH v2 08/16] app: set subtitle using VTE name

Victor Toso victortoso at redhat.com
Thu Dec 20 16:31:02 UTC 2018


Hi,

On Wed, Sep 26, 2018 at 07:26:31PM +0400, marcandre.lureau at redhat.com wrote:
> 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)".

Sure,

> 
> 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 889cc6b..7b750c6 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 */
> @@ -701,15 +703,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);

Please, move it to be inside the if scope

Acked-by: Victor Toso <victortoso at redhat.com>

>  
>      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);
> @@ -717,8 +729,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;
> @@ -734,7 +746,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.19.0.271.gfe8321ec05
> 
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/virt-tools-list/attachments/20181220/48b7f17f/attachment.sig>


More information about the virt-tools-list mailing list