screen: add MksScreen:number property

This correlates to "head" of the D-Bus interface, which makes for a
terribly non-descriptive property name.
This commit is contained in:
Christian Hergert 2023-02-08 23:26:35 -08:00
parent d16440566b
commit 169acba1bc
2 changed files with 30 additions and 0 deletions

View File

@ -38,6 +38,7 @@ struct _MksScreen
MksKeyboard *keyboard; MksKeyboard *keyboard;
MksMouse *mouse; MksMouse *mouse;
guint number;
guint width; guint width;
guint height; guint height;
@ -52,6 +53,7 @@ enum {
PROP_KIND, PROP_KIND,
PROP_KEYBOARD, PROP_KEYBOARD,
PROP_MOUSE, PROP_MOUSE,
PROP_NUMBER,
PROP_WIDTH, PROP_WIDTH,
N_PROPS N_PROPS
}; };
@ -128,6 +130,7 @@ mks_screen_set_console (MksScreen *self,
self->width = mks_qemu_console_get_width (console); self->width = mks_qemu_console_get_width (console);
self->height = mks_qemu_console_get_height (console); self->height = mks_qemu_console_get_height (console);
self->number = mks_qemu_console_get_head (console);
} }
} }
@ -170,6 +173,10 @@ mks_screen_get_property (GObject *object,
g_value_set_object (value, mks_screen_get_mouse (self)); g_value_set_object (value, mks_screen_get_mouse (self));
break; break;
case PROP_NUMBER:
g_value_set_uint (value, mks_screen_get_number (self));
break;
case PROP_WIDTH: case PROP_WIDTH:
g_value_set_uint (value, mks_screen_get_width (self)); g_value_set_uint (value, mks_screen_get_width (self));
break; break;
@ -223,6 +230,11 @@ mks_screen_class_init (MksScreenClass *klass)
MKS_TYPE_MOUSE, MKS_TYPE_MOUSE,
(G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)); (G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
properties [PROP_NUMBER] =
g_param_spec_uint ("number", NULL, NULL,
0, G_MAXUINT, 0,
(G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
properties [PROP_WIDTH] = properties [PROP_WIDTH] =
g_param_spec_uint ("width", NULL, NULL, g_param_spec_uint ("width", NULL, NULL,
0, G_MAXUINT, 0, 0, G_MAXUINT, 0,
@ -387,3 +399,19 @@ mks_screen_get_height (MksScreen *self)
return self->height; return self->height;
} }
/**
* mks_screen_get_number:
* @self: a #MksScreen
*
* Gets the "number" property.
*
* Returns: the screen number
*/
guint
mks_screen_get_number (MksScreen *self)
{
g_return_val_if_fail (MKS_IS_SCREEN (self), 0);
return self->number;
}

View File

@ -48,5 +48,7 @@ MKS_AVAILABLE_IN_ALL
guint mks_screen_get_width (MksScreen *self); guint mks_screen_get_width (MksScreen *self);
MKS_AVAILABLE_IN_ALL 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);
G_END_DECLS G_END_DECLS