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

#include <gtk/gtk.h>
#include <glib-object.h>
#include <glib.h>
#include "libdino.h"
#include <adwaita.h>
#include <gio/gio.h>
#include "dino_i18n.h"
#include <stdlib.h>
#include <string.h>
#include <float.h>
#include <math.h>
#include <gee.h>
#include "xmpp-vala.h"
#include <gdk-pixbuf/gdk-pixbuf.h>
#include <gdk/gdk.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 DINO_UI_TYPE_FILE_IMAGE_WIDGET (dino_ui_file_image_widget_get_type ())
#define DINO_UI_FILE_IMAGE_WIDGET(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DINO_UI_TYPE_FILE_IMAGE_WIDGET, DinoUiFileImageWidget))
#define DINO_UI_FILE_IMAGE_WIDGET_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DINO_UI_TYPE_FILE_IMAGE_WIDGET, DinoUiFileImageWidgetClass))
#define DINO_UI_IS_FILE_IMAGE_WIDGET(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DINO_UI_TYPE_FILE_IMAGE_WIDGET))
#define DINO_UI_IS_FILE_IMAGE_WIDGET_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DINO_UI_TYPE_FILE_IMAGE_WIDGET))
#define DINO_UI_FILE_IMAGE_WIDGET_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DINO_UI_TYPE_FILE_IMAGE_WIDGET, DinoUiFileImageWidgetClass))

typedef struct _DinoUiFileImageWidget DinoUiFileImageWidget;
typedef struct _DinoUiFileImageWidgetClass DinoUiFileImageWidgetClass;
typedef struct _DinoUiFileImageWidgetPrivate DinoUiFileImageWidgetPrivate;
typedef enum  {
	DINO_UI_FILE_IMAGE_WIDGET_STATE_EMPTY,
	DINO_UI_FILE_IMAGE_WIDGET_STATE_PREVIEW,
	DINO_UI_FILE_IMAGE_WIDGET_STATE_IMAGE
} DinoUiFileImageWidgetState;

#define DINO_UI_FILE_IMAGE_WIDGET_TYPE_STATE (dino_ui_file_image_widget_state_get_type ())

#define DINO_UI_TYPE_FILE_TRANSMISSION_PROGRESS (dino_ui_file_transmission_progress_get_type ())
#define DINO_UI_FILE_TRANSMISSION_PROGRESS(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DINO_UI_TYPE_FILE_TRANSMISSION_PROGRESS, DinoUiFileTransmissionProgress))
#define DINO_UI_FILE_TRANSMISSION_PROGRESS_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DINO_UI_TYPE_FILE_TRANSMISSION_PROGRESS, DinoUiFileTransmissionProgressClass))
#define DINO_UI_IS_FILE_TRANSMISSION_PROGRESS(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DINO_UI_TYPE_FILE_TRANSMISSION_PROGRESS))
#define DINO_UI_IS_FILE_TRANSMISSION_PROGRESS_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DINO_UI_TYPE_FILE_TRANSMISSION_PROGRESS))
#define DINO_UI_FILE_TRANSMISSION_PROGRESS_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DINO_UI_TYPE_FILE_TRANSMISSION_PROGRESS, DinoUiFileTransmissionProgressClass))

typedef struct _DinoUiFileTransmissionProgress DinoUiFileTransmissionProgress;
typedef struct _DinoUiFileTransmissionProgressClass DinoUiFileTransmissionProgressClass;
enum  {
	DINO_UI_FILE_IMAGE_WIDGET_0_PROPERTY,
	DINO_UI_FILE_IMAGE_WIDGET_NUM_PROPERTIES
};
static GParamSpec* dino_ui_file_image_widget_properties[DINO_UI_FILE_IMAGE_WIDGET_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
typedef struct _Block31Data Block31Data;
typedef struct _DinoUiFileImageWidgetSetFileTransferData DinoUiFileImageWidgetSetFileTransferData;
typedef enum  {
	DINO_UI_FILE_TRANSMISSION_PROGRESS_STATE_UNKNOWN_SOURCE,
	DINO_UI_FILE_TRANSMISSION_PROGRESS_STATE_DOWNLOAD_NOT_STARTED,
	DINO_UI_FILE_TRANSMISSION_PROGRESS_STATE_DOWNLOAD_NOT_STARTED_FAILED_BEFORE,
	DINO_UI_FILE_TRANSMISSION_PROGRESS_STATE_DOWNLOADING,
	DINO_UI_FILE_TRANSMISSION_PROGRESS_STATE_UPLOADING,
	DINO_UI_FILE_TRANSMISSION_PROGRESS_STATE_UPLOAD_FAILED
} DinoUiFileTransmissionProgressState;

#define DINO_UI_FILE_TRANSMISSION_PROGRESS_TYPE_STATE (dino_ui_file_transmission_progress_state_get_type ())
#define _g_free0(var) (var = (g_free (var), NULL))

#define DINO_UI_TYPE_FIXED_RATIO_PICTURE (dino_ui_fixed_ratio_picture_get_type ())
#define DINO_UI_FIXED_RATIO_PICTURE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DINO_UI_TYPE_FIXED_RATIO_PICTURE, DinoUiFixedRatioPicture))
#define DINO_UI_FIXED_RATIO_PICTURE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DINO_UI_TYPE_FIXED_RATIO_PICTURE, DinoUiFixedRatioPictureClass))
#define DINO_UI_IS_FIXED_RATIO_PICTURE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DINO_UI_TYPE_FIXED_RATIO_PICTURE))
#define DINO_UI_IS_FIXED_RATIO_PICTURE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DINO_UI_TYPE_FIXED_RATIO_PICTURE))
#define DINO_UI_FIXED_RATIO_PICTURE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DINO_UI_TYPE_FIXED_RATIO_PICTURE, DinoUiFixedRatioPictureClass))

typedef struct _DinoUiFixedRatioPicture DinoUiFixedRatioPicture;
typedef struct _DinoUiFixedRatioPictureClass DinoUiFixedRatioPictureClass;
typedef struct _DinoUiFileImageWidgetLoadFromFileData DinoUiFileImageWidgetLoadFromFileData;
#define _xmpp_xep_jingle_content_thumbnails_thumbnail_unref0(var) ((var == NULL) ? NULL : (var = (xmpp_xep_jingle_content_thumbnails_thumbnail_unref (var), NULL)))
typedef struct _DinoUiFileImageWidgetLoadFromThumbnailData DinoUiFileImageWidgetLoadFromThumbnailData;

struct _DinoUiFileImageWidget {
	GtkWidget parent_instance;
	DinoUiFileImageWidgetPrivate * priv;
};

struct _DinoUiFileImageWidgetClass {
	GtkWidgetClass parent_class;
};

struct _DinoUiFileImageWidgetPrivate {
	DinoUiFileImageWidgetState state;
	GtkStack* stack;
	GtkOverlay* overlay;
	gboolean show_image_overlay_toolbar;
	GtkBox* image_overlay_toolbar;
	GtkLabel* file_size_label;
	DinoEntitiesFileTransfer* file_transfer;
	DinoUiFileTransmissionProgress* transmission_progress;
};

struct _Block31Data {
	int _ref_count_;
	GtkMenuButton* button;
};

struct _DinoUiFileImageWidgetSetFileTransferData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	DinoUiFileImageWidget* self;
	DinoEntitiesFileTransfer* file_transfer;
	DinoEntitiesFileTransfer* _tmp0_;
	DinoEntitiesFileTransfer* _tmp1_;
	GtkLabel* _tmp2_;
	DinoEntitiesFileTransfer* _tmp3_;
	DinoUiFileTransmissionProgress* _tmp4_;
	DinoEntitiesFileTransfer* _tmp5_;
	DinoUiFileTransmissionProgress* _tmp6_;
};

struct _DinoUiFileImageWidgetLoadFromFileData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	DinoUiFileImageWidget* self;
	GFile* file;
	gchar* file_name;
	DinoUiFixedRatioPicture* image;
	DinoUiFixedRatioPicture* _tmp0_;
	GdkPixbuf* pixbuf;
	gchar* _tmp1_;
	gchar* _tmp2_;
	GdkPixbuf* _tmp3_;
	GdkPixbuf* _tmp4_;
	GdkPixbuf* _tmp5_;
	GdkPixbuf* _tmp6_;
	GdkPixbuf* _tmp7_;
	GdkTexture* _tmp8_;
	GdkTexture* _tmp9_;
	GtkStack* _tmp10_;
	GtkStack* _tmp11_;
	GError* _inner_error0_;
};

struct _DinoUiFileImageWidgetLoadFromThumbnailData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	DinoUiFileImageWidget* self;
	DinoEntitiesFileTransfer* file_transfer;
	DinoEntitiesFileTransfer* _tmp0_;
	GdkPixbuf* pixbuf;
	GeeList* _thumbnail_list;
	GeeList* _tmp1_;
	gint _thumbnail_size;
	GeeList* _tmp2_;
	gint _tmp3_;
	gint _tmp4_;
	gint _thumbnail_index;
	gint _tmp5_;
	gint _tmp6_;
	XmppXepJingleContentThumbnailsThumbnail* thumbnail;
	GeeList* _tmp7_;
	gpointer _tmp8_;
	XmppXepJingleContentThumbnailsThumbnail* _tmp9_;
	GdkPixbuf* _tmp10_;
	GdkPixbuf* _tmp11_;
	GdkPixbuf* _tmp12_;
	const gchar* _tmp13_;
	const gchar* _tmp14_;
	GError* _tmp15_;
	GdkPixbuf* _tmp16_;
	GdkPixbuf* _tmp17_;
	gboolean _tmp18_;
	gint _tmp19_;
	gint _tmp20_;
	gint _tmp21_;
	gint _tmp22_;
	GdkPixbuf* _tmp23_;
	gint _tmp24_;
	gint _tmp25_;
	gint _tmp26_;
	gint _tmp27_;
	GdkPixbuf* _tmp28_;
	gint _tmp29_;
	gint _tmp30_;
	gint _tmp31_;
	gint _tmp32_;
	GdkPixbuf* _tmp33_;
	const gchar* _tmp34_;
	const gchar* _tmp35_;
	GError* _tmp36_;
	DinoUiFixedRatioPicture* image;
	DinoUiFixedRatioPicture* _tmp37_;
	DinoUiFixedRatioPicture* _tmp38_;
	GdkPixbuf* _tmp39_;
	GdkTexture* _tmp40_;
	GdkTexture* _tmp41_;
	GtkStack* _tmp42_;
	DinoUiFixedRatioPicture* _tmp43_;
	GtkStack* _tmp44_;
	DinoUiFixedRatioPicture* _tmp45_;
	GError* _inner_error0_;
};

static gint DinoUiFileImageWidget_private_offset;
static gpointer dino_ui_file_image_widget_parent_class = NULL;

VALA_EXTERN GType dino_ui_file_image_widget_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (DinoUiFileImageWidget, g_object_unref)
static GType dino_ui_file_image_widget_state_get_type (void) G_GNUC_CONST  G_GNUC_UNUSED ;
VALA_EXTERN GType dino_ui_file_transmission_progress_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (DinoUiFileTransmissionProgress, g_object_unref)
VALA_EXTERN DinoUiFileTransmissionProgress* dino_ui_file_transmission_progress_new (void);
VALA_EXTERN DinoUiFileTransmissionProgress* dino_ui_file_transmission_progress_construct (GType object_type);
VALA_EXTERN DinoUiFileImageWidget* dino_ui_file_image_widget_new (gint MAX_WIDTH,
                                                      gint MAX_HEIGHT);
VALA_EXTERN DinoUiFileImageWidget* dino_ui_file_image_widget_construct (GType object_type,
                                                            gint MAX_WIDTH,
                                                            gint MAX_HEIGHT);
VALA_EXTERN void dino_ui_file_image_widget_on_image_clicked (DinoUiFileImageWidget* self,
                                                 GtkGestureClick* gesture_click_controller,
                                                 gint n_press,
                                                 gdouble x,
                                                 gdouble y);
static void _dino_ui_file_image_widget_on_image_clicked_gtk_gesture_click_released (GtkGestureClick* _sender,
                                                                             gint n_press,
                                                                             gdouble x,
                                                                             gdouble y,
                                                                             gpointer self);
static void __lambda39_ (DinoUiFileImageWidget* self,
                  GtkEventControllerMotion* controller,
                  gdouble x,
                  gdouble y);
static void dino_ui_file_image_widget_on_motion_event_enter (DinoUiFileImageWidget* self);
static void ___lambda39__gtk_event_controller_motion_enter (GtkEventControllerMotion* _sender,
                                                     gdouble x,
                                                     gdouble y,
                                                     gpointer self);
static void dino_ui_file_image_widget_attach_on_motion_event_leave (GtkEventControllerMotion* this_motion_events,
                                                             GtkMenuButton* button);
static Block31Data* block31_data_ref (Block31Data* _data31_);
static void block31_data_unref (void * _userdata_);
static void __lambda40_ (Block31Data* _data31_,
                  GtkEventControllerMotion* controller);
static void ___lambda40__gtk_event_controller_motion_leave (GtkEventControllerMotion* _sender,
                                                     gpointer self);
static void dino_ui_file_image_widget_set_file_transfer_data_free (gpointer _data);
VALA_EXTERN void dino_ui_file_image_widget_set_file_transfer (DinoUiFileImageWidget* self,
                                                  DinoEntitiesFileTransfer* file_transfer,
                                                  GAsyncReadyCallback _callback_,
                                                  gpointer _user_data_);
VALA_EXTERN void dino_ui_file_image_widget_set_file_transfer_finish (DinoUiFileImageWidget* self,
                                                         GAsyncResult* _res_);
static gboolean dino_ui_file_image_widget_set_file_transfer_co (DinoUiFileImageWidgetSetFileTransferData* _data_);
static gboolean dino_ui_file_image_widget_file_size_label_transform (GBinding* binding,
                                                              GValue* from_value,
                                                              GValue* to_value);
static gboolean _dino_ui_file_image_widget_file_size_label_transform_gbinding_transform_func (GBinding* binding,
                                                                                       GValue* from_value,
                                                                                       GValue* to_value,
                                                                                       gpointer self);
static void dino_ui_file_image_widget_refresh_state (DinoUiFileImageWidget* self);
static void _dino_ui_file_image_widget_refresh_state_g_object_notify (GObject* _sender,
                                                               GParamSpec* pspec,
                                                               gpointer self);
static void _dino_ui_file_image_widget_refresh_state_dino_entities_file_transfer_sources_changed (DinoEntitiesFileTransfer* _sender,
                                                                                           gpointer self);
VALA_EXTERN gchar* dino_ui_file_default_widget_get_size_string (gint64 size);
VALA_EXTERN void dino_ui_file_image_widget_load_from_file (DinoUiFileImageWidget* self,
                                               GFile* file,
                                               const gchar* file_name,
                                               GAsyncReadyCallback _callback_,
                                               gpointer _user_data_);
VALA_EXTERN void dino_ui_file_image_widget_load_from_file_finish (DinoUiFileImageWidget* self,
                                                      GAsyncResult* _res_,
                                                      GError** error);
VALA_EXTERN void dino_ui_file_image_widget_load_from_thumbnail (DinoUiFileImageWidget* self,
                                                    DinoEntitiesFileTransfer* file_transfer,
                                                    GAsyncReadyCallback _callback_,
                                                    gpointer _user_data_);
VALA_EXTERN void dino_ui_file_image_widget_load_from_thumbnail_finish (DinoUiFileImageWidget* self,
                                                           GAsyncResult* _res_,
                                                           GError** error);
static gboolean ____lambda41_ (DinoUiFileImageWidget* self);
VALA_EXTERN gint64 dino_ui_file_transmission_progress_get_file_size (DinoUiFileTransmissionProgress* self);
VALA_EXTERN void dino_ui_file_transmission_progress_set_transferred_size (DinoUiFileTransmissionProgress* self,
                                                              gint64 value);
static gboolean _____lambda41__gsource_func (gpointer self);
VALA_EXTERN GType dino_ui_file_transmission_progress_state_get_type (void) G_GNUC_CONST ;
VALA_EXTERN void dino_ui_file_transmission_progress_set_state (DinoUiFileTransmissionProgress* self,
                                                   DinoUiFileTransmissionProgressState value);
static void dino_ui_file_image_widget_load_from_file_data_free (gpointer _data);
static gboolean dino_ui_file_image_widget_load_from_file_co (DinoUiFileImageWidgetLoadFromFileData* _data_);
VALA_EXTERN GType dino_ui_fixed_ratio_picture_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (DinoUiFixedRatioPicture, g_object_unref)
VALA_EXTERN DinoUiFixedRatioPicture* dino_ui_fixed_ratio_picture_new (void);
VALA_EXTERN DinoUiFixedRatioPicture* dino_ui_fixed_ratio_picture_construct (GType object_type);
VALA_EXTERN void dino_ui_fixed_ratio_picture_set_min_width (DinoUiFixedRatioPicture* self,
                                                gint value);
VALA_EXTERN void dino_ui_fixed_ratio_picture_set_min_height (DinoUiFixedRatioPicture* self,
                                                 gint value);
VALA_EXTERN void dino_ui_fixed_ratio_picture_set_max_width (DinoUiFixedRatioPicture* self,
                                                gint value);
VALA_EXTERN void dino_ui_fixed_ratio_picture_set_max_height (DinoUiFixedRatioPicture* self,
                                                 gint value);
VALA_EXTERN void dino_ui_fixed_ratio_picture_set_paintable (DinoUiFixedRatioPicture* self,
                                                GdkPaintable* value);
static void dino_ui_file_image_widget_load_from_thumbnail_data_free (gpointer _data);
static gboolean dino_ui_file_image_widget_load_from_thumbnail_co (DinoUiFileImageWidgetLoadFromThumbnailData* _data_);
VALA_EXTERN GdkPixbuf* dino_ui_file_image_widget_parse_thumbnail (XmppXepJingleContentThumbnailsThumbnail* thumbnail);
static guint8* _vala_array_dup2 (guint8* self,
                          gssize length);
VALA_EXTERN gboolean dino_ui_file_image_widget_can_display (DinoEntitiesFileTransfer* file_transfer);
static void dino_ui_file_image_widget_real_dispose (GObject* base);
static GObject * dino_ui_file_image_widget_constructor (GType type,
                                                 guint n_construct_properties,
                                                 GObjectConstructParam * construct_properties);
static void dino_ui_file_image_widget_finalize (GObject * obj);
static GType dino_ui_file_image_widget_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 gssize _vala_array_length (gpointer array);
static inline gpointer _vala_memdup2 (gconstpointer mem,
                        gsize byte_size);

static inline gpointer
dino_ui_file_image_widget_get_instance_private (DinoUiFileImageWidget* self)
{
	return G_STRUCT_MEMBER_P (self, DinoUiFileImageWidget_private_offset);
}

static GType
dino_ui_file_image_widget_state_get_type_once (void)
{
	static const GEnumValue values[] = {{DINO_UI_FILE_IMAGE_WIDGET_STATE_EMPTY, "DINO_UI_FILE_IMAGE_WIDGET_STATE_EMPTY", "empty"}, {DINO_UI_FILE_IMAGE_WIDGET_STATE_PREVIEW, "DINO_UI_FILE_IMAGE_WIDGET_STATE_PREVIEW", "preview"}, {DINO_UI_FILE_IMAGE_WIDGET_STATE_IMAGE, "DINO_UI_FILE_IMAGE_WIDGET_STATE_IMAGE", "image"}, {0, NULL, NULL}};
	GType dino_ui_file_image_widget_state_type_id;
	dino_ui_file_image_widget_state_type_id = g_enum_register_static ("DinoUiFileImageWidgetState", values);
	return dino_ui_file_image_widget_state_type_id;
}

static GType
dino_ui_file_image_widget_state_get_type (void)
{
	static volatile gsize dino_ui_file_image_widget_state_type_id__once = 0;
	if (g_once_init_enter (&dino_ui_file_image_widget_state_type_id__once)) {
		GType dino_ui_file_image_widget_state_type_id;
		dino_ui_file_image_widget_state_type_id = dino_ui_file_image_widget_state_get_type_once ();
		g_once_init_leave (&dino_ui_file_image_widget_state_type_id__once, dino_ui_file_image_widget_state_type_id);
	}
	return dino_ui_file_image_widget_state_type_id__once;
}

static void
_dino_ui_file_image_widget_on_image_clicked_gtk_gesture_click_released (GtkGestureClick* _sender,
                                                                        gint n_press,
                                                                        gdouble x,
                                                                        gdouble y,
                                                                        gpointer self)
{
	dino_ui_file_image_widget_on_image_clicked ((DinoUiFileImageWidget*) self, _sender, n_press, x, y);
}

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

static void
__lambda39_ (DinoUiFileImageWidget* self,
             GtkEventControllerMotion* controller,
             gdouble x,
             gdouble y)
{
	GtkWidget* _tmp0_;
	GtkWidget* _tmp1_;
	g_return_if_fail (controller != NULL);
	_tmp0_ = gtk_event_controller_get_widget ((GtkEventController*) controller);
	_tmp1_ = _tmp0_;
	dino_ui_file_image_widget_on_motion_event_enter (DINO_UI_IS_FILE_IMAGE_WIDGET (_tmp1_) ? ((DinoUiFileImageWidget*) _tmp1_) : NULL);
}

static void
___lambda39__gtk_event_controller_motion_enter (GtkEventControllerMotion* _sender,
                                                gdouble x,
                                                gdouble y,
                                                gpointer self)
{
	__lambda39_ ((DinoUiFileImageWidget*) self, _sender, x, y);
}

DinoUiFileImageWidget*
dino_ui_file_image_widget_construct (GType object_type,
                                     gint MAX_WIDTH,
                                     gint MAX_HEIGHT)
{
	DinoUiFileImageWidget * self = NULL;
	GtkMenuButton* button = NULL;
	GtkMenuButton* _tmp0_;
	GMenu* menu_model = NULL;
	GMenu* _tmp1_;
	const gchar* _tmp2_;
	const gchar* _tmp3_;
	GtkPopoverMenu* popover_menu = NULL;
	GtkPopoverMenu* _tmp4_;
	GtkBox* _tmp5_;
	GtkBox* _tmp6_;
	GtkBox* _tmp7_;
	GtkBox* _tmp8_;
	GtkBox* _tmp9_;
	GtkLabel* _tmp10_;
	GtkOverlay* _tmp11_;
	GtkStack* _tmp12_;
	GtkOverlay* _tmp13_;
	GtkStack* _tmp14_;
	GtkOverlay* _tmp15_;
	GtkLabel* _tmp16_;
	GtkOverlay* _tmp17_;
	DinoUiFileTransmissionProgress* _tmp18_;
	GtkOverlay* _tmp19_;
	GtkBox* _tmp20_;
	GtkOverlay* _tmp21_;
	GtkBox* _tmp22_;
	GtkOverlay* _tmp23_;
	GtkGestureClick* gesture_click_controller = NULL;
	GtkGestureClick* _tmp24_;
	GtkStack* _tmp25_;
	GtkEventController* _tmp26_;
	GtkEventControllerMotion* this_motion_events = NULL;
	GtkEventControllerMotion* _tmp27_;
	GtkEventController* _tmp28_;
	self = (DinoUiFileImageWidget*) g_object_new (object_type, NULL);
	gtk_widget_set_halign ((GtkWidget*) self, GTK_ALIGN_START);
	gtk_widget_add_css_class ((GtkWidget*) self, "file-image-widget");
	_tmp0_ = (GtkMenuButton*) gtk_menu_button_new ();
	g_object_ref_sink (_tmp0_);
	button = _tmp0_;
	gtk_menu_button_set_icon_name (button, "view-more");
	_tmp1_ = g_menu_new ();
	menu_model = _tmp1_;
	_tmp2_ = dino_gettext ("Open");
	g_menu_append (menu_model, _tmp2_, "file.open");
	_tmp3_ = dino_gettext ("Save as…");
	g_menu_append (menu_model, _tmp3_, "file.save_as");
	_tmp4_ = (GtkPopoverMenu*) gtk_popover_menu_new_from_model ((GMenuModel*) menu_model);
	g_object_ref_sink (_tmp4_);
	popover_menu = _tmp4_;
	gtk_menu_button_set_popover (button, (GtkPopover*) popover_menu);
	_tmp5_ = self->priv->image_overlay_toolbar;
	gtk_box_append (_tmp5_, (GtkWidget*) button);
	_tmp6_ = self->priv->image_overlay_toolbar;
	gtk_widget_add_css_class ((GtkWidget*) _tmp6_, "card");
	_tmp7_ = self->priv->image_overlay_toolbar;
	gtk_widget_add_css_class ((GtkWidget*) _tmp7_, "toolbar");
	_tmp8_ = self->priv->image_overlay_toolbar;
	gtk_widget_add_css_class ((GtkWidget*) _tmp8_, "overlay-toolbar");
	_tmp9_ = self->priv->image_overlay_toolbar;
	gtk_widget_set_cursor_from_name ((GtkWidget*) _tmp9_, "default");
	_tmp10_ = self->priv->file_size_label;
	gtk_widget_add_css_class ((GtkWidget*) _tmp10_, "file-details");
	_tmp11_ = self->priv->overlay;
	_tmp12_ = self->priv->stack;
	gtk_overlay_set_child (_tmp11_, (GtkWidget*) _tmp12_);
	_tmp13_ = self->priv->overlay;
	_tmp14_ = self->priv->stack;
	gtk_overlay_set_measure_overlay (_tmp13_, (GtkWidget*) _tmp14_, TRUE);
	_tmp15_ = self->priv->overlay;
	_tmp16_ = self->priv->file_size_label;
	gtk_overlay_add_overlay (_tmp15_, (GtkWidget*) _tmp16_);
	_tmp17_ = self->priv->overlay;
	_tmp18_ = self->priv->transmission_progress;
	gtk_overlay_add_overlay (_tmp17_, (GtkWidget*) _tmp18_);
	_tmp19_ = self->priv->overlay;
	_tmp20_ = self->priv->image_overlay_toolbar;
	gtk_overlay_add_overlay (_tmp19_, (GtkWidget*) _tmp20_);
	_tmp21_ = self->priv->overlay;
	_tmp22_ = self->priv->image_overlay_toolbar;
	gtk_overlay_set_clip_overlay (_tmp21_, (GtkWidget*) _tmp22_, TRUE);
	_tmp23_ = self->priv->overlay;
	gtk_widget_insert_after ((GtkWidget*) _tmp23_, (GtkWidget*) self, NULL);
	_tmp24_ = (GtkGestureClick*) gtk_gesture_click_new ();
	gesture_click_controller = _tmp24_;
	gtk_gesture_single_set_button ((GtkGestureSingle*) gesture_click_controller, (guint) 1);
	g_signal_connect_object (gesture_click_controller, "released", (GCallback) _dino_ui_file_image_widget_on_image_clicked_gtk_gesture_click_released, self, 0);
	_tmp25_ = self->priv->stack;
	_tmp26_ = _g_object_ref0 ((GtkEventController*) gesture_click_controller);
	gtk_widget_add_controller ((GtkWidget*) _tmp25_, _tmp26_);
	_tmp27_ = (GtkEventControllerMotion*) gtk_event_controller_motion_new ();
	this_motion_events = _tmp27_;
	_tmp28_ = _g_object_ref0 ((GtkEventController*) this_motion_events);
	gtk_widget_add_controller ((GtkWidget*) self, _tmp28_);
	g_signal_connect_object (this_motion_events, "enter", (GCallback) ___lambda39__gtk_event_controller_motion_enter, self, 0);
	dino_ui_file_image_widget_attach_on_motion_event_leave (this_motion_events, button);
	_g_object_unref0 (this_motion_events);
	_g_object_unref0 (gesture_click_controller);
	_g_object_unref0 (popover_menu);
	_g_object_unref0 (menu_model);
	_g_object_unref0 (button);
	return self;
}

DinoUiFileImageWidget*
dino_ui_file_image_widget_new (gint MAX_WIDTH,
                               gint MAX_HEIGHT)
{
	return dino_ui_file_image_widget_construct (DINO_UI_TYPE_FILE_IMAGE_WIDGET, MAX_WIDTH, MAX_HEIGHT);
}

static Block31Data*
block31_data_ref (Block31Data* _data31_)
{
	g_atomic_int_inc (&_data31_->_ref_count_);
	return _data31_;
}

static void
block31_data_unref (void * _userdata_)
{
	Block31Data* _data31_;
	_data31_ = (Block31Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data31_->_ref_count_)) {
		_g_object_unref0 (_data31_->button);
		g_slice_free (Block31Data, _data31_);
	}
}

static void
__lambda40_ (Block31Data* _data31_,
             GtkEventControllerMotion* controller)
{
	gboolean _tmp0_ = FALSE;
	GtkPopover* _tmp1_;
	GtkPopover* _tmp2_;
	GtkWidget* _tmp7_;
	GtkWidget* _tmp8_;
	GtkBox* _tmp9_;
	GtkWidget* _tmp10_;
	GtkWidget* _tmp11_;
	GtkLabel* _tmp12_;
	g_return_if_fail (controller != NULL);
	_tmp1_ = gtk_menu_button_get_popover (_data31_->button);
	_tmp2_ = _tmp1_;
	if (_tmp2_ != NULL) {
		GtkPopover* _tmp3_;
		GtkPopover* _tmp4_;
		gboolean _tmp5_;
		gboolean _tmp6_;
		_tmp3_ = gtk_menu_button_get_popover (_data31_->button);
		_tmp4_ = _tmp3_;
		_tmp5_ = gtk_widget_get_visible ((GtkWidget*) _tmp4_);
		_tmp6_ = _tmp5_;
		_tmp0_ = _tmp6_;
	} else {
		_tmp0_ = FALSE;
	}
	if (_tmp0_) {
		return;
	}
	_tmp7_ = gtk_event_controller_get_widget ((GtkEventController*) controller);
	_tmp8_ = _tmp7_;
	_tmp9_ = (DINO_UI_IS_FILE_IMAGE_WIDGET (_tmp8_) ? ((DinoUiFileImageWidget*) _tmp8_) : NULL)->priv->image_overlay_toolbar;
	gtk_widget_set_visible ((GtkWidget*) _tmp9_, FALSE);
	_tmp10_ = gtk_event_controller_get_widget ((GtkEventController*) controller);
	_tmp11_ = _tmp10_;
	_tmp12_ = (DINO_UI_IS_FILE_IMAGE_WIDGET (_tmp11_) ? ((DinoUiFileImageWidget*) _tmp11_) : NULL)->priv->file_size_label;
	gtk_widget_set_visible ((GtkWidget*) _tmp12_, FALSE);
}

static void
___lambda40__gtk_event_controller_motion_leave (GtkEventControllerMotion* _sender,
                                                gpointer self)
{
	__lambda40_ (self, _sender);
}

static void
dino_ui_file_image_widget_attach_on_motion_event_leave (GtkEventControllerMotion* this_motion_events,
                                                        GtkMenuButton* button)
{
	Block31Data* _data31_;
	GtkMenuButton* _tmp0_;
	g_return_if_fail (this_motion_events != NULL);
	g_return_if_fail (button != NULL);
	_data31_ = g_slice_new0 (Block31Data);
	_data31_->_ref_count_ = 1;
	_tmp0_ = _g_object_ref0 (button);
	_g_object_unref0 (_data31_->button);
	_data31_->button = _tmp0_;
	g_signal_connect_data (this_motion_events, "leave", (GCallback) ___lambda40__gtk_event_controller_motion_leave, block31_data_ref (_data31_), (GClosureNotify) block31_data_unref, 0);
	block31_data_unref (_data31_);
	_data31_ = NULL;
}

static void
dino_ui_file_image_widget_on_motion_event_enter (DinoUiFileImageWidget* self)
{
	GtkBox* _tmp0_;
	gboolean _tmp1_ = FALSE;
	gboolean _tmp2_ = FALSE;
	gboolean _tmp3_ = FALSE;
	DinoEntitiesFileTransfer* _tmp4_;
	GtkLabel* _tmp15_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->image_overlay_toolbar;
	gtk_widget_set_visible ((GtkWidget*) _tmp0_, self->priv->show_image_overlay_toolbar);
	_tmp4_ = self->priv->file_transfer;
	if (_tmp4_ != NULL) {
		DinoEntitiesFileTransfer* _tmp5_;
		gboolean _tmp6_;
		gboolean _tmp7_;
		_tmp5_ = self->priv->file_transfer;
		_tmp6_ = dino_entities_file_transfer_get_direction (_tmp5_);
		_tmp7_ = _tmp6_;
		_tmp3_ = _tmp7_ == DINO_ENTITIES_FILE_TRANSFER_DIRECTION_RECEIVED;
	} else {
		_tmp3_ = FALSE;
	}
	if (_tmp3_) {
		DinoEntitiesFileTransfer* _tmp8_;
		DinoEntitiesFileTransferState _tmp9_;
		DinoEntitiesFileTransferState _tmp10_;
		_tmp8_ = self->priv->file_transfer;
		_tmp9_ = dino_entities_file_transfer_get_state (_tmp8_);
		_tmp10_ = _tmp9_;
		_tmp2_ = _tmp10_ == DINO_ENTITIES_FILE_TRANSFER_STATE_NOT_STARTED;
	} else {
		_tmp2_ = FALSE;
	}
	if (_tmp2_) {
		DinoEntitiesFileTransfer* _tmp11_;
		GeeList* _tmp12_;
		gboolean _tmp13_;
		gboolean _tmp14_;
		_tmp11_ = self->priv->file_transfer;
		_tmp12_ = _tmp11_->sfs_sources;
		_tmp13_ = gee_collection_get_is_empty ((GeeCollection*) _tmp12_);
		_tmp14_ = _tmp13_;
		_tmp1_ = !_tmp14_;
	} else {
		_tmp1_ = FALSE;
	}
	_tmp15_ = self->priv->file_size_label;
	gtk_widget_set_visible ((GtkWidget*) _tmp15_, _tmp1_);
}

static void
dino_ui_file_image_widget_set_file_transfer_data_free (gpointer _data)
{
	DinoUiFileImageWidgetSetFileTransferData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->file_transfer);
	_g_object_unref0 (_data_->self);
	g_slice_free (DinoUiFileImageWidgetSetFileTransferData, _data_);
}

void
dino_ui_file_image_widget_set_file_transfer (DinoUiFileImageWidget* self,
                                             DinoEntitiesFileTransfer* file_transfer,
                                             GAsyncReadyCallback _callback_,
                                             gpointer _user_data_)
{
	DinoUiFileImageWidgetSetFileTransferData* _data_;
	DinoUiFileImageWidget* _tmp0_;
	DinoEntitiesFileTransfer* _tmp1_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (file_transfer != NULL);
	_data_ = g_slice_new0 (DinoUiFileImageWidgetSetFileTransferData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, dino_ui_file_image_widget_set_file_transfer_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = _g_object_ref0 (file_transfer);
	_g_object_unref0 (_data_->file_transfer);
	_data_->file_transfer = _tmp1_;
	dino_ui_file_image_widget_set_file_transfer_co (_data_);
}

void
dino_ui_file_image_widget_set_file_transfer_finish (DinoUiFileImageWidget* self,
                                                    GAsyncResult* _res_)
{
	DinoUiFileImageWidgetSetFileTransferData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
}

static gboolean
_dino_ui_file_image_widget_file_size_label_transform_gbinding_transform_func (GBinding* binding,
                                                                              GValue* from_value,
                                                                              GValue* to_value,
                                                                              gpointer self)
{
	gboolean result;
	result = dino_ui_file_image_widget_file_size_label_transform (binding, from_value, to_value);
	return result;
}

static void
_dino_ui_file_image_widget_refresh_state_g_object_notify (GObject* _sender,
                                                          GParamSpec* pspec,
                                                          gpointer self)
{
	dino_ui_file_image_widget_refresh_state ((DinoUiFileImageWidget*) self);
}

static void
_dino_ui_file_image_widget_refresh_state_dino_entities_file_transfer_sources_changed (DinoEntitiesFileTransfer* _sender,
                                                                                      gpointer self)
{
	dino_ui_file_image_widget_refresh_state ((DinoUiFileImageWidget*) self);
}

static gboolean
dino_ui_file_image_widget_set_file_transfer_co (DinoUiFileImageWidgetSetFileTransferData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_tmp0_ = _g_object_ref0 (_data_->file_transfer);
	_g_object_unref0 (_data_->self->priv->file_transfer);
	_data_->self->priv->file_transfer = _data_->_tmp0_;
	_data_->_tmp1_ = _data_->self->priv->file_transfer;
	_data_->_tmp2_ = _data_->self->priv->file_size_label;
	g_object_bind_property_with_closures ((GObject*) _data_->_tmp1_, "size", (GObject*) _data_->_tmp2_, "label", G_BINDING_SYNC_CREATE, (GClosure*) g_cclosure_new ((GCallback) _dino_ui_file_image_widget_file_size_label_transform_gbinding_transform_func, NULL, (GClosureNotify) NULL), (GClosure*) ((NULL == NULL) ? NULL : g_cclosure_new ((GCallback) NULL, NULL, (GClosureNotify) NULL)));
	_data_->_tmp3_ = _data_->self->priv->file_transfer;
	_data_->_tmp4_ = _data_->self->priv->transmission_progress;
	g_object_bind_property_with_closures ((GObject*) _data_->_tmp3_, "size", (GObject*) _data_->_tmp4_, "file-size", 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)));
	_data_->_tmp5_ = _data_->self->priv->file_transfer;
	_data_->_tmp6_ = _data_->self->priv->transmission_progress;
	g_object_bind_property_with_closures ((GObject*) _data_->_tmp5_, "transferred-bytes", (GObject*) _data_->_tmp6_, "transferred-size", 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)));
	g_signal_connect_object ((GObject*) _data_->file_transfer, "notify::state", (GCallback) _dino_ui_file_image_widget_refresh_state_g_object_notify, _data_->self, 0);
	g_signal_connect_object (_data_->file_transfer, "sources-changed", (GCallback) _dino_ui_file_image_widget_refresh_state_dino_entities_file_transfer_sources_changed, _data_->self, 0);
	dino_ui_file_image_widget_refresh_state (_data_->self);
	g_task_return_pointer (_data_->_async_result, _data_, NULL);
	if (_data_->_state_ != 0) {
		while (!g_task_get_completed (_data_->_async_result)) {
			g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
		}
	}
	g_object_unref (_data_->_async_result);
	return FALSE;
}

static gboolean
dino_ui_file_image_widget_file_size_label_transform (GBinding* binding,
                                                     GValue* from_value,
                                                     GValue* to_value)
{
	GValue _tmp0_;
	gchar* _tmp1_;
	GValue _tmp2_ = {0};
	gboolean result;
	g_return_val_if_fail (binding != NULL, FALSE);
	g_return_val_if_fail (from_value != NULL, FALSE);
	g_return_val_if_fail (to_value != NULL, FALSE);
	_tmp0_ = *from_value;
	_tmp1_ = dino_ui_file_default_widget_get_size_string (g_value_get_int64 (&_tmp0_));
	g_value_init (&_tmp2_, G_TYPE_STRING);
	g_value_take_string (&_tmp2_, _tmp1_);
	G_IS_VALUE (to_value) ? (g_value_unset (to_value), NULL) : NULL;
	*to_value = _tmp2_;
	result = TRUE;
	return result;
}

static gboolean
____lambda41_ (DinoUiFileImageWidget* self)
{
	DinoUiFileTransmissionProgress* _tmp0_;
	DinoUiFileTransmissionProgress* _tmp1_;
	gint64 _tmp2_;
	gint64 _tmp3_;
	DinoUiFileTransmissionProgress* _tmp4_;
	gboolean result;
	_tmp0_ = self->priv->transmission_progress;
	_tmp1_ = self->priv->transmission_progress;
	_tmp2_ = dino_ui_file_transmission_progress_get_file_size (_tmp1_);
	_tmp3_ = _tmp2_;
	dino_ui_file_transmission_progress_set_transferred_size (_tmp0_, _tmp3_);
	_tmp4_ = self->priv->transmission_progress;
	gtk_widget_set_visible ((GtkWidget*) _tmp4_, FALSE);
	self->priv->show_image_overlay_toolbar = TRUE;
	result = FALSE;
	return result;
}

static gboolean
_____lambda41__gsource_func (gpointer self)
{
	gboolean result;
	result = ____lambda41_ ((DinoUiFileImageWidget*) self);
	return result;
}

static void
dino_ui_file_image_widget_refresh_state (DinoUiFileImageWidget* self)
{
	gboolean _tmp0_ = FALSE;
	gboolean _tmp1_ = FALSE;
	gboolean _tmp18_ = FALSE;
	gboolean _tmp19_ = FALSE;
	DinoEntitiesFileTransfer* _tmp20_;
	DinoEntitiesFileTransferState _tmp21_;
	DinoEntitiesFileTransferState _tmp22_;
	DinoEntitiesFileTransfer* _tmp33_;
	gboolean _tmp34_;
	gboolean _tmp35_;
	g_return_if_fail (self != NULL);
	if (self->priv->state == DINO_UI_FILE_IMAGE_WIDGET_STATE_EMPTY) {
		_tmp1_ = TRUE;
	} else {
		_tmp1_ = self->priv->state == DINO_UI_FILE_IMAGE_WIDGET_STATE_PREVIEW;
	}
	if (_tmp1_) {
		DinoEntitiesFileTransfer* _tmp2_;
		const gchar* _tmp3_;
		const gchar* _tmp4_;
		_tmp2_ = self->priv->file_transfer;
		_tmp3_ = dino_entities_file_transfer_get_path (_tmp2_);
		_tmp4_ = _tmp3_;
		_tmp0_ = _tmp4_ != NULL;
	} else {
		_tmp0_ = FALSE;
	}
	if (_tmp0_) {
		DinoEntitiesFileTransfer* _tmp5_;
		GFile* _tmp6_;
		GFile* _tmp7_;
		DinoEntitiesFileTransfer* _tmp8_;
		const gchar* _tmp9_;
		const gchar* _tmp10_;
		_tmp5_ = self->priv->file_transfer;
		_tmp6_ = dino_entities_file_transfer_get_file (_tmp5_);
		_tmp7_ = _tmp6_;
		_tmp8_ = self->priv->file_transfer;
		_tmp9_ = dino_entities_file_transfer_get_file_name (_tmp8_);
		_tmp10_ = _tmp9_;
		dino_ui_file_image_widget_load_from_file (self, _tmp7_, _tmp10_, NULL, NULL);
		_g_object_unref0 (_tmp7_);
		self->priv->show_image_overlay_toolbar = TRUE;
		gtk_widget_set_cursor_from_name ((GtkWidget*) self, "zoom-in");
		self->priv->state = DINO_UI_FILE_IMAGE_WIDGET_STATE_IMAGE;
	} else {
		gboolean _tmp11_ = FALSE;
		if (self->priv->state == DINO_UI_FILE_IMAGE_WIDGET_STATE_EMPTY) {
			DinoEntitiesFileTransfer* _tmp12_;
			GeeList* _tmp13_;
			gint _tmp14_;
			gint _tmp15_;
			_tmp12_ = self->priv->file_transfer;
			_tmp13_ = _tmp12_->thumbnails;
			_tmp14_ = gee_collection_get_size ((GeeCollection*) _tmp13_);
			_tmp15_ = _tmp14_;
			_tmp11_ = _tmp15_ > 0;
		} else {
			_tmp11_ = FALSE;
		}
		if (_tmp11_) {
			DinoEntitiesFileTransfer* _tmp16_;
			DinoUiFileTransmissionProgress* _tmp17_;
			_tmp16_ = self->priv->file_transfer;
			dino_ui_file_image_widget_load_from_thumbnail (self, _tmp16_, NULL, NULL);
			_tmp17_ = self->priv->transmission_progress;
			gtk_widget_set_visible ((GtkWidget*) _tmp17_, TRUE);
			self->priv->show_image_overlay_toolbar = FALSE;
			self->priv->state = DINO_UI_FILE_IMAGE_WIDGET_STATE_PREVIEW;
		}
	}
	_tmp20_ = self->priv->file_transfer;
	_tmp21_ = dino_entities_file_transfer_get_state (_tmp20_);
	_tmp22_ = _tmp21_;
	if (_tmp22_ == DINO_ENTITIES_FILE_TRANSFER_STATE_IN_PROGRESS) {
		_tmp19_ = TRUE;
	} else {
		DinoEntitiesFileTransfer* _tmp23_;
		DinoEntitiesFileTransferState _tmp24_;
		DinoEntitiesFileTransferState _tmp25_;
		_tmp23_ = self->priv->file_transfer;
		_tmp24_ = dino_entities_file_transfer_get_state (_tmp23_);
		_tmp25_ = _tmp24_;
		_tmp19_ = _tmp25_ == DINO_ENTITIES_FILE_TRANSFER_STATE_NOT_STARTED;
	}
	if (_tmp19_) {
		_tmp18_ = TRUE;
	} else {
		DinoEntitiesFileTransfer* _tmp26_;
		DinoEntitiesFileTransferState _tmp27_;
		DinoEntitiesFileTransferState _tmp28_;
		_tmp26_ = self->priv->file_transfer;
		_tmp27_ = dino_entities_file_transfer_get_state (_tmp26_);
		_tmp28_ = _tmp27_;
		_tmp18_ = _tmp28_ == DINO_ENTITIES_FILE_TRANSFER_STATE_FAILED;
	}
	if (_tmp18_) {
		DinoUiFileTransmissionProgress* _tmp29_;
		_tmp29_ = self->priv->transmission_progress;
		gtk_widget_set_visible ((GtkWidget*) _tmp29_, TRUE);
		self->priv->show_image_overlay_toolbar = FALSE;
	} else {
		DinoUiFileTransmissionProgress* _tmp30_;
		gboolean _tmp31_;
		gboolean _tmp32_;
		_tmp30_ = self->priv->transmission_progress;
		_tmp31_ = gtk_widget_get_visible ((GtkWidget*) _tmp30_);
		_tmp32_ = _tmp31_;
		if (_tmp32_) {
			g_timeout_add_full (G_PRIORITY_DEFAULT, (guint) 250, _____lambda41__gsource_func, g_object_ref (self), g_object_unref);
		}
	}
	_tmp33_ = self->priv->file_transfer;
	_tmp34_ = dino_entities_file_transfer_get_direction (_tmp33_);
	_tmp35_ = _tmp34_;
	if (_tmp35_ == DINO_ENTITIES_FILE_TRANSFER_DIRECTION_RECEIVED) {
		DinoEntitiesFileTransfer* _tmp36_;
		DinoEntitiesFileTransferState _tmp37_;
		DinoEntitiesFileTransferState _tmp38_;
		_tmp36_ = self->priv->file_transfer;
		_tmp37_ = dino_entities_file_transfer_get_state (_tmp36_);
		_tmp38_ = _tmp37_;
		if (_tmp38_ == DINO_ENTITIES_FILE_TRANSFER_STATE_IN_PROGRESS) {
			DinoUiFileTransmissionProgress* _tmp39_;
			_tmp39_ = self->priv->transmission_progress;
			dino_ui_file_transmission_progress_set_state (_tmp39_, DINO_UI_FILE_TRANSMISSION_PROGRESS_STATE_DOWNLOADING);
		} else {
			DinoEntitiesFileTransfer* _tmp40_;
			GeeList* _tmp41_;
			gboolean _tmp42_;
			gboolean _tmp43_;
			_tmp40_ = self->priv->file_transfer;
			_tmp41_ = _tmp40_->sfs_sources;
			_tmp42_ = gee_collection_get_is_empty ((GeeCollection*) _tmp41_);
			_tmp43_ = _tmp42_;
			if (_tmp43_) {
				DinoUiFileTransmissionProgress* _tmp44_;
				_tmp44_ = self->priv->transmission_progress;
				dino_ui_file_transmission_progress_set_state (_tmp44_, DINO_UI_FILE_TRANSMISSION_PROGRESS_STATE_UNKNOWN_SOURCE);
			} else {
				DinoEntitiesFileTransfer* _tmp45_;
				DinoEntitiesFileTransferState _tmp46_;
				DinoEntitiesFileTransferState _tmp47_;
				_tmp45_ = self->priv->file_transfer;
				_tmp46_ = dino_entities_file_transfer_get_state (_tmp45_);
				_tmp47_ = _tmp46_;
				if (_tmp47_ == DINO_ENTITIES_FILE_TRANSFER_STATE_NOT_STARTED) {
					DinoUiFileTransmissionProgress* _tmp48_;
					_tmp48_ = self->priv->transmission_progress;
					dino_ui_file_transmission_progress_set_state (_tmp48_, DINO_UI_FILE_TRANSMISSION_PROGRESS_STATE_DOWNLOAD_NOT_STARTED);
				} else {
					DinoEntitiesFileTransfer* _tmp49_;
					DinoEntitiesFileTransferState _tmp50_;
					DinoEntitiesFileTransferState _tmp51_;
					_tmp49_ = self->priv->file_transfer;
					_tmp50_ = dino_entities_file_transfer_get_state (_tmp49_);
					_tmp51_ = _tmp50_;
					if (_tmp51_ == DINO_ENTITIES_FILE_TRANSFER_STATE_FAILED) {
						DinoUiFileTransmissionProgress* _tmp52_;
						_tmp52_ = self->priv->transmission_progress;
						dino_ui_file_transmission_progress_set_state (_tmp52_, DINO_UI_FILE_TRANSMISSION_PROGRESS_STATE_DOWNLOAD_NOT_STARTED_FAILED_BEFORE);
					}
				}
			}
		}
	} else {
		DinoEntitiesFileTransfer* _tmp53_;
		gboolean _tmp54_;
		gboolean _tmp55_;
		_tmp53_ = self->priv->file_transfer;
		_tmp54_ = dino_entities_file_transfer_get_direction (_tmp53_);
		_tmp55_ = _tmp54_;
		if (_tmp55_ == DINO_ENTITIES_FILE_TRANSFER_DIRECTION_SENT) {
			DinoEntitiesFileTransfer* _tmp56_;
			DinoEntitiesFileTransferState _tmp57_;
			DinoEntitiesFileTransferState _tmp58_;
			_tmp56_ = self->priv->file_transfer;
			_tmp57_ = dino_entities_file_transfer_get_state (_tmp56_);
			_tmp58_ = _tmp57_;
			if (_tmp58_ == DINO_ENTITIES_FILE_TRANSFER_STATE_IN_PROGRESS) {
				DinoUiFileTransmissionProgress* _tmp59_;
				_tmp59_ = self->priv->transmission_progress;
				dino_ui_file_transmission_progress_set_state (_tmp59_, DINO_UI_FILE_TRANSMISSION_PROGRESS_STATE_UPLOADING);
			} else {
				DinoEntitiesFileTransfer* _tmp60_;
				DinoEntitiesFileTransferState _tmp61_;
				DinoEntitiesFileTransferState _tmp62_;
				_tmp60_ = self->priv->file_transfer;
				_tmp61_ = dino_entities_file_transfer_get_state (_tmp60_);
				_tmp62_ = _tmp61_;
				if (_tmp62_ == DINO_ENTITIES_FILE_TRANSFER_STATE_FAILED) {
					DinoUiFileTransmissionProgress* _tmp63_;
					_tmp63_ = self->priv->transmission_progress;
					dino_ui_file_transmission_progress_set_state (_tmp63_, DINO_UI_FILE_TRANSMISSION_PROGRESS_STATE_UPLOAD_FAILED);
				}
			}
		}
	}
}

static void
dino_ui_file_image_widget_load_from_file_data_free (gpointer _data)
{
	DinoUiFileImageWidgetLoadFromFileData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->file);
	_g_free0 (_data_->file_name);
	_g_object_unref0 (_data_->self);
	g_slice_free (DinoUiFileImageWidgetLoadFromFileData, _data_);
}

void
dino_ui_file_image_widget_load_from_file (DinoUiFileImageWidget* self,
                                          GFile* file,
                                          const gchar* file_name,
                                          GAsyncReadyCallback _callback_,
                                          gpointer _user_data_)
{
	DinoUiFileImageWidgetLoadFromFileData* _data_;
	DinoUiFileImageWidget* _tmp0_;
	GFile* _tmp1_;
	gchar* _tmp2_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (file != NULL);
	g_return_if_fail (file_name != NULL);
	_data_ = g_slice_new0 (DinoUiFileImageWidgetLoadFromFileData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, dino_ui_file_image_widget_load_from_file_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = _g_object_ref0 (file);
	_g_object_unref0 (_data_->file);
	_data_->file = _tmp1_;
	_tmp2_ = g_strdup (file_name);
	_g_free0 (_data_->file_name);
	_data_->file_name = _tmp2_;
	dino_ui_file_image_widget_load_from_file_co (_data_);
}

void
dino_ui_file_image_widget_load_from_file_finish (DinoUiFileImageWidget* self,
                                                 GAsyncResult* _res_,
                                                 GError** error)
{
	DinoUiFileImageWidgetLoadFromFileData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), error);
	if (NULL == _data_) {
		return;
	}
}

static gboolean
dino_ui_file_image_widget_load_from_file_co (DinoUiFileImageWidgetLoadFromFileData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_tmp0_ = NULL;
	_data_->_tmp0_ = dino_ui_fixed_ratio_picture_new ();
	dino_ui_fixed_ratio_picture_set_min_width (_data_->_tmp0_, 100);
	dino_ui_fixed_ratio_picture_set_min_height (_data_->_tmp0_, 100);
	dino_ui_fixed_ratio_picture_set_max_width (_data_->_tmp0_, 600);
	dino_ui_fixed_ratio_picture_set_max_height (_data_->_tmp0_, 300);
	g_object_ref_sink (_data_->_tmp0_);
	_data_->image = _data_->_tmp0_;
	_data_->_tmp1_ = g_file_get_path (_data_->file);
	_data_->_tmp2_ = _data_->_tmp1_;
	_data_->_tmp3_ = gdk_pixbuf_new_from_file (_data_->_tmp2_, &_data_->_inner_error0_);
	_data_->_tmp4_ = _data_->_tmp3_;
	_g_free0 (_data_->_tmp2_);
	_data_->pixbuf = _data_->_tmp4_;
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
		_g_object_unref0 (_data_->image);
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_data_->_tmp5_ = _data_->pixbuf;
	_data_->_tmp6_ = gdk_pixbuf_apply_embedded_orientation (_data_->_tmp5_);
	_g_object_unref0 (_data_->pixbuf);
	_data_->pixbuf = _data_->_tmp6_;
	_data_->_tmp7_ = _data_->pixbuf;
	_data_->_tmp8_ = gdk_texture_new_for_pixbuf (_data_->_tmp7_);
	_data_->_tmp9_ = _data_->_tmp8_;
	dino_ui_fixed_ratio_picture_set_paintable (_data_->image, (GdkPaintable*) _data_->_tmp9_);
	_g_object_unref0 (_data_->_tmp9_);
	_data_->_tmp10_ = _data_->self->priv->stack;
	gtk_stack_add_child (_data_->_tmp10_, (GtkWidget*) _data_->image);
	_data_->_tmp11_ = _data_->self->priv->stack;
	gtk_stack_set_visible_child (_data_->_tmp11_, (GtkWidget*) _data_->image);
	_g_object_unref0 (_data_->pixbuf);
	_g_object_unref0 (_data_->image);
	g_task_return_pointer (_data_->_async_result, _data_, NULL);
	if (_data_->_state_ != 0) {
		while (!g_task_get_completed (_data_->_async_result)) {
			g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
		}
	}
	g_object_unref (_data_->_async_result);
	return FALSE;
}

static void
dino_ui_file_image_widget_load_from_thumbnail_data_free (gpointer _data)
{
	DinoUiFileImageWidgetLoadFromThumbnailData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->file_transfer);
	_g_object_unref0 (_data_->self);
	g_slice_free (DinoUiFileImageWidgetLoadFromThumbnailData, _data_);
}

void
dino_ui_file_image_widget_load_from_thumbnail (DinoUiFileImageWidget* self,
                                               DinoEntitiesFileTransfer* file_transfer,
                                               GAsyncReadyCallback _callback_,
                                               gpointer _user_data_)
{
	DinoUiFileImageWidgetLoadFromThumbnailData* _data_;
	DinoUiFileImageWidget* _tmp0_;
	DinoEntitiesFileTransfer* _tmp1_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (file_transfer != NULL);
	_data_ = g_slice_new0 (DinoUiFileImageWidgetLoadFromThumbnailData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, dino_ui_file_image_widget_load_from_thumbnail_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = _g_object_ref0 (file_transfer);
	_g_object_unref0 (_data_->file_transfer);
	_data_->file_transfer = _tmp1_;
	dino_ui_file_image_widget_load_from_thumbnail_co (_data_);
}

void
dino_ui_file_image_widget_load_from_thumbnail_finish (DinoUiFileImageWidget* self,
                                                      GAsyncResult* _res_,
                                                      GError** error)
{
	DinoUiFileImageWidgetLoadFromThumbnailData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), error);
	if (NULL == _data_) {
		return;
	}
}

static gboolean
dino_ui_file_image_widget_load_from_thumbnail_co (DinoUiFileImageWidgetLoadFromThumbnailData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	_data_->_tmp0_ = _g_object_ref0 (_data_->file_transfer);
	_g_object_unref0 (_data_->self->priv->file_transfer);
	_data_->self->priv->file_transfer = _data_->_tmp0_;
	_data_->pixbuf = NULL;
	{
		_data_->_tmp1_ = _data_->file_transfer->thumbnails;
		_data_->_thumbnail_list = _data_->_tmp1_;
		_data_->_tmp2_ = _data_->_thumbnail_list;
		_data_->_tmp3_ = gee_collection_get_size ((GeeCollection*) _data_->_tmp2_);
		_data_->_tmp4_ = _data_->_tmp3_;
		_data_->_thumbnail_size = _data_->_tmp4_;
		_data_->_thumbnail_index = -1;
		while (TRUE) {
			_data_->_thumbnail_index = _data_->_thumbnail_index + 1;
			_data_->_tmp5_ = _data_->_thumbnail_index;
			_data_->_tmp6_ = _data_->_thumbnail_size;
			if (!(_data_->_tmp5_ < _data_->_tmp6_)) {
				break;
			}
			_data_->_tmp7_ = _data_->_thumbnail_list;
			_data_->_tmp8_ = gee_list_get (_data_->_tmp7_, _data_->_thumbnail_index);
			_data_->thumbnail = (XmppXepJingleContentThumbnailsThumbnail*) _data_->_tmp8_;
			_data_->_tmp9_ = _data_->thumbnail;
			_data_->_tmp10_ = dino_ui_file_image_widget_parse_thumbnail (_data_->_tmp9_);
			_g_object_unref0 (_data_->pixbuf);
			_data_->pixbuf = _data_->_tmp10_;
			_data_->_tmp11_ = _data_->pixbuf;
			if (_data_->_tmp11_ != NULL) {
				_xmpp_xep_jingle_content_thumbnails_thumbnail_unref0 (_data_->thumbnail);
				break;
			}
			_xmpp_xep_jingle_content_thumbnails_thumbnail_unref0 (_data_->thumbnail);
		}
	}
	_data_->_tmp12_ = _data_->pixbuf;
	if (_data_->_tmp12_ == NULL) {
		_data_->_tmp13_ = dino_entities_file_transfer_get_file_name (_data_->file_transfer);
		_data_->_tmp14_ = _data_->_tmp13_;
		g_warning ("file_image_widget.vala:177: Can't load thumbnails of file %s", _data_->_tmp14_);
		_data_->_tmp15_ = g_error_new ((GQuark) -1, 0, "Error loading preview image");
		_data_->_inner_error0_ = _data_->_tmp15_;
		g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
		_g_object_unref0 (_data_->pixbuf);
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_data_->_tmp16_ = _data_->pixbuf;
	_data_->_tmp17_ = gdk_pixbuf_apply_embedded_orientation (_data_->_tmp16_);
	_g_object_unref0 (_data_->pixbuf);
	_data_->pixbuf = _data_->_tmp17_;
	_data_->_tmp19_ = dino_entities_file_transfer_get_width (_data_->file_transfer);
	_data_->_tmp20_ = _data_->_tmp19_;
	if (_data_->_tmp20_ > 0) {
		_data_->_tmp21_ = dino_entities_file_transfer_get_height (_data_->file_transfer);
		_data_->_tmp22_ = _data_->_tmp21_;
		_data_->_tmp18_ = _data_->_tmp22_ > 0;
	} else {
		_data_->_tmp18_ = FALSE;
	}
	if (_data_->_tmp18_) {
		_data_->_tmp23_ = _data_->pixbuf;
		_data_->_tmp24_ = dino_entities_file_transfer_get_width (_data_->file_transfer);
		_data_->_tmp25_ = _data_->_tmp24_;
		_data_->_tmp26_ = dino_entities_file_transfer_get_height (_data_->file_transfer);
		_data_->_tmp27_ = _data_->_tmp26_;
		_data_->_tmp28_ = gdk_pixbuf_scale_simple (_data_->_tmp23_, _data_->_tmp25_, _data_->_tmp27_, GDK_INTERP_BILINEAR);
		_g_object_unref0 (_data_->pixbuf);
		_data_->pixbuf = _data_->_tmp28_;
	} else {
		_data_->_tmp29_ = dino_entities_file_transfer_get_width (_data_->file_transfer);
		_data_->_tmp30_ = _data_->_tmp29_;
		_data_->_tmp31_ = dino_entities_file_transfer_get_height (_data_->file_transfer);
		_data_->_tmp32_ = _data_->_tmp31_;
		g_warning ("file_image_widget.vala:186: Preview: Not scaling image, width: %d, hei" \
"ght: %d\n", _data_->_tmp30_, _data_->_tmp32_);
	}
	_data_->_tmp33_ = _data_->pixbuf;
	if (_data_->_tmp33_ == NULL) {
		_data_->_tmp34_ = dino_entities_file_transfer_get_file_name (_data_->file_transfer);
		_data_->_tmp35_ = _data_->_tmp34_;
		g_warning ("file_image_widget.vala:189: Can't scale thumbnail %s", _data_->_tmp35_);
		_data_->_tmp36_ = g_error_new ((GQuark) -1, 0, "Error scaling preview image");
		_data_->_inner_error0_ = _data_->_tmp36_;
		g_task_return_error (_data_->_async_result, _data_->_inner_error0_);
		_g_object_unref0 (_data_->pixbuf);
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	_data_->_tmp37_ = NULL;
	_data_->_tmp37_ = dino_ui_fixed_ratio_picture_new ();
	dino_ui_fixed_ratio_picture_set_min_width (_data_->_tmp37_, 100);
	dino_ui_fixed_ratio_picture_set_min_height (_data_->_tmp37_, 100);
	dino_ui_fixed_ratio_picture_set_max_width (_data_->_tmp37_, 600);
	dino_ui_fixed_ratio_picture_set_max_height (_data_->_tmp37_, 300);
	g_object_ref_sink (_data_->_tmp37_);
	_data_->image = _data_->_tmp37_;
	_data_->_tmp38_ = _data_->image;
	_data_->_tmp39_ = _data_->pixbuf;
	_data_->_tmp40_ = gdk_texture_new_for_pixbuf (_data_->_tmp39_);
	_data_->_tmp41_ = _data_->_tmp40_;
	dino_ui_fixed_ratio_picture_set_paintable (_data_->_tmp38_, (GdkPaintable*) _data_->_tmp41_);
	_g_object_unref0 (_data_->_tmp41_);
	_data_->_tmp42_ = _data_->self->priv->stack;
	_data_->_tmp43_ = _data_->image;
	gtk_stack_add_child (_data_->_tmp42_, (GtkWidget*) _data_->_tmp43_);
	_data_->_tmp44_ = _data_->self->priv->stack;
	_data_->_tmp45_ = _data_->image;
	gtk_stack_set_visible_child (_data_->_tmp44_, (GtkWidget*) _data_->_tmp45_);
	_g_object_unref0 (_data_->image);
	_g_object_unref0 (_data_->pixbuf);
	g_task_return_pointer (_data_->_async_result, _data_, NULL);
	if (_data_->_state_ != 0) {
		while (!g_task_get_completed (_data_->_async_result)) {
			g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
		}
	}
	g_object_unref (_data_->_async_result);
	return FALSE;
}

void
dino_ui_file_image_widget_on_image_clicked (DinoUiFileImageWidget* self,
                                            GtkGestureClick* gesture_click_controller,
                                            gint n_press,
                                            gdouble x,
                                            gdouble y)
{
	DinoEntitiesFileTransfer* _tmp0_;
	DinoEntitiesFileTransferState _tmp1_;
	DinoEntitiesFileTransferState _tmp2_;
	GdkDevice* _tmp3_;
	GdkInputSource _tmp4_;
	GdkInputSource _tmp5_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (gesture_click_controller != NULL);
	_tmp0_ = self->priv->file_transfer;
	_tmp1_ = dino_entities_file_transfer_get_state (_tmp0_);
	_tmp2_ = _tmp1_;
	if (_tmp2_ != DINO_ENTITIES_FILE_TRANSFER_STATE_COMPLETE) {
		return;
	}
	_tmp3_ = gtk_gesture_get_device ((GtkGesture*) gesture_click_controller);
	_tmp4_ = gdk_device_get_source (_tmp3_);
	_tmp5_ = _tmp4_;
	switch (_tmp5_) {
		case GDK_SOURCE_TOUCHSCREEN:
		case GDK_SOURCE_PEN:
		{
			if (n_press == 1) {
				GtkBox* _tmp6_;
				GtkBox* _tmp7_;
				gboolean _tmp8_;
				gboolean _tmp9_;
				_tmp6_ = self->priv->image_overlay_toolbar;
				_tmp7_ = self->priv->image_overlay_toolbar;
				_tmp8_ = gtk_widget_get_visible ((GtkWidget*) _tmp7_);
				_tmp9_ = _tmp8_;
				gtk_widget_set_visible ((GtkWidget*) _tmp6_, !_tmp9_);
			} else {
				if (n_press == 2) {
					GtkBox* _tmp10_;
					gtk_widget_activate_action ((GtkWidget*) self, "file.open", NULL, NULL);
					_tmp10_ = self->priv->image_overlay_toolbar;
					gtk_widget_set_visible ((GtkWidget*) _tmp10_, FALSE);
				}
			}
			break;
		}
		default:
		{
			GtkBox* _tmp11_;
			gtk_widget_activate_action ((GtkWidget*) self, "file.open", NULL, NULL);
			_tmp11_ = self->priv->image_overlay_toolbar;
			gtk_widget_set_visible ((GtkWidget*) _tmp11_, FALSE);
			break;
		}
	}
}

static guint8*
_vala_array_dup2 (guint8* self,
                  gssize length)
{
	if (length > 0) {
		return _vala_memdup2 (self, length * sizeof (guint8));
	}
	return NULL;
}

GdkPixbuf*
dino_ui_file_image_widget_parse_thumbnail (XmppXepJingleContentThumbnailsThumbnail* thumbnail)
{
	gchar** splits = NULL;
	const gchar* _tmp0_;
	gchar** _tmp1_;
	gchar** _tmp2_;
	gint splits_length1;
	gint _splits_size_;
	gchar** _tmp3_;
	gint _tmp3__length1;
	gchar** _tmp4_;
	gint _tmp4__length1;
	const gchar* _tmp5_;
	gchar** _tmp6_;
	gint _tmp6__length1;
	const gchar* _tmp7_;
	gchar** _tmp8_;
	gchar** _tmp9_;
	gchar** _tmp10_;
	gint _tmp10__length1;
	gchar** _tmp11_;
	gint _tmp11__length1;
	const gchar* _tmp12_;
	gchar** _tmp13_;
	gint _tmp13__length1;
	const gchar* _tmp14_;
	gchar** _tmp15_;
	gchar** _tmp16_;
	gchar** _tmp17_;
	gint _tmp17__length1;
	gchar** _tmp18_;
	gint _tmp18__length1;
	const gchar* _tmp19_;
	guint8* data = NULL;
	gchar** _tmp20_;
	gint _tmp20__length1;
	const gchar* _tmp21_;
	gsize _tmp22_ = 0;
	guchar* _tmp23_;
	gint data_length1;
	gint _data_size_;
	GMemoryInputStream* input_stream = NULL;
	guint8* _tmp24_;
	gint _tmp24__length1;
	guint8* _tmp25_;
	gint _tmp25__length1;
	GDestroyNotify _tmp26_;
	GMemoryInputStream* _tmp27_;
	GdkPixbuf* pixbuf = NULL;
	GMemoryInputStream* _tmp28_;
	GdkPixbuf* _tmp29_;
	GError* _inner_error0_ = NULL;
	GdkPixbuf* result;
	g_return_val_if_fail (thumbnail != NULL, NULL);
	_tmp0_ = thumbnail->uri;
	_tmp2_ = _tmp1_ = g_strsplit (_tmp0_, ":", 2);
	splits = _tmp2_;
	splits_length1 = _vala_array_length (_tmp1_);
	_splits_size_ = splits_length1;
	_tmp3_ = splits;
	_tmp3__length1 = splits_length1;
	if (_tmp3__length1 != 2) {
		g_warning ("file_image_widget.vala:222: Thumbnail parsing error: ':' not found");
		result = NULL;
		splits = (_vala_array_free (splits, splits_length1, (GDestroyNotify) g_free), NULL);
		return result;
	}
	_tmp4_ = splits;
	_tmp4__length1 = splits_length1;
	_tmp5_ = _tmp4_[0];
	if (g_strcmp0 (_tmp5_, "data") != 0) {
		g_warning ("file_image_widget.vala:226: Unsupported thumbnail: unimplemented uri t" \
"ype\n");
		result = NULL;
		splits = (_vala_array_free (splits, splits_length1, (GDestroyNotify) g_free), NULL);
		return result;
	}
	_tmp6_ = splits;
	_tmp6__length1 = splits_length1;
	_tmp7_ = _tmp6_[1];
	_tmp9_ = _tmp8_ = g_strsplit (_tmp7_, ";", 2);
	splits = (_vala_array_free (splits, splits_length1, (GDestroyNotify) g_free), NULL);
	splits = _tmp9_;
	splits_length1 = _vala_array_length (_tmp8_);
	_splits_size_ = splits_length1;
	_tmp10_ = splits;
	_tmp10__length1 = splits_length1;
	if (_tmp10__length1 != 2) {
		g_warning ("file_image_widget.vala:231: Thumbnail parsing error: ';' not found");
		result = NULL;
		splits = (_vala_array_free (splits, splits_length1, (GDestroyNotify) g_free), NULL);
		return result;
	}
	_tmp11_ = splits;
	_tmp11__length1 = splits_length1;
	_tmp12_ = _tmp11_[0];
	if (g_strcmp0 (_tmp12_, "image/png") != 0) {
		g_warning ("file_image_widget.vala:235: Unsupported thumbnail: unsupported mime-ty" \
"pe\n");
		result = NULL;
		splits = (_vala_array_free (splits, splits_length1, (GDestroyNotify) g_free), NULL);
		return result;
	}
	_tmp13_ = splits;
	_tmp13__length1 = splits_length1;
	_tmp14_ = _tmp13_[1];
	_tmp16_ = _tmp15_ = g_strsplit (_tmp14_, ",", 2);
	splits = (_vala_array_free (splits, splits_length1, (GDestroyNotify) g_free), NULL);
	splits = _tmp16_;
	splits_length1 = _vala_array_length (_tmp15_);
	_splits_size_ = splits_length1;
	_tmp17_ = splits;
	_tmp17__length1 = splits_length1;
	if (_tmp17__length1 != 2) {
		g_warning ("file_image_widget.vala:240: Thumbnail parsing error: ',' not found");
		result = NULL;
		splits = (_vala_array_free (splits, splits_length1, (GDestroyNotify) g_free), NULL);
		return result;
	}
	_tmp18_ = splits;
	_tmp18__length1 = splits_length1;
	_tmp19_ = _tmp18_[0];
	if (g_strcmp0 (_tmp19_, "base64") != 0) {
		g_warning ("file_image_widget.vala:244: Unsupported thumbnail: data is not base64 " \
"encoded\n");
		result = NULL;
		splits = (_vala_array_free (splits, splits_length1, (GDestroyNotify) g_free), NULL);
		return result;
	}
	_tmp20_ = splits;
	_tmp20__length1 = splits_length1;
	_tmp21_ = _tmp20_[1];
	_tmp23_ = g_base64_decode (_tmp21_, &_tmp22_);
	data = _tmp23_;
	data_length1 = _tmp22_;
	_data_size_ = data_length1;
	_tmp24_ = data;
	_tmp24__length1 = data_length1;
	_tmp25_ = (_tmp24_ != NULL) ? _vala_array_dup2 (_tmp24_, _tmp24__length1) : _tmp24_;
	_tmp25__length1 = _tmp24__length1;
	_tmp26_ = g_free;
	_tmp27_ = (GMemoryInputStream*) g_memory_input_stream_new_from_data (_tmp25_, _tmp25__length1, _tmp26_);
	input_stream = _tmp27_;
	_tmp28_ = input_stream;
	_tmp29_ = gdk_pixbuf_new_from_stream ((GInputStream*) _tmp28_, NULL, &_inner_error0_);
	pixbuf = _tmp29_;
	if (G_UNLIKELY (_inner_error0_ != NULL)) {
		_g_object_unref0 (input_stream);
		data = (g_free (data), NULL);
		splits = (_vala_array_free (splits, splits_length1, (GDestroyNotify) g_free), NULL);
		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;
	}
	result = pixbuf;
	_g_object_unref0 (input_stream);
	data = (g_free (data), NULL);
	splits = (_vala_array_free (splits, splits_length1, (GDestroyNotify) g_free), NULL);
	return result;
}

gboolean
dino_ui_file_image_widget_can_display (DinoEntitiesFileTransfer* file_transfer)
{
	gboolean _tmp0_ = FALSE;
	gboolean _tmp1_ = FALSE;
	const gchar* _tmp2_;
	const gchar* _tmp3_;
	gboolean result;
	g_return_val_if_fail (file_transfer != NULL, FALSE);
	_tmp2_ = dino_entities_file_transfer_get_mime_type (file_transfer);
	_tmp3_ = _tmp2_;
	if (_tmp3_ != NULL) {
		const gchar* _tmp4_;
		const gchar* _tmp5_;
		_tmp4_ = dino_entities_file_transfer_get_mime_type (file_transfer);
		_tmp5_ = _tmp4_;
		_tmp1_ = dino_util_is_pixbuf_supported_mime_type (_tmp5_);
	} else {
		_tmp1_ = FALSE;
	}
	if (_tmp1_) {
		gboolean _tmp6_ = FALSE;
		DinoEntitiesFileTransferState _tmp7_;
		DinoEntitiesFileTransferState _tmp8_;
		_tmp7_ = dino_entities_file_transfer_get_state (file_transfer);
		_tmp8_ = _tmp7_;
		if (_tmp8_ == DINO_ENTITIES_FILE_TRANSFER_STATE_COMPLETE) {
			_tmp6_ = TRUE;
		} else {
			GeeList* _tmp9_;
			gint _tmp10_;
			gint _tmp11_;
			_tmp9_ = file_transfer->thumbnails;
			_tmp10_ = gee_collection_get_size ((GeeCollection*) _tmp9_);
			_tmp11_ = _tmp10_;
			_tmp6_ = _tmp11_ > 0;
		}
		_tmp0_ = _tmp6_;
	} else {
		_tmp0_ = FALSE;
	}
	result = _tmp0_;
	return result;
}

static void
dino_ui_file_image_widget_real_dispose (GObject* base)
{
	DinoUiFileImageWidget * self;
	gboolean _tmp0_ = FALSE;
	GtkOverlay* _tmp1_;
	self = (DinoUiFileImageWidget*) base;
	_tmp1_ = self->priv->overlay;
	if (_tmp1_ != NULL) {
		GtkOverlay* _tmp2_;
		GtkWidget* _tmp3_;
		GtkWidget* _tmp4_;
		_tmp2_ = self->priv->overlay;
		_tmp3_ = gtk_widget_get_parent ((GtkWidget*) _tmp2_);
		_tmp4_ = _tmp3_;
		_tmp0_ = _tmp4_ != NULL;
	} else {
		_tmp0_ = FALSE;
	}
	if (_tmp0_) {
		GtkOverlay* _tmp5_;
		_tmp5_ = self->priv->overlay;
		gtk_widget_unparent ((GtkWidget*) _tmp5_);
	}
	G_OBJECT_CLASS (dino_ui_file_image_widget_parent_class)->dispose ((GObject*) G_TYPE_CHECK_INSTANCE_CAST (self, gtk_widget_get_type (), GtkWidget));
}

static GObject *
dino_ui_file_image_widget_constructor (GType type,
                                       guint n_construct_properties,
                                       GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	DinoUiFileImageWidget * self;
	GtkBinLayout* _tmp0_;
	parent_class = G_OBJECT_CLASS (dino_ui_file_image_widget_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, DINO_UI_TYPE_FILE_IMAGE_WIDGET, DinoUiFileImageWidget);
	_tmp0_ = (GtkBinLayout*) gtk_bin_layout_new ();
	gtk_widget_set_layout_manager ((GtkWidget*) self, (GtkLayoutManager*) _tmp0_);
	return obj;
}

static void
dino_ui_file_image_widget_class_init (DinoUiFileImageWidgetClass * klass,
                                      gpointer klass_data)
{
	dino_ui_file_image_widget_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &DinoUiFileImageWidget_private_offset);
	((GObjectClass *) klass)->dispose = (void (*) (GObject*)) dino_ui_file_image_widget_real_dispose;
	G_OBJECT_CLASS (klass)->constructor = dino_ui_file_image_widget_constructor;
	G_OBJECT_CLASS (klass)->finalize = dino_ui_file_image_widget_finalize;
}

static void
dino_ui_file_image_widget_instance_init (DinoUiFileImageWidget * self,
                                         gpointer klass)
{
	GtkStack* _tmp0_ = NULL;
	GtkOverlay* _tmp1_;
	GtkBox* _tmp2_ = NULL;
	GtkLabel* _tmp3_ = NULL;
	DinoUiFileTransmissionProgress* _tmp4_ = NULL;
	self->priv = dino_ui_file_image_widget_get_instance_private (self);
	self->priv->state = DINO_UI_FILE_IMAGE_WIDGET_STATE_EMPTY;
	_tmp0_ = (GtkStack*) gtk_stack_new ();
	gtk_stack_set_transition_duration (_tmp0_, (guint) 600);
	gtk_stack_set_transition_type (_tmp0_, GTK_STACK_TRANSITION_TYPE_CROSSFADE);
	gtk_stack_set_hhomogeneous (_tmp0_, FALSE);
	gtk_stack_set_vhomogeneous (_tmp0_, FALSE);
	gtk_stack_set_interpolate_size (_tmp0_, TRUE);
	g_object_ref_sink (_tmp0_);
	self->priv->stack = _tmp0_;
	_tmp1_ = (GtkOverlay*) gtk_overlay_new ();
	g_object_ref_sink (_tmp1_);
	self->priv->overlay = _tmp1_;
	self->priv->show_image_overlay_toolbar = FALSE;
	_tmp2_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_VERTICAL, 0);
	gtk_widget_set_halign ((GtkWidget*) _tmp2_, GTK_ALIGN_END);
	gtk_widget_set_valign ((GtkWidget*) _tmp2_, GTK_ALIGN_START);
	gtk_widget_set_margin_top ((GtkWidget*) _tmp2_, 10);
	gtk_widget_set_margin_start ((GtkWidget*) _tmp2_, 10);
	gtk_widget_set_margin_end ((GtkWidget*) _tmp2_, 10);
	gtk_widget_set_margin_bottom ((GtkWidget*) _tmp2_, 10);
	gtk_widget_set_vexpand ((GtkWidget*) _tmp2_, FALSE);
	gtk_widget_set_visible ((GtkWidget*) _tmp2_, FALSE);
	g_object_ref_sink (_tmp2_);
	self->priv->image_overlay_toolbar = _tmp2_;
	_tmp3_ = (GtkLabel*) gtk_label_new (NULL);
	gtk_widget_set_halign ((GtkWidget*) _tmp3_, GTK_ALIGN_START);
	gtk_widget_set_valign ((GtkWidget*) _tmp3_, GTK_ALIGN_END);
	gtk_widget_set_margin_bottom ((GtkWidget*) _tmp3_, 4);
	gtk_widget_set_margin_start ((GtkWidget*) _tmp3_, 4);
	gtk_widget_set_visible ((GtkWidget*) _tmp3_, FALSE);
	g_object_ref_sink (_tmp3_);
	self->priv->file_size_label = _tmp3_;
	_tmp4_ = dino_ui_file_transmission_progress_new ();
	gtk_widget_set_halign ((GtkWidget*) _tmp4_, GTK_ALIGN_CENTER);
	gtk_widget_set_valign ((GtkWidget*) _tmp4_, GTK_ALIGN_CENTER);
	gtk_widget_set_visible ((GtkWidget*) _tmp4_, FALSE);
	g_object_ref_sink (_tmp4_);
	self->priv->transmission_progress = _tmp4_;
}

static void
dino_ui_file_image_widget_finalize (GObject * obj)
{
	DinoUiFileImageWidget * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, DINO_UI_TYPE_FILE_IMAGE_WIDGET, DinoUiFileImageWidget);
	_g_object_unref0 (self->priv->stack);
	_g_object_unref0 (self->priv->overlay);
	_g_object_unref0 (self->priv->image_overlay_toolbar);
	_g_object_unref0 (self->priv->file_size_label);
	_g_object_unref0 (self->priv->file_transfer);
	_g_object_unref0 (self->priv->transmission_progress);
	G_OBJECT_CLASS (dino_ui_file_image_widget_parent_class)->finalize (obj);
}

static GType
dino_ui_file_image_widget_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (DinoUiFileImageWidgetClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) dino_ui_file_image_widget_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (DinoUiFileImageWidget), 0, (GInstanceInitFunc) dino_ui_file_image_widget_instance_init, NULL };
	GType dino_ui_file_image_widget_type_id;
	dino_ui_file_image_widget_type_id = g_type_register_static (gtk_widget_get_type (), "DinoUiFileImageWidget", &g_define_type_info, 0);
	DinoUiFileImageWidget_private_offset = g_type_add_instance_private (dino_ui_file_image_widget_type_id, sizeof (DinoUiFileImageWidgetPrivate));
	return dino_ui_file_image_widget_type_id;
}

GType
dino_ui_file_image_widget_get_type (void)
{
	static volatile gsize dino_ui_file_image_widget_type_id__once = 0;
	if (g_once_init_enter (&dino_ui_file_image_widget_type_id__once)) {
		GType dino_ui_file_image_widget_type_id;
		dino_ui_file_image_widget_type_id = dino_ui_file_image_widget_get_type_once ();
		g_once_init_leave (&dino_ui_file_image_widget_type_id__once, dino_ui_file_image_widget_type_id);
	}
	return dino_ui_file_image_widget_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);
}

static gssize
_vala_array_length (gpointer array)
{
	gssize length;
	length = 0;
	if (array) {
		while (((gpointer*) array)[length]) {
			length++;
		}
	}
	return length;
}

static inline gpointer
_vala_memdup2 (gconstpointer mem,
               gsize byte_size)
{
	gpointer new_mem;
	if (mem && byte_size != 0) {
		new_mem = g_malloc (byte_size);
		memcpy (new_mem, mem, byte_size);
	} else {
		new_mem = NULL;
	}
	return new_mem;
}

