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

/*
 * Copyright © 2023 Alain M. (https://github.com/alainm23/planify)
 *
 * This program 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.
 *
 * This program 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 this program; if not, write to the
 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 * Boston, MA 02110-1301 USA
 *
 * Authored by: Alain M. <alainmh23@gmail.com>
 */

#include <gtk/gtk.h>
#include <glib-object.h>
#include "planify.h"
#include <glib.h>
#include <stdlib.h>
#include <string.h>
#include <gio/gio.h>
#include <adwaita.h>
#include <pango/pango.h>
#include <glib/gi18n-lib.h>
#include <float.h>
#include <math.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 WIDGETS_TYPE_ATTACHMENT_ROW (widgets_attachment_row_get_type ())
#define WIDGETS_ATTACHMENT_ROW(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), WIDGETS_TYPE_ATTACHMENT_ROW, WidgetsAttachmentRow))
#define WIDGETS_ATTACHMENT_ROW_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), WIDGETS_TYPE_ATTACHMENT_ROW, WidgetsAttachmentRowClass))
#define WIDGETS_IS_ATTACHMENT_ROW(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), WIDGETS_TYPE_ATTACHMENT_ROW))
#define WIDGETS_IS_ATTACHMENT_ROW_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), WIDGETS_TYPE_ATTACHMENT_ROW))
#define WIDGETS_ATTACHMENT_ROW_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), WIDGETS_TYPE_ATTACHMENT_ROW, WidgetsAttachmentRowClass))

typedef struct _WidgetsAttachmentRow WidgetsAttachmentRow;
typedef struct _WidgetsAttachmentRowClass WidgetsAttachmentRowClass;
typedef struct _WidgetsAttachmentRowPrivate WidgetsAttachmentRowPrivate;
enum  {
	WIDGETS_ATTACHMENT_ROW_0_PROPERTY,
	WIDGETS_ATTACHMENT_ROW_ATTACHMENT_PROPERTY,
	WIDGETS_ATTACHMENT_ROW_NUM_PROPERTIES
};
static GParamSpec* widgets_attachment_row_properties[WIDGETS_ATTACHMENT_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)))
typedef struct _Block54Data Block54Data;

struct _WidgetsAttachmentRow {
	GtkListBoxRow parent_instance;
	WidgetsAttachmentRowPrivate * priv;
};

struct _WidgetsAttachmentRowClass {
	GtkListBoxRowClass parent_class;
};

struct _WidgetsAttachmentRowPrivate {
	ObjectsAttachment* _attachment;
	GtkRevealer* main_revealer;
	WidgetsLoadingButton* close_button;
};

struct _Block54Data {
	int _ref_count_;
	WidgetsAttachmentRow* self;
	GtkGestureClick* remove_gesture;
};

static gint WidgetsAttachmentRow_private_offset;
static gpointer widgets_attachment_row_parent_class = NULL;

VALA_EXTERN GType widgets_attachment_row_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (WidgetsAttachmentRow, g_object_unref)
VALA_EXTERN WidgetsAttachmentRow* widgets_attachment_row_new (ObjectsAttachment* attachment);
VALA_EXTERN WidgetsAttachmentRow* widgets_attachment_row_construct (GType object_type,
                                                        ObjectsAttachment* attachment);
static void widgets_attachment_row_open_file (WidgetsAttachmentRow* self);
VALA_EXTERN ObjectsAttachment* widgets_attachment_row_get_attachment (WidgetsAttachmentRow* self);
static void _g_object_unref0_ (gpointer var);
static inline void _g_list_free__g_object_unref0_ (GList* self);
VALA_EXTERN void widgets_attachment_row_hide_destroy (WidgetsAttachmentRow* self);
static gboolean __lambda41_ (WidgetsAttachmentRow* self);
static gboolean ___lambda41__gsource_func (gpointer self);
static void widgets_attachment_row_set_attachment (WidgetsAttachmentRow* self,
                                            ObjectsAttachment* value);
static GObject * widgets_attachment_row_constructor (GType type,
                                              guint n_construct_properties,
                                              GObjectConstructParam * construct_properties);
static Block54Data* block54_data_ref (Block54Data* _data54_);
static void block54_data_unref (void * _userdata_);
static gboolean _widgets_attachment_row___lambda42_ (WidgetsAttachmentRow* self);
static gboolean __widgets_attachment_row___lambda42__gsource_func (gpointer self);
static void _widgets_attachment_row___lambda43_ (WidgetsAttachmentRow* self);
static void __widgets_attachment_row___lambda43__gtk_gesture_click_pressed (GtkGestureClick* _sender,
                                                                     gint n_press,
                                                                     gdouble x,
                                                                     gdouble y,
                                                                     gpointer self);
static void _widgets_attachment_row___lambda44_ (WidgetsAttachmentRow* self);
static void __widgets_attachment_row___lambda44__gtk_list_box_row_activate (GtkListBoxRow* _sender,
                                                                     gpointer self);
static void _widgets_attachment_row___lambda45_ (Block54Data* _data54_);
static void __widgets_attachment_row___lambda45__gtk_gesture_click_pressed (GtkGestureClick* _sender,
                                                                     gint n_press,
                                                                     gdouble x,
                                                                     gdouble y,
                                                                     gpointer self);
static void widgets_attachment_row_finalize (GObject * obj);
static GType widgets_attachment_row_get_type_once (void);
static void _vala_widgets_attachment_row_get_property (GObject * object,
                                                guint property_id,
                                                GValue * value,
                                                GParamSpec * pspec);
static void _vala_widgets_attachment_row_set_property (GObject * object,
                                                guint property_id,
                                                const GValue * value,
                                                GParamSpec * pspec);
static void _vala_array_destroy (gpointer array,
                          gssize array_length,
                          GDestroyNotify destroy_func);
static void _vala_array_free (gpointer array,
                       gssize array_length,
                       GDestroyNotify destroy_func);

static inline gpointer
widgets_attachment_row_get_instance_private (WidgetsAttachmentRow* self)
{
	return G_STRUCT_MEMBER_P (self, WidgetsAttachmentRow_private_offset);
}

WidgetsAttachmentRow*
widgets_attachment_row_construct (GType object_type,
                                  ObjectsAttachment* attachment)
{
	WidgetsAttachmentRow * self = NULL;
	g_return_val_if_fail (attachment != NULL, NULL);
	self = (WidgetsAttachmentRow*) g_object_new (object_type, "attachment", attachment, NULL);
	return self;
}

WidgetsAttachmentRow*
widgets_attachment_row_new (ObjectsAttachment* attachment)
{
	return widgets_attachment_row_construct (WIDGETS_TYPE_ATTACHMENT_ROW, attachment);
}

static gchar*
string_strip (const gchar* self)
{
	gchar* _result_ = NULL;
	gchar* _tmp0_;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = g_strdup (self);
	_result_ = _tmp0_;
	g_strstrip (_result_);
	result = _result_;
	return result;
}

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

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

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

static void
widgets_attachment_row_open_file (WidgetsAttachmentRow* self)
{
	WidgetsLoadingButton* _tmp0_;
	GError* _inner_error0_ = NULL;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->close_button;
	widgets_loading_button_set_is_loading (_tmp0_, TRUE);
	{
		gboolean _tmp1_ = FALSE;
		ObjectsAttachment* _tmp2_;
		const gchar* _tmp3_;
		const gchar* _tmp4_;
		GFile* file = NULL;
		ObjectsAttachment* _tmp11_;
		const gchar* _tmp12_;
		const gchar* _tmp13_;
		GFile* _tmp14_;
		GFile* _tmp15_;
		GAppInfo* app_info = NULL;
		GAppInfo* _tmp17_;
		GAppInfo* _tmp18_;
		GAppInfo* _tmp26_;
		WidgetsLoadingButton* _tmp34_;
		_tmp2_ = self->priv->_attachment;
		_tmp3_ = objects_attachment_get_file_path (_tmp2_);
		_tmp4_ = _tmp3_;
		if (_tmp4_ == NULL) {
			_tmp1_ = TRUE;
		} else {
			ObjectsAttachment* _tmp5_;
			const gchar* _tmp6_;
			const gchar* _tmp7_;
			gchar* _tmp8_;
			gchar* _tmp9_;
			_tmp5_ = self->priv->_attachment;
			_tmp6_ = objects_attachment_get_file_path (_tmp5_);
			_tmp7_ = _tmp6_;
			_tmp8_ = string_strip (_tmp7_);
			_tmp9_ = _tmp8_;
			_tmp1_ = g_strcmp0 (_tmp9_, "") == 0;
			_g_free0 (_tmp9_);
		}
		if (_tmp1_) {
			GError* _tmp10_;
			_tmp10_ = g_error_new_literal (G_IO_ERROR, G_IO_ERROR_INVALID_ARGUMENT, "File path is empty");
			_inner_error0_ = _tmp10_;
			goto __catch0_g_error;
		}
		_tmp11_ = self->priv->_attachment;
		_tmp12_ = objects_attachment_get_file_path (_tmp11_);
		_tmp13_ = _tmp12_;
		_tmp14_ = g_file_new_for_uri (_tmp13_);
		file = _tmp14_;
		_tmp15_ = file;
		if (!g_file_query_exists (_tmp15_, NULL)) {
			GError* _tmp16_;
			_tmp16_ = g_error_new_literal (G_IO_ERROR, G_IO_ERROR_NOT_FOUND, "File no longer exists");
			_inner_error0_ = _tmp16_;
			_g_object_unref0 (file);
			goto __catch0_g_error;
		}
		_tmp17_ = g_app_info_get_default_for_uri_scheme ("file");
		app_info = _tmp17_;
		_tmp18_ = app_info;
		if (_tmp18_ == NULL) {
			GFileInfo* file_info = NULL;
			GFile* _tmp19_;
			GFileInfo* _tmp20_;
			gchar* content_type = NULL;
			GFileInfo* _tmp21_;
			const gchar* _tmp22_;
			gchar* _tmp23_;
			const gchar* _tmp24_;
			GAppInfo* _tmp25_;
			_tmp19_ = file;
			_tmp20_ = g_file_query_info (_tmp19_, G_FILE_ATTRIBUTE_STANDARD_CONTENT_TYPE, G_FILE_QUERY_INFO_NONE, NULL, &_inner_error0_);
			file_info = _tmp20_;
			if (G_UNLIKELY (_inner_error0_ != NULL)) {
				_g_object_unref0 (app_info);
				_g_object_unref0 (file);
				goto __catch0_g_error;
			}
			_tmp21_ = file_info;
			_tmp22_ = g_file_info_get_content_type (_tmp21_);
			_tmp23_ = g_strdup (_tmp22_);
			content_type = _tmp23_;
			_tmp24_ = content_type;
			_tmp25_ = g_app_info_get_default_for_type (_tmp24_, FALSE);
			_g_object_unref0 (app_info);
			app_info = _tmp25_;
			_g_free0 (content_type);
			_g_object_unref0 (file_info);
		}
		_tmp26_ = app_info;
		if (_tmp26_ != NULL) {
			GList* file_list = NULL;
			GFile* _tmp27_;
			GFile* _tmp28_;
			GAppInfo* _tmp29_;
			GList* _tmp30_;
			file_list = NULL;
			_tmp27_ = file;
			_tmp28_ = _g_object_ref0 (_tmp27_);
			file_list = g_list_append (file_list, _tmp28_);
			_tmp29_ = app_info;
			_tmp30_ = file_list;
			g_app_info_launch (_tmp29_, _tmp30_, NULL, &_inner_error0_);
			if (G_UNLIKELY (_inner_error0_ != NULL)) {
				(file_list == NULL) ? NULL : (file_list = (_g_list_free__g_object_unref0_ (file_list), NULL));
				_g_object_unref0 (app_info);
				_g_object_unref0 (file);
				goto __catch0_g_error;
			}
			(file_list == NULL) ? NULL : (file_list = (_g_list_free__g_object_unref0_ (file_list), NULL));
		} else {
			ObjectsAttachment* _tmp31_;
			const gchar* _tmp32_;
			const gchar* _tmp33_;
			_tmp31_ = self->priv->_attachment;
			_tmp32_ = objects_attachment_get_file_path (_tmp31_);
			_tmp33_ = _tmp32_;
			g_app_info_launch_default_for_uri (_tmp33_, NULL, &_inner_error0_);
			if (G_UNLIKELY (_inner_error0_ != NULL)) {
				_g_object_unref0 (app_info);
				_g_object_unref0 (file);
				goto __catch0_g_error;
			}
		}
		_tmp34_ = self->priv->close_button;
		widgets_loading_button_set_is_loading (_tmp34_, FALSE);
		_g_object_unref0 (app_info);
		_g_object_unref0 (file);
	}
	goto __finally0;
	__catch0_g_error:
	{
		GError* e = NULL;
		WidgetsLoadingButton* _tmp35_;
		ServicesEventBus* _tmp36_;
		ServicesEventBus* _tmp37_;
		Util* _tmp38_;
		Util* _tmp39_;
		GError* _tmp40_;
		const gchar* _tmp41_;
		gchar* _tmp42_;
		gchar* _tmp43_;
		AdwToast* _tmp44_;
		AdwToast* _tmp45_;
		e = _inner_error0_;
		_inner_error0_ = NULL;
		_tmp35_ = self->priv->close_button;
		widgets_loading_button_set_is_loading (_tmp35_, FALSE);
		_tmp36_ = services_event_bus_get_default ();
		_tmp37_ = _tmp36_;
		_tmp38_ = util_get_default ();
		_tmp39_ = _tmp38_;
		_tmp40_ = e;
		_tmp41_ = _tmp40_->message;
		_tmp42_ = g_strconcat ("Error opening file: ", _tmp41_, NULL);
		_tmp43_ = _tmp42_;
		_tmp44_ = util_create_toast (_tmp39_, _tmp43_, (guint) 2, ADW_TOAST_PRIORITY_NORMAL);
		_tmp45_ = _tmp44_;
		g_signal_emit_by_name (_tmp37_, "send-toast", _tmp45_);
		_g_object_unref0 (_tmp45_);
		_g_free0 (_tmp43_);
		_g_object_unref0 (_tmp39_);
		_g_object_unref0 (_tmp37_);
		_g_error_free0 (e);
	}
	__finally0:
	if (G_UNLIKELY (_inner_error0_ != 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;
	}
}

static gboolean
__lambda41_ (WidgetsAttachmentRow* self)
{
	GtkWidget* _tmp0_;
	GtkWidget* _tmp1_;
	gboolean result;
	_tmp0_ = gtk_widget_get_parent ((GtkWidget*) self);
	_tmp1_ = _tmp0_;
	gtk_list_box_remove (G_TYPE_CHECK_INSTANCE_CAST (_tmp1_, gtk_list_box_get_type (), GtkListBox), (GtkWidget*) self);
	result = G_SOURCE_REMOVE;
	return result;
}

static gboolean
___lambda41__gsource_func (gpointer self)
{
	gboolean result;
	result = __lambda41_ ((WidgetsAttachmentRow*) self);
	return result;
}

void
widgets_attachment_row_hide_destroy (WidgetsAttachmentRow* self)
{
	GtkRevealer* _tmp0_;
	GtkRevealer* _tmp1_;
	guint _tmp2_;
	guint _tmp3_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->main_revealer;
	gtk_revealer_set_reveal_child (_tmp0_, FALSE);
	_tmp1_ = self->priv->main_revealer;
	_tmp2_ = gtk_revealer_get_transition_duration (_tmp1_);
	_tmp3_ = _tmp2_;
	g_timeout_add_full (G_PRIORITY_DEFAULT, _tmp3_, ___lambda41__gsource_func, g_object_ref (self), g_object_unref);
}

ObjectsAttachment*
widgets_attachment_row_get_attachment (WidgetsAttachmentRow* self)
{
	ObjectsAttachment* result;
	ObjectsAttachment* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_attachment;
	result = _tmp0_;
	return result;
}

static void
widgets_attachment_row_set_attachment (WidgetsAttachmentRow* self,
                                       ObjectsAttachment* value)
{
	ObjectsAttachment* old_value;
	g_return_if_fail (self != NULL);
	old_value = widgets_attachment_row_get_attachment (self);
	if (old_value != value) {
		ObjectsAttachment* _tmp0_;
		_tmp0_ = _g_object_ref0 (value);
		_g_object_unref0 (self->priv->_attachment);
		self->priv->_attachment = _tmp0_;
		g_object_notify_by_pspec ((GObject *) self, widgets_attachment_row_properties[WIDGETS_ATTACHMENT_ROW_ATTACHMENT_PROPERTY]);
	}
}

static Block54Data*
block54_data_ref (Block54Data* _data54_)
{
	g_atomic_int_inc (&_data54_->_ref_count_);
	return _data54_;
}

static void
block54_data_unref (void * _userdata_)
{
	Block54Data* _data54_;
	_data54_ = (Block54Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data54_->_ref_count_)) {
		WidgetsAttachmentRow* self;
		self = _data54_->self;
		_g_object_unref0 (_data54_->remove_gesture);
		_g_object_unref0 (self);
		g_slice_free (Block54Data, _data54_);
	}
}

static gboolean
_widgets_attachment_row___lambda42_ (WidgetsAttachmentRow* self)
{
	GtkRevealer* _tmp0_;
	gboolean result;
	_tmp0_ = self->priv->main_revealer;
	gtk_revealer_set_reveal_child (_tmp0_, TRUE);
	result = G_SOURCE_REMOVE;
	return result;
}

static gboolean
__widgets_attachment_row___lambda42__gsource_func (gpointer self)
{
	gboolean result;
	result = _widgets_attachment_row___lambda42_ ((WidgetsAttachmentRow*) self);
	return result;
}

static void
_widgets_attachment_row___lambda43_ (WidgetsAttachmentRow* self)
{
	widgets_attachment_row_open_file (self);
}

static void
__widgets_attachment_row___lambda43__gtk_gesture_click_pressed (GtkGestureClick* _sender,
                                                                gint n_press,
                                                                gdouble x,
                                                                gdouble y,
                                                                gpointer self)
{
	_widgets_attachment_row___lambda43_ ((WidgetsAttachmentRow*) self);
}

static void
_widgets_attachment_row___lambda44_ (WidgetsAttachmentRow* self)
{
	widgets_attachment_row_open_file (self);
}

static void
__widgets_attachment_row___lambda44__gtk_list_box_row_activate (GtkListBoxRow* _sender,
                                                                gpointer self)
{
	_widgets_attachment_row___lambda44_ ((WidgetsAttachmentRow*) self);
}

static void
_widgets_attachment_row___lambda45_ (Block54Data* _data54_)
{
	WidgetsAttachmentRow* self;
	GtkGestureClick* _tmp0_;
	ObjectsAttachment* _tmp1_;
	self = _data54_->self;
	_tmp0_ = _data54_->remove_gesture;
	gtk_gesture_set_state ((GtkGesture*) _tmp0_, GTK_EVENT_SEQUENCE_CLAIMED);
	_tmp1_ = self->priv->_attachment;
	objects_attachment_delete (_tmp1_);
}

static void
__widgets_attachment_row___lambda45__gtk_gesture_click_pressed (GtkGestureClick* _sender,
                                                                gint n_press,
                                                                gdouble x,
                                                                gdouble y,
                                                                gpointer self)
{
	_widgets_attachment_row___lambda45_ (self);
}

static GObject *
widgets_attachment_row_constructor (GType type,
                                    guint n_construct_properties,
                                    GObjectConstructParam * construct_properties)
{
	GObject * obj;
	GObjectClass * parent_class;
	WidgetsAttachmentRow * self;
	Block54Data* _data54_;
	GtkLabel* name_label = NULL;
	ObjectsAttachment* _tmp0_;
	const gchar* _tmp1_;
	const gchar* _tmp2_;
	GtkLabel* _tmp3_;
	GtkLabel* _tmp4_;
	GtkLabel* _tmp5_;
	gchar* _tmp6_;
	gchar** _tmp7_;
	gchar* _tmp8_;
	WidgetsLoadingButton* _tmp9_ = NULL;
	GtkBox* content_box = NULL;
	GtkBox* _tmp10_ = NULL;
	GtkBox* _tmp11_;
	GtkImage* _tmp12_;
	GtkImage* _tmp13_;
	GtkBox* _tmp14_;
	GtkLabel* _tmp15_;
	GtkBox* _tmp16_;
	WidgetsLoadingButton* _tmp17_;
	GtkBox* _tmp18_;
	GtkWidget* _tmp19_;
	GtkRevealer* _tmp20_ = NULL;
	GtkRevealer* _tmp21_;
	GtkRevealer* _tmp22_;
	guint _tmp23_;
	guint _tmp24_;
	GtkGestureClick* gesture = NULL;
	GtkGestureClick* _tmp25_;
	GtkGestureClick* _tmp26_;
	GtkEventController* _tmp27_;
	GtkGestureClick* _tmp28_;
	GtkGestureClick* _tmp29_;
	WidgetsLoadingButton* _tmp30_;
	GtkGestureClick* _tmp31_;
	GtkEventController* _tmp32_;
	GtkGestureClick* _tmp33_;
	parent_class = G_OBJECT_CLASS (widgets_attachment_row_parent_class);
	obj = parent_class->constructor (type, n_construct_properties, construct_properties);
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, WIDGETS_TYPE_ATTACHMENT_ROW, WidgetsAttachmentRow);
	_data54_ = g_slice_new0 (Block54Data);
	_data54_->_ref_count_ = 1;
	_data54_->self = g_object_ref (self);
	gtk_widget_add_css_class ((GtkWidget*) self, "row");
	gtk_widget_add_css_class ((GtkWidget*) self, "transition");
	gtk_widget_add_css_class ((GtkWidget*) self, "no-padding");
	_tmp0_ = self->priv->_attachment;
	_tmp1_ = objects_attachment_get_file_name (_tmp0_);
	_tmp2_ = _tmp1_;
	_tmp3_ = (GtkLabel*) gtk_label_new (_tmp2_);
	g_object_ref_sink (_tmp3_);
	name_label = _tmp3_;
	_tmp4_ = name_label;
	gtk_widget_set_valign ((GtkWidget*) _tmp4_, GTK_ALIGN_CENTER);
	_tmp5_ = name_label;
	gtk_label_set_ellipsize (_tmp5_, PANGO_ELLIPSIZE_END);
	_tmp6_ = g_strdup ("flat");
	_tmp7_ = g_new0 (gchar*, 1 + 1);
	_tmp7_[0] = _tmp6_;
	_tmp8_ = g_strdup (_ ("Delete"));
	_tmp9_ = widgets_loading_button_new_with_icon ("cross-large-circle-filled-symbolic", 16);
	gtk_widget_set_valign ((GtkWidget*) _tmp9_, GTK_ALIGN_CENTER);
	gtk_widget_set_halign ((GtkWidget*) _tmp9_, GTK_ALIGN_END);
	gtk_widget_set_hexpand ((GtkWidget*) _tmp9_, TRUE);
	gtk_widget_set_css_classes ((GtkWidget*) _tmp9_, _tmp7_);
	_tmp7_ = (_vala_array_free (_tmp7_, 1, (GDestroyNotify) g_free), NULL);
	gtk_widget_set_tooltip_text ((GtkWidget*) _tmp9_, _tmp8_);
	_g_free0 (_tmp8_);
	g_object_ref_sink (_tmp9_);
	_g_object_unref0 (self->priv->close_button);
	self->priv->close_button = _tmp9_;
	_tmp10_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
	gtk_widget_set_margin_top ((GtkWidget*) _tmp10_, 3);
	gtk_widget_set_margin_start ((GtkWidget*) _tmp10_, 6);
	gtk_widget_set_margin_bottom ((GtkWidget*) _tmp10_, 3);
	gtk_widget_set_margin_end ((GtkWidget*) _tmp10_, 6);
	g_object_ref_sink (_tmp10_);
	content_box = _tmp10_;
	_tmp11_ = content_box;
	_tmp12_ = (GtkImage*) gtk_image_new_from_icon_name ("paper-symbolic");
	g_object_ref_sink (_tmp12_);
	_tmp13_ = _tmp12_;
	gtk_box_append (_tmp11_, (GtkWidget*) _tmp13_);
	_g_object_unref0 (_tmp13_);
	_tmp14_ = content_box;
	_tmp15_ = name_label;
	gtk_box_append (_tmp14_, (GtkWidget*) _tmp15_);
	_tmp16_ = content_box;
	_tmp17_ = self->priv->close_button;
	gtk_box_append (_tmp16_, (GtkWidget*) _tmp17_);
	_tmp18_ = content_box;
	_tmp19_ = _g_object_ref0 ((GtkWidget*) _tmp18_);
	_tmp20_ = (GtkRevealer*) gtk_revealer_new ();
	gtk_revealer_set_transition_type (_tmp20_, GTK_REVEALER_TRANSITION_TYPE_SLIDE_DOWN);
	gtk_revealer_set_child (_tmp20_, _tmp19_);
	_g_object_unref0 (_tmp19_);
	g_object_ref_sink (_tmp20_);
	_g_object_unref0 (self->priv->main_revealer);
	self->priv->main_revealer = _tmp20_;
	_tmp21_ = self->priv->main_revealer;
	gtk_list_box_row_set_child ((GtkListBoxRow*) self, (GtkWidget*) _tmp21_);
	_tmp22_ = self->priv->main_revealer;
	_tmp23_ = gtk_revealer_get_transition_duration (_tmp22_);
	_tmp24_ = _tmp23_;
	g_timeout_add_full (G_PRIORITY_DEFAULT, _tmp24_, __widgets_attachment_row___lambda42__gsource_func, g_object_ref (self), g_object_unref);
	_tmp25_ = (GtkGestureClick*) gtk_gesture_click_new ();
	gesture = _tmp25_;
	_tmp26_ = gesture;
	_tmp27_ = _g_object_ref0 ((GtkEventController*) _tmp26_);
	gtk_widget_add_controller ((GtkWidget*) self, _tmp27_);
	_tmp28_ = gesture;
	g_signal_connect_object (_tmp28_, "pressed", (GCallback) __widgets_attachment_row___lambda43__gtk_gesture_click_pressed, self, 0);
	g_signal_connect_object ((GtkListBoxRow*) self, "activate", (GCallback) __widgets_attachment_row___lambda44__gtk_list_box_row_activate, self, 0);
	_tmp29_ = (GtkGestureClick*) gtk_gesture_click_new ();
	_data54_->remove_gesture = _tmp29_;
	_tmp30_ = self->priv->close_button;
	_tmp31_ = _data54_->remove_gesture;
	_tmp32_ = _g_object_ref0 ((GtkEventController*) _tmp31_);
	gtk_widget_add_controller ((GtkWidget*) _tmp30_, _tmp32_);
	_tmp33_ = _data54_->remove_gesture;
	g_signal_connect_data (_tmp33_, "pressed", (GCallback) __widgets_attachment_row___lambda45__gtk_gesture_click_pressed, block54_data_ref (_data54_), (GClosureNotify) block54_data_unref, 0);
	_g_object_unref0 (gesture);
	_g_object_unref0 (content_box);
	_g_object_unref0 (name_label);
	block54_data_unref (_data54_);
	_data54_ = NULL;
	return obj;
}

static void
widgets_attachment_row_class_init (WidgetsAttachmentRowClass * klass,
                                   gpointer klass_data)
{
	widgets_attachment_row_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &WidgetsAttachmentRow_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_widgets_attachment_row_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_widgets_attachment_row_set_property;
	G_OBJECT_CLASS (klass)->constructor = widgets_attachment_row_constructor;
	G_OBJECT_CLASS (klass)->finalize = widgets_attachment_row_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), WIDGETS_ATTACHMENT_ROW_ATTACHMENT_PROPERTY, widgets_attachment_row_properties[WIDGETS_ATTACHMENT_ROW_ATTACHMENT_PROPERTY] = g_param_spec_object ("attachment", "attachment", "attachment", OBJECTS_TYPE_ATTACHMENT, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE | G_PARAM_CONSTRUCT_ONLY));
}

static void
widgets_attachment_row_instance_init (WidgetsAttachmentRow * self,
                                      gpointer klass)
{
	self->priv = widgets_attachment_row_get_instance_private (self);
}

static void
widgets_attachment_row_finalize (GObject * obj)
{
	WidgetsAttachmentRow * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, WIDGETS_TYPE_ATTACHMENT_ROW, WidgetsAttachmentRow);
	g_debug ("AttachmentRow.vala:35: Destroying - Widgets.AttachmentRow\n");
	_g_object_unref0 (self->priv->_attachment);
	_g_object_unref0 (self->priv->main_revealer);
	_g_object_unref0 (self->priv->close_button);
	G_OBJECT_CLASS (widgets_attachment_row_parent_class)->finalize (obj);
}

static GType
widgets_attachment_row_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (WidgetsAttachmentRowClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) widgets_attachment_row_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (WidgetsAttachmentRow), 0, (GInstanceInitFunc) widgets_attachment_row_instance_init, NULL };
	GType widgets_attachment_row_type_id;
	widgets_attachment_row_type_id = g_type_register_static (gtk_list_box_row_get_type (), "WidgetsAttachmentRow", &g_define_type_info, 0);
	WidgetsAttachmentRow_private_offset = g_type_add_instance_private (widgets_attachment_row_type_id, sizeof (WidgetsAttachmentRowPrivate));
	return widgets_attachment_row_type_id;
}

GType
widgets_attachment_row_get_type (void)
{
	static volatile gsize widgets_attachment_row_type_id__once = 0;
	if (g_once_init_enter (&widgets_attachment_row_type_id__once)) {
		GType widgets_attachment_row_type_id;
		widgets_attachment_row_type_id = widgets_attachment_row_get_type_once ();
		g_once_init_leave (&widgets_attachment_row_type_id__once, widgets_attachment_row_type_id);
	}
	return widgets_attachment_row_type_id__once;
}

static void
_vala_widgets_attachment_row_get_property (GObject * object,
                                           guint property_id,
                                           GValue * value,
                                           GParamSpec * pspec)
{
	WidgetsAttachmentRow * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, WIDGETS_TYPE_ATTACHMENT_ROW, WidgetsAttachmentRow);
	switch (property_id) {
		case WIDGETS_ATTACHMENT_ROW_ATTACHMENT_PROPERTY:
		g_value_set_object (value, widgets_attachment_row_get_attachment (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_widgets_attachment_row_set_property (GObject * object,
                                           guint property_id,
                                           const GValue * value,
                                           GParamSpec * pspec)
{
	WidgetsAttachmentRow * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, WIDGETS_TYPE_ATTACHMENT_ROW, WidgetsAttachmentRow);
	switch (property_id) {
		case WIDGETS_ATTACHMENT_ROW_ATTACHMENT_PROPERTY:
		widgets_attachment_row_set_attachment (self, g_value_get_object (value));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

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

