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

/*
 * Copyright 2024 elementary, Inc. (https://elementary.io)
 * SPDX-License-Identifier: GPL-3.0-or-later
 *
 * Authored by: Leonhard Kargl <leo.kargl@proton.me>
 */

#include <glib-object.h>
#include <meta/display.h>
#include <glib.h>
#include <stdlib.h>
#include <string.h>
#include <meta/window.h>
#include "gala.h"
#include <meta/meta-wayland-client.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_NOTIFICATIONS_CLIENT (gala_notifications_client_get_type ())
#define GALA_NOTIFICATIONS_CLIENT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GALA_TYPE_NOTIFICATIONS_CLIENT, GalaNotificationsClient))
#define GALA_NOTIFICATIONS_CLIENT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GALA_TYPE_NOTIFICATIONS_CLIENT, GalaNotificationsClientClass))
#define GALA_IS_NOTIFICATIONS_CLIENT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GALA_TYPE_NOTIFICATIONS_CLIENT))
#define GALA_IS_NOTIFICATIONS_CLIENT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GALA_TYPE_NOTIFICATIONS_CLIENT))
#define GALA_NOTIFICATIONS_CLIENT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GALA_TYPE_NOTIFICATIONS_CLIENT, GalaNotificationsClientClass))

typedef struct _GalaNotificationsClient GalaNotificationsClient;
typedef struct _GalaNotificationsClientClass GalaNotificationsClientClass;
typedef struct _GalaNotificationsClientPrivate GalaNotificationsClientPrivate;

#define GALA_TYPE_MANAGED_CLIENT (gala_managed_client_get_type ())
#define GALA_MANAGED_CLIENT(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GALA_TYPE_MANAGED_CLIENT, GalaManagedClient))
#define GALA_MANAGED_CLIENT_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GALA_TYPE_MANAGED_CLIENT, GalaManagedClientClass))
#define GALA_IS_MANAGED_CLIENT(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GALA_TYPE_MANAGED_CLIENT))
#define GALA_IS_MANAGED_CLIENT_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GALA_TYPE_MANAGED_CLIENT))
#define GALA_MANAGED_CLIENT_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GALA_TYPE_MANAGED_CLIENT, GalaManagedClientClass))

typedef struct _GalaManagedClient GalaManagedClient;
typedef struct _GalaManagedClientClass GalaManagedClientClass;
enum  {
	GALA_NOTIFICATIONS_CLIENT_0_PROPERTY,
	GALA_NOTIFICATIONS_CLIENT_DISPLAY_PROPERTY,
	GALA_NOTIFICATIONS_CLIENT_NUM_PROPERTIES
};
static GParamSpec* gala_notifications_client_properties[GALA_NOTIFICATIONS_CLIENT_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

struct _GalaNotificationsClient {
	GObject parent_instance;
	GalaNotificationsClientPrivate * priv;
};

struct _GalaNotificationsClientClass {
	GObjectClass parent_class;
};

struct _GalaNotificationsClientPrivate {
	MetaDisplay* _display;
	GalaManagedClient* client;
};

static gint GalaNotificationsClient_private_offset;
static gpointer gala_notifications_client_parent_class = NULL;

VALA_EXTERN GType gala_notifications_client_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (GalaNotificationsClient, g_object_unref)
VALA_EXTERN GType gala_managed_client_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (GalaManagedClient, g_object_unref)
VALA_EXTERN GalaNotificationsClient* gala_notifications_client_new (MetaDisplay* display);
VALA_EXTERN GalaNotificationsClient* gala_notifications_client_construct (GType object_type,
                                                              MetaDisplay* display);
VALA_EXTERN MetaDisplay* gala_notifications_client_get_display (GalaNotificationsClient* self);
static void gala_notifications_client_set_display (GalaNotificationsClient* self,
                                            MetaDisplay* value);
static GObject * gala_notifications_client_constructor (GType type,
                                                 guint n_construct_properties,
                                                 GObjectConstructParam * construct_properties);
VALA_EXTERN GalaManagedClient* gala_managed_client_new (MetaDisplay* display,
                                            gchar** args,
                                            gint args_length1);
VALA_EXTERN GalaManagedClient* gala_managed_client_construct (GType object_type,
                                                  MetaDisplay* display,
                                                  gchar** args,
                                                  gint args_length1);
static void _gala_notifications_client___lambda8_ (GalaNotificationsClient* self,
                                            MetaWindow* window);
VALA_EXTERN MetaWaylandClient* gala_managed_client_get_wayland_client (GalaManagedClient* self);
static void __gala_notifications_client___lambda8__gala_managed_client_window_created (GalaManagedClient* _sender,
                                                                                MetaWindow* window,
                                                                                gpointer self);
static void gala_notifications_client_finalize (GObject * obj);
static GType gala_notifications_client_get_type_once (void);
static void _vala_gala_notifications_client_get_property (GObject * object,
                                                   guint property_id,
                                                   GValue * value,
                                                   GParamSpec * pspec);
static void _vala_gala_notifications_client_set_property (GObject * object,
                                                   guint property_id,
                                                   const GValue * value,
                                                   GParamSpec * pspec);
static void _vala_array_destroy (gpointer array,
                          gssize array_length,
                          GDestroyNotify destroy_func);
static void _vala_array_free (gpointer array,
                       gssize array_length,
                       GDestroyNotify destroy_func);

static inline gpointer
gala_notifications_client_get_instance_private (GalaNotificationsClient* self)
{
	return G_STRUCT_MEMBER_P (self, GalaNotificationsClient_private_offset);
}

GalaNotificationsClient*
gala_notifications_client_construct (GType object_type,
                                     MetaDisplay* display)
{
	GalaNotificationsClient * self = NULL;
	g_return_val_if_fail (display != NULL, NULL);
	self = (GalaNotificationsClient*) g_object_new (object_type, "display", display, NULL);
	return self;
}

GalaNotificationsClient*
gala_notifications_client_new (MetaDisplay* display)
{
	return gala_notifications_client_construct (GALA_TYPE_NOTIFICATIONS_CLIENT, display);
}

MetaDisplay*
gala_notifications_client_get_display (GalaNotificationsClient* self)
{
	MetaDisplay* result;
	MetaDisplay* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_display;
	result = _tmp0_;
	return result;
}

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

static void
gala_notifications_client_set_display (GalaNotificationsClient* self,
                                       MetaDisplay* value)
{
	MetaDisplay* old_value;
	g_return_if_fail (self != NULL);
	old_value = gala_notifications_client_get_display (self);
	if (old_value != value) {
		MetaDisplay* _tmp0_;
		_tmp0_ = _g_object_ref0 (value);
		_g_object_unref0 (self->priv->_display);
		self->priv->_display = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, gala_notifications_client_properties[GALA_NOTIFICATIONS_CLIENT_DISPLAY_PROPERTY]);
	}
}

static void
_gala_notifications_client___lambda8_ (GalaNotificationsClient* self,
                                       MetaWindow* window)
{
	GalaManagedClient* _tmp0_;
	MetaWaylandClient* _tmp1_;
	MetaWaylandClient* _tmp2_;
	g_return_if_fail (window != NULL);
	g_object_set_data_full ((GObject*) window, GALA_NOTIFICATION_DATA_KEY, (gpointer) ((gintptr) TRUE), NULL);
	meta_window_make_above (window);
	meta_window_stick (window);
	_tmp0_ = self->priv->client;
	_tmp1_ = gala_managed_client_get_wayland_client (_tmp0_);
	_tmp2_ = _tmp1_;
	meta_wayland_client_make_dock (_tmp2_, window);
}

static void
__gala_notifications_client___lambda8__gala_managed_client_window_created (GalaManagedClient* _sender,
                                                                           MetaWindow* window,
                                                                           gpointer self)
{
	_gala_notifications_client___lambda8_ ((GalaNotificationsClient*) self, window);
}

static GObject *
gala_notifications_client_constructor (GType type,
                                       guint n_construct_properties,
                                       GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	GalaNotificationsClient * self;
	MetaDisplay* _tmp0_;
	gchar* _tmp1_;
	gchar** _tmp2_;
	gchar** _tmp3_;
	gint _tmp3__length1;
	GalaManagedClient* _tmp4_;
	GalaManagedClient* _tmp5_;
	parent_class = G_OBJECT_CLASS (gala_notifications_client_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GALA_TYPE_NOTIFICATIONS_CLIENT, GalaNotificationsClient);
	_tmp0_ = self->priv->_display;
	_tmp1_ = g_strdup ("io.elementary.notifications");
	_tmp2_ = g_new0 (gchar*, 1 + 1);
	_tmp2_[0] = _tmp1_;
	_tmp3_ = _tmp2_;
	_tmp3__length1 = 1;
	_tmp4_ = gala_managed_client_new (_tmp0_, _tmp3_, 1);
	_g_object_unref0 (self->priv->client);
	self->priv->client = _tmp4_;
	_tmp3_ = (_vala_array_free (_tmp3_, _tmp3__length1, (GDestroyNotify) g_free), NULL);
	_tmp5_ = self->priv->client;
	g_signal_connect_object (_tmp5_, "window-created", (GCallback) __gala_notifications_client___lambda8__gala_managed_client_window_created, self, 0);
	return obj;
}

static void
gala_notifications_client_class_init (GalaNotificationsClientClass * klass,
                                      gpointer klass_data)
{
	gala_notifications_client_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &GalaNotificationsClient_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_gala_notifications_client_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_gala_notifications_client_set_property;
	G_OBJECT_CLASS (klass)->constructor = gala_notifications_client_constructor;
	G_OBJECT_CLASS (klass)->finalize = gala_notifications_client_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), GALA_NOTIFICATIONS_CLIENT_DISPLAY_PROPERTY, gala_notifications_client_properties[GALA_NOTIFICATIONS_CLIENT_DISPLAY_PROPERTY] = g_param_spec_object ("display", "display", "display", meta_display_get_type (), G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
}

static void
gala_notifications_client_instance_init (GalaNotificationsClient * self,
                                         gpointer klass)
{
	self->priv = gala_notifications_client_get_instance_private (self);
}

static void
gala_notifications_client_finalize (GObject * obj)
{
	GalaNotificationsClient * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GALA_TYPE_NOTIFICATIONS_CLIENT, GalaNotificationsClient);
	_g_object_unref0 (self->priv->_display);
	_g_object_unref0 (self->priv->client);
	G_OBJECT_CLASS (gala_notifications_client_parent_class)->finalize (obj);
}

 G_GNUC_NO_INLINE static GType
gala_notifications_client_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (GalaNotificationsClientClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) gala_notifications_client_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (GalaNotificationsClient), 0, (GInstanceInitFunc) gala_notifications_client_instance_init, NULL };
	GType gala_notifications_client_type_id;
	gala_notifications_client_type_id = g_type_register_static (G_TYPE_OBJECT, "GalaNotificationsClient", &g_define_type_info, 0);
	GalaNotificationsClient_private_offset = g_type_add_instance_private (gala_notifications_client_type_id, sizeof (GalaNotificationsClientPrivate));
	return gala_notifications_client_type_id;
}

GType
gala_notifications_client_get_type (void)
{
	static gsize gala_notifications_client_type_id__once = 0;
	if (g_once_init_enter (&gala_notifications_client_type_id__once)) {
		GType gala_notifications_client_type_id;
		gala_notifications_client_type_id = gala_notifications_client_get_type_once ();
		g_once_init_leave (&gala_notifications_client_type_id__once, gala_notifications_client_type_id);
	}
	return gala_notifications_client_type_id__once;
}

static void
_vala_gala_notifications_client_get_property (GObject * object,
                                              guint property_id,
                                              GValue * value,
                                              GParamSpec * pspec)
{
	GalaNotificationsClient * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, GALA_TYPE_NOTIFICATIONS_CLIENT, GalaNotificationsClient);
	switch (property_id) {
		case GALA_NOTIFICATIONS_CLIENT_DISPLAY_PROPERTY:
		g_value_set_object (value, gala_notifications_client_get_display (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_gala_notifications_client_set_property (GObject * object,
                                              guint property_id,
                                              const GValue * value,
                                              GParamSpec * pspec)
{
	GalaNotificationsClient * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, GALA_TYPE_NOTIFICATIONS_CLIENT, GalaNotificationsClient);
	switch (property_id) {
		case GALA_NOTIFICATIONS_CLIENT_DISPLAY_PROPERTY:
		gala_notifications_client_set_display (self, g_value_get_object (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_array_destroy (gpointer array,
                     gssize array_length,
                     GDestroyNotify destroy_func)
{
	if ((array != NULL) && (destroy_func != NULL)) {
		gssize i;
		for (i = 0; i < array_length; i = i + 1) {
			if (((gpointer*) array)[i] != NULL) {
				destroy_func (((gpointer*) array)[i]);
			}
		}
	}
}

static void
_vala_array_free (gpointer array,
                  gssize array_length,
                  GDestroyNotify destroy_func)
{
	_vala_array_destroy (array, array_length, destroy_func);
	g_free (array);
}

