/* controller-text-input-policy.c generated by valac 0.56.19, the Vala compiler
 * generated from controller-text-input-policy.vala, do not modify */

#include "protonplus_core.h"
#include <gtk/gtk.h>
#include <glib-object.h>
#include <glib.h>
#include <adwaita.h>
#include <string.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  {
	PROTON_PLUS_UTILS_TEXT_INPUT_METADATA_0_PROPERTY,
	PROTON_PLUS_UTILS_TEXT_INPUT_METADATA_PURPOSE_PROPERTY,
	PROTON_PLUS_UTILS_TEXT_INPUT_METADATA_HINTS_PROPERTY,
	PROTON_PLUS_UTILS_TEXT_INPUT_METADATA_NUM_PROPERTIES
};
static GParamSpec* proton_plus_utils_text_input_metadata_properties[PROTON_PLUS_UTILS_TEXT_INPUT_METADATA_NUM_PROPERTIES];
enum  {
	PROTON_PLUS_UTILS_TEXT_INPUT_METADATA_POLICY_0_PROPERTY,
	PROTON_PLUS_UTILS_TEXT_INPUT_METADATA_POLICY_NUM_PROPERTIES
};
static GParamSpec* proton_plus_utils_text_input_metadata_policy_properties[PROTON_PLUS_UTILS_TEXT_INPUT_METADATA_POLICY_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
enum  {
	PROTON_PLUS_UTILS_CONTROLLER_ACTIVATION_POLICY_0_PROPERTY,
	PROTON_PLUS_UTILS_CONTROLLER_ACTIVATION_POLICY_NUM_PROPERTIES
};
static GParamSpec* proton_plus_utils_controller_activation_policy_properties[PROTON_PLUS_UTILS_CONTROLLER_ACTIVATION_POLICY_NUM_PROPERTIES];
enum  {
	PROTON_PLUS_UTILS_CONTROLLER_EDITABLE_TARGET_RESOLVER_0_PROPERTY,
	PROTON_PLUS_UTILS_CONTROLLER_EDITABLE_TARGET_RESOLVER_NUM_PROPERTIES
};
static GParamSpec* proton_plus_utils_controller_editable_target_resolver_properties[PROTON_PLUS_UTILS_CONTROLLER_EDITABLE_TARGET_RESOLVER_NUM_PROPERTIES];

struct _ProtonPlusUtilsTextInputMetadataPrivate {
	GtkInputPurpose _purpose;
	GtkInputHints _hints;
};

static gint ProtonPlusUtilsTextInputMetadata_private_offset;
static gpointer proton_plus_utils_text_input_metadata_parent_class = NULL;
static gpointer proton_plus_utils_text_input_metadata_policy_parent_class = NULL;
static gpointer proton_plus_utils_controller_activation_policy_parent_class = NULL;
static gpointer proton_plus_utils_controller_editable_target_resolver_parent_class = NULL;

static void proton_plus_utils_text_input_metadata_set_purpose (ProtonPlusUtilsTextInputMetadata* self,
                                                        GtkInputPurpose value);
static void proton_plus_utils_text_input_metadata_set_hints (ProtonPlusUtilsTextInputMetadata* self,
                                                      GtkInputHints value);
static void proton_plus_utils_text_input_metadata_finalize (GObject * obj);
static GType proton_plus_utils_text_input_metadata_get_type_once (void);
static void _vala_proton_plus_utils_text_input_metadata_get_property (GObject * object,
                                                               guint property_id,
                                                               GValue * value,
                                                               GParamSpec * pspec);
static void _vala_proton_plus_utils_text_input_metadata_set_property (GObject * object,
                                                               guint property_id,
                                                               const GValue * value,
                                                               GParamSpec * pspec);
static ProtonPlusUtilsTextInputMetadata* proton_plus_utils_text_input_metadata_policy_exact_metadata (GtkInputPurpose purpose,
                                                                                               gboolean is_private);
static GType proton_plus_utils_text_input_metadata_policy_get_type_once (void);
static GType proton_plus_utils_controller_activation_policy_get_type_once (void);
static GType proton_plus_utils_controller_editable_target_resolver_get_type_once (void);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

static GType
proton_plus_utils_text_input_field_kind_get_type_once (void)
{
	static const GEnumValue values[] = {{PROTON_PLUS_UTILS_TEXT_INPUT_FIELD_KIND_SEARCH, "PROTON_PLUS_UTILS_TEXT_INPUT_FIELD_KIND_SEARCH", "search"}, {PROTON_PLUS_UTILS_TEXT_INPUT_FIELD_KIND_FREE_FORM, "PROTON_PLUS_UTILS_TEXT_INPUT_FIELD_KIND_FREE_FORM", "free-form"}, {PROTON_PLUS_UTILS_TEXT_INPUT_FIELD_KIND_NUMERIC, "PROTON_PLUS_UTILS_TEXT_INPUT_FIELD_KIND_NUMERIC", "numeric"}, {PROTON_PLUS_UTILS_TEXT_INPUT_FIELD_KIND_DIGITS, "PROTON_PLUS_UTILS_TEXT_INPUT_FIELD_KIND_DIGITS", "digits"}, {PROTON_PLUS_UTILS_TEXT_INPUT_FIELD_KIND_URL, "PROTON_PLUS_UTILS_TEXT_INPUT_FIELD_KIND_URL", "url"}, {PROTON_PLUS_UTILS_TEXT_INPUT_FIELD_KIND_SECRET, "PROTON_PLUS_UTILS_TEXT_INPUT_FIELD_KIND_SECRET", "secret"}, {PROTON_PLUS_UTILS_TEXT_INPUT_FIELD_KIND_COMMAND, "PROTON_PLUS_UTILS_TEXT_INPUT_FIELD_KIND_COMMAND", "command"}, {PROTON_PLUS_UTILS_TEXT_INPUT_FIELD_KIND_PATH_OR_IDENTIFIER, "PROTON_PLUS_UTILS_TEXT_INPUT_FIELD_KIND_PATH_OR_IDENTIFIER", "path-or-identifier"}, {0, NULL, NULL}};
	GType proton_plus_utils_text_input_field_kind_type_id;
	proton_plus_utils_text_input_field_kind_type_id = g_enum_register_static ("ProtonPlusUtilsTextInputFieldKind", values);
	return proton_plus_utils_text_input_field_kind_type_id;
}

GType
proton_plus_utils_text_input_field_kind_get_type (void)
{
	static volatile gsize proton_plus_utils_text_input_field_kind_type_id__once = 0;
	if (g_once_init_enter (&proton_plus_utils_text_input_field_kind_type_id__once)) {
		GType proton_plus_utils_text_input_field_kind_type_id;
		proton_plus_utils_text_input_field_kind_type_id = proton_plus_utils_text_input_field_kind_get_type_once ();
		g_once_init_leave (&proton_plus_utils_text_input_field_kind_type_id__once, proton_plus_utils_text_input_field_kind_type_id);
	}
	return proton_plus_utils_text_input_field_kind_type_id__once;
}

static inline gpointer
proton_plus_utils_text_input_metadata_get_instance_private (ProtonPlusUtilsTextInputMetadata* self)
{
	return G_STRUCT_MEMBER_P (self, ProtonPlusUtilsTextInputMetadata_private_offset);
}

ProtonPlusUtilsTextInputMetadata*
proton_plus_utils_text_input_metadata_construct (GType object_type,
                                                 GtkInputPurpose purpose,
                                                 GtkInputHints hints)
{
	ProtonPlusUtilsTextInputMetadata * self = NULL;
	self = (ProtonPlusUtilsTextInputMetadata*) g_object_new (object_type, NULL);
	proton_plus_utils_text_input_metadata_set_purpose (self, purpose);
	proton_plus_utils_text_input_metadata_set_hints (self, hints);
	return self;
}

ProtonPlusUtilsTextInputMetadata*
proton_plus_utils_text_input_metadata_new (GtkInputPurpose purpose,
                                           GtkInputHints hints)
{
	return proton_plus_utils_text_input_metadata_construct (PROTON_PLUS_UTILS_TYPE_TEXT_INPUT_METADATA, purpose, hints);
}

gboolean
proton_plus_utils_text_input_metadata_has_hint (ProtonPlusUtilsTextInputMetadata* self,
                                                GtkInputHints hint)
{
	GtkInputHints _tmp0_;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	_tmp0_ = self->priv->_hints;
	result = (_tmp0_ & hint) != 0;
	return result;
}

GtkInputPurpose
proton_plus_utils_text_input_metadata_get_purpose (ProtonPlusUtilsTextInputMetadata* self)
{
	GtkInputPurpose result;
	g_return_val_if_fail (self != NULL, 0);
	result = self->priv->_purpose;
	return result;
}

static void
proton_plus_utils_text_input_metadata_set_purpose (ProtonPlusUtilsTextInputMetadata* self,
                                                   GtkInputPurpose value)
{
	GtkInputPurpose old_value;
	g_return_if_fail (self != NULL);
	old_value = proton_plus_utils_text_input_metadata_get_purpose (self);
	if (old_value != value) {
		self->priv->_purpose = value;
		g_object_notify_by_pspec ((GObject *) self, proton_plus_utils_text_input_metadata_properties[PROTON_PLUS_UTILS_TEXT_INPUT_METADATA_PURPOSE_PROPERTY]);
	}
}

GtkInputHints
proton_plus_utils_text_input_metadata_get_hints (ProtonPlusUtilsTextInputMetadata* self)
{
	GtkInputHints result;
	g_return_val_if_fail (self != NULL, 0U);
	result = self->priv->_hints;
	return result;
}

static void
proton_plus_utils_text_input_metadata_set_hints (ProtonPlusUtilsTextInputMetadata* self,
                                                 GtkInputHints value)
{
	GtkInputHints old_value;
	g_return_if_fail (self != NULL);
	old_value = proton_plus_utils_text_input_metadata_get_hints (self);
	if (old_value != value) {
		self->priv->_hints = value;
		g_object_notify_by_pspec ((GObject *) self, proton_plus_utils_text_input_metadata_properties[PROTON_PLUS_UTILS_TEXT_INPUT_METADATA_HINTS_PROPERTY]);
	}
}

static void
proton_plus_utils_text_input_metadata_class_init (ProtonPlusUtilsTextInputMetadataClass * klass,
                                                  gpointer klass_data)
{
	proton_plus_utils_text_input_metadata_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &ProtonPlusUtilsTextInputMetadata_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_proton_plus_utils_text_input_metadata_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_proton_plus_utils_text_input_metadata_set_property;
	G_OBJECT_CLASS (klass)->finalize = proton_plus_utils_text_input_metadata_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), PROTON_PLUS_UTILS_TEXT_INPUT_METADATA_PURPOSE_PROPERTY, proton_plus_utils_text_input_metadata_properties[PROTON_PLUS_UTILS_TEXT_INPUT_METADATA_PURPOSE_PROPERTY] = g_param_spec_enum ("purpose", "purpose", "purpose", gtk_input_purpose_get_type (), 0, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), PROTON_PLUS_UTILS_TEXT_INPUT_METADATA_HINTS_PROPERTY, proton_plus_utils_text_input_metadata_properties[PROTON_PLUS_UTILS_TEXT_INPUT_METADATA_HINTS_PROPERTY] = g_param_spec_flags ("hints", "hints", "hints", gtk_input_hints_get_type (), 0U, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
}

static void
proton_plus_utils_text_input_metadata_instance_init (ProtonPlusUtilsTextInputMetadata * self,
                                                     gpointer klass)
{
	self->priv = proton_plus_utils_text_input_metadata_get_instance_private (self);
}

static void
proton_plus_utils_text_input_metadata_finalize (GObject * obj)
{
	ProtonPlusUtilsTextInputMetadata * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, PROTON_PLUS_UTILS_TYPE_TEXT_INPUT_METADATA, ProtonPlusUtilsTextInputMetadata);
	G_OBJECT_CLASS (proton_plus_utils_text_input_metadata_parent_class)->finalize (obj);
}

static GType
proton_plus_utils_text_input_metadata_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (ProtonPlusUtilsTextInputMetadataClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) proton_plus_utils_text_input_metadata_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ProtonPlusUtilsTextInputMetadata), 0, (GInstanceInitFunc) proton_plus_utils_text_input_metadata_instance_init, NULL };
	GType proton_plus_utils_text_input_metadata_type_id;
	proton_plus_utils_text_input_metadata_type_id = g_type_register_static (G_TYPE_OBJECT, "ProtonPlusUtilsTextInputMetadata", &g_define_type_info, 0);
	ProtonPlusUtilsTextInputMetadata_private_offset = g_type_add_instance_private (proton_plus_utils_text_input_metadata_type_id, sizeof (ProtonPlusUtilsTextInputMetadataPrivate));
	return proton_plus_utils_text_input_metadata_type_id;
}

GType
proton_plus_utils_text_input_metadata_get_type (void)
{
	static volatile gsize proton_plus_utils_text_input_metadata_type_id__once = 0;
	if (g_once_init_enter (&proton_plus_utils_text_input_metadata_type_id__once)) {
		GType proton_plus_utils_text_input_metadata_type_id;
		proton_plus_utils_text_input_metadata_type_id = proton_plus_utils_text_input_metadata_get_type_once ();
		g_once_init_leave (&proton_plus_utils_text_input_metadata_type_id__once, proton_plus_utils_text_input_metadata_type_id);
	}
	return proton_plus_utils_text_input_metadata_type_id__once;
}

static void
_vala_proton_plus_utils_text_input_metadata_get_property (GObject * object,
                                                          guint property_id,
                                                          GValue * value,
                                                          GParamSpec * pspec)
{
	ProtonPlusUtilsTextInputMetadata * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, PROTON_PLUS_UTILS_TYPE_TEXT_INPUT_METADATA, ProtonPlusUtilsTextInputMetadata);
	switch (property_id) {
		case PROTON_PLUS_UTILS_TEXT_INPUT_METADATA_PURPOSE_PROPERTY:
		g_value_set_enum (value, proton_plus_utils_text_input_metadata_get_purpose (self));
		break;
		case PROTON_PLUS_UTILS_TEXT_INPUT_METADATA_HINTS_PROPERTY:
		g_value_set_flags (value, proton_plus_utils_text_input_metadata_get_hints (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_proton_plus_utils_text_input_metadata_set_property (GObject * object,
                                                          guint property_id,
                                                          const GValue * value,
                                                          GParamSpec * pspec)
{
	ProtonPlusUtilsTextInputMetadata * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, PROTON_PLUS_UTILS_TYPE_TEXT_INPUT_METADATA, ProtonPlusUtilsTextInputMetadata);
	switch (property_id) {
		case PROTON_PLUS_UTILS_TEXT_INPUT_METADATA_PURPOSE_PROPERTY:
		proton_plus_utils_text_input_metadata_set_purpose (self, g_value_get_enum (value));
		break;
		case PROTON_PLUS_UTILS_TEXT_INPUT_METADATA_HINTS_PROPERTY:
		proton_plus_utils_text_input_metadata_set_hints (self, g_value_get_flags (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

ProtonPlusUtilsTextInputMetadata*
proton_plus_utils_text_input_metadata_policy_for_kind (ProtonPlusUtilsTextInputFieldKind kind)
{
	ProtonPlusUtilsTextInputMetadata* result;
	switch (kind) {
		case PROTON_PLUS_UTILS_TEXT_INPUT_FIELD_KIND_SEARCH:
		{
			ProtonPlusUtilsTextInputMetadata* _tmp0_;
			_tmp0_ = proton_plus_utils_text_input_metadata_new (GTK_INPUT_PURPOSE_FREE_FORM, GTK_INPUT_HINT_NO_SPELLCHECK | GTK_INPUT_HINT_NO_EMOJI);
			result = _tmp0_;
			return result;
		}
		case PROTON_PLUS_UTILS_TEXT_INPUT_FIELD_KIND_FREE_FORM:
		{
			ProtonPlusUtilsTextInputMetadata* _tmp1_;
			_tmp1_ = proton_plus_utils_text_input_metadata_new (GTK_INPUT_PURPOSE_FREE_FORM, GTK_INPUT_HINT_NONE);
			result = _tmp1_;
			return result;
		}
		case PROTON_PLUS_UTILS_TEXT_INPUT_FIELD_KIND_NUMERIC:
		{
			ProtonPlusUtilsTextInputMetadata* _tmp2_;
			_tmp2_ = proton_plus_utils_text_input_metadata_new (GTK_INPUT_PURPOSE_NUMBER, GTK_INPUT_HINT_NONE);
			result = _tmp2_;
			return result;
		}
		case PROTON_PLUS_UTILS_TEXT_INPUT_FIELD_KIND_DIGITS:
		{
			ProtonPlusUtilsTextInputMetadata* _tmp3_;
			_tmp3_ = proton_plus_utils_text_input_metadata_new (GTK_INPUT_PURPOSE_DIGITS, GTK_INPUT_HINT_NONE);
			result = _tmp3_;
			return result;
		}
		case PROTON_PLUS_UTILS_TEXT_INPUT_FIELD_KIND_URL:
		{
			ProtonPlusUtilsTextInputMetadata* _tmp4_;
			_tmp4_ = proton_plus_utils_text_input_metadata_policy_exact_metadata (GTK_INPUT_PURPOSE_URL, FALSE);
			result = _tmp4_;
			return result;
		}
		case PROTON_PLUS_UTILS_TEXT_INPUT_FIELD_KIND_SECRET:
		{
			ProtonPlusUtilsTextInputMetadata* _tmp5_;
			_tmp5_ = proton_plus_utils_text_input_metadata_policy_exact_metadata (GTK_INPUT_PURPOSE_PASSWORD, TRUE);
			result = _tmp5_;
			return result;
		}
		case PROTON_PLUS_UTILS_TEXT_INPUT_FIELD_KIND_COMMAND:
		{
			ProtonPlusUtilsTextInputMetadata* _tmp6_;
			_tmp6_ = proton_plus_utils_text_input_metadata_policy_exact_metadata (GTK_INPUT_PURPOSE_TERMINAL, FALSE);
			result = _tmp6_;
			return result;
		}
		case PROTON_PLUS_UTILS_TEXT_INPUT_FIELD_KIND_PATH_OR_IDENTIFIER:
		{
			ProtonPlusUtilsTextInputMetadata* _tmp7_;
			_tmp7_ = proton_plus_utils_text_input_metadata_policy_exact_metadata (GTK_INPUT_PURPOSE_TERMINAL, FALSE);
			result = _tmp7_;
			return result;
		}
		default:
		{
			g_assert_not_reached ();
		}
	}
}

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

void
proton_plus_utils_text_input_metadata_policy_apply (GtkWidget* widget,
                                                    ProtonPlusUtilsTextInputFieldKind kind)
{
	ProtonPlusUtilsTextInputMetadata* metadata = NULL;
	ProtonPlusUtilsTextInputMetadata* _tmp0_;
	g_return_if_fail (widget != NULL);
	_tmp0_ = proton_plus_utils_text_input_metadata_policy_for_kind (kind);
	metadata = _tmp0_;
	if (G_TYPE_CHECK_INSTANCE_TYPE (widget, adw_entry_row_get_type ())) {
		AdwEntryRow* entry_row = NULL;
		AdwEntryRow* _tmp1_;
		AdwEntryRow* _tmp2_;
		ProtonPlusUtilsTextInputMetadata* _tmp3_;
		GtkInputPurpose _tmp4_;
		GtkInputPurpose _tmp5_;
		AdwEntryRow* _tmp6_;
		ProtonPlusUtilsTextInputMetadata* _tmp7_;
		GtkInputHints _tmp8_;
		GtkInputHints _tmp9_;
		ProtonPlusUtilsTextInputMetadata* _tmp10_;
		_tmp1_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (widget, adw_entry_row_get_type (), AdwEntryRow));
		entry_row = _tmp1_;
		_tmp2_ = entry_row;
		_tmp3_ = metadata;
		_tmp4_ = proton_plus_utils_text_input_metadata_get_purpose (_tmp3_);
		_tmp5_ = _tmp4_;
		adw_entry_row_set_input_purpose (_tmp2_, _tmp5_);
		_tmp6_ = entry_row;
		_tmp7_ = metadata;
		_tmp8_ = proton_plus_utils_text_input_metadata_get_hints (_tmp7_);
		_tmp9_ = _tmp8_;
		adw_entry_row_set_input_hints (_tmp6_, _tmp9_);
		_tmp10_ = metadata;
		if (proton_plus_utils_text_input_metadata_has_hint (_tmp10_, GTK_INPUT_HINT_NO_EMOJI)) {
			AdwEntryRow* _tmp11_;
			_tmp11_ = entry_row;
			adw_entry_row_set_enable_emoji_completion (_tmp11_, FALSE);
		}
		_g_object_unref0 (entry_row);
	} else {
		if (G_TYPE_CHECK_INSTANCE_TYPE (widget, gtk_search_entry_get_type ())) {
			GtkSearchEntry* search_entry = NULL;
			GtkSearchEntry* _tmp12_;
			GtkSearchEntry* _tmp13_;
			ProtonPlusUtilsTextInputMetadata* _tmp14_;
			GtkInputPurpose _tmp15_;
			GtkInputPurpose _tmp16_;
			GtkSearchEntry* _tmp17_;
			ProtonPlusUtilsTextInputMetadata* _tmp18_;
			GtkInputHints _tmp19_;
			GtkInputHints _tmp20_;
			_tmp12_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (widget, gtk_search_entry_get_type (), GtkSearchEntry));
			search_entry = _tmp12_;
			_tmp13_ = search_entry;
			_tmp14_ = metadata;
			_tmp15_ = proton_plus_utils_text_input_metadata_get_purpose (_tmp14_);
			_tmp16_ = _tmp15_;
			gtk_search_entry_set_input_purpose (_tmp13_, _tmp16_);
			_tmp17_ = search_entry;
			_tmp18_ = metadata;
			_tmp19_ = proton_plus_utils_text_input_metadata_get_hints (_tmp18_);
			_tmp20_ = _tmp19_;
			gtk_search_entry_set_input_hints (_tmp17_, _tmp20_);
			_g_object_unref0 (search_entry);
		} else {
			if (G_TYPE_CHECK_INSTANCE_TYPE (widget, gtk_entry_get_type ())) {
				GtkEntry* entry = NULL;
				GtkEntry* _tmp21_;
				GtkEntry* _tmp22_;
				ProtonPlusUtilsTextInputMetadata* _tmp23_;
				GtkInputPurpose _tmp24_;
				GtkInputPurpose _tmp25_;
				GtkEntry* _tmp26_;
				ProtonPlusUtilsTextInputMetadata* _tmp27_;
				GtkInputHints _tmp28_;
				GtkInputHints _tmp29_;
				ProtonPlusUtilsTextInputMetadata* _tmp30_;
				_tmp21_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (widget, gtk_entry_get_type (), GtkEntry));
				entry = _tmp21_;
				_tmp22_ = entry;
				_tmp23_ = metadata;
				_tmp24_ = proton_plus_utils_text_input_metadata_get_purpose (_tmp23_);
				_tmp25_ = _tmp24_;
				gtk_entry_set_input_purpose (_tmp22_, _tmp25_);
				_tmp26_ = entry;
				_tmp27_ = metadata;
				_tmp28_ = proton_plus_utils_text_input_metadata_get_hints (_tmp27_);
				_tmp29_ = _tmp28_;
				gtk_entry_set_input_hints (_tmp26_, _tmp29_);
				_tmp30_ = metadata;
				if (proton_plus_utils_text_input_metadata_has_hint (_tmp30_, GTK_INPUT_HINT_NO_EMOJI)) {
					GtkEntry* _tmp31_;
					_tmp31_ = entry;
					g_object_set (_tmp31_, "enable-emoji-completion", FALSE, NULL);
				}
				_g_object_unref0 (entry);
			} else {
				if (G_TYPE_CHECK_INSTANCE_TYPE (widget, gtk_text_view_get_type ())) {
					GtkTextView* text_view = NULL;
					GtkTextView* _tmp32_;
					GtkTextView* _tmp33_;
					ProtonPlusUtilsTextInputMetadata* _tmp34_;
					GtkInputPurpose _tmp35_;
					GtkInputPurpose _tmp36_;
					GtkTextView* _tmp37_;
					ProtonPlusUtilsTextInputMetadata* _tmp38_;
					GtkInputHints _tmp39_;
					GtkInputHints _tmp40_;
					_tmp32_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (widget, gtk_text_view_get_type (), GtkTextView));
					text_view = _tmp32_;
					_tmp33_ = text_view;
					_tmp34_ = metadata;
					_tmp35_ = proton_plus_utils_text_input_metadata_get_purpose (_tmp34_);
					_tmp36_ = _tmp35_;
					gtk_text_view_set_input_purpose (_tmp33_, _tmp36_);
					_tmp37_ = text_view;
					_tmp38_ = metadata;
					_tmp39_ = proton_plus_utils_text_input_metadata_get_hints (_tmp38_);
					_tmp40_ = _tmp39_;
					gtk_text_view_set_input_hints (_tmp37_, _tmp40_);
					_g_object_unref0 (text_view);
				}
			}
		}
	}
	_g_object_unref0 (metadata);
}

static ProtonPlusUtilsTextInputMetadata*
proton_plus_utils_text_input_metadata_policy_exact_metadata (GtkInputPurpose purpose,
                                                             gboolean is_private)
{
	GtkInputHints hints = 0U;
	ProtonPlusUtilsTextInputMetadata* _tmp0_;
	ProtonPlusUtilsTextInputMetadata* result;
	hints = GTK_INPUT_HINT_NO_SPELLCHECK | GTK_INPUT_HINT_NO_EMOJI;
	if (is_private) {
		hints |= GTK_INPUT_HINT_PRIVATE;
	}
	_tmp0_ = proton_plus_utils_text_input_metadata_new (purpose, hints);
	result = _tmp0_;
	return result;
}

ProtonPlusUtilsTextInputMetadataPolicy*
proton_plus_utils_text_input_metadata_policy_construct (GType object_type)
{
	ProtonPlusUtilsTextInputMetadataPolicy * self = NULL;
	self = (ProtonPlusUtilsTextInputMetadataPolicy*) g_object_new (object_type, NULL);
	return self;
}

ProtonPlusUtilsTextInputMetadataPolicy*
proton_plus_utils_text_input_metadata_policy_new (void)
{
	return proton_plus_utils_text_input_metadata_policy_construct (PROTON_PLUS_UTILS_TYPE_TEXT_INPUT_METADATA_POLICY);
}

static void
proton_plus_utils_text_input_metadata_policy_class_init (ProtonPlusUtilsTextInputMetadataPolicyClass * klass,
                                                         gpointer klass_data)
{
	proton_plus_utils_text_input_metadata_policy_parent_class = g_type_class_peek_parent (klass);
}

static void
proton_plus_utils_text_input_metadata_policy_instance_init (ProtonPlusUtilsTextInputMetadataPolicy * self,
                                                            gpointer klass)
{
}

static GType
proton_plus_utils_text_input_metadata_policy_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (ProtonPlusUtilsTextInputMetadataPolicyClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) proton_plus_utils_text_input_metadata_policy_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ProtonPlusUtilsTextInputMetadataPolicy), 0, (GInstanceInitFunc) proton_plus_utils_text_input_metadata_policy_instance_init, NULL };
	GType proton_plus_utils_text_input_metadata_policy_type_id;
	proton_plus_utils_text_input_metadata_policy_type_id = g_type_register_static (G_TYPE_OBJECT, "ProtonPlusUtilsTextInputMetadataPolicy", &g_define_type_info, 0);
	return proton_plus_utils_text_input_metadata_policy_type_id;
}

GType
proton_plus_utils_text_input_metadata_policy_get_type (void)
{
	static volatile gsize proton_plus_utils_text_input_metadata_policy_type_id__once = 0;
	if (g_once_init_enter (&proton_plus_utils_text_input_metadata_policy_type_id__once)) {
		GType proton_plus_utils_text_input_metadata_policy_type_id;
		proton_plus_utils_text_input_metadata_policy_type_id = proton_plus_utils_text_input_metadata_policy_get_type_once ();
		g_once_init_leave (&proton_plus_utils_text_input_metadata_policy_type_id__once, proton_plus_utils_text_input_metadata_policy_type_id);
	}
	return proton_plus_utils_text_input_metadata_policy_type_id__once;
}

static GType
proton_plus_utils_controller_activation_decision_get_type_once (void)
{
	static const GEnumValue values[] = {{PROTON_PLUS_UTILS_CONTROLLER_ACTIVATION_DECISION_ACTIVATE, "PROTON_PLUS_UTILS_CONTROLLER_ACTIVATION_DECISION_ACTIVATE", "activate"}, {PROTON_PLUS_UTILS_CONTROLLER_ACTIVATION_DECISION_FOCUS_TEXT_INPUT, "PROTON_PLUS_UTILS_CONTROLLER_ACTIVATION_DECISION_FOCUS_TEXT_INPUT", "focus-text-input"}, {0, NULL, NULL}};
	GType proton_plus_utils_controller_activation_decision_type_id;
	proton_plus_utils_controller_activation_decision_type_id = g_enum_register_static ("ProtonPlusUtilsControllerActivationDecision", values);
	return proton_plus_utils_controller_activation_decision_type_id;
}

GType
proton_plus_utils_controller_activation_decision_get_type (void)
{
	static volatile gsize proton_plus_utils_controller_activation_decision_type_id__once = 0;
	if (g_once_init_enter (&proton_plus_utils_controller_activation_decision_type_id__once)) {
		GType proton_plus_utils_controller_activation_decision_type_id;
		proton_plus_utils_controller_activation_decision_type_id = proton_plus_utils_controller_activation_decision_get_type_once ();
		g_once_init_leave (&proton_plus_utils_controller_activation_decision_type_id__once, proton_plus_utils_controller_activation_decision_type_id);
	}
	return proton_plus_utils_controller_activation_decision_type_id__once;
}

ProtonPlusUtilsControllerActivationDecision
proton_plus_utils_controller_activation_policy_for_focused_control (gboolean has_effective_editable)
{
	ProtonPlusUtilsControllerActivationDecision _tmp0_ = 0;
	ProtonPlusUtilsControllerActivationDecision result;
	if (has_effective_editable) {
		_tmp0_ = PROTON_PLUS_UTILS_CONTROLLER_ACTIVATION_DECISION_FOCUS_TEXT_INPUT;
	} else {
		_tmp0_ = PROTON_PLUS_UTILS_CONTROLLER_ACTIVATION_DECISION_ACTIVATE;
	}
	result = _tmp0_;
	return result;
}

ProtonPlusUtilsControllerActivationPolicy*
proton_plus_utils_controller_activation_policy_construct (GType object_type)
{
	ProtonPlusUtilsControllerActivationPolicy * self = NULL;
	self = (ProtonPlusUtilsControllerActivationPolicy*) g_object_new (object_type, NULL);
	return self;
}

ProtonPlusUtilsControllerActivationPolicy*
proton_plus_utils_controller_activation_policy_new (void)
{
	return proton_plus_utils_controller_activation_policy_construct (PROTON_PLUS_UTILS_TYPE_CONTROLLER_ACTIVATION_POLICY);
}

static void
proton_plus_utils_controller_activation_policy_class_init (ProtonPlusUtilsControllerActivationPolicyClass * klass,
                                                           gpointer klass_data)
{
	proton_plus_utils_controller_activation_policy_parent_class = g_type_class_peek_parent (klass);
}

static void
proton_plus_utils_controller_activation_policy_instance_init (ProtonPlusUtilsControllerActivationPolicy * self,
                                                              gpointer klass)
{
}

static GType
proton_plus_utils_controller_activation_policy_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (ProtonPlusUtilsControllerActivationPolicyClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) proton_plus_utils_controller_activation_policy_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ProtonPlusUtilsControllerActivationPolicy), 0, (GInstanceInitFunc) proton_plus_utils_controller_activation_policy_instance_init, NULL };
	GType proton_plus_utils_controller_activation_policy_type_id;
	proton_plus_utils_controller_activation_policy_type_id = g_type_register_static (G_TYPE_OBJECT, "ProtonPlusUtilsControllerActivationPolicy", &g_define_type_info, 0);
	return proton_plus_utils_controller_activation_policy_type_id;
}

GType
proton_plus_utils_controller_activation_policy_get_type (void)
{
	static volatile gsize proton_plus_utils_controller_activation_policy_type_id__once = 0;
	if (g_once_init_enter (&proton_plus_utils_controller_activation_policy_type_id__once)) {
		GType proton_plus_utils_controller_activation_policy_type_id;
		proton_plus_utils_controller_activation_policy_type_id = proton_plus_utils_controller_activation_policy_get_type_once ();
		g_once_init_leave (&proton_plus_utils_controller_activation_policy_type_id__once, proton_plus_utils_controller_activation_policy_type_id);
	}
	return proton_plus_utils_controller_activation_policy_type_id__once;
}

gboolean
proton_plus_utils_controller_editable_target_resolver_accepts_edits (gboolean is_text_control,
                                                                     gboolean editable,
                                                                     gboolean sensitive)
{
	gboolean _tmp0_ = FALSE;
	gboolean _tmp1_ = FALSE;
	gboolean result;
	if (is_text_control) {
		_tmp1_ = editable;
	} else {
		_tmp1_ = FALSE;
	}
	if (_tmp1_) {
		_tmp0_ = sensitive;
	} else {
		_tmp0_ = FALSE;
	}
	result = _tmp0_;
	return result;
}

GtkWidget*
proton_plus_utils_controller_editable_target_resolver_resolve (GtkWidget* focused,
                                                               GtkWidget* root)
{
	GtkWidget* current = NULL;
	GtkWidget* _tmp0_;
	GtkWidget* delegate_candidate = NULL;
	GtkWidget* result;
	g_return_val_if_fail (root != NULL, NULL);
	_tmp0_ = _g_object_ref0 (focused);
	current = _tmp0_;
	delegate_candidate = NULL;
	while (TRUE) {
		GtkWidget* _tmp1_;
		gboolean is_editable = FALSE;
		GtkWidget* _tmp2_;
		gboolean is_text_view = FALSE;
		GtkWidget* _tmp3_;
		gboolean _tmp4_ = FALSE;
		GtkWidget* _tmp22_;
		GtkWidget* _tmp23_;
		GtkWidget* _tmp24_;
		GtkWidget* _tmp25_;
		_tmp1_ = current;
		if (!(_tmp1_ != NULL)) {
			break;
		}
		_tmp2_ = current;
		is_editable = G_TYPE_CHECK_INSTANCE_TYPE (_tmp2_, gtk_editable_get_type ());
		_tmp3_ = current;
		is_text_view = G_TYPE_CHECK_INSTANCE_TYPE (_tmp3_, gtk_text_view_get_type ());
		if (is_editable) {
			_tmp4_ = TRUE;
		} else {
			_tmp4_ = is_text_view;
		}
		if (_tmp4_) {
			gboolean _tmp5_ = FALSE;
			gboolean editable = FALSE;
			GtkWidget* _tmp8_;
			gboolean _tmp9_ = FALSE;
			gboolean _tmp10_ = FALSE;
			gboolean _tmp11_ = FALSE;
			GtkWidget* _tmp12_;
			GtkWidget* _tmp16_;
			if (is_editable) {
				GtkWidget* _tmp6_;
				_tmp6_ = current;
				_tmp5_ = gtk_editable_get_editable (G_TYPE_CHECK_INSTANCE_CAST (_tmp6_, gtk_editable_get_type (), GtkEditable));
			} else {
				GtkWidget* _tmp7_;
				_tmp7_ = current;
				_tmp5_ = gtk_text_view_get_editable (G_TYPE_CHECK_INSTANCE_CAST (_tmp7_, gtk_text_view_get_type (), GtkTextView));
			}
			editable = _tmp5_;
			_tmp8_ = current;
			if (!proton_plus_utils_controller_editable_target_resolver_accepts_edits (TRUE, editable, gtk_widget_is_sensitive (_tmp8_))) {
				result = NULL;
				_g_object_unref0 (delegate_candidate);
				_g_object_unref0 (current);
				return result;
			}
			_tmp12_ = current;
			if (G_TYPE_CHECK_INSTANCE_TYPE (_tmp12_, adw_entry_row_get_type ())) {
				_tmp11_ = TRUE;
			} else {
				GtkWidget* _tmp13_;
				_tmp13_ = current;
				_tmp11_ = G_TYPE_CHECK_INSTANCE_TYPE (_tmp13_, gtk_entry_get_type ());
			}
			if (_tmp11_) {
				_tmp10_ = TRUE;
			} else {
				GtkWidget* _tmp14_;
				_tmp14_ = current;
				_tmp10_ = G_TYPE_CHECK_INSTANCE_TYPE (_tmp14_, gtk_search_entry_get_type ());
			}
			if (_tmp10_) {
				_tmp9_ = TRUE;
			} else {
				GtkWidget* _tmp15_;
				_tmp15_ = current;
				_tmp9_ = G_TYPE_CHECK_INSTANCE_TYPE (_tmp15_, gtk_text_view_get_type ());
			}
			if (_tmp9_) {
				result = current;
				_g_object_unref0 (delegate_candidate);
				return result;
			}
			_tmp16_ = delegate_candidate;
			if (_tmp16_ == NULL) {
				GtkWidget* _tmp17_;
				GtkWidget* _tmp18_;
				_tmp17_ = current;
				_tmp18_ = _g_object_ref0 (_tmp17_);
				_g_object_unref0 (delegate_candidate);
				delegate_candidate = _tmp18_;
			}
		} else {
			gboolean _tmp19_ = FALSE;
			GtkWidget* _tmp20_;
			_tmp20_ = delegate_candidate;
			if (_tmp20_ == NULL) {
				GtkWidget* _tmp21_;
				_tmp21_ = current;
				_tmp19_ = gtk_widget_get_focusable (_tmp21_);
			} else {
				_tmp19_ = FALSE;
			}
			if (_tmp19_) {
				result = NULL;
				_g_object_unref0 (delegate_candidate);
				_g_object_unref0 (current);
				return result;
			}
		}
		_tmp22_ = current;
		if (_tmp22_ == root) {
			break;
		}
		_tmp23_ = current;
		_tmp24_ = gtk_widget_get_parent (_tmp23_);
		_tmp25_ = _g_object_ref0 (_tmp24_);
		_g_object_unref0 (current);
		current = _tmp25_;
	}
	result = delegate_candidate;
	_g_object_unref0 (current);
	return result;
}

ProtonPlusUtilsControllerEditableTargetResolver*
proton_plus_utils_controller_editable_target_resolver_construct (GType object_type)
{
	ProtonPlusUtilsControllerEditableTargetResolver * self = NULL;
	self = (ProtonPlusUtilsControllerEditableTargetResolver*) g_object_new (object_type, NULL);
	return self;
}

ProtonPlusUtilsControllerEditableTargetResolver*
proton_plus_utils_controller_editable_target_resolver_new (void)
{
	return proton_plus_utils_controller_editable_target_resolver_construct (PROTON_PLUS_UTILS_TYPE_CONTROLLER_EDITABLE_TARGET_RESOLVER);
}

static void
proton_plus_utils_controller_editable_target_resolver_class_init (ProtonPlusUtilsControllerEditableTargetResolverClass * klass,
                                                                  gpointer klass_data)
{
	proton_plus_utils_controller_editable_target_resolver_parent_class = g_type_class_peek_parent (klass);
}

static void
proton_plus_utils_controller_editable_target_resolver_instance_init (ProtonPlusUtilsControllerEditableTargetResolver * self,
                                                                     gpointer klass)
{
}

static GType
proton_plus_utils_controller_editable_target_resolver_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (ProtonPlusUtilsControllerEditableTargetResolverClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) proton_plus_utils_controller_editable_target_resolver_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ProtonPlusUtilsControllerEditableTargetResolver), 0, (GInstanceInitFunc) proton_plus_utils_controller_editable_target_resolver_instance_init, NULL };
	GType proton_plus_utils_controller_editable_target_resolver_type_id;
	proton_plus_utils_controller_editable_target_resolver_type_id = g_type_register_static (G_TYPE_OBJECT, "ProtonPlusUtilsControllerEditableTargetResolver", &g_define_type_info, 0);
	return proton_plus_utils_controller_editable_target_resolver_type_id;
}

GType
proton_plus_utils_controller_editable_target_resolver_get_type (void)
{
	static volatile gsize proton_plus_utils_controller_editable_target_resolver_type_id__once = 0;
	if (g_once_init_enter (&proton_plus_utils_controller_editable_target_resolver_type_id__once)) {
		GType proton_plus_utils_controller_editable_target_resolver_type_id;
		proton_plus_utils_controller_editable_target_resolver_type_id = proton_plus_utils_controller_editable_target_resolver_get_type_once ();
		g_once_init_leave (&proton_plus_utils_controller_editable_target_resolver_type_id__once, proton_plus_utils_controller_editable_target_resolver_type_id);
	}
	return proton_plus_utils_controller_editable_target_resolver_type_id__once;
}

static inline gpointer
_vala_memdup2 (gconstpointer mem,
               gsize byte_size)
{
	gpointer new_mem;
	if (mem && byte_size != 0) {
		new_mem = g_malloc (byte_size);
		memcpy (new_mem, mem, byte_size);
	} else {
		new_mem = NULL;
	}
	return new_mem;
}

