/* OSKManager.c generated by valac 0.56.19, the Vala compiler
 * generated from OSKManager.vala, do not modify */

/*
 * Copyright 2026 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 <gio/gio.h>
#include <glib.h>
#include <ibus.h>
#include <stdlib.h>
#include <string.h>
#include <clutter/clutter.h>

#define GALA_OSK_MANAGER_OSK_BUS_NAME "io.elementary.OSK"
#define GALA_OSK_MANAGER_OSK_OBJECT_PATH "/io/elementary/OSK"
#define GALA_OSK_MANAGER_OSK_SETTINGS_KEY "screen-keyboard-enabled"
#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_OSK_MANAGER (gala_osk_manager_get_type ())
#define GALA_OSK_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GALA_TYPE_OSK_MANAGER, GalaOSKManager))
#define GALA_OSK_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GALA_TYPE_OSK_MANAGER, GalaOSKManagerClass))
#define GALA_IS_OSK_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GALA_TYPE_OSK_MANAGER))
#define GALA_IS_OSK_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GALA_TYPE_OSK_MANAGER))
#define GALA_OSK_MANAGER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GALA_TYPE_OSK_MANAGER, GalaOSKManagerClass))

typedef struct _GalaOSKManager GalaOSKManager;
typedef struct _GalaOSKManagerClass GalaOSKManagerClass;
typedef struct _GalaOSKManagerPrivate GalaOSKManagerPrivate;

#define GALA_TYPE_OSK_PROXY (gala_osk_proxy_get_type ())
#define GALA_OSK_PROXY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GALA_TYPE_OSK_PROXY, GalaOSKProxy))
#define GALA_IS_OSK_PROXY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GALA_TYPE_OSK_PROXY))
#define GALA_OSK_PROXY_GET_INTERFACE(obj) (G_TYPE_INSTANCE_GET_INTERFACE ((obj), GALA_TYPE_OSK_PROXY, GalaOSKProxyIface))

typedef struct _GalaOSKProxy GalaOSKProxy;
typedef struct _GalaOSKProxyIface GalaOSKProxyIface;

#define GALA_TYPE_OSK_PROXY_PROXY (gala_osk_proxy_proxy_get_type ())

#define GALA_TYPE_OSK_RECEIVER (gala_osk_receiver_get_type ())
#define GALA_OSK_RECEIVER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), GALA_TYPE_OSK_RECEIVER, GalaOSKReceiver))
#define GALA_OSK_RECEIVER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), GALA_TYPE_OSK_RECEIVER, GalaOSKReceiverClass))
#define GALA_IS_OSK_RECEIVER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), GALA_TYPE_OSK_RECEIVER))
#define GALA_IS_OSK_RECEIVER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), GALA_TYPE_OSK_RECEIVER))
#define GALA_OSK_RECEIVER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), GALA_TYPE_OSK_RECEIVER, GalaOSKReceiverClass))

typedef struct _GalaOSKReceiver GalaOSKReceiver;
typedef struct _GalaOSKReceiverClass GalaOSKReceiverClass;
enum  {
	GALA_OSK_MANAGER_0_PROPERTY,
	GALA_OSK_MANAGER_DISPLAY_PROPERTY,
	GALA_OSK_MANAGER_NUM_PROPERTIES
};
static GParamSpec* gala_osk_manager_properties[GALA_OSK_MANAGER_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
typedef struct _GalaOskManagerOskAppearedData GalaOskManagerOskAppearedData;
#define _g_free0(var) (var = (g_free (var), NULL))
enum  {
	GALA_OSK_MANAGER_INPUT_PANEL_DEACTIVATION_REQUESTED_SIGNAL,
	GALA_OSK_MANAGER_NUM_SIGNALS
};
static guint gala_osk_manager_signals[GALA_OSK_MANAGER_NUM_SIGNALS] = {0};

struct _GalaOSKManager {
	GObject parent_instance;
	GalaOSKManagerPrivate * priv;
};

struct _GalaOSKManagerClass {
	GObjectClass parent_class;
};

struct _GalaOSKProxyIface {
	GTypeInterface parent_iface;
	void (*set_enabled) (GalaOSKProxy* self, gboolean enabled, GAsyncReadyCallback _callback_, gpointer _user_data_);
	void (*set_enabled_finish) (GalaOSKProxy* self, GAsyncResult* _res_, GError** error);
	void (*reset) (GalaOSKProxy* self, GAsyncReadyCallback _callback_, gpointer _user_data_);
	void (*reset_finish) (GalaOSKProxy* self, GAsyncResult* _res_, GError** error);
	void (*set_input_purpose) (GalaOSKProxy* self, IBusInputPurpose input_purpose, GAsyncReadyCallback _callback_, gpointer _user_data_);
	void (*set_input_purpose_finish) (GalaOSKProxy* self, GAsyncResult* _res_, GError** error);
};

struct _GalaOSKManagerPrivate {
	MetaDisplay* _display;
	GalaOSKProxy* osk;
	GalaOSKReceiver* receiver;
	gboolean enabled;
	IBusInputPurpose input_purpose;
};

struct _GalaOskManagerOskAppearedData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	GalaOSKManager* self;
	GalaOSKProxy* _tmp0_;
	GalaOSKProxy* _tmp1_;
	GalaOSKProxy* _tmp2_;
	GError* e;
	GError* _tmp3_;
	const gchar* _tmp4_;
	MetaDisplay* _tmp5_;
	GalaOSKProxy* _tmp6_;
	GalaOSKReceiver* _tmp7_;
	GalaOSKProxy* _tmp8_;
	GalaOSKProxy* _tmp9_;
	GalaOSKProxy* _tmp10_;
	GError* _inner_error0_;
};

static gint GalaOSKManager_private_offset;
static gpointer gala_osk_manager_parent_class = NULL;
static GSettings* gala_osk_manager_settings;
static GSettings* gala_osk_manager_settings = NULL;

VALA_EXTERN GType gala_osk_manager_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (GalaOSKManager, g_object_unref)
VALA_EXTERN GType gala_osk_proxy_proxy_get_type (void) G_GNUC_CONST ;
VALA_EXTERN guint gala_osk_proxy_register_object (void* object,
                                      GDBusConnection* connection,
                                      const gchar* path,
                                      GError** error);
VALA_EXTERN GType gala_osk_proxy_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (GalaOSKProxy, g_object_unref)
VALA_EXTERN GType gala_osk_receiver_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (GalaOSKReceiver, g_object_unref)
VALA_EXTERN GalaOSKManager* gala_osk_manager_new (MetaDisplay* display);
VALA_EXTERN GalaOSKManager* gala_osk_manager_construct (GType object_type,
                                            MetaDisplay* display);
static void gala_osk_manager_sync_enabled (GalaOSKManager* self);
VALA_EXTERN void gala_osk_proxy_set_enabled (GalaOSKProxy* self,
                                 gboolean enabled,
                                 GAsyncReadyCallback _callback_,
                                 gpointer _user_data_);
VALA_EXTERN void gala_osk_proxy_set_enabled_finish (GalaOSKProxy* self,
                                        GAsyncResult* _res_,
                                        GError** error);
static void gala_osk_manager_osk_appeared_data_free (gpointer _data);
static void gala_osk_manager_osk_appeared (GalaOSKManager* self,
                                    GAsyncReadyCallback _callback_,
                                    gpointer _user_data_);
static void gala_osk_manager_osk_appeared_finish (GalaOSKManager* self,
                                           GAsyncResult* _res_);
static gboolean gala_osk_manager_osk_appeared_co (GalaOskManagerOskAppearedData* _data_);
static void gala_osk_manager_osk_appeared_ready (GObject* source_object,
                                          GAsyncResult* _res_,
                                          gpointer _user_data_);
static MetaDisplay* gala_osk_manager_get_display (GalaOSKManager* self);
VALA_EXTERN GalaOSKReceiver* gala_osk_receiver_new (MetaDisplay* display,
                                        GalaOSKProxy* osk);
VALA_EXTERN GalaOSKReceiver* gala_osk_receiver_construct (GType object_type,
                                              MetaDisplay* display,
                                              GalaOSKProxy* osk);
VALA_EXTERN void gala_osk_proxy_set_input_purpose (GalaOSKProxy* self,
                                       IBusInputPurpose input_purpose,
                                       GAsyncReadyCallback _callback_,
                                       gpointer _user_data_);
VALA_EXTERN void gala_osk_proxy_set_input_purpose_finish (GalaOSKProxy* self,
                                              GAsyncResult* _res_,
                                              GError** error);
static void __lambda8_ (GalaOSKManager* self);
static void ___lambda8__gala_osk_proxy_hide_requested (GalaOSKProxy* _sender,
                                                gpointer self);
static void gala_osk_manager_osk_lost (GalaOSKManager* self);
VALA_EXTERN void gala_osk_manager_reset (GalaOSKManager* self);
VALA_EXTERN void gala_osk_proxy_reset (GalaOSKProxy* self,
                           GAsyncReadyCallback _callback_,
                           gpointer _user_data_);
VALA_EXTERN void gala_osk_proxy_reset_finish (GalaOSKProxy* self,
                                  GAsyncResult* _res_,
                                  GError** error);
VALA_EXTERN void gala_osk_manager_set_input_purpose (GalaOSKManager* self,
                                         IBusInputPurpose purpose);
static void gala_osk_manager_set_display (GalaOSKManager* self,
                                   MetaDisplay* value);
static GObject * gala_osk_manager_constructor (GType type,
                                        guint n_construct_properties,
                                        GObjectConstructParam * construct_properties);
static void _gala_osk_manager_sync_enabled_g_settings_changed (GSettings* _sender,
                                                        const gchar* key,
                                                        gpointer self);
static void _gala_osk_manager_sync_enabled_g_object_notify (GObject* _sender,
                                                     GParamSpec* pspec,
                                                     gpointer self);
static void _gala_osk_manager___lambda9_ (GalaOSKManager* self);
static void __gala_osk_manager___lambda9__gbus_name_appeared_callback (GDBusConnection* connection,
                                                                const gchar* name,
                                                                const gchar* name_owner,
                                                                gpointer self);
static void _gala_osk_manager_osk_lost_gbus_name_vanished_callback (GDBusConnection* connection,
                                                             const gchar* name,
                                                             gpointer self);
static void gala_osk_manager_finalize (GObject * obj);
static GType gala_osk_manager_get_type_once (void);
static void _vala_gala_osk_manager_get_property (GObject * object,
                                          guint property_id,
                                          GValue * value,
                                          GParamSpec * pspec);
static void _vala_gala_osk_manager_set_property (GObject * object,
                                          guint property_id,
                                          const GValue * value,
                                          GParamSpec * pspec);

static inline gpointer
gala_osk_manager_get_instance_private (GalaOSKManager* self)
{
	return G_STRUCT_MEMBER_P (self, GalaOSKManager_private_offset);
}

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

GalaOSKManager*
gala_osk_manager_new (MetaDisplay* display)
{
	return gala_osk_manager_construct (GALA_TYPE_OSK_MANAGER, display);
}

static void
gala_osk_manager_sync_enabled (GalaOSKManager* self)
{
	gboolean manually_enabled = FALSE;
	GSettings* _tmp0_;
	gboolean auto_enabled = FALSE;
	ClutterBackend* _tmp1_;
	ClutterSeat* _tmp2_;
	gboolean _tmp3_;
	gboolean _tmp4_;
	gboolean _tmp5_ = FALSE;
	GalaOSKProxy* _tmp6_;
	g_return_if_fail (self != NULL);
	_tmp0_ = gala_osk_manager_settings;
	manually_enabled = g_settings_get_boolean (_tmp0_, GALA_OSK_MANAGER_OSK_SETTINGS_KEY);
	_tmp1_ = clutter_get_default_backend ();
	_tmp2_ = clutter_backend_get_default_seat (_tmp1_);
	_tmp3_ = clutter_seat_get_touch_mode (_tmp2_);
	_tmp4_ = _tmp3_;
	auto_enabled = _tmp4_;
	if (manually_enabled) {
		_tmp5_ = TRUE;
	} else {
		_tmp5_ = auto_enabled;
	}
	self->priv->enabled = _tmp5_;
	_tmp6_ = self->priv->osk;
	if (_tmp6_ != NULL) {
		GalaOSKProxy* _tmp7_;
		_tmp7_ = self->priv->osk;
		gala_osk_proxy_set_enabled (_tmp7_, self->priv->enabled, NULL, NULL);
	}
}

static void
gala_osk_manager_osk_appeared_data_free (gpointer _data)
{
	GalaOskManagerOskAppearedData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->self);
	g_slice_free (GalaOskManagerOskAppearedData, _data_);
}

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

static void
gala_osk_manager_osk_appeared (GalaOSKManager* self,
                               GAsyncReadyCallback _callback_,
                               gpointer _user_data_)
{
	GalaOskManagerOskAppearedData* _data_;
	GalaOSKManager* _tmp0_;
	g_return_if_fail (self != NULL);
	_data_ = g_slice_new0 (GalaOskManagerOskAppearedData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, gala_osk_manager_osk_appeared_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	gala_osk_manager_osk_appeared_co (_data_);
}

static void
gala_osk_manager_osk_appeared_finish (GalaOSKManager* self,
                                      GAsyncResult* _res_)
{
	GalaOskManagerOskAppearedData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
}

static void
gala_osk_manager_osk_appeared_ready (GObject* source_object,
                                     GAsyncResult* _res_,
                                     gpointer _user_data_)
{
	GalaOskManagerOskAppearedData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	gala_osk_manager_osk_appeared_co (_data_);
}

static void
__lambda8_ (GalaOSKManager* self)
{
	g_signal_emit (self, gala_osk_manager_signals[GALA_OSK_MANAGER_INPUT_PANEL_DEACTIVATION_REQUESTED_SIGNAL], 0);
}

static void
___lambda8__gala_osk_proxy_hide_requested (GalaOSKProxy* _sender,
                                           gpointer self)
{
	__lambda8_ ((GalaOSKManager*) self);
}

static gboolean
gala_osk_manager_osk_appeared_co (GalaOskManagerOskAppearedData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	{
		_data_->_state_ = 1;
		g_async_initable_new_async (GALA_TYPE_OSK_PROXY_PROXY, 0, NULL, gala_osk_manager_osk_appeared_ready, _data_, "g-flags", 0, "g-name", GALA_OSK_MANAGER_OSK_BUS_NAME, "g-bus-type", G_BUS_TYPE_SESSION, "g-object-path", GALA_OSK_MANAGER_OSK_OBJECT_PATH, "g-interface-name", "io.elementary.OSK", NULL);
		return FALSE;
		_state_1:
		_data_->_tmp1_ = (GalaOSKProxy*) g_async_initable_new_finish ((GAsyncInitable *) _data_->_source_object_, _data_->_res_, &_data_->_inner_error0_);
		_data_->_tmp0_ = (GalaOSKProxy*) _data_->_tmp1_;
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
		_data_->_tmp2_ = _data_->_tmp0_;
		_data_->_tmp0_ = NULL;
		_g_object_unref0 (_data_->self->priv->osk);
		_data_->self->priv->osk = _data_->_tmp2_;
		_g_object_unref0 (_data_->_tmp0_);
	}
	goto __finally0;
	__catch0_g_error:
	{
		_data_->e = _data_->_inner_error0_;
		_data_->_inner_error0_ = NULL;
		_data_->_tmp3_ = _data_->e;
		_data_->_tmp4_ = _data_->_tmp3_->message;
		g_warning ("OSKManager.vala:58: Failed to get OSK proxy: %s", _data_->_tmp4_);
		_g_error_free0 (_data_->e);
		g_task_return_pointer (_data_->_async_result, _data_, NULL);
		if (_data_->_state_ != 0) {
			while (!g_task_get_completed (_data_->_async_result)) {
				g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
			}
		}
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	__finally0:
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _data_->_inner_error0_->message, g_quark_to_string (_data_->_inner_error0_->domain), _data_->_inner_error0_->code);
		g_clear_error (&_data_->_inner_error0_);
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_data_->_tmp5_ = _data_->self->priv->_display;
	_data_->_tmp6_ = _data_->self->priv->osk;
	_data_->_tmp7_ = gala_osk_receiver_new (_data_->_tmp5_, _data_->_tmp6_);
	_g_object_unref0 (_data_->self->priv->receiver);
	_data_->self->priv->receiver = _data_->_tmp7_;
	_data_->_tmp8_ = _data_->self->priv->osk;
	gala_osk_proxy_set_enabled (_data_->_tmp8_, _data_->self->priv->enabled, NULL, NULL);
	_data_->_tmp9_ = _data_->self->priv->osk;
	gala_osk_proxy_set_input_purpose (_data_->_tmp9_, _data_->self->priv->input_purpose, NULL, NULL);
	_data_->_tmp10_ = _data_->self->priv->osk;
	g_signal_connect_object (_data_->_tmp10_, "hide-requested", (GCallback) ___lambda8__gala_osk_proxy_hide_requested, _data_->self, 0);
	g_task_return_pointer (_data_->_async_result, _data_, NULL);
	if (_data_->_state_ != 0) {
		while (!g_task_get_completed (_data_->_async_result)) {
			g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
		}
	}
	g_object_unref (_data_->_async_result);
	return FALSE;
}

static void
gala_osk_manager_osk_lost (GalaOSKManager* self)
{
	g_return_if_fail (self != NULL);
	_g_object_unref0 (self->priv->osk);
	self->priv->osk = NULL;
	_g_object_unref0 (self->priv->receiver);
	self->priv->receiver = NULL;
}

void
gala_osk_manager_reset (GalaOSKManager* self)
{
	gboolean _tmp0_ = FALSE;
	GalaOSKProxy* _tmp2_;
	g_return_if_fail (self != NULL);
	if (!self->priv->enabled) {
		_tmp0_ = TRUE;
	} else {
		GalaOSKProxy* _tmp1_;
		_tmp1_ = self->priv->osk;
		_tmp0_ = _tmp1_ == NULL;
	}
	if (_tmp0_) {
		return;
	}
	_tmp2_ = self->priv->osk;
	gala_osk_proxy_reset (_tmp2_, NULL, NULL);
}

void
gala_osk_manager_set_input_purpose (GalaOSKManager* self,
                                    IBusInputPurpose purpose)
{
	GalaOSKProxy* _tmp0_;
	GalaOSKProxy* _tmp1_;
	g_return_if_fail (self != NULL);
	self->priv->input_purpose = purpose;
	_tmp0_ = self->priv->osk;
	if (_tmp0_ == NULL) {
		return;
	}
	_tmp1_ = self->priv->osk;
	gala_osk_proxy_set_input_purpose (_tmp1_, purpose, NULL, NULL);
}

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

static void
gala_osk_manager_set_display (GalaOSKManager* self,
                              MetaDisplay* value)
{
	MetaDisplay* old_value;
	g_return_if_fail (self != NULL);
	old_value = gala_osk_manager_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_osk_manager_properties[GALA_OSK_MANAGER_DISPLAY_PROPERTY]);
	}
}

static void
_gala_osk_manager_sync_enabled_g_settings_changed (GSettings* _sender,
                                                   const gchar* key,
                                                   gpointer self)
{
	gala_osk_manager_sync_enabled ((GalaOSKManager*) self);
}

static void
_gala_osk_manager_sync_enabled_g_object_notify (GObject* _sender,
                                                GParamSpec* pspec,
                                                gpointer self)
{
	gala_osk_manager_sync_enabled ((GalaOSKManager*) self);
}

static void
_gala_osk_manager___lambda9_ (GalaOSKManager* self)
{
	gala_osk_manager_osk_appeared (self, NULL, NULL);
}

static void
__gala_osk_manager___lambda9__gbus_name_appeared_callback (GDBusConnection* connection,
                                                           const gchar* name,
                                                           const gchar* name_owner,
                                                           gpointer self)
{
	_gala_osk_manager___lambda9_ ((GalaOSKManager*) self);
}

static void
_gala_osk_manager_osk_lost_gbus_name_vanished_callback (GDBusConnection* connection,
                                                        const gchar* name,
                                                        gpointer self)
{
	gala_osk_manager_osk_lost ((GalaOSKManager*) self);
}

static GObject *
gala_osk_manager_constructor (GType type,
                              guint n_construct_properties,
                              GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	GalaOSKManager * self;
	GSettings* _tmp0_;
	gchar* _tmp1_;
	ClutterBackend* _tmp2_;
	ClutterSeat* _tmp3_;
	parent_class = G_OBJECT_CLASS (gala_osk_manager_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GALA_TYPE_OSK_MANAGER, GalaOSKManager);
	_tmp0_ = gala_osk_manager_settings;
	_tmp1_ = g_strconcat ("changed::", GALA_OSK_MANAGER_OSK_SETTINGS_KEY, NULL);
	g_signal_connect_object (_tmp0_, _tmp1_, (GCallback) _gala_osk_manager_sync_enabled_g_settings_changed, self, 0);
	_g_free0 (_tmp1_);
	_tmp2_ = clutter_get_default_backend ();
	_tmp3_ = clutter_backend_get_default_seat (_tmp2_);
	g_signal_connect_object ((GObject*) _tmp3_, "notify::touch-mode", (GCallback) _gala_osk_manager_sync_enabled_g_object_notify, self, 0);
	gala_osk_manager_sync_enabled (self);
	g_bus_watch_name_with_closures (G_BUS_TYPE_SESSION, GALA_OSK_MANAGER_OSK_BUS_NAME, G_BUS_NAME_WATCHER_FLAGS_NONE, (GClosure*) ((__gala_osk_manager___lambda9__gbus_name_appeared_callback == NULL) ? NULL : g_cclosure_new ((GCallback) __gala_osk_manager___lambda9__gbus_name_appeared_callback, g_object_ref (self), (GClosureNotify) g_object_unref)), (GClosure*) ((_gala_osk_manager_osk_lost_gbus_name_vanished_callback == NULL) ? NULL : g_cclosure_new ((GCallback) _gala_osk_manager_osk_lost_gbus_name_vanished_callback, g_object_ref (self), (GClosureNotify) g_object_unref)));
	return obj;
}

static void
gala_osk_manager_class_init (GalaOSKManagerClass * klass,
                             gpointer klass_data)
{
	GSettings* _tmp0_;
	gala_osk_manager_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &GalaOSKManager_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_gala_osk_manager_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_gala_osk_manager_set_property;
	G_OBJECT_CLASS (klass)->constructor = gala_osk_manager_constructor;
	G_OBJECT_CLASS (klass)->finalize = gala_osk_manager_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), GALA_OSK_MANAGER_DISPLAY_PROPERTY, gala_osk_manager_properties[GALA_OSK_MANAGER_DISPLAY_PROPERTY] = g_param_spec_object ("display", "display", "display", meta_display_get_type (), G_PARAM_STATIC_STRINGS | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
	gala_osk_manager_signals[GALA_OSK_MANAGER_INPUT_PANEL_DEACTIVATION_REQUESTED_SIGNAL] = g_signal_new ("input-panel-deactivation-requested", GALA_TYPE_OSK_MANAGER, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
	_tmp0_ = g_settings_new ("org.gnome.desktop.a11y.applications");
	gala_osk_manager_settings = _tmp0_;
}

static void
gala_osk_manager_instance_init (GalaOSKManager * self,
                                gpointer klass)
{
	self->priv = gala_osk_manager_get_instance_private (self);
	self->priv->enabled = FALSE;
	self->priv->input_purpose = IBUS_INPUT_PURPOSE_FREE_FORM;
}

static void
gala_osk_manager_finalize (GObject * obj)
{
	GalaOSKManager * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, GALA_TYPE_OSK_MANAGER, GalaOSKManager);
	_g_object_unref0 (self->priv->_display);
	_g_object_unref0 (self->priv->osk);
	_g_object_unref0 (self->priv->receiver);
	G_OBJECT_CLASS (gala_osk_manager_parent_class)->finalize (obj);
}

/**
 * Handles enabling/disabling the on-screen keyboard (OSK) and relaying information to it.
 */
 G_GNUC_NO_INLINE static GType
gala_osk_manager_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (GalaOSKManagerClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) gala_osk_manager_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (GalaOSKManager), 0, (GInstanceInitFunc) gala_osk_manager_instance_init, NULL };
	GType gala_osk_manager_type_id;
	gala_osk_manager_type_id = g_type_register_static (G_TYPE_OBJECT, "GalaOSKManager", &g_define_type_info, G_TYPE_FLAG_NONE);
	GalaOSKManager_private_offset = g_type_add_instance_private (gala_osk_manager_type_id, sizeof (GalaOSKManagerPrivate));
	return gala_osk_manager_type_id;
}

GType
gala_osk_manager_get_type (void)
{
	static gsize gala_osk_manager_type_id__once = 0;
	if (g_once_init_enter (&gala_osk_manager_type_id__once)) {
		GType gala_osk_manager_type_id;
		gala_osk_manager_type_id = gala_osk_manager_get_type_once ();
		g_once_init_leave (&gala_osk_manager_type_id__once, gala_osk_manager_type_id);
	}
	return gala_osk_manager_type_id__once;
}

static void
_vala_gala_osk_manager_get_property (GObject * object,
                                     guint property_id,
                                     GValue * value,
                                     GParamSpec * pspec)
{
	GalaOSKManager * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, GALA_TYPE_OSK_MANAGER, GalaOSKManager);
	switch (property_id) {
		case GALA_OSK_MANAGER_DISPLAY_PROPERTY:
		g_value_set_object (value, gala_osk_manager_get_display (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_gala_osk_manager_set_property (GObject * object,
                                     guint property_id,
                                     const GValue * value,
                                     GParamSpec * pspec)
{
	GalaOSKManager * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, GALA_TYPE_OSK_MANAGER, GalaOSKManager);
	switch (property_id) {
		case GALA_OSK_MANAGER_DISPLAY_PROPERTY:
		gala_osk_manager_set_display (self, g_value_get_object (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

