lib: add MksScreen:device-address

Can be handy when troubleshooting things, so wrap that too.
This commit is contained in:
Christian Hergert 2023-02-09 03:21:43 -08:00
parent c35baef43e
commit 8898636ac4
3 changed files with 32 additions and 8 deletions

View File

@ -54,6 +54,7 @@ G_DEFINE_FINAL_TYPE (MksScreen, mks_screen, MKS_TYPE_DEVICE)
enum {
PROP_0,
PROP_DEVICE_ADDRESS,
PROP_HEIGHT,
PROP_KIND,
PROP_KEYBOARD,
@ -214,6 +215,10 @@ mks_screen_get_property (GObject *object,
switch (prop_id)
{
case PROP_DEVICE_ADDRESS:
g_value_set_string (value, mks_screen_get_device_address (self));
break;
case PROP_KEYBOARD:
g_value_set_object (value, mks_screen_get_keyboard (self));
break;
@ -254,6 +259,11 @@ mks_screen_class_init (MksScreenClass *klass)
device_class->setup = mks_screen_setup;
properties [PROP_DEVICE_ADDRESS] =
g_param_spec_string ("device-address", NULL, NULL,
NULL,
(G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
properties [PROP_KEYBOARD] =
g_param_spec_object ("keyboard", NULL, NULL,
MKS_TYPE_KEYBOARD,
@ -388,3 +398,14 @@ mks_screen_get_number (MksScreen *self)
return self->number;
}
const char *
mks_screen_get_device_address (MksScreen *self)
{
g_return_val_if_fail (MKS_IS_SCREEN (self), NULL);
if (self->console != NULL)
return mks_qemu_console_get_device_address (self->console);
return NULL;
}

View File

@ -62,6 +62,8 @@ MKS_AVAILABLE_IN_ALL
guint mks_screen_get_height (MksScreen *self);
MKS_AVAILABLE_IN_ALL
guint mks_screen_get_number (MksScreen *self);
MKS_AVAILABLE_IN_ALL
const char *mks_screen_get_device_address (MksScreen *self);
G_DEFINE_AUTOPTR_CLEANUP_FUNC (MksScreen, g_object_unref)

View File

@ -42,7 +42,8 @@ print_device_info (MksDevice *device,
G_OBJECT_TYPE_NAME (device),
mks_device_get_name (device) ?: "");
if (MKS_IS_SCREEN (device))
g_print (", number=%u, width=%u, height=%u",
g_print (", address=\"%s\", number=%u, width=%u, height=%u",
mks_screen_get_device_address (MKS_SCREEN (device)),
mks_screen_get_number (MKS_SCREEN (device)),
mks_screen_get_width (MKS_SCREEN (device)),
mks_screen_get_height (MKS_SCREEN (device)));