]> xenbits.xensource.com Git - qemu-xen.git/commitdiff
console/gtk: add qemu_console_get_label
authorGerd Hoffmann <kraxel@redhat.com>
Tue, 17 Feb 2015 09:41:08 +0000 (10:41 +0100)
committerGerd Hoffmann <kraxel@redhat.com>
Wed, 22 Apr 2015 11:21:16 +0000 (13:21 +0200)
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 <kraxel@redhat.com>
include/ui/console.h
ui/console.c
ui/gtk.c

index 2f5b9f06348b3a2b4fef59b6146337cb60be787d..03cd665a8f7f5b793342130191920ce58ed56089 100644 (file)
@@ -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);
index b15ca87f0f27f631d3efdc00b2d424e4438181ce..29275136c78321f1bbb1a8edf0041c2a3f28d020 100644 (file)
@@ -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) {
index c8d30fed7911167b039064d98869a474d3c0dc7d..7180066bde1000a682e5410711971f2017e39cd5 100644 (file)
--- 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;