/* CanvasActor.c generated by valac 0.56.18-dirty, the Vala compiler
 * generated from CanvasActor.vala, do not modify */

/*
 * Copyright 2024 elementary, Inc. (https://elementary.io)
 * SPDX-License-Identifier: LGPL-2.0-or-later
 */

#include "gala.h"
#include <clutter/clutter.h>
#include <cairo-gobject.h>
#include <glib.h>
#include <glib-object.h>

#if !defined(VALA_STRICT_C)
#if !defined(__clang__) && defined(__GNUC__) && (__GNUC__ >= 14)
#pragma GCC diagnostic warning "-Wincompatible-pointer-types"
#elif defined(__clang__) && (__clang_major__ >= 16)
#pragma clang diagnostic ignored "-Wincompatible-function-pointer-types"
#pragma clang diagnostic ignored "-Wincompatible-pointer-types"
#endif
#endif

enum  {
	GALA_CANVAS_ACTOR_0_PROPERTY,
	GALA_CANVAS_ACTOR_NUM_PROPERTIES
};
static GParamSpec* gala_canvas_actor_properties[GALA_CANVAS_ACTOR_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

struct _GalaCanvasActorPrivate {
	GalaDrawingCanvas* canvas;
};

static gint GalaCanvasActor_private_offset;
static gpointer gala_canvas_actor_parent_class = NULL;

static void gala_canvas_actor_real_resource_scale_changed (ClutterActor* base);
static void gala_canvas_actor_real_allocate (ClutterActor* base,
                                      ClutterActorBox* box);
static void gala_canvas_actor_real_draw (GalaCanvasActor* self,
                                  cairo_t* canvas,
                                  gint width,
                                  gint height);
static GObject * gala_canvas_actor_constructor (GType type,
                                         guint n_construct_properties,
                                         GObjectConstructParam * construct_properties);
static void _gala_canvas_actor___lambda9_ (GalaCanvasActor* self,
                                    cairo_t* ctx,
                                    gint width,
                                    gint height);
static void __gala_canvas_actor___lambda9__gala_drawing_canvas_draw (GalaDrawingCanvas* _sender,
                                                              cairo_t* cr,
                                                              gint width,
                                                              gint height,
                                                              gpointer self);
static void gala_canvas_actor_finalize (GObject * obj);
static GType gala_canvas_actor_get_type_once (void);

static inline gpointer
gala_canvas_actor_get_instance_private (GalaCanvasActor* self)
{
	return G_STRUCT_MEMBER_P (self, GalaCanvasActor_private_offset);
}

static void
gala_canvas_actor_real_resource_scale_changed (ClutterActor* base)
{
	GalaCanvasActor * self;
	GalaDrawingCanvas* _tmp0_;
	self = (GalaCanvasActor*) base;
	_tmp0_ = self->priv->canvas;
	gala_drawing_canvas_set_scale_factor (_tmp0_, clutter_actor_get_resource_scale ((ClutterActor*) self));
}

static void
gala_canvas_actor_real_allocate (ClutterActor* base,
                                 ClutterActorBox* box)
{
	GalaCanvasActor * self;
	ClutterActorBox _tmp0_;
	GalaDrawingCanvas* _tmp1_;
	GalaDrawingCanvas* _tmp2_;
	self = (GalaCanvasActor*) base;
	g_return_if_fail (box != NULL);
	_tmp0_ = *box;
	CLUTTER_ACTOR_CLASS (gala_canvas_actor_parent_class)->allocate (G_TYPE_CHECK_INSTANCE_CAST (self, clutter_actor_get_type (), ClutterActor), (const ClutterActorBox *) (&_tmp0_));
	_tmp1_ = self->priv->canvas;
	gala_drawing_canvas_set_size (_tmp1_, (gint) clutter_actor_box_get_width (box), (gint) clutter_actor_box_get_height (box));
	_tmp2_ = self->priv->canvas;
	gala_drawing_canvas_set_scale_factor (_tmp2_, clutter_actor_get_resource_scale ((ClutterActor*) self));
}

static void
gala_canvas_actor_real_draw (GalaCanvasActor* self,
                             cairo_t* canvas,
                             gint width,
                             gint height)
{
	g_return_if_fail (canvas != NULL);
}

void
gala_canvas_actor_draw (GalaCanvasActor* self,
                        cairo_t* canvas,
                        gint width,
                        gint height)
{
	GalaCanvasActorClass* _klass_;
	g_return_if_fail (self != NULL);
	_klass_ = GALA_CANVAS_ACTOR_GET_CLASS (self);
	if (_klass_->draw) {
		_klass_->draw (self, canvas, width, height);
	}
}

GalaCanvasActor*
gala_canvas_actor_construct (GType object_type)
{
	GalaCanvasActor * self = NULL;
	self = (GalaCanvasActor*) g_object_new (object_type, NULL);
	return self;
}

GalaCanvasActor*
gala_canvas_actor_new (void)
{
	return gala_canvas_actor_construct (GALA_TYPE_CANVAS_ACTOR);
}

static void
_gala_canvas_actor___lambda9_ (GalaCanvasActor* self,
                               cairo_t* ctx,
                               gint width,
                               gint height)
{
	g_return_if_fail (ctx != NULL);
	gala_canvas_actor_draw (self, ctx, width, height);
}

static void
__gala_canvas_actor___lambda9__gala_drawing_canvas_draw (GalaDrawingCanvas* _sender,
                                                         cairo_t* cr,
                                                         gint width,
                                                         gint height,
                                                         gpointer self)
{
	_gala_canvas_actor___lambda9_ ((GalaCanvasActor*) self, cr, width, height);
}

static GObject *
gala_canvas_actor_constructor (GType type,
                               guint n_construct_properties,
                               GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	GalaCanvasActor * self;
	GalaDrawingCanvas* _tmp0_;
	GalaDrawingCanvas* _tmp1_;
	GalaDrawingCanvas* _tmp2_;
	parent_class = G_OBJECT_CLASS (gala_canvas_actor_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GALA_TYPE_CANVAS_ACTOR, GalaCanvasActor);
	_tmp0_ = gala_drawing_canvas_new ();
	_g_object_unref0 (self->priv->canvas);
	self->priv->canvas = _tmp0_;
	_tmp1_ = self->priv->canvas;
	clutter_actor_set_content ((ClutterActor*) self, (ClutterContent*) _tmp1_);
	_tmp2_ = self->priv->canvas;
	g_signal_connect_object (_tmp2_, "draw", (GCallback) __gala_canvas_actor___lambda9__gala_drawing_canvas_draw, self, 0);
	return obj;
}

static void
gala_canvas_actor_class_init (GalaCanvasActorClass * klass,
                              gpointer klass_data)
{
	gala_canvas_actor_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &GalaCanvasActor_private_offset);
	((ClutterActorClass *) klass)->resource_scale_changed = (void (*) (ClutterActor*)) gala_canvas_actor_real_resource_scale_changed;
	((ClutterActorClass *) klass)->allocate = (void (*) (ClutterActor*, const ClutterActorBox *)) gala_canvas_actor_real_allocate;
	((GalaCanvasActorClass *) klass)->draw = (void (*) (GalaCanvasActor*, cairo_t*, gint, gint)) gala_canvas_actor_real_draw;
	G_OBJECT_CLASS (klass)->constructor = gala_canvas_actor_constructor;
	G_OBJECT_CLASS (klass)->finalize = gala_canvas_actor_finalize;
}

static void
gala_canvas_actor_instance_init (GalaCanvasActor * self,
                                 gpointer klass)
{
	self->priv = gala_canvas_actor_get_instance_private (self);
}

static void
gala_canvas_actor_finalize (GObject * obj)
{
	GalaCanvasActor * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GALA_TYPE_CANVAS_ACTOR, GalaCanvasActor);
	_g_object_unref0 (self->priv->canvas);
	G_OBJECT_CLASS (gala_canvas_actor_parent_class)->finalize (obj);
}

 G_GNUC_NO_INLINE static GType
gala_canvas_actor_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (GalaCanvasActorClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) gala_canvas_actor_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (GalaCanvasActor), 0, (GInstanceInitFunc) gala_canvas_actor_instance_init, NULL };
	GType gala_canvas_actor_type_id;
	gala_canvas_actor_type_id = g_type_register_static (clutter_actor_get_type (), "GalaCanvasActor", &g_define_type_info, 0);
	GalaCanvasActor_private_offset = g_type_add_instance_private (gala_canvas_actor_type_id, sizeof (GalaCanvasActorPrivate));
	return gala_canvas_actor_type_id;
}

GType
gala_canvas_actor_get_type (void)
{
	static gsize gala_canvas_actor_type_id__once = 0;
	if (g_once_init_enter (&gala_canvas_actor_type_id__once)) {
		GType gala_canvas_actor_type_id;
		gala_canvas_actor_type_id = gala_canvas_actor_get_type_once ();
		g_once_init_leave (&gala_canvas_actor_type_id__once, gala_canvas_actor_type_id);
	}
	return gala_canvas_actor_type_id__once;
}

