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

#include "protonplus_core.h"
#include <gee.h>
#include <glib-object.h>
#include <adwaita.h>
#include <gtk/gtk.h>
#include <glib.h>
#include <glib/gi18n-lib.h>
#include <stdlib.h>
#include <string.h>
#include <float.h>
#include <math.h>
#include <pango/pango.h>

#if !defined(VALA_STRICT_C)
#if !defined(__clang__) && defined(__GNUC__) && (__GNUC__ >= 14)
#pragma GCC diagnostic warning "-Wincompatible-pointer-types"
#elif defined(__clang__) && (__clang_major__ >= 16)
#pragma clang diagnostic ignored "-Wincompatible-function-pointer-types"
#pragma clang diagnostic ignored "-Wincompatible-pointer-types"
#endif
#endif

#define PROTON_PLUS_WIDGETS_HEADER_TYPE_DOWNLOAD_ENTRY (proton_plus_widgets_header_download_entry_get_type ())
#define PROTON_PLUS_WIDGETS_HEADER_DOWNLOAD_ENTRY(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), PROTON_PLUS_WIDGETS_HEADER_TYPE_DOWNLOAD_ENTRY, ProtonPlusWidgetsHeaderDownloadEntry))
#define PROTON_PLUS_WIDGETS_HEADER_DOWNLOAD_ENTRY_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), PROTON_PLUS_WIDGETS_HEADER_TYPE_DOWNLOAD_ENTRY, ProtonPlusWidgetsHeaderDownloadEntryClass))
#define PROTON_PLUS_WIDGETS_HEADER_IS_DOWNLOAD_ENTRY(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), PROTON_PLUS_WIDGETS_HEADER_TYPE_DOWNLOAD_ENTRY))
#define PROTON_PLUS_WIDGETS_HEADER_IS_DOWNLOAD_ENTRY_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), PROTON_PLUS_WIDGETS_HEADER_TYPE_DOWNLOAD_ENTRY))
#define PROTON_PLUS_WIDGETS_HEADER_DOWNLOAD_ENTRY_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), PROTON_PLUS_WIDGETS_HEADER_TYPE_DOWNLOAD_ENTRY, ProtonPlusWidgetsHeaderDownloadEntryClass))

typedef struct _ProtonPlusWidgetsHeaderDownloadEntry ProtonPlusWidgetsHeaderDownloadEntry;
typedef struct _ProtonPlusWidgetsHeaderDownloadEntryClass ProtonPlusWidgetsHeaderDownloadEntryClass;
enum  {
	PROTON_PLUS_WIDGETS_HEADER_DOWNLOADS_INDICATOR_0_PROPERTY,
	PROTON_PLUS_WIDGETS_HEADER_DOWNLOADS_INDICATOR_NUM_PROPERTIES
};
static GParamSpec* proton_plus_widgets_header_downloads_indicator_properties[PROTON_PLUS_WIDGETS_HEADER_DOWNLOADS_INDICATOR_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
typedef struct _Block8Data Block8Data;
#define _g_free0(var) (var = (g_free (var), NULL))
enum  {
	PROTON_PLUS_WIDGETS_HEADER_DOWNLOADS_INDICATOR_DOWNLOAD_SELECTED_SIGNAL,
	PROTON_PLUS_WIDGETS_HEADER_DOWNLOADS_INDICATOR_NUM_SIGNALS
};
static guint proton_plus_widgets_header_downloads_indicator_signals[PROTON_PLUS_WIDGETS_HEADER_DOWNLOADS_INDICATOR_NUM_SIGNALS] = {0};
typedef struct _ProtonPlusWidgetsHeaderDownloadEntryPrivate ProtonPlusWidgetsHeaderDownloadEntryPrivate;
enum  {
	PROTON_PLUS_WIDGETS_HEADER_DOWNLOAD_ENTRY_0_PROPERTY,
	PROTON_PLUS_WIDGETS_HEADER_DOWNLOAD_ENTRY_NUM_PROPERTIES
};
static GParamSpec* proton_plus_widgets_header_download_entry_properties[PROTON_PLUS_WIDGETS_HEADER_DOWNLOAD_ENTRY_NUM_PROPERTIES];
typedef struct _Block9Data Block9Data;
#define _g_regex_unref0(var) ((var == NULL) ? NULL : (var = (g_regex_unref (var), NULL)))

struct _ProtonPlusWidgetsHeaderDownloadsIndicatorPrivate {
	ProtonPlusUtilsDownloadManager* manager;
	GeeHashMap* entries;
	GtkMenuButton* button;
	GtkImage* icon;
	GtkLabel* badge;
	GtkLabel* limit_label;
	GtkListBox* downloads_list;
	GtkPopover* downloads_popover;
	gulong download_added_handler;
	gulong download_removed_handler;
	gulong speed_limit_changed_handler;
	gboolean global_header_visible;
};

struct _Block8Data {
	int _ref_count_;
	ProtonPlusWidgetsHeaderDownloadsIndicator* self;
	ProtonPlusServicesInstallJob* job;
};

struct _ProtonPlusWidgetsHeaderDownloadEntry {
	AdwActionRow parent_instance;
	ProtonPlusWidgetsHeaderDownloadEntryPrivate * priv;
};

struct _ProtonPlusWidgetsHeaderDownloadEntryClass {
	AdwActionRowClass parent_class;
};

struct _ProtonPlusWidgetsHeaderDownloadEntryPrivate {
	ProtonPlusServicesInstallJob* job;
	GtkProgressBar* progress_bar;
	GtkLabel* status_label;
	GtkLabel* metrics_label;
	GtkButton* cancel_button;
	gulong progress_handler;
	gulong step_handler;
	gulong canceled_handler;
};

struct _Block9Data {
	int _ref_count_;
	ProtonPlusWidgetsHeaderDownloadEntry* self;
	ProtonPlusServicesInstallJob* job;
};

static gint ProtonPlusWidgetsHeaderDownloadsIndicator_private_offset;
static gpointer proton_plus_widgets_header_downloads_indicator_parent_class = NULL;
static gint ProtonPlusWidgetsHeaderDownloadEntry_private_offset;
static gpointer proton_plus_widgets_header_download_entry_parent_class = NULL;

VALA_EXTERN GType proton_plus_widgets_header_download_entry_get_type (void) G_GNUC_CONST ;
static void proton_plus_widgets_header_downloads_indicator_add_download (ProtonPlusWidgetsHeaderDownloadsIndicator* self,
                                                                  ProtonPlusServicesInstallJob* job);
static void _proton_plus_widgets_header_downloads_indicator_add_download_proton_plus_utils_download_manager_download_added (ProtonPlusUtilsDownloadManager* _sender,
                                                                                                                     ProtonPlusServicesInstallJob* job,
                                                                                                                     gpointer self);
static void proton_plus_widgets_header_downloads_indicator_remove_download (ProtonPlusWidgetsHeaderDownloadsIndicator* self,
                                                                     ProtonPlusServicesInstallJob* job);
static void _proton_plus_widgets_header_downloads_indicator_remove_download_proton_plus_utils_download_manager_download_removed (ProtonPlusUtilsDownloadManager* _sender,
                                                                                                                          ProtonPlusServicesInstallJob* job,
                                                                                                                          gpointer self);
static void __lambda196_ (ProtonPlusWidgetsHeaderDownloadsIndicator* self,
                   gint64 new_limit);
static void proton_plus_widgets_header_downloads_indicator_update_limit_label (ProtonPlusWidgetsHeaderDownloadsIndicator* self,
                                                                        gint64 speed_limit_bps);
static void ___lambda196__proton_plus_utils_download_manager_speed_limit_changed (ProtonPlusUtilsDownloadManager* _sender,
                                                                           gint64 new_limit,
                                                                           gpointer self);
static void proton_plus_widgets_header_downloads_indicator_update_badge (ProtonPlusWidgetsHeaderDownloadsIndicator* self);
static void proton_plus_widgets_header_downloads_indicator_real_dispose (GObject* base);
VALA_EXTERN void proton_plus_widgets_header_download_entry_disconnect_release_signals (ProtonPlusWidgetsHeaderDownloadEntry* self);
static Block8Data* block8_data_ref (Block8Data* _data8_);
static void block8_data_unref (void * _userdata_);
VALA_EXTERN ProtonPlusWidgetsHeaderDownloadEntry* proton_plus_widgets_header_download_entry_new (ProtonPlusServicesInstallJob* job);
VALA_EXTERN ProtonPlusWidgetsHeaderDownloadEntry* proton_plus_widgets_header_download_entry_construct (GType object_type,
                                                                                           ProtonPlusServicesInstallJob* job);
static void __lambda195_ (Block8Data* _data8_);
static void ___lambda195__adw_action_row_activated (AdwActionRow* _sender,
                                             gpointer self);
static void proton_plus_widgets_header_downloads_indicator_finalize (GObject * obj);
static GType proton_plus_widgets_header_downloads_indicator_get_type_once (void);
static Block9Data* block9_data_ref (Block9Data* _data9_);
static void block9_data_unref (void * _userdata_);
static void __lambda194_ (Block9Data* _data9_);
static void proton_plus_widgets_header_download_entry_update_display (ProtonPlusWidgetsHeaderDownloadEntry* self);
static void ___lambda194__gtk_button_clicked (GtkButton* _sender,
                                       gpointer self);
static void _proton_plus_widgets_header_download_entry_update_display_proton_plus_services_install_job_progress_updated (ProtonPlusServicesInstallJob* _sender,
                                                                                                                  gpointer self);
static void _proton_plus_widgets_header_download_entry_update_display_g_object_notify (GObject* _sender,
                                                                                GParamSpec* pspec,
                                                                                gpointer self);
static void proton_plus_widgets_header_download_entry_real_dispose (GObject* base);
static gchar* proton_plus_widgets_header_download_entry_get_step_text (ProtonPlusWidgetsHeaderDownloadEntry* self);
static gchar* proton_plus_widgets_header_download_entry_format_eta (ProtonPlusWidgetsHeaderDownloadEntry* self,
                                                             gdouble seconds);
static void proton_plus_widgets_header_download_entry_finalize (GObject * obj);
static GType proton_plus_widgets_header_download_entry_get_type_once (void);
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_header_downloads_indicator_get_instance_private (ProtonPlusWidgetsHeaderDownloadsIndicator* self)
{
	return G_STRUCT_MEMBER_P (self, ProtonPlusWidgetsHeaderDownloadsIndicator_private_offset);
}

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

static void
_proton_plus_widgets_header_downloads_indicator_add_download_proton_plus_utils_download_manager_download_added (ProtonPlusUtilsDownloadManager* _sender,
                                                                                                                ProtonPlusServicesInstallJob* job,
                                                                                                                gpointer self)
{
	proton_plus_widgets_header_downloads_indicator_add_download ((ProtonPlusWidgetsHeaderDownloadsIndicator*) self, job);
}

static void
_proton_plus_widgets_header_downloads_indicator_remove_download_proton_plus_utils_download_manager_download_removed (ProtonPlusUtilsDownloadManager* _sender,
                                                                                                                     ProtonPlusServicesInstallJob* job,
                                                                                                                     gpointer self)
{
	proton_plus_widgets_header_downloads_indicator_remove_download ((ProtonPlusWidgetsHeaderDownloadsIndicator*) self, job);
}

static void
__lambda196_ (ProtonPlusWidgetsHeaderDownloadsIndicator* self,
              gint64 new_limit)
{
	proton_plus_widgets_header_downloads_indicator_update_limit_label (self, new_limit);
}

static void
___lambda196__proton_plus_utils_download_manager_speed_limit_changed (ProtonPlusUtilsDownloadManager* _sender,
                                                                      gint64 new_limit,
                                                                      gpointer self)
{
	__lambda196_ ((ProtonPlusWidgetsHeaderDownloadsIndicator*) self, new_limit);
}

ProtonPlusWidgetsHeaderDownloadsIndicator*
proton_plus_widgets_header_downloads_indicator_construct (GType object_type)
{
	ProtonPlusWidgetsHeaderDownloadsIndicator * self = NULL;
	ProtonPlusUtilsDownloadManager* _tmp0_;
	ProtonPlusUtilsDownloadManager* _tmp1_;
	ProtonPlusUtilsDownloadManager* _tmp2_;
	GeeHashMap* _tmp3_;
	GtkImage* _tmp4_;
	GtkLabel* _tmp5_;
	GtkLabel* _tmp6_;
	GtkBox* button_content = NULL;
	GtkBox* _tmp7_;
	GtkBox* _tmp8_;
	GtkImage* _tmp9_;
	GtkBox* _tmp10_;
	GtkLabel* _tmp11_;
	GtkMenuButton* _tmp12_;
	GtkMenuButton* _tmp13_;
	GtkBox* _tmp14_;
	GtkMenuButton* _tmp15_;
	GtkMenuButton* _tmp16_;
	GtkMenuButton* _tmp17_;
	GtkMenuButton* _tmp18_;
	GtkListBox* _tmp19_ = NULL;
	GtkListBox* _tmp20_;
	GtkListBox* _tmp21_;
	GtkLabel* title = NULL;
	gchar* _tmp22_;
	gchar** _tmp23_;
	GtkLabel* _tmp24_ = NULL;
	gchar* _tmp25_;
	gchar* _tmp26_;
	gchar** _tmp27_;
	GtkLabel* _tmp28_ = NULL;
	GtkBox* title_row = NULL;
	GtkBox* _tmp29_;
	GtkBox* _tmp30_;
	GtkLabel* _tmp31_;
	GtkBox* _tmp32_;
	GtkLabel* _tmp33_;
	GtkScrolledWindow* scrolled = NULL;
	GtkListBox* _tmp34_;
	GtkWidget* _tmp35_;
	GtkScrolledWindow* _tmp36_ = NULL;
	GtkBox* content = NULL;
	GtkBox* _tmp37_ = NULL;
	GtkBox* _tmp38_;
	GtkBox* _tmp39_;
	GtkBox* _tmp40_;
	GtkScrolledWindow* _tmp41_;
	GtkPopover* _tmp42_;
	GtkPopover* _tmp43_;
	GtkBox* _tmp44_;
	GtkMenuButton* _tmp45_;
	GtkPopover* _tmp46_;
	GtkPopover* _tmp47_;
	GtkMenuButton* _tmp48_;
	ProtonPlusUtilsDownloadManager* _tmp49_;
	gulong _tmp50_;
	ProtonPlusUtilsDownloadManager* _tmp51_;
	gulong _tmp52_;
	ProtonPlusUtilsDownloadManager* _tmp53_;
	gulong _tmp54_;
	ProtonPlusUtilsDownloadManager* _tmp55_;
	gint64 _tmp56_;
	gint64 _tmp57_;
	self = (ProtonPlusWidgetsHeaderDownloadsIndicator*) g_object_new (object_type, "orientation", GTK_ORIENTATION_HORIZONTAL, "spacing", 0, NULL);
	_tmp0_ = proton_plus_utils_download_manager_get_instance ();
	_tmp1_ = _tmp0_;
	_tmp2_ = _g_object_ref0 (_tmp1_);
	_g_object_unref0 (self->priv->manager);
	self->priv->manager = _tmp2_;
	_tmp3_ = gee_hash_map_new (PROTON_PLUS_SERVICES_TYPE_INSTALL_JOB, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, PROTON_PLUS_WIDGETS_HEADER_TYPE_DOWNLOAD_ENTRY, (GBoxedCopyFunc) g_object_ref, (GDestroyNotify) g_object_unref, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
	_g_object_unref0 (self->priv->entries);
	self->priv->entries = _tmp3_;
	_tmp4_ = (GtkImage*) gtk_image_new_from_icon_name ("folder-download-symbolic");
	g_object_ref_sink (_tmp4_);
	_g_object_unref0 (self->priv->icon);
	self->priv->icon = _tmp4_;
	_tmp5_ = (GtkLabel*) gtk_label_new ("0");
	g_object_ref_sink (_tmp5_);
	_g_object_unref0 (self->priv->badge);
	self->priv->badge = _tmp5_;
	_tmp6_ = self->priv->badge;
	gtk_widget_add_css_class ((GtkWidget*) _tmp6_, "downloads-indicator-badge");
	_tmp7_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 4);
	g_object_ref_sink (_tmp7_);
	button_content = _tmp7_;
	_tmp8_ = button_content;
	_tmp9_ = self->priv->icon;
	gtk_box_append (_tmp8_, (GtkWidget*) _tmp9_);
	_tmp10_ = button_content;
	_tmp11_ = self->priv->badge;
	gtk_box_append (_tmp10_, (GtkWidget*) _tmp11_);
	_tmp12_ = (GtkMenuButton*) gtk_menu_button_new ();
	g_object_ref_sink (_tmp12_);
	_g_object_unref0 (self->priv->button);
	self->priv->button = _tmp12_;
	_tmp13_ = self->priv->button;
	_tmp14_ = button_content;
	gtk_menu_button_set_child (_tmp13_, (GtkWidget*) _tmp14_);
	_tmp15_ = self->priv->button;
	gtk_widget_add_css_class ((GtkWidget*) _tmp15_, "flat");
	_tmp16_ = self->priv->button;
	gtk_widget_set_tooltip_text ((GtkWidget*) _tmp16_, _ ("Active downloads"));
	_tmp17_ = self->priv->button;
	gtk_accessible_update_property ((GtkAccessible*) _tmp17_, GTK_ACCESSIBLE_PROPERTY_LABEL, _ ("Active downloads"), -1, -1);
	_tmp18_ = self->priv->button;
	gtk_box_append ((GtkBox*) self, (GtkWidget*) _tmp18_);
	_tmp19_ = (GtkListBox*) gtk_list_box_new ();
	gtk_list_box_set_selection_mode (_tmp19_, GTK_SELECTION_NONE);
	g_object_ref_sink (_tmp19_);
	_g_object_unref0 (self->priv->downloads_list);
	self->priv->downloads_list = _tmp19_;
	_tmp20_ = self->priv->downloads_list;
	gtk_widget_add_css_class ((GtkWidget*) _tmp20_, "boxed-list");
	_tmp21_ = self->priv->downloads_list;
	gtk_widget_add_css_class ((GtkWidget*) _tmp21_, "downloads-popover-list");
	_tmp22_ = g_strdup ("title-4");
	_tmp23_ = g_new0 (gchar*, 1 + 1);
	_tmp23_[0] = _tmp22_;
	_tmp24_ = (GtkLabel*) gtk_label_new (_ ("Downloads"));
	gtk_widget_set_halign ((GtkWidget*) _tmp24_, GTK_ALIGN_START);
	gtk_widget_set_css_classes ((GtkWidget*) _tmp24_, _tmp23_);
	_tmp23_ = (_vala_array_free (_tmp23_, 1, (GDestroyNotify) g_free), NULL);
	g_object_ref_sink (_tmp24_);
	title = _tmp24_;
	_tmp25_ = g_strdup ("caption");
	_tmp26_ = g_strdup ("dim-label");
	_tmp27_ = g_new0 (gchar*, 2 + 1);
	_tmp27_[0] = _tmp25_;
	_tmp27_[1] = _tmp26_;
	_tmp28_ = (GtkLabel*) gtk_label_new ("");
	gtk_widget_set_halign ((GtkWidget*) _tmp28_, GTK_ALIGN_END);
	gtk_label_set_xalign (_tmp28_, (gfloat) 1);
	gtk_widget_set_hexpand ((GtkWidget*) _tmp28_, TRUE);
	gtk_widget_set_css_classes ((GtkWidget*) _tmp28_, _tmp27_);
	_tmp27_ = (_vala_array_free (_tmp27_, 2, (GDestroyNotify) g_free), NULL);
	g_object_ref_sink (_tmp28_);
	_g_object_unref0 (self->priv->limit_label);
	self->priv->limit_label = _tmp28_;
	_tmp29_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 8);
	g_object_ref_sink (_tmp29_);
	title_row = _tmp29_;
	_tmp30_ = title_row;
	_tmp31_ = title;
	gtk_box_append (_tmp30_, (GtkWidget*) _tmp31_);
	_tmp32_ = title_row;
	_tmp33_ = self->priv->limit_label;
	gtk_box_append (_tmp32_, (GtkWidget*) _tmp33_);
	_tmp34_ = self->priv->downloads_list;
	_tmp35_ = _g_object_ref0 ((GtkWidget*) _tmp34_);
	_tmp36_ = (GtkScrolledWindow*) gtk_scrolled_window_new ();
	gtk_scrolled_window_set_child (_tmp36_, _tmp35_);
	_g_object_unref0 (_tmp35_);
	g_object_set (_tmp36_, "hscrollbar-policy", GTK_POLICY_NEVER, NULL);
	g_object_set (_tmp36_, "vscrollbar-policy", GTK_POLICY_AUTOMATIC, NULL);
	gtk_scrolled_window_set_propagate_natural_height (_tmp36_, TRUE);
	gtk_scrolled_window_set_max_content_height (_tmp36_, 360);
	g_object_ref_sink (_tmp36_);
	scrolled = _tmp36_;
	_tmp37_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_VERTICAL, 12);
	gtk_widget_set_margin_top ((GtkWidget*) _tmp37_, 12);
	gtk_widget_set_margin_bottom ((GtkWidget*) _tmp37_, 12);
	gtk_widget_set_margin_start ((GtkWidget*) _tmp37_, 12);
	gtk_widget_set_margin_end ((GtkWidget*) _tmp37_, 12);
	g_object_set ((GtkWidget*) _tmp37_, "width-request", 360, NULL);
	g_object_ref_sink (_tmp37_);
	content = _tmp37_;
	_tmp38_ = content;
	_tmp39_ = title_row;
	gtk_box_append (_tmp38_, (GtkWidget*) _tmp39_);
	_tmp40_ = content;
	_tmp41_ = scrolled;
	gtk_box_append (_tmp40_, (GtkWidget*) _tmp41_);
	_tmp42_ = (GtkPopover*) gtk_popover_new ();
	g_object_ref_sink (_tmp42_);
	_g_object_unref0 (self->priv->downloads_popover);
	self->priv->downloads_popover = _tmp42_;
	_tmp43_ = self->priv->downloads_popover;
	_tmp44_ = content;
	gtk_popover_set_child (_tmp43_, (GtkWidget*) _tmp44_);
	_tmp45_ = self->priv->button;
	_tmp46_ = self->priv->downloads_popover;
	gtk_menu_button_set_popover (_tmp45_, _tmp46_);
	_tmp47_ = self->priv->downloads_popover;
	_tmp48_ = self->priv->button;
	proton_plus_widgets_window_register_popover_for_controller (_tmp47_, (GtkWidget*) _tmp48_, NULL);
	_tmp49_ = self->priv->manager;
	_tmp50_ = g_signal_connect_object (_tmp49_, "download-added", (GCallback) _proton_plus_widgets_header_downloads_indicator_add_download_proton_plus_utils_download_manager_download_added, self, 0);
	self->priv->download_added_handler = _tmp50_;
	_tmp51_ = self->priv->manager;
	_tmp52_ = g_signal_connect_object (_tmp51_, "download-removed", (GCallback) _proton_plus_widgets_header_downloads_indicator_remove_download_proton_plus_utils_download_manager_download_removed, self, 0);
	self->priv->download_removed_handler = _tmp52_;
	_tmp53_ = self->priv->manager;
	_tmp54_ = g_signal_connect_object (_tmp53_, "speed-limit-changed", (GCallback) ___lambda196__proton_plus_utils_download_manager_speed_limit_changed, self, 0);
	self->priv->speed_limit_changed_handler = _tmp54_;
	_tmp55_ = self->priv->manager;
	_tmp56_ = proton_plus_utils_download_manager_get_speed_limit_bps (_tmp55_);
	_tmp57_ = _tmp56_;
	proton_plus_widgets_header_downloads_indicator_update_limit_label (self, _tmp57_);
	{
		GeeLinkedList* _job_list = NULL;
		ProtonPlusUtilsDownloadManager* _tmp58_;
		GeeLinkedList* _tmp59_;
		GeeLinkedList* _tmp60_;
		gint _job_size = 0;
		GeeLinkedList* _tmp61_;
		gint _tmp62_;
		gint _tmp63_;
		gint _job_index = 0;
		_tmp58_ = self->priv->manager;
		_tmp59_ = proton_plus_utils_download_manager_get_active_downloads (_tmp58_);
		_tmp60_ = _tmp59_;
		_job_list = _tmp60_;
		_tmp61_ = _job_list;
		_tmp62_ = gee_abstract_collection_get_size ((GeeAbstractCollection*) _tmp61_);
		_tmp63_ = _tmp62_;
		_job_size = _tmp63_;
		_job_index = -1;
		while (TRUE) {
			gint _tmp64_;
			gint _tmp65_;
			ProtonPlusServicesInstallJob* job = NULL;
			GeeLinkedList* _tmp66_;
			gpointer _tmp67_;
			ProtonPlusServicesInstallJob* _tmp68_;
			_job_index = _job_index + 1;
			_tmp64_ = _job_index;
			_tmp65_ = _job_size;
			if (!(_tmp64_ < _tmp65_)) {
				break;
			}
			_tmp66_ = _job_list;
			_tmp67_ = gee_abstract_list_get ((GeeAbstractList*) _tmp66_, _job_index);
			job = (ProtonPlusServicesInstallJob*) _tmp67_;
			_tmp68_ = job;
			proton_plus_widgets_header_downloads_indicator_add_download (self, _tmp68_);
			_g_object_unref0 (job);
		}
	}
	proton_plus_widgets_header_downloads_indicator_update_badge (self);
	_g_object_unref0 (content);
	_g_object_unref0 (scrolled);
	_g_object_unref0 (title_row);
	_g_object_unref0 (title);
	_g_object_unref0 (button_content);
	return self;
}

ProtonPlusWidgetsHeaderDownloadsIndicator*
proton_plus_widgets_header_downloads_indicator_new (void)
{
	return proton_plus_widgets_header_downloads_indicator_construct (PROTON_PLUS_WIDGETS_HEADER_TYPE_DOWNLOADS_INDICATOR);
}

static void
proton_plus_widgets_header_downloads_indicator_real_dispose (GObject* base)
{
	ProtonPlusWidgetsHeaderDownloadsIndicator * self;
	GeeHashMap* _tmp13_;
	self = (ProtonPlusWidgetsHeaderDownloadsIndicator*) base;
	if (self->priv->download_added_handler != ((gulong) 0)) {
		ProtonPlusUtilsDownloadManager* _tmp0_;
		_tmp0_ = self->priv->manager;
		g_signal_handler_disconnect ((GObject*) _tmp0_, self->priv->download_added_handler);
		self->priv->download_added_handler = (gulong) 0;
	}
	if (self->priv->download_removed_handler != ((gulong) 0)) {
		ProtonPlusUtilsDownloadManager* _tmp1_;
		_tmp1_ = self->priv->manager;
		g_signal_handler_disconnect ((GObject*) _tmp1_, self->priv->download_removed_handler);
		self->priv->download_removed_handler = (gulong) 0;
	}
	if (self->priv->speed_limit_changed_handler != ((gulong) 0)) {
		ProtonPlusUtilsDownloadManager* _tmp2_;
		_tmp2_ = self->priv->manager;
		g_signal_handler_disconnect ((GObject*) _tmp2_, self->priv->speed_limit_changed_handler);
		self->priv->speed_limit_changed_handler = (gulong) 0;
	}
	{
		GeeIterator* _entry_it = NULL;
		GeeHashMap* _tmp3_;
		GeeCollection* _tmp4_;
		GeeCollection* _tmp5_;
		GeeCollection* _tmp6_;
		GeeIterator* _tmp7_;
		GeeIterator* _tmp8_;
		_tmp3_ = self->priv->entries;
		_tmp4_ = gee_abstract_map_get_values ((GeeAbstractMap*) _tmp3_);
		_tmp5_ = _tmp4_;
		_tmp6_ = _tmp5_;
		_tmp7_ = gee_iterable_iterator ((GeeIterable*) _tmp6_);
		_tmp8_ = _tmp7_;
		_g_object_unref0 (_tmp6_);
		_entry_it = _tmp8_;
		while (TRUE) {
			GeeIterator* _tmp9_;
			ProtonPlusWidgetsHeaderDownloadEntry* entry = NULL;
			GeeIterator* _tmp10_;
			gpointer _tmp11_;
			ProtonPlusWidgetsHeaderDownloadEntry* _tmp12_;
			_tmp9_ = _entry_it;
			if (!gee_iterator_next (_tmp9_)) {
				break;
			}
			_tmp10_ = _entry_it;
			_tmp11_ = gee_iterator_get (_tmp10_);
			entry = (ProtonPlusWidgetsHeaderDownloadEntry*) _tmp11_;
			_tmp12_ = entry;
			proton_plus_widgets_header_download_entry_disconnect_release_signals (_tmp12_);
			_g_object_unref0 (entry);
		}
		_g_object_unref0 (_entry_it);
	}
	_tmp13_ = self->priv->entries;
	gee_abstract_map_clear ((GeeAbstractMap*) _tmp13_);
	G_OBJECT_CLASS (proton_plus_widgets_header_downloads_indicator_parent_class)->dispose ((GObject*) G_TYPE_CHECK_INSTANCE_CAST (self, gtk_box_get_type (), GtkBox));
}

static Block8Data*
block8_data_ref (Block8Data* _data8_)
{
	g_atomic_int_inc (&_data8_->_ref_count_);
	return _data8_;
}

static void
block8_data_unref (void * _userdata_)
{
	Block8Data* _data8_;
	_data8_ = (Block8Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data8_->_ref_count_)) {
		ProtonPlusWidgetsHeaderDownloadsIndicator* self;
		self = _data8_->self;
		_g_object_unref0 (_data8_->job);
		_g_object_unref0 (self);
		g_slice_free (Block8Data, _data8_);
	}
}

static void
__lambda195_ (Block8Data* _data8_)
{
	ProtonPlusWidgetsHeaderDownloadsIndicator* self;
	GtkPopover* _tmp0_;
	self = _data8_->self;
	_tmp0_ = self->priv->downloads_popover;
	gtk_popover_popdown (_tmp0_);
	g_signal_emit (self, proton_plus_widgets_header_downloads_indicator_signals[PROTON_PLUS_WIDGETS_HEADER_DOWNLOADS_INDICATOR_DOWNLOAD_SELECTED_SIGNAL], 0, _data8_->job);
}

static void
___lambda195__adw_action_row_activated (AdwActionRow* _sender,
                                        gpointer self)
{
	__lambda195_ (self);
}

static void
proton_plus_widgets_header_downloads_indicator_add_download (ProtonPlusWidgetsHeaderDownloadsIndicator* self,
                                                             ProtonPlusServicesInstallJob* job)
{
	Block8Data* _data8_;
	ProtonPlusServicesInstallJob* _tmp0_;
	GeeHashMap* _tmp1_;
	ProtonPlusWidgetsHeaderDownloadEntry* entry = NULL;
	ProtonPlusWidgetsHeaderDownloadEntry* _tmp2_;
	ProtonPlusWidgetsHeaderDownloadEntry* _tmp3_;
	GeeHashMap* _tmp4_;
	ProtonPlusWidgetsHeaderDownloadEntry* _tmp5_;
	GtkListBox* _tmp6_;
	ProtonPlusWidgetsHeaderDownloadEntry* _tmp7_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (job != NULL);
	_data8_ = g_slice_new0 (Block8Data);
	_data8_->_ref_count_ = 1;
	_data8_->self = g_object_ref (self);
	_tmp0_ = _g_object_ref0 (job);
	_g_object_unref0 (_data8_->job);
	_data8_->job = _tmp0_;
	_tmp1_ = self->priv->entries;
	if (gee_abstract_map_has_key ((GeeAbstractMap*) _tmp1_, _data8_->job)) {
		block8_data_unref (_data8_);
		_data8_ = NULL;
		return;
	}
	_tmp2_ = proton_plus_widgets_header_download_entry_new (_data8_->job);
	g_object_ref_sink (_tmp2_);
	entry = _tmp2_;
	_tmp3_ = entry;
	g_signal_connect_data ((AdwActionRow*) _tmp3_, "activated", (GCallback) ___lambda195__adw_action_row_activated, block8_data_ref (_data8_), (GClosureNotify) block8_data_unref, 0);
	_tmp4_ = self->priv->entries;
	_tmp5_ = entry;
	gee_abstract_map_set ((GeeAbstractMap*) _tmp4_, _data8_->job, _tmp5_);
	_tmp6_ = self->priv->downloads_list;
	_tmp7_ = entry;
	gtk_list_box_append (_tmp6_, (GtkWidget*) _tmp7_);
	proton_plus_widgets_header_downloads_indicator_update_badge (self);
	_g_object_unref0 (entry);
	block8_data_unref (_data8_);
	_data8_ = NULL;
}

static void
proton_plus_widgets_header_downloads_indicator_remove_download (ProtonPlusWidgetsHeaderDownloadsIndicator* self,
                                                                ProtonPlusServicesInstallJob* job)
{
	ProtonPlusWidgetsHeaderDownloadEntry* entry = NULL;
	GeeHashMap* _tmp0_;
	gpointer _tmp1_;
	ProtonPlusWidgetsHeaderDownloadEntry* _tmp2_;
	GtkListBox* _tmp3_;
	ProtonPlusWidgetsHeaderDownloadEntry* _tmp4_;
	GeeHashMap* _tmp5_;
	ProtonPlusWidgetsHeaderDownloadEntry* _tmp6_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (job != NULL);
	_tmp0_ = self->priv->entries;
	_tmp1_ = gee_abstract_map_get ((GeeAbstractMap*) _tmp0_, job);
	entry = (ProtonPlusWidgetsHeaderDownloadEntry*) _tmp1_;
	_tmp2_ = entry;
	if (_tmp2_ == NULL) {
		_g_object_unref0 (entry);
		return;
	}
	_tmp3_ = self->priv->downloads_list;
	_tmp4_ = entry;
	gtk_list_box_remove (_tmp3_, (GtkWidget*) _tmp4_);
	_tmp5_ = self->priv->entries;
	gee_abstract_map_unset ((GeeAbstractMap*) _tmp5_, job, NULL);
	_tmp6_ = entry;
	proton_plus_widgets_header_download_entry_disconnect_release_signals (_tmp6_);
	proton_plus_widgets_header_downloads_indicator_update_badge (self);
	_g_object_unref0 (entry);
}

static void
proton_plus_widgets_header_downloads_indicator_update_badge (ProtonPlusWidgetsHeaderDownloadsIndicator* self)
{
	gint count = 0;
	GeeHashMap* _tmp0_;
	gint _tmp1_;
	gint _tmp2_;
	GtkLabel* _tmp3_;
	gchar* _tmp4_;
	gchar* _tmp5_;
	gboolean _tmp6_ = FALSE;
	GtkMenuButton* _tmp9_;
	gchar* _tmp10_;
	gchar* _tmp11_;
	GtkMenuButton* _tmp12_;
	gchar* _tmp13_;
	gchar* _tmp14_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->entries;
	_tmp1_ = gee_abstract_map_get_size ((GeeAbstractMap*) _tmp0_);
	_tmp2_ = _tmp1_;
	count = _tmp2_;
	_tmp3_ = self->priv->badge;
	_tmp4_ = g_strdup_printf ("%i", count);
	_tmp5_ = _tmp4_;
	gtk_label_set_label (_tmp3_, _tmp5_);
	_g_free0 (_tmp5_);
	if (self->priv->global_header_visible) {
		_tmp6_ = count > 0;
	} else {
		_tmp6_ = FALSE;
	}
	gtk_widget_set_visible ((GtkWidget*) self, _tmp6_);
	if (count > 0) {
		GtkImage* _tmp7_;
		_tmp7_ = self->priv->icon;
		gtk_widget_add_css_class ((GtkWidget*) _tmp7_, "downloads-indicator-active");
	} else {
		GtkImage* _tmp8_;
		_tmp8_ = self->priv->icon;
		gtk_widget_remove_css_class ((GtkWidget*) _tmp8_, "downloads-indicator-active");
	}
	_tmp9_ = self->priv->button;
	_tmp10_ = g_strdup_printf (ngettext ("%u active download", "%u active downloads", (gulong) count), (guint) count);
	_tmp11_ = _tmp10_;
	gtk_widget_set_tooltip_text ((GtkWidget*) _tmp9_, _tmp11_);
	_g_free0 (_tmp11_);
	_tmp12_ = self->priv->button;
	_tmp13_ = g_strdup_printf (ngettext ("%u active download", "%u active downloads", (gulong) count), (guint) count);
	_tmp14_ = _tmp13_;
	gtk_accessible_update_property ((GtkAccessible*) _tmp12_, GTK_ACCESSIBLE_PROPERTY_LABEL, _tmp14_, -1, -1);
	_g_free0 (_tmp14_);
	if (count == 0) {
		GtkPopover* _tmp15_;
		_tmp15_ = self->priv->downloads_popover;
		gtk_popover_popdown (_tmp15_);
	}
}

void
proton_plus_widgets_header_downloads_indicator_set_global_header_visible (ProtonPlusWidgetsHeaderDownloadsIndicator* self,
                                                                          gboolean visible)
{
	g_return_if_fail (self != NULL);
	self->priv->global_header_visible = visible;
	proton_plus_widgets_header_downloads_indicator_update_badge (self);
}

static void
proton_plus_widgets_header_downloads_indicator_update_limit_label (ProtonPlusWidgetsHeaderDownloadsIndicator* self,
                                                                   gint64 speed_limit_bps)
{
	g_return_if_fail (self != NULL);
	if (speed_limit_bps > ((gint64) 0)) {
		GtkLabel* _tmp0_;
		gchar* _tmp1_;
		gchar* _tmp2_;
		gchar* _tmp3_;
		gchar* _tmp4_;
		_tmp0_ = self->priv->limit_label;
		_tmp1_ = proton_plus_utils_filesystem_convert_bytes_to_string (speed_limit_bps);
		_tmp2_ = _tmp1_;
		_tmp3_ = g_strdup_printf (_ ("Limit: %s/s"), _tmp2_);
		_tmp4_ = _tmp3_;
		gtk_label_set_label (_tmp0_, _tmp4_);
		_g_free0 (_tmp4_);
		_g_free0 (_tmp2_);
	} else {
		GtkLabel* _tmp5_;
		_tmp5_ = self->priv->limit_label;
		gtk_label_set_label (_tmp5_, "");
	}
}

static void
proton_plus_widgets_header_downloads_indicator_class_init (ProtonPlusWidgetsHeaderDownloadsIndicatorClass * klass,
                                                           gpointer klass_data)
{
	proton_plus_widgets_header_downloads_indicator_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &ProtonPlusWidgetsHeaderDownloadsIndicator_private_offset);
	((GObjectClass *) klass)->dispose = (void (*) (GObject*)) proton_plus_widgets_header_downloads_indicator_real_dispose;
	G_OBJECT_CLASS (klass)->finalize = proton_plus_widgets_header_downloads_indicator_finalize;
	proton_plus_widgets_header_downloads_indicator_signals[PROTON_PLUS_WIDGETS_HEADER_DOWNLOADS_INDICATOR_DOWNLOAD_SELECTED_SIGNAL] = g_signal_new ("download-selected", PROTON_PLUS_WIDGETS_HEADER_TYPE_DOWNLOADS_INDICATOR, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__OBJECT, G_TYPE_NONE, 1, PROTON_PLUS_SERVICES_TYPE_INSTALL_JOB);
}

static void
proton_plus_widgets_header_downloads_indicator_instance_init (ProtonPlusWidgetsHeaderDownloadsIndicator * self,
                                                              gpointer klass)
{
	self->priv = proton_plus_widgets_header_downloads_indicator_get_instance_private (self);
	self->priv->download_added_handler = (gulong) 0;
	self->priv->download_removed_handler = (gulong) 0;
	self->priv->speed_limit_changed_handler = (gulong) 0;
	self->priv->global_header_visible = TRUE;
}

static void
proton_plus_widgets_header_downloads_indicator_finalize (GObject * obj)
{
	ProtonPlusWidgetsHeaderDownloadsIndicator * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, PROTON_PLUS_WIDGETS_HEADER_TYPE_DOWNLOADS_INDICATOR, ProtonPlusWidgetsHeaderDownloadsIndicator);
	_g_object_unref0 (self->priv->manager);
	_g_object_unref0 (self->priv->entries);
	_g_object_unref0 (self->priv->button);
	_g_object_unref0 (self->priv->icon);
	_g_object_unref0 (self->priv->badge);
	_g_object_unref0 (self->priv->limit_label);
	_g_object_unref0 (self->priv->downloads_list);
	_g_object_unref0 (self->priv->downloads_popover);
	G_OBJECT_CLASS (proton_plus_widgets_header_downloads_indicator_parent_class)->finalize (obj);
}

static GType
proton_plus_widgets_header_downloads_indicator_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (ProtonPlusWidgetsHeaderDownloadsIndicatorClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) proton_plus_widgets_header_downloads_indicator_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ProtonPlusWidgetsHeaderDownloadsIndicator), 0, (GInstanceInitFunc) proton_plus_widgets_header_downloads_indicator_instance_init, NULL };
	GType proton_plus_widgets_header_downloads_indicator_type_id;
	proton_plus_widgets_header_downloads_indicator_type_id = g_type_register_static (gtk_box_get_type (), "ProtonPlusWidgetsHeaderDownloadsIndicator", &g_define_type_info, 0);
	ProtonPlusWidgetsHeaderDownloadsIndicator_private_offset = g_type_add_instance_private (proton_plus_widgets_header_downloads_indicator_type_id, sizeof (ProtonPlusWidgetsHeaderDownloadsIndicatorPrivate));
	return proton_plus_widgets_header_downloads_indicator_type_id;
}

GType
proton_plus_widgets_header_downloads_indicator_get_type (void)
{
	static volatile gsize proton_plus_widgets_header_downloads_indicator_type_id__once = 0;
	if (g_once_init_enter (&proton_plus_widgets_header_downloads_indicator_type_id__once)) {
		GType proton_plus_widgets_header_downloads_indicator_type_id;
		proton_plus_widgets_header_downloads_indicator_type_id = proton_plus_widgets_header_downloads_indicator_get_type_once ();
		g_once_init_leave (&proton_plus_widgets_header_downloads_indicator_type_id__once, proton_plus_widgets_header_downloads_indicator_type_id);
	}
	return proton_plus_widgets_header_downloads_indicator_type_id__once;
}

static inline gpointer
proton_plus_widgets_header_download_entry_get_instance_private (ProtonPlusWidgetsHeaderDownloadEntry* self)
{
	return G_STRUCT_MEMBER_P (self, ProtonPlusWidgetsHeaderDownloadEntry_private_offset);
}

static Block9Data*
block9_data_ref (Block9Data* _data9_)
{
	g_atomic_int_inc (&_data9_->_ref_count_);
	return _data9_;
}

static void
block9_data_unref (void * _userdata_)
{
	Block9Data* _data9_;
	_data9_ = (Block9Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data9_->_ref_count_)) {
		ProtonPlusWidgetsHeaderDownloadEntry* self;
		self = _data9_->self;
		_g_object_unref0 (_data9_->job);
		_g_object_unref0 (self);
		g_slice_free (Block9Data, _data9_);
	}
}

static void
__lambda194_ (Block9Data* _data9_)
{
	ProtonPlusWidgetsHeaderDownloadEntry* self;
	self = _data9_->self;
	proton_plus_services_install_job_set_canceled (_data9_->job, TRUE);
	proton_plus_widgets_header_download_entry_update_display (self);
}

static void
___lambda194__gtk_button_clicked (GtkButton* _sender,
                                  gpointer self)
{
	__lambda194_ (self);
}

static void
_proton_plus_widgets_header_download_entry_update_display_proton_plus_services_install_job_progress_updated (ProtonPlusServicesInstallJob* _sender,
                                                                                                             gpointer self)
{
	proton_plus_widgets_header_download_entry_update_display ((ProtonPlusWidgetsHeaderDownloadEntry*) self);
}

static void
_proton_plus_widgets_header_download_entry_update_display_g_object_notify (GObject* _sender,
                                                                           GParamSpec* pspec,
                                                                           gpointer self)
{
	proton_plus_widgets_header_download_entry_update_display ((ProtonPlusWidgetsHeaderDownloadEntry*) self);
}

ProtonPlusWidgetsHeaderDownloadEntry*
proton_plus_widgets_header_download_entry_construct (GType object_type,
                                                     ProtonPlusServicesInstallJob* job)
{
	ProtonPlusWidgetsHeaderDownloadEntry * self = NULL;
	Block9Data* _data9_;
	ProtonPlusServicesInstallJob* _tmp0_;
	ProtonPlusModelsTool* _tmp1_;
	ProtonPlusModelsTool* _tmp2_;
	const gchar* _tmp3_;
	const gchar* _tmp4_;
	ProtonPlusServicesInstallJob* _tmp5_;
	gchar* _tmp6_;
	gchar* _tmp7_;
	gchar* _tmp8_;
	GtkProgressBar* _tmp9_ = NULL;
	gchar* _tmp10_;
	gchar** _tmp11_;
	GtkLabel* _tmp12_ = NULL;
	gchar* _tmp13_;
	gchar** _tmp14_;
	GtkLabel* _tmp15_ = NULL;
	GtkBox* progress_box = NULL;
	GtkBox* _tmp16_ = NULL;
	GtkProgressBar* _tmp17_;
	GtkLabel* _tmp18_;
	GtkLabel* _tmp19_;
	GtkButton* _tmp20_ = NULL;
	GtkButton* _tmp21_;
	GtkButton* _tmp22_;
	GtkButton* _tmp23_;
	GtkButton* _tmp24_;
	GtkButton* _tmp25_;
	gulong _tmp26_;
	gulong _tmp27_;
	gulong _tmp28_;
	g_return_val_if_fail (job != NULL, NULL);
	_data9_ = g_slice_new0 (Block9Data);
	_data9_->_ref_count_ = 1;
	_tmp0_ = _g_object_ref0 (job);
	_g_object_unref0 (_data9_->job);
	_data9_->job = _tmp0_;
	_tmp1_ = proton_plus_services_install_job_get_tool (_data9_->job);
	_tmp2_ = _tmp1_;
	_tmp3_ = proton_plus_models_tool_get_title (_tmp2_);
	_tmp4_ = _tmp3_;
	self = (ProtonPlusWidgetsHeaderDownloadEntry*) g_object_new (object_type, "title", _tmp4_, "activatable", TRUE, NULL);
	_data9_->self = g_object_ref (self);
	_tmp5_ = _g_object_ref0 (_data9_->job);
	_g_object_unref0 (self->priv->job);
	self->priv->job = _tmp5_;
	_tmp6_ = proton_plus_services_install_job_get_displayed_title (_data9_->job);
	_tmp7_ = _tmp6_;
	_tmp8_ = _tmp7_;
	adw_action_row_set_subtitle ((AdwActionRow*) self, _tmp8_);
	_g_free0 (_tmp8_);
	_tmp9_ = (GtkProgressBar*) gtk_progress_bar_new ();
	gtk_progress_bar_set_show_text (_tmp9_, FALSE);
	g_object_set ((GtkWidget*) _tmp9_, "width-request", 132, NULL);
	gtk_widget_set_valign ((GtkWidget*) _tmp9_, GTK_ALIGN_CENTER);
	g_object_ref_sink (_tmp9_);
	_g_object_unref0 (self->priv->progress_bar);
	self->priv->progress_bar = _tmp9_;
	_tmp10_ = g_strdup ("caption");
	_tmp11_ = g_new0 (gchar*, 1 + 1);
	_tmp11_[0] = _tmp10_;
	_tmp12_ = (GtkLabel*) gtk_label_new ("");
	gtk_widget_set_halign ((GtkWidget*) _tmp12_, GTK_ALIGN_START);
	gtk_label_set_xalign (_tmp12_, (gfloat) 0);
	gtk_widget_set_css_classes ((GtkWidget*) _tmp12_, _tmp11_);
	_tmp11_ = (_vala_array_free (_tmp11_, 1, (GDestroyNotify) g_free), NULL);
	gtk_label_set_ellipsize (_tmp12_, PANGO_ELLIPSIZE_END);
	gtk_label_set_max_width_chars (_tmp12_, 24);
	g_object_ref_sink (_tmp12_);
	_g_object_unref0 (self->priv->status_label);
	self->priv->status_label = _tmp12_;
	_tmp13_ = g_strdup ("caption");
	_tmp14_ = g_new0 (gchar*, 1 + 1);
	_tmp14_[0] = _tmp13_;
	_tmp15_ = (GtkLabel*) gtk_label_new ("");
	gtk_widget_set_halign ((GtkWidget*) _tmp15_, GTK_ALIGN_START);
	gtk_label_set_xalign (_tmp15_, (gfloat) 0);
	gtk_widget_set_css_classes ((GtkWidget*) _tmp15_, _tmp14_);
	_tmp14_ = (_vala_array_free (_tmp14_, 1, (GDestroyNotify) g_free), NULL);
	gtk_label_set_ellipsize (_tmp15_, PANGO_ELLIPSIZE_END);
	gtk_label_set_max_width_chars (_tmp15_, 24);
	g_object_ref_sink (_tmp15_);
	_g_object_unref0 (self->priv->metrics_label);
	self->priv->metrics_label = _tmp15_;
	_tmp16_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_VERTICAL, 4);
	gtk_widget_set_valign ((GtkWidget*) _tmp16_, GTK_ALIGN_CENTER);
	g_object_set ((GtkWidget*) _tmp16_, "width-request", 150, NULL);
	gtk_widget_set_margin_top ((GtkWidget*) _tmp16_, 6);
	g_object_ref_sink (_tmp16_);
	progress_box = _tmp16_;
	_tmp17_ = self->priv->progress_bar;
	gtk_box_append (progress_box, (GtkWidget*) _tmp17_);
	_tmp18_ = self->priv->status_label;
	gtk_box_append (progress_box, (GtkWidget*) _tmp18_);
	_tmp19_ = self->priv->metrics_label;
	gtk_box_append (progress_box, (GtkWidget*) _tmp19_);
	_tmp20_ = (GtkButton*) gtk_button_new_from_icon_name ("process-stop-symbolic");
	gtk_widget_set_valign ((GtkWidget*) _tmp20_, GTK_ALIGN_CENTER);
	g_object_ref_sink (_tmp20_);
	_g_object_unref0 (self->priv->cancel_button);
	self->priv->cancel_button = _tmp20_;
	_tmp21_ = self->priv->cancel_button;
	gtk_widget_add_css_class ((GtkWidget*) _tmp21_, "flat");
	_tmp22_ = self->priv->cancel_button;
	gtk_widget_set_tooltip_text ((GtkWidget*) _tmp22_, _ ("Cancel"));
	_tmp23_ = self->priv->cancel_button;
	gtk_accessible_update_property ((GtkAccessible*) _tmp23_, GTK_ACCESSIBLE_PROPERTY_LABEL, _ ("Cancel"), -1, -1);
	_tmp24_ = self->priv->cancel_button;
	g_signal_connect_data (_tmp24_, "clicked", (GCallback) ___lambda194__gtk_button_clicked, block9_data_ref (_data9_), (GClosureNotify) block9_data_unref, 0);
	adw_action_row_add_suffix ((AdwActionRow*) self, (GtkWidget*) progress_box);
	_tmp25_ = self->priv->cancel_button;
	adw_action_row_add_suffix ((AdwActionRow*) self, (GtkWidget*) _tmp25_);
	_tmp26_ = g_signal_connect_object (_data9_->job, "progress-updated", (GCallback) _proton_plus_widgets_header_download_entry_update_display_proton_plus_services_install_job_progress_updated, self, 0);
	self->priv->progress_handler = _tmp26_;
	_tmp27_ = g_signal_connect_object ((GObject*) _data9_->job, "notify::step", (GCallback) _proton_plus_widgets_header_download_entry_update_display_g_object_notify, self, 0);
	self->priv->step_handler = _tmp27_;
	_tmp28_ = g_signal_connect_object ((GObject*) _data9_->job, "notify::canceled", (GCallback) _proton_plus_widgets_header_download_entry_update_display_g_object_notify, self, 0);
	self->priv->canceled_handler = _tmp28_;
	proton_plus_widgets_header_download_entry_update_display (self);
	_g_object_unref0 (progress_box);
	block9_data_unref (_data9_);
	_data9_ = NULL;
	return self;
}

ProtonPlusWidgetsHeaderDownloadEntry*
proton_plus_widgets_header_download_entry_new (ProtonPlusServicesInstallJob* job)
{
	return proton_plus_widgets_header_download_entry_construct (PROTON_PLUS_WIDGETS_HEADER_TYPE_DOWNLOAD_ENTRY, job);
}

static void
proton_plus_widgets_header_download_entry_real_dispose (GObject* base)
{
	ProtonPlusWidgetsHeaderDownloadEntry * self;
	self = (ProtonPlusWidgetsHeaderDownloadEntry*) base;
	proton_plus_widgets_header_download_entry_disconnect_release_signals (self);
	G_OBJECT_CLASS (proton_plus_widgets_header_download_entry_parent_class)->dispose ((GObject*) G_TYPE_CHECK_INSTANCE_CAST (self, adw_action_row_get_type (), AdwActionRow));
}

void
proton_plus_widgets_header_download_entry_disconnect_release_signals (ProtonPlusWidgetsHeaderDownloadEntry* self)
{
	g_return_if_fail (self != NULL);
	if (self->priv->progress_handler != ((gulong) 0)) {
		ProtonPlusServicesInstallJob* _tmp0_;
		_tmp0_ = self->priv->job;
		g_signal_handler_disconnect ((GObject*) _tmp0_, self->priv->progress_handler);
		self->priv->progress_handler = (gulong) 0;
	}
	if (self->priv->step_handler != ((gulong) 0)) {
		ProtonPlusServicesInstallJob* _tmp1_;
		_tmp1_ = self->priv->job;
		g_signal_handler_disconnect ((GObject*) _tmp1_, self->priv->step_handler);
		self->priv->step_handler = (gulong) 0;
	}
	if (self->priv->canceled_handler != ((gulong) 0)) {
		ProtonPlusServicesInstallJob* _tmp2_;
		_tmp2_ = self->priv->job;
		g_signal_handler_disconnect ((GObject*) _tmp2_, self->priv->canceled_handler);
		self->priv->canceled_handler = (gulong) 0;
	}
}

static gchar*
string_replace (const gchar* self,
                const gchar* old,
                const gchar* replacement)
{
	gboolean _tmp0_ = FALSE;
	gboolean _tmp1_ = FALSE;
	GError* _inner_error0_ = NULL;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	g_return_val_if_fail (old != NULL, NULL);
	g_return_val_if_fail (replacement != NULL, NULL);
	if ((*((gchar*) self)) == '\0') {
		_tmp1_ = TRUE;
	} else {
		_tmp1_ = (*((gchar*) old)) == '\0';
	}
	if (_tmp1_) {
		_tmp0_ = TRUE;
	} else {
		_tmp0_ = g_strcmp0 (old, replacement) == 0;
	}
	if (_tmp0_) {
		gchar* _tmp2_;
		_tmp2_ = g_strdup (self);
		result = _tmp2_;
		return result;
	}
	{
		GRegex* regex = NULL;
		gchar* _tmp3_;
		gchar* _tmp4_;
		GRegex* _tmp5_;
		GRegex* _tmp6_;
		gchar* _tmp7_ = NULL;
		GRegex* _tmp8_;
		gchar* _tmp9_;
		gchar* _tmp10_;
		_tmp3_ = g_regex_escape_string (old, -1);
		_tmp4_ = _tmp3_;
		_tmp5_ = g_regex_new (_tmp4_, 0, 0, &_inner_error0_);
		_tmp6_ = _tmp5_;
		_g_free0 (_tmp4_);
		regex = _tmp6_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			if (_inner_error0_->domain == G_REGEX_ERROR) {
				goto __catch0_g_regex_error;
			}
			g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
			g_clear_error (&_inner_error0_);
			return NULL;
		}
		_tmp8_ = regex;
		_tmp9_ = g_regex_replace_literal (_tmp8_, self, (gssize) -1, 0, replacement, 0, &_inner_error0_);
		_tmp7_ = _tmp9_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			_g_regex_unref0 (regex);
			if (_inner_error0_->domain == G_REGEX_ERROR) {
				goto __catch0_g_regex_error;
			}
			g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
			g_clear_error (&_inner_error0_);
			return NULL;
		}
		_tmp10_ = _tmp7_;
		_tmp7_ = NULL;
		result = _tmp10_;
		_g_free0 (_tmp7_);
		_g_regex_unref0 (regex);
		return result;
	}
	goto __finally0;
	__catch0_g_regex_error:
	{
		g_clear_error (&_inner_error0_);
		g_assert_not_reached ();
	}
	__finally0:
	g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
	g_clear_error (&_inner_error0_);
	return NULL;
}

static gdouble
double_parse (const gchar* str)
{
	gdouble result;
	g_return_val_if_fail (str != NULL, -1.0);
	result = g_ascii_strtod (str, NULL);
	return result;
}

static void
proton_plus_widgets_header_download_entry_update_display (ProtonPlusWidgetsHeaderDownloadEntry* self)
{
	gchar* step_text = NULL;
	gchar* _tmp0_;
	gchar* percent_text = NULL;
	gchar* _tmp1_;
	gboolean _tmp2_ = FALSE;
	ProtonPlusServicesInstallJob* _tmp3_;
	gboolean _tmp4_;
	gboolean _tmp5_;
	ProtonPlusServicesInstallJob* _tmp20_;
	gboolean _tmp21_;
	gboolean _tmp22_;
	gchar* status = NULL;
	const gchar* _tmp27_;
	gchar* _tmp28_;
	const gchar* _tmp29_;
	gchar* speed = NULL;
	gchar* _tmp35_;
	ProtonPlusServicesInstallJob* _tmp36_;
	ProtonPlusServicesInstallJobStep _tmp37_;
	ProtonPlusServicesInstallJobStep _tmp38_;
	GtkLabel* _tmp45_;
	const gchar* _tmp46_;
	gdouble _tmp47_ = 0.0;
	ProtonPlusServicesInstallJob* _tmp48_;
	ProtonPlusServicesInstallJobStep _tmp49_;
	ProtonPlusServicesInstallJobStep _tmp50_;
	gchar* eta = NULL;
	gchar* _tmp54_;
	GtkLabel* _tmp55_;
	const gchar* _tmp56_;
	gchar* _tmp57_;
	gchar* _tmp58_;
	g_return_if_fail (self != NULL);
	_tmp0_ = proton_plus_widgets_header_download_entry_get_step_text (self);
	step_text = _tmp0_;
	_tmp1_ = g_strdup ("");
	percent_text = _tmp1_;
	_tmp3_ = self->priv->job;
	_tmp4_ = proton_plus_services_install_job_get_is_percent (_tmp3_);
	_tmp5_ = _tmp4_;
	if (_tmp5_) {
		ProtonPlusServicesInstallJob* _tmp6_;
		const gchar* _tmp7_;
		const gchar* _tmp8_;
		_tmp6_ = self->priv->job;
		_tmp7_ = proton_plus_services_install_job_get_progress (_tmp6_);
		_tmp8_ = _tmp7_;
		_tmp2_ = _tmp8_ != NULL;
	} else {
		_tmp2_ = FALSE;
	}
	if (_tmp2_) {
		gchar* value = NULL;
		ProtonPlusServicesInstallJob* _tmp9_;
		const gchar* _tmp10_;
		const gchar* _tmp11_;
		gchar* _tmp12_;
		GtkProgressBar* _tmp13_;
		const gchar* _tmp14_;
		ProtonPlusServicesInstallJob* _tmp15_;
		const gchar* _tmp16_;
		const gchar* _tmp17_;
		gchar* _tmp18_;
		_tmp9_ = self->priv->job;
		_tmp10_ = proton_plus_services_install_job_get_progress (_tmp9_);
		_tmp11_ = _tmp10_;
		_tmp12_ = string_replace (_tmp11_, "%", "");
		value = _tmp12_;
		_tmp13_ = self->priv->progress_bar;
		_tmp14_ = value;
		gtk_progress_bar_set_fraction (_tmp13_, double_parse (_tmp14_) / 100.0);
		_tmp15_ = self->priv->job;
		_tmp16_ = proton_plus_services_install_job_get_progress (_tmp15_);
		_tmp17_ = _tmp16_;
		_tmp18_ = g_strdup (_tmp17_);
		_g_free0 (percent_text);
		percent_text = _tmp18_;
		_g_free0 (value);
	} else {
		GtkProgressBar* _tmp19_;
		_tmp19_ = self->priv->progress_bar;
		gtk_progress_bar_set_fraction (_tmp19_, 0.0);
	}
	_tmp20_ = self->priv->job;
	_tmp21_ = proton_plus_services_install_job_get_canceled (_tmp20_);
	_tmp22_ = _tmp21_;
	if (_tmp22_) {
		gchar* _tmp23_;
		GtkButton* _tmp24_;
		GtkButton* _tmp25_;
		GtkButton* _tmp26_;
		_tmp23_ = g_strdup (_ ("Cancelling"));
		_g_free0 (step_text);
		step_text = _tmp23_;
		_tmp24_ = self->priv->cancel_button;
		gtk_widget_set_sensitive ((GtkWidget*) _tmp24_, FALSE);
		_tmp25_ = self->priv->cancel_button;
		gtk_widget_set_tooltip_text ((GtkWidget*) _tmp25_, _ ("Cancelling"));
		_tmp26_ = self->priv->cancel_button;
		gtk_accessible_update_property ((GtkAccessible*) _tmp26_, GTK_ACCESSIBLE_PROPERTY_LABEL, _ ("Cancelling"), -1, -1);
	}
	_tmp27_ = step_text;
	_tmp28_ = g_strdup (_tmp27_);
	status = _tmp28_;
	_tmp29_ = percent_text;
	if (g_strcmp0 (_tmp29_, "") != 0) {
		const gchar* _tmp30_;
		const gchar* _tmp31_;
		gchar* _tmp32_;
		gchar* _tmp33_;
		gchar* _tmp34_;
		_tmp30_ = status;
		_tmp31_ = percent_text;
		_tmp32_ = g_strdup_printf (" · %s", _tmp31_);
		_tmp33_ = _tmp32_;
		_tmp34_ = g_strconcat (_tmp30_, _tmp33_, NULL);
		_g_free0 (status);
		status = _tmp34_;
		_g_free0 (_tmp33_);
	}
	_tmp35_ = g_strdup ("--");
	speed = _tmp35_;
	_tmp36_ = self->priv->job;
	_tmp37_ = proton_plus_services_install_job_get_step (_tmp36_);
	_tmp38_ = _tmp37_;
	if (_tmp38_ == PROTON_PLUS_SERVICES_INSTALL_JOB_STEP_DOWNLOADING) {
		ProtonPlusServicesInstallJob* _tmp39_;
		gdouble _tmp40_;
		gdouble _tmp41_;
		gchar* _tmp42_;
		gchar* _tmp43_;
		gchar* _tmp44_;
		_tmp39_ = self->priv->job;
		_tmp40_ = proton_plus_services_install_job_get_speed_kbps (_tmp39_);
		_tmp41_ = _tmp40_;
		_tmp42_ = proton_plus_utils_filesystem_convert_bytes_to_string ((gint64) (_tmp41_ * 1024));
		_tmp43_ = _tmp42_;
		_tmp44_ = g_strdup_printf ("%s/s", _tmp43_);
		_g_free0 (speed);
		speed = _tmp44_;
		_g_free0 (_tmp43_);
	}
	_tmp45_ = self->priv->status_label;
	_tmp46_ = status;
	gtk_label_set_label (_tmp45_, _tmp46_);
	_tmp48_ = self->priv->job;
	_tmp49_ = proton_plus_services_install_job_get_step (_tmp48_);
	_tmp50_ = _tmp49_;
	if (_tmp50_ == PROTON_PLUS_SERVICES_INSTALL_JOB_STEP_DOWNLOADING) {
		ProtonPlusServicesInstallJob* _tmp51_;
		gdouble _tmp52_;
		gdouble _tmp53_;
		_tmp51_ = self->priv->job;
		_tmp52_ = proton_plus_services_install_job_get_seconds_remaining (_tmp51_);
		_tmp53_ = _tmp52_;
		_tmp47_ = _tmp53_;
	} else {
		_tmp47_ = (gdouble) -1;
	}
	_tmp54_ = proton_plus_widgets_header_download_entry_format_eta (self, _tmp47_);
	eta = _tmp54_;
	_tmp55_ = self->priv->metrics_label;
	_tmp56_ = speed;
	_tmp57_ = g_strdup_printf ("%s · %s", _tmp56_, eta);
	_tmp58_ = _tmp57_;
	gtk_label_set_label (_tmp55_, _tmp58_);
	_g_free0 (_tmp58_);
	_g_free0 (eta);
	_g_free0 (speed);
	_g_free0 (status);
	_g_free0 (percent_text);
	_g_free0 (step_text);
}

static gchar*
proton_plus_widgets_header_download_entry_get_step_text (ProtonPlusWidgetsHeaderDownloadEntry* self)
{
	ProtonPlusServicesInstallJob* _tmp0_;
	ProtonPlusServicesInstallJobStep _tmp1_;
	ProtonPlusServicesInstallJobStep _tmp2_;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->job;
	_tmp1_ = proton_plus_services_install_job_get_step (_tmp0_);
	_tmp2_ = _tmp1_;
	switch (_tmp2_) {
		case PROTON_PLUS_SERVICES_INSTALL_JOB_STEP_DOWNLOADING:
		{
			gchar* _tmp3_;
			_tmp3_ = g_strdup (_ ("Downloading"));
			result = _tmp3_;
			return result;
		}
		case PROTON_PLUS_SERVICES_INSTALL_JOB_STEP_EXTRACTING:
		{
			gchar* _tmp4_;
			_tmp4_ = g_strdup (_ ("Extracting"));
			result = _tmp4_;
			return result;
		}
		case PROTON_PLUS_SERVICES_INSTALL_JOB_STEP_MOVING:
		{
			gchar* _tmp5_;
			_tmp5_ = g_strdup (_ ("Installing"));
			result = _tmp5_;
			return result;
		}
		case PROTON_PLUS_SERVICES_INSTALL_JOB_STEP_REMOVING:
		{
			gchar* _tmp6_;
			_tmp6_ = g_strdup (_ ("Removing"));
			result = _tmp6_;
			return result;
		}
		default:
		{
			gchar* _tmp7_;
			_tmp7_ = g_strdup (_ ("Preparing"));
			result = _tmp7_;
			return result;
		}
	}
}

static gchar*
proton_plus_widgets_header_download_entry_format_eta (ProtonPlusWidgetsHeaderDownloadEntry* self,
                                                      gdouble seconds)
{
	gint total_seconds = 0;
	gint hours = 0;
	gint minutes = 0;
	gint remaining_seconds = 0;
	gchar* _tmp3_;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	if (seconds < ((gdouble) 0)) {
		gchar* _tmp0_;
		_tmp0_ = g_strdup (_ ("ETA: --"));
		result = _tmp0_;
		return result;
	}
	total_seconds = (gint) seconds;
	hours = total_seconds / 3600;
	minutes = (total_seconds % 3600) / 60;
	remaining_seconds = total_seconds % 60;
	if (hours > 0) {
		gchar* _tmp1_;
		_tmp1_ = g_strdup_printf (_ ("ETA: %dh %dm"), hours, minutes);
		result = _tmp1_;
		return result;
	}
	if (minutes > 0) {
		gchar* _tmp2_;
		_tmp2_ = g_strdup_printf (_ ("ETA: %dm %ds"), minutes, remaining_seconds);
		result = _tmp2_;
		return result;
	}
	_tmp3_ = g_strdup_printf (_ ("ETA: %ds"), remaining_seconds);
	result = _tmp3_;
	return result;
}

static void
proton_plus_widgets_header_download_entry_class_init (ProtonPlusWidgetsHeaderDownloadEntryClass * klass,
                                                      gpointer klass_data)
{
	proton_plus_widgets_header_download_entry_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &ProtonPlusWidgetsHeaderDownloadEntry_private_offset);
	((GObjectClass *) klass)->dispose = (void (*) (GObject*)) proton_plus_widgets_header_download_entry_real_dispose;
	G_OBJECT_CLASS (klass)->finalize = proton_plus_widgets_header_download_entry_finalize;
}

static void
proton_plus_widgets_header_download_entry_instance_init (ProtonPlusWidgetsHeaderDownloadEntry * self,
                                                         gpointer klass)
{
	self->priv = proton_plus_widgets_header_download_entry_get_instance_private (self);
	self->priv->progress_handler = (gulong) 0;
	self->priv->step_handler = (gulong) 0;
	self->priv->canceled_handler = (gulong) 0;
}

static void
proton_plus_widgets_header_download_entry_finalize (GObject * obj)
{
	ProtonPlusWidgetsHeaderDownloadEntry * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, PROTON_PLUS_WIDGETS_HEADER_TYPE_DOWNLOAD_ENTRY, ProtonPlusWidgetsHeaderDownloadEntry);
	_g_object_unref0 (self->priv->job);
	_g_object_unref0 (self->priv->progress_bar);
	_g_object_unref0 (self->priv->status_label);
	_g_object_unref0 (self->priv->metrics_label);
	_g_object_unref0 (self->priv->cancel_button);
	G_OBJECT_CLASS (proton_plus_widgets_header_download_entry_parent_class)->finalize (obj);
}

static GType
proton_plus_widgets_header_download_entry_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (ProtonPlusWidgetsHeaderDownloadEntryClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) proton_plus_widgets_header_download_entry_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ProtonPlusWidgetsHeaderDownloadEntry), 0, (GInstanceInitFunc) proton_plus_widgets_header_download_entry_instance_init, NULL };
	GType proton_plus_widgets_header_download_entry_type_id;
	proton_plus_widgets_header_download_entry_type_id = g_type_register_static (adw_action_row_get_type (), "ProtonPlusWidgetsHeaderDownloadEntry", &g_define_type_info, 0);
	ProtonPlusWidgetsHeaderDownloadEntry_private_offset = g_type_add_instance_private (proton_plus_widgets_header_download_entry_type_id, sizeof (ProtonPlusWidgetsHeaderDownloadEntryPrivate));
	return proton_plus_widgets_header_download_entry_type_id;
}

GType
proton_plus_widgets_header_download_entry_get_type (void)
{
	static volatile gsize proton_plus_widgets_header_download_entry_type_id__once = 0;
	if (g_once_init_enter (&proton_plus_widgets_header_download_entry_type_id__once)) {
		GType proton_plus_widgets_header_download_entry_type_id;
		proton_plus_widgets_header_download_entry_type_id = proton_plus_widgets_header_download_entry_get_type_once ();
		g_once_init_leave (&proton_plus_widgets_header_download_entry_type_id__once, proton_plus_widgets_header_download_entry_type_id);
	}
	return proton_plus_widgets_header_download_entry_type_id__once;
}

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);
}

