/* tools-release-games-dialog.c generated by valac 0.56.19, the Vala compiler
 * generated from tools-release-games-dialog.vala, do not modify */

#include "protonplus_core.h"
#include <gtk/gtk.h>
#include <glib.h>
#include <glib-object.h>
#include <glib/gi18n-lib.h>
#include <stdlib.h>
#include <string.h>
#include <adwaita.h>
#include <gee.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_RELEASE_GAMES_DIALOG_0_PROPERTY,
	PROTON_PLUS_WIDGETS_TOOLS_RELEASE_GAMES_DIALOG_NUM_PROPERTIES
};
static GParamSpec* proton_plus_widgets_tools_release_games_dialog_properties[PROTON_PLUS_WIDGETS_TOOLS_RELEASE_GAMES_DIALOG_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_RELEASE_GAMES_DIALOG_MIGRATE_REQUESTED_SIGNAL,
	PROTON_PLUS_WIDGETS_TOOLS_RELEASE_GAMES_DIALOG_NUM_SIGNALS
};
static guint proton_plus_widgets_tools_release_games_dialog_signals[PROTON_PLUS_WIDGETS_TOOLS_RELEASE_GAMES_DIALOG_NUM_SIGNALS] = {0};

struct _ProtonPlusWidgetsToolsReleaseGamesDialogPrivate {
	GtkListBox* list_box;
	GtkCheckButton* check_button;
	GtkButton* migrate_button;
	gboolean updating_select_all;
};

static gint ProtonPlusWidgetsToolsReleaseGamesDialog_private_offset;
static gpointer proton_plus_widgets_tools_release_games_dialog_parent_class = NULL;

static void __lambda84_ (ProtonPlusWidgetsToolsReleaseGamesDialog* self);
static GeeArrayList* proton_plus_widgets_tools_release_games_dialog_get_selected_games (ProtonPlusWidgetsToolsReleaseGamesDialog* self);
static void ___lambda84__gtk_button_clicked (GtkButton* _sender,
                                      gpointer self);
static void __lambda85_ (ProtonPlusWidgetsToolsReleaseGamesDialog* self);
static void proton_plus_widgets_tools_release_games_dialog_update_selection_state (ProtonPlusWidgetsToolsReleaseGamesDialog* self);
static void ___lambda85__gtk_check_button_toggled (GtkCheckButton* _sender,
                                            gpointer self);
static void _proton_plus_widgets_tools_release_games_dialog_update_selection_state_g_object_notify (GObject* _sender,
                                                                                             GParamSpec* pspec,
                                                                                             gpointer self);
static void proton_plus_widgets_tools_release_games_dialog_finalize (GObject * obj);
static GType proton_plus_widgets_tools_release_games_dialog_get_type_once (void);

static inline gpointer
proton_plus_widgets_tools_release_games_dialog_get_instance_private (ProtonPlusWidgetsToolsReleaseGamesDialog* self)
{
	return G_STRUCT_MEMBER_P (self, ProtonPlusWidgetsToolsReleaseGamesDialog_private_offset);
}

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

static void
__lambda84_ (ProtonPlusWidgetsToolsReleaseGamesDialog* self)
{
	GeeArrayList* games = NULL;
	GeeArrayList* _tmp0_;
	GeeArrayList* _tmp1_;
	gint _tmp2_;
	gint _tmp3_;
	_tmp0_ = proton_plus_widgets_tools_release_games_dialog_get_selected_games (self);
	games = _tmp0_;
	_tmp1_ = games;
	_tmp2_ = gee_abstract_collection_get_size ((GeeAbstractCollection*) _tmp1_);
	_tmp3_ = _tmp2_;
	if (_tmp3_ > 0) {
		GeeArrayList* _tmp4_;
		adw_dialog_close ((AdwDialog*) self);
		_tmp4_ = games;
		g_signal_emit (self, proton_plus_widgets_tools_release_games_dialog_signals[PROTON_PLUS_WIDGETS_TOOLS_RELEASE_GAMES_DIALOG_MIGRATE_REQUESTED_SIGNAL], 0, _tmp4_);
	}
	_g_object_unref0 (games);
}

static void
___lambda84__gtk_button_clicked (GtkButton* _sender,
                                 gpointer self)
{
	__lambda84_ ((ProtonPlusWidgetsToolsReleaseGamesDialog*) self);
}

static void
__lambda85_ (ProtonPlusWidgetsToolsReleaseGamesDialog* self)
{
	gboolean is_active = FALSE;
	GtkCheckButton* _tmp0_;
	GtkWidget* child = NULL;
	GtkListBox* _tmp1_;
	GtkWidget* _tmp2_;
	GtkWidget* _tmp3_;
	if (self->priv->updating_select_all) {
		return;
	}
	_tmp0_ = self->priv->check_button;
	is_active = gtk_check_button_get_active (_tmp0_);
	self->priv->updating_select_all = TRUE;
	_tmp1_ = self->priv->list_box;
	_tmp2_ = gtk_widget_get_first_child ((GtkWidget*) _tmp1_);
	_tmp3_ = _g_object_ref0 (_tmp2_);
	child = _tmp3_;
	while (TRUE) {
		GtkWidget* _tmp4_;
		GtkWidget* _tmp5_;
		GtkWidget* _tmp7_;
		GtkWidget* _tmp8_;
		GtkWidget* _tmp9_;
		_tmp4_ = child;
		if (!(_tmp4_ != NULL)) {
			break;
		}
		_tmp5_ = child;
		if (PROTON_PLUS_WIDGETS_TOOLS_IS_GAME_ROW (_tmp5_)) {
			GtkWidget* _tmp6_;
			_tmp6_ = child;
			proton_plus_widgets_tools_game_row_set_selected (G_TYPE_CHECK_INSTANCE_CAST (_tmp6_, PROTON_PLUS_WIDGETS_TOOLS_TYPE_GAME_ROW, ProtonPlusWidgetsToolsGameRow), is_active);
		}
		_tmp7_ = child;
		_tmp8_ = gtk_widget_get_next_sibling (_tmp7_);
		_tmp9_ = _g_object_ref0 (_tmp8_);
		_g_object_unref0 (child);
		child = _tmp9_;
	}
	self->priv->updating_select_all = FALSE;
	proton_plus_widgets_tools_release_games_dialog_update_selection_state (self);
	_g_object_unref0 (child);
}

static void
___lambda85__gtk_check_button_toggled (GtkCheckButton* _sender,
                                       gpointer self)
{
	__lambda85_ ((ProtonPlusWidgetsToolsReleaseGamesDialog*) self);
}

static void
_proton_plus_widgets_tools_release_games_dialog_update_selection_state_g_object_notify (GObject* _sender,
                                                                                        GParamSpec* pspec,
                                                                                        gpointer self)
{
	proton_plus_widgets_tools_release_games_dialog_update_selection_state ((ProtonPlusWidgetsToolsReleaseGamesDialog*) self);
}

ProtonPlusWidgetsToolsReleaseGamesDialog*
proton_plus_widgets_tools_release_games_dialog_construct (GType object_type,
                                                          ProtonPlusServicesInstallJob* job)
{
	ProtonPlusWidgetsToolsReleaseGamesDialog * self = NULL;
	gchar* _tmp0_;
	gchar* _tmp1_;
	gchar* _tmp2_;
	gchar* _tmp3_;
	gchar* _tmp4_;
	AdwWindowTitle* window_title = NULL;
	gchar* _tmp5_;
	gchar* _tmp6_;
	AdwWindowTitle* _tmp7_;
	AdwWindowTitle* _tmp8_;
	AdwHeaderBar* header_bar = NULL;
	AdwHeaderBar* _tmp9_;
	AdwHeaderBar* _tmp10_;
	AdwWindowTitle* _tmp11_;
	AdwButtonContent* migrate_button_content = NULL;
	gchar* _tmp12_;
	gchar* _tmp13_;
	AdwButtonContent* _tmp14_ = NULL;
	AdwButtonContent* _tmp15_;
	GtkWidget* _tmp16_;
	GtkButton* _tmp17_ = NULL;
	GtkButton* _tmp18_;
	GtkButton* _tmp19_;
	AdwHeaderBar* _tmp20_;
	GtkButton* _tmp21_;
	GtkListBox* _tmp22_ = NULL;
	GtkListBox* _tmp23_;
	GtkCheckButton* _tmp24_;
	GtkCheckButton* _tmp25_;
	GtkCheckButton* _tmp26_;
	GtkCheckButton* _tmp27_;
	AdwActionRow* select_all_row = NULL;
	gchar* _tmp28_;
	GtkCheckButton* _tmp29_;
	GtkWidget* _tmp30_;
	AdwActionRow* _tmp31_ = NULL;
	AdwActionRow* _tmp32_;
	GtkCheckButton* _tmp33_;
	GtkListBox* _tmp34_;
	AdwActionRow* _tmp35_;
	ProtonPlusModelsLaunchersSteam* steam_launcher = NULL;
	ProtonPlusModelsTool* _tmp36_;
	ProtonPlusModelsTool* _tmp37_;
	ProtonPlusModelsGroup* _tmp38_;
	ProtonPlusModelsGroup* _tmp39_;
	ProtonPlusModelsLauncher* _tmp40_;
	ProtonPlusModelsLauncher* _tmp41_;
	ProtonPlusModelsLaunchersSteam* _tmp42_;
	gboolean has_games = FALSE;
	ProtonPlusModelsLaunchersSteam* _tmp43_;
	GtkWidget* content = NULL;
	AdwToolbarView* toolbar_view = NULL;
	AdwToolbarView* _tmp72_;
	AdwHeaderBar* _tmp73_;
	GtkWidget* _tmp74_;
	g_return_val_if_fail (job != NULL, NULL);
	_tmp0_ = proton_plus_services_install_job_get_title (job);
	_tmp1_ = _tmp0_;
	_tmp2_ = _tmp1_;
	_tmp3_ = g_strdup_printf (_ ("Games using %s"), _tmp2_);
	_tmp4_ = _tmp3_;
	self = (ProtonPlusWidgetsToolsReleaseGamesDialog*) g_object_new (object_type, "title", _tmp4_, NULL);
	_g_free0 (_tmp4_);
	_g_free0 (_tmp2_);
	_tmp5_ = proton_plus_widgets_tools_release_row_release_display_title (job);
	_tmp6_ = _tmp5_;
	_tmp7_ = (AdwWindowTitle*) adw_window_title_new (_ ("Games Using This Tool"), _tmp6_);
	g_object_ref_sink (_tmp7_);
	_tmp8_ = _tmp7_;
	_g_free0 (_tmp6_);
	window_title = _tmp8_;
	_tmp9_ = (AdwHeaderBar*) adw_header_bar_new ();
	g_object_ref_sink (_tmp9_);
	header_bar = _tmp9_;
	_tmp10_ = header_bar;
	_tmp11_ = window_title;
	adw_header_bar_set_title_widget (_tmp10_, (GtkWidget*) _tmp11_);
	_tmp12_ = g_strdup (_ ("Migrate"));
	_tmp13_ = g_strdup ("right-left-symbolic");
	_tmp14_ = (AdwButtonContent*) adw_button_content_new ();
	adw_button_content_set_label (_tmp14_, _tmp12_);
	_g_free0 (_tmp12_);
	adw_button_content_set_icon_name (_tmp14_, _tmp13_);
	_g_free0 (_tmp13_);
	g_object_ref_sink (_tmp14_);
	migrate_button_content = _tmp14_;
	_tmp15_ = migrate_button_content;
	_tmp16_ = _g_object_ref0 ((GtkWidget*) _tmp15_);
	_tmp17_ = (GtkButton*) gtk_button_new ();
	gtk_widget_set_valign ((GtkWidget*) _tmp17_, GTK_ALIGN_CENTER);
	gtk_widget_set_visible ((GtkWidget*) _tmp17_, FALSE);
	gtk_button_set_child (_tmp17_, _tmp16_);
	_g_object_unref0 (_tmp16_);
	g_object_ref_sink (_tmp17_);
	_g_object_unref0 (self->priv->migrate_button);
	self->priv->migrate_button = _tmp17_;
	_tmp18_ = self->priv->migrate_button;
	gtk_widget_set_tooltip_text ((GtkWidget*) _tmp18_, _ ("Migrate selected games to another tool"));
	_tmp19_ = self->priv->migrate_button;
	g_signal_connect_object (_tmp19_, "clicked", (GCallback) ___lambda84__gtk_button_clicked, self, 0);
	_tmp20_ = header_bar;
	_tmp21_ = self->priv->migrate_button;
	adw_header_bar_pack_end (_tmp20_, (GtkWidget*) _tmp21_);
	_tmp22_ = (GtkListBox*) gtk_list_box_new ();
	gtk_list_box_set_selection_mode (_tmp22_, GTK_SELECTION_NONE);
	g_object_ref_sink (_tmp22_);
	_g_object_unref0 (self->priv->list_box);
	self->priv->list_box = _tmp22_;
	_tmp23_ = self->priv->list_box;
	gtk_widget_add_css_class ((GtkWidget*) _tmp23_, "boxed-list");
	_tmp24_ = (GtkCheckButton*) gtk_check_button_new ();
	g_object_ref_sink (_tmp24_);
	_g_object_unref0 (self->priv->check_button);
	self->priv->check_button = _tmp24_;
	_tmp25_ = self->priv->check_button;
	gtk_widget_set_tooltip_text ((GtkWidget*) _tmp25_, _ ("Select all games"));
	_tmp26_ = self->priv->check_button;
	gtk_accessible_update_property ((GtkAccessible*) _tmp26_, GTK_ACCESSIBLE_PROPERTY_LABEL, _ ("Select all games"), -1, -1);
	_tmp27_ = self->priv->check_button;
	g_signal_connect_object (_tmp27_, "toggled", (GCallback) ___lambda85__gtk_check_button_toggled, self, 0);
	_tmp28_ = g_strdup (_ ("Select all games"));
	_tmp29_ = self->priv->check_button;
	_tmp30_ = _g_object_ref0 ((GtkWidget*) _tmp29_);
	_tmp31_ = (AdwActionRow*) adw_action_row_new ();
	adw_preferences_row_set_title ((AdwPreferencesRow*) _tmp31_, _tmp28_);
	_g_free0 (_tmp28_);
	adw_action_row_set_activatable_widget (_tmp31_, _tmp30_);
	_g_object_unref0 (_tmp30_);
	g_object_ref_sink (_tmp31_);
	select_all_row = _tmp31_;
	_tmp32_ = select_all_row;
	_tmp33_ = self->priv->check_button;
	adw_action_row_add_prefix (_tmp32_, (GtkWidget*) _tmp33_);
	_tmp34_ = self->priv->list_box;
	_tmp35_ = select_all_row;
	gtk_list_box_append (_tmp34_, (GtkWidget*) _tmp35_);
	_tmp36_ = proton_plus_services_install_job_get_tool (job);
	_tmp37_ = _tmp36_;
	_tmp38_ = proton_plus_models_tool_get_group (_tmp37_);
	_tmp39_ = _tmp38_;
	_tmp40_ = proton_plus_models_group_get_launcher (_tmp39_);
	_tmp41_ = _tmp40_;
	_tmp42_ = _g_object_ref0 (PROTON_PLUS_MODELS_LAUNCHERS_IS_STEAM (_tmp41_) ? ((ProtonPlusModelsLaunchersSteam*) _tmp41_) : NULL);
	steam_launcher = _tmp42_;
	has_games = FALSE;
	_tmp43_ = steam_launcher;
	if (_tmp43_ != NULL) {
		gchar* tool_name = NULL;
		gchar* _tmp44_;
		_tmp44_ = proton_plus_services_install_job_get_usage_identifier (job);
		tool_name = _tmp44_;
		{
			GeeList* _game_list = NULL;
			ProtonPlusModelsLaunchersSteam* _tmp45_;
			const gchar* _tmp46_;
			GeeList* _tmp47_;
			gint _game_size = 0;
			GeeList* _tmp48_;
			gint _tmp49_;
			gint _tmp50_;
			gint _game_index = 0;
			_tmp45_ = steam_launcher;
			_tmp46_ = tool_name;
			_tmp47_ = proton_plus_models_launchers_steam_get_compatibility_tool_usage_games (G_TYPE_CHECK_INSTANCE_CAST (_tmp45_, PROTON_PLUS_MODELS_LAUNCHERS_TYPE_STEAM, ProtonPlusModelsLaunchersSteam), _tmp46_);
			_game_list = _tmp47_;
			_tmp48_ = _game_list;
			_tmp49_ = gee_collection_get_size ((GeeCollection*) _tmp48_);
			_tmp50_ = _tmp49_;
			_game_size = _tmp50_;
			_game_index = -1;
			while (TRUE) {
				gint _tmp51_;
				gint _tmp52_;
				ProtonPlusModelsGame* game = NULL;
				GeeList* _tmp53_;
				gpointer _tmp54_;
				ProtonPlusWidgetsToolsGameRow* row = NULL;
				ProtonPlusModelsGame* _tmp55_;
				ProtonPlusWidgetsToolsGameRow* _tmp56_;
				ProtonPlusWidgetsToolsGameRow* _tmp57_;
				GtkListBox* _tmp58_;
				ProtonPlusWidgetsToolsGameRow* _tmp59_;
				_game_index = _game_index + 1;
				_tmp51_ = _game_index;
				_tmp52_ = _game_size;
				if (!(_tmp51_ < _tmp52_)) {
					break;
				}
				_tmp53_ = _game_list;
				_tmp54_ = gee_list_get (_tmp53_, _game_index);
				game = (ProtonPlusModelsGame*) _tmp54_;
				_tmp55_ = game;
				_tmp56_ = proton_plus_widgets_tools_game_row_new (_tmp55_);
				g_object_ref_sink (_tmp56_);
				row = _tmp56_;
				_tmp57_ = row;
				g_signal_connect_object ((GObject*) _tmp57_, "notify::selected", (GCallback) _proton_plus_widgets_tools_release_games_dialog_update_selection_state_g_object_notify, self, 0);
				_tmp58_ = self->priv->list_box;
				_tmp59_ = row;
				gtk_list_box_append (_tmp58_, (GtkWidget*) _tmp59_);
				has_games = TRUE;
				_g_object_unref0 (row);
				_g_object_unref0 (game);
			}
			_g_object_unref0 (_game_list);
		}
		_g_free0 (tool_name);
	}
	if (has_games) {
		GtkBox* games_content = NULL;
		GtkBox* _tmp60_ = NULL;
		GtkBox* _tmp61_;
		GtkListBox* _tmp62_;
		AdwClamp* games_clamp = NULL;
		GtkBox* _tmp63_;
		GtkWidget* _tmp64_;
		AdwClamp* _tmp65_ = NULL;
		AdwClamp* _tmp66_;
		GtkWidget* _tmp67_;
		GtkScrolledWindow* _tmp68_ = NULL;
		_tmp60_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
		gtk_widget_set_margin_start ((GtkWidget*) _tmp60_, 12);
		gtk_widget_set_margin_end ((GtkWidget*) _tmp60_, 12);
		gtk_widget_set_margin_top ((GtkWidget*) _tmp60_, 24);
		gtk_widget_set_margin_bottom ((GtkWidget*) _tmp60_, 24);
		g_object_ref_sink (_tmp60_);
		games_content = _tmp60_;
		_tmp61_ = games_content;
		_tmp62_ = self->priv->list_box;
		gtk_box_append (_tmp61_, (GtkWidget*) _tmp62_);
		_tmp63_ = games_content;
		_tmp64_ = _g_object_ref0 ((GtkWidget*) _tmp63_);
		_tmp65_ = (AdwClamp*) adw_clamp_new ();
		adw_clamp_set_maximum_size (_tmp65_, 720);
		adw_clamp_set_tightening_threshold (_tmp65_, 600);
		adw_clamp_set_child (_tmp65_, _tmp64_);
		_g_object_unref0 (_tmp64_);
		g_object_ref_sink (_tmp65_);
		games_clamp = _tmp65_;
		_tmp66_ = games_clamp;
		_tmp67_ = _g_object_ref0 ((GtkWidget*) _tmp66_);
		_tmp68_ = (GtkScrolledWindow*) gtk_scrolled_window_new ();
		gtk_widget_set_vexpand ((GtkWidget*) _tmp68_, TRUE);
		g_object_set (_tmp68_, "hscrollbar-policy", GTK_POLICY_NEVER, NULL);
		g_object_set (_tmp68_, "vscrollbar-policy", GTK_POLICY_AUTOMATIC, NULL);
		gtk_scrolled_window_set_child (_tmp68_, _tmp67_);
		_g_object_unref0 (_tmp67_);
		g_object_ref_sink (_tmp68_);
		_g_object_unref0 (content);
		content = (GtkWidget*) _tmp68_;
		_g_object_unref0 (games_clamp);
		_g_object_unref0 (games_content);
	} else {
		gchar* _tmp69_;
		gchar* _tmp70_;
		AdwStatusPage* _tmp71_ = NULL;
		_tmp69_ = g_strdup (_ ("No Games Use This Tool"));
		_tmp70_ = g_strdup ("gamepad-symbolic");
		_tmp71_ = (AdwStatusPage*) adw_status_page_new ();
		adw_status_page_set_title (_tmp71_, _tmp69_);
		_g_free0 (_tmp69_);
		adw_status_page_set_icon_name (_tmp71_, _tmp70_);
		_g_free0 (_tmp70_);
		gtk_widget_set_vexpand ((GtkWidget*) _tmp71_, TRUE);
		g_object_ref_sink (_tmp71_);
		_g_object_unref0 (content);
		content = (GtkWidget*) _tmp71_;
	}
	_tmp72_ = (AdwToolbarView*) adw_toolbar_view_new ();
	g_object_ref_sink (_tmp72_);
	toolbar_view = _tmp72_;
	_tmp73_ = header_bar;
	adw_toolbar_view_add_top_bar (toolbar_view, (GtkWidget*) _tmp73_);
	_tmp74_ = content;
	adw_toolbar_view_set_content (toolbar_view, _tmp74_);
	adw_dialog_set_content_width ((AdwDialog*) self, 720);
	adw_dialog_set_content_height ((AdwDialog*) self, 600);
	adw_dialog_set_can_close ((AdwDialog*) self, TRUE);
	adw_dialog_set_child ((AdwDialog*) self, (GtkWidget*) toolbar_view);
	proton_plus_widgets_tools_release_games_dialog_update_selection_state (self);
	_g_object_unref0 (toolbar_view);
	_g_object_unref0 (content);
	_g_object_unref0 (steam_launcher);
	_g_object_unref0 (select_all_row);
	_g_object_unref0 (migrate_button_content);
	_g_object_unref0 (header_bar);
	_g_object_unref0 (window_title);
	return self;
}

ProtonPlusWidgetsToolsReleaseGamesDialog*
proton_plus_widgets_tools_release_games_dialog_new (ProtonPlusServicesInstallJob* job)
{
	return proton_plus_widgets_tools_release_games_dialog_construct (PROTON_PLUS_WIDGETS_TOOLS_TYPE_RELEASE_GAMES_DIALOG, job);
}

static void
proton_plus_widgets_tools_release_games_dialog_update_selection_state (ProtonPlusWidgetsToolsReleaseGamesDialog* self)
{
	gint selected = 0;
	gint total = 0;
	GtkWidget* child = NULL;
	GtkListBox* _tmp0_;
	GtkWidget* _tmp1_;
	GtkWidget* _tmp2_;
	gboolean _tmp13_ = FALSE;
	GtkCheckButton* _tmp14_;
	gboolean _tmp15_ = FALSE;
	GtkCheckButton* _tmp16_;
	GtkCheckButton* _tmp17_;
	GtkButton* _tmp18_;
	g_return_if_fail (self != NULL);
	if (self->priv->updating_select_all) {
		return;
	}
	selected = 0;
	total = 0;
	_tmp0_ = self->priv->list_box;
	_tmp1_ = gtk_widget_get_first_child ((GtkWidget*) _tmp0_);
	_tmp2_ = _g_object_ref0 (_tmp1_);
	child = _tmp2_;
	while (TRUE) {
		GtkWidget* _tmp3_;
		GtkWidget* _tmp4_;
		GtkWidget* _tmp10_;
		GtkWidget* _tmp11_;
		GtkWidget* _tmp12_;
		_tmp3_ = child;
		if (!(_tmp3_ != NULL)) {
			break;
		}
		_tmp4_ = child;
		if (PROTON_PLUS_WIDGETS_TOOLS_IS_GAME_ROW (_tmp4_)) {
			gint _tmp5_;
			GtkWidget* _tmp6_;
			gboolean _tmp7_;
			gboolean _tmp8_;
			_tmp5_ = total;
			total = _tmp5_ + 1;
			_tmp6_ = child;
			_tmp7_ = proton_plus_widgets_tools_game_row_get_selected (G_TYPE_CHECK_INSTANCE_CAST (_tmp6_, PROTON_PLUS_WIDGETS_TOOLS_TYPE_GAME_ROW, ProtonPlusWidgetsToolsGameRow));
			_tmp8_ = _tmp7_;
			if (_tmp8_) {
				gint _tmp9_;
				_tmp9_ = selected;
				selected = _tmp9_ + 1;
			}
		}
		_tmp10_ = child;
		_tmp11_ = gtk_widget_get_next_sibling (_tmp10_);
		_tmp12_ = _g_object_ref0 (_tmp11_);
		_g_object_unref0 (child);
		child = _tmp12_;
	}
	self->priv->updating_select_all = TRUE;
	if (selected > 0) {
		_tmp13_ = selected < total;
	} else {
		_tmp13_ = FALSE;
	}
	_tmp14_ = self->priv->check_button;
	gtk_check_button_set_inconsistent (_tmp14_, _tmp13_);
	if (total > 0) {
		_tmp15_ = selected == total;
	} else {
		_tmp15_ = FALSE;
	}
	_tmp16_ = self->priv->check_button;
	gtk_check_button_set_active (_tmp16_, _tmp15_);
	_tmp17_ = self->priv->check_button;
	gtk_widget_set_sensitive ((GtkWidget*) _tmp17_, total > 0);
	self->priv->updating_select_all = FALSE;
	_tmp18_ = self->priv->migrate_button;
	gtk_widget_set_visible ((GtkWidget*) _tmp18_, selected > 0);
	_g_object_unref0 (child);
}

static GeeArrayList*
proton_plus_widgets_tools_release_games_dialog_get_selected_games (ProtonPlusWidgetsToolsReleaseGamesDialog* self)
{
	GeeArrayList* selected_games = NULL;
	GeeArrayList* _tmp0_;
	GtkWidget* child = NULL;
	GtkListBox* _tmp1_;
	GtkWidget* _tmp2_;
	GtkWidget* _tmp3_;
	GeeArrayList* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = gee_array_list_new (PROTON_PLUS_MODELS_TYPE_GAME, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, NULL, NULL, NULL);
	selected_games = _tmp0_;
	_tmp1_ = self->priv->list_box;
	_tmp2_ = gtk_widget_get_first_child ((GtkWidget*) _tmp1_);
	_tmp3_ = _g_object_ref0 (_tmp2_);
	child = _tmp3_;
	while (TRUE) {
		GtkWidget* _tmp4_;
		gboolean _tmp5_ = FALSE;
		GtkWidget* _tmp6_;
		GtkWidget* _tmp14_;
		GtkWidget* _tmp15_;
		GtkWidget* _tmp16_;
		_tmp4_ = child;
		if (!(_tmp4_ != NULL)) {
			break;
		}
		_tmp6_ = child;
		if (PROTON_PLUS_WIDGETS_TOOLS_IS_GAME_ROW (_tmp6_)) {
			GtkWidget* _tmp7_;
			gboolean _tmp8_;
			gboolean _tmp9_;
			_tmp7_ = child;
			_tmp8_ = proton_plus_widgets_tools_game_row_get_selected (G_TYPE_CHECK_INSTANCE_CAST (_tmp7_, PROTON_PLUS_WIDGETS_TOOLS_TYPE_GAME_ROW, ProtonPlusWidgetsToolsGameRow));
			_tmp9_ = _tmp8_;
			_tmp5_ = _tmp9_;
		} else {
			_tmp5_ = FALSE;
		}
		if (_tmp5_) {
			GeeArrayList* _tmp10_;
			GtkWidget* _tmp11_;
			ProtonPlusModelsGame* _tmp12_;
			ProtonPlusModelsGame* _tmp13_;
			_tmp10_ = selected_games;
			_tmp11_ = child;
			_tmp12_ = proton_plus_widgets_tools_game_row_get_game (G_TYPE_CHECK_INSTANCE_CAST (_tmp11_, PROTON_PLUS_WIDGETS_TOOLS_TYPE_GAME_ROW, ProtonPlusWidgetsToolsGameRow));
			_tmp13_ = _tmp12_;
			gee_abstract_collection_add ((GeeAbstractCollection*) _tmp10_, _tmp13_);
		}
		_tmp14_ = child;
		_tmp15_ = gtk_widget_get_next_sibling (_tmp14_);
		_tmp16_ = _g_object_ref0 (_tmp15_);
		_g_object_unref0 (child);
		child = _tmp16_;
	}
	result = selected_games;
	_g_object_unref0 (child);
	return result;
}

static void
proton_plus_widgets_tools_release_games_dialog_class_init (ProtonPlusWidgetsToolsReleaseGamesDialogClass * klass,
                                                           gpointer klass_data)
{
	proton_plus_widgets_tools_release_games_dialog_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &ProtonPlusWidgetsToolsReleaseGamesDialog_private_offset);
	G_OBJECT_CLASS (klass)->finalize = proton_plus_widgets_tools_release_games_dialog_finalize;
	proton_plus_widgets_tools_release_games_dialog_signals[PROTON_PLUS_WIDGETS_TOOLS_RELEASE_GAMES_DIALOG_MIGRATE_REQUESTED_SIGNAL] = g_signal_new ("migrate-requested", PROTON_PLUS_WIDGETS_TOOLS_TYPE_RELEASE_GAMES_DIALOG, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__OBJECT, G_TYPE_NONE, 1, GEE_TYPE_ARRAY_LIST);
}

static void
proton_plus_widgets_tools_release_games_dialog_instance_init (ProtonPlusWidgetsToolsReleaseGamesDialog * self,
                                                              gpointer klass)
{
	self->priv = proton_plus_widgets_tools_release_games_dialog_get_instance_private (self);
	self->priv->updating_select_all = FALSE;
}

static void
proton_plus_widgets_tools_release_games_dialog_finalize (GObject * obj)
{
	ProtonPlusWidgetsToolsReleaseGamesDialog * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, PROTON_PLUS_WIDGETS_TOOLS_TYPE_RELEASE_GAMES_DIALOG, ProtonPlusWidgetsToolsReleaseGamesDialog);
	_g_object_unref0 (self->priv->list_box);
	_g_object_unref0 (self->priv->check_button);
	_g_object_unref0 (self->priv->migrate_button);
	G_OBJECT_CLASS (proton_plus_widgets_tools_release_games_dialog_parent_class)->finalize (obj);
}

static GType
proton_plus_widgets_tools_release_games_dialog_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (ProtonPlusWidgetsToolsReleaseGamesDialogClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) proton_plus_widgets_tools_release_games_dialog_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ProtonPlusWidgetsToolsReleaseGamesDialog), 0, (GInstanceInitFunc) proton_plus_widgets_tools_release_games_dialog_instance_init, NULL };
	GType proton_plus_widgets_tools_release_games_dialog_type_id;
	proton_plus_widgets_tools_release_games_dialog_type_id = g_type_register_static (adw_dialog_get_type (), "ProtonPlusWidgetsToolsReleaseGamesDialog", &g_define_type_info, 0);
	ProtonPlusWidgetsToolsReleaseGamesDialog_private_offset = g_type_add_instance_private (proton_plus_widgets_tools_release_games_dialog_type_id, sizeof (ProtonPlusWidgetsToolsReleaseGamesDialogPrivate));
	return proton_plus_widgets_tools_release_games_dialog_type_id;
}

GType
proton_plus_widgets_tools_release_games_dialog_get_type (void)
{
	static volatile gsize proton_plus_widgets_tools_release_games_dialog_type_id__once = 0;
	if (g_once_init_enter (&proton_plus_widgets_tools_release_games_dialog_type_id__once)) {
		GType proton_plus_widgets_tools_release_games_dialog_type_id;
		proton_plus_widgets_tools_release_games_dialog_type_id = proton_plus_widgets_tools_release_games_dialog_get_type_once ();
		g_once_init_leave (&proton_plus_widgets_tools_release_games_dialog_type_id__once, proton_plus_widgets_tools_release_games_dialog_type_id);
	}
	return proton_plus_widgets_tools_release_games_dialog_type_id__once;
}

