st/image-content: Remove usage of private struct

As it is a final type.

Part-of: <https://gitlab.gnome.org/GNOME/gnome-shell/-/merge_requests/3547>
This commit is contained in:
Bilal Elmoussaoui 2024-11-15 11:51:35 +01:00 committed by Marge Bot
parent 4cff5e4572
commit ea88ba687e

View File

@ -25,13 +25,8 @@
struct _StImageContent struct _StImageContent
{ {
/*< private >*/
ClutterImage parent_instance; ClutterImage parent_instance;
};
typedef struct _StImageContentPrivate StImageContentPrivate;
struct _StImageContentPrivate
{
int width; int width;
int height; int height;
gboolean is_symbolic; gboolean is_symbolic;
@ -48,8 +43,7 @@ static void clutter_content_interface_init (ClutterContentInterface *iface);
static void g_icon_interface_init (GIconIface *iface); static void g_icon_interface_init (GIconIface *iface);
static void g_loadable_icon_interface_init (GLoadableIconIface *iface); static void g_loadable_icon_interface_init (GLoadableIconIface *iface);
G_DEFINE_TYPE_WITH_CODE (StImageContent, st_image_content, CLUTTER_TYPE_IMAGE, G_DEFINE_FINAL_TYPE_WITH_CODE (StImageContent, st_image_content, CLUTTER_TYPE_IMAGE,
G_ADD_PRIVATE (StImageContent)
G_IMPLEMENT_INTERFACE (CLUTTER_TYPE_CONTENT, G_IMPLEMENT_INTERFACE (CLUTTER_TYPE_CONTENT,
clutter_content_interface_init) clutter_content_interface_init)
G_IMPLEMENT_INTERFACE (G_TYPE_ICON, G_IMPLEMENT_INTERFACE (G_TYPE_ICON,
@ -66,11 +60,10 @@ static void
st_image_content_constructed (GObject *object) st_image_content_constructed (GObject *object)
{ {
StImageContent *self = ST_IMAGE_CONTENT (object); StImageContent *self = ST_IMAGE_CONTENT (object);
StImageContentPrivate *priv = st_image_content_get_instance_private (self);
if (priv->width < 0 || priv->height < 0) if (self->width < 0 || self->height < 0)
g_warning ("StImageContent initialized with invalid preferred size: %dx%d\n", g_warning ("StImageContent initialized with invalid preferred size: %dx%d\n",
priv->width, priv->height); self->width, self->height);
} }
static void static void
@ -80,16 +73,15 @@ st_image_content_get_property (GObject *object,
GParamSpec *pspec) GParamSpec *pspec)
{ {
StImageContent *self = ST_IMAGE_CONTENT (object); StImageContent *self = ST_IMAGE_CONTENT (object);
StImageContentPrivate *priv = st_image_content_get_instance_private (self);
switch (prop_id) switch (prop_id)
{ {
case PROP_PREFERRED_WIDTH: case PROP_PREFERRED_WIDTH:
g_value_set_int (value, priv->width); g_value_set_int (value, self->width);
break; break;
case PROP_PREFERRED_HEIGHT: case PROP_PREFERRED_HEIGHT:
g_value_set_int (value, priv->height); g_value_set_int (value, self->height);
break; break;
default: default:
@ -105,16 +97,15 @@ st_image_content_set_property (GObject *object,
GParamSpec *pspec) GParamSpec *pspec)
{ {
StImageContent *self = ST_IMAGE_CONTENT (object); StImageContent *self = ST_IMAGE_CONTENT (object);
StImageContentPrivate *priv = st_image_content_get_instance_private (self);
switch (prop_id) switch (prop_id)
{ {
case PROP_PREFERRED_WIDTH: case PROP_PREFERRED_WIDTH:
priv->width = g_value_get_int (value); self->width = g_value_get_int (value);
break; break;
case PROP_PREFERRED_HEIGHT: case PROP_PREFERRED_HEIGHT:
priv->height = g_value_get_int (value); self->height = g_value_get_int (value);
break; break;
default: default:
@ -150,7 +141,6 @@ st_image_content_get_preferred_size (ClutterContent *content,
float *height) float *height)
{ {
StImageContent *self = ST_IMAGE_CONTENT (content); StImageContent *self = ST_IMAGE_CONTENT (content);
StImageContentPrivate *priv = st_image_content_get_instance_private (self);
CoglTexture *texture; CoglTexture *texture;
texture = clutter_image_get_texture (CLUTTER_IMAGE (content)); texture = clutter_image_get_texture (CLUTTER_IMAGE (content));
@ -158,14 +148,14 @@ st_image_content_get_preferred_size (ClutterContent *content,
if (texture == NULL) if (texture == NULL)
return FALSE; return FALSE;
g_assert_cmpint (priv->width, >, -1); g_assert_cmpint (self->width, >, -1);
g_assert_cmpint (priv->height, >, -1); g_assert_cmpint (self->height, >, -1);
if (width != NULL) if (width != NULL)
*width = (float) priv->width; *width = (float) self->width;
if (height != NULL) if (height != NULL)
*height = (float) priv->height; *height = (float) self->height;
return TRUE; return TRUE;
} }
@ -348,21 +338,15 @@ void
st_image_content_set_is_symbolic (StImageContent *content, st_image_content_set_is_symbolic (StImageContent *content,
gboolean is_symbolic) gboolean is_symbolic)
{ {
StImageContentPrivate *priv;
g_return_if_fail (ST_IS_IMAGE_CONTENT (content)); g_return_if_fail (ST_IS_IMAGE_CONTENT (content));
priv = st_image_content_get_instance_private (content); content->is_symbolic = is_symbolic;
priv->is_symbolic = is_symbolic;
} }
gboolean gboolean
st_image_content_get_is_symbolic (StImageContent *content) st_image_content_get_is_symbolic (StImageContent *content)
{ {
StImageContentPrivate *priv;
g_return_val_if_fail (ST_IS_IMAGE_CONTENT (content), FALSE); g_return_val_if_fail (ST_IS_IMAGE_CONTENT (content), FALSE);
priv = st_image_content_get_instance_private (content); return content->is_symbolic;
return priv->is_symbolic;
} }