/* downloads-box.c generated by valac 0.56.19, the Vala compiler
 * generated from downloads-box.vala, do not modify */

#include <gtk/gtk.h>
#include <glib-object.h>
#include <adwaita.h>
#include <glib.h>
#include <glib/gi18n-lib.h>
#include <gee.h>
#include <stdlib.h>
#include <string.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
#if !defined(VALA_EXTERN)
#if defined(_MSC_VER)
#define VALA_EXTERN __declspec(dllexport) extern
#elif __GNUC__ >= 4
#define VALA_EXTERN __attribute__((visibility("default"))) extern
#else
#define VALA_EXTERN extern
#endif
#endif

#define PROTON_PLUS_WIDGETS_TYPE_DOWNLOADS_BOX (proton_plus_widgets_downloads_box_get_type ())
#define PROTON_PLUS_WIDGETS_DOWNLOADS_BOX(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PROTON_PLUS_WIDGETS_TYPE_DOWNLOADS_BOX, ProtonPlusWidgetsDownloadsBox))
#define PROTON_PLUS_WIDGETS_DOWNLOADS_BOX_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PROTON_PLUS_WIDGETS_TYPE_DOWNLOADS_BOX, ProtonPlusWidgetsDownloadsBoxClass))
#define PROTON_PLUS_WIDGETS_IS_DOWNLOADS_BOX(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PROTON_PLUS_WIDGETS_TYPE_DOWNLOADS_BOX))
#define PROTON_PLUS_WIDGETS_IS_DOWNLOADS_BOX_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PROTON_PLUS_WIDGETS_TYPE_DOWNLOADS_BOX))
#define PROTON_PLUS_WIDGETS_DOWNLOADS_BOX_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PROTON_PLUS_WIDGETS_TYPE_DOWNLOADS_BOX, ProtonPlusWidgetsDownloadsBoxClass))

typedef struct _ProtonPlusWidgetsDownloadsBox ProtonPlusWidgetsDownloadsBox;
typedef struct _ProtonPlusWidgetsDownloadsBoxClass ProtonPlusWidgetsDownloadsBoxClass;
typedef struct _ProtonPlusWidgetsDownloadsBoxPrivate ProtonPlusWidgetsDownloadsBoxPrivate;
enum  {
	PROTON_PLUS_WIDGETS_DOWNLOADS_BOX_0_PROPERTY,
	PROTON_PLUS_WIDGETS_DOWNLOADS_BOX_NUM_PROPERTIES
};
static GParamSpec* proton_plus_widgets_downloads_box_properties[PROTON_PLUS_WIDGETS_DOWNLOADS_BOX_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

#define PROTON_PLUS_MODELS_TYPE_DOWNLOAD_MANAGER (proton_plus_models_download_manager_get_type ())
#define PROTON_PLUS_MODELS_DOWNLOAD_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PROTON_PLUS_MODELS_TYPE_DOWNLOAD_MANAGER, ProtonPlusModelsDownloadManager))
#define PROTON_PLUS_MODELS_DOWNLOAD_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PROTON_PLUS_MODELS_TYPE_DOWNLOAD_MANAGER, ProtonPlusModelsDownloadManagerClass))
#define PROTON_PLUS_MODELS_IS_DOWNLOAD_MANAGER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PROTON_PLUS_MODELS_TYPE_DOWNLOAD_MANAGER))
#define PROTON_PLUS_MODELS_IS_DOWNLOAD_MANAGER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PROTON_PLUS_MODELS_TYPE_DOWNLOAD_MANAGER))
#define PROTON_PLUS_MODELS_DOWNLOAD_MANAGER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PROTON_PLUS_MODELS_TYPE_DOWNLOAD_MANAGER, ProtonPlusModelsDownloadManagerClass))

typedef struct _ProtonPlusModelsDownloadManager ProtonPlusModelsDownloadManager;
typedef struct _ProtonPlusModelsDownloadManagerClass ProtonPlusModelsDownloadManagerClass;

#define PROTON_PLUS_MODELS_TYPE_BASE_RELEASE (proton_plus_models_base_release_get_type ())
#define PROTON_PLUS_MODELS_BASE_RELEASE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PROTON_PLUS_MODELS_TYPE_BASE_RELEASE, ProtonPlusModelsBaseRelease))
#define PROTON_PLUS_MODELS_BASE_RELEASE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PROTON_PLUS_MODELS_TYPE_BASE_RELEASE, ProtonPlusModelsBaseReleaseClass))
#define PROTON_PLUS_MODELS_IS_BASE_RELEASE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PROTON_PLUS_MODELS_TYPE_BASE_RELEASE))
#define PROTON_PLUS_MODELS_IS_BASE_RELEASE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PROTON_PLUS_MODELS_TYPE_BASE_RELEASE))
#define PROTON_PLUS_MODELS_BASE_RELEASE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PROTON_PLUS_MODELS_TYPE_BASE_RELEASE, ProtonPlusModelsBaseReleaseClass))

typedef struct _ProtonPlusModelsBaseRelease ProtonPlusModelsBaseRelease;
typedef struct _ProtonPlusModelsBaseReleaseClass ProtonPlusModelsBaseReleaseClass;

#define PROTON_PLUS_WIDGETS_TYPE_DOWNLOAD_ROW (proton_plus_widgets_download_row_get_type ())
#define PROTON_PLUS_WIDGETS_DOWNLOAD_ROW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PROTON_PLUS_WIDGETS_TYPE_DOWNLOAD_ROW, ProtonPlusWidgetsDownloadRow))
#define PROTON_PLUS_WIDGETS_DOWNLOAD_ROW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PROTON_PLUS_WIDGETS_TYPE_DOWNLOAD_ROW, ProtonPlusWidgetsDownloadRowClass))
#define PROTON_PLUS_WIDGETS_IS_DOWNLOAD_ROW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PROTON_PLUS_WIDGETS_TYPE_DOWNLOAD_ROW))
#define PROTON_PLUS_WIDGETS_IS_DOWNLOAD_ROW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PROTON_PLUS_WIDGETS_TYPE_DOWNLOAD_ROW))
#define PROTON_PLUS_WIDGETS_DOWNLOAD_ROW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PROTON_PLUS_WIDGETS_TYPE_DOWNLOAD_ROW, ProtonPlusWidgetsDownloadRowClass))

typedef struct _ProtonPlusWidgetsDownloadRow ProtonPlusWidgetsDownloadRow;
typedef struct _ProtonPlusWidgetsDownloadRowClass ProtonPlusWidgetsDownloadRowClass;

struct _ProtonPlusWidgetsDownloadsBox {
	GtkBox parent_instance;
	ProtonPlusWidgetsDownloadsBoxPrivate * priv;
};

struct _ProtonPlusWidgetsDownloadsBoxClass {
	GtkBoxClass parent_class;
};

struct _ProtonPlusWidgetsDownloadsBoxPrivate {
	GtkListBox* in_progress_list_box;
	GtkListBox* completed_list_box;
	GtkBox* in_progress_box;
	GtkBox* completed_box;
	AdwStatusPage* status_page;
	AdwClamp* clamp;
	GtkScrolledWindow* scrolled_window;
	GtkBox* completed_header_box;
	GtkButton* clear_button;
};

static gint ProtonPlusWidgetsDownloadsBox_private_offset;
static gpointer proton_plus_widgets_downloads_box_parent_class = NULL;

VALA_EXTERN GType proton_plus_widgets_downloads_box_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ProtonPlusWidgetsDownloadsBox, g_object_unref)
VALA_EXTERN ProtonPlusWidgetsDownloadsBox* proton_plus_widgets_downloads_box_new (void);
VALA_EXTERN ProtonPlusWidgetsDownloadsBox* proton_plus_widgets_downloads_box_construct (GType object_type);
static void proton_plus_widgets_downloads_box_on_clear_clicked (ProtonPlusWidgetsDownloadsBox* self);
static void _proton_plus_widgets_downloads_box_on_clear_clicked_gtk_button_clicked (GtkButton* _sender,
                                                                             gpointer self);
VALA_EXTERN GType proton_plus_models_download_manager_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ProtonPlusModelsDownloadManager, g_object_unref)
VALA_EXTERN ProtonPlusModelsDownloadManager* proton_plus_models_download_manager_get_instance (void);
VALA_EXTERN GType proton_plus_models_base_release_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ProtonPlusModelsBaseRelease, g_object_unref)
static void proton_plus_widgets_downloads_box_on_download_added (ProtonPlusWidgetsDownloadsBox* self,
                                                          ProtonPlusModelsBaseRelease* release);
static void _proton_plus_widgets_downloads_box_on_download_added_proton_plus_models_download_manager_download_added (ProtonPlusModelsDownloadManager* _sender,
                                                                                                              ProtonPlusModelsBaseRelease* release,
                                                                                                              gpointer self);
static void proton_plus_widgets_downloads_box_on_download_removed (ProtonPlusWidgetsDownloadsBox* self,
                                                            ProtonPlusModelsBaseRelease* release);
static void _proton_plus_widgets_downloads_box_on_download_removed_proton_plus_models_download_manager_download_removed (ProtonPlusModelsDownloadManager* _sender,
                                                                                                                  ProtonPlusModelsBaseRelease* release,
                                                                                                                  gpointer self);
static void proton_plus_widgets_downloads_box_on_download_finished (ProtonPlusWidgetsDownloadsBox* self,
                                                             ProtonPlusModelsBaseRelease* release,
                                                             gboolean success);
static void _proton_plus_widgets_downloads_box_on_download_finished_proton_plus_models_download_manager_download_finished (ProtonPlusModelsDownloadManager* _sender,
                                                                                                                    ProtonPlusModelsBaseRelease* release,
                                                                                                                    gboolean success,
                                                                                                                    gpointer self);
static void proton_plus_widgets_downloads_box_update_visibility (ProtonPlusWidgetsDownloadsBox* self);
VALA_EXTERN GeeArrayList* proton_plus_models_download_manager_get_active_downloads (ProtonPlusModelsDownloadManager* self);
static void proton_plus_widgets_downloads_box_add_download_row (ProtonPlusWidgetsDownloadsBox* self,
                                                         ProtonPlusModelsBaseRelease* release,
                                                         GtkListBox* list_box);
VALA_EXTERN GeeArrayList* proton_plus_models_download_manager_get_history (ProtonPlusModelsDownloadManager* self);
VALA_EXTERN GType proton_plus_widgets_download_row_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (ProtonPlusWidgetsDownloadRow, g_object_unref)
VALA_EXTERN ProtonPlusModelsBaseRelease* proton_plus_widgets_download_row_get_release (ProtonPlusWidgetsDownloadRow* self);
VALA_EXTERN const gchar* proton_plus_models_base_release_get_title (ProtonPlusModelsBaseRelease* self);
VALA_EXTERN void proton_plus_models_download_manager_clear_history (ProtonPlusModelsDownloadManager* self);
VALA_EXTERN ProtonPlusWidgetsDownloadRow* proton_plus_widgets_download_row_new (ProtonPlusModelsBaseRelease* release);
VALA_EXTERN ProtonPlusWidgetsDownloadRow* proton_plus_widgets_download_row_construct (GType object_type,
                                                                          ProtonPlusModelsBaseRelease* release);
static void proton_plus_widgets_downloads_box_finalize (GObject * obj);
static GType proton_plus_widgets_downloads_box_get_type_once (void);

static inline gpointer
proton_plus_widgets_downloads_box_get_instance_private (ProtonPlusWidgetsDownloadsBox* self)
{
	return G_STRUCT_MEMBER_P (self, ProtonPlusWidgetsDownloadsBox_private_offset);
}

static void
_proton_plus_widgets_downloads_box_on_clear_clicked_gtk_button_clicked (GtkButton* _sender,
                                                                        gpointer self)
{
	proton_plus_widgets_downloads_box_on_clear_clicked ((ProtonPlusWidgetsDownloadsBox*) self);
}

static void
_proton_plus_widgets_downloads_box_on_download_added_proton_plus_models_download_manager_download_added (ProtonPlusModelsDownloadManager* _sender,
                                                                                                         ProtonPlusModelsBaseRelease* release,
                                                                                                         gpointer self)
{
	proton_plus_widgets_downloads_box_on_download_added ((ProtonPlusWidgetsDownloadsBox*) self, release);
}

static void
_proton_plus_widgets_downloads_box_on_download_removed_proton_plus_models_download_manager_download_removed (ProtonPlusModelsDownloadManager* _sender,
                                                                                                             ProtonPlusModelsBaseRelease* release,
                                                                                                             gpointer self)
{
	proton_plus_widgets_downloads_box_on_download_removed ((ProtonPlusWidgetsDownloadsBox*) self, release);
}

static void
_proton_plus_widgets_downloads_box_on_download_finished_proton_plus_models_download_manager_download_finished (ProtonPlusModelsDownloadManager* _sender,
                                                                                                               ProtonPlusModelsBaseRelease* release,
                                                                                                               gboolean success,
                                                                                                               gpointer self)
{
	proton_plus_widgets_downloads_box_on_download_finished ((ProtonPlusWidgetsDownloadsBox*) self, release, success);
}

ProtonPlusWidgetsDownloadsBox*
proton_plus_widgets_downloads_box_construct (GType object_type)
{
	ProtonPlusWidgetsDownloadsBox * self = NULL;
	AdwStatusPage* _tmp0_;
	AdwStatusPage* _tmp1_;
	AdwStatusPage* _tmp2_;
	AdwStatusPage* _tmp3_;
	AdwStatusPage* _tmp4_;
	GtkLabel* in_progress_label = NULL;
	GtkLabel* _tmp5_;
	GtkLabel* _tmp6_;
	GtkLabel* _tmp7_;
	GtkListBox* _tmp8_;
	GtkListBox* _tmp9_;
	GtkListBox* _tmp10_;
	GtkBox* _tmp11_;
	GtkBox* _tmp12_;
	GtkLabel* _tmp13_;
	GtkBox* _tmp14_;
	GtkListBox* _tmp15_;
	GtkLabel* completed_label = NULL;
	GtkLabel* _tmp16_;
	GtkLabel* _tmp17_;
	GtkLabel* _tmp18_;
	GtkBox* spacer = NULL;
	GtkBox* _tmp19_;
	GtkBox* _tmp20_;
	GtkButton* _tmp21_;
	GtkButton* _tmp22_;
	GtkButton* _tmp23_;
	GtkButton* _tmp24_;
	GtkButton* _tmp25_;
	GtkBox* _tmp26_;
	GtkBox* _tmp27_;
	GtkLabel* _tmp28_;
	GtkBox* _tmp29_;
	GtkBox* _tmp30_;
	GtkBox* _tmp31_;
	GtkButton* _tmp32_;
	GtkListBox* _tmp33_;
	GtkListBox* _tmp34_;
	GtkListBox* _tmp35_;
	GtkBox* _tmp36_;
	GtkBox* _tmp37_;
	GtkBox* _tmp38_;
	GtkBox* _tmp39_;
	GtkListBox* _tmp40_;
	GtkBox* content_box = NULL;
	GtkBox* _tmp41_;
	GtkBox* _tmp42_;
	GtkBox* _tmp43_;
	GtkBox* _tmp44_;
	GtkBox* _tmp45_;
	AdwClamp* _tmp46_;
	AdwClamp* _tmp47_;
	AdwClamp* _tmp48_;
	GtkBox* _tmp49_;
	GtkScrolledWindow* _tmp50_;
	GtkScrolledWindow* _tmp51_;
	AdwClamp* _tmp52_;
	GtkScrolledWindow* _tmp53_;
	GtkScrolledWindow* _tmp54_;
	GtkScrolledWindow* _tmp55_;
	AdwStatusPage* _tmp56_;
	ProtonPlusModelsDownloadManager* _tmp57_;
	ProtonPlusModelsDownloadManager* _tmp58_;
	ProtonPlusModelsDownloadManager* _tmp59_;
	ProtonPlusModelsDownloadManager* _tmp60_;
	ProtonPlusModelsDownloadManager* _tmp61_;
	ProtonPlusModelsDownloadManager* _tmp62_;
	self = (ProtonPlusWidgetsDownloadsBox*) g_object_new (object_type, "orientation", GTK_ORIENTATION_VERTICAL, "spacing", 0, NULL);
	gtk_widget_set_vexpand ((GtkWidget*) self, TRUE);
	_tmp0_ = (AdwStatusPage*) adw_status_page_new ();
	g_object_ref_sink (_tmp0_);
	_g_object_unref0 (self->priv->status_page);
	self->priv->status_page = _tmp0_;
	_tmp1_ = self->priv->status_page;
	adw_status_page_set_title (_tmp1_, _ ("No active downloads"));
	_tmp2_ = self->priv->status_page;
	adw_status_page_set_description (_tmp2_, _ ("Your downloads will appear here."));
	_tmp3_ = self->priv->status_page;
	adw_status_page_set_icon_name (_tmp3_, "download-symbolic");
	_tmp4_ = self->priv->status_page;
	gtk_widget_set_vexpand ((GtkWidget*) _tmp4_, TRUE);
	_tmp5_ = (GtkLabel*) gtk_label_new (_ ("In-Progress"));
	g_object_ref_sink (_tmp5_);
	in_progress_label = _tmp5_;
	_tmp6_ = in_progress_label;
	gtk_widget_add_css_class ((GtkWidget*) _tmp6_, "heading");
	_tmp7_ = in_progress_label;
	gtk_widget_set_halign ((GtkWidget*) _tmp7_, GTK_ALIGN_START);
	_tmp8_ = (GtkListBox*) gtk_list_box_new ();
	g_object_ref_sink (_tmp8_);
	_g_object_unref0 (self->priv->in_progress_list_box);
	self->priv->in_progress_list_box = _tmp8_;
	_tmp9_ = self->priv->in_progress_list_box;
	gtk_list_box_set_selection_mode (_tmp9_, GTK_SELECTION_NONE);
	_tmp10_ = self->priv->in_progress_list_box;
	gtk_widget_add_css_class ((GtkWidget*) _tmp10_, "boxed-list");
	_tmp11_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
	g_object_ref_sink (_tmp11_);
	_g_object_unref0 (self->priv->in_progress_box);
	self->priv->in_progress_box = _tmp11_;
	_tmp12_ = self->priv->in_progress_box;
	_tmp13_ = in_progress_label;
	gtk_box_append (_tmp12_, (GtkWidget*) _tmp13_);
	_tmp14_ = self->priv->in_progress_box;
	_tmp15_ = self->priv->in_progress_list_box;
	gtk_box_append (_tmp14_, (GtkWidget*) _tmp15_);
	_tmp16_ = (GtkLabel*) gtk_label_new (_ ("Completed"));
	g_object_ref_sink (_tmp16_);
	completed_label = _tmp16_;
	_tmp17_ = completed_label;
	gtk_widget_add_css_class ((GtkWidget*) _tmp17_, "heading");
	_tmp18_ = completed_label;
	gtk_widget_set_halign ((GtkWidget*) _tmp18_, GTK_ALIGN_START);
	_tmp19_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 0);
	g_object_ref_sink (_tmp19_);
	spacer = _tmp19_;
	_tmp20_ = spacer;
	gtk_widget_set_hexpand ((GtkWidget*) _tmp20_, TRUE);
	_tmp21_ = (GtkButton*) gtk_button_new_from_icon_name ("eraser-symbolic");
	g_object_ref_sink (_tmp21_);
	_g_object_unref0 (self->priv->clear_button);
	self->priv->clear_button = _tmp21_;
	_tmp22_ = self->priv->clear_button;
	gtk_widget_add_css_class ((GtkWidget*) _tmp22_, "flat");
	_tmp23_ = self->priv->clear_button;
	gtk_widget_add_css_class ((GtkWidget*) _tmp23_, "circular");
	_tmp24_ = self->priv->clear_button;
	gtk_widget_set_tooltip_text ((GtkWidget*) _tmp24_, _ ("Clear History"));
	_tmp25_ = self->priv->clear_button;
	g_signal_connect_object (_tmp25_, "clicked", (GCallback) _proton_plus_widgets_downloads_box_on_clear_clicked_gtk_button_clicked, self, 0);
	_tmp26_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
	g_object_ref_sink (_tmp26_);
	_g_object_unref0 (self->priv->completed_header_box);
	self->priv->completed_header_box = _tmp26_;
	_tmp27_ = self->priv->completed_header_box;
	_tmp28_ = completed_label;
	gtk_box_append (_tmp27_, (GtkWidget*) _tmp28_);
	_tmp29_ = self->priv->completed_header_box;
	_tmp30_ = spacer;
	gtk_box_append (_tmp29_, (GtkWidget*) _tmp30_);
	_tmp31_ = self->priv->completed_header_box;
	_tmp32_ = self->priv->clear_button;
	gtk_box_append (_tmp31_, (GtkWidget*) _tmp32_);
	_tmp33_ = (GtkListBox*) gtk_list_box_new ();
	g_object_ref_sink (_tmp33_);
	_g_object_unref0 (self->priv->completed_list_box);
	self->priv->completed_list_box = _tmp33_;
	_tmp34_ = self->priv->completed_list_box;
	gtk_list_box_set_selection_mode (_tmp34_, GTK_SELECTION_NONE);
	_tmp35_ = self->priv->completed_list_box;
	gtk_widget_add_css_class ((GtkWidget*) _tmp35_, "boxed-list");
	_tmp36_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_VERTICAL, 6);
	g_object_ref_sink (_tmp36_);
	_g_object_unref0 (self->priv->completed_box);
	self->priv->completed_box = _tmp36_;
	_tmp37_ = self->priv->completed_box;
	_tmp38_ = self->priv->completed_header_box;
	gtk_box_append (_tmp37_, (GtkWidget*) _tmp38_);
	_tmp39_ = self->priv->completed_box;
	_tmp40_ = self->priv->completed_list_box;
	gtk_box_append (_tmp39_, (GtkWidget*) _tmp40_);
	_tmp41_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_VERTICAL, 15);
	g_object_ref_sink (_tmp41_);
	content_box = _tmp41_;
	_tmp42_ = content_box;
	_tmp43_ = self->priv->in_progress_box;
	gtk_box_append (_tmp42_, (GtkWidget*) _tmp43_);
	_tmp44_ = content_box;
	_tmp45_ = self->priv->completed_box;
	gtk_box_append (_tmp44_, (GtkWidget*) _tmp45_);
	_tmp46_ = (AdwClamp*) adw_clamp_new ();
	g_object_ref_sink (_tmp46_);
	_g_object_unref0 (self->priv->clamp);
	self->priv->clamp = _tmp46_;
	_tmp47_ = self->priv->clamp;
	adw_clamp_set_maximum_size (_tmp47_, 975);
	_tmp48_ = self->priv->clamp;
	_tmp49_ = content_box;
	adw_clamp_set_child (_tmp48_, (GtkWidget*) _tmp49_);
	_tmp50_ = (GtkScrolledWindow*) gtk_scrolled_window_new ();
	g_object_ref_sink (_tmp50_);
	_g_object_unref0 (self->priv->scrolled_window);
	self->priv->scrolled_window = _tmp50_;
	_tmp51_ = self->priv->scrolled_window;
	_tmp52_ = self->priv->clamp;
	gtk_scrolled_window_set_child (_tmp51_, (GtkWidget*) _tmp52_);
	_tmp53_ = self->priv->scrolled_window;
	gtk_scrolled_window_set_policy (_tmp53_, GTK_POLICY_NEVER, GTK_POLICY_AUTOMATIC);
	_tmp54_ = self->priv->scrolled_window;
	gtk_widget_set_vexpand ((GtkWidget*) _tmp54_, TRUE);
	_tmp55_ = self->priv->scrolled_window;
	gtk_box_append ((GtkBox*) self, (GtkWidget*) _tmp55_);
	_tmp56_ = self->priv->status_page;
	gtk_box_append ((GtkBox*) self, (GtkWidget*) _tmp56_);
	_tmp57_ = proton_plus_models_download_manager_get_instance ();
	_tmp58_ = _tmp57_;
	g_signal_connect_object (_tmp58_, "download-added", (GCallback) _proton_plus_widgets_downloads_box_on_download_added_proton_plus_models_download_manager_download_added, self, 0);
	_tmp59_ = proton_plus_models_download_manager_get_instance ();
	_tmp60_ = _tmp59_;
	g_signal_connect_object (_tmp60_, "download-removed", (GCallback) _proton_plus_widgets_downloads_box_on_download_removed_proton_plus_models_download_manager_download_removed, self, 0);
	_tmp61_ = proton_plus_models_download_manager_get_instance ();
	_tmp62_ = _tmp61_;
	g_signal_connect_object (_tmp62_, "download-finished", (GCallback) _proton_plus_widgets_downloads_box_on_download_finished_proton_plus_models_download_manager_download_finished, self, 0);
	proton_plus_widgets_downloads_box_update_visibility (self);
	{
		GeeArrayList* _release_list = NULL;
		ProtonPlusModelsDownloadManager* _tmp63_;
		ProtonPlusModelsDownloadManager* _tmp64_;
		GeeArrayList* _tmp65_;
		GeeArrayList* _tmp66_;
		gint _release_size = 0;
		GeeArrayList* _tmp67_;
		gint _tmp68_;
		gint _tmp69_;
		gint _release_index = 0;
		_tmp63_ = proton_plus_models_download_manager_get_instance ();
		_tmp64_ = _tmp63_;
		_tmp65_ = proton_plus_models_download_manager_get_active_downloads (_tmp64_);
		_tmp66_ = _tmp65_;
		_release_list = _tmp66_;
		_tmp67_ = _release_list;
		_tmp68_ = gee_abstract_collection_get_size ((GeeAbstractCollection*) _tmp67_);
		_tmp69_ = _tmp68_;
		_release_size = _tmp69_;
		_release_index = -1;
		while (TRUE) {
			gint _tmp70_;
			gint _tmp71_;
			ProtonPlusModelsBaseRelease* release = NULL;
			GeeArrayList* _tmp72_;
			gpointer _tmp73_;
			ProtonPlusModelsBaseRelease* _tmp74_;
			GtkListBox* _tmp75_;
			_release_index = _release_index + 1;
			_tmp70_ = _release_index;
			_tmp71_ = _release_size;
			if (!(_tmp70_ < _tmp71_)) {
				break;
			}
			_tmp72_ = _release_list;
			_tmp73_ = gee_abstract_list_get ((GeeAbstractList*) _tmp72_, _release_index);
			release = (ProtonPlusModelsBaseRelease*) _tmp73_;
			_tmp74_ = release;
			_tmp75_ = self->priv->in_progress_list_box;
			proton_plus_widgets_downloads_box_add_download_row (self, _tmp74_, _tmp75_);
			_g_object_unref0 (release);
		}
	}
	{
		GeeArrayList* _release_list = NULL;
		ProtonPlusModelsDownloadManager* _tmp76_;
		ProtonPlusModelsDownloadManager* _tmp77_;
		GeeArrayList* _tmp78_;
		GeeArrayList* _tmp79_;
		gint _release_size = 0;
		GeeArrayList* _tmp80_;
		gint _tmp81_;
		gint _tmp82_;
		gint _release_index = 0;
		_tmp76_ = proton_plus_models_download_manager_get_instance ();
		_tmp77_ = _tmp76_;
		_tmp78_ = proton_plus_models_download_manager_get_history (_tmp77_);
		_tmp79_ = _tmp78_;
		_release_list = _tmp79_;
		_tmp80_ = _release_list;
		_tmp81_ = gee_abstract_collection_get_size ((GeeAbstractCollection*) _tmp80_);
		_tmp82_ = _tmp81_;
		_release_size = _tmp82_;
		_release_index = -1;
		while (TRUE) {
			gint _tmp83_;
			gint _tmp84_;
			ProtonPlusModelsBaseRelease* release = NULL;
			GeeArrayList* _tmp85_;
			gpointer _tmp86_;
			ProtonPlusModelsBaseRelease* _tmp87_;
			GtkListBox* _tmp88_;
			_release_index = _release_index + 1;
			_tmp83_ = _release_index;
			_tmp84_ = _release_size;
			if (!(_tmp83_ < _tmp84_)) {
				break;
			}
			_tmp85_ = _release_list;
			_tmp86_ = gee_abstract_list_get ((GeeAbstractList*) _tmp85_, _release_index);
			release = (ProtonPlusModelsBaseRelease*) _tmp86_;
			_tmp87_ = release;
			_tmp88_ = self->priv->completed_list_box;
			proton_plus_widgets_downloads_box_add_download_row (self, _tmp87_, _tmp88_);
			_g_object_unref0 (release);
		}
	}
	_g_object_unref0 (content_box);
	_g_object_unref0 (spacer);
	_g_object_unref0 (completed_label);
	_g_object_unref0 (in_progress_label);
	return self;
}

ProtonPlusWidgetsDownloadsBox*
proton_plus_widgets_downloads_box_new (void)
{
	return proton_plus_widgets_downloads_box_construct (PROTON_PLUS_WIDGETS_TYPE_DOWNLOADS_BOX);
}

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

static void
proton_plus_widgets_downloads_box_on_download_added (ProtonPlusWidgetsDownloadsBox* self,
                                                     ProtonPlusModelsBaseRelease* release)
{
	GtkWidget* child = NULL;
	GtkListBox* _tmp0_;
	GtkWidget* _tmp1_;
	GtkWidget* _tmp2_;
	GtkListBox* _tmp20_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (release != NULL);
	_tmp0_ = self->priv->completed_list_box;
	_tmp1_ = gtk_widget_get_first_child ((GtkWidget*) _tmp0_);
	_tmp2_ = _g_object_ref0 (_tmp1_);
	child = _tmp2_;
	while (TRUE) {
		GtkWidget* _tmp3_;
		GtkWidget* next = NULL;
		GtkWidget* _tmp4_;
		GtkWidget* _tmp5_;
		GtkWidget* _tmp6_;
		gboolean _tmp7_ = FALSE;
		GtkWidget* _tmp8_;
		GtkWidget* _tmp18_;
		GtkWidget* _tmp19_;
		_tmp3_ = child;
		if (!(_tmp3_ != NULL)) {
			break;
		}
		_tmp4_ = child;
		_tmp5_ = gtk_widget_get_next_sibling (_tmp4_);
		_tmp6_ = _g_object_ref0 (_tmp5_);
		next = _tmp6_;
		_tmp8_ = child;
		if (PROTON_PLUS_WIDGETS_IS_DOWNLOAD_ROW (_tmp8_)) {
			GtkWidget* _tmp9_;
			ProtonPlusModelsBaseRelease* _tmp10_;
			ProtonPlusModelsBaseRelease* _tmp11_;
			const gchar* _tmp12_;
			const gchar* _tmp13_;
			const gchar* _tmp14_;
			const gchar* _tmp15_;
			_tmp9_ = child;
			_tmp10_ = proton_plus_widgets_download_row_get_release (G_TYPE_CHECK_INSTANCE_CAST (_tmp9_, PROTON_PLUS_WIDGETS_TYPE_DOWNLOAD_ROW, ProtonPlusWidgetsDownloadRow));
			_tmp11_ = _tmp10_;
			_tmp12_ = proton_plus_models_base_release_get_title (_tmp11_);
			_tmp13_ = _tmp12_;
			_tmp14_ = proton_plus_models_base_release_get_title (release);
			_tmp15_ = _tmp14_;
			_tmp7_ = g_strcmp0 (_tmp13_, _tmp15_) == 0;
		} else {
			_tmp7_ = FALSE;
		}
		if (_tmp7_) {
			GtkListBox* _tmp16_;
			GtkWidget* _tmp17_;
			_tmp16_ = self->priv->completed_list_box;
			_tmp17_ = child;
			gtk_list_box_remove (_tmp16_, _tmp17_);
		}
		_tmp18_ = next;
		_tmp19_ = _g_object_ref0 (_tmp18_);
		_g_object_unref0 (child);
		child = _tmp19_;
		_g_object_unref0 (next);
	}
	_tmp20_ = self->priv->in_progress_list_box;
	proton_plus_widgets_downloads_box_add_download_row (self, release, _tmp20_);
	proton_plus_widgets_downloads_box_update_visibility (self);
	_g_object_unref0 (child);
}

static void
proton_plus_widgets_downloads_box_on_download_removed (ProtonPlusWidgetsDownloadsBox* self,
                                                       ProtonPlusModelsBaseRelease* release)
{
	g_return_if_fail (self != NULL);
	g_return_if_fail (release != NULL);
	proton_plus_widgets_downloads_box_update_visibility (self);
}

static void
proton_plus_widgets_downloads_box_on_download_finished (ProtonPlusWidgetsDownloadsBox* self,
                                                        ProtonPlusModelsBaseRelease* release,
                                                        gboolean success)
{
	GtkWidget* child = NULL;
	GtkListBox* _tmp0_;
	GtkWidget* _tmp1_;
	GtkWidget* _tmp2_;
	GtkListBox* _tmp14_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (release != NULL);
	_tmp0_ = self->priv->in_progress_list_box;
	_tmp1_ = gtk_widget_get_first_child ((GtkWidget*) _tmp0_);
	_tmp2_ = _g_object_ref0 (_tmp1_);
	child = _tmp2_;
	while (TRUE) {
		GtkWidget* _tmp3_;
		gboolean _tmp4_ = FALSE;
		GtkWidget* _tmp5_;
		GtkWidget* _tmp11_;
		GtkWidget* _tmp12_;
		GtkWidget* _tmp13_;
		_tmp3_ = child;
		if (!(_tmp3_ != NULL)) {
			break;
		}
		_tmp5_ = child;
		if (PROTON_PLUS_WIDGETS_IS_DOWNLOAD_ROW (_tmp5_)) {
			GtkWidget* _tmp6_;
			ProtonPlusModelsBaseRelease* _tmp7_;
			ProtonPlusModelsBaseRelease* _tmp8_;
			_tmp6_ = child;
			_tmp7_ = proton_plus_widgets_download_row_get_release (G_TYPE_CHECK_INSTANCE_CAST (_tmp6_, PROTON_PLUS_WIDGETS_TYPE_DOWNLOAD_ROW, ProtonPlusWidgetsDownloadRow));
			_tmp8_ = _tmp7_;
			_tmp4_ = _tmp8_ == release;
		} else {
			_tmp4_ = FALSE;
		}
		if (_tmp4_) {
			GtkListBox* _tmp9_;
			GtkWidget* _tmp10_;
			_tmp9_ = self->priv->in_progress_list_box;
			_tmp10_ = child;
			gtk_list_box_remove (_tmp9_, _tmp10_);
			break;
		}
		_tmp11_ = child;
		_tmp12_ = gtk_widget_get_next_sibling (_tmp11_);
		_tmp13_ = _g_object_ref0 (_tmp12_);
		_g_object_unref0 (child);
		child = _tmp13_;
	}
	_tmp14_ = self->priv->completed_list_box;
	proton_plus_widgets_downloads_box_add_download_row (self, release, _tmp14_);
	proton_plus_widgets_downloads_box_update_visibility (self);
	_g_object_unref0 (child);
}

static void
proton_plus_widgets_downloads_box_on_clear_clicked (ProtonPlusWidgetsDownloadsBox* self)
{
	ProtonPlusModelsDownloadManager* _tmp0_;
	ProtonPlusModelsDownloadManager* _tmp1_;
	GtkWidget* child = NULL;
	GtkListBox* _tmp2_;
	GtkWidget* _tmp3_;
	GtkWidget* _tmp4_;
	g_return_if_fail (self != NULL);
	_tmp0_ = proton_plus_models_download_manager_get_instance ();
	_tmp1_ = _tmp0_;
	proton_plus_models_download_manager_clear_history (_tmp1_);
	_tmp2_ = self->priv->completed_list_box;
	_tmp3_ = gtk_widget_get_first_child ((GtkWidget*) _tmp2_);
	_tmp4_ = _g_object_ref0 (_tmp3_);
	child = _tmp4_;
	while (TRUE) {
		GtkWidget* _tmp5_;
		GtkWidget* next = NULL;
		GtkWidget* _tmp6_;
		GtkWidget* _tmp7_;
		GtkWidget* _tmp8_;
		GtkListBox* _tmp9_;
		GtkWidget* _tmp10_;
		GtkWidget* _tmp11_;
		GtkWidget* _tmp12_;
		_tmp5_ = child;
		if (!(_tmp5_ != NULL)) {
			break;
		}
		_tmp6_ = child;
		_tmp7_ = gtk_widget_get_next_sibling (_tmp6_);
		_tmp8_ = _g_object_ref0 (_tmp7_);
		next = _tmp8_;
		_tmp9_ = self->priv->completed_list_box;
		_tmp10_ = child;
		gtk_list_box_remove (_tmp9_, _tmp10_);
		_tmp11_ = next;
		_tmp12_ = _g_object_ref0 (_tmp11_);
		_g_object_unref0 (child);
		child = _tmp12_;
		_g_object_unref0 (next);
	}
	proton_plus_widgets_downloads_box_update_visibility (self);
	_g_object_unref0 (child);
}

static void
proton_plus_widgets_downloads_box_add_download_row (ProtonPlusWidgetsDownloadsBox* self,
                                                    ProtonPlusModelsBaseRelease* release,
                                                    GtkListBox* list_box)
{
	ProtonPlusWidgetsDownloadRow* row = NULL;
	ProtonPlusWidgetsDownloadRow* _tmp0_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (release != NULL);
	g_return_if_fail (list_box != NULL);
	_tmp0_ = proton_plus_widgets_download_row_new (release);
	g_object_ref_sink (_tmp0_);
	row = _tmp0_;
	gtk_list_box_prepend (list_box, (GtkWidget*) row);
	_g_object_unref0 (row);
}

static void
proton_plus_widgets_downloads_box_update_visibility (ProtonPlusWidgetsDownloadsBox* self)
{
	gboolean _tmp0_ = FALSE;
	ProtonPlusModelsDownloadManager* _tmp1_;
	ProtonPlusModelsDownloadManager* _tmp2_;
	GeeArrayList* _tmp3_;
	GeeArrayList* _tmp4_;
	gint _tmp5_;
	gint _tmp6_;
	gboolean has_downloads = FALSE;
	gboolean has_active = FALSE;
	ProtonPlusModelsDownloadManager* _tmp13_;
	ProtonPlusModelsDownloadManager* _tmp14_;
	GeeArrayList* _tmp15_;
	GeeArrayList* _tmp16_;
	gint _tmp17_;
	gint _tmp18_;
	gboolean has_history = FALSE;
	ProtonPlusModelsDownloadManager* _tmp19_;
	ProtonPlusModelsDownloadManager* _tmp20_;
	GeeArrayList* _tmp21_;
	GeeArrayList* _tmp22_;
	gint _tmp23_;
	gint _tmp24_;
	GtkBox* _tmp25_;
	GtkScrolledWindow* _tmp26_;
	AdwStatusPage* _tmp27_;
	GtkButton* _tmp28_;
	GtkBox* _tmp29_;
	GtkBox* _tmp30_;
	g_return_if_fail (self != NULL);
	_tmp1_ = proton_plus_models_download_manager_get_instance ();
	_tmp2_ = _tmp1_;
	_tmp3_ = proton_plus_models_download_manager_get_active_downloads (_tmp2_);
	_tmp4_ = _tmp3_;
	_tmp5_ = gee_abstract_collection_get_size ((GeeAbstractCollection*) _tmp4_);
	_tmp6_ = _tmp5_;
	if (_tmp6_ > 0) {
		_tmp0_ = TRUE;
	} else {
		ProtonPlusModelsDownloadManager* _tmp7_;
		ProtonPlusModelsDownloadManager* _tmp8_;
		GeeArrayList* _tmp9_;
		GeeArrayList* _tmp10_;
		gint _tmp11_;
		gint _tmp12_;
		_tmp7_ = proton_plus_models_download_manager_get_instance ();
		_tmp8_ = _tmp7_;
		_tmp9_ = proton_plus_models_download_manager_get_history (_tmp8_);
		_tmp10_ = _tmp9_;
		_tmp11_ = gee_abstract_collection_get_size ((GeeAbstractCollection*) _tmp10_);
		_tmp12_ = _tmp11_;
		_tmp0_ = _tmp12_ > 0;
	}
	has_downloads = _tmp0_;
	_tmp13_ = proton_plus_models_download_manager_get_instance ();
	_tmp14_ = _tmp13_;
	_tmp15_ = proton_plus_models_download_manager_get_active_downloads (_tmp14_);
	_tmp16_ = _tmp15_;
	_tmp17_ = gee_abstract_collection_get_size ((GeeAbstractCollection*) _tmp16_);
	_tmp18_ = _tmp17_;
	has_active = _tmp18_ > 0;
	_tmp19_ = proton_plus_models_download_manager_get_instance ();
	_tmp20_ = _tmp19_;
	_tmp21_ = proton_plus_models_download_manager_get_history (_tmp20_);
	_tmp22_ = _tmp21_;
	_tmp23_ = gee_abstract_collection_get_size ((GeeAbstractCollection*) _tmp22_);
	_tmp24_ = _tmp23_;
	has_history = _tmp24_ > 0;
	_tmp25_ = self->priv->completed_header_box;
	gtk_widget_set_visible ((GtkWidget*) _tmp25_, has_downloads);
	_tmp26_ = self->priv->scrolled_window;
	gtk_widget_set_visible ((GtkWidget*) _tmp26_, has_downloads);
	_tmp27_ = self->priv->status_page;
	gtk_widget_set_visible ((GtkWidget*) _tmp27_, !has_downloads);
	_tmp28_ = self->priv->clear_button;
	gtk_widget_set_visible ((GtkWidget*) _tmp28_, has_history);
	_tmp29_ = self->priv->in_progress_box;
	gtk_widget_set_visible ((GtkWidget*) _tmp29_, has_active);
	_tmp30_ = self->priv->completed_box;
	gtk_widget_set_visible ((GtkWidget*) _tmp30_, has_history);
}

static void
proton_plus_widgets_downloads_box_class_init (ProtonPlusWidgetsDownloadsBoxClass * klass,
                                              gpointer klass_data)
{
	proton_plus_widgets_downloads_box_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &ProtonPlusWidgetsDownloadsBox_private_offset);
	G_OBJECT_CLASS (klass)->finalize = proton_plus_widgets_downloads_box_finalize;
}

static void
proton_plus_widgets_downloads_box_instance_init (ProtonPlusWidgetsDownloadsBox * self,
                                                 gpointer klass)
{
	self->priv = proton_plus_widgets_downloads_box_get_instance_private (self);
}

static void
proton_plus_widgets_downloads_box_finalize (GObject * obj)
{
	ProtonPlusWidgetsDownloadsBox * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, PROTON_PLUS_WIDGETS_TYPE_DOWNLOADS_BOX, ProtonPlusWidgetsDownloadsBox);
	_g_object_unref0 (self->priv->in_progress_list_box);
	_g_object_unref0 (self->priv->completed_list_box);
	_g_object_unref0 (self->priv->in_progress_box);
	_g_object_unref0 (self->priv->completed_box);
	_g_object_unref0 (self->priv->status_page);
	_g_object_unref0 (self->priv->clamp);
	_g_object_unref0 (self->priv->scrolled_window);
	_g_object_unref0 (self->priv->completed_header_box);
	_g_object_unref0 (self->priv->clear_button);
	G_OBJECT_CLASS (proton_plus_widgets_downloads_box_parent_class)->finalize (obj);
}

static GType
proton_plus_widgets_downloads_box_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (ProtonPlusWidgetsDownloadsBoxClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) proton_plus_widgets_downloads_box_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ProtonPlusWidgetsDownloadsBox), 0, (GInstanceInitFunc) proton_plus_widgets_downloads_box_instance_init, NULL };
	GType proton_plus_widgets_downloads_box_type_id;
	proton_plus_widgets_downloads_box_type_id = g_type_register_static (gtk_box_get_type (), "ProtonPlusWidgetsDownloadsBox", &g_define_type_info, 0);
	ProtonPlusWidgetsDownloadsBox_private_offset = g_type_add_instance_private (proton_plus_widgets_downloads_box_type_id, sizeof (ProtonPlusWidgetsDownloadsBoxPrivate));
	return proton_plus_widgets_downloads_box_type_id;
}

GType
proton_plus_widgets_downloads_box_get_type (void)
{
	static volatile gsize proton_plus_widgets_downloads_box_type_id__once = 0;
	if (g_once_init_enter (&proton_plus_widgets_downloads_box_type_id__once)) {
		GType proton_plus_widgets_downloads_box_type_id;
		proton_plus_widgets_downloads_box_type_id = proton_plus_widgets_downloads_box_get_type_once ();
		g_once_init_leave (&proton_plus_widgets_downloads_box_type_id__once, proton_plus_widgets_downloads_box_type_id);
	}
	return proton_plus_widgets_downloads_box_type_id__once;
}

