/* launch-options-editor-custom-expander-row.c generated by valac 0.56.19, the Vala compiler
 * generated from launch-options-editor-custom-expander-row.vala, do not modify */

#include "protonplus_core.h"
#include <gee.h>
#include <glib-object.h>
#include <stdlib.h>
#include <string.h>
#include <glib.h>
#include <adwaita.h>
#include <gtk/gtk.h>
#include <glib/gi18n-lib.h>
#include <gdk/gdk.h>
#include <gio/gio.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_WIDGETS_GAMES_LAUNCH_OPTIONS_EDITOR_CUSTOM_EXPANDER_ROW_0_PROPERTY,
	PROTON_PLUS_WIDGETS_GAMES_LAUNCH_OPTIONS_EDITOR_CUSTOM_EXPANDER_ROW_IS_ADVANCED_PROPERTY,
	PROTON_PLUS_WIDGETS_GAMES_LAUNCH_OPTIONS_EDITOR_CUSTOM_EXPANDER_ROW_NUM_PROPERTIES
};
static GParamSpec* proton_plus_widgets_games_launch_options_editor_custom_expander_row_properties[PROTON_PLUS_WIDGETS_GAMES_LAUNCH_OPTIONS_EDITOR_CUSTOM_EXPANDER_ROW_NUM_PROPERTIES];
#define _g_hash_table_unref0(var) ((var == NULL) ? NULL : (var = (g_hash_table_unref (var), NULL)))
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))
enum  {
	PROTON_PLUS_WIDGETS_GAMES_LAUNCH_OPTIONS_EDITOR_CUSTOM_EXPANDER_ROW_CHANGED_SIGNAL,
	PROTON_PLUS_WIDGETS_GAMES_LAUNCH_OPTIONS_EDITOR_CUSTOM_EXPANDER_ROW_NUM_SIGNALS
};
static guint proton_plus_widgets_games_launch_options_editor_custom_expander_row_signals[PROTON_PLUS_WIDGETS_GAMES_LAUNCH_OPTIONS_EDITOR_CUSTOM_EXPANDER_ROW_NUM_SIGNALS] = {0};

struct _ProtonPlusWidgetsGamesLaunchOptionsEditorCustomExpanderRowPrivate {
	GeeHashSet* predefined_keys;
	AdwEntryRow* add_custom_row;
	gboolean _is_advanced;
	GtkEventControllerKey* key_controller;
};

static gint ProtonPlusWidgetsGamesLaunchOptionsEditorCustomExpanderRow_private_offset;
static gpointer proton_plus_widgets_games_launch_options_editor_custom_expander_row_parent_class = NULL;

static gchar** _vala_array_dup22 (gchar** self,
                           gssize length);
static gchar** _vala_array_dup23 (gchar** self,
                           gssize length);
static void _g_free0_ (gpointer var);
static void _g_object_unref0_ (gpointer var);
static void proton_plus_widgets_games_launch_options_editor_custom_expander_row_on_custom_item_added (ProtonPlusWidgetsGamesLaunchOptionsEditorCustomExpanderRow* self);
static void _proton_plus_widgets_games_launch_options_editor_custom_expander_row_on_custom_item_added_gtk_button_clicked (GtkButton* _sender,
                                                                                                                   gpointer self);
static gboolean __lambda111_ (ProtonPlusWidgetsGamesLaunchOptionsEditorCustomExpanderRow* self,
                       guint keyval,
                       guint keycode,
                       GdkModifierType state);
static gboolean ___lambda111__gtk_event_controller_key_key_pressed (GtkEventControllerKey* _sender,
                                                             guint keyval,
                                                             guint keycode,
                                                             GdkModifierType state,
                                                             gpointer self);
static void __lambda112_ (ProtonPlusWidgetsGamesLaunchOptionsEditorCustomExpanderRow* self);
static void ___lambda112__g_object_notify (GObject* _sender,
                                    GParamSpec* pspec,
                                    gpointer self);
static void __lambda110_ (ProtonPlusWidgetsGamesLaunchOptionsEditorCustomExpanderRow* self);
static void ___lambda110__g_object_notify (GObject* _sender,
                                    GParamSpec* pspec,
                                    gpointer self);
static void proton_plus_widgets_games_launch_options_editor_custom_expander_row_real_trigger_changed_if_ready (ProtonPlusWidgetsGamesLaunchOptionsEditorCustomExpanderRow* self);
static gboolean proton_plus_widgets_games_launch_options_editor_custom_expander_row_real_is_active (ProtonPlusWidgetsGamesLaunchOptionsEditorCustomExpanderRow* self);
static void proton_plus_widgets_games_launch_options_editor_custom_expander_row_finalize (GObject * obj);
static GType proton_plus_widgets_games_launch_options_editor_custom_expander_row_get_type_once (void);
static void _vala_proton_plus_widgets_games_launch_options_editor_custom_expander_row_get_property (GObject * object,
                                                                                             guint property_id,
                                                                                             GValue * value,
                                                                                             GParamSpec * pspec);
static void _vala_proton_plus_widgets_games_launch_options_editor_custom_expander_row_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 _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

static inline gpointer
proton_plus_widgets_games_launch_options_editor_custom_expander_row_get_instance_private (ProtonPlusWidgetsGamesLaunchOptionsEditorCustomExpanderRow* self)
{
	return G_STRUCT_MEMBER_P (self, ProtonPlusWidgetsGamesLaunchOptionsEditorCustomExpanderRow_private_offset);
}

static gchar**
_vala_array_dup22 (gchar** self,
                   gssize length)
{
	if (length >= 0) {
		gchar** result;
		gssize i;
		result = g_new0 (gchar*, length + 1);
		for (i = 0; i < length; i++) {
			gchar* _tmp0_;
			_tmp0_ = g_strdup (self[i]);
			result[i] = _tmp0_;
		}
		return result;
	}
	return NULL;
}

static gchar**
_vala_array_dup23 (gchar** self,
                   gssize length)
{
	if (length >= 0) {
		gchar** result;
		gssize i;
		result = g_new0 (gchar*, length + 1);
		for (i = 0; i < length; i++) {
			gchar* _tmp0_;
			_tmp0_ = g_strdup (self[i]);
			result[i] = _tmp0_;
		}
		return result;
	}
	return NULL;
}

static void
_g_free0_ (gpointer var)
{
	var = (g_free (var), NULL);
}

static void
_g_object_unref0_ (gpointer var)
{
	(var == NULL) ? NULL : (var = (g_object_unref (var), NULL));
}

static gpointer
_g_hash_table_ref0 (gpointer self)
{
	return self ? g_hash_table_ref (self) : NULL;
}

static void
_proton_plus_widgets_games_launch_options_editor_custom_expander_row_on_custom_item_added_gtk_button_clicked (GtkButton* _sender,
                                                                                                              gpointer self)
{
	proton_plus_widgets_games_launch_options_editor_custom_expander_row_on_custom_item_added ((ProtonPlusWidgetsGamesLaunchOptionsEditorCustomExpanderRow*) self);
}

static gboolean
__lambda111_ (ProtonPlusWidgetsGamesLaunchOptionsEditorCustomExpanderRow* self,
              guint keyval,
              guint keycode,
              GdkModifierType state)
{
	gboolean _tmp0_ = FALSE;
	gboolean result;
	if (keyval == ((guint) GDK_KEY_Return)) {
		_tmp0_ = TRUE;
	} else {
		_tmp0_ = keyval == ((guint) GDK_KEY_KP_Enter);
	}
	if (_tmp0_) {
		proton_plus_widgets_games_launch_options_editor_custom_expander_row_on_custom_item_added (self);
		result = TRUE;
		return result;
	}
	result = FALSE;
	return result;
}

static gboolean
___lambda111__gtk_event_controller_key_key_pressed (GtkEventControllerKey* _sender,
                                                    guint keyval,
                                                    guint keycode,
                                                    GdkModifierType state,
                                                    gpointer self)
{
	gboolean result;
	result = __lambda111_ ((ProtonPlusWidgetsGamesLaunchOptionsEditorCustomExpanderRow*) self, keyval, keycode, state);
	return result;
}

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

static void
__lambda112_ (ProtonPlusWidgetsGamesLaunchOptionsEditorCustomExpanderRow* self)
{
	proton_plus_widgets_games_launch_options_editor_custom_expander_row_trigger_changed_if_ready (self);
}

static void
___lambda112__g_object_notify (GObject* _sender,
                               GParamSpec* pspec,
                               gpointer self)
{
	__lambda112_ ((ProtonPlusWidgetsGamesLaunchOptionsEditorCustomExpanderRow*) self);
}

ProtonPlusWidgetsGamesLaunchOptionsEditorCustomExpanderRow*
proton_plus_widgets_games_launch_options_editor_custom_expander_row_construct (GType object_type,
                                                                               const gchar* switch_title,
                                                                               const gchar* switch_subtitle,
                                                                               gchar** options_display,
                                                                               gint options_display_length1,
                                                                               gchar** options_values,
                                                                               gint options_values_length1,
                                                                               GHashTable* tooltips)
{
	ProtonPlusWidgetsGamesLaunchOptionsEditorCustomExpanderRow * self = NULL;
	gchar** _tmp0_;
	gint _tmp0__length1;
	gchar** _tmp1_;
	gint _tmp1__length1;
	GHashFunc _tmp2_;
	GEqualFunc _tmp3_;
	GHashTable* _tmp4_;
	GeeArrayList* _tmp5_;
	GeeHashSet* _tmp6_;
	GHashTable* _tmp7_;
	AdwEntryRow* _tmp8_;
	AdwEntryRow* _tmp9_;
	AdwEntryRow* _tmp10_;
	AdwEntryRow* _tmp11_;
	AdwEntryRow* _tmp12_;
	const gchar* _tmp13_;
	const gchar* _tmp14_;
	AdwEntryRow* _tmp15_;
	GtkButton* add_button = NULL;
	GtkButton* _tmp16_;
	AdwEntryRow* _tmp17_;
	const gchar* _tmp18_;
	const gchar* _tmp19_;
	AdwEntryRow* _tmp20_;
	GtkEventControllerKey* _tmp21_;
	GtkEventControllerKey* _tmp22_;
	GtkEventControllerKey* _tmp23_;
	AdwEntryRow* _tmp24_;
	GtkEventControllerKey* _tmp25_;
	GtkEventController* _tmp26_;
	g_return_val_if_fail (switch_title != NULL, NULL);
	g_return_val_if_fail (switch_subtitle != NULL, NULL);
	self = (ProtonPlusWidgetsGamesLaunchOptionsEditorCustomExpanderRow*) g_object_new (object_type, "title", switch_title, "subtitle", switch_subtitle, "show-enable-switch", TRUE, NULL);
	_tmp0_ = (options_display != NULL) ? _vala_array_dup22 (options_display, options_display_length1) : options_display;
	_tmp0__length1 = options_display_length1;
	self->options_display = (_vala_array_free (self->options_display, self->options_display_length1, (GDestroyNotify) g_free), NULL);
	self->options_display = _tmp0_;
	self->options_display_length1 = _tmp0__length1;
	_tmp1_ = (options_values != NULL) ? _vala_array_dup23 (options_values, options_values_length1) : options_values;
	_tmp1__length1 = options_values_length1;
	self->options_values = (_vala_array_free (self->options_values, self->options_values_length1, (GDestroyNotify) g_free), NULL);
	self->options_values = _tmp1_;
	self->options_values_length1 = _tmp1__length1;
	_tmp2_ = g_str_hash;
	_tmp3_ = g_str_equal;
	_tmp4_ = g_hash_table_new_full (_tmp2_, _tmp3_, _g_free0_, _g_object_unref0_);
	_g_hash_table_unref0 (self->rows_map);
	self->rows_map = _tmp4_;
	_tmp5_ = gee_array_list_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, NULL, NULL, NULL);
	_g_object_unref0 (self->row_order);
	self->row_order = _tmp5_;
	_tmp6_ = gee_hash_set_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, NULL, NULL, NULL, NULL, NULL, NULL);
	_g_object_unref0 (self->priv->predefined_keys);
	self->priv->predefined_keys = _tmp6_;
	_tmp7_ = _g_hash_table_ref0 (tooltips);
	_g_hash_table_unref0 (self->item_tooltips);
	self->item_tooltips = _tmp7_;
	gtk_widget_set_tooltip_text ((GtkWidget*) self, switch_subtitle);
	_tmp8_ = (AdwEntryRow*) adw_entry_row_new ();
	g_object_ref_sink (_tmp8_);
	_g_object_unref0 (self->priv->add_custom_row);
	self->priv->add_custom_row = _tmp8_;
	_tmp9_ = self->priv->add_custom_row;
	adw_preferences_row_set_title ((AdwPreferencesRow*) _tmp9_, _ ("Add custom item (Type name and press Enter)..."));
	_tmp10_ = self->priv->add_custom_row;
	proton_plus_utils_text_input_metadata_policy_apply ((GtkWidget*) _tmp10_, PROTON_PLUS_UTILS_TEXT_INPUT_FIELD_KIND_PATH_OR_IDENTIFIER);
	_tmp11_ = self->priv->add_custom_row;
	_tmp12_ = self->priv->add_custom_row;
	_tmp13_ = adw_preferences_row_get_title ((AdwPreferencesRow*) _tmp12_);
	_tmp14_ = _tmp13_;
	gtk_widget_set_tooltip_text ((GtkWidget*) _tmp11_, _tmp14_);
	_tmp15_ = self->priv->add_custom_row;
	adw_entry_row_set_activates_default (_tmp15_, TRUE);
	_tmp16_ = (GtkButton*) gtk_button_new_from_icon_name ("list-add-symbolic");
	g_object_ref_sink (_tmp16_);
	add_button = _tmp16_;
	gtk_widget_add_css_class ((GtkWidget*) add_button, "flat");
	gtk_widget_set_valign ((GtkWidget*) add_button, GTK_ALIGN_CENTER);
	_tmp17_ = self->priv->add_custom_row;
	_tmp18_ = adw_preferences_row_get_title ((AdwPreferencesRow*) _tmp17_);
	_tmp19_ = _tmp18_;
	gtk_widget_set_tooltip_text ((GtkWidget*) add_button, _tmp19_);
	g_signal_connect_object (add_button, "clicked", (GCallback) _proton_plus_widgets_games_launch_options_editor_custom_expander_row_on_custom_item_added_gtk_button_clicked, self, 0);
	_tmp20_ = self->priv->add_custom_row;
	adw_entry_row_add_suffix (_tmp20_, (GtkWidget*) add_button);
	_tmp21_ = (GtkEventControllerKey*) gtk_event_controller_key_new ();
	_g_object_unref0 (self->priv->key_controller);
	self->priv->key_controller = _tmp21_;
	_tmp22_ = self->priv->key_controller;
	gtk_event_controller_set_propagation_phase ((GtkEventController*) _tmp22_, GTK_PHASE_CAPTURE);
	_tmp23_ = self->priv->key_controller;
	g_signal_connect_object (_tmp23_, "key-pressed", (GCallback) ___lambda111__gtk_event_controller_key_key_pressed, self, 0);
	_tmp24_ = self->priv->add_custom_row;
	_tmp25_ = self->priv->key_controller;
	_tmp26_ = _g_object_ref0 ((GtkEventController*) _tmp25_);
	gtk_widget_add_controller ((GtkWidget*) _tmp24_, _tmp26_);
	g_signal_connect_object ((GObject*) self, "notify::enable-expansion", (GCallback) ___lambda112__g_object_notify, self, 0);
	_g_object_unref0 (add_button);
	return self;
}

ProtonPlusWidgetsGamesLaunchOptionsEditorCustomExpanderRow*
proton_plus_widgets_games_launch_options_editor_custom_expander_row_new (const gchar* switch_title,
                                                                         const gchar* switch_subtitle,
                                                                         gchar** options_display,
                                                                         gint options_display_length1,
                                                                         gchar** options_values,
                                                                         gint options_values_length1,
                                                                         GHashTable* tooltips)
{
	return proton_plus_widgets_games_launch_options_editor_custom_expander_row_construct (PROTON_PLUS_WIDGETS_GAMES_LAUNCH_OPTIONS_EDITOR_TYPE_CUSTOM_EXPANDER_ROW, switch_title, switch_subtitle, options_display, options_display_length1, options_values, options_values_length1, tooltips);
}

static gchar*
string_strip (const gchar* self)
{
	gchar* _result_ = NULL;
	gchar* _tmp0_;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = g_strdup (self);
	_result_ = _tmp0_;
	g_strstrip (_result_);
	result = _result_;
	return result;
}

void
proton_plus_widgets_games_launch_options_editor_custom_expander_row_init_predefined_keys (ProtonPlusWidgetsGamesLaunchOptionsEditorCustomExpanderRow* self,
                                                                                          gchar** predefined_keys,
                                                                                          gint predefined_keys_length1)
{
	AdwEntryRow* _tmp8_;
	g_return_if_fail (self != NULL);
	if (predefined_keys == NULL) {
		return;
	}
	{
		gchar** key_collection = NULL;
		gint key_collection_length1 = 0;
		gint _key_collection_size_ = 0;
		gint key_it = 0;
		key_collection = predefined_keys;
		key_collection_length1 = predefined_keys_length1;
		for (key_it = 0; key_it < key_collection_length1; key_it = key_it + 1) {
			gchar* _tmp0_;
			gchar* key = NULL;
			_tmp0_ = g_strdup (key_collection[key_it]);
			key = _tmp0_;
			{
				GeeHashSet* _tmp1_;
				const gchar* _tmp2_;
				gchar* _tmp3_;
				gchar* _tmp4_;
				gchar* _tmp5_;
				gchar* _tmp6_;
				const gchar* _tmp7_;
				_tmp1_ = self->priv->predefined_keys;
				_tmp2_ = key;
				_tmp3_ = string_strip (_tmp2_);
				_tmp4_ = _tmp3_;
				_tmp5_ = g_utf8_strdown (_tmp4_, (gssize) -1);
				_tmp6_ = _tmp5_;
				gee_abstract_collection_add ((GeeAbstractCollection*) _tmp1_, _tmp6_);
				_g_free0 (_tmp6_);
				_g_free0 (_tmp4_);
				_tmp7_ = key;
				proton_plus_widgets_games_launch_options_editor_custom_expander_row_create_item_row (self, _tmp7_, "");
				_g_free0 (key);
			}
		}
	}
	_tmp8_ = self->priv->add_custom_row;
	adw_expander_row_add_row ((AdwExpanderRow*) self, (GtkWidget*) _tmp8_);
}

static void
__lambda110_ (ProtonPlusWidgetsGamesLaunchOptionsEditorCustomExpanderRow* self)
{
	proton_plus_widgets_games_launch_options_editor_custom_expander_row_trigger_changed_if_ready (self);
}

static void
___lambda110__g_object_notify (GObject* _sender,
                               GParamSpec* pspec,
                               gpointer self)
{
	__lambda110_ ((ProtonPlusWidgetsGamesLaunchOptionsEditorCustomExpanderRow*) self);
}

void
proton_plus_widgets_games_launch_options_editor_custom_expander_row_create_item_row (ProtonPlusWidgetsGamesLaunchOptionsEditorCustomExpanderRow* self,
                                                                                     const gchar* key_name,
                                                                                     const gchar* initial_value)
{
	gchar* normalized_key = NULL;
	gchar* _tmp0_;
	gchar* _tmp1_;
	gchar* _tmp2_;
	gchar* _tmp3_;
	GHashTable* _tmp4_;
	const gchar* _tmp5_;
	AdwComboRow* row = NULL;
	AdwComboRow* _tmp6_;
	AdwComboRow* _tmp7_;
	const gchar* _tmp8_;
	AdwComboRow* _tmp9_;
	gchar** _tmp10_;
	gint _tmp10__length1;
	GtkStringList* _tmp11_;
	GtkStringList* _tmp12_;
	guint selected_idx = 0U;
	AdwComboRow* _tmp18_;
	AdwComboRow* _tmp19_;
	gboolean _tmp20_ = FALSE;
	GHashTable* _tmp21_;
	GHashTable* _tmp36_;
	const gchar* _tmp37_;
	gchar* _tmp38_;
	AdwComboRow* _tmp39_;
	AdwComboRow* _tmp40_;
	GeeArrayList* _tmp41_;
	const gchar* _tmp42_;
	AdwComboRow* _tmp43_;
	AdwComboRow* _tmp44_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (key_name != NULL);
	g_return_if_fail (initial_value != NULL);
	_tmp0_ = string_strip (key_name);
	_tmp1_ = _tmp0_;
	_tmp2_ = g_utf8_strdown (_tmp1_, (gssize) -1);
	_tmp3_ = _tmp2_;
	_g_free0 (_tmp1_);
	normalized_key = _tmp3_;
	_tmp4_ = self->rows_map;
	_tmp5_ = normalized_key;
	if (g_hash_table_contains (_tmp4_, _tmp5_)) {
		_g_free0 (normalized_key);
		return;
	}
	_tmp6_ = (AdwComboRow*) adw_combo_row_new ();
	g_object_ref_sink (_tmp6_);
	row = _tmp6_;
	_tmp7_ = row;
	_tmp8_ = normalized_key;
	adw_preferences_row_set_title ((AdwPreferencesRow*) _tmp7_, _tmp8_);
	_tmp9_ = row;
	_tmp10_ = self->options_display;
	_tmp10__length1 = self->options_display_length1;
	_tmp11_ = gtk_string_list_new (_tmp10_);
	_tmp12_ = _tmp11_;
	adw_combo_row_set_model (_tmp9_, (GListModel*) _tmp12_);
	_g_object_unref0 (_tmp12_);
	selected_idx = (guint) 0;
	{
		guint i = 0U;
		i = (guint) 0;
		{
			gboolean _tmp13_ = FALSE;
			_tmp13_ = TRUE;
			while (TRUE) {
				gchar** _tmp15_;
				gint _tmp15__length1;
				gchar** _tmp16_;
				gint _tmp16__length1;
				const gchar* _tmp17_;
				if (!_tmp13_) {
					guint _tmp14_;
					_tmp14_ = i;
					i = _tmp14_ + 1;
				}
				_tmp13_ = FALSE;
				_tmp15_ = self->options_values;
				_tmp15__length1 = self->options_values_length1;
				if (!(i < ((guint) _tmp15__length1))) {
					break;
				}
				_tmp16_ = self->options_values;
				_tmp16__length1 = self->options_values_length1;
				_tmp17_ = _tmp16_[i];
				if (g_strcmp0 (_tmp17_, initial_value) == 0) {
					selected_idx = i;
					break;
				}
			}
		}
	}
	_tmp18_ = row;
	adw_combo_row_set_selected (_tmp18_, selected_idx);
	_tmp19_ = row;
	g_signal_connect_object ((GObject*) _tmp19_, "notify::selected", (GCallback) ___lambda110__g_object_notify, self, 0);
	_tmp21_ = self->item_tooltips;
	if (_tmp21_ != NULL) {
		GHashTable* _tmp22_;
		const gchar* _tmp23_;
		_tmp22_ = self->item_tooltips;
		_tmp23_ = normalized_key;
		_tmp20_ = g_hash_table_contains (_tmp22_, _tmp23_);
	} else {
		_tmp20_ = FALSE;
	}
	if (_tmp20_) {
		AdwComboRow* _tmp24_;
		GHashTable* _tmp25_;
		const gchar* _tmp26_;
		gconstpointer _tmp27_;
		AdwComboRow* _tmp28_;
		AdwComboRow* _tmp29_;
		const gchar* _tmp30_;
		const gchar* _tmp31_;
		_tmp24_ = row;
		_tmp25_ = self->item_tooltips;
		_tmp26_ = normalized_key;
		_tmp27_ = g_hash_table_lookup (_tmp25_, _tmp26_);
		adw_action_row_set_subtitle ((AdwActionRow*) _tmp24_, (const gchar*) _tmp27_);
		_tmp28_ = row;
		_tmp29_ = row;
		_tmp30_ = adw_action_row_get_subtitle ((AdwActionRow*) _tmp29_);
		_tmp31_ = _tmp30_;
		gtk_widget_set_tooltip_text ((GtkWidget*) _tmp28_, _tmp31_);
	} else {
		AdwComboRow* _tmp32_;
		AdwComboRow* _tmp33_;
		const gchar* _tmp34_;
		const gchar* _tmp35_;
		_tmp32_ = row;
		_tmp33_ = row;
		_tmp34_ = adw_preferences_row_get_title ((AdwPreferencesRow*) _tmp33_);
		_tmp35_ = _tmp34_;
		gtk_widget_set_tooltip_text ((GtkWidget*) _tmp32_, _tmp35_);
	}
	_tmp36_ = self->rows_map;
	_tmp37_ = normalized_key;
	_tmp38_ = g_strdup (_tmp37_);
	_tmp39_ = row;
	_tmp40_ = _g_object_ref0 (_tmp39_);
	g_hash_table_insert (_tmp36_, _tmp38_, _tmp40_);
	_tmp41_ = self->row_order;
	_tmp42_ = normalized_key;
	gee_abstract_collection_add ((GeeAbstractCollection*) _tmp41_, _tmp42_);
	_tmp43_ = row;
	adw_expander_row_add_row ((AdwExpanderRow*) self, (GtkWidget*) _tmp43_);
	_tmp44_ = row;
	gtk_widget_set_visible ((GtkWidget*) _tmp44_, TRUE);
	_g_object_unref0 (row);
	_g_free0 (normalized_key);
}

static void
proton_plus_widgets_games_launch_options_editor_custom_expander_row_on_custom_item_added (ProtonPlusWidgetsGamesLaunchOptionsEditorCustomExpanderRow* self)
{
	gchar* custom_key = NULL;
	AdwEntryRow* _tmp0_;
	const gchar* _tmp1_;
	const gchar* _tmp2_;
	gchar* _tmp3_;
	gchar* _tmp4_;
	gchar* _tmp5_;
	gchar* _tmp6_;
	gboolean _tmp7_ = FALSE;
	const gchar* _tmp8_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->add_custom_row;
	_tmp1_ = gtk_editable_get_text ((GtkEditable*) _tmp0_);
	_tmp2_ = _tmp1_;
	_tmp3_ = string_strip (_tmp2_);
	_tmp4_ = _tmp3_;
	_tmp5_ = g_utf8_strdown (_tmp4_, (gssize) -1);
	_tmp6_ = _tmp5_;
	_g_free0 (_tmp4_);
	custom_key = _tmp6_;
	_tmp8_ = custom_key;
	if (g_strcmp0 (_tmp8_, "") != 0) {
		GHashTable* _tmp9_;
		const gchar* _tmp10_;
		_tmp9_ = self->rows_map;
		_tmp10_ = custom_key;
		_tmp7_ = !g_hash_table_contains (_tmp9_, _tmp10_);
	} else {
		_tmp7_ = FALSE;
	}
	if (_tmp7_) {
		const gchar* _tmp11_ = NULL;
		gchar** _tmp12_;
		gint _tmp12__length1;
		gchar* default_val = NULL;
		gchar* _tmp15_;
		AdwEntryRow* _tmp16_;
		const gchar* _tmp17_;
		const gchar* _tmp18_;
		AdwEntryRow* _tmp19_;
		AdwEntryRow* _tmp20_;
		_tmp12_ = self->options_values;
		_tmp12__length1 = self->options_values_length1;
		if (_tmp12__length1 > 1) {
			gchar** _tmp13_;
			gint _tmp13__length1;
			const gchar* _tmp14_;
			_tmp13_ = self->options_values;
			_tmp13__length1 = self->options_values_length1;
			_tmp14_ = _tmp13_[1];
			_tmp11_ = _tmp14_;
		} else {
			_tmp11_ = "";
		}
		_tmp15_ = g_strdup (_tmp11_);
		default_val = _tmp15_;
		_tmp16_ = self->priv->add_custom_row;
		adw_expander_row_remove ((AdwExpanderRow*) self, (GtkWidget*) _tmp16_);
		_tmp17_ = custom_key;
		_tmp18_ = default_val;
		proton_plus_widgets_games_launch_options_editor_custom_expander_row_create_item_row (self, _tmp17_, _tmp18_);
		_tmp19_ = self->priv->add_custom_row;
		adw_expander_row_add_row ((AdwExpanderRow*) self, (GtkWidget*) _tmp19_);
		_tmp20_ = self->priv->add_custom_row;
		gtk_editable_set_text ((GtkEditable*) _tmp20_, "");
		proton_plus_widgets_games_launch_options_editor_custom_expander_row_trigger_changed_if_ready (self);
		_g_free0 (default_val);
	} else {
		AdwEntryRow* _tmp21_;
		_tmp21_ = self->priv->add_custom_row;
		gtk_editable_set_text ((GtkEditable*) _tmp21_, "");
	}
	_g_free0 (custom_key);
}

void
proton_plus_widgets_games_launch_options_editor_custom_expander_row_force_add_custom_row (ProtonPlusWidgetsGamesLaunchOptionsEditorCustomExpanderRow* self,
                                                                                          const gchar* key,
                                                                                          const gchar* val)
{
	AdwEntryRow* _tmp0_;
	AdwEntryRow* _tmp1_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (key != NULL);
	g_return_if_fail (val != NULL);
	_tmp0_ = self->priv->add_custom_row;
	adw_expander_row_remove ((AdwExpanderRow*) self, (GtkWidget*) _tmp0_);
	proton_plus_widgets_games_launch_options_editor_custom_expander_row_create_item_row (self, key, val);
	_tmp1_ = self->priv->add_custom_row;
	adw_expander_row_add_row ((AdwExpanderRow*) self, (GtkWidget*) _tmp1_);
}

void
proton_plus_widgets_games_launch_options_editor_custom_expander_row_clear_custom_items (ProtonPlusWidgetsGamesLaunchOptionsEditorCustomExpanderRow* self)
{
	GeeArrayList* custom_keys = NULL;
	GeeArrayList* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = gee_array_list_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, NULL, NULL, NULL);
	custom_keys = _tmp0_;
	{
		GeeArrayList* _key_list = NULL;
		GeeArrayList* _tmp1_;
		gint _key_size = 0;
		GeeArrayList* _tmp2_;
		gint _tmp3_;
		gint _tmp4_;
		gint _key_index = 0;
		_tmp1_ = self->row_order;
		_key_list = _tmp1_;
		_tmp2_ = _key_list;
		_tmp3_ = gee_abstract_collection_get_size ((GeeAbstractCollection*) _tmp2_);
		_tmp4_ = _tmp3_;
		_key_size = _tmp4_;
		_key_index = -1;
		while (TRUE) {
			gint _tmp5_;
			gint _tmp6_;
			gchar* key = NULL;
			GeeArrayList* _tmp7_;
			gpointer _tmp8_;
			GeeHashSet* _tmp9_;
			const gchar* _tmp10_;
			_key_index = _key_index + 1;
			_tmp5_ = _key_index;
			_tmp6_ = _key_size;
			if (!(_tmp5_ < _tmp6_)) {
				break;
			}
			_tmp7_ = _key_list;
			_tmp8_ = gee_abstract_list_get ((GeeAbstractList*) _tmp7_, _key_index);
			key = (gchar*) _tmp8_;
			_tmp9_ = self->priv->predefined_keys;
			_tmp10_ = key;
			if (!gee_abstract_collection_contains ((GeeAbstractCollection*) _tmp9_, _tmp10_)) {
				GeeArrayList* _tmp11_;
				const gchar* _tmp12_;
				_tmp11_ = custom_keys;
				_tmp12_ = key;
				gee_abstract_collection_add ((GeeAbstractCollection*) _tmp11_, _tmp12_);
			}
			_g_free0 (key);
		}
	}
	{
		GeeArrayList* _key_list = NULL;
		GeeArrayList* _tmp13_;
		gint _key_size = 0;
		GeeArrayList* _tmp14_;
		gint _tmp15_;
		gint _tmp16_;
		gint _key_index = 0;
		_tmp13_ = custom_keys;
		_key_list = _tmp13_;
		_tmp14_ = _key_list;
		_tmp15_ = gee_abstract_collection_get_size ((GeeAbstractCollection*) _tmp14_);
		_tmp16_ = _tmp15_;
		_key_size = _tmp16_;
		_key_index = -1;
		while (TRUE) {
			gint _tmp17_;
			gint _tmp18_;
			gchar* key = NULL;
			GeeArrayList* _tmp19_;
			gpointer _tmp20_;
			AdwComboRow* row = NULL;
			GHashTable* _tmp21_;
			const gchar* _tmp22_;
			gconstpointer _tmp23_;
			AdwComboRow* _tmp24_;
			AdwComboRow* _tmp25_;
			GHashTable* _tmp27_;
			const gchar* _tmp28_;
			GeeArrayList* _tmp29_;
			const gchar* _tmp30_;
			_key_index = _key_index + 1;
			_tmp17_ = _key_index;
			_tmp18_ = _key_size;
			if (!(_tmp17_ < _tmp18_)) {
				break;
			}
			_tmp19_ = _key_list;
			_tmp20_ = gee_abstract_list_get ((GeeAbstractList*) _tmp19_, _key_index);
			key = (gchar*) _tmp20_;
			_tmp21_ = self->rows_map;
			_tmp22_ = key;
			_tmp23_ = g_hash_table_lookup (_tmp21_, _tmp22_);
			_tmp24_ = _g_object_ref0 ((AdwComboRow*) _tmp23_);
			row = _tmp24_;
			_tmp25_ = row;
			if (_tmp25_ != NULL) {
				AdwComboRow* _tmp26_;
				_tmp26_ = row;
				adw_expander_row_remove ((AdwExpanderRow*) self, (GtkWidget*) _tmp26_);
			}
			_tmp27_ = self->rows_map;
			_tmp28_ = key;
			g_hash_table_remove (_tmp27_, _tmp28_);
			_tmp29_ = self->row_order;
			_tmp30_ = key;
			gee_abstract_collection_remove ((GeeAbstractCollection*) _tmp29_, _tmp30_);
			_g_object_unref0 (row);
			_g_free0 (key);
		}
	}
	_g_object_unref0 (custom_keys);
}

static void
proton_plus_widgets_games_launch_options_editor_custom_expander_row_real_trigger_changed_if_ready (ProtonPlusWidgetsGamesLaunchOptionsEditorCustomExpanderRow* self)
{
	g_signal_emit (self, proton_plus_widgets_games_launch_options_editor_custom_expander_row_signals[PROTON_PLUS_WIDGETS_GAMES_LAUNCH_OPTIONS_EDITOR_CUSTOM_EXPANDER_ROW_CHANGED_SIGNAL], 0);
}

void
proton_plus_widgets_games_launch_options_editor_custom_expander_row_trigger_changed_if_ready (ProtonPlusWidgetsGamesLaunchOptionsEditorCustomExpanderRow* self)
{
	ProtonPlusWidgetsGamesLaunchOptionsEditorCustomExpanderRowClass* _klass_;
	g_return_if_fail (self != NULL);
	_klass_ = PROTON_PLUS_WIDGETS_GAMES_LAUNCH_OPTIONS_EDITOR_CUSTOM_EXPANDER_ROW_GET_CLASS (self);
	if (_klass_->trigger_changed_if_ready) {
		_klass_->trigger_changed_if_ready (self);
	}
}

static gboolean
proton_plus_widgets_games_launch_options_editor_custom_expander_row_real_is_active (ProtonPlusWidgetsGamesLaunchOptionsEditorCustomExpanderRow* self)
{
	gboolean _tmp0_;
	gboolean _tmp1_;
	gboolean result;
	_tmp0_ = adw_expander_row_get_enable_expansion ((AdwExpanderRow*) self);
	_tmp1_ = _tmp0_;
	result = _tmp1_;
	return result;
}

gboolean
proton_plus_widgets_games_launch_options_editor_custom_expander_row_is_active (ProtonPlusWidgetsGamesLaunchOptionsEditorCustomExpanderRow* self)
{
	ProtonPlusWidgetsGamesLaunchOptionsEditorCustomExpanderRowClass* _klass_;
	g_return_val_if_fail (self != NULL, FALSE);
	_klass_ = PROTON_PLUS_WIDGETS_GAMES_LAUNCH_OPTIONS_EDITOR_CUSTOM_EXPANDER_ROW_GET_CLASS (self);
	if (_klass_->is_active) {
		return _klass_->is_active (self);
	}
	return FALSE;
}

gboolean
proton_plus_widgets_games_launch_options_editor_custom_expander_row_get_is_advanced (ProtonPlusWidgetsGamesLaunchOptionsEditorCustomExpanderRow* self)
{
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	result = self->priv->_is_advanced;
	return result;
}

void
proton_plus_widgets_games_launch_options_editor_custom_expander_row_set_is_advanced (ProtonPlusWidgetsGamesLaunchOptionsEditorCustomExpanderRow* self,
                                                                                     gboolean value)
{
	gboolean old_value;
	g_return_if_fail (self != NULL);
	old_value = proton_plus_widgets_games_launch_options_editor_custom_expander_row_get_is_advanced (self);
	if (old_value != value) {
		self->priv->_is_advanced = value;
		g_object_notify_by_pspec ((GObject *) self, proton_plus_widgets_games_launch_options_editor_custom_expander_row_properties[PROTON_PLUS_WIDGETS_GAMES_LAUNCH_OPTIONS_EDITOR_CUSTOM_EXPANDER_ROW_IS_ADVANCED_PROPERTY]);
	}
}

static void
proton_plus_widgets_games_launch_options_editor_custom_expander_row_class_init (ProtonPlusWidgetsGamesLaunchOptionsEditorCustomExpanderRowClass * klass,
                                                                                gpointer klass_data)
{
	proton_plus_widgets_games_launch_options_editor_custom_expander_row_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &ProtonPlusWidgetsGamesLaunchOptionsEditorCustomExpanderRow_private_offset);
	((ProtonPlusWidgetsGamesLaunchOptionsEditorCustomExpanderRowClass *) klass)->trigger_changed_if_ready = (void (*) (ProtonPlusWidgetsGamesLaunchOptionsEditorCustomExpanderRow*)) proton_plus_widgets_games_launch_options_editor_custom_expander_row_real_trigger_changed_if_ready;
	((ProtonPlusWidgetsGamesLaunchOptionsEditorCustomExpanderRowClass *) klass)->is_active = (gboolean (*) (ProtonPlusWidgetsGamesLaunchOptionsEditorCustomExpanderRow*)) proton_plus_widgets_games_launch_options_editor_custom_expander_row_real_is_active;
	G_OBJECT_CLASS (klass)->get_property = _vala_proton_plus_widgets_games_launch_options_editor_custom_expander_row_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_proton_plus_widgets_games_launch_options_editor_custom_expander_row_set_property;
	G_OBJECT_CLASS (klass)->finalize = proton_plus_widgets_games_launch_options_editor_custom_expander_row_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), PROTON_PLUS_WIDGETS_GAMES_LAUNCH_OPTIONS_EDITOR_CUSTOM_EXPANDER_ROW_IS_ADVANCED_PROPERTY, proton_plus_widgets_games_launch_options_editor_custom_expander_row_properties[PROTON_PLUS_WIDGETS_GAMES_LAUNCH_OPTIONS_EDITOR_CUSTOM_EXPANDER_ROW_IS_ADVANCED_PROPERTY] = g_param_spec_boolean ("is-advanced", "is-advanced", "is-advanced", FALSE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	proton_plus_widgets_games_launch_options_editor_custom_expander_row_signals[PROTON_PLUS_WIDGETS_GAMES_LAUNCH_OPTIONS_EDITOR_CUSTOM_EXPANDER_ROW_CHANGED_SIGNAL] = g_signal_new ("changed", PROTON_PLUS_WIDGETS_GAMES_LAUNCH_OPTIONS_EDITOR_TYPE_CUSTOM_EXPANDER_ROW, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
}

static void
proton_plus_widgets_games_launch_options_editor_custom_expander_row_instance_init (ProtonPlusWidgetsGamesLaunchOptionsEditorCustomExpanderRow * self,
                                                                                   gpointer klass)
{
	self->priv = proton_plus_widgets_games_launch_options_editor_custom_expander_row_get_instance_private (self);
	self->priv->_is_advanced = FALSE;
}

static void
proton_plus_widgets_games_launch_options_editor_custom_expander_row_finalize (GObject * obj)
{
	ProtonPlusWidgetsGamesLaunchOptionsEditorCustomExpanderRow * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, PROTON_PLUS_WIDGETS_GAMES_LAUNCH_OPTIONS_EDITOR_TYPE_CUSTOM_EXPANDER_ROW, ProtonPlusWidgetsGamesLaunchOptionsEditorCustomExpanderRow);
	self->options_display = (_vala_array_free (self->options_display, self->options_display_length1, (GDestroyNotify) g_free), NULL);
	self->options_values = (_vala_array_free (self->options_values, self->options_values_length1, (GDestroyNotify) g_free), NULL);
	_g_hash_table_unref0 (self->item_tooltips);
	_g_hash_table_unref0 (self->rows_map);
	_g_object_unref0 (self->row_order);
	_g_object_unref0 (self->priv->predefined_keys);
	_g_object_unref0 (self->priv->add_custom_row);
	_g_object_unref0 (self->priv->key_controller);
	G_OBJECT_CLASS (proton_plus_widgets_games_launch_options_editor_custom_expander_row_parent_class)->finalize (obj);
}

static GType
proton_plus_widgets_games_launch_options_editor_custom_expander_row_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (ProtonPlusWidgetsGamesLaunchOptionsEditorCustomExpanderRowClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) proton_plus_widgets_games_launch_options_editor_custom_expander_row_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ProtonPlusWidgetsGamesLaunchOptionsEditorCustomExpanderRow), 0, (GInstanceInitFunc) proton_plus_widgets_games_launch_options_editor_custom_expander_row_instance_init, NULL };
	GType proton_plus_widgets_games_launch_options_editor_custom_expander_row_type_id;
	proton_plus_widgets_games_launch_options_editor_custom_expander_row_type_id = g_type_register_static (adw_expander_row_get_type (), "ProtonPlusWidgetsGamesLaunchOptionsEditorCustomExpanderRow", &g_define_type_info, 0);
	ProtonPlusWidgetsGamesLaunchOptionsEditorCustomExpanderRow_private_offset = g_type_add_instance_private (proton_plus_widgets_games_launch_options_editor_custom_expander_row_type_id, sizeof (ProtonPlusWidgetsGamesLaunchOptionsEditorCustomExpanderRowPrivate));
	return proton_plus_widgets_games_launch_options_editor_custom_expander_row_type_id;
}

GType
proton_plus_widgets_games_launch_options_editor_custom_expander_row_get_type (void)
{
	static volatile gsize proton_plus_widgets_games_launch_options_editor_custom_expander_row_type_id__once = 0;
	if (g_once_init_enter (&proton_plus_widgets_games_launch_options_editor_custom_expander_row_type_id__once)) {
		GType proton_plus_widgets_games_launch_options_editor_custom_expander_row_type_id;
		proton_plus_widgets_games_launch_options_editor_custom_expander_row_type_id = proton_plus_widgets_games_launch_options_editor_custom_expander_row_get_type_once ();
		g_once_init_leave (&proton_plus_widgets_games_launch_options_editor_custom_expander_row_type_id__once, proton_plus_widgets_games_launch_options_editor_custom_expander_row_type_id);
	}
	return proton_plus_widgets_games_launch_options_editor_custom_expander_row_type_id__once;
}

static void
_vala_proton_plus_widgets_games_launch_options_editor_custom_expander_row_get_property (GObject * object,
                                                                                        guint property_id,
                                                                                        GValue * value,
                                                                                        GParamSpec * pspec)
{
	ProtonPlusWidgetsGamesLaunchOptionsEditorCustomExpanderRow * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, PROTON_PLUS_WIDGETS_GAMES_LAUNCH_OPTIONS_EDITOR_TYPE_CUSTOM_EXPANDER_ROW, ProtonPlusWidgetsGamesLaunchOptionsEditorCustomExpanderRow);
	switch (property_id) {
		case PROTON_PLUS_WIDGETS_GAMES_LAUNCH_OPTIONS_EDITOR_CUSTOM_EXPANDER_ROW_IS_ADVANCED_PROPERTY:
		g_value_set_boolean (value, proton_plus_widgets_games_launch_options_editor_custom_expander_row_get_is_advanced (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_proton_plus_widgets_games_launch_options_editor_custom_expander_row_set_property (GObject * object,
                                                                                        guint property_id,
                                                                                        const GValue * value,
                                                                                        GParamSpec * pspec)
{
	ProtonPlusWidgetsGamesLaunchOptionsEditorCustomExpanderRow * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, PROTON_PLUS_WIDGETS_GAMES_LAUNCH_OPTIONS_EDITOR_TYPE_CUSTOM_EXPANDER_ROW, ProtonPlusWidgetsGamesLaunchOptionsEditorCustomExpanderRow);
	switch (property_id) {
		case PROTON_PLUS_WIDGETS_GAMES_LAUNCH_OPTIONS_EDITOR_CUSTOM_EXPANDER_ROW_IS_ADVANCED_PROPERTY:
		proton_plus_widgets_games_launch_options_editor_custom_expander_row_set_is_advanced (self, g_value_get_boolean (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);
}

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;
}

