/* preferences-tool-row.c generated by valac 0.56.19, the Vala compiler
 * generated from preferences-tool-row.vala, do not modify */

#include "protonplus_core.h"
#include <gtk/gtk.h>
#include <glib.h>
#include <glib-object.h>
#include <gio/gio.h>
#include <stdlib.h>
#include <string.h>
#include <adwaita.h>
#include <glib/gi18n-lib.h>
#include <pango/pango.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_PREFERENCES_TOOL_ROW_0_PROPERTY,
	PROTON_PLUS_WIDGETS_PREFERENCES_TOOL_ROW_NUM_PROPERTIES
};
static GParamSpec* proton_plus_widgets_preferences_tool_row_properties[PROTON_PLUS_WIDGETS_PREFERENCES_TOOL_ROW_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_hash_table_unref0(var) ((var == NULL) ? NULL : (var = (g_hash_table_unref (var), NULL)))
typedef struct _Block6Data Block6Data;

struct _ProtonPlusWidgetsPreferencesToolRowPrivate {
	GtkSignalListItemFactory* compatibility_tool_factory;
	GHashTable* hast_table;
};

struct _Block6Data {
	int _ref_count_;
	ProtonPlusWidgetsPreferencesToolRow* self;
	ProtonPlusModelsCompatibilityTool* compatibility_tool;
};

static gint ProtonPlusWidgetsPreferencesToolRow_private_offset;
static gpointer proton_plus_widgets_preferences_tool_row_parent_class = NULL;

static gboolean __lambda32_ (ProtonPlusModelsCompatibilityTool* a,
                      ProtonPlusModelsCompatibilityTool* b);
static gboolean ___lambda32__gequal_func (gconstpointer a,
                                   gconstpointer b);
static void _g_object_unref0_ (gpointer var);
static void proton_plus_widgets_preferences_tool_row_compatibility_tool_factory_setup (ProtonPlusWidgetsPreferencesToolRow* self,
                                                                                GObject* object);
static void _proton_plus_widgets_preferences_tool_row_compatibility_tool_factory_setup_gtk_signal_list_item_factory_setup (GtkSignalListItemFactory* _sender,
                                                                                                                    GObject* object,
                                                                                                                    gpointer self);
static void proton_plus_widgets_preferences_tool_row_compatibility_tool_factory_bind (ProtonPlusWidgetsPreferencesToolRow* self,
                                                                               GObject* object);
static void _proton_plus_widgets_preferences_tool_row_compatibility_tool_factory_bind_gtk_signal_list_item_factory_bind (GtkSignalListItemFactory* _sender,
                                                                                                                  GObject* object,
                                                                                                                  gpointer self);
static void proton_plus_widgets_preferences_tool_row_compatibility_tool_factory_unbind (ProtonPlusWidgetsPreferencesToolRow* self,
                                                                                 GObject* object);
static void _proton_plus_widgets_preferences_tool_row_compatibility_tool_factory_unbind_gtk_signal_list_item_factory_unbind (GtkSignalListItemFactory* _sender,
                                                                                                                      GObject* object,
                                                                                                                      gpointer self);
static void proton_plus_widgets_preferences_tool_row_compatibility_tool_row_selected_item_changed (ProtonPlusWidgetsPreferencesToolRow* self);
static void _proton_plus_widgets_preferences_tool_row_compatibility_tool_row_selected_item_changed_g_object_notify (GObject* _sender,
                                                                                                             GParamSpec* pspec,
                                                                                                             gpointer self);
static Block6Data* block6_data_ref (Block6Data* _data6_);
static void block6_data_unref (void * _userdata_);
static void __lambda33_ (Block6Data* _data6_,
                  ProtonPlusModelsCompatibilityTool* tool,
                  GtkListItem* list_item);
static void ___lambda33__gh_func (gconstpointer key,
                           gconstpointer value,
                           gpointer self);
static void proton_plus_widgets_preferences_tool_row_finalize (GObject * obj);
static GType proton_plus_widgets_preferences_tool_row_get_type_once (void);

static inline gpointer
proton_plus_widgets_preferences_tool_row_get_instance_private (ProtonPlusWidgetsPreferencesToolRow* self)
{
	return G_STRUCT_MEMBER_P (self, ProtonPlusWidgetsPreferencesToolRow_private_offset);
}

static gboolean
__lambda32_ (ProtonPlusModelsCompatibilityTool* a,
             ProtonPlusModelsCompatibilityTool* b)
{
	const gchar* _tmp0_;
	const gchar* _tmp1_;
	const gchar* _tmp2_;
	const gchar* _tmp3_;
	gboolean result;
	g_return_val_if_fail (a != NULL, FALSE);
	g_return_val_if_fail (b != NULL, FALSE);
	_tmp0_ = proton_plus_models_compatibility_tool_get_internal_title (a);
	_tmp1_ = _tmp0_;
	_tmp2_ = proton_plus_models_compatibility_tool_get_internal_title (b);
	_tmp3_ = _tmp2_;
	result = g_strcmp0 (_tmp1_, _tmp3_) == 0;
	return result;
}

static gboolean
___lambda32__gequal_func (gconstpointer a,
                          gconstpointer b)
{
	gboolean result;
	result = __lambda32_ ((ProtonPlusModelsCompatibilityTool*) a, (ProtonPlusModelsCompatibilityTool*) b);
	return result;
}

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

static void
_proton_plus_widgets_preferences_tool_row_compatibility_tool_factory_setup_gtk_signal_list_item_factory_setup (GtkSignalListItemFactory* _sender,
                                                                                                               GObject* object,
                                                                                                               gpointer self)
{
	proton_plus_widgets_preferences_tool_row_compatibility_tool_factory_setup ((ProtonPlusWidgetsPreferencesToolRow*) self, object);
}

static void
_proton_plus_widgets_preferences_tool_row_compatibility_tool_factory_bind_gtk_signal_list_item_factory_bind (GtkSignalListItemFactory* _sender,
                                                                                                             GObject* object,
                                                                                                             gpointer self)
{
	proton_plus_widgets_preferences_tool_row_compatibility_tool_factory_bind ((ProtonPlusWidgetsPreferencesToolRow*) self, object);
}

static void
_proton_plus_widgets_preferences_tool_row_compatibility_tool_factory_unbind_gtk_signal_list_item_factory_unbind (GtkSignalListItemFactory* _sender,
                                                                                                                 GObject* object,
                                                                                                                 gpointer self)
{
	proton_plus_widgets_preferences_tool_row_compatibility_tool_factory_unbind ((ProtonPlusWidgetsPreferencesToolRow*) self, object);
}

static void
_proton_plus_widgets_preferences_tool_row_compatibility_tool_row_selected_item_changed_g_object_notify (GObject* _sender,
                                                                                                        GParamSpec* pspec,
                                                                                                        gpointer self)
{
	proton_plus_widgets_preferences_tool_row_compatibility_tool_row_selected_item_changed ((ProtonPlusWidgetsPreferencesToolRow*) self);
}

ProtonPlusWidgetsPreferencesToolRow*
proton_plus_widgets_preferences_tool_row_construct (GType object_type,
                                                    GListStore* model,
                                                    GtkPropertyExpression* expression)
{
	ProtonPlusWidgetsPreferencesToolRow * self = NULL;
	GHashTable* _tmp0_;
	GtkSignalListItemFactory* _tmp1_;
	GtkSignalListItemFactory* _tmp2_;
	GtkSignalListItemFactory* _tmp3_;
	GtkSignalListItemFactory* _tmp4_;
	GtkSignalListItemFactory* _tmp5_;
	g_return_val_if_fail (model != NULL, NULL);
	g_return_val_if_fail (expression != NULL, NULL);
	self = (ProtonPlusWidgetsPreferencesToolRow*) g_object_new (object_type, NULL);
	_tmp0_ = g_hash_table_new_full (NULL, ___lambda32__gequal_func, _g_object_unref0_, _g_object_unref0_);
	_g_hash_table_unref0 (self->priv->hast_table);
	self->priv->hast_table = _tmp0_;
	_tmp1_ = (GtkSignalListItemFactory*) gtk_signal_list_item_factory_new ();
	_g_object_unref0 (self->priv->compatibility_tool_factory);
	self->priv->compatibility_tool_factory = _tmp1_;
	_tmp2_ = self->priv->compatibility_tool_factory;
	g_signal_connect_object (_tmp2_, "setup", (GCallback) _proton_plus_widgets_preferences_tool_row_compatibility_tool_factory_setup_gtk_signal_list_item_factory_setup, self, 0);
	_tmp3_ = self->priv->compatibility_tool_factory;
	g_signal_connect_object (_tmp3_, "bind", (GCallback) _proton_plus_widgets_preferences_tool_row_compatibility_tool_factory_bind_gtk_signal_list_item_factory_bind, self, 0);
	_tmp4_ = self->priv->compatibility_tool_factory;
	g_signal_connect_object (_tmp4_, "unbind", (GCallback) _proton_plus_widgets_preferences_tool_row_compatibility_tool_factory_unbind_gtk_signal_list_item_factory_unbind, self, 0);
	g_signal_connect_object ((GObject*) self, "notify::selected-item", (GCallback) _proton_plus_widgets_preferences_tool_row_compatibility_tool_row_selected_item_changed_g_object_notify, self, 0);
	adw_preferences_row_set_title ((AdwPreferencesRow*) self, _ ("Select your desired compatibility tool"));
	adw_combo_row_set_model ((AdwComboRow*) self, (GListModel*) model);
	adw_combo_row_set_expression ((AdwComboRow*) self, (GtkExpression*) expression);
	_tmp5_ = self->priv->compatibility_tool_factory;
	adw_combo_row_set_list_factory ((AdwComboRow*) self, (GtkListItemFactory*) _tmp5_);
	return self;
}

ProtonPlusWidgetsPreferencesToolRow*
proton_plus_widgets_preferences_tool_row_new (GListStore* model,
                                              GtkPropertyExpression* expression)
{
	return proton_plus_widgets_preferences_tool_row_construct (PROTON_PLUS_WIDGETS_PREFERENCES_TYPE_TOOL_ROW, model, expression);
}

static Block6Data*
block6_data_ref (Block6Data* _data6_)
{
	g_atomic_int_inc (&_data6_->_ref_count_);
	return _data6_;
}

static void
block6_data_unref (void * _userdata_)
{
	Block6Data* _data6_;
	_data6_ = (Block6Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data6_->_ref_count_)) {
		ProtonPlusWidgetsPreferencesToolRow* self;
		self = _data6_->self;
		_g_object_unref0 (_data6_->compatibility_tool);
		_g_object_unref0 (self);
		g_slice_free (Block6Data, _data6_);
	}
}

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

static void
__lambda33_ (Block6Data* _data6_,
             ProtonPlusModelsCompatibilityTool* tool,
             GtkListItem* list_item)
{
	ProtonPlusWidgetsPreferencesToolRow* self;
	gconstpointer _tmp0_;
	ProtonPlusModelsCompatibilityTool* _tmp1_;
	self = _data6_->self;
	g_return_if_fail (tool != NULL);
	g_return_if_fail (list_item != NULL);
	_tmp0_ = g_object_get_data ((GObject*) list_item, "check");
	_tmp1_ = _data6_->compatibility_tool;
	gtk_widget_set_visible ((GtkWidget*) ((GtkImage*) _tmp0_), tool == _tmp1_);
}

static void
___lambda33__gh_func (gconstpointer key,
                      gconstpointer value,
                      gpointer self)
{
	__lambda33_ (self, (ProtonPlusModelsCompatibilityTool*) key, (GtkListItem*) value);
}

static void
proton_plus_widgets_preferences_tool_row_compatibility_tool_row_selected_item_changed (ProtonPlusWidgetsPreferencesToolRow* self)
{
	Block6Data* _data6_;
	GObject* _tmp0_;
	ProtonPlusModelsCompatibilityTool* _tmp1_;
	ProtonPlusModelsCompatibilityTool* _tmp2_;
	ProtonPlusModelsCompatibilityTool* _tmp3_;
	const gchar* _tmp4_;
	const gchar* _tmp5_;
	GHashTable* _tmp6_;
	g_return_if_fail (self != NULL);
	_data6_ = g_slice_new0 (Block6Data);
	_data6_->_ref_count_ = 1;
	_data6_->self = g_object_ref (self);
	_tmp0_ = adw_combo_row_get_selected_item ((AdwComboRow*) self);
	_tmp1_ = _g_object_ref0 (PROTON_PLUS_MODELS_IS_COMPATIBILITY_TOOL (_tmp0_) ? ((ProtonPlusModelsCompatibilityTool*) _tmp0_) : NULL);
	_data6_->compatibility_tool = _tmp1_;
	_tmp2_ = _data6_->compatibility_tool;
	if (_tmp2_ == NULL) {
		block6_data_unref (_data6_);
		_data6_ = NULL;
		return;
	}
	_tmp3_ = _data6_->compatibility_tool;
	_tmp4_ = proton_plus_models_compatibility_tool_get_display_title (_tmp3_);
	_tmp5_ = _tmp4_;
	gtk_widget_set_tooltip_text ((GtkWidget*) self, _tmp5_);
	_tmp6_ = self->priv->hast_table;
	g_hash_table_foreach (_tmp6_, ___lambda33__gh_func, _data6_);
	block6_data_unref (_data6_);
	_data6_ = NULL;
}

static void
proton_plus_widgets_preferences_tool_row_compatibility_tool_factory_bind (ProtonPlusWidgetsPreferencesToolRow* self,
                                                                          GObject* object)
{
	GtkListItem* list_item = NULL;
	GtkListItem* _tmp0_;
	ProtonPlusModelsCompatibilityTool* compatibility_tool = NULL;
	GObject* _tmp1_;
	ProtonPlusModelsCompatibilityTool* _tmp2_;
	GHashTable* _tmp3_;
	ProtonPlusModelsCompatibilityTool* _tmp4_;
	GtkListItem* _tmp5_;
	gconstpointer _tmp6_;
	const gchar* _tmp7_;
	const gchar* _tmp8_;
	gconstpointer _tmp9_;
	GObject* _tmp10_;
	gconstpointer _tmp11_;
	const gchar* _tmp12_;
	const gchar* _tmp13_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (object != NULL);
	_tmp0_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (object, gtk_list_item_get_type ()) ? ((GtkListItem*) object) : NULL);
	list_item = _tmp0_;
	_tmp1_ = gtk_list_item_get_item (list_item);
	_tmp2_ = _g_object_ref0 (PROTON_PLUS_MODELS_IS_COMPATIBILITY_TOOL (_tmp1_) ? ((ProtonPlusModelsCompatibilityTool*) _tmp1_) : NULL);
	compatibility_tool = _tmp2_;
	_tmp3_ = self->priv->hast_table;
	_tmp4_ = _g_object_ref0 (compatibility_tool);
	_tmp5_ = _g_object_ref0 (list_item);
	g_hash_table_insert (_tmp3_, _tmp4_, _tmp5_);
	_tmp6_ = g_object_get_data (object, "title");
	_tmp7_ = proton_plus_models_compatibility_tool_get_display_title (compatibility_tool);
	_tmp8_ = _tmp7_;
	gtk_label_set_label ((GtkLabel*) _tmp6_, _tmp8_);
	_tmp9_ = g_object_get_data (object, "check");
	_tmp10_ = adw_combo_row_get_selected_item ((AdwComboRow*) self);
	gtk_widget_set_visible ((GtkWidget*) ((GtkImage*) _tmp9_), G_TYPE_CHECK_INSTANCE_CAST (compatibility_tool, G_TYPE_OBJECT, GObject) == _tmp10_);
	_tmp11_ = g_object_get_data (object, "box");
	_tmp12_ = proton_plus_models_compatibility_tool_get_display_title (compatibility_tool);
	_tmp13_ = _tmp12_;
	gtk_widget_set_tooltip_text ((GtkWidget*) ((GtkBox*) _tmp11_), _tmp13_);
	_g_object_unref0 (compatibility_tool);
	_g_object_unref0 (list_item);
}

static void
proton_plus_widgets_preferences_tool_row_compatibility_tool_factory_unbind (ProtonPlusWidgetsPreferencesToolRow* self,
                                                                            GObject* object)
{
	GtkListItem* list_item = NULL;
	GtkListItem* _tmp0_;
	ProtonPlusModelsCompatibilityTool* compatibility_tool = NULL;
	GtkListItem* _tmp1_;
	GObject* _tmp2_;
	ProtonPlusModelsCompatibilityTool* _tmp3_;
	GHashTable* _tmp4_;
	ProtonPlusModelsCompatibilityTool* _tmp5_;
	gconstpointer _tmp6_;
	GtkListItem* _tmp7_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (object != NULL);
	_tmp0_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (object, gtk_list_item_get_type ()) ? ((GtkListItem*) object) : NULL);
	list_item = _tmp0_;
	_tmp1_ = list_item;
	_tmp2_ = gtk_list_item_get_item (_tmp1_);
	_tmp3_ = _g_object_ref0 (PROTON_PLUS_MODELS_IS_COMPATIBILITY_TOOL (_tmp2_) ? ((ProtonPlusModelsCompatibilityTool*) _tmp2_) : NULL);
	compatibility_tool = _tmp3_;
	_tmp4_ = self->priv->hast_table;
	_tmp5_ = compatibility_tool;
	_tmp6_ = g_hash_table_lookup (_tmp4_, _tmp5_);
	_tmp7_ = list_item;
	if (((GtkListItem*) _tmp6_) == _tmp7_) {
		GHashTable* _tmp8_;
		ProtonPlusModelsCompatibilityTool* _tmp9_;
		_tmp8_ = self->priv->hast_table;
		_tmp9_ = compatibility_tool;
		g_hash_table_remove (_tmp8_, _tmp9_);
	}
	_g_object_unref0 (compatibility_tool);
	_g_object_unref0 (list_item);
}

static void
proton_plus_widgets_preferences_tool_row_compatibility_tool_factory_setup (ProtonPlusWidgetsPreferencesToolRow* self,
                                                                           GObject* object)
{
	GtkListItem* list_item = NULL;
	GtkListItem* _tmp0_;
	GtkLabel* title_label = NULL;
	GtkLabel* _tmp1_;
	GtkImage* check_image = NULL;
	GtkImage* _tmp2_;
	GtkBox* box = NULL;
	GtkBox* _tmp3_;
	GtkLabel* _tmp4_;
	GtkImage* _tmp5_;
	GtkBox* _tmp6_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (object != NULL);
	_tmp0_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (object, gtk_list_item_get_type ()) ? ((GtkListItem*) object) : NULL);
	list_item = _tmp0_;
	_tmp1_ = (GtkLabel*) gtk_label_new (NULL);
	g_object_ref_sink (_tmp1_);
	title_label = _tmp1_;
	gtk_label_set_xalign (title_label, 0.0f);
	gtk_label_set_max_width_chars (title_label, 30);
	gtk_label_set_ellipsize (title_label, PANGO_ELLIPSIZE_END);
	gtk_widget_set_hexpand ((GtkWidget*) title_label, TRUE);
	_tmp2_ = (GtkImage*) gtk_image_new_from_icon_name ("object-select-symbolic");
	g_object_ref_sink (_tmp2_);
	check_image = _tmp2_;
	gtk_widget_set_visible ((GtkWidget*) check_image, FALSE);
	_tmp3_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
	g_object_ref_sink (_tmp3_);
	box = _tmp3_;
	gtk_box_append (box, (GtkWidget*) title_label);
	gtk_box_append (box, (GtkWidget*) check_image);
	_tmp4_ = _g_object_ref0 (title_label);
	g_object_set_data_full (object, "title", _tmp4_, g_object_unref);
	_tmp5_ = _g_object_ref0 (check_image);
	g_object_set_data_full (object, "check", _tmp5_, g_object_unref);
	_tmp6_ = _g_object_ref0 (box);
	g_object_set_data_full (object, "box", _tmp6_, g_object_unref);
	gtk_list_item_set_child (list_item, (GtkWidget*) box);
	_g_object_unref0 (box);
	_g_object_unref0 (check_image);
	_g_object_unref0 (title_label);
	_g_object_unref0 (list_item);
}

static void
proton_plus_widgets_preferences_tool_row_class_init (ProtonPlusWidgetsPreferencesToolRowClass * klass,
                                                     gpointer klass_data)
{
	proton_plus_widgets_preferences_tool_row_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &ProtonPlusWidgetsPreferencesToolRow_private_offset);
	G_OBJECT_CLASS (klass)->finalize = proton_plus_widgets_preferences_tool_row_finalize;
}

static void
proton_plus_widgets_preferences_tool_row_instance_init (ProtonPlusWidgetsPreferencesToolRow * self,
                                                        gpointer klass)
{
	self->priv = proton_plus_widgets_preferences_tool_row_get_instance_private (self);
}

static void
proton_plus_widgets_preferences_tool_row_finalize (GObject * obj)
{
	ProtonPlusWidgetsPreferencesToolRow * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, PROTON_PLUS_WIDGETS_PREFERENCES_TYPE_TOOL_ROW, ProtonPlusWidgetsPreferencesToolRow);
	_g_object_unref0 (self->priv->compatibility_tool_factory);
	_g_hash_table_unref0 (self->priv->hast_table);
	G_OBJECT_CLASS (proton_plus_widgets_preferences_tool_row_parent_class)->finalize (obj);
}

static GType
proton_plus_widgets_preferences_tool_row_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (ProtonPlusWidgetsPreferencesToolRowClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) proton_plus_widgets_preferences_tool_row_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ProtonPlusWidgetsPreferencesToolRow), 0, (GInstanceInitFunc) proton_plus_widgets_preferences_tool_row_instance_init, NULL };
	GType proton_plus_widgets_preferences_tool_row_type_id;
	proton_plus_widgets_preferences_tool_row_type_id = g_type_register_static (adw_combo_row_get_type (), "ProtonPlusWidgetsPreferencesToolRow", &g_define_type_info, 0);
	ProtonPlusWidgetsPreferencesToolRow_private_offset = g_type_add_instance_private (proton_plus_widgets_preferences_tool_row_type_id, sizeof (ProtonPlusWidgetsPreferencesToolRowPrivate));
	return proton_plus_widgets_preferences_tool_row_type_id;
}

GType
proton_plus_widgets_preferences_tool_row_get_type (void)
{
	static volatile gsize proton_plus_widgets_preferences_tool_row_type_id__once = 0;
	if (g_once_init_enter (&proton_plus_widgets_preferences_tool_row_type_id__once)) {
		GType proton_plus_widgets_preferences_tool_row_type_id;
		proton_plus_widgets_preferences_tool_row_type_id = proton_plus_widgets_preferences_tool_row_get_type_once ();
		g_once_init_leave (&proton_plus_widgets_preferences_tool_row_type_id__once, proton_plus_widgets_preferences_tool_row_type_id);
	}
	return proton_plus_widgets_preferences_tool_row_type_id__once;
}

