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

#include <gtk/gtk.h>
#include <glib-object.h>
#include <glib.h>
#include <stdlib.h>
#include <string.h>
#include <float.h>
#include <math.h>
#include <pango/pango.h>
#include <gdk/gdk.h>
#include <gdk-pixbuf/gdk-pixbuf.h>
#include <gio/gio.h>
#include <glib/gstdio.h>

#define DC_COMPOSE_BAR_EMOJI_TRIGGER_START_MARK "parla-emoji-trigger-start"
#define DC_COMPOSE_BAR_EMOJI_TRIGGER_END_MARK "parla-emoji-trigger-end"
#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 DC_TYPE_COMPOSE_BAR (dc_compose_bar_get_type ())
#define DC_COMPOSE_BAR(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), DC_TYPE_COMPOSE_BAR, DcComposeBar))
#define DC_COMPOSE_BAR_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), DC_TYPE_COMPOSE_BAR, DcComposeBarClass))
#define DC_IS_COMPOSE_BAR(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), DC_TYPE_COMPOSE_BAR))
#define DC_IS_COMPOSE_BAR_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), DC_TYPE_COMPOSE_BAR))
#define DC_COMPOSE_BAR_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), DC_TYPE_COMPOSE_BAR, DcComposeBarClass))

typedef struct _DcComposeBar DcComposeBar;
typedef struct _DcComposeBarClass DcComposeBarClass;
typedef struct _DcComposeBarPrivate DcComposeBarPrivate;
enum  {
	DC_COMPOSE_BAR_0_PROPERTY,
	DC_COMPOSE_BAR_SHIFT_ENTER_SENDS_PROPERTY,
	DC_COMPOSE_BAR_NUM_PROPERTIES
};
static GParamSpec* dc_compose_bar_properties[DC_COMPOSE_BAR_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_string_free0(var) ((var == NULL) ? NULL : (var = (g_string_free (var, TRUE), NULL)))
typedef struct _Block21Data Block21Data;
#define _gdk_content_formats_unref0(var) ((var == NULL) ? NULL : (var = (gdk_content_formats_unref (var), NULL)))
#define __vala_GdkFileList_free0(var) ((var == NULL) ? NULL : (var = (_vala_GdkFileList_free (var), NULL)))
#define __vala_GValue_free0(var) ((var == NULL) ? NULL : (var = (_vala_GValue_free (var), NULL)))
typedef struct _DcComposeBarPasteFromClipboardData DcComposeBarPasteFromClipboardData;
enum  {
	DC_COMPOSE_BAR_SEND_MESSAGE_SIGNAL,
	DC_COMPOSE_BAR_EDIT_MESSAGE_SIGNAL,
	DC_COMPOSE_BAR_EDIT_LAST_REQUESTED_SIGNAL,
	DC_COMPOSE_BAR_NUM_SIGNALS
};
static guint dc_compose_bar_signals[DC_COMPOSE_BAR_NUM_SIGNALS] = {0};

struct _DcComposeBar {
	GtkBox parent_instance;
	DcComposeBarPrivate * priv;
};

struct _DcComposeBarClass {
	GtkBoxClass parent_class;
};

struct _DcComposeBarPrivate {
	gboolean _shift_enter_sends;
	GtkTextView* text_view;
	GtkLabel* placeholder_label;
	gchar* placeholder_default;
	GtkButton* send_button;
	GtkButton* attach_button;
	GtkMenuButton* emoji_button;
	GtkButton* cancel_attach_button;
	GtkButton* cancel_edit_button;
	GtkButton* cancel_reply_button;
	GtkLabel* reply_label;
	GtkBox* reply_bar;
	GtkBox* attachment_bar;
	GtkPicture* attachment_picture;
	GtkImage* attachment_icon;
	GtkLabel* attachment_name_label;
	GtkLabel* attachment_meta_label;
	GtkButton* attachment_close_button;
	gchar* pending_file;
	gchar* pending_file_name;
	gboolean pending_file_is_temp;
	gint editing_msg_id;
	gint replying_msg_id;
};

struct _Block21Data {
	int _ref_count_;
	DcComposeBar* self;
	GtkFileDialog* dialog;
};

struct _DcComposeBarPasteFromClipboardData {
	int _state_;
	GObject* _source_object_;
	GAsyncResult* _res_;
	GTask* _async_result;
	DcComposeBar* self;
	GdkClipboard* clipboard;
	gboolean try_files;
	gboolean try_texture;
	GValue* value;
	GValue* _tmp0_;
	GdkFileList* _tmp1_;
	GValue* _tmp2_;
	GValue* _tmp3_;
	void* _tmp4_;
	GdkFileList* fl;
	GdkFileList* _tmp5_;
	GFile* _tmp6_;
	gboolean _tmp7_;
	GdkFileList* _tmp8_;
	GdkFileList* _tmp9_;
	GSList* _tmp10_;
	GSList* _tmp11_;
	GdkFileList* _tmp12_;
	GSList* _tmp13_;
	GSList* _tmp14_;
	gconstpointer _tmp15_;
	GFile* gf;
	GFile* _tmp16_;
	gchar* _tmp17_;
	GFile* _tmp18_;
	GFile* _tmp19_;
	gchar* _tmp20_;
	gchar* path;
	gchar* _tmp21_;
	gboolean _tmp22_;
	const gchar* _tmp23_;
	const gchar* _tmp24_;
	const gchar* _tmp25_;
	GFile* _tmp26_;
	gchar* _tmp27_;
	gchar* _tmp28_;
	GdkTexture* texture;
	GdkTexture* _tmp29_;
	GdkTexture* _tmp30_;
	GFileIOStream* stream;
	GFile* tmp;
	GFileIOStream* _tmp31_;
	GFile* _tmp32_;
	GFileIOStream* _tmp33_;
	GdkTexture* _tmp34_;
	GFile* _tmp35_;
	gchar* _tmp36_;
	gchar* _tmp37_;
	gboolean _tmp38_;
	GFile* _tmp39_;
	gchar* _tmp40_;
	gchar* _tmp41_;
	GError* _inner_error0_;
};

static gint DcComposeBar_private_offset;
static gpointer dc_compose_bar_parent_class = NULL;

VALA_EXTERN GType dc_compose_bar_get_type (void) G_GNUC_CONST ;
G_DEFINE_AUTOPTR_CLEANUP_FUNC (DcComposeBar, g_object_unref)
VALA_EXTERN DcComposeBar* dc_compose_bar_new (void);
VALA_EXTERN DcComposeBar* dc_compose_bar_construct (GType object_type);
static void dc_compose_bar_cancel_reply (DcComposeBar* self);
static void _dc_compose_bar_cancel_reply_gtk_button_clicked (GtkButton* _sender,
                                                      gpointer self);
static void dc_compose_bar_clear_attachment (DcComposeBar* self);
static void _dc_compose_bar_clear_attachment_gtk_button_clicked (GtkButton* _sender,
                                                          gpointer self);
static void dc_compose_bar_on_attach_clicked (DcComposeBar* self);
static void _dc_compose_bar_on_attach_clicked_gtk_button_clicked (GtkButton* _sender,
                                                           gpointer self);
VALA_EXTERN GtkEmojiChooser* dc_create_emoji_chooser (void);
static void dc_compose_bar_on_emoji_picked (DcComposeBar* self,
                                     const gchar* emoji);
static void _dc_compose_bar_on_emoji_picked_gtk_emoji_chooser_emoji_picked (GtkEmojiChooser* _sender,
                                                                     const gchar* text,
                                                                     gpointer self);
static void ___lambda23_ (DcComposeBar* self);
static gboolean __lambda24_ (DcComposeBar* self);
static void dc_compose_bar_clear_emoji_trigger_marks (DcComposeBar* self);
static gboolean ___lambda24__gsource_func (gpointer self);
static void ____lambda23__gtk_popover_closed (GtkPopover* _sender,
                                       gpointer self);
static void dc_compose_bar_cancel_edit (DcComposeBar* self);
static void _dc_compose_bar_cancel_edit_gtk_button_clicked (GtkButton* _sender,
                                                     gpointer self);
static void dc_compose_bar_update_placeholder (DcComposeBar* self);
static void _dc_compose_bar_update_placeholder_gtk_text_buffer_changed (GtkTextBuffer* _sender,
                                                                 gpointer self);
static void __lambda25_ (DcComposeBar* self);
static gboolean __lambda26_ (DcComposeBar* self);
static gboolean ___lambda26__gsource_func (gpointer self);
static void ___lambda25__g_object_notify (GObject* _sender,
                                   GParamSpec* pspec,
                                   gpointer self);
static gboolean dc_compose_bar_on_entry_key_pressed (DcComposeBar* self,
                                              guint keyval,
                                              guint keycode,
                                              GdkModifierType state);
static gboolean _dc_compose_bar_on_entry_key_pressed_gtk_event_controller_key_key_pressed (GtkEventControllerKey* _sender,
                                                                                    guint keyval,
                                                                                    guint keycode,
                                                                                    GdkModifierType state,
                                                                                    gpointer self);
static void dc_compose_bar_on_send (DcComposeBar* self);
static void _dc_compose_bar_on_send_gtk_button_clicked (GtkButton* _sender,
                                                 gpointer self);
VALA_EXTERN void dc_compose_bar_grab_entry_focus (DcComposeBar* self);
static gboolean __lambda28_ (DcComposeBar* self);
static gboolean ___lambda28__gsource_func (gpointer self);
VALA_EXTERN void dc_compose_bar_type_text (DcComposeBar* self,
                               const gchar* text);
static gboolean dc_compose_bar_previous_char_is_colon (DcComposeBar* self);
static void dc_compose_bar_open_emoji_picker_after_typed_colon (DcComposeBar* self);
VALA_EXTERN void dc_compose_bar_clear (DcComposeBar* self);
static gchar* dc_compose_bar_get_text (DcComposeBar* self);
static void dc_compose_bar_set_placeholder (DcComposeBar* self,
                                     const gchar* s);
VALA_EXTERN gboolean dc_compose_bar_can_accept_attachment (DcComposeBar* self);
VALA_EXTERN void dc_compose_bar_set_pending_attachment (DcComposeBar* self,
                                            const gchar* file_path,
                                            const gchar* file_name);
static void dc_compose_bar_populate_attachment_preview (DcComposeBar* self,
                                                 const gchar* file_path,
                                                 const gchar* file_name);
static gchar* dc_compose_bar_guess_mime (const gchar* file_path);
static gchar* dc_compose_bar_mime_icon_name (const gchar* mime,
                                      const gchar* file_path);
static gchar* dc_compose_bar_format_size (gint64 bytes);
static gint64 dc_compose_bar_file_size_or_zero (const gchar* file_path);
VALA_EXTERN void dc_compose_bar_begin_reply (DcComposeBar* self,
                                 gint msg_id,
                                 const gchar* sender_name,
                                 const gchar* preview);
static gchar* dc_compose_bar_shorten_preview (const gchar* text);
VALA_EXTERN void dc_compose_bar_begin_edit (DcComposeBar* self,
                                gint msg_id,
                                const gchar* current_text);
static gboolean __lambda29_ (DcComposeBar* self);
static gboolean ___lambda29__gsource_func (gpointer self);
VALA_EXTERN gboolean dc_compose_bar_has_active_mode (DcComposeBar* self);
VALA_EXTERN gboolean dc_compose_bar_entry_has_focus (DcComposeBar* self);
VALA_EXTERN void dc_compose_bar_cancel_active_mode (DcComposeBar* self);
static gboolean dc_compose_bar_replace_emoji_trigger (DcComposeBar* self,
                                               const gchar* emoji);
static Block21Data* block21_data_ref (Block21Data* _data21_);
static void block21_data_unref (void * _userdata_);
static void __lambda22_ (Block21Data* _data21_,
                  GObject* obj,
                  GAsyncResult* res);
static void ___lambda22__gasync_ready_callback (GObject* source_object,
                                         GAsyncResult* res,
                                         gpointer self);
static gboolean dc_compose_bar_is_plain_colon_key (guint keyval,
                                            GdkModifierType state);
VALA_EXTERN gboolean dc_compose_bar_get_shift_enter_sends (DcComposeBar* self);
VALA_EXTERN gboolean dc_platform_has_primary_modifier (GdkModifierType state);
static void dc_compose_bar_paste_from_clipboard (DcComposeBar* self,
                                          GdkClipboard* clipboard,
                                          gboolean try_files,
                                          gboolean try_texture,
                                          GAsyncReadyCallback _callback_,
                                          gpointer _user_data_);
static void dc_compose_bar_paste_from_clipboard_finish (DcComposeBar* self,
                                                 GAsyncResult* _res_);
static gboolean __lambda27_ (DcComposeBar* self);
static gboolean dc_compose_bar_remember_typed_colon_trigger (DcComposeBar* self);
static gboolean ___lambda27__gsource_func (gpointer self);
static void dc_compose_bar_paste_from_clipboard_data_free (gpointer _data);
static gboolean dc_compose_bar_paste_from_clipboard_co (DcComposeBarPasteFromClipboardData* _data_);
static void dc_compose_bar_paste_from_clipboard_ready (GObject* source_object,
                                                GAsyncResult* _res_,
                                                gpointer _user_data_);
static GValue* _g_value_dup (GValue* self);
static GdkFileList* _vala_GdkFileList_copy (GdkFileList* self);
static void _vala_GdkFileList_free (GdkFileList* self);
static void _vala_GValue_free (GValue* self);
VALA_EXTERN void dc_compose_bar_set_shift_enter_sends (DcComposeBar* self,
                                           gboolean value);
static void g_cclosure_user_marshal_VOID__STRING_STRING_STRING_INT (GClosure * closure,
                                                             GValue * return_value,
                                                             guint n_param_values,
                                                             const GValue * param_values,
                                                             gpointer invocation_hint,
                                                             gpointer marshal_data);
static void g_cclosure_user_marshal_VOID__INT_STRING (GClosure * closure,
                                               GValue * return_value,
                                               guint n_param_values,
                                               const GValue * param_values,
                                               gpointer invocation_hint,
                                               gpointer marshal_data);
static void dc_compose_bar_finalize (GObject * obj);
static GType dc_compose_bar_get_type_once (void);
static void _vala_dc_compose_bar_get_property (GObject * object,
                                        guint property_id,
                                        GValue * value,
                                        GParamSpec * pspec);
static void _vala_dc_compose_bar_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 gssize _vala_array_length (gpointer array);

static inline gpointer
dc_compose_bar_get_instance_private (DcComposeBar* self)
{
	return G_STRUCT_MEMBER_P (self, DcComposeBar_private_offset);
}

static void
_dc_compose_bar_cancel_reply_gtk_button_clicked (GtkButton* _sender,
                                                 gpointer self)
{
	dc_compose_bar_cancel_reply ((DcComposeBar*) self);
}

static void
_dc_compose_bar_clear_attachment_gtk_button_clicked (GtkButton* _sender,
                                                     gpointer self)
{
	dc_compose_bar_clear_attachment ((DcComposeBar*) self);
}

static void
_dc_compose_bar_on_attach_clicked_gtk_button_clicked (GtkButton* _sender,
                                                      gpointer self)
{
	dc_compose_bar_on_attach_clicked ((DcComposeBar*) self);
}

static void
_dc_compose_bar_on_emoji_picked_gtk_emoji_chooser_emoji_picked (GtkEmojiChooser* _sender,
                                                                const gchar* text,
                                                                gpointer self)
{
	dc_compose_bar_on_emoji_picked ((DcComposeBar*) self, text);
}

static gboolean
__lambda24_ (DcComposeBar* self)
{
	gboolean result;
	dc_compose_bar_clear_emoji_trigger_marks (self);
	result = G_SOURCE_REMOVE;
	return result;
}

static gboolean
___lambda24__gsource_func (gpointer self)
{
	gboolean result;
	result = __lambda24_ ((DcComposeBar*) self);
	return result;
}

static void
___lambda23_ (DcComposeBar* self)
{
	g_idle_add_full (G_PRIORITY_DEFAULT_IDLE, ___lambda24__gsource_func, g_object_ref (self), g_object_unref);
}

static void
____lambda23__gtk_popover_closed (GtkPopover* _sender,
                                  gpointer self)
{
	___lambda23_ ((DcComposeBar*) self);
}

static void
_dc_compose_bar_cancel_edit_gtk_button_clicked (GtkButton* _sender,
                                                gpointer self)
{
	dc_compose_bar_cancel_edit ((DcComposeBar*) self);
}

static void
_dc_compose_bar_update_placeholder_gtk_text_buffer_changed (GtkTextBuffer* _sender,
                                                            gpointer self)
{
	dc_compose_bar_update_placeholder ((DcComposeBar*) self);
}

static gboolean
__lambda26_ (DcComposeBar* self)
{
	gint b1 = 0;
	gint b2 = 0;
	gint b3 = 0;
	gint b4 = 0;
	GtkTextView* _tmp0_;
	GtkTextView* _tmp1_;
	gint _tmp2_ = 0;
	gint _tmp3_ = 0;
	gint _tmp4_ = 0;
	gint _tmp5_ = 0;
	GtkTextView* _tmp6_;
	gboolean result;
	_tmp0_ = self->priv->text_view;
	_tmp1_ = self->priv->text_view;
	gtk_widget_measure ((GtkWidget*) _tmp0_, GTK_ORIENTATION_VERTICAL, gtk_widget_get_width ((GtkWidget*) _tmp1_), &_tmp2_, &_tmp3_, &_tmp4_, &_tmp5_);
	b1 = _tmp2_;
	b2 = _tmp3_;
	b3 = _tmp4_;
	b4 = _tmp5_;
	_tmp6_ = self->priv->text_view;
	gtk_widget_queue_resize ((GtkWidget*) _tmp6_);
	result = G_SOURCE_REMOVE;
	return result;
}

static gboolean
___lambda26__gsource_func (gpointer self)
{
	gboolean result;
	result = __lambda26_ ((DcComposeBar*) self);
	return result;
}

static void
__lambda25_ (DcComposeBar* self)
{
	g_idle_add_full (G_PRIORITY_DEFAULT_IDLE, ___lambda26__gsource_func, g_object_ref (self), g_object_unref);
}

static void
___lambda25__g_object_notify (GObject* _sender,
                              GParamSpec* pspec,
                              gpointer self)
{
	__lambda25_ ((DcComposeBar*) self);
}

static gboolean
_dc_compose_bar_on_entry_key_pressed_gtk_event_controller_key_key_pressed (GtkEventControllerKey* _sender,
                                                                           guint keyval,
                                                                           guint keycode,
                                                                           GdkModifierType state,
                                                                           gpointer self)
{
	gboolean result;
	result = dc_compose_bar_on_entry_key_pressed ((DcComposeBar*) self, keyval, keycode, state);
	return result;
}

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

static void
_dc_compose_bar_on_send_gtk_button_clicked (GtkButton* _sender,
                                            gpointer self)
{
	dc_compose_bar_on_send ((DcComposeBar*) self);
}

DcComposeBar*
dc_compose_bar_construct (GType object_type)
{
	DcComposeBar * self = NULL;
	GtkBox* _tmp0_;
	GtkBox* _tmp1_;
	GtkBox* _tmp2_;
	GtkLabel* _tmp3_;
	GtkLabel* _tmp4_;
	GtkLabel* _tmp5_;
	GtkLabel* _tmp6_;
	GtkLabel* _tmp7_;
	GtkLabel* _tmp8_;
	GtkLabel* _tmp9_;
	GtkLabel* _tmp10_;
	GtkLabel* _tmp11_;
	GtkLabel* _tmp12_;
	GtkBox* _tmp13_;
	GtkLabel* _tmp14_;
	GtkButton* _tmp15_;
	GtkButton* _tmp16_;
	GtkButton* _tmp17_;
	GtkButton* _tmp18_;
	GtkButton* _tmp19_;
	GtkButton* _tmp20_;
	GtkBox* _tmp21_;
	GtkButton* _tmp22_;
	GtkBox* _tmp23_;
	GtkBox* _tmp24_;
	GtkBox* _tmp25_;
	GtkBox* _tmp26_;
	GtkPicture* _tmp27_;
	GtkPicture* _tmp28_;
	GtkPicture* _tmp29_;
	GtkPicture* _tmp30_;
	GtkPicture* _tmp31_;
	GtkBox* _tmp32_;
	GtkPicture* _tmp33_;
	GtkImage* _tmp34_;
	GtkImage* _tmp35_;
	GtkImage* _tmp36_;
	GtkImage* _tmp37_;
	GtkBox* _tmp38_;
	GtkImage* _tmp39_;
	GtkBox* attachment_info = NULL;
	GtkBox* _tmp40_;
	GtkBox* _tmp41_;
	GtkBox* _tmp42_;
	GtkLabel* _tmp43_;
	GtkLabel* _tmp44_;
	GtkLabel* _tmp45_;
	GtkLabel* _tmp46_;
	GtkLabel* _tmp47_;
	GtkLabel* _tmp48_;
	GtkLabel* _tmp49_;
	GtkBox* _tmp50_;
	GtkLabel* _tmp51_;
	GtkLabel* _tmp52_;
	GtkLabel* _tmp53_;
	GtkLabel* _tmp54_;
	GtkLabel* _tmp55_;
	GtkLabel* _tmp56_;
	GtkBox* _tmp57_;
	GtkLabel* _tmp58_;
	GtkBox* _tmp59_;
	GtkBox* _tmp60_;
	GtkButton* _tmp61_;
	GtkButton* _tmp62_;
	GtkButton* _tmp63_;
	GtkButton* _tmp64_;
	GtkButton* _tmp65_;
	GtkButton* _tmp66_;
	GtkBox* _tmp67_;
	GtkButton* _tmp68_;
	GtkBox* _tmp69_;
	GtkBox* input_row = NULL;
	GtkBox* _tmp70_;
	GtkButton* _tmp71_;
	GtkButton* _tmp72_;
	GtkButton* _tmp73_;
	GtkButton* _tmp74_;
	GtkButton* _tmp75_;
	GtkBox* _tmp76_;
	GtkButton* _tmp77_;
	GtkMenuButton* _tmp78_;
	GtkMenuButton* _tmp79_;
	GtkMenuButton* _tmp80_;
	GtkMenuButton* _tmp81_;
	GtkMenuButton* _tmp82_;
	GtkEmojiChooser* emoji_chooser = NULL;
	GtkEmojiChooser* _tmp83_;
	GtkEmojiChooser* _tmp84_;
	GtkBox* _tmp91_;
	GtkMenuButton* _tmp92_;
	GtkButton* _tmp93_;
	GtkButton* _tmp94_;
	GtkButton* _tmp95_;
	GtkButton* _tmp96_;
	GtkButton* _tmp97_;
	GtkButton* _tmp98_;
	GtkBox* _tmp99_;
	GtkButton* _tmp100_;
	GtkButton* _tmp101_;
	GtkButton* _tmp102_;
	GtkButton* _tmp103_;
	GtkButton* _tmp104_;
	GtkButton* _tmp105_;
	GtkButton* _tmp106_;
	GtkBox* _tmp107_;
	GtkButton* _tmp108_;
	GtkTextView* _tmp109_;
	GtkTextView* _tmp110_;
	GtkTextView* _tmp111_;
	GtkTextView* _tmp112_;
	GtkTextView* _tmp113_;
	GtkTextView* _tmp114_;
	GtkTextView* _tmp115_;
	GtkTextView* _tmp116_;
	GtkTextView* _tmp117_;
	GtkTextView* _tmp118_;
	GtkTextView* _tmp119_;
	GtkTextView* _tmp120_;
	GtkTextView* _tmp121_;
	const gchar* _tmp122_;
	GtkLabel* _tmp123_;
	GtkLabel* _tmp124_;
	GtkLabel* _tmp125_;
	GtkLabel* _tmp126_;
	GtkLabel* _tmp127_;
	GtkLabel* _tmp128_;
	GtkLabel* _tmp129_;
	GtkLabel* _tmp130_;
	GtkOverlay* entry_overlay = NULL;
	GtkOverlay* _tmp131_;
	GtkTextView* _tmp132_;
	GtkLabel* _tmp133_;
	GtkTextView* _tmp134_;
	GtkTextBuffer* _tmp135_;
	GtkTextBuffer* _tmp136_;
	GtkAdjustment* entry_vadj = NULL;
	GtkAdjustment* _tmp137_;
	GtkTextView* _tmp138_;
	GtkEventControllerKey* key_ctrl = NULL;
	GtkEventControllerKey* _tmp139_;
	GtkTextView* _tmp140_;
	GtkEventController* _tmp141_;
	GtkBox* _tmp142_;
	GtkButton* _tmp143_;
	GtkButton* _tmp144_;
	GtkButton* _tmp145_;
	GtkButton* _tmp146_;
	GtkButton* _tmp147_;
	GtkButton* _tmp148_;
	GtkBox* _tmp149_;
	GtkButton* _tmp150_;
	GtkBox* _tmp151_;
	self = (DcComposeBar*) g_object_new (object_type, "orientation", GTK_ORIENTATION_VERTICAL, "spacing", 0, NULL);
	gtk_widget_add_css_class ((GtkWidget*) self, "compose-bar");
	gtk_widget_set_margin_start ((GtkWidget*) self, 8);
	gtk_widget_set_margin_end ((GtkWidget*) self, 8);
	gtk_widget_set_margin_top ((GtkWidget*) self, 6);
	gtk_widget_set_margin_bottom ((GtkWidget*) self, 6);
	_tmp0_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
	g_object_ref_sink (_tmp0_);
	_g_object_unref0 (self->priv->reply_bar);
	self->priv->reply_bar = _tmp0_;
	_tmp1_ = self->priv->reply_bar;
	gtk_widget_add_css_class ((GtkWidget*) _tmp1_, "reply-bar");
	_tmp2_ = self->priv->reply_bar;
	gtk_widget_set_visible ((GtkWidget*) _tmp2_, FALSE);
	_tmp3_ = (GtkLabel*) gtk_label_new ("");
	g_object_ref_sink (_tmp3_);
	_g_object_unref0 (self->priv->reply_label);
	self->priv->reply_label = _tmp3_;
	_tmp4_ = self->priv->reply_label;
	gtk_widget_add_css_class ((GtkWidget*) _tmp4_, "reply-label");
	_tmp5_ = self->priv->reply_label;
	gtk_widget_set_halign ((GtkWidget*) _tmp5_, GTK_ALIGN_START);
	_tmp6_ = self->priv->reply_label;
	gtk_widget_set_valign ((GtkWidget*) _tmp6_, GTK_ALIGN_START);
	_tmp7_ = self->priv->reply_label;
	gtk_widget_set_hexpand ((GtkWidget*) _tmp7_, TRUE);
	_tmp8_ = self->priv->reply_label;
	gtk_label_set_xalign (_tmp8_, (gfloat) 0);
	_tmp9_ = self->priv->reply_label;
	gtk_label_set_wrap (_tmp9_, TRUE);
	_tmp10_ = self->priv->reply_label;
	gtk_label_set_wrap_mode (_tmp10_, PANGO_WRAP_WORD_CHAR);
	_tmp11_ = self->priv->reply_label;
	gtk_label_set_lines (_tmp11_, 3);
	_tmp12_ = self->priv->reply_label;
	gtk_label_set_ellipsize (_tmp12_, PANGO_ELLIPSIZE_END);
	_tmp13_ = self->priv->reply_bar;
	_tmp14_ = self->priv->reply_label;
	gtk_box_append (_tmp13_, (GtkWidget*) _tmp14_);
	_tmp15_ = (GtkButton*) gtk_button_new_from_icon_name ("window-close-symbolic");
	g_object_ref_sink (_tmp15_);
	_g_object_unref0 (self->priv->cancel_reply_button);
	self->priv->cancel_reply_button = _tmp15_;
	_tmp16_ = self->priv->cancel_reply_button;
	gtk_widget_add_css_class ((GtkWidget*) _tmp16_, "flat");
	_tmp17_ = self->priv->cancel_reply_button;
	gtk_widget_add_css_class ((GtkWidget*) _tmp17_, "circular");
	_tmp18_ = self->priv->cancel_reply_button;
	gtk_widget_set_tooltip_text ((GtkWidget*) _tmp18_, "Cancel reply");
	_tmp19_ = self->priv->cancel_reply_button;
	gtk_widget_set_valign ((GtkWidget*) _tmp19_, GTK_ALIGN_CENTER);
	_tmp20_ = self->priv->cancel_reply_button;
	g_signal_connect_object (_tmp20_, "clicked", (GCallback) _dc_compose_bar_cancel_reply_gtk_button_clicked, self, 0);
	_tmp21_ = self->priv->reply_bar;
	_tmp22_ = self->priv->cancel_reply_button;
	gtk_box_append (_tmp21_, (GtkWidget*) _tmp22_);
	_tmp23_ = self->priv->reply_bar;
	gtk_box_append ((GtkBox*) self, (GtkWidget*) _tmp23_);
	_tmp24_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 8);
	g_object_ref_sink (_tmp24_);
	_g_object_unref0 (self->priv->attachment_bar);
	self->priv->attachment_bar = _tmp24_;
	_tmp25_ = self->priv->attachment_bar;
	gtk_widget_add_css_class ((GtkWidget*) _tmp25_, "attachment-bar");
	_tmp26_ = self->priv->attachment_bar;
	gtk_widget_set_visible ((GtkWidget*) _tmp26_, FALSE);
	_tmp27_ = (GtkPicture*) gtk_picture_new ();
	g_object_ref_sink (_tmp27_);
	_g_object_unref0 (self->priv->attachment_picture);
	self->priv->attachment_picture = _tmp27_;
	_tmp28_ = self->priv->attachment_picture;
	gtk_widget_add_css_class ((GtkWidget*) _tmp28_, "attachment-preview-image");
	_tmp29_ = self->priv->attachment_picture;
	gtk_picture_set_content_fit (_tmp29_, GTK_CONTENT_FIT_COVER);
	_tmp30_ = self->priv->attachment_picture;
	gtk_widget_set_size_request ((GtkWidget*) _tmp30_, 72, 72);
	_tmp31_ = self->priv->attachment_picture;
	gtk_picture_set_can_shrink (_tmp31_, TRUE);
	_tmp32_ = self->priv->attachment_bar;
	_tmp33_ = self->priv->attachment_picture;
	gtk_box_append (_tmp32_, (GtkWidget*) _tmp33_);
	_tmp34_ = (GtkImage*) gtk_image_new ();
	g_object_ref_sink (_tmp34_);
	_g_object_unref0 (self->priv->attachment_icon);
	self->priv->attachment_icon = _tmp34_;
	_tmp35_ = self->priv->attachment_icon;
	gtk_widget_add_css_class ((GtkWidget*) _tmp35_, "attachment-preview-icon");
	_tmp36_ = self->priv->attachment_icon;
	gtk_image_set_pixel_size (_tmp36_, 36);
	_tmp37_ = self->priv->attachment_icon;
	gtk_widget_set_valign ((GtkWidget*) _tmp37_, GTK_ALIGN_CENTER);
	_tmp38_ = self->priv->attachment_bar;
	_tmp39_ = self->priv->attachment_icon;
	gtk_box_append (_tmp38_, (GtkWidget*) _tmp39_);
	_tmp40_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_VERTICAL, 2);
	g_object_ref_sink (_tmp40_);
	attachment_info = _tmp40_;
	_tmp41_ = attachment_info;
	gtk_widget_set_valign ((GtkWidget*) _tmp41_, GTK_ALIGN_CENTER);
	_tmp42_ = attachment_info;
	gtk_widget_set_hexpand ((GtkWidget*) _tmp42_, TRUE);
	_tmp43_ = (GtkLabel*) gtk_label_new ("");
	g_object_ref_sink (_tmp43_);
	_g_object_unref0 (self->priv->attachment_name_label);
	self->priv->attachment_name_label = _tmp43_;
	_tmp44_ = self->priv->attachment_name_label;
	gtk_widget_add_css_class ((GtkWidget*) _tmp44_, "attachment-preview-name");
	_tmp45_ = self->priv->attachment_name_label;
	gtk_widget_set_halign ((GtkWidget*) _tmp45_, GTK_ALIGN_START);
	_tmp46_ = self->priv->attachment_name_label;
	gtk_label_set_xalign (_tmp46_, (gfloat) 0);
	_tmp47_ = self->priv->attachment_name_label;
	gtk_label_set_ellipsize (_tmp47_, PANGO_ELLIPSIZE_MIDDLE);
	_tmp48_ = self->priv->attachment_name_label;
	gtk_label_set_max_width_chars (_tmp48_, 40);
	_tmp49_ = self->priv->attachment_name_label;
	gtk_label_set_single_line_mode (_tmp49_, TRUE);
	_tmp50_ = attachment_info;
	_tmp51_ = self->priv->attachment_name_label;
	gtk_box_append (_tmp50_, (GtkWidget*) _tmp51_);
	_tmp52_ = (GtkLabel*) gtk_label_new ("");
	g_object_ref_sink (_tmp52_);
	_g_object_unref0 (self->priv->attachment_meta_label);
	self->priv->attachment_meta_label = _tmp52_;
	_tmp53_ = self->priv->attachment_meta_label;
	gtk_widget_add_css_class ((GtkWidget*) _tmp53_, "attachment-preview-meta");
	_tmp54_ = self->priv->attachment_meta_label;
	gtk_widget_set_halign ((GtkWidget*) _tmp54_, GTK_ALIGN_START);
	_tmp55_ = self->priv->attachment_meta_label;
	gtk_label_set_xalign (_tmp55_, (gfloat) 0);
	_tmp56_ = self->priv->attachment_meta_label;
	gtk_label_set_ellipsize (_tmp56_, PANGO_ELLIPSIZE_END);
	_tmp57_ = attachment_info;
	_tmp58_ = self->priv->attachment_meta_label;
	gtk_box_append (_tmp57_, (GtkWidget*) _tmp58_);
	_tmp59_ = self->priv->attachment_bar;
	_tmp60_ = attachment_info;
	gtk_box_append (_tmp59_, (GtkWidget*) _tmp60_);
	_tmp61_ = (GtkButton*) gtk_button_new_from_icon_name ("window-close-symbolic");
	g_object_ref_sink (_tmp61_);
	_g_object_unref0 (self->priv->attachment_close_button);
	self->priv->attachment_close_button = _tmp61_;
	_tmp62_ = self->priv->attachment_close_button;
	gtk_widget_add_css_class ((GtkWidget*) _tmp62_, "flat");
	_tmp63_ = self->priv->attachment_close_button;
	gtk_widget_add_css_class ((GtkWidget*) _tmp63_, "circular");
	_tmp64_ = self->priv->attachment_close_button;
	gtk_widget_set_tooltip_text ((GtkWidget*) _tmp64_, "Remove attachment");
	_tmp65_ = self->priv->attachment_close_button;
	gtk_widget_set_valign ((GtkWidget*) _tmp65_, GTK_ALIGN_CENTER);
	_tmp66_ = self->priv->attachment_close_button;
	g_signal_connect_object (_tmp66_, "clicked", (GCallback) _dc_compose_bar_clear_attachment_gtk_button_clicked, self, 0);
	_tmp67_ = self->priv->attachment_bar;
	_tmp68_ = self->priv->attachment_close_button;
	gtk_box_append (_tmp67_, (GtkWidget*) _tmp68_);
	_tmp69_ = self->priv->attachment_bar;
	gtk_box_append ((GtkBox*) self, (GtkWidget*) _tmp69_);
	_tmp70_ = (GtkBox*) gtk_box_new (GTK_ORIENTATION_HORIZONTAL, 6);
	g_object_ref_sink (_tmp70_);
	input_row = _tmp70_;
	_tmp71_ = (GtkButton*) gtk_button_new_from_icon_name ("mail-attachment-symbolic");
	g_object_ref_sink (_tmp71_);
	_g_object_unref0 (self->priv->attach_button);
	self->priv->attach_button = _tmp71_;
	_tmp72_ = self->priv->attach_button;
	gtk_widget_add_css_class ((GtkWidget*) _tmp72_, "flat");
	_tmp73_ = self->priv->attach_button;
	gtk_widget_set_tooltip_text ((GtkWidget*) _tmp73_, "Attach file");
	_tmp74_ = self->priv->attach_button;
	gtk_widget_set_valign ((GtkWidget*) _tmp74_, GTK_ALIGN_CENTER);
	_tmp75_ = self->priv->attach_button;
	g_signal_connect_object (_tmp75_, "clicked", (GCallback) _dc_compose_bar_on_attach_clicked_gtk_button_clicked, self, 0);
	_tmp76_ = input_row;
	_tmp77_ = self->priv->attach_button;
	gtk_box_append (_tmp76_, (GtkWidget*) _tmp77_);
	_tmp78_ = (GtkMenuButton*) gtk_menu_button_new ();
	g_object_ref_sink (_tmp78_);
	_g_object_unref0 (self->priv->emoji_button);
	self->priv->emoji_button = _tmp78_;
	_tmp79_ = self->priv->emoji_button;
	gtk_menu_button_set_icon_name (_tmp79_, "face-smile-symbolic");
	_tmp80_ = self->priv->emoji_button;
	gtk_widget_add_css_class ((GtkWidget*) _tmp80_, "flat");
	_tmp81_ = self->priv->emoji_button;
	gtk_widget_set_tooltip_text ((GtkWidget*) _tmp81_, "Insert emoji");
	_tmp82_ = self->priv->emoji_button;
	gtk_widget_set_valign ((GtkWidget*) _tmp82_, GTK_ALIGN_CENTER);
	_tmp83_ = dc_create_emoji_chooser ();
	emoji_chooser = _tmp83_;
	_tmp84_ = emoji_chooser;
	if (_tmp84_ != NULL) {
		GtkEmojiChooser* _tmp85_;
		GtkEmojiChooser* _tmp86_;
		GtkMenuButton* _tmp87_;
		GtkEmojiChooser* _tmp88_;
		_tmp85_ = emoji_chooser;
		g_signal_connect_object (_tmp85_, "emoji-picked", (GCallback) _dc_compose_bar_on_emoji_picked_gtk_emoji_chooser_emoji_picked, self, 0);
		_tmp86_ = emoji_chooser;
		g_signal_connect_object ((GtkPopover*) _tmp86_, "closed", (GCallback) ____lambda23__gtk_popover_closed, self, 0);
		_tmp87_ = self->priv->emoji_button;
		_tmp88_ = emoji_chooser;
		gtk_menu_button_set_popover (_tmp87_, (GtkPopover*) _tmp88_);
	} else {
		GtkMenuButton* _tmp89_;
		GtkMenuButton* _tmp90_;
		_tmp89_ = self->priv->emoji_button;
		gtk_widget_set_sensitive ((GtkWidget*) _tmp89_, FALSE);
		_tmp90_ = self->priv->emoji_button;
		gtk_widget_set_tooltip_text ((GtkWidget*) _tmp90_, "Emoji picker unavailable");
	}
	_tmp91_ = input_row;
	_tmp92_ = self->priv->emoji_button;
	gtk_box_append (_tmp91_, (GtkWidget*) _tmp92_);
	_tmp93_ = (GtkButton*) gtk_button_new_from_icon_name ("edit-clear-symbolic");
	g_object_ref_sink (_tmp93_);
	_g_object_unref0 (self->priv->cancel_attach_button);
	self->priv->cancel_attach_button = _tmp93_;
	_tmp94_ = self->priv->cancel_attach_button;
	gtk_widget_add_css_class ((GtkWidget*) _tmp94_, "flat");
	_tmp95_ = self->priv->cancel_attach_button;
	gtk_widget_set_tooltip_text ((GtkWidget*) _tmp95_, "Remove attachment");
	_tmp96_ = self->priv->cancel_attach_button;
	gtk_widget_set_valign ((GtkWidget*) _tmp96_, GTK_ALIGN_CENTER);
	_tmp97_ = self->priv->cancel_attach_button;
	gtk_widget_set_visible ((GtkWidget*) _tmp97_, FALSE);
	_tmp98_ = self->priv->cancel_attach_button;
	g_signal_connect_object (_tmp98_, "clicked", (GCallback) _dc_compose_bar_clear_attachment_gtk_button_clicked, self, 0);
	_tmp99_ = input_row;
	_tmp100_ = self->priv->cancel_attach_button;
	gtk_box_append (_tmp99_, (GtkWidget*) _tmp100_);
	_tmp101_ = (GtkButton*) gtk_button_new_from_icon_name ("edit-undo-symbolic");
	g_object_ref_sink (_tmp101_);
	_g_object_unref0 (self->priv->cancel_edit_button);
	self->priv->cancel_edit_button = _tmp101_;
	_tmp102_ = self->priv->cancel_edit_button;
	gtk_widget_add_css_class ((GtkWidget*) _tmp102_, "flat");
	_tmp103_ = self->priv->cancel_edit_button;
	gtk_widget_set_tooltip_text ((GtkWidget*) _tmp103_, "Cancel editing");
	_tmp104_ = self->priv->cancel_edit_button;
	gtk_widget_set_valign ((GtkWidget*) _tmp104_, GTK_ALIGN_CENTER);
	_tmp105_ = self->priv->cancel_edit_button;
	gtk_widget_set_visible ((GtkWidget*) _tmp105_, FALSE);
	_tmp106_ = self->priv->cancel_edit_button;
	g_signal_connect_object (_tmp106_, "clicked", (GCallback) _dc_compose_bar_cancel_edit_gtk_button_clicked, self, 0);
	_tmp107_ = input_row;
	_tmp108_ = self->priv->cancel_edit_button;
	gtk_box_append (_tmp107_, (GtkWidget*) _tmp108_);
	_tmp109_ = (GtkTextView*) gtk_text_view_new ();
	g_object_ref_sink (_tmp109_);
	_g_object_unref0 (self->priv->text_view);
	self->priv->text_view = _tmp109_;
	_tmp110_ = self->priv->text_view;
	gtk_text_view_set_wrap_mode (_tmp110_, GTK_WRAP_WORD_CHAR);
	_tmp111_ = self->priv->text_view;
	gtk_text_view_set_accepts_tab (_tmp111_, FALSE);
	_tmp112_ = self->priv->text_view;
	gtk_text_view_set_top_margin (_tmp112_, 7);
	_tmp113_ = self->priv->text_view;
	gtk_text_view_set_bottom_margin (_tmp113_, 3);
	_tmp114_ = self->priv->text_view;
	gtk_text_view_set_left_margin (_tmp114_, 12);
	_tmp115_ = self->priv->text_view;
	gtk_text_view_set_right_margin (_tmp115_, 12);
	_tmp116_ = self->priv->text_view;
	gtk_text_view_set_pixels_above_lines (_tmp116_, 0);
	_tmp117_ = self->priv->text_view;
	gtk_text_view_set_pixels_below_lines (_tmp117_, 0);
	_tmp118_ = self->priv->text_view;
	gtk_text_view_set_pixels_inside_wrap (_tmp118_, 0);
	_tmp119_ = self->priv->text_view;
	gtk_widget_set_hexpand ((GtkWidget*) _tmp119_, TRUE);
	_tmp120_ = self->priv->text_view;
	gtk_widget_set_vexpand ((GtkWidget*) _tmp120_, FALSE);
	_tmp121_ = self->priv->text_view;
	gtk_widget_add_css_class ((GtkWidget*) _tmp121_, "compose-entry");
	_tmp122_ = self->priv->placeholder_default;
	_tmp123_ = (GtkLabel*) gtk_label_new (_tmp122_);
	g_object_ref_sink (_tmp123_);
	_g_object_unref0 (self->priv->placeholder_label);
	self->priv->placeholder_label = _tmp123_;
	_tmp124_ = self->priv->placeholder_label;
	gtk_widget_add_css_class ((GtkWidget*) _tmp124_, "compose-placeholder");
	_tmp125_ = self->priv->placeholder_label;
	gtk_widget_set_halign ((GtkWidget*) _tmp125_, GTK_ALIGN_START);
	_tmp126_ = self->priv->placeholder_label;
	gtk_widget_set_valign ((GtkWidget*) _tmp126_, GTK_ALIGN_START);
	_tmp127_ = self->priv->placeholder_label;
	gtk_widget_set_margin_start ((GtkWidget*) _tmp127_, 12);
	_tmp128_ = self->priv->placeholder_label;
	gtk_widget_set_margin_top ((GtkWidget*) _tmp128_, 7);
	_tmp129_ = self->priv->placeholder_label;
	gtk_widget_set_can_target ((GtkWidget*) _tmp129_, FALSE);
	_tmp130_ = self->priv->placeholder_label;
	gtk_label_set_ellipsize (_tmp130_, PANGO_ELLIPSIZE_END);
	_tmp131_ = (GtkOverlay*) gtk_overlay_new ();
	g_object_ref_sink (_tmp131_);
	entry_overlay = _tmp131_;
	_tmp132_ = self->priv->text_view;
	gtk_overlay_set_child (entry_overlay, (GtkWidget*) _tmp132_);
	_tmp133_ = self->priv->placeholder_label;
	gtk_overlay_add_overlay (entry_overlay, (GtkWidget*) _tmp133_);
	gtk_widget_set_hexpand ((GtkWidget*) entry_overlay, TRUE);
	gtk_widget_set_valign ((GtkWidget*) entry_overlay, GTK_ALIGN_CENTER);
	_tmp134_ = self->priv->text_view;
	_tmp135_ = gtk_text_view_get_buffer (_tmp134_);
	_tmp136_ = _tmp135_;
	g_signal_connect_object (_tmp136_, "changed", (GCallback) _dc_compose_bar_update_placeholder_gtk_text_buffer_changed, self, 0);
	dc_compose_bar_update_placeholder (self);
	_tmp137_ = gtk_adjustment_new ((gdouble) 0, (gdouble) 0, (gdouble) 0, (gdouble) 0, (gdouble) 0, (gdouble) 0);
	g_object_ref_sink (_tmp137_);
	entry_vadj = _tmp137_;
	g_signal_connect_object ((GObject*) entry_vadj, "notify::upper", (GCallback) ___lambda25__g_object_notify, self, 0);
	_tmp138_ = self->priv->text_view;
	gtk_scrollable_set_vadjustment ((GtkScrollable*) _tmp138_, entry_vadj);
	_tmp139_ = (GtkEventControllerKey*) gtk_event_controller_key_new ();
	key_ctrl = _tmp139_;
	g_signal_connect_object (key_ctrl, "key-pressed", (GCallback) _dc_compose_bar_on_entry_key_pressed_gtk_event_controller_key_key_pressed, self, 0);
	_tmp140_ = self->priv->text_view;
	_tmp141_ = _g_object_ref0 ((GtkEventController*) key_ctrl);
	gtk_widget_add_controller ((GtkWidget*) _tmp140_, _tmp141_);
	_tmp142_ = input_row;
	gtk_box_append (_tmp142_, (GtkWidget*) entry_overlay);
	_tmp143_ = (GtkButton*) gtk_button_new_from_icon_name ("go-up-symbolic");
	g_object_ref_sink (_tmp143_);
	_g_object_unref0 (self->priv->send_button);
	self->priv->send_button = _tmp143_;
	_tmp144_ = self->priv->send_button;
	gtk_widget_add_css_class ((GtkWidget*) _tmp144_, "suggested-action");
	_tmp145_ = self->priv->send_button;
	gtk_widget_add_css_class ((GtkWidget*) _tmp145_, "circular");
	_tmp146_ = self->priv->send_button;
	gtk_widget_set_tooltip_text ((GtkWidget*) _tmp146_, "Send message");
	_tmp147_ = self->priv->send_button;
	gtk_widget_set_valign ((GtkWidget*) _tmp147_, GTK_ALIGN_CENTER);
	_tmp148_ = self->priv->send_button;
	g_signal_connect_object (_tmp148_, "clicked", (GCallback) _dc_compose_bar_on_send_gtk_button_clicked, self, 0);
	_tmp149_ = input_row;
	_tmp150_ = self->priv->send_button;
	gtk_box_append (_tmp149_, (GtkWidget*) _tmp150_);
	_tmp151_ = input_row;
	gtk_box_append ((GtkBox*) self, (GtkWidget*) _tmp151_);
	_g_object_unref0 (key_ctrl);
	_g_object_unref0 (entry_vadj);
	_g_object_unref0 (entry_overlay);
	_g_object_unref0 (emoji_chooser);
	_g_object_unref0 (input_row);
	_g_object_unref0 (attachment_info);
	return self;
}

DcComposeBar*
dc_compose_bar_new (void)
{
	return dc_compose_bar_construct (DC_TYPE_COMPOSE_BAR);
}

static gboolean
__lambda28_ (DcComposeBar* self)
{
	GtkTextView* _tmp0_;
	gboolean result;
	_tmp0_ = self->priv->text_view;
	gtk_widget_grab_focus ((GtkWidget*) _tmp0_);
	result = G_SOURCE_REMOVE;
	return result;
}

static gboolean
___lambda28__gsource_func (gpointer self)
{
	gboolean result;
	result = __lambda28_ ((DcComposeBar*) self);
	return result;
}

void
dc_compose_bar_grab_entry_focus (DcComposeBar* self)
{
	GtkTextView* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->text_view;
	gtk_widget_grab_focus ((GtkWidget*) _tmp0_);
	g_idle_add_full (G_PRIORITY_DEFAULT_IDLE, ___lambda28__gsource_func, g_object_ref (self), g_object_unref);
}

void
dc_compose_bar_type_text (DcComposeBar* self,
                          const gchar* text)
{
	gboolean _tmp0_ = FALSE;
	gboolean open_emoji = FALSE;
	GtkTextView* _tmp1_;
	GtkTextBuffer* _tmp2_;
	GtkTextBuffer* _tmp3_;
	gint _tmp4_;
	gint _tmp5_;
	GtkTextView* _tmp6_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (text != NULL);
	if (g_strcmp0 (text, ":") == 0) {
		_tmp0_ = dc_compose_bar_previous_char_is_colon (self);
	} else {
		_tmp0_ = FALSE;
	}
	open_emoji = _tmp0_;
	_tmp1_ = self->priv->text_view;
	_tmp2_ = gtk_text_view_get_buffer (_tmp1_);
	_tmp3_ = _tmp2_;
	_tmp4_ = strlen (text);
	_tmp5_ = _tmp4_;
	gtk_text_buffer_insert_at_cursor (_tmp3_, text, _tmp5_);
	_tmp6_ = self->priv->text_view;
	gtk_widget_grab_focus ((GtkWidget*) _tmp6_);
	if (open_emoji) {
		dc_compose_bar_open_emoji_picker_after_typed_colon (self);
	}
}

void
dc_compose_bar_clear (DcComposeBar* self)
{
	GtkTextView* _tmp0_;
	GtkTextBuffer* _tmp1_;
	GtkTextBuffer* _tmp2_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->text_view;
	_tmp1_ = gtk_text_view_get_buffer (_tmp0_);
	_tmp2_ = _tmp1_;
	g_object_set (_tmp2_, "text", "", NULL);
	dc_compose_bar_clear_attachment (self);
}

static gchar*
dc_compose_bar_get_text (DcComposeBar* self)
{
	GtkTextIter start = {0};
	GtkTextIter end = {0};
	GtkTextView* _tmp0_;
	GtkTextBuffer* _tmp1_;
	GtkTextBuffer* _tmp2_;
	GtkTextIter _tmp3_ = {0};
	GtkTextIter _tmp4_ = {0};
	GtkTextView* _tmp5_;
	GtkTextBuffer* _tmp6_;
	GtkTextBuffer* _tmp7_;
	GtkTextIter _tmp8_;
	GtkTextIter _tmp9_;
	gchar* _tmp10_;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->text_view;
	_tmp1_ = gtk_text_view_get_buffer (_tmp0_);
	_tmp2_ = _tmp1_;
	gtk_text_buffer_get_bounds (_tmp2_, &_tmp3_, &_tmp4_);
	start = _tmp3_;
	end = _tmp4_;
	_tmp5_ = self->priv->text_view;
	_tmp6_ = gtk_text_view_get_buffer (_tmp5_);
	_tmp7_ = _tmp6_;
	_tmp8_ = start;
	_tmp9_ = end;
	_tmp10_ = gtk_text_buffer_get_text (_tmp7_, &_tmp8_, &_tmp9_, FALSE);
	result = _tmp10_;
	return result;
}

static void
dc_compose_bar_set_placeholder (DcComposeBar* self,
                                const gchar* s)
{
	GtkLabel* _tmp0_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (s != NULL);
	_tmp0_ = self->priv->placeholder_label;
	gtk_label_set_label (_tmp0_, s);
}

static void
dc_compose_bar_update_placeholder (DcComposeBar* self)
{
	GtkLabel* _tmp0_;
	GtkTextView* _tmp1_;
	GtkTextBuffer* _tmp2_;
	GtkTextBuffer* _tmp3_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->placeholder_label;
	_tmp1_ = self->priv->text_view;
	_tmp2_ = gtk_text_view_get_buffer (_tmp1_);
	_tmp3_ = _tmp2_;
	gtk_widget_set_visible ((GtkWidget*) _tmp0_, gtk_text_buffer_get_char_count (_tmp3_) == 0);
}

gboolean
dc_compose_bar_can_accept_attachment (DcComposeBar* self)
{
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	result = self->priv->editing_msg_id == 0;
	return result;
}

void
dc_compose_bar_set_pending_attachment (DcComposeBar* self,
                                       const gchar* file_path,
                                       const gchar* file_name)
{
	gchar* _tmp0_;
	gchar* _tmp1_ = NULL;
	gchar* _tmp2_;
	gchar* _tmp4_;
	GtkTextView* _tmp5_;
	GtkTextBuffer* _tmp6_;
	GtkTextBuffer* _tmp7_;
	const gchar* _tmp8_;
	GtkButton* _tmp9_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (file_path != NULL);
	_tmp0_ = g_strdup (file_path);
	_g_free0 (self->priv->pending_file);
	self->priv->pending_file = _tmp0_;
	_tmp2_ = g_strdup (file_name);
	_tmp1_ = _tmp2_;
	if (_tmp1_ == NULL) {
		gchar* _tmp3_;
		_tmp3_ = g_path_get_basename (file_path);
		_g_free0 (_tmp1_);
		_tmp1_ = _tmp3_;
	}
	_tmp4_ = _tmp1_;
	_tmp1_ = NULL;
	_g_free0 (self->priv->pending_file_name);
	self->priv->pending_file_name = _tmp4_;
	self->priv->pending_file_is_temp = FALSE;
	_tmp5_ = self->priv->text_view;
	_tmp6_ = gtk_text_view_get_buffer (_tmp5_);
	_tmp7_ = _tmp6_;
	g_object_set (_tmp7_, "text", "", NULL);
	_tmp8_ = self->priv->pending_file_name;
	dc_compose_bar_populate_attachment_preview (self, file_path, _tmp8_);
	_tmp9_ = self->priv->cancel_attach_button;
	gtk_widget_set_visible ((GtkWidget*) _tmp9_, TRUE);
	_g_free0 (_tmp1_);
}

static void
dc_compose_bar_populate_attachment_preview (DcComposeBar* self,
                                            const gchar* file_path,
                                            const gchar* file_name)
{
	gchar* mime = NULL;
	gchar* _tmp0_;
	gboolean _tmp1_ = FALSE;
	const gchar* _tmp2_;
	gboolean is_image = FALSE;
	GtkPicture* _tmp4_;
	GtkImage* _tmp5_;
	GtkLabel* _tmp17_;
	gchar* size_str = NULL;
	gchar* _tmp18_;
	gchar* _tmp19_ = NULL;
	const gchar* _tmp20_;
	GtkLabel* _tmp26_;
	GtkBox* _tmp27_;
	GError* _inner_error0_ = NULL;
	g_return_if_fail (self != NULL);
	g_return_if_fail (file_path != NULL);
	g_return_if_fail (file_name != NULL);
	_tmp0_ = dc_compose_bar_guess_mime (file_path);
	mime = _tmp0_;
	_tmp2_ = mime;
	if (_tmp2_ != NULL) {
		const gchar* _tmp3_;
		_tmp3_ = mime;
		_tmp1_ = g_str_has_prefix (_tmp3_, "image/");
	} else {
		_tmp1_ = FALSE;
	}
	is_image = _tmp1_;
	_tmp4_ = self->priv->attachment_picture;
	gtk_widget_set_visible ((GtkWidget*) _tmp4_, FALSE);
	_tmp5_ = self->priv->attachment_icon;
	gtk_widget_set_visible ((GtkWidget*) _tmp5_, FALSE);
	if (is_image) {
		{
			GdkPixbuf* pixbuf = NULL;
			GdkPixbuf* _tmp6_;
			GdkTexture* texture = NULL;
			GdkPixbuf* _tmp7_;
			GdkTexture* _tmp8_;
			GtkPicture* _tmp9_;
			GdkTexture* _tmp10_;
			GtkPicture* _tmp11_;
			_tmp6_ = gdk_pixbuf_new_from_file_at_scale (file_path, 256, 256, TRUE, &_inner_error0_);
			pixbuf = _tmp6_;
			if (G_UNLIKELY (_inner_error0_ != NULL)) {
				goto __catch0_g_error;
			}
			_tmp7_ = pixbuf;
			_tmp8_ = gdk_texture_new_for_pixbuf (_tmp7_);
			texture = _tmp8_;
			_tmp9_ = self->priv->attachment_picture;
			_tmp10_ = texture;
			gtk_picture_set_paintable (_tmp9_, (GdkPaintable*) _tmp10_);
			_tmp11_ = self->priv->attachment_picture;
			gtk_widget_set_visible ((GtkWidget*) _tmp11_, TRUE);
			_g_object_unref0 (texture);
			_g_object_unref0 (pixbuf);
		}
		goto __finally0;
		__catch0_g_error:
		{
			g_clear_error (&_inner_error0_);
			is_image = FALSE;
		}
		__finally0:
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			_g_free0 (mime);
			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;
		}
	}
	if (!is_image) {
		GtkImage* _tmp12_;
		const gchar* _tmp13_;
		gchar* _tmp14_;
		gchar* _tmp15_;
		GtkImage* _tmp16_;
		_tmp12_ = self->priv->attachment_icon;
		_tmp13_ = mime;
		_tmp14_ = dc_compose_bar_mime_icon_name (_tmp13_, file_path);
		_tmp15_ = _tmp14_;
		g_object_set (_tmp12_, "icon-name", _tmp15_, NULL);
		_g_free0 (_tmp15_);
		_tmp16_ = self->priv->attachment_icon;
		gtk_widget_set_visible ((GtkWidget*) _tmp16_, TRUE);
	}
	_tmp17_ = self->priv->attachment_name_label;
	gtk_label_set_label (_tmp17_, file_name);
	_tmp18_ = dc_compose_bar_format_size (dc_compose_bar_file_size_or_zero (file_path));
	size_str = _tmp18_;
	_tmp20_ = mime;
	if (_tmp20_ != NULL) {
		const gchar* _tmp21_;
		const gchar* _tmp22_;
		gchar* _tmp23_;
		_tmp21_ = mime;
		_tmp22_ = size_str;
		_tmp23_ = g_strdup_printf ("%s · %s", _tmp21_, _tmp22_);
		_g_free0 (_tmp19_);
		_tmp19_ = _tmp23_;
	} else {
		const gchar* _tmp24_;
		gchar* _tmp25_;
		_tmp24_ = size_str;
		_tmp25_ = g_strdup (_tmp24_);
		_g_free0 (_tmp19_);
		_tmp19_ = _tmp25_;
	}
	_tmp26_ = self->priv->attachment_meta_label;
	gtk_label_set_label (_tmp26_, _tmp19_);
	_tmp27_ = self->priv->attachment_bar;
	gtk_widget_set_visible ((GtkWidget*) _tmp27_, TRUE);
	_g_free0 (_tmp19_);
	_g_free0 (size_str);
	_g_free0 (mime);
}

static gchar*
dc_compose_bar_guess_mime (const gchar* file_path)
{
	GError* _inner_error0_ = NULL;
	gchar* result;
	g_return_val_if_fail (file_path != NULL, NULL);
	{
		GFileInfo* info = NULL;
		GFile* _tmp0_;
		GFile* _tmp1_;
		GFileInfo* _tmp2_;
		GFileInfo* _tmp3_;
		gchar* ct = NULL;
		GFileInfo* _tmp4_;
		const gchar* _tmp5_;
		gchar* _tmp6_;
		const gchar* _tmp7_;
		_tmp0_ = g_file_new_for_path (file_path);
		_tmp1_ = _tmp0_;
		_tmp2_ = g_file_query_info (_tmp1_, "standard::content-type", G_FILE_QUERY_INFO_NONE, NULL, &_inner_error0_);
		_tmp3_ = _tmp2_;
		_g_object_unref0 (_tmp1_);
		info = _tmp3_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
		_tmp4_ = info;
		_tmp5_ = g_file_info_get_content_type (_tmp4_);
		_tmp6_ = g_strdup (_tmp5_);
		ct = _tmp6_;
		_tmp7_ = ct;
		if (_tmp7_ != NULL) {
			gchar* mime = NULL;
			const gchar* _tmp8_;
			gchar* _tmp9_;
			gboolean _tmp10_ = FALSE;
			const gchar* _tmp11_;
			_tmp8_ = ct;
			_tmp9_ = g_content_type_get_mime_type (_tmp8_);
			mime = _tmp9_;
			_tmp11_ = mime;
			if (_tmp11_ != NULL) {
				const gchar* _tmp12_;
				gint _tmp13_;
				gint _tmp14_;
				_tmp12_ = mime;
				_tmp13_ = strlen (_tmp12_);
				_tmp14_ = _tmp13_;
				_tmp10_ = _tmp14_ > 0;
			} else {
				_tmp10_ = FALSE;
			}
			if (_tmp10_) {
				result = mime;
				_g_free0 (ct);
				_g_object_unref0 (info);
				return result;
			}
			_g_free0 (mime);
		}
		_g_free0 (ct);
		_g_object_unref0 (info);
	}
	goto __finally0;
	__catch0_g_error:
	{
		g_clear_error (&_inner_error0_);
	}
	__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 NULL;
	}
	result = NULL;
	return result;
}

static gchar*
dc_compose_bar_mime_icon_name (const gchar* mime,
                               const gchar* file_path)
{
	gchar* lower = NULL;
	gchar* _tmp12_;
	const gchar* _tmp13_;
	gboolean _tmp15_ = FALSE;
	gboolean _tmp16_ = FALSE;
	gboolean _tmp17_ = FALSE;
	gboolean _tmp18_ = FALSE;
	gboolean _tmp19_ = FALSE;
	gboolean _tmp20_ = FALSE;
	const gchar* _tmp21_;
	gchar* _tmp29_;
	gchar* result;
	g_return_val_if_fail (file_path != NULL, NULL);
	if (mime != NULL) {
		gboolean _tmp5_ = FALSE;
		gboolean _tmp6_ = FALSE;
		gboolean _tmp7_ = FALSE;
		gboolean _tmp8_ = FALSE;
		gboolean _tmp9_ = FALSE;
		gboolean _tmp10_ = FALSE;
		if (g_str_has_prefix (mime, "video/")) {
			gchar* _tmp0_;
			_tmp0_ = g_strdup ("video-x-generic-symbolic");
			result = _tmp0_;
			return result;
		}
		if (g_str_has_prefix (mime, "audio/")) {
			gchar* _tmp1_;
			_tmp1_ = g_strdup ("audio-x-generic-symbolic");
			result = _tmp1_;
			return result;
		}
		if (g_str_has_prefix (mime, "image/")) {
			gchar* _tmp2_;
			_tmp2_ = g_strdup ("image-x-generic-symbolic");
			result = _tmp2_;
			return result;
		}
		if (g_strcmp0 (mime, "application/pdf") == 0) {
			gchar* _tmp3_;
			_tmp3_ = g_strdup ("application-pdf-symbolic");
			result = _tmp3_;
			return result;
		}
		if (g_str_has_prefix (mime, "text/")) {
			gchar* _tmp4_;
			_tmp4_ = g_strdup ("text-x-generic-symbolic");
			result = _tmp4_;
			return result;
		}
		if (g_strcmp0 (mime, "application/zip") == 0) {
			_tmp10_ = TRUE;
		} else {
			_tmp10_ = g_strcmp0 (mime, "application/x-tar") == 0;
		}
		if (_tmp10_) {
			_tmp9_ = TRUE;
		} else {
			_tmp9_ = g_strcmp0 (mime, "application/gzip") == 0;
		}
		if (_tmp9_) {
			_tmp8_ = TRUE;
		} else {
			_tmp8_ = g_strcmp0 (mime, "application/x-7z-compressed") == 0;
		}
		if (_tmp8_) {
			_tmp7_ = TRUE;
		} else {
			_tmp7_ = g_strcmp0 (mime, "application/x-rar-compressed") == 0;
		}
		if (_tmp7_) {
			_tmp6_ = TRUE;
		} else {
			_tmp6_ = g_strcmp0 (mime, "application/x-bzip") == 0;
		}
		if (_tmp6_) {
			_tmp5_ = TRUE;
		} else {
			_tmp5_ = g_strcmp0 (mime, "application/x-bzip2") == 0;
		}
		if (_tmp5_) {
			gchar* _tmp11_;
			_tmp11_ = g_strdup ("package-x-generic-symbolic");
			result = _tmp11_;
			return result;
		}
	}
	_tmp12_ = g_utf8_strdown (file_path, (gssize) -1);
	lower = _tmp12_;
	_tmp13_ = lower;
	if (g_str_has_suffix (_tmp13_, ".pdf")) {
		gchar* _tmp14_;
		_tmp14_ = g_strdup ("application-pdf-symbolic");
		result = _tmp14_;
		_g_free0 (lower);
		return result;
	}
	_tmp21_ = lower;
	if (g_str_has_suffix (_tmp21_, ".zip")) {
		_tmp20_ = TRUE;
	} else {
		const gchar* _tmp22_;
		_tmp22_ = lower;
		_tmp20_ = g_str_has_suffix (_tmp22_, ".tar");
	}
	if (_tmp20_) {
		_tmp19_ = TRUE;
	} else {
		const gchar* _tmp23_;
		_tmp23_ = lower;
		_tmp19_ = g_str_has_suffix (_tmp23_, ".tgz");
	}
	if (_tmp19_) {
		_tmp18_ = TRUE;
	} else {
		const gchar* _tmp24_;
		_tmp24_ = lower;
		_tmp18_ = g_str_has_suffix (_tmp24_, ".gz");
	}
	if (_tmp18_) {
		_tmp17_ = TRUE;
	} else {
		const gchar* _tmp25_;
		_tmp25_ = lower;
		_tmp17_ = g_str_has_suffix (_tmp25_, ".7z");
	}
	if (_tmp17_) {
		_tmp16_ = TRUE;
	} else {
		const gchar* _tmp26_;
		_tmp26_ = lower;
		_tmp16_ = g_str_has_suffix (_tmp26_, ".rar");
	}
	if (_tmp16_) {
		_tmp15_ = TRUE;
	} else {
		const gchar* _tmp27_;
		_tmp27_ = lower;
		_tmp15_ = g_str_has_suffix (_tmp27_, ".bz2");
	}
	if (_tmp15_) {
		gchar* _tmp28_;
		_tmp28_ = g_strdup ("package-x-generic-symbolic");
		result = _tmp28_;
		_g_free0 (lower);
		return result;
	}
	_tmp29_ = g_strdup ("mail-attachment-symbolic");
	result = _tmp29_;
	_g_free0 (lower);
	return result;
}

static gint64
dc_compose_bar_file_size_or_zero (const gchar* file_path)
{
	gint64 _tmp4_ = -1LL;
	GError* _inner_error0_ = NULL;
	gint64 result;
	g_return_val_if_fail (file_path != NULL, -1LL);
	{
		GFileInfo* info = NULL;
		GFile* _tmp0_;
		GFile* _tmp1_;
		GFileInfo* _tmp2_;
		GFileInfo* _tmp3_;
		_tmp0_ = g_file_new_for_path (file_path);
		_tmp1_ = _tmp0_;
		_tmp2_ = g_file_query_info (_tmp1_, "standard::size", G_FILE_QUERY_INFO_NONE, NULL, &_inner_error0_);
		_tmp3_ = _tmp2_;
		_g_object_unref0 (_tmp1_);
		info = _tmp3_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
		result = g_file_info_get_size (info);
		_g_object_unref0 (info);
		return result;
	}
	goto __finally0;
	__catch0_g_error:
	{
		g_clear_error (&_inner_error0_);
		result = (gint64) 0;
		return result;
	}
	__finally0:
	g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
	g_clear_error (&_inner_error0_);
	return _tmp4_;
}

static gchar*
dc_compose_bar_format_size (gint64 bytes)
{
	gdouble v = 0.0;
	gchar** units = NULL;
	gchar* _tmp1_;
	gchar* _tmp2_;
	gchar* _tmp3_;
	gchar* _tmp4_;
	gchar** _tmp5_;
	gint units_length1;
	gint _units_size_;
	gint u = 0;
	gchar** _tmp12_;
	gint _tmp12__length1;
	const gchar* _tmp13_;
	gchar* _tmp14_;
	gchar* result;
	if (bytes <= ((gint64) 0)) {
		gchar* _tmp0_;
		_tmp0_ = g_strdup ("—");
		result = _tmp0_;
		return result;
	}
	v = (gdouble) bytes;
	_tmp1_ = g_strdup ("B");
	_tmp2_ = g_strdup ("KB");
	_tmp3_ = g_strdup ("MB");
	_tmp4_ = g_strdup ("GB");
	_tmp5_ = g_new0 (gchar*, 4 + 1);
	_tmp5_[0] = _tmp1_;
	_tmp5_[1] = _tmp2_;
	_tmp5_[2] = _tmp3_;
	_tmp5_[3] = _tmp4_;
	units = _tmp5_;
	units_length1 = 4;
	_units_size_ = units_length1;
	u = 0;
	while (TRUE) {
		gboolean _tmp6_ = FALSE;
		gint _tmp8_;
		if (v >= 1024.0) {
			gchar** _tmp7_;
			gint _tmp7__length1;
			_tmp7_ = units;
			_tmp7__length1 = units_length1;
			_tmp6_ = u < (_tmp7__length1 - 1);
		} else {
			_tmp6_ = FALSE;
		}
		if (!_tmp6_) {
			break;
		}
		v /= 1024.0;
		_tmp8_ = u;
		u = _tmp8_ + 1;
	}
	if (u == 0) {
		gchar** _tmp9_;
		gint _tmp9__length1;
		const gchar* _tmp10_;
		gchar* _tmp11_;
		_tmp9_ = units;
		_tmp9__length1 = units_length1;
		_tmp10_ = _tmp9_[u];
		_tmp11_ = g_strdup_printf ("%lld %s", (gint64) v, _tmp10_);
		result = _tmp11_;
		units = (_vala_array_free (units, units_length1, (GDestroyNotify) g_free), NULL);
		return result;
	}
	_tmp12_ = units;
	_tmp12__length1 = units_length1;
	_tmp13_ = _tmp12_[u];
	_tmp14_ = g_strdup_printf ("%.1f %s", v, _tmp13_);
	result = _tmp14_;
	units = (_vala_array_free (units, units_length1, (GDestroyNotify) g_free), NULL);
	return result;
}

static void
dc_compose_bar_clear_attachment (DcComposeBar* self)
{
	gboolean _tmp0_ = FALSE;
	GtkButton* _tmp5_;
	GtkBox* _tmp6_;
	GtkPicture* _tmp7_;
	GtkLabel* _tmp8_;
	GtkLabel* _tmp9_;
	const gchar* _tmp10_;
	GError* _inner_error0_ = NULL;
	g_return_if_fail (self != NULL);
	if (self->priv->pending_file_is_temp) {
		const gchar* _tmp1_;
		_tmp1_ = self->priv->pending_file;
		_tmp0_ = _tmp1_ != NULL;
	} else {
		_tmp0_ = FALSE;
	}
	if (_tmp0_) {
		{
			GFile* f = NULL;
			const gchar* _tmp2_;
			GFile* _tmp3_;
			GFile* _tmp4_;
			_tmp2_ = self->priv->pending_file;
			_tmp3_ = g_file_new_for_path (_tmp2_);
			f = _tmp3_;
			_tmp4_ = f;
			g_file_delete (_tmp4_, NULL, &_inner_error0_);
			if (G_UNLIKELY (_inner_error0_ != NULL)) {
				_g_object_unref0 (f);
				goto __catch0_g_error;
			}
			_g_object_unref0 (f);
		}
		goto __finally0;
		__catch0_g_error:
		{
			g_clear_error (&_inner_error0_);
		}
		__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;
		}
	}
	_g_free0 (self->priv->pending_file);
	self->priv->pending_file = NULL;
	_g_free0 (self->priv->pending_file_name);
	self->priv->pending_file_name = NULL;
	self->priv->pending_file_is_temp = FALSE;
	_tmp5_ = self->priv->cancel_attach_button;
	gtk_widget_set_visible ((GtkWidget*) _tmp5_, FALSE);
	_tmp6_ = self->priv->attachment_bar;
	gtk_widget_set_visible ((GtkWidget*) _tmp6_, FALSE);
	_tmp7_ = self->priv->attachment_picture;
	gtk_picture_set_paintable (_tmp7_, NULL);
	_tmp8_ = self->priv->attachment_name_label;
	gtk_label_set_label (_tmp8_, "");
	_tmp9_ = self->priv->attachment_meta_label;
	gtk_label_set_label (_tmp9_, "");
	_tmp10_ = self->priv->placeholder_default;
	dc_compose_bar_set_placeholder (self, _tmp10_);
}

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 void
dc_compose_bar_on_send (DcComposeBar* self)
{
	gchar* text = NULL;
	gchar* _tmp0_;
	gchar* _tmp1_;
	gchar* _tmp2_;
	gchar* _tmp3_;
	gboolean _tmp8_ = FALSE;
	const gchar* _tmp9_;
	gint _tmp10_;
	gint _tmp11_;
	gint qid = 0;
	const gchar* _tmp13_;
	const gchar* _tmp14_;
	const gchar* _tmp15_;
	g_return_if_fail (self != NULL);
	_tmp0_ = dc_compose_bar_get_text (self);
	_tmp1_ = _tmp0_;
	_tmp2_ = string_strip (_tmp1_);
	_tmp3_ = _tmp2_;
	_g_free0 (_tmp1_);
	text = _tmp3_;
	if (self->priv->editing_msg_id > 0) {
		const gchar* _tmp4_;
		gint _tmp5_;
		gint _tmp6_;
		const gchar* _tmp7_;
		_tmp4_ = text;
		_tmp5_ = strlen (_tmp4_);
		_tmp6_ = _tmp5_;
		if (_tmp6_ == 0) {
			_g_free0 (text);
			return;
		}
		_tmp7_ = text;
		g_signal_emit (self, dc_compose_bar_signals[DC_COMPOSE_BAR_EDIT_MESSAGE_SIGNAL], 0, self->priv->editing_msg_id, _tmp7_);
		dc_compose_bar_cancel_edit (self);
		_g_free0 (text);
		return;
	}
	_tmp9_ = text;
	_tmp10_ = strlen (_tmp9_);
	_tmp11_ = _tmp10_;
	if (_tmp11_ == 0) {
		const gchar* _tmp12_;
		_tmp12_ = self->priv->pending_file;
		_tmp8_ = _tmp12_ == NULL;
	} else {
		_tmp8_ = FALSE;
	}
	if (_tmp8_) {
		_g_free0 (text);
		return;
	}
	qid = self->priv->replying_msg_id;
	_tmp13_ = text;
	_tmp14_ = self->priv->pending_file;
	_tmp15_ = self->priv->pending_file_name;
	g_signal_emit (self, dc_compose_bar_signals[DC_COMPOSE_BAR_SEND_MESSAGE_SIGNAL], 0, _tmp13_, _tmp14_, _tmp15_, qid);
	dc_compose_bar_cancel_reply (self);
	self->priv->pending_file_is_temp = FALSE;
	dc_compose_bar_clear (self);
	_g_free0 (text);
}

void
dc_compose_bar_begin_reply (DcComposeBar* self,
                            gint msg_id,
                            const gchar* sender_name,
                            const gchar* preview)
{
	GtkLabel* _tmp0_;
	gchar* _tmp1_;
	gchar* _tmp2_;
	gchar* _tmp3_;
	gchar* _tmp4_;
	GtkBox* _tmp5_;
	GtkTextView* _tmp6_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (sender_name != NULL);
	g_return_if_fail (preview != NULL);
	dc_compose_bar_cancel_edit (self);
	self->priv->replying_msg_id = msg_id;
	_tmp0_ = self->priv->reply_label;
	_tmp1_ = dc_compose_bar_shorten_preview (preview);
	_tmp2_ = _tmp1_;
	_tmp3_ = g_strdup_printf ("%s: %s", sender_name, _tmp2_);
	_tmp4_ = _tmp3_;
	gtk_label_set_label (_tmp0_, _tmp4_);
	_g_free0 (_tmp4_);
	_g_free0 (_tmp2_);
	_tmp5_ = self->priv->reply_bar;
	gtk_widget_set_visible ((GtkWidget*) _tmp5_, TRUE);
	_tmp6_ = self->priv->text_view;
	gtk_widget_grab_focus ((GtkWidget*) _tmp6_);
}

static gint
string_index_of_nth_char (const gchar* self,
                          glong c)
{
	gchar* _tmp0_;
	gint result;
	g_return_val_if_fail (self != NULL, -1);
	_tmp0_ = g_utf8_offset_to_pointer (self, c);
	result = (gint) (_tmp0_ - ((gchar*) self));
	return result;
}

static glong
string_strnlen (gchar* str,
                glong maxlen)
{
	gchar* end = NULL;
	gchar* _tmp0_;
	gchar* _tmp1_;
	glong result;
	_tmp0_ = memchr (str, 0, (gsize) maxlen);
	end = _tmp0_;
	_tmp1_ = end;
	if (_tmp1_ == NULL) {
		result = maxlen;
		return result;
	} else {
		gchar* _tmp2_;
		_tmp2_ = end;
		result = (glong) (_tmp2_ - str);
		return result;
	}
}

static gchar*
string_substring (const gchar* self,
                  glong offset,
                  glong len)
{
	glong string_length = 0L;
	gboolean _tmp0_ = FALSE;
	gchar* _tmp3_;
	gchar* result;
	g_return_val_if_fail (self != NULL, NULL);
	if (offset >= ((glong) 0)) {
		_tmp0_ = len >= ((glong) 0);
	} else {
		_tmp0_ = FALSE;
	}
	if (_tmp0_) {
		string_length = string_strnlen ((gchar*) self, offset + len);
	} else {
		gint _tmp1_;
		gint _tmp2_;
		_tmp1_ = strlen (self);
		_tmp2_ = _tmp1_;
		string_length = (glong) _tmp2_;
	}
	if (offset < ((glong) 0)) {
		offset = string_length + offset;
		g_return_val_if_fail (offset >= ((glong) 0), NULL);
	} else {
		g_return_val_if_fail (offset <= string_length, NULL);
	}
	if (len < ((glong) 0)) {
		len = string_length - offset;
	}
	g_return_val_if_fail ((offset + len) <= string_length, NULL);
	_tmp3_ = g_strndup (((gchar*) self) + offset, (gsize) len);
	result = _tmp3_;
	return result;
}

static gchar*
dc_compose_bar_shorten_preview (const gchar* text)
{
	gchar** lines = NULL;
	gchar** _tmp0_;
	gchar** _tmp1_;
	gint lines_length1;
	gint _lines_size_;
	gint max_lines = 0;
	gint _tmp2_ = 0;
	gchar** _tmp3_;
	gint _tmp3__length1;
	gint n = 0;
	GString* sb = NULL;
	GString* _tmp5_;
	gchar** _tmp12_;
	gint _tmp12__length1;
	gchar* _result_ = NULL;
	GString* _tmp14_;
	const gchar* _tmp15_;
	gchar* _tmp16_;
	gint max_chars = 0;
	const gchar* _tmp17_;
	gchar* result;
	g_return_val_if_fail (text != NULL, NULL);
	_tmp1_ = _tmp0_ = g_strsplit (text, "\n", 0);
	lines = _tmp1_;
	lines_length1 = _vala_array_length (_tmp0_);
	_lines_size_ = lines_length1;
	max_lines = 3;
	_tmp3_ = lines;
	_tmp3__length1 = lines_length1;
	if (_tmp3__length1 < max_lines) {
		gchar** _tmp4_;
		gint _tmp4__length1;
		_tmp4_ = lines;
		_tmp4__length1 = lines_length1;
		_tmp2_ = _tmp4__length1;
	} else {
		_tmp2_ = max_lines;
	}
	n = _tmp2_;
	_tmp5_ = g_string_new ("");
	sb = _tmp5_;
	{
		gint i = 0;
		i = 0;
		{
			gboolean _tmp6_ = FALSE;
			_tmp6_ = TRUE;
			while (TRUE) {
				GString* _tmp9_;
				gchar** _tmp10_;
				gint _tmp10__length1;
				const gchar* _tmp11_;
				if (!_tmp6_) {
					gint _tmp7_;
					_tmp7_ = i;
					i = _tmp7_ + 1;
				}
				_tmp6_ = FALSE;
				if (!(i < n)) {
					break;
				}
				if (i > 0) {
					GString* _tmp8_;
					_tmp8_ = sb;
					g_string_append_c (_tmp8_, '\n');
				}
				_tmp9_ = sb;
				_tmp10_ = lines;
				_tmp10__length1 = lines_length1;
				_tmp11_ = _tmp10_[i];
				g_string_append (_tmp9_, _tmp11_);
			}
		}
	}
	_tmp12_ = lines;
	_tmp12__length1 = lines_length1;
	if (_tmp12__length1 > max_lines) {
		GString* _tmp13_;
		_tmp13_ = sb;
		g_string_append (_tmp13_, "…");
	}
	_tmp14_ = sb;
	_tmp15_ = _tmp14_->str;
	_tmp16_ = g_strdup (_tmp15_);
	_result_ = _tmp16_;
	max_chars = 240;
	_tmp17_ = _result_;
	if (g_utf8_strlen (_tmp17_, (gssize) -1) > max_chars) {
		gint byte_pos = 0;
		const gchar* _tmp18_;
		const gchar* _tmp19_;
		gchar* _tmp20_;
		gchar* _tmp21_;
		gchar* _tmp22_;
		_tmp18_ = _result_;
		byte_pos = string_index_of_nth_char (_tmp18_, (glong) max_chars);
		_tmp19_ = _result_;
		_tmp20_ = string_substring (_tmp19_, (glong) 0, (glong) byte_pos);
		_tmp21_ = _tmp20_;
		_tmp22_ = g_strconcat (_tmp21_, "…", NULL);
		_g_free0 (_result_);
		_result_ = _tmp22_;
		_g_free0 (_tmp21_);
	}
	result = _result_;
	_g_string_free0 (sb);
	lines = (_vala_array_free (lines, lines_length1, (GDestroyNotify) g_free), NULL);
	return result;
}

static void
dc_compose_bar_cancel_reply (DcComposeBar* self)
{
	GtkBox* _tmp0_;
	GtkLabel* _tmp1_;
	g_return_if_fail (self != NULL);
	self->priv->replying_msg_id = 0;
	_tmp0_ = self->priv->reply_bar;
	gtk_widget_set_visible ((GtkWidget*) _tmp0_, FALSE);
	_tmp1_ = self->priv->reply_label;
	gtk_label_set_label (_tmp1_, "");
}

static gboolean
__lambda29_ (DcComposeBar* self)
{
	GtkTextView* _tmp0_;
	GtkTextView* _tmp1_;
	GtkTextBuffer* _tmp2_;
	GtkTextBuffer* _tmp3_;
	GtkTextMark* _tmp4_;
	gboolean result;
	_tmp0_ = self->priv->text_view;
	_tmp1_ = self->priv->text_view;
	_tmp2_ = gtk_text_view_get_buffer (_tmp1_);
	_tmp3_ = _tmp2_;
	_tmp4_ = gtk_text_buffer_get_insert (_tmp3_);
	gtk_text_view_scroll_mark_onscreen (_tmp0_, _tmp4_);
	result = G_SOURCE_REMOVE;
	return result;
}

static gboolean
___lambda29__gsource_func (gpointer self)
{
	gboolean result;
	result = __lambda29_ ((DcComposeBar*) self);
	return result;
}

void
dc_compose_bar_begin_edit (DcComposeBar* self,
                           gint msg_id,
                           const gchar* current_text)
{
	GtkTextView* _tmp0_;
	GtkTextBuffer* _tmp1_;
	GtkTextBuffer* _tmp2_;
	GtkButton* _tmp3_;
	GtkButton* _tmp4_;
	GtkTextView* _tmp5_;
	GtkTextIter end_iter = {0};
	GtkTextView* _tmp6_;
	GtkTextBuffer* _tmp7_;
	GtkTextBuffer* _tmp8_;
	GtkTextIter _tmp9_ = {0};
	GtkTextView* _tmp10_;
	GtkTextBuffer* _tmp11_;
	GtkTextBuffer* _tmp12_;
	GtkTextIter _tmp13_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (current_text != NULL);
	dc_compose_bar_cancel_edit (self);
	dc_compose_bar_cancel_reply (self);
	dc_compose_bar_clear_attachment (self);
	self->priv->editing_msg_id = msg_id;
	_tmp0_ = self->priv->text_view;
	_tmp1_ = gtk_text_view_get_buffer (_tmp0_);
	_tmp2_ = _tmp1_;
	g_object_set (_tmp2_, "text", current_text, NULL);
	dc_compose_bar_set_placeholder (self, "Edit message…");
	_tmp3_ = self->priv->cancel_edit_button;
	gtk_widget_set_visible ((GtkWidget*) _tmp3_, TRUE);
	_tmp4_ = self->priv->attach_button;
	gtk_widget_set_sensitive ((GtkWidget*) _tmp4_, FALSE);
	_tmp5_ = self->priv->text_view;
	gtk_widget_grab_focus ((GtkWidget*) _tmp5_);
	_tmp6_ = self->priv->text_view;
	_tmp7_ = gtk_text_view_get_buffer (_tmp6_);
	_tmp8_ = _tmp7_;
	gtk_text_buffer_get_end_iter (_tmp8_, &_tmp9_);
	end_iter = _tmp9_;
	_tmp10_ = self->priv->text_view;
	_tmp11_ = gtk_text_view_get_buffer (_tmp10_);
	_tmp12_ = _tmp11_;
	_tmp13_ = end_iter;
	gtk_text_buffer_place_cursor (_tmp12_, &_tmp13_);
	g_idle_add_full (G_PRIORITY_DEFAULT_IDLE, ___lambda29__gsource_func, g_object_ref (self), g_object_unref);
}

static void
dc_compose_bar_cancel_edit (DcComposeBar* self)
{
	GtkTextView* _tmp0_;
	GtkTextBuffer* _tmp1_;
	GtkTextBuffer* _tmp2_;
	const gchar* _tmp3_;
	GtkButton* _tmp4_;
	GtkButton* _tmp5_;
	g_return_if_fail (self != NULL);
	if (self->priv->editing_msg_id == 0) {
		return;
	}
	self->priv->editing_msg_id = 0;
	_tmp0_ = self->priv->text_view;
	_tmp1_ = gtk_text_view_get_buffer (_tmp0_);
	_tmp2_ = _tmp1_;
	g_object_set (_tmp2_, "text", "", NULL);
	_tmp3_ = self->priv->placeholder_default;
	dc_compose_bar_set_placeholder (self, _tmp3_);
	_tmp4_ = self->priv->cancel_edit_button;
	gtk_widget_set_visible ((GtkWidget*) _tmp4_, FALSE);
	_tmp5_ = self->priv->attach_button;
	gtk_widget_set_sensitive ((GtkWidget*) _tmp5_, TRUE);
}

gboolean
dc_compose_bar_has_active_mode (DcComposeBar* self)
{
	gboolean _tmp0_ = FALSE;
	gboolean _tmp1_ = FALSE;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	if (self->priv->editing_msg_id != 0) {
		_tmp1_ = TRUE;
	} else {
		_tmp1_ = self->priv->replying_msg_id != 0;
	}
	if (_tmp1_) {
		_tmp0_ = TRUE;
	} else {
		const gchar* _tmp2_;
		_tmp2_ = self->priv->pending_file;
		_tmp0_ = _tmp2_ != NULL;
	}
	result = _tmp0_;
	return result;
}

gboolean
dc_compose_bar_entry_has_focus (DcComposeBar* self)
{
	GtkWindow* root = NULL;
	GtkRoot* _tmp0_;
	GtkWindow* _tmp1_;
	GtkWindow* _tmp2_;
	GtkWidget* fw = NULL;
	GtkWindow* _tmp3_;
	GtkWidget* _tmp4_;
	GtkWidget* _tmp5_;
	gboolean _tmp6_ = FALSE;
	GtkWidget* _tmp7_;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	_tmp0_ = gtk_widget_get_root ((GtkWidget*) self);
	_tmp1_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (_tmp0_, gtk_window_get_type ()) ? ((GtkWindow*) _tmp0_) : NULL);
	root = _tmp1_;
	_tmp2_ = root;
	if (_tmp2_ == NULL) {
		result = FALSE;
		_g_object_unref0 (root);
		return result;
	}
	_tmp3_ = root;
	_tmp4_ = gtk_window_get_focus (_tmp3_);
	_tmp5_ = _g_object_ref0 (_tmp4_);
	fw = _tmp5_;
	_tmp7_ = fw;
	if (_tmp7_ != NULL) {
		gboolean _tmp8_ = FALSE;
		GtkWidget* _tmp9_;
		GtkTextView* _tmp10_;
		_tmp9_ = fw;
		_tmp10_ = self->priv->text_view;
		if (_tmp9_ == G_TYPE_CHECK_INSTANCE_CAST (_tmp10_, gtk_widget_get_type (), GtkWidget)) {
			_tmp8_ = TRUE;
		} else {
			GtkWidget* _tmp11_;
			GtkTextView* _tmp12_;
			_tmp11_ = fw;
			_tmp12_ = self->priv->text_view;
			_tmp8_ = gtk_widget_is_ancestor (_tmp11_, (GtkWidget*) _tmp12_);
		}
		_tmp6_ = _tmp8_;
	} else {
		_tmp6_ = FALSE;
	}
	result = _tmp6_;
	_g_object_unref0 (fw);
	_g_object_unref0 (root);
	return result;
}

void
dc_compose_bar_cancel_active_mode (DcComposeBar* self)
{
	g_return_if_fail (self != NULL);
	dc_compose_bar_cancel_edit (self);
	dc_compose_bar_cancel_reply (self);
	dc_compose_bar_clear_attachment (self);
}

static void
dc_compose_bar_on_emoji_picked (DcComposeBar* self,
                                const gchar* emoji)
{
	GtkTextView* _tmp5_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (emoji != NULL);
	if (!dc_compose_bar_replace_emoji_trigger (self, emoji)) {
		GtkTextView* _tmp0_;
		GtkTextBuffer* _tmp1_;
		GtkTextBuffer* _tmp2_;
		gint _tmp3_;
		gint _tmp4_;
		_tmp0_ = self->priv->text_view;
		_tmp1_ = gtk_text_view_get_buffer (_tmp0_);
		_tmp2_ = _tmp1_;
		_tmp3_ = strlen (emoji);
		_tmp4_ = _tmp3_;
		gtk_text_buffer_insert_at_cursor (_tmp2_, emoji, _tmp4_);
	}
	_tmp5_ = self->priv->text_view;
	gtk_widget_grab_focus ((GtkWidget*) _tmp5_);
}

static Block21Data*
block21_data_ref (Block21Data* _data21_)
{
	g_atomic_int_inc (&_data21_->_ref_count_);
	return _data21_;
}

static void
block21_data_unref (void * _userdata_)
{
	Block21Data* _data21_;
	_data21_ = (Block21Data*) _userdata_;
	if (g_atomic_int_dec_and_test (&_data21_->_ref_count_)) {
		DcComposeBar* self;
		self = _data21_->self;
		_g_object_unref0 (_data21_->dialog);
		_g_object_unref0 (self);
		g_slice_free (Block21Data, _data21_);
	}
}

static void
__lambda22_ (Block21Data* _data21_,
             GObject* obj,
             GAsyncResult* res)
{
	DcComposeBar* self;
	GError* _inner_error0_ = NULL;
	self = _data21_->self;
	g_return_if_fail (res != NULL);
	{
		GFile* file = NULL;
		GFile* _tmp0_;
		_tmp0_ = gtk_file_dialog_open_finish (_data21_->dialog, res, &_inner_error0_);
		file = _tmp0_;
		if (G_UNLIKELY (_inner_error0_ != NULL)) {
			goto __catch0_g_error;
		}
		if (file != NULL) {
			gchar* path = NULL;
			gchar* _tmp1_;
			const gchar* _tmp2_;
			_tmp1_ = g_file_get_path (file);
			path = _tmp1_;
			_tmp2_ = path;
			if (_tmp2_ != NULL) {
				const gchar* _tmp3_;
				gchar* _tmp4_;
				gchar* _tmp5_;
				_tmp3_ = path;
				_tmp4_ = g_file_get_basename (file);
				_tmp5_ = _tmp4_;
				dc_compose_bar_set_pending_attachment (self, _tmp3_, _tmp5_);
				_g_free0 (_tmp5_);
			}
			_g_free0 (path);
		}
		_g_object_unref0 (file);
	}
	goto __finally0;
	__catch0_g_error:
	{
		g_clear_error (&_inner_error0_);
	}
	__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 void
___lambda22__gasync_ready_callback (GObject* source_object,
                                    GAsyncResult* res,
                                    gpointer self)
{
	__lambda22_ (self, source_object, res);
	block21_data_unref (self);
}

static void
dc_compose_bar_on_attach_clicked (DcComposeBar* self)
{
	Block21Data* _data21_;
	GtkFileDialog* _tmp0_;
	GtkWindow* window = NULL;
	GtkRoot* _tmp1_;
	GtkWindow* _tmp2_;
	g_return_if_fail (self != NULL);
	_data21_ = g_slice_new0 (Block21Data);
	_data21_->_ref_count_ = 1;
	_data21_->self = g_object_ref (self);
	_tmp0_ = gtk_file_dialog_new ();
	_data21_->dialog = _tmp0_;
	gtk_file_dialog_set_title (_data21_->dialog, "Select file to attach");
	_tmp1_ = gtk_widget_get_root ((GtkWidget*) self);
	_tmp2_ = _g_object_ref0 (G_TYPE_CHECK_INSTANCE_CAST (_tmp1_, gtk_window_get_type (), GtkWindow));
	window = _tmp2_;
	gtk_file_dialog_open (_data21_->dialog, window, NULL, ___lambda22__gasync_ready_callback, block21_data_ref (_data21_));
	_g_object_unref0 (window);
	block21_data_unref (_data21_);
	_data21_ = NULL;
}

static gpointer
_gdk_content_formats_ref0 (gpointer self)
{
	return self ? gdk_content_formats_ref (self) : NULL;
}

static gboolean
dc_compose_bar_on_entry_key_pressed (DcComposeBar* self,
                                     guint keyval,
                                     guint keycode,
                                     GdkModifierType state)
{
	gboolean _tmp0_ = FALSE;
	gboolean _tmp1_ = FALSE;
	gboolean _tmp2_ = FALSE;
	gboolean _tmp3_ = FALSE;
	gboolean _tmp4_ = FALSE;
	gboolean shift = FALSE;
	gboolean _tmp8_ = FALSE;
	gboolean _tmp9_ = FALSE;
	gboolean _tmp12_ = FALSE;
	gboolean primary_v = FALSE;
	gboolean _tmp14_ = FALSE;
	GdkClipboard* clipboard = NULL;
	GdkDisplay* _tmp16_;
	GdkClipboard* _tmp17_;
	GdkClipboard* _tmp18_;
	GdkContentFormats* formats = NULL;
	GdkClipboard* _tmp19_;
	GdkContentFormats* _tmp20_;
	GdkContentFormats* _tmp21_;
	gboolean has_files = FALSE;
	GdkContentFormats* _tmp22_;
	gboolean has_texture = FALSE;
	GdkContentFormats* _tmp23_;
	gboolean _tmp24_ = FALSE;
	GdkClipboard* _tmp25_;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	if (dc_compose_bar_is_plain_colon_key (keyval, state)) {
		_tmp0_ = dc_compose_bar_previous_char_is_colon (self);
	} else {
		_tmp0_ = FALSE;
	}
	if (_tmp0_) {
		dc_compose_bar_open_emoji_picker_after_typed_colon (self);
		result = FALSE;
		return result;
	}
	if (keyval == GDK_KEY_Up) {
		_tmp4_ = TRUE;
	} else {
		_tmp4_ = keyval == GDK_KEY_KP_Up;
	}
	if (_tmp4_) {
		_tmp3_ = (state & ((GDK_SHIFT_MASK | GDK_CONTROL_MASK) | GDK_ALT_MASK)) == 0;
	} else {
		_tmp3_ = FALSE;
	}
	if (_tmp3_) {
		GtkTextView* _tmp5_;
		GtkTextBuffer* _tmp6_;
		GtkTextBuffer* _tmp7_;
		_tmp5_ = self->priv->text_view;
		_tmp6_ = gtk_text_view_get_buffer (_tmp5_);
		_tmp7_ = _tmp6_;
		_tmp2_ = gtk_text_buffer_get_char_count (_tmp7_) == 0;
	} else {
		_tmp2_ = FALSE;
	}
	if (_tmp2_) {
		_tmp1_ = !dc_compose_bar_has_active_mode (self);
	} else {
		_tmp1_ = FALSE;
	}
	if (_tmp1_) {
		g_signal_emit (self, dc_compose_bar_signals[DC_COMPOSE_BAR_EDIT_LAST_REQUESTED_SIGNAL], 0);
		result = TRUE;
		return result;
	}
	shift = (state & GDK_SHIFT_MASK) != 0;
	if (keyval == GDK_KEY_Return) {
		_tmp9_ = TRUE;
	} else {
		_tmp9_ = keyval == GDK_KEY_KP_Enter;
	}
	if (_tmp9_) {
		_tmp8_ = TRUE;
	} else {
		_tmp8_ = keyval == GDK_KEY_ISO_Enter;
	}
	if (_tmp8_) {
		gboolean _tmp10_ = FALSE;
		gboolean _tmp11_;
		gboolean should_send = FALSE;
		_tmp11_ = self->priv->_shift_enter_sends;
		if (_tmp11_) {
			_tmp10_ = shift;
		} else {
			_tmp10_ = !shift;
		}
		should_send = _tmp10_;
		if (!should_send) {
			result = FALSE;
			return result;
		}
		dc_compose_bar_on_send (self);
		result = TRUE;
		return result;
	}
	if (!dc_compose_bar_can_accept_attachment (self)) {
		result = FALSE;
		return result;
	}
	if (dc_platform_has_primary_modifier (state)) {
		gboolean _tmp13_ = FALSE;
		if (keyval == GDK_KEY_v) {
			_tmp13_ = TRUE;
		} else {
			_tmp13_ = keyval == GDK_KEY_V;
		}
		_tmp12_ = _tmp13_;
	} else {
		_tmp12_ = FALSE;
	}
	primary_v = _tmp12_;
	if (!primary_v) {
		gboolean _tmp15_ = FALSE;
		if (shift) {
			_tmp15_ = keyval == GDK_KEY_Insert;
		} else {
			_tmp15_ = FALSE;
		}
		_tmp14_ = !_tmp15_;
	} else {
		_tmp14_ = FALSE;
	}
	if (_tmp14_) {
		result = FALSE;
		return result;
	}
	_tmp16_ = gtk_widget_get_display ((GtkWidget*) self);
	_tmp17_ = gdk_display_get_clipboard (_tmp16_);
	_tmp18_ = _g_object_ref0 (_tmp17_);
	clipboard = _tmp18_;
	_tmp19_ = clipboard;
	_tmp20_ = gdk_clipboard_get_formats (_tmp19_);
	_tmp21_ = _gdk_content_formats_ref0 (_tmp20_);
	formats = _tmp21_;
	_tmp22_ = formats;
	has_files = gdk_content_formats_contain_gtype (_tmp22_, gdk_file_list_get_type ());
	_tmp23_ = formats;
	has_texture = gdk_content_formats_contain_gtype (_tmp23_, gdk_texture_get_type ());
	if (!has_files) {
		_tmp24_ = !has_texture;
	} else {
		_tmp24_ = FALSE;
	}
	if (_tmp24_) {
		result = FALSE;
		_gdk_content_formats_unref0 (formats);
		_g_object_unref0 (clipboard);
		return result;
	}
	_tmp25_ = clipboard;
	dc_compose_bar_paste_from_clipboard (self, _tmp25_, has_files, has_texture, NULL, NULL);
	result = TRUE;
	_gdk_content_formats_unref0 (formats);
	_g_object_unref0 (clipboard);
	return result;
}

static gboolean
dc_compose_bar_is_plain_colon_key (guint keyval,
                                   GdkModifierType state)
{
	GdkModifierType mods = 0U;
	gboolean result;
	if (keyval != GDK_KEY_colon) {
		result = FALSE;
		return result;
	}
	mods = state & (((GDK_CONTROL_MASK | GDK_ALT_MASK) | GDK_SUPER_MASK) | GDK_META_MASK);
	result = mods == 0;
	return result;
}

static gboolean
dc_compose_bar_previous_char_is_colon (DcComposeBar* self)
{
	GtkTextIter cursor = {0};
	GtkTextIter selection_start = {0};
	GtkTextIter selection_end = {0};
	GtkTextView* _tmp0_;
	GtkTextBuffer* _tmp1_;
	GtkTextBuffer* _tmp2_;
	GtkTextIter _tmp3_ = {0};
	GtkTextIter _tmp4_ = {0};
	gboolean _tmp5_;
	GtkTextIter previous = {0};
	GtkTextIter _tmp15_;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	_tmp0_ = self->priv->text_view;
	_tmp1_ = gtk_text_view_get_buffer (_tmp0_);
	_tmp2_ = _tmp1_;
	_tmp5_ = gtk_text_buffer_get_selection_bounds (_tmp2_, &_tmp3_, &_tmp4_);
	selection_start = _tmp3_;
	selection_end = _tmp4_;
	if (_tmp5_) {
		GtkTextIter _tmp6_;
		_tmp6_ = selection_start;
		cursor = _tmp6_;
	} else {
		GtkTextView* _tmp7_;
		GtkTextBuffer* _tmp8_;
		GtkTextBuffer* _tmp9_;
		GtkTextView* _tmp10_;
		GtkTextBuffer* _tmp11_;
		GtkTextBuffer* _tmp12_;
		GtkTextMark* _tmp13_;
		GtkTextIter _tmp14_ = {0};
		_tmp7_ = self->priv->text_view;
		_tmp8_ = gtk_text_view_get_buffer (_tmp7_);
		_tmp9_ = _tmp8_;
		_tmp10_ = self->priv->text_view;
		_tmp11_ = gtk_text_view_get_buffer (_tmp10_);
		_tmp12_ = _tmp11_;
		_tmp13_ = gtk_text_buffer_get_insert (_tmp12_);
		gtk_text_buffer_get_iter_at_mark (_tmp9_, &_tmp14_, _tmp13_);
		cursor = _tmp14_;
	}
	_tmp15_ = cursor;
	previous = _tmp15_;
	if (!gtk_text_iter_backward_char (&previous)) {
		result = FALSE;
		return result;
	}
	result = gtk_text_iter_get_char (&previous) == ((gunichar) ':');
	return result;
}

static gboolean
__lambda27_ (DcComposeBar* self)
{
	gboolean _tmp0_ = FALSE;
	GtkMenuButton* _tmp1_;
	GtkPopover* _tmp2_;
	gboolean result;
	_tmp1_ = self->priv->emoji_button;
	_tmp2_ = gtk_menu_button_get_popover (_tmp1_);
	if (_tmp2_ != NULL) {
		_tmp0_ = dc_compose_bar_remember_typed_colon_trigger (self);
	} else {
		_tmp0_ = FALSE;
	}
	if (_tmp0_) {
		GtkMenuButton* _tmp3_;
		_tmp3_ = self->priv->emoji_button;
		gtk_menu_button_popup (_tmp3_);
	}
	result = G_SOURCE_REMOVE;
	return result;
}

static gboolean
___lambda27__gsource_func (gpointer self)
{
	gboolean result;
	result = __lambda27_ ((DcComposeBar*) self);
	return result;
}

static void
dc_compose_bar_open_emoji_picker_after_typed_colon (DcComposeBar* self)
{
	g_return_if_fail (self != NULL);
	g_idle_add_full (G_PRIORITY_DEFAULT_IDLE, ___lambda27__gsource_func, g_object_ref (self), g_object_unref);
}

static gboolean
dc_compose_bar_remember_typed_colon_trigger (DcComposeBar* self)
{
	GtkTextIter end = {0};
	GtkTextView* _tmp0_;
	GtkTextBuffer* _tmp1_;
	GtkTextBuffer* _tmp2_;
	GtkTextView* _tmp3_;
	GtkTextBuffer* _tmp4_;
	GtkTextBuffer* _tmp5_;
	GtkTextMark* _tmp6_;
	GtkTextIter _tmp7_ = {0};
	GtkTextIter start = {0};
	GtkTextIter _tmp8_;
	gboolean _tmp9_ = FALSE;
	GtkTextView* _tmp10_;
	GtkTextBuffer* _tmp11_;
	GtkTextBuffer* _tmp12_;
	GtkTextIter _tmp13_;
	GtkTextIter _tmp14_;
	gchar* _tmp15_;
	gchar* _tmp16_;
	gboolean _tmp17_;
	GtkTextView* _tmp18_;
	GtkTextBuffer* _tmp19_;
	GtkTextBuffer* _tmp20_;
	GtkTextIter _tmp21_;
	GtkTextView* _tmp22_;
	GtkTextBuffer* _tmp23_;
	GtkTextBuffer* _tmp24_;
	GtkTextIter _tmp25_;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	dc_compose_bar_clear_emoji_trigger_marks (self);
	_tmp0_ = self->priv->text_view;
	_tmp1_ = gtk_text_view_get_buffer (_tmp0_);
	_tmp2_ = _tmp1_;
	_tmp3_ = self->priv->text_view;
	_tmp4_ = gtk_text_view_get_buffer (_tmp3_);
	_tmp5_ = _tmp4_;
	_tmp6_ = gtk_text_buffer_get_insert (_tmp5_);
	gtk_text_buffer_get_iter_at_mark (_tmp2_, &_tmp7_, _tmp6_);
	end = _tmp7_;
	_tmp8_ = end;
	start = _tmp8_;
	if (!gtk_text_iter_backward_char (&start)) {
		_tmp9_ = TRUE;
	} else {
		_tmp9_ = !gtk_text_iter_backward_char (&start);
	}
	if (_tmp9_) {
		result = FALSE;
		return result;
	}
	_tmp10_ = self->priv->text_view;
	_tmp11_ = gtk_text_view_get_buffer (_tmp10_);
	_tmp12_ = _tmp11_;
	_tmp13_ = start;
	_tmp14_ = end;
	_tmp15_ = gtk_text_buffer_get_text (_tmp12_, &_tmp13_, &_tmp14_, FALSE);
	_tmp16_ = _tmp15_;
	_tmp17_ = g_strcmp0 (_tmp16_, "::") != 0;
	_g_free0 (_tmp16_);
	if (_tmp17_) {
		result = FALSE;
		return result;
	}
	_tmp18_ = self->priv->text_view;
	_tmp19_ = gtk_text_view_get_buffer (_tmp18_);
	_tmp20_ = _tmp19_;
	_tmp21_ = start;
	gtk_text_buffer_create_mark (_tmp20_, DC_COMPOSE_BAR_EMOJI_TRIGGER_START_MARK, &_tmp21_, TRUE);
	_tmp22_ = self->priv->text_view;
	_tmp23_ = gtk_text_view_get_buffer (_tmp22_);
	_tmp24_ = _tmp23_;
	_tmp25_ = end;
	gtk_text_buffer_create_mark (_tmp24_, DC_COMPOSE_BAR_EMOJI_TRIGGER_END_MARK, &_tmp25_, FALSE);
	result = TRUE;
	return result;
}

static gboolean
dc_compose_bar_replace_emoji_trigger (DcComposeBar* self,
                                      const gchar* emoji)
{
	GtkTextMark* start_mark = NULL;
	GtkTextView* _tmp0_;
	GtkTextBuffer* _tmp1_;
	GtkTextBuffer* _tmp2_;
	GtkTextMark* _tmp3_;
	GtkTextMark* _tmp4_;
	GtkTextMark* end_mark = NULL;
	GtkTextView* _tmp5_;
	GtkTextBuffer* _tmp6_;
	GtkTextBuffer* _tmp7_;
	GtkTextMark* _tmp8_;
	GtkTextMark* _tmp9_;
	gboolean _tmp10_ = FALSE;
	GtkTextMark* _tmp11_;
	GtkTextIter start = {0};
	GtkTextIter end = {0};
	GtkTextView* _tmp13_;
	GtkTextBuffer* _tmp14_;
	GtkTextBuffer* _tmp15_;
	GtkTextMark* _tmp16_;
	GtkTextIter _tmp17_ = {0};
	GtkTextView* _tmp18_;
	GtkTextBuffer* _tmp19_;
	GtkTextBuffer* _tmp20_;
	GtkTextMark* _tmp21_;
	GtkTextIter _tmp22_ = {0};
	gboolean _tmp23_ = FALSE;
	GtkTextIter _tmp24_;
	GtkTextView* _tmp32_;
	GtkTextBuffer* _tmp33_;
	GtkTextBuffer* _tmp34_;
	GtkTextView* _tmp35_;
	GtkTextBuffer* _tmp36_;
	GtkTextBuffer* _tmp37_;
	gint _tmp38_;
	gint _tmp39_;
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	g_return_val_if_fail (emoji != NULL, FALSE);
	_tmp0_ = self->priv->text_view;
	_tmp1_ = gtk_text_view_get_buffer (_tmp0_);
	_tmp2_ = _tmp1_;
	_tmp3_ = gtk_text_buffer_get_mark (_tmp2_, DC_COMPOSE_BAR_EMOJI_TRIGGER_START_MARK);
	_tmp4_ = _g_object_ref0 (_tmp3_);
	start_mark = _tmp4_;
	_tmp5_ = self->priv->text_view;
	_tmp6_ = gtk_text_view_get_buffer (_tmp5_);
	_tmp7_ = _tmp6_;
	_tmp8_ = gtk_text_buffer_get_mark (_tmp7_, DC_COMPOSE_BAR_EMOJI_TRIGGER_END_MARK);
	_tmp9_ = _g_object_ref0 (_tmp8_);
	end_mark = _tmp9_;
	_tmp11_ = start_mark;
	if (_tmp11_ == NULL) {
		_tmp10_ = TRUE;
	} else {
		GtkTextMark* _tmp12_;
		_tmp12_ = end_mark;
		_tmp10_ = _tmp12_ == NULL;
	}
	if (_tmp10_) {
		result = FALSE;
		_g_object_unref0 (end_mark);
		_g_object_unref0 (start_mark);
		return result;
	}
	_tmp13_ = self->priv->text_view;
	_tmp14_ = gtk_text_view_get_buffer (_tmp13_);
	_tmp15_ = _tmp14_;
	_tmp16_ = start_mark;
	gtk_text_buffer_get_iter_at_mark (_tmp15_, &_tmp17_, _tmp16_);
	start = _tmp17_;
	_tmp18_ = self->priv->text_view;
	_tmp19_ = gtk_text_view_get_buffer (_tmp18_);
	_tmp20_ = _tmp19_;
	_tmp21_ = end_mark;
	gtk_text_buffer_get_iter_at_mark (_tmp20_, &_tmp22_, _tmp21_);
	end = _tmp22_;
	_tmp24_ = end;
	if (gtk_text_iter_compare (&start, &_tmp24_) >= 0) {
		_tmp23_ = TRUE;
	} else {
		GtkTextView* _tmp25_;
		GtkTextBuffer* _tmp26_;
		GtkTextBuffer* _tmp27_;
		GtkTextIter _tmp28_;
		GtkTextIter _tmp29_;
		gchar* _tmp30_;
		gchar* _tmp31_;
		_tmp25_ = self->priv->text_view;
		_tmp26_ = gtk_text_view_get_buffer (_tmp25_);
		_tmp27_ = _tmp26_;
		_tmp28_ = start;
		_tmp29_ = end;
		_tmp30_ = gtk_text_buffer_get_text (_tmp27_, &_tmp28_, &_tmp29_, FALSE);
		_tmp31_ = _tmp30_;
		_tmp23_ = g_strcmp0 (_tmp31_, "::") != 0;
		_g_free0 (_tmp31_);
	}
	if (_tmp23_) {
		dc_compose_bar_clear_emoji_trigger_marks (self);
		result = FALSE;
		_g_object_unref0 (end_mark);
		_g_object_unref0 (start_mark);
		return result;
	}
	_tmp32_ = self->priv->text_view;
	_tmp33_ = gtk_text_view_get_buffer (_tmp32_);
	_tmp34_ = _tmp33_;
	gtk_text_buffer_delete (_tmp34_, &start, &end);
	_tmp35_ = self->priv->text_view;
	_tmp36_ = gtk_text_view_get_buffer (_tmp35_);
	_tmp37_ = _tmp36_;
	_tmp38_ = strlen (emoji);
	_tmp39_ = _tmp38_;
	gtk_text_buffer_insert (_tmp37_, &start, emoji, _tmp39_);
	dc_compose_bar_clear_emoji_trigger_marks (self);
	result = TRUE;
	_g_object_unref0 (end_mark);
	_g_object_unref0 (start_mark);
	return result;
}

static void
dc_compose_bar_clear_emoji_trigger_marks (DcComposeBar* self)
{
	GtkTextMark* start_mark = NULL;
	GtkTextView* _tmp0_;
	GtkTextBuffer* _tmp1_;
	GtkTextBuffer* _tmp2_;
	GtkTextMark* _tmp3_;
	GtkTextMark* _tmp4_;
	GtkTextMark* _tmp5_;
	GtkTextMark* end_mark = NULL;
	GtkTextView* _tmp10_;
	GtkTextBuffer* _tmp11_;
	GtkTextBuffer* _tmp12_;
	GtkTextMark* _tmp13_;
	GtkTextMark* _tmp14_;
	GtkTextMark* _tmp15_;
	g_return_if_fail (self != NULL);
	_tmp0_ = self->priv->text_view;
	_tmp1_ = gtk_text_view_get_buffer (_tmp0_);
	_tmp2_ = _tmp1_;
	_tmp3_ = gtk_text_buffer_get_mark (_tmp2_, DC_COMPOSE_BAR_EMOJI_TRIGGER_START_MARK);
	_tmp4_ = _g_object_ref0 (_tmp3_);
	start_mark = _tmp4_;
	_tmp5_ = start_mark;
	if (_tmp5_ != NULL) {
		GtkTextView* _tmp6_;
		GtkTextBuffer* _tmp7_;
		GtkTextBuffer* _tmp8_;
		GtkTextMark* _tmp9_;
		_tmp6_ = self->priv->text_view;
		_tmp7_ = gtk_text_view_get_buffer (_tmp6_);
		_tmp8_ = _tmp7_;
		_tmp9_ = start_mark;
		gtk_text_buffer_delete_mark (_tmp8_, _tmp9_);
	}
	_tmp10_ = self->priv->text_view;
	_tmp11_ = gtk_text_view_get_buffer (_tmp10_);
	_tmp12_ = _tmp11_;
	_tmp13_ = gtk_text_buffer_get_mark (_tmp12_, DC_COMPOSE_BAR_EMOJI_TRIGGER_END_MARK);
	_tmp14_ = _g_object_ref0 (_tmp13_);
	end_mark = _tmp14_;
	_tmp15_ = end_mark;
	if (_tmp15_ != NULL) {
		GtkTextView* _tmp16_;
		GtkTextBuffer* _tmp17_;
		GtkTextBuffer* _tmp18_;
		GtkTextMark* _tmp19_;
		_tmp16_ = self->priv->text_view;
		_tmp17_ = gtk_text_view_get_buffer (_tmp16_);
		_tmp18_ = _tmp17_;
		_tmp19_ = end_mark;
		gtk_text_buffer_delete_mark (_tmp18_, _tmp19_);
	}
	_g_object_unref0 (end_mark);
	_g_object_unref0 (start_mark);
}

static void
dc_compose_bar_paste_from_clipboard_data_free (gpointer _data)
{
	DcComposeBarPasteFromClipboardData* _data_;
	_data_ = _data;
	_g_object_unref0 (_data_->clipboard);
	_g_object_unref0 (_data_->self);
	g_slice_free (DcComposeBarPasteFromClipboardData, _data_);
}

static void
dc_compose_bar_paste_from_clipboard (DcComposeBar* self,
                                     GdkClipboard* clipboard,
                                     gboolean try_files,
                                     gboolean try_texture,
                                     GAsyncReadyCallback _callback_,
                                     gpointer _user_data_)
{
	DcComposeBarPasteFromClipboardData* _data_;
	DcComposeBar* _tmp0_;
	GdkClipboard* _tmp1_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (clipboard != NULL);
	_data_ = g_slice_new0 (DcComposeBarPasteFromClipboardData);
	_data_->_async_result = g_task_new (G_OBJECT (self), NULL, _callback_, _user_data_);
	g_task_set_task_data (_data_->_async_result, _data_, dc_compose_bar_paste_from_clipboard_data_free);
	_tmp0_ = _g_object_ref0 (self);
	_data_->self = _tmp0_;
	_tmp1_ = _g_object_ref0 (clipboard);
	_g_object_unref0 (_data_->clipboard);
	_data_->clipboard = _tmp1_;
	_data_->try_files = try_files;
	_data_->try_texture = try_texture;
	dc_compose_bar_paste_from_clipboard_co (_data_);
}

static void
dc_compose_bar_paste_from_clipboard_finish (DcComposeBar* self,
                                            GAsyncResult* _res_)
{
	DcComposeBarPasteFromClipboardData* _data_;
	_data_ = g_task_propagate_pointer (G_TASK (_res_), NULL);
}

static void
dc_compose_bar_paste_from_clipboard_ready (GObject* source_object,
                                           GAsyncResult* _res_,
                                           gpointer _user_data_)
{
	DcComposeBarPasteFromClipboardData* _data_;
	_data_ = _user_data_;
	_data_->_source_object_ = source_object;
	_data_->_res_ = _res_;
	dc_compose_bar_paste_from_clipboard_co (_data_);
}

static GValue*
_g_value_dup (GValue* self)
{
	return g_boxed_copy (G_TYPE_VALUE, self);
}

static gpointer
__g_value_dup0 (gpointer self)
{
	return self ? _g_value_dup (self) : NULL;
}

static GdkFileList*
_vala_GdkFileList_copy (GdkFileList* self)
{
	return g_boxed_copy (gdk_file_list_get_type (), self);
}

static gpointer
__vala_GdkFileList_copy0 (gpointer self)
{
	return self ? _vala_GdkFileList_copy (self) : NULL;
}

static void
_vala_GdkFileList_free (GdkFileList* self)
{
	g_boxed_free (gdk_file_list_get_type (), self);
}

static void
_vala_GValue_free (GValue* self)
{
	g_boxed_free (G_TYPE_VALUE, self);
}

static gboolean
dc_compose_bar_paste_from_clipboard_co (DcComposeBarPasteFromClipboardData* _data_)
{
	switch (_data_->_state_) {
		case 0:
		goto _state_0;
		case 1:
		goto _state_1;
		case 2:
		goto _state_2;
		default:
		g_assert_not_reached ();
	}
	_state_0:
	if (_data_->try_files) {
		{
			_data_->_state_ = 1;
			gdk_clipboard_read_value_async (_data_->clipboard, gdk_file_list_get_type (), G_PRIORITY_DEFAULT, NULL, dc_compose_bar_paste_from_clipboard_ready, _data_);
			return FALSE;
			_state_1:
			_data_->_tmp0_ = __g_value_dup0 (gdk_clipboard_read_value_finish (_data_->clipboard, _data_->_res_, &_data_->_inner_error0_));
			_data_->value = _data_->_tmp0_;
			if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
				goto __catch0_g_error;
			}
			_data_->_tmp2_ = _data_->value;
			if (((gpointer) _data_->_tmp2_) == NULL) {
				_data_->_tmp1_ = NULL;
			} else {
				_data_->_tmp3_ = _data_->value;
				_data_->_tmp4_ = g_value_get_boxed (_data_->_tmp3_);
				_data_->_tmp1_ = (GdkFileList*) _data_->_tmp4_;
			}
			_data_->_tmp5_ = __vala_GdkFileList_copy0 (_data_->_tmp1_);
			_data_->fl = _data_->_tmp5_;
			_data_->_tmp8_ = _data_->fl;
			if (_data_->_tmp8_ == NULL) {
				_data_->_tmp7_ = TRUE;
			} else {
				_data_->_tmp9_ = _data_->fl;
				_data_->_tmp10_ = gdk_file_list_get_files (_data_->_tmp9_);
				_data_->_tmp11_ = _data_->_tmp10_;
				_data_->_tmp7_ = _data_->_tmp11_ == NULL;
				(_data_->_tmp11_ == NULL) ? NULL : (_data_->_tmp11_ = (g_slist_free (_data_->_tmp11_), NULL));
			}
			if (_data_->_tmp7_) {
				_data_->_tmp6_ = NULL;
			} else {
				_data_->_tmp12_ = _data_->fl;
				_data_->_tmp13_ = gdk_file_list_get_files (_data_->_tmp12_);
				_data_->_tmp14_ = _data_->_tmp13_;
				_data_->_tmp15_ = _data_->_tmp14_->data;
				_data_->_tmp6_ = (GFile*) _data_->_tmp15_;
				(_data_->_tmp14_ == NULL) ? NULL : (_data_->_tmp14_ = (g_slist_free (_data_->_tmp14_), NULL));
			}
			_data_->_tmp16_ = _g_object_ref0 (_data_->_tmp6_);
			_data_->gf = _data_->_tmp16_;
			_data_->_tmp18_ = _data_->gf;
			if (_data_->_tmp18_ == NULL) {
				_g_free0 (_data_->_tmp17_);
				_data_->_tmp17_ = NULL;
			} else {
				_data_->_tmp19_ = _data_->gf;
				_data_->_tmp20_ = g_file_get_path (_data_->_tmp19_);
				_g_free0 (_data_->_tmp17_);
				_data_->_tmp17_ = _data_->_tmp20_;
			}
			_data_->_tmp21_ = _data_->_tmp17_;
			_data_->_tmp17_ = NULL;
			_data_->path = _data_->_tmp21_;
			_data_->_tmp23_ = _data_->path;
			if (_data_->_tmp23_ != NULL) {
				_data_->_tmp24_ = _data_->path;
				_data_->_tmp22_ = g_file_test (_data_->_tmp24_, G_FILE_TEST_EXISTS);
			} else {
				_data_->_tmp22_ = FALSE;
			}
			if (_data_->_tmp22_) {
				_data_->_tmp25_ = _data_->path;
				_data_->_tmp26_ = _data_->gf;
				_data_->_tmp27_ = g_file_get_basename (_data_->_tmp26_);
				_data_->_tmp28_ = _data_->_tmp27_;
				dc_compose_bar_set_pending_attachment (_data_->self, _data_->_tmp25_, _data_->_tmp28_);
				_g_free0 (_data_->_tmp28_);
				_g_free0 (_data_->path);
				_g_free0 (_data_->_tmp17_);
				_g_object_unref0 (_data_->gf);
				__vala_GdkFileList_free0 (_data_->fl);
				__vala_GValue_free0 (_data_->value);
				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;
			}
			_g_free0 (_data_->path);
			_g_free0 (_data_->_tmp17_);
			_g_object_unref0 (_data_->gf);
			__vala_GdkFileList_free0 (_data_->fl);
			__vala_GValue_free0 (_data_->value);
		}
		goto __finally0;
		__catch0_g_error:
		{
			g_clear_error (&_data_->_inner_error0_);
		}
		__finally0:
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _data_->_inner_error0_->message, g_quark_to_string (_data_->_inner_error0_->domain), _data_->_inner_error0_->code);
			g_clear_error (&_data_->_inner_error0_);
			g_object_unref (_data_->_async_result);
			return FALSE;
		}
	}
	if (!_data_->try_texture) {
		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;
	}
	{
		_data_->_state_ = 2;
		gdk_clipboard_read_texture_async (_data_->clipboard, NULL, dc_compose_bar_paste_from_clipboard_ready, _data_);
		return FALSE;
		_state_2:
		_data_->_tmp29_ = gdk_clipboard_read_texture_finish (_data_->clipboard, _data_->_res_, &_data_->_inner_error0_);
		_data_->texture = _data_->_tmp29_;
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			goto __catch1_g_error;
		}
		_data_->_tmp30_ = _data_->texture;
		if (_data_->_tmp30_ == NULL) {
			_g_object_unref0 (_data_->texture);
			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;
		}
		_data_->_tmp31_ = NULL;
		_data_->_tmp32_ = g_file_new_tmp ("parla-XXXXXX.png", &_data_->_tmp31_, &_data_->_inner_error0_);
		_g_object_unref0 (_data_->stream);
		_data_->stream = _data_->_tmp31_;
		_data_->tmp = _data_->_tmp32_;
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			_g_object_unref0 (_data_->stream);
			_g_object_unref0 (_data_->texture);
			goto __catch1_g_error;
		}
		_data_->_tmp33_ = _data_->stream;
		g_io_stream_close ((GIOStream*) _data_->_tmp33_, NULL, &_data_->_inner_error0_);
		if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
			_g_object_unref0 (_data_->tmp);
			_g_object_unref0 (_data_->stream);
			_g_object_unref0 (_data_->texture);
			goto __catch1_g_error;
		}
		_data_->_tmp34_ = _data_->texture;
		_data_->_tmp35_ = _data_->tmp;
		_data_->_tmp36_ = g_file_get_path (_data_->_tmp35_);
		_data_->_tmp37_ = _data_->_tmp36_;
		_data_->_tmp38_ = gdk_texture_save_to_png (_data_->_tmp34_, _data_->_tmp37_);
		_g_free0 (_data_->_tmp37_);
		if (_data_->_tmp38_) {
			_data_->_tmp39_ = _data_->tmp;
			_data_->_tmp40_ = g_file_get_path (_data_->_tmp39_);
			_data_->_tmp41_ = _data_->_tmp40_;
			dc_compose_bar_set_pending_attachment (_data_->self, _data_->_tmp41_, "pasted-image.png");
			_g_free0 (_data_->_tmp41_);
			_data_->self->priv->pending_file_is_temp = TRUE;
		}
		_g_object_unref0 (_data_->tmp);
		_g_object_unref0 (_data_->stream);
		_g_object_unref0 (_data_->texture);
	}
	goto __finally1;
	__catch1_g_error:
	{
		g_clear_error (&_data_->_inner_error0_);
	}
	__finally1:
	if (G_UNLIKELY (_data_->_inner_error0_ != NULL)) {
		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _data_->_inner_error0_->message, g_quark_to_string (_data_->_inner_error0_->domain), _data_->_inner_error0_->code);
		g_clear_error (&_data_->_inner_error0_);
		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)) {
			g_main_context_iteration (g_task_get_context (_data_->_async_result), TRUE);
		}
	}
	g_object_unref (_data_->_async_result);
	return FALSE;
}

gboolean
dc_compose_bar_get_shift_enter_sends (DcComposeBar* self)
{
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	result = self->priv->_shift_enter_sends;
	return result;
}

void
dc_compose_bar_set_shift_enter_sends (DcComposeBar* self,
                                      gboolean value)
{
	gboolean old_value;
	g_return_if_fail (self != NULL);
	old_value = dc_compose_bar_get_shift_enter_sends (self);
	if (old_value != value) {
		self->priv->_shift_enter_sends = value;
		g_object_notify_by_pspec ((GObject *) self, dc_compose_bar_properties[DC_COMPOSE_BAR_SHIFT_ENTER_SENDS_PROPERTY]);
	}
}

static void
g_cclosure_user_marshal_VOID__STRING_STRING_STRING_INT (GClosure * closure,
                                                        GValue * return_value,
                                                        guint n_param_values,
                                                        const GValue * param_values,
                                                        gpointer invocation_hint,
                                                        gpointer marshal_data)
{
	typedef void (*GMarshalFunc_VOID__STRING_STRING_STRING_INT) (gpointer data1, const char* arg_1, const char* arg_2, const char* arg_3, gint arg_4, gpointer data2);
	register GMarshalFunc_VOID__STRING_STRING_STRING_INT callback;
	register GCClosure * cc;
	register gpointer data1;
	register gpointer data2;
	cc = (GCClosure *) closure;
	g_return_if_fail (n_param_values == 5);
	if (G_CCLOSURE_SWAP_DATA (closure)) {
		data1 = closure->data;
		data2 = param_values->data[0].v_pointer;
	} else {
		data1 = param_values->data[0].v_pointer;
		data2 = closure->data;
	}
	callback = (GMarshalFunc_VOID__STRING_STRING_STRING_INT) (marshal_data ? marshal_data : cc->callback);
	callback (data1, g_value_get_string (param_values + 1), g_value_get_string (param_values + 2), g_value_get_string (param_values + 3), g_value_get_int (param_values + 4), data2);
}

static void
g_cclosure_user_marshal_VOID__INT_STRING (GClosure * closure,
                                          GValue * return_value,
                                          guint n_param_values,
                                          const GValue * param_values,
                                          gpointer invocation_hint,
                                          gpointer marshal_data)
{
	typedef void (*GMarshalFunc_VOID__INT_STRING) (gpointer data1, gint arg_1, const char* arg_2, gpointer data2);
	register GMarshalFunc_VOID__INT_STRING callback;
	register GCClosure * cc;
	register gpointer data1;
	register gpointer data2;
	cc = (GCClosure *) closure;
	g_return_if_fail (n_param_values == 3);
	if (G_CCLOSURE_SWAP_DATA (closure)) {
		data1 = closure->data;
		data2 = param_values->data[0].v_pointer;
	} else {
		data1 = param_values->data[0].v_pointer;
		data2 = closure->data;
	}
	callback = (GMarshalFunc_VOID__INT_STRING) (marshal_data ? marshal_data : cc->callback);
	callback (data1, g_value_get_int (param_values + 1), g_value_get_string (param_values + 2), data2);
}

static void
dc_compose_bar_class_init (DcComposeBarClass * klass,
                           gpointer klass_data)
{
	dc_compose_bar_parent_class = g_type_class_peek_parent (klass);
	g_type_class_adjust_private_offset (klass, &DcComposeBar_private_offset);
	G_OBJECT_CLASS (klass)->get_property = _vala_dc_compose_bar_get_property;
	G_OBJECT_CLASS (klass)->set_property = _vala_dc_compose_bar_set_property;
	G_OBJECT_CLASS (klass)->finalize = dc_compose_bar_finalize;
	g_object_class_install_property (G_OBJECT_CLASS (klass), DC_COMPOSE_BAR_SHIFT_ENTER_SENDS_PROPERTY, dc_compose_bar_properties[DC_COMPOSE_BAR_SHIFT_ENTER_SENDS_PROPERTY] = g_param_spec_boolean ("shift-enter-sends", "shift-enter-sends", "shift-enter-sends", FALSE, G_PARAM_STATIC_STRINGS | G_PARAM_READABLE | G_PARAM_WRITABLE));
	dc_compose_bar_signals[DC_COMPOSE_BAR_SEND_MESSAGE_SIGNAL] = g_signal_new ("send-message", DC_TYPE_COMPOSE_BAR, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_user_marshal_VOID__STRING_STRING_STRING_INT, G_TYPE_NONE, 4, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_STRING, G_TYPE_INT);
	dc_compose_bar_signals[DC_COMPOSE_BAR_EDIT_MESSAGE_SIGNAL] = g_signal_new ("edit-message", DC_TYPE_COMPOSE_BAR, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_user_marshal_VOID__INT_STRING, G_TYPE_NONE, 2, G_TYPE_INT, G_TYPE_STRING);
	dc_compose_bar_signals[DC_COMPOSE_BAR_EDIT_LAST_REQUESTED_SIGNAL] = g_signal_new ("edit-last-requested", DC_TYPE_COMPOSE_BAR, G_SIGNAL_RUN_LAST, 0, NULL, NULL, g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
}

static void
dc_compose_bar_instance_init (DcComposeBar * self,
                              gpointer klass)
{
	gchar* _tmp0_;
	self->priv = dc_compose_bar_get_instance_private (self);
	self->priv->_shift_enter_sends = FALSE;
	_tmp0_ = g_strdup ("Type a message…");
	self->priv->placeholder_default = _tmp0_;
	self->priv->pending_file = NULL;
	self->priv->pending_file_name = NULL;
	self->priv->pending_file_is_temp = FALSE;
	self->priv->editing_msg_id = 0;
	self->priv->replying_msg_id = 0;
}

static void
dc_compose_bar_finalize (GObject * obj)
{
	DcComposeBar * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, DC_TYPE_COMPOSE_BAR, DcComposeBar);
	_g_object_unref0 (self->priv->text_view);
	_g_object_unref0 (self->priv->placeholder_label);
	_g_free0 (self->priv->placeholder_default);
	_g_object_unref0 (self->priv->send_button);
	_g_object_unref0 (self->priv->attach_button);
	_g_object_unref0 (self->priv->emoji_button);
	_g_object_unref0 (self->priv->cancel_attach_button);
	_g_object_unref0 (self->priv->cancel_edit_button);
	_g_object_unref0 (self->priv->cancel_reply_button);
	_g_object_unref0 (self->priv->reply_label);
	_g_object_unref0 (self->priv->reply_bar);
	_g_object_unref0 (self->priv->attachment_bar);
	_g_object_unref0 (self->priv->attachment_picture);
	_g_object_unref0 (self->priv->attachment_icon);
	_g_object_unref0 (self->priv->attachment_name_label);
	_g_object_unref0 (self->priv->attachment_meta_label);
	_g_object_unref0 (self->priv->attachment_close_button);
	_g_free0 (self->priv->pending_file);
	_g_free0 (self->priv->pending_file_name);
	G_OBJECT_CLASS (dc_compose_bar_parent_class)->finalize (obj);
}

/**
     * Compose bar at the bottom of the message view.
     * Contains a text entry, file attach button, and send button.
     */
static GType
dc_compose_bar_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (DcComposeBarClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) dc_compose_bar_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (DcComposeBar), 0, (GInstanceInitFunc) dc_compose_bar_instance_init, NULL };
	GType dc_compose_bar_type_id;
	dc_compose_bar_type_id = g_type_register_static (gtk_box_get_type (), "DcComposeBar", &g_define_type_info, 0);
	DcComposeBar_private_offset = g_type_add_instance_private (dc_compose_bar_type_id, sizeof (DcComposeBarPrivate));
	return dc_compose_bar_type_id;
}

GType
dc_compose_bar_get_type (void)
{
	static volatile gsize dc_compose_bar_type_id__once = 0;
	if (g_once_init_enter (&dc_compose_bar_type_id__once)) {
		GType dc_compose_bar_type_id;
		dc_compose_bar_type_id = dc_compose_bar_get_type_once ();
		g_once_init_leave (&dc_compose_bar_type_id__once, dc_compose_bar_type_id);
	}
	return dc_compose_bar_type_id__once;
}

static void
_vala_dc_compose_bar_get_property (GObject * object,
                                   guint property_id,
                                   GValue * value,
                                   GParamSpec * pspec)
{
	DcComposeBar * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, DC_TYPE_COMPOSE_BAR, DcComposeBar);
	switch (property_id) {
		case DC_COMPOSE_BAR_SHIFT_ENTER_SENDS_PROPERTY:
		g_value_set_boolean (value, dc_compose_bar_get_shift_enter_sends (self));
		break;
		default:
		G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
		break;
	}
}

static void
_vala_dc_compose_bar_set_property (GObject * object,
                                   guint property_id,
                                   const GValue * value,
                                   GParamSpec * pspec)
{
	DcComposeBar * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (object, DC_TYPE_COMPOSE_BAR, DcComposeBar);
	switch (property_id) {
		case DC_COMPOSE_BAR_SHIFT_ENTER_SENDS_PROPERTY:
		dc_compose_bar_set_shift_enter_sends (self, g_value_get_boolean (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);
}

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

