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

#include "protonplus_core.h"
#include <gtk/gtk.h>
#include <glib-object.h>
#include <gio/gio.h>
#include <glib.h>
#include <adwaita.h>
#include <pango/pango.h>
#include <stdlib.h>
#include <string.h>
#include <glib/gstdio.h>
#include <gdk/gdk.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_STEAM_PROFILE_ROW_0_PROPERTY,
	PROTON_PLUS_WIDGETS_PREFERENCES_STEAM_PROFILE_ROW_NUM_PROPERTIES
};
static GParamSpec* proton_plus_widgets_preferences_steam_profile_row_properties[PROTON_PLUS_WIDGETS_PREFERENCES_STEAM_PROFILE_ROW_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _gtk_expression_unref0(var) ((var == NULL) ? NULL : (var = (gtk_expression_unref (var), NULL)))

struct _ProtonPlusWidgetsPreferencesSteamProfileRowPrivate {
	GtkSignalListItemFactory* profile_factory;
};

static gint ProtonPlusWidgetsPreferencesSteamProfileRow_private_offset;
static gpointer proton_plus_widgets_preferences_steam_profile_row_parent_class = NULL;

static void proton_plus_widgets_preferences_steam_profile_row_profile_factory_setup (ProtonPlusWidgetsPreferencesSteamProfileRow* self,
                                                                              GObject* object);
static void _proton_plus_widgets_preferences_steam_profile_row_profile_factory_setup_gtk_signal_list_item_factory_setup (GtkSignalListItemFactory* _sender,
                                                                                                                  GObject* object,
                                                                                                                  gpointer self);
static void proton_plus_widgets_preferences_steam_profile_row_profile_factory_bind (ProtonPlusWidgetsPreferencesSteamProfileRow* self,
                                                                             GObject* object);
static void _proton_plus_widgets_preferences_steam_profile_row_profile_factory_bind_gtk_signal_list_item_factory_bind (GtkSignalListItemFactory* _sender,
                                                                                                                GObject* object,
                                                                                                                gpointer self);
static void proton_plus_widgets_preferences_steam_profile_row_finalize (GObject * obj);
static GType proton_plus_widgets_preferences_steam_profile_row_get_type_once (void);

static inline gpointer
proton_plus_widgets_preferences_steam_profile_row_get_instance_private (ProtonPlusWidgetsPreferencesSteamProfileRow* self)
{
	return G_STRUCT_MEMBER_P (self, ProtonPlusWidgetsPreferencesSteamProfileRow_private_offset);
}

static void
_proton_plus_widgets_preferences_steam_profile_row_profile_factory_setup_gtk_signal_list_item_factory_setup (GtkSignalListItemFactory* _sender,
                                                                                                             GObject* object,
                                                                                                             gpointer self)
{
	proton_plus_widgets_preferences_steam_profile_row_profile_factory_setup ((ProtonPlusWidgetsPreferencesSteamProfileRow*) self, object);
}

static void
_proton_plus_widgets_preferences_steam_profile_row_profile_factory_bind_gtk_signal_list_item_factory_bind (GtkSignalListItemFactory* _sender,
                                                                                                           GObject* object,
                                                                                                           gpointer self)
{
	proton_plus_widgets_preferences_steam_profile_row_profile_factory_bind ((ProtonPlusWidgetsPreferencesSteamProfileRow*) self, object);
}

ProtonPlusWidgetsPreferencesSteamProfileRow*
proton_plus_widgets_preferences_steam_profile_row_construct (GType object_type,
                                                             GListStore* model)
{
	ProtonPlusWidgetsPreferencesSteamProfileRow * self = NULL;
	GtkSignalListItemFactory* _tmp0_;
	GtkSignalListItemFactory* _tmp1_;
	GtkSignalListItemFactory* _tmp2_;
	GtkPropertyExpression* _tmp3_;
	GtkPropertyExpression* _tmp4_;
	GtkSignalListItemFactory* _tmp5_;
	g_return_val_if_fail (model != NULL, NULL);
	self = (ProtonPlusWidgetsPreferencesSteamProfileRow*) g_object_new (object_type, NULL);
	_tmp0_ = (GtkSignalListItemFactory*) gtk_signal_list_item_factory_new ();
	_g_object_unref0 (self->priv->profile_factory);
	self->priv->profile_factory = _tmp0_;
	_tmp1_ = self->priv->profile_factory;
	g_signal_connect_object (_tmp1_, "setup", (GCallback) _proton_plus_widgets_preferences_steam_profile_row_profile_factory_setup_gtk_signal_list_item_factory_setup, self, 0);
	_tmp2_ = self->priv->profile_factory;
	g_signal_connect_object (_tmp2_, "bind", (GCallback) _proton_plus_widgets_preferences_steam_profile_row_profile_factory_bind_gtk_signal_list_item_factory_bind, self, 0);
	adw_combo_row_set_model ((AdwComboRow*) self, (GListModel*) model);
	_tmp3_ = (GtkPropertyExpression*) gtk_property_expression_new (PROTON_PLUS_MODELS_TYPE_STEAM_PROFILE, NULL, "username");
	_tmp4_ = _tmp3_;
	adw_combo_row_set_expression ((AdwComboRow*) self, (GtkExpression*) _tmp4_);
	_gtk_expression_unref0 (_tmp4_);
	_tmp5_ = self->priv->profile_factory;
	adw_combo_row_set_list_factory ((AdwComboRow*) self, (GtkListItemFactory*) _tmp5_);
	return self;
}

ProtonPlusWidgetsPreferencesSteamProfileRow*
proton_plus_widgets_preferences_steam_profile_row_new (GListStore* model)
{
	return proton_plus_widgets_preferences_steam_profile_row_construct (PROTON_PLUS_WIDGETS_PREFERENCES_TYPE_STEAM_PROFILE_ROW, model);
}

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

static void
proton_plus_widgets_preferences_steam_profile_row_profile_factory_setup (ProtonPlusWidgetsPreferencesSteamProfileRow* self,
                                                                         GObject* object)
{
	GtkListItem* list_item = NULL;
	GtkListItem* _tmp0_;
	AdwAvatar* avatar = NULL;
	AdwAvatar* _tmp1_;
	GtkLabel* username_label = NULL;
	GtkLabel* _tmp2_ = NULL;
	GtkLabel* steam_id_label = NULL;
	GtkLabel* _tmp3_ = NULL;
	GtkBox* labels = NULL;
	GtkBox* _tmp4_ = NULL;
	GtkBox* box = NULL;
	GtkBox* _tmp5_ = NULL;
	AdwAvatar* _tmp6_;
	GtkLabel* _tmp7_;
	GtkLabel* _tmp8_;
	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_ = (AdwAvatar*) adw_avatar_new (36, NULL, TRUE);
	g_object_ref_sink (_tmp1_);
	avatar = _tmp1_;
	_tmp2_ = (GtkLabel*) gtk_label_new (NULL);
	gtk_label_set_xalign (_tmp2_, 0.0f);
	gtk_label_set_ellipsize (_tmp2_, PANGO_ELLIPSIZE_END);
	gtk_widget_set_hexpand ((GtkWidget*) _tmp2_, TRUE);
	g_object_ref_sink (_tmp2_);
	username_label = _tmp2_;
	_tmp3_ = (GtkLabel*) gtk_label_new (NULL);
	gtk_label_set_xalign (_tmp3_, 0.0f);
	gtk_label_set_ellipsize (_tmp3_, PANGO_ELLIPSIZE_END);
	g_object_ref_sink (_tmp3_);
	steam_id_label = _tmp3_;
	gtk_widget_add_css_class ((GtkWidget*) steam_id_label, "dim-label");
	gtk_widget_add_css_class ((GtkWidget*) steam_id_label, "caption");
	_tmp4_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_VERTICAL, 2);
	gtk_widget_set_valign ((GtkWidget*) _tmp4_, GTK_ALIGN_CENTER);
	g_object_ref_sink (_tmp4_);
	labels = _tmp4_;
	gtk_box_append (labels, (GtkWidget*) username_label);
	gtk_box_append (labels, (GtkWidget*) steam_id_label);
	_tmp5_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 12);
	gtk_widget_set_margin_top ((GtkWidget*) _tmp5_, 6);
	gtk_widget_set_margin_bottom ((GtkWidget*) _tmp5_, 6);
	gtk_widget_set_margin_start ((GtkWidget*) _tmp5_, 6);
	gtk_widget_set_margin_end ((GtkWidget*) _tmp5_, 6);
	g_object_ref_sink (_tmp5_);
	box = _tmp5_;
	gtk_box_append (box, (GtkWidget*) avatar);
	gtk_box_append (box, (GtkWidget*) labels);
	_tmp6_ = _g_object_ref0 (avatar);
	g_object_set_data_full (object, "avatar", _tmp6_, g_object_unref);
	_tmp7_ = _g_object_ref0 (username_label);
	g_object_set_data_full (object, "username", _tmp7_, g_object_unref);
	_tmp8_ = _g_object_ref0 (steam_id_label);
	g_object_set_data_full (object, "steam-id", _tmp8_, g_object_unref);
	gtk_list_item_set_child (list_item, (GtkWidget*) box);
	_g_object_unref0 (box);
	_g_object_unref0 (labels);
	_g_object_unref0 (steam_id_label);
	_g_object_unref0 (username_label);
	_g_object_unref0 (avatar);
	_g_object_unref0 (list_item);
}

static void
proton_plus_widgets_preferences_steam_profile_row_profile_factory_bind (ProtonPlusWidgetsPreferencesSteamProfileRow* self,
                                                                        GObject* object)
{
	GtkListItem* list_item = NULL;
	GtkListItem* _tmp0_;
	ProtonPlusModelsSteamProfile* profile = NULL;
	GtkListItem* _tmp1_;
	GObject* _tmp2_;
	ProtonPlusModelsSteamProfile* _tmp3_;
	ProtonPlusModelsSteamProfile* _tmp4_;
	AdwAvatar* avatar = NULL;
	gconstpointer _tmp5_;
	AdwAvatar* _tmp6_;
	AdwAvatar* _tmp7_;
	ProtonPlusModelsSteamProfile* _tmp8_;
	const gchar* _tmp9_;
	const gchar* _tmp10_;
	AdwAvatar* _tmp11_;
	ProtonPlusModelsSteamProfile* _tmp12_;
	const gchar* _tmp13_;
	const gchar* _tmp14_;
	gconstpointer _tmp22_;
	ProtonPlusModelsSteamProfile* _tmp23_;
	const gchar* _tmp24_;
	const gchar* _tmp25_;
	gconstpointer _tmp26_;
	ProtonPlusModelsSteamProfile* _tmp27_;
	const gchar* _tmp28_;
	const gchar* _tmp29_;
	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_STEAM_PROFILE (_tmp2_) ? ((ProtonPlusModelsSteamProfile*) _tmp2_) : NULL);
	profile = _tmp3_;
	_tmp4_ = profile;
	if (_tmp4_ == NULL) {
		_g_object_unref0 (profile);
		_g_object_unref0 (list_item);
		return;
	}
	_tmp5_ = g_object_get_data (object, "avatar");
	_tmp6_ = _g_object_ref0 ((AdwAvatar*) _tmp5_);
	avatar = _tmp6_;
	_tmp7_ = avatar;
	_tmp8_ = profile;
	_tmp9_ = proton_plus_models_steam_profile_get_username (_tmp8_);
	_tmp10_ = _tmp9_;
	adw_avatar_set_text (_tmp7_, _tmp10_);
	_tmp11_ = avatar;
	adw_avatar_set_custom_image (_tmp11_, NULL);
	_tmp12_ = profile;
	_tmp13_ = proton_plus_models_steam_profile_get_image_path (_tmp12_);
	_tmp14_ = _tmp13_;
	if (g_file_test (_tmp14_, G_FILE_TEST_IS_REGULAR)) {
		GtkImage* profile_image = NULL;
		ProtonPlusModelsSteamProfile* _tmp15_;
		const gchar* _tmp16_;
		const gchar* _tmp17_;
		GtkImage* _tmp18_;
		AdwAvatar* _tmp19_;
		GtkImage* _tmp20_;
		GdkPaintable* _tmp21_;
		_tmp15_ = profile;
		_tmp16_ = proton_plus_models_steam_profile_get_image_path (_tmp15_);
		_tmp17_ = _tmp16_;
		_tmp18_ = (GtkImage*) gtk_image_new_from_file (_tmp17_);
		g_object_ref_sink (_tmp18_);
		profile_image = _tmp18_;
		_tmp19_ = avatar;
		_tmp20_ = profile_image;
		_tmp21_ = gtk_image_get_paintable (_tmp20_);
		adw_avatar_set_custom_image (_tmp19_, _tmp21_);
		_g_object_unref0 (profile_image);
	}
	_tmp22_ = g_object_get_data (object, "username");
	_tmp23_ = profile;
	_tmp24_ = proton_plus_models_steam_profile_get_username (_tmp23_);
	_tmp25_ = _tmp24_;
	gtk_label_set_label ((GtkLabel*) _tmp22_, _tmp25_);
	_tmp26_ = g_object_get_data (object, "steam-id");
	_tmp27_ = profile;
	_tmp28_ = proton_plus_models_steam_profile_get_steam_id (_tmp27_);
	_tmp29_ = _tmp28_;
	gtk_label_set_label ((GtkLabel*) _tmp26_, _tmp29_);
	_g_object_unref0 (avatar);
	_g_object_unref0 (profile);
	_g_object_unref0 (list_item);
}

static void
proton_plus_widgets_preferences_steam_profile_row_class_init (ProtonPlusWidgetsPreferencesSteamProfileRowClass * klass,
                                                              gpointer klass_data)
{
	proton_plus_widgets_preferences_steam_profile_row_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &ProtonPlusWidgetsPreferencesSteamProfileRow_private_offset);
	G_OBJECT_CLASS (klass)->finalize = proton_plus_widgets_preferences_steam_profile_row_finalize;
}

static void
proton_plus_widgets_preferences_steam_profile_row_instance_init (ProtonPlusWidgetsPreferencesSteamProfileRow * self,
                                                                 gpointer klass)
{
	self->priv = proton_plus_widgets_preferences_steam_profile_row_get_instance_private (self);
}

static void
proton_plus_widgets_preferences_steam_profile_row_finalize (GObject * obj)
{
	ProtonPlusWidgetsPreferencesSteamProfileRow * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, PROTON_PLUS_WIDGETS_PREFERENCES_TYPE_STEAM_PROFILE_ROW, ProtonPlusWidgetsPreferencesSteamProfileRow);
	_g_object_unref0 (self->priv->profile_factory);
	G_OBJECT_CLASS (proton_plus_widgets_preferences_steam_profile_row_parent_class)->finalize (obj);
}

static GType
proton_plus_widgets_preferences_steam_profile_row_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (ProtonPlusWidgetsPreferencesSteamProfileRowClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) proton_plus_widgets_preferences_steam_profile_row_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ProtonPlusWidgetsPreferencesSteamProfileRow), 0, (GInstanceInitFunc) proton_plus_widgets_preferences_steam_profile_row_instance_init, NULL };
	GType proton_plus_widgets_preferences_steam_profile_row_type_id;
	proton_plus_widgets_preferences_steam_profile_row_type_id = g_type_register_static (adw_combo_row_get_type (), "ProtonPlusWidgetsPreferencesSteamProfileRow", &g_define_type_info, 0);
	ProtonPlusWidgetsPreferencesSteamProfileRow_private_offset = g_type_add_instance_private (proton_plus_widgets_preferences_steam_profile_row_type_id, sizeof (ProtonPlusWidgetsPreferencesSteamProfileRowPrivate));
	return proton_plus_widgets_preferences_steam_profile_row_type_id;
}

GType
proton_plus_widgets_preferences_steam_profile_row_get_type (void)
{
	static volatile gsize proton_plus_widgets_preferences_steam_profile_row_type_id__once = 0;
	if (g_once_init_enter (&proton_plus_widgets_preferences_steam_profile_row_type_id__once)) {
		GType proton_plus_widgets_preferences_steam_profile_row_type_id;
		proton_plus_widgets_preferences_steam_profile_row_type_id = proton_plus_widgets_preferences_steam_profile_row_get_type_once ();
		g_once_init_leave (&proton_plus_widgets_preferences_steam_profile_row_type_id__once, proton_plus_widgets_preferences_steam_profile_row_type_id);
	}
	return proton_plus_widgets_preferences_steam_profile_row_type_id__once;
}

