/* tools-migrate-box.c generated by valac 0.56.19, the Vala compiler
 * generated from tools-migrate-box.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 <float.h>
#include <math.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_TOOLS_MIGRATE_BOX_0_PROPERTY,
	PROTON_PLUS_WIDGETS_TOOLS_MIGRATE_BOX_MIGRATE_BUTTON_PROPERTY,
	PROTON_PLUS_WIDGETS_TOOLS_MIGRATE_BOX_GAMES_BUTTON_PROPERTY,
	PROTON_PLUS_WIDGETS_TOOLS_MIGRATE_BOX_NUM_PROPERTIES
};
static GParamSpec* proton_plus_widgets_tools_migrate_box_properties[PROTON_PLUS_WIDGETS_TOOLS_MIGRATE_BOX_NUM_PROPERTIES];
#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_TOOLS_MIGRATE_BOX_FINISHED_SIGNAL,
	PROTON_PLUS_WIDGETS_TOOLS_MIGRATE_BOX_NUM_SIGNALS
};
static guint proton_plus_widgets_tools_migrate_box_signals[PROTON_PLUS_WIDGETS_TOOLS_MIGRATE_BOX_NUM_SIGNALS] = {0};

struct _ProtonPlusWidgetsToolsMigrateBoxPrivate {
	GeeArrayList* games;
	gchar* current_tool_name;
	ProtonPlusModelsLauncher* launcher;
	AdwComboRow* combo_row;
	GtkButton* _migrate_button;
	GtkMenuButton* _games_button;
	GeeArrayList* possible_tools_internal;
};

static gint ProtonPlusWidgetsToolsMigrateBox_private_offset;
static gpointer proton_plus_widgets_tools_migrate_box_parent_class = NULL;

static void proton_plus_widgets_tools_migrate_box_set_games_button (ProtonPlusWidgetsToolsMigrateBox* self,
                                                             GtkMenuButton* value);
static void proton_plus_widgets_tools_migrate_box_set_migrate_button (ProtonPlusWidgetsToolsMigrateBox* self,
                                                               GtkButton* value);
static void proton_plus_widgets_tools_migrate_box_on_migrate_clicked (ProtonPlusWidgetsToolsMigrateBox* self);
static void _proton_plus_widgets_tools_migrate_box_on_migrate_clicked_gtk_button_clicked (GtkButton* _sender,
                                                                                   gpointer self);
static void proton_plus_widgets_tools_migrate_box_finalize (GObject * obj);
static GType proton_plus_widgets_tools_migrate_box_get_type_once (void);
static void _vala_proton_plus_widgets_tools_migrate_box_get_property (GObject * object,
                                                               guint property_id,
                                                               GValue * value,
                                                               GParamSpec * pspec);
static void _vala_proton_plus_widgets_tools_migrate_box_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
proton_plus_widgets_tools_migrate_box_get_instance_private (ProtonPlusWidgetsToolsMigrateBox* self)
{
	return G_STRUCT_MEMBER_P (self, ProtonPlusWidgetsToolsMigrateBox_private_offset);
}

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

static void
_proton_plus_widgets_tools_migrate_box_on_migrate_clicked_gtk_button_clicked (GtkButton* _sender,
                                                                              gpointer self)
{
	proton_plus_widgets_tools_migrate_box_on_migrate_clicked ((ProtonPlusWidgetsToolsMigrateBox*) self);
}

ProtonPlusWidgetsToolsMigrateBox*
proton_plus_widgets_tools_migrate_box_construct (GType object_type)
{
	ProtonPlusWidgetsToolsMigrateBox * self = NULL;
	gchar* _tmp0_;
	AdwComboRow* _tmp1_ = NULL;
	AdwPreferencesGroup* group = NULL;
	AdwPreferencesGroup* _tmp2_;
	AdwComboRow* _tmp3_;
	AdwClamp* clamp = NULL;
	GtkWidget* _tmp4_;
	AdwClamp* _tmp5_ = NULL;
	gchar* _tmp6_;
	gchar* _tmp7_;
	gchar** _tmp8_;
	GtkMenuButton* _tmp9_ = NULL;
	GtkMenuButton* _tmp10_;
	AdwStatusPage* status_page = NULL;
	gchar* _tmp11_;
	gchar* _tmp12_;
	gchar* _tmp13_;
	GtkWidget* _tmp14_;
	AdwStatusPage* _tmp15_ = NULL;
	GtkButton* _tmp16_ = NULL;
	GtkButton* _tmp17_;
	GtkButton* _tmp18_;
	GtkButton* _tmp19_;
	self = (ProtonPlusWidgetsToolsMigrateBox*) g_object_new (object_type, "orientation", GTK_ORIENTATION_VERTICAL, "spacing", 0, NULL);
	_tmp0_ = g_strdup (_ ("New tool"));
	_tmp1_ = (AdwComboRow*) adw_combo_row_new ();
	adw_preferences_row_set_title ((AdwPreferencesRow*) _tmp1_, _tmp0_);
	_g_free0 (_tmp0_);
	g_object_ref_sink (_tmp1_);
	_g_object_unref0 (self->priv->combo_row);
	self->priv->combo_row = _tmp1_;
	_tmp2_ = (AdwPreferencesGroup*) adw_preferences_group_new ();
	g_object_ref_sink (_tmp2_);
	group = _tmp2_;
	_tmp3_ = self->priv->combo_row;
	adw_preferences_group_add (group, (GtkWidget*) _tmp3_);
	_tmp4_ = _g_object_ref0 ((GtkWidget*) group);
	_tmp5_ = (AdwClamp*) adw_clamp_new ();
	adw_clamp_set_maximum_size (_tmp5_, 600);
	adw_clamp_set_child (_tmp5_, _tmp4_);
	_g_object_unref0 (_tmp4_);
	g_object_ref_sink (_tmp5_);
	clamp = _tmp5_;
	_tmp6_ = g_strdup ("flat");
	_tmp7_ = g_strdup ("bold");
	_tmp8_ = g_new0 (gchar*, 2 + 1);
	_tmp8_[0] = _tmp6_;
	_tmp8_[1] = _tmp7_;
	_tmp9_ = (GtkMenuButton*) gtk_menu_button_new ();
	gtk_widget_set_halign ((GtkWidget*) _tmp9_, GTK_ALIGN_CENTER);
	gtk_widget_set_valign ((GtkWidget*) _tmp9_, GTK_ALIGN_CENTER);
	gtk_widget_set_css_classes ((GtkWidget*) _tmp9_, _tmp8_);
	_tmp8_ = (_vala_array_free (_tmp8_, 2, (GDestroyNotify) g_free), NULL);
	g_object_ref_sink (_tmp9_);
	_tmp10_ = _tmp9_;
	proton_plus_widgets_tools_migrate_box_set_games_button (self, _tmp10_);
	_g_object_unref0 (_tmp10_);
	_tmp11_ = g_strdup (_ ("Migrate games"));
	_tmp12_ = g_strdup (_ ("Select a new tool for the selected games."));
	_tmp13_ = g_strdup ("right-left-symbolic");
	_tmp14_ = _g_object_ref0 ((GtkWidget*) clamp);
	_tmp15_ = (AdwStatusPage*) adw_status_page_new ();
	adw_status_page_set_title (_tmp15_, _tmp11_);
	_g_free0 (_tmp11_);
	adw_status_page_set_description (_tmp15_, _tmp12_);
	_g_free0 (_tmp12_);
	adw_status_page_set_icon_name (_tmp15_, _tmp13_);
	_g_free0 (_tmp13_);
	gtk_widget_set_vexpand ((GtkWidget*) _tmp15_, TRUE);
	adw_status_page_set_child (_tmp15_, _tmp14_);
	_g_object_unref0 (_tmp14_);
	g_object_ref_sink (_tmp15_);
	status_page = _tmp15_;
	_tmp16_ = (GtkButton*) gtk_button_new_with_label (_ ("Migrate"));
	gtk_widget_set_valign ((GtkWidget*) _tmp16_, GTK_ALIGN_CENTER);
	gtk_widget_set_visible ((GtkWidget*) _tmp16_, FALSE);
	g_object_ref_sink (_tmp16_);
	_tmp17_ = _tmp16_;
	proton_plus_widgets_tools_migrate_box_set_migrate_button (self, _tmp17_);
	_g_object_unref0 (_tmp17_);
	_tmp18_ = self->priv->_migrate_button;
	gtk_widget_add_css_class ((GtkWidget*) _tmp18_, "suggested-action");
	_tmp19_ = self->priv->_migrate_button;
	g_signal_connect_object (_tmp19_, "clicked", (GCallback) _proton_plus_widgets_tools_migrate_box_on_migrate_clicked_gtk_button_clicked, self, 0);
	gtk_box_append ((GtkBox*) self, (GtkWidget*) status_page);
	_g_object_unref0 (status_page);
	_g_object_unref0 (clamp);
	_g_object_unref0 (group);
	return self;
}

ProtonPlusWidgetsToolsMigrateBox*
proton_plus_widgets_tools_migrate_box_new (void)
{
	return proton_plus_widgets_tools_migrate_box_construct (PROTON_PLUS_WIDGETS_TOOLS_TYPE_MIGRATE_BOX);
}

void
proton_plus_widgets_tools_migrate_box_init (ProtonPlusWidgetsToolsMigrateBox* self,
                                            GeeArrayList* games,
                                            const gchar* current_tool_name,
                                            ProtonPlusModelsLauncher* launcher)
{
	GeeArrayList* _tmp0_;
	gchar* _tmp1_;
	ProtonPlusModelsLauncher* _tmp2_;
	GtkMenuButton* _tmp3_;
	gint _tmp4_;
	gint _tmp5_;
	gint _tmp6_;
	gint _tmp7_;
	gchar* _tmp8_;
	gchar* _tmp9_;
	GtkListBox* games_list_box = NULL;
	GtkListBox* _tmp10_;
	GtkListBox* _tmp11_;
	GtkListBox* _tmp12_;
	GtkScrolledWindow* scrolled = NULL;
	GtkListBox* _tmp31_;
	GtkWidget* _tmp32_;
	GtkScrolledWindow* _tmp33_ = NULL;
	GtkPopover* popover = NULL;
	GtkPopover* _tmp34_;
	GtkPopover* _tmp35_;
	GtkScrolledWindow* _tmp36_;
	GtkMenuButton* _tmp37_;
	GtkPopover* _tmp38_;
	GtkPopover* _tmp39_;
	GtkMenuButton* _tmp40_;
	GtkStringList* model = NULL;
	GtkStringList* _tmp41_;
	GeeArrayList* _tmp42_;
	gboolean all_steam_linux_runtime_compatible = FALSE;
	gint _tmp43_;
	gint _tmp44_;
	gboolean _tmp53_ = FALSE;
	AdwComboRow* _tmp89_;
	GtkStringList* _tmp90_;
	GtkButton* _tmp91_;
	GeeArrayList* _tmp92_;
	gint _tmp93_;
	gint _tmp94_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (games != NULL);
	g_return_if_fail (current_tool_name != NULL);
	g_return_if_fail (launcher != NULL);
	_tmp0_ = _g_object_ref0 (games);
	_g_object_unref0 (self->priv->games);
	self->priv->games = _tmp0_;
	_tmp1_ = g_strdup (current_tool_name);
	_g_free0 (self->priv->current_tool_name);
	self->priv->current_tool_name = _tmp1_;
	_tmp2_ = _g_object_ref0 (launcher);
	_g_object_unref0 (self->priv->launcher);
	self->priv->launcher = _tmp2_;
	_tmp3_ = self->priv->_games_button;
	_tmp4_ = gee_abstract_collection_get_size ((GeeAbstractCollection*) games);
	_tmp5_ = _tmp4_;
	_tmp6_ = gee_abstract_collection_get_size ((GeeAbstractCollection*) games);
	_tmp7_ = _tmp6_;
	_tmp8_ = g_strdup_printf (ngettext ("%d game selected", "%d games selected", (gulong) _tmp5_), _tmp7_);
	_tmp9_ = _tmp8_;
	gtk_menu_button_set_label (_tmp3_, _tmp9_);
	_g_free0 (_tmp9_);
	_tmp10_ = (GtkListBox*) gtk_list_box_new ();
	g_object_ref_sink (_tmp10_);
	games_list_box = _tmp10_;
	_tmp11_ = games_list_box;
	gtk_list_box_set_selection_mode (_tmp11_, GTK_SELECTION_NONE);
	_tmp12_ = games_list_box;
	gtk_widget_add_css_class ((GtkWidget*) _tmp12_, "boxed-list");
	{
		GeeArrayList* _game_list = NULL;
		gint _game_size = 0;
		GeeArrayList* _tmp13_;
		gint _tmp14_;
		gint _tmp15_;
		gint _game_index = 0;
		_game_list = games;
		_tmp13_ = _game_list;
		_tmp14_ = gee_abstract_collection_get_size ((GeeAbstractCollection*) _tmp13_);
		_tmp15_ = _tmp14_;
		_game_size = _tmp15_;
		_game_index = -1;
		while (TRUE) {
			gint _tmp16_;
			gint _tmp17_;
			ProtonPlusModelsGame* game = NULL;
			GeeArrayList* _tmp18_;
			gpointer _tmp19_;
			GtkLabel* label = NULL;
			ProtonPlusModelsGame* _tmp20_;
			const gchar* _tmp21_;
			const gchar* _tmp22_;
			GtkLabel* _tmp23_;
			GtkLabel* _tmp24_;
			GtkLabel* _tmp25_;
			GtkLabel* _tmp26_;
			GtkLabel* _tmp27_;
			GtkLabel* _tmp28_;
			GtkListBox* _tmp29_;
			GtkLabel* _tmp30_;
			_game_index = _game_index + 1;
			_tmp16_ = _game_index;
			_tmp17_ = _game_size;
			if (!(_tmp16_ < _tmp17_)) {
				break;
			}
			_tmp18_ = _game_list;
			_tmp19_ = gee_abstract_list_get ((GeeAbstractList*) _tmp18_, _game_index);
			game = (ProtonPlusModelsGame*) _tmp19_;
			_tmp20_ = game;
			_tmp21_ = proton_plus_models_game_get_name (_tmp20_);
			_tmp22_ = _tmp21_;
			_tmp23_ = (GtkLabel*) gtk_label_new (_tmp22_);
			g_object_ref_sink (_tmp23_);
			label = _tmp23_;
			_tmp24_ = label;
			gtk_label_set_xalign (_tmp24_, (gfloat) 0);
			_tmp25_ = label;
			gtk_widget_set_margin_start ((GtkWidget*) _tmp25_, 12);
			_tmp26_ = label;
			gtk_widget_set_margin_end ((GtkWidget*) _tmp26_, 12);
			_tmp27_ = label;
			gtk_widget_set_margin_top ((GtkWidget*) _tmp27_, 5);
			_tmp28_ = label;
			gtk_widget_set_margin_bottom ((GtkWidget*) _tmp28_, 5);
			_tmp29_ = games_list_box;
			_tmp30_ = label;
			gtk_list_box_append (_tmp29_, (GtkWidget*) _tmp30_);
			_g_object_unref0 (label);
			_g_object_unref0 (game);
		}
	}
	_tmp31_ = games_list_box;
	_tmp32_ = _g_object_ref0 ((GtkWidget*) _tmp31_);
	_tmp33_ = (GtkScrolledWindow*) gtk_scrolled_window_new ();
	g_object_set (_tmp33_, "hscrollbar-policy", GTK_POLICY_NEVER, NULL);
	gtk_scrolled_window_set_max_content_height (_tmp33_, 300);
	gtk_scrolled_window_set_propagate_natural_height (_tmp33_, TRUE);
	gtk_scrolled_window_set_child (_tmp33_, _tmp32_);
	_g_object_unref0 (_tmp32_);
	g_object_ref_sink (_tmp33_);
	scrolled = _tmp33_;
	_tmp34_ = (GtkPopover*) gtk_popover_new ();
	g_object_ref_sink (_tmp34_);
	popover = _tmp34_;
	_tmp35_ = popover;
	_tmp36_ = scrolled;
	gtk_popover_set_child (_tmp35_, (GtkWidget*) _tmp36_);
	_tmp37_ = self->priv->_games_button;
	_tmp38_ = popover;
	gtk_menu_button_set_popover (_tmp37_, _tmp38_);
	_tmp39_ = popover;
	_tmp40_ = self->priv->_games_button;
	proton_plus_widgets_window_register_popover_for_controller (_tmp39_, (GtkWidget*) _tmp40_, NULL);
	_tmp41_ = gtk_string_list_new (NULL);
	model = _tmp41_;
	_tmp42_ = gee_array_list_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, NULL, NULL, NULL);
	_g_object_unref0 (self->priv->possible_tools_internal);
	self->priv->possible_tools_internal = _tmp42_;
	_tmp43_ = gee_abstract_collection_get_size ((GeeAbstractCollection*) games);
	_tmp44_ = _tmp43_;
	all_steam_linux_runtime_compatible = _tmp44_ > 0;
	{
		GeeArrayList* _game_list = NULL;
		gint _game_size = 0;
		GeeArrayList* _tmp45_;
		gint _tmp46_;
		gint _tmp47_;
		gint _game_index = 0;
		_game_list = games;
		_tmp45_ = _game_list;
		_tmp46_ = gee_abstract_collection_get_size ((GeeAbstractCollection*) _tmp45_);
		_tmp47_ = _tmp46_;
		_game_size = _tmp47_;
		_game_index = -1;
		while (TRUE) {
			gint _tmp48_;
			gint _tmp49_;
			ProtonPlusModelsGame* game = NULL;
			GeeArrayList* _tmp50_;
			gpointer _tmp51_;
			ProtonPlusModelsGame* _tmp52_;
			_game_index = _game_index + 1;
			_tmp48_ = _game_index;
			_tmp49_ = _game_size;
			if (!(_tmp48_ < _tmp49_)) {
				break;
			}
			_tmp50_ = _game_list;
			_tmp51_ = gee_abstract_list_get ((GeeAbstractList*) _tmp50_, _game_index);
			game = (ProtonPlusModelsGame*) _tmp51_;
			_tmp52_ = game;
			if (!proton_plus_models_launchers_steam_is_game_steam_linux_runtime_compatible (_tmp52_)) {
				all_steam_linux_runtime_compatible = FALSE;
				_g_object_unref0 (game);
				break;
			}
			_g_object_unref0 (game);
		}
	}
	if (PROTON_PLUS_MODELS_LAUNCHERS_IS_STEAM (launcher)) {
		_tmp53_ = g_strcmp0 (current_tool_name, "Default") != 0;
	} else {
		_tmp53_ = FALSE;
	}
	if (_tmp53_) {
		GtkStringList* _tmp54_;
		GeeArrayList* _tmp55_;
		_tmp54_ = model;
		gtk_string_list_append (_tmp54_, _ ("Default"));
		_tmp55_ = self->priv->possible_tools_internal;
		gee_abstract_collection_add ((GeeAbstractCollection*) _tmp55_, "Default");
	}
	{
		GeeLinkedList* _tool_list = NULL;
		GeeLinkedList* _tmp56_;
		gint _tool_size = 0;
		GeeLinkedList* _tmp57_;
		gint _tmp58_;
		gint _tmp59_;
		gint _tool_index = 0;
		_tmp56_ = launcher->compatibility_tools;
		_tool_list = _tmp56_;
		_tmp57_ = _tool_list;
		_tmp58_ = gee_abstract_collection_get_size ((GeeAbstractCollection*) _tmp57_);
		_tmp59_ = _tmp58_;
		_tool_size = _tmp59_;
		_tool_index = -1;
		while (TRUE) {
			gint _tmp60_;
			gint _tmp61_;
			ProtonPlusModelsCompatibilityTool* tool = NULL;
			GeeLinkedList* _tmp62_;
			gpointer _tmp63_;
			gboolean _tmp64_ = FALSE;
			ProtonPlusModelsCompatibilityTool* _tmp65_;
			gboolean _tmp66_;
			gboolean _tmp67_;
			ProtonPlusModelsCompatibilityTool* _tmp71_;
			const gchar* _tmp72_;
			const gchar* _tmp73_;
			_tool_index = _tool_index + 1;
			_tmp60_ = _tool_index;
			_tmp61_ = _tool_size;
			if (!(_tmp60_ < _tmp61_)) {
				break;
			}
			_tmp62_ = _tool_list;
			_tmp63_ = gee_abstract_list_get ((GeeAbstractList*) _tmp62_, _tool_index);
			tool = (ProtonPlusModelsCompatibilityTool*) _tmp63_;
			_tmp65_ = tool;
			_tmp66_ = proton_plus_models_compatibility_tool_get_is_assignable (_tmp65_);
			_tmp67_ = _tmp66_;
			if (!_tmp67_) {
				_tmp64_ = TRUE;
			} else {
				ProtonPlusModelsCompatibilityTool* _tmp68_;
				gboolean _tmp69_;
				gboolean _tmp70_;
				_tmp68_ = tool;
				_tmp69_ = proton_plus_models_compatibility_tool_get_is_available (_tmp68_);
				_tmp70_ = _tmp69_;
				_tmp64_ = !_tmp70_;
			}
			if (_tmp64_) {
				_g_object_unref0 (tool);
				continue;
			}
			_tmp71_ = tool;
			_tmp72_ = proton_plus_models_compatibility_tool_get_internal_title (_tmp71_);
			_tmp73_ = _tmp72_;
			if (g_strcmp0 (_tmp73_, current_tool_name) != 0) {
				gboolean _tmp74_ = FALSE;
				ProtonPlusModelsCompatibilityTool* _tmp75_;
				const gchar* _tmp76_;
				const gchar* _tmp77_;
				ProtonPlusModelsCompatibilityTool* _tmp78_;
				const gchar* _tmp79_;
				const gchar* _tmp80_;
				GtkStringList* _tmp81_;
				ProtonPlusModelsCompatibilityTool* _tmp82_;
				const gchar* _tmp83_;
				const gchar* _tmp84_;
				GeeArrayList* _tmp85_;
				ProtonPlusModelsCompatibilityTool* _tmp86_;
				const gchar* _tmp87_;
				const gchar* _tmp88_;
				_tmp75_ = tool;
				_tmp76_ = proton_plus_models_compatibility_tool_get_display_title (_tmp75_);
				_tmp77_ = _tmp76_;
				_tmp78_ = tool;
				_tmp79_ = proton_plus_models_compatibility_tool_get_internal_title (_tmp78_);
				_tmp80_ = _tmp79_;
				if (proton_plus_models_launchers_steam_is_steam_linux_runtime (_tmp77_, _tmp80_)) {
					_tmp74_ = !all_steam_linux_runtime_compatible;
				} else {
					_tmp74_ = FALSE;
				}
				if (_tmp74_) {
					_g_object_unref0 (tool);
					continue;
				}
				_tmp81_ = model;
				_tmp82_ = tool;
				_tmp83_ = proton_plus_models_compatibility_tool_get_display_title (_tmp82_);
				_tmp84_ = _tmp83_;
				gtk_string_list_append (_tmp81_, _tmp84_);
				_tmp85_ = self->priv->possible_tools_internal;
				_tmp86_ = tool;
				_tmp87_ = proton_plus_models_compatibility_tool_get_internal_title (_tmp86_);
				_tmp88_ = _tmp87_;
				gee_abstract_collection_add ((GeeAbstractCollection*) _tmp85_, _tmp88_);
			}
			_g_object_unref0 (tool);
		}
	}
	_tmp89_ = self->priv->combo_row;
	_tmp90_ = model;
	adw_combo_row_set_model (_tmp89_, (GListModel*) _tmp90_);
	_tmp91_ = self->priv->_migrate_button;
	_tmp92_ = self->priv->possible_tools_internal;
	_tmp93_ = gee_abstract_collection_get_size ((GeeAbstractCollection*) _tmp92_);
	_tmp94_ = _tmp93_;
	gtk_widget_set_sensitive ((GtkWidget*) _tmp91_, _tmp94_ > 0);
	_g_object_unref0 (model);
	_g_object_unref0 (popover);
	_g_object_unref0 (scrolled);
	_g_object_unref0 (games_list_box);
}

static void
proton_plus_widgets_tools_migrate_box_on_migrate_clicked (ProtonPlusWidgetsToolsMigrateBox* self)
{
	guint selected_index = 0U;
	AdwComboRow* _tmp0_;
	guint _tmp1_;
	guint _tmp2_;
	GeeArrayList* _tmp3_;
	gint _tmp4_;
	gint _tmp5_;
	gchar* new_tool_internal = NULL;
	GeeArrayList* _tmp6_;
	gpointer _tmp7_;
	GtkButton* _tmp8_;
	GeeArrayList* failures = NULL;
	GeeArrayList* _tmp9_;
	GeeArrayList* _tmp24_;
	gint _tmp25_;
	gint _tmp26_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->combo_row;
	_tmp1_ = adw_combo_row_get_selected (_tmp0_);
	_tmp2_ = _tmp1_;
	selected_index = _tmp2_;
	_tmp3_ = self->priv->possible_tools_internal;
	_tmp4_ = gee_abstract_collection_get_size ((GeeAbstractCollection*) _tmp3_);
	_tmp5_ = _tmp4_;
	if (selected_index >= ((guint) _tmp5_)) {
		return;
	}
	_tmp6_ = self->priv->possible_tools_internal;
	_tmp7_ = gee_abstract_list_get ((GeeAbstractList*) _tmp6_, (gint) selected_index);
	new_tool_internal = (gchar*) _tmp7_;
	_tmp8_ = self->priv->_migrate_button;
	gtk_widget_set_sensitive ((GtkWidget*) _tmp8_, FALSE);
	_tmp9_ = gee_array_list_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, NULL, NULL, NULL);
	failures = _tmp9_;
	{
		GeeArrayList* _game_list = NULL;
		GeeArrayList* _tmp10_;
		gint _game_size = 0;
		GeeArrayList* _tmp11_;
		gint _tmp12_;
		gint _tmp13_;
		gint _game_index = 0;
		_tmp10_ = self->priv->games;
		_game_list = _tmp10_;
		_tmp11_ = _game_list;
		_tmp12_ = gee_abstract_collection_get_size ((GeeAbstractCollection*) _tmp11_);
		_tmp13_ = _tmp12_;
		_game_size = _tmp13_;
		_game_index = -1;
		while (TRUE) {
			gint _tmp14_;
			gint _tmp15_;
			ProtonPlusModelsGame* game = NULL;
			GeeArrayList* _tmp16_;
			gpointer _tmp17_;
			ProtonPlusModelsGame* _tmp18_;
			const gchar* _tmp19_;
			_game_index = _game_index + 1;
			_tmp14_ = _game_index;
			_tmp15_ = _game_size;
			if (!(_tmp14_ < _tmp15_)) {
				break;
			}
			_tmp16_ = _game_list;
			_tmp17_ = gee_abstract_list_get ((GeeAbstractList*) _tmp16_, _game_index);
			game = (ProtonPlusModelsGame*) _tmp17_;
			_tmp18_ = game;
			_tmp19_ = new_tool_internal;
			if (!proton_plus_models_game_change_compatibility_tool (_tmp18_, _tmp19_)) {
				GeeArrayList* _tmp20_;
				ProtonPlusModelsGame* _tmp21_;
				const gchar* _tmp22_;
				const gchar* _tmp23_;
				_tmp20_ = failures;
				_tmp21_ = game;
				_tmp22_ = proton_plus_models_game_get_name (_tmp21_);
				_tmp23_ = _tmp22_;
				gee_abstract_collection_add ((GeeAbstractCollection*) _tmp20_, _tmp23_);
			}
			_g_object_unref0 (game);
		}
	}
	_tmp24_ = failures;
	_tmp25_ = gee_abstract_collection_get_size ((GeeAbstractCollection*) _tmp24_);
	_tmp26_ = _tmp25_;
	if (_tmp26_ > 0) {
		gchar* names = NULL;
		gchar* _tmp27_;
		ProtonPlusWidgetsMainErrorDialog* dialog = NULL;
		const gchar* _tmp44_;
		ProtonPlusWidgetsMainErrorDialog* _tmp45_;
		ProtonPlusWidgetsMainErrorDialog* _tmp46_;
		GtkRoot* _tmp47_;
		GtkButton* _tmp48_;
		_tmp27_ = g_strdup ("");
		names = _tmp27_;
		{
			GeeArrayList* _name_list = NULL;
			GeeArrayList* _tmp28_;
			gint _name_size = 0;
			GeeArrayList* _tmp29_;
			gint _tmp30_;
			gint _tmp31_;
			gint _name_index = 0;
			_tmp28_ = failures;
			_name_list = _tmp28_;
			_tmp29_ = _name_list;
			_tmp30_ = gee_abstract_collection_get_size ((GeeAbstractCollection*) _tmp29_);
			_tmp31_ = _tmp30_;
			_name_size = _tmp31_;
			_name_index = -1;
			while (TRUE) {
				gint _tmp32_;
				gint _tmp33_;
				gchar* name = NULL;
				GeeArrayList* _tmp34_;
				gpointer _tmp35_;
				const gchar* _tmp36_;
				const gchar* _tmp39_;
				const gchar* _tmp40_;
				gchar* _tmp41_;
				gchar* _tmp42_;
				gchar* _tmp43_;
				_name_index = _name_index + 1;
				_tmp32_ = _name_index;
				_tmp33_ = _name_size;
				if (!(_tmp32_ < _tmp33_)) {
					break;
				}
				_tmp34_ = _name_list;
				_tmp35_ = gee_abstract_list_get ((GeeAbstractList*) _tmp34_, _name_index);
				name = (gchar*) _tmp35_;
				_tmp36_ = names;
				if (g_strcmp0 (_tmp36_, "") != 0) {
					const gchar* _tmp37_;
					gchar* _tmp38_;
					_tmp37_ = names;
					_tmp38_ = g_strconcat (_tmp37_, "\n", NULL);
					_g_free0 (names);
					names = _tmp38_;
				}
				_tmp39_ = names;
				_tmp40_ = name;
				_tmp41_ = g_strdup_printf ("- %s", _tmp40_);
				_tmp42_ = _tmp41_;
				_tmp43_ = g_strconcat (_tmp39_, _tmp42_, NULL);
				_g_free0 (names);
				names = _tmp43_;
				_g_free0 (_tmp42_);
				_g_free0 (name);
			}
		}
		_tmp44_ = names;
		_tmp45_ = proton_plus_widgets_main_error_dialog_new (_ ("Migration Failed"), _ ("Some games could not be migrated to the new compatibility tool. This m" \
"ay be due to missing permissions or file access issues."), _tmp44_);
		g_object_ref_sink (_tmp45_);
		dialog = _tmp45_;
		_tmp46_ = dialog;
		_tmp47_ = gtk_widget_get_root ((GtkWidget*) self);
		proton_plus_widgets_window_present_dialog_for_controller ((AdwDialog*) _tmp46_, (GtkWidget*) G_TYPE_CHECK_INSTANCE_CAST (_tmp47_, gtk_window_get_type (), GtkWindow));
		_tmp48_ = self->priv->_migrate_button;
		gtk_widget_set_sensitive ((GtkWidget*) _tmp48_, TRUE);
		_g_object_unref0 (dialog);
		_g_free0 (names);
		_g_object_unref0 (failures);
		_g_free0 (new_tool_internal);
		return;
	}
	g_signal_emit (self, proton_plus_widgets_tools_migrate_box_signals[PROTON_PLUS_WIDGETS_TOOLS_MIGRATE_BOX_FINISHED_SIGNAL], 0);
	_g_object_unref0 (failures);
	_g_free0 (new_tool_internal);
}

GtkButton*
proton_plus_widgets_tools_migrate_box_get_migrate_button (ProtonPlusWidgetsToolsMigrateBox* self)
{
	GtkButton* result;
	GtkButton* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_migrate_button;
	result = _tmp0_;
	return result;
}

static void
proton_plus_widgets_tools_migrate_box_set_migrate_button (ProtonPlusWidgetsToolsMigrateBox* self,
                                                          GtkButton* value)
{
	GtkButton* old_value;
	g_return_if_fail (self != NULL);
	old_value = proton_plus_widgets_tools_migrate_box_get_migrate_button (self);
	if (old_value != value) {
		GtkButton* _tmp0_;
		_tmp0_ = _g_object_ref0 (value);
		_g_object_unref0 (self->priv->_migrate_button);
		self->priv->_migrate_button = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, proton_plus_widgets_tools_migrate_box_properties[PROTON_PLUS_WIDGETS_TOOLS_MIGRATE_BOX_MIGRATE_BUTTON_PROPERTY]);
	}
}

GtkMenuButton*
proton_plus_widgets_tools_migrate_box_get_games_button (ProtonPlusWidgetsToolsMigrateBox* self)
{
	GtkMenuButton* result;
	GtkMenuButton* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_games_button;
	result = _tmp0_;
	return result;
}

static void
proton_plus_widgets_tools_migrate_box_set_games_button (ProtonPlusWidgetsToolsMigrateBox* self,
                                                        GtkMenuButton* value)
{
	GtkMenuButton* old_value;
	g_return_if_fail (self != NULL);
	old_value = proton_plus_widgets_tools_migrate_box_get_games_button (self);
	if (old_value != value) {
		GtkMenuButton* _tmp0_;
		_tmp0_ = _g_object_ref0 (value);
		_g_object_unref0 (self->priv->_games_button);
		self->priv->_games_button = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, proton_plus_widgets_tools_migrate_box_properties[PROTON_PLUS_WIDGETS_TOOLS_MIGRATE_BOX_GAMES_BUTTON_PROPERTY]);
	}
}

static void
proton_plus_widgets_tools_migrate_box_class_init (ProtonPlusWidgetsToolsMigrateBoxClass * klass,
                                                  gpointer klass_data)
{
	proton_plus_widgets_tools_migrate_box_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &ProtonPlusWidgetsToolsMigrateBox_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_proton_plus_widgets_tools_migrate_box_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_proton_plus_widgets_tools_migrate_box_set_property;
	G_OBJECT_CLASS (klass)->finalize = proton_plus_widgets_tools_migrate_box_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), PROTON_PLUS_WIDGETS_TOOLS_MIGRATE_BOX_MIGRATE_BUTTON_PROPERTY, proton_plus_widgets_tools_migrate_box_properties[PROTON_PLUS_WIDGETS_TOOLS_MIGRATE_BOX_MIGRATE_BUTTON_PROPERTY] = g_param_spec_object ("migrate-button", "migrate-button", "migrate-button", gtk_button_get_type (), G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	g_object_class_install_property (G_OBJECT_CLASS (klass), PROTON_PLUS_WIDGETS_TOOLS_MIGRATE_BOX_GAMES_BUTTON_PROPERTY, proton_plus_widgets_tools_migrate_box_properties[PROTON_PLUS_WIDGETS_TOOLS_MIGRATE_BOX_GAMES_BUTTON_PROPERTY] = g_param_spec_object ("games-button", "games-button", "games-button", gtk_menu_button_get_type (), G_PARAM_STATIC_STRINGS | G_PARAM_READABLE));
	proton_plus_widgets_tools_migrate_box_signals[PROTON_PLUS_WIDGETS_TOOLS_MIGRATE_BOX_FINISHED_SIGNAL] = g_signal_new ("finished", PROTON_PLUS_WIDGETS_TOOLS_TYPE_MIGRATE_BOX, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
}

static void
proton_plus_widgets_tools_migrate_box_instance_init (ProtonPlusWidgetsToolsMigrateBox * self,
                                                     gpointer klass)
{
	self->priv = proton_plus_widgets_tools_migrate_box_get_instance_private (self);
}

static void
proton_plus_widgets_tools_migrate_box_finalize (GObject * obj)
{
	ProtonPlusWidgetsToolsMigrateBox * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, PROTON_PLUS_WIDGETS_TOOLS_TYPE_MIGRATE_BOX, ProtonPlusWidgetsToolsMigrateBox);
	_g_object_unref0 (self->priv->games);
	_g_free0 (self->priv->current_tool_name);
	_g_object_unref0 (self->priv->launcher);
	_g_object_unref0 (self->priv->combo_row);
	_g_object_unref0 (self->priv->_migrate_button);
	_g_object_unref0 (self->priv->_games_button);
	_g_object_unref0 (self->priv->possible_tools_internal);
	G_OBJECT_CLASS (proton_plus_widgets_tools_migrate_box_parent_class)->finalize (obj);
}

static GType
proton_plus_widgets_tools_migrate_box_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (ProtonPlusWidgetsToolsMigrateBoxClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) proton_plus_widgets_tools_migrate_box_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ProtonPlusWidgetsToolsMigrateBox), 0, (GInstanceInitFunc) proton_plus_widgets_tools_migrate_box_instance_init, NULL };
	GType proton_plus_widgets_tools_migrate_box_type_id;
	proton_plus_widgets_tools_migrate_box_type_id = g_type_register_static (gtk_box_get_type (), "ProtonPlusWidgetsToolsMigrateBox", &g_define_type_info, 0);
	ProtonPlusWidgetsToolsMigrateBox_private_offset = g_type_add_instance_private (proton_plus_widgets_tools_migrate_box_type_id, sizeof (ProtonPlusWidgetsToolsMigrateBoxPrivate));
	return proton_plus_widgets_tools_migrate_box_type_id;
}

GType
proton_plus_widgets_tools_migrate_box_get_type (void)
{
	static volatile gsize proton_plus_widgets_tools_migrate_box_type_id__once = 0;
	if (g_once_init_enter (&proton_plus_widgets_tools_migrate_box_type_id__once)) {
		GType proton_plus_widgets_tools_migrate_box_type_id;
		proton_plus_widgets_tools_migrate_box_type_id = proton_plus_widgets_tools_migrate_box_get_type_once ();
		g_once_init_leave (&proton_plus_widgets_tools_migrate_box_type_id__once, proton_plus_widgets_tools_migrate_box_type_id);
	}
	return proton_plus_widgets_tools_migrate_box_type_id__once;
}

static void
_vala_proton_plus_widgets_tools_migrate_box_get_property (GObject * object,
                                                          guint property_id,
                                                          GValue * value,
                                                          GParamSpec * pspec)
{
	ProtonPlusWidgetsToolsMigrateBox * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, PROTON_PLUS_WIDGETS_TOOLS_TYPE_MIGRATE_BOX, ProtonPlusWidgetsToolsMigrateBox);
	switch (property_id) {
		case PROTON_PLUS_WIDGETS_TOOLS_MIGRATE_BOX_MIGRATE_BUTTON_PROPERTY:
		g_value_set_object (value, proton_plus_widgets_tools_migrate_box_get_migrate_button (self));
		break;
		case PROTON_PLUS_WIDGETS_TOOLS_MIGRATE_BOX_GAMES_BUTTON_PROPERTY:
		g_value_set_object (value, proton_plus_widgets_tools_migrate_box_get_games_button (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_proton_plus_widgets_tools_migrate_box_set_property (GObject * object,
                                                          guint property_id,
                                                          const GValue * value,
                                                          GParamSpec * pspec)
{
	ProtonPlusWidgetsToolsMigrateBox * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, PROTON_PLUS_WIDGETS_TOOLS_TYPE_MIGRATE_BOX, ProtonPlusWidgetsToolsMigrateBox);
	switch (property_id) {
		case PROTON_PLUS_WIDGETS_TOOLS_MIGRATE_BOX_MIGRATE_BUTTON_PROPERTY:
		proton_plus_widgets_tools_migrate_box_set_migrate_button (self, g_value_get_object (value));
		break;
		case PROTON_PLUS_WIDGETS_TOOLS_MIGRATE_BOX_GAMES_BUTTON_PROPERTY:
		proton_plus_widgets_tools_migrate_box_set_games_button (self, g_value_get_object (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);
}

