[virt-tools-list] [PATCH] Set window title to VM name
Christophe Fergeau
cfergeau at redhat.com
Wed Nov 21 09:02:32 UTC 2018
hey,
On Mon, Nov 19, 2018 at 03:29:45AM +0000, Ben Mathews wrote:
> The attached patch address an issue with virt-view not setting the titlebar text to be the title of the VM (previously discussed on: https://www.redhat.com/archives/virt-tools-list/2018-September/msg00064.html).
>
> Thank you,
> Ben Mathews
>
> diff --git a/src/virt-viewer.c b/src/virt-viewer.c
> index 5c321db..39178ce 100644
> --- a/src/virt-viewer.c
> +++ b/src/virt-viewer.c
> @@ -875,6 +875,7 @@ virt_viewer_initial_connect(VirtViewerApp *app, GError **error)
> VirtViewerPrivate *priv = self->priv;
> char uuid_string[VIR_UUID_STRING_BUFLEN];
> const char *guest_name;
> + const char *title;
> GError *err = NULL;
>
> g_debug("initial connect");
> @@ -915,6 +916,11 @@ virt_viewer_initial_connect(VirtViewerApp *app, GError **error)
> g_object_set(app, "guest-name", guest_name, NULL);
> }
>
> + title = virDomainGetMetadata(dom, VIR_DOMAIN_METADATA_TITLE, NULL, 0);
There's a small trick here, contrary to virDomainGetName, the string
returned by virDomainGetMetadata must be freed when you no longer need
it, so 'title' needs to become 'char *title' and you need a free(title)
after the g_object_set() call below. I've fixed that locally, so no need
to send an updated patch. I'll push this shortly.
Thanks for the patch !
Christophe
> + if (title != NULL) {
> + g_object_set(app, "title", title, NULL);
> + }
> +
> virt_viewer_app_show_status(app, _("Checking guest domain status"));
> if (virDomainGetInfo(dom, &info) < 0) {
> g_set_error_literal(&err, VIRT_VIEWER_ERROR, VIRT_VIEWER_ERROR_FAILED,
> _______________________________________________
> virt-tools-list mailing list
> virt-tools-list at redhat.com
> https://www.redhat.com/mailman/listinfo/virt-tools-list
-------------- 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/20181121/256e211c/attachment.sig>
More information about the virt-tools-list
mailing list