From patchwork Mon Apr 27 13:39:06 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gerd Hoffmann X-Patchwork-Id: 465027 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id A3152140318 for ; Mon, 27 Apr 2015 23:42:17 +1000 (AEST) Received: from localhost ([::1]:55147 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YmjId-0003wx-Jp for incoming@patchwork.ozlabs.org; Mon, 27 Apr 2015 09:42:15 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39130) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YmjFr-00079E-9W for qemu-devel@nongnu.org; Mon, 27 Apr 2015 09:39:24 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YmjFk-0006I1-Gu for qemu-devel@nongnu.org; Mon, 27 Apr 2015 09:39:23 -0400 Received: from mx1.redhat.com ([209.132.183.28]:48728) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YmjFk-0006Ha-8S for qemu-devel@nongnu.org; Mon, 27 Apr 2015 09:39:16 -0400 Received: from int-mx09.intmail.prod.int.phx2.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id t3RDdD9P026488 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL) for ; Mon, 27 Apr 2015 09:39:14 -0400 Received: from nilsson.home.kraxel.org (ovpn-116-39.ams2.redhat.com [10.36.116.39]) by int-mx09.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id t3RDdCvX000860; Mon, 27 Apr 2015 09:39:13 -0400 Received: by nilsson.home.kraxel.org (Postfix, from userid 500) id 80ED2831E3; Mon, 27 Apr 2015 15:39:12 +0200 (CEST) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Mon, 27 Apr 2015 15:39:06 +0200 Message-Id: <1430141948-18272-4-git-send-email-kraxel@redhat.com> In-Reply-To: <1430141948-18272-1-git-send-email-kraxel@redhat.com> References: <1430141948-18272-1-git-send-email-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.22 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Gerd Hoffmann Subject: [Qemu-devel] [PULL 3/5] console/gtk: add qemu_console_get_label X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Add a new function to get a nice label for a given QemuConsole. Drop the labeling code in gtk.c and use the new function instead. Signed-off-by: Gerd Hoffmann --- include/ui/console.h | 1 + ui/console.c | 15 +++++++++++++++ ui/gtk.c | 12 +----------- 3 files changed, 17 insertions(+), 11 deletions(-) diff --git a/include/ui/console.h b/include/ui/console.h index 2f5b9f0..03cd665 100644 --- a/include/ui/console.h +++ b/include/ui/console.h @@ -307,6 +307,7 @@ QemuConsole *qemu_console_lookup_by_device(DeviceState *dev, uint32_t head); bool qemu_console_is_visible(QemuConsole *con); bool qemu_console_is_graphic(QemuConsole *con); bool qemu_console_is_fixedsize(QemuConsole *con); +char *qemu_console_get_label(QemuConsole *con); int qemu_console_get_index(QemuConsole *con); uint32_t qemu_console_get_head(QemuConsole *con); QemuUIInfo *qemu_console_get_ui_info(QemuConsole *con); diff --git a/ui/console.c b/ui/console.c index b15ca87..2927513 100644 --- a/ui/console.c +++ b/ui/console.c @@ -1788,6 +1788,21 @@ bool qemu_console_is_fixedsize(QemuConsole *con) return con && (con->console_type != TEXT_CONSOLE); } +char *qemu_console_get_label(QemuConsole *con) +{ + if (con->console_type == GRAPHIC_CONSOLE) { + if (con->device) { + return g_strdup(object_get_typename(con->device)); + } + return g_strdup("VGA"); + } else { + if (con->chr && con->chr->label) { + return g_strdup(con->chr->label); + } + return g_strdup_printf("vc%d", con->index); + } +} + int qemu_console_get_index(QemuConsole *con) { if (con == NULL) { diff --git a/ui/gtk.c b/ui/gtk.c index c8d30fe..7180066 100644 --- a/ui/gtk.c +++ b/ui/gtk.c @@ -1730,17 +1730,7 @@ static GSList *gd_vc_gfx_init(GtkDisplayState *s, VirtualConsole *vc, QemuConsole *con, int idx, GSList *group, GtkWidget *view_menu) { - Object *obj; - - obj = object_property_get_link(OBJECT(con), "device", NULL); - if (obj) { - vc->label = g_strdup_printf("%s", object_get_typename(obj)); - } else if (qemu_console_is_graphic(con)) { - vc->label = g_strdup_printf("VGA"); - } else { - vc->label = g_strdup_printf("vc%d", idx); - } - + vc->label = qemu_console_get_label(con); vc->s = s; vc->gfx.scale_x = 1.0; vc->gfx.scale_y = 1.0;