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

/*
 * Copyright 2014 Tom Beckmann
 * Copyright 2023-2024 elementary, Inc. <https://elementary.io>
 * SPDX-License-Identifier: GPL-3.0-or-later
 */

#include <glib-object.h>
#include <meta/meta-background-actor.h>
#include <meta/display.h>
#include <glib.h>
#include <meta/meta-background.h>
#include <clutter/clutter.h>
#include <meta/meta-background-content.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
#if !defined(VALA_EXTERN)
#if defined(_MSC_VER)
#define VALA_EXTERN __declspec(dllexport) extern
#elif __GNUC__ >= 4
#define VALA_EXTERN __attribute__((visibility("default"))) extern
#else
#define VALA_EXTERN extern
#endif
#endif

#define GALA_TYPE_SYSTEM_BACKGROUND (gala_system_background_get_type ())
#define GALA_SYSTEM_BACKGROUND(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GALA_TYPE_SYSTEM_BACKGROUND, GalaSystemBackground))
#define GALA_SYSTEM_BACKGROUND_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GALA_TYPE_SYSTEM_BACKGROUND, GalaSystemBackgroundClass))
#define GALA_IS_SYSTEM_BACKGROUND(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GALA_TYPE_SYSTEM_BACKGROUND))
#define GALA_IS_SYSTEM_BACKGROUND_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GALA_TYPE_SYSTEM_BACKGROUND))
#define GALA_SYSTEM_BACKGROUND_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GALA_TYPE_SYSTEM_BACKGROUND, GalaSystemBackgroundClass))

typedef struct _GalaSystemBackground GalaSystemBackground;
typedef struct _GalaSystemBackgroundClass GalaSystemBackgroundClass;
typedef struct _GalaSystemBackgroundPrivate GalaSystemBackgroundPrivate;
enum  {
	GALA_SYSTEM_BACKGROUND_0_PROPERTY,
	GALA_SYSTEM_BACKGROUND_BACKGROUND_ACTOR_PROPERTY,
	GALA_SYSTEM_BACKGROUND_NUM_PROPERTIES
};
static GParamSpec* gala_system_background_properties[GALA_SYSTEM_BACKGROUND_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

struct _GalaSystemBackground {
	GObject parent_instance;
	GalaSystemBackgroundPrivate * priv;
};

struct _GalaSystemBackgroundClass {
	GObjectClass parent_class;
};

struct _GalaSystemBackgroundPrivate {
	MetaBackgroundActor* _background_actor;
};

static gint GalaSystemBackground_private_offset;
static gpointer gala_system_background_parent_class = NULL;

VALA_EXTERN GType gala_system_background_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (GalaSystemBackground, g_object_unref)
VALA_EXTERN GalaSystemBackground* gala_system_background_new (MetaDisplay* display);
VALA_EXTERN GalaSystemBackground* gala_system_background_construct (GType object_type,
                                                        MetaDisplay* display);
VALA_EXTERN MetaBackgroundActor* gala_system_background_get_background_actor (GalaSystemBackground* self);
static void gala_system_background_set_background_actor (GalaSystemBackground* self,
                                                  MetaBackgroundActor* value);
static GObject * gala_system_background_constructor (GType type,
                                              guint n_construct_properties,
                                              GObjectConstructParam * construct_properties);
static void gala_system_background_finalize (GObject * obj);
static GType gala_system_background_get_type_once (void);
static void _vala_gala_system_background_get_property (GObject * object,
                                                guint property_id,
                                                GValue * value,
                                                GParamSpec * pspec);
static void _vala_gala_system_background_set_property (GObject * object,
                                                guint property_id,
                                                const GValue * value,
                                                GParamSpec * pspec);

static inline gpointer
gala_system_background_get_instance_private (GalaSystemBackground* self)
{
	return G_STRUCT_MEMBER_P (self, GalaSystemBackground_private_offset);
}

GalaSystemBackground*
gala_system_background_construct (GType object_type,
                                  MetaDisplay* display)
{
	GalaSystemBackground * self = NULL;
	MetaBackgroundActor* _tmp0_;
	MetaBackgroundActor* _tmp1_;
	g_return_val_if_fail (display != NULL, NULL);
	_tmp0_ = (MetaBackgroundActor*) meta_background_actor_new (display, 0);
	g_object_ref_sink (_tmp0_);
	_tmp1_ = _tmp0_;
	self = (GalaSystemBackground*) g_object_new (object_type, "background-actor", _tmp1_, NULL);
	_g_object_unref0 (_tmp1_);
	return self;
}

GalaSystemBackground*
gala_system_background_new (MetaDisplay* display)
{
	return gala_system_background_construct (GALA_TYPE_SYSTEM_BACKGROUND, display);
}

MetaBackgroundActor*
gala_system_background_get_background_actor (GalaSystemBackground* self)
{
	MetaBackgroundActor* result;
	MetaBackgroundActor* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_background_actor;
	result = _tmp0_;
	return result;
}

static gpointer
_g_object_ref0 (gpointer self)
{
	return self ? g_object_ref (self) : NULL;
}

static void
gala_system_background_set_background_actor (GalaSystemBackground* self,
                                             MetaBackgroundActor* value)
{
	MetaBackgroundActor* old_value;
	g_return_if_fail (self != NULL);
	old_value = gala_system_background_get_background_actor (self);
	if (old_value != value) {
		MetaBackgroundActor* _tmp0_;
		_tmp0_ = _g_object_ref0 (value);
		_g_object_unref0 (self->priv->_background_actor);
		self->priv->_background_actor = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, gala_system_background_properties[GALA_SYSTEM_BACKGROUND_BACKGROUND_ACTOR_PROPERTY]);
	}
}

static GObject *
gala_system_background_constructor (GType type,
                                    guint n_construct_properties,
                                    GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	GalaSystemBackground * self;
	MetaBackground* system_background = NULL;
	MetaBackgroundActor* _tmp0_;
	MetaDisplay* _tmp1_;
	MetaDisplay* _tmp2_;
	MetaDisplay* _tmp3_;
	MetaBackground* _tmp4_;
	MetaBackground* _tmp5_;
	MetaBackground* _tmp6_;
	ClutterColor _tmp7_ = {0};
	MetaBackgroundActor* _tmp8_;
	ClutterContent* _tmp9_;
	ClutterContent* _tmp10_;
	MetaBackground* _tmp11_;
	parent_class = G_OBJECT_CLASS (gala_system_background_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GALA_TYPE_SYSTEM_BACKGROUND, GalaSystemBackground);
	_tmp0_ = self->priv->_background_actor;
	g_object_get (_tmp0_, "meta-display", &_tmp1_, NULL);
	_tmp2_ = _tmp1_;
	_tmp3_ = _tmp2_;
	_tmp4_ = meta_background_new (_tmp3_);
	_tmp5_ = _tmp4_;
	_g_object_unref0 (_tmp3_);
	system_background = _tmp5_;
	_tmp6_ = system_background;
	_tmp7_.red = (guint8) 0x2e;
	_tmp7_.green = (guint8) 0x34;
	_tmp7_.blue = (guint8) 0x36;
	_tmp7_.alpha = (guint8) 0xff;
	meta_background_set_color (_tmp6_, &_tmp7_);
	_tmp8_ = self->priv->_background_actor;
	_tmp9_ = clutter_actor_get_content ((ClutterActor*) _tmp8_);
	_tmp10_ = _tmp9_;
	_tmp11_ = system_background;
	g_object_set (G_TYPE_CHECK_INSTANCE_CAST (_tmp10_, meta_background_content_get_type (), MetaBackgroundContent), "background", _tmp11_, NULL);
	_g_object_unref0 (system_background);
	return obj;
}

static void
gala_system_background_class_init (GalaSystemBackgroundClass * klass,
                                   gpointer klass_data)
{
	gala_system_background_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &GalaSystemBackground_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_gala_system_background_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_gala_system_background_set_property;
	G_OBJECT_CLASS (klass)->constructor = gala_system_background_constructor;
	G_OBJECT_CLASS (klass)->finalize = gala_system_background_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), GALA_SYSTEM_BACKGROUND_BACKGROUND_ACTOR_PROPERTY, gala_system_background_properties[GALA_SYSTEM_BACKGROUND_BACKGROUND_ACTOR_PROPERTY] = g_param_spec_object ("background-actor", "background-actor", "background-actor", meta_background_actor_get_type (), G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
}

static void
gala_system_background_instance_init (GalaSystemBackground * self,
                                      gpointer klass)
{
	self->priv = gala_system_background_get_instance_private (self);
}

static void
gala_system_background_finalize (GObject * obj)
{
	GalaSystemBackground * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GALA_TYPE_SYSTEM_BACKGROUND, GalaSystemBackground);
	_g_object_unref0 (self->priv->_background_actor);
	G_OBJECT_CLASS (gala_system_background_parent_class)->finalize (obj);
}

 G_GNUC_NO_INLINE static GType
gala_system_background_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (GalaSystemBackgroundClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) gala_system_background_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (GalaSystemBackground), 0, (GInstanceInitFunc) gala_system_background_instance_init, NULL };
	GType gala_system_background_type_id;
	gala_system_background_type_id = g_type_register_static (G_TYPE_OBJECT, "GalaSystemBackground", &g_define_type_info, 0);
	GalaSystemBackground_private_offset = g_type_add_instance_private (gala_system_background_type_id, sizeof (GalaSystemBackgroundPrivate));
	return gala_system_background_type_id;
}

GType
gala_system_background_get_type (void)
{
	static gsize gala_system_background_type_id__once = 0;
	if (g_once_init_enter (&gala_system_background_type_id__once)) {
		GType gala_system_background_type_id;
		gala_system_background_type_id = gala_system_background_get_type_once ();
		g_once_init_leave (&gala_system_background_type_id__once, gala_system_background_type_id);
	}
	return gala_system_background_type_id__once;
}

static void
_vala_gala_system_background_get_property (GObject * object,
                                           guint property_id,
                                           GValue * value,
                                           GParamSpec * pspec)
{
	GalaSystemBackground * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, GALA_TYPE_SYSTEM_BACKGROUND, GalaSystemBackground);
	switch (property_id) {
		case GALA_SYSTEM_BACKGROUND_BACKGROUND_ACTOR_PROPERTY:
		g_value_set_object (value, gala_system_background_get_background_actor (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_gala_system_background_set_property (GObject * object,
                                           guint property_id,
                                           const GValue * value,
                                           GParamSpec * pspec)
{
	GalaSystemBackground * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, GALA_TYPE_SYSTEM_BACKGROUND, GalaSystemBackground);
	switch (property_id) {
		case GALA_SYSTEM_BACKGROUND_BACKGROUND_ACTOR_PROPERTY:
		gala_system_background_set_background_actor (self, g_value_get_object (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

