lib: export paintable properties

This is mostly useful so that we can see things within the inspector at
runtime in case we need to debug what backends are used.
This commit is contained in:
Christian Hergert 2023-02-15 07:01:32 -08:00
parent a8505e1245
commit 2286183747
2 changed files with 50 additions and 0 deletions

View File

@ -67,6 +67,7 @@ typedef struct
enum {
PROP_0,
PROP_PAINTABLE,
PROP_SCREEN,
N_PROPS
};
@ -165,6 +166,8 @@ mks_display_set_paintable (MksDisplay *self,
self,
G_CONNECT_SWAPPED);
}
g_object_notify_by_pspec (G_OBJECT (self), properties [PROP_PAINTABLE]);
}
static void
@ -674,9 +677,14 @@ mks_display_get_property (GObject *object,
GParamSpec *pspec)
{
MksDisplay *self = MKS_DISPLAY (object);
MksDisplayPrivate *priv = mks_display_get_instance_private (self);
switch (prop_id)
{
case PROP_PAINTABLE:
g_value_set_object (value, priv->paintable);
break;
case PROP_SCREEN:
g_value_set_object (value, mks_display_get_screen (self));
break;
@ -719,6 +727,11 @@ mks_display_class_init (MksDisplayClass *klass)
widget_class->measure = mks_display_measure;
widget_class->snapshot = mks_display_snapshot;
properties [PROP_PAINTABLE] =
g_param_spec_object ("paintable", NULL, NULL,
GDK_TYPE_PAINTABLE,
(G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
properties[PROP_SCREEN] =
g_param_spec_object ("screen", NULL, NULL,
MKS_TYPE_SCREEN,

View File

@ -41,6 +41,14 @@ struct _MksPaintable
GdkPaintable *child;
};
enum {
PROP_0,
PROP_PAINTABLE,
N_PROPS
};
static GParamSpec *properties [N_PROPS];
static cairo_format_t
_pixman_format_to_cairo_format (guint pixman_format)
{
@ -145,12 +153,39 @@ mks_paintable_dispose (GObject *object)
G_OBJECT_CLASS (mks_paintable_parent_class)->dispose (object);
}
static void
mks_paintable_get_property (GObject *object,
guint prop_id,
GValue *value,
GParamSpec *pspec)
{
MksPaintable *self = MKS_PAINTABLE (object);
switch (prop_id)
{
case PROP_PAINTABLE:
g_value_set_object (value, self->child);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, prop_id, pspec);
}
}
static void
mks_paintable_class_init (MksPaintableClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->dispose = mks_paintable_dispose;
object_class->get_property = mks_paintable_get_property;
properties [PROP_PAINTABLE] =
g_param_spec_object ("paintable", NULL, NULL,
GDK_TYPE_PAINTABLE,
(G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
g_object_class_install_properties (object_class, N_PROPS, properties);
}
static void
@ -225,6 +260,8 @@ mks_paintable_set_child (MksPaintable *self,
if (size_changed)
gdk_paintable_invalidate_size (GDK_PAINTABLE (self));
g_object_notify_by_pspec (G_OBJECT (self), properties [PROP_PAINTABLE]);
}
static gboolean