/* transfer-popover.c generated by valac 0.56.18-dirty, the Vala compiler
 * generated from transfer-popover.vala, do not modify */

/* This file is part of GNOME Boxes. License: LGPLv2+*/

#include <gtk/gtk.h>
#include <glib-object.h>
#include <glib.h>
#include <spice-client.h>
#include <float.h>
#include <math.h>
#include <handy.h>
#include <gio/gio.h>
#include <stdlib.h>
#include <string.h>

#define BOXES_TRANSFER_POPOVER_remove_id_timeout ((guint) 5000)
#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 BOXES_TYPE_TRANSFER_POPOVER (boxes_transfer_popover_get_type ())
#define BOXES_TRANSFER_POPOVER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), BOXES_TYPE_TRANSFER_POPOVER, BoxesTransferPopover))
#define BOXES_TRANSFER_POPOVER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), BOXES_TYPE_TRANSFER_POPOVER, BoxesTransferPopoverClass))
#define BOXES_IS_TRANSFER_POPOVER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), BOXES_TYPE_TRANSFER_POPOVER))
#define BOXES_IS_TRANSFER_POPOVER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), BOXES_TYPE_TRANSFER_POPOVER))
#define BOXES_TRANSFER_POPOVER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), BOXES_TYPE_TRANSFER_POPOVER, BoxesTransferPopoverClass))

typedef struct _BoxesTransferPopover BoxesTransferPopover;
typedef struct _BoxesTransferPopoverClass BoxesTransferPopoverClass;
typedef struct _BoxesTransferPopoverPrivate BoxesTransferPopoverPrivate;

#define BOXES_TYPE_DISPLAY_TOOLBAR (boxes_display_toolbar_get_type ())
#define BOXES_DISPLAY_TOOLBAR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), BOXES_TYPE_DISPLAY_TOOLBAR, BoxesDisplayToolbar))
#define BOXES_DISPLAY_TOOLBAR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), BOXES_TYPE_DISPLAY_TOOLBAR, BoxesDisplayToolbarClass))
#define BOXES_IS_DISPLAY_TOOLBAR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), BOXES_TYPE_DISPLAY_TOOLBAR))
#define BOXES_IS_DISPLAY_TOOLBAR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), BOXES_TYPE_DISPLAY_TOOLBAR))
#define BOXES_DISPLAY_TOOLBAR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), BOXES_TYPE_DISPLAY_TOOLBAR, BoxesDisplayToolbarClass))

typedef struct _BoxesDisplayToolbar BoxesDisplayToolbar;
typedef struct _BoxesDisplayToolbarClass BoxesDisplayToolbarClass;
enum  {
	BOXES_TRANSFER_POPOVER_0_PROPERTY,
	BOXES_TRANSFER_POPOVER_PROGRESS_PROPERTY,
	BOXES_TRANSFER_POPOVER_NUM_PROPERTIES
};
static GParamSpec* boxes_transfer_popover_properties[BOXES_TRANSFER_POPOVER_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
typedef struct _BoxesDisplayToolbarPrivate BoxesDisplayToolbarPrivate;

#define BOXES_TYPE_TRANSFER_INFO_ROW (boxes_transfer_info_row_get_type ())
#define BOXES_TRANSFER_INFO_ROW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), BOXES_TYPE_TRANSFER_INFO_ROW, BoxesTransferInfoRow))
#define BOXES_TRANSFER_INFO_ROW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), BOXES_TYPE_TRANSFER_INFO_ROW, BoxesTransferInfoRowClass))
#define BOXES_IS_TRANSFER_INFO_ROW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), BOXES_TYPE_TRANSFER_INFO_ROW))
#define BOXES_IS_TRANSFER_INFO_ROW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), BOXES_TYPE_TRANSFER_INFO_ROW))
#define BOXES_TRANSFER_INFO_ROW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), BOXES_TYPE_TRANSFER_INFO_ROW, BoxesTransferInfoRowClass))

typedef struct _BoxesTransferInfoRow BoxesTransferInfoRow;
typedef struct _BoxesTransferInfoRowClass BoxesTransferInfoRowClass;
typedef struct _Block48Data Block48Data;
#define _g_free0(var) (var = (g_free (var), NULL))

struct _BoxesTransferPopover {
	GtkPopover parent_instance;
	BoxesTransferPopoverPrivate * priv;
	GtkBox* transfers_container;
	GList* spice_tasks;
};

struct _BoxesTransferPopoverClass {
	GtkPopoverClass parent_class;
};

struct _BoxesTransferPopoverPrivate {
	gdouble _progress;
	gulong total_bytes_id;
	BoxesDisplayToolbar* display_toolbar;
};

struct _BoxesDisplayToolbar {
	HdyHeaderBar parent_instance;
	BoxesDisplayToolbarPrivate * priv;
	GtkButton* transfers_button;
};

struct _BoxesDisplayToolbarClass {
	HdyHeaderBarClass parent_class;
};

struct _Block48Data {
	int _ref_count_;
	BoxesTransferPopover* self;
	BoxesTransferInfoRow* row;
	SpiceFileTransferTask* transfer_task;
};

static gint BoxesTransferPopover_private_offset;
static gpointer boxes_transfer_popover_parent_class = NULL;

VALA_EXTERN GType boxes_transfer_popover_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (BoxesTransferPopover, g_object_unref)
VALA_EXTERN GType boxes_display_toolbar_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (BoxesDisplayToolbar, g_object_unref)
static void _g_object_unref0_ (gpointer var);
static inline void _g_list_free__g_object_unref0_ (GList* self);
VALA_EXTERN BoxesTransferPopover* boxes_transfer_popover_new (BoxesDisplayToolbar* toolbar);
VALA_EXTERN BoxesTransferPopover* boxes_transfer_popover_construct (GType object_type,
                                                        BoxesDisplayToolbar* toolbar);
static void __lambda52_ (BoxesTransferPopover* self);
static void ___lambda52__gtk_button_clicked (GtkButton* _sender,
                                      gpointer self);
VALA_EXTERN void boxes_transfer_popover_add_transfer (BoxesTransferPopover* self,
                                          GObject* transfer_task);
VALA_EXTERN void boxes_transfer_popover_add_spice_transfer (BoxesTransferPopover* self,
                                                SpiceFileTransferTask* transfer_task);
VALA_EXTERN GType boxes_transfer_info_row_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (BoxesTransferInfoRow, g_object_unref)
static Block48Data* block48_data_ref (Block48Data* _data48_);
static void block48_data_unref (void * _userdata_);
VALA_EXTERN BoxesTransferInfoRow* boxes_transfer_info_row_new (const gchar* name);
VALA_EXTERN BoxesTransferInfoRow* boxes_transfer_info_row_construct (GType object_type,
                                                         const gchar* name);
static void __lambda54_ (Block48Data* _data48_,
                  GObject* t,
                  GParamSpec* p);
VALA_EXTERN void boxes_transfer_info_row_set_total_bytes (BoxesTransferInfoRow* self,
                                              guint64 value);
static void ___lambda54__g_object_notify (GObject* _sender,
                                   GParamSpec* pspec,
                                   gpointer self);
static void __lambda55_ (Block48Data* _data48_,
                  GObject* t,
                  GParamSpec* p);
VALA_EXTERN void boxes_transfer_info_row_set_progress (BoxesTransferInfoRow* self,
                                           gdouble value);
VALA_EXTERN void boxes_transfer_popover_set_progress (BoxesTransferPopover* self,
                                          gdouble value);
static void ___lambda55__g_object_notify (GObject* _sender,
                                   GParamSpec* pspec,
                                   gpointer self);
static void __lambda56_ (Block48Data* _data48_,
                  SpiceFileTransferTask* transfer_task,
                  GError* _error_);
VALA_EXTERN void boxes_transfer_info_row_finalize_transfer (BoxesTransferInfoRow* self);
static gboolean ___lambda57_ (BoxesTransferPopover* self);
static void boxes_transfer_popover_on_transfer_finished (BoxesTransferPopover* self);
static gboolean ____lambda57__gsource_func (gpointer self);
static void ___lambda56__spice_file_transfer_task_finished (SpiceFileTransferTask* _sender,
                                                     GError* object,
                                                     gpointer self);
static void __lambda58_ (Block48Data* _data48_);
static gboolean ___lambda59_ (BoxesTransferPopover* self);
static gboolean ____lambda59__gsource_func (gpointer self);
static void ___lambda58__boxes_transfer_info_row_finished (BoxesTransferInfoRow* _sender,
                                                    gpointer self);
VALA_EXTERN void boxes_transfer_popover_clean_up (BoxesTransferPopover* self);
VALA_EXTERN void boxes_display_toolbar_set_progress (BoxesDisplayToolbar* self,
                                         gdouble value);
VALA_EXTERN gdouble boxes_transfer_popover_get_progress (BoxesTransferPopover* self);
static void boxes_transfer_popover_finalize (GObject * obj);
static GType boxes_transfer_popover_get_type_once (void);
static void _vala_boxes_transfer_popover_get_property (GObject * object,
                                                guint property_id,
                                                GValue * value,
                                                GParamSpec * pspec);
static void _vala_boxes_transfer_popover_set_property (GObject * object,
                                                guint property_id,
                                                const GValue * value,
                                                GParamSpec * pspec);

static inline gpointer
boxes_transfer_popover_get_instance_private (BoxesTransferPopover* self)
{
	return G_STRUCT_MEMBER_P (self, BoxesTransferPopover_private_offset);
}

static void
_g_object_unref0_ (gpointer var)
{
	(var == NULL) ? NULL : (var = (g_object_unref (var), NULL));
}

static inline void
_g_list_free__g_object_unref0_ (GList* self)
{
	g_list_free_full (self, (GDestroyNotify) _g_object_unref0_);
}

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

static void
__lambda52_ (BoxesTransferPopover* self)
{
	gboolean _tmp0_;
	gboolean _tmp1_;
	_tmp0_ = gtk_widget_get_visible ((GtkWidget*) self);
	_tmp1_ = _tmp0_;
	if (_tmp1_) {
		gtk_popover_popdown ((GtkPopover*) self);
	} else {
		gtk_popover_popup ((GtkPopover*) self);
	}
}

static void
___lambda52__gtk_button_clicked (GtkButton* _sender,
                                 gpointer self)
{
	__lambda52_ ((BoxesTransferPopover*) self);
}

BoxesTransferPopover*
boxes_transfer_popover_construct (GType object_type,
                                  BoxesDisplayToolbar* toolbar)
{
	BoxesTransferPopover * self = NULL;
	BoxesDisplayToolbar* _tmp0_;
	BoxesDisplayToolbar* _tmp1_;
	GtkButton* _tmp2_;
	BoxesDisplayToolbar* _tmp3_;
	GtkButton* _tmp4_;
	BoxesDisplayToolbar* _tmp5_;
	g_return_val_if_fail (toolbar != NULL, NULL);
	self = (BoxesTransferPopover*) g_object_new (object_type, NULL);
	_tmp0_ = _g_object_ref0 (toolbar);
	_g_object_unref0 (self->priv->display_toolbar);
	self->priv->display_toolbar = _tmp0_;
	_tmp1_ = self->priv->display_toolbar;
	_tmp2_ = _tmp1_->transfers_button;
	gtk_popover_set_relative_to ((GtkPopover*) self, (GtkWidget*) _tmp2_);
	_tmp3_ = self->priv->display_toolbar;
	_tmp4_ = _tmp3_->transfers_button;
	g_signal_connect_object (_tmp4_, "clicked", (GCallback) ___lambda52__gtk_button_clicked, self, 0);
	_tmp5_ = self->priv->display_toolbar;
	g_object_bind_property_with_closures ((GObject*) self, "progress", (GObject*) _tmp5_, "progress", G_BINDING_DEFAULT, (GClosure*) ((NULL == NULL) ? NULL : g_cclosure_new ((GCallback) NULL, NULL, (GClosureNotify) NULL)), (GClosure*) ((NULL == NULL) ? NULL : g_cclosure_new ((GCallback) NULL, NULL, (GClosureNotify) NULL)));
	return self;
}

BoxesTransferPopover*
boxes_transfer_popover_new (BoxesDisplayToolbar* toolbar)
{
	return boxes_transfer_popover_construct (BOXES_TYPE_TRANSFER_POPOVER, toolbar);
}

void
boxes_transfer_popover_add_transfer (BoxesTransferPopover* self,
                                     GObject* transfer_task)
{
	g_return_if_fail (self != NULL);
	g_return_if_fail (transfer_task != NULL);
	if (G_TYPE_CHECK_INSTANCE_TYPE (transfer_task, spice_file_transfer_task_get_type ())) {
		SpiceFileTransferTask* spice_transfer_task = NULL;
		SpiceFileTransferTask* _tmp0_;
		SpiceFileTransferTask* _tmp1_;
		_tmp0_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (transfer_task, spice_file_transfer_task_get_type ()) ? ((SpiceFileTransferTask*) transfer_task) : NULL);
		spice_transfer_task = _tmp0_;
		_tmp1_ = spice_transfer_task;
		boxes_transfer_popover_add_spice_transfer (self, _tmp1_);
		_g_object_unref0 (spice_transfer_task);
	} else {
		g_warning ("transfer-popover.vala:36: File transfer of unsupported type.");
	}
	gtk_popover_popup ((GtkPopover*) self);
}

static Block48Data*
block48_data_ref (Block48Data* _data48_)
{
	g_atomic_int_inc (&_data48_->_ref_count_);
	return _data48_;
}

static void
block48_data_unref (void * _userdata_)
{
	Block48Data* _data48_;
	_data48_ = (Block48Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data48_->_ref_count_)) {
		BoxesTransferPopover* self;
		self = _data48_->self;
		_g_object_unref0 (_data48_->row);
		_g_object_unref0 (_data48_->transfer_task);
		_g_object_unref0 (self);
		g_slice_free (Block48Data, _data48_);
	}
}

static void
__lambda54_ (Block48Data* _data48_,
             GObject* t,
             GParamSpec* p)
{
	BoxesTransferPopover* self;
	guint64 _tmp0_;
	guint64 _tmp1_;
	self = _data48_->self;
	g_return_if_fail (t != NULL);
	g_return_if_fail (p != NULL);
	_tmp0_ = spice_file_transfer_task_get_total_bytes (_data48_->transfer_task);
	_tmp1_ = _tmp0_;
	boxes_transfer_info_row_set_total_bytes (_data48_->row, _tmp1_);
	g_signal_handler_disconnect ((GObject*) _data48_->transfer_task, self->priv->total_bytes_id);
}

static void
___lambda54__g_object_notify (GObject* _sender,
                              GParamSpec* pspec,
                              gpointer self)
{
	__lambda54_ (self, _sender, pspec);
}

static void
__lambda55_ (Block48Data* _data48_,
             GObject* t,
             GParamSpec* p)
{
	BoxesTransferPopover* self;
	gdouble _tmp0_;
	gdouble _tmp1_;
	gdouble total = 0.0;
	gdouble transferred = 0.0;
	GList* _tmp2_;
	self = _data48_->self;
	g_return_if_fail (t != NULL);
	g_return_if_fail (p != NULL);
	_tmp0_ = spice_file_transfer_task_get_progress (_data48_->transfer_task);
	_tmp1_ = _tmp0_;
	boxes_transfer_info_row_set_progress (_data48_->row, _tmp1_);
	total = (gdouble) 0;
	transferred = (gdouble) 0;
	_tmp2_ = self->spice_tasks;
	{
		GList* task_collection = NULL;
		GList* task_it = NULL;
		task_collection = _tmp2_;
		for (task_it = task_collection; task_it != NULL; task_it = task_it->next) {
			SpiceFileTransferTask* _tmp3_;
			SpiceFileTransferTask* task = NULL;
			_tmp3_ = _g_object_ref0 ((SpiceFileTransferTask*) task_it->data);
			task = _tmp3_;
			{
				SpiceFileTransferTask* _tmp4_;
				SpiceFileTransferTask* _tmp5_;
				_tmp4_ = task;
				total += (gdouble) spice_file_transfer_task_get_total_bytes (_tmp4_);
				_tmp5_ = task;
				transferred += (gdouble) spice_file_transfer_task_get_transferred_bytes (_tmp5_);
				_g_object_unref0 (task);
			}
		}
	}
	boxes_transfer_popover_set_progress (self, transferred / total);
}

static void
___lambda55__g_object_notify (GObject* _sender,
                              GParamSpec* pspec,
                              gpointer self)
{
	__lambda55_ (self, _sender, pspec);
}

static GList*
vala_g_list_remove_full (GList* self,
                         gconstpointer data,
                         GFreeFunc func)
{
	GList* l = NULL;
	GList* result;
	l = self;
	while (TRUE) {
		GList* _tmp0_;
		GList* _tmp1_;
		gconstpointer _tmp2_;
		_tmp0_ = l;
		if (!(_tmp0_ != NULL)) {
			break;
		}
		_tmp1_ = l;
		_tmp2_ = ((GList*) _tmp1_)->data;
		if (_tmp2_ != data) {
			GList* _tmp3_;
			GList* _tmp4_;
			_tmp3_ = l;
			_tmp4_ = ((GList*) _tmp3_)->next;
			l = _tmp4_;
		} else {
			GList* _tmp5_;
			gconstpointer _tmp6_;
			GList* _tmp7_;
			_tmp5_ = l;
			_tmp6_ = ((GList*) _tmp5_)->data;
			func (_tmp6_);
			_tmp7_ = l;
			self = g_list_delete_link (self, (GList*) _tmp7_);
			break;
		}
	}
	result = self;
	return result;
}

static gboolean
___lambda57_ (BoxesTransferPopover* self)
{
	gboolean result;
	boxes_transfer_popover_on_transfer_finished (self);
	result = FALSE;
	return result;
}

static gboolean
____lambda57__gsource_func (gpointer self)
{
	gboolean result;
	result = ___lambda57_ ((BoxesTransferPopover*) self);
	return result;
}

static void
__lambda56_ (Block48Data* _data48_,
             SpiceFileTransferTask* transfer_task,
             GError* _error_)
{
	BoxesTransferPopover* self;
	GList* _tmp1_;
	self = _data48_->self;
	g_return_if_fail (transfer_task != NULL);
	g_return_if_fail (_error_ != NULL);
	if (_error_ != NULL) {
		const gchar* _tmp0_;
		_tmp0_ = _error_->message;
		g_warning ("transfer-popover.vala:68: %s", _tmp0_);
	}
	boxes_transfer_info_row_finalize_transfer (_data48_->row);
	self->spice_tasks = vala_g_list_remove_full (self->spice_tasks, transfer_task, _g_object_unref0_);
	_tmp1_ = self->spice_tasks;
	if (g_list_length (_tmp1_) == ((guint) 0)) {
		g_timeout_add_full (G_PRIORITY_DEFAULT, BOXES_TRANSFER_POPOVER_remove_id_timeout, ____lambda57__gsource_func, g_object_ref (self), g_object_unref);
	}
}

static void
___lambda56__spice_file_transfer_task_finished (SpiceFileTransferTask* _sender,
                                                GError* object,
                                                gpointer self)
{
	__lambda56_ (self, _sender, object);
}

static gboolean
___lambda59_ (BoxesTransferPopover* self)
{
	gboolean result;
	boxes_transfer_popover_on_transfer_finished (self);
	result = FALSE;
	return result;
}

static gboolean
____lambda59__gsource_func (gpointer self)
{
	gboolean result;
	result = ___lambda59_ ((BoxesTransferPopover*) self);
	return result;
}

static void
__lambda58_ (Block48Data* _data48_)
{
	BoxesTransferPopover* self;
	GList* _tmp0_;
	self = _data48_->self;
	self->spice_tasks = vala_g_list_remove_full (self->spice_tasks, _data48_->transfer_task, _g_object_unref0_);
	_tmp0_ = self->spice_tasks;
	if (g_list_length (_tmp0_) == ((guint) 0)) {
		g_timeout_add_full (G_PRIORITY_DEFAULT, BOXES_TRANSFER_POPOVER_remove_id_timeout, ____lambda59__gsource_func, g_object_ref (self), g_object_unref);
	}
}

static void
___lambda58__boxes_transfer_info_row_finished (BoxesTransferInfoRow* _sender,
                                               gpointer self)
{
	__lambda58_ (self);
}

void
boxes_transfer_popover_add_spice_transfer (BoxesTransferPopover* self,
                                           SpiceFileTransferTask* transfer_task)
{
	Block48Data* _data48_;
	SpiceFileTransferTask* _tmp0_;
	SpiceFileTransferTask* _tmp1_;
	GFile* _tmp2_;
	GFile* _tmp3_;
	GFile* _tmp4_;
	gchar* _tmp5_;
	gchar* _tmp6_;
	BoxesTransferInfoRow* _tmp7_;
	BoxesTransferInfoRow* _tmp8_;
	gulong _tmp9_;
	GtkBox* _tmp10_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (transfer_task != NULL);
	_data48_ = g_slice_new0 (Block48Data);
	_data48_->_ref_count_ = 1;
	_data48_->self = g_object_ref (self);
	_tmp0_ = _g_object_ref0 (transfer_task);
	_g_object_unref0 (_data48_->transfer_task);
	_data48_->transfer_task = _tmp0_;
	_tmp1_ = _g_object_ref0 (_data48_->transfer_task);
	self->spice_tasks = g_list_append (self->spice_tasks, _tmp1_);
	g_object_get (_data48_->transfer_task, "file", &_tmp2_, NULL);
	_tmp3_ = _tmp2_;
	_tmp4_ = _tmp3_;
	_tmp5_ = g_file_get_basename (_tmp4_);
	_tmp6_ = _tmp5_;
	_tmp7_ = boxes_transfer_info_row_new (_tmp6_);
	g_object_ref_sink (_tmp7_);
	_tmp8_ = _tmp7_;
	_g_free0 (_tmp6_);
	_g_object_unref0 (_tmp4_);
	_data48_->row = _tmp8_;
	g_object_bind_property_with_closures ((GObject*) _data48_->transfer_task, "transferred-bytes", (GObject*) _data48_->row, "transferred-bytes", G_BINDING_SYNC_CREATE, (GClosure*) ((NULL == NULL) ? NULL : g_cclosure_new ((GCallback) NULL, NULL, (GClosureNotify) NULL)), (GClosure*) ((NULL == NULL) ? NULL : g_cclosure_new ((GCallback) NULL, NULL, (GClosureNotify) NULL)));
	_tmp9_ = g_signal_connect_data ((GObject*) _data48_->transfer_task, "notify::total-bytes", (GCallback) ___lambda54__g_object_notify, block48_data_ref (_data48_), (GClosureNotify) block48_data_unref, 0);
	self->priv->total_bytes_id = _tmp9_;
	g_signal_connect_data ((GObject*) _data48_->transfer_task, "notify::progress", (GCallback) ___lambda55__g_object_notify, block48_data_ref (_data48_), (GClosureNotify) block48_data_unref, 0);
	g_signal_connect_data (_data48_->transfer_task, "finished", (GCallback) ___lambda56__spice_file_transfer_task_finished, block48_data_ref (_data48_), (GClosureNotify) block48_data_unref, 0);
	g_signal_connect_data (_data48_->row, "finished", (GCallback) ___lambda58__boxes_transfer_info_row_finished, block48_data_ref (_data48_), (GClosureNotify) block48_data_unref, 0);
	_tmp10_ = self->transfers_container;
	gtk_box_pack_start (_tmp10_, (GtkWidget*) _data48_->row, TRUE, TRUE, (guint) 0);
	gtk_widget_show ((GtkWidget*) _data48_->row);
	block48_data_unref (_data48_);
	_data48_ = NULL;
}

void
boxes_transfer_popover_clean_up (BoxesTransferPopover* self)
{
	GtkBox* _tmp0_;
	GList* _tmp1_;
	BoxesDisplayToolbar* _tmp4_;
	BoxesDisplayToolbar* _tmp5_;
	GtkButton* _tmp6_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->transfers_container;
	_tmp1_ = gtk_container_get_children ((GtkContainer*) _tmp0_);
	{
		GList* row_collection = NULL;
		GList* row_it = NULL;
		row_collection = _tmp1_;
		for (row_it = row_collection; row_it != NULL; row_it = row_it->next) {
			GtkWidget* row = NULL;
			row = (GtkWidget*) row_it->data;
			{
				GtkBox* _tmp2_;
				GtkWidget* _tmp3_;
				_tmp2_ = self->transfers_container;
				_tmp3_ = row;
				gtk_container_remove ((GtkContainer*) _tmp2_, _tmp3_);
			}
		}
		(row_collection == NULL) ? NULL : (row_collection = (g_list_free (row_collection), NULL));
	}
	gtk_popover_popdown ((GtkPopover*) self);
	_tmp4_ = self->priv->display_toolbar;
	boxes_display_toolbar_set_progress (_tmp4_, (gdouble) 0);
	_tmp5_ = self->priv->display_toolbar;
	_tmp6_ = _tmp5_->transfers_button;
	gtk_widget_hide ((GtkWidget*) _tmp6_);
}

static void
boxes_transfer_popover_on_transfer_finished (BoxesTransferPopover* self)
{
	g_return_if_fail (self != NULL);
	boxes_transfer_popover_clean_up (self);
	gtk_popover_popdown ((GtkPopover*) self);
}

gdouble
boxes_transfer_popover_get_progress (BoxesTransferPopover* self)
{
	gdouble result;
	g_return_val_if_fail (self != NULL, 0.0);
	result = self->priv->_progress;
	return result;
}

void
boxes_transfer_popover_set_progress (BoxesTransferPopover* self,
                                     gdouble value)
{
	gdouble old_value;
	g_return_if_fail (self != NULL);
	old_value = boxes_transfer_popover_get_progress (self);
	if (old_value != value) {
		self->priv->_progress = value;
		g_object_notify_by_pspec ((GObject *) self, boxes_transfer_popover_properties[BOXES_TRANSFER_POPOVER_PROGRESS_PROPERTY]);
	}
}

static void
boxes_transfer_popover_class_init (BoxesTransferPopoverClass * klass,
                                   gpointer klass_data)
{
	boxes_transfer_popover_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &BoxesTransferPopover_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_boxes_transfer_popover_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_boxes_transfer_popover_set_property;
	G_OBJECT_CLASS (klass)->finalize = boxes_transfer_popover_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), BOXES_TRANSFER_POPOVER_PROGRESS_PROPERTY, boxes_transfer_popover_properties[BOXES_TRANSFER_POPOVER_PROGRESS_PROPERTY] = g_param_spec_double ("progress", "progress", "progress", -G_MAXDOUBLE, G_MAXDOUBLE, 0.0, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	gtk_widget_class_set_template_from_resource (GTK_WIDGET_CLASS (klass), "/org/gnome/Boxes/ui/transfer-popover.ui");
	gtk_widget_class_bind_template_child_full (GTK_WIDGET_CLASS (klass), "transfers_container", FALSE, G_STRUCT_OFFSET (BoxesTransferPopover, transfers_container));
}

static void
boxes_transfer_popover_instance_init (BoxesTransferPopover * self,
                                      gpointer klass)
{
	self->priv = boxes_transfer_popover_get_instance_private (self);
	self->priv->total_bytes_id = (gulong) 0;
	gtk_widget_init_template (GTK_WIDGET (self));
}

static void
boxes_transfer_popover_finalize (GObject * obj)
{
	BoxesTransferPopover * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, BOXES_TYPE_TRANSFER_POPOVER, BoxesTransferPopover);
	(self->spice_tasks == NULL) ? NULL : (self->spice_tasks = (_g_list_free__g_object_unref0_ (self->spice_tasks), NULL));
	_g_object_unref0 (self->priv->display_toolbar);
	G_OBJECT_CLASS (boxes_transfer_popover_parent_class)->finalize (obj);
}

static GType
boxes_transfer_popover_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (BoxesTransferPopoverClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) boxes_transfer_popover_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (BoxesTransferPopover), 0, (GInstanceInitFunc) boxes_transfer_popover_instance_init, NULL };
	GType boxes_transfer_popover_type_id;
	boxes_transfer_popover_type_id = g_type_register_static (gtk_popover_get_type (), "BoxesTransferPopover", &g_define_type_info, 0);
	BoxesTransferPopover_private_offset = g_type_add_instance_private (boxes_transfer_popover_type_id, sizeof (BoxesTransferPopoverPrivate));
	return boxes_transfer_popover_type_id;
}

GType
boxes_transfer_popover_get_type (void)
{
	static volatile gsize boxes_transfer_popover_type_id__once = 0;
	if (g_once_init_enter (&boxes_transfer_popover_type_id__once)) {
		GType boxes_transfer_popover_type_id;
		boxes_transfer_popover_type_id = boxes_transfer_popover_get_type_once ();
		g_once_init_leave (&boxes_transfer_popover_type_id__once, boxes_transfer_popover_type_id);
	}
	return boxes_transfer_popover_type_id__once;
}

static void
_vala_boxes_transfer_popover_get_property (GObject * object,
                                           guint property_id,
                                           GValue * value,
                                           GParamSpec * pspec)
{
	BoxesTransferPopover * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, BOXES_TYPE_TRANSFER_POPOVER, BoxesTransferPopover);
	switch (property_id) {
		case BOXES_TRANSFER_POPOVER_PROGRESS_PROPERTY:
		g_value_set_double (value, boxes_transfer_popover_get_progress (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_boxes_transfer_popover_set_property (GObject * object,
                                           guint property_id,
                                           const GValue * value,
                                           GParamSpec * pspec)
{
	BoxesTransferPopover * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, BOXES_TYPE_TRANSFER_POPOVER, BoxesTransferPopover);
	switch (property_id) {
		case BOXES_TRANSFER_POPOVER_PROGRESS_PROPERTY:
		boxes_transfer_popover_set_progress (self, g_value_get_double (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

