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

@ -49,19 +49,21 @@ typedef enum _MksScreenKind
} MksScreenKind;
MKS_AVAILABLE_IN_ALL
GType mks_screen_get_type (void) G_GNUC_CONST;
GType mks_screen_get_type (void) G_GNUC_CONST;
MKS_AVAILABLE_IN_ALL
MksScreenKind mks_screen_get_kind (MksScreen *self);
MksScreenKind mks_screen_get_kind (MksScreen *self);
MKS_AVAILABLE_IN_ALL
MksKeyboard *mks_screen_get_keyboard (MksScreen *self);
MksKeyboard *mks_screen_get_keyboard (MksScreen *self);
MKS_AVAILABLE_IN_ALL
MksMouse *mks_screen_get_mouse (MksScreen *self);
MksMouse *mks_screen_get_mouse (MksScreen *self);
MKS_AVAILABLE_IN_ALL
guint mks_screen_get_width (MksScreen *self);
guint mks_screen_get_width (MksScreen *self);
MKS_AVAILABLE_IN_ALL
guint mks_screen_get_height (MksScreen *self);
guint mks_screen_get_height (MksScreen *self);
MKS_AVAILABLE_IN_ALL
guint mks_screen_get_number (MksScreen *self);
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)));