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

/*
 * Copyright (c) 2019 elementary, Inc. (https://elementary.io)
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public
 * License as published by the Free Software Foundation; either
 * version 2 of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * General Public License for more details.
 *
 * You should have received a copy of the GNU General Public
 * License along with this program; if not, write to the
 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 * Boston, MA 02110-1301 USA.
 */

#include "wacom.h"
#include <gee.h>
#include <glib-object.h>
#include <gdk/gdk.h>
#include <glib.h>
#include <gdk/x11/gdkx.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  {
	WACOM_BACKEND_DEVICE_MANAGER_0_PROPERTY,
	WACOM_BACKEND_DEVICE_MANAGER_NUM_PROPERTIES
};
static GParamSpec* wacom_backend_device_manager_properties[WACOM_BACKEND_DEVICE_MANAGER_NUM_PROPERTIES];
enum  {
	WACOM_BACKEND_DEVICE_MANAGER_DEVICE_ADDED_SIGNAL,
	WACOM_BACKEND_DEVICE_MANAGER_DEVICE_REMOVED_SIGNAL,
	WACOM_BACKEND_DEVICE_MANAGER_DEVICE_CHANGED_SIGNAL,
	WACOM_BACKEND_DEVICE_MANAGER_NUM_SIGNALS
};
static guint wacom_backend_device_manager_signals[WACOM_BACKEND_DEVICE_MANAGER_NUM_SIGNALS] = {0};

static gpointer wacom_backend_device_manager_parent_class = NULL;
static GOnce wacom_backend_device_manager_instance;
static GOnce wacom_backend_device_manager_instance = G_ONCE_INIT;

static WacomBackendDeviceManager* __lambda4_ (void);
static gpointer ___lambda4__gthread_func (gpointer self);
static GeeArrayList* wacom_backend_device_manager_real_list_devices (WacomBackendDeviceManager* self,
                                                              WacomBackendDeviceDeviceType type);
static WacomBackendDevice* wacom_backend_device_manager_real_lookup_gdk_device (WacomBackendDeviceManager* self,
                                                                         GdkDevice* device);
static void wacom_backend_device_manager_finalize (GObject * obj);
static GType wacom_backend_device_manager_get_type_once (void);

static WacomBackendDeviceManager*
__lambda4_ (void)
{
	GdkDisplay* _tmp0_;
	WacomBackendDeviceManager* result;
	_tmp0_ = gdk_display_get_default ();
	if (G_TYPE_CHECK_INSTANCE_TYPE (_tmp0_, gdk_x11_display_get_type ())) {
		WacomBackendDeviceManagerX11* _tmp1_;
		_tmp1_ = wacom_backend_device_manager_x11_new ();
		result = (WacomBackendDeviceManager*) _tmp1_;
		return result;
	} else {
		WacomBackendDeviceManagerWayland* _tmp2_;
		_tmp2_ = wacom_backend_device_manager_wayland_new ();
		result = (WacomBackendDeviceManager*) _tmp2_;
		return result;
	}
}

static gpointer
___lambda4__gthread_func (gpointer self)
{
	gpointer result;
	result = __lambda4_ ();
	return result;
}

WacomBackendDeviceManager*
wacom_backend_device_manager_get_default (void)
{
	gconstpointer _tmp0_;
	WacomBackendDeviceManager* result;
	_tmp0_ = g_once (&wacom_backend_device_manager_instance, ___lambda4__gthread_func, NULL);
	result = (WacomBackendDeviceManager*) _tmp0_;
	return result;
}

static GeeArrayList*
wacom_backend_device_manager_real_list_devices (WacomBackendDeviceManager* self,
                                                WacomBackendDeviceDeviceType type)
{
	g_critical ("Type `%s' does not implement abstract method `wacom_backend_device_manager_list_devices'", g_type_name (G_TYPE_FROM_INSTANCE (self)));
	return NULL;
}

GeeArrayList*
wacom_backend_device_manager_list_devices (WacomBackendDeviceManager* self,
                                           WacomBackendDeviceDeviceType type)
{
	WacomBackendDeviceManagerClass* _klass_;
	g_return_val_if_fail (self != NULL, NULL);
	_klass_ = WACOM_BACKEND_DEVICE_MANAGER_GET_CLASS (self);
	if (_klass_->list_devices) {
		return _klass_->list_devices (self, type);
	}
	return NULL;
}

static WacomBackendDevice*
wacom_backend_device_manager_real_lookup_gdk_device (WacomBackendDeviceManager* self,
                                                     GdkDevice* device)
{
	g_critical ("Type `%s' does not implement abstract method `wacom_backend_device_manager_lookup_gdk_device'", g_type_name (G_TYPE_FROM_INSTANCE (self)));
	return NULL;
}

WacomBackendDevice*
wacom_backend_device_manager_lookup_gdk_device (WacomBackendDeviceManager* self,
                                                GdkDevice* device)
{
	WacomBackendDeviceManagerClass* _klass_;
	g_return_val_if_fail (self != NULL, NULL);
	_klass_ = WACOM_BACKEND_DEVICE_MANAGER_GET_CLASS (self);
	if (_klass_->lookup_gdk_device) {
		return _klass_->lookup_gdk_device (self, device);
	}
	return NULL;
}

WacomBackendDeviceManager*
wacom_backend_device_manager_construct (GType object_type)
{
	WacomBackendDeviceManager * self = NULL;
	self = (WacomBackendDeviceManager*) g_object_new (object_type, NULL);
	return self;
}

static void
wacom_backend_device_manager_class_init (WacomBackendDeviceManagerClass * klass,
                                         gpointer klass_data)
{
	wacom_backend_device_manager_parent_class = g_type_class_peek_parent (klass);
	((WacomBackendDeviceManagerClass *) klass)->list_devices = (GeeArrayList* (*) (WacomBackendDeviceManager*, WacomBackendDeviceDeviceType)) wacom_backend_device_manager_real_list_devices;
	((WacomBackendDeviceManagerClass *) klass)->lookup_gdk_device = (WacomBackendDevice* (*) (WacomBackendDeviceManager*, GdkDevice*)) wacom_backend_device_manager_real_lookup_gdk_device;
	G_OBJECT_CLASS (klass)->finalize = wacom_backend_device_manager_finalize;
	wacom_backend_device_manager_signals[WACOM_BACKEND_DEVICE_MANAGER_DEVICE_ADDED_SIGNAL] = g_signal_new ("device-added", WACOM_BACKEND_TYPE_DEVICE_MANAGER, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__OBJECT, G_TYPE_NONE, 1, WACOM_BACKEND_TYPE_DEVICE);
	wacom_backend_device_manager_signals[WACOM_BACKEND_DEVICE_MANAGER_DEVICE_REMOVED_SIGNAL] = g_signal_new ("device-removed", WACOM_BACKEND_TYPE_DEVICE_MANAGER, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__OBJECT, G_TYPE_NONE, 1, WACOM_BACKEND_TYPE_DEVICE);
	wacom_backend_device_manager_signals[WACOM_BACKEND_DEVICE_MANAGER_DEVICE_CHANGED_SIGNAL] = g_signal_new ("device-changed", WACOM_BACKEND_TYPE_DEVICE_MANAGER, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__OBJECT, G_TYPE_NONE, 1, WACOM_BACKEND_TYPE_DEVICE);
}

static void
wacom_backend_device_manager_instance_init (WacomBackendDeviceManager * self,
                                            gpointer klass)
{
}

static void
wacom_backend_device_manager_finalize (GObject * obj)
{
	WacomBackendDeviceManager * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, WACOM_BACKEND_TYPE_DEVICE_MANAGER, WacomBackendDeviceManager);
	G_OBJECT_CLASS (wacom_backend_device_manager_parent_class)->finalize (obj);
}

static GType
wacom_backend_device_manager_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (WacomBackendDeviceManagerClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) wacom_backend_device_manager_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (WacomBackendDeviceManager), 0, (GInstanceInitFunc) wacom_backend_device_manager_instance_init, NULL };
	GType wacom_backend_device_manager_type_id;
	wacom_backend_device_manager_type_id = g_type_register_static (G_TYPE_OBJECT, "WacomBackendDeviceManager", &g_define_type_info, G_TYPE_FLAG_ABSTRACT);
	return wacom_backend_device_manager_type_id;
}

GType
wacom_backend_device_manager_get_type (void)
{
	static volatile gsize wacom_backend_device_manager_type_id__once = 0;
	if (g_once_init_enter (&wacom_backend_device_manager_type_id__once)) {
		GType wacom_backend_device_manager_type_id;
		wacom_backend_device_manager_type_id = wacom_backend_device_manager_get_type_once ();
		g_once_init_leave (&wacom_backend_device_manager_type_id__once, wacom_backend_device_manager_type_id);
	}
	return wacom_backend_device_manager_type_id__once;
}

