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

/*  This file is part of corebird, a Gtk+ linux Twitter client.
 *  Copyright (C) 2017 Timm Bäder
 *
 *  corebird is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  corebird is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with corebird.  If not, see <http://www.gnu.org/licenses/>.
 */

#include <glib.h>
#include <glib-object.h>
#include <gtk/gtk.h>
#include <stdlib.h>
#include <string.h>
#include <cairo.h>
#include <gdk/gdk.h>
#include <glib/gi18n-lib.h>
#include <gio/gio.h>
#include <float.h>
#include <math.h>
#include <gdk-pixbuf/gdk-pixbuf.h>


#define TYPE_FAV_IMAGE_ROW (fav_image_row_get_type ())
#define FAV_IMAGE_ROW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), TYPE_FAV_IMAGE_ROW, FavImageRow))
#define FAV_IMAGE_ROW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), TYPE_FAV_IMAGE_ROW, FavImageRowClass))
#define IS_FAV_IMAGE_ROW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), TYPE_FAV_IMAGE_ROW))
#define IS_FAV_IMAGE_ROW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), TYPE_FAV_IMAGE_ROW))
#define FAV_IMAGE_ROW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), TYPE_FAV_IMAGE_ROW, FavImageRowClass))

typedef struct _FavImageRow FavImageRow;
typedef struct _FavImageRowClass FavImageRowClass;
typedef struct _FavImageRowPrivate FavImageRowPrivate;
enum  {
	FAV_IMAGE_ROW_0_PROPERTY,
	FAV_IMAGE_ROW_NUM_PROPERTIES
};
static GParamSpec* fav_image_row_properties[FAV_IMAGE_ROW_NUM_PROPERTIES];
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))
#define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
#define __vala_GdkEventButton_free0(var) ((var == NULL) ? NULL : (var = (_vala_GdkEventButton_free (var), NULL)))
#define __vala_GdkEventSequence_free0(var) ((var == NULL) ? NULL : (var = (_vala_GdkEventSequence_free (var), NULL)))
typedef struct _FavImageRowLoadImageData FavImageRowLoadImageData;
#define _cairo_surface_destroy0(var) ((var == NULL) ? NULL : (var = (cairo_surface_destroy (var), NULL)))

struct _FavImageRow {
	GtkFlowBoxChild parent_instance;
	FavImageRowPrivate * priv;
	gboolean is_gif;
};

struct _FavImageRowClass {
	GtkFlowBoxChildClass parent_class;
};

struct _FavImageRowPrivate {
	GtkEventBox* event_box;
	GtkImage* image;
	gchar* file_path;
	GtkGestureMultiPress* gesture;
};

struct _FavImageRowLoadImageData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	FavImageRow* self;
	GFileInputStream* in_stream;
	const gchar* _tmp0_;
	GFile* _tmp1_;
	GFile* _tmp2_;
	GFileInputStream* _tmp3_;
	GFileInputStream* _tmp4_;
	GdkPixbuf* pixbuf;
	GFileInputStream* _tmp5_;
	GdkPixbuf* _tmp6_;
	GFileInputStream* _tmp7_;
	GtkImage* _tmp8_;
	GdkPixbuf* _tmp9_;
	GError* e;
	GError* _tmp10_;
	const gchar* _tmp11_;
	GError * _inner_error_;
};


static gpointer fav_image_row_parent_class = NULL;
static cairo_surface_t* fav_image_row_play_icon;
static cairo_surface_t* fav_image_row_play_icon = NULL;

GType fav_image_row_get_type (void) G_GNUC_CONST;
#define FAV_IMAGE_ROW_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), TYPE_FAV_IMAGE_ROW, FavImageRowPrivate))
#define FAV_IMAGE_ROW_THUMB_WIDTH 80
#define FAV_IMAGE_ROW_THUMB_HEIGHT 50
FavImageRow* fav_image_row_new (const gchar* path);
FavImageRow* fav_image_row_construct (GType object_type, const gchar* path);
static gboolean __lambda33_ (FavImageRow* self);
static gboolean ___lambda33__gtk_widget_enter_notify_event (GtkWidget* _sender, GdkEventCrossing* event, gpointer self);
static gboolean __lambda34_ (FavImageRow* self);
static gboolean ___lambda34__gtk_widget_leave_notify_event (GtkWidget* _sender, GdkEventCrossing* event, gpointer self);
static void __lambda35_ (FavImageRow* self);
static GdkEventButton* _vala_GdkEventButton_copy (GdkEventButton* self);
static void ___lambda36_ (FavImageRow* self);
static void ____lambda36__gtk_menu_item_activate (GtkMenuItem* _sender, gpointer self);
static void _vala_GdkEventButton_free (GdkEventButton* self);
static void _vala_GdkEventSequence_free (GdkEventSequence* self);
static void ___lambda35__gtk_gesture_multi_press_pressed (GtkGestureMultiPress* _sender, gint p0, gdouble p1, gdouble p2, gpointer self);
static void __lambda37_ (FavImageRow* self);
static void ___lambda37__gtk_gesture_multi_press_released (GtkGestureMultiPress* _sender, gint p0, gdouble p1, gdouble p2, gpointer self);
static void fav_image_row_load_image (FavImageRow* self, GAsyncReadyCallback _callback_, gpointer _user_data_);
static void fav_image_row_load_image_finish (FavImageRow* self, GAsyncResult* _res_);
static gboolean fav_image_row_real_draw (GtkWidget* base, cairo_t* ct);
const gchar* fav_image_row_get_image_path (FavImageRow* self);
static void fav_image_row_load_image_data_free (gpointer _data);
static gboolean fav_image_row_load_image_co (FavImageRowLoadImageData* _data_);
static void fav_image_row_load_image_ready (GObject* source_object, GAsyncResult* _res_, gpointer _user_data_);
static void fav_image_row_finalize (GObject * obj);


static gboolean __lambda33_ (FavImageRow* self) {
	gboolean result = FALSE;
	GtkStateFlags flags = 0;
	GtkStateFlags _tmp0_;
	_tmp0_ = gtk_widget_get_state_flags (G_TYPE_CHECK_INSTANCE_CAST (self, gtk_widget_get_type (), GtkWidget));
	flags = _tmp0_;
	gtk_widget_set_state_flags (G_TYPE_CHECK_INSTANCE_CAST (self, gtk_widget_get_type (), GtkWidget), flags | GTK_STATE_FLAG_PRELIGHT, TRUE);
	result = FALSE;
	return result;
}


static gboolean ___lambda33__gtk_widget_enter_notify_event (GtkWidget* _sender, GdkEventCrossing* event, gpointer self) {
	gboolean result;
	result = __lambda33_ ((FavImageRow*) self);
	return result;
}


static gboolean __lambda34_ (FavImageRow* self) {
	gboolean result = FALSE;
	gtk_widget_unset_state_flags (G_TYPE_CHECK_INSTANCE_CAST (self, gtk_widget_get_type (), GtkWidget), GTK_STATE_FLAG_PRELIGHT);
	result = FALSE;
	return result;
}


static gboolean ___lambda34__gtk_widget_leave_notify_event (GtkWidget* _sender, GdkEventCrossing* event, gpointer self) {
	gboolean result;
	result = __lambda34_ ((FavImageRow*) self);
	return result;
}


static GdkEventButton* _vala_GdkEventButton_copy (GdkEventButton* self) {
	return g_boxed_copy (gdk_event_get_type (), self);
}


static gpointer __vala_GdkEventButton_copy0 (gpointer self) {
	return self ? _vala_GdkEventButton_copy (self) : NULL;
}


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


static void ___lambda36_ (FavImageRow* self) {
	GtkContainer* flowbox = NULL;
	GtkContainer* _tmp0_;
	GtkContainer* _tmp1_;
	GtkContainer* _tmp2_;
	GError * _inner_error_ = NULL;
	_tmp0_ = (GtkContainer*) gtk_widget_get_parent (G_TYPE_CHECK_INSTANCE_CAST (self, gtk_widget_get_type (), GtkWidget));
	_tmp1_ = _g_object_ref0 (_tmp0_);
	flowbox = _tmp1_;
	_tmp2_ = flowbox;
	if (!G_TYPE_CHECK_INSTANCE_TYPE (_tmp2_, gtk_flow_box_get_type ())) {
		g_warning ("FavImageRow.vala:85: Parent is not a flowbox");
		_g_object_unref0 (flowbox);
		return;
	}
	{
		GFile* file = NULL;
		const gchar* _tmp3_;
		GFile* _tmp4_;
		GFile* _tmp5_;
		GtkContainer* _tmp6_;
		_tmp3_ = self->priv->file_path;
		_tmp4_ = g_file_new_for_path (_tmp3_);
		file = _tmp4_;
		_tmp5_ = file;
		g_file_trash (_tmp5_, NULL, &_inner_error_);
		if (G_UNLIKELY (_inner_error_ != NULL)) {
			_g_object_unref0 (file);
			goto __catch84_g_error;
		}
		_tmp6_ = flowbox;
		gtk_container_remove (_tmp6_, G_TYPE_CHECK_INSTANCE_CAST (self, gtk_widget_get_type (), GtkWidget));
		_g_object_unref0 (file);
	}
	goto __finally84;
	__catch84_g_error:
	{
		GError* e = NULL;
		GError* _tmp7_;
		const gchar* _tmp8_;
		e = _inner_error_;
		_inner_error_ = NULL;
		_tmp7_ = e;
		_tmp8_ = _tmp7_->message;
		g_warning ("FavImageRow.vala:94: %s", _tmp8_);
		_g_error_free0 (e);
	}
	__finally84:
	if (G_UNLIKELY (_inner_error_ != NULL)) {
		_g_object_unref0 (flowbox);
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
		g_clear_error (&_inner_error_);
		return;
	}
	_g_object_unref0 (flowbox);
}


static void ____lambda36__gtk_menu_item_activate (GtkMenuItem* _sender, gpointer self) {
	___lambda36_ ((FavImageRow*) self);
}


static void _vala_GdkEventButton_free (GdkEventButton* self) {
	g_boxed_free (gdk_event_get_type (), self);
}


static void _vala_GdkEventSequence_free (GdkEventSequence* self) {
	g_boxed_free (gdk_event_sequence_get_type (), self);
}


static void __lambda35_ (FavImageRow* self) {
	GdkEventSequence* sequence = NULL;
	GtkGestureMultiPress* _tmp0_;
	GdkEventSequence* _tmp1_;
	GdkEventButton* event = NULL;
	GtkGestureMultiPress* _tmp2_;
	GdkEventSequence* _tmp3_;
	GdkEvent* _tmp4_;
	GdkEventButton* _tmp5_;
	GdkEventButton* _tmp6_;
	gboolean _tmp7_;
	GtkGestureMultiPress* _tmp21_;
	_tmp0_ = self->priv->gesture;
	_tmp1_ = gtk_gesture_single_get_current_sequence (G_TYPE_CHECK_INSTANCE_CAST (_tmp0_, gtk_gesture_single_get_type (), GtkGestureSingle));
	sequence = _tmp1_;
	_tmp2_ = self->priv->gesture;
	_tmp3_ = sequence;
	_tmp4_ = gtk_gesture_get_last_event (G_TYPE_CHECK_INSTANCE_CAST (_tmp2_, gtk_gesture_get_type (), GtkGesture), _tmp3_);
	_tmp5_ = __vala_GdkEventButton_copy0 ((GdkEventButton*) _tmp4_);
	event = _tmp5_;
	_tmp6_ = event;
	_tmp7_ = gdk_event_triggers_context_menu ((GdkEvent*) _tmp6_);
	if (_tmp7_) {
		GtkMenu* menu = NULL;
		GtkMenu* _tmp8_;
		GtkMenuItem* delete_item = NULL;
		GtkMenuItem* _tmp9_;
		GtkMenuItem* _tmp10_;
		GtkMenu* _tmp11_;
		GtkMenuItem* _tmp12_;
		GtkMenu* _tmp13_;
		GtkMenu* _tmp14_;
		GtkMenu* _tmp15_;
		GdkEventButton* _tmp16_;
		guint _tmp17_;
		GdkEventButton* _tmp18_;
		guint32 _tmp19_;
		_tmp8_ = (GtkMenu*) gtk_menu_new ();
		g_object_ref_sink (_tmp8_);
		menu = _tmp8_;
		_tmp9_ = (GtkMenuItem*) gtk_menu_item_new_with_label (_ ("Delete"));
		g_object_ref_sink (_tmp9_);
		delete_item = _tmp9_;
		_tmp10_ = delete_item;
		g_signal_connect_object (_tmp10_, "activate", (GCallback) ____lambda36__gtk_menu_item_activate, self, 0);
		_tmp11_ = menu;
		_tmp12_ = delete_item;
		gtk_container_add (G_TYPE_CHECK_INSTANCE_CAST (_tmp11_, gtk_container_get_type (), GtkContainer), G_TYPE_CHECK_INSTANCE_CAST (_tmp12_, gtk_widget_get_type (), GtkWidget));
		_tmp13_ = menu;
		gtk_menu_attach_to_widget (_tmp13_, G_TYPE_CHECK_INSTANCE_CAST (self, gtk_widget_get_type (), GtkWidget), NULL);
		_tmp14_ = menu;
		gtk_widget_show_all (G_TYPE_CHECK_INSTANCE_CAST (_tmp14_, gtk_widget_get_type (), GtkWidget));
		_tmp15_ = menu;
		_tmp16_ = event;
		_tmp17_ = _tmp16_->button;
		_tmp18_ = event;
		_tmp19_ = _tmp18_->time;
		gtk_menu_popup (_tmp15_, NULL, NULL, NULL, NULL, _tmp17_, _tmp19_);
		_g_object_unref0 (delete_item);
		_g_object_unref0 (menu);
	} else {
		GtkStateFlags _tmp20_;
		_tmp20_ = gtk_widget_get_state_flags (G_TYPE_CHECK_INSTANCE_CAST (self, gtk_widget_get_type (), GtkWidget));
		gtk_widget_set_state_flags (G_TYPE_CHECK_INSTANCE_CAST (self, gtk_widget_get_type (), GtkWidget), _tmp20_ | GTK_STATE_FLAG_ACTIVE, TRUE);
	}
	_tmp21_ = self->priv->gesture;
	gtk_gesture_set_state (G_TYPE_CHECK_INSTANCE_CAST (_tmp21_, gtk_gesture_get_type (), GtkGesture), GTK_EVENT_SEQUENCE_CLAIMED);
	__vala_GdkEventButton_free0 (event);
	__vala_GdkEventSequence_free0 (sequence);
}


static void ___lambda35__gtk_gesture_multi_press_pressed (GtkGestureMultiPress* _sender, gint p0, gdouble p1, gdouble p2, gpointer self) {
	__lambda35_ ((FavImageRow*) self);
}


static void __lambda37_ (FavImageRow* self) {
	GdkEventSequence* sequence = NULL;
	GtkGestureMultiPress* _tmp0_;
	GdkEventSequence* _tmp1_;
	GdkEventButton* event = NULL;
	GtkGestureMultiPress* _tmp2_;
	GdkEventSequence* _tmp3_;
	GdkEvent* _tmp4_;
	GdkEventButton* _tmp5_;
	gboolean _tmp6_ = FALSE;
	GdkEventButton* _tmp7_;
	_tmp0_ = self->priv->gesture;
	_tmp1_ = gtk_gesture_single_get_current_sequence (G_TYPE_CHECK_INSTANCE_CAST (_tmp0_, gtk_gesture_single_get_type (), GtkGestureSingle));
	sequence = _tmp1_;
	_tmp2_ = self->priv->gesture;
	_tmp3_ = sequence;
	_tmp4_ = gtk_gesture_get_last_event (G_TYPE_CHECK_INSTANCE_CAST (_tmp2_, gtk_gesture_get_type (), GtkGesture), _tmp3_);
	_tmp5_ = __vala_GdkEventButton_copy0 ((GdkEventButton*) _tmp4_);
	event = _tmp5_;
	gtk_widget_unset_state_flags (G_TYPE_CHECK_INSTANCE_CAST (self, gtk_widget_get_type (), GtkWidget), GTK_STATE_FLAG_ACTIVE);
	_tmp7_ = event;
	if (_tmp7_ != NULL) {
		GdkEventButton* _tmp8_;
		guint _tmp9_;
		_tmp8_ = event;
		_tmp9_ = _tmp8_->button;
		_tmp6_ = _tmp9_ == ((guint) GDK_BUTTON_PRIMARY);
	} else {
		_tmp6_ = FALSE;
	}
	if (_tmp6_) {
		GtkContainer* _tmp10_;
		_tmp10_ = (GtkContainer*) gtk_widget_get_parent (G_TYPE_CHECK_INSTANCE_CAST (self, gtk_widget_get_type (), GtkWidget));
		if (G_TYPE_CHECK_INSTANCE_TYPE (_tmp10_, gtk_flow_box_get_type ())) {
			GtkContainer* _tmp11_;
			_tmp11_ = (GtkContainer*) gtk_widget_get_parent (G_TYPE_CHECK_INSTANCE_CAST (self, gtk_widget_get_type (), GtkWidget));
			g_signal_emit_by_name (G_TYPE_CHECK_INSTANCE_CAST (_tmp11_, gtk_flow_box_get_type (), GtkFlowBox), "child-activated", G_TYPE_CHECK_INSTANCE_CAST (self, gtk_flow_box_child_get_type (), GtkFlowBoxChild));
		}
	}
	__vala_GdkEventButton_free0 (event);
	__vala_GdkEventSequence_free0 (sequence);
}


static void ___lambda37__gtk_gesture_multi_press_released (GtkGestureMultiPress* _sender, gint p0, gdouble p1, gdouble p2, gpointer self) {
	__lambda37_ ((FavImageRow*) self);
}


FavImageRow* fav_image_row_construct (GType object_type, const gchar* path) {
	FavImageRow * self = NULL;
	const gchar* _tmp0_;
	gchar* _tmp1_;
	GtkEventBox* _tmp2_;
	GtkEventBox* _tmp3_;
	GtkImage* _tmp4_;
	GtkImage* _tmp5_;
	GtkImage* _tmp6_;
	GtkImage* _tmp7_;
	GtkImage* _tmp8_;
	GtkImage* _tmp9_;
	GtkEventBox* _tmp10_;
	GtkImage* _tmp11_;
	GtkEventBox* _tmp12_;
	GtkEventBox* _tmp13_;
	GtkEventBox* _tmp14_;
	GtkEventBox* _tmp15_;
	GtkGestureMultiPress* _tmp16_;
	GtkGestureMultiPress* _tmp17_;
	GtkGestureMultiPress* _tmp18_;
	GtkGestureMultiPress* _tmp19_;
	GtkGestureMultiPress* _tmp20_;
	GtkStyleContext* _tmp21_;
	g_return_val_if_fail (path != NULL, NULL);
	self = (FavImageRow*) g_object_new (object_type, NULL);
	_tmp0_ = path;
	_tmp1_ = g_strdup (_tmp0_);
	_g_free0 (self->priv->file_path);
	self->priv->file_path = _tmp1_;
	_tmp2_ = (GtkEventBox*) gtk_event_box_new ();
	g_object_ref_sink (_tmp2_);
	_g_object_unref0 (self->priv->event_box);
	self->priv->event_box = _tmp2_;
	_tmp3_ = self->priv->event_box;
	gtk_widget_show (G_TYPE_CHECK_INSTANCE_CAST (_tmp3_, gtk_widget_get_type (), GtkWidget));
	_tmp4_ = (GtkImage*) gtk_image_new ();
	g_object_ref_sink (_tmp4_);
	_g_object_unref0 (self->priv->image);
	self->priv->image = _tmp4_;
	_tmp5_ = self->priv->image;
	gtk_widget_set_size_request (G_TYPE_CHECK_INSTANCE_CAST (_tmp5_, gtk_widget_get_type (), GtkWidget), FAV_IMAGE_ROW_THUMB_WIDTH, FAV_IMAGE_ROW_THUMB_HEIGHT);
	_tmp6_ = self->priv->image;
	gtk_widget_set_halign (G_TYPE_CHECK_INSTANCE_CAST (_tmp6_, gtk_widget_get_type (), GtkWidget), GTK_ALIGN_CENTER);
	_tmp7_ = self->priv->image;
	gtk_widget_set_valign (G_TYPE_CHECK_INSTANCE_CAST (_tmp7_, gtk_widget_get_type (), GtkWidget), GTK_ALIGN_CENTER);
	_tmp8_ = self->priv->image;
	g_object_set (G_TYPE_CHECK_INSTANCE_CAST (_tmp8_, gtk_widget_get_type (), GtkWidget), "margin", 3, NULL);
	_tmp9_ = self->priv->image;
	gtk_widget_show (G_TYPE_CHECK_INSTANCE_CAST (_tmp9_, gtk_widget_get_type (), GtkWidget));
	_tmp10_ = self->priv->event_box;
	_tmp11_ = self->priv->image;
	gtk_container_add (G_TYPE_CHECK_INSTANCE_CAST (_tmp10_, gtk_container_get_type (), GtkContainer), G_TYPE_CHECK_INSTANCE_CAST (_tmp11_, gtk_widget_get_type (), GtkWidget));
	_tmp12_ = self->priv->event_box;
	gtk_container_add (G_TYPE_CHECK_INSTANCE_CAST (self, gtk_container_get_type (), GtkContainer), G_TYPE_CHECK_INSTANCE_CAST (_tmp12_, gtk_widget_get_type (), GtkWidget));
	gtk_widget_set_valign (G_TYPE_CHECK_INSTANCE_CAST (self, gtk_widget_get_type (), GtkWidget), GTK_ALIGN_START);
	_tmp13_ = self->priv->event_box;
	g_signal_connect_object (G_TYPE_CHECK_INSTANCE_CAST (_tmp13_, gtk_widget_get_type (), GtkWidget), "enter-notify-event", (GCallback) ___lambda33__gtk_widget_enter_notify_event, self, 0);
	_tmp14_ = self->priv->event_box;
	g_signal_connect_object (G_TYPE_CHECK_INSTANCE_CAST (_tmp14_, gtk_widget_get_type (), GtkWidget), "leave-notify-event", (GCallback) ___lambda34__gtk_widget_leave_notify_event, self, 0);
	_tmp15_ = self->priv->event_box;
	_tmp16_ = (GtkGestureMultiPress*) gtk_gesture_multi_press_new (G_TYPE_CHECK_INSTANCE_CAST (_tmp15_, gtk_widget_get_type (), GtkWidget));
	_g_object_unref0 (self->priv->gesture);
	self->priv->gesture = _tmp16_;
	_tmp17_ = self->priv->gesture;
	gtk_event_controller_set_propagation_phase (G_TYPE_CHECK_INSTANCE_CAST (_tmp17_, gtk_event_controller_get_type (), GtkEventController), GTK_PHASE_CAPTURE);
	_tmp18_ = self->priv->gesture;
	gtk_gesture_single_set_button (G_TYPE_CHECK_INSTANCE_CAST (_tmp18_, gtk_gesture_single_get_type (), GtkGestureSingle), (guint) 0);
	_tmp19_ = self->priv->gesture;
	g_signal_connect_object (_tmp19_, "pressed", (GCallback) ___lambda35__gtk_gesture_multi_press_pressed, self, 0);
	_tmp20_ = self->priv->gesture;
	g_signal_connect_object (_tmp20_, "released", (GCallback) ___lambda37__gtk_gesture_multi_press_released, self, 0);
	_tmp21_ = gtk_widget_get_style_context (G_TYPE_CHECK_INSTANCE_CAST (self, gtk_widget_get_type (), GtkWidget));
	gtk_style_context_add_class (_tmp21_, "fav-image-item");
	fav_image_row_load_image (self, NULL, NULL);
	return self;
}


FavImageRow* fav_image_row_new (const gchar* path) {
	return fav_image_row_construct (TYPE_FAV_IMAGE_ROW, path);
}


static gboolean fav_image_row_real_draw (GtkWidget* base, cairo_t* ct) {
	FavImageRow * self;
	gboolean result = FALSE;
	cairo_t* _tmp0_;
	gboolean _tmp1_;
	self = G_TYPE_CHECK_INSTANCE_CAST (base, TYPE_FAV_IMAGE_ROW, FavImageRow);
	g_return_val_if_fail (ct != NULL, FALSE);
	_tmp0_ = ct;
	GTK_WIDGET_CLASS (fav_image_row_parent_class)->draw (G_TYPE_CHECK_INSTANCE_CAST (G_TYPE_CHECK_INSTANCE_CAST (self, gtk_flow_box_child_get_type (), GtkFlowBoxChild), gtk_widget_get_type (), GtkWidget), _tmp0_);
	_tmp1_ = self->is_gif;
	if (_tmp1_) {
		gdouble scale = 0.0;
		gint width = 0;
		gint _tmp2_;
		gint height = 0;
		gint _tmp3_;
		gdouble x = 0.0;
		gint _tmp4_;
		gdouble _tmp5_;
		cairo_surface_t* _tmp6_;
		gint _tmp7_;
		gdouble y = 0.0;
		gint _tmp8_;
		gdouble _tmp9_;
		cairo_surface_t* _tmp10_;
		gint _tmp11_;
		cairo_t* _tmp12_;
		gdouble _tmp13_;
		gdouble _tmp14_;
		cairo_t* _tmp15_;
		cairo_surface_t* _tmp16_;
		gdouble _tmp17_;
		gdouble _tmp18_;
		cairo_t* _tmp19_;
		scale = 0.6;
		_tmp2_ = gtk_widget_get_allocated_width (G_TYPE_CHECK_INSTANCE_CAST (self, gtk_widget_get_type (), GtkWidget));
		width = _tmp2_;
		_tmp3_ = gtk_widget_get_allocated_height (G_TYPE_CHECK_INSTANCE_CAST (self, gtk_widget_get_type (), GtkWidget));
		height = _tmp3_;
		_tmp4_ = width;
		_tmp5_ = scale;
		_tmp6_ = fav_image_row_play_icon;
		_tmp7_ = cairo_image_surface_get_width (_tmp6_);
		x = ((_tmp4_ / 2.0) / _tmp5_) - (_tmp7_ / 2.0);
		_tmp8_ = height;
		_tmp9_ = scale;
		_tmp10_ = fav_image_row_play_icon;
		_tmp11_ = cairo_image_surface_get_height (_tmp10_);
		y = ((_tmp8_ / 2.0) / _tmp9_) - (_tmp11_ / 2.0);
		_tmp12_ = ct;
		_tmp13_ = scale;
		_tmp14_ = scale;
		cairo_scale (_tmp12_, _tmp13_, _tmp14_);
		_tmp15_ = ct;
		_tmp16_ = fav_image_row_play_icon;
		_tmp17_ = x;
		_tmp18_ = y;
		cairo_set_source_surface (_tmp15_, _tmp16_, _tmp17_, _tmp18_);
		_tmp19_ = ct;
		cairo_paint (_tmp19_);
	}
	result = FALSE;
	return result;
}


const gchar* fav_image_row_get_image_path (FavImageRow* self) {
	const gchar* result = NULL;
	const gchar* _tmp0_;
	g_return_val_if_fail (IS_FAV_IMAGE_ROW (self), NULL);
	_tmp0_ = self->priv->file_path;
	result = _tmp0_;
	return result;
}


static void fav_image_row_load_image_data_free (gpointer _data) {
	FavImageRowLoadImageData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->self);
	g_slice_free (FavImageRowLoadImageData, _data_);
}


static void fav_image_row_load_image (FavImageRow* self, GAsyncReadyCallback _callback_, gpointer _user_data_) {
	FavImageRowLoadImageData* _data_;
	FavImageRow* _tmp0_;
	_data_ = g_slice_new0 (FavImageRowLoadImageData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, fav_image_row_load_image_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	fav_image_row_load_image_co (_data_);
}


static void fav_image_row_load_image_finish (FavImageRow* self, GAsyncResult* _res_) {
	FavImageRowLoadImageData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
}


static void fav_image_row_load_image_ready (GObject* source_object, GAsyncResult* _res_, gpointer _user_data_) {
	FavImageRowLoadImageData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	fav_image_row_load_image_co (_data_);
}


static gboolean fav_image_row_load_image_co (FavImageRowLoadImageData* _data_) {
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	{
		_data_->_tmp0_ = _data_->self->priv->file_path;
		_data_->_tmp1_ = g_file_new_for_path (_data_->_tmp0_);
		_data_->_tmp2_ = _data_->_tmp1_;
		_data_->_tmp3_ = g_file_read (_data_->_tmp2_, NULL, &_data_->_inner_error_);
		_data_->_tmp4_ = _data_->_tmp3_;
		_g_object_unref0 (_data_->_tmp2_);
		_data_->in_stream = _data_->_tmp4_;
		if (G_UNLIKELY (_data_->_inner_error_ != NULL)) {
			goto __catch85_g_error;
		}
		_data_->_tmp5_ = _data_->in_stream;
		_data_->_state_ = 1;
		gdk_pixbuf_new_from_stream_at_scale_async (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp5_, g_input_stream_get_type (), GInputStream), FAV_IMAGE_ROW_THUMB_WIDTH, FAV_IMAGE_ROW_THUMB_HEIGHT, TRUE, NULL, fav_image_row_load_image_ready, _data_);
		return FALSE;
		_state_1:
		_data_->_tmp6_ = (GdkPixbuf*) gdk_pixbuf_new_from_stream_finish (_data_->_res_, &_data_->_inner_error_);
		_data_->pixbuf = _data_->_tmp6_;
		if (G_UNLIKELY (_data_->_inner_error_ != NULL)) {
			_g_object_unref0 (_data_->in_stream);
			goto __catch85_g_error;
		}
		_data_->_tmp7_ = _data_->in_stream;
		g_input_stream_close (G_TYPE_CHECK_INSTANCE_CAST (_data_->_tmp7_, g_input_stream_get_type (), GInputStream), NULL, &_data_->_inner_error_);
		if (G_UNLIKELY (_data_->_inner_error_ != NULL)) {
			_g_object_unref0 (_data_->pixbuf);
			_g_object_unref0 (_data_->in_stream);
			goto __catch85_g_error;
		}
		_data_->_tmp8_ = _data_->self->priv->image;
		_data_->_tmp9_ = _data_->pixbuf;
		gtk_image_set_from_pixbuf (_data_->_tmp8_, _data_->_tmp9_);
		_g_object_unref0 (_data_->pixbuf);
		_g_object_unref0 (_data_->in_stream);
	}
	goto __finally85;
	__catch85_g_error:
	{
		_data_->e = _data_->_inner_error_;
		_data_->_inner_error_ = NULL;
		_data_->_tmp10_ = _data_->e;
		_data_->_tmp11_ = _data_->_tmp10_->message;
		g_warning ("FavImageRow.vala:161: %s", _data_->_tmp11_);
		_g_error_free0 (_data_->e);
	}
	__finally85:
	if (G_UNLIKELY (_data_->_inner_error_ != NULL)) {
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _data_->_inner_error_->message, g_quark_to_string (_data_->_inner_error_->domain), _data_->_inner_error_->code);
		g_clear_error (&_data_->_inner_error_);
		g_object_unref (_data_->_async_result);
		return FALSE;
	}
	g_task_return_pointer (_data_->_async_result, _data_, NULL);
	if (_data_->_state_ != 0) {
		while (g_task_get_completed (_data_->_async_result) != TRUE) {
			g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
		}
	}
	g_object_unref (_data_->_async_result);
	return FALSE;
}


static void fav_image_row_class_init (FavImageRowClass * klass) {
	GError * _inner_error_ = NULL;
	fav_image_row_parent_class = g_type_class_peek_parent (klass);
	g_type_class_add_private (klass, sizeof (FavImageRowPrivate));
	((GtkWidgetClass *) klass)->draw = (gboolean (*) (GtkWidget *, cairo_t*)) fav_image_row_real_draw;
	G_OBJECT_CLASS (klass)->finalize = fav_image_row_finalize;
	{
		GdkPixbuf* _tmp0_ = NULL;
		GdkPixbuf* _tmp1_;
		cairo_surface_t* _tmp2_;
		_tmp1_ = gdk_pixbuf_new_from_resource ("/org/baedert/corebird/data/play.png", &_inner_error_);
		_tmp0_ = _tmp1_;
		if (G_UNLIKELY (_inner_error_ != NULL)) {
			goto __catch86_g_error;
		}
		_tmp2_ = gdk_cairo_surface_create_from_pixbuf (_tmp0_, 1, NULL);
		_cairo_surface_destroy0 (fav_image_row_play_icon);
		fav_image_row_play_icon = (cairo_surface_t*) _tmp2_;
		_g_object_unref0 (_tmp0_);
	}
	goto __finally86;
	__catch86_g_error:
	{
		GError* e = NULL;
		GError* _tmp3_;
		const gchar* _tmp4_;
		e = _inner_error_;
		_inner_error_ = NULL;
		_tmp3_ = e;
		_tmp4_ = _tmp3_->message;
		g_critical ("FavImageRow.vala:36: %s", _tmp4_);
		_g_error_free0 (e);
	}
	__finally86:
	if (G_UNLIKELY (_inner_error_ != NULL)) {
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error_->message, g_quark_to_string (_inner_error_->domain), _inner_error_->code);
		g_clear_error (&_inner_error_);
	}
}


static void fav_image_row_instance_init (FavImageRow * self) {
	self->priv = FAV_IMAGE_ROW_GET_PRIVATE (self);
	self->is_gif = FALSE;
}


static void fav_image_row_finalize (GObject * obj) {
	FavImageRow * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, TYPE_FAV_IMAGE_ROW, FavImageRow);
	_g_object_unref0 (self->priv->event_box);
	_g_object_unref0 (self->priv->image);
	_g_free0 (self->priv->file_path);
	_g_object_unref0 (self->priv->gesture);
	G_OBJECT_CLASS (fav_image_row_parent_class)->finalize (obj);
}


GType fav_image_row_get_type (void) {
	static volatile gsize fav_image_row_type_id__volatile = 0;
	if (g_once_init_enter (&fav_image_row_type_id__volatile)) {
		static const GTypeInfo g_define_type_info = { sizeof (FavImageRowClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) fav_image_row_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (FavImageRow), 0, (GInstanceInitFunc) fav_image_row_instance_init, NULL };
		GType fav_image_row_type_id;
		fav_image_row_type_id = g_type_register_static (gtk_flow_box_child_get_type (), "FavImageRow", &g_define_type_info, 0);
		g_once_init_leave (&fav_image_row_type_id__volatile, fav_image_row_type_id);
	}
	return fav_image_row_type_id__volatile;
}



